]>
git.proxmox.com Git - mirror_edk2.git/blob - AppPkg/Applications/Sockets/GetNameInfo/GetNameInfo.c
2 Test the getnameinfo API
4 Copyright (c) 2011-2012, Intel Corporation. All rights reserved.
5 SPDX-License-Identifier: BSD-2-Clause-Patent
16 #include <netinet/in.h>
18 #include <sys/socket.h>
22 char mServiceName
[256];
25 Test the getnameinfo API
27 @param [in] Argc The number of arguments
28 @param [in] Argv The argument value array
30 @retval 0 The application exited normally.
31 @retval Other An error occurred.
40 struct addrinfo
* pAddrInfo
;
42 struct addrinfo
* pInfo
;
46 // Determine if the host name is specified
50 printf ( "%s <host address> <server name>\r\n", Argv
[0]);
54 // Translate the host name
59 pServerName
= Argv
[2];
61 AppStatus
= getaddrinfo ( pHostName
,
65 if ( 0 != AppStatus
) {
66 printf ( "ERROR - address info not found, errno: %d\r\n", AppStatus
);
68 if ( NULL
== pAddrInfo
) {
69 printf ( "ERROR - No address info structure allocated\r\n" );
73 // Walk the list of names
76 while ( NULL
!= pInfo
) {
80 AppStatus
= getnameinfo ((struct sockaddr
*)pInfo
->ai_addr
,
85 sizeof ( mServiceName
),
87 if ( 0 != AppStatus
) {
94 printf ( "%s: HostName\r\n", &mHostName
[0]);
95 printf ( "%s: Service Name\r\n", &mServiceName
[0]);
100 pInfo
= pInfo
->ai_next
;
104 // Done with this structures
106 freeaddrinfo ( pAddrInfo
);