Home | History | Annotate | Line # | Download | only in yp
xdryp.c revision 1.23
      1  1.23     lukem /*	$NetBSD: xdryp.c,v 1.23 1999/09/16 11:45:45 lukem Exp $	*/
      2   1.8       cgd 
      3   1.3   deraadt /*
      4  1.12   thorpej  * Copyright (c) 1996 Jason R. Thorpe <thorpej (at) NetBSD.ORG>.
      5  1.12   thorpej  * All rights reserved.
      6  1.12   thorpej  *
      7   1.6   deraadt  * Copyright (c) 1992, 1993 Theo de Raadt <deraadt (at) fsa.ca>
      8   1.3   deraadt  * All rights reserved.
      9   1.3   deraadt  *
     10   1.3   deraadt  * Redistribution and use in source and binary forms, with or without
     11   1.3   deraadt  * modification, are permitted provided that the following conditions
     12   1.3   deraadt  * are met:
     13   1.3   deraadt  * 1. Redistributions of source code must retain the above copyright
     14   1.3   deraadt  *    notice, this list of conditions and the following disclaimer.
     15   1.3   deraadt  * 2. Redistributions in binary form must reproduce the above copyright
     16   1.3   deraadt  *    notice, this list of conditions and the following disclaimer in the
     17   1.3   deraadt  *    documentation and/or other materials provided with the distribution.
     18   1.6   deraadt  * 3. All advertising materials mentioning features or use of this software
     19   1.6   deraadt  *    must display the following acknowledgement:
     20   1.6   deraadt  *	This product includes software developed by Theo de Raadt.
     21  1.12   thorpej  *	This product includes software developed for the NetBSD Project
     22  1.12   thorpej  *	by Jason R. Thorpe.
     23   1.6   deraadt  * 4. The name of the author may not be used to endorse or promote products
     24   1.6   deraadt  *    derived from this software without specific prior written permission.
     25   1.3   deraadt  *
     26   1.3   deraadt  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
     27   1.3   deraadt  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     28   1.3   deraadt  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     29   1.3   deraadt  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
     30   1.3   deraadt  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     31   1.3   deraadt  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     32   1.3   deraadt  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     33   1.3   deraadt  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     34   1.3   deraadt  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     35   1.3   deraadt  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     36   1.3   deraadt  * SUCH DAMAGE.
     37   1.3   deraadt  */
     38   1.3   deraadt 
     39  1.16  christos #include <sys/cdefs.h>
     40  1.10       jtc #if defined(LIBC_SCCS) && !defined(lint)
     41  1.23     lukem __RCSID("$NetBSD: xdryp.c,v 1.23 1999/09/16 11:45:45 lukem Exp $");
     42   1.3   deraadt #endif
     43   1.3   deraadt 
     44  1.12   thorpej /*
     45  1.12   thorpej  * XDR routines used by the YP protocol.  Note that these routines do
     46  1.12   thorpej  * not strictly conform to the RPC definition in yp.x.  This file
     47  1.12   thorpej  * replicates the functions exported by the Sun YP API; reality is
     48  1.12   thorpej  * often inaccurate.
     49  1.12   thorpej  */
     50  1.12   thorpej 
     51  1.17       jtc #include "namespace.h"
     52  1.23     lukem 
     53   1.1   deraadt #include <sys/param.h>
     54   1.1   deraadt #include <sys/socket.h>
     55  1.23     lukem 
     56  1.23     lukem #include <assert.h>
     57  1.23     lukem #include <ctype.h>
     58   1.1   deraadt #include <stdio.h>
     59   1.7       jtc #include <stdlib.h>
     60   1.7       jtc #include <string.h>
     61  1.23     lukem 
     62   1.1   deraadt #include <rpc/rpc.h>
     63   1.1   deraadt #include <rpc/xdr.h>
     64   1.1   deraadt #include <rpcsvc/yp_prot.h>
     65   1.1   deraadt #include <rpcsvc/ypclnt.h>
     66  1.17       jtc 
     67  1.17       jtc #ifdef __weak_alias
     68  1.17       jtc __weak_alias(xdr_datum,_xdr_datum);
     69  1.17       jtc __weak_alias(xdr_domainname,_xdr_domainname);
     70  1.17       jtc __weak_alias(xdr_mapname,_xdr_mapname);
     71  1.17       jtc __weak_alias(xdr_peername,_xdr_peername);
     72  1.17       jtc __weak_alias(xdr_yp_inaddr,_xdr_yp_inaddr);
     73  1.17       jtc __weak_alias(xdr_ypall,_xdr_ypall);
     74  1.17       jtc __weak_alias(xdr_ypbind_resp,_xdr_ypbind_resp);
     75  1.17       jtc __weak_alias(xdr_ypbind_setdom,_xdr_ypbind_setdom);
     76  1.17       jtc __weak_alias(xdr_ypdomain_wrap_string,_xdr_ypdomain_wrap_string);
     77  1.17       jtc __weak_alias(xdr_ypmap_parms,_xdr_ypmap_parms);
     78  1.17       jtc __weak_alias(xdr_ypmap_wrap_string,_xdr_ypmap_wrap_string);
     79  1.17       jtc __weak_alias(xdr_ypmaplist,_xdr_ypmaplist);
     80  1.17       jtc __weak_alias(xdr_ypowner_wrap_string,_xdr_ypowner_wrap_string);
     81  1.17       jtc __weak_alias(xdr_yppushresp_xfr,_xdr_yppushresp_xfr);
     82  1.17       jtc __weak_alias(xdr_ypreq_key,_xdr_ypreq_key);
     83  1.17       jtc __weak_alias(xdr_ypreq_nokey,_xdr_ypreq_nokey);
     84  1.17       jtc __weak_alias(xdr_ypreq_xfr,_xdr_ypreq_xfr);
     85  1.17       jtc __weak_alias(xdr_ypresp_key_val,_xdr_ypresp_key_val);
     86  1.17       jtc __weak_alias(xdr_ypresp_maplist,_xdr_ypresp_maplist);
     87  1.17       jtc __weak_alias(xdr_ypresp_master,_xdr_ypresp_master);
     88  1.17       jtc __weak_alias(xdr_ypresp_order,_xdr_ypresp_order);
     89  1.17       jtc __weak_alias(xdr_ypresp_val,_xdr_ypresp_val);
     90  1.17       jtc #endif
     91   1.1   deraadt 
     92  1.12   thorpej /*
     93  1.12   thorpej  * Functions used only within this file.
     94  1.12   thorpej  */
     95  1.12   thorpej static	bool_t xdr_ypbind_binding __P((XDR *, struct ypbind_binding *));
     96  1.12   thorpej static	bool_t xdr_ypbind_resptype __P((XDR *, enum ypbind_resptype *));
     97  1.12   thorpej static	bool_t xdr_ypstat __P((XDR *, enum ypbind_resptype *));
     98  1.12   thorpej static	bool_t xdr_ypmaplist_str __P((XDR *, char *));
     99  1.12   thorpej 
    100  1.19   thorpej __warn_references(xdr_domainname,
    101  1.20   thorpej     "warning: this program uses xdr_domainname(), which is deprecated and buggy.")
    102  1.19   thorpej 
    103  1.19   thorpej bool_t
    104  1.19   thorpej xdr_domainname(xdrs, objp)
    105  1.19   thorpej 	XDR *xdrs;
    106  1.19   thorpej 	char *objp;
    107  1.19   thorpej {
    108  1.23     lukem 
    109  1.23     lukem 	_DIAGASSERT(xdrs != NULL);
    110  1.23     lukem 	_DIAGASSERT(objp != NULL);
    111  1.23     lukem #ifdef _DIAGNOSTIC
    112  1.23     lukem 	if (xdrs == NULL || objp == NULL)
    113  1.23     lukem 		return FALSE;
    114  1.23     lukem #endif
    115  1.23     lukem 
    116  1.19   thorpej 	return xdr_string(xdrs, &objp, YPMAXDOMAIN);
    117  1.19   thorpej }
    118  1.19   thorpej 
    119  1.19   thorpej __warn_references(xdr_peername,
    120  1.20   thorpej     "warning: this program uses xdr_peername(), which is deprecated and buggy.")
    121  1.19   thorpej 
    122  1.19   thorpej bool_t
    123  1.19   thorpej xdr_peername(xdrs, objp)
    124  1.19   thorpej 	XDR *xdrs;
    125  1.19   thorpej 	char *objp;
    126  1.19   thorpej {
    127  1.23     lukem 
    128  1.23     lukem 	_DIAGASSERT(xdrs != NULL);
    129  1.23     lukem 	_DIAGASSERT(objp != NULL);
    130  1.23     lukem #ifdef _DIAGNOSTIC
    131  1.23     lukem 	if (xdrs == NULL || objp == NULL)
    132  1.23     lukem 		return FALSE;
    133  1.23     lukem #endif
    134  1.23     lukem 
    135  1.19   thorpej 	return xdr_string(xdrs, &objp, YPMAXPEER);
    136  1.19   thorpej }
    137  1.19   thorpej 
    138  1.19   thorpej __warn_references(xdr_mapname,
    139  1.20   thorpej     "warning: this program uses xdr_mapname(), which is deprecated and buggy.")
    140  1.19   thorpej 
    141  1.19   thorpej bool_t
    142  1.19   thorpej xdr_mapname(xdrs, objp)
    143  1.19   thorpej 	XDR *xdrs;
    144  1.19   thorpej 	char *objp;
    145  1.19   thorpej {
    146  1.23     lukem 
    147  1.23     lukem 	_DIAGASSERT(xdrs != NULL);
    148  1.23     lukem 	_DIAGASSERT(objp != NULL);
    149  1.23     lukem #ifdef _DIAGNOSTIC
    150  1.23     lukem 	if (xdrs == NULL || objp == NULL)
    151  1.23     lukem 		return FALSE;
    152  1.23     lukem #endif
    153  1.23     lukem 
    154  1.19   thorpej 	return xdr_string(xdrs, &objp, YPMAXMAP);
    155  1.19   thorpej }
    156  1.19   thorpej 
    157  1.12   thorpej bool_t
    158  1.12   thorpej xdr_ypdomain_wrap_string(xdrs, objp)
    159  1.12   thorpej 	XDR *xdrs;
    160  1.12   thorpej 	char **objp;
    161  1.12   thorpej {
    162  1.23     lukem 
    163  1.23     lukem 	_DIAGASSERT(xdrs != NULL);
    164  1.23     lukem 	_DIAGASSERT(objp != NULL);
    165  1.23     lukem #ifdef _DIAGNOSTIC
    166  1.23     lukem 	if (xdrs == NULL || objp == NULL)
    167  1.23     lukem 		return FALSE;
    168  1.23     lukem #endif
    169  1.23     lukem 
    170  1.12   thorpej 	return xdr_string(xdrs, objp, YPMAXDOMAIN);
    171  1.12   thorpej }
    172  1.12   thorpej 
    173  1.12   thorpej bool_t
    174  1.12   thorpej xdr_ypmap_wrap_string(xdrs, objp)
    175  1.12   thorpej 	XDR *xdrs;
    176  1.12   thorpej 	char **objp;
    177  1.12   thorpej {
    178  1.23     lukem 
    179  1.23     lukem 	_DIAGASSERT(xdrs != NULL);
    180  1.23     lukem 	_DIAGASSERT(objp != NULL);
    181  1.23     lukem #ifdef _DIAGNOSTIC
    182  1.23     lukem 	if (xdrs == NULL || objp == NULL)
    183  1.23     lukem 		return FALSE;
    184  1.23     lukem #endif
    185  1.23     lukem 
    186  1.12   thorpej 	return xdr_string(xdrs, objp, YPMAXMAP);
    187  1.12   thorpej }
    188  1.12   thorpej 
    189   1.1   deraadt bool_t
    190  1.12   thorpej xdr_ypowner_wrap_string(xdrs, objp)
    191  1.12   thorpej 	XDR *xdrs;
    192  1.12   thorpej 	char **objp;
    193   1.1   deraadt {
    194  1.23     lukem 
    195  1.23     lukem 	_DIAGASSERT(xdrs != NULL);
    196  1.23     lukem 	_DIAGASSERT(objp != NULL);
    197  1.23     lukem #ifdef _DIAGNOSTIC
    198  1.23     lukem 	if (xdrs == NULL || objp == NULL)
    199  1.23     lukem 		return FALSE;
    200  1.23     lukem #endif
    201  1.23     lukem 
    202  1.12   thorpej 	return xdr_string(xdrs, objp, YPMAXPEER);
    203   1.1   deraadt }
    204   1.1   deraadt 
    205   1.1   deraadt bool_t
    206  1.12   thorpej xdr_datum(xdrs, objp)
    207  1.12   thorpej 	XDR *xdrs;
    208  1.12   thorpej 	datum *objp;
    209   1.1   deraadt {
    210  1.23     lukem 
    211  1.23     lukem 	_DIAGASSERT(xdrs != NULL);
    212  1.23     lukem 	_DIAGASSERT(objp != NULL);
    213  1.23     lukem #ifdef _DIAGNOSTIC
    214  1.23     lukem 	if (xdrs == NULL || objp == NULL)
    215  1.23     lukem 		return FALSE;
    216  1.23     lukem #endif
    217  1.23     lukem 
    218  1.12   thorpej 	return xdr_bytes(xdrs, (char **)&objp->dptr,
    219  1.12   thorpej 	    (u_int *)&objp->dsize, YPMAXRECORD);
    220   1.1   deraadt }
    221   1.1   deraadt 
    222   1.1   deraadt bool_t
    223   1.1   deraadt xdr_ypreq_key(xdrs, objp)
    224  1.12   thorpej 	XDR *xdrs;
    225  1.12   thorpej 	struct ypreq_key *objp;
    226   1.1   deraadt {
    227  1.23     lukem 
    228  1.23     lukem 	_DIAGASSERT(xdrs != NULL);
    229  1.23     lukem 	_DIAGASSERT(objp != NULL);
    230  1.23     lukem #ifdef _DIAGNOSTIC
    231  1.23     lukem 	if (xdrs == NULL || objp == NULL)
    232  1.23     lukem 		return FALSE;
    233  1.23     lukem #endif
    234  1.23     lukem 
    235  1.13  christos 	if (!xdr_ypdomain_wrap_string(xdrs, (char **)&objp->domain))
    236   1.9  christos 		return FALSE;
    237  1.12   thorpej 
    238  1.13  christos 	if (!xdr_ypmap_wrap_string(xdrs, (char **)&objp->map))
    239   1.9  christos 		return FALSE;
    240  1.12   thorpej 
    241  1.13  christos 	if (!xdr_datum(xdrs, &objp->keydat))
    242  1.13  christos 		return FALSE;
    243  1.13  christos 
    244  1.13  christos 	return TRUE;
    245   1.1   deraadt }
    246   1.1   deraadt 
    247   1.1   deraadt bool_t
    248   1.1   deraadt xdr_ypreq_nokey(xdrs, objp)
    249  1.12   thorpej 	XDR *xdrs;
    250  1.12   thorpej 	struct ypreq_nokey *objp;
    251   1.1   deraadt {
    252  1.23     lukem 
    253  1.23     lukem 	_DIAGASSERT(xdrs != NULL);
    254  1.23     lukem 	_DIAGASSERT(objp != NULL);
    255  1.23     lukem #ifdef _DIAGNOSTIC
    256  1.23     lukem 	if (xdrs == NULL || objp == NULL)
    257  1.23     lukem 		return FALSE;
    258  1.23     lukem #endif
    259  1.23     lukem 
    260  1.13  christos 	if (!xdr_ypdomain_wrap_string(xdrs, (char **)&objp->domain))
    261  1.13  christos 		return FALSE;
    262  1.13  christos 
    263  1.13  christos 	if (!xdr_ypmap_wrap_string(xdrs, (char **)&objp->map))
    264   1.9  christos 		return FALSE;
    265  1.12   thorpej 
    266  1.13  christos 	return TRUE;
    267   1.1   deraadt }
    268   1.1   deraadt 
    269   1.1   deraadt bool_t
    270   1.1   deraadt xdr_yp_inaddr(xdrs, objp)
    271  1.12   thorpej 	XDR *xdrs;
    272  1.12   thorpej 	struct in_addr *objp;
    273   1.1   deraadt {
    274  1.23     lukem 
    275  1.23     lukem 	_DIAGASSERT(xdrs != NULL);
    276  1.23     lukem 	_DIAGASSERT(objp != NULL);
    277  1.23     lukem #ifdef _DIAGNOSTIC
    278  1.23     lukem 	if (xdrs == NULL || objp == NULL)
    279  1.23     lukem 		return FALSE;
    280  1.23     lukem #endif
    281  1.23     lukem 
    282  1.21  christos 	return xdr_opaque(xdrs, (caddr_t)(void *)&objp->s_addr,
    283  1.21  christos 	    sizeof objp->s_addr);
    284   1.1   deraadt }
    285   1.1   deraadt 
    286  1.12   thorpej static bool_t
    287   1.1   deraadt xdr_ypbind_binding(xdrs, objp)
    288  1.12   thorpej 	XDR *xdrs;
    289  1.12   thorpej 	struct ypbind_binding *objp;
    290   1.1   deraadt {
    291  1.23     lukem 
    292  1.23     lukem 	_DIAGASSERT(xdrs != NULL);
    293  1.23     lukem 	_DIAGASSERT(objp != NULL);
    294  1.23     lukem #ifdef _DIAGNOSTIC
    295  1.23     lukem 	if (xdrs == NULL || objp == NULL)
    296  1.23     lukem 		return FALSE;
    297  1.23     lukem #endif
    298  1.23     lukem 
    299  1.12   thorpej 	if (!xdr_yp_inaddr(xdrs, &objp->ypbind_binding_addr))
    300   1.9  christos 		return FALSE;
    301  1.12   thorpej 
    302  1.13  christos 	if (!xdr_opaque(xdrs, (void *)&objp->ypbind_binding_port,
    303  1.13  christos 	    sizeof objp->ypbind_binding_port))
    304  1.13  christos 		return FALSE;
    305  1.13  christos 
    306  1.13  christos 	return TRUE;
    307   1.1   deraadt }
    308   1.1   deraadt 
    309  1.12   thorpej static bool_t
    310   1.1   deraadt xdr_ypbind_resptype(xdrs, objp)
    311  1.12   thorpej 	XDR *xdrs;
    312  1.12   thorpej 	enum ypbind_resptype *objp;
    313   1.1   deraadt {
    314  1.23     lukem 
    315  1.23     lukem 	_DIAGASSERT(xdrs != NULL);
    316  1.23     lukem 	_DIAGASSERT(objp != NULL);
    317  1.23     lukem #ifdef _DIAGNOSTIC
    318  1.23     lukem 	if (xdrs == NULL || objp == NULL)
    319  1.23     lukem 		return FALSE;
    320  1.23     lukem #endif
    321  1.23     lukem 
    322   1.7       jtc 	return xdr_enum(xdrs, (enum_t *)objp);
    323   1.1   deraadt }
    324   1.1   deraadt 
    325  1.12   thorpej static bool_t
    326   1.1   deraadt xdr_ypstat(xdrs, objp)
    327  1.12   thorpej 	XDR *xdrs;
    328  1.12   thorpej 	enum ypbind_resptype *objp;
    329   1.1   deraadt {
    330  1.23     lukem 
    331  1.23     lukem 	_DIAGASSERT(xdrs != NULL);
    332  1.23     lukem 	_DIAGASSERT(objp != NULL);
    333  1.23     lukem #ifdef _DIAGNOSTIC
    334  1.23     lukem 	if (xdrs == NULL || objp == NULL)
    335  1.23     lukem 		return FALSE;
    336  1.23     lukem #endif
    337  1.23     lukem 
    338   1.7       jtc 	return xdr_enum(xdrs, (enum_t *)objp);
    339   1.1   deraadt }
    340   1.1   deraadt 
    341   1.1   deraadt bool_t
    342   1.1   deraadt xdr_ypbind_resp(xdrs, objp)
    343  1.12   thorpej 	XDR *xdrs;
    344  1.12   thorpej 	struct ypbind_resp *objp;
    345   1.1   deraadt {
    346  1.23     lukem 
    347  1.23     lukem 	_DIAGASSERT(xdrs != NULL);
    348  1.23     lukem 	_DIAGASSERT(objp != NULL);
    349  1.23     lukem #ifdef _DIAGNOSTIC
    350  1.23     lukem 	if (xdrs == NULL || objp == NULL)
    351  1.23     lukem 		return FALSE;
    352  1.23     lukem #endif
    353  1.23     lukem 
    354  1.12   thorpej 	if (!xdr_ypbind_resptype(xdrs, &objp->ypbind_status))
    355   1.9  christos 		return FALSE;
    356   1.9  christos 
    357   1.1   deraadt 	switch (objp->ypbind_status) {
    358   1.1   deraadt 	case YPBIND_FAIL_VAL:
    359   1.9  christos 		return xdr_u_int(xdrs,
    360  1.12   thorpej 		    (u_int *)&objp->ypbind_respbody.ypbind_error);
    361  1.12   thorpej 
    362   1.1   deraadt 	case YPBIND_SUCC_VAL:
    363  1.12   thorpej 		return xdr_ypbind_binding(xdrs,
    364  1.12   thorpej 		    &objp->ypbind_respbody.ypbind_bindinfo);
    365  1.12   thorpej 
    366   1.1   deraadt 	default:
    367   1.9  christos 		return FALSE;
    368   1.1   deraadt 	}
    369   1.7       jtc 	/* NOTREACHED */
    370   1.1   deraadt }
    371   1.1   deraadt 
    372   1.1   deraadt bool_t
    373   1.1   deraadt xdr_ypresp_val(xdrs, objp)
    374  1.12   thorpej 	XDR *xdrs;
    375  1.12   thorpej 	struct ypresp_val *objp;
    376   1.1   deraadt {
    377  1.23     lukem 
    378  1.23     lukem 	_DIAGASSERT(xdrs != NULL);
    379  1.23     lukem 	_DIAGASSERT(objp != NULL);
    380  1.23     lukem #ifdef _DIAGNOSTIC
    381  1.23     lukem 	if (xdrs == NULL || objp == NULL)
    382  1.23     lukem 		return FALSE;
    383  1.23     lukem #endif
    384  1.23     lukem 
    385  1.12   thorpej 	if (!xdr_ypstat(xdrs, (enum ypbind_resptype *)&objp->status))
    386   1.9  christos 		return FALSE;
    387  1.12   thorpej 
    388  1.13  christos 	if (!xdr_datum(xdrs, &objp->valdat))
    389  1.13  christos 		return FALSE;
    390  1.13  christos 
    391  1.13  christos 	return TRUE;
    392   1.1   deraadt }
    393   1.1   deraadt 
    394   1.1   deraadt bool_t
    395   1.1   deraadt xdr_ypbind_setdom(xdrs, objp)
    396  1.12   thorpej 	XDR *xdrs;
    397  1.12   thorpej 	struct ypbind_setdom *objp;
    398   1.1   deraadt {
    399  1.23     lukem 	char *cp;
    400  1.23     lukem 
    401  1.23     lukem 	_DIAGASSERT(xdrs != NULL);
    402  1.23     lukem 	_DIAGASSERT(objp != NULL);
    403  1.23     lukem #ifdef _DIAGNOSTIC
    404  1.23     lukem 	if (xdrs == NULL || objp == NULL)
    405  1.23     lukem 		return FALSE;
    406  1.23     lukem #endif
    407  1.23     lukem 
    408  1.23     lukem 	cp = objp->ypsetdom_domain;
    409  1.12   thorpej 
    410  1.13  christos 	if (!xdr_ypdomain_wrap_string(xdrs, &cp))
    411   1.9  christos 		return FALSE;
    412  1.12   thorpej 
    413  1.12   thorpej 	if (!xdr_ypbind_binding(xdrs, &objp->ypsetdom_binding))
    414   1.9  christos 		return FALSE;
    415  1.12   thorpej 
    416  1.14   thorpej 	if (!xdr_u_int(xdrs, &objp->ypsetdom_vers))
    417  1.13  christos 		return FALSE;
    418  1.13  christos 
    419  1.13  christos 	return TRUE;
    420   1.1   deraadt }
    421   1.1   deraadt 
    422   1.1   deraadt bool_t
    423   1.1   deraadt xdr_ypresp_key_val(xdrs, objp)
    424  1.12   thorpej 	XDR *xdrs;
    425  1.12   thorpej 	struct ypresp_key_val *objp;
    426   1.1   deraadt {
    427  1.23     lukem 
    428  1.23     lukem 	_DIAGASSERT(xdrs != NULL);
    429  1.23     lukem 	_DIAGASSERT(objp != NULL);
    430  1.23     lukem #ifdef _DIAGNOSTIC
    431  1.23     lukem 	if (xdrs == NULL || objp == NULL)
    432  1.23     lukem 		return FALSE;
    433  1.23     lukem #endif
    434  1.23     lukem 
    435  1.12   thorpej 	if (!xdr_ypstat(xdrs, (enum ypbind_resptype *)&objp->status))
    436   1.9  christos 		return FALSE;
    437  1.12   thorpej 
    438  1.12   thorpej 	if (!xdr_datum(xdrs, &objp->valdat))
    439   1.9  christos 		return FALSE;
    440  1.12   thorpej 
    441  1.13  christos 	if (!xdr_datum(xdrs, &objp->keydat))
    442  1.13  christos 		return FALSE;
    443  1.13  christos 
    444  1.13  christos 	return TRUE;
    445   1.1   deraadt }
    446   1.1   deraadt 
    447   1.1   deraadt bool_t
    448  1.12   thorpej xdr_ypall(xdrs, incallback)
    449  1.12   thorpej 	XDR *xdrs;
    450  1.12   thorpej 	struct ypall_callback *incallback;
    451  1.12   thorpej {
    452  1.12   thorpej 	struct ypresp_key_val out;
    453  1.12   thorpej 	char key[YPMAXRECORD], val[YPMAXRECORD];
    454  1.12   thorpej 	bool_t more, status;
    455   1.1   deraadt 
    456  1.23     lukem 	_DIAGASSERT(xdrs != NULL);
    457  1.23     lukem 	_DIAGASSERT(incallback != NULL);
    458  1.23     lukem #ifdef _DIAGNOSTIC
    459  1.23     lukem 	if (xdrs == NULL || incallback == NULL)
    460  1.23     lukem 		return FALSE;
    461  1.23     lukem #endif
    462  1.23     lukem 
    463  1.12   thorpej 	/*
    464  1.12   thorpej 	 * Set up key/val struct to be used during the transaction.
    465  1.12   thorpej 	 */
    466   1.7       jtc 	memset(&out, 0, sizeof out);
    467  1.12   thorpej 	out.keydat.dptr = key;
    468  1.12   thorpej 	out.keydat.dsize = sizeof(key);
    469  1.12   thorpej 	out.valdat.dptr = val;
    470  1.12   thorpej 	out.valdat.dsize = sizeof(val);
    471  1.12   thorpej 
    472  1.12   thorpej 	for (;;) {
    473  1.12   thorpej 		/* Values pending? */
    474  1.12   thorpej 		if (!xdr_bool(xdrs, &more))
    475  1.12   thorpej 			return FALSE;		/* can't tell! */
    476  1.13  christos 		if (!more)
    477  1.12   thorpej 			return TRUE;		/* no more */
    478  1.12   thorpej 
    479  1.12   thorpej 		/* Transfer key/value pair. */
    480  1.12   thorpej 		status = xdr_ypresp_key_val(xdrs, &out);
    481  1.12   thorpej 
    482  1.12   thorpej 		/*
    483  1.12   thorpej 		 * If we succeeded, call the callback function.
    484  1.12   thorpej 		 * The callback will return TRUE when it wants
    485  1.12   thorpej 		 * no more values.  If we fail, indicate the
    486  1.12   thorpej 		 * error.
    487  1.12   thorpej 		 */
    488  1.13  christos 		if (status) {
    489  1.21  christos 			/* LINTED const dropouts */
    490  1.21  christos 			if ((*incallback->foreach)((int)out.status,
    491  1.12   thorpej 			    (char *)out.keydat.dptr, out.keydat.dsize,
    492  1.12   thorpej 			    (char *)out.valdat.dptr, out.valdat.dsize,
    493  1.12   thorpej 			    incallback->data))
    494  1.12   thorpej 				return TRUE;
    495  1.12   thorpej 		} else
    496   1.1   deraadt 			return FALSE;
    497   1.1   deraadt 	}
    498   1.1   deraadt }
    499   1.1   deraadt 
    500   1.1   deraadt bool_t
    501   1.1   deraadt xdr_ypresp_master(xdrs, objp)
    502  1.12   thorpej 	XDR *xdrs;
    503  1.12   thorpej 	struct ypresp_master *objp;
    504   1.1   deraadt {
    505  1.23     lukem 
    506  1.23     lukem 	_DIAGASSERT(xdrs != NULL);
    507  1.23     lukem 	_DIAGASSERT(objp != NULL);
    508  1.23     lukem #ifdef _DIAGNOSTIC
    509  1.23     lukem 	if (xdrs == NULL || objp == NULL)
    510  1.23     lukem 		return FALSE;
    511  1.23     lukem #endif
    512  1.23     lukem 
    513  1.12   thorpej 	if (!xdr_ypstat(xdrs, (enum ypbind_resptype *)&objp->status))
    514   1.9  christos 		return FALSE;
    515  1.12   thorpej 
    516  1.13  christos 	if (!xdr_string(xdrs, &objp->master, YPMAXPEER))
    517  1.13  christos 		return FALSE;
    518  1.13  christos 
    519  1.13  christos 	return TRUE;
    520   1.1   deraadt }
    521   1.1   deraadt 
    522  1.12   thorpej static bool_t
    523   1.1   deraadt xdr_ypmaplist_str(xdrs, objp)
    524  1.12   thorpej 	XDR *xdrs;
    525  1.12   thorpej 	char *objp;
    526   1.1   deraadt {
    527  1.23     lukem 
    528  1.23     lukem 	_DIAGASSERT(xdrs != NULL);
    529  1.23     lukem 	_DIAGASSERT(objp != NULL);
    530  1.23     lukem #ifdef _DIAGNOSTIC
    531  1.23     lukem 	if (xdrs == NULL || objp == NULL)
    532  1.23     lukem 		return FALSE;
    533  1.23     lukem #endif
    534  1.23     lukem 
    535   1.7       jtc 	return xdr_string(xdrs, &objp, YPMAXMAP+1);
    536   1.1   deraadt }
    537   1.1   deraadt 
    538   1.1   deraadt bool_t
    539   1.1   deraadt xdr_ypmaplist(xdrs, objp)
    540  1.12   thorpej 	XDR *xdrs;
    541  1.12   thorpej 	struct ypmaplist *objp;
    542   1.1   deraadt {
    543  1.23     lukem 
    544  1.23     lukem 	_DIAGASSERT(xdrs != NULL);
    545  1.23     lukem 	_DIAGASSERT(objp != NULL);
    546  1.23     lukem #ifdef _DIAGNOSTIC
    547  1.23     lukem 	if (xdrs == NULL || objp == NULL)
    548  1.23     lukem 		return FALSE;
    549  1.23     lukem #endif
    550  1.23     lukem 
    551  1.12   thorpej 	if (!xdr_ypmaplist_str(xdrs, objp->ypml_name))
    552   1.9  christos 		return FALSE;
    553  1.12   thorpej 
    554  1.13  christos 	if (!xdr_pointer(xdrs, (caddr_t *)&objp->ypml_next,
    555  1.22  christos 	    sizeof(struct ypmaplist), (xdrproc_t)xdr_ypmaplist))
    556  1.13  christos 		return FALSE;
    557  1.13  christos 
    558  1.13  christos 	return TRUE;
    559   1.1   deraadt }
    560   1.1   deraadt 
    561   1.1   deraadt bool_t
    562   1.1   deraadt xdr_ypresp_maplist(xdrs, objp)
    563  1.12   thorpej 	XDR *xdrs;
    564  1.12   thorpej 	struct ypresp_maplist *objp;
    565   1.1   deraadt {
    566  1.23     lukem 
    567  1.23     lukem 	_DIAGASSERT(xdrs != NULL);
    568  1.23     lukem 	_DIAGASSERT(objp != NULL);
    569  1.23     lukem #ifdef _DIAGNOSTIC
    570  1.23     lukem 	if (xdrs == NULL || objp == NULL)
    571  1.23     lukem 		return FALSE;
    572  1.23     lukem #endif
    573  1.23     lukem 
    574  1.12   thorpej 	if (!xdr_ypstat(xdrs, (enum ypbind_resptype *)&objp->status))
    575   1.9  christos 		return FALSE;
    576  1.12   thorpej 
    577  1.13  christos 	if (!xdr_pointer(xdrs, (caddr_t *)&objp->list,
    578  1.22  christos 	    sizeof(struct ypmaplist), (xdrproc_t)xdr_ypmaplist))
    579  1.13  christos 		return FALSE;
    580  1.13  christos 
    581  1.13  christos 	return TRUE;
    582   1.1   deraadt }
    583   1.1   deraadt 
    584   1.1   deraadt bool_t
    585   1.1   deraadt xdr_ypresp_order(xdrs, objp)
    586  1.12   thorpej 	XDR *xdrs;
    587  1.12   thorpej 	struct ypresp_order *objp;
    588   1.1   deraadt {
    589  1.23     lukem 
    590  1.23     lukem 	_DIAGASSERT(xdrs != NULL);
    591  1.23     lukem 	_DIAGASSERT(objp != NULL);
    592  1.23     lukem #ifdef _DIAGNOSTIC
    593  1.23     lukem 	if (xdrs == NULL || objp == NULL)
    594  1.23     lukem 		return FALSE;
    595  1.23     lukem #endif
    596  1.23     lukem 
    597  1.12   thorpej 	if (!xdr_ypstat(xdrs, (enum ypbind_resptype *)&objp->status))
    598   1.9  christos 		return FALSE;
    599  1.12   thorpej 
    600  1.14   thorpej 	if (!xdr_u_int(xdrs, &objp->ordernum))
    601  1.13  christos 		return FALSE;
    602  1.13  christos 
    603  1.13  christos 	return TRUE;
    604  1.12   thorpej }
    605  1.12   thorpej 
    606  1.12   thorpej bool_t
    607  1.12   thorpej xdr_ypreq_xfr(xdrs, objp)
    608  1.12   thorpej 	XDR *xdrs;
    609  1.12   thorpej 	struct ypreq_xfr *objp;
    610  1.12   thorpej {
    611  1.23     lukem 
    612  1.23     lukem 	_DIAGASSERT(xdrs != NULL);
    613  1.23     lukem 	_DIAGASSERT(objp != NULL);
    614  1.23     lukem #ifdef _DIAGNOSTIC
    615  1.23     lukem 	if (xdrs == NULL || objp == NULL)
    616  1.23     lukem 		return FALSE;
    617  1.23     lukem #endif
    618  1.23     lukem 
    619  1.13  christos 	if (!xdr_ypmap_parms(xdrs, &objp->map_parms))
    620  1.12   thorpej 		return FALSE;
    621  1.12   thorpej 
    622  1.14   thorpej 	if (!xdr_u_int(xdrs, &objp->transid))
    623  1.12   thorpej 		return FALSE;
    624  1.12   thorpej 
    625  1.14   thorpej 	if (!xdr_u_int(xdrs, &objp->proto))
    626  1.12   thorpej 		return FALSE;
    627  1.12   thorpej 
    628  1.14   thorpej 	if (!xdr_u_int(xdrs, &objp->port))
    629  1.12   thorpej 		return FALSE;
    630  1.12   thorpej 
    631  1.12   thorpej 	return TRUE;
    632  1.12   thorpej }
    633  1.12   thorpej 
    634  1.12   thorpej bool_t
    635  1.12   thorpej xdr_ypmap_parms(xdrs, objp)
    636  1.12   thorpej 	XDR *xdrs;
    637  1.12   thorpej 	struct ypmap_parms *objp;
    638  1.12   thorpej {
    639  1.23     lukem 
    640  1.23     lukem 	_DIAGASSERT(xdrs != NULL);
    641  1.23     lukem 	_DIAGASSERT(objp != NULL);
    642  1.23     lukem #ifdef _DIAGNOSTIC
    643  1.23     lukem 	if (xdrs == NULL || objp == NULL)
    644  1.23     lukem 		return FALSE;
    645  1.23     lukem #endif
    646  1.23     lukem 
    647  1.15     chuck 	if (!xdr_ypdomain_wrap_string(xdrs, (char **)&objp->domain))
    648  1.12   thorpej 		return FALSE;
    649  1.12   thorpej 
    650  1.15     chuck 	if (!xdr_ypmap_wrap_string(xdrs, (char **)&objp->map))
    651  1.12   thorpej 		return FALSE;
    652  1.12   thorpej 
    653  1.14   thorpej 	if (!xdr_u_int(xdrs, &objp->ordernum))
    654  1.12   thorpej 		return FALSE;
    655  1.12   thorpej 
    656  1.13  christos 	if (!xdr_ypowner_wrap_string(xdrs, &objp->owner))
    657  1.12   thorpej 		return FALSE;
    658  1.12   thorpej 
    659  1.12   thorpej 	return TRUE;
    660  1.12   thorpej }
    661  1.12   thorpej 
    662  1.12   thorpej bool_t
    663  1.12   thorpej xdr_yppushresp_xfr(xdrs, objp)
    664  1.12   thorpej 	XDR *xdrs;
    665  1.12   thorpej 	struct yppushresp_xfr *objp;
    666  1.12   thorpej {
    667  1.23     lukem 
    668  1.23     lukem 	_DIAGASSERT(xdrs != NULL);
    669  1.23     lukem 	_DIAGASSERT(objp != NULL);
    670  1.23     lukem #ifdef _DIAGNOSTIC
    671  1.23     lukem 	if (xdrs == NULL || objp == NULL)
    672  1.23     lukem 		return FALSE;
    673  1.23     lukem #endif
    674  1.23     lukem 
    675  1.14   thorpej 	if (!xdr_u_int(xdrs, &objp->transid))
    676  1.12   thorpej 		return FALSE;
    677  1.12   thorpej 
    678  1.14   thorpej 	if (!xdr_enum(xdrs, (enum_t *)&objp->status))
    679  1.12   thorpej 		return FALSE;
    680  1.12   thorpej 
    681  1.12   thorpej 	return TRUE;
    682   1.1   deraadt }
    683