Home | History | Annotate | Download | only in include
      1 /*
      2  * Derived from android-14/arch-arm/usr/include/netdb.h
      3  *-
      4  * Copyright (c) 1980, 1983, 1988, 1993
      5  *      The Regents of the University of California.  All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  * 3. All advertising materials mentioning features or use of this software
     16  *    must display the following acknowledgement:
     17  *      This product includes software developed by the University of
     18  *      California, Berkeley and its contributors.
     19  * 4. Neither the name of the University nor the names of its contributors
     20  *    may be used to endorse or promote products derived from this software
     21  *    without specific prior written permission.
     22  *
     23  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     26  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     33  * SUCH DAMAGE.
     34  *
     35  * -
     36  * Portions Copyright (c) 1993 by Digital Equipment Corporation.
     37  *
     38  * Permission to use, copy, modify, and distribute this software for any
     39  * purpose with or without fee is hereby granted, provided that the above
     40  * copyright notice and this permission notice appear in all copies, and that
     41  * the name of Digital Equipment Corporation not be used in advertising or
     42  * publicity pertaining to distribution of the document or software without
     43  * specific, written prior permission.
     44  *
     45  * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
     46  * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
     47  * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
     48  * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
     49  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
     50  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
     51  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
     52  * SOFTWARE.
     53  * -
     54  * --Copyright--
     55  */
     56 
     57 /*
     58  *      @(#)netdb.h     8.1 (Berkeley) 6/2/93
     59  *      From: Id: netdb.h,v 8.9 1996/11/19 08:39:29 vixie Exp $
     60  * $FreeBSD: /repoman/r/ncvs/src/include/netdb.h,v 1.41 2006/04/15 16:20:26 ume Exp $
     61  */
     62 
     63 #ifndef _NETDB_PORTABLE_H_
     64 #define _NETDB_PORTABLE_H_
     65 
     66 #if 0
     67 /*
     68  * Most of the declararitions are not needed for addrinfo mapping.
     69  * Diff of mips and arm code running through cpp show only the
     70  * values of ai_socktype being different.
     71  */
     72 #include <sys/cdefs.h>
     73 #include <sys/types.h>
     74 #include <sys/socket.h>
     75 
     76 #ifndef  _PATH_HEQUIV
     77 # define _PATH_HEQUIV    "/system/etc/hosts.equiv"
     78 #endif
     79 
     80 #define _PATH_HOSTS     "/system/etc/hosts"
     81 #define _PATH_NETWORKS  "/system/etc/networks"
     82 #define _PATH_PROTOCOLS "/system/etc/protocols"
     83 #define _PATH_SERVICES  "/system/etc/services"
     84 
     85 #define  MAXHOSTNAMELEN  256
     86 
     87 
     88 /*
     89  * Structures returned by network data base library.  All addresses are
     90  * supplied in host order, and returned in network order (suitable for
     91  * use in system calls).
     92  */
     93 struct hostent {
     94         char    *h_name;        /* official name of host */
     95         char    **h_aliases;    /* alias list */
     96         int     h_addrtype;     /* host address type */
     97         int     h_length;       /* length of address */
     98         char    **h_addr_list;  /* list of addresses from name server */
     99 #define h_addr  h_addr_list[0]  /* address, for backward compatibility */
    100 };
    101 
    102 struct netent {
    103         char     *n_name;        /* official name of net */
    104         char     **n_aliases;    /* alias list */
    105         int      n_addrtype;     /* net address type */
    106         uint32_t n_net;          /* network # */
    107 };
    108 
    109 struct servent {
    110         char    *s_name;        /* official service name */
    111         char    **s_aliases;    /* alias list */
    112         int     s_port;         /* port # */
    113         char    *s_proto;       /* protocol to use */
    114 };
    115 
    116 struct protoent {
    117         char    *p_name;        /* official protocol name */
    118         char    **p_aliases;    /* alias list */
    119         int     p_proto;        /* protocol # */
    120 };
    121 #endif
    122 
    123 /*
    124  * For mapping MIPS and ARM these structures differ only in the
    125  * ai_socktype values.
    126  */
    127 struct addrinfo_portable {
    128         int     ai_flags;           /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */
    129         int     ai_family;          /* PF_xxx */
    130         int     ai_socktype;        /* SOCK_xxx */
    131         int     ai_protocol;        /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
    132         socklen_t ai_addrlen;       /* length of ai_addr */
    133         char    *ai_canonname;      /* canonical name for hostname */
    134         struct  sockaddr *ai_addr;  /* binary address */
    135         struct  addrinfo *ai_next;  /* next structure in linked list */
    136 };
    137 
    138 #if 0
    139 /*
    140  * Error return codes from gethostbyname() and gethostbyaddr()
    141  * (left in h_errno).
    142  */
    143 
    144 #define NETDB_INTERNAL  -1      /* see errno */
    145 #define NETDB_SUCCESS   0       /* no problem */
    146 #define HOST_NOT_FOUND  1       /* Authoritative Answer Host not found */
    147 #define TRY_AGAIN       2       /* Non-Authoritative Host not found, or SERVERFAIL */
    148 #define NO_RECOVERY     3       /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
    149 #define NO_DATA         4       /* Valid name, no data record of requested type */
    150 #define NO_ADDRESS      NO_DATA /* no address, look for MX record */
    151 
    152 /*
    153  * Error return codes from getaddrinfo()
    154  */
    155 #define EAI_ADDRFAMILY   1      /* address family for hostname not supported */
    156 #define EAI_AGAIN        2      /* temporary failure in name resolution */
    157 #define EAI_BADFLAGS     3      /* invalid value for ai_flags */
    158 #define EAI_FAIL         4      /* non-recoverable failure in name resolution */
    159 #define EAI_FAMILY       5      /* ai_family not supported */
    160 #define EAI_MEMORY       6      /* memory allocation failure */
    161 #define EAI_NODATA       7      /* no address associated with hostname */
    162 #define EAI_NONAME       8      /* hostname nor servname provided, or not known */
    163 #define EAI_SERVICE      9      /* servname not supported for ai_socktype */
    164 #define EAI_SOCKTYPE    10      /* ai_socktype not supported */
    165 #define EAI_SYSTEM      11      /* system error returned in errno */
    166 #define EAI_BADHINTS    12      /* invalid value for hints */
    167 #define EAI_PROTOCOL    13      /* resolved protocol is unknown */
    168 #define EAI_OVERFLOW    14      /* argument buffer overflow */
    169 #define EAI_MAX         15
    170 
    171 /*
    172  * Flag values for getaddrinfo()
    173  */
    174 #define AI_PASSIVE      0x00000001 /* get address to use bind() */
    175 #define AI_CANONNAME    0x00000002 /* fill ai_canonname */
    176 #define AI_NUMERICHOST  0x00000004 /* prevent host name resolution */
    177 #define AI_NUMERICSERV  0x00000008 /* prevent service name resolution */
    178 /* valid flags for addrinfo (not a standard def, apps should not use it) */
    179 #define AI_MASK \
    180     (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_NUMERICSERV | \
    181     AI_ADDRCONFIG)
    182 
    183 #define AI_ALL          0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */
    184 #define AI_V4MAPPED_CFG 0x00000200 /* accept IPv4-mapped if kernel supports */
    185 #define AI_ADDRCONFIG   0x00000400 /* only if any address is assigned */
    186 #define AI_V4MAPPED     0x00000800 /* accept IPv4-mapped IPv6 address */
    187 /* special recommended flags for getipnodebyname */
    188 #define AI_DEFAULT      (AI_V4MAPPED_CFG | AI_ADDRCONFIG)
    189 
    190 /*
    191  * Constants for getnameinfo()
    192  */
    193 #define NI_MAXHOST      1025
    194 #define NI_MAXSERV      32
    195 
    196 /*
    197  * Flag values for getnameinfo()
    198  */
    199 #define NI_NOFQDN       0x00000001
    200 #define NI_NUMERICHOST  0x00000002
    201 #define NI_NAMEREQD     0x00000004
    202 #define NI_NUMERICSERV  0x00000008
    203 #define NI_DGRAM        0x00000010
    204 #if 0 /* obsolete */
    205 #define NI_WITHSCOPEID  0x00000020
    206 #endif
    207 
    208 /*
    209  * Scope delimit character
    210  */
    211 #define SCOPE_DELIMITER '%'
    212 
    213 __BEGIN_DECLS
    214 /* BIONIC-BEGIN */
    215 #define  h_errno   (*__get_h_errno())
    216 int*  __get_h_errno(void);
    217 /* BIONIC-END */
    218 void endservent(void);
    219 struct hostent  *gethostbyaddr(const char *, int, int);
    220 struct hostent  *gethostbyname(const char *);
    221 int gethostbyname_r(const char *, struct hostent *, char *, size_t, struct hostent **, int *);
    222 struct hostent  *gethostbyname2(const char *, int);
    223 struct hostent  *gethostent(void);
    224 struct netent   *getnetbyaddr(uint32_t, int);
    225 struct netent   *getnetbyname(const char *);
    226 struct protoent *getprotobyname(const char *);
    227 struct protoent *getprotobynumber(int);
    228 struct servent  *getservbyname(const char *, const char *);
    229 struct servent  *getservbyport(int, const char *);
    230 struct servent  *getservent(void);
    231 void herror(const char *);
    232 const char      *hstrerror(int);
    233 #endif
    234 
    235 int WRAP(getaddrinfo)(const char *, const char *, struct addrinfo_portable *,
    236                          struct addrinfo_portable **);
    237 
    238 void WRAP(freeaddrinfo)(struct addrinfo_portable *);
    239 
    240 #if 0 /* Not needed for addrinfo mapping */
    241 int getnameinfo(const struct sockaddr *, socklen_t, char *, size_t, char *, size_t, int);
    242 const char      *gai_strerror(int);
    243 void setservent(int);
    244 
    245 #if 0 /* MISSING FROM BIONIC */
    246 void endhostent(void);
    247 void endnetent(void);
    248 void endnetgrent(void);
    249 void endprotoent(void);
    250 void freehostent(struct hostent *);
    251 
    252 int gethostbyaddr_r(const char *, int, int, struct hostent *, char *, size_t,
    253                     struct hostent **, int *);
    254 
    255 int gethostbyname2_r(const char *, int, struct hostent *, char *, size_t,
    256                      struct hostent **, int *);
    257 
    258 int gethostent_r(struct hostent *, char *, size_t, struct hostent **, int *);
    259 struct hostent   *getipnodebyaddr(const void *, size_t, int, int *);
    260 struct hostent   *getipnodebyname(const char *, int, int, int *);
    261 int getnetbyaddr_r(uint32_t, int, struct netent *, char *, size_t, struct netent**, int *);
    262 int getnetbyname_r(const char *, struct netent *, char *, size_t, struct netent **, int *);
    263 int getnetent_r(struct netent *, char *, size_t, struct netent **, int *);
    264 int getnetgrent(char **, char **, char **);
    265 int getprotobyname_r(const char *, struct protoent *, char *, size_t, struct protoent **);
    266 int getprotobynumber_r(int, struct protoent *, char *, size_t, struct protoent **);
    267 struct protoent  *getprotoent(void);
    268 int getprotoent_r(struct protoent *, char *, size_t, struct protoent **);
    269 int innetgr(const char *, const char *, const char *, const char *);
    270 void sethostent(int);
    271 void setnetent(int);
    272 void setprotoent(int);
    273 struct netent   *getnetent(void);
    274 void setnetgrent(const char *);
    275 #endif /* MISSING FROM BIONIC */
    276 #endif /* Not needed for addrinfo mapping */
    277 
    278 
    279 __END_DECLS
    280 
    281 #endif /* !_NETDB_H_ */
    282