xdr.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * linux/include/linux/lockd/xdr.h
  3. *
  4. * XDR types for the NLM protocol
  5. *
  6. * Copyright (C) 1996 Olaf Kirch <okir@monad.swb.de>
  7. */
  8. #ifndef LOCKD_XDR_H
  9. #define LOCKD_XDR_H
  10. #include <linux/fs.h>
  11. #include <linux/nfs.h>
  12. #include <linux/sunrpc/xdr.h>
  13. struct svc_rqst;
  14. #define NLM_MAXCOOKIELEN 32
  15. #define NLM_MAXSTRLEN 1024
  16. #define nlm_granted __constant_htonl(NLM_LCK_GRANTED)
  17. #define nlm_lck_denied __constant_htonl(NLM_LCK_DENIED)
  18. #define nlm_lck_denied_nolocks __constant_htonl(NLM_LCK_DENIED_NOLOCKS)
  19. #define nlm_lck_blocked __constant_htonl(NLM_LCK_BLOCKED)
  20. #define nlm_lck_denied_grace_period __constant_htonl(NLM_LCK_DENIED_GRACE_PERIOD)
  21. #define nlm_drop_reply __constant_htonl(30000)
  22. /* Lock info passed via NLM */
  23. struct nlm_lock {
  24. char * caller;
  25. unsigned int len; /* length of "caller" */
  26. struct nfs_fh fh;
  27. struct xdr_netobj oh;
  28. u32 svid;
  29. struct file_lock fl;
  30. };
  31. /*
  32. * NLM cookies. Technically they can be 1K, but Linux only uses 8 bytes.
  33. * FreeBSD uses 16, Apple Mac OS X 10.3 uses 20. Therefore we set it to
  34. * 32 bytes.
  35. */
  36. struct nlm_cookie
  37. {
  38. unsigned char data[NLM_MAXCOOKIELEN];
  39. unsigned int len;
  40. };
  41. /*
  42. * Generic lockd arguments for all but sm_notify
  43. */
  44. struct nlm_args {
  45. struct nlm_cookie cookie;
  46. struct nlm_lock lock;
  47. u32 block;
  48. u32 reclaim;
  49. u32 state;
  50. u32 monitor;
  51. u32 fsm_access;
  52. u32 fsm_mode;
  53. };
  54. typedef struct nlm_args nlm_args;
  55. /*
  56. * Generic lockd result
  57. */
  58. struct nlm_res {
  59. struct nlm_cookie cookie;
  60. __be32 status;
  61. struct nlm_lock lock;
  62. };
  63. /*
  64. * statd callback when client has rebooted
  65. */
  66. struct nlm_reboot {
  67. char * mon;
  68. unsigned int len;
  69. u32 state;
  70. __be32 addr;
  71. __be32 vers;
  72. __be32 proto;
  73. };
  74. /*
  75. * Contents of statd callback when monitored host rebooted
  76. */
  77. #define NLMSVC_XDRSIZE sizeof(struct nlm_args)
  78. int nlmsvc_decode_testargs(struct svc_rqst *, __be32 *, struct nlm_args *);
  79. int nlmsvc_encode_testres(struct svc_rqst *, __be32 *, struct nlm_res *);
  80. int nlmsvc_decode_lockargs(struct svc_rqst *, __be32 *, struct nlm_args *);
  81. int nlmsvc_decode_cancargs(struct svc_rqst *, __be32 *, struct nlm_args *);
  82. int nlmsvc_decode_unlockargs(struct svc_rqst *, __be32 *, struct nlm_args *);
  83. int nlmsvc_encode_res(struct svc_rqst *, __be32 *, struct nlm_res *);
  84. int nlmsvc_decode_res(struct svc_rqst *, __be32 *, struct nlm_res *);
  85. int nlmsvc_encode_void(struct svc_rqst *, __be32 *, void *);
  86. int nlmsvc_decode_void(struct svc_rqst *, __be32 *, void *);
  87. int nlmsvc_decode_shareargs(struct svc_rqst *, __be32 *, struct nlm_args *);
  88. int nlmsvc_encode_shareres(struct svc_rqst *, __be32 *, struct nlm_res *);
  89. int nlmsvc_decode_notify(struct svc_rqst *, __be32 *, struct nlm_args *);
  90. int nlmsvc_decode_reboot(struct svc_rqst *, __be32 *, struct nlm_reboot *);
  91. /*
  92. int nlmclt_encode_testargs(struct rpc_rqst *, u32 *, struct nlm_args *);
  93. int nlmclt_encode_lockargs(struct rpc_rqst *, u32 *, struct nlm_args *);
  94. int nlmclt_encode_cancargs(struct rpc_rqst *, u32 *, struct nlm_args *);
  95. int nlmclt_encode_unlockargs(struct rpc_rqst *, u32 *, struct nlm_args *);
  96. */
  97. #endif /* LOCKD_XDR_H */