xref: /illumos-gate/usr/src/lib/libresolv/netdb.h (revision 1da57d55)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 1996 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
28 /*	  All Rights Reserved  	*/
29 
30 /*
31  * Portions of this source code were derived from Berkeley 4.3 BSD
32  * under license from the Regents of the University of California.
33  */
34 
35 /*
36  * Structures returned by network data base library.
37  * All addresses are supplied in host order, and
38  * returned in network order (suitable for use in system calls).
39  */
40 
41 #ifndef _NETDB_H
42 #define	_NETDB_H
43 
44 #ifdef	__cplusplus
45 extern "C" {
46 #endif
47 
48 #define	_PATH_HEQUIV	"/etc/hosts.equiv"
49 #define	_PATH_HOSTS	"/etc/hosts"
50 #define	_PATH_NETWORKS	"/etc/networks"
51 #define	_PATH_PROTOCOLS	"/etc/protocols"
52 #define	_PATH_SERVICES	"/etc/services"
53 
54 struct	hostent {
55 	char	*h_name;	/* official name of host */
56 	char	**h_aliases;	/* alias list */
57 	int	h_addrtype;	/* host address type */
58 	int	h_length;	/* length of address */
59 	char	**h_addr_list;	/* list of addresses from name server */
60 #define	h_addr	h_addr_list[0]	/* address, for backward compatiblity */
61 };
62 
63 /*
64  * Assumption here is that a network number
65  * fits in 32 bits -- probably a poor one.
66  */
67 struct	netent {
68 	char		*n_name;	/* official name of net */
69 	char		**n_aliases;	/* alias list */
70 	int		n_addrtype;	/* net address type */
71 	unsigned long	n_net;		/* network # */
72 };
73 
74 struct	servent {
75 	char	*s_name;	/* official service name */
76 	char	**s_aliases;	/* alias list */
77 	int	s_port;		/* port # */
78 	char	*s_proto;	/* protocol to use */
79 };
80 
81 struct	protoent {
82 	char	*p_name;	/* official protocol name */
83 	char	**p_aliases;	/* alias list */
84 	int	p_proto;	/* protocol # */
85 };
86 
87 #ifdef	__STDC__
88 struct hostent	*gethostbyname_r
89 	(const char *,		 struct hostent *, char *, int, int *h_errnop);
90 struct hostent	*gethostbyaddr_r
91 	(const char *, int, int, struct hostent *, char *, int, int *h_errnop);
92 struct hostent	*gethostent_r(struct hostent *, char *, int, int *h_errnop);
93 
94 struct servent	*getservbyname_r
95 	(const char *name, const char *, struct servent *, char *, int);
96 struct servent	*getservbyport_r
97 	(int port,	   const char *, struct servent *, char *, int);
98 struct servent	*getservent_r(struct	servent *, char *, int);
99 
100 struct netent	*getnetbyname_r
101 	(const char *, struct netent *, char *, int);
102 struct netent	*getnetbyaddr_r(long, int, struct netent *, char *, int);
103 struct netent	*getnetent_r(struct netent *, char *, int);
104 
105 struct protoent	*getprotobyname_r
106 	(const char *, struct protoent *, char *, int);
107 struct protoent	*getprotobynumber_r
108 	(int, struct protoent *, char *, int);
109 struct protoent	*getprotoent_r(struct protoent *, char *, int);
110 
111 int getnetgrent_r(char **, char **, char **, char *, int);
112 int innetgr(const char *, const char *, const char *, const char *);
113 
114 /* Old interfaces that return a pointer to a static area;  MT-unsafe */
115 struct hostent	*gethostbyname(const char *);
116 struct hostent	*gethostbyaddr(const char *, int, int);
117 struct hostent	*gethostent(void);
118 struct netent	*getnetbyname(const char *);
119 struct netent	*getnetbyaddr(long, int);
120 struct netent	*getnetent(void);
121 struct servent	*getservbyname(const char *, const char *);
122 struct servent	*getservbyport(int, const char *);
123 struct servent	*getservent(void);
124 struct protoent	*getprotobyname(const char *);
125 struct protoent	*getprotobynumber(int);
126 struct protoent	*getprotoent(void);
127 int		 getnetgrent(char **, char **, char **);
128 
129 int sethostent(int);
130 int endhostent(void);
131 int setnetent(int);
132 int endnetent(void);
133 int setservent(int);
134 int endservent(void);
135 int setprotoent(int);
136 int endprotoent(void);
137 int setnetgrent(const char *);
138 int endnetgrent(void);
139 int rcmd(char **ahost, unsigned short inport,
140 	const char *luser, const char *ruser, const char *cmd, int *fd2p);
141 int rexec(char **ahost, unsigned short inport,
142 	const char *user, const char *passwd, const char *cmd, int *fd2p);
143 int rresvport(int *);
144 int ruserok(const char *rhost, int suser, const char *ruser, const char *luser);
145 #else
146 struct hostent	*gethostbyname_r();
147 struct hostent	*gethostbyaddr_r();
148 struct hostent	*gethostent_r();
149 struct servent	*getservbyname_r();
150 struct servent	*getservbyport_r();
151 struct servent	*getservent_r();
152 struct netent	*getnetbyname_r();
153 struct netent	*getnetbyaddr_r();
154 struct netent	*getnetent_r();
155 struct protoent	*getprotobyname_r();
156 struct protoent	*getprotobynumber_r();
157 struct protoent	*getprotoent_r();
158 int		 getnetgrent_r();
159 int		 innetgr();
160 
161 /* Old interfaces that return a pointer to a static area;  MT-unsafe */
162 struct hostent	*gethostbyname();
163 struct hostent	*gethostbyaddr();
164 struct hostent	*gethostent();
165 struct netent	*getnetbyname();
166 struct netent	*getnetbyaddr();
167 struct netent	*getnetent();
168 struct servent	*getservbyname();
169 struct servent	*getservbyport();
170 struct servent	*getservent();
171 struct protoent	*getprotobyname();
172 struct protoent	*getprotobynumber();
173 struct protoent	*getprotoent();
174 int		 getnetgrent();
175 
176 int sethostent();
177 int endhostent();
178 int setnetent();
179 int endnetent();
180 int setservent();
181 int endservent();
182 int setprotoent();
183 int endprotoent();
184 int setnetgrent();
185 int endnetgrent();
186 int rcmd();
187 int rexec();
188 int rresvport();
189 int ruserok();
190 #endif
191 
192 /*
193  * Error return codes from gethostbyname() and gethostbyaddr()
194  * (when using the resolver)
195  */
196 
197 extern  int h_errno;
198 
199 #define	HOST_NOT_FOUND	1 /* Authoritive Answer Host not found */
200 #define	TRY_AGAIN	2 /* Non-Authoritive Host not found, or SERVERFAIL */
201 #define	NO_RECOVERY	3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
202 #define	NO_DATA		4 /* Valid name, no data record of requested type */
203 #define	NO_ADDRESS	NO_DATA		/* no address, look for MX record */
204 
205 #define	MAXHOSTNAMELEN	256
206 
207 #define	MAXALIASES	35
208 #define	MAXADDRS	35
209 
210 #ifdef	__cplusplus
211 }
212 #endif
213 
214 #endif	/* _NETDB_H */
215