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