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
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
|
/* packet-bpv6.c
* References:
* RFC 5050: https://tools.ietf.org/html/rfc5050
*
* Copyright 2006-2007 The MITRE Corporation.
* All Rights Reserved.
* Approved for Public Release; Distribution Unlimited.
* Tracking Number 07-0090.
*
* The US Government will not be charged any license fee and/or royalties
* related to this software. Neither name of The MITRE Corporation; nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*
* Specification reference:
* RFC 5050
* https://tools.ietf.org/html/rfc5050
*/
/*
* Modifications were made to this file under designation MFS-33289-1 and
* are Copyright 2015 United States Government as represented by NASA
* Marshall Space Flight Center. All Rights Reserved.
*
* Released under the GNU GPL with NASA legal approval granted 2016-06-10.
*
* The subject software is provided "AS IS" WITHOUT ANY WARRANTY of any kind,
* either expressed, implied or statutory and this agreement does not,
* in any manner, constitute an endorsement by government agency of any
* results, designs or products resulting from use of the subject software.
* See the Agreement for the specific language governing permissions and
* limitations.
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/reassemble.h>
#include <epan/expert.h>
#include <epan/wscbor.h>
#include "packet-bpv6.h"
#include "packet-cfdp.h"
void proto_register_bpv6(void);
void proto_reg_handoff_bpv6(void);
static int dissect_admin_record(proto_tree *primary_tree, tvbuff_t *tvb, packet_info *pinfo,
int offset, int payload_length, gboolean* success);
extern void
dissect_amp_as_subtree(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset);
static int evaluate_sdnv(tvbuff_t *tvb, int offset, int *bytecount);
/// Return an error_info index if not valid
static int evaluate_sdnv_ei(tvbuff_t *tvb, int offset, int *bytecount, expert_field **error);
static int add_sdnv_time_to_tree(proto_tree *tree, tvbuff_t *tvb, int offset, int hf_sdnv_time);
static gint64
evaluate_sdnv_64(tvbuff_t *tvb, int offset, int *bytecount);
static int proto_bundle = -1;
static dissector_handle_t bundle_handle = NULL;
static dissector_handle_t bpv6_handle = NULL;
static dissector_handle_t bpv7_handle = NULL;
static int hf_bundle_pdu_version = -1;
/* Primary Header Processing Flag Variables */
static int hf_bundle_procflags = -1;
static int hf_bundle_procflags_fragment = -1;
static int hf_bundle_procflags_admin = -1;
static int hf_bundle_procflags_dont_fragment = -1;
static int hf_bundle_procflags_cust_xfer_req = -1;
static int hf_bundle_procflags_dest_singleton = -1;
static int hf_bundle_procflags_application_ack = -1;
/* Additions for Version 5 */
static int hf_bundle_control_flags = -1;
static int hf_bundle_procflags_general = -1;
static int hf_bundle_procflags_cos = -1;
static int hf_bundle_procflags_status = -1;
/* Primary Header COS Flag Variables */
static int hf_bundle_cosflags = -1;
static int hf_bundle_cosflags_priority = -1;
/* Primary Header Status Report Request Flag Variables */
static int hf_bundle_srrflags = -1;
static int hf_bundle_srrflags_report_receipt = -1;
static int hf_bundle_srrflags_report_cust_accept = -1;
static int hf_bundle_srrflags_report_forward = -1;
static int hf_bundle_srrflags_report_delivery = -1;
static int hf_bundle_srrflags_report_deletion = -1;
static int hf_bundle_srrflags_report_ack = -1;
/* Primary Header Fields*/
static int hf_bundle_primary_header_len = -1;
static int hf_bundle_primary_dictionary_len = -1;
static int hf_bundle_primary_timestamp = -1;
static int hf_bundle_primary_fragment_offset = -1;
static int hf_bundle_primary_total_adu_len = -1;
static int hf_bundle_primary_timestamp_seq_num64 = -1;
static int hf_bundle_primary_timestamp_seq_num32 = -1;
static int hf_bundle_dest_scheme_offset_u16 = -1;
static int hf_bundle_dest_scheme_offset_i32 = -1;
static int hf_bundle_dest_ssp_offset_u16 = -1;
static int hf_bundle_dest_ssp_offset_i32 = -1;
static int hf_bundle_source_scheme_offset_u16 = -1;
static int hf_bundle_source_scheme_offset_i32 = -1;
static int hf_bundle_source_ssp_offset_u16 = -1;
static int hf_bundle_source_ssp_offset_i32 = -1;
static int hf_bundle_report_scheme_offset_u16 = -1;
static int hf_bundle_report_scheme_offset_i32 = -1;
static int hf_bundle_report_ssp_offset_u16 = -1;
static int hf_bundle_report_ssp_offset_i32 = -1;
static int hf_bundle_cust_scheme_offset_u16 = -1;
static int hf_bundle_cust_scheme_offset_i32 = -1;
static int hf_bundle_cust_ssp_offset_u16 = -1;
static int hf_bundle_cust_ssp_offset_i32 = -1;
/* Dictionary EIDs */
static int hf_bundle_dest_scheme = -1;
static int hf_bundle_dest_ssp = -1;
static int hf_bundle_source_scheme = -1;
static int hf_bundle_source_ssp = -1;
static int hf_bundle_report_scheme = -1;
static int hf_bundle_report_ssp = -1;
static int hf_bundle_custodian_scheme = -1;
static int hf_bundle_custodian_ssp = -1;
/* Remaining Primary Header Fields */
static int hf_bundle_creation_timestamp = -1;
static int hf_bundle_lifetime = -1;
static int hf_bundle_lifetime_sdnv = -1;
/* Secondary Header Processing Flag Variables */
static int hf_bundle_payload_length = -1;
static int hf_bundle_payload_header_type = -1;
static int hf_bundle_payload_data = -1;
static int hf_bundle_payload_flags = -1;
static int hf_bundle_payload_flags_replicate_hdr = -1;
static int hf_bundle_payload_flags_xmit_report = -1;
static int hf_bundle_payload_flags_discard_on_fail = -1;
static int hf_bundle_payload_flags_last_header = -1;
/* Block Processing Control Flag Variables (Version 5) */
static int hf_block_control_flags = -1;
static int hf_block_control_flags_sdnv = -1;
static int hf_block_control_replicate = -1;
static int hf_block_control_transmit_status = -1;
static int hf_block_control_delete_bundle = -1;
static int hf_block_control_last_block = -1;
static int hf_block_control_discard_block = -1;
static int hf_block_control_not_processed = -1;
static int hf_block_control_eid_reference = -1;
static int hf_block_control_block_length = -1;
static int hf_block_control_block_cteb_custody_id = -1;
static int hf_block_control_block_cteb_creator_custodian_eid = -1;
/* Non-Primary Block Type Code Variable */
static int hf_bundle_block_type_code = -1;
static int hf_bundle_unprocessed_block_data = -1;
/* ECOS Flag Variables */
static int hf_ecos_flags = -1;
static int hf_ecos_flags_critical = -1;
static int hf_ecos_flags_streaming = -1;
static int hf_ecos_flags_flowlabel = -1;
static int hf_ecos_flags_reliable = -1;
static int hf_ecos_flow_label = -1;
static int hf_ecos_ordinal = -1;
/* Administrative Record Variables */
static int hf_bundle_admin_record_type = -1;
static int hf_bundle_admin_record_fragment = -1;
static int hf_bundle_admin_statflags = -1;
static int hf_bundle_admin_rcvd = -1;
static int hf_bundle_admin_accepted = -1;
static int hf_bundle_admin_forwarded = -1;
static int hf_bundle_admin_delivered = -1;
static int hf_bundle_admin_deleted = -1;
static int hf_bundle_admin_acked = -1;
static int hf_bundle_admin_fragment_offset = -1;
static int hf_bundle_admin_fragment_length = -1;
static int hf_bundle_admin_timestamp_seq_num64 = -1;
static int hf_bundle_admin_timestamp_seq_num32 = -1;
static int hf_bundle_admin_endpoint_length = -1;
static int hf_bundle_admin_endpoint_id = -1;
static int hf_bundle_admin_receipt_time = -1;
static int hf_bundle_admin_accept_time = -1;
static int hf_bundle_admin_forward_time = -1;
static int hf_bundle_admin_delivery_time = -1;
static int hf_bundle_admin_delete_time = -1;
static int hf_bundle_admin_ack_time = -1;
static int hf_bundle_admin_timestamp_copy = -1;
static int hf_bundle_admin_signal_time = -1;
static int hf_bundle_status_report_reason_code = -1;
static int hf_bundle_custody_trf_succ_flg = -1;
static int hf_bundle_custody_signal_reason = -1;
static int hf_bundle_custody_id_range_start = -1;
static int hf_bundle_custody_id_range_end = -1;
static int hf_bundle_age_extension_block_code = -1;
static int hf_bundle_block_previous_hop_scheme = -1;
static int hf_bundle_block_previous_hop_eid = -1;
/* Security Block Variables */
static int hf_bundle_target_block_type = -1;
static int hf_bundle_target_block_occurrence = -1;
static int hf_bundle_ciphersuite_type = -1;
static int hf_bundle_ciphersuite_flags = -1;
static int hf_block_ciphersuite_params = -1;
static int hf_block_ciphersuite_params_length = -1;
static int hf_block_ciphersuite_params_item_length = -1;
static int hf_block_ciphersuite_param_type = -1;
static int hf_block_ciphersuite_param_data = -1;
static int hf_block_ciphersuite_result_length = -1;
static int hf_block_ciphersuite_result_item_length = -1;
static int hf_block_ciphersuite_result_type = -1;
static int hf_block_ciphersuite_result_data = -1;
static int hf_block_ciphersuite_range_offset = -1;
static int hf_block_ciphersuite_range_length = -1;
/* Tree Node Variables */
static gint ett_bundle = -1;
static gint ett_bundle_hdr = -1;
static gint ett_primary_hdr = -1;
static gint ett_proc_flags = -1;
static gint ett_gen_flags = -1;
static gint ett_cos_flags = -1;
static gint ett_srr_flags = -1;
static gint ett_dictionary = -1;
static gint ett_payload_hdr = -1;
static gint ett_payload_flags = -1;
static gint ett_block_flags = -1;
static gint ett_admin_record = -1;
static gint ett_admin_rec_status = -1;
static gint ett_metadata_hdr = -1;
static gint ett_sec_block_param_data = -1;
static expert_field ei_bundle_payload_length = EI_INIT;
static expert_field ei_bundle_control_flags_length = EI_INIT;
static expert_field ei_bundle_block_control_flags = EI_INIT;
static expert_field ei_bundle_sdnv_length = EI_INIT;
static expert_field ei_bundle_timestamp_seq_num = EI_INIT;
static expert_field ei_bundle_offset_error = EI_INIT;
static expert_field ei_block_control_block_cteb_invalid = EI_INIT;
static expert_field ei_block_control_block_cteb_valid = EI_INIT;
typedef struct dictionary_data {
int bundle_header_dict_length;
int dest_scheme_offset;
int dst_scheme_pos;
int dst_scheme_len;
int source_scheme_offset;
int src_scheme_pos;
int src_scheme_len;
int report_scheme_offset;
int rpt_scheme_pos;
int rpt_scheme_len;
int cust_scheme_offset;
int cust_scheme_pos;
int cust_scheme_len;
int dest_ssp_offset;
int dst_ssp_len;
int source_ssp_offset;
int src_ssp_len;
int report_ssp_offset;
int rpt_ssp_len;
int cust_ssp_offset;
int cust_ssp_len;
} dictionary_data_t;
static const value_string admin_record_type_vals[] = {
{ADMIN_REC_TYPE_STATUS_REPORT, "Bundle Status Report"},
{ADMIN_REC_TYPE_CUSTODY_SIGNAL, "Custody Signal"},
{ADMIN_REC_TYPE_AGGREGATE_CUSTODY_SIGNAL, "Aggregate Custody Signal"},
{ADMIN_REC_TYPE_ANNOUNCE_BUNDLE, "Announce Record (Contact)"},
{0, NULL}
};
static const value_string custody_signal_reason_codes[] = {
{0x0, "No Additional Information"},
{0x3, "Redundant Reception"},
{0x4, "Depleted Storage"},
{0x5, "Destination Endpoint ID Unintelligible"},
{0x6, "No Known Route to Destination"},
{0x7, "No Timely Contact with Next Node on Route"},
{0x8, "Header Unintelligible"},
{0, NULL}
};
static const value_string status_report_reason_codes[] = {
{0x0, "No Additional Information"},
{0x1, "Lifetime Expired"},
{0x2, "Forwarded over Unidirectional Link"},
{0x3, "Transmission Cancelled"},
{0x4, "Depleted Storage"},
{0x5, "Destination Endpoint ID Unintelligible"},
{0x6, "No Known Route to Destination"},
{0x7, "No Timely Contact with Next Node on Route"},
{0x8, "Header Unintelligible"},
{0, NULL}
};
static const value_string bundle_block_type_codes[] = {
{0x01, "Bundle Payload Block"},
{0x02, "Bundle Authentication Block"},
{0x03, "Block Integrity Block"},
{0x04, "Block Confidentiality Block"},
{0x05, "Previous-Hop Insertion Block"},
{0x08, "Metadata Extension Block"},
{0x09, "Extension Security Block"},
{0x0a, "Custody Transfer Enhancement Block"},
{0x13, "Extended Class of Service Block"},
{0x14, "Bundle Age Extension Block"},
{0, NULL}
};
static const value_string cosflags_priority_vals[] = {
{0x00, "Bulk"},
{0x01, "Normal"},
{0x02, "Expedited"},
{0x03, "Invalid (Reserved)"},
{0, NULL}
};
static const value_string ciphersuite_types[] = {
{0x01, "HMAC_SHA1"},
{0x05, "HMAC_SHA256"},
{0x06, "ARC4_AES128"},
{0xD1, "HMAC_SHA384"},
{0xD2, "ECDSA_SHA256"},
{0xD3, "ECDSA_SHA384"},
{0xD4, "SHA256_AES128"},
{0xD5, "SHA384_AES256"},
{0, NULL}
};
static const value_string res_params_types[] = {
{0x01, "Initialization Vector"},
{0x03, "Key Information"},
{0x04, "Content Range"},
{0x05, "Integrity Signature"},
{0x07, "Salt"},
{0x08, "BCB Integrity Check Value"},
{0, NULL}
};
/*
* Adds the result of 2 SDNVs to tree: First SDNV is seconds, next is nanoseconds.
* Returns bytes in both SDNVs or 0 if something goes wrong.
*/
static int
add_dtn_time_to_tree(proto_tree *tree, tvbuff_t *tvb, int offset, int hf_dtn_time)
{
nstime_t dtn_time;
int sdnv_length, sdnv2_length;
int sdnv_value;
int orig_offset;
orig_offset = offset;
sdnv_value = evaluate_sdnv(tvb, offset, &sdnv_length);
if (sdnv_value < 0) {
return 0;
}
dtn_time.secs = (time_t)(sdnv_value + 946684800);
offset += sdnv_length;
dtn_time.nsecs = evaluate_sdnv(tvb, offset, &sdnv2_length);
if (dtn_time.nsecs < 0) {
return 0;
}
proto_tree_add_time(tree, hf_dtn_time, tvb, orig_offset, sdnv_length + sdnv2_length, &dtn_time);
return (sdnv_length + sdnv2_length);
}
/*
* Adds the result of SDNV which is a time since 2000 to tree.
* Returns bytes in SDNV or 0 if something goes wrong.
*/
int
add_sdnv_time_to_tree(proto_tree *tree, tvbuff_t *tvb, int offset, int hf_sdnv_time)
{
nstime_t dtn_time;
int sdnv_length;
int sdnv_value;
sdnv_value = evaluate_sdnv(tvb, offset, &sdnv_length);
if (sdnv_value < 0) {
return 0;
}
dtn_time.secs = (time_t)(sdnv_value + 946684800);
dtn_time.nsecs = 0;
proto_tree_add_time(tree, hf_sdnv_time, tvb, offset, sdnv_length, &dtn_time);
return sdnv_length;
}
static int
add_sdnv_to_tree(proto_tree *tree, tvbuff_t *tvb, packet_info* pinfo, int offset, int hf_sdnv)
{
proto_item *ti;
int sdnv_length;
int sdnv_value;
sdnv_value = evaluate_sdnv(tvb, offset, &sdnv_length);
ti = proto_tree_add_int(tree, hf_sdnv, tvb, offset, sdnv_length, sdnv_value);
if (sdnv_value < 0) {
expert_add_info(pinfo, ti, &ei_bundle_sdnv_length);
return 0;
}
return sdnv_length;
}
/*
* Pull out stuff from the dictionary
*/
static int
dissect_dictionary(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, dictionary_data_t* dict_data,
guint8 pri_hdr_procflags, gchar **bundle_custodian, int creation_timestamp, int timestamp_sequence)
{
proto_tree *dict_tree;
const gchar* col_text;
col_text = col_get_text(pinfo->cinfo, COL_INFO);
dict_tree = proto_tree_add_subtree(tree, tvb, offset, dict_data->bundle_header_dict_length, ett_dictionary, NULL, "Dictionary");
/*
* If the dictionary length is 0, then the CBHE block compression method is applied. (RFC6260)
* So the scheme offset is the node number and the ssp offset is the service number.
* If destination scheme offset is 2 and destination ssp offset is 1, then the EID is
* ipn:2.1
*/
if (dict_data->bundle_header_dict_length == 0)
{
const gchar *src_node, *dst_node;
/*
* Destination info
*/
if (dict_data->dest_scheme_offset == 0 && dict_data->dest_ssp_offset == 0)
{
proto_tree_add_string(dict_tree, hf_bundle_dest_scheme, tvb, 0, 0, DTN_SCHEME_STR);
proto_tree_add_string(dict_tree, hf_bundle_dest_ssp, tvb, dict_data->dst_scheme_pos,
dict_data->dst_scheme_len + dict_data->dst_ssp_len, "none");
dst_node = "dtn:none";
}
else
{
proto_tree_add_string(dict_tree, hf_bundle_dest_scheme, tvb, 0, 0, IPN_SCHEME_STR);
proto_tree_add_string(dict_tree, hf_bundle_dest_ssp, tvb, dict_data->dst_scheme_pos,
dict_data->dst_scheme_len + dict_data->dst_ssp_len,
wmem_strdup_printf(pinfo->pool, "%d.%d",dict_data->dest_scheme_offset,dict_data->dest_ssp_offset));
dst_node = wmem_strdup_printf(pinfo->pool, "%s:%d.%d", IPN_SCHEME_STR,
dict_data->dest_scheme_offset, dict_data->dest_ssp_offset);
}
/*
* Source info
*/
if (dict_data->source_scheme_offset == 0 && dict_data->source_ssp_offset == 0)
{
proto_tree_add_string(dict_tree, hf_bundle_source_scheme, tvb, 0, 0, DTN_SCHEME_STR);
proto_tree_add_string(dict_tree, hf_bundle_source_ssp, tvb, dict_data->src_scheme_pos,
dict_data->src_scheme_len + dict_data->src_ssp_len, "none");
src_node = "dtn:none";
}
else
{
proto_tree_add_string(dict_tree, hf_bundle_source_scheme, tvb, 0, 0, IPN_SCHEME_STR);
proto_tree_add_string(dict_tree, hf_bundle_source_ssp, tvb, dict_data->src_scheme_pos,
dict_data->src_scheme_len + dict_data->src_ssp_len,
wmem_strdup_printf(pinfo->pool, "%d.%d", dict_data->source_scheme_offset, dict_data->source_ssp_offset));
src_node = wmem_strdup_printf(pinfo->pool, "%s:%d.%d", IPN_SCHEME_STR,
dict_data->source_scheme_offset, dict_data->source_ssp_offset);
}
/*
* Report to info
*/
if (dict_data->report_scheme_offset == 0 && dict_data->report_ssp_offset == 0)
{
proto_tree_add_string(dict_tree, hf_bundle_report_scheme, tvb, 0, 0, DTN_SCHEME_STR);
proto_tree_add_string(dict_tree, hf_bundle_report_ssp, tvb, dict_data->rpt_scheme_pos,
dict_data->rpt_scheme_len + dict_data->rpt_ssp_len, "none");
}
else
{
proto_tree_add_string(dict_tree, hf_bundle_report_scheme, tvb, 0, 0, IPN_SCHEME_STR);
proto_tree_add_string(dict_tree, hf_bundle_report_ssp, tvb, dict_data->rpt_scheme_pos,
dict_data->rpt_scheme_len + dict_data->rpt_ssp_len,
wmem_strdup_printf(pinfo->pool, "%d.%d", dict_data->report_scheme_offset, dict_data->report_ssp_offset));
}
/*
* Custodian info
*/
if (dict_data->cust_scheme_offset == 0 && dict_data->cust_ssp_offset == 0)
{
proto_tree_add_string(dict_tree, hf_bundle_custodian_scheme, tvb, 0, 0, DTN_SCHEME_STR);
proto_tree_add_string(dict_tree, hf_bundle_custodian_ssp, tvb, dict_data->cust_scheme_pos,
dict_data->cust_scheme_len + dict_data->cust_ssp_len, "none");
}
else
{
proto_tree_add_string(dict_tree, hf_bundle_custodian_scheme, tvb, 0, 0, IPN_SCHEME_STR);
proto_tree_add_string(dict_tree, hf_bundle_custodian_ssp, tvb, dict_data->cust_scheme_pos,
dict_data->cust_scheme_len + dict_data->cust_ssp_len,
wmem_strdup_printf(pinfo->pool, "%d.%d", dict_data->cust_scheme_offset, dict_data->cust_ssp_offset));
}
/* remember custodian, for use in checking cteb validity */
col_set_writable(pinfo->cinfo, COL_INFO, TRUE);
col_clear_fence(pinfo->cinfo, COL_INFO);
if (col_text && strstr(col_text, " > ")) {
if (! strstr(col_text, "[multiple]")) {
col_append_str(pinfo->cinfo, COL_INFO, ", [multiple]");
}
} else {
col_clear(pinfo->cinfo, COL_INFO);
col_add_fstr(pinfo->cinfo, COL_INFO, "%s > %s %d.%d", src_node, dst_node, creation_timestamp, timestamp_sequence);
}
col_set_fence(pinfo->cinfo, COL_INFO);
*bundle_custodian = wmem_strdup_printf(pinfo->pool, "%s:%d.%d", IPN_SCHEME_STR,
dict_data->cust_scheme_offset, dict_data->cust_ssp_offset);
}
/*
* This pointer can be made to address outside the packet boundaries so we
* need to check for improperly formatted strings (no null termination).
*/
else
{
/*
* Destination info
*/
proto_tree_add_item(dict_tree, hf_bundle_dest_scheme,
tvb, offset + dict_data->dest_scheme_offset, -1, ENC_ASCII);
proto_tree_add_item(dict_tree, hf_bundle_dest_ssp,
tvb, offset + dict_data->dest_ssp_offset, -1, ENC_ASCII);
/*
* Source info
*/
proto_tree_add_item(dict_tree, hf_bundle_source_scheme,
tvb, offset + dict_data->source_scheme_offset, -1, ENC_ASCII);
proto_tree_add_item(dict_tree, hf_bundle_source_ssp,
tvb, offset + dict_data->source_ssp_offset, -1, ENC_ASCII);
/*
* Report to info
*/
proto_tree_add_item(dict_tree, hf_bundle_report_scheme,
tvb, offset + dict_data->report_scheme_offset, -1, ENC_ASCII);
proto_tree_add_item(dict_tree, hf_bundle_report_ssp,
tvb, offset + dict_data->report_ssp_offset, -1, ENC_ASCII);
/*
* Custodian info
*/
proto_tree_add_item(dict_tree, hf_bundle_custodian_scheme, tvb, offset + dict_data->cust_scheme_offset, -1, ENC_ASCII);
proto_tree_add_item(dict_tree, hf_bundle_custodian_ssp, tvb, offset + dict_data->cust_ssp_offset, -1, ENC_ASCII);
/*
* Add Source/Destination to INFO Field
*/
col_set_writable(pinfo->cinfo, COL_INFO, TRUE);
col_clear_fence(pinfo->cinfo, COL_INFO);
if (col_text && strstr(col_text, " > "))
col_append_str(pinfo->cinfo, COL_INFO, ", [multiple]");
else {
col_clear(pinfo->cinfo, COL_INFO);
col_add_fstr(pinfo->cinfo, COL_INFO, "%s:%s > %s:%s %d.%d",
tvb_get_stringz_enc(pinfo->pool, tvb, offset + dict_data->source_scheme_offset, NULL, ENC_ASCII),
tvb_get_stringz_enc(pinfo->pool, tvb, offset + dict_data->source_ssp_offset, NULL, ENC_ASCII),
tvb_get_stringz_enc(pinfo->pool, tvb, offset + dict_data->dest_scheme_offset, NULL, ENC_ASCII),
tvb_get_stringz_enc(pinfo->pool, tvb, offset + dict_data->dest_ssp_offset, NULL, ENC_ASCII),
creation_timestamp, timestamp_sequence);
}
col_set_fence(pinfo->cinfo, COL_INFO);
/* remember custodian, for use in checking cteb validity */
*bundle_custodian = wmem_strdup_printf(pinfo->pool,
"%s:%s",
tvb_get_stringz_enc(pinfo->pool,
tvb, offset + dict_data->cust_scheme_offset,
NULL, ENC_ASCII),
tvb_get_stringz_enc(pinfo->pool,
tvb, offset + dict_data->cust_ssp_offset,
NULL, ENC_ASCII));
}
offset += dict_data->bundle_header_dict_length; /*Skip over dictionary*/
/*
* Do this only if Fragment Flag is set
*/
if (pri_hdr_procflags & BUNDLE_PROCFLAGS_FRAG_MASK) {
int sdnv_length;
sdnv_length = add_sdnv_to_tree(tree, tvb, pinfo, offset, hf_bundle_primary_fragment_offset);
if (sdnv_length < 0) {
return 0;
}
offset += sdnv_length;
sdnv_length = add_sdnv_to_tree(tree, tvb, pinfo, offset, hf_bundle_primary_total_adu_len);
if (sdnv_length < 0) {
return 0;
}
offset += sdnv_length;
}
return offset;
}
/*
* This routine returns 0 if header decoding fails, otherwise the length of the primary
* header, starting right after version number.
*/
static int
dissect_version_4_primary_header(packet_info *pinfo, proto_tree *primary_tree, tvbuff_t *tvb,
guint8* pri_hdr_procflags, gchar **bundle_custodian)
{
int bundle_header_length;
int offset = 1; /* Version Number already displayed */
int sdnv_length;
dictionary_data_t dict_data;
proto_item *ti;
proto_tree *srr_flag_tree, *proc_flag_tree, *cos_flag_tree;
/* Primary Header Processing Flags */
*pri_hdr_procflags = tvb_get_guint8(tvb, offset);
ti = proto_tree_add_item(primary_tree, hf_bundle_procflags, tvb,
offset, 1, ENC_BIG_ENDIAN);
proc_flag_tree = proto_item_add_subtree(ti, ett_proc_flags);
proto_tree_add_item(proc_flag_tree, hf_bundle_procflags_fragment,
tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(proc_flag_tree, hf_bundle_procflags_admin,
tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(proc_flag_tree, hf_bundle_procflags_dont_fragment,
tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(proc_flag_tree, hf_bundle_procflags_cust_xfer_req,
tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(proc_flag_tree, hf_bundle_procflags_dest_singleton,
tvb, offset, 1, ENC_BIG_ENDIAN);
/* Primary Header COS Flags */
++offset;
ti = proto_tree_add_item(primary_tree, hf_bundle_cosflags, tvb,
offset, 1, ENC_BIG_ENDIAN);
cos_flag_tree = proto_item_add_subtree(ti, ett_cos_flags);
proto_tree_add_item(cos_flag_tree, hf_bundle_cosflags_priority,
tvb, offset, 1, ENC_BIG_ENDIAN);
/* Status Report Request Flags */
++offset;
ti = proto_tree_add_item(primary_tree, hf_bundle_srrflags, tvb,
offset, 1, ENC_BIG_ENDIAN);
srr_flag_tree = proto_item_add_subtree(ti, ett_srr_flags);
proto_tree_add_item(srr_flag_tree, hf_bundle_srrflags_report_receipt,
tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(srr_flag_tree, hf_bundle_srrflags_report_cust_accept,
tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(srr_flag_tree, hf_bundle_srrflags_report_forward,
tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(srr_flag_tree, hf_bundle_srrflags_report_delivery,
tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(srr_flag_tree, hf_bundle_srrflags_report_deletion,
tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(srr_flag_tree, hf_bundle_srrflags_report_ack,
tvb, offset, 1, ENC_BIG_ENDIAN);
++offset;
bundle_header_length = evaluate_sdnv(tvb, offset, &sdnv_length);
ti = proto_tree_add_int(primary_tree, hf_bundle_primary_header_len, tvb, offset, sdnv_length,
bundle_header_length);
if (bundle_header_length < 0) {
expert_add_info_format(pinfo, ti, &ei_bundle_sdnv_length, "Bundle Header Length Error");
return tvb_reported_length_remaining(tvb, offset);
}
offset += sdnv_length;
/* Ensure all fields have been initialized */
memset(&dict_data, 0, sizeof(dict_data));
/*
* Pick up offsets into dictionary (8 of them)
*/
dict_data.dest_scheme_offset = tvb_get_ntohs(tvb, offset);
dict_data.dst_scheme_pos = offset;
dict_data.dst_scheme_len = 2;
proto_tree_add_item(primary_tree, hf_bundle_dest_scheme_offset_u16,
tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
dict_data.dest_ssp_offset = tvb_get_ntohs(tvb, offset);
dict_data.dst_ssp_len = 2;
proto_tree_add_item(primary_tree, hf_bundle_dest_ssp_offset_u16,
tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
dict_data.source_scheme_offset = tvb_get_ntohs(tvb, offset);
dict_data.src_scheme_pos = offset;
dict_data.src_scheme_len = 2;
proto_tree_add_item(primary_tree, hf_bundle_source_scheme_offset_u16,
tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
dict_data.source_ssp_offset = tvb_get_ntohs(tvb, offset);
dict_data.src_ssp_len = 2;
proto_tree_add_item(primary_tree, hf_bundle_source_ssp_offset_u16,
tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
dict_data.report_scheme_offset = tvb_get_ntohs(tvb, offset);
dict_data.rpt_scheme_pos = offset;
dict_data.rpt_scheme_len = 2;
proto_tree_add_item(primary_tree, hf_bundle_report_scheme_offset_u16,
tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
dict_data.report_ssp_offset = tvb_get_ntohs(tvb, offset);
dict_data.rpt_ssp_len = 2;
proto_tree_add_item(primary_tree, hf_bundle_report_ssp_offset_u16,
tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
dict_data.cust_scheme_offset = tvb_get_ntohs(tvb, offset);
dict_data.cust_scheme_pos = offset;
dict_data.cust_scheme_len = 2;
proto_tree_add_item(primary_tree, hf_bundle_cust_scheme_offset_u16,
tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
dict_data.cust_ssp_offset = tvb_get_ntohs(tvb, offset);
dict_data.cust_ssp_len = 2;
proto_tree_add_item(primary_tree, hf_bundle_cust_ssp_offset_u16,
tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(primary_tree, hf_bundle_creation_timestamp,
tvb, offset, 8, ENC_BIG_ENDIAN);
offset += 8;
proto_tree_add_item(primary_tree, hf_bundle_lifetime, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
dict_data.bundle_header_dict_length = evaluate_sdnv(tvb, offset, &sdnv_length);
ti = proto_tree_add_int(primary_tree, hf_bundle_primary_dictionary_len, tvb, offset, sdnv_length,
dict_data.bundle_header_dict_length);
if (dict_data.bundle_header_dict_length < 0) {
expert_add_info_format(pinfo, ti, &ei_bundle_sdnv_length, "Dictionary Header Length Error");
return tvb_reported_length_remaining(tvb, offset);
}
offset += sdnv_length;
offset = dissect_dictionary(pinfo, primary_tree, tvb, offset, &dict_data, *pri_hdr_procflags, bundle_custodian, 0, 0);
return offset;
}
/*
* This routine returns 0 if header decoding fails, otherwise the length of the primary
* header, starting right after version number.
*/
static int src_ssp;
static int dst_ssp;
static int
dissect_version_5_and_6_primary_header(packet_info *pinfo,
proto_tree *primary_tree, tvbuff_t *tvb,
guint8* pri_hdr_procflags, gchar **bundle_custodian)
{
guint64 bundle_processing_control_flags;
guint8 cosflags;
int bundle_header_length;
int offset = 1; /* Version Number already displayed */
int sdnv_length;
dictionary_data_t dict_data;
int timestamp_sequence;
int creation_timestamp;
guint8 srrflags;
proto_item *ti;
proto_item *ti_dst_scheme_offset, *ti_dst_ssp_offset;
proto_item *ti_src_scheme_offset, *ti_src_ssp_offset;
proto_item *ti_cust_scheme_offset, *ti_cust_ssp_offset;
proto_item *ti_rprt_scheme_offset, *ti_rprt_ssp_offset;
proto_tree *gen_flag_tree, *srr_flag_tree, *proc_flag_tree, *cos_flag_tree;
static int * const pri_flags[] = {
&hf_bundle_procflags_fragment,
&hf_bundle_procflags_admin,
&hf_bundle_procflags_dont_fragment,
&hf_bundle_procflags_cust_xfer_req,
&hf_bundle_procflags_dest_singleton,
&hf_bundle_procflags_application_ack,
NULL
};
static int * const srr_flags[] = {
&hf_bundle_srrflags_report_receipt,
&hf_bundle_srrflags_report_cust_accept,
&hf_bundle_srrflags_report_forward,
&hf_bundle_srrflags_report_delivery,
&hf_bundle_srrflags_report_deletion,
NULL
};
bundle_processing_control_flags = evaluate_sdnv_64(tvb, offset, &sdnv_length);
/* Primary Header Processing Flags */
*pri_hdr_procflags = (guint8) (bundle_processing_control_flags & 0x7f);
if (sdnv_length < 1 || sdnv_length > 8) {
expert_add_info_format(pinfo, primary_tree, &ei_bundle_control_flags_length,
"Wrong bundle control flag length: %d", sdnv_length);
return 0;
}
ti = proto_tree_add_item(primary_tree, hf_bundle_control_flags, tvb,
offset, sdnv_length, ENC_BIG_ENDIAN);
proc_flag_tree = proto_item_add_subtree(ti, ett_proc_flags);
ti = proto_tree_add_uint(proc_flag_tree, hf_bundle_procflags_general, tvb, offset,
sdnv_length, *pri_hdr_procflags);
gen_flag_tree = proto_item_add_subtree(ti, ett_gen_flags);
/* With the variability of sdnv_length, proto_tree_add_bitmask_value
can't be used */
proto_tree_add_bitmask_list_value(gen_flag_tree, tvb, offset, sdnv_length, pri_flags, *pri_hdr_procflags);
/* Primary Header COS Flags */
cosflags = (guint8) ((bundle_processing_control_flags >> 7) & 0x7f);
ti = proto_tree_add_uint(proc_flag_tree, hf_bundle_procflags_cos, tvb, offset,
sdnv_length, cosflags);
cos_flag_tree = proto_item_add_subtree(ti, ett_cos_flags);
proto_tree_add_uint(cos_flag_tree, hf_bundle_cosflags_priority, tvb, offset,
sdnv_length, cosflags);
/* Status Report Request Flags */
srrflags = (guint8) ((bundle_processing_control_flags >> 14) & 0x7f);
ti = proto_tree_add_uint(proc_flag_tree, hf_bundle_procflags_status, tvb, offset,
sdnv_length, srrflags);
srr_flag_tree = proto_item_add_subtree(ti, ett_srr_flags);
proto_tree_add_bitmask_list_value(srr_flag_tree, tvb, offset, sdnv_length, srr_flags, srrflags);
offset += sdnv_length;
/* -- hdr_length -- */
bundle_header_length = evaluate_sdnv(tvb, offset, &sdnv_length);
ti = proto_tree_add_int(primary_tree, hf_bundle_primary_header_len, tvb, offset, sdnv_length,
bundle_header_length);
if (bundle_header_length < 0) {
expert_add_info_format(pinfo, ti, &ei_bundle_sdnv_length, "Bundle Header Length Error");
return tvb_reported_length_remaining(tvb, offset);
}
offset += sdnv_length;
/*
* Pick up offsets into dictionary (8 of them). Do rough sanity check that SDNV
* hasn't told us to access way past the Primary Header.
*/
/* Ensure all fields have been initialized */
memset(&dict_data, 0, sizeof(dict_data));
/* -- dest_scheme -- */
dict_data.dest_scheme_offset = evaluate_sdnv(tvb, offset, &sdnv_length);
dict_data.dst_scheme_pos = offset;
dict_data.dst_scheme_len = sdnv_length;
ti_dst_scheme_offset = proto_tree_add_int(primary_tree, hf_bundle_dest_scheme_offset_i32, tvb, offset, sdnv_length,
dict_data.dest_scheme_offset);
offset += sdnv_length;
/* -- dest_ssp -- */
dict_data.dest_ssp_offset = evaluate_sdnv(tvb, offset, &sdnv_length);
dict_data.dst_ssp_len = sdnv_length;
dst_ssp = dict_data.dest_ssp_offset;
ti_dst_ssp_offset = proto_tree_add_int(primary_tree, hf_bundle_dest_ssp_offset_i32, tvb, offset, sdnv_length,
dict_data.dest_ssp_offset);
offset += sdnv_length;
/* -- source_scheme -- */
dict_data.source_scheme_offset = evaluate_sdnv(tvb, offset, &sdnv_length);
dict_data.src_scheme_pos = offset;
dict_data.src_scheme_len = sdnv_length;
ti_src_scheme_offset = proto_tree_add_int(primary_tree, hf_bundle_source_scheme_offset_i32, tvb, offset, sdnv_length,
dict_data.source_scheme_offset);
offset += sdnv_length;
/* -- source_ssp -- */
dict_data.source_ssp_offset = evaluate_sdnv(tvb, offset, &sdnv_length);
dict_data.src_ssp_len = sdnv_length;
src_ssp = dict_data.source_ssp_offset;
ti_src_ssp_offset = proto_tree_add_int(primary_tree, hf_bundle_source_ssp_offset_i32, tvb, offset, sdnv_length,
dict_data.source_ssp_offset);
offset += sdnv_length;
/* -- report_scheme -- */
dict_data.report_scheme_offset = evaluate_sdnv(tvb, offset, &sdnv_length);
dict_data.rpt_scheme_pos = offset;
dict_data.rpt_scheme_len = sdnv_length;
ti_rprt_scheme_offset = proto_tree_add_int(primary_tree, hf_bundle_report_scheme_offset_i32, tvb, offset,
sdnv_length, dict_data.report_scheme_offset);
offset += sdnv_length;
/* -- report_ssp -- */
dict_data.report_ssp_offset = evaluate_sdnv(tvb, offset, &sdnv_length);
dict_data.rpt_ssp_len = sdnv_length;
ti_rprt_ssp_offset = proto_tree_add_int(primary_tree, hf_bundle_report_ssp_offset_i32, tvb, offset, sdnv_length,
dict_data.report_ssp_offset);
offset += sdnv_length;
/* -- cust_scheme -- */
dict_data.cust_scheme_offset = evaluate_sdnv(tvb, offset, &sdnv_length);
dict_data.cust_scheme_pos = offset;
dict_data.cust_scheme_len = sdnv_length;
ti_cust_scheme_offset = proto_tree_add_int(primary_tree, hf_bundle_cust_scheme_offset_i32, tvb, offset, sdnv_length,
dict_data.cust_scheme_offset);
offset += sdnv_length;
/* -- cust_ssp -- */
dict_data.cust_ssp_offset = evaluate_sdnv(tvb, offset, &sdnv_length);
dict_data.cust_ssp_len = sdnv_length;
ti_cust_ssp_offset = proto_tree_add_int(primary_tree, hf_bundle_cust_ssp_offset_i32, tvb, offset, sdnv_length,
dict_data.cust_ssp_offset);
offset += sdnv_length;
creation_timestamp = evaluate_sdnv(tvb, offset, &sdnv_length);
sdnv_length = add_sdnv_time_to_tree(primary_tree, tvb, offset, hf_bundle_primary_timestamp);
if (sdnv_length == 0)
return 0;
offset += sdnv_length;
/* -- timestamp_sequence -- */
timestamp_sequence = evaluate_sdnv(tvb, offset, &sdnv_length);
if (timestamp_sequence < 0) {
gint64 ts_seq = evaluate_sdnv_64(tvb, offset, &sdnv_length);
ti = proto_tree_add_int64(primary_tree, hf_bundle_primary_timestamp_seq_num64,
tvb, offset, sdnv_length, ts_seq);
if (ts_seq < 0) {
expert_add_info(pinfo, ti, &ei_bundle_timestamp_seq_num);
}
}
else {
proto_tree_add_int(primary_tree, hf_bundle_primary_timestamp_seq_num32,
tvb, offset, sdnv_length, timestamp_sequence);
}
offset += sdnv_length;
/* -- lifetime -- */
sdnv_length = add_sdnv_to_tree(primary_tree, tvb, pinfo, offset, hf_bundle_lifetime_sdnv);
offset += sdnv_length;
/* -- dict_length -- */
dict_data.bundle_header_dict_length = evaluate_sdnv(tvb, offset, &sdnv_length);
ti = proto_tree_add_int(primary_tree, hf_bundle_primary_dictionary_len, tvb, offset, sdnv_length,
dict_data.bundle_header_dict_length);
if (dict_data.bundle_header_dict_length < 0) {
expert_add_info_format(pinfo, ti, &ei_bundle_sdnv_length, "Dictionary Header Length Error");
return tvb_reported_length_remaining(tvb, offset);
}
offset += sdnv_length;
if ((dict_data.dest_scheme_offset < 0) ||
(dict_data.bundle_header_dict_length > 0 && (dict_data.dest_scheme_offset > bundle_header_length))) {
expert_add_info_format(pinfo, ti_dst_scheme_offset, &ei_bundle_offset_error, "Destination Scheme Offset Error");
}
if ((dict_data.dest_ssp_offset < 0) ||
(dict_data.bundle_header_dict_length > 0 && (dict_data.dest_ssp_offset > bundle_header_length))) {
expert_add_info_format(pinfo, ti_dst_ssp_offset, &ei_bundle_offset_error, "Destination SSP Offset Error");
}
if ((dict_data.source_scheme_offset < 0) ||
(dict_data.bundle_header_dict_length > 0 && (dict_data.source_scheme_offset > bundle_header_length))) {
expert_add_info_format(pinfo, ti_src_scheme_offset, &ei_bundle_offset_error, "Source Scheme Offset Error");
}
if ((dict_data.source_ssp_offset < 0) ||
(dict_data.bundle_header_dict_length > 0 && (dict_data.source_ssp_offset > bundle_header_length))) {
expert_add_info_format(pinfo, ti_src_ssp_offset, &ei_bundle_offset_error, "Source SSP Offset Error");
}
if ((dict_data.report_scheme_offset < 0) ||
(dict_data.bundle_header_dict_length > 0 && (dict_data.report_scheme_offset > bundle_header_length))) {
expert_add_info_format(pinfo, ti_rprt_scheme_offset, &ei_bundle_offset_error, "Report Scheme Offset Error");
}
if ((dict_data.report_ssp_offset < 0) ||
(dict_data.bundle_header_dict_length > 0 && (dict_data.report_ssp_offset > bundle_header_length))) {
expert_add_info_format(pinfo, ti_rprt_ssp_offset, &ei_bundle_offset_error, "Report SSP Offset Error");
}
if ((dict_data.cust_scheme_offset < 0) ||
(dict_data.bundle_header_dict_length > 0 && (dict_data.cust_scheme_offset > bundle_header_length))) {
expert_add_info_format(pinfo, ti_cust_scheme_offset, &ei_bundle_offset_error, "Custodian Scheme Offset Error");
}
if ((dict_data.cust_ssp_offset < 0) ||
(dict_data.bundle_header_dict_length > 0 && (dict_data.cust_ssp_offset > bundle_header_length))) {
expert_add_info_format(pinfo, ti_cust_ssp_offset, &ei_bundle_offset_error, "Custodian SSP Offset Error");
}
offset = dissect_dictionary(pinfo, primary_tree, tvb, offset, &dict_data, *pri_hdr_procflags, bundle_custodian,
creation_timestamp, timestamp_sequence);
return offset;
}
/*
* offset is where the header starts.
* Return new offset, and set lastheader if failure.
*/
static int
dissect_payload_header(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int offset, guint8 version,
guint8 pri_hdr_procflags, gboolean *lastheader)
{
proto_item *payload_block, *payload_item, *ti;
proto_tree *payload_block_tree, *payload_tree;
int sdnv_length, payload_length;
payload_block_tree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_payload_hdr, &payload_block, "Payload Block");
payload_tree = proto_tree_add_subtree(payload_block_tree, tvb, offset, -1, ett_payload_hdr, &payload_item, "Payload Header");
proto_tree_add_uint(payload_tree, hf_bundle_payload_header_type, tvb, offset, 1, 1);
++offset;
/* Add tree for processing flags */
/* This is really a SDNV but there are only 7 bits defined so leave it this way*/
if (version == 4) {
static int * const flags[] = {
&hf_bundle_payload_flags_replicate_hdr,
&hf_bundle_payload_flags_xmit_report,
&hf_bundle_payload_flags_discard_on_fail,
&hf_bundle_payload_flags_last_header,
NULL
};
guint8 procflags;
procflags = tvb_get_guint8(tvb, offset);
if (procflags & HEADER_PROCFLAGS_LAST_HEADER) {
*lastheader = TRUE;
}
else {
*lastheader = FALSE;
}
proto_tree_add_bitmask(payload_tree, tvb, offset, hf_bundle_payload_flags,
ett_payload_flags, flags, ENC_BIG_ENDIAN);
++offset;
}
else { /*Bundle Protocol Version 5*/
int control_flags;
proto_item *block_flag_item;
proto_tree *block_flag_tree;
control_flags = evaluate_sdnv(tvb, offset, &sdnv_length);
if (control_flags & BLOCK_CONTROL_LAST_BLOCK) {
*lastheader = TRUE;
}
else {
*lastheader = FALSE;
}
block_flag_item = proto_tree_add_item(payload_tree, hf_block_control_flags, tvb,
offset, sdnv_length, ENC_BIG_ENDIAN);
block_flag_tree = proto_item_add_subtree(block_flag_item, ett_block_flags);
proto_tree_add_item(block_flag_tree, hf_block_control_replicate,
tvb, offset, sdnv_length, ENC_BIG_ENDIAN);
proto_tree_add_item(block_flag_tree, hf_block_control_transmit_status,
tvb, offset, sdnv_length, ENC_BIG_ENDIAN);
proto_tree_add_item(block_flag_tree, hf_block_control_delete_bundle,
tvb, offset, sdnv_length, ENC_BIG_ENDIAN);
proto_tree_add_item(block_flag_tree, hf_block_control_last_block,
tvb, offset, sdnv_length, ENC_BIG_ENDIAN);
proto_tree_add_item(block_flag_tree, hf_block_control_discard_block,
tvb, offset, sdnv_length, ENC_BIG_ENDIAN);
proto_tree_add_item(block_flag_tree, hf_block_control_not_processed,
tvb, offset, sdnv_length, ENC_BIG_ENDIAN);
proto_tree_add_item(block_flag_tree, hf_block_control_eid_reference,
tvb, offset, sdnv_length, ENC_BIG_ENDIAN);
offset += sdnv_length;
}
payload_length = evaluate_sdnv(tvb, offset, &sdnv_length);
ti = proto_tree_add_int(payload_tree, hf_bundle_payload_length, tvb, offset, sdnv_length, payload_length);
if (payload_length < 0) {
expert_add_info(pinfo, ti, &ei_bundle_payload_length);
/* Force quiting */
*lastheader = TRUE;
return offset;
}
proto_item_set_len(payload_item, 2 + sdnv_length);
proto_item_set_len(payload_block, 2 + sdnv_length + payload_length);
offset += sdnv_length;
if (pri_hdr_procflags & BUNDLE_PROCFLAGS_ADMIN_MASK) {
gboolean success = FALSE;
/*
* XXXX - Have not allowed for admin record spanning multiple segments!
*/
offset = dissect_admin_record(payload_block_tree, tvb, pinfo, offset, payload_length, &success);
if (!success) {
/* Force quiting */
*lastheader = TRUE;
return offset;
}
} else {
/* If Source SSP Offset is 64 and Destination SSP offset is 65, then
interpret the payload-data part as CFDP. */
if (src_ssp == 0x40 &&
dst_ssp == 0x41)
{
dissect_cfdp_as_subtree (tvb, pinfo, payload_block_tree, offset);
}
/* If Source SSP Offset is 5 and Destination SSP offset is 6, then
interpret the payload-data part as AMP. */
else if ((src_ssp == 0x5 && dst_ssp == 0x6) ||
(dst_ssp == 0x5 && src_ssp == 0x6))
{
dissect_amp_as_subtree (tvb, pinfo, payload_block_tree, offset);
}
else
{
proto_tree_add_string(payload_block_tree, hf_bundle_payload_data, tvb, offset, payload_length,
wmem_strdup_printf(pinfo->pool, "<%d bytes>",payload_length));
}
offset += payload_length;
}
return offset;
}
/*
* Return the offset after the Administrative Record or set success = FALSE if analysis fails.
*/
static int
dissect_admin_record(proto_tree *primary_tree, tvbuff_t *tvb, packet_info *pinfo,
int offset, int payload_length, gboolean* success)
{
proto_item *admin_record_item;
proto_tree *admin_record_tree;
proto_item *timestamp_sequence_item;
guint8 record_type;
guint8 status;
int start_offset = offset;
int sdnv_length;
int timestamp_sequence;
int endpoint_length;
*success = FALSE;
admin_record_tree = proto_tree_add_subtree(primary_tree, tvb, offset, -1,
ett_admin_record, &admin_record_item, "Administrative Record");
record_type = tvb_get_guint8(tvb, offset);
proto_tree_add_item(admin_record_tree, hf_bundle_admin_record_type, tvb, offset, 1, ENC_BIG_ENDIAN);
switch ((record_type >> 4) & 0xf)
{
case ADMIN_REC_TYPE_STATUS_REPORT:
{
proto_item *status_flag_item;
proto_tree *status_flag_tree;
proto_tree_add_item(admin_record_tree, hf_bundle_admin_record_fragment, tvb, offset, 1, ENC_NA);
++offset;
/* Decode Bundle Status Report Flags */
status = tvb_get_guint8(tvb, offset);
status_flag_item = proto_tree_add_item(admin_record_tree,
hf_bundle_admin_statflags, tvb, offset, 1, ENC_BIG_ENDIAN);
status_flag_tree = proto_item_add_subtree(status_flag_item,
ett_admin_rec_status);
proto_tree_add_item(status_flag_tree, hf_bundle_admin_rcvd,
tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(status_flag_tree, hf_bundle_admin_accepted,
tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(status_flag_tree, hf_bundle_admin_forwarded,
tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(status_flag_tree, hf_bundle_admin_delivered,
tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(status_flag_tree, hf_bundle_admin_deleted,
tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(status_flag_tree, hf_bundle_admin_acked,
tvb, offset, 1, ENC_BIG_ENDIAN);
++offset;
proto_tree_add_item(admin_record_tree, hf_bundle_status_report_reason_code, tvb, offset, 1, ENC_BIG_ENDIAN);
++offset;
if (record_type & ADMIN_REC_FLAGS_FRAGMENT) {
sdnv_length = add_sdnv_to_tree(admin_record_tree, tvb, pinfo, offset, hf_bundle_admin_fragment_offset);
if (sdnv_length <= 0) {
return offset;
}
offset += sdnv_length;
sdnv_length = add_sdnv_to_tree(admin_record_tree, tvb, pinfo, offset, hf_bundle_admin_fragment_length);
if (sdnv_length <= 0) {
return offset;
}
offset += sdnv_length;
}
if (status & ADMIN_STATUS_FLAGS_RECEIVED) {
sdnv_length = add_dtn_time_to_tree(admin_record_tree, tvb, offset, hf_bundle_admin_receipt_time);
if (sdnv_length <= 0) {
return offset;
}
offset += sdnv_length;
}
if (status & ADMIN_STATUS_FLAGS_ACCEPTED) {
sdnv_length = add_dtn_time_to_tree(admin_record_tree, tvb, offset, hf_bundle_admin_accept_time);
if (sdnv_length <= 0) {
return offset;
}
offset += sdnv_length;
}
if (status & ADMIN_STATUS_FLAGS_FORWARDED) {
sdnv_length = add_dtn_time_to_tree(admin_record_tree, tvb, offset, hf_bundle_admin_forward_time);
if (sdnv_length <= 0) {
return offset;
}
offset += sdnv_length;
}
if (status & ADMIN_STATUS_FLAGS_DELIVERED) {
sdnv_length = add_dtn_time_to_tree(admin_record_tree, tvb, offset, hf_bundle_admin_delivery_time);
if (sdnv_length <= 0) {
return offset;
}
offset += sdnv_length;
}
if (status & ADMIN_STATUS_FLAGS_DELETED) {
sdnv_length = add_dtn_time_to_tree(admin_record_tree, tvb, offset, hf_bundle_admin_delete_time);
if (sdnv_length <= 0) {
return offset;
}
offset += sdnv_length;
}
if (status & ADMIN_STATUS_FLAGS_ACKNOWLEDGED) {
sdnv_length = add_dtn_time_to_tree(admin_record_tree, tvb, offset, hf_bundle_admin_ack_time);
if (sdnv_length <= 0) {
return offset;
}
offset += sdnv_length;
}
/* Get 2 SDNVs for Creation Timestamp */
sdnv_length = add_sdnv_time_to_tree(admin_record_tree, tvb, offset, hf_bundle_admin_timestamp_copy);
if (sdnv_length <= 0) {
return offset;
}
offset += sdnv_length;
timestamp_sequence = evaluate_sdnv(tvb, offset, &sdnv_length);
if (timestamp_sequence < 0) {
gint64 ts_seq = evaluate_sdnv_64(tvb, offset, &sdnv_length);
timestamp_sequence_item = proto_tree_add_int64(admin_record_tree, hf_bundle_admin_timestamp_seq_num64,
tvb, offset, sdnv_length, ts_seq);
if (ts_seq < 0) {
expert_add_info(pinfo, timestamp_sequence_item, &ei_bundle_timestamp_seq_num);
return offset;
}
}
else {
proto_tree_add_int(admin_record_tree, hf_bundle_admin_timestamp_seq_num32,
tvb, offset, sdnv_length, timestamp_sequence);
}
offset += sdnv_length;
endpoint_length = evaluate_sdnv(tvb, offset, &sdnv_length);
if (endpoint_length < 0) {
return tvb_reported_length_remaining(tvb, offset);
}
proto_tree_add_int(admin_record_tree, hf_bundle_admin_endpoint_length, tvb, offset, sdnv_length, endpoint_length);
offset += sdnv_length;
/*
* Endpoint name may not be null terminated. This routine is supposed
* to add the null at the end of the string buffer.
*/
proto_tree_add_item(admin_record_tree, hf_bundle_admin_endpoint_id, tvb, offset, endpoint_length, ENC_NA|ENC_ASCII);
offset += endpoint_length;
break;
} /* case ADMIN_REC_TYPE_STATUS_REPORT */
case ADMIN_REC_TYPE_CUSTODY_SIGNAL:
{
proto_tree_add_item(admin_record_tree, hf_bundle_admin_record_fragment, tvb, offset, 1, ENC_NA);
++offset;
proto_tree_add_item(admin_record_tree, hf_bundle_custody_trf_succ_flg, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(admin_record_tree, hf_bundle_custody_signal_reason, tvb, offset, 1, ENC_BIG_ENDIAN);
++offset;
if (record_type & ADMIN_REC_FLAGS_FRAGMENT) {
sdnv_length = add_sdnv_to_tree(admin_record_tree, tvb, pinfo, offset, hf_bundle_admin_fragment_offset);
if (sdnv_length <= 0) {
return offset;
}
offset += sdnv_length;
sdnv_length = add_sdnv_to_tree(admin_record_tree, tvb, pinfo, offset, hf_bundle_admin_fragment_length);
if (sdnv_length <= 0) {
return offset;
}
offset += sdnv_length;
}
/* Signal Time */
sdnv_length = add_dtn_time_to_tree(admin_record_tree, tvb, offset, hf_bundle_admin_signal_time);
if (sdnv_length <= 0) {
return offset;
}
offset += sdnv_length;
/* Timestamp copy */
sdnv_length = add_sdnv_time_to_tree(admin_record_tree, tvb, offset, hf_bundle_admin_timestamp_copy);
if (sdnv_length <= 0) {
return offset;
}
offset += sdnv_length;
timestamp_sequence = evaluate_sdnv(tvb, offset, &sdnv_length);
if (timestamp_sequence < 0) {
gint64 ts_seq = evaluate_sdnv_64(tvb, offset, &sdnv_length);
timestamp_sequence_item = proto_tree_add_int64(admin_record_tree, hf_bundle_admin_timestamp_seq_num64,
tvb, offset, sdnv_length, ts_seq);
if (ts_seq < 0) {
expert_add_info(pinfo, timestamp_sequence_item, &ei_bundle_timestamp_seq_num);
return offset;
}
}
else {
proto_tree_add_int(admin_record_tree, hf_bundle_admin_timestamp_seq_num32,
tvb, offset, sdnv_length, timestamp_sequence);
}
offset += sdnv_length;
endpoint_length = evaluate_sdnv(tvb, offset, &sdnv_length);
if (endpoint_length < 0) {
return tvb_reported_length_remaining(tvb, offset);
}
proto_tree_add_int(admin_record_tree, hf_bundle_admin_endpoint_length, tvb, offset, sdnv_length, endpoint_length);
offset += sdnv_length;
proto_tree_add_item(admin_record_tree, hf_bundle_admin_endpoint_id, tvb, offset, endpoint_length, ENC_NA|ENC_ASCII);
offset += endpoint_length;
break;
} /* case ADMIN_REC_TYPE_CUSTODY_SIGNAL */
case ADMIN_REC_TYPE_AGGREGATE_CUSTODY_SIGNAL:
{
proto_item *ti;
int payload_bytes_processed = 0;
int right_edge = -1;
int fill_start;
int fill_length = -1;
int sdnv_length_start = -1;
int sdnv_length_gap = -1;
int sdnv_length_length = -1;
proto_tree_add_item(admin_record_tree, hf_bundle_admin_record_fragment, tvb, offset, 1, ENC_NA);
++offset;
++payload_bytes_processed;
proto_tree_add_item(admin_record_tree, hf_bundle_custody_trf_succ_flg, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(admin_record_tree, hf_bundle_custody_signal_reason, tvb, offset, 1, ENC_BIG_ENDIAN);
++offset;
++payload_bytes_processed;
/* process the first fill */
fill_start = evaluate_sdnv(tvb, offset, &sdnv_length_start);
ti = proto_tree_add_int(admin_record_tree, hf_bundle_custody_id_range_start, tvb, offset, sdnv_length_start, fill_start);
if (fill_start < 0 || sdnv_length_start < 0) {
expert_add_info_format(pinfo, ti, &ei_bundle_sdnv_length, "ACS: Unable to process CTEB Custody ID Range start SDNV");
return offset;
}
fill_length = evaluate_sdnv(tvb, offset + sdnv_length_start, &sdnv_length_length);
ti = proto_tree_add_int(admin_record_tree, hf_bundle_custody_id_range_end, tvb, offset,
sdnv_length_start + sdnv_length_length, fill_start + fill_length - 1);
if (fill_length < 0 || sdnv_length_length < 0) {
expert_add_info_format(pinfo, ti, &ei_bundle_sdnv_length, "ACS: Unable to process CTEB Custody ID Range length SDNV");
return tvb_reported_length_remaining(tvb, offset);
}
right_edge = fill_start + fill_length;
offset += sdnv_length_start + sdnv_length_length;
payload_bytes_processed += sdnv_length_start + sdnv_length_length;
/* now attempt to consume all the rest of the data in the
* payload as additional fills */
while (payload_bytes_processed < payload_length) {
int fill_gap;
fill_gap = evaluate_sdnv(tvb, offset, &sdnv_length_gap);
ti = proto_tree_add_int(admin_record_tree, hf_bundle_custody_id_range_start, tvb, offset, sdnv_length_gap, fill_gap);
if (fill_gap < 0 || sdnv_length_gap < 0) {
expert_add_info_format(pinfo, ti, &ei_bundle_sdnv_length, "ACS: Unable to process CTEB Custody ID Range gap SDNV");
return offset;
}
fill_length = evaluate_sdnv(tvb, offset + sdnv_length_gap, &sdnv_length_length);
ti = proto_tree_add_int(admin_record_tree, hf_bundle_custody_id_range_end, tvb, offset,
sdnv_length_gap + sdnv_length_length, right_edge + fill_gap + fill_length - 1);
if (fill_length < 0 || sdnv_length_length < 0) {
expert_add_info_format(pinfo, ti, &ei_bundle_sdnv_length, "ACS: Unable to process CTEB Custody ID Range length SDNV");
return tvb_reported_length_remaining(tvb, offset);
}
right_edge += fill_gap + fill_length;
offset += sdnv_length_gap + sdnv_length_length;
payload_bytes_processed += sdnv_length_gap + sdnv_length_length;
}
if (payload_bytes_processed > payload_length) {
expert_add_info_format(pinfo, ti, &ei_bundle_offset_error, "ACS: CTEB Custody ID Range data extends past payload length");
return offset;
}
break;
} /* case ADMIN_REC_TYPE_AGGREGATE_CUSTODY_SIGNAL */
case ADMIN_REC_TYPE_ANNOUNCE_BUNDLE:
default:
offset++;
break;
} /* End Switch */
proto_item_set_len(admin_record_item, offset - start_offset);
*success = TRUE;
return offset;
}
static int
display_extension_block(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int offset, gchar *bundle_custodian, gboolean *lastheader)
{
proto_item *block_item, *ti, *block_flag_replicate_item, *block_flag_eid_reference_item;
proto_tree *block_tree;
int sdnv_length;
int block_length;
int block_overhead;
int bundle_age;
guint8 type;
unsigned int control_flags;
proto_tree *block_flag_tree;
proto_item *block_flag_item;
type = tvb_get_guint8(tvb, offset);
block_tree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_metadata_hdr, &block_item, "Extension Block");
proto_tree_add_item(block_tree, hf_bundle_block_type_code, tvb, offset, 1, ENC_BIG_ENDIAN);
++offset;
block_overhead = 1;
control_flags = (unsigned int)evaluate_sdnv(tvb, offset, &sdnv_length);
if (control_flags & BLOCK_CONTROL_LAST_BLOCK) {
*lastheader = TRUE;
} else {
*lastheader = FALSE;
}
block_flag_item = proto_tree_add_uint(block_tree, hf_block_control_flags_sdnv, tvb,
offset, sdnv_length, control_flags);
block_flag_tree = proto_item_add_subtree(block_flag_item, ett_block_flags);
block_flag_replicate_item = proto_tree_add_boolean(block_flag_tree, hf_block_control_replicate,
tvb, offset, sdnv_length, control_flags);
proto_tree_add_boolean(block_flag_tree, hf_block_control_transmit_status,
tvb, offset, sdnv_length, control_flags);
proto_tree_add_boolean(block_flag_tree, hf_block_control_delete_bundle,
tvb, offset, sdnv_length, control_flags);
proto_tree_add_boolean(block_flag_tree, hf_block_control_last_block,
tvb, offset, sdnv_length, control_flags);
proto_tree_add_boolean(block_flag_tree, hf_block_control_discard_block,
tvb, offset, sdnv_length, control_flags);
proto_tree_add_boolean(block_flag_tree, hf_block_control_not_processed,
tvb, offset, sdnv_length, control_flags);
block_flag_eid_reference_item = proto_tree_add_boolean(block_flag_tree, hf_block_control_eid_reference,
tvb, offset, sdnv_length, control_flags);
offset += sdnv_length;
block_overhead += sdnv_length;
/* TODO: if this block has EID references, add them to display tree */
if (control_flags & BLOCK_CONTROL_EID_REFERENCE) {
int i;
int num_eid_ref;
num_eid_ref = evaluate_sdnv(tvb, offset, &sdnv_length);
offset += sdnv_length;
block_overhead += sdnv_length;
for (i = 0; i < num_eid_ref; i++)
{
if (evaluate_sdnv(tvb, offset, &sdnv_length) < 0)
break;
offset += sdnv_length;
block_overhead += sdnv_length;
if (evaluate_sdnv(tvb, offset, &sdnv_length) < 0)
break;
offset += sdnv_length;
block_overhead += sdnv_length;
}
}
block_length = evaluate_sdnv(tvb, offset, &sdnv_length);
ti = proto_tree_add_int(block_tree, hf_block_control_block_length, tvb, offset, sdnv_length, block_length);
if (block_length < 0) {
expert_add_info_format(pinfo, ti, &ei_bundle_offset_error, "Metadata Block Length Error");
/* Force quitting */
*lastheader = TRUE;
return offset;
}
offset += sdnv_length;
block_overhead += sdnv_length;
/* now we have enough info to know total length of metadata block */
proto_item_set_len(block_item, block_overhead + block_length);
switch (type)
{
case BUNDLE_BLOCK_TYPE_AUTHENTICATION:
case BUNDLE_BLOCK_TYPE_METADATA_EXTENSION:
case BUNDLE_BLOCK_TYPE_EXTENSION_SECURITY:
{
proto_tree_add_string(block_tree, hf_bundle_unprocessed_block_data, tvb, offset, block_length, "Block data");
/* not yet dissected, skip past data */
offset += block_length;
break;
}
case BUNDLE_BLOCK_TYPE_BUNDLE_AGE:
{
bundle_age = evaluate_sdnv(tvb, offset, &sdnv_length);
proto_tree_add_int(block_tree, hf_bundle_age_extension_block_code, tvb, offset, sdnv_length, bundle_age/1000000);
offset += block_length;
break;
}
case BUNDLE_BLOCK_TYPE_PREVIOUS_HOP_INSERT:
{
int scheme_length;
proto_tree_add_item_ret_length(block_tree, hf_bundle_block_previous_hop_scheme, tvb, offset, 4, ENC_ASCII, &scheme_length);
offset += scheme_length;
proto_tree_add_item(block_tree, hf_bundle_block_previous_hop_eid, tvb, offset, block_length-scheme_length, ENC_ASCII);
if (block_length - scheme_length < 1) {
expert_add_info_format(pinfo, ti, &ei_bundle_offset_error, "Metadata Block Length Error");
*lastheader = TRUE;
return offset;
}
offset += block_length - scheme_length;
break;
}
case BUNDLE_BLOCK_TYPE_INTEGRITY:
case BUNDLE_BLOCK_TYPE_CONFIDENTIALITY:
{
int target_block_type;
int target_block_occurrence;
int ciphersuite_type;
unsigned int ciphersuite_flags;
target_block_type = evaluate_sdnv(tvb, offset, &sdnv_length);
proto_tree_add_int(block_tree, hf_bundle_target_block_type, tvb, offset, sdnv_length, target_block_type);
offset += sdnv_length;
target_block_occurrence = evaluate_sdnv(tvb, offset, &sdnv_length);
proto_tree_add_int(block_tree, hf_bundle_target_block_occurrence, tvb, offset, sdnv_length, target_block_occurrence);
offset += sdnv_length;
ciphersuite_type = evaluate_sdnv(tvb, offset, &sdnv_length);
proto_tree_add_int(block_tree, hf_bundle_ciphersuite_type, tvb, offset, sdnv_length, ciphersuite_type);
offset += sdnv_length;
ciphersuite_flags = (unsigned int)evaluate_sdnv(tvb, offset, &sdnv_length);
block_flag_item = proto_tree_add_uint(block_tree, hf_bundle_ciphersuite_flags, tvb, offset, sdnv_length, ciphersuite_flags);
block_flag_tree = proto_item_add_subtree(block_flag_item, ett_block_flags);
proto_tree_add_boolean(block_flag_tree, hf_block_ciphersuite_params, tvb, offset, sdnv_length, ciphersuite_flags);
offset += sdnv_length;
int range_offset;
int range_length;
if (ciphersuite_flags & BLOCK_CIPHERSUITE_PARAMS) {
/* Decode cipher suite parameters */
int params_length;
int param_type;
int item_length;
proto_tree *param_tree;
expert_field *ei = NULL;
params_length = evaluate_sdnv_ei(tvb, offset, &sdnv_length, &ei);
if (ei) {
proto_tree_add_expert(block_tree, pinfo, ei, tvb, offset, -1);
*lastheader = TRUE;
return offset;
}
param_tree = proto_tree_add_subtree(block_tree, tvb, offset, params_length+1, ett_sec_block_param_data, NULL, "Ciphersuite Parameters Data");
proto_tree_add_int(param_tree, hf_block_ciphersuite_params_length, tvb, offset, sdnv_length, params_length);
offset += sdnv_length;
for(int i = 0; i < params_length; i+=item_length+2)
{
param_type = evaluate_sdnv(tvb, offset, &sdnv_length);
proto_tree_add_int(param_tree, hf_block_ciphersuite_param_type, tvb, offset, sdnv_length, param_type);
offset += sdnv_length;
ei = NULL;
item_length = evaluate_sdnv_ei(tvb, offset, &sdnv_length, &ei);
proto_tree_add_int(param_tree, hf_block_ciphersuite_params_item_length, tvb, offset, sdnv_length, item_length);
if (ei) {
proto_tree_add_expert(param_tree, pinfo, ei, tvb, offset, -1);
*lastheader = TRUE;
return offset;
}
offset += sdnv_length;
//display item data
switch (param_type)
{
case 1:
case 3:
case 5:
case 7:
case 8:
proto_tree_add_item(param_tree, hf_block_ciphersuite_param_data, tvb, offset, item_length, ENC_NA);
offset += item_length;
break;
case 4:
//pair of sdnvs offset and length
range_offset = evaluate_sdnv(tvb, offset, &sdnv_length);
proto_tree_add_int(param_tree, hf_block_ciphersuite_range_offset, tvb, offset, sdnv_length, range_offset);
offset += sdnv_length;
range_length = evaluate_sdnv(tvb, offset, &sdnv_length);
proto_tree_add_int(param_tree, hf_block_ciphersuite_range_length, tvb, offset, sdnv_length, range_length);
offset += sdnv_length;
break;
default:
break;
}
}
}
/* Decode cipher suite results */
int result_length;
int result_type;
int result_item_length;
proto_tree *result_tree;
result_length = evaluate_sdnv(tvb, offset, &sdnv_length);
result_tree = proto_tree_add_subtree(block_tree, tvb, offset, result_length+1, ett_sec_block_param_data, NULL, "Security Results Data");
proto_tree_add_int(result_tree, hf_block_ciphersuite_result_length, tvb, offset, sdnv_length, result_length);
offset += sdnv_length;
for(int i = 0; i < result_length; i+=result_item_length+2)
{
result_type = evaluate_sdnv(tvb, offset, &sdnv_length);
proto_tree_add_int(result_tree, hf_block_ciphersuite_result_type, tvb, offset, sdnv_length, result_type);
offset += sdnv_length;
expert_field *ei = NULL;
result_item_length = evaluate_sdnv_ei(tvb, offset, &sdnv_length, &ei);
proto_tree_add_int(result_tree, hf_block_ciphersuite_result_item_length, tvb, offset, sdnv_length, result_item_length);
if (ei) {
proto_tree_add_expert(result_tree, pinfo, ei, tvb, offset, -1);
*lastheader = TRUE;
return offset;
}
offset += sdnv_length;
//display item data
switch (result_type)
{
case 1:
case 3:
case 5:
case 7:
case 8:
proto_tree_add_item(result_tree, hf_block_ciphersuite_result_data, tvb, offset, result_item_length, ENC_NA);
offset += result_item_length;
break;
case 4:
//pair of sdnvs offset and length
range_offset = evaluate_sdnv(tvb, offset, &sdnv_length);
proto_tree_add_int(result_tree, hf_block_ciphersuite_range_offset, tvb, offset, sdnv_length, range_offset);
offset += sdnv_length;
range_length = evaluate_sdnv(tvb, offset, &sdnv_length);
proto_tree_add_int(result_tree, hf_block_ciphersuite_range_length, tvb, offset, sdnv_length, range_length);
offset += sdnv_length;
break;
default:
break;
}
}
break;
}
case BUNDLE_BLOCK_TYPE_CUSTODY_TRANSFER:
{
int custody_id;
const guint8 *cteb_creator_custodian_eid;
int cteb_creator_custodian_eid_length;
/* check requirements for Block Processing Control Flags */
if ((control_flags & BLOCK_CONTROL_REPLICATE) != 0) {
expert_add_info_format(pinfo, block_flag_replicate_item, &ei_bundle_block_control_flags, "ERROR: Replicate must be clear for CTEB");
}
if ((control_flags & BLOCK_CONTROL_EID_REFERENCE) != 0) {
expert_add_info_format(pinfo, block_flag_eid_reference_item, &ei_bundle_block_control_flags, "ERROR: EID-Reference must be clear for CTEB");
}
/* there are two elements in a CTEB, first is the custody ID */
custody_id = evaluate_sdnv(tvb, offset, &sdnv_length);
proto_tree_add_int(block_tree, hf_block_control_block_cteb_custody_id, tvb, offset, sdnv_length, custody_id);
offset += sdnv_length;
/* and second is the creator custodian EID */
if (block_length - sdnv_length < 1) {
expert_add_info_format(pinfo, ti, &ei_bundle_offset_error, "Metadata Block Length Error");
*lastheader = TRUE;
return offset;
}
cteb_creator_custodian_eid_length = block_length - sdnv_length;
ti = proto_tree_add_item_ret_string(block_tree, hf_block_control_block_cteb_creator_custodian_eid, tvb, offset,
cteb_creator_custodian_eid_length, ENC_ASCII, pinfo->pool, &cteb_creator_custodian_eid);
/* also check if CTEB is valid, i.e. custodians match */
if (bundle_custodian == NULL) {
expert_add_info_format(pinfo, ti, &ei_block_control_block_cteb_invalid,
"CTEB Is NOT Valid (Bundle Custodian NULL)");
}
else if (strlen(cteb_creator_custodian_eid) != strlen(bundle_custodian)) {
expert_add_info_format(pinfo, ti, &ei_block_control_block_cteb_invalid,
"CTEB Is NOT Valid (Bundle Custodian [%s] != CTEB Custodian [%s])",
bundle_custodian, cteb_creator_custodian_eid);
}
else if (memcmp(cteb_creator_custodian_eid, bundle_custodian, strlen(bundle_custodian)) != 0) {
expert_add_info_format(pinfo, ti, &ei_block_control_block_cteb_invalid,
"CTEB Is NOT Valid (Bundle Custodian [%s] != CTEB Custodian [%s])",
bundle_custodian, cteb_creator_custodian_eid);
}
else {
expert_add_info(pinfo, ti, &ei_block_control_block_cteb_valid);
}
offset += cteb_creator_custodian_eid_length;
break;
}
case BUNDLE_BLOCK_TYPE_EXTENDED_COS:
{
int flags;
static int * const ecos_flags_fields[] = {
&hf_ecos_flags_critical,
&hf_ecos_flags_streaming,
&hf_ecos_flags_flowlabel,
&hf_ecos_flags_reliable,
NULL
};
/* check requirements for Block Processing Control Flags */
if ((control_flags & BLOCK_CONTROL_REPLICATE) == 0) {
expert_add_info_format(pinfo, block_flag_replicate_item, &ei_bundle_block_control_flags, "ERROR: Replicate must be set for ECOS");
}
if ((control_flags & BLOCK_CONTROL_EID_REFERENCE) != 0) {
expert_add_info_format(pinfo, block_flag_eid_reference_item, &ei_bundle_block_control_flags, "ERROR: EID-Reference must be clear for ECOS");
}
/* flags byte */
flags = (int)tvb_get_guint8(tvb, offset);
proto_tree_add_bitmask(block_tree, tvb, offset, hf_ecos_flags, ett_block_flags, ecos_flags_fields, ENC_BIG_ENDIAN);
offset += 1;
/* ordinal byte */
proto_tree_add_item(block_tree, hf_ecos_ordinal, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
/* optional flow label sdnv */
if ((flags & ECOS_FLAGS_FLOWLABEL) != 0) {
int flow_label;
flow_label = evaluate_sdnv(tvb, offset, &sdnv_length);
ti = proto_tree_add_int(block_tree, hf_ecos_flow_label, tvb, offset, sdnv_length, flow_label);
if (flow_label < 0) {
expert_add_info_format(pinfo, ti, &ei_bundle_sdnv_length, "ECOS Flow Label Error");
/* Force quitting */
*lastheader = TRUE;
return offset;
}
offset += sdnv_length;
}
break;
}
default:
{
proto_tree_add_string(block_tree, hf_bundle_unprocessed_block_data, tvb, offset, block_length, "Block data");
/* unknown bundle type, skip past data */
offset += block_length;
break;
}
}
return offset;
}
/*3rd arg is number of bytes in field (returned)*/
static int
evaluate_sdnv(tvbuff_t *tvb, int offset, int *bytecount)
{
guint64 value = 0;
*bytecount = tvb_get_varint(tvb, offset, FT_VARINT_MAX_LEN, &value, ENC_VARINT_SDNV);
if (*bytecount == 0) {
return -1;
}
if (value > G_MAXINT) {
ws_warning("evaluate_sdnv decoded a value too large to fit in an int, truncating");
return G_MAXINT;
}
return (int)value;
}
static int
evaluate_sdnv_ei(tvbuff_t *tvb, int offset, int *bytecount, expert_field **error) {
int value = evaluate_sdnv(tvb, offset, bytecount);
*error = (value < 0) ? &ei_bundle_sdnv_length : NULL;
return value;
}
/* Special Function to evaluate 64 bit SDNVs */
/*3rd arg is number of bytes in field (returned)*/
static gint64
evaluate_sdnv_64(tvbuff_t *tvb, int offset, int *bytecount)
{
guint64 val = 0;
*bytecount = tvb_get_varint(tvb, offset, FT_VARINT_MAX_LEN, &val, ENC_VARINT_SDNV);
if (*bytecount == 0) {
return -1;
}
return val & G_MAXINT64;
}
static int
dissect_bpv6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
proto_item *ti, *ti_bundle_protocol;
proto_tree *bundle_tree, *primary_tree;
int primary_header_size;
gboolean lastheader = FALSE;
int offset = 0;
guint8 version, pri_hdr_procflags;
/* Custodian from Primary Block, used to validate CTEB */
gchar *bundle_custodian = NULL;
version = tvb_get_guint8(tvb, offset); /* Primary Header Version */
if ((version != 4) && (version != 5) && (version != 6)) {
return 0;
}
col_set_str(pinfo->cinfo, COL_PROTOCOL, "Bundle");
/* Clear out stuff in the info column */
col_clear(pinfo->cinfo,COL_INFO);
ti_bundle_protocol = proto_tree_add_item(tree, proto_bundle, tvb, offset, -1, ENC_NA);
// identify parent proto version
proto_item_append_text(ti_bundle_protocol, " Version %d", version);
bundle_tree = proto_item_add_subtree(ti_bundle_protocol, ett_bundle);
primary_tree = proto_tree_add_subtree(bundle_tree, tvb, offset, -1, ett_primary_hdr, &ti, "Primary Bundle Header");
proto_tree_add_item(primary_tree, hf_bundle_pdu_version, tvb, offset, 1, ENC_BIG_ENDIAN);
if (version == 4) {
primary_header_size = dissect_version_4_primary_header(pinfo, primary_tree, tvb,
&pri_hdr_procflags, &bundle_custodian);
}
else {
primary_header_size = dissect_version_5_and_6_primary_header(pinfo, primary_tree, tvb,
&pri_hdr_procflags, &bundle_custodian);
}
if (primary_header_size == 0) { /*Couldn't parse primary header*/
col_add_str(pinfo->cinfo, COL_INFO, "Protocol Error");
return(0); /*Give up*/
}
proto_item_set_len(ti, primary_header_size);
offset = primary_header_size;
/*
* Done with primary header; decode the remaining headers
*/
while (lastheader == FALSE) {
guint8 next_header_type;
next_header_type = tvb_get_guint8(tvb, offset);
if (next_header_type == BUNDLE_BLOCK_TYPE_PAYLOAD) {
/*
* Returns payload size or 0 if can't parse payload
*/
offset = dissect_payload_header(bundle_tree, tvb, pinfo, offset, version, pri_hdr_procflags, &lastheader);
}
else { /*Assume anything else is a Metadata Block*/
offset = display_extension_block(bundle_tree, tvb, pinfo, offset, bundle_custodian, &lastheader);
}
}
proto_item_set_len(ti_bundle_protocol, offset);
return(offset);
}
/// Introspect the data to choose a dissector version
static int
dissect_bundle(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
gint offset = 0;
{
// Primary Header Version octet
guint8 version = tvb_get_guint8(tvb, offset);
if ((version == 4) || (version == 5) || (version == 6)) {
return call_dissector(bpv6_handle, tvb, pinfo, tree);
}
}
wscbor_chunk_t *frame = wscbor_chunk_read(pinfo->pool, tvb, &offset);
if (frame->type_major == CBOR_TYPE_ARRAY) {
wscbor_chunk_t *primary = wscbor_chunk_read(pinfo->pool, tvb, &offset);
if (primary->type_major == CBOR_TYPE_ARRAY) {
wscbor_chunk_t *version = wscbor_chunk_read(pinfo->pool, tvb, &offset);
if (version->type_major == CBOR_TYPE_UINT) {
guint64 vers_val = version->head_value;
if (vers_val == 7) {
return call_dissector(bpv7_handle, tvb, pinfo, tree);
}
}
}
}
return 0;
}
void
proto_register_bpv6(void)
{
static hf_register_info hf[] = {
{&hf_bundle_pdu_version,
{"Bundle Version", "bundle.version",
FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_procflags,
{"Primary Header Processing Flags", "bundle.primary.proc.flag",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_procflags_fragment,
{"Bundle is a Fragment", "bundle.primary.proc.frag",
FT_BOOLEAN, 8, NULL, BUNDLE_PROCFLAGS_FRAG_MASK, NULL, HFILL}
},
{&hf_bundle_procflags_admin,
{"Administrative Record", "bundle.primary.proc.admin",
FT_BOOLEAN, 8, NULL, BUNDLE_PROCFLAGS_ADMIN_MASK, NULL, HFILL}
},
{&hf_bundle_procflags_dont_fragment,
{"Do Not Fragment Bundle", "bundle.primary.proc.dontfrag",
FT_BOOLEAN, 8, NULL, BUNDLE_PROCFLAGS_DONTFRAG_MASK, NULL, HFILL}
},
{&hf_bundle_procflags_cust_xfer_req,
{"Request Custody Transfer", "bundle.primary.proc.xferreq",
FT_BOOLEAN, 8, NULL, BUNDLE_PROCFLAGS_XFERREQ_MASK, NULL, HFILL}
},
{&hf_bundle_procflags_dest_singleton,
{"Destination is Singleton", "bundle.primary.proc.single",
FT_BOOLEAN, 8, NULL, BUNDLE_PROCFLAGS_SINGLETON_MASK, NULL, HFILL}
},
{&hf_bundle_procflags_application_ack,
{"Request Acknowledgement by Application", "bundle.primary.proc.ack",
FT_BOOLEAN, 8, NULL, BUNDLE_PROCFLAGS_APP_ACK_MASK, NULL, HFILL}
},
{&hf_bundle_control_flags,
{"Bundle Processing Control Flags", "bundle.primary.processing.control.flag",
FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_procflags_general,
{"General Flags", "bundle.primary.proc.gen",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_procflags_cos,
{"Class of Service Flags", "bundle.primary.proc.cos",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_procflags_status,
{"Status Report Flags", "bundle.primary.proc.status",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_cosflags,
{"Primary Header COS Flags", "bundle.primary.cos.flags",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_cosflags_priority,
{"Priority", "bundle.primary.cos.priority",
FT_UINT8, BASE_DEC, VALS(cosflags_priority_vals), BUNDLE_COSFLAGS_PRIORITY_MASK, NULL, HFILL}
},
{&hf_bundle_srrflags,
{"Primary Header Report Request Flags", "bundle.primary.srr.flag",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_srrflags_report_receipt,
{"Request Reception Report", "bundle.primary.srr.report",
FT_BOOLEAN, 8, NULL, BUNDLE_SRRFLAGS_REPORT_MASK, NULL, HFILL}
},
{&hf_bundle_srrflags_report_cust_accept,
{"Request Report of Custody Acceptance", "bundle.primary.srr.custaccept",
FT_BOOLEAN, 8, NULL, BUNDLE_SRRFLAGS_CUSTODY_MASK, NULL, HFILL}
},
{&hf_bundle_srrflags_report_forward,
{"Request Report of Bundle Forwarding", "bundle.primary.srr.forward",
FT_BOOLEAN, 8, NULL, BUNDLE_SRRFLAGS_FORWARD_MASK, NULL, HFILL}
},
{&hf_bundle_srrflags_report_delivery,
{"Request Report of Bundle Delivery", "bundle.primary.srr.delivery",
FT_BOOLEAN, 8, NULL, BUNDLE_SRRFLAGS_DELIVERY_MASK, NULL, HFILL}
},
{&hf_bundle_srrflags_report_deletion,
{"Request Report of Bundle Deletion", "bundle.primary.srr.delete",
FT_BOOLEAN, 8, NULL, BUNDLE_SRRFLAGS_DELETION_MASK, NULL, HFILL}
},
{&hf_bundle_srrflags_report_ack,
{"Request Report of Application Ack", "bundle.primary.srr.ack",
FT_BOOLEAN, 8, NULL, BUNDLE_SRRFLAGS_ACK_MASK, NULL, HFILL}
},
{&hf_bundle_primary_header_len,
{"Bundle Header Length", "bundle.primary.len",
FT_INT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_primary_dictionary_len,
{"Dictionary Length", "bundle.primary.dictionary_len",
FT_INT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_primary_fragment_offset,
{"Fragment Offset", "bundle.primary.fragment_offset",
FT_INT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_primary_total_adu_len,
{"Total Application Data Unit Length", "bundle.primary.total_adu_len",
FT_INT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_primary_timestamp_seq_num64,
{"Timestamp Sequence Number", "bundle.primary.timestamp_seq_num64",
FT_INT64, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_primary_timestamp_seq_num32,
{"Timestamp Sequence Number", "bundle.primary.timestamp_seq_num32",
FT_INT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_primary_timestamp,
{"Timestamp", "bundle.primary.timestamp",
FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_dest_scheme_offset_u16,
{"Destination Scheme Offset", "bundle.primary.destschemeoffu16",
FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_dest_scheme_offset_i32,
{"Destination Scheme Offset", "bundle.primary.destschemeoffi32",
FT_INT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_dest_ssp_offset_u16,
{"Destination SSP Offset", "bundle.primary.destssspoffu16",
FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_dest_ssp_offset_i32,
{"Destination SSP Offset", "bundle.primary.destssspoffi32",
FT_INT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_source_scheme_offset_u16,
{"Source Scheme Offset", "bundle.primary.srcschemeoffu16",
FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_source_scheme_offset_i32,
{"Source Scheme Offset", "bundle.primary.srcschemeoffi32",
FT_INT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_source_ssp_offset_u16,
{"Source SSP Offset", "bundle.primary.srcsspoffu16",
FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_source_ssp_offset_i32,
{"Source SSP Offset", "bundle.primary.srcsspoffi32",
FT_INT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_report_scheme_offset_u16,
{"Report Scheme Offset", "bundle.primary.rptschemeoffu16",
FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_report_scheme_offset_i32,
{"Report Scheme Offset", "bundle.primary.rptschemeoffi32",
FT_INT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_report_ssp_offset_u16,
{"Report SSP Offset", "bundle.primary.rptsspoffu16",
FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_report_ssp_offset_i32,
{"Report SSP Offset", "bundle.primary.rptsspoffi32",
FT_INT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_cust_scheme_offset_u16,
{"Custodian Scheme Offset", "bundle.primary.custschemeoffu16",
FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_cust_scheme_offset_i32,
{"Custodian Scheme Offset", "bundle.primary.custschemeoffi32",
FT_INT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_cust_ssp_offset_u16,
{"Custodian SSP Offset", "bundle.primary.custsspoffu16",
FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_cust_ssp_offset_i32,
{"Custodian SSP Offset", "bundle.primary.custsspoffi32",
FT_INT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_dest_scheme,
{"Destination Scheme", "bundle.primary.destination_scheme",
FT_STRINGZ, BASE_NONE, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_dest_ssp,
{"Destination", "bundle.primary.destination",
FT_STRINGZ, BASE_NONE, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_source_scheme,
{"Source Scheme", "bundle.primary.source_scheme",
FT_STRINGZ, BASE_NONE, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_source_ssp,
{"Source", "bundle.primary.source",
FT_STRINGZ, BASE_NONE, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_report_scheme,
{"Report Scheme", "bundle.primary.report_scheme",
FT_STRINGZ, BASE_NONE, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_report_ssp,
{"Report", "bundle.primary.report",
FT_STRINGZ, BASE_NONE, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_custodian_scheme,
{"Custodian Scheme", "bundle.primary.custodian_scheme",
FT_STRINGZ, BASE_NONE, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_custodian_ssp,
{"Custodian", "bundle.primary.custodian",
FT_STRINGZ, BASE_NONE, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_creation_timestamp,
{"Creation Timestamp", "bundle.primary.creation_timestamp",
FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_lifetime,
{"Lifetime", "bundle.primary.lifetime",
FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_lifetime_sdnv,
{"Lifetime", "bundle.primary.lifetime_sdnv",
FT_INT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_payload_length,
{"Payload Length", "bundle.payload.length",
FT_INT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_payload_flags,
{"Payload Header Processing Flags", "bundle.payload.proc.flag",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_payload_header_type,
{"Header Type", "bundle.payload.proc.header_type",
FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_payload_data,
{"Payload Data", "bundle.payload.data",
FT_STRINGZPAD, BASE_NONE, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_payload_flags_replicate_hdr,
{"Replicate Header in Every Fragment", "bundle.payload.proc.replicate",
FT_BOOLEAN, 8, NULL, PAYLOAD_PROCFLAGS_REPLICATE_MASK, NULL, HFILL}
},
{&hf_bundle_payload_flags_xmit_report,
{"Report if Can't Process Header", "bundle.payload.proc.report",
FT_BOOLEAN, 8, NULL, PAYLOAD_PROCFLAGS_XMIT_STATUS, NULL, HFILL}
},
{&hf_bundle_payload_flags_discard_on_fail,
{"Discard if Can't Process Header", "bundle.payload.proc.discard",
FT_BOOLEAN, 8, NULL, PAYLOAD_PROCFLAGS_DISCARD_FAILURE, NULL, HFILL}
},
{&hf_bundle_payload_flags_last_header,
{"Last Header", "bundle.payload.proc.lastheader",
FT_BOOLEAN, 8, NULL, PAYLOAD_PROCFLAGS_LAST_HEADER, NULL, HFILL}
},
{&hf_bundle_admin_record_type,
{"Administrative Record Type", "bundle.admin.record_type",
FT_UINT8, BASE_DEC, VALS(admin_record_type_vals), 0xF0, NULL, HFILL}
},
{&hf_bundle_admin_record_fragment,
{"Administrative Record for Fragment", "bundle.admin.record_fragment",
FT_BOOLEAN, 8, TFS(&tfs_yes_no), ADMIN_REC_FLAGS_FRAGMENT, NULL, HFILL}
},
{&hf_bundle_admin_statflags,
{"Administrative Record Status Flags", "bundle.admin.status.flag",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_admin_rcvd,
{"Reporting Node Received Bundle", "bundle.admin.status.rcvd",
FT_BOOLEAN, 8, NULL, ADMIN_STATUS_FLAGS_RECEIVED, NULL, HFILL}
},
{&hf_bundle_admin_accepted,
{"Reporting Node Accepted Custody", "bundle.admin.status.accept",
FT_BOOLEAN, 8, NULL, ADMIN_STATUS_FLAGS_ACCEPTED, NULL, HFILL}
},
{&hf_bundle_admin_forwarded,
{"Reporting Node Forwarded Bundle", "bundle.admin.status.forward",
FT_BOOLEAN, 8, NULL, ADMIN_STATUS_FLAGS_FORWARDED, NULL, HFILL}
},
{&hf_bundle_admin_delivered,
{"Reporting Node Delivered Bundle", "bundle.admin.status.delivered",
FT_BOOLEAN, 8, NULL, ADMIN_STATUS_FLAGS_DELIVERED, NULL, HFILL}
},
{&hf_bundle_admin_deleted,
{"Reporting Node Deleted Bundle", "bundle.admin.status.delete",
FT_BOOLEAN, 8, NULL, ADMIN_STATUS_FLAGS_DELETED, NULL, HFILL}
},
{&hf_bundle_admin_acked,
{"Acknowledged by Application", "bundle.admin.status.ack",
FT_BOOLEAN, 8, NULL, ADMIN_STATUS_FLAGS_ACKNOWLEDGED, NULL, HFILL}
},
{&hf_bundle_admin_fragment_offset,
{"Fragment Offset", "bundle.admin.fragment_offset",
FT_INT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_admin_fragment_length,
{"Fragment Length", "bundle.admin.fragment_length",
FT_INT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_admin_timestamp_seq_num64,
{"Timestamp Sequence Number", "bundle.admin.timestamp_seq_num64",
FT_INT64, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_admin_timestamp_seq_num32,
{"Timestamp Sequence Number", "bundle.admin.timestamp_seq_num32",
FT_INT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_admin_endpoint_length,
{"Endpoint Length", "bundle.admin.endpoint_length",
FT_INT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_admin_endpoint_id,
{"Bundle Endpoint ID", "bundle.admin.endpoint_id",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_admin_receipt_time,
{"Bundle Received Time", "bundle.admin.status.receipttime",
FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_admin_accept_time,
{"Bundle Accepted Time", "bundle.admin.status.accepttime",
FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_admin_forward_time,
{"Bundle Forwarded Time", "bundle.admin.status.forwardtime",
FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_admin_delivery_time,
{"Bundle Delivered Time", "bundle.admin.status.deliverytime",
FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_admin_delete_time,
{"Bundle Deleted Time", "bundle.admin.status.deletetime",
FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_admin_ack_time,
{"Bundle Acknowledged Time", "bundle.admin.status.acktime",
FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_admin_timestamp_copy,
{"Bundle Creation Timestamp", "bundle.admin.status.timecopy",
FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_admin_signal_time,
{"Bundle Signal Time", "bundle.admin.signal.time",
FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0, NULL, HFILL}
},
{&hf_block_control_flags,
{"Block Processing Control Flags", "bundle.block.control.flags",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
},
{&hf_block_control_flags_sdnv,
{"Block Processing Control Flags", "bundle.block.control.flags",
FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}
},
{&hf_block_control_block_length,
{"Block Length", "bundle.block.length",
FT_INT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{&hf_block_control_block_cteb_custody_id,
{"CTEB Custody ID", "bundle.block.cteb_custody_id",
FT_INT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{&hf_block_control_block_cteb_creator_custodian_eid,
{"CTEB Creator Custodian EID", "bundle.block.cteb_creator_custodian_eid",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL}
},
{&hf_block_control_replicate,
{"Replicate Block in Every Fragment", "bundle.block.control.replicate",
FT_BOOLEAN, 8, NULL, BLOCK_CONTROL_REPLICATE, NULL, HFILL}
},
{&hf_block_control_transmit_status,
{"Transmit Status if Block Can't be Processed", "bundle.block.control.status",
FT_BOOLEAN, 8, NULL, BLOCK_CONTROL_TRANSMIT_STATUS, NULL, HFILL}
},
{&hf_block_control_delete_bundle,
{"Delete Bundle if Block Can't be Processed", "bundle.block.control.delete",
FT_BOOLEAN, 8, NULL, BLOCK_CONTROL_DELETE_BUNDLE, NULL, HFILL}
},
{&hf_block_control_last_block,
{"Last Block", "bundle.block.control.last",
FT_BOOLEAN, 8, NULL, BLOCK_CONTROL_LAST_BLOCK, NULL, HFILL}
},
{&hf_block_control_discard_block,
{"Discard Block If Can't Process", "bundle.block.control.discard",
FT_BOOLEAN, 8, NULL, BLOCK_CONTROL_DISCARD_BLOCK, NULL, HFILL}
},
{&hf_block_control_not_processed,
{"Block Was Forwarded Without Processing", "bundle.block.control.process",
FT_BOOLEAN, 8, NULL, BLOCK_CONTROL_NOT_PROCESSED, NULL, HFILL}
},
{&hf_block_control_eid_reference,
{"Block Contains an EID-reference Field", "bundle.block.control.eid",
FT_BOOLEAN, 8, NULL, BLOCK_CONTROL_EID_REFERENCE, NULL, HFILL}
},
{&hf_bundle_status_report_reason_code,
{"Status Report Reason Code", "bundle.status_report_reason_code",
FT_UINT8, BASE_DEC, VALS(status_report_reason_codes), 0x0, NULL, HFILL}
},
{&hf_bundle_custody_trf_succ_flg,
{"Custody Transfer Succeeded Flag", "bundle.custody_trf_succ_flg",
FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL}
},
{&hf_bundle_custody_signal_reason,
{"Custody Signal Reason Code", "bundle.custody_signal_reason_code",
FT_UINT8, BASE_DEC, VALS(custody_signal_reason_codes), ADMIN_REC_CUSTODY_REASON_MASK, NULL, HFILL}
},
{&hf_bundle_custody_id_range_start,
{"CTEB Custody ID Range Start", "bundle.custody_id_range_start",
FT_INT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_custody_id_range_end,
{"CTEB Custody ID Range End", "bundle.custody_id_range_end",
FT_INT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_block_type_code,
{"Block Type Code", "bundle.block_type_code",
FT_UINT8, BASE_DEC, VALS(bundle_block_type_codes), 0x0, NULL, HFILL}
},
{&hf_bundle_unprocessed_block_data,
{"Block Data", "bundle.block_data",
FT_STRINGZPAD, BASE_NONE, NULL, 0x0, NULL, HFILL}
},
{&hf_ecos_flags,
{"ECOS Flags", "bundle.block.ecos.flags",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
},
{&hf_ecos_flags_critical,
{"Critical", "bundle.block.ecos.flags.critical",
FT_BOOLEAN, 8, NULL, ECOS_FLAGS_CRITICAL, NULL, HFILL}
},
{&hf_ecos_flags_streaming,
{"Streaming", "bundle.block.ecos.flags.streaming",
FT_BOOLEAN, 8, NULL, ECOS_FLAGS_STREAMING, NULL, HFILL}
},
{&hf_ecos_flags_flowlabel,
{"Flow Label", "bundle.block.ecos.flags.flowlabel",
FT_BOOLEAN, 8, NULL, ECOS_FLAGS_FLOWLABEL, NULL, HFILL}
},
{&hf_ecos_flags_reliable,
{"Reliable", "bundle.block.ecos.flags.reliable",
FT_BOOLEAN, 8, NULL, ECOS_FLAGS_RELIABLE, NULL, HFILL}
},
{&hf_ecos_flow_label,
{"ECOS Flow Label", "bundle.block.ecos.flow_label",
FT_INT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{&hf_ecos_ordinal,
{"ECOS Ordinal", "bundle.block.ecos.ordinal",
FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_age_extension_block_code,
{"Bundle Age in seconds", "bundle.age_extension_block_code",
FT_INT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_block_previous_hop_scheme,
{"Previous Hop Scheme", "bundle.block.previous_hop_scheme",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_block_previous_hop_eid,
{"Previous Hop EID", "bundle.block.previous_hop_eid",
FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_target_block_type,
{"Target Block Type", "bundle.target_block_type",
FT_INT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_target_block_occurrence,
{"Target Block Occurrence", "bundle.target_block_occurrence",
FT_INT32, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{&hf_bundle_ciphersuite_type,
{"Ciphersuite Type", "bundle.ciphersuite_type",
FT_INT32, BASE_DEC, VALS(ciphersuite_types), 0x0, NULL, HFILL}
},
{&hf_bundle_ciphersuite_flags,
{"Ciphersuite Flags", "bundle.ciphersuite_flags",
FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL}
},
{&hf_block_ciphersuite_params,
{"Block Contains Ciphersuite Parameters", "bundle.block.ciphersuite_params",
FT_BOOLEAN, 8, NULL, BLOCK_CIPHERSUITE_PARAMS, NULL, HFILL}
},
{&hf_block_ciphersuite_params_length,
{"Ciphersuite Parameters Length", "bundle.block.ciphersuite_params_length",
FT_INT8, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{&hf_block_ciphersuite_params_item_length,
{"Parameter Length", "bundle.block.ciphersuite_params_item_length",
FT_INT8, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{&hf_block_ciphersuite_param_type,
{"Ciphersuite Parameter Type", "bundle.block.ciphersuite_param_type",
FT_INT8, BASE_DEC, VALS(res_params_types), 0x0, NULL, HFILL}
},
{&hf_block_ciphersuite_param_data,
{"Ciphersuite Parameter Data", "bundle.block.ciphersuite_param_data",
FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
},
{&hf_block_ciphersuite_result_length,
{"Security Results Length", "bundle.block.ciphersuite_result_length",
FT_INT8, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{&hf_block_ciphersuite_result_item_length,
{"Security Result Item Length", "bundle.block.ciphersuite_result_item_length",
FT_INT8, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{&hf_block_ciphersuite_result_type,
{"Security Result Item Type", "bundle.block.ciphersuite_result_type",
FT_INT8, BASE_DEC, VALS(res_params_types), 0x0, NULL, HFILL}
},
{&hf_block_ciphersuite_result_data,
{"Security Result Item Data", "bundle.block.ciphersuite_result_data",
FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}
},
{&hf_block_ciphersuite_range_offset,
{"Content Range Offset", "bundle.block.ciphersuite_range_offset",
FT_INT8, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
{&hf_block_ciphersuite_range_length,
{"Content Range Length", "bundle.block.ciphersuite_range_length",
FT_INT8, BASE_DEC, NULL, 0x0, NULL, HFILL}
},
};
static gint *ett[] = {
&ett_bundle,
&ett_bundle_hdr,
&ett_primary_hdr,
&ett_proc_flags,
&ett_gen_flags,
&ett_cos_flags,
&ett_srr_flags,
&ett_dictionary,
&ett_payload_hdr,
&ett_payload_flags,
&ett_block_flags,
&ett_admin_record,
&ett_admin_rec_status,
&ett_metadata_hdr,
&ett_sec_block_param_data
};
static ei_register_info ei[] = {
{ &ei_bundle_control_flags_length,
{ "bundle.block.control.flags.length", PI_UNDECODED, PI_WARN, "Wrong bundle control flag length", EXPFILL }
},
{ &ei_bundle_payload_length,
{ "bundle.payload.length.invalid", PI_PROTOCOL, PI_ERROR, "Payload length error", EXPFILL }
},
{ &ei_bundle_sdnv_length,
{ "bundle.sdnv_length_invalid", PI_PROTOCOL, PI_ERROR, "SDNV length error", EXPFILL }
},
{ &ei_bundle_timestamp_seq_num,
{ "bundle.timestamp_seq_num_invalid", PI_PROTOCOL, PI_ERROR, "Timestamp Sequence Number error", EXPFILL }
},
{ &ei_bundle_offset_error,
{ "bundle.offset_error", PI_PROTOCOL, PI_WARN, "Offset field error", EXPFILL }
},
{ &ei_bundle_block_control_flags,
{ "bundle.block.control.flags.error", PI_PROTOCOL, PI_WARN, "Control flag error", EXPFILL }
},
{ &ei_block_control_block_cteb_invalid,
{ "bundle.block.control.cteb_invalid", PI_PROTOCOL, PI_WARN, "CTEB Is Invalid", EXPFILL }
},
{ &ei_block_control_block_cteb_valid,
{ "bundle.block.control.cteb_valid", PI_PROTOCOL, PI_NOTE, "CTEB Is Valid", EXPFILL }
},
};
expert_module_t *expert_bundle;
proto_bundle = proto_register_protocol("Bundle Protocol", "BP", "bundle");
bpv6_handle = register_dissector("bpv6", dissect_bpv6, proto_bundle);
bundle_handle = register_dissector("bundle", dissect_bundle, proto_bundle);
proto_register_field_array(proto_bundle, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
expert_bundle = expert_register_protocol(proto_bundle);
expert_register_field_array(expert_bundle, ei, array_length(ei));
}
void
proto_reg_handoff_bpv6(void)
{
bpv7_handle = find_dissector("bpv7");
dissector_add_uint_with_preference("udp.port", BUNDLE_PORT, bundle_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:
*/
|