xref: /freebsd/include/rpcsvc/nlm_prot.x (revision 603c86672ce346f0fde026a4bd1cee3d782f5634)
1 /*
2  * Network lock manager protocol definition
3  * Copyright (C) 1986 Sun Microsystems, Inc.
4  *
5  * protocol used between local lock manager and remote lock manager
6  */
7 
8 #ifdef RPC_HDR
9 %#define LM_MAXSTRLEN	1024
10 %#define MAXNAMELEN	LM_MAXSTRLEN+1
11 #else
12 %#include <sys/cdefs.h>
13 %#ifndef lint
14 %static const char rcsid[] =
15 %  "$FreeBSD$";
16 %/*static char sccsid[] = "from: @(#)nlm_prot.x 1.8 87/09/21 Copyr 1987 Sun Micro";*/
17 %/*static char sccsid[] = "from: * @(#)nlm_prot.x	2.1 88/08/01 4.0 RPCSRC";*/
18 %__RCSID("$NetBSD: nlm_prot.x,v 1.6 2000/06/07 14:30:15 bouyer Exp $");
19 %#endif /* not lint */
20 #endif
21 
22 /*
23  * status of a call to the lock manager
24  */
25 enum nlm_stats {
26 	nlm_granted = 0,
27 	nlm_denied = 1,
28 	nlm_denied_nolocks = 2,
29 	nlm_blocked = 3,
30 	nlm_denied_grace_period = 4,
31 	nlm_deadlck = 5
32 };
33 
34 struct nlm_holder {
35 	bool exclusive;
36 	int svid;
37 	netobj oh;
38 	unsigned l_offset;
39 	unsigned l_len;
40 };
41 
42 union nlm_testrply switch (nlm_stats stat) {
43 	case nlm_denied:
44 		struct nlm_holder holder;
45 	default:
46 		void;
47 };
48 
49 struct nlm_stat {
50 	nlm_stats stat;
51 };
52 
53 struct nlm_res {
54 	netobj cookie;
55 	nlm_stat stat;
56 };
57 
58 struct nlm_testres {
59 	netobj cookie;
60 	nlm_testrply stat;
61 };
62 
63 struct nlm_lock {
64 	string caller_name<LM_MAXSTRLEN>;
65 	netobj fh;		/* identify a file */
66 	netobj oh;		/* identify owner of a lock */
67 	int svid;		/* generated from pid for svid */
68 	unsigned l_offset;
69 	unsigned l_len;
70 };
71 
72 struct nlm_lockargs {
73 	netobj cookie;
74 	bool block;
75 	bool exclusive;
76 	struct nlm_lock alock;
77 	bool reclaim;		/* used for recovering locks */
78 	int state;		/* specify local status monitor state */
79 };
80 
81 struct nlm_cancargs {
82 	netobj cookie;
83 	bool block;
84 	bool exclusive;
85 	struct nlm_lock alock;
86 };
87 
88 struct nlm_testargs {
89 	netobj cookie;
90 	bool exclusive;
91 	struct nlm_lock alock;
92 };
93 
94 struct nlm_unlockargs {
95 	netobj cookie;
96 	struct nlm_lock alock;
97 };
98 
99 
100 #ifdef RPC_HDR
101 %/*
102 % * The following enums are actually bit encoded for efficient
103 % * boolean algebra.... DON'T change them.....
104 % */
105 #endif
106 enum	fsh_mode {
107 	fsm_DN  = 0,	/* deny none */
108 	fsm_DR  = 1,	/* deny read */
109 	fsm_DW  = 2,	/* deny write */
110 	fsm_DRW = 3	/* deny read/write */
111 };
112 
113 enum	fsh_access {
114 	fsa_NONE = 0,	/* for completeness */
115 	fsa_R    = 1,	/* read only */
116 	fsa_W    = 2,	/* write only */
117 	fsa_RW   = 3	/* read/write */
118 };
119 
120 struct	nlm_share {
121 	string caller_name<LM_MAXSTRLEN>;
122 	netobj	fh;
123 	netobj	oh;
124 	fsh_mode	mode;
125 	fsh_access	access;
126 };
127 
128 struct	nlm_shareargs {
129 	netobj	cookie;
130 	nlm_share	share;
131 	bool	reclaim;
132 };
133 
134 struct	nlm_shareres {
135 	netobj	cookie;
136 	nlm_stats	stat;
137 	int	sequence;
138 };
139 
140 struct	nlm_notify {
141 	string name<MAXNAMELEN>;
142 	long state;
143 };
144 
145 #ifdef RPC_HDR
146 %/* definitions for NLM version 4 */
147 #endif
148 enum nlm4_stats {
149 	nlm4_granted			= 0,
150 	nlm4_denied			= 1,
151 	nlm4_denied_nolocks		= 2,
152 	nlm4_blocked			= 3,
153 	nlm4_denied_grace_period	= 4,
154 	nlm4_deadlck			= 5,
155 	nlm4_rofs			= 6,
156 	nlm4_stale_fh			= 7,
157 	nlm4_fbig			= 8,
158 	nlm4_failed			= 9
159 };
160 
161 struct nlm4_stat {
162 	nlm4_stats stat;
163 };
164 
165 struct nlm4_holder {
166 	bool exclusive;
167 	u_int32_t svid;
168 	netobj oh;
169 	u_int64_t l_offset;
170 	u_int64_t l_len;
171 };
172 
173 struct nlm4_lock {
174 	string caller_name<MAXNAMELEN>;
175 	netobj fh;
176 	netobj oh;
177 	u_int32_t svid;
178 	u_int64_t l_offset;
179 	u_int64_t l_len;
180 };
181 
182 struct nlm4_share {
183 	string caller_name<MAXNAMELEN>;
184 	netobj fh;
185 	netobj oh;
186 	fsh_mode mode;
187 	fsh_access access;
188 };
189 
190 union nlm4_testrply switch (nlm4_stats stat) {
191 	case nlm_denied:
192 		struct nlm4_holder holder;
193 	default:
194 		void;
195 };
196 
197 struct nlm4_testres {
198 	netobj cookie;
199 	nlm4_testrply stat;
200 };
201 
202 struct nlm4_testargs {
203 	netobj cookie;
204 	bool exclusive;
205 	struct nlm4_lock alock;
206 };
207 
208 struct nlm4_res {
209 	netobj cookie;
210 	nlm4_stat stat;
211 };
212 
213 struct nlm4_lockargs {
214 	netobj cookie;
215 	bool block;
216 	bool exclusive;
217 	struct nlm4_lock alock;
218 	bool reclaim;		/* used for recovering locks */
219 	int state;		/* specify local status monitor state */
220 };
221 
222 struct nlm4_cancargs {
223 	netobj cookie;
224 	bool block;
225 	bool exclusive;
226 	struct nlm4_lock alock;
227 };
228 
229 struct nlm4_unlockargs {
230 	netobj cookie;
231 	struct nlm4_lock alock;
232 };
233 
234 struct	nlm4_shareargs {
235 	netobj	cookie;
236 	nlm4_share	share;
237 	bool	reclaim;
238 };
239 
240 struct	nlm4_shareres {
241 	netobj	cookie;
242 	nlm4_stats	stat;
243 	int	sequence;
244 };
245 
246 /*
247  * argument for the procedure called by rpc.statd when a monitored host
248  * status change.
249  * XXX assumes LM_MAXSTRLEN == SM_MAXSTRLEN
250  */
251 struct nlm_sm_status {
252 	string mon_name<LM_MAXSTRLEN>; /* name of host */
253 	int state;			/* new state */
254 	opaque priv[16];		/* private data */
255 };
256 
257 struct	nlm4_notify {
258 	string name<MAXNAMELEN>;
259 	int32_t state;
260 };
261 
262 /*
263  * Over-the-wire protocol used between the network lock managers
264  */
265 
266 program NLM_PROG {
267 
268 	version NLM_SM {
269 		void NLM_SM_NOTIFY(struct nlm_sm_status) = 1;
270 	} = 0;
271 
272 	version NLM_VERS {
273 
274 		nlm_testres	NLM_TEST(struct nlm_testargs) =	1;
275 
276 		nlm_res		NLM_LOCK(struct nlm_lockargs) =	2;
277 
278 		nlm_res		NLM_CANCEL(struct nlm_cancargs) = 3;
279 		nlm_res		NLM_UNLOCK(struct nlm_unlockargs) =	4;
280 
281 		/*
282 		 * remote lock manager call-back to grant lock
283 		 */
284 		nlm_res		NLM_GRANTED(struct nlm_testargs)= 5;
285 		/*
286 		 * message passing style of requesting lock
287 		 */
288 		void		NLM_TEST_MSG(struct nlm_testargs) = 6;
289 		void		NLM_LOCK_MSG(struct nlm_lockargs) = 7;
290 		void		NLM_CANCEL_MSG(struct nlm_cancargs) =8;
291 		void		NLM_UNLOCK_MSG(struct nlm_unlockargs) = 9;
292 		void		NLM_GRANTED_MSG(struct nlm_testargs) = 10;
293 		void		NLM_TEST_RES(nlm_testres) = 11;
294 		void		NLM_LOCK_RES(nlm_res) = 12;
295 		void		NLM_CANCEL_RES(nlm_res) = 13;
296 		void		NLM_UNLOCK_RES(nlm_res) = 14;
297 		void		NLM_GRANTED_RES(nlm_res) = 15;
298 	} = 1;
299 
300 	version NLM_VERSX {
301 		nlm_shareres	NLM_SHARE(nlm_shareargs) = 20;
302 		nlm_shareres	NLM_UNSHARE(nlm_shareargs) = 21;
303 		nlm_res		NLM_NM_LOCK(nlm_lockargs) = 22;
304 		void		NLM_FREE_ALL(nlm_notify) = 23;
305 	} = 3;
306 
307 	version NLM_VERS4 {
308 		nlm4_testres NLM4_TEST(nlm4_testargs) = 1;
309 		nlm4_res NLM4_LOCK(nlm4_lockargs) = 2;
310 		nlm4_res NLM4_CANCEL(nlm4_cancargs) = 3;
311 		nlm4_res NLM4_UNLOCK(nlm4_unlockargs) = 4;
312 		nlm4_res NLM4_GRANTED(nlm4_testargs) = 5;
313 		void NLM4_TEST_MSG(nlm4_testargs) = 6;
314 		void NLM4_LOCK_MSG(nlm4_lockargs) = 7;
315 		void NLM4_CANCEL_MSG(nlm4_cancargs) = 8;
316 		void NLM4_UNLOCK_MSG(nlm4_unlockargs) = 9;
317 		void NLM4_GRANTED_MSG(nlm4_testargs) = 10;
318 		void NLM4_TEST_RES(nlm4_testres) = 11;
319 		void NLM4_LOCK_RES(nlm4_res) = 12;
320 		void NLM4_CANCEL_RES(nlm4_res) = 13;
321 		void NLM4_UNLOCK_RES(nlm4_res) = 14;
322 		void NLM4_GRANTED_RES(nlm4_res) = 15;
323 		nlm4_shareres NLM4_SHARE(nlm4_shareargs) = 20;
324 		nlm4_shareres NLM4_UNSHARE(nlm4_shareargs) = 21;
325 		nlm4_res NLM4_NM_LOCK(nlm4_lockargs) = 22;
326 		void NLM4_FREE_ALL(nlm4_notify) = 23;
327 	} = 4;
328 } = 100021;
329