clnt.h
上传用户:lgb322
上传日期:2013-02-24
资源大小:30529k
文件大小:4k
源码类别:

嵌入式Linux

开发平台:

Unix_Linux

  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. /*
  17.  * This defines an RPC port mapping
  18.  */
  19. struct rpc_portmap {
  20. __u32 pm_prog;
  21. __u32 pm_vers;
  22. __u32 pm_prot;
  23. __u16 pm_port;
  24. };
  25. /*
  26.  * The high-level client handle
  27.  */
  28. struct rpc_clnt {
  29. atomic_t cl_users; /* number of references */
  30. struct rpc_xprt * cl_xprt; /* transport */
  31. struct rpc_procinfo * cl_procinfo; /* procedure info */
  32. u32 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; /* statistics */
  37. unsigned int cl_softrtry : 1,/* soft timeouts */
  38. cl_intr     : 1,/* interruptible */
  39. cl_chatty   : 1,/* be verbose */
  40. cl_autobind : 1,/* use getport() */
  41. cl_binding  : 1,/* doing a getport() */
  42. cl_droppriv : 1,/* enable NFS suid hack */
  43. cl_oneshot  : 1,/* dispose after use */
  44. cl_dead     : 1;/* abandoned */
  45. unsigned int cl_flags; /* misc client flags */
  46. unsigned long cl_hardmax; /* max hard timeout */
  47. struct rpc_portmap cl_pmap; /* port mapping */
  48. struct rpc_wait_queue cl_bindwait; /* waiting on getport() */
  49. int cl_nodelen; /* nodename length */
  50. char  cl_nodename[UNX_MAXNODENAME];
  51. };
  52. #define cl_timeout cl_xprt->timeout
  53. #define cl_prog cl_pmap.pm_prog
  54. #define cl_vers cl_pmap.pm_vers
  55. #define cl_port cl_pmap.pm_port
  56. #define cl_prot cl_pmap.pm_prot
  57. /*
  58.  * General RPC program info
  59.  */
  60. #define RPC_MAXVERSION 4
  61. struct rpc_program {
  62. char * name; /* protocol name */
  63. u32 number; /* program number */
  64. unsigned int nrvers; /* number of versions */
  65. struct rpc_version ** version; /* version array */
  66. struct rpc_stat * stats; /* statistics */
  67. };
  68. struct rpc_version {
  69. u32 number; /* version number */
  70. unsigned int nrprocs; /* number of procs */
  71. struct rpc_procinfo * procs; /* procedure array */
  72. };
  73. /*
  74.  * Procedure information
  75.  */
  76. struct rpc_procinfo {
  77. char * p_procname; /* procedure name */
  78. kxdrproc_t p_encode; /* XDR encode function */
  79. kxdrproc_t p_decode; /* XDR decode function */
  80. unsigned int p_bufsiz; /* req. buffer size */
  81. unsigned int p_count; /* call count */
  82. };
  83. #define rpcproc_bufsiz(clnt, proc) ((clnt)->cl_procinfo[proc].p_bufsiz)
  84. #define rpcproc_encode(clnt, proc) ((clnt)->cl_procinfo[proc].p_encode)
  85. #define rpcproc_decode(clnt, proc) ((clnt)->cl_procinfo[proc].p_decode)
  86. #define rpcproc_name(clnt, proc) ((clnt)->cl_procinfo[proc].p_procname)
  87. #define rpcproc_count(clnt, proc) ((clnt)->cl_procinfo[proc].p_count)
  88. #define RPC_CONGESTED(clnt) (RPCXPRT_CONGESTED((clnt)->cl_xprt))
  89. #define RPC_PEERADDR(clnt) (&(clnt)->cl_xprt->addr)
  90. #ifdef __KERNEL__
  91. struct rpc_clnt *rpc_create_client(struct rpc_xprt *xprt, char *servname,
  92. struct rpc_program *info,
  93. u32 version, int authflavor);
  94. int rpc_shutdown_client(struct rpc_clnt *);
  95. int rpc_destroy_client(struct rpc_clnt *);
  96. void rpc_release_client(struct rpc_clnt *);
  97. void rpc_getport(struct rpc_task *, struct rpc_clnt *);
  98. int rpc_register(u32, u32, int, unsigned short, int *);
  99. void rpc_call_setup(struct rpc_task *, struct rpc_message *, int);
  100. int rpc_call_async(struct rpc_clnt *clnt, struct rpc_message *msg,
  101.        int flags, rpc_action callback, void *clntdata);
  102. int rpc_call_sync(struct rpc_clnt *clnt, struct rpc_message *msg,
  103.       int flags);
  104. void rpc_restart_call(struct rpc_task *);
  105. void rpc_clnt_sigmask(struct rpc_clnt *clnt, sigset_t *oldset);
  106. void rpc_clnt_sigunmask(struct rpc_clnt *clnt, sigset_t *oldset);
  107. static __inline__
  108. int rpc_call(struct rpc_clnt *clnt, u32 proc, void *argp, void *resp, int flags)
  109. {
  110. struct rpc_message msg = { proc, argp, resp, NULL };
  111. return rpc_call_sync(clnt, &msg, flags);
  112. }
  113. static __inline__ void
  114. rpc_set_timeout(struct rpc_clnt *clnt, unsigned int retr, unsigned long incr)
  115. {
  116. xprt_set_timeout(&clnt->cl_timeout, retr, incr);
  117. }
  118. extern void rpciod_wake_up(void);
  119. /*
  120.  * Helper function for NFSroot support
  121.  */
  122. int rpc_getport_external(struct sockaddr_in *, __u32, __u32, int);
  123. #endif /* __KERNEL__ */
  124. #endif /* _LINUX_SUNRPC_CLNT_H */