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 { |
| 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 Lever | 4a68179 | 2006-08-22 20:06:15 -0400 | [diff] [blame] | 31 | u32 cl_prog, /* RPC program number */ |
| 32 | cl_vers, /* RPC version number */ |
| 33 | cl_maxproc; /* max procedure number */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | |
| 35 | char * cl_server; /* server machine name */ |
| 36 | char * cl_protname; /* protocol name */ |
| 37 | struct rpc_auth * cl_auth; /* authenticator */ |
Chuck Lever | 11c556b | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 38 | struct rpc_stat * cl_stats; /* per-program statistics */ |
| 39 | struct rpc_iostats * cl_metrics; /* per-client statistics */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | |
| 41 | unsigned int cl_softrtry : 1,/* soft timeouts */ |
| 42 | cl_intr : 1,/* interruptible */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | |
| 49 | int cl_nodelen; /* nodename length */ |
| 50 | char cl_nodename[UNX_MAXNODENAME]; |
| 51 | char cl_pathname[30];/* Path in rpc_pipe_fs */ |
Trond Myklebust | 5428154 | 2006-03-20 13:44:49 -0500 | [diff] [blame] | 52 | struct vfsmount * cl_vfsmnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | struct dentry * cl_dentry; /* inode */ |
| 54 | struct rpc_clnt * cl_parent; /* Points to parent of clones */ |
| 55 | struct rpc_rtt cl_rtt_default; |
Trond Myklebust | 3e32a5d | 2006-11-16 11:37:27 -0500 | [diff] [blame] | 56 | struct rpc_program * cl_program; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | char cl_inline_name[32]; |
| 58 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | |
| 60 | /* |
| 61 | * General RPC program info |
| 62 | */ |
| 63 | #define RPC_MAXVERSION 4 |
| 64 | struct rpc_program { |
| 65 | char * name; /* protocol name */ |
| 66 | u32 number; /* program number */ |
| 67 | unsigned int nrvers; /* number of versions */ |
| 68 | struct rpc_version ** version; /* version array */ |
| 69 | struct rpc_stat * stats; /* statistics */ |
| 70 | char * pipe_dir_name; /* path to rpc_pipefs dir */ |
| 71 | }; |
| 72 | |
| 73 | struct rpc_version { |
| 74 | u32 number; /* version number */ |
| 75 | unsigned int nrprocs; /* number of procs */ |
| 76 | struct rpc_procinfo * procs; /* procedure array */ |
| 77 | }; |
| 78 | |
| 79 | /* |
| 80 | * Procedure information |
| 81 | */ |
| 82 | struct rpc_procinfo { |
| 83 | u32 p_proc; /* RPC procedure number */ |
| 84 | kxdrproc_t p_encode; /* XDR encode function */ |
| 85 | kxdrproc_t p_decode; /* XDR decode function */ |
| 86 | unsigned int p_bufsiz; /* req. buffer size */ |
| 87 | unsigned int p_count; /* call count */ |
| 88 | unsigned int p_timer; /* Which RTT timer to use */ |
Chuck Lever | cc0175c | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 89 | u32 p_statidx; /* Which procedure to account */ |
| 90 | char * p_name; /* name of procedure */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | }; |
| 92 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | #ifdef __KERNEL__ |
| 94 | |
Chuck Lever | c286676 | 2006-08-22 20:06:20 -0400 | [diff] [blame] | 95 | struct rpc_create_args { |
| 96 | int protocol; |
| 97 | struct sockaddr *address; |
| 98 | size_t addrsize; |
| 99 | struct rpc_timeout *timeout; |
| 100 | char *servername; |
| 101 | struct rpc_program *program; |
| 102 | u32 version; |
| 103 | rpc_authflavor_t authflavor; |
| 104 | unsigned long flags; |
| 105 | }; |
| 106 | |
| 107 | /* Values for "flags" field */ |
| 108 | #define RPC_CLNT_CREATE_HARDRTRY (1UL << 0) |
| 109 | #define RPC_CLNT_CREATE_INTR (1UL << 1) |
| 110 | #define RPC_CLNT_CREATE_AUTOBIND (1UL << 2) |
| 111 | #define RPC_CLNT_CREATE_ONESHOT (1UL << 3) |
| 112 | #define RPC_CLNT_CREATE_NONPRIVPORT (1UL << 4) |
| 113 | #define RPC_CLNT_CREATE_NOPING (1UL << 5) |
| 114 | |
| 115 | struct rpc_clnt *rpc_create(struct rpc_create_args *args); |
Andreas Gruenbacher | 007e251 | 2005-06-22 17:16:23 +0000 | [diff] [blame] | 116 | struct rpc_clnt *rpc_bind_new_program(struct rpc_clnt *, |
| 117 | struct rpc_program *, int); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | struct rpc_clnt *rpc_clone_client(struct rpc_clnt *); |
| 119 | int rpc_shutdown_client(struct rpc_clnt *); |
| 120 | int rpc_destroy_client(struct rpc_clnt *); |
| 121 | void rpc_release_client(struct rpc_clnt *); |
Chuck Lever | bbf7c1d | 2006-08-22 20:06:16 -0400 | [diff] [blame] | 122 | void rpc_getport(struct rpc_task *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | int rpc_register(u32, u32, int, unsigned short, int *); |
| 124 | |
| 125 | void rpc_call_setup(struct rpc_task *, struct rpc_message *, int); |
| 126 | |
| 127 | int rpc_call_async(struct rpc_clnt *clnt, struct rpc_message *msg, |
Trond Myklebust | 963d8fe | 2006-01-03 09:55:04 +0100 | [diff] [blame] | 128 | int flags, const struct rpc_call_ops *tk_ops, |
| 129 | void *calldata); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | int rpc_call_sync(struct rpc_clnt *clnt, struct rpc_message *msg, |
| 131 | int flags); |
| 132 | void rpc_restart_call(struct rpc_task *); |
| 133 | void rpc_clnt_sigmask(struct rpc_clnt *clnt, sigset_t *oldset); |
| 134 | void rpc_clnt_sigunmask(struct rpc_clnt *clnt, sigset_t *oldset); |
| 135 | void rpc_setbufsize(struct rpc_clnt *, unsigned int, unsigned int); |
| 136 | size_t rpc_max_payload(struct rpc_clnt *); |
Chuck Lever | 35f5a42 | 2006-01-03 09:55:50 +0100 | [diff] [blame] | 137 | void rpc_force_rebind(struct rpc_clnt *); |
Trond Myklebust | 5ee0ed7 | 2005-06-22 17:16:20 +0000 | [diff] [blame] | 138 | int rpc_ping(struct rpc_clnt *clnt, int flags); |
Chuck Lever | ed39440 | 2006-08-22 20:06:17 -0400 | [diff] [blame] | 139 | size_t rpc_peeraddr(struct rpc_clnt *, struct sockaddr *, size_t); |
Chuck Lever | f425eba | 2006-08-22 20:06:18 -0400 | [diff] [blame] | 140 | char * rpc_peeraddr2str(struct rpc_clnt *, enum rpc_display_format_t); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | /* |
| 143 | * Helper function for NFSroot support |
| 144 | */ |
| 145 | int rpc_getport_external(struct sockaddr_in *, __u32, __u32, int); |
| 146 | |
| 147 | #endif /* __KERNEL__ */ |
| 148 | #endif /* _LINUX_SUNRPC_CLNT_H */ |