clnt.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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. #ifndef _LINUX_SUNRPC_CLNT_H
  9. #define _LINUX_SUNRPC_CLNT_H
  10. #include <linux/types.h>
  11. #include <linux/socket.h>
  12. #include <linux/in.h>
  13. #include <linux/in6.h>
  14. #include <linux/sunrpc/msg_prot.h>
  15. #include <linux/sunrpc/sched.h>
  16. #include <linux/sunrpc/xprt.h>
  17. #include <linux/sunrpc/auth.h>
  18. #include <linux/sunrpc/stats.h>
  19. #include <linux/sunrpc/xdr.h>
  20. #include <linux/sunrpc/timer.h>
  21. #include <linux/sunrpc/rpc_pipe_fs.h>
  22. #include <asm/signal.h>
  23. #include <linux/path.h>
  24. #include <net/ipv6.h>
  25. struct rpc_inode;
  26. /*
  27. * The high-level client handle
  28. */
  29. struct rpc_clnt {
  30. atomic_t cl_count; /* Number of references */
  31. unsigned int cl_clid; /* client id */
  32. struct list_head cl_clients; /* Global list of clients */
  33. struct list_head cl_tasks; /* List of tasks */
  34. spinlock_t cl_lock; /* spinlock */
  35. struct rpc_xprt __rcu * cl_xprt; /* transport */
  36. struct rpc_procinfo * cl_procinfo; /* procedure info */
  37. u32 cl_prog, /* RPC program number */
  38. cl_vers, /* RPC version number */
  39. cl_maxproc; /* max procedure number */
  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. unsigned int cl_softrtry : 1,/* soft timeouts */
  44. cl_discrtry : 1,/* disconnect before retry */
  45. cl_noretranstimeo: 1,/* No retransmit timeouts */
  46. cl_autobind : 1,/* use getport() */
  47. cl_chatty : 1;/* be verbose */
  48. struct rpc_rtt * cl_rtt; /* RTO estimator data */
  49. const struct rpc_timeout *cl_timeout; /* Timeout strategy */
  50. int cl_nodelen; /* nodename length */
  51. char cl_nodename[UNX_MAXNODENAME+1];
  52. struct rpc_pipe_dir_head cl_pipedir_objects;
  53. struct rpc_clnt * cl_parent; /* Points to parent of clones */
  54. struct rpc_rtt cl_rtt_default;
  55. struct rpc_timeout cl_timeout_default;
  56. const struct rpc_program *cl_program;
  57. };
  58. /*
  59. * General RPC program info
  60. */
  61. #define RPC_MAXVERSION 4
  62. struct rpc_program {
  63. const char * name; /* protocol name */
  64. u32 number; /* program number */
  65. unsigned int nrvers; /* number of versions */
  66. const struct rpc_version ** version; /* version array */
  67. struct rpc_stat * stats; /* statistics */
  68. const char * pipe_dir_name; /* path to rpc_pipefs dir */
  69. };
  70. struct rpc_version {
  71. u32 number; /* version number */
  72. unsigned int nrprocs; /* number of procs */
  73. struct rpc_procinfo * procs; /* procedure array */
  74. };
  75. /*
  76. * Procedure information
  77. */
  78. struct rpc_procinfo {
  79. u32 p_proc; /* RPC procedure number */
  80. kxdreproc_t p_encode; /* XDR encode function */
  81. kxdrdproc_t p_decode; /* XDR decode function */
  82. unsigned int p_arglen; /* argument hdr length (u32) */
  83. unsigned int p_replen; /* reply hdr length (u32) */
  84. unsigned int p_count; /* call count */
  85. unsigned int p_timer; /* Which RTT timer to use */
  86. u32 p_statidx; /* Which procedure to account */
  87. const char * p_name; /* name of procedure */
  88. };
  89. #ifdef __KERNEL__
  90. struct rpc_create_args {
  91. struct net *net;
  92. int protocol;
  93. struct sockaddr *address;
  94. size_t addrsize;
  95. struct sockaddr *saddress;
  96. const struct rpc_timeout *timeout;
  97. const char *servername;
  98. const char *nodename;
  99. const struct rpc_program *program;
  100. u32 prognumber; /* overrides program->number */
  101. u32 version;
  102. rpc_authflavor_t authflavor;
  103. unsigned long flags;
  104. char *client_name;
  105. struct svc_xprt *bc_xprt; /* NFSv4.1 backchannel */
  106. };
  107. /* Values for "flags" field */
  108. #define RPC_CLNT_CREATE_HARDRTRY (1UL << 0)
  109. #define RPC_CLNT_CREATE_AUTOBIND (1UL << 2)
  110. #define RPC_CLNT_CREATE_NONPRIVPORT (1UL << 3)
  111. #define RPC_CLNT_CREATE_NOPING (1UL << 4)
  112. #define RPC_CLNT_CREATE_DISCRTRY (1UL << 5)
  113. #define RPC_CLNT_CREATE_QUIET (1UL << 6)
  114. #define RPC_CLNT_CREATE_INFINITE_SLOTS (1UL << 7)
  115. #define RPC_CLNT_CREATE_NO_IDLE_TIMEOUT (1UL << 8)
  116. #define RPC_CLNT_CREATE_NO_RETRANS_TIMEOUT (1UL << 9)
  117. struct rpc_clnt *rpc_create(struct rpc_create_args *args);
  118. struct rpc_clnt *rpc_create_xprt(struct rpc_create_args *args,
  119. struct rpc_xprt *xprt);
  120. struct rpc_clnt *rpc_bind_new_program(struct rpc_clnt *,
  121. const struct rpc_program *, u32);
  122. void rpc_task_reset_client(struct rpc_task *task, struct rpc_clnt *clnt);
  123. struct rpc_clnt *rpc_clone_client(struct rpc_clnt *);
  124. struct rpc_clnt *rpc_clone_client_set_auth(struct rpc_clnt *,
  125. rpc_authflavor_t);
  126. int rpc_switch_client_transport(struct rpc_clnt *,
  127. struct xprt_create *,
  128. const struct rpc_timeout *);
  129. void rpc_shutdown_client(struct rpc_clnt *);
  130. void rpc_release_client(struct rpc_clnt *);
  131. void rpc_task_release_client(struct rpc_task *);
  132. int rpcb_create_local(struct net *);
  133. void rpcb_put_local(struct net *);
  134. int rpcb_register(struct net *, u32, u32, int, unsigned short);
  135. int rpcb_v4_register(struct net *net, const u32 program,
  136. const u32 version,
  137. const struct sockaddr *address,
  138. const char *netid);
  139. void rpcb_getport_async(struct rpc_task *);
  140. void rpc_call_start(struct rpc_task *);
  141. int rpc_call_async(struct rpc_clnt *clnt,
  142. const struct rpc_message *msg, int flags,
  143. const struct rpc_call_ops *tk_ops,
  144. void *calldata);
  145. int rpc_call_sync(struct rpc_clnt *clnt,
  146. const struct rpc_message *msg, int flags);
  147. struct rpc_task *rpc_call_null(struct rpc_clnt *clnt, struct rpc_cred *cred,
  148. int flags);
  149. int rpc_restart_call_prepare(struct rpc_task *);
  150. int rpc_restart_call(struct rpc_task *);
  151. void rpc_setbufsize(struct rpc_clnt *, unsigned int, unsigned int);
  152. int rpc_protocol(struct rpc_clnt *);
  153. struct net * rpc_net_ns(struct rpc_clnt *);
  154. size_t rpc_max_payload(struct rpc_clnt *);
  155. unsigned long rpc_get_timeout(struct rpc_clnt *clnt);
  156. void rpc_force_rebind(struct rpc_clnt *);
  157. size_t rpc_peeraddr(struct rpc_clnt *, struct sockaddr *, size_t);
  158. const char *rpc_peeraddr2str(struct rpc_clnt *, enum rpc_display_format_t);
  159. int rpc_localaddr(struct rpc_clnt *, struct sockaddr *, size_t);
  160. #endif /* __KERNEL__ */
  161. #endif /* _LINUX_SUNRPC_CLNT_H */