]> git.decadent.org.uk Git - nfs-utils.git/blob - support/include/rpcmisc.h
Imported Upstream version 1.2.3
[nfs-utils.git] / support / include / rpcmisc.h
1 /*
2  * rpcmisc      Support for RPC startup, dispatching and logging.
3  *
4  * Copyright (C) 1995 Olaf Kirch <okir@monad.swb.de>
5  */
6
7 #ifndef RPCMISC_H
8 #define RPCMISC_H
9
10 #include <rpc/rpc.h>
11 #include <rpc/pmap_clnt.h>
12
13 #ifdef __STDC__
14 #   define CONCAT(a,b)          a##b
15 #   define STRING(a)            #a
16 #else
17 #   define CONCAT(a,b)          a/**/b
18 #   define STRING(a)            "a"
19 #endif
20
21 typedef bool_t  (*rpcsvc_fn_t)(struct svc_req *, void *argp, void *resp);
22
23 struct rpc_dentry {
24         const char      *name;
25         rpcsvc_fn_t     func;
26         xdrproc_t       xdr_arg_fn;             /* argument XDR */
27         size_t          xdr_arg_size;
28         xdrproc_t       xdr_res_fn;             /* result XDR */
29         size_t          xdr_res_size;
30 };
31
32 struct rpc_dtable {
33         struct rpc_dentry *entries;
34         int             nproc;
35 };
36
37 #define dtable_ent(func, vers, arg_type, res_type) \
38         {       STRING(func), \
39                 (rpcsvc_fn_t)func##_##vers##_svc, \
40                 (xdrproc_t)xdr_##arg_type, sizeof(arg_type), \
41                 (xdrproc_t)xdr_##res_type, sizeof(res_type), \
42         }
43
44 void            nfs_svc_unregister(const rpcprog_t program,
45                                 const rpcvers_t version);
46 unsigned int    nfs_svc_create(char *name, const rpcprog_t program,
47                                 const rpcvers_t version,
48                                 void (*dispatch)(struct svc_req *, SVCXPRT *),
49                                 const uint16_t port);
50 void            rpc_init(char *name, int prog, int vers,
51                                 void (*dispatch)(struct svc_req *, SVCXPRT *),
52                                 int defport);
53 void            rpc_dispatch(struct svc_req *rq, SVCXPRT *xprt,
54                                 struct rpc_dtable *dtable, int nvers,
55                                 void *argp, void *resp);
56
57 extern int      _rpcpmstart;
58 extern int      _rpcfdtype;
59 extern int      _rpcsvcdirty;
60
61 static inline struct sockaddr_in *nfs_getrpccaller_in(SVCXPRT *xprt)
62 {
63         return (struct sockaddr_in *)(char *)svc_getcaller(xprt);
64 }
65
66 static inline struct sockaddr *nfs_getrpccaller(SVCXPRT *xprt)
67 {
68         return (struct sockaddr *)(char *)svc_getcaller(xprt);
69 }
70
71 #endif /* RPCMISC_H */