xref: /linux/fs/lockd/xdr.h (revision 0fc8f6200d2313278fbf4539bbab74677c685531)
1*615384a2SChuck Lever /* SPDX-License-Identifier: GPL-2.0 */
2*615384a2SChuck Lever /*
3*615384a2SChuck Lever  * XDR types for the NLM protocol
4*615384a2SChuck Lever  *
5*615384a2SChuck Lever  * Copyright (C) 1996 Olaf Kirch <okir@monad.swb.de>
6*615384a2SChuck Lever  */
7*615384a2SChuck Lever 
8*615384a2SChuck Lever #ifndef _LOCKD_XDR_H
9*615384a2SChuck Lever #define _LOCKD_XDR_H
10*615384a2SChuck Lever 
11*615384a2SChuck Lever #include <linux/fs.h>
12*615384a2SChuck Lever #include <linux/filelock.h>
13*615384a2SChuck Lever #include <linux/nfs.h>
14*615384a2SChuck Lever #include <linux/sunrpc/xdr.h>
15*615384a2SChuck Lever 
16*615384a2SChuck Lever #define SM_MAXSTRLEN		1024
17*615384a2SChuck Lever #define SM_PRIV_SIZE		16
18*615384a2SChuck Lever 
19*615384a2SChuck Lever struct nsm_private {
20*615384a2SChuck Lever 	unsigned char		data[SM_PRIV_SIZE];
21*615384a2SChuck Lever };
22*615384a2SChuck Lever 
23*615384a2SChuck Lever struct svc_rqst;
24*615384a2SChuck Lever 
25*615384a2SChuck Lever #define NLM_MAXCOOKIELEN    	32
26*615384a2SChuck Lever #define NLM_MAXSTRLEN		1024
27*615384a2SChuck Lever 
28*615384a2SChuck Lever #define	nlm_granted		cpu_to_be32(NLM_LCK_GRANTED)
29*615384a2SChuck Lever #define	nlm_lck_denied		cpu_to_be32(NLM_LCK_DENIED)
30*615384a2SChuck Lever #define	nlm_lck_denied_nolocks	cpu_to_be32(NLM_LCK_DENIED_NOLOCKS)
31*615384a2SChuck Lever #define	nlm_lck_blocked		cpu_to_be32(NLM_LCK_BLOCKED)
32*615384a2SChuck Lever #define	nlm_lck_denied_grace_period	cpu_to_be32(NLM_LCK_DENIED_GRACE_PERIOD)
33*615384a2SChuck Lever 
34*615384a2SChuck Lever /* Lock info passed via NLM */
35*615384a2SChuck Lever struct nlm_lock {
36*615384a2SChuck Lever 	char *			caller;
37*615384a2SChuck Lever 	unsigned int		len; 	/* length of "caller" */
38*615384a2SChuck Lever 	struct nfs_fh		fh;
39*615384a2SChuck Lever 	struct xdr_netobj	oh;
40*615384a2SChuck Lever 	u32			svid;
41*615384a2SChuck Lever 	u64			lock_start;
42*615384a2SChuck Lever 	u64			lock_len;
43*615384a2SChuck Lever 	struct file_lock	fl;
44*615384a2SChuck Lever };
45*615384a2SChuck Lever 
46*615384a2SChuck Lever /*
47*615384a2SChuck Lever  *	NLM cookies. Technically they can be 1K, but Linux only uses 8 bytes.
48*615384a2SChuck Lever  *	FreeBSD uses 16, Apple Mac OS X 10.3 uses 20. Therefore we set it to
49*615384a2SChuck Lever  *	32 bytes.
50*615384a2SChuck Lever  */
51*615384a2SChuck Lever 
52*615384a2SChuck Lever struct nlm_cookie
53*615384a2SChuck Lever {
54*615384a2SChuck Lever 	unsigned char data[NLM_MAXCOOKIELEN];
55*615384a2SChuck Lever 	unsigned int len;
56*615384a2SChuck Lever };
57*615384a2SChuck Lever 
58*615384a2SChuck Lever /*
59*615384a2SChuck Lever  * Generic lockd arguments for all but sm_notify
60*615384a2SChuck Lever  */
61*615384a2SChuck Lever struct nlm_args {
62*615384a2SChuck Lever 	struct nlm_cookie	cookie;
63*615384a2SChuck Lever 	struct nlm_lock		lock;
64*615384a2SChuck Lever 	u32			block;
65*615384a2SChuck Lever 	u32			reclaim;
66*615384a2SChuck Lever 	u32			state;
67*615384a2SChuck Lever 	u32			monitor;
68*615384a2SChuck Lever 	u32			fsm_access;
69*615384a2SChuck Lever 	u32			fsm_mode;
70*615384a2SChuck Lever };
71*615384a2SChuck Lever 
72*615384a2SChuck Lever /*
73*615384a2SChuck Lever  * Generic lockd result
74*615384a2SChuck Lever  */
75*615384a2SChuck Lever struct nlm_res {
76*615384a2SChuck Lever 	struct nlm_cookie	cookie;
77*615384a2SChuck Lever 	__be32			status;
78*615384a2SChuck Lever 	struct nlm_lock		lock;
79*615384a2SChuck Lever };
80*615384a2SChuck Lever 
81*615384a2SChuck Lever /*
82*615384a2SChuck Lever  * statd callback when client has rebooted
83*615384a2SChuck Lever  */
84*615384a2SChuck Lever struct nlm_reboot {
85*615384a2SChuck Lever 	char			*mon;
86*615384a2SChuck Lever 	unsigned int		len;
87*615384a2SChuck Lever 	u32			state;
88*615384a2SChuck Lever 	struct nsm_private	priv;
89*615384a2SChuck Lever };
90*615384a2SChuck Lever 
91*615384a2SChuck Lever bool	nlmsvc_decode_void(struct svc_rqst *rqstp, struct xdr_stream *xdr);
92*615384a2SChuck Lever bool	nlmsvc_decode_testargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
93*615384a2SChuck Lever bool	nlmsvc_decode_lockargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
94*615384a2SChuck Lever bool	nlmsvc_decode_cancargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
95*615384a2SChuck Lever bool	nlmsvc_decode_unlockargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
96*615384a2SChuck Lever bool	nlmsvc_decode_res(struct svc_rqst *rqstp, struct xdr_stream *xdr);
97*615384a2SChuck Lever bool	nlmsvc_decode_reboot(struct svc_rqst *rqstp, struct xdr_stream *xdr);
98*615384a2SChuck Lever bool	nlmsvc_decode_shareargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
99*615384a2SChuck Lever bool	nlmsvc_decode_notify(struct svc_rqst *rqstp, struct xdr_stream *xdr);
100*615384a2SChuck Lever 
101*615384a2SChuck Lever bool	nlmsvc_encode_testres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
102*615384a2SChuck Lever bool	nlmsvc_encode_res(struct svc_rqst *rqstp, struct xdr_stream *xdr);
103*615384a2SChuck Lever bool	nlmsvc_encode_void(struct svc_rqst *rqstp, struct xdr_stream *xdr);
104*615384a2SChuck Lever bool	nlmsvc_encode_shareres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
105*615384a2SChuck Lever 
106*615384a2SChuck Lever #endif /* _LOCKD_XDR_H */
107