Instead of saying the "manuf" file is in "/usr/local/etc/manuf", say
[obnox/wireshark/wip.git] / packet-nlm.c
1 /* packet-nlm.c
2  * Routines for nlm dissection
3  *
4  * $Id: packet-nlm.c,v 1.20 2001/09/14 06:48:30 guy Exp $
5  *
6  * Ethereal - Network traffic analyzer
7  * By Gerald Combs <gerald@ethereal.com>
8  * Copyright 1998 Gerald Combs
9  *
10  * Copied from packet-mount.c
11  *
12  * 2001-JAN  Ronnie Sahlberg <rsahlber@bigpond.net.au>
13  *  Updates to version 1 of the protocol.
14  *  Added version 3 of the protocol.
15  *  Added version 4 of the protocol.
16  *
17  *
18  * This program is free software; you can redistribute it and/or
19  * modify it under the terms of the GNU General Public License
20  * as published by the Free Software Foundation; either version 2
21  * of the License, or (at your option) any later version.
22  *
23  * This program is distributed in the hope that it will be useful,
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26  * GNU General Public License for more details.
27  *
28  * You should have received a copy of the GNU General Public License
29  * along with this program; if not, write to the Free Software
30  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
31  */
32
33
34 #ifdef HAVE_CONFIG_H
35 #include "config.h"
36 #endif
37
38
39 #ifdef HAVE_SYS_TYPES_H
40 #include <sys/types.h>
41 #endif
42
43
44 #include "packet-rpc.h"
45 #include "packet-nfs.h"
46 #include "packet-nlm.h"
47
48 /*
49  * NFS Lock Manager protocol specs can only be found in actual
50  * implementations or in the nice book:
51  * Brent Callaghan: "NFS Illustrated", Addison-Wesley, ISBN 0-201-32570-5
52  * which I use here as reference (BC).
53  *
54  * They can also be found if you go to
55  *
56  *      http://www.opengroup.org/publications/catalog/c702.htm
57  *
58  * and follow the links to the HTML version of the document.
59  */
60
61 static int proto_nlm = -1;
62
63 static int hf_nlm_cookie = -1;
64 static int hf_nlm_block = -1;
65 static int hf_nlm_exclusive = -1;
66 static int hf_nlm_lock = -1;
67 static int hf_nlm_lock_caller_name = -1;
68 static int hf_nlm_lock_owner = -1;
69 static int hf_nlm_lock_svid = -1;
70 static int hf_nlm_lock_l_offset = -1;
71 static int hf_nlm_lock_l_len = -1;
72 static int hf_nlm_reclaim = -1;
73 static int hf_nlm_stat = -1;
74 static int hf_nlm_state = -1;
75 static int hf_nlm_test_stat = -1;
76 static int hf_nlm_test_stat_stat = -1;
77 static int hf_nlm_holder = -1;
78 static int hf_nlm_share = -1;
79 static int hf_nlm_share_mode = -1;
80 static int hf_nlm_share_access = -1;
81 static int hf_nlm_share_name = -1;
82 static int hf_nlm_sequence = -1;
83
84 static gint ett_nlm = -1;
85 static gint ett_nlm_lock = -1;
86
87
88 const value_string names_nlm_stats[] =
89 {
90         /* NLM_GRANTED is the function number 5 and the state code 0.
91          * So we use for the state the postfix _S.
92          */
93 #define NLM_GRANTED_S           0
94                 {       NLM_GRANTED_S,  "NLM_GRANTED"   },
95 #define NLM_DENIED              1
96                 {       NLM_DENIED,     "NLM_DENIED"    },
97 #define NLM_DENIED_NOLOCKS      2
98                 {       NLM_DENIED_NOLOCKS,     "NLM_DENIED_NOLOCKS"    },
99 #define NLM_BLOCKED             3
100                 {       NLM_BLOCKED,    "NLM_BLOCKED"           },
101 #define NLM_DENIED_GRACE_PERIOD 4
102                 {       NLM_DENIED_GRACE_PERIOD,        "NLM_DENIED_GRACE_PERIOD"       },
103 #define NLM_DEADLCK             5
104                 {       NLM_DEADLCK,    "NLM_DEADLCK"   },
105 #define NLM_ROFS                6
106                 {       NLM_ROFS,       "NLM_ROFS"      },
107 #define NLM_STALE_FH            7
108                 {       NLM_STALE_FH,   "NLM_STALE_FH"  },
109 #define NLM_BIG                 8
110                 {       NLM_BIG,        "NLM_BIG"       },
111 #define NLM_FAILED              9
112                 {       NLM_FAILED,     "NLM_FAILED"    },
113                 {       0,              NULL            }
114 };
115
116
117 const value_string names_fsh_mode[] =
118 {
119 #define FSM_DN  0
120                 {       FSM_DN,         "deny none"     },
121 #define FSM_DR  1
122                 {       FSM_DR,         "deny read"     },
123 #define FSM_DW  2
124                 {       FSM_DW,         "deny write"    },
125 #define FSM_DRW 3
126                 {       FSM_DRW,        "deny read/write"       },
127
128                 {       0,              NULL    }
129 };
130
131
132 const value_string names_fsh_access[] =
133 {
134 #define FSA_NONE        0
135                 {       FSA_NONE,       "no access"     },
136 #define FSA_R   1
137                 {       FSA_R,          "read-only"     },
138 #define FSA_W   2
139                 {       FSA_W,          "write-only"    },
140 #define FSA_RW  3
141                 {       FSA_RW,         "read/write"    },
142                 {       0,              NULL    }
143 };
144
145
146
147
148
149
150 /* **************************** */
151 /* generic dissecting functions */
152 /* **************************** */
153 static int
154 dissect_lock(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int version, int offset)
155 {
156         proto_item* lock_item = NULL;
157         proto_tree* lock_tree = NULL;
158
159         if (tree) {
160                 lock_item = proto_tree_add_item(tree, hf_nlm_lock, tvb,
161                                 offset, tvb_length_remaining(tvb, offset), FALSE);
162                 if (lock_item)
163                         lock_tree = proto_item_add_subtree(lock_item, ett_nlm_lock);
164         }
165
166         offset = dissect_rpc_string(tvb,pinfo,lock_tree,
167                         hf_nlm_lock_caller_name, offset, NULL);
168         offset = dissect_nfs_fh3(tvb, offset, pinfo, lock_tree,"fh");
169
170         offset = dissect_rpc_data(tvb, pinfo, lock_tree, hf_nlm_lock_owner, offset);
171
172         offset = dissect_rpc_uint32(tvb, pinfo, lock_tree, hf_nlm_lock_svid, offset);
173
174         if (version == 4) {
175                 offset = dissect_rpc_uint64(tvb, pinfo, lock_tree, hf_nlm_lock_l_offset, offset);
176                 offset = dissect_rpc_uint64(tvb, pinfo, lock_tree, hf_nlm_lock_l_len, offset);
177         }
178         else {
179                 offset = dissect_rpc_uint32(tvb, pinfo, lock_tree, hf_nlm_lock_l_offset, offset);
180                 offset = dissect_rpc_uint32(tvb, pinfo, lock_tree, hf_nlm_lock_l_len, offset);
181         }
182
183         return offset;
184 }
185
186
187 static int
188 dissect_nlm_test(tvbuff_t *tvb, int offset, packet_info *pinfo,
189     proto_tree *tree, int version)
190 {
191         offset = dissect_rpc_data(tvb, pinfo, tree, hf_nlm_cookie, offset);
192         dissect_rpc_bool(tvb, pinfo, tree, hf_nlm_exclusive, offset);
193         offset += 4;
194         offset = dissect_lock(tvb, pinfo, tree, version, offset);
195         return offset;
196 }
197
198 static int
199 dissect_nlm_lock(tvbuff_t *tvb, int offset, packet_info *pinfo,
200     proto_tree *tree,int version)
201 {
202         offset = dissect_rpc_data(tvb, pinfo, tree, hf_nlm_cookie, offset);
203         offset = dissect_rpc_bool(tvb, pinfo, tree, hf_nlm_block, offset);
204         offset = dissect_rpc_bool(tvb, pinfo, tree, hf_nlm_exclusive, offset);
205         offset = dissect_lock(tvb, pinfo, tree, version, offset);
206         offset = dissect_rpc_bool(tvb, pinfo, tree, hf_nlm_reclaim, offset);
207         offset = dissect_rpc_uint32(tvb, pinfo, tree, hf_nlm_state, offset);
208         return offset;
209 }
210
211 static int
212 dissect_nlm_cancel(tvbuff_t *tvb, int offset, packet_info *pinfo,
213     proto_tree *tree,int version)
214 {
215         offset = dissect_rpc_data(tvb, pinfo, tree, hf_nlm_cookie, offset);
216         offset = dissect_rpc_bool(tvb, pinfo, tree, hf_nlm_block, offset);
217         offset = dissect_rpc_bool(tvb, pinfo, tree, hf_nlm_exclusive, offset);
218         offset = dissect_lock(tvb, pinfo, tree, version, offset);
219         return offset;
220 }
221
222 static int
223 dissect_nlm_unlock(tvbuff_t *tvb, int offset, packet_info *pinfo,
224     proto_tree *tree,int version)
225 {
226         offset = dissect_rpc_data(tvb, pinfo, tree, hf_nlm_cookie, offset);
227         offset = dissect_lock(tvb, pinfo, tree, version, offset);
228         return offset;
229 }
230
231 static int
232 dissect_nlm_granted(tvbuff_t *tvb, int offset, packet_info *pinfo,
233     proto_tree *tree,int version)
234 {
235         offset = dissect_rpc_data(tvb, pinfo, tree, hf_nlm_cookie, offset);
236         offset = dissect_rpc_bool(tvb, pinfo, tree, hf_nlm_exclusive, offset);
237         offset = dissect_lock(tvb, pinfo, tree, version, offset);
238         return offset;
239 }
240
241
242 static int
243 dissect_nlm_test_res(tvbuff_t *tvb, int offset, packet_info *pinfo,
244     proto_tree *tree,int version)
245 {
246         proto_item* lock_item = NULL;
247         proto_tree* lock_tree = NULL;
248
249         offset = dissect_rpc_data(tvb, pinfo, tree, hf_nlm_cookie, offset);
250
251         if (tree) {
252                 lock_item = proto_tree_add_item(tree, hf_nlm_test_stat, tvb,
253                                 offset, 
254                                 tvb_length_remaining(tvb, offset),
255                                 FALSE);
256                 if (lock_item)
257                         lock_tree = proto_item_add_subtree(lock_item, 
258                                 ett_nlm_lock);
259         }
260
261         offset = dissect_rpc_uint32(tvb, pinfo, lock_tree, hf_nlm_test_stat_stat,
262             offset);
263
264         /* last structure is optional, only supplied for stat==1 (LOCKED) */
265         if(!tvb_length_remaining(tvb, offset)){
266                 return offset;
267         }
268
269         if (tree) {
270                 lock_item = proto_tree_add_item(lock_tree, hf_nlm_holder, tvb,
271                                 offset, 
272                                 tvb_length_remaining(tvb, offset), 
273                                 FALSE);
274                 if (lock_item)
275                         lock_tree = proto_item_add_subtree(lock_item, 
276                                 ett_nlm_lock);
277         }
278
279         offset = dissect_rpc_bool(tvb, pinfo, lock_tree, hf_nlm_exclusive,
280             offset);
281         offset = dissect_rpc_uint32(tvb, pinfo, lock_tree, hf_nlm_lock_svid,
282             offset);
283         offset = dissect_rpc_data(tvb, pinfo, lock_tree, hf_nlm_lock_owner,
284             offset);
285
286         if (version == 4) {
287                 offset = dissect_rpc_uint64(tvb, pinfo, lock_tree,
288                     hf_nlm_lock_l_offset, offset);
289                 offset = dissect_rpc_uint64(tvb, pinfo, lock_tree,
290                     hf_nlm_lock_l_len, offset);
291         }
292         else {
293                 offset = dissect_rpc_uint32(tvb, pinfo, lock_tree,
294                     hf_nlm_lock_l_offset, offset);
295                 offset = dissect_rpc_uint32(tvb, pinfo, lock_tree,
296                     hf_nlm_lock_l_len, offset);
297         }
298
299         return offset;
300 }
301
302
303 static int
304 dissect_nlm_share(tvbuff_t *tvb, int offset, packet_info *pinfo,
305     proto_tree *tree,int version)
306 {
307         proto_item* lock_item = NULL;
308         proto_tree* lock_tree = NULL;
309
310         offset = dissect_rpc_data(tvb, pinfo, tree, hf_nlm_cookie, offset);
311
312         if (tree) {
313                 lock_item = proto_tree_add_item(tree, hf_nlm_share, tvb,
314                                 offset, 
315                                 tvb_length_remaining(tvb, offset), 
316                                 FALSE);
317                 if (lock_item)
318                         lock_tree = proto_item_add_subtree(lock_item, 
319                                 ett_nlm_lock);
320         }
321
322         offset = dissect_rpc_string(tvb,pinfo,lock_tree,
323                         hf_nlm_lock_caller_name, offset, NULL);
324         
325         offset = dissect_nfs_fh3(tvb, offset, pinfo, lock_tree, "fh");
326
327         offset = dissect_rpc_data(tvb, pinfo, lock_tree, hf_nlm_lock_owner, offset);
328
329         offset = dissect_rpc_uint32(tvb, pinfo, lock_tree, hf_nlm_share_mode, offset);
330         offset = dissect_rpc_uint32(tvb, pinfo, lock_tree, hf_nlm_share_access, offset);
331
332
333         offset = dissect_rpc_bool(tvb, pinfo, tree, hf_nlm_reclaim, offset);
334         return offset;
335 }
336
337 static int
338 dissect_nlm_shareres(tvbuff_t *tvb, int offset, packet_info *pinfo,
339     proto_tree *tree, int version)
340 {
341         offset = dissect_rpc_data(tvb, pinfo, tree, hf_nlm_cookie, offset);
342         offset = dissect_rpc_uint32(tvb, pinfo, tree, hf_nlm_stat, offset);
343         offset = dissect_rpc_uint32(tvb, pinfo, tree, hf_nlm_sequence, offset);
344         return offset;
345 }
346
347 static int
348 dissect_nlm_freeall(tvbuff_t *tvb, int offset, packet_info *pinfo,
349     proto_tree *tree,int version)
350 {
351         offset = dissect_rpc_string(tvb,pinfo,tree,
352                         hf_nlm_share_name, offset, NULL);
353
354         offset = dissect_rpc_uint32(tvb, pinfo, tree, hf_nlm_stat, offset);
355
356         return offset;
357 }
358
359
360 /* RPC functions */
361
362
363 /* This function is identical for all NLM protocol versions (1-4)*/
364 static int
365 dissect_nlm_gen_reply(tvbuff_t *tvb, int offset, packet_info *pinfo,
366     proto_tree *tree)
367 {
368         offset = dissect_rpc_data(tvb, pinfo, tree, hf_nlm_cookie, offset);
369         offset = dissect_rpc_uint32(tvb, pinfo, tree, hf_nlm_stat, offset);
370         return offset;
371 }
372
373 static int
374 dissect_nlm1_test(tvbuff_t *tvb, int offset, packet_info *pinfo,
375     proto_tree *tree)
376 {
377         return dissect_nlm_test(tvb,offset,pinfo,tree,1);
378 }
379
380 static int
381 dissect_nlm4_test(tvbuff_t *tvb, int offset, packet_info *pinfo,
382     proto_tree *tree)
383 {
384         return dissect_nlm_test(tvb,offset,pinfo,tree,4);
385 }
386
387
388 static int
389 dissect_nlm1_lock(tvbuff_t *tvb, int offset, packet_info *pinfo,
390     proto_tree *tree)
391 {
392         return dissect_nlm_lock(tvb,offset,pinfo,tree,1);
393 }
394
395 static int
396 dissect_nlm4_lock(tvbuff_t *tvb, int offset, packet_info *pinfo,
397     proto_tree *tree)
398 {
399         return dissect_nlm_lock(tvb,offset,pinfo,tree,4);
400 }
401
402
403 static int
404 dissect_nlm1_cancel(tvbuff_t *tvb, int offset, packet_info *pinfo,
405     proto_tree *tree)
406 {
407         return dissect_nlm_cancel(tvb,offset,pinfo,tree,1);
408 }
409
410 static int
411 dissect_nlm4_cancel(tvbuff_t *tvb, int offset, packet_info *pinfo,
412     proto_tree *tree)
413 {
414         return dissect_nlm_cancel(tvb,offset,pinfo,tree,4);
415 }
416
417
418 static int
419 dissect_nlm1_unlock(tvbuff_t *tvb, int offset, packet_info *pinfo,
420     proto_tree *tree)
421 {
422         return dissect_nlm_unlock(tvb,offset,pinfo,tree,1);
423 }
424
425 static int
426 dissect_nlm4_unlock(tvbuff_t *tvb, int offset, packet_info *pinfo,
427     proto_tree *tree)
428 {
429         return dissect_nlm_unlock(tvb,offset,pinfo,tree,4);
430 }
431
432
433 static int
434 dissect_nlm1_granted(tvbuff_t *tvb, int offset, packet_info *pinfo,
435     proto_tree *tree)
436 {
437         return dissect_nlm_granted(tvb,offset,pinfo,tree,1);
438 }
439
440 static int
441 dissect_nlm4_granted(tvbuff_t *tvb, int offset, packet_info *pinfo,
442     proto_tree *tree)
443 {
444         return dissect_nlm_granted(tvb,offset,pinfo,tree,4);
445 }
446
447
448 static int
449 dissect_nlm1_test_res(tvbuff_t *tvb, int offset, packet_info *pinfo,
450     proto_tree *tree)
451 {
452         return dissect_nlm_test_res(tvb,offset,pinfo,tree,1);
453 }
454
455 static int
456 dissect_nlm4_test_res(tvbuff_t *tvb, int offset, packet_info *pinfo,
457     proto_tree *tree)
458 {
459         return dissect_nlm_test_res(tvb,offset,pinfo,tree,4);
460 }
461
462 static int
463 dissect_nlm3_share(tvbuff_t *tvb, int offset, packet_info *pinfo,
464     proto_tree *tree)
465 {
466         return dissect_nlm_share(tvb,offset,pinfo,tree,3);
467 }
468
469 static int
470 dissect_nlm4_share(tvbuff_t *tvb, int offset, packet_info *pinfo,
471     proto_tree *tree)
472 {
473         return dissect_nlm_share(tvb,offset,pinfo,tree,4);
474 }
475
476 static int
477 dissect_nlm3_shareres(tvbuff_t *tvb, int offset, packet_info *pinfo,
478     proto_tree *tree)
479 {
480         return dissect_nlm_shareres(tvb,offset,pinfo,tree,3);
481 }
482
483 static int
484 dissect_nlm4_shareres(tvbuff_t *tvb, int offset, packet_info *pinfo,
485     proto_tree *tree)
486 {
487         return dissect_nlm_shareres(tvb,offset,pinfo,tree,4);
488 }
489
490 static int
491 dissect_nlm3_freeall(tvbuff_t *tvb, int offset, packet_info *pinfo,
492     proto_tree *tree)
493 {
494         return dissect_nlm_freeall(tvb,offset,pinfo,tree,3);
495 }
496
497 static int
498 dissect_nlm4_freeall(tvbuff_t *tvb, int offset, packet_info *pinfo,
499     proto_tree *tree)
500 {
501         return dissect_nlm_freeall(tvb,offset,pinfo,tree,4);
502 }
503
504
505
506
507 /* proc number, "proc name", dissect_request, dissect_reply */
508 /* NULL as function pointer means: type of arguments is "void". */
509 /* NLM protocol version 1 */
510 static const vsff nlm1_proc[] = {
511         { NLM_NULL,             "NULL",         
512                 NULL,                           NULL },
513         { NLM_TEST,             "TEST",
514                 dissect_nlm1_test,              dissect_nlm1_test_res },
515         { NLM_LOCK,             "LOCK", 
516                 dissect_nlm1_lock,              dissect_nlm_gen_reply },
517         { NLM_CANCEL,           "CANCEL",
518                 dissect_nlm1_cancel,            dissect_nlm_gen_reply },
519         { NLM_UNLOCK,           "UNLOCK",
520                 dissect_nlm1_unlock,            dissect_nlm_gen_reply },
521         { NLM_GRANTED,          "GRANTED",
522                 dissect_nlm1_granted,           dissect_nlm_gen_reply },
523         { NLM_TEST_MSG,         "TEST_MSG",
524                 dissect_nlm1_test,              NULL },
525         { NLM_LOCK_MSG,         "LOCK_MSG",
526                 dissect_nlm1_lock,              NULL },
527         { NLM_CANCEL_MSG,       "CANCEL_MSG",
528                 dissect_nlm1_cancel,            NULL },
529         { NLM_UNLOCK_MSG,       "UNLOCK_MSG",   
530                 dissect_nlm1_unlock,            NULL },
531         { NLM_GRANTED_MSG,      "GRANTED_MSG",
532                 dissect_nlm1_granted,           NULL },
533         { NLM_TEST_RES,         "TEST_RES",
534                 dissect_nlm1_test_res,          NULL },
535         { NLM_LOCK_RES,         "LOCK_RES",     
536                 dissect_nlm_gen_reply,          NULL },
537         { NLM_CANCEL_RES,       "CANCEL_RES",   
538                 dissect_nlm_gen_reply,          NULL },
539         { NLM_UNLOCK_RES,       "UNLOCK_RES",   
540                 dissect_nlm_gen_reply,          NULL },
541         { NLM_GRANTED_RES,      "GRANTED_RES",  
542                 dissect_nlm_gen_reply,          NULL },
543         { 0,                    NULL,
544                 NULL,                           NULL }
545 };
546 /* end of NLM protocol version 1 */
547
548 /* NLM protocol version 2 */
549 static const vsff nlm2_proc[] = {
550         { NLM_NULL,             "NULL",         
551                 NULL,                           NULL },
552         { NLM_TEST,             "TEST",
553                 dissect_nlm1_test,              dissect_nlm1_test_res },
554         { NLM_LOCK,             "LOCK", 
555                 dissect_nlm1_lock,              dissect_nlm_gen_reply },
556         { NLM_CANCEL,           "CANCEL",
557                 dissect_nlm1_cancel,            dissect_nlm_gen_reply },
558         { NLM_UNLOCK,           "UNLOCK",
559                 dissect_nlm1_unlock,            dissect_nlm_gen_reply },
560         { NLM_GRANTED,          "GRANTED",
561                 dissect_nlm1_granted,           dissect_nlm_gen_reply },
562         { NLM_TEST_MSG,         "TEST_MSG",
563                 dissect_nlm1_test,              NULL },
564         { NLM_LOCK_MSG,         "LOCK_MSG",
565                 dissect_nlm1_lock,              NULL },
566         { NLM_CANCEL_MSG,       "CANCEL_MSG",
567                 dissect_nlm1_cancel,            NULL },
568         { NLM_UNLOCK_MSG,       "UNLOCK_MSG",   
569                 dissect_nlm1_unlock,            NULL },
570         { NLM_GRANTED_MSG,      "GRANTED_MSG",
571                 dissect_nlm1_granted,           NULL },
572         { NLM_TEST_RES,         "TEST_RES",
573                 dissect_nlm1_test_res,          NULL },
574         { NLM_LOCK_RES,         "LOCK_RES",     
575                 dissect_nlm_gen_reply,          NULL },
576         { NLM_CANCEL_RES,       "CANCEL_RES",   
577                 dissect_nlm_gen_reply,          NULL },
578         { NLM_UNLOCK_RES,       "UNLOCK_RES",   
579                 dissect_nlm_gen_reply,          NULL },
580         { NLM_GRANTED_RES,      "GRANTED_RES",  
581                 dissect_nlm_gen_reply,          NULL },
582         { 0,                    NULL,
583                 NULL,                           NULL }
584 };
585 /* end of NLM protocol version 2 */
586
587 /* NLM protocol version 3 */
588 static const vsff nlm3_proc[] = {
589         { NLM_NULL,             "NULL",         
590                 NULL,                           NULL },
591         { NLM_TEST,             "TEST",
592                 dissect_nlm1_test,              dissect_nlm1_test_res },
593         { NLM_LOCK,             "LOCK", 
594                 dissect_nlm1_lock,              dissect_nlm_gen_reply },
595         { NLM_CANCEL,           "CANCEL",
596                 dissect_nlm1_cancel,            dissect_nlm_gen_reply },
597         { NLM_UNLOCK,           "UNLOCK",
598                 dissect_nlm1_unlock,            dissect_nlm_gen_reply },
599         { NLM_GRANTED,          "GRANTED",
600                 dissect_nlm1_granted,           dissect_nlm_gen_reply },
601         { NLM_TEST_MSG,         "TEST_MSG",
602                 dissect_nlm1_test,              NULL },
603         { NLM_LOCK_MSG,         "LOCK_MSG",
604                 dissect_nlm1_lock,              NULL },
605         { NLM_CANCEL_MSG,       "CANCEL_MSG",
606                 dissect_nlm1_cancel,            NULL },
607         { NLM_UNLOCK_MSG,       "UNLOCK_MSG",   
608                 dissect_nlm1_unlock,            NULL },
609         { NLM_GRANTED_MSG,      "GRANTED_MSG",
610                 dissect_nlm1_granted,           NULL },
611         { NLM_TEST_RES,         "TEST_RES",
612                 dissect_nlm1_test_res,          NULL },
613         { NLM_LOCK_RES,         "LOCK_RES",     
614                 dissect_nlm_gen_reply,          NULL },
615         { NLM_CANCEL_RES,       "CANCEL_RES",   
616                 dissect_nlm_gen_reply,          NULL },
617         { NLM_UNLOCK_RES,       "UNLOCK_RES",   
618                 dissect_nlm_gen_reply,          NULL },
619         { NLM_GRANTED_RES,      "GRANTED_RES",  
620                 dissect_nlm_gen_reply,          NULL },
621         { NLM_SHARE,            "SHARE",        
622                 dissect_nlm3_share,             dissect_nlm3_shareres },
623         { NLM_UNSHARE,          "UNSHARE",      
624                 dissect_nlm3_share,             dissect_nlm3_shareres },
625         { NLM_NM_LOCK,          "NM_LOCK",      
626                 dissect_nlm1_lock,              dissect_nlm_gen_reply },
627         { NLM_FREE_ALL,         "FREE_ALL",     
628                 dissect_nlm3_freeall,           NULL },
629         { 0,                    NULL,
630                 NULL,                           NULL }
631 };
632 /* end of NLM protocol version 3 */
633
634
635 /* NLM protocol version 4 */
636 static const vsff nlm4_proc[] = {
637         { NLM_NULL,             "NULL",         
638                 NULL,                           NULL },
639         { NLM_TEST,             "TEST",         
640                 dissect_nlm4_test,              dissect_nlm4_test_res },
641         { NLM_LOCK,             "LOCK",         
642                 dissect_nlm4_lock,              dissect_nlm_gen_reply },
643         { NLM_CANCEL,           "CANCEL",       
644                 dissect_nlm4_cancel,            dissect_nlm_gen_reply },
645         { NLM_UNLOCK,           "UNLOCK",       
646                 dissect_nlm4_unlock,            dissect_nlm_gen_reply },
647         { NLM_GRANTED,          "GRANTED",      
648                 dissect_nlm4_granted,           dissect_nlm_gen_reply },
649         { NLM_TEST_MSG,         "TEST_MSG",     
650                 dissect_nlm4_test,              NULL },
651         { NLM_LOCK_MSG,         "LOCK_MSG",     
652                 dissect_nlm4_lock,              NULL },
653         { NLM_CANCEL_MSG,       "CANCEL_MSG",   
654                 dissect_nlm4_cancel,            NULL },
655         { NLM_UNLOCK_MSG,       "UNLOCK_MSG",   
656                 dissect_nlm4_unlock,            NULL },
657         { NLM_GRANTED_MSG,      "GRANTED_MSG",  
658                 dissect_nlm4_granted,           NULL },
659         { NLM_TEST_RES,         "TEST_RES",
660                 dissect_nlm4_test_res,          NULL },
661         { NLM_LOCK_RES,         "LOCK_RES",     
662                 dissect_nlm_gen_reply,          NULL },
663         { NLM_CANCEL_RES,       "CANCEL_RES",   
664                 dissect_nlm_gen_reply,          NULL },
665         { NLM_UNLOCK_RES,       "UNLOCK_RES",   
666                 dissect_nlm_gen_reply,          NULL },
667         { NLM_GRANTED_RES,      "GRANTED_RES",  
668                 dissect_nlm_gen_reply,          NULL },
669         { NLM_SHARE,            "SHARE",
670                 dissect_nlm4_share,             dissect_nlm4_shareres },
671         { NLM_UNSHARE,          "UNSHARE",
672                 dissect_nlm4_share,             dissect_nlm4_shareres },
673         { NLM_NM_LOCK,          "NM_LOCK",      
674                 dissect_nlm4_lock,              dissect_nlm_gen_reply },
675         { NLM_FREE_ALL,         "FREE_ALL",
676                 dissect_nlm4_freeall,           NULL },
677         { 0,                    NULL,
678                 NULL,                           NULL }
679 };
680 /* end of NLM protocol version 4 */
681
682
683 static struct true_false_string yesno = { "Yes", "No" };
684
685
686 void
687 proto_register_nlm(void)
688 {
689         static hf_register_info hf[] = {
690                 { &hf_nlm_cookie, {
691                         "cookie", "nlm.cookie", FT_BYTES, BASE_DEC,
692                         NULL, 0, "cookie", HFILL }},
693                 { &hf_nlm_block, {
694                         "block", "nlm.block", FT_BOOLEAN, BASE_NONE,
695                         &yesno, 0, "block", HFILL }},
696                 { &hf_nlm_exclusive, {
697                         "exclusive", "nlm.exclusive", FT_BOOLEAN, BASE_NONE,
698                         &yesno, 0, "exclusive", HFILL }},
699                 { &hf_nlm_lock, {
700                         "lock", "nlm.lock", FT_NONE, 0,
701                         NULL, 0, "lock", HFILL }},
702                 { &hf_nlm_lock_caller_name, {
703                         "caller_name", "nlm.lock.caller_name", FT_STRING, BASE_NONE,
704                         NULL, 0, "caller_name", HFILL }},
705                 { &hf_nlm_lock_owner, {
706                         "owner", "nlm.lock.owner", FT_BYTES, BASE_DEC,
707                         NULL, 0, "owner", HFILL }},
708                 { &hf_nlm_lock_svid, {
709                         "svid", "nlm.lock.svid", FT_UINT32, BASE_DEC,
710                         NULL, 0, "svid", HFILL }},
711                 { &hf_nlm_lock_l_offset, {
712                         "l_offset", "nlm.lock.l_offset", FT_UINT32, BASE_DEC,
713                         NULL, 0, "l_offset", HFILL }},
714                 { &hf_nlm_lock_l_len, {
715                         "l_len", "nlm.lock.l_len", FT_UINT32, BASE_DEC,
716                         NULL, 0, "l_len", HFILL }},
717                 { &hf_nlm_reclaim, {
718                         "reclaim", "nlm.reclaim", FT_BOOLEAN, BASE_NONE,
719                         &yesno, 0, "reclaim", HFILL }},
720                 { &hf_nlm_state, {
721                         "state", "nlm.state", FT_UINT32, BASE_DEC,
722                         NULL, 0, "STATD state", HFILL }},
723                 { &hf_nlm_stat, {
724                         "stat", "nlm.stat", FT_UINT32, BASE_DEC,
725                         VALS(names_nlm_stats), 0, "stat", HFILL }},
726                 { &hf_nlm_test_stat, {
727                         "test_stat", "nlm.test_stat", FT_NONE, 0,
728                         NULL, 0, "test_stat", HFILL }},
729                 { &hf_nlm_test_stat_stat, {
730                         "stat", "nlm.test_stat.stat", FT_UINT32, BASE_DEC,
731                         VALS(names_nlm_stats), 0, "stat", HFILL }},
732                 { &hf_nlm_holder, {
733                         "holder", "nlm.holder", FT_NONE, 0,
734                         NULL, 0, "holder", HFILL }},
735                 { &hf_nlm_share, {
736                         "share", "nlm.share", FT_NONE, 0,
737                         NULL, 0, "share", HFILL }},
738                 { &hf_nlm_share_mode, {
739                         "mode", "nlm.share.mode", FT_UINT32, BASE_DEC,
740                         VALS(names_fsh_mode), 0, "mode", HFILL }},
741                 { &hf_nlm_share_access, {
742                         "access", "nlm.share.access", FT_UINT32, BASE_DEC,
743                         VALS(names_fsh_access), 0, "access", HFILL }},
744                 { &hf_nlm_share_name, {
745                         "name", "nlm.share.name", FT_STRING, BASE_NONE,
746                         NULL, 0, "name", HFILL }},
747                 { &hf_nlm_sequence, {
748                         "sequence", "nlm.sequence", FT_INT32, BASE_DEC,
749                         NULL, 0, "sequence", HFILL }},
750                 };
751
752         static gint *ett[] = {
753                 &ett_nlm,
754                 &ett_nlm_lock,
755         };
756
757         proto_nlm = proto_register_protocol("Network Lock Manager Protocol",
758             "NLM", "nlm");
759         proto_register_field_array(proto_nlm, hf, array_length(hf));
760         proto_register_subtree_array(ett, array_length(ett));
761 }
762
763 void
764 proto_reg_handoff_nlm(void)
765 {
766         /* Register the protocol as RPC */
767         rpc_init_prog(proto_nlm, NLM_PROGRAM, ett_nlm);
768         /* Register the procedure tables */
769         rpc_init_proc_table(NLM_PROGRAM, 1, nlm1_proc);
770         rpc_init_proc_table(NLM_PROGRAM, 2, nlm2_proc);
771         rpc_init_proc_table(NLM_PROGRAM, 3, nlm3_proc);
772         rpc_init_proc_table(NLM_PROGRAM, 4, nlm4_proc);
773 }