forked from wireshark/wireshark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpacket-afs.c
2612 lines (2406 loc) · 68.6 KB
/
packet-afs.c
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
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* packet-afs.c
* Routines for AFS packet dissection
* Copyright 1999, Nathan Neulinger <nneul@umr.edu>
* Based on routines from tcpdump patches by
* Ken Hornstein <kenh@cmf.nrl.navy.mil>
* Portions based on information retrieved from the RX definitions
* in Arla, the free AFS client at http://www.stacken.kth.se/project/arla/
*
* $Id: packet-afs.c,v 1.13 2000/08/13 14:07:56 deniel Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
* Copyright 1998 Gerald Combs
*
* Copied from packet-tftp.c
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#include <string.h>
#include <glib.h>
#include "packet.h"
#include "conversation.h"
#include "packet-rx.h"
#include "packet-afs.h"
#include "resolv.h"
static const value_string fs_req[] = {
{ 130, "fetch-data" },
{ 131, "fetch-acl" },
{ 132, "fetch-status" },
{ 133, "store-data" },
{ 134, "store-acl" },
{ 135, "store-status" },
{ 136, "remove-file" },
{ 137, "create-file" },
{ 138, "rename" },
{ 139, "symlink" },
{ 140, "link" },
{ 141, "makedir" },
{ 142, "rmdir" },
{ 143, "oldsetlock" },
{ 144, "oldextlock" },
{ 145, "oldrellock" },
{ 146, "get-stats" },
{ 147, "give-cbs" },
{ 148, "get-vlinfo" },
{ 149, "get-vlstats" },
{ 150, "set-vlstats" },
{ 151, "get-rootvl" },
{ 152, "check-token" },
{ 153, "get-time" },
{ 154, "nget-vlinfo" },
{ 155, "bulk-stat" },
{ 156, "setlock" },
{ 157, "extlock" },
{ 158, "rellock" },
{ 159, "xstat-ver" },
{ 160, "get-xstat" },
{ 161, "dfs-lookup" },
{ 162, "dfs-flushcps" },
{ 163, "dfs-symlink" },
{ 0, NULL },
};
static const value_string cb_req[] = {
{ 204, "callback" },
{ 205, "initcb" },
{ 206, "probe" },
{ 207, "getlock" },
{ 208, "getce" },
{ 209, "xstatver" },
{ 210, "getxstat" },
{ 211, "initcb2" },
{ 212, "whoareyou" },
{ 213, "initcb3" },
{ 214, "probeuuid" },
{ 0, NULL },
};
static const value_string prot_req[] = {
{ 500, "new-user" },
{ 501, "where-is-it" },
{ 502, "dump-entry" },
{ 503, "add-to-group" },
{ 504, "name-to-id" },
{ 505, "id-to-name" },
{ 506, "delete" },
{ 507, "remove-from-group" },
{ 508, "get-cps" },
{ 509, "new-entry" },
{ 510, "list-max" },
{ 511, "set-max" },
{ 512, "list-entry" },
{ 513, "change-entry" },
{ 514, "list-elements" },
{ 515, "same-mbr-of" },
{ 516, "set-fld-sentry" },
{ 517, "list-owned" },
{ 518, "get-cps2" },
{ 519, "get-host-cps" },
{ 520, "update-entry" },
{ 0, NULL },
};
static const value_string vldb_req[] = {
{ 501, "create-entry" },
{ 502, "delete-entry" },
{ 503, "get-entry-by-id" },
{ 504, "get-entry-by-name" },
{ 505, "get-new-volume-id" },
{ 506, "replace-entry" },
{ 507, "update-entry" },
{ 508, "setlock" },
{ 509, "releaselock" },
{ 510, "list-entry" },
{ 511, "list-attrib" },
{ 512, "linked-list" },
{ 513, "get-stats" },
{ 514, "probe" },
{ 515, "get-addrs" },
{ 516, "change-addr" },
{ 517, "create-entry-n" },
{ 518, "get-entry-by-id-n" },
{ 519, "get-entry-by-name-n" },
{ 520, "replace-entry-n" },
{ 521, "list-entry-n" },
{ 522, "list-attrib-n" },
{ 523, "linked-list-n" },
{ 524, "update-entry-by-name" },
{ 525, "create-entry-u" },
{ 526, "get-entry-by-id-u" },
{ 527, "get-entry-by-name-u" },
{ 528, "replace-entry-u" },
{ 529, "list-entry-u" },
{ 530, "list-attrib-u" },
{ 531, "linked-list-u" },
{ 532, "regaddr" },
{ 533, "get-addrs-u" },
{ 0, NULL },
};
static const value_string kauth_req[] = {
{ 1, "auth-old" },
{ 21, "authenticate" },
{ 22, "authenticate-v2" },
{ 2, "change-pw" },
{ 3, "get-ticket-old" },
{ 23, "get-ticket" },
{ 4, "set-pw" },
{ 5, "set-fields" },
{ 6, "create-user" },
{ 7, "delete-user" },
{ 8, "get-entry" },
{ 9, "list-entry" },
{ 10, "get-stats" },
{ 11, "debug" },
{ 12, "get-pw" },
{ 13, "get-random-key" },
{ 14, "unlock" },
{ 15, "lock-status" },
{ 0, NULL },
};
static const value_string vol_req[] = {
{ 100, "create-volume" },
{ 101, "delete-volume" },
{ 102, "restore" },
{ 103, "forward" },
{ 104, "end-trans" },
{ 105, "clone" },
{ 106, "set-flags" },
{ 107, "get-flags" },
{ 108, "trans-create" },
{ 109, "dump" },
{ 110, "get-nth-volume" },
{ 111, "set-forwarding" },
{ 112, "get-name" },
{ 113, "get-status" },
{ 114, "sig-restore" },
{ 115, "list-partitions" },
{ 116, "list-volumes" },
{ 117, "set-id-types" },
{ 118, "monitor" },
{ 119, "partition-info" },
{ 120, "reclone" },
{ 121, "list-one-volume" },
{ 122, "nuke" },
{ 123, "set-date" },
{ 124, "x-list-volumes" },
{ 125, "x-list-one-volume" },
{ 126, "set-info" },
{ 127, "x-list-partitions" },
{ 128, "forward-multiple" },
{ 0, NULL },
};
static const value_string bos_req[] = {
{ 80, "create-bnode" },
{ 81, "delete-bnode" },
{ 82, "set-status" },
{ 83, "get-status" },
{ 84, "enumerate-instance" },
{ 85, "get-instance-info" },
{ 86, "get-instance-parm" },
{ 87, "add-superuser" },
{ 88, "delete-superuser" },
{ 89, "list-superusers" },
{ 90, "list-keys" },
{ 91, "add-key" },
{ 92, "delete-key" },
{ 93, "set-cell-name" },
{ 94, "get-cell-name" },
{ 95, "get-cell-host" },
{ 96, "add-cell-host" },
{ 97, "delete-cell-host" },
{ 98, "set-t-status" },
{ 99, "shutdown-all" },
{ 100, "restart-all" },
{ 101, "startup-all" },
{ 102, "set-noauth-flag" },
{ 103, "re-bozo" },
{ 104, "restart" },
{ 105, "start-bozo-install" },
{ 106, "uninstall" },
{ 107, "get-dates" },
{ 108, "exec" },
{ 109, "prune" },
{ 110, "set-restart-time" },
{ 111, "get-restart-time" },
{ 112, "start-bozo-log" },
{ 113, "wait-all" },
{ 114, "get-instance-strings" },
{ 0, NULL },
};
static const value_string ubik_req[] = {
{ 10000, "vote-beacon" },
{ 10001, "vote-debug-old" },
{ 10002, "vote-sdebug-old" },
{ 10003, "vote-getsyncsite" },
{ 10004, "vote-debug" },
{ 10005, "vote-sdebug" },
{ 20000, "disk-begin" },
{ 20001, "disk-commit" },
{ 20002, "disk-lock" },
{ 20003, "disk-write" },
{ 20004, "disk-getversion" },
{ 20005, "disk-getfile" },
{ 20006, "disk-sendfile" },
{ 20007, "disk-abort" },
{ 20008, "disk-releaselocks" },
{ 20009, "disk-truncate" },
{ 20010, "disk-probe" },
{ 20011, "disk-writev" },
{ 20012, "disk-interfaceaddr" },
{ 20013, "disk-setversion" },
{ 0, NULL },
};
static const value_string cb_types[] = {
{ CB_TYPE_EXCLUSIVE, "exclusive" },
{ CB_TYPE_SHARED, "shared" },
{ CB_TYPE_DROPPED, "dropped" },
{ 0, NULL },
};
static const value_string afs_errors[] = {
/* VOL Errors */
{ 363520, "ID Exists"},
{ 363521, "IO Error"},
{ 363522, "Name Exists"},
{ 363523, "Create Failed"},
{ 363524, "Entry Not Found"},
{ 363525, "Empty"},
{ 363526, "Entry Deleted"},
{ 363527, "Bad Name"},
{ 363528, "Bad Index"},
{ 363529, "Bad Volume Type"},
{ 363530, "Bad Partition"},
{ 363531, "Bad Server"},
{ 363532, "Bad Replicate Server"},
{ 363533, "No Replicate Server"},
{ 363534, "Duplicate Replicate Server"},
{ 363535, "ReadWrite Volume Not Found"},
{ 363536, "Bad Reference Count"},
{ 363537, "Size Exceeded"},
{ 363538, "Bad Entry"},
{ 363539, "Bad Volume ID Bump"},
{ 363540, "Already has edit"},
{ 363541, "Entry Locked"},
{ 363542, "Bad Volume Operation"},
{ 363543, "Bad Rel Lock Type"},
{ 363544, "Rerelease"},
{ 363545, "Bad Server"},
{ 363546, "Permission Denied"},
{ 363547, "Out of Memory"},
/* KAUTH Errors */
{ 180480, "Database Inconsistent"},
{ 180481, "Exists"},
{ 180482, "IO"},
{ 180483, "Create Failed"},
{ 180484, "noent"},
{ 180485, "Empty"},
{ 180486, "Bad Name"},
{ 180487, "Bad Index"},
{ 180488, "No auth"},
{ 180489, "Answer too long"},
{ 180490, "Bad Request"},
{ 180491, "Old Interface"},
{ 180492, "Bad Argument"},
{ 180493, "Bad Command"},
{ 180494, "No keys"},
{ 180495, "Read PW"},
{ 180496, "Bad key"},
{ 180497, "Ubik Init"},
{ 180498, "Ubik Call"},
{ 180499, "Bad Protocol"},
{ 180500, "No cells"},
{ 180501, "No cell"},
{ 180502, "Too many ubiks"},
{ 180503, "Too many keys"},
{ 180504, "Bad ticket"},
{ 180505, "Unknown Key"},
{ 180506, "Key Cache Invalid"},
{ 180507, "Bad Server"},
{ 180508, "Bad User"},
{ 180509, "Bad CPW"},
{ 180510, "Bad Create"},
{ 180511, "No ticket"},
{ 180512, "Assoc user"},
{ 180513, "Not special"},
{ 180514, "Clock skew too great"},
{ 180515, "No recursion"},
{ 180516, "RX failed"},
{ 180517, "Null password"},
{ 180518, "Internal error"},
{ 180519, "Password expired"},
{ 180520, "Reused"},
{ 180521, "Too soon"},
{ 180522, "Locked"},
/* PT Errors */
{ 267264, "Exists"},
{ 267265, "ID Exists"},
{ 267266, "No IDs"},
{ 267267, "DB Failed"},
{ 267268, "No such entry"},
{ 267269, "Permission denied"},
{ 267270, "Not group"},
{ 267271, "Not user"},
{ 267272, "Bad name"},
{ 267273, "Bad argument"},
{ 267274, "No more"},
{ 267275, "Bad DB"},
{ 267276, "Group empty"},
{ 267277, "Inconsistent"},
{ 267278, "DB Address"},
{ 267279, "Too many"},
{ 267280, "No memory"},
/* Volume server errors */
{ 1492325120, "Release error"},
{ 1492325121, "No op"},
{ 1492325122, "Read dump error"},
{ 1492325123, "Dump error"},
{ 1492325124, "Attach error"},
{ 1492325125, "Illegal partition"},
{ 1492325126, "Detach error"},
{ 1492325127, "Bad access"},
{ 1492325128, "VLDB error"},
{ 1492325129, "Bad Name"},
{ 1492325130, "Volume moved"},
{ 1492325131, "Bad operation"},
{ 1492325132, "Bad release"},
{ 1492325133, "Volume busy"},
{ 1492325134, "No memory"},
{ 1492325135, "No volume"},
{ 1492325136, "Multiple RW volumes"},
{ 1492325137, "Failed operation"},
/* add more of these errors to decode the errcode responses */
{ 0, NULL },
};
static const value_string port_types[] = {
{ AFS_PORT_FS, "File Server" },
{ AFS_PORT_CB, "Callback Server" },
{ AFS_PORT_BOS, "BOS Server" },
{ AFS_PORT_PROT, "Protection Server" },
{ AFS_PORT_VLDB, "Volume Location Database Server" },
{ AFS_PORT_KAUTH, "Kerberos Authentication Server" },
{ AFS_PORT_ERROR, "Error Server" },
{ AFS_PORT_VOL, "Volume Server" },
{ AFS_PORT_RMTSYS, "Rmtsys? Server" },
{ AFS_PORT_UPDATE, "Update? Server" },
{ AFS_PORT_BACKUP, "Backup Server" },
{ 0, NULL }
};
static const value_string port_types_short[] = {
{ AFS_PORT_FS, "FS" },
{ AFS_PORT_CB, "CB" },
{ AFS_PORT_BOS, "BOS" },
{ AFS_PORT_PROT, "PROT" },
{ AFS_PORT_VLDB, "VLDB" },
{ AFS_PORT_KAUTH, "KAUTH" },
{ AFS_PORT_ERROR, "ERR" },
{ AFS_PORT_VOL, "VOL" },
{ AFS_PORT_RMTSYS, "RMT" },
{ AFS_PORT_UPDATE, "UPD" },
{ AFS_PORT_BACKUP, "BKUP" },
{ 0, NULL }
};
static const value_string ubik_lock_types[] = {
{ 1, "read" },
{ 2, "write" },
{ 3, "wait" },
{ 0, NULL },
};
static const value_string volume_types[] = {
{ 0, "read-write" },
{ 1, "read-only" },
{ 2, "backup" },
{ 0, NULL },
};
int afs_packet_init_count = 100;
struct afs_request_key {
guint32 conversation, callnumber;
guint16 service;
};
struct afs_request_val {
guint32 opcode;
};
GHashTable *afs_request_hash = NULL;
GMemChunk *afs_request_keys = NULL;
GMemChunk *afs_request_vals = NULL;
static int proto_afs = -1;
static int hf_afs_fs = -1;
static int hf_afs_cb = -1;
static int hf_afs_prot = -1;
static int hf_afs_vldb = -1;
static int hf_afs_kauth = -1;
static int hf_afs_vol = -1;
static int hf_afs_error = -1;
static int hf_afs_bos = -1;
static int hf_afs_update = -1;
static int hf_afs_rmtsys = -1;
static int hf_afs_ubik = -1;
static int hf_afs_backup = -1;
static int hf_afs_fs_opcode = -1;
static int hf_afs_cb_opcode = -1;
static int hf_afs_prot_opcode = -1;
static int hf_afs_vldb_opcode = -1;
static int hf_afs_kauth_opcode = -1;
static int hf_afs_vol_opcode = -1;
static int hf_afs_error_opcode = -1;
static int hf_afs_bos_opcode = -1;
static int hf_afs_update_opcode = -1;
static int hf_afs_rmtsys_opcode = -1;
static int hf_afs_ubik_opcode = -1;
static int hf_afs_backup_opcode = -1;
static int hf_afs_fs_fid_volume = -1;
static int hf_afs_fs_fid_vnode = -1;
static int hf_afs_fs_fid_uniqifier = -1;
static int hf_afs_fs_offset = -1;
static int hf_afs_fs_length = -1;
static int hf_afs_fs_flength = -1;
static int hf_afs_fs_errcode = -1;
static int hf_afs_fs_data = -1;
static int hf_afs_fs_name = -1;
static int hf_afs_fs_oldname = -1;
static int hf_afs_fs_newname = -1;
static int hf_afs_fs_symlink_name = -1;
static int hf_afs_fs_symlink_content = -1;
static int hf_afs_fs_volid = -1;
static int hf_afs_fs_volname = -1;
static int hf_afs_fs_timestamp = -1;
static int hf_afs_fs_acl_datasize = -1;
static int hf_afs_fs_acl_count_negative = -1;
static int hf_afs_fs_acl_count_positive = -1;
static int hf_afs_fs_acl_entity = -1;
static int hf_afs_fs_acl_r = -1;
static int hf_afs_fs_acl_l = -1;
static int hf_afs_fs_acl_i = -1;
static int hf_afs_fs_acl_d = -1;
static int hf_afs_fs_acl_w = -1;
static int hf_afs_fs_acl_k = -1;
static int hf_afs_fs_acl_a = -1;
static int hf_afs_fs_callback_version = -1;
static int hf_afs_fs_callback_expires = -1;
static int hf_afs_fs_callback_type = -1;
static int hf_afs_bos_errcode = -1;
static int hf_afs_bos_type = -1;
static int hf_afs_bos_instance = -1;
static int hf_afs_bos_status = -1;
static int hf_afs_bos_num = -1;
static int hf_afs_bos_size = -1;
static int hf_afs_bos_flags = -1;
static int hf_afs_bos_date = -1;
static int hf_afs_bos_content = -1;
static int hf_afs_vldb_errcode = -1;
static int hf_afs_vldb_name = -1;
static int hf_afs_vldb_id = -1;
static int hf_afs_vldb_type = -1;
static int hf_afs_vldb_bump = -1;
static int hf_afs_vldb_index = -1;
static int hf_afs_vldb_nextindex = -1;
static int hf_afs_vldb_count = -1;
static int hf_afs_vldb_numservers = -1;
static int hf_afs_vldb_server = -1;
static int hf_afs_vldb_serveruuid = -1;
static int hf_afs_vldb_partition = -1;
static int hf_afs_vldb_rovol = -1;
static int hf_afs_vldb_rwvol = -1;
static int hf_afs_vldb_bkvol = -1;
static int hf_afs_kauth_errcode = -1;
static int hf_afs_kauth_princ = -1;
static int hf_afs_kauth_realm = -1;
static int hf_afs_kauth_domain = -1;
static int hf_afs_kauth_kvno = -1;
static int hf_afs_kauth_name = -1;
static int hf_afs_kauth_data = -1;
static int hf_afs_vol_errcode = -1;
static int hf_afs_vol_count = -1;
static int hf_afs_vol_id = -1;
static int hf_afs_vol_name = -1;
static int hf_afs_cb_errcode = -1;
static int hf_afs_cb_callback_version = -1;
static int hf_afs_cb_callback_type = -1;
static int hf_afs_cb_callback_expires = -1;
static int hf_afs_cb_fid_volume = -1;
static int hf_afs_cb_fid_vnode = -1;
static int hf_afs_cb_fid_uniqifier = -1;
static int hf_afs_prot_errcode = -1;
static int hf_afs_prot_name = -1;
static int hf_afs_prot_id = -1;
static int hf_afs_prot_count = -1;
static int hf_afs_prot_oldid = -1;
static int hf_afs_prot_newid = -1;
static int hf_afs_prot_pos = -1;
static int hf_afs_prot_flag = -1;
static int hf_afs_prot_uid = -1;
static int hf_afs_prot_gid = -1;
static int hf_afs_prot_maxuid = -1;
static int hf_afs_prot_maxgid = -1;
static int hf_afs_backup_errcode = -1;
static int hf_afs_ubik_errcode = -1;
static int hf_afs_ubik_version_epoch = -1;
static int hf_afs_ubik_version_counter = -1;
static int hf_afs_ubik_votestart = -1;
static int hf_afs_ubik_syncsite = -1;
static int hf_afs_ubik_site = -1;
static int hf_afs_ubik_file = -1;
static int hf_afs_ubik_pos = -1;
static int hf_afs_ubik_length = -1;
static int hf_afs_ubik_locktype = -1;
static int hf_afs_ubik_voteend = -1;
static int hf_afs_ubik_votetype = -1;
static gint ett_afs = -1;
static gint ett_afs_op = -1;
static gint ett_afs_acl = -1;
static gint ett_afs_fid = -1;
static gint ett_afs_callback = -1;
static gint ett_afs_ubikver = -1;
/*
* Dissector prototypes
*/
static void dissect_fs_request(const u_char *pd,
int offset, frame_data *fd, proto_tree *tree, int opcode);
static void dissect_fs_reply(const u_char *pd,
int offset, frame_data *fd, proto_tree *tree, int opcode);
static void dissect_cb_request(const u_char *pd,
int offset, frame_data *fd, proto_tree *tree, int opcode);
static void dissect_cb_reply(const u_char *pd,
int offset, frame_data *fd, proto_tree *tree, int opcode);
static void dissect_bos_request(const u_char *pd,
int offset, frame_data *fd, proto_tree *tree, int opcode);
static void dissect_bos_reply(const u_char *pd,
int offset, frame_data *fd, proto_tree *tree, int opcode);
static void dissect_vol_request(const u_char *pd,
int offset, frame_data *fd, proto_tree *tree, int opcode);
static void dissect_vol_reply(const u_char *pd,
int offset, frame_data *fd, proto_tree *tree, int opcode);
static void dissect_ubik_request(const u_char *pd,
int offset, frame_data *fd, proto_tree *tree, int opcode);
static void dissect_ubik_reply(const u_char *pd,
int offset, frame_data *fd, proto_tree *tree, int opcode);
static void dissect_kauth_request(const u_char *pd,
int offset, frame_data *fd, proto_tree *tree, int opcode);
static void dissect_kauth_reply(const u_char *pd,
int offset, frame_data *fd, proto_tree *tree, int opcode);
static void dissect_prot_request(const u_char *pd,
int offset, frame_data *fd, proto_tree *tree, int opcode);
static void dissect_prot_reply(const u_char *pd,
int offset, frame_data *fd, proto_tree *tree, int opcode);
static void dissect_vldb_request(const u_char *pd,
int offset, frame_data *fd, proto_tree *tree, int opcode);
static void dissect_vldb_reply(const u_char *pd,
int offset, frame_data *fd, proto_tree *tree, int opcode);
static void dissect_backup_request(const u_char *pd,
int offset, frame_data *fd, proto_tree *tree, int opcode);
static void dissect_backup_reply(const u_char *pd,
int offset, frame_data *fd, proto_tree *tree, int opcode);
/*
* Hash Functions - copied from packet-afs.c
*/
gint
afs_equal(gconstpointer v, gconstpointer w)
{
struct afs_request_key *v1 = (struct afs_request_key *)v;
struct afs_request_key *v2 = (struct afs_request_key *)w;
if (v1 -> conversation == v2 -> conversation &&
v1 -> service == v2 -> service &&
v1 -> callnumber == v2 -> callnumber ) {
return 1;
}
return 0;
}
guint
afs_hash (gconstpointer v)
{
struct afs_request_key *key = (struct afs_request_key *)v;
guint val;
val = key -> conversation + key -> service + key -> callnumber;
return val;
}
/*
* Protocol initialization
*/
static void
afs_init_protocol(void)
{
if (afs_request_hash)
g_hash_table_destroy(afs_request_hash);
if (afs_request_keys)
g_mem_chunk_destroy(afs_request_keys);
if (afs_request_vals)
g_mem_chunk_destroy(afs_request_vals);
afs_request_hash = g_hash_table_new(afs_hash, afs_equal);
afs_request_keys = g_mem_chunk_new("afs_request_keys",
sizeof(struct afs_request_key),
afs_packet_init_count * sizeof(struct afs_request_key),
G_ALLOC_AND_FREE);
afs_request_vals = g_mem_chunk_new("afs_request_vals",
sizeof(struct afs_request_val),
afs_packet_init_count * sizeof(struct afs_request_val),
G_ALLOC_AND_FREE);
}
/*
* Dissection routines
*/
void
dissect_afs(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
{
proto_tree *afs_tree, *afs_op_tree, *ti;
struct rx_header *rxh;
struct afs_header *afsh;
int port, node, typenode, opcode;
value_string const *vals;
int reply = 0;
int doffset = 0;
conversation_t *conversation;
struct afs_request_key request_key, *new_request_key;
struct afs_request_val *request_val;
void (*dissector)(const u_char *pd, int offset,
frame_data *fd, proto_tree *tree, int opcode);
OLD_CHECK_DISPLAY_AS_DATA(proto_afs, pd, offset, fd, tree);
rxh = (struct rx_header *) &pd[offset];
doffset = offset + sizeof(struct rx_header);
afsh = (struct afs_header *) &pd[doffset];
/* get at least a full packet structure */
if ( !BYTES_ARE_IN_FRAME(offset, sizeof(struct rx_header)) )
return;
if (check_col(fd, COL_PROTOCOL))
col_add_str(fd, COL_PROTOCOL, "AFS (RX)");
reply = (rxh->flags & RX_CLIENT_INITIATED) == 0;
port = ((reply == 0) ? pi.destport : pi.srcport );
/*
* Find out what conversation this packet is part of.
* XXX - this should really be done by the transport-layer protocol,
* although for connectionless transports, we may not want to do that
* unless we know some higher-level protocol will want it - or we
* may want to do it, so you can say e.g. "show only the packets in
* this UDP 'connection'".
*
* Note that we don't have to worry about the direction this packet
* was going - the conversation code handles that for us, treating
* packets from A:X to B:Y as being part of the same conversation as
* packets from B:Y to A:X.
*/
conversation = find_conversation(&pi.src, &pi.dst, pi.ptype,
pi.srcport, pi.destport);
if (conversation == NULL) {
/* It's not part of any conversation - create a new one. */
conversation = conversation_new(&pi.src, &pi.dst, pi.ptype,
pi.srcport, pi.destport, NULL);
}
request_key.conversation = conversation->index;
request_key.service = pntohs(&rxh->serviceId);
request_key.callnumber = pntohl(&rxh->callNumber);
request_val = (struct afs_request_val *) g_hash_table_lookup(
afs_request_hash, &request_key);
/* only allocate a new hash element when it's a request */
opcode = 0;
if ( !request_val && !reply)
{
new_request_key = g_mem_chunk_alloc(afs_request_keys);
*new_request_key = request_key;
request_val = g_mem_chunk_alloc(afs_request_vals);
request_val -> opcode = pntohl(&afsh->opcode);
opcode = request_val->opcode;
g_hash_table_insert(afs_request_hash, new_request_key,
request_val);
}
if ( request_val )
{
opcode = request_val->opcode;
}
node = 0;
typenode = 0;
vals = NULL;
dissector = NULL;
switch (port)
{
case AFS_PORT_FS:
typenode = hf_afs_fs;
node = hf_afs_fs_opcode;
vals = fs_req;
dissector = reply ? dissect_fs_reply : dissect_fs_request;
break;
case AFS_PORT_CB:
typenode = hf_afs_cb;
node = hf_afs_cb_opcode;
vals = cb_req;
dissector = reply ? dissect_cb_reply : dissect_cb_request;
break;
case AFS_PORT_PROT:
typenode = hf_afs_prot;
node = hf_afs_prot_opcode;
vals = prot_req;
dissector = reply ? dissect_prot_reply : dissect_prot_request;
break;
case AFS_PORT_VLDB:
typenode = hf_afs_vldb;
node = hf_afs_vldb_opcode;
vals = vldb_req;
dissector = reply ? dissect_vldb_reply : dissect_vldb_request;
break;
case AFS_PORT_KAUTH:
typenode = hf_afs_kauth;
node = hf_afs_kauth_opcode;
vals = kauth_req;
dissector = reply ? dissect_kauth_reply : dissect_kauth_request;
break;
case AFS_PORT_VOL:
typenode = hf_afs_vol;
node = hf_afs_vol_opcode;
vals = vol_req;
dissector = reply ? dissect_vol_reply : dissect_vol_request;
break;
case AFS_PORT_ERROR:
typenode = hf_afs_error;
node = hf_afs_error_opcode;
/* dissector = reply ? dissect_error_reply : dissect_error_request; */
break;
case AFS_PORT_BOS:
typenode = hf_afs_bos;
node = hf_afs_bos_opcode;
vals = bos_req;
dissector = reply ? dissect_bos_reply : dissect_bos_request;
break;
case AFS_PORT_UPDATE:
typenode = hf_afs_update;
node = hf_afs_update_opcode;
/* dissector = reply ? dissect_update_reply : dissect_update_request; */
break;
case AFS_PORT_RMTSYS:
typenode = hf_afs_rmtsys;
node = hf_afs_rmtsys_opcode;
/* dissector = reply ? dissect_rmtsys_reply : dissect_rmtsys_request; */
break;
case AFS_PORT_BACKUP:
typenode = hf_afs_backup;
node = hf_afs_backup_opcode;
dissector = reply ? dissect_backup_reply : dissect_backup_request;
break;
}
if ( (opcode >= VOTE_LOW && opcode <= VOTE_HIGH) ||
(opcode >= DISK_LOW && opcode <= DISK_HIGH) )
{
typenode = hf_afs_ubik;
node = hf_afs_ubik_opcode;
vals = ubik_req;
dissector = reply ? dissect_ubik_reply : dissect_ubik_request;
}
if ( vals )
{
if (check_col(fd, COL_INFO))
col_add_fstr(fd, COL_INFO, "%s %s: %s (%d)",
val_to_str(port, port_types_short, "Unknown(%d)"),
reply ? "Reply" : "Request",
val_to_str(opcode, vals, "Unknown(%d)"), opcode);
}
else
{
if (check_col(fd, COL_INFO))
col_add_fstr(fd, COL_INFO, "%s %s: Unknown(%d)",
val_to_str(port, port_types_short, "Unknown(%d)"),
reply ? "Reply" : "Request",
opcode);
}
if (tree) {
ti = proto_tree_add_item(tree, proto_afs, NullTVB, doffset, END_OF_FRAME, FALSE);
afs_tree = proto_item_add_subtree(ti, ett_afs);
if ( !BYTES_ARE_IN_FRAME(offset, sizeof(struct rx_header) +
sizeof(struct afs_header)) )
{
proto_tree_add_text(afs_tree, NullTVB, doffset, END_OF_FRAME,
"Service: %s %s (Truncated)",
val_to_str(port, port_types, "Unknown(%d)"),
reply ? "Reply" : "Request");
return;
}
else
{
proto_tree_add_text(afs_tree, NullTVB, doffset, END_OF_FRAME,
"Service: %s %s",
val_to_str(port, port_types, "Unknown(%d)"),
reply ? "Reply" : "Request");
}
/* until we do cache, can't handle replies */
ti = NULL;
if ( !reply && node != 0 )
{
ti = proto_tree_add_uint(afs_tree,
node, NullTVB, doffset, 4, opcode);
}
else if ( reply && node != 0 )
{
/* the opcode isn't in this packet */
ti = proto_tree_add_uint(afs_tree,
node, NullTVB, doffset, 0, opcode);
}
else
{
ti = proto_tree_add_text(afs_tree, NullTVB,
doffset, 0, "Operation: Unknown");
}
/* Add the subtree for this particular service */
afs_op_tree = proto_item_add_subtree(ti, ett_afs_op);
if ( typenode != 0 )
{
/* indicate the type of request */
proto_tree_add_boolean_hidden(afs_tree, typenode, NullTVB, doffset, 0, 1);
}
/* Process the packet according to what service it is */
if ( dissector )
{
(*dissector)(pd,offset,fd,afs_op_tree,opcode);
}
}
/* if it's the last packet, and it's a reply, remove opcode
from hash */
/* ignoring for now, I'm not sure how the chunk deallocation works */
if ( rxh->flags & RX_LAST_PACKET && reply )
{
}
}
/*
* Macros for helper dissection routines
*
* The macros are here to save on coding. They assume that
* the current offset is in 'curoffset', and that the offset
* should be incremented after performing the macro's operation.
*/
/* Get the next available integer, be sure and call TRUNC beforehand */
#define GETINT() (pntohl(&pd[curoffset]))
/* Check if enough bytes are present, if not, return to caller
after adding a 'Truncated' message to tree */
#define TRUNC(bytes) \
if(!BYTES_ARE_IN_FRAME(curoffset,(bytes))) \
{ proto_tree_add_text(tree, NullTVB,curoffset,END_OF_FRAME,"Truncated"); \
return; }
/* Output a unsigned integer, stored into field 'field'
Assumes it is in network byte order, converts to host before using */
#define UINTOUT(field) \
TRUNC(sizeof(guint32)) \
proto_tree_add_uint(tree,field, NullTVB,curoffset,sizeof(guint32), GETINT()); \
curoffset += 4;
/* Output an IPv4 address, stored into field 'field' */
#define IPOUT(field) \
TRUNC(sizeof(gint32)) \
proto_tree_add_ipv4(tree,field, NullTVB,curoffset,sizeof(gint32),\
*((int*)&pd[curoffset]));\
curoffset += 4;
/* Output a UNIX seconds/microseconds timestamp, after converting to a timeval */
#define BIGDATEOUT(field) \
{ struct timeval tv; \
TRUNC(2*sizeof(guint32)); \
tv.tv_sec = GETINT(); \
tv.tv_usec = GETINT(); \
proto_tree_add_time(tree,field, NullTVB,curoffset,2*sizeof(guint32),&tv); \
curoffset += 8; \
}
/* Output a UNIX seconds-only timestamp, after converting to a timeval */
#define DATEOUT(field) \
{ struct timeval tv; \
TRUNC(sizeof(guint32)); \