SUNRPC: clean up rpc_setup_pipedir()
[safe/jmp/linux-2.6] / include / linux / sunrpc / clnt.h
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 #include <linux/path.h>
21
22 struct rpc_inode;
23
24 /*
25  * The high-level client handle
26  */
27 struct rpc_clnt {
28         struct kref             cl_kref;        /* Number of references */
29         struct list_head        cl_clients;     /* Global list of clients */
30         struct list_head        cl_tasks;       /* List of tasks */
31         spinlock_t              cl_lock;        /* spinlock */
32         struct rpc_xprt *       cl_xprt;        /* transport */
33         struct rpc_procinfo *   cl_procinfo;    /* procedure info */
34         u32                     cl_prog,        /* RPC program number */
35                                 cl_vers,        /* RPC version number */
36                                 cl_maxproc;     /* max procedure number */
37
38         char *                  cl_server;      /* server machine name */
39         char *                  cl_protname;    /* protocol name */
40         struct rpc_auth *       cl_auth;        /* authenticator */
41         struct rpc_stat *       cl_stats;       /* per-program statistics */
42         struct rpc_iostats *    cl_metrics;     /* per-client statistics */
43
44         unsigned int            cl_softrtry : 1,/* soft timeouts */
45                                 cl_discrtry : 1,/* disconnect before retry */
46                                 cl_autobind : 1,/* use getport() */
47                                 cl_chatty   : 1;/* be verbose */
48
49         struct rpc_rtt *        cl_rtt;         /* RTO estimator data */
50         const struct rpc_timeout *cl_timeout;   /* Timeout strategy */
51
52         int                     cl_nodelen;     /* nodename length */
53         char                    cl_nodename[UNX_MAXNODENAME];
54         struct path             cl_path;
55         struct rpc_clnt *       cl_parent;      /* Points to parent of clones */
56         struct rpc_rtt          cl_rtt_default;
57         struct rpc_timeout      cl_timeout_default;
58         struct rpc_program *    cl_program;
59         char                    cl_inline_name[32];
60         char                    *cl_principal;  /* target to authenticate to */
61 };
62
63 /*
64  * General RPC program info
65  */
66 #define RPC_MAXVERSION          4
67 struct 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
76 struct 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  */
85 struct 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 */
89         unsigned int            p_arglen;       /* argument hdr length (u32) */
90         unsigned int            p_replen;       /* reply hdr length (u32) */
91         unsigned int            p_count;        /* call count */
92         unsigned int            p_timer;        /* Which RTT timer to use */
93         u32                     p_statidx;      /* Which procedure to account */
94         char *                  p_name;         /* name of procedure */
95 };
96
97 #ifdef __KERNEL__
98
99 struct rpc_create_args {
100         int                     protocol;
101         struct sockaddr         *address;
102         size_t                  addrsize;
103         struct sockaddr         *saddress;
104         const struct rpc_timeout *timeout;
105         char                    *servername;
106         struct rpc_program      *program;
107         u32                     prognumber;     /* overrides program->number */
108         u32                     version;
109         rpc_authflavor_t        authflavor;
110         unsigned long           flags;
111         char                    *client_name;
112 };
113
114 /* Values for "flags" field */
115 #define RPC_CLNT_CREATE_HARDRTRY        (1UL << 0)
116 #define RPC_CLNT_CREATE_AUTOBIND        (1UL << 2)
117 #define RPC_CLNT_CREATE_NONPRIVPORT     (1UL << 3)
118 #define RPC_CLNT_CREATE_NOPING          (1UL << 4)
119 #define RPC_CLNT_CREATE_DISCRTRY        (1UL << 5)
120 #define RPC_CLNT_CREATE_QUIET           (1UL << 6)
121
122 struct rpc_clnt *rpc_create(struct rpc_create_args *args);
123 struct rpc_clnt *rpc_bind_new_program(struct rpc_clnt *,
124                                 struct rpc_program *, u32);
125 struct rpc_clnt *rpc_clone_client(struct rpc_clnt *);
126 void            rpc_shutdown_client(struct rpc_clnt *);
127 void            rpc_release_client(struct rpc_clnt *);
128
129 int             rpcb_register(u32, u32, int, unsigned short);
130 int             rpcb_v4_register(const u32 program, const u32 version,
131                                  const struct sockaddr *address,
132                                  const char *netid);
133 int             rpcb_getport_sync(struct sockaddr_in *, u32, u32, int);
134 void            rpcb_getport_async(struct rpc_task *);
135
136 void            rpc_call_start(struct rpc_task *);
137 int             rpc_call_async(struct rpc_clnt *clnt,
138                                const struct rpc_message *msg, int flags,
139                                const struct rpc_call_ops *tk_ops,
140                                void *calldata);
141 int             rpc_call_sync(struct rpc_clnt *clnt,
142                               const struct rpc_message *msg, int flags);
143 struct rpc_task *rpc_call_null(struct rpc_clnt *clnt, struct rpc_cred *cred,
144                                int flags);
145 void            rpc_restart_call_prepare(struct rpc_task *);
146 void            rpc_restart_call(struct rpc_task *);
147 void            rpc_setbufsize(struct rpc_clnt *, unsigned int, unsigned int);
148 size_t          rpc_max_payload(struct rpc_clnt *);
149 void            rpc_force_rebind(struct rpc_clnt *);
150 size_t          rpc_peeraddr(struct rpc_clnt *, struct sockaddr *, size_t);
151 const char      *rpc_peeraddr2str(struct rpc_clnt *, enum rpc_display_format_t);
152
153 #endif /* __KERNEL__ */
154 #endif /* _LINUX_SUNRPC_CLNT_H */