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