From f6971c5960a2925fe8764260d3d1c9a3c5046ea0 Mon Sep 17 00:00:00 2001 From: Hein Tibosch Date: Sat, 8 May 2021 17:23:44 +0800 Subject: [PATCH 1/3] IPv6/multi : Before sending a challenge, check the sequence number more properly. --- FreeRTOS_TCP_IP.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/FreeRTOS_TCP_IP.c b/FreeRTOS_TCP_IP.c index 1f5d079ed7..2b36313976 100644 --- a/FreeRTOS_TCP_IP.c +++ b/FreeRTOS_TCP_IP.c @@ -3967,9 +3967,9 @@ vTCPStateChange( pxSocket, eCLOSED ); } /* Otherwise, check whether the packet is within the receive window. */ - else if( ( ulSequenceNumber > pxSocket->u.xTCP.xTCPWindow.rx.ulCurrentSequenceNumber ) && - ( ulSequenceNumber < ( pxSocket->u.xTCP.xTCPWindow.rx.ulCurrentSequenceNumber + - pxSocket->u.xTCP.xTCPWindow.xSize.ulRxWindowLength ) ) ) + else if( ( xSequenceGreaterThan( ulSequenceNumber, pxSocket->u.xTCP.xTCPWindow.rx.ulCurrentSequenceNumber ) != pdFALSE ) && + ( xSequenceLessThan( ulSequenceNumber, pxSocket->u.xTCP.xTCPWindow.rx.ulCurrentSequenceNumber + + pxSocket->u.xTCP.xTCPWindow.xSize.ulRxWindowLength ) != pdFALSE ) ) { /* Send a challenge ACK. */ ( void ) prvTCPSendChallengeAck( pxNetworkBuffer ); From 9334bb9ac2b78fe8d0bc8356163152eb5a10d1c1 Mon Sep 17 00:00:00 2001 From: Hein Tibosch Date: Sat, 8 May 2021 17:32:21 +0800 Subject: [PATCH 2/3] Make 2 sequence compare functions public in TCP_WIN. --- FreeRTOS_TCP_WIN.c | 54 ++++++++++++++++---------------------- include/FreeRTOS_TCP_WIN.h | 25 ++++++++++++++++++ 2 files changed, 47 insertions(+), 32 deletions(-) diff --git a/FreeRTOS_TCP_WIN.c b/FreeRTOS_TCP_WIN.c index 6c315ae697..e1de99f750 100644 --- a/FreeRTOS_TCP_WIN.c +++ b/FreeRTOS_TCP_WIN.c @@ -260,10 +260,6 @@ #endif /* ipconfigUSE_TCP_WIN */ /*-----------------------------------------------------------*/ - #if ( ipconfigUSE_TCP_WIN == 1 ) - static portINLINE BaseType_t xSequenceLessThan( uint32_t a, - uint32_t b ); - /** * @brief Check if a < b. * @@ -272,26 +268,21 @@ * * @return pdTRUE when "( b - ( a + 1 ) ) < 0x80000000", else pdFALSE. */ - static portINLINE BaseType_t xSequenceLessThan( uint32_t a, - uint32_t b ) - { - BaseType_t xResult = pdFALSE; - - /* Test if a < b */ - if( ( ( b - ( a + 1U ) ) & 0x80000000U ) == 0U ) - { - xResult = pdTRUE; - } + BaseType_t xSequenceLessThan( uint32_t a, + uint32_t b ) + { + BaseType_t xResult = pdFALSE; - return xResult; + /* Test if a < b */ + if( ( ( b - ( a + 1U ) ) & 0x80000000U ) == 0U ) + { + xResult = pdTRUE; } - #endif /* ipconfigUSE_TCP_WIN */ -/*-----------------------------------------------------------*/ + return xResult; + } - #if ( ipconfigUSE_TCP_WIN == 1 ) - static portINLINE BaseType_t xSequenceGreaterThan( uint32_t a, - uint32_t b ); +/*-----------------------------------------------------------*/ /** * @brief Check if a > b. @@ -301,21 +292,20 @@ * * @return pdTRUE when "( a - b ) < 0x80000000", else pdFALSE. */ - static portINLINE BaseType_t xSequenceGreaterThan( uint32_t a, - uint32_t b ) - { - BaseType_t xResult = pdFALSE; - - /* Test if a > b */ - if( ( ( a - ( b + 1U ) ) & 0x80000000U ) == 0U ) - { - xResult = pdTRUE; - } + BaseType_t xSequenceGreaterThan( uint32_t a, + uint32_t b ) + { + BaseType_t xResult = pdFALSE; - return xResult; + /* Test if a > b */ + if( ( ( a - ( b + 1U ) ) & 0x80000000U ) == 0U ) + { + xResult = pdTRUE; } - #endif /* ipconfigUSE_TCP_WIN */ + return xResult; + } + /*-----------------------------------------------------------*/ static portINLINE BaseType_t xSequenceGreaterThanOrEqual( uint32_t a, diff --git a/include/FreeRTOS_TCP_WIN.h b/include/FreeRTOS_TCP_WIN.h index db03d7e7b5..025aaa426f 100644 --- a/include/FreeRTOS_TCP_WIN.h +++ b/include/FreeRTOS_TCP_WIN.h @@ -218,6 +218,31 @@ uint32_t ulFirst, uint32_t ulLast ); +/** + * @brief Check if a > b, where a and b are rolling counters. + * + * @param[in] a: The value on the left-hand side. + * @param[in] b: The value on the right-hand side. + * + * @return pdTRUE if a > b, otherwise pdFALSE. + * + * @note GreaterThan is calculated as "( a - ( b + 1U ) ) < 0x80000000". + */ + BaseType_t xSequenceGreaterThan( uint32_t a, + uint32_t b ); + +/** + * @brief Check if a < b, where a and b are rolling counters. + * + * @param[in] a: The value on the left-hand side. + * @param[in] b: The value on the right-hand side. + * + * @return pdTRUE if a < b, otherwise pdFALSE. + * + * @note LessThan is implemented as "( b - ( a + 1 ) ) < 0x80000000". + */ + BaseType_t xSequenceLessThan( uint32_t a, + uint32_t b ); #ifdef __cplusplus } /* extern "C" */ From c64eab537fe507a2850da2ec6b479e815db34e0d Mon Sep 17 00:00:00 2001 From: Hein Tibosch Date: Sun, 9 May 2021 12:58:23 +0800 Subject: [PATCH 3/3] Changes to lexicon.txt --- .github/lexicon.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/lexicon.txt b/.github/lexicon.txt index 2b85c4c48e..71ed198a37 100644 --- a/.github/lexicon.txt +++ b/.github/lexicon.txt @@ -358,6 +358,7 @@ gmacsa gpio gpl gratuitous +greaterthan grr gswutr gw @@ -457,6 +458,7 @@ ldistance leds len lendofframe +lessthan letbase linkcurr linklayer