sofia-sip/su_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 SU_ADDRINFO_H
00031 /* Defined when <sofia-sip/su_addrinfo.h> has been included */
00032 #define SU_ADDRINFO_H
00033 
00042 #ifndef SU_TYPES_H
00043 #include <sofia-sip/su_types.h>
00044 #endif
00045 
00046 SOFIA_BEGIN_DECLS
00047 
00048 #if !SU_HAVE_ADDRINFO
00049 /*
00050  * Error return codes from getaddrinfo()
00051  */
00052 #ifndef EAI_ADDRFAMILY
00053 #define EAI_ADDRFAMILY   1      /* address family for hostname not supported */
00054 #define EAI_AGAIN        2      /* temporary failure in name resolution */
00055 #define EAI_BADFLAGS     3      /* invalid value for ai_flags */
00056 #define EAI_FAIL         4      /* non-recoverable failure in name resolution */
00057 #define EAI_FAMILY       5      /* ai_family not supported */
00058 #define EAI_MEMORY       6      /* memory allocation failure */
00059 #define EAI_NODATA       7      /* no address associated with hostname */
00060 #define EAI_NONAME       8      /* hostname nor servname provided, or not known */
00061 #define EAI_SERVICE      9      /* servname not supported for ai_socktype */
00062 #define EAI_SOCKTYPE    10      /* ai_socktype not supported */
00063 #define EAI_SYSTEM      11      /* system error returned in errno */
00064 #define EAI_BADHINTS    12
00065 #define EAI_PROTOCOL    13
00066 #define EAI_MAX         14
00067 #endif
00068 
00069 /*
00070  * Flag values for getaddrinfo()
00071  */
00072 #ifndef AI_PASSIVE
00073 #define AI_PASSIVE      0x00000001 /* get address to use bind() */
00074 #define AI_CANONNAME    0x00000002 /* fill ai_canonname */
00075 #define AI_NUMERICHOST  0x00000004 /* prevent name resolution */
00076 /* valid flags for addrinfo */
00077 #define AI_MASK         (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST)
00078 
00079 #define AI_ALL          0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */
00080 #define AI_V4MAPPED_CFG 0x00000200 /* accept IPv4-mapped if kernel supports */
00081 #define AI_ADDRCONFIG   0x00000400 /* only if any address is assigned */
00082 #define AI_V4MAPPED     0x00000800 /* accept IPv4-mapped IPv6 address */
00083 /* special recommended flags for getipnodebyname */
00084 #define AI_DEFAULT      (AI_V4MAPPED_CFG | AI_ADDRCONFIG)
00085 #endif
00086 
00087 /*
00088  * Constants for getnameinfo()
00089  */
00090 #ifndef NI_MAXHOST
00091 #define NI_MAXHOST      1025
00092 #define NI_MAXSERV      32
00093 #endif
00094 
00095 /*
00096  * Flag values for getnameinfo()
00097  */
00098 #ifndef NI_NOFQDN
00099 #define NI_NOFQDN       0x00000001
00100 #define NI_NUMERICHOST  0x00000002
00101 #define NI_NAMEREQD     0x00000004
00102 #define NI_NUMERICSERV  0x00000008
00103 #define NI_DGRAM        0x00000010
00104 #endif
00105 
00106 struct addrinfo {
00107         int     ai_flags;       /* AI_PASSIVE, AI_CANONNAME */
00108         int     ai_family;      /* PF_xxx */
00109         int     ai_socktype;    /* SOCK_xxx */
00110         int     ai_protocol;    /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
00111         size_t  ai_addrlen;     /* length of ai_addr */
00112         char    *ai_canonname;  /* canonical name for hostname */
00113         struct sockaddr *ai_addr;       /* binary address */
00114         struct addrinfo *ai_next;       /* next structure in linked list */
00115 };
00116 #endif  /* SU_WITH_GETADDRINFO */
00117 
00118 #ifndef EAI_BADHINTS     
00119 #define EAI_BADHINTS    10012
00120 #endif
00121 #ifndef EAI_PROTOCOL  
00122 #define EAI_PROTOCOL    10013
00123 #endif
00124 
00125 #ifndef AI_MASK
00126 #define AI_MASK         (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST)
00127 #endif
00128 
00130 typedef struct addrinfo su_addrinfo_t;
00131 
00133 SOFIAPUBFUN
00134 int su_getaddrinfo(char const *node, char const *service,
00135                    su_addrinfo_t const *hints,
00136                    su_addrinfo_t **res);
00138 SOFIAPUBFUN void su_freeaddrinfo(su_addrinfo_t *res);
00139 
00141 SOFIAPUBFUN char const *su_gai_strerror(int errcode);
00142 
00143 union su_sockaddr_u;
00144 
00145 SOFIAPUBFUN
00146 int su_getnameinfo(const union su_sockaddr_u *su, size_t sulen,
00147                    char *host, size_t hostlen,
00148                    char *serv, size_t servlen,
00149                    int flags);
00150 
00151 SOFIA_END_DECLS
00152 
00153 #endif  /* !defined(SU_ADDRINFO_H) */

Sofia-SIP 1.12.8 - Copyright (C) 2006 Nokia Corporation. All rights reserved. Licensed under the terms of the GNU Lesser General Public License.