fake-rfc2553.h revision 124696
1124208Sdes/* $Id: fake-rfc2553.h,v 1.6.2.1 2003/09/22 02:09:18 dtucker Exp $ */ 2124696Sdes/* $FreeBSD: head/crypto/openssh/openbsd-compat/fake-rfc2553.h 124696 2004-01-18 22:31:30Z des $ */ 3124208Sdes 4124208Sdes/* 5124208Sdes * Copyright (C) 2000-2003 Damien Miller. All rights reserved. 6124208Sdes * Copyright (C) 1999 WIDE Project. All rights reserved. 7124208Sdes * 8124208Sdes * Redistribution and use in source and binary forms, with or without 9124208Sdes * modification, are permitted provided that the following conditions 10124208Sdes * are met: 11124208Sdes * 1. Redistributions of source code must retain the above copyright 12124208Sdes * notice, this list of conditions and the following disclaimer. 13124208Sdes * 2. Redistributions in binary form must reproduce the above copyright 14124208Sdes * notice, this list of conditions and the following disclaimer in the 15124208Sdes * documentation and/or other materials provided with the distribution. 16124208Sdes * 3. Neither the name of the project nor the names of its contributors 17124208Sdes * may be used to endorse or promote products derived from this software 18124208Sdes * without specific prior written permission. 19124208Sdes * 20124208Sdes * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 21124208Sdes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22124208Sdes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23124208Sdes * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 24124208Sdes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25124208Sdes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26124208Sdes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27124208Sdes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28124208Sdes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29124208Sdes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30124208Sdes * SUCH DAMAGE. 31124208Sdes */ 32124208Sdes 33124208Sdes/* 34124208Sdes * Pseudo-implementation of RFC2553 name / address resolution functions 35124208Sdes * 36124208Sdes * But these functions are not implemented correctly. The minimum subset 37124208Sdes * is implemented for ssh use only. For example, this routine assumes 38124208Sdes * that ai_family is AF_INET. Don't use it for another purpose. 39124208Sdes */ 40124208Sdes 41124208Sdes#ifndef _FAKE_RFC2553_H 42124208Sdes#define _FAKE_RFC2553_H 43124208Sdes 44124208Sdes#include "includes.h" 45124208Sdes#include "sys/types.h" 46124208Sdes 47124208Sdes/* 48124208Sdes * First, socket and INET6 related definitions 49124208Sdes */ 50124208Sdes#ifndef HAVE_STRUCT_SOCKADDR_STORAGE 51124208Sdes# define _SS_MAXSIZE 128 /* Implementation specific max size */ 52124208Sdes# define _SS_PADSIZE (_SS_MAXSIZE - sizeof (struct sockaddr)) 53124208Sdesstruct sockaddr_storage { 54124208Sdes struct sockaddr ss_sa; 55124208Sdes char __ss_pad2[_SS_PADSIZE]; 56124208Sdes}; 57124208Sdes# define ss_family ss_sa.sa_family 58124208Sdes#endif /* !HAVE_STRUCT_SOCKADDR_STORAGE */ 59124208Sdes 60124208Sdes#ifndef IN6_IS_ADDR_LOOPBACK 61124208Sdes# define IN6_IS_ADDR_LOOPBACK(a) \ 62124208Sdes (((u_int32_t *)(a))[0] == 0 && ((u_int32_t *)(a))[1] == 0 && \ 63124208Sdes ((u_int32_t *)(a))[2] == 0 && ((u_int32_t *)(a))[3] == htonl(1)) 64124208Sdes#endif /* !IN6_IS_ADDR_LOOPBACK */ 65124208Sdes 66124208Sdes#ifndef HAVE_STRUCT_IN6_ADDR 67124208Sdesstruct in6_addr { 68124208Sdes u_int8_t s6_addr[16]; 69124208Sdes}; 70124208Sdes#endif /* !HAVE_STRUCT_IN6_ADDR */ 71124208Sdes 72124208Sdes#ifndef HAVE_STRUCT_SOCKADDR_IN6 73124208Sdesstruct sockaddr_in6 { 74124208Sdes unsigned short sin6_family; 75124208Sdes u_int16_t sin6_port; 76124208Sdes u_int32_t sin6_flowinfo; 77124208Sdes struct in6_addr sin6_addr; 78124208Sdes}; 79124208Sdes#endif /* !HAVE_STRUCT_SOCKADDR_IN6 */ 80124208Sdes 81124208Sdes#ifndef AF_INET6 82124208Sdes/* Define it to something that should never appear */ 83124208Sdes#define AF_INET6 AF_MAX 84124208Sdes#endif 85124208Sdes 86124208Sdes/* 87124208Sdes * Next, RFC2553 name / address resolution API 88124208Sdes */ 89124208Sdes 90124208Sdes#ifndef NI_NUMERICHOST 91124208Sdes# define NI_NUMERICHOST (1) 92124208Sdes#endif 93124208Sdes#ifndef NI_NAMEREQD 94124208Sdes# define NI_NAMEREQD (1<<1) 95124208Sdes#endif 96124208Sdes#ifndef NI_NUMERICSERV 97124208Sdes# define NI_NUMERICSERV (1<<2) 98124208Sdes#endif 99124208Sdes 100124208Sdes#ifndef AI_PASSIVE 101124208Sdes# define AI_PASSIVE (1) 102124208Sdes#endif 103124208Sdes#ifndef AI_CANONNAME 104124208Sdes# define AI_CANONNAME (1<<1) 105124208Sdes#endif 106124208Sdes#ifndef AI_NUMERICHOST 107124208Sdes# define AI_NUMERICHOST (1<<2) 108124208Sdes#endif 109124208Sdes 110124208Sdes#ifndef NI_MAXSERV 111124208Sdes# define NI_MAXSERV 32 112124208Sdes#endif /* !NI_MAXSERV */ 113124208Sdes#ifndef NI_MAXHOST 114124208Sdes# define NI_MAXHOST 1025 115124208Sdes#endif /* !NI_MAXHOST */ 116124208Sdes 117124696Sdes#ifndef EAI_NONAME 118124208Sdes# define EAI_NODATA 1 119124208Sdes# define EAI_MEMORY 2 120124208Sdes# define EAI_NONAME 3 121124208Sdes#endif 122124208Sdes 123124208Sdes#ifndef HAVE_STRUCT_ADDRINFO 124124208Sdesstruct addrinfo { 125124208Sdes int ai_flags; /* AI_PASSIVE, AI_CANONNAME */ 126124208Sdes int ai_family; /* PF_xxx */ 127124208Sdes int ai_socktype; /* SOCK_xxx */ 128124208Sdes int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */ 129124208Sdes size_t ai_addrlen; /* length of ai_addr */ 130124208Sdes char *ai_canonname; /* canonical name for hostname */ 131124208Sdes struct sockaddr *ai_addr; /* binary address */ 132124208Sdes struct addrinfo *ai_next; /* next structure in linked list */ 133124208Sdes}; 134124208Sdes#endif /* !HAVE_STRUCT_ADDRINFO */ 135124208Sdes 136124208Sdes#ifndef HAVE_GETADDRINFO 137124208Sdesint getaddrinfo(const char *, const char *, 138124208Sdes const struct addrinfo *, struct addrinfo **); 139124208Sdes#endif /* !HAVE_GETADDRINFO */ 140124208Sdes 141124208Sdes#if !defined(HAVE_GAI_STRERROR) && !defined(HAVE_CONST_GAI_STRERROR_PROTO) 142124208Sdeschar *gai_strerror(int); 143124208Sdes#endif /* !HAVE_GAI_STRERROR */ 144124208Sdes 145124208Sdes#ifndef HAVE_FREEADDRINFO 146124208Sdesvoid freeaddrinfo(struct addrinfo *); 147124208Sdes#endif /* !HAVE_FREEADDRINFO */ 148124208Sdes 149124208Sdes#ifndef HAVE_GETNAMEINFO 150124208Sdesint getnameinfo(const struct sockaddr *, size_t, char *, size_t, 151124208Sdes char *, size_t, int); 152124208Sdes#endif /* !HAVE_GETNAMEINFO */ 153124208Sdes 154124208Sdes#endif /* !_FAKE_RFC2553_H */ 155124208Sdes 156