]>
git.proxmox.com Git - mirror_edk2.git/blob - AppPkg/Applications/Sockets/GetHostByName/GetHostByName.c
2 Translate the host name into an IP address
4 Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
13 #include <Library/DebugLib.h>
14 #include <Library/UefiLib.h>
16 #include <sys/socket.h>
21 /** Translate the host name into an IP address
23 @param[in] Argc The number of arguments
24 @param[in] Argv The argument value array
26 @retval 0 The application exited normally.
27 @retval Other An error occurred.
36 struct hostent
* pHost
;
44 // Determine if the host name is specified
46 Print ( L
"%a <host name>\r\n", Argv
[0]);
49 // Translate the host name
50 pHost
= gethostbyname ( Argv
[1]);
51 if ( NULL
== pHost
) {
52 Print ( L
"ERROR - host not found, h_errno: %d\r\n", h_errno
);
55 pIpAddress
= (UINT8
*)pHost
->h_addr
;
56 Print ( L
"%d.%d.%d.%d, Type %d, %a\r\n",
64 // Display the other addresses
65 for ( Index
= 1; NULL
!= pHost
->h_addr_list
[Index
]; Index
++ ) {
66 pIpAddress
= (UINT8
*)pHost
->h_addr_list
[Index
];
67 Print ( L
"%d.%d.%d.%d\r\n",
74 // Display the list of aliases
75 ppName
= pHost
->h_aliases
;
76 if (( NULL
== ppName
) || ( NULL
== *ppName
)) {
77 Print ( L
"No aliases\r\n" );
80 Print ( L
"Aliases: " );
81 while ( NULL
!= *ppName
) {
85 Print ( L
"%a", *ppName
);
91 if ( NULL
!= *ppName
) {