xref: /illumos-gate/usr/src/lib/libnsl/yp/yp_b_clnt.c (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
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  * Copyright 1997 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
27 /*	  All Rights Reserved   */
28 
29 /*
30  * Portions of this source code were derived from Berkeley
31  * under license from the Regents of the University of
32  * California.
33  */
34 
35 #pragma ident	"%Z%%M%	%I%	%E% SMI"
36 
37 #include <rpc/rpc.h>
38 #include <sys/time.h>
39 #include <sys/types.h>
40 #include <rpc/trace.h>
41 #include "yp_b.h"
42 #define	bzero(a, b) (void) memset(a, 0, b)
43 #define	YPBIND_ERR_ERR 1		/* Internal error */
44 #define	YPBIND_ERR_NOSERV 2		/* No bound server for passed domain */
45 #define	YPBIND_ERR_RESC 3		/* System resource allocation failure */
46 #define	YPBIND_ERR_NODOMAIN 4		/* Domain doesn't exist */
47 
48 /* Default timeout can be changed using clnt_control() */
49 static struct timeval TIMEOUT = { 25, 0 };
50 
51 void *
52 ypbindproc_null_3(argp, clnt)
53 	void *argp;
54 	CLIENT *clnt;
55 {
56 	static char res;
57 
58 	trace2(TR_ypbindproc_null_3, 0, clnt);
59 	bzero((char *)&res, sizeof (res));
60 	if (clnt_call(clnt, YPBINDPROC_NULL, xdr_void,
61 		argp, xdr_void, &res, TIMEOUT) != RPC_SUCCESS) {
62 		trace1(TR_ypbindproc_null_3, 1);
63 		return (NULL);
64 	}
65 	trace1(TR_ypbindproc_null_3, 1);
66 	return ((void *)&res);
67 }
68 
69 ypbind_resp *
70 ypbindproc_domain_3(argp, clnt)
71 	ypbind_domain *argp;
72 	CLIENT *clnt;
73 {
74 	static ypbind_resp res;
75 
76 	trace2(TR_ypbindproc_domain_3, 0, clnt);
77 	bzero((char *)&res, sizeof (res));
78 	if (clnt_call(clnt, YPBINDPROC_DOMAIN,
79 		xdr_ypbind_domain, (char *)argp, xdr_ypbind_resp,
80 		(char *)&res, TIMEOUT) != RPC_SUCCESS) {
81 		trace1(TR_ypbindproc_domain_3, 1);
82 		return (NULL);
83 	}
84 	trace1(TR_ypbindproc_domain_3, 1);
85 	return (&res);
86 }
87 
88 void *
89 ypbindproc_setdom_3(argp, clnt)
90 	ypbind_setdom *argp;
91 	CLIENT *clnt;
92 {
93 	static char res;
94 
95 	trace2(TR_ypbindproc_setdom_3, 0, clnt);
96 	bzero((char *)&res, sizeof (res));
97 	if (clnt_call(clnt, YPBINDPROC_SETDOM,
98 		xdr_ypbind_setdom, (char *)argp, xdr_void, &res,
99 		TIMEOUT) != RPC_SUCCESS) {
100 		trace1(TR_ypbindproc_setdom_3, 1);
101 		return (NULL);
102 	}
103 	trace1(TR_ypbindproc_setdom_3, 1);
104 	return ((void *)&res);
105 }
106