33 Seed->Length =
sizeof (Seed->Dhcp4);
34 Header = &Seed->Dhcp4.Header;
36 Header->OpCode = DHCP4_OPCODE_REQUEST;
37 Header->HwType = InterfaceInfo->IfType;
38 Header->HwAddrLen = (UINT8)InterfaceInfo->HwAddressSize;
39 CopyMem (Header->ClientHwAddr, &(InterfaceInfo->HwAddress), Header->HwAddrLen);
41 Seed->Dhcp4.Magik = DHCP4_MAGIC;
42 Seed->Dhcp4.Option[0] = DHCP4_TAG_EOP;
59 if ((Event ==
NULL) || (Context ==
NULL)) {
63 *((BOOLEAN *)Context) =
TRUE;
100 Status = Dhcp4->Parse (Dhcp4, Packet, &OptionCount, OptionList);
101 if (Status != EFI_BUFFER_TOO_SMALL) {
102 return EFI_DEVICE_ERROR;
106 if (OptionList ==
NULL) {
107 return EFI_OUT_OF_RESOURCES;
110 Status = Dhcp4->Parse (Dhcp4, Packet, &OptionCount, OptionList);
111 if (EFI_ERROR (Status)) {
112 gBS->FreePool (OptionList);
113 return EFI_DEVICE_ERROR;
116 Status = EFI_NOT_FOUND;
118 for (Index = 0; Index < OptionCount; Index++) {
122 if (OptionList[Index]->OpCode == DHCP4_TAG_DNS_SERVER) {
123 if (((OptionList[Index]->Length & 0x3) != 0) || (OptionList[Index]->Length == 0)) {
124 Status = EFI_DEVICE_ERROR;
128 ServerCount = OptionList[Index]->
Length/4;
130 if (ServerList ==
NULL) {
131 return EFI_OUT_OF_RESOURCES;
134 for (Count = 0; Count < ServerCount; Count++) {
138 *(DnsServerInfor->ServerCount) = ServerCount;
139 DnsServerInfor->ServerList = ServerList;
145 gBS->FreePool (OptionList);
188 Status = This->Parse (This, Packet, &OptionCount,
NULL);
189 if (Status != EFI_BUFFER_TOO_SMALL) {
190 return EFI_DEVICE_ERROR;
194 if (OptionList ==
NULL) {
195 return EFI_OUT_OF_RESOURCES;
198 Status = This->Parse (This, Packet, &OptionCount, OptionList);
199 if (EFI_ERROR (Status)) {
200 gBS->FreePool (OptionList);
201 return EFI_DEVICE_ERROR;
206 for (Index = 0; Index < OptionCount; Index++) {
207 OptionList[Index]->
OpCode = NTOHS (OptionList[Index]->OpCode);
208 OptionList[Index]->
OpLen = NTOHS (OptionList[Index]->OpLen);
213 if (OptionList[Index]->OpCode == DHCP6_TAG_DNS_SERVER) {
214 if (((OptionList[Index]->OpLen & 0xf) != 0) || (OptionList[Index]->OpLen == 0)) {
215 Status = EFI_DEVICE_ERROR;
216 gBS->FreePool (OptionList);
220 ServerCount = OptionList[Index]->
OpLen/16;
222 if (ServerList ==
NULL) {
223 gBS->FreePool (OptionList);
224 return EFI_OUT_OF_RESOURCES;
227 for (Count = 0; Count < ServerCount; Count++) {
231 *(DnsServerInfor->ServerCount) = ServerCount;
232 DnsServerInfor->ServerList = ServerList;
236 gBS->FreePool (OptionList);
257 OUT UINT32 *DnsServerCount,
283 Image = Instance->Service->ImageHandle;
284 Controller = Instance->Service->ControllerHandle;
286 MnpChildHandle =
NULL;
295 InterfaceInfo =
NULL;
298 if (EFI_ERROR (Status)) {
299 DEBUG ((DEBUG_ERROR,
"%a failed to generate random number: %r\n", __func__, Status));
303 ZeroMem ((UINT8 *)ParaList,
sizeof (ParaList));
311 DnsServerInfor.ServerCount = DnsServerCount;
330 &gEfiManagedNetworkServiceBindingProtocolGuid,
333 if (EFI_ERROR (Status)) {
337 Status =
gBS->OpenProtocol (
339 &gEfiManagedNetworkProtocolGuid,
343 EFI_OPEN_PROTOCOL_BY_DRIVER
345 if (EFI_ERROR (Status)) {
360 Status = Mnp->Configure (Mnp, &MnpConfigData);
361 if (EFI_ERROR (Status)) {
371 &gEfiDhcp4ServiceBindingProtocolGuid,
374 if (EFI_ERROR (Status)) {
378 Status =
gBS->OpenProtocol (
380 &gEfiDhcp4ProtocolGuid,
384 EFI_OPEN_PROTOCOL_BY_DRIVER
386 if (EFI_ERROR (Status)) {
393 Status =
gBS->HandleProtocol (Controller, &gEfiIp4Config2ProtocolGuid, (VOID **)&Ip4Config2);
394 if (EFI_ERROR (Status)) {
399 if (EFI_ERROR (Status) && (Status != EFI_BUFFER_TOO_SMALL)) {
405 Status = EFI_OUT_OF_RESOURCES;
410 if (EFI_ERROR (Status)) {
419 Status =
gBS->CreateEvent (
426 if (EFI_ERROR (Status)) {
438 Status = EFI_OUT_OF_RESOURCES;
442 if (Instance->Dns4CfgData.UseDefaultSetting) {
457 if (ParaList[0] ==
NULL) {
458 Status = EFI_OUT_OF_RESOURCES;
462 ParaList[0]->
OpCode = DHCP4_TAG_TYPE;
464 ParaList[0]->
Data[0] = DHCP4_MSG_REQUEST;
467 if (ParaList[1] ==
NULL) {
468 Status = EFI_OUT_OF_RESOURCES;
472 ParaList[1]->
OpCode = DHCP4_TAG_PARA_LIST;
474 ParaList[1]->
Data[0] = DHCP4_TAG_DNS_SERVER;
476 Status = Dhcp4->Build (Dhcp4, &SeedPacket, 0,
NULL, 2, ParaList, &Token.
Packet);
480 Token.
Packet->Dhcp4.
Header.Reserved = HTONS ((UINT16)0x8000);
482 if (Instance->Dns4CfgData.UseDefaultSetting) {
495 Status = Dhcp4->TransmitReceive (Dhcp4, &Token);
496 if (EFI_ERROR (Status)) {
504 Status = Mnp->Poll (Mnp);
510 if (IsDone && !EFI_ERROR (Token.
Status)) {
513 if (!EFI_ERROR (Status)) {
518 *DnsServerList = DnsServerInfor.ServerList;
529 for (Index = 0; Index < 2; Index++) {
530 if (ParaList[Index] !=
NULL) {
553 Dhcp4->Configure (Dhcp4,
NULL);
557 &gEfiDhcp4ProtocolGuid,
563 if (Dhcp4Handle !=
NULL) {
567 &gEfiDhcp4ServiceBindingProtocolGuid,
573 Mnp->Configure (Mnp,
NULL);
577 &gEfiManagedNetworkProtocolGuid,
586 &gEfiManagedNetworkServiceBindingProtocolGuid,
611 OUT UINT32 *DnsServerCount,
632 DnsServerInfor.ServerCount = DnsServerCount;
649 &gEfiDhcp6ServiceBindingProtocolGuid,
652 if (EFI_ERROR (Status)) {
656 Status =
gBS->OpenProtocol (
658 &gEfiDhcp6ProtocolGuid,
662 EFI_OPEN_PROTOCOL_BY_DRIVER
664 if (EFI_ERROR (Status)) {
670 Status = EFI_OUT_OF_RESOURCES;
678 Oro->
OpCode = HTONS (DHCP6_TAG_DNS_REQUEST);
679 Oro->
OpLen = HTONS (2);
680 Oro->
Data[1] = DHCP6_TAG_DNS_SERVER;
682 InfoReqReXmit.
Irt = 4;
683 InfoReqReXmit.
Mrc = 1;
684 InfoReqReXmit.
Mrt = 10;
685 InfoReqReXmit.
Mrd = 30;
687 Status = Dhcp6->InfoRequest (
698 if (Status == EFI_NO_MAPPING) {
699 Status =
gBS->CreateEvent (EVT_TIMER, TPL_CALLBACK,
NULL,
NULL, &Timer);
700 if (EFI_ERROR (Status)) {
704 Status =
gBS->SetTimer (
707 DNS_TIME_TO_GETMAP * TICKS_PER_SECOND
710 if (EFI_ERROR (Status)) {
715 TimerStatus =
gBS->CheckEvent (Timer);
716 if (!EFI_ERROR (TimerStatus)) {
717 Status = Dhcp6->InfoRequest (
729 }
while (TimerStatus == EFI_NOT_READY);
732 *DnsServerList = DnsServerInfor.ServerList;
741 gBS->CloseEvent (Timer);
747 &gEfiDhcp6ProtocolGuid,
756 &gEfiDhcp6ServiceBindingProtocolGuid,
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)
EFI_STATUS ParseDhcp4Ack(IN EFI_DHCP4_PROTOCOL *Dhcp4, IN EFI_DHCP4_PACKET *Packet, IN DNS4_SERVER_INFOR *DnsServerInfor)
VOID DnsInitSeedPacket(OUT EFI_DHCP4_PACKET *Seed, IN EFI_IP4_CONFIG2_INTERFACE_INFO *InterfaceInfo)
VOID EFIAPI DhcpCommonNotify(IN EFI_EVENT Event, IN VOID *Context)
EFI_STATUS GetDns4ServerFromDhcp4(IN DNS_INSTANCE *Instance, OUT UINT32 *DnsServerCount, OUT EFI_IPv4_ADDRESS **DnsServerList)
EFI_STATUS GetDns6ServerFromDhcp6(IN EFI_HANDLE Image, IN EFI_HANDLE Controller, OUT UINT32 *DnsServerCount, OUT EFI_IPv6_ADDRESS **DnsServerList)
EFI_STATUS EFIAPI ParseDhcp6Ack(IN EFI_DHCP6_PROTOCOL *This, IN VOID *Context, IN EFI_DHCP6_PACKET *Packet)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
@ Ip4Config2DataTypeInterfaceInfo
#define DEBUG(Expression)
EFI_STATUS EFIAPI NetLibCreateServiceChild(IN EFI_HANDLE Controller, IN EFI_HANDLE Image, IN EFI_GUID *ServiceBindingGuid, IN OUT EFI_HANDLE *ChildHandle)
EFI_STATUS EFIAPI NetLibDestroyServiceChild(IN EFI_HANDLE Controller, IN EFI_HANDLE Image, IN EFI_GUID *ServiceBindingGuid, IN EFI_HANDLE ChildHandle)
EFI_STATUS EFIAPI NetLibDetectMediaWaitTimeout(IN EFI_HANDLE ServiceHandle, IN UINT64 Timeout, OUT EFI_STATUS *MediaState)
EFI_STATUS EFIAPI PseudoRandomU32(OUT UINT32 *Output)
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
EFI_IPv4_ADDRESS ClientAddr
Client IP address from client.
UINT8 ClientHwAddr[16]
Client hardware address.
EFI_IPv4_ADDRESS ListenAddress
EFI_IPv4_ADDRESS SubnetMask
EFI_IPv4_ADDRESS RemoteAddress
EFI_DHCP4_LISTEN_POINT * ListenPoints
EFI_DHCP4_PACKET * Packet
EFI_DHCP4_PACKET * ResponseList
EFI_EVENT CompletionEvent
EFI_MAC_ADDRESS HwAddress
EFI_IPv4_ADDRESS SubnetMask
EFI_IPv4_ADDRESS StationAddress
BOOLEAN EnableBroadcastReceive
BOOLEAN EnableMulticastReceive
BOOLEAN FlushQueuesOnReset
UINT32 ReceivedQueueTimeoutValue
UINT16 ProtocolTypeFilter
UINT32 TransmitQueueTimeoutValue
BOOLEAN DisableBackgroundPolling
BOOLEAN EnableUnicastReceive
BOOLEAN EnablePromiscuousReceive
BOOLEAN EnableReceiveTimestamps