netdb.h revision 8858
11539Srgrimes/*-
21539Srgrimes * Copyright (c) 1980, 1983, 1988, 1993
31539Srgrimes *	The Regents of the University of California.  All rights reserved.
41539Srgrimes *
51539Srgrimes * Redistribution and use in source and binary forms, with or without
61539Srgrimes * modification, are permitted provided that the following conditions
71539Srgrimes * are met:
81539Srgrimes * 1. Redistributions of source code must retain the above copyright
91539Srgrimes *    notice, this list of conditions and the following disclaimer.
101539Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
111539Srgrimes *    notice, this list of conditions and the following disclaimer in the
121539Srgrimes *    documentation and/or other materials provided with the distribution.
131539Srgrimes * 3. All advertising materials mentioning features or use of this software
141539Srgrimes *    must display the following acknowledgement:
151539Srgrimes *	This product includes software developed by the University of
161539Srgrimes *	California, Berkeley and its contributors.
171539Srgrimes * 4. Neither the name of the University nor the names of its contributors
181539Srgrimes *    may be used to endorse or promote products derived from this software
191539Srgrimes *    without specific prior written permission.
201539Srgrimes *
211539Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
221539Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
231539Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
241539Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
251539Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
261539Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
271539Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
281539Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
291539Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
301539Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
311539Srgrimes * SUCH DAMAGE.
321539Srgrimes *
331539Srgrimes *      @(#)netdb.h	8.1 (Berkeley) 6/2/93
348858Srgrimes *	$Id: netdb.h,v 1.1.1.1 1994/05/24 09:57:18 rgrimes Exp $
351539Srgrimes * -
361539Srgrimes * Portions Copyright (c) 1993 by Digital Equipment Corporation.
378858Srgrimes *
381539Srgrimes * Permission to use, copy, modify, and distribute this software for any
391539Srgrimes * purpose with or without fee is hereby granted, provided that the above
401539Srgrimes * copyright notice and this permission notice appear in all copies, and that
411539Srgrimes * the name of Digital Equipment Corporation not be used in advertising or
421539Srgrimes * publicity pertaining to distribution of the document or software without
431539Srgrimes * specific, written prior permission.
448858Srgrimes *
451539Srgrimes * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
461539Srgrimes * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
471539Srgrimes * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
481539Srgrimes * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
491539Srgrimes * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
501539Srgrimes * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
511539Srgrimes * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
521539Srgrimes * SOFTWARE.
531539Srgrimes * -
541539Srgrimes * --Copyright--
551539Srgrimes */
561539Srgrimes
571539Srgrimes#ifndef _NETDB_H_
581539Srgrimes#define _NETDB_H_
591539Srgrimes
601539Srgrimes#define	_PATH_HEQUIV	"/etc/hosts.equiv"
611539Srgrimes#define	_PATH_HOSTS	"/etc/hosts"
621539Srgrimes#define	_PATH_NETWORKS	"/etc/networks"
631539Srgrimes#define	_PATH_PROTOCOLS	"/etc/protocols"
641539Srgrimes#define	_PATH_SERVICES	"/etc/services"
651539Srgrimes
661539Srgrimes/*
671539Srgrimes * Structures returned by network data base library.  All addresses are
681539Srgrimes * supplied in host order, and returned in network order (suitable for
691539Srgrimes * use in system calls).
701539Srgrimes */
711539Srgrimesstruct	hostent {
721539Srgrimes	char	*h_name;	/* official name of host */
731539Srgrimes	char	**h_aliases;	/* alias list */
741539Srgrimes	int	h_addrtype;	/* host address type */
751539Srgrimes	int	h_length;	/* length of address */
761539Srgrimes	char	**h_addr_list;	/* list of addresses from name server */
771539Srgrimes#define	h_addr	h_addr_list[0]	/* address, for backward compatiblity */
781539Srgrimes};
791539Srgrimes
801539Srgrimes/*
811539Srgrimes * Assumption here is that a network number
821539Srgrimes * fits in an unsigned long -- probably a poor one.
831539Srgrimes */
841539Srgrimesstruct	netent {
851539Srgrimes	char		*n_name;	/* official name of net */
861539Srgrimes	char		**n_aliases;	/* alias list */
871539Srgrimes	int		n_addrtype;	/* net address type */
881539Srgrimes	unsigned long	n_net;		/* network # */
891539Srgrimes};
901539Srgrimes
911539Srgrimesstruct	servent {
921539Srgrimes	char	*s_name;	/* official service name */
931539Srgrimes	char	**s_aliases;	/* alias list */
941539Srgrimes	int	s_port;		/* port # */
951539Srgrimes	char	*s_proto;	/* protocol to use */
961539Srgrimes};
971539Srgrimes
981539Srgrimesstruct	protoent {
991539Srgrimes	char	*p_name;	/* official protocol name */
1001539Srgrimes	char	**p_aliases;	/* alias list */
1011539Srgrimes	int	p_proto;	/* protocol # */
1021539Srgrimes};
1031539Srgrimes
1041539Srgrimes/*
1051539Srgrimes * Error return codes from gethostbyname() and gethostbyaddr()
1061539Srgrimes * (left in extern int h_errno).
1071539Srgrimes */
1081539Srgrimes
1091539Srgrimes#define	HOST_NOT_FOUND	1 /* Authoritative Answer Host not found */
1101539Srgrimes#define	TRY_AGAIN	2 /* Non-Authoritive Host not found, or SERVERFAIL */
1111539Srgrimes#define	NO_RECOVERY	3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
1121539Srgrimes#define	NO_DATA		4 /* Valid name, no data record of requested type */
1131539Srgrimes#define	NO_ADDRESS	NO_DATA		/* no address, look for MX record */
1141539Srgrimes
1151539Srgrimes#include <sys/cdefs.h>
1161539Srgrimes
1171539Srgrimes__BEGIN_DECLS
1181539Srgrimesvoid		endhostent __P((void));
1191539Srgrimesvoid		endnetent __P((void));
1201539Srgrimesvoid		endprotoent __P((void));
1211539Srgrimesvoid		endservent __P((void));
1221539Srgrimesstruct hostent	*gethostbyaddr __P((const char *, int, int));
1231539Srgrimesstruct hostent	*gethostbyname __P((const char *));
1241539Srgrimesstruct hostent	*gethostent __P((void));
1251539Srgrimesstruct netent	*getnetbyaddr __P((long, int)); /* u_long? */
1261539Srgrimesstruct netent	*getnetbyname __P((const char *));
1271539Srgrimesstruct netent	*getnetent __P((void));
1281539Srgrimesstruct protoent	*getprotobyname __P((const char *));
1291539Srgrimesstruct protoent	*getprotobynumber __P((int));
1301539Srgrimesstruct protoent	*getprotoent __P((void));
1311539Srgrimesstruct servent	*getservbyname __P((const char *, const char *));
1321539Srgrimesstruct servent	*getservbyport __P((int, const char *));
1331539Srgrimesstruct servent	*getservent __P((void));
1341539Srgrimesvoid		herror __P((const char *));
1351539Srgrimeschar		*hstrerror __P((int));
1361539Srgrimesvoid		sethostent __P((int));
1371539Srgrimes/* void		sethostfile __P((const char *)); */
1381539Srgrimesvoid		setnetent __P((int));
1391539Srgrimesvoid		setprotoent __P((int));
1401539Srgrimesvoid		setservent __P((int));
1411539Srgrimes__END_DECLS
1421539Srgrimes
1431539Srgrimes#endif /* !_NETDB_H_ */
144