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