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 23 /**************************************************************************/ 24 /* */ 25 /* COMPONENT DEFINITION RELEASE */ 26 /* */ 27 /* nx_igmp.h PORTABLE C */ 28 /* 6.1.9 */ 29 /* AUTHOR */ 30 /* */ 31 /* Yuxin Zhou, Microsoft Corporation */ 32 /* */ 33 /* DESCRIPTION */ 34 /* */ 35 /* This file defines the NetX Internet Group Management Protocol (IGMP)*/ 36 /* component, including all data types and external references. It is */ 37 /* assumed that nx_api.h and nx_port.h have already been included. */ 38 /* */ 39 /* RELEASE HISTORY */ 40 /* */ 41 /* DATE NAME DESCRIPTION */ 42 /* */ 43 /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ 44 /* 09-30-2020 Yuxin Zhou Modified comment(s), */ 45 /* resulting in version 6.1 */ 46 /* 10-15-2021 Yuxin Zhou Modified comment(s), included */ 47 /* necessary header file, */ 48 /* resulting in version 6.1.9 */ 49 /* */ 50 /**************************************************************************/ 51 52 #ifndef NX_IGMP_H 53 #define NX_IGMP_H 54 55 #include "nx_api.h" 56 57 58 #ifndef NX_DISABLE_IPV4 59 /* Define IGMP types and codes. */ 60 61 /* IGMPv2 combines version field with the type field ffectively, and calls the 8 bit 62 field the Type field. IGMPv2 uses Type 0x11, 0x16, and 0x17 in this field, while 63 IGMPv1 uses Type 1 and 2 in the lower 4 bits, combined with version 1 in the upper 4 bits 64 for 0x11 and 0x12 as the possible values. */ 65 66 67 /* Define the IGMP version in the IGMP header. */ 68 69 #define NX_IGMP_VERSION 0x10000000 70 71 72 /* Define the numeric version of IGMP protocol used by NetX. */ 73 74 #define NX_IGMP_HOST_VERSION_1 1 75 #define NX_IGMP_HOST_VERSION_2 2 76 77 78 /* Define the IGMP query message type and mask in the IGMP header. */ 79 80 #define NX_IGMP_ROUTER_QUERY_TYPE 0x01000000 81 #define NX_IGMP_TYPE_MASK 0x0F000000 82 83 84 /* Define the IGMPv1 type for membership join reports. */ 85 86 #define NX_IGMP_HOST_RESPONSE_TYPE 0x02000000 87 88 89 /* Define IGMPv2 types for membership join and leave reports. */ 90 91 #define NX_IGMP_HOST_V2_JOIN_TYPE 0x16000000 92 #define NX_IGMP_HOST_V2_LEAVE_TYPE 0x17000000 93 94 95 /* Define the IGMPv2 type mask in the IGMP header. */ 96 97 #define NX_IGMPV2_TYPE_MASK 0xFF000000 98 99 100 /* Define the IGMPv2 maximum response time mask in the IGMP header. Max value is 0x64, 101 left intentionally blank in IGMPv1 queries and all IGMP reports. Maximum response time 102 is in tenth's of a second. */ 103 104 #define NX_IGMP_MAX_RESP_TIME_MASK 0x00FF0000 105 106 107 /* For IGMPv1 only, define the IGMP maximum delay time to 10 seconds as per RFC 1112. This is achieved if 108 the slow NetX IP periodic thread timer executes every second (e.g. NX_IP_PERIODIC_RATE is set to 100) 109 and the threadx timer interrupt occurs every 10 ms). */ 110 111 #define NX_IGMP_MAX_UPDATE_TIME 10 112 113 114 /* Define the time to live for IGMP packets. RFC 1112 and 2236 specify 115 time to live should be set at 1. */ 116 117 #define NX_IGMP_TTL 1 118 119 120 /* Define the IP "all hosts" multicast address. */ 121 122 #define NX_ALL_HOSTS_ADDRESS IP_ADDRESS(224, 0, 0, 1) 123 124 125 /* Define the IP "all routers" multicast address. */ 126 127 #define NX_ALL_ROUTERS_ADDRESS IP_ADDRESS(224, 0, 0, 2) 128 129 130 /* Define Basic IGMP packet header data type. This will be used to 131 build new IGMP packets and to examine incoming IGMP queries sent 132 to NetX. */ 133 134 typedef struct NX_IGMP_HEADER_STRUCT 135 { 136 /* Define the first 32-bit word of the IGMP header. This word contains 137 the following information: 138 139 bits 31-28 IGMP 4-bit version (Version 1) 140 141 bits 27-24 IGMP 4-bit type defined as follows: 142 143 Type Field IGMP Message Type 144 145 1 Router Query Request 146 2 Host Query Response 147 148 bits 15-0 IGMP 16-bit checksum 149 150 */ 151 152 ULONG nx_igmp_header_word_0; 153 154 /* Define the second and final word of the IGMP header. This word contains 155 the following information: 156 157 bits 31-0 32-bit group address (class D IP address) 158 */ 159 ULONG nx_igmp_header_word_1; 160 } NX_IGMP_HEADER; 161 162 163 /* Define the IGMP query response message size. */ 164 165 #define NX_IGMP_HEADER_SIZE sizeof(NX_IGMP_HEADER) 166 167 168 169 /* Define IGMP internal function prototypes. */ 170 UINT _nx_igmp_multicast_interface_join_internal(NX_IP *ip_ptr, ULONG group_address, UINT interface_index, UINT update_time); 171 UINT _nx_igmp_multicast_interface_leave_internal(NX_IP *ip_ptr, ULONG group_address, UINT interface_index); 172 UINT _nx_igmp_interface_report_send(NX_IP *ip_ptr, ULONG group_address, UINT interface_index, UINT is_joining); 173 VOID _nx_igmp_periodic_processing(NX_IP *ip_ptr); 174 VOID _nx_igmp_packet_process(NX_IP *ip_ptr, NX_PACKET *packet_ptr); 175 VOID _nx_igmp_packet_receive(NX_IP *ip_ptr, NX_PACKET *packet_ptr); 176 VOID _nx_igmp_queue_process(NX_IP *ip_ptr); 177 UINT _nx_igmp_multicast_check(NX_IP *ip_ptr, ULONG group_address, NX_INTERFACE *nx_interface); 178 #endif /* NX_DISABLE_IPV4 */ 179 180 181 /* Define IGMP function prototypes. */ 182 183 UINT _nx_igmp_enable(NX_IP *ip_ptr); 184 UINT _nx_igmp_info_get(NX_IP *ip_ptr, ULONG *igmp_reports_sent, ULONG *igmp_queries_received, 185 ULONG *igmp_checksum_errors, ULONG *current_groups_joined); 186 UINT _nx_igmp_loopback_disable(NX_IP *ip_ptr); 187 UINT _nx_igmp_loopback_enable(NX_IP *ip_ptr); 188 UINT _nx_igmp_multicast_join(NX_IP *ip_ptr, ULONG group_address); 189 UINT _nx_igmp_multicast_interface_join(NX_IP *ip_ptr, ULONG group_address, UINT interface_index); 190 UINT _nx_igmp_multicast_leave(NX_IP *ip_ptr, ULONG group_address); 191 UINT _nx_igmp_multicast_interface_leave(NX_IP *ip_ptr, ULONG group_address, UINT interface_index); 192 193 /* Define error checking shells for API services. These are only referenced by the 194 application. */ 195 196 UINT _nxe_igmp_enable(NX_IP *ip_ptr); 197 UINT _nxe_igmp_info_get(NX_IP *ip_ptr, ULONG *igmp_reports_sent, ULONG *igmp_queries_received, 198 ULONG *igmp_checksum_errors, ULONG *current_groups_joined); 199 UINT _nxe_igmp_loopback_disable(NX_IP *ip_ptr); 200 UINT _nxe_igmp_loopback_enable(NX_IP *ip_ptr); 201 UINT _nxe_igmp_multicast_join(NX_IP *ip_ptr, ULONG group_address); 202 UINT _nxe_igmp_multicast_interface_join(NX_IP *ip_ptr, ULONG group_address, UINT interface_index); 203 UINT _nxe_igmp_multicast_leave(NX_IP *ip_ptr, ULONG group_address); 204 UINT _nxe_igmp_multicast_interface_leave(NX_IP *ip_ptr, ULONG group_address, UINT interface_index); 205 206 207 #endif 208 209