]> git.proxmox.com Git - mirror_edk2.git/blob - NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.h
NetworkPkg: Refine codes related to Dhcpv4 and Dhcpv6 configuration.
[mirror_edk2.git] / NetworkPkg / UefiPxeBcDxe / PxeBcDhcp6.h
1 /** @file
2 Functions declaration related with DHCPv6 for UefiPxeBc Driver.
3
4 Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
5
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php.
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15
16 #ifndef __EFI_PXEBC_DHCP6_H__
17 #define __EFI_PXEBC_DHCP6_H__
18
19 #define PXEBC_DHCP6_OPTION_MAX_NUM 16
20 #define PXEBC_DHCP6_OPTION_MAX_SIZE 312
21 #define PXEBC_DHCP6_PACKET_MAX_SIZE 1472
22 #define PXEBC_IP6_POLICY_MAX 0xff
23 #define PXEBC_IP6_ROUTE_TABLE_TIMEOUT 10
24
25 #define PXEBC_DHCP6_S_PORT 547
26 #define PXEBC_DHCP6_C_PORT 546
27
28 #define PXEBC_DHCP6_ENTERPRISE_NUM 343 // TODO: IANA TBD: temporarily using Intel's
29 #define PXEBC_DHCP6_MAX_BOOT_FILE_SIZE 65535 // It's a limitation of bit length, 65535*512 bytes.
30
31
32 #define PXEBC_DHCP6_IDX_IA_NA 0
33 #define PXEBC_DHCP6_IDX_BOOT_FILE_URL 1
34 #define PXEBC_DHCP6_IDX_BOOT_FILE_PARAM 2
35 #define PXEBC_DHCP6_IDX_VENDOR_CLASS 3
36 #define PXEBC_DHCP6_IDX_MAX 4
37
38 #define PXEBC_DHCP6_BOOT_FILE_URL_PREFIX "tftp://"
39 #define PXEBC_TFTP_URL_SEPARATOR '/'
40 #define PXEBC_ADDR_START_DELIMITER '['
41 #define PXEBC_ADDR_END_DELIMITER ']'
42
43 #define GET_NEXT_DHCP6_OPTION(Opt) \
44 (EFI_DHCP6_PACKET_OPTION *) ((UINT8 *) (Opt) + \
45 sizeof (EFI_DHCP6_PACKET_OPTION) + (NTOHS ((Opt)->OpLen)) - 1)
46
47 #define GET_DHCP6_OPTION_SIZE(Pkt) \
48 ((Pkt)->Length - sizeof (EFI_DHCP6_HEADER))
49
50 #define IS_PROXY_OFFER(Type) \
51 ((Type) == PxeOfferTypeProxyBinl || \
52 (Type) == PxeOfferTypeProxyPxe10 || \
53 (Type) == PxeOfferTypeProxyWfm11a)
54
55
56 #pragma pack(1)
57 typedef struct {
58 UINT16 OpCode[256];
59 } PXEBC_DHCP6_OPTION_ORO;
60
61 typedef struct {
62 UINT8 Type;
63 UINT8 MajorVer;
64 UINT8 MinorVer;
65 } PXEBC_DHCP6_OPTION_UNDI;
66
67 typedef struct {
68 UINT16 Type;
69 } PXEBC_DHCP6_OPTION_ARCH;
70
71 typedef struct {
72 UINT8 ClassIdentifier[10];
73 UINT8 ArchitecturePrefix[5];
74 UINT8 ArchitectureType[5];
75 UINT8 Lit3[1];
76 UINT8 InterfaceName[4];
77 UINT8 Lit4[1];
78 UINT8 UndiMajor[3];
79 UINT8 UndiMinor[3];
80 } PXEBC_CLASS_ID;
81
82 typedef struct {
83 UINT32 Vendor;
84 UINT16 ClassLen;
85 PXEBC_CLASS_ID ClassId;
86 } PXEBC_DHCP6_OPTION_VENDOR_CLASS;
87
88 #pragma pack()
89
90 typedef union {
91 PXEBC_DHCP6_OPTION_ORO *Oro;
92 PXEBC_DHCP6_OPTION_UNDI *Undi;
93 PXEBC_DHCP6_OPTION_ARCH *Arch;
94 PXEBC_DHCP6_OPTION_VENDOR_CLASS *VendorClass;
95 } PXEBC_DHCP6_OPTION_ENTRY;
96
97 typedef struct {
98 LIST_ENTRY Link;
99 EFI_DHCP6_PACKET_OPTION *Option;
100 UINT8 Precedence;
101 } PXEBC_DHCP6_OPTION_NODE;
102
103 typedef union {
104 EFI_DHCP6_PACKET Offer;
105 EFI_DHCP6_PACKET Ack;
106 UINT8 Buffer[PXEBC_DHCP6_PACKET_MAX_SIZE];
107 } PXEBC_DHCP6_PACKET;
108
109 typedef struct {
110 PXEBC_DHCP6_PACKET Packet;
111 PXEBC_OFFER_TYPE OfferType;
112 EFI_DHCP6_PACKET_OPTION *OptList[PXEBC_DHCP6_IDX_MAX];
113 } PXEBC_DHCP6_PACKET_CACHE;
114
115
116 /**
117 Free all the nodes in the boot file list.
118
119 @param[in] Head The pointer to the head of the list.
120
121 **/
122 VOID
123 PxeBcFreeBootFileOption (
124 IN LIST_ENTRY *Head
125 );
126
127
128 /**
129 Parse the Boot File URL option.
130
131 @param[out] FileName The pointer to the boot file name.
132 @param[in, out] SrvAddr The pointer to the boot server address.
133 @param[in] BootFile The pointer to the boot file URL option data.
134 @param[in] Length Length of the boot file URL option data.
135
136 @retval EFI_ABORTED User canceled the operation.
137 @retval EFI_SUCCESS Selected the boot menu successfully.
138 @retval EFI_NOT_READY Read the input key from the keybroad has not finish.
139
140 **/
141 EFI_STATUS
142 PxeBcExtractBootFileUrl (
143 OUT UINT8 **FileName,
144 IN OUT EFI_IPv6_ADDRESS *SrvAddr,
145 IN CHAR8 *BootFile,
146 IN UINT16 Length
147 );
148
149
150 /**
151 Parse the Boot File Parameter option.
152
153 @param[in] BootFilePara The pointer to the boot file parameter option data.
154 @param[out] BootFileSize The pointer to the parsed boot file size.
155
156 @retval EFI_SUCCESS Successfully obtained the boot file size from parameter option.
157 @retval EFI_NOT_FOUND Failed to extract the boot file size from parameter option.
158
159 **/
160 EFI_STATUS
161 PxeBcExtractBootFileParam (
162 IN CHAR8 *BootFilePara,
163 OUT UINT16 *BootFileSize
164 );
165
166
167 /**
168 Parse the cached DHCPv6 packet, including all the options.
169
170 @param[in] Cache6 The pointer to a cached DHCPv6 packet.
171
172 @retval EFI_SUCCESS Parsed the DHCPv6 packet successfully.
173 @retval EFI_DEVICE_ERROR Failed to parse and invalid packet.
174
175 **/
176 EFI_STATUS
177 PxeBcParseDhcp6Packet (
178 IN PXEBC_DHCP6_PACKET_CACHE *Cache6
179 );
180
181
182 /**
183 Register the ready address by Ip6Config protocol.
184
185 @param[in] Private The pointer to the PxeBc private data.
186 @param[in] Address The pointer to the ready address.
187
188 @retval EFI_SUCCESS Registered the address succesfully.
189 @retval Others Failed to register the address.
190
191 **/
192 EFI_STATUS
193 PxeBcRegisterIp6Address (
194 IN PXEBC_PRIVATE_DATA *Private,
195 IN EFI_IPv6_ADDRESS *Address
196 );
197
198
199 /**
200 Unregister the address by Ip6Config protocol.
201
202 @param[in] Private The pointer to the PxeBc private data.
203
204 **/
205 VOID
206 PxeBcUnregisterIp6Address (
207 IN PXEBC_PRIVATE_DATA *Private
208 );
209
210
211 /**
212 Build and send out the request packet for the bootfile, and parse the reply.
213
214 @param[in] Private The pointer to the PxeBc private data.
215 @param[in] Type PxeBc option boot item type.
216 @param[in] Layer The pointer to the option boot item layer.
217 @param[in] UseBis Use BIS or not.
218 @param[in] DestIp The pointer to the server address.
219
220 @retval EFI_SUCCESS Successfully discovered theboot file.
221 @retval EFI_OUT_OF_RESOURCES Failed to allocate resource.
222 @retval EFI_NOT_FOUND Can't get the PXE reply packet.
223 @retval Others Failed to discover boot file.
224
225 **/
226 EFI_STATUS
227 PxeBcDhcp6Discover (
228 IN PXEBC_PRIVATE_DATA *Private,
229 IN UINT16 Type,
230 IN UINT16 *Layer,
231 IN BOOLEAN UseBis,
232 IN EFI_IP_ADDRESS *DestIp
233 );
234
235 /**
236 Set the IP6 policy to Automatic.
237
238 @param[in] Private The pointer to PXEBC_PRIVATE_DATA.
239
240 @retval EFI_SUCCESS Switch the IP policy succesfully.
241 @retval Others Unexpect error happened.
242
243 **/
244 EFI_STATUS
245 PxeBcSetIp6Policy (
246 IN PXEBC_PRIVATE_DATA *Private
247 );
248
249 /**
250 This function will register the station IP address and flush IP instance to start using the new IP address.
251
252 @param[in] Private The pointer to PXEBC_PRIVATE_DATA.
253
254 @retval EFI_SUCCESS The new IP address has been configured successfully.
255 @retval Others Failed to configure the address.
256
257 **/
258 EFI_STATUS
259 PxeBcSetIp6Address (
260 IN PXEBC_PRIVATE_DATA *Private
261 );
262
263 /**
264 Start the DHCPv6 S.A.R.R. process to acquire the IPv6 address and other PXE boot information.
265
266 @param[in] Private The pointer to the PxeBc private data.
267 @param[in] Dhcp6 The pointer to EFI_DHCP6_PROTOCOL.
268
269 @retval EFI_SUCCESS The S.A.R.R. process successfully finished.
270 @retval Others Failed to finish the S.A.R.R. process.
271
272 **/
273 EFI_STATUS
274 PxeBcDhcp6Sarr (
275 IN PXEBC_PRIVATE_DATA *Private,
276 IN EFI_DHCP6_PROTOCOL *Dhcp6
277 );
278
279 #endif
280