2 Functions declaration related with DHCPv6 for UefiPxeBc Driver.
4 Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #ifndef __EFI_PXEBC_DHCP6_H__
11 #define __EFI_PXEBC_DHCP6_H__
13 #define PXEBC_DHCP6_OPTION_MAX_NUM 16
14 #define PXEBC_DHCP6_OPTION_MAX_SIZE 312
15 #define PXEBC_DHCP6_PACKET_MAX_SIZE (sizeof (EFI_PXE_BASE_CODE_PACKET))
16 #define PXEBC_IP6_POLICY_MAX 0xff
17 #define PXEBC_IP6_ROUTE_TABLE_TIMEOUT 10
19 #define PXEBC_DHCP6_S_PORT 547
20 #define PXEBC_DHCP6_C_PORT 546
22 #define PXEBC_DHCP6_ENTERPRISE_NUM 343 // TODO: IANA TBD: temporarily using Intel's
23 #define PXEBC_DHCP6_MAX_BOOT_FILE_SIZE 65535 // It's a limitation of bit length, 65535*512 bytes.
26 #define PXEBC_DHCP6_IDX_IA_NA 0
27 #define PXEBC_DHCP6_IDX_BOOT_FILE_URL 1
28 #define PXEBC_DHCP6_IDX_BOOT_FILE_PARAM 2
29 #define PXEBC_DHCP6_IDX_VENDOR_CLASS 3
30 #define PXEBC_DHCP6_IDX_DNS_SERVER 4
31 #define PXEBC_DHCP6_IDX_MAX 5
33 #define PXEBC_DHCP6_BOOT_FILE_URL_PREFIX "tftp://"
34 #define PXEBC_TFTP_URL_SEPARATOR '/'
35 #define PXEBC_ADDR_START_DELIMITER '['
36 #define PXEBC_ADDR_END_DELIMITER ']'
38 #define GET_NEXT_DHCP6_OPTION(Opt) \
39 (EFI_DHCP6_PACKET_OPTION *) ((UINT8 *) (Opt) + \
40 sizeof (EFI_DHCP6_PACKET_OPTION) + (NTOHS ((Opt)->OpLen)) - 1)
42 #define GET_DHCP6_OPTION_SIZE(Pkt) \
43 ((Pkt)->Length - sizeof (EFI_DHCP6_HEADER))
45 #define IS_PROXY_OFFER(Type) \
46 ((Type) == PxeOfferTypeProxyBinl || \
47 (Type) == PxeOfferTypeProxyPxe10 || \
48 (Type) == PxeOfferTypeProxyWfm11a)
54 } PXEBC_DHCP6_OPTION_ORO
;
60 } PXEBC_DHCP6_OPTION_UNDI
;
64 } PXEBC_DHCP6_OPTION_ARCH
;
67 UINT8 ClassIdentifier
[10];
68 UINT8 ArchitecturePrefix
[5];
69 UINT8 ArchitectureType
[5];
71 UINT8 InterfaceName
[4];
80 PXEBC_CLASS_ID ClassId
;
81 } PXEBC_DHCP6_OPTION_VENDOR_CLASS
;
86 PXEBC_DHCP6_OPTION_ORO
*Oro
;
87 PXEBC_DHCP6_OPTION_UNDI
*Undi
;
88 PXEBC_DHCP6_OPTION_ARCH
*Arch
;
89 PXEBC_DHCP6_OPTION_VENDOR_CLASS
*VendorClass
;
90 } PXEBC_DHCP6_OPTION_ENTRY
;
94 EFI_DHCP6_PACKET_OPTION
*Option
;
96 } PXEBC_DHCP6_OPTION_NODE
;
98 #define PXEBC_CACHED_DHCP6_PACKET_MAX_SIZE (OFFSET_OF (EFI_DHCP6_PACKET, Dhcp6) + PXEBC_DHCP6_PACKET_MAX_SIZE)
101 EFI_DHCP6_PACKET Offer
;
102 EFI_DHCP6_PACKET Ack
;
103 UINT8 Buffer
[PXEBC_CACHED_DHCP6_PACKET_MAX_SIZE
];
104 } PXEBC_DHCP6_PACKET
;
107 PXEBC_DHCP6_PACKET Packet
;
108 PXEBC_OFFER_TYPE OfferType
;
109 EFI_DHCP6_PACKET_OPTION
*OptList
[PXEBC_DHCP6_IDX_MAX
];
110 } PXEBC_DHCP6_PACKET_CACHE
;
116 Parse the Boot File URL option.
118 @param[in] Private Pointer to PxeBc private data.
119 @param[out] FileName The pointer to the boot file name.
120 @param[in, out] SrvAddr The pointer to the boot server address.
121 @param[in] BootFile The pointer to the boot file URL option data.
122 @param[in] Length Length of the boot file URL option data.
124 @retval EFI_ABORTED User canceled the operation.
125 @retval EFI_SUCCESS Selected the boot menu successfully.
126 @retval EFI_NOT_READY Read the input key from the keyboard has not finish.
130 PxeBcExtractBootFileUrl (
131 IN PXEBC_PRIVATE_DATA
*Private
,
132 OUT UINT8
**FileName
,
133 IN OUT EFI_IPv6_ADDRESS
*SrvAddr
,
140 Parse the Boot File Parameter option.
142 @param[in] BootFilePara The pointer to the boot file parameter option data.
143 @param[out] BootFileSize The pointer to the parsed boot file size.
145 @retval EFI_SUCCESS Successfully obtained the boot file size from parameter option.
146 @retval EFI_NOT_FOUND Failed to extract the boot file size from parameter option.
150 PxeBcExtractBootFileParam (
151 IN CHAR8
*BootFilePara
,
152 OUT UINT16
*BootFileSize
157 Parse the cached DHCPv6 packet, including all the options.
159 @param[in] Cache6 The pointer to a cached DHCPv6 packet.
161 @retval EFI_SUCCESS Parsed the DHCPv6 packet successfully.
162 @retval EFI_DEVICE_ERROR Failed to parse and invalid packet.
166 PxeBcParseDhcp6Packet (
167 IN PXEBC_DHCP6_PACKET_CACHE
*Cache6
172 Register the ready address by Ip6Config protocol.
174 @param[in] Private The pointer to the PxeBc private data.
175 @param[in] Address The pointer to the ready address.
177 @retval EFI_SUCCESS Registered the address successfully.
178 @retval Others Failed to register the address.
182 PxeBcRegisterIp6Address (
183 IN PXEBC_PRIVATE_DATA
*Private
,
184 IN EFI_IPv6_ADDRESS
*Address
189 Unregister the address by Ip6Config protocol.
191 @param[in] Private The pointer to the PxeBc private data.
195 PxeBcUnregisterIp6Address (
196 IN PXEBC_PRIVATE_DATA
*Private
201 Build and send out the request packet for the bootfile, and parse the reply.
203 @param[in] Private The pointer to the PxeBc private data.
204 @param[in] Type PxeBc option boot item type.
205 @param[in] Layer The pointer to the option boot item layer.
206 @param[in] UseBis Use BIS or not.
207 @param[in] DestIp The pointer to the server address.
209 @retval EFI_SUCCESS Successfully discovered theboot file.
210 @retval EFI_OUT_OF_RESOURCES Failed to allocate resource.
211 @retval EFI_NOT_FOUND Can't get the PXE reply packet.
212 @retval Others Failed to discover boot file.
217 IN PXEBC_PRIVATE_DATA
*Private
,
221 IN EFI_IP_ADDRESS
*DestIp
225 Set the IP6 policy to Automatic.
227 @param[in] Private The pointer to PXEBC_PRIVATE_DATA.
229 @retval EFI_SUCCESS Switch the IP policy successfully.
230 @retval Others Unexpected error happened.
235 IN PXEBC_PRIVATE_DATA
*Private
239 This function will register the station IP address and flush IP instance to start using the new IP address.
241 @param[in] Private The pointer to PXEBC_PRIVATE_DATA.
243 @retval EFI_SUCCESS The new IP address has been configured successfully.
244 @retval Others Failed to configure the address.
249 IN PXEBC_PRIVATE_DATA
*Private
253 Start the DHCPv6 S.A.R.R. process to acquire the IPv6 address and other PXE boot information.
255 @param[in] Private The pointer to the PxeBc private data.
256 @param[in] Dhcp6 The pointer to EFI_DHCP6_PROTOCOL.
258 @retval EFI_SUCCESS The S.A.R.R. process successfully finished.
259 @retval Others Failed to finish the S.A.R.R. process.
264 IN PXEBC_PRIVATE_DATA
*Private
,
265 IN EFI_DHCP6_PROTOCOL
*Dhcp6