1 /* 2 * FreeRTOS+TCP <DEVELOPMENT BRANCH> 3 * Copyright (C) 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 * 5 * SPDX-License-Identifier: MIT 6 * 7 * Permission is hereby granted, free of charge, to any person obtaining a copy of 8 * this software and associated documentation files (the "Software"), to deal in 9 * the Software without restriction, including without limitation the rights to 10 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 * the Software, and to permit persons to whom the Software is furnished to do so, 12 * subject to the following conditions: 13 * 14 * The above copyright notice and this permission notice shall be included in all 15 * copies or substantial portions of the Software. 16 * 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 * 24 * http://aws.amazon.com/freertos 25 * http://www.FreeRTOS.org 26 */ 27 28 #ifndef FREERTOS_DEFAULT_IP_CONFIG_H 29 #define FREERTOS_DEFAULT_IP_CONFIG_H 30 31 /* This file must be included only after the configuration files FreeRTOSConfig.h and 32 * FreeRTOSIPConfig.h have been included already. 33 * Mentioned header files are private to the project, whereas this header 34 * file is part of FreeRTOS+TCP. 35 * 36 * The complete documentation of the configuration parameters can be found here: 37 * 38 * https://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_IP_Configuration.html 39 * 40 */ 41 42 /* The error numbers defined in this file will be moved to the core FreeRTOS 43 * code in future versions of FreeRTOS - at which time the following header file 44 * will be removed. */ 45 #include "FreeRTOS_errno_TCP.h" 46 47 /* This file provides default values for configuration options that are missing 48 * from the FreeRTOSIPConfig.h configuration header file. */ 49 50 /* These macros are used to define away static keyword for CBMC proofs */ 51 #ifndef _static 52 #define _static static 53 #endif 54 55 /* Through time some macro names have changed. This always 56 * happened for a good reason: clarity or consistency. 57 * Here below there are some ifdef's that will issue an error if any of the 58 * deprecated macros is still defined. */ 59 60 /* Ensure defined configuration constants are using the most up to date naming. */ 61 #ifdef tcpconfigIP_TIME_TO_LIVE 62 #error now called: ipconfigTCP_TIME_TO_LIVE 63 #endif 64 65 #ifdef updconfigIP_TIME_TO_LIVE 66 #error now called: ipconfigUDP_TIME_TO_LIVE 67 #endif 68 69 #ifdef ipFILLER_SIZE 70 #error now called: ipconfigPACKET_FILLER_SIZE 71 #endif 72 73 #ifndef ipconfigENDPOINT_DNS_ADDRESS_COUNT 74 #define ipconfigENDPOINT_DNS_ADDRESS_COUNT 2U 75 #endif 76 77 #ifdef dnsMAX_REQUEST_ATTEMPTS 78 #error now called: ipconfigDNS_REQUEST_ATTEMPTS 79 #endif 80 81 #ifdef ipconfigUDP_TASK_PRIORITY 82 #error now called: ipconfigIP_TASK_PRIORITY 83 #endif 84 85 #ifdef ipconfigUDP_TASK_STACK_SIZE_WORDS 86 #error now called: ipconfigIP_TASK_STACK_SIZE_WORDS 87 #endif 88 89 #ifdef ipconfigDRIVER_INCLUDED_RX_IP_FILTERING 90 #error now called: ipconfigETHERNET_DRIVER_FILTERS_PACKETS 91 #endif 92 93 #ifdef ipconfigMAX_SEND_BLOCK_TIME_TICKS 94 #error now called: ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS 95 #endif 96 97 #ifdef ipconfigUSE_RECEIVE_CONNECT_CALLBACKS 98 #error now called: ipconfigUSE_CALLBACKS 99 #endif 100 101 #ifdef ipconfigNUM_NETWORK_BUFFERS 102 #error now called: ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS 103 #endif 104 105 #ifdef ipconfigTCP_HANG_PROT 106 #error now called: ipconfigTCP_HANG_PROTECTION 107 #endif 108 109 #ifdef ipconfigTCP_HANG_PROT_TIME 110 #error now called: ipconfigTCP_HANG_PROTECTION_TIME 111 #endif 112 113 #ifdef FreeRTOS_lprintf 114 #error now called: FreeRTOS_debug_printf 115 #endif 116 117 #ifdef ipconfigBUFFER_ALLOC_FIXED_SIZE 118 #error ipconfigBUFFER_ALLOC_FIXED_SIZE was dropped and replaced by a const value, declared in BufferAllocation[12].c 119 #endif 120 121 #ifdef ipconfigNIC_SEND_PASSES_DMA 122 #error now called: ipconfigZERO_COPY_TX_DRIVER 123 #endif 124 125 #ifdef HAS_TX_CRC_OFFLOADING 126 #error now called: ipconfigHAS_TX_CRC_OFFLOADING 127 #endif 128 129 #ifdef HAS_RX_CRC_OFFLOADING 130 #error now called: ipconfigHAS_RX_CRC_OFFLOADING 131 #endif 132 133 #ifdef ipconfigTCP_RX_BUF_LEN 134 #error ipconfigTCP_RX_BUF_LEN is now called ipconfigTCP_RX_BUFFER_LENGTH 135 #endif 136 137 #ifdef ipconfigTCP_TX_BUF_LEN 138 #error ipconfigTCP_TX_BUF_LEN is now called ipconfigTCP_TX_BUFFER_LENGTH 139 #endif 140 141 #ifdef ipconfigDHCP_USES_USER_HOOK 142 #error ipconfigDHCP_USES_USER_HOOK and its associated callback have been superseded - see http: /*www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_IP_Configuration.html#ipconfigUSE_DHCP_HOOK */ 143 #endif 144 145 /* The macro 'ipconfigBYTE_ORDER' must be defined as either 'pdFREERTOS_LITTLE_ENDIAN' 146 * or as 'pdFREERTOS_BIG_ENDIAN'. See also 'projdefs.h'. 147 */ 148 #ifndef ipconfigBYTE_ORDER 149 #error The macro 'ipconfigBYTE_ORDER' must be defined at this point 150 #endif 151 152 /* So far the warnings about deprecated configuration macros. */ 153 154 /*-----------------------------------------------------------*/ 155 156 /* The IP stack executes it its own task (although any application task can make 157 * use of its services through the published sockets API). ipconfigUDP_TASK_PRIORITY 158 * sets the priority of the task that executes the IP stack. The priority is a 159 * standard FreeRTOS task priority so can take any value from 0 (the lowest 160 * priority) to (configMAX_PRIORITIES - 1) (the highest priority). 161 * configMAX_PRIORITIES is a standard FreeRTOS configuration parameter defined in 162 * FreeRTOSConfig.h, not FreeRTOSIPConfig.h. Consideration needs to be given as to 163 * the priority assigned to the task executing the IP stack relative to the 164 * priority assigned to tasks that use the IP stack. 165 * 166 * Define the priority of the IP-task. It is recommended to use this 167 * order of priorities: 168 * Highest : network interface, handling transmission and reception. 169 * Medium : the IP-task handling API calls from the application. 170 * Lower : the tasks that make use of the IP-stack. 171 * For other tasks any priority can be chosen. 172 */ 173 #ifndef ipconfigIP_TASK_PRIORITY 174 #define ipconfigIP_TASK_PRIORITY ( configMAX_PRIORITIES - 2 ) 175 #endif 176 177 /* The size, in words (not bytes), of the stack allocated to the FreeRTOS+TCP 178 * task. This setting is less important when the FreeRTOS Win32 simulator is used 179 * as the Win32 simulator only stores a fixed amount of information on the task 180 * stack. FreeRTOS includes optional stack overflow detection, see: 181 * http://www.freertos.org/Stacks-and-stack-overflow-checking.html */ 182 #ifndef ipconfigIP_TASK_STACK_SIZE_WORDS 183 #define ipconfigIP_TASK_STACK_SIZE_WORDS ( configMINIMAL_STACK_SIZE * 5U ) 184 #endif 185 186 /* Include all API's and code that is needed for the TCP protocol. 187 * When defined as zero, the application is UDP-only. */ 188 #ifndef ipconfigUSE_TCP 189 #define ipconfigUSE_TCP ( 1 ) 190 #endif 191 192 #ifndef ipconfigCOMPATIBLE_WITH_SINGLE 193 #define ipconfigCOMPATIBLE_WITH_SINGLE ( 0 ) 194 #endif 195 196 #ifndef ipconfigMULTI_INTERFACE 197 #define ipconfigMULTI_INTERFACE ( 1 ) 198 #endif 199 200 /* Disable DHCPv6 by default. */ 201 #ifndef ipconfigUSE_DHCPv6 202 #define ipconfigUSE_DHCPv6 ( 0 ) 203 #endif 204 205 #if ( ipconfigUSE_TCP != 0 ) 206 207 /* 'ipconfigUSE_TCP_WIN' enables support for TCP sliding windows. When 208 * defined as zero, each TCP packet must be acknowledged individually. 209 * That will be slower, but it will result less code. */ 210 #ifndef ipconfigUSE_TCP_WIN 211 #define ipconfigUSE_TCP_WIN ( 1 ) 212 #endif 213 214 /* The total number of outstanding TCP segments, either outgoing or incoming. 215 * This only applies when 'ipconfigUSE_TCP_WIN' is enabled. */ 216 #ifndef ipconfigTCP_WIN_SEG_COUNT 217 #define ipconfigTCP_WIN_SEG_COUNT ( 256 ) 218 #endif 219 220 /* When non-zero, TCP will not send RST packets in reply to 221 * TCP packets which are unknown, or out-of-order. 222 * This is an option used for testing. It is recommended to 223 * define it as '0'. */ 224 #ifndef ipconfigIGNORE_UNKNOWN_PACKETS 225 #define ipconfigIGNORE_UNKNOWN_PACKETS ( 0 ) 226 #endif 227 #endif /* if ipconfigUSE_TCP */ 228 229 /* 230 * For debugging/logging: check if the port number is used for e.g. telnet. 231 * Some events will not be logged for telnet connections 232 * because it would produce logging about the transmission of the logging... 233 * This macro will only be used if FreeRTOS_debug_printf() is defined for logging. 234 * Note that the parameter 'xPort' is already converted to host-endian. 235 */ 236 #ifndef ipconfigTCP_MAY_LOG_PORT 237 #define ipconfigTCP_MAY_LOG_PORT( xPort ) ( ( xPort ) != 23U ) 238 #endif 239 240 /* Include all API's and code that is needed for the IPv4 protocol. 241 * When defined as zero, the application should uses IPv6. */ 242 #ifndef ipconfigUSE_IPv4 243 #define ipconfigUSE_IPv4 ( 1 ) 244 #endif 245 246 /* Include all API's and code that is needed for the IPv6 protocol. 247 * When defined as zero, the application should uses IPv4. */ 248 #ifndef ipconfigUSE_IPv6 249 #define ipconfigUSE_IPv6 ( 1 ) 250 #endif 251 252 #if ( ipconfigUSE_IPv4 != 1 ) && ( ipconfigUSE_IPv6 != 1 ) 253 #error "Invalid build configuration" 254 #endif 255 256 /* 257 * If defined this macro enables the APIs that are backward compatible 258 * with single end point IPv4 version of the FreeRTOS+TCP library. 259 */ 260 #ifndef ipconfigIPv4_BACKWARD_COMPATIBLE 261 #define ipconfigIPv4_BACKWARD_COMPATIBLE 0 262 #endif 263 264 /* Determine the number of clock ticks that the API's FreeRTOS_recv() and 265 * FreeRTOS_recvfrom() must wait for incoming data. */ 266 #ifndef ipconfigSOCK_DEFAULT_RECEIVE_BLOCK_TIME 267 #define ipconfigSOCK_DEFAULT_RECEIVE_BLOCK_TIME portMAX_DELAY 268 #endif 269 270 /* Determine the number of clock ticks that FreeRTOS_send() must wait 271 * for space in the transmission buffer. 272 * For FreeRTOS_sendto(), it limits how long the application 273 * should wait for a network buffer to become available. 274 */ 275 #ifndef ipconfigSOCK_DEFAULT_SEND_BLOCK_TIME 276 #define ipconfigSOCK_DEFAULT_SEND_BLOCK_TIME portMAX_DELAY 277 #endif 278 279 /* When sending a UDP packet, a network buffer must be obtained. This macro 280 * will limit the maximum waiting time that is configured with e.g. 281 * ipconfigSOCK_DEFAULT_SEND_BLOCK_TIME, or when setting the socket option 282 * FREERTOS_SO_SNDTIMEO. 283 * It serves as a protection against a possible dead-lock; a task waiting 284 * for itself to release a network buffer. 285 */ 286 #ifndef ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS 287 #define ipconfigUDP_MAX_SEND_BLOCK_TIME_TICKS ( pdMS_TO_TICKS( 20U ) ) 288 #endif 289 290 /* 291 * FreeRTOS debug logging routines. 292 * The macro will be called with a printf() format as a parameter. Users 293 * can define their own logging routine as: 294 * 295 * extern void my_printf( const char * pcFormat, ... ); 296 * #define FreeRTOS_debug_printf( MSG ) my_printf MSG 297 * 298 * The FreeRTOS_debug_printf() must be thread-safe but does not have to be 299 * interrupt-safe. 300 */ 301 #ifdef ipconfigHAS_DEBUG_PRINTF 302 #if ( ipconfigHAS_DEBUG_PRINTF == 0 ) 303 #ifdef FreeRTOS_debug_printf 304 #error Do not define FreeRTOS_debug_print if ipconfigHAS_DEBUG_PRINTF is set to 0 305 #endif /* ifdef FreeRTOS_debug_printf */ 306 #endif /* ( ipconfigHAS_DEBUG_PRINTF == 0 ) */ 307 #endif /* ifdef ipconfigHAS_DEBUG_PRINTF */ 308 309 #ifndef FreeRTOS_debug_printf 310 #define FreeRTOS_debug_printf( MSG ) do {} while( ipFALSE_BOOL ) 311 /* MISRA Ref 20.5.1 [Use of undef] */ 312 /* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-2051 */ 313 /* coverity[misra_c_2012_rule_20_5_violation] */ 314 #undef ipconfigHAS_DEBUG_PRINTF 315 #define ipconfigHAS_DEBUG_PRINTF 0 316 #endif 317 318 /* 319 * FreeRTOS general logging routine (proposal) 320 * Used in some utility functions such as FreeRTOS_netstat() and FreeRTOS_PrintARPCache() 321 * 322 * extern void my_printf( const char * pcFormat, ... ); 323 * #define FreeRTOS_printf( MSG ) my_printf MSG 324 * 325 * The FreeRTOS_printf() must be thread-safe but does not have to be interrupt-safe 326 */ 327 #ifdef ipconfigHAS_PRINTF 328 #if ( ipconfigHAS_PRINTF == 0 ) 329 #ifdef FreeRTOS_printf 330 #error Do not define FreeRTOS_print if ipconfigHAS_PRINTF is set to 0 331 #endif /* ifdef FreeRTOS_debug_printf */ 332 #endif /* ( ipconfigHAS_PRINTF == 0 ) */ 333 #endif /* ifdef ipconfigHAS_PRINTF */ 334 335 #ifndef FreeRTOS_printf 336 #define FreeRTOS_printf( MSG ) do {} while( ipFALSE_BOOL ) 337 /* MISRA Ref 20.5.1 [Use of undef] */ 338 /* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-2051 */ 339 /* coverity[misra_c_2012_rule_20_5_violation] */ 340 #undef ipconfigHAS_PRINTF 341 #define ipconfigHAS_PRINTF 0 342 #endif 343 344 /* 345 * In cases where a lot of logging is produced, FreeRTOS_flush_logging( ) 346 * will be called to give the logging module a chance to flush the data. 347 */ 348 #ifndef FreeRTOS_flush_logging 349 #define FreeRTOS_flush_logging() do {} while( ipFALSE_BOOL ) 350 #endif 351 352 /* Malloc functions. Within most applications of FreeRTOS, the couple 353 * pvPortMalloc()/vPortFree() will be used. 354 * If there are different types of RAM, the user may decide to use a different 355 * memory allocator for different purposes: 356 * MallocLarge is used to allocate large TCP buffers (for Rx/Tx) 357 * MallocSocket is used to allocate the space for the sockets 358 */ 359 #ifndef pvPortMallocLarge 360 #define pvPortMallocLarge( x ) pvPortMalloc( x ) 361 #endif 362 363 #ifndef vPortFreeLarge 364 #define vPortFreeLarge( ptr ) vPortFree( ptr ) 365 #endif 366 367 #ifndef pvPortMallocSocket 368 #define pvPortMallocSocket( x ) pvPortMalloc( x ) 369 #endif 370 371 #ifndef vPortFreeSocket 372 #define vPortFreeSocket( ptr ) vPortFree( ptr ) 373 #endif 374 375 /* 376 * At several places within the library, random numbers are needed: 377 * - DHCP: For creating a DHCP transaction number 378 * - TCP: Set the Initial Sequence Number: this is the value of the first outgoing 379 * sequence number being used when connecting to a peer. 380 * Having a well randomized ISN is important to avoid spoofing 381 * - UDP/TCP: for setting the first port number to be used, in case a socket 382 * uses a 'random' or anonymous port number 383 * 384 * The function is now **deprecated**, in stead the following function must be provided: 385 * BaseType_t xApplicationGetRandomNumber( uint32_t *pulValue ); 386 * It will return pdPASS if the random number could be created, otherwise pdFAIL. 387 */ 388 #ifndef ipconfigRAND32 389 #define ipconfigRAND32() rand() 390 #endif 391 392 /* 'ipconfigUSE_NETWORK_EVENT_HOOK' indicates if an application hook is available 393 * called 'vApplicationIPNetworkEventHook()' ( if ipconfigIPv4_BACKWARD_COMPATIBLE enabled, 394 * otherwise vApplicationIPNetworkEventHook_Multi() ). 395 * This function will be called when 396 * the network goes up and when it goes down. See also FREERTOS_IP.h for further 397 * explanation. */ 398 #ifndef ipconfigUSE_NETWORK_EVENT_HOOK 399 #define ipconfigUSE_NETWORK_EVENT_HOOK 0 400 #endif 401 402 /* Define the number of entries in the ARP cache table. */ 403 #ifndef ipconfigARP_CACHE_ENTRIES 404 #define ipconfigARP_CACHE_ENTRIES 10 405 #endif 406 407 /* The number of times an ARP request is sent when looking 408 * up an IP-address. 409 * The name should have been 'max transmissions', and not 410 * 'max re-transmissions'. */ 411 #ifndef ipconfigMAX_ARP_RETRANSMISSIONS 412 #define ipconfigMAX_ARP_RETRANSMISSIONS ( 5U ) 413 #endif 414 415 /* The maximum age of an entry in the ARP cache table can be 416 * calculated as 'ipARP_TIMER_PERIOD_MS' x 'ipconfigMAX_ARP_AGE'. 417 * The macro 'ipARP_TIMER_PERIOD_MS' is local to FreeRTOSIP.c 418 * but it can be overwritten from FreeRTOSIPConfig.h 419 * The default is 10000 x 150 = 1500000 ms or 1500 seconds 420 */ 421 #ifndef ipconfigMAX_ARP_AGE 422 #define ipconfigMAX_ARP_AGE 150U 423 #endif 424 425 /* 'ipconfigUSE_ARP_REVERSED_LOOKUP' when non-zero, the function 426 * eARPGetCacheEntryByMac() will be included in the code. 427 */ 428 #ifndef ipconfigUSE_ARP_REVERSED_LOOKUP 429 #define ipconfigUSE_ARP_REVERSED_LOOKUP 0 430 #endif 431 432 /* 'ipconfigUSE_ARP_REMOVE_ENTRY' when non-zero, the function 433 * ulARPRemoveCacheEntryByMac() will be included in the code. 434 */ 435 #ifndef ipconfigUSE_ARP_REMOVE_ENTRY 436 #define ipconfigUSE_ARP_REMOVE_ENTRY 0 437 #endif 438 439 /* Normally, the ARP table will only store IP-addresses that are located 440 * in the local subnet. 441 * When enabled, the option 'ipconfigARP_STORES_REMOTE_ADDRESSES' will allow 442 * that remote IP-addresses will also be stored, along with the MAC-address of 443 * the gateway. 444 */ 445 #ifndef ipconfigARP_STORES_REMOTE_ADDRESSES 446 #define ipconfigARP_STORES_REMOTE_ADDRESSES 0 447 #endif 448 449 /* 'ipconfigINCLUDE_FULL_INET_ADDR' used to determine if 450 * the function 'FreeRTOS_inet_addr()' is included. 451 * The macro is now deprecated and the function is included 452 * unconditionally. 453 */ 454 #ifndef ipconfigINCLUDE_FULL_INET_ADDR 455 #define ipconfigINCLUDE_FULL_INET_ADDR 1 456 #endif 457 458 /* This is about how new packets are passed from the network interface 459 * to the IP-task. By default they will be sent one-by-one. 460 * When 'ipconfigUSE_LINKED_RX_MESSAGES' is non-zero, each message 461 * buffer gets a 'pxNextBuffer' field, to that linked packets can be passed 462 * to the IP-task in a single call to 'xSendEventStructToIPTask()'. 463 * Note that this only works if the Network Interface also supports this 464 * option. 465 */ 466 #ifndef ipconfigUSE_LINKED_RX_MESSAGES 467 #define ipconfigUSE_LINKED_RX_MESSAGES 0 468 #endif 469 470 /* 'ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS' is an important macro: it 471 * determines the number of network buffers that are available in the 472 * entire application. 473 * Note that the default of 45 may be pretty high for smaller 474 * applications. 475 * Also note that when the network interface uses zero-copy reception 476 * ( ipconfigZERO_COPY_RX_DRIVER ), it will reserve a set of network 477 * buffers permanently. 478 * For zero-copy transmission, no network buffers are permanently 479 * "reserved" for transmission. 480 */ 481 #ifndef ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS 482 #define ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS 45U 483 #endif 484 485 /* Every task, and also the network interface can send messages 486 * to the IP-task by calling API's. These messages pass through a 487 * queue which has a maximum size of 'ipconfigEVENT_QUEUE_LENGTH' 488 * items. 489 * When developing an application, it is important to monitor the 490 * actual usage of the queue. See 'ipconfigCHECK_IP_QUEUE_SPACE' 491 * here below. 492 */ 493 #ifndef ipconfigEVENT_QUEUE_LENGTH 494 #define ipconfigEVENT_QUEUE_LENGTH ( ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS + 5U ) 495 #endif 496 497 #if ( ipconfigEVENT_QUEUE_LENGTH < ( ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS + 5U ) ) 498 #error The ipconfigEVENT_QUEUE_LENGTH parameter must be at least ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS + 5 499 #endif 500 501 /* Related to the macro 'ipconfigEVENT_QUEUE_LENGTH' here above: 502 * when developing a new networking application, it can be helpful 503 * to monitor the length of the message queue of the IP-task. 504 * This code is only enabled when 'ipconfigCHECK_IP_QUEUE_SPACE' 505 * is set to 1. See also the function 'uxGetMinimumIPQueueSpace()'. 506 */ 507 #ifndef ipconfigCHECK_IP_QUEUE_SPACE 508 #define ipconfigCHECK_IP_QUEUE_SPACE 0 509 #endif 510 511 /* When defined as non-zero, this macro allows to use a socket 512 * without first binding it explicitly to a port number. 513 * In that case, it will be bound to a random free port number. */ 514 #ifndef ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND 515 #define ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND 1 516 #endif 517 518 /* Configuration to control whether packets with IP options, 519 * received over the network, should be passed up to the 520 * software stack OR should be dropped. 521 * If set to 1, the stack accepts IP packets that contain IP options, but does 522 * not process the options (IP options are not supported). 523 * If set to 0, the stack will drop IP packets that contain IP options. 524 */ 525 #ifndef ipconfigIP_PASS_PACKETS_WITH_IP_OPTIONS 526 #define ipconfigIP_PASS_PACKETS_WITH_IP_OPTIONS 1 527 #endif 528 529 /* Configuration to control whether all outgoing IP datagrams get their 530 * "don't fragment" flag set. 531 * If set to 1, the stack will set the "don't fragment" flag on all outgoing IP 532 * packets. If a packet needs to be fragmented somewhere along it's path, it will get 533 * discarded instead of fragmented. 534 * If set to 0, the stack will clear the "don't fragment" flag an all outgoing IP 535 * packets therefore allowing fragmentation if it is needed. 536 */ 537 #ifndef ipconfigFORCE_IP_DONT_FRAGMENT 538 #define ipconfigFORCE_IP_DONT_FRAGMENT 0 539 #endif 540 541 /* Configuration to control whether UDP packets with 542 * checksum value of zero should be passed up the software 543 * stack OR should be dropped. 544 * When enabled, the stack will accept UDP packets that have their checksum 545 * value set to 0. 546 * When disabled, the stack will drop UDP packets that have their checksum 547 * value set to 0, and issue some logging. 548 */ 549 #ifndef ipconfigUDP_PASS_ZERO_CHECKSUM_PACKETS 550 #define ipconfigUDP_PASS_ZERO_CHECKSUM_PACKETS 0 551 #endif 552 553 /* Define the value of the TTL field in outgoing UDP packets. */ 554 #ifndef ipconfigUDP_TIME_TO_LIVE 555 #define ipconfigUDP_TIME_TO_LIVE 128 556 #endif 557 558 /* Define the value of the TTL field in outgoing TCP packets. */ 559 #ifndef ipconfigTCP_TIME_TO_LIVE 560 #define ipconfigTCP_TIME_TO_LIVE 128 561 #endif 562 563 /* Define the value of the TTL field in outgoing TCP packets. */ 564 /* The default of 64 is recommend in RFC 1700. */ 565 #ifndef ipconfigICMP_TIME_TO_LIVE 566 #define ipconfigICMP_TIME_TO_LIVE 64 567 #endif 568 569 /* TCP only: when measuring the Smoothed Round Trip Time (SRTT), 570 * the result will be rounded up to a minimum value. 571 * The default has always been 50, but a value of 1000 572 * is recommended ( see RFC6298 ) because hosts often delay the 573 * sending of ACK packets with 200 ms. */ 574 #ifndef ipconfigTCP_SRTT_MINIMUM_VALUE_MS 575 #define ipconfigTCP_SRTT_MINIMUM_VALUE_MS 50 576 #endif 577 578 /* Make positive to define the maximum number of packets which will be buffered 579 * in a UDP socket. 580 * Can be overridden with the socket option 'FREERTOS_SO_UDP_MAX_RX_PACKETS'. 581 */ 582 #ifndef ipconfigUDP_MAX_RX_PACKETS 583 #define ipconfigUDP_MAX_RX_PACKETS 0U 584 #endif 585 586 /* When non-zero, the module FreeRTOS_DHCP.c will be included and called. 587 * Note that the application can override decide to ignore the outcome 588 * of the DHCP negotiation and use a static IP-address. */ 589 #ifndef ipconfigUSE_DHCP 590 #define ipconfigUSE_DHCP 1 591 #endif 592 593 /* During the DHCP process, the driver will call an application hook 594 * if 'ipconfigUSE_DHCP_HOOK' is non-zero. It lets the application decide 595 * if the DHCP offer shall be accepted. 596 */ 597 #ifndef ipconfigUSE_DHCP_HOOK 598 #define ipconfigUSE_DHCP_HOOK 1 599 #endif 600 601 /* DHCP servers have a table with information about each clients. One 602 * of the fields in this table contains the host name of the DHCP clients. 603 * When 'ipconfigDHCP_REGISTER_HOSTNAME' is defined as non-zero, the DHCP 604 * driver will call 'pcApplicationHostnameHook()' to obtain the name of 605 * the embedded device. 606 */ 607 #ifndef ipconfigDHCP_REGISTER_HOSTNAME 608 #define ipconfigDHCP_REGISTER_HOSTNAME 0 609 #endif 610 611 /* 612 * Only applicable when DHCP is in use: 613 * If no DHCP server responds, use "Auto-IP" : the 614 * device will allocate a random LinkLayer IP address. 615 */ 616 #ifndef ipconfigDHCP_FALL_BACK_AUTO_IP 617 #define ipconfigDHCP_FALL_BACK_AUTO_IP ( 0 ) 618 #endif 619 620 /* When a link-layer address is assigned, the driver will test 621 * if it is already taken by a different device by sending ARP 622 * requests. Therefore, 'ipconfigARP_USE_CLASH_DETECTION' must 623 * be defined as non-zero. 624 */ 625 #if ( ipconfigDHCP_FALL_BACK_AUTO_IP != 0 ) 626 #ifndef ipconfigARP_USE_CLASH_DETECTION 627 #define ipconfigARP_USE_CLASH_DETECTION 1 628 #else 629 #if ( ipconfigARP_USE_CLASH_DETECTION != 1 ) 630 #error ipconfigARP_USE_CLASH_DETECTION should be defined as 1 when AUTO_IP is used. 631 #endif 632 #endif 633 #endif 634 635 /* If ipconfigDHCP_FALL_BACK_AUTO_IP is not used, the code for 636 * clash detection is not needed. 637 */ 638 #ifndef ipconfigARP_USE_CLASH_DETECTION 639 #define ipconfigARP_USE_CLASH_DETECTION 0 640 #endif 641 642 /* An important macro: 'ipconfigNETWORK_MTU' determines the Maximum 643 * transmission unit, which is a network packet minus the size of the 644 * 14-byte Ethernet header. 645 */ 646 #ifndef ipconfigNETWORK_MTU 647 #define ipconfigNETWORK_MTU 1500 648 #else 649 /* A sanity check to avoid a possible overflow of size_t. */ 650 #if ipconfigNETWORK_MTU > ( SIZE_MAX >> 1 ) 651 /* MISRA Ref 20.5.1 [Use of undef] */ 652 /* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-2051 */ 653 /* coverity[misra_c_2012_rule_20_5_violation] */ 654 #undef ipconfigNETWORK_MTU 655 #define ipconfigNETWORK_MTU ( SIZE_MAX >> 1 ) 656 #endif 657 #endif 658 659 #if ( ipconfigNETWORK_MTU < 46 ) 660 #error ipconfigNETWORK_MTU must be at least 46. 661 #endif 662 663 /* The maximum segment size used by TCP, it is the maximum size of 664 * the TCP payload per packet. 665 * For IPv4: when MTU equals 1500, the MSS equals 1460. 666 * It is recommended to use the default value defined here. 667 * 668 * In FreeRTOS_TCP_IP.c, there is a local macro called 'tcpREDUCED_MSS_THROUGH_INTERNET'. 669 * When a TCP connection is made outside the local network, the MSS 670 * will be reduced to 'tcpREDUCED_MSS_THROUGH_INTERNET' before the connection 671 * is made. 672 */ 673 #ifndef ipconfigTCP_MSS 674 #define ipconfigTCP_MSS ( ipconfigNETWORK_MTU - ( ipSIZE_OF_IPv4_HEADER + ipSIZE_OF_TCP_HEADER ) ) 675 #endif 676 677 /* This macro defines the minimum size of an outgoing Ethernet packet. 678 * When zero, there is no minimum. 679 * When non-zero, the packet will be extended to the minimum size. 680 * The extra bytes will be cleared. 681 * In many projects a value of 60 is used. 682 * The 32-bit CRC added in the physical layer is not included. 683 */ 684 #ifndef ipconfigETHERNET_MINIMUM_PACKET_BYTES 685 #define ipconfigETHERNET_MINIMUM_PACKET_BYTES 0 686 #endif 687 688 /* Each TCP socket has circular stream buffers for reception and transmission, 689 * which have a fixed maximum size. 690 * The defaults for these sizes are defined here, although 691 * they can be overridden at runtime by calling FreeRTOS_setsockopt(), 692 * and use 'FREERTOS_SO_RCVBUF', 'FREERTOS_SO_SNDBUF' or 693 * 'FREERTOS_SO_WIN_PROPERTIES'. 694 * A stream buffer will only be created when needed. A TCP server socket 695 * will never create buffers. 696 */ 697 #ifndef ipconfigTCP_RX_BUFFER_LENGTH 698 /* When MTU equals 1500, the buffer length defaults to 5840 bytes */ 699 #define ipconfigTCP_RX_BUFFER_LENGTH ( 4U * ipconfigTCP_MSS ) 700 #endif 701 702 /* Define the size of Tx stream buffer for TCP sockets. 703 */ 704 #ifndef ipconfigTCP_TX_BUFFER_LENGTH 705 /* When MTU equals 1500, the buffer length defaults to 5840 bytes */ 706 #define ipconfigTCP_TX_BUFFER_LENGTH ( 4U * ipconfigTCP_MSS ) 707 #endif 708 709 /* 'ipconfigMAXIMUM_DISCOVER_TX_PERIOD' is about DHCP. 710 * It determines the maximum time (in clock-ticks) that the DHCP client 711 * will wait for an offer from a DHCP server. */ 712 #ifndef ipconfigMAXIMUM_DISCOVER_TX_PERIOD 713 #ifdef _WINDOWS_ 714 #define ipconfigMAXIMUM_DISCOVER_TX_PERIOD ( pdMS_TO_TICKS( 999U ) ) 715 #else 716 #define ipconfigMAXIMUM_DISCOVER_TX_PERIOD ( pdMS_TO_TICKS( 30000U ) ) 717 #endif /* _WINDOWS_ */ 718 #endif /* ipconfigMAXIMUM_DISCOVER_TX_PERIOD */ 719 720 #if ( ipconfigUSE_DNS == 0 ) 721 /* The DNS module will not be included. */ 722 #if ( ( ipconfigUSE_LLMNR != 0 ) || ( ipconfigUSE_NBNS != 0 ) ) 723 /* LLMNR and NBNS depend on DNS because those protocols share a lot of code. */ 724 #error When either LLMNR or NBNS is used, ipconfigUSE_DNS must be defined 725 #endif 726 #endif 727 728 /* By default, the DNS client is included. Note that LLMNR and 729 * NBNS also need the code from FreeRTOS_DNS.c 730 */ 731 #ifndef ipconfigUSE_DNS 732 #define ipconfigUSE_DNS 1 733 #endif 734 735 #if ( ipconfigUSE_IPv4 == 0 ) && ( ipconfigUSE_DNS != 0 ) 736 #error "IPv4 (ipconfigUSE_IPv4) needs to be enabled to use DNS" 737 #endif 738 739 /* When looking up a host with DNS, this macro determines how long the 740 * call to FreeRTOS_recvfrom() will wait for a reply. 741 * When there is no reply, the request will be repeated up to 742 * 'ipconfigDNS_REQUEST_ATTEMPTS' attempts. */ 743 #ifndef ipconfigDNS_RECEIVE_BLOCK_TIME_TICKS 744 #define ipconfigDNS_RECEIVE_BLOCK_TIME_TICKS pdMS_TO_TICKS( 5000U ) 745 #endif 746 747 /* When looking up a host with DNS, this macro determines how long the 748 * call to FreeRTOS_sendto() will block to wait for a free buffer. */ 749 #ifndef ipconfigDNS_SEND_BLOCK_TIME_TICKS 750 #define ipconfigDNS_SEND_BLOCK_TIME_TICKS pdMS_TO_TICKS( 500U ) 751 #endif 752 753 /* The number of times a DNS request will be send before giving up. */ 754 #ifndef ipconfigDNS_REQUEST_ATTEMPTS 755 #define ipconfigDNS_REQUEST_ATTEMPTS 5 756 #endif 757 758 /* The results of DNS lookup's can be stored in a cache table. */ 759 #ifndef ipconfigUSE_DNS_CACHE 760 #define ipconfigUSE_DNS_CACHE 1 761 #endif 762 763 #if ( ipconfigUSE_DNS_CACHE != 0 ) 764 765 /* Per https://tools.ietf.org/html/rfc1035, 253 is the maximum string length 766 * of a DNS name. The following default accounts for a null terminator. */ 767 #ifndef ipconfigDNS_CACHE_NAME_LENGTH 768 #define ipconfigDNS_CACHE_NAME_LENGTH 254U 769 #endif 770 771 /* The number of entries in the DNS cache table. 772 * The default of 1 is maybe too economic. */ 773 #ifndef ipconfigDNS_CACHE_ENTRIES 774 #define ipconfigDNS_CACHE_ENTRIES 1U 775 #endif 776 777 #endif /* ipconfigUSE_DNS_CACHE != 0 */ 778 779 /* When accessing services which have multiple IP addresses, setting this 780 * greater than 1 can improve reliability by returning different IP address 781 * answers on successive calls to FreeRTOS_gethostbyname(). */ 782 #ifndef ipconfigDNS_CACHE_ADDRESSES_PER_ENTRY 783 #define ipconfigDNS_CACHE_ADDRESSES_PER_ENTRY 1 784 #endif 785 786 /* When 'ipconfigDNS_USE_CALLBACKS' is defined, a function 'FreeRTOS_gethostbyname_a()' 787 * will become available. 788 * It is used for asynchronous DNS lookups. 789 * This function will start a DNS-lookup and set an application hook. 790 * This hook will be called when either the URL has been found, or when 791 * a time-out has been reached. 792 * Note that the function 'FreeRTOS_gethostbyname_a()' will not make use of the 793 * macros 'ipconfigDNS_SEND_BLOCK_TIME_TICKS', 'ipconfigDNS_RECEIVE_BLOCK_TIME_TICKS' 794 * or 'ipconfigDNS_REQUEST_ATTEMPTS'. 795 */ 796 #ifndef ipconfigDNS_USE_CALLBACKS 797 #define ipconfigDNS_USE_CALLBACKS 0 798 #endif 799 800 /* Include support for LLMNR: Link-local Multicast Name Resolution. */ 801 #ifndef ipconfigUSE_LLMNR 802 #define ipconfigUSE_LLMNR ( 0 ) 803 #endif 804 805 /* Include support for NBNS: NetBIOS Name Server. */ 806 #ifndef ipconfigUSE_NBNS 807 #define ipconfigUSE_NBNS 0 808 #endif 809 810 /* Include support for MDNS: Multicast DNS. */ 811 #ifndef ipconfigUSE_MDNS 812 #define ipconfigUSE_MDNS 0 813 #endif 814 815 /* It is recommended to let the application respond to incoming ping 816 * requests. */ 817 #ifndef ipconfigREPLY_TO_INCOMING_PINGS 818 #define ipconfigREPLY_TO_INCOMING_PINGS 1 819 #endif 820 821 /* Add code for outgoing pings as well. */ 822 #ifndef ipconfigSUPPORT_OUTGOING_PINGS 823 #define ipconfigSUPPORT_OUTGOING_PINGS 0 824 #endif 825 826 /* A MISRA note: The macros 'ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES' 827 * and 'ipconfigETHERNET_DRIVER_FILTERS_PACKETS' are too long: 828 * the first 32 bytes are equal, which might cause problems 829 * for some compilers. */ 830 831 /* Beside that, there is some overlap between the following 3 macros. Here is 832 * a summary: 833 * 834 * 1) ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES 835 * When disabled, the IP-task will call 'eConsiderFrameForProcessing()' 836 * to check incoming packets. 837 * 2) ipconfigETHERNET_DRIVER_FILTERS_PACKETS 838 * When disabled, the IP-task will perform sanity checks on the IP-header, 839 * also checking the target IP address. 840 * Also when disabled, xPortHasUDPSocket() won't be included. That means 841 * that the IP-task can access the 'xBoundUDPSocketsList' without locking. 842 * 3) ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES 843 * When enabled, the function 'eConsiderFrameForProcessing()' will also 844 * check if the Ethernet frame type is acceptable. 845 */ 846 847 /* The following macro determines if the network interface will 848 * do checks on the incoming packets. When false, the IP-task will 849 * perform these checks in the function eConsiderFrameForProcessing(). 850 * 851 * It should be noted that it is most efficient to drop unwanted packets 852 * as early as possible. 853 */ 854 855 #ifndef ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES 856 #define ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES 1 857 #endif 858 859 /* When ipconfigETHERNET_DRIVER_FILTERS_PACKETS is enabled, the network 860 * interface will inspect the incoming packets to see if they can be 861 * accepted. 862 * When enabled, the function 'xPortHasUDPSocket()' will become available. 863 * That function checks if there is a UDP socket listening to a 864 * given port number. 865 */ 866 #ifndef ipconfigETHERNET_DRIVER_FILTERS_PACKETS 867 #define ipconfigETHERNET_DRIVER_FILTERS_PACKETS ( 0 ) 868 #endif 869 870 /* When defined as 1, the driver will drop all packets with an unknown 871 * frame type. 872 * This macro is only looked at when 'ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES' 873 * is disabled. 874 */ 875 #ifndef ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES 876 #define ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES 1 877 #endif 878 879 880 /* The macro 'ipconfigINCLUDE_EXAMPLE_FREERTOS_PLUS_TRACE_CALLS' was 881 * introduced to enable a tracing system. 882 * Currently it is only used in BufferAllocation_2.c. 883 */ 884 #ifndef configINCLUDE_TRACE_RELATED_CLI_COMMANDS 885 #define ipconfigINCLUDE_EXAMPLE_FREERTOS_PLUS_TRACE_CALLS 0 886 #else 887 #define ipconfigINCLUDE_EXAMPLE_FREERTOS_PLUS_TRACE_CALLS configINCLUDE_TRACE_RELATED_CLI_COMMANDS 888 #endif 889 890 /* This macro will be called in every loop the IP-task makes. It may be 891 * replaced by user-code that triggers a watchdog */ 892 #ifndef ipconfigWATCHDOG_TIMER 893 #define ipconfigWATCHDOG_TIMER() 894 #endif 895 896 /* The option 'ipconfigUSE_CALLBACKS' allows to assign specific application 897 * hooks to a socket. Each hook will be set with a specific socket option: 898 * 899 * FREERTOS_SO_TCP_CONN_HANDLER * Callback for (dis) connection events. 900 * * Supply pointer to 'F_TCP_UDP_Handler_t' 901 * FREERTOS_SO_TCP_RECV_HANDLER * Callback for receiving TCP data. 902 * * Supply pointer to 'F_TCP_UDP_Handler_t' 903 * FREERTOS_SO_TCP_SENT_HANDLER * Callback for sending TCP data. 904 * * Supply pointer to 'F_TCP_UDP_Handler_t' 905 * FREERTOS_SO_UDP_RECV_HANDLER * Callback for receiving UDP data. 906 * * Supply pointer to 'F_TCP_UDP_Handler_t' 907 * FREERTOS_SO_UDP_SENT_HANDLER * Callback for sending UDP data. 908 * * Supply pointer to 'F_TCP_UDP_Handler_t' 909 * 910 * Note that the call-back functions will run in the IP-task, so very little 911 * things can be done. Better not to call any networking API, because that 912 * could easily lead to a deadlock situation. 913 */ 914 #ifndef ipconfigUSE_CALLBACKS 915 #define ipconfigUSE_CALLBACKS ( 0 ) 916 #endif 917 918 /* Replace this macro with a test returning non-zero if the memory pointer to by 919 * pxAddress is valid memory which can contain executable code. 920 * In fact this is an extra safety measure: if a handler points to invalid memory, 921 * it will not be called. 922 * The parameter 'pxAddress' is in fact a pointer to a function. 923 */ 924 #if ( ipconfigUSE_CALLBACKS != 0 ) 925 #ifndef ipconfigIS_VALID_PROG_ADDRESS 926 #define ipconfigIS_VALID_PROG_ADDRESS( pxAddress ) ( ( pxAddress ) != NULL ) 927 #endif 928 #endif 929 930 /* The macro 'ipconfigHAS_INLINE_FUNCTIONS' is now deprecated. */ 931 #ifndef ipconfigHAS_INLINE_FUNCTIONS 932 #define ipconfigHAS_INLINE_FUNCTIONS ( 1 ) 933 #endif 934 935 /* Since all code is made compatible with the MISRA rules, the inline functions 936 * disappear. 'portINLINE' should normally be defined in FreeRTOSCOnfig.h 937 */ 938 #ifndef portINLINE 939 #define portINLINE inline 940 #endif 941 942 /* When non-zero, the buffers passed to xNetworkInterfaceOutput() will be passed 943 * directly to DMA. As soon as sending is ready, the buffers must be released by 944 * calling vReleaseNetworkBufferAndDescriptor(). */ 945 #ifndef ipconfigZERO_COPY_TX_DRIVER 946 #define ipconfigZERO_COPY_TX_DRIVER ( 0 ) 947 #endif 948 949 /* When enabled, the network interface will pass the network buffers directly to 950 * the DMA descriptors. When a packet has been received, the function 951 * pxPacketBuffer_to_NetworkBuffer() will translate a buffer address to a 952 * network packet, so it can be passed to the IP-task. */ 953 #ifndef ipconfigZERO_COPY_RX_DRIVER 954 #define ipconfigZERO_COPY_RX_DRIVER ( 0 ) 955 #endif 956 957 /* When ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM is defined as non-zero, 958 * the network interface is responsible for setting the checksums 959 * of the outgoing packets. 960 * This can be either done in hardware, or by calling the checksum 961 * routines from 'xNetworkInterfaceOutput()'. 962 */ 963 #ifndef ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM 964 #define ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM 0 965 #endif 966 967 /* When ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM is enabled, 968 * the network interface is responsible for checking the checksums 969 * of the incoming packets. If hardware supports checking TCP checksum only, 970 * the network interface layer should handle the same for other protocols, 971 * such as IP/UDP/ICMP/etc, and give the checksum verified packets to the 972 * FreeRTOS-plus-TCP stack. 973 * 974 * This can be either done in hardware, or by calling the checksum 975 * functions. 976 */ 977 #ifndef ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM 978 #define ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM 0 979 #endif 980 981 /* The macro 'ipconfigSOCKET_HAS_USER_SEMAPHORE' is rarely used, yet it 982 * can be very useful. IT applies to both TCP and UDP sockets. 983 * 984 * The application can register a semaphore ( of type 'SemaphoreHandle_t' ) 985 * in a socket with the option 'FREERTOS_SO_SET_SEMAPHORE'. 986 * Once set, the semaphore will be signalled after every important socket event: 987 * READ, WRITE, EXCEPTION. 988 * Note that a READ event is also generated for a TCP socket in listen mode, 989 * and a WRITE event is generated when a call to connect() has succeeded. 990 * Beside that, READ and WRITE are the normal events that occur when 991 * data has been received or delivered. 992 */ 993 #ifndef ipconfigSOCKET_HAS_USER_SEMAPHORE 994 #define ipconfigSOCKET_HAS_USER_SEMAPHORE 0 995 #endif 996 997 /* The macro 'ipconfigSOCKET_HAS_USER_WAKE_CALLBACK' allows to use a call-back 998 * function that will be called at the moment one of the above events occurs. 999 * Use the socket option 'FREERTOS_SO_WAKEUP_CALLBACK' to install a function 1000 * of the type 'void callback( Socket_t pxSocket )'. 1001 * Note that the call-back function runs in the IP-task, so very little things 1002 * can be done. Better not to call any networking API, because that could 1003 * easily lead to a deadlock situation. 1004 */ 1005 #ifndef ipconfigSOCKET_HAS_USER_WAKE_CALLBACK 1006 #define ipconfigSOCKET_HAS_USER_WAKE_CALLBACK 0 1007 #endif 1008 1009 /* Yet another possibility that makes it easy to handle multiple socket in 1010 * a single task FreeRTOS_select(). The code for this functionality will 1011 * be included when 'ipconfigSUPPORT_SELECT_FUNCTION' is defined as non-zero. 1012 */ 1013 #ifndef ipconfigSUPPORT_SELECT_FUNCTION 1014 #define ipconfigSUPPORT_SELECT_FUNCTION 0 1015 #endif 1016 1017 /* If the select function will be called simultaneously from more that one task 1018 * e.g. one for 'eSELECT_READ', and the other for the other flags, it is strongly 1019 * recommended to define 'ipconfigSELECT_USES_NOTIFY'. 1020 * The problem is 'eSELECT_CALL_IP': 2 tasks would be waiting for the same bit 1021 * in the event group, and both will try to reset this bit. 1022 * When ipconfigSELECT_USES_NOTIFY is used, the IP-task will wakeup the calling 1023 * task by notifying it. 1024 */ 1025 #ifndef ipconfigSELECT_USES_NOTIFY 1026 #define ipconfigSELECT_USES_NOTIFY 0 1027 #endif 1028 1029 /* TCP only: if the 'ipconfigTCP_KEEP_ALIVE' macro is defined as 1, 1030 * sockets in state "ESTABLISHED" can be protected using keep-alive packets. 1031 * These packets will be sent as soon as there hasn't been any activity 1032 * for a while. 1033 * The macro 'ipconfigTCP_KEEP_ALIVE_INTERVAL' determines the interval at 1034 * which keep-alive packets are sent. 1035 */ 1036 #ifndef ipconfigTCP_KEEP_ALIVE 1037 #define ipconfigTCP_KEEP_ALIVE 0 1038 #endif 1039 1040 /* The period of non-activity ( in seconds ) after which the driver will 1041 * start sending a keep-alive packet to the TCP peer. The default is 20 seconds. 1042 */ 1043 #ifndef ipconfigTCP_KEEP_ALIVE_INTERVAL 1044 #define ipconfigTCP_KEEP_ALIVE_INTERVAL 20U 1045 #endif 1046 1047 /* Another less used option: signals. This macro makes it possible to interrupt 1048 * a blocking call to one of the API's by calling either FreeRTOS_SignalSocket() or 1049 * FreeRTOS_SignalSocketFromISR() for that socket. 1050 * When an API got interrupted, it will return the error value -pdFREERTOS_ERRNO_EINTR. 1051 */ 1052 #ifndef ipconfigSUPPORT_SIGNALS 1053 #define ipconfigSUPPORT_SIGNALS 0 1054 #endif 1055 1056 /* Hang protection can help reduce the impact of SYN floods. 1057 * When a SYN packet comes in, it will first be checked if there is a listening 1058 * socket for the port number. If not, it will be replied to with a RESET packet. 1059 * If there is a listing socket for that port number, a new socket will be created. 1060 * This socket will be owned temporarily by the IP-task. Only when the SYN/ACK 1061 * handshake is finished, the new socket will be passed to the application, 1062 * resulting in a successful call to FreeRTOS_accept(). 1063 * The option 'ipconfigTCP_HANG_PROTECTION' will make sure that the socket will be 1064 * deleted in case the SYN-handshake doesn't come to a good end. 1065 * See also ipconfigTCP_HANG_PROTECTION_TIME time. 1066 */ 1067 #ifndef ipconfigTCP_HANG_PROTECTION 1068 #define ipconfigTCP_HANG_PROTECTION 1 1069 #endif 1070 1071 /* ipconfigTCP_HANG_PROTECTION_TIME defines the maximum time that a socket stays 1072 * in one of these "in-between" states: 1073 * 1074 * eCONNECT_SYN, eSYN_FIRST, eSYN_RECEIVED, eFIN_WAIT_1, eFIN_WAIT_2, eCLOSING, 1075 * eLAST_ACK, or eTIME_WAIT. 1076 */ 1077 #ifndef ipconfigTCP_HANG_PROTECTION_TIME 1078 #define ipconfigTCP_HANG_PROTECTION_TIME 30U 1079 #endif 1080 1081 /* Initially, 'ipconfigTCP_IP_SANITY' was introduced to include all code that checks 1082 * the correctness of the algorithms. However, it is only used in BufferAllocation_1.c 1083 * When defined as non-zero, some extra code will check the validity of network buffers. 1084 */ 1085 #ifndef ipconfigTCP_IP_SANITY 1086 #define ipconfigTCP_IP_SANITY 0 1087 #endif 1088 1089 /* Expert option: define a value for 'ipBUFFER_PADDING'. 1090 * When 'ipconfigBUFFER_PADDING' equals 0, 1091 * 'ipBUFFER_PADDING' will get a default value of 8 + 2 bytes. */ 1092 #ifndef ipconfigBUFFER_PADDING 1093 #define ipconfigBUFFER_PADDING 0U 1094 #endif 1095 1096 /* This library treats the network packets as structs, containing 16- and 32-bit 1097 * variables. However, due to the size of the Ethernet header, the 32-byte 1098 * variables are badly aligned. 1099 * This is corrected with the macro 'ipconfigPACKET_FILLER_SIZE' which has a default 1100 * of two. Thanks to this offset, ( almost ) all 32-bit numbers can be read and 1101 * written in a single assembler instruction. 1102 */ 1103 #ifndef ipconfigPACKET_FILLER_SIZE 1104 #define ipconfigPACKET_FILLER_SIZE 2U 1105 #endif 1106 1107 /* Set to 1 if you plan on processing custom Ethernet protocols or protocols 1108 * that are not yet supported by the FreeRTOS+TCP stack. If set to 1, 1109 * the user must define eFrameProcessingResult_t eApplicationProcessCustomFrameHook( NetworkBufferDescriptor_t * const pxNetworkBuffer ) 1110 * which will be called by the stack for any frame with an unsupported EtherType. */ 1111 #ifndef ipconfigPROCESS_CUSTOM_ETHERNET_FRAMES 1112 #define ipconfigPROCESS_CUSTOM_ETHERNET_FRAMES 0 1113 #endif 1114 1115 /* Set to 1 if you want to receive eNetworkDown notification via vApplicationIPNetworkEventHook() callback. 1116 * Not all drivers support this feature. */ 1117 #ifndef ipconfigSUPPORT_NETWORK_DOWN_EVENT 1118 #define ipconfigSUPPORT_NETWORK_DOWN_EVENT 0 1119 #endif 1120 1121 #ifndef ipconfigND_CACHE_ENTRIES 1122 #define ipconfigND_CACHE_ENTRIES 24 1123 #endif 1124 1125 #ifndef ipconfigHAS_ROUTING_STATISTICS 1126 #define ipconfigHAS_ROUTING_STATISTICS 1 1127 #endif 1128 1129 #ifndef ipconfigUSE_RA 1130 #define ipconfigUSE_RA 1 1131 #endif 1132 1133 /* RA or Router Advertisement/SLAAC: see end-point flag 'bWantRA'. 1134 * An Router Solicitation will be sent. It will wait for ipconfigRA_SEARCH_TIME_OUT_MSEC ms. 1135 * When there is no response, it will be repeated ipconfigRA_SEARCH_COUNT times. 1136 * Then it will be checked if the chosen IP-address already exists, repeating this 1137 * ipconfigRA_IP_TEST_COUNT times, each time with a timeout of ipconfigRA_IP_TEST_TIME_OUT_MSEC ms. 1138 * Finally the end-point will go in the UP state. 1139 */ 1140 #ifndef ipconfigRA_SEARCH_COUNT 1141 #define ipconfigRA_SEARCH_COUNT ( 3U ) 1142 #endif 1143 1144 #ifndef ipconfigRA_SEARCH_TIME_OUT_MSEC 1145 #define ipconfigRA_SEARCH_TIME_OUT_MSEC ( 10000U ) 1146 #endif 1147 1148 #ifndef ipconfigRA_IP_TEST_COUNT 1149 #define ipconfigRA_IP_TEST_COUNT ( 3 ) 1150 #endif 1151 1152 #ifndef ipconfigRA_IP_TEST_TIME_OUT_MSEC 1153 #define ipconfigRA_IP_TEST_TIME_OUT_MSEC ( 1500U ) 1154 #endif 1155 1156 /* For some use cases, users set the configurations that issues warning messages. 1157 * This configuration is used to suppress warning in portable layers to make compilation clean. 1158 */ 1159 #ifndef ipconfigPORT_SUPPRESS_WARNING 1160 #define ipconfigPORT_SUPPRESS_WARNING ( 0 ) 1161 #endif 1162 1163 #endif /* FREERTOS_DEFAULT_IP_CONFIG_H */ 1164