2 Functions declaration related with DHCPv4 for HTTP boot driver.
4 Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials are licensed and made available under
6 the terms and conditions of the BSD License that accompanies this distribution.
7 The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php.
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #ifndef __EFI_UEFI_HTTP_BOOT_DHCP4_H__
16 #define __EFI_UEFI_HTTP_BOOT_DHCP4_H__
18 #define HTTP_BOOT_DHCP4_OPTION_MAX_NUM 16
19 #define HTTP_BOOT_DHCP4_OPTION_MAX_SIZE 312
20 #define HTTP_BOOT_DHCP4_PACKET_MAX_SIZE 1472
22 #define HTTP_BOOT_DHCP4_OPCODE_REQUEST 1
23 #define HTTP_BOOT_DHCP4_OPCODE_REPLY 2
24 #define HTTP_BOOT_DHCP4_MSG_TYPE_REQUEST 3
25 #define HTTP_BOOT_DHCP4_MAGIC 0x63538263 // network byte order
27 #define HTTP_BOOT_DHCP4_OVERLOAD_FILE 1
28 #define HTTP_BOOT_DHCP4_OVERLOAD_SERVER_NAME 2
31 /// HTTP Tag definition that identifies the processor
32 /// and programming environment of the client system.
33 /// These identifiers are defined by IETF:
34 /// http://www.ietf.org/assignments/dhcpv6-parameters/dhcpv6-parameters.xml
36 #if defined (MDE_CPU_IA32)
37 #define EFI_HTTP_BOOT_CLIENT_SYSTEM_ARCHITECTURE HTTP_CLIENT_ARCH_IA32
38 #elif defined (MDE_CPU_X64)
39 #define EFI_HTTP_BOOT_CLIENT_SYSTEM_ARCHITECTURE HTTP_CLIENT_ARCH_X64
40 #elif defined (MDE_CPU_ARM)
41 #define EFI_HTTP_BOOT_CLIENT_SYSTEM_ARCHITECTURE HTTP_CLIENT_ARCH_ARM
42 #elif defined (MDE_CPU_AARCH64)
43 #define EFI_HTTP_BOOT_CLIENT_SYSTEM_ARCHITECTURE HTTP_CLIENT_ARCH_AARCH64
44 #elif defined (MDE_CPU_EBC)
45 #define EFI_HTTP_BOOT_CLIENT_SYSTEM_ARCHITECTURE HTTP_CLIENT_ARCH_EBC
48 /// DHCP offer types among HTTP boot.
49 /// Dhcp4 and Dhcp6 share this definition, and corresponding
50 /// relatioinship is as follows:
51 /// Dhcp4Discover <> Dhcp6Solicit
52 /// Dhcp4Offer <> Dhcp6Advertise
53 /// Dhcp4Request <> Dhcp6Request
54 /// Dhcp4Ack <> DHcp6Reply
58 // <IP address, IP expressed URI>
60 HttpOfferTypeDhcpIpUri
,
62 // <IP address, IP expressed URI, Name-server>
64 HttpOfferTypeDhcpIpUriDns
,
66 // <IP address, Domain-name expressed URI, Name-server>
68 HttpOfferTypeDhcpNameUriDns
,
70 // <IP address, Name-server>
76 HttpOfferTypeDhcpOnly
,
78 // <Domain-name expressed URI> or
79 // <Domain-name expressed URI, Name-server (will be ignored)>
81 HttpOfferTypeProxyNameUri
,
83 // <IP expressed URI> or
84 // <IP expressed URI, Name-server (will be ignored)>
86 HttpOfferTypeProxyIpUri
,
88 // <IP address, Domain-name expressed URI>
90 HttpOfferTypeDhcpNameUri
,
92 } HTTP_BOOT_OFFER_TYPE
;
94 #define HTTP_BOOT_DHCP_RETRIES 4
95 #define HTTP_BOOT_OFFER_MAX_NUM 16
97 // The array index of the DHCP4 option tag interested
99 #define HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE_LEN 0
100 #define HTTP_BOOT_DHCP4_TAG_INDEX_OVERLOAD 1
101 #define HTTP_BOOT_DHCP4_TAG_INDEX_MSG_TYPE 2
102 #define HTTP_BOOT_DHCP4_TAG_INDEX_SERVER_ID 3
103 #define HTTP_BOOT_DHCP4_TAG_INDEX_CLASS_ID 4
104 #define HTTP_BOOT_DHCP4_TAG_INDEX_BOOTFILE 5
105 #define HTTP_BOOT_DHCP4_TAG_INDEX_DNS_SERVER 6
106 #define HTTP_BOOT_DHCP4_TAG_INDEX_MAX 7
112 } HTTP_BOOT_DHCP4_OPTION_PARA
;
116 } HTTP_BOOT_DHCP4_OPTION_MAX_MESG_SIZE
;
122 } HTTP_BOOT_DHCP4_OPTION_UNDI
;
126 } HTTP_BOOT_DHCP4_OPTION_MESG
;
130 } HTTP_BOOT_DHCP4_OPTION_ARCH
;
133 UINT8 ClassIdentifier
[11];
134 UINT8 ArchitecturePrefix
[5];
135 UINT8 ArchitectureType
[5];
137 UINT8 InterfaceName
[4];
141 } HTTP_BOOT_DHCP4_OPTION_CLID
;
146 } HTTP_BOOT_DHCP4_OPTION_UUID
;
151 } HTTP_BOOT_OPTION_BOOT_ITEM
;
156 HTTP_BOOT_DHCP4_OPTION_PARA
*Para
;
157 HTTP_BOOT_DHCP4_OPTION_UNDI
*Undi
;
158 HTTP_BOOT_DHCP4_OPTION_ARCH
*Arch
;
159 HTTP_BOOT_DHCP4_OPTION_CLID
*Clid
;
160 HTTP_BOOT_DHCP4_OPTION_UUID
*Uuid
;
161 HTTP_BOOT_DHCP4_OPTION_MESG
*Mesg
;
162 HTTP_BOOT_DHCP4_OPTION_MAX_MESG_SIZE
*MaxMesgSize
;
163 } HTTP_BOOT_DHCP4_OPTION_ENTRY
;
165 #define GET_NEXT_DHCP_OPTION(Opt) \
166 (EFI_DHCP4_PACKET_OPTION *) ((UINT8 *) (Opt) + \
167 sizeof (EFI_DHCP4_PACKET_OPTION) + (Opt)->Length - 1)
169 #define GET_OPTION_BUFFER_LEN(Pkt) \
170 ((Pkt)->Length - sizeof (EFI_DHCP4_HEADER) - 4)
172 #define DEFAULT_CLASS_ID_DATA "HTTPClient:Arch:xxxxx:UNDI:003000"
173 #define DEFAULT_UNDI_TYPE 1
174 #define DEFAULT_UNDI_MAJOR 3
175 #define DEFAULT_UNDI_MINOR 0
179 } HTTP_BOOT_VENDOR_OPTION
;
181 #define HTTP_CACHED_DHCP4_PACKET_MAX_SIZE (OFFSET_OF (EFI_DHCP4_PACKET, Dhcp4) + HTTP_BOOT_DHCP4_PACKET_MAX_SIZE)
184 EFI_DHCP4_PACKET Offer
;
185 EFI_DHCP4_PACKET Ack
;
186 UINT8 Buffer
[HTTP_CACHED_DHCP4_PACKET_MAX_SIZE
];
187 } HTTP_BOOT_DHCP4_PACKET
;
197 CHAR8
*Fragment
; /// TODO: may not required in HTTP URL
199 CHAR8
*RegName
; /// Point to somewhere in Authority
201 EFI_IP_ADDRESS Address
;
203 } HTTP_BOOT_URI_CONTENT
;
206 HTTP_BOOT_DHCP4_PACKET Packet
;
207 HTTP_BOOT_OFFER_TYPE OfferType
;
209 EFI_DHCP4_PACKET_OPTION
*OptList
[HTTP_BOOT_DHCP4_TAG_INDEX_MAX
];
210 } HTTP_BOOT_DHCP4_PACKET_CACHE
;
213 Select an DHCPv4 or DHCP6 offer, and record SelectIndex and SelectProxyType.
215 @param[in] Private Pointer to HTTP boot driver private data.
219 HttpBootSelectDhcpOffer (
220 IN HTTP_BOOT_PRIVATE_DATA
*Private
224 Start the D.O.R.A DHCPv4 process to acquire the IPv4 address and other Http boot information.
226 @param[in] Private Pointer to HTTP_BOOT private data.
228 @retval EFI_SUCCESS The D.O.R.A process successfully finished.
229 @retval Others Failed to finish the D.O.R.A process.
234 IN HTTP_BOOT_PRIVATE_DATA
*Private
238 This function will register the default DNS addresses to the network device.
240 @param[in] Private The pointer to HTTP_BOOT_PRIVATE_DATA.
241 @param[in] DataLength Size of the buffer pointed to by DnsServerData in bytes.
242 @param[in] DnsServerData Point a list of DNS server address in an array
243 of EFI_IPv4_ADDRESS instances.
245 @retval EFI_SUCCESS The DNS configuration has been configured successfully.
246 @retval Others Failed to configure the address.
250 HttpBootRegisterIp4Dns (
251 IN HTTP_BOOT_PRIVATE_DATA
*Private
,
253 IN VOID
*DnsServerData