2 Functions declaration related with DHCPv4 for HTTP boot driver.
4 Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #ifndef __EFI_UEFI_HTTP_BOOT_DHCP4_H__
10 #define __EFI_UEFI_HTTP_BOOT_DHCP4_H__
12 #define HTTP_BOOT_DHCP4_OPTION_MAX_NUM 16
13 #define HTTP_BOOT_DHCP4_OPTION_MAX_SIZE 312
14 #define HTTP_BOOT_DHCP4_PACKET_MAX_SIZE 1472
16 #define HTTP_BOOT_DHCP4_OPCODE_REQUEST 1
17 #define HTTP_BOOT_DHCP4_OPCODE_REPLY 2
18 #define HTTP_BOOT_DHCP4_MSG_TYPE_REQUEST 3
19 #define HTTP_BOOT_DHCP4_MAGIC 0x63538263 // network byte order
21 #define HTTP_BOOT_DHCP4_OVERLOAD_FILE 1
22 #define HTTP_BOOT_DHCP4_OVERLOAD_SERVER_NAME 2
25 /// HTTP Tag definition that identifies the processor
26 /// and programming environment of the client system.
27 /// These identifiers are defined by IETF:
28 /// http://www.ietf.org/assignments/dhcpv6-parameters/dhcpv6-parameters.xml
30 #if defined (MDE_CPU_IA32)
31 #define EFI_HTTP_BOOT_CLIENT_SYSTEM_ARCHITECTURE HTTP_CLIENT_ARCH_IA32
32 #elif defined (MDE_CPU_X64)
33 #define EFI_HTTP_BOOT_CLIENT_SYSTEM_ARCHITECTURE HTTP_CLIENT_ARCH_X64
34 #elif defined (MDE_CPU_ARM)
35 #define EFI_HTTP_BOOT_CLIENT_SYSTEM_ARCHITECTURE HTTP_CLIENT_ARCH_ARM
36 #elif defined (MDE_CPU_AARCH64)
37 #define EFI_HTTP_BOOT_CLIENT_SYSTEM_ARCHITECTURE HTTP_CLIENT_ARCH_AARCH64
38 #elif defined (MDE_CPU_EBC)
39 #define EFI_HTTP_BOOT_CLIENT_SYSTEM_ARCHITECTURE HTTP_CLIENT_ARCH_EBC
42 /// DHCP offer types among HTTP boot.
43 /// Dhcp4 and Dhcp6 share this definition, and corresponding
44 /// relationship is as follows:
45 /// Dhcp4Discover <> Dhcp6Solicit
46 /// Dhcp4Offer <> Dhcp6Advertise
47 /// Dhcp4Request <> Dhcp6Request
48 /// Dhcp4Ack <> DHcp6Reply
52 // <IP address, IP expressed URI>
54 HttpOfferTypeDhcpIpUri
,
56 // <IP address, IP expressed URI, Name-server>
58 HttpOfferTypeDhcpIpUriDns
,
60 // <IP address, Domain-name expressed URI, Name-server>
62 HttpOfferTypeDhcpNameUriDns
,
64 // <IP address, Name-server>
70 HttpOfferTypeDhcpOnly
,
72 // <Domain-name expressed URI> or
73 // <Domain-name expressed URI, Name-server (will be ignored)>
75 HttpOfferTypeProxyNameUri
,
77 // <IP expressed URI> or
78 // <IP expressed URI, Name-server (will be ignored)>
80 HttpOfferTypeProxyIpUri
,
82 // <IP address, Domain-name expressed URI>
84 HttpOfferTypeDhcpNameUri
,
86 } HTTP_BOOT_OFFER_TYPE
;
88 #define HTTP_BOOT_DHCP_RETRIES 4
89 #define HTTP_BOOT_OFFER_MAX_NUM 16
91 // The array index of the DHCP4 option tag interested
93 #define HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE_LEN 0
94 #define HTTP_BOOT_DHCP4_TAG_INDEX_OVERLOAD 1
95 #define HTTP_BOOT_DHCP4_TAG_INDEX_MSG_TYPE 2
96 #define HTTP_BOOT_DHCP4_TAG_INDEX_SERVER_ID 3
97 #define HTTP_BOOT_DHCP4_TAG_INDEX_CLASS_ID 4
98 #define HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE 5
99 #define HTTP_BOOT_DHCP4_TAG_INDEX_DNS_SERVER 6
100 #define HTTP_BOOT_DHCP4_TAG_INDEX_MAX 7
106 } HTTP_BOOT_DHCP4_OPTION_PARA
;
110 } HTTP_BOOT_DHCP4_OPTION_MAX_MESG_SIZE
;
116 } HTTP_BOOT_DHCP4_OPTION_UNDI
;
120 } HTTP_BOOT_DHCP4_OPTION_MESG
;
124 } HTTP_BOOT_DHCP4_OPTION_ARCH
;
127 UINT8 ClassIdentifier
[11];
128 UINT8 ArchitecturePrefix
[5];
129 UINT8 ArchitectureType
[5];
131 UINT8 InterfaceName
[4];
135 } HTTP_BOOT_DHCP4_OPTION_CLID
;
140 } HTTP_BOOT_DHCP4_OPTION_UUID
;
145 } HTTP_BOOT_OPTION_BOOT_ITEM
;
150 HTTP_BOOT_DHCP4_OPTION_PARA
*Para
;
151 HTTP_BOOT_DHCP4_OPTION_UNDI
*Undi
;
152 HTTP_BOOT_DHCP4_OPTION_ARCH
*Arch
;
153 HTTP_BOOT_DHCP4_OPTION_CLID
*Clid
;
154 HTTP_BOOT_DHCP4_OPTION_UUID
*Uuid
;
155 HTTP_BOOT_DHCP4_OPTION_MESG
*Mesg
;
156 HTTP_BOOT_DHCP4_OPTION_MAX_MESG_SIZE
*MaxMesgSize
;
157 } HTTP_BOOT_DHCP4_OPTION_ENTRY
;
159 #define GET_NEXT_DHCP_OPTION(Opt) \
160 (EFI_DHCP4_PACKET_OPTION *) ((UINT8 *) (Opt) + \
161 sizeof (EFI_DHCP4_PACKET_OPTION) + (Opt)->Length - 1)
163 #define GET_OPTION_BUFFER_LEN(Pkt) \
164 ((Pkt)->Length - sizeof (EFI_DHCP4_HEADER) - 4)
166 #define DEFAULT_CLASS_ID_DATA "HTTPClient:Arch:xxxxx:UNDI:003000"
167 #define DEFAULT_UNDI_TYPE 1
168 #define DEFAULT_UNDI_MAJOR 3
169 #define DEFAULT_UNDI_MINOR 0
173 } HTTP_BOOT_VENDOR_OPTION
;
175 #define HTTP_CACHED_DHCP4_PACKET_MAX_SIZE (OFFSET_OF (EFI_DHCP4_PACKET, Dhcp4) + HTTP_BOOT_DHCP4_PACKET_MAX_SIZE)
178 EFI_DHCP4_PACKET Offer
;
179 EFI_DHCP4_PACKET Ack
;
180 UINT8 Buffer
[HTTP_CACHED_DHCP4_PACKET_MAX_SIZE
];
181 } HTTP_BOOT_DHCP4_PACKET
;
191 CHAR8
*Fragment
; /// TODO: may not required in HTTP URL
193 CHAR8
*RegName
; /// Point to somewhere in Authority
195 EFI_IP_ADDRESS Address
;
197 } HTTP_BOOT_URI_CONTENT
;
200 HTTP_BOOT_DHCP4_PACKET Packet
;
201 HTTP_BOOT_OFFER_TYPE OfferType
;
203 EFI_DHCP4_PACKET_OPTION
*OptList
[HTTP_BOOT_DHCP4_TAG_INDEX_MAX
];
204 } HTTP_BOOT_DHCP4_PACKET_CACHE
;
207 Select an DHCPv4 or DHCP6 offer, and record SelectIndex and SelectProxyType.
209 @param[in] Private Pointer to HTTP boot driver private data.
213 HttpBootSelectDhcpOffer (
214 IN HTTP_BOOT_PRIVATE_DATA
*Private
218 Start the D.O.R.A DHCPv4 process to acquire the IPv4 address and other Http boot information.
220 @param[in] Private Pointer to HTTP_BOOT private data.
222 @retval EFI_SUCCESS The D.O.R.A process successfully finished.
223 @retval Others Failed to finish the D.O.R.A process.
228 IN HTTP_BOOT_PRIVATE_DATA
*Private
232 This function will register the default DNS addresses to the network device.
234 @param[in] Private The pointer to HTTP_BOOT_PRIVATE_DATA.
235 @param[in] DataLength Size of the buffer pointed to by DnsServerData in bytes.
236 @param[in] DnsServerData Point a list of DNS server address in an array
237 of EFI_IPv4_ADDRESS instances.
239 @retval EFI_SUCCESS The DNS configuration has been configured successfully.
240 @retval Others Failed to configure the address.
244 HttpBootRegisterIp4Dns (
245 IN HTTP_BOOT_PRIVATE_DATA
*Private
,
247 IN VOID
*DnsServerData