3 * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5 * Permission is hereby granted, free of charge, to any person obtaining a copy of
6 * this software and associated documentation files (the "Software"), to deal in
7 * the Software without restriction, including without limitation the rights to
8 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 * the Software, and to permit persons to whom the Software is furnished to do so,
10 * subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in all
13 * copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 * http://www.FreeRTOS.org
23 * http://aws.amazon.com/freertos
28 #ifndef FREERTOS_DEFAULT_IP_CONFIG_H
29 #define FREERTOS_DEFAULT_IP_CONFIG_H
31 /* The error numbers defined in this file will be moved to the core FreeRTOS
32 code in future versions of FreeRTOS - at which time the following header file
34 #include "FreeRTOS_errno_TCP.h"
36 /* This file provides default values for configuration options that are missing
37 from the FreeRTOSIPConfig.h configuration header file. */
40 /* Ensure defined configuration constants are using the most up to date naming. */
41 #ifdef tcpconfigIP_TIME_TO_LIVE
42 #error now called: ipconfigTCP_TIME_TO_LIVE
45 #ifdef updconfigIP_TIME_TO_LIVE
46 #error now called: ipconfigUDP_TIME_TO_LIVE
50 #error now called: ipconfigPACKET_FILLER_SIZE
53 #ifdef dnsMAX_REQUEST_ATTEMPTS
54 #error now called: ipconfigDNS_REQUEST_ATTEMPTS
57 #ifdef ipconfigUDP_TASK_PRIORITY
58 #error now called: ipconfigIP_TASK_PRIORITY
61 #ifdef ipconfigUDP_TASK_STACK_SIZE_WORDS
62 #error now called: ipconfigIP_TASK_STACK_SIZE_WORDS
65 #ifdef ipconfigDRIVER_INCLUDED_RX_IP_FILTERING
66 #error now called: ipconfigETHERNET_DRIVER_FILTERS_PACKETS
69 #ifdef ipconfigMAX_SEND_BLOCK_TIME_TICKS
70 #error now called: ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS
73 #ifdef ipconfigUSE_RECEIVE_CONNECT_CALLBACKS
74 #error now called: ipconfigUSE_CALLBACKS
77 #ifdef ipconfigNUM_NETWORK_BUFFERS
78 #error now called: ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS
81 #ifdef ipconfigTCP_HANG_PROT
82 #error now called: ipconfigTCP_HANG_PROTECTION
85 #ifdef ipconfigTCP_HANG_PROT_TIME
86 #error now called: ipconfigTCP_HANG_PROTECTION_TIME
89 #ifdef FreeRTOS_lprintf
90 #error now called: FreeRTOS_debug_printf
93 #if ( ipconfigEVENT_QUEUE_LENGTH < ( ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS + 5 ) )
94 #error The ipconfigEVENT_QUEUE_LENGTH parameter must be at least ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS + 5
97 #if ( ipconfigNETWORK_MTU < 46 )
98 #error ipconfigNETWORK_MTU must be at least 46.
101 #ifdef ipconfigBUFFER_ALLOC_FIXED_SIZE
102 #error ipconfigBUFFER_ALLOC_FIXED_SIZE was dropped and replaced by a const value, declared in BufferAllocation[12].c
105 #ifdef ipconfigNIC_SEND_PASSES_DMA
106 #error now called: ipconfigZERO_COPY_TX_DRIVER
109 #ifdef HAS_TX_CRC_OFFLOADING
110 /* _HT_ As these macro names have changed, throw an error
111 if they're still defined. */
112 #error now called: ipconfigHAS_TX_CRC_OFFLOADING
115 #ifdef HAS_RX_CRC_OFFLOADING
116 #error now called: ipconfigHAS_RX_CRC_OFFLOADING
119 #ifdef ipconfigTCP_RX_BUF_LEN
120 #error ipconfigTCP_RX_BUF_LEN is now called ipconfigTCP_RX_BUFFER_LENGTH
123 #ifdef ipconfigTCP_TX_BUF_LEN
124 #error ipconfigTCP_TX_BUF_LEN is now called ipconfigTCP_TX_BUFFER_LENGTH
127 #ifdef ipconfigDHCP_USES_USER_HOOK
128 #error ipconfigDHCP_USES_USER_HOOK and its associated callback have been superceeded - see http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_IP_Configuration.html#ipconfigUSE_DHCP_HOOK
131 #ifndef ipconfigUSE_TCP
132 #define ipconfigUSE_TCP ( 1 )
137 /* Include support for TCP scaling windows */
138 #ifndef ipconfigUSE_TCP_WIN
139 #define ipconfigUSE_TCP_WIN ( 1 )
142 #ifndef ipconfigTCP_WIN_SEG_COUNT
143 #define ipconfigTCP_WIN_SEG_COUNT ( 256 )
146 #ifndef ipconfigIGNORE_UNKNOWN_PACKETS
147 /* When non-zero, TCP will not send RST packets in reply to
148 TCP packets which are unknown, or out-of-order. */
149 #define ipconfigIGNORE_UNKNOWN_PACKETS ( 0 )
154 * For debuging/logging: check if the port number is used for telnet
155 * Some events will not be logged for telnet connections
156 * because it would produce logging about the transmission of the logging...
157 * This macro will only be used if FreeRTOS_debug_printf() is defined for logging
159 #ifndef ipconfigTCP_MAY_LOG_PORT
160 #define ipconfigTCP_MAY_LOG_PORT(xPort) ( ( xPort ) != 23u )
164 #ifndef ipconfigSOCK_DEFAULT_RECEIVE_BLOCK_TIME
165 #define ipconfigSOCK_DEFAULT_RECEIVE_BLOCK_TIME portMAX_DELAY
168 #ifndef ipconfigSOCK_DEFAULT_SEND_BLOCK_TIME
169 #define ipconfigSOCK_DEFAULT_SEND_BLOCK_TIME portMAX_DELAY
173 #ifndef ipconfigDNS_RECEIVE_BLOCK_TIME_TICKS
174 #define ipconfigDNS_RECEIVE_BLOCK_TIME_TICKS pdMS_TO_TICKS( 500u )
177 #ifndef ipconfigDNS_SEND_BLOCK_TIME_TICKS
178 #define ipconfigDNS_SEND_BLOCK_TIME_TICKS pdMS_TO_TICKS( 500u )
181 * FreeRTOS debug logging routine (proposal)
182 * The macro will be called in the printf() style. Users can define
183 * their own logging routine as:
185 * #define FreeRTOS_debug_printf( MSG ) my_printf MSG
187 * The FreeRTOS_debug_printf() must be thread-safe but does not have to be
190 #ifdef ipconfigHAS_DEBUG_PRINTF
191 #if( ipconfigHAS_DEBUG_PRINTF == 0 )
192 #ifdef FreeRTOS_debug_printf
193 #error Do not define FreeRTOS_debug_print if ipconfigHAS_DEBUG_PRINTF is set to 0
194 #endif /* ifdef FreeRTOS_debug_printf */
195 #endif /* ( ipconfigHAS_DEBUG_PRINTF == 0 ) */
196 #endif /* ifdef ipconfigHAS_DEBUG_PRINTF */
198 #ifndef FreeRTOS_debug_printf
199 #define FreeRTOS_debug_printf( MSG ) do{} while(0)
200 #define ipconfigHAS_DEBUG_PRINTF 0
204 * FreeRTOS general logging routine (proposal)
205 * Used in some utility functions such as FreeRTOS_netstat() and FreeRTOS_PrintARPCache()
207 * #define FreeRTOS_printf( MSG ) my_printf MSG
209 * The FreeRTOS_printf() must be thread-safe but does not have to be interrupt-safe
211 #ifdef ipconfigHAS_PRINTF
212 #if( ipconfigHAS_PRINTF == 0 )
213 #ifdef FreeRTOS_printf
214 #error Do not define FreeRTOS_print if ipconfigHAS_PRINTF is set to 0
215 #endif /* ifdef FreeRTOS_debug_printf */
216 #endif /* ( ipconfigHAS_PRINTF == 0 ) */
217 #endif /* ifdef ipconfigHAS_PRINTF */
219 #ifndef FreeRTOS_printf
220 #define FreeRTOS_printf( MSG ) do{} while(0)
221 #define ipconfigHAS_PRINTF 0
225 * In cases where a lot of logging is produced, FreeRTOS_flush_logging( )
226 * will be called to give the logging module a chance to flush the data
227 * An example of this is the netstat command, which produces many lines of logging
229 #ifndef FreeRTOS_flush_logging
230 #define FreeRTOS_flush_logging( ) do{} while(0)
233 /* Malloc functions. Within most applications of FreeRTOS, the couple
234 * pvPortMalloc()/vPortFree() will be used.
235 * If there is also SDRAM, the user may decide to use a different memory
237 * MallocLarge is used to allocate large TCP buffers (for Rx/Tx)
238 * MallocSocket is used to allocate the space for the sockets
240 #ifndef pvPortMallocLarge
241 #define pvPortMallocLarge( x ) pvPortMalloc( x )
244 #ifndef vPortFreeLarge
245 #define vPortFreeLarge(ptr) vPortFree(ptr)
248 #ifndef pvPortMallocSocket
249 #define pvPortMallocSocket( x ) pvPortMalloc( x )
252 #ifndef vPortFreeSocket
253 #define vPortFreeSocket(ptr) vPortFree(ptr)
257 * At several places within the library, random numbers are needed:
258 * - DHCP: For creating a DHCP transaction number
259 * - TCP: Set the Initial Sequence Number: this is the value of the first outgoing
260 * sequence number being used when connecting to a peer.
261 * Having a well randomised ISN is important to avoid spoofing
262 * - UDP/TCP: for setting the first port number to be used, in case a socket
263 * uses a 'random' or anonymous port number
265 #ifndef ipconfigRAND32
266 #define ipconfigRAND32() rand()
268 /* --------------------------------------------------------
269 * End of: HT Added some macro defaults for the PLUS-UDP project
270 * -------------------------------------------------------- */
272 #ifndef ipconfigUSE_NETWORK_EVENT_HOOK
273 #define ipconfigUSE_NETWORK_EVENT_HOOK 0
276 #ifndef ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS
277 #define ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS ( pdMS_TO_TICKS( 20 ) )
280 #ifndef ipconfigARP_CACHE_ENTRIES
281 #define ipconfigARP_CACHE_ENTRIES 10
284 #ifndef ipconfigMAX_ARP_RETRANSMISSIONS
285 #define ipconfigMAX_ARP_RETRANSMISSIONS ( 5u )
288 #ifndef ipconfigMAX_ARP_AGE
289 #define ipconfigMAX_ARP_AGE 150u
292 #ifndef ipconfigUSE_ARP_REVERSED_LOOKUP
293 #define ipconfigUSE_ARP_REVERSED_LOOKUP 0
296 #ifndef ipconfigUSE_ARP_REMOVE_ENTRY
297 #define ipconfigUSE_ARP_REMOVE_ENTRY 0
300 #ifndef ipconfigINCLUDE_FULL_INET_ADDR
301 #define ipconfigINCLUDE_FULL_INET_ADDR 1
304 #ifndef ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS
305 #define ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS 45
308 #ifndef ipconfigEVENT_QUEUE_LENGTH
309 #define ipconfigEVENT_QUEUE_LENGTH ( ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS + 5 )
312 #ifndef ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND
313 #define ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND 1
316 #ifndef ipconfigUDP_TIME_TO_LIVE
317 #define ipconfigUDP_TIME_TO_LIVE 128
320 #ifndef ipconfigTCP_TIME_TO_LIVE
321 #define ipconfigTCP_TIME_TO_LIVE 128
324 #ifndef ipconfigUDP_MAX_RX_PACKETS
325 /* Make postive to define the maximum number of packets which will be buffered
326 * for each UDP socket.
327 * Can be overridden with the socket option FREERTOS_SO_UDP_MAX_RX_PACKETS
329 #define ipconfigUDP_MAX_RX_PACKETS 0u
332 #ifndef ipconfigUSE_DHCP
333 #define ipconfigUSE_DHCP 1
336 #ifndef ipconfigUSE_DHCP_HOOK
337 #define ipconfigUSE_DHCP_HOOK 0
340 #ifndef ipconfigDHCP_FALL_BACK_AUTO_IP
342 * Only applicable when DHCP is in use:
343 * If no DHCP server responds, use "Auto-IP" : the
344 * device will allocate a random LinkLayer IP address.
346 #define ipconfigDHCP_FALL_BACK_AUTO_IP ( 0 )
349 #if( ipconfigDHCP_FALL_BACK_AUTO_IP != 0 )
350 #define ipconfigARP_USE_CLASH_DETECTION 1
353 #ifndef ipconfigARP_USE_CLASH_DETECTION
354 #define ipconfigARP_USE_CLASH_DETECTION 0
357 #ifndef ipconfigNETWORK_MTU
358 #define ipconfigNETWORK_MTU 1500
361 #ifndef ipconfigTCP_MSS
362 #define ipconfigTCP_MSS ( ipconfigNETWORK_MTU - ipSIZE_OF_IPv4_HEADER - ipSIZE_OF_TCP_HEADER )
365 /* Each TCP socket has circular stream buffers for Rx and Tx, which
366 * have a fixed maximum size.
367 * The defaults for these size are defined here, although
368 * they can be overridden at runtime by using the setsockopt() call */
369 #ifndef ipconfigTCP_RX_BUFFER_LENGTH
370 #define ipconfigTCP_RX_BUFFER_LENGTH ( 4u * ipconfigTCP_MSS ) /* defaults to 5840 bytes */
373 /* Define the size of Tx stream buffer for TCP sockets */
374 #ifndef ipconfigTCP_TX_BUFFER_LENGTH
375 # define ipconfigTCP_TX_BUFFER_LENGTH ( 4u * ipconfigTCP_MSS ) /* defaults to 5840 bytes */
378 #ifndef ipconfigMAXIMUM_DISCOVER_TX_PERIOD
380 #define ipconfigMAXIMUM_DISCOVER_TX_PERIOD ( pdMS_TO_TICKS( 999 ) )
382 #define ipconfigMAXIMUM_DISCOVER_TX_PERIOD ( pdMS_TO_TICKS( 30000 ) )
383 #endif /* _WINDOWS_ */
384 #endif /* ipconfigMAXIMUM_DISCOVER_TX_PERIOD */
386 #if( ipconfigUSE_DNS == 0 )
387 /* The DNS module will not be included. */
388 #if( ( ipconfigUSE_LLMNR != 0 ) || ( ipconfigUSE_NBNS != 0 ) )
389 /* LLMNR and NBNS depend on DNS because those protocols share a lot of code. */
390 #error When either LLMNR or NBNS is used, ipconfigUSE_DNS must be defined
394 #ifndef ipconfigUSE_DNS
395 #define ipconfigUSE_DNS 1
398 #ifndef ipconfigDNS_REQUEST_ATTEMPTS
399 #define ipconfigDNS_REQUEST_ATTEMPTS 5
402 #ifndef ipconfigUSE_DNS_CACHE
403 #define ipconfigUSE_DNS_CACHE 0
406 #if( ipconfigUSE_DNS_CACHE != 0 )
407 #ifndef ipconfigDNS_CACHE_NAME_LENGTH
408 /* Per https://tools.ietf.org/html/rfc1035, 253 is the maximum string length
409 of a DNS name. The following default accounts for a null terminator. */
410 #define ipconfigDNS_CACHE_NAME_LENGTH 254
413 #ifndef ipconfigDNS_CACHE_ENTRIES
414 #define ipconfigDNS_CACHE_ENTRIES 1
416 #endif /* ipconfigUSE_DNS_CACHE != 0 */
418 #ifndef ipconfigCHECK_IP_QUEUE_SPACE
419 #define ipconfigCHECK_IP_QUEUE_SPACE 0
422 #ifndef ipconfigUSE_LLMNR
423 /* Include support for LLMNR: Link-local Multicast Name Resolution (non-Microsoft) */
424 #define ipconfigUSE_LLMNR ( 0 )
427 #ifndef ipconfigREPLY_TO_INCOMING_PINGS
428 #define ipconfigREPLY_TO_INCOMING_PINGS 1
431 #ifndef ipconfigSUPPORT_OUTGOING_PINGS
432 #define ipconfigSUPPORT_OUTGOING_PINGS 0
435 #ifndef ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES
436 #define ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES 1
439 #ifndef ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES
440 #define ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES 1
443 #ifndef configINCLUDE_TRACE_RELATED_CLI_COMMANDS
444 #define ipconfigINCLUDE_EXAMPLE_FREERTOS_PLUS_TRACE_CALLS 0
446 #define ipconfigINCLUDE_EXAMPLE_FREERTOS_PLUS_TRACE_CALLS configINCLUDE_TRACE_RELATED_CLI_COMMANDS
449 #ifndef ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM
450 #define ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM ( 0 )
453 #ifndef ipconfigETHERNET_DRIVER_FILTERS_PACKETS
454 #define ipconfigETHERNET_DRIVER_FILTERS_PACKETS ( 0 )
457 #ifndef ipconfigWATCHDOG_TIMER
458 /* This macro will be called in every loop the IP-task makes. It may be
459 replaced by user-code that triggers a watchdog */
460 #define ipconfigWATCHDOG_TIMER()
463 #ifndef ipconfigUSE_CALLBACKS
464 #define ipconfigUSE_CALLBACKS ( 0 )
467 #if( ipconfigUSE_CALLBACKS != 0 )
468 #ifndef ipconfigIS_VALID_PROG_ADDRESS
469 /* Replace this macro with a test returning non-zero if the memory pointer to by x
470 * is valid memory which can contain executable code
471 * In fact this is an extra safety measure: if a handler points to invalid memory,
472 * it will not be called
474 #define ipconfigIS_VALID_PROG_ADDRESS(x) ( ( x ) != NULL )
478 #ifndef ipconfigHAS_INLINE_FUNCTIONS
479 #define ipconfigHAS_INLINE_FUNCTIONS ( 1 )
483 #define portINLINE inline
486 #ifndef ipconfigZERO_COPY_TX_DRIVER
487 /* When non-zero, the buffers passed to the SEND routine may be passed
488 to DMA. As soon as sending is ready, the buffers must be released by
489 calling vReleaseNetworkBufferAndDescriptor(), */
490 #define ipconfigZERO_COPY_TX_DRIVER ( 0 )
493 #ifndef ipconfigZERO_COPY_RX_DRIVER
494 /* This define doesn't mean much to the driver, except that it makes
495 sure that pxPacketBuffer_to_NetworkBuffer() will be included. */
496 #define ipconfigZERO_COPY_RX_DRIVER ( 0 )
499 #ifndef ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM
500 #define ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM 0
503 #ifndef ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM
504 #define ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM 0
507 #ifndef ipconfigDHCP_REGISTER_HOSTNAME
508 #define ipconfigDHCP_REGISTER_HOSTNAME 0
511 #ifndef ipconfigSOCKET_HAS_USER_SEMAPHORE
512 #define ipconfigSOCKET_HAS_USER_SEMAPHORE 0
515 #ifndef ipconfigSOCKET_HAS_USER_WAKE_CALLBACK
516 #define ipconfigSOCKET_HAS_USER_WAKE_CALLBACK 0
519 #ifndef ipconfigSUPPORT_SELECT_FUNCTION
520 #define ipconfigSUPPORT_SELECT_FUNCTION 0
523 #ifndef ipconfigTCP_KEEP_ALIVE
524 #define ipconfigTCP_KEEP_ALIVE 0
527 #ifndef ipconfigDNS_USE_CALLBACKS
528 #define ipconfigDNS_USE_CALLBACKS 0
531 #ifndef ipconfigSUPPORT_SIGNALS
532 #define ipconfigSUPPORT_SIGNALS 0
535 #ifndef ipconfigUSE_NBNS
536 #define ipconfigUSE_NBNS 0
539 /* As an attack surface reduction for ports that listen for inbound
540 connections, hang protection can help reduce the impact of SYN floods. */
541 #ifndef ipconfigTCP_HANG_PROTECTION
542 #define ipconfigTCP_HANG_PROTECTION 1
545 /* Non-activity timeout is expressed in seconds. */
546 #ifndef ipconfigTCP_HANG_PROTECTION_TIME
547 #define ipconfigTCP_HANG_PROTECTION_TIME 30
550 #ifndef ipconfigTCP_IP_SANITY
551 #define ipconfigTCP_IP_SANITY 0
554 #ifndef ipconfigARP_STORES_REMOTE_ADDRESSES
555 #define ipconfigARP_STORES_REMOTE_ADDRESSES 0
558 #ifndef ipconfigBUFFER_PADDING
559 /* Expert option: define a value for 'ipBUFFER_PADDING'.
560 When 'ipconfigBUFFER_PADDING' equals 0,
561 'ipBUFFER_PADDING' will get a default value of 8 + 2 bytes. */
562 #define ipconfigBUFFER_PADDING 0
565 #ifndef ipconfigPACKET_FILLER_SIZE
566 #define ipconfigPACKET_FILLER_SIZE 2
569 #endif /* FREERTOS_DEFAULT_IP_CONFIG_H */