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