iPXE
Dhcp4.h
Go to the documentation of this file.
00001 /** @file
00002   EFI_DHCP4_PROTOCOL as defined in UEFI 2.0.
00003   EFI_DHCP4_SERVICE_BINDING_PROTOCOL as defined in UEFI 2.0.
00004   These protocols are used to collect configuration information for the EFI IPv4 Protocol
00005   drivers and to provide DHCPv4 server and PXE boot server discovery services.
00006 
00007 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
00008 This program and the accompanying materials are licensed and made available under
00009 the terms and conditions of the BSD License that accompanies this distribution.
00010 The full text of the license may be found at
00011 http://opensource.org/licenses/bsd-license.php.
00012 
00013 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
00014 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
00015 
00016   @par Revision Reference:
00017   This Protocol was introduced in UEFI Specification 2.0.
00018 
00019 **/
00020 
00021 #ifndef __EFI_DHCP4_PROTOCOL_H__
00022 #define __EFI_DHCP4_PROTOCOL_H__
00023 
00024 FILE_LICENCE ( BSD3 );
00025 
00026 #define EFI_DHCP4_PROTOCOL_GUID \
00027   { \
00028     0x8a219718, 0x4ef5, 0x4761, {0x91, 0xc8, 0xc0, 0xf0, 0x4b, 0xda, 0x9e, 0x56 } \
00029   }
00030 
00031 #define EFI_DHCP4_SERVICE_BINDING_PROTOCOL_GUID \
00032   { \
00033     0x9d9a39d8, 0xbd42, 0x4a73, {0xa4, 0xd5, 0x8e, 0xe9, 0x4b, 0xe1, 0x13, 0x80 } \
00034   }
00035 
00036 typedef struct _EFI_DHCP4_PROTOCOL EFI_DHCP4_PROTOCOL;
00037 
00038 
00039 #pragma pack(1)
00040 typedef struct {
00041   ///
00042   /// DHCP option code.
00043   ///
00044   UINT8               OpCode;
00045   ///
00046   /// Length of the DHCP option data. Not present if OpCode is 0 or 255.
00047   ///
00048   UINT8               Length;
00049   ///
00050   /// Start of the DHCP option data. Not present if OpCode is 0 or 255 or if Length is zero.
00051   ///
00052   UINT8               Data[1];
00053 } EFI_DHCP4_PACKET_OPTION;
00054 #pragma pack()
00055 
00056 
00057 #pragma pack(1)
00058 ///
00059 /// EFI_DHCP4_PACKET defines the format of DHCPv4 packets. See RFC 2131 for more information.
00060 ///
00061 typedef struct {
00062   UINT8             OpCode;
00063   UINT8             HwType;
00064   UINT8             HwAddrLen;
00065   UINT8             Hops;
00066   UINT32            Xid;
00067   UINT16            Seconds;
00068   UINT16            Reserved;
00069   EFI_IPv4_ADDRESS  ClientAddr;       ///< Client IP address from client.
00070   EFI_IPv4_ADDRESS  YourAddr;         ///< Client IP address from server.
00071   EFI_IPv4_ADDRESS  ServerAddr;       ///< IP address of next server in bootstrap.
00072   EFI_IPv4_ADDRESS  GatewayAddr;      ///< Relay agent IP address.
00073   UINT8             ClientHwAddr[16]; ///< Client hardware address.
00074   CHAR8             ServerName[64];
00075   CHAR8             BootFileName[128];
00076 }EFI_DHCP4_HEADER;
00077 #pragma pack()
00078 
00079 
00080 #pragma pack(1)
00081 typedef struct {
00082   ///
00083   /// Size of the EFI_DHCP4_PACKET buffer.
00084   ///
00085   UINT32              Size;
00086   ///
00087   /// Length of the EFI_DHCP4_PACKET from the first byte of the Header field
00088   /// to the last byte of the Option[] field.
00089   ///
00090   UINT32              Length;
00091 
00092   struct {
00093     ///
00094     /// DHCP packet header.
00095     ///
00096     EFI_DHCP4_HEADER  Header;
00097     ///
00098     /// DHCP magik cookie in network byte order.
00099     ///
00100     UINT32            Magik;
00101     ///
00102     /// Start of the DHCP packed option data.
00103     ///
00104     UINT8             Option[1];
00105   } Dhcp4;
00106 } EFI_DHCP4_PACKET;
00107 #pragma pack()
00108 
00109 
00110 typedef enum {
00111   ///
00112   /// The EFI DHCPv4 Protocol driver is stopped.
00113   ///
00114   Dhcp4Stopped        = 0x0,
00115   ///
00116   /// The EFI DHCPv4 Protocol driver is inactive.
00117   ///
00118   Dhcp4Init           = 0x1,
00119   ///
00120   /// The EFI DHCPv4 Protocol driver is collecting DHCP offer packets from DHCP servers.
00121   ///
00122   Dhcp4Selecting      = 0x2,
00123   ///
00124   /// The EFI DHCPv4 Protocol driver has sent the request to the DHCP server and is waiting for a response.
00125   ///
00126   Dhcp4Requesting     = 0x3,
00127   ///
00128   /// The DHCP configuration has completed.
00129   ///
00130   Dhcp4Bound          = 0x4,
00131   ///
00132   /// The DHCP configuration is being renewed and another request has
00133   /// been sent out, but it has not received a response from the server yet.
00134   ///
00135   Dhcp4Renewing       = 0x5,
00136   ///
00137   /// The DHCP configuration has timed out and the EFI DHCPv4
00138   /// Protocol driver is trying to extend the lease time.
00139   ///
00140   Dhcp4Rebinding      = 0x6,
00141   ///
00142   /// The EFI DHCPv4 Protocol driver was initialized with a previously
00143   /// allocated or known IP address.
00144   ///
00145   Dhcp4InitReboot     = 0x7,
00146   ///
00147   /// The EFI DHCPv4 Protocol driver is seeking to reuse the previously
00148   /// allocated IP address by sending a request to the DHCP server.
00149   ///
00150   Dhcp4Rebooting      = 0x8
00151 } EFI_DHCP4_STATE;
00152 
00153 
00154 typedef enum{
00155   ///
00156   /// The packet to start the configuration sequence is about to be sent.
00157   ///
00158   Dhcp4SendDiscover   = 0x01,
00159   ///
00160   /// A reply packet was just received.
00161   ///
00162   Dhcp4RcvdOffer      = 0x02,
00163   ///
00164   /// It is time for Dhcp4Callback to select an offer.
00165   ///
00166   Dhcp4SelectOffer    = 0x03,
00167   ///
00168   /// A request packet is about to be sent.
00169   ///
00170   Dhcp4SendRequest    = 0x04,
00171   ///
00172   /// A DHCPACK packet was received and will be passed to Dhcp4Callback.
00173   ///
00174   Dhcp4RcvdAck        = 0x05,
00175   ///
00176   /// A DHCPNAK packet was received and will be passed to Dhcp4Callback.
00177   ///
00178   Dhcp4RcvdNak        = 0x06,
00179   ///
00180   /// A decline packet is about to be sent.
00181   ///
00182   Dhcp4SendDecline    = 0x07,
00183   ///
00184   /// The DHCP configuration process has completed. No packet is associated with this event.
00185   ///
00186   Dhcp4BoundCompleted = 0x08,
00187   ///
00188   /// It is time to enter the Dhcp4Renewing state and to contact the server
00189   /// that originally issued the network address. No packet is associated with this event.
00190   ///
00191   Dhcp4EnterRenewing  = 0x09,
00192   ///
00193   /// It is time to enter the Dhcp4Rebinding state and to contact any server.
00194   /// No packet is associated with this event.
00195   ///
00196   Dhcp4EnterRebinding = 0x0a,
00197   ///
00198   /// The configured IP address was lost either because the lease has expired,
00199   /// the user released the configuration, or a DHCPNAK packet was received in
00200   /// the Dhcp4Renewing or Dhcp4Rebinding state. No packet is associated with this event.
00201   ///
00202   Dhcp4AddressLost    = 0x0b,
00203   ///
00204   /// The DHCP process failed because a DHCPNAK packet was received or the user
00205   /// aborted the DHCP process at a time when the configuration was not available yet.
00206   /// No packet is associated with this event.
00207   ///
00208   Dhcp4Fail           = 0x0c
00209 } EFI_DHCP4_EVENT;
00210 
00211 /**
00212   Callback routine.
00213 
00214   EFI_DHCP4_CALLBACK is provided by the consumer of the EFI DHCPv4 Protocol driver
00215   to intercept events that occurred in the configuration process. This structure
00216   provides advanced control of each state transition of the DHCP process. The
00217   returned status code determines the behavior of the EFI DHCPv4 Protocol driver.
00218   There are three possible returned values, which are described in the following
00219   table.
00220 
00221   @param  This                  The pointer to the EFI DHCPv4 Protocol instance that is used to
00222                                 configure this callback function.
00223   @param  Context               The pointer to the context that is initialized by
00224                                 EFI_DHCP4_PROTOCOL.Configure().
00225   @param  CurrentState          The current operational state of the EFI DHCPv4 Protocol
00226                                 driver.
00227   @param  Dhcp4Event            The event that occurs in the current state, which usually means a
00228                                 state transition.
00229   @param  Packet                The DHCP packet that is going to be sent or already received.
00230   @param  NewPacket             The packet that is used to replace the above Packet.
00231 
00232   @retval EFI_SUCCESS           Tells the EFI DHCPv4 Protocol driver to continue the DHCP process.
00233                                 When it is in the Dhcp4Selecting state, it tells the EFI DHCPv4 Protocol
00234                                 driver to stop collecting additional packets. The driver will exit
00235                                 the Dhcp4Selecting state and enter the Dhcp4Requesting state.
00236   @retval EFI_NOT_READY         Only used in the Dhcp4Selecting state. The EFI DHCPv4 Protocol
00237                                 driver will continue to wait for more packets until the retry
00238                                 timeout expires.
00239   @retval EFI_ABORTED           Tells the EFI DHCPv4 Protocol driver to abort the current process and
00240                                 return to the Dhcp4Init or Dhcp4InitReboot state.
00241 
00242 **/
00243 typedef
00244 EFI_STATUS
00245 (EFIAPI *EFI_DHCP4_CALLBACK)(
00246   IN  EFI_DHCP4_PROTOCOL         *This,
00247   IN  VOID                       *Context,
00248   IN  EFI_DHCP4_STATE            CurrentState,
00249   IN  EFI_DHCP4_EVENT            Dhcp4Event,
00250   IN  EFI_DHCP4_PACKET           *Packet     OPTIONAL,
00251   OUT EFI_DHCP4_PACKET           **NewPacket OPTIONAL
00252   );
00253 
00254 typedef struct {
00255   ///
00256   /// The number of times to try sending a packet during the Dhcp4SendDiscover
00257   /// event and waiting for a response during the Dhcp4RcvdOffer event.
00258   /// Set to zero to use the default try counts and timeout values.
00259   ///
00260   UINT32                      DiscoverTryCount;
00261   ///
00262   /// The maximum amount of time (in seconds) to wait for returned packets in each
00263   /// of the retries. Timeout values of zero will default to a timeout value
00264   /// of one second. Set to NULL to use default timeout values.
00265   ///
00266   UINT32                      *DiscoverTimeout;
00267   ///
00268   /// The number of times to try sending a packet during the Dhcp4SendRequest event
00269   /// and waiting for a response during the Dhcp4RcvdAck event before accepting
00270   /// failure. Set to zero to use the default try counts and timeout values.
00271   ///
00272   UINT32                      RequestTryCount;
00273   ///
00274   /// The maximum amount of time (in seconds) to wait for return packets in each of the retries.
00275   /// Timeout values of zero will default to a timeout value of one second.
00276   /// Set to NULL to use default timeout values.
00277   ///
00278   UINT32                      *RequestTimeout;
00279   ///
00280   /// For a DHCPDISCOVER, setting this parameter to the previously allocated IP
00281   /// address will cause the EFI DHCPv4 Protocol driver to enter the Dhcp4InitReboot state.
00282   /// And set this field to 0.0.0.0 to enter the Dhcp4Init state.
00283   /// For a DHCPINFORM this parameter should be set to the client network address
00284   /// which was assigned to the client during a DHCPDISCOVER.
00285   ///
00286   EFI_IPv4_ADDRESS            ClientAddress;
00287   ///
00288   /// The callback function to intercept various events that occurred in
00289   /// the DHCP configuration process. Set to NULL to ignore all those events.
00290   ///
00291   EFI_DHCP4_CALLBACK          Dhcp4Callback;
00292   ///
00293   /// The pointer to the context that will be passed to Dhcp4Callback when it is called.
00294   ///
00295   VOID                        *CallbackContext;
00296   ///
00297   /// Number of DHCP options in the OptionList.
00298   ///
00299   UINT32                      OptionCount;
00300   ///
00301   /// List of DHCP options to be included in every packet that is sent during the
00302   /// Dhcp4SendDiscover event. Pad options are appended automatically by DHCP driver
00303   /// in outgoing DHCP packets. If OptionList itself contains pad option, they are
00304   /// ignored by the driver. OptionList can be freed after EFI_DHCP4_PROTOCOL.Configure()
00305   /// returns. Ignored if OptionCount is zero.
00306   ///
00307   EFI_DHCP4_PACKET_OPTION     **OptionList;
00308 } EFI_DHCP4_CONFIG_DATA;
00309 
00310 
00311 typedef struct {
00312   ///
00313   /// The EFI DHCPv4 Protocol driver operating state.
00314   ///
00315   EFI_DHCP4_STATE             State;
00316   ///
00317   /// The configuration data of the current EFI DHCPv4 Protocol driver instance.
00318   ///
00319   EFI_DHCP4_CONFIG_DATA       ConfigData;
00320   ///
00321   /// The client IP address that was acquired from the DHCP server. If it is zero,
00322   /// the DHCP acquisition has not completed yet and the following fields in this structure are undefined.
00323   ///
00324   EFI_IPv4_ADDRESS            ClientAddress;
00325   ///
00326   /// The local hardware address.
00327   ///
00328   EFI_MAC_ADDRESS             ClientMacAddress;
00329   ///
00330   /// The server IP address that is providing the DHCP service to this client.
00331   ///
00332   EFI_IPv4_ADDRESS            ServerAddress;
00333   ///
00334   /// The router IP address that was acquired from the DHCP server.
00335   /// May be zero if the server does not offer this address.
00336   ///
00337   EFI_IPv4_ADDRESS            RouterAddress;
00338   ///
00339   /// The subnet mask of the connected network that was acquired from the DHCP server.
00340   ///
00341   EFI_IPv4_ADDRESS            SubnetMask;
00342   ///
00343   /// The lease time (in 1-second units) of the configured IP address.
00344   /// The value 0xFFFFFFFF means that the lease time is infinite.
00345   /// A default lease of 7 days is used if the DHCP server does not provide a value.
00346   ///
00347   UINT32                      LeaseTime;
00348   ///
00349   /// The cached latest DHCPACK or DHCPNAK or BOOTP REPLY packet. May be NULL if no packet is cached.
00350   ///
00351   EFI_DHCP4_PACKET            *ReplyPacket;
00352 } EFI_DHCP4_MODE_DATA;
00353 
00354 
00355 typedef struct {
00356   ///
00357   /// Alternate listening address. It can be a unicast, multicast, or broadcast address.
00358   ///
00359   EFI_IPv4_ADDRESS            ListenAddress;
00360   ///
00361   /// The subnet mask of above listening unicast/broadcast IP address.
00362   /// Ignored if ListenAddress is a multicast address.
00363   ///
00364   EFI_IPv4_ADDRESS            SubnetMask;
00365   ///
00366   /// Alternate station source (or listening) port number.
00367   /// If zero, then the default station port number (68) will be used.
00368   ///
00369   UINT16                      ListenPort;
00370 } EFI_DHCP4_LISTEN_POINT;
00371 
00372 
00373 typedef struct {
00374   ///
00375   /// The completion status of transmitting and receiving.
00376   ///
00377   EFI_STATUS              Status;
00378   ///
00379   /// If not NULL, the event that will be signaled when the collection process
00380   /// completes. If NULL, this function will busy-wait until the collection process competes.
00381   ///
00382   EFI_EVENT               CompletionEvent;
00383   ///
00384   /// The pointer to the server IP address. This address may be a unicast, multicast, or broadcast address.
00385   ///
00386   EFI_IPv4_ADDRESS        RemoteAddress;
00387   ///
00388   /// The server listening port number. If zero, the default server listening port number (67) will be used.
00389   ///
00390   UINT16                  RemotePort;
00391   ///
00392   /// The pointer to the gateway address to override the existing setting.
00393   ///
00394   EFI_IPv4_ADDRESS        GatewayAddress;
00395   ///
00396   /// The number of entries in ListenPoints. If zero, the default station address and port number 68 are used.
00397   ///
00398   UINT32                  ListenPointCount;
00399   ///
00400   /// An array of station address and port number pairs that are used as receiving filters.
00401   /// The first entry is also used as the source address and source port of the outgoing packet.
00402   ///
00403   EFI_DHCP4_LISTEN_POINT  *ListenPoints;
00404   ///
00405   /// The number of seconds to collect responses. Zero is invalid.
00406   ///
00407   UINT32                  TimeoutValue;
00408   ///
00409   /// The pointer to the packet to be transmitted.
00410   ///
00411   EFI_DHCP4_PACKET        *Packet;
00412   ///
00413   /// Number of received packets.
00414   ///
00415   UINT32                  ResponseCount;
00416   ///
00417   /// The pointer to the allocated list of received packets.
00418   ///
00419   EFI_DHCP4_PACKET        *ResponseList;
00420 } EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN;
00421 
00422 
00423 /**
00424   Returns the current operating mode and cached data packet for the EFI DHCPv4 Protocol driver.
00425 
00426   The GetModeData() function returns the current operating mode and cached data
00427   packet for the EFI DHCPv4 Protocol driver.
00428 
00429   @param  This          The pointer to the EFI_DHCP4_PROTOCOL instance.
00430   @param  Dhcp4ModeData The pointer to storage for the EFI_DHCP4_MODE_DATA structure.
00431 
00432   @retval EFI_SUCCESS           The mode data was returned.
00433   @retval EFI_INVALID_PARAMETER This is NULL.
00434 
00435 **/
00436 typedef
00437 EFI_STATUS
00438 (EFIAPI *EFI_DHCP4_GET_MODE_DATA)(
00439   IN  EFI_DHCP4_PROTOCOL      *This,
00440   OUT EFI_DHCP4_MODE_DATA     *Dhcp4ModeData
00441   );
00442 
00443 /**
00444   Initializes, changes, or resets the operational settings for the EFI DHCPv4 Protocol driver.
00445 
00446   The Configure() function is used to initialize, change, or reset the operational
00447   settings of the EFI DHCPv4 Protocol driver for the communication device on which
00448   the EFI DHCPv4 Service Binding Protocol is installed. This function can be
00449   successfully called only if both of the following are true:
00450   * This instance of the EFI DHCPv4 Protocol driver is in the Dhcp4Stopped, Dhcp4Init,
00451     Dhcp4InitReboot, or Dhcp4Bound states.
00452   * No other EFI DHCPv4 Protocol driver instance that is controlled by this EFI
00453     DHCPv4 Service Binding Protocol driver instance has configured this EFI DHCPv4
00454     Protocol driver.
00455   When this driver is in the Dhcp4Stopped state, it can transfer into one of the
00456   following two possible initial states:
00457   * Dhcp4Init
00458   * Dhcp4InitReboot.
00459   The driver can transfer into these states by calling Configure() with a non-NULL
00460   Dhcp4CfgData. The driver will transfer into the appropriate state based on the
00461   supplied client network address in the ClientAddress parameter and DHCP options
00462   in the OptionList parameter as described in RFC 2131.
00463   When Configure() is called successfully while Dhcp4CfgData is set to NULL, the
00464   default configuring data will be reset in the EFI DHCPv4 Protocol driver and
00465   the state of the EFI DHCPv4 Protocol driver will not be changed. If one instance
00466   wants to make it possible for another instance to configure the EFI DHCPv4 Protocol
00467   driver, it must call this function with Dhcp4CfgData set to NULL.
00468 
00469   @param  This                   The pointer to the EFI_DHCP4_PROTOCOL instance.
00470   @param  Dhcp4CfgData           The pointer to the EFI_DHCP4_CONFIG_DATA.
00471 
00472   @retval EFI_SUCCESS           The EFI DHCPv4 Protocol driver is now in the Dhcp4Init or
00473                                 Dhcp4InitReboot state, if the original state of this driver
00474                                 was Dhcp4Stopped, Dhcp4Init,Dhcp4InitReboot, or Dhcp4Bound
00475                                 and the value of Dhcp4CfgData was not NULL.
00476                                 Otherwise, the state was left unchanged.
00477   @retval EFI_ACCESS_DENIED     This instance of the EFI DHCPv4 Protocol driver was not in the
00478                                 Dhcp4Stopped, Dhcp4Init, Dhcp4InitReboot, or Dhcp4Bound state;
00479                                 Or onother instance of this EFI DHCPv4 Protocol driver is already
00480                                 in a valid configured state.
00481   @retval EFI_INVALID_PARAMETER One or more following conditions are TRUE:
00482                                 This is NULL.
00483                                 DiscoverTryCount > 0 and DiscoverTimeout is NULL
00484                                 RequestTryCount > 0 and RequestTimeout is NULL.
00485                                 OptionCount >0 and OptionList is NULL.
00486                                 ClientAddress is not a valid unicast address.
00487   @retval EFI_OUT_OF_RESOURCES  Required system resources could not be allocated.
00488   @retval EFI_DEVICE_ERROR      An unexpected system or network error occurred.
00489 
00490 **/
00491 typedef
00492 EFI_STATUS
00493 (EFIAPI *EFI_DHCP4_CONFIGURE)(
00494   IN EFI_DHCP4_PROTOCOL       *This,
00495   IN EFI_DHCP4_CONFIG_DATA    *Dhcp4CfgData  OPTIONAL
00496   );
00497 
00498 
00499 /**
00500   Starts the DHCP configuration process.
00501 
00502   The Start() function starts the DHCP configuration process. This function can
00503   be called only when the EFI DHCPv4 Protocol driver is in the Dhcp4Init or
00504   Dhcp4InitReboot state.
00505   If the DHCP process completes successfully, the state of the EFI DHCPv4 Protocol
00506   driver will be transferred through Dhcp4Selecting and Dhcp4Requesting to the
00507   Dhcp4Bound state. The CompletionEvent will then be signaled if it is not NULL.
00508   If the process aborts, either by the user or by some unexpected network error,
00509   the state is restored to the Dhcp4Init state. The Start() function can be called
00510   again to restart the process.
00511   Refer to RFC 2131 for precise state transitions during this process. At the
00512   time when each event occurs in this process, the callback function that was set
00513   by EFI_DHCP4_PROTOCOL.Configure() will be called and the user can take this
00514   opportunity to control the process.
00515 
00516   @param  This            The pointer to the EFI_DHCP4_PROTOCOL instance.
00517   @param  CompletionEvent If not NULL, it indicates the event that will be signaled when the
00518                           EFI DHCPv4 Protocol driver is transferred into the
00519                           Dhcp4Bound state or when the DHCP process is aborted.
00520                           EFI_DHCP4_PROTOCOL.GetModeData() can be called to
00521                           check the completion status. If NULL,
00522                           EFI_DHCP4_PROTOCOL.Start() will wait until the driver
00523                           is transferred into the Dhcp4Bound state or the process fails.
00524 
00525   @retval EFI_SUCCESS           The DHCP configuration process has started, or it has completed
00526                                 when CompletionEvent is NULL.
00527   @retval EFI_NOT_STARTED       The EFI DHCPv4 Protocol driver is in the Dhcp4Stopped
00528                                 state. EFI_DHCP4_PROTOCOL. Configure() needs to be called.
00529   @retval EFI_INVALID_PARAMETER This is NULL.
00530   @retval EFI_OUT_OF_RESOURCES  Required system resources could not be allocated.
00531   @retval EFI_TIMEOUT           The DHCP configuration process failed because no response was
00532                                 received from the server within the specified timeout value.
00533   @retval EFI_ABORTED           The user aborted the DHCP process.
00534   @retval EFI_ALREADY_STARTED   Some other EFI DHCPv4 Protocol instance already started the
00535                                 DHCP process.
00536   @retval EFI_DEVICE_ERROR      An unexpected system or network error occurred.
00537   @retval EFI_NO_MEDIA          There was a media error.
00538 
00539 **/
00540 typedef
00541 EFI_STATUS
00542 (EFIAPI *EFI_DHCP4_START)(
00543   IN EFI_DHCP4_PROTOCOL       *This,
00544   IN EFI_EVENT                CompletionEvent   OPTIONAL
00545   );
00546 
00547 /**
00548   Extends the lease time by sending a request packet.
00549 
00550   The RenewRebind() function is used to manually extend the lease time when the
00551   EFI DHCPv4 Protocol driver is in the Dhcp4Bound state, and the lease time has
00552   not expired yet. This function will send a request packet to the previously
00553   found server (or to any server when RebindRequest is TRUE) and transfer the
00554   state into the Dhcp4Renewing state (or Dhcp4Rebinding when RebindingRequest is
00555   TRUE). When a response is received, the state is returned to Dhcp4Bound.
00556   If no response is received before the try count is exceeded (the RequestTryCount
00557   field that is specified in EFI_DHCP4_CONFIG_DATA) but before the lease time that
00558   was issued by the previous server expires, the driver will return to the Dhcp4Bound
00559   state, and the previous configuration is restored. The outgoing and incoming packets
00560   can be captured by the EFI_DHCP4_CALLBACK function.
00561 
00562   @param  This            The pointer to the EFI_DHCP4_PROTOCOL instance.
00563   @param  RebindRequest   If TRUE, this function broadcasts the request packets and enters
00564                           the Dhcp4Rebinding state. Otherwise, it sends a unicast
00565                           request packet and enters the Dhcp4Renewing state.
00566   @param  CompletionEvent If not NULL, this event is signaled when the renew/rebind phase
00567                           completes or some error occurs.
00568                           EFI_DHCP4_PROTOCOL.GetModeData() can be called to
00569                           check the completion status. If NULL,
00570                           EFI_DHCP4_PROTOCOL.RenewRebind() will busy-wait
00571                           until the DHCP process finishes.
00572 
00573   @retval EFI_SUCCESS           The EFI DHCPv4 Protocol driver is now in the
00574                                 Dhcp4Renewing state or is back to the Dhcp4Bound state.
00575   @retval EFI_NOT_STARTED       The EFI DHCPv4 Protocol driver is in the Dhcp4Stopped
00576                                 state. EFI_DHCP4_PROTOCOL.Configure() needs to
00577                                 be called.
00578   @retval EFI_INVALID_PARAMETER This is NULL.
00579   @retval EFI_TIMEOUT           There was no response from the server when the try count was
00580                                 exceeded.
00581   @retval EFI_ACCESS_DENIED     The driver is not in the Dhcp4Bound state.
00582   @retval EFI_DEVICE_ERROR      An unexpected system or network error occurred.
00583 
00584 **/
00585 typedef
00586 EFI_STATUS
00587 (EFIAPI *EFI_DHCP4_RENEW_REBIND)(
00588   IN EFI_DHCP4_PROTOCOL       *This,
00589   IN BOOLEAN                  RebindRequest,
00590   IN EFI_EVENT                CompletionEvent  OPTIONAL
00591   );
00592 
00593 /**
00594   Releases the current address configuration.
00595 
00596   The Release() function releases the current configured IP address by doing either
00597   of the following:
00598   * Sending a DHCPRELEASE packet when the EFI DHCPv4 Protocol driver is in the
00599     Dhcp4Bound state
00600   * Setting the previously assigned IP address that was provided with the
00601     EFI_DHCP4_PROTOCOL.Configure() function to 0.0.0.0 when the driver is in
00602     Dhcp4InitReboot state
00603   After a successful call to this function, the EFI DHCPv4 Protocol driver returns
00604   to the Dhcp4Init state, and any subsequent incoming packets will be discarded silently.
00605 
00606   @param  This                  The pointer to the EFI_DHCP4_PROTOCOL instance.
00607 
00608   @retval EFI_SUCCESS           The EFI DHCPv4 Protocol driver is now in the Dhcp4Init phase.
00609   @retval EFI_INVALID_PARAMETER This is NULL.
00610   @retval EFI_ACCESS_DENIED     The EFI DHCPv4 Protocol driver is not Dhcp4InitReboot state.
00611   @retval EFI_DEVICE_ERROR      An unexpected system or network error occurred.
00612 
00613 **/
00614 typedef
00615 EFI_STATUS
00616 (EFIAPI *EFI_DHCP4_RELEASE)(
00617   IN EFI_DHCP4_PROTOCOL       *This
00618   );
00619 
00620 /**
00621   Stops the current address configuration.
00622 
00623   The Stop() function is used to stop the DHCP configuration process. After this
00624   function is called successfully, the EFI DHCPv4 Protocol driver is transferred
00625   into the Dhcp4Stopped state. EFI_DHCP4_PROTOCOL.Configure() needs to be called
00626   before DHCP configuration process can be started again. This function can be
00627   called when the EFI DHCPv4 Protocol driver is in any state.
00628 
00629   @param  This                  The pointer to the EFI_DHCP4_PROTOCOL instance.
00630 
00631   @retval EFI_SUCCESS           The EFI DHCPv4 Protocol driver is now in the Dhcp4Stopped phase.
00632   @retval EFI_INVALID_PARAMETER This is NULL.
00633 
00634 **/
00635 typedef
00636 EFI_STATUS
00637 (EFIAPI *EFI_DHCP4_STOP)(
00638   IN EFI_DHCP4_PROTOCOL       *This
00639   );
00640 
00641 /**
00642   Builds a DHCP packet, given the options to be appended or deleted or replaced.
00643 
00644   The Build() function is used to assemble a new packet from the original packet
00645   by replacing or deleting existing options or appending new options. This function
00646   does not change any state of the EFI DHCPv4 Protocol driver and can be used at
00647   any time.
00648 
00649   @param  This        The pointer to the EFI_DHCP4_PROTOCOL instance.
00650   @param  SeedPacket  Initial packet to be used as a base for building new packet.
00651   @param  DeleteCount Number of opcodes in the DeleteList.
00652   @param  DeleteList  List of opcodes to be deleted from the seed packet.
00653                       Ignored if DeleteCount is zero.
00654   @param  AppendCount Number of entries in the OptionList.
00655   @param  AppendList  The pointer to a DHCP option list to be appended to SeedPacket.
00656                       If SeedPacket also contains options in this list, they are
00657                       replaced by new options (except pad option). Ignored if
00658                       AppendCount is zero. Type EFI_DHCP4_PACKET_OPTION
00659   @param  NewPacket   The pointer to storage for the pointer to the new allocated packet.
00660                       Use the EFI Boot Service FreePool() on the resulting pointer
00661                       when done with the packet.
00662 
00663   @retval EFI_SUCCESS           The new packet was built.
00664   @retval EFI_OUT_OF_RESOURCES  Storage for the new packet could not be allocated.
00665   @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
00666                                 This is NULL.
00667                                 SeedPacket is NULL.
00668                                 SeedPacket is not a well-formed DHCP packet.
00669                                 AppendCount is not zero and AppendList is NULL.
00670                                 DeleteCount is not zero and DeleteList is NULL.
00671                                 NewPacket is NULL
00672                                 Both DeleteCount and AppendCount are zero and
00673                                 NewPacket is not NULL.
00674 
00675 **/
00676 typedef
00677 EFI_STATUS
00678 (EFIAPI *EFI_DHCP4_BUILD)(
00679   IN  EFI_DHCP4_PROTOCOL      *This,
00680   IN  EFI_DHCP4_PACKET        *SeedPacket,
00681   IN  UINT32                  DeleteCount,
00682   IN  UINT8                   *DeleteList         OPTIONAL,
00683   IN  UINT32                  AppendCount,
00684   IN  EFI_DHCP4_PACKET_OPTION *AppendList[]       OPTIONAL,
00685   OUT EFI_DHCP4_PACKET        **NewPacket
00686   );
00687 
00688 
00689 /**
00690   Transmits a DHCP formatted packet and optionally waits for responses.
00691 
00692   The TransmitReceive() function is used to transmit a DHCP packet and optionally
00693   wait for the response from servers. This function does not change the state of
00694   the EFI DHCPv4 Protocol driver. It can be used at any time because of this.
00695 
00696   @param  This    The pointer to the EFI_DHCP4_PROTOCOL instance.
00697   @param  Token   The pointer to the EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN structure.
00698 
00699   @retval EFI_SUCCESS           The packet was successfully queued for transmission.
00700   @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
00701                                 This is NULL.
00702                                 Token.RemoteAddress is zero.
00703                                 Token.Packet is NULL.
00704                                 Token.Packet is not a well-formed DHCP packet.
00705                                 The transaction ID in Token.Packet is in use by another DHCP process.
00706   @retval EFI_NOT_READY         The previous call to this function has not finished yet. Try to call
00707                                 this function after collection process completes.
00708   @retval EFI_NO_MAPPING        The default station address is not available yet.
00709   @retval EFI_OUT_OF_RESOURCES  Required system resources could not be allocated.
00710   @retval EFI_UNSUPPORTED       The implementation doesn't support this function
00711   @retval Others                Some other unexpected error occurred.
00712 
00713 **/
00714 typedef
00715 EFI_STATUS
00716 (EFIAPI *EFI_DHCP4_TRANSMIT_RECEIVE)(
00717   IN EFI_DHCP4_PROTOCOL                *This,
00718   IN EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN  *Token
00719   );
00720 
00721 
00722 /**
00723   Parses the packed DHCP option data.
00724 
00725   The Parse() function is used to retrieve the option list from a DHCP packet.
00726   If *OptionCount isn't zero, and there is enough space for all the DHCP options
00727   in the Packet, each element of PacketOptionList is set to point to somewhere in
00728   the Packet->Dhcp4.Option where a new DHCP option begins. If RFC3396 is supported,
00729   the caller should reassemble the parsed DHCP options to get the final result.
00730   If *OptionCount is zero or there isn't enough space for all of them, the number
00731   of DHCP options in the Packet is returned in OptionCount.
00732 
00733   @param  This             The pointer to the EFI_DHCP4_PROTOCOL instance.
00734   @param  Packet           The pointer to packet to be parsed.
00735   @param  OptionCount      On input, the number of entries in the PacketOptionList.
00736                            On output, the number of entries that were written into the
00737                            PacketOptionList.
00738   @param  PacketOptionList A list of packet option entries to be filled in. End option or pad
00739                            options are not included.
00740 
00741   @retval EFI_SUCCESS           The packet was successfully parsed.
00742   @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
00743                                 This is NULL.
00744                                 The packet is NULL.
00745                                 The packet is not a well-formed DHCP packet.
00746                                 OptionCount is NULL.
00747   @retval EFI_BUFFER_TOO_SMALL  One or more of the following conditions is TRUE:
00748                                 1) *OptionCount is smaller than the number of options that
00749                                 were found in the Packet.
00750                                 2) PacketOptionList is NULL.
00751   @retval EFI_OUT_OF_RESOURCE   The packet failed to parse because of a resource shortage.
00752 
00753 **/
00754 typedef
00755 EFI_STATUS
00756 (EFIAPI *EFI_DHCP4_PARSE)(
00757   IN EFI_DHCP4_PROTOCOL        *This,
00758   IN EFI_DHCP4_PACKET          *Packet,
00759   IN OUT UINT32                *OptionCount,
00760   OUT EFI_DHCP4_PACKET_OPTION  *PacketOptionList[]  OPTIONAL
00761   );
00762 
00763 ///
00764 /// This protocol is used to collect configuration information for the EFI IPv4 Protocol drivers
00765 /// and to provide DHCPv4 server and PXE boot server discovery services.
00766 ///
00767 struct _EFI_DHCP4_PROTOCOL {
00768   EFI_DHCP4_GET_MODE_DATA      GetModeData;
00769   EFI_DHCP4_CONFIGURE          Configure;
00770   EFI_DHCP4_START              Start;
00771   EFI_DHCP4_RENEW_REBIND       RenewRebind;
00772   EFI_DHCP4_RELEASE            Release;
00773   EFI_DHCP4_STOP               Stop;
00774   EFI_DHCP4_BUILD              Build;
00775   EFI_DHCP4_TRANSMIT_RECEIVE   TransmitReceive;
00776   EFI_DHCP4_PARSE              Parse;
00777 };
00778 
00779 extern EFI_GUID gEfiDhcp4ProtocolGuid;
00780 extern EFI_GUID gEfiDhcp4ServiceBindingProtocolGuid;
00781 
00782 #endif