]> git.proxmox.com Git - mirror_edk2.git/blob - NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.h
MdeModulePkg/Ip4Dxe: Sync the direct route entry setting.
[mirror_edk2.git] / NetworkPkg / UefiPxeBcDxe / PxeBcDhcp6.h
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 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 (sizeof (EFI_PXE_BASE_CODE_PACKET))
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 #define PXEBC_CACHED_DHCP6_PACKET_MAX_SIZE (OFFSET_OF (EFI_DHCP6_PACKET, Dhcp6) + PXEBC_DHCP6_PACKET_MAX_SIZE)
105
106 typedef union {
107 EFI_DHCP6_PACKET Offer;
108 EFI_DHCP6_PACKET Ack;
109 UINT8 Buffer[PXEBC_CACHED_DHCP6_PACKET_MAX_SIZE];
110 } PXEBC_DHCP6_PACKET;
111
112 typedef struct {
113 PXEBC_DHCP6_PACKET Packet;
114 PXEBC_OFFER_TYPE OfferType;
115 EFI_DHCP6_PACKET_OPTION *OptList[PXEBC_DHCP6_IDX_MAX];
116 } PXEBC_DHCP6_PACKET_CACHE;
117
118
119
120
121 /**
122 Parse the Boot File URL option.
123
124 @param[in] Private Pointer to PxeBc private data.
125 @param[out] FileName The pointer to the boot file name.
126 @param[in, out] SrvAddr The pointer to the boot server address.
127 @param[in] BootFile The pointer to the boot file URL option data.
128 @param[in] Length Length of the boot file URL option data.
129
130 @retval EFI_ABORTED User canceled the operation.
131 @retval EFI_SUCCESS Selected the boot menu successfully.
132 @retval EFI_NOT_READY Read the input key from the keybroad has not finish.
133
134 **/
135 EFI_STATUS
136 PxeBcExtractBootFileUrl (
137 IN PXEBC_PRIVATE_DATA *Private,
138 OUT UINT8 **FileName,
139 IN OUT EFI_IPv6_ADDRESS *SrvAddr,
140 IN CHAR8 *BootFile,
141 IN UINT16 Length
142 );
143
144
145 /**
146 Parse the Boot File Parameter option.
147
148 @param[in] BootFilePara The pointer to the boot file parameter option data.
149 @param[out] BootFileSize The pointer to the parsed boot file size.
150
151 @retval EFI_SUCCESS Successfully obtained the boot file size from parameter option.
152 @retval EFI_NOT_FOUND Failed to extract the boot file size from parameter option.
153
154 **/
155 EFI_STATUS
156 PxeBcExtractBootFileParam (
157 IN CHAR8 *BootFilePara,
158 OUT UINT16 *BootFileSize
159 );
160
161
162 /**
163 Parse the cached DHCPv6 packet, including all the options.
164
165 @param[in] Cache6 The pointer to a cached DHCPv6 packet.
166
167 @retval EFI_SUCCESS Parsed the DHCPv6 packet successfully.
168 @retval EFI_DEVICE_ERROR Failed to parse and invalid packet.
169
170 **/
171 EFI_STATUS
172 PxeBcParseDhcp6Packet (
173 IN PXEBC_DHCP6_PACKET_CACHE *Cache6
174 );
175
176
177 /**
178 Register the ready address by Ip6Config protocol.
179
180 @param[in] Private The pointer to the PxeBc private data.
181 @param[in] Address The pointer to the ready address.
182
183 @retval EFI_SUCCESS Registered the address succesfully.
184 @retval Others Failed to register the address.
185
186 **/
187 EFI_STATUS
188 PxeBcRegisterIp6Address (
189 IN PXEBC_PRIVATE_DATA *Private,
190 IN EFI_IPv6_ADDRESS *Address
191 );
192
193
194 /**
195 Unregister the address by Ip6Config protocol.
196
197 @param[in] Private The pointer to the PxeBc private data.
198
199 **/
200 VOID
201 PxeBcUnregisterIp6Address (
202 IN PXEBC_PRIVATE_DATA *Private
203 );
204
205
206 /**
207 Build and send out the request packet for the bootfile, and parse the reply.
208
209 @param[in] Private The pointer to the PxeBc private data.
210 @param[in] Type PxeBc option boot item type.
211 @param[in] Layer The pointer to the option boot item layer.
212 @param[in] UseBis Use BIS or not.
213 @param[in] DestIp The pointer to the server address.
214
215 @retval EFI_SUCCESS Successfully discovered theboot file.
216 @retval EFI_OUT_OF_RESOURCES Failed to allocate resource.
217 @retval EFI_NOT_FOUND Can't get the PXE reply packet.
218 @retval Others Failed to discover boot file.
219
220 **/
221 EFI_STATUS
222 PxeBcDhcp6Discover (
223 IN PXEBC_PRIVATE_DATA *Private,
224 IN UINT16 Type,
225 IN UINT16 *Layer,
226 IN BOOLEAN UseBis,
227 IN EFI_IP_ADDRESS *DestIp
228 );
229
230 /**
231 Set the IP6 policy to Automatic.
232
233 @param[in] Private The pointer to PXEBC_PRIVATE_DATA.
234
235 @retval EFI_SUCCESS Switch the IP policy succesfully.
236 @retval Others Unexpect error happened.
237
238 **/
239 EFI_STATUS
240 PxeBcSetIp6Policy (
241 IN PXEBC_PRIVATE_DATA *Private
242 );
243
244 /**
245 This function will register the station IP address and flush IP instance to start using the new IP address.
246
247 @param[in] Private The pointer to PXEBC_PRIVATE_DATA.
248
249 @retval EFI_SUCCESS The new IP address has been configured successfully.
250 @retval Others Failed to configure the address.
251
252 **/
253 EFI_STATUS
254 PxeBcSetIp6Address (
255 IN PXEBC_PRIVATE_DATA *Private
256 );
257
258 /**
259 Start the DHCPv6 S.A.R.R. process to acquire the IPv6 address and other PXE boot information.
260
261 @param[in] Private The pointer to the PxeBc private data.
262 @param[in] Dhcp6 The pointer to EFI_DHCP6_PROTOCOL.
263
264 @retval EFI_SUCCESS The S.A.R.R. process successfully finished.
265 @retval Others Failed to finish the S.A.R.R. process.
266
267 **/
268 EFI_STATUS
269 PxeBcDhcp6Sarr (
270 IN PXEBC_PRIVATE_DATA *Private,
271 IN EFI_DHCP6_PROTOCOL *Dhcp6
272 );
273
274 #endif
275