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