xdr.h 2.9 KB

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