Import 2.4.0-test2pre7
[davej-history.git] / include / linux / sunrpc / clnt.h
blob4cc0f16ad649b8217c0d2f1c9614fb6ac2b0f8c7
1 /*
2 * linux/include/linux/sunrpc/clnt.h
4 * Declarations for the high-level RPC client interface
6 * Copyright (C) 1995, 1996, Olaf Kirch <okir@monad.swb.de>
7 */
9 #ifndef _LINUX_SUNRPC_CLNT_H
10 #define _LINUX_SUNRPC_CLNT_H
12 #include <linux/sunrpc/msg_prot.h>
13 #include <linux/sunrpc/sched.h>
14 #include <linux/sunrpc/xprt.h>
15 #include <linux/sunrpc/auth.h>
16 #include <linux/sunrpc/stats.h>
17 #include <linux/sunrpc/xdr.h>
20 * This defines an RPC port mapping
22 struct rpc_portmap {
23 __u32 pm_prog;
24 __u32 pm_vers;
25 __u32 pm_prot;
26 __u16 pm_port;
30 * The high-level client handle
32 struct rpc_clnt {
33 atomic_t cl_users; /* number of references */
34 struct rpc_xprt * cl_xprt; /* transport */
35 struct rpc_procinfo * cl_procinfo; /* procedure info */
36 u32 cl_maxproc; /* max procedure number */
38 char * cl_server; /* server machine name */
39 char * cl_protname; /* protocol name */
40 struct rpc_auth * cl_auth; /* authenticator */
41 struct rpc_stat * cl_stats; /* statistics */
43 unsigned int cl_softrtry : 1,/* soft timeouts */
44 cl_intr : 1,/* interruptible */
45 cl_chatty : 1,/* be verbose */
46 cl_autobind : 1,/* use getport() */
47 cl_binding : 1,/* doing a getport() */
48 cl_oneshot : 1,/* dispose after use */
49 cl_dead : 1;/* abandoned */
50 unsigned int cl_flags; /* misc client flags */
51 unsigned long cl_hardmax; /* max hard timeout */
53 struct rpc_portmap cl_pmap; /* port mapping */
54 struct rpc_wait_queue cl_bindwait; /* waiting on getport() */
56 int cl_nodelen; /* nodename length */
57 char cl_nodename[UNX_MAXNODENAME];
59 #define cl_timeout cl_xprt->timeout
60 #define cl_prog cl_pmap.pm_prog
61 #define cl_vers cl_pmap.pm_vers
62 #define cl_port cl_pmap.pm_port
63 #define cl_prot cl_pmap.pm_prot
66 * General RPC program info
68 #define RPC_MAXVERSION 4
69 struct rpc_program {
70 char * name; /* protocol name */
71 u32 number; /* program number */
72 unsigned int nrvers; /* number of versions */
73 struct rpc_version ** version; /* version array */
74 struct rpc_stat * stats; /* statistics */
77 struct rpc_version {
78 u32 number; /* version number */
79 unsigned int nrprocs; /* number of procs */
80 struct rpc_procinfo * procs; /* procedure array */
84 * Procedure information
86 struct rpc_procinfo {
87 char * p_procname; /* procedure name */
88 kxdrproc_t p_encode; /* XDR encode function */
89 kxdrproc_t p_decode; /* XDR decode function */
90 unsigned int p_bufsiz; /* req. buffer size */
91 unsigned int p_count; /* call count */
94 #define rpcproc_bufsiz(clnt, proc) ((clnt)->cl_procinfo[proc].p_bufsiz)
95 #define rpcproc_encode(clnt, proc) ((clnt)->cl_procinfo[proc].p_encode)
96 #define rpcproc_decode(clnt, proc) ((clnt)->cl_procinfo[proc].p_decode)
97 #define rpcproc_name(clnt, proc) ((clnt)->cl_procinfo[proc].p_procname)
98 #define rpcproc_count(clnt, proc) ((clnt)->cl_procinfo[proc].p_count)
100 #define RPC_CONGESTED(clnt) (RPCXPRT_CONGESTED((clnt)->cl_xprt))
101 #define RPC_PEERADDR(clnt) (&(clnt)->cl_xprt->addr)
103 #ifdef __KERNEL__
105 struct rpc_clnt *rpc_create_client(struct rpc_xprt *xprt, char *servname,
106 struct rpc_program *info,
107 u32 version, int authflavor);
108 int rpc_shutdown_client(struct rpc_clnt *);
109 int rpc_destroy_client(struct rpc_clnt *);
110 void rpc_release_client(struct rpc_clnt *);
111 void rpc_getport(struct rpc_task *, struct rpc_clnt *);
112 int rpc_register(u32, u32, int, unsigned short, int *);
114 void rpc_call_setup(struct rpc_task *, struct rpc_message *, int);
116 int rpc_call_async(struct rpc_clnt *clnt, struct rpc_message *msg,
117 int flags, rpc_action callback, void *clntdata);
118 int rpc_call_sync(struct rpc_clnt *clnt, struct rpc_message *msg,
119 int flags);
120 void rpc_restart_call(struct rpc_task *);
121 void rpc_clnt_sigmask(struct rpc_clnt *clnt, sigset_t *oldset);
122 void rpc_clnt_sigunmask(struct rpc_clnt *clnt, sigset_t *oldset);
124 static __inline__
125 int rpc_call(struct rpc_clnt *clnt, u32 proc, void *argp, void *resp, int flags)
127 struct rpc_message msg = { proc, argp, resp, NULL };
128 return rpc_call_sync(clnt, &msg, flags);
132 extern __inline__ void
133 rpc_set_timeout(struct rpc_clnt *clnt, unsigned int retr, unsigned long incr)
135 xprt_set_timeout(&clnt->cl_timeout, retr, incr);
138 extern void rpciod_tcp_dispatcher(void);
139 extern void rpciod_wake_up(void);
142 * Helper function for NFSroot support
144 int rpc_getport_external(struct sockaddr_in *, __u32, __u32, int);
146 #endif /* __KERNEL__ */
147 #endif /* _LINUX_SUNRPC_CLNT_H */