clnt.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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. atomic_t cl_swapper; /* swapfile count */
  51. int cl_nodelen; /* nodename length */
  52. char cl_nodename[UNX_MAXNODENAME+1];
  53. struct rpc_pipe_dir_head cl_pipedir_objects;
  54. struct rpc_clnt * cl_parent; /* Points to parent of clones */
  55. struct rpc_rtt cl_rtt_default;
  56. struct rpc_timeout cl_timeout_default;
  57. const struct rpc_program *cl_program;
  58. #if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
  59. struct dentry *cl_debugfs; /* debugfs directory */
  60. #endif
  61. };
  62. /*
  63. * General RPC program info
  64. */
  65. #define RPC_MAXVERSION 4
  66. struct rpc_program {
  67. const char * name; /* protocol name */
  68. u32 number; /* program number */
  69. unsigned int nrvers; /* number of versions */
  70. const struct rpc_version ** version; /* version array */
  71. struct rpc_stat * stats; /* statistics */
  72. const char * pipe_dir_name; /* path to rpc_pipefs dir */
  73. };
  74. struct rpc_version {
  75. u32 number; /* version number */
  76. unsigned int nrprocs; /* number of procs */
  77. struct rpc_procinfo * procs; /* procedure array */
  78. };
  79. /*
  80. * Procedure information
  81. */
  82. struct rpc_procinfo {
  83. u32 p_proc; /* RPC procedure number */
  84. kxdreproc_t p_encode; /* XDR encode function */
  85. kxdrdproc_t p_decode; /* XDR decode function */
  86. unsigned int p_arglen; /* argument hdr length (u32) */
  87. unsigned int p_replen; /* reply hdr length (u32) */
  88. unsigned int p_count; /* call count */
  89. unsigned int p_timer; /* Which RTT timer to use */
  90. u32 p_statidx; /* Which procedure to account */
  91. const char * p_name; /* name of procedure */
  92. };
  93. #ifdef __KERNEL__
  94. struct rpc_create_args {
  95. struct net *net;
  96. int protocol;
  97. struct sockaddr *address;
  98. size_t addrsize;
  99. struct sockaddr *saddress;
  100. const struct rpc_timeout *timeout;
  101. const char *servername;
  102. const char *nodename;
  103. const struct rpc_program *program;
  104. u32 prognumber; /* overrides program->number */
  105. u32 version;
  106. rpc_authflavor_t authflavor;
  107. unsigned long flags;
  108. char *client_name;
  109. struct svc_xprt *bc_xprt; /* NFSv4.1 backchannel */
  110. };
  111. /* Values for "flags" field */
  112. #define RPC_CLNT_CREATE_HARDRTRY (1UL << 0)
  113. #define RPC_CLNT_CREATE_AUTOBIND (1UL << 2)
  114. #define RPC_CLNT_CREATE_NONPRIVPORT (1UL << 3)
  115. #define RPC_CLNT_CREATE_NOPING (1UL << 4)
  116. #define RPC_CLNT_CREATE_DISCRTRY (1UL << 5)
  117. #define RPC_CLNT_CREATE_QUIET (1UL << 6)
  118. #define RPC_CLNT_CREATE_INFINITE_SLOTS (1UL << 7)
  119. #define RPC_CLNT_CREATE_NO_IDLE_TIMEOUT (1UL << 8)
  120. #define RPC_CLNT_CREATE_NO_RETRANS_TIMEOUT (1UL << 9)
  121. struct rpc_clnt *rpc_create(struct rpc_create_args *args);
  122. struct rpc_clnt *rpc_bind_new_program(struct rpc_clnt *,
  123. const struct rpc_program *, u32);
  124. void rpc_task_reset_client(struct rpc_task *task, struct rpc_clnt *clnt);
  125. struct rpc_clnt *rpc_clone_client(struct rpc_clnt *);
  126. struct rpc_clnt *rpc_clone_client_set_auth(struct rpc_clnt *,
  127. rpc_authflavor_t);
  128. int rpc_switch_client_transport(struct rpc_clnt *,
  129. struct xprt_create *,
  130. const struct rpc_timeout *);
  131. void rpc_shutdown_client(struct rpc_clnt *);
  132. void rpc_release_client(struct rpc_clnt *);
  133. void rpc_task_release_client(struct rpc_task *);
  134. int rpcb_create_local(struct net *);
  135. void rpcb_put_local(struct net *);
  136. int rpcb_register(struct net *, u32, u32, int, unsigned short);
  137. int rpcb_v4_register(struct net *net, const u32 program,
  138. const u32 version,
  139. const struct sockaddr *address,
  140. const char *netid);
  141. void rpcb_getport_async(struct rpc_task *);
  142. void rpc_call_start(struct rpc_task *);
  143. int rpc_call_async(struct rpc_clnt *clnt,
  144. const struct rpc_message *msg, int flags,
  145. const struct rpc_call_ops *tk_ops,
  146. void *calldata);
  147. int rpc_call_sync(struct rpc_clnt *clnt,
  148. const struct rpc_message *msg, int flags);
  149. struct rpc_task *rpc_call_null(struct rpc_clnt *clnt, struct rpc_cred *cred,
  150. int flags);
  151. int rpc_restart_call_prepare(struct rpc_task *);
  152. int rpc_restart_call(struct rpc_task *);
  153. void rpc_setbufsize(struct rpc_clnt *, unsigned int, unsigned int);
  154. int rpc_protocol(struct rpc_clnt *);
  155. struct net * rpc_net_ns(struct rpc_clnt *);
  156. size_t rpc_max_payload(struct rpc_clnt *);
  157. unsigned long rpc_get_timeout(struct rpc_clnt *clnt);
  158. void rpc_force_rebind(struct rpc_clnt *);
  159. size_t rpc_peeraddr(struct rpc_clnt *, struct sockaddr *, size_t);
  160. const char *rpc_peeraddr2str(struct rpc_clnt *, enum rpc_display_format_t);
  161. int rpc_localaddr(struct rpc_clnt *, struct sockaddr *, size_t);
  162. const char *rpc_proc_name(const struct rpc_task *task);
  163. void rpc_cleanup_clids(void);
  164. #endif /* __KERNEL__ */
  165. #endif /* _LINUX_SUNRPC_CLNT_H */