]> git.decadent.org.uk Git - nfs-utils.git/blob - utils/mountd/mount_dispatch.c
tcp_wrapper: Clean up logit()
[nfs-utils.git] / utils / mountd / mount_dispatch.c
1 /*
2  * mount_dispatch       This file contains the function dispatch table.
3  *
4  * Copyright (C) 1995 Olaf Kirch <okir@monad.swb.de>
5  */
6
7 #ifdef HAVE_CONFIG_H
8 #include <config.h>
9 #endif
10
11 #ifdef HAVE_TCP_WRAPPER
12 #include "tcpwrapper.h"
13 #endif
14
15 #include "mountd.h"
16 #include "rpcmisc.h"
17
18 /*
19  * Procedures for MNTv1
20  */
21 static struct rpc_dentry mnt_1_dtable[] = {
22         dtable_ent(mount_null,1,void,void),             /* NULL */
23         dtable_ent(mount_mnt,1,dirpath,fhstatus),       /* MNT */
24         dtable_ent(mount_dump,1,void,mountlist),        /* DUMP */
25         dtable_ent(mount_umnt,1,dirpath,void),          /* UMNT */
26         dtable_ent(mount_umntall,1,void,void),          /* UMNTALL */
27         dtable_ent(mount_export,1,void,exports),        /* EXPORT */
28         dtable_ent(mount_exportall,1,void,exports),     /* EXPORTALL */
29 };
30
31 /*
32  * Procedures for MNTv2
33  */
34 static struct rpc_dentry mnt_2_dtable[] = {
35         dtable_ent(mount_null,1,void,void),             /* NULL */
36         dtable_ent(mount_mnt,1,dirpath,fhstatus),       /* MNT */
37         dtable_ent(mount_dump,1,void,mountlist),        /* DUMP */
38         dtable_ent(mount_umnt,1,dirpath,void),          /* UMNT */
39         dtable_ent(mount_umntall,1,void,void),          /* UMNTALL */
40         dtable_ent(mount_export,1,void,exports),        /* EXPORT */
41         dtable_ent(mount_exportall,1,void,exports),     /* EXPORTALL */
42         dtable_ent(mount_pathconf,2,dirpath,ppathcnf),  /* PATHCONF */
43 };
44
45 /*
46  * Procedures for MNTv3
47  */
48 static struct rpc_dentry mnt_3_dtable[] = {
49         dtable_ent(mount_null,1,void,void),             /* NULL */
50         dtable_ent(mount_mnt,3,dirpath,mountres3),      /* MNT */
51         dtable_ent(mount_dump,1,void,mountlist),        /* DUMP */
52         dtable_ent(mount_umnt,1,dirpath,void),          /* UMNT */
53         dtable_ent(mount_umntall,1,void,void),          /* UMNTALL */
54         dtable_ent(mount_export,1,void,exports),        /* EXPORT */
55 };
56
57 #define number_of(x)    (sizeof(x)/sizeof(x[0]))
58
59 static struct rpc_dtable        dtable[] = {
60         { mnt_1_dtable,         number_of(mnt_1_dtable) },
61         { mnt_2_dtable,         number_of(mnt_2_dtable) },
62         { mnt_3_dtable,         number_of(mnt_3_dtable) },
63 };
64
65 /*
66  * The main dispatch routine.
67  */
68 void
69 mount_dispatch(struct svc_req *rqstp, SVCXPRT *transp)
70 {
71         union mountd_arguments  argument;
72         union mountd_results    result;
73 #ifdef HAVE_TCP_WRAPPER
74         struct sockaddr_in *sin = nfs_getrpccaller_in(transp);
75
76         /* remote host authorization check */
77         if (sin->sin_family == AF_INET &&
78             !check_default("mountd", sin, MOUNTPROG)) {
79                 svcerr_auth (transp, AUTH_FAILED);
80                 return;
81         }
82 #endif
83
84         rpc_dispatch(rqstp, transp, dtable, number_of(dtable),
85                         &argument, &result);
86 }