clnt.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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. /*
  19. * This defines an RPC port mapping
  20. */
  21. struct rpc_portmap {
  22. __u32 pm_prog;
  23. __u32 pm_vers;
  24. __u32 pm_prot;
  25. __u16 pm_port;
  26. unsigned char pm_binding : 1; /* doing a getport() */
  27. struct rpc_wait_queue pm_bindwait; /* waiting on getport() */
  28. };
  29. struct rpc_inode;
  30. /*
  31. * The high-level client handle
  32. */
  33. struct rpc_clnt {
  34. atomic_t cl_count; /* Number of clones */
  35. atomic_t cl_users; /* number of references */
  36. struct rpc_xprt * cl_xprt; /* transport */
  37. struct rpc_procinfo * cl_procinfo; /* procedure info */
  38. u32 cl_maxproc; /* max procedure number */
  39. char * cl_server; /* server machine name */
  40. char * cl_protname; /* protocol name */
  41. struct rpc_auth * cl_auth; /* authenticator */
  42. struct rpc_stat * cl_stats; /* statistics */
  43. unsigned int cl_softrtry : 1,/* soft timeouts */
  44. cl_intr : 1,/* interruptible */
  45. cl_autobind : 1,/* use getport() */
  46. cl_oneshot : 1,/* dispose after use */
  47. cl_dead : 1;/* abandoned */
  48. struct rpc_rtt * cl_rtt; /* RTO estimator data */
  49. struct rpc_portmap * cl_pmap; /* port mapping */
  50. int cl_nodelen; /* nodename length */
  51. char cl_nodename[UNX_MAXNODENAME];
  52. char cl_pathname[30];/* Path in rpc_pipe_fs */
  53. struct dentry * cl_dentry; /* inode */
  54. struct rpc_clnt * cl_parent; /* Points to parent of clones */
  55. struct rpc_rtt cl_rtt_default;
  56. struct rpc_portmap cl_pmap_default;
  57. char cl_inline_name[32];
  58. };
  59. #define cl_timeout cl_xprt->timeout
  60. #define cl_prog cl_pmap->pm_prog
  61. #define cl_vers cl_pmap->pm_vers
  62. #define cl_port cl_pmap->pm_port
  63. #define cl_prot cl_pmap->pm_prot
  64. /*
  65. * General RPC program info
  66. */
  67. #define RPC_MAXVERSION 4
  68. struct rpc_program {
  69. char * name; /* protocol name */
  70. u32 number; /* program number */
  71. unsigned int nrvers; /* number of versions */
  72. struct rpc_version ** version; /* version array */
  73. struct rpc_stat * stats; /* statistics */
  74. char * pipe_dir_name; /* path to rpc_pipefs dir */
  75. };
  76. struct rpc_version {
  77. u32 number; /* version number */
  78. unsigned int nrprocs; /* number of procs */
  79. struct rpc_procinfo * procs; /* procedure array */
  80. };
  81. /*
  82. * Procedure information
  83. */
  84. struct rpc_procinfo {
  85. u32 p_proc; /* RPC procedure number */
  86. kxdrproc_t p_encode; /* XDR encode function */
  87. kxdrproc_t p_decode; /* XDR decode function */
  88. unsigned int p_bufsiz; /* req. buffer size */
  89. unsigned int p_count; /* call count */
  90. unsigned int p_timer; /* Which RTT timer to use */
  91. };
  92. #define RPC_CONGESTED(clnt) (RPCXPRT_CONGESTED((clnt)->cl_xprt))
  93. #define RPC_PEERADDR(clnt) (&(clnt)->cl_xprt->addr)
  94. #ifdef __KERNEL__
  95. struct rpc_clnt *rpc_create_client(struct rpc_xprt *xprt, char *servname,
  96. struct rpc_program *info,
  97. u32 version, rpc_authflavor_t authflavor);
  98. struct rpc_clnt *rpc_new_client(struct rpc_xprt *xprt, char *servname,
  99. struct rpc_program *info,
  100. u32 version, rpc_authflavor_t authflavor);
  101. struct rpc_clnt *rpc_bind_new_program(struct rpc_clnt *,
  102. struct rpc_program *, int);
  103. struct rpc_clnt *rpc_clone_client(struct rpc_clnt *);
  104. int rpc_shutdown_client(struct rpc_clnt *);
  105. int rpc_destroy_client(struct rpc_clnt *);
  106. void rpc_release_client(struct rpc_clnt *);
  107. void rpc_getport(struct rpc_task *, struct rpc_clnt *);
  108. int rpc_register(u32, u32, int, unsigned short, int *);
  109. void rpc_call_setup(struct rpc_task *, struct rpc_message *, int);
  110. int rpc_call_async(struct rpc_clnt *clnt, struct rpc_message *msg,
  111. int flags, const struct rpc_call_ops *tk_ops,
  112. void *calldata);
  113. int rpc_call_sync(struct rpc_clnt *clnt, struct rpc_message *msg,
  114. int flags);
  115. void rpc_restart_call(struct rpc_task *);
  116. void rpc_clnt_sigmask(struct rpc_clnt *clnt, sigset_t *oldset);
  117. void rpc_clnt_sigunmask(struct rpc_clnt *clnt, sigset_t *oldset);
  118. void rpc_setbufsize(struct rpc_clnt *, unsigned int, unsigned int);
  119. size_t rpc_max_payload(struct rpc_clnt *);
  120. void rpc_force_rebind(struct rpc_clnt *);
  121. int rpc_ping(struct rpc_clnt *clnt, int flags);
  122. static __inline__
  123. int rpc_call(struct rpc_clnt *clnt, u32 proc, void *argp, void *resp, int flags)
  124. {
  125. struct rpc_message msg = {
  126. .rpc_proc = &clnt->cl_procinfo[proc],
  127. .rpc_argp = argp,
  128. .rpc_resp = resp,
  129. .rpc_cred = NULL
  130. };
  131. return rpc_call_sync(clnt, &msg, flags);
  132. }
  133. extern void rpciod_wake_up(void);
  134. /*
  135. * Helper function for NFSroot support
  136. */
  137. int rpc_getport_external(struct sockaddr_in *, __u32, __u32, int);
  138. #endif /* __KERNEL__ */
  139. #endif /* _LINUX_SUNRPC_CLNT_H */