netdb.h revision 17902
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 3417902Speter * $Id: netdb.h,v 1.4 1996/01/30 23:30:30 mpp 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 6610132Speterextern int h_errno; 6710132Speter 681539Srgrimes/* 691539Srgrimes * Structures returned by network data base library. All addresses are 701539Srgrimes * supplied in host order, and returned in network order (suitable for 711539Srgrimes * use in system calls). 721539Srgrimes */ 731539Srgrimesstruct hostent { 741539Srgrimes char *h_name; /* official name of host */ 751539Srgrimes char **h_aliases; /* alias list */ 761539Srgrimes int h_addrtype; /* host address type */ 771539Srgrimes int h_length; /* length of address */ 781539Srgrimes char **h_addr_list; /* list of addresses from name server */ 7913771Smpp#define h_addr h_addr_list[0] /* address, for backward compatibility */ 801539Srgrimes}; 811539Srgrimes 821539Srgrimes/* 831539Srgrimes * Assumption here is that a network number 841539Srgrimes * fits in an unsigned long -- probably a poor one. 851539Srgrimes */ 861539Srgrimesstruct netent { 871539Srgrimes char *n_name; /* official name of net */ 881539Srgrimes char **n_aliases; /* alias list */ 891539Srgrimes int n_addrtype; /* net address type */ 901539Srgrimes unsigned long n_net; /* network # */ 911539Srgrimes}; 921539Srgrimes 931539Srgrimesstruct servent { 941539Srgrimes char *s_name; /* official service name */ 951539Srgrimes char **s_aliases; /* alias list */ 961539Srgrimes int s_port; /* port # */ 971539Srgrimes char *s_proto; /* protocol to use */ 981539Srgrimes}; 991539Srgrimes 1001539Srgrimesstruct protoent { 1011539Srgrimes char *p_name; /* official protocol name */ 1021539Srgrimes char **p_aliases; /* alias list */ 1031539Srgrimes int p_proto; /* protocol # */ 1041539Srgrimes}; 1051539Srgrimes 1061539Srgrimes/* 1071539Srgrimes * Error return codes from gethostbyname() and gethostbyaddr() 1081539Srgrimes * (left in extern int h_errno). 1091539Srgrimes */ 1101539Srgrimes 11110132Speter#define NETDB_INTERNAL -1 /* see errno */ 11210132Speter#define NETDB_SUCCESS 0 /* no problem */ 1131539Srgrimes#define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found */ 11413771Smpp#define TRY_AGAIN 2 /* Non-Authoritative Host not found, or SERVERFAIL */ 1151539Srgrimes#define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */ 1161539Srgrimes#define NO_DATA 4 /* Valid name, no data record of requested type */ 1171539Srgrimes#define NO_ADDRESS NO_DATA /* no address, look for MX record */ 1181539Srgrimes 1191539Srgrimes#include <sys/cdefs.h> 1201539Srgrimes 1211539Srgrimes__BEGIN_DECLS 1221539Srgrimesvoid endhostent __P((void)); 1231539Srgrimesvoid endnetent __P((void)); 1241539Srgrimesvoid endprotoent __P((void)); 1251539Srgrimesvoid endservent __P((void)); 1261539Srgrimesstruct hostent *gethostbyaddr __P((const char *, int, int)); 1271539Srgrimesstruct hostent *gethostbyname __P((const char *)); 12817902Speterstruct hostent *gethostbyname2 __P((const char *, int)); 1291539Srgrimesstruct hostent *gethostent __P((void)); 1301539Srgrimesstruct netent *getnetbyaddr __P((long, int)); /* u_long? */ 1311539Srgrimesstruct netent *getnetbyname __P((const char *)); 1321539Srgrimesstruct netent *getnetent __P((void)); 1331539Srgrimesstruct protoent *getprotobyname __P((const char *)); 1341539Srgrimesstruct protoent *getprotobynumber __P((int)); 1351539Srgrimesstruct protoent *getprotoent __P((void)); 1361539Srgrimesstruct servent *getservbyname __P((const char *, const char *)); 1371539Srgrimesstruct servent *getservbyport __P((int, const char *)); 1381539Srgrimesstruct servent *getservent __P((void)); 1391539Srgrimesvoid herror __P((const char *)); 14010132Speterconst char *hstrerror __P((int)); 1411539Srgrimesvoid sethostent __P((int)); 1421539Srgrimes/* void sethostfile __P((const char *)); */ 1431539Srgrimesvoid setnetent __P((int)); 1441539Srgrimesvoid setprotoent __P((int)); 1451539Srgrimesvoid setservent __P((int)); 14617902Speter 14717902Speter/* 14817902Speter * PRIVATE functions specific to the FreeBSD implementation 14917902Speter */ 15017902Speter 15117902Speter/* DO NOT USE THESE, THEY ARE SUBJECT TO CHANGE AND ARE NOT PORTABLE!!! */ 15217902Spetervoid _sethosthtent __P((int)); 15317902Spetervoid _endhosthtent __P((void)); 15417902Spetervoid _sethostdnsent __P((int)); 15517902Spetervoid _endhostdnsent __P((void)); 15617902Spetervoid _setnethtent __P((int)); 15717902Spetervoid _endnethtent __P((void)); 15817902Spetervoid _setnetdnsent __P((int)); 15917902Spetervoid _endnetdnsent __P((void)); 16017902Speterstruct hostent * _gethostbyhtname __P((const char *, int)); 16117902Speterstruct hostent * _gethostbydnsname __P((const char *, int)); 16217902Speterstruct hostent * _gethostbynisname __P((const char *, int)); 16317902Speterstruct hostent * _gethostbyhtaddr __P((const char *, int, int)); 16417902Speterstruct hostent * _gethostbydnsaddr __P((const char *, int, int)); 16517902Speterstruct hostent * _gethostbynisaddr __P((const char *, int, int)); 16617902Speterstruct netent * _getnetbyhtname __P((const char *)); 16717902Speterstruct netent * _getnetbydnsname __P((const char *)); 16817902Speterstruct netent * _getnetbynisname __P((const char *)); 16917902Speterstruct netent * _getnetbyhtaddr __P((unsigned long, int)); 17017902Speterstruct netent * _getnetbydnsaddr __P((unsigned long, int)); 17117902Speterstruct netent * _getnetbynisaddr __P((unsigned long, int)); 17217902Spetervoid _map_v4v6_address __P((const char *src, char *dst)); 17317902Spetervoid _map_v4v6_hostent __P((struct hostent *hp, char **bp, int *len)); 17417902Speter 1751539Srgrimes__END_DECLS 1761539Srgrimes 1771539Srgrimes#endif /* !_NETDB_H_ */ 178