1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 1996 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ 28*7c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate /* 31*7c478bd9Sstevel@tonic-gate * Portions of this source code were derived from Berkeley 4.3 BSD 32*7c478bd9Sstevel@tonic-gate * under license from the Regents of the University of California. 33*7c478bd9Sstevel@tonic-gate */ 34*7c478bd9Sstevel@tonic-gate 35*7c478bd9Sstevel@tonic-gate /* 36*7c478bd9Sstevel@tonic-gate * Structures returned by network data base library. 37*7c478bd9Sstevel@tonic-gate * All addresses are supplied in host order, and 38*7c478bd9Sstevel@tonic-gate * returned in network order (suitable for use in system calls). 39*7c478bd9Sstevel@tonic-gate */ 40*7c478bd9Sstevel@tonic-gate 41*7c478bd9Sstevel@tonic-gate #ifndef _NETDB_H 42*7c478bd9Sstevel@tonic-gate #define _NETDB_H 43*7c478bd9Sstevel@tonic-gate 44*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 45*7c478bd9Sstevel@tonic-gate 46*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 47*7c478bd9Sstevel@tonic-gate extern "C" { 48*7c478bd9Sstevel@tonic-gate #endif 49*7c478bd9Sstevel@tonic-gate 50*7c478bd9Sstevel@tonic-gate #define _PATH_HEQUIV "/etc/hosts.equiv" 51*7c478bd9Sstevel@tonic-gate #define _PATH_HOSTS "/etc/hosts" 52*7c478bd9Sstevel@tonic-gate #define _PATH_NETWORKS "/etc/networks" 53*7c478bd9Sstevel@tonic-gate #define _PATH_PROTOCOLS "/etc/protocols" 54*7c478bd9Sstevel@tonic-gate #define _PATH_SERVICES "/etc/services" 55*7c478bd9Sstevel@tonic-gate 56*7c478bd9Sstevel@tonic-gate struct hostent { 57*7c478bd9Sstevel@tonic-gate char *h_name; /* official name of host */ 58*7c478bd9Sstevel@tonic-gate char **h_aliases; /* alias list */ 59*7c478bd9Sstevel@tonic-gate int h_addrtype; /* host address type */ 60*7c478bd9Sstevel@tonic-gate int h_length; /* length of address */ 61*7c478bd9Sstevel@tonic-gate char **h_addr_list; /* list of addresses from name server */ 62*7c478bd9Sstevel@tonic-gate #define h_addr h_addr_list[0] /* address, for backward compatiblity */ 63*7c478bd9Sstevel@tonic-gate }; 64*7c478bd9Sstevel@tonic-gate 65*7c478bd9Sstevel@tonic-gate /* 66*7c478bd9Sstevel@tonic-gate * Assumption here is that a network number 67*7c478bd9Sstevel@tonic-gate * fits in 32 bits -- probably a poor one. 68*7c478bd9Sstevel@tonic-gate */ 69*7c478bd9Sstevel@tonic-gate struct netent { 70*7c478bd9Sstevel@tonic-gate char *n_name; /* official name of net */ 71*7c478bd9Sstevel@tonic-gate char **n_aliases; /* alias list */ 72*7c478bd9Sstevel@tonic-gate int n_addrtype; /* net address type */ 73*7c478bd9Sstevel@tonic-gate unsigned long n_net; /* network # */ 74*7c478bd9Sstevel@tonic-gate }; 75*7c478bd9Sstevel@tonic-gate 76*7c478bd9Sstevel@tonic-gate struct servent { 77*7c478bd9Sstevel@tonic-gate char *s_name; /* official service name */ 78*7c478bd9Sstevel@tonic-gate char **s_aliases; /* alias list */ 79*7c478bd9Sstevel@tonic-gate int s_port; /* port # */ 80*7c478bd9Sstevel@tonic-gate char *s_proto; /* protocol to use */ 81*7c478bd9Sstevel@tonic-gate }; 82*7c478bd9Sstevel@tonic-gate 83*7c478bd9Sstevel@tonic-gate struct protoent { 84*7c478bd9Sstevel@tonic-gate char *p_name; /* official protocol name */ 85*7c478bd9Sstevel@tonic-gate char **p_aliases; /* alias list */ 86*7c478bd9Sstevel@tonic-gate int p_proto; /* protocol # */ 87*7c478bd9Sstevel@tonic-gate }; 88*7c478bd9Sstevel@tonic-gate 89*7c478bd9Sstevel@tonic-gate #ifdef __STDC__ 90*7c478bd9Sstevel@tonic-gate struct hostent *gethostbyname_r 91*7c478bd9Sstevel@tonic-gate (const char *, struct hostent *, char *, int, int *h_errnop); 92*7c478bd9Sstevel@tonic-gate struct hostent *gethostbyaddr_r 93*7c478bd9Sstevel@tonic-gate (const char *, int, int, struct hostent *, char *, int, int *h_errnop); 94*7c478bd9Sstevel@tonic-gate struct hostent *gethostent_r(struct hostent *, char *, int, int *h_errnop); 95*7c478bd9Sstevel@tonic-gate 96*7c478bd9Sstevel@tonic-gate struct servent *getservbyname_r 97*7c478bd9Sstevel@tonic-gate (const char *name, const char *, struct servent *, char *, int); 98*7c478bd9Sstevel@tonic-gate struct servent *getservbyport_r 99*7c478bd9Sstevel@tonic-gate (int port, const char *, struct servent *, char *, int); 100*7c478bd9Sstevel@tonic-gate struct servent *getservent_r(struct servent *, char *, int); 101*7c478bd9Sstevel@tonic-gate 102*7c478bd9Sstevel@tonic-gate struct netent *getnetbyname_r 103*7c478bd9Sstevel@tonic-gate (const char *, struct netent *, char *, int); 104*7c478bd9Sstevel@tonic-gate struct netent *getnetbyaddr_r(long, int, struct netent *, char *, int); 105*7c478bd9Sstevel@tonic-gate struct netent *getnetent_r(struct netent *, char *, int); 106*7c478bd9Sstevel@tonic-gate 107*7c478bd9Sstevel@tonic-gate struct protoent *getprotobyname_r 108*7c478bd9Sstevel@tonic-gate (const char *, struct protoent *, char *, int); 109*7c478bd9Sstevel@tonic-gate struct protoent *getprotobynumber_r 110*7c478bd9Sstevel@tonic-gate (int, struct protoent *, char *, int); 111*7c478bd9Sstevel@tonic-gate struct protoent *getprotoent_r(struct protoent *, char *, int); 112*7c478bd9Sstevel@tonic-gate 113*7c478bd9Sstevel@tonic-gate int getnetgrent_r(char **, char **, char **, char *, int); 114*7c478bd9Sstevel@tonic-gate int innetgr(const char *, const char *, const char *, const char *); 115*7c478bd9Sstevel@tonic-gate 116*7c478bd9Sstevel@tonic-gate /* Old interfaces that return a pointer to a static area; MT-unsafe */ 117*7c478bd9Sstevel@tonic-gate struct hostent *gethostbyname(const char *); 118*7c478bd9Sstevel@tonic-gate struct hostent *gethostbyaddr(const char *, int, int); 119*7c478bd9Sstevel@tonic-gate struct hostent *gethostent(void); 120*7c478bd9Sstevel@tonic-gate struct netent *getnetbyname(const char *); 121*7c478bd9Sstevel@tonic-gate struct netent *getnetbyaddr(long, int); 122*7c478bd9Sstevel@tonic-gate struct netent *getnetent(void); 123*7c478bd9Sstevel@tonic-gate struct servent *getservbyname(const char *, const char *); 124*7c478bd9Sstevel@tonic-gate struct servent *getservbyport(int, const char *); 125*7c478bd9Sstevel@tonic-gate struct servent *getservent(void); 126*7c478bd9Sstevel@tonic-gate struct protoent *getprotobyname(const char *); 127*7c478bd9Sstevel@tonic-gate struct protoent *getprotobynumber(int); 128*7c478bd9Sstevel@tonic-gate struct protoent *getprotoent(void); 129*7c478bd9Sstevel@tonic-gate int getnetgrent(char **, char **, char **); 130*7c478bd9Sstevel@tonic-gate 131*7c478bd9Sstevel@tonic-gate int sethostent(int); 132*7c478bd9Sstevel@tonic-gate int endhostent(void); 133*7c478bd9Sstevel@tonic-gate int setnetent(int); 134*7c478bd9Sstevel@tonic-gate int endnetent(void); 135*7c478bd9Sstevel@tonic-gate int setservent(int); 136*7c478bd9Sstevel@tonic-gate int endservent(void); 137*7c478bd9Sstevel@tonic-gate int setprotoent(int); 138*7c478bd9Sstevel@tonic-gate int endprotoent(void); 139*7c478bd9Sstevel@tonic-gate int setnetgrent(const char *); 140*7c478bd9Sstevel@tonic-gate int endnetgrent(void); 141*7c478bd9Sstevel@tonic-gate int rcmd(char **ahost, unsigned short inport, 142*7c478bd9Sstevel@tonic-gate const char *luser, const char *ruser, const char *cmd, int *fd2p); 143*7c478bd9Sstevel@tonic-gate int rexec(char **ahost, unsigned short inport, 144*7c478bd9Sstevel@tonic-gate const char *user, const char *passwd, const char *cmd, int *fd2p); 145*7c478bd9Sstevel@tonic-gate int rresvport(int *); 146*7c478bd9Sstevel@tonic-gate int ruserok(const char *rhost, int suser, const char *ruser, const char *luser); 147*7c478bd9Sstevel@tonic-gate #else 148*7c478bd9Sstevel@tonic-gate struct hostent *gethostbyname_r(); 149*7c478bd9Sstevel@tonic-gate struct hostent *gethostbyaddr_r(); 150*7c478bd9Sstevel@tonic-gate struct hostent *gethostent_r(); 151*7c478bd9Sstevel@tonic-gate struct servent *getservbyname_r(); 152*7c478bd9Sstevel@tonic-gate struct servent *getservbyport_r(); 153*7c478bd9Sstevel@tonic-gate struct servent *getservent_r(); 154*7c478bd9Sstevel@tonic-gate struct netent *getnetbyname_r(); 155*7c478bd9Sstevel@tonic-gate struct netent *getnetbyaddr_r(); 156*7c478bd9Sstevel@tonic-gate struct netent *getnetent_r(); 157*7c478bd9Sstevel@tonic-gate struct protoent *getprotobyname_r(); 158*7c478bd9Sstevel@tonic-gate struct protoent *getprotobynumber_r(); 159*7c478bd9Sstevel@tonic-gate struct protoent *getprotoent_r(); 160*7c478bd9Sstevel@tonic-gate int getnetgrent_r(); 161*7c478bd9Sstevel@tonic-gate int innetgr(); 162*7c478bd9Sstevel@tonic-gate 163*7c478bd9Sstevel@tonic-gate /* Old interfaces that return a pointer to a static area; MT-unsafe */ 164*7c478bd9Sstevel@tonic-gate struct hostent *gethostbyname(); 165*7c478bd9Sstevel@tonic-gate struct hostent *gethostbyaddr(); 166*7c478bd9Sstevel@tonic-gate struct hostent *gethostent(); 167*7c478bd9Sstevel@tonic-gate struct netent *getnetbyname(); 168*7c478bd9Sstevel@tonic-gate struct netent *getnetbyaddr(); 169*7c478bd9Sstevel@tonic-gate struct netent *getnetent(); 170*7c478bd9Sstevel@tonic-gate struct servent *getservbyname(); 171*7c478bd9Sstevel@tonic-gate struct servent *getservbyport(); 172*7c478bd9Sstevel@tonic-gate struct servent *getservent(); 173*7c478bd9Sstevel@tonic-gate struct protoent *getprotobyname(); 174*7c478bd9Sstevel@tonic-gate struct protoent *getprotobynumber(); 175*7c478bd9Sstevel@tonic-gate struct protoent *getprotoent(); 176*7c478bd9Sstevel@tonic-gate int getnetgrent(); 177*7c478bd9Sstevel@tonic-gate 178*7c478bd9Sstevel@tonic-gate int sethostent(); 179*7c478bd9Sstevel@tonic-gate int endhostent(); 180*7c478bd9Sstevel@tonic-gate int setnetent(); 181*7c478bd9Sstevel@tonic-gate int endnetent(); 182*7c478bd9Sstevel@tonic-gate int setservent(); 183*7c478bd9Sstevel@tonic-gate int endservent(); 184*7c478bd9Sstevel@tonic-gate int setprotoent(); 185*7c478bd9Sstevel@tonic-gate int endprotoent(); 186*7c478bd9Sstevel@tonic-gate int setnetgrent(); 187*7c478bd9Sstevel@tonic-gate int endnetgrent(); 188*7c478bd9Sstevel@tonic-gate int rcmd(); 189*7c478bd9Sstevel@tonic-gate int rexec(); 190*7c478bd9Sstevel@tonic-gate int rresvport(); 191*7c478bd9Sstevel@tonic-gate int ruserok(); 192*7c478bd9Sstevel@tonic-gate #endif 193*7c478bd9Sstevel@tonic-gate 194*7c478bd9Sstevel@tonic-gate /* 195*7c478bd9Sstevel@tonic-gate * Error return codes from gethostbyname() and gethostbyaddr() 196*7c478bd9Sstevel@tonic-gate * (when using the resolver) 197*7c478bd9Sstevel@tonic-gate */ 198*7c478bd9Sstevel@tonic-gate 199*7c478bd9Sstevel@tonic-gate extern int h_errno; 200*7c478bd9Sstevel@tonic-gate 201*7c478bd9Sstevel@tonic-gate #define HOST_NOT_FOUND 1 /* Authoritive Answer Host not found */ 202*7c478bd9Sstevel@tonic-gate #define TRY_AGAIN 2 /* Non-Authoritive Host not found, or SERVERFAIL */ 203*7c478bd9Sstevel@tonic-gate #define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */ 204*7c478bd9Sstevel@tonic-gate #define NO_DATA 4 /* Valid name, no data record of requested type */ 205*7c478bd9Sstevel@tonic-gate #define NO_ADDRESS NO_DATA /* no address, look for MX record */ 206*7c478bd9Sstevel@tonic-gate 207*7c478bd9Sstevel@tonic-gate #define MAXHOSTNAMELEN 256 208*7c478bd9Sstevel@tonic-gate 209*7c478bd9Sstevel@tonic-gate #define MAXALIASES 35 210*7c478bd9Sstevel@tonic-gate #define MAXADDRS 35 211*7c478bd9Sstevel@tonic-gate 212*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 213*7c478bd9Sstevel@tonic-gate } 214*7c478bd9Sstevel@tonic-gate #endif 215*7c478bd9Sstevel@tonic-gate 216*7c478bd9Sstevel@tonic-gate #endif /* _NETDB_H */ 217