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
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
|
/* packet-gtp.c
*
* Routines for GTP dissection
* Copyright 2001, Michal Melerowicz <michal.melerowicz@nokia.com>
* Nicolas Balkota <balkota@mac.com>
*
* $Id: packet-gtp.c,v 1.72 2004/02/25 09:31:05 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
* Copyright 1998 Gerald Combs
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <epan/packet.h>
#include "prefs.h"
#include "packet-gtp.h"
#include "packet-ipv6.h"
#include "packet-ppp.h"
static dissector_table_t ppp_subdissector_table;
#define GTPv0_PORT 3386
#define GTPv1C_PORT 2123 /* 3G Control PDU */
#define GTPv1U_PORT 2152 /* 3G T-PDU */
#define GTPv0_HDR_LENGTH 20
#define GTPv1_HDR_LENGTH 12
#define GTP_PRIME_HDR_LENGTH 6
/* to check compliance with ETSI */
#define GTP_MANDATORY 1
#define GTP_OPTIONAL 2
#define GTP_CONDITIONAL 4
static int g_gtpv0_port = GTPv0_PORT;
static int g_gtpv1c_port = GTPv1C_PORT;
static int g_gtpv1u_port = GTPv1U_PORT;
void proto_reg_handoff_gtp(void);
static int proto_gtp = -1;
static int hf_gtp_apn = -1;
static int hf_gtp_cause = -1;
static int hf_gtp_chrg_char = -1;
static int hf_gtp_chrg_char_s = -1;
static int hf_gtp_chrg_char_n = -1;
static int hf_gtp_chrg_char_p = -1;
static int hf_gtp_chrg_char_f = -1;
static int hf_gtp_chrg_char_h = -1;
static int hf_gtp_chrg_char_r = -1;
static int hf_gtp_chrg_id = -1;
static int hf_gtp_chrg_ipv4 = -1;
static int hf_gtp_chrg_ipv6 = -1;
static int hf_gtp_ext_flow_label = -1;
static int hf_gtp_ext_id = -1;
static int hf_gtp_ext_val = -1;
static int hf_gtp_flags = -1;
static int hf_gtp_flags_ver = -1;
static int hf_gtp_flags_pt = -1;
static int hf_gtp_flags_spare1 = -1;
static int hf_gtp_flags_snn = -1;
static int hf_gtp_flags_spare2 = -1;
static int hf_gtp_flags_e = -1;
static int hf_gtp_flags_s = -1;
static int hf_gtp_flags_pn = -1;
static int hf_gtp_flow_ii = -1;
static int hf_gtp_flow_label = -1;
static int hf_gtp_flow_sig = -1;
static int hf_gtp_gsn_addr_len = -1;
static int hf_gtp_gsn_addr_type = -1;
static int hf_gtp_gsn_ipv4 = -1;
static int hf_gtp_gsn_ipv6 = -1;
static int hf_gtp_imsi = -1;
static int hf_gtp_length = -1;
static int hf_gtp_map_cause = -1;
static int hf_gtp_message_type = -1;
static int hf_gtp_ms_reason = -1;
static int hf_gtp_ms_valid = -1;
static int hf_gtp_msisdn = -1;
static int hf_gtp_next = -1;
static int hf_gtp_npdu_number = -1;
static int hf_gtp_node_ipv4 = -1;
static int hf_gtp_node_ipv6 = -1;
static int hf_gtp_nsapi = -1;
static int hf_gtp_ptmsi = -1;
static int hf_gtp_ptmsi_sig = -1;
static int hf_gtp_qos_spare1 = -1;
static int hf_gtp_qos_delay = -1;
static int hf_gtp_qos_mean = -1;
static int hf_gtp_qos_peak = -1;
static int hf_gtp_qos_spare2 = -1;
static int hf_gtp_qos_precedence = -1;
static int hf_gtp_qos_spare3 = -1;
static int hf_gtp_qos_reliability = -1;
static int hf_gtp_qos_al_ret_priority = -1;
static int hf_gtp_qos_traf_class = -1;
static int hf_gtp_qos_del_order = -1;
static int hf_gtp_qos_del_err_sdu = -1;
static int hf_gtp_qos_max_sdu_size = -1;
static int hf_gtp_qos_max_ul = -1;
static int hf_gtp_qos_max_dl = -1;
static int hf_gtp_qos_res_ber = -1;
static int hf_gtp_qos_sdu_err_ratio = -1;
static int hf_gtp_qos_trans_delay = -1;
static int hf_gtp_qos_traf_handl_prio = -1;
static int hf_gtp_qos_guar_ul = -1;
static int hf_gtp_qos_guar_dl = -1;
static int hf_gtp_pkt_flow_id = -1;
static int hf_gtp_rab_gtpu_dn = -1;
static int hf_gtp_rab_gtpu_up = -1;
static int hf_gtp_rab_pdu_dn = -1;
static int hf_gtp_rab_pdu_up = -1;
static int hf_gtp_rai_mcc = -1;
static int hf_gtp_rai_mnc = -1;
static int hf_gtp_rai_rac = -1;
static int hf_gtp_rai_lac = -1;
static int hf_gtp_ranap_cause = -1;
static int hf_gtp_recovery = -1;
static int hf_gtp_reorder = -1;
static int hf_gtp_rnc_ipv4 = -1;
static int hf_gtp_rnc_ipv6 = -1;
static int hf_gtp_rp = -1;
static int hf_gtp_rp_nsapi = -1;
static int hf_gtp_rp_sms = -1;
static int hf_gtp_rp_spare = -1;
static int hf_gtp_sel_mode = -1;
static int hf_gtp_seq_number = -1;
static int hf_gtp_sndcp_number = -1;
static int hf_gtp_tear_ind = -1;
static int hf_gtp_teid = -1;
static int hf_gtp_teid_cp = -1;
static int hf_gtp_teid_data = -1;
static int hf_gtp_teid_ii = -1;
static int hf_gtp_tft_code = -1;
static int hf_gtp_tft_spare = -1;
static int hf_gtp_tft_number = -1;
static int hf_gtp_tft_eval = -1;
static int hf_gtp_tid = -1;
static int hf_gtp_tlli = -1;
static int hf_gtp_tr_comm = -1;
static int hf_gtp_trace_ref = -1;
static int hf_gtp_trace_type = -1;
static int hf_gtp_unknown = -1;
static int hf_gtp_user_addr_pdp_org = -1;
static int hf_gtp_user_addr_pdp_type = -1;
static int hf_gtp_user_ipv4 = -1;
static int hf_gtp_user_ipv6 = -1;
/* Initialize the subtree pointers */
static gint ett_gtp = -1;
static gint ett_gtp_flags = -1;
static gint ett_gtp_ext = -1;
static gint ett_gtp_rai = -1;
static gint ett_gtp_qos = -1;
static gint ett_gtp_auth_tri = -1;
static gint ett_gtp_flow_ii = -1;
static gint ett_gtp_rab_cntxt = -1;
static gint ett_gtp_rp = -1;
static gint ett_gtp_pkt_flow_id = -1;
static gint ett_gtp_chrg_char = -1;
static gint ett_gtp_user = -1;
static gint ett_gtp_mm = -1;
static gint ett_gtp_trip = -1;
static gint ett_gtp_quint = -1;
static gint ett_gtp_pdp = -1;
static gint ett_gtp_apn = -1;
static gint ett_gtp_proto = -1;
static gint ett_gtp_gsn_addr = -1;
static gint ett_gtp_tft = -1;
static gint ett_gtp_tft_pf = -1;
static gint ett_gtp_tft_flags = -1;
static gint ett_gtp_rab_setup = -1;
static gint ett_gtp_hdr_list = -1;
static gint ett_gtp_chrg_addr = -1;
static gint ett_gtp_node_addr = -1;
static gint ett_gtp_rel_pack = -1;
static gint ett_gtp_can_pack = -1;
static gint ett_gtp_data_resp = -1;
static gint ett_gtp_priv_ext = -1;
static gboolean gtp_tpdu = TRUE;
static gboolean gtp_etsi_order = FALSE;
static int gtpv0_port = 0;
static int gtpv1c_port = 0;
static int gtpv1u_port = 0;
/* Definition of flags masks */
#define GTP_VER_MASK 0xE0
static const value_string ver_types[] = {
{ 0, "GTP release 97/98 version" },
{ 1, "GTP release 99 version" },
{ 2, "None" },
{ 3, "None" },
{ 4, "None" },
{ 5, "None" },
{ 6, "None" },
{ 7, "None" },
{ 0, NULL }
};
#define GTP_PT_MASK 0x10
#define GTP_SPARE1_MASK 0x0E
#define GTP_SPARE2_MASK 0x08
#define GTP_E_MASK 0x04
#define GTP_S_MASK 0x02
#define GTP_SNN_MASK 0x01
#define GTP_PN_MASK 0x01
/* Definition of 3G charging characteristics masks */
#define GTP_MASK_CHRG_CHAR_S 0xF000
#define GTP_MASK_CHRG_CHAR_N 0x0800
#define GTP_MASK_CHRG_CHAR_P 0x0400
#define GTP_MASK_CHRG_CHAR_F 0x0200
#define GTP_MASK_CHRG_CHAR_H 0x0100
#define GTP_MASK_CHRG_CHAR_R 0x00FF
/* Traffic Flow Templates mask */
#define GTPv1_TFT_CODE_MASK 0xE0
#define GTPv1_TFT_SPARE_MASK 0x10
#define GTPv1_TFT_NUMBER_MASK 0x0F
/* Definition of GSN Address masks */
#define GTP_EXT_GSN_ADDR_TYPE_MASK 0xC0
#define GTP_EXT_GSN_ADDR_LEN_MASK 0x3F
/* Definition of QoS masks */
#define GTP_EXT_QOS_SPARE1_MASK 0xC0
#define GTP_EXT_QOS_DELAY_MASK 0x38
#define GTP_EXT_QOS_RELIABILITY_MASK 0x07
#define GTP_EXT_QOS_PEAK_MASK 0xF0
#define GTP_EXT_QOS_SPARE2_MASK 0x08
#define GTP_EXT_QOS_PRECEDENCE_MASK 0x07
#define GTP_EXT_QOS_SPARE3_MASK 0xE0
#define GTP_EXT_QOS_MEAN_MASK 0x1F
#define GTP_EXT_QOS_TRAF_CLASS_MASK 0xE0
#define GTP_EXT_QOS_DEL_ORDER_MASK 0x18
#define GTP_EXT_QOS_DEL_ERR_SDU_MASK 0x07
#define GTP_EXT_QOS_RES_BER_MASK 0xF0
#define GTP_EXT_QOS_SDU_ERR_RATIO_MASK 0x0F
#define GTP_EXT_QOS_TRANS_DELAY_MASK 0xFC
#define GTP_EXT_QOS_TRAF_HANDL_PRIORITY_MASK 0x03
/* Definition of Radio Priority's masks */
#define GTPv1_EXT_RP_NSAPI_MASK 0xF0
#define GTPv1_EXT_RP_SPARE_MASK 0x08
#define GTPv1_EXT_RP_MASK 0x07
/* definitions of GTP messages */
#define GTP_MSG_UNKNOWN 0x00
#define GTP_MSG_ECHO_REQ 0x01
#define GTP_MSG_ECHO_RESP 0x02
#define GTP_MSG_VER_NOT_SUPP 0x03
#define GTP_MSG_NODE_ALIVE_REQ 0x04
#define GTP_MSG_NODE_ALIVE_RESP 0x05
#define GTP_MSG_REDIR_REQ 0x06
#define GTP_MSG_REDIR_RESP 0x07
#define GTP_MSG_CREATE_PDP_REQ 0x10
#define GTP_MSG_CREATE_PDP_RESP 0x11
#define GTP_MSG_UPDATE_PDP_REQ 0x12
#define GTP_MSG_UPDATE_PDP_RESP 0x13
#define GTP_MSG_DELETE_PDP_REQ 0x14
#define GTP_MSG_DELETE_PDP_RESP 0x15
#define GTP_MSG_CREATE_AA_PDP_REQ 0x16 /* 2G */
#define GTP_MSG_CREATE_AA_PDP_RESP 0x17 /* 2G */
#define GTP_MSG_DELETE_AA_PDP_REQ 0x18 /* 2G */
#define GTP_MSG_DELETE_AA_PDP_RESP 0x19 /* 2G */
#define GTP_MSG_ERR_IND 0x1A
#define GTP_MSG_PDU_NOTIFY_REQ 0x1B
#define GTP_MSG_PDU_NOTIFY_RESP 0x1C
#define GTP_MSG_PDU_NOTIFY_REJ_REQ 0x1D
#define GTP_MSG_PDU_NOTIFY_REJ_RESP 0x1E
#define GTP_MSG_SUPP_EXT_HDR 0x1F
#define GTP_MSG_SEND_ROUT_INFO_REQ 0x20
#define GTP_MSG_SEND_ROUT_INFO_RESP 0x21
#define GTP_MSG_FAIL_REP_REQ 0x22
#define GTP_MSG_FAIL_REP_RESP 0x23
#define GTP_MSG_MS_PRESENT_REQ 0x24
#define GTP_MSG_MS_PRESENT_RESP 0x25
#define GTP_MSG_IDENT_REQ 0x30
#define GTP_MSG_IDENT_RESP 0x31
#define GTP_MSG_SGSN_CNTXT_REQ 0x32
#define GTP_MSG_SGSN_CNTXT_RESP 0x33
#define GTP_MSG_SGSN_CNTXT_ACK 0x34
#define GTP_MSG_FORW_RELOC_REQ 0x35
#define GTP_MSG_FORW_RELOC_RESP 0x36
#define GTP_MSG_FORW_RELOC_COMP 0x37
#define GTP_MSG_RELOC_CANCEL_REQ 0x38
#define GTP_MSG_RELOC_CANCEL_RESP 0x39
#define GTP_MSG_FORW_SRNS_CNTXT 0x3A
#define GTP_MSG_FORW_RELOC_ACK 0x3B
#define GTP_MSG_FORW_SRNS_CNTXT_ACK 0x3C
#define GTP_MSG_DATA_TRANSF_REQ 0xF0
#define GTP_MSG_DATA_TRANSF_RESP 0xF1
#define GTP_MSG_TPDU 0xFF
static const value_string message_type[] = {
{ GTP_MSG_UNKNOWN, "For future use" },
{ GTP_MSG_ECHO_REQ, "Echo request" },
{ GTP_MSG_ECHO_RESP, "Echo response" },
{ GTP_MSG_VER_NOT_SUPP, "Version not supported" },
{ GTP_MSG_NODE_ALIVE_REQ, "Node alive request" },
{ GTP_MSG_NODE_ALIVE_RESP, "Node alive response" },
{ GTP_MSG_REDIR_REQ, "Redirection request" },
{ GTP_MSG_REDIR_RESP, "Redirection response" },
{ GTP_MSG_CREATE_PDP_REQ, "Create PDP context request" },
{ GTP_MSG_CREATE_PDP_RESP, "Create PDP context response" },
{ GTP_MSG_UPDATE_PDP_REQ, "Update PDP context request" },
{ GTP_MSG_UPDATE_PDP_RESP, "Update PDP context response" },
{ GTP_MSG_DELETE_PDP_REQ, "Delete PDP context request" },
{ GTP_MSG_DELETE_PDP_RESP, "Delete PDP context response" },
{ GTP_MSG_CREATE_AA_PDP_REQ, "Create AA PDP Context Request" },
{ GTP_MSG_CREATE_AA_PDP_RESP, "Create AA PDP Context Response" },
{ GTP_MSG_DELETE_AA_PDP_REQ, "Delete AA PDP Context Request" },
{ GTP_MSG_DELETE_AA_PDP_RESP, "Delete AA PDP Context Response" },
{ GTP_MSG_ERR_IND, "Error indication" },
{ GTP_MSG_PDU_NOTIFY_REQ, "PDU notification request" },
{ GTP_MSG_PDU_NOTIFY_RESP, "PDU notification response" },
{ GTP_MSG_PDU_NOTIFY_REJ_REQ, "PDU notification reject request" },
{ GTP_MSG_PDU_NOTIFY_REJ_RESP, "PDU notification reject response" },
{ GTP_MSG_SUPP_EXT_HDR, "Supported extension header notification" },
{ GTP_MSG_SEND_ROUT_INFO_REQ, "Send routing information for GPRS request" },
{ GTP_MSG_SEND_ROUT_INFO_RESP, "Send routing information for GPRS response" },
{ GTP_MSG_FAIL_REP_REQ, "Failure report request" },
{ GTP_MSG_FAIL_REP_RESP, "Failure report response" },
{ GTP_MSG_MS_PRESENT_REQ, "Note MS GPRS present request" },
{ GTP_MSG_MS_PRESENT_RESP, "Note MS GPRS present response" },
{ GTP_MSG_IDENT_REQ, "Identification request" },
{ GTP_MSG_IDENT_RESP, "Identification response" },
{ GTP_MSG_SGSN_CNTXT_REQ, "SGSN context request" },
{ GTP_MSG_SGSN_CNTXT_RESP, "SGSN context response" },
{ GTP_MSG_SGSN_CNTXT_ACK, "SGSN context acknowledgement" },
{ GTP_MSG_FORW_RELOC_REQ, "Forward relocation request" },
{ GTP_MSG_FORW_RELOC_RESP, "Forward relocation response" },
{ GTP_MSG_FORW_RELOC_COMP, "Forward relocation complete" },
{ GTP_MSG_RELOC_CANCEL_REQ, "Relocation cancel request" },
{ GTP_MSG_RELOC_CANCEL_RESP, "Relocation cancel response" },
{ GTP_MSG_FORW_SRNS_CNTXT, "Forward SRNS context" },
{ GTP_MSG_FORW_RELOC_ACK, "Forward relocation complete acknowledge" },
{ GTP_MSG_FORW_SRNS_CNTXT_ACK, "Forward SRNS context acknowledge" },
{ GTP_MSG_DATA_TRANSF_REQ, "Data record transfer request" },
{ GTP_MSG_DATA_TRANSF_RESP, "Data record transfer response" },
{ GTP_MSG_TPDU, "T-PDU" },
{ 0, NULL }
};
/* definitions of fields in extension header */
#define GTP_EXT_CAUSE 0x01
#define GTP_EXT_IMSI 0x02
#define GTP_EXT_RAI 0x03
#define GTP_EXT_TLLI 0x04
#define GTP_EXT_PTMSI 0x05
#define GTP_EXT_QOS_GPRS 0x06
#define GTP_EXT_REORDER 0x08
#define GTP_EXT_AUTH_TRI 0x09
#define GTP_EXT_MAP_CAUSE 0x0B
#define GTP_EXT_PTMSI_SIG 0x0C
#define GTP_EXT_MS_VALID 0x0D
#define GTP_EXT_RECOVER 0x0E
#define GTP_EXT_SEL_MODE 0x0F
#define GTP_EXT_16 0x10
#define GTP_EXT_FLOW_LABEL 0x10
#define GTP_EXT_TEID 0x10 /* 0xFF10 3G */
#define GTP_EXT_17 0x11
#define GTP_EXT_FLOW_SIG 0x11
#define GTP_EXT_TEID_CP 0x11 /* 0xFF11 3G */
#define GTP_EXT_18 0x12
#define GTP_EXT_FLOW_II 0x12
#define GTP_EXT_TEID_II 0x12 /* 0xFF12 3G*/
#define GTP_EXT_19 0x13
#define GTP_EXT_MS_REASON 0x13 /* same as 0x1D GTPv1_EXT_MS_REASON */
#define GTP_EXT_TEAR_IND 0x13 /* 0xFF13 3G*/
#define GTP_EXT_NSAPI 0x14 /* 3G */
#define GTP_EXT_RANAP_CAUSE 0x15 /* 3G */
#define GTP_EXT_RAB_CNTXT 0x16 /* 3G */
#define GTP_EXT_RP_SMS 0x17 /* 3G */
#define GTP_EXT_RP 0x18 /* 3G */
#define GTP_EXT_PKT_FLOW_ID 0x19 /* 3G */
#define GTP_EXT_CHRG_CHAR 0x1A /* 3G */
#define GTP_EXT_TRACE_REF 0x1B /* 3G */
#define GTP_EXT_TRACE_TYPE 0x1C /* 3G */
#define GTPv1_EXT_MS_REASON 0x1D /* 3G */
#define GTP_EXT_TR_COMM 0x7E /* charging */
#define GTP_EXT_CHRG_ID 0x7F
#define GTP_EXT_USER_ADDR 0x80
#define GTP_EXT_MM_CNTXT 0x81
#define GTP_EXT_PDP_CNTXT 0x82
#define GTP_EXT_APN 0x83
#define GTP_EXT_PROTO_CONF 0x84
#define GTP_EXT_GSN_ADDR 0x85
#define GTP_EXT_MSISDN 0x86
#define GTP_EXT_QOS_UMTS 0x87 /* 3G */
#define GTP_EXT_AUTH_QUI 0x88 /* 3G */
#define GTP_EXT_TFT 0x89 /* 3G */
#define GTP_EXT_TARGET_ID 0x8A /* 3G */
#define GTP_EXT_UTRAN_CONT 0x8B /* 3G */
#define GTP_EXT_RAB_SETUP 0x8C /* 3G */
#define GTP_EXT_HDR_LIST 0x8D /* 3G */
#define GTP_EXT_TRIGGER_ID 0x8E /* 3G */
#define GTP_EXT_OMC_ID 0x8F /* 3G */
#define GTP_EXT_C1 0xC1
#define GTP_EXT_C2 0xC2
#define GTP_EXT_REL_PACK 0xF9 /* charging */
#define GTP_EXT_CAN_PACK 0xFA /* charging */
#define GTP_EXT_CHRG_ADDR 0xFB
#define GTP_EXT_DATA_REQ 0xFC /* charging */
#define GTP_EXT_DATA_RESP 0xFD /* charging */
#define GTP_EXT_NODE_ADDR 0xFE /* charging */
#define GTP_EXT_PRIV_EXT 0xFF
static const value_string gtp_val[] = {
{ GTP_EXT_CAUSE, "Cause of operation" },
{ GTP_EXT_IMSI, "IMSI" },
{ GTP_EXT_RAI, "Routing Area Identity" },
{ GTP_EXT_TLLI, "Temporary Logical Link Identity" },
{ GTP_EXT_PTMSI, "Packet TMSI" },
{ GTP_EXT_QOS_GPRS, "Quality of Service" },
{ GTP_EXT_REORDER, "Reorder required" },
{ GTP_EXT_AUTH_TRI, "Authentication triplets" },
{ GTP_EXT_MAP_CAUSE, "MAP cause" },
{ GTP_EXT_PTMSI_SIG, "P-TMSI signature" },
{ GTP_EXT_MS_VALID, "MS validated" },
{ GTP_EXT_RECOVER, "Recovery" },
{ GTP_EXT_SEL_MODE, "Selection mode" },
{ GTP_EXT_16, "Flow label data I" },
{ GTP_EXT_FLOW_LABEL, "Flow label data I" },
{ GTP_EXT_TEID, "Tunnel Endpoint Identifier Data I" }, /* 3G */
{ GTP_EXT_17, "Flow label signalling" },
{ GTP_EXT_FLOW_SIG, "Flow label signalling" },
{ GTP_EXT_TEID_CP, "Tunnel Endpoint Identifier Data Control Plane" }, /* 3G */
{ GTP_EXT_18, "Flow label data II" },
{ GTP_EXT_FLOW_II, "Flow label data II" },
{ GTP_EXT_TEID_II, "Tunnel Endpoint Identifier Data II" }, /* 3G */
{ GTP_EXT_19, "MS not reachable reason" },
{ GTP_EXT_MS_REASON, "MS not reachable reason" },
{ GTP_EXT_TEAR_IND, "Teardown ID" }, /* 3G */
{ GTP_EXT_NSAPI, "NSAPI" }, /* 3G */
{ GTP_EXT_RANAP_CAUSE, "RANAP cause" }, /* 3G */
{ GTP_EXT_RAB_CNTXT, "RAB context" }, /* 3G */
{ GTP_EXT_RP_SMS, "Radio Priority for MO SMS" }, /* 3G */
{ GTP_EXT_RP, "Radio Priority" }, /* 3G */
{ GTP_EXT_PKT_FLOW_ID, "Packet Flow ID" }, /* 3G */
{ GTP_EXT_CHRG_CHAR, "Charging characteristics" }, /* 3G */
{ GTP_EXT_TRACE_REF, "Trace references" }, /* 3G */
{ GTP_EXT_TRACE_TYPE, "Trace type" }, /* 3G */
{ GTPv1_EXT_MS_REASON, "MS not reachable reason" }, /* 3G */
{ GTP_EXT_TR_COMM, "Packet transfer command" }, /* charging */
{ GTP_EXT_CHRG_ID, "Charging ID" },
{ GTP_EXT_USER_ADDR, "End user address" },
{ GTP_EXT_MM_CNTXT, "MM context" },
{ GTP_EXT_PDP_CNTXT, "PDP context" },
{ GTP_EXT_APN, "Access Point Name" },
{ GTP_EXT_PROTO_CONF, "Protocol configuration options" },
{ GTP_EXT_GSN_ADDR, "GSN address" },
{ GTP_EXT_MSISDN, "MS international PSTN/ISDN number" },
{ GTP_EXT_QOS_UMTS, "Quality of service (UMTS)" }, /* 3G */
{ GTP_EXT_AUTH_QUI, "Authentication quintuplets" }, /* 3G */
{ GTP_EXT_TFT, "Traffic Flow Template (TFT)" }, /* 3G */
{ GTP_EXT_TARGET_ID, "Target (RNC) identification" }, /* 3G */
{ GTP_EXT_UTRAN_CONT, "UTRAN transparent field" }, /* 3G */
{ GTP_EXT_RAB_SETUP, "RAB setup information" }, /* 3G */
{ GTP_EXT_HDR_LIST, "Extension Header Types List" }, /* 3G */
{ GTP_EXT_TRIGGER_ID, "Trigger Id" }, /* 3G */
{ GTP_EXT_OMC_ID, "OMC Identity" }, /* 3G */
{ GTP_EXT_REL_PACK, "Sequence numbers of released packets IE" }, /* charging */
{ GTP_EXT_CAN_PACK, "Sequence numbers of canceled packets IE" }, /* charging */
{ GTP_EXT_CHRG_ADDR, "Charging Gateway address" },
{ GTP_EXT_DATA_REQ, "Data record packet" }, /* charging */
{ GTP_EXT_DATA_RESP, "Requests responded" }, /* charging */
{ GTP_EXT_NODE_ADDR, "Address of recommended node" }, /* charging */
{ GTP_EXT_PRIV_EXT, "Private Extension" },
{ 0, NULL }
};
/* GPRS: 9.60 v7.6.0, page 37
* UMTS: 29.060 v4.0, page 45
*/
static const value_string cause_type[] = {
{ 0, "Request IMSI" },
{ 1, "Request IMEI" },
{ 2, "Request IMSI and IMEI" },
{ 3, "No identity needed" },
{ 4, "MS refuses" },
{ 5, "MS is not GPRS responding" },
{ 59, "System failure" }, /* charging */
{ 60, "The transmit buffers are becoming full" }, /* charging */
{ 61, "The receive buffers are becoming full" }, /* charging */
{ 62, "Another node is about to go down" }, /* charging */
{ 63, "This node is about to go down" }, /* charging */
{ 128, "Request accepted" },
{ 192, "Non-existent" },
{ 193, "Invalid message format" },
{ 194, "IMSI not known" },
{ 195, "MS is GPRS detached" },
{ 196, "MS is not GPRS responding" },
{ 197, "MS refuses" },
{ 198, "Version not supported" },
{ 199, "No resource available" },
{ 200, "Service not supported" },
{ 201, "Mandatory IE incorrect" },
{ 202, "Mandatory IE missing" },
{ 203, "Optional IE incorrect" },
{ 204, "System failure" },
{ 205, "Roaming restriction" },
{ 206, "P-TMSI signature mismatch" },
{ 207, "GPRS connection suspended" },
{ 208, "Authentication failure" },
{ 209, "User authentication failed" },
{ 210, "Context not found" },
{ 211, "All PDP dynamic addresses are occupied" },
{ 212, "No memory is available" },
{ 213, "Relocation failure" },
{ 214, "Unknown mandatory extension header" },
{ 215, "Semantic error in the TFT operation" },
{ 216, "Syntactic error in the TFT operation" },
{ 217, "Semantic errors in packet filter(s)" },
{ 218, "Syntactic errors in packet filter(s)" },
{ 219, "Missing or unknown APN" },
{ 220, "Unknown PDP address or PDP type" },
{ 252, "Request related to possibly duplicated packets already fulfilled" }, /* charging */
{ 253, "Request already fulfilled" }, /* charging */
{ 254, "Sequence numbers of released/cancelled packets IE incorrect" }, /* charging */
{ 255, "Request not fulfilled" }, /* charging */
{ 0, NULL }
};
/* GPRS: 9.02 v7.7.0
* UMTS: 29.002 v4.2.1, chapter 17.5, page 268
* TODO: Check if all map_cause values are included
*/
static const value_string map_cause_type[] = {
{ 1, "Unknown subscriber" },
{ 8, "Roaming not allowed" },
{ 10, "Bearer service not provisioned" },
{ 11, "Teleservice not provisioned" },
{ 13, "Call barred" },
{ 21, "Facility not supported" },
{ 23, "Update GPRS location" },
{ 24, "Send routing info for GPRS" },
{ 26, "Note MS present for GPRS" },
{ 27, "Absent subscriber" },
{ 34, "System failure" },
{ 35, "Data missing" },
{ 36, "Unexpected data value" },
{ 44, "Number chenged" },
{ 45, "Busy subscriber" },
{ 46, "No subscriber reply" },
{ 48, "Facility not allowed" },
{ 0, NULL }
};
static const value_string gsn_addr_type[] = {
{ 0x00, "IPv4" },
{ 0x01, "IPv6" },
{ 0, NULL },
};
static const value_string pdp_type[] = {
{ 0x00, "X.25" },
{ 0x01, "PPP" },
{ 0x02, "OSP:IHOSS" },
{ 0x21, "IPv4" },
{ 0x57, "IPv6" },
{ 0, NULL }
};
static const value_string pdp_org_type[] = {
{ 0, "ETSI" },
{ 1, "IETF" },
{ 0, NULL }
};
static const value_string qos_delay_type[] = {
{ 0x00, "Subsribed delay class (in MS to network direction)" },
{ 0x01, "Delay class 1" },
{ 0x02, "Delay class 2" },
{ 0x03, "Delay class 3" },
{ 0x04, "Delay class 4 (best effort)" },
{ 0x07, "Reserved" },
{ 0, NULL }
};
static const value_string qos_reliability_type[] = {
{ 0x00, "Subscribed reliability class (in MS to network direction)" },
{ 0x01, "Ack GTP/LLC/RLC, Protected data" },
{ 0x02, "Unack GTP, Ack LLC/RLC, Protected data" },
{ 0x03, "Unack GTP/LLC, Ack RLC, Protected data" },
{ 0x04, "Unack GTP/LLC/RLC, Protected data" },
{ 0x05, "Unack GTP/LLC/RLC, Unprotected data" },
{ 0x07, "Reserved" },
{ 0, NULL }
};
static const value_string qos_peak_type[] = {
{ 0x00, "Subscribed peak throughput (in MS to network direction)" },
{ 0x01, "Up to 1 000 oct/s" },
{ 0x02, "Up to 2 000 oct/s" },
{ 0x03, "Up to 4 000 oct/s" },
{ 0x04, "Up to 8 000 oct/s" },
{ 0x05, "Up to 16 000 oct/s" },
{ 0x06, "Up to 32 000 oct/s" },
{ 0x07, "Up to 64 000 oct/s" },
{ 0x08, "Up to 128 000 oct/s" },
{ 0x09, "Up to 256 000 oct/s" },
/* QoS Peak throughput classes from 0x0A to 0x0F (from 10 to 15) are subscribed */
{ 0x0A, "Reserved" },
{ 0x0B, "Reserved" },
{ 0x0C, "Reserved" },
{ 0x0D, "Reserved" },
{ 0x0E, "Reserved" },
{ 0x0F, "Reserved" },
{ 0, NULL }
};
static const value_string qos_precedence_type[] = {
{ 0x00, "Subscribed precedence (in MS to network direction)" },
{ 0x01, "High priority" },
{ 0x02, "Normal priority" },
{ 0x03, "Low priority" },
{ 0x07, "Reserved" },
{ 0, NULL }
};
static const value_string qos_mean_type[] = {
{ 0x00, "Subscribed mean throughput (in MS to network direction)" },
{ 0x01, "100 oct/h" }, /* Class 2 */
{ 0x02, "200 oct/h" }, /* Class 3 */
{ 0x03, "500 oct/h" }, /* Class 4 */
{ 0x04, "1 000 oct/h" }, /* Class 5 */
{ 0x05, "2 000 oct/h" }, /* Class 6 */
{ 0x06, "5 000 oct/h" }, /* Class 7 */
{ 0x07, "10 000 oct/h" }, /* Class 8 */
{ 0x08, "20 000 oct/h" }, /* Class 9 */
{ 0x09, "50 000 oct/h" }, /* Class 10 */
{ 0x0A, "100 000 oct/h" }, /* Class 11 */
{ 0x0B, "200 000 oct/h" }, /* Class 12 */
{ 0x0C, "500 000 oct/h" }, /* Class 13 */
{ 0x0D, "1 000 000 oct/h" }, /* Class 14 */
{ 0x0E, "2 000 000 oct/h" }, /* Class 15 */
{ 0x0F, "5 000 000 oct/h" }, /* Class 16 */
{ 0x10, "10 000 000 oct/h" }, /* Class 17 */
{ 0x11, "20 000 000 oct/h" }, /* Class 18 */
{ 0x12, "50 000 000 oct/h" }, /* Class 19 */
/* QoS Mean throughput classes from 0x13 to 0x1E (from 19 to 30) are subscribed */
{ 0x13, "Reserved" },
{ 0x14, "Reserved" },
{ 0x15, "Reserved" },
{ 0x16, "Reserved" },
{ 0x17, "Reserved" },
{ 0x18, "Reserved" },
{ 0x19, "Reserved" },
{ 0x1A, "Reserved" },
{ 0x1B, "Reserved" },
{ 0x1C, "Reserved" },
{ 0x1D, "Reserved" },
{ 0x1E, "Reserved" },
{ 0x1F, "Best effort" }, /* Class 1 */
{ 0, NULL }
};
static const value_string qos_del_err_sdu[] = {
{ 0x00, "Subscribed delivery of erroneous SDUs (in MS to network direction)" },
{ 0x01, "No detect ('-')" },
{ 0x02, "Erroneous SDUs are delivered ('yes')" },
{ 0x03, "Erroneous SDUs are not delivered ('no')" },
{ 0x07, "Reserved" }, /* All other values are reserved */
{ 0, NULL }
};
static const value_string qos_del_order[] = {
{ 0x00, "Subscribed delivery order (in MS to network direction)" },
{ 0x01, "With delivery order ('yes')" },
{ 0x02, "Without delivery order ('no')" },
{ 0x03, "Reserved" }, /* All other values are reserved */
{ 0, NULL }
};
static const value_string qos_traf_class[] = {
{ 0x00, "Subscribed traffic class (in MS to network direction)" },
{ 0x01, "Conversational class" },
{ 0x02, "Streaming class" },
{ 0x03, "Interactive class" },
{ 0x04, "Background class" },
{ 0x07, "Reserved" }, /* All other values are reserved */
{ 0, NULL }
};
static const value_string qos_max_sdu_size[] = {
{ 0x00, "Subscribed maximum SDU size (in MS to network direction" },
/* For values from 0x01 to 0x96 (from 1 to 150), use a granularity of 10 octets */
{ 0x97, "1502 octets" },
{ 0x98, "1510 octets" },
{ 0x99, "1520 octets" },
{ 0, NULL } /* All other values are reserved */
};
static const value_string qos_max_ul[] = {
{ 0x00, "Subscribed maximum bit rate for uplink (in MS to network direction)" },
/* For values from 0x01 to 0x3F (from 1 to 63), use a granularity of 1 kbps */
/* For values from 0x40 to 0x7F, value = 64 kbps + (value - 0x40) * 8 kbps */
/* For values from 0x80 to 0xFE, value = 576 kbps + (value - 0x80) * 64 kbps */
{ 0xFF, "0 kbps" },
{ 0, NULL }
};
static const value_string qos_max_dl[] = {
{ 0x00, "Subscribed maximum bit rate for downlink (in MS to network direction)" },
/* For values from 0x01 to 0x3F (from 1 to 63), use a granularity of 1 kbps */
/* For values from 0x40 to 0x7F, value = 64 kbps + (value - 0x40) * 8 kbps */
/* For values from 0x80 to 0xFE, value = 576 kbps + (value - 0x80) * 64 kbps */
{ 0xFF, "0 kbps" },
{ 0, NULL }
};
static const value_string qos_res_ber[] = {
{ 0x00, "Subscribed residual BER (in MS to network direction)" },
{ 0x01, "1/20 = 5x10^-2" },
{ 0x02, "1/100 = 1x10^-2" },
{ 0x03, "1/200 = 5x10^-3" },
{ 0x04, "1/250 = 4x10^-3" },
{ 0x05, "1/1 000 = 1x10^-3" },
{ 0x06, "1/10 000 = 1x10^-4" },
{ 0x07, "1/100 000 = 1x10^-5" },
{ 0x08, "1/1 000 000 = 1x10^-6" },
{ 0x09, "3/50 000 000 = 6x10^-8" },
{ 0x0F, "Reserved" }, /* All other values are reserved */
{ 0, NULL }
};
static const value_string qos_sdu_err_ratio[] = {
{ 0x00, "Subscribed SDU error ratio (in MS to network direction)" },
{ 0x01, "1/100 = 1x10^-2" },
{ 0x02, "7/1000 = 7x10^-3" },
{ 0x03, "1/1 000 = 1x10^-3" },
{ 0x04, "1/10 000 = 1x10^-4" },
{ 0x05, "1/100 000 = 1x10^-5" },
{ 0x06, "1/1 000 000 = 1x10^-6" },
{ 0x07, "1/10 = 1x10^-1" },
{ 0x0F, "Reserved" }, /* All other values are reserved */
{ 0, NULL }
};
static const value_string qos_traf_handl_prio[] = {
{ 0x00, "Subscribed traffic handling priority (in MS to network direction)" },
{ 0x01, "Priority level 1" },
{ 0x02, "Priority level 2" },
{ 0x03, "Priority level 3" },
{ 0, NULL }
};
static const value_string qos_trans_delay[] = {
{ 0x00, "Subscribed Transfer Delay (in MS to network direction)" },
{ 0x01, "10 ms" }, /* Using a granularity of 10 ms */
{ 0x02, "20 ms" },
{ 0x03, "30 ms" },
{ 0x04, "40 ms" },
{ 0x05, "50 ms" },
{ 0x06, "60 ms" },
{ 0x07, "70 ms" },
{ 0x08, "80 ms" },
{ 0x09, "90 ms" },
{ 0x0A, "100 ms" },
{ 0x0B, "110 ms" },
{ 0x0C, "120 ms" },
{ 0x0D, "130 ms" },
{ 0x0E, "140 ms" },
{ 0x0F, "150 ms" },
{ 0x10, "200 ms" }, /* (For values from 0x10 to 0x1F, value = 200 ms + (value - 0x10) * 50 ms */
{ 0x11, "250 ms" },
{ 0x12, "300 ms" },
{ 0x13, "350 ms" },
{ 0x14, "400 ms" },
{ 0x15, "450 ms" },
{ 0x16, "500 ms" },
{ 0x17, "550 ms" },
{ 0x18, "600 ms" },
{ 0x19, "650 ms" },
{ 0x1A, "700 ms" },
{ 0x1B, "750 ms" },
{ 0x1C, "800 ms" },
{ 0x1D, "850 ms" },
{ 0x1E, "900 ms" },
{ 0x1F, "950 ms" },
{ 0x20, "1000 ms" }, /* For values from 0x20 to 0x3E, value = 1000 ms + (value - 0x20) * 100 ms */
{ 0x21, "1100 ms" },
{ 0x22, "1200 ms" },
{ 0x23, "1300 ms" },
{ 0x24, "1400 ms" },
{ 0x25, "1500 ms" },
{ 0x26, "1600 ms" },
{ 0x27, "1700 ms" },
{ 0x28, "1800 ms" },
{ 0x29, "1900 ms" },
{ 0x2A, "2000 ms" },
{ 0x2B, "2100 ms" },
{ 0x2C, "2200 ms" },
{ 0x2D, "2300 ms" },
{ 0x2E, "2400 ms" },
{ 0x2F, "2500 ms" },
{ 0x30, "2600 ms" },
{ 0x31, "2700 ms" },
{ 0x32, "2800 ms" },
{ 0x33, "2900 ms" },
{ 0x34, "3000 ms" },
{ 0x35, "3100 ms" },
{ 0x36, "3200 ms" },
{ 0x37, "3300 ms" },
{ 0x38, "3400 ms" },
{ 0x39, "3500 ms" },
{ 0x3A, "3600 ms" },
{ 0x3B, "3700 ms" },
{ 0x3C, "3800 ms" },
{ 0x3D, "3900 ms" },
{ 0x3E, "4000 ms" },
{ 0x3F, "Reserved"},
{ 0, NULL }
};
static const value_string qos_guar_ul[] = {
{ 0x00, "Subscribed guaranteed bit rate for uplink (in MS to network direction)" },
/* For values from 0x01 to 0x3F (from 1 to 63), use a granularity of 1 kbps */
/* For values from 0x40 to 0x7F, value = 64 kbps + (value - 0x40) * 8 kbps */
/* For values from 0x80 to 0xFE, value = 576 kbps + (value - 0x80) * 64 kbps */
{ 0xFF, "0 kbps" },
{ 0, NULL }
};
static const value_string qos_guar_dl[] = {
{ 0x00, "Subscribed guaranteed bit rate for downlink (in MS to network direction)" },
/* For values from 0x01 to 0x3F (from 1 to 63), use a granularity of 1 kbps */
/* For values from 0x40 to 0x7F, value = 64 kbps + (value - 0x40) * 8 kbps */
/* For values from 0x80 to 0xFE, value = 576 kbps + (value - 0x80) * 64 kbps */
{ 0xFF, "0 kbps" },
{ 0, NULL }
};
static const value_string sel_mode_type[] = {
{ 0, "MS or network provided APN, subscribed verified" },
{ 1, "MS provided APN, subscription not verified" },
{ 2, "Network provided APN, subscription not verified" },
{ 3, "For future use (Network provided APN, subscription not verified" },/* Shall not be sent. If received, shall be sent as value 2 */
{ 0, NULL }
};
static const value_string tr_comm_type[] = {
{ 1, "Send data record packet" },
{ 2, "Send possibly duplicated data record packet" },
{ 3, "Cancel data record packet" },
{ 4, "Release data record packet"},
{ 0, NULL }
};
/* TODO: CHeck if all ms_reasons are included */
static const value_string ms_not_reachable_type[] = {
{ 0, "No paging response via the MSC" },
{ 1, "IMSI detached" },
{ 2, "Roaming restriction" },
{ 3, "Deregistered in the HLR for non GPRS" },
{ 4, "MS purge for non GPRS" },
{ 5, "No paging response via the SGSN" },
{ 6, "GPRS detached" },
{ 7, "Deregistered in the HLR for non GPRS" },
{ 8, "MS purged for GPRS" },
{ 9, "Unidentified subscriber via the MSC" },
{ 10, "Unidentified subscriber via the SGSN" },
{ 0, NULL }
};
/* UMTS: 25.413 v3.4.0, chapter 9.2.1.4, page 80
*/
static const value_string ranap_cause_type[] = {
/* Radio Network Layer Cause (1-->64) */
{ 1, "RAB preempted" },
{ 2, "Trelocoverall Expiry" },
{ 3, "Trelocprep Expiry" },
{ 4, "Treloccomplete Expiry" },
{ 5, "Tqueing Expiry" },
{ 6, "Relocation Triggered" },
{ 7, "TRELOCalloc Expiry" },
{ 8, "Unable to Estabish During Relocation" },
{ 9, "Unknown Target RNC" },
{ 10, "Relocation Cancelled" },
{ 11, "Successful Relocation" },
{ 12, "Requested Ciphering and/or Integrity Protection Algorithms not Supported" },
{ 13, "Change of Ciphering and/or Integrity Protection is not supported" },
{ 14, "Failure in the Radio Interface Procedure" },
{ 15, "Release due to UTRAN Generated Reason" },
{ 16, "User Inactivity" },
{ 17, "Time Critical Relocation" },
{ 18, "Requested Traffic Class not Available" },
{ 19, "Invalid RAB Parameters Value" },
{ 20, "Requested Maximum Bit Rate not Available" },
{ 21, "Requested Guaranteed Bit Rate not Available" },
{ 22, "Requested Transfer Delay not Achievable" },
{ 23, "Invalid RAB Parameters Combination" },
{ 24, "Condition Violation for SDU Parameters" },
{ 25, "Condition Violation for Traffic Handling Priority" },
{ 26, "Condition Violation for Guaranteed Bit Rate" },
{ 27, "User Plane Versions not Supported" },
{ 28, "Iu UP Failure" },
{ 29, "Relocation Failure in Target CN/RNC or Target System" },
{ 30, "Invalid RAB ID" },
{ 31, "No Remaining RAB" },
{ 32, "Interaction with other procedure" },
{ 33, "Requested Maximum Bit Rate for DL not Available" },
{ 34, "Requested Maximum Bit Rate for UL not Available" },
{ 35, "Requested Guaranteed Bit Rate for DL not Available" },
{ 36, "Requested Guaranteed Bit Rate for UL not Available" },
{ 37, "Repeated Integrity Checking Failure" },
{ 38, "Requested Report Type not supported" },
{ 39, "Request superseded" },
{ 40, "Release due to UE generated signalling connection release" },
{ 41, "Resource Optimisation Relocation" },
{ 42, "Requested Information Not Available" },
{ 43, "Relocation desirable for radio reasons" },
{ 44, "Relocation not supported in Target RNC or Target System" },
{ 45, "Directed Retry" },
{ 46, "Radio Connection With UE Lost" },
/* Transport Layer Cause (65-->80) */
{ 65, "Signalling Transport Resource Failure" },
{ 66, "Iu Transport Connection Failed to Establish" },
/* NAS Cause (81-->96) */
{ 81, "User Restriction Start Indication" },
{ 82, "User Restriction End Indication" },
{ 83, "Normal Release" },
/* Protocol Cause (97-->112) */
{ 97, "Transfer Syntax Error" },
{ 98, "Semantic Error" },
{ 99, "Message not compatible with receiver state" },
{ 100, "Abstract Syntax Error (Reject)" },
{ 101, "Abstract Syntax Error (Ignore and Notify)" },
{ 102, "Abstract Syntax Error (Falsely Constructed Message" },
/* Miscellaneous Cause (113-->128) */
{ 113, "O & M Intervention" },
{ 114, "No Resource Available" },
{ 115, "Unspecified Failure" },
{ 116, "Network Opimisation" },
/* Non-standard Cause (129-->255) */
{ 0, NULL }
};
static const value_string mm_sec_modep[] = {
{ 0, "Used cipher value, UMTS keys and Quintuplets" },
{ 1, "GSM key and triplets" },
{ 2, "UMTS key and quintuplets" },
{ 3, "GSM key and quintuplets" },
{ 0, NULL }
};
#define MM_PROTO_GROUP_CALL_CONTROL 0x00
#define MM_PROTO_BROADCAST_CALL_CONTROL 0x01
#define MM_PROTO_PDSS1 0x02
#define MM_PROTO_CALL_CONTROL 0x03
#define MM_PROTO_PDSS2 0x04
#define MM_PROTO_MM_NON_GPRS 0x05
#define MM_PROTO_RR_MGMT 0x06
#define MM_PROTO_MM_GPRS 0x08
#define MM_PROTO_SMS 0x09
#define MM_PROTO_SESSION_MGMT 0x0A
#define MM_PROTO_NON_CALL_RELATED 0x0B
static const value_string mm_proto_disc[] = {
{ MM_PROTO_GROUP_CALL_CONTROL, "Group call control" },
{ MM_PROTO_BROADCAST_CALL_CONTROL, "Broadcast call control" },
{ MM_PROTO_PDSS1, "PDSS1" },
{ MM_PROTO_CALL_CONTROL, "Call control; call related SS messages" },
{ MM_PROTO_PDSS2, "PDSS2" },
{ MM_PROTO_MM_NON_GPRS, "Mobility Management messages for non-GPRS services" },
{ MM_PROTO_RR_MGMT, "Radio Resource management messages" },
{ MM_PROTO_MM_GPRS, "Mobility Management messages for GPRS services" },
{ MM_PROTO_SMS, "SMS" },
{ MM_PROTO_SESSION_MGMT, "Session Management messages" },
{ MM_PROTO_NON_CALL_RELATED, "Non-call related SS messages" },
{ 0, NULL }
};
static const value_string mm_rr_mess[] = {
{ 0x3C, "RR initialization request" },
{ 0x3B, "Additional assignment" },
{ 0x3F, "Immediate assignment" },
{ 0x39, "Immediate assignment extended" },
{ 0x3A, "Immediate assignment reject" },
{ 0x35, "Ciphering mode command" },
{ 0x32, "Ciphering mode complete" },
{ 0x30, "Configuration change command" },
{ 0x31, "Configuration change ack" },
{ 0x33, "Configuration change reject" },
{ 0x2E, "Assignment command" },
{ 0x29, "Assignment complete" },
{ 0x2F, "Assigment failure" },
{ 0x2B, "Handover command" },
{ 0x2C, "Handover complete" },
{ 0x28, "Handover failure" },
{ 0x2D, "Physical information" },
{ 0x08, "RR-cell change order" },
{ 0x23, "PDCH assignment command" },
{ 0x0D, "Channel release" },
{ 0x0A, "Partial release" },
{ 0x0F, "PArtial release complete" },
{ 0x21, "Paging request type 1" },
{ 0x22, "Paging request type 2" },
{ 0x24, "Paging request type 3" },
{ 0x27, "Paging response" },
{ 0x20, "Notification/NCH" },
{ 0x25, "Notification/FACCH" },
{ 0x26, "Reserved" },
{ 0x0B, "Reserved" },
{ 0x18, "System information type 8" },
{ 0x19, "System information type 1" },
{ 0x1A, "System information type 2" },
{ 0x1B, "System information type 3" },
{ 0x1C, "System information type 4" },
{ 0x1D, "System information type 5" },
{ 0x1E, "System information type 6" },
{ 0x1F, "System information type 7" },
{ 0x02, "System information type 2bis" },
{ 0x03, "System information type 2ter" },
{ 0x05, "System information type 5bis" },
{ 0x06, "System information type 5ter" },
{ 0x04, "System information 9" },
{ 0x00, "System information 13" },
{ 0x01, "System information 14" },
{ 0x3D, "System information type 16" },
{ 0x3E, "System information type 17" },
{ 0x10, "Channel mode modify" },
{ 0x12, "RR status" },
{ 0x17, "Channel mode modify ack" },
{ 0x14, "Frequency redefinition" },
{ 0x15, "Measurement report" },
{ 0x16, "Classmark change" },
{ 0x13, "Classmark enquiry" },
{ 0x36, "Extended measurement report" },
{ 0x37, "Extended measurement order" },
{ 0x34, "GPRS suspension request" },
{ 0x09, "VGCS uplink grant" },
{ 0x0E, "Uplink release" },
{ 0x0C, "Uplink free" },
{ 0x2A, "Uplink busy" },
{ 0x11, "Talker indication" },
{ 0, NULL }
};
static const value_string mm_mm_mess[] = {
{ 0x01, "IMSI DETACH INDICATION" },
{ 0x02, "LOCATION UPDATING ACCEPT" },
{ 0x04, "LOCATION UPDATING REJECT" },
{ 0x08, "LOCATION UPDATING REQUEST" },
{ 0x11, "AUTHENTICATION REJECT" },
{ 0x12, "AUTHENTICATION REQUEST" },
{ 0x14, "AUTHENTICATION RESPONSE" },
{ 0x18, "IDENTITY REQUEST" },
{ 0x19, "IDENTITY RESPONSE" },
{ 0x1A, "TMSI REALLOCATION COMMAND" },
{ 0x1B, "TMSI REALLOCATION COMPLETE" },
{ 0x21, "CM SERVICE ACCEPT" },
{ 0x22, "CM SERVICE REJECT" },
{ 0x23, "CM SERVICE ABORT" },
{ 0x24, "CM SERVICE REQUEST" },
{ 0x25, "CM SERVICE PROMPT" },
{ 0x26, "NOTIFICATION RESPONSE" },
{ 0x28, "CM RE-ESTABLISHMENT REQUEST" },
{ 0x29, "ABORT" },
{ 0x30, "MM NULL" },
{ 0x31, "MM STATUS" },
{ 0x32, "MM INFORMATION" },
{ 0, NULL }
};
static const value_string mm_cc_mess[] = {
{ 0x00, "escape to nationally specific" },
/*{ 0 x 0 0, "- - - Call establishment messages:" },*/
{ 0x01, "ALERTING" },
{ 0x08, "CALL CONFIRMED" },
{ 0x02, "CALL PROCEEDING" },
{ 0x07, "CONNECT" },
{ 0x0F, "CONNECT ACKNOWLEDGE" },
{ 0x0E, "EMERGENCY SETUP" },
{ 0x03, "PROGRESS" },
{ 0x04, "CC-ESTABLISHMENT" },
{ 0x06, "CC-ESTABLISHMENT CONFIRMED" },
{ 0x0B, "RECALL" },
{ 0x09, "START CC" },
{ 0x05, "SETUP" },
/*{ 0 x 0 1, "- - - Call information phase messages:" },*/
{ 0x17, "MODIFY" },
{ 0x1F, "MODIFY COMPLETE" },
{ 0x13, "MODIFY REJECT" },
{ 0x10, "USER INFORMATION" },
{ 0x18, "HOLD" },
{ 0x19, "HOLD ACKNOWLEDGE" },
{ 0x1A, "HOLD REJECT" },
{ 0x1C, "RETRIEVE" },
{ 0x1D, "RETRIEVE ACKNOWLEDGE" },
{ 0x1E, "RETRIEVE REJECT" },
/*{ 0 x 1 0, "- - - Call clearing messages:" },*/
{ 0x25, "DISCONNECT" },
{ 0x2D, "RELEASE" },
{ 0x2A, "RELEASE COMPLETE" },
/*{ 0 x 1 1, "- - - Miscellaneous messages:" },*/
{ 0x39, "CONGESTION CONTROL" },
{ 0x3E, "NOTIFY" },
{ 0x3D, "STATUS" },
{ 0x34, "STATUS ENQUIRY" },
{ 0x35, "START DTMF" },
{ 0x31, "STOP DTMF" },
{ 0x32, "STOP DTMF ACKNOWLEDGE" },
{ 0x36, "START DTMF ACKNOWLEDGE" },
{ 0x37, "START DTMF REJECT" },
{ 0x3A, "FACILITY" },
{ 0, NULL }
};
static const value_string mm_gprs_mess[] = {
{ 0x01, "Attach request" },
{ 0x02, "Attach accept" },
{ 0x03, "Attach complete" },
{ 0x04, "Attach reject" },
{ 0x05, "Detach request" },
{ 0x06, "Detach accept" },
{ 0x08, "Routing area update request" },
{ 0x09, "Routing area update accept" },
{ 0x0A, "Routing area update complete" },
{ 0x0B, "Routing area update reject" },
{ 0x10, "P-TMSI reallocation command" },
{ 0x11, "P-TMSI reallocation complete" },
{ 0x12, "Authentication and ciphering req" },
{ 0x13, "Authentication and ciphering resp" },
{ 0x14, "Authentication and ciphering rej" },
{ 0x15, "Identity request" },
{ 0x16, "Identity response" },
{ 0x20, "GMM status" },
{ 0x21, "GMM information" },
{ 0, NULL }
};
static const value_string tft_code_type[] = {
{ 0, "Spare" },
{ 1, "Create new TFT" },
{ 2, "Delete existing TFT" },
{ 3, "Add packet filters to existing TFT" },
{ 4, "Replace packet filters in existing TFT" },
{ 5, "Delete packet filters from existing TFT" },
{ 6, "Reserved" },
{ 7, "Reserved" },
{ 0, NULL }
};
static dissector_handle_t ip_handle;
static dissector_handle_t ipv6_handle;
static dissector_handle_t ppp_handle;
static dissector_handle_t data_handle;
static dissector_handle_t gtpcdr_handle;
static int decode_gtp_cause (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_imsi (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_rai (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_tlli (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_ptmsi (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_qos_gprs (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_reorder (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_auth_tri (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_map_cause (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_ptmsi_sig (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_ms_valid (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_recovery (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_sel_mode (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_16 (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_17 (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_18 (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_19 (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_nsapi (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_ranap_cause (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_rab_cntxt (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_rp_sms (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_rp (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_pkt_flow_id (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_chrg_char (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_trace_ref (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_trace_type (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_ms_reason (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_tr_comm (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_chrg_id (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_user_addr (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_mm_cntxt (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_pdp_cntxt (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_apn (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_gsn_addr (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_proto_conf (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_msisdn (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_qos_umts (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_auth_qui (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_tft (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_target_id (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_utran_cont (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_rab_setup (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_hdr_list (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_trigger_id (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_omc_id (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_chrg_addr (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_rel_pack (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_can_pack (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_data_req (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_data_resp (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_node_addr (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_priv_ext (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
static int decode_gtp_unknown (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
typedef struct _gtp_opt {
int optcode;
int (*decode)(tvbuff_t *, int, packet_info *, proto_tree *);
} gtp_opt_t;
static const gtp_opt_t gtpopt[] = {
{ GTP_EXT_CAUSE, decode_gtp_cause },
{ GTP_EXT_IMSI, decode_gtp_imsi },
{ GTP_EXT_RAI, decode_gtp_rai },
{ GTP_EXT_TLLI, decode_gtp_tlli },
{ GTP_EXT_PTMSI, decode_gtp_ptmsi },
{ GTP_EXT_QOS_GPRS, decode_gtp_qos_gprs },
{ GTP_EXT_REORDER, decode_gtp_reorder },
{ GTP_EXT_AUTH_TRI, decode_gtp_auth_tri },
{ GTP_EXT_MAP_CAUSE, decode_gtp_map_cause },
{ GTP_EXT_PTMSI_SIG, decode_gtp_ptmsi_sig },
{ GTP_EXT_MS_VALID, decode_gtp_ms_valid },
{ GTP_EXT_RECOVER, decode_gtp_recovery },
{ GTP_EXT_SEL_MODE, decode_gtp_sel_mode },
{ GTP_EXT_16, decode_gtp_16 },
{ GTP_EXT_17, decode_gtp_17 },
{ GTP_EXT_18, decode_gtp_18 },
{ GTP_EXT_19, decode_gtp_19 },
{ GTP_EXT_NSAPI, decode_gtp_nsapi },
{ GTP_EXT_RANAP_CAUSE, decode_gtp_ranap_cause },
{ GTP_EXT_RAB_CNTXT, decode_gtp_rab_cntxt },
{ GTP_EXT_RP_SMS, decode_gtp_rp_sms },
{ GTP_EXT_RP, decode_gtp_rp },
{ GTP_EXT_PKT_FLOW_ID, decode_gtp_pkt_flow_id },
{ GTP_EXT_CHRG_CHAR, decode_gtp_chrg_char },
{ GTP_EXT_TRACE_REF, decode_gtp_trace_ref },
{ GTP_EXT_TRACE_TYPE, decode_gtp_trace_type },
{ GTPv1_EXT_MS_REASON, decode_gtp_ms_reason },
{ GTP_EXT_TR_COMM, decode_gtp_tr_comm },
{ GTP_EXT_CHRG_ID, decode_gtp_chrg_id },
{ GTP_EXT_USER_ADDR, decode_gtp_user_addr },
{ GTP_EXT_MM_CNTXT, decode_gtp_mm_cntxt },
{ GTP_EXT_PDP_CNTXT, decode_gtp_pdp_cntxt },
{ GTP_EXT_APN, decode_gtp_apn },
{ GTP_EXT_PROTO_CONF, decode_gtp_proto_conf },
{ GTP_EXT_GSN_ADDR, decode_gtp_gsn_addr },
{ GTP_EXT_MSISDN, decode_gtp_msisdn },
{ GTP_EXT_QOS_UMTS, decode_gtp_qos_umts }, /* 3G */
{ GTP_EXT_AUTH_QUI, decode_gtp_auth_qui }, /* 3G */
{ GTP_EXT_TFT, decode_gtp_tft }, /* 3G */
{ GTP_EXT_TARGET_ID, decode_gtp_target_id }, /* 3G */
{ GTP_EXT_UTRAN_CONT, decode_gtp_utran_cont }, /* 3G */
{ GTP_EXT_RAB_SETUP, decode_gtp_rab_setup }, /* 3G */
{ GTP_EXT_HDR_LIST, decode_gtp_hdr_list }, /* 3G */
{ GTP_EXT_TRIGGER_ID, decode_gtp_trigger_id }, /* 3G */
{ GTP_EXT_OMC_ID, decode_gtp_omc_id }, /* 3G */
{ GTP_EXT_REL_PACK, decode_gtp_rel_pack }, /* charging */
{ GTP_EXT_CAN_PACK, decode_gtp_can_pack }, /* charging */
{ GTP_EXT_CHRG_ADDR, decode_gtp_chrg_addr },
{ GTP_EXT_DATA_REQ, decode_gtp_data_req }, /* charging */
{ GTP_EXT_DATA_RESP, decode_gtp_data_resp }, /* charging */
{ GTP_EXT_NODE_ADDR, decode_gtp_node_addr },
{ GTP_EXT_PRIV_EXT, decode_gtp_priv_ext },
{ 0, decode_gtp_unknown }
};
struct _gtp_hdr {
guint8 flags;
guint8 message;
guint16 length;
};
static guint8 gtp_version = 0;
static char *yesno[] = { "no", "yes" };
static void
col_append_str_gtp(column_info *cinfo, gint el, gchar *proto_name) {
int i;
int max_len;
gchar _tmp[COL_MAX_LEN];
max_len = COL_MAX_LEN;
for (i = 0; i < cinfo->num_cols; i++) {
if (cinfo->fmt_matx[i][el]) {
if (cinfo->col_data[i] != cinfo->col_buf[i]) {
strncpy(cinfo->col_buf[i], cinfo->col_data[i], max_len);
cinfo->col_buf[i][max_len - 1] = '\0';
}
_tmp[0] = '\0';
strcat(_tmp, proto_name);
strcat(_tmp, " <");
strcat(_tmp, cinfo->col_buf[i]);
strcat(_tmp, ">");
cinfo->col_buf[i][0] = '\0';
strcat(cinfo->col_buf[i], _tmp);
cinfo->col_data[i] = cinfo->col_buf[i];
}
}
}
static gchar *
id_to_str(const guint8 *ad) {
static gchar str[17] = " ";
guint8 bits8to5, bits4to1;
int i, j = 0;
static const gchar hex_digits[10] = "0123456789";
for (i = 0; i < 8; i++) {
bits8to5 = (ad[i] >> 4) & 0x0F;
bits4to1 = ad[i] & 0x0F;
if (bits8to5 < 0xA)
str[j++] = hex_digits[bits4to1];
if (bits4to1 < 0xA)
str[j++] = hex_digits[bits8to5];
}
str[j] = '\0';
return str;
}
static gchar *
imsi_to_str(const guint8 *ad) {
static gchar str[17] = " ";
int i, j = 0;
for (i = 0; i < 8; i++) {
if ((ad[i] & 0x0F) <= 9) str[j++] = (ad[i] & 0x0F) + 0x30;
if (((ad[i] >> 4) & 0x0F) <= 9) str[j++] = ((ad[i] >> 4) & 0x0F) + 0x30;
}
str[j] = '\0';
return str;
}
static gchar *
msisdn_to_str(const guint8 *ad, int len) {
static gchar str[18] = "+ ";
guint8 bits8to5, bits4to1;
int i, j = 1;
static const gchar hex_digits[10] = "0123456789";
for (i = 1; i < len && i < 9; i++) {
bits8to5 = (ad[i] >> 4) & 0x0F;
bits4to1 = ad[i] & 0x0F;
if (bits4to1 < 0xA)
str[j++] = hex_digits[bits4to1];
if (bits8to5 < 0xA)
str[j++] = hex_digits[bits8to5];
}
str[j] = '\0';
return str;
}
/* Next definitions and function check_field_presence checks if given field
* in GTP packet is compliant with ETSI
*/
typedef struct _header {
guint8 code;
guint8 presence;
} ext_header;
typedef struct _message {
guint8 code;
ext_header fields[32];
} _gtp_mess_items;
/* ---------------------
* GPRS messages
* ---------------------*/
static _gtp_mess_items gprs_mess_items[] = {
{
GTP_MSG_ECHO_REQ, {
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_ECHO_RESP, {
{ GTP_EXT_RECOVER, GTP_MANDATORY },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_VER_NOT_SUPP, {
{ 0, 0 }
}
},
{
GTP_MSG_NODE_ALIVE_REQ, {
{ GTP_EXT_NODE_ADDR, GTP_MANDATORY },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_NODE_ALIVE_RESP, {
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_REDIR_REQ, {
{ GTP_EXT_CAUSE, GTP_MANDATORY },
{ GTP_EXT_NODE_ADDR, GTP_OPTIONAL },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_REDIR_RESP, {
{ GTP_EXT_CAUSE, GTP_MANDATORY },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_CREATE_PDP_REQ, {
{ GTP_EXT_QOS_GPRS, GTP_MANDATORY },
{ GTP_EXT_RECOVER, GTP_OPTIONAL },
{ GTP_EXT_SEL_MODE, GTP_MANDATORY },
{ GTP_EXT_FLOW_LABEL, GTP_MANDATORY },
{ GTP_EXT_FLOW_SIG, GTP_MANDATORY },
{ GTP_EXT_MSISDN, GTP_MANDATORY },
{ GTP_EXT_USER_ADDR, GTP_MANDATORY },
{ GTP_EXT_APN, GTP_MANDATORY },
{ GTP_EXT_PROTO_CONF, GTP_OPTIONAL },
{ GTP_EXT_GSN_ADDR, GTP_MANDATORY },
{ GTP_EXT_GSN_ADDR, GTP_MANDATORY },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_CREATE_PDP_RESP, {
{ GTP_EXT_CAUSE, GTP_MANDATORY },
{ GTP_EXT_QOS_GPRS, GTP_CONDITIONAL },
{ GTP_EXT_REORDER, GTP_CONDITIONAL },
{ GTP_EXT_RECOVER, GTP_OPTIONAL },
{ GTP_EXT_FLOW_LABEL, GTP_CONDITIONAL },
{ GTP_EXT_FLOW_SIG, GTP_CONDITIONAL },
{ GTP_EXT_CHRG_ID, GTP_CONDITIONAL },
{ GTP_EXT_USER_ADDR, GTP_CONDITIONAL },
{ GTP_EXT_PROTO_CONF, GTP_OPTIONAL },
{ GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
{ GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
{ GTP_EXT_CHRG_ADDR, GTP_OPTIONAL },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_UPDATE_PDP_REQ, {
{ GTP_EXT_QOS_GPRS, GTP_MANDATORY },
{ GTP_EXT_RECOVER, GTP_OPTIONAL },
{ GTP_EXT_FLOW_LABEL, GTP_MANDATORY },
{ GTP_EXT_FLOW_SIG, GTP_MANDATORY },
{ GTP_EXT_GSN_ADDR, GTP_MANDATORY },
{ GTP_EXT_GSN_ADDR, GTP_MANDATORY },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 },
}
},
{
GTP_MSG_UPDATE_PDP_RESP, {
{ GTP_EXT_CAUSE, GTP_MANDATORY },
{ GTP_EXT_QOS_GPRS, GTP_CONDITIONAL },
{ GTP_EXT_RECOVER, GTP_OPTIONAL },
{ GTP_EXT_FLOW_LABEL, GTP_CONDITIONAL },
{ GTP_EXT_FLOW_SIG, GTP_CONDITIONAL },
{ GTP_EXT_CHRG_ID, GTP_CONDITIONAL },
{ GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
{ GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
{ GTP_EXT_CHRG_ADDR, GTP_OPTIONAL },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_DELETE_PDP_REQ, {
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_DELETE_PDP_RESP, {
{ GTP_EXT_CAUSE, GTP_MANDATORY },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 },
}
},
{
GTP_MSG_CREATE_AA_PDP_REQ, {
{ GTP_EXT_QOS_GPRS, GTP_MANDATORY },
{ GTP_EXT_RECOVER, GTP_OPTIONAL },
{ GTP_EXT_SEL_MODE, GTP_MANDATORY },
{ GTP_EXT_FLOW_LABEL, GTP_MANDATORY },
{ GTP_EXT_FLOW_SIG, GTP_MANDATORY },
{ GTP_EXT_USER_ADDR, GTP_MANDATORY },
{ GTP_EXT_APN, GTP_MANDATORY },
{ GTP_EXT_PROTO_CONF, GTP_OPTIONAL },
{ GTP_EXT_GSN_ADDR, GTP_MANDATORY },
{ GTP_EXT_GSN_ADDR, GTP_MANDATORY },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_CREATE_AA_PDP_RESP, {
{ GTP_EXT_CAUSE, GTP_MANDATORY },
{ GTP_EXT_QOS_GPRS, GTP_CONDITIONAL },
{ GTP_EXT_REORDER, GTP_CONDITIONAL },
{ GTP_EXT_RECOVER, GTP_OPTIONAL },
{ GTP_EXT_FLOW_LABEL, GTP_CONDITIONAL },
{ GTP_EXT_FLOW_SIG, GTP_CONDITIONAL },
{ GTP_EXT_CHRG_ID, GTP_CONDITIONAL },
{ GTP_EXT_USER_ADDR, GTP_CONDITIONAL },
{ GTP_EXT_PROTO_CONF, GTP_OPTIONAL },
{ GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
{ GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
{ GTP_EXT_CHRG_ADDR, GTP_OPTIONAL },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_DELETE_AA_PDP_REQ, {
{ GTP_EXT_CAUSE, GTP_MANDATORY },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_DELETE_AA_PDP_RESP, {
{ GTP_EXT_CAUSE, GTP_MANDATORY },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_ERR_IND, {
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_PDU_NOTIFY_REQ, {
{ GTP_EXT_USER_ADDR, GTP_MANDATORY },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_PDU_NOTIFY_RESP, {
{ GTP_EXT_CAUSE, GTP_MANDATORY },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_PDU_NOTIFY_REJ_REQ, {
{ GTP_EXT_CAUSE, GTP_MANDATORY },
{ GTP_EXT_USER_ADDR, GTP_MANDATORY },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_PDU_NOTIFY_REJ_RESP, {
{ GTP_EXT_CAUSE, GTP_MANDATORY },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_SEND_ROUT_INFO_REQ, {
{ GTP_EXT_IMSI, GTP_MANDATORY },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_SEND_ROUT_INFO_RESP, {
{ GTP_EXT_CAUSE, GTP_MANDATORY },
{ GTP_EXT_IMSI, GTP_MANDATORY },
{ GTP_EXT_MAP_CAUSE, GTP_OPTIONAL },
{ GTP_EXT_MS_REASON, GTP_OPTIONAL },
{ GTP_EXT_GSN_ADDR, GTP_OPTIONAL },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_FAIL_REP_REQ, {
{ GTP_EXT_IMSI, GTP_MANDATORY },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_FAIL_REP_RESP, {
{ GTP_EXT_CAUSE, GTP_MANDATORY },
{ GTP_EXT_MAP_CAUSE, GTP_OPTIONAL },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_MS_PRESENT_REQ, {
{ GTP_EXT_IMSI, GTP_MANDATORY },
{ GTP_EXT_GSN_ADDR, GTP_MANDATORY },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_MS_PRESENT_RESP, {
{ GTP_EXT_CAUSE, GTP_MANDATORY },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_IDENT_REQ, {
{ GTP_EXT_RAI, GTP_MANDATORY },
{ GTP_EXT_PTMSI, GTP_MANDATORY },
{ GTP_EXT_PTMSI_SIG, GTP_OPTIONAL },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_IDENT_RESP, {
{ GTP_EXT_CAUSE, GTP_MANDATORY },
{ GTP_EXT_IMSI, GTP_CONDITIONAL },
{ GTP_EXT_AUTH_TRI, GTP_OPTIONAL },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_SGSN_CNTXT_REQ, {
{ GTP_EXT_IMSI, GTP_CONDITIONAL },
{ GTP_EXT_RAI, GTP_MANDATORY },
{ GTP_EXT_TLLI, GTP_MANDATORY },
{ GTP_EXT_PTMSI_SIG, GTP_OPTIONAL },
{ GTP_EXT_MS_VALID, GTP_OPTIONAL },
{ GTP_EXT_FLOW_SIG, GTP_MANDATORY },
{ 0, 0 }
}
},
{
GTP_MSG_SGSN_CNTXT_RESP, {
{ GTP_EXT_CAUSE, GTP_MANDATORY },
{ GTP_EXT_IMSI, GTP_CONDITIONAL },
{ GTP_EXT_FLOW_SIG, GTP_CONDITIONAL },
{ GTP_EXT_MM_CNTXT, GTP_CONDITIONAL },
{ GTP_EXT_PDP_CNTXT, GTP_CONDITIONAL },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_SGSN_CNTXT_ACK, {
{ GTP_EXT_CAUSE, GTP_MANDATORY },
{ GTP_EXT_FLOW_II, GTP_CONDITIONAL },
{ GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_DATA_TRANSF_REQ, {
{ GTP_EXT_TR_COMM, GTP_MANDATORY },
{ GTP_EXT_DATA_REQ, GTP_CONDITIONAL },
{ GTP_EXT_REL_PACK, GTP_CONDITIONAL },
{ GTP_EXT_CAN_PACK, GTP_CONDITIONAL },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_DATA_TRANSF_RESP, {
{ GTP_EXT_CAUSE, GTP_MANDATORY },
{ GTP_EXT_DATA_RESP, GTP_MANDATORY },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
0, {
{ 0, 0 }
}
}
};
/* -----------------------------
* UMTS messages
* -----------------------------*/
static _gtp_mess_items umts_mess_items[] = {
{
GTP_MSG_ECHO_REQ, {
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_ECHO_RESP, {
{ GTP_EXT_RECOVER, GTP_MANDATORY },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_VER_NOT_SUPP, {
{ 0, 0 }
}
},
{
GTP_MSG_NODE_ALIVE_REQ, {
{ GTP_EXT_NODE_ADDR, GTP_MANDATORY },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_NODE_ALIVE_RESP, {
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_REDIR_REQ, {
{ GTP_EXT_CAUSE, GTP_MANDATORY },
{ GTP_EXT_NODE_ADDR, GTP_OPTIONAL },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_REDIR_REQ, {
{ 0, 0 }
}
},
{
GTP_MSG_CREATE_PDP_REQ, {
{ GTP_EXT_IMSI, GTP_CONDITIONAL },
{ GTP_EXT_RECOVER, GTP_OPTIONAL },
{ GTP_EXT_SEL_MODE, GTP_CONDITIONAL },
{ GTP_EXT_TEID, GTP_MANDATORY },
{ GTP_EXT_TEID_CP, GTP_CONDITIONAL },
{ GTP_EXT_NSAPI, GTP_MANDATORY },
{ GTP_EXT_NSAPI, GTP_CONDITIONAL },
{ GTP_EXT_CHRG_CHAR, GTP_OPTIONAL },
{ GTP_EXT_TRACE_REF, GTP_OPTIONAL },
{ GTP_EXT_TRACE_TYPE, GTP_OPTIONAL },
{ GTP_EXT_USER_ADDR, GTP_CONDITIONAL },
{ GTP_EXT_APN, GTP_CONDITIONAL },
{ GTP_EXT_PROTO_CONF, GTP_CONDITIONAL },
{ GTP_EXT_GSN_ADDR, GTP_MANDATORY },
{ GTP_EXT_GSN_ADDR, GTP_MANDATORY },
{ GTP_EXT_MSISDN, GTP_CONDITIONAL },
{ GTP_EXT_QOS_UMTS, GTP_MANDATORY },
{ GTP_EXT_TFT, GTP_CONDITIONAL },
{ GTP_EXT_TRIGGER_ID, GTP_OPTIONAL },
{ GTP_EXT_OMC_ID, GTP_OPTIONAL },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_CREATE_PDP_RESP, {
{ GTP_EXT_CAUSE, GTP_MANDATORY },
{ GTP_EXT_REORDER, GTP_CONDITIONAL },
{ GTP_EXT_RECOVER, GTP_OPTIONAL },
{ GTP_EXT_TEID, GTP_CONDITIONAL },
{ GTP_EXT_TEID_CP, GTP_CONDITIONAL },
{ GTP_EXT_CHRG_ID, GTP_CONDITIONAL },
{ GTP_EXT_USER_ADDR, GTP_CONDITIONAL },
{ GTP_EXT_PROTO_CONF, GTP_OPTIONAL },
{ GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
{ GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
{ GTP_EXT_QOS_UMTS, GTP_CONDITIONAL },
{ GTP_EXT_CHRG_ADDR, GTP_OPTIONAL },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{ /* checked, SGSN -> GGSN */
GTP_MSG_UPDATE_PDP_REQ, {
{ GTP_EXT_IMSI, GTP_CONDITIONAL },
{ GTP_EXT_RECOVER, GTP_OPTIONAL },
{ GTP_EXT_TEID, GTP_MANDATORY },
{ GTP_EXT_TEID_CP, GTP_CONDITIONAL },
{ GTP_EXT_NSAPI, GTP_MANDATORY },
{ GTP_EXT_TRACE_REF, GTP_OPTIONAL },
{ GTP_EXT_TRACE_TYPE, GTP_OPTIONAL },
{ GTP_EXT_GSN_ADDR, GTP_MANDATORY },
{ GTP_EXT_GSN_ADDR, GTP_MANDATORY },
{ GTP_EXT_QOS_UMTS, GTP_MANDATORY },
{ GTP_EXT_TFT, GTP_OPTIONAL },
{ GTP_EXT_TRIGGER_ID, GTP_OPTIONAL },
{ GTP_EXT_OMC_ID, GTP_OPTIONAL },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{ /* checked, GGSN -> SGSN */
GTP_MSG_UPDATE_PDP_RESP, {
{ GTP_EXT_CAUSE, GTP_MANDATORY },
{ GTP_EXT_RECOVER, GTP_OPTIONAL },
{ GTP_EXT_TEID, GTP_CONDITIONAL },
{ GTP_EXT_TEID_CP, GTP_CONDITIONAL },
{ GTP_EXT_CHRG_ID, GTP_CONDITIONAL },
{ GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
{ GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
{ GTP_EXT_QOS_UMTS, GTP_CONDITIONAL },
{ GTP_EXT_CHRG_ADDR, GTP_OPTIONAL },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_DELETE_PDP_REQ, {
{ GTP_EXT_TEAR_IND, GTP_CONDITIONAL },
{ GTP_EXT_NSAPI, GTP_MANDATORY },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_DELETE_PDP_RESP, {
{ GTP_EXT_CAUSE, GTP_MANDATORY },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_ERR_IND, {
{ GTP_EXT_TEID, GTP_MANDATORY },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_PDU_NOTIFY_REQ, {
{ GTP_EXT_IMSI, GTP_MANDATORY },
{ GTP_EXT_TEID_CP, GTP_MANDATORY },
{ GTP_EXT_USER_ADDR, GTP_MANDATORY },
{ GTP_EXT_APN, GTP_MANDATORY },
{ GTP_EXT_GSN_ADDR, GTP_MANDATORY },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_PDU_NOTIFY_RESP, {
{ GTP_EXT_CAUSE, GTP_MANDATORY },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_PDU_NOTIFY_REJ_REQ, {
{ GTP_EXT_CAUSE, GTP_MANDATORY },
{ GTP_EXT_TEID_CP, GTP_MANDATORY },
{ GTP_EXT_USER_ADDR, GTP_MANDATORY },
{ GTP_EXT_APN, GTP_MANDATORY },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_PDU_NOTIFY_REJ_RESP, {
{ GTP_EXT_CAUSE, GTP_MANDATORY },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_SUPP_EXT_HDR, {
{ GTP_EXT_HDR_LIST, GTP_MANDATORY },
{ 0, 0 }
}
},
{
GTP_MSG_SEND_ROUT_INFO_REQ, {
{ GTP_EXT_IMSI, GTP_MANDATORY },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_SEND_ROUT_INFO_RESP, {
{ GTP_EXT_CAUSE, GTP_MANDATORY },
{ GTP_EXT_IMSI, GTP_MANDATORY },
{ GTP_EXT_MAP_CAUSE, GTP_OPTIONAL },
{ GTPv1_EXT_MS_REASON, GTP_OPTIONAL },
{ GTP_EXT_GSN_ADDR, GTP_OPTIONAL },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_FAIL_REP_REQ, {
{ GTP_EXT_IMSI, GTP_MANDATORY },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_FAIL_REP_RESP, {
{ GTP_EXT_CAUSE, GTP_MANDATORY },
{ GTP_EXT_MAP_CAUSE, GTP_OPTIONAL },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_MS_PRESENT_REQ, {
{ GTP_EXT_IMSI, GTP_MANDATORY },
{ GTP_EXT_GSN_ADDR, GTP_MANDATORY },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_MS_PRESENT_RESP, {
{ GTP_EXT_CAUSE, GTP_MANDATORY },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_IDENT_REQ, {
{ GTP_EXT_RAI, GTP_MANDATORY },
{ GTP_EXT_PTMSI, GTP_MANDATORY },
{ GTP_EXT_PTMSI_SIG, GTP_CONDITIONAL },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_IDENT_RESP, {
{ GTP_EXT_CAUSE, GTP_MANDATORY },
{ GTP_EXT_IMSI, GTP_CONDITIONAL },
{ GTP_EXT_AUTH_TRI, GTP_CONDITIONAL },
{ GTP_EXT_AUTH_QUI, GTP_CONDITIONAL },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_SGSN_CNTXT_REQ, {
{ GTP_EXT_IMSI, GTP_CONDITIONAL },
{ GTP_EXT_RAI, GTP_MANDATORY },
{ GTP_EXT_TLLI, GTP_CONDITIONAL },
{ GTP_EXT_PTMSI, GTP_CONDITIONAL },
{ GTP_EXT_PTMSI_SIG, GTP_CONDITIONAL },
{ GTP_EXT_MS_VALID, GTP_OPTIONAL },
{ GTP_EXT_TEID_CP, GTP_MANDATORY },
{ GTP_EXT_GSN_ADDR, GTP_MANDATORY },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_SGSN_CNTXT_RESP, {
{ GTP_EXT_CAUSE, GTP_MANDATORY },
{ GTP_EXT_IMSI, GTP_CONDITIONAL },
{ GTP_EXT_TEID_CP, GTP_CONDITIONAL },
{ GTP_EXT_RP_SMS, GTP_OPTIONAL },
{ GTP_EXT_RP, GTP_OPTIONAL },
{ GTP_EXT_PKT_FLOW_ID, GTP_OPTIONAL },
{ GTP_EXT_MM_CNTXT, GTP_CONDITIONAL },
{ GTP_EXT_PDP_CNTXT, GTP_CONDITIONAL },
{ GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_SGSN_CNTXT_ACK, {
{ GTP_EXT_CAUSE, GTP_MANDATORY },
{ GTP_EXT_TEID_II, GTP_CONDITIONAL },
{ GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_FORW_RELOC_REQ, {
{ GTP_EXT_IMSI, GTP_MANDATORY },
{ GTP_EXT_TEID_CP, GTP_MANDATORY },
{ GTP_EXT_RANAP_CAUSE, GTP_MANDATORY },
{ GTP_EXT_MM_CNTXT, GTP_MANDATORY },
{ GTP_EXT_PDP_CNTXT, GTP_CONDITIONAL },
{ GTP_EXT_GSN_ADDR, GTP_MANDATORY },
{ GTP_EXT_TARGET_ID, GTP_MANDATORY },
{ GTP_EXT_UTRAN_CONT, GTP_MANDATORY },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_FORW_RELOC_RESP, {
{ GTP_EXT_CAUSE, GTP_MANDATORY },
{ GTP_EXT_TEID_CP, GTP_CONDITIONAL },
{ GTP_EXT_RANAP_CAUSE, GTP_CONDITIONAL },
{ GTP_EXT_GSN_ADDR, GTP_CONDITIONAL },
{ GTP_EXT_UTRAN_CONT, GTP_OPTIONAL },
{ GTP_EXT_RAB_SETUP, GTP_CONDITIONAL },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_FORW_RELOC_COMP, {
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_RELOC_CANCEL_REQ, {
{ GTP_EXT_IMSI, GTP_MANDATORY },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_RELOC_CANCEL_RESP, {
{ GTP_EXT_CAUSE, GTP_MANDATORY },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_FORW_RELOC_ACK, {
{ GTP_EXT_CAUSE, GTP_MANDATORY },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_FORW_SRNS_CNTXT, {
{ GTP_EXT_RAB_CNTXT, GTP_MANDATORY },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
GTP_MSG_FORW_SRNS_CNTXT_ACK, {
{ GTP_EXT_CAUSE, GTP_MANDATORY },
{ GTP_EXT_PRIV_EXT, GTP_OPTIONAL },
{ 0, 0 }
}
},
{
0, {
{ 0, 0 }
}
}
};
static int
check_field_presence(guint8 message, guint8 field, int *position) {
guint i = 0;
_gtp_mess_items *mess_items;
switch(gtp_version) {
case 0:
mess_items = gprs_mess_items;
break;
case 1:
mess_items = umts_mess_items;
break;
default:
return -2;
}
while (mess_items[i].code) {
if (mess_items[i].code == message) {
while (mess_items[i].fields[*position].code) {
if (mess_items[i].fields[*position].code == field) {
(*position)++;
return 0;
} else {
if (mess_items[i].fields[*position].presence == GTP_MANDATORY) {
return mess_items[i].fields[(*position)++].code;
} else {
(*position)++;
}}
}
return -1;
}
i++;
}
return -2;
}
/* Decoders of fields in extension headers, each function returns no of bytes from field */
/* GPRS: 9.60 v7.6.0, chapter
* UMTS: 29.060 v4.0, chapter
*/
static int
decode_gtp_cause(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
guint8 cause;
cause = tvb_get_guint8(tvb, offset+1);
proto_tree_add_uint(tree, hf_gtp_cause, tvb, offset, 2, cause);
return 2;
}
/* GPRS: 9.60 v7.6.0, chapter 7.9.2
* UMTS: 29.060 v4.0, chapter 7.7.2
*/
static int
decode_gtp_imsi(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
guint8 imsi_val[8];
gchar *imsi_str;
tvb_memcpy(tvb, imsi_val, offset+1, 8);
imsi_str = imsi_to_str (imsi_val);
proto_tree_add_string (tree, hf_gtp_imsi, tvb, offset, 9, imsi_str);
return 9;
}
/* GPRS: 9.60 v7.6.0, chapter 7.9.3
* UMTS: 29.060 v4.0, chapter 7.7.3
*/
static int
decode_gtp_rai(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
proto_tree *ext_tree_rai;
proto_item *te;
guint8 byte[3];
guint16 mnc, mcc;
te = proto_tree_add_text(tree, tvb, offset, 1, val_to_str(GTP_EXT_RAI, gtp_val, "Unknown message"));
ext_tree_rai = proto_item_add_subtree(te, ett_gtp_rai);
byte[1] = tvb_get_guint8 (tvb, offset + 1);
byte[2] = tvb_get_guint8 (tvb, offset + 2);
byte[3] = tvb_get_guint8 (tvb, offset + 3);
mcc = (byte[1] & 0x0F) * 100 + ((byte[1] & 0xF0) >> 4) * 10 + (byte[2] & 0x0F );
if ((byte[2] & 0xF0) == 0xF0)
mnc = (byte[3] & 0x0F) * 10 + ((byte[3] & 0xF0) >> 4);
else
mnc = (byte[3] & 0x0F) * 100 + ((byte[3] & 0xF0) >> 4 ) * 10 + ((byte[2] & 0xF0) >> 4);
proto_tree_add_uint(ext_tree_rai, hf_gtp_rai_mcc, tvb, offset+1, 2, mcc);
proto_tree_add_uint(ext_tree_rai, hf_gtp_rai_mnc, tvb, offset+2, 2, mnc);
proto_tree_add_uint(ext_tree_rai, hf_gtp_rai_lac, tvb, offset+4, 2, tvb_get_ntohs (tvb, offset+4));
proto_tree_add_uint(ext_tree_rai, hf_gtp_rai_rac, tvb, offset+6, 1, tvb_get_guint8 (tvb, offset+6));
return 7;
}
/* GPRS: 9.60 v7.6.0, chapter 7.9.4, page 39
* UMTS: 29.060 v4.0, chapter 7.7.4, page 47
*/
static int
decode_gtp_tlli(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
guint32 tlli;
tlli = tvb_get_ntohl(tvb, offset+1);
proto_tree_add_uint(tree, hf_gtp_tlli, tvb, offset, 5, tlli);
return 5;
}
/* GPRS: 9.60 v7.6.0, chapter 7.9.5, page 39
* UMTS: 29.060 v4.0, chapter 7.7.5, page 47
*/
static int
decode_gtp_ptmsi(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
guint32 ptmsi;
ptmsi = tvb_get_ntohl (tvb, offset+1);
proto_tree_add_uint (tree, hf_gtp_ptmsi, tvb, offset, 5, ptmsi);
return 5;
}
/* adjust - how many bytes before offset should be highlighted
*/
static int
decode_qos_gprs(tvbuff_t *tvb, int offset, proto_tree *tree, gchar* qos_str, guint8 adjust) {
guint8 spare1, delay, reliability, peak, spare2, precedence, spare3, mean;
proto_tree *ext_tree_qos;
proto_item *te;
spare1 = tvb_get_guint8(tvb, offset) & 0xC0;
delay = tvb_get_guint8(tvb, offset) & 0x38;
reliability = tvb_get_guint8(tvb, offset) & 0x07;
peak = tvb_get_guint8(tvb, offset+1) & 0xF0;
spare2 = tvb_get_guint8(tvb, offset+1) & 0x08;
precedence = tvb_get_guint8(tvb, offset+1) & 0x07;
spare3 = tvb_get_guint8(tvb, offset+2) & 0xE0;
mean = tvb_get_guint8(tvb, offset+2) & 0x1F;
te = proto_tree_add_text(tree, tvb, offset-adjust, 3+adjust, "%s: delay: %u, reliability: %u, peak: %u, precedence: %u, mean: %u",
qos_str, (delay >> 3) & 0x07, reliability, (peak >> 4) & 0x0F, precedence, mean);
ext_tree_qos = proto_item_add_subtree(te, ett_gtp_qos);
if (adjust != 0) {
proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_spare1, tvb, offset, 1, spare1);
proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_delay, tvb, offset, 1, delay);
proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_reliability, tvb, offset, 1, reliability);
proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_peak, tvb, offset+1, 1, peak);
proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_spare2, tvb, offset+1, 1, spare2);
proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_precedence, tvb, offset+1, 1, precedence);
proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_spare3, tvb, offset+2, 1, spare3);
proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_mean, tvb, offset+2, 1, mean);
}
return 3;
}
/* GPRS: 9.60 v7.6.0, chapter 7.9.6, page 39
* 4.08
* 3.60
* UMTS: not present
* TODO: check if length is included: ETSI 4.08 vs 9.60
*/
static int
decode_gtp_qos_gprs(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
return (1+decode_qos_gprs(tvb, offset+1, tree, "Quality of Service", 1));
}
/* GPRS: 9.60 v7.6.0, chapter 7.9.7, page 39
* UMTS: 29.060 v4.0, chapter 7.7.6, page 47
*/
static int
decode_gtp_reorder(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
guint8 reorder;
reorder = tvb_get_guint8(tvb, offset+1) & 0x01;
proto_tree_add_boolean(tree, hf_gtp_reorder, tvb, offset, 2, reorder);
return 2;
}
/* GPRS: 9.60 v7.6.0, chapter 7.9.8, page 40
* 4.08 v7.1.2, chapter 10.5.3.1+
* UMTS: 29.060 v4.0, chapter 7.7.7
* TODO: Add blurb support by registering items in the protocol registration
*/
static int
decode_gtp_auth_tri(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
proto_tree *ext_tree_auth_tri;
proto_item *te;
te = proto_tree_add_text(tree, tvb, offset, 29, val_to_str(GTP_EXT_AUTH_TRI, gtp_val, "Unknown message"));
ext_tree_auth_tri = proto_item_add_subtree(tree, ett_gtp_auth_tri);
proto_tree_add_text(ext_tree_auth_tri, tvb, offset+1, 16, "RAND: %s", tvb_bytes_to_str(tvb, offset+1, 16));
proto_tree_add_text(ext_tree_auth_tri, tvb, offset+17, 4, "SRES: %s", tvb_bytes_to_str(tvb, offset+17, 4));
proto_tree_add_text(ext_tree_auth_tri, tvb, offset+21, 8, "Kc: %s", tvb_bytes_to_str(tvb, offset+21, 8));
return 1+16+4+8;
}
/* GPRS: 9.60 v7.6.0, chapter 7.9.9, page 40
* 9.02 v7.7.0, page 1090
* UMTS: 29.060 v4.0, chapter 7.7.8, page 48
* 29.002 v4.2.1, chapter 17.5, page 268
*/
static int
decode_gtp_map_cause(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
guint8 map_cause;
map_cause = tvb_get_guint8(tvb, offset+1);
proto_tree_add_uint (tree, hf_gtp_map_cause, tvb, offset, 2, map_cause);
return 2;
}
/* GPRS: 9.60 v7.6.0, chapter 7.9.10, page 41
* UMTS: 29.060 v4.0, chapter 7.7.9, page 48
*/
static int
decode_gtp_ptmsi_sig(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
guint32 ptmsi_sig;
ptmsi_sig = tvb_get_ntoh24(tvb, offset+1);
proto_tree_add_uint(tree, hf_gtp_ptmsi_sig, tvb, offset, 4, ptmsi_sig);
return 4;
}
/* GPRS: 9.60 v7.6.0, chapter 7.9.11, page 41
* UMTS: 29.060 v4.0, chapter 7.7.10, page 49
*/
static int
decode_gtp_ms_valid(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
guint8 ms_valid;
ms_valid = tvb_get_guint8(tvb, offset+1) & 0x01;
proto_tree_add_boolean (tree, hf_gtp_ms_valid, tvb, offset, 2, ms_valid);
return 2;
}
/* GPRS: 9.60 v7.6.0, chapter 7.9.12, page 41
* UMTS: 29.060 v4.0, chapter 7.7.11, page 49
*/
static int
decode_gtp_recovery(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
guint8 recovery;
recovery = tvb_get_guint8(tvb, offset+1);
proto_tree_add_uint (tree, hf_gtp_recovery, tvb, offset, 2, recovery);
return 2;
}
/* GPRS: 9.60 v7.6.0, chapter 7.9.13, page 42
* UMTS: 29.060 v4.0, chapter 7.7.12, page 49
*/
static int
decode_gtp_sel_mode(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
guint8 sel_mode;
sel_mode = tvb_get_guint8(tvb, offset+1) & 0x03;
proto_tree_add_uint(tree, hf_gtp_sel_mode, tvb, offset, 2, sel_mode);
return 2;
}
/* GPRS: 9.60 v7.6.0, chapter 7.9.14, page 42
* UMTS: 29.060 v4.0, chapter 7.7.13, page 50
*/
static int
decode_gtp_16(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
guint16 ext_flow_label;
guint32 teid_data;
switch (gtp_version) {
case 0:
ext_flow_label = tvb_get_ntohs(tvb, offset+1);
proto_tree_add_uint(tree, hf_gtp_ext_flow_label, tvb, offset, 3, ext_flow_label);
return 3;
case 1:
teid_data = tvb_get_ntohl(tvb, offset+1);
proto_tree_add_uint(tree, hf_gtp_teid_data, tvb, offset, 5, teid_data);
return 5;
default:
proto_tree_add_text(tree, tvb, offset, 1, "Flow label/TEID Data I : GTP version not supported");
return 3;
}
}
/* GPRS: 9.60 v7.6.0, chapter 7.9.15, page 42
* UMTS: 29.060 v4.0, chapter 7.7.14, page 42
*/
static int
decode_gtp_17(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
guint16 flow_sig;
guint32 teid_cp;
switch (gtp_version) {
case 0:
flow_sig = tvb_get_ntohs(tvb, offset+1);
proto_tree_add_uint (tree, hf_gtp_flow_sig, tvb, offset, 3, flow_sig);
return 3;
case 1:
teid_cp = tvb_get_ntohl(tvb, offset+1);
proto_tree_add_uint (tree, hf_gtp_teid_cp, tvb, offset, 5, teid_cp);
return 5;
default:
proto_tree_add_text(tree, tvb, offset, 1, "Flow label signalling/TEID control plane : GTP version not supported");
return 3;
}
}
/* GPRS: 9.60 v7.6.0, chapter 7.9.16, page 42
* UMTS: 29.060 v4.0, chapter 7.7.15, page 51
*/
static int
decode_gtp_18(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
guint16 flow_ii;
guint32 teid_ii;
proto_tree *ext_tree_flow_ii;
proto_item *te;
switch (gtp_version) {
case 0:
te = proto_tree_add_text(tree, tvb, offset, 4, val_to_str(GTP_EXT_FLOW_II, gtp_val, "Unknown message"));
ext_tree_flow_ii = proto_item_add_subtree (te, ett_gtp_flow_ii);
proto_tree_add_uint(ext_tree_flow_ii, hf_gtp_nsapi, tvb, offset+1, 1, tvb_get_guint8(tvb, offset+1) & 0x0F);
flow_ii = tvb_get_ntohs(tvb, offset+2);
proto_tree_add_uint(ext_tree_flow_ii, hf_gtp_flow_ii, tvb, offset+2, 2, flow_ii);
return 4;
case 1:
te = proto_tree_add_text (tree, tvb, offset, 6, val_to_str(GTP_EXT_TEID_II, gtp_val, "Unknown message"));
ext_tree_flow_ii = proto_item_add_subtree(te, ett_gtp_flow_ii);
proto_tree_add_uint(ext_tree_flow_ii, hf_gtp_nsapi, tvb, offset+1, 1, tvb_get_guint8(tvb, offset+1) & 0x0F);
teid_ii = tvb_get_ntohl(tvb, offset+2);
proto_tree_add_uint(ext_tree_flow_ii, hf_gtp_teid_ii, tvb, offset+2, 4, teid_ii);
return 6;
default:
proto_tree_add_text(tree, tvb, offset, 1, "Flow data II/TEID Data II : GTP Version not supported");
return 4;
}
}
/* GPRS: 9.60 v7.6.0, chapter 7.9.16A, page 43
* UMTS: 29.060 v4.0, chapter 7.7.16, page 51
* Check if all ms_reason types are included
*/
static int
decode_gtp_19(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
guint8 field19;
field19 = tvb_get_guint8(tvb, offset+1);
switch (gtp_version) {
case 0:
proto_tree_add_uint(tree, hf_gtp_ms_reason, tvb, offset, 2, field19);
break;
case 1:
proto_tree_add_boolean(tree, hf_gtp_tear_ind, tvb, offset, 2, field19 & 0x01);
break;
default:
proto_tree_add_text(tree, tvb, offset, 1, "Information Element Type = 19 : GTP Version not supported");
break;
}
return 2;
}
/* GPRS: not present
* UMTS: 29.060 v4.0, chapter 7.7.17, page 51
*/
static int
decode_gtp_nsapi(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
guint8 nsapi;
nsapi = tvb_get_guint8(tvb, offset+1) & 0x0F;
proto_tree_add_uint(tree, hf_gtp_nsapi, tvb, offset, 2, nsapi);
return 2;
}
/* GPRS: not present
* UMTS: 29.060 v4.0, chapter 7.7.18, page 52
*/
static int
decode_gtp_ranap_cause(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
guint8 ranap;
ranap = tvb_get_guint8(tvb, offset+1);
if(ranap > 0 && ranap <=64)
proto_tree_add_uint_format(tree, hf_gtp_ranap_cause, tvb, offset, 2,
ranap, "%s (Radio Network Layer Cause) : %s (%u)",
val_to_str(GTP_EXT_RANAP_CAUSE, gtp_val, "Unknown"),
val_to_str(ranap, ranap_cause_type, "Unknown RANAP Cause"), ranap);
if(ranap > 64 && ranap <=80)
proto_tree_add_uint_format(tree, hf_gtp_ranap_cause, tvb, offset, 2,
ranap, "%s (Transport Layer Cause) : %s (%u)",
val_to_str(GTP_EXT_RANAP_CAUSE, gtp_val, "Unknown"),
val_to_str(ranap, ranap_cause_type, "Unknown RANAP Cause"), ranap);
if(ranap > 80 && ranap <=96)
proto_tree_add_uint_format(tree, hf_gtp_ranap_cause, tvb, offset, 2,
ranap, "%s (NAS Cause) : %s (%u)",
val_to_str(GTP_EXT_RANAP_CAUSE, gtp_val, "Unknown"),
val_to_str(ranap, ranap_cause_type, "Unknown RANAP Cause"), ranap);
if(ranap > 96 && ranap <=112)
proto_tree_add_uint_format(tree, hf_gtp_ranap_cause, tvb, offset, 2, ranap,
"%s (Protocol Cause) : %s (%u)",
val_to_str(GTP_EXT_RANAP_CAUSE, gtp_val, "Unknown"),
val_to_str(ranap, ranap_cause_type, "Unknown RANAP Cause"), ranap);
if(ranap > 112 && ranap <=128)
proto_tree_add_uint_format(tree, hf_gtp_ranap_cause, tvb, offset, 2, ranap,
"%s (Miscellaneous Cause) : %s (%u)",
val_to_str(GTP_EXT_RANAP_CAUSE, gtp_val, "Unknown"),
val_to_str(ranap, ranap_cause_type, "Unknown RANAP Cause"), ranap);
if(ranap > 128 /* && ranap <=255 */)
proto_tree_add_uint_format(tree, hf_gtp_ranap_cause, tvb, offset, 2, ranap,
"%s (Non-standard Cause) : %s (%u)",
val_to_str(GTP_EXT_RANAP_CAUSE, gtp_val, "Unknown"),
val_to_str(ranap, ranap_cause_type, "Unknown RANAP Cause"), ranap);
return 2;
}
/* GPRS: not present
* UMTS: 29.060 v4.0, chapter 7.7.19, page 52
*/
static int
decode_gtp_rab_cntxt(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
guint8 nsapi, dl_pdcp_seq, ul_pdcp_seq;
guint16 dl_gtpu_seq, ul_gtpu_seq;
proto_tree *ext_tree_rab_cntxt;
proto_item *te;
te = proto_tree_add_text(tree, tvb, offset, 8, val_to_str(GTP_EXT_RAB_CNTXT, gtp_val, "Unknown message"));
ext_tree_rab_cntxt = proto_item_add_subtree(te, ett_gtp_rab_cntxt);
nsapi = tvb_get_guint8(tvb, offset+1) & 0x0F;
dl_gtpu_seq = tvb_get_ntohs(tvb, offset+2);
ul_gtpu_seq = tvb_get_ntohs(tvb, offset+4);
dl_pdcp_seq = tvb_get_guint8(tvb, offset+6);
ul_pdcp_seq = tvb_get_guint8(tvb, offset+7);
proto_tree_add_uint (ext_tree_rab_cntxt, hf_gtp_nsapi, tvb, offset+1, 1, nsapi);
proto_tree_add_uint(ext_tree_rab_cntxt, hf_gtp_rab_gtpu_dn, tvb, offset+2, 2, dl_gtpu_seq);
proto_tree_add_uint(ext_tree_rab_cntxt, hf_gtp_rab_gtpu_up, tvb, offset+4, 2, ul_gtpu_seq);
proto_tree_add_uint(ext_tree_rab_cntxt, hf_gtp_rab_pdu_dn, tvb, offset+6, 1, dl_pdcp_seq);
proto_tree_add_uint(ext_tree_rab_cntxt, hf_gtp_rab_pdu_up, tvb, offset+7, 1, ul_pdcp_seq);
return 8;
}
/* GPRS: not present
* UMTS: 29.060 v4.0, chapter 7.7.20, page 53
*/
static int
decode_gtp_rp_sms(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
guint8 rp_sms;
rp_sms = tvb_get_guint8(tvb, offset+1) & 0x07;
proto_tree_add_uint(tree, hf_gtp_rp_sms, tvb, offset, 2, rp_sms);
return 2;
}
/* GPRS: not present
* UMTS: 29.060 v4.0, chapter 7.7.21, page 53
*/
static int
decode_gtp_rp(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
proto_tree *ext_tree_rp;
proto_item *te;
guint8 nsapi, rp, spare;
nsapi = tvb_get_guint8(tvb, offset+1) & 0xF0;
spare = tvb_get_guint8(tvb, offset+1) & 0x08;
rp = tvb_get_guint8(tvb, offset+1) & 0x07;
te = proto_tree_add_uint_format(tree, hf_gtp_rp, tvb, offset, 2, rp, "Radio Priority for NSAPI(%u) : %u", nsapi, rp);
ext_tree_rp = proto_item_add_subtree(tree, ett_gtp_rp);
proto_tree_add_uint(ext_tree_rp, hf_gtp_rp_nsapi, tvb, offset+1, 1, nsapi);
proto_tree_add_uint(ext_tree_rp, hf_gtp_rp_spare, tvb, offset+1, 1, spare);
proto_tree_add_uint(ext_tree_rp, hf_gtp_rp, tvb, offset+1, 1, rp);
return 2;
}
/* GPRS: not present
* UMTS: 29.060 v4.0, chapter 7.7.22, page 53
*/
static int
decode_gtp_pkt_flow_id(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
proto_tree *ext_tree_pkt_flow_id;
proto_item *te;
guint8 nsapi, pkt_flow_id;
nsapi = tvb_get_guint8(tvb, offset+1) & 0x0F;
pkt_flow_id = tvb_get_guint8(tvb, offset+2);
te = proto_tree_add_uint_format (tree, hf_gtp_pkt_flow_id, tvb, offset,
3, pkt_flow_id, "Packet Flow ID for NSAPI(%u) : %u", nsapi,
pkt_flow_id);
ext_tree_pkt_flow_id = proto_item_add_subtree(tree, ett_gtp_pkt_flow_id);
proto_tree_add_uint(ext_tree_pkt_flow_id, hf_gtp_nsapi, tvb, offset+1, 1, nsapi);
proto_tree_add_uint_format(ext_tree_pkt_flow_id, hf_gtp_pkt_flow_id, tvb,
offset+2, 1, pkt_flow_id, "%s : %u",
val_to_str(GTP_EXT_PKT_FLOW_ID, gtp_val, "Unknown message"),
pkt_flow_id);
return 3;
}
/* GPRS: not present
* UMTS: 29.060 v4.0, chapter 7.7.23, page 53
* TODO: Differenciate these uints?
*/
static int
decode_gtp_chrg_char(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
guint16 chrg_char;
proto_item *te;
proto_tree *ext_tree_chrg_char;
chrg_char = tvb_get_ntohs(tvb, offset+1);
te = proto_tree_add_uint (tree, hf_gtp_chrg_char, tvb, offset, 3, chrg_char);
/*"%s: %x", val_to_str (GTP_EXT_CHRG_CHAR, gtp_val, "Unknown message"), chrg_char);*/
ext_tree_chrg_char = proto_item_add_subtree(te, ett_gtp_chrg_char);
proto_tree_add_uint (ext_tree_chrg_char, hf_gtp_chrg_char_s, tvb, offset+1, 2, chrg_char);
proto_tree_add_uint (ext_tree_chrg_char, hf_gtp_chrg_char_n, tvb, offset+1, 2, chrg_char);
proto_tree_add_uint (ext_tree_chrg_char, hf_gtp_chrg_char_p, tvb, offset+1, 2, chrg_char);
proto_tree_add_uint (ext_tree_chrg_char, hf_gtp_chrg_char_f, tvb, offset+1, 2, chrg_char);
proto_tree_add_uint (ext_tree_chrg_char, hf_gtp_chrg_char_h, tvb, offset+1, 2, chrg_char);
proto_tree_add_uint (ext_tree_chrg_char, hf_gtp_chrg_char_r, tvb, offset+1, 2, chrg_char);
return 3;
}
/* GPRS: not present
* UMTS: 29.060 v4.0, chapter 7.7.24, page
*/
static int
decode_gtp_trace_ref(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
guint16 trace_ref;
trace_ref = tvb_get_ntohs(tvb, offset+1);
proto_tree_add_uint (tree, hf_gtp_trace_ref, tvb, offset, 3, trace_ref);
return 3;
}
/* GPRS: not present
* UMTS: 29.060 v4.0, chapter 7.7.25, page
*/
static int
decode_gtp_trace_type(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
guint16 trace_type;
trace_type = tvb_get_ntohs(tvb, offset+1);
proto_tree_add_uint (tree, hf_gtp_trace_type, tvb, offset, 3, trace_type);
return 3;
}
/* GPRS: 9.60 v7.6.0, chapter 7.9.16A
* UMTS: 29.060 v4.0, chapter 7.7.25A, page
*/
static int
decode_gtp_ms_reason(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
guint8 reason;
reason = tvb_get_guint8(tvb, offset+1);
proto_tree_add_uint (tree, hf_gtp_ms_reason, tvb, offset, 2, reason);
return 2;
}
/* GPRS: 12.15 v7.6.0, chapter 7.3.3, page 45
* UMTS: 33.015
*/
static int
decode_gtp_tr_comm(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
guint8 tr_command;
tr_command = tvb_get_guint8(tvb, offset+1);
proto_tree_add_uint (tree, hf_gtp_tr_comm, tvb, offset, 2, tr_command);
return 2;
}
/* GPRS: 9.60 v7.6.0, chapter 7.9.17, page 43
* UMTS: 29.060 v4.0, chapter 7.7.26, page 55
*/
static int
decode_gtp_chrg_id(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
guint32 chrg_id;
chrg_id = tvb_get_ntohl(tvb, offset+1);
proto_tree_add_uint (tree, hf_gtp_chrg_id, tvb, offset, 5, chrg_id);
return 5;
}
/* GPRS: 9.60 v7.6.0, chapter 7.9.18, page 43
* UMTS: 29.060 v4.0, chapter 7.7.27, page 55
*/
static int
decode_gtp_user_addr(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
guint16 length;
guint8 pdp_typ, pdp_org;
guint32 addr_ipv4;
struct e_in6_addr addr_ipv6;
proto_tree *ext_tree_user;
proto_item *te;
length = tvb_get_ntohs(tvb, offset+1);
pdp_org = tvb_get_guint8(tvb, offset+3) & 0x0F;
pdp_typ = tvb_get_guint8(tvb, offset+4);
te = proto_tree_add_text(tree, tvb, offset, 3+length, "%s (%s/%s)",
val_to_str(GTP_EXT_USER_ADDR, gtp_val, "Unknown message"),
val_to_str(pdp_org, pdp_org_type, "Unknown PDP Organization"),
val_to_str(pdp_typ, pdp_type, "Unknown PDP Type"));
ext_tree_user = proto_item_add_subtree(te, ett_gtp_user);
proto_tree_add_text(ext_tree_user, tvb, offset+1, 2, "Length : %u", length);
proto_tree_add_uint(ext_tree_user, hf_gtp_user_addr_pdp_org, tvb, offset+3, 1, pdp_org);
proto_tree_add_uint(ext_tree_user, hf_gtp_user_addr_pdp_type, tvb, offset+4, 1, pdp_typ);
if (length == 2) {
if (pdp_org == 0 && pdp_typ == 1)
proto_item_append_text(te, " (Point to Point Protocol)");
else if (pdp_typ == 2)
proto_item_append_text(te, " (Octet Stream Protocol)");
} else if (length > 2) {
switch (pdp_typ) {
case 0x21:
tvb_memcpy(tvb, (guint8 *)&addr_ipv4, offset+5, sizeof addr_ipv4);
proto_tree_add_ipv4(ext_tree_user, hf_gtp_user_ipv4, tvb, offset+5, 4, addr_ipv4);
proto_item_append_text(te, " : %s", ip_to_str((guint8 *)&addr_ipv4));
break;
case 0x57:
tvb_memcpy(tvb, (guint8 *)&addr_ipv6, offset+5, sizeof addr_ipv6);
proto_tree_add_ipv6 (ext_tree_user, hf_gtp_user_ipv6, tvb, offset+5, 16, (guint8 *)&addr_ipv6);
proto_item_append_text(te, " : %s", ip6_to_str((struct e_in6_addr*)&addr_ipv6));
break;
}
} else
proto_item_append_text(te, " : empty PDP Address");
return 3+length;
}
static int
decode_triplet(tvbuff_t *tvb, int offset, proto_tree *tree, guint16 count) {
proto_tree *ext_tree_trip;
proto_item *te_trip;
guint16 i;
for (i=0;i<count;i++) {
te_trip = proto_tree_add_text(tree, tvb, offset+i*28, 28, "Triplet no%x", i);
ext_tree_trip = proto_item_add_subtree(te_trip, ett_gtp_trip);
proto_tree_add_text(ext_tree_trip, tvb, offset+i*28, 16, "RAND: %s", tvb_bytes_to_str(tvb, offset+i*28, 16));
proto_tree_add_text(ext_tree_trip, tvb, offset+i*28+16, 4, "SRES: %s", tvb_bytes_to_str(tvb, offset+i*28+16, 4));
proto_tree_add_text(ext_tree_trip, tvb, offset+i*28+20, 8, "Kc: %s", tvb_bytes_to_str(tvb, offset+i*28+20, 8));
}
return count*28;
}
/* adjust - how many bytes before quintuplet should be highlighted
*/
static int
decode_quintuplet(tvbuff_t *tvb, int offset, proto_tree *tree, guint16 count, guint8 adjust) {
proto_tree *ext_tree_quint;
proto_item *te_quint;
guint16 q_len, xres_len, auth_len, q_offset, i;
q_offset = 0;
for (i=0;i<count;i++) {
offset = offset + q_offset;
q_len = tvb_get_ntohs(tvb, offset);
te_quint = proto_tree_add_text(tree, tvb, offset-adjust, q_len+adjust, "Quintuplet #%x", i);
ext_tree_quint = proto_item_add_subtree(te_quint, ett_gtp_quint);
proto_tree_add_text(ext_tree_quint, tvb, offset, 2, "Length: %x", q_len);
proto_tree_add_text(ext_tree_quint, tvb, offset+2, 16, "RAND: %s", tvb_bytes_to_str(tvb, offset+2, 16));
xres_len = tvb_get_ntohs(tvb, offset+18);
proto_tree_add_text(ext_tree_quint, tvb, offset+18, 2, "XRES length: %u", xres_len);
proto_tree_add_text(ext_tree_quint, tvb, offset+20, xres_len, "XRES: %s", tvb_bytes_to_str(tvb, offset+20, xres_len));
proto_tree_add_text(ext_tree_quint, tvb, offset+20+xres_len, 16, "Quintuplet ciphering key: %s", tvb_bytes_to_str(tvb, offset+20+xres_len, 16));
proto_tree_add_text(ext_tree_quint, tvb, offset+36+xres_len, 16, "Quintuplet integrity key: %s", tvb_bytes_to_str(tvb, offset+36+xres_len, 16));
auth_len = tvb_get_ntohs(tvb, offset+52+xres_len);
proto_tree_add_text(ext_tree_quint, tvb, offset+52+xres_len, 2, "Authentication length: %u", auth_len);
proto_tree_add_text(ext_tree_quint, tvb, offset+54+xres_len, auth_len, "AUTH: %s", tvb_bytes_to_str(tvb, offset+54+xres_len, auth_len));
q_offset = q_offset + q_len + 2;
}
return q_offset;
}
/* GPRS: 9.60 v7.6.0, chapter 7.9.19 page
* UMTS: 29.060 v4.0, chapter 7.7.28 page 57
* TODO: - check if for quintuplets first 2 bytes are length, according to AuthQuint
* - finish displaying last 3 parameters
*/
static int
decode_gtp_mm_cntxt(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
guint16 length, quint_len, net_cap, con_len;
guint8 cksn, count, sec_mode, cipher, trans_id, proto_disc, message, drx_split, drx_len, drx_ccch, non_drx_timer;
proto_tree *ext_tree_mm;
proto_item *te;
te = proto_tree_add_text(tree, tvb, offset, 1, val_to_str(GTP_EXT_MM_CNTXT, gtp_val, "Unknown message"));
ext_tree_mm = proto_item_add_subtree(te, ett_gtp_mm);
length = tvb_get_ntohs(tvb, offset+1);
if (length < 1) return 3;
cksn = tvb_get_guint8(tvb, offset+3) & 0x07;
sec_mode = (tvb_get_guint8(tvb, offset+4) >> 6) & 0x03;
count = (tvb_get_guint8(tvb, offset+4) >> 3) & 0x07;
cipher = tvb_get_guint8(tvb, offset+4) & 0x07;
proto_tree_add_text(ext_tree_mm, tvb, offset+1, 2, "Length: %x", length);
proto_tree_add_text(ext_tree_mm, tvb, offset+3, 1, "Ciphering Key Sequence Number: %u", cksn);
if (gtp_version != 0) {
proto_tree_add_text(ext_tree_mm, tvb, offset+3, 1, "Security type: %u (%s)", sec_mode,
val_to_str(sec_mode, mm_sec_modep, "Unknown"));
} else {
sec_mode = 1;
}
proto_tree_add_text(ext_tree_mm, tvb, offset+4, 1, "No of triplets: %u", count);
switch (sec_mode) {
case 0:
if (cipher == 0) {
proto_tree_add_text(ext_tree_mm, tvb, offset+4, 1, "Ciphering: no ciphering");
} else {
proto_tree_add_text(ext_tree_mm, tvb, offset+4, 1, "Ciphering: GEA/%u", cipher);
}
proto_tree_add_text(ext_tree_mm, tvb, offset+5, 16, "Ciphering key CK: %s", tvb_bytes_to_str(tvb, offset+5, 16));
proto_tree_add_text(ext_tree_mm, tvb, offset+21, 16, "Integrity key CK: %s", tvb_bytes_to_str(tvb, offset+21, 16));
quint_len = tvb_get_ntohs(tvb, offset+37);
proto_tree_add_text(ext_tree_mm, tvb, offset+37, 2, "Quintuplets length: %x", quint_len);
offset = offset + decode_quintuplet(tvb, offset+39, ext_tree_mm, count, 0) + 39;
break;
case 1:
if (cipher == 0) {
proto_tree_add_text(ext_tree_mm, tvb, offset+4, 1, "Ciphering: no ciphering");
} else {
proto_tree_add_text(ext_tree_mm, tvb, offset+4, 1, "Ciphering: GEA/%u", cipher);
}
proto_tree_add_text(ext_tree_mm, tvb, offset+5, 8, "Ciphering key Kc: %s", tvb_bytes_to_str(tvb, offset+5, 8));
offset = offset + decode_triplet(tvb, offset+13, ext_tree_mm, count) + 13;
break;
case 2:
proto_tree_add_text(ext_tree_mm, tvb, offset+5, 16, "Ciphering key CK: %s", tvb_bytes_to_str(tvb, offset+5, 16));
proto_tree_add_text(ext_tree_mm, tvb, offset+21, 16, "Integrity key CK: %s", tvb_bytes_to_str(tvb, offset+21, 16));
quint_len = tvb_get_ntohs(tvb, offset+37);
proto_tree_add_text(ext_tree_mm, tvb, offset+37, 2, "Quintuplets length: %x", quint_len);
offset = offset + decode_quintuplet(tvb, offset+39, ext_tree_mm, count, 0) + 39;
break;
case 3:
if (cipher == 0) {
proto_tree_add_text(ext_tree_mm, tvb, offset+4, 1, "Ciphering: no ciphering");
} else {
proto_tree_add_text(ext_tree_mm, tvb, offset+4, 1, "Ciphering: GEA/%u", cipher);
}
proto_tree_add_text(ext_tree_mm, tvb, offset+5, 8, "Ciphering key Kc: %s", tvb_bytes_to_str(tvb, offset+5, 8));
quint_len = tvb_get_ntohs(tvb, offset+13);
proto_tree_add_text(ext_tree_mm, tvb, offset+13, 2, "Quintuplets length: %x", quint_len);
offset = offset + decode_quintuplet(tvb, offset+15, ext_tree_mm, count, 0) + 15;
break;
default:
break;
}
drx_split = tvb_get_guint8(tvb, offset);
drx_len = (tvb_get_guint8(tvb, offset+1) >> 4) & 0x0F;
drx_ccch = (tvb_get_guint8(tvb, offset+1) >> 3) & 0x01;
non_drx_timer = tvb_get_guint8(tvb, offset+1) & 0x07;
net_cap = tvb_get_ntohs(tvb, offset+2);
con_len = tvb_get_ntohs(tvb, offset+4);
proto_tree_add_text(ext_tree_mm, tvb, offset, 1, "DRX: split PG cycle code: %u", drx_split);
proto_tree_add_text(ext_tree_mm, tvb, offset+1, 1, "DRX: CN specific DRX cycle length coefficient: %u", drx_len);
proto_tree_add_text(ext_tree_mm, tvb, offset+1, 1, "DRX: split PG cycle on CCCH supported by MS: %s", yesno[drx_ccch]);
if (non_drx_timer == 0) {
proto_tree_add_text(ext_tree_mm, tvb, offset+1, 1, "DRX: no non-DRX mode after transfer state");
} else {
proto_tree_add_text(ext_tree_mm, tvb, offset+1, 1, "DRX: max sec non-DRX mode after transfer state: 2^%u", non_drx_timer-1);
}
proto_tree_add_text(ext_tree_mm, tvb, offset+2, 2, "MS network capability: %u", net_cap);
proto_tree_add_text(ext_tree_mm, tvb, offset+4, 2, "Container length: %u", con_len);
if (con_len > 0) {
trans_id = (tvb_get_guint8(tvb, offset+6) >> 4) & 0x0F;
proto_tree_add_text(ext_tree_mm, tvb, offset+6, 1, "Transaction identifier: 0x%x", trans_id);
proto_disc = tvb_get_guint8(tvb, offset+6) & 0x0F;
proto_tree_add_text(ext_tree_mm, tvb, offset+6, 1, "Protocol discriminator: 0x%x (%s)", proto_disc,
val_to_str(proto_disc, mm_proto_disc, "Unknown"));
message = tvb_get_guint8(tvb, offset+7);
switch (message) {
case MM_PROTO_RR_MGMT:
proto_tree_add_text(ext_tree_mm, tvb, offset+7, 1, "Message type: 0x%02x (%s)", message,
val_to_str(message, mm_rr_mess, "Unknown"));
break;
case MM_PROTO_MM_NON_GPRS:
proto_tree_add_text(ext_tree_mm, tvb, offset+7, 1, "Message type: 0x%02x (%s)", message,
val_to_str(message, mm_mm_mess, "Unknown"));
break;
case MM_PROTO_CALL_CONTROL:
case MM_PROTO_GROUP_CALL_CONTROL:
case MM_PROTO_BROADCAST_CALL_CONTROL:
proto_tree_add_text(ext_tree_mm, tvb, offset+7, 1, "Message type: 0x%02x (%s)", message,
val_to_str(message, mm_cc_mess, "Unknown"));
break;
case MM_PROTO_MM_GPRS:
proto_tree_add_text(ext_tree_mm, tvb, offset+7, 1, "Message type: 0x%02x (%s)", message,
val_to_str(message, mm_gprs_mess, "Unknown"));
break;
default:
proto_tree_add_text(ext_tree_mm, tvb, offset+7, 1, "Message type: 0x%02x", message);
break;
}
/* XXX - dissect additional IEs from GSM L3 message */
}
return 3+length;
}
/* Function to extract the value of an hexadecimal octet. Only the lower
* nybble will be non-zero in the output.
* */
static guint8 hex2dec (guint8 x)
{
if ((x >= 'a') && (x <= 'f'))
x = x - 'a' + 10;
else if ((x >= 'A') && (x <= 'F'))
x = x - 'A' + 10;
else if ((x >= '0') && (x <= '9'))
x = x - '0';
else
x = 0;
return x;
}
/* Wrapper function to add UTF-8 decoding for QoS attributes in
* RADIUS messages.
* */
static guint8 wrapped_tvb_get_guint8( tvbuff_t *tvb, int offset, int type)
{
if (type == 2)
return (hex2dec(tvb_get_guint8(tvb, offset)) << 4
| hex2dec(tvb_get_guint8(tvb, offset + 1)));
else
return tvb_get_guint8(tvb, offset);
}
/* WARNING : actually length is coded on 2 octets for QoS profile but on 1 octet for PDP Context!
* so type means length of length :-)
*
* WARNING :) type does not mean length of length any more... see below for
* type = 3!
*/
int
decode_qos_umts(tvbuff_t *tvb, int offset, proto_tree *tree, gchar* qos_str, guint8 type) {
guint length;
guint8 al_ret_priority;
guint8 delay, reliability, peak, precedence, mean, spare1, spare2, spare3;
guint8 traf_class, del_order, del_err_sdu;
guint8 max_sdu_size, max_ul, max_dl;
guint8 res_ber, sdu_err_ratio;
guint8 trans_delay, traf_handl_prio;
guint8 guar_ul, guar_dl;
proto_tree *ext_tree_qos;
proto_item *te;
int mss, mu, md, gu, gd;
/* Will keep if the input is UTF-8 encoded (as in RADIUS messages).
* If 1, input is *not* UTF-8 encoded (i.e. each input octet corresponds
* to one byte to be dissected).
* If 2, input is UTF-8 encoded (i.e. each *couple* of input octets
* corresponds to one byte to be dissected)
* */
guint8 utf8_type = 1;
/* In RADIUS messages the QoS has a version field of two octets prepended.
* As of 29.061 v.3.a.0, there is an hyphen between "Release Indicator" and
* <release specific QoS IE UTF-8 encoding>. Even if it sounds rather
* inconsistent and unuseful, I will check hyphen presence here and
* will signal its presence.
* */
guint8 version_buffer[2];
guint8 hyphen;
/* Will keep the value that will be returned
* */
int retval = 0;
switch (type) {
case 1:
length = tvb_get_guint8 (tvb, offset);
te = proto_tree_add_text (tree, tvb, offset, length + 1, "%s", qos_str);
ext_tree_qos = proto_item_add_subtree (te, ett_gtp_qos);
proto_tree_add_text (ext_tree_qos, tvb, offset, 1, "Length: %u", length);
offset++;
retval = length + 1;
break;
case 2:
length = tvb_get_ntohs (tvb, offset + 1);
te = proto_tree_add_text(tree, tvb, offset, length + 3, "%s", qos_str);
ext_tree_qos = proto_item_add_subtree (te, ett_gtp_qos);
proto_tree_add_text (ext_tree_qos, tvb, offset + 1, 2, "Length: %u", length);
offset += 3; /* +1 because of first 0x86 byte for UMTS QoS */
retval = length + 3;
break;
case 3:
/* For QoS inside RADIUS Client messages from GGSN */
utf8_type = 2;
/* The field in the RADIUS message starts one byte before :) */
length = tvb_get_guint8 (tvb, offset);
te = proto_tree_add_text (tree, tvb, offset - 1, length, "%s", qos_str);
ext_tree_qos = proto_item_add_subtree (te, ett_gtp_qos);
version_buffer[0] = tvb_get_guint8(tvb, offset + 1);
version_buffer[1] = tvb_get_guint8(tvb, offset + 2);
proto_tree_add_text (ext_tree_qos, tvb, offset + 1, 2, "Version: %c%c", version_buffer[0], version_buffer[1]);
/* Hyphen handling */
hyphen = tvb_get_guint8(tvb, offset + 3);
if (hyphen == ((guint8) '-'))
{
/* Hyphen is present, put in protocol tree */
proto_tree_add_text (ext_tree_qos, tvb, offset + 3, 1, "Hyphen separator: -");
offset++; /* "Get rid" of hyphen */
}
/* Now, we modify offset here and in order to use type later
* effectively.*/
offset += 2;
retval = length + 3; /* Actually, will be ignored. */
break;
default:
/* XXX - what should we do with the length here? */
length = 0;
retval = 0;
ext_tree_qos = NULL;
break;
}
/* In RADIUS messages there is no allocation-retention priority
* so I don't need to wrap the following call to tvb_get_guint8
* */
al_ret_priority = tvb_get_guint8 (tvb, offset);
/* All calls are wrapped to take into account the possibility that the
* input is UTF-8 encoded. If utf8_type is equal to 1, the final value
* of the offset will be the same as in the previous version of this
* dissector, and the wrapped function will serve as a dumb wrapper;
* otherwise, if utf_8_type is 2, the offset is correctly shifted by
* two bytes for needed shift, and the wrapped function will unencode
* two values from the input.
* */
spare1 = wrapped_tvb_get_guint8(tvb, offset+(1 - 1) * utf8_type + 1, utf8_type) & 0xC0;
delay = wrapped_tvb_get_guint8(tvb, offset+(1 - 1) * utf8_type + 1, utf8_type) & 0x38;
reliability = wrapped_tvb_get_guint8(tvb, offset+(1 - 1) * utf8_type + 1, utf8_type) & 0x07;
peak = wrapped_tvb_get_guint8(tvb, offset+(2 - 1) * utf8_type + 1, utf8_type) & 0xF0;
spare2 = wrapped_tvb_get_guint8(tvb, offset+(2 - 1) * utf8_type + 1, utf8_type) & 0x08;
precedence = wrapped_tvb_get_guint8(tvb, offset+(2 - 1) * utf8_type + 1, utf8_type) & 0x07;
spare3 = wrapped_tvb_get_guint8(tvb, offset+(3 - 1) * utf8_type + 1, utf8_type) & 0xE0;
mean = wrapped_tvb_get_guint8(tvb, offset+(3 - 1) * utf8_type + 1, utf8_type) & 0x1F;
/* In RADIUS messages there is no allocation-retention priority */
if (type != 3)
proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_al_ret_priority, tvb, offset, 1, al_ret_priority);
/* All additions must take care of the fact that QoS fields in RADIUS
* messages are UTF-8 encoded, so we have to use the same trick as above.
* */
proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_spare1, tvb, offset+(1 - 1) * utf8_type + 1, utf8_type, spare1);
proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_delay, tvb, offset+(1 - 1) * utf8_type + 1, utf8_type, delay);
proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_reliability, tvb, offset+(1 - 1) * utf8_type + 1, utf8_type, reliability);
proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_peak, tvb, offset+(2 - 1) * utf8_type + 1, utf8_type, peak);
proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_spare2, tvb, offset+(2 - 1) * utf8_type + 1, utf8_type, spare2);
proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_precedence, tvb, offset+(2 - 1) * utf8_type + 1, utf8_type, precedence);
proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_spare3, tvb, offset+(3 - 1) * utf8_type + 1, utf8_type, spare3);
proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_mean, tvb, offset+(3 - 1) * utf8_type + 1, utf8_type, mean);
if (length > 4) {
/* See above for the need of wrapping
* */
traf_class = wrapped_tvb_get_guint8(tvb, offset+(4 - 1) * utf8_type + 1, utf8_type) & 0xE0;
del_order = wrapped_tvb_get_guint8(tvb, offset+(4 - 1) * utf8_type + 1, utf8_type) & 0x18;
del_err_sdu = wrapped_tvb_get_guint8(tvb, offset+(4 - 1) * utf8_type + 1, utf8_type) & 0x07;
max_sdu_size = wrapped_tvb_get_guint8(tvb, offset+(5 - 1) * utf8_type + 1, utf8_type);
max_ul = wrapped_tvb_get_guint8(tvb, offset+(6 - 1) * utf8_type + 1, utf8_type);
max_dl = wrapped_tvb_get_guint8(tvb, offset+(7 - 1) * utf8_type + 1, utf8_type);
res_ber = wrapped_tvb_get_guint8(tvb, offset+(8 - 1) * utf8_type + 1, utf8_type) & 0xF0;
sdu_err_ratio = wrapped_tvb_get_guint8(tvb, offset+(8 - 1) * utf8_type + 1, utf8_type) & 0x0F;
trans_delay = wrapped_tvb_get_guint8(tvb, offset+(9 - 1) * utf8_type + 1, utf8_type) & 0xFC;
traf_handl_prio = wrapped_tvb_get_guint8(tvb, offset+(9 - 1) * utf8_type + 1, utf8_type) & 0x03;
guar_ul = wrapped_tvb_get_guint8(tvb, offset+(10 - 1) * utf8_type + 1, utf8_type);
guar_dl = wrapped_tvb_get_guint8(tvb, offset+(11 - 1) * utf8_type + 1, utf8_type);
/* See above comments for the changes
* */
proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_traf_class, tvb, offset+(4 - 1) * utf8_type + 1, utf8_type, traf_class);
proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_del_order, tvb, offset+(4 - 1) * utf8_type + 1, utf8_type, del_order);
proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_del_err_sdu, tvb, offset+(4 - 1) * utf8_type + 1, utf8_type, del_err_sdu);
if (max_sdu_size == 0 || max_sdu_size > 150)
proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_max_sdu_size, tvb, offset+(5 - 1) * utf8_type + 1, utf8_type, max_sdu_size);
if (max_sdu_size > 0 && max_sdu_size <= 150) {
mss = max_sdu_size*10;
proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_max_sdu_size, tvb, offset+(5 - 1) * utf8_type + 1, utf8_type, mss, "Maximum SDU size : %u octets", mss);
}
if(max_ul == 0 || max_ul == 255)
proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_max_ul, tvb, offset+(6 - 1) * utf8_type + 1, utf8_type, max_ul);
if(max_ul > 0 && max_ul <= 63)
proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_max_ul, tvb, offset+(6 - 1) * utf8_type + 1, utf8_type, max_ul, "Maximum bit rate for uplink : %u kbps", max_ul);
if(max_ul > 63 && max_ul <=127) {
mu = 64 + ( max_ul - 64 ) * 8;
proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_max_ul, tvb, offset+(6 - 1) * utf8_type + 1, utf8_type, mu, "Maximum bit rate for uplink : %u kbps", mu);
}
if(max_ul > 127 && max_ul <=254) {
mu = 576 + ( max_ul - 128 ) * 64;
proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_max_ul, tvb, offset+(6 - 1) * utf8_type + 1, utf8_type, mu, "Maximum bit rate for uplink : %u kbps", mu);
}
if(max_dl == 0 || max_dl == 255)
proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_max_dl, tvb, offset+(7 - 1) * utf8_type + 1, utf8_type, max_dl);
if(max_dl > 0 && max_dl <= 63)
proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_max_dl, tvb, offset+(7 - 1) * utf8_type + 1, utf8_type, max_dl, "Maximum bit rate for downlink : %u kbps", max_dl);
if(max_dl > 63 && max_dl <=127) {
md = 64 + ( max_dl - 64 ) * 8;
proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_max_dl, tvb, offset+(7 - 1) * utf8_type + 1, utf8_type, md, "Maximum bit rate for downlink : %u kbps", md);
}
if(max_dl > 127 && max_dl <=254) {
md = 576 + ( max_dl - 128 ) * 64;
proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_max_dl, tvb, offset+(7 - 1) * utf8_type + 1, utf8_type, md, "Maximum bit rate for downlink : %u kbps", md);
}
proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_res_ber, tvb, offset+(8 - 1) * utf8_type + 1, utf8_type, res_ber);
proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_sdu_err_ratio, tvb, offset+(8 - 1) * utf8_type + 1, utf8_type, sdu_err_ratio);
proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_trans_delay, tvb, offset+(9 - 1) * utf8_type + 1, utf8_type, trans_delay);
proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_traf_handl_prio, tvb, offset+(9 - 1) * utf8_type + 1, utf8_type, traf_handl_prio);
if(guar_ul == 0 || guar_ul == 255)
proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_guar_ul, tvb, offset+(10 - 1) * utf8_type + 1, utf8_type, guar_ul);
if(guar_ul > 0 && guar_ul <= 63)
proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_guar_ul, tvb, offset+(10 - 1) * utf8_type + 1, utf8_type, guar_ul, "Guaranteed bit rate for uplink : %u kbps", guar_ul);
if(guar_ul > 63 && guar_ul <=127) {
gu = 64 + ( guar_ul - 64 ) * 8;
proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_guar_ul, tvb, offset+(10 - 1) * utf8_type + 1, utf8_type, gu, "Guaranteed bit rate for uplink : %u kbps", gu);
}
if(guar_ul > 127 && guar_ul <=254) {
gu = 576 + ( guar_ul - 128 ) * 64;
proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_guar_ul, tvb, offset+(10 - 1) * utf8_type + 1, utf8_type, gu, "Guaranteed bit rate for uplink : %u kbps", gu);
}
if(guar_dl == 0 || guar_dl == 255)
proto_tree_add_uint(ext_tree_qos, hf_gtp_qos_guar_dl, tvb, offset+(11 - 1) * utf8_type + 1, utf8_type, guar_dl);
if(guar_dl > 0 && guar_dl <= 63)
proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_guar_dl, tvb, offset+(11 - 1) * utf8_type + 1, utf8_type, guar_dl, "Guaranteed bit rate for downlink : %u kbps", guar_dl);
if(guar_dl > 63 && guar_dl <=127) {
gd = 64 + ( guar_dl - 64 ) * 8;
proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_guar_dl, tvb, offset+(11 - 1) * utf8_type + 1, utf8_type, gd, "Guaranteed bit rate for downlink : %u kbps", gd);
}
if(guar_dl > 127 && guar_dl <=254) {
gd = 576 + ( guar_dl - 128 ) * 64;
proto_tree_add_uint_format(ext_tree_qos, hf_gtp_qos_guar_dl, tvb, offset+(11 - 1) * utf8_type + 1, utf8_type, gd, "Guaranteed bit rate for downlink : %u kbps", gd);
}
}
return retval;
}
static void
decode_apn(tvbuff_t *tvb, int offset, guint16 length, proto_tree *tree) {
gchar *apn = NULL;
guint8 name_len, tmp;
if (length > 0) {
name_len = tvb_get_guint8 (tvb, offset);
if (name_len < 0x20) {
apn = tvb_get_string(tvb, offset + 1, length);
tvb_memcpy (tvb, apn, offset + 1, length);
for (;;) {
if (name_len >= length - 1) break;
tmp = name_len;
name_len = name_len + apn[tmp] + 1;
apn[tmp] = '.';
}
} else
apn = tvb_get_string(tvb, offset, length);
proto_tree_add_string (tree, hf_gtp_apn, tvb, offset, length, apn);
g_free(apn);
}
}
/* GPRS: 9.60 v7.6.0, chapter 7.9.20
* UMTS: 29.060 v4.0, chapter 7.7.29
* TODO: unify addr functions
*/
static int
decode_gtp_pdp_cntxt(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
guint8 ggsn_addr_len, apn_len, trans_id, vaa, order, nsapi, sapi, pdu_send_no, pdu_rec_no, pdp_cntxt_id,
pdp_type_org, pdp_type_num, pdp_addr_len;
guint16 length, sn_down, sn_up, up_flow;
guint32 addr_ipv4, up_teid, up_teid_cp;
struct e_in6_addr addr_ipv6;
proto_tree *ext_tree_pdp;
proto_item *te;
length = tvb_get_ntohs(tvb, offset+1);
te = proto_tree_add_text(tree, tvb, offset, length+3, val_to_str(GTP_EXT_PDP_CNTXT, gtp_val, "Unknown message"));
ext_tree_pdp = proto_item_add_subtree(te, ett_gtp_pdp);
vaa = (tvb_get_guint8(tvb, offset+3) >> 6) & 0x01;
order = (tvb_get_guint8(tvb, offset+3) >> 4) & 0x01;
nsapi = tvb_get_guint8(tvb, offset+3) & 0x0F;
sapi = tvb_get_guint8(tvb, offset+4) & 0x0F;
proto_tree_add_text(ext_tree_pdp, tvb, offset+3, 1, "VPLMN address allowed: %s", yesno[vaa]);
proto_tree_add_text(ext_tree_pdp, tvb, offset+3, 1, "Reordering required: %s", yesno[order]);
proto_tree_add_text(ext_tree_pdp, tvb, offset+3, 1, "NSAPI: %u", nsapi);
proto_tree_add_text(ext_tree_pdp, tvb, offset+4, 1, "SAPI: %u", sapi);
switch (gtp_version) {
case 0:
decode_qos_gprs(tvb, offset+5, ext_tree_pdp, "QoS subscribed", 0);
decode_qos_gprs(tvb, offset+8, ext_tree_pdp, "QoS requested", 0);
decode_qos_gprs(tvb, offset+11, ext_tree_pdp, "QoS negotiated", 0);
offset = offset + 14;
break;
case 1:
offset = offset + 5;
offset = offset + decode_qos_umts(tvb, offset, ext_tree_pdp, "QoS subscribed", 1);
offset = offset + decode_qos_umts(tvb, offset, ext_tree_pdp, "QoS requested", 1);
offset = offset + decode_qos_umts(tvb, offset, ext_tree_pdp, "QoS negotiated", 1);
break;
default:
break;
}
sn_down = tvb_get_ntohs(tvb, offset);
sn_up = tvb_get_ntohs(tvb, offset+2);
pdu_send_no = tvb_get_guint8(tvb, offset+4);
pdu_rec_no = tvb_get_guint8(tvb, offset+5);
proto_tree_add_text(ext_tree_pdp, tvb, offset, 2, "Sequence number down: %u", sn_down);
proto_tree_add_text(ext_tree_pdp, tvb, offset+2, 2, "Sequence number up: %u", sn_up);
proto_tree_add_text(ext_tree_pdp, tvb, offset+4, 1, "Send N-PDU number: %u", pdu_send_no);
proto_tree_add_text(ext_tree_pdp, tvb, offset+5, 1, "Receive N-PDU number: %u", pdu_rec_no);
switch (gtp_version) {
case 0:
up_flow = tvb_get_ntohs(tvb, offset+6);
proto_tree_add_text(ext_tree_pdp, tvb, offset+6, 2, "Uplink flow label signalling: %u", up_flow);
offset = offset + 8;
break;
case 1:
up_teid = tvb_get_ntohl(tvb, offset+6);
up_teid_cp = tvb_get_ntohl(tvb, offset+10);
pdp_cntxt_id = tvb_get_guint8(tvb, offset+14);
proto_tree_add_text(ext_tree_pdp, tvb, offset+6, 4, "Uplink TEID: %x", up_teid);
proto_tree_add_text(ext_tree_pdp, tvb, offset+10, 4, "Uplink TEID control plane: %x", up_teid_cp);
proto_tree_add_text(ext_tree_pdp, tvb, offset+14, 1, "PDP context identifier: %u", pdp_cntxt_id);
offset = offset + 15;
break;
default:
break;
}
pdp_type_org = tvb_get_guint8(tvb, offset) & 0x0F;
pdp_type_num = tvb_get_guint8(tvb, offset+1);
pdp_addr_len = tvb_get_guint8(tvb, offset+2);
proto_tree_add_text(ext_tree_pdp, tvb, offset, 1, "PDP organization: %s", val_to_str(pdp_type_org, pdp_type, "Unknown PDP org"));
proto_tree_add_text(ext_tree_pdp, tvb, offset+1, 1, "PDP type: %s", val_to_str(pdp_type_num, pdp_org_type, "Unknown PDP type"));
proto_tree_add_text(ext_tree_pdp, tvb, offset+2, 1, "PDP address length: %u", pdp_addr_len);
if (pdp_addr_len > 0) {
switch (pdp_type_num) {
case 0x21:
tvb_memcpy(tvb, (guint8 *)&addr_ipv4, offset+3, sizeof addr_ipv4);
proto_tree_add_text(ext_tree_pdp, tvb, offset+3, 4, "PDP address: %s", ip_to_str((guint8 *)&addr_ipv4));
break;
case 0x57:
tvb_memcpy(tvb, (guint8 *)&addr_ipv6, offset+3, sizeof addr_ipv6);
proto_tree_add_text(ext_tree_pdp, tvb, offset+3, 16, "PDP address: %s", ip6_to_str((struct e_in6_addr*)&addr_ipv6));
break;
default:
break;
}
}
offset = offset + 3 + pdp_addr_len;
ggsn_addr_len = tvb_get_guint8(tvb, offset);
proto_tree_add_text(ext_tree_pdp, tvb, offset, 1, "GGSN address length: %u", ggsn_addr_len);
switch (ggsn_addr_len) {
case 4:
tvb_memcpy(tvb, (guint8 *)&addr_ipv4, offset+1, sizeof addr_ipv4);
proto_tree_add_text(ext_tree_pdp, tvb, offset+1, 4, "GGSN address: %s", ip_to_str((guint8 *)&addr_ipv4));
break;
case 16:
tvb_memcpy(tvb, (guint8 *)&addr_ipv6, offset+1, sizeof addr_ipv6);
proto_tree_add_text(ext_tree_pdp, tvb, offset+1, 16, "GGSN address: %s", ip6_to_str((struct e_in6_addr*)&addr_ipv6));
break;
default:
break;
}
offset = offset + 1 + ggsn_addr_len;
if (gtp_version == 1) {
ggsn_addr_len = tvb_get_guint8(tvb, offset);
proto_tree_add_text(ext_tree_pdp, tvb, offset, 1, "GGSN 2 address length: %u", ggsn_addr_len);
switch (ggsn_addr_len) {
case 4:
tvb_memcpy(tvb, (guint8 *)&addr_ipv4, offset+1, sizeof addr_ipv4);
proto_tree_add_text(ext_tree_pdp, tvb, offset+1, 4, "GGSN 2 address: %s", ip_to_str((guint8 *)&addr_ipv4));
break;
case 16:
tvb_memcpy(tvb, (guint8 *)&addr_ipv6, offset+1, sizeof addr_ipv6);
proto_tree_add_text(ext_tree_pdp, tvb, offset+1, 16, "GGSN 2 address: %s", ip6_to_str((struct e_in6_addr*)&addr_ipv6));
break;
default:
break;
}
offset = offset + 1 + ggsn_addr_len;
}
apn_len = tvb_get_guint8(tvb, offset);
proto_tree_add_text(ext_tree_pdp, tvb, offset, 1, "APN length: %u", apn_len);
decode_apn(tvb, offset+1, apn_len, ext_tree_pdp);
offset = offset + 1 + apn_len;
trans_id = tvb_get_guint8(tvb, offset);
proto_tree_add_text(ext_tree_pdp, tvb, offset, 1, "Transaction identifier: %u", trans_id);
return 3+length;
}
/* GPRS: 9.60, v7.6.0, chapter 7.9.21
* UMTS: 29.060, v4.0, chapter 7.7.30
*/
static int
decode_gtp_apn(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
guint16 length;
proto_tree *ext_tree_apn;
proto_item *te;
length = tvb_get_ntohs(tvb, offset+1);
te = proto_tree_add_text (tree, tvb, offset, length+3, val_to_str(GTP_EXT_APN, gtp_val, "Unknown field"));
ext_tree_apn = proto_item_add_subtree(te, ett_gtp_apn);
proto_tree_add_text (ext_tree_apn, tvb, offset+1, 2, "APN length : %u", length);
decode_apn (tvb, offset+3, length, ext_tree_apn);
return 3+length;
}
/* GPRS: 9.60 v7.6.0, chapter 7.9.22
* 4.08 v. 7.1.2, chapter 10.5.6.3 (p.580)
* UMTS: 29.060 v4.0, chapter 7.7.31
* 24.008, v4.2, chapter 10.5.6.3
*/
int
decode_gtp_proto_conf(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree) {
guint16 length, proto_offset;
guint16 proto_id;
guint8 conf, proto_len, cnt = 1;
tvbuff_t *next_tvb;
proto_tree *ext_tree_proto;
proto_item *te;
gboolean save_writable;
length = tvb_get_ntohs(tvb, offset + 1);
te = proto_tree_add_text(tree, tvb, offset, length + 3, val_to_str(GTP_EXT_PROTO_CONF, gtp_val, "Unknown message"));
ext_tree_proto = proto_item_add_subtree(te, ett_gtp_proto);
proto_tree_add_text(ext_tree_proto, tvb, offset + 1, 2, "Length: %u", length);
if (length < 1) return 3;
conf = tvb_get_guint8 (tvb, offset + 3) & 0x07;
proto_tree_add_text (ext_tree_proto, tvb, offset + 3, 1, "Configuration protocol (00000xxx): %u", conf);
proto_offset = 1; /* ... 1st byte is conf */
offset += 4;
for (;;) {
if (proto_offset >= length) break;
proto_id = tvb_get_ntohs (tvb, offset);
proto_len = tvb_get_guint8 (tvb, offset + 2);
proto_offset += proto_len + 3; /* 3 = proto id + length byte */
if (proto_len > 0) {
proto_tree_add_text (ext_tree_proto, tvb, offset, 2, "Protocol %u ID: %s (0x%04x)",
cnt, val_to_str(proto_id, ppp_vals, "Unknown"),
proto_id);
proto_tree_add_text (ext_tree_proto, tvb, offset+2, 1, "Protocol %u length: %u", cnt, proto_len);
/*
* Don't allow the dissector for the configuration
* protocol in question to update the columns - this
* is GTP, not PPP.
*/
save_writable = col_get_writable(pinfo->cinfo);
col_set_writable(pinfo->cinfo, FALSE);
/*
* XXX - should we have our own dissector table,
* solely for configuration protocols, so that bogus
* values don't cause us to dissect the protocol
* data as, for example, IP?
*/
next_tvb = tvb_new_subset (tvb, offset + 3, proto_len, proto_len);
if (!dissector_try_port(ppp_subdissector_table,
proto_id, next_tvb, pinfo, ext_tree_proto)) {
call_dissector(data_handle, next_tvb, pinfo,
ext_tree_proto);
}
col_set_writable(pinfo->cinfo, save_writable);
}
offset += proto_len + 3;
cnt++;
}
return 3 + length;
}
/* GPRS: 9.60 v7.6.0, chapter 7.9.23
* UMTS: 29.060 v4.0, chapter 7.7.32
*/
static int
decode_gtp_gsn_addr(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
guint8 addr_type, addr_len;
guint16 length;
guint32 addr_ipv4;
struct e_in6_addr addr_ipv6;
proto_tree *ext_tree_gsn_addr;
proto_item *te;
length = tvb_get_ntohs(tvb, offset+1);
te = proto_tree_add_text(tree, tvb, offset, 3+length, "GSN address : ");
ext_tree_gsn_addr = proto_item_add_subtree(te, ett_gtp_gsn_addr);
switch (length) {
case 4:
proto_tree_add_text(ext_tree_gsn_addr, tvb, offset+1, 2, "GSN address length : %u", length);
tvb_memcpy(tvb, (guint8 *)&addr_ipv4, offset+3, sizeof addr_ipv4);
proto_item_append_text(te, "%s", ip_to_str((guint8 *)&addr_ipv4));
proto_tree_add_ipv4(ext_tree_gsn_addr, hf_gtp_gsn_ipv4, tvb, offset+3, 4, addr_ipv4);
break;
case 5:
proto_tree_add_text(ext_tree_gsn_addr, tvb, offset+1, 2, "GSN address Information Element length : %u", length);
addr_type = tvb_get_guint8(tvb, offset+3) & 0xC0;
proto_tree_add_uint(ext_tree_gsn_addr, hf_gtp_gsn_addr_type, tvb, offset+3, 1, addr_type);
addr_len = tvb_get_guint8(tvb, offset+3) & 0x3F;
proto_tree_add_uint(ext_tree_gsn_addr, hf_gtp_gsn_addr_len, tvb, offset+3, 1, addr_len);
tvb_memcpy(tvb, (guint8 *)&addr_ipv4, offset+4, sizeof addr_ipv4);
proto_item_append_text(te, "%s", ip_to_str((guint8 *)&addr_ipv4));
proto_tree_add_ipv4(ext_tree_gsn_addr, hf_gtp_gsn_ipv4, tvb, offset+4, 4, addr_ipv4);
break;
case 16:
proto_tree_add_text(ext_tree_gsn_addr, tvb, offset+1, 2, "GSN address length : %u", length);
tvb_memcpy(tvb, (guint8 *)&addr_ipv6, offset+3, sizeof addr_ipv6);
proto_item_append_text(te, "%s", ip6_to_str((struct e_in6_addr*)&addr_ipv6));
proto_tree_add_ipv6(ext_tree_gsn_addr, hf_gtp_gsn_ipv6, tvb, offset+3, 16, (guint8*)&addr_ipv6);
break;
case 17:
proto_tree_add_text(ext_tree_gsn_addr, tvb, offset+1, 2, "GSN address Information Element length : %u", length);
addr_type = tvb_get_guint8(tvb, offset+3) & 0xC0;
proto_tree_add_uint(ext_tree_gsn_addr, hf_gtp_gsn_addr_type, tvb, offset+3, 1, addr_type);
addr_len = tvb_get_guint8(tvb, offset+3) & 0x3F;
proto_tree_add_uint(ext_tree_gsn_addr, hf_gtp_gsn_addr_len, tvb, offset+3, 1, addr_len);
tvb_memcpy(tvb, (guint8 *)&addr_ipv6, offset+4, sizeof addr_ipv6);
proto_item_append_text(te, "%s", ip6_to_str((struct e_in6_addr*)&addr_ipv6));
proto_tree_add_ipv6(ext_tree_gsn_addr, hf_gtp_gsn_ipv6, tvb, offset+4, 16, (guint8*)&addr_ipv6);
break;
default:
proto_item_append_text(te, "unknown type or wrong length");
break;
}
return 3+length;
}
/* GPRS: 9.60 v7.6.0, chapter 7.9.24
* UMTS: 29.060 v4.0, chapter 7.7.33
*/
static int
decode_gtp_msisdn(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
const guint8 *msisdn_val;
gchar *msisdn_str;
guint16 length;
length = tvb_get_ntohs(tvb, offset+1);
if (length < 1) return 3;
msisdn_val = tvb_get_ptr(tvb, offset+3, length);
msisdn_str = msisdn_to_str(msisdn_val, length);
proto_tree_add_string(tree, hf_gtp_msisdn, tvb, offset, 3+length, msisdn_str);
return 3+length;
}
/* GPRS: not present
* UMTS: 29.060 v4.0, chapter 7.7.34
* 24.008 v4.2, chapter 10.5.6.5
*/
static int
decode_gtp_qos_umts(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
return decode_qos_umts(tvb, offset, tree, "Quality of Service", 2);
}
/* GPRS: not present
* UMTS: 29.060 v4.0, chapter 7.7.35
*/
static int
decode_gtp_auth_qui(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
return (1 + decode_quintuplet(tvb, offset+1, tree, 1, 1));
}
/* GPRS: not present
* UMTS: 29.060 v4.0, chapter 7.7.36
* 24.008 v4.2, chapter 10.5.6.12
*/
static int
decode_gtp_tft(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
guint16 length, port1, port2, tos;
guint8 tft_flags, tft_code, no_packet_filters, i, pf_id, pf_eval, pf_len, pf_content_id, proto, spare;
guint pf_offset;
guint32 mask_ipv4, addr_ipv4, ipsec_id, label;
struct e_in6_addr addr_ipv6, mask_ipv6;
proto_tree *ext_tree_tft, *ext_tree_tft_pf, *ext_tree_tft_flags;
proto_item *te, *tee, *tef;
length = tvb_get_ntohs(tvb, offset+1);
te = proto_tree_add_text(tree, tvb, offset, 3+length, "Traffic flow template");
ext_tree_tft = proto_item_add_subtree(te, ett_gtp_tft);
tft_flags = tvb_get_guint8(tvb, offset+3);
tft_code = (tft_flags >> 5) & 0x07;
spare = (tft_flags >> 4) & 0x01;
no_packet_filters = tft_flags & 0x0F;
proto_tree_add_text(ext_tree_tft, tvb, offset+1, 2, "TFT length: %u", length);
tef = proto_tree_add_text (ext_tree_tft, tvb, offset + 3, 1, "TFT flags");
ext_tree_tft_flags = proto_item_add_subtree (tef, ett_gtp_tft_flags);
proto_tree_add_uint (ext_tree_tft_flags, hf_gtp_tft_code, tvb, offset + 3, 1, tft_flags);
proto_tree_add_uint (ext_tree_tft_flags, hf_gtp_tft_spare, tvb, offset + 3, 1, tft_flags);
proto_tree_add_uint (ext_tree_tft_flags, hf_gtp_tft_number, tvb, offset + 3, 1, tft_flags);
offset = offset + 4;
for (i=0;i<no_packet_filters;i++) {
pf_id = tvb_get_guint8(tvb, offset);
tee = proto_tree_add_text (ext_tree_tft, tvb, offset, 1, "Packet filter id: %u", pf_id);
ext_tree_tft_pf = proto_item_add_subtree (tee, ett_gtp_tft_pf);
offset++;
if (tft_code != 2) {
pf_eval = tvb_get_guint8(tvb, offset);
pf_len = tvb_get_guint8(tvb, offset + 1);
proto_tree_add_uint (ext_tree_tft_pf, hf_gtp_tft_eval, tvb, offset, 1, pf_eval);
proto_tree_add_text (ext_tree_tft_pf, tvb, offset+1, 1, "Content length: %u", pf_len);
offset = offset + 2;
pf_offset = 0;
while (pf_offset < pf_len) {
pf_content_id = tvb_get_guint8 (tvb, offset + pf_offset);
switch (pf_content_id) {
/* address IPv4 and mask = 8 bytes*/
case 0x10:
tvb_memcpy (tvb, (guint8 *)&addr_ipv4, offset + pf_offset + 1, sizeof addr_ipv4);
tvb_memcpy (tvb, (guint8 *)&mask_ipv4, offset + pf_offset + 5, sizeof mask_ipv4);
proto_tree_add_text (ext_tree_tft_pf, tvb, offset + pf_offset, 9, "ID 0x10: IPv4/mask: %s/%s", ip_to_str ((guint8 *)&addr_ipv4), ip_to_str ((guint8 *)&mask_ipv4));
pf_offset = pf_offset + 9;
break;
/* address IPv6 and mask = 32 bytes*/
case 0x20:
tvb_memcpy (tvb, (guint8 *)&addr_ipv6, offset+pf_offset+1, sizeof addr_ipv6);
tvb_memcpy (tvb, (guint8 *)&mask_ipv6, offset+pf_offset+17, sizeof mask_ipv6);
proto_tree_add_text (ext_tree_tft_pf, tvb, offset+pf_offset, 33, "ID 0x20: IPv6/mask: %s/%s", ip6_to_str ((struct e_in6_addr*)&addr_ipv6), ip6_to_str ((struct e_in6_addr*)&mask_ipv6));
pf_offset = pf_offset + 33;
break;
/* protocol identifier/next header type = 1 byte*/
case 0x30:
proto = tvb_get_guint8 (tvb, offset + pf_offset + 1);
proto_tree_add_text (ext_tree_tft_pf, tvb, offset + pf_offset, 2, "ID 0x30: IPv4 protocol identifier/IPv6 next header: %u (%x)", proto, proto);
pf_offset = pf_offset + 2;
break;
/* single destination port type = 2 bytes */
case 0x40:
port1 = tvb_get_ntohs (tvb, offset + pf_offset + 1);
proto_tree_add_text (ext_tree_tft_pf, tvb, offset + pf_offset, 3, "ID 0x40: destination port: %u", port1);
pf_offset = pf_offset + 3;
break;
/* destination port range type = 4 bytes */
case 0x41:
port1 = tvb_get_ntohs (tvb, offset + pf_offset + 1);
port2 = tvb_get_ntohs (tvb, offset + pf_offset + 3);
proto_tree_add_text (ext_tree_tft_pf, tvb, offset + pf_offset, 5, "ID 0x41: destination port range: %u - %u", port1, port2);
pf_offset = pf_offset + 5;
break;
/* single source port type = 2 bytes */
case 0x50:
port1 = tvb_get_ntohs (tvb, offset + pf_offset + 1);
proto_tree_add_text (ext_tree_tft_pf, tvb, offset + pf_offset, 3, "ID 0x50: source port: %u", port1);
pf_offset = pf_offset + 3;
break;
/* source port range type = 4 bytes */
case 0x51:
port1 = tvb_get_ntohs (tvb, offset + pf_offset + 1);
port2 = tvb_get_ntohs (tvb, offset + pf_offset + 3);
proto_tree_add_text (ext_tree_tft_pf, tvb, offset + pf_offset, 5, "ID 0x51: source port range: %u - %u", port1, port2);
pf_offset = pf_offset + 5;
break;
/* security parameter index type = 4 bytes */
case 0x60:
ipsec_id = tvb_get_ntohl (tvb, offset + pf_offset + 1);
proto_tree_add_text (ext_tree_tft_pf, tvb, offset + pf_offset, 5, "ID 0x60: security parameter index: %x", ipsec_id);
pf_offset = pf_offset + 5;
break;
/* type of service/traffic class type = 2 bytes */
case 0x70:
tos = tvb_get_ntohs (tvb, offset + pf_offset + 1);
proto_tree_add_text (ext_tree_tft_pf, tvb, offset + pf_offset, 2, "ID 0x70: Type of Service/Traffic Class: %u (%x)", tos, tos);
pf_offset = pf_offset + 3;
break;
/* flow label type = 3 bytes */
case 0x80:
label = tvb_get_ntoh24(tvb, offset + pf_offset + 1) & 0x0FFFFF;
proto_tree_add_text (ext_tree_tft_pf, tvb, offset + pf_offset, 4, "ID 0x80: Flow Label: %u (%x)", label, label);
pf_offset = pf_offset + 4;
break;
default:
proto_tree_add_text (ext_tree_tft_pf, tvb, offset + pf_offset, 1, "Unknown value: %x ", pf_content_id);
pf_offset++; /* to avoid infinite loop */
break;
}
}
offset = offset + pf_offset;
}
}
return 3 + length;
}
/* GPRS: not present
* UMTS: 29.060 v4.0, chapter 7.7.37
* 25.413 v3.4, chapter ???
*/
static int
decode_gtp_target_id(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
guint16 length;
length = tvb_get_ntohs(tvb, offset + 1);
proto_tree_add_text(tree, tvb, offset, 3 + length, "Targer Identification");
return 3 + length;
}
/* GPRS: not present
* UMTS: 29.060 v4.0, chapter 7.7.38
*/
static int
decode_gtp_utran_cont(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
guint16 length;
length = tvb_get_ntohs(tvb, offset + 1);
proto_tree_add_text(tree, tvb, offset, 3 + length, "UTRAN transparent field");
return 3 + length;
}
/* GPRS: not present
* UMTS: 29.060 v4.0, chapter 7.7.39
*/
static int
decode_gtp_rab_setup(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
guint32 teid, addr_ipv4;
guint16 length;
guint8 nsapi;
struct e_in6_addr addr_ipv6;
proto_tree *ext_tree_rab_setup;
proto_item *te;
length = tvb_get_ntohs(tvb, offset + 1);
nsapi = tvb_get_guint8(tvb, offset + 3) & 0x0F;
te = proto_tree_add_text(tree, tvb, offset, 3+length, "Radio Access Bearer Setup Information");
ext_tree_rab_setup = proto_item_add_subtree(te, ett_gtp_rab_setup);
proto_tree_add_text(ext_tree_rab_setup, tvb, offset+1, 2, "RAB setup length : %u", length);
proto_tree_add_uint(ext_tree_rab_setup, hf_gtp_nsapi, tvb, offset+3, 1, nsapi);
if (length > 1) {
teid = tvb_get_ntohl(tvb, offset + 4);
proto_tree_add_uint(ext_tree_rab_setup, hf_gtp_teid_data, tvb, offset+4, 4, teid);
switch (length) {
case 12:
tvb_memcpy(tvb, (guint8 *)&addr_ipv4, offset+8, sizeof addr_ipv4);
proto_tree_add_ipv4(ext_tree_rab_setup, hf_gtp_rnc_ipv4, tvb, offset+8, 4, addr_ipv4);
break;
case 24:
tvb_memcpy(tvb, (guint8 *)&addr_ipv6, offset+8, sizeof addr_ipv6);
proto_tree_add_ipv6(ext_tree_rab_setup, hf_gtp_rnc_ipv6, tvb, offset+8, 16, (guint8 *)&addr_ipv6);
break;
default:
break;
}
}
return 3 + length;
}
/* GPRS: not present
* UMTS: 29.060 v4.0, chapter 7.7.40
*/
static int
decode_gtp_hdr_list(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
int i;
guint8 length, hdr;
proto_tree *ext_tree_hdr_list;
proto_item *te;
length = tvb_get_guint8(tvb, offset + 1);
te = proto_tree_add_text(tree, tvb, offset, 2+length, "%s", val_to_str(GTP_EXT_HDR_LIST, gtp_val, "Unknown"));
ext_tree_hdr_list = proto_item_add_subtree(te, ett_gtp_hdr_list);
proto_tree_add_text(ext_tree_hdr_list, tvb, offset+1, 1, "Number of Extension Header Types in list (i.e., length) : %u", length);
for(i=0 ; i<length ; i++) {
hdr = tvb_get_guint8(tvb, offset+2+i);
proto_tree_add_text(ext_tree_hdr_list, tvb, offset+2+i, 1, "No. %u --> Extension Header Type value : %s (%u)", i+1, val_to_str(hdr, gtp_val, "Unknown Extension Header Type"), hdr);
}
return 2 + length;
}
/* GPRS: not present
* UMTS: 29.060 v4.0, chapter 7.7.41
* TODO: find TriggerID description
*/
static int
decode_gtp_trigger_id(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
guint16 length;
length = tvb_get_ntohs(tvb, offset + 1);
proto_tree_add_text(tree, tvb, offset, 3+length, "%s length : %u", val_to_str(GTP_EXT_TRIGGER_ID, gtp_val, "Unknown"), length);
return 3 + length;
}
/* GPRS: not present
* UMTS: 29.060 v4.0, chapter 7.7.42
* TODO: find OMC-ID description
*/
static int
decode_gtp_omc_id(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
guint16 length;
length = tvb_get_ntohs(tvb, offset + 1);
proto_tree_add_text(tree, tvb, offset, 3+length, "%s length : %u", val_to_str(GTP_EXT_OMC_ID, gtp_val, "Unknown"), length);
return 3 + length;
}
/* GPRS: 9.60 v7.6.0, chapter 7.9.25
* UMTS: 29.060 v4.0, chapter 7.7.43
*/
static int
decode_gtp_chrg_addr(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
guint16 length;
guint32 addr_ipv4;
struct e_in6_addr addr_ipv6;
proto_tree *ext_tree_chrg_addr;
proto_item *te;
length = tvb_get_ntohs(tvb, offset+1);
te = proto_tree_add_text(tree, tvb, offset, 3+length, "%s : ", val_to_str(GTP_EXT_CHRG_ADDR, gtp_val, "Unknown"));
ext_tree_chrg_addr = proto_item_add_subtree(te, ett_gtp_chrg_addr);
proto_tree_add_text(ext_tree_chrg_addr, tvb, offset+1, 2, "%s length : %u", val_to_str(GTP_EXT_CHRG_ADDR, gtp_val, "Unknown"), length);
switch (length) {
case 4:
tvb_memcpy(tvb, (guint8 *)&addr_ipv4, offset+3, sizeof addr_ipv4);
proto_item_append_text(te, "%s", ip_to_str((guint8 *)&addr_ipv4));
proto_tree_add_ipv4 (ext_tree_chrg_addr, hf_gtp_chrg_ipv4, tvb, offset+3, 4, addr_ipv4);
break;
case 16:
tvb_memcpy(tvb, (guint8 *)&addr_ipv6, offset+3, sizeof addr_ipv6);
proto_item_append_text(te, "%s", ip6_to_str((struct e_in6_addr*)&addr_ipv6));
proto_tree_add_ipv6 (ext_tree_chrg_addr, hf_gtp_chrg_ipv6, tvb, offset+3, 16, (guint8*)&addr_ipv6);
break;
default:
proto_item_append_text(te, "unknown type or wrong length");
break;
}
return 3 + length;
}
/* GPRS: 12.15
* UMTS: 33.015
*/
static int
decode_gtp_rel_pack(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
guint16 length, n, number;
proto_tree *ext_tree_rel_pack;
proto_item *te;
length = tvb_get_ntohs(tvb, offset + 1);
te = proto_tree_add_text(tree, tvb, offset, 3 + length, "Sequence numbers of released packets IE");
ext_tree_rel_pack = proto_item_add_subtree(te, ett_gtp_rel_pack);
n = 0;
while (n < length) {
number = tvb_get_ntohs(tvb, offset + 3 + n);
proto_tree_add_text(ext_tree_rel_pack, tvb, offset + 3 + n, 2, "%u", number);
n = n + 2;
}
return 3 + length;
}
/* GPRS: 12.15
* UMTS: 33.015
*/
static int
decode_gtp_can_pack(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
guint16 length, n, number;
proto_tree *ext_tree_can_pack;
proto_item *te;
length = tvb_get_ntohs(tvb, offset + 1);
te = proto_tree_add_text(tree, tvb, offset, 3 + length, "Sequence numbers of cancelled packets IE");
ext_tree_can_pack = proto_item_add_subtree(te, ett_gtp_can_pack);
n = 0;
while (n < length) {
number = tvb_get_ntohs(tvb, offset + 3 + n);
proto_tree_add_text(ext_tree_can_pack, tvb, offset + 3 + n, 2, "%u", number);
n = n + 2;
}
return 3 + length;
}
/* CDRs dissector */
static int
decode_gtp_data_req(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
guint16 length, format_ver;
guint8 no, format;
proto_tree *ext_tree;
proto_item *te;
tvbuff_t *next_tvb;
te = proto_tree_add_text(tree, tvb, offset, 1, val_to_str(GTP_EXT_DATA_REQ, gtp_val, "Unknown message"));
ext_tree = proto_item_add_subtree(te, ett_gtp_ext);
length = tvb_get_ntohs(tvb, offset + 1);
no = tvb_get_guint8(tvb, offset + 3);
format = tvb_get_guint8(tvb, offset + 4);
format_ver = tvb_get_ntohs(tvb, offset + 5);
proto_tree_add_text(ext_tree, tvb, offset+1, 2, "Length: %u", length);
proto_tree_add_text(ext_tree, tvb, offset+3, 1, "Number of data records: %u", no);
proto_tree_add_text(ext_tree, tvb, offset+4, 1, "Data record format: %u", format);
proto_tree_add_text(ext_tree, tvb, offset+5, 2, "Data record format version: %u", format_ver);
if (gtpcdr_handle) {
next_tvb = tvb_new_subset (tvb, offset, -1, -1);
call_dissector (gtpcdr_handle, next_tvb, pinfo, tree);
}
else
proto_tree_add_text (tree, tvb, offset, 0, "Data");
return 3+length;
}
/* GPRS: 12.15
* UMTS: 33.015
*/
static int
decode_gtp_data_resp(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
guint16 length, n, number;
proto_tree *ext_tree_data_resp;
proto_item *te;
length = tvb_get_ntohs(tvb, offset + 1);
te = proto_tree_add_text(tree, tvb, offset, 3 + length, "Requests responded");
ext_tree_data_resp = proto_item_add_subtree(te, ett_gtp_data_resp);
n = 0;
while (n < length) {
number = tvb_get_ntohs(tvb, offset + 3 + n);
proto_tree_add_text(ext_tree_data_resp, tvb, offset + 3 + n, 2, "%u", number);
n = n + 2;
}
return 3 + length;
}
/* GPRS: 12.15
* UMTS: 33.015
*/
static int
decode_gtp_node_addr(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
guint16 length;
guint32 addr_ipv4;
struct e_in6_addr addr_ipv6;
proto_tree *ext_tree_node_addr;
proto_item *te;
length = tvb_get_ntohs(tvb, offset+1);
te = proto_tree_add_text(tree, tvb, offset, 3+length, "Node address: ");
ext_tree_node_addr = proto_item_add_subtree(te, ett_gtp_node_addr);
proto_tree_add_text (ext_tree_node_addr, tvb, offset+1, 2, "Node address length: %u", length);
switch (length) {
case 4:
tvb_memcpy(tvb, (guint8 *)&addr_ipv4, offset+3, sizeof addr_ipv4);
proto_item_append_text(te, "%s", ip_to_str((guint8 *)&addr_ipv4));
proto_tree_add_ipv4 (ext_tree_node_addr, hf_gtp_node_ipv4, tvb, offset+3, 4, addr_ipv4);
break;
case 16:
tvb_memcpy(tvb, (guint8 *)&addr_ipv6, offset+3, sizeof addr_ipv6);
proto_item_append_text(te, "%s", ip6_to_str((struct e_in6_addr*)&addr_ipv6));
proto_tree_add_ipv6 (ext_tree_node_addr, hf_gtp_node_ipv6, tvb, offset+3, 16, (guint8*)&addr_ipv6);
break;
default:
proto_item_append_text(te, "unknown type or wrong length");
break;
}
return 3 + length;
}
/* GPRS: 9.60 v7.6.0, chapter 7.9.26
* UMTS: 29.060 v4.0, chapter 7.7.44
*/
static int
decode_gtp_priv_ext(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
guint16 length, ext_id;
gchar ext_val[64];
proto_tree *ext_tree_priv_ext;
proto_item *te;
te = proto_tree_add_text(tree, tvb, offset, 1, val_to_str(GTP_EXT_PRIV_EXT, gtp_val, "Unknown message"));
ext_tree_priv_ext = proto_item_add_subtree(te, ett_gtp_ext);
length = tvb_get_ntohs(tvb, offset+1);
if (length < 1) return 3+length;
ext_id = tvb_get_ntohs(tvb, offset+3);
tvb_memcpy(tvb, ext_val, offset+5, length > 65 ? 63 : length-2);
ext_val[length > 65 ? 64 : length-1] = '\0';
proto_tree_add_uint(ext_tree_priv_ext, hf_gtp_ext_id, tvb, offset+3, 2, ext_id);
proto_tree_add_string(ext_tree_priv_ext, hf_gtp_ext_val, tvb, offset+5, length-2, ext_val);
return 3+length;
}
static int
decode_gtp_unknown(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree) {
proto_tree_add_text(tree, tvb, offset, 1, "Unknown extension header");
return tvb_length_remaining(tvb, offset);
}
static void
dissect_gtp (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
struct _gtp_hdr gtp_hdr;
proto_tree *gtp_tree, *flags_tree;
proto_item *ti, *tf;
int i, offset, length, gtp_prime, checked_field, mandatory;
int seq_no, flow_label;
guint8 pdu_no, next_hdr = 0, ext_hdr_val;
const guint8 *tid_val;
gchar *tid_str;
guint32 teid;
tvbuff_t *next_tvb;
guint8 sub_proto, acfield_len = 0, control_field;
if (check_col(pinfo->cinfo, COL_PROTOCOL))
col_set_str(pinfo->cinfo, COL_PROTOCOL, "GTP");
if (check_col(pinfo->cinfo, COL_INFO))
col_clear(pinfo->cinfo, COL_INFO);
tvb_memcpy(tvb, (guint8 *)>p_hdr, 0, 4);
if (!(gtp_hdr.flags & 0x10))
gtp_prime = 1;
else
gtp_prime = 0;
switch ((gtp_hdr.flags >> 5) & 0x07) {
case 0:
gtp_version = 0;
break;
case 1:
gtp_version = 1;
break;
default:
gtp_version = 1;
break;
}
if (check_col(pinfo->cinfo, COL_INFO))
col_add_str(pinfo->cinfo, COL_INFO, val_to_str(gtp_hdr.message, message_type, "Unknown"));
if (tree) {
ti = proto_tree_add_item (tree, proto_gtp, tvb, 0, -1, FALSE);
gtp_tree = proto_item_add_subtree(ti, ett_gtp);
tf = proto_tree_add_uint (gtp_tree, hf_gtp_flags, tvb, 0, 1, gtp_hdr.flags);
flags_tree = proto_item_add_subtree (tf, ett_gtp_flags);
proto_tree_add_uint (flags_tree, hf_gtp_flags_ver, tvb, 0, 1, gtp_hdr.flags);
proto_tree_add_uint (flags_tree, hf_gtp_flags_pt, tvb, 0, 1, gtp_hdr.flags);
switch (gtp_version) {
case 0:
proto_tree_add_uint (flags_tree, hf_gtp_flags_spare1, tvb, 0, 1, gtp_hdr.flags);
proto_tree_add_boolean (flags_tree, hf_gtp_flags_snn, tvb, 0, 1, gtp_hdr.flags);
break;
case 1:
proto_tree_add_uint (flags_tree, hf_gtp_flags_spare2, tvb, 0, 1, gtp_hdr.flags);
proto_tree_add_boolean (flags_tree, hf_gtp_flags_e, tvb, 0, 1, gtp_hdr.flags);
proto_tree_add_boolean (flags_tree, hf_gtp_flags_s, tvb, 0, 1, gtp_hdr.flags);
proto_tree_add_boolean (flags_tree, hf_gtp_flags_pn, tvb, 0, 1, gtp_hdr.flags);
break;
default:
break;
}
proto_tree_add_uint (gtp_tree, hf_gtp_message_type, tvb, 1, 1, gtp_hdr.message);
gtp_hdr.length = g_ntohs (gtp_hdr.length);
proto_tree_add_uint (gtp_tree, hf_gtp_length, tvb, 2, 2, gtp_hdr.length);
offset = 4;
if (gtp_prime) {
seq_no = tvb_get_ntohs (tvb, offset);
proto_tree_add_uint (gtp_tree, hf_gtp_seq_number, tvb, offset, 2, seq_no);
offset += 2;
} else
switch (gtp_version) {
case 0:
seq_no = tvb_get_ntohs (tvb, offset);
proto_tree_add_uint (gtp_tree, hf_gtp_seq_number, tvb, offset, 2, seq_no);
offset += 2;
flow_label = tvb_get_ntohs (tvb, offset);
proto_tree_add_uint (gtp_tree, hf_gtp_flow_label, tvb, offset, 2, flow_label);
offset += 2;
pdu_no = tvb_get_guint8 (tvb, offset);
proto_tree_add_uint (gtp_tree, hf_gtp_sndcp_number, tvb, offset, 1, pdu_no);
offset += 4;
tid_val = tvb_get_ptr(tvb, offset, 8);
tid_str = id_to_str (tid_val);
proto_tree_add_string (gtp_tree, hf_gtp_tid, tvb, offset, 8, tid_str);
offset += 8;
break;
case 1:
teid = tvb_get_ntohl (tvb, offset);
proto_tree_add_uint (gtp_tree, hf_gtp_teid, tvb, offset, 4, teid);
offset += 4;
if (gtp_hdr.flags & 0x07) {
seq_no = tvb_get_ntohs (tvb, offset);
proto_tree_add_uint (gtp_tree, hf_gtp_seq_number, tvb, offset, 2, seq_no);
offset += 2;
pdu_no = tvb_get_guint8 (tvb, offset);
proto_tree_add_uint (gtp_tree, hf_gtp_npdu_number, tvb, offset, 1, pdu_no);
offset++;
next_hdr = tvb_get_guint8 (tvb, offset);
proto_tree_add_uint (gtp_tree, hf_gtp_next, tvb, offset, 1, next_hdr);
if (!next_hdr)
offset++;
}
break;
default:
break;
}
if (gtp_hdr.message != GTP_MSG_TPDU) {
proto_tree_add_text(gtp_tree, tvb, 0, 0, "[--- end of GTP header, beginning of extension headers ---]");
length = tvb_length (tvb);
mandatory = 0; /* check order of GTP fields against ETSI */
for (;;) {
if (offset >= length)
break;
if (next_hdr) {
ext_hdr_val = next_hdr;
next_hdr = 0;
}
else
ext_hdr_val = tvb_get_guint8 (tvb, offset);
if (gtp_etsi_order) {
checked_field = check_field_presence (gtp_hdr.message, ext_hdr_val , (int *)&mandatory);
switch (checked_field) {
case -2: proto_tree_add_text (gtp_tree, tvb, 0, 0, "[WARNING] message not found");
break;
case -1: proto_tree_add_text (gtp_tree, tvb, 0, 0, "[WARNING] field not present");
break;
case 0: break;
default: proto_tree_add_text (gtp_tree, tvb, offset, 1, "[WARNING] wrong next field, should be: %s", val_to_str(checked_field, gtp_val, "Unknown extension field"));
break;
}
}
i = -1;
while (gtpopt[++i].optcode)
if (gtpopt[i].optcode == ext_hdr_val)
break;
offset = offset + (*gtpopt[i].decode)(tvb, offset, pinfo, gtp_tree);
}
}
}
if ((gtp_hdr.message == GTP_MSG_TPDU) && gtp_tpdu) {
if (gtp_prime)
offset = 6;
else
if (gtp_version == 1) {
if (gtp_hdr.flags & 0x07) {
offset = 11;
if (tvb_get_guint8 (tvb, offset) == 0)
offset++;
}
else
offset = 8;
}
else
offset = 20;
sub_proto = tvb_get_guint8 (tvb, offset);
if ((sub_proto >= 0x45) && (sub_proto <= 0x4e)) {
/* this is most likely an IPv4 packet
* we can exclude 0x40 - 0x44 because the minimum header size is 20 octets
* 0x4f is excluded because PPP protocol type "IPv6 header compression"
* with protocol field compression is more likely than a plain IPv4 packet with 60 octet header size */
next_tvb = tvb_new_subset (tvb, offset, -1, -1);
call_dissector(ip_handle, next_tvb, pinfo, tree);
} else
if ((sub_proto & 0xf0) == 0x60){
/* this is most likely an IPv6 packet */
next_tvb = tvb_new_subset (tvb, offset, -1, -1);
call_dissector (ipv6_handle, next_tvb, pinfo, tree);
} else {
/* this seems to be a PPP packet */
if (sub_proto == 0xff) {
/* this might be an address field, even it shouldn't be here */
control_field = tvb_get_guint8 (tvb, offset + 1);
if (control_field == 0x03)
/* now we are pretty sure that address and control field are mistakenly inserted -> ignore it for PPP dissection */
acfield_len = 2;
}
next_tvb = tvb_new_subset (tvb, offset + acfield_len, -1, -1);
call_dissector (ppp_handle, next_tvb, pinfo, tree);
}
if (check_col(pinfo->cinfo, COL_PROTOCOL))
col_append_str_gtp(pinfo->cinfo, COL_PROTOCOL, "GTP");
}
}
static const true_false_string yes_no_tfs = {
"yes" ,
"no"
};
void
proto_register_gtp(void)
{
static hf_register_info hf_gtp[] = {
{ &hf_gtp_apn, { "APN", "gtp.apn", FT_STRING, BASE_DEC, NULL, 0, "Access Point Name", HFILL }},
{ &hf_gtp_cause, { "Cause ", "gtp.cause", FT_UINT8, BASE_DEC, VALS(cause_type), 0, "Cause of operation", HFILL }},
{ &hf_gtp_chrg_char, { "Charging characteristics", "gtp.chrg_char", FT_UINT16, BASE_DEC, NULL, 0, "Charging characteristics", HFILL }},
{ &hf_gtp_chrg_char_s, { "Spare", "gtp.chrg_char_s", FT_UINT16, BASE_DEC, NULL, GTP_MASK_CHRG_CHAR_S, "Spare", HFILL }},
{ &hf_gtp_chrg_char_n, { "Normal charging", "gtp.chrg_char_n", FT_UINT16, BASE_DEC, NULL, GTP_MASK_CHRG_CHAR_N, "Normal charging", HFILL }},
{ &hf_gtp_chrg_char_p, { "Prepaid charging", "gtp.chrg_char_p", FT_UINT16, BASE_DEC, NULL, GTP_MASK_CHRG_CHAR_P, "Prepaid charging", HFILL }},
{ &hf_gtp_chrg_char_f, { "Flat rate charging", "gtp.chrg_char_f", FT_UINT16, BASE_DEC, NULL, GTP_MASK_CHRG_CHAR_F, "Flat rate charging", HFILL }},
{ &hf_gtp_chrg_char_h, { "Hot billing charging", "gtp.chrg_char_h", FT_UINT16, BASE_DEC, NULL, GTP_MASK_CHRG_CHAR_H, "Hot billing charging", HFILL }},
{ &hf_gtp_chrg_char_r, { "Reserved", "gtp.chrg_char_r", FT_UINT16, BASE_DEC, NULL, GTP_MASK_CHRG_CHAR_R, "Reserved", HFILL }},
{ &hf_gtp_chrg_id, { "Charging ID", "gtp.chrg_id", FT_UINT32, BASE_HEX, NULL, 0, "Charging ID", HFILL }},
{ &hf_gtp_chrg_ipv4, { "CG address IPv4", "gtp.chrg_ipv4", FT_IPv4, BASE_DEC, NULL, 0, "Charging Gateway address IPv4", HFILL }},
{ &hf_gtp_chrg_ipv6, { "CG address IPv6", "gtp.chrg_ipv6", FT_IPv6, BASE_HEX, NULL, 0, "Charging Gateway address IPv6", HFILL }},
{ &hf_gtp_ext_flow_label, { "Flow Label Data I", "gtp.ext_flow_label", FT_UINT16, BASE_HEX, NULL, 0, "Flow label data", HFILL }},
{ &hf_gtp_ext_id, { "Extension identifier", "gtp.ext_id", FT_UINT16, BASE_DEC, NULL, 0, "Extension Identifier", HFILL }},
{ &hf_gtp_ext_val, { "Extension value", "gtp.ext_val", FT_STRING, BASE_DEC, NULL, 0, "Extension Value", HFILL }},
{ &hf_gtp_flags, { "Flags", "gtp.flags", FT_UINT8, BASE_HEX, NULL, 0, "Ver/PT/Spare...", HFILL }},
{ &hf_gtp_flags_ver, { "Version", "gtp.flags.version", FT_UINT8, BASE_DEC, VALS(ver_types), GTP_VER_MASK, "GTP Version", HFILL }},
{ &hf_gtp_flags_pt, { "Protocol type", "gtp.flags.payload", FT_UINT8, BASE_DEC, NULL, GTP_PT_MASK, "Protocol Type", HFILL }},
{ &hf_gtp_flags_spare1, { "Reserved", "gtp.flags.reserved", FT_UINT8, BASE_DEC, NULL, GTP_SPARE1_MASK, "Reserved (shall be sent as '111' )", HFILL }},
{ &hf_gtp_flags_snn, { "Is SNDCP N-PDU included?", "gtp.flags.snn", FT_BOOLEAN, 8, TFS(&yes_no_tfs), GTP_SNN_MASK, "Is SNDCP N-PDU LLC Number included? (1 = yes, 0 = no)", HFILL }},
{ &hf_gtp_flags_spare2, { "Reserved", "gtp.flags.reserved", FT_UINT8, BASE_DEC, NULL, GTP_SPARE2_MASK, "Reserved (shall be sent as '1' )", HFILL }},
{ &hf_gtp_flags_e, { "Is Next Extension Header present?", "gtp.flags.e", FT_BOOLEAN, 8, TFS(&yes_no_tfs), GTP_E_MASK, "Is Next Extension Header present? (1 = yes, 0 = no)", HFILL }},
{ &hf_gtp_flags_s, { "Is Sequence Number present?", "gtp.flags.s", FT_BOOLEAN, 8, TFS(&yes_no_tfs), GTP_S_MASK, "Is Sequence Number present? (1 = yes, 0 = no)", HFILL }},
{ &hf_gtp_flags_pn, { "Is N-PDU number present?", "gtp.flags.pn", FT_BOOLEAN, 8, TFS(&yes_no_tfs), GTP_PN_MASK, "Is N-PDU number present? (1 = yes, 0 = no)", HFILL }},
{ &hf_gtp_flow_ii, { "Flow Label Data II ", "gtp.flow_ii", FT_UINT16, BASE_DEC, NULL, 0, "Downlink flow label data", HFILL }},
{ &hf_gtp_flow_label, { "Flow label", "gtp.flow_label", FT_UINT16, BASE_HEX, NULL, 0, "Flow label", HFILL }},
{ &hf_gtp_flow_sig, { "Flow label Signalling", "gtp.flow_sig", FT_UINT16, BASE_HEX, NULL, 0, "Flow label signalling", HFILL }},
{ &hf_gtp_gsn_addr_len, { "GSN Address Length", "gtp.gsn_addr_len", FT_UINT8, BASE_DEC, NULL, GTP_EXT_GSN_ADDR_LEN_MASK, "GSN Address Length", HFILL }},
{ &hf_gtp_gsn_addr_type, { "GSN Address Type", "gtp.gsn_addr_type", FT_UINT8, BASE_DEC, VALS(gsn_addr_type), GTP_EXT_GSN_ADDR_TYPE_MASK, "GSN Address Type", HFILL }},
{ &hf_gtp_gsn_ipv4, { "GSN address IPv4", "gtp.gsn_ipv4", FT_IPv4, BASE_DEC, NULL, 0, "GSN address IPv4", HFILL }},
{ &hf_gtp_gsn_ipv6, { "GSN address IPv6", "gtp.gsn_ipv6", FT_IPv6, BASE_DEC, NULL, 0, "GSN address IPv6", HFILL }},
{ &hf_gtp_imsi, { "IMSI", "gtp.imsi", FT_STRING, BASE_DEC, NULL, 0, "International Mobile Subscriber Identity number", HFILL }},
{ &hf_gtp_length, { "Length", "gtp.length", FT_UINT16, BASE_DEC, NULL, 0, "Length (i.e. number of octets after TID or TEID)", HFILL }},
{ &hf_gtp_map_cause, { "MAP cause", "gtp.map_cause", FT_UINT8, BASE_DEC, VALS(map_cause_type), 0, "MAP cause", HFILL }},
{ &hf_gtp_message_type, { "Message Type", "gtp.message", FT_UINT8, BASE_HEX, VALS(message_type), 0x0, "GTP Message Type", HFILL }},
{ &hf_gtp_ms_reason, { "MS not reachable reason", "gtp.ms_reason", FT_UINT8, BASE_DEC, VALS(ms_not_reachable_type), 0, "MS Not Reachable Reason", HFILL }},
{ &hf_gtp_ms_valid, { "MS validated", "gtp.ms_valid", FT_BOOLEAN, BASE_NONE,NULL, 0, "MS validated", HFILL }},
{ &hf_gtp_msisdn, { "MSISDN", "gtp.msisdn", FT_STRING, BASE_DEC, NULL, 0, "MS international PSTN/ISDN number", HFILL }},
{ &hf_gtp_next, { "Next extension header type", "gtp.next", FT_UINT8, BASE_HEX, NULL, 0, "Next Extension Header Type", HFILL }},
{ &hf_gtp_node_ipv4, { "Node address IPv4", "gtp.node_ipv4", FT_IPv4, BASE_DEC, NULL, 0, "Recommended node address IPv4", HFILL }},
{ &hf_gtp_node_ipv6, { "Node address IPv6", "gtp.node_ipv6", FT_IPv6, BASE_HEX, NULL, 0, "Recommended node address IPv6", HFILL }},
{ &hf_gtp_npdu_number, { "N-PDU Number", "gtp.npdu_number", FT_UINT8, BASE_HEX, NULL, 0, "N-PDU Number", HFILL }},
{ &hf_gtp_nsapi, { "NSAPI", "gtp.nsapi", FT_UINT8, BASE_DEC, NULL, 0, "Network layer Service Access Point Identifier", HFILL }},
{ &hf_gtp_qos_spare1, { "Spare", "gtp.qos_spare1", FT_UINT8, BASE_DEC, NULL, GTP_EXT_QOS_SPARE1_MASK, "Spare (shall be sent as '00' )", HFILL }},
{ &hf_gtp_qos_delay, { "QoS delay", "gtp.qos_delay", FT_UINT8, BASE_DEC, VALS(qos_delay_type), GTP_EXT_QOS_DELAY_MASK, "Quality of Service Delay Class", HFILL }},
{ &hf_gtp_qos_reliability, { "QoS reliability", "gtp.qos_reliabilty", FT_UINT8, BASE_DEC, VALS(qos_reliability_type), GTP_EXT_QOS_RELIABILITY_MASK, "Quality of Service Reliability Class", HFILL }},
{ &hf_gtp_qos_peak, { "QoS peak", "gtp.qos_peak", FT_UINT8, BASE_DEC, VALS(qos_peak_type), GTP_EXT_QOS_PEAK_MASK, "Quality of Service Peak Throughput", HFILL }},
{ &hf_gtp_qos_spare2, { "Spare", "gtp.qos_spare2",FT_UINT8, BASE_DEC, NULL, GTP_EXT_QOS_SPARE2_MASK, "Spare (shall be sent as 0)", HFILL }},
{ &hf_gtp_qos_precedence, { "QoS precedence", "gtp.qos_precedence", FT_UINT8, BASE_DEC, VALS(qos_precedence_type), GTP_EXT_QOS_PRECEDENCE_MASK, "Quality of Service Precedence Class", HFILL }},
{ &hf_gtp_qos_spare3, { "Spare", "gtp.qos_spare3", FT_UINT8, BASE_DEC, NULL, GTP_EXT_QOS_SPARE3_MASK, "Spare (shall be sent as '000' )", HFILL }},
{ &hf_gtp_qos_mean, { "QoS mean", "gtp.qos_mean", FT_UINT8, BASE_DEC, VALS(qos_mean_type), GTP_EXT_QOS_MEAN_MASK, "Quality of Service Mean Throughput", HFILL }},
{ &hf_gtp_qos_al_ret_priority, { "Allocation/Retention priority ","gtp.qos_al_ret_priority", FT_UINT8, BASE_DEC, NULL, 0, "Allocation/Retention Priority", HFILL }},
{ &hf_gtp_qos_traf_class, { "Traffic class", "gtp.qos_traf_class", FT_UINT8, BASE_DEC, VALS(qos_traf_class), GTP_EXT_QOS_TRAF_CLASS_MASK, "Traffic Class", HFILL }},
{ &hf_gtp_qos_del_order, { "Delivery order", "gtp.qos_del_order", FT_UINT8, BASE_DEC, VALS(qos_del_order), GTP_EXT_QOS_DEL_ORDER_MASK, "Delivery Order", HFILL }},
{ &hf_gtp_qos_del_err_sdu, { "Delivery of erroneous SDU", "gtp.qos_del_err_sdu", FT_UINT8, BASE_DEC, VALS(qos_del_err_sdu), GTP_EXT_QOS_DEL_ERR_SDU_MASK, "Delivery of Erroneous SDU", HFILL }},
{ &hf_gtp_qos_max_sdu_size, { "Maximum SDU size", "gtp.qos_max_sdu_size", FT_UINT8, BASE_DEC, VALS(qos_max_sdu_size), 0, "Maximum SDU size", HFILL }},
{ &hf_gtp_qos_max_ul, { "Maximum bit rate for uplink", "gtp.qos_max_ul", FT_UINT8, BASE_DEC, VALS(qos_max_ul), 0, "Maximum bit rate for uplink", HFILL }},
{ &hf_gtp_qos_max_dl, { "Maximum bit rate for downlink", "gtp.qos_max_dl", FT_UINT8, BASE_DEC, VALS(qos_max_dl), 0, "Maximum bit rate for downlink", HFILL }},
{ &hf_gtp_qos_res_ber, { "Residual BER", "gtp.qos_res_ber", FT_UINT8, BASE_DEC, VALS(qos_res_ber), GTP_EXT_QOS_RES_BER_MASK, "Residual Bit Error Rate", HFILL }},
{ &hf_gtp_qos_sdu_err_ratio, { "SDU Error ratio", "gtp.qos_sdu_err_ratio", FT_UINT8, BASE_DEC, VALS(qos_sdu_err_ratio), GTP_EXT_QOS_SDU_ERR_RATIO_MASK, "SDU Error Ratio", HFILL }},
{ &hf_gtp_qos_trans_delay, { "Transfer delay", "gtp.qos_trans_delay", FT_UINT8, BASE_DEC, VALS(qos_trans_delay), GTP_EXT_QOS_TRANS_DELAY_MASK, "Transfer Delay", HFILL }},
{ &hf_gtp_qos_traf_handl_prio, { "Traffic handling priority", "gtp.qos_traf_handl_prio", FT_UINT8, BASE_DEC, VALS(qos_traf_handl_prio), GTP_EXT_QOS_TRAF_HANDL_PRIORITY_MASK, "Traffic Handling Priority", HFILL }},
{ &hf_gtp_qos_guar_ul, { "Guaranteed bit rate for uplink", "gtp.qos_guar_ul", FT_UINT8, BASE_DEC, VALS(qos_guar_ul), 0, "Guaranteed bit rate for uplink", HFILL }},
{ &hf_gtp_qos_guar_dl, { "Guaranteed bit rate for downlink", "gtp.qos_guar_dl", FT_UINT8, BASE_DEC, VALS(qos_guar_dl), 0, "Guaranteed bit rate for downlink", HFILL }},
{ &hf_gtp_pkt_flow_id, { "Packet Flow ID", "gtp.pkt_flow_id", FT_UINT8, BASE_DEC, NULL, 0, "Packet Flow ID", HFILL }},
{ &hf_gtp_ptmsi, { "P-TMSI", "gtp.ptmsi", FT_UINT32, BASE_HEX, NULL, 0, "Packet-Temporary Mobile Subscriber Identity", HFILL }},
{ &hf_gtp_ptmsi_sig, { "P-TMSI Signature", "gtp.ptmsi_sig", FT_UINT24, BASE_HEX, NULL, 0, "P-TMSI Signature", HFILL }},
{ &hf_gtp_rab_gtpu_dn, { "Downlink GTP-U seq number", "gtp.rab_gtp_dn", FT_UINT16, BASE_DEC, NULL, 0, "Downlink GTP-U sequence number", HFILL }},
{ &hf_gtp_rab_gtpu_up, { "Uplink GTP-U seq number", "gtp.rab_gtp_up", FT_UINT16, BASE_DEC, NULL, 0, "Uplink GTP-U sequence number", HFILL }},
{ &hf_gtp_rab_pdu_dn, { "Downlink next PDCP-PDU seq number", "gtp.rab_pdu_dn", FT_UINT8, BASE_DEC, NULL, 0, "Downlink next PDCP-PDU sequence number", HFILL }},
{ &hf_gtp_rab_pdu_up, { "Uplink next PDCP-PDU seq number", "gtp.rab_pdu_up", FT_UINT8, BASE_DEC, NULL, 0, "Uplink next PDCP-PDU sequence number", HFILL }},
{ &hf_gtp_rai_mcc, { "MCC", "gtp.mcc", FT_UINT16, BASE_DEC, NULL, 0, "Mobile Country Code", HFILL }},
{ &hf_gtp_rai_mnc, { "MNC", "gtp.mnc", FT_UINT8, BASE_DEC, NULL, 0, "Mobile Network Code", HFILL }},
{ &hf_gtp_rai_rac, { "RAC", "gtp.rac", FT_UINT8, BASE_DEC, NULL, 0, "Routing Area Code", HFILL }},
{ &hf_gtp_rai_lac, { "LAC", "gtp.lac", FT_UINT16, BASE_DEC, NULL, 0, "Location Area Code", HFILL }},
{ &hf_gtp_ranap_cause, { "RANAP cause", "gtp.ranap_cause", FT_UINT8, BASE_DEC, VALS(ranap_cause_type), 0, "RANAP cause", HFILL }},
{ &hf_gtp_recovery, { "Recovery", "gtp.recovery", FT_UINT8, BASE_DEC, NULL, 0, "Restart counter", HFILL }},
{ &hf_gtp_reorder, { "Reordering required","gtp.reorder", FT_BOOLEAN, BASE_NONE,NULL, 0, "Reordering required", HFILL }},
{ &hf_gtp_rnc_ipv4, { "RNC address IPv4", "gtp.rnc_ipv4", FT_IPv4, BASE_DEC, NULL, 0, "Radio Network Controller address IPv4", HFILL }},
{ &hf_gtp_rnc_ipv6, { "RNC address IPv6", "gtp.rnc_ipv6", FT_IPv6, BASE_HEX, NULL, 0, "Radio Network Controller address IPv6", HFILL }},
{ &hf_gtp_rp, { "Radio Priority", "gtp.rp", FT_UINT8, BASE_DEC, NULL, GTPv1_EXT_RP_MASK, "Radio Priority for uplink tx", HFILL }},
{ &hf_gtp_rp_nsapi, { "NSAPI in Radio Priority", "gtp.rp_nsapi", FT_UINT8, BASE_DEC, NULL, GTPv1_EXT_RP_NSAPI_MASK, "Network layer Service Access Point Identifier in Radio Priority", HFILL }},
{ &hf_gtp_rp_sms, { "Radio Priority SMS", "gtp.rp_sms", FT_UINT8, BASE_DEC, NULL, 0, "Radio Priority for MO SMS", HFILL }},
{ &hf_gtp_rp_spare, { "Reserved", "gtp.rp_spare", FT_UINT8, BASE_DEC, NULL, GTPv1_EXT_RP_SPARE_MASK, "Spare bit", HFILL }},
{ &hf_gtp_sel_mode, { "Selection mode", "gtp.sel_mode", FT_UINT8, BASE_DEC, VALS(sel_mode_type), 0, "Selection Mode", HFILL }},
{ &hf_gtp_seq_number, { "Sequence number", "gtp.seq_number", FT_UINT16, BASE_HEX, NULL, 0, "Sequence Number", HFILL }},
{ &hf_gtp_sndcp_number, { "SNDCP N-PDU LLC Number", "gtp.sndcp_number", FT_UINT8, BASE_HEX, NULL, 0, "SNDCP N-PDU LLC Number", HFILL }},
{ &hf_gtp_tear_ind, { "Teardown Indicator", "gtp.tear_ind", FT_BOOLEAN, BASE_NONE,NULL, 0, "Teardown Indicator", HFILL }},
{ &hf_gtp_teid, { "TEID", "gtp.teid", FT_UINT32, BASE_HEX, NULL, 0, "Tunnel Endpoint Identifier", HFILL }},
{ &hf_gtp_teid_cp, { "TEID Control Plane", "gtp.teid_cp", FT_UINT32, BASE_HEX, NULL, 0, "Tunnel Endpoint Identifier Control Plane", HFILL }},
{ &hf_gtp_teid_data, { "TEID Data I", "gtp.teid_data", FT_UINT32, BASE_HEX, NULL, 0, "Tunnel Endpoint Identifier Data I", HFILL }},
{ &hf_gtp_teid_ii, { "TEID Data II", "gtp.teid_ii", FT_UINT32, BASE_HEX, NULL, 0, "Tunnel Endpoint Identifier Data II", HFILL }},
{ &hf_gtp_tft_code, { "TFT operation code", "gtp.tft_code", FT_UINT8, BASE_DEC, VALS (tft_code_type), GTPv1_TFT_CODE_MASK, "TFT operation code", HFILL }},
{ &hf_gtp_tft_spare, { "TFT spare bit", "gtp.tft_spare", FT_UINT8, BASE_DEC, NULL, GTPv1_TFT_SPARE_MASK, "TFT spare bit", HFILL }},
{ &hf_gtp_tft_number, { "Number of packet filters", "gtp.tft_number", FT_UINT8, BASE_DEC, NULL, GTPv1_TFT_NUMBER_MASK, "Number of packet filters", HFILL }},
{ &hf_gtp_tft_eval, { "Evaluation precedence", "gtp.tft_eval", FT_UINT8, BASE_DEC, NULL, 0, "Evaluation precedence", HFILL }},
{ &hf_gtp_tid, { "TID", "gtp.tid", FT_STRING, BASE_DEC, NULL, 0, "Tunnel Identifier", HFILL }},
{ &hf_gtp_tlli, { "TLLI", "gtp.tlli", FT_UINT32, BASE_HEX, NULL, 0, "Temporary Logical Link Identity", HFILL }},
{ &hf_gtp_tr_comm, { "Packet transfer command", "gtp.tr_comm", FT_UINT8, BASE_DEC, VALS (tr_comm_type), 0, "Packat transfer command", HFILL }},
{ &hf_gtp_trace_ref, { "Trace reference", "gtp.trace_ref", FT_UINT16, BASE_HEX, NULL, 0, "Trace reference", HFILL }},
{ &hf_gtp_trace_type, { "Trace type", "gtp.trace_type", FT_UINT16, BASE_HEX, NULL, 0, "Trace type", HFILL }},
{ &hf_gtp_unknown, { "Unknown data (length)", "gtp.unknown", FT_UINT16, BASE_DEC, NULL, 0, "Unknown data", HFILL }},
{ &hf_gtp_user_addr_pdp_org, { "PDP type organization", "gtp.user_addr_pdp_org", FT_UINT8, BASE_DEC, VALS(pdp_org_type), 0, "PDP type organization", HFILL }},
{ &hf_gtp_user_addr_pdp_type, { "PDP type number", "gtp.user_addr_pdp_type", FT_UINT8, BASE_HEX, VALS (pdp_type), 0, "PDP type", HFILL }},
{ &hf_gtp_user_ipv4, { "End user address IPv4", "gtp.user_ipv4", FT_IPv4, BASE_DEC, NULL, 0, "End user address IPv4", HFILL }},
{ &hf_gtp_user_ipv6, { "End user address IPv6", "gtp.user_ipv6", FT_IPv6, BASE_HEX, NULL, 0, "End user address IPv6", HFILL }},
};
static gint *ett_gtp_array[] = {
&ett_gtp,
&ett_gtp_flags,
&ett_gtp_ext,
&ett_gtp_rai,
&ett_gtp_qos,
&ett_gtp_auth_tri,
&ett_gtp_flow_ii,
&ett_gtp_rab_cntxt,
&ett_gtp_rp,
&ett_gtp_pkt_flow_id,
&ett_gtp_chrg_char,
&ett_gtp_user,
&ett_gtp_mm,
&ett_gtp_trip,
&ett_gtp_quint,
&ett_gtp_pdp,
&ett_gtp_apn,
&ett_gtp_proto,
&ett_gtp_gsn_addr,
&ett_gtp_tft,
&ett_gtp_tft_pf,
&ett_gtp_tft_flags,
&ett_gtp_rab_setup,
&ett_gtp_hdr_list,
&ett_gtp_chrg_addr,
&ett_gtp_node_addr,
&ett_gtp_rel_pack,
&ett_gtp_can_pack,
&ett_gtp_data_resp,
&ett_gtp_priv_ext,
};
module_t *gtp_module;
proto_gtp = proto_register_protocol ("GPRS Tunneling Protocol", "GTP", "gtp");
proto_register_field_array (proto_gtp, hf_gtp, array_length (hf_gtp));
proto_register_subtree_array (ett_gtp_array, array_length (ett_gtp_array));
gtp_module = prefs_register_protocol(proto_gtp, proto_reg_handoff_gtp);
prefs_register_uint_preference(gtp_module, "v0_port", "GTPv0 port", "GTPv0 port (default 3386)", 10, &g_gtpv0_port);
prefs_register_uint_preference(gtp_module, "v1c_port", "GTPv1 control plane (GTP-C) port", "GTPv1 control plane port (default 2123)", 10, &g_gtpv1c_port);
prefs_register_uint_preference(gtp_module, "v1u_port", "GTPv1 user plane (GTP-U) port", "GTPv1 user plane port (default 2152)", 10, &g_gtpv1u_port);
prefs_register_bool_preference(gtp_module, "dissect_tpdu", "Dissect T-PDU", "Dissect T-PDU", >p_tpdu);
prefs_register_obsolete_preference (gtp_module, "v0_dissect_cdr_as");
prefs_register_obsolete_preference (gtp_module, "v0_check_etsi");
prefs_register_obsolete_preference (gtp_module, "v1_check_etsi");
prefs_register_bool_preference (gtp_module, "check_etsi", "Compare GTP order with ETSI", "GTP ETSI order", >p_etsi_order);
prefs_register_obsolete_preference(gtp_module, "ppp_reorder");
register_dissector("gtp", dissect_gtp, proto_gtp);
}
void
proto_reg_handoff_gtp(void)
{
static int Initialized = FALSE;
static dissector_handle_t gtp_handle;
if (!Initialized) {
gtp_handle = find_dissector("gtp");
ppp_subdissector_table = find_dissector_table("ppp.protocol");
Initialized = TRUE;
} else {
dissector_delete ("udp.port", gtpv0_port, gtp_handle);
dissector_delete ("tcp.port", gtpv0_port, gtp_handle);
dissector_delete ("udp.port", gtpv1c_port, gtp_handle);
dissector_delete ("tcp.port", gtpv1c_port, gtp_handle);
dissector_delete ("udp.port", gtpv1u_port, gtp_handle);
dissector_delete ("tcp.port", gtpv1u_port, gtp_handle);
}
gtpv0_port = g_gtpv0_port;
gtpv1c_port = g_gtpv1c_port;
gtpv1u_port = g_gtpv1u_port;
dissector_add ("udp.port", g_gtpv0_port, gtp_handle);
dissector_add ("tcp.port", g_gtpv0_port, gtp_handle);
dissector_add ("udp.port", g_gtpv1c_port, gtp_handle);
dissector_add ("tcp.port", g_gtpv1c_port, gtp_handle);
dissector_add ("udp.port", g_gtpv1u_port, gtp_handle);
dissector_add ("tcp.port", g_gtpv1u_port, gtp_handle);
ip_handle = find_dissector("ip");
ipv6_handle = find_dissector("ipv6");
ppp_handle = find_dissector("ppp");
data_handle = find_dissector("data");
gtpcdr_handle = find_dissector("gtpcdr");
}
|