]> git.proxmox.com Git - mirror_edk2.git/blob - NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.h
NetworkPkg: Add dns support for pxe boot based on IPv6.
[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_DNS_SERVER 4
37 #define PXEBC_DHCP6_IDX_MAX 5
38
39 #define PXEBC_DHCP6_BOOT_FILE_URL_PREFIX "tftp://"
40 #define PXEBC_TFTP_URL_SEPARATOR '/'
41 #define PXEBC_ADDR_START_DELIMITER '['
42 #define PXEBC_ADDR_END_DELIMITER ']'
43
44 #define GET_NEXT_DHCP6_OPTION(Opt) \
45 (EFI_DHCP6_PACKET_OPTION *) ((UINT8 *) (Opt) + \
46 sizeof (EFI_DHCP6_PACKET_OPTION) + (NTOHS ((Opt)->OpLen)) - 1)
47
48 #define GET_DHCP6_OPTION_SIZE(Pkt) \
49 ((Pkt)->Length - sizeof (EFI_DHCP6_HEADER))
50
51 #define IS_PROXY_OFFER(Type) \
52 ((Type) == PxeOfferTypeProxyBinl || \
53 (Type) == PxeOfferTypeProxyPxe10 || \
54 (Type) == PxeOfferTypeProxyWfm11a)
55
56
57 #pragma pack(1)
58 typedef struct {
59 UINT16 OpCode[256];
60 } PXEBC_DHCP6_OPTION_ORO;
61
62 typedef struct {
63 UINT8 Type;
64 UINT8 MajorVer;
65 UINT8 MinorVer;
66 } PXEBC_DHCP6_OPTION_UNDI;
67
68 typedef struct {
69 UINT16 Type;
70 } PXEBC_DHCP6_OPTION_ARCH;
71
72 typedef struct {
73 UINT8 ClassIdentifier[10];
74 UINT8 ArchitecturePrefix[5];
75 UINT8 ArchitectureType[5];
76 UINT8 Lit3[1];
77 UINT8 InterfaceName[4];
78 UINT8 Lit4[1];
79 UINT8 UndiMajor[3];
80 UINT8 UndiMinor[3];
81 } PXEBC_CLASS_ID;
82
83 typedef struct {
84 UINT32 Vendor;
85 UINT16 ClassLen;
86 PXEBC_CLASS_ID ClassId;
87 } PXEBC_DHCP6_OPTION_VENDOR_CLASS;
88
89 #pragma pack()
90
91 typedef union {
92 PXEBC_DHCP6_OPTION_ORO *Oro;
93 PXEBC_DHCP6_OPTION_UNDI *Undi;
94 PXEBC_DHCP6_OPTION_ARCH *Arch;
95 PXEBC_DHCP6_OPTION_VENDOR_CLASS *VendorClass;
96 } PXEBC_DHCP6_OPTION_ENTRY;
97
98 typedef struct {
99 LIST_ENTRY Link;
100 EFI_DHCP6_PACKET_OPTION *Option;
101 UINT8 Precedence;
102 } PXEBC_DHCP6_OPTION_NODE;
103
104 typedef union {
105 EFI_DHCP6_PACKET Offer;
106 EFI_DHCP6_PACKET Ack;
107 UINT8 Buffer[PXEBC_DHCP6_PACKET_MAX_SIZE];
108 } PXEBC_DHCP6_PACKET;
109
110 typedef struct {
111 PXEBC_DHCP6_PACKET Packet;
112 PXEBC_OFFER_TYPE OfferType;
113 EFI_DHCP6_PACKET_OPTION *OptList[PXEBC_DHCP6_IDX_MAX];
114 } PXEBC_DHCP6_PACKET_CACHE;
115
116
117 /**
118 Free all the nodes in the boot file list.
119
120 @param[in] Head The pointer to the head of the list.
121
122 **/
123 VOID
124 PxeBcFreeBootFileOption (
125 IN LIST_ENTRY *Head
126 );
127
128
129 /**
130 Parse the Boot File URL option.
131
132 @param[in] Private Pointer to PxeBc private data.
133 @param[out] FileName The pointer to the boot file name.
134 @param[in, out] SrvAddr The pointer to the boot server address.
135 @param[in] BootFile The pointer to the boot file URL option data.
136 @param[in] Length Length of the boot file URL option data.
137
138 @retval EFI_ABORTED User canceled the operation.
139 @retval EFI_SUCCESS Selected the boot menu successfully.
140 @retval EFI_NOT_READY Read the input key from the keybroad has not finish.
141
142 **/
143 EFI_STATUS
144 PxeBcExtractBootFileUrl (
145 IN PXEBC_PRIVATE_DATA *Private,
146 OUT UINT8 **FileName,
147 IN OUT EFI_IPv6_ADDRESS *SrvAddr,
148 IN CHAR8 *BootFile,
149 IN UINT16 Length
150 );
151
152
153 /**
154 Parse the Boot File Parameter option.
155
156 @param[in] BootFilePara The pointer to the boot file parameter option data.
157 @param[out] BootFileSize The pointer to the parsed boot file size.
158
159 @retval EFI_SUCCESS Successfully obtained the boot file size from parameter option.
160 @retval EFI_NOT_FOUND Failed to extract the boot file size from parameter option.
161
162 **/
163 EFI_STATUS
164 PxeBcExtractBootFileParam (
165 IN CHAR8 *BootFilePara,
166 OUT UINT16 *BootFileSize
167 );
168
169
170 /**
171 Parse the cached DHCPv6 packet, including all the options.
172
173 @param[in] Cache6 The pointer to a cached DHCPv6 packet.
174
175 @retval EFI_SUCCESS Parsed the DHCPv6 packet successfully.
176 @retval EFI_DEVICE_ERROR Failed to parse and invalid packet.
177
178 **/
179 EFI_STATUS
180 PxeBcParseDhcp6Packet (
181 IN PXEBC_DHCP6_PACKET_CACHE *Cache6
182 );
183
184
185 /**
186 Register the ready address by Ip6Config protocol.
187
188 @param[in] Private The pointer to the PxeBc private data.
189 @param[in] Address The pointer to the ready address.
190
191 @retval EFI_SUCCESS Registered the address succesfully.
192 @retval Others Failed to register the address.
193
194 **/
195 EFI_STATUS
196 PxeBcRegisterIp6Address (
197 IN PXEBC_PRIVATE_DATA *Private,
198 IN EFI_IPv6_ADDRESS *Address
199 );
200
201
202 /**
203 Unregister the address by Ip6Config protocol.
204
205 @param[in] Private The pointer to the PxeBc private data.
206
207 **/
208 VOID
209 PxeBcUnregisterIp6Address (
210 IN PXEBC_PRIVATE_DATA *Private
211 );
212
213
214 /**
215 Build and send out the request packet for the bootfile, and parse the reply.
216
217 @param[in] Private The pointer to the PxeBc private data.
218 @param[in] Type PxeBc option boot item type.
219 @param[in] Layer The pointer to the option boot item layer.
220 @param[in] UseBis Use BIS or not.
221 @param[in] DestIp The pointer to the server address.
222
223 @retval EFI_SUCCESS Successfully discovered theboot file.
224 @retval EFI_OUT_OF_RESOURCES Failed to allocate resource.
225 @retval EFI_NOT_FOUND Can't get the PXE reply packet.
226 @retval Others Failed to discover boot file.
227
228 **/
229 EFI_STATUS
230 PxeBcDhcp6Discover (
231 IN PXEBC_PRIVATE_DATA *Private,
232 IN UINT16 Type,
233 IN UINT16 *Layer,
234 IN BOOLEAN UseBis,
235 IN EFI_IP_ADDRESS *DestIp
236 );
237
238 /**
239 Set the IP6 policy to Automatic.
240
241 @param[in] Private The pointer to PXEBC_PRIVATE_DATA.
242
243 @retval EFI_SUCCESS Switch the IP policy succesfully.
244 @retval Others Unexpect error happened.
245
246 **/
247 EFI_STATUS
248 PxeBcSetIp6Policy (
249 IN PXEBC_PRIVATE_DATA *Private
250 );
251
252 /**
253 This function will register the station IP address and flush IP instance to start using the new IP address.
254
255 @param[in] Private The pointer to PXEBC_PRIVATE_DATA.
256
257 @retval EFI_SUCCESS The new IP address has been configured successfully.
258 @retval Others Failed to configure the address.
259
260 **/
261 EFI_STATUS
262 PxeBcSetIp6Address (
263 IN PXEBC_PRIVATE_DATA *Private
264 );
265
266 /**
267 Start the DHCPv6 S.A.R.R. process to acquire the IPv6 address and other PXE boot information.
268
269 @param[in] Private The pointer to the PxeBc private data.
270 @param[in] Dhcp6 The pointer to EFI_DHCP6_PROTOCOL.
271
272 @retval EFI_SUCCESS The S.A.R.R. process successfully finished.
273 @retval Others Failed to finish the S.A.R.R. process.
274
275 **/
276 EFI_STATUS
277 PxeBcDhcp6Sarr (
278 IN PXEBC_PRIVATE_DATA *Private,
279 IN EFI_DHCP6_PROTOCOL *Dhcp6
280 );
281
282 #endif
283