]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[efi] Add definitions of GUIDs observed when chainloading from Intel driver
authorMichael Brown <mcb30@ipxe.org>
Thu, 25 Sep 2014 12:16:44 +0000 (13:16 +0100)
committerMichael Brown <mcb30@ipxe.org>
Thu, 25 Sep 2014 12:16:44 +0000 (13:16 +0100)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
12 files changed:
src/include/ipxe/efi/Protocol/Arp.h [new file with mode: 0644]
src/include/ipxe/efi/Protocol/Dhcp4.h [new file with mode: 0644]
src/include/ipxe/efi/Protocol/Ip4.h [new file with mode: 0644]
src/include/ipxe/efi/Protocol/Ip4Config.h [new file with mode: 0644]
src/include/ipxe/efi/Protocol/ManagedNetwork.h [new file with mode: 0644]
src/include/ipxe/efi/Protocol/Mtftp4.h [new file with mode: 0644]
src/include/ipxe/efi/Protocol/Tcp4.h [new file with mode: 0644]
src/include/ipxe/efi/Protocol/Udp4.h [new file with mode: 0644]
src/include/ipxe/efi/Protocol/VlanConfig.h [new file with mode: 0644]
src/include/ipxe/efi/efi.h
src/interface/efi/efi_debug.c
src/interface/efi/efi_guid.c

