1 /*************************************************************************** 2 * Copyright (c) 2024 Microsoft Corporation 3 * 4 * This program and the accompanying materials are made available under the 5 * terms of the MIT License which is available at 6 * https://opensource.org/licenses/MIT. 7 * 8 * SPDX-License-Identifier: MIT 9 **************************************************************************/ 10 11 12 /**************************************************************************/ 13 /**************************************************************************/ 14 /** */ 15 /** NetX Component */ 16 /** */ 17 /** Internet Group Management Protocol (IGMP) */ 18 /** */ 19 /**************************************************************************/ 20 /**************************************************************************/ 21 22 #define NX_SOURCE_CODE 23 24 25 /* Include necessary system files. */ 26 27 #include "nx_api.h" 28 #include "nx_igmp.h" 29 30 #ifndef NX_DISABLE_IPV4 31 /**************************************************************************/ 32 /* */ 33 /* FUNCTION RELEASE */ 34 /* */ 35 /* _nx_igmp_periodic_processing PORTABLE C */ 36 /* 6.1 */ 37 /* AUTHOR */ 38 /* */ 39 /* Yuxin Zhou, Microsoft Corporation */ 40 /* */ 41 /* DESCRIPTION */ 42 /* */ 43 /* This function handles the sending of periodic processing of IGMP */ 44 /* join report messages. */ 45 /* */ 46 /* INPUT */ 47 /* */ 48 /* ip_ptr IP instance pointer */ 49 /* */ 50 /* OUTPUT */ 51 /* */ 52 /* None */ 53 /* */ 54 /* CALLS */ 55 /* */ 56 /* nx_igmp_interface_report_send Send IGMP group report */ 57 /* */ 58 /* CALLED BY */ 59 /* */ 60 /* _nx_ip_thread_entry IP helper thread */ 61 /* */ 62 /* RELEASE HISTORY */ 63 /* */ 64 /* DATE NAME DESCRIPTION */ 65 /* */ 66 /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ 67 /* 09-30-2020 Yuxin Zhou Modified comment(s), */ 68 /* resulting in version 6.1 */ 69 /* */ 70 /**************************************************************************/ _nx_igmp_periodic_processing(NX_IP * ip_ptr)71VOID _nx_igmp_periodic_processing(NX_IP *ip_ptr) 72 { 73 74 UINT i; 75 UINT status; 76 UINT sent_count = 0; 77 NX_INTERFACE *interface_ptr; 78 UINT interface_index; 79 80 81 /* Search the multicast join list for pending IGMP responses. */ 82 for (i = 0; i < NX_MAX_MULTICAST_GROUPS; i++) 83 { 84 85 /* Determine if the specified entry is active. */ 86 if (ip_ptr -> nx_ipv4_multicast_entry[i].nx_ipv4_multicast_join_list) 87 { 88 89 /* Now determine if a response is pending. */ 90 if ((ip_ptr -> nx_ipv4_multicast_entry[i].nx_ipv4_multicast_update_time > 0) && 91 (ip_ptr -> nx_ipv4_multicast_entry[i].nx_ipv4_multicast_update_time != NX_WAIT_FOREVER)) 92 { 93 94 /* Yes, it is active. Decrement and check for expiration. */ 95 ip_ptr -> nx_ipv4_multicast_entry[i].nx_ipv4_multicast_update_time--; 96 97 /* We don't want to decrement a join group if we cannot send it. Check 98 if we've already sent a packet on this periodic. */ 99 if ((ip_ptr -> nx_ipv4_multicast_entry[i].nx_ipv4_multicast_update_time == 0) && (sent_count > 0)) 100 { 101 102 /* Restore the timeout to 1 second because we cannot send on this periodic; we've already sent out a packet. */ 103 ip_ptr -> nx_ipv4_multicast_entry[i].nx_ipv4_multicast_update_time = 1; 104 } 105 106 /* Has time expired and have we not sent an IGMP report in this period? */ 107 if (ip_ptr -> nx_ipv4_multicast_entry[i].nx_ipv4_multicast_update_time == 0) 108 { 109 110 /* Yes, time has expired and we have not yet sent a packet out on this periodic. */ 111 112 /* Build and send the join report packet. */ 113 interface_ptr = ip_ptr -> nx_ipv4_multicast_entry[i].nx_ipv4_multicast_join_interface_list; 114 115 interface_index = (UINT)interface_ptr -> nx_interface_index; 116 117 /* Build a IGMP host response packet for a join report and send it! */ 118 status = _nx_igmp_interface_report_send(ip_ptr, ip_ptr -> nx_ipv4_multicast_entry[i].nx_ipv4_multicast_join_list, 119 interface_index, NX_TRUE); 120 121 if (status == NX_SUCCESS) 122 { 123 124 /* Update the sent count. Only one report sent per IP periodic. */ 125 sent_count++; 126 } 127 } 128 } 129 } 130 } 131 } 132 #endif /* !NX_DISABLE_IPV4 */ 133 134