2 * Copyright (C) 1993 AmiTCP/IP Group, <amitcp-group@hut.fi>
3 * Helsinki University of Technology, Finland.
5 * Copyright (C) 2005 Neil Cafferkey
6 * Copyright (C) 2005 - 2011 Pavel Fedin
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU Library General Public License
10 * version 2 as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this file; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
25 * Copyright (c) 1980, 1983, 1988 Regents of the University of California.
26 * All rights reserved.
28 * Redistribution and use in source and binary forms are permitted
29 * provided that: (1) source distributions retain this entire copyright
30 * notice and comment, and (2) distributions including binaries display
31 * the following acknowledgement: ``This product includes software
32 * developed by the University of California, Berkeley and its contributors''
33 * in the documentation or other materials provided with the distribution
34 * and in all advertising materials mentioning features or use of this
35 * software. Neither the name of the University nor the names of its
36 * contributors may be used to endorse or promote products derived
37 * from this software without specific prior written permission.
38 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
39 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
40 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
46 #define __BSD_VISIBLE 1
47 #include <sys/types.h>
49 #include <sys/socket.h> /* for socklen_t */
52 * Structures returned by network data base library. All addresses are
53 * supplied in host order, and returned in network order (suitable for
54 * use in system calls).
57 char *h_name
; /* official name of host */
58 char **h_aliases
; /* alias list */
59 int h_addrtype
; /* host address type */
60 int h_length
; /* length of address */
61 char **h_addr_list
; /* list of addresses from name server */
62 #define h_addr h_addr_list[0] /* address, for backward compatiblity */
66 * Assumption here is that a network number
67 * fits in 32 bits -- probably a poor one.
70 char *n_name
; /* official name of net */
71 char **n_aliases
; /* alias list */
72 int n_addrtype
; /* net address type */
73 unsigned long n_net
; /* network # */
77 char *s_name
; /* official service name */
78 char **s_aliases
; /* alias list */
79 int s_port
; /* port # */
80 char *s_proto
; /* protocol to use */
84 char *p_name
; /* official protocol name */
85 char **p_aliases
; /* alias list */
86 int p_proto
; /* protocol # */
90 * Error return codes from gethostbyname() and gethostbyaddr()
91 * (left in extern int h_errno).
95 #include <bsdsocket/socketbasetags.h>
96 #include <proto/socket.h>
98 static inline int *__get_h_errno_ptr(struct Library
*SocketBase
)
101 struct TagItem tags
[] = {
102 {SBTM_GETREF(SBTC_HERRNOLONGPTR
), (STACKIPTR
)&ptr
},
106 SocketBaseTagList(tags
);
110 #define h_errno (*__get_h_errno_ptr(SocketBase))
114 #define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found */
115 #define TRY_AGAIN 2 /* Non-Authoritive Host not found, or SERVERFAIL */
116 #define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
117 #define NO_DATA 4 /* Valid name, no data record of requested type */
118 #define NO_ADDRESS NO_DATA /* no address, look for MX record */
121 long ai_flags
; /* AI_PASSIVE, AI_CANONNAME */
122 long ai_family
; /* PF_xxx */
123 long ai_socktype
; /* SOCK_xxx */
124 long ai_protocol
; /* IPPROTO_xxx for IPv4 and IPv6 */
125 size_t ai_addrlen
; /* length of ai_addr */
126 char *ai_canonname
; /* canonical name for host */
127 struct sockaddr
*ai_addr
; /* binary address */
128 struct addrinfo
*ai_next
; /* next structure in linked list */
131 /* following for getaddrinfo() */
132 #define AI_PASSIVE 1 /* socket is intended for bind() + listen() */
133 #define AI_CANONNAME 2 /* return canonical name */
135 /* following for getnameinfo() */
136 #define NI_MAXHOST 1025 /* max hostname returned */
137 #define NI_MAXSERV 32 /* max service name returned */
139 #define NI_NOFQDN 1 /* do not return FQDN */
140 #define NI_NUMERICHOST 2 /* return numeric form of hostname */
141 #define NI_NAMEREQD 4 /* return error if hostname not found */
142 #define NI_NUMERICSERV 8 /* return numeric form of service name */
143 #define NI_DGRAM 16 /* datagram service for getservbyname() */
146 #define EAI_ADDRFAMILY 1 /* address family for host not supported */
147 #define EAI_AGAIN 2 /* temporary failure in name resolution */
148 #define EAI_BADFLAGS 3 /* invalid value for ai_flags */
149 #define EAI_FAIL 4 /* non-recoverable failure in name resolution */
150 #define EAI_FAMILY 5 /* ai_family not supported */
151 #define EAI_MEMORY 6 /* memory allocation failure */
152 #define EAI_NODATA 7 /* no address associated with host */
153 #define EAI_NONAME 8 /* host nor service provided, or not known */
154 #define EAI_SERVICE 9 /* service not supported for ai_socktype */
155 #define EAI_SOCKTYPE 10 /* ai_socktype not supported */
156 #define EAI_SYSTEM 11 /* system error returned in errno */
159 /* Flags for ResetNetDB() */
160 #define NETDB_IFF_CLEANOLD 1
161 #define NETDB_IFF_MODIFYOLD 2
162 #define NETDB_IFF_ADDNEW 4
164 #endif /* !NETDB_H */