xref: /titanic_41/usr/src/lib/libnsl/yp/yp_b_xdr.c (revision 986fd29a0dc13f7608ef7f508f6e700bd7bc2720)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
38 
39 #include "mt.h"
40 #include <rpc/rpc.h>
41 #include <netconfig.h>
42 #include "yp_b.h"
43 #include <rpcsvc/yp_prot.h>
44 #include <sys/types.h>
45 
46 bool_t
47 xdr_ypbind_resptype(XDR *xdrs, ypbind_resptype *objp)
48 {
49 	return (xdr_enum(xdrs, (enum_t *)objp));
50 }
51 
52 bool_t
53 xdr_ypbind_domain(XDR *xdrs, ypbind_domain *objp)
54 {
55 	if (!xdr_string(xdrs, &objp->ypbind_domainname, YPMAXDOMAIN))
56 		return (FALSE);
57 	return (xdr_rpcvers(xdrs, &objp->ypbind_vers));
58 }
59 
60 bool_t
61 xdr_ypbind_binding(XDR *xdrs, ypbind_binding *objp)
62 {
63 	if (!xdr_pointer(xdrs, (char **)&objp->ypbind_nconf,
64 			sizeof (struct netconfig), xdr_netconfig))
65 		return (FALSE);
66 	if (!xdr_pointer(xdrs, (char **)&objp->ypbind_svcaddr,
67 			sizeof (struct netbuf), xdr_netbuf))
68 		return (FALSE);
69 	if (!xdr_string(xdrs, &objp->ypbind_servername, ~0))
70 		return (FALSE);
71 	if (!xdr_rpcvers(xdrs, &objp->ypbind_hi_vers))
72 		return (FALSE);
73 	return (xdr_rpcvers(xdrs, &objp->ypbind_lo_vers));
74 }
75 
76 bool_t
77 xdr_ypbind_resp(XDR *xdrs, ypbind_resp *objp)
78 {
79 	if (!xdr_ypbind_resptype(xdrs, &objp->ypbind_status))
80 		return (FALSE);
81 	switch (objp->ypbind_status) {
82 	case YPBIND_FAIL_VAL:
83 		if (!xdr_u_int(xdrs, &objp->ypbind_resp_u.ypbind_error))
84 			return (FALSE);
85 		break;
86 	case YPBIND_SUCC_VAL:
87 		if (!xdr_pointer(xdrs,
88 			(char **)&objp->ypbind_resp_u.ypbind_bindinfo,
89 			sizeof (ypbind_binding), xdr_ypbind_binding))
90 			return (FALSE);
91 		break;
92 	default:
93 		return (FALSE);
94 	}
95 	return (TRUE);
96 }
97 
98 bool_t
99 xdr_ypbind_setdom(XDR *xdrs, ypbind_setdom *objp)
100 {
101 	if (!xdr_string(xdrs, &objp->ypsetdom_domain, YPMAXDOMAIN))
102 		return (FALSE);
103 	return (xdr_pointer(xdrs, (char **)&objp->ypsetdom_bindinfo,
104 		sizeof (ypbind_binding), xdr_ypbind_binding));
105 }
106