xref: /titanic_44/usr/src/lib/libnsl/rpc/clnt_raw.c (revision 61961e0f20c7637a3846bb39786bb9dffa91dfb9)
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
21*61961e0fSrobinson  */
22*61961e0fSrobinson 
23*61961e0fSrobinson /*
24*61961e0fSrobinson  * 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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate /*
387c478bd9Sstevel@tonic-gate  * clnt_raw.c
397c478bd9Sstevel@tonic-gate  *
407c478bd9Sstevel@tonic-gate  * Memory based rpc for simple testing and timing.
417c478bd9Sstevel@tonic-gate  * Interface to create an rpc client and server in the same process.
427c478bd9Sstevel@tonic-gate  * This lets us similate rpc and get round trip overhead, without
437c478bd9Sstevel@tonic-gate  * any interference from the kernel.
447c478bd9Sstevel@tonic-gate  */
457c478bd9Sstevel@tonic-gate #include "mt.h"
467c478bd9Sstevel@tonic-gate #include "rpc_mt.h"
47*61961e0fSrobinson #include <stdlib.h>
487c478bd9Sstevel@tonic-gate #include <rpc/rpc.h>
497c478bd9Sstevel@tonic-gate #include <rpc/raw.h>
507c478bd9Sstevel@tonic-gate #include <syslog.h>
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate extern mutex_t	clntraw_lock;
537c478bd9Sstevel@tonic-gate #define	MCALL_MSG_SIZE 24
547c478bd9Sstevel@tonic-gate #ifndef UDPMSGSIZE
557c478bd9Sstevel@tonic-gate #define	UDPMSGSIZE 8800
567c478bd9Sstevel@tonic-gate #endif
577c478bd9Sstevel@tonic-gate 
587c478bd9Sstevel@tonic-gate /*
597c478bd9Sstevel@tonic-gate  * This is the "network" we will be moving stuff over.
607c478bd9Sstevel@tonic-gate  */
617c478bd9Sstevel@tonic-gate static struct clnt_raw_private {
627c478bd9Sstevel@tonic-gate 	CLIENT	client_object;
637c478bd9Sstevel@tonic-gate 	XDR	xdr_stream;
647c478bd9Sstevel@tonic-gate 	char	*raw_buf;	/* should be shared with server handle */
657c478bd9Sstevel@tonic-gate 	char	mashl_callmsg[MCALL_MSG_SIZE];
667c478bd9Sstevel@tonic-gate 	uint_t	mcnt;
677c478bd9Sstevel@tonic-gate } *clnt_raw_private;
687c478bd9Sstevel@tonic-gate 
697c478bd9Sstevel@tonic-gate static struct clnt_ops *clnt_raw_ops();
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate extern void svc_getreq_common(int);
727c478bd9Sstevel@tonic-gate extern bool_t xdr_opaque_auth();
737c478bd9Sstevel@tonic-gate 
747c478bd9Sstevel@tonic-gate /*
757c478bd9Sstevel@tonic-gate  * Create a client handle for memory based rpc.
767c478bd9Sstevel@tonic-gate  */
777c478bd9Sstevel@tonic-gate CLIENT *
clnt_raw_create(const rpcprog_t prog,const rpcvers_t vers)78*61961e0fSrobinson clnt_raw_create(const rpcprog_t prog, const rpcvers_t vers)
797c478bd9Sstevel@tonic-gate {
807c478bd9Sstevel@tonic-gate 	struct clnt_raw_private *clp;
817c478bd9Sstevel@tonic-gate 	struct rpc_msg call_msg;
827c478bd9Sstevel@tonic-gate 	XDR *xdrs;
837c478bd9Sstevel@tonic-gate 	CLIENT *client;
847c478bd9Sstevel@tonic-gate 
857c478bd9Sstevel@tonic-gate /* VARIABLES PROTECTED BY clntraw_lock: clp */
867c478bd9Sstevel@tonic-gate 
87*61961e0fSrobinson 	(void) mutex_lock(&clntraw_lock);
887c478bd9Sstevel@tonic-gate 	clp = clnt_raw_private;
897c478bd9Sstevel@tonic-gate 	if (clp == NULL) {
90*61961e0fSrobinson 		clp = calloc(1, sizeof (*clp));
917c478bd9Sstevel@tonic-gate 		if (clp == NULL) {
92*61961e0fSrobinson 			(void) mutex_unlock(&clntraw_lock);
93*61961e0fSrobinson 			return (NULL);
947c478bd9Sstevel@tonic-gate 		}
957c478bd9Sstevel@tonic-gate 		if (_rawcombuf == NULL) {
96*61961e0fSrobinson 			_rawcombuf = calloc(UDPMSGSIZE, sizeof (char));
977c478bd9Sstevel@tonic-gate 			if (_rawcombuf == NULL) {
987c478bd9Sstevel@tonic-gate 				syslog(LOG_ERR, "clnt_raw_create: "
997c478bd9Sstevel@tonic-gate 					"out of memory.");
1007c478bd9Sstevel@tonic-gate 				if (clp)
1017c478bd9Sstevel@tonic-gate 					free(clp);
102*61961e0fSrobinson 				(void) mutex_unlock(&clntraw_lock);
103*61961e0fSrobinson 				return (NULL);
1047c478bd9Sstevel@tonic-gate 			}
1057c478bd9Sstevel@tonic-gate 		}
1067c478bd9Sstevel@tonic-gate 		clp->raw_buf = _rawcombuf; /* Share it with the server */
1077c478bd9Sstevel@tonic-gate 		clnt_raw_private = clp;
1087c478bd9Sstevel@tonic-gate 	}
1097c478bd9Sstevel@tonic-gate 	xdrs = &clp->xdr_stream;
1107c478bd9Sstevel@tonic-gate 	client = &clp->client_object;
1117c478bd9Sstevel@tonic-gate 
1127c478bd9Sstevel@tonic-gate 	/*
1137c478bd9Sstevel@tonic-gate 	 * pre-serialize the static part of the call msg and stash it away
1147c478bd9Sstevel@tonic-gate 	 */
1157c478bd9Sstevel@tonic-gate 	call_msg.rm_direction = CALL;
1167c478bd9Sstevel@tonic-gate 	call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION;
1177c478bd9Sstevel@tonic-gate 	call_msg.rm_call.cb_prog = prog;
1187c478bd9Sstevel@tonic-gate 	call_msg.rm_call.cb_vers = vers;
1197c478bd9Sstevel@tonic-gate 	xdrmem_create(xdrs, clp->mashl_callmsg, MCALL_MSG_SIZE, XDR_ENCODE);
1207c478bd9Sstevel@tonic-gate 	if (!xdr_callhdr(xdrs, &call_msg))
1217c478bd9Sstevel@tonic-gate 		(void) syslog(LOG_ERR,
1227c478bd9Sstevel@tonic-gate 			(const char *) "clnt_raw_create :  \
1237c478bd9Sstevel@tonic-gate 			Fatal header serialization error.");
1247c478bd9Sstevel@tonic-gate 
1257c478bd9Sstevel@tonic-gate 	clp->mcnt = XDR_GETPOS(xdrs);
1267c478bd9Sstevel@tonic-gate 	XDR_DESTROY(xdrs);
1277c478bd9Sstevel@tonic-gate 
1287c478bd9Sstevel@tonic-gate 	/*
1297c478bd9Sstevel@tonic-gate 	 * Set xdrmem for client/server shared buffer
1307c478bd9Sstevel@tonic-gate 	 */
1317c478bd9Sstevel@tonic-gate 	xdrmem_create(xdrs, clp->raw_buf, UDPMSGSIZE, XDR_FREE);
1327c478bd9Sstevel@tonic-gate 
1337c478bd9Sstevel@tonic-gate 	/*
1347c478bd9Sstevel@tonic-gate 	 * create client handle
1357c478bd9Sstevel@tonic-gate 	 */
1367c478bd9Sstevel@tonic-gate 	client->cl_ops = clnt_raw_ops();
1377c478bd9Sstevel@tonic-gate 	client->cl_auth = authnone_create();
138*61961e0fSrobinson 	(void) mutex_unlock(&clntraw_lock);
1397c478bd9Sstevel@tonic-gate 	return (client);
1407c478bd9Sstevel@tonic-gate }
1417c478bd9Sstevel@tonic-gate 
1427c478bd9Sstevel@tonic-gate /*ARGSUSED*/
1437c478bd9Sstevel@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)1447c478bd9Sstevel@tonic-gate clnt_raw_call(CLIENT *h, rpcproc_t proc, xdrproc_t xargs, caddr_t argsp,
1457c478bd9Sstevel@tonic-gate 	xdrproc_t xresults, caddr_t resultsp, struct timeval timeout)
1467c478bd9Sstevel@tonic-gate {
1477c478bd9Sstevel@tonic-gate 	struct clnt_raw_private *clp;
1487c478bd9Sstevel@tonic-gate 	XDR *xdrs;
1497c478bd9Sstevel@tonic-gate 	struct rpc_msg msg;
1507c478bd9Sstevel@tonic-gate 	enum clnt_stat status;
1517c478bd9Sstevel@tonic-gate 	struct rpc_err error;
1527c478bd9Sstevel@tonic-gate 
153*61961e0fSrobinson 	(void) mutex_lock(&clntraw_lock);
1547c478bd9Sstevel@tonic-gate 	clp = clnt_raw_private;
1557c478bd9Sstevel@tonic-gate 	xdrs = &clp->xdr_stream;
1567c478bd9Sstevel@tonic-gate 	if (clp == NULL) {
157*61961e0fSrobinson 		(void) mutex_unlock(&clntraw_lock);
1587c478bd9Sstevel@tonic-gate 		return (RPC_FAILED);
1597c478bd9Sstevel@tonic-gate 	}
160*61961e0fSrobinson 	(void) mutex_unlock(&clntraw_lock);
1617c478bd9Sstevel@tonic-gate 
1627c478bd9Sstevel@tonic-gate call_again:
1637c478bd9Sstevel@tonic-gate 	/*
1647c478bd9Sstevel@tonic-gate 	 * send request
1657c478bd9Sstevel@tonic-gate 	 */
1667c478bd9Sstevel@tonic-gate 	xdrs->x_op = XDR_ENCODE;
1677c478bd9Sstevel@tonic-gate 	XDR_SETPOS(xdrs, 0);
1687c478bd9Sstevel@tonic-gate /* LINTED pointer alignment */
1697c478bd9Sstevel@tonic-gate 	((struct rpc_msg *)clp->mashl_callmsg)->rm_xid++;
1707c478bd9Sstevel@tonic-gate 	if ((!XDR_PUTBYTES(xdrs, clp->mashl_callmsg, clp->mcnt)) ||
1717c478bd9Sstevel@tonic-gate 	    (!XDR_PUTINT32(xdrs, (int32_t *)&proc)) ||
1727c478bd9Sstevel@tonic-gate 	    (!AUTH_MARSHALL(h->cl_auth, xdrs)) ||
173*61961e0fSrobinson 	    (!(*xargs)(xdrs, argsp)))
1747c478bd9Sstevel@tonic-gate 		return (RPC_CANTENCODEARGS);
1757c478bd9Sstevel@tonic-gate 	(void) XDR_GETPOS(xdrs);  /* called just to cause overhead */
1767c478bd9Sstevel@tonic-gate 
1777c478bd9Sstevel@tonic-gate 	/*
1787c478bd9Sstevel@tonic-gate 	 * We have to call server input routine here because this is
1797c478bd9Sstevel@tonic-gate 	 * all going on in one process.
1807c478bd9Sstevel@tonic-gate 	 * By convention using FD_SETSIZE as the psuedo file descriptor.
1817c478bd9Sstevel@tonic-gate 	 */
1827c478bd9Sstevel@tonic-gate 	svc_getreq_common(FD_SETSIZE);
1837c478bd9Sstevel@tonic-gate 
1847c478bd9Sstevel@tonic-gate 	/*
1857c478bd9Sstevel@tonic-gate 	 * get results
1867c478bd9Sstevel@tonic-gate 	 */
1877c478bd9Sstevel@tonic-gate 	xdrs->x_op = XDR_DECODE;
1887c478bd9Sstevel@tonic-gate 	XDR_SETPOS(xdrs, 0);
1897c478bd9Sstevel@tonic-gate 	msg.acpted_rply.ar_verf = _null_auth;
1907c478bd9Sstevel@tonic-gate 	msg.acpted_rply.ar_results.where = resultsp;
1917c478bd9Sstevel@tonic-gate 	msg.acpted_rply.ar_results.proc = xresults;
192*61961e0fSrobinson 	if (!xdr_replymsg(xdrs, &msg))
1937c478bd9Sstevel@tonic-gate 		return (RPC_CANTDECODERES);
1947c478bd9Sstevel@tonic-gate 	if ((msg.rm_reply.rp_stat == MSG_ACCEPTED) &&
1957c478bd9Sstevel@tonic-gate 		    (msg.acpted_rply.ar_stat == SUCCESS))
1967c478bd9Sstevel@tonic-gate 		status = RPC_SUCCESS;
1977c478bd9Sstevel@tonic-gate 	else {
1987c478bd9Sstevel@tonic-gate 		__seterr_reply(&msg, &error);
1997c478bd9Sstevel@tonic-gate 		status = error.re_status;
2007c478bd9Sstevel@tonic-gate 	}
2017c478bd9Sstevel@tonic-gate 
2027c478bd9Sstevel@tonic-gate 	if (status == RPC_SUCCESS) {
2037c478bd9Sstevel@tonic-gate 		if (!AUTH_VALIDATE(h->cl_auth, &msg.acpted_rply.ar_verf)) {
2047c478bd9Sstevel@tonic-gate 			status = RPC_AUTHERROR;
2057c478bd9Sstevel@tonic-gate 		}
2067c478bd9Sstevel@tonic-gate 		/* end successful completion */
2077c478bd9Sstevel@tonic-gate 	} else {
2087c478bd9Sstevel@tonic-gate 		if (AUTH_REFRESH(h->cl_auth, &msg))
2097c478bd9Sstevel@tonic-gate 			goto call_again;
2107c478bd9Sstevel@tonic-gate 		/* end of unsuccessful completion */
2117c478bd9Sstevel@tonic-gate 	}
2127c478bd9Sstevel@tonic-gate 
2137c478bd9Sstevel@tonic-gate 	if (status == RPC_SUCCESS) {
2147c478bd9Sstevel@tonic-gate 		if (!AUTH_VALIDATE(h->cl_auth, &msg.acpted_rply.ar_verf)) {
2157c478bd9Sstevel@tonic-gate 			status = RPC_AUTHERROR;
2167c478bd9Sstevel@tonic-gate 		}
2177c478bd9Sstevel@tonic-gate 		if (msg.acpted_rply.ar_verf.oa_base != NULL) {
2187c478bd9Sstevel@tonic-gate 			xdrs->x_op = XDR_FREE;
2197c478bd9Sstevel@tonic-gate 			(void) xdr_opaque_auth(xdrs,
2207c478bd9Sstevel@tonic-gate 					&(msg.acpted_rply.ar_verf));
2217c478bd9Sstevel@tonic-gate 		}
2227c478bd9Sstevel@tonic-gate 	}
2237c478bd9Sstevel@tonic-gate 	return (status);
2247c478bd9Sstevel@tonic-gate }
2257c478bd9Sstevel@tonic-gate 
2267c478bd9Sstevel@tonic-gate /*ARGSUSED*/
2277c478bd9Sstevel@tonic-gate static enum clnt_stat
clnt_raw_send(CLIENT * h,rpcproc_t proc,xdrproc_t xargs,caddr_t argsp)2287c478bd9Sstevel@tonic-gate clnt_raw_send(CLIENT *h, rpcproc_t proc, xdrproc_t xargs, caddr_t argsp)
2297c478bd9Sstevel@tonic-gate {
2307c478bd9Sstevel@tonic-gate 	struct clnt_raw_private *clp;
2317c478bd9Sstevel@tonic-gate 	XDR *xdrs;
2327c478bd9Sstevel@tonic-gate 
233*61961e0fSrobinson 	(void) mutex_lock(&clntraw_lock);
2347c478bd9Sstevel@tonic-gate 	clp = clnt_raw_private;
2357c478bd9Sstevel@tonic-gate 	xdrs = &clp->xdr_stream;
2367c478bd9Sstevel@tonic-gate 	if (clp == NULL) {
237*61961e0fSrobinson 		(void) mutex_unlock(&clntraw_lock);
2387c478bd9Sstevel@tonic-gate 		return (RPC_FAILED);
2397c478bd9Sstevel@tonic-gate 	}
240*61961e0fSrobinson 	(void) mutex_unlock(&clntraw_lock);
2417c478bd9Sstevel@tonic-gate 
2427c478bd9Sstevel@tonic-gate 	/*
2437c478bd9Sstevel@tonic-gate 	 * send request
2447c478bd9Sstevel@tonic-gate 	 */
2457c478bd9Sstevel@tonic-gate 	xdrs->x_op = XDR_ENCODE;
2467c478bd9Sstevel@tonic-gate 	XDR_SETPOS(xdrs, 0);
2477c478bd9Sstevel@tonic-gate /* LINTED pointer alignment */
2487c478bd9Sstevel@tonic-gate 	((struct rpc_msg *)clp->mashl_callmsg)->rm_xid++;
2497c478bd9Sstevel@tonic-gate 	if ((!XDR_PUTBYTES(xdrs, clp->mashl_callmsg, clp->mcnt)) ||
2507c478bd9Sstevel@tonic-gate 	    (!XDR_PUTINT32(xdrs, (int32_t *)&proc)) ||
2517c478bd9Sstevel@tonic-gate 	    (!AUTH_MARSHALL(h->cl_auth, xdrs)) ||
252*61961e0fSrobinson 	    (!(*xargs)(xdrs, argsp)))
2537c478bd9Sstevel@tonic-gate 		return (RPC_CANTENCODEARGS);
2547c478bd9Sstevel@tonic-gate 	(void) XDR_GETPOS(xdrs);  /* called just to cause overhead */
2557c478bd9Sstevel@tonic-gate 
2567c478bd9Sstevel@tonic-gate 	/*
2577c478bd9Sstevel@tonic-gate 	 * We have to call server input routine here because this is
2587c478bd9Sstevel@tonic-gate 	 * all going on in one process.
2597c478bd9Sstevel@tonic-gate 	 * By convention using FD_SETSIZE as the psuedo file descriptor.
2607c478bd9Sstevel@tonic-gate 	 */
2617c478bd9Sstevel@tonic-gate 	svc_getreq_common(FD_SETSIZE);
2627c478bd9Sstevel@tonic-gate 
2637c478bd9Sstevel@tonic-gate 	return (RPC_SUCCESS);
2647c478bd9Sstevel@tonic-gate }
2657c478bd9Sstevel@tonic-gate 
2667c478bd9Sstevel@tonic-gate /*ARGSUSED*/
2677c478bd9Sstevel@tonic-gate static void
clnt_raw_geterr(CLIENT * cl,struct rpc_err * errp)2687c478bd9Sstevel@tonic-gate clnt_raw_geterr(CLIENT *cl, struct rpc_err *errp)
2697c478bd9Sstevel@tonic-gate {
2707c478bd9Sstevel@tonic-gate }
2717c478bd9Sstevel@tonic-gate 
2727c478bd9Sstevel@tonic-gate /*ARGSUSED*/
2737c478bd9Sstevel@tonic-gate static bool_t
clnt_raw_freeres(CLIENT * cl,xdrproc_t xdr_res,caddr_t res_ptr)2747c478bd9Sstevel@tonic-gate clnt_raw_freeres(CLIENT *cl, xdrproc_t xdr_res, caddr_t res_ptr)
2757c478bd9Sstevel@tonic-gate {
2767c478bd9Sstevel@tonic-gate 	struct clnt_raw_private *clp;
2777c478bd9Sstevel@tonic-gate 	XDR *xdrs;
2787c478bd9Sstevel@tonic-gate 
279*61961e0fSrobinson 	(void) mutex_lock(&clntraw_lock);
2807c478bd9Sstevel@tonic-gate 	clp = clnt_raw_private;
2817c478bd9Sstevel@tonic-gate 	xdrs = &clp->xdr_stream;
2827c478bd9Sstevel@tonic-gate 	if (clp == NULL) {
283*61961e0fSrobinson 		(void) mutex_unlock(&clntraw_lock);
2847c478bd9Sstevel@tonic-gate 		return (FALSE);
2857c478bd9Sstevel@tonic-gate 	}
286*61961e0fSrobinson 	(void) mutex_unlock(&clntraw_lock);
2877c478bd9Sstevel@tonic-gate 	xdrs->x_op = XDR_FREE;
288*61961e0fSrobinson 	return ((*xdr_res)(xdrs, res_ptr));
2897c478bd9Sstevel@tonic-gate }
2907c478bd9Sstevel@tonic-gate 
2917c478bd9Sstevel@tonic-gate /*ARGSUSED*/
2927c478bd9Sstevel@tonic-gate static void
clnt_raw_abort(CLIENT * cl,struct rpc_err * errp)2937c478bd9Sstevel@tonic-gate clnt_raw_abort(CLIENT *cl, struct rpc_err *errp)
2947c478bd9Sstevel@tonic-gate {
2957c478bd9Sstevel@tonic-gate }
2967c478bd9Sstevel@tonic-gate 
2977c478bd9Sstevel@tonic-gate /*ARGSUSED*/
2987c478bd9Sstevel@tonic-gate static bool_t
clnt_raw_control(CLIENT * cl,int request,char * info)2997c478bd9Sstevel@tonic-gate clnt_raw_control(CLIENT *cl, int request, char *info)
3007c478bd9Sstevel@tonic-gate {
3017c478bd9Sstevel@tonic-gate 	return (FALSE);
3027c478bd9Sstevel@tonic-gate }
3037c478bd9Sstevel@tonic-gate 
3047c478bd9Sstevel@tonic-gate /*ARGSUSED*/
3057c478bd9Sstevel@tonic-gate static void
clnt_raw_destroy(CLIENT * cl)3067c478bd9Sstevel@tonic-gate clnt_raw_destroy(CLIENT *cl)
3077c478bd9Sstevel@tonic-gate {
3087c478bd9Sstevel@tonic-gate }
3097c478bd9Sstevel@tonic-gate 
3107c478bd9Sstevel@tonic-gate static struct clnt_ops *
clnt_raw_ops(void)3117c478bd9Sstevel@tonic-gate clnt_raw_ops(void)
3127c478bd9Sstevel@tonic-gate {
3137c478bd9Sstevel@tonic-gate 	static struct clnt_ops ops;
3147c478bd9Sstevel@tonic-gate 	extern mutex_t	ops_lock;
3157c478bd9Sstevel@tonic-gate 
3167c478bd9Sstevel@tonic-gate 	/* VARIABLES PROTECTED BY ops_lock: ops */
3177c478bd9Sstevel@tonic-gate 
318*61961e0fSrobinson 	(void) mutex_lock(&ops_lock);
3197c478bd9Sstevel@tonic-gate 	if (ops.cl_call == NULL) {
3207c478bd9Sstevel@tonic-gate 		ops.cl_call = clnt_raw_call;
3217c478bd9Sstevel@tonic-gate 		ops.cl_send = clnt_raw_send;
3227c478bd9Sstevel@tonic-gate 		ops.cl_abort = clnt_raw_abort;
3237c478bd9Sstevel@tonic-gate 		ops.cl_geterr = clnt_raw_geterr;
3247c478bd9Sstevel@tonic-gate 		ops.cl_freeres = clnt_raw_freeres;
3257c478bd9Sstevel@tonic-gate 		ops.cl_destroy = clnt_raw_destroy;
3267c478bd9Sstevel@tonic-gate 		ops.cl_control = clnt_raw_control;
3277c478bd9Sstevel@tonic-gate 	}
328*61961e0fSrobinson 	(void) mutex_unlock(&ops_lock);
3297c478bd9Sstevel@tonic-gate 	return (&ops);
3307c478bd9Sstevel@tonic-gate }
331