| 1 |
adx |
30 |
/* inet_misc.h - Supplemental structs, functions, * |
| 2 |
|
|
* and definitions required to build ircd on some * |
| 3 |
|
|
* exotic platforms. * |
| 4 |
|
|
* * |
| 5 |
knight |
31 |
* $Id$ * |
| 6 |
adx |
30 |
* |
| 7 |
|
|
* Copyright (c) 1980, 1983, 1988, 1993 |
| 8 |
|
|
* The Regents of the University of California. All rights reserved. |
| 9 |
|
|
* |
| 10 |
|
|
* Redistribution and use in source and binary forms, with or without |
| 11 |
|
|
* modification, are permitted provided that the following conditions |
| 12 |
|
|
* are met: |
| 13 |
|
|
* 1. Redistributions of source code must retain the above copyright |
| 14 |
|
|
* notice, this list of conditions and the following disclaimer. |
| 15 |
|
|
* 2. Redistributions in binary form must reproduce the above copyright |
| 16 |
|
|
* notice, this list of conditions and the following disclaimer in the |
| 17 |
|
|
* documentation and/or other materials provided with the distribution. |
| 18 |
|
|
* 3. All advertising materials mentioning features or use of this software |
| 19 |
|
|
* must display the following acknowledgement: |
| 20 |
|
|
* This product includes software developed by the University of |
| 21 |
|
|
* California, Berkeley and its contributors. |
| 22 |
|
|
* 4. Neither the name of the University nor the names of its contributors |
| 23 |
|
|
* may be used to endorse or promote products derived from this software |
| 24 |
|
|
* without specific prior written permission. |
| 25 |
|
|
* |
| 26 |
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
| 27 |
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 28 |
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 29 |
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
| 30 |
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 31 |
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 32 |
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 33 |
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 34 |
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 35 |
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 36 |
|
|
* SUCH DAMAGE. |
| 37 |
|
|
* |
| 38 |
|
|
* - |
| 39 |
|
|
* Portions Copyright (c) 1993 by Digital Equipment Corporation. |
| 40 |
|
|
* |
| 41 |
|
|
* Permission to use, copy, modify, and distribute this software for any |
| 42 |
|
|
* purpose with or without fee is hereby granted, provided that the above |
| 43 |
|
|
* copyright notice and this permission notice appear in all copies, and that |
| 44 |
|
|
* the name of Digital Equipment Corporation not be used in advertising or |
| 45 |
|
|
* publicity pertaining to distribution of the document or software without |
| 46 |
|
|
* specific, written prior permission. |
| 47 |
|
|
* |
| 48 |
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL |
| 49 |
|
|
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES |
| 50 |
|
|
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT |
| 51 |
|
|
* CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 52 |
|
|
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 53 |
|
|
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS |
| 54 |
|
|
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS |
| 55 |
|
|
* SOFTWARE. |
| 56 |
|
|
* - |
| 57 |
|
|
* --Copyright-- |
| 58 |
|
|
*/ |
| 59 |
|
|
|
| 60 |
|
|
#ifndef INCLUDED_inet_misc_h |
| 61 |
|
|
#define INCLUDED_inet_misc_h |
| 62 |
|
|
|
| 63 |
|
|
#include "stdinc.h" |
| 64 |
|
|
|
| 65 |
|
|
#ifndef AI_PASSIVE |
| 66 |
|
|
#define AI_PASSIVE 0x00000001 /* get address to use bind() */ |
| 67 |
|
|
#endif /* AI_PASSIVE */ |
| 68 |
|
|
|
| 69 |
|
|
#ifndef AI_NUMERICHOST |
| 70 |
|
|
#define AI_NUMERICHOST 0x00000004 /* prevent name resolution */ |
| 71 |
|
|
#endif /* AI_NUMERICHOST */ |
| 72 |
|
|
|
| 73 |
|
|
#ifndef EAI_FAIL |
| 74 |
|
|
#define EAI_FAIL 4 /* non-recoverable failure in name resolution */ |
| 75 |
|
|
#endif /* EAI_FAIL */ |
| 76 |
|
|
|
| 77 |
|
|
#ifndef EAI_FAMILY |
| 78 |
|
|
#define EAI_FAMILY 5 /* ai_family not supported */ |
| 79 |
|
|
#endif /* EAI_FAMILY */ |
| 80 |
|
|
|
| 81 |
|
|
#ifndef EAI_MEMORY |
| 82 |
|
|
#define EAI_MEMORY 6 /* memory allocation failure */ |
| 83 |
|
|
#endif /* EAI_MEMORY */ |
| 84 |
|
|
|
| 85 |
|
|
#ifndef EAI_NONAME |
| 86 |
|
|
#define EAI_NONAME 8 /* hostname nor servname provided, or not known */ |
| 87 |
|
|
#endif /* EAI_NONAME */ |
| 88 |
|
|
|
| 89 |
|
|
#ifndef EAI_SYSTEM |
| 90 |
|
|
#define EAI_SYSTEM 11 /* system error returned in errno */ |
| 91 |
|
|
#endif /* EAI_SYSTEM */ |
| 92 |
|
|
|
| 93 |
|
|
#ifndef NI_NUMERICHOST |
| 94 |
|
|
#define NI_NUMERICHOST 0x00000002 |
| 95 |
|
|
#endif /* NI_NUMERICHOST */ |
| 96 |
|
|
|
| 97 |
|
|
#ifndef NI_NAMEREQD |
| 98 |
|
|
#define NI_NAMEREQD 0x00000004 |
| 99 |
|
|
#endif /* NI_NAMEREQD */ |
| 100 |
|
|
|
| 101 |
|
|
#ifndef NI_NUMERICSERV |
| 102 |
|
|
#define NI_NUMERICSERV 0x00000008 |
| 103 |
|
|
#endif /* NI_NUMERICSERV */ |
| 104 |
|
|
|
| 105 |
|
|
#ifndef NI_DGRAM |
| 106 |
|
|
#define NI_DGRAM 0x00000010 |
| 107 |
|
|
#endif /* NI_DGRAM */ |
| 108 |
|
|
|
| 109 |
|
|
#ifndef INADDR_NONE |
| 110 |
|
|
#define INADDR_NONE ((unsigned int) 0xffffffff) |
| 111 |
|
|
#endif /* INADDR_NONE */ |
| 112 |
|
|
|
| 113 |
|
|
#ifndef HAVE_STRUCT_SOCKADDR_STORAGE |
| 114 |
|
|
#ifdef SOCKADDR_IN_HAS_LEN /* BSD style sockaddr_storage for BSD style |
| 115 |
|
|
sockaddr_in */ |
| 116 |
|
|
struct sockaddr_storage { |
| 117 |
|
|
unsigned char ss_len; |
| 118 |
|
|
sa_family_t ss_family; |
| 119 |
|
|
char __ss_pad1[((sizeof(int64_t)) - sizeof(unsigned char) - |
| 120 |
|
|
sizeof(sa_family_t) )]; |
| 121 |
|
|
int64_t __ss_align; |
| 122 |
|
|
char __ss_pad2[(128 - sizeof(unsigned char) - sizeof(sa_family_t) - |
| 123 |
|
|
((sizeof(int64_t)) - sizeof(unsigned char) - |
| 124 |
|
|
sizeof(sa_family_t)) - (sizeof(int64_t)))]; |
| 125 |
|
|
}; |
| 126 |
|
|
#else /* Linux style for everything else (for now) */ |
| 127 |
|
|
struct sockaddr_storage |
| 128 |
|
|
{ |
| 129 |
|
|
sa_family_t ss_family; |
| 130 |
|
|
u_int32_t __ss_align; |
| 131 |
|
|
char __ss_padding[(128 - (2 * sizeof (u_int32_t)))]; |
| 132 |
|
|
}; |
| 133 |
|
|
#endif /* SOCKADDR_IN_HAS_LEN */ |
| 134 |
|
|
#endif /* HAVE_STRUCT_SOCKADDR_STORAGE */ |
| 135 |
|
|
|
| 136 |
|
|
#ifndef HAVE_STRUCT_ADDRINFO |
| 137 |
|
|
struct addrinfo { |
| 138 |
|
|
int ai_flags; |
| 139 |
|
|
int ai_family; |
| 140 |
|
|
int ai_socktype; |
| 141 |
|
|
int ai_protocol; |
| 142 |
|
|
size_t ai_addrlen; |
| 143 |
|
|
char *ai_canonname; |
| 144 |
|
|
struct sockaddr *ai_addr; |
| 145 |
|
|
struct addrinfo *ai_next; |
| 146 |
|
|
}; |
| 147 |
|
|
#endif /* HAVE_STRUCT_ADDRINFO */ |
| 148 |
|
|
|
| 149 |
|
|
#ifdef NO_IN6ADDR_ANY |
| 150 |
|
|
extern const struct in6_addr in6addr_any; |
| 151 |
|
|
#endif |
| 152 |
|
|
|
| 153 |
|
|
#ifdef NO_INET_NTOP |
| 154 |
|
|
const char * inet_ntop(int af, const void *src, char *dst, size_t size); |
| 155 |
|
|
#endif /* NO_INET_NTOP */ |
| 156 |
|
|
|
| 157 |
|
|
#ifdef NO_INET_PTON |
| 158 |
|
|
int inet_pton(int af, const char *src, void *dst); |
| 159 |
|
|
#endif /* NO_INET_PTON */ |
| 160 |
|
|
|
| 161 |
|
|
#ifdef NO_INET_ATON |
| 162 |
|
|
int inet_aton(const char *cp, struct in_addr * addr); |
| 163 |
|
|
#endif /* NO_INET_ATON */ |
| 164 |
|
|
|
| 165 |
|
|
#endif /* INCLUDED_inet_misc_h */ |