diff --git a/src/include/ipxe/efi/Protocol/Arp.h b/src/include/ipxe/efi/Protocol/Arp.h
new file mode 100644 (file)
index 0000000..80921f9
--- /dev/null
@@ -0,0 +1,387 @@
+/** @file
+  EFI ARP Protocol Definition
+
+  The EFI ARP Service Binding Protocol is used to locate EFI
+  ARP Protocol drivers to create and destroy child of the
+  driver to communicate with other host using ARP protocol.
+  The EFI ARP Protocol provides services to map IP network
+  address to hardware address used by a data link protocol.
+
+Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  @par Revision Reference:
+  This Protocol was introduced in UEFI Specification 2.0.
+
+**/
+
+#ifndef __EFI_ARP_PROTOCOL_H__
+#define __EFI_ARP_PROTOCOL_H__
+
+FILE_LICENCE ( BSD3 );
+
+#define EFI_ARP_SERVICE_BINDING_PROTOCOL_GUID \
+  { \
+    0xf44c00ee, 0x1f2c, 0x4a00, {0xaa, 0x9, 0x1c, 0x9f, 0x3e, 0x8, 0x0, 0xa3 } \
+  }
+
+#define EFI_ARP_PROTOCOL_GUID \
+  { \
+    0xf4b427bb, 0xba21, 0x4f16, {0xbc, 0x4e, 0x43, 0xe4, 0x16, 0xab, 0x61, 0x9c } \
+  }
+
+typedef struct _EFI_ARP_PROTOCOL EFI_ARP_PROTOCOL;
+
+typedef struct {
+  ///
+  /// Length in bytes of this entry.
+  ///
+  UINT32                      Size;
+
+  ///
+  /// Set to TRUE if this entry is a "deny" entry.
+  /// Set to FALSE if this entry is a "normal" entry.
+  ///
+  BOOLEAN                     DenyFlag;
+
+  ///
+  /// Set to TRUE if this entry will not time out.
+  /// Set to FALSE if this entry will time out.
+  ///
+  BOOLEAN                     StaticFlag;
+
+  ///
+  /// 16-bit ARP hardware identifier number.
+  ///
+  UINT16                      HwAddressType;
+
+  ///
+  /// 16-bit protocol type number.
+  ///
+  UINT16                      SwAddressType;
+
+  ///
+  /// The length of the hardware address.
+  ///
+  UINT8                       HwAddressLength;
+
+  ///
+  /// The length of the protocol address.
+  ///
+  UINT8                       SwAddressLength;
+} EFI_ARP_FIND_DATA;
+
+typedef struct {
+  ///
+  /// 16-bit protocol type number in host byte order.
+  ///
+  UINT16                    SwAddressType;
+
+  ///
+  /// The length in bytes of the station's protocol address to register.
+  ///
+  UINT8                     SwAddressLength;
+
+  ///
+  /// The pointer to the first byte of the protocol address to register. For
+  /// example, if SwAddressType is 0x0800 (IP), then
+  /// StationAddress points to the first byte of this station's IP
+  /// address stored in network byte order.
+  ///
+  VOID                      *StationAddress;
+
+  ///
+  /// The timeout value in 100-ns units that is associated with each
+  /// new dynamic ARP cache entry. If it is set to zero, the value is
+  /// implementation-specific.
+  ///
+  UINT32                    EntryTimeOut;
+
+  ///
+  /// The number of retries before a MAC address is resolved. If it is
+  /// set to zero, the value is implementation-specific.
+  ///
+  UINT32                    RetryCount;
+
+  ///
+  /// The timeout value in 100-ns units that is used to wait for the ARP
+  /// reply packet or the timeout value between two retries. Set to zero
+  /// to use implementation-specific value.
+  ///
+  UINT32                    RetryTimeOut;
+} EFI_ARP_CONFIG_DATA;
+
+
+/**
+  This function is used to assign a station address to the ARP cache for this instance
+  of the ARP driver.
+
+  Each ARP instance has one station address. The EFI_ARP_PROTOCOL driver will
+  respond to ARP requests that match this registered station address. A call to
+  this function with the ConfigData field set to NULL will reset this ARP instance.
+
+  Once a protocol type and station address have been assigned to this ARP instance,
+  all the following ARP functions will use this information. Attempting to change
+  the protocol type or station address to a configured ARP instance will result in errors.
+
+  @param  This                   The pointer to the EFI_ARP_PROTOCOL instance.
+  @param  ConfigData             The pointer to the EFI_ARP_CONFIG_DATA structure.
+
+  @retval EFI_SUCCESS            The new station address was successfully
+                                 registered.
+  @retval EFI_INVALID_PARAMETER  One or more of the following conditions is TRUE:
+                                 * This is NULL.
+                                 * SwAddressLength is zero when ConfigData is not NULL.
+                                 * StationAddress is NULL when ConfigData is not NULL.
+  @retval EFI_ACCESS_DENIED      The SwAddressType, SwAddressLength, or
+                                 StationAddress is different from the one that is
+                                 already registered.
+  @retval EFI_OUT_OF_RESOURCES   Storage for the new StationAddress could not be
+                                 allocated.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_ARP_CONFIGURE)(
+  IN EFI_ARP_PROTOCOL       *This,
+  IN EFI_ARP_CONFIG_DATA    *ConfigData   OPTIONAL
+  );
+
+/**
+  This function is used to insert entries into the ARP cache.
+
+  ARP cache entries are typically inserted and updated by network protocol drivers
+  as network traffic is processed. Most ARP cache entries will time out and be
+  deleted if the network traffic stops. ARP cache entries that were inserted
+  by the Add() function may be static (will not time out) or dynamic (will time out).
+  Default ARP cache timeout values are not covered in most network protocol
+  specifications (although RFC 1122 comes pretty close) and will only be
+  discussed in general terms in this specification. The timeout values that are
+  used in the EFI Sample Implementation should be used only as a guideline.
+  Final product implementations of the EFI network stack should be tuned for
+  their expected network environments.
+
+  @param  This                   Pointer to the EFI_ARP_PROTOCOL instance.
+  @param  DenyFlag               Set to TRUE if this entry is a deny entry. Set to
+                                 FALSE if this  entry is a normal entry.
+  @param  TargetSwAddress        Pointer to a protocol address to add (or deny).
+                                 May be set to NULL if DenyFlag is TRUE.
+  @param  TargetHwAddress        Pointer to a hardware address to add (or deny).
+                                 May be set to NULL if DenyFlag is TRUE.
+  @param  TimeoutValue           Time in 100-ns units that this entry will remain
+                                 in the ARP cache. A value of zero means that the
+                                 entry is permanent. A nonzero value will override
+                                 the one given by Configure() if the entry to be
+                                 added is a dynamic entry.
+  @param  Overwrite              If TRUE, the matching cache entry will be
+                                 overwritten with the supplied parameters. If
+                                 FALSE, EFI_ACCESS_DENIED is returned if the
+                                 corresponding cache entry already exists.
+
+  @retval EFI_SUCCESS            The entry has been added or updated.
+  @retval EFI_INVALID_PARAMETER  One or more of the following conditions is TRUE:
+                                 * This is NULL.
+                                 * DenyFlag is FALSE and TargetHwAddress is NULL.
+                                 * DenyFlag is FALSE and TargetSwAddress is NULL.
+                                 * TargetHwAddress is NULL and TargetSwAddress is NULL.
+                                 * Neither TargetSwAddress nor TargetHwAddress are NULL when DenyFlag is
+                                 TRUE.
+  @retval EFI_OUT_OF_RESOURCES   The new ARP cache entry could not be allocated.
+  @retval EFI_ACCESS_DENIED      The ARP cache entry already exists and Overwrite
+                                 is not true.
+  @retval EFI_NOT_STARTED        The ARP driver instance has not been configured.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_ARP_ADD)(
+  IN EFI_ARP_PROTOCOL       *This,
+  IN BOOLEAN                DenyFlag,
+  IN VOID                   *TargetSwAddress  OPTIONAL,
+  IN VOID                   *TargetHwAddress  OPTIONAL,
+  IN UINT32                 TimeoutValue,
+  IN BOOLEAN                Overwrite
+  );
+
+/**
+  This function searches the ARP cache for matching entries and allocates a buffer into
+  which those entries are copied.
+
+  The first part of the allocated buffer is EFI_ARP_FIND_DATA, following which
+  are protocol address pairs and hardware address pairs.
+  When finding a specific protocol address (BySwAddress is TRUE and AddressBuffer
+  is not NULL), the ARP cache timeout for the found entry is reset if Refresh is
+  set to TRUE. If the found ARP cache entry is a permanent entry, it is not
+  affected by Refresh.
+
+  @param  This                   The pointer to the EFI_ARP_PROTOCOL instance.
+  @param  BySwAddress            Set to TRUE to look for matching software protocol
+                                 addresses. Set to FALSE to look for matching
+                                 hardware protocol addresses.
+  @param  AddressBuffer          The pointer to the address buffer. Set to NULL
+                                 to match all addresses.
+  @param  EntryLength            The size of an entry in the entries buffer.
+  @param  EntryCount             The number of ARP cache entries that are found by
+                                 the specified criteria.
+  @param  Entries                The pointer to the buffer that will receive the ARP
+                                 cache entries.
+  @param  Refresh                Set to TRUE to refresh the timeout value of the
+                                 matching ARP cache entry.
+
+  @retval EFI_SUCCESS            The requested ARP cache entries were copied into
+                                 the buffer.
+  @retval EFI_INVALID_PARAMETER  One or more of the following conditions is TRUE:
+                                 This is NULL. Both EntryCount and EntryLength are
+                                 NULL, when Refresh is FALSE.
+  @retval EFI_NOT_FOUND          No matching entries were found.
+  @retval EFI_NOT_STARTED        The ARP driver instance has not been configured.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_ARP_FIND)(
+  IN EFI_ARP_PROTOCOL       *This,
+  IN BOOLEAN                BySwAddress,
+  IN VOID                   *AddressBuffer    OPTIONAL,
+  OUT UINT32                *EntryLength      OPTIONAL,
+  OUT UINT32                *EntryCount       OPTIONAL,
+  OUT EFI_ARP_FIND_DATA     **Entries         OPTIONAL,
+  IN BOOLEAN                Refresh
+  );
+
+
+/**
+  This function removes specified ARP cache entries.
+
+  @param  This                   The pointer to the EFI_ARP_PROTOCOL instance.
+  @param  BySwAddress            Set to TRUE to delete matching protocol addresses.
+                                 Set to FALSE to delete matching hardware
+                                 addresses.
+  @param  AddressBuffer          The pointer to the address buffer that is used as a
+                                 key to look for the cache entry. Set to NULL to
+                                 delete all entries.
+
+  @retval EFI_SUCCESS            The entry was removed from the ARP cache.
+  @retval EFI_INVALID_PARAMETER  This is NULL.
+  @retval EFI_NOT_FOUND          The specified deletion key was not found.
+  @retval EFI_NOT_STARTED        The ARP driver instance has not been configured.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_ARP_DELETE)(
+  IN EFI_ARP_PROTOCOL       *This,
+  IN BOOLEAN                BySwAddress,
+  IN VOID                   *AddressBuffer   OPTIONAL
+  );
+
+/**
+  This function delete all dynamic entries from the ARP cache that match the specified
+  software protocol type.
+
+  @param  This                   The pointer to the EFI_ARP_PROTOCOL instance.
+
+  @retval EFI_SUCCESS            The cache has been flushed.
+  @retval EFI_INVALID_PARAMETER  This is NULL.
+  @retval EFI_NOT_FOUND          There are no matching dynamic cache entries.
+  @retval EFI_NOT_STARTED        The ARP driver instance has not been configured.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_ARP_FLUSH)(
+  IN EFI_ARP_PROTOCOL       *This
+  );
+
+/**
+  This function tries to resolve the TargetSwAddress and optionally returns a
+  TargetHwAddress if it already exists in the ARP cache.
+
+  @param  This                   The pointer to the EFI_ARP_PROTOCOL instance.
+  @param  TargetSwAddress        The pointer to the protocol address to resolve.
+  @param  ResolvedEvent          The pointer to the event that will be signaled when
+                                 the address is resolved or some error occurs.
+  @param  TargetHwAddress        The pointer to the buffer for the resolved hardware
+                                 address in network byte order.
+
+  @retval EFI_SUCCESS            The data is copied from the ARP cache into the
+                                 TargetHwAddress buffer.
+  @retval EFI_INVALID_PARAMETER  One or more of the following conditions is TRUE:
+                                 This is NULL. TargetHwAddress is NULL.
+  @retval EFI_ACCESS_DENIED      The requested address is not present in the normal
+                                 ARP cache but is present in the deny address list.
+                                 Outgoing traffic to that address is forbidden.
+  @retval EFI_NOT_STARTED        The ARP driver instance has not been configured.
+  @retval EFI_NOT_READY          The request has been started and is not finished.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_ARP_REQUEST)(
+  IN EFI_ARP_PROTOCOL       *This,
+  IN VOID                   *TargetSwAddress  OPTIONAL,
+  IN EFI_EVENT              ResolvedEvent     OPTIONAL,
+  OUT VOID                  *TargetHwAddress
+  );
+
+/**
+  This function aborts the previous ARP request (identified by This, TargetSwAddress
+  and ResolvedEvent) that is issued by EFI_ARP_PROTOCOL.Request().
+
+  If the request is in the internal ARP request queue, the request is aborted
+  immediately and its ResolvedEvent is signaled. Only an asynchronous address
+  request needs to be canceled. If TargeSwAddress and ResolveEvent are both
+  NULL, all the pending asynchronous requests that have been issued by This
+  instance will be cancelled and their corresponding events will be signaled.
+
+  @param  This                   The pointer to the EFI_ARP_PROTOCOL instance.
+  @param  TargetSwAddress        The pointer to the protocol address in previous
+                                 request session.
+  @param  ResolvedEvent          Pointer to the event that is used as the
+                                 notification event in previous request session.
+
+  @retval EFI_SUCCESS            The pending request session(s) is/are aborted and
+                                 corresponding event(s) is/are signaled.
+  @retval EFI_INVALID_PARAMETER  One or more of the following conditions is TRUE:
+                                 This is NULL. TargetSwAddress is not NULL and
+                                 ResolvedEvent is NULL. TargetSwAddress is NULL and
+                                 ResolvedEvent is not NULL.
+  @retval EFI_NOT_STARTED        The ARP driver instance has not been configured.
+  @retval EFI_NOT_FOUND          The request is not issued by
+                                 EFI_ARP_PROTOCOL.Request().
+
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_ARP_CANCEL)(
+  IN EFI_ARP_PROTOCOL       *This,
+  IN VOID                   *TargetSwAddress  OPTIONAL,
+  IN EFI_EVENT              ResolvedEvent     OPTIONAL
+  );
+
+///
+/// ARP is used to resolve local network protocol addresses into
+/// network hardware addresses.
+///
+struct _EFI_ARP_PROTOCOL {
+  EFI_ARP_CONFIGURE         Configure;
+  EFI_ARP_ADD               Add;
+  EFI_ARP_FIND              Find;
+  EFI_ARP_DELETE            Delete;
+  EFI_ARP_FLUSH             Flush;
+  EFI_ARP_REQUEST           Request;
+  EFI_ARP_CANCEL            Cancel;
+};
+
+
+extern EFI_GUID gEfiArpServiceBindingProtocolGuid;
+extern EFI_GUID gEfiArpProtocolGuid;
+
+#endif
diff --git a/src/include/ipxe/efi/Protocol/Dhcp4.h b/src/include/ipxe/efi/Protocol/Dhcp4.h
new file mode 100644 (file)
index 0000000..560ee32
--- /dev/null
@@ -0,0 +1,782 @@
+/** @file
+  EFI_DHCP4_PROTOCOL as defined in UEFI 2.0.
+  EFI_DHCP4_SERVICE_BINDING_PROTOCOL as defined in UEFI 2.0.
+  These protocols are used to collect configuration information for the EFI IPv4 Protocol
+  drivers and to provide DHCPv4 server and PXE boot server discovery services.
+
+Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  @par Revision Reference:
+  This Protocol was introduced in UEFI Specification 2.0.
+
+**/
+
+#ifndef __EFI_DHCP4_PROTOCOL_H__
+#define __EFI_DHCP4_PROTOCOL_H__
+
+FILE_LICENCE ( BSD3 );
+
+#define EFI_DHCP4_PROTOCOL_GUID \
+  { \
+    0x8a219718, 0x4ef5, 0x4761, {0x91, 0xc8, 0xc0, 0xf0, 0x4b, 0xda, 0x9e, 0x56 } \
+  }
+
+#define EFI_DHCP4_SERVICE_BINDING_PROTOCOL_GUID \
+  { \
+    0x9d9a39d8, 0xbd42, 0x4a73, {0xa4, 0xd5, 0x8e, 0xe9, 0x4b, 0xe1, 0x13, 0x80 } \
+  }
+
+typedef struct _EFI_DHCP4_PROTOCOL EFI_DHCP4_PROTOCOL;
+
+
+#pragma pack(1)
+typedef struct {
+  ///
+  /// DHCP option code.
+  ///
+  UINT8               OpCode;
+  ///
+  /// Length of the DHCP option data. Not present if OpCode is 0 or 255.
+  ///
+  UINT8               Length;
+  ///
+  /// Start of the DHCP option data. Not present if OpCode is 0 or 255 or if Length is zero.
+  ///
+  UINT8               Data[1];
+} EFI_DHCP4_PACKET_OPTION;
+#pragma pack()
+
+
+#pragma pack(1)
+///
+/// EFI_DHCP4_PACKET defines the format of DHCPv4 packets. See RFC 2131 for more information.
+///
+typedef struct {
+  UINT8             OpCode;
+  UINT8             HwType;
+  UINT8             HwAddrLen;
+  UINT8             Hops;
+  UINT32            Xid;
+  UINT16            Seconds;
+  UINT16            Reserved;
+  EFI_IPv4_ADDRESS  ClientAddr;       ///< Client IP address from client.
+  EFI_IPv4_ADDRESS  YourAddr;         ///< Client IP address from server.
+  EFI_IPv4_ADDRESS  ServerAddr;       ///< IP address of next server in bootstrap.
+  EFI_IPv4_ADDRESS  GatewayAddr;      ///< Relay agent IP address.
+  UINT8             ClientHwAddr[16]; ///< Client hardware address.
+  CHAR8             ServerName[64];
+  CHAR8             BootFileName[128];
+}EFI_DHCP4_HEADER;
+#pragma pack()
+
+
+#pragma pack(1)
+typedef struct {
+  ///
+  /// Size of the EFI_DHCP4_PACKET buffer.
+  ///
+  UINT32              Size;
+  ///
+  /// Length of the EFI_DHCP4_PACKET from the first byte of the Header field
+  /// to the last byte of the Option[] field.
+  ///
+  UINT32              Length;
+
+  struct {
+    ///
+    /// DHCP packet header.
+    ///
+    EFI_DHCP4_HEADER  Header;
+    ///
+    /// DHCP magik cookie in network byte order.
+    ///
+    UINT32            Magik;
+    ///
+    /// Start of the DHCP packed option data.
+    ///
+    UINT8             Option[1];
+  } Dhcp4;
+} EFI_DHCP4_PACKET;
+#pragma pack()
+
+
+typedef enum {
+  ///
+  /// The EFI DHCPv4 Protocol driver is stopped.
+  ///
+  Dhcp4Stopped        = 0x0,
+  ///
+  /// The EFI DHCPv4 Protocol driver is inactive.
+  ///
+  Dhcp4Init           = 0x1,
+  ///
+  /// The EFI DHCPv4 Protocol driver is collecting DHCP offer packets from DHCP servers.
+  ///
+  Dhcp4Selecting      = 0x2,
+  ///
+  /// The EFI DHCPv4 Protocol driver has sent the request to the DHCP server and is waiting for a response.
+  ///
+  Dhcp4Requesting     = 0x3,
+  ///
+  /// The DHCP configuration has completed.
+  ///
+  Dhcp4Bound          = 0x4,
+  ///
+  /// The DHCP configuration is being renewed and another request has
+  /// been sent out, but it has not received a response from the server yet.
+  ///
+  Dhcp4Renewing       = 0x5,
+  ///
+  /// The DHCP configuration has timed out and the EFI DHCPv4
+  /// Protocol driver is trying to extend the lease time.
+  ///
+  Dhcp4Rebinding      = 0x6,
+  ///
+  /// The EFI DHCPv4 Protocol driver was initialized with a previously
+  /// allocated or known IP address.
+  ///
+  Dhcp4InitReboot     = 0x7,
+  ///
+  /// The EFI DHCPv4 Protocol driver is seeking to reuse the previously
+  /// allocated IP address by sending a request to the DHCP server.
+  ///
+  Dhcp4Rebooting      = 0x8
+} EFI_DHCP4_STATE;
+
+
+typedef enum{
+  ///
+  /// The packet to start the configuration sequence is about to be sent.
+  ///
+  Dhcp4SendDiscover   = 0x01,
+  ///
+  /// A reply packet was just received.
+  ///
+  Dhcp4RcvdOffer      = 0x02,
+  ///
+  /// It is time for Dhcp4Callback to select an offer.
+  ///
+  Dhcp4SelectOffer    = 0x03,
+  ///
+  /// A request packet is about to be sent.
+  ///
+  Dhcp4SendRequest    = 0x04,
+  ///
+  /// A DHCPACK packet was received and will be passed to Dhcp4Callback.
+  ///
+  Dhcp4RcvdAck        = 0x05,
+  ///
+  /// A DHCPNAK packet was received and will be passed to Dhcp4Callback.
+  ///
+  Dhcp4RcvdNak        = 0x06,
+  ///
+  /// A decline packet is about to be sent.
+  ///
+  Dhcp4SendDecline    = 0x07,
+  ///
+  /// The DHCP configuration process has completed. No packet is associated with this event.
+  ///
+  Dhcp4BoundCompleted = 0x08,
+  ///
+  /// It is time to enter the Dhcp4Renewing state and to contact the server
+  /// that originally issued the network address. No packet is associated with this event.
+  ///
+  Dhcp4EnterRenewing  = 0x09,
+  ///
+  /// It is time to enter the Dhcp4Rebinding state and to contact any server.
+  /// No packet is associated with this event.
+  ///
+  Dhcp4EnterRebinding = 0x0a,
+  ///
+  /// The configured IP address was lost either because the lease has expired,
+  /// the user released the configuration, or a DHCPNAK packet was received in
+  /// the Dhcp4Renewing or Dhcp4Rebinding state. No packet is associated with this event.
+  ///
+  Dhcp4AddressLost    = 0x0b,
+  ///
+  /// The DHCP process failed because a DHCPNAK packet was received or the user
+  /// aborted the DHCP process at a time when the configuration was not available yet.
+  /// No packet is associated with this event.
+  ///
+  Dhcp4Fail           = 0x0c
+} EFI_DHCP4_EVENT;
+
+/**
+  Callback routine.
+
+  EFI_DHCP4_CALLBACK is provided by the consumer of the EFI DHCPv4 Protocol driver
+  to intercept events that occurred in the configuration process. This structure
+  provides advanced control of each state transition of the DHCP process. The
+  returned status code determines the behavior of the EFI DHCPv4 Protocol driver.
+  There are three possible returned values, which are described in the following
+  table.
+
+  @param  This                  The pointer to the EFI DHCPv4 Protocol instance that is used to
+                                configure this callback function.
+  @param  Context               The pointer to the context that is initialized by
+                                EFI_DHCP4_PROTOCOL.Configure().
+  @param  CurrentState          The current operational state of the EFI DHCPv4 Protocol
+                                driver.
+  @param  Dhcp4Event            The event that occurs in the current state, which usually means a
+                                state transition.
+  @param  Packet                The DHCP packet that is going to be sent or already received.
+  @param  NewPacket             The packet that is used to replace the above Packet.
+
+  @retval EFI_SUCCESS           Tells the EFI DHCPv4 Protocol driver to continue the DHCP process.
+                                When it is in the Dhcp4Selecting state, it tells the EFI DHCPv4 Protocol
+                                driver to stop collecting additional packets. The driver will exit
+                                the Dhcp4Selecting state and enter the Dhcp4Requesting state.
+  @retval EFI_NOT_READY         Only used in the Dhcp4Selecting state. The EFI DHCPv4 Protocol
+                                driver will continue to wait for more packets until the retry
+                                timeout expires.
+  @retval EFI_ABORTED           Tells the EFI DHCPv4 Protocol driver to abort the current process and
+                                return to the Dhcp4Init or Dhcp4InitReboot state.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DHCP4_CALLBACK)(
+  IN  EFI_DHCP4_PROTOCOL         *This,
+  IN  VOID                       *Context,
+  IN  EFI_DHCP4_STATE            CurrentState,
+  IN  EFI_DHCP4_EVENT            Dhcp4Event,
+  IN  EFI_DHCP4_PACKET           *Packet     OPTIONAL,
+  OUT EFI_DHCP4_PACKET           **NewPacket OPTIONAL
+  );
+
+typedef struct {
+  ///
+  /// The number of times to try sending a packet during the Dhcp4SendDiscover
+  /// event and waiting for a response during the Dhcp4RcvdOffer event.
+  /// Set to zero to use the default try counts and timeout values.
+  ///
+  UINT32                      DiscoverTryCount;
+  ///
+  /// The maximum amount of time (in seconds) to wait for returned packets in each
+  /// of the retries. Timeout values of zero will default to a timeout value
+  /// of one second. Set to NULL to use default timeout values.
+  ///
+  UINT32                      *DiscoverTimeout;
+  ///
+  /// The number of times to try sending a packet during the Dhcp4SendRequest event
+  /// and waiting for a response during the Dhcp4RcvdAck event before accepting
+  /// failure. Set to zero to use the default try counts and timeout values.
+  ///
+  UINT32                      RequestTryCount;
+  ///
+  /// The maximum amount of time (in seconds) to wait for return packets in each of the retries.
+  /// Timeout values of zero will default to a timeout value of one second.
+  /// Set to NULL to use default timeout values.
+  ///
+  UINT32                      *RequestTimeout;
+  ///
+  /// For a DHCPDISCOVER, setting this parameter to the previously allocated IP
+  /// address will cause the EFI DHCPv4 Protocol driver to enter the Dhcp4InitReboot state.
+  /// And set this field to 0.0.0.0 to enter the Dhcp4Init state.
+  /// For a DHCPINFORM this parameter should be set to the client network address
+  /// which was assigned to the client during a DHCPDISCOVER.
+  ///
+  EFI_IPv4_ADDRESS            ClientAddress;
+  ///
+  /// The callback function to intercept various events that occurred in
+  /// the DHCP configuration process. Set to NULL to ignore all those events.
+  ///
+  EFI_DHCP4_CALLBACK          Dhcp4Callback;
+  ///
+  /// The pointer to the context that will be passed to Dhcp4Callback when it is called.
+  ///
+  VOID                        *CallbackContext;
+  ///
+  /// Number of DHCP options in the OptionList.
+  ///
+  UINT32                      OptionCount;
+  ///
+  /// List of DHCP options to be included in every packet that is sent during the
+  /// Dhcp4SendDiscover event. Pad options are appended automatically by DHCP driver
+  /// in outgoing DHCP packets. If OptionList itself contains pad option, they are
+  /// ignored by the driver. OptionList can be freed after EFI_DHCP4_PROTOCOL.Configure()
+  /// returns. Ignored if OptionCount is zero.
+  ///
+  EFI_DHCP4_PACKET_OPTION     **OptionList;
+} EFI_DHCP4_CONFIG_DATA;
+
+
+typedef struct {
+  ///
+  /// The EFI DHCPv4 Protocol driver operating state.
+  ///
+  EFI_DHCP4_STATE             State;
+  ///
+  /// The configuration data of the current EFI DHCPv4 Protocol driver instance.
+  ///
+  EFI_DHCP4_CONFIG_DATA       ConfigData;
+  ///
+  /// The client IP address that was acquired from the DHCP server. If it is zero,
+  /// the DHCP acquisition has not completed yet and the following fields in this structure are undefined.
+  ///
+  EFI_IPv4_ADDRESS            ClientAddress;
+  ///
+  /// The local hardware address.
+  ///
+  EFI_MAC_ADDRESS             ClientMacAddress;
+  ///
+  /// The server IP address that is providing the DHCP service to this client.
+  ///
+  EFI_IPv4_ADDRESS            ServerAddress;
+  ///
+  /// The router IP address that was acquired from the DHCP server.
+  /// May be zero if the server does not offer this address.
+  ///
+  EFI_IPv4_ADDRESS            RouterAddress;
+  ///
+  /// The subnet mask of the connected network that was acquired from the DHCP server.
+  ///
+  EFI_IPv4_ADDRESS            SubnetMask;
+  ///
+  /// The lease time (in 1-second units) of the configured IP address.
+  /// The value 0xFFFFFFFF means that the lease time is infinite.
+  /// A default lease of 7 days is used if the DHCP server does not provide a value.
+  ///
+  UINT32                      LeaseTime;
+  ///
+  /// The cached latest DHCPACK or DHCPNAK or BOOTP REPLY packet. May be NULL if no packet is cached.
+  ///
+  EFI_DHCP4_PACKET            *ReplyPacket;
+} EFI_DHCP4_MODE_DATA;
+
+
+typedef struct {
+  ///
+  /// Alternate listening address. It can be a unicast, multicast, or broadcast address.
+  ///
+  EFI_IPv4_ADDRESS            ListenAddress;
+  ///
+  /// The subnet mask of above listening unicast/broadcast IP address.
+  /// Ignored if ListenAddress is a multicast address.
+  ///
+  EFI_IPv4_ADDRESS            SubnetMask;
+  ///
+  /// Alternate station source (or listening) port number.
+  /// If zero, then the default station port number (68) will be used.
+  ///
+  UINT16                      ListenPort;
+} EFI_DHCP4_LISTEN_POINT;
+
+
+typedef struct {
+  ///
+  /// The completion status of transmitting and receiving.
+  ///
+  EFI_STATUS              Status;
+  ///
+  /// If not NULL, the event that will be signaled when the collection process
+  /// completes. If NULL, this function will busy-wait until the collection process competes.
+  ///
+  EFI_EVENT               CompletionEvent;
+  ///
+  /// The pointer to the server IP address. This address may be a unicast, multicast, or broadcast address.
+  ///
+  EFI_IPv4_ADDRESS        RemoteAddress;
+  ///
+  /// The server listening port number. If zero, the default server listening port number (67) will be used.
+  ///
+  UINT16                  RemotePort;
+  ///
+  /// The pointer to the gateway address to override the existing setting.
+  ///
+  EFI_IPv4_ADDRESS        GatewayAddress;
+  ///
+  /// The number of entries in ListenPoints. If zero, the default station address and port number 68 are used.
+  ///
+  UINT32                  ListenPointCount;
+  ///
+  /// An array of station address and port number pairs that are used as receiving filters.
+  /// The first entry is also used as the source address and source port of the outgoing packet.
+  ///
+  EFI_DHCP4_LISTEN_POINT  *ListenPoints;
+  ///
+  /// The number of seconds to collect responses. Zero is invalid.
+  ///
+  UINT32                  TimeoutValue;
+  ///
+  /// The pointer to the packet to be transmitted.
+  ///
+  EFI_DHCP4_PACKET        *Packet;
+  ///
+  /// Number of received packets.
+  ///
+  UINT32                  ResponseCount;
+  ///
+  /// The pointer to the allocated list of received packets.
+  ///
+  EFI_DHCP4_PACKET        *ResponseList;
+} EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN;
+
+
+/**
+  Returns the current operating mode and cached data packet for the EFI DHCPv4 Protocol driver.
+
+  The GetModeData() function returns the current operating mode and cached data
+  packet for the EFI DHCPv4 Protocol driver.
+
+  @param  This          The pointer to the EFI_DHCP4_PROTOCOL instance.
+  @param  Dhcp4ModeData The pointer to storage for the EFI_DHCP4_MODE_DATA structure.
+
+  @retval EFI_SUCCESS           The mode data was returned.
+  @retval EFI_INVALID_PARAMETER This is NULL.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DHCP4_GET_MODE_DATA)(
+  IN  EFI_DHCP4_PROTOCOL      *This,
+  OUT EFI_DHCP4_MODE_DATA     *Dhcp4ModeData
+  );
+
+/**
+  Initializes, changes, or resets the operational settings for the EFI DHCPv4 Protocol driver.
+
+  The Configure() function is used to initialize, change, or reset the operational
+  settings of the EFI DHCPv4 Protocol driver for the communication device on which
+  the EFI DHCPv4 Service Binding Protocol is installed. This function can be
+  successfully called only if both of the following are true:
+  * This instance of the EFI DHCPv4 Protocol driver is in the Dhcp4Stopped, Dhcp4Init,
+    Dhcp4InitReboot, or Dhcp4Bound states.
+  * No other EFI DHCPv4 Protocol driver instance that is controlled by this EFI
+    DHCPv4 Service Binding Protocol driver instance has configured this EFI DHCPv4
+    Protocol driver.
+  When this driver is in the Dhcp4Stopped state, it can transfer into one of the
+  following two possible initial states:
+  * Dhcp4Init
+  * Dhcp4InitReboot.
+  The driver can transfer into these states by calling Configure() with a non-NULL
+  Dhcp4CfgData. The driver will transfer into the appropriate state based on the
+  supplied client network address in the ClientAddress parameter and DHCP options
+  in the OptionList parameter as described in RFC 2131.
+  When Configure() is called successfully while Dhcp4CfgData is set to NULL, the
+  default configuring data will be reset in the EFI DHCPv4 Protocol driver and
+  the state of the EFI DHCPv4 Protocol driver will not be changed. If one instance
+  wants to make it possible for another instance to configure the EFI DHCPv4 Protocol
+  driver, it must call this function with Dhcp4CfgData set to NULL.
+
+  @param  This                   The pointer to the EFI_DHCP4_PROTOCOL instance.
+  @param  Dhcp4CfgData           The pointer to the EFI_DHCP4_CONFIG_DATA.
+
+  @retval EFI_SUCCESS           The EFI DHCPv4 Protocol driver is now in the Dhcp4Init or
+                                Dhcp4InitReboot state, if the original state of this driver
+                                was Dhcp4Stopped, Dhcp4Init,Dhcp4InitReboot, or Dhcp4Bound
+                                and the value of Dhcp4CfgData was not NULL.
+                                Otherwise, the state was left unchanged.
+  @retval EFI_ACCESS_DENIED     This instance of the EFI DHCPv4 Protocol driver was not in the
+                                Dhcp4Stopped, Dhcp4Init, Dhcp4InitReboot, or Dhcp4Bound state;
+                                Or onother instance of this EFI DHCPv4 Protocol driver is already
+                                in a valid configured state.
+  @retval EFI_INVALID_PARAMETER One or more following conditions are TRUE:
+                                This is NULL.
+                                DiscoverTryCount > 0 and DiscoverTimeout is NULL
+                                RequestTryCount > 0 and RequestTimeout is NULL.
+                                OptionCount >0 and OptionList is NULL.
+                                ClientAddress is not a valid unicast address.
+  @retval EFI_OUT_OF_RESOURCES  Required system resources could not be allocated.
+  @retval EFI_DEVICE_ERROR      An unexpected system or network error occurred.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DHCP4_CONFIGURE)(
+  IN EFI_DHCP4_PROTOCOL       *This,
+  IN EFI_DHCP4_CONFIG_DATA    *Dhcp4CfgData  OPTIONAL
+  );
+
+
+/**
+  Starts the DHCP configuration process.
+
+  The Start() function starts the DHCP configuration process. This function can
+  be called only when the EFI DHCPv4 Protocol driver is in the Dhcp4Init or
+  Dhcp4InitReboot state.
+  If the DHCP process completes successfully, the state of the EFI DHCPv4 Protocol
+  driver will be transferred through Dhcp4Selecting and Dhcp4Requesting to the
+  Dhcp4Bound state. The CompletionEvent will then be signaled if it is not NULL.
+  If the process aborts, either by the user or by some unexpected network error,
+  the state is restored to the Dhcp4Init state. The Start() function can be called
+  again to restart the process.
+  Refer to RFC 2131 for precise state transitions during this process. At the
+  time when each event occurs in this process, the callback function that was set
+  by EFI_DHCP4_PROTOCOL.Configure() will be called and the user can take this
+  opportunity to control the process.
+
+  @param  This            The pointer to the EFI_DHCP4_PROTOCOL instance.
+  @param  CompletionEvent If not NULL, it indicates the event that will be signaled when the
+                          EFI DHCPv4 Protocol driver is transferred into the
+                          Dhcp4Bound state or when the DHCP process is aborted.
+                          EFI_DHCP4_PROTOCOL.GetModeData() can be called to
+                          check the completion status. If NULL,
+                          EFI_DHCP4_PROTOCOL.Start() will wait until the driver
+                          is transferred into the Dhcp4Bound state or the process fails.
+
+  @retval EFI_SUCCESS           The DHCP configuration process has started, or it has completed
+                                when CompletionEvent is NULL.
+  @retval EFI_NOT_STARTED       The EFI DHCPv4 Protocol driver is in the Dhcp4Stopped
+                                state. EFI_DHCP4_PROTOCOL. Configure() needs to be called.
+  @retval EFI_INVALID_PARAMETER This is NULL.
+  @retval EFI_OUT_OF_RESOURCES  Required system resources could not be allocated.
+  @retval EFI_TIMEOUT           The DHCP configuration process failed because no response was
+                                received from the server within the specified timeout value.
+  @retval EFI_ABORTED           The user aborted the DHCP process.
+  @retval EFI_ALREADY_STARTED   Some other EFI DHCPv4 Protocol instance already started the
+                                DHCP process.
+  @retval EFI_DEVICE_ERROR      An unexpected system or network error occurred.
+  @retval EFI_NO_MEDIA          There was a media error.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DHCP4_START)(
+  IN EFI_DHCP4_PROTOCOL       *This,
+  IN EFI_EVENT                CompletionEvent   OPTIONAL
+  );
+
+/**
+  Extends the lease time by sending a request packet.
+
+  The RenewRebind() function is used to manually extend the lease time when the
+  EFI DHCPv4 Protocol driver is in the Dhcp4Bound state, and the lease time has
+  not expired yet. This function will send a request packet to the previously
+  found server (or to any server when RebindRequest is TRUE) and transfer the
+  state into the Dhcp4Renewing state (or Dhcp4Rebinding when RebindingRequest is
+  TRUE). When a response is received, the state is returned to Dhcp4Bound.
+  If no response is received before the try count is exceeded (the RequestTryCount
+  field that is specified in EFI_DHCP4_CONFIG_DATA) but before the lease time that
+  was issued by the previous server expires, the driver will return to the Dhcp4Bound
+  state, and the previous configuration is restored. The outgoing and incoming packets
+  can be captured by the EFI_DHCP4_CALLBACK function.
+
+  @param  This            The pointer to the EFI_DHCP4_PROTOCOL instance.
+  @param  RebindRequest   If TRUE, this function broadcasts the request packets and enters
+                          the Dhcp4Rebinding state. Otherwise, it sends a unicast
+                          request packet and enters the Dhcp4Renewing state.
+  @param  CompletionEvent If not NULL, this event is signaled when the renew/rebind phase
+                          completes or some error occurs.
+                          EFI_DHCP4_PROTOCOL.GetModeData() can be called to
+                          check the completion status. If NULL,
+                          EFI_DHCP4_PROTOCOL.RenewRebind() will busy-wait
+                          until the DHCP process finishes.
+
+  @retval EFI_SUCCESS           The EFI DHCPv4 Protocol driver is now in the
+                                Dhcp4Renewing state or is back to the Dhcp4Bound state.
+  @retval EFI_NOT_STARTED       The EFI DHCPv4 Protocol driver is in the Dhcp4Stopped
+                                state. EFI_DHCP4_PROTOCOL.Configure() needs to
+                                be called.
+  @retval EFI_INVALID_PARAMETER This is NULL.
+  @retval EFI_TIMEOUT           There was no response from the server when the try count was
+                                exceeded.
+  @retval EFI_ACCESS_DENIED     The driver is not in the Dhcp4Bound state.
+  @retval EFI_DEVICE_ERROR      An unexpected system or network error occurred.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DHCP4_RENEW_REBIND)(
+  IN EFI_DHCP4_PROTOCOL       *This,
+  IN BOOLEAN                  RebindRequest,
+  IN EFI_EVENT                CompletionEvent  OPTIONAL
+  );
+
+/**
+  Releases the current address configuration.
+
+  The Release() function releases the current configured IP address by doing either
+  of the following:
+  * Sending a DHCPRELEASE packet when the EFI DHCPv4 Protocol driver is in the
+    Dhcp4Bound state
+  * Setting the previously assigned IP address that was provided with the
+    EFI_DHCP4_PROTOCOL.Configure() function to 0.0.0.0 when the driver is in
+    Dhcp4InitReboot state
+  After a successful call to this function, the EFI DHCPv4 Protocol driver returns
+  to the Dhcp4Init state, and any subsequent incoming packets will be discarded silently.
+
+  @param  This                  The pointer to the EFI_DHCP4_PROTOCOL instance.
+
+  @retval EFI_SUCCESS           The EFI DHCPv4 Protocol driver is now in the Dhcp4Init phase.
+  @retval EFI_INVALID_PARAMETER This is NULL.
+  @retval EFI_ACCESS_DENIED     The EFI DHCPv4 Protocol driver is not Dhcp4InitReboot state.
+  @retval EFI_DEVICE_ERROR      An unexpected system or network error occurred.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DHCP4_RELEASE)(
+  IN EFI_DHCP4_PROTOCOL       *This
+  );
+
+/**
+  Stops the current address configuration.
+
+  The Stop() function is used to stop the DHCP configuration process. After this
+  function is called successfully, the EFI DHCPv4 Protocol driver is transferred
+  into the Dhcp4Stopped state. EFI_DHCP4_PROTOCOL.Configure() needs to be called
+  before DHCP configuration process can be started again. This function can be
+  called when the EFI DHCPv4 Protocol driver is in any state.
+
+  @param  This                  The pointer to the EFI_DHCP4_PROTOCOL instance.
+
+  @retval EFI_SUCCESS           The EFI DHCPv4 Protocol driver is now in the Dhcp4Stopped phase.
+  @retval EFI_INVALID_PARAMETER This is NULL.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DHCP4_STOP)(
+  IN EFI_DHCP4_PROTOCOL       *This
+  );
+
+/**
+  Builds a DHCP packet, given the options to be appended or deleted or replaced.
+
+  The Build() function is used to assemble a new packet from the original packet
+  by replacing or deleting existing options or appending new options. This function
+  does not change any state of the EFI DHCPv4 Protocol driver and can be used at
+  any time.
+
+  @param  This        The pointer to the EFI_DHCP4_PROTOCOL instance.
+  @param  SeedPacket  Initial packet to be used as a base for building new packet.
+  @param  DeleteCount Number of opcodes in the DeleteList.
+  @param  DeleteList  List of opcodes to be deleted from the seed packet.
+                      Ignored if DeleteCount is zero.
+  @param  AppendCount Number of entries in the OptionList.
+  @param  AppendList  The pointer to a DHCP option list to be appended to SeedPacket.
+                      If SeedPacket also contains options in this list, they are
+                      replaced by new options (except pad option). Ignored if
+                      AppendCount is zero. Type EFI_DHCP4_PACKET_OPTION
+  @param  NewPacket   The pointer to storage for the pointer to the new allocated packet.
+                      Use the EFI Boot Service FreePool() on the resulting pointer
+                      when done with the packet.
+
+  @retval EFI_SUCCESS           The new packet was built.
+  @retval EFI_OUT_OF_RESOURCES  Storage for the new packet could not be allocated.
+  @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
+                                This is NULL.
+                                SeedPacket is NULL.
+                                SeedPacket is not a well-formed DHCP packet.
+                                AppendCount is not zero and AppendList is NULL.
+                                DeleteCount is not zero and DeleteList is NULL.
+                                NewPacket is NULL
+                                Both DeleteCount and AppendCount are zero and
+                                NewPacket is not NULL.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DHCP4_BUILD)(
+  IN  EFI_DHCP4_PROTOCOL      *This,
+  IN  EFI_DHCP4_PACKET        *SeedPacket,
+  IN  UINT32                  DeleteCount,
+  IN  UINT8                   *DeleteList         OPTIONAL,
+  IN  UINT32                  AppendCount,
+  IN  EFI_DHCP4_PACKET_OPTION *AppendList[]       OPTIONAL,
+  OUT EFI_DHCP4_PACKET        **NewPacket
+  );
+
+
+/**
+  Transmits a DHCP formatted packet and optionally waits for responses.
+
+  The TransmitReceive() function is used to transmit a DHCP packet and optionally
+  wait for the response from servers. This function does not change the state of
+  the EFI DHCPv4 Protocol driver. It can be used at any time because of this.
+
+  @param  This    The pointer to the EFI_DHCP4_PROTOCOL instance.
+  @param  Token   The pointer to the EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN structure.
+
+  @retval EFI_SUCCESS           The packet was successfully queued for transmission.
+  @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
+                                This is NULL.
+                                Token.RemoteAddress is zero.
+                                Token.Packet is NULL.
+                                Token.Packet is not a well-formed DHCP packet.
+                                The transaction ID in Token.Packet is in use by another DHCP process.
+  @retval EFI_NOT_READY         The previous call to this function has not finished yet. Try to call
+                                this function after collection process completes.
+  @retval EFI_NO_MAPPING        The default station address is not available yet.
+  @retval EFI_OUT_OF_RESOURCES  Required system resources could not be allocated.
+  @retval EFI_UNSUPPORTED       The implementation doesn't support this function
+  @retval Others                Some other unexpected error occurred.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DHCP4_TRANSMIT_RECEIVE)(
+  IN EFI_DHCP4_PROTOCOL                *This,
+  IN EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN  *Token
+  );
+
+
+/**
+  Parses the packed DHCP option data.
+
+  The Parse() function is used to retrieve the option list from a DHCP packet.
+  If *OptionCount isn't zero, and there is enough space for all the DHCP options
+  in the Packet, each element of PacketOptionList is set to point to somewhere in
+  the Packet->Dhcp4.Option where a new DHCP option begins. If RFC3396 is supported,
+  the caller should reassemble the parsed DHCP options to get the final result.
+  If *OptionCount is zero or there isn't enough space for all of them, the number
+  of DHCP options in the Packet is returned in OptionCount.
+
+  @param  This             The pointer to the EFI_DHCP4_PROTOCOL instance.
+  @param  Packet           The pointer to packet to be parsed.
+  @param  OptionCount      On input, the number of entries in the PacketOptionList.
+                           On output, the number of entries that were written into the
+                           PacketOptionList.
+  @param  PacketOptionList A list of packet option entries to be filled in. End option or pad
+                           options are not included.
+
+  @retval EFI_SUCCESS           The packet was successfully parsed.
+  @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
+                                This is NULL.
+                                The packet is NULL.
+                                The packet is not a well-formed DHCP packet.
+                                OptionCount is NULL.
+  @retval EFI_BUFFER_TOO_SMALL  One or more of the following conditions is TRUE:
+                                1) *OptionCount is smaller than the number of options that
+                                were found in the Packet.
+                                2) PacketOptionList is NULL.
+  @retval EFI_OUT_OF_RESOURCE   The packet failed to parse because of a resource shortage.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DHCP4_PARSE)(
+  IN EFI_DHCP4_PROTOCOL        *This,
+  IN EFI_DHCP4_PACKET          *Packet,
+  IN OUT UINT32                *OptionCount,
+  OUT EFI_DHCP4_PACKET_OPTION  *PacketOptionList[]  OPTIONAL
+  );
+
+///
+/// This protocol is used to collect configuration information for the EFI IPv4 Protocol drivers
+/// and to provide DHCPv4 server and PXE boot server discovery services.
+///
+struct _EFI_DHCP4_PROTOCOL {
+  EFI_DHCP4_GET_MODE_DATA      GetModeData;
+  EFI_DHCP4_CONFIGURE          Configure;
+  EFI_DHCP4_START              Start;
+  EFI_DHCP4_RENEW_REBIND       RenewRebind;
+  EFI_DHCP4_RELEASE            Release;
+  EFI_DHCP4_STOP               Stop;
+  EFI_DHCP4_BUILD              Build;
+  EFI_DHCP4_TRANSMIT_RECEIVE   TransmitReceive;
+  EFI_DHCP4_PARSE              Parse;
+};
+
+extern EFI_GUID gEfiDhcp4ProtocolGuid;
+extern EFI_GUID gEfiDhcp4ServiceBindingProtocolGuid;
+
+#endif
diff --git a/src/include/ipxe/efi/Protocol/Ip4.h b/src/include/ipxe/efi/Protocol/Ip4.h
new file mode 100644 (file)
index 0000000..f174c0c
--- /dev/null
@@ -0,0 +1,614 @@
+/** @file
+  This file defines the EFI IPv4 (Internet Protocol version 4)
+  Protocol interface. It is split into the following three main
+  sections:
+  - EFI IPv4 Service Binding Protocol
+  - EFI IPv4 Variable (deprecated in UEFI 2.4B)
+  - EFI IPv4 Protocol.
+  The EFI IPv4 Protocol provides basic network IPv4 packet I/O services,
+  which includes support foR a subset of the Internet Control Message
+  Protocol (ICMP) and may include support for the Internet Group Management
+  Protocol (IGMP).
+
+Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  @par Revision Reference:
+  This Protocol is introduced in UEFI Specification 2.0.
+
+**/
+
+#ifndef __EFI_IP4_PROTOCOL_H__
+#define __EFI_IP4_PROTOCOL_H__
+
+FILE_LICENCE ( BSD3 );
+
+#include <ipxe/efi/Protocol/ManagedNetwork.h>
+
+#define EFI_IP4_SERVICE_BINDING_PROTOCOL_GUID \
+  { \
+    0xc51711e7, 0xb4bf, 0x404a, {0xbf, 0xb8, 0x0a, 0x04, 0x8e, 0xf1, 0xff, 0xe4 } \
+  }
+
+#define EFI_IP4_PROTOCOL_GUID \
+  { \
+    0x41d94cd2, 0x35b6, 0x455a, {0x82, 0x58, 0xd4, 0xe5, 0x13, 0x34, 0xaa, 0xdd } \
+  }
+
+typedef struct _EFI_IP4_PROTOCOL EFI_IP4_PROTOCOL;
+
+///
+/// EFI_IP4_ADDRESS_PAIR is deprecated in the UEFI 2.4B and should not be used any more.
+/// The definition in here is only present to provide backwards compatability.
+///
+typedef struct {
+  EFI_HANDLE              InstanceHandle;
+  EFI_IPv4_ADDRESS        Ip4Address;
+  EFI_IPv4_ADDRESS        SubnetMask;
+} EFI_IP4_ADDRESS_PAIR;
+
+///
+/// EFI_IP4_VARIABLE_DATA is deprecated in the UEFI 2.4B and should not be used any more.
+/// The definition in here is only present to provide backwards compatability.
+///
+typedef struct {
+  EFI_HANDLE              DriverHandle;
+  UINT32                  AddressCount;
+  EFI_IP4_ADDRESS_PAIR    AddressPairs[1];
+} EFI_IP4_VARIABLE_DATA;
+
+typedef struct {
+  ///
+  /// The default IPv4 protocol packets to send and receive. Ignored
+  /// when AcceptPromiscuous is TRUE.
+  ///
+  UINT8                   DefaultProtocol;
+  ///
+  /// Set to TRUE to receive all IPv4 packets that get through the receive filters.
+  /// Set to FALSE to receive only the DefaultProtocol IPv4
+  /// packets that get through the receive filters.
+  ///
+  BOOLEAN                 AcceptAnyProtocol;
+  ///
+  /// Set to TRUE to receive ICMP error report packets. Ignored when
+  /// AcceptPromiscuous or AcceptAnyProtocol is TRUE.
+  ///
+  BOOLEAN                 AcceptIcmpErrors;
+  ///
+  /// Set to TRUE to receive broadcast IPv4 packets. Ignored when
+  /// AcceptPromiscuous is TRUE.
+  /// Set to FALSE to stop receiving broadcast IPv4 packets.
+  ///
+  BOOLEAN                 AcceptBroadcast;
+  ///
+  /// Set to TRUE to receive all IPv4 packets that are sent to any
+  /// hardware address or any protocol address.
+  /// Set to FALSE to stop receiving all promiscuous IPv4 packets
+  ///
+  BOOLEAN                 AcceptPromiscuous;
+  ///
+  /// Set to TRUE to use the default IPv4 address and default routing table.
+  ///
+  BOOLEAN                 UseDefaultAddress;
+  ///
+  /// The station IPv4 address that will be assigned to this EFI IPv4Protocol instance.
+  ///
+  EFI_IPv4_ADDRESS        StationAddress;
+  ///
+  /// The subnet address mask that is associated with the station address.
+  ///
+  EFI_IPv4_ADDRESS        SubnetMask;
+  ///
+  /// TypeOfService field in transmitted IPv4 packets.
+  ///
+  UINT8                   TypeOfService;
+  ///
+  /// TimeToLive field in transmitted IPv4 packets.
+  ///
+  UINT8                   TimeToLive;
+  ///
+  /// State of the DoNotFragment bit in transmitted IPv4 packets.
+  ///
+  BOOLEAN                 DoNotFragment;
+  ///
+  /// Set to TRUE to send and receive unformatted packets. The other
+  /// IPv4 receive filters are still applied. Fragmentation is disabled for RawData mode.
+  ///
+  BOOLEAN                 RawData;
+  ///
+  /// The timer timeout value (number of microseconds) for the
+  /// receive timeout event to be associated with each assembled
+  /// packet. Zero means do not drop assembled packets.
+  ///
+  UINT32                  ReceiveTimeout;
+  ///
+  /// The timer timeout value (number of microseconds) for the
+  /// transmit timeout event to be associated with each outgoing
+  /// packet. Zero means do not drop outgoing packets.
+  ///
+  UINT32                  TransmitTimeout;
+} EFI_IP4_CONFIG_DATA;
+
+
+typedef struct {
+  EFI_IPv4_ADDRESS        SubnetAddress;
+  EFI_IPv4_ADDRESS        SubnetMask;
+  EFI_IPv4_ADDRESS        GatewayAddress;
+} EFI_IP4_ROUTE_TABLE;
+
+typedef struct {
+  UINT8                   Type;
+  UINT8                   Code;
+} EFI_IP4_ICMP_TYPE;
+
+typedef struct {
+  ///
+  /// Set to TRUE after this EFI IPv4 Protocol instance has been successfully configured.
+  ///
+  BOOLEAN                 IsStarted;
+  ///
+  /// The maximum packet size, in bytes, of the packet which the upper layer driver could feed.
+  ///
+  UINT32                  MaxPacketSize;
+  ///
+  /// Current configuration settings.
+  ///
+  EFI_IP4_CONFIG_DATA     ConfigData;
+  ///
+  /// Set to TRUE when the EFI IPv4 Protocol instance has a station address and subnet mask.
+  ///
+  BOOLEAN                 IsConfigured;
+  ///
+  /// Number of joined multicast groups.
+  ///
+  UINT32                  GroupCount;
+  ///
+  /// List of joined multicast group addresses.
+  ///
+  EFI_IPv4_ADDRESS        *GroupTable;
+  ///
+  /// Number of entries in the routing table.
+  ///
+  UINT32                  RouteCount;
+  ///
+  /// Routing table entries.
+  ///
+  EFI_IP4_ROUTE_TABLE     *RouteTable;
+  ///
+  /// Number of entries in the supported ICMP types list.
+  ///
+  UINT32                  IcmpTypeCount;
+  ///
+  /// Array of ICMP types and codes that are supported by this EFI IPv4 Protocol driver
+  ///
+  EFI_IP4_ICMP_TYPE       *IcmpTypeList;
+} EFI_IP4_MODE_DATA;
+
+#pragma pack(1)
+
+typedef struct {
+  UINT8                   HeaderLength:4;
+  UINT8                   Version:4;
+  UINT8                   TypeOfService;
+  UINT16                  TotalLength;
+  UINT16                  Identification;
+  UINT16                  Fragmentation;
+  UINT8                   TimeToLive;
+  UINT8                   Protocol;
+  UINT16                  Checksum;
+  EFI_IPv4_ADDRESS        SourceAddress;
+  EFI_IPv4_ADDRESS        DestinationAddress;
+} EFI_IP4_HEADER;
+#pragma pack()
+
+
+typedef struct {
+  UINT32                  FragmentLength;
+  VOID                    *FragmentBuffer;
+} EFI_IP4_FRAGMENT_DATA;
+
+
+typedef struct {
+  EFI_TIME               TimeStamp;
+  EFI_EVENT              RecycleSignal;
+  UINT32                 HeaderLength;
+  EFI_IP4_HEADER         *Header;
+  UINT32                 OptionsLength;
+  VOID                   *Options;
+  UINT32                 DataLength;
+  UINT32                 FragmentCount;
+  EFI_IP4_FRAGMENT_DATA  FragmentTable[1];
+} EFI_IP4_RECEIVE_DATA;
+
+
+typedef struct {
+  EFI_IPv4_ADDRESS       SourceAddress;
+  EFI_IPv4_ADDRESS       GatewayAddress;
+  UINT8                  Protocol;
+  UINT8                  TypeOfService;
+  UINT8                  TimeToLive;
+  BOOLEAN                DoNotFragment;
+} EFI_IP4_OVERRIDE_DATA;
+
+typedef struct {
+  EFI_IPv4_ADDRESS       DestinationAddress;
+  EFI_IP4_OVERRIDE_DATA  *OverrideData;      //OPTIONAL
+  UINT32                 OptionsLength;      //OPTIONAL
+  VOID                   *OptionsBuffer;     //OPTIONAL
+  UINT32                 TotalDataLength;
+  UINT32                 FragmentCount;
+  EFI_IP4_FRAGMENT_DATA  FragmentTable[1];
+} EFI_IP4_TRANSMIT_DATA;
+
+typedef struct {
+  ///
+  /// This Event will be signaled after the Status field is updated
+  /// by the EFI IPv4 Protocol driver. The type of Event must be
+  /// EFI_NOTIFY_SIGNAL. The Task Priority Level (TPL) of
+  /// Event must be lower than or equal to TPL_CALLBACK.
+  ///
+  EFI_EVENT                Event;
+  ///
+  /// The status that is returned to the caller at the end of the operation
+  /// to indicate whether this operation completed successfully.
+  ///
+  EFI_STATUS               Status;
+  union {
+    ///
+    /// When this token is used for receiving, RxData is a pointer to the EFI_IP4_RECEIVE_DATA.
+    ///
+    EFI_IP4_RECEIVE_DATA   *RxData;
+    ///
+    /// When this token is used for transmitting, TxData is a pointer to the EFI_IP4_TRANSMIT_DATA.
+    ///
+    EFI_IP4_TRANSMIT_DATA  *TxData;
+  } Packet;
+} EFI_IP4_COMPLETION_TOKEN;
+
+/**
+  Gets the current operational settings for this instance of the EFI IPv4 Protocol driver.
+
+  The GetModeData() function returns the current operational mode data for this
+  driver instance. The data fields in EFI_IP4_MODE_DATA are read only. This
+  function is used optionally to retrieve the operational mode data of underlying
+  networks or drivers.
+
+  @param  This          The pointer to the EFI_IP4_PROTOCOL instance.
+  @param  Ip4ModeData   The pointer to the EFI IPv4 Protocol mode data structure.
+  @param  MnpConfigData The pointer to the managed network configuration data structure.
+  @param  SnpModeData   The pointer to the simple network mode data structure.
+
+  @retval EFI_SUCCESS           The operation completed successfully.
+  @retval EFI_INVALID_PARAMETER This is NULL.
+  @retval EFI_OUT_OF_RESOURCES  The required mode data could not be allocated.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_IP4_GET_MODE_DATA)(
+  IN CONST  EFI_IP4_PROTOCOL                *This,
+  OUT       EFI_IP4_MODE_DATA               *Ip4ModeData     OPTIONAL,
+  OUT       EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData   OPTIONAL,
+  OUT       EFI_SIMPLE_NETWORK_MODE         *SnpModeData     OPTIONAL
+  );
+
+/**
+  Assigns an IPv4 address and subnet mask to this EFI IPv4 Protocol driver instance.
+
+  The Configure() function is used to set, change, or reset the operational
+  parameters and filter settings for this EFI IPv4 Protocol instance. Until these
+  parameters have been set, no network traffic can be sent or received by this
+  instance. Once the parameters have been reset (by calling this function with
+  IpConfigData set to NULL), no more traffic can be sent or received until these
+  parameters have been set again. Each EFI IPv4 Protocol instance can be started
+  and stopped independently of each other by enabling or disabling their receive
+  filter settings with the Configure() function.
+
+  When IpConfigData.UseDefaultAddress is set to FALSE, the new station address will
+  be appended as an alias address into the addresses list in the EFI IPv4 Protocol
+  driver. While set to TRUE, Configure() will trigger the EFI_IP4_CONFIG_PROTOCOL
+  to retrieve the default IPv4 address if it is not available yet. Clients could
+  frequently call GetModeData() to check the status to ensure that the default IPv4
+  address is ready.
+
+  If operational parameters are reset or changed, any pending transmit and receive
+  requests will be cancelled. Their completion token status will be set to EFI_ABORTED
+  and their events will be signaled.
+
+  @param  This         The pointer to the EFI_IP4_PROTOCOL instance.
+  @param  IpConfigData The pointer to the EFI IPv4 Protocol configuration data structure.
+
+  @retval EFI_SUCCESS           The driver instance was successfully opened.
+  @retval EFI_NO_MAPPING        When using the default address, configuration (DHCP, BOOTP,
+                                RARP, etc.) is not finished yet.
+  @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
+                                This is NULL.
+                                IpConfigData.StationAddress is not a unicast IPv4 address.
+                                IpConfigData.SubnetMask is not a valid IPv4 subnet
+  @retval EFI_UNSUPPORTED       One or more of the following conditions is TRUE:
+                                A configuration protocol (DHCP, BOOTP, RARP, etc.) could
+                                not be located when clients choose to use the default IPv4
+                                address. This EFI IPv4 Protocol implementation does not
+                                support this requested filter or timeout setting.
+  @retval EFI_OUT_OF_RESOURCES  The EFI IPv4 Protocol driver instance data could not be allocated.
+  @retval EFI_ALREADY_STARTED   The interface is already open and must be stopped before the
+                                IPv4 address or subnet mask can be changed. The interface must
+                                also be stopped when switching to/from raw packet mode.
+  @retval EFI_DEVICE_ERROR      An unexpected system or network error occurred. The EFI IPv4
+                                Protocol driver instance is not opened.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_IP4_CONFIGURE)(
+  IN EFI_IP4_PROTOCOL    *This,
+  IN EFI_IP4_CONFIG_DATA *IpConfigData     OPTIONAL
+  );
+
+/**
+  Joins and leaves multicast groups.
+
+  The Groups() function is used to join and leave multicast group sessions. Joining
+  a group will enable reception of matching multicast packets. Leaving a group will
+  disable the multicast packet reception.
+
+  If JoinFlag is FALSE and GroupAddress is NULL, all joined groups will be left.
+
+  @param  This                  The pointer to the EFI_IP4_PROTOCOL instance.
+  @param  JoinFlag              Set to TRUE to join the multicast group session and FALSE to leave.
+  @param  GroupAddress          The pointer to the IPv4 multicast address.
+
+  @retval EFI_SUCCESS           The operation completed successfully.
+  @retval EFI_INVALID_PARAMETER One or more of the following is TRUE:
+                                - This is NULL.
+                                - JoinFlag is TRUE and GroupAddress is NULL.
+                                - GroupAddress is not NULL and *GroupAddress is
+                                  not a multicast IPv4 address.
+  @retval EFI_NOT_STARTED       This instance has not been started.
+  @retval EFI_NO_MAPPING        When using the default address, configuration (DHCP, BOOTP,
+                                RARP, etc.) is not finished yet.
+  @retval EFI_OUT_OF_RESOURCES  System resources could not be allocated.
+  @retval EFI_UNSUPPORTED       This EFI IPv4 Protocol implementation does not support multicast groups.
+  @retval EFI_ALREADY_STARTED   The group address is already in the group table (when
+                                JoinFlag is TRUE).
+  @retval EFI_NOT_FOUND         The group address is not in the group table (when JoinFlag is FALSE).
+  @retval EFI_DEVICE_ERROR      An unexpected system or network error occurred.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_IP4_GROUPS)(
+  IN EFI_IP4_PROTOCOL    *This,
+  IN BOOLEAN             JoinFlag,
+  IN EFI_IPv4_ADDRESS    *GroupAddress  OPTIONAL
+  );
+
+/**
+  Adds and deletes routing table entries.
+
+  The Routes() function adds a route to or deletes a route from the routing table.
+
+  Routes are determined by comparing the SubnetAddress with the destination IPv4
+  address arithmetically AND-ed with the SubnetMask. The gateway address must be
+  on the same subnet as the configured station address.
+
+  The default route is added with SubnetAddress and SubnetMask both set to 0.0.0.0.
+  The default route matches all destination IPv4 addresses that do not match any
+  other routes.
+
+  A GatewayAddress that is zero is a nonroute. Packets are sent to the destination
+  IP address if it can be found in the ARP cache or on the local subnet. One automatic
+  nonroute entry will be inserted into the routing table for outgoing packets that
+  are addressed to a local subnet (gateway address of 0.0.0.0).
+
+  Each EFI IPv4 Protocol instance has its own independent routing table. Those EFI
+  IPv4 Protocol instances that use the default IPv4 address will also have copies
+  of the routing table that was provided by the EFI_IP4_CONFIG_PROTOCOL, and these
+  copies will be updated whenever the EIF IPv4 Protocol driver reconfigures its
+  instances. As a result, client modification to the routing table will be lost.
+
+  @param  This                   The pointer to the EFI_IP4_PROTOCOL instance.
+  @param  DeleteRoute            Set to TRUE to delete this route from the routing table. Set to
+                                 FALSE to add this route to the routing table. SubnetAddress
+                                 and SubnetMask are used as the key to each route entry.
+  @param  SubnetAddress          The address of the subnet that needs to be routed.
+  @param  SubnetMask             The subnet mask of SubnetAddress.
+  @param  GatewayAddress         The unicast gateway IPv4 address for this route.
+
+  @retval EFI_SUCCESS            The operation completed successfully.
+  @retval EFI_NOT_STARTED        The driver instance has not been started.
+  @retval EFI_NO_MAPPING         When using the default address, configuration (DHCP, BOOTP,
+                                 RARP, etc.) is not finished yet.
+  @retval EFI_INVALID_PARAMETER  One or more of the following conditions is TRUE:
+                                 - This is NULL.
+                                 - SubnetAddress is NULL.
+                                 - SubnetMask is NULL.
+                                 - GatewayAddress is NULL.
+                                 - *SubnetAddress is not a valid subnet address.
+                                 - *SubnetMask is not a valid subnet mask.
+                                 - *GatewayAddress is not a valid unicast IPv4 address.
+  @retval EFI_OUT_OF_RESOURCES   Could not add the entry to the routing table.
+  @retval EFI_NOT_FOUND          This route is not in the routing table (when DeleteRoute is TRUE).
+  @retval EFI_ACCESS_DENIED      The route is already defined in the routing table (when
+                                 DeleteRoute is FALSE).
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_IP4_ROUTES)(
+  IN EFI_IP4_PROTOCOL    *This,
+  IN BOOLEAN             DeleteRoute,
+  IN EFI_IPv4_ADDRESS    *SubnetAddress,
+  IN EFI_IPv4_ADDRESS    *SubnetMask,
+  IN EFI_IPv4_ADDRESS    *GatewayAddress
+  );
+
+/**
+  Places outgoing data packets into the transmit queue.
+
+  The Transmit() function places a sending request in the transmit queue of this
+  EFI IPv4 Protocol instance. Whenever the packet in the token is sent out or some
+  errors occur, the event in the token will be signaled and the status is updated.
+
+  @param  This  The pointer to the EFI_IP4_PROTOCOL instance.
+  @param  Token The pointer to the transmit token.
+
+  @retval  EFI_SUCCESS           The data has been queued for transmission.
+  @retval  EFI_NOT_STARTED       This instance has not been started.
+  @retval  EFI_NO_MAPPING        When using the default address, configuration (DHCP, BOOTP,
+                                 RARP, etc.) is not finished yet.
+  @retval  EFI_INVALID_PARAMETER One or more pameters are invalid.
+  @retval  EFI_ACCESS_DENIED     The transmit completion token with the same Token.Event
+                                 was already in the transmit queue.
+  @retval  EFI_NOT_READY         The completion token could not be queued because the transmit
+                                 queue is full.
+  @retval  EFI_NOT_FOUND         Not route is found to destination address.
+  @retval  EFI_OUT_OF_RESOURCES  Could not queue the transmit data.
+  @retval  EFI_BUFFER_TOO_SMALL  Token.Packet.TxData.TotalDataLength is too
+                                 short to transmit.
+  @retval  EFI_BAD_BUFFER_SIZE   The length of the IPv4 header + option length + total data length is
+                                 greater than MTU (or greater than the maximum packet size if
+                                 Token.Packet.TxData.OverrideData.
+                                 DoNotFragment is TRUE.)
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_IP4_TRANSMIT)(
+  IN EFI_IP4_PROTOCOL          *This,
+  IN EFI_IP4_COMPLETION_TOKEN  *Token
+  );
+
+/**
+  Places a receiving request into the receiving queue.
+
+  The Receive() function places a completion token into the receive packet queue.
+  This function is always asynchronous.
+
+  The Token.Event field in the completion token must be filled in by the caller
+  and cannot be NULL. When the receive operation completes, the EFI IPv4 Protocol
+  driver updates the Token.Status and Token.Packet.RxData fields and the Token.Event
+  is signaled.
+
+  @param  This  The pointer to the EFI_IP4_PROTOCOL instance.
+  @param  Token The pointer to a token that is associated with the receive data descriptor.
+
+  @retval EFI_SUCCESS           The receive completion token was cached.
+  @retval EFI_NOT_STARTED       This EFI IPv4 Protocol instance has not been started.
+  @retval EFI_NO_MAPPING        When using the default address, configuration (DHCP, BOOTP, RARP, etc.)
+                                is not finished yet.
+  @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
+                                - This is NULL.
+                                - Token is NULL.
+                                - Token.Event is NULL.
+  @retval EFI_OUT_OF_RESOURCES  The receive completion token could not be queued due to a lack of system
+                                resources (usually memory).
+  @retval EFI_DEVICE_ERROR      An unexpected system or network error occurred.
+                                The EFI IPv4 Protocol instance has been reset to startup defaults.
+  @retval EFI_ACCESS_DENIED     The receive completion token with the same Token.Event was already
+                                in the receive queue.
+  @retval EFI_NOT_READY         The receive request could not be queued because the receive queue is full.
+  @retval EFI_ICMP_ERROR        An ICMP error packet was received.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_IP4_RECEIVE)(
+  IN EFI_IP4_PROTOCOL          *This,
+  IN EFI_IP4_COMPLETION_TOKEN  *Token
+  );
+
+/**
+  Abort an asynchronous transmit or receive request.
+
+  The Cancel() function is used to abort a pending transmit or receive request.
+  If the token is in the transmit or receive request queues, after calling this
+  function, Token->Status will be set to EFI_ABORTED and then Token->Event will
+  be signaled. If the token is not in one of the queues, which usually means the
+  asynchronous operation has completed, this function will not signal the token
+  and EFI_NOT_FOUND is returned.
+
+  @param  This  The pointer to the EFI_IP4_PROTOCOL instance.
+  @param  Token The pointer to a token that has been issued by
+                EFI_IP4_PROTOCOL.Transmit() or
+                EFI_IP4_PROTOCOL.Receive(). If NULL, all pending
+                tokens are aborted. Type EFI_IP4_COMPLETION_TOKEN is
+                defined in EFI_IP4_PROTOCOL.Transmit().
+
+  @retval EFI_SUCCESS           The asynchronous I/O request was aborted and
+                                Token->Event was signaled. When Token is NULL, all
+                                pending requests were aborted and their events were signaled.
+  @retval EFI_INVALID_PARAMETER This is NULL.
+  @retval EFI_NOT_STARTED       This instance has not been started.
+  @retval EFI_NO_MAPPING        When using the default address, configuration (DHCP, BOOTP,
+                                RARP, etc.) is not finished yet.
+  @retval EFI_NOT_FOUND         When Token is not NULL, the asynchronous I/O request was
+                                not found in the transmit or receive queue. It has either completed
+                                or was not issued by Transmit() and Receive().
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_IP4_CANCEL)(
+  IN EFI_IP4_PROTOCOL          *This,
+  IN EFI_IP4_COMPLETION_TOKEN  *Token OPTIONAL
+  );
+
+/**
+  Polls for incoming data packets and processes outgoing data packets.
+
+  The Poll() function polls for incoming data packets and processes outgoing data
+  packets. Network drivers and applications can call the EFI_IP4_PROTOCOL.Poll()
+  function to increase the rate that data packets are moved between the communications
+  device and the transmit and receive queues.
+
+  In some systems the periodic timer event may not poll the underlying communications
+  device fast enough to transmit and/or receive all data packets without missing
+  incoming packets or dropping outgoing packets. Drivers and applications that are
+  experiencing packet loss should try calling the EFI_IP4_PROTOCOL.Poll() function
+  more often.
+
+  @param  This The pointer to the EFI_IP4_PROTOCOL instance.
+
+  @retval  EFI_SUCCESS           Incoming or outgoing data was processed.
+  @retval  EFI_NOT_STARTED       This EFI IPv4 Protocol instance has not been started.
+  @retval  EFI_NO_MAPPING        When using the default address, configuration (DHCP, BOOTP,
+                                 RARP, etc.) is not finished yet.
+  @retval  EFI_INVALID_PARAMETER This is NULL.
+  @retval  EFI_DEVICE_ERROR      An unexpected system or network error occurred.
+  @retval  EFI_NOT_READY         No incoming or outgoing data is processed.
+  @retval  EFI_TIMEOUT           Data was dropped out of the transmit and/or receive queue.
+                                 Consider increasing the polling rate.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_IP4_POLL)(
+  IN EFI_IP4_PROTOCOL          *This
+  );
+
+///
+/// The EFI IPv4 Protocol implements a simple packet-oriented interface that can be
+/// used by drivers, daemons, and applications to transmit and receive network packets.
+///
+struct _EFI_IP4_PROTOCOL {
+  EFI_IP4_GET_MODE_DATA        GetModeData;
+  EFI_IP4_CONFIGURE            Configure;
+  EFI_IP4_GROUPS               Groups;
+  EFI_IP4_ROUTES               Routes;
+  EFI_IP4_TRANSMIT             Transmit;
+  EFI_IP4_RECEIVE              Receive;
+  EFI_IP4_CANCEL               Cancel;
+  EFI_IP4_POLL                 Poll;
+};
+
+extern EFI_GUID gEfiIp4ServiceBindingProtocolGuid;
+extern EFI_GUID gEfiIp4ProtocolGuid;
+
+#endif
diff --git a/src/include/ipxe/efi/Protocol/Ip4Config.h b/src/include/ipxe/efi/Protocol/Ip4Config.h
new file mode 100644 (file)
index 0000000..227ae03
--- /dev/null
@@ -0,0 +1,184 @@
+/** @file
+  This file provides a definition of the EFI IPv4 Configuration
+  Protocol.
+
+Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  @par Revision Reference:
+  This Protocol is introduced in UEFI Specification 2.0.
+
+**/
+#ifndef __EFI_IP4CONFIG_PROTOCOL_H__
+#define __EFI_IP4CONFIG_PROTOCOL_H__
+
+FILE_LICENCE ( BSD3 );
+
+#include <ipxe/efi/Protocol/Ip4.h>
+
+#define EFI_IP4_CONFIG_PROTOCOL_GUID \
+  { \
+    0x3b95aa31, 0x3793, 0x434b, {0x86, 0x67, 0xc8, 0x07, 0x08, 0x92, 0xe0, 0x5e } \
+  }
+
+typedef struct _EFI_IP4_CONFIG_PROTOCOL EFI_IP4_CONFIG_PROTOCOL;
+
+#define IP4_CONFIG_VARIABLE_ATTRIBUTES \
+        (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS)
+
+///
+/// EFI_IP4_IPCONFIG_DATA contains the minimum IPv4 configuration data
+/// that is needed to start basic network communication. The StationAddress
+/// and SubnetMask must be a valid unicast IP address and subnet mask.
+/// If RouteTableSize is not zero, then RouteTable contains a properly
+/// formatted routing table for the StationAddress/SubnetMask, with the
+/// last entry in the table being the default route.
+///
+typedef struct {
+  ///
+  /// Default station IP address, stored in network byte order.
+  ///
+  EFI_IPv4_ADDRESS             StationAddress;
+  ///
+  /// Default subnet mask, stored in network byte order.
+  ///
+  EFI_IPv4_ADDRESS             SubnetMask;
+  ///
+  /// Number of entries in the following RouteTable. May be zero.
+  ///
+  UINT32                       RouteTableSize;
+  ///
+  /// Default routing table data (stored in network byte order).
+  /// Ignored if RouteTableSize is zero.
+  ///
+  EFI_IP4_ROUTE_TABLE          *RouteTable;
+} EFI_IP4_IPCONFIG_DATA;
+
+
+/**
+  Starts running the configuration policy for the EFI IPv4 Protocol driver.
+
+  The Start() function is called to determine and to begin the platform
+  configuration policy by the EFI IPv4 Protocol driver. This determination may
+  be as simple as returning EFI_UNSUPPORTED if there is no EFI IPv4 Protocol
+  driver configuration policy. It may be as involved as loading some defaults
+  from nonvolatile storage, downloading dynamic data from a DHCP server, and
+  checking permissions with a site policy server.
+  Starting the configuration policy is just the beginning. It may finish almost
+  instantly or it may take several minutes before it fails to retrieve configuration
+  information from one or more servers. Once the policy is started, drivers
+  should use the DoneEvent parameter to determine when the configuration policy
+  has completed. EFI_IP4_CONFIG_PROTOCOL.GetData() must then be called to
+  determine if the configuration succeeded or failed.
+  Until the configuration completes successfully, EFI IPv4 Protocol driver instances
+  that are attempting to use default configurations must return EFI_NO_MAPPING.
+  Once the configuration is complete, the EFI IPv4 Configuration Protocol driver
+  signals DoneEvent. The configuration may need to be updated in the future.
+  Note that in this case the EFI IPv4 Configuration Protocol driver must signal
+  ReconfigEvent, and all EFI IPv4 Protocol driver instances that are using default
+  configurations must return EFI_NO_MAPPING until the configuration policy has
+  been rerun.
+
+  @param  This                   The pointer to the EFI_IP4_CONFIG_PROTOCOL instance.
+  @param  DoneEvent              Event that will be signaled when the EFI IPv4
+                                 Protocol driver configuration policy completes
+                                 execution. This event must be of type EVT_NOTIFY_SIGNAL.
+  @param  ReconfigEvent          Event that will be signaled when the EFI IPv4
+                                 Protocol driver configuration needs to be updated.
+                                 This event must be of type EVT_NOTIFY_SIGNAL.
+
+  @retval EFI_SUCCESS            The configuration policy for the EFI IPv4 Protocol
+                                 driver is now running.
+  @retval EFI_INVALID_PARAMETER  One or more of the following parameters is NULL:
+                                  This
+                                  DoneEvent
+                                  ReconfigEvent
+  @retval EFI_OUT_OF_RESOURCES   Required system resources could not be allocated.
+  @retval EFI_ALREADY_STARTED    The configuration policy for the EFI IPv4 Protocol
+                                 driver was already started.
+  @retval EFI_DEVICE_ERROR       An unexpected system error or network error occurred.
+  @retval EFI_UNSUPPORTED        This interface does not support the EFI IPv4 Protocol
+                                 driver configuration.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_IP4_CONFIG_START)(
+  IN EFI_IP4_CONFIG_PROTOCOL   *This,
+  IN EFI_EVENT                 DoneEvent,
+  IN EFI_EVENT                 ReconfigEvent
+  );
+
+/**
+  Stops running the configuration policy for the EFI IPv4 Protocol driver.
+
+  The Stop() function stops the configuration policy for the EFI IPv4 Protocol driver.
+  All configuration data will be lost after calling Stop().
+
+  @param  This                   The pointer to the EFI_IP4_CONFIG_PROTOCOL instance.
+
+  @retval EFI_SUCCESS            The configuration policy for the EFI IPv4 Protocol
+                                 driver has been stopped.
+  @retval EFI_INVALID_PARAMETER  This is NULL.
+  @retval EFI_NOT_STARTED        The configuration policy for the EFI IPv4 Protocol
+                                 driver was not started.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_IP4_CONFIG_STOP)(
+  IN EFI_IP4_CONFIG_PROTOCOL   *This
+  );
+
+/**
+  Returns the default configuration data (if any) for the EFI IPv4 Protocol driver.
+
+  The GetData() function returns the current configuration data for the EFI IPv4
+  Protocol driver after the configuration policy has completed.
+
+  @param  This                   The pointer to the EFI_IP4_CONFIG_PROTOCOL instance.
+  @param  IpConfigDataSize       On input, the size of the IpConfigData buffer.
+                                 On output, the count of bytes that were written
+                                 into the IpConfigData buffer.
+  @param  IpConfigData           The pointer to the EFI IPv4 Configuration Protocol
+                                 driver configuration data structure.
+                                 Type EFI_IP4_IPCONFIG_DATA is defined in
+                                 "Related Definitions" below.
+
+  @retval EFI_SUCCESS            The EFI IPv4 Protocol driver configuration has been returned.
+  @retval EFI_INVALID_PARAMETER  This is NULL.
+  @retval EFI_NOT_STARTED        The configuration policy for the EFI IPv4 Protocol
+                                 driver is not running.
+  @retval EFI_NOT_READY EFI      IPv4 Protocol driver configuration is still running.
+  @retval EFI_ABORTED EFI        IPv4 Protocol driver configuration could not complete.
+  @retval EFI_BUFFER_TOO_SMALL   *IpConfigDataSize is smaller than the configuration
+                                 data buffer or IpConfigData is NULL.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_IP4_CONFIG_GET_DATA)(
+  IN EFI_IP4_CONFIG_PROTOCOL   *This,
+  IN OUT UINTN                 *IpConfigDataSize,
+  OUT EFI_IP4_IPCONFIG_DATA    *IpConfigData    OPTIONAL
+  );
+
+///
+/// The EFI_IP4_CONFIG_PROTOCOL driver performs platform-dependent and policy-dependent
+/// configurations for the EFI IPv4 Protocol driver.
+///
+struct _EFI_IP4_CONFIG_PROTOCOL {
+  EFI_IP4_CONFIG_START         Start;
+  EFI_IP4_CONFIG_STOP          Stop;
+  EFI_IP4_CONFIG_GET_DATA      GetData;
+};
+
+extern EFI_GUID gEfiIp4ConfigProtocolGuid;
+
+#endif
diff --git a/src/include/ipxe/efi/Protocol/ManagedNetwork.h b/src/include/ipxe/efi/Protocol/ManagedNetwork.h
new file mode 100644 (file)
index 0000000..2bd0922
--- /dev/null
@@ -0,0 +1,374 @@
+/** @file
+  EFI_MANAGED_NETWORK_SERVICE_BINDING_PROTOCOL as defined in UEFI 2.0.
+  EFI_MANAGED_NETWORK_PROTOCOL as defined in UEFI 2.0.
+
+Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  @par Revision Reference:
+  This Protocol is introduced in UEFI Specification 2.0
+
+**/
+
+#ifndef __EFI_MANAGED_NETWORK_PROTOCOL_H__
+#define __EFI_MANAGED_NETWORK_PROTOCOL_H__
+
+FILE_LICENCE ( BSD3 );
+
+#include <ipxe/efi/Protocol/SimpleNetwork.h>
+
+#define EFI_MANAGED_NETWORK_SERVICE_BINDING_PROTOCOL_GUID \
+  { \
+    0xf36ff770, 0xa7e1, 0x42cf, {0x9e, 0xd2, 0x56, 0xf0, 0xf2, 0x71, 0xf4, 0x4c } \
+  }
+
+#define EFI_MANAGED_NETWORK_PROTOCOL_GUID \
+  { \
+    0x7ab33a91, 0xace5, 0x4326, { 0xb5, 0x72, 0xe7, 0xee, 0x33, 0xd3, 0x9f, 0x16 } \
+  }
+
+typedef struct _EFI_MANAGED_NETWORK_PROTOCOL EFI_MANAGED_NETWORK_PROTOCOL;
+
+typedef struct {
+  ///
+  /// Timeout value for a UEFI one-shot timer event. A packet that has not been removed
+  /// from the MNP receive queue will be dropped if its receive timeout expires.
+  ///
+  UINT32     ReceivedQueueTimeoutValue;
+  ///
+  /// Timeout value for a UEFI one-shot timer event. A packet that has not been removed
+  /// from the MNP transmit queue will be dropped if its receive timeout expires.
+  ///
+  UINT32     TransmitQueueTimeoutValue;
+  ///
+  /// Ethernet type II 16-bit protocol type in host byte order. Valid
+  /// values are zero and 1,500 to 65,535.
+  ///
+  UINT16     ProtocolTypeFilter;
+  ///
+  /// Set to TRUE to receive packets that are sent to the network
+  /// device MAC address. The startup default value is FALSE.
+  ///
+  BOOLEAN    EnableUnicastReceive;
+  ///
+  /// Set to TRUE to receive packets that are sent to any of the
+  /// active multicast groups. The startup default value is FALSE.
+  ///
+  BOOLEAN    EnableMulticastReceive;
+  ///
+  /// Set to TRUE to receive packets that are sent to the network
+  /// device broadcast address. The startup default value is FALSE.
+  ///
+  BOOLEAN    EnableBroadcastReceive;
+  ///
+  /// Set to TRUE to receive packets that are sent to any MAC address.
+  /// The startup default value is FALSE.
+  ///
+  BOOLEAN    EnablePromiscuousReceive;
+  ///
+  /// Set to TRUE to drop queued packets when the configuration
+  /// is changed. The startup default value is FALSE.
+  ///
+  BOOLEAN    FlushQueuesOnReset;
+  ///
+  /// Set to TRUE to timestamp all packets when they are received
+  /// by the MNP. Note that timestamps may be unsupported in some
+  /// MNP implementations. The startup default value is FALSE.
+  ///
+  BOOLEAN    EnableReceiveTimestamps;
+  ///
+  /// Set to TRUE to disable background polling in this MNP
+  /// instance. Note that background polling may not be supported in
+  /// all MNP implementations. The startup default value is FALSE,
+  /// unless background polling is not supported.
+  ///
+  BOOLEAN    DisableBackgroundPolling;
+} EFI_MANAGED_NETWORK_CONFIG_DATA;
+
+typedef struct {
+  EFI_TIME      Timestamp;
+  EFI_EVENT     RecycleEvent;
+  UINT32        PacketLength;
+  UINT32        HeaderLength;
+  UINT32        AddressLength;
+  UINT32        DataLength;
+  BOOLEAN       BroadcastFlag;
+  BOOLEAN       MulticastFlag;
+  BOOLEAN       PromiscuousFlag;
+  UINT16        ProtocolType;
+  VOID          *DestinationAddress;
+  VOID          *SourceAddress;
+  VOID          *MediaHeader;
+  VOID          *PacketData;
+} EFI_MANAGED_NETWORK_RECEIVE_DATA;
+
+typedef struct {
+  UINT32        FragmentLength;
+  VOID          *FragmentBuffer;
+} EFI_MANAGED_NETWORK_FRAGMENT_DATA;
+
+typedef struct {
+  EFI_MAC_ADDRESS                   *DestinationAddress; //OPTIONAL
+  EFI_MAC_ADDRESS                   *SourceAddress;      //OPTIONAL
+  UINT16                            ProtocolType;        //OPTIONAL
+  UINT32                            DataLength;
+  UINT16                            HeaderLength;        //OPTIONAL
+  UINT16                            FragmentCount;
+  EFI_MANAGED_NETWORK_FRAGMENT_DATA FragmentTable[1];
+} EFI_MANAGED_NETWORK_TRANSMIT_DATA;
+
+
+typedef struct {
+  ///
+  /// This Event will be signaled after the Status field is updated
+  /// by the MNP. The type of Event must be
+  /// EFI_NOTIFY_SIGNAL. The Task Priority Level (TPL) of
+  /// Event must be lower than or equal to TPL_CALLBACK.
+  ///
+  EFI_EVENT                             Event;
+  ///
+  /// The status that is returned to the caller at the end of the operation
+  /// to indicate whether this operation completed successfully.
+  ///
+  EFI_STATUS                            Status;
+  union {
+    ///
+    /// When this token is used for receiving, RxData is a pointer to the EFI_MANAGED_NETWORK_RECEIVE_DATA.
+    ///
+    EFI_MANAGED_NETWORK_RECEIVE_DATA    *RxData;
+    ///
+    /// When this token is used for transmitting, TxData is a pointer to the EFI_MANAGED_NETWORK_TRANSMIT_DATA.
+    ///
+    EFI_MANAGED_NETWORK_TRANSMIT_DATA   *TxData;
+  } Packet;
+} EFI_MANAGED_NETWORK_COMPLETION_TOKEN;
+
+/**
+  Returns the operational parameters for the current MNP child driver.
+
+  @param  This          The pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance.
+  @param  MnpConfigData The pointer to storage for MNP operational parameters.
+  @param  SnpModeData   The pointer to storage for SNP operational parameters.
+
+  @retval EFI_SUCCESS           The operation completed successfully.
+  @retval EFI_INVALID_PARAMETER This is NULL.
+  @retval EFI_UNSUPPORTED       The requested feature is unsupported in this MNP implementation.
+  @retval EFI_NOT_STARTED       This MNP child driver instance has not been configured. The default
+                                values are returned in MnpConfigData if it is not NULL.
+  @retval Other                 The mode data could not be read.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_MANAGED_NETWORK_GET_MODE_DATA)(
+  IN  EFI_MANAGED_NETWORK_PROTOCOL     *This,
+  OUT EFI_MANAGED_NETWORK_CONFIG_DATA  *MnpConfigData  OPTIONAL,
+  OUT EFI_SIMPLE_NETWORK_MODE          *SnpModeData    OPTIONAL
+  );
+
+/**
+  Sets or clears the operational parameters for the MNP child driver.
+
+  @param  This          The pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance.
+  @param  MnpConfigData The pointer to configuration data that will be assigned to the MNP
+                        child driver instance. If NULL, the MNP child driver instance is
+                        reset to startup defaults and all pending transmit and receive
+                        requests are flushed.
+
+  @retval EFI_SUCCESS           The operation completed successfully.
+  @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
+  @retval EFI_OUT_OF_RESOURCES  Required system resources (usually memory) could not be
+                                allocated.
+  @retval EFI_UNSUPPORTED       The requested feature is unsupported in this [MNP]
+                                implementation.
+  @retval EFI_DEVICE_ERROR      An unexpected network or system error occurred.
+  @retval Other                 The MNP child driver instance has been reset to startup defaults.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_MANAGED_NETWORK_CONFIGURE)(
+  IN EFI_MANAGED_NETWORK_PROTOCOL     *This,
+  IN EFI_MANAGED_NETWORK_CONFIG_DATA  *MnpConfigData  OPTIONAL
+  );
+
+/**
+  Translates an IP multicast address to a hardware (MAC) multicast address.
+
+  @param  This       The pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance.
+  @param  Ipv6Flag   Set to TRUE to if IpAddress is an IPv6 multicast address.
+                     Set to FALSE if IpAddress is an IPv4 multicast address.
+  @param  IpAddress  The pointer to the multicast IP address (in network byte order) to convert.
+  @param  MacAddress The pointer to the resulting multicast MAC address.
+
+  @retval EFI_SUCCESS           The operation completed successfully.
+  @retval EFI_INVALID_PARAMETER One of the following conditions is TRUE:
+                                - This is NULL.
+                                - IpAddress is NULL.
+                                - *IpAddress is not a valid multicast IP address.
+                                - MacAddress is NULL.
+  @retval EFI_NOT_STARTED       This MNP child driver instance has not been configured.
+  @retval EFI_UNSUPPORTED       The requested feature is unsupported in this MNP implementation.
+  @retval EFI_DEVICE_ERROR      An unexpected network or system error occurred.
+  @retval Other                 The address could not be converted.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_MANAGED_NETWORK_MCAST_IP_TO_MAC)(
+  IN  EFI_MANAGED_NETWORK_PROTOCOL  *This,
+  IN  BOOLEAN                       Ipv6Flag,
+  IN  EFI_IP_ADDRESS                *IpAddress,
+  OUT EFI_MAC_ADDRESS               *MacAddress
+  );
+
+/**
+  Enables and disables receive filters for multicast address.
+
+  @param  This       The pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance.
+  @param  JoinFlag   Set to TRUE to join this multicast group.
+                     Set to FALSE to leave this multicast group.
+  @param  MacAddress The pointer to the multicast MAC group (address) to join or leave.
+
+  @retval EFI_SUCCESS           The requested operation completed successfully.
+  @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
+                                - This is NULL.
+                                - JoinFlag is TRUE and MacAddress is NULL.
+                                - *MacAddress is not a valid multicast MAC address.
+  @retval EFI_NOT_STARTED       This MNP child driver instance has not been configured.
+  @retval EFI_ALREADY_STARTED   The supplied multicast group is already joined.
+  @retval EFI_NOT_FOUND         The supplied multicast group is not joined.
+  @retval EFI_DEVICE_ERROR      An unexpected network or system error occurred.
+  @retval EFI_UNSUPPORTED       The requested feature is unsupported in this MNP implementation.
+  @retval Other                 The requested operation could not be completed.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_MANAGED_NETWORK_GROUPS)(
+  IN EFI_MANAGED_NETWORK_PROTOCOL  *This,
+  IN BOOLEAN                       JoinFlag,
+  IN EFI_MAC_ADDRESS               *MacAddress  OPTIONAL
+  );
+
+/**
+  Places asynchronous outgoing data packets into the transmit queue.
+
+  @param  This  The pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance.
+  @param  Token The pointer to a token associated with the transmit data descriptor.
+
+  @retval EFI_SUCCESS           The transmit completion token was cached.
+  @retval EFI_NOT_STARTED       This MNP child driver instance has not been configured.
+  @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
+  @retval EFI_ACCESS_DENIED     The transmit completion token is already in the transmit queue.
+  @retval EFI_OUT_OF_RESOURCES  The transmit data could not be queued due to a lack of system resources
+                                (usually memory).
+  @retval EFI_DEVICE_ERROR      An unexpected system or network error occurred.
+  @retval EFI_NOT_READY         The transmit request could not be queued because the transmit queue is full.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_MANAGED_NETWORK_TRANSMIT)(
+  IN EFI_MANAGED_NETWORK_PROTOCOL          *This,
+  IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN  *Token
+  );
+
+/**
+  Places an asynchronous receiving request into the receiving queue.
+
+  @param  This  The pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance.
+  @param  Token The pointer to a token associated with the receive data descriptor.
+
+  @retval EFI_SUCCESS           The receive completion token was cached.
+  @retval EFI_NOT_STARTED       This MNP child driver instance has not been configured.
+  @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
+                                - This is NULL.
+                                - Token is NULL.
+                                - Token.Event is NULL.
+  @retval EFI_OUT_OF_RESOURCES  The transmit data could not be queued due to a lack of system resources
+                                (usually memory).
+  @retval EFI_DEVICE_ERROR      An unexpected system or network error occurred.
+  @retval EFI_ACCESS_DENIED     The receive completion token was already in the receive queue.
+  @retval EFI_NOT_READY         The receive request could not be queued because the receive queue is full.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_MANAGED_NETWORK_RECEIVE)(
+  IN EFI_MANAGED_NETWORK_PROTOCOL          *This,
+  IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN  *Token
+  );
+
+
+/**
+  Aborts an asynchronous transmit or receive request.
+
+  @param  This  The pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance.
+  @param  Token The pointer to a token that has been issued by
+                EFI_MANAGED_NETWORK_PROTOCOL.Transmit() or
+                EFI_MANAGED_NETWORK_PROTOCOL.Receive(). If
+                NULL, all pending tokens are aborted.
+
+  @retval  EFI_SUCCESS           The asynchronous I/O request was aborted and Token.Event
+                                 was signaled. When Token is NULL, all pending requests were
+                                 aborted and their events were signaled.
+  @retval  EFI_NOT_STARTED       This MNP child driver instance has not been configured.
+  @retval  EFI_INVALID_PARAMETER This is NULL.
+  @retval  EFI_NOT_FOUND         When Token is not NULL, the asynchronous I/O request was
+                                 not found in the transmit or receive queue. It has either completed
+                                 or was not issued by Transmit() and Receive().
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_MANAGED_NETWORK_CANCEL)(
+  IN EFI_MANAGED_NETWORK_PROTOCOL          *This,
+  IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN  *Token  OPTIONAL
+  );
+
+/**
+  Polls for incoming data packets and processes outgoing data packets.
+
+  @param  This The pointer to the EFI_MANAGED_NETWORK_PROTOCOL instance.
+
+  @retval EFI_SUCCESS      Incoming or outgoing data was processed.
+  @retval EFI_NOT_STARTED  This MNP child driver instance has not been configured.
+  @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
+  @retval EFI_NOT_READY    No incoming or outgoing data was processed. Consider increasing
+                           the polling rate.
+  @retval EFI_TIMEOUT      Data was dropped out of the transmit and/or receive queue.
+                            Consider increasing the polling rate.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_MANAGED_NETWORK_POLL)(
+  IN EFI_MANAGED_NETWORK_PROTOCOL    *This
+  );
+
+///
+/// The MNP is used by network applications (and drivers) to
+/// perform raw (unformatted) asynchronous network packet I/O.
+///
+struct _EFI_MANAGED_NETWORK_PROTOCOL {
+  EFI_MANAGED_NETWORK_GET_MODE_DATA       GetModeData;
+  EFI_MANAGED_NETWORK_CONFIGURE           Configure;
+  EFI_MANAGED_NETWORK_MCAST_IP_TO_MAC     McastIpToMac;
+  EFI_MANAGED_NETWORK_GROUPS              Groups;
+  EFI_MANAGED_NETWORK_TRANSMIT            Transmit;
+  EFI_MANAGED_NETWORK_RECEIVE             Receive;
+  EFI_MANAGED_NETWORK_CANCEL              Cancel;
+  EFI_MANAGED_NETWORK_POLL                Poll;
+};
+
+extern EFI_GUID gEfiManagedNetworkServiceBindingProtocolGuid;
+extern EFI_GUID gEfiManagedNetworkProtocolGuid;
+
+#endif
diff --git a/src/include/ipxe/efi/Protocol/Mtftp4.h b/src/include/ipxe/efi/Protocol/Mtftp4.h
new file mode 100644 (file)
index 0000000..0e961cf
--- /dev/null
@@ -0,0 +1,595 @@
+/** @file
+  EFI Multicast Trivial File Tranfer Protocol Definition
+
+Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  @par Revision Reference:
+  This Protocol is introduced in UEFI Specification 2.0
+
+**/
+
+#ifndef __EFI_MTFTP4_PROTOCOL_H__
+#define __EFI_MTFTP4_PROTOCOL_H__
+
+FILE_LICENCE ( BSD3 );
+
+#define EFI_MTFTP4_SERVICE_BINDING_PROTOCOL_GUID \
+  { \
+    0x2FE800BE, 0x8F01, 0x4aa6, {0x94, 0x6B, 0xD7, 0x13, 0x88, 0xE1, 0x83, 0x3F } \
+  }
+
+#define EFI_MTFTP4_PROTOCOL_GUID \
+  { \
+    0x78247c57, 0x63db, 0x4708, {0x99, 0xc2, 0xa8, 0xb4, 0xa9, 0xa6, 0x1f, 0x6b } \
+  }
+
+typedef struct _EFI_MTFTP4_PROTOCOL EFI_MTFTP4_PROTOCOL;
+typedef struct _EFI_MTFTP4_TOKEN EFI_MTFTP4_TOKEN;
+
+//
+//MTFTP4 packet opcode definition
+//
+#define EFI_MTFTP4_OPCODE_RRQ                     1
+#define EFI_MTFTP4_OPCODE_WRQ                     2
+#define EFI_MTFTP4_OPCODE_DATA                    3
+#define EFI_MTFTP4_OPCODE_ACK                     4
+#define EFI_MTFTP4_OPCODE_ERROR                   5
+#define EFI_MTFTP4_OPCODE_OACK                    6
+#define EFI_MTFTP4_OPCODE_DIR                     7
+#define EFI_MTFTP4_OPCODE_DATA8                   8
+#define EFI_MTFTP4_OPCODE_ACK8                    9
+
+//
+// MTFTP4 error code definition
+//
+#define EFI_MTFTP4_ERRORCODE_NOT_DEFINED          0
+#define EFI_MTFTP4_ERRORCODE_FILE_NOT_FOUND       1
+#define EFI_MTFTP4_ERRORCODE_ACCESS_VIOLATION     2
+#define EFI_MTFTP4_ERRORCODE_DISK_FULL            3
+#define EFI_MTFTP4_ERRORCODE_ILLEGAL_OPERATION    4
+#define EFI_MTFTP4_ERRORCODE_UNKNOWN_TRANSFER_ID  5
+#define EFI_MTFTP4_ERRORCODE_FILE_ALREADY_EXISTS  6
+#define EFI_MTFTP4_ERRORCODE_NO_SUCH_USER         7
+#define EFI_MTFTP4_ERRORCODE_REQUEST_DENIED       8
+
+//
+// MTFTP4 pacekt definitions
+//
+#pragma pack(1)
+
+typedef struct {
+  UINT16                  OpCode;
+  UINT8                   Filename[1];
+} EFI_MTFTP4_REQ_HEADER;
+
+typedef struct {
+  UINT16                  OpCode;
+  UINT8                   Data[1];
+} EFI_MTFTP4_OACK_HEADER;
+
+typedef struct {
+  UINT16                  OpCode;
+  UINT16                  Block;
+  UINT8                   Data[1];
+} EFI_MTFTP4_DATA_HEADER;
+
+typedef struct {
+  UINT16                  OpCode;
+  UINT16                  Block[1];
+} EFI_MTFTP4_ACK_HEADER;
+
+typedef struct {
+  UINT16                  OpCode;
+  UINT64                  Block;
+  UINT8                   Data[1];
+} EFI_MTFTP4_DATA8_HEADER;
+
+typedef struct {
+  UINT16                  OpCode;
+  UINT64                  Block[1];
+} EFI_MTFTP4_ACK8_HEADER;
+
+typedef struct {
+  UINT16                  OpCode;
+  UINT16                  ErrorCode;
+  UINT8                   ErrorMessage[1];
+} EFI_MTFTP4_ERROR_HEADER;
+
+typedef union {
+  ///
+  /// Type of packets as defined by the MTFTPv4 packet opcodes.
+  ///
+  UINT16                  OpCode;
+  ///
+  /// Read request packet header.
+  ///
+  EFI_MTFTP4_REQ_HEADER   Rrq;
+  ///
+  /// Write request packet header.
+  ///
+  EFI_MTFTP4_REQ_HEADER   Wrq;
+  ///
+  /// Option acknowledge packet header.
+  ///
+  EFI_MTFTP4_OACK_HEADER  Oack;
+  ///
+  /// Data packet header.
+  ///
+  EFI_MTFTP4_DATA_HEADER  Data;
+  ///
+  /// Acknowledgement packet header.
+  ///
+  EFI_MTFTP4_ACK_HEADER   Ack;
+  ///
+  /// Data packet header with big block number.
+  ///
+  EFI_MTFTP4_DATA8_HEADER Data8;
+  ///
+  /// Acknowledgement header with big block num.
+  ///
+  EFI_MTFTP4_ACK8_HEADER  Ack8;
+  ///
+  /// Error packet header.
+  ///
+  EFI_MTFTP4_ERROR_HEADER Error;
+} EFI_MTFTP4_PACKET;
+
+#pragma pack()
+
+///
+/// MTFTP4 option definition.
+///
+typedef struct {
+  UINT8                   *OptionStr;
+  UINT8                   *ValueStr;
+} EFI_MTFTP4_OPTION;
+
+
+typedef struct {
+  BOOLEAN                 UseDefaultSetting;
+  EFI_IPv4_ADDRESS        StationIp;
+  EFI_IPv4_ADDRESS        SubnetMask;
+  UINT16                  LocalPort;
+  EFI_IPv4_ADDRESS        GatewayIp;
+  EFI_IPv4_ADDRESS        ServerIp;
+  UINT16                  InitialServerPort;
+  UINT16                  TryCount;
+  UINT16                  TimeoutValue;
+} EFI_MTFTP4_CONFIG_DATA;
+
+
+typedef struct {
+  EFI_MTFTP4_CONFIG_DATA  ConfigData;
+  UINT8                   SupportedOptionCount;
+  UINT8                   **SupportedOptoins;
+  UINT8                   UnsupportedOptionCount;
+  UINT8                   **UnsupportedOptoins;
+} EFI_MTFTP4_MODE_DATA;
+
+
+typedef struct {
+  EFI_IPv4_ADDRESS        GatewayIp;
+  EFI_IPv4_ADDRESS        ServerIp;
+  UINT16                  ServerPort;
+  UINT16                  TryCount;
+  UINT16                  TimeoutValue;
+} EFI_MTFTP4_OVERRIDE_DATA;
+
+//
+// Protocol interfaces definition
+//
+
+/**
+  A callback function that is provided by the caller to intercept
+  the EFI_MTFTP4_OPCODE_DATA or EFI_MTFTP4_OPCODE_DATA8 packets processed in the
+  EFI_MTFTP4_PROTOCOL.ReadFile() function, and alternatively to intercept
+  EFI_MTFTP4_OPCODE_OACK or EFI_MTFTP4_OPCODE_ERROR packets during a call to
+  EFI_MTFTP4_PROTOCOL.ReadFile(), WriteFile() or ReadDirectory().
+
+  @param  This        The pointer to the EFI_MTFTP4_PROTOCOL instance.
+  @param  Token       The token that the caller provided in the
+                      EFI_MTFTP4_PROTOCOL.ReadFile(), WriteFile()
+                      or ReadDirectory() function.
+  @param  PacketLen   Indicates the length of the packet.
+  @param  Packet      The pointer to an MTFTPv4 packet.
+
+  @retval EFI_SUCCESS The operation was successful.
+  @retval Others      Aborts the transfer process.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_MTFTP4_CHECK_PACKET)(
+  IN EFI_MTFTP4_PROTOCOL  *This,
+  IN EFI_MTFTP4_TOKEN     *Token,
+  IN UINT16               PacketLen,
+  IN EFI_MTFTP4_PACKET    *Paket
+  );
+
+/**
+  Timeout callback funtion.
+
+  @param  This           The pointer to the EFI_MTFTP4_PROTOCOL instance.
+  @param  Token          The token that is provided in the
+                         EFI_MTFTP4_PROTOCOL.ReadFile() or
+                         EFI_MTFTP4_PROTOCOL.WriteFile() or
+                         EFI_MTFTP4_PROTOCOL.ReadDirectory() functions
+                         by the caller.
+
+  @retval EFI_SUCCESS   The operation was successful.
+  @retval Others        Aborts download process.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_MTFTP4_TIMEOUT_CALLBACK)(
+  IN EFI_MTFTP4_PROTOCOL  *This,
+  IN EFI_MTFTP4_TOKEN     *Token
+  );
+
+/**
+  A callback function that the caller provides to feed data to the
+  EFI_MTFTP4_PROTOCOL.WriteFile() function.
+
+  @param  This   The pointer to the EFI_MTFTP4_PROTOCOL instance.
+  @param  Token  The token provided in the
+                 EFI_MTFTP4_PROTOCOL.WriteFile() by the caller.
+  @param  Length Indicates the length of the raw data wanted on input, and the
+                 length the data available on output.
+  @param  Buffer The pointer to the buffer where the data is stored.
+
+  @retval EFI_SUCCESS The operation was successful.
+  @retval Others      Aborts session.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_MTFTP4_PACKET_NEEDED)(
+  IN  EFI_MTFTP4_PROTOCOL *This,
+  IN  EFI_MTFTP4_TOKEN    *Token,
+  IN  OUT UINT16          *Length,
+  OUT VOID                **Buffer
+  );
+
+
+/**
+  Submits an asynchronous interrupt transfer to an interrupt endpoint of a USB device.
+
+  @param  This     The pointer to the EFI_MTFTP4_PROTOCOL instance.
+  @param  ModeData The pointer to storage for the EFI MTFTPv4 Protocol driver mode data.
+
+  @retval EFI_SUCCESS           The configuration data was successfully returned.
+  @retval EFI_OUT_OF_RESOURCES  The required mode data could not be allocated.
+  @retval EFI_INVALID_PARAMETER This is NULL or ModeData is NULL.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_MTFTP4_GET_MODE_DATA)(
+  IN  EFI_MTFTP4_PROTOCOL     *This,
+  OUT EFI_MTFTP4_MODE_DATA    *ModeData
+  );
+
+
+/**
+  Initializes, changes, or resets the default operational setting for this
+  EFI MTFTPv4 Protocol driver instance.
+
+  @param  This            The pointer to the EFI_MTFTP4_PROTOCOL instance.
+  @param  MtftpConfigData The pointer to the configuration data structure.
+
+  @retval EFI_SUCCESS           The EFI MTFTPv4 Protocol driver was configured successfully.
+  @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
+  @retval EFI_ACCESS_DENIED     The EFI configuration could not be changed at this time because
+                                there is one MTFTP background operation in progress.
+  @retval EFI_NO_MAPPING        When using a default address, configuration (DHCP, BOOTP,
+                                RARP, etc.) has not finished yet.
+  @retval EFI_UNSUPPORTED       A configuration protocol (DHCP, BOOTP, RARP, etc.) could not
+                                be located when clients choose to use the default address
+                                settings.
+  @retval EFI_OUT_OF_RESOURCES  The EFI MTFTPv4 Protocol driver instance data could not be
+                                allocated.
+  @retval EFI_DEVICE_ERROR      An unexpected system or network error occurred. The EFI
+                                 MTFTPv4 Protocol driver instance is not configured.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_MTFTP4_CONFIGURE)(
+  IN EFI_MTFTP4_PROTOCOL       *This,
+  IN EFI_MTFTP4_CONFIG_DATA    *MtftpConfigData OPTIONAL
+  );
+
+
+/**
+  Gets information about a file from an MTFTPv4 server.
+
+  @param  This         The pointer to the EFI_MTFTP4_PROTOCOL instance.
+  @param  OverrideData Data that is used to override the existing parameters. If NULL,
+                       the default parameters that were set in the
+                       EFI_MTFTP4_PROTOCOL.Configure() function are used.
+  @param  Filename     The pointer to null-terminated ASCII file name string.
+  @param  ModeStr      The pointer to null-terminated ASCII mode string. If NULL, "octet" will be used.
+  @param  OptionCount  Number of option/value string pairs in OptionList.
+  @param  OptionList   The pointer to array of option/value string pairs. Ignored if
+                       OptionCount is zero.
+  @param  PacketLength The number of bytes in the returned packet.
+  @param  Packet       The pointer to the received packet. This buffer must be freed by
+                       the caller.
+
+  @retval EFI_SUCCESS              An MTFTPv4 OACK packet was received and is in the Packet.
+  @retval EFI_INVALID_PARAMETER    One or more of the following conditions is TRUE:
+                                   - This is NULL.
+                                   - Filename is NULL.
+                                   - OptionCount is not zero and OptionList is NULL.
+                                   - One or more options in OptionList have wrong format.
+                                   - PacketLength is NULL.
+                                   - One or more IPv4 addresses in OverrideData are not valid
+                                     unicast IPv4 addresses if OverrideData is not NULL.
+  @retval EFI_UNSUPPORTED          One or more options in the OptionList are in the
+                                   unsupported list of structure EFI_MTFTP4_MODE_DATA.
+  @retval EFI_NOT_STARTED          The EFI MTFTPv4 Protocol driver has not been started.
+  @retval EFI_NO_MAPPING           When using a default address, configuration (DHCP, BOOTP,
+                                   RARP, etc.) has not finished yet.
+  @retval EFI_ACCESS_DENIED        The previous operation has not completed yet.
+  @retval EFI_OUT_OF_RESOURCES     Required system resources could not be allocated.
+  @retval EFI_TFTP_ERROR           An MTFTPv4 ERROR packet was received and is in the Packet.
+  @retval EFI_NETWORK_UNREACHABLE  An ICMP network unreachable error packet was received and the Packet is set to NULL.
+  @retval EFI_HOST_UNREACHABLE     An ICMP host unreachable error packet was received and the Packet is set to NULL.
+  @retval EFI_PROTOCOL_UNREACHABLE An ICMP protocol unreachable error packet was received and the Packet is set to NULL.
+  @retval EFI_PORT_UNREACHABLE     An ICMP port unreachable error packet was received and the Packet is set to NULL.
+  @retval EFI_ICMP_ERROR           Some other ICMP ERROR packet was received and is in the Buffer.
+  @retval EFI_PROTOCOL_ERROR       An unexpected MTFTPv4 packet was received and is in the Packet.
+  @retval EFI_TIMEOUT              No responses were received from the MTFTPv4 server.
+  @retval EFI_DEVICE_ERROR         An unexpected network error or system error occurred.
+  @retval EFI_NO_MEDIA             There was a media error.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_MTFTP4_GET_INFO)(
+  IN  EFI_MTFTP4_PROTOCOL      *This,
+  IN  EFI_MTFTP4_OVERRIDE_DATA *OverrideData   OPTIONAL,
+  IN  UINT8                    *Filename,
+  IN  UINT8                    *ModeStr        OPTIONAL,
+  IN  UINT8                    OptionCount,
+  IN  EFI_MTFTP4_OPTION        *OptionList,
+  OUT UINT32                   *PacketLength,
+  OUT EFI_MTFTP4_PACKET        **Packet        OPTIONAL
+  );
+
+/**
+  Parses the options in an MTFTPv4 OACK packet.
+
+  @param  This         The pointer to the EFI_MTFTP4_PROTOCOL instance.
+  @param  PacketLen    Length of the OACK packet to be parsed.
+  @param  Packet       The pointer to the OACK packet to be parsed.
+  @param  OptionCount  The pointer to the number of options in following OptionList.
+  @param  OptionList   The pointer to EFI_MTFTP4_OPTION storage. Call the EFI Boot
+                       Service FreePool() to release the OptionList if the options
+                       in this OptionList are not needed any more.
+
+  @retval EFI_SUCCESS           The OACK packet was valid and the OptionCount and
+                                OptionList parameters have been updated.
+  @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
+                                - PacketLen is 0.
+                                - Packet is NULL or Packet is not a valid MTFTPv4 packet.
+                                - OptionCount is NULL.
+  @retval EFI_NOT_FOUND         No options were found in the OACK packet.
+  @retval EFI_OUT_OF_RESOURCES  Storage for the OptionList array cannot be allocated.
+  @retval EFI_PROTOCOL_ERROR    One or more of the option fields is invalid.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_MTFTP4_PARSE_OPTIONS)(
+  IN  EFI_MTFTP4_PROTOCOL      *This,
+  IN  UINT32                   PacketLen,
+  IN  EFI_MTFTP4_PACKET        *Packet,
+  OUT UINT32                   *OptionCount,
+  OUT EFI_MTFTP4_OPTION        **OptionList OPTIONAL
+  );
+
+
+/**
+  Downloads a file from an MTFTPv4 server.
+
+  @param  This  The pointer to the EFI_MTFTP4_PROTOCOL instance.
+  @param  Token The pointer to the token structure to provide the parameters that are
+                used in this operation.
+
+  @retval EFI_SUCCESS              The data file has been transferred successfully.
+  @retval EFI_OUT_OF_RESOURCES     Required system resources could not be allocated.
+  @retval EFI_BUFFER_TOO_SMALL     BufferSize is not zero but not large enough to hold the
+                                   downloaded data in downloading process.
+  @retval EFI_ABORTED              Current operation is aborted by user.
+  @retval EFI_NETWORK_UNREACHABLE  An ICMP network unreachable error packet was received.
+  @retval EFI_HOST_UNREACHABLE     An ICMP host unreachable error packet was received.
+  @retval EFI_PROTOCOL_UNREACHABLE An ICMP protocol unreachable error packet was received.
+  @retval EFI_PORT_UNREACHABLE     An ICMP port unreachable error packet was received.
+  @retval EFI_ICMP_ERROR           Some other  ICMP ERROR packet was received.
+  @retval EFI_TIMEOUT              No responses were received from the MTFTPv4 server.
+  @retval EFI_TFTP_ERROR           An MTFTPv4 ERROR packet was received.
+  @retval EFI_DEVICE_ERROR         An unexpected network error or system error occurred.
+  @retval EFI_NO_MEDIA             There was a media error.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_MTFTP4_READ_FILE)(
+  IN EFI_MTFTP4_PROTOCOL       *This,
+  IN EFI_MTFTP4_TOKEN          *Token
+  );
+
+
+
+/**
+  Sends a file to an MTFTPv4 server.
+
+  @param  This  The pointer to the EFI_MTFTP4_PROTOCOL instance.
+  @param  Token The pointer to the token structure to provide the parameters that are
+                used in this operation.
+
+  @retval EFI_SUCCESS           The upload session has started.
+  @retval EFI_UNSUPPORTED       The operation is not supported by this implementation.
+  @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
+  @retval EFI_UNSUPPORTED       One or more options in the Token.OptionList are in
+                                the unsupported list of structure EFI_MTFTP4_MODE_DATA.
+  @retval EFI_NOT_STARTED       The EFI MTFTPv4 Protocol driver has not been started.
+  @retval EFI_NO_MAPPING        When using a default address, configuration (DHCP, BOOTP,
+                                RARP, etc.) is not finished yet.
+  @retval EFI_ALREADY_STARTED   This Token is already being used in another MTFTPv4 session.
+  @retval EFI_OUT_OF_RESOURCES  Required system resources could not be allocated.
+  @retval EFI_ACCESS_DENIED     The previous operation has not completed yet.
+  @retval EFI_DEVICE_ERROR      An unexpected network error or system error occurred.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_MTFTP4_WRITE_FILE)(
+  IN EFI_MTFTP4_PROTOCOL       *This,
+  IN EFI_MTFTP4_TOKEN          *Token
+  );
+
+
+/**
+  Downloads a data file "directory" from an MTFTPv4 server. May be unsupported in some EFI
+  implementations.
+
+  @param  This  The pointer to the EFI_MTFTP4_PROTOCOL instance.
+  @param  Token The pointer to the token structure to provide the parameters that are
+                used in this operation.
+
+  @retval EFI_SUCCESS           The MTFTPv4 related file "directory" has been downloaded.
+  @retval EFI_UNSUPPORTED       The operation is not supported by this implementation.
+  @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
+  @retval EFI_UNSUPPORTED       One or more options in the Token.OptionList are in
+                                the unsupported list of structure EFI_MTFTP4_MODE_DATA.
+  @retval EFI_NOT_STARTED       The EFI MTFTPv4 Protocol driver has not been started.
+  @retval EFI_NO_MAPPING        When using a default address, configuration (DHCP, BOOTP,
+                                RARP, etc.) is not finished yet.
+  @retval EFI_ALREADY_STARTED   This Token is already being used in another MTFTPv4 session.
+  @retval EFI_OUT_OF_RESOURCES  Required system resources could not be allocated.
+  @retval EFI_ACCESS_DENIED     The previous operation has not completed yet.
+  @retval EFI_DEVICE_ERROR      An unexpected network error or system error occurred.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_MTFTP4_READ_DIRECTORY)(
+  IN EFI_MTFTP4_PROTOCOL       *This,
+  IN EFI_MTFTP4_TOKEN          *Token
+  );
+
+/**
+  Polls for incoming data packets and processes outgoing data packets.
+
+  @param  This The pointer to the EFI_MTFTP4_PROTOCOL instance.
+
+  @retval  EFI_SUCCESS           Incoming or outgoing data was processed.
+  @retval  EFI_NOT_STARTED       This EFI MTFTPv4 Protocol instance has not been started.
+  @retval  EFI_NO_MAPPING        When using a default address, configuration (DHCP, BOOTP,
+                                 RARP, etc.) is not finished yet.
+  @retval  EFI_INVALID_PARAMETER This is NULL.
+  @retval  EFI_DEVICE_ERROR      An unexpected system or network error occurred.
+  @retval  EFI_TIMEOUT           Data was dropped out of the transmit and/or receive queue.
+                                 Consider increasing the polling rate.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_MTFTP4_POLL)(
+  IN EFI_MTFTP4_PROTOCOL       *This
+  );
+
+///
+/// The EFI_MTFTP4_PROTOCOL is designed to be used by UEFI drivers and applications
+/// to transmit and receive data files. The EFI MTFTPv4 Protocol driver uses
+/// the underlying EFI UDPv4 Protocol driver and EFI IPv4 Protocol driver.
+///
+struct _EFI_MTFTP4_PROTOCOL {
+  EFI_MTFTP4_GET_MODE_DATA     GetModeData;
+  EFI_MTFTP4_CONFIGURE         Configure;
+  EFI_MTFTP4_GET_INFO          GetInfo;
+  EFI_MTFTP4_PARSE_OPTIONS     ParseOptions;
+  EFI_MTFTP4_READ_FILE         ReadFile;
+  EFI_MTFTP4_WRITE_FILE        WriteFile;
+  EFI_MTFTP4_READ_DIRECTORY    ReadDirectory;
+  EFI_MTFTP4_POLL              Poll;
+};
+
+struct _EFI_MTFTP4_TOKEN {
+  ///
+  /// The status that is returned to the caller at the end of the operation
+  /// to indicate whether this operation completed successfully.
+  ///
+  EFI_STATUS                  Status;
+  ///
+  /// The event that will be signaled when the operation completes. If
+  /// set to NULL, the corresponding function will wait until the read or
+  /// write operation finishes. The type of Event must be
+  /// EVT_NOTIFY_SIGNAL. The Task Priority Level (TPL) of
+  /// Event must be lower than or equal to TPL_CALLBACK.
+  ///
+  EFI_EVENT                   Event;
+  ///
+  /// If not NULL, the data that will be used to override the existing configure data.
+  ///
+  EFI_MTFTP4_OVERRIDE_DATA    *OverrideData;
+  ///
+  /// The pointer to the null-terminated ASCII file name string.
+  ///
+  UINT8                       *Filename;
+  ///
+  /// The pointer to the null-terminated ASCII mode string. If NULL, "octet" is used.
+  ///
+  UINT8                       *ModeStr;
+  ///
+  /// Number of option/value string pairs.
+  ///
+  UINT32                      OptionCount;
+  ///
+  /// The pointer to an array of option/value string pairs. Ignored if OptionCount is zero.
+  ///
+  EFI_MTFTP4_OPTION           *OptionList;
+  ///
+  /// The size of the data buffer.
+  ///
+  UINT64                      BufferSize;
+  ///
+  /// The pointer to the data buffer. Data that is downloaded from the
+  /// MTFTPv4 server is stored here. Data that is uploaded to the
+  /// MTFTPv4 server is read from here. Ignored if BufferSize is zero.
+  ///
+  VOID                        *Buffer;
+  ///
+  /// The pointer to the context that will be used by CheckPacket,
+  /// TimeoutCallback and PacketNeeded.
+  ///
+  VOID                        *Context;
+  ///
+  /// The pointer to the callback function to check the contents of the received packet.
+  ///
+  EFI_MTFTP4_CHECK_PACKET     CheckPacket;
+  ///
+  /// The pointer to the function to be called when a timeout occurs.
+  ///
+  EFI_MTFTP4_TIMEOUT_CALLBACK TimeoutCallback;
+  ///
+  /// The pointer to the function to provide the needed packet contents.
+  ///
+  EFI_MTFTP4_PACKET_NEEDED    PacketNeeded;
+};
+
+extern EFI_GUID gEfiMtftp4ServiceBindingProtocolGuid;
+extern EFI_GUID gEfiMtftp4ProtocolGuid;
+
+#endif
+
diff --git a/src/include/ipxe/efi/Protocol/Tcp4.h b/src/include/ipxe/efi/Protocol/Tcp4.h
new file mode 100644 (file)
index 0000000..1771bc5
--- /dev/null
@@ -0,0 +1,579 @@
+/** @file
+  EFI TCPv4(Transmission Control Protocol version 4) Protocol Definition
+  The EFI TCPv4 Service Binding Protocol is used to locate EFI TCPv4 Protocol drivers to create
+  and destroy child of the driver to communicate with other host using TCP protocol.
+  The EFI TCPv4 Protocol provides services to send and receive data stream.
+
+Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  @par Revision Reference:
+  This Protocol is introduced in UEFI Specification 2.0.
+
+**/
+
+#ifndef __EFI_TCP4_PROTOCOL_H__
+#define __EFI_TCP4_PROTOCOL_H__
+
+FILE_LICENCE ( BSD3 );
+
+#include <ipxe/efi/Protocol/Ip4.h>
+
+#define EFI_TCP4_SERVICE_BINDING_PROTOCOL_GUID \
+  { \
+    0x00720665, 0x67EB, 0x4a99, {0xBA, 0xF7, 0xD3, 0xC3, 0x3A, 0x1C, 0x7C, 0xC9 } \
+  }
+
+#define EFI_TCP4_PROTOCOL_GUID \
+  { \
+    0x65530BC7, 0xA359, 0x410f, {0xB0, 0x10, 0x5A, 0xAD, 0xC7, 0xEC, 0x2B, 0x62 } \
+  }
+
+typedef struct _EFI_TCP4_PROTOCOL EFI_TCP4_PROTOCOL;
+
+///
+/// EFI_TCP4_SERVICE_POINT is deprecated in the UEFI 2.4B and should not be used any more.
+/// The definition in here is only present to provide backwards compatability.
+///
+typedef struct {
+  EFI_HANDLE              InstanceHandle;
+  EFI_IPv4_ADDRESS        LocalAddress;
+  UINT16                  LocalPort;
+  EFI_IPv4_ADDRESS        RemoteAddress;
+  UINT16                  RemotePort;
+} EFI_TCP4_SERVICE_POINT;
+
+///
+/// EFI_TCP4_VARIABLE_DATA is deprecated in the UEFI 2.4B and should not be used any more.
+/// The definition in here is only present to provide backwards compatability.
+///
+typedef struct {
+  EFI_HANDLE              DriverHandle;
+  UINT32                  ServiceCount;
+  EFI_TCP4_SERVICE_POINT  Services[1];
+} EFI_TCP4_VARIABLE_DATA;
+
+typedef struct {
+  BOOLEAN                 UseDefaultAddress;
+  EFI_IPv4_ADDRESS        StationAddress;
+  EFI_IPv4_ADDRESS        SubnetMask;
+  UINT16                  StationPort;
+  EFI_IPv4_ADDRESS        RemoteAddress;
+  UINT16                  RemotePort;
+  BOOLEAN                 ActiveFlag;
+} EFI_TCP4_ACCESS_POINT;
+
+typedef struct {
+  UINT32                  ReceiveBufferSize;
+  UINT32                  SendBufferSize;
+  UINT32                  MaxSynBackLog;
+  UINT32                  ConnectionTimeout;
+  UINT32                  DataRetries;
+  UINT32                  FinTimeout;
+  UINT32                  TimeWaitTimeout;
+  UINT32                  KeepAliveProbes;
+  UINT32                  KeepAliveTime;
+  UINT32                  KeepAliveInterval;
+  BOOLEAN                 EnableNagle;
+  BOOLEAN                 EnableTimeStamp;
+  BOOLEAN                 EnableWindowScaling;
+  BOOLEAN                 EnableSelectiveAck;
+  BOOLEAN                 EnablePathMtuDiscovery;
+} EFI_TCP4_OPTION;
+
+typedef struct {
+  //
+  // I/O parameters
+  //
+  UINT8                   TypeOfService;
+  UINT8                   TimeToLive;
+
+  //
+  // Access Point
+  //
+  EFI_TCP4_ACCESS_POINT   AccessPoint;
+
+  //
+  // TCP Control Options
+  //
+  EFI_TCP4_OPTION         *ControlOption;
+} EFI_TCP4_CONFIG_DATA;
+
+///
+/// TCP4 connnection state
+///
+typedef enum {
+  Tcp4StateClosed         = 0,
+  Tcp4StateListen         = 1,
+  Tcp4StateSynSent        = 2,
+  Tcp4StateSynReceived    = 3,
+  Tcp4StateEstablished    = 4,
+  Tcp4StateFinWait1       = 5,
+  Tcp4StateFinWait2       = 6,
+  Tcp4StateClosing        = 7,
+  Tcp4StateTimeWait       = 8,
+  Tcp4StateCloseWait      = 9,
+  Tcp4StateLastAck        = 10
+} EFI_TCP4_CONNECTION_STATE;
+
+typedef struct {
+  EFI_EVENT   Event;
+  EFI_STATUS  Status;
+} EFI_TCP4_COMPLETION_TOKEN;
+
+typedef struct {
+  ///
+  /// The Status in the CompletionToken will be set to one of
+  /// the following values if the active open succeeds or an unexpected
+  /// error happens:
+  /// EFI_SUCCESS:              The active open succeeds and the instance's
+  ///                           state is Tcp4StateEstablished.
+  /// EFI_CONNECTION_RESET:     The connect fails because the connection is reset
+  ///                           either by instance itself or the communication peer.
+  /// EFI_CONNECTION_REFUSED:   The connect fails because this connection is initiated with
+  ///                           an active open and the connection is refused.
+  /// EFI_ABORTED:              The active open is aborted.
+  /// EFI_TIMEOUT:              The connection establishment timer expires and
+  ///                           no more specific information is available.
+  /// EFI_NETWORK_UNREACHABLE:  The active open fails because
+  ///                           an ICMP network unreachable error is received.
+  /// EFI_HOST_UNREACHABLE:     The active open fails because an
+  ///                           ICMP host unreachable error is received.
+  /// EFI_PROTOCOL_UNREACHABLE: The active open fails
+  ///                           because an ICMP protocol unreachable error is received.
+  /// EFI_PORT_UNREACHABLE:     The connection establishment
+  ///                           timer times out and an ICMP port unreachable error is received.
+  /// EFI_ICMP_ERROR:           The connection establishment timer timeout and some other ICMP
+  ///                           error is received.
+  /// EFI_DEVICE_ERROR:         An unexpected system or network error occurred.
+  /// EFI_NO_MEDIA:             There was a media error.
+  ///
+  EFI_TCP4_COMPLETION_TOKEN CompletionToken;
+} EFI_TCP4_CONNECTION_TOKEN;
+
+typedef struct {
+  EFI_TCP4_COMPLETION_TOKEN CompletionToken;
+  EFI_HANDLE                NewChildHandle;
+} EFI_TCP4_LISTEN_TOKEN;
+
+typedef struct {
+  UINT32 FragmentLength;
+  VOID   *FragmentBuffer;
+} EFI_TCP4_FRAGMENT_DATA;
+
+typedef struct {
+  BOOLEAN                   UrgentFlag;
+  UINT32                    DataLength;
+  UINT32                    FragmentCount;
+  EFI_TCP4_FRAGMENT_DATA    FragmentTable[1];
+} EFI_TCP4_RECEIVE_DATA;
+
+typedef struct {
+  BOOLEAN                   Push;
+  BOOLEAN                   Urgent;
+  UINT32                    DataLength;
+  UINT32                    FragmentCount;
+  EFI_TCP4_FRAGMENT_DATA    FragmentTable[1];
+} EFI_TCP4_TRANSMIT_DATA;
+
+typedef struct {
+  ///
+  /// When transmission finishes or meets any unexpected error it will
+  /// be set to one of the following values:
+  /// EFI_SUCCESS:              The receiving or transmission operation
+  ///                           completes successfully.
+  /// EFI_CONNECTION_FIN:       The receiving operation fails because the communication peer
+  ///                           has closed the connection and there is no more data in the
+  ///                           receive buffer of the instance.
+  /// EFI_CONNECTION_RESET:     The receiving or transmission operation fails
+  ///                           because this connection is reset either by instance
+  ///                           itself or the communication peer.
+  /// EFI_ABORTED:              The receiving or transmission is aborted.
+  /// EFI_TIMEOUT:              The transmission timer expires and no more
+  ///                           specific information is available.
+  /// EFI_NETWORK_UNREACHABLE:  The transmission fails
+  ///                           because an ICMP network unreachable error is received.
+  /// EFI_HOST_UNREACHABLE:     The transmission fails because an
+  ///                           ICMP host unreachable error is received.
+  /// EFI_PROTOCOL_UNREACHABLE: The transmission fails
+  ///                           because an ICMP protocol unreachable error is received.
+  /// EFI_PORT_UNREACHABLE:     The transmission fails and an
+  ///                           ICMP port unreachable error is received.
+  /// EFI_ICMP_ERROR:           The transmission fails and some other
+  ///                           ICMP error is received.
+  /// EFI_DEVICE_ERROR:         An unexpected system or network error occurs.
+  /// EFI_NO_MEDIA:             There was a media error.
+  ///
+  EFI_TCP4_COMPLETION_TOKEN CompletionToken;
+  union {
+    ///
+    /// When this token is used for receiving, RxData is a pointer to EFI_TCP4_RECEIVE_DATA.
+    ///
+    EFI_TCP4_RECEIVE_DATA   *RxData;
+    ///
+    /// When this token is used for transmitting, TxData is a pointer to EFI_TCP4_TRANSMIT_DATA.
+    ///
+    EFI_TCP4_TRANSMIT_DATA  *TxData;
+  } Packet;
+} EFI_TCP4_IO_TOKEN;
+
+typedef struct {
+  EFI_TCP4_COMPLETION_TOKEN CompletionToken;
+  BOOLEAN                   AbortOnClose;
+} EFI_TCP4_CLOSE_TOKEN;
+
+//
+// Interface definition for TCP4 protocol
+//
+
+/**
+  Get the current operational status.
+
+  @param  This           The pointer to the EFI_TCP4_PROTOCOL instance.
+  @param  Tcp4State      The pointer to the buffer to receive the current TCP state.
+  @param  Tcp4ConfigData The pointer to the buffer to receive the current TCP configuration.
+  @param  Ip4ModeData    The pointer to the buffer to receive the current IPv4 configuration
+                         data used by the TCPv4 instance.
+  @param  MnpConfigData  The pointer to the buffer to receive the current MNP configuration
+                         data used indirectly by the TCPv4 instance.
+  @param  SnpModeData    The pointer to the buffer to receive the current SNP configuration
+                         data used indirectly by the TCPv4 instance.
+
+  @retval EFI_SUCCESS           The mode data was read.
+  @retval EFI_INVALID_PARAMETER This is NULL.
+  @retval EFI_NOT_STARTED       No configuration data is available because this instance hasn't
+                                 been started.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCP4_GET_MODE_DATA)(
+  IN   EFI_TCP4_PROTOCOL                  *This,
+  OUT  EFI_TCP4_CONNECTION_STATE          *Tcp4State      OPTIONAL,
+  OUT  EFI_TCP4_CONFIG_DATA               *Tcp4ConfigData OPTIONAL,
+  OUT  EFI_IP4_MODE_DATA                  *Ip4ModeData    OPTIONAL,
+  OUT  EFI_MANAGED_NETWORK_CONFIG_DATA    *MnpConfigData  OPTIONAL,
+  OUT  EFI_SIMPLE_NETWORK_MODE            *SnpModeData    OPTIONAL
+  );
+
+/**
+  Initialize or brutally reset the operational parameters for this EFI TCPv4 instance.
+
+  @param  This           The pointer to the EFI_TCP4_PROTOCOL instance.
+  @param  Tcp4ConfigData The pointer to the configure data to configure the instance.
+
+  @retval EFI_SUCCESS           The operational settings are set, changed, or reset
+                                successfully.
+  @retval EFI_INVALID_PARAMETER Some parameter is invalid.
+  @retval EFI_NO_MAPPING        When using a default address, configuration (through
+                                DHCP, BOOTP, RARP, etc.) is not finished yet.
+  @retval EFI_ACCESS_DENIED     Configuring TCP instance when it is configured without
+                                calling Configure() with NULL to reset it.
+  @retval EFI_DEVICE_ERROR      An unexpected network or system error occurred.
+  @retval EFI_UNSUPPORTED       One or more of the control options are not supported in
+                                the implementation.
+  @retval EFI_OUT_OF_RESOURCES  Could not allocate enough system resources when
+                                executing Configure().
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCP4_CONFIGURE)(
+  IN EFI_TCP4_PROTOCOL                   *This,
+  IN EFI_TCP4_CONFIG_DATA                *TcpConfigData OPTIONAL
+  );
+
+
+/**
+  Add or delete a route entry to the route table
+
+  @param  This           The pointer to the EFI_TCP4_PROTOCOL instance.
+  @param  DeleteRoute    Set it to TRUE to delete this route from the routing table. Set it to
+                         FALSE to add this route to the routing table.
+                         DestinationAddress and SubnetMask are used as the
+                         keywords to search route entry.
+  @param  SubnetAddress  The destination network.
+  @param  SubnetMask     The subnet mask of the destination network.
+  @param  GatewayAddress The gateway address for this route. It must be on the same
+                         subnet with the station address unless a direct route is specified.
+
+  @retval EFI_SUCCESS           The operation completed successfully.
+  @retval EFI_NOT_STARTED       The EFI TCPv4 Protocol instance has not been configured.
+  @retval EFI_NO_MAPPING        When using a default address, configuration (DHCP, BOOTP,
+                                RARP, etc.) is not finished yet.
+  @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
+                                - This is NULL.
+                                - SubnetAddress is NULL.
+                                - SubnetMask is NULL.
+                                - GatewayAddress is NULL.
+                                - *SubnetAddress is not NULL a valid subnet address.
+                                - *SubnetMask is not a valid subnet mask.
+                                - *GatewayAddress is not a valid unicast IP address or it
+                                is not in the same subnet.
+  @retval EFI_OUT_OF_RESOURCES  Could not allocate enough resources to add the entry to the
+                                routing table.
+  @retval EFI_NOT_FOUND         This route is not in the routing table.
+  @retval EFI_ACCESS_DENIED     The route is already defined in the routing table.
+  @retval EFI_UNSUPPORTED       The TCP driver does not support this operation.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCP4_ROUTES)(
+  IN EFI_TCP4_PROTOCOL                   *This,
+  IN BOOLEAN                             DeleteRoute,
+  IN EFI_IPv4_ADDRESS                    *SubnetAddress,
+  IN EFI_IPv4_ADDRESS                    *SubnetMask,
+  IN EFI_IPv4_ADDRESS                    *GatewayAddress
+  );
+
+/**
+  Initiate a nonblocking TCP connection request for an active TCP instance.
+
+  @param  This                  The pointer to the EFI_TCP4_PROTOCOL instance.
+  @param  ConnectionToken       The pointer to the connection token to return when the TCP three
+                                way handshake finishes.
+
+  @retval EFI_SUCCESS           The connection request is successfully initiated and the state
+                                of this TCPv4 instance has been changed to Tcp4StateSynSent.
+  @retval EFI_NOT_STARTED       This EFI TCPv4 Protocol instance has not been configured.
+  @retval EFI_ACCESS_DENIED     One or more of the following conditions are TRUE:
+                                - This instance is not configured as an active one.
+                                - This instance is not in Tcp4StateClosed state.
+  @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
+                                - This is NULL.
+                                - ConnectionToken is NULL.
+                                - ConnectionToken->CompletionToken.Event is NULL.
+  @retval EFI_OUT_OF_RESOURCES  The driver can't allocate enough resource to initiate the activ eopen.
+  @retval EFI_DEVICE_ERROR      An unexpected system or network error occurred.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCP4_CONNECT)(
+  IN EFI_TCP4_PROTOCOL                   *This,
+  IN EFI_TCP4_CONNECTION_TOKEN           *ConnectionToken
+  );
+
+
+/**
+  Listen on the passive instance to accept an incoming connection request. This is a nonblocking operation.
+
+  @param  This        The pointer to the EFI_TCP4_PROTOCOL instance.
+  @param  ListenToken The pointer to the listen token to return when operation finishes.
+
+  @retval EFI_SUCCESS           The listen token has been queued successfully.
+  @retval EFI_NOT_STARTED       This EFI TCPv4 Protocol instance has not been configured.
+  @retval EFI_ACCESS_DENIED     One or more of the following are TRUE:
+                                - This instance is not a passive instance.
+                                - This instance is not in Tcp4StateListen state.
+                                - The same listen token has already existed in the listen
+                                token queue of this TCP instance.
+  @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
+                                - This is NULL.
+                                - ListenToken is NULL.
+                                - ListentToken->CompletionToken.Event is NULL.
+  @retval EFI_OUT_OF_RESOURCES  Could not allocate enough resource to finish the operation.
+  @retval EFI_DEVICE_ERROR      Any unexpected and not belonged to above category error.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCP4_ACCEPT)(
+  IN EFI_TCP4_PROTOCOL                   *This,
+  IN EFI_TCP4_LISTEN_TOKEN               *ListenToken
+  );
+
+/**
+  Queues outgoing data into the transmit queue.
+
+  @param  This  The pointer to the EFI_TCP4_PROTOCOL instance.
+  @param  Token The pointer to the completion token to queue to the transmit queue.
+
+  @retval EFI_SUCCESS             The data has been queued for transmission.
+  @retval EFI_NOT_STARTED         This EFI TCPv4 Protocol instance has not been configured.
+  @retval EFI_NO_MAPPING          When using a default address, configuration (DHCP, BOOTP,
+                                  RARP, etc.) is not finished yet.
+  @retval EFI_INVALID_PARAMETER   One or more of the following are TRUE:
+                                  - This is NULL.
+                                  - Token is NULL.
+                                  - Token->CompletionToken.Event is NULL.
+                                  - Token->Packet.TxData is NULL L.
+                                  - Token->Packet.FragmentCount is zero.
+                                  - Token->Packet.DataLength is not equal to the sum of fragment lengths.
+  @retval EFI_ACCESS_DENIED       One or more of the following conditions is TRUE:
+                                  - A transmit completion token with the same Token->CompletionToken.Event
+                                  was already in the transmission queue.
+                                  - The current instance is in Tcp4StateClosed state.
+                                  - The current instance is a passive one and it is in
+                                  Tcp4StateListen state.
+                                  - User has called Close() to disconnect this connection.
+  @retval EFI_NOT_READY           The completion token could not be queued because the
+                                  transmit queue is full.
+  @retval EFI_OUT_OF_RESOURCES    Could not queue the transmit data because of resource
+                                  shortage.
+  @retval EFI_NETWORK_UNREACHABLE There is no route to the destination network or address.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCP4_TRANSMIT)(
+  IN EFI_TCP4_PROTOCOL                   *This,
+  IN EFI_TCP4_IO_TOKEN                   *Token
+  );
+
+
+/**
+  Places an asynchronous receive request into the receiving queue.
+
+  @param  This  The pointer to the EFI_TCP4_PROTOCOL instance.
+  @param  Token The pointer to a token that is associated with the receive data
+                descriptor.
+
+  @retval EFI_SUCCESS           The receive completion token was cached.
+  @retval EFI_NOT_STARTED       This EFI TCPv4 Protocol instance has not been configured.
+  @retval EFI_NO_MAPPING        When using a default address, configuration (DHCP, BOOTP, RARP,
+                                etc.) is not finished yet.
+  @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
+                                - This is NULL.
+                                - Token is NULL.
+                                - Token->CompletionToken.Event is NULL.
+                                - Token->Packet.RxData is NULL.
+                                - Token->Packet.RxData->DataLength is 0.
+                                - The Token->Packet.RxData->DataLength is not
+                                the sum of all FragmentBuffer length in FragmentTable.
+  @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued due to a lack of
+                               system resources (usually memory).
+  @retval EFI_DEVICE_ERROR     An unexpected system or network error occurred.
+  @retval EFI_ACCESS_DENIED    One or more of the following conditions is TRUE:
+                               - A receive completion token with the same Token-
+                               >CompletionToken.Event was already in the receive
+                               queue.
+                               - The current instance is in Tcp4StateClosed state.
+                               - The current instance is a passive one and it is in
+                               Tcp4StateListen state.
+                               - User has called Close() to disconnect this connection.
+  @retval EFI_CONNECTION_FIN   The communication peer has closed the connection and there is
+                               no any buffered data in the receive buffer of this instance.
+  @retval EFI_NOT_READY        The receive request could not be queued because the receive queue is full.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCP4_RECEIVE)(
+  IN EFI_TCP4_PROTOCOL                   *This,
+  IN EFI_TCP4_IO_TOKEN                   *Token
+  );
+
+/**
+  Disconnecting a TCP connection gracefully or reset a TCP connection. This function is a
+  nonblocking operation.
+
+  @param  This       The pointer to the EFI_TCP4_PROTOCOL instance.
+  @param  CloseToken The pointer to the close token to return when operation finishes.
+
+  @retval EFI_SUCCESS           The Close() is called successfully.
+  @retval EFI_NOT_STARTED       This EFI TCPv4 Protocol instance has not been configured.
+  @retval EFI_ACCESS_DENIED     One or more of the following are TRUE:
+                                - Configure() has been called with
+                                TcpConfigData set to NULL and this function has
+                                not returned.
+                                - Previous Close() call on this instance has not
+                                finished.
+  @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:
+                                - This is NULL.
+                                - CloseToken is NULL.
+                                - CloseToken->CompletionToken.Event is NULL.
+  @retval EFI_OUT_OF_RESOURCES  Could not allocate enough resource to finish the operation.
+  @retval EFI_DEVICE_ERROR      Any unexpected and not belonged to above category error.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCP4_CLOSE)(
+  IN EFI_TCP4_PROTOCOL                   *This,
+  IN EFI_TCP4_CLOSE_TOKEN                *CloseToken
+  );
+
+/**
+  Abort an asynchronous connection, listen, transmission or receive request.
+
+  @param  This  The pointer to the EFI_TCP4_PROTOCOL instance.
+  @param  Token The pointer to a token that has been issued by
+                EFI_TCP4_PROTOCOL.Connect(),
+                EFI_TCP4_PROTOCOL.Accept(),
+                EFI_TCP4_PROTOCOL.Transmit() or
+                EFI_TCP4_PROTOCOL.Receive(). If NULL, all pending
+                tokens issued by above four functions will be aborted. Type
+                EFI_TCP4_COMPLETION_TOKEN is defined in
+                EFI_TCP4_PROTOCOL.Connect().
+
+  @retval  EFI_SUCCESS             The asynchronous I/O request is aborted and Token->Event
+                                   is signaled.
+  @retval  EFI_INVALID_PARAMETER   This is NULL.
+  @retval  EFI_NOT_STARTED         This instance hasn't been configured.
+  @retval  EFI_NO_MAPPING          When using the default address, configuration
+                                   (DHCP, BOOTP,RARP, etc.) hasn't finished yet.
+  @retval  EFI_NOT_FOUND           The asynchronous I/O request isn't found in the
+                                   transmission or receive queue. It has either
+                                   completed or wasn't issued by Transmit() and Receive().
+  @retval  EFI_UNSUPPORTED         The implementation does not support this function.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCP4_CANCEL)(
+  IN EFI_TCP4_PROTOCOL                   *This,
+  IN EFI_TCP4_COMPLETION_TOKEN           *Token OPTIONAL
+  );
+
+
+/**
+  Poll to receive incoming data and transmit outgoing segments.
+
+  @param  This The pointer to the EFI_TCP4_PROTOCOL instance.
+
+  @retval  EFI_SUCCESS           Incoming or outgoing data was processed.
+  @retval  EFI_INVALID_PARAMETER This is NULL.
+  @retval  EFI_DEVICE_ERROR      An unexpected system or network error occurred.
+  @retval  EFI_NOT_READY         No incoming or outgoing data is processed.
+  @retval  EFI_TIMEOUT           Data was dropped out of the transmission or receive queue.
+                                 Consider increasing the polling rate.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCP4_POLL)(
+  IN EFI_TCP4_PROTOCOL                   *This
+  );
+
+///
+/// The EFI_TCP4_PROTOCOL defines the EFI TCPv4 Protocol child to be used by
+/// any network drivers or applications to send or receive data stream.
+/// It can either listen on a specified port as a service or actively connected
+/// to remote peer as a client. Each instance has its own independent settings,
+/// such as the routing table.
+///
+struct _EFI_TCP4_PROTOCOL {
+  EFI_TCP4_GET_MODE_DATA                 GetModeData;
+  EFI_TCP4_CONFIGURE                     Configure;
+  EFI_TCP4_ROUTES                        Routes;
+  EFI_TCP4_CONNECT                       Connect;
+  EFI_TCP4_ACCEPT                        Accept;
+  EFI_TCP4_TRANSMIT                      Transmit;
+  EFI_TCP4_RECEIVE                       Receive;
+  EFI_TCP4_CLOSE                         Close;
+  EFI_TCP4_CANCEL                        Cancel;
+  EFI_TCP4_POLL                          Poll;
+};
+
+extern EFI_GUID gEfiTcp4ServiceBindingProtocolGuid;
+extern EFI_GUID gEfiTcp4ProtocolGuid;
+
+#endif
diff --git a/src/include/ipxe/efi/Protocol/Udp4.h b/src/include/ipxe/efi/Protocol/Udp4.h
new file mode 100644 (file)
index 0000000..3c61db8
--- /dev/null
@@ -0,0 +1,447 @@
+/** @file
+  UDP4 Service Binding Protocol as defined in UEFI specification.
+
+  The EFI UDPv4 Protocol provides simple packet-oriented services
+  to transmit and receive UDP packets.
+
+Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  @par Revision Reference:
+  This Protocol is introduced in UEFI Specification 2.0.
+
+**/
+
+#ifndef __EFI_UDP4_PROTOCOL_H__
+#define __EFI_UDP4_PROTOCOL_H__
+
+FILE_LICENCE ( BSD3 );
+
+#include <ipxe/efi/Protocol/Ip4.h>
+//
+//GUID definitions
+//
+#define EFI_UDP4_SERVICE_BINDING_PROTOCOL_GUID \
+  { \
+    0x83f01464, 0x99bd, 0x45e5, {0xb3, 0x83, 0xaf, 0x63, 0x05, 0xd8, 0xe9, 0xe6 } \
+  }
+
+#define EFI_UDP4_PROTOCOL_GUID \
+  { \
+    0x3ad9df29, 0x4501, 0x478d, {0xb1, 0xf8, 0x7f, 0x7f, 0xe7, 0x0e, 0x50, 0xf3 } \
+  }
+
+typedef struct _EFI_UDP4_PROTOCOL EFI_UDP4_PROTOCOL;
+
+///
+/// EFI_UDP4_SERVICE_POINT is deprecated in the UEFI 2.4B and should not be used any more.
+/// The definition in here is only present to provide backwards compatability.
+///
+typedef struct {
+  EFI_HANDLE              InstanceHandle;
+  EFI_IPv4_ADDRESS        LocalAddress;
+  UINT16                  LocalPort;
+  EFI_IPv4_ADDRESS        RemoteAddress;
+  UINT16                  RemotePort;
+} EFI_UDP4_SERVICE_POINT;
+
+///
+/// EFI_UDP4_VARIABLE_DATA is deprecated in the UEFI 2.4B and should not be used any more.
+/// The definition in here is only present to provide backwards compatability.
+///
+typedef struct {
+  EFI_HANDLE              DriverHandle;
+  UINT32                  ServiceCount;
+  EFI_UDP4_SERVICE_POINT  Services[1];
+} EFI_UDP4_VARIABLE_DATA;
+
+typedef struct {
+  UINT32             FragmentLength;
+  VOID               *FragmentBuffer;
+} EFI_UDP4_FRAGMENT_DATA;
+
+typedef struct {
+  EFI_IPv4_ADDRESS   SourceAddress;
+  UINT16             SourcePort;
+  EFI_IPv4_ADDRESS   DestinationAddress;
+  UINT16             DestinationPort;
+} EFI_UDP4_SESSION_DATA;
+typedef struct {
+  //
+  // Receiving Filters
+  //
+  BOOLEAN            AcceptBroadcast;
+  BOOLEAN            AcceptPromiscuous;
+  BOOLEAN            AcceptAnyPort;
+  BOOLEAN            AllowDuplicatePort;
+  //
+  // I/O parameters
+  //
+  UINT8              TypeOfService;
+  UINT8              TimeToLive;
+  BOOLEAN            DoNotFragment;
+  UINT32             ReceiveTimeout;
+  UINT32             TransmitTimeout;
+  //
+  // Access Point
+  //
+  BOOLEAN            UseDefaultAddress;
+  EFI_IPv4_ADDRESS   StationAddress;
+  EFI_IPv4_ADDRESS   SubnetMask;
+  UINT16             StationPort;
+  EFI_IPv4_ADDRESS   RemoteAddress;
+  UINT16             RemotePort;
+} EFI_UDP4_CONFIG_DATA;
+
+typedef struct {
+  EFI_UDP4_SESSION_DATA     *UdpSessionData;       //OPTIONAL
+  EFI_IPv4_ADDRESS          *GatewayAddress;       //OPTIONAL
+  UINT32                    DataLength;
+  UINT32                    FragmentCount;
+  EFI_UDP4_FRAGMENT_DATA    FragmentTable[1];
+} EFI_UDP4_TRANSMIT_DATA;
+
+typedef struct {
+  EFI_TIME                  TimeStamp;
+  EFI_EVENT                 RecycleSignal;
+  EFI_UDP4_SESSION_DATA     UdpSession;
+  UINT32                    DataLength;
+  UINT32                    FragmentCount;
+  EFI_UDP4_FRAGMENT_DATA    FragmentTable[1];
+} EFI_UDP4_RECEIVE_DATA;
+
+
+typedef struct {
+  EFI_EVENT                 Event;
+  EFI_STATUS                Status;
+  union {
+    EFI_UDP4_RECEIVE_DATA   *RxData;
+    EFI_UDP4_TRANSMIT_DATA  *TxData;
+  } Packet;
+} EFI_UDP4_COMPLETION_TOKEN;
+
+/**
+  Reads the current operational settings.
+
+  The GetModeData() function copies the current operational settings of this EFI
+  UDPv4 Protocol instance into user-supplied buffers. This function is used
+  optionally to retrieve the operational mode data of underlying networks or
+  drivers.
+
+  @param  This           The pointer to the EFI_UDP4_PROTOCOL instance.
+  @param  Udp4ConfigData The pointer to the buffer to receive the current configuration data.
+  @param  Ip4ModeData    The pointer to the EFI IPv4 Protocol mode data structure.
+  @param  MnpConfigData  The pointer to the managed network configuration data structure.
+  @param  SnpModeData    The pointer to the simple network mode data structure.
+
+  @retval EFI_SUCCESS           The mode data was read.
+  @retval EFI_NOT_STARTED       When Udp4ConfigData is queried, no configuration data is
+                                available because this instance has not been started.
+  @retval EFI_INVALID_PARAMETER This is NULL.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_UDP4_GET_MODE_DATA)(
+  IN  EFI_UDP4_PROTOCOL                *This,
+  OUT EFI_UDP4_CONFIG_DATA             *Udp4ConfigData OPTIONAL,
+  OUT EFI_IP4_MODE_DATA                *Ip4ModeData    OPTIONAL,
+  OUT EFI_MANAGED_NETWORK_CONFIG_DATA  *MnpConfigData  OPTIONAL,
+  OUT EFI_SIMPLE_NETWORK_MODE          *SnpModeData    OPTIONAL
+  );
+
+
+/**
+  Initializes, changes, or resets the operational parameters for this instance of the EFI UDPv4
+  Protocol.
+
+  The Configure() function is used to do the following:
+  * Initialize and start this instance of the EFI UDPv4 Protocol.
+  * Change the filtering rules and operational parameters.
+  * Reset this instance of the EFI UDPv4 Protocol.
+  Until these parameters are initialized, no network traffic can be sent or
+  received by this instance. This instance can be also reset by calling Configure()
+  with UdpConfigData set to NULL. Once reset, the receiving queue and transmitting
+  queue are flushed and no traffic is allowed through this instance.
+  With different parameters in UdpConfigData, Configure() can be used to bind
+  this instance to specified port.
+
+  @param  This           The pointer to the EFI_UDP4_PROTOCOL instance.
+  @param  Udp4ConfigData The pointer to the buffer to receive the current configuration data.
+
+  @retval EFI_SUCCESS           The configuration settings were set, changed, or reset successfully.
+  @retval EFI_NO_MAPPING        When using a default address, configuration (DHCP, BOOTP,
+                                RARP, etc.) is not finished yet.
+  @retval EFI_INVALID_PARAMETER This is NULL.
+  @retval EFI_INVALID_PARAMETER UdpConfigData.StationAddress is not a valid unicast IPv4 address.
+  @retval EFI_INVALID_PARAMETER UdpConfigData.SubnetMask is not a valid IPv4 address mask. The subnet
+                                mask must be contiguous.
+  @retval EFI_INVALID_PARAMETER UdpConfigData.RemoteAddress is not a valid unicast IPv4 address if it
+                                is not zero.
+  @retval EFI_ALREADY_STARTED   The EFI UDPv4 Protocol instance is already started/configured
+                                and must be stopped/reset before it can be reconfigured.
+  @retval EFI_ACCESS_DENIED     UdpConfigData. AllowDuplicatePort is FALSE
+                                and UdpConfigData.StationPort is already used by
+                                other instance.
+  @retval EFI_OUT_OF_RESOURCES  The EFI UDPv4 Protocol driver cannot allocate memory for this
+                                EFI UDPv4 Protocol instance.
+  @retval EFI_DEVICE_ERROR      An unexpected network or system error occurred and this instance
+                                 was not opened.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_UDP4_CONFIGURE)(
+  IN EFI_UDP4_PROTOCOL      *This,
+  IN EFI_UDP4_CONFIG_DATA   *UdpConfigData OPTIONAL
+  );
+
+/**
+  Joins and leaves multicast groups.
+
+  The Groups() function is used to enable and disable the multicast group
+  filtering. If the JoinFlag is FALSE and the MulticastAddress is NULL, then all
+  currently joined groups are left.
+
+  @param  This             The pointer to the EFI_UDP4_PROTOCOL instance.
+  @param  JoinFlag         Set to TRUE to join a multicast group. Set to FALSE to leave one
+                           or all multicast groups.
+  @param  MulticastAddress The pointer to multicast group address to join or leave.
+
+  @retval EFI_SUCCESS           The operation completed successfully.
+  @retval EFI_NOT_STARTED       The EFI UDPv4 Protocol instance has not been started.
+  @retval EFI_NO_MAPPING        When using a default address, configuration (DHCP, BOOTP,
+                                RARP, etc.) is not finished yet.
+  @retval EFI_OUT_OF_RESOURCES  Could not allocate resources to join the group.
+  @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
+                                - This is NULL.
+                                - JoinFlag is TRUE and MulticastAddress is NULL.
+                                - JoinFlag is TRUE and *MulticastAddress is not
+                                  a valid multicast address.
+  @retval EFI_ALREADY_STARTED   The group address is already in the group table (when
+                                JoinFlag is TRUE).
+  @retval EFI_NOT_FOUND         The group address is not in the group table (when JoinFlag is
+                                FALSE).
+  @retval EFI_DEVICE_ERROR      An unexpected system or network error occurred.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_UDP4_GROUPS)(
+  IN EFI_UDP4_PROTOCOL      *This,
+  IN BOOLEAN                JoinFlag,
+  IN EFI_IPv4_ADDRESS       *MulticastAddress    OPTIONAL
+  );
+
+/**
+  Adds and deletes routing table entries.
+
+  The Routes() function adds a route to or deletes a route from the routing table.
+  Routes are determined by comparing the SubnetAddress with the destination IP
+  address and arithmetically AND-ing it with the SubnetMask. The gateway address
+  must be on the same subnet as the configured station address.
+  The default route is added with SubnetAddress and SubnetMask both set to 0.0.0.0.
+  The default route matches all destination IP addresses that do not match any
+  other routes.
+  A zero GatewayAddress is a nonroute. Packets are sent to the destination IP
+  address if it can be found in the Address Resolution Protocol (ARP) cache or
+  on the local subnet. One automatic nonroute entry will be inserted into the
+  routing table for outgoing packets that are addressed to a local subnet
+  (gateway address of 0.0.0.0).
+  Each instance of the EFI UDPv4 Protocol has its own independent routing table.
+  Instances of the EFI UDPv4 Protocol that use the default IP address will also
+  have copies of the routing table provided by the EFI_IP4_CONFIG_PROTOCOL. These
+  copies will be updated automatically whenever the IP driver reconfigures its
+  instances; as a result, the previous modification to these copies will be lost.
+
+  @param  This           The pointer to the EFI_UDP4_PROTOCOL instance.
+  @param  DeleteRoute    Set to TRUE to delete this route from the routing table.
+                         Set to FALSE to add this route to the routing table.
+  @param  SubnetAddress  The destination network address that needs to be routed.
+  @param  SubnetMask     The subnet mask of SubnetAddress.
+  @param  GatewayAddress The gateway IP address for this route.
+
+  @retval EFI_SUCCESS           The operation completed successfully.
+  @retval EFI_NOT_STARTED       The EFI UDPv4 Protocol instance has not been started.
+  @retval EFI_NO_MAPPING        When using a default address, configuration (DHCP, BOOTP,
+                                - RARP, etc.) is not finished yet.
+  @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
+  @retval EFI_OUT_OF_RESOURCES  Could not add the entry to the routing table.
+  @retval EFI_NOT_FOUND         This route is not in the routing table.
+  @retval EFI_ACCESS_DENIED     The route is already defined in the routing table.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_UDP4_ROUTES)(
+  IN EFI_UDP4_PROTOCOL      *This,
+  IN BOOLEAN                DeleteRoute,
+  IN EFI_IPv4_ADDRESS       *SubnetAddress,
+  IN EFI_IPv4_ADDRESS       *SubnetMask,
+  IN EFI_IPv4_ADDRESS       *GatewayAddress
+  );
+
+/**
+  Polls for incoming data packets and processes outgoing data packets.
+
+  The Poll() function can be used by network drivers and applications to increase
+  the rate that data packets are moved between the communications device and the
+  transmit and receive queues.
+  In some systems, the periodic timer event in the managed network driver may not
+  poll the underlying communications device fast enough to transmit and/or receive
+  all data packets without missing incoming packets or dropping outgoing packets.
+  Drivers and applications that are experiencing packet loss should try calling
+  the Poll() function more often.
+
+  @param  This The pointer to the EFI_UDP4_PROTOCOL instance.
+
+  @retval EFI_SUCCESS           Incoming or outgoing data was processed.
+  @retval EFI_INVALID_PARAMETER This is NULL.
+  @retval EFI_DEVICE_ERROR      An unexpected system or network error occurred.
+  @retval EFI_TIMEOUT           Data was dropped out of the transmit and/or receive queue.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_UDP4_POLL)(
+  IN EFI_UDP4_PROTOCOL      *This
+  );
+
+/**
+  Places an asynchronous receive request into the receiving queue.
+
+  The Receive() function places a completion token into the receive packet queue.
+  This function is always asynchronous.
+  The caller must fill in the Token.Event field in the completion token, and this
+  field cannot be NULL. When the receive operation completes, the EFI UDPv4 Protocol
+  driver updates the Token.Status and Token.Packet.RxData fields and the Token.Event
+  is signaled. Providing a proper notification function and context for the event
+  will enable the user to receive the notification and receiving status. That
+  notification function is guaranteed to not be re-entered.
+
+  @param  This  The pointer to the EFI_UDP4_PROTOCOL instance.
+  @param  Token The pointer to a token that is associated with the receive data
+                descriptor.
+
+  @retval EFI_SUCCESS           The receive completion token was cached.
+  @retval EFI_NOT_STARTED       This EFI UDPv4 Protocol instance has not been started.
+  @retval EFI_NO_MAPPING        When using a default address, configuration (DHCP, BOOTP, RARP, etc.)
+                                is not finished yet.
+  @retval EFI_INVALID_PARAMETER This is NULL.
+  @retval EFI_INVALID_PARAMETER Token is NULL.
+  @retval EFI_INVALID_PARAMETER Token.Event is NULL.
+  @retval EFI_OUT_OF_RESOURCES  The receive completion token could not be queued due to a lack of system
+                                resources (usually memory).
+  @retval EFI_DEVICE_ERROR      An unexpected system or network error occurred.
+  @retval EFI_ACCESS_DENIED     A receive completion token with the same Token.Event was already in
+                                the receive queue.
+  @retval EFI_NOT_READY         The receive request could not be queued because the receive queue is full.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_UDP4_RECEIVE)(
+  IN EFI_UDP4_PROTOCOL          *This,
+  IN EFI_UDP4_COMPLETION_TOKEN  *Token
+  );
+
+/**
+  Queues outgoing data packets into the transmit queue.
+
+  The Transmit() function places a sending request to this instance of the EFI
+  UDPv4 Protocol, alongside the transmit data that was filled by the user. Whenever
+  the packet in the token is sent out or some errors occur, the Token.Event will
+  be signaled and Token.Status is updated. Providing a proper notification function
+  and context for the event will enable the user to receive the notification and
+  transmitting status.
+
+  @param  This  The pointer to the EFI_UDP4_PROTOCOL instance.
+  @param  Token The pointer to the completion token that will be placed into the
+                transmit queue.
+
+  @retval EFI_SUCCESS           The data has been queued for transmission.
+  @retval EFI_NOT_STARTED       This EFI UDPv4 Protocol instance has not been started.
+  @retval EFI_NO_MAPPING        When using a default address, configuration (DHCP, BOOTP,
+                                RARP, etc.) is not finished yet.
+  @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
+  @retval EFI_ACCESS_DENIED     The transmit completion token with the same
+                                Token.Event was already in the transmit queue.
+  @retval EFI_NOT_READY         The completion token could not be queued because the
+                                transmit queue is full.
+  @retval EFI_OUT_OF_RESOURCES  Could not queue the transmit data.
+  @retval EFI_NOT_FOUND         There is no route to the destination network or address.
+  @retval EFI_BAD_BUFFER_SIZE   The data length is greater than the maximum UDP packet
+                                size. Or the length of the IP header + UDP header + data
+                                length is greater than MTU if DoNotFragment is TRUE.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_UDP4_TRANSMIT)(
+  IN EFI_UDP4_PROTOCOL           *This,
+  IN EFI_UDP4_COMPLETION_TOKEN   *Token
+  );
+
+/**
+  Aborts an asynchronous transmit or receive request.
+
+  The Cancel() function is used to abort a pending transmit or receive request.
+  If the token is in the transmit or receive request queues, after calling this
+  function, Token.Status will be set to EFI_ABORTED and then Token.Event will be
+  signaled. If the token is not in one of the queues, which usually means that
+  the asynchronous operation has completed, this function will not signal the
+  token and EFI_NOT_FOUND is returned.
+
+  @param  This  The pointer to the EFI_UDP4_PROTOCOL instance.
+  @param  Token The pointer to a token that has been issued by
+                EFI_UDP4_PROTOCOL.Transmit() or
+                EFI_UDP4_PROTOCOL.Receive().If NULL, all pending
+                tokens are aborted.
+
+  @retval  EFI_SUCCESS           The asynchronous I/O request was aborted and Token.Event
+                                 was signaled. When Token is NULL, all pending requests are
+                                 aborted and their events are signaled.
+  @retval  EFI_INVALID_PARAMETER This is NULL.
+  @retval  EFI_NOT_STARTED       This instance has not been started.
+  @retval  EFI_NO_MAPPING        When using the default address, configuration (DHCP, BOOTP,
+                                 RARP, etc.) is not finished yet.
+  @retval  EFI_NOT_FOUND         When Token is not NULL, the asynchronous I/O request was
+                                 not found in the transmit or receive queue. It has either completed
+                                 or was not issued by Transmit() and Receive().
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_UDP4_CANCEL)(
+  IN EFI_UDP4_PROTOCOL          *This,
+  IN EFI_UDP4_COMPLETION_TOKEN  *Token  OPTIONAL
+  );
+
+///
+/// The EFI_UDP4_PROTOCOL defines an EFI UDPv4 Protocol session that can be used
+/// by any network drivers, applications, or daemons to transmit or receive UDP packets.
+/// This protocol instance can either be bound to a specified port as a service or
+/// connected to some remote peer as an active client. Each instance has its own settings,
+/// such as the routing table and group table, which are independent from each other.
+///
+struct _EFI_UDP4_PROTOCOL {
+  EFI_UDP4_GET_MODE_DATA        GetModeData;
+  EFI_UDP4_CONFIGURE            Configure;
+  EFI_UDP4_GROUPS               Groups;
+  EFI_UDP4_ROUTES               Routes;
+  EFI_UDP4_TRANSMIT             Transmit;
+  EFI_UDP4_RECEIVE              Receive;
+  EFI_UDP4_CANCEL               Cancel;
+  EFI_UDP4_POLL                 Poll;
+};
+
+extern EFI_GUID gEfiUdp4ServiceBindingProtocolGuid;
+extern EFI_GUID gEfiUdp4ProtocolGuid;
+
+#endif
diff --git a/src/include/ipxe/efi/Protocol/VlanConfig.h b/src/include/ipxe/efi/Protocol/VlanConfig.h
new file mode 100644 (file)
index 0000000..928fade
--- /dev/null
@@ -0,0 +1,145 @@
+/** @file
+  EFI VLAN Config protocol is to provide manageability interface for VLAN configuration.
+
+  Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD License
+  which accompanies this distribution.  The full text of the license may be found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+  @par Revision Reference:
+  This Protocol is introduced in UEFI Specification 2.2
+
+**/
+
+#ifndef __EFI_VLANCONFIG_PROTOCOL_H__
+#define __EFI_VLANCONFIG_PROTOCOL_H__
+
+FILE_LICENCE ( BSD3 );
+
+
+#define EFI_VLAN_CONFIG_PROTOCOL_GUID \
+  { \
+    0x9e23d768, 0xd2f3, 0x4366, {0x9f, 0xc3, 0x3a, 0x7a, 0xba, 0x86, 0x43, 0x74 } \
+  }
+
+typedef struct _EFI_VLAN_CONFIG_PROTOCOL EFI_VLAN_CONFIG_PROTOCOL;
+
+
+///
+/// EFI_VLAN_FIND_DATA
+///
+typedef struct {
+  UINT16          VlanId;     ///< Vlan Identifier.
+  UINT8           Priority;   ///< Priority of this VLAN.
+} EFI_VLAN_FIND_DATA;
+
+
+/**
+  Create a VLAN device or modify the configuration parameter of an
+  already-configured VLAN.
+
+  The Set() function is used to create a new VLAN device or change the VLAN
+  configuration parameters. If the VlanId hasn't been configured in the
+  physical Ethernet device, a new VLAN device will be created. If a VLAN with
+  this VlanId is already configured, then related configuration will be updated
+  as the input parameters.
+
+  If VlanId is zero, the VLAN device will send and receive untagged frames.
+  Otherwise, the VLAN device will send and receive VLAN-tagged frames containing the VlanId.
+  If VlanId is out of scope of (0-4094), EFI_INVALID_PARAMETER is returned.
+  If Priority is out of the scope of (0-7), then EFI_INVALID_PARAMETER is returned.
+  If there is not enough system memory to perform the registration, then
+  EFI_OUT_OF_RESOURCES is returned.
+
+  @param[in] This                Points to the EFI_VLAN_CONFIG_PROTOCOL.
+  @param[in] VlanId              A unique identifier (1-4094) of the VLAN which is being created
+                                 or modified, or zero (0).
+  @param[in] Priority            3 bit priority in VLAN header. Priority 0 is default value. If
+                                 VlanId is zero (0), Priority is ignored.
+
+  @retval EFI_SUCCESS            The VLAN is successfully configured.
+  @retval EFI_INVALID_PARAMETER  One or more of following conditions is TRUE:
+                                 - This is NULL.
+                                 - VlanId is an invalid VLAN Identifier.
+                                 - Priority is invalid.
+  @retval EFI_OUT_OF_RESOURCES   There is not enough system memory to perform the registration.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_VLAN_CONFIG_SET)(
+  IN  EFI_VLAN_CONFIG_PROTOCOL     *This,
+  IN  UINT16                       VlanId,
+  IN  UINT8                        Priority
+  );
+
+/**
+  Find configuration information for specified VLAN or all configured VLANs.
+
+  The Find() function is used to find the configuration information for matching
+  VLAN and allocate a buffer into which those entries are copied.
+
+  @param[in]  This               Points to the EFI_VLAN_CONFIG_PROTOCOL.
+  @param[in]  VlanId             Pointer to VLAN identifier. Set to NULL to find all
+                                 configured VLANs.
+  @param[out] NumberOfVlan       The number of VLANs which is found by the specified criteria.
+  @param[out] Entries            The buffer which receive the VLAN configuration.
+
+  @retval EFI_SUCCESS            The VLAN is successfully found.
+  @retval EFI_INVALID_PARAMETER  One or more of following conditions is TRUE:
+                                 - This is NULL.
+                                 - Specified VlanId is invalid.
+  @retval EFI_NOT_FOUND          No matching VLAN is found.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_VLAN_CONFIG_FIND)(
+  IN  EFI_VLAN_CONFIG_PROTOCOL     *This,
+  IN  UINT16                       *VlanId  OPTIONAL,
+  OUT UINT16                       *NumberOfVlan,
+  OUT EFI_VLAN_FIND_DATA           **Entries
+  );
+
+/**
+  Remove the configured VLAN device.
+
+  The Remove() function is used to remove the specified VLAN device.
+  If the VlanId is out of the scope of (0-4094), EFI_INVALID_PARAMETER is returned.
+  If specified VLAN hasn't been previously configured, EFI_NOT_FOUND is returned.
+
+  @param[in] This                Points to the EFI_VLAN_CONFIG_PROTOCOL.
+  @param[in] VlanId              Identifier (0-4094) of the VLAN to be removed.
+
+  @retval EFI_SUCCESS            The VLAN is successfully removed.
+  @retval EFI_INVALID_PARAMETER  One or more of following conditions is TRUE:
+                                 - This is NULL.
+                                 - VlanId  is an invalid parameter.
+  @retval EFI_NOT_FOUND          The to-be-removed VLAN does not exist.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_VLAN_CONFIG_REMOVE)(
+  IN  EFI_VLAN_CONFIG_PROTOCOL     *This,
+  IN  UINT16                       VlanId
+  );
+
+///
+/// EFI_VLAN_CONFIG_PROTOCOL
+/// provide manageability interface for VLAN setting. The intended
+/// VLAN tagging implementation is IEEE802.1Q.
+///
+struct _EFI_VLAN_CONFIG_PROTOCOL {
+  EFI_VLAN_CONFIG_SET              Set;
+  EFI_VLAN_CONFIG_FIND             Find;
+  EFI_VLAN_CONFIG_REMOVE           Remove;
+};
+
+extern EFI_GUID gEfiVlanConfigProtocolGuid;
+
+#endif
index 4dff2a7b8b68a3f5b1a9468a82693c0b1197f216..ab52dd9e0ab0a1159efe62a96fc54f51180336d2 100644 (file)
@@ -153,19 +153,30 @@ struct efi_config_table {
  */
 #define EEFI( efirc ) EPLATFORM ( EINFO_EPLATFORM, efirc )
 
