Back to index

glibc  2.9
nis_xdr.c
Go to the documentation of this file.
00001 /* Copyright (c) 1997, 1998, 2005, 2006, 2007 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003    Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00019 
00020 #include <rpcsvc/nis.h>
00021 #include <rpcsvc/nis_callback.h> /* for "official" Solaris xdr functions */
00022 
00023 /* This functions do exist without beginning "_" under Solaris 2.x, but
00024    we have no prototypes for them. To avoid the same problems as with the
00025    YP xdr functions, we don't make them public. */
00026 #include "nis_xdr.h"
00027 
00028 static bool_t
00029 xdr_nis_attr (XDR *xdrs, nis_attr *objp)
00030 {
00031   bool_t res = xdr_string (xdrs, &objp->zattr_ndx, ~0);
00032   if (__builtin_expect (res, TRUE))
00033     res = xdr_bytes (xdrs, (char **) &objp->zattr_val.zattr_val_val,
00034                    &objp->zattr_val.zattr_val_len, ~0);
00035   return res;
00036 }
00037 
00038 static __always_inline bool_t
00039 xdr_nis_name (XDR *xdrs, nis_name *objp)
00040 {
00041   return xdr_string (xdrs, objp, ~0);
00042 }
00043 
00044 bool_t
00045 _xdr_nis_name (XDR *xdrs, nis_name *objp)
00046 {
00047   return xdr_nis_name (xdrs, objp);
00048 }
00049 
00050 static __always_inline bool_t
00051 xdr_zotypes (XDR *xdrs, zotypes *objp)
00052 {
00053   return xdr_enum (xdrs, (enum_t *) objp);
00054 }
00055 
00056 static __always_inline bool_t
00057 xdr_nstype (XDR *xdrs, nstype *objp)
00058 {
00059   return xdr_enum (xdrs, (enum_t *) objp);
00060 }
00061 
00062 static bool_t
00063 xdr_oar_mask (XDR *xdrs, oar_mask *objp)
00064 {
00065   bool_t res = xdr_u_int (xdrs, &objp->oa_rights);
00066   if (__builtin_expect (res, TRUE))
00067     res = xdr_zotypes (xdrs, &objp->oa_otype);
00068   return res;
00069 }
00070 
00071 static bool_t
00072 xdr_endpoint (XDR *xdrs, endpoint *objp)
00073 {
00074   bool_t res =  xdr_string (xdrs, &objp->uaddr, ~0);
00075   if (__builtin_expect (res, TRUE))
00076     {
00077       res = xdr_string (xdrs, &objp->family, ~0);
00078       if (__builtin_expect (res, 1))
00079        res = xdr_string (xdrs, &objp->proto, ~0);
00080     }
00081   return res;
00082 }
00083 
00084 bool_t
00085 _xdr_nis_server (XDR *xdrs, nis_server *objp)
00086 {
00087   bool_t res = xdr_nis_name (xdrs, &objp->name);
00088   if (__builtin_expect (res, TRUE))
00089     {
00090       res = xdr_array (xdrs, (void *) &objp->ep.ep_val, &objp->ep.ep_len,
00091                      ~0, sizeof (endpoint), (xdrproc_t) xdr_endpoint);
00092       if (__builtin_expect (res, TRUE))
00093        {
00094          res = xdr_u_int (xdrs, &objp->key_type);
00095          if (__builtin_expect (res, TRUE))
00096            res = xdr_netobj (xdrs, &objp->pkey);
00097        }
00098     }
00099   return res;
00100 }
00101 
00102 bool_t
00103 _xdr_directory_obj (XDR *xdrs, directory_obj *objp)
00104 {
00105   bool_t res = xdr_nis_name (xdrs, &objp->do_name);
00106   if (__builtin_expect (res, TRUE))
00107     {
00108       res = xdr_nstype (xdrs, &objp->do_type);
00109       if (__builtin_expect (res, TRUE))
00110        {
00111          res = xdr_array (xdrs, (void *) &objp->do_servers.do_servers_val,
00112                         &objp->do_servers.do_servers_len, ~0,
00113                         sizeof (nis_server), (xdrproc_t) _xdr_nis_server);
00114          if (__builtin_expect (res, TRUE))
00115            {
00116              res = xdr_uint32_t (xdrs, &objp->do_ttl);
00117              if (__builtin_expect (res, TRUE))
00118               res = xdr_array (xdrs,
00119                              (void *) &objp->do_armask.do_armask_val,
00120                              &objp->do_armask.do_armask_len, ~0,
00121                              sizeof (oar_mask), (xdrproc_t) xdr_oar_mask);
00122            }
00123        }
00124     }
00125   return res;
00126 }
00127 
00128 static bool_t
00129 xdr_entry_col (XDR *xdrs, entry_col *objp)
00130 {
00131   bool_t res = xdr_u_int (xdrs, &objp->ec_flags);
00132   if (__builtin_expect (res, TRUE))
00133     res = xdr_bytes (xdrs, (char **) &objp->ec_value.ec_value_val,
00134                    &objp->ec_value.ec_value_len, ~0);
00135   return res;
00136 }
00137 
00138 static bool_t
00139 xdr_entry_obj (XDR *xdrs, entry_obj *objp)
00140 {
00141   bool_t res = xdr_string (xdrs, &objp->en_type, ~0);
00142   if (__builtin_expect (res, TRUE))
00143     res = xdr_array (xdrs, (void *) &objp->en_cols.en_cols_val,
00144                    &objp->en_cols.en_cols_len, ~0,
00145                    sizeof (entry_col), (xdrproc_t) xdr_entry_col);
00146   return res;
00147 }
00148 
00149 static bool_t
00150 xdr_group_obj (XDR *xdrs, group_obj *objp)
00151 {
00152   bool_t res = xdr_u_int (xdrs, &objp->gr_flags);
00153   if (__builtin_expect (res, TRUE))
00154     res = xdr_array (xdrs, (void *) &objp->gr_members.gr_members_val,
00155                    &objp->gr_members.gr_members_len, ~0,
00156                    sizeof (nis_name), (xdrproc_t) _xdr_nis_name);
00157   return res;
00158 }
00159 
00160 static bool_t
00161 xdr_link_obj (XDR *xdrs, link_obj *objp)
00162 {
00163   bool_t res = xdr_zotypes (xdrs, &objp->li_rtype);
00164   if (__builtin_expect (res, TRUE))
00165     {
00166       res = xdr_array (xdrs, (void *) &objp->li_attrs.li_attrs_val,
00167                      &objp->li_attrs.li_attrs_len, ~0,
00168                      sizeof (nis_attr), (xdrproc_t) xdr_nis_attr);
00169       if (__builtin_expect (res, TRUE))
00170        res = xdr_nis_name (xdrs, &objp->li_name);
00171     }
00172   return res;
00173 }
00174 
00175 static bool_t
00176 xdr_table_col (XDR *xdrs, table_col *objp)
00177 {
00178   bool_t res = xdr_string (xdrs, &objp->tc_name, 64);
00179   if (__builtin_expect (res, TRUE))
00180     {
00181       res = xdr_u_int (xdrs, &objp->tc_flags);
00182       if (__builtin_expect (res, TRUE))
00183        res = xdr_u_int (xdrs, &objp->tc_rights);
00184     }
00185   return res;
00186 }
00187 
00188 static bool_t
00189 xdr_table_obj (XDR *xdrs, table_obj *objp)
00190 {
00191   bool_t res = xdr_string (xdrs, &objp->ta_type, 64);
00192   if (__builtin_expect (res, TRUE))
00193     {
00194       res = xdr_int (xdrs, &objp->ta_maxcol);
00195       if (__builtin_expect (res, TRUE))
00196        {
00197          res = xdr_u_char (xdrs, &objp->ta_sep);
00198          if (__builtin_expect (res, TRUE))
00199            {
00200              res = xdr_array (xdrs, (void *) &objp->ta_cols.ta_cols_val,
00201                             &objp->ta_cols.ta_cols_len, ~0,
00202                             sizeof (table_col), (xdrproc_t) xdr_table_col);
00203              if (__builtin_expect (res, TRUE))
00204               res = xdr_string (xdrs, &objp->ta_path, ~0);
00205            }
00206        }
00207     }
00208   return res;
00209 }
00210 
00211 static bool_t
00212 xdr_objdata (XDR *xdrs, objdata *objp)
00213 {
00214   bool_t res = xdr_zotypes (xdrs, &objp->zo_type);
00215   if (!__builtin_expect (res, TRUE))
00216     return res;
00217   switch (objp->zo_type)
00218     {
00219     case NIS_DIRECTORY_OBJ:
00220       return _xdr_directory_obj (xdrs, &objp->objdata_u.di_data);
00221     case NIS_GROUP_OBJ:
00222       return xdr_group_obj (xdrs, &objp->objdata_u.gr_data);
00223     case NIS_TABLE_OBJ:
00224       return xdr_table_obj (xdrs, &objp->objdata_u.ta_data);
00225     case NIS_ENTRY_OBJ:
00226       return xdr_entry_obj (xdrs, &objp->objdata_u.en_data);
00227     case NIS_LINK_OBJ:
00228       return xdr_link_obj (xdrs, &objp->objdata_u.li_data);
00229     case NIS_PRIVATE_OBJ:
00230       return xdr_bytes (xdrs, &objp->objdata_u.po_data.po_data_val,
00231                      &objp->objdata_u.po_data.po_data_len, ~0);
00232     case NIS_NO_OBJ:
00233     case NIS_BOGUS_OBJ:
00234     default:
00235       return TRUE;
00236     }
00237 }
00238 
00239 static bool_t
00240 xdr_nis_oid (XDR *xdrs, nis_oid *objp)
00241 {
00242   bool_t res = xdr_uint32_t (xdrs, &objp->ctime);
00243   if  (__builtin_expect (res, TRUE))
00244     res = xdr_uint32_t (xdrs, &objp->mtime);
00245   return res;
00246 }
00247 
00248 bool_t
00249 _xdr_nis_object (XDR *xdrs, nis_object *objp)
00250 {
00251   bool_t res = xdr_nis_oid (xdrs, &objp->zo_oid);
00252   if (__builtin_expect (res, TRUE))
00253     {
00254       res = xdr_nis_name (xdrs, &objp->zo_name);
00255       if (__builtin_expect (res, TRUE))
00256        {
00257          res = xdr_nis_name (xdrs, &objp->zo_owner);
00258          if (__builtin_expect (res, TRUE))
00259            {
00260              res = xdr_nis_name (xdrs, &objp->zo_group);
00261              if (__builtin_expect (res, TRUE))
00262               {
00263                 res = xdr_nis_name (xdrs, &objp->zo_domain);
00264                 if (__builtin_expect (res, TRUE))
00265                   {
00266                     res = xdr_u_int (xdrs, &objp->zo_access);
00267                     if (__builtin_expect (res, TRUE))
00268                      {
00269                        res = xdr_uint32_t (xdrs, &objp->zo_ttl);
00270                        if (__builtin_expect (res, TRUE))
00271                          res = xdr_objdata (xdrs, &objp->zo_data);
00272                      }
00273                   }
00274               }
00275            }
00276        }
00277     }
00278   return res;
00279 }
00280 
00281 static __always_inline bool_t
00282 xdr_nis_error (XDR *xdrs, nis_error *objp)
00283 {
00284   return xdr_enum (xdrs, (enum_t *) objp);
00285 }
00286 
00287 bool_t
00288 _xdr_nis_error (XDR *xdrs, nis_error *objp)
00289 {
00290   return xdr_nis_error (xdrs, objp);
00291 }
00292 
00293 bool_t
00294 _xdr_nis_result (XDR *xdrs, nis_result *objp)
00295 {
00296   bool_t res = xdr_nis_error (xdrs, &objp->status);
00297   if (__builtin_expect (res, TRUE))
00298     {
00299       res = xdr_array (xdrs, (void *) &objp->objects.objects_val,
00300                      &objp->objects.objects_len, ~0,
00301                      sizeof (nis_object), (xdrproc_t) _xdr_nis_object);
00302       if (__builtin_expect (res, TRUE))
00303        {
00304          res = xdr_netobj (xdrs, &objp->cookie);
00305          if (__builtin_expect (res, TRUE))
00306            {
00307              res = xdr_uint32_t (xdrs, &objp->zticks);
00308              if (__builtin_expect (res, TRUE))
00309               {
00310                 res = xdr_uint32_t (xdrs, &objp->dticks);
00311                 if (__builtin_expect (res, TRUE))
00312                   {
00313                     res = xdr_uint32_t (xdrs, &objp->aticks);
00314                     if (__builtin_expect (res, TRUE))
00315                      res = xdr_uint32_t (xdrs, &objp->cticks);
00316                   }
00317               }
00318            }
00319        }
00320     }
00321   return res;
00322 }
00323 libnsl_hidden_def (_xdr_nis_result)
00324 
00325 bool_t
00326 _xdr_ns_request (XDR *xdrs, ns_request *objp)
00327 {
00328   bool_t res = xdr_nis_name (xdrs, &objp->ns_name);
00329   if (__builtin_expect (res, TRUE))
00330     res = xdr_array (xdrs, (void *) &objp->ns_object.ns_object_val,
00331                    &objp->ns_object.ns_object_len, 1,
00332                    sizeof (nis_object), (xdrproc_t) _xdr_nis_object);
00333   return res;
00334 }
00335 
00336 bool_t
00337 _xdr_ib_request (XDR *xdrs, ib_request *objp)
00338 {
00339   bool_t res = xdr_nis_name (xdrs, &objp->ibr_name);
00340   if (__builtin_expect (res, TRUE))
00341     {
00342       res = xdr_array (xdrs, (void *) &objp->ibr_srch.ibr_srch_val,
00343                      &objp->ibr_srch.ibr_srch_len, ~0,
00344                      sizeof (nis_attr), (xdrproc_t) xdr_nis_attr);
00345       if (__builtin_expect (res, TRUE))
00346        {
00347          res = xdr_u_int (xdrs, &objp->ibr_flags);
00348          if (__builtin_expect (res, TRUE))
00349            {
00350              res = xdr_array (xdrs, (void *) &objp->ibr_obj.ibr_obj_val,
00351                             &objp->ibr_obj.ibr_obj_len, 1,
00352                             sizeof (nis_object),
00353                             (xdrproc_t) _xdr_nis_object);
00354              if (__builtin_expect (res, TRUE))
00355               {
00356                 res = xdr_array (xdrs,
00357                                (void *) &objp->ibr_cbhost.ibr_cbhost_val,
00358                                &objp->ibr_cbhost.ibr_cbhost_len, 1,
00359                                sizeof (nis_server),
00360                                (xdrproc_t) _xdr_nis_server);
00361                 if (__builtin_expect (res, TRUE))
00362                   {
00363                     res = xdr_u_int (xdrs, &objp->ibr_bufsize);
00364                     if (__builtin_expect (res, TRUE))
00365                      res =  xdr_netobj (xdrs, &objp->ibr_cookie);
00366                   }
00367               }
00368            }
00369        }
00370     }
00371   return res;
00372 }
00373 libnsl_hidden_def (_xdr_ib_request)
00374 
00375 bool_t
00376 _xdr_ping_args (XDR *xdrs, ping_args *objp)
00377 {
00378   bool_t res = xdr_nis_name (xdrs, &objp->dir);
00379   if (__builtin_expect (res, TRUE))
00380     res = xdr_uint32_t (xdrs, &objp->stamp);
00381   return res;
00382 }
00383 
00384 bool_t
00385 _xdr_cp_result (XDR *xdrs, cp_result *objp)
00386 {
00387   bool_t res = xdr_nis_error (xdrs, &objp->cp_status);
00388   if (__builtin_expect (res, TRUE))
00389     {
00390       res = xdr_uint32_t (xdrs, &objp->cp_zticks);
00391       if (__builtin_expect (res, TRUE))
00392        res = xdr_uint32_t (xdrs, &objp->cp_dticks);
00393     }
00394   return res;
00395 }
00396 
00397 bool_t
00398 _xdr_nis_tag (XDR *xdrs, nis_tag *objp)
00399 {
00400   bool_t res = xdr_u_int (xdrs, &objp->tag_type);
00401   if (__builtin_expect (res, TRUE))
00402     res = xdr_string (xdrs, &objp->tag_val, ~0);
00403   return res;
00404 }
00405 
00406 bool_t
00407 _xdr_nis_taglist (XDR *xdrs, nis_taglist *objp)
00408 {
00409   return xdr_array (xdrs, (void *) &objp->tags.tags_val,
00410                   &objp->tags.tags_len, ~0, sizeof (nis_tag),
00411                   (xdrproc_t) _xdr_nis_tag);
00412 }
00413 
00414 bool_t
00415 _xdr_fd_args (XDR *xdrs, fd_args *objp)
00416 {
00417   bool_t res = xdr_nis_name (xdrs, &objp->dir_name);
00418   if (__builtin_expect (res, TRUE))
00419     res = xdr_nis_name (xdrs, &objp->requester);
00420   return res;
00421 }
00422 
00423 bool_t
00424 _xdr_fd_result (XDR *xdrs, fd_result *objp)
00425 {
00426   bool_t res = xdr_nis_error (xdrs, &objp->status);
00427   if (__builtin_expect (res, TRUE))
00428     {
00429       res = xdr_nis_name (xdrs, &objp->source);
00430       if (__builtin_expect (res, TRUE))
00431        {
00432          res = xdr_bytes (xdrs, (char **) &objp->dir_data.dir_data_val,
00433                         &objp->dir_data.dir_data_len, ~0);
00434          if (__builtin_expect (res, TRUE))
00435            res = xdr_bytes (xdrs, (char **) &objp->signature.signature_val,
00436                           &objp->signature.signature_len, ~0);
00437        }
00438     }
00439   return res;
00440 }
00441 
00442 /* The following functions have prototypes in nis_callback.h.  So
00443    we make them public */
00444 bool_t
00445 xdr_obj_p (XDR *xdrs, obj_p *objp)
00446 {
00447   return xdr_pointer (xdrs, (char **)objp, sizeof (nis_object),
00448                     (xdrproc_t)_xdr_nis_object);
00449 }
00450 libnsl_hidden_def (xdr_obj_p)
00451 
00452 bool_t
00453 xdr_cback_data (XDR *xdrs, cback_data *objp)
00454 {
00455   return xdr_array (xdrs, (void *) &objp->entries.entries_val,
00456                   &objp->entries.entries_len, ~0,
00457                   sizeof (obj_p), (xdrproc_t) xdr_obj_p);
00458 }
00459 libnsl_hidden_def (xdr_cback_data)