xref: /illumos-gate/usr/src/lib/libnsl/yp/yp_b_xdr.c (revision 1da57d551424de5a9d469760be7c4b4d4f10a755)
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 2006 Sun Microsystems, Inc.  All rights reserved.
25  * Use is subject to license terms.
26  */
27 
28 /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
29 /*	  All Rights Reserved   */
30 
31 /*
32  * Portions of this source code were derived from Berkeley
33  * under license from the Regents of the University of
34  * California.
35  */
36 
37 #include "mt.h"
38 #include <rpc/rpc.h>
39 #include <netconfig.h>
40 #include "yp_b.h"
41 #include <rpcsvc/yp_prot.h>
42 #include <sys/types.h>
43 
44 bool_t
xdr_ypbind_resptype(XDR * xdrs,ypbind_resptype * objp)45 xdr_ypbind_resptype(XDR *xdrs, ypbind_resptype *objp)
46 {
47 	return (xdr_enum(xdrs, (enum_t *)objp));
48 }
49 
50 bool_t
xdr_ypbind_domain(XDR * xdrs,ypbind_domain * objp)51 xdr_ypbind_domain(XDR *xdrs, ypbind_domain *objp)
52 {
53 	if (!xdr_string(xdrs, &objp->ypbind_domainname, YPMAXDOMAIN))
54 		return (FALSE);
55 	return (xdr_rpcvers(xdrs, &objp->ypbind_vers));
56 }
57 
58 bool_t
xdr_ypbind_binding(XDR * xdrs,ypbind_binding * objp)59 xdr_ypbind_binding(XDR *xdrs, ypbind_binding *objp)
60 {
61 	if (!xdr_pointer(xdrs, (char **)&objp->ypbind_nconf,
62 			sizeof (struct netconfig), xdr_netconfig))
63 		return (FALSE);
64 	if (!xdr_pointer(xdrs, (char **)&objp->ypbind_svcaddr,
65 			sizeof (struct netbuf), xdr_netbuf))
66 		return (FALSE);
67 	if (!xdr_string(xdrs, &objp->ypbind_servername, ~0))
68 		return (FALSE);
69 	if (!xdr_rpcvers(xdrs, &objp->ypbind_hi_vers))
70 		return (FALSE);
71 	return (xdr_rpcvers(xdrs, &objp->ypbind_lo_vers));
72 }
73 
74 bool_t
xdr_ypbind_resp(XDR * xdrs,ypbind_resp * objp)75 xdr_ypbind_resp(XDR *xdrs, ypbind_resp *objp)
76 {
77 	if (!xdr_ypbind_resptype(xdrs, &objp->ypbind_status))
78 		return (FALSE);
79 	switch (objp->ypbind_status) {
80 	case YPBIND_FAIL_VAL:
81 		if (!xdr_u_int(xdrs, &objp->ypbind_resp_u.ypbind_error))
82 			return (FALSE);
83 		break;
84 	case YPBIND_SUCC_VAL:
85 		if (!xdr_pointer(xdrs,
86 			(char **)&objp->ypbind_resp_u.ypbind_bindinfo,
87 			sizeof (ypbind_binding), xdr_ypbind_binding))
88 			return (FALSE);
89 		break;
90 	default:
91 		return (FALSE);
92 	}
93 	return (TRUE);
94 }
95 
96 bool_t
xdr_ypbind_setdom(XDR * xdrs,ypbind_setdom * objp)97 xdr_ypbind_setdom(XDR *xdrs, ypbind_setdom *objp)
98 {
99 	if (!xdr_string(xdrs, &objp->ypsetdom_domain, YPMAXDOMAIN))
100 		return (FALSE);
101 	return (xdr_pointer(xdrs, (char **)&objp->ypsetdom_bindinfo,
102 		sizeof (ypbind_binding), xdr_ypbind_binding));
103 }
104