summaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-hclnfsd.c
blob: 088ba85e2f34aa7ac5f42ed5c97242326f7ec9eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
/* packet-hclnfsd.c
 * Routines for hclnfsd (Hummingbird NFS Daemon) dissection
 * Copyright 2001, Mike Frisch <frisch@hummingbird.com>
 *
 * Wireshark - Network traffic analyzer
 * By Gerald Combs <gerald@wireshark.org>
 * Copyright 1998 Gerald Combs
 *
 * Copied from packet-ypserv.c
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 */

#include "config.h"


#include "packet-nfs.h"


void proto_register_hclnfsd(void);
void proto_reg_handoff_hclnfsd(void);

#define HCLNFSD_PROGRAM  0x2f00dbad

#define HCLNFSDPROC_NULL	       0
#define HCLNFSDPROC_SPOOL_INQUIRE      1
#define HCLNFSDPROC_SPOOL_FILE	       2
#define HCLNFSDPROC_AUTHORIZE	       3
#define HCLNFSDPROC_GRP_NAME_TO_NUMB   4
#define HCLNFSDPROC_GRP_TO_NUMBER      5
#define HCLNFSDPROC_RETURN_HOST	       6
#define HCLNFSDPROC_UID_TO_NAME	       7
#define HCLNFSDPROC_NAME_TO_UID	       8
#define HCLNFSDPROC_SHARE	      20
#define HCLNFSDPROC_UNSHARE	      21
#define HCLNFSDPROC_LOCK	      22
#define HCLNFSDPROC_REMOVE	      23
#define HCLNFSDPROC_UNLOCK	      24
#define HCLNFSDPROC_GET_PRINTERS      30
#define HCLNFSDPROC_GET_PRINTQ	      31
#define HCLNFSDPROC_CANCEL_PRJOB      32
#define HCLNFSDPROC_ZAP_LOCKS	     105

static int proto_hclnfsd = -1;
static int hf_hclnfsd_procedure_v1 = -1;
static int hf_hclnfsd_request_type = -1;
static int hf_hclnfsd_device = -1;
/* static int hf_hclnfsd_login = -1; */
static int hf_hclnfsd_lockname = -1;
static int hf_hclnfsd_unknown_data = -1;
static int hf_hclnfsd_lockowner = -1;
static int hf_hclnfsd_printername = -1;
static int hf_hclnfsd_filename = -1;
static int hf_hclnfsd_fileext = -1;
static int hf_hclnfsd_grpname = -1;
static int hf_hclnfsd_hostname = -1;
static int hf_hclnfsd_username = -1;
static int hf_hclnfsd_queuename = -1;
static int hf_hclnfsd_queuecomment = -1;
static int hf_hclnfsd_queuestatus = -1;
static int hf_hclnfsd_numphysicalprinters = -1;
static int hf_hclnfsd_printqueuenumber = -1;
static int hf_hclnfsd_printparams = -1;
static int hf_hclnfsd_status = -1;
static int hf_hclnfsd_sequence = -1;
static int hf_hclnfsd_server_ip = -1;
static int hf_hclnfsd_host_ip = -1;
static int hf_hclnfsd_gid = -1;
static int hf_hclnfsd_uid = -1;
static int hf_hclnfsd_cookie = -1;
static int hf_hclnfsd_mode = -1;
static int hf_hclnfsd_access = -1;
static int hf_hclnfsd_exclusive = -1;
static int hf_hclnfsd_offset = -1;
static int hf_hclnfsd_length = -1;
static int hf_hclnfsd_jobstatus = -1;
static int hf_hclnfsd_timesubmitted = -1;
static int hf_hclnfsd_size = -1;
static int hf_hclnfsd_copies = -1;
static int hf_hclnfsd_auth_ident_obscure = -1;

/* Generated from convert_proto_tree_add_text.pl */
static int hf_hclnfsd_job_id = -1;
static int hf_hclnfsd_print_queues = -1;
static int hf_hclnfsd_print_jobs = -1;
static int hf_hclnfsd_gids = -1;
static int hf_hclnfsd_uids = -1;
static int hf_hclnfsd_password = -1;

static gint ett_hclnfsd = -1;
static gint ett_hclnfsd_gids = -1;
static gint ett_hclnfsd_groups = -1;
static gint ett_hclnfsd_uids = -1;
static gint ett_hclnfsd_usernames = -1;
static gint ett_hclnfsd_printqueues = -1;
static gint ett_hclnfsd_printjob = -1;
static gint ett_hclnfsd_auth_ident = -1;

