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