clnt.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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. cl_oneshot : 1;/* dispose after use */
  43. struct rpc_rtt * cl_rtt; /* RTO estimator data */
  44. int cl_nodelen; /* nodename length */
  45. char cl_nodename[UNX_MAXNODENAME];
  46. char cl_pathname[30];/* Path in rpc_pipe_fs */
  47. struct vfsmount * cl_vfsmnt;
  48. struct dentry * cl_dentry; /* inode */
  49. struct rpc_clnt * cl_parent; /* Points to parent of clones */
  50. struct rpc_rtt cl_rtt_default;
  51. struct rpc_program * cl_program;
  52. char cl_inline_name[32];
  53. };
  54. /*
  55. * General RPC program info
  56. */
  57. #define RPC_MAXVERSION 4
  58. struct rpc_program {
  59. char * name; /* protocol name */
  60. u32 number; /* program number */
  61. unsigned int nrvers; /* number of versions */
  62. struct rpc_version ** version; /* version array */
  63. struct rpc_stat * stats; /* statistics */
  64. char * pipe_dir_name; /* path to rpc_pipefs dir */
  65. };
  66. struct rpc_version {
  67. u32 number; /* version number */
  68. unsigned int nrprocs; /* number of procs */
  69. struct rpc_procinfo * procs; /* procedure array */
  70. };
  71. /*
  72. * Procedure information
  73. */
  74. struct rpc_procinfo {
  75. u32 p_proc; /* RPC procedure number */
  76. kxdrproc_t p_encode; /* XDR encode function */
  77. kxdrproc_t p_decode; /* XDR decode function */
  78. unsigned int p_arglen; /* argument hdr length (u32) */
  79. unsigned int p_replen; /* reply hdr length (u32) */
  80. unsigned int p_count; /* call count */
  81. unsigned int p_timer; /* Which RTT timer to use */
  82. u32 p_statidx; /* Which procedure to account */
  83. char * p_name; /* name of procedure */
  84. };
  85. #ifdef __KERNEL__
  86. struct rpc_create_args {
  87. int protocol;
  88. struct sockaddr *address;
  89. size_t addrsize;
  90. struct rpc_timeout *timeout;
  91. char *servername;
  92. struct rpc_program *program;
  93. u32 version;
  94. rpc_authflavor_t authflavor;
  95. unsigned long flags;
  96. };
  97. /* Values for "flags" field */
  98. #define RPC_CLNT_CREATE_HARDRTRY (1UL << 0)
  99. #define RPC_CLNT_CREATE_INTR (1UL << 1)
  100. #define RPC_CLNT_CREATE_AUTOBIND (1UL << 2)
  101. #define RPC_CLNT_CREATE_ONESHOT (1UL << 3)
  102. #define RPC_CLNT_CREATE_NONPRIVPORT (1UL << 4)
  103. #define RPC_CLNT_CREATE_NOPING (1UL << 5)
  104. #define RPC_CLNT_CREATE_DISCRTRY (1UL << 6)
  105. struct rpc_clnt *rpc_create(struct rpc_create_args *args);
  106. struct rpc_clnt *rpc_bind_new_program(struct rpc_clnt *,
  107. struct rpc_program *, int);
  108. struct rpc_clnt *rpc_clone_client(struct rpc_clnt *);
  109. int rpc_shutdown_client(struct rpc_clnt *);
  110. int rpc_destroy_client(struct rpc_clnt *);
  111. void rpc_release_client(struct rpc_clnt *);
  112. void rpc_register_client(struct rpc_clnt *);
  113. void rpc_unregister_client(struct rpc_clnt *);
  114. int rpcb_register(u32, u32, int, unsigned short, int *);
  115. void rpcb_getport(struct rpc_task *);
  116. void rpc_call_setup(struct rpc_task *, struct rpc_message *, int);
  117. int rpc_call_async(struct rpc_clnt *clnt, struct rpc_message *msg,
  118. int flags, const struct rpc_call_ops *tk_ops,
  119. void *calldata);
  120. int rpc_call_sync(struct rpc_clnt *clnt, struct rpc_message *msg,
  121. int flags);
  122. void rpc_restart_call(struct rpc_task *);
  123. void rpc_clnt_sigmask(struct rpc_clnt *clnt, sigset_t *oldset);
  124. void rpc_clnt_sigunmask(struct rpc_clnt *clnt, sigset_t *oldset);
  125. void rpc_setbufsize(struct rpc_clnt *, unsigned int, unsigned int);
  126. size_t rpc_max_payload(struct rpc_clnt *);
  127. void rpc_force_rebind(struct rpc_clnt *);
  128. int rpc_ping(struct rpc_clnt *clnt, int flags);
  129. size_t rpc_peeraddr(struct rpc_clnt *, struct sockaddr *, size_t);
  130. char * rpc_peeraddr2str(struct rpc_clnt *, enum rpc_display_format_t);
  131. /*
  132. * Helper function for NFSroot support
  133. */
  134. int rpcb_getport_external(struct sockaddr_in *, __u32, __u32, int);
  135. #endif /* __KERNEL__ */
  136. #endif /* _LINUX_SUNRPC_CLNT_H */