Skip to content

Commit 0764d70

Browse files
author
Emil Popov
committed
Adds support for receiving Multicast Group addresses
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
1 parent ce11071 commit 0764d70

14 files changed

+1306
-34
lines changed

source/FreeRTOS_DNS_Networking.c

+5
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@
8484
* going to be '0' i.e. success. Thus, return value is discarded */
8585
( void ) FreeRTOS_setsockopt( xSocket, 0, FREERTOS_SO_SNDTIMEO, &( uxWriteTimeOut_ticks ), sizeof( TickType_t ) );
8686
( void ) FreeRTOS_setsockopt( xSocket, 0, FREERTOS_SO_RCVTIMEO, &( uxReadTimeOut_ticks ), sizeof( TickType_t ) );
87+
#if ( ipconfigSUPPORT_IP_MULTICAST != 0 )
88+
/* Since this socket may be used for LLMNR or mDNS, set the multicast TTL to 1. */
89+
uint8_t ucMulticastTTL = 1;
90+
( void ) FreeRTOS_setsockopt( xSocket, 0, FREERTOS_SO_IP_MULTICAST_TTL, &( ucMulticastTTL ), sizeof( uint8_t ) );
91+
#endif
8792
}
8893

8994
return xSocket;

source/FreeRTOS_IGMP.c

+630
Large diffs are not rendered by default.

source/FreeRTOS_IP.c

+35
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@
5959
#include "FreeRTOS_DNS.h"
6060
#include "FreeRTOS_Routing.h"
6161
#include "FreeRTOS_ND.h"
62+
#if ( ipconfigSUPPORT_IP_MULTICAST != 0 )
63+
#include "FreeRTOS_IGMP.h"
64+
#endif
6265

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

473+
#if ( ipconfigSUPPORT_IP_MULTICAST != 0 )
474+
case eSocketOptAddMembership:
475+
{
476+
MCastGroupDesc_t * pxMCG = ( MCastGroupDesc_t * ) xReceivedEvent.pvData;
477+
( void ) vModifyMulticastMembership( pxMCG, eSocketOptAddMembership );
478+
break;
479+
}
480+
481+
case eSocketOptDropMembership:
482+
{
483+
MCastGroupDesc_t * pxMCG = ( MCastGroupDesc_t * ) xReceivedEvent.pvData;
484+
( void ) vModifyMulticastMembership( pxMCG, eSocketOptDropMembership );
485+
break;
486+
}
487+
488+
case eIGMPEvent:
489+
( void ) vHandleIGMP_Event();
490+
break;
491+
#endif /* ( ipconfigSUPPORT_IP_MULTICAST != 0) */
492+
470493
default:
471494
/* Should not get here. */
472495
break;
@@ -526,6 +549,11 @@ static void prvIPTask_Initialise( void )
526549
}
527550
#endif /* ( ( ipconfigUSE_DNS_CACHE != 0 ) && ( ipconfigUSE_DNS != 0 ) ) */
528551

552+
/* Init the list that will hold scheduled IGMP reports. */
553+
#if ( ipconfigSUPPORT_IP_MULTICAST != 0 )
554+
( void ) vIGMP_Init();
555+
#endif
556+
529557
/* Initialisation is complete and events can now be processed. */
530558
xIPTaskInitialised = pdTRUE;
531559
}
@@ -1980,6 +2008,13 @@ static eFrameProcessingResult_t prvProcessIPPacket( const IPPacket_t * pxIPPacke
19802008
break;
19812009
#endif /* ( ipconfigUSE_IPv6 != 0 ) */
19822010

2011+
#if ( ipconfigSUPPORT_IP_MULTICAST != 0 )
2012+
case ipPROTOCOL_IGMP:
2013+
/* The IP packet contained an IGMP frame. */
2014+
eReturn = eProcessIGMPPacket( pxNetworkBuffer );
2015+
break;
2016+
#endif /* ( ipconfigSUPPORT_IP_MULTICAST != 0 ) */
2017+
19832018
case ipPROTOCOL_UDP:
19842019
/* The IP packet contained a UDP frame. */
19852020

source/FreeRTOS_IP_Timers.c

+41
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@
5555
#include "NetworkBufferManagement.h"
5656
#include "FreeRTOS_Routing.h"
5757
#include "FreeRTOS_DNS.h"
58+
#if ( ipconfigSUPPORT_IP_MULTICAST != 0 )
59+
#include "FreeRTOS_IGMP.h"
60+
#endif
5861
/*-----------------------------------------------------------*/
5962

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

116+
#if ( ipconfigSUPPORT_IP_MULTICAST != 0 )
117+
/** @brief IGMP timer. Used for sending scheduled IGMP Reports */
118+
static IPTimer_t xIGMPTimer;
119+
#endif
120+
113121
/** @brief As long as not all networks are up, repeat initialisation by calling the
114122
* xNetworkInterfaceInitialise() function of the interfaces that are not ready. */
115123

@@ -176,6 +184,15 @@ TickType_t xCalculateSleepTime( void )
176184
}
177185
#endif
178186

187+
#if ( ipconfigSUPPORT_IP_MULTICAST == 1 )
188+
{
189+
if( xIGMPTimer.ulRemainingTime < uxMaximumSleepTime )
190+
{
191+
uxMaximumSleepTime = xIGMPTimer.ulRemainingTime;
192+
}
193+
}
194+
#endif /* ipconfigSUPPORT_IP_MULTICAST */
195+
179196
#if ( ipconfigDNS_USE_CALLBACKS != 0 )
180197
{
181198
if( xDNSTimer.bActive != pdFALSE_UNSIGNED )
@@ -312,6 +329,16 @@ void vCheckNetworkTimers( void )
312329
vSocketListenNextTime( NULL );
313330
#endif /* ipconfigUSE_TCP == 1 */
314331

332+
#if ( ipconfigSUPPORT_IP_MULTICAST != 0 )
333+
{
334+
/* Is it time to send any IGMP reports? */
335+
if( prvIPTimerCheck( &xIGMPTimer ) != pdFALSE )
336+
{
337+
( void ) xSendIGMPEvent();
338+
}
339+
}
340+
#endif /* ipconfigSUPPORT_IP_MULTICAST != 0 */
341+
315342
/* Is it time to trigger the repeated NetworkDown events? */
316343
if( xAllNetworksUp == pdFALSE )
317344
{
@@ -412,6 +439,20 @@ void vARPTimerReload( TickType_t xTime )
412439

413440
/*-----------------------------------------------------------*/
414441

442+
#if ( ipconfigSUPPORT_IP_MULTICAST != 0 )
443+
444+
/**
445+
* @brief Reload the IGMP timer.
446+
*
447+
* @param[in] xIgmpTickTime: The reload value.
448+
*/
449+
void vIGMPTimerReload( TickType_t xIgmpTickTime )
450+
{
451+
prvIPTimerReload( &xIGMPTimer, pdMS_TO_TICKS( ipIGMP_TIMER_PERIOD_MS ) );
452+
}
453+
#endif /* ipconfigSUPPORT_IP_MULTICAST */
454+
/*-----------------------------------------------------------*/
455+
415456
#if ( ipconfigDNS_USE_CALLBACKS != 0 )
416457

417458
/**

0 commit comments

Comments
 (0)