xref: /titanic_41/usr/src/lib/libnsl/nis/gen/nis_xdr.c (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 
23 /*
24  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
25  * Use is subject to license terms.
26  */
27 
28 #pragma ident	"%Z%%M%	%I%	%E% SMI"
29 
30 /*
31  * Originally generated using rpcgen.
32  */
33 
34 #include "mt.h"
35 #include <rpc/rpc.h>
36 #include <rpcsvc/nis.h>
37 
38 bool_t
39 xdr_nis_attr(XDR *xdrs, nis_attr *objp)
40 {
41 	if (!xdr_string(xdrs, &objp->zattr_ndx, ~0))
42 		return (FALSE);
43 	return (xdr_bytes(xdrs, (char **)&objp->zattr_val.zattr_val_val,
44 		(uint_t *)&objp->zattr_val.zattr_val_len, ~0));
45 }
46 
47 bool_t
48 xdr_nis_name(XDR *xdrs, nis_name *objp)
49 {
50 	return (xdr_string(xdrs, objp, ~0));
51 }
52 
53 bool_t
54 xdr_zotypes(XDR *xdrs, zotypes *objp)
55 {
56 	return (xdr_enum(xdrs, (enum_t *)objp));
57 }
58 
59 bool_t
60 xdr_nstype(XDR *xdrs, nstype *objp)
61 {
62 	return (xdr_enum(xdrs, (enum_t *)objp));
63 }
64 
65 bool_t
66 xdr_oar_mask(XDR *xdrs, oar_mask *objp)
67 {
68 	if (!xdr_u_int(xdrs, &objp->oa_rights))
69 		return (FALSE);
70 	return (xdr_zotypes(xdrs, &objp->oa_otype));
71 }
72 
73 bool_t
74 xdr_endpoint(XDR *xdrs, endpoint *objp)
75 {
76 	if (!xdr_string(xdrs, &objp->uaddr, ~0))
77 		return (FALSE);
78 	if (!xdr_string(xdrs, &objp->family, ~0))
79 		return (FALSE);
80 	return (xdr_string(xdrs, &objp->proto, ~0));
81 }
82 
83 bool_t
84 xdr_nis_server(XDR *xdrs, nis_server *objp)
85 {
86 	if (!xdr_nis_name(xdrs, &objp->name))
87 		return (FALSE);
88 	if (!xdr_array(xdrs, (char **)&objp->ep.ep_val,
89 			(uint_t *)&objp->ep.ep_len, ~0,
90 			sizeof (endpoint), (xdrproc_t)xdr_endpoint))
91 		return (FALSE);
92 	if (!xdr_u_int(xdrs, &objp->key_type))
93 		return (FALSE);
94 	return (xdr_netobj(xdrs, &objp->pkey));
95 }
96 
97 bool_t
98 xdr_directory_obj(XDR *xdrs, directory_obj *objp)
99 {
100 	if (!xdr_nis_name(xdrs, &objp->do_name))
101 		return (FALSE);
102 	if (!xdr_nstype(xdrs, &objp->do_type))
103 		return (FALSE);
104 	if (!xdr_array(xdrs, (char **)&objp->do_servers.do_servers_val,
105 			(uint_t *)&objp->do_servers.do_servers_len, ~0,
106 			sizeof (nis_server), (xdrproc_t)xdr_nis_server))
107 		return (FALSE);
108 	if (!xdr_uint32_t(xdrs, &objp->do_ttl))
109 		return (FALSE);
110 	return (xdr_array(xdrs, (char **)&objp->do_armask.do_armask_val,
111 		(uint_t *)&objp->do_armask.do_armask_len, ~0,
112 		sizeof (oar_mask), (xdrproc_t)xdr_oar_mask));
113 }
114 
115 bool_t
116 xdr_entry_col(XDR *xdrs, entry_col *objp)
117 {
118 	if (!xdr_u_int(xdrs, &objp->ec_flags))
119 		return (FALSE);
120 	return (xdr_bytes(xdrs, (char **)&objp->ec_value.ec_value_val,
121 		(uint_t *)&objp->ec_value.ec_value_len, ~0));
122 }
123 
124 bool_t
125 xdr_entry_obj(XDR *xdrs, entry_obj *objp)
126 {
127 	if (!xdr_string(xdrs, &objp->en_type, ~0))
128 		return (FALSE);
129 	return (xdr_array(xdrs, (char **)&objp->en_cols.en_cols_val,
130 		(uint_t *)&objp->en_cols.en_cols_len, ~0,
131 		sizeof (entry_col), (xdrproc_t)xdr_entry_col));
132 }
133 
134 bool_t
135 xdr_group_obj(XDR *xdrs, group_obj *objp)
136 {
137 	if (!xdr_u_int(xdrs, &objp->gr_flags))
138 		return (FALSE);
139 	return (xdr_array(xdrs, (char **)&objp->gr_members.gr_members_val,
140 		(uint_t *)&objp->gr_members.gr_members_len, ~0,
141 		sizeof (nis_name), (xdrproc_t)xdr_nis_name));
142 }
143 
144 bool_t
145 xdr_link_obj(XDR *xdrs, link_obj *objp)
146 {
147 	if (!xdr_zotypes(xdrs, &objp->li_rtype))
148 		return (FALSE);
149 	if (!xdr_array(xdrs, (char **)&objp->li_attrs.li_attrs_val,
150 			(uint_t *)&objp->li_attrs.li_attrs_len, ~0,
151 			sizeof (nis_attr), (xdrproc_t)xdr_nis_attr))
152 		return (FALSE);
153 	return (xdr_nis_name(xdrs, &objp->li_name));
154 }
155 
156 bool_t
157 xdr_table_col(XDR *xdrs, table_col *objp)
158 {
159 	if (!xdr_string(xdrs, &objp->tc_name, 64))
160 		return (FALSE);
161 	if (!xdr_u_int(xdrs, &objp->tc_flags))
162 		return (FALSE);
163 	return (xdr_u_int(xdrs, &objp->tc_rights));
164 }
165 
166 bool_t
167 xdr_table_obj(XDR *xdrs, table_obj *objp)
168 {
169 	if (!xdr_string(xdrs, &objp->ta_type, 64))
170 		return (FALSE);
171 	if (!xdr_int(xdrs, &objp->ta_maxcol))
172 		return (FALSE);
173 	if (!xdr_u_char(xdrs, &objp->ta_sep))
174 		return (FALSE);
175 	if (!xdr_array(xdrs, (char **)&objp->ta_cols.ta_cols_val,
176 			(uint_t *)&objp->ta_cols.ta_cols_len, ~0,
177 			sizeof (table_col), (xdrproc_t)xdr_table_col))
178 		return (FALSE);
179 	return (xdr_string(xdrs, &objp->ta_path, ~0));
180 }
181 
182 bool_t
183 xdr_objdata(XDR *xdrs, objdata *objp)
184 {
185 	if (!xdr_zotypes(xdrs, &objp->zo_type))
186 		return (FALSE);
187 
188 	switch (objp->zo_type) {
189 	case NIS_DIRECTORY_OBJ:
190 		return (xdr_directory_obj(xdrs, &objp->objdata_u.di_data));
191 	case NIS_GROUP_OBJ:
192 		return (xdr_group_obj(xdrs, &objp->objdata_u.gr_data));
193 	case NIS_TABLE_OBJ:
194 		return (xdr_table_obj(xdrs, &objp->objdata_u.ta_data));
195 	case NIS_ENTRY_OBJ:
196 		return (xdr_entry_obj(xdrs, &objp->objdata_u.en_data));
197 	case NIS_LINK_OBJ:
198 		return (xdr_link_obj(xdrs, &objp->objdata_u.li_data));
199 	case NIS_PRIVATE_OBJ:
200 		return (xdr_bytes(xdrs,
201 			(char **)&objp->objdata_u.po_data.po_data_val,
202 			(uint_t *)&objp->objdata_u.po_data.po_data_len, ~0));
203 	case NIS_NO_OBJ:
204 		return (TRUE);
205 	case NIS_BOGUS_OBJ:
206 		return (TRUE);
207 	}
208 	return (TRUE);
209 }
210 
211 bool_t
212 xdr_nis_oid(XDR *xdrs, nis_oid *objp)
213 {
214 	if (!xdr_uint32_t(xdrs, &objp->ctime))
215 		return (FALSE);
216 	return (xdr_uint32_t(xdrs, &objp->mtime));
217 }
218 
219 bool_t
220 xdr_nis_object(XDR *xdrs, nis_object *objp)
221 {
222 	if (!xdr_nis_oid(xdrs, &objp->zo_oid))
223 		return (FALSE);
224 	if (!xdr_nis_name(xdrs, &objp->zo_name))
225 		return (FALSE);
226 	if (!xdr_nis_name(xdrs, &objp->zo_owner))
227 		return (FALSE);
228 	if (!xdr_nis_name(xdrs, &objp->zo_group))
229 		return (FALSE);
230 	if (!xdr_nis_name(xdrs, &objp->zo_domain))
231 		return (FALSE);
232 	if (!xdr_u_int(xdrs, &objp->zo_access))
233 		return (FALSE);
234 	if (!xdr_uint32_t(xdrs, &objp->zo_ttl))
235 		return (FALSE);
236 	return (xdr_objdata(xdrs, &objp->zo_data));
237 }
238 
239 bool_t
240 xdr_nis_error(XDR *xdrs, nis_error *objp)
241 {
242 	return (xdr_enum(xdrs, (enum_t *)objp));
243 }
244 
245 bool_t
246 xdr_nis_result(XDR *xdrs, nis_result *objp)
247 {
248 	if (!xdr_nis_error(xdrs, &objp->status))
249 		return (FALSE);
250 	if (!xdr_array(xdrs, (char **)&objp->objects.objects_val,
251 			(uint_t *)&objp->objects.objects_len, ~0,
252 			sizeof (nis_object), (xdrproc_t)xdr_nis_object))
253 		return (FALSE);
254 	if (!xdr_netobj(xdrs, &objp->cookie))
255 		return (FALSE);
256 	if (!xdr_uint32_t(xdrs, &objp->zticks))
257 		return (FALSE);
258 	if (!xdr_uint32_t(xdrs, &objp->dticks))
259 		return (FALSE);
260 	if (!xdr_uint32_t(xdrs, &objp->aticks))
261 		return (FALSE);
262 	return (xdr_uint32_t(xdrs, &objp->cticks));
263 }
264 
265 bool_t
266 xdr_ns_request(XDR *xdrs, ns_request *objp)
267 {
268 	if (!xdr_nis_name(xdrs, &objp->ns_name))
269 		return (FALSE);
270 	return (xdr_array(xdrs, (char **)&objp->ns_object.ns_object_val,
271 		(uint_t *)&objp->ns_object.ns_object_len, 1,
272 		sizeof (nis_object), (xdrproc_t)xdr_nis_object));
273 }
274 
275 bool_t
276 xdr_ib_request(XDR *xdrs, ib_request *objp)
277 {
278 	if (!xdr_nis_name(xdrs, &objp->ibr_name))
279 		return (FALSE);
280 	if (!xdr_array(xdrs, (char **)&objp->ibr_srch.ibr_srch_val,
281 			(uint_t *)&objp->ibr_srch.ibr_srch_len, ~0,
282 			sizeof (nis_attr), (xdrproc_t)xdr_nis_attr))
283 		return (FALSE);
284 	if (!xdr_u_int(xdrs, &objp->ibr_flags))
285 		return (FALSE);
286 	if (!xdr_array(xdrs, (char **)&objp->ibr_obj.ibr_obj_val,
287 			(uint_t *)&objp->ibr_obj.ibr_obj_len, 1,
288 			sizeof (nis_object), (xdrproc_t)xdr_nis_object))
289 		return (FALSE);
290 	if (!xdr_array(xdrs, (char **)&objp->ibr_cbhost.ibr_cbhost_val,
291 			(uint_t *)&objp->ibr_cbhost.ibr_cbhost_len, 1,
292 			sizeof (nis_server), (xdrproc_t)xdr_nis_server))
293 		return (FALSE);
294 	if (!xdr_u_int(xdrs, &objp->ibr_bufsize))
295 		return (FALSE);
296 	return (xdr_netobj(xdrs, &objp->ibr_cookie));
297 }
298 
299 bool_t
300 xdr_ping_args(XDR *xdrs, ping_args *objp)
301 {
302 	if (!xdr_nis_name(xdrs, &objp->dir))
303 		return (FALSE);
304 	return (xdr_uint32_t(xdrs, &objp->stamp));
305 }
306 
307 bool_t
308 xdr_log_entry_t(XDR *xdrs, log_entry_t *objp)
309 {
310 	return (xdr_enum(xdrs, (enum_t *)objp));
311 }
312 
313 bool_t
314 xdr_log_entry(XDR *xdrs, log_entry *objp)
315 {
316 	if (!xdr_uint32_t(xdrs, &objp->le_time))
317 		return (FALSE);
318 	if (!xdr_log_entry_t(xdrs, &objp->le_type))
319 		return (FALSE);
320 	if (!xdr_nis_name(xdrs, &objp->le_princp))
321 		return (FALSE);
322 	if (!xdr_nis_name(xdrs, &objp->le_name))
323 		return (FALSE);
324 	if (!xdr_array(xdrs, (char **)&objp->le_attrs.le_attrs_val,
325 			(uint_t *)&objp->le_attrs.le_attrs_len, ~0,
326 			sizeof (nis_attr), (xdrproc_t)xdr_nis_attr))
327 		return (FALSE);
328 	return (xdr_nis_object(xdrs, &objp->le_object));
329 }
330 
331 bool_t
332 xdr_log_result(XDR *xdrs, log_result *objp)
333 {
334 	if (!xdr_nis_error(xdrs, &objp->lr_status))
335 		return (FALSE);
336 	if (!xdr_netobj(xdrs, &objp->lr_cookie))
337 		return (FALSE);
338 	return (xdr_array(xdrs, (char **)&objp->lr_entries.lr_entries_val,
339 		(uint_t *)&objp->lr_entries.lr_entries_len, ~0,
340 		sizeof (log_entry), (xdrproc_t)xdr_log_entry));
341 }
342 
343 bool_t
344 xdr_cp_result(XDR *xdrs, cp_result *objp)
345 {
346 	if (!xdr_nis_error(xdrs, &objp->cp_status))
347 		return (FALSE);
348 	if (!xdr_uint32_t(xdrs, &objp->cp_zticks))
349 		return (FALSE);
350 	return (xdr_uint32_t(xdrs, &objp->cp_dticks));
351 }
352 
353 bool_t
354 xdr_nis_tag(XDR *xdrs, nis_tag *objp)
355 {
356 	if (!xdr_u_int(xdrs, &objp->tag_type))
357 		return (FALSE);
358 	return (xdr_string(xdrs, &objp->tag_val, ~0));
359 }
360 
361 bool_t
362 xdr_nis_taglist(XDR *xdrs, nis_taglist *objp)
363 {
364 	return (xdr_array(xdrs, (char **)&objp->tags.tags_val,
365 		(uint_t *)&objp->tags.tags_len, ~0,
366 		sizeof (nis_tag), (xdrproc_t)xdr_nis_tag));
367 }
368 
369 bool_t
370 xdr_dump_args(XDR *xdrs, dump_args *objp)
371 {
372 	if (!xdr_nis_name(xdrs, &objp->da_dir))
373 		return (FALSE);
374 	if (!xdr_uint32_t(xdrs, &objp->da_time))
375 		return (FALSE);
376 	return (xdr_array(xdrs, (char **)&objp->da_cbhost.da_cbhost_val,
377 		(uint_t *)&objp->da_cbhost.da_cbhost_len, 1,
378 		sizeof (nis_server), (xdrproc_t)xdr_nis_server));
379 }
380 
381 bool_t
382 xdr_fd_args(XDR *xdrs, fd_args *objp)
383 {
384 	if (!xdr_nis_name(xdrs, &objp->dir_name))
385 		return (FALSE);
386 	return (xdr_nis_name(xdrs, &objp->requester));
387 }
388 
389 bool_t
390 xdr_fd_result(XDR *xdrs, fd_result *objp)
391 {
392 	if (!xdr_nis_error(xdrs, &objp->status))
393 		return (FALSE);
394 	if (!xdr_nis_name(xdrs, &objp->source))
395 		return (FALSE);
396 	if (!xdr_bytes(xdrs, (char **)&objp->dir_data.dir_data_val,
397 			(uint_t *)&objp->dir_data.dir_data_len, ~0))
398 		return (FALSE);
399 	return (xdr_bytes(xdrs, (char **)&objp->signature.signature_val,
400 		(uint_t *)&objp->signature.signature_len, ~0));
401 }
402 /*
403  * Structures used for server binding.
404  */
405 
406 bool_t
407 xdr_nis_bound_endpoint(XDR *xdrs, nis_bound_endpoint *objp)
408 {
409 	rpc_inline_t *buf;
410 
411 	if (xdrs->x_op == XDR_ENCODE) {
412 		if (!xdr_endpoint(xdrs, &objp->ep))
413 			return (FALSE);
414 		buf = XDR_INLINE(xdrs, 5 * BYTES_PER_XDR_UNIT);
415 		if (buf == NULL) {
416 			if (!xdr_int(xdrs, &objp->generation))
417 				return (FALSE);
418 			if (!xdr_int(xdrs, &objp->rank))
419 				return (FALSE);
420 			if (!xdr_u_int(xdrs, &objp->flags))
421 				return (FALSE);
422 			if (!xdr_int(xdrs, &objp->hostnum))
423 				return (FALSE);
424 			if (!xdr_int(xdrs, &objp->epnum))
425 				return (FALSE);
426 
427 		} else {
428 #if defined(_LP64)
429 			IXDR_PUT_INT32(buf, objp->generation);
430 			IXDR_PUT_INT32(buf, objp->rank);
431 			IXDR_PUT_U_INT32(buf, objp->flags);
432 			IXDR_PUT_INT32(buf, objp->hostnum);
433 			IXDR_PUT_INT32(buf, objp->epnum);
434 #else
435 			IXDR_PUT_LONG(buf, objp->generation);
436 			IXDR_PUT_LONG(buf, objp->rank);
437 			IXDR_PUT_U_LONG(buf, objp->flags);
438 			IXDR_PUT_LONG(buf, objp->hostnum);
439 			IXDR_PUT_LONG(buf, objp->epnum);
440 #endif
441 		}
442 		if (!xdr_nis_name(xdrs, &objp->uaddr))
443 			return (FALSE);
444 		return (xdr_endpoint(xdrs, &objp->cbep));
445 	}
446 	if (xdrs->x_op == XDR_DECODE) {
447 		if (!xdr_endpoint(xdrs, &objp->ep))
448 			return (FALSE);
449 		buf = XDR_INLINE(xdrs, 5 * BYTES_PER_XDR_UNIT);
450 		if (buf == NULL) {
451 			if (!xdr_int(xdrs, &objp->generation))
452 				return (FALSE);
453 			if (!xdr_int(xdrs, &objp->rank))
454 				return (FALSE);
455 			if (!xdr_u_int(xdrs, &objp->flags))
456 				return (FALSE);
457 			if (!xdr_int(xdrs, &objp->hostnum))
458 				return (FALSE);
459 			if (!xdr_int(xdrs, &objp->epnum))
460 				return (FALSE);
461 
462 		} else {
463 #if defined(_LP64)
464 			objp->generation = IXDR_GET_INT32(buf);
465 			objp->rank = IXDR_GET_INT32(buf);
466 			objp->flags = IXDR_GET_U_INT32(buf);
467 			objp->hostnum = IXDR_GET_INT32(buf);
468 			objp->epnum = IXDR_GET_INT32(buf);
469 #else
470 			objp->generation = IXDR_GET_LONG(buf);
471 			objp->rank = IXDR_GET_LONG(buf);
472 			objp->flags = IXDR_GET_U_LONG(buf);
473 			objp->hostnum = IXDR_GET_LONG(buf);
474 			objp->epnum = IXDR_GET_LONG(buf);
475 #endif
476 		}
477 		if (!xdr_nis_name(xdrs, &objp->uaddr))
478 			return (FALSE);
479 		return (xdr_endpoint(xdrs, &objp->cbep));
480 	}
481 
482 	if (!xdr_endpoint(xdrs, &objp->ep))
483 		return (FALSE);
484 	if (!xdr_int(xdrs, &objp->generation))
485 		return (FALSE);
486 	if (!xdr_int(xdrs, &objp->rank))
487 		return (FALSE);
488 	if (!xdr_u_int(xdrs, &objp->flags))
489 		return (FALSE);
490 	if (!xdr_int(xdrs, &objp->hostnum))
491 		return (FALSE);
492 	if (!xdr_int(xdrs, &objp->epnum))
493 		return (FALSE);
494 	if (!xdr_nis_name(xdrs, &objp->uaddr))
495 		return (FALSE);
496 	return (xdr_endpoint(xdrs, &objp->cbep));
497 }
498 
499 bool_t
500 xdr_nis_bound_directory(XDR *xdrs, nis_bound_directory *objp)
501 {
502 	if (!xdr_int(xdrs, &objp->generation))
503 		return (FALSE);
504 	if (!xdr_int(xdrs, &objp->min_rank))
505 		return (FALSE);
506 	if (!xdr_int(xdrs, &objp->optimal_rank))
507 		return (FALSE);
508 	if (!xdr_directory_obj(xdrs, &objp->dobj))
509 		return (FALSE);
510 	return (xdr_array(xdrs, (char **)&objp->BEP.BEP_val,
511 		(uint_t *)&objp->BEP.BEP_len, ~0,
512 		sizeof (nis_bound_endpoint),
513 		(xdrproc_t)xdr_nis_bound_endpoint));
514 }
515 
516 bool_t
517 xdr_nis_active_endpoint(XDR *xdrs, nis_active_endpoint *objp)
518 {
519 	if (!xdr_endpoint(xdrs, &objp->ep))
520 		return (FALSE);
521 	if (!xdr_nis_name(xdrs, &objp->hostname))
522 		return (FALSE);
523 	if (!xdr_int(xdrs, &objp->rank))
524 		return (FALSE);
525 	if (!xdr_int(xdrs, &objp->uaddr_generation))
526 		return (FALSE);
527 	if (!xdr_nis_name(xdrs, &objp->uaddr))
528 		return (FALSE);
529 	if (!xdr_int(xdrs, &objp->cbep_generation))
530 		return (FALSE);
531 	return (xdr_endpoint(xdrs, &objp->cbep));
532 }
533