2
* Copied from OpenSolaris 10 public sources
3
* http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/head/netdb.h
6
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
7
* Use is subject to license terms.
10
/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
11
/* All Rights Reserved */
16
* Copyright (c) 1980, 1983, 1988, 1993
17
* The Regents of the University of California. All rights reserved.
19
* Redistribution and use in source and binary forms, with or without
20
* modification, are permitted provided that the following conditions
22
* 1. Redistributions of source code must retain the above copyright
23
* notice, this list of conditions and the following disclaimer.
24
* 2. Redistributions in binary form must reproduce the above copyright
25
* notice, this list of conditions and the following disclaimer in the
26
* documentation and/or other materials provided with the distribution.
27
* 3. All advertising materials mentioning features or use of this software
28
* must display the following acknowledgement:
29
* This product includes software developed by the University of
30
* California, Berkeley and its contributors.
31
* 4. Neither the name of the University nor the names of its contributors
32
* may be used to endorse or promote products derived from this software
33
* without specific prior written permission.
35
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
36
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
37
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
38
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
39
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
40
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
41
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
42
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
43
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
44
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
49
* Permission to use, copy, modify, and distribute this software for any
50
* purpose with or without fee is hereby granted, provided that the above
51
* copyright notice and this permission notice appear in all copies, and that
52
* the name of Digital Equipment Corporation not be used in advertising or
53
* publicity pertaining to distribution of the document or software without
54
* specific, written prior permission.
56
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
57
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
58
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
59
* CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
60
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
61
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
62
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
70
* Structures returned by network data base library.
71
* All addresses are supplied in host order, and
72
* returned in network order (suitable for use in system calls).
78
#include <sys/types.h>
79
#include <netinet/in.h>
80
#if !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__)
81
#include <sys/socket.h>
82
#endif /* !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) */
83
#include <sys/feature_tests.h>
89
#define _PATH_HEQUIV "/etc/hosts.equiv"
90
#define _PATH_HOSTS "/etc/hosts"
91
#define _PATH_IPNODES "/etc/inet/ipnodes"
92
#define _PATH_IPSECALGS "/etc/inet/ipsecalgs"
93
#define _PATH_NETMASKS "/etc/netmasks"
94
#define _PATH_NETWORKS "/etc/networks"
95
#define _PATH_PROTOCOLS "/etc/protocols"
96
#define _PATH_SERVICES "/etc/services"
99
char *h_name; /* official name of host */
100
char **h_aliases; /* alias list */
101
int h_addrtype; /* host address type */
102
int h_length; /* length of address */
103
char **h_addr_list; /* list of addresses from name server */
104
#define h_addr h_addr_list[0] /* address, for backward compatiblity */
109
* addrinfo introduced with IPv6 for Protocol-Independent Hostname
110
* and Service Name Translation.
113
#if !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__)
115
int ai_flags; /* AI_PASSIVE, AI_CANONNAME, ... */
116
int ai_family; /* PF_xxx */
117
int ai_socktype; /* SOCK_xxx */
118
int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
120
int _ai_pad; /* for backwards compat with old size_t */
121
#endif /* __sparcv9 */
122
socklen_t ai_addrlen;
123
char *ai_canonname; /* canonical name for hostname */
124
struct sockaddr *ai_addr; /* binary address */
125
struct addrinfo *ai_next; /* next structure in linked list */
130
#define AI_PASSIVE 0x0008 /* intended for bind() + listen() */
131
#define AI_CANONNAME 0x0010 /* return canonical version of host */
132
#define AI_NUMERICHOST 0x0020 /* use numeric node address string */
133
#define AI_NUMERICSERV 0x0040 /* servname is assumed numeric */
135
/* getipnodebyname() flags */
136
#define AI_V4MAPPED 0x0001 /* IPv4 mapped addresses if no IPv6 */
137
#define AI_ALL 0x0002 /* IPv6 and IPv4 mapped addresses */
138
#define AI_ADDRCONFIG 0x0004 /* AAAA or A records only if IPv6/IPv4 cnfg'd */
142
* These were defined in RFC 2553 but not SUSv3
143
* or RFC 3493 which obsoleted 2553.
145
#if !defined(_XPG6) || defined(__EXTENSIONS__)
146
#define AI_DEFAULT (AI_V4MAPPED | AI_ADDRCONFIG)
148
/* addrinfo errors */
149
#define EAI_ADDRFAMILY 1 /* address family not supported */
150
#define EAI_NODATA 7 /* no address */
151
#endif /* !defined(_XPG6) || defined(__EXTENSIONS__) */
152
#define EAI_AGAIN 2 /* DNS temporary failure */
153
#define EAI_BADFLAGS 3 /* invalid ai_flags */
154
#define EAI_FAIL 4 /* DNS non-recoverable failure */
155
#define EAI_FAMILY 5 /* ai_family not supported */
156
#define EAI_MEMORY 6 /* memory allocation failure */
157
#define EAI_NONAME 8 /* host/servname not known */
158
#define EAI_SERVICE 9 /* servname not supported for ai_socktype */
159
#define EAI_SOCKTYPE 10 /* ai_socktype not supported */
160
#define EAI_SYSTEM 11 /* system error in errno */
161
#define EAI_OVERFLOW 12 /* argument buffer overflow */
162
#define EAI_PROTOCOL 13
165
/* getnameinfo flags */
166
#define NI_NOFQDN 0x0001
167
#define NI_NUMERICHOST 0x0002 /* return numeric form of address */
168
#define NI_NAMEREQD 0x0004 /* request DNS name */
169
#define NI_NUMERICSERV 0x0008
170
#define NI_DGRAM 0x0010
172
#if !defined(_XPG6) || defined(__EXTENSIONS__)
173
/* Not listed in any standards document */
174
#define NI_WITHSCOPEID 0x0020
175
#define NI_NUMERICSCOPE 0x0040
177
/* getnameinfo max sizes as defined in RFC 2553 obsoleted in RFC 3493 */
178
#define NI_MAXHOST 1025
179
#define NI_MAXSERV 32
180
#endif /* !defined(_XPG6) || defined(__EXTENSIONS__) */
181
#endif /* !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) */
184
* Scope delimit character
186
#define SCOPE_DELIMITER '%'
190
* Algorithm entry for /etc/inet/ipsecalgs which defines IPsec protocols
193
#if !defined(_XPG4_2) || defined(__EXTENSIONS__)
194
typedef struct ipsecalgent {
195
char **a_names; /* algorithm names */
196
int a_proto_num; /* protocol number */
197
int a_alg_num; /* algorithm number */
198
char *a_mech_name; /* encryption framework mechanism name */
199
int *a_block_sizes; /* supported block sizes */
200
int *a_key_sizes; /* supported key sizes */
201
int a_key_increment; /* key size increment */
202
int *a_mech_params; /* mechanism specific parameters */
203
int a_alg_flags; /* algorithm flags */
206
/* well-known IPsec protocol numbers */
208
#define IPSEC_PROTO_AH 2
209
#define IPSEC_PROTO_ESP 3
210
#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
213
* Assumption here is that a network number
214
* fits in 32 bits -- probably a poor one.
217
char *n_name; /* official name of net */
218
char **n_aliases; /* alias list */
219
int n_addrtype; /* net address type */
220
in_addr_t n_net; /* network # */
224
char *p_name; /* official protocol name */
225
char **p_aliases; /* alias list */
226
int p_proto; /* protocol # */
230
char *s_name; /* official service name */
231
char **s_aliases; /* alias list */
232
int s_port; /* port # */
233
char *s_proto; /* protocol to use */
237
#if !defined(_XPG4_2) || defined(__EXTENSIONS__)
238
struct hostent *gethostbyname_r
239
(const char *, struct hostent *, char *, int, int *h_errnop);
240
struct hostent *gethostbyaddr_r
241
(const char *, int, int, struct hostent *, char *, int, int *h_errnop);
242
struct hostent *getipnodebyname(const char *, int, int, int *);
243
struct hostent *getipnodebyaddr(const void *, size_t, int, int *);
244
void freehostent(struct hostent *);
245
struct hostent *gethostent_r(struct hostent *, char *, int, int *h_errnop);
247
struct servent *getservbyname_r
248
(const char *name, const char *, struct servent *, char *, int);
249
struct servent *getservbyport_r
250
(int port, const char *, struct servent *, char *, int);
251
struct servent *getservent_r(struct servent *, char *, int);
253
struct netent *getnetbyname_r
254
(const char *, struct netent *, char *, int);
255
struct netent *getnetbyaddr_r(long, int, struct netent *, char *, int);
256
struct netent *getnetent_r(struct netent *, char *, int);
258
struct protoent *getprotobyname_r
259
(const char *, struct protoent *, char *, int);
260
struct protoent *getprotobynumber_r
261
(int, struct protoent *, char *, int);
262
struct protoent *getprotoent_r(struct protoent *, char *, int);
264
int getnetgrent_r(char **, char **, char **, char *, int);
265
int innetgr(const char *, const char *, const char *, const char *);
266
#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
268
/* Old interfaces that return a pointer to a static area; MT-unsafe */
269
struct hostent *gethostbyname(const char *);
270
struct hostent *gethostent(void);
271
struct netent *getnetbyaddr(in_addr_t, int);
272
struct netent *getnetbyname(const char *);
273
struct netent *getnetent(void);
274
struct protoent *getprotobyname(const char *);
275
struct protoent *getprotobynumber(int);
276
struct protoent *getprotoent(void);
277
struct servent *getservbyname(const char *, const char *);
278
struct servent *getservbyport(int, const char *);
279
struct servent *getservent(void);
281
/* gethostbyaddr() second argument is a size_t only in unix95/unix98 */
282
#if !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__)
283
struct hostent *gethostbyaddr(const void *, socklen_t, int);
285
struct hostent *gethostbyaddr(const void *, size_t, int);
286
#endif /* !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) */
288
#if !defined(_XPG4_2) || defined(__EXTENSIONS__)
289
int endhostent(void);
291
int endprotoent(void);
292
int endservent(void);
295
int setprotoent(int);
298
void endhostent(void);
299
void endnetent(void);
300
void endprotoent(void);
301
void endservent(void);
302
void sethostent(int);
304
void setprotoent(int);
305
void setservent(int);
306
#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
308
#if !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__)
311
#ifdef __PRAGMA_REDEFINE_EXTNAME
312
#pragma redefine_extname getaddrinfo __xnet_getaddrinfo
313
#else /* __PRAGMA_REDEFINE_EXTNAME */
314
#define getaddrinfo __xnet_getaddrinfo
315
#endif /* __PRAGMA_REDEFINE_EXTNAME */
318
int getaddrinfo(const char *_RESTRICT_KYWD1,
319
const char *_RESTRICT_KYWD2,
320
const struct addrinfo *_RESTRICT_KYWD3,
321
struct addrinfo **_RESTRICT_KYWD4);
322
void freeaddrinfo(struct addrinfo *);
323
const char *gai_strerror(int);
324
int getnameinfo(const struct sockaddr *_RESTRICT_KYWD1,
325
socklen_t, char *_RESTRICT_KYWD2, socklen_t,
326
char *_RESTRICT_KYWD3, socklen_t, int);
327
#endif /* !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) */
329
#if !defined(_XPG4_2) || defined(__EXTENSIONS__)
330
int getnetgrent(char **, char **, char **);
331
int setnetgrent(const char *);
332
int endnetgrent(void);
333
int rcmd(char **, unsigned short,
334
const char *, const char *, const char *, int *);
335
int rcmd_af(char **, unsigned short,
336
const char *, const char *, const char *, int *, int);
337
int rresvport_af(int *, int);
338
int rresvport_addr(int *, struct sockaddr_storage *);
339
int rexec(char **, unsigned short,
340
const char *, const char *, const char *, int *);
341
int rexec_af(char **, unsigned short,
342
const char *, const char *, const char *, int *, int);
343
int rresvport(int *);
344
int ruserok(const char *, int, const char *, const char *);
346
struct hostent *gethostbyname2(const char *, int);
347
void herror(const char *);
348
const char *hstrerror(int);
351
/* IPsec algorithm prototype definitions */
352
struct ipsecalgent *getipsecalgbyname(const char *, int, int *);
353
struct ipsecalgent *getipsecalgbynum(int, int, int *);
354
int getipsecprotobyname(const char *doi_name);
355
char *getipsecprotobynum(int doi_domain);
356
void freeipsecalgent(struct ipsecalgent *ptr);
357
/* END IPsec algorithm prototype definitions */
359
#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
361
struct hostent *gethostbyname_r();
362
struct hostent *gethostbyaddr_r();
363
struct hostent *getipnodebyname();
364
struct hostent *getipnodebyaddr();
366
struct hostent *gethostent_r();
367
struct servent *getservbyname_r();
368
struct servent *getservbyport_r();
369
struct servent *getservent_r();
370
struct netent *getnetbyname_r();
371
struct netent *getnetbyaddr_r();
372
struct netent *getnetent_r();
373
struct protoent *getprotobyname_r();
374
struct protoent *getprotobynumber_r();
375
struct protoent *getprotoent_r();
379
/* Old interfaces that return a pointer to a static area; MT-unsafe */
380
struct hostent *gethostbyname();
381
struct hostent *gethostbyaddr();
382
struct hostent *gethostent();
383
struct netent *getnetbyname();
384
struct netent *getnetbyaddr();
385
struct netent *getnetent();
386
struct servent *getservbyname();
387
struct servent *getservbyport();
388
struct servent *getservent();
389
struct protoent *getprotobyname();
390
struct protoent *getprotobynumber();
391
struct protoent *getprotoent();
410
int rresvport_addr();
413
struct hostent *gethostbyname2();
416
/* IPv6 prototype definitons */
419
const char *gai_strerror();
421
/* END IPv6 prototype definitions */
424
#if !defined(_XPG4_2) || defined(__EXTENSIONS__)
425
/* IPsec algorithm prototype definitions */
426
struct ipsecalgent *getalgbyname();
427
struct ipsecalgent *getalgbydoi();
428
int getdoidomainbyname();
429
const char *getdoidomainbynum();
431
/* END IPsec algorithm prototype definitions */
432
#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
434
#endif /* __STDC__ */
437
* Error return codes from gethostbyname() and gethostbyaddr()
438
* (when using the resolver)
445
extern int *__h_errno(void);
447
extern int *__h_errno();
448
#endif /* __STDC__ */
450
/* Only #define h_errno if there is no conflict with other use */
451
#ifdef H_ERRNO_IS_FUNCTION
452
#define h_errno (*__h_errno())
453
#endif /* NO_H_ERRNO_DEFINE */
454
#endif /* _REENTRANT */
457
* Error return codes from gethostbyname() and gethostbyaddr()
458
* (left in extern int h_errno).
460
#define HOST_NOT_FOUND 1 /* Authoritive Answer Host not found */
461
#define TRY_AGAIN 2 /* Non-Authoritive Host not found, or SERVERFAIL */
462
#define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
463
#define NO_DATA 4 /* Valid name, no data record of requested type */
465
#if !defined(_XPG4_2) || defined(__EXTENSIONS__)
466
#define NO_ADDRESS NO_DATA /* no address, look for MX record */
469
#define NETDB_INTERNAL -1 /* see errno */
470
#define NETDB_SUCCESS 0 /* no problem */
473
#define MAXHOSTNAMELEN 256
475
#define MAXALIASES 35
477
#endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
483
#endif /* _NETDB_H */