]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.c
Fixed the issue of duplicated SYS_ARCH in MdeModulePkg\UefiPxeBcDxe.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / UefiPxeBcDxe / PxeBcDhcp.c
index 5e86cf5779e6cc10e2789bc221dcaaad79820c5e..f2d8eecfe2b1cb335a65f8064db5670723259e48 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Support for PxeBc dhcp functions.\r
-  \r
-Copyright (c) 2007 - 2009, Intel Corporation.<BR>                                                         \r
+\r
+Copyright (c) 2007 - 2010, 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
@@ -33,7 +33,7 @@ UINT8 mInterestedDhcp4Tags[PXEBC_DHCP4_TAG_INDEX_MAX] = {
   This function initialize the DHCP4 message instance.\r
 \r
   This function will pad each item of dhcp4 message packet.\r
-  \r
+\r
   @param  Seed    Pointer to the message instance of the DHCP4 packet.\r
   @param  Udp4    Pointer to the EFI_UDP4_PROTOCOL instance.\r
 \r
@@ -181,7 +181,7 @@ PxeBcParseCachedDhcpPacket (
   // serverhostname option.\r
   //\r
   Option = Options[PXEBC_DHCP4_TAG_INDEX_OVERLOAD];\r
-  if ((Option != NULL) && (Option->Data[0] & PXEBC_DHCP4_OVERLOAD_FILE)) {\r
+  if ((Option != NULL) && ((Option->Data[0] & PXEBC_DHCP4_OVERLOAD_FILE) != 0)) {\r
 \r
     Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] = PxeBcParseExtendOptions (\r
                                                 (UINT8 *) Offer->Dhcp4.Header.BootFileName,\r
@@ -253,9 +253,9 @@ PxeBcParseCachedDhcpPacket (
                     the index is maximum offer number.\r
 \r
   @retval TRUE      Offer the service successfully under priority BINL.\r
-  @retval FALSE     Boot Service failed, parse cached dhcp packet failed or this \r
+  @retval FALSE     Boot Service failed, parse cached dhcp packet failed or this\r
                     BINL ack cannot find options set or bootfile name specified.\r
-  \r
+\r
 **/\r
 BOOLEAN\r
 PxeBcTryBinl (\r
@@ -287,8 +287,8 @@ PxeBcTryBinl (
       );\r
   } else {\r
     CopyMem (\r
-      &ServerIp.Addr[0], \r
-      &Offer->Dhcp4.Header.ServerAddr, \r
+      &ServerIp.Addr[0],\r
+      &Offer->Dhcp4.Header.ServerAddr,\r
       sizeof (EFI_IPv4_ADDRESS)\r
       );\r
   }\r
@@ -338,7 +338,7 @@ PxeBcTryBinl (
   Offer dhcp service for each proxy with a BINL dhcp offer.\r
 \r
   @param  Private     Pointer to PxeBc private data\r
-  @param  OfferIndex  Pointer to the index of cached packets as complements of \r
+  @param  OfferIndex  Pointer to the index of cached packets as complements of\r
                       pxe mode data, the index is maximum offer number.\r
 \r
   @return If there is no service needed offer return FALSE, otherwise TRUE.\r
@@ -408,8 +408,8 @@ PxeBcCheckSelectedOffer (
     }\r
   } else if (SelectedOffer->OfferType == DHCP4_PACKET_TYPE_DHCP_ONLY) {\r
     //\r
-    // The selected offer to finish the D.O.R.A. is a DHCP only offer, we need \r
-    // try proxy offers if there are some, othewise the bootfile name must be \r
+    // The selected offer to finish the D.O.R.A. is a DHCP only offer, we need\r
+    // try proxy offers if there are some, othewise the bootfile name must be\r
     // set in this DHCP only offer.\r
     //\r
     if (Private->GotProxyOffer) {\r
@@ -439,7 +439,7 @@ PxeBcCheckSelectedOffer (
         }\r
       } else {\r
         //\r
-        // The proxy offer type is not determined, choose proxy offer in the \r
+        // The proxy offer type is not determined, choose proxy offer in the\r
         // received order.\r
         //\r
         Status = EFI_NO_RESPONSE;\r
@@ -615,7 +615,7 @@ PxeBcCacheDhcpOffer (
 /**\r
   Select the specified proxy offer, such as BINL, DHCP_ONLY and so on.\r
   If the proxy does not exist, try offers with bootfile.\r
-  \r
+\r
   @param  Private   Pointer to PxeBc private data.\r
 \r
 **/\r
@@ -733,7 +733,7 @@ PxeBcSelectOffer (
 \r
 /**\r
   Callback routine.\r
-  \r
+\r
   EFI_DHCP4_CALLBACK is provided by the consumer of the EFI DHCPv4 Protocol driver\r
   to intercept events that occurred in the configuration process. This structure\r
   provides advanced control of each state transition of the DHCP process. The\r
@@ -902,8 +902,8 @@ PxeBcDhcpCallBack (
 \r
   @param  Private          Pointer to PxeBc private data.\r
   @param  OptList          Pointer to a DHCP option list.\r
-                           \r
-  @param  IsDhcpDiscover   Discover dhcp option or not.     \r
+\r
+  @param  IsDhcpDiscover   Discover dhcp option or not.\r
 \r
   @return The index item number of the option list.\r
 \r
@@ -1033,7 +1033,7 @@ PxeBcBuildDhcpOptions (
   OptList[Index]->OpCode  = PXEBC_PXE_DHCP4_TAG_ARCH;\r
   OptList[Index]->Length  = sizeof (PXEBC_DHCP4_OPTION_ARCH);\r
   OptEnt.Arch             = (PXEBC_DHCP4_OPTION_ARCH *) OptList[Index]->Data;\r
-  Value                   = HTONS (SYS_ARCH);\r
+  Value                   = HTONS (EFI_PXE_CLIENT_SYSTEM_ARCHITECTURE);\r
   CopyMem (&OptEnt.Arch->Type, &Value, sizeof (UINT16));\r
   Index++;\r
   OptList[Index]          = GET_NEXT_DHCP_OPTION (OptList[Index - 1]);\r
@@ -1045,10 +1045,10 @@ PxeBcBuildDhcpOptions (
   OptList[Index]->Length  = sizeof (PXEBC_DHCP4_OPTION_CLID);\r
   OptEnt.Clid             = (PXEBC_DHCP4_OPTION_CLID *) OptList[Index]->Data;\r
   CopyMem (OptEnt.Clid, DEFAULT_CLASS_ID_DATA, sizeof (PXEBC_DHCP4_OPTION_CLID));\r
-  CvtNum (SYS_ARCH, OptEnt.Clid->ArchitectureType, sizeof (OptEnt.Clid->ArchitectureType));\r
+  CvtNum (EFI_PXE_CLIENT_SYSTEM_ARCHITECTURE, OptEnt.Clid->ArchitectureType, sizeof (OptEnt.Clid->ArchitectureType));\r
 \r
   if (Private->Nii != NULL) {\r
-    // \r
+    //\r
     // If NII protocol exists, update DHCP option data\r
     //\r
     CopyMem (OptEnt.Clid->InterfaceName, Private->Nii->StringId, sizeof (OptEnt.Clid->InterfaceName));\r
@@ -1069,8 +1069,8 @@ PxeBcBuildDhcpOptions (
   @param  Type                  PxeBc option boot item type\r
   @param  Layer                 PxeBc option boot item layer\r
   @param  UseBis                Use BIS or not\r
-  @param  DestIp                Ip address for server      \r
-  @param  IpCount               The total count of the server ip address    \r
+  @param  DestIp                Ip address for server\r
+  @param  IpCount               The total count of the server ip address\r
   @param  SrvList               Server list\r
   @param  IsDiscv               Discover the vendor or not\r
   @param  Reply                 The dhcp4 packet of Pxe reply\r
@@ -1078,8 +1078,8 @@ PxeBcBuildDhcpOptions (
   @retval EFI_SUCCESS           Operation succeeds.\r
   @retval EFI_OUT_OF_RESOURCES  Allocate memory pool failed.\r
   @retval EFI_NOT_FOUND         There is no vendor option exists.\r
-  @retval EFI_TIMEOUT           Send Pxe Discover time out. \r
-  \r
+  @retval EFI_TIMEOUT           Send Pxe Discover time out.\r
+\r
 **/\r
 EFI_STATUS\r
 PxeBcDiscvBootService (\r
@@ -1161,7 +1161,7 @@ PxeBcDiscvBootService (
   Status = Dhcp4->Build (Dhcp4, &Private->SeedPacket, 0, NULL, OptCount, OptList, &Token.Packet);\r
 \r
   if (IsDiscv) {\r
-    gBS->FreePool (OptList[OptCount - 1]);\r
+    FreePool (OptList[OptCount - 1]);\r
   }\r
 \r
   if (EFI_ERROR (Status)) {\r
@@ -1179,10 +1179,10 @@ PxeBcDiscvBootService (
 \r
     DhcpHeader->HwAddrLen = sizeof (EFI_GUID);\r
   }\r
-       \r
+\r
   Xid                                 = NET_RANDOM (NetRandomInitSeed ());\r
   Token.Packet->Dhcp4.Header.Xid      = HTONL(Xid);\r
-  Token.Packet->Dhcp4.Header.Reserved = HTONS((IsBCast) ? 0x8000 : 0);\r
+  Token.Packet->Dhcp4.Header.Reserved = HTONS((UINT16) ((IsBCast) ? 0x8000 : 0));\r
   CopyMem (&Token.Packet->Dhcp4.Header.ClientAddr, &Private->StationIp, sizeof (EFI_IPv4_ADDRESS));\r
 \r
   Token.RemotePort = Sport;\r
@@ -1270,12 +1270,12 @@ PxeBcDiscvBootService (
     //\r
     // free the responselist\r
     //\r
-    gBS->FreePool (Token.ResponseList);\r
+    FreePool (Token.ResponseList);\r
   }\r
   //\r
   // Free the dhcp packet\r
   //\r
-  gBS->FreePool (Token.Packet);\r
+  FreePool (Token.Packet);\r
 \r
   return Status;\r
 }\r
@@ -1288,7 +1288,7 @@ PxeBcDiscvBootService (
   @param  Length     The length of the dhcp options.\r
   @param  OptTag     The option OpCode.\r
 \r
-  @return NULL if the buffer length is 0 and OpCode is not \r
+  @return NULL if the buffer length is 0 and OpCode is not\r
           PXEBC_DHCP4_TAG_EOP, or the pointer to the buffer.\r
 \r
 **/\r
@@ -1451,8 +1451,8 @@ PxeBcParseVendorOptions (
 /**\r
   This function display boot item detail.\r
 \r
-  If the length of the boot item string over 70 Char, just display 70 Char. \r
-   \r
+  If the length of the boot item string over 70 Char, just display 70 Char.\r
+\r
   @param  Str     Pointer to a string (boot item string).\r
   @param  Len     The length of string.\r
 \r
@@ -1479,11 +1479,11 @@ PxeBcDisplayBootItem (
   @param  Private              Pointer to PxeBc private data.\r
 \r
   @retval EFI_SUCCESS          Select boot prompt done.\r
-  @retval EFI_TIMEOUT          Select boot prompt time out. \r
+  @retval EFI_TIMEOUT          Select boot prompt time out.\r
   @retval EFI_NOT_FOUND        The proxy offer is not Pxe10.\r
   @retval EFI_ABORTED          User cancel the operation.\r
   @retval EFI_NOT_READY        Read the input key from the keybroad has not finish.\r
-  \r
+\r
 **/\r
 EFI_STATUS\r
 PxeBcSelectBootPrompt (\r
@@ -1657,10 +1657,10 @@ ON_EXIT:
   @param  Private         Pointer to PxeBc private data.\r
   @param  Type            The type of the menu.\r
   @param  UseDefaultItem  Use default item or not.\r
-  \r
+\r
   @retval EFI_ABORTED     User cancel operation.\r
   @retval EFI_SUCCESS     Select the boot menu success.\r
-  @retval EFI_NOT_READY   Read the input key from the keybroad has not finish.    \r
+  @retval EFI_NOT_READY   Read the input key from the keybroad has not finish.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -1671,7 +1671,7 @@ PxeBcSelectBootMenu (
   )\r
 {\r
   PXEBC_CACHED_DHCP4_PACKET  *Packet;\r
-  PXEBC_VENDOR_OPTION       *VendorOpt;\r
+  PXEBC_VENDOR_OPTION        *VendorOpt;\r
   EFI_INPUT_KEY              InputKey;\r
   UINT8                      MenuSize;\r
   UINT8                      MenuNum;\r
@@ -1754,7 +1754,7 @@ PxeBcSelectBootMenu (
       gBS->Stall (10 * TICKS_PER_MS);\r
     }\r
 \r
-    if (!InputKey.ScanCode) {\r
+    if (InputKey.ScanCode != 0) {\r
       switch (InputKey.UnicodeChar) {\r
       case CTRL ('c'):\r
         InputKey.ScanCode = SCAN_ESC;\r