1/* $NetBSD: socktohost.c,v 1.1.1.2 2012/01/31 21:24:07 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 24char * 25socktohost( 26 const 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