diff --git a/source/FreeRTOS_ARP.c b/source/FreeRTOS_ARP.c index 1e1fa615e..1a3dc6a47 100644 --- a/source/FreeRTOS_ARP.c +++ b/source/FreeRTOS_ARP.c @@ -962,7 +962,7 @@ static BaseType_t prvFindCacheEntry( const MACAddress_t * pxMACAddress, MACAddress_t * const pxMACAddress, struct xNetworkEndPoint ** ppxEndPoint ) { - eARPLookupResult_t eReturn; + eARPLookupResult_t eReturn = eCantSendPacket; uint32_t ulAddressToLookup; NetworkEndPoint_t * pxEndPoint = NULL; @@ -974,12 +974,21 @@ static BaseType_t prvFindCacheEntry( const MACAddress_t * pxMACAddress, ulAddressToLookup = *pulIPAddress; pxEndPoint = FreeRTOS_FindEndPointOnIP_IPv4( ulAddressToLookup ); - if( xIsIPv4Multicast( ulAddressToLookup ) != 0 ) + if( xIsIPv4Loopback( ulAddressToLookup ) != 0 ) + { + if( pxEndPoint != NULL ) + { + /* For multi-cast, use the first IPv4 end-point. */ + memcpy( pxMACAddress->ucBytes, pxEndPoint->xMACAddress.ucBytes, sizeof( pxMACAddress->ucBytes ) ); + *( ppxEndPoint ) = pxEndPoint; + eReturn = eARPCacheHit; + } + } + else if( xIsIPv4Multicast( ulAddressToLookup ) != 0 ) { /* Get the lowest 23 bits of the IP-address. */ vSetMultiCastIPv4MacAddress( ulAddressToLookup, pxMACAddress ); - eReturn = eCantSendPacket; pxEndPoint = FreeRTOS_FirstEndPoint( NULL ); for( ; diff --git a/source/FreeRTOS_DNS_Callback.c b/source/FreeRTOS_DNS_Callback.c index 15bddbfe5..5dd1658ac 100644 --- a/source/FreeRTOS_DNS_Callback.c +++ b/source/FreeRTOS_DNS_Callback.c @@ -76,8 +76,8 @@ BaseType_t xMatching; DNSCallback_t * pxCallback = ( ( DNSCallback_t * ) listGET_LIST_ITEM_OWNER( pxIterator ) ); #if ( ipconfigUSE_MDNS == 1 ) - /* mDNS port 5353. */ - if( pxSet->usPortNumber == FreeRTOS_htons( ipMDNS_PORT ) ) + /* mDNS port 5353. Host byte order comparison. */ + if( pxSet->usPortNumber == ipMDNS_PORT ) { /* In mDNS, the query ID field is ignored and the * hostname will be compared with outstanding requests. */ diff --git a/source/FreeRTOS_Sockets.c b/source/FreeRTOS_Sockets.c index a4ffaf389..b473c06f5 100644 --- a/source/FreeRTOS_Sockets.c +++ b/source/FreeRTOS_Sockets.c @@ -2356,17 +2356,25 @@ void * vSocketClose( FreeRTOS_Socket_t * pxSocket ) uint32_t ulNewValue; BaseType_t xReturn; + if( ( FreeRTOS_issocketconnected( pxSocket ) == pdTRUE ) ) + { + /* If this socket is the child of a listening socket, the remote client may or may not have already sent + * us data. If data was already sent, then pxSocket->u.xTCP.rxStream != NULL and this call will fail. + * Warn the user about this inconsistent behavior. */ + FreeRTOS_printf( ( "Warning: Changing buffer/window properties on a connected socket may fail." ) ); + } + if( pxSocket->ucProtocol != ( uint8_t ) FREERTOS_IPPROTO_TCP ) { - FreeRTOS_debug_printf( ( "Set SO_%sBUF: wrong socket type\n", - ( lOptionName == FREERTOS_SO_SNDBUF ) ? "SND" : "RCV" ) ); + FreeRTOS_printf( ( "Set SO_%sBUF: wrong socket type\n", + ( lOptionName == FREERTOS_SO_SNDBUF ) ? "SND" : "RCV" ) ); xReturn = -pdFREERTOS_ERRNO_EINVAL; } else if( ( ( lOptionName == FREERTOS_SO_SNDBUF ) && ( pxSocket->u.xTCP.txStream != NULL ) ) || ( ( lOptionName == FREERTOS_SO_RCVBUF ) && ( pxSocket->u.xTCP.rxStream != NULL ) ) ) { - FreeRTOS_debug_printf( ( "Set SO_%sBUF: buffer already created\n", - ( lOptionName == FREERTOS_SO_SNDBUF ) ? "SND" : "RCV" ) ); + FreeRTOS_printf( ( "Set SO_%sBUF: buffer already created\n", + ( lOptionName == FREERTOS_SO_SNDBUF ) ? "SND" : "RCV" ) ); xReturn = -pdFREERTOS_ERRNO_EINVAL; } else diff --git a/source/FreeRTOS_Stream_Buffer.c b/source/FreeRTOS_Stream_Buffer.c index 5c0c52fc8..5f0d08f5b 100644 --- a/source/FreeRTOS_Stream_Buffer.c +++ b/source/FreeRTOS_Stream_Buffer.c @@ -307,7 +307,7 @@ size_t uxStreamBufferAdd( StreamBuffer_t * const pxBuffer, /* The below update to the stream buffer members must happen * atomically. */ - vTaskSuspendAll(); + taskENTER_CRITICAL(); { if( uxOffset == 0U ) { @@ -328,7 +328,7 @@ size_t uxStreamBufferAdd( StreamBuffer_t * const pxBuffer, pxBuffer->uxFront = uxNextHead; } } - ( void ) xTaskResumeAll(); + taskEXIT_CRITICAL(); } return uxCount; diff --git a/source/portable/NetworkInterface/RX/NetworkInterface.c b/source/portable/NetworkInterface/RX/NetworkInterface.c index 6f5d3a6c7..1c3874173 100644 --- a/source/portable/NetworkInterface/RX/NetworkInterface.c +++ b/source/portable/NetworkInterface/RX/NetworkInterface.c @@ -101,8 +101,10 @@ void prvLinkStatusChange( BaseType_t xStatus ); /*-----------------------------------------------------------*/ -NetworkInterface_t * pxRX_FillInterfaceDescriptor( BaseType_t xEMACIndex, - NetworkInterface_t * pxInterface ); +#if ( ipconfigIPv4_BACKWARD_COMPATIBLE != 0 ) + NetworkInterface_t * pxRX_FillInterfaceDescriptor( BaseType_t xEMACIndex, + NetworkInterface_t * pxInterface ); +#endif /* Function to initialise the network interface */ BaseType_t xRX_NetworkInterfaceInitialise( NetworkInterface_t * pxInterface ); @@ -136,6 +138,14 @@ NetworkInterface_t * pxRX_FillInterfaceDescriptor( BaseType_t xEMACIndex, return pxInterface; } +#if ( ipconfigIPv4_BACKWARD_COMPATIBLE != 0 ) + NetworkInterface_t * pxFillInterfaceDescriptor( BaseType_t xEMACIndex, + NetworkInterface_t * pxInterface ) + { + return pxRX_FillInterfaceDescriptor( xEMACIndex, pxInterface ); + } +#endif + /*********************************************************************************************************************** * Function Name: xRX_NetworkInterfaceInitialise () * Description : Initialization of Ethernet driver. diff --git a/source/portable/NetworkInterface/loopback/loopbackNetworkInterface.c b/source/portable/NetworkInterface/loopback/loopbackNetworkInterface.c index cf66a62ff..9152d4744 100644 --- a/source/portable/NetworkInterface/loopback/loopbackNetworkInterface.c +++ b/source/portable/NetworkInterface/loopback/loopbackNetworkInterface.c @@ -134,23 +134,23 @@ static BaseType_t prvLoopback_Output( NetworkInterface_t * pxInterface, } { - MACAddress_t xMACAddress; + const MACAddress_t * pxMACAddress = &( pxDescriptor->pxEndPoint->xMACAddress ); if( pxDescriptor->pxEndPoint->bits.bIPv6 != 0 ) { #if ( ipconfigUSE_IPv6 != 0 ) - if( xIsIPv6Loopback( &( pxDescriptor->xIPAddress ) ) != pdFALSE ) + if( xIsIPv6Loopback( &( pxDescriptor->xIPAddress.xIP_IPv6 ) ) != pdFALSE ) { - vNDRefreshCacheEntry( &xMACAddress, &( pxDescriptor->xIPAddress.xIP_IPv6 ), pxDescriptor->pxEndPoint ); + vNDRefreshCacheEntry( pxMACAddress, &( pxDescriptor->xIPAddress.xIP_IPv6 ), pxDescriptor->pxEndPoint ); } #endif } else { #if ( ipconfigUSE_IPv4 != 0 ) - if( xIsIPv4Loopback( pxDescriptor->xIPAddress.ulIP_IPv4 ) ) + if( xIsIPv4Loopback( pxDescriptor->xIPAddress.ulIP_IPv4 ) != pdFALSE ) { - vARPRefreshCacheEntry( &xMACAddress, pxDescriptor->xIPAddress.ulIP_IPv4, pxDescriptor->pxEndPoint ); + vARPRefreshCacheEntry( pxMACAddress, pxDescriptor->xIPAddress.ulIP_IPv4, pxDescriptor->pxEndPoint ); } #endif } @@ -170,11 +170,21 @@ static BaseType_t prvLoopback_Output( NetworkInterface_t * pxInterface, xRxEvent.eEventType = eNetworkRxEvent; xRxEvent.pvData = ( void * ) pxDescriptor; - if( xSendEventStructToIPTask( &xRxEvent, 0u ) != pdTRUE ) + pxDescriptor->pxInterface = xLoopbackInterface; + pxDescriptor->pxEndPoint = FreeRTOS_MatchingEndpoint( xLoopbackInterface, pxDescriptor->pucEthernetBuffer ); + + if( pxDescriptor->pxEndPoint == NULL ) + { + vReleaseNetworkBufferAndDescriptor( pxDescriptor ); + iptraceETHERNET_RX_EVENT_LOST(); + FreeRTOS_printf( ( "prvLoopback_Output: Can not find a proper endpoint\n" ) ); + } + else if( xSendEventStructToIPTask( &xRxEvent, 0u ) != pdTRUE ) { + /* Sending failed, release the descriptor. */ vReleaseNetworkBufferAndDescriptor( pxDescriptor ); iptraceETHERNET_RX_EVENT_LOST(); - FreeRTOS_printf( ( "prvEMACRxPoll: Can not queue return packet!\n" ) ); + FreeRTOS_printf( ( "prvLoopback_Output: Can not queue return packet!\n" ) ); } } diff --git a/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c b/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c index 057d39619..106520eb7 100644 --- a/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c +++ b/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c @@ -558,6 +558,7 @@ void test_eARPProcessPacket_Request_GratuitousARP( void ) vResetARPClashCounter(); FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( &xEndPoint ); + xIsIPv4Loopback_ExpectAndReturn( ulTargetIP, 0UL ); xIsIPv4Multicast_ExpectAndReturn( ulTargetIP, 0UL ); FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( &xEndPoint ); FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( &xEndPoint ); @@ -621,6 +622,7 @@ void test_eARPProcessPacket_Request_GratuitousARP_MACUnchanged( void ) vResetARPClashCounter(); FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( &xEndPoint ); + xIsIPv4Loopback_ExpectAndReturn( ulTargetIP, 0UL ); xIsIPv4Multicast_ExpectAndReturn( ulTargetIP, 0UL ); FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( &xEndPoint ); FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( &xEndPoint ); @@ -863,6 +865,7 @@ void test_eARPProcessPacket_Request_GratuitousARP_NonMatchingEndpoint( void ) vResetARPClashCounter(); FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( &xEndPoint ); + xIsIPv4Loopback_ExpectAndReturn( ulTargetIP, 0UL ); xIsIPv4Multicast_ExpectAndReturn( ulTargetIP, 0UL ); FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( &xEndPoint ); @@ -926,6 +929,7 @@ void test_eARPProcessPacket_Request_GratuitousARP_NonMatchingIP( void ) vResetARPClashCounter(); FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( &xEndPoint ); + xIsIPv4Loopback_ExpectAndReturn( ulTargetIP, 0UL ); xIsIPv4Multicast_ExpectAndReturn( ulTargetIP, 0UL ); FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( &xEndPoint ); @@ -2090,6 +2094,7 @@ void test_eARPGetCacheEntry_IPMatchesBroadcastAddr( void ) ulIPAddress = FreeRTOS_ntohl( xNetworkAddressing.ulBroadcastAddress ); /* Not worried about what these functions do. */ FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); + xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL ); xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL ); FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( &xEndPoint ); eResult = eARPGetCacheEntry( &ulIPAddress, &xMACAddress, &pxEndPoint ); @@ -2112,6 +2117,7 @@ void test_eARPGetCacheEntry_IPMatchesBroadcastAddr_NullEndPointOnNetMask( void ) ulIPAddress = FreeRTOS_ntohl( xNetworkAddressing.ulBroadcastAddress ); /* Not worried about what these functions do. */ FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); + xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL ); xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL ); FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( NULL ); eResult = eARPGetCacheEntry( &ulIPAddress, &xMACAddress, &pxEndPoint ); @@ -2132,6 +2138,7 @@ void test_eARPGetCacheEntry_MultiCastAddr( void ) /* =================================================== */ ulIPAddress = FreeRTOS_ntohl( xNetworkAddressing.ulBroadcastAddress ); FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); + xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL ); xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 1UL ); vSetMultiCastIPv4MacAddress_Ignore(); FreeRTOS_FirstEndPoint_ExpectAndReturn( NULL, NULL ); @@ -2144,6 +2151,7 @@ void test_eARPGetCacheEntry_MultiCastAddr( void ) xEndPoint.bits.bIPv6 = 1; FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); + xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL ); xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 1UL ); vSetMultiCastIPv4MacAddress_Ignore(); FreeRTOS_FirstEndPoint_ExpectAndReturn( NULL, &xEndPoint ); @@ -2169,6 +2177,7 @@ void test_eARPGetCacheEntry_IPMatchesOtherBroadcastAddr( void ) ulIPAddress = FreeRTOS_ntohl( ipBROADCAST_IP_ADDRESS ); /* Not worried about what these functions do. */ FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); + xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL ); xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL ); FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( &xEndPoint ); eResult = eARPGetCacheEntry( &ulIPAddress, &xMACAddress, &pxEndPoint ); @@ -2198,6 +2207,7 @@ void test_eARPGetCacheEntry_MatchingInvalidEntry( void ) /* Not worried about what these functions do. */ xEndPoint.ipv4_settings.ulGatewayAddress = xNetworkAddressing.ulGatewayAddress; FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); + xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL ); xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL ); FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( NULL ); FreeRTOS_FindGateWay_ExpectAnyArgsAndReturn( &xEndPoint ); @@ -2227,6 +2237,7 @@ void test_eARPGetCacheEntry_MatchingValidEntry( void ) /* Not worried about what these functions do. */ xEndPoint.ipv4_settings.ulGatewayAddress = xNetworkAddressing.ulGatewayAddress; FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); + xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL ); xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL ); FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( NULL ); FreeRTOS_FindGateWay_ExpectAnyArgsAndReturn( &xEndPoint ); @@ -2259,6 +2270,7 @@ void test_eARPGetCacheEntry_GatewayAddressZero( void ) /* Not worried about what these functions do. */ xEndPoint.ipv4_settings.ulGatewayAddress = 0; FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); + xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL ); xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL ); FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( NULL ); FreeRTOS_FindGateWay_ExpectAnyArgsAndReturn( NULL ); @@ -2286,6 +2298,7 @@ void test_eARPGetCacheEntry_AddressNotOnLocalAddress( void ) /* Not worried about what these functions do. */ FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); + xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL ); xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL ); FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( NULL ); FreeRTOS_FindGateWay_ExpectAnyArgsAndReturn( NULL ); @@ -2324,6 +2337,7 @@ void test_eARPGetCacheEntry_NoCacheHit( void ) pxNetworkEndPoints = &xEndPoint; /* Not worried about what these functions do. */ FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); + xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL ); xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL ); FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( NULL ); eResult = eARPGetCacheEntry( &ulIPAddress, &xMACAddress, &pxEndPoint ); @@ -2333,6 +2347,91 @@ void test_eARPGetCacheEntry_NoCacheHit( void ) /* =================================================== */ } +/** + * @brief Test the scenario that the address given is a loopback address + * but there is no loopback endpoint + */ +void test_eARPGetCacheEntry_LoopbackAddress( void ) +{ + uint32_t ulIPAddress; + MACAddress_t xMACAddress = { 0 }; + MACAddress_t xMACAddressExp = { 0 }; + eARPLookupResult_t eResult; + uint32_t ulSavedGatewayAddress; + struct xNetworkInterface * xInterface; + struct xNetworkEndPoint * pxEndPoint, xEndPoint; + int i; + + /* =================================================== */ + for( i = 0; i < ipconfigARP_CACHE_ENTRIES; i++ ) + { + xARPCache[ i ].ulIPAddress = 0; + xARPCache[ i ].ucValid = ( uint8_t ) pdTRUE; + xARPCache[ i ].pxEndPoint = NULL; + } + + ulSavedGatewayAddress = xNetworkAddressing.ulGatewayAddress; + xNetworkAddressing.ulGatewayAddress = 0; + /* Make IP address param == 0 */ + ulIPAddress = 0x7F000000UL; + + /* Make both values (IP address and local IP pointer) different + * and on different net masks. */ + xEndPoint.ipv4_settings.ulIPAddress = 0x1234; + pxNetworkEndPoints = &xEndPoint; + /* Not worried about what these functions do. */ + FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); + xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 1UL ); + eResult = eARPGetCacheEntry( &ulIPAddress, &xMACAddress, &pxEndPoint ); + TEST_ASSERT_EQUAL( eCantSendPacket, eResult ); + TEST_ASSERT_NOT_EQUAL( pxEndPoint, &xEndPoint ); + TEST_ASSERT_EQUAL_MEMORY( xMACAddressExp.ucBytes, xMACAddress.ucBytes, sizeof( MACAddress_t ) ); + /* =================================================== */ +} + +/** + * @brief Test the scenario that the address given is a loopback address + * and there is a loopback endpoint + */ +void test_eARPGetCacheEntry_LoopbackAddress_ValidLPEndpoint( void ) +{ + uint32_t ulIPAddress; + MACAddress_t xMACAddress = { 0 }; + MACAddress_t xMACAddressExp = { 0x11, 0x22, 0x33, 0x11, 0x22, 0x33 }; + eARPLookupResult_t eResult; + uint32_t ulSavedGatewayAddress; + struct xNetworkInterface * xInterface; + struct xNetworkEndPoint * pxEndPoint, xEndPoint; + int i; + + /* =================================================== */ + for( i = 0; i < ipconfigARP_CACHE_ENTRIES; i++ ) + { + xARPCache[ i ].ulIPAddress = 0; + xARPCache[ i ].ucValid = ( uint8_t ) pdTRUE; + xARPCache[ i ].pxEndPoint = NULL; + } + + ulSavedGatewayAddress = xNetworkAddressing.ulGatewayAddress; + xNetworkAddressing.ulGatewayAddress = 0; + /* Make IP address param == 0 */ + ulIPAddress = 0x7F000000UL; + + /* Make both values (IP address and local IP pointer) different + * and on different net masks. */ + xEndPoint.ipv4_settings.ulIPAddress = 0x1234; + memcpy( xEndPoint.xMACAddress.ucBytes, xMACAddressExp.ucBytes, sizeof( MACAddress_t ) ); + pxNetworkEndPoints = &xEndPoint; + /* Not worried about what these functions do. */ + FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( &xEndPoint ); + xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 1UL ); + eResult = eARPGetCacheEntry( &ulIPAddress, &xMACAddress, &pxEndPoint ); + TEST_ASSERT_EQUAL( eARPCacheHit, eResult ); + TEST_ASSERT_EQUAL( pxEndPoint, &xEndPoint ); + TEST_ASSERT_EQUAL_MEMORY( xMACAddressExp.ucBytes, xMACAddress.ucBytes, sizeof( MACAddress_t ) ); + /* =================================================== */ +} + void test_vARPAgeCache( void ) { NetworkEndPoint_t xEndPoint = { 0 }; @@ -2641,6 +2740,7 @@ void test_xARPWaitResolution_PrivateFunctionReturnsHit( void ) xIsCallingFromIPTask_IgnoreAndReturn( pdFALSE ); /* Not worried about what these functions do. */ FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); + xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL ); xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 1UL ); vSetMultiCastIPv4MacAddress_Ignore(); FreeRTOS_FirstEndPoint_ExpectAndReturn( NULL, &xEndPoint ); @@ -2679,6 +2779,7 @@ void test_xARPWaitResolution_GNWFailsNoTimeout( void ) FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); xIsCallingFromIPTask_IgnoreAndReturn( pdFALSE ); /* Not worried about what these functions do. */ + xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL ); xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL ); FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( ( void * ) 1234 ); @@ -2691,6 +2792,7 @@ void test_xARPWaitResolution_GNWFailsNoTimeout( void ) pxGetNetworkBufferWithDescriptor_ExpectAndReturn( sizeof( ARPPacket_t ), 0, NULL ); vTaskDelay_Expect( pdMS_TO_TICKS( 250U ) ); FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); + xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL ); xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL ); FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( ( void * ) 1234 ); xTaskCheckForTimeOut_IgnoreAndReturn( pdFALSE ); @@ -2730,6 +2832,7 @@ void test_xARPWaitResolution( void ) FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); xIsCallingFromIPTask_IgnoreAndReturn( pdFALSE ); /* Not worried about what these functions do. */ + xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL ); xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL ); FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( ( void * ) 1234 ); @@ -2742,6 +2845,7 @@ void test_xARPWaitResolution( void ) pxGetNetworkBufferWithDescriptor_ExpectAndReturn( sizeof( ARPPacket_t ), 0, NULL ); vTaskDelay_Expect( pdMS_TO_TICKS( 250U ) ); FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); + xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL ); xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL ); FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( ( void * ) 1234 ); xTaskCheckForTimeOut_IgnoreAndReturn( pdFALSE ); @@ -2751,6 +2855,7 @@ void test_xARPWaitResolution( void ) pxGetNetworkBufferWithDescriptor_ExpectAndReturn( sizeof( ARPPacket_t ), 0, NULL ); vTaskDelay_Expect( pdMS_TO_TICKS( 250U ) ); FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); + xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL ); xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL ); FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( ( void * ) 1234 ); xTaskCheckForTimeOut_IgnoreAndReturn( pdTRUE ); @@ -2778,6 +2883,7 @@ void test_xARPWaitResolution( void ) FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); xIsCallingFromIPTask_IgnoreAndReturn( pdFALSE ); /* Not worried about what these functions do. */ + xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL ); xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL ); FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( ( void * ) 1234 ); @@ -2790,6 +2896,7 @@ void test_xARPWaitResolution( void ) pxGetNetworkBufferWithDescriptor_ExpectAndReturn( sizeof( ARPPacket_t ), 0, NULL ); vTaskDelay_Expect( pdMS_TO_TICKS( 250U ) ); FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); + xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL ); xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL ); FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( ( void * ) 1234 ); xTaskCheckForTimeOut_IgnoreAndReturn( pdFALSE ); @@ -2799,6 +2906,7 @@ void test_xARPWaitResolution( void ) pxGetNetworkBufferWithDescriptor_ExpectAndReturn( sizeof( ARPPacket_t ), 0, NULL ); vTaskDelay_Expect( pdMS_TO_TICKS( 250U ) ); FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); + xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL ); xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 1UL ); vSetMultiCastIPv4MacAddress_Ignore(); FreeRTOS_FirstEndPoint_ExpectAndReturn( NULL, &xEndPoint ); diff --git a/test/unit-test/FreeRTOS_DNS_Callback/FreeRTOS_DNS_Callback_utest.c b/test/unit-test/FreeRTOS_DNS_Callback/FreeRTOS_DNS_Callback_utest.c index d35100387..1f3eae7f0 100644 --- a/test/unit-test/FreeRTOS_DNS_Callback/FreeRTOS_DNS_Callback_utest.c +++ b/test/unit-test/FreeRTOS_DNS_Callback/FreeRTOS_DNS_Callback_utest.c @@ -216,7 +216,7 @@ void test_xDNSDoCallback_success_equal_port_number_equal_name( void ) DNSCallback_t * pxDnsCallback = ( DNSCallback_t * ) &dnsCallbackMemory; pxSet.pxDNSMessageHeader = &xDNSMessageHeader; - pxSet.usPortNumber = FreeRTOS_htons( ipMDNS_PORT ); + pxSet.usPortNumber = ipMDNS_PORT; strcpy( pxSet.pcName, pc_name ); pxDnsCallback->pCallbackFunction = dns_callback; strcpy( pxDnsCallback->pcName, pc_name ); @@ -255,7 +255,7 @@ void test_xDNSDoCallback_fail_equal_port_number_not_equal_name( void ) pxSet.pxDNSMessageHeader = &xDNSMessageHeader; pxSet.pxDNSMessageHeader->usIdentifier = 123; - pxSet.usPortNumber = FreeRTOS_htons( ipMDNS_PORT ); + pxSet.usPortNumber = ipMDNS_PORT; char pc_name[] = "test"; strcpy( pxSet.pcName, pc_name ); dnsCallback->pCallbackFunction = dns_callback; diff --git a/test/unit-test/FreeRTOS_Stream_Buffer/FreeRTOS_Stream_Buffer_utest.c b/test/unit-test/FreeRTOS_Stream_Buffer/FreeRTOS_Stream_Buffer_utest.c index b4e6c3d29..2fcb41c55 100644 --- a/test/unit-test/FreeRTOS_Stream_Buffer/FreeRTOS_Stream_Buffer_utest.c +++ b/test/unit-test/FreeRTOS_Stream_Buffer/FreeRTOS_Stream_Buffer_utest.c @@ -601,9 +601,6 @@ void test_uxStreamBufferAdd_BufferHasMoreSpaceThanData_ZeroOffset_DataWriteCause FreeRTOS_min_size_t_Stub( FreeRTOS_min_stub ); - vTaskSuspendAll_Expect(); - xTaskResumeAll_ExpectAndReturn( pdTRUE ); - uxReturn = uxStreamBufferAdd( pxLocalBuffer, uxOffset, pucData, uxByteCount ); /* Only these many bytes should be written. */ @@ -656,9 +653,6 @@ void test_uxStreamBufferAdd_BufferHasLessSpaceThanData_ZeroOffset( void ) FreeRTOS_min_size_t_Stub( FreeRTOS_min_stub ); - vTaskSuspendAll_Expect(); - xTaskResumeAll_ExpectAndReturn( pdTRUE ); - uxReturn = uxStreamBufferAdd( pxLocalBuffer, uxOffset, pucData, uxByteCount ); /* Only 500 bytes should be written. */ @@ -702,9 +696,6 @@ void test_uxStreamBufferAdd_BufferHasLessSpaceThanData_NonZeroOffset( void ) FreeRTOS_min_size_t_Stub( FreeRTOS_min_stub ); - vTaskSuspendAll_Expect(); - xTaskResumeAll_ExpectAndReturn( pdTRUE ); - uxReturn = uxStreamBufferAdd( pxLocalBuffer, uxOffset, pucData, uxByteCount ); /* Only these many bytes should be written. */ @@ -757,9 +748,6 @@ void test_uxStreamBufferAdd_BufferHasLessSpaceThanData_NonZeroOffsetCausesRollov FreeRTOS_min_size_t_Stub( FreeRTOS_min_stub ); - vTaskSuspendAll_Expect(); - xTaskResumeAll_ExpectAndReturn( pdTRUE ); - uxReturn = uxStreamBufferAdd( pxLocalBuffer, uxOffset, pucData, uxByteCount ); /* Only these many bytes should be written. */ @@ -813,9 +801,6 @@ void test_uxStreamBufferAdd_BufferHasLessSpaceThanData_ZeroOffset_DataWriteCause FreeRTOS_min_size_t_Stub( FreeRTOS_min_stub ); - vTaskSuspendAll_Expect(); - xTaskResumeAll_ExpectAndReturn( pdTRUE ); - uxReturn = uxStreamBufferAdd( pxLocalBuffer, uxOffset, pucData, uxByteCount ); /* Only these many bytes should be written. */ @@ -873,9 +858,6 @@ void test_uxStreamBufferAdd_NULLData_BufferHasLessSpaceThanData_ZeroOffset_DataW FreeRTOS_min_size_t_Stub( FreeRTOS_min_stub ); - vTaskSuspendAll_Expect(); - xTaskResumeAll_ExpectAndReturn( pdTRUE ); - uxReturn = uxStreamBufferAdd( pxLocalBuffer, uxOffset, NULL, uxByteCount ); /* Nothing should be written but tail will be updated. */ @@ -929,9 +911,6 @@ void test_uxStreamBufferAdd_NULLData_BufferHasLessSpaceThanData_ZeroOffset_DataW FreeRTOS_min_size_t_Stub( FreeRTOS_min_stub ); - vTaskSuspendAll_Expect(); - xTaskResumeAll_ExpectAndReturn( pdTRUE ); - uxReturn = uxStreamBufferAdd( pxLocalBuffer, uxOffset, NULL, uxByteCount ); /* Nothing should be written but tail should be updated. */ diff --git a/test/unit-test/FreeRTOS_TCP_Reception/FreeRTOS_TCP_Reception_utest.c b/test/unit-test/FreeRTOS_TCP_Reception/FreeRTOS_TCP_Reception_utest.c index c626a522c..a12479374 100644 --- a/test/unit-test/FreeRTOS_TCP_Reception/FreeRTOS_TCP_Reception_utest.c +++ b/test/unit-test/FreeRTOS_TCP_Reception/FreeRTOS_TCP_Reception_utest.c @@ -786,7 +786,7 @@ void test_prvCheckRxData_URG_On( void ) TEST_ASSERT_EQUAL( 4, result ); } -/* Test for prvStorexData function. */ +/* Test for prvStoreRxData function. */ void test_prvStoreRxData_Happy_Path( void ) { int32_t result; @@ -827,7 +827,7 @@ void test_prvStoreRxData_Happy_Path( void ) TEST_ASSERT_EQUAL( 0, xResult ); } -/* Test for prvStorexData function. */ +/* Test for prvStoreRxData function. */ void test_prvStoreRxData_Wrong_State( void ) { int32_t result; @@ -859,7 +859,7 @@ void test_prvStoreRxData_Wrong_State( void ) TEST_ASSERT_EQUAL( 0, xResult ); } -/* Test for prvStorexData function. */ +/* Test for prvStoreRxData function. */ void test_prvStoreRxData_Zero_Length( void ) { int32_t result; @@ -901,7 +901,7 @@ void test_prvStoreRxData_Zero_Length( void ) } -/* Test for prvStorexData function. */ +/* Test for prvStoreRxData function. */ void test_prvStoreRxData_Null_RxStream( void ) { int32_t result; @@ -938,7 +938,7 @@ void test_prvStoreRxData_Null_RxStream( void ) TEST_ASSERT_EQUAL( -1, xResult ); } -/* Test for prvStorexData function. */ +/* Test for prvStoreRxData function. */ void test_prvStoreRxData_Negative_Offset( void ) { int32_t result; @@ -975,7 +975,7 @@ void test_prvStoreRxData_Negative_Offset( void ) TEST_ASSERT_EQUAL( 0, xResult ); } -/* Test for prvStorexData function. */ +/* Test for prvStoreRxData function. */ void test_prvStoreRxData_None_Zero_Skipcount( void ) { int32_t result;