]> git.proxmox.com Git - mirror_edk2.git/blame - NetworkPkg/Ip6Dxe/Ip6Common.h
BaseTools/Capsule: Do not support -o with --dump-info
[mirror_edk2.git] / NetworkPkg / Ip6Dxe / Ip6Common.h
CommitLineData
a3bcde70
HT
1/** @file\r
2 Common definition and functions for IP6 driver.\r
3\r
d551cc64 4 Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
a3bcde70
HT
5\r
6 This program and the accompanying materials\r
7 are licensed and made available under the terms and conditions of the BSD License\r
8 which accompanies this distribution. The full text of the license may be found at\r
9 http://opensource.org/licenses/bsd-license.php.\r
10\r
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16#ifndef __EFI_IP6_COMMON_H__\r
17#define __EFI_IP6_COMMON_H__\r
18\r
19#define IP6_LINK_EQUAL(Mac1, Mac2) (CompareMem ((Mac1), (Mac2), sizeof (EFI_MAC_ADDRESS)) == 0)\r
20\r
21//\r
22// Convert the Microsecond to second. IP transmit/receive time is\r
23// in the unit of microsecond. IP ticks once per second.\r
24//\r
25#define IP6_US_TO_SEC(Us) (((Us) + 999999) / 1000000)\r
26\r
27#define IP6_ETHER_PROTO 0x86DD\r
28\r
29#define IP6_MAC_LEN 6\r
30#define IP6_IF_ID_LEN 8\r
31\r
32#define IP6_INTERFACE_LOCAL_SCOPE 1\r
33#define IP6_LINK_LOCAL_SCOPE 2\r
34#define IP6_SITE_LOCAL_SCOPE 5\r
35\r
36#define IP6_INFINIT_LIFETIME 0xFFFFFFFF\r
37\r
38#define IP6_HOP_LIMIT 255\r
39//\r
40// Make it to 64 since all 54 bits are zero.\r
41//\r
42#define IP6_LINK_LOCAL_PREFIX_LENGTH 64\r
43\r
44#define IP6_TIMER_INTERVAL_IN_MS 100\r
45#define IP6_ONE_SECOND_IN_MS 1000\r
46\r
47//\r
48// The packet is received as link level broadcast/multicast/promiscuous.\r
49//\r
50#define IP6_LINK_BROADCAST 0x00000001\r
51#define IP6_LINK_MULTICAST 0x00000002\r
52#define IP6_LINK_PROMISC 0x00000004\r
53\r
54#define IP6_U_BIT 0x02\r
55\r
56typedef enum {\r
57 Ip6Promiscuous = 1,\r
58 Ip6Unicast,\r
59 Ip6Multicast,\r
60 Ip6AnyCast\r
61} IP6_ADDRESS_TYPE;\r
62\r
216f7970 63typedef struct {\r
64 EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;\r
65 EFI_IPv6_ADDRESS *Address;\r
66} IP6_DESTROY_CHILD_BY_ADDR_CALLBACK_CONTEXT;\r
67\r
a3bcde70
HT
68typedef struct _IP6_INTERFACE IP6_INTERFACE;\r
69typedef struct _IP6_PROTOCOL IP6_PROTOCOL;\r
70typedef struct _IP6_SERVICE IP6_SERVICE;\r
71typedef struct _IP6_ADDRESS_INFO IP6_ADDRESS_INFO;\r
72\r
73/**\r
74 Build a array of EFI_IP6_ADDRESS_INFO to be returned to the caller. The number\r
75 of EFI_IP6_ADDRESS_INFO is also returned. If AddressList is NULL,\r
76 only the address count is returned.\r
77\r
78 @param[in] IpSb The IP6 service binding instance.\r
79 @param[out] AddressCount The number of returned addresses.\r
80 @param[out] AddressList The pointer to the array of EFI_IP6_ADDRESS_INFO.\r
81 This is an optional parameter.\r
82\r
83\r
84 @retval EFI_SUCCESS The address array is successfully build\r
85 @retval EFI_OUT_OF_RESOURCES Failed to allocate the memory for the address info.\r
86 @retval EFI_INVALID_PARAMETER Any input parameter is invalid.\r
87\r
88**/\r
89EFI_STATUS\r
90Ip6BuildEfiAddressList (\r
91 IN IP6_SERVICE *IpSb,\r
92 OUT UINT32 *AddressCount,\r
93 OUT EFI_IP6_ADDRESS_INFO **AddressList OPTIONAL\r
94 );\r
95\r
96/**\r
97 Generate the multicast addresses identify the group of all IPv6 nodes or IPv6\r
98 routers defined in RFC4291.\r
99\r
100 All Nodes Addresses: FF01::1, FF02::1.\r
101 All Router Addresses: FF01::2, FF02::2, FF05::2.\r
102\r
103 @param[in] Router If TRUE, generate all routers addresses,\r
104 else generate all node addresses.\r
105 @param[in] Scope interface-local(1), link-local(2), or site-local(5)\r
106 @param[out] Ip6Addr The generated multicast address.\r
107\r
108 @retval EFI_INVALID_PARAMETER Any input parameter is invalid.\r
109 @retval EFI_SUCCESS The address is generated.\r
110\r
111**/\r
112EFI_STATUS\r
113Ip6SetToAllNodeMulticast (\r
114 IN BOOLEAN Router,\r
115 IN UINT8 Scope,\r
116 OUT EFI_IPv6_ADDRESS *Ip6Addr\r
117 );\r
118\r
119/**\r
120 This function converts MAC address to 64 bits interface ID according to RFC4291\r
121 and returns the interface ID. Currently only 48-bit MAC address is supported by\r
122 this function.\r
123\r
124 @param[in, out] IpSb The IP6 service binding instance.\r
125\r
126 @retval NULL The operation fails.\r
127 @return Pointer to the generated interface ID.\r
128\r
129**/\r
130UINT8 *\r
131Ip6CreateInterfaceID (\r
132 IN OUT IP6_SERVICE *IpSb\r
133 );\r
134\r
135/**\r
136 This function creates link-local address from interface identifier. The\r
137 interface identifier is normally created from MAC address. It might be manually\r
138 configured by administrator if the link-local address created from MAC address\r
139 is a duplicate address.\r
140\r
141 @param[in, out] IpSb The IP6 service binding instance.\r
142\r
143 @retval NULL If the operation fails.\r
144 @return The generated Link Local address, in network order.\r
145\r
146**/\r
147EFI_IPv6_ADDRESS *\r
148Ip6CreateLinkLocalAddr (\r
149 IN OUT IP6_SERVICE *IpSb\r
150 );\r
151\r
152/**\r
153 Compute the solicited-node multicast address for an unicast or anycast address,\r
154 by taking the low-order 24 bits of this address, and appending those bits to\r
155 the prefix FF02:0:0:0:0:1:FF00::/104.\r
156\r
157 @param Ip6Addr The unicast or anycast address, in network order.\r
158 @param MulticastAddr The generated solicited-node multicast address,\r
159 in network order.\r
160\r
161**/\r
162VOID\r
163Ip6CreateSNMulticastAddr (\r
164 IN EFI_IPv6_ADDRESS *Ip6Addr,\r
165 OUT EFI_IPv6_ADDRESS *MulticastAddr\r
166 );\r
167\r
168/**\r
169 Check whether the incoming Ipv6 address is a solicited-node multicast address.\r
170\r
171 @param[in] Ip6 Ip6 address, in network order.\r
172\r
173 @retval TRUE Yes, solicited-node multicast address\r
174 @retval FALSE No\r
175\r
176**/\r
177BOOLEAN\r
178Ip6IsSNMulticastAddr (\r
179 IN EFI_IPv6_ADDRESS *Ip6\r
180 );\r
181\r
182/**\r
183 Check whether the incoming IPv6 address is one of the maintained address in\r
184 the IP6 service binding instance.\r
185\r
186 @param[in] IpSb Points to a IP6 service binding instance\r
187 @param[in] Address The IP6 address to be checked.\r
188 @param[out] Interface If not NULL, output the IP6 interface which\r
189 maintains the Address.\r
190 @param[out] AddressInfo If not NULL, output the IP6 address information\r
191 of the Address.\r
192\r
193 @retval TRUE Yes, it is one of the maintained addresses.\r
194 @retval FALSE No, it is not one of the maintained addresses.\r
195\r
196**/\r
197BOOLEAN\r
198Ip6IsOneOfSetAddress (\r
199 IN IP6_SERVICE *IpSb,\r
200 IN EFI_IPv6_ADDRESS *Address,\r
201 OUT IP6_INTERFACE **Interface OPTIONAL,\r
202 OUT IP6_ADDRESS_INFO **AddressInfo OPTIONAL\r
203 );\r
204\r
205/**\r
206 Check whether the incoming MAC address is valid.\r
207\r
208 @param[in] IpSb Points to a IP6 service binding instance.\r
209 @param[in] LinkAddress The MAC address.\r
210\r
211 @retval TRUE Yes, it is valid.\r
212 @retval FALSE No, it is not valid.\r
213\r
214**/\r
215BOOLEAN\r
216Ip6IsValidLinkAddress (\r
217 IN IP6_SERVICE *IpSb,\r
218 IN EFI_MAC_ADDRESS *LinkAddress\r
219 );\r
220\r
221\r
222/**\r
223 Copy the PrefixLength bits from Src to Dest.\r
224\r
225 @param[out] Dest A pointer to the buffer to copy to.\r
226 @param[in] Src A pointer to the buffer to copy from.\r
227 @param[in] PrefixLength The number of bits to copy.\r
228\r
229**/\r
230VOID\r
231Ip6CopyAddressByPrefix (\r
232 OUT EFI_IPv6_ADDRESS *Dest,\r
233 IN EFI_IPv6_ADDRESS *Src,\r
234 IN UINT8 PrefixLength\r
235 );\r
236\r
237/**\r
238 Insert a node IP6_ADDRESS_INFO to an IP6 interface.\r
239\r
240 @param[in, out] IpIf Points to an IP6 interface.\r
241 @param[in] AddrInfo Points to an IP6_ADDRESS_INFO.\r
242\r
243**/\r
244VOID\r
245Ip6AddAddr (\r
246 IN OUT IP6_INTERFACE *IpIf,\r
247 IN IP6_ADDRESS_INFO *AddrInfo\r
248 );\r
249\r
250/**\r
251 Remove the IPv6 address from the address list node points to IP6_ADDRESS_INFO.\r
252\r
253 This function removes the matching IPv6 addresses from the address list and\r
254 adjusts the address count of the address list. If IpSb is not NULL, this function\r
255 calls Ip6LeaveGroup to see whether it should call Mnp->Groups() to remove the\r
256 its solicited-node multicast MAC address from the filter list and sends out\r
257 a Multicast Listener Done. If Prefix is NULL, all address in the address list\r
258 will be removed. If Prefix is not NULL, the address that matching the Prefix\r
259 with PrefixLength in the address list will be removed.\r
260\r
261 @param[in] IpSb NULL or points to IP6 service binding instance.\r
262 @param[in, out] AddressList address list array\r
263 @param[in, out] AddressCount the count of addresses in address list array\r
264 @param[in] Prefix NULL or an IPv6 address prefix\r
265 @param[in] PrefixLength the length of Prefix\r
266\r
267 @retval EFI_SUCCESS The operation completed successfully.\r
268 @retval EFI_NOT_FOUND The address matching the Prefix with PrefixLength\r
269 cannot be found in address list.\r
270 @retval EFI_INVALID_PARAMETER Any input parameter is invalid.\r
271\r
272**/\r
273EFI_STATUS\r
274Ip6RemoveAddr (\r
275 IN IP6_SERVICE *IpSb OPTIONAL,\r
276 IN OUT LIST_ENTRY *AddressList,\r
277 IN OUT UINT32 *AddressCount,\r
278 IN EFI_IPv6_ADDRESS *Prefix OPTIONAL,\r
279 IN UINT8 PrefixLength\r
280 );\r
281\r
a3bcde70
HT
282/**\r
283 Get the MAC address for a multicast IP address. Call\r
284 Mnp's McastIpToMac to find the MAC address instead of\r
285 hard-coding the NIC to be Ethernet.\r
286\r
287 @param[in] Mnp The Mnp instance to get the MAC address.\r
288 @param[in] Multicast The multicast IP address to translate.\r
289 @param[out] Mac The buffer to hold the translated address.\r
290\r
291 @retval EFI_SUCCESS The multicast IP is successfully\r
292 translated to a multicast MAC address.\r
293 @retval Other The address is not converted because an error occurred.\r
294\r
295**/\r
296EFI_STATUS\r
297Ip6GetMulticastMac (\r
298 IN EFI_MANAGED_NETWORK_PROTOCOL *Mnp,\r
299 IN EFI_IPv6_ADDRESS *Multicast,\r
300 OUT EFI_MAC_ADDRESS *Mac\r
301 );\r
302\r
303/**\r
304 Convert the multibyte field in IP header's byter order.\r
305 In spite of its name, it can also be used to convert from\r
306 host to network byte order.\r
307\r
308 @param[in, out] Head The IP head to convert.\r
309\r
310 @return Point to the converted IP head.\r
311\r
312**/\r
313EFI_IP6_HEADER *\r
314Ip6NtohHead (\r
315 IN OUT EFI_IP6_HEADER *Head\r
316 );\r
317\r
318#endif\r