Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
| 9 | #ifndef LOCKD_XDR_H |
| 10 | #define LOCKD_XDR_H |
| 11 | |
| 12 | #include <linux/fs.h> |
| 13 | #include <linux/nfs.h> |
| 14 | #include <linux/sunrpc/xdr.h> |
| 15 | |
NeilBrown | d343fce | 2006-10-17 00:10:18 -0700 | [diff] [blame] | 16 | struct svc_rqst; |
| 17 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | #define NLM_MAXCOOKIELEN 32 |
| 19 | #define NLM_MAXSTRLEN 1024 |
| 20 | |
| 21 | #define nlm_granted __constant_htonl(NLM_LCK_GRANTED) |
| 22 | #define nlm_lck_denied __constant_htonl(NLM_LCK_DENIED) |
| 23 | #define nlm_lck_denied_nolocks __constant_htonl(NLM_LCK_DENIED_NOLOCKS) |
| 24 | #define nlm_lck_blocked __constant_htonl(NLM_LCK_BLOCKED) |
| 25 | #define nlm_lck_denied_grace_period __constant_htonl(NLM_LCK_DENIED_GRACE_PERIOD) |
| 26 | |
NeilBrown | d343fce | 2006-10-17 00:10:18 -0700 | [diff] [blame] | 27 | #define nlm_drop_reply __constant_htonl(30000) |
| 28 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | /* Lock info passed via NLM */ |
| 30 | struct nlm_lock { |
| 31 | char * caller; |
| 32 | int len; /* length of "caller" */ |
| 33 | struct nfs_fh fh; |
| 34 | struct xdr_netobj oh; |
Trond Myklebust | 7bab377 | 2006-03-20 13:44:06 -0500 | [diff] [blame] | 35 | u32 svid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | struct file_lock fl; |
| 37 | }; |
| 38 | |
| 39 | /* |
| 40 | * NLM cookies. Technically they can be 1K, but Linux only uses 8 bytes. |
| 41 | * FreeBSD uses 16, Apple Mac OS X 10.3 uses 20. Therefore we set it to |
| 42 | * 32 bytes. |
| 43 | */ |
| 44 | |
| 45 | struct nlm_cookie |
| 46 | { |
| 47 | unsigned char data[NLM_MAXCOOKIELEN]; |
| 48 | unsigned int len; |
| 49 | }; |
| 50 | |
| 51 | /* |
| 52 | * Generic lockd arguments for all but sm_notify |
| 53 | */ |
| 54 | struct nlm_args { |
| 55 | struct nlm_cookie cookie; |
| 56 | struct nlm_lock lock; |
| 57 | u32 block; |
| 58 | u32 reclaim; |
| 59 | u32 state; |
| 60 | u32 monitor; |
| 61 | u32 fsm_access; |
| 62 | u32 fsm_mode; |
| 63 | }; |
| 64 | |
| 65 | typedef struct nlm_args nlm_args; |
| 66 | |
| 67 | /* |
| 68 | * Generic lockd result |
| 69 | */ |
| 70 | struct nlm_res { |
| 71 | struct nlm_cookie cookie; |
Al Viro | e8c5c04 | 2006-12-13 00:35:03 -0800 | [diff] [blame] | 72 | __be32 status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | struct nlm_lock lock; |
| 74 | }; |
| 75 | |
| 76 | /* |
| 77 | * statd callback when client has rebooted |
| 78 | */ |
| 79 | struct nlm_reboot { |
| 80 | char * mon; |
| 81 | int len; |
| 82 | u32 state; |
Al Viro | e8c5c04 | 2006-12-13 00:35:03 -0800 | [diff] [blame] | 83 | __be32 addr; |
| 84 | __be32 vers; |
| 85 | __be32 proto; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | }; |
| 87 | |
| 88 | /* |
| 89 | * Contents of statd callback when monitored host rebooted |
| 90 | */ |
| 91 | #define NLMSVC_XDRSIZE sizeof(struct nlm_args) |
| 92 | |
Al Viro | 52921e0 | 2006-10-19 23:28:46 -0700 | [diff] [blame] | 93 | int nlmsvc_decode_testargs(struct svc_rqst *, __be32 *, struct nlm_args *); |
| 94 | int nlmsvc_encode_testres(struct svc_rqst *, __be32 *, struct nlm_res *); |
| 95 | int nlmsvc_decode_lockargs(struct svc_rqst *, __be32 *, struct nlm_args *); |
| 96 | int nlmsvc_decode_cancargs(struct svc_rqst *, __be32 *, struct nlm_args *); |
| 97 | int nlmsvc_decode_unlockargs(struct svc_rqst *, __be32 *, struct nlm_args *); |
| 98 | int nlmsvc_encode_res(struct svc_rqst *, __be32 *, struct nlm_res *); |
| 99 | int nlmsvc_decode_res(struct svc_rqst *, __be32 *, struct nlm_res *); |
| 100 | int nlmsvc_encode_void(struct svc_rqst *, __be32 *, void *); |
| 101 | int nlmsvc_decode_void(struct svc_rqst *, __be32 *, void *); |
| 102 | int nlmsvc_decode_shareargs(struct svc_rqst *, __be32 *, struct nlm_args *); |
| 103 | int nlmsvc_encode_shareres(struct svc_rqst *, __be32 *, struct nlm_res *); |
| 104 | int nlmsvc_decode_notify(struct svc_rqst *, __be32 *, struct nlm_args *); |
| 105 | int nlmsvc_decode_reboot(struct svc_rqst *, __be32 *, struct nlm_reboot *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | /* |
| 107 | int nlmclt_encode_testargs(struct rpc_rqst *, u32 *, struct nlm_args *); |
| 108 | int nlmclt_encode_lockargs(struct rpc_rqst *, u32 *, struct nlm_args *); |
| 109 | int nlmclt_encode_cancargs(struct rpc_rqst *, u32 *, struct nlm_args *); |
| 110 | int nlmclt_encode_unlockargs(struct rpc_rqst *, u32 *, struct nlm_args *); |
| 111 | */ |
| 112 | |
| 113 | #endif /* LOCKD_XDR_H */ |