summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Universal/Network/Udp4Dxe
diff options
context:
space:
mode:
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2007-07-30 02:37:10 +0000
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2007-07-30 02:37:10 +0000
commit772db4bb33ae66fa20e39f786b5f80d107d450a5 (patch)
tree206a2d4756e0f7e245e08ca75f3ba10df2e1cf7a /MdeModulePkg/Universal/Network/Udp4Dxe
parenteca7eaf49be5f23e3c79270621df7097ef585349 (diff)
downloadedk2-platforms-772db4bb33ae66fa20e39f786b5f80d107d450a5.tar.xz
Import ArpDxe, Dhcp4Dxe, Ip4Dxe, Mtftp4Dxe, PxeBcDxe and PxeDhcp4Dxe.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@3492 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Universal/Network/Udp4Dxe')
-rw-r--r--MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Driver.c1
-rw-r--r--MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.c84
-rw-r--r--MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Main.c64
3 files changed, 87 insertions, 62 deletions
diff --git a/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Driver.c b/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Driver.c
index 7b47ef44a9..ada73d79db 100644
--- a/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Driver.c
+++ b/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Driver.c
@@ -473,7 +473,6 @@ Udp4ServiceBindingDestroyChild (
return EFI_SUCCESS;
}
-//@MT: EFI_DRIVER_ENTRY_POINT (Udp4DriverEntryPoint)
EFI_STATUS
EFIAPI
diff --git a/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.c b/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.c
index e6fddd8052..e5576820a6 100644
--- a/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.c
+++ b/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.c
@@ -424,7 +424,7 @@ Udp4FindInstanceByPort (
continue;
}
- if (EFI_IP_EQUAL (ConfigData->StationAddress, *Address) &&
+ if (EFI_IP4_EQUAL (ConfigData->StationAddress, *Address) &&
(ConfigData->StationPort == Port)) {
//
// if both the address and the port are the same, return TRUE.
@@ -566,8 +566,8 @@ Udp4IsReconfigurable (
}
if (!NewConfigData->UseDefaultAddress &&
- (!EFI_IP_EQUAL (NewConfigData->StationAddress, OldConfigData->StationAddress) ||
- !EFI_IP_EQUAL (NewConfigData->SubnetMask, OldConfigData->SubnetMask))) {
+ (!EFI_IP4_EQUAL (NewConfigData->StationAddress, OldConfigData->StationAddress) ||
+ !EFI_IP4_EQUAL (NewConfigData->SubnetMask, OldConfigData->SubnetMask))) {
//
// If the instance doesn't use the default address, and the new address or
// new subnet mask is different from the old values.
@@ -576,15 +576,14 @@ Udp4IsReconfigurable (
}
}
- if (!EFI_IP_EQUAL (NewConfigData->RemoteAddress, OldConfigData->RemoteAddress)) {
+ if (!EFI_IP4_EQUAL (NewConfigData->RemoteAddress, OldConfigData->RemoteAddress)) {
//
// The remoteaddress is not the same.
//
return FALSE;
}
- if ((EFI_IP4 (NewConfigData->RemoteAddress) != 0) &&
- (NewConfigData->RemotePort != OldConfigData->RemotePort)) {
+ if (!EFI_IP4_EQUAL (NewConfigData->RemoteAddress, mZeroIp4Addr) && (NewConfigData->RemotePort != OldConfigData->RemotePort)) {
//
// The RemotePort differs if it's designated in the configdata.
//
@@ -667,6 +666,7 @@ Udp4ValidateTxToken (
EFI_UDP4_CONFIG_DATA *ConfigData;
EFI_UDP4_SESSION_DATA *UdpSessionData;
IP4_ADDR SourceAddress;
+ IP4_ADDR GatewayAddress;
if (TxToken->Event == NULL) {
return EFI_INVALID_PARAMETER;
@@ -700,12 +700,15 @@ Udp4ValidateTxToken (
return EFI_INVALID_PARAMETER;
}
- if ((TxData->GatewayAddress != NULL) &&
- !Ip4IsUnicast(EFI_NTOHL (*(TxData->GatewayAddress)), 0)) {
- //
- // The specified GatewayAddress is not a unicast IPv4 address while it's not 0.
- //
- return EFI_INVALID_PARAMETER;
+ if (TxData->GatewayAddress != NULL) {
+ NetCopyMem (&GatewayAddress, TxData->GatewayAddress, sizeof (IP4_ADDR));
+
+ if (!Ip4IsUnicast (NTOHL (GatewayAddress), 0)) {
+ //
+ // The specified GatewayAddress is not a unicast IPv4 address while it's not 0.
+ //
+ return EFI_INVALID_PARAMETER;
+ }
}
ConfigData = &Instance->ConfigData;
@@ -713,9 +716,9 @@ Udp4ValidateTxToken (
if (UdpSessionData != NULL) {
- SourceAddress = EFI_NTOHL (UdpSessionData->SourceAddress);
+ NetCopyMem (&SourceAddress, &UdpSessionData->SourceAddress, sizeof (IP4_ADDR));
- if ((SourceAddress != 0) && !Ip4IsUnicast (SourceAddress, 0)) {
+ if ((SourceAddress != 0) && !Ip4IsUnicast (HTONL (SourceAddress), 0)) {
//
// Check whether SourceAddress is a valid IPv4 address in case it's not zero.
// The configured station address is used if SourceAddress is zero.
@@ -730,13 +733,13 @@ Udp4ValidateTxToken (
return EFI_INVALID_PARAMETER;
}
- if (EFI_IP4 (UdpSessionData->DestinationAddress) == 0) {
+ if (EFI_IP4_EQUAL (UdpSessionData->DestinationAddress, mZeroIp4Addr)) {
//
// The DestinationAddress specified in the UdpSessionData is 0.
//
return EFI_INVALID_PARAMETER;
}
- } else if (EFI_IP4 (ConfigData->RemoteAddress) == 0) {
+ } else if (EFI_IP4_EQUAL (ConfigData->RemoteAddress, mZeroIp4Addr)) {
//
// the configured RemoteAddress is all zero, and the user doens't override the
// destination address.
@@ -959,9 +962,9 @@ Udp4LeaveGroup (
McastIp = Arg;
- if ((McastIp != NULL) && ((UINTN) EFI_IP4 (*McastIp) != (UINTN) (Item->Key))) {
+ if ((McastIp != NULL) && (!EFI_IP4_EQUAL (*McastIp, (UINTN) Item->Key))) {
//
- // McastIp is not NULL and the multicast address contained in the Item
+ // McastIp is not NULL and the multicast address contained in the Item
// is not the same as McastIp.
//
return EFI_SUCCESS;
@@ -1169,16 +1172,16 @@ Udp4MatchDgram (
return FALSE;
}
- if ((EFI_IP4 (ConfigData->RemoteAddress) != 0) &&
- !EFI_IP_EQUAL (ConfigData->RemoteAddress, Udp4Session->SourceAddress)) {
+ if (!EFI_IP4_EQUAL (ConfigData->RemoteAddress, mZeroIp4Addr) &&
+ !EFI_IP4_EQUAL (ConfigData->RemoteAddress, Udp4Session->SourceAddress)) {
//
// This datagram doesn't come from the instance's specified sender.
//
return FALSE;
}
- if ((EFI_IP4 (ConfigData->StationAddress) == 0) ||
- EFI_IP_EQUAL (Udp4Session->DestinationAddress, ConfigData->StationAddress)) {
+ if (EFI_IP4_EQUAL (ConfigData->StationAddress, mZeroIp4Addr) ||
+ EFI_IP4_EQUAL (Udp4Session->DestinationAddress, ConfigData->StationAddress)) {
//
// The instance is configured to receive datagrams destinated to any station IP or
// the destination address of this datagram matches the configured station IP.
@@ -1186,7 +1189,7 @@ Udp4MatchDgram (
return TRUE;
}
- Destination = EFI_IP4 (Udp4Session->DestinationAddress);
+ NetCopyMem (&Destination, &Udp4Session->DestinationAddress, sizeof (IP4_ADDR));
if (IP4_IS_LOCAL_BROADCAST (Destination) && ConfigData->AcceptBroadcast) {
//
@@ -1513,11 +1516,12 @@ Udp4Demultiplex (
gRT->GetTime (&RxData.TimeStamp, NULL);
- Udp4Session = &RxData.UdpSession;
- EFI_IP4 (Udp4Session->SourceAddress) = NetSession->Source;
- EFI_IP4 (Udp4Session->DestinationAddress) = NetSession->Dest;
- Udp4Session->SourcePort = NTOHS (Udp4Header->SrcPort);
- Udp4Session->DestinationPort = NTOHS (Udp4Header->DstPort);
+ Udp4Session = &RxData.UdpSession;
+ Udp4Session->SourcePort = NTOHS (Udp4Header->SrcPort);
+ Udp4Session->DestinationPort = NTOHS (Udp4Header->DstPort);
+
+ NetCopyMem (&Udp4Session->SourceAddress, &NetSession->Source, sizeof (EFI_IPv4_ADDRESS));
+ NetCopyMem (&Udp4Session->DestinationAddress, &NetSession->Dest, sizeof (EFI_IPv4_ADDRESS));
//
// Trim the UDP header.
@@ -1637,12 +1641,13 @@ Udp4SendPortUnreach (
//
// Fill the override data.
//
- Override.DoNotFragment = FALSE;
- Override.TypeOfService = 0;
- Override.TimeToLive = 255;
- Override.Protocol = EFI_IP_PROTO_ICMP;
- EFI_IP4 (Override.SourceAddress) = NetSession->Dest;
- EFI_IP4 (Override.GatewayAddress) = 0;
+ Override.DoNotFragment = FALSE;
+ Override.TypeOfService = 0;
+ Override.TimeToLive = 255;
+ Override.Protocol = EFI_IP_PROTO_ICMP;
+
+ NetCopyMem (&Override.SourceAddress, &NetSession->Dest, sizeof (EFI_IPv4_ADDRESS));
+ NetZeroMem (&Override.GatewayAddress, sizeof (EFI_IPv4_ADDRESS));
//
// Send out this icmp packet.
@@ -1682,10 +1687,11 @@ Udp4IcmpHandler (
Udp4Header = (EFI_UDP4_HEADER *) NetbufGetByte (Packet, 0, NULL);
- EFI_IP4 (Udp4Session.SourceAddress) = NetSession->Source;
- EFI_IP4 (Udp4Session.DestinationAddress) = NetSession->Dest;
- Udp4Session.SourcePort = NTOHS (Udp4Header->DstPort);
- Udp4Session.DestinationPort = NTOHS (Udp4Header->SrcPort);
+ NetCopyMem (&Udp4Session.SourceAddress, &NetSession->Source, sizeof (EFI_IPv4_ADDRESS));
+ NetCopyMem (&Udp4Session.DestinationAddress, &NetSession->Dest, sizeof (EFI_IPv4_ADDRESS));
+
+ Udp4Session.SourcePort = NTOHS (Udp4Header->DstPort);
+ Udp4Session.DestinationPort = NTOHS (Udp4Header->SrcPort);
NET_LIST_FOR_EACH (Entry, &Udp4Service->ChildrenList) {
//
@@ -1696,7 +1702,7 @@ Udp4IcmpHandler (
if (!Instance->Configured ||
Instance->ConfigData.AcceptPromiscuous ||
Instance->ConfigData.AcceptAnyPort ||
- (EFI_IP4 (Instance->ConfigData.StationAddress) == 0)) {
+ EFI_IP4_EQUAL (Instance->ConfigData.StationAddress, mZeroIp4Addr)) {
//
// Don't try to deliver the ICMP error to this instance if it is not configured,
// or it's configured to be promiscuous or accept any port or accept all the
diff --git a/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Main.c b/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Main.c
index 5343bd5c4b..b3daacba23 100644
--- a/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Main.c
+++ b/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Main.c
@@ -153,6 +153,8 @@ Udp4Configure (
IP4_ADDR SubnetMask;
IP4_ADDR RemoteAddress;
EFI_IP4_CONFIG_DATA Ip4ConfigData;
+ IP4_ADDR LocalAddr;
+ IP4_ADDR RemoteAddr;
if (This == NULL) {
return EFI_INVALID_PARAMETER;
@@ -171,9 +173,14 @@ Udp4Configure (
if (UdpConfigData != NULL) {
- StationAddress = EFI_NTOHL (UdpConfigData->StationAddress);
- SubnetMask = EFI_NTOHL (UdpConfigData->SubnetMask);
- RemoteAddress = EFI_NTOHL (UdpConfigData->RemoteAddress);
+ NetCopyMem (&StationAddress, &UdpConfigData->StationAddress, sizeof (IP4_ADDR));
+ NetCopyMem (&SubnetMask, &UdpConfigData->SubnetMask, sizeof (IP4_ADDR));
+ NetCopyMem (&RemoteAddress, &UdpConfigData->RemoteAddress, sizeof (IP4_ADDR));
+
+ StationAddress = NTOHL (StationAddress);
+ SubnetMask = NTOHL (SubnetMask);
+ RemoteAddress = NTOHL (RemoteAddress);
+
if (!UdpConfigData->UseDefaultAddress &&
(!IP4_IS_VALID_NETMASK (SubnetMask) ||
@@ -251,9 +258,11 @@ Udp4Configure (
//
// Pre calculate the checksum for the pseudo head, ignore the UDP length first.
//
+ NetCopyMem (&LocalAddr, &Instance->ConfigData.StationAddress, sizeof (IP4_ADDR));
+ NetCopyMem (&RemoteAddr, &Instance->ConfigData.RemoteAddress, sizeof (IP4_ADDR));
Instance->HeadSum = NetPseudoHeadChecksum (
- EFI_IP4 (Instance->ConfigData.StationAddress),
- EFI_IP4 (Instance->ConfigData.RemoteAddress),
+ LocalAddr,
+ RemoteAddr,
EFI_IP_PROTO_UDP,
0
);
@@ -332,13 +341,21 @@ Udp4Groups (
UDP4_INSTANCE_DATA *Instance;
EFI_IP4_PROTOCOL *Ip;
EFI_TPL OldTpl;
+ IP4_ADDR McastIp;
- if ((This == NULL) ||
- (JoinFlag && (MulticastAddress == NULL)) ||
- (JoinFlag && !IP4_IS_MULTICAST (EFI_NTOHL (*MulticastAddress)))) {
+ if ((This == NULL) || (JoinFlag && (MulticastAddress == NULL))) {
return EFI_INVALID_PARAMETER;
}
+ McastIp = 0;
+ if (JoinFlag) {
+ NetCopyMem (&McastIp, MulticastAddress, sizeof (IP4_ADDR));
+
+ if (IP4_IS_MULTICAST (NTOHL (McastIp))) {
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+
Instance = UDP4_INSTANCE_DATA_FROM_THIS (This);
if (Instance->IsNoMapping) {
@@ -370,11 +387,7 @@ Udp4Groups (
//
if (JoinFlag) {
- NetMapInsertTail (
- &Instance->McastIps,
- (VOID *) (UINTN) EFI_IP4 (*MulticastAddress),
- NULL
- );
+ NetMapInsertTail (&Instance->McastIps, (VOID *) (UINTN) McastIp, NULL);
} else {
NetMapIterate (&Instance->McastIps, Udp4LeaveGroup, MulticastAddress);
@@ -506,6 +519,7 @@ Udp4Transmit (
NET_BUF *Packet;
EFI_UDP4_HEADER *Udp4Header;
EFI_UDP4_CONFIG_DATA *ConfigData;
+ IP4_ADDR Source;
IP4_ADDR Destination;
EFI_UDP4_TRANSMIT_DATA *TxData;
EFI_UDP4_SESSION_DATA *UdpSessionData;
@@ -590,25 +604,26 @@ Udp4Transmit (
// Set the SourceAddress, SrcPort and Destination according to the specified
// UdpSessionData.
//
- if (EFI_IP4 (UdpSessionData->SourceAddress) != 0) {
- Override.SourceAddress = UdpSessionData->SourceAddress;
+ if (!EFI_IP4_EQUAL (UdpSessionData->SourceAddress, mZeroIp4Addr)) {
+ NetCopyMem (&Override.SourceAddress, &UdpSessionData->SourceAddress, sizeof (EFI_IPv4_ADDRESS));
}
if (UdpSessionData->SourcePort != 0) {
Udp4Header->SrcPort = HTONS (UdpSessionData->SourcePort);
}
- Destination = EFI_IP4 (UdpSessionData->DestinationAddress);
-
if (UdpSessionData->DestinationPort != 0) {
Udp4Header->DstPort = HTONS (UdpSessionData->DestinationPort);
}
+ NetCopyMem (&Source, &Override.SourceAddress, sizeof (IP4_ADDR));
+ NetCopyMem (&Destination, &UdpSessionData->DestinationAddress, sizeof (IP4_ADDR));
+
//
// calculate the pseudo head checksum using the overridden parameters.
//
HeadSum = NetPseudoHeadChecksum (
- EFI_IP4 (Override.SourceAddress),
+ Source,
Destination,
EFI_IP_PROTO_UDP,
0
@@ -617,8 +632,9 @@ Udp4Transmit (
//
// UdpSessionData is NULL, use the address and port information previously configured.
//
- Destination = EFI_IP4 (ConfigData->RemoteAddress);
- HeadSum = Instance->HeadSum;
+ NetCopyMem (&Destination, &ConfigData->RemoteAddress, sizeof (IP4_ADDR));
+
+ HeadSum = Instance->HeadSum;
}
//
@@ -635,8 +651,12 @@ Udp4Transmit (
//
// Fill the IpIo Override data.
//
- EFI_IP4 (Override.GatewayAddress) = (TxData->GatewayAddress != NULL) ?
- EFI_IP4 (*(TxData->GatewayAddress)) : 0;
+ if (TxData->GatewayAddress != NULL) {
+ NetCopyMem (&Override.GatewayAddress, TxData->GatewayAddress, sizeof (EFI_IPv4_ADDRESS));
+ } else {
+ NetZeroMem (&Override.GatewayAddress, sizeof (EFI_IPv4_ADDRESS));
+ }
+
Override.Protocol = EFI_IP_PROTO_UDP;
Override.TypeOfService = ConfigData->TypeOfService;
Override.TimeToLive = ConfigData->TimeToLive;