1dfdcada3SDoug Rabson /*-
2*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause
3fe267a55SPedro F. Giffuni *
4dfdcada3SDoug Rabson * Copyright (c) 2008 Isilon Inc http://www.isilon.com/
5dfdcada3SDoug Rabson * Authors: Doug Rabson <dfr@rabson.org>
6dfdcada3SDoug Rabson * Developed with Red Inc: Alfred Perlstein <alfred@freebsd.org>
7dfdcada3SDoug Rabson *
8dfdcada3SDoug Rabson * Redistribution and use in source and binary forms, with or without
9dfdcada3SDoug Rabson * modification, are permitted provided that the following conditions
10dfdcada3SDoug Rabson * are met:
11dfdcada3SDoug Rabson * 1. Redistributions of source code must retain the above copyright
12dfdcada3SDoug Rabson * notice, this list of conditions and the following disclaimer.
13dfdcada3SDoug Rabson * 2. Redistributions in binary form must reproduce the above copyright
14dfdcada3SDoug Rabson * notice, this list of conditions and the following disclaimer in the
15dfdcada3SDoug Rabson * documentation and/or other materials provided with the distribution.
16dfdcada3SDoug Rabson *
17dfdcada3SDoug Rabson * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18dfdcada3SDoug Rabson * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19dfdcada3SDoug Rabson * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20dfdcada3SDoug Rabson * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21dfdcada3SDoug Rabson * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22dfdcada3SDoug Rabson * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23dfdcada3SDoug Rabson * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24dfdcada3SDoug Rabson * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25dfdcada3SDoug Rabson * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26dfdcada3SDoug Rabson * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27dfdcada3SDoug Rabson * SUCH DAMAGE.
28dfdcada3SDoug Rabson */
29dfdcada3SDoug Rabson
30dfdcada3SDoug Rabson #include <sys/param.h>
31dfdcada3SDoug Rabson #include <sys/systm.h>
32dfdcada3SDoug Rabson
33ee31b83aSDoug Rabson #include <nlm/nlm_prot.h>
34ee31b83aSDoug Rabson #include <nlm/nlm.h>
35dfdcada3SDoug Rabson
36dfdcada3SDoug Rabson #include <sys/cdefs.h>
37dfdcada3SDoug Rabson #ifndef lint
38dfdcada3SDoug Rabson __RCSID("$NetBSD: nlm_prot.x,v 1.6 2000/06/07 14:30:15 bouyer Exp $");
39dfdcada3SDoug Rabson #endif /* not lint */
40dfdcada3SDoug Rabson void nlm_prog_0(struct svc_req *rqstp, SVCXPRT *transp);
41dfdcada3SDoug Rabson void nlm_prog_1(struct svc_req *rqstp, SVCXPRT *transp);
42dfdcada3SDoug Rabson void nlm_prog_3(struct svc_req *rqstp, SVCXPRT *transp);
43dfdcada3SDoug Rabson void nlm_prog_4(struct svc_req *rqstp, SVCXPRT *transp);
44dfdcada3SDoug Rabson
45dfdcada3SDoug Rabson void
nlm_prog_0(struct svc_req * rqstp,SVCXPRT * transp)46dfdcada3SDoug Rabson nlm_prog_0(struct svc_req *rqstp, SVCXPRT *transp)
47dfdcada3SDoug Rabson {
48dfdcada3SDoug Rabson union {
49dfdcada3SDoug Rabson struct nlm_sm_status nlm_sm_notify_0_arg;
50dfdcada3SDoug Rabson } argument;
51dfdcada3SDoug Rabson char result;
52dfdcada3SDoug Rabson bool_t retval;
53dfdcada3SDoug Rabson xdrproc_t xdr_argument, xdr_result;
54dfdcada3SDoug Rabson bool_t (*local)(char *, void *, struct svc_req *);
55dfdcada3SDoug Rabson
56dfdcada3SDoug Rabson switch (rqstp->rq_proc) {
57dfdcada3SDoug Rabson case NULLPROC:
58a9148abdSDoug Rabson (void) svc_sendreply(rqstp,
59dfdcada3SDoug Rabson (xdrproc_t) xdr_void, (char *)NULL);
60a9148abdSDoug Rabson svc_freereq(rqstp);
61dfdcada3SDoug Rabson return;
62dfdcada3SDoug Rabson
63dfdcada3SDoug Rabson case NLM_SM_NOTIFY:
64dfdcada3SDoug Rabson xdr_argument = (xdrproc_t) xdr_nlm_sm_status;
65dfdcada3SDoug Rabson xdr_result = (xdrproc_t) xdr_void;
66dfdcada3SDoug Rabson local = (bool_t (*) (char *, void *, struct svc_req *))nlm_sm_notify_0_svc;
67dfdcada3SDoug Rabson break;
68dfdcada3SDoug Rabson
69dfdcada3SDoug Rabson default:
70a9148abdSDoug Rabson svcerr_noproc(rqstp);
71a9148abdSDoug Rabson svc_freereq(rqstp);
72dfdcada3SDoug Rabson return;
73dfdcada3SDoug Rabson }
74dfdcada3SDoug Rabson (void) memset((char *)&argument, 0, sizeof (argument));
75a9148abdSDoug Rabson if (!svc_getargs(rqstp, xdr_argument, (char *)(caddr_t) &argument)) {
76a9148abdSDoug Rabson svcerr_decode(rqstp);
77a9148abdSDoug Rabson svc_freereq(rqstp);
78dfdcada3SDoug Rabson return;
79dfdcada3SDoug Rabson }
80dfdcada3SDoug Rabson retval = (bool_t) (*local)((char *)&argument, (void *)&result, rqstp);
81a9148abdSDoug Rabson if (retval > 0 && !svc_sendreply(rqstp, xdr_result, (char *)&result)) {
82a9148abdSDoug Rabson svcerr_systemerr(rqstp);
83dfdcada3SDoug Rabson }
84a9148abdSDoug Rabson if (!svc_freeargs(rqstp, xdr_argument, (char *)(caddr_t) &argument)) {
85dfdcada3SDoug Rabson printf("unable to free arguments");
86dfdcada3SDoug Rabson //exit(1);
87dfdcada3SDoug Rabson }
886f978a84SDoug Rabson svc_freereq(rqstp);
89dfdcada3SDoug Rabson
90dfdcada3SDoug Rabson return;
91dfdcada3SDoug Rabson }
92dfdcada3SDoug Rabson
93dfdcada3SDoug Rabson void
nlm_prog_1(struct svc_req * rqstp,SVCXPRT * transp)94dfdcada3SDoug Rabson nlm_prog_1(struct svc_req *rqstp, SVCXPRT *transp)
95dfdcada3SDoug Rabson {
96dfdcada3SDoug Rabson union {
97dfdcada3SDoug Rabson struct nlm_testargs nlm_test_1_arg;
98dfdcada3SDoug Rabson struct nlm_lockargs nlm_lock_1_arg;
99dfdcada3SDoug Rabson struct nlm_cancargs nlm_cancel_1_arg;
100dfdcada3SDoug Rabson struct nlm_unlockargs nlm_unlock_1_arg;
101dfdcada3SDoug Rabson struct nlm_testargs nlm_granted_1_arg;
102dfdcada3SDoug Rabson struct nlm_testargs nlm_test_msg_1_arg;
103dfdcada3SDoug Rabson struct nlm_lockargs nlm_lock_msg_1_arg;
104dfdcada3SDoug Rabson struct nlm_cancargs nlm_cancel_msg_1_arg;
105dfdcada3SDoug Rabson struct nlm_unlockargs nlm_unlock_msg_1_arg;
106dfdcada3SDoug Rabson struct nlm_testargs nlm_granted_msg_1_arg;
107dfdcada3SDoug Rabson nlm_testres nlm_test_res_1_arg;
108dfdcada3SDoug Rabson nlm_res nlm_lock_res_1_arg;
109dfdcada3SDoug Rabson nlm_res nlm_cancel_res_1_arg;
110dfdcada3SDoug Rabson nlm_res nlm_unlock_res_1_arg;
111dfdcada3SDoug Rabson nlm_res nlm_granted_res_1_arg;
112dfdcada3SDoug Rabson } argument;
113dfdcada3SDoug Rabson union {
114dfdcada3SDoug Rabson nlm_testres nlm_test_1_res;
115dfdcada3SDoug Rabson nlm_res nlm_lock_1_res;
116dfdcada3SDoug Rabson nlm_res nlm_cancel_1_res;
117dfdcada3SDoug Rabson nlm_res nlm_unlock_1_res;
118dfdcada3SDoug Rabson nlm_res nlm_granted_1_res;
119dfdcada3SDoug Rabson } result;
120dfdcada3SDoug Rabson bool_t retval;
121dfdcada3SDoug Rabson xdrproc_t xdr_argument, xdr_result;
122dfdcada3SDoug Rabson bool_t (*local)(char *, void *, struct svc_req *);
123dfdcada3SDoug Rabson
124dfdcada3SDoug Rabson switch (rqstp->rq_proc) {
125dfdcada3SDoug Rabson case NULLPROC:
126a9148abdSDoug Rabson (void) svc_sendreply(rqstp,
127dfdcada3SDoug Rabson (xdrproc_t) xdr_void, (char *)NULL);
128a9148abdSDoug Rabson svc_freereq(rqstp);
129dfdcada3SDoug Rabson return;
130dfdcada3SDoug Rabson
131dfdcada3SDoug Rabson case NLM_TEST:
132dfdcada3SDoug Rabson xdr_argument = (xdrproc_t) xdr_nlm_testargs;
133dfdcada3SDoug Rabson xdr_result = (xdrproc_t) xdr_nlm_testres;
134dfdcada3SDoug Rabson local = (bool_t (*) (char *, void *, struct svc_req *))nlm_test_1_svc;
135dfdcada3SDoug Rabson break;
136dfdcada3SDoug Rabson
137dfdcada3SDoug Rabson case NLM_LOCK:
138dfdcada3SDoug Rabson xdr_argument = (xdrproc_t) xdr_nlm_lockargs;
139dfdcada3SDoug Rabson xdr_result = (xdrproc_t) xdr_nlm_res;
140dfdcada3SDoug Rabson local = (bool_t (*) (char *, void *, struct svc_req *))nlm_lock_1_svc;
141dfdcada3SDoug Rabson break;
142dfdcada3SDoug Rabson
143dfdcada3SDoug Rabson case NLM_CANCEL:
144dfdcada3SDoug Rabson xdr_argument = (xdrproc_t) xdr_nlm_cancargs;
145dfdcada3SDoug Rabson xdr_result = (xdrproc_t) xdr_nlm_res;
146dfdcada3SDoug Rabson local = (bool_t (*) (char *, void *, struct svc_req *))nlm_cancel_1_svc;
147dfdcada3SDoug Rabson break;
148dfdcada3SDoug Rabson
149dfdcada3SDoug Rabson case NLM_UNLOCK:
150dfdcada3SDoug Rabson xdr_argument = (xdrproc_t) xdr_nlm_unlockargs;
151dfdcada3SDoug Rabson xdr_result = (xdrproc_t) xdr_nlm_res;
152dfdcada3SDoug Rabson local = (bool_t (*) (char *, void *, struct svc_req *))nlm_unlock_1_svc;
153dfdcada3SDoug Rabson break;
154dfdcada3SDoug Rabson
155dfdcada3SDoug Rabson case NLM_GRANTED:
156dfdcada3SDoug Rabson xdr_argument = (xdrproc_t) xdr_nlm_testargs;
157dfdcada3SDoug Rabson xdr_result = (xdrproc_t) xdr_nlm_res;
158dfdcada3SDoug Rabson local = (bool_t (*) (char *, void *, struct svc_req *))nlm_granted_1_svc;
159dfdcada3SDoug Rabson break;
160dfdcada3SDoug Rabson
161dfdcada3SDoug Rabson case NLM_TEST_MSG:
162dfdcada3SDoug Rabson xdr_argument = (xdrproc_t) xdr_nlm_testargs;
163dfdcada3SDoug Rabson xdr_result = (xdrproc_t) xdr_void;
164dfdcada3SDoug Rabson local = (bool_t (*) (char *, void *, struct svc_req *))nlm_test_msg_1_svc;
165dfdcada3SDoug Rabson break;
166dfdcada3SDoug Rabson
167dfdcada3SDoug Rabson case NLM_LOCK_MSG:
168dfdcada3SDoug Rabson xdr_argument = (xdrproc_t) xdr_nlm_lockargs;
169dfdcada3SDoug Rabson xdr_result = (xdrproc_t) xdr_void;
170dfdcada3SDoug Rabson local = (bool_t (*) (char *, void *, struct svc_req *))nlm_lock_msg_1_svc;
171dfdcada3SDoug Rabson break;
172dfdcada3SDoug Rabson
173dfdcada3SDoug Rabson case NLM_CANCEL_MSG:
174dfdcada3SDoug Rabson xdr_argument = (xdrproc_t) xdr_nlm_cancargs;
175dfdcada3SDoug Rabson xdr_result = (xdrproc_t) xdr_void;
176dfdcada3SDoug Rabson local = (bool_t (*) (char *, void *, struct svc_req *))nlm_cancel_msg_1_svc;
177dfdcada3SDoug Rabson break;
178dfdcada3SDoug Rabson
179dfdcada3SDoug Rabson case NLM_UNLOCK_MSG:
180dfdcada3SDoug Rabson xdr_argument = (xdrproc_t) xdr_nlm_unlockargs;
181dfdcada3SDoug Rabson xdr_result = (xdrproc_t) xdr_void;
182dfdcada3SDoug Rabson local = (bool_t (*) (char *, void *, struct svc_req *))nlm_unlock_msg_1_svc;
183dfdcada3SDoug Rabson break;
184dfdcada3SDoug Rabson
185dfdcada3SDoug Rabson case NLM_GRANTED_MSG:
186dfdcada3SDoug Rabson xdr_argument = (xdrproc_t) xdr_nlm_testargs;
187dfdcada3SDoug Rabson xdr_result = (xdrproc_t) xdr_void;
188dfdcada3SDoug Rabson local = (bool_t (*) (char *, void *, struct svc_req *))nlm_granted_msg_1_svc;
189dfdcada3SDoug Rabson break;
190dfdcada3SDoug Rabson
191dfdcada3SDoug Rabson case NLM_TEST_RES:
192dfdcada3SDoug Rabson xdr_argument = (xdrproc_t) xdr_nlm_testres;
193dfdcada3SDoug Rabson xdr_result = (xdrproc_t) xdr_void;
194dfdcada3SDoug Rabson local = (bool_t (*) (char *, void *, struct svc_req *))nlm_test_res_1_svc;
195dfdcada3SDoug Rabson break;
196dfdcada3SDoug Rabson
197dfdcada3SDoug Rabson case NLM_LOCK_RES:
198dfdcada3SDoug Rabson xdr_argument = (xdrproc_t) xdr_nlm_res;
199dfdcada3SDoug Rabson xdr_result = (xdrproc_t) xdr_void;
200dfdcada3SDoug Rabson local = (bool_t (*) (char *, void *, struct svc_req *))nlm_lock_res_1_svc;
201dfdcada3SDoug Rabson break;
202dfdcada3SDoug Rabson
203dfdcada3SDoug Rabson case NLM_CANCEL_RES:
204dfdcada3SDoug Rabson xdr_argument = (xdrproc_t) xdr_nlm_res;
205dfdcada3SDoug Rabson xdr_result = (xdrproc_t) xdr_void;
206dfdcada3SDoug Rabson local = (bool_t (*) (char *, void *, struct svc_req *))nlm_cancel_res_1_svc;
207dfdcada3SDoug Rabson break;
208dfdcada3SDoug Rabson
209dfdcada3SDoug Rabson case NLM_UNLOCK_RES:
210dfdcada3SDoug Rabson xdr_argument = (xdrproc_t) xdr_nlm_res;
211dfdcada3SDoug Rabson xdr_result = (xdrproc_t) xdr_void;
212dfdcada3SDoug Rabson local = (bool_t (*) (char *, void *, struct svc_req *))nlm_unlock_res_1_svc;
213dfdcada3SDoug Rabson break;
214dfdcada3SDoug Rabson
215dfdcada3SDoug Rabson case NLM_GRANTED_RES:
216dfdcada3SDoug Rabson xdr_argument = (xdrproc_t) xdr_nlm_res;
217dfdcada3SDoug Rabson xdr_result = (xdrproc_t) xdr_void;
218dfdcada3SDoug Rabson local = (bool_t (*) (char *, void *, struct svc_req *))nlm_granted_res_1_svc;
219dfdcada3SDoug Rabson break;
220dfdcada3SDoug Rabson
221dfdcada3SDoug Rabson default:
222a9148abdSDoug Rabson svcerr_noproc(rqstp);
223a9148abdSDoug Rabson svc_freereq(rqstp);
224dfdcada3SDoug Rabson return;
225dfdcada3SDoug Rabson }
226dfdcada3SDoug Rabson (void) memset((char *)&argument, 0, sizeof (argument));
227a9148abdSDoug Rabson if (!svc_getargs(rqstp, xdr_argument, (char *)(caddr_t) &argument)) {
228a9148abdSDoug Rabson svcerr_decode(rqstp);
229a9148abdSDoug Rabson svc_freereq(rqstp);
230dfdcada3SDoug Rabson return;
231dfdcada3SDoug Rabson }
232dfdcada3SDoug Rabson retval = (bool_t) (*local)((char *)&argument, (void *)&result, rqstp);
233a9148abdSDoug Rabson if (retval > 0 && !svc_sendreply(rqstp, xdr_result, (char *)&result)) {
234a9148abdSDoug Rabson svcerr_systemerr(rqstp);
235dfdcada3SDoug Rabson }
236a9148abdSDoug Rabson if (!svc_freeargs(rqstp, xdr_argument, (char *)(caddr_t) &argument)) {
237dfdcada3SDoug Rabson printf("unable to free arguments");
238dfdcada3SDoug Rabson //exit(1);
239dfdcada3SDoug Rabson }
240a9148abdSDoug Rabson svc_freereq(rqstp);
241dfdcada3SDoug Rabson if (!nlm_prog_1_freeresult(transp, xdr_result, (caddr_t) &result))
242dfdcada3SDoug Rabson printf("unable to free results");
243dfdcada3SDoug Rabson
244dfdcada3SDoug Rabson return;
245dfdcada3SDoug Rabson }
246dfdcada3SDoug Rabson
247dfdcada3SDoug Rabson void
nlm_prog_3(struct svc_req * rqstp,SVCXPRT * transp)248dfdcada3SDoug Rabson nlm_prog_3(struct svc_req *rqstp, SVCXPRT *transp)
249dfdcada3SDoug Rabson {
250dfdcada3SDoug Rabson union {
251dfdcada3SDoug Rabson nlm_shareargs nlm_share_3_arg;
252dfdcada3SDoug Rabson nlm_shareargs nlm_unshare_3_arg;
253dfdcada3SDoug Rabson nlm_lockargs nlm_nm_lock_3_arg;
254dfdcada3SDoug Rabson nlm_notify nlm_free_all_3_arg;
255dfdcada3SDoug Rabson } argument;
256dfdcada3SDoug Rabson union {
257dfdcada3SDoug Rabson nlm_shareres nlm_share_3_res;
258dfdcada3SDoug Rabson nlm_shareres nlm_unshare_3_res;
259dfdcada3SDoug Rabson nlm_res nlm_nm_lock_3_res;
260dfdcada3SDoug Rabson } result;
261dfdcada3SDoug Rabson bool_t retval;
262dfdcada3SDoug Rabson xdrproc_t xdr_argument, xdr_result;
263dfdcada3SDoug Rabson bool_t (*local)(char *, void *, struct svc_req *);
264dfdcada3SDoug Rabson
265dfdcada3SDoug Rabson switch (rqstp->rq_proc) {
266dfdcada3SDoug Rabson case NULLPROC:
267a9148abdSDoug Rabson (void) svc_sendreply(rqstp,
268dfdcada3SDoug Rabson (xdrproc_t) xdr_void, (char *)NULL);
269a9148abdSDoug Rabson svc_freereq(rqstp);
270dfdcada3SDoug Rabson return;
271dfdcada3SDoug Rabson
272dfdcada3SDoug Rabson case NLM_TEST:
273dfdcada3SDoug Rabson case NLM_LOCK:
274dfdcada3SDoug Rabson case NLM_CANCEL:
275dfdcada3SDoug Rabson case NLM_UNLOCK:
276dfdcada3SDoug Rabson case NLM_GRANTED:
277dfdcada3SDoug Rabson case NLM_TEST_MSG:
278dfdcada3SDoug Rabson case NLM_LOCK_MSG:
279dfdcada3SDoug Rabson case NLM_CANCEL_MSG:
280dfdcada3SDoug Rabson case NLM_UNLOCK_MSG:
281dfdcada3SDoug Rabson case NLM_GRANTED_MSG:
282dfdcada3SDoug Rabson case NLM_TEST_RES:
283dfdcada3SDoug Rabson case NLM_LOCK_RES:
284dfdcada3SDoug Rabson case NLM_CANCEL_RES:
285dfdcada3SDoug Rabson case NLM_UNLOCK_RES:
286dfdcada3SDoug Rabson case NLM_GRANTED_RES:
287dfdcada3SDoug Rabson nlm_prog_1(rqstp, transp);
288dfdcada3SDoug Rabson return;
289dfdcada3SDoug Rabson
290dfdcada3SDoug Rabson case NLM_SHARE:
291dfdcada3SDoug Rabson xdr_argument = (xdrproc_t) xdr_nlm_shareargs;
292dfdcada3SDoug Rabson xdr_result = (xdrproc_t) xdr_nlm_shareres;
293dfdcada3SDoug Rabson local = (bool_t (*) (char *, void *, struct svc_req *))nlm_share_3_svc;
294dfdcada3SDoug Rabson break;
295dfdcada3SDoug Rabson
296dfdcada3SDoug Rabson case NLM_UNSHARE:
297dfdcada3SDoug Rabson xdr_argument = (xdrproc_t) xdr_nlm_shareargs;
298dfdcada3SDoug Rabson xdr_result = (xdrproc_t) xdr_nlm_shareres;
299dfdcada3SDoug Rabson local = (bool_t (*) (char *, void *, struct svc_req *))nlm_unshare_3_svc;
300dfdcada3SDoug Rabson break;
301dfdcada3SDoug Rabson
302dfdcada3SDoug Rabson case NLM_NM_LOCK:
303dfdcada3SDoug Rabson xdr_argument = (xdrproc_t) xdr_nlm_lockargs;
304dfdcada3SDoug Rabson xdr_result = (xdrproc_t) xdr_nlm_res;
305dfdcada3SDoug Rabson local = (bool_t (*) (char *, void *, struct svc_req *))nlm_nm_lock_3_svc;
306dfdcada3SDoug Rabson break;
307dfdcada3SDoug Rabson
308dfdcada3SDoug Rabson case NLM_FREE_ALL:
309dfdcada3SDoug Rabson xdr_argument = (xdrproc_t) xdr_nlm_notify;
310dfdcada3SDoug Rabson xdr_result = (xdrproc_t) xdr_void;
311dfdcada3SDoug Rabson local = (bool_t (*) (char *, void *, struct svc_req *))nlm_free_all_3_svc;
312dfdcada3SDoug Rabson break;
313dfdcada3SDoug Rabson
314dfdcada3SDoug Rabson default:
315a9148abdSDoug Rabson svcerr_noproc(rqstp);
316a9148abdSDoug Rabson svc_freereq(rqstp);
317dfdcada3SDoug Rabson return;
318dfdcada3SDoug Rabson }
319dfdcada3SDoug Rabson (void) memset((char *)&argument, 0, sizeof (argument));
320a9148abdSDoug Rabson if (!svc_getargs(rqstp, xdr_argument, (char *)(caddr_t) &argument)) {
321a9148abdSDoug Rabson svcerr_decode(rqstp);
322a9148abdSDoug Rabson svc_freereq(rqstp);
323dfdcada3SDoug Rabson return;
324dfdcada3SDoug Rabson }
325dfdcada3SDoug Rabson retval = (bool_t) (*local)((char *)&argument, (void *)&result, rqstp);
326a9148abdSDoug Rabson if (retval > 0 && !svc_sendreply(rqstp, xdr_result, (char *)&result)) {
327a9148abdSDoug Rabson svcerr_systemerr(rqstp);
328dfdcada3SDoug Rabson }
329a9148abdSDoug Rabson if (!svc_freeargs(rqstp, xdr_argument, (char *)(caddr_t) &argument)) {
330dfdcada3SDoug Rabson printf("unable to free arguments");
331dfdcada3SDoug Rabson //exit(1);
332dfdcada3SDoug Rabson }
333a9148abdSDoug Rabson svc_freereq(rqstp);
334dfdcada3SDoug Rabson if (!nlm_prog_3_freeresult(transp, xdr_result, (caddr_t) &result))
335dfdcada3SDoug Rabson printf("unable to free results");
336dfdcada3SDoug Rabson
337dfdcada3SDoug Rabson return;
338dfdcada3SDoug Rabson }
339dfdcada3SDoug Rabson
340dfdcada3SDoug Rabson void
nlm_prog_4(struct svc_req * rqstp,SVCXPRT * transp)341dfdcada3SDoug Rabson nlm_prog_4(struct svc_req *rqstp, SVCXPRT *transp)
342dfdcada3SDoug Rabson {
343dfdcada3SDoug Rabson union {
344dfdcada3SDoug Rabson nlm4_testargs nlm4_test_4_arg;
345dfdcada3SDoug Rabson nlm4_lockargs nlm4_lock_4_arg;
346dfdcada3SDoug Rabson nlm4_cancargs nlm4_cancel_4_arg;
347dfdcada3SDoug Rabson nlm4_unlockargs nlm4_unlock_4_arg;
348dfdcada3SDoug Rabson nlm4_testargs nlm4_granted_4_arg;
349dfdcada3SDoug Rabson nlm4_testargs nlm4_test_msg_4_arg;
350dfdcada3SDoug Rabson nlm4_lockargs nlm4_lock_msg_4_arg;
351dfdcada3SDoug Rabson nlm4_cancargs nlm4_cancel_msg_4_arg;
352dfdcada3SDoug Rabson nlm4_unlockargs nlm4_unlock_msg_4_arg;
353dfdcada3SDoug Rabson nlm4_testargs nlm4_granted_msg_4_arg;
354dfdcada3SDoug Rabson nlm4_testres nlm4_test_res_4_arg;
355dfdcada3SDoug Rabson nlm4_res nlm4_lock_res_4_arg;
356dfdcada3SDoug Rabson nlm4_res nlm4_cancel_res_4_arg;
357dfdcada3SDoug Rabson nlm4_res nlm4_unlock_res_4_arg;
358dfdcada3SDoug Rabson nlm4_res nlm4_granted_res_4_arg;
359dfdcada3SDoug Rabson nlm4_shareargs nlm4_share_4_arg;
360dfdcada3SDoug Rabson nlm4_shareargs nlm4_unshare_4_arg;
361dfdcada3SDoug Rabson nlm4_lockargs nlm4_nm_lock_4_arg;
362dfdcada3SDoug Rabson nlm4_notify nlm4_free_all_4_arg;
363dfdcada3SDoug Rabson } argument;
364dfdcada3SDoug Rabson union {
365dfdcada3SDoug Rabson nlm4_testres nlm4_test_4_res;
366dfdcada3SDoug Rabson nlm4_res nlm4_lock_4_res;
367dfdcada3SDoug Rabson nlm4_res nlm4_cancel_4_res;
368dfdcada3SDoug Rabson nlm4_res nlm4_unlock_4_res;
369dfdcada3SDoug Rabson nlm4_res nlm4_granted_4_res;
370dfdcada3SDoug Rabson nlm4_shareres nlm4_share_4_res;
371dfdcada3SDoug Rabson nlm4_shareres nlm4_unshare_4_res;
372dfdcada3SDoug Rabson nlm4_res nlm4_nm_lock_4_res;
373dfdcada3SDoug Rabson } result;
374dfdcada3SDoug Rabson bool_t retval;
375dfdcada3SDoug Rabson xdrproc_t xdr_argument, xdr_result;
376dfdcada3SDoug Rabson bool_t (*local)(char *, void *, struct svc_req *);
377dfdcada3SDoug Rabson
378dfdcada3SDoug Rabson switch (rqstp->rq_proc) {
379dfdcada3SDoug Rabson case NULLPROC:
380a9148abdSDoug Rabson (void) svc_sendreply(rqstp,
381dfdcada3SDoug Rabson (xdrproc_t) xdr_void, (char *)NULL);
382a9148abdSDoug Rabson svc_freereq(rqstp);
383dfdcada3SDoug Rabson return;
384dfdcada3SDoug Rabson
385dfdcada3SDoug Rabson case NLM4_TEST:
386dfdcada3SDoug Rabson xdr_argument = (xdrproc_t) xdr_nlm4_testargs;
387dfdcada3SDoug Rabson xdr_result = (xdrproc_t) xdr_nlm4_testres;
388dfdcada3SDoug Rabson local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_test_4_svc;
389dfdcada3SDoug Rabson break;
390dfdcada3SDoug Rabson
391dfdcada3SDoug Rabson case NLM4_LOCK:
392dfdcada3SDoug Rabson xdr_argument = (xdrproc_t) xdr_nlm4_lockargs;
393dfdcada3SDoug Rabson xdr_result = (xdrproc_t) xdr_nlm4_res;
394dfdcada3SDoug Rabson local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_lock_4_svc;
395dfdcada3SDoug Rabson break;
396dfdcada3SDoug Rabson
397dfdcada3SDoug Rabson case NLM4_CANCEL:
398dfdcada3SDoug Rabson xdr_argument = (xdrproc_t) xdr_nlm4_cancargs;
399dfdcada3SDoug Rabson xdr_result = (xdrproc_t) xdr_nlm4_res;
400dfdcada3SDoug Rabson local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_cancel_4_svc;
401dfdcada3SDoug Rabson break;
402dfdcada3SDoug Rabson
403dfdcada3SDoug Rabson case NLM4_UNLOCK:
404dfdcada3SDoug Rabson xdr_argument = (xdrproc_t) xdr_nlm4_unlockargs;
405dfdcada3SDoug Rabson xdr_result = (xdrproc_t) xdr_nlm4_res;
406dfdcada3SDoug Rabson local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_unlock_4_svc;
407dfdcada3SDoug Rabson break;
408dfdcada3SDoug Rabson
409dfdcada3SDoug Rabson case NLM4_GRANTED:
410dfdcada3SDoug Rabson xdr_argument = (xdrproc_t) xdr_nlm4_testargs;
411dfdcada3SDoug Rabson xdr_result = (xdrproc_t) xdr_nlm4_res;
412dfdcada3SDoug Rabson local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_granted_4_svc;
413dfdcada3SDoug Rabson break;
414dfdcada3SDoug Rabson
415dfdcada3SDoug Rabson case NLM4_TEST_MSG:
416dfdcada3SDoug Rabson xdr_argument = (xdrproc_t) xdr_nlm4_testargs;
417dfdcada3SDoug Rabson xdr_result = (xdrproc_t) xdr_void;
418dfdcada3SDoug Rabson local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_test_msg_4_svc;
419dfdcada3SDoug Rabson break;
420dfdcada3SDoug Rabson
421dfdcada3SDoug Rabson case NLM4_LOCK_MSG:
422dfdcada3SDoug Rabson xdr_argument = (xdrproc_t) xdr_nlm4_lockargs;
423dfdcada3SDoug Rabson xdr_result = (xdrproc_t) xdr_void;
424dfdcada3SDoug Rabson local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_lock_msg_4_svc;
425dfdcada3SDoug Rabson break;
426dfdcada3SDoug Rabson
427dfdcada3SDoug Rabson case NLM4_CANCEL_MSG:
428dfdcada3SDoug Rabson xdr_argument = (xdrproc_t) xdr_nlm4_cancargs;
429dfdcada3SDoug Rabson xdr_result = (xdrproc_t) xdr_void;
430dfdcada3SDoug Rabson local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_cancel_msg_4_svc;
431dfdcada3SDoug Rabson break;
432dfdcada3SDoug Rabson
433dfdcada3SDoug Rabson case NLM4_UNLOCK_MSG:
434dfdcada3SDoug Rabson xdr_argument = (xdrproc_t) xdr_nlm4_unlockargs;
435dfdcada3SDoug Rabson xdr_result = (xdrproc_t) xdr_void;
436dfdcada3SDoug Rabson local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_unlock_msg_4_svc;
437dfdcada3SDoug Rabson break;
438dfdcada3SDoug Rabson
439dfdcada3SDoug Rabson case NLM4_GRANTED_MSG:
440dfdcada3SDoug Rabson xdr_argument = (xdrproc_t) xdr_nlm4_testargs;
441dfdcada3SDoug Rabson xdr_result = (xdrproc_t) xdr_void;
442dfdcada3SDoug Rabson local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_granted_msg_4_svc;
443dfdcada3SDoug Rabson break;
444dfdcada3SDoug Rabson
445dfdcada3SDoug Rabson case NLM4_TEST_RES:
446dfdcada3SDoug Rabson xdr_argument = (xdrproc_t) xdr_nlm4_testres;
447dfdcada3SDoug Rabson xdr_result = (xdrproc_t) xdr_void;
448dfdcada3SDoug Rabson local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_test_res_4_svc;
449dfdcada3SDoug Rabson break;
450dfdcada3SDoug Rabson
451dfdcada3SDoug Rabson case NLM4_LOCK_RES:
452dfdcada3SDoug Rabson xdr_argument = (xdrproc_t) xdr_nlm4_res;
453dfdcada3SDoug Rabson xdr_result = (xdrproc_t) xdr_void;
454dfdcada3SDoug Rabson local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_lock_res_4_svc;
455dfdcada3SDoug Rabson break;
456dfdcada3SDoug Rabson
457dfdcada3SDoug Rabson case NLM4_CANCEL_RES:
458dfdcada3SDoug Rabson xdr_argument = (xdrproc_t) xdr_nlm4_res;
459dfdcada3SDoug Rabson xdr_result = (xdrproc_t) xdr_void;
460dfdcada3SDoug Rabson local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_cancel_res_4_svc;
461dfdcada3SDoug Rabson break;
462dfdcada3SDoug Rabson
463dfdcada3SDoug Rabson case NLM4_UNLOCK_RES:
464dfdcada3SDoug Rabson xdr_argument = (xdrproc_t) xdr_nlm4_res;
465dfdcada3SDoug Rabson xdr_result = (xdrproc_t) xdr_void;
466dfdcada3SDoug Rabson local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_unlock_res_4_svc;
467dfdcada3SDoug Rabson break;
468dfdcada3SDoug Rabson
469dfdcada3SDoug Rabson case NLM4_GRANTED_RES:
470dfdcada3SDoug Rabson xdr_argument = (xdrproc_t) xdr_nlm4_res;
471dfdcada3SDoug Rabson xdr_result = (xdrproc_t) xdr_void;
472dfdcada3SDoug Rabson local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_granted_res_4_svc;
473dfdcada3SDoug Rabson break;
474dfdcada3SDoug Rabson
475dfdcada3SDoug Rabson case NLM4_SHARE:
476dfdcada3SDoug Rabson xdr_argument = (xdrproc_t) xdr_nlm4_shareargs;
477dfdcada3SDoug Rabson xdr_result = (xdrproc_t) xdr_nlm4_shareres;
478dfdcada3SDoug Rabson local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_share_4_svc;
479dfdcada3SDoug Rabson break;
480dfdcada3SDoug Rabson
481dfdcada3SDoug Rabson case NLM4_UNSHARE:
482dfdcada3SDoug Rabson xdr_argument = (xdrproc_t) xdr_nlm4_shareargs;
483dfdcada3SDoug Rabson xdr_result = (xdrproc_t) xdr_nlm4_shareres;
484dfdcada3SDoug Rabson local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_unshare_4_svc;
485dfdcada3SDoug Rabson break;
486dfdcada3SDoug Rabson
487dfdcada3SDoug Rabson case NLM4_NM_LOCK:
488dfdcada3SDoug Rabson xdr_argument = (xdrproc_t) xdr_nlm4_lockargs;
489dfdcada3SDoug Rabson xdr_result = (xdrproc_t) xdr_nlm4_res;
490dfdcada3SDoug Rabson local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_nm_lock_4_svc;
491dfdcada3SDoug Rabson break;
492dfdcada3SDoug Rabson
493dfdcada3SDoug Rabson case NLM4_FREE_ALL:
494dfdcada3SDoug Rabson xdr_argument = (xdrproc_t) xdr_nlm4_notify;
495dfdcada3SDoug Rabson xdr_result = (xdrproc_t) xdr_void;
496dfdcada3SDoug Rabson local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_free_all_4_svc;
497dfdcada3SDoug Rabson break;
498dfdcada3SDoug Rabson
499dfdcada3SDoug Rabson default:
500a9148abdSDoug Rabson svcerr_noproc(rqstp);
501a9148abdSDoug Rabson svc_freereq(rqstp);
502dfdcada3SDoug Rabson return;
503dfdcada3SDoug Rabson }
504dfdcada3SDoug Rabson (void) memset((char *)&argument, 0, sizeof (argument));
505a9148abdSDoug Rabson if (!svc_getargs(rqstp, xdr_argument, (char *)(caddr_t) &argument)) {
506a9148abdSDoug Rabson svcerr_decode(rqstp);
507a9148abdSDoug Rabson svc_freereq(rqstp);
508dfdcada3SDoug Rabson return;
509dfdcada3SDoug Rabson }
510dfdcada3SDoug Rabson retval = (bool_t) (*local)((char *)&argument, (void *)&result, rqstp);
511a9148abdSDoug Rabson if (retval > 0 && !svc_sendreply(rqstp, xdr_result, (char *)&result)) {
512a9148abdSDoug Rabson svcerr_systemerr(rqstp);
513dfdcada3SDoug Rabson }
514a9148abdSDoug Rabson if (!svc_freeargs(rqstp, xdr_argument, (char *)(caddr_t) &argument)) {
515dfdcada3SDoug Rabson printf("unable to free arguments");
516dfdcada3SDoug Rabson //exit(1);
517dfdcada3SDoug Rabson }
518a9148abdSDoug Rabson svc_freereq(rqstp);
519dfdcada3SDoug Rabson if (!nlm_prog_4_freeresult(transp, xdr_result, (caddr_t) &result))
520dfdcada3SDoug Rabson printf("unable to free results");
521dfdcada3SDoug Rabson
522dfdcada3SDoug Rabson return;
523dfdcada3SDoug Rabson }
524