]> git.ipfire.org Git - thirdparty/glibc.git/blob - nis/nis_xdr.c
Replace FSF snail mail address with URLs.
[thirdparty/glibc.git] / nis / nis_xdr.c
1 /* Copyright (c) 1997, 1998, 2005, 2006, 2007 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.
4
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.
9
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.
14
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/>. */
18
19 #include <rpcsvc/nis.h>
20 #include <rpcsvc/nis_callback.h> /* for "official" Solaris xdr functions */
21
22 /* This functions do exist without beginning "_" under Solaris 2.x, but
23 we have no prototypes for them. To avoid the same problems as with the
24 YP xdr functions, we don't make them public. */
25 #include "nis_xdr.h"
26
27 static bool_t
28 xdr_nis_attr (XDR *xdrs, nis_attr *objp)
29 {
30 bool_t res = xdr_string (xdrs, &objp->zattr_ndx, ~0);
31 if (__builtin_expect (res, TRUE))
32 res = xdr_bytes (xdrs, (char **) &objp->zattr_val.zattr_val_val,
33 &objp->zattr_val.zattr_val_len, ~0);
34 return res;
35 }
36
37 static __always_inline bool_t
38 xdr_nis_name (XDR *xdrs, nis_name *objp)
39 {
40 return xdr_string (xdrs, objp, ~0);
41 }
42
43 bool_t
44 _xdr_nis_name (XDR *xdrs, nis_name *objp)
45 {
46 return xdr_nis_name (xdrs, objp);
47 }
48
49 static __always_inline bool_t
50 xdr_zotypes (XDR *xdrs, zotypes *objp)
51 {
52 return xdr_enum (xdrs, (enum_t *) objp);
53 }
54
55 static __always_inline bool_t
56 xdr_nstype (XDR *xdrs, nstype *objp)
57 {
58 return xdr_enum (xdrs, (enum_t *) objp);
59 }
60
61 static bool_t
62 xdr_oar_mask (XDR *xdrs, oar_mask *objp)
63 {
64 bool_t res = xdr_u_int (xdrs, &objp->oa_rights);
65 if (__builtin_expect (res, TRUE))
66 res = xdr_zotypes (xdrs, &objp->oa_otype);
67 return res;
68 }
69
70 static bool_t
71 xdr_endpoint (XDR *xdrs, endpoint *objp)
72 {
73 bool_t res = xdr_string (xdrs, &objp->uaddr, ~0);
74 if (__builtin_expect (res, TRUE))
75 {
76 res = xdr_string (xdrs, &objp->family, ~0);
77 if (__builtin_expect (res, 1))
78 res = xdr_string (xdrs, &objp->proto, ~0);
79 }
80 return res;
81 }
82
83 bool_t
84 _xdr_nis_server (XDR *xdrs, nis_server *objp)
85 {
86 bool_t res = xdr_nis_name (xdrs, &objp->name);
87 if (__builtin_expect (res, TRUE))
88 {
89 res = xdr_array (xdrs, (void *) &objp->ep.ep_val, &objp->ep.ep_len,
90 ~0, sizeof (endpoint), (xdrproc_t) xdr_endpoint);
91 if (__builtin_expect (res, TRUE))
92 {
93 res = xdr_u_int (xdrs, &objp->key_type);
94 if (__builtin_expect (res, TRUE))
95 res = xdr_netobj (xdrs, &objp->pkey);
96 }
97 }
98 return res;
99 }
100
101 bool_t
102 _xdr_directory_obj (XDR *xdrs, directory_obj *objp)
103 {
104 bool_t res = xdr_nis_name (xdrs, &objp->do_name);
105 if (__builtin_expect (res, TRUE))
106 {
107 res = xdr_nstype (xdrs, &objp->do_type);
108 if (__builtin_expect (res, TRUE))
109 {
110 res = xdr_array (xdrs, (void *) &objp->do_servers.do_servers_val,
111 &objp->do_servers.do_servers_len, ~0,
112 sizeof (nis_server), (xdrproc_t) _xdr_nis_server);
113 if (__builtin_expect (res, TRUE))
114 {
115 res = xdr_uint32_t (xdrs, &objp->do_ttl);
116 if (__builtin_expect (res, TRUE))
117 res = xdr_array (xdrs,
118 (void *) &objp->do_armask.do_armask_val,
119 &objp->do_armask.do_armask_len, ~0,
120 sizeof (oar_mask), (xdrproc_t) xdr_oar_mask);
121 }
122 }
123 }
124 return res;
125 }
126
127 static bool_t
128 xdr_entry_col (XDR *xdrs, entry_col *objp)
129 {
130 bool_t res = xdr_u_int (xdrs, &objp->ec_flags);
131 if (__builtin_expect (res, TRUE))
132 res = xdr_bytes (xdrs, (char **) &objp->ec_value.ec_value_val,
133 &objp->ec_value.ec_value_len, ~0);
134 return res;
135 }
136
137 static bool_t
138 xdr_entry_obj (XDR *xdrs, entry_obj *objp)
139 {
140 bool_t res = xdr_string (xdrs, &objp->en_type, ~0);
141 if (__builtin_expect (res, TRUE))
142 res = xdr_array (xdrs, (void *) &objp->en_cols.en_cols_val,
143 &objp->en_cols.en_cols_len, ~0,
144 sizeof (entry_col), (xdrproc_t) xdr_entry_col);
145 return res;
146 }
147
148 static bool_t
149 xdr_group_obj (XDR *xdrs, group_obj *objp)
150 {
151 bool_t res = xdr_u_int (xdrs, &objp->gr_flags);
152 if (__builtin_expect (res, TRUE))
153 res = xdr_array (xdrs, (void *) &objp->gr_members.gr_members_val,
154 &objp->gr_members.gr_members_len, ~0,
155 sizeof (nis_name), (xdrproc_t) _xdr_nis_name);
156 return res;
157 }
158
159 static bool_t
160 xdr_link_obj (XDR *xdrs, link_obj *objp)
161 {
162 bool_t res = xdr_zotypes (xdrs, &objp->li_rtype);
163 if (__builtin_expect (res, TRUE))
164 {
165 res = xdr_array (xdrs, (void *) &objp->li_attrs.li_attrs_val,
166 &objp->li_attrs.li_attrs_len, ~0,
167 sizeof (nis_attr), (xdrproc_t) xdr_nis_attr);
168 if (__builtin_expect (res, TRUE))
169 res = xdr_nis_name (xdrs, &objp->li_name);
170 }
171 return res;
172 }
173
174 static bool_t
175 xdr_table_col (XDR *xdrs, table_col *objp)
176 {
177 bool_t res = xdr_string (xdrs, &objp->tc_name, 64);
178 if (__builtin_expect (res, TRUE))
179 {
180 res = xdr_u_int (xdrs, &objp->tc_flags);
181 if (__builtin_expect (res, TRUE))
182 res = xdr_u_int (xdrs, &objp->tc_rights);
183 }
184 return res;
185 }
186
187 static bool_t
188 xdr_table_obj (XDR *xdrs, table_obj *objp)
189 {
190 bool_t res = xdr_string (xdrs, &objp->ta_type, 64);
191 if (__builtin_expect (res, TRUE))
192 {
193 res = xdr_int (xdrs, &objp->ta_maxcol);
194 if (__builtin_expect (res, TRUE))
195 {
196 res = xdr_u_char (xdrs, &objp->ta_sep);
197 if (__builtin_expect (res, TRUE))
198 {
199 res = xdr_array (xdrs, (void *) &objp->ta_cols.ta_cols_val,
200 &objp->ta_cols.ta_cols_len, ~0,
201 sizeof (table_col), (xdrproc_t) xdr_table_col);
202 if (__builtin_expect (res, TRUE))
203 res = xdr_string (xdrs, &objp->ta_path, ~0);
204 }
205 }
206 }
207 return res;
208 }
209
210 static bool_t
211 xdr_objdata (XDR *xdrs, objdata *objp)
212 {
213 bool_t res = xdr_zotypes (xdrs, &objp->zo_type);
214 if (!__builtin_expect (res, TRUE))
215 return res;
216 switch (objp->zo_type)
217 {
218 case NIS_DIRECTORY_OBJ:
219 return _xdr_directory_obj (xdrs, &objp->objdata_u.di_data);
220 case NIS_GROUP_OBJ:
221 return xdr_group_obj (xdrs, &objp->objdata_u.gr_data);
222 case NIS_TABLE_OBJ:
223 return xdr_table_obj (xdrs, &objp->objdata_u.ta_data);
224 case NIS_ENTRY_OBJ:
225 return xdr_entry_obj (xdrs, &objp->objdata_u.en_data);
226 case NIS_LINK_OBJ:
227 return xdr_link_obj (xdrs, &objp->objdata_u.li_data);
228 case NIS_PRIVATE_OBJ:
229 return xdr_bytes (xdrs, &objp->objdata_u.po_data.po_data_val,
230 &objp->objdata_u.po_data.po_data_len, ~0);
231 case NIS_NO_OBJ:
232 case NIS_BOGUS_OBJ:
233 default:
234 return TRUE;
235 }
236 }
237
238 static bool_t
239 xdr_nis_oid (XDR *xdrs, nis_oid *objp)
240 {
241 bool_t res = xdr_uint32_t (xdrs, &objp->ctime);
242 if (__builtin_expect (res, TRUE))
243 res = xdr_uint32_t (xdrs, &objp->mtime);
244 return res;
245 }
246
247 bool_t
248 _xdr_nis_object (XDR *xdrs, nis_object *objp)
249 {
250 bool_t res = xdr_nis_oid (xdrs, &objp->zo_oid);
251 if (__builtin_expect (res, TRUE))
252 {
253 res = xdr_nis_name (xdrs, &objp->zo_name);
254 if (__builtin_expect (res, TRUE))
255 {
256 res = xdr_nis_name (xdrs, &objp->zo_owner);
257 if (__builtin_expect (res, TRUE))
258 {
259 res = xdr_nis_name (xdrs, &objp->zo_group);
260 if (__builtin_expect (res, TRUE))
261 {
262 res = xdr_nis_name (xdrs, &objp->zo_domain);
263 if (__builtin_expect (res, TRUE))
264 {
265 res = xdr_u_int (xdrs, &objp->zo_access);
266 if (__builtin_expect (res, TRUE))
267 {
268 res = xdr_uint32_t (xdrs, &objp->zo_ttl);
269 if (__builtin_expect (res, TRUE))
270 res = xdr_objdata (xdrs, &objp->zo_data);
271 }
272 }
273 }
274 }
275 }
276 }
277 return res;
278 }
279
280 static __always_inline bool_t
281 xdr_nis_error (XDR *xdrs, nis_error *objp)
282 {
283 return xdr_enum (xdrs, (enum_t *) objp);
284 }
285
286 bool_t
287 _xdr_nis_error (XDR *xdrs, nis_error *objp)
288 {
289 return xdr_nis_error (xdrs, objp);
290 }
291
292 bool_t
293 _xdr_nis_result (XDR *xdrs, nis_result *objp)
294 {
295 bool_t res = xdr_nis_error (xdrs, &objp->status);
296 if (__builtin_expect (res, TRUE))
297 {
298 res = xdr_array (xdrs, (void *) &objp->objects.objects_val,
299 &objp->objects.objects_len, ~0,
300 sizeof (nis_object), (xdrproc_t) _xdr_nis_object);
301 if (__builtin_expect (res, TRUE))
302 {
303 res = xdr_netobj (xdrs, &objp->cookie);
304 if (__builtin_expect (res, TRUE))
305 {
306 res = xdr_uint32_t (xdrs, &objp->zticks);
307 if (__builtin_expect (res, TRUE))
308 {
309 res = xdr_uint32_t (xdrs, &objp->dticks);
310 if (__builtin_expect (res, TRUE))
311 {
312 res = xdr_uint32_t (xdrs, &objp->aticks);
313 if (__builtin_expect (res, TRUE))
314 res = xdr_uint32_t (xdrs, &objp->cticks);
315 }
316 }
317 }
318 }
319 }
320 return res;
321 }
322 libnsl_hidden_def (_xdr_nis_result)
323
324 bool_t
325 _xdr_ns_request (XDR *xdrs, ns_request *objp)
326 {
327 bool_t res = xdr_nis_name (xdrs, &objp->ns_name);
328 if (__builtin_expect (res, TRUE))
329 res = xdr_array (xdrs, (void *) &objp->ns_object.ns_object_val,
330 &objp->ns_object.ns_object_len, 1,
331 sizeof (nis_object), (xdrproc_t) _xdr_nis_object);
332 return res;
333 }
334
335 bool_t
336 _xdr_ib_request (XDR *xdrs, ib_request *objp)
337 {
338 bool_t res = xdr_nis_name (xdrs, &objp->ibr_name);
339 if (__builtin_expect (res, TRUE))
340 {
341 res = xdr_array (xdrs, (void *) &objp->ibr_srch.ibr_srch_val,
342 &objp->ibr_srch.ibr_srch_len, ~0,
343 sizeof (nis_attr), (xdrproc_t) xdr_nis_attr);
344 if (__builtin_expect (res, TRUE))
345 {
346 res = xdr_u_int (xdrs, &objp->ibr_flags);
347 if (__builtin_expect (res, TRUE))
348 {
349 res = xdr_array (xdrs, (void *) &objp->ibr_obj.ibr_obj_val,
350 &objp->ibr_obj.ibr_obj_len, 1,
351 sizeof (nis_object),
352 (xdrproc_t) _xdr_nis_object);
353 if (__builtin_expect (res, TRUE))
354 {
355 res = xdr_array (xdrs,
356 (void *) &objp->ibr_cbhost.ibr_cbhost_val,
357 &objp->ibr_cbhost.ibr_cbhost_len, 1,
358 sizeof (nis_server),
359 (xdrproc_t) _xdr_nis_server);
360 if (__builtin_expect (res, TRUE))
361 {
362 res = xdr_u_int (xdrs, &objp->ibr_bufsize);
363 if (__builtin_expect (res, TRUE))
364 res = xdr_netobj (xdrs, &objp->ibr_cookie);
365 }
366 }
367 }
368 }
369 }
370 return res;
371 }
372 libnsl_hidden_def (_xdr_ib_request)
373
374 bool_t
375 _xdr_ping_args (XDR *xdrs, ping_args *objp)
376 {
377 bool_t res = xdr_nis_name (xdrs, &objp->dir);
378 if (__builtin_expect (res, TRUE))
379 res = xdr_uint32_t (xdrs, &objp->stamp);
380 return res;
381 }
382
383 bool_t
384 _xdr_cp_result (XDR *xdrs, cp_result *objp)
385 {
386 bool_t res = xdr_nis_error (xdrs, &objp->cp_status);
387 if (__builtin_expect (res, TRUE))
388 {
389 res = xdr_uint32_t (xdrs, &objp->cp_zticks);
390 if (__builtin_expect (res, TRUE))
391 res = xdr_uint32_t (xdrs, &objp->cp_dticks);
392 }
393 return res;
394 }
395
396 bool_t
397 _xdr_nis_tag (XDR *xdrs, nis_tag *objp)
398 {
399 bool_t res = xdr_u_int (xdrs, &objp->tag_type);
400 if (__builtin_expect (res, TRUE))
401 res = xdr_string (xdrs, &objp->tag_val, ~0);
402 return res;
403 }
404
405 bool_t
406 _xdr_nis_taglist (XDR *xdrs, nis_taglist *objp)
407 {
408 return xdr_array (xdrs, (void *) &objp->tags.tags_val,
409 &objp->tags.tags_len, ~0, sizeof (nis_tag),
410 (xdrproc_t) _xdr_nis_tag);
411 }
412
413 bool_t
414 _xdr_fd_args (XDR *xdrs, fd_args *objp)
415 {
416 bool_t res = xdr_nis_name (xdrs, &objp->dir_name);
417 if (__builtin_expect (res, TRUE))
418 res = xdr_nis_name (xdrs, &objp->requester);
419 return res;
420 }
421
422 bool_t
423 _xdr_fd_result (XDR *xdrs, fd_result *objp)
424 {
425 bool_t res = xdr_nis_error (xdrs, &objp->status);
426 if (__builtin_expect (res, TRUE))
427 {
428 res = xdr_nis_name (xdrs, &objp->source);
429 if (__builtin_expect (res, TRUE))
430 {
431 res = xdr_bytes (xdrs, (char **) &objp->dir_data.dir_data_val,
432 &objp->dir_data.dir_data_len, ~0);
433 if (__builtin_expect (res, TRUE))
434 res = xdr_bytes (xdrs, (char **) &objp->signature.signature_val,
435 &objp->signature.signature_len, ~0);
436 }
437 }
438 return res;
439 }
440
441 /* The following functions have prototypes in nis_callback.h. So
442 we make them public */
443 bool_t
444 xdr_obj_p (XDR *xdrs, obj_p *objp)
445 {
446 return xdr_pointer (xdrs, (char **)objp, sizeof (nis_object),
447 (xdrproc_t)_xdr_nis_object);
448 }
449 libnsl_hidden_def (xdr_obj_p)
450
451 bool_t
452 xdr_cback_data (XDR *xdrs, cback_data *objp)
453 {
454 return xdr_array (xdrs, (void *) &objp->entries.entries_val,
455 &objp->entries.entries_len, ~0,
456 sizeof (obj_p), (xdrproc_t) xdr_obj_p);
457 }
458 libnsl_hidden_def (xdr_cback_data)