|
59 | 59 | #include "NetworkBufferManagement.h"
|
60 | 60 | #include "FreeRTOS_DNS.h"
|
61 | 61 | #include "FreeRTOS_Routing.h"
|
| 62 | +#if ( ipconfigIS_ENABLED( ipconfigSUPPORT_IP_MULTICAST ) ) |
| 63 | + #include "FreeRTOS_IGMP.h" |
| 64 | +#endif /* ipconfigIS_ENABLED( ipconfigSUPPORT_IP_MULTICAST ) */ |
62 | 65 |
|
63 | 66 | /** @brief Time delay between repeated attempts to initialise the network hardware. */
|
64 | 67 | #ifndef ipINITIALISATION_RETRY_DELAY
|
@@ -477,6 +480,20 @@ static void prvProcessIPEventsAndTimers( void )
|
477 | 480 | /* xQueueReceive() returned because of a normal time-out. */
|
478 | 481 | break;
|
479 | 482 |
|
| 483 | + #if ( ipconfigIS_ENABLED( ipconfigSUPPORT_IP_MULTICAST ) ) |
| 484 | + case eSocketOptAddMembership: |
| 485 | + case eSocketOptDropMembership: |
| 486 | + { |
| 487 | + MulticastAction_t * pxMCA = ( MulticastAction_t * ) xReceivedEvent.pvData; |
| 488 | + vModifyMulticastMembership( pxMCA, xReceivedEvent.eEventType ); |
| 489 | + break; |
| 490 | + } |
| 491 | + |
| 492 | + case eMulticastTimerEvent: |
| 493 | + vIPMulticast_HandleTimerEvent(); |
| 494 | + break; |
| 495 | + #endif /* ipconfigIS_ENABLED( ipconfigSUPPORT_IP_MULTICAST ) */ |
| 496 | + |
480 | 497 | default:
|
481 | 498 | /* Should not get here. */
|
482 | 499 | break;
|
@@ -543,6 +560,11 @@ static void prvIPTask_Initialise( void )
|
543 | 560 | }
|
544 | 561 | #endif /* ( ( ipconfigUSE_DNS_CACHE != 0 ) && ( ipconfigUSE_DNS != 0 ) ) */
|
545 | 562 |
|
| 563 | + #if ( ipconfigIS_ENABLED( ipconfigSUPPORT_IP_MULTICAST ) ) |
| 564 | + /* Init the list that will hold scheduled IGMP reports. */ |
| 565 | + ( void ) vIPMulticast_Init(); |
| 566 | + #endif /* ipconfigIS_ENABLED( ipconfigSUPPORT_IP_MULTICAST ) */ |
| 567 | + |
546 | 568 | /* Initialisation is complete and events can now be processed. */
|
547 | 569 | xIPTaskInitialised = pdTRUE;
|
548 | 570 | }
|
@@ -656,6 +678,16 @@ void vIPNetworkUpCalls( struct xNetworkEndPoint * pxEndPoint )
|
656 | 678 | #endif
|
657 | 679 | }
|
658 | 680 |
|
| 681 | + #if ( ipconfigIS_ENABLED( ipconfigSUPPORT_IP_MULTICAST ) ) |
| 682 | + |
| 683 | + /* Reschedule all multicast reports associated with this end-point. |
| 684 | + * Note: countdown is in increments of ipIGMP_TIMER_PERIOD_MS. It's a good idea to spread out all reports a little. |
| 685 | + * 200 to 500ms ( xMaxCountdown of 2 - 5 ) should be a good happy medium. If the network we just connected to has a IGMP/MLD querier, |
| 686 | + * they will soon ask us for reports anyways, so sending these unsolicited reports is not required. It simply enhances the user |
| 687 | + * experience by shortening the time it takes before we begin receiving the multicasts that we care for. */ |
| 688 | + vRescheduleAllMulticastReports( pxEndPoint->pxNetworkInterface, 5 ); |
| 689 | + #endif /* ipconfigIS_ENABLED( ipconfigSUPPORT_IP_MULTICAST ) */ |
| 690 | + |
659 | 691 | pxEndPoint->bits.bEndPointUp = pdTRUE_UNSIGNED;
|
660 | 692 |
|
661 | 693 | #if ( ipconfigUSE_NETWORK_EVENT_HOOK == 1 )
|
@@ -1356,6 +1388,7 @@ void FreeRTOS_ReleaseUDPPayloadBuffer( void const * pvBuffer )
|
1356 | 1388 | pxNetworkBuffer->pucEthernetBuffer[ ipSOCKET_OPTIONS_OFFSET ] = FREERTOS_SO_UDPCKSUM_OUT;
|
1357 | 1389 | pxNetworkBuffer->xIPAddress.ulIP_IPv4 = ulIPAddress;
|
1358 | 1390 | pxNetworkBuffer->usPort = ipPACKET_CONTAINS_ICMP_DATA;
|
| 1391 | + pxNetworkBuffer->ucMaximumHops = ipconfigICMP_TIME_TO_LIVE; |
1359 | 1392 | /* xDataLength is the size of the total packet, including the Ethernet header. */
|
1360 | 1393 | pxNetworkBuffer->xDataLength = uxTotalLength;
|
1361 | 1394 |
|
@@ -2156,6 +2189,13 @@ static eFrameProcessingResult_t prvProcessIPPacket( const IPPacket_t * pxIPPacke
|
2156 | 2189 | break;
|
2157 | 2190 | #endif /* ( ipconfigUSE_IPv6 != 0 ) */
|
2158 | 2191 |
|
| 2192 | + #if ( ipconfigIS_ENABLED( ipconfigSUPPORT_IP_MULTICAST ) && ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) ) |
| 2193 | + case ipPROTOCOL_IGMP: |
| 2194 | + /* The IP packet contained an IGMP frame. */ |
| 2195 | + eReturn = eProcessIGMPPacket( pxNetworkBuffer ); |
| 2196 | + break; |
| 2197 | + #endif /* ( ipconfigIS_ENABLED( ipconfigSUPPORT_IP_MULTICAST ) && ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) ) */ |
| 2198 | + |
2159 | 2199 | case ipPROTOCOL_UDP:
|
2160 | 2200 | /* The IP packet contained a UDP frame. */
|
2161 | 2201 |
|
|
0 commit comments