1 | /* |
---|
2 | * Replacement implementation of getnameinfo. |
---|
3 | * |
---|
4 | * This is an implementation of the getnameinfo function for systems that lack |
---|
5 | * it, so that code can use getnameinfo always. It provides IPv4 support |
---|
6 | * only; for IPv6 support, a native getnameinfo implemenation is required. |
---|
7 | * |
---|
8 | * This file should generally be included by way of portable/socket.h rather |
---|
9 | * than directly. |
---|
10 | * |
---|
11 | * Written by Russ Allbery <rra@stanford.edu> |
---|
12 | * This work is hereby placed in the public domain by its author. |
---|
13 | */ |
---|
14 | |
---|
15 | #ifndef PORTABLE_GETNAMEINFO_H |
---|
16 | #define PORTABLE_GETNAMEINFO_H 1 |
---|
17 | |
---|
18 | #include <config.h> |
---|
19 | #include <portable/macros.h> |
---|
20 | |
---|
21 | /* Skip this entire file if a system getaddrinfo was detected. */ |
---|
22 | #if !HAVE_GETNAMEINFO |
---|
23 | |
---|
24 | #include <sys/socket.h> |
---|
25 | |
---|
26 | /* Constants for flags from RFC 3493, combined with binary or. */ |
---|
27 | #define NI_NOFQDN 0x0001 |
---|
28 | #define NI_NUMERICHOST 0x0002 |
---|
29 | #define NI_NAMEREQD 0x0004 |
---|
30 | #define NI_NUMERICSERV 0x0008 |
---|
31 | #define NI_DGRAM 0x0010 |
---|
32 | |
---|
33 | /* |
---|
34 | * Maximum length of hostnames and service names. Our implementation doesn't |
---|
35 | * use these values, so they're taken from Linux. They're provided just for |
---|
36 | * code that uses them to size buffers. |
---|
37 | */ |
---|
38 | #ifndef NI_MAXHOST |
---|
39 | # define NI_MAXHOST 1025 |
---|
40 | #endif |
---|
41 | #ifndef NI_MAXSERV |
---|
42 | # define NI_MAXSERV 32 |
---|
43 | #endif |
---|
44 | |
---|
45 | BEGIN_DECLS |
---|
46 | |
---|
47 | /* Function prototypes. */ |
---|
48 | int getnameinfo(const struct sockaddr *sa, socklen_t salen, |
---|
49 | char *node, socklen_t nodelen, |
---|
50 | char *service, socklen_t servicelen, int flags) |
---|
51 | __attribute__((__visibility__("hidden"))); |
---|
52 | |
---|
53 | END_DECLS |
---|
54 | |
---|
55 | #endif /* !HAVE_GETNAMEINFO */ |
---|
56 | #endif /* !PORTABLE_GETNAMEINFO_H */ |
---|