blob: 6b51992638585296b68748ced6b1d26632aaa293 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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 Lever7e44d3b2008-12-05 19:03:16 -050016#define SM_PRIV_SIZE 16
17
18struct nsm_private {
19 unsigned char data[SM_PRIV_SIZE];
20};
21
NeilBrownd343fce2006-10-17 00:10:18 -070022struct svc_rqst;
23
Linus Torvalds1da177e2005-04-16 15:20:36 -070024#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
NeilBrownd343fce2006-10-17 00:10:18 -070033#define nlm_drop_reply __constant_htonl(30000)
34
Linus Torvalds1da177e2005-04-16 15:20:36 -070035/* Lock info passed via NLM */
36struct nlm_lock {
37 char * caller;
Chuck Lever48df0202007-11-01 16:56:53 -040038 unsigned int len; /* length of "caller" */
Linus Torvalds1da177e2005-04-16 15:20:36 -070039 struct nfs_fh fh;
40 struct xdr_netobj oh;
Trond Myklebust7bab3772006-03-20 13:44:06 -050041 u32 svid;
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 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
51struct 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 */
60struct 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
71typedef struct nlm_args nlm_args;
72
73/*
74 * Generic lockd result
75 */
76struct nlm_res {
77 struct nlm_cookie cookie;
Al Viroe8c5c042006-12-13 00:35:03 -080078 __be32 status;
Linus Torvalds1da177e2005-04-16 15:20:36 -070079 struct nlm_lock lock;
80};
81
82/*
83 * statd callback when client has rebooted
84 */
85struct nlm_reboot {
86 char * mon;
Chuck Lever48df0202007-11-01 16:56:53 -040087 unsigned int len;
Linus Torvalds1da177e2005-04-16 15:20:36 -070088 u32 state;
Al Viroe8c5c042006-12-13 00:35:03 -080089 __be32 addr;
Linus Torvalds1da177e2005-04-16 15:20:36 -070090};
91
92/*
93 * Contents of statd callback when monitored host rebooted
94 */
95#define NLMSVC_XDRSIZE sizeof(struct nlm_args)
96
Al Viro52921e02006-10-19 23:28:46 -070097int nlmsvc_decode_testargs(struct svc_rqst *, __be32 *, struct nlm_args *);
98int nlmsvc_encode_testres(struct svc_rqst *, __be32 *, struct nlm_res *);
99int nlmsvc_decode_lockargs(struct svc_rqst *, __be32 *, struct nlm_args *);
100int nlmsvc_decode_cancargs(struct svc_rqst *, __be32 *, struct nlm_args *);
101int nlmsvc_decode_unlockargs(struct svc_rqst *, __be32 *, struct nlm_args *);
102int nlmsvc_encode_res(struct svc_rqst *, __be32 *, struct nlm_res *);
103int nlmsvc_decode_res(struct svc_rqst *, __be32 *, struct nlm_res *);
104int nlmsvc_encode_void(struct svc_rqst *, __be32 *, void *);
105int nlmsvc_decode_void(struct svc_rqst *, __be32 *, void *);
106int nlmsvc_decode_shareargs(struct svc_rqst *, __be32 *, struct nlm_args *);
107int nlmsvc_encode_shareres(struct svc_rqst *, __be32 *, struct nlm_res *);
108int nlmsvc_decode_notify(struct svc_rqst *, __be32 *, struct nlm_args *);
109int nlmsvc_decode_reboot(struct svc_rqst *, __be32 *, struct nlm_reboot *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110/*
111int nlmclt_encode_testargs(struct rpc_rqst *, u32 *, struct nlm_args *);
112int nlmclt_encode_lockargs(struct rpc_rqst *, u32 *, struct nlm_args *);
113int nlmclt_encode_cancargs(struct rpc_rqst *, u32 *, struct nlm_args *);
114int nlmclt_encode_unlockargs(struct rpc_rqst *, u32 *, struct nlm_args *);
115 */
116
117#endif /* LOCKD_XDR_H */