| 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 |  | 
|  | 21 | /* | 
|  | 22 | * This defines an RPC port mapping | 
|  | 23 | */ | 
|  | 24 | struct rpc_portmap { | 
|  | 25 | __u32			pm_prog; | 
|  | 26 | __u32			pm_vers; | 
|  | 27 | __u32			pm_prot; | 
|  | 28 | __u16			pm_port; | 
|  | 29 | unsigned char		pm_binding : 1;	/* doing a getport() */ | 
|  | 30 | struct rpc_wait_queue	pm_bindwait;	/* waiting on getport() */ | 
|  | 31 | }; | 
|  | 32 |  | 
|  | 33 | struct rpc_inode; | 
|  | 34 |  | 
|  | 35 | /* | 
|  | 36 | * The high-level client handle | 
|  | 37 | */ | 
|  | 38 | struct rpc_clnt { | 
|  | 39 | atomic_t		cl_count;	/* Number of clones */ | 
|  | 40 | atomic_t		cl_users;	/* number of references */ | 
|  | 41 | struct rpc_xprt *	cl_xprt;	/* transport */ | 
|  | 42 | struct rpc_procinfo *	cl_procinfo;	/* procedure info */ | 
|  | 43 | u32			cl_maxproc;	/* max procedure number */ | 
|  | 44 |  | 
|  | 45 | char *			cl_server;	/* server machine name */ | 
|  | 46 | char *			cl_protname;	/* protocol name */ | 
|  | 47 | struct rpc_auth *	cl_auth;	/* authenticator */ | 
|  | 48 | struct rpc_stat *	cl_stats;	/* statistics */ | 
|  | 49 |  | 
|  | 50 | unsigned int		cl_softrtry : 1,/* soft timeouts */ | 
|  | 51 | cl_intr     : 1,/* interruptible */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | cl_autobind : 1,/* use getport() */ | 
|  | 53 | cl_oneshot  : 1,/* dispose after use */ | 
|  | 54 | cl_dead     : 1;/* abandoned */ | 
|  | 55 |  | 
|  | 56 | struct rpc_rtt *	cl_rtt;		/* RTO estimator data */ | 
|  | 57 | struct rpc_portmap *	cl_pmap;	/* port mapping */ | 
|  | 58 |  | 
|  | 59 | int			cl_nodelen;	/* nodename length */ | 
|  | 60 | char 			cl_nodename[UNX_MAXNODENAME]; | 
|  | 61 | char			cl_pathname[30];/* Path in rpc_pipe_fs */ | 
|  | 62 | struct dentry *		cl_dentry;	/* inode */ | 
|  | 63 | struct rpc_clnt *	cl_parent;	/* Points to parent of clones */ | 
|  | 64 | struct rpc_rtt		cl_rtt_default; | 
|  | 65 | struct rpc_portmap	cl_pmap_default; | 
|  | 66 | char			cl_inline_name[32]; | 
|  | 67 | }; | 
|  | 68 | #define cl_timeout		cl_xprt->timeout | 
|  | 69 | #define cl_prog			cl_pmap->pm_prog | 
|  | 70 | #define cl_vers			cl_pmap->pm_vers | 
|  | 71 | #define cl_port			cl_pmap->pm_port | 
|  | 72 | #define cl_prot			cl_pmap->pm_prot | 
|  | 73 |  | 
|  | 74 | /* | 
|  | 75 | * General RPC program info | 
|  | 76 | */ | 
|  | 77 | #define RPC_MAXVERSION		4 | 
|  | 78 | struct rpc_program { | 
|  | 79 | char *			name;		/* protocol name */ | 
|  | 80 | u32			number;		/* program number */ | 
|  | 81 | unsigned int		nrvers;		/* number of versions */ | 
|  | 82 | struct rpc_version **	version;	/* version array */ | 
|  | 83 | struct rpc_stat *	stats;		/* statistics */ | 
|  | 84 | char *			pipe_dir_name;	/* path to rpc_pipefs dir */ | 
|  | 85 | }; | 
|  | 86 |  | 
|  | 87 | struct rpc_version { | 
|  | 88 | u32			number;		/* version number */ | 
|  | 89 | unsigned int		nrprocs;	/* number of procs */ | 
|  | 90 | struct rpc_procinfo *	procs;		/* procedure array */ | 
|  | 91 | }; | 
|  | 92 |  | 
|  | 93 | /* | 
|  | 94 | * Procedure information | 
|  | 95 | */ | 
|  | 96 | struct rpc_procinfo { | 
|  | 97 | u32			p_proc;		/* RPC procedure number */ | 
|  | 98 | kxdrproc_t		p_encode;	/* XDR encode function */ | 
|  | 99 | kxdrproc_t		p_decode;	/* XDR decode function */ | 
|  | 100 | unsigned int		p_bufsiz;	/* req. buffer size */ | 
|  | 101 | unsigned int		p_count;	/* call count */ | 
|  | 102 | unsigned int		p_timer;	/* Which RTT timer to use */ | 
|  | 103 | }; | 
|  | 104 |  | 
|  | 105 | #define RPC_CONGESTED(clnt)	(RPCXPRT_CONGESTED((clnt)->cl_xprt)) | 
|  | 106 | #define RPC_PEERADDR(clnt)	(&(clnt)->cl_xprt->addr) | 
|  | 107 |  | 
|  | 108 | #ifdef __KERNEL__ | 
|  | 109 |  | 
|  | 110 | struct rpc_clnt *rpc_create_client(struct rpc_xprt *xprt, char *servname, | 
|  | 111 | struct rpc_program *info, | 
|  | 112 | u32 version, rpc_authflavor_t authflavor); | 
| Trond Myklebust | 5ee0ed7 | 2005-06-22 17:16:20 +0000 | [diff] [blame] | 113 | struct rpc_clnt *rpc_new_client(struct rpc_xprt *xprt, char *servname, | 
|  | 114 | struct rpc_program *info, | 
|  | 115 | u32 version, rpc_authflavor_t authflavor); | 
| 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 *); | 
|  | 122 | void		rpc_getport(struct rpc_task *, struct rpc_clnt *); | 
|  | 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); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 |  | 
|  | 140 | static __inline__ | 
|  | 141 | int rpc_call(struct rpc_clnt *clnt, u32 proc, void *argp, void *resp, int flags) | 
|  | 142 | { | 
|  | 143 | struct rpc_message msg = { | 
|  | 144 | .rpc_proc	= &clnt->cl_procinfo[proc], | 
|  | 145 | .rpc_argp	= argp, | 
|  | 146 | .rpc_resp	= resp, | 
|  | 147 | .rpc_cred	= NULL | 
|  | 148 | }; | 
|  | 149 | return rpc_call_sync(clnt, &msg, flags); | 
|  | 150 | } | 
|  | 151 |  | 
|  | 152 | extern void rpciod_wake_up(void); | 
|  | 153 |  | 
|  | 154 | /* | 
|  | 155 | * Helper function for NFSroot support | 
|  | 156 | */ | 
|  | 157 | int		rpc_getport_external(struct sockaddr_in *, __u32, __u32, int); | 
|  | 158 |  | 
|  | 159 | #endif /* __KERNEL__ */ | 
|  | 160 | #endif /* _LINUX_SUNRPC_CLNT_H */ |