blob: f6d1d646ce05c1039437ff7af52155df9afbe353 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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#include <asm/signal.h>
20
Linus Torvalds1da177e2005-04-16 15:20:36 -070021struct rpc_inode;
22
23/*
24 * The high-level client handle
25 */
26struct rpc_clnt {
27 atomic_t cl_count; /* Number of clones */
28 atomic_t cl_users; /* number of references */
29 struct rpc_xprt * cl_xprt; /* transport */
30 struct rpc_procinfo * cl_procinfo; /* procedure info */
Chuck Lever4a681792006-08-22 20:06:15 -040031 u32 cl_prog, /* RPC program number */
32 cl_vers, /* RPC version number */
33 cl_maxproc; /* max procedure number */
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
35 char * cl_server; /* server machine name */
36 char * cl_protname; /* protocol name */
37 struct rpc_auth * cl_auth; /* authenticator */
Chuck Lever11c556b2006-03-20 13:44:22 -050038 struct rpc_stat * cl_stats; /* per-program statistics */
39 struct rpc_iostats * cl_metrics; /* per-client statistics */
Linus Torvalds1da177e2005-04-16 15:20:36 -070040
41 unsigned int cl_softrtry : 1,/* soft timeouts */
42 cl_intr : 1,/* interruptible */
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 cl_autobind : 1,/* use getport() */
44 cl_oneshot : 1,/* dispose after use */
45 cl_dead : 1;/* abandoned */
46
47 struct rpc_rtt * cl_rtt; /* RTO estimator data */
Linus Torvalds1da177e2005-04-16 15:20:36 -070048
49 int cl_nodelen; /* nodename length */
50 char cl_nodename[UNX_MAXNODENAME];
51 char cl_pathname[30];/* Path in rpc_pipe_fs */
Trond Myklebust54281542006-03-20 13:44:49 -050052 struct vfsmount * cl_vfsmnt;
Linus Torvalds1da177e2005-04-16 15:20:36 -070053 struct dentry * cl_dentry; /* inode */
54 struct rpc_clnt * cl_parent; /* Points to parent of clones */
55 struct rpc_rtt cl_rtt_default;
Linus Torvalds1da177e2005-04-16 15:20:36 -070056 char cl_inline_name[32];
57};
Linus Torvalds1da177e2005-04-16 15:20:36 -070058
59/*
60 * General RPC program info
61 */
62#define RPC_MAXVERSION 4
63struct rpc_program {
64 char * name; /* protocol name */
65 u32 number; /* program number */
66 unsigned int nrvers; /* number of versions */
67 struct rpc_version ** version; /* version array */
68 struct rpc_stat * stats; /* statistics */
69 char * pipe_dir_name; /* path to rpc_pipefs dir */
70};
71
72struct rpc_version {
73 u32 number; /* version number */
74 unsigned int nrprocs; /* number of procs */
75 struct rpc_procinfo * procs; /* procedure array */
76};
77
78/*
79 * Procedure information
80 */
81struct rpc_procinfo {
82 u32 p_proc; /* RPC procedure number */
83 kxdrproc_t p_encode; /* XDR encode function */
84 kxdrproc_t p_decode; /* XDR decode function */
85 unsigned int p_bufsiz; /* req. buffer size */
86 unsigned int p_count; /* call count */
87 unsigned int p_timer; /* Which RTT timer to use */
Chuck Levercc0175c2006-03-20 13:44:22 -050088 u32 p_statidx; /* Which procedure to account */
89 char * p_name; /* name of procedure */
Linus Torvalds1da177e2005-04-16 15:20:36 -070090};
91
Linus Torvalds1da177e2005-04-16 15:20:36 -070092#ifdef __KERNEL__
93
Chuck Leverc2866762006-08-22 20:06:20 -040094struct rpc_create_args {
95 int protocol;
96 struct sockaddr *address;
97 size_t addrsize;
98 struct rpc_timeout *timeout;
99 char *servername;
100 struct rpc_program *program;
101 u32 version;
102 rpc_authflavor_t authflavor;
103 unsigned long flags;
104};
105
106/* Values for "flags" field */
107#define RPC_CLNT_CREATE_HARDRTRY (1UL << 0)
108#define RPC_CLNT_CREATE_INTR (1UL << 1)
109#define RPC_CLNT_CREATE_AUTOBIND (1UL << 2)
110#define RPC_CLNT_CREATE_ONESHOT (1UL << 3)
111#define RPC_CLNT_CREATE_NONPRIVPORT (1UL << 4)
112#define RPC_CLNT_CREATE_NOPING (1UL << 5)
113
114struct rpc_clnt *rpc_create(struct rpc_create_args *args);
Andreas Gruenbacher007e2512005-06-22 17:16:23 +0000115struct rpc_clnt *rpc_bind_new_program(struct rpc_clnt *,
116 struct rpc_program *, int);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117struct rpc_clnt *rpc_clone_client(struct rpc_clnt *);
118int rpc_shutdown_client(struct rpc_clnt *);
119int rpc_destroy_client(struct rpc_clnt *);
120void rpc_release_client(struct rpc_clnt *);
Chuck Leverbbf7c1d2006-08-22 20:06:16 -0400121void rpc_getport(struct rpc_task *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122int rpc_register(u32, u32, int, unsigned short, int *);
123
124void rpc_call_setup(struct rpc_task *, struct rpc_message *, int);
125
126int rpc_call_async(struct rpc_clnt *clnt, struct rpc_message *msg,
Trond Myklebust963d8fe2006-01-03 09:55:04 +0100127 int flags, const struct rpc_call_ops *tk_ops,
128 void *calldata);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129int rpc_call_sync(struct rpc_clnt *clnt, struct rpc_message *msg,
130 int flags);
131void rpc_restart_call(struct rpc_task *);
132void rpc_clnt_sigmask(struct rpc_clnt *clnt, sigset_t *oldset);
133void rpc_clnt_sigunmask(struct rpc_clnt *clnt, sigset_t *oldset);
134void rpc_setbufsize(struct rpc_clnt *, unsigned int, unsigned int);
135size_t rpc_max_payload(struct rpc_clnt *);
Chuck Lever35f5a422006-01-03 09:55:50 +0100136void rpc_force_rebind(struct rpc_clnt *);
Trond Myklebust5ee0ed72005-06-22 17:16:20 +0000137int rpc_ping(struct rpc_clnt *clnt, int flags);
Chuck Levered394402006-08-22 20:06:17 -0400138size_t rpc_peeraddr(struct rpc_clnt *, struct sockaddr *, size_t);
Chuck Leverf425eba2006-08-22 20:06:18 -0400139char * rpc_peeraddr2str(struct rpc_clnt *, enum rpc_display_format_t);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141/*
142 * Helper function for NFSroot support
143 */
144int rpc_getport_external(struct sockaddr_in *, __u32, __u32, int);
145
146#endif /* __KERNEL__ */
147#endif /* _LINUX_SUNRPC_CLNT_H */