blob: d39ed1cc5fbf48648880825560d04d1ec1ebba44 [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 Levere6765b82008-12-11 17:56:14 -050016#define SM_MAXSTRLEN 1024
Chuck Lever7e44d3b2008-12-05 19:03:16 -050017#define SM_PRIV_SIZE 16
18
19struct nsm_private {
20 unsigned char data[SM_PRIV_SIZE];
21};
22
NeilBrownd343fce2006-10-17 00:10:18 -070023struct svc_rqst;
24
Linus Torvalds1da177e2005-04-16 15:20:36 -070025#define NLM_MAXCOOKIELEN 32
26#define NLM_MAXSTRLEN 1024
27
Harvey Harrison77f18f52009-02-11 17:16:58 -080028#define nlm_granted cpu_to_be32(NLM_LCK_GRANTED)
29#define nlm_lck_denied cpu_to_be32(NLM_LCK_DENIED)
30#define nlm_lck_denied_nolocks cpu_to_be32(NLM_LCK_DENIED_NOLOCKS)
31#define nlm_lck_blocked cpu_to_be32(NLM_LCK_BLOCKED)
32#define nlm_lck_denied_grace_period cpu_to_be32(NLM_LCK_DENIED_GRACE_PERIOD)
Linus Torvalds1da177e2005-04-16 15:20:36 -070033
Harvey Harrison77f18f52009-02-11 17:16:58 -080034#define nlm_drop_reply cpu_to_be32(30000)
NeilBrownd343fce2006-10-17 00:10:18 -070035
Linus Torvalds1da177e2005-04-16 15:20:36 -070036/* Lock info passed via NLM */
37struct nlm_lock {
38 char * caller;
Chuck Lever48df0202007-11-01 16:56:53 -040039 unsigned int len; /* length of "caller" */
Linus Torvalds1da177e2005-04-16 15:20:36 -070040 struct nfs_fh fh;
41 struct xdr_netobj oh;
Trond Myklebust7bab3772006-03-20 13:44:06 -050042 u32 svid;
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 struct file_lock fl;
44};
45
46/*
47 * NLM cookies. Technically they can be 1K, but Linux only uses 8 bytes.
48 * FreeBSD uses 16, Apple Mac OS X 10.3 uses 20. Therefore we set it to
49 * 32 bytes.
50 */
51
52struct nlm_cookie
53{
54 unsigned char data[NLM_MAXCOOKIELEN];
55 unsigned int len;
56};
57
58/*
59 * Generic lockd arguments for all but sm_notify
60 */
61struct nlm_args {
62 struct nlm_cookie cookie;
63 struct nlm_lock lock;
64 u32 block;
65 u32 reclaim;
66 u32 state;
67 u32 monitor;
68 u32 fsm_access;
69 u32 fsm_mode;
70};
71
72typedef struct nlm_args nlm_args;
73
74/*
75 * Generic lockd result
76 */
77struct nlm_res {
78 struct nlm_cookie cookie;
Al Viroe8c5c042006-12-13 00:35:03 -080079 __be32 status;
Linus Torvalds1da177e2005-04-16 15:20:36 -070080 struct nlm_lock lock;
81};
82
83/*
84 * statd callback when client has rebooted
85 */
86struct nlm_reboot {
Chuck Lever576df462008-12-05 19:03:39 -050087 char *mon;
88 unsigned int len;
89 u32 state;
90 struct nsm_private priv;
Linus Torvalds1da177e2005-04-16 15:20:36 -070091};
92
93/*
94 * Contents of statd callback when monitored host rebooted
95 */
96#define NLMSVC_XDRSIZE sizeof(struct nlm_args)
97
Al Viro52921e02006-10-19 23:28:46 -070098int nlmsvc_decode_testargs(struct svc_rqst *, __be32 *, struct nlm_args *);
99int nlmsvc_encode_testres(struct svc_rqst *, __be32 *, struct nlm_res *);
100int nlmsvc_decode_lockargs(struct svc_rqst *, __be32 *, struct nlm_args *);
101int nlmsvc_decode_cancargs(struct svc_rqst *, __be32 *, struct nlm_args *);
102int nlmsvc_decode_unlockargs(struct svc_rqst *, __be32 *, struct nlm_args *);
103int nlmsvc_encode_res(struct svc_rqst *, __be32 *, struct nlm_res *);
104int nlmsvc_decode_res(struct svc_rqst *, __be32 *, struct nlm_res *);
105int nlmsvc_encode_void(struct svc_rqst *, __be32 *, void *);
106int nlmsvc_decode_void(struct svc_rqst *, __be32 *, void *);
107int nlmsvc_decode_shareargs(struct svc_rqst *, __be32 *, struct nlm_args *);
108int nlmsvc_encode_shareres(struct svc_rqst *, __be32 *, struct nlm_res *);
109int nlmsvc_decode_notify(struct svc_rqst *, __be32 *, struct nlm_args *);
110int nlmsvc_decode_reboot(struct svc_rqst *, __be32 *, struct nlm_reboot *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111/*
112int nlmclt_encode_testargs(struct rpc_rqst *, u32 *, struct nlm_args *);
113int nlmclt_encode_lockargs(struct rpc_rqst *, u32 *, struct nlm_args *);
114int nlmclt_encode_cancargs(struct rpc_rqst *, u32 *, struct nlm_args *);
115int nlmclt_encode_unlockargs(struct rpc_rqst *, u32 *, struct nlm_args *);
116 */
117
118#endif /* LOCKD_XDR_H */