static int
dissect_hclnfsd_gids(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
{
	guint32 ngids, ngids_i;
	proto_tree *gidtree = NULL;
	proto_item *giditem = NULL;


	ngids = tvb_get_ntohl(tvb, offset);
	if (tree)
	{
		giditem = proto_tree_add_item(tree, hf_hclnfsd_gids, tvb, offset, 4, ENC_BIG_ENDIAN);
		gidtree = proto_item_add_subtree(giditem, ett_hclnfsd_gids);
	}
	offset += 4;

	if (gidtree)
	{
		for (ngids_i = 0; ngids_i < ngids; ngids_i++)
		{
			proto_tree_add_item(gidtree, hf_hclnfsd_gid, tvb, offset + (4 * ngids_i), 4, ENC_BIG_ENDIAN);
		}
	}
	offset += 4 * ngids;

	return offset;
}

static int
dissect_hclnfsd_spool_inquire_call(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
{
	int offset = 0;
	offset = dissect_rpc_uint32(tvb, tree, hf_hclnfsd_status, offset);

	offset = dissect_nfs3_fh(tvb, offset, pinfo, tree, "spool filehandle", NULL, (rpc_call_info_value*)data);

	return offset;
}


static int
dissect_hclnfsd_spool_file_call(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
{
	int offset = 0;

	offset = dissect_rpc_string(tvb, tree, hf_hclnfsd_printername, offset, NULL);

	offset = dissect_rpc_string(tvb, tree, hf_hclnfsd_filename, offset, NULL);

	offset = dissect_rpc_uint32(tvb, tree, hf_hclnfsd_fileext, offset);

	return offset;
}


static const value_string names_request_type[] = {
#define HCLNFSD_DISK_REQUEST 4
	{ HCLNFSD_DISK_REQUEST, "DISK" },
#define HCLNFSD_PRINT_REQUEST 3
	{ HCLNFSD_PRINT_REQUEST, "PRINTER" },
	{ 0, NULL }
};

static char *
hclnfsd_decode_obscure(wmem_allocator_t *pool, const char *ident, int ident_len)
{
	char *ident_decoded, *ident_out;
	int j, x, y;

	ident_decoded = (char *)wmem_alloc(pool, ident_len);
	ident_out = ident_decoded;
	for (x = -1, j = 0; j < ident_len; j++)
	{
		y = *ident;
		x ^= *ident;
		*ident_out = x;
		x = y;
		ident++;
		ident_out++;
	}
	return ident_decoded;
}


static int
dissect_hclnfsd_authorize_call(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
	guint32 request_type;
	const char *ident = NULL;
	char *ident_decoded;
	char *username = NULL;
	char *password = NULL;
	int ident_len = 0;
	int newoffset;
	proto_item *ident_item = NULL;
	proto_tree *ident_tree = NULL;
	int offset = 0;

	proto_tree_add_item(tree, hf_hclnfsd_server_ip, tvb, offset, 4, ENC_BIG_ENDIAN);
	offset += 4;

	request_type = tvb_get_ntohl(tvb, offset);
	proto_tree_add_uint(tree, hf_hclnfsd_request_type, tvb, offset,
			4, request_type);
	offset += 4;

	offset = dissect_rpc_string(tvb, tree, hf_hclnfsd_device, offset,
		NULL);

	ident_tree = proto_tree_add_subtree(tree, tvb, offset, -1,
		ett_hclnfsd_auth_ident, &ident_item, "Authentication Ident");

	if (ident_tree)
	{
		newoffset = dissect_rpc_string(tvb, ident_tree,
			hf_hclnfsd_auth_ident_obscure, offset, &ident);

		if (ident)
		{
			ident_len = (int)strlen(ident);

			proto_item_set_len(ident_item, ident_len);

			ident_decoded = hclnfsd_decode_obscure(pinfo->pool, ident, ident_len);

			username = ident_decoded + 2;
			password = username + strlen(username) + 1;

			proto_tree_add_string(ident_tree, hf_hclnfsd_username, tvb, offset, ident_len, username);
			proto_tree_add_string(ident_tree, hf_hclnfsd_password, tvb, offset, ident_len, password);

			offset = newoffset;
		}
	}

	return offset;
}


static int
dissect_hclnfsd_authorize_reply(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
{
	guint32 status;
	int offset = 0;

	status = tvb_get_ntohl(tvb, offset);
	if (!tree)
		return offset;
	offset += 4;

	if (status != 0)
		return offset;

	proto_tree_add_uint(tree, hf_hclnfsd_status, tvb, offset, 4, status);

	offset = dissect_rpc_uint32(tvb, tree, hf_hclnfsd_uid, offset);

	offset = dissect_rpc_uint32(tvb, tree, hf_hclnfsd_gid, offset);

	offset = dissect_hclnfsd_gids(tvb, offset, pinfo, tree);

	return offset;
}

static int
dissect_hclnfsd_grp_name_to_numb_call(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
{
	return dissect_rpc_string(tvb, tree, hf_hclnfsd_grpname, 0, NULL);
}

static int
dissect_hclnfsd_grp_name_to_numb_reply(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
{
	return dissect_rpc_uint32(tvb, tree, hf_hclnfsd_gid, 0);
}


static int
dissect_hclnfsd_grp_to_number_call(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
	return dissect_hclnfsd_gids(tvb, 0, pinfo, tree);
}


static int
dissect_hclnfsd_grp_to_number_reply(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
{
	return dissect_rpc_string(tvb, tree, hf_hclnfsd_grpname, 0, NULL);
}


static int
dissect_hclnfsd_return_host_call(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
{
	int offset = 0;
	proto_tree_add_item(tree, hf_hclnfsd_host_ip, tvb, offset, 4, ENC_BIG_ENDIAN);
	offset += 4;

	return offset;
}


static int
dissect_hclnfsd_return_host_reply(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
{
	return dissect_rpc_string(tvb, tree, hf_hclnfsd_hostname, 0, NULL);
}


static int
dissect_hclnfsd_uid_to_name_call(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
{
	guint32 nuids, nuids_i;
	proto_tree *uidtree = NULL;
	proto_item *uiditem = NULL;
	int offset = 0;

	nuids = tvb_get_ntohl(tvb, offset);
	if (tree)
	{
		uiditem = proto_tree_add_item(tree, hf_hclnfsd_uids, tvb, offset, 4, ENC_BIG_ENDIAN);

		if (uiditem)
			uidtree = proto_item_add_subtree(uiditem, ett_hclnfsd_uids);
	}
	offset += 4;

	for (nuids_i = 0; nuids_i < nuids; nuids_i++)
		offset = dissect_rpc_uint32(tvb, uidtree, hf_hclnfsd_uid, offset);

	return offset;
}


static int
dissect_hclnfsd_uid_to_name_reply(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
{
	guint32 nusers, nusers_i;
	proto_tree *usertree = NULL;
	proto_item *useritem = NULL;
	int offset = 0;

	nusers = tvb_get_ntohl(tvb, offset);
	if (tree)
	{
		useritem = proto_tree_add_item(tree, hf_hclnfsd_uids, tvb, offset, 4, ENC_BIG_ENDIAN);

		if (useritem)
			usertree = proto_item_add_subtree(useritem, ett_hclnfsd_usernames);
	}
	offset += 4;

	if (!usertree)
		return offset;

	for (nusers_i = 0; nusers_i < nusers; nusers_i++)
		offset = dissect_rpc_string(tvb, usertree,
			hf_hclnfsd_username, offset, NULL);

	return offset;
}


static int
dissect_hclnfsd_name_to_uid_call(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
{
	return dissect_rpc_string(tvb, tree, hf_hclnfsd_username, 0, NULL);
}


static int
dissect_hclnfsd_name_to_uid_reply(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
{
	return dissect_rpc_uint32(tvb, tree, hf_hclnfsd_uid, 0);
}


static int
dissect_hclnfsd_share_call(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
{
	guint32 request_type;
	int offset = 0;

	proto_tree_add_item_ret_uint(tree, hf_hclnfsd_request_type, tvb, offset,
			4, ENC_BIG_ENDIAN, &request_type);
	offset += 4;

	offset = dissect_rpc_uint32(tvb, tree, hf_hclnfsd_cookie, offset);

	offset = dissect_rpc_string(tvb, tree, hf_hclnfsd_lockname, offset, NULL);

	offset = dissect_nfs3_fh(tvb, offset, pinfo, tree, "Filehandle", NULL, (rpc_call_info_value*)data);

	offset = dissect_rpc_data(tvb, tree, hf_hclnfsd_unknown_data, offset);

	offset = dissect_rpc_uint32(tvb, tree, hf_hclnfsd_mode, offset);

	offset = dissect_rpc_uint32(tvb, tree, hf_hclnfsd_access, offset);

	offset += 4;	/* skip last 4 UNUSED bytes */

	return offset;
}


static int
dissect_hclnfsd_share_reply(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
{
	guint32 request_type;
	int offset = 0;

	request_type = tvb_get_ntohl(tvb, offset);
	if (tree)
		proto_tree_add_uint(tree, hf_hclnfsd_request_type, tvb, offset,
			4, request_type);
	offset += 4;

	offset = dissect_rpc_uint32(tvb, tree, hf_hclnfsd_cookie, offset);
	offset = dissect_rpc_uint32(tvb, tree, hf_hclnfsd_status, offset);
	offset = dissect_rpc_uint32(tvb, tree, hf_hclnfsd_sequence, offset);

	return offset;
}


static int
dissect_hclnfsd_unshare_call(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
	return dissect_hclnfsd_share_call(tvb, pinfo, tree, data);
}


static int
dissect_hclnfsd_unshare_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
	return dissect_hclnfsd_share_reply(tvb, pinfo, tree, data);
}


static int
dissect_hclnfsd_lock_call(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
{
	int offset = 0;

	offset = dissect_rpc_uint32(tvb, tree, hf_hclnfsd_status, offset);
	offset = dissect_rpc_uint32(tvb, tree, hf_hclnfsd_cookie, offset);
	offset += 4; /* skip unused uint */

	offset = dissect_rpc_uint32(tvb, tree, hf_hclnfsd_exclusive, offset);

	offset = dissect_rpc_string(tvb, tree, hf_hclnfsd_lockname, offset, NULL);

	offset = dissect_nfs3_fh(tvb, offset, pinfo, tree, "Filehandle", NULL, (rpc_call_info_value*)data);

	offset = dissect_rpc_data(tvb, tree, hf_hclnfsd_lockowner, offset);

	offset += 4;  /* unused, skip */

	offset = dissect_rpc_uint32(tvb, tree, hf_hclnfsd_offset, offset);

	offset = dissect_rpc_uint32(tvb, tree, hf_hclnfsd_length, offset);

	return offset;
}


static int
dissect_hclnfsd_lock_reply(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
{
	guint32 request_type;
	int offset = 0;

	proto_tree_add_item_ret_uint(tree, hf_hclnfsd_request_type, tvb, offset,
			4, ENC_BIG_ENDIAN, &request_type);
	offset += 4;

	offset = dissect_rpc_uint32(tvb, tree, hf_hclnfsd_cookie, offset);
	offset = dissect_rpc_uint32(tvb, tree, hf_hclnfsd_status, offset);

	return offset;
}


static int
dissect_hclnfsd_remove_call(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
{
	int offset = 0;
	offset = dissect_rpc_string(tvb, tree, hf_hclnfsd_lockname, offset, NULL);

	offset += 4;  /* skip unused */

	return offset;
}


static int
dissect_hclnfsd_unlock_call(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
{
	int offset = 0;
	offset += 4;  /* skip unused */

	offset = dissect_rpc_uint32(tvb, tree, hf_hclnfsd_cookie, offset);

	offset = dissect_rpc_string(tvb, tree, hf_hclnfsd_lockname, offset, NULL);

	offset = dissect_nfs3_fh(tvb, offset, pinfo, tree, "Filehandle", NULL, (rpc_call_info_value*)data);

	offset = dissect_rpc_data(tvb, tree, hf_hclnfsd_unknown_data, offset);

	offset += 4;  /* skip unused */

	offset = dissect_rpc_uint32(tvb, tree, hf_hclnfsd_offset, offset);
	offset = dissect_rpc_uint32(tvb, tree, hf_hclnfsd_length, offset);

	return offset;
}


static int
dissect_hclnfsd_unlock_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
	return dissect_hclnfsd_lock_reply(tvb, pinfo, tree, data);
}


static int
dissect_hclnfsd_get_printers_reply(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
{
	guint nqueues, nqueues_i;
	proto_item *queuesitem = NULL;
	proto_tree *queuestree = NULL;
	int offset = 0;

	nqueues = tvb_get_ntohl(tvb, offset);
	if (tree)
	{
		queuesitem = proto_tree_add_item(tree, hf_hclnfsd_print_queues, tvb, offset, 4, ENC_BIG_ENDIAN);
		queuestree = proto_item_add_subtree(queuesitem, ett_hclnfsd_printqueues);
	}
	offset += 4;

	if (!queuestree)
		return offset;

	for (nqueues_i = 0; nqueues_i < nqueues; nqueues_i++)
	{
		/* create new item for print queue */
		offset = dissect_rpc_string(tvb, tree,
			hf_hclnfsd_queuename, offset, NULL);

		/* create subtree on new item with print queue comment */
		offset = dissect_rpc_string(tvb, tree,
			hf_hclnfsd_queuecomment, offset, NULL);
	}

	return offset;
}


static int
dissect_hclnfsd_get_printq_call(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
{
	int offset = 0;

	offset = dissect_rpc_string(tvb, tree, hf_hclnfsd_queuename, offset, NULL);

	offset = dissect_rpc_string(tvb, tree, hf_hclnfsd_username, offset, NULL);

	return offset;
}


static int
dissect_hclnfsd_get_printq_reply(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
{
	guint datafollows;
	proto_item *queueitem = NULL;
	proto_tree *queuetree = NULL;
	proto_item *jobitem;
	proto_tree *jobtree;
	int offset = 0;

	offset = dissect_rpc_uint32(tvb, tree, hf_hclnfsd_printqueuenumber, offset);

	offset = dissect_rpc_string(tvb, tree, hf_hclnfsd_queuecomment, offset, NULL);

	offset = dissect_rpc_uint32(tvb, tree, hf_hclnfsd_queuestatus, offset);

	offset = dissect_rpc_uint32(tvb, tree, hf_hclnfsd_numphysicalprinters, offset);

	datafollows = tvb_get_ntohl(tvb, offset);
	if (tree)
	{
		queueitem = proto_tree_add_item(tree, hf_hclnfsd_print_jobs, tvb, offset, 4, ENC_BIG_ENDIAN);
		queuetree = proto_item_add_subtree(queueitem, ett_hclnfsd_printqueues);
	}
	offset += 4;

	while (datafollows)
	{
		jobitem = proto_tree_add_item(queuetree, hf_hclnfsd_job_id, tvb, offset, 4, ENC_BIG_ENDIAN);
		offset += 4;

		jobtree = proto_item_add_subtree(jobitem, ett_hclnfsd_printjob);

		offset = dissect_rpc_string(tvb, jobtree,
			hf_hclnfsd_username, offset, NULL);

		offset = dissect_rpc_string(tvb, jobtree,
			hf_hclnfsd_printparams, offset, NULL);

		offset = dissect_rpc_uint32(tvb, jobtree, hf_hclnfsd_queuestatus, offset);

		offset = dissect_rpc_uint32(tvb, jobtree, hf_hclnfsd_jobstatus, offset);
		offset = dissect_rpc_uint32(tvb, jobtree, hf_hclnfsd_timesubmitted, offset);
		offset = dissect_rpc_uint32(tvb, jobtree, hf_hclnfsd_size, offset);
		offset = dissect_rpc_uint32(tvb, jobtree, hf_hclnfsd_copies, offset);
		offset = dissect_rpc_string(tvb, jobtree, hf_hclnfsd_queuecomment, offset, NULL);

		datafollows = tvb_get_ntohl(tvb, offset);
		offset += 4;
	}

	return offset;
}


/* proc number, "proc name", dissect_request, dissect_reply */

static const vsff hclnfsd1_proc[] = {
	{ HCLNFSDPROC_NULL, "NULL",
	  dissect_rpc_void, dissect_rpc_void },
	{ HCLNFSDPROC_SPOOL_INQUIRE, "SPOOL_INQUIRE",
	  dissect_hclnfsd_spool_inquire_call, dissect_rpc_unknown },
	{ HCLNFSDPROC_SPOOL_FILE, "SPOOL_FILE",
	  dissect_hclnfsd_spool_file_call, dissect_rpc_void },
	{ HCLNFSDPROC_AUTHORIZE, "AUTHORIZE",
	  dissect_hclnfsd_authorize_call, dissect_hclnfsd_authorize_reply },
	{ HCLNFSDPROC_GRP_NAME_TO_NUMB, "GRP_NAME_TO_NUMB",
	  dissect_hclnfsd_grp_name_to_numb_call, dissect_hclnfsd_grp_name_to_numb_reply },
	{ HCLNFSDPROC_GRP_TO_NUMBER, "GRP_TO_NUMBER",
	  dissect_hclnfsd_grp_to_number_call, dissect_hclnfsd_grp_to_number_reply },
	{ HCLNFSDPROC_RETURN_HOST, "RETURN_HOST",
	  dissect_hclnfsd_return_host_call, dissect_hclnfsd_return_host_reply },
	{ HCLNFSDPROC_UID_TO_NAME, "UID_TO_NAME",
	  dissect_hclnfsd_uid_to_name_call, dissect_hclnfsd_uid_to_name_reply },
	{ HCLNFSDPROC_NAME_TO_UID, "NAME_TO_UID",
	  dissect_hclnfsd_name_to_uid_call, dissect_hclnfsd_name_to_uid_reply },
	{ HCLNFSDPROC_SHARE, "SHARE",
	  dissect_hclnfsd_share_call, dissect_hclnfsd_share_reply },
	{ HCLNFSDPROC_UNSHARE, "UNSHARE",
	  dissect_hclnfsd_unshare_call, dissect_hclnfsd_unshare_reply },
	{ HCLNFSDPROC_LOCK, "LOCK",
	  dissect_hclnfsd_lock_call, dissect_hclnfsd_lock_reply },
	{ HCLNFSDPROC_REMOVE, "REMOVE",
	  dissect_hclnfsd_remove_call, dissect_rpc_void },
	{ HCLNFSDPROC_UNLOCK, "UNLOCK",
	  dissect_hclnfsd_unlock_call, dissect_hclnfsd_unlock_reply },
	{ HCLNFSDPROC_GET_PRINTERS, "GET_PRINTERS",
	  dissect_rpc_void, dissect_hclnfsd_get_printers_reply },
	{ HCLNFSDPROC_GET_PRINTQ, "GET_PRINTQ",
	  dissect_hclnfsd_get_printq_call, dissect_hclnfsd_get_printq_reply },
	{ HCLNFSDPROC_CANCEL_PRJOB, "CANCEL_PRJOB",
	  dissect_rpc_unknown, dissect_rpc_unknown },
	{ HCLNFSDPROC_ZAP_LOCKS, "ZAP_LOCKS",
	  dissect_rpc_unknown, dissect_rpc_unknown },
	{ 0, NULL, NULL, NULL }
};
static const rpc_prog_vers_info hclnfsd_vers_info[] = {
	{ 1, hclnfsd1_proc, &hf_hclnfsd_procedure_v1 },
};
static const value_string hclnfsd1_proc_vals[] = {
	{ HCLNFSDPROC_NULL,		"NULL" },
	{ HCLNFSDPROC_SPOOL_INQUIRE,	"SPOOL_INQUIRE" },
	{ HCLNFSDPROC_SPOOL_FILE,	"SPOOL_FILE" },
	{ HCLNFSDPROC_AUTHORIZE,	"AUTHORIZE" },
	{ HCLNFSDPROC_GRP_NAME_TO_NUMB, "GRP_NAME_TO_NUMB" },
	{ HCLNFSDPROC_GRP_TO_NUMBER,	"GRP_TO_NUMBER" },
	{ HCLNFSDPROC_RETURN_HOST,	"RETURN_HOST" },
	{ HCLNFSDPROC_UID_TO_NAME,	"UID_TO_NAME" },
	{ HCLNFSDPROC_NAME_TO_UID,	"NAME_TO_UID" },
	{ HCLNFSDPROC_SHARE,		"SHARE" },
	{ HCLNFSDPROC_UNSHARE,		"UNSHARE" },
	{ HCLNFSDPROC_LOCK,		"LOCK" },
	{ HCLNFSDPROC_REMOVE,		"REMOVE" },
	{ HCLNFSDPROC_UNLOCK,		"UNLOCK" },
	{ HCLNFSDPROC_GET_PRINTERS,	"GET_PRINTERS" },
	{ HCLNFSDPROC_GET_PRINTQ,	"GET_PRINTQ" },
	{ HCLNFSDPROC_CANCEL_PRJOB,	"CANCEL_PRJOB" },
	{ HCLNFSDPROC_ZAP_LOCKS,	"ZAP_LOCKS" },
	{ 0, NULL }
};
/* end of hclnfsd version 1 */


void
proto_register_hclnfsd(void)
{
	static hf_register_info hf[] = {
		{ &hf_hclnfsd_procedure_v1, {
				"V1 Procedure", "hclnfsd.procedure_v1", FT_UINT32, BASE_DEC,
				VALS(hclnfsd1_proc_vals), 0, NULL, HFILL }},
		{ &hf_hclnfsd_request_type, {
				"Request Type", "hclnfsd.request_type", FT_UINT32, BASE_DEC,
				VALS(names_request_type), 0, NULL, HFILL }},

		{ &hf_hclnfsd_device, {
				"Device", "hclnfsd.device", FT_STRING, BASE_NONE,
				NULL, 0, NULL, HFILL }},

#if 0
		{ &hf_hclnfsd_login, {
				"Login Text", "hclnfsd.logintext", FT_STRING, BASE_NONE,
				NULL, 0, NULL, HFILL }},
#endif

		{ &hf_hclnfsd_lockname, {
				"Lockname", "hclnfsd.lockname", FT_STRING, BASE_NONE,
				NULL, 0, NULL, HFILL }},

		{ &hf_hclnfsd_unknown_data, {
				"Unknown", "hclnfsd.unknown_data", FT_BYTES, BASE_NONE,
				NULL, 0, "Data", HFILL }},

		{ &hf_hclnfsd_lockowner, {
				"Lockowner", "hclnfsd.lockowner", FT_BYTES, BASE_NONE,
				NULL, 0, NULL, HFILL }},

		{ &hf_hclnfsd_printername, {
				"Printer Name", "hclnfsd.printername", FT_STRING, BASE_NONE,
				NULL, 0, NULL, HFILL }},

		{ &hf_hclnfsd_filename, {
				"Filename", "hclnfsd.filename", FT_STRING, BASE_NONE,
				NULL, 0, NULL, HFILL }},

		{ &hf_hclnfsd_fileext, {
				"File Extension", "hclnfsd.fileext", FT_UINT32, BASE_DEC,
				NULL, 0, NULL, HFILL }},

		{ &hf_hclnfsd_grpname, {
				"Group", "hclnfsd.group", FT_STRING, BASE_NONE,
				NULL, 0, NULL, HFILL }},

		{ &hf_hclnfsd_hostname, {
				"Hostname", "hclnfsd.hostname", FT_STRING, BASE_NONE,
				NULL, 0, NULL, HFILL }},

		{ &hf_hclnfsd_username, {
				"Username", "hclnfsd.username", FT_STRING, BASE_NONE,
				NULL, 0, NULL, HFILL }},

		{ &hf_hclnfsd_queuename, {
				"Name", "hclnfsd.printqueuename", FT_STRING, BASE_NONE,
				NULL, 0, "Print Queue Name", HFILL }},

		{ &hf_hclnfsd_queuecomment, {
				"Comment", "hclnfsd.printqueuecomment", FT_STRING, BASE_NONE,
				NULL, 0, "Print Queue Comment", HFILL }},

		{ &hf_hclnfsd_printparams, {
				"Print Parameters", "hclnfsd.printparameters", FT_STRING, BASE_NONE,
				NULL, 0, NULL, HFILL }},

		{ &hf_hclnfsd_status, {
				"Status", "hclnfsd.status", FT_UINT32, BASE_DEC,
				NULL, 0, NULL, HFILL }},

		{ &hf_hclnfsd_uid, {
				"UID", "hclnfsd.uid", FT_UINT32, BASE_DEC,
				NULL, 0, "User ID", HFILL }},

		{ &hf_hclnfsd_sequence, {
				"Sequence", "hclnfsd.sequence", FT_UINT32, BASE_HEX,
				NULL, 0, NULL, HFILL }},

		{ &hf_hclnfsd_cookie, {
				"Cookie", "hclnfsd.cookie", FT_UINT32, BASE_HEX,
				NULL, 0, NULL, HFILL }},

		{ &hf_hclnfsd_mode, {
				"Mode", "hclnfsd.mode", FT_UINT32, BASE_DEC,
				NULL, 0, NULL, HFILL }},

		{ &hf_hclnfsd_access, {
				"Access", "hclnfsd.access", FT_UINT32, BASE_DEC,
				NULL, 0, NULL, HFILL }},

		{ &hf_hclnfsd_exclusive, {
				"Exclusive", "hclnfsd.exclusive", FT_UINT32, BASE_DEC,
				NULL, 0, NULL, HFILL }},

		{ &hf_hclnfsd_offset, {
				"Offset", "hclnfsd.offset", FT_UINT32, BASE_DEC,
				NULL, 0, NULL, HFILL }},

		{ &hf_hclnfsd_length, {
				"Length", "hclnfsd.length", FT_UINT32, BASE_DEC,
				NULL, 0, NULL, HFILL }},

		{ &hf_hclnfsd_queuestatus, {
				"Queue Status", "hclnfsd.queuestatus", FT_UINT32, BASE_DEC,
				NULL, 0, NULL, HFILL }},

		{ &hf_hclnfsd_printqueuenumber, {
				"Print Queue Number", "hclnfsd.pqn", FT_UINT32, BASE_DEC,
				NULL, 0, NULL, HFILL }},

		{ &hf_hclnfsd_numphysicalprinters, {
				"Number of Physical Printers", "hclnfsd.npp", FT_UINT32, BASE_DEC,
				NULL, 0, NULL, HFILL }},

		{ &hf_hclnfsd_jobstatus, {
				"Job Status", "hclnfsd.jobstatus", FT_UINT32, BASE_DEC,
				NULL, 0, NULL, HFILL }},

		{ &hf_hclnfsd_timesubmitted, {
				"Time Submitted", "hclnfsd.timesubmitted", FT_UINT32, BASE_DEC,
				NULL, 0, NULL, HFILL }},

		{ &hf_hclnfsd_size, {
				"Size", "hclnfsd.size", FT_UINT32, BASE_DEC,
				NULL, 0, NULL, HFILL }},

		{ &hf_hclnfsd_copies, {
				"Copies", "hclnfsd.copies", FT_UINT32, BASE_DEC,
				NULL, 0, NULL, HFILL }},

		{ &hf_hclnfsd_gid, {
				"GID", "hclnfsd.gid", FT_UINT32, BASE_DEC,
				NULL, 0, "Group ID", HFILL }},

		{ &hf_hclnfsd_server_ip, {
				"Server IP", "hclnfsd.server_ip", FT_IPv4, BASE_NONE,
				NULL, 0, NULL, HFILL }},

		{ &hf_hclnfsd_host_ip, {
				"Host IP", "hclnfsd.host_ip", FT_IPv4, BASE_NONE,
				NULL, 0, NULL, HFILL }},

		{ &hf_hclnfsd_auth_ident_obscure, {
				"Obscure Ident", "hclnfsd.authorize.ident.obscure", FT_STRING,
				BASE_NONE	, NULL, 0, "Authentication Obscure Ident", HFILL }},

		/* Generated from convert_proto_tree_add_text.pl */
		{ &hf_hclnfsd_gids,
		  { "GIDs", "hclnfsd.gids",
		    FT_UINT32, BASE_DEC, NULL, 0x0,
		    NULL, HFILL }
		},
		{ &hf_hclnfsd_password,
		  { "Password", "hclnfsd.password",
		    FT_STRING, BASE_NONE, NULL, 0x0,
		    NULL, HFILL }
		},
		{ &hf_hclnfsd_uids,
		  { "UIDs", "hclnfsd.uids",
		    FT_UINT32, BASE_DEC, NULL, 0x0,
		    NULL, HFILL }
		},
		{ &hf_hclnfsd_print_queues,
		  { "Print Queues", "hclnfsd.print_queues",
		    FT_UINT32, BASE_DEC, NULL, 0x0,
		    NULL, HFILL }
		},
		{ &hf_hclnfsd_print_jobs,
		  { "Print Jobs", "hclnfsd.print_jobs",
		    FT_UINT32, BASE_DEC, NULL, 0x0,
		    NULL, HFILL }
		},
		{ &hf_hclnfsd_job_id,
		  { "Job ID", "hclnfsd.job_id",
		    FT_UINT32, BASE_DEC, NULL, 0x0,
		    NULL, HFILL }
		},
	};
	static gint *ett[] = {
		&ett_hclnfsd,
		&ett_hclnfsd_gids,
		&ett_hclnfsd_groups,
		&ett_hclnfsd_uids,
		&ett_hclnfsd_usernames,
		&ett_hclnfsd_printqueues,
		&ett_hclnfsd_printjob,
		&ett_hclnfsd_auth_ident
	};

	proto_hclnfsd = proto_register_protocol("Hummingbird NFS Daemon",
		"HCLNFSD", "hclnfsd");
	proto_register_field_array(proto_hclnfsd, hf, array_length(hf));
	proto_register_subtree_array(ett, array_length(ett));
}

void
proto_reg_handoff_hclnfsd(void)
{
	/* Register the protocol as RPC */
	rpc_init_prog(proto_hclnfsd, HCLNFSD_PROGRAM, ett_hclnfsd,
	    G_N_ELEMENTS(hclnfsd_vers_info), hclnfsd_vers_info);
}

/*
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
 *
 * Local variables:
 * c-basic-offset: 8
 * tab-width: 8
 * indent-tabs-mode: t
 * End:
 *
 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
 * :indentSize=8:tabSize=8:noTabs=false:
 */