+extern EFI_GUID efi_arp_protocol_guid;
+extern EFI_GUID efi_arp_service_binding_protocol_guid;
 extern EFI_GUID efi_block_io_protocol_guid;
 extern EFI_GUID efi_bus_specific_driver_override_protocol_guid;
 extern EFI_GUID efi_component_name_protocol_guid;
 extern EFI_GUID efi_component_name2_protocol_guid;
 extern EFI_GUID efi_device_path_protocol_guid;
+extern EFI_GUID efi_dhcp4_protocol_guid;
+extern EFI_GUID efi_dhcp4_service_binding_protocol_guid;
 extern EFI_GUID efi_disk_io_protocol_guid;
 extern EFI_GUID efi_driver_binding_protocol_guid;
 extern EFI_GUID efi_graphics_output_protocol_guid;
 extern EFI_GUID efi_hii_config_access_protocol_guid;
+extern EFI_GUID efi_ip4_protocol_guid;
+extern EFI_GUID efi_ip4_config_protocol_guid;
+extern EFI_GUID efi_ip4_service_binding_protocol_guid;
 extern EFI_GUID efi_load_file_protocol_guid;
 extern EFI_GUID efi_load_file2_protocol_guid;
 extern EFI_GUID efi_loaded_image_protocol_guid;
 extern EFI_GUID efi_loaded_image_device_path_protocol_guid;
