]> git.proxmox.com Git - mirror_edk2.git/blob - NetworkPkg/HttpBootDxe/HttpBootDhcp4.h
NetworkPkg: Clean up source files
[mirror_edk2.git] / NetworkPkg / HttpBootDxe / HttpBootDhcp4.h
1 /** @file
2 Functions declaration related with DHCPv4 for HTTP boot driver.
3
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.
9
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.
12
13 **/
14
15 #ifndef __EFI_UEFI_HTTP_BOOT_DHCP4_H__
16 #define __EFI_UEFI_HTTP_BOOT_DHCP4_H__
17
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
21
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
26
27 #define HTTP_BOOT_DHCP4_OVERLOAD_FILE 1
28 #define HTTP_BOOT_DHCP4_OVERLOAD_SERVER_NAME 2
29
30 ///
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
35 ///
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
46 #endif
47
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
55 ///
56 typedef enum {
57 //
58 // <IP address, IP expressed URI>
59 //
60 HttpOfferTypeDhcpIpUri,
61 //
62 // <IP address, IP expressed URI, Name-server>
63 //
64 HttpOfferTypeDhcpIpUriDns,
65 //
66 // <IP address, Domain-name expressed URI, Name-server>
67 //
68 HttpOfferTypeDhcpNameUriDns,
69 //
70 // <IP address, Name-server>
71 //
72 HttpOfferTypeDhcpDns,
73 //
74 // <IP address>
75 //
76 HttpOfferTypeDhcpOnly,
77 //
78 // <Domain-name expressed URI> or
79 // <Domain-name expressed URI, Name-server (will be ignored)>
80 //
81 HttpOfferTypeProxyNameUri,
82 //
83 // <IP expressed URI> or
84 // <IP expressed URI, Name-server (will be ignored)>
85 //
86 HttpOfferTypeProxyIpUri,
87 //
88 // <IP address, Domain-name expressed URI>
89 //
90 HttpOfferTypeDhcpNameUri,
91 HttpOfferTypeMax
92 } HTTP_BOOT_OFFER_TYPE;
93
94 #define HTTP_BOOT_DHCP_RETRIES 4
95 #define HTTP_BOOT_OFFER_MAX_NUM 16
96
97 // The array index of the DHCP4 option tag interested
98 //
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
107
108 #pragma pack(1)
109
110 typedef struct {
111 UINT8 ParaList[135];
112 } HTTP_BOOT_DHCP4_OPTION_PARA;
113
114 typedef struct {
115 UINT16 Size;
116 } HTTP_BOOT_DHCP4_OPTION_MAX_MESG_SIZE;
117
118 typedef struct {
119 UINT8 Type;
120 UINT8 MajorVer;
121 UINT8 MinorVer;
122 } HTTP_BOOT_DHCP4_OPTION_UNDI;
123
124 typedef struct {
125 UINT8 Type;
126 } HTTP_BOOT_DHCP4_OPTION_MESG;
127
128 typedef struct {
129 UINT16 Type;
130 } HTTP_BOOT_DHCP4_OPTION_ARCH;
131
132 typedef struct {
133 UINT8 ClassIdentifier[11];
134 UINT8 ArchitecturePrefix[5];
135 UINT8 ArchitectureType[5];
136 UINT8 Lit3[1];
137 UINT8 InterfaceName[4];
138 UINT8 Lit4[1];
139 UINT8 UndiMajor[3];
140 UINT8 UndiMinor[3];
141 } HTTP_BOOT_DHCP4_OPTION_CLID;
142
143 typedef struct {
144 UINT8 Type;
145 UINT8 Guid[16];
146 } HTTP_BOOT_DHCP4_OPTION_UUID;
147
148 typedef struct {
149 UINT16 Type;
150 UINT16 Layer;
151 } HTTP_BOOT_OPTION_BOOT_ITEM;
152
153 #pragma pack()
154
155 typedef union {
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;
164
165 #define GET_NEXT_DHCP_OPTION(Opt) \
166 (EFI_DHCP4_PACKET_OPTION *) ((UINT8 *) (Opt) + \
167 sizeof (EFI_DHCP4_PACKET_OPTION) + (Opt)->Length - 1)
168
169 #define GET_OPTION_BUFFER_LEN(Pkt) \
170 ((Pkt)->Length - sizeof (EFI_DHCP4_HEADER) - 4)
171
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
176
177 typedef struct {
178 UINT32 Reserved;
179 } HTTP_BOOT_VENDOR_OPTION;
180
181 #define HTTP_CACHED_DHCP4_PACKET_MAX_SIZE (OFFSET_OF (EFI_DHCP4_PACKET, Dhcp4) + HTTP_BOOT_DHCP4_PACKET_MAX_SIZE)
182
183 typedef union {
184 EFI_DHCP4_PACKET Offer;
185 EFI_DHCP4_PACKET Ack;
186 UINT8 Buffer[HTTP_CACHED_DHCP4_PACKET_MAX_SIZE];
187 } HTTP_BOOT_DHCP4_PACKET;
188
189 typedef struct {
190 //
191 // URI component
192 //
193 CHAR8 *Scheme;
194 CHAR8 *Authority;
195 CHAR8 *Path;
196 CHAR8 *Query;
197 CHAR8 *Fragment; /// TODO: may not required in HTTP URL
198
199 CHAR8 *RegName; /// Point to somewhere in Authority
200 BOOLEAN AddrIsOk;
201 EFI_IP_ADDRESS Address;
202 UINT16 Port;
203 } HTTP_BOOT_URI_CONTENT;
204
205 typedef struct {
206 HTTP_BOOT_DHCP4_PACKET Packet;
207 HTTP_BOOT_OFFER_TYPE OfferType;
208 VOID *UriParser;
209 EFI_DHCP4_PACKET_OPTION *OptList[HTTP_BOOT_DHCP4_TAG_INDEX_MAX];
210 } HTTP_BOOT_DHCP4_PACKET_CACHE;
211
212 /**
213 Select an DHCPv4 or DHCP6 offer, and record SelectIndex and SelectProxyType.
214
215 @param[in] Private Pointer to HTTP boot driver private data.
216
217 **/
218 VOID
219 HttpBootSelectDhcpOffer (
220 IN HTTP_BOOT_PRIVATE_DATA *Private
221 );
222
223 /**
224 Start the D.O.R.A DHCPv4 process to acquire the IPv4 address and other Http boot information.
225
226 @param[in] Private Pointer to HTTP_BOOT private data.
227
228 @retval EFI_SUCCESS The D.O.R.A process successfully finished.
229 @retval Others Failed to finish the D.O.R.A process.
230
231 **/
232 EFI_STATUS
233 HttpBootDhcp4Dora (
234 IN HTTP_BOOT_PRIVATE_DATA *Private
235 );
236
237 /**
238 This function will register the default DNS addresses to the network device.
239
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.
244
245 @retval EFI_SUCCESS The DNS configuration has been configured successfully.
246 @retval Others Failed to configure the address.
247
248 **/
249 EFI_STATUS
250 HttpBootRegisterIp4Dns (
251 IN HTTP_BOOT_PRIVATE_DATA *Private,
252 IN UINTN DataLength,
253 IN VOID *DnsServerData
254 );
255
256 #endif