xdr.h 2.9 KB

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