From e07d79db9283cde545de93ddba0ae10baf8ff20f Mon Sep 17 00:00:00 2001 From: Emil Popov Date: Mon, 29 Jan 2024 14:27:19 -0500 Subject: [PATCH] Removes the explicit broadcast MAC check in eConsiderFrameForProcessing. Broadcasts are a form of multicasts and will be received when ipconfigSUPPORT_IP_MULTICAST is enabled. --- source/FreeRTOS_IP.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/source/FreeRTOS_IP.c b/source/FreeRTOS_IP.c index 267c23590a..af580fbe49 100644 --- a/source/FreeRTOS_IP.c +++ b/source/FreeRTOS_IP.c @@ -1515,12 +1515,7 @@ eFrameProcessingResult_t eConsiderFrameForProcessing( const uint8_t * const pucE /* 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 ( ipconfigIS_ENABLED( ipconfigSUPPORT_IP_MULTICAST ) ) /* @@ -1529,34 +1524,40 @@ eFrameProcessingResult_t eConsiderFrameForProcessing( const uint8_t * const pucE * know which socket needs which multicast address. Another thing to consider is * that unless this function returns eProcessBuffer, eApplicationProcessCustomFrameHook() * will not be called, so handling custom multicast frames would be impossible. + * Note that the broadcast MAC is a type of multicast so the multicast check covers it. */ - if( MAC_IS_MULTICAST( pxEthernetHeader->xDestinationAddress.ucBytes ) ) + else if( MAC_IS_MULTICAST( pxEthernetHeader->xDestinationAddress.ucBytes ) ) { eReturn = eProcessBuffer; } #else /* ipconfigIS_ENABLED( ipconfigSUPPORT_IP_MULTICAST ) */ + else if( memcmp( xBroadcastMACAddress.ucBytes, pxEthernetHeader->xDestinationAddress.ucBytes, sizeof( MACAddress_t ) ) == 0 ) + { + /* The packet was a broadcast - process it. */ + eReturn = eProcessBuffer; + } #if ( ( ipconfigUSE_LLMNR == 1 ) && ( ipconfigUSE_DNS != 0 ) ) - if( memcmp( xLLMNR_MacAddress.ucBytes, pxEthernetHeader->xDestinationAddress.ucBytes, sizeof( MACAddress_t ) ) == 0 ) + else 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 ) + else 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; - } + #if ( ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) ) + 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 - process it. */ + eReturn = eProcessBuffer; + } + #endif /* ipconfigIS_ENABLED( ipconfigUSE_IPv6 ) */ #endif /* ipconfigIS_ENABLED( ipconfigSUPPORT_IP_MULTICAST ) */ else {