]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.c
1. Define a netlib library function NetLibGetSystemGuid()
[mirror_edk2.git] / MdeModulePkg / Universal / Network / UefiPxeBcDxe / PxeBcDhcp.c
index efb7aac757f791c0fbc61e202c71d4026ae466c5..a9c86dc042bf1c2672843af73245a5a65a9d06e7 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Support for PxeBc dhcp functions.\r
 \r
-Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2011, 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
@@ -193,10 +193,11 @@ PxeBcParseCachedDhcpPacket (
     // RFC 2132, Section 9.5 does not strictly state Bootfile name (option 67) is null \r
     // terminated string. So force to append null terminated character at the end of string.\r
     //\r
-    ASSERT (Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] != NULL);\r
-    Ptr8 =  (UINT8*)&Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE]->Data[0];\r
-    Ptr8 += Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE]->Length;\r
-    Ptr8 =  '\0';\r
+    if (Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] != NULL) {\r
+      Ptr8 =  (UINT8*)&Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE]->Data[0];\r
+      Ptr8 += Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE]->Length;\r
+      *Ptr8 =  '\0';\r
+    }\r
 \r
   } else if ((Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] == NULL) &&\r
             (Offer->Dhcp4.Header.BootFileName[0] != 0)) {\r
@@ -787,7 +788,6 @@ PxeBcDhcpCallBack (
   UINT16                              Value;\r
   EFI_STATUS                          Status;\r
   BOOLEAN                             Received;\r
-  CHAR8                               *SystemSerialNumber;\r
   EFI_DHCP4_HEADER                    *DhcpHeader;\r
 \r
   if ((Dhcp4Event != Dhcp4RcvdOffer) &&\r
@@ -842,7 +842,7 @@ PxeBcDhcpCallBack (
       //\r
       DhcpHeader = &Packet->Dhcp4.Header;\r
 \r
-      if (EFI_ERROR (GetSmbiosSystemGuidAndSerialNumber ((EFI_GUID *) DhcpHeader->ClientHwAddr, &SystemSerialNumber))) {\r
+      if (EFI_ERROR (NetLibGetSystemGuid ((EFI_GUID *) DhcpHeader->ClientHwAddr))) {\r
         //\r
         // GUID not yet set - send all 0xff's to show programable (via SetVariable)\r
         // SetMem(DHCPV4_OPTIONS_BUFFER.DhcpPlatformId.Guid, sizeof(EFI_GUID), 0xff);\r
@@ -851,7 +851,7 @@ PxeBcDhcpCallBack (
         ZeroMem (DhcpHeader->ClientHwAddr, sizeof (EFI_GUID));\r
       }\r
 \r
-      DhcpHeader->HwAddrLen = sizeof (EFI_GUID);\r
+      DhcpHeader->HwAddrLen = (UINT8) sizeof (EFI_GUID);\r
     }\r
 \r
     if (Dhcp4Event == Dhcp4SendDiscover) {\r
@@ -927,7 +927,6 @@ PxeBcBuildDhcpOptions (
   UINT32                    Index;\r
   PXEBC_DHCP4_OPTION_ENTRY  OptEnt;\r
   UINT16                    Value;\r
-  CHAR8                     *SystemSerialNumber;\r
 \r
   Index       = 0;\r
   OptList[0]  = (EFI_DHCP4_PACKET_OPTION *) Private->OptionBuffer;\r
@@ -947,7 +946,7 @@ PxeBcBuildDhcpOptions (
     // Append max message size.\r
     //\r
     OptList[Index]->OpCode  = PXEBC_DHCP4_TAG_MAXMSG;\r
-    OptList[Index]->Length  = sizeof (PXEBC_DHCP4_OPTION_MAX_MESG_SIZE);\r
+    OptList[Index]->Length  = (UINT8) sizeof (PXEBC_DHCP4_OPTION_MAX_MESG_SIZE);\r
     OptEnt.MaxMesgSize      = (PXEBC_DHCP4_OPTION_MAX_MESG_SIZE *) OptList[Index]->Data;\r
     Value                   = NTOHS (PXEBC_DHCP4_MAX_PACKET_SIZE);\r
     CopyMem (&OptEnt.MaxMesgSize->Size, &Value, sizeof (UINT16));\r
@@ -1002,13 +1001,13 @@ PxeBcBuildDhcpOptions (
   // Append UUID/Guid-based client identifier option\r
   //\r
   OptList[Index]->OpCode  = PXEBC_PXE_DHCP4_TAG_UUID;\r
-  OptList[Index]->Length  = sizeof (PXEBC_DHCP4_OPTION_UUID);\r
+  OptList[Index]->Length  = (UINT8) sizeof (PXEBC_DHCP4_OPTION_UUID);\r
   OptEnt.Uuid             = (PXEBC_DHCP4_OPTION_UUID *) OptList[Index]->Data;\r
   OptEnt.Uuid->Type       = 0;\r
   Index++;\r
   OptList[Index]          = GET_NEXT_DHCP_OPTION (OptList[Index - 1]);\r
 \r
-  if (EFI_ERROR (GetSmbiosSystemGuidAndSerialNumber ((EFI_GUID *) OptEnt.Uuid->Guid, &SystemSerialNumber))) {\r
+  if (EFI_ERROR (NetLibGetSystemGuid ((EFI_GUID *) OptEnt.Uuid->Guid))) {\r
     //\r
     // GUID not yet set - send all 0xff's to show programable (via SetVariable)\r
     // SetMem(DHCPV4_OPTIONS_BUFFER.DhcpPlatformId.Guid, sizeof(EFI_GUID), 0xff);\r
@@ -1021,7 +1020,7 @@ PxeBcBuildDhcpOptions (
   // Append client network device interface option\r
   //\r
   OptList[Index]->OpCode  = PXEBC_PXE_DHCP4_TAG_UNDI;\r
-  OptList[Index]->Length  = sizeof (PXEBC_DHCP4_OPTION_UNDI);\r
+  OptList[Index]->Length  = (UINT8) sizeof (PXEBC_DHCP4_OPTION_UNDI);\r
   OptEnt.Undi             = (PXEBC_DHCP4_OPTION_UNDI *) OptList[Index]->Data;\r
   if (Private->Nii != NULL) {\r
     OptEnt.Undi->Type       = Private->Nii->Type;\r
@@ -1040,7 +1039,7 @@ PxeBcBuildDhcpOptions (
   // Append client system architecture option\r
   //\r
   OptList[Index]->OpCode  = PXEBC_PXE_DHCP4_TAG_ARCH;\r
-  OptList[Index]->Length  = sizeof (PXEBC_DHCP4_OPTION_ARCH);\r
+  OptList[Index]->Length  = (UINT8) sizeof (PXEBC_DHCP4_OPTION_ARCH);\r
   OptEnt.Arch             = (PXEBC_DHCP4_OPTION_ARCH *) OptList[Index]->Data;\r
   Value                   = HTONS (EFI_PXE_CLIENT_SYSTEM_ARCHITECTURE);\r
   CopyMem (&OptEnt.Arch->Type, &Value, sizeof (UINT16));\r
@@ -1051,7 +1050,7 @@ PxeBcBuildDhcpOptions (
   // Append client system architecture option\r
   //\r
   OptList[Index]->OpCode  = PXEBC_DHCP4_TAG_CLASS_ID;\r
-  OptList[Index]->Length  = sizeof (PXEBC_DHCP4_OPTION_CLID);\r
+  OptList[Index]->Length  = (UINT8) 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 (EFI_PXE_CLIENT_SYSTEM_ARCHITECTURE, OptEnt.Clid->ArchitectureType, sizeof (OptEnt.Clid->ArchitectureType));\r
@@ -1119,7 +1118,6 @@ PxeBcDiscvBootService (
   EFI_DHCP4_PACKET_OPTION             *PxeOpt;\r
   PXEBC_OPTION_BOOT_ITEM              *PxeBootItem;\r
   UINT8                               VendorOptLen;\r
-  CHAR8                               *SystemSerialNumber;\r
   EFI_DHCP4_HEADER                    *DhcpHeader;\r
   UINT32                              Xid;\r
 \r
@@ -1148,7 +1146,7 @@ PxeBcDiscvBootService (
     //\r
     // Add vendor option of PXE_BOOT_ITEM\r
     //\r
-    VendorOptLen      = (sizeof (EFI_DHCP4_PACKET_OPTION) - 1) * 2 + sizeof (PXEBC_OPTION_BOOT_ITEM) + 1;\r
+    VendorOptLen = (UINT8) ((sizeof (EFI_DHCP4_PACKET_OPTION) - 1) * 2 + sizeof (PXEBC_OPTION_BOOT_ITEM) + 1);\r
     OptList[OptCount] = AllocatePool (VendorOptLen);\r
     if (OptList[OptCount] == NULL) {\r
       return EFI_OUT_OF_RESOURCES;\r
@@ -1158,7 +1156,7 @@ PxeBcDiscvBootService (
     OptList[OptCount]->Length     = (UINT8) (VendorOptLen - 2);\r
     PxeOpt                        = (EFI_DHCP4_PACKET_OPTION *) OptList[OptCount]->Data;\r
     PxeOpt->OpCode                = PXEBC_VENDOR_TAG_BOOT_ITEM;\r
-    PxeOpt->Length                = sizeof (PXEBC_OPTION_BOOT_ITEM);\r
+    PxeOpt->Length                = (UINT8) sizeof (PXEBC_OPTION_BOOT_ITEM);\r
     PxeBootItem                   = (PXEBC_OPTION_BOOT_ITEM *) PxeOpt->Data;\r
     PxeBootItem->Type             = HTONS (Type);\r
     PxeBootItem->Layer            = HTONS (*Layer);\r
@@ -1179,14 +1177,14 @@ PxeBcDiscvBootService (
 \r
   DhcpHeader = &Token.Packet->Dhcp4.Header;\r
   if (Mode->SendGUID) {\r
-    if (EFI_ERROR (GetSmbiosSystemGuidAndSerialNumber ((EFI_GUID *) DhcpHeader->ClientHwAddr, &SystemSerialNumber))) {\r
+    if (EFI_ERROR (NetLibGetSystemGuid ((EFI_GUID *) DhcpHeader->ClientHwAddr))) {\r
       //\r
       // GUID not yet set - send all 0's to show not programable\r
       //\r
       ZeroMem (DhcpHeader->ClientHwAddr, sizeof (EFI_GUID));\r
     }\r
 \r
-    DhcpHeader->HwAddrLen = sizeof (EFI_GUID);\r
+    DhcpHeader->HwAddrLen = (UINT8) sizeof (EFI_GUID);\r
   }\r
 \r
   Xid                                 = NET_RANDOM (NetRandomInitSeed ());\r