xref: /illumos-gate/usr/src/lib/libnsl/rpc/clnt_raw.c (revision 2a6fb28d0877f35efb94c09cc03e8088426d0c30)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
2161961e0fSrobinson  */
2261961e0fSrobinson 
2361961e0fSrobinson /*
2461961e0fSrobinson  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
257c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
267c478bd9Sstevel@tonic-gate  */
277c478bd9Sstevel@tonic-gate /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
287c478bd9Sstevel@tonic-gate /* All Rights Reserved */
297c478bd9Sstevel@tonic-gate /*
307c478bd9Sstevel@tonic-gate  * Portions of this source code were derived from Berkeley
317c478bd9Sstevel@tonic-gate  * 4.3 BSD under license from the Regents of the University of
327c478bd9Sstevel@tonic-gate  * California.
337c478bd9Sstevel@tonic-gate  */
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate /*
367c478bd9Sstevel@tonic-gate  * clnt_raw.c
377c478bd9Sstevel@tonic-gate  *
387c478bd9Sstevel@tonic-gate  * Memory based rpc for simple testing and timing.
397c478bd9Sstevel@tonic-gate  * Interface to create an rpc client and server in the same process.
40*2a6fb28dSMarcel Telka  * This lets us simulate rpc and get round trip overhead, without
417c478bd9Sstevel@tonic-gate  * any interference from the kernel.
427c478bd9Sstevel@tonic-gate  */
437c478bd9Sstevel@tonic-gate #include "mt.h"
447c478bd9Sstevel@tonic-gate #include "rpc_mt.h"
4561961e0fSrobinson #include <stdlib.h>
467c478bd9Sstevel@tonic-gate #include <rpc/rpc.h>
477c478bd9Sstevel@tonic-gate #include <syslog.h>
487c478bd9Sstevel@tonic-gate 
497c478bd9Sstevel@tonic-gate extern mutex_t	clntraw_lock;
507c478bd9Sstevel@tonic-gate #define	MCALL_MSG_SIZE 24
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate /*
537c478bd9Sstevel@tonic-gate  * This is the "network" we will be moving stuff over.
547c478bd9Sstevel@tonic-gate  */
557c478bd9Sstevel@tonic-gate static struct clnt_raw_private {
567c478bd9Sstevel@tonic-gate 	CLIENT	client_object;
57*2a6fb28dSMarcel Telka 	struct netbuf	*raw_netbuf;
587c478bd9Sstevel@tonic-gate 	char	mashl_callmsg[MCALL_MSG_SIZE];
597c478bd9Sstevel@tonic-gate 	uint_t	mcnt;
607c478bd9Sstevel@tonic-gate } *clnt_raw_private;
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate static struct clnt_ops *clnt_raw_ops();
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate extern bool_t xdr_opaque_auth();
657c478bd9Sstevel@tonic-gate 
667c478bd9Sstevel@tonic-gate /*
67*2a6fb28dSMarcel Telka  * This netbuf is shared with the raw server.
68*2a6fb28dSMarcel Telka  */
69*2a6fb28dSMarcel Telka extern struct netbuf _rawcomnetbuf;
70*2a6fb28dSMarcel Telka 
71*2a6fb28dSMarcel Telka /*
727c478bd9Sstevel@tonic-gate  * Create a client handle for memory based rpc.
737c478bd9Sstevel@tonic-gate  */
747c478bd9Sstevel@tonic-gate CLIENT *
clnt_raw_create(const rpcprog_t prog,const rpcvers_t vers)7561961e0fSrobinson clnt_raw_create(const rpcprog_t prog, const rpcvers_t vers)
767c478bd9Sstevel@tonic-gate {
777c478bd9Sstevel@tonic-gate 	struct clnt_raw_private *clp;
787c478bd9Sstevel@tonic-gate 	struct rpc_msg call_msg;
79*2a6fb28dSMarcel Telka 	XDR xdrs;
807c478bd9Sstevel@tonic-gate 	CLIENT *client;
81*2a6fb28dSMarcel Telka 	uint_t start;
827c478bd9Sstevel@tonic-gate 
837c478bd9Sstevel@tonic-gate /* VARIABLES PROTECTED BY clntraw_lock: clp */
847c478bd9Sstevel@tonic-gate 
8561961e0fSrobinson 	(void) mutex_lock(&clntraw_lock);
867c478bd9Sstevel@tonic-gate 	clp = clnt_raw_private;
87*2a6fb28dSMarcel Telka 	if (clp != NULL) {
88*2a6fb28dSMarcel Telka 		(void) mutex_unlock(&clntraw_lock);
89*2a6fb28dSMarcel Telka 		return (&clp->client_object);
90*2a6fb28dSMarcel Telka 	}
91*2a6fb28dSMarcel Telka 
9261961e0fSrobinson 	clp = calloc(1, sizeof (*clp));
937c478bd9Sstevel@tonic-gate 	if (clp == NULL) {
9461961e0fSrobinson 		(void) mutex_unlock(&clntraw_lock);
9561961e0fSrobinson 		return (NULL);
967c478bd9Sstevel@tonic-gate 	}
97*2a6fb28dSMarcel Telka 
98*2a6fb28dSMarcel Telka 	clp->raw_netbuf = &_rawcomnetbuf;
997c478bd9Sstevel@tonic-gate 
1007c478bd9Sstevel@tonic-gate 	/*
1017c478bd9Sstevel@tonic-gate 	 * pre-serialize the static part of the call msg and stash it away
1027c478bd9Sstevel@tonic-gate 	 */
1037c478bd9Sstevel@tonic-gate 	call_msg.rm_direction = CALL;
1047c478bd9Sstevel@tonic-gate 	call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION;
1057c478bd9Sstevel@tonic-gate 	call_msg.rm_call.cb_prog = prog;
1067c478bd9Sstevel@tonic-gate 	call_msg.rm_call.cb_vers = vers;
107*2a6fb28dSMarcel Telka 
108*2a6fb28dSMarcel Telka 	xdrmem_create(&xdrs, clp->mashl_callmsg, sizeof (clp->mashl_callmsg),
109*2a6fb28dSMarcel Telka 	    XDR_ENCODE);
110*2a6fb28dSMarcel Telka 	start = XDR_GETPOS(&xdrs);
111*2a6fb28dSMarcel Telka 	if (!xdr_callhdr(&xdrs, &call_msg)) {
112*2a6fb28dSMarcel Telka 		free(clp);
1137c478bd9Sstevel@tonic-gate 		(void) syslog(LOG_ERR,
114*2a6fb28dSMarcel Telka 		    "clnt_raw_create: Fatal header serialization error");
1157c478bd9Sstevel@tonic-gate 
116*2a6fb28dSMarcel Telka 		(void) mutex_unlock(&clntraw_lock);
117*2a6fb28dSMarcel Telka 		return (NULL);
118*2a6fb28dSMarcel Telka 	}
119*2a6fb28dSMarcel Telka 	clp->mcnt = XDR_GETPOS(&xdrs) - start;
120*2a6fb28dSMarcel Telka 	XDR_DESTROY(&xdrs);
1217c478bd9Sstevel@tonic-gate 
1227c478bd9Sstevel@tonic-gate 	/*
1237c478bd9Sstevel@tonic-gate 	 * create client handle
1247c478bd9Sstevel@tonic-gate 	 */
125*2a6fb28dSMarcel Telka 	client = &clp->client_object;
1267c478bd9Sstevel@tonic-gate 	client->cl_ops = clnt_raw_ops();
1277c478bd9Sstevel@tonic-gate 	client->cl_auth = authnone_create();
128*2a6fb28dSMarcel Telka 
129*2a6fb28dSMarcel Telka 	clnt_raw_private = clp;
130*2a6fb28dSMarcel Telka 
13161961e0fSrobinson 	(void) mutex_unlock(&clntraw_lock);
1327c478bd9Sstevel@tonic-gate 	return (client);
1337c478bd9Sstevel@tonic-gate }
1347c478bd9Sstevel@tonic-gate 
1357c478bd9Sstevel@tonic-gate /*ARGSUSED*/
1367c478bd9Sstevel@tonic-gate static enum clnt_stat
clnt_raw_call(CLIENT * h,rpcproc_t proc,xdrproc_t xargs,caddr_t argsp,xdrproc_t xresults,caddr_t resultsp,struct timeval timeout)1377c478bd9Sstevel@tonic-gate clnt_raw_call(CLIENT *h, rpcproc_t proc, xdrproc_t xargs, caddr_t argsp,
1387c478bd9Sstevel@tonic-gate     xdrproc_t xresults, caddr_t resultsp, struct timeval timeout)
1397c478bd9Sstevel@tonic-gate {
1407c478bd9Sstevel@tonic-gate 	struct clnt_raw_private *clp;
141*2a6fb28dSMarcel Telka 	XDR xdrs;
1427c478bd9Sstevel@tonic-gate 	struct rpc_msg msg;
143*2a6fb28dSMarcel Telka 	uint_t start;
144*2a6fb28dSMarcel Telka 
145*2a6fb28dSMarcel Telka 	rpc_callerr.re_errno = 0;
146*2a6fb28dSMarcel Telka 	rpc_callerr.re_terrno = 0;
1477c478bd9Sstevel@tonic-gate 
14861961e0fSrobinson 	(void) mutex_lock(&clntraw_lock);
1497c478bd9Sstevel@tonic-gate 	clp = clnt_raw_private;
1507c478bd9Sstevel@tonic-gate 	if (clp == NULL) {
15161961e0fSrobinson 		(void) mutex_unlock(&clntraw_lock);
152*2a6fb28dSMarcel Telka 		return (rpc_callerr.re_status = RPC_FAILED);
1537c478bd9Sstevel@tonic-gate 	}
15461961e0fSrobinson 	(void) mutex_unlock(&clntraw_lock);
1557c478bd9Sstevel@tonic-gate 
1567c478bd9Sstevel@tonic-gate call_again:
1577c478bd9Sstevel@tonic-gate 	/*
1587c478bd9Sstevel@tonic-gate 	 * send request
1597c478bd9Sstevel@tonic-gate 	 */
160*2a6fb28dSMarcel Telka 	xdrmem_create(&xdrs, clp->raw_netbuf->buf, clp->raw_netbuf->maxlen,
161*2a6fb28dSMarcel Telka 	    XDR_ENCODE);
162*2a6fb28dSMarcel Telka 	start = XDR_GETPOS(&xdrs);
1637c478bd9Sstevel@tonic-gate /* LINTED pointer alignment */
1647c478bd9Sstevel@tonic-gate 	((struct rpc_msg *)clp->mashl_callmsg)->rm_xid++;
165*2a6fb28dSMarcel Telka 	if ((!XDR_PUTBYTES(&xdrs, clp->mashl_callmsg, clp->mcnt)) ||
166*2a6fb28dSMarcel Telka 	    (!XDR_PUTINT32(&xdrs, (int32_t *)&proc)) ||
167*2a6fb28dSMarcel Telka 	    (!AUTH_MARSHALL(h->cl_auth, &xdrs)) ||
168*2a6fb28dSMarcel Telka 	    (!(*xargs)(&xdrs, argsp))) {
169*2a6fb28dSMarcel Telka 		XDR_DESTROY(&xdrs);
170*2a6fb28dSMarcel Telka 		return (rpc_callerr.re_status = RPC_CANTENCODEARGS);
171*2a6fb28dSMarcel Telka 	}
172*2a6fb28dSMarcel Telka 	clp->raw_netbuf->len = XDR_GETPOS(&xdrs) - start;
173*2a6fb28dSMarcel Telka 	XDR_DESTROY(&xdrs);
1747c478bd9Sstevel@tonic-gate 
1757c478bd9Sstevel@tonic-gate 	/*
1767c478bd9Sstevel@tonic-gate 	 * We have to call server input routine here because this is
1777c478bd9Sstevel@tonic-gate 	 * all going on in one process.
178*2a6fb28dSMarcel Telka 	 * By convention using FD_SETSIZE as the pseudo file descriptor.
1797c478bd9Sstevel@tonic-gate 	 */
1807c478bd9Sstevel@tonic-gate 	svc_getreq_common(FD_SETSIZE);
1817c478bd9Sstevel@tonic-gate 
1827c478bd9Sstevel@tonic-gate 	/*
1837c478bd9Sstevel@tonic-gate 	 * get results
1847c478bd9Sstevel@tonic-gate 	 */
185*2a6fb28dSMarcel Telka 	xdrmem_create(&xdrs, clp->raw_netbuf->buf, clp->raw_netbuf->len,
186*2a6fb28dSMarcel Telka 	    XDR_DECODE);
1877c478bd9Sstevel@tonic-gate 	msg.acpted_rply.ar_verf = _null_auth;
1887c478bd9Sstevel@tonic-gate 	msg.acpted_rply.ar_results.where = resultsp;
1897c478bd9Sstevel@tonic-gate 	msg.acpted_rply.ar_results.proc = xresults;
190*2a6fb28dSMarcel Telka 	if (!xdr_replymsg(&xdrs, &msg)) {
191*2a6fb28dSMarcel Telka 		XDR_DESTROY(&xdrs);
192*2a6fb28dSMarcel Telka 		return (rpc_callerr.re_status = RPC_CANTDECODERES);
193*2a6fb28dSMarcel Telka 	}
194*2a6fb28dSMarcel Telka 	XDR_DESTROY(&xdrs);
1957c478bd9Sstevel@tonic-gate 	if ((msg.rm_reply.rp_stat == MSG_ACCEPTED) &&
1967c478bd9Sstevel@tonic-gate 	    (msg.acpted_rply.ar_stat == SUCCESS))
197*2a6fb28dSMarcel Telka 		rpc_callerr.re_status = RPC_SUCCESS;
198*2a6fb28dSMarcel Telka 	else
199*2a6fb28dSMarcel Telka 		__seterr_reply(&msg, &rpc_callerr);
2007c478bd9Sstevel@tonic-gate 
201*2a6fb28dSMarcel Telka 	if (rpc_callerr.re_status == RPC_SUCCESS) {
2027c478bd9Sstevel@tonic-gate 		if (!AUTH_VALIDATE(h->cl_auth, &msg.acpted_rply.ar_verf)) {
203*2a6fb28dSMarcel Telka 			rpc_callerr.re_status = RPC_AUTHERROR;
204*2a6fb28dSMarcel Telka 			rpc_callerr.re_why = AUTH_INVALIDRESP;
205*2a6fb28dSMarcel Telka 		}
206*2a6fb28dSMarcel Telka 		if (msg.acpted_rply.ar_verf.oa_base != NULL) {
207*2a6fb28dSMarcel Telka 			xdr_free(xdr_opaque_auth,
208*2a6fb28dSMarcel Telka 			    (char *)&(msg.acpted_rply.ar_verf));
2097c478bd9Sstevel@tonic-gate 		}
2107c478bd9Sstevel@tonic-gate 		/* end successful completion */
2117c478bd9Sstevel@tonic-gate 	} else {
2127c478bd9Sstevel@tonic-gate 		if (AUTH_REFRESH(h->cl_auth, &msg))
2137c478bd9Sstevel@tonic-gate 			goto call_again;
2147c478bd9Sstevel@tonic-gate 		/* end of unsuccessful completion */
2157c478bd9Sstevel@tonic-gate 	}
2167c478bd9Sstevel@tonic-gate 
217*2a6fb28dSMarcel Telka 	return (rpc_callerr.re_status);
2187c478bd9Sstevel@tonic-gate }
2197c478bd9Sstevel@tonic-gate 
2207c478bd9Sstevel@tonic-gate /*ARGSUSED*/
2217c478bd9Sstevel@tonic-gate static enum clnt_stat
clnt_raw_send(CLIENT * h,rpcproc_t proc,xdrproc_t xargs,caddr_t argsp)2227c478bd9Sstevel@tonic-gate clnt_raw_send(CLIENT *h, rpcproc_t proc, xdrproc_t xargs, caddr_t argsp)
2237c478bd9Sstevel@tonic-gate {
2247c478bd9Sstevel@tonic-gate 	struct clnt_raw_private *clp;
225*2a6fb28dSMarcel Telka 	XDR xdrs;
226*2a6fb28dSMarcel Telka 	uint_t start;
227*2a6fb28dSMarcel Telka 
228*2a6fb28dSMarcel Telka 	rpc_callerr.re_errno = 0;
229*2a6fb28dSMarcel Telka 	rpc_callerr.re_terrno = 0;
2307c478bd9Sstevel@tonic-gate 
23161961e0fSrobinson 	(void) mutex_lock(&clntraw_lock);
2327c478bd9Sstevel@tonic-gate 	clp = clnt_raw_private;
2337c478bd9Sstevel@tonic-gate 	if (clp == NULL) {
23461961e0fSrobinson 		(void) mutex_unlock(&clntraw_lock);
235*2a6fb28dSMarcel Telka 		return (rpc_callerr.re_status = RPC_FAILED);
2367c478bd9Sstevel@tonic-gate 	}
23761961e0fSrobinson 	(void) mutex_unlock(&clntraw_lock);
2387c478bd9Sstevel@tonic-gate 
2397c478bd9Sstevel@tonic-gate 	/*
2407c478bd9Sstevel@tonic-gate 	 * send request
2417c478bd9Sstevel@tonic-gate 	 */
242*2a6fb28dSMarcel Telka 	xdrmem_create(&xdrs, clp->raw_netbuf->buf, clp->raw_netbuf->maxlen,
243*2a6fb28dSMarcel Telka 	    XDR_ENCODE);
244*2a6fb28dSMarcel Telka 	start = XDR_GETPOS(&xdrs);
2457c478bd9Sstevel@tonic-gate /* LINTED pointer alignment */
2467c478bd9Sstevel@tonic-gate 	((struct rpc_msg *)clp->mashl_callmsg)->rm_xid++;
247*2a6fb28dSMarcel Telka 	if ((!XDR_PUTBYTES(&xdrs, clp->mashl_callmsg, clp->mcnt)) ||
248*2a6fb28dSMarcel Telka 	    (!XDR_PUTINT32(&xdrs, (int32_t *)&proc)) ||
249*2a6fb28dSMarcel Telka 	    (!AUTH_MARSHALL(h->cl_auth, &xdrs)) ||
250*2a6fb28dSMarcel Telka 	    (!(*xargs)(&xdrs, argsp))) {
251*2a6fb28dSMarcel Telka 		XDR_DESTROY(&xdrs);
252*2a6fb28dSMarcel Telka 		return (rpc_callerr.re_status = RPC_CANTENCODEARGS);
253*2a6fb28dSMarcel Telka 	}
254*2a6fb28dSMarcel Telka 	clp->raw_netbuf->len = XDR_GETPOS(&xdrs) - start;
255*2a6fb28dSMarcel Telka 	XDR_DESTROY(&xdrs);
2567c478bd9Sstevel@tonic-gate 
2577c478bd9Sstevel@tonic-gate 	/*
2587c478bd9Sstevel@tonic-gate 	 * We have to call server input routine here because this is
2597c478bd9Sstevel@tonic-gate 	 * all going on in one process.
260*2a6fb28dSMarcel Telka 	 * By convention using FD_SETSIZE as the pseudo file descriptor.
2617c478bd9Sstevel@tonic-gate 	 */
2627c478bd9Sstevel@tonic-gate 	svc_getreq_common(FD_SETSIZE);
2637c478bd9Sstevel@tonic-gate 
264*2a6fb28dSMarcel Telka 	return (rpc_callerr.re_status = RPC_SUCCESS);
2657c478bd9Sstevel@tonic-gate }
2667c478bd9Sstevel@tonic-gate 
2677c478bd9Sstevel@tonic-gate /*ARGSUSED*/
2687c478bd9Sstevel@tonic-gate static void
clnt_raw_geterr(CLIENT * cl,struct rpc_err * errp)2697c478bd9Sstevel@tonic-gate clnt_raw_geterr(CLIENT *cl, struct rpc_err *errp)
2707c478bd9Sstevel@tonic-gate {
271*2a6fb28dSMarcel Telka 	*errp = rpc_callerr;
2727c478bd9Sstevel@tonic-gate }
2737c478bd9Sstevel@tonic-gate 
2747c478bd9Sstevel@tonic-gate /*ARGSUSED*/
2757c478bd9Sstevel@tonic-gate static bool_t
clnt_raw_freeres(CLIENT * cl,xdrproc_t xdr_res,caddr_t res_ptr)2767c478bd9Sstevel@tonic-gate clnt_raw_freeres(CLIENT *cl, xdrproc_t xdr_res, caddr_t res_ptr)
2777c478bd9Sstevel@tonic-gate {
2787c478bd9Sstevel@tonic-gate 	struct clnt_raw_private *clp;
2797c478bd9Sstevel@tonic-gate 
28061961e0fSrobinson 	(void) mutex_lock(&clntraw_lock);
2817c478bd9Sstevel@tonic-gate 	clp = clnt_raw_private;
2827c478bd9Sstevel@tonic-gate 	if (clp == NULL) {
28361961e0fSrobinson 		(void) mutex_unlock(&clntraw_lock);
2847c478bd9Sstevel@tonic-gate 		return (FALSE);
2857c478bd9Sstevel@tonic-gate 	}
28661961e0fSrobinson 	(void) mutex_unlock(&clntraw_lock);
287*2a6fb28dSMarcel Telka 
288*2a6fb28dSMarcel Telka 	xdr_free(xdr_res, res_ptr);
289*2a6fb28dSMarcel Telka 
290*2a6fb28dSMarcel Telka 	return (TRUE);
2917c478bd9Sstevel@tonic-gate }
2927c478bd9Sstevel@tonic-gate 
2937c478bd9Sstevel@tonic-gate /*ARGSUSED*/
2947c478bd9Sstevel@tonic-gate static void
clnt_raw_abort(CLIENT * cl,struct rpc_err * errp)2957c478bd9Sstevel@tonic-gate clnt_raw_abort(CLIENT *cl, struct rpc_err *errp)
2967c478bd9Sstevel@tonic-gate {
2977c478bd9Sstevel@tonic-gate }
2987c478bd9Sstevel@tonic-gate 
2997c478bd9Sstevel@tonic-gate /*ARGSUSED*/
3007c478bd9Sstevel@tonic-gate static bool_t
clnt_raw_control(CLIENT * cl,int request,char * info)3017c478bd9Sstevel@tonic-gate clnt_raw_control(CLIENT *cl, int request, char *info)
3027c478bd9Sstevel@tonic-gate {
3037c478bd9Sstevel@tonic-gate 	return (FALSE);
3047c478bd9Sstevel@tonic-gate }
3057c478bd9Sstevel@tonic-gate 
3067c478bd9Sstevel@tonic-gate /*ARGSUSED*/
3077c478bd9Sstevel@tonic-gate static void
clnt_raw_destroy(CLIENT * cl)3087c478bd9Sstevel@tonic-gate clnt_raw_destroy(CLIENT *cl)
3097c478bd9Sstevel@tonic-gate {
3107c478bd9Sstevel@tonic-gate }
3117c478bd9Sstevel@tonic-gate 
3127c478bd9Sstevel@tonic-gate static struct clnt_ops *
clnt_raw_ops(void)3137c478bd9Sstevel@tonic-gate clnt_raw_ops(void)
3147c478bd9Sstevel@tonic-gate {
3157c478bd9Sstevel@tonic-gate 	static struct clnt_ops ops;
3167c478bd9Sstevel@tonic-gate 	extern mutex_t	ops_lock;
3177c478bd9Sstevel@tonic-gate 
3187c478bd9Sstevel@tonic-gate 	/* VARIABLES PROTECTED BY ops_lock: ops */
3197c478bd9Sstevel@tonic-gate 
32061961e0fSrobinson 	(void) mutex_lock(&ops_lock);
3217c478bd9Sstevel@tonic-gate 	if (ops.cl_call == NULL) {
3227c478bd9Sstevel@tonic-gate 		ops.cl_call = clnt_raw_call;
3237c478bd9Sstevel@tonic-gate 		ops.cl_send = clnt_raw_send;
3247c478bd9Sstevel@tonic-gate 		ops.cl_abort = clnt_raw_abort;
3257c478bd9Sstevel@tonic-gate 		ops.cl_geterr = clnt_raw_geterr;
3267c478bd9Sstevel@tonic-gate 		ops.cl_freeres = clnt_raw_freeres;
3277c478bd9Sstevel@tonic-gate 		ops.cl_destroy = clnt_raw_destroy;
3287c478bd9Sstevel@tonic-gate 		ops.cl_control = clnt_raw_control;
3297c478bd9Sstevel@tonic-gate 	}
33061961e0fSrobinson 	(void) mutex_unlock(&ops_lock);
3317c478bd9Sstevel@tonic-gate 	return (&ops);
3327c478bd9Sstevel@tonic-gate }
333