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