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