6464#ifndef ipINITIALISATION_RETRY_DELAY
6565 #define ipINITIALISATION_RETRY_DELAY ( pdMS_TO_TICKS( 3000U ) )
6666#endif
67+
6768#if ( ipconfigUSE_TCP_MEM_STATS != 0 )
6869 #include "tcp_mem_stats.h"
6970#endif
7071
71- /** @brief Maximum time to wait for a resolution while holding a packet. */
72- #ifndef ipADDR_RES_MAX_DELAY
73- #define ipADDR_RES_MAX_DELAY ( pdMS_TO_TICKS( 2000U ) )
72+ /** @brief Maximum time to wait for an ARP resolution while holding a packet. */
73+ #ifndef ipARP_RESOLUTION_MAX_DELAY
74+ #define ipARP_RESOLUTION_MAX_DELAY ( pdMS_TO_TICKS( 2000U ) )
7475#endif
7576
76- #ifndef iptraceIP_TASK_STARTING
77- #define iptraceIP_TASK_STARTING () do {} while( ipFALSE_BOOL ) /**< Empty definition in case iptraceIP_TASK_STARTING is not defined. */
77+ /** @brief Maximum time to wait for a ND resolution while holding a packet. */
78+ #ifndef ipND_RESOLUTION_MAX_DELAY
79+ #define ipND_RESOLUTION_MAX_DELAY ( pdMS_TO_TICKS( 2000U ) )
7880#endif
7981
80- #if ( ( ipconfigUSE_TCP == 1 ) && !defined( ipTCP_TIMER_PERIOD_MS ) )
81- /** @brief When initialising the TCP timer, give it an initial time-out of 1 second. */
82- #define ipTCP_TIMER_PERIOD_MS ( 1000U )
82+ /** @brief Defines how often the ARP resolution timer callback function is executed. The time is
83+ * shorter in the Windows simulator as simulated time is not real time. */
84+ #ifndef ipARP_TIMER_PERIOD_MS
85+ #ifdef _WINDOWS_
86+ #define ipARP_TIMER_PERIOD_MS ( 500U ) /* For windows simulator builds. */
87+ #else
88+ #define ipARP_TIMER_PERIOD_MS ( 10000U )
89+ #endif
8390#endif
8491
85- /** @brief Defines how often the resolution timer callback function is executed. The time is
92+ /** @brief Defines how often the ND resolution timer callback function is executed. The time is
8693 * shorter in the Windows simulator as simulated time is not real time. */
87- #ifndef ipADDR_RES_TIMER_PERIOD_MS
94+ #ifndef ipND_TIMER_PERIOD_MS
8895 #ifdef _WINDOWS_
89- #define ipADDR_RES_TIMER_PERIOD_MS ( 500U ) /* For windows simulator builds. */
96+ #define ipND_TIMER_PERIOD_MS ( 500U ) /* For windows simulator builds. */
9097 #else
91- #define ipADDR_RES_TIMER_PERIOD_MS ( 10000U )
98+ #define ipND_TIMER_PERIOD_MS ( 10000U )
9299 #endif
93100#endif
94101
102+ #if ( ( ipconfigUSE_TCP == 1 ) && !defined( ipTCP_TIMER_PERIOD_MS ) )
103+ /** @brief When initialising the TCP timer, give it an initial time-out of 1 second. */
104+ #define ipTCP_TIMER_PERIOD_MS ( 1000U )
105+ #endif
106+
107+ #ifndef iptraceIP_TASK_STARTING
108+ #define iptraceIP_TASK_STARTING () do {} while( ipFALSE_BOOL ) /**< Empty definition in case iptraceIP_TASK_STARTING is not defined. */
109+ #endif
110+
95111/** @brief The frame type field in the Ethernet header must have a value greater than 0x0600.
96112 * If the configuration option ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES is enabled, the stack
97113 * will discard packets with a frame type value less than or equal to 0x0600.
@@ -106,8 +122,15 @@ static void prvIPTask_CheckPendingEvents( void );
106122
107123/*-----------------------------------------------------------*/
108124
109- /** @brief The pointer to buffer with packet waiting for resolution. */
110- NetworkBufferDescriptor_t * pxResolutionWaitingNetworkBuffer = NULL ;
125+ /** @brief The pointer to buffer with packet waiting for ARP resolution. */
126+ #if ipconfigIS_ENABLED ( ipconfigUSE_IPv4 )
127+ NetworkBufferDescriptor_t * pxARPWaitingNetworkBuffer = NULL ;
128+ #endif
129+
130+ /** @brief The pointer to buffer with packet waiting for ND resolution. */
131+ #if ipconfigIS_ENABLED ( ipconfigUSE_IPv6 )
132+ NetworkBufferDescriptor_t * pxNDWaitingNetworkBuffer = NULL ;
133+ #endif
111134
112135/*-----------------------------------------------------------*/
113136
@@ -293,16 +316,18 @@ static void prvProcessIPEventsAndTimers( void )
293316 prvForwardTxPacket ( ( ( NetworkBufferDescriptor_t * ) xReceivedEvent .pvData ), pdTRUE );
294317 break ;
295318
296- case eResolutionTimerEvent :
297- /* The Resolution timer has expired, process the cache. */
298- #if ( ipconfigUSE_IPv4 != 0 )
319+ case eARPTimerEvent :
320+ /* The ARP Resolution timer has expired, process the cache. */
321+ #if ipconfigIS_ENABLED ( ipconfigUSE_IPv4 )
299322 vARPAgeCache ();
300323 #endif /* ( ipconfigUSE_IPv4 != 0 ) */
324+ break ;
301325
302- #if ( ipconfigUSE_IPv6 != 0 )
326+ case eNDTimerEvent :
327+ /* The ND Resolution timer has expired, process the cache. */
328+ #if ipconfigIS_ENABLED ( ipconfigUSE_IPv6 )
303329 vNDAgeCache ();
304330 #endif /* ( ipconfigUSE_IPv6 != 0 ) */
305-
306331 break ;
307332
308333 case eSocketBindEvent :
@@ -493,8 +518,15 @@ static void prvIPTask_Initialise( void )
493518 }
494519 #endif
495520
496- /* Mark the timer as inactive since we are not waiting on any resolution as of now. */
497- vIPSetResolutionTimerEnableState ( pdFALSE );
521+ #if ipconfigIS_ENABLED ( ipconfigUSE_IPv4 )
522+ /* Mark the ARP timer as inactive since we are not waiting on any resolution as of now. */
523+ vIPSetARPResolutionTimerEnableState ( pdFALSE );
524+ #endif
525+
526+ #if ipconfigIS_ENABLED ( ipconfigUSE_IPv6 )
527+ /* Mark the ND timer as inactive since we are not waiting on any resolution as of now. */
528+ vIPSetNDResolutionTimerEnableState ( pdFALSE );
529+ #endif
498530
499531 #if ( ( ipconfigDNS_USE_CALLBACKS != 0 ) && ( ipconfigUSE_DNS != 0 ) )
500532 {
@@ -648,7 +680,18 @@ void vIPNetworkUpCalls( struct xNetworkEndPoint * pxEndPoint )
648680 #endif /* ipconfigDNS_USE_CALLBACKS != 0 */
649681
650682 /* Set remaining time to 0 so it will become active immediately. */
651- vResolutionTimerReload ( pdMS_TO_TICKS ( ipADDR_RES_TIMER_PERIOD_MS ) );
683+ if ( pxEndPoint -> bits .bIPv6 == pdTRUE_UNSIGNED )
684+ {
685+ #if ipconfigIS_ENABLED ( ipconfigUSE_IPv6 )
686+ vNDTimerReload ( pdMS_TO_TICKS ( ipND_TIMER_PERIOD_MS ) );
687+ #endif
688+ }
689+ else
690+ {
691+ #if ipconfigIS_ENABLED ( ipconfigUSE_IPv4 )
692+ vARPTimerReload ( pdMS_TO_TICKS ( ipARP_TIMER_PERIOD_MS ) );
693+ #endif
694+ }
652695}
653696/*-----------------------------------------------------------*/
654697
@@ -1733,20 +1776,47 @@ static void prvProcessEthernetPacket( NetworkBufferDescriptor_t * const pxNetwor
17331776
17341777 case eWaitingResolution :
17351778
1736- if ( pxResolutionWaitingNetworkBuffer == NULL )
1737- {
1738- pxResolutionWaitingNetworkBuffer = pxNetworkBuffer ;
1739- vIPTimerStartResolution ( ipADDR_RES_MAX_DELAY );
1779+ #if ipconfigIS_ENABLED ( ipconfigUSE_IPv4 )
1780+ if ( pxEthernetHeader -> usFrameType == ipIPv4_FRAME_TYPE )
1781+ {
1782+ if ( pxARPWaitingNetworkBuffer == NULL )
1783+ {
1784+ pxARPWaitingNetworkBuffer = pxNetworkBuffer ;
1785+ vIPTimerStartARPResolution ( ipARP_RESOLUTION_MAX_DELAY );
17401786
1741- iptraceDELAYED_RESOLUTION_REQUEST_STARTED ();
1742- }
1743- else
1744- {
1745- /* We are already waiting on one resolution. This frame will be dropped. */
1746- vReleaseNetworkBufferAndDescriptor ( pxNetworkBuffer );
1787+ iptraceDELAYED_ARP_REQUEST_STARTED ();
1788+ }
1789+ else
1790+ {
1791+ /* We are already waiting on one resolution. This frame will be dropped. */
1792+ vReleaseNetworkBufferAndDescriptor ( pxNetworkBuffer );
17471793
1748- iptraceDELAYED_RESOLUTION_BUFFER_FULL ();
1749- }
1794+ iptraceDELAYED_ARP_BUFFER_FULL ();
1795+ }
1796+ break ;
1797+ }
1798+ #endif
1799+
1800+ #if ipconfigIS_ENABLED ( ipconfigUSE_IPv6 )
1801+ if ( pxEthernetHeader -> usFrameType == ipIPv6_FRAME_TYPE )
1802+ {
1803+ if ( pxNDWaitingNetworkBuffer == NULL )
1804+ {
1805+ pxNDWaitingNetworkBuffer = pxNetworkBuffer ;
1806+ vIPTimerStartNDResolution ( ipND_RESOLUTION_MAX_DELAY );
1807+
1808+ iptraceDELAYED_ND_REQUEST_STARTED ();
1809+ }
1810+ else
1811+ {
1812+ /* We are already waiting on one resolution. This frame will be dropped. */
1813+ vReleaseNetworkBufferAndDescriptor ( pxNetworkBuffer );
1814+
1815+ iptraceDELAYED_ND_BUFFER_FULL ();
1816+ }
1817+ break ;
1818+ }
1819+ #endif
17501820
17511821 break ;
17521822
0 commit comments