VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.h@ 106129

Last change on this file since 106129 was 105670, checked in by vboxsync, 9 months ago

Devices/EFI/FirmwareNew: Merge edk2-stable-202405 and make it build on aarch64, bugref:4643

  • Property svn:eol-style set to native
File size: 8.1 KB
Line 
1/** @file
2 Functions declaration related with DHCPv6 for UefiPxeBc Driver.
3
4 Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
5
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8**/
9
10#ifndef __EFI_PXEBC_DHCP6_H__
11#define __EFI_PXEBC_DHCP6_H__
12
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
18
19#define PXEBC_DHCP6_S_PORT 547
20#define PXEBC_DHCP6_C_PORT 546
21
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.
24
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
31
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 ']'
36
37//
38// A DUID consists of a 2-octet type code represented in network byte
39// order, followed by a variable number of octets that make up the
40// actual identifier. The length of the DUID (not including the type
41// code) is at least 1 octet and at most 128 octets.
42//
43#define PXEBC_MIN_SIZE_OF_DUID (sizeof(UINT16) + 1)
44#define PXEBC_MAX_SIZE_OF_DUID (sizeof(UINT16) + 128)
45
46//
47// This define represents the combineds code and length field from
48// https://datatracker.ietf.org/doc/html/rfc3315#section-22.1
49//
50#define PXEBC_COMBINED_SIZE_OF_OPT_CODE_AND_LEN \
51 (sizeof (((EFI_DHCP6_PACKET_OPTION *)0)->OpCode) + \
52 sizeof (((EFI_DHCP6_PACKET_OPTION *)0)->OpLen))
53
54#define GET_NEXT_DHCP6_OPTION(Opt) \
55 (EFI_DHCP6_PACKET_OPTION *) ((UINT8 *) (Opt) + \
56 sizeof (EFI_DHCP6_PACKET_OPTION) + (NTOHS ((Opt)->OpLen)) - 1)
57
58#define GET_DHCP6_OPTION_SIZE(Pkt) \
59 ((Pkt)->Length - sizeof (EFI_DHCP6_HEADER))
60
61#define IS_PROXY_OFFER(Type) \
62 ((Type) == PxeOfferTypeProxyBinl || \
63 (Type) == PxeOfferTypeProxyPxe10 || \
64 (Type) == PxeOfferTypeProxyWfm11a)
65
66#pragma pack(1)
67typedef struct {
68 UINT16 OpCode[256];
69} PXEBC_DHCP6_OPTION_ORO;
70
71typedef struct {
72 UINT8 Type;
73 UINT8 MajorVer;
74 UINT8 MinorVer;
75} PXEBC_DHCP6_OPTION_UNDI;
76
77typedef struct {
78 UINT16 Type;
79} PXEBC_DHCP6_OPTION_ARCH;
80
81typedef struct {
82 UINT8 ClassIdentifier[10];
83 UINT8 ArchitecturePrefix[5];
84 UINT8 ArchitectureType[5];
85 UINT8 Lit3[1];
86 UINT8 InterfaceName[4];
87 UINT8 Lit4[1];
88 UINT8 UndiMajor[3];
89 UINT8 UndiMinor[3];
90} PXEBC_CLASS_ID;
91
92typedef struct {
93 UINT32 Vendor;
94 UINT16 ClassLen;
95 PXEBC_CLASS_ID ClassId;
96} PXEBC_DHCP6_OPTION_VENDOR_CLASS;
97
98#pragma pack()
99
100typedef union {
101 PXEBC_DHCP6_OPTION_ORO *Oro;
102 PXEBC_DHCP6_OPTION_UNDI *Undi;
103 PXEBC_DHCP6_OPTION_ARCH *Arch;
104 PXEBC_DHCP6_OPTION_VENDOR_CLASS *VendorClass;
105} PXEBC_DHCP6_OPTION_ENTRY;
106
107typedef struct {
108 LIST_ENTRY Link;
109 EFI_DHCP6_PACKET_OPTION *Option;
110 UINT8 Precedence;
111} PXEBC_DHCP6_OPTION_NODE;
112
113#define PXEBC_CACHED_DHCP6_PACKET_MAX_SIZE (OFFSET_OF (EFI_DHCP6_PACKET, Dhcp6) + PXEBC_DHCP6_PACKET_MAX_SIZE)
114
115typedef union {
116 EFI_DHCP6_PACKET Offer;
117 EFI_DHCP6_PACKET Ack;
118 UINT8 Buffer[PXEBC_CACHED_DHCP6_PACKET_MAX_SIZE];
119} PXEBC_DHCP6_PACKET;
120
121typedef struct {
122 PXEBC_DHCP6_PACKET Packet;
123 PXEBC_OFFER_TYPE OfferType;
124 EFI_DHCP6_PACKET_OPTION *OptList[PXEBC_DHCP6_IDX_MAX];
125} PXEBC_DHCP6_PACKET_CACHE;
126
127/**
128 Parse the Boot File URL option.
129
130 @param[in] Private Pointer to PxeBc private data.
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 keyboard has not finish.
139
140**/
141EFI_STATUS
142PxeBcExtractBootFileUrl (
143 IN PXEBC_PRIVATE_DATA *Private,
144 OUT UINT8 **FileName,
145 IN OUT EFI_IPv6_ADDRESS *SrvAddr,
146 IN CHAR8 *BootFile,
147 IN UINT16 Length
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**/
160EFI_STATUS
161PxeBcExtractBootFileParam (
162 IN CHAR8 *BootFilePara,
163 OUT UINT16 *BootFileSize
164 );
165
166/**
167 Parse the cached DHCPv6 packet, including all the options.
168
169 @param[in] Cache6 The pointer to a cached DHCPv6 packet.
170
171 @retval EFI_SUCCESS Parsed the DHCPv6 packet successfully.
172 @retval EFI_DEVICE_ERROR Failed to parse and invalid packet.
173
174**/
175EFI_STATUS
176PxeBcParseDhcp6Packet (
177 IN PXEBC_DHCP6_PACKET_CACHE *Cache6
178 );
179
180/**
181 Register the ready address by Ip6Config protocol.
182
183 @param[in] Private The pointer to the PxeBc private data.
184 @param[in] Address The pointer to the ready address.
185
186 @retval EFI_SUCCESS Registered the address successfully.
187 @retval Others Failed to register the address.
188
189**/
190EFI_STATUS
191PxeBcRegisterIp6Address (
192 IN PXEBC_PRIVATE_DATA *Private,
193 IN EFI_IPv6_ADDRESS *Address
194 );
195
196/**
197 Unregister the address by Ip6Config protocol.
198
199 @param[in] Private The pointer to the PxeBc private data.
200
201**/
202VOID
203PxeBcUnregisterIp6Address (
204 IN PXEBC_PRIVATE_DATA *Private
205 );
206
207/**
208 Build and send out the request packet for the bootfile, and parse the reply.
209
210 @param[in] Private The pointer to the PxeBc private data.
211 @param[in] Type PxeBc option boot item type.
212 @param[in] Layer The pointer to the option boot item layer.
213 @param[in] UseBis Use BIS or not.
214 @param[in] DestIp The pointer to the server address.
215
216 @retval EFI_SUCCESS Successfully discovered theboot file.
217 @retval EFI_OUT_OF_RESOURCES Failed to allocate resource.
218 @retval EFI_NOT_FOUND Can't get the PXE reply packet.
219 @retval Others Failed to discover boot file.
220
221**/
222EFI_STATUS
223PxeBcDhcp6Discover (
224 IN PXEBC_PRIVATE_DATA *Private,
225 IN UINT16 Type,
226 IN UINT16 *Layer,
227 IN BOOLEAN UseBis,
228 IN EFI_IP_ADDRESS *DestIp
229 );
230
231/**
232 Set the IP6 policy to Automatic.
233
234 @param[in] Private The pointer to PXEBC_PRIVATE_DATA.
235
236 @retval EFI_SUCCESS Switch the IP policy successfully.
237 @retval Others Unexpected error happened.
238
239**/
240EFI_STATUS
241PxeBcSetIp6Policy (
242 IN PXEBC_PRIVATE_DATA *Private
243 );
244
245/**
246 This function will register the station IP address and flush IP instance to start using the new IP address.
247
248 @param[in] Private The pointer to PXEBC_PRIVATE_DATA.
249
250 @retval EFI_SUCCESS The new IP address has been configured successfully.
251 @retval Others Failed to configure the address.
252
253**/
254EFI_STATUS
255PxeBcSetIp6Address (
256 IN PXEBC_PRIVATE_DATA *Private
257 );
258
259/**
260 Start the DHCPv6 S.A.R.R. process to acquire the IPv6 address and other PXE boot information.
261
262 @param[in] Private The pointer to the PxeBc private data.
263 @param[in] Dhcp6 The pointer to EFI_DHCP6_PROTOCOL.
264
265 @retval EFI_SUCCESS The S.A.R.R. process successfully finished.
266 @retval Others Failed to finish the S.A.R.R. process.
267
268**/
269EFI_STATUS
270PxeBcDhcp6Sarr (
271 IN PXEBC_PRIVATE_DATA *Private,
272 IN EFI_DHCP6_PROTOCOL *Dhcp6
273 );
274
275#endif
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette