xref: /csrg-svn/include/netdb.h (revision 61068)
142267Sbostic /*-
2*61068Sbostic  * Copyright (c) 1980, 1983, 1988, 1993
3*61068Sbostic  *	The Regents of the University of California.  All rights reserved.
423533Smckusick  *
542267Sbostic  * %sccs.include.redist.c%
633940Skarels  *
7*61068Sbostic  *      @(#)netdb.h	8.1 (Berkeley) 06/02/93
861025Skarels  *	$Id: netdb.h,v 4.9.1.2 1993/05/17 09:59:01 vixie Exp $
961025Skarels  * -
1061025Skarels  * Portions Copyright (c) 1993 by Digital Equipment Corporation.
1161025Skarels  *
1261025Skarels  * Permission to use, copy, modify, and distribute this software for any
1361025Skarels  * purpose with or without fee is hereby granted, provided that the above
1461025Skarels  * copyright notice and this permission notice appear in all copies, and that
1561025Skarels  * the name of Digital Equipment Corporation not be used in advertising or
1661025Skarels  * publicity pertaining to distribution of the document or software without
1761025Skarels  * specific, written prior permission.
1861025Skarels  *
1961025Skarels  * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
2061025Skarels  * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
2161025Skarels  * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
2261025Skarels  * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
2361025Skarels  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
2461025Skarels  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
2561025Skarels  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
2661025Skarels  * SOFTWARE.
2761025Skarels  * -
2861025Skarels  * --Copyright--
2923533Smckusick  */
3023533Smckusick 
3147773Sbostic #ifndef _NETDB_H_
3247773Sbostic #define _NETDB_H_
3347773Sbostic 
3442267Sbostic #define	_PATH_HEQUIV	"/etc/hosts.equiv"
3542267Sbostic #define	_PATH_HOSTS	"/etc/hosts"
3642267Sbostic #define	_PATH_NETWORKS	"/etc/networks"
3742267Sbostic #define	_PATH_PROTOCOLS	"/etc/protocols"
3842267Sbostic #define	_PATH_SERVICES	"/etc/services"
3942267Sbostic 
4023533Smckusick /*
4142267Sbostic  * Structures returned by network data base library.  All addresses are
4242267Sbostic  * supplied in host order, and returned in network order (suitable for
4342267Sbostic  * use in system calls).
448308Ssam  */
458308Ssam struct	hostent {
468308Ssam 	char	*h_name;	/* official name of host */
478308Ssam 	char	**h_aliases;	/* alias list */
488308Ssam 	int	h_addrtype;	/* host address type */
498308Ssam 	int	h_length;	/* length of address */
5042267Sbostic 	char	**h_addr_list;	/* list of addresses from name server */
5142267Sbostic #define	h_addr	h_addr_list[0]	/* address, for backward compatiblity */
528308Ssam };
538308Ssam 
548308Ssam /*
558308Ssam  * Assumption here is that a network number
5661025Skarels  * fits in an unsigned long -- probably a poor one.
578308Ssam  */
588308Ssam struct	netent {
5927927Slepreau 	char		*n_name;	/* official name of net */
6027927Slepreau 	char		**n_aliases;	/* alias list */
6127927Slepreau 	int		n_addrtype;	/* net address type */
6227927Slepreau 	unsigned long	n_net;		/* network # */
638308Ssam };
648308Ssam 
658308Ssam struct	servent {
668308Ssam 	char	*s_name;	/* official service name */
678308Ssam 	char	**s_aliases;	/* alias list */
688308Ssam 	int	s_port;		/* port # */
698308Ssam 	char	*s_proto;	/* protocol to use */
708308Ssam };
718308Ssam 
728308Ssam struct	protoent {
738308Ssam 	char	*p_name;	/* official protocol name */
748308Ssam 	char	**p_aliases;	/* alias list */
758308Ssam 	int	p_proto;	/* protocol # */
768308Ssam };
778308Ssam 
7825399Skjd /*
7925399Skjd  * Error return codes from gethostbyname() and gethostbyaddr()
8033940Skarels  * (left in extern int h_errno).
8125399Skjd  */
8225399Skjd 
8333940Skarels #define	HOST_NOT_FOUND	1 /* Authoritative Answer Host not found */
8425399Skjd #define	TRY_AGAIN	2 /* Non-Authoritive Host not found, or SERVERFAIL */
8525399Skjd #define	NO_RECOVERY	3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
8633940Skarels #define	NO_DATA		4 /* Valid name, no data record of requested type */
8733940Skarels #define	NO_ADDRESS	NO_DATA		/* no address, look for MX record */
8846515Sdonn 
8946515Sdonn #include <sys/cdefs.h>
9046515Sdonn 
9146515Sdonn __BEGIN_DECLS
9246515Sdonn void		endhostent __P((void));
9346515Sdonn void		endnetent __P((void));
9446515Sdonn void		endprotoent __P((void));
9546515Sdonn void		endservent __P((void));
9646620Sbostic struct hostent	*gethostbyaddr __P((const char *, int, int));
9753070Sbostic struct hostent	*gethostbyname __P((const char *));
9861025Skarels struct hostent	*gethostent __P((void));
9946515Sdonn struct netent	*getnetbyaddr __P((long, int)); /* u_long? */
10046515Sdonn struct netent	*getnetbyname __P((const char *));
10146515Sdonn struct netent	*getnetent __P((void));
10246515Sdonn struct protoent	*getprotobyname __P((const char *));
10346515Sdonn struct protoent	*getprotobynumber __P((int));
10446515Sdonn struct protoent	*getprotoent __P((void));
10546515Sdonn struct servent	*getservbyname __P((const char *, const char *));
10646515Sdonn struct servent	*getservbyport __P((int, const char *));
10746515Sdonn struct servent	*getservent __P((void));
10846515Sdonn void		herror __P((const char *));
10961025Skarels char		*hstrerror __P((int));
11046515Sdonn void		sethostent __P((int));
11146515Sdonn /* void		sethostfile __P((const char *)); */
11246515Sdonn void		setnetent __P((int));
11346515Sdonn void		setprotoent __P((int));
11446515Sdonn void		setservent __P((int));
11546515Sdonn __END_DECLS
11647773Sbostic 
11747773Sbostic #endif /* !_NETDB_H_ */
118