Skip to content

Commit

Permalink
Adds support for receiving Multicast Group addresses
Browse files Browse the repository at this point in the history
Adds IGMP version 2
Adds 2 function pointers to the network interface struct that handle adding and removing  multicast MAC addresses.
Updates IGMP to use function pointers through the network interface.
Makes the Add/Remove Multicast functions private to NetworkInterface.c They are now used through pointers in the NetworkInterface_t struct.
Improves the SAME70 driver to handle adding/removing muticast MAC addresses
  • Loading branch information
Emil Popov committed Sep 29, 2023
1 parent ce11071 commit 0764d70
Show file tree
Hide file tree
Showing 14 changed files with 1,306 additions and 34 deletions.
5 changes: 5 additions & 0 deletions source/FreeRTOS_DNS_Networking.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@
* going to be '0' i.e. success. Thus, return value is discarded */
( void ) FreeRTOS_setsockopt( xSocket, 0, FREERTOS_SO_SNDTIMEO, &( uxWriteTimeOut_ticks ), sizeof( TickType_t ) );
( void ) FreeRTOS_setsockopt( xSocket, 0, FREERTOS_SO_RCVTIMEO, &( uxReadTimeOut_ticks ), sizeof( TickType_t ) );
#if ( ipconfigSUPPORT_IP_MULTICAST != 0 )
/* Since this socket may be used for LLMNR or mDNS, set the multicast TTL to 1. */
uint8_t ucMulticastTTL = 1;
( void ) FreeRTOS_setsockopt( xSocket, 0, FREERTOS_SO_IP_MULTICAST_TTL, &( ucMulticastTTL ), sizeof( uint8_t ) );
#endif
}

return xSocket;
Expand Down
630 changes: 630 additions & 0 deletions source/FreeRTOS_IGMP.c

Large diffs are not rendered by default.

35 changes: 35 additions & 0 deletions source/FreeRTOS_IP.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
#include "FreeRTOS_DNS.h"
#include "FreeRTOS_Routing.h"
#include "FreeRTOS_ND.h"
#if ( ipconfigSUPPORT_IP_MULTICAST != 0 )
#include "FreeRTOS_IGMP.h"
#endif

/** @brief Time delay between repeated attempts to initialise the network hardware. */
#ifndef ipINITIALISATION_RETRY_DELAY
Expand Down Expand Up @@ -467,6 +470,26 @@ static void prvProcessIPEventsAndTimers( void )
/* xQueueReceive() returned because of a normal time-out. */
break;

#if ( ipconfigSUPPORT_IP_MULTICAST != 0 )
case eSocketOptAddMembership:
{
MCastGroupDesc_t * pxMCG = ( MCastGroupDesc_t * ) xReceivedEvent.pvData;
( void ) vModifyMulticastMembership( pxMCG, eSocketOptAddMembership );
break;
}

case eSocketOptDropMembership:
{
MCastGroupDesc_t * pxMCG = ( MCastGroupDesc_t * ) xReceivedEvent.pvData;
( void ) vModifyMulticastMembership( pxMCG, eSocketOptDropMembership );
break;
}

case eIGMPEvent:
( void ) vHandleIGMP_Event();
break;
#endif /* ( ipconfigSUPPORT_IP_MULTICAST != 0) */

default:
/* Should not get here. */
break;
Expand Down Expand Up @@ -526,6 +549,11 @@ static void prvIPTask_Initialise( void )
}
#endif /* ( ( ipconfigUSE_DNS_CACHE != 0 ) && ( ipconfigUSE_DNS != 0 ) ) */

/* Init the list that will hold scheduled IGMP reports. */
#if ( ipconfigSUPPORT_IP_MULTICAST != 0 )
( void ) vIGMP_Init();
#endif

/* Initialisation is complete and events can now be processed. */
xIPTaskInitialised = pdTRUE;
}
Expand Down Expand Up @@ -1980,6 +2008,13 @@ static eFrameProcessingResult_t prvProcessIPPacket( const IPPacket_t * pxIPPacke
break;
#endif /* ( ipconfigUSE_IPv6 != 0 ) */

#if ( ipconfigSUPPORT_IP_MULTICAST != 0 )
case ipPROTOCOL_IGMP:
/* The IP packet contained an IGMP frame. */
eReturn = eProcessIGMPPacket( pxNetworkBuffer );
break;
#endif /* ( ipconfigSUPPORT_IP_MULTICAST != 0 ) */

case ipPROTOCOL_UDP:
/* The IP packet contained a UDP frame. */

Expand Down
41 changes: 41 additions & 0 deletions source/FreeRTOS_IP_Timers.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
#include "NetworkBufferManagement.h"
#include "FreeRTOS_Routing.h"
#include "FreeRTOS_DNS.h"
#if ( ipconfigSUPPORT_IP_MULTICAST != 0 )
#include "FreeRTOS_IGMP.h"
#endif
/*-----------------------------------------------------------*/

/** @brief 'xAllNetworksUp' becomes pdTRUE as soon as all network interfaces have
Expand Down Expand Up @@ -110,6 +113,11 @@ static IPTimer_t xARPTimer;
static IPTimer_t xDNSTimer;
#endif

#if ( ipconfigSUPPORT_IP_MULTICAST != 0 )
/** @brief IGMP timer. Used for sending scheduled IGMP Reports */
static IPTimer_t xIGMPTimer;
#endif

/** @brief As long as not all networks are up, repeat initialisation by calling the
* xNetworkInterfaceInitialise() function of the interfaces that are not ready. */

Expand Down Expand Up @@ -176,6 +184,15 @@ TickType_t xCalculateSleepTime( void )
}
#endif

#if ( ipconfigSUPPORT_IP_MULTICAST == 1 )
{
if( xIGMPTimer.ulRemainingTime < uxMaximumSleepTime )
{
uxMaximumSleepTime = xIGMPTimer.ulRemainingTime;
}
}
#endif /* ipconfigSUPPORT_IP_MULTICAST */

#if ( ipconfigDNS_USE_CALLBACKS != 0 )
{
if( xDNSTimer.bActive != pdFALSE_UNSIGNED )
Expand Down Expand Up @@ -312,6 +329,16 @@ void vCheckNetworkTimers( void )
vSocketListenNextTime( NULL );
#endif /* ipconfigUSE_TCP == 1 */

#if ( ipconfigSUPPORT_IP_MULTICAST != 0 )
{
/* Is it time to send any IGMP reports? */
if( prvIPTimerCheck( &xIGMPTimer ) != pdFALSE )
{
( void ) xSendIGMPEvent();
}
}
#endif /* ipconfigSUPPORT_IP_MULTICAST != 0 */

/* Is it time to trigger the repeated NetworkDown events? */
if( xAllNetworksUp == pdFALSE )
{
Expand Down Expand Up @@ -412,6 +439,20 @@ void vARPTimerReload( TickType_t xTime )

/*-----------------------------------------------------------*/

#if ( ipconfigSUPPORT_IP_MULTICAST != 0 )

/**
* @brief Reload the IGMP timer.
*
* @param[in] xIgmpTickTime: The reload value.
*/
void vIGMPTimerReload( TickType_t xIgmpTickTime )
{
prvIPTimerReload( &xIGMPTimer, pdMS_TO_TICKS( ipIGMP_TIMER_PERIOD_MS ) );
}
#endif /* ipconfigSUPPORT_IP_MULTICAST */
/*-----------------------------------------------------------*/

#if ( ipconfigDNS_USE_CALLBACKS != 0 )

/**
Expand Down
Loading

0 comments on commit 0764d70

Please sign in to comment.