]> git.proxmox.com Git - mirror_edk2.git/blobdiff - NetworkPkg/HttpBootDxe/HttpBootDhcp4.c
NetworkPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / NetworkPkg / HttpBootDxe / HttpBootDhcp4.c
index a8cee04c256c1c5657255dcc02c529e7f46cbe34..b5dd6e09567aaa00ede203ba4db006123cd553cb 100644 (file)
@@ -1,14 +1,8 @@
 /** @file\r
   Functions implementation related with DHCPv4 for HTTP boot driver.\r
 \r
-Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials are licensed and made available under \r
-the terms and conditions of the BSD License that accompanies this distribution.  \r
-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
+Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -267,7 +261,7 @@ HttpBootParseDhcp4Packet (
   HTTP_BOOT_OFFER_TYPE           OfferType;\r
   EFI_IPv4_ADDRESS               IpAddr;\r
   BOOLEAN                        FileFieldOverloaded;\r
-  \r
+\r
   IsDnsOffer     = FALSE;\r
   IpExpressedUri = FALSE;\r
   IsProxyOffer   = FALSE;\r
@@ -291,7 +285,7 @@ HttpBootParseDhcp4Packet (
                        );\r
   }\r
   //\r
-  // Second, Check if bootfilename and serverhostname is overloaded to carry DHCP options refers to rfc-2132. \r
+  // Second, Check if bootfilename and serverhostname is overloaded to carry DHCP options refers to rfc-2132.\r
   // If yes, try to parse options from the BootFileName field, then ServerName field.\r
   //\r
   Option = Options[HTTP_BOOT_DHCP4_TAG_INDEX_OVERLOAD];\r
@@ -332,8 +326,8 @@ HttpBootParseDhcp4Packet (
   // The offer with "HTTPClient" is a Http offer.\r
   //\r
   Option = Options[HTTP_BOOT_DHCP4_TAG_INDEX_CLASS_ID];\r
-  if ((Option != NULL) && (Option->Length >= 9) &&\r
-      (CompareMem (Option->Data, DEFAULT_CLASS_ID_DATA, 9) == 0)) {\r
+  if ((Option != NULL) && (Option->Length >= 10) &&\r
+      (CompareMem (Option->Data, DEFAULT_CLASS_ID_DATA, 10) == 0)) {\r
     IsHttpOffer = TRUE;\r
   }\r
 \r
@@ -379,7 +373,7 @@ HttpBootParseDhcp4Packet (
   }\r
 \r
   //\r
-  // Try to retrieve the IP of HTTP server from URI. \r
+  // Try to retrieve the IP of HTTP server from URI.\r
   //\r
   if (IsHttpOffer) {\r
     Status = HttpParseUrl (\r
@@ -422,10 +416,13 @@ HttpBootParseDhcp4Packet (
     if (!IsProxyOffer) {\r
       OfferType = IsDnsOffer ? HttpOfferTypeDhcpDns : HttpOfferTypeDhcpOnly;\r
     } else {\r
+      if (Cache4->UriParser != NULL) {\r
+        FreePool (Cache4->UriParser);\r
+      }\r
       return EFI_DEVICE_ERROR;\r
     }\r
   }\r
-  \r
+\r
   Cache4->OfferType = OfferType;\r
   return EFI_SUCCESS;\r
 }\r
@@ -503,70 +500,70 @@ HttpBootSelectDhcpOffer (
     // The offer with DNS server address takes priority here.\r
     //\r
     if (Private->OfferCount[HttpOfferTypeDhcpDns] > 0) {\r
-      \r
+\r
       Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpDns][0] + 1;\r
-      \r
+\r
     } else if (Private->OfferCount[HttpOfferTypeDhcpIpUriDns] > 0) {\r
-    \r
+\r
       Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpIpUriDns][0] + 1;\r
-      \r
+\r
     } else if (Private->OfferCount[HttpOfferTypeDhcpNameUriDns] > 0) {\r
-    \r
+\r
       Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpNameUriDns][0] + 1;\r
-      \r
+\r
     }  else if (Private->OfferCount[HttpOfferTypeDhcpOnly] > 0) {\r
-    \r
+\r
       Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpOnly][0] + 1;\r
-      \r
+\r
     }  else if (Private->OfferCount[HttpOfferTypeDhcpIpUri] > 0) {\r
-    \r
+\r
       Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpIpUri][0] + 1;\r
     }\r
-    \r
+\r
   } else {\r
     //\r
     // We are in corporate environment.\r
     //\r
     // Priority1: HttpOfferTypeDhcpIpUri or HttpOfferTypeDhcpIpUriDns\r
-    // Priority2: HttpOfferTypeDhcpNameUriDns                      \r
-    // Priority3: HttpOfferTypeDhcpOnly + HttpOfferTypeProxyIpUri  \r
-    // Priority4: HttpOfferTypeDhcpDns  + HttpOfferTypeProxyIpUri  \r
+    // Priority2: HttpOfferTypeDhcpNameUriDns\r
+    // Priority3: HttpOfferTypeDhcpOnly + HttpOfferTypeProxyIpUri\r
+    // Priority4: HttpOfferTypeDhcpDns  + HttpOfferTypeProxyIpUri\r
     // Priority5: HttpOfferTypeDhcpDns  + HttpOfferTypeProxyNameUri\r
-    // Priority6: HttpOfferTypeDhcpDns  + HttpOfferTypeDhcpNameUri \r
-    //    \r
+    // Priority6: HttpOfferTypeDhcpDns  + HttpOfferTypeDhcpNameUri\r
+    //\r
     if (Private->OfferCount[HttpOfferTypeDhcpIpUri] > 0) {\r
-      \r
+\r
       Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpIpUri][0] + 1;\r
-      \r
+\r
     } else if (Private->OfferCount[HttpOfferTypeDhcpIpUriDns] > 0) {\r
-      \r
+\r
       Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpIpUriDns][0] + 1;\r
-      \r
+\r
     }else if (Private->OfferCount[HttpOfferTypeDhcpNameUriDns] > 0) {\r
-    \r
+\r
       Private->SelectIndex = Private->OfferIndex[HttpOfferTypeDhcpNameUriDns][0] + 1;\r
-      \r
+\r
     } else if (Private->OfferCount[HttpOfferTypeDhcpOnly] > 0 &&\r
                Private->OfferCount[HttpOfferTypeProxyIpUri] > 0) {\r
-               \r
+\r
       Private->SelectIndex     = Private->OfferIndex[HttpOfferTypeDhcpOnly][0] + 1;\r
       Private->SelectProxyType = HttpOfferTypeProxyIpUri;\r
-      \r
+\r
     } else if (Private->OfferCount[HttpOfferTypeDhcpDns] > 0 &&\r
                Private->OfferCount[HttpOfferTypeProxyIpUri] > 0) {\r
-               \r
+\r
       Private->SelectIndex     = Private->OfferIndex[HttpOfferTypeDhcpDns][0] + 1;\r
       Private->SelectProxyType = HttpOfferTypeProxyIpUri;\r
-      \r
+\r
     } else if (Private->OfferCount[HttpOfferTypeDhcpDns] > 0 &&\r
                Private->OfferCount[HttpOfferTypeProxyNameUri] > 0) {\r
-               \r
+\r
       Private->SelectIndex     = Private->OfferIndex[HttpOfferTypeDhcpDns][0] + 1;\r
       Private->SelectProxyType = HttpOfferTypeProxyNameUri;\r
-      \r
+\r
     } else if (Private->OfferCount[HttpOfferTypeDhcpDns] > 0 &&\r
                Private->OfferCount[HttpOfferTypeDhcpNameUri] > 0) {\r
-               \r
+\r
       Private->SelectIndex     = Private->OfferIndex[HttpOfferTypeDhcpDns][0] + 1;\r
       Private->SelectProxyType = HttpOfferTypeDhcpNameUri;\r
     }\r
@@ -611,14 +608,14 @@ HttpBootDhcp4CallBack (
   EFI_STATUS                           Status;\r
   BOOLEAN                              Received;\r
 \r
-  if ((Dhcp4Event != Dhcp4SendDiscover) && \r
-      (Dhcp4Event != Dhcp4RcvdOffer) && \r
-      (Dhcp4Event != Dhcp4SendRequest) && \r
-      (Dhcp4Event != Dhcp4RcvdAck) && \r
+  if ((Dhcp4Event != Dhcp4SendDiscover) &&\r
+      (Dhcp4Event != Dhcp4RcvdOffer) &&\r
+      (Dhcp4Event != Dhcp4SendRequest) &&\r
+      (Dhcp4Event != Dhcp4RcvdAck) &&\r
       (Dhcp4Event != Dhcp4SelectOffer)) {\r
     return EFI_SUCCESS;\r
   }\r
-  \r
+\r
   Private = (HTTP_BOOT_PRIVATE_DATA *) Context;\r
 \r
   //\r
@@ -633,14 +630,14 @@ HttpBootDhcp4CallBack (
     Value = HTONS (HTTP_BOOT_DHCP4_PACKET_MAX_SIZE);\r
     CopyMem (MaxMsgSize->Data, &Value, sizeof (Value));\r
   }\r
-  \r
+\r
   //\r
   // Callback to user if any packets sent or received.\r
   //\r
   if (Private->HttpBootCallback != NULL && Dhcp4Event != Dhcp4SelectOffer) {\r
     Received = (BOOLEAN) (Dhcp4Event == Dhcp4RcvdOffer || Dhcp4Event == Dhcp4RcvdAck);\r
     Status = Private->HttpBootCallback->Callback (\r
-               Private->HttpBootCallback, \r
+               Private->HttpBootCallback,\r
                HttpBootDhcp4,\r
                Received,\r
                Packet->Length,\r
@@ -673,7 +670,7 @@ HttpBootDhcp4CallBack (
 \r
   case Dhcp4SelectOffer:\r
     //\r
-    // Select offer according to the priority in UEFI spec, and record the SelectIndex \r
+    // Select offer according to the priority in UEFI spec, and record the SelectIndex\r
     // and SelectProxyType.\r
     //\r
     HttpBootSelectDhcpOffer (Private);\r
@@ -684,7 +681,7 @@ HttpBootDhcp4CallBack (
       *NewPacket = &Private->OfferBuffer[Private->SelectIndex - 1].Dhcp4.Packet.Offer;\r
     }\r
     break;\r
-    \r
+\r
   default:\r
     break;\r
   }\r
@@ -694,7 +691,7 @@ HttpBootDhcp4CallBack (
 \r
 /**\r
   This function will register the IPv4 gateway address to the network device.\r
-  \r
+\r
   @param[in]  Private             The pointer to HTTP_BOOT_PRIVATE_DATA.\r
 \r
   @retval     EFI_SUCCESS         The new IP configuration has been configured successfully.\r
@@ -733,7 +730,7 @@ HttpBootRegisterIp4Gateway (
 \r
 /**\r
   This function will register the default DNS addresses to the network device.\r
-  \r
+\r
   @param[in]  Private             The pointer to HTTP_BOOT_PRIVATE_DATA.\r
   @param[in]  DataLength          Size of the buffer pointed to by DnsServerData in bytes.\r
   @param[in]  DnsServerData       Point a list of DNS server address in an array\r
@@ -751,11 +748,11 @@ HttpBootRegisterIp4Dns (
   )\r
 {\r
   EFI_IP4_CONFIG2_PROTOCOL        *Ip4Config2;\r
-  \r
+\r
   ASSERT (!Private->UsingIpv6);\r
 \r
   Ip4Config2 = Private->Ip4Config2;\r
-  \r
+\r
   return Ip4Config2->SetData (\r
                        Ip4Config2,\r
                        Ip4Config2DataTypeDnsServer,\r
@@ -807,7 +804,7 @@ HttpBootSetIp4Policy (
                           );\r
     if (EFI_ERROR (Status)) {\r
       return Status;\r
-    } \r
+    }\r
   }\r
 \r
   return EFI_SUCCESS;\r
@@ -834,7 +831,7 @@ HttpBootDhcp4Dora (
   EFI_DHCP4_CONFIG_DATA        Config;\r
   EFI_STATUS                   Status;\r
   EFI_DHCP4_MODE_DATA          Mode;\r
-  \r
+\r
   Dhcp4 = Private->Dhcp4;\r
   ASSERT (Dhcp4 != NULL);\r
 \r