]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Main.c
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Udp4Dxe / Udp4Main.c
index 582d6f6d448905a643974861d59bb95d61e853de..aa1956cd4b4214c6c2c7844a1a36bb15991da8ee 100644 (file)
@@ -1,13 +1,8 @@
 /** @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
@@ -33,11 +28,11 @@ EFI_UDP4_PROTOCOL  mUdp4Protocol = {
   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
@@ -79,7 +74,7 @@ Udp4GetModeData (
     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
@@ -95,7 +90,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 +117,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 +165,9 @@ Udp4Configure (
 \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
@@ -227,8 +222,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 +276,6 @@ Udp4Configure (
     ASSERT (IsListEmpty (&Instance->DeliveredDgramQue));\r
   }\r
 \r
-  Udp4SetVariableData (Instance->Udp4Service);\r
-\r
 ON_EXIT:\r
 \r
   gBS->RestoreTPL (OldTpl);\r
@@ -293,7 +286,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
@@ -357,7 +350,7 @@ Udp4Groups (
     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
@@ -394,7 +387,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
@@ -457,7 +450,7 @@ Udp4Routes (
     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
@@ -468,7 +461,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
@@ -586,11 +579,11 @@ Udp4Transmit (
   //\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
@@ -598,7 +591,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 +638,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 +690,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 +790,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 +861,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
@@ -900,7 +893,7 @@ Udp4Poll (
   }\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