]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Igmp.h
Pass ECC
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Ip4Dxe / Ip4Igmp.h
CommitLineData
83cbd279 1/** @file\r
2\r
3e8c18da 3Copyright (c) 2005 - 2006, Intel Corporation.<BR>\r
83cbd279 4All rights reserved. This program and the accompanying materials\r
5are licensed and made available under the terms and conditions of the BSD License\r
6which accompanies this distribution. The full text of the license may be found at\r
7http://opensource.org/licenses/bsd-license.php\r
8\r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
11\r
83cbd279 12**/\r
13\r
14#ifndef __EFI_IP4_IGMP_H__\r
15#define __EFI_IP4_IGMP_H__\r
16\r
17#pragma pack(1)\r
18typedef struct {\r
19 UINT8 Type;\r
20 UINT8 MaxRespTime;\r
21 UINT16 Checksum;\r
22 IP4_ADDR Group;\r
23} IGMP_HEAD;\r
24#pragma pack()\r
25\r
96e1079f 26///\r
27/// The status of multicast group. It isn't necessary to maintain\r
28/// explicit state of host state diagram. A group with non-zero\r
29/// DelayTime is in "delaying member" state. otherwise, it is in\r
30/// "idle member" state.\r
31///\r
83cbd279 32typedef struct {\r
e48e37fc 33 LIST_ENTRY Link;\r
83cbd279 34 INTN RefCnt;\r
35 IP4_ADDR Address;\r
36 INTN DelayTime;\r
37 BOOLEAN ReportByUs;\r
38 EFI_MAC_ADDRESS Mac;\r
39} IGMP_GROUP;\r
40\r
96e1079f 41///\r
42/// The IGMP status. Each IP4 service instance has a IGMP_SERVICE_DATA\r
43/// attached. The Igmpv1QuerySeen remember whether the server on this\r
44/// connected network is v1 or v2.\r
45///\r
83cbd279 46typedef struct {\r
47 INTN Igmpv1QuerySeen;\r
e48e37fc 48 LIST_ENTRY Groups;\r
83cbd279 49} IGMP_SERVICE_DATA;\r
50\r
5405e9a6 51typedef enum {\r
83cbd279 52 //\r
53 // IGMP message type\r
54 //\r
55 IGMP_MEMBERSHIP_QUERY = 0x11,\r
56 IGMP_V1_MEMBERSHIP_REPORT = 0x12,\r
57 IGMP_V2_MEMBERSHIP_REPORT = 0x16,\r
58 IGMP_LEAVE_GROUP = 0x17,\r
59\r
60 IGMP_V1ROUTER_PRESENT = 400,\r
61 IGMP_UNSOLICIATED_REPORT = 10\r
5405e9a6 62} IGMP_ENUM_TYPES;\r
83cbd279 63\r
2ff29212 64/**\r
65 Init the IGMP control data of the IP4 service instance, configure\r
66 MNP to receive ALL SYSTEM multicast.\r
67\r
3e8c18da 68 @param[in, out] IpSb The IP4 service whose IGMP is to be initialized.\r
2ff29212 69\r
70 @retval EFI_SUCCESS IGMP of the IpSb is successfully initialized.\r
71 @retval EFI_OUT_OF_RESOURCES Failed to allocate resource to initialize IGMP.\r
72 @retval Others Failed to initialize the IGMP of IpSb.\r
73\r
74**/\r
83cbd279 75EFI_STATUS\r
76Ip4InitIgmp (\r
2ff29212 77 IN OUT IP4_SERVICE *IpSb\r
83cbd279 78 );\r
79\r
2ff29212 80/**\r
81 Join the multicast group on behalf of this IP4 child\r
82\r
3e8c18da 83 @param[in] IpInstance The IP4 child that wants to join the group\r
84 @param[in] Address The group to join\r
2ff29212 85\r
86 @retval EFI_SUCCESS Successfully join the multicast group\r
87 @retval EFI_OUT_OF_RESOURCES Failed to allocate resources\r
88 @retval Others Failed to join the multicast group.\r
89\r
90**/\r
83cbd279 91EFI_STATUS\r
92Ip4JoinGroup (\r
2ff29212 93 IN IP4_PROTOCOL *IpInstance,\r
94 IN IP4_ADDR Address\r
83cbd279 95 );\r
96\r
2ff29212 97/**\r
98 Leave the IP4 multicast group on behalf of IpInstance.\r
99\r
3e8c18da 100 @param[in] IpInstance The IP4 child that wants to leave the group\r
2ff29212 101 address\r
3e8c18da 102 @param[in] Address The group address to leave\r
2ff29212 103\r
104 @retval EFI_NOT_FOUND The IP4 service instance isn't in the group\r
105 @retval EFI_SUCCESS Successfully leave the multicast group.\r
106 @retval Others Failed to leave the multicast group.\r
107\r
108**/\r
83cbd279 109EFI_STATUS\r
110Ip4LeaveGroup (\r
2ff29212 111 IN IP4_PROTOCOL *IpInstance,\r
112 IN IP4_ADDR Address\r
83cbd279 113 );\r
114\r
2ff29212 115/**\r
116 Handle the received IGMP message for the IP4 service instance.\r
117\r
3e8c18da 118 @param[in] IpSb The IP4 service instance that received the message\r
119 @param[in] Head The IP4 header of the received message\r
120 @param[in] Packet The IGMP message, without IP4 header\r
2ff29212 121\r
122 @retval EFI_INVALID_PARAMETER The IGMP message is malformated.\r
123 @retval EFI_SUCCESS The IGMP message is successfully processed.\r
124\r
125**/\r
83cbd279 126EFI_STATUS\r
127Ip4IgmpHandle (\r
2ff29212 128 IN IP4_SERVICE *IpSb,\r
129 IN IP4_HEAD *Head,\r
130 IN NET_BUF *Packet\r
83cbd279 131 );\r
132\r
2ff29212 133/**\r
134 The periodical timer function for IGMP. It does the following\r
135 things:\r
136 1. Decrease the Igmpv1QuerySeen to make it possible to refresh\r
137 the IGMP server type.\r
138 2. Decrease the report timer for each IGMP group in "delaying\r
139 member" state.\r
140\r
3e8c18da 141 @param[in] IpSb The IP4 service instance that is ticking\r
2ff29212 142\r
143**/\r
83cbd279 144VOID\r
145Ip4IgmpTicking (\r
2ff29212 146 IN IP4_SERVICE *IpSb\r
83cbd279 147 );\r
148\r
2ff29212 149/**\r
150 Add a group address to the array of group addresses.\r
151 The caller should make sure that no duplicated address\r
152 existed in the array. Although the function doesn't\r
153 assume the byte order of the both Source and Addr, the\r
154 network byte order is used by the caller.\r
155\r
3e8c18da 156 @param[in] Source The array of group addresses to add to\r
157 @param[in] Count The number of group addresses in the Source\r
158 @param[in] Addr The IP4 multicast address to add\r
2ff29212 159\r
160 @return NULL if failed to allocate memory for the new groups,\r
161 otherwise the new combined group addresses.\r
162\r
163**/\r
83cbd279 164IP4_ADDR *\r
165Ip4CombineGroups (\r
2ff29212 166 IN IP4_ADDR *Source,\r
167 IN UINT32 Count,\r
168 IN IP4_ADDR Addr\r
83cbd279 169 );\r
170\r
2ff29212 171/**\r
172 Remove a group address from the array of group addresses.\r
173 Although the function doesn't assume the byte order of the\r
174 both Groups and Addr, the network byte order is used by\r
175 the caller.\r
176\r
3e8c18da 177 @param Groups The array of group addresses to remove from\r
178 @param Count The number of group addresses in the Groups\r
179 @param Addr The IP4 multicast address to remove\r
2ff29212 180\r
181 @return The nubmer of group addresses in the Groups after remove.\r
182 It is Count if the Addr isn't in the Groups.\r
183\r
184**/\r
83cbd279 185INTN\r
186Ip4RemoveGroupAddr (\r
2ff29212 187 IN OUT IP4_ADDR *Groups,\r
188 IN UINT32 Count,\r
189 IN IP4_ADDR Addr\r
83cbd279 190 );\r
191\r
2ff29212 192/**\r
193 Find the IGMP_GROUP structure which contains the status of multicast\r
194 group Address in this IGMP control block\r
195\r
3e8c18da 196 @param[in] IgmpCtrl The IGMP control block to search from\r
197 @param[in] Address The multicast address to search\r
2ff29212 198\r
199 @return NULL if the multicast address isn't in the IGMP control block. Otherwise\r
200 the point to the IGMP_GROUP which contains the status of multicast group\r
201 for Address.\r
202\r
203**/\r
83cbd279 204IGMP_GROUP *\r
205Ip4FindGroup (\r
2ff29212 206 IN IGMP_SERVICE_DATA *IgmpCtrl,\r
207 IN IP4_ADDR Address\r
83cbd279 208 );\r
209#endif\r