64 if (Instance->UdpIo !=
NULL) {
93 return EFI_OUT_OF_RESOURCES;
96 DnsIns->Signature = DNS_INSTANCE_SIGNATURE;
98 DnsIns->State = DNS_STATE_UNCONFIGED;
99 DnsIns->InDestroy =
FALSE;
100 DnsIns->Service = Service;
102 if (Service->IpVersion == IP_VERSION_4) {
103 CopyMem (&DnsIns->Dns4, &mDns4Protocol, sizeof (DnsIns->Dns4));
106 CopyMem (&DnsIns->Dns6, &mDns6Protocol, sizeof (DnsIns->Dns6));
111 Service->ControllerHandle,
112 Service->ImageHandle,
117 if (DnsIns->UdpIo ==
NULL) {
119 return EFI_OUT_OF_RESOURCES;
146 UINTN NumberOfChildren;
149 if ((Entry ==
NULL) || (Context ==
NULL)) {
150 return EFI_INVALID_PARAMETER;
153 Instance = NET_LIST_USER_STRUCT_S (Entry,
DNS_INSTANCE, Link, DNS_INSTANCE_SIGNATURE);
162 return ServiceBinding->DestroyChild (ServiceBinding, Instance->ChildHandle);
200 if (DnsSb->TimerToGetMap !=
NULL) {
201 gBS->CloseEvent (DnsSb->TimerToGetMap);
204 if (DnsSb->Timer !=
NULL) {
205 gBS->CloseEvent (DnsSb->Timer);
246 return EFI_OUT_OF_RESOURCES;
249 DnsSb->Signature = DNS_SERVICE_SIGNATURE;
251 if (IpVersion == IP_VERSION_4) {
252 DnsSb->ServiceBinding = mDns4ServiceBinding;
254 DnsSb->ServiceBinding = mDns6ServiceBinding;
257 DnsSb->Dns4ChildrenNum = 0;
260 DnsSb->Dns6ChildrenNum = 0;
263 DnsSb->ControllerHandle = Controller;
264 DnsSb->ImageHandle = Image;
266 DnsSb->TimerToGetMap =
NULL;
276 Status =
gBS->CreateEvent (
281 &DnsSb->TimerToGetMap
283 if (EFI_ERROR (Status)) {
291 Status =
gBS->CreateEvent (
292 EVT_NOTIFY_SIGNAL | EVT_TIMER,
298 if (EFI_ERROR (Status)) {
299 if (DnsSb->TimerToGetMap !=
NULL) {
300 gBS->CloseEvent (DnsSb->TimerToGetMap);
307 DnsSb->ConnectUdp =
NULL;
315 if (DnsSb->ConnectUdp ==
NULL) {
316 if (DnsSb->TimerToGetMap !=
NULL) {
317 gBS->CloseEvent (DnsSb->TimerToGetMap);
320 gBS->CloseEvent (DnsSb->Timer);
322 return EFI_DEVICE_ERROR;
353 ItemServerIp4 =
NULL;
355 ItemServerIp6 =
NULL;
361 if (EFI_ERROR (Status)) {
368 if (mDriverData !=
NULL) {
369 if (mDriverData->Timer !=
NULL) {
370 gBS->CloseEvent (mDriverData->Timer);
375 ASSERT (Entry !=
NULL);
376 ItemCache4 = NET_LIST_USER_STRUCT (Entry,
DNS4_CACHE, AllCacheLink);
382 while (!
IsListEmpty (&mDriverData->Dns4ServerList)) {
384 ASSERT (Entry !=
NULL);
385 ItemServerIp4 = NET_LIST_USER_STRUCT (Entry,
DNS4_SERVER_IP, AllServerLink);
389 while (!
IsListEmpty (&mDriverData->Dns6CacheList)) {
391 ASSERT (Entry !=
NULL);
392 ItemCache6 = NET_LIST_USER_STRUCT (Entry,
DNS6_CACHE, AllCacheLink);
398 while (!
IsListEmpty (&mDriverData->Dns6ServerList)) {
400 ASSERT (Entry !=
NULL);
401 ItemServerIp6 = NET_LIST_USER_STRUCT (Entry,
DNS6_SERVER_IP, AllServerLink);
444 if (EFI_ERROR (Status)) {
459 if (EFI_ERROR (Status)) {
467 if (mDriverData ==
NULL) {
468 Status = EFI_OUT_OF_RESOURCES;
475 Status =
gBS->CreateEvent (
476 EVT_NOTIFY_SIGNAL | EVT_TIMER,
482 if (EFI_ERROR (Status)) {
486 Status =
gBS->SetTimer (mDriverData->Timer,
TimerPeriodic, TICKS_PER_SECOND);
487 if (EFI_ERROR (Status)) {
499 gBS->CloseEvent (mDriverData->Timer);
576 Status =
gBS->OpenProtocol (
578 &gEfiDns4ServiceBindingProtocolGuid,
580 This->DriverBindingHandle,
582 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
584 if (!EFI_ERROR (Status)) {
585 return EFI_ALREADY_STARTED;
591 Status =
gBS->OpenProtocol (
593 &gEfiUdp4ServiceBindingProtocolGuid,
595 This->DriverBindingHandle,
597 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
649 Status =
DnsCreateService (ControllerHandle, This->DriverBindingHandle, IP_VERSION_4, &DnsSb);
650 if (EFI_ERROR (Status)) {
654 ASSERT (DnsSb !=
NULL);
657 if (EFI_ERROR (Status)) {
664 Status =
gBS->InstallMultipleProtocolInterfaces (
666 &gEfiDns4ServiceBindingProtocolGuid,
667 &DnsSb->ServiceBinding,
670 if (EFI_ERROR (Status)) {
731 if (NicHandle ==
NULL) {
735 Status =
gBS->OpenProtocol (
737 &gEfiDns4ServiceBindingProtocolGuid,
738 (VOID **)&ServiceBinding,
739 This->DriverBindingHandle,
741 EFI_OPEN_PROTOCOL_GET_PROTOCOL
743 if (EFI_ERROR (Status)) {
744 return EFI_DEVICE_ERROR;
747 DnsSb = DNS_SERVICE_FROM_THIS (ServiceBinding);
753 List = &DnsSb->Dns4ChildrenList;
754 Context.ServiceBinding = ServiceBinding;
755 Context.NumberOfChildren = NumberOfChildren;
756 Context.ChildHandleBuffer = ChildHandleBuffer;
765 if ((NumberOfChildren == 0) &&
IsListEmpty (&DnsSb->Dns4ChildrenList)) {
766 gBS->UninstallProtocolInterface (
768 &gEfiDns4ServiceBindingProtocolGuid,
774 if (gDnsControllerNameTable !=
NULL) {
776 gDnsControllerNameTable =
NULL;
840 Status =
gBS->OpenProtocol (
842 &gEfiDns6ServiceBindingProtocolGuid,
844 This->DriverBindingHandle,
846 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
848 if (!EFI_ERROR (Status)) {
849 return EFI_ALREADY_STARTED;
855 Status =
gBS->OpenProtocol (
857 &gEfiUdp6ServiceBindingProtocolGuid,
859 This->DriverBindingHandle,
861 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
913 Status =
DnsCreateService (ControllerHandle, This->DriverBindingHandle, IP_VERSION_6, &DnsSb);
914 if (EFI_ERROR (Status)) {
918 ASSERT (DnsSb !=
NULL);
921 if (EFI_ERROR (Status)) {
928 Status =
gBS->InstallMultipleProtocolInterfaces (
930 &gEfiDns6ServiceBindingProtocolGuid,
931 &DnsSb->ServiceBinding,
935 if (EFI_ERROR (Status)) {
996 if (NicHandle ==
NULL) {
1000 Status =
gBS->OpenProtocol (
1002 &gEfiDns6ServiceBindingProtocolGuid,
1003 (VOID **)&ServiceBinding,
1004 This->DriverBindingHandle,
1006 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1008 if (EFI_ERROR (Status)) {
1009 return EFI_DEVICE_ERROR;
1012 DnsSb = DNS_SERVICE_FROM_THIS (ServiceBinding);
1018 List = &DnsSb->Dns6ChildrenList;
1019 Context.ServiceBinding = ServiceBinding;
1020 Context.NumberOfChildren = NumberOfChildren;
1021 Context.ChildHandleBuffer = ChildHandleBuffer;
1030 if ((NumberOfChildren == 0) &&
IsListEmpty (&DnsSb->Dns6ChildrenList)) {
1031 gBS->UninstallProtocolInterface (
1033 &gEfiDns6ServiceBindingProtocolGuid,
1039 if (gDnsControllerNameTable !=
NULL) {
1041 gDnsControllerNameTable =
NULL;
1082 if ((This ==
NULL) || (ChildHandle ==
NULL)) {
1083 return EFI_INVALID_PARAMETER;
1086 DnsSb = DNS_SERVICE_FROM_THIS (This);
1089 if (EFI_ERROR (Status)) {
1093 ASSERT (Instance !=
NULL);
1098 Status =
gBS->InstallMultipleProtocolInterfaces (
1100 &gEfiDns4ProtocolGuid,
1104 if (EFI_ERROR (Status)) {
1108 Instance->ChildHandle = *ChildHandle;
1113 Status =
gBS->OpenProtocol (
1114 DnsSb->ConnectUdp->UdpHandle,
1115 &gEfiUdp4ProtocolGuid,
1118 Instance->ChildHandle,
1119 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
1121 if (EFI_ERROR (Status)) {
1122 gBS->UninstallMultipleProtocolInterfaces (
1123 Instance->ChildHandle,
1124 &gEfiDns4ProtocolGuid,
1135 Status =
gBS->OpenProtocol (
1136 Instance->UdpIo->UdpHandle,
1137 &gEfiUdp4ProtocolGuid,
1140 Instance->ChildHandle,
1141 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
1143 if (EFI_ERROR (Status)) {
1147 gBS->CloseProtocol (
1148 DnsSb->ConnectUdp->UdpHandle,
1149 &gEfiUdp4ProtocolGuid,
1154 gBS->UninstallMultipleProtocolInterfaces (
1155 Instance->ChildHandle,
1156 &gEfiDns4ProtocolGuid,
1167 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
1170 DnsSb->Dns4ChildrenNum++;
1172 gBS->RestoreTPL (OldTpl);
1214 if ((This ==
NULL) || (ChildHandle ==
NULL)) {
1215 return EFI_INVALID_PARAMETER;
1221 Status =
gBS->OpenProtocol (
1223 &gEfiDns4ProtocolGuid,
1227 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1230 if (EFI_ERROR (Status)) {
1231 return EFI_UNSUPPORTED;
1234 Instance = DNS_INSTANCE_FROM_THIS_PROTOCOL4 (Dns4);
1235 DnsSb = DNS_SERVICE_FROM_THIS (This);
1237 if (Instance->Service != DnsSb) {
1238 return EFI_INVALID_PARAMETER;
1241 if (Instance->InDestroy) {
1245 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
1247 Instance->InDestroy =
TRUE;
1252 gBS->CloseProtocol (
1253 DnsSb->ConnectUdp->UdpHandle,
1254 &gEfiUdp4ProtocolGuid,
1259 gBS->CloseProtocol (
1260 Instance->UdpIo->UdpHandle,
1261 &gEfiUdp4ProtocolGuid,
1266 gBS->RestoreTPL (OldTpl);
1271 Status =
gBS->UninstallProtocolInterface (
1273 &gEfiDns4ProtocolGuid,
1277 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
1279 if (EFI_ERROR (Status)) {
1280 Instance->InDestroy =
FALSE;
1281 gBS->RestoreTPL (OldTpl);
1286 DnsSb->Dns4ChildrenNum--;
1288 gBS->RestoreTPL (OldTpl);
1326 if ((This ==
NULL) || (ChildHandle ==
NULL)) {
1327 return EFI_INVALID_PARAMETER;
1330 DnsSb = DNS_SERVICE_FROM_THIS (This);
1333 if (EFI_ERROR (Status)) {
1337 ASSERT (Instance !=
NULL);
1342 Status =
gBS->InstallMultipleProtocolInterfaces (
1344 &gEfiDns6ProtocolGuid,
1348 if (EFI_ERROR (Status)) {
1352 Instance->ChildHandle = *ChildHandle;
1357 Status =
gBS->OpenProtocol (
1358 DnsSb->ConnectUdp->UdpHandle,
1359 &gEfiUdp6ProtocolGuid,
1362 Instance->ChildHandle,
1363 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
1365 if (EFI_ERROR (Status)) {
1366 gBS->UninstallMultipleProtocolInterfaces (
1367 Instance->ChildHandle,
1368 &gEfiDns6ProtocolGuid,
1379 Status =
gBS->OpenProtocol (
1380 Instance->UdpIo->UdpHandle,
1381 &gEfiUdp6ProtocolGuid,
1384 Instance->ChildHandle,
1385 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
1387 if (EFI_ERROR (Status)) {
1391 gBS->CloseProtocol (
1392 DnsSb->ConnectUdp->UdpHandle,
1393 &gEfiUdp6ProtocolGuid,
1398 gBS->UninstallMultipleProtocolInterfaces (
1399 Instance->ChildHandle,
1400 &gEfiDns6ProtocolGuid,
1411 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
1414 DnsSb->Dns6ChildrenNum++;
1416 gBS->RestoreTPL (OldTpl);
1458 if ((This ==
NULL) || (ChildHandle ==
NULL)) {
1459 return EFI_INVALID_PARAMETER;
1465 Status =
gBS->OpenProtocol (
1467 &gEfiDns6ProtocolGuid,
1471 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1474 if (EFI_ERROR (Status)) {
1475 return EFI_UNSUPPORTED;
1478 Instance = DNS_INSTANCE_FROM_THIS_PROTOCOL6 (Dns6);
1479 DnsSb = DNS_SERVICE_FROM_THIS (This);
1481 if (Instance->Service != DnsSb) {
1482 return EFI_INVALID_PARAMETER;
1485 if (Instance->InDestroy) {
1489 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
1491 Instance->InDestroy =
TRUE;
1496 gBS->CloseProtocol (
1497 DnsSb->ConnectUdp->UdpHandle,
1498 &gEfiUdp6ProtocolGuid,
1503 gBS->CloseProtocol (
1504 Instance->UdpIo->UdpHandle,
1505 &gEfiUdp6ProtocolGuid,
1510 gBS->RestoreTPL (OldTpl);
1515 Status =
gBS->UninstallProtocolInterface (
1517 &gEfiDns6ProtocolGuid,
1521 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
1523 if (EFI_ERROR (Status)) {
1524 Instance->InDestroy =
FALSE;
1525 gBS->RestoreTPL (OldTpl);
1530 DnsSb->Dns6ChildrenNum--;
1532 gBS->RestoreTPL (OldTpl);
BOOLEAN EFIAPI IsListEmpty(IN CONST LIST_ENTRY *ListHead)
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
LIST_ENTRY *EFIAPI InitializeListHead(IN OUT LIST_ENTRY *ListHead)
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
VOID DnsDestroyInstance(IN DNS_INSTANCE *Instance)
EFI_STATUS EFIAPI DnsDestroyChildEntryInHandleBuffer(IN LIST_ENTRY *Entry, IN VOID *Context)
EFI_STATUS EFIAPI DnsDriverEntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
EFI_STATUS EFIAPI Dns4DriverBindingStop(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer OPTIONAL)
EFI_STATUS EFIAPI Dns4ServiceBindingDestroyChild(IN EFI_SERVICE_BINDING_PROTOCOL *This, IN EFI_HANDLE ChildHandle)
EFI_STATUS DnsCreateService(IN EFI_HANDLE Controller, IN EFI_HANDLE Image, IN UINT8 IpVersion, OUT DNS_SERVICE **Service)
EFI_STATUS EFIAPI Dns6DriverBindingStop(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer OPTIONAL)
EFI_STATUS EFIAPI Dns6ServiceBindingCreateChild(IN EFI_SERVICE_BINDING_PROTOCOL *This, IN EFI_HANDLE *ChildHandle)
EFI_STATUS EFIAPI DnsUnload(IN EFI_HANDLE ImageHandle)
EFI_STATUS EFIAPI Dns6DriverBindingStart(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL)
EFI_STATUS EFIAPI Dns6DriverBindingSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL)
EFI_STATUS EFIAPI Dns4DriverBindingSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL)
EFI_STATUS EFIAPI Dns4DriverBindingStart(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL)
EFI_STATUS EFIAPI Dns6ServiceBindingDestroyChild(IN EFI_SERVICE_BINDING_PROTOCOL *This, IN EFI_HANDLE ChildHandle)
EFI_STATUS DnsCreateInstance(IN DNS_SERVICE *Service, OUT DNS_INSTANCE **Instance)
VOID DnsDestroyService(IN DNS_SERVICE *DnsSb)
EFI_STATUS EFIAPI Dns4ServiceBindingCreateChild(IN EFI_SERVICE_BINDING_PROTOCOL *This, IN EFI_HANDLE *ChildHandle)
EFI_STATUS EFIAPI DnsConfigNullUdp(IN UDP_IO *UdpIo, IN VOID *Context)
EFI_STATUS Dns4InstanceCancelToken(IN DNS_INSTANCE *Instance, IN EFI_DNS4_COMPLETION_TOKEN *Token)
EFI_STATUS Dns6InstanceCancelToken(IN DNS_INSTANCE *Instance, IN EFI_DNS6_COMPLETION_TOKEN *Token)
VOID EFIAPI DnsOnTimerUpdate(IN EFI_EVENT Event, IN VOID *Context)
VOID EFIAPI DnsOnTimerRetransmit(IN EFI_EVENT Event, IN VOID *Context)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
LIST_ENTRY *EFIAPI NetListRemoveHead(IN OUT LIST_ENTRY *Head)
VOID EFIAPI NetMapInit(IN OUT NET_MAP *Map)
EFI_STATUS EFIAPI NetLibDefaultUnload(IN EFI_HANDLE ImageHandle)
BOOLEAN EFIAPI NetIsInHandleBuffer(IN EFI_HANDLE Handle, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer OPTIONAL)
BOOLEAN EFIAPI NetMapIsEmpty(IN NET_MAP *Map)
EFI_HANDLE EFIAPI NetLibGetNicHandle(IN EFI_HANDLE Controller, IN EFI_GUID *ProtocolGuid)
EFI_STATUS EFIAPI NetDestroyLinkList(IN LIST_ENTRY *List, IN NET_DESTROY_LINK_LIST_CALLBACK CallBack, IN VOID *Context OPTIONAL, OUT UINTN *ListLength OPTIONAL)
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gDnsComponentName2
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gDnsComponentName
EFI_STATUS EFIAPI UdpIoFreeIo(IN UDP_IO *UdpIo)
UDP_IO *EFIAPI UdpIoCreateIo(IN EFI_HANDLE Controller, IN EFI_HANDLE ImageHandle, IN UDP_IO_CONFIG Configure, IN UINT8 UdpVersion, IN VOID *Context)
EFI_STATUS EFIAPI EfiLibUninstallDriverBindingComponentName2(IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding, IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName OPTIONAL, IN CONST EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2 OPTIONAL)
EFI_STATUS EFIAPI EfiLibInstallDriverBindingComponentName2(IN CONST EFI_HANDLE ImageHandle, IN CONST EFI_SYSTEM_TABLE *SystemTable, IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding, IN EFI_HANDLE DriverBindingHandle, IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName OPTIONAL, IN CONST EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2 OPTIONAL)
EFI_STATUS EFIAPI FreeUnicodeStringTable(IN EFI_UNICODE_STRING_TABLE *UnicodeStringTable)
LIST_ENTRY Dns4CacheList
Ticking timer for DNS cache update.
UINT8 IpVersion
Ticking timer for packet retransmission.
EFI_HANDLE DriverBindingHandle
EFI_IPv4_ADDRESS * IpAddress
EFI_IPv6_ADDRESS * IpAddress