]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Protocol/Dhcp4.h
Code have been checked with spec
[mirror_edk2.git] / MdePkg / Include / Protocol / Dhcp4.h
CommitLineData
d1f95000 1/** @file\r
2 EFI_DHCP4_PROTOCOL as defined in UEFI 2.0.\r
3 EFI_DHCP4_SERVICE_BINDING_PROTOCOL as defined in UEFI 2.0.\r
305a1279 4 These protocols are used to collect configuration information for the EFI IPv4 Protocol\r
d1f95000 5 drivers and to provide DHCPv4 server and PXE boot server discovery services.\r
6\r
4ca9b6c4 7 Copyright (c) 2006 - 2008, Intel Corporation\r
305a1279 8 All rights reserved. This program and the accompanying materials\r
9 are licensed and made available under the terms and conditions of the BSD License\r
10 which accompanies this distribution. The full text of the license may be found at\r
11 http://opensource.org/licenses/bsd-license.php\r
d1f95000 12\r
305a1279 13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
d1f95000 15\r
d1f95000 16**/\r
17\r
18#ifndef __EFI_DHCP4_PROTOCOL_H__\r
19#define __EFI_DHCP4_PROTOCOL_H__\r
20\r
21#define EFI_DHCP4_PROTOCOL_GUID \\r
22 { \\r
23 0x8a219718, 0x4ef5, 0x4761, {0x91, 0xc8, 0xc0, 0xf0, 0x4b, 0xda, 0x9e, 0x56 } \\r
24 }\r
25\r
26#define EFI_DHCP4_SERVICE_BINDING_PROTOCOL_GUID \\r
27 { \\r
28 0x9d9a39d8, 0xbd42, 0x4a73, {0xa4, 0xd5, 0x8e, 0xe9, 0x4b, 0xe1, 0x13, 0x80 } \\r
29 }\r
305a1279 30\r
d1f95000 31typedef struct _EFI_DHCP4_PROTOCOL EFI_DHCP4_PROTOCOL;\r
32\r
33\r
34#pragma pack(1)\r
35typedef struct {\r
74fec708
LG
36 ///\r
37 /// DHCP option code.\r
38 ///\r
d1f95000 39 UINT8 OpCode;\r
74fec708
LG
40 ///\r
41 /// Length of the DHCP option data. Not present if OpCode is 0 or 255.\r
42 ///\r
d1f95000 43 UINT8 Length;\r
74fec708
LG
44 ///\r
45 /// Start of the DHCP option data. Not present if OpCode is 0 or 255 or if Length is zero.\r
46 ///\r
d1f95000 47 UINT8 Data[1];\r
48} EFI_DHCP4_PACKET_OPTION;\r
49#pragma pack()\r
50\r
51\r
52#pragma pack(1)\r
74fec708
LG
53///\r
54/// EFI_DHCP4_PACKET defines the format of DHCPv4 packets. See RFC 2131 for more information.\r
55///\r
d1f95000 56typedef struct {\r
74fec708
LG
57 UINT8 OpCode;\r
58 UINT8 HwType;\r
59 UINT8 HwAddrLen;\r
60 UINT8 Hops;\r
61 UINT32 Xid;\r
62 UINT16 Seconds;\r
63 UINT16 Reserved;\r
64 EFI_IPv4_ADDRESS ClientAddr; ///< Client IP address from client\r
65 EFI_IPv4_ADDRESS YourAddr; ///< Client IP address from server\r
66 EFI_IPv4_ADDRESS ServerAddr; ///< IP address of next server in bootstrap\r
67 EFI_IPv4_ADDRESS GatewayAddr; ///< Relay agent IP address\r
68 UINT8 ClientHwAddr[16]; ///< Client hardware address\r
69 CHAR8 ServerName[64];\r
70 CHAR8 BootFileName[128];\r
d1f95000 71}EFI_DHCP4_HEADER;\r
72#pragma pack()\r
73\r
74\r
75#pragma pack(1)\r
76typedef struct {\r
74fec708
LG
77 ///\r
78 /// Size of the EFI_DHCP4_PACKET buffer.\r
79 ///\r
d1f95000 80 UINT32 Size;\r
74fec708
LG
81 ///\r
82 /// Length of the EFI_DHCP4_PACKET from the first byte of the Header field \r
83 /// to the last byte of the Option[] field.\r
84 ///\r
d1f95000 85 UINT32 Length;\r
86\r
87 struct {\r
74fec708
LG
88 ///\r
89 /// DHCP packet header.\r
90 ///\r
d1f95000 91 EFI_DHCP4_HEADER Header;\r
74fec708
LG
92 ///\r
93 /// DHCP magik cookie in network byte order.\r
94 ///\r
d1f95000 95 UINT32 Magik;\r
74fec708
LG
96 ///\r
97 /// Start of the DHCP packed option data.\r
98 ///\r
d1f95000 99 UINT8 Option[1];\r
100 } Dhcp4;\r
101} EFI_DHCP4_PACKET;\r
102#pragma pack()\r
103\r
104\r
105typedef enum {\r
74fec708
LG
106 ///\r
107 /// The EFI DHCPv4 Protocol driver is stopped\r
108 ///\r
d1f95000 109 Dhcp4Stopped = 0x0,\r
74fec708
LG
110 ///\r
111 /// The EFI DHCPv4 Protocol driver is inactive\r
112 ///\r
d1f95000 113 Dhcp4Init = 0x1,\r
74fec708
LG
114 ///\r
115 /// The EFI DHCPv4 Protocol driver is collecting DHCP offer packets from DHCP servers.\r
116 ///\r
d1f95000 117 Dhcp4Selecting = 0x2,\r
74fec708
LG
118 ///\r
119 /// The EFI DHCPv4 Protocol driver has sent the request to the DHCP server and is waiting for a response.\r
120 ///\r
d1f95000 121 Dhcp4Requesting = 0x3,\r
74fec708
LG
122 ///\r
123 /// The DHCP configuration has completed.\r
124 ///\r
d1f95000 125 Dhcp4Bound = 0x4,\r
74fec708
LG
126 ///\r
127 /// The DHCP configuration is being renewed and another request has\r
128 /// been sent out, but it has not received a response from the server yet.\r
129 ///\r
d1f95000 130 Dhcp4Renewing = 0x5,\r
74fec708
LG
131 ///\r
132 /// The DHCP configuration has timed out and the EFI DHCPv4\r
133 /// Protocol driver is trying to extend the lease time.\r
134 ///\r
d1f95000 135 Dhcp4Rebinding = 0x6,\r
74fec708
LG
136 ///\r
137 /// The EFI DHCPv4 Protocol driver is initialized with a previously\r
138 /// allocated or known IP address.\r
139 ///\r
d1f95000 140 Dhcp4InitReboot = 0x7,\r
74fec708
LG
141 ///\r
142 /// The EFI DHCPv4 Protocol driver is seeking to reuse the previously\r
143 /// allocated IP address by sending a request to the DHCP server.\r
144 ///\r
d1f95000 145 Dhcp4Rebooting = 0x8\r
146} EFI_DHCP4_STATE;\r
147\r
148\r
149typedef enum{\r
74fec708
LG
150 ///\r
151 /// A DHCPDISCOVER packet is about to be sent.\r
152 ///\r
d1f95000 153 Dhcp4SendDiscover = 0x01,\r
74fec708
LG
154 ///\r
155 /// A DHCPOFFER packet was just received.\r
156 ///\r
d1f95000 157 Dhcp4RcvdOffer = 0x02,\r
74fec708
LG
158 ///\r
159 /// It is time for Dhcp4Callback to select an offer.\r
160 ///\r
d1f95000 161 Dhcp4SelectOffer = 0x03,\r
74fec708
LG
162 ///\r
163 /// A request packet is about to be sent.\r
164 ///\r
d1f95000 165 Dhcp4SendRequest = 0x04,\r
74fec708
LG
166 ///\r
167 /// A DHCPACK packet was received and will be passed to Dhcp4Callback.\r
168 ///\r
d1f95000 169 Dhcp4RcvdAck = 0x05,\r
74fec708
LG
170 ///\r
171 /// A DHCPNAK packet was received and will be passed to Dhcp4Callback.\r
172 ///\r
d1f95000 173 Dhcp4RcvdNak = 0x06,\r
74fec708
LG
174 ///\r
175 /// A decline packet is about to be sent.\r
176 ///\r
d1f95000 177 Dhcp4SendDecline = 0x07,\r
74fec708
LG
178 ///\r
179 /// The DHCP configuration process has completed. No packet is associated with this event.\r
180 ///\r
d1f95000 181 Dhcp4BoundCompleted = 0x08,\r
74fec708
LG
182 ///\r
183 /// It is time to enter the Dhcp4Renewing state and to contact the server \r
184 /// that originally issued the network address. No packet is associated with this event.\r
185 ///\r
d1f95000 186 Dhcp4EnterRenewing = 0x09,\r
74fec708
LG
187 ///\r
188 /// It is time to enter the Dhcp4Rebinding state and to contact any server. \r
189 /// No packet is associated with this event.\r
190 ///\r
d1f95000 191 Dhcp4EnterRebinding = 0x0a,\r
74fec708
LG
192 ///\r
193 /// The configured IP address was lost either because the lease has expired, \r
194 /// the user released the configuration, or a DHCPNAK packet was received in \r
195 /// the Dhcp4Renewing or Dhcp4Rebinding state. No packet is associated with this event.\r
196 ///\r
d1f95000 197 Dhcp4AddressLost = 0x0b,\r
74fec708
LG
198 ///\r
199 /// The DHCP process failed because a DHCPNAK packet was received or the user \r
200 /// aborted the DHCP process at a time when the configuration was not available yet. \r
201 /// No packet is associated with this event.\r
202 ///\r
d1f95000 203 Dhcp4Fail = 0x0c\r
204} EFI_DHCP4_EVENT;\r
205\r
305a1279 206/**\r
faac3f0c 207 Callback routine.\r
208 \r
209 EFI_DHCP4_CALLBACK is provided by the consumer of the EFI DHCPv4 Protocol driver\r
210 to intercept events that occurred in the configuration process. This structure\r
211 provides advanced control of each state transition of the DHCP process. The\r
212 returned status code determines the behavior of the EFI DHCPv4 Protocol driver.\r
213 There are three possible returned values, which are described in the following\r
214 table.\r
305a1279 215\r
d1f95000 216 @param This Pointer to the EFI DHCPv4 Protocol instance that is used to\r
305a1279 217 configure this callback function.\r
d1f95000 218 @param Context Pointer to the context that is initialized by\r
305a1279 219 EFI_DHCP4_PROTOCOL.Configure().\r
d1f95000 220 @param CurrentState The current operational state of the EFI DHCPv4 Protocol\r
305a1279 221 driver.\r
d1f95000 222 @param Dhcp4Event The event that occurs in the current state, which usually means a\r
305a1279 223 state transition.\r
224 @param Packet The DHCP packet that is going to be sent or already received.\r
d1f95000 225 @param NewPacket The packet that is used to replace the above Packet.\r
305a1279 226\r
d1f95000 227 @retval EFI_SUCCESS Tells the EFI DHCPv4 Protocol driver to continue the DHCP process.\r
305a1279 228 @retval EFI_NOT_READY Only used in the Dhcp4Selecting state. The EFI DHCPv4 Protocol\r
d1f95000 229 driver will continue to wait for more DHCPOFFER packets until the retry\r
305a1279 230 timeout expires.\r
d1f95000 231 @retval EFI_ABORTED Tells the EFI DHCPv4 Protocol driver to abort the current process and\r
305a1279 232 return to the Dhcp4Init or Dhcp4InitReboot state.\r
233\r
d1f95000 234**/\r
305a1279 235typedef\r
236EFI_STATUS\r
8b13229b 237(EFIAPI *EFI_DHCP4_CALLBACK)(\r
d1f95000 238 IN EFI_DHCP4_PROTOCOL *This,\r
239 IN VOID *Context,\r
240 IN EFI_DHCP4_STATE CurrentState,\r
241 IN EFI_DHCP4_EVENT Dhcp4Event,\r
305a1279 242 IN EFI_DHCP4_PACKET *Packet OPTIONAL,\r
d1f95000 243 OUT EFI_DHCP4_PACKET **NewPacket OPTIONAL\r
244 );\r
245\r
d1f95000 246typedef struct {\r
74fec708
LG
247 ///\r
248 /// Number of times to try sending DHCPDISCOVER packets and \r
249 /// waiting for DHCPOFFER packets before accepting failure.\r
250 /// Set to zero to use the default try counts and timeout values.\r
251 ///\r
305a1279 252 UINT32 DiscoverTryCount;\r
74fec708
LG
253 ///\r
254 /// Maximum amount of time (in seconds) to wait for DHCPOFFER packets in each \r
255 /// of the retries. Timeout values of zero will default to a timeout value \r
256 /// of one second. Set to NULL to use default timeout values.\r
257 ///\r
d1f95000 258 UINT32 *DiscoverTimeout;\r
74fec708
LG
259 ///\r
260 /// Number of times to try sending DHCPREQUEST packets and waiting for DHCPACK \r
261 /// packets before accepting failure. Set to zero to use the default try counts and timeout values.\r
262 ///\r
d1f95000 263 UINT32 RequestTryCount;\r
74fec708
LG
264 ///\r
265 /// Maximum amount of time (in seconds) to wait for DHCPACK packets in each of the retries. \r
266 /// Timeout values of zero will default to a timeout value of one second. \r
267 /// Set to NULL to use default timeout values.\r
268 ///\r
d1f95000 269 UINT32 *RequestTimeout;\r
74fec708
LG
270 ///\r
271 /// Setting this parameter to the previously allocated IP address will cause \r
272 /// the EFI DHCPv4 Protocol driver to enter the Dhcp4InitReboot state. \r
273 /// Set this field to 0.0.0.0 to enter the Dhcp4Init state.\r
274 ///\r
d1f95000 275 EFI_IPv4_ADDRESS ClientAddress;\r
74fec708
LG
276 ///\r
277 /// The callback function to intercept various events that occurred in \r
278 /// the DHCP configuration process. Set to NULL to ignore all those events.\r
279 ///\r
d1f95000 280 EFI_DHCP4_CALLBACK Dhcp4Callback;\r
74fec708
LG
281 ///\r
282 /// Pointer to the context that will be passed to Dhcp4Callback when it is called.\r
283 ///\r
284 VOID *CallbackContext;\r
285 ///\r
286 /// Number of DHCP options in the OptionList.\r
287 ///\r
d1f95000 288 UINT32 OptionCount;\r
74fec708
LG
289 ///\r
290 /// List of DHCP options to be included in every DHCPDISCOVER packet and \r
291 /// subsequent DHCPREQUEST packet that is generated from DHCPOFFER packets.\r
292 ///\r
d1f95000 293 EFI_DHCP4_PACKET_OPTION **OptionList;\r
294} EFI_DHCP4_CONFIG_DATA;\r
295\r
296\r
297typedef struct {\r
74fec708
LG
298 ///\r
299 /// The EFI DHCPv4 Protocol driver operating state. \r
300 ///\r
d1f95000 301 EFI_DHCP4_STATE State;\r
74fec708
LG
302 ///\r
303 /// The configuration data of the current EFI DHCPv4 Protocol driver instance.\r
304 ///\r
d1f95000 305 EFI_DHCP4_CONFIG_DATA ConfigData;\r
74fec708
LG
306 ///\r
307 /// The client IP address that was acquired from the DHCP server. If it is zero,\r
308 /// the DHCP acquisition has not completed yet and the following fields in this structure are undefined.\r
309 ///\r
d1f95000 310 EFI_IPv4_ADDRESS ClientAddress;\r
74fec708
LG
311 ///\r
312 /// The local hardware address.\r
313 ///\r
d1f95000 314 EFI_MAC_ADDRESS ClientMacAddress;\r
74fec708
LG
315 ///\r
316 /// The server IP address that is providing the DHCP service to this client.\r
317 ///\r
d1f95000 318 EFI_IPv4_ADDRESS ServerAddress;\r
74fec708
LG
319 ///\r
320 /// The router IP address that was acquired from the DHCP server. \r
321 /// May be zero if the server does not offer this address.\r
322 ///\r
d1f95000 323 EFI_IPv4_ADDRESS RouterAddress;\r
74fec708
LG
324 ///\r
325 /// The subnet mask of the connected network that was acquired from the DHCP server.\r
326 ///\r
d1f95000 327 EFI_IPv4_ADDRESS SubnetMask;\r
74fec708
LG
328 ///\r
329 /// The lease time (in 1-second units) of the configured IP address. \r
330 /// The value 0xFFFFFFFF means that the lease time is infinite. \r
331 /// A default lease of 7 days is used if the DHCP server does not provide a value.\r
332 ///\r
d1f95000 333 UINT32 LeaseTime;\r
74fec708
LG
334 ///\r
335 /// The cached latest DHCPACK or DHCPNAK or BOOTP REPLY packet. May be NULL if no packet is cached.\r
336 ///\r
d1f95000 337 EFI_DHCP4_PACKET *ReplyPacket;\r
338} EFI_DHCP4_MODE_DATA;\r
339\r
340\r
341typedef struct {\r
74fec708
LG
342 ///\r
343 /// Alternate listening address. It can be a unicast, multicast, or broadcast address.\r
344 ///\r
d1f95000 345 EFI_IPv4_ADDRESS ListenAddress;\r
74fec708
LG
346 ///\r
347 /// The subnet mask of above listening unicast/broadcast IP address. \r
348 /// Ignored if ListenAddress is a multicast address.\r
349 ///\r
d1f95000 350 EFI_IPv4_ADDRESS SubnetMask;\r
74fec708
LG
351 ///\r
352 /// Alternate station source (or listening) port number. \r
353 /// If zero, then the default station port number (68) will be used.\r
354 ///\r
d1f95000 355 UINT16 ListenPort;\r
356} EFI_DHCP4_LISTEN_POINT;\r
357\r
358\r
359typedef struct {\r
74fec708
LG
360 ///\r
361 /// The completion status of transmitting and receiving.\r
362 ///\r
305a1279 363 EFI_STATUS Status;\r
74fec708
LG
364 ///\r
365 /// If not NULL, the event that will be signaled when the collection process \r
366 /// completes. If NULL, this function will busy-wait until the collection process competes.\r
367 ///\r
305a1279 368 EFI_EVENT CompletionEvent;\r
74fec708
LG
369 ///\r
370 /// Pointer to the server IP address. This address may be a unicast, multicast, or broadcast address.\r
371 ///\r
305a1279 372 EFI_IPv4_ADDRESS RemoteAddress;\r
74fec708
LG
373 ///\r
374 /// Server listening port number. If zero, the default server listening port number (67) will be used.\r
375 ///\r
305a1279 376 UINT16 RemotePort;\r
74fec708
LG
377 ///\r
378 /// Pointer to the gateway address to override the existing setting.\r
379 ///\r
305a1279 380 EFI_IPv4_ADDRESS GatewayAddress;\r
74fec708
LG
381 ///\r
382 /// The number of entries in ListenPoints. If zero, the default station address and port number 68 are used.\r
383 ///\r
305a1279 384 UINT32 ListenPointCount;\r
74fec708
LG
385 ///\r
386 /// An array of station address and port number pairs that are used as receiving filters. \r
387 /// The first entry is also used as the source address and source port of the outgoing packet.\r
388 ///\r
305a1279 389 EFI_DHCP4_LISTEN_POINT *ListenPoints;\r
74fec708
LG
390 ///\r
391 /// Number of seconds to collect responses. Zero is invalid.\r
392 ///\r
305a1279 393 UINT32 TimeoutValue;\r
74fec708
LG
394 ///\r
395 /// Pointer to the packet to be transmitted.\r
396 ///\r
305a1279 397 EFI_DHCP4_PACKET *Packet;\r
74fec708
LG
398 ///\r
399 /// Number of received packets.\r
400 ///\r
305a1279 401 UINT32 ResponseCount;\r
74fec708
LG
402 ///\r
403 /// Pointer to the allocated list of received packets.\r
404 ///\r
305a1279 405 EFI_DHCP4_PACKET *ResponseList;\r
d1f95000 406} EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN;\r
407\r
408\r
409/**\r
410 Returns the current operating mode and cached data packet for the EFI DHCPv4 Protocol driver.\r
faac3f0c 411 \r
412 The GetModeData() function returns the current operating mode and cached data\r
413 packet for the EFI DHCPv4 Protocol driver.\r
d1f95000 414\r
415 @param This Pointer to the EFI_DHCP4_PROTOCOL instance.\r
416 @param Dhcp4ModeData Pointer to storage for the EFI_DHCP4_MODE_DATA structure.\r
417\r
418 @retval EFI_SUCCESS The mode data was returned.\r
419 @retval EFI_INVALID_PARAMETER This is NULL.\r
420\r
421**/\r
305a1279 422typedef\r
423EFI_STATUS\r
8b13229b 424(EFIAPI *EFI_DHCP4_GET_MODE_DATA)(\r
d1f95000 425 IN EFI_DHCP4_PROTOCOL *This,\r
426 OUT EFI_DHCP4_MODE_DATA *Dhcp4ModeData\r
ed66e1bc 427 );\r
d1f95000 428\r
429/**\r
430 Initializes, changes, or resets the operational settings for the EFI DHCPv4 Protocol driver.\r
431\r
faac3f0c 432 The Configure() function is used to initialize, change, or reset the operational\r
433 settings of the EFI DHCPv4 Protocol driver for the communication device on which\r
434 the EFI DHCPv4 Service Binding Protocol is installed. This function can be\r
435 successfully called only if both of the following are true:\r
436 * This instance of the EFI DHCPv4 Protocol driver is in the Dhcp4Stopped, Dhcp4Init,\r
437 Dhcp4InitReboot, or Dhcp4Bound states.\r
438 * No other EFI DHCPv4 Protocol driver instance that is controlled by this EFI\r
439 DHCPv4 Service Binding Protocol driver instance has configured this EFI DHCPv4\r
440 Protocol driver.\r
441 When this driver is in the Dhcp4Stopped state, it can transfer into one of the\r
442 following two possible initial states:\r
443 * Dhcp4Init\r
444 * Dhcp4InitReboot\r
445 The driver can transfer into these states by calling Configure() with a non-NULL\r
446 Dhcp4CfgData. The driver will transfer into the appropriate state based on the\r
447 supplied client network address in the ClientAddress parameter and DHCP options\r
448 in the OptionList parameter as described in RFC 2131.\r
449 When Configure() is called successfully while Dhcp4CfgData is set to NULL, the\r
450 default configuring data will be reset in the EFI DHCPv4 Protocol driver and\r
451 the state of the EFI DHCPv4 Protocol driver will not be changed. If one instance\r
452 wants to make it possible for another instance to configure the EFI DHCPv4 Protocol\r
453 driver, it must call this function with Dhcp4CfgData set to NULL.\r
454\r
d1f95000 455 @param This Pointer to the EFI_DHCP4_PROTOCOL instance.\r
456 @param Dhcp4CfgData Pointer to the EFI_DHCP4_CONFIG_DATA.\r
457\r
458 @retval EFI_SUCCESS The EFI DHCPv4 Protocol driver is now in the Dhcp4Init or\r
459 Dhcp4InitReboot state, if the original state of this driver\r
460 was Dhcp4Stopped and the value of Dhcp4CfgData was\r
461 not NULL. Otherwise, the state was left unchanged.\r
462 @retval EFI_ACCESS_DENIED This instance of the EFI DHCPv4 Protocol driver was not in the\r
463 Dhcp4Stopped, Dhcp4Init, Dhcp4InitReboot, or Dhcp4Bound state;\r
464 Or onother instance of this EFI DHCPv4 Protocol driver is already\r
465 in a valid configured state.\r
74fec708
LG
466 @retval EFI_INVALID_PARAMETER One or more following conditions are TRUE:\r
467 This is NULL.\r
468 DiscoverTryCount > 0 and DiscoverTimeout is NULL\r
469 RequestTryCount > 0 and RequestTimeout is NULL.\r
470 OptionCount >0 and OptionList is NULL.\r
471 ClientAddress is not a valid unicast address.\r
d1f95000 472 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.\r
473 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
474\r
475**/\r
305a1279 476typedef\r
d1f95000 477EFI_STATUS\r
8b13229b 478(EFIAPI *EFI_DHCP4_CONFIGURE)(\r
d1f95000 479 IN EFI_DHCP4_PROTOCOL *This,\r
480 IN EFI_DHCP4_CONFIG_DATA *Dhcp4CfgData OPTIONAL\r
ed66e1bc 481 );\r
d1f95000 482\r
483\r
484/**\r
485 Starts the DHCP configuration process.\r
486\r
faac3f0c 487 The Start() function starts the DHCP configuration process. This function can\r
488 be called only when the EFI DHCPv4 Protocol driver is in the Dhcp4Init or\r
489 Dhcp4InitReboot state.\r
490 If the DHCP process completes successfully, the state of the EFI DHCPv4 Protocol\r
491 driver will be transferred through Dhcp4Selecting and Dhcp4Requesting to the\r
492 Dhcp4Bound state. The CompletionEvent will then be signaled if it is not NULL.\r
493 If the process aborts, either by the user or by some unexpected network error,\r
494 the state is restored to the Dhcp4Init state. The Start() function can be called\r
495 again to restart the process.\r
496 Refer to RFC 2131 for precise state transitions during this process. At the\r
497 time when each event occurs in this process, the callback function that was set\r
498 by EFI_DHCP4_PROTOCOL.Configure() will be called and the user can take this\r
499 opportunity to control the process.\r
500 \r
d1f95000 501 @param This Pointer to the EFI_DHCP4_PROTOCOL instance.\r
502 @param CompletionEvent If not NULL, indicates the event that will be signaled when the\r
503 EFI DHCPv4 Protocol driver is transferred into the\r
504 Dhcp4Bound state or when the DHCP process is aborted.\r
505 EFI_DHCP4_PROTOCOL.GetModeData() can be called to\r
506 check the completion status. If NULL,\r
507 EFI_DHCP4_PROTOCOL.Start() will wait until the driver\r
508 is transferred into the Dhcp4Bound state or the process fails.\r
509\r
510 @retval EFI_SUCCESS The DHCP configuration process has started, or it has completed\r
511 when CompletionEvent is NULL.\r
512 @retval EFI_NOT_STARTED The EFI DHCPv4 Protocol driver is in the Dhcp4Stopped\r
513 state. EFI_DHCP4_PROTOCOL. Configure() needs to be called.\r
514 @retval EFI_INVALID_PARAMETER This is NULL.\r
515 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.\r
516 @retval EFI_TIMEOUT The DHCP configuration process failed because no response was\r
517 received from the server within the specified timeout value.\r
518 @retval EFI_ABORTED The user aborted the DHCP process.\r
519 @retval EFI_ALREADY_STARTED Some other EFI DHCPv4 Protocol instance already started the\r
520 DHCP process.\r
521 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
522\r
523**/\r
305a1279 524typedef\r
d1f95000 525EFI_STATUS\r
8b13229b 526(EFIAPI *EFI_DHCP4_START)(\r
d1f95000 527 IN EFI_DHCP4_PROTOCOL *This,\r
528 IN EFI_EVENT CompletionEvent OPTIONAL\r
ed66e1bc 529 );\r
d1f95000 530\r
531/**\r
532 Extends the lease time by sending a request packet.\r
faac3f0c 533 \r
534 The RenewRebind() function is used to manually extend the lease time when the\r
535 EFI DHCPv4 Protocol driver is in the Dhcp4Bound state and the lease time has\r
536 not expired yet. This function will send a request packet to the previously\r
537 found server (or to any server when RebindRequest is TRUE) and transfer the\r
538 state into the Dhcp4Renewing state (or Dhcp4Rebinding when RebindingRequest is\r
539 TRUE). When a response is received, the state is returned to Dhcp4Bound.\r
540 If no response is received before the try count is exceeded (the RequestTryCount\r
541 field that is specified in EFI_DHCP4_CONFIG_DATA) but before the lease time that\r
542 was issued by the previous server expires, the driver will return to the Dhcp4Bound\r
543 state and the previous configuration is restored. The outgoing and incoming packets\r
544 can be captured by the EFI_DHCP4_CALLBACK function.\r
d1f95000 545\r
546 @param This Pointer to the EFI_DHCP4_PROTOCOL instance.\r
547 @param RebindRequest If TRUE, this function broadcasts the request packets and enters\r
548 the Dhcp4Rebinding state. Otherwise, it sends a unicast\r
549 request packet and enters the Dhcp4Renewing state.\r
550 @param CompletionEvent If not NULL, this event is signaled when the renew/rebind phase\r
551 completes or some error occurs.\r
552 EFI_DHCP4_PROTOCOL.GetModeData() can be called to\r
553 check the completion status. If NULL,\r
554 EFI_DHCP4_PROTOCOL.RenewRebind() will busy-wait\r
555 until the DHCP process finishes.\r
556\r
557 @retval EFI_SUCCESS The EFI DHCPv4 Protocol driver is now in the\r
558 Dhcp4Renewing state or is back to the Dhcp4Bound state.\r
559 @retval EFI_NOT_STARTED The EFI DHCPv4 Protocol driver is in the Dhcp4Stopped\r
560 state. EFI_DHCP4_PROTOCOL.Configure() needs to\r
561 be called.\r
562 @retval EFI_INVALID_PARAMETER This is NULL.\r
563 @retval EFI_TIMEOUT There was no response from the server when the try count was\r
564 exceeded.\r
565 @retval EFI_ACCESS_DENIED The driver is not in the Dhcp4Bound state.\r
566 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
567\r
568**/\r
569typedef\r
570EFI_STATUS\r
8b13229b 571(EFIAPI *EFI_DHCP4_RENEW_REBIND)(\r
d1f95000 572 IN EFI_DHCP4_PROTOCOL *This,\r
573 IN BOOLEAN RebindRequest,\r
574 IN EFI_EVENT CompletionEvent OPTIONAL\r
ed66e1bc 575 );\r
d1f95000 576\r
577/**\r
578 Releases the current address configuration.\r
579\r
faac3f0c 580 The Release() function releases the current configured IP address by doing either\r
581 of the following:\r
582 * Sending a DHCPRELEASE packet when the EFI DHCPv4 Protocol driver is in the\r
583 Dhcp4Bound state\r
584 * Setting the previously assigned IP address that was provided with the\r
585 EFI_DHCP4_PROTOCOL.Configure() function to 0.0.0.0 when the driver is in\r
586 Dhcp4InitReboot state\r
587 After a successful call to this function, the EFI DHCPv4 Protocol driver returns\r
588 to the Dhcp4Init state and any subsequent incoming packets will be discarded silently.\r
589\r
d1f95000 590 @param This Pointer to the EFI_DHCP4_PROTOCOL instance.\r
591\r
592 @retval EFI_SUCCESS The EFI DHCPv4 Protocol driver is now in the Dhcp4Init phase.\r
593 @retval EFI_INVALID_PARAMETER This is NULL.\r
594 @retval EFI_ACCESS_DENIED The EFI DHCPv4 Protocol driver is not Dhcp4InitReboot state.\r
595 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
596\r
597**/\r
305a1279 598typedef\r
d1f95000 599EFI_STATUS\r
8b13229b 600(EFIAPI *EFI_DHCP4_RELEASE)(\r
d1f95000 601 IN EFI_DHCP4_PROTOCOL *This\r
ed66e1bc 602 );\r
d1f95000 603\r
604/**\r
605 Stops the current address configuration.\r
faac3f0c 606 \r
607 The Stop() function is used to stop the DHCP configuration process. After this\r
608 function is called successfully, the EFI DHCPv4 Protocol driver is transferred\r
609 into the Dhcp4Stopped state. EFI_DHCP4_PROTOCOL.Configure() needs to be called\r
610 before DHCP configuration process can be started again. This function can be\r
611 called when the EFI DHCPv4 Protocol driver is in any state.\r
d1f95000 612\r
613 @param This Pointer to the EFI_DHCP4_PROTOCOL instance.\r
305a1279 614\r
d1f95000 615 @retval EFI_SUCCESS The EFI DHCPv4 Protocol driver is now in the Dhcp4Stopped phase.\r
616 @retval EFI_INVALID_PARAMETER This is NULL.\r
617\r
618**/\r
305a1279 619typedef\r
d1f95000 620EFI_STATUS\r
8b13229b 621(EFIAPI *EFI_DHCP4_STOP)(\r
d1f95000 622 IN EFI_DHCP4_PROTOCOL *This\r
ed66e1bc 623 );\r
d1f95000 624\r
625/**\r
626 Builds a DHCP packet, given the options to be appended or deleted or replaced.\r
627\r
faac3f0c 628 The Build() function is used to assemble a new packet from the original packet\r
629 by replacing or deleting existing options or appending new options. This function\r
630 does not change any state of the EFI DHCPv4 Protocol driver and can be used at\r
631 any time.\r
632\r
d1f95000 633 @param This Pointer to the EFI_DHCP4_PROTOCOL instance.\r
eecd469b 634 @param SeedPacket Initial packet to be used as a base for building new packet.\r
d1f95000 635 @param DeleteCount Number of opcodes in the DeleteList.\r
636 @param DeleteList List of opcodes to be deleted from the seed packet.\r
637 Ignored if DeleteCount is zero.\r
638 @param AppendCount Number of entries in the OptionList.\r
639 @param AppendList Pointer to a DHCP option list to be appended to SeedPacket.\r
640 If SeedPacket also contains options in this list, they are\r
641 replaced by new options (except pad option). Ignored if\r
642 AppendCount is zero. Type EFI_DHCP4_PACKET_OPTION\r
643 @param NewPacket Pointer to storage for the pointer to the new allocated packet.\r
644 Use the EFI Boot Service FreePool() on the resulting pointer\r
645 when done with the packet.\r
646\r
647 @retval EFI_SUCCESS The new packet was built.\r
648 @retval EFI_OUT_OF_RESOURCES Storage for the new packet could not be allocated.\r
74fec708
LG
649 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
650 This is NULL.\r
651 SeedPacket is NULL.\r
652 SeedPacket is not a well-formed DHCP packet.\r
653 AppendCount is not zero and AppendList is NULL.\r
654 DeleteCount is not zero and DeleteList is NULL.\r
655 NewPacket is NULL\r
656 Both DeleteCount and AppendCount are zero and\r
657 NewPacket is not NULL.\r
d1f95000 658\r
659**/\r
660typedef\r
661EFI_STATUS\r
8b13229b 662(EFIAPI *EFI_DHCP4_BUILD)(\r
d1f95000 663 IN EFI_DHCP4_PROTOCOL *This,\r
664 IN EFI_DHCP4_PACKET *SeedPacket,\r
665 IN UINT32 DeleteCount,\r
666 IN UINT8 *DeleteList OPTIONAL,\r
667 IN UINT32 AppendCount,\r
668 IN EFI_DHCP4_PACKET_OPTION *AppendList[] OPTIONAL,\r
669 OUT EFI_DHCP4_PACKET **NewPacket\r
ed66e1bc 670 );\r
faac3f0c 671\r
672\r
d1f95000 673/**\r
674 Transmits a DHCP formatted packet and optionally waits for responses.\r
faac3f0c 675 \r
676 The TransmitReceive() function is used to transmit a DHCP packet and optionally\r
677 wait for the response from servers. This function does not change the state of\r
678 the EFI DHCPv4 Protocol driver and thus can be used at any time.\r
d1f95000 679\r
680 @param This Pointer to the EFI_DHCP4_PROTOCOL instance.\r
681 @param Token Pointer to the EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN structure.\r
682\r
683 @retval EFI_SUCCESS The packet was successfully queued for transmission.\r
74fec708
LG
684 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
685 This is NULL.\r
686 Token.RemoteAddress is zero.\r
687 Token.Packet is NULL.\r
688 Token.Packet is not a well-formed DHCP packet.\r
689 The transaction ID in Token.Packet is in use by another DHCP process.\r
d1f95000 690 @retval EFI_NOT_READY The previous call to this function has not finished yet. Try to call\r
691 this function after collection process completes.\r
692 @retval EFI_NO_MAPPING The default station address is not available yet.\r
693 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.\r
ff7630cc 694 @retval EFI_UNSUPPORTED The implementation doesn't support this function\r
d1f95000 695 @retval Others Some other unexpected error occurred.\r
696\r
697**/\r
305a1279 698typedef\r
d1f95000 699EFI_STATUS\r
8b13229b 700(EFIAPI *EFI_DHCP4_TRANSMIT_RECEIVE)(\r
d1f95000 701 IN EFI_DHCP4_PROTOCOL *This,\r
702 IN EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN *Token\r
ed66e1bc 703 );\r
d1f95000 704\r
705\r
706/**\r
707 Parses the packed DHCP option data.\r
faac3f0c 708 \r
709 The Parse() function is used to retrieve the option list from a DHCP packet.\r
ff7630cc 710 If *OptionCount isn't zero, and there is enough space for all the DHCP options\r
faac3f0c 711 in the Packet, each element of PacketOptionList is set to point to somewhere in\r
712 the Packet->Dhcp4.Option where a new DHCP option begins. If RFC3396 is supported,\r
713 the caller should reassemble the parsed DHCP options to get the finial result.\r
ff7630cc 714 If *OptionCount is zero or there isn't enough space for all of them, the number\r
faac3f0c 715 of DHCP options in the Packet is returned in OptionCount.\r
d1f95000 716\r
717 @param This Pointer to the EFI_DHCP4_PROTOCOL instance.\r
718 @param Packet Pointer to packet to be parsed.\r
719 @param OptionCount On input, the number of entries in the PacketOptionList.\r
720 On output, the number of entries that were written into the\r
721 PacketOptionList.\r
722 @param PacketOptionList List of packet option entries to be filled in. End option or pad\r
723 options are not included.\r
724\r
725 @retval EFI_SUCCESS The packet was successfully parsed.\r
74fec708
LG
726 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
727 This is NULL.\r
728 Packet is NULL.\r
729 Packet is not a well-formed DHCP packet.\r
730 OptionCount is NULL.\r
d1f95000 731 @retval EFI_BUFFER_TOO_SMALL One or more of the following conditions is TRUE:\r
732 1) *OptionCount is smaller than the number of options that\r
733 were found in the Packet.\r
734 2) PacketOptionList is NULL.\r
74fec708 735 @retval EFI_OUT_OF_RESOURCE The packet is failed to parse because of resource shortage.\r
d1f95000 736\r
737**/\r
738typedef\r
739EFI_STATUS\r
8b13229b 740(EFIAPI *EFI_DHCP4_PARSE)(\r
d1f95000 741 IN EFI_DHCP4_PROTOCOL *This,\r
742 IN EFI_DHCP4_PACKET *Packet,\r
743 IN OUT UINT32 *OptionCount,\r
744 OUT EFI_DHCP4_PACKET_OPTION *PacketOptionList[] OPTIONAL\r
ed66e1bc 745 );\r
d1f95000 746\r
44717a39 747///\r
748/// This protocol is used to collect configuration information for the EFI IPv4 Protocol drivers\r
749/// and to provide DHCPv4 server and PXE boot server discovery services.\r
750///\r
d1f95000 751struct _EFI_DHCP4_PROTOCOL {\r
752 EFI_DHCP4_GET_MODE_DATA GetModeData;\r
753 EFI_DHCP4_CONFIGURE Configure;\r
754 EFI_DHCP4_START Start;\r
755 EFI_DHCP4_RENEW_REBIND RenewRebind;\r
756 EFI_DHCP4_RELEASE Release;\r
757 EFI_DHCP4_STOP Stop;\r
758 EFI_DHCP4_BUILD Build;\r
759 EFI_DHCP4_TRANSMIT_RECEIVE TransmitReceive;\r
760 EFI_DHCP4_PARSE Parse;\r
761};\r
762\r
763extern EFI_GUID gEfiDhcp4ProtocolGuid;\r
764extern EFI_GUID gEfiDhcp4ServiceBindingProtocolGuid;\r
765\r
766#endif\r