netdb.h revision 28271
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
3426975Speter *      From: Id: netdb.h,v 8.8 1997/06/01 20:34:32 vixie Exp
3528271Ssteve *	$Id: netdb.h,v 1.9 1997/06/27 08:32:37 peter Exp $
361539Srgrimes * -
371539Srgrimes * Portions Copyright (c) 1993 by Digital Equipment Corporation.
388858Srgrimes *
391539Srgrimes * Permission to use, copy, modify, and distribute this software for any
401539Srgrimes * purpose with or without fee is hereby granted, provided that the above
411539Srgrimes * copyright notice and this permission notice appear in all copies, and that
421539Srgrimes * the name of Digital Equipment Corporation not be used in advertising or
431539Srgrimes * publicity pertaining to distribution of the document or software without
441539Srgrimes * specific, written prior permission.
458858Srgrimes *
461539Srgrimes * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
471539Srgrimes * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
481539Srgrimes * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
491539Srgrimes * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
501539Srgrimes * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
511539Srgrimes * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
521539Srgrimes * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
531539Srgrimes * SOFTWARE.
541539Srgrimes * -
551539Srgrimes * --Copyright--
561539Srgrimes */
571539Srgrimes
581539Srgrimes#ifndef _NETDB_H_
591539Srgrimes#define _NETDB_H_
601539Srgrimes
6121055Speter#include <sys/cdefs.h>
6221055Speter
631539Srgrimes#define	_PATH_HEQUIV	"/etc/hosts.equiv"
641539Srgrimes#define	_PATH_HOSTS	"/etc/hosts"
651539Srgrimes#define	_PATH_NETWORKS	"/etc/networks"
661539Srgrimes#define	_PATH_PROTOCOLS	"/etc/protocols"
671539Srgrimes#define	_PATH_SERVICES	"/etc/services"
681539Srgrimes
6910132Speterextern int h_errno;
7010132Speter
711539Srgrimes/*
721539Srgrimes * Structures returned by network data base library.  All addresses are
731539Srgrimes * supplied in host order, and returned in network order (suitable for
741539Srgrimes * use in system calls).
751539Srgrimes */
761539Srgrimesstruct	hostent {
771539Srgrimes	char	*h_name;	/* official name of host */
781539Srgrimes	char	**h_aliases;	/* alias list */
791539Srgrimes	int	h_addrtype;	/* host address type */
801539Srgrimes	int	h_length;	/* length of address */
811539Srgrimes	char	**h_addr_list;	/* list of addresses from name server */
8213771Smpp#define	h_addr	h_addr_list[0]	/* address, for backward compatibility */
831539Srgrimes};
841539Srgrimes
851539Srgrimes/*
861539Srgrimes * Assumption here is that a network number
871539Srgrimes * fits in an unsigned long -- probably a poor one.
881539Srgrimes */
891539Srgrimesstruct	netent {
901539Srgrimes	char		*n_name;	/* official name of net */
911539Srgrimes	char		**n_aliases;	/* alias list */
921539Srgrimes	int		n_addrtype;	/* net address type */
931539Srgrimes	unsigned long	n_net;		/* network # */
941539Srgrimes};
951539Srgrimes
961539Srgrimesstruct	servent {
971539Srgrimes	char	*s_name;	/* official service name */
981539Srgrimes	char	**s_aliases;	/* alias list */
991539Srgrimes	int	s_port;		/* port # */
1001539Srgrimes	char	*s_proto;	/* protocol to use */
1011539Srgrimes};
1021539Srgrimes
1031539Srgrimesstruct	protoent {
1041539Srgrimes	char	*p_name;	/* official protocol name */
1051539Srgrimes	char	**p_aliases;	/* alias list */
1061539Srgrimes	int	p_proto;	/* protocol # */
1071539Srgrimes};
1081539Srgrimes
1091539Srgrimes/*
1101539Srgrimes * Error return codes from gethostbyname() and gethostbyaddr()
1111539Srgrimes * (left in extern int h_errno).
1121539Srgrimes */
1131539Srgrimes
11410132Speter#define	NETDB_INTERNAL	-1	/* see errno */
11510132Speter#define	NETDB_SUCCESS	0	/* no problem */
1161539Srgrimes#define	HOST_NOT_FOUND	1 /* Authoritative Answer Host not found */
11713771Smpp#define	TRY_AGAIN	2 /* Non-Authoritative Host not found, or SERVERFAIL */
1181539Srgrimes#define	NO_RECOVERY	3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
1191539Srgrimes#define	NO_DATA		4 /* Valid name, no data record of requested type */
1201539Srgrimes#define	NO_ADDRESS	NO_DATA		/* no address, look for MX record */
1211539Srgrimes
1221539Srgrimes__BEGIN_DECLS
1231539Srgrimesvoid		endhostent __P((void));
1241539Srgrimesvoid		endnetent __P((void));
1251539Srgrimesvoid		endprotoent __P((void));
1261539Srgrimesvoid		endservent __P((void));
1271539Srgrimesstruct hostent	*gethostbyaddr __P((const char *, int, int));
1281539Srgrimesstruct hostent	*gethostbyname __P((const char *));
12917902Speterstruct hostent	*gethostbyname2 __P((const char *, int));
1301539Srgrimesstruct hostent	*gethostent __P((void));
13121055Speterstruct netent	*getnetbyaddr __P((unsigned long, int));
1321539Srgrimesstruct netent	*getnetbyname __P((const char *));
1331539Srgrimesstruct netent	*getnetent __P((void));
1341539Srgrimesstruct protoent	*getprotobyname __P((const char *));
1351539Srgrimesstruct protoent	*getprotobynumber __P((int));
1361539Srgrimesstruct protoent	*getprotoent __P((void));
1371539Srgrimesstruct servent	*getservbyname __P((const char *, const char *));
1381539Srgrimesstruct servent	*getservbyport __P((int, const char *));
1391539Srgrimesstruct servent	*getservent __P((void));
1401539Srgrimesvoid		herror __P((const char *));
14128271Ssteve__const char	*hstrerror __P((int));
1421539Srgrimesvoid		sethostent __P((int));
1431539Srgrimes/* void		sethostfile __P((const char *)); */
1441539Srgrimesvoid		setnetent __P((int));
1451539Srgrimesvoid		setprotoent __P((int));
1461539Srgrimesvoid		setservent __P((int));
14717902Speter
14817902Speter/*
14917902Speter * PRIVATE functions specific to the FreeBSD implementation
15017902Speter */
15117902Speter
15217902Speter/* DO NOT USE THESE, THEY ARE SUBJECT TO CHANGE AND ARE NOT PORTABLE!!! */
15317902Spetervoid	_sethosthtent __P((int));
15417902Spetervoid	_endhosthtent __P((void));
15517902Spetervoid	_sethostdnsent __P((int));
15617902Spetervoid	_endhostdnsent __P((void));
15717902Spetervoid	_setnethtent __P((int));
15817902Spetervoid	_endnethtent __P((void));
15917902Spetervoid	_setnetdnsent __P((int));
16017902Spetervoid	_endnetdnsent __P((void));
16117902Speterstruct hostent * _gethostbyhtname  __P((const char *, int));
16217902Speterstruct hostent * _gethostbydnsname __P((const char *, int));
16317902Speterstruct hostent * _gethostbynisname __P((const char *, int));
16417902Speterstruct hostent * _gethostbyhtaddr  __P((const char *, int, int));
16517902Speterstruct hostent * _gethostbydnsaddr __P((const char *, int, int));
16617902Speterstruct hostent * _gethostbynisaddr __P((const char *, int, int));
16717902Speterstruct netent *  _getnetbyhtname  __P((const char *));
16817902Speterstruct netent *  _getnetbydnsname __P((const char *));
16917902Speterstruct netent *  _getnetbynisname __P((const char *));
17017902Speterstruct netent *  _getnetbyhtaddr  __P((unsigned long, int));
17117902Speterstruct netent *  _getnetbydnsaddr __P((unsigned long, int));
17217902Speterstruct netent *  _getnetbynisaddr __P((unsigned long, int));
17317902Spetervoid _map_v4v6_address __P((const char *src, char *dst));
17417902Spetervoid _map_v4v6_hostent __P((struct hostent *hp, char **bp, int *len));
1751539Srgrimes__END_DECLS
1761539Srgrimes
1771539Srgrimes#endif /* !_NETDB_H_ */
178