xref: /titanic_50/usr/src/lib/libresolv/netdb.h (revision 54925bf60766fbb4f1f2d7c843721406a7b7a3fb)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
45 
46 #ifdef	__cplusplus
47 extern "C" {
48 #endif
49 
50 #define	_PATH_HEQUIV	"/etc/hosts.equiv"
51 #define	_PATH_HOSTS	"/etc/hosts"
52 #define	_PATH_NETWORKS	"/etc/networks"
53 #define	_PATH_PROTOCOLS	"/etc/protocols"
54 #define	_PATH_SERVICES	"/etc/services"
55 
56 struct	hostent {
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 */
63 };
64 
65 /*
66  * Assumption here is that a network number
67  * fits in 32 bits -- probably a poor one.
68  */
69 struct	netent {
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 # */
74 };
75 
76 struct	servent {
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 */
81 };
82 
83 struct	protoent {
84 	char	*p_name;	/* official protocol name */
85 	char	**p_aliases;	/* alias list */
86 	int	p_proto;	/* protocol # */
87 };
88 
89 #ifdef	__STDC__
90 struct hostent	*gethostbyname_r
91 	(const char *,		 struct hostent *, char *, int, int *h_errnop);
92 struct hostent	*gethostbyaddr_r
93 	(const char *, int, int, struct hostent *, char *, int, int *h_errnop);
94 struct hostent	*gethostent_r(struct hostent *, char *, int, int *h_errnop);
95 
96 struct servent	*getservbyname_r
97 	(const char *name, const char *, struct servent *, char *, int);
98 struct servent	*getservbyport_r
99 	(int port,	   const char *, struct servent *, char *, int);
100 struct servent	*getservent_r(struct	servent *, char *, int);
101 
102 struct netent	*getnetbyname_r
103 	(const char *, struct netent *, char *, int);
104 struct netent	*getnetbyaddr_r(long, int, struct netent *, char *, int);
105 struct netent	*getnetent_r(struct netent *, char *, int);
106 
107 struct protoent	*getprotobyname_r
108 	(const char *, struct protoent *, char *, int);
109 struct protoent	*getprotobynumber_r
110 	(int, struct protoent *, char *, int);
111 struct protoent	*getprotoent_r(struct protoent *, char *, int);
112 
113 int getnetgrent_r(char **, char **, char **, char *, int);
114 int innetgr(const char *, const char *, const char *, const char *);
115 
116 /* Old interfaces that return a pointer to a static area;  MT-unsafe */
117 struct hostent	*gethostbyname(const char *);
118 struct hostent	*gethostbyaddr(const char *, int, int);
119 struct hostent	*gethostent(void);
120 struct netent	*getnetbyname(const char *);
121 struct netent	*getnetbyaddr(long, int);
122 struct netent	*getnetent(void);
123 struct servent	*getservbyname(const char *, const char *);
124 struct servent	*getservbyport(int, const char *);
125 struct servent	*getservent(void);
126 struct protoent	*getprotobyname(const char *);
127 struct protoent	*getprotobynumber(int);
128 struct protoent	*getprotoent(void);
129 int		 getnetgrent(char **, char **, char **);
130 
131 int sethostent(int);
132 int endhostent(void);
133 int setnetent(int);
134 int endnetent(void);
135 int setservent(int);
136 int endservent(void);
137 int setprotoent(int);
138 int endprotoent(void);
139 int setnetgrent(const char *);
140 int endnetgrent(void);
141 int rcmd(char **ahost, unsigned short inport,
142 	const char *luser, const char *ruser, const char *cmd, int *fd2p);
143 int rexec(char **ahost, unsigned short inport,
144 	const char *user, const char *passwd, const char *cmd, int *fd2p);
145 int rresvport(int *);
146 int ruserok(const char *rhost, int suser, const char *ruser, const char *luser);
147 #else
148 struct hostent	*gethostbyname_r();
149 struct hostent	*gethostbyaddr_r();
150 struct hostent	*gethostent_r();
151 struct servent	*getservbyname_r();
152 struct servent	*getservbyport_r();
153 struct servent	*getservent_r();
154 struct netent	*getnetbyname_r();
155 struct netent	*getnetbyaddr_r();
156 struct netent	*getnetent_r();
157 struct protoent	*getprotobyname_r();
158 struct protoent	*getprotobynumber_r();
159 struct protoent	*getprotoent_r();
160 int		 getnetgrent_r();
161 int		 innetgr();
162 
163 /* Old interfaces that return a pointer to a static area;  MT-unsafe */
164 struct hostent	*gethostbyname();
165 struct hostent	*gethostbyaddr();
166 struct hostent	*gethostent();
167 struct netent	*getnetbyname();
168 struct netent	*getnetbyaddr();
169 struct netent	*getnetent();
170 struct servent	*getservbyname();
171 struct servent	*getservbyport();
172 struct servent	*getservent();
173 struct protoent	*getprotobyname();
174 struct protoent	*getprotobynumber();
175 struct protoent	*getprotoent();
176 int		 getnetgrent();
177 
178 int sethostent();
179 int endhostent();
180 int setnetent();
181 int endnetent();
182 int setservent();
183 int endservent();
184 int setprotoent();
185 int endprotoent();
186 int setnetgrent();
187 int endnetgrent();
188 int rcmd();
189 int rexec();
190 int rresvport();
191 int ruserok();
192 #endif
193 
194 /*
195  * Error return codes from gethostbyname() and gethostbyaddr()
196  * (when using the resolver)
197  */
198 
199 extern  int h_errno;
200 
201 #define	HOST_NOT_FOUND	1 /* Authoritive Answer Host not found */
202 #define	TRY_AGAIN	2 /* Non-Authoritive Host not found, or SERVERFAIL */
203 #define	NO_RECOVERY	3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
204 #define	NO_DATA		4 /* Valid name, no data record of requested type */
205 #define	NO_ADDRESS	NO_DATA		/* no address, look for MX record */
206 
207 #define	MAXHOSTNAMELEN	256
208 
209 #define	MAXALIASES	35
210 #define	MAXADDRS	35
211 
212 #ifdef	__cplusplus
213 }
214 #endif
215 
216 #endif	/* _NETDB_H */
217