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