]> git.sur5r.net Git - freertos/blob - FreeRTOS-Plus/Demo/FreeRTOS_Plus_UDP_and_CLI_Windows_Simulator/FreeRTOSIPConfig.h
Update copyright date ready for tagging V10.1.0.
[freertos] / FreeRTOS-Plus / Demo / FreeRTOS_Plus_UDP_and_CLI_Windows_Simulator / FreeRTOSIPConfig.h
1 /*\r
2  * FreeRTOS+UDP V1.0.4\r
3  * Copyright (C) 2017 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
4  *\r
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
6  * this software and associated documentation files (the "Software"), to deal in\r
7  * the Software without restriction, including without limitation the rights to\r
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r
9  * the Software, and to permit persons to whom the Software is furnished to do so,\r
10  * subject to the following conditions:\r
11  *\r
12  * The above copyright notice and this permission notice shall be included in all\r
13  * copies or substantial portions of the Software.\r
14  *\r
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
21  *\r
22  * http://www.FreeRTOS.org\r
23  * http://aws.amazon.com/freertos\r
24  *\r
25  * 1 tab == 4 spaces!\r
26  */\r
27 \r
28 /*****************************************************************************\r
29  *\r
30  * See the following URL for configuration information.\r
31  * http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_UDP/UDP_IP_Configuration.shtml\r
32  *\r
33  *****************************************************************************/\r
34 \r
35 #ifndef FREERTOS_IP_CONFIG_H\r
36 #define FREERTOS_IP_CONFIG_H\r
37 \r
38 /* The IP stack executes it its own task (although any application task can make\r
39 use of its services through the published sockets API). ipconfigUDP_TASK_PRIORITY\r
40 sets the priority of the task that executes the IP stack.  The priority is a\r
41 standard FreeRTOS task priority so can take any value from 0 (the lowest\r
42 priority) to (configMAX_PRIORITIES - 1) (the highest priority).\r
43 configMAX_PRIORITIES is a standard FreeRTOS configuration parameter defined in\r
44 FreeRTOSConfig.h, not FreeRTOSIPConfig.h. Consideration needs to be given as to\r
45 the priority assigned to the task executing the IP stack relative to the\r
46 priority assigned to tasks that use the IP stack. */\r
47 #define ipconfigUDP_TASK_PRIORITY                       ( configMAX_PRIORITIES - 2 )\r
48 \r
49 /* The size, in words (not bytes), of the stack allocated to the FreeRTOS+UDP\r
50 task.  This setting is less important when the FreeRTOS Win32 simulator is used\r
51 as the Win32 simulator only stores a fixed amount of information on the task\r
52 stack.  FreeRTOS includes optional stack overflow detection, see:\r
53 http://www.freertos.org/Stacks-and-stack-overflow-checking.html */\r
54 #define ipconfigUDP_TASK_STACK_SIZE_WORDS       ( configMINIMAL_STACK_SIZE * 5 )\r
55 \r
56 /* ipconfigRAND32() is called by the IP stack to generate a random number that\r
57 is then used as a DHCP transaction number.  Random number generation is performed\r
58 via this macro to allow applications to use their own random number generation\r
59 method.  For example, it might be possible to generate a random number by\r
60 sampling noise on an analogue input. */\r
61 #define ipconfigRAND32()        1\r
62 \r
63 /* If ipconfigUSE_NETWORK_EVENT_HOOK is set to 1 then FreeRTOS+UDP will call the\r
64 network event hook at the appropriate times.  If ipconfigUSE_NETWORK_EVENT_HOOK\r
65 is not set to 1 then the network event hook will never be called.  See\r
66 http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_UDP/API/vApplicationIPNetworkEventHook.shtml\r
67 */\r
68 #define ipconfigUSE_NETWORK_EVENT_HOOK 1\r
69 \r
70 /* Sockets have a send block time attribute.  If FreeRTOS_sendto() is called but\r
71 a network buffer cannot be obtained then the calling task is held in the Blocked\r
72 state (so other tasks can continue to executed) until either a network buffer\r
73 becomes available or the send block time expires.  If the send block time expires\r
74 then the send operation is aborted.  The maximum allowable send block time is\r
75 capped to the value set by ipconfigMAX_SEND_BLOCK_TIME_TICKS.  Capping the\r
76 maximum allowable send block time prevents prevents a deadlock occurring when\r
77 all the network buffers are in use and the tasks that process (and subsequently\r
78 free) the network buffers are themselves blocked waiting for a network buffer.\r
79 ipconfigMAX_SEND_BLOCK_TIME_TICKS is specified in RTOS ticks.  A time in\r
80 milliseconds can be converted to a time in ticks by dividing the time in\r
81 milliseconds by portTICK_RATE_MS. */\r
82 #define ipconfigMAX_SEND_BLOCK_TIME_TICKS ( 20 / portTICK_RATE_MS )\r
83 \r
84 /* If ipconfigUSE_DHCP is 1 then FreeRTOS+UDP will attempt to retrieve an IP\r
85 address, netmask, DNS server address and gateway address from a DHCP server.  If\r
86 ipconfigUSE_DHCP is 0 then FreeRTOS+UDP will use a static IP address.  The\r
87 stack will revert to using the static IP address even when ipconfigUSE_DHCP is\r
88 set to 1 if a valid configuration cannot be obtained from a DHCP server for any\r
89 reason.  The static configuration used is that passed into the stack by the\r
90 FreeRTOS_IPInit() function call. */\r
91 #define ipconfigUSE_DHCP        1\r
92 \r
93 /* When ipconfigUSE_DHCP is set to 1, DHCP requests will be sent out at\r
94 increasing time intervals until either a reply is received from a DHCP server\r
95 and accepted, or the interval between transmissions reaches\r
96 ipconfigMAXIMUM_DISCOVER_TX_PERIOD.  The IP stack will revert to using the\r
97 static IP address passed as a parameter to FreeRTOS_IPInit() if the\r
98 re-transmission time interval reaches ipconfigMAXIMUM_DISCOVER_TX_PERIOD without\r
99 a DHCP reply being received. */\r
100 #ifdef _WINDOWS_\r
101         /* The windows simulated time is not real time so the max delay is much\r
102         shorter. */\r
103         #define ipconfigMAXIMUM_DISCOVER_TX_PERIOD              ( 999 / portTICK_RATE_MS )\r
104 #else\r
105         #define ipconfigMAXIMUM_DISCOVER_TX_PERIOD              ( 120000 / portTICK_RATE_MS )\r
106 #endif /* _WINDOWS_ */\r
107 \r
108 /* The ARP cache is a table that maps IP addresses to MAC addresses.  The IP\r
109 stack can only send a UDP message to a remove IP address if it knowns the MAC\r
110 address associated with the IP address, or the MAC address of the router used to\r
111 contact the remote IP address.  When a UDP message is received from a remote IP\r
112 address the MAC address and IP address are added to the ARP cache.  When a UDP\r
113 message is sent to a remote IP address that does not already appear in the ARP\r
114 cache then the UDP message is replaced by a ARP message that solicits the\r
115 required MAC address information.  ipconfigARP_CACHE_ENTRIES defines the maximum\r
116 number of entries that can exist in the ARP table at any one time. */\r
117 #define ipconfigARP_CACHE_ENTRIES               6\r
118 \r
119 /* ARP requests that do not result in an ARP response will be re-transmitted a\r
120 maximum of ipconfigMAX_ARP_RETRANSMISSIONS times before the ARP request is\r
121 aborted. */\r
122 #define ipconfigMAX_ARP_RETRANSMISSIONS ( 5 )\r
123 \r
124 /* ipconfigMAX_ARP_AGE defines the maximum time between an entry in the ARP\r
125 table being created or refreshed and the entry being removed because it is stale.\r
126 New ARP requests are sent for ARP cache entries that are nearing their maximum\r
127 age.  ipconfigMAX_ARP_AGE is specified in tens of seconds, so a value of 150 is\r
128 equal to 1500 seconds (or 25 minutes). */\r
129 #define ipconfigMAX_ARP_AGE                     150\r
130 \r
131 /* Implementing FreeRTOS_inet_addr() necessitates the use of string handling\r
132 routines, which are relatively large.  To save code space the full\r
133 FreeRTOS_inet_addr() implementation is made optional, and a smaller and faster\r
134 alternative called FreeRTOS_inet_addr_quick() is provided.  FreeRTOS_inet_addr()\r
135 takes an IP in decimal dot format (for example, "192.168.0.1") as its parameter.\r
136 FreeRTOS_inet_addr_quick() takes an IP address as four separate numerical octets\r
137 (for example, 192, 168, 0, 1) as its parameters.  If\r
138 ipconfigINCLUDE_FULL_INET_ADDR is set to 1 then both FreeRTOS_inet_addr() and\r
139 FreeRTOS_indet_addr_quick() are available.  If ipconfigINCLUDE_FULL_INET_ADDR is\r
140 not set to 1 then only FreeRTOS_indet_addr_quick() is available. */\r
141 #define ipconfigINCLUDE_FULL_INET_ADDR  1\r
142 \r
143 /* ipconfigNUM_NETWORK_BUFFERS defines the total number of network buffer that\r
144 are available to the IP stack.  The total number of network buffers is limited\r
145 to ensure the total amount of RAM that can be consumed by the IP stack is capped\r
146 to a pre-determinable value. */\r
147 #define ipconfigNUM_NETWORK_BUFFERS             45\r
148 \r
149 /* A FreeRTOS queue is used to send events from application tasks to the IP\r
150 stack.  ipconfigEVENT_QUEUE_LENGTH sets the maximum number of events that can\r
151 be queued for processing at any one time.  The event queue must be a minimum of\r
152 5 greater than the total number of network buffers. */\r
153 #define ipconfigEVENT_QUEUE_LENGTH              ( ipconfigNUM_NETWORK_BUFFERS + 5 )\r
154 \r
155 /* The address of a socket is the combination of its IP address and its port\r
156 number.  FreeRTOS_bind() is used to manually allocate a port number to a socket\r
157 (to 'bind' the socket to a port), but manual binding is not normally necessary\r
158 for client sockets (those sockets that initiate outgoing connections rather than\r
159 wait for incoming connections on a known port number).  If\r
160 ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 1 then calling\r
161 FreeRTOS_sendto() on a socket that has not yet been bound will result in the IP\r
162 stack automatically binding the socket to a port number from the range\r
163 socketAUTO_PORT_ALLOCATION_START_NUMBER to 0xffff.  If\r
164 ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 0 then calling FreeRTOS_sendto()\r
165 on a socket that has not yet been bound will result in the send operation being\r
166 aborted. */\r
167 #define ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND 1\r
168 \r
169 /* Defines the Time To Live (TTL) values used in outgoing UDP packets. */\r
170 #define updconfigIP_TIME_TO_LIVE                128\r
171 \r
172 /* If ipconfigCAN_FRAGMENT_OUTGOING_PACKETS is set to 1 then UDP packets that\r
173 contain more data than will fit in a single network frame will be fragmented\r
174 across multiple IP packets.  Also see the ipconfigNETWORK_MTU setting.  If\r
175 ipconfigCAN_FRAGMENT_OUTGOING_PACKETS is 1 then (ipconfigNETWORK_MTU - 28) must\r
176 be divisible by 8.  Setting ipconfigCAN_FRAGMENT_OUTGOING_PACKETS to 1 will\r
177 increase both the code size and execution time. */\r
178 #define ipconfigCAN_FRAGMENT_OUTGOING_PACKETS 0\r
179 \r
180 /* The MTU is the maximum number of bytes the payload of a network frame can\r
181 contain.  For normal Ethernet V2 frames the maximum MTU is 1500.  Setting a\r
182 lower value can save RAM, depending on the buffer management scheme used.  If\r
183 ipconfigCAN_FRAGMENT_OUTGOING_PACKETS is 1 then (ipconfigNETWORK_MTU - 28) must\r
184 be divisible by 8. */\r
185 #define ipconfigNETWORK_MTU 1500\r
186 \r
187 /* Set ipconfigUSE_DNS to 1 to include a basic DNS client/resolver.  DNS is used\r
188 through the FreeRTOS_gethostbyname() API function. */\r
189 #define ipconfigUSE_DNS         1\r
190 \r
191 /* If ipconfigREPLY_TO_INCOMING_PINGS is set to 1 then the IP stack will\r
192 generate replies to incoming ICMP echo (ping) requests. */\r
193 #define ipconfigREPLY_TO_INCOMING_PINGS                         1\r
194 \r
195 /* If ipconfigSUPPORT_OUTGOING_PINGS is set to 1 then the\r
196 FreeRTOS_SendPingRequest() API function is available. */\r
197 #define ipconfigSUPPORT_OUTGOING_PINGS                          1\r
198 \r
199 /* If ipconfigSUPPORT_SELECT_FUNCTION is set to 1 then the FreeRTOS_select()\r
200 (and associated) API function is available. */\r
201 #define ipconfigSUPPORT_SELECT_FUNCTION                         1\r
202 \r
203 /* Used for stack testing only, and must be implemented in the network\r
204 interface. */\r
205 #define updconfigLOOPBACK_ETHERNET_PACKETS      0\r
206 \r
207 /* If ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES is set to 1 then Ethernet frames\r
208 that are not in Ethernet II format will be dropped.  This option is included for\r
209 potential future IP stack developments. */\r
210 #define ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES 1\r
211 \r
212 /* If ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES is set to 1 then it is the\r
213 responsibility of the Ethernet interface to filter out packets that are of no\r
214 interest.  If the Ethernet interface does not implement this functionality, then\r
215 set ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES to 0 to have the IP stack\r
216 perform the filtering instead (it is much less efficient for the stack to do it\r
217 because the packet will already have been passed into the stack).  If the\r
218 Ethernet driver does all the necessary filtering in hardware then software\r
219 filtering can be removed by using a value other than 1 or 0. */\r
220 #define ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES     1\r
221 \r
222 /* The windows simulator cannot really simulate MAC interrupts, and needs to\r
223 block occasionally to allow other tasks to run. */\r
224 #ifdef _WINDOWS_\r
225         #define configWINDOWS_MAC_INTERRUPT_SIMULATOR_DELAY ( 3 / portTICK_RATE_MS )\r
226 #endif\r
227 \r
228 /* The example IP trace macros are included here so the definitions are\r
229 available in all the FreeRTOS+UDP source files. */\r
230 #include "DemoIPTrace.h"\r
231 \r
232 #endif /* FREERTOS_IP_CONFIG_H */\r