clnt.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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/sunrpc/msg_prot.h>
  11. #include <linux/sunrpc/sched.h>
  12. #include <linux/sunrpc/xprt.h>
  13. #include <linux/sunrpc/auth.h>
  14. #include <linux/sunrpc/stats.h>
  15. #include <linux/sunrpc/xdr.h>
  16. #include <linux/sunrpc/timer.h>
  17. #include <asm/signal.h>
  18. struct rpc_inode;
  19. /*
  20. * The high-level client handle
  21. */
  22. struct rpc_clnt {
  23. struct kref cl_kref; /* Number of references */
  24. atomic_t cl_count; /* Number of clones */
  25. struct list_head cl_clients; /* Global list of clients */
  26. struct list_head cl_tasks; /* List of tasks */
  27. spinlock_t cl_lock; /* spinlock */
  28. struct rpc_xprt * cl_xprt; /* transport */
  29. struct rpc_procinfo * cl_procinfo; /* procedure info */
  30. u32 cl_prog, /* RPC program number */
  31. cl_vers, /* RPC version number */
  32. cl_maxproc; /* max procedure number */
  33. char * cl_server; /* server machine name */
  34. char * cl_protname; /* protocol name */
  35. struct rpc_auth * cl_auth; /* authenticator */
  36. struct rpc_stat * cl_stats; /* per-program statistics */
  37. struct rpc_iostats * cl_metrics; /* per-client statistics */
  38. unsigned int cl_softrtry : 1,/* soft timeouts */
  39. cl_intr : 1,/* interruptible */
  40. cl_discrtry : 1,/* disconnect before retry */
  41. cl_autobind : 1;/* use getport() */
  42. struct rpc_rtt * cl_rtt; /* RTO estimator data */
  43. int cl_nodelen; /* nodename length */
  44. char cl_nodename[UNX_MAXNODENAME];
  45. char cl_pathname[30];/* Path in rpc_pipe_fs */
  46. struct vfsmount * cl_vfsmnt;
  47. struct dentry * cl_dentry; /* inode */
  48. struct rpc_clnt * cl_parent; /* Points to parent of clones */
  49. struct rpc_rtt cl_rtt_default;
  50. struct rpc_program * cl_program;
  51. char cl_inline_name[32];
  52. };
  53. /*
  54. * General RPC program info
  55. */
  56. #define RPC_MAXVERSION 4
  57. struct rpc_program {
  58. char * name; /* protocol name */
  59. u32 number; /* program number */
  60. unsigned int nrvers; /* number of versions */
  61. struct rpc_version ** version; /* version array */
  62. struct rpc_stat * stats; /* statistics */
  63. char * pipe_dir_name; /* path to rpc_pipefs dir */
  64. };
  65. struct rpc_version {
  66. u32 number; /* version number */
  67. unsigned int nrprocs; /* number of procs */
  68. struct rpc_procinfo * procs; /* procedure array */
  69. };
  70. /*
  71. * Procedure information
  72. */
  73. struct rpc_procinfo {
  74. u32 p_proc; /* RPC procedure number */
  75. kxdrproc_t p_encode; /* XDR encode function */
  76. kxdrproc_t p_decode; /* XDR decode function */
  77. unsigned int p_arglen; /* argument hdr length (u32) */
  78. unsigned int p_replen; /* reply hdr length (u32) */
  79. unsigned int p_count; /* call count */
  80. unsigned int p_timer; /* Which RTT timer to use */
  81. u32 p_statidx; /* Which procedure to account */
  82. char * p_name; /* name of procedure */
  83. };
  84. #ifdef __KERNEL__
  85. struct rpc_create_args {
  86. int protocol;
  87. struct sockaddr *address;
  88. size_t addrsize;
  89. struct rpc_timeout *timeout;
  90. char *servername;
  91. struct rpc_program *program;
  92. u32 version;
  93. rpc_authflavor_t authflavor;
  94. unsigned long flags;
  95. };
  96. /* Values for "flags" field */
  97. #define RPC_CLNT_CREATE_HARDRTRY (1UL << 0)
  98. #define RPC_CLNT_CREATE_INTR (1UL << 1)
  99. #define RPC_CLNT_CREATE_AUTOBIND (1UL << 2)
  100. #define RPC_CLNT_CREATE_NONPRIVPORT (1UL << 3)
  101. #define RPC_CLNT_CREATE_NOPING (1UL << 4)
  102. #define RPC_CLNT_CREATE_DISCRTRY (1UL << 5)
  103. struct rpc_clnt *rpc_create(struct rpc_create_args *args);
  104. struct rpc_clnt *rpc_bind_new_program(struct rpc_clnt *,
  105. struct rpc_program *, int);
  106. struct rpc_clnt *rpc_clone_client(struct rpc_clnt *);
  107. int rpc_shutdown_client(struct rpc_clnt *);
  108. int rpc_destroy_client(struct rpc_clnt *);
  109. void rpc_release_client(struct rpc_clnt *);
  110. void rpc_register_client(struct rpc_clnt *);
  111. void rpc_unregister_client(struct rpc_clnt *);
  112. int rpcb_register(u32, u32, int, unsigned short, int *);
  113. void rpcb_getport(struct rpc_task *);
  114. void rpc_call_setup(struct rpc_task *, struct rpc_message *, int);
  115. int rpc_call_async(struct rpc_clnt *clnt, struct rpc_message *msg,
  116. int flags, const struct rpc_call_ops *tk_ops,
  117. void *calldata);
  118. int rpc_call_sync(struct rpc_clnt *clnt, struct rpc_message *msg,
  119. int flags);
  120. void rpc_restart_call(struct rpc_task *);
  121. void rpc_clnt_sigmask(struct rpc_clnt *clnt, sigset_t *oldset);
  122. void rpc_clnt_sigunmask(struct rpc_clnt *clnt, sigset_t *oldset);
  123. void rpc_setbufsize(struct rpc_clnt *, unsigned int, unsigned int);
  124. size_t rpc_max_payload(struct rpc_clnt *);
  125. void rpc_force_rebind(struct rpc_clnt *);
  126. int rpc_ping(struct rpc_clnt *clnt, int flags);
  127. size_t rpc_peeraddr(struct rpc_clnt *, struct sockaddr *, size_t);
  128. char * rpc_peeraddr2str(struct rpc_clnt *, enum rpc_display_format_t);
  129. /*
  130. * Helper function for NFSroot support
  131. */
  132. int rpcb_getport_external(struct sockaddr_in *, __u32, __u32, int);
  133. #endif /* __KERNEL__ */
  134. #endif /* _LINUX_SUNRPC_CLNT_H */