]> git.lizzy.rs Git - plan9front.git/blob - sys/include/ape/netdb.h
libsec: implement elliptic curve group operations in jacobian coordinate system
[plan9front.git] / sys / include / ape / netdb.h
1 #ifndef __NETDB_H__
2 #define __NETDB_H__
3
4 #ifndef _BSD_EXTENSION
5     This header file is an extension to ANSI/POSIX
6 #endif
7
8 #pragma lib "/$M/lib/ape/libbsd.a"
9
10 /*-
11  * Copyright (c) 1980, 1983, 1988 Regents of the University of California.
12  * All rights reserved.
13  *
14  * Redistribution and use in source and binary forms are permitted
15  * provided that: (1) source distributions retain this entire copyright
16  * notice and comment, and (2) distributions including binaries display
17  * the following acknowledgement:  ``This product includes software
18  * developed by the University of California, Berkeley and its contributors''
19  * in the documentation or other materials provided with the distribution
20  * and in all advertising materials mentioning features or use of this
21  * software. Neither the name of the University nor the names of its
22  * contributors may be used to endorse or promote products derived
23  * from this software without specific prior written permission.
24  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
25  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
26  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27  *
28  *      @(#)netdb.h     5.11 (Berkeley) 5/21/90
29  */
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 /*
36  * Structures returned by network data base library.  All addresses are
37  * supplied in host order, and returned in network order (suitable for
38  * use in system calls).
39  */
40 struct  hostent {
41         char    *h_name;        /* official name of host */
42         char    **h_aliases;    /* alias list */
43         int     h_addrtype;     /* host address type */
44         int     h_length;       /* length of address */
45         char    **h_addr_list;  /* list of addresses from name server */
46 #define h_addr  h_addr_list[0]  /* address, for backward compatiblity */
47 };
48
49 /*
50  * Assumption here is that a network number
51  * fits in 32 bits -- probably a poor one.
52  */
53 struct  netent {
54         char            *n_name;        /* official name of net */
55         char            **n_aliases;    /* alias list */
56         int             n_addrtype;     /* net address type */
57         unsigned long   n_net;          /* network # */
58 };
59
60 struct  servent {
61         char    *s_name;        /* official service name */
62         char    **s_aliases;    /* alias list */
63         int     s_port;         /* port # */
64         char    *s_proto;       /* protocol to use */
65 };
66
67 struct  protoent {
68         char    *p_name;        /* official protocol name */
69         char    **p_aliases;    /* alias list */
70         int     p_proto;        /* protocol # */
71 };
72
73 /* from 4.0 RPCSRC */
74 struct rpcent {
75         char    *r_name;        /* name of server for this rpc program */
76         char    **r_aliases;    /* alias list */
77         int     r_number;       /* rpc program number */
78 };
79
80 extern struct hostent   *gethostbyname(const char *),
81                         *gethostbyaddr(const void *, int, int),
82                         *gethostent(void);
83 extern struct netent    *getnetbyname(const char *),
84                         *getnetbyaddr(long, int),
85                         *getnetent(void);
86 extern struct servent   *getservbyname(const char *, const char *),
87                         *getservbyport(int, const char *),
88                         *getservent(void);
89 extern struct protoent  *getprotobyname(const char *),
90                         *getprotobynumber(int),
91                         *getprotoent(void);
92 extern struct rpcent    *getrpcbyname(const char *), 
93                         *getrpcbynumber(int), 
94                         *getrpcent(void);
95 extern void sethostent(int),  endhostent(void),
96             setnetent(int),   endnetent(void),
97             setservent(int),  endservent(void),
98             setprotoent(int), endprotoent(void),
99             setrpcent(int),   endrpcent(void);
100
101 /*
102  * Error return codes from gethostbyname() and gethostbyaddr()
103  * (left in extern int h_errno).
104  */
105 extern int h_errno;
106 extern void herror(const char *);
107 extern char *hstrerror(int);
108
109 #define HOST_NOT_FOUND  1 /* Authoritative Answer Host not found */
110 #define TRY_AGAIN       2 /* Non-Authoritive Host not found, or SERVERFAIL */
111 #define NO_RECOVERY     3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
112 #define NO_DATA         4 /* Valid name, no data record of requested type */
113 #define NO_ADDRESS      NO_DATA         /* no address, look for MX record */
114
115 #define __HOST_SVC_NOT_AVAIL 99         /* libc internal use only */
116
117 struct  addrinfo {
118         int             ai_flags;       /* Input flags.  */
119         int             ai_family;      /* Protocol family for socket.  */
120         int             ai_socktype;    /* Socket type.  */
121         int             ai_protocol;    /* Protocol for socket.  */
122         int             ai_addrlen;     /* Length of socket address.  */
123         struct sockaddr *ai_addr;       /* Socket address for socket.  */
124         char            *ai_canonname;  /* Canonical name for service location.  */
125         struct addrinfo *ai_next;       /* Pointer to next in list.  */
126 };
127
128 extern int      getaddrinfo(char *, char *, struct addrinfo *, struct addrinfo **);
129 extern void     freeaddrinfo(struct addrinfo *);
130 extern int      getnameinfo(struct sockaddr *, int, char *, int, char *, int, unsigned int);
131 extern char     *gai_strerror(int);
132
133 /* Possible values for `ai_flags' field in `addrinfo' structure.  */
134 #define AI_PASSIVE      0x0001  /* Socket address is intended for `bind'.  */
135 #define AI_CANONNAME    0x0002  /* Request for canonical name.  */
136 #define AI_NUMERICHOST  0x0004  /* Don't use name resolution.  */
137 #define AI_V4MAPPED     0x0008  /* IPv4 mapped addresses are acceptable.  */
138 #define AI_ALL          0x0010  /* Return IPv4 mapped and IPv6 addresses.  */
139 #define AI_ADDRCONFIG   0x0020  /* Use configuration of this host to choose returned address type..  */
140 #define AI_NUMERICSERV  0x0400  /* Don't use name resolution.  */
141
142 /* getnameinfo flags */
143 #define NI_NOFQDN       0x0001  /* Only the nodename portion of the FQDN is returned for local hosts. */
144 #define NI_NUMERICHOST  0x0002  /* The numeric form of the node's address is returned instead of its name. */
145 #define NI_NAMEREQD     0x0004  /* Return an error if the node's name cannot be located in the database. */
146 #define NI_NUMERICSERV  0x0008  /* The numeric form of the service address is returned instead of its name. */
147 #define NI_NUMERICSCOPE 0x0010  /* For IPv6 addresses, the numeric form of the scope identifier is returned
148                                    instead of its name. */
149 #define NI_DGRAM        0x0020  /* Indicates that the service is a datagram service (SOCK_DGRAM). */
150
151 /* Error values for `getaddrinfo' and `getnameinfo' functions.  */
152 #define EAI_BADFLAGS      -1    /* Invalid value for `ai_flags' field */
153 #define EAI_NONAME        -2    /* NAME or SERVICE is unknown */
154 #define EAI_AGAIN         -3    /* Temporary failure in name resolution */
155 #define EAI_FAIL          -4    /* Non-recoverable failure in name resolution */
156 #define EAI_NODATA        -5    /* No address associated with NAME */
157 #define EAI_FAMILY        -6    /* `ai_family' not supported */
158 #define EAI_SOCKTYPE      -7    /* `ai_socktype' not supported */
159 #define EAI_SERVICE       -8    /* SERVICE not supported for `ai_socktype' */
160 #define EAI_ADDRFAMILY    -9    /* Address family for NAME not supported */
161 #define EAI_MEMORY        -10   /* Memory allocation failure */
162 #define EAI_SYSTEM        -11   /* System error returned in `errno' */
163 #define EAI_OVERFLOW      -12   /* Argument buffer overflow */
164
165 #ifdef __cplusplus
166 }
167 #endif
168
169 #endif /* !__NETDB_H__ */