summaryrefslogtreecommitdiffstats
path: root/contrib/ntp/libntp/socktohost.c
diff options
context:
space:
mode:
authorroberto <roberto@FreeBSD.org>2004-07-20 15:01:56 +0000
committerroberto <roberto@FreeBSD.org>2004-07-20 15:01:56 +0000
commit118e757284cbb8fc4f43a713e892b41504b50a5f (patch)
tree528d12dda44ebdc3ffcc38050f159ac553a69c17 /contrib/ntp/libntp/socktohost.c
parenta85d9ae25e8e8696677bc30feb6eaf7fc150e529 (diff)
downloadFreeBSD-src-118e757284cbb8fc4f43a713e892b41504b50a5f.zip
FreeBSD-src-118e757284cbb8fc4f43a713e892b41504b50a5f.tar.gz
Virgin import of ntpd 4.2.0
Diffstat (limited to 'contrib/ntp/libntp/socktohost.c')
-rw-r--r--contrib/ntp/libntp/socktohost.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/contrib/ntp/libntp/socktohost.c b/contrib/ntp/libntp/socktohost.c
new file mode 100644
index 0000000..7a3b30f
--- /dev/null
+++ b/contrib/ntp/libntp/socktohost.c
@@ -0,0 +1,32 @@
+/*
+ * socktoa - return a numeric host name from a sockaddr_storage structure
+ */
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.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;
+}
OpenPOWER on IntegriCloud