netdb.h

Go to the documentation of this file.
00001 /* NETDB.H
00002 /*-
00003  * Copyright (c) 1980, 1983, 1988, 1993
00004  *      The Regents of the University of California.  All rights reserved.
00005  *
00006  * Redistribution and use in source and binary forms, with or without
00007  * modification, are permitted provided that the following conditions
00008  * are met:
00009  * 1. Redistributions of source code must retain the above copyright
00010  *    notice, this list of conditions and the following disclaimer.
00011  * 2. Redistributions in binary form must reproduce the above copyright
00012  *    notice, this list of conditions and the following disclaimer in the
00013  *    documentation and/or other materials provided with the distribution.
00014  * 3. All advertising materials mentioning features or use of this software
00015  *    must display the following acknowledgement:
00016  *      This product includes software developed by the University of
00017  *      California, Berkeley and its contributors.
00018  * 4. Neither the name of the University nor the names of its contributors
00019  *    may be used to endorse or promote products derived from this software
00020  *    without specific prior written permission.
00021  *
00022  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
00023  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00024  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00025  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
00026  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00027  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00028  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00029  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00031  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00032  * SUCH DAMAGE.
00033  *
00034  * -
00035  * Portions Copyright (c) 1993 by Digital Equipment Corporation.
00036  *
00037  * Permission to use, copy, modify, and distribute this software for any
00038  * purpose with or without fee is hereby granted, provided that the above
00039  * copyright notice and this permission notice appear in all copies, and that
00040  * the name of Digital Equipment Corporation not be used in advertising or
00041  * publicity pertaining to distribution of the document or software without
00042  * specific, written prior permission.
00043  *
00044  * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
00045  * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
00046  * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
00047  * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
00048  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
00049  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
00050  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
00051  * SOFTWARE.
00052  * -
00053  * --Copyright--
00054  */
00055 
00056 /*
00057  *      @(#)netdb.h     8.1 (Berkeley) 6/2/93
00058  *      From: Id: netdb.h,v 8.9 1996/11/19 08:39:29 vixie Exp $
00059  * $FreeBSD: src/include/netdb.h,v 1.38.2.1 2005/07/22 20:17:30 ume Exp $
00060  */
00061 
00062 #ifndef _NETDB_H_
00063 #define _NETDB_H_
00064 
00065 #ifdef __SYMBIAN32__
00066 #ifdef __cplusplus
00067 extern "C" {
00068 #endif
00069 #include <_ansi.h>
00070 #include <sys/cdefs.h>
00071 #endif
00072 #include <sys/_types.h>
00073 #include <sys/cdefs.h>
00074 #ifdef __SYMBIAN32__
00075 #include <arpa/inet.h>
00076 #include <sys/errno.h>
00077 #endif
00078 
00079 #ifndef _SIZE_T_DECLARED
00080 typedef __size_t        size_t;
00081 #define _SIZE_T_DECLARED
00082 #endif
00083 
00084 #ifndef _SOCKLEN_T_DECLARED
00085 typedef __socklen_t     socklen_t;
00086 #define _SOCKLEN_T_DECLARED
00087 #endif
00088 
00089 #ifndef _UINT32_T_DECLARED
00090 typedef __uint32_t      uint32_t;
00091 #define _UINT32_T_DECLARED
00092 #endif
00093 
00094 #ifndef _PATH_HEQUIV
00095 # define        _PATH_HEQUIV    "/etc/hosts.equiv"
00096 #endif
00097 #ifndef __SYMBIAN32__
00098 #define _PATH_HOSTS     "/etc/hosts"
00099 #define _PATH_NETWORKS  "/etc/networks"
00100 #define _PATH_PROTOCOLS "/etc/protocols"
00101 #define _PATH_SERVICES  "/etc/services"
00102 #define h_errno (*__h_error())
00103 #else
00104 #define _PATH_SERVICES  "z:\\resource\\services"
00105 #define h_errno errno
00106 #endif
00107 
00108 
00109 /*
00110  * Structures returned by network data base library.  All addresses are
00111  * supplied in host order, and returned in network order (suitable for
00112  * use in system calls).
00113  */
00114 struct hostent {
00115         char    *h_name;        /* official name of host */
00116         char    **h_aliases;    /* alias list */
00117         int     h_addrtype;     /* host address type */
00118         int     h_length;       /* length of address */
00119         char    **h_addr_list;  /* list of addresses from name server */
00120 #define h_addr  h_addr_list[0]  /* address, for backward compatibility */
00121 };
00122 
00123 struct netent {
00124         char            *n_name;        /* official name of net */
00125         char            **n_aliases;    /* alias list */
00126         int             n_addrtype;     /* net address type */
00127         #ifdef __SYMBIAN32__
00128         unsigned long n_net;
00129         #else
00130         uint32_t        n_net;          /* network # */
00131         #endif
00132 };
00133 
00134 struct servent {
00135         char    *s_name;        /* official service name */
00136         char    **s_aliases;    /* alias list */
00137         int     s_port;         /* port # */
00138         char    *s_proto;       /* protocol to use */
00139 };
00140 
00141 struct protoent {
00142         char    *p_name;        /* official protocol name */
00143         char    **p_aliases;    /* alias list */
00144         int     p_proto;        /* protocol # */
00145 };
00146 
00147 struct addrinfo {
00148         int     ai_flags;       /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */
00149         int     ai_family;      /* PF_xxx */
00150         int     ai_socktype;    /* SOCK_xxx */
00151         int     ai_protocol;    /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
00152         socklen_t ai_addrlen;   /* length of ai_addr */
00153         char    *ai_canonname;  /* canonical name for hostname */
00154         struct  sockaddr *ai_addr;      /* binary address */
00155         struct  addrinfo *ai_next;      /* next structure in linked list */
00156 };
00157 
00158 /*
00159  * Error return codes from gethostbyname() and gethostbyaddr()
00160  * (left in h_errno).
00161  */
00162 
00163 #define NETDB_INTERNAL  -1      /* see errno */
00164 #define NETDB_SUCCESS   0       /* no problem */
00165 #ifndef __SYMBIAN32__
00166 #define HOST_NOT_FOUND  1 /* Authoritative Answer Host not found */
00167 #define TRY_AGAIN       2 /* Non-Authoritative Host not found, or SERVERFAIL */
00168 #define NO_RECOVERY     3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
00169 #else
00170 #define HOST_NOT_FOUND  ENOENT          /* Authoritative Answer Host not found */
00171 #define TRY_AGAIN       ETIMEDOUT       /* Non-Authoritative Host not found, or SERVERFAIL */
00172 #define NO_RECOVERY     ECOMM           /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
00173 #endif
00174 #define NO_DATA         4 /* Valid name, no data record of requested type */
00175 #define NO_ADDRESS      NO_DATA         /* no address, look for MX record */
00176 
00177 /*
00178  * Error return codes from getaddrinfo()
00179  */
00180 #if 0
00181 /* obsoleted */
00182 #define EAI_ADDRFAMILY   1      /* address family for hostname not supported */
00183 #endif
00184 #define EAI_AGAIN        2      /* temporary failure in name resolution */
00185 #define EAI_BADFLAGS     3      /* invalid value for ai_flags */
00186 #define EAI_FAIL         4      /* non-recoverable failure in name resolution */
00187 #define EAI_FAMILY       5      /* ai_family not supported */
00188 #define EAI_MEMORY       6      /* memory allocation failure */
00189 #if 0
00190 /* obsoleted */
00191 #define EAI_NODATA       7      /* no address associated with hostname */
00192 #endif
00193 #define EAI_NONAME       8      /* hostname nor servname provided, or not known */
00194 #define EAI_SERVICE      9      /* servname not supported for ai_socktype */
00195 #define EAI_SOCKTYPE    10      /* ai_socktype not supported */
00196 #define EAI_SYSTEM      11      /* system error returned in errno */
00197 #define EAI_BADHINTS    12
00198 #define EAI_PROTOCOL    13
00199 #define EAI_MAX         14
00200 
00201 /*
00202  * Flag values for getaddrinfo()
00203  */
00204 #define AI_PASSIVE      0x00000001 /* get address to use bind() */
00205 #define AI_CANONNAME    0x00000002 /* fill ai_canonname */
00206 #define AI_NUMERICHOST  0x00000004 /* prevent host name resolution */
00207 #define AI_NUMERICSERV  0x00000008 /* prevent service name resolution */
00208 /* valid flags for addrinfo (not a standard def, apps should not use it) */
00209 #define AI_MASK \
00210     (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_NUMERICSERV | \
00211     AI_ADDRCONFIG)
00212 
00213 #define AI_ALL          0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */
00214 #define AI_V4MAPPED_CFG 0x00000200 /* accept IPv4-mapped if kernel supports */
00215 #define AI_ADDRCONFIG   0x00000400 /* only if any address is assigned */
00216 #define AI_V4MAPPED     0x00000800 /* accept IPv4-mapped IPv6 address */
00217 /* special recommended flags for getipnodebyname */
00218 #define AI_DEFAULT      (AI_V4MAPPED_CFG | AI_ADDRCONFIG)
00219 
00220 /*
00221  * Constants for getnameinfo()
00222  */
00223 #define NI_MAXHOST      1025
00224 #define NI_MAXSERV      32
00225 
00226 /*
00227  * Flag values for getnameinfo()
00228  */
00229 #define NI_NOFQDN       0x00000001
00230 #define NI_NUMERICHOST  0x00000002
00231 #define NI_NAMEREQD     0x00000004
00232 #define NI_NUMERICSERV  0x00000008
00233 #define NI_DGRAM        0x00000010
00234 #if 0 /* obsolete */
00235 #define NI_WITHSCOPEID  0x00000020
00236 #endif
00237 
00238 /*
00239  * Scope delimit character
00240  */
00241 #define SCOPE_DELIMITER '%'
00242 
00243 __BEGIN_DECLS
00244 #ifndef __SYMBIAN32__
00245 void            endhostent(void);
00246 void            endnetent(void);
00247 void            endnetgrent(void);
00248 void            endprotoent(void);
00249 #endif//__SYMBIAN32__
00250 IMPORT_C void           endservent(void);
00251 #ifndef __SYMBIAN32__
00252 void            freehostent(struct hostent *);
00253 #endif//__SYMBIAN32__
00254 IMPORT_C struct hostent *gethostbyaddr(const char *, int, int);
00255 IMPORT_C struct hostent *gethostbyname(const char *);
00256 #ifndef __SYMBIAN32__
00257 struct hostent  *gethostbyname2(const char *, int);
00258 struct hostent  *gethostent(void);
00259 struct hostent  *getipnodebyaddr(const void *, size_t, int, int *);
00260 struct hostent  *getipnodebyname(const char *, int, int, int *);
00261 struct netent   *getnetbyaddr(uint32_t, int);
00262 struct netent   *getnetbyname(const char *);
00263 struct netent   *getnetent(void);
00264 int             getnetgrent(char **, char **, char **);
00265 #endif//__SYMBIAN32__
00266 IMPORT_C struct protoent        *getprotobyname(const char *);
00267 IMPORT_C struct protoent        *getprotobynumber(int);
00268 #ifndef __SYMBIAN32__
00269 struct protoent *getprotoent(void);
00270 #endif//__SYMBIAN32__
00271 IMPORT_C struct servent *getservbyname(const char *, const char *);
00272 IMPORT_C struct servent *getservbyport(int, const char *);
00273 IMPORT_C struct servent *getservent(void);
00274 #ifndef __SYMBIAN32__
00275 void            herror(const char *);
00276 __const char    *hstrerror(int);
00277 int             innetgr(const char *, const char *, const char *, const char *);
00278 void            sethostent(int);
00279 /* void         sethostfile(const char *); */
00280 void            setnetent(int);
00281 void            setprotoent(int);
00282 #endif//__SYMBIAN32__
00283 IMPORT_C int            getaddrinfo(const char *, const char *,
00284                             const struct addrinfo *, struct addrinfo **);
00285 IMPORT_C int            getnameinfo(const struct sockaddr *, socklen_t, char *,
00286                             size_t, char *, size_t, int);
00287 IMPORT_C void           freeaddrinfo(struct addrinfo *);
00288 IMPORT_C const char     *gai_strerror(int);
00289 void            setnetgrent(const char *);
00290 IMPORT_C void           setservent(int);
00291 #ifdef __SYMBIAN32__
00292 
00293 #ifdef __SYMBIAN_COMPILE_UNUSED__
00294 int *__h_errno_location(void);
00295 #endif
00296 
00297 #endif
00298 
00299 /*
00300  * PRIVATE functions specific to the FreeBSD implementation
00301  */
00302 
00303 /* DO NOT USE THESE, THEY ARE SUBJECT TO CHANGE AND ARE NOT PORTABLE!!! */
00304 int     * __h_error(void);
00305 __END_DECLS
00306 #ifdef __SYMBIAN32__
00307 #ifdef __cplusplus
00308 }
00309 #endif
00310 #endif
00311 
00312 #endif /* !_NETDB_H_ */

Copyright © Nokia Corporation 2001-2008
Back to top