@@ -2966,7 +2966,9 @@ BaseType_t FreeRTOS_setsockopt( Socket_t xSocket,
29662966 case FREERTOS_SO_IP_MULTICAST_TTL :
29672967 case FREERTOS_SO_IPV6_MULTICAST_HOPS :
29682968 case FREERTOS_SO_IP_ADD_MEMBERSHIP :
2969+ case FREERTOS_SO_IPV6_ADD_MEMBERSHIP :
29692970 case FREERTOS_SO_IP_DROP_MEMBERSHIP :
2971+ case FREERTOS_SO_IPV6_DROP_MEMBERSHIP :
29702972 xReturn = prvSetMulticastSocketOption ( xSocket , lLevel , lOptionName , pvOptionValue , uxOptionLength );
29712973 break ;
29722974 #endif /* (ipconfigSUPPORT_IP_MULTICAST != 0) */
@@ -6461,15 +6463,15 @@ void * pvSocketGetSocketID( const ConstSocket_t xSocket )
64616463
64626464 case FREERTOS_SO_IP_ADD_MEMBERSHIP :
64636465 {
6466+ struct freertos_ip_mreq * pMReq = ( struct freertos_ip_mreq * ) pvOptionValue ;
6467+
64646468 if ( ( pxSocket -> ucProtocol != ( uint8_t ) FREERTOS_IPPROTO_UDP ) ||
64656469 ( uxOptionLength != sizeof ( struct freertos_ip_mreq ) ) ||
64666470 ( pxSocket -> bits .bIsIPv6 != pdFALSE ) )
64676471 {
64686472 break ; /* will return -pdFREERTOS_ERRNO_EINVAL */
64696473 }
64706474
6471- struct freertos_ip_mreq * pMReq = ( struct freertos_ip_mreq * ) pvOptionValue ;
6472-
64736475 if ( pdFALSE == xIsIPv4Multicast ( pMReq -> imr_multiaddr .s_addr ) )
64746476 {
64756477 break ; /* will return -pdFREERTOS_ERRNO_EINVAL */
@@ -6513,7 +6515,7 @@ void * pvSocketGetSocketID( const ConstSocket_t xSocket )
65136515
65146516 /* Pass the IGMP report descriptor inside the multicast group descriptor,
65156517 * so we can easily pass it to the IP task in one message. */
6516- pxMCG -> pxIGMPReportDesc = pxMRD ;
6518+ pxMCG -> pxMCastReportData = pxMRD ;
65176519
65186520 IPStackEvent_t xSockOptsEvent = { eSocketOptAddMembership , ( void * ) pxMCG };
65196521
@@ -6532,20 +6534,26 @@ void * pvSocketGetSocketID( const ConstSocket_t xSocket )
65326534
65336535 case FREERTOS_SO_IP_DROP_MEMBERSHIP :
65346536 {
6537+ struct freertos_ip_mreq * pMReq = ( struct freertos_ip_mreq * ) pvOptionValue ;
6538+
65356539 if ( ( pxSocket -> ucProtocol != ( uint8_t ) FREERTOS_IPPROTO_UDP ) ||
65366540 ( uxOptionLength != sizeof ( struct freertos_ip_mreq ) ) ||
65376541 ( pxSocket -> bits .bIsIPv6 != pdFALSE ) )
65386542 {
65396543 break ; /* will return -pdFREERTOS_ERRNO_EINVAL */
65406544 }
65416545
6542- struct freertos_ip_mreq * pMReq = ( struct freertos_ip_mreq * ) pvOptionValue ;
6543-
65446546 if ( pdFALSE == xIsIPv4Multicast ( pMReq -> imr_multiaddr .s_addr ) )
65456547 {
65466548 break ; /* will return -pdFREERTOS_ERRNO_EINVAL */
65476549 }
65486550
6551+ if ( pxSocket -> u .xUDP .xMulticastAddress .ulIP_IPv4 != pMReq -> imr_multiaddr .s_addr )
6552+ {
6553+ /* The socket was is not subscribed to this multicast group. */
6554+ break ; /* will return -pdFREERTOS_ERRNO_EINVAL */
6555+ }
6556+
65496557 /* Allocate some RAM to remember the multicast group that is being registered */
65506558 MCastGroupDesc_t * pxMCG = ( MCastGroupDesc_t * ) pvPortMalloc ( sizeof ( MCastGroupDesc_t ) );
65516559
@@ -6563,7 +6571,7 @@ void * pvSocketGetSocketID( const ConstSocket_t xSocket )
65636571 pxMCG -> pxSocket = pxSocket ;
65646572
65656573 /* When dropping memberships, we don't need an IGMP report descriptor. */
6566- pxMCG -> pxIGMPReportDesc = NULL ;
6574+ pxMCG -> pxMCastReportData = NULL ;
65676575
65686576 IPStackEvent_t xSockOptsEvent = { eSocketOptDropMembership , ( void * ) pxMCG };
65696577
@@ -6579,6 +6587,70 @@ void * pvSocketGetSocketID( const ConstSocket_t xSocket )
65796587 }
65806588 break ;
65816589
6590+ case FREERTOS_SO_IPV6_ADD_MEMBERSHIP :
6591+ {
6592+ struct freertos_ipv6_mreq * pMReq = ( struct freertos_ipv6_mreq * ) pvOptionValue ;
6593+
6594+ if ( ( pxSocket -> ucProtocol != ( uint8_t ) FREERTOS_IPPROTO_UDP ) ||
6595+ ( uxOptionLength != sizeof ( struct freertos_ipv6_mreq ) ) ||
6596+ ( pxSocket -> bits .bIsIPv6 != pdTRUE ) )
6597+ {
6598+ break ; /* will return -pdFREERTOS_ERRNO_EINVAL */
6599+ }
6600+
6601+ if ( pdFALSE == xIsIPv6AllowedMulticast ( & ( pMReq -> ipv6mr_multiaddr .s6_addr ) ) )
6602+ {
6603+ break ; /* will return -pdFREERTOS_ERRNO_EINVAL */
6604+ }
6605+
6606+ /* Allocate some RAM to remember the multicast group that is being registered */
6607+ MCastGroupDesc_t * pxMCG = ( MCastGroupDesc_t * ) pvPortMalloc ( sizeof ( MCastGroupDesc_t ) );
6608+ MCastReportData_t * pxMRD = ( MCastReportData_t * ) pvPortMalloc ( sizeof ( MCastReportData_t ) );
6609+
6610+ if ( NULL == pxMCG )
6611+ {
6612+ xReturn = - pdFREERTOS_ERRNO_ENOMEM ;
6613+ break ;
6614+ }
6615+
6616+ if ( NULL == pxMRD )
6617+ {
6618+ xReturn = - pdFREERTOS_ERRNO_ENOMEM ;
6619+ vPortFree ( pxMCG );
6620+ pxMCG = NULL ;
6621+ break ;
6622+ }
6623+
6624+ /* ToDo: .... working on it .... */
6625+ }
6626+ break ;
6627+
6628+ case FREERTOS_SO_IPV6_DROP_MEMBERSHIP :
6629+ {
6630+ struct freertos_ipv6_mreq * pMReq = ( struct freertos_ipv6_mreq * ) pvOptionValue ;
6631+
6632+ if ( ( pxSocket -> ucProtocol != ( uint8_t ) FREERTOS_IPPROTO_UDP ) ||
6633+ ( uxOptionLength != sizeof ( struct freertos_ipv6_mreq ) ) ||
6634+ ( pxSocket -> bits .bIsIPv6 != pdTRUE ) )
6635+ {
6636+ break ; /* will return -pdFREERTOS_ERRNO_EINVAL */
6637+ }
6638+
6639+ if ( pdFALSE == xIsIPv6AllowedMulticast ( & ( pMReq -> ipv6mr_multiaddr .s6_addr ) ) )
6640+ {
6641+ break ; /* will return -pdFREERTOS_ERRNO_EINVAL */
6642+ }
6643+
6644+ if ( memcmp ( pxSocket -> u .xUDP .xMulticastAddress .xIP_IPv6 .ucBytes , pMReq -> ipv6mr_multiaddr .s6_addr .ucBytes , ipSIZE_OF_IPv6_ADDRESS ) != 0 )
6645+ {
6646+ /* The socket was is not subscribed to this multicast group. */
6647+ break ; /* will return -pdFREERTOS_ERRNO_EINVAL */
6648+ }
6649+
6650+ /* ToDo: .... working on it .... */
6651+ }
6652+ break ;
6653+
65826654 default :
65836655 /* This function doesn't handle any other options. */
65846656 xReturn = - pdFREERTOS_ERRNO_ENOPROTOOPT ;
0 commit comments