15UINT8 mInterestedDhcp4Tags[PXEBC_DHCP4_TAG_INDEX_MAX] = {
16 DHCP4_TAG_BOOTFILE_LEN,
21 DHCP4_TAG_VENDOR_CLASS_ID,
28UINT32 mPxeDhcpTimeout[4] = { 4, 8, 16, 32 };
54 while (Offset < Length && Option->OpCode != DHCP4_TAG_EOP) {
55 if (Option->
OpCode == OptTag) {
68 Offset += Option->
Length + 2;
91 UINT8 VendorOptionLen;
95 BitMap = VendorOption->BitMap;
96 VendorOptionLen = Dhcp4Option->
Length;
100 ASSERT (PxeOption !=
NULL);
102 while ((Offset < VendorOptionLen) && (PxeOption->
OpCode != DHCP4_TAG_EOP)) {
106 switch (PxeOption->
OpCode) {
107 case PXEBC_VENDOR_TAG_MTFTP_IP:
112 case PXEBC_VENDOR_TAG_MTFTP_CPORT:
114 CopyMem (&VendorOption->MtftpCPort, PxeOption->
Data, sizeof (VendorOption->MtftpCPort));
117 case PXEBC_VENDOR_TAG_MTFTP_SPORT:
119 CopyMem (&VendorOption->MtftpSPort, PxeOption->
Data, sizeof (VendorOption->MtftpSPort));
122 case PXEBC_VENDOR_TAG_MTFTP_TIMEOUT:
124 VendorOption->MtftpTimeout = *PxeOption->
Data;
127 case PXEBC_VENDOR_TAG_MTFTP_DELAY:
129 VendorOption->MtftpDelay = *PxeOption->
Data;
132 case PXEBC_VENDOR_TAG_DISCOVER_CTRL:
134 VendorOption->DiscoverCtrl = *PxeOption->
Data;
137 case PXEBC_VENDOR_TAG_DISCOVER_MCAST:
142 case PXEBC_VENDOR_TAG_BOOT_SERVERS:
144 VendorOption->BootSvrLen = PxeOption->
Length;
148 case PXEBC_VENDOR_TAG_BOOT_MENU:
150 VendorOption->BootMenuLen = PxeOption->
Length;
154 case PXEBC_VENDOR_TAG_MENU_PROMPT:
156 VendorOption->MenuPromptLen = PxeOption->
Length;
160 case PXEBC_VENDOR_TAG_MCAST_ALLOC:
163 CopyMem (&VendorOption->McastIpBlock, PxeOption->
Data + 4, sizeof (VendorOption->McastIpBlock));
164 CopyMem (&VendorOption->McastIpRange, PxeOption->
Data + 6, sizeof (VendorOption->McastIpRange));
167 case PXEBC_VENDOR_TAG_CREDENTIAL_TYPES:
169 VendorOption->CredTypeLen = PxeOption->
Length;
170 VendorOption->CredType = (UINT32 *)PxeOption->
Data;
173 case PXEBC_VENDOR_TAG_BOOT_ITEM:
175 CopyMem (&VendorOption->BootSrvType, PxeOption->
Data, sizeof (VendorOption->BootSrvType));
176 CopyMem (&VendorOption->BootSrvLayer, PxeOption->
Data + 2, sizeof (VendorOption->BootSrvLayer));
189 SET_VENDOR_OPTION_BIT_MAP (BitMap, PxeOption->
OpCode);
197 Offset = (UINT8)(Offset + PxeOption->
Length + 2);
221 IN BOOLEAN NeedMsgType
235 OptList[Index]->OpCode = DHCP4_TAG_MSG_TYPE;
236 OptList[Index]->Length = 1;
238 OptEnt.Mesg->Type = PXEBC_DHCP4_MSG_TYPE_REQUEST;
240 OptList[Index] = GET_NEXT_DHCP_OPTION (OptList[Index - 1]);
245 OptList[Index]->OpCode = DHCP4_TAG_MAXMSG;
248 Value = NTOHS (PXEBC_DHCP4_PACKET_MAX_SIZE);
249 CopyMem (&OptEnt.MaxMesgSize->Size, &Value, sizeof (UINT16));
251 OptList[Index] = GET_NEXT_DHCP_OPTION (OptList[Index - 1]);
257 OptList[Index]->OpCode = DHCP4_TAG_PARA_LIST;
258 OptList[Index]->Length = 35;
260 OptEnt.Para->ParaList[0] = DHCP4_TAG_NETMASK;
261 OptEnt.Para->ParaList[1] = DHCP4_TAG_TIME_OFFSET;
262 OptEnt.Para->ParaList[2] = DHCP4_TAG_ROUTER;
263 OptEnt.Para->ParaList[3] = DHCP4_TAG_TIME_SERVER;
264 OptEnt.Para->ParaList[4] = DHCP4_TAG_NAME_SERVER;
265 OptEnt.Para->ParaList[5] = DHCP4_TAG_DNS_SERVER;
266 OptEnt.Para->ParaList[6] = DHCP4_TAG_HOSTNAME;
267 OptEnt.Para->ParaList[7] = DHCP4_TAG_BOOTFILE_LEN;
268 OptEnt.Para->ParaList[8] = DHCP4_TAG_DOMAINNAME;
269 OptEnt.Para->ParaList[9] = DHCP4_TAG_ROOTPATH;
270 OptEnt.Para->ParaList[10] = DHCP4_TAG_EXTEND_PATH;
271 OptEnt.Para->ParaList[11] = DHCP4_TAG_EMTU;
272 OptEnt.Para->ParaList[12] = DHCP4_TAG_TTL;
273 OptEnt.Para->ParaList[13] = DHCP4_TAG_BROADCAST;
274 OptEnt.Para->ParaList[14] = DHCP4_TAG_NIS_DOMAIN;
275 OptEnt.Para->ParaList[15] = DHCP4_TAG_NIS_SERVER;
276 OptEnt.Para->ParaList[16] = DHCP4_TAG_NTP_SERVER;
277 OptEnt.Para->ParaList[17] = DHCP4_TAG_VENDOR;
278 OptEnt.Para->ParaList[18] = DHCP4_TAG_REQUEST_IP;
279 OptEnt.Para->ParaList[19] = DHCP4_TAG_LEASE;
280 OptEnt.Para->ParaList[20] = DHCP4_TAG_SERVER_ID;
281 OptEnt.Para->ParaList[21] = DHCP4_TAG_T1;
282 OptEnt.Para->ParaList[22] = DHCP4_TAG_T2;
283 OptEnt.Para->ParaList[23] = DHCP4_TAG_VENDOR_CLASS_ID;
284 OptEnt.Para->ParaList[24] = DHCP4_TAG_TFTP;
285 OptEnt.Para->ParaList[25] = DHCP4_TAG_BOOTFILE;
286 OptEnt.Para->ParaList[26] = DHCP4_TAG_UUID;
287 OptEnt.Para->ParaList[27] = 0x80;
288 OptEnt.Para->ParaList[28] = 0x81;
289 OptEnt.Para->ParaList[29] = 0x82;
290 OptEnt.Para->ParaList[30] = 0x83;
291 OptEnt.Para->ParaList[31] = 0x84;
292 OptEnt.Para->ParaList[32] = 0x85;
293 OptEnt.Para->ParaList[33] = 0x86;
294 OptEnt.Para->ParaList[34] = 0x87;
296 OptList[Index] = GET_NEXT_DHCP_OPTION (OptList[Index - 1]);
301 OptList[Index]->OpCode = DHCP4_TAG_UUID;
304 OptEnt.Uuid->Type = 0;
306 OptList[Index] = GET_NEXT_DHCP_OPTION (OptList[Index - 1]);
312 DEBUG ((DEBUG_WARN,
"PXE: Failed to read system GUID from the smbios table!\n"));
319 OptList[Index]->OpCode = DHCP4_TAG_UNDI;
323 if (Private->Nii !=
NULL) {
324 OptEnt.Undi->Type = Private->Nii->Type;
325 OptEnt.Undi->MajorVer = Private->Nii->MajorVer;
326 OptEnt.Undi->MinorVer = Private->Nii->MinorVer;
328 OptEnt.Undi->Type = DEFAULT_UNDI_TYPE;
329 OptEnt.Undi->MajorVer = DEFAULT_UNDI_MAJOR;
330 OptEnt.Undi->MinorVer = DEFAULT_UNDI_MINOR;
334 OptList[Index] = GET_NEXT_DHCP_OPTION (OptList[Index - 1]);
339 OptList[Index]->OpCode = DHCP4_TAG_ARCH;
342 Value = HTONS (EFI_PXE_CLIENT_SYSTEM_ARCHITECTURE);
343 CopyMem (&OptEnt.Arch->Type, &Value, sizeof (UINT16));
345 OptList[Index] = GET_NEXT_DHCP_OPTION (OptList[Index - 1]);
350 OptList[Index]->OpCode = DHCP4_TAG_VENDOR_CLASS_ID;
355 DEFAULT_CLASS_ID_DATA,
359 EFI_PXE_CLIENT_SYSTEM_ARCHITECTURE,
360 OptEnt.Clid->ArchitectureType,
361 sizeof (OptEnt.Clid->ArchitectureType)
364 if (Private->Nii !=
NULL) {
365 CopyMem (OptEnt.Clid->InterfaceName, Private->Nii->StringId, sizeof (OptEnt.Clid->InterfaceName));
397 Seed->Length =
sizeof (Seed->Dhcp4);
398 Header = &Seed->Dhcp4.Header;
400 Header->OpCode = PXEBC_DHCP4_OPCODE_REQUEST;
401 Header->HwType = Mode.
IfType;
405 Seed->Dhcp4.Magik = PXEBC_DHCP4_MAGIC;
406 Seed->Dhcp4.Option[0] = DHCP4_TAG_EOP;
425 if (Dst->Size < Src->Length) {
426 return EFI_BUFFER_TOO_SMALL;
429 CopyMem (&Dst->Dhcp4, &Src->Dhcp4, Src->Length);
430 Dst->Length = Src->Length;
452 PXEBC_OFFER_TYPE OfferType;
454 BOOLEAN IsProxyOffer;
457 BOOLEAN FileFieldOverloaded;
459 IsProxyOffer =
FALSE;
461 FileFieldOverloaded =
FALSE;
463 ZeroMem (Cache4->OptList, sizeof (Cache4->OptList));
464 ZeroMem (&Cache4->VendorOpt, sizeof (Cache4->VendorOpt));
466 Offer = &Cache4->Packet.Offer;
467 Options = Cache4->OptList;
473 for (Index = 0; Index < PXEBC_DHCP4_TAG_INDEX_MAX; Index++) {
476 GET_OPTION_BUFFER_LEN (Offer),
477 mInterestedDhcp4Tags[Index]
485 Option = Options[PXEBC_DHCP4_TAG_INDEX_OVERLOAD];
486 if (Option !=
NULL) {
487 if ((Option->
Data[0] & PXEBC_DHCP4_OVERLOAD_FILE) != 0) {
488 FileFieldOverloaded =
TRUE;
489 for (Index = 0; Index < PXEBC_DHCP4_TAG_INDEX_MAX; Index++) {
490 if (Options[Index] ==
NULL) {
492 (UINT8 *)Offer->Dhcp4.
Header.BootFileName,
493 sizeof (Offer->Dhcp4.
Header.BootFileName),
494 mInterestedDhcp4Tags[Index]
500 if ((Option->
Data[0] & PXEBC_DHCP4_OVERLOAD_SERVER_NAME) != 0) {
501 for (Index = 0; Index < PXEBC_DHCP4_TAG_INDEX_MAX; Index++) {
502 if (Options[Index] ==
NULL) {
504 (UINT8 *)Offer->Dhcp4.
Header.ServerName,
505 sizeof (Offer->Dhcp4.
Header.ServerName),
506 mInterestedDhcp4Tags[Index]
523 Option = Options[PXEBC_DHCP4_TAG_INDEX_CLASS_ID];
524 if ((Option !=
NULL) && (Option->
Length >= 9) &&
533 Option = Options[PXEBC_DHCP4_TAG_INDEX_VENDOR];
534 if (IsPxeOffer && (Option !=
NULL)) {
543 if (Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] !=
NULL) {
548 Ptr8 = (UINT8 *)&Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE]->Data[0];
549 Ptr8 += Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE]->Length;
550 if (*(Ptr8 - 1) !=
'\0') {
553 }
else if (!FileFieldOverloaded && (Offer->Dhcp4.
Header.BootFileName[0] != 0)) {
559 (&Offer->Dhcp4.
Header.BootFileName[0] -
566 Option = Options[PXEBC_DHCP4_TAG_INDEX_MSG_TYPE];
567 if ((Option ==
NULL) || (Option->
Data[0] == 0)) {
571 OfferType = PxeOfferTypeBootp;
573 Option = Cache4->OptList[PXEBC_DHCP4_TAG_INDEX_BOOTFILE];
574 if (Option ==
NULL) {
578 return EFI_DEVICE_ERROR;
581 if (IS_VALID_DISCOVER_VENDOR_OPTION (Cache4->VendorOpt.BitMap)) {
585 OfferType = IsProxyOffer ? PxeOfferTypeProxyPxe10 : PxeOfferTypeDhcpPxe10;
586 }
else if (IS_VALID_MTFTP_VENDOR_OPTION (Cache4->VendorOpt.BitMap)) {
591 return EFI_DEVICE_ERROR;
592 }
else if (IsPxeOffer) {
596 OfferType = IsProxyOffer ? PxeOfferTypeProxyBinl : PxeOfferTypeDhcpBinl;
601 OfferType = PxeOfferTypeDhcpOnly;
605 Cache4->OfferType = OfferType;
631 Mode = Private->PxeBc.Mode;
634 if (EFI_ERROR (Status)) {
643 CopyMem (&Mode->DhcpAck.Dhcpv4, &Ack->Dhcp4, Ack->Length);
644 Mode->DhcpAckReceived =
TRUE;
670 ASSERT (OfferIndex < Private->OfferNum);
671 ASSERT (OfferIndex < PXEBC_OFFER_MAX_NUM);
673 Mode = Private->PxeBc.Mode;
674 Offer = &Private->OfferBuffer[OfferIndex].Dhcp4.Packet.Offer;
680 if (EFI_ERROR (Status)) {
689 CopyMem (&Mode->ProxyOffer.Dhcpv4, &Offer->Dhcp4, Offer->
Length);
690 Mode->ProxyOfferReceived =
TRUE;
717 ASSERT (Index < PXEBC_OFFER_MAX_NUM);
719 Private->OfferBuffer[Index].Dhcp4.OfferType == PxeOfferTypeDhcpBinl ||
720 Private->OfferBuffer[Index].Dhcp4.OfferType == PxeOfferTypeProxyBinl
723 Offer = &Private->OfferBuffer[Index].Dhcp4.Packet.Offer;
731 Private->OfferBuffer[Index].Dhcp4.OptList[PXEBC_DHCP4_TAG_INDEX_SERVER_ID]->Data,
742 Private->IsDoDiscover =
FALSE;
743 Cache4 = &Private->ProxyOffer.Dhcp4;
744 Reply = &Cache4->Packet.Offer;
758 if (EFI_ERROR (Status)) {
766 if (EFI_ERROR (Status)) {
770 if ((Cache4->OfferType != PxeOfferTypeProxyPxe10) &&
771 (Cache4->OfferType != PxeOfferTypeProxyWfm11a) &&
772 (Cache4->OptList[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] ==
NULL))
778 return EFI_DEVICE_ERROR;
784 Private->PxeBc.Mode->ProxyOfferReceived =
TRUE;
785 CopyMem (&Private->PxeBc.Mode->ProxyOffer.Dhcpv4, &Reply->Dhcp4, Reply->
Length);
808 PXEBC_OFFER_TYPE OfferType;
811 ASSERT (Private->OfferNum < PXEBC_OFFER_MAX_NUM);
812 Cache4 = &Private->OfferBuffer[Private->OfferNum].Dhcp4;
813 Offer = &Cache4->Packet.Offer;
819 if (EFI_ERROR (Status)) {
833 OfferType = Cache4->OfferType;
834 ASSERT (OfferType < PxeOfferTypeMax);
836 if (OfferType == PxeOfferTypeBootp) {
840 if (Private->OfferCount[OfferType] == 0) {
841 Private->OfferIndex[OfferType][0] = Private->OfferNum;
842 Private->OfferCount[OfferType] = 1;
847 ASSERT (Private->OfferCount[OfferType] < PXEBC_OFFER_MAX_NUM);
848 if (IS_PROXY_DHCP_OFFER (Offer)) {
852 Private->IsProxyRecved =
TRUE;
854 if (OfferType == PxeOfferTypeProxyBinl) {
858 Private->OfferIndex[OfferType][Private->OfferCount[OfferType]] = Private->OfferNum;
859 Private->OfferCount[OfferType]++;
860 }
else if (((OfferType == PxeOfferTypeProxyPxe10) || (OfferType == PxeOfferTypeProxyWfm11a)) &&
861 (Private->OfferCount[OfferType] < 1))
866 Private->OfferIndex[OfferType][0] = Private->OfferNum;
867 Private->OfferCount[OfferType] = 1;
875 Private->OfferIndex[OfferType][Private->OfferCount[OfferType]] = Private->OfferNum;
876 Private->OfferCount[OfferType]++;
900 Private->SelectIndex = 0;
902 if (Private->IsOfferSorted) {
906 if (Private->OfferCount[PxeOfferTypeDhcpPxe10] > 0) {
910 Private->SelectIndex = Private->OfferIndex[PxeOfferTypeDhcpPxe10][0] + 1;
911 }
else if (Private->OfferCount[PxeOfferTypeDhcpWfm11a] > 0) {
915 Private->SelectIndex = Private->OfferIndex[PxeOfferTypeDhcpWfm11a][0] + 1;
916 }
else if ((Private->OfferCount[PxeOfferTypeDhcpOnly] > 0) &&
917 (Private->OfferCount[PxeOfferTypeProxyPxe10] > 0))
922 Private->SelectIndex = Private->OfferIndex[PxeOfferTypeDhcpOnly][0] + 1;
923 Private->SelectProxyType = PxeOfferTypeProxyPxe10;
924 }
else if ((Private->OfferCount[PxeOfferTypeDhcpOnly] > 0) &&
925 (Private->OfferCount[PxeOfferTypeProxyWfm11a] > 0))
930 Private->SelectIndex = Private->OfferIndex[PxeOfferTypeDhcpOnly][0] + 1;
931 Private->SelectProxyType = PxeOfferTypeProxyWfm11a;
932 }
else if (Private->OfferCount[PxeOfferTypeDhcpBinl] > 0) {
936 Private->SelectIndex = Private->OfferIndex[PxeOfferTypeDhcpBinl][0] + 1;
937 }
else if ((Private->OfferCount[PxeOfferTypeDhcpOnly] > 0) &&
938 (Private->OfferCount[PxeOfferTypeProxyBinl] > 0))
943 Private->SelectIndex = Private->OfferIndex[PxeOfferTypeDhcpOnly][0] + 1;
944 Private->SelectProxyType = PxeOfferTypeProxyBinl;
949 for (Index = 0; Index < Private->OfferCount[PxeOfferTypeDhcpOnly]; Index++) {
950 OfferIndex = Private->OfferIndex[PxeOfferTypeDhcpOnly][Index];
951 if (Private->OfferBuffer[OfferIndex].Dhcp4.OptList[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] !=
NULL) {
952 Private->SelectIndex = OfferIndex + 1;
960 OfferIndex = Private->OfferIndex[PxeOfferTypeBootp][0];
961 if ((Private->SelectIndex == 0) &&
962 (Private->OfferCount[PxeOfferTypeBootp] > 0) &&
963 (Private->OfferBuffer[OfferIndex].Dhcp4.OptList[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] !=
NULL))
965 Private->SelectIndex = OfferIndex + 1;
972 for (Index = 0; Index < Private->OfferNum; Index++) {
973 Offer = &Private->OfferBuffer[Index].Dhcp4.Packet.Offer;
975 if (IS_PROXY_DHCP_OFFER (Offer)) {
982 if (!Private->IsProxyRecved &&
983 (Private->OfferBuffer[Index].Dhcp4.OfferType == PxeOfferTypeDhcpOnly) &&
984 (Private->OfferBuffer[Index].Dhcp4.OptList[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] ==
NULL))
995 Private->SelectIndex = Index + 1;
1021 PXEBC_OFFER_TYPE OfferType;
1028 ASSERT (Private->SelectIndex > 0);
1029 SelectIndex = (UINT32)(Private->SelectIndex - 1);
1030 ASSERT (SelectIndex < PXEBC_OFFER_MAX_NUM);
1031 Cache4 = &Private->OfferBuffer[SelectIndex].Dhcp4;
1032 Options = Cache4->OptList;
1035 if (Cache4->OfferType == PxeOfferTypeDhcpBinl) {
1040 Status = EFI_NO_RESPONSE;
1042 }
else if (Cache4->OfferType == PxeOfferTypeDhcpOnly) {
1043 if (Private->IsProxyRecved) {
1048 if (Private->IsOfferSorted) {
1053 ASSERT (Private->SelectProxyType < PxeOfferTypeMax);
1054 ASSERT (Private->OfferCount[Private->SelectProxyType] > 0);
1056 if (Private->SelectProxyType == PxeOfferTypeProxyBinl) {
1060 for (Index = 0; Index < Private->OfferCount[Private->SelectProxyType]; Index++) {
1061 ASSERT (Index < PXEBC_OFFER_MAX_NUM);
1062 ProxyIndex = Private->OfferIndex[Private->SelectProxyType][Index];
1068 if (Index == Private->OfferCount[Private->SelectProxyType]) {
1069 Status = EFI_NO_RESPONSE;
1075 ProxyIndex = Private->OfferIndex[Private->SelectProxyType][0];
1081 Status = EFI_NO_RESPONSE;
1083 for (Index = 0; Index < Private->OfferNum; Index++) {
1084 ASSERT (Index < PXEBC_OFFER_MAX_NUM);
1085 Offer = &Private->OfferBuffer[Index].Dhcp4.Packet.Offer;
1086 OfferType = Private->OfferBuffer[Index].Dhcp4.OfferType;
1087 if (!IS_PROXY_DHCP_OFFER (Offer)) {
1094 if (OfferType == PxeOfferTypeProxyBinl) {
1103 Private->SelectProxyType = OfferType;
1110 if (!EFI_ERROR (Status) && (Private->SelectProxyType != PxeOfferTypeProxyBinl)) {
1120 if (Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] ==
NULL) {
1121 Status = EFI_NOT_FOUND;
1126 if (!EFI_ERROR (Status)) {
1130 Mode = Private->PxeBc.Mode;
1131 Offer = &Cache4->Packet.Offer;
1132 Ack = &Private->DhcpAck.Dhcp4.Packet.Ack;
1133 if (Cache4->OfferType == PxeOfferTypeBootp) {
1142 if (EFI_ERROR (Status)) {
1146 Mode->DhcpDiscoverValid =
TRUE;
1199 ASSERT (Packet !=
NULL);
1202 Mode = Private->PxeBc.
Mode;
1203 Callback = Private->PxeBcCallback;
1209 Packet->Dhcp4.Option,
1210 GET_OPTION_BUFFER_LEN (Packet),
1213 if (MaxMsgSize !=
NULL) {
1214 Value = HTONS (PXEBC_DHCP4_PACKET_MAX_SIZE);
1215 CopyMem (MaxMsgSize->
Data, &Value, sizeof (Value));
1223 Status = Callback->Callback (
1230 if (Status != EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE) {
1237 switch (Dhcp4Event) {
1239 if (Packet->Length > PXEBC_DHCP4_PACKET_MAX_SIZE) {
1243 Status = EFI_ABORTED;
1251 CopyMem (&Mode->DhcpDiscover.Dhcpv4, &Packet->Dhcp4, Packet->Length);
1254 if (Packet->Length > PXEBC_DHCP4_PACKET_MAX_SIZE) {
1258 Status = EFI_ABORTED;
1262 if (Mode->SendGUID) {
1270 DEBUG ((DEBUG_WARN,
"PXE: Failed to read system GUID from the smbios table!\n"));
1274 Packet->Dhcp4.Header.HwAddrLen = (UINT8)
sizeof (
EFI_GUID);
1280 Status = EFI_NOT_READY;
1281 if (Packet->Length > PXEBC_DHCP4_PACKET_MAX_SIZE) {
1288 if (Private->OfferNum < PXEBC_OFFER_MAX_NUM) {
1300 ASSERT (NewPacket !=
NULL);
1308 if (Private->SelectIndex == 0) {
1309 Status = EFI_ABORTED;
1311 *NewPacket = &Private->OfferBuffer[Private->SelectIndex - 1].Dhcp4.Packet.Offer;
1321 ASSERT (Private->SelectIndex != 0);
1324 if (EFI_ERROR (Status)) {
1325 Status = EFI_ABORTED;
1365 EFI_PXE_BASE_CODE_UDP_PORT Sport;
1376 UINT8 Buffer[PXEBC_DHCP4_OPTION_MAX_SIZE];
1385 if (EFI_ERROR (Status)) {
1386 DEBUG ((DEBUG_ERROR,
"%a failed to generate random number: %r\n", __func__, Status));
1390 Mode = Private->PxeBc.Mode;
1391 Dhcp4 = Private->Dhcp4;
1399 if (DestIp ==
NULL) {
1400 Sport = PXEBC_DHCP4_S_PORT;
1403 Sport = PXEBC_BS_DISCOVER_PORT;
1407 if (!UseBis && (Layer !=
NULL)) {
1408 *Layer &= EFI_PXE_BASE_CODE_BOOT_LAYER_MASK;
1416 if (Private->IsDoDiscover) {
1422 if (OptList[OptCount] ==
NULL) {
1423 return EFI_OUT_OF_RESOURCES;
1426 OptList[OptCount]->
OpCode = DHCP4_TAG_VENDOR;
1427 OptList[OptCount]->
Length = (UINT8)(VendorOptLen - 2);
1429 PxeOpt->
OpCode = PXEBC_VENDOR_TAG_BOOT_ITEM;
1432 PxeBootItem->Type = HTONS (Type);
1433 PxeOpt->
Data[PxeOpt->
Length] = DHCP4_TAG_EOP;
1435 if (Layer !=
NULL) {
1436 PxeBootItem->Layer = HTONS (*Layer);
1445 Status = Dhcp4->Build (
1447 &Private->SeedPacket,
1457 if (Private->IsDoDiscover) {
1461 if (EFI_ERROR (Status)) {
1465 if (Mode->SendGUID) {
1470 DEBUG ((DEBUG_WARN,
"PXE: Failed to read system GUID from the smbios table!\n"));
1481 Token.
Packet->Dhcp4.
Header.Reserved = HTONS ((UINT16)((IsBCast) ? 0x8000 : 0x0));
1505 for (TryIndex = 1; TryIndex <= PXEBC_BOOT_REQUEST_RETRIES; TryIndex++) {
1506 Token.
TimeoutValue = (UINT16)(PXEBC_BOOT_REQUEST_TIMEOUT * TryIndex);
1507 Token.
Packet->Dhcp4.
Header.Seconds = (UINT16)(PXEBC_BOOT_REQUEST_TIMEOUT * (TryIndex - 1));
1509 Status = Dhcp4->TransmitReceive (Dhcp4, &Token);
1510 if (Token.
Status != EFI_TIMEOUT) {
1515 if (TryIndex > PXEBC_BOOT_REQUEST_RETRIES) {
1519 Status = EFI_TIMEOUT;
1522 if (!EFI_ERROR (Status)) {
1530 if (Response->
Length > PXEBC_DHCP4_PACKET_MAX_SIZE) {
1537 while (SrvIndex < IpCount) {
1538 if (SrvList[SrvIndex].AcceptAnyResponse) {
1542 if ((SrvList[SrvIndex].Type == Type) &&
1543 EFI_IP4_EQUAL (&Response->Dhcp4.
Header.
ServerAddr, &SrvList[SrvIndex].IpAddr))
1551 if ((IpCount != SrvIndex) || (IpCount == 0)) {
1565 if (Private->IsDoDiscover) {
1567 if (EFI_ERROR (Status)) {
1574 if (EFI_ERROR (Status)) {
1582 Status = EFI_NOT_FOUND;
1618 Ip4Config2 = Private->Ip4Config2;
1620 Status = Ip4Config2->GetData (
1626 if (EFI_ERROR (Status)) {
1632 Status = Ip4Config2->SetData (
1638 if (EFI_ERROR (Status)) {
1666 UINT8 Buffer[PXEBC_DHCP4_OPTION_MAX_SIZE];
1670 ASSERT (Dhcp4 !=
NULL);
1673 PxeMode = Private->PxeBc.Mode;
1679 ASSERT (OptCount > 0);
1694 Status = Dhcp4->Configure (Dhcp4, &Config);
1695 if (EFI_ERROR (Status)) {
1702 Private->IsProxyRecved =
FALSE;
1703 Private->OfferNum = 0;
1704 ZeroMem (Private->OfferCount, sizeof (Private->OfferCount));
1705 ZeroMem (Private->OfferIndex, sizeof (Private->OfferIndex));
1707 Status = Dhcp4->Start (Dhcp4,
NULL);
1708 if (EFI_ERROR (Status)) {
1709 if (Status == EFI_ICMP_ERROR) {
1710 PxeMode->IcmpErrorReceived =
TRUE;
1713 if ((Status == EFI_TIMEOUT) && (Private->OfferNum > 0)) {
1714 Status = EFI_NO_RESPONSE;
1723 Status = Dhcp4->GetModeData (Dhcp4, &Mode);
1724 if (EFI_ERROR (Status)) {
1737 if (EFI_ERROR (Status)) {
1752 if (EFI_ERROR (Status)) {
1753 Dhcp4->Stop (Dhcp4);
1754 Dhcp4->Configure (Dhcp4,
NULL);
1757 Dhcp4->Configure (Dhcp4, &Config);
1758 Private->IsAddressOk =
TRUE;
INTN EFIAPI CompareMem(IN CONST VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI SetMem(OUT VOID *Buffer, IN UINTN Length, IN UINT8 Value)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
@ Ip4Config2DataTypePolicy
#define OFFSET_OF(TYPE, Field)
#define DEBUG(Expression)
EFI_STATUS EFIAPI NetLibGetSystemGuid(OUT EFI_GUID *SystemGuid)
EFI_STATUS EFIAPI PseudoRandomU32(OUT UINT32 *Output)
EFI_STATUS PxeBcDhcp4Discover(IN PXEBC_PRIVATE_DATA *Private, IN UINT16 Type, IN UINT16 *Layer, IN BOOLEAN UseBis, IN EFI_IP_ADDRESS *DestIp, IN UINT16 IpCount, IN EFI_PXE_BASE_CODE_SRVLIST *SrvList)
EFI_STATUS PxeBcCopyDhcp4Ack(IN PXEBC_PRIVATE_DATA *Private, IN EFI_DHCP4_PACKET *Ack, IN BOOLEAN Verified)
EFI_STATUS PxeBcCacheDhcp4Offer(IN PXEBC_PRIVATE_DATA *Private, IN EFI_DHCP4_PACKET *RcvdOffer)
EFI_STATUS PxeBcHandleDhcp4Offer(IN PXEBC_PRIVATE_DATA *Private)
EFI_STATUS PxeBcCacheDhcp4Packet(IN EFI_DHCP4_PACKET *Dst, IN EFI_DHCP4_PACKET *Src)
EFI_STATUS PxeBcSetIp4Policy(IN PXEBC_PRIVATE_DATA *Private)
EFI_DHCP4_PACKET_OPTION * PxeBcParseDhcp4Options(IN UINT8 *Buffer, IN UINT32 Length, IN UINT8 OptTag)
EFI_STATUS EFIAPI PxeBcDhcp4CallBack(IN EFI_DHCP4_PROTOCOL *This, IN VOID *Context, IN EFI_DHCP4_STATE CurrentState, IN EFI_DHCP4_EVENT Dhcp4Event, IN EFI_DHCP4_PACKET *Packet OPTIONAL, OUT EFI_DHCP4_PACKET **NewPacket OPTIONAL)
VOID PxeBcSeedDhcp4Packet(OUT EFI_DHCP4_PACKET *Seed, IN EFI_UDP4_PROTOCOL *Udp4)
EFI_STATUS PxeBcDhcp4Dora(IN PXEBC_PRIVATE_DATA *Private, IN EFI_DHCP4_PROTOCOL *Dhcp4)
EFI_STATUS PxeBcRetryBinlOffer(IN PXEBC_PRIVATE_DATA *Private, IN UINT32 Index)
EFI_STATUS PxeBcParseDhcp4Packet(IN PXEBC_DHCP4_PACKET_CACHE *Cache4)
VOID PxeBcSelectDhcp4Offer(IN PXEBC_PRIVATE_DATA *Private)
VOID PxeBcParseVendorOptions(IN EFI_DHCP4_PACKET_OPTION *Dhcp4Option, IN PXEBC_VENDOR_OPTION *VendorOption)
UINT32 PxeBcBuildDhcp4Options(IN PXEBC_PRIVATE_DATA *Private, OUT EFI_DHCP4_PACKET_OPTION **OptList, IN UINT8 *Buffer, IN BOOLEAN NeedMsgType)
EFI_STATUS PxeBcCopyProxyOffer(IN PXEBC_PRIVATE_DATA *Private, IN UINT32 OfferIndex)
EFI_STATUS PxeBcFlushStationIp(PXEBC_PRIVATE_DATA *Private, EFI_IP_ADDRESS *StationIp OPTIONAL, EFI_IP_ADDRESS *SubnetMask OPTIONAL)
VOID PxeBcShowIp4Addr(IN EFI_IPv4_ADDRESS *Ip)
VOID PxeBcUintnToAscDecWithFormat(IN UINTN Number, IN UINT8 *Buffer, IN INTN Length)
UINTN EFIAPI AsciiPrint(IN CONST CHAR8 *Format,...)
EFI_PXE_BASE_CODE_MODE * Mode
EFI_DHCP4_PACKET_OPTION ** OptionList
EFI_DHCP4_CALLBACK Dhcp4Callback
EFI_IPv4_ADDRESS ClientAddr
Client IP address from client.
EFI_IPv4_ADDRESS ServerAddr
IP address of next server in bootstrap.
UINT8 ClientHwAddr[16]
Client hardware address.
EFI_IPv4_ADDRESS YourAddr
Client IP address from server.
EFI_IPv4_ADDRESS ListenAddress
EFI_IPv4_ADDRESS SubnetMask
EFI_IPv4_ADDRESS SubnetMask
EFI_IPv4_ADDRESS RouterAddress
EFI_IPv4_ADDRESS ClientAddress
EFI_IPv4_ADDRESS RemoteAddress
EFI_DHCP4_LISTEN_POINT * ListenPoints
EFI_DHCP4_PACKET * Packet
EFI_IPv4_ADDRESS GatewayAddress
EFI_DHCP4_PACKET * ResponseList
EFI_MAC_ADDRESS CurrentAddress