2 Functions declaration related with DHCPv4 for HTTP boot driver.
4 Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
5 Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #ifndef __EFI_UEFI_HTTP_BOOT_DHCP4_H__
11 #define __EFI_UEFI_HTTP_BOOT_DHCP4_H__
13 #define HTTP_BOOT_DHCP4_OPTION_MAX_NUM 16
14 #define HTTP_BOOT_DHCP4_OPTION_MAX_SIZE 312
15 #define HTTP_BOOT_DHCP4_PACKET_MAX_SIZE 1472
17 #define HTTP_BOOT_DHCP4_OPCODE_REQUEST 1
18 #define HTTP_BOOT_DHCP4_OPCODE_REPLY 2
19 #define HTTP_BOOT_DHCP4_MSG_TYPE_REQUEST 3
20 #define HTTP_BOOT_DHCP4_MAGIC 0x63538263 // network byte order
22 #define HTTP_BOOT_DHCP4_OVERLOAD_FILE 1
23 #define HTTP_BOOT_DHCP4_OVERLOAD_SERVER_NAME 2
26 /// HTTP Tag definition that identifies the processor
27 /// and programming environment of the client system.
28 /// These identifiers are defined by IETF:
29 /// http://www.ietf.org/assignments/dhcpv6-parameters/dhcpv6-parameters.xml
31 #if defined (MDE_CPU_IA32)
32 #define EFI_HTTP_BOOT_CLIENT_SYSTEM_ARCHITECTURE HTTP_CLIENT_ARCH_IA32
33 #elif defined (MDE_CPU_X64)
34 #define EFI_HTTP_BOOT_CLIENT_SYSTEM_ARCHITECTURE HTTP_CLIENT_ARCH_X64
35 #elif defined (MDE_CPU_ARM)
36 #define EFI_HTTP_BOOT_CLIENT_SYSTEM_ARCHITECTURE HTTP_CLIENT_ARCH_ARM
37 #elif defined (MDE_CPU_AARCH64)
38 #define EFI_HTTP_BOOT_CLIENT_SYSTEM_ARCHITECTURE HTTP_CLIENT_ARCH_AARCH64
39 #elif defined (MDE_CPU_RISCV64)
40 #define EFI_HTTP_BOOT_CLIENT_SYSTEM_ARCHITECTURE HTTP_CLIENT_ARCH_RISCV64
41 #elif defined (MDE_CPU_EBC)
42 #define EFI_HTTP_BOOT_CLIENT_SYSTEM_ARCHITECTURE HTTP_CLIENT_ARCH_EBC
45 /// DHCP offer types among HTTP boot.
46 /// Dhcp4 and Dhcp6 share this definition, and corresponding
47 /// relationship is as follows:
48 /// Dhcp4Discover <> Dhcp6Solicit
49 /// Dhcp4Offer <> Dhcp6Advertise
50 /// Dhcp4Request <> Dhcp6Request
51 /// Dhcp4Ack <> DHcp6Reply
55 // <IP address, IP expressed URI>
57 HttpOfferTypeDhcpIpUri
,
59 // <IP address, IP expressed URI, Name-server>
61 HttpOfferTypeDhcpIpUriDns
,
63 // <IP address, Domain-name expressed URI, Name-server>
65 HttpOfferTypeDhcpNameUriDns
,
67 // <IP address, Name-server>
73 HttpOfferTypeDhcpOnly
,
75 // <Domain-name expressed URI> or
76 // <Domain-name expressed URI, Name-server (will be ignored)>
78 HttpOfferTypeProxyNameUri
,
80 // <IP expressed URI> or
81 // <IP expressed URI, Name-server (will be ignored)>
83 HttpOfferTypeProxyIpUri
,
85 // <IP address, Domain-name expressed URI>
87 HttpOfferTypeDhcpNameUri
,
89 } HTTP_BOOT_OFFER_TYPE
;
91 #define HTTP_BOOT_DHCP_RETRIES 4
92 #define HTTP_BOOT_OFFER_MAX_NUM 16
94 // The array index of the DHCP4 option tag interested
96 #define HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE_LEN 0
97 #define HTTP_BOOT_DHCP4_TAG_INDEX_OVERLOAD 1
98 #define HTTP_BOOT_DHCP4_TAG_INDEX_MSG_TYPE 2
99 #define HTTP_BOOT_DHCP4_TAG_INDEX_SERVER_ID 3
100 #define HTTP_BOOT_DHCP4_TAG_INDEX_CLASS_ID 4
101 #define HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE 5
102 #define HTTP_BOOT_DHCP4_TAG_INDEX_DNS_SERVER 6
103 #define HTTP_BOOT_DHCP4_TAG_INDEX_MAX 7
109 } HTTP_BOOT_DHCP4_OPTION_PARA
;
113 } HTTP_BOOT_DHCP4_OPTION_MAX_MESG_SIZE
;
119 } HTTP_BOOT_DHCP4_OPTION_UNDI
;
123 } HTTP_BOOT_DHCP4_OPTION_MESG
;
127 } HTTP_BOOT_DHCP4_OPTION_ARCH
;
130 UINT8 ClassIdentifier
[11];
131 UINT8 ArchitecturePrefix
[5];
132 UINT8 ArchitectureType
[5];
134 UINT8 InterfaceName
[4];
138 } HTTP_BOOT_DHCP4_OPTION_CLID
;
143 } HTTP_BOOT_DHCP4_OPTION_UUID
;
148 } HTTP_BOOT_OPTION_BOOT_ITEM
;
153 HTTP_BOOT_DHCP4_OPTION_PARA
*Para
;
154 HTTP_BOOT_DHCP4_OPTION_UNDI
*Undi
;
155 HTTP_BOOT_DHCP4_OPTION_ARCH
*Arch
;
156 HTTP_BOOT_DHCP4_OPTION_CLID
*Clid
;
157 HTTP_BOOT_DHCP4_OPTION_UUID
*Uuid
;
158 HTTP_BOOT_DHCP4_OPTION_MESG
*Mesg
;
159 HTTP_BOOT_DHCP4_OPTION_MAX_MESG_SIZE
*MaxMesgSize
;
160 } HTTP_BOOT_DHCP4_OPTION_ENTRY
;
162 #define GET_NEXT_DHCP_OPTION(Opt) \
163 (EFI_DHCP4_PACKET_OPTION *) ((UINT8 *) (Opt) + \
164 sizeof (EFI_DHCP4_PACKET_OPTION) + (Opt)->Length - 1)
166 #define GET_OPTION_BUFFER_LEN(Pkt) \
167 ((Pkt)->Length - sizeof (EFI_DHCP4_HEADER) - 4)
169 #define DEFAULT_CLASS_ID_DATA "HTTPClient:Arch:xxxxx:UNDI:003000"
170 #define DEFAULT_UNDI_TYPE 1
171 #define DEFAULT_UNDI_MAJOR 3
172 #define DEFAULT_UNDI_MINOR 0
176 } HTTP_BOOT_VENDOR_OPTION
;
178 #define HTTP_CACHED_DHCP4_PACKET_MAX_SIZE (OFFSET_OF (EFI_DHCP4_PACKET, Dhcp4) + HTTP_BOOT_DHCP4_PACKET_MAX_SIZE)
181 EFI_DHCP4_PACKET Offer
;
182 EFI_DHCP4_PACKET Ack
;
183 UINT8 Buffer
[HTTP_CACHED_DHCP4_PACKET_MAX_SIZE
];
184 } HTTP_BOOT_DHCP4_PACKET
;
194 CHAR8
*Fragment
; /// TODO: may not required in HTTP URL
196 CHAR8
*RegName
; /// Point to somewhere in Authority
198 EFI_IP_ADDRESS Address
;
200 } HTTP_BOOT_URI_CONTENT
;
203 HTTP_BOOT_DHCP4_PACKET Packet
;
204 HTTP_BOOT_OFFER_TYPE OfferType
;
206 EFI_DHCP4_PACKET_OPTION
*OptList
[HTTP_BOOT_DHCP4_TAG_INDEX_MAX
];
207 } HTTP_BOOT_DHCP4_PACKET_CACHE
;
210 Select an DHCPv4 or DHCP6 offer, and record SelectIndex and SelectProxyType.
212 @param[in] Private Pointer to HTTP boot driver private data.
216 HttpBootSelectDhcpOffer (
217 IN HTTP_BOOT_PRIVATE_DATA
*Private
221 Start the D.O.R.A DHCPv4 process to acquire the IPv4 address and other Http boot information.
223 @param[in] Private Pointer to HTTP_BOOT private data.
225 @retval EFI_SUCCESS The D.O.R.A process successfully finished.
226 @retval Others Failed to finish the D.O.R.A process.
231 IN HTTP_BOOT_PRIVATE_DATA
*Private
235 This function will register the default DNS addresses to the network device.
237 @param[in] Private The pointer to HTTP_BOOT_PRIVATE_DATA.
238 @param[in] DataLength Size of the buffer pointed to by DnsServerData in bytes.
239 @param[in] DnsServerData Point a list of DNS server address in an array
240 of EFI_IPv4_ADDRESS instances.
242 @retval EFI_SUCCESS The DNS configuration has been configured successfully.
243 @retval Others Failed to configure the address.
247 HttpBootRegisterIp4Dns (
248 IN HTTP_BOOT_PRIVATE_DATA
*Private
,
250 IN VOID
*DnsServerData