1 /* $Id: fake-rfc2553.h,v 1.13 2006/07/24 03:51:52 djm Exp $ */ 2 /* $FreeBSD: /tmp/pcvs/ports/japanese/FreeWnn-server/files/patch-Wnn-include-fake-rfc2553.h,v 1.2 2010-01-02 14:47:19 hrs Exp $ */ 3 4 /* 5 * Copyright (C) 2000-2003 Damien Miller. All rights reserved. 6 * Copyright (C) 1999 WIDE Project. All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 3. Neither the name of the project nor the names of its contributors 17 * may be used to endorse or promote products derived from this software 18 * without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 */ 32 33 /* 34 * Pseudo-implementation of RFC2553 name / address resolution functions 35 * 36 * But these functions are not implemented correctly. The minimum subset 37 * is implemented for ssh use only. For example, this routine assumes 38 * that ai_family is AF_INET. Don't use it for another purpose. 39 */ 40 41 #ifndef _FAKE_RFC2553_H 42 #define _FAKE_RFC2553_H 43 44 #include "config.h" 45 46 #include <sys/types.h> 47 #if defined(HAVE_NETDB_H) 48 # include <netdb.h> 49 #endif 50 51 /* 52 * First, socket and INET6 related definitions 53 */ 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]; 60 }; 61 # define ss_family ss_sa.sa_family 62 #endif /* !HAVE_STRUCT_SOCKADDR_STORAGE */ 63 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 */ 69 70 #ifndef HAVE_STRUCT_IN6_ADDR 71 struct in6_addr { 72 u_int8_t s6_addr[16]; 73 }; 74 #endif /* !HAVE_STRUCT_IN6_ADDR */ 75 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 }; 83 #endif /* !HAVE_STRUCT_SOCKADDR_IN6 */ 84 85 #ifndef AF_INET6 86 /* Define it to something that should never appear */ 87 #define AF_INET6 AF_MAX 88 #endif 89 90 /* 91 * Next, RFC2553 name / address resolution API 92 */ 93 94 #ifndef NI_NUMERICHOST 95 # define NI_NUMERICHOST (1) 96 #endif 97 #ifndef NI_NAMEREQD 98 # define NI_NAMEREQD (1<<1) 99 #endif 100 #ifndef NI_NUMERICSERV 101 # define NI_NUMERICSERV (1<<2) 102 #endif 103 104 #ifndef AI_PASSIVE 105 # define AI_PASSIVE (1) 106 #endif 107 #ifndef AI_CANONNAME 108 # define AI_CANONNAME (1<<1) 109 #endif 110 #ifndef AI_NUMERICHOST 111 # define AI_NUMERICHOST (1<<2) 112 #endif 113 114 #ifndef NI_MAXSERV 115 # define NI_MAXSERV 32 116 #endif /* !NI_MAXSERV */ 117 #ifndef NI_MAXHOST 118 # define NI_MAXHOST 1025 119 #endif /* !NI_MAXHOST */ 120 121 #ifndef EAI_NODATA 122 # define EAI_NODATA (INT_MAX - 1) 123 #endif 124 #ifndef EAI_MEMORY 125 # define EAI_MEMORY (INT_MAX - 2) 126 #endif 127 #ifndef EAI_NONAME 128 # define EAI_NONAME (INT_MAX - 3) 129 #endif 130 #ifndef EAI_SYSTEM 131 # define EAI_SYSTEM (INT_MAX - 4) 132 #endif 133 134 #ifndef HAVE_STRUCT_ADDRINFO 135 struct addrinfo { 136 int ai_flags; /* AI_PASSIVE, AI_CANONNAME */ 137 int ai_family; /* PF_xxx */ 138 int ai_socktype; /* SOCK_xxx */ 139 int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */ 140 size_t ai_addrlen; /* length of ai_addr */ 141 char *ai_canonname; /* canonical name for hostname */ 142 struct sockaddr *ai_addr; /* binary address */ 143 struct addrinfo *ai_next; /* next structure in linked list */ 144 }; 145 #endif /* !HAVE_STRUCT_ADDRINFO */ 146 147 #ifndef HAVE_GETADDRINFO 148 #ifdef getaddrinfo 149 # undef getaddrinfo 150 #endif 151 #define getaddrinfo(a,b,c,d) (ssh_getaddrinfo(a,b,c,d)) 152 int getaddrinfo(const char *, const char *, 153 const struct addrinfo *, struct addrinfo **); 154 #endif /* !HAVE_GETADDRINFO */ 155 156 #if !defined(HAVE_GAI_STRERROR) && !defined(HAVE_CONST_GAI_STRERROR_PROTO) 157 #define gai_strerror(a) (ssh_gai_strerror(a)) 158 char *gai_strerror(int); 159 #endif /* !HAVE_GAI_STRERROR */ 160 161 #ifndef HAVE_FREEADDRINFO 162 #define freeaddrinfo(a) (ssh_freeaddrinfo(a)) 163 void freeaddrinfo(struct addrinfo *); 164 #endif /* !HAVE_FREEADDRINFO */ 165 166 #ifndef HAVE_GETNAMEINFO 167 #define getnameinfo(a,b,c,d,e,f,g) (ssh_getnameinfo(a,b,c,d,e,f,g)) 168 int getnameinfo(const struct sockaddr *, size_t, char *, size_t, 169 char *, size_t, int); 170 #endif /* !HAVE_GETNAMEINFO */ 171 172 #endif /* !_FAKE_RFC2553_H */ 173 174