1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-16 10:20:30 +00:00
freebsd/contrib/ntp/libntp/socktohost.c
Ollivier Robert ea906c4152 Merge ntpd & friends 4.2.4p5 from vendor/ntp/dist into head. Next commit
will update usr.sbin/ntp to match this.

MFC after:	2 weeks
2008-08-22 15:58:00 +00:00

32 lines
541 B
C

/*
* socktoa - return a numeric host name from a sockaddr_storage structure
*/
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdio.h>
#include "ntp_fp.h"
#include "lib_strbuf.h"
#include "ntp_stdlib.h"
#include "ntp.h"
char *
socktohost(
struct sockaddr_storage* sock
)
{
register char *buffer;
LIB_GETBUF(buffer);
if (getnameinfo((struct sockaddr *)sock, SOCKLEN(sock), buffer,
LIB_BUFLENGTH /* NI_MAXHOST*/, NULL, 0, 0))
return stoa(sock);
return buffer;
}