netdb.h revision 50473
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 * - 341539Srgrimes * Portions Copyright (c) 1993 by Digital Equipment Corporation. 358858Srgrimes * 361539Srgrimes * Permission to use, copy, modify, and distribute this software for any 371539Srgrimes * purpose with or without fee is hereby granted, provided that the above 381539Srgrimes * copyright notice and this permission notice appear in all copies, and that 391539Srgrimes * the name of Digital Equipment Corporation not be used in advertising or 401539Srgrimes * publicity pertaining to distribution of the document or software without 411539Srgrimes * specific, written prior permission. 428858Srgrimes * 431539Srgrimes * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL 441539Srgrimes * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES 451539Srgrimes * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT 461539Srgrimes * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 471539Srgrimes * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 481539Srgrimes * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS 491539Srgrimes * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 501539Srgrimes * SOFTWARE. 511539Srgrimes * - 521539Srgrimes * --Copyright-- 531539Srgrimes */ 541539Srgrimes 5536888Speter/* 5636888Speter * @(#)netdb.h 8.1 (Berkeley) 6/2/93 5736888Speter * From: Id: netdb.h,v 8.9 1996/11/19 08:39:29 vixie Exp $ 5850473Speter * $FreeBSD: head/include/netdb.h 50473 1999-08-27 23:45:13Z peter $ 5936888Speter */ 6036888Speter 611539Srgrimes#ifndef _NETDB_H_ 621539Srgrimes#define _NETDB_H_ 631539Srgrimes 6421055Speter#include <sys/cdefs.h> 6521055Speter 6636888Speter#ifndef _PATH_HEQUIV 6736888Speter# define _PATH_HEQUIV "/etc/hosts.equiv" 6836888Speter#endif 691539Srgrimes#define _PATH_HOSTS "/etc/hosts" 701539Srgrimes#define _PATH_NETWORKS "/etc/networks" 711539Srgrimes#define _PATH_PROTOCOLS "/etc/protocols" 721539Srgrimes#define _PATH_SERVICES "/etc/services" 731539Srgrimes 7410132Speterextern int h_errno; 7510132Speter 761539Srgrimes/* 771539Srgrimes * Structures returned by network data base library. All addresses are 781539Srgrimes * supplied in host order, and returned in network order (suitable for 791539Srgrimes * use in system calls). 801539Srgrimes */ 811539Srgrimesstruct hostent { 821539Srgrimes char *h_name; /* official name of host */ 831539Srgrimes char **h_aliases; /* alias list */ 841539Srgrimes int h_addrtype; /* host address type */ 851539Srgrimes int h_length; /* length of address */ 861539Srgrimes char **h_addr_list; /* list of addresses from name server */ 8713771Smpp#define h_addr h_addr_list[0] /* address, for backward compatibility */ 881539Srgrimes}; 891539Srgrimes 901539Srgrimes/* 911539Srgrimes * Assumption here is that a network number 921539Srgrimes * fits in an unsigned long -- probably a poor one. 931539Srgrimes */ 941539Srgrimesstruct netent { 951539Srgrimes char *n_name; /* official name of net */ 961539Srgrimes char **n_aliases; /* alias list */ 971539Srgrimes int n_addrtype; /* net address type */ 981539Srgrimes unsigned long n_net; /* network # */ 991539Srgrimes}; 1001539Srgrimes 1011539Srgrimesstruct servent { 1021539Srgrimes char *s_name; /* official service name */ 1031539Srgrimes char **s_aliases; /* alias list */ 1041539Srgrimes int s_port; /* port # */ 1051539Srgrimes char *s_proto; /* protocol to use */ 1061539Srgrimes}; 1071539Srgrimes 1081539Srgrimesstruct protoent { 1091539Srgrimes char *p_name; /* official protocol name */ 1101539Srgrimes char **p_aliases; /* alias list */ 1111539Srgrimes int p_proto; /* protocol # */ 1121539Srgrimes}; 1131539Srgrimes 1141539Srgrimes/* 1151539Srgrimes * Error return codes from gethostbyname() and gethostbyaddr() 1161539Srgrimes * (left in extern int h_errno). 1171539Srgrimes */ 1181539Srgrimes 11910132Speter#define NETDB_INTERNAL -1 /* see errno */ 12010132Speter#define NETDB_SUCCESS 0 /* no problem */ 1211539Srgrimes#define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found */ 12213771Smpp#define TRY_AGAIN 2 /* Non-Authoritative Host not found, or SERVERFAIL */ 1231539Srgrimes#define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */ 1241539Srgrimes#define NO_DATA 4 /* Valid name, no data record of requested type */ 1251539Srgrimes#define NO_ADDRESS NO_DATA /* no address, look for MX record */ 1261539Srgrimes 1271539Srgrimes__BEGIN_DECLS 1281539Srgrimesvoid endhostent __P((void)); 1291539Srgrimesvoid endnetent __P((void)); 1301539Srgrimesvoid endprotoent __P((void)); 1311539Srgrimesvoid endservent __P((void)); 1321539Srgrimesstruct hostent *gethostbyaddr __P((const char *, int, int)); 1331539Srgrimesstruct hostent *gethostbyname __P((const char *)); 13417902Speterstruct hostent *gethostbyname2 __P((const char *, int)); 1351539Srgrimesstruct hostent *gethostent __P((void)); 13621055Speterstruct netent *getnetbyaddr __P((unsigned long, int)); 1371539Srgrimesstruct netent *getnetbyname __P((const char *)); 1381539Srgrimesstruct netent *getnetent __P((void)); 1391539Srgrimesstruct protoent *getprotobyname __P((const char *)); 1401539Srgrimesstruct protoent *getprotobynumber __P((int)); 1411539Srgrimesstruct protoent *getprotoent __P((void)); 1421539Srgrimesstruct servent *getservbyname __P((const char *, const char *)); 1431539Srgrimesstruct servent *getservbyport __P((int, const char *)); 1441539Srgrimesstruct servent *getservent __P((void)); 1451539Srgrimesvoid herror __P((const char *)); 14628271Ssteve__const char *hstrerror __P((int)); 1471539Srgrimesvoid sethostent __P((int)); 1481539Srgrimes/* void sethostfile __P((const char *)); */ 1491539Srgrimesvoid setnetent __P((int)); 1501539Srgrimesvoid setprotoent __P((int)); 1511539Srgrimesvoid setservent __P((int)); 15217902Speter 15317902Speter/* 15417902Speter * PRIVATE functions specific to the FreeBSD implementation 15517902Speter */ 15617902Speter 15717902Speter/* DO NOT USE THESE, THEY ARE SUBJECT TO CHANGE AND ARE NOT PORTABLE!!! */ 15817902Spetervoid _sethosthtent __P((int)); 15917902Spetervoid _endhosthtent __P((void)); 16017902Spetervoid _sethostdnsent __P((int)); 16117902Spetervoid _endhostdnsent __P((void)); 16217902Spetervoid _setnethtent __P((int)); 16317902Spetervoid _endnethtent __P((void)); 16417902Spetervoid _setnetdnsent __P((int)); 16517902Spetervoid _endnetdnsent __P((void)); 16617902Speterstruct hostent * _gethostbyhtname __P((const char *, int)); 16717902Speterstruct hostent * _gethostbydnsname __P((const char *, int)); 16817902Speterstruct hostent * _gethostbynisname __P((const char *, int)); 16917902Speterstruct hostent * _gethostbyhtaddr __P((const char *, int, int)); 17017902Speterstruct hostent * _gethostbydnsaddr __P((const char *, int, int)); 17117902Speterstruct hostent * _gethostbynisaddr __P((const char *, int, int)); 17217902Speterstruct netent * _getnetbyhtname __P((const char *)); 17317902Speterstruct netent * _getnetbydnsname __P((const char *)); 17417902Speterstruct netent * _getnetbynisname __P((const char *)); 17517902Speterstruct netent * _getnetbyhtaddr __P((unsigned long, int)); 17617902Speterstruct netent * _getnetbydnsaddr __P((unsigned long, int)); 17717902Speterstruct netent * _getnetbynisaddr __P((unsigned long, int)); 17817902Spetervoid _map_v4v6_address __P((const char *src, char *dst)); 17917902Spetervoid _map_v4v6_hostent __P((struct hostent *hp, char **bp, int *len)); 1801539Srgrimes__END_DECLS 1811539Srgrimes 1821539Srgrimes#endif /* !_NETDB_H_ */ 183