blob: 83a1f9f6237b5f539f52cda2b6b09eeb013dd97c [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
NeilBrownd343fce2006-10-17 00:10:18 -070016struct svc_rqst;
17
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#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
NeilBrownd343fce2006-10-17 00:10:18 -070027#define nlm_drop_reply __constant_htonl(30000)
28
Linus Torvalds1da177e2005-04-16 15:20:36 -070029/* Lock info passed via NLM */
30struct nlm_lock {
31 char * caller;
32 int len; /* length of "caller" */
33 struct nfs_fh fh;
34 struct xdr_netobj oh;
Trond Myklebust7bab3772006-03-20 13:44:06 -050035 u32 svid;
Linus Torvalds1da177e2005-04-16 15:20:36 -070036 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
45struct 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 */
54struct 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
65typedef struct nlm_args nlm_args;
66
67/*
68 * Generic lockd result
69 */
70struct nlm_res {
71 struct nlm_cookie cookie;
Al Viroe8c5c042006-12-13 00:35:03 -080072 __be32 status;
Linus Torvalds1da177e2005-04-16 15:20:36 -070073 struct nlm_lock lock;
74};
75
76/*
77 * statd callback when client has rebooted
78 */
79struct nlm_reboot {
80 char * mon;
81 int len;
82 u32 state;
Al Viroe8c5c042006-12-13 00:35:03 -080083 __be32 addr;
84 __be32 vers;
85 __be32 proto;
Linus Torvalds1da177e2005-04-16 15:20:36 -070086};
87
88/*
89 * Contents of statd callback when monitored host rebooted
90 */
91#define NLMSVC_XDRSIZE sizeof(struct nlm_args)
92
Al Viro52921e02006-10-19 23:28:46 -070093int nlmsvc_decode_testargs(struct svc_rqst *, __be32 *, struct nlm_args *);
94int nlmsvc_encode_testres(struct svc_rqst *, __be32 *, struct nlm_res *);
95int nlmsvc_decode_lockargs(struct svc_rqst *, __be32 *, struct nlm_args *);
96int nlmsvc_decode_cancargs(struct svc_rqst *, __be32 *, struct nlm_args *);
97int nlmsvc_decode_unlockargs(struct svc_rqst *, __be32 *, struct nlm_args *);
98int nlmsvc_encode_res(struct svc_rqst *, __be32 *, struct nlm_res *);
99int nlmsvc_decode_res(struct svc_rqst *, __be32 *, struct nlm_res *);
100int nlmsvc_encode_void(struct svc_rqst *, __be32 *, void *);
101int nlmsvc_decode_void(struct svc_rqst *, __be32 *, void *);
102int nlmsvc_decode_shareargs(struct svc_rqst *, __be32 *, struct nlm_args *);
103int nlmsvc_encode_shareres(struct svc_rqst *, __be32 *, struct nlm_res *);
104int nlmsvc_decode_notify(struct svc_rqst *, __be32 *, struct nlm_args *);
105int nlmsvc_decode_reboot(struct svc_rqst *, __be32 *, struct nlm_reboot *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106/*
107int nlmclt_encode_testargs(struct rpc_rqst *, u32 *, struct nlm_args *);
108int nlmclt_encode_lockargs(struct rpc_rqst *, u32 *, struct nlm_args *);
109int nlmclt_encode_cancargs(struct rpc_rqst *, u32 *, struct nlm_args *);
110int nlmclt_encode_unlockargs(struct rpc_rqst *, u32 *, struct nlm_args *);
111 */
112
113#endif /* LOCKD_XDR_H */