Obfuscate RCS ID matching so that CVS doesn't expand it.
[netbsd-mini2440.git] / dist / ntp / libntp / socktoa.c
blobfb9948f8197d5130a008237d4e7083ab8f99ccfd
1 /* $NetBSD: socktoa.c,v 1.3 2006/03/18 12:40:48 kardel Exp $ */
3 /*
4 * socktoa - return a numeric host name from a sockaddr_storage structure
5 */
7 #include <config.h>
9 #include <sys/types.h>
10 #include <sys/socket.h>
11 #include <netinet/in.h>
13 #include <arpa/inet.h>
15 #ifdef ISC_PLATFORM_NEEDNTOP
16 #include <isc/net.h>
17 #endif
19 #include <stdio.h>
21 #include "ntp_fp.h"
22 #include "lib_strbuf.h"
23 #include "ntp_stdlib.h"
24 #include "ntp.h"
26 char *
27 socktoa(
28 struct sockaddr_storage* sock
31 register char *buffer;
33 LIB_GETBUF(buffer);
35 if (sock == NULL)
36 strcpy(buffer, "null");
37 else
40 switch(sock->ss_family) {
42 default:
43 case AF_INET :
44 inet_ntop(AF_INET, &GET_INADDR(*sock), buffer,
45 LIB_BUFLENGTH);
46 break;
48 case AF_INET6 :
49 inet_ntop(AF_INET6, &GET_INADDR6(*sock), buffer,
50 LIB_BUFLENGTH);
51 #if 0
52 default:
53 strcpy(buffer, "unknown");
54 #endif
57 return buffer;