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