TianoCore EDK2 master
Loading...
Searching...
No Matches
Dhcp4Impl.c
Go to the documentation of this file.
1
9#include "Dhcp4Impl.h"
10
25EFIAPI
28 OUT EFI_DHCP4_MODE_DATA *Dhcp4ModeData
29 );
30
74EFIAPI
77 IN EFI_DHCP4_CONFIG_DATA *Dhcp4CfgData OPTIONAL
78 );
79
121EFIAPI
124 IN EFI_EVENT CompletionEvent OPTIONAL
125 );
126
166EFIAPI
169 IN BOOLEAN RebindRequest,
170 IN EFI_EVENT CompletionEvent OPTIONAL
171 );
172
195EFIAPI
198 );
199
216EFIAPI
219 );
220
249EFIAPI
252 IN EFI_DHCP4_PACKET *SeedPacket,
253 IN UINT32 DeleteCount,
254 IN UINT8 *DeleteList OPTIONAL,
255 IN UINT32 AppendCount,
256 IN EFI_DHCP4_PACKET_OPTION *AppendList[] OPTIONAL,
257 OUT EFI_DHCP4_PACKET **NewPacket
258 );
259
280EFIAPI
284 );
285
314EFIAPI
317 IN EFI_DHCP4_PACKET *Packet,
318 IN OUT UINT32 *OptionCount,
319 OUT EFI_DHCP4_PACKET_OPTION *PacketOptionList[] OPTIONAL
320 );
321
322EFI_DHCP4_PROTOCOL mDhcp4ProtocolTemplate = {
332};
333
348EFIAPI
351 OUT EFI_DHCP4_MODE_DATA *Dhcp4ModeData
352 )
353{
354 DHCP_PROTOCOL *Instance;
355 DHCP_SERVICE *DhcpSb;
356 DHCP_PARAMETER *Para;
357 EFI_TPL OldTpl;
358 IP4_ADDR Ip;
359
360 //
361 // First validate the parameters.
362 //
363 if ((This == NULL) || (Dhcp4ModeData == NULL)) {
364 return EFI_INVALID_PARAMETER;
365 }
366
367 Instance = DHCP_INSTANCE_FROM_THIS (This);
368
369 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
370 DhcpSb = Instance->Service;
371
372 //
373 // Caller can use GetModeData to retrieve current DHCP states
374 // no matter whether it is the active child or not.
375 //
376 Dhcp4ModeData->State = (EFI_DHCP4_STATE)DhcpSb->DhcpState;
377 CopyMem (&Dhcp4ModeData->ConfigData, &DhcpSb->ActiveConfig, sizeof (Dhcp4ModeData->ConfigData));
378 CopyMem (&Dhcp4ModeData->ClientMacAddress, &DhcpSb->Mac, sizeof (Dhcp4ModeData->ClientMacAddress));
379
380 Ip = HTONL (DhcpSb->ClientAddr);
381 CopyMem (&Dhcp4ModeData->ClientAddress, &Ip, sizeof (EFI_IPv4_ADDRESS));
382
383 Ip = HTONL (DhcpSb->Netmask);
384 CopyMem (&Dhcp4ModeData->SubnetMask, &Ip, sizeof (EFI_IPv4_ADDRESS));
385
386 Ip = HTONL (DhcpSb->ServerAddr);
387 CopyMem (&Dhcp4ModeData->ServerAddress, &Ip, sizeof (EFI_IPv4_ADDRESS));
388
389 Para = DhcpSb->Para;
390
391 if (Para != NULL) {
392 Ip = HTONL (Para->Router);
393 CopyMem (&Dhcp4ModeData->RouterAddress, &Ip, sizeof (EFI_IPv4_ADDRESS));
394 Dhcp4ModeData->LeaseTime = Para->Lease;
395 } else {
396 ZeroMem (&Dhcp4ModeData->RouterAddress, sizeof (EFI_IPv4_ADDRESS));
397 Dhcp4ModeData->LeaseTime = 0xffffffff;
398 }
399
400 Dhcp4ModeData->ReplyPacket = DhcpSb->Selected;
401
402 gBS->RestoreTPL (OldTpl);
403 return EFI_SUCCESS;
404}
405
414VOID
417 )
418{
419 UINT32 Index;
420
421 if (Config->DiscoverTimeout != NULL) {
422 FreePool (Config->DiscoverTimeout);
423 }
424
425 if (Config->RequestTimeout != NULL) {
426 FreePool (Config->RequestTimeout);
427 }
428
429 if (Config->OptionList != NULL) {
430 for (Index = 0; Index < Config->OptionCount; Index++) {
431 if (Config->OptionList[Index] != NULL) {
432 FreePool (Config->OptionList[Index]);
433 }
434 }
435
436 FreePool (Config->OptionList);
437 }
438
439 ZeroMem (Config, sizeof (EFI_DHCP4_CONFIG_DATA));
440}
441
457 )
458{
459 EFI_DHCP4_PACKET_OPTION **DstOptions;
460 EFI_DHCP4_PACKET_OPTION **SrcOptions;
461 UINTN Len;
462 UINT32 Index;
463
464 CopyMem (Dst, Src, sizeof (*Dst));
465 Dst->DiscoverTimeout = NULL;
466 Dst->RequestTimeout = NULL;
467 Dst->OptionList = NULL;
468
469 //
470 // Allocate a memory then copy DiscoverTimeout to it
471 //
472 if (Src->DiscoverTimeout != NULL) {
473 Len = Src->DiscoverTryCount * sizeof (UINT32);
474 Dst->DiscoverTimeout = AllocatePool (Len);
475
476 if (Dst->DiscoverTimeout == NULL) {
477 return EFI_OUT_OF_RESOURCES;
478 }
479
480 for (Index = 0; Index < Src->DiscoverTryCount; Index++) {
481 Dst->DiscoverTimeout[Index] = MAX (Src->DiscoverTimeout[Index], 1);
482 }
483 }
484
485 //
486 // Allocate a memory then copy RequestTimeout to it
487 //
488 if (Src->RequestTimeout != NULL) {
489 Len = Src->RequestTryCount * sizeof (UINT32);
490 Dst->RequestTimeout = AllocatePool (Len);
491
492 if (Dst->RequestTimeout == NULL) {
493 goto ON_ERROR;
494 }
495
496 for (Index = 0; Index < Src->RequestTryCount; Index++) {
497 Dst->RequestTimeout[Index] = MAX (Src->RequestTimeout[Index], 1);
498 }
499 }
500
501 //
502 // Allocate an array of dhcp option point, then allocate memory
503 // for each option and copy the source option to it
504 //
505 if (Src->OptionList != NULL) {
506 Len = Src->OptionCount * sizeof (EFI_DHCP4_PACKET_OPTION *);
507 Dst->OptionList = AllocateZeroPool (Len);
508
509 if (Dst->OptionList == NULL) {
510 goto ON_ERROR;
511 }
512
513 DstOptions = Dst->OptionList;
514 SrcOptions = Src->OptionList;
515
516 for (Index = 0; Index < Src->OptionCount; Index++) {
517 Len = sizeof (EFI_DHCP4_PACKET_OPTION) + MAX (SrcOptions[Index]->Length - 1, 0);
518
519 DstOptions[Index] = AllocatePool (Len);
520
521 if (DstOptions[Index] == NULL) {
522 goto ON_ERROR;
523 }
524
525 CopyMem (DstOptions[Index], SrcOptions[Index], Len);
526 }
527 }
528
529 return EFI_SUCCESS;
530
531ON_ERROR:
532 DhcpCleanConfigure (Dst);
533 return EFI_OUT_OF_RESOURCES;
534}
535
544VOID
546 IN DHCP_SERVICE *DhcpSb
547 )
548{
549 EFI_DHCP4_CONFIG_DATA *Config;
550
551 Config = &DhcpSb->ActiveConfig;
552
553 DhcpSb->ServiceState = DHCP_UNCONFIGED;
554 DhcpSb->ActiveChild = NULL;
555
556 if (Config->DiscoverTimeout != NULL) {
557 FreePool (Config->DiscoverTimeout);
558
559 Config->DiscoverTryCount = 0;
560 Config->DiscoverTimeout = NULL;
561 }
562
563 if (Config->RequestTimeout != NULL) {
564 FreePool (Config->RequestTimeout);
565
566 Config->RequestTryCount = 0;
567 Config->RequestTimeout = NULL;
568 }
569
570 Config->Dhcp4Callback = NULL;
571 Config->CallbackContext = NULL;
572}
573
617EFIAPI
620 IN EFI_DHCP4_CONFIG_DATA *Dhcp4CfgData OPTIONAL
621 )
622{
623 EFI_DHCP4_CONFIG_DATA *Config;
624 DHCP_PROTOCOL *Instance;
625 DHCP_SERVICE *DhcpSb;
626 EFI_STATUS Status;
627 EFI_TPL OldTpl;
628 UINT32 Index;
629 IP4_ADDR Ip;
630
631 //
632 // First validate the parameters
633 //
634 if (This == NULL) {
635 return EFI_INVALID_PARAMETER;
636 }
637
638 if (Dhcp4CfgData != NULL) {
639 if ((Dhcp4CfgData->DiscoverTryCount != 0) && (Dhcp4CfgData->DiscoverTimeout == NULL)) {
640 return EFI_INVALID_PARAMETER;
641 }
642
643 if ((Dhcp4CfgData->RequestTryCount != 0) && (Dhcp4CfgData->RequestTimeout == NULL)) {
644 return EFI_INVALID_PARAMETER;
645 }
646
647 if ((Dhcp4CfgData->OptionCount != 0) && (Dhcp4CfgData->OptionList == NULL)) {
648 return EFI_INVALID_PARAMETER;
649 }
650
651 CopyMem (&Ip, &Dhcp4CfgData->ClientAddress, sizeof (IP4_ADDR));
652 if (IP4_IS_LOCAL_BROADCAST (NTOHL (Ip))) {
653 return EFI_INVALID_PARAMETER;
654 }
655 }
656
657 Instance = DHCP_INSTANCE_FROM_THIS (This);
658
659 if (Instance->Signature != DHCP_PROTOCOL_SIGNATURE) {
660 return EFI_INVALID_PARAMETER;
661 }
662
663 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
664
665 DhcpSb = Instance->Service;
666 Config = &DhcpSb->ActiveConfig;
667
668 Status = EFI_ACCESS_DENIED;
669
670 if ((DhcpSb->DhcpState != Dhcp4Stopped) &&
671 (DhcpSb->DhcpState != Dhcp4Init) &&
672 (DhcpSb->DhcpState != Dhcp4InitReboot) &&
673 (DhcpSb->DhcpState != Dhcp4Bound))
674 {
675 goto ON_EXIT;
676 }
677
678 if ((DhcpSb->ActiveChild != NULL) && (DhcpSb->ActiveChild != Instance)) {
679 goto ON_EXIT;
680 }
681
682 if (Dhcp4CfgData != NULL) {
683 Status = EFI_OUT_OF_RESOURCES;
684 DhcpCleanConfigure (Config);
685
686 if (EFI_ERROR (DhcpCopyConfigure (Config, Dhcp4CfgData))) {
687 goto ON_EXIT;
688 }
689
690 DhcpSb->UserOptionLen = 0;
691
692 for (Index = 0; Index < Dhcp4CfgData->OptionCount; Index++) {
693 DhcpSb->UserOptionLen += Dhcp4CfgData->OptionList[Index]->Length + 2;
694 }
695
696 DhcpSb->ActiveChild = Instance;
697
698 if (DhcpSb->DhcpState == Dhcp4Stopped) {
699 DhcpSb->ClientAddr = EFI_NTOHL (Dhcp4CfgData->ClientAddress);
700
701 if (DhcpSb->ClientAddr != 0) {
702 DhcpSb->DhcpState = Dhcp4InitReboot;
703 } else {
704 DhcpSb->DhcpState = Dhcp4Init;
705 }
706 }
707
708 DhcpSb->ServiceState = DHCP_CONFIGED;
709 Status = EFI_SUCCESS;
710 } else if (DhcpSb->ActiveChild == Instance) {
711 Status = EFI_SUCCESS;
712 DhcpYieldControl (DhcpSb);
713 }
714
715ON_EXIT:
716 gBS->RestoreTPL (OldTpl);
717 return Status;
718}
719
762EFIAPI
765 IN EFI_EVENT CompletionEvent OPTIONAL
766 )
767{
768 DHCP_PROTOCOL *Instance;
769 DHCP_SERVICE *DhcpSb;
770 EFI_STATUS Status;
771 EFI_TPL OldTpl;
772 EFI_STATUS MediaStatus;
773
774 //
775 // First validate the parameters
776 //
777 if (This == NULL) {
778 return EFI_INVALID_PARAMETER;
779 }
780
781 Instance = DHCP_INSTANCE_FROM_THIS (This);
782
783 if (Instance->Signature != DHCP_PROTOCOL_SIGNATURE) {
784 return EFI_INVALID_PARAMETER;
785 }
786
787 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
788 DhcpSb = Instance->Service;
789
790 if (DhcpSb->DhcpState == Dhcp4Stopped) {
791 Status = EFI_NOT_STARTED;
792 goto ON_ERROR;
793 }
794
795 if ((DhcpSb->DhcpState != Dhcp4Init) && (DhcpSb->DhcpState != Dhcp4InitReboot)) {
796 Status = EFI_ALREADY_STARTED;
797 goto ON_ERROR;
798 }
799
800 //
801 // Check Media Status.
802 //
803 MediaStatus = EFI_SUCCESS;
804 NetLibDetectMediaWaitTimeout (DhcpSb->Controller, DHCP_CHECK_MEDIA_WAITING_TIME, &MediaStatus);
805 if (MediaStatus != EFI_SUCCESS) {
806 Status = EFI_NO_MEDIA;
807 goto ON_ERROR;
808 }
809
810 DhcpSb->IoStatus = EFI_ALREADY_STARTED;
811
812 if (EFI_ERROR (Status = DhcpInitRequest (DhcpSb))) {
813 goto ON_ERROR;
814 }
815
816 Instance->CompletionEvent = CompletionEvent;
817
818 //
819 // Restore the TPL now, don't call poll function at TPL_CALLBACK.
820 //
821 gBS->RestoreTPL (OldTpl);
822
823 if (CompletionEvent == NULL) {
824 while (DhcpSb->IoStatus == EFI_ALREADY_STARTED) {
825 DhcpSb->UdpIo->Protocol.Udp4->Poll (DhcpSb->UdpIo->Protocol.Udp4);
826 }
827
828 return DhcpSb->IoStatus;
829 }
830
831 return EFI_SUCCESS;
832
833ON_ERROR:
834 gBS->RestoreTPL (OldTpl);
835 return Status;
836}
837
877EFIAPI
880 IN BOOLEAN RebindRequest,
881 IN EFI_EVENT CompletionEvent OPTIONAL
882 )
883{
884 DHCP_PROTOCOL *Instance;
885 DHCP_SERVICE *DhcpSb;
886 EFI_STATUS Status;
887 EFI_TPL OldTpl;
888
889 //
890 // First validate the parameters
891 //
892 if (This == NULL) {
893 return EFI_INVALID_PARAMETER;
894 }
895
896 Instance = DHCP_INSTANCE_FROM_THIS (This);
897
898 if (Instance->Signature != DHCP_PROTOCOL_SIGNATURE) {
899 return EFI_INVALID_PARAMETER;
900 }
901
902 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
903 DhcpSb = Instance->Service;
904
905 if (DhcpSb->DhcpState == Dhcp4Stopped) {
906 Status = EFI_NOT_STARTED;
907 goto ON_EXIT;
908 }
909
910 if (DhcpSb->DhcpState != Dhcp4Bound) {
911 Status = EFI_ACCESS_DENIED;
912 goto ON_EXIT;
913 }
914
915 if (DHCP_IS_BOOTP (DhcpSb->Para)) {
916 Status = EFI_SUCCESS;
917 goto ON_EXIT;
918 }
919
920 //
921 // Transit the states then send a extra DHCP request
922 //
923 if (!RebindRequest) {
925 } else {
927 }
928
929 //
930 // Clear initial time to make sure that elapsed-time
931 // is set to 0 for first REQUEST in renewal process.
932 //
933 Instance->ElaspedTime = 0;
934
935 Status = DhcpSendMessage (
936 DhcpSb,
937 DhcpSb->Selected,
938 DhcpSb->Para,
939 DHCP_MSG_REQUEST,
940 (UINT8 *)"Extra renew/rebind by the application"
941 );
942
943 if (EFI_ERROR (Status)) {
944 DhcpSetState (DhcpSb, Dhcp4Bound, FALSE);
945 goto ON_EXIT;
946 }
947
948 DhcpSb->ExtraRefresh = TRUE;
949 DhcpSb->IoStatus = EFI_ALREADY_STARTED;
950 Instance->RenewRebindEvent = CompletionEvent;
951
952 gBS->RestoreTPL (OldTpl);
953
954 if (CompletionEvent == NULL) {
955 while (DhcpSb->IoStatus == EFI_ALREADY_STARTED) {
956 DhcpSb->UdpIo->Protocol.Udp4->Poll (DhcpSb->UdpIo->Protocol.Udp4);
957 }
958
959 return DhcpSb->IoStatus;
960 }
961
962 return EFI_SUCCESS;
963
964ON_EXIT:
965 gBS->RestoreTPL (OldTpl);
966 return Status;
967}
968
991EFIAPI
994 )
995{
996 DHCP_PROTOCOL *Instance;
997 DHCP_SERVICE *DhcpSb;
998 EFI_STATUS Status;
999 EFI_TPL OldTpl;
1000
1001 //
1002 // First validate the parameters
1003 //
1004 if (This == NULL) {
1005 return EFI_INVALID_PARAMETER;
1006 }
1007
1008 Instance = DHCP_INSTANCE_FROM_THIS (This);
1009
1010 if (Instance->Signature != DHCP_PROTOCOL_SIGNATURE) {
1011 return EFI_INVALID_PARAMETER;
1012 }
1013
1014 Status = EFI_SUCCESS;
1015 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
1016 DhcpSb = Instance->Service;
1017
1018 if ((DhcpSb->DhcpState != Dhcp4InitReboot) && (DhcpSb->DhcpState != Dhcp4Bound)) {
1019 Status = EFI_ACCESS_DENIED;
1020 goto ON_EXIT;
1021 }
1022
1023 if (!DHCP_IS_BOOTP (DhcpSb->Para) && (DhcpSb->DhcpState == Dhcp4Bound)) {
1024 Status = DhcpSendMessage (
1025 DhcpSb,
1026 DhcpSb->Selected,
1027 DhcpSb->Para,
1028 DHCP_MSG_RELEASE,
1029 NULL
1030 );
1031
1032 if (EFI_ERROR (Status)) {
1033 Status = EFI_DEVICE_ERROR;
1034 goto ON_EXIT;
1035 }
1036 }
1037
1038 DhcpCleanLease (DhcpSb);
1039
1040ON_EXIT:
1041 gBS->RestoreTPL (OldTpl);
1042 return Status;
1043}
1044
1061EFIAPI
1064 )
1065{
1066 DHCP_PROTOCOL *Instance;
1067 DHCP_SERVICE *DhcpSb;
1068 EFI_TPL OldTpl;
1069
1070 //
1071 // First validate the parameters
1072 //
1073 if (This == NULL) {
1074 return EFI_INVALID_PARAMETER;
1075 }
1076
1077 Instance = DHCP_INSTANCE_FROM_THIS (This);
1078
1079 if (Instance->Signature != DHCP_PROTOCOL_SIGNATURE) {
1080 return EFI_INVALID_PARAMETER;
1081 }
1082
1083 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
1084 DhcpSb = Instance->Service;
1085
1086 DhcpCleanLease (DhcpSb);
1087
1088 DhcpSb->DhcpState = Dhcp4Stopped;
1089 DhcpSb->ServiceState = DHCP_UNCONFIGED;
1090
1091 gBS->RestoreTPL (OldTpl);
1092 return EFI_SUCCESS;
1093}
1094
1123EFIAPI
1125 IN EFI_DHCP4_PROTOCOL *This,
1126 IN EFI_DHCP4_PACKET *SeedPacket,
1127 IN UINT32 DeleteCount,
1128 IN UINT8 *DeleteList OPTIONAL,
1129 IN UINT32 AppendCount,
1130 IN EFI_DHCP4_PACKET_OPTION *AppendList[] OPTIONAL,
1131 OUT EFI_DHCP4_PACKET **NewPacket
1132 )
1133{
1134 //
1135 // First validate the parameters
1136 //
1137 if ((This == NULL) || (NewPacket == NULL)) {
1138 return EFI_INVALID_PARAMETER;
1139 }
1140
1141 if ((SeedPacket == NULL) || (SeedPacket->Dhcp4.Magik != DHCP_OPTION_MAGIC) ||
1142 EFI_ERROR (DhcpValidateOptions (SeedPacket, NULL)))
1143 {
1144 return EFI_INVALID_PARAMETER;
1145 }
1146
1147 if (((DeleteCount == 0) && (AppendCount == 0)) ||
1148 ((DeleteCount != 0) && (DeleteList == NULL)) ||
1149 ((AppendCount != 0) && (AppendList == NULL)))
1150 {
1151 return EFI_INVALID_PARAMETER;
1152 }
1153
1154 return DhcpBuild (
1155 SeedPacket,
1156 DeleteCount,
1157 DeleteList,
1158 AppendCount,
1159 AppendList,
1160 NewPacket
1161 );
1162}
1163
1176EFIAPI
1178 IN UDP_IO *UdpIo,
1179 IN VOID *Context
1180 )
1181{
1182 DHCP_PROTOCOL *Instance;
1183 DHCP_SERVICE *DhcpSb;
1185 EFI_UDP4_CONFIG_DATA UdpConfigData;
1186 IP4_ADDR ClientAddr;
1187 IP4_ADDR Ip;
1188 INTN Class;
1189 IP4_ADDR SubnetMask;
1190
1191 Instance = (DHCP_PROTOCOL *)Context;
1192 DhcpSb = Instance->Service;
1193 Token = Instance->Token;
1194
1195 ZeroMem (&UdpConfigData, sizeof (EFI_UDP4_CONFIG_DATA));
1196
1197 UdpConfigData.AcceptBroadcast = TRUE;
1198 UdpConfigData.AllowDuplicatePort = TRUE;
1199 UdpConfigData.TimeToLive = 64;
1200 UdpConfigData.DoNotFragment = TRUE;
1201
1202 ClientAddr = EFI_NTOHL (Token->Packet->Dhcp4.Header.ClientAddr);
1203 Ip = HTONL (ClientAddr);
1204 CopyMem (&UdpConfigData.StationAddress, &Ip, sizeof (EFI_IPv4_ADDRESS));
1205
1206 if (DhcpSb->Netmask == 0) {
1207 //
1208 // The Dhcp4.TransmitReceive() API should be able to used at any time according to
1209 // UEFI spec, while in classless addressing network, the netmask must be explicitly
1210 // provided together with the station address.
1211 // If the DHCP instance haven't be configured with a valid netmask, we could only
1212 // compute it according to the classful addressing rule.
1213 //
1214 Class = NetGetIpClass (ClientAddr);
1215 //
1216 // Class E IP address is not supported here!
1217 //
1218 ASSERT (Class < IP4_ADDR_CLASSE);
1219 if (Class >= IP4_ADDR_CLASSE) {
1220 return EFI_INVALID_PARAMETER;
1221 }
1222
1223 SubnetMask = gIp4AllMasks[Class << 3];
1224 } else {
1225 SubnetMask = DhcpSb->Netmask;
1226 }
1227
1228 Ip = HTONL (SubnetMask);
1229 CopyMem (&UdpConfigData.SubnetMask, &Ip, sizeof (EFI_IPv4_ADDRESS));
1230
1231 if ((Token->ListenPointCount == 0) || (Token->ListenPoints[0].ListenPort == 0)) {
1232 UdpConfigData.StationPort = DHCP_CLIENT_PORT;
1233 } else {
1234 UdpConfigData.StationPort = Token->ListenPoints[0].ListenPort;
1235 }
1236
1237 return UdpIo->Protocol.Udp4->Configure (UdpIo->Protocol.Udp4, &UdpConfigData);
1238}
1239
1251 IN OUT DHCP_PROTOCOL *Instance
1252 )
1253{
1254 DHCP_SERVICE *DhcpSb;
1255 EFI_STATUS Status;
1256 VOID *Udp4;
1257
1258 ASSERT (Instance->Token != NULL);
1259
1260 DhcpSb = Instance->Service;
1261 Instance->UdpIo = UdpIoCreateIo (
1262 DhcpSb->Controller,
1263 DhcpSb->Image,
1265 UDP_IO_UDP4_VERSION,
1266 Instance
1267 );
1268 if (Instance->UdpIo == NULL) {
1269 return EFI_OUT_OF_RESOURCES;
1270 } else {
1271 Status = gBS->OpenProtocol (
1272 Instance->UdpIo->UdpHandle,
1273 &gEfiUdp4ProtocolGuid,
1274 (VOID **)&Udp4,
1275 Instance->Service->Image,
1276 Instance->Handle,
1277 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
1278 );
1279 if (EFI_ERROR (Status)) {
1280 UdpIoFreeIo (Instance->UdpIo);
1281 Instance->UdpIo = NULL;
1282 }
1283
1284 return Status;
1285 }
1286}
1287
1294VOID
1295EFIAPI
1297 IN VOID *Arg
1298 )
1299{
1300}
1301
1314VOID
1315EFIAPI
1317 NET_BUF *UdpPacket,
1318 UDP_END_POINT *EndPoint,
1319 EFI_STATUS IoStatus,
1320 VOID *Context
1321 )
1322{
1323 DHCP_PROTOCOL *Instance;
1324 EFI_DHCP4_HEADER *Head;
1325 NET_BUF *Wrap;
1326 EFI_DHCP4_PACKET *Packet;
1328 UINT32 Len;
1329 EFI_STATUS Status;
1330
1331 Wrap = NULL;
1332 Instance = (DHCP_PROTOCOL *)Context;
1333 Token = Instance->Token;
1334
1335 //
1336 // Don't restart receive if error occurs or DHCP is destroyed.
1337 //
1338 if (EFI_ERROR (IoStatus)) {
1339 return;
1340 }
1341
1342 ASSERT (UdpPacket != NULL);
1343
1344 //
1345 // Validate the packet received
1346 //
1347 if (UdpPacket->TotalSize < sizeof (EFI_DHCP4_HEADER)) {
1348 goto RESTART;
1349 }
1350
1351 //
1352 // Copy the DHCP message to a continuous memory block, make the buffer size
1353 // of the EFI_DHCP4_PACKET a multiple of 4-byte.
1354 //
1355 Len = NET_ROUNDUP (sizeof (EFI_DHCP4_PACKET) + UdpPacket->TotalSize - sizeof (EFI_DHCP4_HEADER), 4);
1356 Wrap = NetbufAlloc (Len);
1357 if (Wrap == NULL) {
1358 goto RESTART;
1359 }
1360
1361 Packet = (EFI_DHCP4_PACKET *)NetbufAllocSpace (Wrap, Len, NET_BUF_TAIL);
1362 ASSERT (Packet != NULL);
1363
1364 Packet->Size = Len;
1365 Head = &Packet->Dhcp4.Header;
1366 Packet->Length = NetbufCopy (UdpPacket, 0, UdpPacket->TotalSize, (UINT8 *)Head);
1367
1368 if (Packet->Length != UdpPacket->TotalSize) {
1369 goto RESTART;
1370 }
1371
1372 //
1373 // Is this packet the answer to our packet?
1374 //
1375 if ((Head->OpCode != BOOTP_REPLY) ||
1376 (Head->Xid != Token->Packet->Dhcp4.Header.Xid) ||
1377 (CompareMem (&Token->Packet->Dhcp4.Header.ClientHwAddr[0], Head->ClientHwAddr, Head->HwAddrLen) != 0))
1378 {
1379 goto RESTART;
1380 }
1381
1382 //
1383 // Validate the options and retrieve the interested options
1384 //
1385 if ((Packet->Length > sizeof (EFI_DHCP4_HEADER) + sizeof (UINT32)) &&
1386 (Packet->Dhcp4.Magik == DHCP_OPTION_MAGIC) &&
1387 EFI_ERROR (DhcpValidateOptions (Packet, NULL)))
1388 {
1389 goto RESTART;
1390 }
1391
1392 //
1393 // Keep this packet in the ResponseQueue.
1394 //
1395 NET_GET_REF (Wrap);
1396 NetbufQueAppend (&Instance->ResponseQueue, Wrap);
1397
1398RESTART:
1399
1400 NetbufFree (UdpPacket);
1401
1402 if (Wrap != NULL) {
1403 NetbufFree (Wrap);
1404 }
1405
1406 Status = UdpIoRecvDatagram (Instance->UdpIo, PxeDhcpInput, Instance, 0);
1407 if (EFI_ERROR (Status)) {
1408 PxeDhcpDone (Instance);
1409 }
1410}
1411
1418VOID
1420 IN DHCP_PROTOCOL *Instance
1421 )
1422{
1424
1425 Token = Instance->Token;
1426
1427 Token->ResponseCount = Instance->ResponseQueue.BufNum;
1428 if (Token->ResponseCount != 0) {
1429 Token->ResponseList = (EFI_DHCP4_PACKET *)AllocatePool (Instance->ResponseQueue.BufSize);
1430 if (Token->ResponseList == NULL) {
1431 Token->Status = EFI_OUT_OF_RESOURCES;
1432 goto SIGNAL_USER;
1433 }
1434
1435 //
1436 // Copy the received DHCP responses.
1437 //
1438 NetbufQueCopy (&Instance->ResponseQueue, 0, Instance->ResponseQueue.BufSize, (UINT8 *)Token->ResponseList);
1439 Token->Status = EFI_SUCCESS;
1440 } else {
1441 Token->ResponseList = NULL;
1442 Token->Status = EFI_TIMEOUT;
1443 }
1444
1445SIGNAL_USER:
1446 //
1447 // Clean up the resources dedicated for this transmit receive transaction.
1448 //
1449 NetbufQueFlush (&Instance->ResponseQueue);
1450 UdpIoCleanIo (Instance->UdpIo);
1451 gBS->CloseProtocol (
1452 Instance->UdpIo->UdpHandle,
1453 &gEfiUdp4ProtocolGuid,
1454 Instance->Service->Image,
1455 Instance->Handle
1456 );
1457 UdpIoFreeIo (Instance->UdpIo);
1458 Instance->UdpIo = NULL;
1459 Instance->Token = NULL;
1460
1461 if (Token->CompletionEvent != NULL) {
1462 gBS->SignalEvent (Token->CompletionEvent);
1463 }
1464}
1465
1486EFIAPI
1488 IN EFI_DHCP4_PROTOCOL *This,
1490 )
1491{
1492 DHCP_PROTOCOL *Instance;
1493 EFI_TPL OldTpl;
1494 EFI_STATUS Status;
1495 NET_FRAGMENT Frag;
1496 NET_BUF *Wrap;
1497 UDP_END_POINT EndPoint;
1498 IP4_ADDR Ip;
1499 DHCP_SERVICE *DhcpSb;
1500 EFI_IP_ADDRESS Gateway;
1501 IP4_ADDR ClientAddr;
1502
1503 if ((This == NULL) || (Token == NULL) || (Token->Packet == NULL)) {
1504 return EFI_INVALID_PARAMETER;
1505 }
1506
1507 Instance = DHCP_INSTANCE_FROM_THIS (This);
1508 DhcpSb = Instance->Service;
1509
1510 if (Instance->Token != NULL) {
1511 //
1512 // The previous call to TransmitReceive is not finished.
1513 //
1514 return EFI_NOT_READY;
1515 }
1516
1517 if ((Token->Packet->Dhcp4.Magik != DHCP_OPTION_MAGIC) ||
1518 (NTOHL (Token->Packet->Dhcp4.Header.Xid) == Instance->Service->Xid) ||
1519 (Token->TimeoutValue == 0) ||
1520 ((Token->ListenPointCount != 0) && (Token->ListenPoints == NULL)) ||
1521 EFI_ERROR (DhcpValidateOptions (Token->Packet, NULL)) ||
1522 EFI_IP4_EQUAL (&Token->RemoteAddress, &mZeroIp4Addr)
1523 )
1524 {
1525 //
1526 // The DHCP packet isn't well-formed, the Transaction ID is already used,
1527 // the timeout value is zero, the ListenPoint is invalid, or the
1528 // RemoteAddress is zero.
1529 //
1530 return EFI_INVALID_PARAMETER;
1531 }
1532
1533 ClientAddr = EFI_NTOHL (Token->Packet->Dhcp4.Header.ClientAddr);
1534
1535 if (ClientAddr == 0) {
1536 return EFI_NO_MAPPING;
1537 }
1538
1539 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
1540
1541 //
1542 // Save the token and the timeout value.
1543 //
1544 Instance->Token = Token;
1545 Instance->Timeout = Token->TimeoutValue;
1546
1547 //
1548 // Create a UDP IO for this transmit receive transaction.
1549 //
1550 Status = Dhcp4InstanceCreateUdpIo (Instance);
1551 if (EFI_ERROR (Status)) {
1552 goto ON_ERROR;
1553 }
1554
1555 //
1556 // Save the Client Address is sent out
1557 //
1558 CopyMem (
1559 &DhcpSb->ClientAddressSendOut[0],
1560 &Token->Packet->Dhcp4.Header.ClientHwAddr[0],
1561 Token->Packet->Dhcp4.Header.HwAddrLen
1562 );
1563
1564 //
1565 // Wrap the DHCP packet into a net buffer.
1566 //
1567 Frag.Bulk = (UINT8 *)&Token->Packet->Dhcp4;
1568 Frag.Len = Token->Packet->Length;
1569 Wrap = NetbufFromExt (&Frag, 1, 0, 0, DhcpDummyExtFree, NULL);
1570 if (Wrap == NULL) {
1571 Status = EFI_OUT_OF_RESOURCES;
1572 goto ON_ERROR;
1573 }
1574
1575 //
1576 // Set the local address and local port to ZERO.
1577 //
1578 ZeroMem (&EndPoint, sizeof (UDP_END_POINT));
1579
1580 //
1581 // Set the destination address and destination port.
1582 //
1583 CopyMem (&Ip, &Token->RemoteAddress, sizeof (EFI_IPv4_ADDRESS));
1584 EndPoint.RemoteAddr.Addr[0] = NTOHL (Ip);
1585
1586 if (Token->RemotePort == 0) {
1587 EndPoint.RemotePort = DHCP_SERVER_PORT;
1588 } else {
1589 EndPoint.RemotePort = Token->RemotePort;
1590 }
1591
1592 //
1593 // Get the gateway.
1594 //
1595 ZeroMem (&Gateway, sizeof (Gateway));
1596 if (!IP4_NET_EQUAL (ClientAddr, EndPoint.RemoteAddr.Addr[0], DhcpSb->Netmask)) {
1597 CopyMem (&Gateway.v4, &Token->GatewayAddress, sizeof (EFI_IPv4_ADDRESS));
1598 Gateway.Addr[0] = NTOHL (Gateway.Addr[0]);
1599 }
1600
1601 //
1602 // Transmit the DHCP packet.
1603 //
1604 Status = UdpIoSendDatagram (Instance->UdpIo, Wrap, &EndPoint, &Gateway, DhcpOnPacketSent, NULL);
1605 if (EFI_ERROR (Status)) {
1606 NetbufFree (Wrap);
1607 goto ON_ERROR;
1608 }
1609
1610 //
1611 // Start to receive the DHCP response.
1612 //
1613 Status = UdpIoRecvDatagram (Instance->UdpIo, PxeDhcpInput, Instance, 0);
1614 if (EFI_ERROR (Status)) {
1615 goto ON_ERROR;
1616 }
1617
1618ON_ERROR:
1619
1620 if (EFI_ERROR (Status) && (Instance->UdpIo != NULL)) {
1621 UdpIoCleanIo (Instance->UdpIo);
1622 gBS->CloseProtocol (
1623 Instance->UdpIo->UdpHandle,
1624 &gEfiUdp4ProtocolGuid,
1625 Instance->Service->Image,
1626 Instance->Handle
1627 );
1628 UdpIoFreeIo (Instance->UdpIo);
1629 Instance->UdpIo = NULL;
1630 Instance->Token = NULL;
1631 }
1632
1633 gBS->RestoreTPL (OldTpl);
1634
1635 if (!EFI_ERROR (Status) && (Token->CompletionEvent == NULL)) {
1636 //
1637 // Keep polling until timeout if no error happens and the CompletionEvent
1638 // is NULL.
1639 //
1640 while (TRUE) {
1641 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
1642 //
1643 // Raise TPL to protect the UDPIO in instance, in case that DhcpOnTimerTick
1644 // free it when timeout.
1645 //
1646 if (Instance->Timeout > 0) {
1647 Instance->UdpIo->Protocol.Udp4->Poll (Instance->UdpIo->Protocol.Udp4);
1648 gBS->RestoreTPL (OldTpl);
1649 } else {
1650 gBS->RestoreTPL (OldTpl);
1651 break;
1652 }
1653 }
1654 }
1655
1656 return Status;
1657}
1658
1674 IN UINT8 Tag,
1675 IN UINT8 Len,
1676 IN UINT8 *Data,
1677 IN VOID *Context
1678 )
1679{
1680 DHCP_PARSE_CONTEXT *Parse;
1681
1682 Parse = (DHCP_PARSE_CONTEXT *)Context;
1683 Parse->Index++;
1684
1685 if (Parse->Index <= Parse->OptionCount) {
1686 //
1687 // Use BASE_CR to get the memory position of EFI_DHCP4_PACKET_OPTION for
1688 // the EFI_DHCP4_PACKET_OPTION->Data because DhcpIterateOptions only
1689 // pass in the point to option data.
1690 //
1691 Parse->Option[Parse->Index - 1] = BASE_CR (Data, EFI_DHCP4_PACKET_OPTION, Data);
1692 }
1693
1694 return EFI_SUCCESS;
1695}
1696
1725EFIAPI
1727 IN EFI_DHCP4_PROTOCOL *This,
1728 IN EFI_DHCP4_PACKET *Packet,
1729 IN OUT UINT32 *OptionCount,
1730 OUT EFI_DHCP4_PACKET_OPTION *PacketOptionList[] OPTIONAL
1731 )
1732{
1733 DHCP_PARSE_CONTEXT Context;
1734 EFI_STATUS Status;
1735
1736 //
1737 // First validate the parameters
1738 //
1739 if ((This == NULL) || (Packet == NULL) || (OptionCount == NULL)) {
1740 return EFI_INVALID_PARAMETER;
1741 }
1742
1743 if ((Packet->Size < Packet->Length + 2 * sizeof (UINT32)) ||
1744 (Packet->Dhcp4.Magik != DHCP_OPTION_MAGIC) ||
1745 EFI_ERROR (DhcpValidateOptions (Packet, NULL)))
1746 {
1747 return EFI_INVALID_PARAMETER;
1748 }
1749
1750 if ((*OptionCount != 0) && (PacketOptionList == NULL)) {
1751 return EFI_BUFFER_TOO_SMALL;
1752 }
1753
1754 ZeroMem (PacketOptionList, *OptionCount * sizeof (EFI_DHCP4_PACKET_OPTION *));
1755
1756 Context.Option = PacketOptionList;
1757 Context.OptionCount = *OptionCount;
1758 Context.Index = 0;
1759
1760 Status = DhcpIterateOptions (Packet, Dhcp4ParseCheckOption, &Context);
1761
1762 if (EFI_ERROR (Status)) {
1763 return Status;
1764 }
1765
1766 *OptionCount = Context.Index;
1767
1768 if (Context.Index > Context.OptionCount) {
1769 return EFI_BUFFER_TOO_SMALL;
1770 }
1771
1772 return EFI_SUCCESS;
1773}
1774
1782VOID
1784 IN UINT16 *Elapsed,
1785 IN DHCP_PROTOCOL *Instance
1786 )
1787{
1788 WriteUnaligned16 (Elapsed, HTONS (Instance->ElaspedTime));
1789}
UINT64 UINTN
INT64 INTN
UINT16 EFIAPI WriteUnaligned16(OUT UINT16 *Buffer, IN UINT16 Value)
Definition: Unaligned.c:61
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 ZeroMem(OUT VOID *Buffer, IN UINTN Length)
EFI_DHCP4_STATE
Definition: Dhcp4.h:98
@ Dhcp4Stopped
Definition: Dhcp4.h:102
@ Dhcp4Init
Definition: Dhcp4.h:106
@ Dhcp4Bound
Definition: Dhcp4.h:118
@ Dhcp4InitReboot
Definition: Dhcp4.h:133
@ Dhcp4Rebinding
Definition: Dhcp4.h:128
@ Dhcp4Renewing
Definition: Dhcp4.h:123
EFI_STATUS EFIAPI Dhcp4InstanceConfigUdpIo(IN UDP_IO *UdpIo, IN VOID *Context)
Definition: Dhcp4Impl.c:1177
EFI_STATUS EFIAPI EfiDhcp4Build(IN EFI_DHCP4_PROTOCOL *This, IN EFI_DHCP4_PACKET *SeedPacket, IN UINT32 DeleteCount, IN UINT8 *DeleteList OPTIONAL, IN UINT32 AppendCount, IN EFI_DHCP4_PACKET_OPTION *AppendList[] OPTIONAL, OUT EFI_DHCP4_PACKET **NewPacket)
Definition: Dhcp4Impl.c:1124
EFI_STATUS EFIAPI EfiDhcp4RenewRebind(IN EFI_DHCP4_PROTOCOL *This, IN BOOLEAN RebindRequest, IN EFI_EVENT CompletionEvent OPTIONAL)
Definition: Dhcp4Impl.c:878
VOID EFIAPI DhcpDummyExtFree(IN VOID *Arg)
Definition: Dhcp4Impl.c:1296
EFI_STATUS DhcpCopyConfigure(OUT EFI_DHCP4_CONFIG_DATA *Dst, IN EFI_DHCP4_CONFIG_DATA *Src)
Definition: Dhcp4Impl.c:454
VOID EFIAPI PxeDhcpInput(NET_BUF *UdpPacket, UDP_END_POINT *EndPoint, EFI_STATUS IoStatus, VOID *Context)
Definition: Dhcp4Impl.c:1316
EFI_STATUS EFIAPI EfiDhcp4TransmitReceive(IN EFI_DHCP4_PROTOCOL *This, IN EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN *Token)
Definition: Dhcp4Impl.c:1487
EFI_STATUS EFIAPI EfiDhcp4Start(IN EFI_DHCP4_PROTOCOL *This, IN EFI_EVENT CompletionEvent OPTIONAL)
Definition: Dhcp4Impl.c:763
EFI_STATUS Dhcp4ParseCheckOption(IN UINT8 Tag, IN UINT8 Len, IN UINT8 *Data, IN VOID *Context)
Definition: Dhcp4Impl.c:1673
EFI_STATUS EFIAPI EfiDhcp4Stop(IN EFI_DHCP4_PROTOCOL *This)
Definition: Dhcp4Impl.c:1062
EFI_STATUS EFIAPI EfiDhcp4Configure(IN EFI_DHCP4_PROTOCOL *This, IN EFI_DHCP4_CONFIG_DATA *Dhcp4CfgData OPTIONAL)
Definition: Dhcp4Impl.c:618
VOID DhcpCleanConfigure(IN OUT EFI_DHCP4_CONFIG_DATA *Config)
Definition: Dhcp4Impl.c:415
VOID PxeDhcpDone(IN DHCP_PROTOCOL *Instance)
Definition: Dhcp4Impl.c:1419
EFI_STATUS EFIAPI EfiDhcp4Release(IN EFI_DHCP4_PROTOCOL *This)
Definition: Dhcp4Impl.c:992
EFI_STATUS EFIAPI EfiDhcp4Parse(IN EFI_DHCP4_PROTOCOL *This, IN EFI_DHCP4_PACKET *Packet, IN OUT UINT32 *OptionCount, OUT EFI_DHCP4_PACKET_OPTION *PacketOptionList[] OPTIONAL)
Definition: Dhcp4Impl.c:1726
VOID DhcpYieldControl(IN DHCP_SERVICE *DhcpSb)
Definition: Dhcp4Impl.c:545
VOID SetElapsedTime(IN UINT16 *Elapsed, IN DHCP_PROTOCOL *Instance)
Definition: Dhcp4Impl.c:1783
EFI_STATUS Dhcp4InstanceCreateUdpIo(IN OUT DHCP_PROTOCOL *Instance)
Definition: Dhcp4Impl.c:1250
EFI_STATUS EFIAPI EfiDhcp4GetModeData(IN EFI_DHCP4_PROTOCOL *This, OUT EFI_DHCP4_MODE_DATA *Dhcp4ModeData)
Definition: Dhcp4Impl.c:349
EFI_STATUS DhcpInitRequest(IN DHCP_SERVICE *DhcpSb)
Definition: Dhcp4Io.c:24
EFI_STATUS DhcpSendMessage(IN DHCP_SERVICE *DhcpSb, IN EFI_DHCP4_PACKET *Seed, IN DHCP_PARAMETER *Para, IN UINT8 Type, IN UINT8 *Msg)
Definition: Dhcp4Io.c:1114
EFI_STATUS DhcpSetState(IN OUT DHCP_SERVICE *DhcpSb, IN INTN State, IN BOOLEAN CallUser)
Definition: Dhcp4Io.c:179
VOID DhcpCleanLease(IN DHCP_SERVICE *DhcpSb)
Definition: Dhcp4Io.c:424
VOID EFIAPI DhcpOnPacketSent(NET_BUF *Packet, UDP_END_POINT *EndPoint, EFI_STATUS IoStatus, VOID *Context)
Definition: Dhcp4Io.c:1084
EFI_STATUS DhcpBuild(IN EFI_DHCP4_PACKET *SeedPacket, IN UINT32 DeleteCount, IN UINT8 *DeleteList OPTIONAL, IN UINT32 AppendCount, IN EFI_DHCP4_PACKET_OPTION *AppendList[] OPTIONAL, OUT EFI_DHCP4_PACKET **NewPacket)
Definition: Dhcp4Option.c:770
EFI_STATUS DhcpIterateOptions(IN EFI_DHCP4_PACKET *Packet, IN DHCP_CHECK_OPTION Check OPTIONAL, IN VOID *Context)
Definition: Dhcp4Option.c:382
EFI_STATUS DhcpValidateOptions(IN EFI_DHCP4_PACKET *Packet, OUT DHCP_PARAMETER **Para OPTIONAL)
Definition: Dhcp4Option.c:641
#define DHCP_OPTION_MAGIC
Definition: Dhcp4Option.h:16
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
#define NULL
Definition: Base.h:319
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
#define BASE_CR(Record, TYPE, Field)
Definition: Base.h:891
#define MAX(a, b)
Definition: Base.h:992
VOID EFIAPI NetbufFree(IN NET_BUF *Nbuf)
Definition: NetBuffer.c:195
UINT32 EFIAPI NetbufQueCopy(IN NET_BUF_QUEUE *NbufQue, IN UINT32 Offset, IN UINT32 Len, OUT UINT8 *Dest)
Definition: NetBuffer.c:1438
VOID EFIAPI NetbufQueFlush(IN OUT NET_BUF_QUEUE *NbufQue)
Definition: NetBuffer.c:1592
UINT32 EFIAPI NetbufCopy(IN NET_BUF *Nbuf, IN UINT32 Offset, IN UINT32 Len, IN UINT8 *Dest)
Definition: NetBuffer.c:1206
NET_BUF *EFIAPI NetbufAlloc(IN UINT32 Len)
Definition: NetBuffer.c:89
NET_BUF *EFIAPI NetbufFromExt(IN NET_FRAGMENT *ExtFragment, IN UINT32 ExtNum, IN UINT32 HeadSpace, IN UINT32 HeadLen, IN NET_VECTOR_EXT_FREE ExtFree, IN VOID *Arg OPTIONAL)
Definition: NetBuffer.c:693
EFI_STATUS EFIAPI NetLibDetectMediaWaitTimeout(IN EFI_HANDLE ServiceHandle, IN UINT64 Timeout, OUT EFI_STATUS *MediaState)
Definition: DxeNetLib.c:2683
INTN EFIAPI NetGetIpClass(IN IP4_ADDR Addr)
Definition: DxeNetLib.c:643
UINT8 *EFIAPI NetbufAllocSpace(IN OUT NET_BUF *Nbuf, IN UINT32 Len, IN BOOLEAN FromHead)
Definition: NetBuffer.c:1015
VOID EFIAPI NetbufQueAppend(IN OUT NET_BUF_QUEUE *NbufQue, IN OUT NET_BUF *Nbuf)
Definition: NetBuffer.c:1374
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
VOID EFIAPI UdpIoCleanIo(IN UDP_IO *UdpIo)
Definition: DxeUdpIoLib.c:915
EFI_STATUS EFIAPI UdpIoRecvDatagram(IN UDP_IO *UdpIo, IN UDP_IO_CALLBACK CallBack, IN VOID *Context, IN UINT32 HeadLen)
Definition: DxeUdpIoLib.c:1084
EFI_STATUS EFIAPI UdpIoSendDatagram(IN UDP_IO *UdpIo, IN NET_BUF *Packet, IN UDP_END_POINT *EndPoint OPTIONAL, IN EFI_IP_ADDRESS *Gateway OPTIONAL, IN UDP_IO_CALLBACK CallBack, IN VOID *Context)
Definition: DxeUdpIoLib.c:971
EFI_STATUS EFIAPI UdpIoFreeIo(IN UDP_IO *UdpIo)
Definition: DxeUdpIoLib.c:809
UDP_IO *EFIAPI UdpIoCreateIo(IN EFI_HANDLE Controller, IN EFI_HANDLE ImageHandle, IN UDP_IO_CONFIG Configure, IN UINT8 UdpVersion, IN VOID *Context)
Definition: DxeUdpIoLib.c:602
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_EVENT
Definition: UefiBaseType.h:37
UINTN EFI_TPL
Definition: UefiBaseType.h:41
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_BOOT_SERVICES * gBS
VOID * CallbackContext
Definition: Dhcp4.h:282
UINT32 * DiscoverTimeout
Definition: Dhcp4.h:253
UINT32 * RequestTimeout
Definition: Dhcp4.h:265
EFI_DHCP4_CALLBACK Dhcp4Callback
Definition: Dhcp4.h:278
UINT32 RequestTryCount
Definition: Dhcp4.h:259
UINT32 DiscoverTryCount
Definition: Dhcp4.h:247
EFI_IPv4_ADDRESS ClientAddr
Client IP address from client.
Definition: Dhcp4.h:59
UINT8 ClientHwAddr[16]
Client hardware address.
Definition: Dhcp4.h:63
UINT32 Length
Definition: Dhcp4.h:79
EFI_DHCP4_HEADER Header
Definition: Dhcp4.h:85
UINT32 Size
Definition: Dhcp4.h:74
UINT32 Magik
Definition: Dhcp4.h:89
EFI_DHCP4_LISTEN_POINT * ListenPoints
Definition: Dhcp4.h:387
EFI_DHCP4_PACKET * Packet
Definition: Dhcp4.h:395
EFI_DHCP4_PACKET * ResponseList
Definition: Dhcp4.h:403