2 * support/nfs/rcpdispatch.c
4 * Generic RPC dispatcher.
6 * Copyright (C) 1995, 1996, Olaf Kirch <okir@monad.swb.de>
15 #include <rpc/pmap_clnt.h>
17 #include <arpa/inet.h>
24 rpc_dispatch(struct svc_req *rqstp, SVCXPRT *transp,
25 struct rpc_dtable *dtable, int nvers,
26 void *argp, void *resp)
28 struct rpc_dentry *dent;
30 if (((int)rqstp->rq_vers) > nvers) {
31 svcerr_progvers(transp, 1, nvers);
34 dtable += (rqstp->rq_vers - 1);
35 if (rqstp->rq_proc > dtable->nproc) {
36 svcerr_noproc(transp);
40 if (dtable->nproc <= rqstp->rq_proc) {
41 svcerr_noproc(transp);
45 dent = dtable->entries + rqstp->rq_proc;
47 if (dent->func == NULL) {
48 svcerr_noproc(transp);
52 memset(argp, 0, dent->xdr_arg_size);
53 memset(resp, 0, dent->xdr_res_size);
55 if (!svc_getargs(transp, dent->xdr_arg_fn, argp)) {
56 svcerr_decode(transp);
60 if ((dent->func)(rqstp, argp, resp) && resp != 0) {
61 if (!svc_sendreply(transp, dent->xdr_res_fn, (caddr_t)resp))
62 svcerr_systemerr(transp);
64 if (!svc_freeargs(transp, dent->xdr_arg_fn, argp)) {
65 xlog(L_ERROR, "failed to free RPC arguments");