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