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$");
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(transp,
61 (xdrproc_t) xdr_void, (char *)NULL);
62 return;
63
64 case NLM_SM_NOTIFY:
65 xdr_argument = (xdrproc_t) xdr_nlm_sm_status;
66 xdr_result = (xdrproc_t) xdr_void;
67 local = (bool_t (*) (char *, void *, struct svc_req *))nlm_sm_notify_0_svc;
68 break;
69
70 default:
71 svcerr_noproc(transp);
72 return;
73 }
74 (void) memset((char *)&argument, 0, sizeof (argument));
75 if (!svc_getargs(transp, xdr_argument, (char *)(caddr_t) &argument)) {
76 svcerr_decode(transp);
77 return;
78 }
79 retval = (bool_t) (*local)((char *)&argument, (void *)&result, rqstp);
80 if (retval > 0 && !svc_sendreply(transp, xdr_result, (char *)&result)) {
81 svcerr_systemerr(transp);
82 }
83 if (!svc_freeargs(transp, xdr_argument, (char *)(caddr_t) &argument)) {
84 printf("unable to free arguments");
85 //exit(1);
86 }
87
88 return;
89 }
90
91 void
92 nlm_prog_1(struct svc_req *rqstp, SVCXPRT *transp)
93 {
94 union {
95 struct nlm_testargs nlm_test_1_arg;
96 struct nlm_lockargs nlm_lock_1_arg;
97 struct nlm_cancargs nlm_cancel_1_arg;
98 struct nlm_unlockargs nlm_unlock_1_arg;
99 struct nlm_testargs nlm_granted_1_arg;
100 struct nlm_testargs nlm_test_msg_1_arg;
101 struct nlm_lockargs nlm_lock_msg_1_arg;
102 struct nlm_cancargs nlm_cancel_msg_1_arg;
103 struct nlm_unlockargs nlm_unlock_msg_1_arg;
104 struct nlm_testargs nlm_granted_msg_1_arg;
105 nlm_testres nlm_test_res_1_arg;
106 nlm_res nlm_lock_res_1_arg;
107 nlm_res nlm_cancel_res_1_arg;
108 nlm_res nlm_unlock_res_1_arg;
109 nlm_res nlm_granted_res_1_arg;
110 } argument;
111 union {
112 nlm_testres nlm_test_1_res;
113 nlm_res nlm_lock_1_res;
114 nlm_res nlm_cancel_1_res;
115 nlm_res nlm_unlock_1_res;
116 nlm_res nlm_granted_1_res;
117 } result;
118 bool_t retval;
119 xdrproc_t xdr_argument, xdr_result;
120 bool_t (*local)(char *, void *, struct svc_req *);
121
122 switch (rqstp->rq_proc) {
123 case NULLPROC:
124 (void) svc_sendreply(transp,
125 (xdrproc_t) xdr_void, (char *)NULL);
126 return;
127
128 case NLM_TEST:
129 xdr_argument = (xdrproc_t) xdr_nlm_testargs;
130 xdr_result = (xdrproc_t) xdr_nlm_testres;
131 local = (bool_t (*) (char *, void *, struct svc_req *))nlm_test_1_svc;
132 break;
133
134 case NLM_LOCK:
135 xdr_argument = (xdrproc_t) xdr_nlm_lockargs;
136 xdr_result = (xdrproc_t) xdr_nlm_res;
137 local = (bool_t (*) (char *, void *, struct svc_req *))nlm_lock_1_svc;
138 break;
139
140 case NLM_CANCEL:
141 xdr_argument = (xdrproc_t) xdr_nlm_cancargs;
142 xdr_result = (xdrproc_t) xdr_nlm_res;
143 local = (bool_t (*) (char *, void *, struct svc_req *))nlm_cancel_1_svc;
144 break;
145
146 case NLM_UNLOCK:
147 xdr_argument = (xdrproc_t) xdr_nlm_unlockargs;
148 xdr_result = (xdrproc_t) xdr_nlm_res;
149 local = (bool_t (*) (char *, void *, struct svc_req *))nlm_unlock_1_svc;
150 break;
151
152 case NLM_GRANTED:
153 xdr_argument = (xdrproc_t) xdr_nlm_testargs;
154 xdr_result = (xdrproc_t) xdr_nlm_res;
155 local = (bool_t (*) (char *, void *, struct svc_req *))nlm_granted_1_svc;
156 break;
157
158 case NLM_TEST_MSG:
159 xdr_argument = (xdrproc_t) xdr_nlm_testargs;
160 xdr_result = (xdrproc_t) xdr_void;
161 local = (bool_t (*) (char *, void *, struct svc_req *))nlm_test_msg_1_svc;
162 break;
163
164 case NLM_LOCK_MSG:
165 xdr_argument = (xdrproc_t) xdr_nlm_lockargs;
166 xdr_result = (xdrproc_t) xdr_void;
167 local = (bool_t (*) (char *, void *, struct svc_req *))nlm_lock_msg_1_svc;
168 break;
169
170 case NLM_CANCEL_MSG:
171 xdr_argument = (xdrproc_t) xdr_nlm_cancargs;
172 xdr_result = (xdrproc_t) xdr_void;
173 local = (bool_t (*) (char *, void *, struct svc_req *))nlm_cancel_msg_1_svc;
174 break;
175
176 case NLM_UNLOCK_MSG:
177 xdr_argument = (xdrproc_t) xdr_nlm_unlockargs;
178 xdr_result = (xdrproc_t) xdr_void;
179 local = (bool_t (*) (char *, void *, struct svc_req *))nlm_unlock_msg_1_svc;
180 break;
181
182 case NLM_GRANTED_MSG:
183 xdr_argument = (xdrproc_t) xdr_nlm_testargs;
184 xdr_result = (xdrproc_t) xdr_void;
185 local = (bool_t (*) (char *, void *, struct svc_req *))nlm_granted_msg_1_svc;
186 break;
187
188 case NLM_TEST_RES:
189 xdr_argument = (xdrproc_t) xdr_nlm_testres;
190 xdr_result = (xdrproc_t) xdr_void;
191 local = (bool_t (*) (char *, void *, struct svc_req *))nlm_test_res_1_svc;
192 break;
193
194 case NLM_LOCK_RES:
195 xdr_argument = (xdrproc_t) xdr_nlm_res;
196 xdr_result = (xdrproc_t) xdr_void;
197 local = (bool_t (*) (char *, void *, struct svc_req *))nlm_lock_res_1_svc;
198 break;
199
200 case NLM_CANCEL_RES:
201 xdr_argument = (xdrproc_t) xdr_nlm_res;
202 xdr_result = (xdrproc_t) xdr_void;
203 local = (bool_t (*) (char *, void *, struct svc_req *))nlm_cancel_res_1_svc;
204 break;
205
206 case NLM_UNLOCK_RES:
207 xdr_argument = (xdrproc_t) xdr_nlm_res;
208 xdr_result = (xdrproc_t) xdr_void;
209 local = (bool_t (*) (char *, void *, struct svc_req *))nlm_unlock_res_1_svc;
210 break;
211
212 case NLM_GRANTED_RES:
213 xdr_argument = (xdrproc_t) xdr_nlm_res;
214 xdr_result = (xdrproc_t) xdr_void;
215 local = (bool_t (*) (char *, void *, struct svc_req *))nlm_granted_res_1_svc;
216 break;
217
218 default:
219 svcerr_noproc(transp);
220 return;
221 }
222 (void) memset((char *)&argument, 0, sizeof (argument));
223 if (!svc_getargs(transp, xdr_argument, (char *)(caddr_t) &argument)) {
224 svcerr_decode(transp);
225 return;
226 }
227 retval = (bool_t) (*local)((char *)&argument, (void *)&result, rqstp);
228 if (retval > 0 && !svc_sendreply(transp, xdr_result, (char *)&result)) {
229 svcerr_systemerr(transp);
230 }
231 if (!svc_freeargs(transp, xdr_argument, (char *)(caddr_t) &argument)) {
232 printf("unable to free arguments");
233 //exit(1);
234 }
235 if (!nlm_prog_1_freeresult(transp, xdr_result, (caddr_t) &result))
236 printf("unable to free results");
237
238 return;
239 }
240
241 void
242 nlm_prog_3(struct svc_req *rqstp, SVCXPRT *transp)
243 {
244 union {
245 nlm_shareargs nlm_share_3_arg;
246 nlm_shareargs nlm_unshare_3_arg;
247 nlm_lockargs nlm_nm_lock_3_arg;
248 nlm_notify nlm_free_all_3_arg;
249 } argument;
250 union {
251 nlm_shareres nlm_share_3_res;
252 nlm_shareres nlm_unshare_3_res;
253 nlm_res nlm_nm_lock_3_res;
254 } result;
255 bool_t retval;
256 xdrproc_t xdr_argument, xdr_result;
257 bool_t (*local)(char *, void *, struct svc_req *);
258
259 switch (rqstp->rq_proc) {
260 case NULLPROC:
261 (void) svc_sendreply(transp,
262 (xdrproc_t) xdr_void, (char *)NULL);
263 return;
264
265 case NLM_TEST:
266 case NLM_LOCK:
267 case NLM_CANCEL:
268 case NLM_UNLOCK:
269 case NLM_GRANTED:
270 case NLM_TEST_MSG:
271 case NLM_LOCK_MSG:
272 case NLM_CANCEL_MSG:
273 case NLM_UNLOCK_MSG:
274 case NLM_GRANTED_MSG:
275 case NLM_TEST_RES:
276 case NLM_LOCK_RES:
277 case NLM_CANCEL_RES:
278 case NLM_UNLOCK_RES:
279 case NLM_GRANTED_RES:
280 nlm_prog_1(rqstp, transp);
281 return;
282
283 case NLM_SHARE:
284 xdr_argument = (xdrproc_t) xdr_nlm_shareargs;
285 xdr_result = (xdrproc_t) xdr_nlm_shareres;
286 local = (bool_t (*) (char *, void *, struct svc_req *))nlm_share_3_svc;
287 break;
288
289 case NLM_UNSHARE:
290 xdr_argument = (xdrproc_t) xdr_nlm_shareargs;
291 xdr_result = (xdrproc_t) xdr_nlm_shareres;
292 local = (bool_t (*) (char *, void *, struct svc_req *))nlm_unshare_3_svc;
293 break;
294
295 case NLM_NM_LOCK:
296 xdr_argument = (xdrproc_t) xdr_nlm_lockargs;
297 xdr_result = (xdrproc_t) xdr_nlm_res;
298 local = (bool_t (*) (char *, void *, struct svc_req *))nlm_nm_lock_3_svc;
299 break;
300
301 case NLM_FREE_ALL:
302 xdr_argument = (xdrproc_t) xdr_nlm_notify;
303 xdr_result = (xdrproc_t) xdr_void;
304 local = (bool_t (*) (char *, void *, struct svc_req *))nlm_free_all_3_svc;
305 break;
306
307 default:
308 svcerr_noproc(transp);
309 return;
310 }
311 (void) memset((char *)&argument, 0, sizeof (argument));
312 if (!svc_getargs(transp, xdr_argument, (char *)(caddr_t) &argument)) {
313 svcerr_decode(transp);
314 return;
315 }
316 retval = (bool_t) (*local)((char *)&argument, (void *)&result, rqstp);
317 if (retval > 0 && !svc_sendreply(transp, xdr_result, (char *)&result)) {
318 svcerr_systemerr(transp);
319 }
320 if (!svc_freeargs(transp, xdr_argument, (char *)(caddr_t) &argument)) {
321 printf("unable to free arguments");
322 //exit(1);
323 }
324 if (!nlm_prog_3_freeresult(transp, xdr_result, (caddr_t) &result))
325 printf("unable to free results");
326
327 return;
328 }
329
330 void
331 nlm_prog_4(struct svc_req *rqstp, SVCXPRT *transp)
332 {
333 union {
334 nlm4_testargs nlm4_test_4_arg;
335 nlm4_lockargs nlm4_lock_4_arg;
336 nlm4_cancargs nlm4_cancel_4_arg;
337 nlm4_unlockargs nlm4_unlock_4_arg;
338 nlm4_testargs nlm4_granted_4_arg;
339 nlm4_testargs nlm4_test_msg_4_arg;
340 nlm4_lockargs nlm4_lock_msg_4_arg;
341 nlm4_cancargs nlm4_cancel_msg_4_arg;
342 nlm4_unlockargs nlm4_unlock_msg_4_arg;
343 nlm4_testargs nlm4_granted_msg_4_arg;
344 nlm4_testres nlm4_test_res_4_arg;
345 nlm4_res nlm4_lock_res_4_arg;
346 nlm4_res nlm4_cancel_res_4_arg;
347 nlm4_res nlm4_unlock_res_4_arg;
348 nlm4_res nlm4_granted_res_4_arg;
349 nlm4_shareargs nlm4_share_4_arg;
350 nlm4_shareargs nlm4_unshare_4_arg;
351 nlm4_lockargs nlm4_nm_lock_4_arg;
352 nlm4_notify nlm4_free_all_4_arg;
353 } argument;
354 union {
355 nlm4_testres nlm4_test_4_res;
356 nlm4_res nlm4_lock_4_res;
357 nlm4_res nlm4_cancel_4_res;
358 nlm4_res nlm4_unlock_4_res;
359 nlm4_res nlm4_granted_4_res;
360 nlm4_shareres nlm4_share_4_res;
361 nlm4_shareres nlm4_unshare_4_res;
362 nlm4_res nlm4_nm_lock_4_res;
363 } result;
364 bool_t retval;
365 xdrproc_t xdr_argument, xdr_result;
366 bool_t (*local)(char *, void *, struct svc_req *);
367
368 switch (rqstp->rq_proc) {
369 case NULLPROC:
370 (void) svc_sendreply(transp,
371 (xdrproc_t) xdr_void, (char *)NULL);
372 return;
373
374 case NLM4_TEST:
375 xdr_argument = (xdrproc_t) xdr_nlm4_testargs;
376 xdr_result = (xdrproc_t) xdr_nlm4_testres;
377 local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_test_4_svc;
378 break;
379
380 case NLM4_LOCK:
381 xdr_argument = (xdrproc_t) xdr_nlm4_lockargs;
382 xdr_result = (xdrproc_t) xdr_nlm4_res;
383 local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_lock_4_svc;
384 break;
385
386 case NLM4_CANCEL:
387 xdr_argument = (xdrproc_t) xdr_nlm4_cancargs;
388 xdr_result = (xdrproc_t) xdr_nlm4_res;
389 local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_cancel_4_svc;
390 break;
391
392 case NLM4_UNLOCK:
393 xdr_argument = (xdrproc_t) xdr_nlm4_unlockargs;
394 xdr_result = (xdrproc_t) xdr_nlm4_res;
395 local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_unlock_4_svc;
396 break;
397
398 case NLM4_GRANTED:
399 xdr_argument = (xdrproc_t) xdr_nlm4_testargs;
400 xdr_result = (xdrproc_t) xdr_nlm4_res;
401 local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_granted_4_svc;
402 break;
403
404 case NLM4_TEST_MSG:
405 xdr_argument = (xdrproc_t) xdr_nlm4_testargs;
406 xdr_result = (xdrproc_t) xdr_void;
407 local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_test_msg_4_svc;
408 break;
409
410 case NLM4_LOCK_MSG:
411 xdr_argument = (xdrproc_t) xdr_nlm4_lockargs;
412 xdr_result = (xdrproc_t) xdr_void;
413 local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_lock_msg_4_svc;
414 break;
415
416 case NLM4_CANCEL_MSG:
417 xdr_argument = (xdrproc_t) xdr_nlm4_cancargs;
418 xdr_result = (xdrproc_t) xdr_void;
419 local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_cancel_msg_4_svc;
420 break;
421
422 case NLM4_UNLOCK_MSG:
423 xdr_argument = (xdrproc_t) xdr_nlm4_unlockargs;
424 xdr_result = (xdrproc_t) xdr_void;
425 local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_unlock_msg_4_svc;
426 break;
427
428 case NLM4_GRANTED_MSG:
429 xdr_argument = (xdrproc_t) xdr_nlm4_testargs;
430 xdr_result = (xdrproc_t) xdr_void;
431 local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_granted_msg_4_svc;
432 break;
433
434 case NLM4_TEST_RES:
435 xdr_argument = (xdrproc_t) xdr_nlm4_testres;
436 xdr_result = (xdrproc_t) xdr_void;
437 local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_test_res_4_svc;
438 break;
439
440 case NLM4_LOCK_RES:
441 xdr_argument = (xdrproc_t) xdr_nlm4_res;
442 xdr_result = (xdrproc_t) xdr_void;
443 local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_lock_res_4_svc;
444 break;
445
446 case NLM4_CANCEL_RES:
447 xdr_argument = (xdrproc_t) xdr_nlm4_res;
448 xdr_result = (xdrproc_t) xdr_void;
449 local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_cancel_res_4_svc;
450 break;
451
452 case NLM4_UNLOCK_RES:
453 xdr_argument = (xdrproc_t) xdr_nlm4_res;
454 xdr_result = (xdrproc_t) xdr_void;
455 local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_unlock_res_4_svc;
456 break;
457
458 case NLM4_GRANTED_RES:
459 xdr_argument = (xdrproc_t) xdr_nlm4_res;
460 xdr_result = (xdrproc_t) xdr_void;
461 local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_granted_res_4_svc;
462 break;
463
464 case NLM4_SHARE:
465 xdr_argument = (xdrproc_t) xdr_nlm4_shareargs;
466 xdr_result = (xdrproc_t) xdr_nlm4_shareres;
467 local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_share_4_svc;
468 break;
469
470 case NLM4_UNSHARE:
471 xdr_argument = (xdrproc_t) xdr_nlm4_shareargs;
472 xdr_result = (xdrproc_t) xdr_nlm4_shareres;
473 local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_unshare_4_svc;
474 break;
475
476 case NLM4_NM_LOCK:
477 xdr_argument = (xdrproc_t) xdr_nlm4_lockargs;
478 xdr_result = (xdrproc_t) xdr_nlm4_res;
479 local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_nm_lock_4_svc;
480 break;
481
482 case NLM4_FREE_ALL:
483 xdr_argument = (xdrproc_t) xdr_nlm4_notify;
484 xdr_result = (xdrproc_t) xdr_void;
485 local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_free_all_4_svc;
486 break;
487
488 default:
489 svcerr_noproc(transp);
490 return;
491 }
492 (void) memset((char *)&argument, 0, sizeof (argument));
493 if (!svc_getargs(transp, xdr_argument, (char *)(caddr_t) &argument)) {
494 svcerr_decode(transp);
495 return;
496 }
497 retval = (bool_t) (*local)((char *)&argument, (void *)&result, rqstp);
498 if (retval > 0 && !svc_sendreply(transp, xdr_result, (char *)&result)) {
499 svcerr_systemerr(transp);
500 }
501 if (!svc_freeargs(transp, xdr_argument, (char *)(caddr_t) &argument)) {
502 printf("unable to free arguments");
503 //exit(1);
504 }
505 if (!nlm_prog_4_freeresult(transp, xdr_result, (caddr_t) &result))
506 printf("unable to free results");
507
508 return;
509 }
Cache object: 2a43b75b03fda244468d423d442a665a
|