+extern EFI_GUID efi_managed_network_protocol_guid;
+extern EFI_GUID efi_managed_network_service_binding_protocol_guid;
+extern EFI_GUID efi_mtftp4_protocol_guid;
+extern EFI_GUID efi_mtftp4_service_binding_protocol_guid;
 extern EFI_GUID efi_nii_protocol_guid;
 extern EFI_GUID efi_nii31_protocol_guid;
 extern EFI_GUID efi_pci_io_protocol_guid;
@@ -174,6 +185,11 @@ extern EFI_GUID efi_pxe_base_code_protocol_guid;
 extern EFI_GUID efi_simple_file_system_protocol_guid;
 extern EFI_GUID efi_simple_network_protocol_guid;
 extern EFI_GUID efi_tcg_protocol_guid;
+extern EFI_GUID efi_tcp4_protocol_guid;
+extern EFI_GUID efi_tcp4_service_binding_protocol_guid;
+extern EFI_GUID efi_udp4_protocol_guid;
+extern EFI_GUID efi_udp4_service_binding_protocol_guid;
+extern EFI_GUID efi_vlan_config_protocol_guid;
 
 extern EFI_HANDLE efi_image_handle;
 extern EFI_LOADED_IMAGE_PROTOCOL *efi_loaded_image;
