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