xref: /illumos-gate/usr/src/lib/libnsl/rpc/svid_funcs.c (revision 20a7641f9918de8574b8b3b47dbe35c4bfc78df1)
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 /*
29  *	These functions are documented in the SVID as being part of libnsl.
30  *	They are also defined as macros in various RPC header files.  To
31  *	ensure that these interfaces exist as functions, we've created this
32  *	(we hope unused) file.
33  */
34 
35 #include "mt.h"
36 #include <rpc/rpc.h>
37 #include <sys/types.h>
38 #include <synch.h>
39 
40 #undef	auth_destroy
41 #undef	clnt_call
42 #undef  clnt_send
43 #undef	clnt_control
44 #undef	clnt_destroy
45 #undef	clnt_freeres
46 #undef	clnt_geterr
47 #undef	svc_destroy
48 #undef	svc_freeargs
49 #undef	svc_getargs
50 #undef	svc_getrpccaller
51 #undef	xdr_destroy
52 #undef	xdr_getpos
53 #undef	xdr_inline
54 #undef	xdr_setpos
55 
56 extern int __svc_versquiet_get();
57 extern void __svc_versquiet_off();
58 extern void __svc_versquiet_on();
59 
60 void
61 auth_destroy(AUTH *auth)
62 {
63 	((*((auth)->ah_ops->ah_destroy))(auth));
64 }
65 
66 enum clnt_stat
67 clnt_call(CLIENT *cl, uint32_t proc, xdrproc_t xargs, caddr_t argsp,
68 			xdrproc_t xres, caddr_t resp, struct timeval timeout)
69 {
70 	return ((*(cl)->cl_ops->cl_call)(cl, proc, xargs, argsp, xres, resp,
71 		timeout));
72 }
73 
74 enum clnt_stat
75 clnt_send(CLIENT *cl, uint32_t proc, xdrproc_t xargs, caddr_t argsp)
76 {
77 	return ((*(cl)->cl_ops->cl_send)(cl, proc, xargs, argsp));
78 }
79 
80 bool_t
81 clnt_control(CLIENT *cl, uint_t rq, char *in)
82 {
83 	return ((*(cl)->cl_ops->cl_control)(cl, rq, in));
84 }
85 
86 void
87 clnt_destroy(CLIENT *cl)
88 {
89 	((*(cl)->cl_ops->cl_destroy)(cl));
90 }
91 
92 bool_t
93 clnt_freeres(CLIENT *cl, xdrproc_t xres, caddr_t resp)
94 {
95 	return ((*(cl)->cl_ops->cl_freeres)(cl, xres, resp));
96 }
97 
98 void
99 clnt_geterr(CLIENT *cl, struct rpc_err *errp)
100 {
101 	(*(cl)->cl_ops->cl_geterr)(cl, errp);
102 }
103 
104 bool_t
105 svc_control(SVCXPRT *xprt, const uint_t rq, void *in)
106 {
107 	switch (rq) {
108 	case SVCGET_VERSQUIET:
109 		*((int *)in) = __svc_versquiet_get(xprt);
110 		return (TRUE);
111 	case SVCSET_VERSQUIET:
112 		if (*((int *)in) == 0)
113 			__svc_versquiet_off(xprt);
114 		else
115 			__svc_versquiet_on(xprt);
116 		return (TRUE);
117 	default:
118 		return ((*(xprt)->xp_ops->xp_control)(xprt, rq, in));
119 	}
120 }
121 
122 void
123 svc_destroy(SVCXPRT *xprt)
124 {
125 	(*(xprt)->xp_ops->xp_destroy)(xprt);
126 }
127 
128 bool_t
129 svc_freeargs(SVCXPRT *xprt, xdrproc_t xargs, char *argsp)
130 {
131 	return ((*(xprt)->xp_ops->xp_freeargs)(xprt, xargs, argsp));
132 }
133 
134 bool_t
135 svc_getargs(SVCXPRT *xprt, xdrproc_t xargs, char *argsp)
136 {
137 	return ((*(xprt)->xp_ops->xp_getargs)(xprt, xargs, argsp));
138 }
139 
140 struct netbuf *
141 svc_getrpccaller(SVCXPRT *xprt)
142 {
143 	return (&(xprt)->xp_rtaddr);
144 }
145 
146 void
147 xdr_destroy(XDR *xdrs)
148 {
149 	(*(xdrs)->x_ops->x_destroy)(xdrs);
150 }
151 
152 uint_t
153 xdr_getpos(XDR *xdrs)
154 {
155 	return ((*(xdrs)->x_ops->x_getpostn)(xdrs));
156 }
157 
158 rpc_inline_t *
159 xdr_inline(XDR *xdrs, int len)
160 {
161 	return ((*(xdrs)->x_ops->x_inline)(xdrs, len));
162 }
163 
164 bool_t
165 xdr_setpos(XDR *xdrs, uint_t pos)
166 {
167 	return ((*(xdrs)->x_ops->x_setpostn)(xdrs, pos));
168 }
169