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