1*d687e96aSpgoyette /* $NetBSD: nlm_prot_svc.c,v 1.2 2016/12/13 21:58:17 pgoyette Exp $ */
26ca35587Sdholland /*-
36ca35587Sdholland * Copyright (c) 2008 Isilon Inc http://www.isilon.com/
46ca35587Sdholland * Authors: Doug Rabson <dfr@rabson.org>
56ca35587Sdholland * Developed with Red Inc: Alfred Perlstein <alfred@freebsd.org>
66ca35587Sdholland *
76ca35587Sdholland * Redistribution and use in source and binary forms, with or without
86ca35587Sdholland * modification, are permitted provided that the following conditions
96ca35587Sdholland * are met:
106ca35587Sdholland * 1. Redistributions of source code must retain the above copyright
116ca35587Sdholland * notice, this list of conditions and the following disclaimer.
126ca35587Sdholland * 2. Redistributions in binary form must reproduce the above copyright
136ca35587Sdholland * notice, this list of conditions and the following disclaimer in the
146ca35587Sdholland * documentation and/or other materials provided with the distribution.
156ca35587Sdholland *
166ca35587Sdholland * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
176ca35587Sdholland * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
186ca35587Sdholland * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
196ca35587Sdholland * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
206ca35587Sdholland * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
216ca35587Sdholland * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
226ca35587Sdholland * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
236ca35587Sdholland * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
246ca35587Sdholland * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
256ca35587Sdholland * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
266ca35587Sdholland * SUCH DAMAGE.
276ca35587Sdholland */
286ca35587Sdholland
296ca35587Sdholland #include <sys/param.h>
306ca35587Sdholland #include <sys/systm.h>
316ca35587Sdholland
32*d687e96aSpgoyette #include <fs/nfs/nlm/nlm_prot.h>
33*d687e96aSpgoyette #include <fs/nfs/nlm/nlm.h>
346ca35587Sdholland
356ca35587Sdholland #include <sys/cdefs.h>
366ca35587Sdholland #ifndef lint
376ca35587Sdholland /*static char sccsid[] = "from: @(#)nlm_prot.x 1.8 87/09/21 Copyr 1987 Sun Micro";*/
386ca35587Sdholland /*static char sccsid[] = "from: * @(#)nlm_prot.x 2.1 88/08/01 4.0 RPCSRC";*/
396ca35587Sdholland /* __RCSID("NetBSD: nlm_prot.x,v 1.6 2000/06/07 14:30:15 bouyer Exp "); */
406ca35587Sdholland #endif /* not lint */
416ca35587Sdholland /* __FBSDID("FreeBSD: head/sys/nlm/nlm_prot_svc.c 184886 2008-11-12 15:30:30Z dfr "); */
42*d687e96aSpgoyette __RCSID("$NetBSD: nlm_prot_svc.c,v 1.2 2016/12/13 21:58:17 pgoyette Exp $");
436ca35587Sdholland
446ca35587Sdholland void nlm_prog_0(struct svc_req *rqstp, SVCXPRT *transp);
456ca35587Sdholland void nlm_prog_1(struct svc_req *rqstp, SVCXPRT *transp);
466ca35587Sdholland void nlm_prog_3(struct svc_req *rqstp, SVCXPRT *transp);
476ca35587Sdholland void nlm_prog_4(struct svc_req *rqstp, SVCXPRT *transp);
486ca35587Sdholland
496ca35587Sdholland void
nlm_prog_0(struct svc_req * rqstp,SVCXPRT * transp)506ca35587Sdholland nlm_prog_0(struct svc_req *rqstp, SVCXPRT *transp)
516ca35587Sdholland {
526ca35587Sdholland union {
536ca35587Sdholland struct nlm_sm_status nlm_sm_notify_0_arg;
546ca35587Sdholland } argument;
556ca35587Sdholland char result;
566ca35587Sdholland bool_t retval;
576ca35587Sdholland xdrproc_t xdr_argument, xdr_result;
586ca35587Sdholland bool_t (*local)(char *, void *, struct svc_req *);
596ca35587Sdholland
606ca35587Sdholland switch (rqstp->rq_proc) {
616ca35587Sdholland case NULLPROC:
626ca35587Sdholland (void) svc_sendreply(rqstp,
636ca35587Sdholland (xdrproc_t) xdr_void, (char *)NULL);
646ca35587Sdholland svc_freereq(rqstp);
656ca35587Sdholland return;
666ca35587Sdholland
676ca35587Sdholland case NLM_SM_NOTIFY:
686ca35587Sdholland xdr_argument = (xdrproc_t) xdr_nlm_sm_status;
696ca35587Sdholland xdr_result = (xdrproc_t) xdr_void;
706ca35587Sdholland local = (bool_t (*) (char *, void *, struct svc_req *))nlm_sm_notify_0_svc;
716ca35587Sdholland break;
726ca35587Sdholland
736ca35587Sdholland default:
746ca35587Sdholland svcerr_noproc(rqstp);
756ca35587Sdholland svc_freereq(rqstp);
766ca35587Sdholland return;
776ca35587Sdholland }
786ca35587Sdholland (void) memset((char *)&argument, 0, sizeof (argument));
796ca35587Sdholland if (!svc_getargs(rqstp, xdr_argument, (char *)(caddr_t) &argument)) {
806ca35587Sdholland svcerr_decode(rqstp);
816ca35587Sdholland svc_freereq(rqstp);
826ca35587Sdholland return;
836ca35587Sdholland }
846ca35587Sdholland retval = (bool_t) (*local)((char *)&argument, (void *)&result, rqstp);
856ca35587Sdholland if (retval > 0 && !svc_sendreply(rqstp, xdr_result, (char *)&result)) {
866ca35587Sdholland svcerr_systemerr(rqstp);
876ca35587Sdholland }
886ca35587Sdholland if (!svc_freeargs(rqstp, xdr_argument, (char *)(caddr_t) &argument)) {
896ca35587Sdholland printf("unable to free arguments");
906ca35587Sdholland //exit(1);
916ca35587Sdholland }
926ca35587Sdholland svc_freereq(rqstp);
936ca35587Sdholland
946ca35587Sdholland return;
956ca35587Sdholland }
966ca35587Sdholland
976ca35587Sdholland void
nlm_prog_1(struct svc_req * rqstp,SVCXPRT * transp)986ca35587Sdholland nlm_prog_1(struct svc_req *rqstp, SVCXPRT *transp)
996ca35587Sdholland {
1006ca35587Sdholland union {
1016ca35587Sdholland struct nlm_testargs nlm_test_1_arg;
1026ca35587Sdholland struct nlm_lockargs nlm_lock_1_arg;
1036ca35587Sdholland struct nlm_cancargs nlm_cancel_1_arg;
1046ca35587Sdholland struct nlm_unlockargs nlm_unlock_1_arg;
1056ca35587Sdholland struct nlm_testargs nlm_granted_1_arg;
1066ca35587Sdholland struct nlm_testargs nlm_test_msg_1_arg;
1076ca35587Sdholland struct nlm_lockargs nlm_lock_msg_1_arg;
1086ca35587Sdholland struct nlm_cancargs nlm_cancel_msg_1_arg;
1096ca35587Sdholland struct nlm_unlockargs nlm_unlock_msg_1_arg;
1106ca35587Sdholland struct nlm_testargs nlm_granted_msg_1_arg;
1116ca35587Sdholland nlm_testres nlm_test_res_1_arg;
1126ca35587Sdholland nlm_res nlm_lock_res_1_arg;
1136ca35587Sdholland nlm_res nlm_cancel_res_1_arg;
1146ca35587Sdholland nlm_res nlm_unlock_res_1_arg;
1156ca35587Sdholland nlm_res nlm_granted_res_1_arg;
1166ca35587Sdholland } argument;
1176ca35587Sdholland union {
1186ca35587Sdholland nlm_testres nlm_test_1_res;
1196ca35587Sdholland nlm_res nlm_lock_1_res;
1206ca35587Sdholland nlm_res nlm_cancel_1_res;
1216ca35587Sdholland nlm_res nlm_unlock_1_res;
1226ca35587Sdholland nlm_res nlm_granted_1_res;
1236ca35587Sdholland } result;
1246ca35587Sdholland bool_t retval;
1256ca35587Sdholland xdrproc_t xdr_argument, xdr_result;
1266ca35587Sdholland bool_t (*local)(char *, void *, struct svc_req *);
1276ca35587Sdholland
1286ca35587Sdholland switch (rqstp->rq_proc) {
1296ca35587Sdholland case NULLPROC:
1306ca35587Sdholland (void) svc_sendreply(rqstp,
1316ca35587Sdholland (xdrproc_t) xdr_void, (char *)NULL);
1326ca35587Sdholland svc_freereq(rqstp);
1336ca35587Sdholland return;
1346ca35587Sdholland
1356ca35587Sdholland case NLM_TEST:
1366ca35587Sdholland xdr_argument = (xdrproc_t) xdr_nlm_testargs;
1376ca35587Sdholland xdr_result = (xdrproc_t) xdr_nlm_testres;
1386ca35587Sdholland local = (bool_t (*) (char *, void *, struct svc_req *))nlm_test_1_svc;
1396ca35587Sdholland break;
1406ca35587Sdholland
1416ca35587Sdholland case NLM_LOCK:
1426ca35587Sdholland xdr_argument = (xdrproc_t) xdr_nlm_lockargs;
1436ca35587Sdholland xdr_result = (xdrproc_t) xdr_nlm_res;
1446ca35587Sdholland local = (bool_t (*) (char *, void *, struct svc_req *))nlm_lock_1_svc;
1456ca35587Sdholland break;
1466ca35587Sdholland
1476ca35587Sdholland case NLM_CANCEL:
1486ca35587Sdholland xdr_argument = (xdrproc_t) xdr_nlm_cancargs;
1496ca35587Sdholland xdr_result = (xdrproc_t) xdr_nlm_res;
1506ca35587Sdholland local = (bool_t (*) (char *, void *, struct svc_req *))nlm_cancel_1_svc;
1516ca35587Sdholland break;
1526ca35587Sdholland
1536ca35587Sdholland case NLM_UNLOCK:
1546ca35587Sdholland xdr_argument = (xdrproc_t) xdr_nlm_unlockargs;
1556ca35587Sdholland xdr_result = (xdrproc_t) xdr_nlm_res;
1566ca35587Sdholland local = (bool_t (*) (char *, void *, struct svc_req *))nlm_unlock_1_svc;
1576ca35587Sdholland break;
1586ca35587Sdholland
1596ca35587Sdholland case NLM_GRANTED:
1606ca35587Sdholland xdr_argument = (xdrproc_t) xdr_nlm_testargs;
1616ca35587Sdholland xdr_result = (xdrproc_t) xdr_nlm_res;
1626ca35587Sdholland local = (bool_t (*) (char *, void *, struct svc_req *))nlm_granted_1_svc;
1636ca35587Sdholland break;
1646ca35587Sdholland
1656ca35587Sdholland case NLM_TEST_MSG:
1666ca35587Sdholland xdr_argument = (xdrproc_t) xdr_nlm_testargs;
1676ca35587Sdholland xdr_result = (xdrproc_t) xdr_void;
1686ca35587Sdholland local = (bool_t (*) (char *, void *, struct svc_req *))nlm_test_msg_1_svc;
1696ca35587Sdholland break;
1706ca35587Sdholland
1716ca35587Sdholland case NLM_LOCK_MSG:
1726ca35587Sdholland xdr_argument = (xdrproc_t) xdr_nlm_lockargs;
1736ca35587Sdholland xdr_result = (xdrproc_t) xdr_void;
1746ca35587Sdholland local = (bool_t (*) (char *, void *, struct svc_req *))nlm_lock_msg_1_svc;
1756ca35587Sdholland break;
1766ca35587Sdholland
1776ca35587Sdholland case NLM_CANCEL_MSG:
1786ca35587Sdholland xdr_argument = (xdrproc_t) xdr_nlm_cancargs;
1796ca35587Sdholland xdr_result = (xdrproc_t) xdr_void;
1806ca35587Sdholland local = (bool_t (*) (char *, void *, struct svc_req *))nlm_cancel_msg_1_svc;
1816ca35587Sdholland break;
1826ca35587Sdholland
1836ca35587Sdholland case NLM_UNLOCK_MSG:
1846ca35587Sdholland xdr_argument = (xdrproc_t) xdr_nlm_unlockargs;
1856ca35587Sdholland xdr_result = (xdrproc_t) xdr_void;
1866ca35587Sdholland local = (bool_t (*) (char *, void *, struct svc_req *))nlm_unlock_msg_1_svc;
1876ca35587Sdholland break;
1886ca35587Sdholland
1896ca35587Sdholland case NLM_GRANTED_MSG:
1906ca35587Sdholland xdr_argument = (xdrproc_t) xdr_nlm_testargs;
1916ca35587Sdholland xdr_result = (xdrproc_t) xdr_void;
1926ca35587Sdholland local = (bool_t (*) (char *, void *, struct svc_req *))nlm_granted_msg_1_svc;
1936ca35587Sdholland break;
1946ca35587Sdholland
1956ca35587Sdholland case NLM_TEST_RES:
1966ca35587Sdholland xdr_argument = (xdrproc_t) xdr_nlm_testres;
1976ca35587Sdholland xdr_result = (xdrproc_t) xdr_void;
1986ca35587Sdholland local = (bool_t (*) (char *, void *, struct svc_req *))nlm_test_res_1_svc;
1996ca35587Sdholland break;
2006ca35587Sdholland
2016ca35587Sdholland case NLM_LOCK_RES:
2026ca35587Sdholland xdr_argument = (xdrproc_t) xdr_nlm_res;
2036ca35587Sdholland xdr_result = (xdrproc_t) xdr_void;
2046ca35587Sdholland local = (bool_t (*) (char *, void *, struct svc_req *))nlm_lock_res_1_svc;
2056ca35587Sdholland break;
2066ca35587Sdholland
2076ca35587Sdholland case NLM_CANCEL_RES:
2086ca35587Sdholland xdr_argument = (xdrproc_t) xdr_nlm_res;
2096ca35587Sdholland xdr_result = (xdrproc_t) xdr_void;
2106ca35587Sdholland local = (bool_t (*) (char *, void *, struct svc_req *))nlm_cancel_res_1_svc;
2116ca35587Sdholland break;
2126ca35587Sdholland
2136ca35587Sdholland case NLM_UNLOCK_RES:
2146ca35587Sdholland xdr_argument = (xdrproc_t) xdr_nlm_res;
2156ca35587Sdholland xdr_result = (xdrproc_t) xdr_void;
2166ca35587Sdholland local = (bool_t (*) (char *, void *, struct svc_req *))nlm_unlock_res_1_svc;
2176ca35587Sdholland break;
2186ca35587Sdholland
2196ca35587Sdholland case NLM_GRANTED_RES:
2206ca35587Sdholland xdr_argument = (xdrproc_t) xdr_nlm_res;
2216ca35587Sdholland xdr_result = (xdrproc_t) xdr_void;
2226ca35587Sdholland local = (bool_t (*) (char *, void *, struct svc_req *))nlm_granted_res_1_svc;
2236ca35587Sdholland break;
2246ca35587Sdholland
2256ca35587Sdholland default:
2266ca35587Sdholland svcerr_noproc(rqstp);
2276ca35587Sdholland svc_freereq(rqstp);
2286ca35587Sdholland return;
2296ca35587Sdholland }
2306ca35587Sdholland (void) memset((char *)&argument, 0, sizeof (argument));
2316ca35587Sdholland if (!svc_getargs(rqstp, xdr_argument, (char *)(caddr_t) &argument)) {
2326ca35587Sdholland svcerr_decode(rqstp);
2336ca35587Sdholland svc_freereq(rqstp);
2346ca35587Sdholland return;
2356ca35587Sdholland }
2366ca35587Sdholland retval = (bool_t) (*local)((char *)&argument, (void *)&result, rqstp);
2376ca35587Sdholland if (retval > 0 && !svc_sendreply(rqstp, xdr_result, (char *)&result)) {
2386ca35587Sdholland svcerr_systemerr(rqstp);
2396ca35587Sdholland }
2406ca35587Sdholland if (!svc_freeargs(rqstp, xdr_argument, (char *)(caddr_t) &argument)) {
2416ca35587Sdholland printf("unable to free arguments");
2426ca35587Sdholland //exit(1);
2436ca35587Sdholland }
2446ca35587Sdholland svc_freereq(rqstp);
2456ca35587Sdholland if (!nlm_prog_1_freeresult(transp, xdr_result, (caddr_t) &result))
2466ca35587Sdholland printf("unable to free results");
2476ca35587Sdholland
2486ca35587Sdholland return;
2496ca35587Sdholland }
2506ca35587Sdholland
2516ca35587Sdholland void
nlm_prog_3(struct svc_req * rqstp,SVCXPRT * transp)2526ca35587Sdholland nlm_prog_3(struct svc_req *rqstp, SVCXPRT *transp)
2536ca35587Sdholland {
2546ca35587Sdholland union {
2556ca35587Sdholland nlm_shareargs nlm_share_3_arg;
2566ca35587Sdholland nlm_shareargs nlm_unshare_3_arg;
2576ca35587Sdholland nlm_lockargs nlm_nm_lock_3_arg;
2586ca35587Sdholland nlm_notify nlm_free_all_3_arg;
2596ca35587Sdholland } argument;
2606ca35587Sdholland union {
2616ca35587Sdholland nlm_shareres nlm_share_3_res;
2626ca35587Sdholland nlm_shareres nlm_unshare_3_res;
2636ca35587Sdholland nlm_res nlm_nm_lock_3_res;
2646ca35587Sdholland } result;
2656ca35587Sdholland bool_t retval;
2666ca35587Sdholland xdrproc_t xdr_argument, xdr_result;
2676ca35587Sdholland bool_t (*local)(char *, void *, struct svc_req *);
2686ca35587Sdholland
2696ca35587Sdholland switch (rqstp->rq_proc) {
2706ca35587Sdholland case NULLPROC:
2716ca35587Sdholland (void) svc_sendreply(rqstp,
2726ca35587Sdholland (xdrproc_t) xdr_void, (char *)NULL);
2736ca35587Sdholland svc_freereq(rqstp);
2746ca35587Sdholland return;
2756ca35587Sdholland
2766ca35587Sdholland case NLM_TEST:
2776ca35587Sdholland case NLM_LOCK:
2786ca35587Sdholland case NLM_CANCEL:
2796ca35587Sdholland case NLM_UNLOCK:
2806ca35587Sdholland case NLM_GRANTED:
2816ca35587Sdholland case NLM_TEST_MSG:
2826ca35587Sdholland case NLM_LOCK_MSG:
2836ca35587Sdholland case NLM_CANCEL_MSG:
2846ca35587Sdholland case NLM_UNLOCK_MSG:
2856ca35587Sdholland case NLM_GRANTED_MSG:
2866ca35587Sdholland case NLM_TEST_RES:
2876ca35587Sdholland case NLM_LOCK_RES:
2886ca35587Sdholland case NLM_CANCEL_RES:
2896ca35587Sdholland case NLM_UNLOCK_RES:
2906ca35587Sdholland case NLM_GRANTED_RES:
2916ca35587Sdholland nlm_prog_1(rqstp, transp);
2926ca35587Sdholland return;
2936ca35587Sdholland
2946ca35587Sdholland case NLM_SHARE:
2956ca35587Sdholland xdr_argument = (xdrproc_t) xdr_nlm_shareargs;
2966ca35587Sdholland xdr_result = (xdrproc_t) xdr_nlm_shareres;
2976ca35587Sdholland local = (bool_t (*) (char *, void *, struct svc_req *))nlm_share_3_svc;
2986ca35587Sdholland break;
2996ca35587Sdholland
3006ca35587Sdholland case NLM_UNSHARE:
3016ca35587Sdholland xdr_argument = (xdrproc_t) xdr_nlm_shareargs;
3026ca35587Sdholland xdr_result = (xdrproc_t) xdr_nlm_shareres;
3036ca35587Sdholland local = (bool_t (*) (char *, void *, struct svc_req *))nlm_unshare_3_svc;
3046ca35587Sdholland break;
3056ca35587Sdholland
3066ca35587Sdholland case NLM_NM_LOCK:
3076ca35587Sdholland xdr_argument = (xdrproc_t) xdr_nlm_lockargs;
3086ca35587Sdholland xdr_result = (xdrproc_t) xdr_nlm_res;
3096ca35587Sdholland local = (bool_t (*) (char *, void *, struct svc_req *))nlm_nm_lock_3_svc;
3106ca35587Sdholland break;
3116ca35587Sdholland
3126ca35587Sdholland case NLM_FREE_ALL:
3136ca35587Sdholland xdr_argument = (xdrproc_t) xdr_nlm_notify;
3146ca35587Sdholland xdr_result = (xdrproc_t) xdr_void;
3156ca35587Sdholland local = (bool_t (*) (char *, void *, struct svc_req *))nlm_free_all_3_svc;
3166ca35587Sdholland break;
3176ca35587Sdholland
3186ca35587Sdholland default:
3196ca35587Sdholland svcerr_noproc(rqstp);
3206ca35587Sdholland svc_freereq(rqstp);
3216ca35587Sdholland return;
3226ca35587Sdholland }
3236ca35587Sdholland (void) memset((char *)&argument, 0, sizeof (argument));
3246ca35587Sdholland if (!svc_getargs(rqstp, xdr_argument, (char *)(caddr_t) &argument)) {
3256ca35587Sdholland svcerr_decode(rqstp);
3266ca35587Sdholland svc_freereq(rqstp);
3276ca35587Sdholland return;
3286ca35587Sdholland }
3296ca35587Sdholland retval = (bool_t) (*local)((char *)&argument, (void *)&result, rqstp);
3306ca35587Sdholland if (retval > 0 && !svc_sendreply(rqstp, xdr_result, (char *)&result)) {
3316ca35587Sdholland svcerr_systemerr(rqstp);
3326ca35587Sdholland }
3336ca35587Sdholland if (!svc_freeargs(rqstp, xdr_argument, (char *)(caddr_t) &argument)) {
3346ca35587Sdholland printf("unable to free arguments");
3356ca35587Sdholland //exit(1);
3366ca35587Sdholland }
3376ca35587Sdholland svc_freereq(rqstp);
3386ca35587Sdholland if (!nlm_prog_3_freeresult(transp, xdr_result, (caddr_t) &result))
3396ca35587Sdholland printf("unable to free results");
3406ca35587Sdholland
3416ca35587Sdholland return;
3426ca35587Sdholland }
3436ca35587Sdholland
3446ca35587Sdholland void
nlm_prog_4(struct svc_req * rqstp,SVCXPRT * transp)3456ca35587Sdholland nlm_prog_4(struct svc_req *rqstp, SVCXPRT *transp)
3466ca35587Sdholland {
3476ca35587Sdholland union {
3486ca35587Sdholland nlm4_testargs nlm4_test_4_arg;
3496ca35587Sdholland nlm4_lockargs nlm4_lock_4_arg;
3506ca35587Sdholland nlm4_cancargs nlm4_cancel_4_arg;
3516ca35587Sdholland nlm4_unlockargs nlm4_unlock_4_arg;
3526ca35587Sdholland nlm4_testargs nlm4_granted_4_arg;
3536ca35587Sdholland nlm4_testargs nlm4_test_msg_4_arg;
3546ca35587Sdholland nlm4_lockargs nlm4_lock_msg_4_arg;
3556ca35587Sdholland nlm4_cancargs nlm4_cancel_msg_4_arg;
3566ca35587Sdholland nlm4_unlockargs nlm4_unlock_msg_4_arg;
3576ca35587Sdholland nlm4_testargs nlm4_granted_msg_4_arg;
3586ca35587Sdholland nlm4_testres nlm4_test_res_4_arg;
3596ca35587Sdholland nlm4_res nlm4_lock_res_4_arg;
3606ca35587Sdholland nlm4_res nlm4_cancel_res_4_arg;
3616ca35587Sdholland nlm4_res nlm4_unlock_res_4_arg;
3626ca35587Sdholland nlm4_res nlm4_granted_res_4_arg;
3636ca35587Sdholland nlm4_shareargs nlm4_share_4_arg;
3646ca35587Sdholland nlm4_shareargs nlm4_unshare_4_arg;
3656ca35587Sdholland nlm4_lockargs nlm4_nm_lock_4_arg;
3666ca35587Sdholland nlm4_notify nlm4_free_all_4_arg;
3676ca35587Sdholland } argument;
3686ca35587Sdholland union {
3696ca35587Sdholland nlm4_testres nlm4_test_4_res;
3706ca35587Sdholland nlm4_res nlm4_lock_4_res;
3716ca35587Sdholland nlm4_res nlm4_cancel_4_res;
3726ca35587Sdholland nlm4_res nlm4_unlock_4_res;
3736ca35587Sdholland nlm4_res nlm4_granted_4_res;
3746ca35587Sdholland nlm4_shareres nlm4_share_4_res;
3756ca35587Sdholland nlm4_shareres nlm4_unshare_4_res;
3766ca35587Sdholland nlm4_res nlm4_nm_lock_4_res;
3776ca35587Sdholland } result;
3786ca35587Sdholland bool_t retval;
3796ca35587Sdholland xdrproc_t xdr_argument, xdr_result;
3806ca35587Sdholland bool_t (*local)(char *, void *, struct svc_req *);
3816ca35587Sdholland
3826ca35587Sdholland switch (rqstp->rq_proc) {
3836ca35587Sdholland case NULLPROC:
3846ca35587Sdholland (void) svc_sendreply(rqstp,
3856ca35587Sdholland (xdrproc_t) xdr_void, (char *)NULL);
3866ca35587Sdholland svc_freereq(rqstp);
3876ca35587Sdholland return;
3886ca35587Sdholland
3896ca35587Sdholland case NLM4_TEST:
3906ca35587Sdholland xdr_argument = (xdrproc_t) xdr_nlm4_testargs;
3916ca35587Sdholland xdr_result = (xdrproc_t) xdr_nlm4_testres;
3926ca35587Sdholland local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_test_4_svc;
3936ca35587Sdholland break;
3946ca35587Sdholland
3956ca35587Sdholland case NLM4_LOCK:
3966ca35587Sdholland xdr_argument = (xdrproc_t) xdr_nlm4_lockargs;
3976ca35587Sdholland xdr_result = (xdrproc_t) xdr_nlm4_res;
3986ca35587Sdholland local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_lock_4_svc;
3996ca35587Sdholland break;
4006ca35587Sdholland
4016ca35587Sdholland case NLM4_CANCEL:
4026ca35587Sdholland xdr_argument = (xdrproc_t) xdr_nlm4_cancargs;
4036ca35587Sdholland xdr_result = (xdrproc_t) xdr_nlm4_res;
4046ca35587Sdholland local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_cancel_4_svc;
4056ca35587Sdholland break;
4066ca35587Sdholland
4076ca35587Sdholland case NLM4_UNLOCK:
4086ca35587Sdholland xdr_argument = (xdrproc_t) xdr_nlm4_unlockargs;
4096ca35587Sdholland xdr_result = (xdrproc_t) xdr_nlm4_res;
4106ca35587Sdholland local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_unlock_4_svc;
4116ca35587Sdholland break;
4126ca35587Sdholland
4136ca35587Sdholland case NLM4_GRANTED:
4146ca35587Sdholland xdr_argument = (xdrproc_t) xdr_nlm4_testargs;
4156ca35587Sdholland xdr_result = (xdrproc_t) xdr_nlm4_res;
4166ca35587Sdholland local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_granted_4_svc;
4176ca35587Sdholland break;
4186ca35587Sdholland
4196ca35587Sdholland case NLM4_TEST_MSG:
4206ca35587Sdholland xdr_argument = (xdrproc_t) xdr_nlm4_testargs;
4216ca35587Sdholland xdr_result = (xdrproc_t) xdr_void;
4226ca35587Sdholland local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_test_msg_4_svc;
4236ca35587Sdholland break;
4246ca35587Sdholland
4256ca35587Sdholland case NLM4_LOCK_MSG:
4266ca35587Sdholland xdr_argument = (xdrproc_t) xdr_nlm4_lockargs;
4276ca35587Sdholland xdr_result = (xdrproc_t) xdr_void;
4286ca35587Sdholland local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_lock_msg_4_svc;
4296ca35587Sdholland break;
4306ca35587Sdholland
4316ca35587Sdholland case NLM4_CANCEL_MSG:
4326ca35587Sdholland xdr_argument = (xdrproc_t) xdr_nlm4_cancargs;
4336ca35587Sdholland xdr_result = (xdrproc_t) xdr_void;
4346ca35587Sdholland local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_cancel_msg_4_svc;
4356ca35587Sdholland break;
4366ca35587Sdholland
4376ca35587Sdholland case NLM4_UNLOCK_MSG:
4386ca35587Sdholland xdr_argument = (xdrproc_t) xdr_nlm4_unlockargs;
4396ca35587Sdholland xdr_result = (xdrproc_t) xdr_void;
4406ca35587Sdholland local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_unlock_msg_4_svc;
4416ca35587Sdholland break;
4426ca35587Sdholland
4436ca35587Sdholland case NLM4_GRANTED_MSG:
4446ca35587Sdholland xdr_argument = (xdrproc_t) xdr_nlm4_testargs;
4456ca35587Sdholland xdr_result = (xdrproc_t) xdr_void;
4466ca35587Sdholland local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_granted_msg_4_svc;
4476ca35587Sdholland break;
4486ca35587Sdholland
4496ca35587Sdholland case NLM4_TEST_RES:
4506ca35587Sdholland xdr_argument = (xdrproc_t) xdr_nlm4_testres;
4516ca35587Sdholland xdr_result = (xdrproc_t) xdr_void;
4526ca35587Sdholland local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_test_res_4_svc;
4536ca35587Sdholland break;
4546ca35587Sdholland
4556ca35587Sdholland case NLM4_LOCK_RES:
4566ca35587Sdholland xdr_argument = (xdrproc_t) xdr_nlm4_res;
4576ca35587Sdholland xdr_result = (xdrproc_t) xdr_void;
4586ca35587Sdholland local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_lock_res_4_svc;
4596ca35587Sdholland break;
4606ca35587Sdholland
4616ca35587Sdholland case NLM4_CANCEL_RES:
4626ca35587Sdholland xdr_argument = (xdrproc_t) xdr_nlm4_res;
4636ca35587Sdholland xdr_result = (xdrproc_t) xdr_void;
4646ca35587Sdholland local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_cancel_res_4_svc;
4656ca35587Sdholland break;
4666ca35587Sdholland
4676ca35587Sdholland case NLM4_UNLOCK_RES:
4686ca35587Sdholland xdr_argument = (xdrproc_t) xdr_nlm4_res;
4696ca35587Sdholland xdr_result = (xdrproc_t) xdr_void;
4706ca35587Sdholland local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_unlock_res_4_svc;
4716ca35587Sdholland break;
4726ca35587Sdholland
4736ca35587Sdholland case NLM4_GRANTED_RES:
4746ca35587Sdholland xdr_argument = (xdrproc_t) xdr_nlm4_res;
4756ca35587Sdholland xdr_result = (xdrproc_t) xdr_void;
4766ca35587Sdholland local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_granted_res_4_svc;
4776ca35587Sdholland break;
4786ca35587Sdholland
4796ca35587Sdholland case NLM4_SHARE:
4806ca35587Sdholland xdr_argument = (xdrproc_t) xdr_nlm4_shareargs;
4816ca35587Sdholland xdr_result = (xdrproc_t) xdr_nlm4_shareres;
4826ca35587Sdholland local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_share_4_svc;
4836ca35587Sdholland break;
4846ca35587Sdholland
4856ca35587Sdholland case NLM4_UNSHARE:
4866ca35587Sdholland xdr_argument = (xdrproc_t) xdr_nlm4_shareargs;
4876ca35587Sdholland xdr_result = (xdrproc_t) xdr_nlm4_shareres;
4886ca35587Sdholland local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_unshare_4_svc;
4896ca35587Sdholland break;
4906ca35587Sdholland
4916ca35587Sdholland case NLM4_NM_LOCK:
4926ca35587Sdholland xdr_argument = (xdrproc_t) xdr_nlm4_lockargs;
4936ca35587Sdholland xdr_result = (xdrproc_t) xdr_nlm4_res;
4946ca35587Sdholland local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_nm_lock_4_svc;
4956ca35587Sdholland break;
4966ca35587Sdholland
4976ca35587Sdholland case NLM4_FREE_ALL:
4986ca35587Sdholland xdr_argument = (xdrproc_t) xdr_nlm4_notify;
4996ca35587Sdholland xdr_result = (xdrproc_t) xdr_void;
5006ca35587Sdholland local = (bool_t (*) (char *, void *, struct svc_req *))nlm4_free_all_4_svc;
5016ca35587Sdholland break;
5026ca35587Sdholland
5036ca35587Sdholland default:
5046ca35587Sdholland svcerr_noproc(rqstp);
5056ca35587Sdholland svc_freereq(rqstp);
5066ca35587Sdholland return;
5076ca35587Sdholland }
5086ca35587Sdholland (void) memset((char *)&argument, 0, sizeof (argument));
5096ca35587Sdholland if (!svc_getargs(rqstp, xdr_argument, (char *)(caddr_t) &argument)) {
5106ca35587Sdholland svcerr_decode(rqstp);
5116ca35587Sdholland svc_freereq(rqstp);
5126ca35587Sdholland return;
5136ca35587Sdholland }
5146ca35587Sdholland retval = (bool_t) (*local)((char *)&argument, (void *)&result, rqstp);
5156ca35587Sdholland if (retval > 0 && !svc_sendreply(rqstp, xdr_result, (char *)&result)) {
5166ca35587Sdholland svcerr_systemerr(rqstp);
5176ca35587Sdholland }
5186ca35587Sdholland if (!svc_freeargs(rqstp, xdr_argument, (char *)(caddr_t) &argument)) {
5196ca35587Sdholland printf("unable to free arguments");
5206ca35587Sdholland //exit(1);
5216ca35587Sdholland }
5226ca35587Sdholland svc_freereq(rqstp);
5236ca35587Sdholland if (!nlm_prog_4_freeresult(transp, xdr_result, (caddr_t) &result))
5246ca35587Sdholland printf("unable to free results");
5256ca35587Sdholland
5266ca35587Sdholland return;
5276ca35587Sdholland }
528