]>
Commit | Line | Data |
---|---|---|
52d58495 | 1 | /* |
2 | * Pseudo-implementation of RFC2553 name / address resolution functions | |
3 | * | |
4 | * But these functions are not implemented correctly. The minimum subset | |
5e24e4a5 | 5 | * is implemented for ssh use only. For example, this routine assumes |
52d58495 | 6 | * that ai_family is AF_INET. Don't use it for another purpose. |
7 | */ | |
8 | ||
9 | /* $Id$ */ | |
10 | ||
11 | #ifndef _FAKE_RFC2553_H | |
12 | #define _FAKE_RFC2553_H | |
13 | ||
14 | #include "includes.h" | |
15 | #include "sys/types.h" | |
16 | ||
17 | /* | |
18 | * First, socket and INET6 related definitions | |
19 | */ | |
20 | #ifndef HAVE_STRUCT_SOCKADDR_STORAGE | |
21 | # define _SS_MAXSIZE 128 /* Implementation specific max size */ | |
22 | # define _SS_PADSIZE (_SS_MAXSIZE - sizeof (struct sockaddr)) | |
23 | struct sockaddr_storage { | |
24 | struct sockaddr ss_sa; | |
25 | char __ss_pad2[_SS_PADSIZE]; | |
26 | }; | |
27 | # define ss_family ss_sa.sa_family | |
28 | #endif /* !HAVE_STRUCT_SOCKADDR_STORAGE */ | |
29 | ||
30 | #ifndef IN6_IS_ADDR_LOOPBACK | |
31 | # define IN6_IS_ADDR_LOOPBACK(a) \ | |
32 | (((u_int32_t *)(a))[0] == 0 && ((u_int32_t *)(a))[1] == 0 && \ | |
33 | ((u_int32_t *)(a))[2] == 0 && ((u_int32_t *)(a))[3] == htonl(1)) | |
34 | #endif /* !IN6_IS_ADDR_LOOPBACK */ | |
35 | ||
36 | #ifndef HAVE_STRUCT_IN6_ADDR | |
37 | struct in6_addr { | |
38 | u_int8_t s6_addr[16]; | |
39 | }; | |
40 | #endif /* !HAVE_STRUCT_IN6_ADDR */ | |
41 | ||
42 | #ifndef HAVE_STRUCT_SOCKADDR_IN6 | |
43 | struct sockaddr_in6 { | |
44 | unsigned short sin6_family; | |
45 | u_int16_t sin6_port; | |
46 | u_int32_t sin6_flowinfo; | |
47 | struct in6_addr sin6_addr; | |
48 | }; | |
49 | #endif /* !HAVE_STRUCT_SOCKADDR_IN6 */ | |
50 | ||
51 | #ifndef AF_INET6 | |
52 | /* Define it to something that should never appear */ | |
53 | #define AF_INET6 AF_MAX | |
54 | #endif | |
55 | ||
56 | /* | |
57 | * Next, RFC2553 name / address resolution API | |
58 | */ | |
59 | ||
60 | #ifndef NI_NUMERICHOST | |
61 | # define NI_NUMERICHOST (1) | |
62 | # define NI_NAMEREQD (1<<1) | |
63 | # define NI_NUMERICSERV (1<<2) | |
64 | #endif | |
65 | #ifndef AI_PASSIVE | |
66 | # define AI_PASSIVE (1) | |
67 | # define AI_CANONNAME (1<<1) | |
68 | # define AI_NUMERICHOST (1<<2) | |
69 | #endif | |
70 | ||
71 | #ifndef NI_MAXSERV | |
72 | # define NI_MAXSERV 32 | |
73 | #endif /* !NI_MAXSERV */ | |
74 | #ifndef NI_MAXHOST | |
75 | # define NI_MAXHOST 1025 | |
76 | #endif /* !NI_MAXHOST */ | |
77 | ||
78 | #ifndef EAI_NODATA | |
79 | # define EAI_NODATA 1 | |
80 | # define EAI_MEMORY 2 | |
e932f447 | 81 | # define EAI_NONAME 3 |
52d58495 | 82 | #endif |
83 | ||
84 | #ifndef HAVE_STRUCT_ADDRINFO | |
85 | struct addrinfo { | |
86 | int ai_flags; /* AI_PASSIVE, AI_CANONNAME */ | |
87 | int ai_family; /* PF_xxx */ | |
88 | int ai_socktype; /* SOCK_xxx */ | |
89 | int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */ | |
90 | size_t ai_addrlen; /* length of ai_addr */ | |
91 | char *ai_canonname; /* canonical name for hostname */ | |
92 | struct sockaddr *ai_addr; /* binary address */ | |
93 | struct addrinfo *ai_next; /* next structure in linked list */ | |
94 | }; | |
95 | #endif /* !HAVE_STRUCT_ADDRINFO */ | |
96 | ||
97 | #ifndef HAVE_GETADDRINFO | |
98 | int getaddrinfo(const char *, const char *, | |
99 | const struct addrinfo *, struct addrinfo **); | |
100 | #endif /* !HAVE_GETADDRINFO */ | |
101 | ||
102 | #ifndef HAVE_GAI_STRERROR | |
103 | char *gai_strerror(int); | |
104 | #endif /* !HAVE_GAI_STRERROR */ | |
105 | ||
106 | #ifndef HAVE_FREEADDRINFO | |
107 | void freeaddrinfo(struct addrinfo *); | |
108 | #endif /* !HAVE_FREEADDRINFO */ | |
109 | ||
110 | #ifndef HAVE_GETNAMEINFO | |
111 | int getnameinfo(const struct sockaddr *, size_t, char *, size_t, | |
112 | char *, size_t, int); | |
113 | #endif /* !HAVE_GETNAMEINFO */ | |
114 | ||
115 | #endif /* !_FAKE_RFC2553_H */ | |
116 |