Skip to content

Commit

Permalink
Changes eConsiderFrameForProcessing() to allow all multicast ethernet…
Browse files Browse the repository at this point in the history
… frames when ipconfigSUPPORT_IP_MULTICAST is enabled and ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES is disabled.
  • Loading branch information
Emil Popov committed Jan 23, 2024
1 parent 3be09ef commit 5a2759f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 18 deletions.
47 changes: 31 additions & 16 deletions source/FreeRTOS_IP.c
Original file line number Diff line number Diff line change
Expand Up @@ -1513,28 +1513,43 @@ eFrameProcessingResult_t eConsiderFrameForProcessing( const uint8_t * const pucE
eReturn = eProcessBuffer;
}
else
#if ( ( ipconfigUSE_LLMNR == 1 ) && ( ipconfigUSE_DNS != 0 ) )
if( memcmp( xLLMNR_MacAddress.ucBytes, pxEthernetHeader->xDestinationAddress.ucBytes, sizeof( MACAddress_t ) ) == 0 )
#if ( ipconfigIS_ENABLED( ipconfigSUPPORT_IP_MULTICAST ) )

/*
* With ipconfigSUPPORT_IP_MULTICAST enabled, FreeRTOS+TCP needs access to all
* multicast packets. It is too early to filter them out here because we don't
* 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.
*/
if( MAC_IS_MULTICAST( pxEthernetHeader->xDestinationAddress.ucBytes ) )
{
/* 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 /* ipconfigIS_ENABLED( ipconfigSUPPORT_IP_MULTICAST ) */
#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 MDNS - process it. */
/* The packet is a request for LLMNR - 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;
}
#endif /* ipconfigIS_ENABLED( ipconfigSUPPORT_IP_MULTICAST ) */
else
{
/* The packet was not a broadcast, or for this node, just release
Expand Down
2 changes: 1 addition & 1 deletion source/FreeRTOS_IP_Multicast.c
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ BaseType_t xEnlistMulticastReport( struct MCastReportDescription * pNewEntry )
IGMPPacket_t * pxIGMPPacket;
portBASE_TYPE xReturn = pdFAIL;

configASSERT( pxEndPoint != NULL )
configASSERT( pxEndPoint != NULL );

if( NULL != ( pxNetworkBuffer = pxGetNetworkBufferWithDescriptor( sizeof( IGMPPacket_t ), 0 ) ) )
{
Expand Down
6 changes: 5 additions & 1 deletion source/include/FreeRTOSIPConfigDefaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -3301,7 +3301,11 @@
* Type: BaseType_t ( ipconfigENABLE | ipconfigDISABLE )
*
* When set to ipconfigENABLE, this macro will
* enable the reception of multicast groups addresses. */
* enable the reception of multicast groups addresses. When enabled,
* It is highly recommended to enable ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES
* and use a network driver that supports MAC filtering through the
* pfAddAllowedMAC/pfRemoveAllowedMAC functions.
*/
#ifndef ipconfigSUPPORT_IP_MULTICAST
#define ipconfigSUPPORT_IP_MULTICAST ipconfigDISABLE
#endif
Expand Down

0 comments on commit 5a2759f

Please sign in to comment.