clnt.h 4.7 KB

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