xref: /linux/Documentation/sunrpc/xdr/nlm4.x (revision 0fc8f6200d2313278fbf4539bbab74677c685531)
1 /*
2  * This file was extracted by hand from
3  * https://www.rfc-editor.org/rfc/rfc1813.html .
4  *
5  * Note that RFC 1813 is Informational. Its official date of
6  * publication (June 1995) is before the IETF required its RFCs to
7  * carry an explicit copyright or other IP ownership notices.
8  *
9  * Note also that RFC 1813 does not specify the whole NLM4 protocol.
10  * In particular, the argument and result types are not present in
11  * that document, and had to be reverse-engineered.
12  */
13 
14 /*
15  * The NLMv4 protocol
16  */
17 
18 pragma header nlm4;
19 
20 /*
21  * The following definitions are missing in RFC 1813,
22  * but can be found in the OpenNetworking Network Lock
23  * Manager protocol:
24  *
25  * https://pubs.opengroup.org/onlinepubs/9629799/chap10.htm
26  */
27 
28 const LM_MAXSTRLEN = 1024;
29 
30 const LM_MAXNAMELEN = 1025;
31 
32 const MAXNETOBJ_SZ = 1024;
33 
34 typedef opaque netobj<MAXNETOBJ_SZ>;
35 
36 enum fsh4_mode {
37 	fsm_DN = 0,		/* deny none */
38 	fsm_DR = 1,		/* deny read */
39 	fsm_DW = 2,		/* deny write */
40 	fsm_DRW = 3		/* deny read/write */
41 };
42 
43 enum fsh4_access {
44 	fsa_NONE = 0,		/* for completeness */
45 	fsa_R = 1,		/* read-only */
46 	fsa_W = 2,		/* write-only */
47 	fsa_RW = 3		/* read/write */
48 };
49 
50 /*
51  * The following definitions come from the OpenNetworking
52  * Network Status Monitor protocol:
53  *
54  * https://pubs.opengroup.org/onlinepubs/9629799/chap11.htm
55  */
56 
57 const SM_MAXSTRLEN = 1024;
58 
59 /*
60  * The NLM protocol as extracted from:
61  * https://tools.ietf.org/html/rfc1813 Appendix II
62  */
63 
64 typedef unsigned hyper uint64;
65 
66 typedef hyper int64;
67 
68 typedef unsigned long uint32;
69 
70 typedef long int32;
71 
72 enum nlm4_stats {
73 	NLM4_GRANTED = 0,
74 	NLM4_DENIED = 1,
75 	NLM4_DENIED_NOLOCKS = 2,
76 	NLM4_BLOCKED = 3,
77 	NLM4_DENIED_GRACE_PERIOD = 4,
78 	NLM4_DEADLCK = 5,
79 	NLM4_ROFS = 6,
80 	NLM4_STALE_FH = 7,
81 	NLM4_FBIG = 8,
82 	NLM4_FAILED = 9
83 };
84 
85 pragma big_endian nlm4_stats;
86 
87 struct nlm4_holder {
88 	bool		exclusive;
89 	int32		svid;
90 	netobj		oh;
91 	uint64		l_offset;
92 	uint64		l_len;
93 };
94 
95 union nlm4_testrply switch (nlm4_stats stat) {
96 	case NLM4_DENIED:
97 		nlm4_holder	holder;
98 	default:
99 		void;
100 };
101 
102 struct nlm4_stat {
103 	nlm4_stats	stat;
104 };
105 
106 struct nlm4_res {
107 	netobj		cookie;
108 	nlm4_stat	stat;
109 };
110 
111 struct nlm4_testres {
112 	netobj		cookie;
113 	nlm4_testrply	stat;
114 };
115 
116 struct nlm4_lock {
117 	string		caller_name<LM_MAXSTRLEN>;
118 	netobj		fh;
119 	netobj		oh;
120 	int32		svid;
121 	uint64		l_offset;
122 	uint64		l_len;
123 };
124 
125 struct nlm4_lockargs {
126 	netobj		cookie;
127 	bool		block;
128 	bool		exclusive;
129 	nlm4_lock	alock;
130 	bool		reclaim;
131 	int32		state;
132 };
133 
134 struct nlm4_cancargs {
135 	netobj		cookie;
136 	bool		block;
137 	bool		exclusive;
138 	nlm4_lock	alock;
139 };
140 
141 struct nlm4_testargs {
142 	netobj		cookie;
143 	bool		exclusive;
144 	nlm4_lock	alock;
145 };
146 
147 struct nlm4_unlockargs {
148 	netobj		cookie;
149 	nlm4_lock	alock;
150 };
151 
152 struct nlm4_share {
153 	string		caller_name<LM_MAXSTRLEN>;
154 	netobj		fh;
155 	netobj		oh;
156 	fsh4_mode	mode;
157 	fsh4_access	access;
158 };
159 
160 struct nlm4_shareargs {
161 	netobj		cookie;
162 	nlm4_share	share;
163 	bool		reclaim;
164 };
165 
166 struct nlm4_shareres {
167 	netobj		cookie;
168 	nlm4_stats	stat;
169 	int32		sequence;
170 };
171 
172 struct nlm4_notify {
173 	string		name<LM_MAXNAMELEN>;
174 	int32		state;
175 };
176 
177 /*
178  * Argument for the Linux-private SM_NOTIFY procedure
179  */
180 const SM_PRIV_SIZE = 16;
181 
182 struct nlm4_notifyargs {
183 	nlm4_notify	notify;
184 	opaque		private[SM_PRIV_SIZE];
185 };
186 
187 program NLM4_PROG {
188 	version NLM4_VERS {
189 		void		NLMPROC4_NULL(void)			= 0;
190 		nlm4_testres	NLMPROC4_TEST(nlm4_testargs)		= 1;
191 		nlm4_res	NLMPROC4_LOCK(nlm4_lockargs)		= 2;
192 		nlm4_res	NLMPROC4_CANCEL(nlm4_cancargs)		= 3;
193 		nlm4_res	NLMPROC4_UNLOCK(nlm4_unlockargs)	= 4;
194 		nlm4_res	NLMPROC4_GRANTED(nlm4_testargs)		= 5;
195 		void		NLMPROC4_TEST_MSG(nlm4_testargs)	= 6;
196 		void		NLMPROC4_LOCK_MSG(nlm4_lockargs)	= 7;
197 		void		NLMPROC4_CANCEL_MSG(nlm4_cancargs)	= 8;
198 		void		NLMPROC4_UNLOCK_MSG(nlm4_unlockargs)	= 9;
199 		void		NLMPROC4_GRANTED_MSG(nlm4_testargs)	= 10;
200 		void		NLMPROC4_TEST_RES(nlm4_testres)		= 11;
201 		void		NLMPROC4_LOCK_RES(nlm4_res)		= 12;
202 		void		NLMPROC4_CANCEL_RES(nlm4_res)		= 13;
203 		void		NLMPROC4_UNLOCK_RES(nlm4_res)		= 14;
204 		void		NLMPROC4_GRANTED_RES(nlm4_res)		= 15;
205 		void		NLMPROC4_SM_NOTIFY(nlm4_notifyargs)	= 16;
206 		nlm4_shareres	NLMPROC4_SHARE(nlm4_shareargs)		= 20;
207 		nlm4_shareres	NLMPROC4_UNSHARE(nlm4_shareargs)	= 21;
208 		nlm4_res	NLMPROC4_NM_LOCK(nlm4_lockargs)		= 22;
209 		void		NLMPROC4_FREE_ALL(nlm4_notify)		= 23;
210 	} = 4;
211 } = 100021;
212