1238106Sdes/* From openssh 4.3p2 filename openbsd-compat/fake-rfc2553.h */ 2238106Sdes/* 3238106Sdes * Copyright (C) 2000-2003 Damien Miller. All rights reserved. 4238106Sdes * Copyright (C) 1999 WIDE Project. All rights reserved. 5238106Sdes * 6238106Sdes * Redistribution and use in source and binary forms, with or without 7238106Sdes * modification, are permitted provided that the following conditions 8238106Sdes * are met: 9238106Sdes * 1. Redistributions of source code must retain the above copyright 10238106Sdes * notice, this list of conditions and the following disclaimer. 11238106Sdes * 2. Redistributions in binary form must reproduce the above copyright 12238106Sdes * notice, this list of conditions and the following disclaimer in the 13238106Sdes * documentation and/or other materials provided with the distribution. 14238106Sdes * 3. Neither the name of the project nor the names of its contributors 15238106Sdes * may be used to endorse or promote products derived from this software 16238106Sdes * without specific prior written permission. 17238106Sdes * 18238106Sdes * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 19238106Sdes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20238106Sdes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21238106Sdes * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 22238106Sdes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23238106Sdes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24238106Sdes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25238106Sdes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26238106Sdes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27238106Sdes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28238106Sdes * SUCH DAMAGE. 29238106Sdes */ 30238106Sdes 31238106Sdes/* 32238106Sdes * Pseudo-implementation of RFC2553 name / address resolution functions 33238106Sdes * 34238106Sdes * But these functions are not implemented correctly. The minimum subset 35238106Sdes * is implemented for ssh use only. For example, this routine assumes 36238106Sdes * that ai_family is AF_INET. Don't use it for another purpose. 37238106Sdes */ 38238106Sdes 39238106Sdes#ifndef _FAKE_RFC2553_H 40238106Sdes#define _FAKE_RFC2553_H 41238106Sdes 42238106Sdes#include <config.h> 43238106Sdes#include <sys/types.h> 44238106Sdes#include <sys/socket.h> 45238106Sdes#include <netdb.h> 46238106Sdes#include <limits.h> 47238106Sdes 48238106Sdes/* 49238106Sdes * First, socket and INET6 related definitions 50238106Sdes */ 51238106Sdes#ifndef HAVE_STRUCT_SOCKADDR_STORAGE 52238106Sdes# define _SS_MAXSIZE 128 /* Implementation specific max size */ 53238106Sdes# define _SS_PADSIZE (_SS_MAXSIZE - sizeof (struct sockaddr)) 54238106Sdesstruct sockaddr_storage { 55238106Sdes struct sockaddr ss_sa; 56238106Sdes char __ss_pad2[_SS_PADSIZE]; 57238106Sdes}; 58238106Sdes# define ss_family ss_sa.sa_family 59238106Sdes#endif /* !HAVE_STRUCT_SOCKADDR_STORAGE */ 60238106Sdes 61238106Sdes#ifndef IN6_IS_ADDR_LOOPBACK 62238106Sdes# define IN6_IS_ADDR_LOOPBACK(a) \ 63238106Sdes (((uint32_t *)(a))[0] == 0 && ((uint32_t *)(a))[1] == 0 && \ 64238106Sdes ((uint32_t *)(a))[2] == 0 && ((uint32_t *)(a))[3] == htonl(1)) 65238106Sdes#endif /* !IN6_IS_ADDR_LOOPBACK */ 66238106Sdes 67238106Sdes#ifndef HAVE_STRUCT_IN6_ADDR 68238106Sdesstruct in6_addr { 69238106Sdes uint8_t s6_addr[16]; 70238106Sdes}; 71238106Sdes#endif /* !HAVE_STRUCT_IN6_ADDR */ 72238106Sdes 73238106Sdes#ifndef HAVE_STRUCT_SOCKADDR_IN6 74238106Sdesstruct sockaddr_in6 { 75238106Sdes unsigned short sin6_family; 76238106Sdes uint16_t sin6_port; 77238106Sdes uint32_t sin6_flowinfo; 78238106Sdes struct in6_addr sin6_addr; 79238106Sdes}; 80238106Sdes#endif /* !HAVE_STRUCT_SOCKADDR_IN6 */ 81238106Sdes 82238106Sdes#ifndef AF_INET6 83238106Sdes/* Define it to something that should never appear */ 84238106Sdes#define AF_INET6 AF_MAX 85238106Sdes#endif 86238106Sdes 87238106Sdes/* 88238106Sdes * Next, RFC2553 name / address resolution API 89238106Sdes */ 90238106Sdes 91238106Sdes#ifndef NI_NUMERICHOST 92238106Sdes# define NI_NUMERICHOST (1) 93238106Sdes#endif 94238106Sdes#ifndef NI_NAMEREQD 95238106Sdes# define NI_NAMEREQD (1<<1) 96238106Sdes#endif 97238106Sdes#ifndef NI_NUMERICSERV 98238106Sdes# define NI_NUMERICSERV (1<<2) 99238106Sdes#endif 100238106Sdes 101238106Sdes#ifndef AI_PASSIVE 102238106Sdes# define AI_PASSIVE (1) 103238106Sdes#endif 104238106Sdes#ifndef AI_CANONNAME 105238106Sdes# define AI_CANONNAME (1<<1) 106238106Sdes#endif 107238106Sdes#ifndef AI_NUMERICHOST 108238106Sdes# define AI_NUMERICHOST (1<<2) 109238106Sdes#endif 110238106Sdes 111238106Sdes#ifndef NI_MAXSERV 112238106Sdes# define NI_MAXSERV 32 113238106Sdes#endif /* !NI_MAXSERV */ 114238106Sdes#ifndef NI_MAXHOST 115238106Sdes# define NI_MAXHOST 1025 116238106Sdes#endif /* !NI_MAXHOST */ 117238106Sdes 118238106Sdes#ifndef INT_MAX 119238106Sdes#define INT_MAX 0xffffffff 120238106Sdes#endif 121238106Sdes 122238106Sdes#ifndef EAI_NODATA 123238106Sdes# define EAI_NODATA (INT_MAX - 1) 124238106Sdes#endif 125238106Sdes#ifndef EAI_MEMORY 126238106Sdes# define EAI_MEMORY (INT_MAX - 2) 127238106Sdes#endif 128238106Sdes#ifndef EAI_NONAME 129238106Sdes# define EAI_NONAME (INT_MAX - 3) 130238106Sdes#endif 131238106Sdes#ifndef EAI_SYSTEM 132238106Sdes# define EAI_SYSTEM (INT_MAX - 4) 133238106Sdes#endif 134238106Sdes 135238106Sdes#ifndef HAVE_STRUCT_ADDRINFO 136238106Sdesstruct addrinfo { 137238106Sdes int ai_flags; /* AI_PASSIVE, AI_CANONNAME */ 138238106Sdes int ai_family; /* PF_xxx */ 139238106Sdes int ai_socktype; /* SOCK_xxx */ 140238106Sdes int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */ 141238106Sdes size_t ai_addrlen; /* length of ai_addr */ 142238106Sdes char *ai_canonname; /* canonical name for hostname */ 143238106Sdes struct sockaddr *ai_addr; /* binary address */ 144238106Sdes struct addrinfo *ai_next; /* next structure in linked list */ 145238106Sdes}; 146238106Sdes#endif /* !HAVE_STRUCT_ADDRINFO */ 147238106Sdes 148238106Sdes#ifndef HAVE_GETADDRINFO 149238106Sdes#ifdef getaddrinfo 150238106Sdes# undef getaddrinfo 151238106Sdes#endif 152238106Sdes#define getaddrinfo(a,b,c,d) (getaddrinfo_unbound(a,b,c,d)) 153238106Sdesint getaddrinfo(const char *, const char *, 154238106Sdes const struct addrinfo *, struct addrinfo **); 155238106Sdes#endif /* !HAVE_GETADDRINFO */ 156238106Sdes 157238106Sdes#if !defined(HAVE_GAI_STRERROR) && !defined(HAVE_CONST_GAI_STRERROR_PROTO) 158238106Sdes#define gai_strerror(a) (gai_strerror_unbound(a)) 159238106Sdeschar *gai_strerror(int); 160238106Sdes#endif /* !HAVE_GAI_STRERROR */ 161238106Sdes 162238106Sdes#ifndef HAVE_FREEADDRINFO 163238106Sdes#define freeaddrinfo(a) (freeaddrinfo_unbound(a)) 164238106Sdesvoid freeaddrinfo(struct addrinfo *); 165238106Sdes#endif /* !HAVE_FREEADDRINFO */ 166238106Sdes 167238106Sdes#ifndef HAVE_GETNAMEINFO 168238106Sdes#define getnameinfo(a,b,c,d,e,f,g) (getnameinfo_unbound(a,b,c,d,e,f,g)) 169238106Sdesint getnameinfo(const struct sockaddr *, size_t, char *, size_t, 170238106Sdes char *, size_t, int); 171238106Sdes#endif /* !HAVE_GETNAMEINFO */ 172238106Sdes 173238106Sdes#endif /* !_FAKE_RFC2553_H */ 174238106Sdes 175