clnt.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. struct list_head cl_clients; /* Global list of clients */
  25. struct list_head cl_tasks; /* List of tasks */
  26. spinlock_t cl_lock; /* spinlock */
  27. struct rpc_xprt * cl_xprt; /* transport */
  28. struct rpc_procinfo * cl_procinfo; /* procedure info */
  29. u32 cl_prog, /* RPC program number */
  30. cl_vers, /* RPC version number */
  31. cl_maxproc; /* max procedure number */
  32. char * cl_server; /* server machine name */
  33. char * cl_protname; /* protocol name */
  34. struct rpc_auth * cl_auth; /* authenticator */
  35. struct rpc_stat * cl_stats; /* per-program statistics */
  36. struct rpc_iostats * cl_metrics; /* per-client statistics */
  37. unsigned int cl_softrtry : 1,/* soft timeouts */
  38. cl_discrtry : 1,/* disconnect before retry */
  39. cl_autobind : 1;/* use getport() */
  40. struct rpc_rtt * cl_rtt; /* RTO estimator data */
  41. const struct rpc_timeout *cl_timeout; /* Timeout strategy */
  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_timeout cl_timeout_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 sockaddr *saddress;
  90. const 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_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 *, u32);
  106. struct rpc_clnt *rpc_clone_client(struct rpc_clnt *);
  107. void rpc_shutdown_client(struct rpc_clnt *);
  108. void rpc_release_client(struct rpc_clnt *);
  109. int rpcb_register(u32, u32, int, unsigned short, int *);
  110. int rpcb_getport_sync(struct sockaddr_in *, u32, u32, int);
  111. void rpcb_getport_async(struct rpc_task *);
  112. void rpc_call_start(struct rpc_task *);
  113. int rpc_call_async(struct rpc_clnt *clnt, struct rpc_message *msg,
  114. int flags, const struct rpc_call_ops *tk_ops,
  115. void *calldata);
  116. int rpc_call_sync(struct rpc_clnt *clnt, struct rpc_message *msg,
  117. int flags);
  118. struct rpc_task *rpc_call_null(struct rpc_clnt *clnt, struct rpc_cred *cred,
  119. int flags);
  120. void rpc_restart_call(struct rpc_task *);
  121. void rpc_setbufsize(struct rpc_clnt *, unsigned int, unsigned int);
  122. size_t rpc_max_payload(struct rpc_clnt *);
  123. void rpc_force_rebind(struct rpc_clnt *);
  124. size_t rpc_peeraddr(struct rpc_clnt *, struct sockaddr *, size_t);
  125. const char *rpc_peeraddr2str(struct rpc_clnt *, enum rpc_display_format_t);
  126. #endif /* __KERNEL__ */
  127. #endif /* _LINUX_SUNRPC_CLNT_H */