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