ext/socket/addrinfo.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project.
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  * 1. Redistributions of source code must retain the above copyright
00009  *    notice, this list of conditions and the following disclaimer.
00010  * 2. Redistributions in binary form must reproduce the above copyright
00011  *    notice, this list of conditions and the following disclaimer in the
00012  *    documentation and/or other materials provided with the distribution.
00013  * 3. Neither the name of the project nor the names of its contributors
00014  *    may be used to endorse or promote products derived from this software
00015  *    without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
00018  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
00021  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00022  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00023  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00024  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00025  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00026  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00027  * SUCH DAMAGE.
00028  */
00029 
00030 #ifndef ADDR_INFO_H
00031 #define ADDR_INFO_H
00032 
00033 /* special compatibility hack */
00034 #undef EAI_ADDRFAMILY
00035 #undef EAI_AGAIN
00036 #undef EAI_BADFLAGS
00037 #undef EAI_FAIL
00038 #undef EAI_FAMILY
00039 #undef EAI_MEMORY
00040 #undef EAI_NODATA
00041 #undef EAI_NONAME
00042 #undef EAI_SERVICE
00043 #undef EAI_SOCKTYPE
00044 #undef EAI_SYSTEM
00045 #undef EAI_BADHINTS
00046 #undef EAI_PROTOCOL
00047 #undef EAI_MAX
00048 
00049 #undef AI_PASSIVE
00050 #undef AI_CANONNAME
00051 #undef AI_NUMERICHOST
00052 #undef AI_NUMERICSERV
00053 #undef AI_ALL
00054 #undef AI_ADDRCONFIG
00055 #undef AI_V4MAPPED
00056 #undef AI_DEFAULT
00057 
00058 #undef NI_NOFQDN
00059 #undef NI_NUMERICHOST
00060 #undef NI_NAMEREQD
00061 #undef NI_NUMERICSERV
00062 #undef NI_DGRAM
00063 
00064 #ifndef __P
00065 # ifdef HAVE_PROTOTYPES
00066 #  define __P(args) args
00067 # else
00068 #  define __P(args) ()
00069 # endif
00070 #endif
00071 
00072 /* special compatibility hack -- end*/
00073 
00074 
00075 /*
00076  * Error return codes from getaddrinfo()
00077  */
00078 #define EAI_ADDRFAMILY   1      /* address family for hostname not supported */
00079 #define EAI_AGAIN        2      /* temporary failure in name resolution */
00080 #define EAI_BADFLAGS     3      /* invalid value for ai_flags */
00081 #define EAI_FAIL         4      /* non-recoverable failure in name resolution */
00082 #define EAI_FAMILY       5      /* ai_family not supported */
00083 #define EAI_MEMORY       6      /* memory allocation failure */
00084 #define EAI_NODATA       7      /* no address associated with hostname */
00085 #define EAI_NONAME       8      /* hostname nor servname provided, or not known */
00086 #define EAI_SERVICE      9      /* servname not supported for ai_socktype */
00087 #define EAI_SOCKTYPE    10      /* ai_socktype not supported */
00088 #define EAI_SYSTEM      11      /* system error returned in errno */
00089 #define EAI_BADHINTS    12
00090 #define EAI_PROTOCOL    13
00091 #define EAI_MAX         14
00092 
00093 /*
00094  * Flag values for getaddrinfo()
00095  */
00096 #define AI_PASSIVE      0x00000001 /* get address to use bind() */
00097 #define AI_CANONNAME    0x00000002 /* fill ai_canonname */
00098 #define AI_NUMERICHOST  0x00000004 /* prevent name resolution */
00099 #define AI_NUMERICSERV  0x00000008 /* prevent service name resolution */
00100 /* valid flags for addrinfo */
00101 #ifndef __HAIKU__
00102 #undef AI_MASK
00103 #define AI_MASK         (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_NUMERICSERV)
00104 #endif
00105 
00106 #define AI_ALL          0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */
00107 #define AI_V4MAPPED_CFG 0x00000200 /* accept IPv4-mapped if kernel supports */
00108 #define AI_ADDRCONFIG   0x00000400 /* only if any address is assigned */
00109 #define AI_V4MAPPED     0x00000800 /* accept IPv4-mapped IPv6 address */
00110 /* special recommended flags for getipnodebyname */
00111 #define AI_DEFAULT      (AI_V4MAPPED_CFG | AI_ADDRCONFIG)
00112 
00113 /*
00114  * Constants for getnameinfo()
00115  */
00116 #ifndef NI_MAXHOST
00117 #define NI_MAXHOST      1025
00118 #define NI_MAXSERV      32
00119 #endif
00120 
00121 /*
00122  * Flag values for getnameinfo()
00123  */
00124 #define NI_NOFQDN       0x00000001
00125 #define NI_NUMERICHOST  0x00000002
00126 #define NI_NAMEREQD     0x00000004
00127 #define NI_NUMERICSERV  0x00000008
00128 #define NI_DGRAM        0x00000010
00129 
00130 #ifndef HAVE_TYPE_STRUCT_ADDRINFO
00131 struct addrinfo {
00132         int     ai_flags;       /* AI_PASSIVE, AI_CANONNAME */
00133         int     ai_family;      /* PF_xxx */
00134         int     ai_socktype;    /* SOCK_xxx */
00135         int     ai_protocol;    /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
00136         size_t  ai_addrlen;     /* length of ai_addr */
00137         char    *ai_canonname;  /* canonical name for hostname */
00138         struct sockaddr *ai_addr;       /* binary address */
00139         struct addrinfo *ai_next;       /* next structure in linked list */
00140 };
00141 #endif
00142 
00143 #ifndef HAVE_GETADDRINFO
00144 #undef getaddrinfo
00145 #define getaddrinfo getaddrinfo__compat
00146 #endif
00147 #ifndef HAVE_GETNAMEINFO
00148 #undef getnameinfo
00149 #define getnameinfo getnameinfo__compat
00150 #endif
00151 #ifndef HAVE_FREEHOSTENT
00152 #undef freehostent
00153 #define freehostent freehostent__compat
00154 #endif
00155 #ifndef HAVE_FREEADDRINFO
00156 #undef freeaddrinfo
00157 #define freeaddrinfo freeaddrinfo__compat
00158 #endif
00159 
00160 extern int getaddrinfo __P((
00161         const char *hostname, const char *servname,
00162         const struct addrinfo *hints,
00163         struct addrinfo **res));
00164 
00165 extern int getnameinfo __P((
00166         const struct sockaddr *sa,
00167         socklen_t salen,
00168         char *host,
00169         socklen_t hostlen,
00170         char *serv,
00171         socklen_t servlen,
00172         int flags));
00173 
00174 extern void freehostent __P((struct hostent *));
00175 extern void freeaddrinfo __P((struct addrinfo *));
00176 extern
00177 #ifdef GAI_STRERROR_CONST
00178 const
00179 #endif
00180 char *gai_strerror __P((int));
00181 
00182 /* In case there is no definition of offsetof() provided - though any proper
00183 Standard C system should have one. */
00184 
00185 #ifndef offsetof
00186 #define offsetof(p_type,field) ((size_t)&(((p_type *)0)->field))
00187 #endif
00188 
00189 #endif
00190 

Generated on Wed Aug 10 09:17:04 2011 for Ruby by  doxygen 1.4.7