blob: fb41b22a0c3fa4d57d17367057e19a5629c6e9b4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
/*
* socktoa - return a numeric host name from a sockaddr_storage structure
*/
#include <config.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#ifdef ISC_PLATFORM_NEEDNTOP
#include <isc/net.h>
#endif
#include <stdio.h>
#include "ntp_fp.h"
#include "lib_strbuf.h"
#include "ntp_stdlib.h"
#include "ntp.h"
char *
socktoa(
struct sockaddr_storage* sock
)
{
register char *buffer;
LIB_GETBUF(buffer);
if (sock == NULL)
strcpy(buffer, "null");
else
{
switch(sock->ss_family) {
default:
case AF_INET :
inet_ntop(AF_INET, &GET_INADDR(*sock), buffer,
LIB_BUFLENGTH);
break;
case AF_INET6 :
inet_ntop(AF_INET6, &GET_INADDR6(*sock), buffer,
LIB_BUFLENGTH);
#if 0
default:
strcpy(buffer, "unknown");
#endif
}
}
return buffer;
}
|