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