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