index c6b43e016b7234e2954fb94398ff824d2088ef38..d2396014012c466cc15709cd5daf7560d95f53ad 100644 (file)
@@ -42,6 +42,18 @@ FILE_LICENCE ( GPL2_OR_LATER );
 static EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *efidpt;
 EFI_REQUEST_PROTOCOL ( EFI_DEVICE_PATH_TO_TEXT_PROTOCOL, &efidpt );
 
+/** Iscsi4Dxe module GUID */
+static EFI_GUID efi_iscsi4_dxe_guid = {
+       0x4579b72d, 0x7ec4, 0x4dd4,
+       { 0x84, 0x86, 0x08, 0x3c, 0x86, 0xb1, 0x82, 0xa7 }
+};
+
+/** VlanConfigDxe module GUID */
+static EFI_GUID efi_vlan_config_dxe_guid = {
+       0xe4f61863, 0xfe2c, 0x4b56,
+       { 0xa8, 0xf4, 0x08, 0x51, 0x9b, 0xc4, 0x39, 0xdf }
+};
+
 /** A well-known GUID */
 struct efi_well_known_guid {
        /** GUID */
@@ -52,24 +64,40 @@ struct efi_well_known_guid {
 
 /** Well-known GUIDs */
 static struct efi_well_known_guid efi_well_known_guids[] = {
+       { &efi_arp_protocol_guid,
+         "Arp" },
+       { &efi_arp_service_binding_protocol_guid,
+         "ArpSb" },
        { &efi_block_io_protocol_guid,
          "BlockIo" },
        { &efi_bus_specific_driver_override_protocol_guid,
          "BusSpecificDriverOverride" },
-       { &efi_component_name2_protocol_guid,
-         "ComponentName2" },
        { &efi_component_name_protocol_guid,
          "ComponentName" },
+       { &efi_component_name2_protocol_guid,
+         "ComponentName2" },
        { &efi_device_path_protocol_guid,
          "DevicePath" },
        { &efi_driver_binding_protocol_guid,
          "DriverBinding" },
+       { &efi_dhcp4_protocol_guid,
+         "Dhcp4" },
+       { &efi_dhcp4_service_binding_protocol_guid,
+         "Dhcp4Sb" },
        { &efi_disk_io_protocol_guid,
          "DiskIo" },
        { &efi_graphics_output_protocol_guid,
          "GraphicsOutput" },
        { &efi_hii_config_access_protocol_guid,
          "HiiConfigAccess" },
+       { &efi_ip4_protocol_guid,
+         "Ip4" },
+       { &efi_ip4_config_protocol_guid,
+         "Ip4Config" },
+       { &efi_ip4_service_binding_protocol_guid,
+         "Ip4Sb" },
+       { &efi_iscsi4_dxe_guid,
+         "IScsi4Dxe" },
        { &efi_load_file_protocol_guid,
          "LoadFile" },
        { &efi_load_file2_protocol_guid,
@@ -78,6 +106,14 @@ static struct efi_well_known_guid efi_well_known_guids[] = {
          "LoadedImage" },
        { &efi_loaded_image_device_path_protocol_guid,
          "LoadedImageDevicePath"},
+       { &efi_managed_network_protocol_guid,
+         "ManagedNetwork" },
+       { &efi_managed_network_service_binding_protocol_guid,
+         "ManagedNetworkSb" },
+       { &efi_mtftp4_protocol_guid,
+         "Mtftp4" },
+       { &efi_mtftp4_service_binding_protocol_guid,
+         "Mtftp4Sb" },
        { &efi_nii_protocol_guid,
          "Nii" },
        { &efi_nii31_protocol_guid,
@@ -94,6 +130,18 @@ static struct efi_well_known_guid efi_well_known_guids[] = {
          "SimpleNetwork" },
        { &efi_tcg_protocol_guid,
          "Tcg" },
+       { &efi_tcp4_protocol_guid,
+         "Tcp4" },
+       { &efi_tcp4_service_binding_protocol_guid,
+         "Tcp4Sb" },
+       { &efi_udp4_protocol_guid,
+         "Udp4" },
+       { &efi_udp4_service_binding_protocol_guid,
+         "Udp4Sb" },
+       { &efi_vlan_config_protocol_guid,
+         "VlanConfig" },
+       { &efi_vlan_config_dxe_guid,
+         "VlanConfigDxe" },
 };
 
 /**
index 458cbb297ac3c0d6803f1f7fed88d476aa97b696..52ba58ae4856a4cae0a4afc4cd9f9a5edadc23d2 100644 (file)
 FILE_LICENCE ( GPL2_OR_LATER );
 
 #include <ipxe/efi/efi.h>
+#include <ipxe/efi/Protocol/Arp.h>
 #include <ipxe/efi/Protocol/BlockIo.h>
 #include <ipxe/efi/Protocol/BusSpecificDriverOverride.h>
 #include <ipxe/efi/Protocol/ComponentName.h>
 #include <ipxe/efi/Protocol/ComponentName2.h>
 #include <ipxe/efi/Protocol/DevicePath.h>
 #include <ipxe/efi/Protocol/DevicePathToText.h>
+#include <ipxe/efi/Protocol/Dhcp4.h>
 #include <ipxe/efi/Protocol/DiskIo.h>
 #include <ipxe/efi/Protocol/DriverBinding.h>
 #include <ipxe/efi/Protocol/GraphicsOutput.h>
 #include <ipxe/efi/Protocol/HiiConfigAccess.h>
+#include <ipxe/efi/Protocol/Ip4.h>
+#include <ipxe/efi/Protocol/Ip4Config.h>
 #include <ipxe/efi/Protocol/LoadFile.h>
 #include <ipxe/efi/Protocol/LoadFile2.h>
 #include <ipxe/efi/Protocol/LoadedImage.h>
+#include <ipxe/efi/Protocol/ManagedNetwork.h>
+#include <ipxe/efi/Protocol/Mtftp4.h>
 #include <ipxe/efi/Protocol/NetworkInterfaceIdentifier.h>
 #include <ipxe/efi/Protocol/PciIo.h>
 #include <ipxe/efi/Protocol/PciRootBridgeIo.h>
@@ -40,6 +46,9 @@ FILE_LICENCE ( GPL2_OR_LATER );
 #include <ipxe/efi/Protocol/SimpleFileSystem.h>
 #include <ipxe/efi/Protocol/SimpleNetwork.h>
 #include <ipxe/efi/Protocol/TcgService.h>
+#include <ipxe/efi/Protocol/Tcp4.h>
+#include <ipxe/efi/Protocol/Udp4.h>
+#include <ipxe/efi/Protocol/VlanConfig.h>
 
 /** @file
  *
@@ -47,6 +56,14 @@ FILE_LICENCE ( GPL2_OR_LATER );
  *
  */
 
+/** ARP protocol GUID */
+EFI_GUID efi_arp_protocol_guid
+       = EFI_ARP_PROTOCOL_GUID;
+
+/** ARP service binding protocol GUID */
+EFI_GUID efi_arp_service_binding_protocol_guid
+       = EFI_ARP_SERVICE_BINDING_PROTOCOL_GUID;
+
 /** Block I/O protocol GUID */
 EFI_GUID efi_block_io_protocol_guid
        = EFI_BLOCK_IO_PROTOCOL_GUID;
@@ -67,6 +84,14 @@ EFI_GUID efi_component_name2_protocol_guid
 EFI_GUID efi_device_path_protocol_guid
        = EFI_DEVICE_PATH_PROTOCOL_GUID;
 
+/** DHCPv4 protocol GUID */
+EFI_GUID efi_dhcp4_protocol_guid
+       = EFI_DHCP4_PROTOCOL_GUID;
+
+/** DHCPv4 service binding protocol GUID */
+EFI_GUID efi_dhcp4_service_binding_protocol_guid
+       = EFI_DHCP4_SERVICE_BINDING_PROTOCOL_GUID;
+
 /** Disk I/O protocol GUID */
 EFI_GUID efi_disk_io_protocol_guid
        = EFI_DISK_IO_PROTOCOL_GUID;
@@ -83,6 +108,18 @@ EFI_GUID efi_graphics_output_protocol_guid
 EFI_GUID efi_hii_config_access_protocol_guid
        = EFI_HII_CONFIG_ACCESS_PROTOCOL_GUID;
 
+/** IPv4 protocol GUID */
+EFI_GUID efi_ip4_protocol_guid
+       = EFI_IP4_PROTOCOL_GUID;
+
+/** IPv4 configuration protocol GUID */
+EFI_GUID efi_ip4_config_protocol_guid
+       = EFI_IP4_CONFIG_PROTOCOL_GUID;
+
+/** IPv4 service binding protocol GUID */
+EFI_GUID efi_ip4_service_binding_protocol_guid
+       = EFI_IP4_SERVICE_BINDING_PROTOCOL_GUID;
+
 /** Load file protocol GUID */
 EFI_GUID efi_load_file_protocol_guid
        = EFI_LOAD_FILE_PROTOCOL_GUID;
@@ -99,6 +136,22 @@ EFI_GUID efi_loaded_image_protocol_guid
 EFI_GUID efi_loaded_image_device_path_protocol_guid
        = EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL_GUID;
 
+/** Managed network protocol GUID */
+EFI_GUID efi_managed_network_protocol_guid
+       = EFI_MANAGED_NETWORK_PROTOCOL_GUID;
+
+/** Managed network service binding protocol GUID */
+EFI_GUID efi_managed_network_service_binding_protocol_guid
+       = EFI_MANAGED_NETWORK_SERVICE_BINDING_PROTOCOL_GUID;
+
+/** MTFTPv4 protocol GUID */
+EFI_GUID efi_mtftp4_protocol_guid
+       = EFI_MTFTP4_PROTOCOL_GUID;
+
+/** MTFTPv4 service binding protocol GUID */
+EFI_GUID efi_mtftp4_service_binding_protocol_guid
+       = EFI_MTFTP4_SERVICE_BINDING_PROTOCOL_GUID;
+
 /** Network interface identifier protocol GUID (old version) */
 EFI_GUID efi_nii_protocol_guid
        = EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_GUID;
@@ -130,3 +183,23 @@ EFI_GUID efi_simple_network_protocol_guid
 /** TCG protocol GUID */
 EFI_GUID efi_tcg_protocol_guid
        = EFI_TCG_PROTOCOL_GUID;
+
+/** TCPv4 protocol GUID */
+EFI_GUID efi_tcp4_protocol_guid
+       = EFI_TCP4_PROTOCOL_GUID;
+
+/** TCPv4 service binding protocol GUID */
+EFI_GUID efi_tcp4_service_binding_protocol_guid
+       = EFI_TCP4_SERVICE_BINDING_PROTOCOL_GUID;
+
+/** UDPv4 protocol GUID */
+EFI_GUID efi_udp4_protocol_guid
+       = EFI_UDP4_PROTOCOL_GUID;
+
+/** UDPv4 service binding protocol GUID */
+EFI_GUID efi_udp4_service_binding_protocol_guid
+       = EFI_UDP4_SERVICE_BINDING_PROTOCOL_GUID;
+
+/** VLAN configuration protocol GUID */
+EFI_GUID efi_vlan_config_protocol_guid
+       = EFI_VLAN_CONFIG_PROTOCOL_GUID;