Functions implementation related with DHCPv6 for UefiPxeBc Driver.\r
\r
(C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>\r
- Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
// Append client option request option\r
//\r
OptList[Index]->OpCode = HTONS (DHCP6_OPT_ORO);\r
- OptList[Index]->OpLen = HTONS (6);\r
+ OptList[Index]->OpLen = HTONS (8);\r
OptEnt.Oro = (PXEBC_DHCP6_OPTION_ORO *) OptList[Index]->Data;\r
OptEnt.Oro->OpCode[0] = HTONS(DHCP6_OPT_BOOT_FILE_URL);\r
OptEnt.Oro->OpCode[1] = HTONS(DHCP6_OPT_BOOT_FILE_PARAM);\r
OptEnt.Oro->OpCode[2] = HTONS(DHCP6_OPT_DNS_SERVERS);\r
+ OptEnt.Oro->OpCode[3] = HTONS(DHCP6_OPT_VENDOR_CLASS);\r
Index++;\r
OptList[Index] = GET_NEXT_DHCP6_OPTION (OptList[Index - 1]);\r
\r
if (ModeStr != NULL && *(ModeStr + AsciiStrLen (";mode=octet")) == '\0') {\r
*ModeStr = '\0';\r
} else if (AsciiStrStr (BootFileNamePtr, ";mode=") != NULL) {\r
+ FreePool (TmpStr);\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
UINT16 OpCode;\r
UINT16 OpLen;\r
EFI_STATUS Status;\r
- EFI_DHCP6_PACKET *ProxyOffer;\r
+ EFI_DHCP6_PACKET *IndexOffer;\r
UINT8 *Option;\r
\r
PxeBc = &Private->PxeBc;\r
Request = Private->Dhcp6Request;\r
- ProxyOffer = &Private->OfferBuffer[Index].Dhcp6.Packet.Offer;\r
+ IndexOffer = &Private->OfferBuffer[Index].Dhcp6.Packet.Offer;\r
SrcPort = PXEBC_BS_DISCOVER_PORT;\r
DestPort = PXEBC_BS_DISCOVER_PORT;\r
OpFlags = 0;\r
//\r
// Build the request packet by the cached request packet before.\r
//\r
- Discover->TransactionId = ProxyOffer->Dhcp6.Header.TransactionId;\r
+ Discover->TransactionId = IndexOffer->Dhcp6.Header.TransactionId;\r
Discover->MessageType = Request->Dhcp6.Header.MessageType;\r
RequestOpt = Request->Dhcp6.Option;\r
DiscoverOpt = Discover->DhcpOptions;\r
//\r
// Find Server ID Option from ProxyOffer.\r
//\r
- Option = PxeBcDhcp6SeekOption (\r
- ProxyOffer->Dhcp6.Option,\r
- ProxyOffer->Length - 4,\r
- DHCP6_OPT_SERVER_ID\r
- );\r
- if (Option == NULL) {\r
- return EFI_NOT_FOUND;\r
- }\r
+ if (Private->OfferBuffer[Index].Dhcp6.OfferType == PxeOfferTypeProxyBinl) { \r
+ Option = PxeBcDhcp6SeekOption (\r
+ IndexOffer->Dhcp6.Option,\r
+ IndexOffer->Length - 4,\r
+ DHCP6_OPT_SERVER_ID\r
+ );\r
+ if (Option == NULL) {\r
+ return EFI_NOT_FOUND;\r
+ }\r
\r
- //\r
- // Add Server ID Option.\r
- //\r
- OpLen = NTOHS (((EFI_DHCP6_PACKET_OPTION *) Option)->OpLen);\r
- CopyMem (DiscoverOpt, Option, OpLen + 4);\r
- DiscoverOpt += (OpLen + 4);\r
- DiscoverLen += (OpLen + 4);\r
+ //\r
+ // Add Server ID Option.\r
+ //\r
+ OpLen = NTOHS (((EFI_DHCP6_PACKET_OPTION *) Option)->OpLen);\r
+ CopyMem (DiscoverOpt, Option, OpLen + 4);\r
+ DiscoverOpt += (OpLen + 4);\r
+ DiscoverLen += (OpLen + 4);\r
+ }\r
\r
while (RequestLen < Request->Length) {\r
OpCode = NTOHS (((EFI_DHCP6_PACKET_OPTION *) RequestOpt)->OpCode);\r
);\r
\r
if (EFI_ERROR (Status)) {\r
- return Status;\r
+ goto ON_ERROR;\r
}\r
\r
//\r
//\r
Status = Private->Udp6Read->Configure (Private->Udp6Read, &Private->Udp6CfgData);\r
if (EFI_ERROR (Status)) {\r
- return Status;\r
+ goto ON_ERROR;\r
}\r
\r
Status = PxeBc->UdpRead (\r
Private->Udp6Read->Configure (Private->Udp6Read, NULL);\r
\r
if (EFI_ERROR (Status)) {\r
- return Status;\r
+ goto ON_ERROR;\r
}\r
\r
//\r
Reply->Length = (UINT32) ReadSize;\r
\r
return EFI_SUCCESS;\r
+ \r
+ON_ERROR:\r
+ if (Discover != NULL) {\r
+ FreePool (Discover);\r
+ }\r
+\r
+ return Status;\r
}\r
\r
\r
Mode = Private->PxeBc.Mode;\r
Private->IsDoDiscover = FALSE;\r
Offer = &Private->OfferBuffer[Index].Dhcp6;\r
- if (Offer->OfferType == PxeOfferTypeDhcpBinl) {\r
+ if (Offer->OptList[PXEBC_DHCP6_IDX_BOOT_FILE_URL] == NULL) {\r
//\r
// There is no BootFileUrl option in dhcp6 offer, so use servers multi-cast address instead.\r
//\r
SelectAd = &Private->OfferBuffer[Private->SelectIndex - 1].Dhcp6.Packet.Offer;\r
*NewPacket = AllocateZeroPool (SelectAd->Size);\r
ASSERT (*NewPacket != NULL);\r
+ if (*NewPacket == NULL) {\r
+ return EFI_ABORTED;\r
+ }\r
CopyMem (*NewPacket, SelectAd, SelectAd->Size);\r
}\r
break;\r
(VOID *) Discover\r
);\r
if (EFI_ERROR (Status)) {\r
- return Status;\r
+ goto ON_ERROR;\r
}\r
\r
//\r
//\r
Status = Private->Udp6Read->Configure (Private->Udp6Read, &Private->Udp6CfgData);\r
if (EFI_ERROR (Status)) {\r
- return Status;\r
+ goto ON_ERROR;\r
}\r
\r
Status = PxeBc->UdpRead (\r
//\r
Private->Udp6Read->Configure (Private->Udp6Read, NULL);\r
if (EFI_ERROR (Status)) {\r
- return Status;\r
+ goto ON_ERROR;\r
}\r
\r
return EFI_SUCCESS;\r
+\r
+ON_ERROR:\r
+ if (Discover != NULL) {\r
+ FreePool (Discover);\r
+ }\r
+\r
+ return Status;\r
}\r
\r
\r