+++ /dev/null
-/** @file\r
- Translate the port number into a service name\r
-\r
- Copyright (c) 2011 - 2012, Intel Corporation. All rights reserved.<BR>\r
- SPDX-License-Identifier: BSD-2-Clause-Patent\r
-**/\r
-#include <errno.h>\r
-#include <netdb.h>\r
-#include <stdio.h>\r
-#include <string.h>\r
-#include <Uefi.h>\r
-#include <unistd.h>\r
-\r
-#include <arpa/nameser.h>\r
-#include <arpa/nameser_compat.h>\r
-\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiLib.h>\r
-\r
-#include <sys/socket.h>\r
-\r
-/**\r
- Translate the IP address into a host name\r
-\r
- @param[in] Argc The number of arguments\r
- @param[in] Argv The argument value array\r
-\r
- @retval 0 The application exited normally.\r
- @retval Other An error occurred.\r
-**/\r
-int\r
-main (\r
- IN int Argc,\r
- IN char **Argv\r
- )\r
-{\r
- UINTN Index;\r
- UINT8 IpAddress[4];\r
- struct hostent * pHost;\r
- UINT8 * pIpAddress;\r
- char ** ppName;\r
- UINT32 RemoteAddress[4];\r
-\r
- //\r
- // Determine if the IPv4 address is specified\r
- //\r
- if (( 2 != Argc )\r
- || ( 4 != sscanf ( Argv[1],\r
- "%d.%d.%d.%d",\r
- &RemoteAddress[0],\r
- &RemoteAddress[1],\r
- &RemoteAddress[2],\r
- &RemoteAddress[3]))\r
- || ( 255 < RemoteAddress[0])\r
- || ( 255 < RemoteAddress[1])\r
- || ( 255 < RemoteAddress[2])\r
- || ( 255 < RemoteAddress[3])) {\r
- Print ( L"%a <IPv4 Address>\r\n", Argv[0]);\r
- }\r
- else {\r
- //\r
- // Translate the address into a host name\r
- //\r
- IpAddress[0] = (UINT8)RemoteAddress[0];\r
- IpAddress[1] = (UINT8)RemoteAddress[1];\r
- IpAddress[2] = (UINT8)RemoteAddress[2];\r
- IpAddress[3] = (UINT8)RemoteAddress[3];\r
- pHost = gethostbyaddr ( (const char *)&IpAddress[0], INADDRSZ, AF_INET );\r
- if ( NULL == pHost ) {\r
- Print ( L"ERROR - host not found, h_errno: %d\r\n", h_errno );\r
- }\r
- else {\r
- pIpAddress = (UINT8 *)pHost->h_addr_list[ 0 ];\r
- Print ( L"%d.%d.%d.%d, %a\r\n",\r
- pIpAddress[0],\r
- pIpAddress[1],\r
- pIpAddress[2],\r
- pIpAddress[3],\r
- pHost->h_name );\r
-\r
- //\r
- // Display the other addresses\r
- //\r
- for ( Index = 1; NULL != pHost->h_addr_list[Index]; Index++ ) {\r
- pIpAddress = (UINT8 *)pHost->h_addr_list[Index];\r
- Print ( L"%d.%d.%d.%d\r\n",\r
- pIpAddress[0],\r
- pIpAddress[1],\r
- pIpAddress[2],\r
- pIpAddress[3]);\r
- }\r
-\r
- //\r
- // Display the list of aliases\r
- //\r
- ppName = pHost->h_aliases;\r
- if (( NULL == ppName ) || ( NULL == *ppName )) {\r
- Print ( L"No aliases\r\n" );\r
- }\r
- else {\r
- Print ( L"Aliases: " );\r
- while ( NULL != *ppName ) {\r
- //\r
- // Display the alias\r
- //\r
- Print ( L"%a", *ppName );\r
-\r
- //\r
- // Set the next alias\r
- //\r
- ppName += 1;\r
- if ( NULL != *ppName ) {\r
- Print ( L", " );\r
- }\r
- }\r
- Print ( L"\r\n" );\r
- }\r
- }\r
- }\r
-\r
- //\r
- // All done\r
- //\r
- return errno;\r
-}\r