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 /* Copyright (c) 1992 Sun Microsystems, Inc. */ 23*7c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 24*7c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 25*7c478bd9Sstevel@tonic-gate 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate /* 28*7c478bd9Sstevel@tonic-gate * netdir.h 29*7c478bd9Sstevel@tonic-gate * 30*7c478bd9Sstevel@tonic-gate * This is the include file that defines various structures and 31*7c478bd9Sstevel@tonic-gate * constants used by the netdir routines. 32*7c478bd9Sstevel@tonic-gate */ 33*7c478bd9Sstevel@tonic-gate 34*7c478bd9Sstevel@tonic-gate #ifndef _NETDIR_H 35*7c478bd9Sstevel@tonic-gate #define _NETDIR_H 36*7c478bd9Sstevel@tonic-gate 37*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.5 */ 38*7c478bd9Sstevel@tonic-gate 39*7c478bd9Sstevel@tonic-gate /* 40*7c478bd9Sstevel@tonic-gate * This files uses struct netconfig, and netconfig.h must be included 41*7c478bd9Sstevel@tonic-gate * before this to avoid warnings. 42*7c478bd9Sstevel@tonic-gate */ 43*7c478bd9Sstevel@tonic-gate 44*7c478bd9Sstevel@tonic-gate #include <netconfig.h> 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 struct nd_addrlist { 51*7c478bd9Sstevel@tonic-gate int n_cnt; /* number of netbufs */ 52*7c478bd9Sstevel@tonic-gate struct netbuf *n_addrs; /* the netbufs */ 53*7c478bd9Sstevel@tonic-gate }; 54*7c478bd9Sstevel@tonic-gate 55*7c478bd9Sstevel@tonic-gate struct nd_hostservlist { 56*7c478bd9Sstevel@tonic-gate int h_cnt; /* number of nd_hostservs */ 57*7c478bd9Sstevel@tonic-gate struct nd_hostserv *h_hostservs; /* the entries */ 58*7c478bd9Sstevel@tonic-gate }; 59*7c478bd9Sstevel@tonic-gate 60*7c478bd9Sstevel@tonic-gate struct nd_hostserv { 61*7c478bd9Sstevel@tonic-gate char *h_host; /* the host name */ 62*7c478bd9Sstevel@tonic-gate char *h_serv; /* the service name */ 63*7c478bd9Sstevel@tonic-gate }; 64*7c478bd9Sstevel@tonic-gate 65*7c478bd9Sstevel@tonic-gate struct nd_mergearg { 66*7c478bd9Sstevel@tonic-gate char *s_uaddr; /* servers universal address */ 67*7c478bd9Sstevel@tonic-gate char *c_uaddr; /* clients universal address */ 68*7c478bd9Sstevel@tonic-gate char *m_uaddr; /* merged universal address */ 69*7c478bd9Sstevel@tonic-gate }; 70*7c478bd9Sstevel@tonic-gate 71*7c478bd9Sstevel@tonic-gate /* 72*7c478bd9Sstevel@tonic-gate * _nderror is a private variable to the netdir system. 73*7c478bd9Sstevel@tonic-gate */ 74*7c478bd9Sstevel@tonic-gate #ifdef _REENTRANT 75*7c478bd9Sstevel@tonic-gate extern int *__nderror(); 76*7c478bd9Sstevel@tonic-gate #define _nderror (*(__nderror())) 77*7c478bd9Sstevel@tonic-gate #else 78*7c478bd9Sstevel@tonic-gate extern int _nderror; 79*7c478bd9Sstevel@tonic-gate #endif /* _REENTRANT */ 80*7c478bd9Sstevel@tonic-gate 81*7c478bd9Sstevel@tonic-gate 82*7c478bd9Sstevel@tonic-gate #ifdef __STDC__ 83*7c478bd9Sstevel@tonic-gate 84*7c478bd9Sstevel@tonic-gate int netdir_options(struct netconfig *, int option, int fd, char *par); 85*7c478bd9Sstevel@tonic-gate int netdir_getbyname(struct netconfig *, struct nd_hostserv *, 86*7c478bd9Sstevel@tonic-gate struct nd_addrlist **); 87*7c478bd9Sstevel@tonic-gate int netdir_getbyaddr(struct netconfig *, struct nd_hostservlist **, 88*7c478bd9Sstevel@tonic-gate struct netbuf *); 89*7c478bd9Sstevel@tonic-gate int __netdir_getbyaddr_nosrv(struct netconfig *, struct nd_hostservlist **, 90*7c478bd9Sstevel@tonic-gate struct netbuf *); 91*7c478bd9Sstevel@tonic-gate int netdir_mergeaddr(struct netconfig *, char **muaddr, char *uaddr, 92*7c478bd9Sstevel@tonic-gate char *ruaddr); 93*7c478bd9Sstevel@tonic-gate void netdir_free(void *, int); 94*7c478bd9Sstevel@tonic-gate struct netbuf *uaddr2taddr(struct netconfig *, char *); 95*7c478bd9Sstevel@tonic-gate char *taddr2uaddr(struct netconfig *, struct netbuf *); 96*7c478bd9Sstevel@tonic-gate void netdir_perror(char *); 97*7c478bd9Sstevel@tonic-gate char *netdir_sperror(); 98*7c478bd9Sstevel@tonic-gate struct nd_addrlist *_netdir_getbyname(struct netconfig *, struct nd_hostserv *); 99*7c478bd9Sstevel@tonic-gate struct nd_hostservlist *_netdir_getbyaddr(struct netconfig *, struct netbuf *); 100*7c478bd9Sstevel@tonic-gate struct netbuf *_uaddr2taddr(struct netconfig *, char *); 101*7c478bd9Sstevel@tonic-gate char *_taddr2uaddr(struct netconfig *, struct netbuf *); 102*7c478bd9Sstevel@tonic-gate char *_netdir_mergeaddr(struct netconfig *, char *uaddr, char *ruaddr); 103*7c478bd9Sstevel@tonic-gate 104*7c478bd9Sstevel@tonic-gate #else /* __STDC__ */ 105*7c478bd9Sstevel@tonic-gate 106*7c478bd9Sstevel@tonic-gate int netdir_options(); 107*7c478bd9Sstevel@tonic-gate int netdir_getbyname(); 108*7c478bd9Sstevel@tonic-gate int netdir_getbyaddr(); 109*7c478bd9Sstevel@tonic-gate int netdir_mergeaddr(); 110*7c478bd9Sstevel@tonic-gate void netdir_free(); 111*7c478bd9Sstevel@tonic-gate struct netbuf *uaddr2taddr(); 112*7c478bd9Sstevel@tonic-gate void netdir_perror(); 113*7c478bd9Sstevel@tonic-gate char *netdir_sperror(); 114*7c478bd9Sstevel@tonic-gate char *taddr2uaddr(); 115*7c478bd9Sstevel@tonic-gate struct nd_addrlist *_netdir_getbyname(); 116*7c478bd9Sstevel@tonic-gate struct nd_hostservlist *_netdir_getbyaddr(); 117*7c478bd9Sstevel@tonic-gate char *_netdir_mergeaddr(); 118*7c478bd9Sstevel@tonic-gate struct netbuf *_uaddr2taddr(); 119*7c478bd9Sstevel@tonic-gate char *_taddr2uaddr(); 120*7c478bd9Sstevel@tonic-gate 121*7c478bd9Sstevel@tonic-gate #endif /* __STDC__ */ 122*7c478bd9Sstevel@tonic-gate 123*7c478bd9Sstevel@tonic-gate /* 124*7c478bd9Sstevel@tonic-gate * These are all objects that can be freed by netdir_free 125*7c478bd9Sstevel@tonic-gate */ 126*7c478bd9Sstevel@tonic-gate #define ND_HOSTSERV 0 127*7c478bd9Sstevel@tonic-gate #define ND_HOSTSERVLIST 1 128*7c478bd9Sstevel@tonic-gate #define ND_ADDR 2 129*7c478bd9Sstevel@tonic-gate #define ND_ADDRLIST 3 130*7c478bd9Sstevel@tonic-gate 131*7c478bd9Sstevel@tonic-gate /* 132*7c478bd9Sstevel@tonic-gate * These are the various errors that can be encountered while attempting 133*7c478bd9Sstevel@tonic-gate * to translate names to addresses. Note that none of them (except maybe 134*7c478bd9Sstevel@tonic-gate * no memory) are truely fatal unless the ntoa deamon is on its last attempt 135*7c478bd9Sstevel@tonic-gate * to translate the name. First four errors are to failitate return values 136*7c478bd9Sstevel@tonic-gate * from DNS, that are used by mail and others. 137*7c478bd9Sstevel@tonic-gate * 138*7c478bd9Sstevel@tonic-gate * Negative errors terminate the search resolution process, positive errors 139*7c478bd9Sstevel@tonic-gate * are treated as warnings. 140*7c478bd9Sstevel@tonic-gate */ 141*7c478bd9Sstevel@tonic-gate 142*7c478bd9Sstevel@tonic-gate #define ND_TRY_AGAIN -5 /* Non-Authoritive Host not found, or */ 143*7c478bd9Sstevel@tonic-gate /* SERVERFAIL */ 144*7c478bd9Sstevel@tonic-gate #define ND_NO_RECOVERY -4 /* Non recoverable errors, FORMERR, REFUSED, */ 145*7c478bd9Sstevel@tonic-gate /* NOTIMP */ 146*7c478bd9Sstevel@tonic-gate #define ND_NO_DATA -3 /* Valid name, no data record of requested */ 147*7c478bd9Sstevel@tonic-gate /* type */ 148*7c478bd9Sstevel@tonic-gate #define ND_NO_ADDRESS ND_NO_DATA /* no address, look for MX record */ 149*7c478bd9Sstevel@tonic-gate #define ND_BADARG -2 /* Bad arguments passed */ 150*7c478bd9Sstevel@tonic-gate #define ND_NOMEM -1 /* No virtual memory left */ 151*7c478bd9Sstevel@tonic-gate #define ND_OK 0 /* Translation successful */ 152*7c478bd9Sstevel@tonic-gate #define ND_NOHOST 1 /* Hostname was not resolvable */ 153*7c478bd9Sstevel@tonic-gate #define ND_NOSERV 2 /* Service was unknown */ 154*7c478bd9Sstevel@tonic-gate #define ND_NOSYM 3 /* Couldn't resolve symbol */ 155*7c478bd9Sstevel@tonic-gate #define ND_OPEN 4 /* File couldn't be opened */ 156*7c478bd9Sstevel@tonic-gate #define ND_ACCESS 5 /* File is not accessable */ 157*7c478bd9Sstevel@tonic-gate #define ND_UKNWN 6 /* Unknown object to be freed */ 158*7c478bd9Sstevel@tonic-gate #define ND_NOCTRL 7 /* Unknown option passed to netdir_options */ 159*7c478bd9Sstevel@tonic-gate #define ND_FAILCTRL 8 /* Option failed in netdir_options */ 160*7c478bd9Sstevel@tonic-gate #define ND_SYSTEM 9 /* Other System error */ 161*7c478bd9Sstevel@tonic-gate 162*7c478bd9Sstevel@tonic-gate /* 163*7c478bd9Sstevel@tonic-gate * The following netdir_options commands can be given to the fd. These is 164*7c478bd9Sstevel@tonic-gate * a way of providing for any transport specific action which the caller 165*7c478bd9Sstevel@tonic-gate * may want to initiate on his transport. It is up to the trasport provider 166*7c478bd9Sstevel@tonic-gate * to support the netdir_options he wants to support. 167*7c478bd9Sstevel@tonic-gate */ 168*7c478bd9Sstevel@tonic-gate 169*7c478bd9Sstevel@tonic-gate #define ND_SET_BROADCAST 1 /* Do t_optmgmt to support broadcast */ 170*7c478bd9Sstevel@tonic-gate #define ND_SET_RESERVEDPORT 2 /* bind it to reserve address */ 171*7c478bd9Sstevel@tonic-gate #define ND_CHECK_RESERVEDPORT 3 /* check if address is reserved */ 172*7c478bd9Sstevel@tonic-gate #define ND_MERGEADDR 4 /* Merge universal address */ 173*7c478bd9Sstevel@tonic-gate 174*7c478bd9Sstevel@tonic-gate /* 175*7c478bd9Sstevel@tonic-gate * The following special case host names are used to give the underlying 176*7c478bd9Sstevel@tonic-gate * transport provides a clue as to the intent of the request. 177*7c478bd9Sstevel@tonic-gate */ 178*7c478bd9Sstevel@tonic-gate 179*7c478bd9Sstevel@tonic-gate #define HOST_SELF "\\1" 180*7c478bd9Sstevel@tonic-gate #define HOST_ANY "\\2" 181*7c478bd9Sstevel@tonic-gate #define HOST_BROADCAST "\\3" 182*7c478bd9Sstevel@tonic-gate #define HOST_SELF_BIND HOST_SELF 183*7c478bd9Sstevel@tonic-gate #define HOST_SELF_CONNECT "\\4" 184*7c478bd9Sstevel@tonic-gate 185*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 186*7c478bd9Sstevel@tonic-gate } 187*7c478bd9Sstevel@tonic-gate #endif 188*7c478bd9Sstevel@tonic-gate 189*7c478bd9Sstevel@tonic-gate #endif /* _NETDIR_H */ 190