xref: /titanic_52/usr/src/lib/libbc/libc/yp/yp_prot.h (revision 10db1377dafab8ba3feedef26db9c5d8539a5cd1)
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 /*
23  * Copyright 1997 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 /*
30  * This file contains symbols and structures defining the rpc protocol
31  * between the NIS clients and the NIS servers.  The servers
32  * are the NIS database servers, and the NIS binders.
33  */
34 
35 /*
36  * The following procedures are supported by the protocol:
37  *
38  * YPPROC_NULL() returns () takes nothing, returns nothing.  This indicates
39  * that the NIS server is alive.
40  *
41  * YPPROC_DOMAIN (char *) returns (bool_t) TRUE.  Indicates that the
42  * responding NIS server does serve the named domain; FALSE indicates no
43  * support.
44  *
45  * YPPROC_DOMAIN_NONACK (char *) returns (TRUE) if the NIS server does serve
46  * the named domain, otherwise does not return.  Used in the broadcast case.
47  *
48  * YPPROC_MATCH (struct ypreq_key) returns (struct ypresp_val).  Returns the
49  * right-hand value for a passed left-hand key, within a named map and
50  * domain.
51  *
52  * YPPROC_FIRST (struct ypreq_nokey) returns (struct ypresp_key_val).
53  * Returns the first key-value pair from a named domain and map.
54  *
55  * YPPROC_NEXT (struct ypreq_key) returns (struct ypresp_key_val).  Returns
56  * the key-value pair following a passed key-value pair within a named
57  * domain and map.
58  *
59  * YPPROC_XFR (struct ypreq_xfr) returns nothing.  Indicates to a server that
60  * a map should be updated.
61  *
62  * YPPROC_CLEAR	takes nothing, returns nothing.  Instructs a NIS server to
63  * close the current map, so that old versions of the disk file don't get
64  * held open.
65  *
66  * YPPROC_ALL (struct ypreq_nokey), returns
67  * 	union switch (bool more) {
68  *		TRUE:	(struct ypresp_key_val);
69  *		FALSE:	(struct) {};
70  *	}
71  *
72  * YPPROC_MASTER (struct ypreq_nokey), returns (ypresp_master)
73  *
74  * YPPROC_ORDER (struct ypreq_nokey), returns (ypresp_order)
75  *
76  * YPPROC_MAPLIST (char *), returns (struct ypmaplist *)
77  */
78 #ifndef BOOL_DEFINED
79 typedef unsigned int bool;
80 #define BOOL_DEFINED
81 #endif
82 
83 extern bool xdr_datum();
84 extern bool xdr_ypdomain_wrap_string();
85 extern bool xdr_ypmap_wrap_string();
86 extern bool xdr_ypreq_key();
87 extern bool xdr_ypreq_nokey();
88 extern bool xdr_ypreq_xfr();
89 extern bool xdr_ypresp_val();
90 extern bool xdr_ypresp_key_val();
91 extern bool xdr_ypbind_resp();
92 extern bool xdr_ypbind_setdom();
93 extern bool xdr_yp_inaddr();
94 extern bool xdr_ypmap_parms();
95 extern bool xdr_ypowner_wrap_string();
96 extern bool xdr_yppushresp_xfr();
97 extern bool xdr_ypresp_order();
98 extern bool xdr_ypresp_master();
99 extern bool xdr_ypall();
100 extern bool xdr_ypresp_maplist();
101 
102 /* Program and version symbols, magic numbers */
103 
104 #define YPPROG		((u_long)100004)
105 #define YPVERS		((u_long)2)
106 #define YPVERS_ORIG	((u_long)1)
107 #define YPMAXRECORD	((u_long)1024)
108 #define YPMAXDOMAIN	((u_long)256)
109 #define YPMAXMAP	((u_long)64)
110 #define YPMAXPEER	((u_long)256)
111 
112 /* byte size of a large NIS packet */
113 #define YPMSGSZ		1600
114 
115 #ifndef DATUM
116 typedef struct {
117 	char	*dptr;
118 	int	dsize;
119 } datum;
120 #define DATUM
121 #endif
122 
123 struct ypmap_parms {
124 	char *domain;			/* Null string means not available */
125 	char *map;			/* Null string means not available */
126 	unsigned long int ordernum;	/* 0 means not available */
127 	char *owner;			/* Null string means not available */
128 };
129 
130 /*
131  * Request parameter structures
132  */
133 
134 struct ypreq_key {
135 	char *domain;
136 	char *map;
137 	datum keydat;
138 };
139 
140 struct ypreq_nokey {
141 	char *domain;
142 	char *map;
143 };
144 
145 struct ypreq_xfr {
146 	struct ypmap_parms map_parms;
147 	unsigned long transid;
148 	unsigned long proto;
149 	unsigned short port;
150 };
151 #define ypxfr_domain map_parms.domain
152 #define ypxfr_map map_parms.map
153 #define ypxfr_ordernum map_parms.ordernum
154 #define ypxfr_owner map_parms.owner
155 
156 /*
157  * Response parameter structures
158  */
159 
160 struct ypresp_val {
161 	long unsigned status;
162 	datum valdat;
163 };
164 
165 struct ypresp_key_val {
166 	long unsigned status;
167 	datum keydat;
168 	datum valdat;
169 };
170 
171 struct ypresp_master {
172 	long unsigned status;
173 	char *master;
174 };
175 
176 struct ypresp_order {
177 	long unsigned status;
178 	unsigned long int ordernum;
179 };
180 
181 struct ypmaplist {
182 	char ypml_name[YPMAXMAP + 1];
183 	struct ypmaplist *ypml_next;
184 };
185 
186 struct ypresp_maplist {
187 	long unsigned status;
188 	struct ypmaplist *list;
189 };
190 
191 /*
192  * Procedure symbols.  YPPROC_NULL, YPPROC_DOMAIN, and YPPROC_DOMAIN_NONACK
193  * must keep the same values (0, 1, and 2) that they had in the first version
194  * of the protocol.
195  */
196 
197 #define YPPROC_NULL	((u_long)0)
198 #define YPPROC_DOMAIN	((u_long)1)
199 #define YPPROC_DOMAIN_NONACK ((u_long)2)
200 #define YPPROC_MATCH	((u_long)3)
201 #define YPPROC_FIRST	((u_long)4)
202 #define YPPROC_NEXT	((u_long)5)
203 #define YPPROC_XFR	((u_long)6)
204 #define YPPROC_CLEAR	((u_long)7)
205 #define YPPROC_ALL	((u_long)8)
206 #define YPPROC_MASTER	((u_long)9)
207 #define YPPROC_ORDER	((u_long)10)
208 #define YPPROC_MAPLIST	((u_long)11)
209 
210 /* Return status values */
211 
212 #define YP_TRUE	 	((long)1)	/* General purpose success code */
213 #define YP_NOMORE 	((long)2)	/* No more entries in map */
214 #define YP_FALSE 	((long)0)	/* General purpose failure code */
215 #define YP_NOMAP 	((long)-1)	/* No such map in domain */
216 #define YP_NODOM 	((long)-2)	/* Domain not supported */
217 #define YP_NOKEY 	((long)-3)	/* No such key in map */
218 #define YP_BADOP 	((long)-4)	/* Invalid operation */
219 #define YP_BADDB 	((long)-5)	/* Server data base is bad */
220 #define YP_YPERR 	((long)-6)	/* NIS server error */
221 #define YP_BADARGS 	((long)-7)	/* Request arguments bad */
222 #define YP_VERS		((long)-8)	/* NIS server version mismatch - server
223 					 *   can't supply requested service. */
224 
225 /*
226  * Domain binding data structure, used by ypclnt package and ypserv modules.
227  * Users of the ypclnt package (or of this protocol) don't HAVE to know about
228  * it, but it must be available to users because _yp_dobind is a public
229  * interface.
230  */
231 
232 struct dom_binding {
233 	struct dom_binding *dom_pnext;
234 	char dom_domain[YPMAXDOMAIN + 1];
235 	struct sockaddr_in dom_server_addr;
236 	unsigned short int dom_server_port;
237 	int dom_socket;
238 	CLIENT *dom_client;
239 	unsigned short int dom_local_port;
240 	long int dom_vers;
241 };
242 
243 
244 /*
245  *		Protocol between clients and NIS binder servers
246  */
247 
248 /*
249  * The following procedures are supported by the protocol:
250  *
251  * YPBINDPROC_NULL() returns ()
252  * 	takes nothing, returns nothing
253  *
254  * YPBINDPROC_DOMAIN takes (char *) returns (struct ypbind_resp)
255  *
256  * YPBINDPROC_SETDOM takes (struct ypbind_setdom) returns nothing
257  */
258 
259 /* Program and version symbols, magic numbers */
260 
261 #define YPBINDPROG		((u_long)100007)
262 #define YPBINDVERS		((u_long)2)
263 #define YPBINDVERS_ORIG		((u_long)1)
264 
265 /* Procedure symbols */
266 
267 #define YPBINDPROC_NULL		((u_long)0)
268 #define YPBINDPROC_DOMAIN	((u_long)1)
269 #define YPBINDPROC_SETDOM	((u_long)2)
270 /*
271  * Response structure and overall result status codes.  Success and failure
272  * represent two separate response message types.
273  */
274 
275 enum ypbind_resptype {YPBIND_SUCC_VAL = 1, YPBIND_FAIL_VAL = 2};
276 
277 struct ypbind_binding {
278 	struct in_addr ypbind_binding_addr;	/* In network order */
279 	unsigned short int ypbind_binding_port;	/* In network order */
280 };
281 struct ypbind_resp {
282 	enum ypbind_resptype ypbind_status;
283 	union {
284 		unsigned long ypbind_error;
285 		struct ypbind_binding ypbind_bindinfo;
286 	} ypbind_respbody;
287 };
288 
289 
290 /* Detailed failure reason codes for response field ypbind_error*/
291 
292 #define YPBIND_ERR_ERR 1		/* Internal error */
293 #define YPBIND_ERR_NOSERV 2		/* No bound server for passed domain */
294 #define YPBIND_ERR_RESC 3		/* System resource allocation failure */
295 
296 /*
297  * Request data structure for ypbind "Set domain" procedure.
298  */
299 struct ypbind_setdom {
300 	char ypsetdom_domain[YPMAXDOMAIN + 1];
301 	struct ypbind_binding ypsetdom_binding;
302 	unsigned short ypsetdom_vers;
303 };
304 #define ypsetdom_addr ypsetdom_binding.ypbind_binding_addr
305 #define ypsetdom_port ypsetdom_binding.ypbind_binding_port
306 
307 /*
308  *		Protocol between clients (ypxfr, only) and yppush
309  *		yppush speaks a protocol in the transient range, which
310  *		is supplied to ypxfr as a command-line parameter when it
311  *		is activated by ypserv.
312  */
313 #define YPPUSHVERS		((u_long) 1)
314 #define YPPUSHVERS_ORIG		((u_long)1)
315 
316 /* Procedure symbols */
317 
318 #define YPPUSHPROC_NULL		((u_long)0)
319 #define YPPUSHPROC_XFRRESP	((u_long)1)
320 
321 struct yppushresp_xfr {
322 	unsigned long transid;
323 	unsigned long status;
324 };
325 
326 /* Status values for yppushresp_xfr.status */
327 
328 #define YPPUSH_SUCC	((long)1)	/* Success */
329 #define YPPUSH_AGE	((long)2)	/* Master's version not newer */
330 #define YPPUSH_NOMAP 	((long)-1)	/* Can't find server for map */
331 #define YPPUSH_NODOM 	((long)-2)	/* Domain not supported */
332 #define YPPUSH_RSRC 	((long)-3)	/* Local resouce alloc failure */
333 #define YPPUSH_RPC 	((long)-4)	/* RPC failure talking to server */
334 #define YPPUSH_MADDR	((long)-5)	/* Can't get master address */
335 #define YPPUSH_YPERR 	((long)-6)	/* NIS server/map db error */
336 #define YPPUSH_BADARGS 	((long)-7)	/* Request arguments bad */
337 #define YPPUSH_DBM	((long)-8)	/* Local dbm operation failed */
338 #define YPPUSH_FILE	((long)-9)	/* Local file I/O operation failed */
339 #define YPPUSH_SKEW	((long)-10)	/* Map version skew during transfer */
340 #define YPPUSH_CLEAR	((long)-11)	/* Can't send "Clear" req to local
341 					 *   ypserv */
342 #define YPPUSH_FORCE	((long)-12)	/* No local order number in map -
343 					 *   use -f flag. */
344 #define YPPUSH_XFRERR	((long)-13)	/* ypxfr error */
345 #define YPPUSH_REFUSED	((long)-14)	/* Transfer request refused by ypserv */
346 
347 
348