1238104Sdes/* From openssh 4.3p2 filename openbsd-compat/fake-rfc2553.h */ 2238104Sdes/* 3238104Sdes * Copyright (C) 2000-2003 Damien Miller. All rights reserved. 4238104Sdes * Copyright (C) 1999 WIDE Project. All rights reserved. 5238104Sdes * 6238104Sdes * Redistribution and use in source and binary forms, with or without 7238104Sdes * modification, are permitted provided that the following conditions 8238104Sdes * are met: 9238104Sdes * 1. Redistributions of source code must retain the above copyright 10238104Sdes * notice, this list of conditions and the following disclaimer. 11238104Sdes * 2. Redistributions in binary form must reproduce the above copyright 12238104Sdes * notice, this list of conditions and the following disclaimer in the 13238104Sdes * documentation and/or other materials provided with the distribution. 14238104Sdes * 3. Neither the name of the project nor the names of its contributors 15238104Sdes * may be used to endorse or promote products derived from this software 16238104Sdes * without specific prior written permission. 17238104Sdes * 18238104Sdes * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 19238104Sdes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20238104Sdes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21238104Sdes * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 22238104Sdes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23238104Sdes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24238104Sdes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25238104Sdes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26238104Sdes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27238104Sdes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28238104Sdes * SUCH DAMAGE. 29238104Sdes */ 30238104Sdes 31238104Sdes/* 32238104Sdes * Pseudo-implementation of RFC2553 name / address resolution functions 33238104Sdes * 34238104Sdes * But these functions are not implemented correctly. The minimum subset 35238104Sdes * is implemented for ssh use only. For example, this routine assumes 36238104Sdes * that ai_family is AF_INET. Don't use it for another purpose. 37238104Sdes */ 38238104Sdes 39238104Sdes#ifndef _FAKE_RFC2553_H 40238104Sdes#define _FAKE_RFC2553_H 41238104Sdes 42238104Sdes#include <sys/types.h> 43238104Sdes#include <sys/socket.h> 44238104Sdes#include <netdb.h> 45238104Sdes#include <limits.h> 46238104Sdes 47238104Sdes#ifdef __cplusplus 48238104Sdesextern "C" { 49238104Sdes#endif 50238104Sdes 51238104Sdes/* 52238104Sdes * First, socket and INET6 related definitions 53238104Sdes */ 54238104Sdes#ifndef HAVE_STRUCT_SOCKADDR_STORAGE 55238104Sdes#ifndef _SS_MAXSIZE 56238104Sdes# define _SS_MAXSIZE 128 /* Implementation specific max size */ 57238104Sdes# define _SS_PADSIZE (_SS_MAXSIZE - sizeof (struct sockaddr)) 58238104Sdesstruct sockaddr_storage { 59238104Sdes struct sockaddr ss_sa; 60238104Sdes char __ss_pad2[_SS_PADSIZE]; 61238104Sdes}; 62238104Sdes# define ss_family ss_sa.sa_family 63238104Sdes#endif /* _SS_MAXSIZE */ 64238104Sdes#endif /* !HAVE_STRUCT_SOCKADDR_STORAGE */ 65238104Sdes 66238104Sdes#ifndef IN6_IS_ADDR_LOOPBACK 67238104Sdes# define IN6_IS_ADDR_LOOPBACK(a) \ 68238104Sdes (((uint32_t *)(a))[0] == 0 && ((uint32_t *)(a))[1] == 0 && \ 69238104Sdes ((uint32_t *)(a))[2] == 0 && ((uint32_t *)(a))[3] == htonl(1)) 70238104Sdes#endif /* !IN6_IS_ADDR_LOOPBACK */ 71238104Sdes 72238104Sdes#ifndef HAVE_STRUCT_IN6_ADDR 73238104Sdesstruct in6_addr { 74238104Sdes uint8_t s6_addr[16]; 75238104Sdes}; 76238104Sdes#endif /* !HAVE_STRUCT_IN6_ADDR */ 77238104Sdes 78238104Sdes#ifndef HAVE_STRUCT_SOCKADDR_IN6 79238104Sdesstruct sockaddr_in6 { 80238104Sdes unsigned short sin6_family; 81238104Sdes uint16_t sin6_port; 82238104Sdes uint32_t sin6_flowinfo; 83238104Sdes struct in6_addr sin6_addr; 84238104Sdes}; 85238104Sdes#endif /* !HAVE_STRUCT_SOCKADDR_IN6 */ 86238104Sdes 87238104Sdes#ifndef AF_INET6 88238104Sdes/* Define it to something that should never appear */ 89238104Sdes#define AF_INET6 AF_MAX 90238104Sdes#endif 91238104Sdes 92238104Sdes/* 93238104Sdes * Next, RFC2553 name / address resolution API 94238104Sdes */ 95238104Sdes 96238104Sdes#ifndef NI_NUMERICHOST 97238104Sdes# define NI_NUMERICHOST (1) 98238104Sdes#endif 99238104Sdes#ifndef NI_NAMEREQD 100238104Sdes# define NI_NAMEREQD (1<<1) 101238104Sdes#endif 102238104Sdes#ifndef NI_NUMERICSERV 103238104Sdes# define NI_NUMERICSERV (1<<2) 104238104Sdes#endif 105238104Sdes 106238104Sdes#ifndef AI_PASSIVE 107238104Sdes# define AI_PASSIVE (1) 108238104Sdes#endif 109238104Sdes#ifndef AI_CANONNAME 110238104Sdes# define AI_CANONNAME (1<<1) 111238104Sdes#endif 112238104Sdes#ifndef AI_NUMERICHOST 113238104Sdes# define AI_NUMERICHOST (1<<2) 114238104Sdes#endif 115238104Sdes 116238104Sdes#ifndef NI_MAXSERV 117238104Sdes# define NI_MAXSERV 32 118238104Sdes#endif /* !NI_MAXSERV */ 119238104Sdes#ifndef NI_MAXHOST 120238104Sdes# define NI_MAXHOST 1025 121238104Sdes#endif /* !NI_MAXHOST */ 122238104Sdes 123238104Sdes#ifndef INT_MAX 124238104Sdes#define INT_MAX 0xffffffff 125238104Sdes#endif 126238104Sdes 127238104Sdes#ifndef EAI_NODATA 128238104Sdes# define EAI_NODATA (INT_MAX - 1) 129238104Sdes#endif 130238104Sdes#ifndef EAI_MEMORY 131238104Sdes# define EAI_MEMORY (INT_MAX - 2) 132238104Sdes#endif 133238104Sdes#ifndef EAI_NONAME 134238104Sdes# define EAI_NONAME (INT_MAX - 3) 135238104Sdes#endif 136238104Sdes#ifndef EAI_SYSTEM 137238104Sdes# define EAI_SYSTEM (INT_MAX - 4) 138238104Sdes#endif 139238104Sdes 140238104Sdes#ifndef HAVE_STRUCT_ADDRINFO 141238104Sdesstruct addrinfo { 142238104Sdes int ai_flags; /* AI_PASSIVE, AI_CANONNAME */ 143238104Sdes int ai_family; /* PF_xxx */ 144238104Sdes int ai_socktype; /* SOCK_xxx */ 145238104Sdes int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */ 146238104Sdes size_t ai_addrlen; /* length of ai_addr */ 147238104Sdes char *ai_canonname; /* canonical name for hostname */ 148238104Sdes struct sockaddr *ai_addr; /* binary address */ 149238104Sdes struct addrinfo *ai_next; /* next structure in linked list */ 150238104Sdes}; 151238104Sdes#endif /* !HAVE_STRUCT_ADDRINFO */ 152238104Sdes 153238104Sdes#ifndef HAVE_GETADDRINFO 154238104Sdes#ifdef getaddrinfo 155238104Sdes# undef getaddrinfo 156238104Sdes#endif 157238104Sdes#define getaddrinfo(a,b,c,d) (ssh_getaddrinfo(a,b,c,d)) 158238104Sdesint getaddrinfo(const char *, const char *, 159238104Sdes const struct addrinfo *, struct addrinfo **); 160238104Sdes#endif /* !HAVE_GETADDRINFO */ 161238104Sdes 162238104Sdes#if !defined(HAVE_GAI_STRERROR) && !defined(HAVE_CONST_GAI_STRERROR_PROTO) 163238104Sdes#define gai_strerror(a) (ssh_gai_strerror(a)) 164238104Sdeschar *gai_strerror(int); 165238104Sdes#endif /* !HAVE_GAI_STRERROR */ 166238104Sdes 167238104Sdes#ifndef HAVE_FREEADDRINFO 168238104Sdes#define freeaddrinfo(a) (ssh_freeaddrinfo(a)) 169238104Sdesvoid freeaddrinfo(struct addrinfo *); 170238104Sdes#endif /* !HAVE_FREEADDRINFO */ 171238104Sdes 172238104Sdes#ifndef HAVE_GETNAMEINFO 173238104Sdes#define getnameinfo(a,b,c,d,e,f,g) (ssh_getnameinfo(a,b,c,d,e,f,g)) 174238104Sdesint getnameinfo(const struct sockaddr *, size_t, char *, size_t, 175238104Sdes char *, size_t, int); 176238104Sdes#endif /* !HAVE_GETNAMEINFO */ 177238104Sdes 178238104Sdes#ifdef __cplusplus 179238104Sdes} 180238104Sdes#endif 181238104Sdes 182238104Sdes#endif /* !_FAKE_RFC2553_H */ 183238104Sdes 184