Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | #include <asm/signal.h> |
| 20 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | struct rpc_inode; |
| 22 | |
| 23 | /* |
| 24 | * The high-level client handle |
| 25 | */ |
| 26 | struct rpc_clnt { |
Trond Myklebust | 34f52e3 | 2007-06-14 16:40:31 -0400 | [diff] [blame] | 27 | struct kref cl_kref; /* Number of references */ |
Trond Myklebust | 6529eba | 2007-06-14 16:40:14 -0400 | [diff] [blame] | 28 | struct list_head cl_clients; /* Global list of clients */ |
| 29 | struct list_head cl_tasks; /* List of tasks */ |
Trond Myklebust | 4bef61f | 2007-06-16 14:17:01 -0400 | [diff] [blame] | 30 | spinlock_t cl_lock; /* spinlock */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | struct rpc_xprt * cl_xprt; /* transport */ |
| 32 | struct rpc_procinfo * cl_procinfo; /* procedure info */ |
Chuck Lever | 4a68179 | 2006-08-22 20:06:15 -0400 | [diff] [blame] | 33 | u32 cl_prog, /* RPC program number */ |
| 34 | cl_vers, /* RPC version number */ |
| 35 | cl_maxproc; /* max procedure number */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | |
| 37 | char * cl_server; /* server machine name */ |
| 38 | char * cl_protname; /* protocol name */ |
| 39 | struct rpc_auth * cl_auth; /* authenticator */ |
Chuck Lever | 11c556b | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 40 | struct rpc_stat * cl_stats; /* per-program statistics */ |
| 41 | struct rpc_iostats * cl_metrics; /* per-client statistics */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | |
| 43 | unsigned int cl_softrtry : 1,/* soft timeouts */ |
Chuck Lever | 43d78ef | 2007-02-06 18:26:11 -0500 | [diff] [blame] | 44 | cl_discrtry : 1,/* disconnect before retry */ |
Olga Kornievskaia | b6b6152 | 2008-06-09 16:51:31 -0400 | [diff] [blame] | 45 | cl_autobind : 1,/* use getport() */ |
| 46 | cl_chatty : 1;/* be verbose */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | |
| 48 | struct rpc_rtt * cl_rtt; /* RTO estimator data */ |
Trond Myklebust | ba7392b | 2007-12-20 16:03:55 -0500 | [diff] [blame] | 49 | const struct rpc_timeout *cl_timeout; /* Timeout strategy */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | |
| 51 | int cl_nodelen; /* nodename length */ |
| 52 | char cl_nodename[UNX_MAXNODENAME]; |
| 53 | char cl_pathname[30];/* Path in rpc_pipe_fs */ |
Trond Myklebust | 5428154 | 2006-03-20 13:44:49 -0500 | [diff] [blame] | 54 | struct vfsmount * cl_vfsmnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | struct dentry * cl_dentry; /* inode */ |
| 56 | struct rpc_clnt * cl_parent; /* Points to parent of clones */ |
| 57 | struct rpc_rtt cl_rtt_default; |
Trond Myklebust | ba7392b | 2007-12-20 16:03:55 -0500 | [diff] [blame] | 58 | struct rpc_timeout cl_timeout_default; |
Trond Myklebust | 3e32a5d | 2006-11-16 11:37:27 -0500 | [diff] [blame] | 59 | struct rpc_program * cl_program; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | char cl_inline_name[32]; |
Olga Kornievskaia | 608207e | 2008-12-23 16:17:40 -0500 | [diff] [blame] | 61 | char *cl_principal; /* target to authenticate to */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | |
| 64 | /* |
| 65 | * General RPC program info |
| 66 | */ |
| 67 | #define RPC_MAXVERSION 4 |
| 68 | struct rpc_program { |
| 69 | char * name; /* protocol name */ |
| 70 | u32 number; /* program number */ |
| 71 | unsigned int nrvers; /* number of versions */ |
| 72 | struct rpc_version ** version; /* version array */ |
| 73 | struct rpc_stat * stats; /* statistics */ |
| 74 | char * pipe_dir_name; /* path to rpc_pipefs dir */ |
| 75 | }; |
| 76 | |
| 77 | struct rpc_version { |
| 78 | u32 number; /* version number */ |
| 79 | unsigned int nrprocs; /* number of procs */ |
| 80 | struct rpc_procinfo * procs; /* procedure array */ |
| 81 | }; |
| 82 | |
| 83 | /* |
| 84 | * Procedure information |
| 85 | */ |
| 86 | struct rpc_procinfo { |
| 87 | u32 p_proc; /* RPC procedure number */ |
| 88 | kxdrproc_t p_encode; /* XDR encode function */ |
| 89 | kxdrproc_t p_decode; /* XDR decode function */ |
Chuck Lever | 2bea90d | 2007-03-29 16:47:53 -0400 | [diff] [blame] | 90 | unsigned int p_arglen; /* argument hdr length (u32) */ |
| 91 | unsigned int p_replen; /* reply hdr length (u32) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | unsigned int p_count; /* call count */ |
| 93 | unsigned int p_timer; /* Which RTT timer to use */ |
Chuck Lever | cc0175c | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 94 | u32 p_statidx; /* Which procedure to account */ |
| 95 | char * p_name; /* name of procedure */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | }; |
| 97 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | #ifdef __KERNEL__ |
| 99 | |
Chuck Lever | c286676 | 2006-08-22 20:06:20 -0400 | [diff] [blame] | 100 | struct rpc_create_args { |
| 101 | int protocol; |
| 102 | struct sockaddr *address; |
| 103 | size_t addrsize; |
Frank van Maarseveen | d3bc9a1 | 2007-07-09 22:23:35 +0200 | [diff] [blame] | 104 | struct sockaddr *saddress; |
Trond Myklebust | ba7392b | 2007-12-20 16:03:55 -0500 | [diff] [blame] | 105 | const struct rpc_timeout *timeout; |
Chuck Lever | c286676 | 2006-08-22 20:06:20 -0400 | [diff] [blame] | 106 | char *servername; |
| 107 | struct rpc_program *program; |
Benny Halevy | d5b337b | 2008-09-28 09:21:26 +0300 | [diff] [blame] | 108 | u32 prognumber; /* overrides program->number */ |
Chuck Lever | c286676 | 2006-08-22 20:06:20 -0400 | [diff] [blame] | 109 | u32 version; |
| 110 | rpc_authflavor_t authflavor; |
| 111 | unsigned long flags; |
Olga Kornievskaia | 608207e | 2008-12-23 16:17:40 -0500 | [diff] [blame] | 112 | char *client_name; |
Chuck Lever | c286676 | 2006-08-22 20:06:20 -0400 | [diff] [blame] | 113 | }; |
| 114 | |
| 115 | /* Values for "flags" field */ |
| 116 | #define RPC_CLNT_CREATE_HARDRTRY (1UL << 0) |
Chuck Lever | c286676 | 2006-08-22 20:06:20 -0400 | [diff] [blame] | 117 | #define RPC_CLNT_CREATE_AUTOBIND (1UL << 2) |
Trond Myklebust | 90c5755 | 2007-06-09 19:49:36 -0400 | [diff] [blame] | 118 | #define RPC_CLNT_CREATE_NONPRIVPORT (1UL << 3) |
| 119 | #define RPC_CLNT_CREATE_NOPING (1UL << 4) |
| 120 | #define RPC_CLNT_CREATE_DISCRTRY (1UL << 5) |
Olga Kornievskaia | b6b6152 | 2008-06-09 16:51:31 -0400 | [diff] [blame] | 121 | #define RPC_CLNT_CREATE_QUIET (1UL << 6) |
Chuck Lever | c286676 | 2006-08-22 20:06:20 -0400 | [diff] [blame] | 122 | |
| 123 | struct rpc_clnt *rpc_create(struct rpc_create_args *args); |
Andreas Gruenbacher | 007e251 | 2005-06-22 17:16:23 +0000 | [diff] [blame] | 124 | struct rpc_clnt *rpc_bind_new_program(struct rpc_clnt *, |
Chuck Lever | 89eb21c | 2007-09-11 18:00:09 -0400 | [diff] [blame] | 125 | struct rpc_program *, u32); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | struct rpc_clnt *rpc_clone_client(struct rpc_clnt *); |
Trond Myklebust | 4c402b4 | 2007-06-14 16:40:32 -0400 | [diff] [blame] | 127 | void rpc_shutdown_client(struct rpc_clnt *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | void rpc_release_client(struct rpc_clnt *); |
Chuck Lever | cce63cd | 2007-07-01 12:13:12 -0400 | [diff] [blame] | 129 | |
Chuck Lever | 14aeb21 | 2008-08-18 19:34:00 -0400 | [diff] [blame] | 130 | int rpcb_register(u32, u32, int, unsigned short); |
Chuck Lever | c2e1b09 | 2008-07-14 16:03:30 -0400 | [diff] [blame] | 131 | int rpcb_v4_register(const u32 program, const u32 version, |
| 132 | const struct sockaddr *address, |
Chuck Lever | 14aeb21 | 2008-08-18 19:34:00 -0400 | [diff] [blame] | 133 | const char *netid); |
Chuck Lever | f1ec08c | 2008-01-14 15:11:53 -0500 | [diff] [blame] | 134 | int rpcb_getport_sync(struct sockaddr_in *, u32, u32, int); |
Chuck Lever | 45160d6 | 2007-07-01 12:13:17 -0400 | [diff] [blame] | 135 | void rpcb_getport_async(struct rpc_task *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | |
Trond Myklebust | 77de2c5 | 2007-10-25 18:40:21 -0400 | [diff] [blame] | 137 | void rpc_call_start(struct rpc_task *); |
Trond Myklebust | cbc2005 | 2008-02-14 11:11:30 -0500 | [diff] [blame] | 138 | int rpc_call_async(struct rpc_clnt *clnt, |
| 139 | const struct rpc_message *msg, int flags, |
| 140 | const struct rpc_call_ops *tk_ops, |
Trond Myklebust | 963d8fe | 2006-01-03 09:55:04 +0100 | [diff] [blame] | 141 | void *calldata); |
Trond Myklebust | cbc2005 | 2008-02-14 11:11:30 -0500 | [diff] [blame] | 142 | int rpc_call_sync(struct rpc_clnt *clnt, |
| 143 | const struct rpc_message *msg, int flags); |
Trond Myklebust | 5e1550d | 2007-06-23 10:17:16 -0400 | [diff] [blame] | 144 | struct rpc_task *rpc_call_null(struct rpc_clnt *clnt, struct rpc_cred *cred, |
| 145 | int flags); |
Andy Adamson | aae2006 | 2009-04-01 09:22:40 -0400 | [diff] [blame] | 146 | void rpc_restart_call_prepare(struct rpc_task *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | void rpc_restart_call(struct rpc_task *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | void rpc_setbufsize(struct rpc_clnt *, unsigned int, unsigned int); |
| 149 | size_t rpc_max_payload(struct rpc_clnt *); |
Chuck Lever | 35f5a42 | 2006-01-03 09:55:50 +0100 | [diff] [blame] | 150 | void rpc_force_rebind(struct rpc_clnt *); |
Chuck Lever | ed39440 | 2006-08-22 20:06:17 -0400 | [diff] [blame] | 151 | size_t rpc_peeraddr(struct rpc_clnt *, struct sockaddr *, size_t); |
Chuck Lever | b454ae9 | 2008-01-07 18:34:48 -0500 | [diff] [blame] | 152 | const char *rpc_peeraddr2str(struct rpc_clnt *, enum rpc_display_format_t); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | #endif /* __KERNEL__ */ |
| 155 | #endif /* _LINUX_SUNRPC_CLNT_H */ |