]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Main.c
MdeModulePkg: Clean up source files
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Udp4Dxe / Udp4Main.c
index db1c4fdb87506a49ea73745eb62e65e8954f8528..6950c693aed45adfd12d659fed5df506534f1903 100644 (file)
@@ -1,6 +1,7 @@
 /** @file\r
 \r
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+(C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>\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
@@ -95,7 +96,7 @@ Udp4GetModeData (
 /**\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
@@ -122,7 +123,7 @@ Udp4GetModeData (
   @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
@@ -170,9 +171,9 @@ Udp4Configure (
 \r
 \r
     if (!UdpConfigData->UseDefaultAddress &&\r
-      (!IP4_IS_VALID_NETMASK (SubnetMask) ||\r
-      !((StationAddress == 0) || NetIp4IsUnicast (StationAddress, SubnetMask)) ||\r
-      !((RemoteAddress  == 0) || NetIp4IsUnicast (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
@@ -227,8 +228,8 @@ Udp4Configure (
       // 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
@@ -281,8 +282,6 @@ Udp4Configure (
     ASSERT (IsListEmpty (&Instance->DeliveredDgramQue));\r
   }\r
 \r
-  Udp4SetVariableData (Instance->Udp4Service);\r
-\r
 ON_EXIT:\r
 \r
   gBS->RestoreTPL (OldTpl);\r
@@ -293,7 +292,7 @@ ON_EXIT:
 \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
@@ -394,7 +393,7 @@ ON_EXIT:
 \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
@@ -468,7 +467,7 @@ Udp4Routes (
 \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
@@ -590,7 +589,7 @@ Udp4Transmit (
   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
@@ -598,7 +597,7 @@ Udp4Transmit (
     // 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
@@ -645,7 +644,7 @@ Udp4Transmit (
   // 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
@@ -697,7 +696,7 @@ ON_EXIT:
 \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
@@ -797,7 +796,7 @@ ON_EXIT:
 \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
@@ -868,7 +867,7 @@ Udp4Cancel (
 \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