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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
|
/* packet-pnrp.c
* Routines for Peer Name Resolution Protocol (PNRP) dissection
*
* Copyright 2010, Jan Gerbecks <jan.gerbecks@stud.uni-due.de>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
/* The official Documentation for the Peer Name Resolution Protocol
* ([MS-PNRP]) can be found at
*
* https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-pnrp
*
* This dissector is based on Revision 6.1.2
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/exceptions.h>
#include <epan/reassemble.h>
#define PROTONAME "Peer Name Resolution Protocol"
#define PROTOSHORTNAME "PNRP"
#define PROTOABBREV "pnrp"
#define PNRP_PORT 3540
#define FIELDID_LENGTH = 2
#define LENGTH_FIELD = 2
/* Define all FieldIDs here, so we can use them later on in switch statement etc */
#define PNRP_HEADER 0x0010
#define PNRP_HEADER_ACKED 0x0018
#define PNRP_ID 0x0030
#define TARGET_PNRP_ID 0x0038
#define VALIDATE_PNRP_ID 0x0039
#define FLAGS_FIELD 0x0040
#define FLOOD_CONTROLS 0x0043
#define SOLICIT_CONTROLS 0x0044
#define LOOKUP_CONTROLS 0x0045
#define EXTENDED_PAYLOAD 0x005A
#define PNRP_ID_ARRAY 0x0060
#define CERT_CHAIN 0x0080
#define WCHAR 0x0084
#define CLASSIFIER 0x0085
#define HASHED_NONCE 0x0092
#define NONCE 0x0093
#define SPLIT_CONTROLS 0x0098
#define ROUTING_ENTRY 0x009A
#define VALIDATE_CPA 0x009B
#define REVOKE_CPA 0x009C
#define IPV6_ENDPOINT 0x009D
#define IPV6_ENDPOINT_ARRAY 0x009E
/* Define all message types */
#define SOLICIT 0x01
#define ADVERTISE 0x02
#define REQUEST 0x03
#define FLOOD 0x04
#define INQUIRE 0x07
#define AUTHORITY 0x08
#define ACK 0x09
#define LOOKUP 0x0B
/* Define flags mask fields */
#define FLAGS_INQUIRE_RESERVED1 0xFFE0
#define FLAGS_INQUIRE_A 0x0010
#define FLAGS_INQUIRE_X 0x0008
#define FLAGS_INQUIRE_C 0x0004
#define FLAGS_INQUIRE_RESERVED2 0x0003
#define FLAGS_AUTHORITY_RESERVED1 0xFC00
#define FLAGS_AUTHORITY_L 0x0200
#define FLAGS_AUTHORITY_RESERVED2 0x01F0
#define FLAGS_AUTHORITY_B 0x0008
#define FLAGS_AUTHORITY_RESERVED3 0x0006
#define FLAGS_AUTHORITY_N 0x0001
#define FLAGS_LOOKUPCONTROLS_RESERVED 0xFFFC
#define FLAGS_LOOKUPCONTROLS_A 0x0002
#define FLAGS_LOOKUPCONTROLS_0 0x0001
#define FLAGS_ENCODED_CPA_RESERVED 0xC0
#define FLAGS_ENCODED_CPA_X 0x20
#define FLAGS_ENCODED_CPA_U 0x02
#define FLAGS_ENCODED_CPA_R 0x01
#define FLAGS_ENCODED_CPA_A 0x04
#define FLAGS_ENCODED_CPA_C 0x08
#define FLAGS_ENCODED_CPA_F 0x10
void proto_register_pnrp(void);
void proto_reg_handoff_pnrp(void);
static dissector_handle_t pnrp_handle;
/* Define all helper methods */
static void dissect_pnrp_ids(tvbuff_t *tvb, gint offset, gint length, proto_tree *tree);
static void dissect_ipv6_address(tvbuff_t *tvb, gint offset, gint length, proto_tree *tree);
static void dissect_route_entry(tvbuff_t *tvb, gint offset, gint length, proto_tree *tree);
static void dissect_ipv6_endpoint_structure(tvbuff_t *tvb, gint offset, gint length, proto_tree *tree);
static void dissect_encodedCPA_structure(tvbuff_t *tvb, gint offset, gint length, proto_tree *tree);
static void dissect_payload_structure(tvbuff_t *tvb, gint offset, gint length, proto_tree *tree);
static void dissect_publicKey_structure(tvbuff_t *tvb, gint offset, gint length, proto_tree *tree);
static void dissect_signature_structure(tvbuff_t *tvb, gint offset, gint length, proto_tree *tree);
/* Define global variables
----------------------------*/
static int proto_pnrp = -1;
/* Define FieldIDs */
static const value_string fieldID[] = {
{ PNRP_HEADER, "PNRP_HEADER" },
{ PNRP_HEADER_ACKED, "PNRP_HEADER_ACKED" },
{ PNRP_ID, "PNRP_ID" },
{ TARGET_PNRP_ID, "TARGET_PNRP_ID" },
{ VALIDATE_PNRP_ID, "VALIDATE_PNRP_ID" },
{ FLAGS_FIELD, "FLAGS_FIELD" },
{ FLOOD_CONTROLS, "FLOOD_CONTROLS" },
{ SOLICIT_CONTROLS, "SOLICIT_CONTROLS" },
{ LOOKUP_CONTROLS, "LOOKUP_CONTROLS" },
{ EXTENDED_PAYLOAD, "EXTENDED_PAYLOAD" },
{ PNRP_ID_ARRAY, "PNRP_ID_ARRAY" },
{ CERT_CHAIN, "CERT_CHAIN" },
{ WCHAR, "WCHAR" },
{ CLASSIFIER, "CLASSIFIER" },
{ HASHED_NONCE, "HASHED_NONCE" },
{ NONCE, "NONCE" },
{ SPLIT_CONTROLS, "SPLIT_CONTROLS" },
{ ROUTING_ENTRY, "ROUTING_ENTRY" },
{ VALIDATE_CPA, "VALIDATE_CPA" },
{ REVOKE_CPA, "REVOKE_CPA" },
{ IPV6_ENDPOINT, "IPV6_ENDPOINT" },
{ IPV6_ENDPOINT_ARRAY, "IPV6_ENDPOINT_ARRAY" },
{0, NULL}
};
/* Define Packetnames */
static const value_string messageType[] = {
{ SOLICIT, "SOLICIT" },
{ ADVERTISE, "ADVERTISE" },
{ REQUEST, "REQUEST" },
{ FLOOD, "FLOOD" },
{ INQUIRE, "INQUIRE" },
{ AUTHORITY, "AUTHORITY" },
{ ACK, "ACK" },
{ LOOKUP, "LOOKUP" },
{0, NULL}
};
/* Define Solicit Type */
static const value_string solicitType[] = {
{ 0x00, "SOLICIT_TYPE_ANY" },
{ 0x01, "SOLICIT_TYPE_LOCAL" },
{0, NULL}
};
/* Define Resolve Criteria for Lookup Controls */
static const value_string resolveCriteria[] = {
{ 0x00, "SEARCH_OPCODE_NONE" },
{ 0x01, "SEARCH_OPCODE_ANY_PEERNAME" },
{ 0x02, "SEARCH_OPCODE_NEAREST_PEERNAME" },
{ 0x04, "SEARCH_OPCODE_NEAREST64_PEERNAME" },
{ 0x08, "SEARCH_OPCODE_UPPER_BITS" },
{0, NULL}
};
/* Define Reason Code for Lookup Controls */
static const value_string reasonCode[] = {
{ 0x00, "REASON_APP_REQUEST" },
{ 0x01, "REASON_REGISTRATION" },
{ 0x02, "REASON_CACHE_MAINTENANCE" },
{ 0x03, "REASON_SPLIT_DETECTION" },
{0, NULL}
};
/* Define IDs for subcomponents */
/* Message Header */
static gint hf_pnrp_header = -1;
static gint hf_pnrp_header_fieldID = -1;
static gint hf_pnrp_header_length = -1;
static gint hf_pnrp_header_ident = -1;
static gint hf_pnrp_header_versionMajor = -1;
static gint hf_pnrp_header_versionMinor = -1;
static gint hf_pnrp_header_messageType = -1;
static gint hf_pnrp_header_messageID = -1;
/* Message Body */
static gint hf_pnrp_message_type = -1;
static gint hf_pnrp_message_length = -1;
static gint hf_pnrp_message_headerack = -1;
static gint hf_pnrp_message_pnrpID = -1; /* Generic variable to display pnrp ID in various situations */
/* Inquire Message Flags */
static gint hf_pnrp_message_inquire_flags = -1;
static gint hf_pnrp_message_inquire_flags_reserved1 = -1;
static gint hf_pnrp_message_inquire_flags_Abit = -1;
static gint hf_pnrp_message_inquire_flags_Xbit = -1;
static gint hf_pnrp_message_inquire_flags_Cbit = -1;
static gint hf_pnrp_message_inquire_flags_reserved2 = -1;
static gint hf_pnrp_padding = -1;
static int * const inquire_flags[] = {
&hf_pnrp_message_inquire_flags_reserved1,
&hf_pnrp_message_inquire_flags_Abit,
&hf_pnrp_message_inquire_flags_Xbit,
&hf_pnrp_message_inquire_flags_Cbit,
&hf_pnrp_message_inquire_flags_reserved2,
NULL
};
/* Classifier */
static gint hf_pnrp_message_classifier_unicodeCount = -1;
static gint hf_pnrp_message_classifier_arrayLength = -1;
static gint hf_pnrp_message_classifier_entryLength = -1;
static gint hf_pnrp_message_classifier_string = -1;
/* ACK Message Flags */
static gint hf_pnrp_message_ack_flags_reserved = -1;
static gint hf_pnrp_message_ack_flags_Nbit = -1;
/* SplitControls */
static gint hf_pnrp_message_splitControls_authorityBuffer = -1;
/* IPv6 Endpoint Array */
static gint hf_pnrp_message_ipv6EndpointArray_NumberOfEntries = -1;
static gint hf_pnrp_message_ipv6EndpointArray_ArrayLength = -1;
static gint hf_pnrp_message_ipv6EndpointArray_EntryLength = -1;
/* AUTHORITY Message Flags */
static gint hf_pnrp_message_authority_flags = -1;
static gint hf_pnrp_message_authority_flags_reserved1 = -1;
static gint hf_pnrp_message_authority_flags_Lbit = -1;
static gint hf_pnrp_message_authority_flags_reserved2 = -1;
static gint hf_pnrp_message_authority_flags_Bbit = -1;
static gint hf_pnrp_message_authority_flags_reserved3= -1;
static gint hf_pnrp_message_authority_flags_Nbit = -1;
static int * const authority_flags[] = {
&hf_pnrp_message_authority_flags_reserved1,
&hf_pnrp_message_authority_flags_Lbit,
&hf_pnrp_message_authority_flags_reserved2,
&hf_pnrp_message_authority_flags_Bbit,
&hf_pnrp_message_authority_flags_reserved3,
&hf_pnrp_message_authority_flags_Nbit,
NULL
};
/* Flood Control Flags */
static gint hf_pnrp_message_flood_flags_reserved1 = -1;
static gint hf_pnrp_message_flood_flags_Dbit = -1;
/* PNRP ID Array */
static gint hf_pnrp_message_idArray_NumEntries = -1;
static gint hf_pnrp_message_idArray_Length = -1;
static gint hf_pnrp_message_ElementFieldType = -1;
static gint hf_pnrp_message_idarray_Entrylength = -1;
static gint hf_pnrp_message_solicitType = -1;
static gint hf_pnrp_message_certChain = -1;
static gint hf_pnrp_message_nonce = -1;
static gint hf_pnrp_message_hashednonce = -1;
static gint hf_pnrp_message_ipv6 = -1;
/* Encoded CPA */
static gint hf_pnrp_encodedCPA = -1;
static gint hf_pnrp_encodedCPA_length = -1;
static gint hf_pnrp_encodedCPA_minorVersion = -1;
static gint hf_pnrp_encodedCPA_majorVersion = -1;
static gint hf_pnrp_encodedCPA_flags = -1;
static gint hf_pnrp_encodedCPA_flags_reserved = -1;
static gint hf_pnrp_encodedCPA_flags_Xbit = -1;
static gint hf_pnrp_encodedCPA_flags_Fbit = -1;
static gint hf_pnrp_encodedCPA_flags_Cbit = -1;
static gint hf_pnrp_encodedCPA_flags_Abit = -1;
static gint hf_pnrp_encodedCPA_flags_Ubit = -1;
static gint hf_pnrp_encodedCPA_flags_Rbit = -1;
static int * const encodedCPA_flags[] = {
&hf_pnrp_encodedCPA_flags_reserved,
&hf_pnrp_encodedCPA_flags_Xbit,
&hf_pnrp_encodedCPA_flags_Fbit,
&hf_pnrp_encodedCPA_flags_Cbit,
&hf_pnrp_encodedCPA_flags_Abit,
&hf_pnrp_encodedCPA_flags_Ubit,
&hf_pnrp_encodedCPA_flags_Rbit,
NULL
};
static gint hf_pnrp_encodedCPA_notAfter = -1;
static gint hf_pnrp_encodedCPA_serviceLocation = -1;
static gint hf_pnrp_encodedCPA_binaryAuthority = -1;
static gint hf_pnrp_encodedCPA_classifierHash = -1;
static gint hf_pnrp_encodedCPA_friendlyName = -1;
/* Lookup Controls */
static gint hf_pnrp_message_lookupControls_flags = -1;
static gint hf_pnrp_message_lookupControls_flags_reserved = -1;
static gint hf_pnrp_message_lookupControls_flags_Abit = -1;
static gint hf_pnrp_message_lookupControls_flags_0bit = -1;
static int * const lookupControls_flags[] = {
&hf_pnrp_message_lookupControls_flags_reserved,
&hf_pnrp_message_lookupControls_flags_Abit,
&hf_pnrp_message_lookupControls_flags_0bit,
NULL
};
static gint hf_pnrp_message_lookupControls_precision =-1;
static gint hf_pnrp_message_lookupControls_resolveCriteria =-1;
static gint hf_pnrp_message_lookupControls_reasonCode =-1;
/* Dissect Route Entry */
static gint hf_pnrp_message_routeEntry_portNumber = -1;
static gint hf_pnrp_message_routeEntry_flags = -1;
static gint hf_pnrp_message_routeEntry_addressCount = -1;
/* Public Key Structure */
static gint hf_pnrp_publicKey_objID = -1;
static gint hf_pnrp_publicKey_publicKeyData = -1;
/* Signature Structure */
static gint hf_pnrp_signature_signatureData = -1;
/* Generated from convert_proto_tree_add_text.pl */
static int hf_pnrp_payload_port = -1;
static int hf_pnrp_signature_length = -1;
static int hf_pnrp_signature_structure_length = -1;
static int hf_pnrp_encodedCPA_total_bytes_of_payload = -1;
static int hf_pnrp_signature_hash_id = -1;
static int hf_pnrp_message_flags = -1;
static int hf_pnrp_encodedCPA_number_of_service_addresses = -1;
static int hf_pnrp_payload_iana_proto = -1;
static int hf_pnrp_reserved8 = -1;
static int hf_pnrp_reserved16 = -1;
static int hf_pnrp_encodedCPA_service_address_length = -1;
static int hf_pnrp_message_data = -1;
static int hf_pnrp_publicKey_length_of_structure = -1;
static int hf_pnrp_publicKey_size_of_cbdata = -1;
static int hf_pnrp_payload_type = -1;
static int hf_pnrp_publicKey_size_of_algorithm_oid = -1;
static int hf_pnrp_message_port_number = -1;
static int hf_pnrp_publicKey_reserved = -1;
static int hf_pnrp_encodedCPA_friendlyName_length = -1;
static int hf_pnrp_message_offset = -1;
static int hf_pnrp_publicKey_unused_bits = -1;
static int hf_pnrp_length_of_data = -1;
static int hf_pnrp_encodedCPA_number_of_payload_structures = -1;
/* Reassembly */
static int hf_pnrp_fragments = -1;
static int hf_pnrp_fragment = -1;
static int hf_pnrp_fragment_overlap = -1;
static int hf_pnrp_fragment_overlap_conflict = -1;
static int hf_pnrp_fragment_multiple_tails = -1;
static int hf_pnrp_fragment_too_long_fragment = -1;
static int hf_pnrp_fragment_error = -1;
static int hf_pnrp_fragment_count = -1;
static int hf_pnrp_reassembled_in = -1;
static int hf_pnrp_reassembled_length = -1;
static int hf_pnrp_reassembled_data = -1;
static int hf_pnrp_fragmented_payload = -1;
/* Define variables to reference subtrees */
static gint ett_pnrp = -1;
static gint ett_pnrp_header = -1;
static gint ett_pnrp_message = -1;
static gint ett_pnrp_message_inquire_flags = -1;
static gint ett_pnrp_message_authority_flags = -1;
static gint ett_pnrp_message_encodedCPA = -1;
static gint ett_pnrp_message_encodedCPA_flags = -1;
static gint ett_pnrp_message_lookupControls_flags = -1;
static gint ett_pnrp_message_payloadStructure = -1;
static gint ett_pnrp_message_publicKeyStructure = -1;
static gint ett_pnrp_message_signatureStructure = -1;
static gint ett_pnrp_fragment = -1;
static gint ett_pnrp_fragments = -1;
static reassembly_table pnrp_reassembly_table;
static const fragment_items pnrp_frag_items = {
&ett_pnrp_fragment,
&ett_pnrp_fragments,
&hf_pnrp_fragments,
&hf_pnrp_fragment,
&hf_pnrp_fragment_overlap,
&hf_pnrp_fragment_overlap_conflict,
&hf_pnrp_fragment_multiple_tails,
&hf_pnrp_fragment_too_long_fragment,
&hf_pnrp_fragment_error,
&hf_pnrp_fragment_count,
&hf_pnrp_reassembled_in,
&hf_pnrp_reassembled_length,
&hf_pnrp_reassembled_data,
"PNRP fragments"
};
/* Do actual dissection work */
static int dissect_pnrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
/* Variable declaration */
int offset, start_offset;
gint padding_bytes;
guint8 message_type;
guint16 field_type;
unsigned data_length;
proto_item *ti;
proto_tree *pnrp_tree;
proto_item *pnrp_header_item;
proto_tree *pnrp_header_tree;
proto_item *pnrp_message_tree = NULL;
guint32 msg_id;
/*----------------------------------------
* Validate if it is really a PNRP Packet
*----------------------------------------*/
/* Check that there's enough data */
data_length = tvb_captured_length(tvb);
/* Shortest Message is ACK -> 12 Bytes for Header plus 8 Bytes for Data */
if (data_length < 12+8 )
{
return 0;
}
/* Check some values from the packet header */
/* First 2 bytes must be 0x0010 */
if (tvb_get_ntohs(tvb,0) != PNRP_HEADER )
{
return 0;
}
/* Length of Header must be 0x000C = 12 */
if (tvb_get_ntohs(tvb,2) != 0x000C) {
return 0;
}
/* Identifier must 0x51 */
if (tvb_get_guint8(tvb,4) != 0x51) {
return 0;
}
/* Assign Values to Variables */
/* Use to track data */
offset= 0;
/* Get the message Information beforehand */
message_type = tvb_get_guint8(tvb,7);
/* Simply Display the Protocol Name in the INFO column */
col_set_str(pinfo->cinfo, COL_PROTOCOL, "PNRP");
/* Clear out stuff in the info column */
col_add_fstr(pinfo->cinfo, COL_INFO, "PNRP %s Message ",
val_to_str(message_type, messageType, "Unknown (0x%02x)"));
/* Lets add a subtree to our dissection to display the info */
ti = proto_tree_add_item(tree, proto_pnrp, tvb, 0, -1, ENC_NA);
proto_item_append_text(ti, ", Message Type %s",
val_to_str(message_type, messageType, "Unknown (0x%02x)"));
/* Get a main tree for the whole protocol */
pnrp_tree = proto_item_add_subtree(ti, ett_pnrp);
/*-------------------------------
*--Add all Header Fields
*------------------------------*/
/* Get a subtree for the Header */
pnrp_header_item = proto_tree_add_item(pnrp_tree, hf_pnrp_header, tvb, offset,12,ENC_NA);
pnrp_header_tree = proto_item_add_subtree(pnrp_header_item, ett_pnrp_header);
/* Add Field ID should be 0c0010 */
proto_tree_add_item(pnrp_header_tree,hf_pnrp_header_fieldID,tvb,offset,2,ENC_BIG_ENDIAN);
offset += 2;
/* Add Length should be 0x000C */
proto_tree_add_item(pnrp_header_tree,hf_pnrp_header_length,tvb,offset,2,ENC_BIG_ENDIAN);
offset += 2;
/* Add Ident should be 0x51 */
proto_tree_add_item(pnrp_header_tree,hf_pnrp_header_ident,tvb,offset,1,ENC_BIG_ENDIAN);
offset += 1;
/* Add Major Version */
proto_tree_add_item(pnrp_header_tree,hf_pnrp_header_versionMajor,tvb,offset,1,ENC_BIG_ENDIAN);
offset += 1;
/* Add Minor Version */
proto_tree_add_item(pnrp_header_tree,hf_pnrp_header_versionMinor,tvb,offset,1,ENC_BIG_ENDIAN);
offset += 1;
/* Add Message Type */
proto_tree_add_item(pnrp_header_tree,hf_pnrp_header_messageType,tvb,offset,1,ENC_BIG_ENDIAN);
offset += 1;
/* Add Message ID */
proto_tree_add_item_ret_uint(pnrp_header_tree,hf_pnrp_header_messageID,tvb,offset,4,ENC_BIG_ENDIAN,&msg_id);
offset += 4;
/*-------------------------------
*--Add all Message Fields
*------------------------------*/
/* The following part has dynamic length depending on message type */
start_offset = offset;
while (tvb_reported_length_remaining(tvb, offset) > 0) {
/* Determine the Field Type */
field_type = tvb_get_ntohs(tvb,offset );
/* Determine length of this message */
data_length = tvb_get_ntohs(tvb,offset + 2);
/* Length must be at least 4, because field_type and data_length are part of data_length information */
if (data_length < 4) {
if (tree) {
pnrp_message_tree = proto_tree_add_subtree_format(pnrp_tree, tvb, offset, 4, ett_pnrp_message, NULL,
"Message with invalid length %u (< 4)", data_length);
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_type, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_length, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
}
offset += 4;
/* Don't continue parsing this message segment */
break;
}
/* Actual Parsing of the message Type */
switch (field_type) {
/* First Field in ACK Message */
case PNRP_HEADER_ACKED:
if (tree) {
pnrp_message_tree = proto_tree_add_subtree(pnrp_tree, tvb, offset,
data_length, ett_pnrp_message, NULL, "Message ACK ID: ");
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_type, tvb, offset , 2, ENC_BIG_ENDIAN);
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_length, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_headerack, tvb, offset + 4, data_length -4, ENC_BIG_ENDIAN);
}
offset += data_length;
break;
/* A validate pnrp id follows as found in FLOOD */
case VALIDATE_PNRP_ID:
if (tree) {
pnrp_message_tree = proto_tree_add_subtree(pnrp_tree, tvb, offset,
data_length, ett_pnrp_message, NULL, "Validate PNRP ID: ");
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_type, tvb, offset , 2, ENC_BIG_ENDIAN);
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_length, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
/* We can have a large number of pnrp IDs here */
dissect_pnrp_ids(tvb,offset+4,data_length-4,pnrp_message_tree);
}
offset += data_length;
break;
/* The Flags have different meaning, depending on the message */
case FLAGS_FIELD:
if (tree) {
pnrp_message_tree = proto_tree_add_subtree(pnrp_tree, tvb, offset,
data_length, ett_pnrp_message, NULL, "Flags Field: ");
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_type, tvb, offset , 2, ENC_BIG_ENDIAN);
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_length, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
}
switch (message_type) {
case INQUIRE:
proto_tree_add_bitmask(pnrp_message_tree, tvb, offset+4, hf_pnrp_message_inquire_flags, ett_pnrp_message_inquire_flags, inquire_flags, ENC_BIG_ENDIAN);
proto_tree_add_item(pnrp_message_tree, hf_pnrp_padding, tvb, offset + 6, 2, ENC_NA);
offset += data_length+2;
break;
case ACK:
/* Reserved 0 - 14 bits */
proto_tree_add_bits_item(pnrp_message_tree, hf_pnrp_message_ack_flags_reserved, tvb, (offset + 4)*8, 15, ENC_BIG_ENDIAN);
/* N - Bit */
proto_tree_add_bits_item(pnrp_message_tree, hf_pnrp_message_ack_flags_Nbit, tvb,((offset + 4)*8)+15, 1, ENC_BIG_ENDIAN);
offset += data_length;
break;
case AUTHORITY:
proto_tree_add_bitmask(pnrp_message_tree, tvb, offset+4, hf_pnrp_message_authority_flags, ett_pnrp_message_authority_flags, authority_flags, ENC_BIG_ENDIAN);
/* Check if the Flags Field is the last message part. If so, no padding of 2 bytes is added */
if(tvb_reported_length_remaining(tvb, offset+data_length)==0)
{
offset += data_length;
}
else {
padding_bytes = 2;
proto_tree_add_item(pnrp_message_tree, hf_pnrp_padding, tvb, offset + 6, padding_bytes, ENC_NA);
offset += data_length+2;
}
break;
default:
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_flags, tvb, offset + 4, data_length -4, ENC_BIG_ENDIAN);
offset += data_length;
break;
}
break;
/* Flood controls found in FLOOD Message */
case FLOOD_CONTROLS:
if (tree) {
pnrp_message_tree = proto_tree_add_subtree(pnrp_tree, tvb, offset,
data_length, ett_pnrp_message, NULL, "Flood Control: ");
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_type, tvb, offset , 2, ENC_BIG_ENDIAN);
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_length, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
/* Reserved 1 - 15 bits */
proto_tree_add_bits_item(pnrp_message_tree, hf_pnrp_message_flood_flags_reserved1, tvb, (offset + 4)*8, 15, ENC_BIG_ENDIAN);
/* D - Bit */
proto_tree_add_bits_item(pnrp_message_tree, hf_pnrp_message_flood_flags_Dbit, tvb,((offset + 4)*8)+15, 1, ENC_BIG_ENDIAN);
/* Reserved 2 */
proto_tree_add_item(pnrp_message_tree, hf_pnrp_reserved8, tvb, offset + 6, 1, ENC_NA);
/* Padding 1 */
proto_tree_add_item(pnrp_message_tree, hf_pnrp_padding, tvb, offset + 7, 1, ENC_NA);
}
offset += data_length+1;
break;
/* Solicit Controls found in SOLICIT Message */
case SOLICIT_CONTROLS:
if (tree) {
pnrp_message_tree = proto_tree_add_subtree(pnrp_tree, tvb, offset,
data_length, ett_pnrp_message, NULL, "Solicit Controls: ");
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_type, tvb, offset , 2, ENC_BIG_ENDIAN);
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_length, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(pnrp_message_tree, hf_pnrp_reserved8, tvb, offset + 4, 1, ENC_NA);
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_solicitType, tvb, offset + 5, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(pnrp_message_tree, hf_pnrp_reserved16, tvb, offset + 6, 2, ENC_LITTLE_ENDIAN);
}
offset += data_length +2; /* Padding involved */
break;
/* Lookup controls found in LOOKUP Message */
case LOOKUP_CONTROLS:
if (tree) {
pnrp_message_tree = proto_tree_add_subtree(pnrp_tree, tvb, offset,
data_length, ett_pnrp_message, NULL, "Lookup Control: ");
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_type, tvb, offset , 2, ENC_BIG_ENDIAN);
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_length, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
/* 2 Bytes of Flags */
proto_tree_add_bitmask(pnrp_message_tree, tvb, offset+4, hf_pnrp_message_lookupControls_flags, ett_pnrp_message_lookupControls_flags, lookupControls_flags, ENC_BIG_ENDIAN);
/* Precision Bytes */
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_lookupControls_precision, tvb, offset + 6, 2, ENC_BIG_ENDIAN);
/* Resolve Criteria */
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_lookupControls_resolveCriteria, tvb, offset + 8, 1, ENC_BIG_ENDIAN);
/* Reason Code */
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_lookupControls_reasonCode, tvb, offset + 9, 1, ENC_BIG_ENDIAN);
/* Reserved */
proto_tree_add_item(pnrp_message_tree, hf_pnrp_reserved16, tvb, offset + 10, 2, ENC_LITTLE_ENDIAN);
}
offset += data_length;
break;
/* Target PNRP ID found in Lookup Message */
case TARGET_PNRP_ID:
if (tree) {
pnrp_message_tree = proto_tree_add_subtree(pnrp_tree, tvb, offset,
data_length, ett_pnrp_message, NULL, "Target PNRP ID: ");
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_type, tvb, offset , 2, ENC_BIG_ENDIAN);
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_length, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
dissect_pnrp_ids(tvb, offset+4, data_length-4, pnrp_message_tree);
}
offset += data_length;
break;
/* Extended Payload found in AUTHORITY Message */
case EXTENDED_PAYLOAD:
if (tree) {
pnrp_message_tree = proto_tree_add_subtree(pnrp_tree, tvb, offset,
data_length, ett_pnrp_message, NULL, "Extended Payload: ");
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_type, tvb, offset , 2, ENC_BIG_ENDIAN);
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_length, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
/* TODO: Do actual parsing */
}
offset += data_length;
break;
/* Pnrp id Array as found in REQUEST & ADVERTISE Message */
case PNRP_ID_ARRAY:
if (tree) {
pnrp_message_tree = proto_tree_add_subtree(pnrp_tree, tvb, offset,
data_length, ett_pnrp_message, NULL, "PNRP ID Array: ");
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_type, tvb, offset , 2, ENC_BIG_ENDIAN);
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_length, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_idArray_NumEntries, tvb, offset + 4, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_idArray_Length, tvb, offset + 6, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_ElementFieldType, tvb, offset + 8, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_idarray_Entrylength, tvb, offset + 10, 2, ENC_BIG_ENDIAN);
dissect_pnrp_ids(tvb,offset+12,data_length-12,pnrp_message_tree);
}
offset += data_length;
break;
/* Cert Chain follows as found in AUTHORITY */
case CERT_CHAIN:
if (tree) {
pnrp_message_tree = proto_tree_add_subtree(pnrp_tree, tvb, offset,
data_length, ett_pnrp_message, NULL, "CERT Chain: ");
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_type, tvb, offset , 2, ENC_BIG_ENDIAN);
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_length, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_certChain, tvb, offset + 4, data_length-4, ENC_NA);
}
/* There might be padding, so fill up to the next byte */
padding_bytes = 0;
while (data_length%4 != 0 &&tvb_reported_length_remaining(tvb, offset+data_length)>0) {
data_length++;
padding_bytes++;
}
/* Check if we actually had some padding bytes */
if (0<padding_bytes) {
proto_tree_add_item(pnrp_message_tree, hf_pnrp_padding, tvb, offset + data_length-padding_bytes, padding_bytes, ENC_NA);
}
offset += data_length;
break;
/* classifier: A classifier string follows as found in AUTHORITY */
case CLASSIFIER:
if (tree) {
pnrp_message_tree = proto_tree_add_subtree(pnrp_tree, tvb, offset,
data_length, ett_pnrp_message, NULL, "Classifier: ");
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_type, tvb, offset , 2, ENC_BIG_ENDIAN);
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_length, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
/* NumEntries */
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_classifier_unicodeCount, tvb, offset + 4, 2, ENC_BIG_ENDIAN);
/* Array Length: 8+(NumEntries*EntryLength */
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_classifier_arrayLength, tvb, offset + 6, 2, ENC_BIG_ENDIAN);
/* Element Field Type: WCHAR */
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_type, tvb, offset+8 , 2, ENC_BIG_ENDIAN);
/* Entry Length: Must be 0x0002 */
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_classifier_entryLength, tvb, offset + 10, 2, ENC_BIG_ENDIAN);
/* The actual classifier String */
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_classifier_string, tvb, offset + 12, tvb_get_ntohs(tvb,offset+6)-8, ENC_UTF_16|ENC_BIG_ENDIAN);
}
/* There might be padding, so fill up to the next byte */
padding_bytes = 0;
while (data_length%4 != 0 &&tvb_reported_length_remaining(tvb, offset+data_length)>0) {
data_length++;
padding_bytes++;
}
/* Check if we actually had some padding bytes */
if (0<padding_bytes) {
proto_tree_add_item(pnrp_message_tree, hf_pnrp_padding, tvb, offset + data_length-padding_bytes, padding_bytes, ENC_NA);
}
offset += data_length;
break;
/* A hashed nonce follows as found in ADVERTISE & SOLICIT */
case HASHED_NONCE:
if (tree) {
pnrp_message_tree = proto_tree_add_subtree(pnrp_tree, tvb, offset,
data_length, ett_pnrp_message, NULL, "Hashed Nonce: ");
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_type, tvb, offset , 2, ENC_BIG_ENDIAN);
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_length, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_hashednonce, tvb, offset + 4, data_length-4, ENC_NA);
}
offset += data_length;
break;
/* A nonce follows as found in REQUEST & INQUIRE */
case NONCE:
if (tree) {
pnrp_message_tree = proto_tree_add_subtree(pnrp_tree, tvb, offset,
data_length, ett_pnrp_message, NULL, "Nonce: ");
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_type, tvb, offset , 2, ENC_BIG_ENDIAN);
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_length, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_nonce, tvb, offset + 4, data_length-4, ENC_NA);
}
offset += data_length;
break;
/* split controls as found in AUTHORITY */
case SPLIT_CONTROLS:
{
fragment_head *frag_data;
tvbuff_t *frag_tvb;
guint32 buffer_len, frag_offset, remaining_len;
if (tree) {
pnrp_message_tree = proto_tree_add_subtree(pnrp_tree, tvb, offset,
data_length, ett_pnrp_message, NULL, "Split controls: ");
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_type, tvb, offset , 2, ENC_BIG_ENDIAN);
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_length, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
}
/* Size of Authority Buffer */
proto_tree_add_item_ret_uint(pnrp_message_tree, hf_pnrp_message_splitControls_authorityBuffer,
tvb, offset + 4, 2, ENC_BIG_ENDIAN, &buffer_len);
/* Byte offset */
proto_tree_add_item_ret_uint(pnrp_message_tree, hf_pnrp_message_offset,
tvb, offset + 6, 2, ENC_BIG_ENDIAN, &frag_offset);
offset += data_length;
remaining_len = tvb_reported_length_remaining(tvb, offset);
frag_data = fragment_add_check(&pnrp_reassembly_table, tvb, offset, pinfo,
msg_id, NULL, frag_offset, remaining_len,
(buffer_len != (frag_offset + remaining_len)));
frag_tvb = process_reassembled_data(tvb, offset, pinfo, "Reassembled PNRP message",
frag_data, &pnrp_frag_items, NULL, pnrp_message_tree);
if (frag_tvb) {
tvb = frag_tvb;
offset = 0;
} else {
proto_tree_add_item(pnrp_message_tree, hf_pnrp_fragmented_payload, tvb, offset, -1, ENC_NA);
col_append_fstr(pinfo->cinfo, COL_INFO, " [Fragmented message]");
return tvb_captured_length(tvb);
}
break;
}
/* routing entry: A route entry follows as found in ADVERTISE, INQUIRE, LOOKUP & AUTHORITY */
case ROUTING_ENTRY:
if (tree) {
pnrp_message_tree = proto_tree_add_subtree(pnrp_tree, tvb, offset,
data_length, ett_pnrp_message, NULL, "Routing Entry: ");
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_type, tvb, offset , 2, ENC_BIG_ENDIAN);
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_length, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
dissect_route_entry(tvb,offset+4, tvb_get_ntohs(tvb,offset+2)-4, pnrp_message_tree);
}
/* There might be padding, so fill up to the next byte */
padding_bytes = 0;
while (data_length%4 != 0 &&tvb_reported_length_remaining(tvb, offset+data_length)>0) {
data_length++;
padding_bytes++;
}
/* Check if we actually had some padding bytes */
if (0<padding_bytes) {
proto_tree_add_item(pnrp_message_tree, hf_pnrp_padding, tvb, offset + data_length-padding_bytes, padding_bytes, ENC_NA);
}
offset += data_length;
break;
/* validate cpa: an encoded CPA structure follows as found in AUTHORITY */
case VALIDATE_CPA:
if (tree) {
pnrp_message_tree = proto_tree_add_subtree(pnrp_tree, tvb, offset,
data_length, ett_pnrp_message, NULL, "Validate CPA: ");
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_type, tvb, offset , 2, ENC_BIG_ENDIAN);
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_length, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
/* Do the actual parsing in own method */
dissect_encodedCPA_structure(tvb, offset+4, data_length-4, pnrp_message_tree);
}
offset += data_length;
break;
/* IPV6 Endpoint: an ipv6 endpoint array structure follows as found in LOOKUP */
case IPV6_ENDPOINT_ARRAY:
if (tree) {
pnrp_message_tree = proto_tree_add_subtree(pnrp_tree, tvb, offset,
data_length, ett_pnrp_message, NULL, "IPv6 Endpoint Array: ");
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_type, tvb, offset , 2, ENC_BIG_ENDIAN);
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_length, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
/* Number of route entries */
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_ipv6EndpointArray_NumberOfEntries, tvb, offset + 4, 2, ENC_BIG_ENDIAN);
/* Array length */
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_ipv6EndpointArray_ArrayLength, tvb, offset + 6, 2, ENC_BIG_ENDIAN);
/* Element Field Type */
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_type, tvb, offset+8 , 2, ENC_BIG_ENDIAN);
/* Entry Length: must be 0x0012 (18 bytes) */
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_ipv6EndpointArray_EntryLength, tvb, offset + 10, 2, ENC_BIG_ENDIAN);
/* Flagged Path */
dissect_ipv6_endpoint_structure(tvb, offset+12, tvb_get_ntohs(tvb,offset+6)-8,pnrp_message_tree);
}
offset += data_length;
break;
default:
if (tree) {
pnrp_message_tree = proto_tree_add_subtree_format(pnrp_tree, tvb, offset,
data_length, ett_pnrp_message, NULL, "Type: %s, length: %u",
val_to_str(field_type, fieldID, "Unknown (0x%04x)"), data_length);
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_type, tvb, offset , 2, ENC_BIG_ENDIAN);
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_length, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
if(data_length > 4)
{
proto_tree_add_item(pnrp_message_tree, hf_pnrp_message_data, tvb, offset + 4, data_length -4, ENC_NA);
}
else {
return 0;
}
}
offset += data_length;
break;
}
// SPLIT_CONTROLS might reset our offset.
if (start_offset <= offset) {
THROW(ReportedBoundsError);
}
}
return offset;
}
/*--------------------------------------------------------------*
* Dissecting helper methods *
*--------------------------------------------------------------*/
static void dissect_pnrp_ids(tvbuff_t *tvb, gint offset, gint length, proto_tree *tree)
{
while (32 <=length) {
proto_tree_add_item(tree, hf_pnrp_message_pnrpID, tvb, offset, 32, ENC_NA);
length -= 32;
offset += 32;
}
}
static void dissect_route_entry(tvbuff_t *tvb, gint offset, gint length, proto_tree *tree)
{
gint tmp_offset;
/* Check if we don't run out of data */
if (0 <= tvb_reported_length_remaining(tvb, offset+length)) {
tmp_offset = 0;
/* First, we have a 32 Bit long PNRP ID */
proto_tree_add_item(tree, hf_pnrp_message_pnrpID, tvb, offset+tmp_offset, 32, ENC_NA);
tmp_offset +=32;
/* Add PNRP Major Version */
proto_tree_add_item(tree,hf_pnrp_header_versionMajor,tvb,offset+tmp_offset,1,ENC_BIG_ENDIAN);
tmp_offset += 1;
/* Add Minor Version */
proto_tree_add_item(tree,hf_pnrp_header_versionMinor,tvb,offset+tmp_offset,1,ENC_BIG_ENDIAN);
tmp_offset +=1;
/* Port Number */
proto_tree_add_item(tree,hf_pnrp_message_routeEntry_portNumber,tvb,offset+tmp_offset,2,ENC_BIG_ENDIAN);
tmp_offset +=2;
/* Flags */
proto_tree_add_item(tree,hf_pnrp_message_routeEntry_flags,tvb,offset+tmp_offset,1,ENC_BIG_ENDIAN);
tmp_offset +=1;
/* Address count */
proto_tree_add_item(tree,hf_pnrp_message_routeEntry_addressCount,tvb,offset+tmp_offset,1,ENC_BIG_ENDIAN);
tmp_offset +=1;
/* IPv6 Addresses */
dissect_ipv6_address(tvb, offset+tmp_offset, length -tmp_offset, tree);
}
}
static void dissect_ipv6_endpoint_structure(tvbuff_t *tvb, gint offset, gint length, proto_tree *tree)
{
/* Check if we don't run out of data */
while (0 <= tvb_reported_length_remaining(tvb, offset+18) && 18 <=length) {
/* Port Number */
proto_tree_add_item(tree, hf_pnrp_message_port_number, tvb, offset, 2, ENC_BIG_ENDIAN);
/* IPv6 Addresses */
dissect_ipv6_address(tvb, offset+2,16,tree);
offset += 18;
length -= 18;
}
}
static void dissect_ipv6_address(tvbuff_t *tvb, gint offset, gint length, proto_tree *tree)
{
while (0 <= tvb_reported_length_remaining(tvb, offset+16) && 16 <=length) {
proto_tree_add_item(tree, hf_pnrp_message_ipv6, tvb, offset, 16, ENC_NA);
offset += 16;
length -= 16;
}
}
static void dissect_encodedCPA_structure(tvbuff_t *tvb, gint offset, gint length, proto_tree *tree)
{
/* Check if we don't run out of data */
if (0 <= tvb_reported_length_remaining(tvb, offset+length)) {
guint8 flagsField;
/* Add a new subtree */
proto_item *pnrp_encodedCPA_tree = NULL;
proto_item *pnrp_encodedCPA_item = NULL;
pnrp_encodedCPA_item = proto_tree_add_item(tree, hf_pnrp_encodedCPA, tvb, offset,length,ENC_NA);
pnrp_encodedCPA_tree = proto_item_add_subtree(pnrp_encodedCPA_item, ett_pnrp_message_encodedCPA);
/* Length information */
proto_tree_add_item(pnrp_encodedCPA_tree, hf_pnrp_encodedCPA_length, tvb, offset, 2, ENC_BIG_ENDIAN);
/* CPA Minor Version */
proto_tree_add_item(pnrp_encodedCPA_tree, hf_pnrp_encodedCPA_minorVersion, tvb, offset+2, 1, ENC_BIG_ENDIAN);
/* CPA Major Version */
proto_tree_add_item(pnrp_encodedCPA_tree, hf_pnrp_encodedCPA_majorVersion, tvb, offset+3, 1, ENC_BIG_ENDIAN);
/* PNRP Minor Version */
proto_tree_add_item(pnrp_encodedCPA_tree, hf_pnrp_header_versionMinor, tvb, offset+4, 1, ENC_BIG_ENDIAN);
/* PNRP Major Version */
proto_tree_add_item(pnrp_encodedCPA_tree, hf_pnrp_header_versionMajor, tvb, offset+5, 1, ENC_BIG_ENDIAN);
/* Flags Field */
proto_tree_add_bitmask(pnrp_encodedCPA_tree, tvb, offset+6, hf_pnrp_encodedCPA_flags, ett_pnrp_message_encodedCPA_flags, encodedCPA_flags, ENC_BIG_ENDIAN);
flagsField = tvb_get_guint8(tvb,offset+6);
/* Reserved */
proto_tree_add_item(pnrp_encodedCPA_tree, hf_pnrp_reserved8, tvb, offset + 7, 1, ENC_NA);
/* Not After */
proto_tree_add_item(pnrp_encodedCPA_tree, hf_pnrp_encodedCPA_notAfter, tvb, offset+8, 8, ENC_BIG_ENDIAN);
/* Service Location */
proto_tree_add_item(pnrp_encodedCPA_tree, hf_pnrp_encodedCPA_serviceLocation, tvb, offset+16, 16, ENC_NA);
/* now, the structure is variable, so add bytes to offset */
offset +=32;
/* Check if R Flag is set */
if ((flagsField & FLAGS_ENCODED_CPA_R)==0x00) {
/* Nonce follows */
proto_tree_add_item(pnrp_encodedCPA_tree, hf_pnrp_message_nonce, tvb, offset, 16, ENC_NA);
offset +=16;
}
/* Check if A Flag is set */
if (flagsField & FLAGS_ENCODED_CPA_A) {
/* Binary authority */
proto_tree_add_item(pnrp_encodedCPA_tree, hf_pnrp_encodedCPA_binaryAuthority, tvb, offset, 20, ENC_NA);
offset +=20;
}
/* Check if C Flag is set */
if (flagsField & FLAGS_ENCODED_CPA_C) {
/* Classifier Hash */
proto_tree_add_item(pnrp_encodedCPA_tree, hf_pnrp_encodedCPA_classifierHash, tvb, offset, 20, ENC_NA);
offset +=20;
}
/* Check if F Flag is set */
if (flagsField & FLAGS_ENCODED_CPA_F) {
/* Friendly Name Length */
proto_tree_add_item(pnrp_encodedCPA_tree, hf_pnrp_encodedCPA_friendlyName_length, tvb, offset, 2, ENC_LITTLE_ENDIAN);
/* Friendly Name */
proto_tree_add_item(pnrp_encodedCPA_tree, hf_pnrp_encodedCPA_friendlyName, tvb, offset+2, tvb_get_letohs(tvb,offset), ENC_ASCII);
offset +=tvb_get_letohs(tvb,offset)+2;
}
/* Service Address List */
proto_tree_add_item(pnrp_encodedCPA_tree, hf_pnrp_encodedCPA_number_of_service_addresses, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_item(pnrp_encodedCPA_tree, hf_pnrp_encodedCPA_service_address_length, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* A list of IPV6_Endpoint Structures follows */
dissect_ipv6_endpoint_structure(tvb, offset,tvb_get_letohs(tvb,offset-4)*tvb_get_letohs(tvb,offset-2) , pnrp_encodedCPA_tree);
offset += tvb_get_letohs(tvb,offset-4)*tvb_get_letohs(tvb,offset-2);
/* A number of Payload Structures */
proto_tree_add_item(pnrp_encodedCPA_tree, hf_pnrp_encodedCPA_number_of_payload_structures, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_item(pnrp_encodedCPA_tree, hf_pnrp_encodedCPA_total_bytes_of_payload, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
dissect_payload_structure(tvb,offset, tvb_get_letohs(tvb,offset-2)-4,pnrp_encodedCPA_tree);
offset += tvb_get_letohs(tvb,offset-2)-4;
/* Public Key */
dissect_publicKey_structure(tvb, offset,tvb_get_letohs(tvb,offset),pnrp_encodedCPA_tree);
offset += tvb_get_letohs(tvb,offset);
/* Signature */
dissect_signature_structure(tvb, offset,tvb_get_letohs(tvb,offset),pnrp_encodedCPA_tree);
/*offset += tvb_get_letohs(tvb,offset);*/
}
}
static void dissect_payload_structure(tvbuff_t *tvb, gint offset, gint length, proto_tree *tree)
{
guint16 lengthOfData;
/* Add a new Subtree */
proto_item *pnrp_payload_tree;
/* Check if we actually should display something */
if (0>=length )
return;
pnrp_payload_tree = proto_tree_add_subtree(tree, tvb, offset, length, ett_pnrp_message_payloadStructure, NULL, "Payload Structure");
/* Dissect the Payload Structure */
/* Payload Type */
proto_tree_add_item(pnrp_payload_tree, hf_pnrp_payload_type, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* Data Length */
lengthOfData = tvb_get_letohs(tvb,offset);
proto_tree_add_item(pnrp_payload_tree, hf_pnrp_length_of_data, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* IPV6_APP_ENDPOINT Structure */
while (0 <= tvb_reported_length_remaining(tvb, offset+20)&& 20 <= lengthOfData) {
dissect_ipv6_address(tvb, offset, 16, pnrp_payload_tree);
offset += 16;
proto_tree_add_item(pnrp_payload_tree, hf_pnrp_payload_port, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
proto_tree_add_item(pnrp_payload_tree, hf_pnrp_payload_iana_proto, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
lengthOfData -=20;
}
}
static void dissect_publicKey_structure(tvbuff_t *tvb, gint offset, gint length, proto_tree *tree)
{
guint16 objIDLength;
guint16 cbDataLength;
/* Add a new Subtree */
proto_tree *pnrp_publicKey_tree;
/* Check if we can safely parse Data */
if (0 < length && 0 <= tvb_reported_length_remaining(tvb, offset+length)) {
pnrp_publicKey_tree = proto_tree_add_subtree(tree, tvb, offset, length, ett_pnrp_message_publicKeyStructure, NULL, "CPA Public Key Structure");
/* Parsing of Data */
/* Field Length of Structure */
proto_tree_add_item(pnrp_publicKey_tree, hf_pnrp_publicKey_length_of_structure, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* ObjID length */
objIDLength = tvb_get_letohs(tvb,offset);
proto_tree_add_item(pnrp_publicKey_tree, hf_pnrp_publicKey_size_of_algorithm_oid, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* Reserved */
proto_tree_add_item(pnrp_publicKey_tree, hf_pnrp_publicKey_reserved, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset +=2;
/* Public Key cbData Length */
cbDataLength = tvb_get_letohs(tvb,offset);
proto_tree_add_item(pnrp_publicKey_tree, hf_pnrp_publicKey_size_of_cbdata, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* Unused Bits, actually only 7... */
proto_tree_add_item(pnrp_publicKey_tree, hf_pnrp_publicKey_unused_bits, tvb, offset, 1, ENC_NA);
offset +=1;
/* Algorithm ObjID */
proto_tree_add_item(pnrp_publicKey_tree, hf_pnrp_publicKey_objID, tvb, offset, objIDLength, ENC_ASCII);
offset += objIDLength;
/* Public Key Data */
proto_tree_add_item(pnrp_publicKey_tree, hf_pnrp_publicKey_publicKeyData, tvb, offset, cbDataLength, ENC_ASCII);
}
}
static void dissect_signature_structure(tvbuff_t *tvb, gint offset, gint length, proto_tree *tree)
{
guint16 signatureLength;
/* Add a new Subtree */
proto_tree *pnrp_signature_tree;
/* Check if we can safely parse Data */
if (0 < length && 0 <= tvb_reported_length_remaining(tvb, offset+length)) {
pnrp_signature_tree = proto_tree_add_subtree(tree, tvb, offset, length, ett_pnrp_message_signatureStructure, NULL, "Signature Structure");
/* Parsing of Data */
/* Field Length of Structure */
proto_tree_add_item(pnrp_signature_tree, hf_pnrp_signature_structure_length, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset +=2;
/* Signature Length */
signatureLength = tvb_get_letohs(tvb,offset);
proto_tree_add_item(pnrp_signature_tree, hf_pnrp_signature_length, tvb, offset, 2, ENC_LITTLE_ENDIAN);
offset += 2;
/* Hash Algorithm Identifier */
proto_tree_add_item(pnrp_signature_tree, hf_pnrp_signature_hash_id, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
/* Signature Data */
proto_tree_add_item(pnrp_signature_tree, hf_pnrp_signature_signatureData, tvb, offset, signatureLength, ENC_NA);
}
}
/* Register the protocol */
void proto_register_pnrp(void)
{
/* A header field is something you can search/filter on.
*
* We create a structure to register our fields. It consists of an
* array of hf_register_info structures, each of which are of the format
* {&(field id), {name, abbrev, type, display, strings, bitmask, blurb, HFILL}}.
*/
static hf_register_info hf[] = {
{ &hf_pnrp_header,
{ "Header", "pnrp.header", FT_NONE, BASE_NONE, NULL, 0x0,
"PNRP Header", HFILL }},
{ &hf_pnrp_header_fieldID,
{ "Header FieldID", "pnrp.header.fieldID", FT_UINT16, BASE_HEX, VALS(fieldID), 0x0,
NULL, HFILL }},
{ &hf_pnrp_header_length,
{ "Header length", "pnrp.header.length", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_pnrp_header_ident,
{ "Ident", "pnrp.ident", FT_UINT8, BASE_HEX, NULL, 0x0,
NULL, HFILL }},
{ &hf_pnrp_header_versionMajor,
{ "Version Major", "pnrp.vMajor", FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_pnrp_header_versionMinor,
{ "Version Minor", "pnrp.vMinor", FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_pnrp_header_messageType,
{ "Message Type", "pnrp.messageType", FT_UINT8, BASE_DEC, VALS(messageType), 0x0,
NULL, HFILL }},
{ &hf_pnrp_header_messageID,
{ "Message ID", "pnrp.header.messageID", FT_UINT32, BASE_HEX, NULL, 0x0,
NULL, HFILL }},
{ &hf_pnrp_message_type,
{ "Segment Type", "pnrp.segment.type", FT_UINT16, BASE_HEX, VALS(fieldID), 0x0,
NULL, HFILL }},
{ &hf_pnrp_message_length,
{ "Segment length", "pnrp.segment.length", FT_UINT16, BASE_DEC, NULL, 0x0,
"Message length", HFILL }},
{ &hf_pnrp_message_headerack,
{ "ACKed Header ID", "pnrp.segment.headerAck", FT_UINT32, BASE_HEX, NULL, 0x0,
NULL, HFILL }},
{ &hf_pnrp_message_pnrpID,
{ "PNRP ID", "pnrp.segment.pnrpID", FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
/* Inquire Flags */
{ &hf_pnrp_message_inquire_flags,
{ "Flags", "pnrp.segment.inquire.flags", FT_UINT16, BASE_HEX, NULL, 0x0,
NULL, HFILL }},
{ &hf_pnrp_message_inquire_flags_reserved1,
{ "Reserved 1", "pnrp.segment.inquire.flags.reserved1", FT_UINT16, BASE_HEX, NULL, FLAGS_INQUIRE_RESERVED1,
NULL, HFILL }},
{ &hf_pnrp_message_inquire_flags_Abit,
{ "CPA should (a)ppear in response", "pnrp.segment.inquire.flags.Abit", FT_UINT16, BASE_HEX, NULL, FLAGS_INQUIRE_A,
NULL, HFILL }},
{ &hf_pnrp_message_inquire_flags_Xbit,
{ "E(X)tended Payload sent in Authority response", "pnrp.segment.inquire.flags.Xbit", FT_UINT16, BASE_HEX, NULL, FLAGS_INQUIRE_X,
NULL, HFILL }},
{ &hf_pnrp_message_inquire_flags_Cbit,
{ "(C)ertificate Chain sent in Authority response", "pnrp.segment.inquire.flags.Cbit", FT_UINT16, BASE_HEX, NULL, FLAGS_INQUIRE_C,
NULL, HFILL }},
{ &hf_pnrp_message_inquire_flags_reserved2,
{ "Reserved 2", "pnrp.segment.inquire.flags.reserved2", FT_UINT16, BASE_HEX, NULL, FLAGS_INQUIRE_RESERVED2,
NULL, HFILL }},
{ &hf_pnrp_padding,
{ "Padding", "pnrp.padding", FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
/* Classifier */
{ &hf_pnrp_message_classifier_unicodeCount,
{ "Number of Unicode Characters", "pnrp.segment.classifier.unicodeCount", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_pnrp_message_classifier_arrayLength,
{ "Array Length", "pnrp.segment.classifier.arrayLength", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_pnrp_message_classifier_entryLength,
{ "Entry Length", "pnrp.segment.classifier.entryLength", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_pnrp_message_classifier_string,
{ "Classifier", "pnrp.segment.classifier.string", FT_STRING, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
/* Ack Flags */
{ &hf_pnrp_message_ack_flags_reserved,
{ "Reserved", "pnrp.segment.ack.flags.reserved", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_pnrp_message_ack_flags_Nbit,
{ "(N)ot found Bit", "pnrp.segment.ack.flags.Nbit", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
/* Authority Flags */
{ &hf_pnrp_message_authority_flags,
{ "Flags", "pnrp.segment.authority.flags", FT_UINT16, BASE_HEX, NULL, 0x0,
NULL, HFILL }},
{ &hf_pnrp_message_authority_flags_reserved1,
{ "Reserved 1", "pnrp.segment.authority.flags.reserved1", FT_UINT16, BASE_HEX, NULL, FLAGS_AUTHORITY_RESERVED1,
NULL, HFILL }},
{ &hf_pnrp_message_authority_flags_Lbit,
{ "(L)eaf Set", "pnrp.segment.authority.flags.Lbit", FT_UINT16, BASE_HEX, NULL, FLAGS_AUTHORITY_L,
NULL, HFILL }},
{ &hf_pnrp_message_authority_flags_reserved2,
{ "Reserved 2", "pnrp.segment.authority.flags.reserved2", FT_UINT16, BASE_HEX, NULL, FLAGS_AUTHORITY_RESERVED2,
NULL, HFILL }},
{ &hf_pnrp_message_authority_flags_Bbit,
{ "(B)usy", "pnrp.segment.authority.flags.Bbit", FT_UINT16, BASE_HEX, NULL, FLAGS_AUTHORITY_B,
NULL, HFILL }},
{ &hf_pnrp_message_authority_flags_reserved3,
{ "Reserved 3", "pnrp.segment.authority.flags.reserved3", FT_UINT16, BASE_HEX, NULL, FLAGS_AUTHORITY_RESERVED3,
NULL, HFILL }},
{ &hf_pnrp_message_authority_flags_Nbit,
{ "(N)ot found", "pnrp.segment.authority.flags.Nbit", FT_UINT16, BASE_HEX, NULL, FLAGS_AUTHORITY_N,
NULL, HFILL }},
/* Flood Control Flags */
{ &hf_pnrp_message_flood_flags_reserved1,
{ "Reserved", "pnrp.segment.flood.flags.reserved", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_pnrp_message_flood_flags_Dbit,
{ "(D)on't send ACK", "pnrp.segment.flood.flags.Dbit", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
/* Split Controls */
{ &hf_pnrp_message_splitControls_authorityBuffer,
{ "Authority Buffer Size", "pnrp.segment.splitControls.authorityBuffer", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
/* IPv6 Endpoint Array */
{ &hf_pnrp_message_ipv6EndpointArray_NumberOfEntries,
{ "Number of Entries", "pnrp.segment.ipv6EndpointArray.NumberOfEntries", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_pnrp_message_ipv6EndpointArray_ArrayLength,
{ "Array Length", "pnrp.segment.ipv6EndpointArray.ArrayLength", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_pnrp_message_ipv6EndpointArray_EntryLength,
{ "Entry Length", "pnrp.segment.ipv6EndpointArray.EntryLength", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
/* Encoded CPA structrue */
{ &hf_pnrp_encodedCPA,
{ "Encoded CPA structure", "pnrp.encodedCPA", FT_NONE, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_pnrp_encodedCPA_length,
{ "Length", "pnrp.encodedCPA.length", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_pnrp_encodedCPA_majorVersion,
{ "CPA Major Version", "pnrp.encodedCPA.vMajor", FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_pnrp_encodedCPA_minorVersion,
{ "CPA Minor Version", "pnrp.encodedCPA.vMinor", FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
/* Encoded CPA flags */
{ &hf_pnrp_encodedCPA_flags,
{ "Flags", "pnrp.encodedCPA.flags", FT_UINT8, BASE_HEX, NULL, 0x0,
NULL, HFILL }},
{ &hf_pnrp_encodedCPA_flags_reserved,
{ "Reserved", "pnrp.encodedCPA.flags.reserved", FT_UINT8, BASE_HEX, NULL, FLAGS_ENCODED_CPA_RESERVED,
NULL, HFILL }},
{ &hf_pnrp_encodedCPA_flags_Xbit,
{ "CPA has E(X)tended Payload", "pnrp.encodedCPA.flags.xbit", FT_UINT8, BASE_HEX, NULL, FLAGS_ENCODED_CPA_X,
NULL, HFILL }},
{ &hf_pnrp_encodedCPA_flags_Fbit,
{ "CPA contains (F)riendly Name", "pnrp.encodedCPA.flags.fbit", FT_UINT8, BASE_HEX, NULL, FLAGS_ENCODED_CPA_F,
NULL, HFILL }},
{ &hf_pnrp_encodedCPA_flags_Cbit,
{ "CPA contains (C)lassifier Hash", "pnrp.encodedCPA.flags.cbit", FT_UINT8, BASE_HEX, NULL, FLAGS_ENCODED_CPA_C,
NULL, HFILL }},
{ &hf_pnrp_encodedCPA_flags_Abit,
{ "CPA contains Binary (A)uthority field", "pnrp.encodedCPA.flags.abit", FT_UINT8, BASE_HEX, NULL, FLAGS_ENCODED_CPA_A,
NULL, HFILL }},
{ &hf_pnrp_encodedCPA_flags_Ubit,
{ "Friendly Name in (U)TF-8", "pnrp.encodedCPA.flags.ubit", FT_UINT8, BASE_HEX, NULL, FLAGS_ENCODED_CPA_U,
NULL, HFILL }},
{ &hf_pnrp_encodedCPA_flags_Rbit,
{ "This is a (r)evoke CPA", "pnrp.encodedCPA.flags.rbit", FT_UINT8, BASE_HEX, NULL, FLAGS_ENCODED_CPA_R,
NULL, HFILL }},
/* TODO: Find correct way to Display Time */
{ &hf_pnrp_encodedCPA_notAfter,
{ "CPA expiration Date", "pnrp.encodedCPA.expirationDate", FT_UINT64,BASE_DEC, NULL, 0x0,
"CPA expiration Date since January 1, 1601 UTC", HFILL }},
{ &hf_pnrp_encodedCPA_serviceLocation,
{ "Service Location", "pnrp.encodedCPA.serviceLocation", FT_BYTES,BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_pnrp_encodedCPA_binaryAuthority,
{ "Binary Authority", "pnrp.encodedCPA.binaryAuthority", FT_BYTES,BASE_NONE, NULL, 0x0,
"SHA-1 Hash of PublicKey Data field", HFILL }},
{ &hf_pnrp_encodedCPA_classifierHash,
{ "Classifier Hash", "pnrp.encodedCPA.classifierHash", FT_BYTES,BASE_NONE, NULL, 0x0,
"SHA-1 Hash of the classifier text", HFILL }},
{ &hf_pnrp_encodedCPA_friendlyName,
{ "Friendly Name of PNRP ID", "pnrp.encodedCPA.friendlyName", FT_STRING,BASE_NONE, NULL, 0x0,
"A human-readable label identifying the PNRP ID", HFILL }},
/* Lookup Controls */
{ &hf_pnrp_message_lookupControls_flags,
{ "Flags", "pnrp.lookupControls.flags", FT_UINT16, BASE_HEX, NULL, 0x0,
NULL, HFILL }},
{ &hf_pnrp_message_lookupControls_flags_reserved,
{ "Reserved", "pnrp.lookupControls.flags.reserved", FT_UINT16, BASE_HEX, NULL, FLAGS_LOOKUPCONTROLS_RESERVED,
NULL, HFILL }},
{ &hf_pnrp_message_lookupControls_flags_Abit,
{ "A bit", "pnrp.lookupControls.flags.Abit", FT_UINT16, BASE_HEX, NULL, FLAGS_LOOKUPCONTROLS_A,
"Sender is willing to accept returned nodes that are not closer to the target ID than the Validate PNRP ID", HFILL }},
{ &hf_pnrp_message_lookupControls_flags_0bit,
{ "0 bit - reserved", "pnrp.lookupControls.flags.0bit", FT_UINT16, BASE_HEX, NULL, FLAGS_LOOKUPCONTROLS_0,
NULL, HFILL }},
{ &hf_pnrp_message_lookupControls_precision,
{ "Precision", "pnrp.lookupControls.precision", FT_UINT16, BASE_HEX, NULL, 0x0,
"Precision - Number of significant bits to match", HFILL }},
{ &hf_pnrp_message_lookupControls_resolveCriteria,
{ "Resolve Criteria", "pnrp.lookupControls.resolveCriteria", FT_UINT8, BASE_HEX, VALS(resolveCriteria), 0x0,
NULL, HFILL }},
{ &hf_pnrp_message_lookupControls_reasonCode,
{ "Reason Code", "pnrp.lookupControls.reasonCode", FT_UINT8, BASE_HEX, VALS(reasonCode), 0x0,
NULL, HFILL }},
/* Public Key Structure */
{ &hf_pnrp_publicKey_objID,
{ "Public Key Object Identifier", "pnrp.publicKey.objID", FT_STRING,BASE_NONE, NULL, 0x0,
"An ASN.1-encoded object identifier (OID) indicating the public key format", HFILL }},
{ &hf_pnrp_publicKey_publicKeyData,
{ "Public Key Data", "pnrp.publicKey.publicKeyData", FT_STRING,BASE_NONE, NULL, 0x0,
"An ASN.1-encoded 1024-bit RSA public key", HFILL }},
/* Signature Structure */
{ &hf_pnrp_signature_signatureData,
{ "Signature", "pnrp.signature.data", FT_BYTES,BASE_NONE, NULL, 0x0,
"Signature created when signing the CPA", HFILL }},
/* Route Entry */
{ &hf_pnrp_message_routeEntry_portNumber,
{ "Port Number", "pnrp.segment.routeEntry.portNumber", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_pnrp_message_routeEntry_flags,
{ "Flags", "pnrp.segment.routeEntry.flags", FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_pnrp_message_routeEntry_addressCount,
{ "Address Count", "pnrp.segment.routeEntry.addressCount", FT_UINT8, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_pnrp_message_nonce,
{ "Nonce", "pnrp.segment.nonce", FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_pnrp_message_hashednonce,
{ "Hashed Nonce", "pnrp.segment.hashednonce", FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{ &hf_pnrp_message_idArray_NumEntries,
{ "Number of Entries", "pnrp.segment.idArray.NumEntries", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_pnrp_message_idArray_Length,
{ "Length of Array", "pnrp.segment.idArray.Length", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_pnrp_message_ElementFieldType,
{ "Type of Array Entry", "pnrp.segment.ElementFieldType", FT_UINT16, BASE_HEX, VALS(fieldID), 0x0,
NULL, HFILL }},
{ &hf_pnrp_message_idarray_Entrylength,
{ "Length of each Array Entry", "pnrp.segment.idArray.Entrylength", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_pnrp_message_certChain,
{ "Certificate Chain", "pnrp.segment.certChain", FT_BYTES,BASE_NONE, NULL, 0x0,
"A Certificate Chain, containing the public key used to sign the CPA and its Certificate Chain", HFILL }},
{ &hf_pnrp_message_solicitType,
{ "Solicit Type", "pnrp.segment.solicitType", FT_UINT8, BASE_DEC, VALS(solicitType), 0x0,
NULL, HFILL }},
{ &hf_pnrp_message_ipv6,
{ "IPv6 Address","pnrp.segment.ipv6Address",FT_IPv6, BASE_NONE, NULL, 0x0,NULL,HFILL}},
{ &hf_pnrp_fragments,
{ "Fragments", "pnrp.segment.splitControls.fragments", FT_NONE, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_pnrp_fragment,
{ "Fragment", "pnrp.segment.splitControls.fragment", FT_FRAMENUM, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_pnrp_fragment_overlap,
{ "Fragment Overlap", "pnrp.segment.splitControls.fragment_overlap", FT_BOOLEAN, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_pnrp_fragment_overlap_conflict,
{ "Fragment Overlap Conflict", "pnrp.segment.splitControls.fragment_overlap_conflict", FT_BOOLEAN, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_pnrp_fragment_multiple_tails,
{ "Fragment Multiple Tails", "pnrp.segment.splitControls.fragment_multiple_tails", FT_BOOLEAN, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_pnrp_fragment_too_long_fragment,
{ "Too Long Fragment", "pnrp.segment.splitControls.fragment_too_long_fragment", FT_BOOLEAN, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_pnrp_fragment_error,
{ "Fragment Error", "pnrp.segment.splitControls.fragment_error", FT_FRAMENUM, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_pnrp_fragment_count,
{ "Fragment Count", "pnrp.segment.splitControls.fragment_count", FT_UINT32, BASE_DEC, NULL, 0,
NULL, HFILL }},
{ &hf_pnrp_reassembled_in,
{ "Reassembled In", "pnrp.segment.splitControls.reassembled_in", FT_FRAMENUM, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_pnrp_reassembled_length,
{ "Reassembled Length", "pnrp.segment.splitControls.reassembled_length", FT_UINT32, BASE_DEC, NULL, 0,
NULL, HFILL }},
{ &hf_pnrp_reassembled_data,
{ "Reassembled Data", "pnrp.segment.splitControls.reassembled_data", FT_BYTES, BASE_NONE, NULL, 0,
NULL, HFILL }},
{ &hf_pnrp_fragmented_payload,
{ "Fragmented Payload", "pnrp.segment.splitControls.fragmented_payload", FT_BYTES, BASE_NONE, NULL, 0,
NULL, HFILL }},
/* Generated from convert_proto_tree_add_text.pl */
{ &hf_pnrp_message_flags, { "Flags", "pnrp.segment.flags", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
{ &hf_pnrp_reserved8, { "Reserved", "pnrp.reserved", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_pnrp_reserved16, { "Reserved", "pnrp.reserved", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_pnrp_message_offset, { "Offset", "pnrp.segment.offset", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_pnrp_message_data, { "Data", "pnrp.segment.data", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
{ &hf_pnrp_message_port_number, { "Port Number", "pnrp.segment.port_number", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_pnrp_encodedCPA_friendlyName_length, { "Length of Friendly name", "pnrp.encodedCPA.friendlyName.length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_pnrp_encodedCPA_number_of_service_addresses, { "Number of Service Addresses", "pnrp.encodedCPA.number_of_service_addresses", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_pnrp_encodedCPA_service_address_length, { "Service Address Length", "pnrp.encodedCPA.service_address_length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_pnrp_encodedCPA_number_of_payload_structures, { "Number of Payload Structures", "pnrp.encodedCPA.number_of_payload_structures", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_pnrp_encodedCPA_total_bytes_of_payload, { "Total Bytes of Payload", "pnrp.encodedCPA.total_bytes_of_payload", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_pnrp_payload_type, { "Payload Type", "pnrp.payload.type", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_pnrp_length_of_data, { "Length of Data", "pnrp.payload.length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_pnrp_payload_port, { "Port Number", "pnrp.payload.port", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_pnrp_payload_iana_proto, { "IANA Protocol Number", "pnrp.payload.iana_proto", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_pnrp_publicKey_length_of_structure, { "Length of Structure", "pnrp.publicKey.structure_length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_pnrp_publicKey_size_of_algorithm_oid, { "Size of Algorithm OID", "pnrp.publicKey.algorithm_oid_size", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_pnrp_publicKey_reserved, { "Reserved", "pnrp.publicKey.reserved", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_pnrp_publicKey_size_of_cbdata, { "Size of cbData", "pnrp.publicKey.cbdata_size", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_pnrp_publicKey_unused_bits, { "Unused Bits", "pnrp.publicKey.unused_bits", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_pnrp_signature_structure_length, { "Length of Structure", "pnrp.signature.structure_length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_pnrp_signature_length, { "Length of Signature", "pnrp.signature.length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_pnrp_signature_hash_id, { "Hash Algorithm Identifier", "pnrp.signature.hash_id", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
};
/* Protocol subtree array */
static gint *ett[] = {
&ett_pnrp,
&ett_pnrp_header,
&ett_pnrp_message,
&ett_pnrp_message_inquire_flags,
&ett_pnrp_message_authority_flags,
&ett_pnrp_message_encodedCPA,
&ett_pnrp_message_encodedCPA_flags,
&ett_pnrp_message_payloadStructure,
&ett_pnrp_message_publicKeyStructure,
&ett_pnrp_message_signatureStructure,
&ett_pnrp_message_lookupControls_flags,
&ett_pnrp_fragment,
&ett_pnrp_fragments
};
/* Register the Dissector with Wireshark */
proto_pnrp = proto_register_protocol(PROTONAME,PROTOSHORTNAME,PROTOABBREV);
proto_register_field_array(proto_pnrp,hf,array_length(hf));
proto_register_subtree_array (ett, array_length(ett));
pnrp_handle = register_dissector(PROTOABBREV, dissect_pnrp, proto_pnrp);
reassembly_table_register(&pnrp_reassembly_table,
&addresses_reassembly_table_functions);
}
/* Initialise the dissector */
void proto_reg_handoff_pnrp(void)
{
dissector_add_uint_with_preference("udp.port",PNRP_PORT,pnrp_handle);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 4
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* vi: set shiftwidth=4 tabstop=8 expandtab:
* :indentSize=4:tabSize=8:noTabs=true:
*/
|