Patrick Welche <prlw1@cam.ac.uk>
[netbsd-mini2440.git] / external / bsd / ntp / dist / libntp / socktohost.c
blob7a9abb3dd12259472b9546fd919a4471a769c434
1 /* $NetBSD$ */
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
14 #include <arpa/inet.h>
16 #include <stdio.h>
18 #include "ntp_fp.h"
19 #include "lib_strbuf.h"
20 #include "ntp_stdlib.h"
21 #include "ntp.h"
24 char *
25 socktohost(
26 sockaddr_u *sock
29 register char *buffer;
31 LIB_GETBUF(buffer);
32 if (getnameinfo(&sock->sa, SOCKLEN(sock), buffer,
33 LIB_BUFLENGTH, NULL, 0, 0))
34 return stoa(sock);
36 return buffer;