xref: /freebsd/include/netdb.h (revision d58a9efd01c363186b7eed0e75a0bf074856bec8)
159deaec5SRodney W. Grimes /*-
259deaec5SRodney W. Grimes  * Copyright (c) 1980, 1983, 1988, 1993
359deaec5SRodney W. Grimes  *	The Regents of the University of California.  All rights reserved.
459deaec5SRodney W. Grimes  *
559deaec5SRodney W. Grimes  * Redistribution and use in source and binary forms, with or without
659deaec5SRodney W. Grimes  * modification, are permitted provided that the following conditions
759deaec5SRodney W. Grimes  * are met:
859deaec5SRodney W. Grimes  * 1. Redistributions of source code must retain the above copyright
959deaec5SRodney W. Grimes  *    notice, this list of conditions and the following disclaimer.
1059deaec5SRodney W. Grimes  * 2. Redistributions in binary form must reproduce the above copyright
1159deaec5SRodney W. Grimes  *    notice, this list of conditions and the following disclaimer in the
1259deaec5SRodney W. Grimes  *    documentation and/or other materials provided with the distribution.
1359deaec5SRodney W. Grimes  * 3. All advertising materials mentioning features or use of this software
1459deaec5SRodney W. Grimes  *    must display the following acknowledgement:
1559deaec5SRodney W. Grimes  *	This product includes software developed by the University of
1659deaec5SRodney W. Grimes  *	California, Berkeley and its contributors.
1759deaec5SRodney W. Grimes  * 4. Neither the name of the University nor the names of its contributors
1859deaec5SRodney W. Grimes  *    may be used to endorse or promote products derived from this software
1959deaec5SRodney W. Grimes  *    without specific prior written permission.
2059deaec5SRodney W. Grimes  *
2159deaec5SRodney W. Grimes  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2259deaec5SRodney W. Grimes  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2359deaec5SRodney W. Grimes  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2459deaec5SRodney W. Grimes  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2559deaec5SRodney W. Grimes  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2659deaec5SRodney W. Grimes  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2759deaec5SRodney W. Grimes  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2859deaec5SRodney W. Grimes  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2959deaec5SRodney W. Grimes  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3059deaec5SRodney W. Grimes  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3159deaec5SRodney W. Grimes  * SUCH DAMAGE.
3259deaec5SRodney W. Grimes  *
3359deaec5SRodney W. Grimes  *      @(#)netdb.h	8.1 (Berkeley) 6/2/93
34d58a9efdSPeter Wemm  *	$Id: netdb.h,v 1.2 1995/05/30 04:54:41 rgrimes Exp $
3559deaec5SRodney W. Grimes  * -
3659deaec5SRodney W. Grimes  * Portions Copyright (c) 1993 by Digital Equipment Corporation.
3759deaec5SRodney W. Grimes  *
3859deaec5SRodney W. Grimes  * Permission to use, copy, modify, and distribute this software for any
3959deaec5SRodney W. Grimes  * purpose with or without fee is hereby granted, provided that the above
4059deaec5SRodney W. Grimes  * copyright notice and this permission notice appear in all copies, and that
4159deaec5SRodney W. Grimes  * the name of Digital Equipment Corporation not be used in advertising or
4259deaec5SRodney W. Grimes  * publicity pertaining to distribution of the document or software without
4359deaec5SRodney W. Grimes  * specific, written prior permission.
4459deaec5SRodney W. Grimes  *
4559deaec5SRodney W. Grimes  * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
4659deaec5SRodney W. Grimes  * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
4759deaec5SRodney W. Grimes  * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
4859deaec5SRodney W. Grimes  * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
4959deaec5SRodney W. Grimes  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
5059deaec5SRodney W. Grimes  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
5159deaec5SRodney W. Grimes  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
5259deaec5SRodney W. Grimes  * SOFTWARE.
5359deaec5SRodney W. Grimes  * -
5459deaec5SRodney W. Grimes  * --Copyright--
5559deaec5SRodney W. Grimes  */
5659deaec5SRodney W. Grimes 
5759deaec5SRodney W. Grimes #ifndef _NETDB_H_
5859deaec5SRodney W. Grimes #define _NETDB_H_
5959deaec5SRodney W. Grimes 
6059deaec5SRodney W. Grimes #define	_PATH_HEQUIV	"/etc/hosts.equiv"
6159deaec5SRodney W. Grimes #define	_PATH_HOSTS	"/etc/hosts"
6259deaec5SRodney W. Grimes #define	_PATH_NETWORKS	"/etc/networks"
6359deaec5SRodney W. Grimes #define	_PATH_PROTOCOLS	"/etc/protocols"
6459deaec5SRodney W. Grimes #define	_PATH_SERVICES	"/etc/services"
6559deaec5SRodney W. Grimes 
66d58a9efdSPeter Wemm extern int h_errno;
67d58a9efdSPeter Wemm 
6859deaec5SRodney W. Grimes /*
6959deaec5SRodney W. Grimes  * Structures returned by network data base library.  All addresses are
7059deaec5SRodney W. Grimes  * supplied in host order, and returned in network order (suitable for
7159deaec5SRodney W. Grimes  * use in system calls).
7259deaec5SRodney W. Grimes  */
7359deaec5SRodney W. Grimes struct	hostent {
7459deaec5SRodney W. Grimes 	char	*h_name;	/* official name of host */
7559deaec5SRodney W. Grimes 	char	**h_aliases;	/* alias list */
7659deaec5SRodney W. Grimes 	int	h_addrtype;	/* host address type */
7759deaec5SRodney W. Grimes 	int	h_length;	/* length of address */
7859deaec5SRodney W. Grimes 	char	**h_addr_list;	/* list of addresses from name server */
7959deaec5SRodney W. Grimes #define	h_addr	h_addr_list[0]	/* address, for backward compatiblity */
8059deaec5SRodney W. Grimes };
8159deaec5SRodney W. Grimes 
8259deaec5SRodney W. Grimes /*
8359deaec5SRodney W. Grimes  * Assumption here is that a network number
8459deaec5SRodney W. Grimes  * fits in an unsigned long -- probably a poor one.
8559deaec5SRodney W. Grimes  */
8659deaec5SRodney W. Grimes struct	netent {
8759deaec5SRodney W. Grimes 	char		*n_name;	/* official name of net */
8859deaec5SRodney W. Grimes 	char		**n_aliases;	/* alias list */
8959deaec5SRodney W. Grimes 	int		n_addrtype;	/* net address type */
9059deaec5SRodney W. Grimes 	unsigned long	n_net;		/* network # */
9159deaec5SRodney W. Grimes };
9259deaec5SRodney W. Grimes 
9359deaec5SRodney W. Grimes struct	servent {
9459deaec5SRodney W. Grimes 	char	*s_name;	/* official service name */
9559deaec5SRodney W. Grimes 	char	**s_aliases;	/* alias list */
9659deaec5SRodney W. Grimes 	int	s_port;		/* port # */
9759deaec5SRodney W. Grimes 	char	*s_proto;	/* protocol to use */
9859deaec5SRodney W. Grimes };
9959deaec5SRodney W. Grimes 
10059deaec5SRodney W. Grimes struct	protoent {
10159deaec5SRodney W. Grimes 	char	*p_name;	/* official protocol name */
10259deaec5SRodney W. Grimes 	char	**p_aliases;	/* alias list */
10359deaec5SRodney W. Grimes 	int	p_proto;	/* protocol # */
10459deaec5SRodney W. Grimes };
10559deaec5SRodney W. Grimes 
10659deaec5SRodney W. Grimes /*
10759deaec5SRodney W. Grimes  * Error return codes from gethostbyname() and gethostbyaddr()
10859deaec5SRodney W. Grimes  * (left in extern int h_errno).
10959deaec5SRodney W. Grimes  */
11059deaec5SRodney W. Grimes 
111d58a9efdSPeter Wemm #define	NETDB_INTERNAL	-1	/* see errno */
112d58a9efdSPeter Wemm #define	NETDB_SUCCESS	0	/* no problem */
11359deaec5SRodney W. Grimes #define	HOST_NOT_FOUND	1 /* Authoritative Answer Host not found */
11459deaec5SRodney W. Grimes #define	TRY_AGAIN	2 /* Non-Authoritive Host not found, or SERVERFAIL */
11559deaec5SRodney W. Grimes #define	NO_RECOVERY	3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
11659deaec5SRodney W. Grimes #define	NO_DATA		4 /* Valid name, no data record of requested type */
11759deaec5SRodney W. Grimes #define	NO_ADDRESS	NO_DATA		/* no address, look for MX record */
11859deaec5SRodney W. Grimes 
11959deaec5SRodney W. Grimes #include <sys/cdefs.h>
12059deaec5SRodney W. Grimes 
12159deaec5SRodney W. Grimes __BEGIN_DECLS
12259deaec5SRodney W. Grimes void		endhostent __P((void));
12359deaec5SRodney W. Grimes void		endnetent __P((void));
12459deaec5SRodney W. Grimes void		endprotoent __P((void));
12559deaec5SRodney W. Grimes void		endservent __P((void));
12659deaec5SRodney W. Grimes struct hostent	*gethostbyaddr __P((const char *, int, int));
12759deaec5SRodney W. Grimes struct hostent	*gethostbyname __P((const char *));
12859deaec5SRodney W. Grimes struct hostent	*gethostent __P((void));
12959deaec5SRodney W. Grimes struct netent	*getnetbyaddr __P((long, int)); /* u_long? */
13059deaec5SRodney W. Grimes struct netent	*getnetbyname __P((const char *));
13159deaec5SRodney W. Grimes struct netent	*getnetent __P((void));
13259deaec5SRodney W. Grimes struct protoent	*getprotobyname __P((const char *));
13359deaec5SRodney W. Grimes struct protoent	*getprotobynumber __P((int));
13459deaec5SRodney W. Grimes struct protoent	*getprotoent __P((void));
13559deaec5SRodney W. Grimes struct servent	*getservbyname __P((const char *, const char *));
13659deaec5SRodney W. Grimes struct servent	*getservbyport __P((int, const char *));
13759deaec5SRodney W. Grimes struct servent	*getservent __P((void));
13859deaec5SRodney W. Grimes void		herror __P((const char *));
139d58a9efdSPeter Wemm const char	*hstrerror __P((int));
14059deaec5SRodney W. Grimes void		sethostent __P((int));
14159deaec5SRodney W. Grimes /* void		sethostfile __P((const char *)); */
14259deaec5SRodney W. Grimes void		setnetent __P((int));
14359deaec5SRodney W. Grimes void		setprotoent __P((int));
14459deaec5SRodney W. Grimes void		setservent __P((int));
14559deaec5SRodney W. Grimes __END_DECLS
14659deaec5SRodney W. Grimes 
14759deaec5SRodney W. Grimes #endif /* !_NETDB_H_ */
148