]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.h
1. update timeout interval time from 10ms to 50ms
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Udp4Dxe / Udp4Impl.h
index 7825624090272ffd72c0efdc9a4773a7d767b6a5..0823b6995c67a5ca888000f044d7a774537cc919 100644 (file)
-/** @file
-
-Copyright (c) 2006 - 2007, Intel Corporation
-All rights reserved. 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.
-
-Module Name:
-
-  Udp4Impl.h
-
-Abstract:
-
-  EFI UDPv4 protocol implementation
-
-
-**/
-
-#ifndef _UDP4_IMPL_H_
-#define _UDP4_IMPL_H_
-
-#include <PiDxe.h>\r
-\r
-#include <Protocol/IP4.h>\r
+/** @file\r
+  EFI UDPv4 protocol implementation.\r
+   \r
+Copyright (c) 2006 - 2009, Intel Corporation.<BR>\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef _UDP4_IMPL_H_\r
+#define _UDP4_IMPL_H_\r
+\r
+#include <Uefi.h>\r
+\r
+#include <Protocol/Ip4.h>\r
 #include <Protocol/Udp4.h>\r
-
+\r
 #include <Library/IpIoLib.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/UefiRuntimeServicesTableLib.h>\r
 #include <Library/UefiDriverEntryPoint.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/BaseLib.h>\r
-#include <Library/UefiLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/MemoryAllocationLib.h>
-
-#include "Udp4Driver.h"
-
-
-extern EFI_COMPONENT_NAME_PROTOCOL    gUdp4ComponentName;
-extern EFI_SERVICE_BINDING_PROTOCOL   mUdp4ServiceBinding;
-extern EFI_UDP4_PROTOCOL              mUdp4Protocol;
-extern UINT16                         mUdp4RandomPort;
-
-#define ICMP_ERROR_PACKET_LENGTH  8
-
-#define UDP4_TIMEOUT_INTERVAL (50 * TICKS_PER_MS)  // 50 milliseconds
-
-#define UDP4_HEADER_SIZE      sizeof (EFI_UDP4_HEADER)
-#define UDP4_MAX_DATA_SIZE    65507
-
-#define UDP4_PORT_KNOWN       1024
-
-#define UDP4_SERVICE_DATA_SIGNATURE  EFI_SIGNATURE_32('U', 'd', 'p', '4')
-
-#define UDP4_SERVICE_DATA_FROM_THIS(a) \
-  CR ( \
-  (a), \
-  UDP4_SERVICE_DATA, \
-  ServiceBinding, \
-  UDP4_SERVICE_DATA_SIGNATURE \
-  )
-
-typedef struct _UDP4_SERVICE_DATA_ {
-  UINT32                        Signature;
-  EFI_SERVICE_BINDING_PROTOCOL  ServiceBinding;
-  EFI_HANDLE                    ImageHandle;
-  EFI_HANDLE                    ControllerHandle;
-  NET_LIST_ENTRY                ChildrenList;
-  UINTN                         ChildrenNumber;
-  IP_IO                         *IpIo;
-
-  EFI_EVENT                     TimeoutEvent;
-
-  CHAR16                        *MacString;
-} UDP4_SERVICE_DATA;
-
-#define UDP4_INSTANCE_DATA_SIGNATURE  EFI_SIGNATURE_32('U', 'd', 'p', 'I')
-
-#define UDP4_INSTANCE_DATA_FROM_THIS(a) \
-  CR ( \
-  (a), \
-  UDP4_INSTANCE_DATA, \
-  Udp4Proto, \
-  UDP4_INSTANCE_DATA_SIGNATURE \
-  )
-
-typedef struct _UDP4_INSTANCE_DATA_ {
-  UINT32                Signature;
-  NET_LIST_ENTRY        Link;
-
-  UDP4_SERVICE_DATA     *Udp4Service;
-  EFI_UDP4_PROTOCOL     Udp4Proto;
-  EFI_UDP4_CONFIG_DATA  ConfigData;
-  EFI_HANDLE            ChildHandle;
-  BOOLEAN               Configured;
-  BOOLEAN               IsNoMapping;
-
-  NET_MAP               TxTokens;
-  NET_MAP               RxTokens;
-
-  NET_MAP               McastIps;
-
-  NET_LIST_ENTRY        RcvdDgramQue;
-  NET_LIST_ENTRY        DeliveredDgramQue;
-
-  UINT16                HeadSum;
-
-  EFI_STATUS            IcmpError;
-
-  IP_IO_IP_INFO         *IpInfo;
-
-  BOOLEAN               Destroyed;
-} UDP4_INSTANCE_DATA;
-
-typedef struct _UDP4_RXDATA_WRAP_ {
-  NET_LIST_ENTRY         Link;
-  NET_BUF                *Packet;
-  UINT32                 TimeoutTick;
-  EFI_UDP4_RECEIVE_DATA  RxData;
-} UDP4_RXDATA_WRAP;
-
-EFI_STATUS
-EFIAPI
-Udp4GetModeData (
-  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
-  );
-
-EFI_STATUS
-EFIAPI
-Udp4Configure (
-  IN EFI_UDP4_PROTOCOL     *This,
-  IN EFI_UDP4_CONFIG_DATA  *UdpConfigData OPTIONAL
-  );
-
-EFI_STATUS
-EFIAPI
-Udp4Groups (
-  IN EFI_UDP4_PROTOCOL  *This,
-  IN BOOLEAN            JoinFlag,
-  IN EFI_IPv4_ADDRESS   *MulticastAddress OPTIONAL
-  );
-
-EFI_STATUS
-EFIAPI
-Udp4Routes (
-  IN EFI_UDP4_PROTOCOL  *This,
-  IN BOOLEAN            DeleteRoute,
-  IN EFI_IPv4_ADDRESS   *SubnetAddress,
-  IN EFI_IPv4_ADDRESS   *SubnetMask,
-  IN EFI_IPv4_ADDRESS   *GatewayAddress
-  );
-
-EFI_STATUS
-EFIAPI
-Udp4Transmit (
-  IN EFI_UDP4_PROTOCOL          *This,
-  IN EFI_UDP4_COMPLETION_TOKEN  *Token
-  );
-
-EFI_STATUS
-EFIAPI
-Udp4Receive (
-  IN EFI_UDP4_PROTOCOL          *This,
-  IN EFI_UDP4_COMPLETION_TOKEN  *Token
-  );
-
-EFI_STATUS
-EFIAPI
-Udp4Cancel (
-  IN EFI_UDP4_PROTOCOL          *This,
-  IN EFI_UDP4_COMPLETION_TOKEN  *Token OPTIONAL
-  );
-
-EFI_STATUS
-EFIAPI
-Udp4Poll (
-  IN EFI_UDP4_PROTOCOL  *This
-  );
-
-EFI_STATUS
-Udp4CreateService (
-  IN UDP4_SERVICE_DATA  *Udp4Service,
-  IN EFI_HANDLE         ImageHandle,
-  IN EFI_HANDLE         ControllerHandle
-  );
-
-VOID
-Udp4CleanService (
-  IN UDP4_SERVICE_DATA  *Udp4Service
-  );
-
-VOID
-Udp4InitInstance (
-  IN UDP4_SERVICE_DATA   *Udp4Service,
-  IN UDP4_INSTANCE_DATA  *Instance
-  );
-
-VOID
-Udp4CleanInstance (
-  IN UDP4_INSTANCE_DATA  *Instance
-  );
-
-EFI_STATUS
-Udp4Bind (
-  IN NET_LIST_ENTRY        *InstanceList,
-  IN EFI_UDP4_CONFIG_DATA  *ConfigData
-  );
-
-BOOLEAN
-Udp4IsReconfigurable (
-  IN EFI_UDP4_CONFIG_DATA  *OldConfigData,
-  IN EFI_UDP4_CONFIG_DATA  *NewConfigData
-  );
-
-VOID
-Udp4BuildIp4ConfigData (
-  IN EFI_UDP4_CONFIG_DATA  *Udp4ConfigData,
-  IN EFI_IP4_CONFIG_DATA   *Ip4ConfigData
-  );
-
-EFI_STATUS
-Udp4ValidateTxToken (
-  IN UDP4_INSTANCE_DATA         *Instance,
-  IN EFI_UDP4_COMPLETION_TOKEN  *TxToken
-  );
-
-EFI_STATUS
-Udp4TokenExist (
-  IN NET_MAP       *Map,
-  IN NET_MAP_ITEM  *Item,
-  IN VOID          *Context
-  );
-
-UINT16
-Udp4Checksum (
-  IN NET_BUF *Packet,
-  IN UINT16  HeadSum
-  );
-
-EFI_STATUS
-Udp4RemoveToken (
-  IN NET_MAP                    *TokenMap,
-  IN EFI_UDP4_COMPLETION_TOKEN  *Token
-  );
-
-EFI_STATUS
-Udp4LeaveGroup (
-  IN NET_MAP       *Map,
-  IN NET_MAP_ITEM  *Item,
-  IN VOID          *Arg OPTIONAL
-  );
-
-VOID
-Udp4FlushRxData (
-  IN NET_LIST_ENTRY  *RcvdDgramQue
-  );
-
-EFI_STATUS
-Udp4InstanceCancelToken (
-  IN UDP4_INSTANCE_DATA         *Instance,
-  IN EFI_UDP4_COMPLETION_TOKEN  *Token OPTIONAL
-  );
-
-VOID
-Udp4InstanceDeliverDgram (
-  IN UDP4_INSTANCE_DATA  *Instance
-  );
-
-VOID
-Udp4ReportIcmpError (
-  IN UDP4_INSTANCE_DATA  *Instance
-  );
-
-VOID
-Udp4NetVectorExtFree (
-  VOID  *Context
-  );
-
-EFI_STATUS
-Udp4SetVariableData (
-  IN UDP4_SERVICE_DATA  *Udp4Service
-  );
-
-VOID
-Udp4ClearVariableData (
-  IN UDP4_SERVICE_DATA  *Udp4Service
-  );
-
-#endif
-
+#include <Library/UefiLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/TimerLib.h>\r
+#include <Library/DpcLib.h>\r
+\r
+#include "Udp4Driver.h"\r
+\r
+\r
+extern EFI_COMPONENT_NAME_PROTOCOL     gUdp4ComponentName;\r
+extern EFI_COMPONENT_NAME2_PROTOCOL    gUdp4ComponentName2;\r
+extern EFI_SERVICE_BINDING_PROTOCOL    mUdp4ServiceBinding;\r
+extern EFI_UDP4_PROTOCOL               mUdp4Protocol;\r
+extern UINT16                          mUdp4RandomPort;\r
+\r
+#define ICMP_ERROR_PACKET_LENGTH  8\r
+\r
+#define UDP4_TIMEOUT_INTERVAL (50 * TICKS_PER_MS)  // 50 milliseconds\r
+\r
+#define UDP4_HEADER_SIZE      sizeof (EFI_UDP4_HEADER)\r
+#define UDP4_MAX_DATA_SIZE    65507\r
+\r
+#define UDP4_PORT_KNOWN       1024\r
+\r
+#define UDP4_SERVICE_DATA_SIGNATURE  SIGNATURE_32('U', 'd', 'p', '4')\r
+\r
+#define UDP4_SERVICE_DATA_FROM_THIS(a) \\r
+  CR ( \\r
+  (a), \\r
+  UDP4_SERVICE_DATA, \\r
+  ServiceBinding, \\r
+  UDP4_SERVICE_DATA_SIGNATURE \\r
+  )\r
+\r
+typedef struct _UDP4_SERVICE_DATA_ {\r
+  UINT32                        Signature;\r
+  EFI_SERVICE_BINDING_PROTOCOL  ServiceBinding;\r
+  EFI_HANDLE                    ImageHandle;\r
+  EFI_HANDLE                    ControllerHandle;\r
+  LIST_ENTRY                    ChildrenList;\r
+  UINTN                         ChildrenNumber;\r
+  IP_IO                         *IpIo;\r
+\r
+  EFI_EVENT                     TimeoutEvent;\r
+\r
+  CHAR16                        *MacString;\r
+} UDP4_SERVICE_DATA;\r
+\r
+#define UDP4_INSTANCE_DATA_SIGNATURE  SIGNATURE_32('U', 'd', 'p', 'I')\r
+\r
+#define UDP4_INSTANCE_DATA_FROM_THIS(a) \\r
+  CR ( \\r
+  (a), \\r
+  UDP4_INSTANCE_DATA, \\r
+  Udp4Proto, \\r
+  UDP4_INSTANCE_DATA_SIGNATURE \\r
+  )\r
+\r
+typedef struct _UDP4_INSTANCE_DATA_ {\r
+  UINT32                Signature;\r
+  LIST_ENTRY            Link;\r
+\r
+  UDP4_SERVICE_DATA     *Udp4Service;\r
+  EFI_UDP4_PROTOCOL     Udp4Proto;\r
+  EFI_UDP4_CONFIG_DATA  ConfigData;\r
+  EFI_HANDLE            ChildHandle;\r
+  BOOLEAN               Configured;\r
+  BOOLEAN               IsNoMapping;\r
+\r
+  NET_MAP               TxTokens;\r
+  NET_MAP               RxTokens;\r
+\r
+  NET_MAP               McastIps;\r
+\r
+  LIST_ENTRY            RcvdDgramQue;\r
+  LIST_ENTRY            DeliveredDgramQue;\r
+\r
+  UINT16                HeadSum;\r
+\r
+  EFI_STATUS            IcmpError;\r
+\r
+  IP_IO_IP_INFO         *IpInfo;\r
+\r
+  BOOLEAN               Destroyed;\r
+} UDP4_INSTANCE_DATA;\r
+\r
+typedef struct _UDP4_RXDATA_WRAP_ {\r
+  LIST_ENTRY             Link;\r
+  NET_BUF                *Packet;\r
+  UINT32                 TimeoutTick;\r
+  EFI_UDP4_RECEIVE_DATA  RxData;\r
+} UDP4_RXDATA_WRAP;\r
+\r
+/**\r
+  Reads the current operational settings.\r
+\r
+  The GetModeData() function copies the current operational settings of this EFI\r
+  UDPv4 Protocol instance into user-supplied buffers. This function is used\r
+  optionally to retrieve the operational mode data of underlying networks or\r
+  drivers.\r
+\r
+  @param  This           Pointer to the EFI_UDP4_PROTOCOL instance.\r
+  @param  Udp4ConfigData Pointer to the buffer to receive the current configuration data.\r
+  @param  Ip4ModeData    Pointer to the EFI IPv4 Protocol mode data structure.\r
+  @param  MnpConfigData  Pointer to the managed network configuration data structure.\r
+  @param  SnpModeData    Pointer to the simple network mode data structure.\r
+\r
+  @retval EFI_SUCCESS           The mode data was read.\r
+  @retval EFI_NOT_STARTED       When Udp4ConfigData is queried, no configuration data is\r
+                                available because this instance has not been started.\r
+  @retval EFI_INVALID_PARAMETER This is NULL.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Udp4GetModeData (\r
+  IN  EFI_UDP4_PROTOCOL                *This,\r
+  OUT EFI_UDP4_CONFIG_DATA             *Udp4ConfigData OPTIONAL,\r
+  OUT EFI_IP4_MODE_DATA                *Ip4ModeData    OPTIONAL,\r
+  OUT EFI_MANAGED_NETWORK_CONFIG_DATA  *MnpConfigData  OPTIONAL,\r
+  OUT EFI_SIMPLE_NETWORK_MODE          *SnpModeData    OPTIONAL\r
+  );\r
+\r
+/**\r
+  Initializes, changes, or resets the operational parameters for this instance of the EFI UDPv4\r
+  Protocol.\r
+  \r
+  The Configure() function is used to do the following:\r
+  * Initialize and start this instance of the EFI UDPv4 Protocol.\r
+  * Change the filtering rules and operational parameters.\r
+  * Reset this instance of the EFI UDPv4 Protocol.\r
+  Until these parameters are initialized, no network traffic can be sent or\r
+  received by this instance. This instance can be also reset by calling Configure()\r
+  with UdpConfigData set to NULL. Once reset, the receiving queue and transmitting\r
+  queue are flushed and no traffic is allowed through this instance.\r
+  With different parameters in UdpConfigData, Configure() can be used to bind\r
+  this instance to specified port.\r
+\r
+  @param[in]  This              Pointer to the EFI_UDP4_PROTOCOL instance.\r
+  @param[in]  UdpConfigData     Pointer to the buffer to receive the current configuration data.\r
+\r
+  @retval EFI_SUCCESS           The configuration settings were set, changed, or reset successfully.\r
+  @retval EFI_NO_MAPPING        When using a default address, configuration (DHCP, BOOTP,\r
+                                RARP, etc.) is not finished yet.\r
+  @retval EFI_INVALID_PARAMETER One or more following conditions are TRUE:\r
+  @retval EFI_ALREADY_STARTED   The EFI UDPv4 Protocol instance is already started/configured\r
+                                and must be stopped/reset before it can be reconfigured.\r
+  @retval EFI_ACCESS_DENIED     UdpConfigData. AllowDuplicatePort is FALSE\r
+                                and UdpConfigData.StationPort is already used by\r
+                                other instance.\r
+  @retval EFI_OUT_OF_RESOURCES  The EFI UDPv4 Protocol driver cannot allocate memory for this\r
+                                EFI UDPv4 Protocol instance.\r
+  @retval EFI_DEVICE_ERROR      An unexpected network or system error occurred and this instance\r
+                                 was not opened. \r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Udp4Configure (\r
+  IN EFI_UDP4_PROTOCOL     *This,\r
+  IN EFI_UDP4_CONFIG_DATA  *UdpConfigData OPTIONAL\r
+  );\r
+\r
+/**\r
+  Joins and leaves multicast groups.\r
+  \r
+  The Groups() function is used to enable and disable the multicast group\r
+  filtering. If the JoinFlag is FALSE and the MulticastAddress is NULL, then all\r
+  currently joined groups are left.\r
+\r
+  @param[in]  This              Pointer to the EFI_UDP4_PROTOCOL instance.\r
+  @param[in]  JoinFlag          Set to TRUE to join a multicast group. Set to FALSE to leave one\r
+                                or all multicast groups.\r
+  @param[in]  MulticastAddress  Pointer to multicast group address to join or leave.\r
+\r
+  @retval EFI_SUCCESS           The operation completed successfully.\r
+  @retval EFI_NOT_STARTED       The EFI UDPv4 Protocol instance has not been started.\r
+  @retval EFI_NO_MAPPING        When using a default address, configuration (DHCP, BOOTP,\r
+                                RARP, etc.) is not finished yet.\r
+  @retval EFI_OUT_OF_RESOURCES  Could not allocate resources to join the group.\r
+  @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
+                                - This is NULL.\r
+                                - JoinFlag is TRUE and MulticastAddress is NULL.\r
+                                - JoinFlag is TRUE and *MulticastAddress is not\r
+                                  a valid multicast address.\r
+  @retval EFI_ALREADY_STARTED   The group address is already in the group table (when\r
+                                JoinFlag is TRUE).\r
+  @retval EFI_NOT_FOUND         The group address is not in the group table (when JoinFlag is\r
+                                FALSE).\r
+  @retval EFI_DEVICE_ERROR      An unexpected system or network error occurred.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Udp4Groups (\r
+  IN EFI_UDP4_PROTOCOL  *This,\r
+  IN BOOLEAN            JoinFlag,\r
+  IN EFI_IPv4_ADDRESS   *MulticastAddress OPTIONAL\r
+  );\r
+\r
+/**\r
+  Adds and deletes routing table entries.\r
+  \r
+  The Routes() function adds a route to or deletes a route from the routing table.\r
+  Routes are determined by comparing the SubnetAddress with the destination IP\r
+  address and arithmetically AND-ing it with the SubnetMask. The gateway address\r
+  must be on the same subnet as the configured station address.\r
+  The default route is added with SubnetAddress and SubnetMask both set to 0.0.0.0.\r
+  The default route matches all destination IP addresses that do not match any\r
+  other routes.\r
+  A zero GatewayAddress is a nonroute. Packets are sent to the destination IP\r
+  address if it can be found in the Address Resolution Protocol (ARP) cache or\r
+  on the local subnet. One automatic nonroute entry will be inserted into the\r
+  routing table for outgoing packets that are addressed to a local subnet\r
+  (gateway address of 0.0.0.0).\r
+  Each instance of the EFI UDPv4 Protocol has its own independent routing table.\r
+  Instances of the EFI UDPv4 Protocol that use the default IP address will also\r
+  have copies of the routing table provided by the EFI_IP4_CONFIG_PROTOCOL. These\r
+  copies will be updated automatically whenever the IP driver reconfigures its\r
+  instances; as a result, the previous modification to these copies will be lost.\r
+\r
+  @param[in]  This              Pointer to the EFI_UDP4_PROTOCOL instance.\r
+  @param[in]  DeleteRoute       Set to TRUE to delete this route from the routing table.\r
+                                Set to FALSE to add this route to the routing table.\r
+  @param[in]  SubnetAddress     The destination network address that needs to be routed.\r
+  @param[in]  SubnetMask        The subnet mask of SubnetAddress.\r
+  @param[in]  GatewayAddress    The gateway IP address for this route.\r
+\r
+  @retval EFI_SUCCESS           The operation completed successfully.\r
+  @retval EFI_NOT_STARTED       The EFI UDPv4 Protocol instance has not been started.\r
+  @retval EFI_NO_MAPPING        When using a default address, configuration (DHCP, BOOTP,\r
+                                - RARP, etc.) is not finished yet.\r
+  @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
+  @retval EFI_OUT_OF_RESOURCES  Could not add the entry to the routing table.\r
+  @retval EFI_NOT_FOUND         This route is not in the routing table.\r
+  @retval EFI_ACCESS_DENIED     The route is already defined in the routing table.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Udp4Routes (\r
+  IN EFI_UDP4_PROTOCOL  *This,\r
+  IN BOOLEAN            DeleteRoute,\r
+  IN EFI_IPv4_ADDRESS   *SubnetAddress,\r
+  IN EFI_IPv4_ADDRESS   *SubnetMask,\r
+  IN EFI_IPv4_ADDRESS   *GatewayAddress\r
+  );\r
+\r
+/**\r
+  Queues outgoing data packets into the transmit queue.\r
+  \r
+  The Transmit() function places a sending request to this instance of the EFI\r
+  UDPv4 Protocol, alongside the transmit data that was filled by the user. Whenever\r
+  the packet in the token is sent out or some errors occur, the Token.Event will\r
+  be signaled and Token.Status is updated. Providing a proper notification function\r
+  and context for the event will enable the user to receive the notification and\r
+  transmitting status.\r
+\r
+  @param[in]  This              Pointer to the EFI_UDP4_PROTOCOL instance.\r
+  @param[in]  Token             Pointer to the completion token that will be placed into the\r
+                                transmit queue.\r
+\r
+  @retval EFI_SUCCESS           The data has been queued for transmission.\r
+  @retval EFI_NOT_STARTED       This EFI UDPv4 Protocol instance has not been started.\r
+  @retval EFI_NO_MAPPING        When using a default address, configuration (DHCP, BOOTP,\r
+                                RARP, etc.) is not finished yet.\r
+  @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
+  @retval EFI_ACCESS_DENIED     The transmit completion token with the same\r
+                                Token.Event was already in the transmit queue.\r
+  @retval EFI_NOT_READY         The completion token could not be queued because the\r
+                                transmit queue is full.\r
+  @retval EFI_OUT_OF_RESOURCES  Could not queue the transmit data.\r
+  @retval EFI_NOT_FOUND         There is no route to the destination network or address.\r
+  @retval EFI_BAD_BUFFER_SIZE   The data length is greater than the maximum UDP packet\r
+                                size. Or the length of the IP header + UDP header + data\r
+                                length is greater than MTU if DoNotFragment is TRUE.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Udp4Transmit (\r
+  IN EFI_UDP4_PROTOCOL          *This,\r
+  IN EFI_UDP4_COMPLETION_TOKEN  *Token\r
+  );\r
+\r
+/**\r
+  Places an asynchronous receive request into the receiving queue.\r
+  \r
+  The Receive() function places a completion token into the receive packet queue.\r
+  This function is always asynchronous.\r
+  The caller must fill in the Token.Event field in the completion token, and this\r
+  field cannot be NULL. When the receive operation completes, the EFI UDPv4 Protocol\r
+  driver updates the Token.Status and Token.Packet.RxData fields and the Token.Event\r
+  is signaled. Providing a proper notification function and context for the event\r
+  will enable the user to receive the notification and receiving status. That\r
+  notification function is guaranteed to not be re-entered.\r
+\r
+  @param[in]  This              Pointer to the EFI_UDP4_PROTOCOL instance.\r
+  @param[in]  Token             Pointer to a token that is associated with\r
+                                the receive data descriptor.\r
+\r
+  @retval EFI_SUCCESS           The receive completion token was cached.\r
+  @retval EFI_NOT_STARTED       This EFI UDPv4 Protocol instance has not been started.\r
+  @retval EFI_NO_MAPPING        When using a default address, configuration (DHCP, BOOTP, RARP, etc.)\r
+                                is not finished yet.\r
+  @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
+  @retval EFI_OUT_OF_RESOURCES  The receive completion token could not be queued due to a lack of system\r
+                                resources (usually memory).\r
+  @retval EFI_DEVICE_ERROR      An unexpected system or network error occurred.\r
+  @retval EFI_ACCESS_DENIED     A receive completion token with the same Token.Event was already in\r
+                                the receive queue.\r
+  @retval EFI_NOT_READY         The receive request could not be queued because the receive queue is full.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Udp4Receive (\r
+  IN EFI_UDP4_PROTOCOL          *This,\r
+  IN EFI_UDP4_COMPLETION_TOKEN  *Token\r
+  );\r
+\r
+/**\r
+  Aborts an asynchronous transmit or receive request.\r
+  \r
+  The Cancel() function is used to abort a pending transmit or receive request.\r
+  If the token is in the transmit or receive request queues, after calling this\r
+  function, Token.Status will be set to EFI_ABORTED and then Token.Event will be\r
+  signaled. If the token is not in one of the queues, which usually means that\r
+  the asynchronous operation has completed, this function will not signal the\r
+  token and EFI_NOT_FOUND is returned.\r
+\r
+  @param[in]  This  Pointer to the EFI_UDP4_PROTOCOL instance.\r
+  @param[in]  Token Pointer to a token that has been issued by\r
+                    EFI_UDP4_PROTOCOL.Transmit() or\r
+                    EFI_UDP4_PROTOCOL.Receive().If NULL, all pending\r
+                    tokens are aborted.\r
+\r
+  @retval  EFI_SUCCESS           The asynchronous I/O request was aborted and Token.Event\r
+                                 was signaled. When Token is NULL, all pending requests are\r
+                                 aborted and their events are signaled.\r
+  @retval  EFI_INVALID_PARAMETER This is NULL.\r
+  @retval  EFI_NOT_STARTED       This instance has not been started.\r
+  @retval  EFI_NO_MAPPING        When using the default address, configuration (DHCP, BOOTP,\r
+                                 RARP, etc.) is not finished yet.\r
+  @retval  EFI_NOT_FOUND         When Token is not NULL, the asynchronous I/O request was\r
+                                 not found in the transmit or receive queue. It has either completed\r
+                                 or was not issued by Transmit() and Receive().\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Udp4Cancel (\r
+  IN EFI_UDP4_PROTOCOL          *This,\r
+  IN EFI_UDP4_COMPLETION_TOKEN  *Token OPTIONAL\r
+  );\r
+\r
+/**\r
+  Polls for incoming data packets and processes outgoing data packets.\r
+  \r
+  The Poll() function can be used by network drivers and applications to increase\r
+  the rate that data packets are moved between the communications device and the\r
+  transmit and receive queues.\r
+  In some systems, the periodic timer event in the managed network driver may not\r
+  poll the underlying communications device fast enough to transmit and/or receive\r
+  all data packets without missing incoming packets or dropping outgoing packets.\r
+  Drivers and applications that are experiencing packet loss should try calling\r
+  the Poll() function more often.\r
+\r
+  @param[in]  This  Pointer to the EFI_UDP4_PROTOCOL instance.\r
+\r
+  @retval EFI_SUCCESS           Incoming or outgoing data was processed.\r
+  @retval EFI_INVALID_PARAMETER This is NULL.\r
+  @retval EFI_DEVICE_ERROR      An unexpected system or network error occurred.\r
+  @retval EFI_TIMEOUT           Data was dropped out of the transmit and/or receive queue.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Udp4Poll (\r
+  IN EFI_UDP4_PROTOCOL  *This\r
+  );\r
+\r
+/**\r
+  Create the Udp service context data.\r
+\r
+  @param  Udp4Service            Pointer to the UDP4_SERVICE_DATA.\r
+  @param  ImageHandle            The image handle of this udp4 driver.\r
+  @param  ControllerHandle       The controller handle this udp4 driver binds on.\r
+\r
+  @retval EFI_SUCCESS            The udp4 service context data is created and\r
+                                 initialized.\r
+  @retval EFI_OUT_OF_RESOURCES   Cannot allocate memory.\r
+  @retval other                  Other error occurs.\r
+\r
+**/\r
+EFI_STATUS\r
+Udp4CreateService (\r
+  IN OUT UDP4_SERVICE_DATA  *Udp4Service,\r
+  IN     EFI_HANDLE         ImageHandle,\r
+  IN     EFI_HANDLE         ControllerHandle\r
+  );\r
+\r
+/**\r
+  Clean the Udp service context data.\r
+\r
+  @param[in]  Udp4Service            Pointer to the UDP4_SERVICE_DATA.\r
+\r
+**/\r
+VOID\r
+Udp4CleanService (\r
+  IN UDP4_SERVICE_DATA  *Udp4Service\r
+  );\r
+\r
+/**\r
+  This function intializes the new created udp instance.\r
+\r
+  @param  Udp4Service            Pointer to the UDP4_SERVICE_DATA.\r
+  @param  Instance               Pointer to the un-initialized UDP4_INSTANCE_DATA.\r
+\r
+**/\r
+VOID\r
+Udp4InitInstance (\r
+  IN     UDP4_SERVICE_DATA   *Udp4Service,\r
+  IN OUT UDP4_INSTANCE_DATA  *Instance\r
+  );\r
+\r
+/**\r
+  This function cleans the udp instance.\r
+\r
+  @param[in]  Instance               Pointer to the UDP4_INSTANCE_DATA to clean.\r
+\r
+**/\r
+VOID\r
+Udp4CleanInstance (\r
+  IN UDP4_INSTANCE_DATA  *Instance\r
+  );\r
+\r
+/**\r
+  This function tries to bind the udp instance according to the configured port\r
+  allocation strategy.\r
+\r
+  @param  InstanceList           Pointer to the head of the list linking the udp\r
+                                 instances.\r
+  @param  ConfigData             Pointer to the ConfigData of the instance to be\r
+                                 bound. ConfigData->StationPort will be assigned\r
+                                 with an available port value on success.\r
+\r
+  @retval EFI_SUCCESS            The bound operation is completed successfully.\r
+  @retval EFI_ACCESS_DENIED      The <Address, Port> specified by the ConfigData is\r
+                                 already used by other instance.\r
+  @retval EFI_OUT_OF_RESOURCES   No available port resources.\r
+\r
+**/\r
+EFI_STATUS\r
+Udp4Bind (\r
+  IN     LIST_ENTRY            *InstanceList,\r
+  IN OUT EFI_UDP4_CONFIG_DATA  *ConfigData\r
+  );\r
+\r
+/**\r
+  This function is used to check whether the NewConfigData has any un-reconfigurable\r
+  parameters changed compared to the OldConfigData.\r
+\r
+  @param[in]  OldConfigData      Pointer to the current ConfigData the udp instance\r
+                                 uses.\r
+  @param[in]  NewConfigData      Pointer to the new ConfigData.\r
+\r
+  @retval TRUE     The instance is reconfigurable.\r
+  @retval FALSE    Otherwise.\r
+\r
+**/\r
+BOOLEAN\r
+Udp4IsReconfigurable (\r
+  IN EFI_UDP4_CONFIG_DATA  *OldConfigData,\r
+  IN EFI_UDP4_CONFIG_DATA  *NewConfigData\r
+  );\r
+\r
+/**\r
+  This function builds the Ip4 configdata from the Udp4ConfigData.\r
+\r
+  @param[in]       Udp4ConfigData    Pointer to the EFI_UDP4_CONFIG_DATA.\r
+  @param[in, out]  Ip4ConfigData     Pointer to the EFI_IP4_CONFIG_DATA.\r
+\r
+**/\r
+VOID\r
+Udp4BuildIp4ConfigData (\r
+  IN     EFI_UDP4_CONFIG_DATA  *Udp4ConfigData,\r
+  IN OUT EFI_IP4_CONFIG_DATA   *Ip4ConfigData\r
+  );\r
+\r
+/**\r
+  This function validates the TxToken, it returns the error code according to the spec.\r
+\r
+  @param[in]  Instance           Pointer to the udp instance context data.\r
+  @param[in]  TxToken            Pointer to the token to be checked.\r
+\r
+  @retval EFI_SUCCESS            The TxToken is valid.\r
+  @retval EFI_INVALID_PARAMETER  One or more of the following are TRUE: This is\r
+                                 NULL. Token is NULL. Token.Event is NULL.\r
+                                 Token.Packet.TxData is NULL.\r
+                                 Token.Packet.TxData.FragmentCount is zero.\r
+                                 Token.Packet.TxData.DataLength is not equal to the\r
+                                 sum of fragment lengths. One or more of the\r
+                                 Token.Packet.TxData.FragmentTable[].\r
+                                 FragmentLength fields is zero. One or more of the\r
+                                 Token.Packet.TxData.FragmentTable[].\r
+                                 FragmentBuffer fields is NULL.\r
+                                 Token.Packet.TxData. GatewayAddress is not a\r
+                                 unicast IPv4 address if it is not NULL. One or\r
+                                 more IPv4 addresses in Token.Packet.TxData.\r
+                                 UdpSessionData are not valid unicast IPv4\r
+                                 addresses if the UdpSessionData is not NULL.\r
+  @retval EFI_BAD_BUFFER_SIZE    The data length is greater than the maximum UDP\r
+                                 packet size.\r
+\r
+**/\r
+EFI_STATUS\r
+Udp4ValidateTxToken (\r
+  IN UDP4_INSTANCE_DATA         *Instance,\r
+  IN EFI_UDP4_COMPLETION_TOKEN  *TxToken\r
+  );\r
+\r
+/**\r
+  This function checks whether the specified Token duplicates with the one in the Map.\r
+\r
+  @param[in]  Map                Pointer to the NET_MAP.\r
+  @param[in]  Item               Pointer to the NET_MAP_ITEM contain the pointer to\r
+                                 the Token.\r
+  @param[in]  Context            Pointer to the Token to be checked.\r
+\r
+  @retval EFI_SUCCESS            The Token specified by Context differs from the\r
+                                 one in the Item.\r
+  @retval EFI_ACCESS_DENIED      The Token duplicates with the one in the Item.\r
+\r
+**/\r
+EFI_STATUS\r
+Udp4TokenExist (\r
+  IN NET_MAP       *Map,\r
+  IN NET_MAP_ITEM  *Item,\r
+  IN VOID          *Context\r
+  );\r
+\r
+/**\r
+  This function calculates the checksum for the Packet, utilizing the pre-calculated\r
+  pseudo HeadSum to reduce some overhead.\r
+\r
+  @param[in]  Packet             Pointer to the NET_BUF contains the udp datagram.\r
+  @param[in]  HeadSum            Checksum of the pseudo header execpt the length\r
+                                 field.\r
+\r
+  @retval The 16-bit checksum of this udp datagram.\r
+\r
+**/\r
+UINT16\r
+Udp4Checksum (\r
+  IN NET_BUF *Packet,\r
+  IN UINT16  HeadSum\r
+  );\r
+\r
+/**\r
+  This function removes the specified Token from the TokenMap.\r
+\r
+  @param  TokenMap           Pointer to the NET_MAP containing the tokens.\r
+  @param  Token              Pointer to the Token to be removed.\r
+\r
+  @retval EFI_SUCCESS            The specified Token is removed from the TokenMap.\r
+  @retval EFI_NOT_FOUND          The specified Token is not found in the TokenMap.\r
+\r
+**/\r
+EFI_STATUS\r
+Udp4RemoveToken (\r
+  IN OUT NET_MAP                    *TokenMap,\r
+  IN     EFI_UDP4_COMPLETION_TOKEN  *Token\r
+  );\r
+\r
+/**\r
+  This function removes the multicast group specified by Arg from the Map.\r
+\r
+  @param  Map                    Pointer to the NET_MAP.\r
+  @param  Item                   Pointer to the NET_MAP_ITEM.\r
+  @param  Arg                    Pointer to the Arg, it's the pointer to a\r
+                                 multicast IPv4 Address.\r
+\r
+  @retval EFI_SUCCESS            The multicast address is removed.\r
+  @retval EFI_ABORTED            The specified multicast address is removed and the\r
+                                 Arg is not NULL.\r
+\r
+**/\r
+EFI_STATUS\r
+Udp4LeaveGroup (\r
+  IN OUT NET_MAP       *Map,\r
+  IN     NET_MAP_ITEM  *Item,\r
+  IN     VOID          *Arg OPTIONAL\r
+  );\r
+\r
+/**\r
+  This function removes all the Wrap datas in the RcvdDgramQue.\r
+\r
+  @param[in]  Instance           Pointer to the udp instance context data.\r
+\r
+**/\r
+VOID\r
+Udp4FlushRcvdDgram (\r
+  IN UDP4_INSTANCE_DATA  *Instance\r
+  );\r
+\r
+/**\r
+  Cancel Udp4 tokens from the Udp4 instance.\r
+\r
+  @param[in]  Instance           Pointer to the udp instance context data.\r
+  @param[in]  Token              Pointer to the token to be canceled, if NULL, all\r
+                                 tokens in this instance will be cancelled.\r
+\r
+  @retval EFI_SUCCESS            The Token is cancelled.\r
+  @retval EFI_NOT_FOUND          The Token is not found.\r
+\r
+**/\r
+EFI_STATUS\r
+Udp4InstanceCancelToken (\r
+  IN UDP4_INSTANCE_DATA         *Instance,\r
+  IN EFI_UDP4_COMPLETION_TOKEN  *Token OPTIONAL\r
+  );\r
+\r
+/**\r
+  This function delivers the received datagrams for the specified instance.\r
+\r
+  @param[in]  Instance               Pointer to the instance context data.\r
+\r
+**/\r
+VOID\r
+Udp4InstanceDeliverDgram (\r
+  IN UDP4_INSTANCE_DATA  *Instance\r
+  );\r
+\r
+/**\r
+  This function reports the received ICMP error.\r
+\r
+  @param[in]  Instance               Pointer to the udp instance context data.\r
+\r
+**/\r
+VOID\r
+Udp4ReportIcmpError (\r
+  IN UDP4_INSTANCE_DATA  *Instance\r
+  );\r
+\r
+/**\r
+  This function is a dummy ext-free function for the NET_BUF created for the output\r
+  udp datagram.\r
+\r
+  @param[in]  Context                Pointer to the context data.\r
+\r
+**/\r
+VOID\r
+Udp4NetVectorExtFree (\r
+  VOID  *Context\r
+  );\r
+\r
+/**\r
+  Set the Udp4 variable data.\r
+\r
+  @param  Udp4Service            Udp4 service data.\r
+\r
+  @retval EFI_OUT_OF_RESOURCES   There are not enough resources to set the\r
+                                 variable.\r
+  @retval EFI_SUCCESS            Set variable successfully.\r
+  @retval other                  Set variable failed.\r
+\r
+**/\r
+EFI_STATUS\r
+Udp4SetVariableData (\r
+  IN UDP4_SERVICE_DATA  *Udp4Service\r
+  );\r
+\r
+/**\r
+  Clear the variable and free the resource.\r
+\r
+  @param[[in]  Udp4Service            Udp4 service data.\r
+\r
+**/\r
+VOID\r
+Udp4ClearVariableData (\r
+  IN UDP4_SERVICE_DATA  *Udp4Service\r
+  );\r
+\r
+#endif\r
+\r