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