80049878b08be068c21dcc31e712948933b6304f
[metze/wireshark/wip.git] / epan / dissectors / packet-hclnfsd.c
1 /* packet-hclnfsd.c
2  * Routines for hclnfsd (Hummingbird NFS Daemon) dissection
3  * Copyright 2001, Mike Frisch <frisch@hummingbird.com>
4  *
5  * $Id$
6  *
7  * Wireshark - Network traffic analyzer
8  * By Gerald Combs <gerald@wireshark.org>
9  * Copyright 1998 Gerald Combs
10  *
11  * Copied from packet-ypserv.c
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software
25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26  */
27
28 #include "config.h"
29
30 #include <string.h>
31
32 #include "packet-rpc.h"
33 #include "packet-nfs.h"
34 #include "packet-hclnfsd.h"
35
36 #include <epan/wmem/wmem.h>
37
38 static int proto_hclnfsd = -1;
39 static int hf_hclnfsd_procedure_v1 = -1;
40 static int hf_hclnfsd_request_type = -1;
41 static int hf_hclnfsd_device = -1;
42 /* static int hf_hclnfsd_login = -1; */
43 static int hf_hclnfsd_lockname = -1;
44 static int hf_hclnfsd_unknown_data = -1;
45 static int hf_hclnfsd_lockowner = -1;
46 static int hf_hclnfsd_printername = -1;
47 static int hf_hclnfsd_filename = -1;
48 static int hf_hclnfsd_fileext = -1;
49 static int hf_hclnfsd_grpname = -1;
50 static int hf_hclnfsd_hostname = -1;
51 static int hf_hclnfsd_username = -1;
52 static int hf_hclnfsd_queuename = -1;
53 static int hf_hclnfsd_queuecomment = -1;
54 static int hf_hclnfsd_queuestatus = -1;
55 static int hf_hclnfsd_numphysicalprinters = -1;
56 static int hf_hclnfsd_printqueuenumber = -1;
57 static int hf_hclnfsd_printparams = -1;
58 static int hf_hclnfsd_status = -1;
59 static int hf_hclnfsd_sequence = -1;
60 static int hf_hclnfsd_server_ip = -1;
61 static int hf_hclnfsd_host_ip = -1;
62 static int hf_hclnfsd_gid = -1;
63 static int hf_hclnfsd_uid = -1;
64 static int hf_hclnfsd_cookie = -1;
65 static int hf_hclnfsd_mode = -1;
66 static int hf_hclnfsd_access = -1;
67 static int hf_hclnfsd_exclusive = -1;
68 static int hf_hclnfsd_offset = -1;
69 static int hf_hclnfsd_length = -1;
70 static int hf_hclnfsd_jobstatus = -1;
71 static int hf_hclnfsd_timesubmitted = -1;
72 static int hf_hclnfsd_size = -1;
73 static int hf_hclnfsd_copies = -1;
74 static int hf_hclnfsd_auth_ident_obscure = -1;
75
76 static gint ett_hclnfsd = -1;
77 static gint ett_hclnfsd_gids = -1;
78 static gint ett_hclnfsd_groups = -1;
79 static gint ett_hclnfsd_uids = -1;
80 static gint ett_hclnfsd_usernames = -1;
81 static gint ett_hclnfsd_printqueues = -1;
82 static gint ett_hclnfsd_printjob = -1;
83 static gint ett_hclnfsd_auth_ident = -1;
84
85 static int
86 dissect_hclnfsd_gids(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
87 {
88         guint32 ngids, ngids_i, gid;
89         proto_tree *gidtree = NULL;
90         proto_item *giditem = NULL;
91
92
93         ngids = tvb_get_ntohl(tvb, offset);
94         if (tree)
95         {
96                 giditem = proto_tree_add_text(tree, tvb, offset, 4, "GIDs: %d",
97                         ngids);
98                 if (giditem)
99                         gidtree = proto_item_add_subtree(giditem, ett_hclnfsd_gids);
100         }
101         offset += 4;
102
103         if (gidtree)
104         {
105                 for (ngids_i = 0; ngids_i < ngids; ngids_i++)
106                 {
107                         gid = tvb_get_ntohl(tvb, offset + (4 * ngids_i));
108                         proto_tree_add_text(gidtree, tvb, offset + (4 * ngids_i), 4,
109                                 "GID: %d", gid);
110                 }
111         }
112         offset += 4 * ngids;
113
114         return offset;
115 }
116
117 static int
118 dissect_hclnfsd_spool_inquire_call(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
119 {
120         offset = dissect_rpc_uint32(tvb, tree, hf_hclnfsd_status, offset);
121
122         offset = dissect_nfs3_fh(tvb, offset, pinfo, tree, "spool filehandle", NULL);
123
124         return offset;
125 }
126
127
128 static int
129 dissect_hclnfsd_spool_file_call(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
130 {
131         offset = dissect_rpc_string(tvb, tree, hf_hclnfsd_printername, offset, NULL);
132
133         offset = dissect_rpc_string(tvb, tree, hf_hclnfsd_filename, offset, NULL);
134
135         offset = dissect_rpc_uint32(tvb, tree, hf_hclnfsd_fileext, offset);
136
137         return offset;
138 }
139
140
141 static const value_string names_request_type[] = {
142 #define HCLNFSD_DISK_REQUEST 4
143         { HCLNFSD_DISK_REQUEST, "DISK" },
144 #define HCLNFSD_PRINT_REQUEST 3
145         { HCLNFSD_PRINT_REQUEST, "PRINTER" },
146         { 0, NULL }
147 };
148
149 static char *
150 hclnfsd_decode_obscure(const char *ident, int ident_len)
151 {
152         char *ident_decoded, *ident_out;
153         int j, x, y;
154
155         ident_decoded = (char *)wmem_alloc(wmem_packet_scope(), ident_len);
156         ident_out = ident_decoded;
157         for (x = -1, j = 0; j < ident_len; j++)
158         {
159                 y = *ident;
160                 x ^= *ident;
161                 *ident_out = x;
162                 x = y;
163                 ident++;
164                 ident_out++;
165         }
166         return ident_decoded;
167 }
168
169
170 static int
171 dissect_hclnfsd_authorize_call(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
172 {
173         guint32 request_type;
174         const char *ident = NULL;
175         char *ident_decoded;
176         char *username = NULL;
177         char *password = NULL;
178         int ident_len = 0;
179         int newoffset;
180         proto_item *ident_item = NULL;
181         proto_tree *ident_tree = NULL;
182
183         proto_tree_add_item(tree, hf_hclnfsd_server_ip, tvb, offset, 4, ENC_BIG_ENDIAN);
184         offset += 4;
185
186         request_type = tvb_get_ntohl(tvb, offset);
187         if (tree)
188                 proto_tree_add_uint(tree, hf_hclnfsd_request_type, tvb, offset,
189                         4, request_type);
190         offset += 4;
191
192         offset = dissect_rpc_string(tvb, tree, hf_hclnfsd_device, offset,
193                 NULL);
194
195         if (tree)
196         {
197                 ident_item = proto_tree_add_text(tree, tvb, offset, -1,
198                         "Authentication Ident");
199
200                 if (ident_item)
201                 {
202                         ident_tree = proto_item_add_subtree(ident_item,
203                                 ett_hclnfsd_auth_ident);
204
205                         if (ident_tree)
206                         {
207                                 newoffset = dissect_rpc_string(tvb, ident_tree,
208                                         hf_hclnfsd_auth_ident_obscure, offset, &ident);
209
210                                 if (ident)
211                                 {
212                                         ident_len = (int)strlen(ident);
213
214                                         proto_item_set_len(ident_item, ident_len);
215
216                                         ident_decoded = hclnfsd_decode_obscure(ident, ident_len);
217
218                                         username = ident_decoded + 2;
219                                         password = username + strlen(username) + 1;
220
221                                         proto_tree_add_text(ident_tree, tvb, offset, ident_len,
222                                                 "Username: %s", username);
223
224                                         proto_tree_add_text(ident_tree, tvb, offset, ident_len,
225                                                 "Password: %s", password);
226
227                                         offset = newoffset;
228
229                                         ident = NULL;
230                                 }
231                         }
232                 }
233         }
234
235         return offset;
236 }
237
238
239 static int
240 dissect_hclnfsd_authorize_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
241 {
242         guint32 status;
243
244         status = tvb_get_ntohl(tvb, offset);
245         if (!tree)
246                 return offset;
247         offset += 4;
248
249         if (status != 0)
250                 return offset;
251
252         proto_tree_add_uint(tree, hf_hclnfsd_status, tvb, offset, 4, status);
253
254         offset = dissect_rpc_uint32(tvb, tree, hf_hclnfsd_uid, offset);
255
256         offset = dissect_rpc_uint32(tvb, tree, hf_hclnfsd_gid, offset);
257
258         offset = dissect_hclnfsd_gids(tvb, offset, pinfo, tree);
259
260         return offset;
261 }
262
263 static int
264 dissect_hclnfsd_grp_name_to_numb_call(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
265 {
266         offset = dissect_rpc_string(tvb, tree, hf_hclnfsd_grpname, offset, NULL);
267
268         return offset;
269 }
270
271 static int
272 dissect_hclnfsd_grp_name_to_numb_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
273 {
274         offset = dissect_rpc_uint32(tvb, tree, hf_hclnfsd_gid, offset);
275
276         return offset;
277 }
278
279
280 static int
281 dissect_hclnfsd_grp_to_number_call(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
282 {
283
284         offset = dissect_hclnfsd_gids(tvb, offset, pinfo, tree);
285
286         return offset;
287 }
288
289
290 static int
291 dissect_hclnfsd_grp_to_number_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
292 {
293         return dissect_rpc_string(tvb, tree, hf_hclnfsd_grpname, offset,
294                 NULL);
295 }
296
297
298 static int
299 dissect_hclnfsd_return_host_call(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
300 {
301         proto_tree_add_item(tree, hf_hclnfsd_host_ip, tvb, offset, 4, ENC_BIG_ENDIAN);
302         offset += 4;
303
304         return offset;
305 }
306
307
308 static int
309 dissect_hclnfsd_return_host_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
310 {
311         offset = dissect_rpc_string(tvb, tree, hf_hclnfsd_hostname, offset, NULL);
312
313         return offset;
314 }
315
316
317 static int
318 dissect_hclnfsd_uid_to_name_call(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
319 {
320         guint32 nuids, nuids_i;
321         proto_tree *uidtree = NULL;
322         proto_item *uiditem = NULL;
323
324         nuids = tvb_get_ntohl(tvb, offset);
325         if (tree)
326         {
327                 uiditem = proto_tree_add_text(tree, tvb, offset, 4, "UIDs: %d",
328                         nuids);
329
330                 if (uiditem)
331                         uidtree = proto_item_add_subtree(uiditem, ett_hclnfsd_uids);
332         }
333         offset += 4;
334
335         if (!uidtree)
336                 return offset;
337
338         for (nuids_i = 0; nuids_i < nuids; nuids_i++)
339                 offset = dissect_rpc_uint32(tvb, uidtree, hf_hclnfsd_uid, offset);
340
341         return offset;
342 }
343
344
345 static int
346 dissect_hclnfsd_uid_to_name_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
347 {
348         guint32 nusers, nusers_i;
349         proto_tree *usertree = NULL;
350         proto_item *useritem = NULL;
351
352         nusers = tvb_get_ntohl(tvb, offset);
353         if (tree)
354         {
355                 useritem = proto_tree_add_text(tree, tvb, offset, 4, "UIDs: %d",
356                         nusers);
357
358                 if (useritem)
359                         usertree = proto_item_add_subtree(useritem, ett_hclnfsd_usernames);
360         }
361         offset += 4;
362
363         if (!usertree)
364                 return offset;
365
366         for (nusers_i = 0; nusers_i < nusers; nusers_i++)
367                 offset = dissect_rpc_string(tvb, usertree,
368                         hf_hclnfsd_username, offset, NULL);
369
370         return offset;
371 }
372
373
374 static int
375 dissect_hclnfsd_name_to_uid_call(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
376 {
377         offset = dissect_rpc_string(tvb, tree, hf_hclnfsd_username, offset, NULL);
378
379         return offset;
380 }
381
382
383 static int
384 dissect_hclnfsd_name_to_uid_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
385 {
386         offset = dissect_rpc_uint32(tvb, tree, hf_hclnfsd_uid, offset);
387
388         return offset;
389 }
390
391
392 static int
393 dissect_hclnfsd_share_call(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
394 {
395         guint32 request_type;
396
397         request_type = tvb_get_ntohl(tvb, offset);
398         if (tree)
399                 proto_tree_add_uint(tree, hf_hclnfsd_request_type, tvb, offset,
400                         4, request_type);
401         offset += 4;
402
403         offset = dissect_rpc_uint32(tvb, tree, hf_hclnfsd_cookie, offset);
404
405         offset = dissect_rpc_string(tvb, tree, hf_hclnfsd_lockname, offset, NULL);
406
407         offset = dissect_nfs3_fh(tvb, offset, pinfo, tree, "Filehandle", NULL);
408
409         offset = dissect_rpc_data(tvb, tree, hf_hclnfsd_unknown_data, offset);
410
411         offset = dissect_rpc_uint32(tvb, tree, hf_hclnfsd_mode, offset);
412
413         offset = dissect_rpc_uint32(tvb, tree, hf_hclnfsd_access, offset);
414
415         offset += 4;    /* skip last 4 UNUSED bytes */
416
417         return offset;
418 }
419
420
421 static int
422 dissect_hclnfsd_share_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
423 {
424         guint32 request_type;
425
426         request_type = tvb_get_ntohl(tvb, offset);
427         if (tree)
428                 proto_tree_add_uint(tree, hf_hclnfsd_request_type, tvb, offset,
429                         4, request_type);
430         offset += 4;
431
432         offset = dissect_rpc_uint32(tvb, tree, hf_hclnfsd_cookie, offset);
433         offset = dissect_rpc_uint32(tvb, tree, hf_hclnfsd_status, offset);
434         offset = dissect_rpc_uint32(tvb, tree, hf_hclnfsd_sequence, offset);
435
436         return offset;
437 }
438
439
440 static int
441 dissect_hclnfsd_unshare_call(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
442 {
443         return dissect_hclnfsd_share_call(tvb, offset, pinfo, tree);
444 }
445
446
447 static int
448 dissect_hclnfsd_unshare_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
449 {
450         return dissect_hclnfsd_share_reply(tvb, offset, pinfo, tree);
451 }
452
453
454 static int
455 dissect_hclnfsd_lock_call(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
456 {
457         offset = dissect_rpc_uint32(tvb, tree, hf_hclnfsd_status, offset);
458         offset = dissect_rpc_uint32(tvb, tree, hf_hclnfsd_cookie, offset);
459         offset += 4; /* skip unused uint */
460
461         offset = dissect_rpc_uint32(tvb, tree, hf_hclnfsd_exclusive, offset);
462
463         offset = dissect_rpc_string(tvb, tree, hf_hclnfsd_lockname, offset, NULL);
464
465         offset = dissect_nfs3_fh(tvb, offset, pinfo, tree, "Filehandle", NULL);
466
467         offset = dissect_rpc_data(tvb, tree, hf_hclnfsd_lockowner, offset);
468
469         offset += 4;  /* unused, skip */
470
471         offset = dissect_rpc_uint32(tvb, tree, hf_hclnfsd_offset, offset);
472
473         offset = dissect_rpc_uint32(tvb, tree, hf_hclnfsd_length, offset);
474
475         return offset;
476 }
477
478
479 static int
480 dissect_hclnfsd_lock_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
481 {
482         guint request_type;
483
484         request_type = tvb_get_ntohl(tvb, offset);
485         if (tree)
486                 proto_tree_add_uint(tree, hf_hclnfsd_request_type, tvb, offset,
487                         4, request_type);
488         offset += 4;
489
490         offset = dissect_rpc_uint32(tvb, tree, hf_hclnfsd_cookie, offset);
491         offset = dissect_rpc_uint32(tvb, tree, hf_hclnfsd_status, offset);
492
493         return offset;
494 }
495
496
497 static int
498 dissect_hclnfsd_remove_call(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
499 {
500         offset = dissect_rpc_string(tvb, tree, hf_hclnfsd_lockname, offset, NULL);
501
502         offset += 4;  /* skip unused */
503
504         return offset;
505 }
506
507
508 static int
509 dissect_hclnfsd_unlock_call(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
510 {
511         offset += 4;  /* skip unused */
512
513         offset = dissect_rpc_uint32(tvb, tree, hf_hclnfsd_cookie, offset);
514
515         offset = dissect_rpc_string(tvb, tree, hf_hclnfsd_lockname, offset, NULL);
516
517         offset = dissect_nfs3_fh(tvb, offset, pinfo, tree, "Filehandle", NULL);
518
519         offset = dissect_rpc_data(tvb, tree, hf_hclnfsd_unknown_data, offset);
520
521         offset += 4;  /* skip unused */
522
523         offset = dissect_rpc_uint32(tvb, tree, hf_hclnfsd_offset, offset);
524         offset = dissect_rpc_uint32(tvb, tree, hf_hclnfsd_length, offset);
525
526         return offset;
527 }
528
529
530 static int
531 dissect_hclnfsd_unlock_reply(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
532 {
533         return dissect_hclnfsd_lock_reply(tvb, offset, pinfo, tree);
534 }
535
536
537 static int
538 dissect_hclnfsd_get_printers_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
539 {
540         guint nqueues, nqueues_i;
541         proto_item *queuesitem = NULL;
542         proto_tree *queuestree = NULL;
543
544         nqueues = tvb_get_ntohl(tvb, offset);
545         if (tree)
546         {
547                 queuesitem = proto_tree_add_text(tree, tvb, offset, 4,
548                         "Print Queues: %d", nqueues);
549
550                 if (queuesitem)
551                         queuestree = proto_item_add_subtree(queuesitem,
552                                 ett_hclnfsd_printqueues);
553         }
554         offset += 4;
555
556         if (!queuestree)
557                 return offset;
558
559         for (nqueues_i = 0; nqueues_i < nqueues; nqueues_i++)
560         {
561                 /* create new item for print queue */
562                 offset = dissect_rpc_string(tvb, tree,
563                         hf_hclnfsd_queuename, offset, NULL);
564
565                 /* create subtree on new item with print queue comment */
566                 offset = dissect_rpc_string(tvb, tree,
567                         hf_hclnfsd_queuecomment, offset, NULL);
568         }
569
570         return offset;
571 }
572
573
574 static int
575 dissect_hclnfsd_get_printq_call(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
576 {
577         offset = dissect_rpc_string(tvb, tree, hf_hclnfsd_queuename, offset, NULL);
578
579         offset = dissect_rpc_string(tvb, tree, hf_hclnfsd_username, offset, NULL);
580
581         return offset;
582 }
583
584
585 static int
586 dissect_hclnfsd_get_printq_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
587 {
588         guint datafollows, jobid;
589         proto_item *queueitem = NULL;
590         proto_tree *queuetree = NULL;
591         proto_item *jobitem;
592         proto_tree *jobtree;
593
594         offset = dissect_rpc_uint32(tvb, tree, hf_hclnfsd_printqueuenumber, offset);
595
596         offset = dissect_rpc_string(tvb, tree, hf_hclnfsd_queuecomment, offset, NULL);
597
598         offset = dissect_rpc_uint32(tvb, tree, hf_hclnfsd_queuestatus, offset);
599
600         offset = dissect_rpc_uint32(tvb, tree, hf_hclnfsd_numphysicalprinters, offset);
601
602         datafollows = tvb_get_ntohl(tvb, offset);
603         if (tree)
604         {
605                 queueitem = proto_tree_add_text(tree, tvb, offset, 4,
606                         "Print Jobs: %d", datafollows);
607                 if (queueitem)
608                         queuetree = proto_item_add_subtree(queueitem, ett_hclnfsd_printqueues);
609         }
610         offset += 4;
611
612         if (!queuetree)
613                 return offset;
614
615         while (datafollows)
616         {
617                 jobid = tvb_get_ntohl(tvb, offset);
618                 jobitem = proto_tree_add_text(queuetree, tvb, offset, 4, "Job ID: %d",
619                         jobid);
620                 offset += 4;
621
622                 jobtree = proto_item_add_subtree(jobitem, ett_hclnfsd_printjob);
623
624                 offset = dissect_rpc_string(tvb, jobtree,
625                         hf_hclnfsd_username, offset, NULL);
626
627                 offset = dissect_rpc_string(tvb, jobtree,
628                         hf_hclnfsd_printparams, offset, NULL);
629
630                 offset = dissect_rpc_uint32(tvb, jobtree, hf_hclnfsd_queuestatus, offset);
631
632                 offset = dissect_rpc_uint32(tvb, jobtree, hf_hclnfsd_jobstatus, offset);
633                 offset = dissect_rpc_uint32(tvb, jobtree, hf_hclnfsd_timesubmitted, offset);
634                 offset = dissect_rpc_uint32(tvb, jobtree, hf_hclnfsd_size, offset);
635                 offset = dissect_rpc_uint32(tvb, jobtree, hf_hclnfsd_copies, offset);
636                 offset = dissect_rpc_string(tvb, jobtree,
637                         hf_hclnfsd_queuecomment, offset, NULL);
638
639                 datafollows = tvb_get_ntohl(tvb, offset);
640                 offset += 4;
641         }
642
643         return offset;
644 }
645
646
647 /* proc number, "proc name", dissect_request, dissect_reply */
648 /* NULL as function pointer means: take the generic one. */
649
650 static const vsff hclnfsd1_proc[] = {
651     { HCLNFSDPROC_NULL, "NULL",
652                 NULL, NULL },
653     { HCLNFSDPROC_SPOOL_INQUIRE, "SPOOL_INQUIRE",
654                 dissect_hclnfsd_spool_inquire_call, NULL },
655     { HCLNFSDPROC_SPOOL_FILE, "SPOOL_FILE",
656                 dissect_hclnfsd_spool_file_call, NULL },
657     { HCLNFSDPROC_AUTHORIZE, "AUTHORIZE",
658                 dissect_hclnfsd_authorize_call, dissect_hclnfsd_authorize_reply },
659     { HCLNFSDPROC_GRP_NAME_TO_NUMB, "GRP_NAME_TO_NUMB",
660                 dissect_hclnfsd_grp_name_to_numb_call, dissect_hclnfsd_grp_name_to_numb_reply },
661     { HCLNFSDPROC_GRP_TO_NUMBER, "GRP_TO_NUMBER",
662                 dissect_hclnfsd_grp_to_number_call, dissect_hclnfsd_grp_to_number_reply },
663     { HCLNFSDPROC_RETURN_HOST, "RETURN_HOST",
664                 dissect_hclnfsd_return_host_call, dissect_hclnfsd_return_host_reply },
665     { HCLNFSDPROC_UID_TO_NAME, "UID_TO_NAME",
666                 dissect_hclnfsd_uid_to_name_call, dissect_hclnfsd_uid_to_name_reply },
667     { HCLNFSDPROC_NAME_TO_UID, "NAME_TO_UID",
668                 dissect_hclnfsd_name_to_uid_call, dissect_hclnfsd_name_to_uid_reply },
669     { HCLNFSDPROC_SHARE, "SHARE",
670                 dissect_hclnfsd_share_call, dissect_hclnfsd_share_reply },
671     { HCLNFSDPROC_UNSHARE, "UNSHARE",
672                 dissect_hclnfsd_unshare_call, dissect_hclnfsd_unshare_reply },
673     { HCLNFSDPROC_LOCK, "LOCK",
674                 dissect_hclnfsd_lock_call, dissect_hclnfsd_lock_reply },
675     { HCLNFSDPROC_REMOVE, "REMOVE",
676                 dissect_hclnfsd_remove_call, NULL },
677     { HCLNFSDPROC_UNLOCK, "UNLOCK",
678                 dissect_hclnfsd_unlock_call, dissect_hclnfsd_unlock_reply },
679     { HCLNFSDPROC_GET_PRINTERS, "GET_PRINTERS",
680                 NULL, dissect_hclnfsd_get_printers_reply },
681     { HCLNFSDPROC_GET_PRINTQ, "GET_PRINTQ",
682                 dissect_hclnfsd_get_printq_call, dissect_hclnfsd_get_printq_reply },
683     { HCLNFSDPROC_CANCEL_PRJOB, "CANCEL_PRJOB",
684                 NULL, NULL },
685     { HCLNFSDPROC_ZAP_LOCKS, "ZAP_LOCKS",
686                 NULL, NULL },
687     { 0, NULL, NULL, NULL }
688 };
689 static const value_string hclnfsd1_proc_vals[] = {
690     { HCLNFSDPROC_NULL, "NULL" },
691     { HCLNFSDPROC_SPOOL_INQUIRE, "SPOOL_INQUIRE" },
692     { HCLNFSDPROC_SPOOL_FILE, "SPOOL_FILE" },
693     { HCLNFSDPROC_AUTHORIZE, "AUTHORIZE" },
694     { HCLNFSDPROC_GRP_NAME_TO_NUMB, "GRP_NAME_TO_NUMB" },
695     { HCLNFSDPROC_GRP_TO_NUMBER, "GRP_TO_NUMBER" },
696     { HCLNFSDPROC_RETURN_HOST, "RETURN_HOST" },
697     { HCLNFSDPROC_UID_TO_NAME, "UID_TO_NAME" },
698     { HCLNFSDPROC_NAME_TO_UID, "NAME_TO_UID" },
699     { HCLNFSDPROC_SHARE, "SHARE" },
700     { HCLNFSDPROC_UNSHARE, "UNSHARE" },
701     { HCLNFSDPROC_LOCK, "LOCK" },
702     { HCLNFSDPROC_REMOVE, "REMOVE" },
703     { HCLNFSDPROC_UNLOCK, "UNLOCK" },
704     { HCLNFSDPROC_GET_PRINTERS, "GET_PRINTERS" },
705     { HCLNFSDPROC_GET_PRINTQ, "GET_PRINTQ" },
706     { HCLNFSDPROC_CANCEL_PRJOB, "CANCEL_PRJOB" },
707     { HCLNFSDPROC_ZAP_LOCKS, "ZAP_LOCKS" },
708     { 0, NULL }
709 };
710 /* end of hclnfsd version 1 */
711
712
713 void
714 proto_register_hclnfsd(void)
715 {
716         static hf_register_info hf[] = {
717                 { &hf_hclnfsd_procedure_v1, {
718                         "V1 Procedure", "hclnfsd.procedure_v1", FT_UINT32, BASE_DEC,
719                         VALS(hclnfsd1_proc_vals), 0, NULL, HFILL }},
720                 { &hf_hclnfsd_request_type, {
721                         "Request Type", "hclnfsd.request_type", FT_UINT32, BASE_DEC,
722                         VALS(names_request_type), 0, NULL, HFILL }},
723
724                 { &hf_hclnfsd_device, {
725                         "Device", "hclnfsd.device", FT_STRING, BASE_NONE,
726                         NULL, 0, NULL, HFILL }},
727
728 #if 0
729                 { &hf_hclnfsd_login, {
730                         "Login Text", "hclnfsd.logintext", FT_STRING, BASE_NONE,
731                         NULL, 0, NULL, HFILL }},
732 #endif
733
734                 { &hf_hclnfsd_lockname, {
735                         "Lockname", "hclnfsd.lockname", FT_STRING, BASE_NONE,
736                         NULL, 0, NULL, HFILL }},
737
738                 { &hf_hclnfsd_unknown_data, {
739                         "Unknown", "hclnfsd.unknown_data", FT_BYTES, BASE_NONE,
740                         NULL, 0, "Data", HFILL }},
741
742                 { &hf_hclnfsd_lockowner, {
743                         "Lockowner", "hclnfsd.lockowner", FT_BYTES, BASE_NONE,
744                         NULL, 0, NULL, HFILL }},
745
746                 { &hf_hclnfsd_printername, {
747                         "Printer Name", "hclnfsd.printername", FT_STRING, BASE_NONE,
748                         NULL, 0, NULL, HFILL }},
749
750                 { &hf_hclnfsd_filename, {
751                         "Filename", "hclnfsd.filename", FT_STRING, BASE_NONE,
752                         NULL, 0, NULL, HFILL }},
753
754                 { &hf_hclnfsd_fileext, {
755                         "File Extension", "hclnfsd.fileext", FT_UINT32, BASE_DEC,
756                         NULL, 0, NULL, HFILL }},
757
758                 { &hf_hclnfsd_grpname, {
759                         "Group", "hclnfsd.group", FT_STRING, BASE_NONE,
760                         NULL, 0, NULL, HFILL }},
761
762                 { &hf_hclnfsd_hostname, {
763                         "Hostname", "hclnfsd.hostname", FT_STRING, BASE_NONE,
764                         NULL, 0, NULL, HFILL }},
765
766                 { &hf_hclnfsd_username, {
767                         "Username", "hclnfsd.username", FT_STRING, BASE_NONE,
768                         NULL, 0, NULL, HFILL }},
769
770                 { &hf_hclnfsd_queuename, {
771                         "Name", "hclnfsd.printqueuename", FT_STRING, BASE_NONE,
772                         NULL, 0, "Print Queue Name", HFILL }},
773
774                 { &hf_hclnfsd_queuecomment, {
775                         "Comment", "hclnfsd.printqueuecomment", FT_STRING, BASE_NONE,
776                         NULL, 0, "Print Queue Comment", HFILL }},
777
778                 { &hf_hclnfsd_printparams, {
779                         "Print Parameters", "hclnfsd.printparameters", FT_STRING, BASE_NONE,
780                         NULL, 0, NULL, HFILL }},
781
782                 { &hf_hclnfsd_status, {
783                         "Status", "hclnfsd.status", FT_UINT32, BASE_DEC,
784                         NULL, 0, NULL, HFILL }},
785
786                 { &hf_hclnfsd_uid, {
787                         "UID", "hclnfsd.uid", FT_UINT32, BASE_DEC,
788                         NULL, 0, "User ID", HFILL }},
789
790                 { &hf_hclnfsd_sequence, {
791                         "Sequence", "hclnfsd.sequence", FT_UINT32, BASE_HEX,
792                         NULL, 0, NULL, HFILL }},
793
794                 { &hf_hclnfsd_cookie, {
795                         "Cookie", "hclnfsd.cookie", FT_UINT32, BASE_HEX,
796                         NULL, 0, NULL, HFILL }},
797
798                 { &hf_hclnfsd_mode, {
799                         "Mode", "hclnfsd.mode", FT_UINT32, BASE_DEC,
800                         NULL, 0, NULL, HFILL }},
801
802                 { &hf_hclnfsd_access, {
803                         "Access", "hclnfsd.access", FT_UINT32, BASE_DEC,
804                         NULL, 0, NULL, HFILL }},
805
806                 { &hf_hclnfsd_exclusive, {
807                         "Exclusive", "hclnfsd.exclusive", FT_UINT32, BASE_DEC,
808                         NULL, 0, NULL, HFILL }},
809
810                 { &hf_hclnfsd_offset, {
811                         "Offset", "hclnfsd.offset", FT_UINT32, BASE_DEC,
812                         NULL, 0, NULL, HFILL }},
813
814                 { &hf_hclnfsd_length, {
815                         "Length", "hclnfsd.length", FT_UINT32, BASE_DEC,
816                         NULL, 0, NULL, HFILL }},
817
818                 { &hf_hclnfsd_queuestatus, {
819                         "Queue Status", "hclnfsd.queuestatus", FT_UINT32, BASE_DEC,
820                         NULL, 0, NULL, HFILL }},
821
822                 { &hf_hclnfsd_printqueuenumber, {
823                         "Print Queue Number", "hclnfsd.pqn", FT_UINT32, BASE_DEC,
824                         NULL, 0, NULL, HFILL }},
825
826                 { &hf_hclnfsd_numphysicalprinters, {
827                         "Number of Physical Printers", "hclnfsd.npp", FT_UINT32, BASE_DEC,
828                         NULL, 0, NULL, HFILL }},
829
830                 { &hf_hclnfsd_jobstatus, {
831                         "Job Status", "hclnfsd.jobstatus", FT_UINT32, BASE_DEC,
832                         NULL, 0, NULL, HFILL }},
833
834                 { &hf_hclnfsd_timesubmitted, {
835                         "Time Submitted", "hclnfsd.timesubmitted", FT_UINT32, BASE_DEC,
836                         NULL, 0, NULL, HFILL }},
837
838                 { &hf_hclnfsd_size, {
839                         "Size", "hclnfsd.size", FT_UINT32, BASE_DEC,
840                         NULL, 0, NULL, HFILL }},
841
842                 { &hf_hclnfsd_copies, {
843                         "Copies", "hclnfsd.copies", FT_UINT32, BASE_DEC,
844                         NULL, 0, NULL, HFILL }},
845
846                 { &hf_hclnfsd_gid, {
847                         "GID", "hclnfsd.gid", FT_UINT32, BASE_DEC,
848                         NULL, 0, "Group ID", HFILL }},
849
850                 { &hf_hclnfsd_server_ip, {
851                         "Server IP", "hclnfsd.server_ip", FT_IPv4, BASE_NONE,
852                         NULL, 0, NULL, HFILL }},
853
854                 { &hf_hclnfsd_host_ip, {
855                         "Host IP", "hclnfsd.host_ip", FT_IPv4, BASE_NONE,
856                         NULL, 0, NULL, HFILL }},
857
858                 { &hf_hclnfsd_auth_ident_obscure, {
859                         "Obscure Ident", "hclnfsd.authorize.ident.obscure", FT_STRING,
860                         BASE_NONE       , NULL, 0, "Authentication Obscure Ident", HFILL }},
861         };
862         static gint *ett[] = {
863                 &ett_hclnfsd,
864                 &ett_hclnfsd_gids,
865                 &ett_hclnfsd_groups,
866                 &ett_hclnfsd_uids,
867                 &ett_hclnfsd_usernames,
868                 &ett_hclnfsd_printqueues,
869                 &ett_hclnfsd_printjob,
870                 &ett_hclnfsd_auth_ident
871         };
872
873         proto_hclnfsd = proto_register_protocol("Hummingbird NFS Daemon",
874                 "HCLNFSD", "hclnfsd");
875         proto_register_field_array(proto_hclnfsd, hf, array_length(hf));
876         proto_register_subtree_array(ett, array_length(ett));
877 }
878
879 void
880 proto_reg_handoff_hclnfsd(void)
881 {
882         /* Register the protocol as RPC */
883         rpc_init_prog(proto_hclnfsd, HCLNFSD_PROGRAM, ett_hclnfsd);
884
885         /* Register the procedure tables */
886         rpc_init_proc_table(HCLNFSD_PROGRAM, 1, hclnfsd1_proc, hf_hclnfsd_procedure_v1);
887 }