--- /dev/null
+/** @file\r
+ Udp6 driver's whole implementation and internal data structures.\r
+\r
+ Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
+\r
+ 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 _UDP6_IMPL_H_\r
+#define _UDP6_IMPL_H_\r
+\r
+#include <Uefi.h>\r
+\r
+#include <Protocol/Ip6.h>\r
+#include <Protocol/Udp6.h>\r
+\r
+#include <Library/IpIoLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/UefiRuntimeServicesTableLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/DpcLib.h>\r
+\r
+#include "Udp6Driver.h"\r
+\r
+extern EFI_COMPONENT_NAME2_PROTOCOL gUdp6ComponentName2;\r
+extern EFI_COMPONENT_NAME_PROTOCOL gUdp6ComponentName;\r
+extern EFI_SERVICE_BINDING_PROTOCOL mUdp6ServiceBinding;\r
+extern EFI_UDP6_PROTOCOL mUdp6Protocol;\r
+extern UINT16 mUdp6RandomPort;\r
+\r
+//\r
+// Define time out 50 milliseconds\r
+//\r
+#define UDP6_TIMEOUT_INTERVAL (50 * TICKS_PER_MS)\r
+#define UDP6_HEADER_SIZE sizeof (EFI_UDP_HEADER)\r
+#define UDP6_MAX_DATA_SIZE 65507\r
+#define UDP6_PORT_KNOWN 1024\r
+\r
+#define UDP6_SERVICE_DATA_SIGNATURE SIGNATURE_32 ('U', 'd', 'p', '6')\r
+#define UDP6_INSTANCE_DATA_SIGNATURE SIGNATURE_32 ('U', 'd', 'p', 'S')\r
+\r
+#define UDP6_SERVICE_DATA_FROM_THIS(a) \\r
+ CR ( \\r
+ (a), \\r
+ UDP6_SERVICE_DATA, \\r
+ ServiceBinding, \\r
+ UDP6_SERVICE_DATA_SIGNATURE \\r
+ )\r
+\r
+#define UDP6_INSTANCE_DATA_FROM_THIS(a) \\r
+ CR ( \\r
+ (a), \\r
+ UDP6_INSTANCE_DATA, \\r
+ Udp6Proto, \\r
+ UDP6_INSTANCE_DATA_SIGNATURE \\r
+ )\r
+//\r
+// Udp6 service contest data\r
+//\r
+typedef struct _UDP6_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
+ EFI_EVENT TimeoutEvent;\r
+ CHAR16 *MacString;\r
+} UDP6_SERVICE_DATA;\r
+\r
+typedef struct _UDP6_INSTANCE_DATA {\r
+ UINT32 Signature;\r
+ LIST_ENTRY Link;\r
+ UDP6_SERVICE_DATA *Udp6Service;\r
+ EFI_UDP6_PROTOCOL Udp6Proto;\r
+ EFI_UDP6_CONFIG_DATA ConfigData;\r
+ EFI_HANDLE ChildHandle;\r
+ BOOLEAN Configured;\r
+ BOOLEAN IsNoMapping;\r
+ NET_MAP TxTokens;\r
+ NET_MAP RxTokens;\r
+ NET_MAP McastIps;\r
+ LIST_ENTRY RcvdDgramQue;\r
+ LIST_ENTRY DeliveredDgramQue;\r
+ UINT16 HeadSum;\r
+ EFI_STATUS IcmpError;\r
+ IP_IO_IP_INFO *IpInfo;\r
+ BOOLEAN Destroyed;\r
+} UDP6_INSTANCE_DATA;\r
+\r
+typedef struct _UDP6_RXDATA_WRAP {\r
+ LIST_ENTRY Link;\r
+ NET_BUF *Packet;\r
+ UINT32 TimeoutTick;\r
+ EFI_UDP6_RECEIVE_DATA RxData;\r
+} UDP6_RXDATA_WRAP;\r
+\r
+/**\r
+ Clean the Udp service context data.\r
+\r
+ @param[in, out] Udp6Service Pointer to the UDP6_SERVICE_DATA.\r
+\r
+**/\r
+VOID\r
+Udp6CleanService (\r
+ IN OUT UDP6_SERVICE_DATA *Udp6Service\r
+ );\r
+\r
+/**\r
+ Create the Udp service context data.\r
+\r
+ @param[in] Udp6Service Pointer to the UDP6_SERVICE_DATA.\r
+ @param[in] ImageHandle The image handle of this udp6 driver.\r
+ @param[in] ControllerHandle The controller handle this udp6 driver binds on.\r
+\r
+ @retval EFI_SUCCESS The udp6 service context data was created and\r
+ initialized.\r
+ @retval EFI_OUT_OF_RESOURCES Cannot allocate memory.\r
+ @retval Others An error condition occurred.\r
+\r
+**/\r
+EFI_STATUS\r
+Udp6CreateService (\r
+ IN UDP6_SERVICE_DATA *Udp6Service,\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_HANDLE ControllerHandle\r
+ );\r
+\r
+/**\r
+ Set the Udp6 variable data.\r
+\r
+ @param[in] Udp6Service Udp6 service data.\r
+\r
+ @retval EFI_OUT_OF_RESOURCES There are not enough resources to set the\r
+ variable.\r
+ @retval other Set variable failed.\r
+\r
+**/\r
+EFI_STATUS\r
+Udp6SetVariableData (\r
+ IN UDP6_SERVICE_DATA *Udp6Service\r
+ );\r
+\r
+/**\r
+ This function cleans the udp instance.\r
+\r
+ @param[in, out] Instance Pointer to the UDP6_INSTANCE_DATA to clean.\r
+\r
+**/\r
+VOID\r
+Udp6CleanInstance (\r
+ IN OUT UDP6_INSTANCE_DATA *Instance\r
+ );\r
+\r
+/**\r
+ Clear the variable and free the resource.\r
+\r
+ @param[in, out] Udp6Service Udp6 service data.\r
+\r
+**/\r
+VOID\r
+Udp6ClearVariableData (\r
+ IN OUT UDP6_SERVICE_DATA *Udp6Service\r
+ );\r
+\r
+/**\r
+ This function intializes the new created udp instance.\r
+\r
+ @param[in] Udp6Service Pointer to the UDP6_SERVICE_DATA.\r
+ @param[in, out] Instance Pointer to the un-initialized UDP6_INSTANCE_DATA.\r
+\r
+**/\r
+VOID\r
+Udp6InitInstance (\r
+ IN UDP6_SERVICE_DATA *Udp6Service,\r
+ IN OUT UDP6_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
+Udp6ReportIcmpError (\r
+ IN UDP6_INSTANCE_DATA *Instance\r
+ );\r
+\r
+/**\r
+ This function copies the current operational settings of this EFI UDPv6 Protocol\r
+ instance into user-supplied buffers. This function is used optionally to retrieve\r
+ the operational mode data of underlying networks or drivers.\r
+\r
+ @param[in] This Pointer to the EFI_UDP6_PROTOCOL instance.\r
+ @param[out] Udp6ConfigData The buffer in which the current UDP configuration\r
+ data is returned. This parameter is optional and\r
+ may be NULL.\r
+ @param[out] Ip6ModeData The buffer in which the current EFI IPv6 Protocol\r
+ mode data is returned. This parameter is optional\r
+ and may be NULL.\r
+ @param[out] MnpConfigData The buffer in which the current managed network\r
+ configuration data is returned. This parameter\r
+ is optional and may be NULL.\r
+ @param[out] SnpModeData The buffer in which the simple network mode data\r
+ is returned. This parameter is optional and may be NULL.\r
+\r
+ @retval EFI_SUCCESS The mode data was read.\r
+ @retval EFI_NOT_STARTED When Udp6ConfigData is queried, no configuration\r
+ data is available because this instance has not\r
+ been started.\r
+ @retval EFI_INVALID_PARAMETER This is NULL.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Udp6GetModeData (\r
+ IN EFI_UDP6_PROTOCOL *This,\r
+ OUT EFI_UDP6_CONFIG_DATA *Udp6ConfigData OPTIONAL,\r
+ OUT EFI_IP6_MODE_DATA *Ip6ModeData OPTIONAL,\r
+ OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,\r
+ OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL\r
+ );\r
+\r
+/**\r
+ This function is used to do the following:\r
+ Initialize and start this instance of the EFI UDPv6 Protocol.\r
+ Change the filtering rules and operational parameters.\r
+ Reset this instance of the EFI UDPv6 Protocol.\r
+\r
+ @param[in] This Pointer to the EFI_UDP6_PROTOCOL instance.\r
+ @param[in] UdpConfigData Pointer to the buffer to set the configuration\r
+ data. This parameter is optional and may be NULL.\r
+\r
+ @retval EFI_SUCCESS The configuration settings were set, changed, or\r
+ reset successfully.\r
+ @retval EFI_NO_MAPPING When the UdpConifgData.UseAnyStationAddress is set\r
+ to true and there is no address available for IP6\r
+ driver to binding source address to this\r
+ instance.\r
+ @retval EFI_INVALID_PARAMETER One or more following conditions are TRUE:\r
+ This is NULL.\r
+ UdpConfigData.StationAddress is not a valid\r
+ unicast IPv6 address.\r
+ UdpConfigData.RemoteAddress is not a valid unicast\r
+ IPv6 address, if it is not zero.\r
+ @retval EFI_ALREADY_STARTED The EFI UDPv6 Protocol instance is already\r
+ started/configured and must be stopped/reset\r
+ before it can be reconfigured. Only TrafficClass,\r
+ HopLimit, ReceiveTimeout, and TransmitTimeout can\r
+ be reconfigured without stopping the current\r
+ instance of the EFI UDPv6 Protocol.\r
+ @retval EFI_ACCESS_DENIED UdpConfigData.AllowDuplicatePort is FALSE, and\r
+ UdpConfigData.StationPort is already used by another\r
+ instance.\r
+ @retval EFI_OUT_OF_RESOURCES The EFI UDPv6 Protocol driver cannot allocate\r
+ memory for this EFI UDPv6 Protocol instance.\r
+ @retval EFI_DEVICE_ERROR An unexpected network or system error occurred, and\r
+ this instance was not opened.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Udp6Configure (\r
+ IN EFI_UDP6_PROTOCOL *This,\r
+ IN EFI_UDP6_CONFIG_DATA *UdpConfigData OPTIONAL\r
+ );\r
+\r
+/**\r
+ This function places a sending request to this instance of the EFI UDPv6 Protocol,\r
+ alongside the transmit data that was filled by the user.\r
+\r
+ @param[in] This Pointer to the EFI_UDP6_PROTOCOL instance.\r
+ @param[in] Token Pointer to the completion token that will be\r
+ placed into the transmit queue.\r
+\r
+ @retval EFI_SUCCESS The data has been queued for transmission.\r
+ @retval EFI_NOT_STARTED This EFI UDPv6 Protocol instance has not been\r
+ started.\r
+ @retval EFI_NO_MAPPING The under-layer IPv6 driver was responsible for\r
+ choosing a source address for this instance, but\r
+ no source address was available for use.\r
+ @retval EFI_INVALID_PARAMETER One or more of the following are TRUE:\r
+ This is 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.\r
+ One or more of the\r
+ Token.Packet.TxData.FragmentTable[]\r
+ .FragmentLength fields is zero.\r
+ One or more of the\r
+ Token.Packet.TxData.FragmentTable[]\r
+ .FragmentBuffer fields is NULL.\r
+ One or more of the\r
+ Token.Packet.TxData.UdpSessionData.\r
+ DestinationAddres are not valid unicast IPv6\r
+ addresses, if the UdpSessionData is not NULL.\r
+ Token.Packet.TxData.UdpSessionData.\r
+ DestinationAddres is NULL\r
+ Token.Packet.TxData.UdpSessionData.\r
+ DestinatioPort is zero.\r
+ Token.Packet.TxData.UdpSessionData is\r
+ NULL and this instance's\r
+ UdpConfigData.RemoteAddress is unspecified.\r
+ @retval EFI_ACCESS_DENIED The transmit completion token with the same\r
+ Token.Event is already in the transmit queue.\r
+ @retval EFI_NOT_READY The completion token could not be queued because\r
+ the 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\r
+ address.\r
+ @retval EFI_BAD_BUFFER_SIZE The data length is greater than the maximum UDP\r
+ packet size. Or the length of the IP header + UDP\r
+ header + data length is greater than MTU if\r
+ DoNotFragment is TRUE.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Udp6Transmit (\r
+ IN EFI_UDP6_PROTOCOL *This,\r
+ IN EFI_UDP6_COMPLETION_TOKEN *Token\r
+ );\r
+\r
+/**\r
+ This function places a completion token into the receive packet queue. This function\r
+ is always asynchronous.\r
+\r
+ @param[in] This Pointer to the EFI_UDP6_PROTOCOL instance.\r
+ @param[in] Token Pointer to a token that is associated with the\r
+ receive data descriptor.\r
+\r
+ @retval EFI_SUCCESS The receive completion token is cached.\r
+ @retval EFI_NOT_STARTED This EFI UDPv6 Protocol instance has not been\r
+ started.\r
+ @retval EFI_NO_MAPPING When using a default address, configuration (DHCP,\r
+ BOOTP, RARP, etc.) is not finished yet.\r
+ @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
+ This is NULL.\r
+ Token is NULL.\r
+ Token.Event is NULL.\r
+ @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued\r
+ due to a lack of system resources (usually\r
+ memory).\r
+ @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
+ The EFI UDPv6 Protocol instance has been reset to\r
+ startup defaults.\r
+ @retval EFI_ACCESS_DENIED A receive completion token with the same\r
+ Token.Event is already in the receive queue.\r
+ @retval EFI_NOT_READY The receive request could not be queued because\r
+ the receive queue is full.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Udp6Receive (\r
+ IN EFI_UDP6_PROTOCOL *This,\r
+ IN EFI_UDP6_COMPLETION_TOKEN *Token\r
+ );\r
+\r
+/**\r
+ This function is used to abort a pending transmit or receive request.\r
+\r
+ @param[in] This Pointer to the EFI_UDP6_PROTOCOL instance.\r
+ @param[in] Token Pointer to a token that has been issued by\r
+ EFI_UDP6_PROTOCOL.Transmit() or\r
+ EFI_UDP6_PROTOCOL.Receive(). This parameter is\r
+ optional and may be NULL.\r
+\r
+ @retval EFI_SUCCESS The asynchronous I/O request is aborted and\r
+ Token.Event is signaled. When Token is NULL, all\r
+ pending requests are aborted and their events are\r
+ 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\r
+ (DHCP, BOOTP, RARP, etc.) is not finished yet.\r
+ @retval EFI_NOT_FOUND When Token is not NULL, the asynchronous I/O\r
+ request is not found in the transmit or receive\r
+ queue. It either completed or was not issued by\r
+ Transmit() or Receive().\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Udp6Cancel (\r
+ IN EFI_UDP6_PROTOCOL *This,\r
+ IN EFI_UDP6_COMPLETION_TOKEN *Token OPTIONAL\r
+ );\r
+\r
+/**\r
+ This function can be used by network drivers and applications to increase the rate that\r
+ data packets are moved between the communications device and the transmit/receive queues.\r
+\r
+ @param[in] This Pointer to the EFI_UDP6_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\r
+ receive queue.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Udp6Poll (\r
+ IN EFI_UDP6_PROTOCOL *This\r
+ );\r
+\r
+/**\r
+ This function is used to enable and disable the multicast group filtering.\r
+\r
+ @param[in] This Pointer to the EFI_UDP6_PROTOCOL instance.\r
+ @param[in] JoinFlag Set to TRUE to join a multicast group. Set to\r
+ FALSE to leave one or all multicast groups.\r
+ @param[in] MulticastAddress Pointer to multicast group address to join or\r
+ leave. This parameter is optional and may be NULL.\r
+\r
+ @retval EFI_SUCCESS The operation completed successfully.\r
+ @retval EFI_NOT_STARTED The EFI UDPv6 Protocol instance has not been\r
+ started.\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. JoinFlag is TRUE and\r
+ MulticastAddress is NULL. JoinFlag is TRUE and\r
+ *MulticastAddress is not a valid multicast\r
+ address.\r
+ @retval EFI_ALREADY_STARTED The group address is already in the group table\r
+ (when JoinFlag is TRUE).\r
+ @retval EFI_NOT_FOUND The group address is not in the group table (when\r
+ JoinFlag is FALSE).\r
+ @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+Udp6Groups (\r
+ IN EFI_UDP6_PROTOCOL *This,\r
+ IN BOOLEAN JoinFlag,\r
+ IN EFI_IPv6_ADDRESS *MulticastAddress OPTIONAL\r
+ );\r
+\r
+/**\r
+ This function tries to bind the udp instance according to the configured port\r
+ allocation stragety.\r
+\r
+ @param[in] InstanceList Pointer to the head of the list linking the udp\r
+ instances.\r
+ @param[in] ConfigData Pointer to the ConfigData of the instance to be\r
+ bound.\r
+\r
+ @retval EFI_SUCCESS The bound operation completed successfully.\r
+ @retval EFI_ACCESS_DENIED The <Address, Port> specified by the ConfigData is\r
+ already used by another instance.\r
+ @retval EFI_OUT_OF_RESOURCES No available port resources.\r
+\r
+**/\r
+EFI_STATUS\r
+Udp6Bind (\r
+ IN LIST_ENTRY *InstanceList,\r
+ IN EFI_UDP6_CONFIG_DATA *ConfigData\r
+ );\r
+\r
+/**\r
+ This function builds the Ip6 configdata from the Udp6ConfigData.\r
+\r
+ @param[in] Udp6ConfigData Pointer to the EFI_UDP6_CONFIG_DATA.\r
+ @param[in, out] Ip6ConfigData Pointer to the EFI_IP6_CONFIG_DATA.\r
+\r
+**/\r
+VOID\r
+Udp6BuildIp6ConfigData (\r
+ IN EFI_UDP6_CONFIG_DATA *Udp6ConfigData,\r
+ IN OUT EFI_IP6_CONFIG_DATA *Ip6ConfigData\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
+EFIAPI\r
+Udp6TokenExist (\r
+ IN NET_MAP *Map,\r
+ IN NET_MAP_ITEM *Item,\r
+ IN VOID *Context\r
+ );\r
+\r
+/**\r
+ This function removes the specified Token from the TokenMap.\r
+\r
+ @param[in] TokenMap Pointer to the NET_MAP containing the tokens.\r
+ @param[in] 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
+Udp6RemoveToken (\r
+ IN NET_MAP *TokenMap,\r
+ IN EFI_UDP6_COMPLETION_TOKEN *Token\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 according to NewConfigData.\r
+ @retval FALSE The instance is not reconfigurable according to NewConfigData.\r
+\r
+**/\r
+BOOLEAN\r
+Udp6IsReconfigurable (\r
+ IN EFI_UDP6_CONFIG_DATA *OldConfigData,\r
+ IN EFI_UDP6_CONFIG_DATA *NewConfigData\r
+ );\r
+\r
+/**\r
+ This function removes the multicast group specified by Arg from the Map.\r
+\r
+ @param[in] Map Pointer to the NET_MAP.\r
+ @param[in] Item Pointer to the NET_MAP_ITEM.\r
+ @param[in] Arg Pointer to the Arg. It is the pointer to a\r
+ multicast IPv6 Address. This parameter is\r
+ optional and may be NULL.\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
+EFIAPI\r
+Udp6LeaveGroup (\r
+ IN NET_MAP *Map,\r
+ IN NET_MAP_ITEM *Item,\r
+ IN VOID *Arg OPTIONAL\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:\r
+ 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.\r
+ One or more of the\r
+ Token.Packet.TxData.FragmentTable[].FragmentLength\r
+ fields is zero.\r
+ One or more of the\r
+ Token.Packet.TxData.FragmentTable[].FragmentBuffer\r
+ fields is NULL.\r
+ UdpSessionData.DestinationAddress are not valid\r
+ unicast IPv6 addresses if the UdpSessionData is\r
+ not NULL.\r
+ UdpSessionData.DestinationPort and\r
+ ConfigData.RemotePort are all zero if the\r
+ 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
+Udp6ValidateTxToken (\r
+ IN UDP6_INSTANCE_DATA *Instance,\r
+ IN EFI_UDP6_COMPLETION_TOKEN *TxToken\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
+EFIAPI\r
+Udp6NetVectorExtFree (\r
+ IN VOID *Context\r
+ );\r
+\r
+/**\r
+ This function calculates the checksum for the Packet, utilizing the pre-calculated\r
+ pseudo header to reduce 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
+ @return The 16-bit checksum of this udp datagram.\r
+\r
+**/\r
+UINT16\r
+Udp6Checksum (\r
+ IN NET_BUF *Packet,\r
+ IN UINT16 HeadSum\r
+ );\r
+\r
+/**\r
+ This function delivers the received datagrams to the specified instance.\r
+\r
+ @param[in] Instance Pointer to the instance context data.\r
+\r
+**/\r
+VOID\r
+Udp6InstanceDeliverDgram (\r
+ IN UDP6_INSTANCE_DATA *Instance\r
+ );\r
+\r
+/**\r
+ Cancel Udp6 tokens from the Udp6 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
+ This parameter is optional and may be NULL.\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
+Udp6InstanceCancelToken (\r
+ IN UDP6_INSTANCE_DATA *Instance,\r
+ IN EFI_UDP6_COMPLETION_TOKEN *Token OPTIONAL\r
+ );\r
+\r
+/**\r
+ This function removes all the Wrap datas in the RcvdDgramQue.\r
+\r
+ @param[in] Instance Pointer to the Udp6 Instance.\r
+\r
+**/\r
+VOID\r
+Udp6FlushRcvdDgram (\r
+ IN UDP6_INSTANCE_DATA *Instance\r
+ );\r
+\r
+#endif\r
+\r