/** @file\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
+(C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\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
CopyMem (Udp4ConfigData, &Instance->ConfigData, sizeof (*Udp4ConfigData));\r
}\r
\r
- Ip = Instance->IpInfo->Ip;\r
+ Ip = Instance->IpInfo->Ip.Ip4;\r
\r
//\r
// Get the underlying Ip4ModeData, MnpConfigData and SnpModeData.\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
@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
if (!UdpConfigData->UseDefaultAddress &&\r
- (!IP4_IS_VALID_NETMASK (SubnetMask) ||\r
- !((StationAddress == 0) || Ip4IsUnicast (StationAddress, SubnetMask)) ||\r
- !((RemoteAddress == 0) || Ip4IsUnicast (RemoteAddress, 0)))) {\r
+ (!IP4_IS_VALID_NETMASK (SubnetMask) ||\r
+ !((StationAddress == 0) || (SubnetMask != 0 && NetIp4IsUnicast (StationAddress, SubnetMask))) ||\r
+ IP4_IS_LOCAL_BROADCAST (RemoteAddress))) {\r
//\r
// Don't use default address, and subnet mask is invalid or StationAddress is not\r
// a valid unicast IPv4 address or RemoteAddress is not a valid unicast IPv4 address\r
// Save the configuration data.\r
//\r
CopyMem (&Instance->ConfigData, UdpConfigData, sizeof (Instance->ConfigData));\r
- Instance->ConfigData.StationAddress = Ip4ConfigData.StationAddress;\r
- Instance->ConfigData.SubnetMask = Ip4ConfigData.SubnetMask;\r
+ IP4_COPY_ADDRESS (&Instance->ConfigData.StationAddress, &Ip4ConfigData.StationAddress);\r
+ IP4_COPY_ADDRESS (&Instance->ConfigData.SubnetMask, &Ip4ConfigData.SubnetMask);\r
\r
//\r
// Try to allocate the required port resource.\r
ASSERT (IsListEmpty (&Instance->DeliveredDgramQue));\r
}\r
\r
- Udp4SetVariableData (Instance->Udp4Service);\r
-\r
ON_EXIT:\r
\r
gBS->RestoreTPL (OldTpl);\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
return EFI_NOT_STARTED;\r
}\r
\r
- Ip = Instance->IpInfo->Ip;\r
+ Ip = Instance->IpInfo->Ip.Ip4;\r
\r
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
\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
return EFI_NOT_STARTED;\r
}\r
\r
- Ip = Instance->IpInfo->Ip;\r
+ Ip = Instance->IpInfo->Ip.Ip4;\r
\r
//\r
// Invoke the Ip instance the Udp4 instance consumes to do the actual operation.\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
//\r
Udp4Header->SrcPort = HTONS (ConfigData->StationPort);\r
Udp4Header->DstPort = HTONS (ConfigData->RemotePort);\r
- Udp4Header->Length = HTONS (Packet->TotalSize);\r
+ Udp4Header->Length = HTONS ((UINT16) Packet->TotalSize);\r
Udp4Header->Checksum = 0;\r
\r
UdpSessionData = TxData->UdpSessionData;\r
- Override.Ip4OverrideData.SourceAddress = ConfigData->StationAddress;\r
+ IP4_COPY_ADDRESS (&Override.Ip4OverrideData.SourceAddress, &ConfigData->StationAddress);\r
\r
if (UdpSessionData != NULL) {\r
//\r
// UdpSessionData.\r
//\r
if (!EFI_IP4_EQUAL (&UdpSessionData->SourceAddress, &mZeroIp4Addr)) {\r
- CopyMem (&Override.Ip4OverrideData.SourceAddress, &UdpSessionData->SourceAddress, sizeof (EFI_IPv4_ADDRESS));\r
+ IP4_COPY_ADDRESS (&Override.Ip4OverrideData.SourceAddress, &UdpSessionData->SourceAddress);\r
}\r
\r
if (UdpSessionData->SourcePort != 0) {\r
// Fill the IpIo Override data.\r
//\r
if (TxData->GatewayAddress != NULL) {\r
- CopyMem (&Override.Ip4OverrideData.GatewayAddress, TxData->GatewayAddress, sizeof (EFI_IPv4_ADDRESS));\r
+ IP4_COPY_ADDRESS (&Override.Ip4OverrideData.GatewayAddress, TxData->GatewayAddress);\r
} else {\r
ZeroMem (&Override.Ip4OverrideData.GatewayAddress, sizeof (EFI_IPv4_ADDRESS));\r
}\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
\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
\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
}\r
\r
Instance = UDP4_INSTANCE_DATA_FROM_THIS (This);\r
- Ip = Instance->IpInfo->Ip;\r
+ Ip = Instance->IpInfo->Ip.Ip4;\r
\r
//\r
// Invode the Ip instance consumed by the udp instance to do the poll operation.\r