1 /* $NetBSD: socktohost.c,v 1.1.1.1 2009/12/13 16:55:05 kardel Exp $ */ 2 3 /* 4 * socktoa - return a numeric host name from a sockaddr_storage structure 5 */ 6 #include <sys/types.h> 7 #ifdef HAVE_SYS_SOCKET_H 8 #include <sys/socket.h> 9 #endif 10 #ifdef HAVE_NETINET_IN_H 11 #include <netinet/in.h> 12 #endif 13 14 #include <arpa/inet.h> 15 16 #include <stdio.h> 17 18 #include "ntp_fp.h" 19 #include "lib_strbuf.h" 20 #include "ntp_stdlib.h" 21 #include "ntp.h" 22 23 24 char * 25 socktohost( 26 sockaddr_u *sock 27 ) 28 { 29 register char *buffer; 30 31 LIB_GETBUF(buffer); 32 if (getnameinfo(&sock->sa, SOCKLEN(sock), buffer, 33 LIB_BUFLENGTH, NULL, 0, 0)) 34 return stoa(sock); 35 36 return buffer; 37 } 38