Retrieve the host address using the EFI_DNS4_PROTOCOL. @param[in] HttpInstance Pointer to HTTP_PROTOCOL instance. @param[in] HostName Pointer to buffer containing hostname. @param[out] IpAddress On output, pointer to buffer containing IPv4 address. @retval EFI_SUCCESS Operation succeeded. @retval EFI_OUT_OF_RESOURCES Failed to allocat
| 22 | |
| 23 | **/ |
| 24 | EFI_STATUS |
| 25 | HttpDns4 ( |
| 26 | IN HTTP_PROTOCOL *HttpInstance, |
| 27 | IN CHAR16 *HostName, |
| 28 | OUT EFI_IPv4_ADDRESS *IpAddress |
| 29 | ) |
| 30 | { |
| 31 | EFI_STATUS Status; |
| 32 | EFI_DNS4_PROTOCOL *Dns4; |
| 33 | EFI_DNS4_CONFIG_DATA Dns4CfgData; |
| 34 | EFI_DNS4_COMPLETION_TOKEN Token; |
| 35 | BOOLEAN IsDone; |
| 36 | HTTP_SERVICE *Service; |
| 37 | EFI_HANDLE Dns4Handle; |
| 38 | EFI_IP4_CONFIG2_PROTOCOL *Ip4Config2; |
| 39 | UINTN DnsServerListCount; |
| 40 | EFI_IPv4_ADDRESS *DnsServerList; |
| 41 | UINTN DataSize; |
| 42 | |
| 43 | |
| 44 | Service = HttpInstance->Service; |
| 45 | ASSERT (Service != NULL); |
| 46 | |
| 47 | DnsServerList = NULL; |
| 48 | DnsServerListCount = 0; |
| 49 | ZeroMem (&Token, sizeof (EFI_DNS4_COMPLETION_TOKEN)); |
| 50 | |
| 51 | // |
| 52 | // Get DNS server list from EFI IPv4 Configuration II protocol. |
| 53 | // |
| 54 | Status = gBS->HandleProtocol (Service->ControllerHandle, &gEfiIp4Config2ProtocolGuid, (VOID **) &Ip4Config2); |
| 55 | if (!EFI_ERROR (Status)) { |
| 56 | // |
| 57 | // Get the required size. |
| 58 | // |
| 59 | DataSize = 0; |
| 60 | Status = Ip4Config2->GetData (Ip4Config2, Ip4Config2DataTypeDnsServer, &DataSize, NULL); |
| 61 | if (Status == EFI_BUFFER_TOO_SMALL) { |
| 62 | DnsServerList = AllocatePool (DataSize); |
| 63 | if (DnsServerList == NULL) { |
| 64 | return EFI_OUT_OF_RESOURCES; |
| 65 | } |
| 66 | |
| 67 | Status = Ip4Config2->GetData (Ip4Config2, Ip4Config2DataTypeDnsServer, &DataSize, DnsServerList); |
| 68 | if (EFI_ERROR (Status)) { |
| 69 | FreePool (DnsServerList); |
| 70 | DnsServerList = NULL; |
| 71 | } else { |
| 72 | DnsServerListCount = DataSize / sizeof (EFI_IPv4_ADDRESS); |
| 73 | } |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | Dns4Handle = NULL; |
| 78 | Dns4 = NULL; |
| 79 | |
| 80 | // |
| 81 | // Create a DNS child instance and get the protocol. |
no test coverage detected