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

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