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
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
|
/* packet-p_mul.c
*
* Routines for P_Mul (ACP142) packet disassembly.
* A protocol for reliable multicast messaging in bandwidth constrained
* and delayed acknowledgement (EMCON) environments.
*
* Copyright 2005, Stig Bjorlykke <stig@bjorlykke.org>, Thales Norway AS
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*
* Ref: http://jcs.dtic.mil/j6/cceb/acps/acp142/
*/
/*
* TODO:
* - Obtain dedicated UDP port numbers
* - SEQ/ACK analysis for Announce/Request/Reject/Release PDU
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/prefs.h>
#include <epan/reassemble.h>
#include <epan/expert.h>
#include <epan/asn1.h>
#include <epan/in_cksum.h>
#include <epan/proto_data.h>
#include <wsutil/str_util.h>
#include "packet-cdt.h"
#include "packet-ber.h"
#include "packet-s5066sis.h"
void proto_register_p_mul(void);
void proto_reg_handoff_p_mul(void);
#define PNAME "P_Mul (ACP142)"
#define PSNAME "P_MUL"
#define PFNAME "p_mul"
/* Recommended UDP Port Numbers */
#define DEFAULT_P_MUL_PORT_RANGE ""
/* PDU Types */
#define Data_PDU 0x00
#define Ack_PDU 0x01
#define Address_PDU 0x02
#define Discard_Message_PDU 0x03
#define Announce_PDU 0x04
#define Request_PDU 0x05
#define Reject_PDU 0x06
#define Release_PDU 0x07
#define FEC_Address_PDU 0x08
#define Extra_Address_PDU 0x12
#define Extra_FEC_Address_PDU 0x18
#define Ack_Ack_PDU 0xFF /* Fake type to indicate Ack-Ack */
/* Type of content to decode from Data_PDU */
#define DECODE_NONE 0
#define DECODE_BER 1
#define DECODE_CDT 2
static int proto_p_mul = -1;
static int hf_length = -1;
static int hf_priority = -1;
static int hf_map_first = -1;
static int hf_map_last = -1;
static int hf_map_unused = -1;
static int hf_pdu_type = -1;
static int hf_pdu_type_value = -1;
static int hf_no_pdus = -1;
static int hf_seq_no = -1;
static int hf_unused8 = -1;
static int hf_unused16 = -1;
static int hf_checksum = -1;
static int hf_checksum_good = -1;
static int hf_checksum_bad = -1;
static int hf_source_id_ack = -1;
static int hf_source_id = -1;
static int hf_message_id = -1;
static int hf_expiry_time = -1;
static int hf_mc_group = -1;
static int hf_ann_mc_group = -1;
static int hf_fec_len = -1;
static int hf_fec_id = -1;
static int hf_fec_parameters = -1;
static int hf_count_of_dest = -1;
static int hf_length_of_res = -1;
static int hf_ack_count = -1;
static int hf_ack_entry = -1;
static int hf_ack_length = -1;
static int hf_miss_seq_no = -1;
static int hf_miss_seq_range = -1;
static int hf_miss_seq_range_from = -1;
static int hf_miss_seq_range_delimiter = -1;
static int hf_miss_seq_range_to = -1;
static int hf_tot_miss_seq_no = -1;
static int hf_timestamp_option = -1;
static int hf_dest_entry = -1;
static int hf_dest_id = -1;
static int hf_msg_seq_no = -1;
static int hf_sym_key = -1;
static int hf_data_fragment = -1;
static int hf_msg_fragments = -1;
static int hf_msg_fragment = -1;
static int hf_msg_fragment_overlap = -1;
static int hf_msg_fragment_overlap_conflicts = -1;
static int hf_msg_fragment_multiple_tails = -1;
static int hf_msg_fragment_too_long_fragment = -1;
static int hf_msg_fragment_error = -1;
static int hf_msg_fragment_count = -1;
static int hf_msg_reassembled_in = -1;
static int hf_msg_reassembled_length = -1;
static int hf_analysis_ack_time = -1;
static int hf_analysis_trans_time = -1;
static int hf_analysis_retrans_time = -1;
static int hf_analysis_total_retrans_time = -1;
static int hf_analysis_last_pdu_num = -1;
static int hf_analysis_addr_pdu_num = -1;
static int hf_analysis_acks_addr_pdu_num = -1;
static int hf_analysis_acks_acked_addr_pdu_num = -1;
static int hf_analysis_addr_pdu_time = -1;
static int hf_analysis_prev_pdu_num = -1;
static int hf_analysis_prev_pdu_time = -1;
static int hf_analysis_retrans_no = -1;
static int hf_analysis_ack_num = -1;
static int hf_analysis_ack_missing = -1;
static int hf_analysis_ack_dup_no = -1;
static int hf_analysis_msg_resend_from = -1;
static int hf_analysis_ack_resend_from = -1;
static int hf_analysis_total_time = -1;
static gint ett_p_mul = -1;
static gint ett_pdu_type = -1;
static gint ett_dest_entry = -1;
static gint ett_ack_entry = -1;
static gint ett_range_entry = -1;
static gint ett_checksum = -1;
static gint ett_seq_analysis = -1;
static gint ett_ack_analysis = -1;
static gint ett_seq_ack_analysis = -1;
static gint ett_msg_fragment = -1;
static gint ett_msg_fragments = -1;
static expert_field ei_more_data = EI_INIT;
static expert_field ei_checksum_bad = EI_INIT;
static expert_field ei_illegal_seq_no = EI_INIT;
static expert_field ei_tot_miss_seq_no = EI_INIT;
static expert_field ei_miss_seq_no = EI_INIT;
static expert_field ei_analysis_ack_missing = EI_INIT;
static expert_field ei_miss_seq_range = EI_INIT;
static expert_field ei_address_pdu_missing = EI_INIT;
static expert_field ei_analysis_ack_dup_no = EI_INIT;
static expert_field ei_length = EI_INIT;
static expert_field ei_analysis_prev_pdu_missing = EI_INIT;
static expert_field ei_message_discarded = EI_INIT;
static expert_field ei_ack_length = EI_INIT;
static expert_field ei_analysis_retrans_no = EI_INIT;
static dissector_handle_t p_mul_handle = NULL;
typedef struct _p_mul_id_key {
guint32 id;
guint16 seq;
address addr;
} p_mul_id_key;
typedef struct _p_mul_seq_val {
gint msg_type; /* Message type */
guint32 prev_msg_id; /* Previous message package num */
nstime_t prev_msg_time; /* Previous message receive time */
guint32 addr_id; /* PDU package num for Address_PDU */
nstime_t addr_time; /* PDU received time for Address_PDU */
guint32 pdu_id; /* PDU package num */
nstime_t pdu_time; /* PDU receive time */
guint32 prev_pdu_id; /* Previous PDU package num */
nstime_t prev_pdu_time; /* Previous PDU receive time */
guint16 last_found_pdu; /* Last PDU num */
nstime_t first_msg_time; /* First message receive time */
guint32 msg_resend_count; /* Message resend counter */
wmem_map_t *ack_data;
} p_mul_seq_val;
typedef struct _p_mul_ack_data {
guint32 ack_id; /* Ack PDU package num */
guint32 ack_resend_count; /* Ack resend counter */
} p_mul_ack_data;
/* Hash table with current data for seq/ack analysis */
static wmem_map_t *p_mul_id_hash_table = NULL;
/* User definable values to use for dissection */
static gboolean p_mul_reassemble = TRUE;
static gint decode_option = DECODE_NONE;
static gboolean use_relative_msgid = TRUE;
static gboolean use_seq_ack_analysis = TRUE;
static reassembly_table p_mul_reassembly_table;
static guint32 message_id_offset = 0;
static const fragment_items p_mul_frag_items = {
/* Fragment subtrees */
&ett_msg_fragment,
&ett_msg_fragments,
/* Fragment fields */
&hf_msg_fragments,
&hf_msg_fragment,
&hf_msg_fragment_overlap,
&hf_msg_fragment_overlap_conflicts,
&hf_msg_fragment_multiple_tails,
&hf_msg_fragment_too_long_fragment,
&hf_msg_fragment_error,
&hf_msg_fragment_count,
/* Reassembled in field */
&hf_msg_reassembled_in,
/* Reassembled length field */
&hf_msg_reassembled_length,
/* Reassembled data field */
NULL,
/* Tag */
"Message fragments"
};
static const value_string pdu_vals[] = {
{ Data_PDU, "Data PDU" },
{ Ack_PDU, "Ack PDU" },
{ Address_PDU, "Address PDU" },
{ Discard_Message_PDU, "Discard Message PDU" },
{ Announce_PDU, "Announce PDU" },
{ Request_PDU, "Request PDU" },
{ Reject_PDU, "Reject PDU" },
{ Release_PDU, "Release PDU" },
{ FEC_Address_PDU, "FEC Address PDU" },
{ Extra_Address_PDU, "Extra Address PDU" },
{ Extra_FEC_Address_PDU, "Extra FEC Address PDU" },
{ Ack_Ack_PDU, "Ack-Ack PDU" },
{ 0, NULL }
};
static const enum_val_t decode_options[] = {
{ "none", "No decoding", DECODE_NONE },
{ "ber", "BER encoded ASN.1", DECODE_BER },
{ "cdt", "Compressed Data Type", DECODE_CDT },
{ NULL, NULL, 0 }
};
static const gchar *get_type (guint8 value)
{
return val_to_str_const (value, pdu_vals, "Unknown");
}
/* Function checksum, found in ACP 142 annex B04 (Fletcher algorithm) */
static guint16 checksum_acp142 (guint8 *buffer, gint len, gint offset)
{
guint16 c0 = 0, c1 = 0, ret, ctmp;
gint16 cs;
guint8 *hpp, *pls;
if (len < offset+2) {
/* Buffer too small */
return 0;
}
ctmp = len - offset - 1;
pls = buffer + len;
hpp = buffer;
while (hpp < pls) {
if ((c0 += *hpp++) > 254) { c0 -= 255; }
if ((c1 += c0) > 254) { c1 -= 255; }
}
if ((cs = ((ctmp * c0) - c1) % 255) < 0) { cs += 255; }
ret = cs << 8;
if ((cs = (c1 - ((ctmp + 1L) * c0)) % 255) < 0) { cs += 255; }
ret |= cs;
return ret;
}
static guint p_mul_id_hash (gconstpointer k)
{
const p_mul_id_key *p_mul = (const p_mul_id_key *)k;
return p_mul->id;
}
static gint p_mul_id_hash_equal (gconstpointer k1, gconstpointer k2)
{
const p_mul_id_key *p_mul1 = (const p_mul_id_key *)k1;
const p_mul_id_key *p_mul2 = (const p_mul_id_key *)k2;
if (p_mul1->id != p_mul2->id)
return 0;
if (p_mul1->seq != p_mul2->seq)
return 0;
return (addresses_equal (&p_mul1->addr, &p_mul2->addr));
}
static p_mul_seq_val *lookup_seq_val (guint32 message_id, guint16 seq_no,
address *addr)
{
p_mul_seq_val *pkg_data;
p_mul_id_key *p_mul_key = wmem_new(wmem_file_scope(), p_mul_id_key);
p_mul_key->id = message_id;
p_mul_key->seq = seq_no;
copy_address_wmem(wmem_file_scope(), &p_mul_key->addr, addr);
pkg_data = (p_mul_seq_val *) wmem_map_lookup (p_mul_id_hash_table, p_mul_key);
return pkg_data;
}
static void copy_hashtable_data (gpointer key, gpointer value, gpointer user_data)
{
p_mul_ack_data *ack_data1 = (p_mul_ack_data*)value;
p_mul_ack_data *ack_data2;
wmem_map_t *table = (wmem_map_t*)user_data;
ack_data2 = wmem_new(wmem_file_scope(), p_mul_ack_data);
ack_data2->ack_id = ack_data1->ack_id;
ack_data2->ack_resend_count = ack_data1->ack_resend_count;
wmem_map_insert (table, key, ack_data2);
}
static p_mul_seq_val *register_p_mul_id (packet_info *pinfo, address *addr, guint32 dstIP,
guint8 pdu_type, guint32 message_id,
guint16 seq_no, gint no_missing)
{
p_mul_seq_val *p_mul_data = NULL, *pkg_data = NULL;
p_mul_id_key *p_mul_key;
p_mul_ack_data *ack_data = NULL;
nstime_t addr_time, prev_time;
guint addr_id = 0, prev_id = 0;
guint16 last_found_pdu = 0;
gboolean missing_pdu = FALSE, need_set_address = FALSE;
wmem_map_t *pkg_list;
if (pinfo->flags.in_error_pkt) {
/* No analysis of error packets */
return NULL;
}
if (pdu_type == Data_PDU && seq_no == 0) {
/* Illegal sequence number for Data PDU */
return NULL;
}
nstime_set_zero(&addr_time);
nstime_set_zero(&prev_time);
p_mul_key = wmem_new(wmem_file_scope(), p_mul_id_key);
if (!pinfo->fd->visited &&
(pdu_type == Address_PDU || pdu_type == Data_PDU || pdu_type == Discard_Message_PDU))
{
/* Try to match corresponding address PDU */
p_mul_key->id = message_id;
p_mul_key->seq = 0;
copy_address_wmem(wmem_file_scope(), &p_mul_key->addr, addr);
need_set_address = TRUE;
p_mul_data = (p_mul_seq_val *) wmem_map_lookup (p_mul_id_hash_table, p_mul_key);
if (p_mul_data) {
/* Found address PDU */
last_found_pdu = p_mul_data->last_found_pdu;
p_mul_data->last_found_pdu = seq_no;
addr_id = p_mul_data->pdu_id;
addr_time = p_mul_data->pdu_time;
/* Save data for last found PDU */
p_mul_data->prev_pdu_id = pinfo->num;
p_mul_data->prev_pdu_time = pinfo->abs_ts;
if (pdu_type == Data_PDU && p_mul_data->msg_resend_count == 0 && last_found_pdu != seq_no - 1) {
/* Data_PDU and missing previous PDU */
missing_pdu = TRUE;
}
if (last_found_pdu) {
/* Try to match previous data PDU */
p_mul_key->seq = last_found_pdu;
p_mul_data = (p_mul_seq_val *) wmem_map_lookup (p_mul_id_hash_table, p_mul_key);
}
if (p_mul_data) {
/* Found a previous PDU (Address or Data) */
if (p_mul_data->prev_msg_id > 0) {
prev_id = p_mul_data->prev_msg_id;
} else {
prev_id = p_mul_data->pdu_id;
}
prev_time = p_mul_data->pdu_time;
}
} else if (pdu_type == Address_PDU) {
addr_id = pinfo->num;
addr_time = pinfo->abs_ts;
}
}
pkg_list = (wmem_map_t *)p_get_proto_data(wmem_file_scope(), pinfo, proto_p_mul, 0);
if (!pkg_list) {
/* Never saved list for this packet, create a new */
pkg_list = wmem_map_new(wmem_file_scope(), g_direct_hash, g_direct_equal);
p_add_proto_data(wmem_file_scope(), pinfo, proto_p_mul, 0, pkg_list);
}
if (!pinfo->fd->visited) {
p_mul_key->id = message_id;
p_mul_key->seq = seq_no;
if (!need_set_address) {
copy_address_wmem(wmem_file_scope(), &p_mul_key->addr, addr);
}
p_mul_data = (p_mul_seq_val *) wmem_map_lookup (p_mul_id_hash_table, p_mul_key);
if (p_mul_data) {
if (pdu_type == Ack_PDU) {
/* Only save this data if positive ack */
if (no_missing == 0) {
ack_data = (p_mul_ack_data *)wmem_map_lookup (p_mul_data->ack_data, GUINT_TO_POINTER(dstIP));
if (!ack_data) {
/* Only save reference to first ACK */
ack_data = wmem_new0(wmem_file_scope(), p_mul_ack_data);
ack_data->ack_id = pinfo->num;
wmem_map_insert (p_mul_data->ack_data, GUINT_TO_POINTER(dstIP), ack_data);
} else {
/* Only count when resending */
ack_data->ack_resend_count++;
}
}
} else {
/* Message resent */
p_mul_data->msg_resend_count++;
p_mul_data->prev_msg_id = pinfo->num;
p_mul_data->prev_msg_time = p_mul_data->pdu_time;
p_mul_data->pdu_time = pinfo->abs_ts;
if (pdu_type == Data_PDU) {
p_mul_data->prev_pdu_id = prev_id;
p_mul_data->prev_pdu_time = prev_time;
}
}
} else {
/* New message */
if (pdu_type == Ack_PDU) {
/* Data is just copied to the structure and never stored,
so keep a "more temporary" structure */
p_mul_data = wmem_new0(pinfo->pool, p_mul_seq_val);
} else {
p_mul_data = wmem_new0(wmem_file_scope(), p_mul_seq_val);
}
p_mul_data->msg_type = pdu_type;
if (pdu_type == Address_PDU || pdu_type == Ack_PDU) {
p_mul_data->ack_data = wmem_map_new(wmem_file_scope(), g_direct_hash, g_direct_equal);
}
if (pdu_type == Ack_PDU) {
/* No matching message for this ack */
ack_data = wmem_new0(wmem_file_scope(), p_mul_ack_data);
ack_data->ack_id = pinfo->num;
wmem_map_insert (p_mul_data->ack_data, GUINT_TO_POINTER(dstIP), ack_data);
} else {
p_mul_data->pdu_id = pinfo->num;
p_mul_data->pdu_time = pinfo->abs_ts;
p_mul_data->addr_id = addr_id;
p_mul_data->addr_time = addr_time;
p_mul_data->first_msg_time = pinfo->abs_ts;
if (pdu_type == Data_PDU && !missing_pdu) {
p_mul_data->prev_pdu_id = prev_id;
p_mul_data->prev_pdu_time = prev_time;
}
wmem_map_insert (p_mul_id_hash_table, p_mul_key, p_mul_data);
}
}
/* Copy the current package data to the frame */
pkg_data = wmem_new(wmem_file_scope(), p_mul_seq_val);
*pkg_data = *p_mul_data;
if (p_mul_data->ack_data) {
/* Copy the hash table for ack data */
pkg_data->ack_data = wmem_map_new(wmem_file_scope(), g_direct_hash, g_direct_equal);
wmem_map_foreach (p_mul_data->ack_data, copy_hashtable_data, pkg_data->ack_data);
}
wmem_map_insert(pkg_list, GUINT_TO_POINTER(message_id), pkg_data);
} else {
/* Fetch last values from data saved in packet */
pkg_data = (p_mul_seq_val *)wmem_map_lookup (pkg_list, GUINT_TO_POINTER(message_id));
}
DISSECTOR_ASSERT (pkg_data);
return pkg_data;
}
static void add_ack_analysis (tvbuff_t *tvb, packet_info *pinfo, proto_tree *p_mul_tree,
gint offset, guint8 pdu_type, address *src, address *dst,
guint32 message_id, gint no_missing)
{
proto_tree *analysis_tree = NULL;
proto_item *sa = NULL;
proto_item *en = NULL;
p_mul_seq_val *pkg_data = NULL;
p_mul_ack_data *ack_data = NULL;
gboolean item_added = FALSE;
guint32 dstIp;
nstime_t ns;
if (pinfo->flags.in_error_pkt) {
/* No analysis of error packets */
return;
}
if (pdu_type == Address_PDU) {
analysis_tree = proto_tree_add_subtree(p_mul_tree, tvb, 0, 0, ett_ack_analysis, &sa, "ACK analysis");
proto_item_set_generated (sa);
/* Fetch package data */
if ((pkg_data = lookup_seq_val (message_id, 0, src)) == NULL) {
/* No need for seq/ack analysis yet */
return;
}
if (dst == NULL) {
/* Ack-Ack */
if (pkg_data->addr_id) {
en = proto_tree_add_uint (analysis_tree, hf_analysis_acks_acked_addr_pdu_num, tvb,
0, 0, pkg_data->addr_id);
proto_item_set_generated (en);
nstime_delta (&ns, &pinfo->abs_ts, &pkg_data->addr_time);
en = proto_tree_add_time (analysis_tree, hf_analysis_total_time,
tvb, 0, 0, &ns);
proto_item_set_generated (en);
} else {
proto_tree_add_expert(analysis_tree, pinfo, &ei_address_pdu_missing, tvb, offset, 0);
}
item_added = TRUE;
} else {
memcpy((guint8 *)&dstIp, dst->data, 4);
if (pkg_data->ack_data) {
ack_data = (p_mul_ack_data *)wmem_map_lookup (pkg_data->ack_data, GUINT_TO_POINTER(dstIp));
}
/* Add reference to Ack_PDU */
if (ack_data && ack_data->ack_id) {
en = proto_tree_add_uint (analysis_tree, hf_analysis_ack_num, tvb,
0, 0, ack_data->ack_id);
proto_item_set_generated (en);
item_added = TRUE;
} else if (!pkg_data->msg_resend_count) {
en = proto_tree_add_item (analysis_tree,
hf_analysis_ack_missing,
tvb, offset, 0, ENC_NA);
if (pinfo->fd->visited) {
/* We do not know this on first visit and we do not want to
add a entry in the "Expert Severity Info" for this note */
expert_add_info(pinfo, en, &ei_analysis_ack_missing);
proto_item_set_generated (en);
}
item_added = TRUE;
}
}
if (!item_added) {
proto_item_set_hidden (sa);
}
} else if (pdu_type == Ack_PDU) {
analysis_tree = proto_tree_add_subtree(p_mul_tree, tvb, 0, 0, ett_seq_ack_analysis, &sa, "SEQ/ACK analysis");
proto_item_set_generated (sa);
/* Fetch package data */
memcpy((guint8 *)&dstIp, dst->data, 4);
if ((pkg_data = register_p_mul_id (pinfo, src, dstIp, pdu_type, message_id, 0, no_missing)) == NULL) {
/* No need for seq/ack analysis yet */
return;
}
if (pkg_data->ack_data) {
ack_data = (p_mul_ack_data *)wmem_map_lookup(pkg_data->ack_data, GUINT_TO_POINTER(dstIp));
}
/* Add reference to Address_PDU */
if (pkg_data->msg_type != Ack_PDU) {
en = proto_tree_add_uint (analysis_tree, hf_analysis_acks_addr_pdu_num, tvb,
0, 0, pkg_data->pdu_id);
proto_item_set_generated (en);
if (no_missing == 0) {
nstime_delta (&ns, &pinfo->abs_ts, &pkg_data->first_msg_time);
en = proto_tree_add_time (analysis_tree, hf_analysis_trans_time,
tvb, 0, 0, &ns);
proto_item_set_generated (en);
}
} else {
proto_tree_add_expert(analysis_tree, pinfo, &ei_address_pdu_missing, tvb, offset, 0);
}
if (pkg_data->msg_type != Ack_PDU && pkg_data->prev_pdu_id) {
/* Add reference to previous PDU */
en = proto_tree_add_uint (analysis_tree, hf_analysis_last_pdu_num,
tvb, 0, 0, pkg_data->prev_pdu_id);
proto_item_set_generated (en);
nstime_delta (&ns, &pinfo->abs_ts, &pkg_data->prev_pdu_time);
en = proto_tree_add_time (analysis_tree, hf_analysis_ack_time,
tvb, 0, 0, &ns);
proto_item_set_generated (en);
}
if (ack_data && ack_data->ack_resend_count) {
/* Add resend statistics */
en = proto_tree_add_uint (analysis_tree, hf_analysis_ack_dup_no,
tvb, 0, 0, ack_data->ack_resend_count);
proto_item_set_generated (en);
expert_add_info_format(pinfo, en, &ei_analysis_ack_dup_no, "Dup ACK #%d", ack_data->ack_resend_count);
en = proto_tree_add_uint (analysis_tree, hf_analysis_ack_resend_from,
tvb, 0, 0, ack_data->ack_id);
proto_item_set_generated (en);
col_append_fstr (pinfo->cinfo, COL_INFO, "[Dup ACK %d#%d] ",
ack_data->ack_id, ack_data->ack_resend_count);
}
}
}
static p_mul_seq_val *add_seq_analysis (tvbuff_t *tvb, packet_info *pinfo,
proto_tree *p_mul_tree, address *src,
gint offset,
guint8 pdu_type, guint32 message_id,
guint16 seq_no, gint no_missing)
{
p_mul_seq_val *pkg_data;
proto_tree *analysis_tree;
proto_item *sa, *en = NULL, *eh = NULL;
gboolean item_added = FALSE;
nstime_t ns;
pkg_data = register_p_mul_id (pinfo, src, 0, pdu_type, message_id, seq_no,
no_missing);
if (!pkg_data) {
/* No need for seq/ack analysis */
return NULL;
}
analysis_tree = proto_tree_add_subtree(p_mul_tree, tvb, 0, 0, ett_seq_analysis, &sa, "SEQ analysis");
proto_item_set_generated (sa);
if (pdu_type == Data_PDU || pdu_type == Discard_Message_PDU) {
/* Add reference to Address_PDU */
if (pkg_data->addr_id) {
en = proto_tree_add_uint (analysis_tree, hf_analysis_addr_pdu_num, tvb,
0, 0, pkg_data->addr_id);
proto_item_set_generated (en);
nstime_delta (&ns, &pinfo->abs_ts, &pkg_data->addr_time);
en = proto_tree_add_time (analysis_tree, hf_analysis_addr_pdu_time,
tvb, 0, 0, &ns);
proto_item_set_generated (en);
if (pkg_data->prev_pdu_id == pkg_data->addr_id) {
/* Previous pdu time is the same as time since address pdu */
en = proto_tree_add_time (analysis_tree, hf_analysis_prev_pdu_time,
tvb, 0, 0, &ns);
proto_item_set_generated (en);
}
item_added = TRUE;
} else if (!pkg_data->msg_resend_count) {
proto_tree_add_expert(analysis_tree, pinfo, &ei_address_pdu_missing, tvb, offset, 0);
item_added = TRUE;
}
}
if ((pdu_type == Data_PDU) && (pkg_data->prev_pdu_id != pkg_data->addr_id)) {
/* Add reference to previous Data_PDU */
if (pkg_data->prev_pdu_id) {
en = proto_tree_add_uint (analysis_tree, hf_analysis_prev_pdu_num, tvb,
0, 0, pkg_data->prev_pdu_id);
proto_item_set_generated (en);
nstime_delta (&ns, &pinfo->abs_ts, &pkg_data->prev_pdu_time);
en = proto_tree_add_time (analysis_tree, hf_analysis_prev_pdu_time,
tvb, 0, 0, &ns);
proto_item_set_generated (en);
item_added = TRUE;
} else if (!pkg_data->msg_resend_count) {
proto_tree_add_expert(analysis_tree, pinfo, &ei_analysis_prev_pdu_missing, tvb, offset, 0);
item_added = TRUE;
}
}
if ((pdu_type == Address_PDU) || (pdu_type == Data_PDU) ||
(pdu_type == Discard_Message_PDU)) {
/* Add resend statistics */
if (pkg_data->msg_resend_count) {
en = proto_tree_add_uint (analysis_tree, hf_analysis_retrans_no,
tvb, 0, 0, pkg_data->msg_resend_count);
proto_item_set_generated (en);
en = proto_tree_add_uint (analysis_tree, hf_analysis_msg_resend_from,
tvb, 0, 0, pkg_data->pdu_id);
proto_item_set_generated (en);
expert_add_info_format(pinfo, en, &ei_analysis_retrans_no, "Retransmission #%d", pkg_data->msg_resend_count);
nstime_delta (&ns, &pinfo->abs_ts, &pkg_data->prev_msg_time);
en = proto_tree_add_time (analysis_tree, hf_analysis_retrans_time,
tvb, 0, 0, &ns);
proto_item_set_generated (en);
nstime_delta (&ns, &pinfo->abs_ts, &pkg_data->first_msg_time);
eh = proto_tree_add_time (analysis_tree, hf_analysis_total_retrans_time,
tvb, 0, 0, &ns);
proto_item_set_generated (eh);
if (pkg_data->first_msg_time.secs == pkg_data->prev_msg_time.secs &&
pkg_data->first_msg_time.nsecs == pkg_data->prev_msg_time.nsecs) {
/* Time values does not differ, hide the total time */
proto_item_set_hidden (eh);
}
item_added = TRUE;
col_append_fstr (pinfo->cinfo, COL_INFO, "[Retrans %d#%d] ",
pkg_data->pdu_id, pkg_data->msg_resend_count);
}
}
if (!item_added) {
proto_item_set_hidden (sa);
}
return pkg_data;
}
static void dissect_reassembled_data (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
DISSECTOR_ASSERT(tvb != NULL);
switch (decode_option) {
case DECODE_BER:
dissect_unknown_ber (pinfo, tvb, 0, tree);
break;
case DECODE_CDT:
dissect_cdt (tvb, pinfo, tree);
break;
default:
call_data_dissector(tvb, pinfo, tree);
break;
}
}
static int dissect_p_mul (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
proto_tree *p_mul_tree, *field_tree, *checksum_tree;
proto_item *ti, *en, *len_en;
gboolean save_fragmented;
guint32 message_id = 0;
guint16 no_dest = 0, count = 0, len, data_len = 0;
guint16 checksum_calc, checksum_found;
guint16 pdu_length, no_pdus = 0, seq_no = 0;
guint8 pdu_type, *value, map = 0, fec_len;
gint i, tot_no_missing = 0, no_missing = 0, offset = 0;
address src, dst;
wmem_strbuf_t *message_id_list = NULL;
gboolean fletcher = FALSE;
col_set_str (pinfo->cinfo, COL_PROTOCOL, "P_MUL");
col_clear (pinfo->cinfo, COL_INFO);
/* First fetch PDU Type */
pdu_type = tvb_get_guint8 (tvb, offset + 3) & 0x3F;
ti = proto_tree_add_item (tree, proto_p_mul, tvb, offset, -1, ENC_NA);
proto_item_append_text (ti, ", %s", get_type (pdu_type));
p_mul_tree = proto_item_add_subtree (ti, ett_p_mul);
/* Length of PDU */
pdu_length = tvb_get_ntohs (tvb, offset);
len_en = proto_tree_add_item (p_mul_tree, hf_length, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
switch (pdu_type) {
case Data_PDU:
case Ack_PDU:
case Address_PDU:
case Discard_Message_PDU:
case Extra_Address_PDU:
case FEC_Address_PDU:
case Extra_FEC_Address_PDU:
/* Priority */
proto_tree_add_item (p_mul_tree, hf_priority, tvb, offset, 1, ENC_BIG_ENDIAN);
break;
default:
/* Unused */
proto_tree_add_item (p_mul_tree, hf_unused8, tvb, offset, 1, ENC_BIG_ENDIAN);
}
offset += 1;
/* MAP / PDU_Type */
en = proto_tree_add_uint_format (p_mul_tree, hf_pdu_type, tvb, offset, 1,
pdu_type, "PDU Type: %s (0x%02x)",
get_type (pdu_type), pdu_type);
field_tree = proto_item_add_subtree (en, ett_pdu_type);
if (pdu_type == Discard_Message_PDU) {
expert_add_info(pinfo, en, &ei_message_discarded);
}
switch (pdu_type) {
case Address_PDU:
case Announce_PDU:
case Extra_Address_PDU:
case FEC_Address_PDU:
case Extra_FEC_Address_PDU:
map = tvb_get_guint8 (tvb, offset);
proto_tree_add_item (field_tree, hf_map_first, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item (field_tree, hf_map_last, tvb, offset, 1, ENC_BIG_ENDIAN);
if ((map & 0x80) || (map & 0x40)) {
proto_item_append_text (en, ", %s / %s",
(map & 0x80) ? "Not first" : "First",
(map & 0x40) ? "Not last" : "Last");
} else {
proto_item_append_text (en, ", Only one PDU");
}
break;
default:
proto_tree_add_item (field_tree, hf_map_unused, tvb, offset, 1, ENC_BIG_ENDIAN);
break;
}
proto_tree_add_item (field_tree, hf_pdu_type_value, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
switch (pdu_type) {
case Address_PDU:
case Extra_Address_PDU:
case FEC_Address_PDU:
case Extra_FEC_Address_PDU:
/* Total Number of PDUs */
no_pdus = tvb_get_ntohs (tvb, offset);
seq_no = 0;
proto_tree_add_item (p_mul_tree, hf_no_pdus, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_item_append_text (ti, ", No PDUs: %u", no_pdus);
break;
case Data_PDU:
/* Sequence Number of PDUs */
seq_no = tvb_get_ntohs (tvb, offset);
en = proto_tree_add_item (p_mul_tree, hf_seq_no, tvb, offset, 2, ENC_BIG_ENDIAN);
if (seq_no == 0) {
expert_add_info(pinfo, en, &ei_illegal_seq_no);
}
proto_item_append_text (ti, ", Seq no: %u", seq_no);
break;
case Announce_PDU:
/* Count of Destination Entries */
count = tvb_get_ntohs (tvb, offset);
proto_tree_add_item (p_mul_tree, hf_count_of_dest, tvb, offset, 2, ENC_BIG_ENDIAN);
break;
default:
/* Unused */
proto_tree_add_item (p_mul_tree, hf_unused16, tvb, offset, 2, ENC_BIG_ENDIAN);
break;
}
offset += 2;
/* Checksum */
en = proto_tree_add_item (p_mul_tree, hf_checksum, tvb, offset, 2, ENC_BIG_ENDIAN);
checksum_tree = proto_item_add_subtree (en, ett_checksum);
len = tvb_captured_length (tvb);
value = (guint8 *)tvb_memdup (pinfo->pool, tvb, 0, len);
if (len >= offset+2) {
value[offset] = 0;
value[offset+1] = 0;
}
checksum_found = tvb_get_ntohs (tvb, offset);
/* This computed IP checksum is network-byte-order, so convert to host-byte-order */
checksum_calc = g_ntohs (ip_checksum (value, len));
if (checksum_calc != checksum_found) {
guint16 checksum1 = checksum_acp142 (value, len, offset);
if (checksum1 == checksum_found) {
checksum_calc = checksum1;
fletcher = TRUE;
}
}
if (checksum_calc == checksum_found) {
if (fletcher) {
proto_item_append_text (en, " [Fletcher algorithm]");
}
proto_item_append_text (en, " (correct)");
en = proto_tree_add_boolean (checksum_tree, hf_checksum_good, tvb,
offset, 2, TRUE);
proto_item_set_generated (en);
en = proto_tree_add_boolean (checksum_tree, hf_checksum_bad, tvb,
offset, 2, FALSE);
proto_item_set_generated (en);
} else {
proto_item_append_text (en, " (incorrect, should be 0x%04x)", checksum_calc);
expert_add_info(pinfo, en, &ei_checksum_bad);
en = proto_tree_add_boolean (checksum_tree, hf_checksum_good, tvb,
offset, 2, FALSE);
proto_item_set_generated (en);
en = proto_tree_add_boolean (checksum_tree, hf_checksum_bad, tvb,
offset, 2, TRUE);
proto_item_set_generated (en);
}
offset += 2;
if (pdu_type == Ack_PDU) {
/* Source ID of Ack Sender */
set_address_tvb (&dst, AT_IPv4, 4, tvb, offset);
proto_tree_add_item (p_mul_tree, hf_source_id_ack, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
/* Count of Ack Info Entries */
count = tvb_get_ntohs (tvb, offset);
proto_tree_add_item (p_mul_tree, hf_ack_count, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
} else {
/* Source Id */
set_address_tvb (&src, AT_IPv4, 4, tvb, offset);
proto_tree_add_item (p_mul_tree, hf_source_id, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
/* Message Id */
message_id = tvb_get_ntohl (tvb, offset);
if (use_relative_msgid) {
if (message_id_offset == 0) {
/* First P_Mul package - initialize message_id_offset */
message_id_offset = message_id;
}
message_id -= message_id_offset;
proto_tree_add_uint_format_value(p_mul_tree, hf_message_id, tvb, offset, 4,
message_id, "%u (relative message id)", message_id);
} else {
proto_tree_add_item (p_mul_tree, hf_message_id, tvb, offset, 4, ENC_BIG_ENDIAN);
}
offset += 4;
proto_item_append_text (ti, ", MSID: %u", message_id);
}
if (pdu_type == Address_PDU || pdu_type == Announce_PDU ||
pdu_type == Extra_Address_PDU || pdu_type == FEC_Address_PDU ||
pdu_type == Extra_FEC_Address_PDU) {
/* Expiry Time */
proto_tree_add_item (p_mul_tree, hf_expiry_time, tvb, offset, 4, ENC_TIME_SECS|ENC_BIG_ENDIAN);
offset += 4;
}
if (pdu_type == FEC_Address_PDU || pdu_type == Extra_FEC_Address_PDU) {
/* FEC Parameters Length */
fec_len = tvb_get_guint8 (tvb, offset);
proto_tree_add_item (p_mul_tree, hf_fec_len, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
/* FEC ID */
proto_tree_add_item (p_mul_tree, hf_fec_id, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
if (fec_len > 0) {
/* FEC Parameters */
proto_tree_add_none_format (p_mul_tree, hf_fec_parameters, tvb, offset,
fec_len, "FEC Parameters (%d byte%s)",
fec_len, plurality (fec_len, "", "s"));
offset += fec_len;
}
}
switch (pdu_type) {
case Address_PDU:
case Extra_Address_PDU:
case FEC_Address_PDU:
case Extra_FEC_Address_PDU:
/* Count of Destination Entries */
no_dest = tvb_get_ntohs (tvb, offset);
proto_tree_add_item (p_mul_tree, hf_count_of_dest, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
/* Length of Reserved Field */
len = tvb_get_ntohs (tvb, offset);
proto_tree_add_item (p_mul_tree, hf_length_of_res, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
for (i = 0; i < no_dest; i++) {
/* Destination Entry */
en = proto_tree_add_none_format (p_mul_tree, hf_dest_entry, tvb,
offset, 8 + len,
"Destination Entry #%d", i + 1);
field_tree = proto_item_add_subtree (en, ett_dest_entry);
/* Destination Id */
set_address_tvb (&dst, AT_IPv4, 4, tvb, offset);
proto_tree_add_item (field_tree, hf_dest_id, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
/* Message Sequence Number */
proto_tree_add_item (field_tree, hf_msg_seq_no, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
if (len > 0) {
/* Reserved Field (variable length) */
proto_tree_add_none_format (field_tree, hf_sym_key, tvb, offset,
len, "Symmetric Key (%d byte%s)",
len, plurality (len, "", "s"));
offset += len;
}
if (use_seq_ack_analysis) {
add_ack_analysis (tvb, pinfo, field_tree, offset, pdu_type, &src, &dst,
message_id, 0);
}
}
if (no_dest == 0 && use_seq_ack_analysis) {
/* Add Ack-Ack analysis */
add_ack_analysis (tvb, pinfo, p_mul_tree, offset, pdu_type, &src, NULL,
message_id, 0);
}
proto_item_append_text (ti, ", Count of Dest: %u", no_dest);
break;
case Data_PDU:
/* Fragment of Data (variable length) */
data_len = tvb_captured_length_remaining (tvb, offset);
proto_tree_add_none_format (p_mul_tree, hf_data_fragment, tvb, offset,
data_len, "Fragment %d of Data (%d byte%s)",
seq_no, data_len,
plurality (data_len, "", "s"));
break;
case Ack_PDU:
message_id_list = wmem_strbuf_create(pinfo->pool);
for (i = 0; i < count; i++) {
/* Ack Info Entry */
len = tvb_get_ntohs (tvb, offset);
en = proto_tree_add_none_format (p_mul_tree, hf_ack_entry, tvb,
offset, len,
"Ack Info Entry #%d", i + 1);
field_tree = proto_item_add_subtree (en, ett_ack_entry);
/* Length of Ack Info Entry */
en = proto_tree_add_item (field_tree, hf_ack_length, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
if (len < 10) {
proto_item_append_text (en, " (invalid length)");
expert_add_info(pinfo, en, &ei_ack_length);
}
/* Source Id */
set_address_tvb (&src, AT_IPv4, 4, tvb, offset);
proto_tree_add_item (field_tree, hf_source_id, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
/* Message Id */
message_id = tvb_get_ntohl (tvb, offset);
if (use_relative_msgid) {
if (message_id_offset == 0) {
/* First P_Mul package - initialize message_id_offset */
message_id_offset = message_id;
}
message_id -= message_id_offset;
proto_tree_add_uint_format_value(field_tree, hf_message_id, tvb, offset, 4,
message_id, "%u (relative message id)", message_id);
} else {
proto_tree_add_item (field_tree, hf_message_id, tvb, offset, 4, ENC_BIG_ENDIAN);
}
offset += 4;
if (i == 0) {
wmem_strbuf_append_printf (message_id_list, "%u", message_id);
} else {
wmem_strbuf_append_printf (message_id_list, ",%u", message_id);
}
if (len > 10) {
gint num_seq_no = (len - 10) / 2;
guint16 ack_seq_no, prev_ack_seq_no = 0;
for (no_missing = 0; no_missing < num_seq_no; no_missing++) {
/* Missing Data PDU Seq Number */
ack_seq_no = tvb_get_ntohs (tvb, offset);
if ((ack_seq_no != 0) && (no_missing < num_seq_no - 2) && tvb_get_ntohs (tvb, offset + 2) == 0) {
/* We are handling a range */
guint16 end_seq_no = tvb_get_ntohs (tvb, offset + 4);
en = proto_tree_add_bytes_format_value(field_tree, hf_miss_seq_range,
tvb, offset, 6, NULL,
"%d - %d",
ack_seq_no, end_seq_no);
if (ack_seq_no >= end_seq_no) {
proto_item_append_text (en, " (invalid)");
expert_add_info(pinfo, en, &ei_miss_seq_range);
} else {
proto_tree *missing_tree = proto_item_add_subtree (en, ett_range_entry);
proto_tree_add_item (missing_tree, hf_miss_seq_range_from, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item (missing_tree, hf_miss_seq_range_delimiter, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
proto_tree_add_item (missing_tree, hf_miss_seq_range_to, tvb, offset + 4, 2, ENC_BIG_ENDIAN);
tot_no_missing += (end_seq_no - ack_seq_no + 1);
}
offset += 6;
no_missing += 2; /* Skip the next two */
prev_ack_seq_no = end_seq_no;
} else {
/* No range, handle one seq no */
en = proto_tree_add_item (field_tree, hf_miss_seq_no, tvb,offset, 2, ENC_BIG_ENDIAN);
offset += 2;
if (ack_seq_no == 0) {
proto_item_append_text (en, " (invalid)");
expert_add_info(pinfo, en, &ei_miss_seq_no);
} else if (ack_seq_no <= prev_ack_seq_no) {
proto_item_append_text (en, " (end of list indicator)");
} else {
tot_no_missing++;
}
prev_ack_seq_no = ack_seq_no;
}
}
}
if (use_seq_ack_analysis) {
add_ack_analysis (tvb, pinfo, field_tree, offset, pdu_type, &src, &dst,
message_id, no_missing);
}
}
proto_item_append_text (ti, ", Count of Ack: %u", count);
if (tvb_reported_length_remaining (tvb, offset) >= 8) {
/* Timestamp Option (in units of 100ms) */
guint64 timestamp;
timestamp = tvb_get_ntoh64 (tvb, offset);
proto_tree_add_uint64_format_value(p_mul_tree, hf_timestamp_option, tvb,
offset, 8, timestamp,
"%" PRId64 ".%d second%s (%" PRIu64 ")",
timestamp / 10, (int) timestamp % 10,
(timestamp == 10) ? "" : "s", timestamp);
offset += 8;
}
if (tot_no_missing) {
proto_item_append_text (ti, ", Missing seq numbers: %u", tot_no_missing);
en = proto_tree_add_uint (p_mul_tree, hf_tot_miss_seq_no, tvb, 0, 0,
tot_no_missing);
proto_item_set_generated (en);
expert_add_info_format(pinfo, en, &ei_tot_miss_seq_no, "Missing seq numbers: %d", tot_no_missing);
}
break;
case Discard_Message_PDU:
seq_no = G_MAXUINT16; /* To make the seq_no uniq */
break;
case Announce_PDU:
/* Announced Multicast Group */
proto_tree_add_item (p_mul_tree, hf_ann_mc_group, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
for (i = 0; i < count; i++) {
/* Destination Id */
proto_tree_add_item (p_mul_tree, hf_dest_id, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
}
break;
case Request_PDU:
case Reject_PDU:
case Release_PDU:
/* Multicast Group */
proto_tree_add_item (p_mul_tree, hf_mc_group, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
break;
default:
/* Nothing */
break;
}
/* Add SEQ/ACK analysis entry */
if (use_seq_ack_analysis && (pdu_type <= Discard_Message_PDU) &&
(pdu_type != Ack_PDU) && (pdu_type != Address_PDU || no_dest != 0))
{
add_seq_analysis (tvb, pinfo, p_mul_tree, &src, offset, pdu_type,
message_id, seq_no, tot_no_missing);
}
/* Check if printing Ack-Ack */
if (pdu_type == Address_PDU && no_dest == 0) {
col_append_str (pinfo->cinfo, COL_INFO, get_type (Ack_Ack_PDU));
} else {
col_append_str (pinfo->cinfo, COL_INFO, get_type (pdu_type));
}
if (pdu_type == Address_PDU || pdu_type == Extra_Address_PDU ||
pdu_type == FEC_Address_PDU || pdu_type == Extra_FEC_Address_PDU) {
col_append_fstr (pinfo->cinfo, COL_INFO, ", No PDUs: %u", no_pdus);
} else if (pdu_type == Data_PDU) {
col_append_fstr (pinfo->cinfo, COL_INFO, ", Seq no: %u", seq_no);
}
if (pdu_type == Address_PDU || pdu_type == Extra_Address_PDU ||
pdu_type == FEC_Address_PDU || pdu_type == Extra_FEC_Address_PDU) {
if (no_dest > 0) {
col_append_fstr (pinfo->cinfo, COL_INFO, ", Count of Dest: %u", no_dest);
}
} else if (pdu_type == Ack_PDU) {
if (tot_no_missing) {
col_append_fstr (pinfo->cinfo, COL_INFO, ", Missing seq numbers: %u",
tot_no_missing);
}
col_append_fstr (pinfo->cinfo, COL_INFO, ", Count of Ack: %u", count);
}
if (pdu_type != Ack_PDU) {
col_append_fstr (pinfo->cinfo, COL_INFO, ", MSID: %u", message_id);
} else {
if (message_id_list && wmem_strbuf_get_len(message_id_list) > 0) {
col_append_fstr (pinfo->cinfo, COL_INFO, ", MSID: %s", wmem_strbuf_get_str(message_id_list));
}
}
if (p_mul_reassemble) {
save_fragmented = pinfo->fragmented;
if (pdu_type == Address_PDU && no_pdus > 0) {
/* Start fragment table */
fragment_start_seq_check (&p_mul_reassembly_table,
pinfo, message_id, NULL, no_pdus - 1);
} else if (pdu_type == Data_PDU) {
fragment_head *frag_msg;
tvbuff_t *new_tvb;
pinfo->fragmented = TRUE;
/* Add fragment to fragment table */
frag_msg = fragment_add_seq_check (&p_mul_reassembly_table,
tvb, offset, pinfo, message_id, NULL,
seq_no - 1, data_len, TRUE);
new_tvb = process_reassembled_data (tvb, offset, pinfo,
"Reassembled P_MUL", frag_msg,
&p_mul_frag_items, NULL, tree);
if (frag_msg)
col_append_str (pinfo->cinfo, COL_INFO, " (Message Reassembled)");
if (new_tvb) {
dissect_reassembled_data (new_tvb, pinfo, tree);
}
}
pinfo->fragmented = save_fragmented;
}
/* Update length of P_Mul packet and check length values */
proto_item_set_len (ti, offset);
if (pdu_length != (offset + data_len)) {
proto_item_append_text (len_en, " (incorrect, should be: %d)",
offset + data_len);
expert_add_info(pinfo, len_en, &ei_length);
} else if ((len = tvb_reported_length_remaining (tvb, pdu_length)) > 0) {
proto_item_append_text (len_en, " (more data in packet: %d)", len);
expert_add_info(pinfo, len_en, &ei_more_data);
}
return offset;
}
static void p_mul_init_routine (void)
{
message_id_offset = 0;
}
void proto_register_p_mul (void)
{
static hf_register_info hf[] = {
{ &hf_length,
{ "Length of PDU", "p_mul.length", FT_UINT16, BASE_DEC,
NULL, 0x0, NULL, HFILL } },
{ &hf_priority,
{ "Priority", "p_mul.priority", FT_UINT8, BASE_DEC,
NULL, 0x0, NULL, HFILL } },
{ &hf_map_first,
{ "First", "p_mul.first", FT_BOOLEAN, 8,
TFS (&tfs_no_yes), 0x80, NULL, HFILL } },
{ &hf_map_last,
{ "Last", "p_mul.last", FT_BOOLEAN, 8,
TFS (&tfs_no_yes), 0x40, NULL, HFILL } },
{ &hf_map_unused,
{ "MAP unused", "p_mul.unused", FT_UINT8, BASE_DEC,
NULL, 0xC0, NULL, HFILL } },
{ &hf_pdu_type,
{ "PDU Type", "p_mul.pdu_type", FT_UINT8, BASE_DEC,
VALS (pdu_vals), 0x3F, NULL, HFILL } },
{ &hf_pdu_type_value,
{ "PDU Type", "p_mul.pdu_type_value", FT_UINT8, BASE_DEC,
VALS (pdu_vals), 0x3F, NULL, HFILL } },
{ &hf_no_pdus,
{ "Total Number of PDUs", "p_mul.no_pdus", FT_UINT16, BASE_DEC,
NULL, 0x0, NULL, HFILL } },
{ &hf_seq_no,
{ "Sequence Number of PDUs", "p_mul.seq_no", FT_UINT16, BASE_DEC,
NULL, 0x0, NULL, HFILL } },
{ &hf_unused8,
{ "Unused", "p_mul.unused", FT_UINT8, BASE_DEC,
NULL, 0x0, NULL, HFILL } },
{ &hf_unused16,
{ "Unused", "p_mul.unused", FT_UINT16, BASE_DEC,
NULL, 0x0, NULL, HFILL } },
{ &hf_checksum,
{ "Checksum", "p_mul.checksum", FT_UINT16, BASE_HEX,
NULL, 0x0, NULL, HFILL } },
{ &hf_checksum_good,
{ "Good", "p_mul.checksum_good", FT_BOOLEAN, BASE_NONE,
NULL, 0x0, "True: checksum matches packet content; False: doesn't match content or not checked", HFILL } },
{ &hf_checksum_bad,
{ "Bad", "p_mul.checksum_bad", FT_BOOLEAN, BASE_NONE,
NULL, 0x0, "True: checksum doesn't match packet content; False: matches content or not checked", HFILL } },
{ &hf_source_id_ack,
{ "Source ID of Ack Sender", "p_mul.source_id_ack", FT_IPv4, BASE_NONE,
NULL, 0x0, NULL, HFILL } },
{ &hf_source_id,
{ "Source ID", "p_mul.source_id", FT_IPv4, BASE_NONE,
NULL, 0x0, NULL, HFILL } },
{ &hf_message_id,
{ "Message ID (MSID)", "p_mul.message_id", FT_UINT32, BASE_DEC,
NULL, 0x0, "Message ID", HFILL } },
{ &hf_expiry_time,
{ "Expiry Time", "p_mul.expiry_time", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,
NULL, 0x0, NULL, HFILL } },
{ &hf_mc_group,
{ "Multicast Group", "p_mul.mc_group", FT_UINT32, BASE_DEC,
NULL, 0x0, NULL, HFILL } },
{ &hf_ann_mc_group,
{ "Announced Multicast Group", "p_mul.ann_mc_group", FT_UINT32, BASE_DEC,
NULL, 0x0, NULL, HFILL } },
{ &hf_fec_len,
{ "FEC Parameter Length", "p_mul.fec.length", FT_UINT8, BASE_DEC,
NULL, 0x0, "Forward Error Correction Parameter Length", HFILL } },
{ &hf_fec_id,
{ "FEC ID", "p_mul.fec.id", FT_UINT8, BASE_HEX,
NULL, 0x0, "Forward Error Correction ID", HFILL } },
{ &hf_fec_parameters,
{ "FEC Parameters", "p_mul.fec.parameters", FT_NONE, BASE_NONE,
NULL, 0x0, "Forward Error Correction Parameters", HFILL } },
{ &hf_count_of_dest,
{ "Count of Destination Entries", "p_mul.dest_count", FT_UINT16,BASE_DEC,
NULL, 0x0, NULL, HFILL } },
{ &hf_length_of_res,
{ "Length of Reserved Field", "p_mul.reserved_length",FT_UINT16,BASE_DEC,
NULL, 0x0, NULL, HFILL } },
{ &hf_ack_count,
{ "Count of Ack Info Entries", "p_mul.ack_count", FT_UINT16, BASE_DEC,
NULL, 0x0, NULL, HFILL } },
{ &hf_ack_entry,
{ "Ack Info Entry", "p_mul.ack_info_entry", FT_NONE, BASE_NONE,
NULL, 0x0, NULL, HFILL } },
{ &hf_ack_length,
{ "Length of Ack Info Entry", "p_mul.ack_length", FT_UINT16, BASE_DEC,
NULL, 0x0, NULL, HFILL } },
{ &hf_miss_seq_no,
{ "Missing Data PDU Seq Number", "p_mul.missing_seq_no", FT_UINT16,
BASE_DEC, NULL, 0x0, NULL, HFILL } },
{ &hf_miss_seq_range,
{ "Missing Data PDU Seq Range", "p_mul.missing_seq_range", FT_BYTES,
BASE_NONE, NULL, 0x0, NULL, HFILL } },
{ &hf_miss_seq_range_from,
{ "Missing Data PDU Seq Range from", "p_mul.missing_seq_range.from", FT_UINT16,
BASE_DEC, NULL, 0x0, NULL, HFILL } },
{ &hf_miss_seq_range_delimiter,
{ "Range Delimiter (always zero)", "p_mul.missing_seq_range.delimiter", FT_UINT16,
BASE_DEC, NULL, 0x0, NULL, HFILL } },
{ &hf_miss_seq_range_to,
{ "Missing Data PDU Seq Range to", "p_mul.missing_seq_range.to", FT_UINT16,
BASE_DEC, NULL, 0x0, NULL, HFILL } },
{ &hf_tot_miss_seq_no,
{ "Total Number of Missing Data PDU Sequence Numbers",
"p_mul.no_missing_seq_no", FT_UINT16, BASE_DEC, NULL, 0x0,
NULL, HFILL } },
{ &hf_timestamp_option,
{ "Timestamp", "p_mul.timestamp", FT_UINT64, BASE_DEC,
NULL, 0x0, "Timestamp Option (in units of 100ms)", HFILL } },
{ &hf_dest_entry,
{ "Destination Entry", "p_mul.dest_entry", FT_NONE, BASE_NONE,
NULL, 0x0, NULL, HFILL } },
{ &hf_dest_id,
{ "Destination ID", "p_mul.dest_id", FT_IPv4, BASE_NONE,
NULL, 0x0, NULL, HFILL } },
{ &hf_msg_seq_no,
{ "Message Sequence Number", "p_mul.msg_seq_no", FT_UINT32, BASE_DEC,
NULL, 0x0, NULL, HFILL } },
{ &hf_sym_key,
{ "Symmetric Key", "p_mul.sym_key", FT_NONE, BASE_NONE,
NULL, 0x0, NULL, HFILL } },
{ &hf_data_fragment,
{ "Fragment of Data", "p_mul.data_fragment", FT_NONE, BASE_NONE,
NULL, 0x0, NULL, HFILL } },
/* Fragment entries */
{ &hf_msg_fragments,
{ "Message fragments", "p_mul.fragments", FT_NONE, BASE_NONE,
NULL, 0x00, NULL, HFILL } },
{ &hf_msg_fragment,
{ "Message fragment", "p_mul.fragment", FT_FRAMENUM, BASE_NONE,
NULL, 0x00, NULL, HFILL } },
{ &hf_msg_fragment_overlap,
{ "Message fragment overlap", "p_mul.fragment.overlap", FT_BOOLEAN,
BASE_NONE, NULL, 0x0, NULL, HFILL } },
{ &hf_msg_fragment_overlap_conflicts,
{ "Message fragment overlapping with conflicting data",
"p_mul.fragment.overlap.conflicts", FT_BOOLEAN, BASE_NONE, NULL,
0x0, NULL, HFILL } },
{ &hf_msg_fragment_multiple_tails,
{ "Message has multiple tail fragments",
"p_mul.fragment.multiple_tails", FT_BOOLEAN, BASE_NONE,
NULL, 0x0, NULL, HFILL } },
{ &hf_msg_fragment_too_long_fragment,
{ "Message fragment too long", "p_mul.fragment.too_long_fragment",
FT_BOOLEAN, BASE_NONE, NULL, 0x0, NULL,
HFILL } },
{ &hf_msg_fragment_error,
{ "Message defragmentation error", "p_mul.fragment.error", FT_FRAMENUM,
BASE_NONE, NULL, 0x00, NULL, HFILL } },
{ &hf_msg_fragment_count,
{ "Message fragment count", "p_mul.fragment.count", FT_UINT32, BASE_DEC,
NULL, 0x00, NULL, HFILL } },
{ &hf_msg_reassembled_in,
{ "Reassembled in", "p_mul.reassembled.in", FT_FRAMENUM, BASE_NONE,
NULL, 0x00, NULL, HFILL } },
{ &hf_msg_reassembled_length,
{ "Reassembled P_MUL length", "p_mul.reassembled.length", FT_UINT32, BASE_DEC,
NULL, 0x00, NULL, HFILL } },
/*
** Ack matching / Resend
*/
{ &hf_analysis_ack_time,
{ "Ack Time", "p_mul.analysis.ack_time", FT_RELATIVE_TIME, BASE_NONE,
NULL, 0x0, "The time between the Last PDU and the Ack", HFILL } },
{ &hf_analysis_trans_time,
{ "Transfer Time", "p_mul.analysis.trans_time", FT_RELATIVE_TIME, BASE_NONE,
NULL, 0x0, "The time between the first Address PDU and the Ack", HFILL } },
{ &hf_analysis_retrans_time,
{ "Retransmission Time", "p_mul.analysis.retrans_time", FT_RELATIVE_TIME, BASE_NONE,
NULL, 0x0, "The time between the last PDU and this PDU", HFILL } },
{ &hf_analysis_total_retrans_time,
{ "Total Retransmission Time", "p_mul.analysis.total_retrans_time", FT_RELATIVE_TIME, BASE_NONE,
NULL, 0x0, "The time between the first PDU and this PDU", HFILL } },
{ &hf_analysis_addr_pdu_time,
{ "Time since Address PDU", "p_mul.analysis.elapsed_time", FT_RELATIVE_TIME, BASE_NONE,
NULL, 0x0, "The time between the Address PDU and this PDU", HFILL } },
{ &hf_analysis_prev_pdu_time,
{ "PDU Delay", "p_mul.analysis.pdu_delay", FT_RELATIVE_TIME, BASE_NONE,
NULL, 0x0, "The time between the last PDU and this PDU", HFILL } },
{ &hf_analysis_last_pdu_num,
{ "Last Data PDU in", "p_mul.analysis.last_pdu_in", FT_FRAMENUM, BASE_NONE,
NULL, 0x0, "The last Data PDU found in this frame", HFILL } },
{ &hf_analysis_addr_pdu_num,
{ "Address PDU in", "p_mul.analysis.addr_pdu_in", FT_FRAMENUM, BASE_NONE,
NULL, 0x0, "The Address PDU is found in this frame", HFILL } },
{ &hf_analysis_acks_addr_pdu_num,
{ "This is an Ack to the Address PDU in", "p_mul.analysis.acks_addr_pdu_in", FT_FRAMENUM, BASE_NONE,
FRAMENUM_TYPE(FT_FRAMENUM_ACK), 0x0, "The Address PDU is found in this frame", HFILL } },
{ &hf_analysis_acks_acked_addr_pdu_num,
{ "This is an Ack-Ack to the Address PDU in", "p_mul.analysis.acks_acked_addr_pdu_in", FT_FRAMENUM, BASE_NONE,
FRAMENUM_TYPE(FT_FRAMENUM_DUP_ACK), 0x0, "The Address PDU is found in this frame", HFILL } },
{ &hf_analysis_prev_pdu_num,
{ "Previous PDU in", "p_mul.analysis.prev_pdu_in", FT_FRAMENUM, BASE_NONE,
NULL, 0x0, "The previous PDU is found in this frame", HFILL } },
{ &hf_analysis_ack_num,
{ "Ack PDU in", "p_mul.analysis.ack_in", FT_FRAMENUM, BASE_NONE,
NULL, 0x0, "This packet has an Ack in this frame", HFILL } },
{ &hf_analysis_ack_missing,
{ "Ack PDU missing", "p_mul.analysis.ack_missing", FT_NONE, BASE_NONE,
NULL, 0x0, "The acknowledgement for this packet is missing", HFILL } },
{ &hf_analysis_retrans_no,
{ "Retransmission #", "p_mul.analysis.retrans_no", FT_UINT32, BASE_DEC,
NULL, 0x0, "Retransmission count", HFILL } },
{ &hf_analysis_ack_dup_no,
{ "Duplicate ACK #", "p_mul.analysis.dup_ack_no", FT_UINT32, BASE_DEC,
NULL, 0x0, "Duplicate Ack count", HFILL } },
{ &hf_analysis_msg_resend_from,
{ "Retransmission of Message in", "p_mul.analysis.msg_first_in",
FT_FRAMENUM, BASE_NONE,
NULL, 0x0, "This Message was first sent in this frame", HFILL } },
{ &hf_analysis_ack_resend_from,
{ "Retransmission of Ack in", "p_mul.analysis.ack_first_in",
FT_FRAMENUM, BASE_NONE,
NULL, 0x0, "This Ack was first sent in this frame", HFILL } },
{ &hf_analysis_total_time,
{ "Total Time", "p_mul.analysis.total_time", FT_RELATIVE_TIME, BASE_NONE,
NULL, 0x0, "The time between the first and the last Address PDU", HFILL } },
};
static gint *ett[] = {
&ett_p_mul,
&ett_pdu_type,
&ett_dest_entry,
&ett_ack_entry,
&ett_range_entry,
&ett_checksum,
&ett_seq_analysis,
&ett_ack_analysis,
&ett_seq_ack_analysis,
&ett_msg_fragment,
&ett_msg_fragments
};
static ei_register_info ei[] = {
{ &ei_address_pdu_missing, { "p_mul.analysis.addr_pdu_missing", PI_SEQUENCE, PI_NOTE, "Address PDU missing", EXPFILL }},
{ &ei_analysis_ack_missing, { "p_mul.analysis.ack_missing.expert", PI_SEQUENCE, PI_NOTE, "Ack PDU missing", EXPFILL }},
{ &ei_analysis_ack_dup_no, { "p_mul.analysis.dup_ack_no.expert", PI_SEQUENCE, PI_NOTE, "Dup ACK #", EXPFILL }},
{ &ei_analysis_prev_pdu_missing, { "p_mul.analysis.prev_pdu_missing", PI_SEQUENCE, PI_NOTE, "Previous PDU missing", EXPFILL }},
{ &ei_analysis_retrans_no, { "p_mul.analysis.retrans_no.expert", PI_SEQUENCE, PI_NOTE, "Retransmission #", EXPFILL }},
{ &ei_message_discarded, { "p_mul.message_discarded", PI_RESPONSE_CODE, PI_NOTE, "Message discarded", EXPFILL }},
{ &ei_checksum_bad, { "p_mul.checksum_bad.expert", PI_CHECKSUM, PI_WARN, "Bad checksum", EXPFILL }},
{ &ei_ack_length, { "p_mul.ack_length.invalid", PI_MALFORMED, PI_WARN, "Invalid ack info length", EXPFILL }},
{ &ei_miss_seq_range, { "p_mul.missing_seq_range.invalid", PI_UNDECODED, PI_WARN, "Invalid missing sequence range", EXPFILL }},
{ &ei_miss_seq_no, { "p_mul.missing_seq_no.invalid", PI_UNDECODED, PI_WARN, "Invalid missing seq number", EXPFILL }},
{ &ei_tot_miss_seq_no, { "p_mul.no_missing_seq_no.expert", PI_RESPONSE_CODE, PI_NOTE, "Missing seq numbers", EXPFILL }},
{ &ei_illegal_seq_no, { "p_mul.seq_no.illegal", PI_PROTOCOL, PI_WARN, "Illegal seq number", EXPFILL }},
{ &ei_length, { "p_mul.length.invalid", PI_MALFORMED, PI_WARN, "Incorrect length field", EXPFILL }},
{ &ei_more_data, { "p_mul.more_data", PI_MALFORMED, PI_WARN, "More data in packet", EXPFILL }},
};
module_t *p_mul_module;
expert_module_t* expert_p_mul;
proto_p_mul = proto_register_protocol (PNAME, PSNAME, PFNAME);
p_mul_handle = register_dissector(PFNAME, dissect_p_mul, proto_p_mul);
proto_register_field_array (proto_p_mul, hf, array_length (hf));
proto_register_subtree_array (ett, array_length (ett));
expert_p_mul = expert_register_protocol(proto_p_mul);
expert_register_field_array(expert_p_mul, ei, array_length(ei));
register_init_routine (&p_mul_init_routine);
reassembly_table_register (&p_mul_reassembly_table,
&addresses_reassembly_table_functions);
p_mul_id_hash_table = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), p_mul_id_hash, p_mul_id_hash_equal);
/* Register our configuration options */
p_mul_module = prefs_register_protocol (proto_p_mul, NULL);
prefs_register_obsolete_preference (p_mul_module, "tport");
prefs_register_obsolete_preference (p_mul_module, "rport");
prefs_register_obsolete_preference (p_mul_module, "dport");
prefs_register_obsolete_preference (p_mul_module, "aport");
prefs_register_bool_preference (p_mul_module, "reassemble",
"Reassemble fragmented P_Mul packets",
"Reassemble fragmented P_Mul packets",
&p_mul_reassemble);
prefs_register_bool_preference (p_mul_module, "relative_msgid",
"Use relative Message ID",
"Make the P_Mul dissector use relative"
" message id number instead of absolute"
" ones", &use_relative_msgid);
prefs_register_bool_preference (p_mul_module, "seq_ack_analysis",
"SEQ/ACK Analysis",
"Calculate sequence/acknowledgement analysis",
&use_seq_ack_analysis);
prefs_register_enum_preference (p_mul_module, "decode",
"Decode Data PDU as",
"Type of content in Data_PDU",
&decode_option, decode_options, FALSE);
}
void proto_reg_handoff_p_mul (void)
{
dissector_add_uint ("s5066sis.ctl.appid", S5066_CLIENT_S4406_ANNEX_E_TMI_1_P_MUL, p_mul_handle);
dissector_add_uint_range_with_preference("udp.port", DEFAULT_P_MUL_PORT_RANGE, p_mul_handle);
}
/*
* Editor modelines
*
* Local Variables:
* c-basic-offset: 2
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* ex: set shiftwidth=2 tabstop=8 expandtab:
* :indentSize=2:tabSize=8:noTabs=true:
*/
|