2 Functions declaration related with DHCPv6 for UefiPxeBc Driver.
4 Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
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.
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.
16 #ifndef __EFI_PXEBC_DHCP6_H__
17 #define __EFI_PXEBC_DHCP6_H__
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
25 #define PXEBC_DHCP6_S_PORT 547
26 #define PXEBC_DHCP6_C_PORT 546
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.
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
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 ']'
44 #define GET_NEXT_DHCP6_OPTION(Opt) \
45 (EFI_DHCP6_PACKET_OPTION *) ((UINT8 *) (Opt) + \
46 sizeof (EFI_DHCP6_PACKET_OPTION) + (NTOHS ((Opt)->OpLen)) - 1)
48 #define GET_DHCP6_OPTION_SIZE(Pkt) \
49 ((Pkt)->Length - sizeof (EFI_DHCP6_HEADER))
51 #define IS_PROXY_OFFER(Type) \
52 ((Type) == PxeOfferTypeProxyBinl || \
53 (Type) == PxeOfferTypeProxyPxe10 || \
54 (Type) == PxeOfferTypeProxyWfm11a)
60 } PXEBC_DHCP6_OPTION_ORO
;
66 } PXEBC_DHCP6_OPTION_UNDI
;
70 } PXEBC_DHCP6_OPTION_ARCH
;
73 UINT8 ClassIdentifier
[10];
74 UINT8 ArchitecturePrefix
[5];
75 UINT8 ArchitectureType
[5];
77 UINT8 InterfaceName
[4];
86 PXEBC_CLASS_ID ClassId
;
87 } PXEBC_DHCP6_OPTION_VENDOR_CLASS
;
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
;
100 EFI_DHCP6_PACKET_OPTION
*Option
;
102 } PXEBC_DHCP6_OPTION_NODE
;
105 EFI_DHCP6_PACKET Offer
;
106 EFI_DHCP6_PACKET Ack
;
107 UINT8 Buffer
[PXEBC_DHCP6_PACKET_MAX_SIZE
];
108 } PXEBC_DHCP6_PACKET
;
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
;
118 Free all the nodes in the boot file list.
120 @param[in] Head The pointer to the head of the list.
124 PxeBcFreeBootFileOption (
130 Parse the Boot File URL option.
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.
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.
144 PxeBcExtractBootFileUrl (
145 IN PXEBC_PRIVATE_DATA
*Private
,
146 OUT UINT8
**FileName
,
147 IN OUT EFI_IPv6_ADDRESS
*SrvAddr
,
154 Parse the Boot File Parameter option.
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.
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.
164 PxeBcExtractBootFileParam (
165 IN CHAR8
*BootFilePara
,
166 OUT UINT16
*BootFileSize
171 Parse the cached DHCPv6 packet, including all the options.
173 @param[in] Cache6 The pointer to a cached DHCPv6 packet.
175 @retval EFI_SUCCESS Parsed the DHCPv6 packet successfully.
176 @retval EFI_DEVICE_ERROR Failed to parse and invalid packet.
180 PxeBcParseDhcp6Packet (
181 IN PXEBC_DHCP6_PACKET_CACHE
*Cache6
186 Register the ready address by Ip6Config protocol.
188 @param[in] Private The pointer to the PxeBc private data.
189 @param[in] Address The pointer to the ready address.
191 @retval EFI_SUCCESS Registered the address succesfully.
192 @retval Others Failed to register the address.
196 PxeBcRegisterIp6Address (
197 IN PXEBC_PRIVATE_DATA
*Private
,
198 IN EFI_IPv6_ADDRESS
*Address
203 Unregister the address by Ip6Config protocol.
205 @param[in] Private The pointer to the PxeBc private data.
209 PxeBcUnregisterIp6Address (
210 IN PXEBC_PRIVATE_DATA
*Private
215 Build and send out the request packet for the bootfile, and parse the reply.
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.
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.
231 IN PXEBC_PRIVATE_DATA
*Private
,
235 IN EFI_IP_ADDRESS
*DestIp
239 Set the IP6 policy to Automatic.
241 @param[in] Private The pointer to PXEBC_PRIVATE_DATA.
243 @retval EFI_SUCCESS Switch the IP policy succesfully.
244 @retval Others Unexpect error happened.
249 IN PXEBC_PRIVATE_DATA
*Private
253 This function will register the station IP address and flush IP instance to start using the new IP address.
255 @param[in] Private The pointer to PXEBC_PRIVATE_DATA.
257 @retval EFI_SUCCESS The new IP address has been configured successfully.
258 @retval Others Failed to configure the address.
263 IN PXEBC_PRIVATE_DATA
*Private
267 Start the DHCPv6 S.A.R.R. process to acquire the IPv6 address and other PXE boot information.
269 @param[in] Private The pointer to the PxeBc private data.
270 @param[in] Dhcp6 The pointer to EFI_DHCP6_PROTOCOL.
272 @retval EFI_SUCCESS The S.A.R.R. process successfully finished.
273 @retval Others Failed to finish the S.A.R.R. process.
278 IN PXEBC_PRIVATE_DATA
*Private
,
279 IN EFI_DHCP6_PROTOCOL
*Dhcp6