|
59 | 59 | #include "FreeRTOS_DNS.h"
|
60 | 60 | #include "FreeRTOS_Routing.h"
|
61 | 61 | #include "FreeRTOS_ND.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
|
@@ -452,6 +455,20 @@ static void prvProcessIPEventsAndTimers( void )
|
452 | 455 | /* xQueueReceive() returned because of a normal time-out. */
|
453 | 456 | break;
|
454 | 457 |
|
| 458 | + #if ( ipconfigIS_ENABLED( ipconfigSUPPORT_IP_MULTICAST ) ) |
| 459 | + case eSocketOptAddMembership: |
| 460 | + case eSocketOptDropMembership: |
| 461 | + { |
| 462 | + MulticastAction_t * pxMCA = ( MulticastAction_t * ) xReceivedEvent.pvData; |
| 463 | + vModifyMulticastMembership( pxMCA, xReceivedEvent.eEventType ); |
| 464 | + break; |
| 465 | + } |
| 466 | + |
| 467 | + case eMulticastTimerEvent: |
| 468 | + vIPMulticast_HandleTimerEvent(); |
| 469 | + break; |
| 470 | + #endif /* ipconfigIS_ENABLED( ipconfigSUPPORT_IP_MULTICAST ) */ |
| 471 | + |
455 | 472 | default:
|
456 | 473 | /* Should not get here. */
|
457 | 474 | break;
|
@@ -511,6 +528,11 @@ static void prvIPTask_Initialise( void )
|
511 | 528 | }
|
512 | 529 | #endif /* ( ( ipconfigUSE_DNS_CACHE != 0 ) && ( ipconfigUSE_DNS != 0 ) ) */
|
513 | 530 |
|
| 531 | + #if ( ipconfigIS_ENABLED( ipconfigSUPPORT_IP_MULTICAST ) ) |
| 532 | + /* Init the list that will hold scheduled IGMP reports. */ |
| 533 | + ( void ) vIPMulticast_Init(); |
| 534 | + #endif /* ipconfigIS_ENABLED( ipconfigSUPPORT_IP_MULTICAST ) */ |
| 535 | + |
514 | 536 | /* Initialisation is complete and events can now be processed. */
|
515 | 537 | xIPTaskInitialised = pdTRUE;
|
516 | 538 | }
|
@@ -624,6 +646,16 @@ void vIPNetworkUpCalls( struct xNetworkEndPoint * pxEndPoint )
|
624 | 646 | #endif
|
625 | 647 | }
|
626 | 648 |
|
| 649 | + #if ( ipconfigIS_ENABLED( ipconfigSUPPORT_IP_MULTICAST ) ) |
| 650 | + |
| 651 | + /* Reschedule all multicast reports associated with this end-point. |
| 652 | + * Note: countdown is in increments of ipIGMP_TIMER_PERIOD_MS. It's a good idea to spread out all reports a little. |
| 653 | + * 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, |
| 654 | + * they will soon ask us for reports anyways, so sending these unsolicited reports is not required. It simply enhances the user |
| 655 | + * experience by shortening the time it takes before we begin receiving the multicasts that we care for. */ |
| 656 | + vRescheduleAllMulticastReports( pxEndPoint->pxNetworkInterface, 5 ); |
| 657 | + #endif /* ipconfigIS_ENABLED( ipconfigSUPPORT_IP_MULTICAST ) */ |
| 658 | + |
627 | 659 | pxEndPoint->bits.bEndPointUp = pdTRUE_UNSIGNED;
|
628 | 660 |
|
629 | 661 | #if ( ipconfigUSE_NETWORK_EVENT_HOOK == 1 )
|
@@ -1313,6 +1345,7 @@ void FreeRTOS_ReleaseUDPPayloadBuffer( void const * pvBuffer )
|
1313 | 1345 | pxNetworkBuffer->pucEthernetBuffer[ ipSOCKET_OPTIONS_OFFSET ] = FREERTOS_SO_UDPCKSUM_OUT;
|
1314 | 1346 | pxNetworkBuffer->xIPAddress.ulIP_IPv4 = ulIPAddress;
|
1315 | 1347 | pxNetworkBuffer->usPort = ipPACKET_CONTAINS_ICMP_DATA;
|
| 1348 | + pxNetworkBuffer->ucMaximumHops = ipconfigICMP_TIME_TO_LIVE; |
1316 | 1349 | /* xDataLength is the size of the total packet, including the Ethernet header. */
|
1317 | 1350 | pxNetworkBuffer->xDataLength = uxTotalLength;
|
1318 | 1351 |
|
@@ -2080,6 +2113,13 @@ static eFrameProcessingResult_t prvProcessIPPacket( const IPPacket_t * pxIPPacke
|
2080 | 2113 | break;
|
2081 | 2114 | #endif /* ( ipconfigUSE_IPv6 != 0 ) */
|
2082 | 2115 |
|
| 2116 | + #if ( ipconfigIS_ENABLED( ipconfigSUPPORT_IP_MULTICAST ) && ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) ) |
| 2117 | + case ipPROTOCOL_IGMP: |
| 2118 | + /* The IP packet contained an IGMP frame. */ |
| 2119 | + eReturn = eProcessIGMPPacket( pxNetworkBuffer ); |
| 2120 | + break; |
| 2121 | + #endif /* ( ipconfigIS_ENABLED( ipconfigSUPPORT_IP_MULTICAST ) && ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) ) */ |
| 2122 | + |
2083 | 2123 | case ipPROTOCOL_UDP:
|
2084 | 2124 | /* The IP packet contained a UDP frame. */
|
2085 | 2125 |
|
|
0 commit comments