Debian Codegraph @

compat/fake-rfc2553.h

raw
1 /*
2 * Copyright (C) 2000-2003 Damien Miller. All rights reserved.
3 * Copyright (C) 1999 WIDE Project. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the project nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30 /*
31 * Pseudo-implementation of RFC2553 name / address resolution functions
32 *
33 * But these functions are not implemented correctly. The minimum subset
34 * is implemented for ssh use only. For example, this routine assumes
35 * that ai_family is AF_INET. Don't use it for another purpose.
36 */
37
38 #ifndef _FAKE_RFC2553_H
39 #define _FAKE_RFC2553_H
40
41 /*
42 * First, socket and INET6 related definitions
43 */
44 #ifndef HAVE_STRUCT_SOCKADDR_STORAGE
45 # define _SS_MAXSIZE 128 /* Implementation specific max size */
46 # define _SS_PADSIZE (_SS_MAXSIZE - sizeof (struct sockaddr))
47 struct sockaddr_storage {
48 struct sockaddr ss_sa;
49 char __ss_pad2[_SS_PADSIZE];
50 };
51 # define ss_family ss_sa.sa_family
52 #endif /* !HAVE_STRUCT_SOCKADDR_STORAGE */
53
54 #ifndef IN6_IS_ADDR_LOOPBACK
55 # define IN6_IS_ADDR_LOOPBACK(a) \
56 (((uint32_t *)(a))[0] == 0 && ((uint32_t *)(a))[1] == 0 && \
57 ((uint32_t *)(a))[2] == 0 && ((uint32_t *)(a))[3] == htonl(1))
58 #endif /* !IN6_IS_ADDR_LOOPBACK */
59
60 #ifndef HAVE_STRUCT_IN6_ADDR
61 struct in6_addr {
62 uint8_t s6_addr[16];
63 };
64 #endif /* !HAVE_STRUCT_IN6_ADDR */
65
66 #ifndef HAVE_STRUCT_SOCKADDR_IN6
67 struct sockaddr_in6 {
68 unsigned short sin6_family;
69 uint16_t sin6_port;
70 uint32_t sin6_flowinfo;
71 struct in6_addr sin6_addr;
72 uint32_t sin6_scope_id;
73 };
74 #endif /* !HAVE_STRUCT_SOCKADDR_IN6 */
75
76 #ifndef AF_INET6
77 /* Define it to something that should never appear */
78 #define AF_INET6 AF_MAX
79 #endif
80
81 /*
82 * Next, RFC2553 name / address resolution API
83 */
84
85 #ifndef NI_NUMERICHOST
86 # define NI_NUMERICHOST (1)
87 #endif
88 #ifndef NI_NAMEREQD
89 # define NI_NAMEREQD (1<<1)
90 #endif
91 #ifndef NI_NUMERICSERV
92 # define NI_NUMERICSERV (1<<2)
93 #endif
94
95 #ifndef AI_PASSIVE
96 # define AI_PASSIVE (1)
97 #endif
98 #ifndef AI_CANONNAME
99 # define AI_CANONNAME (1<<1)
100 #endif
101 #ifndef AI_NUMERICHOST
102 # define AI_NUMERICHOST (1<<2)
103 #endif
104
105 #ifndef NI_MAXSERV
106 # define NI_MAXSERV 32
107 #endif /* !NI_MAXSERV */
108 #ifndef NI_MAXHOST
109 # define NI_MAXHOST 1025
110 #endif /* !NI_MAXHOST */
111
112 #ifndef EAI_NODATA
113 # define EAI_NODATA (INT_MAX - 1)
114 #endif
115 #ifndef EAI_MEMORY
116 # define EAI_MEMORY (INT_MAX - 2)
117 #endif
118 #ifndef EAI_NONAME
119 # define EAI_NONAME (INT_MAX - 3)
120 #endif
121 #ifndef EAI_SYSTEM
122 # define EAI_SYSTEM (INT_MAX - 4)
123 #endif
124 #ifndef EAI_FAMILY
125 # define EAI_FAMILY (INT_MAX - 5)
126 #endif
127 #ifndef EAI_SERVICE
128 # define EAI_SERVICE -8 /* SERVICE not supported for `ai_socktype'. */
129 #endif
130
131 #ifndef HAVE_STRUCT_ADDRINFO
132 struct addrinfo {
133 int ai_flags; /* AI_PASSIVE, AI_CANONNAME */
134 int ai_family; /* PF_xxx */
135 int ai_socktype; /* SOCK_xxx */
136 int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
137 size_t ai_addrlen; /* length of ai_addr */
138 char *ai_canonname; /* canonical name for hostname */
139 struct sockaddr *ai_addr; /* binary address */
140 struct addrinfo *ai_next; /* next structure in linked list */
141 };
142 #endif /* !HAVE_STRUCT_ADDRINFO */
143
144 #ifndef HAVE_GETADDRINFO
145 #ifdef getaddrinfo
146 # undef getaddrinfo
147 #endif
148 #define getaddrinfo(a,b,c,d) (fake_getaddrinfo(a,b,c,d))
149 int getaddrinfo(const char *, const char *,
150 const struct addrinfo *, struct addrinfo **);
151 #endif /* !HAVE_GETADDRINFO */
152
153 #ifndef HAVE_GAI_STRERROR
154 #define gai_strerror(a) (fake_gai_strerror(a))
155 const char *gai_strerror(int);
156 #endif /* !HAVE_GAI_STRERROR */
157
158 #ifndef HAVE_FREEADDRINFO
159 #define freeaddrinfo(a) (fake_freeaddrinfo(a))
160 void freeaddrinfo(struct addrinfo *);
161 #endif /* !HAVE_FREEADDRINFO */
162
163 #ifndef HAVE_GETNAMEINFO
164 #define getnameinfo(a,b,c,d,e,f,g) (fake_getnameinfo(a,b,c,d,e,f,g))
165 int getnameinfo(const struct sockaddr *, size_t, char *, size_t,
166 char *, size_t, int);
167 #endif /* !HAVE_GETNAMEINFO */
168
169
170 #endif /* !_FAKE_RFC2553_H */