/** @file\r
+ EFI UDPv4 protocol implementation.\r
\r
-Copyright (c) 2006 - 2007, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\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
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
-Module Name:\r
-\r
- Udp4Impl.h\r
-\r
-Abstract:\r
-\r
- EFI UDPv4 protocol implementation\r
-\r
-\r
**/\r
\r
#ifndef _UDP4_IMPL_H_\r
#define _UDP4_IMPL_H_\r
\r
-#include <PiDxe.h>\r
+#include <Uefi.h>\r
\r
#include <Protocol/Ip4.h>\r
#include <Protocol/Udp4.h>\r
#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
+#include <Library/PrintLib.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_UNICODE_STRING_TABLE *gUdpControllerNameTable;\r
extern EFI_SERVICE_BINDING_PROTOCOL mUdp4ServiceBinding;\r
extern EFI_UDP4_PROTOCOL mUdp4Protocol;\r
extern UINT16 mUdp4RandomPort;\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_HEADER_SIZE sizeof (EFI_UDP_HEADER)\r
#define UDP4_MAX_DATA_SIZE 65507\r
\r
#define UDP4_PORT_KNOWN 1024\r
\r
-#define UDP4_SERVICE_DATA_SIGNATURE EFI_SIGNATURE_32('U', 'd', 'p', '4')\r
+#define UDP4_SERVICE_DATA_SIGNATURE SIGNATURE_32('U', 'd', 'p', '4')\r
\r
#define UDP4_SERVICE_DATA_FROM_THIS(a) \\r
CR ( \\r
IP_IO *IpIo;\r
\r
EFI_EVENT TimeoutEvent;\r
-\r
- CHAR16 *MacString;\r
} UDP4_SERVICE_DATA;\r
\r
-#define UDP4_INSTANCE_DATA_SIGNATURE EFI_SIGNATURE_32('U', 'd', 'p', 'I')\r
+#define UDP4_INSTANCE_DATA_SIGNATURE SIGNATURE_32('U', 'd', 'p', 'I')\r
\r
#define UDP4_INSTANCE_DATA_FROM_THIS(a) \\r
CR ( \\r
\r
IP_IO_IP_INFO *IpInfo;\r
\r
- BOOLEAN Destroyed;\r
+ BOOLEAN InDestroy;\r
} UDP4_INSTANCE_DATA;\r
\r
typedef struct _UDP4_RXDATA_WRAP_ {\r
EFI_UDP4_RECEIVE_DATA RxData;\r
} UDP4_RXDATA_WRAP;\r
\r
+typedef struct {\r
+ EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;\r
+ UINTN NumberOfChildren;\r
+ EFI_HANDLE *ChildHandleBuffer;\r
+} UDP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT;\r
+\r
/**\r
Reads the current operational settings.\r
\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
+ @param[in] This Pointer to the EFI_UDP4_PROTOCOL instance.\r
+ @param[out] Udp4ConfigData Pointer to the buffer to receive the current configuration data.\r
+ @param[out] Ip4ModeData Pointer to the EFI IPv4 Protocol mode data structure.\r
+ @param[out] MnpConfigData Pointer to the managed network configuration data structure.\r
+ @param[out] 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
/**\r
Initializes, changes, or resets the operational parameters for this instance of the EFI UDPv4\r
Protocol.\r
- \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
With different parameters in UdpConfigData, Configure() can be used to bind\r
this instance to specified port.\r
\r
- @param This Pointer to the EFI_UDP4_PROTOCOL instance.\r
- @param UdpConfigData Pointer to the buffer to receive the current configuration data.\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
@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
+ was not opened.\r
\r
**/\r
EFI_STATUS\r
\r
/**\r
Joins and leaves multicast groups.\r
- \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 This Pointer to the EFI_UDP4_PROTOCOL instance.\r
- @param JoinFlag Set to TRUE to join a multicast group. Set to FALSE to leave one\r
- or all multicast groups.\r
- @param MulticastAddress Pointer to multicast group address to join or leave.\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
\r
/**\r
Adds and deletes routing table entries.\r
- \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
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 This Pointer to the EFI_UDP4_PROTOCOL instance.\r
- @param 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 SubnetAddress The destination network address that needs to be routed.\r
- @param SubnetMask The subnet mask of SubnetAddress.\r
- @param GatewayAddress The gateway IP address for this route.\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
\r
/**\r
Queues outgoing data packets into the transmit queue.\r
- \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
and context for the event will enable the user to receive the notification and\r
transmitting status.\r
\r
- @param This Pointer to the EFI_UDP4_PROTOCOL instance.\r
- @param Token Pointer to the completion token that will be placed into the\r
- transmit queue.\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
\r
/**\r
Places an asynchronous receive request into the receiving queue.\r
- \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
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 This Pointer to the EFI_UDP4_PROTOCOL instance.\r
- @param Token Pointer to a token that is associated with the receive data\r
- descriptor.\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
\r
/**\r
Aborts an asynchronous transmit or receive request.\r
- \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
the asynchronous operation has completed, this function will not signal the\r
token and EFI_NOT_FOUND is returned.\r
\r
- @param This Pointer to the EFI_UDP4_PROTOCOL instance.\r
- @param 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
+ @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
\r
/**\r
Polls for incoming data packets and processes outgoing data packets.\r
- \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
Drivers and applications that are experiencing packet loss should try calling\r
the Poll() function more often.\r
\r
- @param This Pointer to the EFI_UDP4_PROTOCOL instance.\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
/**\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
+ @param[in, out] Udp4Service Pointer to the UDP4_SERVICE_DATA.\r
+ @param[in] ImageHandle The image handle of this udp4 driver.\r
+ @param[in] 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
+ @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
/**\r
Clean the Udp service context data.\r
\r
- @param Udp4Service Pointer to the UDP4_SERVICE_DATA.\r
-\r
- @return None.\r
+ @param[in] Udp4Service Pointer to the UDP4_SERVICE_DATA.\r
\r
**/\r
VOID\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
- @return None.\r
+ @param[in] Udp4Service Pointer to the UDP4_SERVICE_DATA.\r
+ @param[in, out] Instance Pointer to the un-initialized UDP4_INSTANCE_DATA.\r
\r
**/\r
VOID\r
/**\r
This function cleans the udp instance.\r
\r
- @param Instance Pointer to the UDP4_INSTANCE_DATA to clean.\r
-\r
- @return None.\r
+ @param[in] Instance Pointer to the UDP4_INSTANCE_DATA to clean.\r
\r
**/\r
VOID\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
+ @param[in] 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
+ @param[in, out] 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
This function is used to check whether the NewConfigData has any un-reconfigurable\r
parameters changed compared to the OldConfigData.\r
\r
- @param OldConfigData Pointer to the current ConfigData the udp instance\r
+ @param[in] OldConfigData Pointer to the current ConfigData the udp instance\r
uses.\r
- @param NewConfigData Pointer to the new ConfigData.\r
+ @param[in] NewConfigData Pointer to the new ConfigData.\r
\r
@retval TRUE The instance is reconfigurable.\r
@retval FALSE Otherwise.\r
/**\r
This function builds the Ip4 configdata from the Udp4ConfigData.\r
\r
- @param Udp4ConfigData Pointer to the EFI_UDP4_CONFIG_DATA.\r
- @param Ip4ConfigData Pointer to the EFI_IP4_CONFIG_DATA.\r
-\r
- @return None.\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
/**\r
This function validates the TxToken, it returns the error code according to the spec.\r
\r
- @param Instance Pointer to the udp instance context data.\r
- @param TxToken Pointer to the token to be checked.\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
/**\r
This function checks whether the specified Token duplicates with the one in the Map.\r
\r
- @param Map Pointer to the NET_MAP.\r
- @param Item Pointer to the NET_MAP_ITEM contain the pointer to\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 Context Pointer to the Token to be checked.\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
\r
**/\r
EFI_STATUS\r
+EFIAPI\r
Udp4TokenExist (\r
IN NET_MAP *Map,\r
IN NET_MAP_ITEM *Item,\r
This function calculates the checksum for the Packet, utilizing the pre-calculated\r
pseudo HeadSum to reduce some overhead.\r
\r
- @param Packet Pointer to the NET_BUF contains the udp datagram.\r
- @param HeadSum Checksum of the pseudo header execpt the length\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
+ @retval The 16-bit checksum of this udp datagram.\r
\r
**/\r
UINT16\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
+ @param[in, out] 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
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
+ @param[in, out] 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's the pointer to a\r
multicast IPv4 Address.\r
\r
@retval EFI_SUCCESS The multicast address is removed.\r
\r
**/\r
EFI_STATUS\r
+EFIAPI\r
Udp4LeaveGroup (\r
IN OUT NET_MAP *Map,\r
IN NET_MAP_ITEM *Item,\r
/**\r
This function removes all the Wrap datas in the RcvdDgramQue.\r
\r
- @param Instance Pointer to the udp instance context data.\r
-\r
- @return None.\r
+ @param[in] Instance Pointer to the udp instance context data.\r
\r
**/\r
VOID\r
/**\r
Cancel Udp4 tokens from the Udp4 instance.\r
\r
- @param Instance Pointer to the udp instance context data.\r
- @param Token Pointer to the token to be canceled, if NULL, all\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
/**\r
This function delivers the received datagrams for the specified instance.\r
\r
- @param Instance Pointer to the instance context data.\r
-\r
- @return None.\r
+ @param[in] Instance Pointer to the instance context data.\r
\r
**/\r
VOID\r
/**\r
This function reports the received ICMP error.\r
\r
- @param Instance Pointer to the udp instance context data.\r
-\r
- @return None.\r
+ @param[in] Instance Pointer to the udp instance context data.\r
\r
**/\r
VOID\r
This function is a dummy ext-free function for the NET_BUF created for the output\r
udp datagram.\r
\r
- @param Context Pointer to the context data.\r
-\r
- @return None.\r
+ @param[in] Context Pointer to the context data.\r
\r
**/\r
VOID\r
+EFIAPI\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 Udp4Service Udp4 service data.\r
-\r
- @return None.\r
-\r
-**/\r
-VOID\r
-Udp4ClearVariableData (\r
- IN UDP4_SERVICE_DATA *Udp4Service\r
- );\r
-\r
#endif\r
-\r