1 /*
2 * linux/include/linux/sunrpc/clnt.h
3 *
4 * Declarations for the high-level RPC client interface
5 *
6 * Copyright (C) 1995, 1996, Olaf Kirch <okir@monad.swb.de>
7 */
8
9 #ifndef _LINUX_SUNRPC_CLNT_H
10 #define _LINUX_SUNRPC_CLNT_H
11
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>
18 #include <linux/sunrpc/timer.h>
19
20 /*
21 * This defines an RPC port mapping
22 */
23 struct rpc_portmap {
24 __u32 pm_prog;
25 __u32 pm_vers;
26 __u32 pm_prot;
27 __u16 pm_port;
28 };
29
30 /*
31 * The high-level client handle
32 */
33 struct rpc_clnt {
34 atomic_t cl_users; /* number of references */
35 struct rpc_xprt * cl_xprt; /* transport */
36 struct rpc_procinfo * cl_procinfo; /* procedure info */
37 u32 cl_maxproc; /* max procedure number */
38
39 char * cl_server; /* server machine name */
40 char * cl_protname; /* protocol name */
41 struct rpc_auth * cl_auth; /* authenticator */
42 struct rpc_stat * cl_stats; /* statistics */
43
44 unsigned int cl_softrtry : 1,/* soft timeouts */
45 cl_intr : 1,/* interruptible */
46 cl_chatty : 1,/* be verbose */
47 cl_autobind : 1,/* use getport() */
48 cl_binding : 1,/* doing a getport() */
49 cl_droppriv : 1,/* enable NFS suid hack */
50 cl_oneshot : 1,/* dispose after use */
51 cl_dead : 1;/* abandoned */
52 unsigned int cl_flags; /* misc client flags */
53 unsigned long cl_hardmax; /* max hard timeout */
54
55 struct rpc_rtt cl_rtt; /* RTO estimator data */
56
57 struct rpc_portmap cl_pmap; /* port mapping */
58 struct rpc_wait_queue cl_bindwait; /* waiting on getport() */
59
60 int cl_nodelen; /* nodename length */
61 char cl_nodename[UNX_MAXNODENAME];
62 };
63 #define cl_timeout cl_xprt->timeout
64 #define cl_prog cl_pmap.pm_prog
65 #define cl_vers cl_pmap.pm_vers
66 #define cl_port cl_pmap.pm_port
67 #define cl_prot cl_pmap.pm_prot
68
69 /*
70 * General RPC program info
71 */
72 #define RPC_MAXVERSION 4
73 struct rpc_program {
74 char * name; /* protocol name */
75 u32 number; /* program number */
76 unsigned int nrvers; /* number of versions */
77 struct rpc_version ** version; /* version array */
78 struct rpc_stat * stats; /* statistics */
79 };
80
81 struct rpc_version {
82 u32 number; /* version number */
83 unsigned int nrprocs; /* number of procs */
84 struct rpc_procinfo * procs; /* procedure array */
85 };
86
87 /*
88 * Procedure information
89 */
90 struct rpc_procinfo {
91 char * p_procname; /* procedure name */
92 kxdrproc_t p_encode; /* XDR encode function */
93 kxdrproc_t p_decode; /* XDR decode function */
94 unsigned int p_bufsiz; /* req. buffer size */
95 unsigned int p_count; /* call count */
96 unsigned int p_timer; /* Which RTT timer to use */
97 };
98
99 #define rpcproc_bufsiz(clnt, proc) ((clnt)->cl_procinfo[proc].p_bufsiz)
100 #define rpcproc_encode(clnt, proc) ((clnt)->cl_procinfo[proc].p_encode)
101 #define rpcproc_decode(clnt, proc) ((clnt)->cl_procinfo[proc].p_decode)
102 #define rpcproc_name(clnt, proc) ((clnt)->cl_procinfo[proc].p_procname)
103 #define rpcproc_count(clnt, proc) ((clnt)->cl_procinfo[proc].p_count)
104 #define rpcproc_timer(clnt, proc) ((clnt)->cl_procinfo[proc].p_timer)
105
106 #define RPC_CONGESTED(clnt) (RPCXPRT_CONGESTED((clnt)->cl_xprt))
107 #define RPC_PEERADDR(clnt) (&(clnt)->cl_xprt->addr)
108
109 #ifdef __KERNEL__
110
111 struct rpc_clnt *rpc_create_client(struct rpc_xprt *xprt, char *servname,
112 struct rpc_program *info,
113 u32 version, int authflavor);
114 int rpc_shutdown_client(struct rpc_clnt *);
115 int rpc_destroy_client(struct rpc_clnt *);
116 void rpc_release_client(struct rpc_clnt *);
117 void rpc_getport(struct rpc_task *, struct rpc_clnt *);
118 int rpc_register(u32, u32, int, unsigned short, int *);
119
120 void rpc_call_setup(struct rpc_task *, struct rpc_message *, int);
121
122 int rpc_call_async(struct rpc_clnt *clnt, struct rpc_message *msg,
123 int flags, rpc_action callback, void *clntdata);
124 int rpc_call_sync(struct rpc_clnt *clnt, struct rpc_message *msg,
125 int flags);
126 void rpc_restart_call(struct rpc_task *);
127 void rpc_clnt_sigmask(struct rpc_clnt *clnt, sigset_t *oldset);
128 void rpc_clnt_sigunmask(struct rpc_clnt *clnt, sigset_t *oldset);
129 void rpc_setbufsize(struct rpc_clnt *, unsigned int, unsigned int);
130
131 static __inline__
rpc_call(struct rpc_clnt * clnt,u32 proc,void * argp,void * resp,int flags)132 int rpc_call(struct rpc_clnt *clnt, u32 proc, void *argp, void *resp, int flags)
133 {
134 struct rpc_message msg = { proc, argp, resp, NULL };
135 return rpc_call_sync(clnt, &msg, flags);
136 }
137
138
139 static __inline__ void
rpc_set_timeout(struct rpc_clnt * clnt,unsigned int retr,unsigned long incr)140 rpc_set_timeout(struct rpc_clnt *clnt, unsigned int retr, unsigned long incr)
141 {
142 xprt_set_timeout(&clnt->cl_timeout, retr, incr);
143 }
144
145 extern void rpciod_wake_up(void);
146
147 /*
148 * Helper function for NFSroot support
149 */
150 int rpc_getport_external(struct sockaddr_in *, __u32, __u32, int);
151
152 #endif /* __KERNEL__ */
153 #endif /* _LINUX_SUNRPC_CLNT_H */
154