\r
#include "Udp4Impl.h"\r
\r
-#include <Protocol/Ip4.h>\r
-\r
EFI_UDP4_PROTOCOL mUdp4Protocol = {\r
Udp4GetModeData,\r
Udp4Configure,\r
\r
\r
/**\r
- This function copies the current operational settings of this EFI UDPv4 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 This Pointer to the EFI_UDP4_PROTOCOL instance.\r
- @param Udp4ConfigData Pointer to the buffer to receive the current\r
- configuration data.\r
- @param Ip4ModeData Pointer to the EFI IPv4 Protocol mode data\r
- structure.\r
- @param MnpConfigData Pointer to the managed network configuration data\r
- 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\r
- data is available because this instance has not\r
- been started.\r
- @retval EFI_INVALID_PARAMETER This is NULL.\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
return EFI_NOT_STARTED;\r
}\r
\r
- OldTpl = NET_RAISE_TPL (NET_TPL_LOCK);\r
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
\r
if (Udp4ConfigData != NULL) {\r
//\r
// Set the Udp4ConfigData.\r
//\r
- CopyMem (Udp4ConfigData, &Instance->ConfigData, sizeof (EFI_UDP4_CONFIG_DATA));\r
+ CopyMem (Udp4ConfigData, &Instance->ConfigData, sizeof (*Udp4ConfigData));\r
}\r
\r
Ip = Instance->IpInfo->Ip;\r
//\r
Status = Ip->GetModeData (Ip, Ip4ModeData, MnpConfigData, SnpModeData);\r
\r
- NET_RESTORE_TPL (OldTpl);\r
+ gBS->RestoreTPL (OldTpl);\r
\r
return Status;\r
}\r
\r
\r
/**\r
- This 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
-\r
- @param This Pointer to the EFI_UDP4_PROTOCOL instance.\r
- @param UdpConfigData Pointer to the buffer to receive the current mode\r
- data.\r
-\r
- @retval EFI_SUCCESS The configuration settings were set, changed, or\r
- reset successfully.\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 following conditions are TRUE: This is\r
- NULL. UdpConfigData.StationAddress is not a valid\r
- unicast IPv4 address. UdpConfigData.SubnetMask is\r
- not a valid IPv4 address mask.\r
- UdpConfigData.RemoteAddress is not a valid unicast\r
- IPv4 address if it is not zero.\r
- @retval EFI_ALREADY_STARTED The EFI UDPv4 Protocol instance is already\r
- started/configured and must be stopped/reset\r
- before it can be reconfigured. Only TypeOfService,\r
- TimeToLive, DoNotFragment, ReceiveTimeout, and\r
- TransmitTimeout can be reconfigured without\r
- stopping the current instance of the EFI UDPv4\r
- Protocol.\r
- @retval EFI_ACCESS_DENIED UdpConfigData.AllowDuplicatePort is FALSE and\r
- UdpConfigData.StationPort is already used by other\r
- instance.\r
- @retval EFI_OUT_OF_RESOURCES The EFI UDPv4 Protocol driver cannot allocate\r
- memory for this EFI UDPv4 Protocol instance.\r
- @retval EFI_DEVICE_ERROR An unexpected network or system error occurred and\r
- this instance was not opened.\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 This Pointer to the EFI_UDP4_PROTOCOL instance.\r
+ @param 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
IP4_ADDR SubnetMask;\r
IP4_ADDR RemoteAddress;\r
EFI_IP4_CONFIG_DATA Ip4ConfigData;\r
+ IP4_ADDR LocalAddr;\r
+ IP4_ADDR RemoteAddr;\r
\r
if (This == NULL) {\r
return EFI_INVALID_PARAMETER;\r
Udp4Service = Instance->Udp4Service;\r
Status = EFI_SUCCESS;\r
\r
- OldTpl = NET_RAISE_TPL (NET_TPL_LOCK);\r
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
\r
if (UdpConfigData != NULL) {\r
\r
- StationAddress = EFI_NTOHL (UdpConfigData->StationAddress);\r
- SubnetMask = EFI_NTOHL (UdpConfigData->SubnetMask);\r
- RemoteAddress = EFI_NTOHL (UdpConfigData->RemoteAddress);\r
+ CopyMem (&StationAddress, &UdpConfigData->StationAddress, sizeof (IP4_ADDR));\r
+ CopyMem (&SubnetMask, &UdpConfigData->SubnetMask, sizeof (IP4_ADDR));\r
+ CopyMem (&RemoteAddress, &UdpConfigData->RemoteAddress, sizeof (IP4_ADDR));\r
+\r
+ StationAddress = NTOHL (StationAddress);\r
+ SubnetMask = NTOHL (SubnetMask);\r
+ RemoteAddress = NTOHL (RemoteAddress);\r
+\r
\r
if (!UdpConfigData->UseDefaultAddress &&\r
(!IP4_IS_VALID_NETMASK (SubnetMask) ||\r
//\r
// Save the configuration data.\r
//\r
- CopyMem (&Instance->ConfigData, UdpConfigData, sizeof (EFI_UDP4_CONFIG_DATA));\r
+ CopyMem (&Instance->ConfigData, UdpConfigData, sizeof (Instance->ConfigData));\r
Instance->ConfigData.StationAddress = Ip4ConfigData.StationAddress;\r
Instance->ConfigData.SubnetMask = Ip4ConfigData.SubnetMask;\r
\r
//\r
// Pre calculate the checksum for the pseudo head, ignore the UDP length first.\r
//\r
+ CopyMem (&LocalAddr, &Instance->ConfigData.StationAddress, sizeof (IP4_ADDR));\r
+ CopyMem (&RemoteAddr, &Instance->ConfigData.RemoteAddress, sizeof (IP4_ADDR));\r
Instance->HeadSum = NetPseudoHeadChecksum (\r
- EFI_IP4 (Instance->ConfigData.StationAddress),\r
- EFI_IP4 (Instance->ConfigData.RemoteAddress),\r
+ LocalAddr,\r
+ RemoteAddr,\r
EFI_IP_PROTO_UDP,\r
0\r
);\r
//\r
// Cancel all the user tokens.\r
//\r
- Udp4InstanceCancelToken (Instance, NULL);\r
+ Instance->Udp4Proto.Cancel (&Instance->Udp4Proto, NULL);\r
\r
//\r
// Remove the buffered RxData for this instance.\r
//\r
- Udp4FlushRxData (&Instance->RcvdDgramQue);\r
+ Udp4FlushRcvdDgram (Instance);\r
+\r
+ ASSERT (IsListEmpty (&Instance->DeliveredDgramQue));\r
}\r
\r
Udp4SetVariableData (Instance->Udp4Service);\r
\r
ON_EXIT:\r
\r
- NET_RESTORE_TPL (OldTpl);\r
+ gBS->RestoreTPL (OldTpl);\r
\r
return Status;\r
}\r
\r
\r
/**\r
- This function is used to enable and disable the multicast group filtering.\r
-\r
- @param This Pointer to the EFI_UDP4_PROTOCOL instance.\r
- @param JoinFlag Set to TRUE to join a multicast group. Set to\r
- FALSE to leave one or all multicast groups.\r
- @param MulticastAddress Pointer to multicast group address to join or\r
- leave.\r
-\r
- @retval EFI_SUCCESS The operation completed successfully.\r
- @retval EFI_NOT_STARTED The EFI UDPv4 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_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
+ 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 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
+\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
UDP4_INSTANCE_DATA *Instance;\r
EFI_IP4_PROTOCOL *Ip;\r
EFI_TPL OldTpl;\r
+ IP4_ADDR McastIp;\r
\r
- if ((This == NULL) ||\r
- (JoinFlag && (MulticastAddress == NULL)) ||\r
- (JoinFlag && !IP4_IS_MULTICAST (EFI_NTOHL (*MulticastAddress)))) {\r
+ if ((This == NULL) || (JoinFlag && (MulticastAddress == NULL))) {\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
+ McastIp = 0;\r
+ if (JoinFlag) {\r
+ CopyMem (&McastIp, MulticastAddress, sizeof (IP4_ADDR));\r
+\r
+ if (!IP4_IS_MULTICAST (NTOHL (McastIp))) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+ }\r
+\r
Instance = UDP4_INSTANCE_DATA_FROM_THIS (This);\r
\r
if (Instance->IsNoMapping) {\r
\r
Ip = Instance->IpInfo->Ip;\r
\r
- OldTpl = NET_RAISE_TPL (NET_TPL_LOCK);\r
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
\r
//\r
// Invoke the Ip instance the Udp4 instance consumes to do the group operation.\r
// Keep a local copy of the configured multicast IPs because IpIo receives\r
// datagrams from the 0 station address IP instance and then UDP delivers to\r
// the matched instance. This copy of multicast IPs is used to avoid receive\r
- // the mutlicast datagrams destinated to multicast IPs the other instances configured.\r
+ // the mutlicast datagrams destined to multicast IPs the other instances configured.\r
//\r
if (JoinFlag) {\r
\r
- NetMapInsertTail (\r
- &Instance->McastIps,\r
- (VOID *) (UINTN) EFI_IP4 (*MulticastAddress),\r
- NULL\r
- );\r
+ NetMapInsertTail (&Instance->McastIps, (VOID *) (UINTN) McastIp, NULL);\r
} else {\r
\r
NetMapIterate (&Instance->McastIps, Udp4LeaveGroup, MulticastAddress);\r
\r
ON_EXIT:\r
\r
- NET_RESTORE_TPL (OldTpl);\r
+ gBS->RestoreTPL (OldTpl);\r
\r
return Status;\r
}\r
\r
\r
/**\r
- This function adds a route to or deletes a route from the routing table.\r
-\r
- @param This Pointer to the EFI_UDP4_PROTOCOL instance.\r
- @param DeleteRoute Set to TRUE to delete this route from the routing\r
- table. Set to FALSE to add this route to the\r
- routing table.\r
- @param SubnetAddress The destination network address that needs to be\r
- routed.\r
- @param SubnetMask The subnet mask of SubnetAddress.\r
- @param 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\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. SubnetAddress is NULL. SubnetMask is\r
- NULL. GatewayAddress is NULL. SubnetAddress is not\r
- a valid subnet address. SubnetMask is not a valid\r
- subnet mask. GatewayAddress is not a valid unicast\r
- IP address.\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
+ 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 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
+\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
\r
\r
/**\r
- This function places a sending request to this instance of the EFI UDPv4 Protocol,\r
- alongside the transmit data that was filled by the user.\r
-\r
- @param This Pointer to the EFI_UDP4_PROTOCOL instance.\r
- @param 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 UDPv4 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 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_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
+ 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 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
+\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
NET_BUF *Packet;\r
EFI_UDP4_HEADER *Udp4Header;\r
EFI_UDP4_CONFIG_DATA *ConfigData;\r
+ IP4_ADDR Source;\r
IP4_ADDR Destination;\r
EFI_UDP4_TRANSMIT_DATA *TxData;\r
EFI_UDP4_SESSION_DATA *UdpSessionData;\r
return EFI_NOT_STARTED;\r
}\r
\r
- OldTpl = NET_RAISE_TPL (NET_TPL_LOCK);\r
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
\r
//\r
// Validate the Token, if the token is invalid return the error code.\r
// Set the SourceAddress, SrcPort and Destination according to the specified\r
// UdpSessionData.\r
//\r
- if (EFI_IP4 (UdpSessionData->SourceAddress) != 0) {\r
- Override.SourceAddress = UdpSessionData->SourceAddress;\r
+ if (!EFI_IP4_EQUAL (&UdpSessionData->SourceAddress, &mZeroIp4Addr)) {\r
+ CopyMem (&Override.SourceAddress, &UdpSessionData->SourceAddress, sizeof (EFI_IPv4_ADDRESS));\r
}\r
\r
if (UdpSessionData->SourcePort != 0) {\r
Udp4Header->SrcPort = HTONS (UdpSessionData->SourcePort);\r
}\r
\r
- Destination = EFI_IP4 (UdpSessionData->DestinationAddress);\r
-\r
if (UdpSessionData->DestinationPort != 0) {\r
Udp4Header->DstPort = HTONS (UdpSessionData->DestinationPort);\r
}\r
\r
+ CopyMem (&Source, &Override.SourceAddress, sizeof (IP4_ADDR));\r
+ CopyMem (&Destination, &UdpSessionData->DestinationAddress, sizeof (IP4_ADDR));\r
+\r
//\r
// calculate the pseudo head checksum using the overridden parameters.\r
//\r
HeadSum = NetPseudoHeadChecksum (\r
- EFI_IP4 (Override.SourceAddress),\r
+ Source,\r
Destination,\r
EFI_IP_PROTO_UDP,\r
0\r
//\r
// UdpSessionData is NULL, use the address and port information previously configured.\r
//\r
- Destination = EFI_IP4 (ConfigData->RemoteAddress);\r
- HeadSum = Instance->HeadSum;\r
+ CopyMem (&Destination, &ConfigData->RemoteAddress, sizeof (IP4_ADDR));\r
+\r
+ HeadSum = Instance->HeadSum;\r
}\r
\r
//\r
//\r
// Fill the IpIo Override data.\r
//\r
- EFI_IP4 (Override.GatewayAddress) = (TxData->GatewayAddress != NULL) ?\r
- EFI_IP4 (*(TxData->GatewayAddress)) : 0;\r
+ if (TxData->GatewayAddress != NULL) {\r
+ CopyMem (&Override.GatewayAddress, TxData->GatewayAddress, sizeof (EFI_IPv4_ADDRESS));\r
+ } else {\r
+ ZeroMem (&Override.GatewayAddress, sizeof (EFI_IPv4_ADDRESS));\r
+ }\r
+\r
Override.Protocol = EFI_IP_PROTO_UDP;\r
Override.TypeOfService = ConfigData->TypeOfService;\r
Override.TimeToLive = ConfigData->TimeToLive;\r
\r
ON_EXIT:\r
\r
- NET_RESTORE_TPL (OldTpl);\r
+ gBS->RestoreTPL (OldTpl);\r
\r
return Status;\r
}\r
\r
\r
/**\r
- This function places a completion token into the receive packet queue. This function\r
- is always asynchronous.\r
-\r
- @param This Pointer to the EFI_UDP4_PROTOCOL instance.\r
- @param 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 UDPv4 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. Token is NULL. 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 UDPv4 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
+ 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 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
+\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
return EFI_NOT_STARTED;\r
}\r
\r
- OldTpl = NET_RAISE_TPL (NET_TPL_LOCK);\r
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
\r
if (EFI_ERROR (NetMapIterate (&Instance->RxTokens, Udp4TokenExist, Token))||\r
EFI_ERROR (NetMapIterate (&Instance->TxTokens, Udp4TokenExist, Token))) {\r
//\r
Status = NetMapInsertTail (&Instance->RxTokens, Token, NULL);\r
if (EFI_ERROR (Status)) {\r
- return EFI_NOT_READY;\r
+ Status = EFI_NOT_READY;\r
+ goto ON_EXIT;\r
}\r
\r
//\r
Udp4ReportIcmpError (Instance);\r
\r
//\r
- // Try to delivered the received datagrams.\r
+ // Try to deliver the received datagrams.\r
//\r
Udp4InstanceDeliverDgram (Instance);\r
\r
+ //\r
+ // Dispatch the DPC queued by the NotifyFunction of Token->Event.\r
+ //\r
+ NetLibDispatchDpc ();\r
+\r
ON_EXIT:\r
\r
- NET_RESTORE_TPL (OldTpl);\r
+ gBS->RestoreTPL (OldTpl);\r
\r
return Status;\r
}\r
\r
\r
/**\r
- This function is used to abort a pending transmit or receive request.\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().\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 is either completed or not issued by\r
- Transmit() or Receive().\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 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
+\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
return EFI_NOT_STARTED;\r
}\r
\r
- OldTpl = NET_RAISE_TPL (NET_TPL_LOCK);\r
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
\r
//\r
// Cancle the tokens specified by Token for this instance.\r
//\r
Status = Udp4InstanceCancelToken (Instance, Token);\r
\r
- NET_RESTORE_TPL (OldTpl);\r
+ //\r
+ // Dispatch the DPC queued by the NotifyFunction of the cancelled token's events.\r
+ //\r
+ NetLibDispatchDpc ();\r
+\r
+ gBS->RestoreTPL (OldTpl);\r
\r
return Status;\r
}\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
- Argumens:\r
- 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\r
- receive queue.\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 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