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