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