blob: 3e9addc741c1ad8a57b41c9172d3114b53faee1b [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 {
Trond Myklebust34f52e32007-06-14 16:40:31 -040027 struct kref cl_kref; /* Number of references */
Trond Myklebust6529eba2007-06-14 16:40:14 -040028 struct list_head cl_clients; /* Global list of clients */
29 struct list_head cl_tasks; /* List of tasks */
Trond Myklebust4bef61f2007-06-16 14:17:01 -040030 spinlock_t cl_lock; /* spinlock */
Linus Torvalds1da177e2005-04-16 15:20:36 -070031 struct rpc_xprt * cl_xprt; /* transport */
32 struct rpc_procinfo * cl_procinfo; /* procedure info */
Chuck Lever4a681792006-08-22 20:06:15 -040033 u32 cl_prog, /* RPC program number */
34 cl_vers, /* RPC version number */
35 cl_maxproc; /* max procedure number */
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
37 char * cl_server; /* server machine name */
38 char * cl_protname; /* protocol name */
39 struct rpc_auth * cl_auth; /* authenticator */
Chuck Lever11c556b2006-03-20 13:44:22 -050040 struct rpc_stat * cl_stats; /* per-program statistics */
41 struct rpc_iostats * cl_metrics; /* per-client statistics */
Linus Torvalds1da177e2005-04-16 15:20:36 -070042
43 unsigned int cl_softrtry : 1,/* soft timeouts */
44 cl_intr : 1,/* interruptible */
Chuck Lever43d78ef2007-02-06 18:26:11 -050045 cl_discrtry : 1,/* disconnect before retry */
Trond Myklebust90c57552007-06-09 19:49:36 -040046 cl_autobind : 1;/* use getport() */
Linus Torvalds1da177e2005-04-16 15:20:36 -070047
48 struct rpc_rtt * cl_rtt; /* RTO estimator data */
Trond Myklebustba7392b2007-12-20 16:03:55 -050049 const struct rpc_timeout *cl_timeout; /* Timeout strategy */
Linus Torvalds1da177e2005-04-16 15:20:36 -070050
51 int cl_nodelen; /* nodename length */
52 char cl_nodename[UNX_MAXNODENAME];
53 char cl_pathname[30];/* Path in rpc_pipe_fs */
Trond Myklebust54281542006-03-20 13:44:49 -050054 struct vfsmount * cl_vfsmnt;
Linus Torvalds1da177e2005-04-16 15:20:36 -070055 struct dentry * cl_dentry; /* inode */
56 struct rpc_clnt * cl_parent; /* Points to parent of clones */
57 struct rpc_rtt cl_rtt_default;
Trond Myklebustba7392b2007-12-20 16:03:55 -050058 struct rpc_timeout cl_timeout_default;
Trond Myklebust3e32a5d2006-11-16 11:37:27 -050059 struct rpc_program * cl_program;
Linus Torvalds1da177e2005-04-16 15:20:36 -070060 char cl_inline_name[32];
61};
Linus Torvalds1da177e2005-04-16 15:20:36 -070062
63/*
64 * General RPC program info
65 */
66#define RPC_MAXVERSION 4
67struct rpc_program {
68 char * name; /* protocol name */
69 u32 number; /* program number */
70 unsigned int nrvers; /* number of versions */
71 struct rpc_version ** version; /* version array */
72 struct rpc_stat * stats; /* statistics */
73 char * pipe_dir_name; /* path to rpc_pipefs dir */
74};
75
76struct rpc_version {
77 u32 number; /* version number */
78 unsigned int nrprocs; /* number of procs */
79 struct rpc_procinfo * procs; /* procedure array */
80};
81
82/*
83 * Procedure information
84 */
85struct rpc_procinfo {
86 u32 p_proc; /* RPC procedure number */
87 kxdrproc_t p_encode; /* XDR encode function */
88 kxdrproc_t p_decode; /* XDR decode function */
Chuck Lever2bea90d2007-03-29 16:47:53 -040089 unsigned int p_arglen; /* argument hdr length (u32) */
90 unsigned int p_replen; /* reply hdr length (u32) */
Linus Torvalds1da177e2005-04-16 15:20:36 -070091 unsigned int p_count; /* call count */
92 unsigned int p_timer; /* Which RTT timer to use */
Chuck Levercc0175c2006-03-20 13:44:22 -050093 u32 p_statidx; /* Which procedure to account */
94 char * p_name; /* name of procedure */
Linus Torvalds1da177e2005-04-16 15:20:36 -070095};
96
Linus Torvalds1da177e2005-04-16 15:20:36 -070097#ifdef __KERNEL__
98
Chuck Leverc2866762006-08-22 20:06:20 -040099struct rpc_create_args {
100 int protocol;
101 struct sockaddr *address;
102 size_t addrsize;
Frank van Maarseveend3bc9a12007-07-09 22:23:35 +0200103 struct sockaddr *saddress;
Trond Myklebustba7392b2007-12-20 16:03:55 -0500104 const struct rpc_timeout *timeout;
Chuck Leverc2866762006-08-22 20:06:20 -0400105 char *servername;
106 struct rpc_program *program;
107 u32 version;
108 rpc_authflavor_t authflavor;
109 unsigned long flags;
110};
111
112/* Values for "flags" field */
113#define RPC_CLNT_CREATE_HARDRTRY (1UL << 0)
114#define RPC_CLNT_CREATE_INTR (1UL << 1)
115#define RPC_CLNT_CREATE_AUTOBIND (1UL << 2)
Trond Myklebust90c57552007-06-09 19:49:36 -0400116#define RPC_CLNT_CREATE_NONPRIVPORT (1UL << 3)
117#define RPC_CLNT_CREATE_NOPING (1UL << 4)
118#define RPC_CLNT_CREATE_DISCRTRY (1UL << 5)
Chuck Leverc2866762006-08-22 20:06:20 -0400119
120struct rpc_clnt *rpc_create(struct rpc_create_args *args);
Andreas Gruenbacher007e2512005-06-22 17:16:23 +0000121struct rpc_clnt *rpc_bind_new_program(struct rpc_clnt *,
Chuck Lever89eb21c2007-09-11 18:00:09 -0400122 struct rpc_program *, u32);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123struct rpc_clnt *rpc_clone_client(struct rpc_clnt *);
Trond Myklebust4c402b42007-06-14 16:40:32 -0400124void rpc_shutdown_client(struct rpc_clnt *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125void rpc_release_client(struct rpc_clnt *);
Chuck Levercce63cd2007-07-01 12:13:12 -0400126
Chuck Levera5090502007-03-29 16:48:04 -0400127int rpcb_register(u32, u32, int, unsigned short, int *);
Chuck Leverf1ec08c2008-01-14 15:11:53 -0500128int rpcb_getport_sync(struct sockaddr_in *, u32, u32, int);
Chuck Lever45160d62007-07-01 12:13:17 -0400129void rpcb_getport_async(struct rpc_task *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130
Trond Myklebust77de2c52007-10-25 18:40:21 -0400131void rpc_call_start(struct rpc_task *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132int rpc_call_async(struct rpc_clnt *clnt, struct rpc_message *msg,
Trond Myklebust963d8fe2006-01-03 09:55:04 +0100133 int flags, const struct rpc_call_ops *tk_ops,
134 void *calldata);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135int rpc_call_sync(struct rpc_clnt *clnt, struct rpc_message *msg,
136 int flags);
Trond Myklebust5e1550d2007-06-23 10:17:16 -0400137struct rpc_task *rpc_call_null(struct rpc_clnt *clnt, struct rpc_cred *cred,
138 int flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139void rpc_restart_call(struct rpc_task *);
140void rpc_clnt_sigmask(struct rpc_clnt *clnt, sigset_t *oldset);
141void rpc_clnt_sigunmask(struct rpc_clnt *clnt, sigset_t *oldset);
142void rpc_setbufsize(struct rpc_clnt *, unsigned int, unsigned int);
143size_t rpc_max_payload(struct rpc_clnt *);
Chuck Lever35f5a422006-01-03 09:55:50 +0100144void rpc_force_rebind(struct rpc_clnt *);
Chuck Levered394402006-08-22 20:06:17 -0400145size_t rpc_peeraddr(struct rpc_clnt *, struct sockaddr *, size_t);
Chuck Leverb454ae92008-01-07 18:34:48 -0500146const char *rpc_peeraddr2str(struct rpc_clnt *, enum rpc_display_format_t);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148#endif /* __KERNEL__ */
149#endif /* _LINUX_SUNRPC_CLNT_H */