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