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