1 /* Copyright (c) 1997-2018 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
20 #include <rpcsvc/nis.h>
21 #include <rpcsvc/nis_callback.h> /* for "official" Solaris xdr functions */
22 #include <shlib-compat.h>
24 /* This functions do exist without beginning "_" under Solaris 2.x, but
25 we have no prototypes for them. To avoid the same problems as with the
26 YP xdr functions, we don't make them public. */
30 xdr_nis_attr (XDR
*xdrs
, nis_attr
*objp
)
32 bool_t res
= xdr_string (xdrs
, &objp
->zattr_ndx
, ~0);
33 if (__builtin_expect (res
, TRUE
))
34 res
= xdr_bytes (xdrs
, (char **) &objp
->zattr_val
.zattr_val_val
,
35 &objp
->zattr_val
.zattr_val_len
, ~0);
39 static __always_inline bool_t
40 xdr_nis_name (XDR
*xdrs
, nis_name
*objp
)
42 return xdr_string (xdrs
, objp
, ~0);
46 _xdr_nis_name (XDR
*xdrs
, nis_name
*objp
)
48 return xdr_nis_name (xdrs
, objp
);
51 static __always_inline bool_t
52 xdr_zotypes (XDR
*xdrs
, zotypes
*objp
)
54 return xdr_enum (xdrs
, (enum_t
*) objp
);
57 static __always_inline bool_t
58 xdr_nstype (XDR
*xdrs
, nstype
*objp
)
60 return xdr_enum (xdrs
, (enum_t
*) objp
);
64 xdr_oar_mask (XDR
*xdrs
, oar_mask
*objp
)
66 bool_t res
= xdr_u_int (xdrs
, &objp
->oa_rights
);
67 if (__builtin_expect (res
, TRUE
))
68 res
= xdr_zotypes (xdrs
, &objp
->oa_otype
);
73 xdr_endpoint (XDR
*xdrs
, endpoint
*objp
)
75 bool_t res
= xdr_string (xdrs
, &objp
->uaddr
, ~0);
76 if (__builtin_expect (res
, TRUE
))
78 res
= xdr_string (xdrs
, &objp
->family
, ~0);
79 if (__glibc_likely (res
))
80 res
= xdr_string (xdrs
, &objp
->proto
, ~0);
86 _xdr_nis_server (XDR
*xdrs
, nis_server
*objp
)
88 bool_t res
= xdr_nis_name (xdrs
, &objp
->name
);
89 if (__builtin_expect (res
, TRUE
))
91 res
= xdr_array (xdrs
, (void *) &objp
->ep
.ep_val
, &objp
->ep
.ep_len
,
92 ~0, sizeof (endpoint
), (xdrproc_t
) xdr_endpoint
);
93 if (__builtin_expect (res
, TRUE
))
95 res
= xdr_u_int (xdrs
, &objp
->key_type
);
96 if (__builtin_expect (res
, TRUE
))
97 res
= xdr_netobj (xdrs
, &objp
->pkey
);
104 _xdr_directory_obj (XDR
*xdrs
, directory_obj
*objp
)
106 bool_t res
= xdr_nis_name (xdrs
, &objp
->do_name
);
107 if (__builtin_expect (res
, TRUE
))
109 res
= xdr_nstype (xdrs
, &objp
->do_type
);
110 if (__builtin_expect (res
, TRUE
))
112 res
= xdr_array (xdrs
, (void *) &objp
->do_servers
.do_servers_val
,
113 &objp
->do_servers
.do_servers_len
, ~0,
114 sizeof (nis_server
), (xdrproc_t
) _xdr_nis_server
);
115 if (__builtin_expect (res
, TRUE
))
117 res
= xdr_uint32_t (xdrs
, &objp
->do_ttl
);
118 if (__builtin_expect (res
, TRUE
))
119 res
= xdr_array (xdrs
,
120 (void *) &objp
->do_armask
.do_armask_val
,
121 &objp
->do_armask
.do_armask_len
, ~0,
122 sizeof (oar_mask
), (xdrproc_t
) xdr_oar_mask
);
130 xdr_entry_col (XDR
*xdrs
, entry_col
*objp
)
132 bool_t res
= xdr_u_int (xdrs
, &objp
->ec_flags
);
133 if (__builtin_expect (res
, TRUE
))
134 res
= xdr_bytes (xdrs
, (char **) &objp
->ec_value
.ec_value_val
,
135 &objp
->ec_value
.ec_value_len
, ~0);
140 xdr_entry_obj (XDR
*xdrs
, entry_obj
*objp
)
142 bool_t res
= xdr_string (xdrs
, &objp
->en_type
, ~0);
143 if (__builtin_expect (res
, TRUE
))
144 res
= xdr_array (xdrs
, (void *) &objp
->en_cols
.en_cols_val
,
145 &objp
->en_cols
.en_cols_len
, ~0,
146 sizeof (entry_col
), (xdrproc_t
) xdr_entry_col
);
151 xdr_group_obj (XDR
*xdrs
, group_obj
*objp
)
153 bool_t res
= xdr_u_int (xdrs
, &objp
->gr_flags
);
154 if (__builtin_expect (res
, TRUE
))
155 res
= xdr_array (xdrs
, (void *) &objp
->gr_members
.gr_members_val
,
156 &objp
->gr_members
.gr_members_len
, ~0,
157 sizeof (nis_name
), (xdrproc_t
) _xdr_nis_name
);
162 xdr_link_obj (XDR
*xdrs
, link_obj
*objp
)
164 bool_t res
= xdr_zotypes (xdrs
, &objp
->li_rtype
);
165 if (__builtin_expect (res
, TRUE
))
167 res
= xdr_array (xdrs
, (void *) &objp
->li_attrs
.li_attrs_val
,
168 &objp
->li_attrs
.li_attrs_len
, ~0,
169 sizeof (nis_attr
), (xdrproc_t
) xdr_nis_attr
);
170 if (__builtin_expect (res
, TRUE
))
171 res
= xdr_nis_name (xdrs
, &objp
->li_name
);
177 xdr_table_col (XDR
*xdrs
, table_col
*objp
)
179 bool_t res
= xdr_string (xdrs
, &objp
->tc_name
, 64);
180 if (__builtin_expect (res
, TRUE
))
182 res
= xdr_u_int (xdrs
, &objp
->tc_flags
);
183 if (__builtin_expect (res
, TRUE
))
184 res
= xdr_u_int (xdrs
, &objp
->tc_rights
);
190 xdr_table_obj (XDR
*xdrs
, table_obj
*objp
)
192 bool_t res
= xdr_string (xdrs
, &objp
->ta_type
, 64);
193 if (__builtin_expect (res
, TRUE
))
195 res
= xdr_int (xdrs
, &objp
->ta_maxcol
);
196 if (__builtin_expect (res
, TRUE
))
198 res
= xdr_u_char (xdrs
, &objp
->ta_sep
);
199 if (__builtin_expect (res
, TRUE
))
201 res
= xdr_array (xdrs
, (void *) &objp
->ta_cols
.ta_cols_val
,
202 &objp
->ta_cols
.ta_cols_len
, ~0,
203 sizeof (table_col
), (xdrproc_t
) xdr_table_col
);
204 if (__builtin_expect (res
, TRUE
))
205 res
= xdr_string (xdrs
, &objp
->ta_path
, ~0);
213 xdr_objdata (XDR
*xdrs
, objdata
*objp
)
215 bool_t res
= xdr_zotypes (xdrs
, &objp
->zo_type
);
216 if (!__builtin_expect (res
, TRUE
))
218 switch (objp
->zo_type
)
220 case NIS_DIRECTORY_OBJ
:
221 return _xdr_directory_obj (xdrs
, &objp
->objdata_u
.di_data
);
223 return xdr_group_obj (xdrs
, &objp
->objdata_u
.gr_data
);
225 return xdr_table_obj (xdrs
, &objp
->objdata_u
.ta_data
);
227 return xdr_entry_obj (xdrs
, &objp
->objdata_u
.en_data
);
229 return xdr_link_obj (xdrs
, &objp
->objdata_u
.li_data
);
230 case NIS_PRIVATE_OBJ
:
231 return xdr_bytes (xdrs
, &objp
->objdata_u
.po_data
.po_data_val
,
232 &objp
->objdata_u
.po_data
.po_data_len
, ~0);
241 xdr_nis_oid (XDR
*xdrs
, nis_oid
*objp
)
243 bool_t res
= xdr_uint32_t (xdrs
, &objp
->ctime
);
244 if (__builtin_expect (res
, TRUE
))
245 res
= xdr_uint32_t (xdrs
, &objp
->mtime
);
250 _xdr_nis_object (XDR
*xdrs
, nis_object
*objp
)
252 bool_t res
= xdr_nis_oid (xdrs
, &objp
->zo_oid
);
253 if (__builtin_expect (res
, TRUE
))
255 res
= xdr_nis_name (xdrs
, &objp
->zo_name
);
256 if (__builtin_expect (res
, TRUE
))
258 res
= xdr_nis_name (xdrs
, &objp
->zo_owner
);
259 if (__builtin_expect (res
, TRUE
))
261 res
= xdr_nis_name (xdrs
, &objp
->zo_group
);
262 if (__builtin_expect (res
, TRUE
))
264 res
= xdr_nis_name (xdrs
, &objp
->zo_domain
);
265 if (__builtin_expect (res
, TRUE
))
267 res
= xdr_u_int (xdrs
, &objp
->zo_access
);
268 if (__builtin_expect (res
, TRUE
))
270 res
= xdr_uint32_t (xdrs
, &objp
->zo_ttl
);
271 if (__builtin_expect (res
, TRUE
))
272 res
= xdr_objdata (xdrs
, &objp
->zo_data
);
282 static __always_inline bool_t
283 xdr_nis_error (XDR
*xdrs
, nis_error
*objp
)
285 return xdr_enum (xdrs
, (enum_t
*) objp
);
289 _xdr_nis_error (XDR
*xdrs
, nis_error
*objp
)
291 return xdr_nis_error (xdrs
, objp
);
295 _xdr_nis_result (XDR
*xdrs
, nis_result
*objp
)
297 bool_t res
= xdr_nis_error (xdrs
, &objp
->status
);
298 if (__builtin_expect (res
, TRUE
))
300 res
= xdr_array (xdrs
, (void *) &objp
->objects
.objects_val
,
301 &objp
->objects
.objects_len
, ~0,
302 sizeof (nis_object
), (xdrproc_t
) _xdr_nis_object
);
303 if (__builtin_expect (res
, TRUE
))
305 res
= xdr_netobj (xdrs
, &objp
->cookie
);
306 if (__builtin_expect (res
, TRUE
))
308 res
= xdr_uint32_t (xdrs
, &objp
->zticks
);
309 if (__builtin_expect (res
, TRUE
))
311 res
= xdr_uint32_t (xdrs
, &objp
->dticks
);
312 if (__builtin_expect (res
, TRUE
))
314 res
= xdr_uint32_t (xdrs
, &objp
->aticks
);
315 if (__builtin_expect (res
, TRUE
))
316 res
= xdr_uint32_t (xdrs
, &objp
->cticks
);
324 libnsl_hidden_nolink_def (_xdr_nis_result
, GLIBC_PRIVATE
)
327 _xdr_ns_request (XDR
*xdrs
, ns_request
*objp
)
329 bool_t res
= xdr_nis_name (xdrs
, &objp
->ns_name
);
330 if (__builtin_expect (res
, TRUE
))
331 res
= xdr_array (xdrs
, (void *) &objp
->ns_object
.ns_object_val
,
332 &objp
->ns_object
.ns_object_len
, 1,
333 sizeof (nis_object
), (xdrproc_t
) _xdr_nis_object
);
338 _xdr_ib_request (XDR
*xdrs
, ib_request
*objp
)
340 bool_t res
= xdr_nis_name (xdrs
, &objp
->ibr_name
);
341 if (__builtin_expect (res
, TRUE
))
343 res
= xdr_array (xdrs
, (void *) &objp
->ibr_srch
.ibr_srch_val
,
344 &objp
->ibr_srch
.ibr_srch_len
, ~0,
345 sizeof (nis_attr
), (xdrproc_t
) xdr_nis_attr
);
346 if (__builtin_expect (res
, TRUE
))
348 res
= xdr_u_int (xdrs
, &objp
->ibr_flags
);
349 if (__builtin_expect (res
, TRUE
))
351 res
= xdr_array (xdrs
, (void *) &objp
->ibr_obj
.ibr_obj_val
,
352 &objp
->ibr_obj
.ibr_obj_len
, 1,
354 (xdrproc_t
) _xdr_nis_object
);
355 if (__builtin_expect (res
, TRUE
))
357 res
= xdr_array (xdrs
,
358 (void *) &objp
->ibr_cbhost
.ibr_cbhost_val
,
359 &objp
->ibr_cbhost
.ibr_cbhost_len
, 1,
361 (xdrproc_t
) _xdr_nis_server
);
362 if (__builtin_expect (res
, TRUE
))
364 res
= xdr_u_int (xdrs
, &objp
->ibr_bufsize
);
365 if (__builtin_expect (res
, TRUE
))
366 res
= xdr_netobj (xdrs
, &objp
->ibr_cookie
);
374 libnsl_hidden_nolink_def (_xdr_ib_request
, GLIBC_PRIVATE
)
377 _xdr_ping_args (XDR
*xdrs
, ping_args
*objp
)
379 bool_t res
= xdr_nis_name (xdrs
, &objp
->dir
);
380 if (__builtin_expect (res
, TRUE
))
381 res
= xdr_uint32_t (xdrs
, &objp
->stamp
);
386 _xdr_cp_result (XDR
*xdrs
, cp_result
*objp
)
388 bool_t res
= xdr_nis_error (xdrs
, &objp
->cp_status
);
389 if (__builtin_expect (res
, TRUE
))
391 res
= xdr_uint32_t (xdrs
, &objp
->cp_zticks
);
392 if (__builtin_expect (res
, TRUE
))
393 res
= xdr_uint32_t (xdrs
, &objp
->cp_dticks
);
399 _xdr_nis_tag (XDR
*xdrs
, nis_tag
*objp
)
401 bool_t res
= xdr_u_int (xdrs
, &objp
->tag_type
);
402 if (__builtin_expect (res
, TRUE
))
403 res
= xdr_string (xdrs
, &objp
->tag_val
, ~0);
408 _xdr_nis_taglist (XDR
*xdrs
, nis_taglist
*objp
)
410 return xdr_array (xdrs
, (void *) &objp
->tags
.tags_val
,
411 &objp
->tags
.tags_len
, ~0, sizeof (nis_tag
),
412 (xdrproc_t
) _xdr_nis_tag
);
416 _xdr_fd_args (XDR
*xdrs
, fd_args
*objp
)
418 bool_t res
= xdr_nis_name (xdrs
, &objp
->dir_name
);
419 if (__builtin_expect (res
, TRUE
))
420 res
= xdr_nis_name (xdrs
, &objp
->requester
);
425 _xdr_fd_result (XDR
*xdrs
, fd_result
*objp
)
427 bool_t res
= xdr_nis_error (xdrs
, &objp
->status
);
428 if (__builtin_expect (res
, TRUE
))
430 res
= xdr_nis_name (xdrs
, &objp
->source
);
431 if (__builtin_expect (res
, TRUE
))
433 res
= xdr_bytes (xdrs
, (char **) &objp
->dir_data
.dir_data_val
,
434 &objp
->dir_data
.dir_data_len
, ~0);
435 if (__builtin_expect (res
, TRUE
))
436 res
= xdr_bytes (xdrs
, (char **) &objp
->signature
.signature_val
,
437 &objp
->signature
.signature_len
, ~0);
443 /* The following functions have prototypes in nis_callback.h. So
444 we make them public */
446 xdr_obj_p (XDR
*xdrs
, obj_p
*objp
)
448 return xdr_pointer (xdrs
, (char **)objp
, sizeof (nis_object
),
449 (xdrproc_t
)_xdr_nis_object
);
451 libnsl_hidden_nolink_def (xdr_obj_p
, GLIBC_2_1
)
454 xdr_cback_data (XDR
*xdrs
, cback_data
*objp
)
456 return xdr_array (xdrs
, (void *) &objp
->entries
.entries_val
,
457 &objp
->entries
.entries_len
, ~0,
458 sizeof (obj_p
), (xdrproc_t
) xdr_obj_p
);
460 libnsl_hidden_nolink_def (xdr_cback_data
, GLIBC_2_1
)