From bda977e0e9c3d7b4c16d4559bb0bdb9d7ad396d0 Mon Sep 17 00:00:00 2001 From: Holden Date: Sat, 10 Feb 2024 01:23:31 -0500 Subject: [PATCH 01/15] add checks for frame types --- source/FreeRTOS_IP.c | 139 ++++++++++++++++++++++++------------------- 1 file changed, 78 insertions(+), 61 deletions(-) diff --git a/source/FreeRTOS_IP.c b/source/FreeRTOS_IP.c index 8eb100a75e..e4c395864f 100644 --- a/source/FreeRTOS_IP.c +++ b/source/FreeRTOS_IP.c @@ -1451,84 +1451,101 @@ BaseType_t xSendEventStructToIPTask( const IPStackEvent_t * pxEvent, eFrameProcessingResult_t eConsiderFrameForProcessing( const uint8_t * const pucEthernetBuffer ) { eFrameProcessingResult_t eReturn = eProcessBuffer; - const EthernetHeader_t * pxEthernetHeader = NULL; - const NetworkEndPoint_t * pxEndPoint = NULL; - if( pucEthernetBuffer == NULL ) - { - eReturn = eReleaseBuffer; - } - else + do { - /* Map the buffer onto Ethernet Header struct for easy access to fields. */ + const EthernetHeader_t * pxEthernetHeader = NULL; + const NetworkEndPoint_t * pxEndPoint = NULL; + + if( pucEthernetBuffer == NULL ) + { + eReturn = eReleaseBuffer; + break; + } + /* Map the buffer onto Ethernet Header struct for easy access to fields. */ /* MISRA Ref 11.3.1 [Misaligned access] */ /* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */ /* coverity[misra_c_2012_rule_11_3_violation] */ pxEthernetHeader = ( ( const EthernetHeader_t * ) pucEthernetBuffer ); + switch( pxEthernetHeader->usFrameType ) + { + case ipARP_FRAME_TYPE: + case ipIPv4_FRAME_TYPE: + #if ipconfigIS_DISABLED( ipconfigUSE_IPv4 ) + eReturn = eReleaseBuffer; + #endif + break; + + case ipIPv6_FRAME_TYPE: + #if ipconfigIS_DISABLED( ipconfigUSE_IPv6 ) + eReturn = eReleaseBuffer; + #endif + break; + + default: + if( FreeRTOS_ntohs( pxEthernetHeader->usFrameType ) <= 0x600U ) + { + #if ipconfigIS_ENABLED( ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES ) + eReturn = eReleaseBuffer; + #endif + } + else + { + #if ipconfigIS_DISABLED( ipconfigPROCESS_CUSTOM_ETHERNET_FRAMES ) + eReturn = eReleaseBuffer; + #endif + } + break; + } + /* Examine the destination MAC from the Ethernet header to see if it matches * that of an end point managed by FreeRTOS+TCP. */ - pxEndPoint = FreeRTOS_FindEndPointOnMAC( &( pxEthernetHeader->xDestinationAddress ), NULL ); - + pxEndPoint = FreeRTOS_MatchingEndpoint( NULL, pucEthernetBuffer ); if( pxEndPoint != NULL ) { - /* The packet was directed to this node - process it. */ - eReturn = eProcessBuffer; - } - else if( memcmp( xBroadcastMACAddress.ucBytes, pxEthernetHeader->xDestinationAddress.ucBytes, sizeof( MACAddress_t ) ) == 0 ) - { - /* The packet was a broadcast - process it. */ - eReturn = eProcessBuffer; - } - else - #if ( ( ipconfigUSE_LLMNR == 1 ) && ( ipconfigUSE_DNS != 0 ) ) - if( memcmp( xLLMNR_MacAddress.ucBytes, pxEthernetHeader->xDestinationAddress.ucBytes, sizeof( MACAddress_t ) ) == 0 ) - { - /* The packet is a request for LLMNR - process it. */ - eReturn = eProcessBuffer; - } - else - #endif /* ipconfigUSE_LLMNR */ - #if ( ( ipconfigUSE_MDNS == 1 ) && ( ipconfigUSE_DNS != 0 ) ) - if( memcmp( xMDNS_MacAddress.ucBytes, pxEthernetHeader->xDestinationAddress.ucBytes, sizeof( MACAddress_t ) ) == 0 ) - { - /* The packet is a request for MDNS - process it. */ - eReturn = eProcessBuffer; - } - else - #endif /* ipconfigUSE_MDNS */ - if( ( pxEthernetHeader->xDestinationAddress.ucBytes[ 0 ] == ipMULTICAST_MAC_ADDRESS_IPv6_0 ) && - ( pxEthernetHeader->xDestinationAddress.ucBytes[ 1 ] == ipMULTICAST_MAC_ADDRESS_IPv6_1 ) ) - { - /* The packet is a request for LLMNR - process it. */ - eReturn = eProcessBuffer; + break; } else { - /* The packet was not a broadcast, or for this node, just release - * the buffer without taking any other action. */ + #if ipconfigIS_ENABLED( ipconfigUSE_DNS ) + #if ipconfigIS_ENABLED( ipconfigUSE_LLMNR ) + #if ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) + if( memcmp( xLLMNR_MacAddress.ucBytes, pxEthernetHeader->xDestinationAddress.ucBytes, sizeof( MACAddress_t ) ) == 0 ) + { + /* The packet is a request for LLMNR - process it. */ + break; + } + #endif + #if ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) + if( memcmp( xLLMNR_MacAddressIPv6.ucBytes, pxEthernetHeader->xDestinationAddress.ucBytes, sizeof( MACAddress_t ) ) == 0 ) + { + /* The packet is a request for LLMNR - process it. */ + break; + } + #endif + #endif + #if ipconfigIS_ENABLED( ipconfigUSE_MDNS ) + #if ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) + if( memcmp( xMDNS_MacAddress.ucBytes, pxEthernetHeader->xDestinationAddress.ucBytes, sizeof( MACAddress_t ) ) == 0 ) + { + /* The packet is a request for MDNS - process it. */ + break; + } + #endif + #if ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) + if( memcmp( xMDNS_MACAddressIPv6.ucBytes, pxEthernetHeader->xDestinationAddress.ucBytes, sizeof( MACAddress_t ) ) == 0 ) + { + /* The packet is a request for MDNS - process it. */ + break; + } + #endif + #endif + #endif eReturn = eReleaseBuffer; } - } - - #if ( ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES == 1 ) - { - uint16_t usFrameType; - - if( eReturn == eProcessBuffer ) - { - usFrameType = pxEthernetHeader->usFrameType; - usFrameType = FreeRTOS_ntohs( usFrameType ); - - if( usFrameType <= 0x600U ) - { - /* Not an Ethernet II frame. */ - eReturn = eReleaseBuffer; - } - } - } - #endif /* ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES == 1 */ + } while( ipFALSE_BOOL ); return eReturn; } From 857638b712189a996439b02374b5b0ba9d4f8bc4 Mon Sep 17 00:00:00 2001 From: Holden Date: Sat, 10 Feb 2024 13:38:12 -0500 Subject: [PATCH 02/15] address review comments --- source/FreeRTOS_IP.c | 75 +++++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 35 deletions(-) diff --git a/source/FreeRTOS_IP.c b/source/FreeRTOS_IP.c index e4c395864f..bcddb99fbd 100644 --- a/source/FreeRTOS_IP.c +++ b/source/FreeRTOS_IP.c @@ -1500,6 +1500,12 @@ eFrameProcessingResult_t eConsiderFrameForProcessing( const uint8_t * const pucE break; } + if( eReturn == eReleaseBuffer ) + { + /* No use to do more testing. */ + break; + } + /* Examine the destination MAC from the Ethernet header to see if it matches * that of an end point managed by FreeRTOS+TCP. */ pxEndPoint = FreeRTOS_MatchingEndpoint( NULL, pucEthernetBuffer ); @@ -1507,44 +1513,43 @@ eFrameProcessingResult_t eConsiderFrameForProcessing( const uint8_t * const pucE { break; } - else - { - #if ipconfigIS_ENABLED( ipconfigUSE_DNS ) - #if ipconfigIS_ENABLED( ipconfigUSE_LLMNR ) - #if ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) - if( memcmp( xLLMNR_MacAddress.ucBytes, pxEthernetHeader->xDestinationAddress.ucBytes, sizeof( MACAddress_t ) ) == 0 ) - { - /* The packet is a request for LLMNR - process it. */ - break; - } - #endif - #if ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) - if( memcmp( xLLMNR_MacAddressIPv6.ucBytes, pxEthernetHeader->xDestinationAddress.ucBytes, sizeof( MACAddress_t ) ) == 0 ) - { - /* The packet is a request for LLMNR - process it. */ - break; - } - #endif + + #if ipconfigIS_ENABLED( ipconfigUSE_DNS ) + #if ipconfigIS_ENABLED( ipconfigUSE_LLMNR ) + #if ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) + if( memcmp( xLLMNR_MacAddress.ucBytes, pxEthernetHeader->xDestinationAddress.ucBytes, sizeof( MACAddress_t ) ) == 0 ) + { + /* The packet is a request for LLMNR - process it. */ + break; + } #endif - #if ipconfigIS_ENABLED( ipconfigUSE_MDNS ) - #if ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) - if( memcmp( xMDNS_MacAddress.ucBytes, pxEthernetHeader->xDestinationAddress.ucBytes, sizeof( MACAddress_t ) ) == 0 ) - { - /* The packet is a request for MDNS - process it. */ - break; - } - #endif - #if ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) - if( memcmp( xMDNS_MACAddressIPv6.ucBytes, pxEthernetHeader->xDestinationAddress.ucBytes, sizeof( MACAddress_t ) ) == 0 ) - { - /* The packet is a request for MDNS - process it. */ - break; - } - #endif + #if ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) + if( memcmp( xLLMNR_MacAddressIPv6.ucBytes, pxEthernetHeader->xDestinationAddress.ucBytes, sizeof( MACAddress_t ) ) == 0 ) + { + /* The packet is a request for LLMNR - process it. */ + break; + } #endif #endif - eReturn = eReleaseBuffer; - } + #if ipconfigIS_ENABLED( ipconfigUSE_MDNS ) + #if ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) + if( memcmp( xMDNS_MacAddress.ucBytes, pxEthernetHeader->xDestinationAddress.ucBytes, sizeof( MACAddress_t ) ) == 0 ) + { + /* The packet is a request for MDNS - process it. */ + break; + } + #endif + #if ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) + if( memcmp( xMDNS_MACAddressIPv6.ucBytes, pxEthernetHeader->xDestinationAddress.ucBytes, sizeof( MACAddress_t ) ) == 0 ) + { + /* The packet is a request for MDNS - process it. */ + break; + } + #endif + #endif + #endif + + eReturn = eReleaseBuffer; } while( ipFALSE_BOOL ); return eReturn; From a2053177a233b3a57d9f0054fb00a0fc2971d24e Mon Sep 17 00:00:00 2001 From: Holden Date: Thu, 15 Feb 2024 03:04:04 -0500 Subject: [PATCH 03/15] Fix multicast filtering and finding endpoint --- source/FreeRTOS_DNS.c | 104 +++++++++----------- source/FreeRTOS_IP.c | 173 +++++++++++++++++++++------------- source/include/FreeRTOS_DNS.h | 40 +++----- 3 files changed, 162 insertions(+), 155 deletions(-) diff --git a/source/FreeRTOS_DNS.c b/source/FreeRTOS_DNS.c index ffce0fe658..cbb9653fbd 100644 --- a/source/FreeRTOS_DNS.c +++ b/source/FreeRTOS_DNS.c @@ -57,6 +57,48 @@ #include "FreeRTOS_DNS_Callback.h" +/** @brief The MAC address used for LLMNR. */ +const MACAddress_t xLLMNR_MacAddress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfc } }; + +/** @brief The IPv6 link-scope multicast MAC address */ +const MACAddress_t xLLMNR_MacAddressIPv6 = { { 0x33, 0x33, 0x00, 0x01, 0x00, 0x03 } }; + +/** @brief The IPv6 link-scope multicast address */ +const IPv6_Address_t ipLLMNR_IP_ADDR_IPv6 = +{ + { /* ff02::1:3 */ + 0xff, 0x02, + 0x00, 0x00, + 0x00, 0x00, + 0x00, 0x00, + 0x00, 0x00, + 0x00, 0x00, + 0x00, 0x01, + 0x00, 0x03, + } +}; + +/** @brief The MAC address used for MDNS. */ +const MACAddress_t xMDNS_MacAddress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfb } }; + +/** @brief The IPv6 multicast DNS MAC address. */ +const MACAddress_t xMDNS_MACAddressIPv6 = { { 0x33, 0x33, 0x00, 0x00, 0x00, 0xFB } }; + +/** @brief multicast DNS IPv6 address */ +const IPv6_Address_t ipMDNS_IP_ADDR_IPv6 = +{ + { /* ff02::fb */ + 0xff, 0x02, + 0x00, 0x00, + 0x00, 0x00, + 0x00, 0x00, + 0x00, 0x00, + 0x00, 0x00, + 0x00, 0x00, + 0x00, 0xfb, + } +}; + /* Exclude the entire file if DNS is not enabled. */ #if ( ipconfigUSE_DNS != 0 ) @@ -95,69 +137,7 @@ struct freertos_addrinfo ** ppxAddressInfo, BaseType_t xFamily ); - #if ( ipconfigUSE_LLMNR == 1 ) - /** @brief The MAC address used for LLMNR. */ - const MACAddress_t xLLMNR_MacAddress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfc } }; - #endif /* ipconfigUSE_LLMNR == 1 */ - /*-----------------------------------------------------------*/ - #if ( ipconfigUSE_LLMNR == 1 ) && ( ipconfigUSE_IPv6 != 0 ) - -/** - * @brief The IPv6 link-scope multicast address - */ - const IPv6_Address_t ipLLMNR_IP_ADDR_IPv6 = - { - { /* ff02::1:3 */ - 0xff, 0x02, - 0x00, 0x00, - 0x00, 0x00, - 0x00, 0x00, - 0x00, 0x00, - 0x00, 0x00, - 0x00, 0x01, - 0x00, 0x03, - } - }; - -/** - * @brief The IPv6 link-scope multicast MAC address - */ - const MACAddress_t xLLMNR_MacAddressIPv6 = { { 0x33, 0x33, 0x00, 0x01, 0x00, 0x03 } }; - #endif /* ipconfigUSE_LLMNR && ipconfigUSE_IPv6 */ - - #if ( ipconfigUSE_MDNS == 1 ) && ( ipconfigUSE_IPv6 != 0 ) - -/** - * @brief multicast DNS IPv6 address - */ - const IPv6_Address_t ipMDNS_IP_ADDR_IPv6 = - { - { /* ff02::fb */ - 0xff, 0x02, - 0x00, 0x00, - 0x00, 0x00, - 0x00, 0x00, - 0x00, 0x00, - 0x00, 0x00, - 0x00, 0x00, - 0x00, 0xfb, - } - }; - -/** - * @brief The IPv6 multicast DNS MAC address. - * The MAC-addresses are provided here in case a network - * interface needs it. - */ - const MACAddress_t xMDNS_MACAddressIPv6 = { { 0x33, 0x33, 0x00, 0x00, 0x00, 0xFB } }; - #endif /* ( ipconfigUSE_MDNS == 1 ) && ( ipconfigUSE_IPv6 != 0 ) */ - - - #if ( ipconfigUSE_MDNS == 1 ) - /** @brief The MAC address used for MDNS. */ - const MACAddress_t xMDNS_MacAddress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfb } }; - #endif /* ipconfigUSE_MDNS == 1 */ /** @brief This global variable is being used to indicate to the driver which IP type * is preferred for name service lookup, either IPv6 or IPv4. */ diff --git a/source/FreeRTOS_IP.c b/source/FreeRTOS_IP.c index bcddb99fbd..56681a9a5c 100644 --- a/source/FreeRTOS_IP.c +++ b/source/FreeRTOS_IP.c @@ -1450,15 +1450,17 @@ BaseType_t xSendEventStructToIPTask( const IPStackEvent_t * pxEvent, */ eFrameProcessingResult_t eConsiderFrameForProcessing( const uint8_t * const pucEthernetBuffer ) { - eFrameProcessingResult_t eReturn = eProcessBuffer; + eFrameProcessingResult_t eReturn = eReleaseBuffer; do { const EthernetHeader_t * pxEthernetHeader = NULL; const NetworkEndPoint_t * pxEndPoint = NULL; + /* First, check the packet buffer is non-null. */ if( pucEthernetBuffer == NULL ) { + /* The packet buffer was null - release it. */ eReturn = eReleaseBuffer; break; } @@ -1469,87 +1471,122 @@ eFrameProcessingResult_t eConsiderFrameForProcessing( const uint8_t * const pucE /* coverity[misra_c_2012_rule_11_3_violation] */ pxEthernetHeader = ( ( const EthernetHeader_t * ) pucEthernetBuffer ); - switch( pxEthernetHeader->usFrameType ) + /* Second, filter based on ethernet frame type. */ + if( FreeRTOS_ntohs( pxEthernetHeader->usFrameType ) <= 0x600U ) { - case ipARP_FRAME_TYPE: - case ipIPv4_FRAME_TYPE: - #if ipconfigIS_DISABLED( ipconfigUSE_IPv4 ) - eReturn = eReleaseBuffer; - #endif + /* The packet was not an Ethernet II frame */ + #if ipconfigIS_ENABLED( ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES ) + /* filtering is enabled - release it. */ break; - - case ipIPv6_FRAME_TYPE: - #if ipconfigIS_DISABLED( ipconfigUSE_IPv6 ) - eReturn = eReleaseBuffer; - #endif + #else + /* filtering is disabled - continue filter checks. */ + #endif + } + else if( pxEthernetHeader->usFrameType == ipARP_FRAME_TYPE ) + { + /* The frame is an ARP type */ + #if ipconfigIS_DISABLED( ipconfigUSE_IPv4 ) + /* IPv4 is disabled - release it. */ break; - - default: - if( FreeRTOS_ntohs( pxEthernetHeader->usFrameType ) <= 0x600U ) - { - #if ipconfigIS_ENABLED( ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES ) - eReturn = eReleaseBuffer; - #endif - } - else - { - #if ipconfigIS_DISABLED( ipconfigPROCESS_CUSTOM_ETHERNET_FRAMES ) - eReturn = eReleaseBuffer; - #endif - } + #else + /* IPv4 is enabled - Continue filter checks. */ + #endif + } + else if( pxEthernetHeader->usFrameType == ipIPv4_FRAME_TYPE ) + { + /* The frame is an IPv4 type */ + #if ipconfigIS_DISABLED( ipconfigUSE_IPv4 ) + /* IPv4 is disabled - release it. */ break; + #else + /* IPv4 is enabled - Continue filter checks. */ + #endif } - - if( eReturn == eReleaseBuffer ) + else if( pxEthernetHeader->usFrameType == ipIPv6_FRAME_TYPE ) { - /* No use to do more testing. */ - break; + /* The frame is an IPv6 type */ + #if ipconfigIS_DISABLED( ipconfigUSE_IPv6 ) + /* IPv6 is disabled - release it. */ + break; + #else + /* IPv6 is enabled - Continue filter checks. */ + #endif + } + else + { + /* The frame is an unsupported Ethernet II type */ + #if ipconfigIS_DISABLED( ipconfigPROCESS_CUSTOM_ETHERNET_FRAMES ) + /* Processing custom ethernet frames is disabled - release it. */ + break; + #else + /* Processing custom ethernet frames is enabled - Continue filter checks. */ + #endif } - /* Examine the destination MAC from the Ethernet header to see if it matches - * that of an end point managed by FreeRTOS+TCP. */ - pxEndPoint = FreeRTOS_MatchingEndpoint( NULL, pucEthernetBuffer ); + /* Third, filter based on destination mac address. */ + pxEndPoint = FreeRTOS_FindEndPointOnMAC( &( pxEthernetHeader->xDestinationAddress ), NULL ); if( pxEndPoint != NULL ) { - break; + /* A destination endpoint was found - Continue filter checks. */ } - - #if ipconfigIS_ENABLED( ipconfigUSE_DNS ) - #if ipconfigIS_ENABLED( ipconfigUSE_LLMNR ) - #if ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) - if( memcmp( xLLMNR_MacAddress.ucBytes, pxEthernetHeader->xDestinationAddress.ucBytes, sizeof( MACAddress_t ) ) == 0 ) - { - /* The packet is a request for LLMNR - process it. */ - break; - } - #endif - #if ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) - if( memcmp( xLLMNR_MacAddressIPv6.ucBytes, pxEthernetHeader->xDestinationAddress.ucBytes, sizeof( MACAddress_t ) ) == 0 ) - { - /* The packet is a request for LLMNR - process it. */ - break; - } - #endif + else if( memcmp( xBroadcastMACAddress.ucBytes, pxEthernetHeader->xDestinationAddress.ucBytes, sizeof( MACAddress_t ) ) == 0 ) + { + /* The packet was a broadcast - Continue filter checks. */ + } + else if( memcmp( xLLMNR_MacAddress.ucBytes, pxEthernetHeader->xDestinationAddress.ucBytes, sizeof( MACAddress_t ) ) == 0 ) + { + /* The packet is a request for LLMNR using IPv4 */ + #if ( ipconfigIS_DISABLED( ipconfigUSE_DNS ) || ipconfigIS_DISABLED( ipconfigUSE_LLMNR ) || ipconfigIS_DISABLED( ipconfigUSE_IPv4 ) ) + /* DNS, LLMNR, or IPv4 is disabled - release it. */ + break; + #else + /* DNS, LLMNR, and IPv4 are enabled - Continue filter checks. */ #endif - #if ipconfigIS_ENABLED( ipconfigUSE_MDNS ) - #if ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) - if( memcmp( xMDNS_MacAddress.ucBytes, pxEthernetHeader->xDestinationAddress.ucBytes, sizeof( MACAddress_t ) ) == 0 ) - { - /* The packet is a request for MDNS - process it. */ - break; - } - #endif - #if ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) - if( memcmp( xMDNS_MACAddressIPv6.ucBytes, pxEthernetHeader->xDestinationAddress.ucBytes, sizeof( MACAddress_t ) ) == 0 ) - { - /* The packet is a request for MDNS - process it. */ - break; - } - #endif + } + else if( memcmp( xLLMNR_MacAddressIPv6.ucBytes, pxEthernetHeader->xDestinationAddress.ucBytes, sizeof( MACAddress_t ) ) == 0 ) + { + /* The packet is a request for LLMNR using IPv6 */ + #if ( ipconfigIS_DISABLED( ipconfigUSE_DNS ) || ipconfigIS_DISABLED( ipconfigUSE_LLMNR ) || ipconfigIS_DISABLED( ipconfigUSE_IPv6 ) ) + /* DNS, LLMNR, or IPv6 is disabled - release it. */ + break; + #else + /* DNS, LLMNR, and IPv6 are enabled - Continue filter checks. */ #endif - #endif + } + else if( memcmp( xMDNS_MacAddress.ucBytes, pxEthernetHeader->xDestinationAddress.ucBytes, sizeof( MACAddress_t ) ) == 0 ) + { + /* The packet is a request for MDNS using IPv4 */ + #if ( ipconfigIS_DISABLED( ipconfigUSE_DNS ) || ipconfigIS_DISABLED( ipconfigUSE_MDNS ) || ipconfigIS_DISABLED( ipconfigUSE_IPv4 ) ) + /* DNS, MDNS, or IPv4 is disabled - release it. */ + break; + #else + /* DNS, MDNS, and IPv4 are enabled - Continue filter checks. */ + #endif + } + else if( memcmp( xMDNS_MACAddressIPv6.ucBytes, pxEthernetHeader->xDestinationAddress.ucBytes, sizeof( MACAddress_t ) ) == 0 ) + { + /* The packet is a request for MDNS using IPv6 */ + #if ( ipconfigIS_DISABLED( ipconfigUSE_DNS ) || ipconfigIS_DISABLED( ipconfigUSE_MDNS ) || ipconfigIS_DISABLED( ipconfigUSE_IPv6 ) ) + /* DNS, MDNS, or IPv6 is disabled - release it. */ + break; + #else + /* DNS, MDNS, and IPv6 are enabled - Continue filter checks. */ + #endif + } + else if( ( pxEthernetHeader->xDestinationAddress.ucBytes[ 0 ] == ipMULTICAST_MAC_ADDRESS_IPv6_0 ) && + ( pxEthernetHeader->xDestinationAddress.ucBytes[ 1 ] == ipMULTICAST_MAC_ADDRESS_IPv6_1 ) ) + { + /* The packet is an IPv6 Multicast */ + #if ipconfigIS_DISABLED( ipconfigUSE_IPv6 ) + /* IPv6 is disabled - release it. */ + break; + #else + /* IPv6 is enabled - Continue filter checks. */ + #endif + } - eReturn = eReleaseBuffer; + /* All checks have been passed, process the packet. */ + eReturn = eProcessBuffer; } while( ipFALSE_BOOL ); return eReturn; diff --git a/source/include/FreeRTOS_DNS.h b/source/include/FreeRTOS_DNS.h index 04daeb2329..90b4860cbc 100644 --- a/source/include/FreeRTOS_DNS.h +++ b/source/include/FreeRTOS_DNS.h @@ -41,38 +41,23 @@ #endif /* *INDENT-ON* */ -/* - * LLMNR is very similar to DNS, so is handled by the DNS routines. - */ -uint32_t ulDNSHandlePacket( const NetworkBufferDescriptor_t * pxNetworkBuffer ); +/* The LLMNR MAC address is 01:00:5e:00:00:fc */ +extern const MACAddress_t xLLMNR_MacAddress; -#if ( ipconfigUSE_LLMNR == 1 ) - /* The LLMNR MAC address is 01:00:5e:00:00:fc */ - extern const MACAddress_t xLLMNR_MacAddress; -#endif /* ipconfigUSE_LLMNR */ - -#if ( ipconfigUSE_LLMNR == 1 ) && ( ipconfigUSE_IPv6 != 0 ) +/* The LLMNR IPv6 MAC address is 33:33:00:01:00:03 */ +extern const MACAddress_t xLLMNR_MacAddressIPv6; /* The LLMNR IPv6 address is ff02::1:3 */ - extern const IPv6_Address_t ipLLMNR_IP_ADDR_IPv6; - -/* The LLMNR IPv6 MAC address is 33:33:00:01:00:03 */ - extern const MACAddress_t xLLMNR_MacAddressIPv6; -#endif /* ipconfigUSE_LLMNR */ +extern const IPv6_Address_t ipLLMNR_IP_ADDR_IPv6; -#if ( ipconfigUSE_MDNS == 1 ) - /* The MDNS MAC address is 01:00:5e:00:00:fc */ - extern const MACAddress_t xMDNS_MacAddress; -#endif /* ipconfigUSE_MDNS */ +/* The MDNS MAC address is 01:00:5e:00:00:fc */ +extern const MACAddress_t xMDNS_MacAddress; -#if ( ipconfigUSE_MDNS == 1 ) && ( ipconfigUSE_IPv6 != 0 ) +/* The MDNS IPv6 MAC address is 33:33:00:01:00:03 */ +extern const MACAddress_t xMDNS_MACAddressIPv6; /* The MDNS IPv6 address is ff02::1:3 */ - extern const IPv6_Address_t ipMDNS_IP_ADDR_IPv6; - -/* The MDNS IPv6 MAC address is 33:33:00:01:00:03 */ - extern const MACAddress_t xMDNS_MACAddressIPv6; -#endif /* ipconfigUSE_MDNS */ +extern const IPv6_Address_t ipMDNS_IP_ADDR_IPv6; /** @brief While doing integration tests, it is necessary to influence the choice * between DNS/IPv4 and DNS/IPv4. Depending on this, a DNS server will be @@ -90,6 +75,11 @@ typedef enum xIPPreference /** @brief This variable determines he choice of DNS server, either IPv4 or IPv6. */ extern IPPreference_t xDNS_IP_Preference; +/* + * LLMNR is very similar to DNS, so is handled by the DNS routines. + */ +uint32_t ulDNSHandlePacket( const NetworkBufferDescriptor_t * pxNetworkBuffer ); + #if ( ipconfigUSE_NBNS != 0 ) /* From 9718f558c1ef7913f58a26bc5b41bcb8ba4bf82f Mon Sep 17 00:00:00 2001 From: Holden Date: Thu, 15 Feb 2024 03:12:22 -0500 Subject: [PATCH 04/15] Remove ipCONSIDER_FRAME_FOR_PROCESSING macro --- source/FreeRTOS_IP.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/source/FreeRTOS_IP.c b/source/FreeRTOS_IP.c index 56681a9a5c..78604eff88 100644 --- a/source/FreeRTOS_IP.c +++ b/source/FreeRTOS_IP.c @@ -99,20 +99,6 @@ BaseType_t xProcessedTCPMessage; #endif -/** @brief If ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES is set to 1, then the Ethernet - * driver will filter incoming packets and only pass the stack those packets it - * considers need processing. In this case ipCONSIDER_FRAME_FOR_PROCESSING() can - * be #-defined away. If ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES is set to 0 - * then the Ethernet driver will pass all received packets to the stack, and the - * stack must do the filtering itself. In this case ipCONSIDER_FRAME_FOR_PROCESSING - * needs to call eConsiderFrameForProcessing. - */ -#if ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES == 0 - #define ipCONSIDER_FRAME_FOR_PROCESSING( pucEthernetBuffer ) eConsiderFrameForProcessing( ( pucEthernetBuffer ) ) -#else - #define ipCONSIDER_FRAME_FOR_PROCESSING( pucEthernetBuffer ) eProcessBuffer -#endif - static void prvCallDHCP_RA_Handler( NetworkEndPoint_t * pxEndPoint ); static void prvIPTask_Initialise( void ); @@ -1633,8 +1619,6 @@ static void prvProcessEthernetPacket( NetworkBufferDescriptor_t * const pxNetwor break; } - eReturned = ipCONSIDER_FRAME_FOR_PROCESSING( pxNetworkBuffer->pucEthernetBuffer ); - /* Map the buffer onto the Ethernet Header struct for easy access to the fields. */ /* MISRA Ref 11.3.1 [Misaligned access] */ @@ -1644,7 +1628,7 @@ static void prvProcessEthernetPacket( NetworkBufferDescriptor_t * const pxNetwor /* The condition "eReturned == eProcessBuffer" must be true. */ #if ( ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES == 0 ) - if( eReturned == eProcessBuffer ) + if( eConsiderFrameForProcessing( pxNetworkBuffer->pucEthernetBuffer ) == eProcessBuffer ) #endif { /* Interpret the received Ethernet packet. */ From 046ec05cf89c84f3ef20ef953781ca20a6760328 Mon Sep 17 00:00:00 2001 From: Holden Date: Fri, 16 Feb 2024 08:01:36 -0500 Subject: [PATCH 05/15] add ipv4 multicast frame check --- source/FreeRTOS_IP.c | 29 ++++++++++++++++++++++++----- source/include/FreeRTOS_IPv4.h | 5 +++++ 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/source/FreeRTOS_IP.c b/source/FreeRTOS_IP.c index 78604eff88..cbf4d21c88 100644 --- a/source/FreeRTOS_IP.c +++ b/source/FreeRTOS_IP.c @@ -1442,12 +1442,12 @@ eFrameProcessingResult_t eConsiderFrameForProcessing( const uint8_t * const pucE { const EthernetHeader_t * pxEthernetHeader = NULL; const NetworkEndPoint_t * pxEndPoint = NULL; + uint16_t usFrameType; /* First, check the packet buffer is non-null. */ if( pucEthernetBuffer == NULL ) { /* The packet buffer was null - release it. */ - eReturn = eReleaseBuffer; break; } @@ -1456,9 +1456,10 @@ eFrameProcessingResult_t eConsiderFrameForProcessing( const uint8_t * const pucE /* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */ /* coverity[misra_c_2012_rule_11_3_violation] */ pxEthernetHeader = ( ( const EthernetHeader_t * ) pucEthernetBuffer ); + usFrameType = FreeRTOS_ntohs( pxEthernetHeader->usFrameType ); /* Second, filter based on ethernet frame type. */ - if( FreeRTOS_ntohs( pxEthernetHeader->usFrameType ) <= 0x600U ) + if( usFrameType <= 0x600U ) { /* The packet was not an Ethernet II frame */ #if ipconfigIS_ENABLED( ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES ) @@ -1468,7 +1469,7 @@ eFrameProcessingResult_t eConsiderFrameForProcessing( const uint8_t * const pucE /* filtering is disabled - continue filter checks. */ #endif } - else if( pxEthernetHeader->usFrameType == ipARP_FRAME_TYPE ) + else if( usFrameType == ipARP_FRAME_TYPE ) { /* The frame is an ARP type */ #if ipconfigIS_DISABLED( ipconfigUSE_IPv4 ) @@ -1478,7 +1479,7 @@ eFrameProcessingResult_t eConsiderFrameForProcessing( const uint8_t * const pucE /* IPv4 is enabled - Continue filter checks. */ #endif } - else if( pxEthernetHeader->usFrameType == ipIPv4_FRAME_TYPE ) + else if( usFrameType == ipIPv4_FRAME_TYPE ) { /* The frame is an IPv4 type */ #if ipconfigIS_DISABLED( ipconfigUSE_IPv4 ) @@ -1488,7 +1489,7 @@ eFrameProcessingResult_t eConsiderFrameForProcessing( const uint8_t * const pucE /* IPv4 is enabled - Continue filter checks. */ #endif } - else if( pxEthernetHeader->usFrameType == ipIPv6_FRAME_TYPE ) + else if( usFrameType == ipIPv6_FRAME_TYPE ) { /* The frame is an IPv6 type */ #if ipconfigIS_DISABLED( ipconfigUSE_IPv6 ) @@ -1559,6 +1560,19 @@ eFrameProcessingResult_t eConsiderFrameForProcessing( const uint8_t * const pucE /* DNS, MDNS, and IPv6 are enabled - Continue filter checks. */ #endif } + else if( ( pxEthernetHeader->xDestinationAddress.ucBytes[ 0 ] == ipMULTICAST_MAC_ADDRESS_IPv4_0 ) && + ( pxEthernetHeader->xDestinationAddress.ucBytes[ 1 ] == ipMULTICAST_MAC_ADDRESS_IPv4_1 ) && + ( pxEthernetHeader->xDestinationAddress.ucBytes[ 2 ] == ipMULTICAST_MAC_ADDRESS_IPv4_2 ) && + ( pxEthernetHeader->xDestinationAddress.ucBytes[ 3 ] <= 0x7fU ) ) + { + /* The packet is an IPv4 Multicast */ + #if ipconfigIS_DISABLED( ipconfigUSE_IPv4 ) + /* IPv4 is disabled - release it. */ + break; + #else + /* IPv4 is enabled - Continue filter checks. */ + #endif + } else if( ( pxEthernetHeader->xDestinationAddress.ucBytes[ 0 ] == ipMULTICAST_MAC_ADDRESS_IPv6_0 ) && ( pxEthernetHeader->xDestinationAddress.ucBytes[ 1 ] == ipMULTICAST_MAC_ADDRESS_IPv6_1 ) ) { @@ -1570,6 +1584,11 @@ eFrameProcessingResult_t eConsiderFrameForProcessing( const uint8_t * const pucE /* IPv6 is enabled - Continue filter checks. */ #endif } + else + { + /* The packet was not a broadcast, or for this node - release it */ + break; + } /* All checks have been passed, process the packet. */ eReturn = eProcessBuffer; diff --git a/source/include/FreeRTOS_IPv4.h b/source/include/FreeRTOS_IPv4.h index 233620d37e..449c8a8b50 100644 --- a/source/include/FreeRTOS_IPv4.h +++ b/source/include/FreeRTOS_IPv4.h @@ -58,6 +58,11 @@ struct xIP_PACKET; #define ipIPV4_VERSION_HEADER_LENGTH_MIN 0x45U /**< Minimum IPv4 header length. */ #define ipIPV4_VERSION_HEADER_LENGTH_MAX 0x4FU /**< Maximum IPv4 header length. */ +/* IPv4 multicast MAC address starts with 01-00-5E. */ +#define ipMULTICAST_MAC_ADDRESS_IPv4_0 0x01U +#define ipMULTICAST_MAC_ADDRESS_IPv4_1 0x00U +#define ipMULTICAST_MAC_ADDRESS_IPv4_2 0x5EU + /* * These functions come from the IPv4-only library. * TODO : They should get an extra parameter, the end-point From c1db70f2af17c9b44b83a3a4b6b553669a8e39bc Mon Sep 17 00:00:00 2001 From: Holden Date: Fri, 16 Feb 2024 12:24:57 -0500 Subject: [PATCH 06/15] make tests finish compiling --- test/unit-test/FreeRTOS_IP/FreeRTOS_IP_stubs.c | 6 ++++++ .../FreeRTOS_IP_DiffConfig/FreeRTOS_IP_DiffConfig_stubs.c | 8 +++++++- .../FreeRTOS_IP_DiffConfig1_stubs.c | 8 +++++++- .../FreeRTOS_IP_DiffConfig2_stubs.c | 6 ++++++ .../FreeRTOS_IP_DiffConfig3_stubs.c | 6 ++++++ 5 files changed, 32 insertions(+), 2 deletions(-) diff --git a/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_stubs.c b/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_stubs.c index f25be869e9..3fcbc1dad8 100644 --- a/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_stubs.c +++ b/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_stubs.c @@ -53,6 +53,12 @@ struct xNetworkEndPoint * pxNetworkEndPoints = NULL; const MACAddress_t xLLMNR_MacAddress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfc } }; +const MACAddress_t xLLMNR_MacAddressIPv6 = { { 0x33, 0x33, 0x00, 0x01, 0x00, 0x03 } }; + +const MACAddress_t xMDNS_MacAddress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfb } }; + +const MACAddress_t xMDNS_MACAddressIPv6 = { { 0x33, 0x33, 0x00, 0x00, 0x00, 0xFB } }; + void vPortEnterCritical( void ) { } diff --git a/test/unit-test/FreeRTOS_IP_DiffConfig/FreeRTOS_IP_DiffConfig_stubs.c b/test/unit-test/FreeRTOS_IP_DiffConfig/FreeRTOS_IP_DiffConfig_stubs.c index 3b13966be3..a69bfcac81 100644 --- a/test/unit-test/FreeRTOS_IP_DiffConfig/FreeRTOS_IP_DiffConfig_stubs.c +++ b/test/unit-test/FreeRTOS_IP_DiffConfig/FreeRTOS_IP_DiffConfig_stubs.c @@ -50,9 +50,15 @@ struct xNetworkInterface * pxNetworkInterfaces = NULL; /** @brief A list of all network end-points. Each element has a next pointer. */ struct xNetworkEndPoint * pxNetworkEndPoints = NULL; +const MACAddress_t xDefault_MacAddress = { { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 } }; + const MACAddress_t xLLMNR_MacAddress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfc } }; -const MACAddress_t xDefault_MacAddress = { { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 } }; +const MACAddress_t xLLMNR_MacAddressIPv6 = { { 0x33, 0x33, 0x00, 0x01, 0x00, 0x03 } }; + +const MACAddress_t xMDNS_MacAddress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfb } }; + +const MACAddress_t xMDNS_MACAddressIPv6 = { { 0x33, 0x33, 0x00, 0x00, 0x00, 0xFB } }; void vPortEnterCritical( void ) { diff --git a/test/unit-test/FreeRTOS_IP_DiffConfig1/FreeRTOS_IP_DiffConfig1_stubs.c b/test/unit-test/FreeRTOS_IP_DiffConfig1/FreeRTOS_IP_DiffConfig1_stubs.c index 5968e321ca..2ce1c386d1 100644 --- a/test/unit-test/FreeRTOS_IP_DiffConfig1/FreeRTOS_IP_DiffConfig1_stubs.c +++ b/test/unit-test/FreeRTOS_IP_DiffConfig1/FreeRTOS_IP_DiffConfig1_stubs.c @@ -51,9 +51,15 @@ struct xNetworkInterface * pxNetworkInterfaces = NULL; /** @brief A list of all network end-points. Each element has a next pointer. */ struct xNetworkEndPoint * pxNetworkEndPoints = NULL; +const MACAddress_t xDefault_MacAddress = { { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 } }; + const MACAddress_t xLLMNR_MacAddress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfc } }; -const MACAddress_t xDefault_MacAddress = { { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 } }; +const MACAddress_t xLLMNR_MacAddressIPv6 = { { 0x33, 0x33, 0x00, 0x01, 0x00, 0x03 } }; + +const MACAddress_t xMDNS_MacAddress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfb } }; + +const MACAddress_t xMDNS_MACAddressIPv6 = { { 0x33, 0x33, 0x00, 0x00, 0x00, 0xFB } }; void vPortEnterCritical( void ) { diff --git a/test/unit-test/FreeRTOS_IP_DiffConfig2/FreeRTOS_IP_DiffConfig2_stubs.c b/test/unit-test/FreeRTOS_IP_DiffConfig2/FreeRTOS_IP_DiffConfig2_stubs.c index f35bef3063..4a9c89c093 100644 --- a/test/unit-test/FreeRTOS_IP_DiffConfig2/FreeRTOS_IP_DiffConfig2_stubs.c +++ b/test/unit-test/FreeRTOS_IP_DiffConfig2/FreeRTOS_IP_DiffConfig2_stubs.c @@ -51,6 +51,12 @@ struct xNetworkEndPoint * pxNetworkEndPoints = NULL; const MACAddress_t xLLMNR_MacAddress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfc } }; +const MACAddress_t xLLMNR_MacAddressIPv6 = { { 0x33, 0x33, 0x00, 0x01, 0x00, 0x03 } }; + +const MACAddress_t xMDNS_MacAddress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfb } }; + +const MACAddress_t xMDNS_MACAddressIPv6 = { { 0x33, 0x33, 0x00, 0x00, 0x00, 0xFB } }; + void vPortEnterCritical( void ) { } diff --git a/test/unit-test/FreeRTOS_IP_DiffConfig3/FreeRTOS_IP_DiffConfig3_stubs.c b/test/unit-test/FreeRTOS_IP_DiffConfig3/FreeRTOS_IP_DiffConfig3_stubs.c index ddaffbd0a7..b420546833 100644 --- a/test/unit-test/FreeRTOS_IP_DiffConfig3/FreeRTOS_IP_DiffConfig3_stubs.c +++ b/test/unit-test/FreeRTOS_IP_DiffConfig3/FreeRTOS_IP_DiffConfig3_stubs.c @@ -52,6 +52,12 @@ struct xNetworkEndPoint * pxNetworkEndPoints = NULL; const MACAddress_t xLLMNR_MacAddress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfc } }; +const MACAddress_t xLLMNR_MacAddressIPv6 = { { 0x33, 0x33, 0x00, 0x01, 0x00, 0x03 } }; + +const MACAddress_t xMDNS_MacAddress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfb } }; + +const MACAddress_t xMDNS_MACAddressIPv6 = { { 0x33, 0x33, 0x00, 0x00, 0x00, 0xFB } }; + void vPortEnterCritical( void ) { } From 3136cbd5eb2abe1c47cfdaec5bda02883156bb42 Mon Sep 17 00:00:00 2001 From: Holden Date: Fri, 16 Feb 2024 12:50:05 -0500 Subject: [PATCH 07/15] fix tests --- source/FreeRTOS_IP.c | 4 ++-- .../unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c | 20 +++++++------------ 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/source/FreeRTOS_IP.c b/source/FreeRTOS_IP.c index cbf4d21c88..f2753a93a8 100644 --- a/source/FreeRTOS_IP.c +++ b/source/FreeRTOS_IP.c @@ -1456,10 +1456,10 @@ eFrameProcessingResult_t eConsiderFrameForProcessing( const uint8_t * const pucE /* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */ /* coverity[misra_c_2012_rule_11_3_violation] */ pxEthernetHeader = ( ( const EthernetHeader_t * ) pucEthernetBuffer ); - usFrameType = FreeRTOS_ntohs( pxEthernetHeader->usFrameType ); + usFrameType = pxEthernetHeader->usFrameType; /* Second, filter based on ethernet frame type. */ - if( usFrameType <= 0x600U ) + if( FreeRTOS_ntohs( usFrameType ) <= 0x0600U ) { /* The packet was not an Ethernet II frame */ #if ipconfigIS_ENABLED( ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES ) diff --git a/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c b/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c index a970462c4c..3e1f3d46e6 100644 --- a/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c +++ b/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c @@ -1546,7 +1546,7 @@ void test_eConsiderFrameForProcessing_LocalMACMatch( void ) /* Align endpoint's & packet's MAC address. */ memset( pxEndPoint->xMACAddress.ucBytes, 0xAA, sizeof( MACAddress_t ) ); memcpy( pxEthernetHeader->xDestinationAddress.ucBytes, pxEndPoint->xMACAddress.ucBytes, sizeof( MACAddress_t ) ); - pxEthernetHeader->usFrameType = FreeRTOS_htons( 0x0800 ); + pxEthernetHeader->usFrameType = ipIPv4_FRAME_TYPE; eResult = eConsiderFrameForProcessing( ucEthernetBuffer ); @@ -1565,9 +1565,6 @@ void test_eConsiderFrameForProcessing_LocalMACMatchInvalidFrameType( void ) uint8_t ucEthernetBuffer[ ipconfigTCP_MSS ]; EthernetHeader_t * pxEthernetHeader; - /* eConsiderFrameForProcessing */ - FreeRTOS_FindEndPointOnMAC_ExpectAnyArgsAndReturn( pxEndPoint ); - /* Map the buffer onto Ethernet Header struct for easy access to fields. */ pxEthernetHeader = ( EthernetHeader_t * ) ucEthernetBuffer; @@ -1576,7 +1573,7 @@ void test_eConsiderFrameForProcessing_LocalMACMatchInvalidFrameType( void ) /* Align endpoint's & packet's MAC address. */ memset( pxEndPoint->xMACAddress.ucBytes, 0xAA, sizeof( MACAddress_t ) ); memcpy( pxEthernetHeader->xDestinationAddress.ucBytes, pxEndPoint->xMACAddress.ucBytes, sizeof( MACAddress_t ) ); - pxEthernetHeader->usFrameType = FreeRTOS_htons( 0 ); + pxEthernetHeader->usFrameType = 0; eResult = eConsiderFrameForProcessing( ucEthernetBuffer ); @@ -1595,9 +1592,6 @@ void test_eConsiderFrameForProcessing_LocalMACMatchInvalidFrameType1( void ) uint8_t ucEthernetBuffer[ ipconfigTCP_MSS ]; EthernetHeader_t * pxEthernetHeader; - /* eConsiderFrameForProcessing */ - FreeRTOS_FindEndPointOnMAC_ExpectAnyArgsAndReturn( pxEndPoint ); - /* Map the buffer onto Ethernet Header struct for easy access to fields. */ pxEthernetHeader = ( EthernetHeader_t * ) ucEthernetBuffer; @@ -1633,7 +1627,7 @@ void test_eConsiderFrameForProcessing_BroadCastMACMatch( void ) memset( ucEthernetBuffer, 0x00, ipconfigTCP_MSS ); memcpy( pxEthernetHeader->xDestinationAddress.ucBytes, xBroadcastMACAddress.ucBytes, sizeof( MACAddress_t ) ); - pxEthernetHeader->usFrameType = 0xFFFF; + pxEthernetHeader->usFrameType = ipIPv4_FRAME_TYPE; eResult = eConsiderFrameForProcessing( ucEthernetBuffer ); @@ -1660,7 +1654,7 @@ void test_eConsiderFrameForProcessing_LLMNR_MACMatch( void ) memset( ucEthernetBuffer, 0x00, ipconfigTCP_MSS ); memcpy( pxEthernetHeader->xDestinationAddress.ucBytes, xLLMNR_MacAddress.ucBytes, sizeof( MACAddress_t ) ); - pxEthernetHeader->usFrameType = 0xFFFF; + pxEthernetHeader->usFrameType = ipIPv4_FRAME_TYPE; eResult = eConsiderFrameForProcessing( ucEthernetBuffer ); @@ -1688,7 +1682,7 @@ void test_eConsiderFrameForProcessing_NotMatch( void ) memset( ucEthernetBuffer, 0x00, ipconfigTCP_MSS ); memcpy( pxEthernetHeader->xDestinationAddress.ucBytes, &xMACAddress, sizeof( MACAddress_t ) ); - pxEthernetHeader->usFrameType = 0xFFFF; + pxEthernetHeader->usFrameType = ipIPv4_FRAME_TYPE; eResult = eConsiderFrameForProcessing( ucEthernetBuffer ); @@ -1716,7 +1710,7 @@ void test_eConsiderFrameForProcessing_IPv6BroadCastMACMatch( void ) pxEthernetHeader->xDestinationAddress.ucBytes[ 0 ] = ipMULTICAST_MAC_ADDRESS_IPv6_0; pxEthernetHeader->xDestinationAddress.ucBytes[ 1 ] = ipMULTICAST_MAC_ADDRESS_IPv6_1; - pxEthernetHeader->usFrameType = 0xFFFF; + pxEthernetHeader->usFrameType = ipIPv6_FRAME_TYPE; eResult = eConsiderFrameForProcessing( ucEthernetBuffer ); @@ -1744,7 +1738,7 @@ void test_eConsiderFrameForProcessing_IPv6BroadCastMACPartialMatch( void ) pxEthernetHeader->xDestinationAddress.ucBytes[ 0 ] = ipMULTICAST_MAC_ADDRESS_IPv6_0; pxEthernetHeader->xDestinationAddress.ucBytes[ 1 ] = 0x00; - pxEthernetHeader->usFrameType = 0xFFFF; + pxEthernetHeader->usFrameType = ipIPv6_FRAME_TYPE; eResult = eConsiderFrameForProcessing( ucEthernetBuffer ); From 6cac71ebbb8f14d21c70c3b4ad778d3f48d7f022 Mon Sep 17 00:00:00 2001 From: Holden Date: Fri, 16 Feb 2024 12:52:43 -0500 Subject: [PATCH 08/15] use multicast macros --- source/FreeRTOS_IPv4_Utils.c | 6 +++--- source/FreeRTOS_IPv6_Utils.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/source/FreeRTOS_IPv4_Utils.c b/source/FreeRTOS_IPv4_Utils.c index b79bdc8de8..f7c1d3f847 100644 --- a/source/FreeRTOS_IPv4_Utils.c +++ b/source/FreeRTOS_IPv4_Utils.c @@ -59,9 +59,9 @@ void vSetMultiCastIPv4MacAddress( uint32_t ulIPAddress, { uint32_t ulIP = FreeRTOS_ntohl( ulIPAddress ); - pxMACAddress->ucBytes[ 0 ] = ( uint8_t ) 0x01U; - pxMACAddress->ucBytes[ 1 ] = ( uint8_t ) 0x00U; - pxMACAddress->ucBytes[ 2 ] = ( uint8_t ) 0x5EU; + pxMACAddress->ucBytes[ 0 ] = ( uint8_t ) ipMULTICAST_MAC_ADDRESS_IPv4_0; + pxMACAddress->ucBytes[ 1 ] = ( uint8_t ) ipMULTICAST_MAC_ADDRESS_IPv4_1; + pxMACAddress->ucBytes[ 2 ] = ( uint8_t ) ipMULTICAST_MAC_ADDRESS_IPv4_2; pxMACAddress->ucBytes[ 3 ] = ( uint8_t ) ( ( ulIP >> 16 ) & 0x7fU ); /* Use 7 bits. */ pxMACAddress->ucBytes[ 4 ] = ( uint8_t ) ( ( ulIP >> 8 ) & 0xffU ); /* Use 8 bits. */ pxMACAddress->ucBytes[ 5 ] = ( uint8_t ) ( ( ulIP ) & 0xffU ); /* Use 8 bits. */ diff --git a/source/FreeRTOS_IPv6_Utils.c b/source/FreeRTOS_IPv6_Utils.c index 0a87fe82e8..8e492aa08c 100644 --- a/source/FreeRTOS_IPv6_Utils.c +++ b/source/FreeRTOS_IPv6_Utils.c @@ -55,8 +55,8 @@ void vSetMultiCastIPv6MacAddress( const IPv6_Address_t * pxAddress, MACAddress_t * pxMACAddress ) { - pxMACAddress->ucBytes[ 0 ] = 0x33U; - pxMACAddress->ucBytes[ 1 ] = 0x33U; + pxMACAddress->ucBytes[ 0 ] = ipMULTICAST_MAC_ADDRESS_IPv6_0; + pxMACAddress->ucBytes[ 1 ] = ipMULTICAST_MAC_ADDRESS_IPv6_1; pxMACAddress->ucBytes[ 2 ] = pxAddress->ucBytes[ 12 ]; pxMACAddress->ucBytes[ 3 ] = pxAddress->ucBytes[ 13 ]; pxMACAddress->ucBytes[ 4 ] = pxAddress->ucBytes[ 14 ]; From f3d960f10fd1495eb786910997246d193f6caf2c Mon Sep 17 00:00:00 2001 From: Holden Date: Fri, 16 Feb 2024 13:24:05 -0500 Subject: [PATCH 09/15] improve test coverage --- test/unit-test/ConfigFiles/FreeRTOSIPConfig.h | 1 + .../unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c | 116 +++++++++++++++++- 2 files changed, 114 insertions(+), 3 deletions(-) diff --git a/test/unit-test/ConfigFiles/FreeRTOSIPConfig.h b/test/unit-test/ConfigFiles/FreeRTOSIPConfig.h index 81d8202893..f3abe731e4 100644 --- a/test/unit-test/ConfigFiles/FreeRTOSIPConfig.h +++ b/test/unit-test/ConfigFiles/FreeRTOSIPConfig.h @@ -307,6 +307,7 @@ #define ipconfigUSE_NBNS ( 1 ) #define ipconfigUSE_LLMNR ( 1 ) +#define ipconfigUSE_MDNS ( 1 ) #define ipconfigDNS_USE_CALLBACKS 1 #define ipconfigUSE_ARP_REMOVE_ENTRY 1 diff --git a/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c b/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c index 3e1f3d46e6..23e0881c51 100644 --- a/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c +++ b/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c @@ -1661,6 +1661,87 @@ void test_eConsiderFrameForProcessing_LLMNR_MACMatch( void ) TEST_ASSERT_EQUAL( eProcessBuffer, eResult ); } +/** + * @brief test_eConsiderFrameForProcessing_LLMNR_IPv6_MACMatch + * eConsiderFrameForProcessing must return eProcessBuffer when the MAC address in packet + * matches LLMNR MAC address and the frame type is valid. + */ +void test_eConsiderFrameForProcessing_LLMNR_IPv6_MACMatch( void ) +{ + eFrameProcessingResult_t eResult; + uint8_t ucEthernetBuffer[ ipconfigTCP_MSS ]; + EthernetHeader_t * pxEthernetHeader; + + /* eConsiderFrameForProcessing */ + FreeRTOS_FindEndPointOnMAC_ExpectAnyArgsAndReturn( NULL ); + + /* Map the buffer onto Ethernet Header struct for easy access to fields. */ + pxEthernetHeader = ( EthernetHeader_t * ) ucEthernetBuffer; + + memset( ucEthernetBuffer, 0x00, ipconfigTCP_MSS ); + + memcpy( pxEthernetHeader->xDestinationAddress.ucBytes, xLLMNR_MacAddressIPv6.ucBytes, sizeof( MACAddress_t ) ); + pxEthernetHeader->usFrameType = ipIPv6_FRAME_TYPE; + + eResult = eConsiderFrameForProcessing( ucEthernetBuffer ); + + TEST_ASSERT_EQUAL( eProcessBuffer, eResult ); +} + +/** + * @brief test_eConsiderFrameForProcessing_MDNS_MACMatch + * eConsiderFrameForProcessing must return eProcessBuffer when the MAC address in packet + * matches MDNS MAC address and the frame type is valid. + */ +void test_eConsiderFrameForProcessing_MDNS_MACMatch( void ) +{ + eFrameProcessingResult_t eResult; + uint8_t ucEthernetBuffer[ ipconfigTCP_MSS ]; + EthernetHeader_t * pxEthernetHeader; + + /* eConsiderFrameForProcessing */ + FreeRTOS_FindEndPointOnMAC_ExpectAnyArgsAndReturn( NULL ); + + /* Map the buffer onto Ethernet Header struct for easy access to fields. */ + pxEthernetHeader = ( EthernetHeader_t * ) ucEthernetBuffer; + + memset( ucEthernetBuffer, 0x00, ipconfigTCP_MSS ); + + memcpy( pxEthernetHeader->xDestinationAddress.ucBytes, xMDNS_MacAddress.ucBytes, sizeof( MACAddress_t ) ); + pxEthernetHeader->usFrameType = ipIPv4_FRAME_TYPE; + + eResult = eConsiderFrameForProcessing( ucEthernetBuffer ); + + TEST_ASSERT_EQUAL( eProcessBuffer, eResult ); +} + +/** + * @brief test_eConsiderFrameForProcessing_MDNS_IPv6_MACMatch + * eConsiderFrameForProcessing must return eProcessBuffer when the MAC address in packet + * matches LLMNR MAC address and the frame type is valid. + */ +void test_eConsiderFrameForProcessing_MDNS_IPv6_MACMatch( void ) +{ + eFrameProcessingResult_t eResult; + uint8_t ucEthernetBuffer[ ipconfigTCP_MSS ]; + EthernetHeader_t * pxEthernetHeader; + + /* eConsiderFrameForProcessing */ + FreeRTOS_FindEndPointOnMAC_ExpectAnyArgsAndReturn( NULL ); + + /* Map the buffer onto Ethernet Header struct for easy access to fields. */ + pxEthernetHeader = ( EthernetHeader_t * ) ucEthernetBuffer; + + memset( ucEthernetBuffer, 0x00, ipconfigTCP_MSS ); + + memcpy( pxEthernetHeader->xDestinationAddress.ucBytes, xMDNS_MACAddressIPv6.ucBytes, sizeof( MACAddress_t ) ); + pxEthernetHeader->usFrameType = ipIPv6_FRAME_TYPE; + + eResult = eConsiderFrameForProcessing( ucEthernetBuffer ); + + TEST_ASSERT_EQUAL( eProcessBuffer, eResult ); +} + /** * @brief test_eConsiderFrameForProcessing_NotMatch * eConsiderFrameForProcessing must return eReleaseBuffer when the MAC address @@ -1690,11 +1771,40 @@ void test_eConsiderFrameForProcessing_NotMatch( void ) } /** - * @brief test_eConsiderFrameForProcessing_IPv6BroadCastMACMatch + * @brief test_eConsiderFrameForProcessing_Multicast_MACMatch + * eConsiderFrameForProcessing must return eProcessBuffer when the MAC address in packet + * matches IPv6 Multicast MAC address and the frame type is valid. + */ +void test_eConsiderFrameForProcessing_Multicast_MACMatch( void ) +{ + eFrameProcessingResult_t eResult; + uint8_t ucEthernetBuffer[ ipconfigTCP_MSS ]; + EthernetHeader_t * pxEthernetHeader; + + /* eConsiderFrameForProcessing */ + FreeRTOS_FindEndPointOnMAC_ExpectAnyArgsAndReturn( NULL ); + + /* Map the buffer onto Ethernet Header struct for easy access to fields. */ + pxEthernetHeader = ( EthernetHeader_t * ) ucEthernetBuffer; + + memset( ucEthernetBuffer, 0x00, ipconfigTCP_MSS ); + + pxEthernetHeader->xDestinationAddress.ucBytes[ 0 ] = ipMULTICAST_MAC_ADDRESS_IPv4_0; + pxEthernetHeader->xDestinationAddress.ucBytes[ 1 ] = ipMULTICAST_MAC_ADDRESS_IPv4_1; + pxEthernetHeader->xDestinationAddress.ucBytes[ 2 ] = ipMULTICAST_MAC_ADDRESS_IPv4_2; + pxEthernetHeader->usFrameType = ipIPv4_FRAME_TYPE; + + eResult = eConsiderFrameForProcessing( ucEthernetBuffer ); + + TEST_ASSERT_EQUAL( eProcessBuffer, eResult ); +} + +/** + * @brief test_eConsiderFrameForProcessing_IPv6_Multicast_MACMatch * eConsiderFrameForProcessing must return eProcessBuffer when the MAC address in packet - * matches IPv6 broadcast MAC address and the frame type is valid. + * matches IPv6 Multicast MAC address and the frame type is valid. */ -void test_eConsiderFrameForProcessing_IPv6BroadCastMACMatch( void ) +void test_eConsiderFrameForProcessing_IPv6_Multicast_MACMatch( void ) { eFrameProcessingResult_t eResult; uint8_t ucEthernetBuffer[ ipconfigTCP_MSS ]; From b5a21d1206af6c9ea73a9cf5287f29079606ebfe Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Wed, 13 Mar 2024 04:20:17 +0000 Subject: [PATCH 10/15] Uncrustify: triggered by comment. --- source/FreeRTOS_IP.c | 1 + source/include/FreeRTOS_IPv4.h | 6 +++--- test/unit-test/ConfigFiles/FreeRTOSIPConfig.h | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/source/FreeRTOS_IP.c b/source/FreeRTOS_IP.c index f2753a93a8..ae07e6d088 100644 --- a/source/FreeRTOS_IP.c +++ b/source/FreeRTOS_IP.c @@ -1512,6 +1512,7 @@ eFrameProcessingResult_t eConsiderFrameForProcessing( const uint8_t * const pucE /* Third, filter based on destination mac address. */ pxEndPoint = FreeRTOS_FindEndPointOnMAC( &( pxEthernetHeader->xDestinationAddress ), NULL ); + if( pxEndPoint != NULL ) { /* A destination endpoint was found - Continue filter checks. */ diff --git a/source/include/FreeRTOS_IPv4.h b/source/include/FreeRTOS_IPv4.h index 449c8a8b50..33c155a170 100644 --- a/source/include/FreeRTOS_IPv4.h +++ b/source/include/FreeRTOS_IPv4.h @@ -59,9 +59,9 @@ struct xIP_PACKET; #define ipIPV4_VERSION_HEADER_LENGTH_MAX 0x4FU /**< Maximum IPv4 header length. */ /* IPv4 multicast MAC address starts with 01-00-5E. */ -#define ipMULTICAST_MAC_ADDRESS_IPv4_0 0x01U -#define ipMULTICAST_MAC_ADDRESS_IPv4_1 0x00U -#define ipMULTICAST_MAC_ADDRESS_IPv4_2 0x5EU +#define ipMULTICAST_MAC_ADDRESS_IPv4_0 0x01U +#define ipMULTICAST_MAC_ADDRESS_IPv4_1 0x00U +#define ipMULTICAST_MAC_ADDRESS_IPv4_2 0x5EU /* * These functions come from the IPv4-only library. diff --git a/test/unit-test/ConfigFiles/FreeRTOSIPConfig.h b/test/unit-test/ConfigFiles/FreeRTOSIPConfig.h index f3abe731e4..2e8a2702c5 100644 --- a/test/unit-test/ConfigFiles/FreeRTOSIPConfig.h +++ b/test/unit-test/ConfigFiles/FreeRTOSIPConfig.h @@ -307,7 +307,7 @@ #define ipconfigUSE_NBNS ( 1 ) #define ipconfigUSE_LLMNR ( 1 ) -#define ipconfigUSE_MDNS ( 1 ) +#define ipconfigUSE_MDNS ( 1 ) #define ipconfigDNS_USE_CALLBACKS 1 #define ipconfigUSE_ARP_REMOVE_ENTRY 1 From fc52baa873a65c245ca52dea653e8367f766782e Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Mon, 29 Jul 2024 09:03:50 +0000 Subject: [PATCH 11/15] Fix unit test to have full coverage --- .../FreeRTOS_DNS_Callback_utest.c | 76 ++++++++++ .../unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c | 137 ++++++++++++++++++ .../FreeRTOS_IP_DiffConfig1_utest.c | 23 +++ .../FreeRTOSIPConfig.h | 3 +- .../FreeRTOS_IP_DiffConfig2_utest.c | 112 ++++++++++++++ 5 files changed, 350 insertions(+), 1 deletion(-) 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 a23ee1ba6d..d6f6467d51 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 @@ -202,6 +202,82 @@ void test_xDNSDoCallback_success_equal_identifier_set_timer( void ) TEST_ASSERT_EQUAL( 1, callback_called ); } +/** + * @brief Happy Path! + */ +void test_xDNSDoCallback_success_equal_port_number_equal_name( void ) +{ + BaseType_t ret; + ParseSet_t pxSet; + struct freertos_addrinfo pxAddress; + DNSMessage_t xDNSMessageHeader; + char pc_name[] = "test"; + uint8_t dnsCallbackMemory[ sizeof( DNSCallback_t ) + ipconfigDNS_CACHE_NAME_LENGTH ]; + DNSCallback_t *pxDnsCallback = ( DNSCallback_t * ) &dnsCallbackMemory; + + pxSet.pxDNSMessageHeader = &xDNSMessageHeader; + pxSet.usPortNumber = FreeRTOS_htons( ipMDNS_PORT ); + strcpy( pxSet.pcName, pc_name ); + pxDnsCallback->pCallbackFunction = dns_callback; + strcpy( pxDnsCallback->pcName, pc_name ); + + /* Expectations */ + listGET_END_MARKER_ExpectAnyArgsAndReturn( ( ListItem_t * ) 4 ); + vTaskSuspendAll_Expect(); + listGET_NEXT_ExpectAnyArgsAndReturn( ( ListItem_t * ) 8 ); + + listGET_LIST_ITEM_OWNER_ExpectAnyArgsAndReturn( pxDnsCallback ); + uxListRemove_ExpectAnyArgsAndReturn( pdTRUE ); + vPortFree_ExpectAnyArgs(); + listLIST_IS_EMPTY_ExpectAnyArgsAndReturn( pdTRUE ); + + vIPSetDNSTimerEnableState_ExpectAnyArgs(); + + xTaskResumeAll_ExpectAndReturn( pdFALSE ); + /* API Call */ + ret = xDNSDoCallback( &pxSet, &pxAddress ); + + /* Validations */ + TEST_ASSERT_EQUAL( pdTRUE, ret ); + TEST_ASSERT_EQUAL( 1, callback_called ); +} + +/** + * @brief A failure path occurs when the port number is for MDNS but + * the name does not match. + */ +void test_xDNSDoCallback_fail_equal_port_number_not_equal_name( void ) +{ + BaseType_t ret; + ParseSet_t pxSet; + struct freertos_addrinfo pxAddress; + DNSMessage_t xDNSMessageHeader; + + pxSet.pxDNSMessageHeader = &xDNSMessageHeader; + pxSet.pxDNSMessageHeader->usIdentifier = 123; + pxSet.usPortNumber = FreeRTOS_htons( ipMDNS_PORT ); + char pc_name[] = "test"; + strcpy( pxSet.pcName, pc_name ); + dnsCallback->pCallbackFunction = dns_callback; + dnsCallback->pcName[0] = '\0'; + + /* Expectations */ + listGET_END_MARKER_ExpectAnyArgsAndReturn( ( ListItem_t * ) 4 ); + vTaskSuspendAll_Expect(); + listGET_NEXT_ExpectAnyArgsAndReturn( ( ListItem_t * ) 8 ); + + listGET_LIST_ITEM_OWNER_ExpectAnyArgsAndReturn( dnsCallback ); + listGET_NEXT_ExpectAnyArgsAndReturn( ( ListItem_t * ) 4 ); + + xTaskResumeAll_ExpectAndReturn( pdFALSE ); + /* API Call */ + ret = xDNSDoCallback( &pxSet, &pxAddress ); + + /* Validations */ + TEST_ASSERT_EQUAL( pdFALSE, ret ); + TEST_ASSERT_EQUAL( 0, callback_called ); +} + /** * @brief Happy Path! */ diff --git a/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c b/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c index f8d1a7ee07..100d3e3f07 100644 --- a/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c +++ b/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c @@ -1813,6 +1813,93 @@ void test_eConsiderFrameForProcessing_Multicast_MACMatch( void ) TEST_ASSERT_EQUAL( eProcessBuffer, eResult ); } +/** + * @brief test_eConsiderFrameForProcessing_Multicast_MACNotMatch1 + * eConsiderFrameForProcessing must return eReleaseBuffer when the MAC address in packet + * does not match IPv4 Multicast MAC address. + */ +void test_eConsiderFrameForProcessing_Multicast_MACNotMatch1( void ) +{ + eFrameProcessingResult_t eResult; + uint8_t ucEthernetBuffer[ ipconfigTCP_MSS ]; + EthernetHeader_t * pxEthernetHeader; + + /* eConsiderFrameForProcessing */ + FreeRTOS_FindEndPointOnMAC_ExpectAnyArgsAndReturn( NULL ); + + /* Map the buffer onto Ethernet Header struct for easy access to fields. */ + pxEthernetHeader = ( EthernetHeader_t * ) ucEthernetBuffer; + + memset( ucEthernetBuffer, 0x00, ipconfigTCP_MSS ); + + pxEthernetHeader->xDestinationAddress.ucBytes[ 0 ] = ipMULTICAST_MAC_ADDRESS_IPv4_0; + pxEthernetHeader->xDestinationAddress.ucBytes[ 1 ] = 0xFF; + pxEthernetHeader->usFrameType = ipIPv4_FRAME_TYPE; + + eResult = eConsiderFrameForProcessing( ucEthernetBuffer ); + + TEST_ASSERT_EQUAL( eReleaseBuffer, eResult ); +} + +/** + * @brief test_eConsiderFrameForProcessing_Multicast_MACNotMatch2 + * eConsiderFrameForProcessing must return eReleaseBuffer when the MAC address in packet + * does not match IPv4 Multicast MAC address. + */ +void test_eConsiderFrameForProcessing_Multicast_MACNotMatch2( void ) +{ + eFrameProcessingResult_t eResult; + uint8_t ucEthernetBuffer[ ipconfigTCP_MSS ]; + EthernetHeader_t * pxEthernetHeader; + + /* eConsiderFrameForProcessing */ + FreeRTOS_FindEndPointOnMAC_ExpectAnyArgsAndReturn( NULL ); + + /* Map the buffer onto Ethernet Header struct for easy access to fields. */ + pxEthernetHeader = ( EthernetHeader_t * ) ucEthernetBuffer; + + memset( ucEthernetBuffer, 0x00, ipconfigTCP_MSS ); + + pxEthernetHeader->xDestinationAddress.ucBytes[ 0 ] = ipMULTICAST_MAC_ADDRESS_IPv4_0; + pxEthernetHeader->xDestinationAddress.ucBytes[ 1 ] = ipMULTICAST_MAC_ADDRESS_IPv4_1; + pxEthernetHeader->xDestinationAddress.ucBytes[ 2 ] = 0xFF; + pxEthernetHeader->usFrameType = ipIPv4_FRAME_TYPE; + + eResult = eConsiderFrameForProcessing( ucEthernetBuffer ); + + TEST_ASSERT_EQUAL( eReleaseBuffer, eResult ); +} + +/** + * @brief test_eConsiderFrameForProcessing_Multicast_MACNotMatch3 + * eConsiderFrameForProcessing must return eReleaseBuffer when the MAC address in packet + * does not match IPv4 Multicast MAC address. + */ +void test_eConsiderFrameForProcessing_Multicast_MACNotMatch3( void ) +{ + eFrameProcessingResult_t eResult; + uint8_t ucEthernetBuffer[ ipconfigTCP_MSS ]; + EthernetHeader_t * pxEthernetHeader; + + /* eConsiderFrameForProcessing */ + FreeRTOS_FindEndPointOnMAC_ExpectAnyArgsAndReturn( NULL ); + + /* Map the buffer onto Ethernet Header struct for easy access to fields. */ + pxEthernetHeader = ( EthernetHeader_t * ) ucEthernetBuffer; + + memset( ucEthernetBuffer, 0x00, ipconfigTCP_MSS ); + + pxEthernetHeader->xDestinationAddress.ucBytes[ 0 ] = ipMULTICAST_MAC_ADDRESS_IPv4_0; + pxEthernetHeader->xDestinationAddress.ucBytes[ 1 ] = ipMULTICAST_MAC_ADDRESS_IPv4_1; + pxEthernetHeader->xDestinationAddress.ucBytes[ 2 ] = ipMULTICAST_MAC_ADDRESS_IPv4_2; + pxEthernetHeader->xDestinationAddress.ucBytes[ 3 ] = 0xFF; + pxEthernetHeader->usFrameType = ipIPv4_FRAME_TYPE; + + eResult = eConsiderFrameForProcessing( ucEthernetBuffer ); + + TEST_ASSERT_EQUAL( eReleaseBuffer, eResult ); +} + /** * @brief test_eConsiderFrameForProcessing_IPv6_Multicast_MACMatch * eConsiderFrameForProcessing must return eProcessBuffer when the MAC address in packet @@ -1869,6 +1956,56 @@ void test_eConsiderFrameForProcessing_IPv6BroadCastMACPartialMatch( void ) TEST_ASSERT_EQUAL( eReleaseBuffer, eResult ); } +/** + * @brief test_eConsiderFrameForProcessing_ArpBoardcastMacMatch + * eConsiderFrameForProcessing must return eProcessBuffer when the MAC address in packet + * matches broadcast MAC address and the frame type is ARP. + */ +void test_eConsiderFrameForProcessing_ArpBoardcastMacMatch( void ) +{ + eFrameProcessingResult_t eResult; + uint8_t ucEthernetBuffer[ ipconfigTCP_MSS ]; + EthernetHeader_t * pxEthernetHeader; + + /* eConsiderFrameForProcessing */ + FreeRTOS_FindEndPointOnMAC_ExpectAnyArgsAndReturn( NULL ); + + /* Map the buffer onto Ethernet Header struct for easy access to fields. */ + pxEthernetHeader = ( EthernetHeader_t * ) ucEthernetBuffer; + + memset( ucEthernetBuffer, 0x00, ipconfigTCP_MSS ); + + memcpy( pxEthernetHeader->xDestinationAddress.ucBytes, xBroadcastMACAddress.ucBytes, sizeof( MACAddress_t ) ); + pxEthernetHeader->usFrameType = ipARP_FRAME_TYPE; + + eResult = eConsiderFrameForProcessing( ucEthernetBuffer ); + + TEST_ASSERT_EQUAL( eProcessBuffer, eResult ); +} + +/** + * @brief test_eConsiderFrameForProcessing_UnknownFrameType + * eConsiderFrameForProcessing must return eReleaseBuffer when the frame type + * is Unknwon. + */ +void test_eConsiderFrameForProcessing_UnknownFrameType( void ) +{ + eFrameProcessingResult_t eResult; + uint8_t ucEthernetBuffer[ ipconfigTCP_MSS ]; + EthernetHeader_t * pxEthernetHeader; + + /* Map the buffer onto Ethernet Header struct for easy access to fields. */ + pxEthernetHeader = ( EthernetHeader_t * ) ucEthernetBuffer; + + memset( ucEthernetBuffer, 0x00, ipconfigTCP_MSS ); + + pxEthernetHeader->usFrameType = 0xFFFF; + + eResult = eConsiderFrameForProcessing( ucEthernetBuffer ); + + TEST_ASSERT_EQUAL( eReleaseBuffer, eResult ); +} + /** * @brief test_prvProcessEthernetPacket_NoData * To validate if prvProcessEthernetPacket calls vReleaseNetworkBufferAndDescriptor diff --git a/test/unit-test/FreeRTOS_IP_DiffConfig1/FreeRTOS_IP_DiffConfig1_utest.c b/test/unit-test/FreeRTOS_IP_DiffConfig1/FreeRTOS_IP_DiffConfig1_utest.c index c103cd2649..3a1652158a 100644 --- a/test/unit-test/FreeRTOS_IP_DiffConfig1/FreeRTOS_IP_DiffConfig1_utest.c +++ b/test/unit-test/FreeRTOS_IP_DiffConfig1/FreeRTOS_IP_DiffConfig1_utest.c @@ -786,3 +786,26 @@ void test_FreeRTOS_GetUDPPayloadBuffer_BlockTimeEqualToConfig_IPv6NotSupported( TEST_ASSERT_EQUAL_PTR( NULL, pvReturn ); } + +/** + * @brief test_eConsiderFrameForProcessing_IPv6_FrameType_But_Disabled + * eConsiderFrameForProcessing must return eReleaseBuffer when the frame type is IPv6 but + * ipconfigUSE_IPv6 is disabled. + */ +void test_eConsiderFrameForProcessing_IPv6_FrameType_But_Disabled( void ) +{ + eFrameProcessingResult_t eResult; + uint8_t ucEthernetBuffer[ ipconfigNETWORK_MTU ]; + EthernetHeader_t * pxEthernetHeader; + + /* Map the buffer onto Ethernet Header struct for easy access to fields. */ + pxEthernetHeader = ( EthernetHeader_t * ) ucEthernetBuffer; + + memset( ucEthernetBuffer, 0x00, ipconfigNETWORK_MTU ); + + pxEthernetHeader->usFrameType = ipIPv6_FRAME_TYPE; + + eResult = eConsiderFrameForProcessing( ucEthernetBuffer ); + + TEST_ASSERT_EQUAL( eReleaseBuffer, eResult ); +} diff --git a/test/unit-test/FreeRTOS_IP_DiffConfig2/FreeRTOSIPConfig.h b/test/unit-test/FreeRTOS_IP_DiffConfig2/FreeRTOSIPConfig.h index cbcbc93853..73c8ac7478 100644 --- a/test/unit-test/FreeRTOS_IP_DiffConfig2/FreeRTOSIPConfig.h +++ b/test/unit-test/FreeRTOS_IP_DiffConfig2/FreeRTOSIPConfig.h @@ -302,7 +302,8 @@ #define ipconfigUSE_NBNS ( 1 ) -#define ipconfigUSE_LLMNR ( 1 ) +#define ipconfigUSE_LLMNR ( 0 ) +#define ipconfigUSE_MDNS ( 0 ) #define ipconfigDNS_USE_CALLBACKS 1 #define ipconfigUSE_ARP_REMOVE_ENTRY 1 diff --git a/test/unit-test/FreeRTOS_IP_DiffConfig2/FreeRTOS_IP_DiffConfig2_utest.c b/test/unit-test/FreeRTOS_IP_DiffConfig2/FreeRTOS_IP_DiffConfig2_utest.c index 15bfe29cc9..0594f6fa7e 100644 --- a/test/unit-test/FreeRTOS_IP_DiffConfig2/FreeRTOS_IP_DiffConfig2_utest.c +++ b/test/unit-test/FreeRTOS_IP_DiffConfig2/FreeRTOS_IP_DiffConfig2_utest.c @@ -143,3 +143,115 @@ void test_FreeRTOS_IPInit_HappyPathDHCP( void ) TEST_ASSERT_EQUAL( pdPASS, xReturn ); TEST_ASSERT_EQUAL( IPInItHappyPath_xTaskHandleToSet, FreeRTOS_GetIPTaskHandle() ); } + +/** + * @brief test_eConsiderFrameForProcessing_LLMNR_IPv4_MACMatch_But_Disabled + * eConsiderFrameForProcessing must return eReleaseBuffer when the MAC address in packet + * matches LLMNR MAC address and the frame type is valid but any of ipconfigUSE_DNS, ipconfigUSE_LLMNR + * or ipconfigUSE_IPv4 is disabled. + */ +void test_eConsiderFrameForProcessing_LLMNR_IPv4_MACMatch_But_Disabled( void ) +{ + eFrameProcessingResult_t eResult; + uint8_t ucEthernetBuffer[ ipconfigNETWORK_MTU ]; + EthernetHeader_t * pxEthernetHeader; + + /* eConsiderFrameForProcessing */ + FreeRTOS_FindEndPointOnMAC_ExpectAnyArgsAndReturn( NULL ); + + /* Map the buffer onto Ethernet Header struct for easy access to fields. */ + pxEthernetHeader = ( EthernetHeader_t * ) ucEthernetBuffer; + + memset( ucEthernetBuffer, 0x00, ipconfigNETWORK_MTU ); + + memcpy( pxEthernetHeader->xDestinationAddress.ucBytes, xLLMNR_MacAddress.ucBytes, sizeof( MACAddress_t ) ); + pxEthernetHeader->usFrameType = ipIPv4_FRAME_TYPE; + + eResult = eConsiderFrameForProcessing( ucEthernetBuffer ); + + TEST_ASSERT_EQUAL( eReleaseBuffer, eResult ); +} + +/** + * @brief test_eConsiderFrameForProcessing_LLMNR_IPv6_MACMatch_But_Disabled + * eConsiderFrameForProcessing must return eReleaseBuffer when the MAC address in packet + * matches LLMNR MAC address and the frame type is valid but any of ipconfigUSE_DNS, ipconfigUSE_LLMNR + * or ipconfigUSE_IPv6 is disabled. + */ +void test_eConsiderFrameForProcessing_LLMNR_IPv6_MACMatch_But_Disabled( void ) +{ + eFrameProcessingResult_t eResult; + uint8_t ucEthernetBuffer[ ipconfigNETWORK_MTU ]; + EthernetHeader_t * pxEthernetHeader; + + /* eConsiderFrameForProcessing */ + FreeRTOS_FindEndPointOnMAC_ExpectAnyArgsAndReturn( NULL ); + + /* Map the buffer onto Ethernet Header struct for easy access to fields. */ + pxEthernetHeader = ( EthernetHeader_t * ) ucEthernetBuffer; + + memset( ucEthernetBuffer, 0x00, ipconfigNETWORK_MTU ); + + memcpy( pxEthernetHeader->xDestinationAddress.ucBytes, xLLMNR_MacAddressIPv6.ucBytes, sizeof( MACAddress_t ) ); + pxEthernetHeader->usFrameType = ipIPv6_FRAME_TYPE; + + eResult = eConsiderFrameForProcessing( ucEthernetBuffer ); + + TEST_ASSERT_EQUAL( eReleaseBuffer, eResult ); +} + +/** + * @brief test_eConsiderFrameForProcessing_MDNS_IPv6_MACMatch_But_Disabled + * eConsiderFrameForProcessing must return eReleaseBuffer when the MAC address in packet + * matches MDNS MAC address and the frame type is valid but any of ipconfigUSE_DNS, ipconfigUSE_MDNS + * or ipconfigUSE_IPv6 is disabled. + */ +void test_eConsiderFrameForProcessing_MDNS_IPv6_MACMatch_But_Disabled( void ) +{ + eFrameProcessingResult_t eResult; + uint8_t ucEthernetBuffer[ ipconfigNETWORK_MTU ]; + EthernetHeader_t * pxEthernetHeader; + + /* eConsiderFrameForProcessing */ + FreeRTOS_FindEndPointOnMAC_ExpectAnyArgsAndReturn( NULL ); + + /* Map the buffer onto Ethernet Header struct for easy access to fields. */ + pxEthernetHeader = ( EthernetHeader_t * ) ucEthernetBuffer; + + memset( ucEthernetBuffer, 0x00, ipconfigNETWORK_MTU ); + + memcpy( pxEthernetHeader->xDestinationAddress.ucBytes, xMDNS_MACAddressIPv6.ucBytes, sizeof( MACAddress_t ) ); + pxEthernetHeader->usFrameType = ipIPv6_FRAME_TYPE; + + eResult = eConsiderFrameForProcessing( ucEthernetBuffer ); + + TEST_ASSERT_EQUAL( eReleaseBuffer, eResult ); +} + +/** + * @brief test_eConsiderFrameForProcessing_MDNS_IPv4_MACMatch_But_Disabled + * eConsiderFrameForProcessing must return eReleaseBuffer when the MAC address in packet + * matches MDNS MAC address and the frame type is valid but any of ipconfigUSE_DNS, ipconfigUSE_MDNS + * or ipconfigUSE_IPv4 is disabled. + */ +void test_eConsiderFrameForProcessing_MDNS_IPv4_MACMatch_But_Disabled( void ) +{ + eFrameProcessingResult_t eResult; + uint8_t ucEthernetBuffer[ ipconfigNETWORK_MTU ]; + EthernetHeader_t * pxEthernetHeader; + + /* eConsiderFrameForProcessing */ + FreeRTOS_FindEndPointOnMAC_ExpectAnyArgsAndReturn( NULL ); + + /* Map the buffer onto Ethernet Header struct for easy access to fields. */ + pxEthernetHeader = ( EthernetHeader_t * ) ucEthernetBuffer; + + memset( ucEthernetBuffer, 0x00, ipconfigNETWORK_MTU ); + + memcpy( pxEthernetHeader->xDestinationAddress.ucBytes, xMDNS_MacAddress.ucBytes, sizeof( MACAddress_t ) ); + pxEthernetHeader->usFrameType = ipIPv4_FRAME_TYPE; + + eResult = eConsiderFrameForProcessing( ucEthernetBuffer ); + + TEST_ASSERT_EQUAL( eReleaseBuffer, eResult ); +} From 6289c9ce92ad8d1669dd9b4f1ad8739fcf844bad Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Mon, 29 Jul 2024 09:09:02 +0000 Subject: [PATCH 12/15] Fix spell check and formatting --- .../FreeRTOS_DNS_Callback/FreeRTOS_DNS_Callback_utest.c | 4 ++-- test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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 d6f6467d51..d351003872 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 @@ -213,7 +213,7 @@ void test_xDNSDoCallback_success_equal_port_number_equal_name( void ) DNSMessage_t xDNSMessageHeader; char pc_name[] = "test"; uint8_t dnsCallbackMemory[ sizeof( DNSCallback_t ) + ipconfigDNS_CACHE_NAME_LENGTH ]; - DNSCallback_t *pxDnsCallback = ( DNSCallback_t * ) &dnsCallbackMemory; + DNSCallback_t * pxDnsCallback = ( DNSCallback_t * ) &dnsCallbackMemory; pxSet.pxDNSMessageHeader = &xDNSMessageHeader; pxSet.usPortNumber = FreeRTOS_htons( ipMDNS_PORT ); @@ -259,7 +259,7 @@ void test_xDNSDoCallback_fail_equal_port_number_not_equal_name( void ) char pc_name[] = "test"; strcpy( pxSet.pcName, pc_name ); dnsCallback->pCallbackFunction = dns_callback; - dnsCallback->pcName[0] = '\0'; + dnsCallback->pcName[ 0 ] = '\0'; /* Expectations */ listGET_END_MARKER_ExpectAnyArgsAndReturn( ( ListItem_t * ) 4 ); diff --git a/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c b/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c index 100d3e3f07..c9e8bdda94 100644 --- a/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c +++ b/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c @@ -1986,7 +1986,7 @@ void test_eConsiderFrameForProcessing_ArpBoardcastMacMatch( void ) /** * @brief test_eConsiderFrameForProcessing_UnknownFrameType * eConsiderFrameForProcessing must return eReleaseBuffer when the frame type - * is Unknwon. + * is unknown. */ void test_eConsiderFrameForProcessing_UnknownFrameType( void ) { From 39d6a1886447b5c7f0c27ba3bdcd2c5c7d804911 Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Wed, 31 Jul 2024 06:00:07 +0000 Subject: [PATCH 13/15] Define macro to check ethernet frame type. --- source/FreeRTOS_IP.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/source/FreeRTOS_IP.c b/source/FreeRTOS_IP.c index 4dafb7fb34..1a2601909d 100644 --- a/source/FreeRTOS_IP.c +++ b/source/FreeRTOS_IP.c @@ -92,6 +92,12 @@ #endif #endif +/** @brief The frame type field in the Ethernet header must have a value greater than 0x0600. + * If the configuration option ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES is enabled, the stack + * will discard packets with a frame type value less than or equal to 0x0600. + * However, if this option is disabled, the stack will continue to process these packets. */ +#define ipIS_ETHERNET_FRAME_TYPE_INVALID( usFrameType ) ( ( usFrameType ) <= 0x0600U ) + static void prvCallDHCP_RA_Handler( NetworkEndPoint_t * pxEndPoint ); static void prvIPTask_Initialise( void ); @@ -1460,7 +1466,8 @@ eFrameProcessingResult_t eConsiderFrameForProcessing( const uint8_t * const pucE usFrameType = pxEthernetHeader->usFrameType; /* Second, filter based on ethernet frame type. */ - if( FreeRTOS_ntohs( usFrameType ) <= 0x0600U ) + /* The frame type field in the Ethernet header must have a value greater than 0x0600. */ + if( ipIS_ETHERNET_FRAME_TYPE_INVALID( FreeRTOS_ntohs( usFrameType ) ) ) { /* The packet was not an Ethernet II frame */ #if ipconfigIS_ENABLED( ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES ) From ec21554e6874e1513704300bf4f1f9ee9a809190 Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Wed, 31 Jul 2024 09:54:01 +0000 Subject: [PATCH 14/15] Remove unnecessary declaration of xMDNS_MACAddressIPv6. --- source/include/FreeRTOS_DNS.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/source/include/FreeRTOS_DNS.h b/source/include/FreeRTOS_DNS.h index 3d5fe17cd2..830e1ae2be 100644 --- a/source/include/FreeRTOS_DNS.h +++ b/source/include/FreeRTOS_DNS.h @@ -54,10 +54,6 @@ extern const IPv6_Address_t ipLLMNR_IP_ADDR_IPv6; extern const MACAddress_t xMDNS_MacAddress; /* The MDNS IPv6 MAC address is 33:33:00:01:00:03 */ -extern const MACAddress_t xMDNS_MACAddressIPv6; - -/* The MDNS IPv6 address is ff02::1:3 */ -extern const IPv6_Address_t ipMDNS_IP_ADDR_IPv6; /* This type-name was formally "misspelled" as * xMDNS_MACAddressIPv6 with "MAC": */ @@ -65,6 +61,9 @@ extern const MACAddress_t xMDNS_MacAddressIPv6; /* Guarantee backward compatibility. */ #define xMDNS_MACAddressIPv6 xMDNS_MacAddressIPv6 +/* The MDNS IPv6 address is ff02::1:3 */ +extern const IPv6_Address_t ipMDNS_IP_ADDR_IPv6; + /** @brief While doing integration tests, it is necessary to influence the choice * between DNS/IPv4 and DNS/IPv4. Depending on this, a DNS server will be * addressed via IPv4 or IPv6 messages. */ From 499b5ff4689abc485af63d138d41366b99b3ecb1 Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Wed, 31 Jul 2024 10:03:08 +0000 Subject: [PATCH 15/15] Replace all usage of xMDNS_MACAddressIPv6 with xMDNS_MacAddressIPv6. --- source/FreeRTOS_DNS.c | 2 +- source/FreeRTOS_IP.c | 2 +- test/unit-test/FreeRTOS_IP/FreeRTOS_IP_stubs.c | 2 +- test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c | 2 +- .../FreeRTOS_IP_DiffConfig/FreeRTOS_IP_DiffConfig_stubs.c | 2 +- .../FreeRTOS_IP_DiffConfig1/FreeRTOS_IP_DiffConfig1_stubs.c | 2 +- .../FreeRTOS_IP_DiffConfig2/FreeRTOS_IP_DiffConfig2_stubs.c | 2 +- .../FreeRTOS_IP_DiffConfig2/FreeRTOS_IP_DiffConfig2_utest.c | 2 +- .../FreeRTOS_IP_DiffConfig3/FreeRTOS_IP_DiffConfig3_stubs.c | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/source/FreeRTOS_DNS.c b/source/FreeRTOS_DNS.c index 9fccf3e26a..82e2c6dbfe 100644 --- a/source/FreeRTOS_DNS.c +++ b/source/FreeRTOS_DNS.c @@ -82,7 +82,7 @@ const IPv6_Address_t ipLLMNR_IP_ADDR_IPv6 = const MACAddress_t xMDNS_MacAddress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfb } }; /** @brief The IPv6 multicast DNS MAC address. */ -const MACAddress_t xMDNS_MACAddressIPv6 = { { 0x33, 0x33, 0x00, 0x00, 0x00, 0xFB } }; +const MACAddress_t xMDNS_MacAddressIPv6 = { { 0x33, 0x33, 0x00, 0x00, 0x00, 0xFB } }; /** @brief multicast DNS IPv6 address */ const IPv6_Address_t ipMDNS_IP_ADDR_IPv6 = diff --git a/source/FreeRTOS_IP.c b/source/FreeRTOS_IP.c index 1a2601909d..607bc8fdc2 100644 --- a/source/FreeRTOS_IP.c +++ b/source/FreeRTOS_IP.c @@ -1559,7 +1559,7 @@ eFrameProcessingResult_t eConsiderFrameForProcessing( const uint8_t * const pucE /* DNS, MDNS, and IPv4 are enabled - Continue filter checks. */ #endif } - else if( memcmp( xMDNS_MACAddressIPv6.ucBytes, pxEthernetHeader->xDestinationAddress.ucBytes, sizeof( MACAddress_t ) ) == 0 ) + else if( memcmp( xMDNS_MacAddressIPv6.ucBytes, pxEthernetHeader->xDestinationAddress.ucBytes, sizeof( MACAddress_t ) ) == 0 ) { /* The packet is a request for MDNS using IPv6 */ #if ( ipconfigIS_DISABLED( ipconfigUSE_DNS ) || ipconfigIS_DISABLED( ipconfigUSE_MDNS ) || ipconfigIS_DISABLED( ipconfigUSE_IPv6 ) ) diff --git a/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_stubs.c b/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_stubs.c index 3fcbc1dad8..117d487d18 100644 --- a/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_stubs.c +++ b/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_stubs.c @@ -57,7 +57,7 @@ const MACAddress_t xLLMNR_MacAddressIPv6 = { { 0x33, 0x33, 0x00, 0x01, 0x00, 0x0 const MACAddress_t xMDNS_MacAddress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfb } }; -const MACAddress_t xMDNS_MACAddressIPv6 = { { 0x33, 0x33, 0x00, 0x00, 0x00, 0xFB } }; +const MACAddress_t xMDNS_MacAddressIPv6 = { { 0x33, 0x33, 0x00, 0x00, 0x00, 0xFB } }; void vPortEnterCritical( void ) { diff --git a/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c b/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c index c9e8bdda94..1e4469d6ab 100644 --- a/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c +++ b/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c @@ -1748,7 +1748,7 @@ void test_eConsiderFrameForProcessing_MDNS_IPv6_MACMatch( void ) memset( ucEthernetBuffer, 0x00, ipconfigTCP_MSS ); - memcpy( pxEthernetHeader->xDestinationAddress.ucBytes, xMDNS_MACAddressIPv6.ucBytes, sizeof( MACAddress_t ) ); + memcpy( pxEthernetHeader->xDestinationAddress.ucBytes, xMDNS_MacAddressIPv6.ucBytes, sizeof( MACAddress_t ) ); pxEthernetHeader->usFrameType = ipIPv6_FRAME_TYPE; eResult = eConsiderFrameForProcessing( ucEthernetBuffer ); diff --git a/test/unit-test/FreeRTOS_IP_DiffConfig/FreeRTOS_IP_DiffConfig_stubs.c b/test/unit-test/FreeRTOS_IP_DiffConfig/FreeRTOS_IP_DiffConfig_stubs.c index a69bfcac81..9a9ea5162b 100644 --- a/test/unit-test/FreeRTOS_IP_DiffConfig/FreeRTOS_IP_DiffConfig_stubs.c +++ b/test/unit-test/FreeRTOS_IP_DiffConfig/FreeRTOS_IP_DiffConfig_stubs.c @@ -58,7 +58,7 @@ const MACAddress_t xLLMNR_MacAddressIPv6 = { { 0x33, 0x33, 0x00, 0x01, 0x00, 0x0 const MACAddress_t xMDNS_MacAddress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfb } }; -const MACAddress_t xMDNS_MACAddressIPv6 = { { 0x33, 0x33, 0x00, 0x00, 0x00, 0xFB } }; +const MACAddress_t xMDNS_MacAddressIPv6 = { { 0x33, 0x33, 0x00, 0x00, 0x00, 0xFB } }; void vPortEnterCritical( void ) { diff --git a/test/unit-test/FreeRTOS_IP_DiffConfig1/FreeRTOS_IP_DiffConfig1_stubs.c b/test/unit-test/FreeRTOS_IP_DiffConfig1/FreeRTOS_IP_DiffConfig1_stubs.c index 2ce1c386d1..2d454be482 100644 --- a/test/unit-test/FreeRTOS_IP_DiffConfig1/FreeRTOS_IP_DiffConfig1_stubs.c +++ b/test/unit-test/FreeRTOS_IP_DiffConfig1/FreeRTOS_IP_DiffConfig1_stubs.c @@ -59,7 +59,7 @@ const MACAddress_t xLLMNR_MacAddressIPv6 = { { 0x33, 0x33, 0x00, 0x01, 0x00, 0x0 const MACAddress_t xMDNS_MacAddress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfb } }; -const MACAddress_t xMDNS_MACAddressIPv6 = { { 0x33, 0x33, 0x00, 0x00, 0x00, 0xFB } }; +const MACAddress_t xMDNS_MacAddressIPv6 = { { 0x33, 0x33, 0x00, 0x00, 0x00, 0xFB } }; void vPortEnterCritical( void ) { diff --git a/test/unit-test/FreeRTOS_IP_DiffConfig2/FreeRTOS_IP_DiffConfig2_stubs.c b/test/unit-test/FreeRTOS_IP_DiffConfig2/FreeRTOS_IP_DiffConfig2_stubs.c index 4a9c89c093..641b42e4b7 100644 --- a/test/unit-test/FreeRTOS_IP_DiffConfig2/FreeRTOS_IP_DiffConfig2_stubs.c +++ b/test/unit-test/FreeRTOS_IP_DiffConfig2/FreeRTOS_IP_DiffConfig2_stubs.c @@ -55,7 +55,7 @@ const MACAddress_t xLLMNR_MacAddressIPv6 = { { 0x33, 0x33, 0x00, 0x01, 0x00, 0x0 const MACAddress_t xMDNS_MacAddress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfb } }; -const MACAddress_t xMDNS_MACAddressIPv6 = { { 0x33, 0x33, 0x00, 0x00, 0x00, 0xFB } }; +const MACAddress_t xMDNS_MacAddressIPv6 = { { 0x33, 0x33, 0x00, 0x00, 0x00, 0xFB } }; void vPortEnterCritical( void ) { diff --git a/test/unit-test/FreeRTOS_IP_DiffConfig2/FreeRTOS_IP_DiffConfig2_utest.c b/test/unit-test/FreeRTOS_IP_DiffConfig2/FreeRTOS_IP_DiffConfig2_utest.c index 0594f6fa7e..25cf53b60e 100644 --- a/test/unit-test/FreeRTOS_IP_DiffConfig2/FreeRTOS_IP_DiffConfig2_utest.c +++ b/test/unit-test/FreeRTOS_IP_DiffConfig2/FreeRTOS_IP_DiffConfig2_utest.c @@ -220,7 +220,7 @@ void test_eConsiderFrameForProcessing_MDNS_IPv6_MACMatch_But_Disabled( void ) memset( ucEthernetBuffer, 0x00, ipconfigNETWORK_MTU ); - memcpy( pxEthernetHeader->xDestinationAddress.ucBytes, xMDNS_MACAddressIPv6.ucBytes, sizeof( MACAddress_t ) ); + memcpy( pxEthernetHeader->xDestinationAddress.ucBytes, xMDNS_MacAddressIPv6.ucBytes, sizeof( MACAddress_t ) ); pxEthernetHeader->usFrameType = ipIPv6_FRAME_TYPE; eResult = eConsiderFrameForProcessing( ucEthernetBuffer ); diff --git a/test/unit-test/FreeRTOS_IP_DiffConfig3/FreeRTOS_IP_DiffConfig3_stubs.c b/test/unit-test/FreeRTOS_IP_DiffConfig3/FreeRTOS_IP_DiffConfig3_stubs.c index b420546833..938937b617 100644 --- a/test/unit-test/FreeRTOS_IP_DiffConfig3/FreeRTOS_IP_DiffConfig3_stubs.c +++ b/test/unit-test/FreeRTOS_IP_DiffConfig3/FreeRTOS_IP_DiffConfig3_stubs.c @@ -56,7 +56,7 @@ const MACAddress_t xLLMNR_MacAddressIPv6 = { { 0x33, 0x33, 0x00, 0x01, 0x00, 0x0 const MACAddress_t xMDNS_MacAddress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfb } }; -const MACAddress_t xMDNS_MACAddressIPv6 = { { 0x33, 0x33, 0x00, 0x00, 0x00, 0xFB } }; +const MACAddress_t xMDNS_MacAddressIPv6 = { { 0x33, 0x33, 0x00, 0x00, 0x00, 0xFB } }; void vPortEnterCritical( void ) {