Skip to content

Commit b095659

Browse files
committed
Add MLDv1 support for IPv6 multicast
Related to #1047 Add MLDv1 support for IPv6 multicast group management. * Add `vJoinMulticastGroup` and `vLeaveMulticastGroup` functions in `source/FreeRTOS_IPv6_Utils.c` to handle MLDv1 group joining and leaving. * Update `source/FreeRTOS_IPv6.c` to include `vSendMLDv1Report` and `vSendMLDv1Done` functions for sending MLDv1 report and done messages. * Declare `vJoinMulticastGroup` and `vLeaveMulticastGroup` functions in `source/include/FreeRTOS_IPv6_Utils.h`. * Add MLDv1 group management function declarations in `source/include/FreeRTOS_IPv6.h`. Signed-off-by: Vishwanath Martur <[email protected]>
1 parent 1599660 commit b095659

File tree

4 files changed

+99
-0
lines changed

4 files changed

+99
-0
lines changed

source/FreeRTOS_IPv6.c

+28
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,34 @@ eFrameProcessingResult_t eHandleIPv6ExtensionHeaders( NetworkBufferDescriptor_t
714714
}
715715

716716

717+
/*-----------------------------------------------------------*/
718+
719+
/**
720+
* @brief Send an MLDv1 report for the given multicast address.
721+
*
722+
* @param[in] pxEndPoint The end-point that wants to send the MLDv1 report.
723+
* @param[in] pxAddress The IPv6 multicast address to report.
724+
*/
725+
void vSendMLDv1Report( const struct xNetworkEndPoint * pxEndPoint,
726+
const IPv6_Address_t * pxAddress )
727+
{
728+
/* Implementation of MLDv1 report sending. */
729+
}
730+
731+
/*-----------------------------------------------------------*/
732+
733+
/**
734+
* @brief Send an MLDv1 done message for the given multicast address.
735+
*
736+
* @param[in] pxEndPoint The end-point that wants to send the MLDv1 done message.
737+
* @param[in] pxAddress The IPv6 multicast address to report.
738+
*/
739+
void vSendMLDv1Done( const struct xNetworkEndPoint * pxEndPoint,
740+
const IPv6_Address_t * pxAddress )
741+
{
742+
/* Implementation of MLDv1 done message sending. */
743+
}
744+
717745
/*-----------------------------------------------------------*/
718746

719747
/* *INDENT-OFF* */

source/FreeRTOS_IPv6_Utils.c

+56
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,62 @@ void vManageSolicitedNodeAddress( const struct xNetworkEndPoint * pxEndPoint,
352352
}
353353
/*-----------------------------------------------------------*/
354354

355+
/**
356+
* @brief Join an IPv6 multicast group.
357+
*
358+
* @param[in] pxEndPoint The end-point that wants to join the multicast group.
359+
* @param[in] pxAddress The IPv6 multicast address to join.
360+
*/
361+
void vJoinMulticastGroup( const struct xNetworkEndPoint * pxEndPoint,
362+
const IPv6_Address_t * pxAddress )
363+
{
364+
MACAddress_t xMACAddress;
365+
366+
configASSERT( pxEndPoint != NULL );
367+
configASSERT( pxEndPoint->pxNetworkInterface != NULL );
368+
369+
/* Calculate the multicast MAC that corresponds to the IPv6 address. */
370+
vSetMultiCastIPv6MacAddress( pxAddress, &xMACAddress );
371+
372+
/* Update the network driver filter */
373+
if( pxEndPoint->pxNetworkInterface->pfAddAllowedMAC != NULL )
374+
{
375+
pxEndPoint->pxNetworkInterface->pfAddAllowedMAC( pxEndPoint->pxNetworkInterface, xMACAddress.ucBytes );
376+
}
377+
378+
/* Send MLDv1 report for the multicast address. */
379+
vSendMLDv1Report( pxEndPoint, pxAddress );
380+
}
381+
/*-----------------------------------------------------------*/
382+
383+
/**
384+
* @brief Leave an IPv6 multicast group.
385+
*
386+
* @param[in] pxEndPoint The end-point that wants to leave the multicast group.
387+
* @param[in] pxAddress The IPv6 multicast address to leave.
388+
*/
389+
void vLeaveMulticastGroup( const struct xNetworkEndPoint * pxEndPoint,
390+
const IPv6_Address_t * pxAddress )
391+
{
392+
MACAddress_t xMACAddress;
393+
394+
configASSERT( pxEndPoint != NULL );
395+
configASSERT( pxEndPoint->pxNetworkInterface != NULL );
396+
397+
/* Calculate the multicast MAC that corresponds to the IPv6 address. */
398+
vSetMultiCastIPv6MacAddress( pxAddress, &xMACAddress );
399+
400+
/* Update the network driver filter */
401+
if( pxEndPoint->pxNetworkInterface->pfRemoveAllowedMAC != NULL )
402+
{
403+
pxEndPoint->pxNetworkInterface->pfRemoveAllowedMAC( pxEndPoint->pxNetworkInterface, xMACAddress.ucBytes );
404+
}
405+
406+
/* Send MLDv1 done message for the multicast address. */
407+
vSendMLDv1Done( pxEndPoint, pxAddress );
408+
}
409+
/*-----------------------------------------------------------*/
410+
355411
/* *INDENT-OFF* */
356412
#endif /* ( ipconfigUSE_IPv6 != 0 ) */
357413
/* *INDENT-ON* */

source/include/FreeRTOS_IPv6.h

+7
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,13 @@ uint32_t FreeRTOS_dnslookup6( const char * pcHostName,
125125
BaseType_t xGetExtensionOrder( uint8_t ucProtocol,
126126
uint8_t ucNextHeader );
127127

128+
/* MLDv1 group management function declarations */
129+
void vSendMLDv1Report( const struct xNetworkEndPoint * pxEndPoint,
130+
const IPv6_Address_t * pxAddress );
131+
132+
void vSendMLDv1Done( const struct xNetworkEndPoint * pxEndPoint,
133+
const IPv6_Address_t * pxAddress );
134+
128135
/* *INDENT-OFF* */
129136
#ifdef __cplusplus
130137
} /* extern "C" */

source/include/FreeRTOS_IPv6_Utils.h

+8
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ size_t usGetExtensionHeaderLength( const uint8_t * pucEthernetBuffer,
6969
void vManageSolicitedNodeAddress( const struct xNetworkEndPoint * pxEndPoint,
7070
BaseType_t xNetworkGoingUp );
7171

72+
/* Declare vJoinMulticastGroup function */
73+
void vJoinMulticastGroup( const struct xNetworkEndPoint * pxEndPoint,
74+
const IPv6_Address_t * pxAddress );
75+
76+
/* Declare vLeaveMulticastGroup function */
77+
void vLeaveMulticastGroup( const struct xNetworkEndPoint * pxEndPoint,
78+
const IPv6_Address_t * pxAddress );
79+
7280
/* *INDENT-OFF* */
7381
#ifdef __cplusplus
7482
} /* extern "C" */

0 commit comments

Comments
 (0)