130c2432des/* From openssh 4.3p2 filename openbsd-compat/fake-rfc2553.h */
230c2432des/*
330c2432des * Copyright (C) 2000-2003 Damien Miller.  All rights reserved.
430c2432des * Copyright (C) 1999 WIDE Project.  All rights reserved.
530c2432des *
630c2432des * Redistribution and use in source and binary forms, with or without
730c2432des * modification, are permitted provided that the following conditions
830c2432des * are met:
930c2432des * 1. Redistributions of source code must retain the above copyright
1030c2432des *    notice, this list of conditions and the following disclaimer.
1130c2432des * 2. Redistributions in binary form must reproduce the above copyright
1230c2432des *    notice, this list of conditions and the following disclaimer in the
1330c2432des *    documentation and/or other materials provided with the distribution.
1430c2432des * 3. Neither the name of the project nor the names of its contributors
1530c2432des *    may be used to endorse or promote products derived from this software
1630c2432des *    without specific prior written permission.
1730c2432des *
1830c2432des * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
1930c2432des * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2030c2432des * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2130c2432des * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
2230c2432des * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2330c2432des * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2430c2432des * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2530c2432des * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2630c2432des * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2730c2432des * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2830c2432des * SUCH DAMAGE.
2930c2432des */
3030c2432des
3130c2432des/*
3230c2432des * Pseudo-implementation of RFC2553 name / address resolution functions
3330c2432des *
3430c2432des * But these functions are not implemented correctly. The minimum subset
3530c2432des * is implemented for ssh use only. For example, this routine assumes
3630c2432des * that ai_family is AF_INET. Don't use it for another purpose.
3730c2432des */
3830c2432des
3930c2432des#ifndef _FAKE_RFC2553_H
4030c2432des#define _FAKE_RFC2553_H
4130c2432des
4230c2432des#include <config.h>
4330c2432des#include <sys/types.h>
4430c2432des#include <sys/socket.h>
4530c2432des#include <netdb.h>
4630c2432des#include <limits.h>
4730c2432des
4830c2432des/*
4930c2432des * First, socket and INET6 related definitions
5030c2432des */
5130c2432des#ifndef HAVE_STRUCT_SOCKADDR_STORAGE
5230c2432des# define	_SS_MAXSIZE	128	/* Implementation specific max size */
5330c2432des# define       _SS_PADSIZE     (_SS_MAXSIZE - sizeof (struct sockaddr))
5430c2432desstruct sockaddr_storage {
5530c2432des	struct sockaddr	ss_sa;
5630c2432des	char		__ss_pad2[_SS_PADSIZE];
5730c2432des};
5830c2432des# define ss_family ss_sa.sa_family
5930c2432des#endif /* !HAVE_STRUCT_SOCKADDR_STORAGE */
6030c2432des
6130c2432des#ifndef IN6_IS_ADDR_LOOPBACK
6230c2432des# define IN6_IS_ADDR_LOOPBACK(a) \
6330c2432des	(((uint32_t *)(a))[0] == 0 && ((uint32_t *)(a))[1] == 0 && \
6430c2432des	 ((uint32_t *)(a))[2] == 0 && ((uint32_t *)(a))[3] == htonl(1))
6530c2432des#endif /* !IN6_IS_ADDR_LOOPBACK */
6630c2432des
6730c2432des#ifndef HAVE_STRUCT_IN6_ADDR
6830c2432desstruct in6_addr {
6930c2432des	uint8_t	s6_addr[16];
7030c2432des};
7130c2432des#endif /* !HAVE_STRUCT_IN6_ADDR */
7230c2432des
7330c2432des#ifndef HAVE_STRUCT_SOCKADDR_IN6
7430c2432desstruct sockaddr_in6 {
7530c2432des	unsigned short	sin6_family;
7630c2432des	uint16_t	sin6_port;
7730c2432des	uint32_t	sin6_flowinfo;
7830c2432des	struct in6_addr	sin6_addr;
7930c2432des};
8030c2432des#endif /* !HAVE_STRUCT_SOCKADDR_IN6 */
8130c2432des
8230c2432des#ifndef AF_INET6
8330c2432des/* Define it to something that should never appear */
8430c2432des#define AF_INET6 AF_MAX
8530c2432des#endif
8630c2432des
8730c2432des/*
8830c2432des * Next, RFC2553 name / address resolution API
8930c2432des */
9030c2432des
9130c2432des#ifndef NI_NUMERICHOST
9230c2432des# define NI_NUMERICHOST    (1)
9330c2432des#endif
9430c2432des#ifndef NI_NAMEREQD
9530c2432des# define NI_NAMEREQD       (1<<1)
9630c2432des#endif
9730c2432des#ifndef NI_NUMERICSERV
9830c2432des# define NI_NUMERICSERV    (1<<2)
9930c2432des#endif
10030c2432des
10130c2432des#ifndef AI_PASSIVE
10230c2432des# define AI_PASSIVE		(1)
10330c2432des#endif
10430c2432des#ifndef AI_CANONNAME
10530c2432des# define AI_CANONNAME		(1<<1)
10630c2432des#endif
10730c2432des#ifndef AI_NUMERICHOST
10830c2432des# define AI_NUMERICHOST		(1<<2)
10930c2432des#endif
11030c2432des
11130c2432des#ifndef NI_MAXSERV
11230c2432des# define NI_MAXSERV 32
11330c2432des#endif /* !NI_MAXSERV */
11430c2432des#ifndef NI_MAXHOST
11530c2432des# define NI_MAXHOST 1025
11630c2432des#endif /* !NI_MAXHOST */
11730c2432des
11830c2432des#ifndef INT_MAX
11930c2432des#define INT_MAX		0xffffffff
12030c2432des#endif
12130c2432des
12230c2432des#ifndef EAI_NODATA
12330c2432des# define EAI_NODATA	(INT_MAX - 1)
12430c2432des#endif
12530c2432des#ifndef EAI_MEMORY
12630c2432des# define EAI_MEMORY	(INT_MAX - 2)
12730c2432des#endif
12830c2432des#ifndef EAI_NONAME
12930c2432des# define EAI_NONAME	(INT_MAX - 3)
13030c2432des#endif
13130c2432des#ifndef EAI_SYSTEM
13230c2432des# define EAI_SYSTEM	(INT_MAX - 4)
13330c2432des#endif
13430c2432des
13530c2432des#ifndef HAVE_STRUCT_ADDRINFO
13630c2432desstruct addrinfo {
13730c2432des	int	ai_flags;	/* AI_PASSIVE, AI_CANONNAME */
13830c2432des	int	ai_family;	/* PF_xxx */
13930c2432des	int	ai_socktype;	/* SOCK_xxx */
14030c2432des	int	ai_protocol;	/* 0 or IPPROTO_xxx for IPv4 and IPv6 */
14130c2432des	size_t	ai_addrlen;	/* length of ai_addr */
14230c2432des	char	*ai_canonname;	/* canonical name for hostname */
14330c2432des	struct sockaddr *ai_addr;	/* binary address */
14430c2432des	struct addrinfo *ai_next;	/* next structure in linked list */
14530c2432des};
14630c2432des#endif /* !HAVE_STRUCT_ADDRINFO */
14730c2432des
14830c2432des#ifndef HAVE_GETADDRINFO
14930c2432des#ifdef getaddrinfo
15030c2432des# undef getaddrinfo
15130c2432des#endif
15230c2432des#define getaddrinfo(a,b,c,d)	(getaddrinfo_unbound(a,b,c,d))
15330c2432desint getaddrinfo(const char *, const char *,
15430c2432des    const struct addrinfo *, struct addrinfo **);
15530c2432des#endif /* !HAVE_GETADDRINFO */
15630c2432des
15730c2432des#if !defined(HAVE_GAI_STRERROR) && !defined(HAVE_CONST_GAI_STRERROR_PROTO)
15830c2432des#define gai_strerror(a)		(gai_strerror_unbound(a))
15930c2432deschar *gai_strerror(int);
16030c2432des#endif /* !HAVE_GAI_STRERROR */
16130c2432des
16230c2432des#ifndef HAVE_FREEADDRINFO
16330c2432des#define freeaddrinfo(a)		(freeaddrinfo_unbound(a))
16430c2432desvoid freeaddrinfo(struct addrinfo *);
16530c2432des#endif /* !HAVE_FREEADDRINFO */
16630c2432des
16730c2432des#ifndef HAVE_GETNAMEINFO
16830c2432des#define getnameinfo(a,b,c,d,e,f,g) (getnameinfo_unbound(a,b,c,d,e,f,g))
16930c2432desint getnameinfo(const struct sockaddr *, size_t, char *, size_t,
17030c2432des    char *, size_t, int);
17130c2432des#endif /* !HAVE_GETNAMEINFO */
17230c2432des
17330c2432des#endif /* !_FAKE_RFC2553_H */
17430c2432des
175