|
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 )
|
@@ -1347,6 +1379,7 @@ void FreeRTOS_ReleaseUDPPayloadBuffer( void const * pvBuffer )
|
1347 | 1379 | pxNetworkBuffer->pucEthernetBuffer[ ipSOCKET_OPTIONS_OFFSET ] = FREERTOS_SO_UDPCKSUM_OUT;
|
1348 | 1380 | pxNetworkBuffer->xIPAddress.ulIP_IPv4 = ulIPAddress;
|
1349 | 1381 | pxNetworkBuffer->usPort = ipPACKET_CONTAINS_ICMP_DATA;
|
| 1382 | + pxNetworkBuffer->ucMaximumHops = ipconfigICMP_TIME_TO_LIVE; |
1350 | 1383 | /* xDataLength is the size of the total packet, including the Ethernet header. */
|
1351 | 1384 | pxNetworkBuffer->xDataLength = uxTotalLength;
|
1352 | 1385 |
|
@@ -2147,6 +2180,13 @@ static eFrameProcessingResult_t prvProcessIPPacket( const IPPacket_t * pxIPPacke
|
2147 | 2180 | break;
|
2148 | 2181 | #endif /* ( ipconfigUSE_IPv6 != 0 ) */
|
2149 | 2182 |
|
| 2183 | + #if ( ipconfigIS_ENABLED( ipconfigSUPPORT_IP_MULTICAST ) && ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) ) |
| 2184 | + case ipPROTOCOL_IGMP: |
| 2185 | + /* The IP packet contained an IGMP frame. */ |
| 2186 | + eReturn = eProcessIGMPPacket( pxNetworkBuffer ); |
| 2187 | + break; |
| 2188 | + #endif /* ( ipconfigIS_ENABLED( ipconfigSUPPORT_IP_MULTICAST ) && ipconfigIS_ENABLED( ipconfigUSE_IPv4 ) ) */ |
| 2189 | + |
2150 | 2190 | case ipPROTOCOL_UDP:
|
2151 | 2191 | /* The IP packet contained a UDP frame. */
|
2152 | 2192 |
|
|
0 commit comments