X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FNetwork%2FUefiPxeBcDxe%2FPxeBcDhcp.c;h=5e86cf5779e6cc10e2789bc221dcaaad79820c5e;hp=ee17ea358dcaefee387db275ad217d5100e13460;hb=2ce5c88a7adaea3eeeccc932b18da5f02440f8cd;hpb=e48e37fce2611df7a52aff271835ff72ee396d9b diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.c b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.c index ee17ea358d..5e86cf5779 100644 --- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.c +++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.c @@ -1,6 +1,7 @@ /** @file - -Copyright (c) 2007, Intel Corporation + Support for PxeBc dhcp functions. + +Copyright (c) 2007 - 2009, Intel Corporation.
All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -9,15 +10,6 @@ http://opensource.org/licenses/bsd-license.php THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -Module Name: - - PxeBcDhcp.c - -Abstract: - - Support for PxeBc dhcp functions - - **/ @@ -38,12 +30,12 @@ UINT8 mInterestedDhcp4Tags[PXEBC_DHCP4_TAG_INDEX_MAX] = { /** - GC_NOTO: Add function description - - @param Seed GC_NOTO: add argument description - @param Udp4 GC_NOTO: add argument description + This function initialize the DHCP4 message instance. - @return GC_NOTO: add return values + This function will pad each item of dhcp4 message packet. + + @param Seed Pointer to the message instance of the DHCP4 packet. + @param Udp4 Pointer to the EFI_UDP4_PROTOCOL instance. **/ VOID @@ -74,12 +66,10 @@ PxeBcInitSeedPacket ( /** - GC_NOTO: Add function description + Copy the DCHP4 packet from srouce to destination. - @param Dst GC_NOTO: add argument description - @param Src GC_NOTO: add argument description - - @return GC_NOTO: add return values + @param Dst Pointer to the EFI_DHCP4_PROTOCOL instance. + @param Src Pointer to the EFI_DHCP4_PROTOCOL instance. **/ VOID @@ -96,12 +86,11 @@ PxeBcCopyEfiDhcp4Packet ( /** - GC_NOTO: Add function description - - @param Private GC_NOTO: add argument description - @param OfferIndex GC_NOTO: add argument description + Copy the dhcp4 packet to the PxeBc private data and parse the dhcp4 packet. - @return GC_NOTO: add return values + @param Private Pointer to PxeBc private data. + @param OfferIndex Index of cached packets as complements of pxe mode data, + the index is maximum offer number. **/ VOID @@ -114,6 +103,7 @@ PxeBcCopyProxyOffer ( EFI_DHCP4_PACKET *Offer; ASSERT (OfferIndex < Private->NumOffers); + ASSERT (OfferIndex < PXEBC_MAX_OFFER_NUM); Mode = Private->PxeBc.Mode; Offer = &Private->Dhcp4Offers[OfferIndex].Packet.Offer; @@ -129,10 +119,10 @@ PxeBcCopyProxyOffer ( /** Parse the cached dhcp packet. - @param CachedPacket Pointer to cached dhcp packet + @param CachedPacket Pointer to cached dhcp packet. - @return TRUE : Success to parse and validation - @return FALSE : Fail to parse or validation + @retval TRUE Succeed to parse and validation. + @retval FALSE Fail to parse or validation. **/ BOOLEAN @@ -206,7 +196,7 @@ PxeBcParseCachedDhcpPacket ( // And do not count dhcp option header, or else will destory the serverhostname. // Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] = (EFI_DHCP4_PACKET_OPTION *) (&Offer->Dhcp4.Header.BootFileName[0] - - EFI_FIELD_OFFSET (EFI_DHCP4_PACKET_OPTION, Data[0])); + OFFSET_OF (EFI_DHCP4_PACKET_OPTION, Data[0])); } @@ -256,13 +246,16 @@ PxeBcParseCachedDhcpPacket ( /** - GC_NOTO: Add function description - - @param Private GC_NOTO: add argument description - @param Index GC_NOTO: add argument description + Offer dhcp service with a BINL dhcp offer. - @return GC_NOTO: add return values + @param Private Pointer to PxeBc private data. + @param Index Index of cached packets as complements of pxe mode data, + the index is maximum offer number. + @retval TRUE Offer the service successfully under priority BINL. + @retval FALSE Boot Service failed, parse cached dhcp packet failed or this + BINL ack cannot find options set or bootfile name specified. + **/ BOOLEAN PxeBcTryBinl ( @@ -276,23 +269,31 @@ PxeBcTryBinl ( PXEBC_CACHED_DHCP4_PACKET *CachedPacket; EFI_DHCP4_PACKET *Reply; + ASSERT (Index < PXEBC_MAX_OFFER_NUM); ASSERT (Private->Dhcp4Offers[Index].OfferType == DHCP4_PACKET_TYPE_BINL); Offer = &Private->Dhcp4Offers[Index].Packet.Offer; - if (Offer->Dhcp4.Header.ServerAddr.Addr[0] == 0) { - // - // next server ip address is zero, use server id option instead. - // + + // + // Use siaddr(next server) in DHCPOFFER packet header, if zero, use option 54(server identifier) + // in DHCPOFFER packet. + // (It does not comply with PXE Spec, Ver2.1) + // + if (EFI_IP4_EQUAL (&Offer->Dhcp4.Header.ServerAddr.Addr, &mZeroIp4Addr)) { CopyMem ( &ServerIp.Addr[0], Private->Dhcp4Offers[Index].Dhcp4Option[PXEBC_DHCP4_TAG_INDEX_SERVER_ID]->Data, sizeof (EFI_IPv4_ADDRESS) ); } else { - // - // use next server ip address. - // - CopyMem (&ServerIp.Addr[0], &Offer->Dhcp4.Header.ServerAddr, sizeof (EFI_IPv4_ADDRESS)); + CopyMem ( + &ServerIp.Addr[0], + &Offer->Dhcp4.Header.ServerAddr, + sizeof (EFI_IPv4_ADDRESS) + ); + } + if (ServerIp.Addr[0] == 0) { + return FALSE; } CachedPacket = &Private->ProxyOffer; @@ -334,12 +335,13 @@ PxeBcTryBinl ( /** - GC_NOTO: Add function description + Offer dhcp service for each proxy with a BINL dhcp offer. - @param Private GC_NOTO: add argument description - @param OfferIndex GC_NOTO: add argument description + @param Private Pointer to PxeBc private data + @param OfferIndex Pointer to the index of cached packets as complements of + pxe mode data, the index is maximum offer number. - @return GC_NOTO: add return values + @return If there is no service needed offer return FALSE, otherwise TRUE. **/ BOOLEAN @@ -366,11 +368,14 @@ PxeBcTryBinlProxy ( /** - GC_NOTO: Add function description + This function is to check the selected proxy offer (include BINL dhcp offer and + DHCP_ONLY offer ) and set the flag and copy the DHCP packets to the Pxe base code + mode structure. - @param Private GC_NOTO: add argument description + @param Private Pointer to PxeBc private data. - @return GC_NOTO: add return values + @retval EFI_SUCCESS Operational successful. + @retval EFI_NO_RESPONSE Offer dhcp service failed. **/ EFI_STATUS @@ -401,72 +406,84 @@ PxeBcCheckSelectedOffer ( if (!PxeBcTryBinl (Private, Private->SelectedOffer - 1)) { Status = EFI_NO_RESPONSE; } - } else if ((SelectedOffer->OfferType == DHCP4_PACKET_TYPE_DHCP_ONLY) && - (Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] == NULL)) { + } else if (SelectedOffer->OfferType == DHCP4_PACKET_TYPE_DHCP_ONLY) { // - // The selected offer to finish the D.O.R.A. is a DHCP only offer and - // bootfile name is not provided in this offer, we need try proxy offers - // to get the bootfile name or the discovery info + // The selected offer to finish the D.O.R.A. is a DHCP only offer, we need + // try proxy offers if there are some, othewise the bootfile name must be + // set in this DHCP only offer. // - ProxyOfferIndex = Private->NumOffers; - - if (Private->SortOffers) { + if (Private->GotProxyOffer) { // - // Choose proxy offer from the type we stored during DHCP offer selection + // Get rid of the compiler warning. // - ASSERT (Private->ProxyIndex[Private->ProxyOfferType] > 0); - - if (Private->ProxyOfferType == DHCP4_PACKET_TYPE_BINL) { + ProxyOfferIndex = 0; + if (Private->SortOffers) { // - // We buffer all received BINL proxy offers, try them all one by one + // The offers are sorted before selecting, the proxy offer type must be + // already determined. // - if (!PxeBcTryBinlProxy (Private, &ProxyOfferIndex)) { - Status = EFI_NO_RESPONSE; + ASSERT (Private->ProxyIndex[Private->ProxyOfferType] > 0); + + if (Private->ProxyOfferType == DHCP4_PACKET_TYPE_BINL) { + // + // We buffer all received BINL proxy offers, try them all one by one + // + if (!PxeBcTryBinlProxy (Private, &ProxyOfferIndex)) { + Status = EFI_NO_RESPONSE; + } + } else { + // + // For other types, only one proxy offer is buffered. + // + ProxyOfferIndex = Private->ProxyIndex[Private->ProxyOfferType] - 1; } } else { // - // For other types, only one proxy offer is buffered. + // The proxy offer type is not determined, choose proxy offer in the + // received order. // - ProxyOfferIndex = Private->ProxyIndex[Private->ProxyOfferType] - 1; - } - } else { - // - // Choose proxy offer in the received order. - // - Status = EFI_NO_RESPONSE; - - for (Index = 0; Index < Private->NumOffers; Index++) { + Status = EFI_NO_RESPONSE; - Offer = &Private->Dhcp4Offers[Index].Packet.Offer; - if (!IS_PROXY_DHCP_OFFER (Offer)) { - // - // Skip non proxy dhcp offers. - // - continue; - } + for (Index = 0; Index < Private->NumOffers; Index++) { - if (Private->Dhcp4Offers[Index].OfferType == DHCP4_PACKET_TYPE_BINL) { - // - // Try BINL - // - if (!PxeBcTryBinl (Private, Index)) { + Offer = &Private->Dhcp4Offers[Index].Packet.Offer; + if (!IS_PROXY_DHCP_OFFER (Offer)) { // - // Failed, skip to the next offer + // Skip non proxy dhcp offers. // continue; } - } - Status = EFI_SUCCESS; - break; + if (Private->Dhcp4Offers[Index].OfferType == DHCP4_PACKET_TYPE_BINL) { + // + // Try BINL + // + if (!PxeBcTryBinl (Private, Index)) { + // + // Failed, skip to the next offer + // + continue; + } + } + + Private->ProxyOfferType = Private->Dhcp4Offers[Index].OfferType; + ProxyOfferIndex = Index; + Status = EFI_SUCCESS; + break; + } } - } - if (!EFI_ERROR (Status) && (Private->ProxyOfferType != DHCP4_PACKET_TYPE_BINL)) { + if (!EFI_ERROR (Status) && (Private->ProxyOfferType != DHCP4_PACKET_TYPE_BINL)) { + // + // Copy the proxy offer to Mode and set the flag + // + PxeBcCopyProxyOffer (Private, ProxyOfferIndex); + } + } else { // - // Copy the proxy offer to Mode and set the flag + // No proxy offer is received, the bootfile name MUST be set. // - PxeBcCopyProxyOffer (Private, ProxyOfferIndex); + ASSERT (Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] != NULL); } } @@ -506,12 +523,10 @@ PxeBcCheckSelectedOffer ( /** - GC_NOTO: Add function description + Cache the Dhcp4 packet offer, Parse and validate each option of the packet. - @param Private GC_NOTO: add argument description - @param RcvdOffer GC_NOTO: add argument description - - @return GC_NOTO: add return values + @param Private Pointer to PxeBc private data. + @param RcvdOffer Pointer to the received Dhcp proxy offer packet. **/ VOID @@ -540,6 +555,7 @@ PxeBcCacheDhcpOffer ( } OfferType = CachedOffer->OfferType; + ASSERT (OfferType < DHCP4_PACKET_TYPE_MAX); if (OfferType == DHCP4_PACKET_TYPE_BOOTP) { @@ -560,6 +576,8 @@ PxeBcCacheDhcpOffer ( // // It's a proxy dhcp offer with no your address, including pxe10, wfm11a or binl offer. // + Private->GotProxyOffer = TRUE; + if (OfferType == DHCP4_PACKET_TYPE_BINL) { // // Cache all binl offers. @@ -581,6 +599,7 @@ PxeBcCacheDhcpOffer ( // // It's a dhcp offer with your address. // + ASSERT (Private->ServerCount[OfferType] < PXEBC_MAX_OFFER_NUM); Private->OfferIndex[OfferType][Private->ServerCount[OfferType]] = Private->NumOffers; Private->ServerCount[OfferType]++; } @@ -594,11 +613,10 @@ PxeBcCacheDhcpOffer ( /** - GC_NOTO: Add function description - - @param Private GC_NOTO: add argument description - - @return GC_NOTO: add return values + Select the specified proxy offer, such as BINL, DHCP_ONLY and so on. + If the proxy does not exist, try offers with bootfile. + + @param Private Pointer to PxeBc private data. **/ VOID @@ -609,7 +627,6 @@ PxeBcSelectOffer ( UINT32 Index; UINT32 OfferIndex; EFI_DHCP4_PACKET *Offer; - BOOLEAN GotProxyOffer; Private->SelectedOffer = 0; @@ -688,15 +705,6 @@ PxeBcSelectOffer ( // // Try the offers in the received order. // - GotProxyOffer = FALSE; - for (Index = 0; Index < DHCP4_PACKET_TYPE_MAX; Index++) { - - GotProxyOffer = (BOOLEAN) (Private->ProxyIndex[Index] > 0); - if (GotProxyOffer) { - break; - } - } - for (Index = 0; Index < Private->NumOffers; Index++) { Offer = &Private->Dhcp4Offers[Index].Packet.Offer; @@ -709,7 +717,7 @@ PxeBcSelectOffer ( } if ((Private->Dhcp4Offers[Index].OfferType == DHCP4_PACKET_TYPE_DHCP_ONLY) && - ((!GotProxyOffer) && (Private->Dhcp4Offers[Index].Dhcp4Option[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] == NULL))) { + ((!Private->GotProxyOffer) && (Private->Dhcp4Offers[Index].Dhcp4Option[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] == NULL))) { // // DHCP only offer but no proxy offer received and no bootfile option in this offer // @@ -724,20 +732,36 @@ PxeBcSelectOffer ( /** - GC_NOTO: Add function description - - @param This GC_NOTO: add argument description - @param Context GC_NOTO: add argument description - @param CurrentState GC_NOTO: add argument description - @param Dhcp4Event GC_NOTO: add argument description - @param Packet GC_NOTO: add argument description - @param NewPacket GC_NOTO: add argument description - - @retval EFI_SUCCESS GC_NOTO: Add description for return value - @retval EFI_ABORTED GC_NOTO: Add description for return value + Callback routine. + + EFI_DHCP4_CALLBACK is provided by the consumer of the EFI DHCPv4 Protocol driver + to intercept events that occurred in the configuration process. This structure + provides advanced control of each state transition of the DHCP process. The + returned status code determines the behavior of the EFI DHCPv4 Protocol driver. + There are three possible returned values, which are described in the following + table. + + @param This Pointer to the EFI DHCPv4 Protocol instance that is used to + configure this callback function. + @param Context Pointer to the context that is initialized by + EFI_DHCP4_PROTOCOL.Configure(). + @param CurrentState The current operational state of the EFI DHCPv4 Protocol + driver. + @param Dhcp4Event The event that occurs in the current state, which usually means a + state transition. + @param Packet The DHCP packet that is going to be sent or already received. + @param NewPacket The packet that is used to replace the above Packet. + + @retval EFI_SUCCESS Tells the EFI DHCPv4 Protocol driver to continue the DHCP process. + @retval EFI_NOT_READY Only used in the Dhcp4Selecting state. The EFI DHCPv4 Protocol + driver will continue to wait for more DHCPOFFER packets until the retry + timeout expires. + @retval EFI_ABORTED Tells the EFI DHCPv4 Protocol driver to abort the current process and + return to the Dhcp4Init or Dhcp4InitReboot state. **/ EFI_STATUS +EFIAPI PxeBcDhcpCallBack ( IN EFI_DHCP4_PROTOCOL * This, IN VOID *Context, @@ -754,11 +778,14 @@ PxeBcDhcpCallBack ( UINT16 Value; EFI_STATUS Status; BOOLEAN Received; + CHAR8 *SystemSerialNumber; + EFI_DHCP4_HEADER *DhcpHeader; if ((Dhcp4Event != Dhcp4RcvdOffer) && (Dhcp4Event != Dhcp4SelectOffer) && (Dhcp4Event != Dhcp4SendDiscover) && - (Dhcp4Event != Dhcp4RcvdAck)) { + (Dhcp4Event != Dhcp4RcvdAck) && + (Dhcp4Event != Dhcp4SendRequest)) { return EFI_SUCCESS; } @@ -798,10 +825,32 @@ PxeBcDhcpCallBack ( switch (Dhcp4Event) { case Dhcp4SendDiscover: - // - // Cache the dhcp discover packet, of which some information will be used later. - // - CopyMem (Mode->DhcpDiscover.Raw, &Packet->Dhcp4, Packet->Length); + case Dhcp4SendRequest: + if (Mode->SendGUID) { + // + // send the system GUID instead of the MAC address as the hardware address + // in the DHCP packet header. + // + DhcpHeader = &Packet->Dhcp4.Header; + + if (EFI_ERROR (GetSmbiosSystemGuidAndSerialNumber ((EFI_GUID *) DhcpHeader->ClientHwAddr, &SystemSerialNumber))) { + // + // GUID not yet set - send all 0xff's to show programable (via SetVariable) + // SetMem(DHCPV4_OPTIONS_BUFFER.DhcpPlatformId.Guid, sizeof(EFI_GUID), 0xff); + // GUID not yet set - send all 0's to show not programable + // + ZeroMem (DhcpHeader->ClientHwAddr, sizeof (EFI_GUID)); + } + + DhcpHeader->HwAddrLen = sizeof (EFI_GUID); + } + + if (Dhcp4Event == Dhcp4SendDiscover) { + // + // Cache the dhcp discover packet, of which some information will be used later. + // + CopyMem (Mode->DhcpDiscover.Raw, &Packet->Dhcp4, Packet->Length); + } break; @@ -839,6 +888,9 @@ PxeBcDhcpCallBack ( PxeBcCopyEfiDhcp4Packet (&Private->Dhcp4Ack.Packet.Ack, Packet); break; + + default: + break; } return Status; @@ -846,13 +898,14 @@ PxeBcDhcpCallBack ( /** - GC_NOTO: Add function description + Initialize the DHCP options and build the option list. - @param Private GC_NOTO: add argument description - @param OptList GC_NOTO: add argument description - @param IsDhcpDiscover GC_NOTO: add argument description + @param Private Pointer to PxeBc private data. + @param OptList Pointer to a DHCP option list. + + @param IsDhcpDiscover Discover dhcp option or not. - @return GC_NOTO: add return values + @return The index item number of the option list. **/ UINT32 @@ -961,9 +1014,15 @@ PxeBcBuildDhcpOptions ( OptList[Index]->OpCode = PXEBC_PXE_DHCP4_TAG_UNDI; OptList[Index]->Length = sizeof (PXEBC_DHCP4_OPTION_UNDI); OptEnt.Undi = (PXEBC_DHCP4_OPTION_UNDI *) OptList[Index]->Data; - OptEnt.Undi->Type = Private->Nii->Type; - OptEnt.Undi->MajorVer = Private->Nii->MajorVer; - OptEnt.Undi->MinorVer = Private->Nii->MinorVer; + if (Private->Nii != NULL) { + OptEnt.Undi->Type = Private->Nii->Type; + OptEnt.Undi->MajorVer = Private->Nii->MajorVer; + OptEnt.Undi->MinorVer = Private->Nii->MinorVer; + } else { + OptEnt.Undi->Type = DEFAULT_UNDI_TYPE; + OptEnt.Undi->MajorVer = DEFAULT_UNDI_MAJOR; + OptEnt.Undi->MinorVer = DEFAULT_UNDI_MINOR; + } Index++; OptList[Index] = GET_NEXT_DHCP_OPTION (OptList[Index - 1]); @@ -987,9 +1046,16 @@ PxeBcBuildDhcpOptions ( OptEnt.Clid = (PXEBC_DHCP4_OPTION_CLID *) OptList[Index]->Data; CopyMem (OptEnt.Clid, DEFAULT_CLASS_ID_DATA, sizeof (PXEBC_DHCP4_OPTION_CLID)); CvtNum (SYS_ARCH, OptEnt.Clid->ArchitectureType, sizeof (OptEnt.Clid->ArchitectureType)); - CopyMem (OptEnt.Clid->InterfaceName, Private->Nii->StringId, sizeof (OptEnt.Clid->InterfaceName)); - CvtNum (Private->Nii->MajorVer, OptEnt.Clid->UndiMajor, sizeof (OptEnt.Clid->UndiMajor)); - CvtNum (Private->Nii->MinorVer, OptEnt.Clid->UndiMinor, sizeof (OptEnt.Clid->UndiMinor)); + + if (Private->Nii != NULL) { + // + // If NII protocol exists, update DHCP option data + // + CopyMem (OptEnt.Clid->InterfaceName, Private->Nii->StringId, sizeof (OptEnt.Clid->InterfaceName)); + CvtNum (Private->Nii->MajorVer, OptEnt.Clid->UndiMajor, sizeof (OptEnt.Clid->UndiMajor)); + CvtNum (Private->Nii->MinorVer, OptEnt.Clid->UndiMinor, sizeof (OptEnt.Clid->UndiMinor)); + } + Index++; return Index; @@ -997,20 +1063,23 @@ PxeBcBuildDhcpOptions ( /** - GC_NOTO: Add function description - - @param Private GC_NOTO: add argument description - @param Type GC_NOTO: add argument description - @param Layer GC_NOTO: add argument description - @param UseBis GC_NOTO: add argument description - @param DestIp GC_NOTO: add argument description - @param IpCount GC_NOTO: add argument description - @param SrvList GC_NOTO: add argument description - @param IsDiscv GC_NOTO: add argument description - @param Reply GC_NOTO: add argument description - - @retval EFI_OUT_OF_RESOURCES GC_NOTO: Add description for return value - + Discover the boot of service and initialize the vendor option if exists. + + @param Private Pointer to PxeBc private data. + @param Type PxeBc option boot item type + @param Layer PxeBc option boot item layer + @param UseBis Use BIS or not + @param DestIp Ip address for server + @param IpCount The total count of the server ip address + @param SrvList Server list + @param IsDiscv Discover the vendor or not + @param Reply The dhcp4 packet of Pxe reply + + @retval EFI_SUCCESS Operation succeeds. + @retval EFI_OUT_OF_RESOURCES Allocate memory pool failed. + @retval EFI_NOT_FOUND There is no vendor option exists. + @retval EFI_TIMEOUT Send Pxe Discover time out. + **/ EFI_STATUS PxeBcDiscvBootService ( @@ -1041,6 +1110,9 @@ PxeBcDiscvBootService ( EFI_DHCP4_PACKET_OPTION *PxeOpt; PXEBC_OPTION_BOOT_ITEM *PxeBootItem; UINT8 VendorOptLen; + CHAR8 *SystemSerialNumber; + EFI_DHCP4_HEADER *DhcpHeader; + UINT32 Xid; Mode = Private->PxeBc.Mode; Dhcp4 = Private->Dhcp4; @@ -1063,6 +1135,7 @@ PxeBcDiscvBootService ( OptCount = PxeBcBuildDhcpOptions (Private, OptList, FALSE); if (IsDiscv) { + ASSERT (Layer != NULL); // // Add vendor option of PXE_BOOT_ITEM // @@ -1095,13 +1168,26 @@ PxeBcDiscvBootService ( return Status; } - Token.Packet->Dhcp4.Header.Xid = NET_RANDOM (NetRandomInitSeed ()); - Token.Packet->Dhcp4.Header.Reserved = (UINT16) ((IsBCast) ? 0xf000 : 0x0); + DhcpHeader = &Token.Packet->Dhcp4.Header; + if (Mode->SendGUID) { + if (EFI_ERROR (GetSmbiosSystemGuidAndSerialNumber ((EFI_GUID *) DhcpHeader->ClientHwAddr, &SystemSerialNumber))) { + // + // GUID not yet set - send all 0's to show not programable + // + ZeroMem (DhcpHeader->ClientHwAddr, sizeof (EFI_GUID)); + } + + DhcpHeader->HwAddrLen = sizeof (EFI_GUID); + } + + Xid = NET_RANDOM (NetRandomInitSeed ()); + Token.Packet->Dhcp4.Header.Xid = HTONL(Xid); + Token.Packet->Dhcp4.Header.Reserved = HTONS((IsBCast) ? 0x8000 : 0); CopyMem (&Token.Packet->Dhcp4.Header.ClientAddr, &Private->StationIp, sizeof (EFI_IPv4_ADDRESS)); Token.RemotePort = Sport; - if (DestIp == NULL) { + if (IsBCast) { SetMem (&Token.RemoteAddress, sizeof (EFI_IPv4_ADDRESS), 0xff); } else { CopyMem (&Token.RemoteAddress, DestIp, sizeof (EFI_IPv4_ADDRESS)); @@ -1121,7 +1207,8 @@ PxeBcDiscvBootService ( // for (TryIndex = 1; TryIndex <= PXEBC_BOOT_REQUEST_RETRIES; TryIndex++) { - Token.TimeoutValue = PXEBC_BOOT_REQUEST_TIMEOUT * TryIndex; + Token.TimeoutValue = (UINT16) (PXEBC_BOOT_REQUEST_TIMEOUT * TryIndex); + Token.Packet->Dhcp4.Header.Seconds = (UINT16) (PXEBC_BOOT_REQUEST_TIMEOUT * (TryIndex - 1)); Status = Dhcp4->TransmitReceive (Dhcp4, &Token); @@ -1195,13 +1282,14 @@ PxeBcDiscvBootService ( /** - GC_NOTO: Add function description + Parse interested dhcp options. - @param Buffer GC_NOTO: add argument description - @param Length GC_NOTO: add argument description - @param OptTag GC_NOTO: add argument description + @param Buffer Pointer to the dhcp options packet. + @param Length The length of the dhcp options. + @param OptTag The option OpCode. - @return GC_NOTO: add return values + @return NULL if the buffer length is 0 and OpCode is not + PXEBC_DHCP4_TAG_EOP, or the pointer to the buffer. **/ EFI_DHCP4_PACKET_OPTION * @@ -1243,8 +1331,7 @@ PxeBcParseExtendOptions ( @param Dhcp4Option Pointer to dhcp options @param VendorOption Pointer to vendor options - @return TRUE : Valid vendor options - @return FALSE : Invalid vendor options + @return TRUE if valid for vendor options, or FALSE. **/ BOOLEAN @@ -1362,12 +1449,12 @@ PxeBcParseVendorOptions ( /** - GC_NOTO: Add function description - - @param Str GC_NOTO: add argument description - @param Len GC_NOTO: add argument description + This function display boot item detail. - @return GC_NOTO: add return values + If the length of the boot item string over 70 Char, just display 70 Char. + + @param Str Pointer to a string (boot item string). + @param Len The length of string. **/ VOID @@ -1387,13 +1474,16 @@ PxeBcDisplayBootItem ( /** - GC_NOTO: Add function description - - @param Private GC_NOTO: add argument description + Choose the boot prompt. - @retval EFI_SUCCESS GC_NOTO: Add description for return value - @retval EFI_TIMEOUT GC_NOTO: Add description for return value + @param Private Pointer to PxeBc private data. + @retval EFI_SUCCESS Select boot prompt done. + @retval EFI_TIMEOUT Select boot prompt time out. + @retval EFI_NOT_FOUND The proxy offer is not Pxe10. + @retval EFI_ABORTED User cancel the operation. + @retval EFI_NOT_READY Read the input key from the keybroad has not finish. + **/ EFI_STATUS PxeBcSelectBootPrompt ( @@ -1562,13 +1652,15 @@ ON_EXIT: /** - GC_NOTO: Add function description + Select the boot menu. - @param Private GC_NOTO: add argument description - @param Type GC_NOTO: add argument description - - @retval EFI_ABORTED GC_NOTO: Add description for return value - @retval EFI_SUCCESS GC_NOTO: Add description for return value + @param Private Pointer to PxeBc private data. + @param Type The type of the menu. + @param UseDefaultItem Use default item or not. + + @retval EFI_ABORTED User cancel operation. + @retval EFI_SUCCESS Select the boot menu success. + @retval EFI_NOT_READY Read the input key from the keybroad has not finish. **/ EFI_STATUS @@ -1618,15 +1710,22 @@ PxeBcSelectBootMenu ( MenuSize = VendorOpt->BootMenuLen; MenuItem = VendorOpt->BootMenu; + if (MenuSize == 0) { + return EFI_NOT_READY; + } + while (MenuSize > 0) { - MenuArray[Index] = MenuItem; + MenuArray[Index++] = MenuItem; MenuSize = (UINT8) (MenuSize - (MenuItem->DescLen + 3)); MenuItem = (PXEBC_BOOT_MENU_ENTRY *) ((UINT8 *) MenuItem + MenuItem->DescLen + 3); - Index++; + if (Index >= PXEBC_MAX_MENU_NUM) { + break; + } } if (UseDefaultItem) { - *Type = NTOHS (MenuArray[0]->Type); + *Type = MenuArray[0]->Type; + *Type = NTOHS (*Type); return EFI_SUCCESS; } @@ -1639,6 +1738,7 @@ PxeBcSelectBootMenu ( TopRow = gST->ConOut->Mode->CursorRow - MenuNum; do { + ASSERT (Select < PXEBC_MAX_MENU_NUM); // // highlight selected row // @@ -1686,7 +1786,7 @@ PxeBcSelectBootMenu ( switch (InputKey.ScanCode) { case SCAN_LEFT: case SCAN_UP: - if (Select) { + if (Select > 0) { --Select; } @@ -1726,7 +1826,8 @@ PxeBcSelectBootMenu ( // // Swap the byte order // - *Type = NTOHS (MenuArray[Select]->Type); + CopyMem (Type, &MenuArray[Select]->Type, sizeof (UINT16)); + *Type = NTOHS (*Type); return EFI_SUCCESS; }