]>
Commit | Line | Data |
---|---|---|
4684b66f | 1 | /** @file\r |
2 | Translate the network name into an IP address\r | |
3 | \r | |
b81cc7d6 OM |
4 | Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>\r |
5 | This program and the accompanying materials are licensed and made available under\r | |
6 | the terms and conditions of the BSD License that accompanies this distribution.\r | |
7 | The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php.\r | |
4684b66f | 9 | \r |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
4684b66f | 12 | **/\r |
4684b66f | 13 | #include <errno.h>\r |
14 | #include <netdb.h>\r | |
15 | #include <string.h>\r | |
16 | #include <Uefi.h>\r | |
17 | #include <unistd.h>\r | |
18 | \r | |
19 | #include <Library/DebugLib.h>\r | |
20 | #include <Library/UefiLib.h>\r | |
21 | \r | |
22 | #include <sys/socket.h>\r | |
23 | \r | |
59bc0593 | 24 | char mBuffer[65536];\r |
4684b66f | 25 | \r |
26 | \r | |
b81cc7d6 | 27 | /** Translate the network name into an IP address\r |
4684b66f | 28 | \r |
b81cc7d6 OM |
29 | @param[in] Argc The number of arguments\r |
30 | @param[in] Argv The argument value array\r | |
4684b66f | 31 | \r |
32 | @retval 0 The application exited normally.\r | |
33 | @retval Other An error occurred.\r | |
34 | **/\r | |
35 | int\r | |
36 | main (\r | |
37 | IN int Argc,\r | |
38 | IN char **Argv\r | |
39 | )\r | |
40 | {\r | |
4684b66f | 41 | UINT8 * pIpAddress;\r |
42 | struct netent * pNetwork;\r | |
43 | \r | |
44 | DEBUG (( DEBUG_INFO,\r | |
45 | "%a starting\r\n",\r | |
46 | Argv[0]));\r | |
47 | \r | |
4684b66f | 48 | // Determine if the network name is specified\r |
4684b66f | 49 | if ( 1 == Argc ) {\r |
50 | Print ( L"%a <network name>\r\n", Argv[0]);\r | |
51 | }\r | |
52 | else {\r | |
4684b66f | 53 | // Translate the net name\r |
4684b66f | 54 | pNetwork = getnetbyname ( Argv[1]);\r |
55 | if ( NULL == pNetwork ) {\r | |
56 | Print ( L"ERROR - network not found, errno: %d\r\n", errno );\r | |
57 | }\r | |
58 | else {\r | |
53c31c51 | 59 | pIpAddress = (UINT8 *)(UINTN)&pNetwork->n_net;\r |
4684b66f | 60 | Print ( L"%a: Type %d, %d.%d.%d.%d\r\n",\r |
61 | pNetwork->n_name,\r | |
62 | pNetwork->n_addrtype,\r | |
63 | pIpAddress[0],\r | |
64 | pIpAddress[1],\r | |
65 | pIpAddress[2],\r | |
66 | pIpAddress[3]);\r | |
67 | }\r | |
68 | }\r | |
4684b66f | 69 | // All done\r |
4684b66f | 70 | return errno;\r |
71 | }\r |