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.
25 #define PXEBC_DHCP6_IDX_IA_NA 0
26 #define PXEBC_DHCP6_IDX_BOOT_FILE_URL 1
27 #define PXEBC_DHCP6_IDX_BOOT_FILE_PARAM 2
28 #define PXEBC_DHCP6_IDX_VENDOR_CLASS 3
29 #define PXEBC_DHCP6_IDX_DNS_SERVER 4
30 #define PXEBC_DHCP6_IDX_MAX 5
32 #define PXEBC_DHCP6_BOOT_FILE_URL_PREFIX "tftp://"
33 #define PXEBC_TFTP_URL_SEPARATOR '/'
34 #define PXEBC_ADDR_START_DELIMITER '['
35 #define PXEBC_ADDR_END_DELIMITER ']'
37 #define GET_NEXT_DHCP6_OPTION(Opt) \
38 (EFI_DHCP6_PACKET_OPTION *) ((UINT8 *) (Opt) + \
39 sizeof (EFI_DHCP6_PACKET_OPTION) + (NTOHS ((Opt)->OpLen)) - 1)
41 #define GET_DHCP6_OPTION_SIZE(Pkt) \
42 ((Pkt)->Length - sizeof (EFI_DHCP6_HEADER))
44 #define IS_PROXY_OFFER(Type) \
45 ((Type) == PxeOfferTypeProxyBinl || \
46 (Type) == PxeOfferTypeProxyPxe10 || \
47 (Type) == PxeOfferTypeProxyWfm11a)
52 } PXEBC_DHCP6_OPTION_ORO
;
58 } PXEBC_DHCP6_OPTION_UNDI
;
62 } PXEBC_DHCP6_OPTION_ARCH
;
65 UINT8 ClassIdentifier
[10];
66 UINT8 ArchitecturePrefix
[5];
67 UINT8 ArchitectureType
[5];
69 UINT8 InterfaceName
[4];
78 PXEBC_CLASS_ID ClassId
;
79 } PXEBC_DHCP6_OPTION_VENDOR_CLASS
;
84 PXEBC_DHCP6_OPTION_ORO
*Oro
;
85 PXEBC_DHCP6_OPTION_UNDI
*Undi
;
86 PXEBC_DHCP6_OPTION_ARCH
*Arch
;
87 PXEBC_DHCP6_OPTION_VENDOR_CLASS
*VendorClass
;
88 } PXEBC_DHCP6_OPTION_ENTRY
;
92 EFI_DHCP6_PACKET_OPTION
*Option
;
94 } PXEBC_DHCP6_OPTION_NODE
;
96 #define PXEBC_CACHED_DHCP6_PACKET_MAX_SIZE (OFFSET_OF (EFI_DHCP6_PACKET, Dhcp6) + PXEBC_DHCP6_PACKET_MAX_SIZE)
99 EFI_DHCP6_PACKET Offer
;
100 EFI_DHCP6_PACKET Ack
;
101 UINT8 Buffer
[PXEBC_CACHED_DHCP6_PACKET_MAX_SIZE
];
102 } PXEBC_DHCP6_PACKET
;
105 PXEBC_DHCP6_PACKET Packet
;
106 PXEBC_OFFER_TYPE OfferType
;
107 EFI_DHCP6_PACKET_OPTION
*OptList
[PXEBC_DHCP6_IDX_MAX
];
108 } PXEBC_DHCP6_PACKET_CACHE
;
111 Parse the Boot File URL option.
113 @param[in] Private Pointer to PxeBc private data.
114 @param[out] FileName The pointer to the boot file name.
115 @param[in, out] SrvAddr The pointer to the boot server address.
116 @param[in] BootFile The pointer to the boot file URL option data.
117 @param[in] Length Length of the boot file URL option data.
119 @retval EFI_ABORTED User canceled the operation.
120 @retval EFI_SUCCESS Selected the boot menu successfully.
121 @retval EFI_NOT_READY Read the input key from the keyboard has not finish.
125 PxeBcExtractBootFileUrl (
126 IN PXEBC_PRIVATE_DATA
*Private
,
127 OUT UINT8
**FileName
,
128 IN OUT EFI_IPv6_ADDRESS
*SrvAddr
,
134 Parse the Boot File Parameter option.
136 @param[in] BootFilePara The pointer to the boot file parameter option data.
137 @param[out] BootFileSize The pointer to the parsed boot file size.
139 @retval EFI_SUCCESS Successfully obtained the boot file size from parameter option.
140 @retval EFI_NOT_FOUND Failed to extract the boot file size from parameter option.
144 PxeBcExtractBootFileParam (
145 IN CHAR8
*BootFilePara
,
146 OUT UINT16
*BootFileSize
150 Parse the cached DHCPv6 packet, including all the options.
152 @param[in] Cache6 The pointer to a cached DHCPv6 packet.
154 @retval EFI_SUCCESS Parsed the DHCPv6 packet successfully.
155 @retval EFI_DEVICE_ERROR Failed to parse and invalid packet.
159 PxeBcParseDhcp6Packet (
160 IN PXEBC_DHCP6_PACKET_CACHE
*Cache6
164 Register the ready address by Ip6Config protocol.
166 @param[in] Private The pointer to the PxeBc private data.
167 @param[in] Address The pointer to the ready address.
169 @retval EFI_SUCCESS Registered the address successfully.
170 @retval Others Failed to register the address.
174 PxeBcRegisterIp6Address (
175 IN PXEBC_PRIVATE_DATA
*Private
,
176 IN EFI_IPv6_ADDRESS
*Address
180 Unregister the address by Ip6Config protocol.
182 @param[in] Private The pointer to the PxeBc private data.
186 PxeBcUnregisterIp6Address (
187 IN PXEBC_PRIVATE_DATA
*Private
191 Build and send out the request packet for the bootfile, and parse the reply.
193 @param[in] Private The pointer to the PxeBc private data.
194 @param[in] Type PxeBc option boot item type.
195 @param[in] Layer The pointer to the option boot item layer.
196 @param[in] UseBis Use BIS or not.
197 @param[in] DestIp The pointer to the server address.
199 @retval EFI_SUCCESS Successfully discovered theboot file.
200 @retval EFI_OUT_OF_RESOURCES Failed to allocate resource.
201 @retval EFI_NOT_FOUND Can't get the PXE reply packet.
202 @retval Others Failed to discover boot file.
207 IN PXEBC_PRIVATE_DATA
*Private
,
211 IN EFI_IP_ADDRESS
*DestIp
215 Set the IP6 policy to Automatic.
217 @param[in] Private The pointer to PXEBC_PRIVATE_DATA.
219 @retval EFI_SUCCESS Switch the IP policy successfully.
220 @retval Others Unexpected error happened.
225 IN PXEBC_PRIVATE_DATA
*Private
229 This function will register the station IP address and flush IP instance to start using the new IP address.
231 @param[in] Private The pointer to PXEBC_PRIVATE_DATA.
233 @retval EFI_SUCCESS The new IP address has been configured successfully.
234 @retval Others Failed to configure the address.
239 IN PXEBC_PRIVATE_DATA
*Private
243 Start the DHCPv6 S.A.R.R. process to acquire the IPv6 address and other PXE boot information.
245 @param[in] Private The pointer to the PxeBc private data.
246 @param[in] Dhcp6 The pointer to EFI_DHCP6_PROTOCOL.
248 @retval EFI_SUCCESS The S.A.R.R. process successfully finished.
249 @retval Others Failed to finish the S.A.R.R. process.
254 IN PXEBC_PRIVATE_DATA
*Private
,
255 IN EFI_DHCP6_PROTOCOL
*Dhcp6