aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-btmesh.c
blob: 06a11e351c7df389f75c791bd1f22f38202939f1 (plain)
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
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
/* packet-btmesh.c
 * Routines for Bluetooth mesh dissection
 *
 * Copyright 2017, Anders Broman <anders.broman@ericsson.com>
 * Copyright 2019, Piotr Winiarczyk <wino45@gmail.com>
 *
 * Wireshark - Network traffic analyzer
 * By Gerald Combs <gerald@wireshark.org>
 * Copyright 1998 Gerald Combs
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 *
 * Ref: Mesh Profile v1.0
 */

#include "packet-bluetooth.h"
#include "packet-btatt.h"
#include "packet-btmesh.h"
#include "config.h"

#include <epan/packet.h>
#include <epan/prefs.h>
#include <wsutil/wsgcrypt.h>
#include <epan/expert.h>
#include <stdio.h>
#include <epan/uat.h>
#include <epan/reassemble.h>

#define BTMESH_NOT_USED 0
#define BTMESH_KEY_ENTRY_VALID 4
#define BTMESH_DEVICE_KEY_ENTRY_VALID 2
#define BTMESH_LABEL_UUID_ENTRY_VALID 1
#define NO_LABEL_UUID_IDX_USED -1

#define CONFIG_APPKEY_ADD                                        0x0000
#define CONFIG_APPKEY_UPDATE                                     0x0001
#define CONFIG_COMPOSITION_DATA_STATUS                           0x0002
#define CONFIG_MODEL_PUBLICATION_SET                             0x0003
#define HEALTH_CURRENT_STATUS                                    0x0004
#define HEALTH_FAULT_STATUS                                      0x0005
#define CONFIG_HEARTBEAT_PUBLICATION_STATUS                      0x0006
#define CONFIG_APPKEY_DELETE                                     0x8000
#define CONFIG_APPKEY_GET                                        0x8001
#define CONFIG_APPKEY_LIST                                       0x8002
#define CONFIG_APPKEY_STATUS                                     0x8003
#define HEALTH_ATTENTION_GET                                     0x8004
#define HEALTH_ATTENTION_SET                                     0x8005
#define HEALTH_ATTENTION_SET_UNACKNOWLEDGED                      0x8006
#define HEALTH_ATTENTION_STATUS                                  0x8007
#define CONFIG_COMPOSITION_DATA_GET                              0x8008
#define CONFIG_BEACON_GET                                        0x8009
#define CONFIG_BEACON_SET                                        0x800a
#define CONFIG_BEACON_STATUS                                     0x800b
#define CONFIG_DEFAULT_TTL_GET                                   0x800c
#define CONFIG_DEFAULT_TTL_SET                                   0x800d
#define CONFIG_DEFAULT_TTL_STATUS                                0x800e
#define CONFIG_FRIEND_GET                                        0x800f
#define CONFIG_FRIEND_SET                                        0x8010
#define CONFIG_FRIEND_STATUS                                     0x8011
#define CONFIG_GATT_PROXY_GET                                    0x8012
#define CONFIG_GATT_PROXY_SET                                    0x8013
#define CONFIG_GATT_PROXY_STATUS                                 0x8014
#define CONFIG_KEY_REFRESH_PHASE_GET                             0x8015
#define CONFIG_KEY_REFRESH_PHASE_SET                             0x8016
#define CONFIG_KEY_REFRESH_PHASE_STATUS                          0x8017
#define CONFIG_MODEL_PUBLICATION_GET                             0x8018
#define CONFIG_MODEL_PUBLICATION_STATUS                          0x8019
#define CONFIG_MODEL_PUBLICATION_VIRTUAL_ADDRESS_SET             0x801a
#define CONFIG_MODEL_SUBSCRIPTION_ADD                            0x801b
#define CONFIG_MODEL_SUBSCRIPTION_DELETE                         0x801c
#define CONFIG_MODEL_SUBSCRIPTION_DELETE_ALL                     0x801d
#define CONFIG_MODEL_SUBSCRIPTION_OVERWRITE                      0x801e
#define CONFIG_MODEL_SUBSCRIPTION_STATUS                         0x801f
#define CONFIG_MODEL_SUBSCRIPTION_VIRTUAL_ADDRESS_ADD            0x8020
#define CONFIG_MODEL_SUBSCRIPTION_VIRTUAL_ADDRESS_DELETE         0x8021
#define CONFIG_MODEL_SUBSCRIPTION_VIRTUAL_ADDRESS_OVERWRITE      0x8022
#define CONFIG_NETWORK_TRANSMIT_GET                              0x8023
#define CONFIG_NETWORK_TRANSMIT_SET                              0x8024
#define CONFIG_NETWORK_TRANSMIT_STATUS                           0x8025
#define CONFIG_RELAY_GET                                         0x8026
#define CONFIG_RELAY_SET                                         0x8027
#define CONFIG_RELAY_STATUS                                      0x8028
#define CONFIG_SIG_MODEL_SUBSCRIPTION_GET                        0x8029
#define CONFIG_SIG_MODEL_SUBSCRIPTION_LIST                       0x802a
#define CONFIG_VENDOR_MODEL_SUBSCRIPTION_GET                     0x802b
#define CONFIG_VENDOR_MODEL_SUBSCRIPTION_LIST                    0x802c
#define CONFIG_LOW_POWER_NODE_POLLTIMEOUT_GET                    0x802d
#define CONFIG_LOW_POWER_NODE_POLLTIMEOUT_STATUS                 0x802e
#define HEALTH_FAULT_CLEAR                                       0x802f
#define HEALTH_FAULT_CLEAR_UNACKNOWLEDGED                        0x8030
#define HEALTH_FAULT_GET                                         0x8031
#define HEALTH_FAULT_TEST                                        0x8032
#define HEALTH_FAULT_TEST_UNACKNOWLEDGED                         0x8033
#define HEALTH_PERIOD_GET                                        0x8034
#define HEALTH_PERIOD_SET                                        0x8035
#define HEALTH_PERIOD_SET_UNACKNOWLEDGED                         0x8036
#define HEALTH_PERIOD_STATUS                                     0x8037
#define CONFIG_HEARTBEAT_PUBLICATION_GET                         0x8038
#define CONFIG_HEARTBEAT_PUBLICATION_SET                         0x8039
#define CONFIG_HEARTBEAT_SUBSCRIPTION_GET                        0x803a
#define CONFIG_HEARTBEAT_SUBSCRIPTION_SET                        0x803b
#define CONFIG_HEARTBEAT_SUBSCRIPTION_STATUS                     0x803c
#define CONFIG_MODEL_APP_BIND                                    0x803d
#define CONFIG_MODEL_APP_STATUS                                  0x803e
#define CONFIG_MODEL_APP_UNBIND                                  0x803f
#define CONFIG_NETKEY_ADD                                        0x8040
#define CONFIG_NETKEY_DELETE                                     0x8041
#define CONFIG_NETKEY_GET                                        0x8042
#define CONFIG_NETKEY_LIST                                       0x8043
#define CONFIG_NETKEY_STATUS                                     0x8044
#define CONFIG_NETKEY_UPDATE                                     0x8045
#define CONFIG_NODE_IDENTITY_GET                                 0x8046
#define CONFIG_NODE_IDENTITY_SET                                 0x8047
#define CONFIG_NODE_IDENTITY_STATUS                              0x8048
#define CONFIG_NODE_RESET                                        0x8049
#define CONFIG_NODE_RESET_STATUS                                 0x804a
#define CONFIG_SIG_MODEL_APP_GET                                 0x804b
#define CONFIG_SIG_MODEL_APP_LIST                                0x804c
#define CONFIG_VENDOR_MODEL_APP_GET                              0x804d
#define CONFIG_VENDOR_MODEL_APP_LIST                             0x804e

void proto_register_btmesh(void);

static int proto_btmesh = -1;
static dissector_table_t btmesh_model_vendor_dissector_table;

/*-------------------------------------
 * UAT for BT Mesh
 *-------------------------------------
 */
static uat_t *btmesh_uat = NULL;
static guint num_btmesh_uat = 0;

/* UAT Network, Application and IVIndex entry structure. */
typedef struct {
    gchar *network_key_string;
    guint8 *network_key;
    gint network_key_length;
    gchar *ivindex_string;
    gint ivindex_string_length;
    guint8 *ivindex;
    guint8 *privacykey;
    guint8 *encryptionkey;
    guint8 nid;
    gchar *application_key_string;
    guint8 *application_key;
    gint application_key_length;
    guint8 aid;
    guint8 valid; /* this counter must be equal to BTMESH_KEY_ENTRY_VALID make UAT entry valid */
    guint32 net_key_iv_index_hash; /* Used to identify net key / IV index pair */
} uat_btmesh_record_t;

static uat_btmesh_record_t *uat_btmesh_records = NULL;

static uat_t *btmesh_dev_key_uat = NULL;
static guint num_btmesh_dev_key_uat = 0;

/* UAT Device Key entry structure. */
typedef struct {
    gchar *device_key_string;
    guint8 *device_key;
    gint device_key_length;
    gchar *src_string;
    gint src_length;
    guint8 *src;
    guint8 valid; /* this counter must be equal to BTMESH_DEVICE_KEY_ENTRY_VALID make UAT entry valid */
} uat_btmesh_dev_key_record_t;

static uat_btmesh_dev_key_record_t *uat_btmesh_dev_key_records = NULL;

static uat_t * btmesh_label_uuid_uat = NULL;
static guint num_btmesh_label_uuid_uat = 0;

/* UAT Label UUID entry structure. */
typedef struct {
    gchar *label_uuid_string;
    guint8 *label_uuid;
    gint label_uuid_length;
    guint16 hash;
    guint8 valid; /* this counter must be equal to BTMESH_LABEL_UUID_ENTRY_VALID make UAT entry valid */
} uat_btmesh_label_uuid_record_t;

static uat_btmesh_label_uuid_record_t *uat_btmesh_label_uuid_records = NULL;

static int hf_btmesh_ivi = -1;
static int hf_btmesh_nid = -1;
static int hf_btmesh_obfuscated = -1;
static int hf_btmesh_encrypted = -1;
static int hf_btmesh_netmic = -1;

static int hf_btmesh_ctl = -1;
static int hf_btmesh_ttl = -1;
static int hf_btmesh_seq = -1;
static int hf_btmesh_src = -1;
static int hf_btmesh_dst = -1;

static int hf_btmesh_transp_pdu = -1;
static int hf_btmesh_cntr_seg = -1;
static int hf_btmesh_acc_seg = -1;
static int hf_btmesh_cntr_opcode = -1;
static int hf_btmesh_acc_akf = -1;
static int hf_btmesh_acc_aid = -1;
static int hf_btmesh_obo = -1;
static int hf_btmesh_seqzero = -1;
static int hf_btmesh_rfu = -1;
static int hf_btmesh_blockack = -1;
static int hf_btmesh_cntr_criteria_rfu = -1;
static int hf_btmesh_cntr_padding = -1;
static int hf_btmesh_cntr_fsn = -1;

static int hf_btmesh_cntr_key_refresh_flag = -1;
static int hf_btmesh_cntr_iv_update_flag = -1;
static int hf_btmesh_cntr_flags_rfu = -1;
static int hf_btmesh_cntr_iv_index = -1;
static int hf_btmesh_cntr_md = -1;

static int hf_btmesh_cntr_heartbeat_rfu = -1;
static int hf_btmesh_cntr_init_ttl = -1;
static int hf_btmesh_cntr_feature_relay = -1;
static int hf_btmesh_cntr_feature_proxy = -1;
static int hf_btmesh_cntr_feature_friend = -1;
static int hf_btmesh_cntr_feature_low_power = -1;
static int hf_btmesh_cntr_feature_rfu = -1;

static int hf_btmesh_cntr_criteria_rssifactor = -1;
static int hf_btmesh_cntr_criteria_receivewindowfactor = -1;
static int hf_btmesh_cntr_criteria_minqueuesizelog = -1;
static int hf_btmesh_cntr_receivedelay = -1;
static int hf_btmesh_cntr_polltimeout = -1;
static int hf_btmesh_cntr_previousaddress = -1;
static int hf_btmesh_cntr_numelements = -1;
static int hf_btmesh_cntr_lpncounter = -1;
static int hf_btmesh_cntr_receivewindow = -1;
static int hf_btmesh_cntr_queuesize = -1;
static int hf_btmesh_cntr_subscriptionlistsize = -1;
static int hf_btmesh_cntr_rssi = -1;
static int hf_btmesh_cntr_friendcounter = -1;
static int hf_btmesh_cntr_lpnaddress = -1;
static int hf_btmesh_cntr_transactionnumber = -1;
static int hf_btmesh_enc_access_pld = -1;
static int hf_btmesh_transtmic = -1;
static int hf_btmesh_szmic = -1;
static int hf_btmesh_seqzero_data = -1;
static int hf_btmesh_sego = -1;
static int hf_btmesh_segn = -1;
static int hf_btmesh_seg_rfu = -1;
static int hf_btmesh_segment = -1;
static int hf_btmesh_cntr_unknown_payload = -1;

static int hf_btmesh_segmented_access_fragments = -1;
static int hf_btmesh_segmented_access_fragment = -1;
static int hf_btmesh_segmented_access_fragment_overlap = -1;
static int hf_btmesh_segmented_access_fragment_overlap_conflict = -1;
static int hf_btmesh_segmented_access_fragment_multiple_tails = -1;
static int hf_btmesh_segmented_access_fragment_too_long_fragment = -1;
static int hf_btmesh_segmented_access_fragment_error = -1;
static int hf_btmesh_segmented_access_fragment_count = -1;
static int hf_btmesh_segmented_access_reassembled_length = -1;

static int hf_btmesh_segmented_control_fragments = -1;
static int hf_btmesh_segmented_control_fragment = -1;
static int hf_btmesh_segmented_control_fragment_overlap = -1;
static int hf_btmesh_segmented_control_fragment_overlap_conflict = -1;
static int hf_btmesh_segmented_control_fragment_multiple_tails = -1;
static int hf_btmesh_segmented_control_fragment_too_long_fragment = -1;
static int hf_btmesh_segmented_control_fragment_error = -1;
static int hf_btmesh_segmented_control_fragment_count = -1;
static int hf_btmesh_segmented_control_reassembled_length = -1;

static int hf_btmesh_decrypted_access = -1;
static int hf_btmesh_model_layer_opcode = -1;
static int hf_btmesh_model_layer_parameters = -1;
static int hf_btmesh_model_layer_vendor_opcode = -1;
static int hf_btmesh_model_layer_vendor = -1;

static int hf_btmesh_config_appkey_add_netkeyindexandappkeyindex = -1;
static int hf_btmesh_config_appkey_add_netkeyindexandappkeyindex_net = -1;
static int hf_btmesh_config_appkey_add_netkeyindexandappkeyindex_app = -1;
static int hf_btmesh_config_appkey_add_appkey = -1;
static int hf_btmesh_config_appkey_update_netkeyindexandappkeyindex = -1;
static int hf_btmesh_config_appkey_update_netkeyindexandappkeyindex_net = -1;
static int hf_btmesh_config_appkey_update_netkeyindexandappkeyindex_app = -1;
static int hf_btmesh_config_appkey_update_appkey = -1;
static int hf_btmesh_config_composition_data_status_page = -1;
static int hf_btmesh_config_composition_data_status_cid = -1;
static int hf_btmesh_config_composition_data_status_pid = -1;
static int hf_btmesh_config_composition_data_status_vid = -1;
static int hf_btmesh_config_composition_data_status_crpl = -1;
static int hf_btmesh_config_composition_data_status_features_relay = -1;
static int hf_btmesh_config_composition_data_status_features_proxy = -1;
static int hf_btmesh_config_composition_data_status_features_friend = -1;
static int hf_btmesh_config_composition_data_status_features_low_power = -1;
static int hf_btmesh_config_composition_data_status_features_rfu = -1;
static int hf_btmesh_config_composition_data_status_features = -1;
static int hf_btmesh_config_composition_data_status_loc = -1;
static int hf_btmesh_config_composition_data_status_nums = -1;
static int hf_btmesh_config_composition_data_status_numv = -1;
static int hf_btmesh_config_composition_data_status_sig_model = -1;
static int hf_btmesh_config_composition_data_status_vendor_model = -1;
static int hf_btmesh_config_model_publication_set_elementaddress = -1;
static int hf_btmesh_config_model_publication_set_publishaddress = -1;
static int hf_btmesh_config_model_publication_set_appkey = -1;
static int hf_btmesh_config_model_publication_set_appkeyindex = -1;
static int hf_btmesh_config_model_publication_set_credentialflag = -1;
static int hf_btmesh_config_model_publication_set_rfu = -1;
static int hf_btmesh_config_model_publication_set_publishttl = -1;
static int hf_btmesh_config_model_publication_set_publishperiod = -1;
static int hf_btmesh_config_model_publication_set_publishperiod_resolution = -1;
static int hf_btmesh_config_model_publication_set_publishperiod_steps = -1;
static int hf_btmesh_config_model_publication_set_publishretransmit = -1;
static int hf_btmesh_config_model_publication_set_publishretransmit_count = -1;
static int hf_btmesh_config_model_publication_set_publishretransmit_intervalsteps = -1;
static int hf_btmesh_config_model_publication_set_modelidentifier = -1;
static int hf_btmesh_config_model_publication_set_vendormodelidentifier = -1;
static int hf_btmesh_health_current_status_test_id = -1;
static int hf_btmesh_health_current_status_company_id = -1;
static int hf_btmesh_health_current_status_fault = -1;
static int hf_btmesh_health_fault_status_test_id = -1;
static int hf_btmesh_health_fault_status_company_id = -1;
static int hf_btmesh_health_fault_status_fault = -1;
static int hf_btmesh_config_heartbeat_publication_status_status = -1;
static int hf_btmesh_config_heartbeat_publication_status_destination = -1;
static int hf_btmesh_config_heartbeat_publication_status_countlog = -1;
static int hf_btmesh_config_heartbeat_publication_status_periodlog = -1;
static int hf_btmesh_config_heartbeat_publication_status_ttl = -1;
static int hf_btmesh_config_heartbeat_publication_status_features_relay = -1;
static int hf_btmesh_config_heartbeat_publication_status_features_proxy = -1;
static int hf_btmesh_config_heartbeat_publication_status_features_friend = -1;
static int hf_btmesh_config_heartbeat_publication_status_features_low_power = -1;
static int hf_btmesh_config_heartbeat_publication_status_features_rfu = -1;
static int hf_btmesh_config_heartbeat_publication_status_features = -1;
static int hf_btmesh_config_heartbeat_publication_status_netkeyindex = -1;
static int hf_btmesh_config_heartbeat_publication_status_netkeyindex_idx = -1;
static int hf_btmesh_config_heartbeat_publication_status_netkeyindex_rfu = -1;
static int hf_btmesh_config_appkey_delete_netkeyindexandappkeyindex = -1;
static int hf_btmesh_config_appkey_delete_netkeyindexandappkeyindex_net = -1;
static int hf_btmesh_config_appkey_delete_netkeyindexandappkeyindex_app = -1;
static int hf_btmesh_config_appkey_get_netkeyindex = -1;
static int hf_btmesh_config_appkey_get_netkeyindex_idx = -1;
static int hf_btmesh_config_appkey_get_netkeyindex_rfu = -1;
static int hf_btmesh_config_appkey_list_status = -1;
static int hf_btmesh_config_appkey_list_netkeyindex = -1;
static int hf_btmesh_config_appkey_list_netkeyindex_idx = -1;
static int hf_btmesh_config_appkey_list_netkeyindex_rfu = -1;
static int hf_btmesh_config_appkey_list_appkeyindex = -1;
static int hf_btmesh_config_appkey_list_appkeyindex_rfu = -1;
static int hf_btmesh_config_appkey_status_status = -1;
static int hf_btmesh_config_appkey_status_netkeyindexandappkeyindex = -1;
static int hf_btmesh_config_appkey_status_netkeyindexandappkeyindex_net = -1;
static int hf_btmesh_config_appkey_status_netkeyindexandappkeyindex_app = -1;
static int hf_btmesh_health_attention_set_attention = -1;
static int hf_btmesh_health_attention_set_unacknowledged_attention = -1;
static int hf_btmesh_health_attention_status_attention = -1;
static int hf_btmesh_config_composition_data_get_page = -1;
static int hf_btmesh_config_beacon_set_beacon = -1;
static int hf_btmesh_config_beacon_status_beacon = -1;
static int hf_btmesh_config_default_ttl_set_ttl = -1;
static int hf_btmesh_config_default_ttl_status_ttl = -1;
static int hf_btmesh_config_friend_set_friend = -1;
static int hf_btmesh_config_friend_status_friend = -1;
static int hf_btmesh_config_gatt_proxy_set_gattproxy = -1;
static int hf_btmesh_config_gatt_proxy_status_gattproxy = -1;
static int hf_btmesh_config_key_refresh_phase_get_netkeyindex = -1;
static int hf_btmesh_config_key_refresh_phase_get_netkeyindex_idx = -1;
static int hf_btmesh_config_key_refresh_phase_get_netkeyindex_rfu = -1;
static int hf_btmesh_config_key_refresh_phase_set_netkeyindex = -1;
static int hf_btmesh_config_key_refresh_phase_set_netkeyindex_idx = -1;
static int hf_btmesh_config_key_refresh_phase_set_netkeyindex_rfu = -1;
static int hf_btmesh_config_key_refresh_phase_set_transition = -1;
static int hf_btmesh_config_key_refresh_phase_status_status = -1;
static int hf_btmesh_config_key_refresh_phase_status_netkeyindex = -1;
static int hf_btmesh_config_key_refresh_phase_status_netkeyindex_idx = -1;
static int hf_btmesh_config_key_refresh_phase_status_netkeyindex_rfu = -1;
static int hf_btmesh_config_key_refresh_phase_status_phase = -1;
static int hf_btmesh_config_model_publication_get_elementaddress = -1;
static int hf_btmesh_config_model_publication_get_modelidentifier = -1;
static int hf_btmesh_config_model_publication_get_vendormodelidentifier = -1;
static int hf_btmesh_config_model_publication_status_status = -1;
static int hf_btmesh_config_model_publication_status_elementaddress = -1;
static int hf_btmesh_config_model_publication_status_publishaddress = -1;
static int hf_btmesh_config_model_publication_status_appkey = -1;
static int hf_btmesh_config_model_publication_status_appkeyindex = -1;
static int hf_btmesh_config_model_publication_status_credentialflag = -1;
static int hf_btmesh_config_model_publication_status_rfu = -1;
static int hf_btmesh_config_model_publication_status_publishttl = -1;
static int hf_btmesh_config_model_publication_status_publishperiod = -1;
static int hf_btmesh_config_model_publication_status_publishperiod_resolution = -1;
static int hf_btmesh_config_model_publication_status_publishperiod_steps = -1;
static int hf_btmesh_config_model_publication_status_publishretransmit = -1;
static int hf_btmesh_config_model_publication_status_publishretransmit_count = -1;
static int hf_btmesh_config_model_publication_status_publishretransmit_intervalsteps = -1;
static int hf_btmesh_config_model_publication_status_modelidentifier = -1;
static int hf_btmesh_config_model_publication_status_vendormodelidentifier = -1;
static int hf_btmesh_config_model_publication_virtual_address_set_elementaddress = -1;
static int hf_btmesh_config_model_publication_virtual_address_set_publishaddress = -1;
static int hf_btmesh_config_model_publication_virtual_address_set_appkey = -1;
static int hf_btmesh_config_model_publication_virtual_address_set_appkeyindex = -1;
static int hf_btmesh_config_model_publication_virtual_address_set_credentialflag = -1;
static int hf_btmesh_config_model_publication_virtual_address_set_rfu = -1;
static int hf_btmesh_config_model_publication_virtual_address_set_publishttl = -1;
static int hf_btmesh_config_model_publication_virtual_address_set_publishperiod = -1;
static int hf_btmesh_config_model_publication_virtual_address_set_publishperiod_resolution = -1;
static int hf_btmesh_config_model_publication_virtual_address_set_publishperiod_steps = -1;
static int hf_btmesh_config_model_publication_virtual_address_set_publishretransmit = -1;
static int hf_btmesh_config_model_publication_virtual_address_set_publishretransmit_count = -1;
static int hf_btmesh_config_model_publication_virtual_address_set_publishretransmit_intervalsteps = -1;
static int hf_btmesh_config_model_publication_virtual_address_set_modelidentifier = -1;
static int hf_btmesh_config_model_publication_virtual_address_set_vendormodelidentifier = -1;
static int hf_btmesh_config_model_subscription_add_elementaddress = -1;
static int hf_btmesh_config_model_subscription_add_address = -1;
static int hf_btmesh_config_model_subscription_add_modelidentifier = -1;
static int hf_btmesh_config_model_subscription_add_vendormodelidentifier = -1;
static int hf_btmesh_config_model_subscription_delete_elementaddress = -1;
static int hf_btmesh_config_model_subscription_delete_address = -1;
static int hf_btmesh_config_model_subscription_delete_modelidentifier = -1;
static int hf_btmesh_config_model_subscription_delete_vendormodelidentifier = -1;
static int hf_btmesh_config_model_subscription_delete_all_elementaddress = -1;
static int hf_btmesh_config_model_subscription_delete_all_modelidentifier = -1;
static int hf_btmesh_config_model_subscription_delete_all_vendormodelidentifier = -1;
static int hf_btmesh_config_model_subscription_overwrite_elementaddress = -1;
static int hf_btmesh_config_model_subscription_overwrite_address = -1;
static int hf_btmesh_config_model_subscription_overwrite_modelidentifier = -1;
static int hf_btmesh_config_model_subscription_overwrite_vendormodelidentifier = -1;
static int hf_btmesh_config_model_subscription_status_status = -1;
static int hf_btmesh_config_model_subscription_status_elementaddress = -1;
static int hf_btmesh_config_model_subscription_status_address = -1;
static int hf_btmesh_config_model_subscription_status_modelidentifier = -1;
static int hf_btmesh_config_model_subscription_status_vendormodelidentifier = -1;
static int hf_btmesh_config_model_subscription_virtual_address_add_elementaddress = -1;
static int hf_btmesh_config_model_subscription_virtual_address_add_label = -1;
static int hf_btmesh_config_model_subscription_virtual_address_add_modelidentifier = -1;
static int hf_btmesh_config_model_subscription_virtual_address_add_vendormodelidentifier = -1;
static int hf_btmesh_config_model_subscription_virtual_address_delete_elementaddress = -1;
static int hf_btmesh_config_model_subscription_virtual_address_delete_label = -1;
static int hf_btmesh_config_model_subscription_virtual_address_delete_modelidentifier = -1;
static int hf_btmesh_config_model_subscription_virtual_address_delete_vendormodelidentifier = -1;
static int hf_btmesh_config_model_subscription_virtual_address_overwrite_elementaddress = -1;
static int hf_btmesh_config_model_subscription_virtual_address_overwrite_label = -1;
static int hf_btmesh_config_model_subscription_virtual_address_overwrite_modelidentifier = -1;
static int hf_btmesh_config_model_subscription_virtual_address_overwrite_vendormodelidentifier = -1;
static int hf_btmesh_config_network_transmit_set_networktransmit = -1;
static int hf_btmesh_config_network_transmit_set_networktransmit_count = -1;
static int hf_btmesh_config_network_transmit_set_networktransmit_intervalsteps = -1;
static int hf_btmesh_config_network_transmit_status_networktransmit = -1;
static int hf_btmesh_config_network_transmit_status_networktransmit_count = -1;
static int hf_btmesh_config_network_transmit_status_networktransmit_intervalsteps = -1;
static int hf_btmesh_config_relay_set_relay = -1;
static int hf_btmesh_config_relay_set_relayretransmit = -1;
static int hf_btmesh_config_relay_set_relayretransmit_count = -1;
static int hf_btmesh_config_relay_set_relayretransmit_intervalsteps = -1;
static int hf_btmesh_config_relay_status_relay = -1;
static int hf_btmesh_config_relay_status_relayretransmit = -1;
static int hf_btmesh_config_relay_status_relayretransmit_count = -1;
static int hf_btmesh_config_relay_status_relayretransmit_intervalsteps = -1;
static int hf_btmesh_config_sig_model_subscription_get_elementaddress = -1;
static int hf_btmesh_config_sig_model_subscription_get_modelidentifier = -1;
static int hf_btmesh_config_sig_model_subscription_list_status = -1;
static int hf_btmesh_config_sig_model_subscription_list_elementaddress = -1;
static int hf_btmesh_config_sig_model_subscription_list_modelidentifier = -1;
static int hf_btmesh_config_sig_model_subscription_list_address = -1;
static int hf_btmesh_config_vendor_model_subscription_get_elementaddress = -1;
static int hf_btmesh_config_vendor_model_subscription_get_modelidentifier = -1;
static int hf_btmesh_config_vendor_model_subscription_list_status = -1;
static int hf_btmesh_config_vendor_model_subscription_list_elementaddress = -1;
static int hf_btmesh_config_vendor_model_subscription_list_modelidentifier = -1;
static int hf_btmesh_config_vendor_model_subscription_list_address = -1;
static int hf_btmesh_config_low_power_node_polltimeout_get_lpnaddress = -1;
static int hf_btmesh_config_low_power_node_polltimeout_status_lpnaddress = -1;
static int hf_btmesh_config_low_power_node_polltimeout_status_polltimeout = -1;
static int hf_btmesh_health_fault_clear_company_id = -1;
static int hf_btmesh_health_fault_clear_unacknowledged_company_id = -1;
static int hf_btmesh_health_fault_get_company_id = -1;
static int hf_btmesh_health_fault_test_test_id = -1;
static int hf_btmesh_health_fault_test_company_id = -1;
static int hf_btmesh_health_fault_test_unacknowledged_test_id = -1;
static int hf_btmesh_health_fault_test_unacknowledged_company_id = -1;
static int hf_btmesh_health_period_set_fastperioddivisor = -1;
static int hf_btmesh_health_period_set_unacknowledged_fastperioddivisor = -1;
static int hf_btmesh_health_period_status_fastperioddivisor = -1;
static int hf_btmesh_config_heartbeat_publication_set_destination = -1;
static int hf_btmesh_config_heartbeat_publication_set_countlog = -1;
static int hf_btmesh_config_heartbeat_publication_set_periodlog = -1;
static int hf_btmesh_config_heartbeat_publication_set_ttl = -1;
static int hf_btmesh_config_heartbeat_publication_set_features_relay = -1;
static int hf_btmesh_config_heartbeat_publication_set_features_proxy = -1;
static int hf_btmesh_config_heartbeat_publication_set_features_friend = -1;
static int hf_btmesh_config_heartbeat_publication_set_features_low_power = -1;
static int hf_btmesh_config_heartbeat_publication_set_features_rfu = -1;
static int hf_btmesh_config_heartbeat_publication_set_features = -1;
static int hf_btmesh_config_heartbeat_publication_set_netkeyindex = -1;
static int hf_btmesh_config_heartbeat_publication_set_netkeyindex_idx = -1;
static int hf_btmesh_config_heartbeat_publication_set_netkeyindex_rfu = -1;
static int hf_btmesh_config_heartbeat_subscription_set_source = -1;
static int hf_btmesh_config_heartbeat_subscription_set_destination = -1;
static int hf_btmesh_config_heartbeat_subscription_set_periodlog = -1;
static int hf_btmesh_config_heartbeat_subscription_status_status = -1;
static int hf_btmesh_config_heartbeat_subscription_status_source = -1;
static int hf_btmesh_config_heartbeat_subscription_status_destination = -1;
static int hf_btmesh_config_heartbeat_subscription_status_periodlog = -1;
static int hf_btmesh_config_heartbeat_subscription_status_countlog = -1;
static int hf_btmesh_config_heartbeat_subscription_status_minhops = -1;
static int hf_btmesh_config_heartbeat_subscription_status_maxhops = -1;
static int hf_btmesh_config_model_app_bind_elementaddress = -1;
static int hf_btmesh_config_model_app_bind_appkeyindex = -1;
static int hf_btmesh_config_model_app_bind_appkeyindex_idx = -1;
static int hf_btmesh_config_model_app_bind_appkeyindex_rfu = -1;
static int hf_btmesh_config_model_app_bind_modelidentifier = -1;
static int hf_btmesh_config_model_app_bind_vendormodelidentifier = -1;
static int hf_btmesh_config_model_app_status_status = -1;
static int hf_btmesh_config_model_app_status_elementaddress = -1;
static int hf_btmesh_config_model_app_status_appkeyindex = -1;
static int hf_btmesh_config_model_app_status_appkeyindex_idx = -1;
static int hf_btmesh_config_model_app_status_appkeyindex_rfu = -1;
static int hf_btmesh_config_model_app_status_modelidentifier = -1;
static int hf_btmesh_config_model_app_status_vendormodelidentifier = -1;
static int hf_btmesh_config_model_app_unbind_elementaddress = -1;
static int hf_btmesh_config_model_app_unbind_appkeyindex = -1;
static int hf_btmesh_config_model_app_unbind_appkeyindex_idx = -1;
static int hf_btmesh_config_model_app_unbind_appkeyindex_rfu = -1;
static int hf_btmesh_config_model_app_unbind_modelidentifier = -1;
static int hf_btmesh_config_model_app_unbind_vendormodelidentifier = -1;
static int hf_btmesh_config_netkey_add_netkeyindex = -1;
static int hf_btmesh_config_netkey_add_netkeyindex_idx = -1;
static int hf_btmesh_config_netkey_add_netkeyindex_rfu = -1;
static int hf_btmesh_config_netkey_add_netkey = -1;
static int hf_btmesh_config_netkey_delete_netkeyindex = -1;
static int hf_btmesh_config_netkey_delete_netkeyindex_idx = -1;
static int hf_btmesh_config_netkey_delete_netkeyindex_rfu = -1;
static int hf_btmesh_config_netkey_list_netkeyindex = -1;
static int hf_btmesh_config_netkey_list_netkeyindex_rfu = -1;
static int hf_btmesh_config_netkey_status_status = -1;
static int hf_btmesh_config_netkey_status_netkeyindex = -1;
static int hf_btmesh_config_netkey_status_netkeyindex_idx = -1;
static int hf_btmesh_config_netkey_status_netkeyindex_rfu = -1;
static int hf_btmesh_config_netkey_update_netkeyindex = -1;
static int hf_btmesh_config_netkey_update_netkeyindex_idx = -1;
static int hf_btmesh_config_netkey_update_netkeyindex_rfu = -1;
static int hf_btmesh_config_netkey_update_netkey = -1;
static int hf_btmesh_config_node_identity_get_netkeyindex = -1;
static int hf_btmesh_config_node_identity_get_netkeyindex_idx = -1;
static int hf_btmesh_config_node_identity_get_netkeyindex_rfu = -1;
static int hf_btmesh_config_node_identity_set_netkeyindex = -1;
static int hf_btmesh_config_node_identity_set_netkeyindex_idx = -1;
static int hf_btmesh_config_node_identity_set_netkeyindex_rfu = -1;
static int hf_btmesh_config_node_identity_set_identity = -1;
static int hf_btmesh_config_node_identity_status_status = -1;
static int hf_btmesh_config_node_identity_status_netkeyindex = -1;
static int hf_btmesh_config_node_identity_status_netkeyindex_idx = -1;
static int hf_btmesh_config_node_identity_status_netkeyindex_rfu = -1;
static int hf_btmesh_config_node_identity_status_identity = -1;
static int hf_btmesh_config_sig_model_app_get_elementaddress = -1;
static int hf_btmesh_config_sig_model_app_get_modelidentifier = -1;
static int hf_btmesh_config_sig_model_app_list_status = -1;
static int hf_btmesh_config_sig_model_app_list_elementaddress = -1;
static int hf_btmesh_config_sig_model_app_list_modelidentifier = -1;
static int hf_btmesh_config_sig_model_app_list_appkeyindex = -1;
static int hf_btmesh_config_sig_model_app_list_appkeyindex_rfu = -1;
static int hf_btmesh_config_vendor_model_app_get_elementaddress = -1;
static int hf_btmesh_config_vendor_model_app_get_modelidentifier = -1;
static int hf_btmesh_config_vendor_model_app_list_status = -1;
static int hf_btmesh_config_vendor_model_app_list_elementaddress = -1;
static int hf_btmesh_config_vendor_model_app_list_modelidentifier = -1;
static int hf_btmesh_config_vendor_model_app_list_appkeyindex = -1;
static int hf_btmesh_config_vendor_model_app_list_appkeyindex_rfu = -1;

static int ett_btmesh = -1;
static int ett_btmesh_net_pdu = -1;
static int ett_btmesh_transp_pdu = -1;
static int ett_btmesh_transp_ctrl_msg = -1;
static int ett_btmesh_upper_transp_acc_pdu = -1;
static int ett_btmesh_segmented_access_fragments = -1;
static int ett_btmesh_segmented_access_fragment = -1;
static int ett_btmesh_segmented_control_fragments = -1;
static int ett_btmesh_segmented_control_fragment = -1;
static int ett_btmesh_access_pdu = -1;
static int ett_btmesh_model_layer = -1;

static int ett_btmesh_config_model_netapp_index = -1;
static int ett_btmesh_config_model_publishperiod = -1;
static int ett_btmesh_config_model_publishretransmit = -1;
static int ett_btmesh_config_model_relayretransmit = -1;
static int ett_btmesh_config_model_network_transmit = -1;
static int ett_btmesh_config_model_element = -1;
static int ett_btmesh_config_model_model = -1;
static int ett_btmesh_config_model_vendor = -1;
static int ett_btmesh_config_composition_data_status_features = -1;
static int ett_btmesh_config_model_pub_app_index = -1;
static int ett_btmesh_config_model_addresses = -1;
static int ett_btmesh_config_model_netkey_list = -1;
static int ett_btmesh_config_model_appkey_list = -1;
static int ett_btmesh_config_model_net_index = -1;
static int ett_btmesh_config_model_app_index = -1;
static int ett_btmesh_config_heartbeat_publication_set_features = -1;
static int ett_btmesh_config_heartbeat_publication_status_features = -1;
static int ett_btmesh_config_model_fault_array = -1;

static expert_field ei_btmesh_not_decoded_yet = EI_INIT;
static expert_field ei_btmesh_unknown_payload = EI_INIT;

static const value_string btmesh_ctl_vals[] = {
    { 0, "Access Message" },
    { 1, "Control Message" },
    { 0, NULL }
};

static const value_string btmesh_ctrl_seg_vals[] = {
    { 0, "Unsegmented Control Message" },
    { 1, "Segmented Control Message" },
    { 0, NULL }
};

static const value_string btmesh_acc_seg_vals[] = {
    { 0, "Unsegmented Access Message" },
    { 1, "Segmented Access Message" },
    { 0, NULL }
};

static const value_string btmesh_acc_akf_vals[] = {
    { 0, "Device key" },
    { 1, "Application key" },
    { 0, NULL }
};

static const value_string btmesh_ctrl_opcode_vals[] = {
    { 0x0, "Segment Acknowledgment" }, /* Reserved for lower transport layer */
    { 0x1, "Friend Poll" },
    { 0x2, "Friend Update" },
    { 0x3, "Friend Request" },
    { 0x4, "Friend Offer" },
    { 0x5, "Friend Clear" },
    { 0x6, "Friend Clear Confirm" },
    { 0x7, "Friend Subscription List Add" },
    { 0x8, "Friend Subscription List Remove" },
    { 0x9, "Friend Subscription List Confirm" },
    { 0xa, "Heartbeat" },
    { 0, NULL }
};

static const value_string btmesh_cntr_key_refresh_flag_vals[] = {
    { 0x0, "Not-In-Phase2" },
    { 0x1, "In-Phase2" },
    { 0, NULL }
};

static const value_string btmesh_cntr_iv_update_flag_vals[] = {
    { 0x0, "Normal operation" },
    { 0x1, "IV Update active" },
    { 0, NULL }
};

static const value_string btmesh_cntr_md_vals[] = {
    { 0x0, "Friend Queue is empty" },
    { 0x1, "Friend Queue is not empty" },
    { 0, NULL }
};

static const true_false_string  btmesh_obo = {
    "Friend node that is acknowledging this message on behalf of a Low Power node",
    "Node that is directly addressed by the received message"
};

static const value_string btmesh_criteria_rssifactor_vals[] = {
    { 0x0, "1" },
    { 0x1, "1.5" },
    { 0x2, "2" },
    { 0x3, "2.5" },
    { 0, NULL }
};

static const value_string btmesh_criteria_receivewindowfactor_vals[] = {
    { 0x0, "1" },
    { 0x1, "1.5" },
    { 0x2, "2" },
    { 0x3, "2.5" },
    { 0, NULL }
};

static const value_string btmesh_criteria_minqueuesizelog_vals[] = {
    { 0x0, "Prohibited" },
    { 0x1, "N = 2" },
    { 0x2, "N = 4" },
    { 0x3, "N = 8" },
    { 0x4, "N = 16" },
    { 0x5, "N = 32" },
    { 0x6, "N = 64" },
    { 0x7, "N = 128" },
    { 0, NULL }
};

static const value_string btmesh_szmic_vals[] = {
    { 0x0, "32-bit" },
    { 0x1, "64-bit" },
    { 0, NULL }
};

static const value_string btmesh_models_opcode_vals[] = {
    /* Bluetooth Mesh Foundation messages */
    { 0x00, "Config AppKey Add" },
    { 0x01, "Config AppKey Update" },
    { 0x02, "Config Composition Data Status" },
    { 0x03, "Config Config Model Publication Set" },
    { 0x04, "Health Current Status" },
    { 0x05, "Health Fault Status" },
    { 0x06, "Config Heartbeat Publication Status" },
    { 0x8000, "Config AppKey Delete" },
    { 0x8001, "Config AppKey Get" },
    { 0x8002, "Config AppKey List" },
    { 0x8003, "Config AppKey Status" },
    { 0x8004, "Health Attention Get" },
    { 0x8005, "Health Attention Set" },
    { 0x8006, "Health Attention Set Unacknowledged" },
    { 0x8007, "Health Attention Status" },
    { 0x8008, "Config Composition Data Get" },
    { 0x8009, "Config Beacon Get" },
    { 0x800A, "Config Beacon Set" },
    { 0x800B, "Config Beacon Status" },
    { 0x800C, "Config Default TTL Get" },
    { 0x800D, "Config Default TTL Set" },
    { 0x800E, "Config Default TTL Status" },
    { 0x800F, "Config Friend Get" },
    { 0x8010, "Config Friend Set" },
    { 0x8011, "Config Friend Status" },
    { 0x8012, "Config GATT Proxy Get" },
    { 0x8013, "Config GATT Proxy Set" },
    { 0x8014, "Config GATT Proxy Status" },
    { 0x8015, "Config Key Refresh Phase Get" },
    { 0x8016, "Config Key Refresh Phase Set" },
    { 0x8017, "Config Key Refresh Phase Status" },
    { 0x8018, "Config Model Publication Get" },
    { 0x8019, "Config Model Publication Status" },
    { 0x801A, "Config Model Publication Virtual Address Set" },
    { 0x801B, "Config Model Subscription Add" },
    { 0x801C, "Config Model Subscription Delete" },
    { 0x801D, "Config Model Subscription Delete All" },
    { 0x801E, "Config Model Subscription Overwrite" },
    { 0x801F, "Config Model Subscription Status" },
    { 0x8020, "Config Model Subscription Virtual Address Add" },
    { 0x8021, "Config Model Subscription Virtual Address Delete" },
    { 0x8022, "Config Model Subscription Virtual Address Overwrite" },
    { 0x8023, "Config Network Transmit Get" },
    { 0x8024, "Config Network Transmit Set" },
    { 0x8025, "Config Network Transmit Status" },
    { 0x8026, "Config Relay Get" },
    { 0x8027, "Config Relay Set" },
    { 0x8028, "Config Relay Status" },
    { 0x8029, "Config SIG Model Subscription Get" },
    { 0x802A, "Config SIG Model Subscription List" },
    { 0x802B, "Config Vendor Model Subscription Get" },
    { 0x802C, "Config Vendor Model Subscription List" },
    { 0x802D, "Config Low Power Node PollTimeout Get" },
    { 0x802E, "Config Low Power Node PollTimeout Status" },
    { 0x802F, "Health Fault Clear" },
    { 0x8030, "Health Fault Clear Unacknowledged" },
    { 0x8031, "Health Fault Get" },
    { 0x8032, "Health Fault Test" },
    { 0x8033, "Health Fault Test Unacknowledged" },
    { 0x8034, "Health Period Get" },
    { 0x8035, "Health Period Set" },
    { 0x8036, "Health Period Set Unacknowledged" },
    { 0x8037, "Health Period Status" },
    { 0x8038, "Config Heartbeat Publication Get" },
    { 0x8039, "Config Heartbeat Publication Set" },
    { 0x803A, "Config Heartbeat Subscription Get" },
    { 0x803B, "Config Heartbeat Subscription Set" },
    { 0x803C, "Config Heartbeat Subscription Status" },
    { 0x803D, "Config Model App Bind" },
    { 0x803E, "Config Model App Status" },
    { 0x803F, "Config Model App Unbind" },
    { 0x8040, "Config NetKey Add" },
    { 0x8041, "Config NetKey Delete" },
    { 0x8042, "Config NetKey Get" },
    { 0x8043, "Config NetKey List" },
    { 0x8044, "Config NetKey Status" },
    { 0x8045, "Config NetKey Update" },
    { 0x8046, "Config Node Identity Get" },
    { 0x8047, "Config Node Identity Set" },
    { 0x8048, "Config Node Identity Status" },
    { 0x8049, "Config Node Reset" },
    { 0x804A, "Config Node Reset Status" },
    { 0x804B, "Config SIG Model App Get" },
    { 0x804C, "Config SIG Model App List" },
    { 0x804D, "Config Vendor Model App Get" },
    { 0x804E, "Config Vendor Model App List" },

    /* Bluetooth Mesh Model messages */
    { 0x8201, "Generic OnOff Get" },
    { 0x8202, "Generic OnOff Set" },
    { 0x8203, "Generic OnOff Set Unacknowledged" },
    { 0x8204, "Generic OnOff Status" },
    { 0x8205, "Generic Level Get" },
    { 0x8206, "Generic Level Set" },
    { 0x8207, "Generic Level Set Unacknowledged" },
    { 0x8208, "Generic Level Status" },
    { 0x8209, "Generic Delta Set" },
    { 0x820A, "Generic Delta Set Unacknowledged" },
    { 0x820B, "Generic Move Set" },
    { 0x820C, "Generic Move Set Unacknowledged" },
    { 0x820D, "Generic Default Transition Time Get" },
    { 0x820E, "Generic Default Transition Time Set" },
    { 0x820F, "Generic Default Transition Time Set Unacknowledged" },
    { 0x8210, "Generic Default Transition Time Status" },
    { 0x8211, "Generic OnPowerUp Get" },
    { 0x8212, "Generic OnPowerUp Status" },
    { 0x8213, "Generic OnPowerUp Set" },
    { 0x8214, "Generic OnPowerUp Set Unacknowledged" },
    { 0x8215, "Generic Power Level Get" },
    { 0x8216, "Generic Power Level Set" },
    { 0x8217, "Generic Power Level Set Unacknowledged" },
    { 0x8218, "Generic Power Level Status" },
    { 0x8219, "Generic Power Last Get" },
    { 0x821A, "Generic Power Last Status" },
    { 0x821B, "Generic Power Default Get" },
    { 0x821C, "Generic Power Default Status" },
    { 0x821D, "Generic Power Range Get" },
    { 0x821E, "Generic Power Range Status" },
    { 0x821F, "Generic Power Default Set" },
    { 0x8220, "Generic Power Default Set Unacknowledged" },
    { 0x8221, "Generic Power Range Set" },
    { 0x8222, "Generic Power Range Set Unacknowledged" },
    { 0x8223, "Generic Battery Get" },
    { 0x8224, "Generic Battery Status" },
    { 0x8225, "Generic Location Global Get" },
    { 0x40, "Generic Location Global Status" },
    { 0x8226, "Generic Location Local Get" },
    { 0x8227, "Generic Location Local Status" },
    { 0x41, "Generic Location Global Set" },
    { 0x42, "Generic Location Global Set Unacknowledged" },
    { 0x8228, "Generic Location Local Set" },
    { 0x8229, "Generic Location Local Set Unacknowledged" },
    { 0x822A, "Generic Manufacturer Properties Get" },
    { 0x43, "Generic Manufacturer Properties Status" },
    { 0x822B, "Generic Manufacturer Property Get" },
    { 0x44, "Generic Manufacturer Property Set" },
    { 0x45, "Generic Manufacturer Property Set Unacknowledged" },
    { 0x46, "Generic Manufacturer Property Status" },
    { 0x822C, "Generic Admin Properties Get" },
    { 0x47, "Generic Admin Properties Status" },
    { 0x822D, "Generic Admin Property Get" },
    { 0x48, "Generic Admin Property Set" },
    { 0x49, "Generic Admin Property Set Unacknowledged" },
    { 0x4A, "Generic Admin Property Status" },
    { 0x822E, "Generic User Properties Get" },
    { 0x4B, "Generic User Properties Status" },
    { 0x822F, "Generic User Property Get" },
    { 0x4C, "Generic User Property Set" },
    { 0x4D, "Generic User Property Set Unacknowledged" },
    { 0x4E, "Generic User Property Status" },
    { 0x4F, "Generic Client Properties Get" },
    { 0x50, "Generic Client Properties Status" },
    { 0x8230, "Sensor Descriptor Get" },
    { 0x51, "Sensor Descriptor Status" },
    { 0x8231, "Sensor Get" },
    { 0x52, "Sensor Status" },
    { 0x8232, "Sensor Column Get" },
    { 0x53, "Sensor Column Status" },
    { 0x8233, "Sensor Series Get" },
    { 0x54, "Sensor Series Status" },
    { 0x8234, "Sensor Cadence Get" },
    { 0x55, "Sensor Cadence Set" },
    { 0x56, "Sensor Cadence Set Unacknowledged" },
    { 0x57, "Sensor Cadence Status" },
    { 0x8235, "Sensor Settings Get" },
    { 0x58, "Sensor Settings Status" },
    { 0x8236, "Sensor Setting Get" },
    { 0x59, "Sensor Setting Set" },
    { 0x5A, "Sensor Setting Set Unacknowledged" },
    { 0x5B, "Sensor Setting Status" },
    { 0x8237, "Time Get" },
    { 0x5C, "Time Set" },
    { 0x5D, "Time Status" },
    { 0x8238, "Time Role Get" },
    { 0x8239, "Time Role Set" },
    { 0x823A, "Time Role Status" },
    { 0x823B, "Time Zone Get" },
    { 0x823C, "Time Zone Set" },
    { 0x823D, "Time Zone Status" },
    { 0x823E, "TAI-UTC Delta Get" },
    { 0x823F, "TAI-UTC Delta Set" },
    { 0x8240, "TAI-UTC Delta Status" },
    { 0x8241, "Scene Get" },
    { 0x8242, "Scene Recall" },
    { 0x8243, "Scene Recall Unacknowledged" },
    { 0x5E, "Scene Status" },
    { 0x8244, "Scene Register Get" },
    { 0x8245, "Scene Register Status" },
    { 0x8246, "Scene Store" },
    { 0x8247, "Scene Store Unacknowledged" },
    { 0x829E, "Scene Delete" },
    { 0x829F, "Scene Delete Unacknowledged" },
    { 0x8248, "Scheduler Action Get" },
    { 0x5F, "Scheduler Action Status" },
    { 0x8249, "Scheduler Get" },
    { 0x824A, "Scheduler Status" },
    { 0x60, "Scheduler Action Set" },
    { 0x61, "Scheduler Action Set Unacknowledged" },
    { 0x824B, "Light Lightness Light Lightness Get" },
    { 0x824C, "Light Lightness Set" },
    { 0x824D, "Light Lightness Set Unacknowledged" },
    { 0x824E, "Light Lightness Status" },
    { 0x824F, "Light Lightness Linear Get" },
    { 0x8250, "Light Lightness Linear Set" },
    { 0x8251, "Light Lightness Linear Set Unacknowledged" },
    { 0x8252, "Light Lightness Linear Status" },
    { 0x8253, "Light Lightness Last Get" },
    { 0x8254, "Light Lightness Last Status" },
    { 0x8255, "Light Lightness Default Get" },
    { 0x8256, "Light Lightness Default Status" },
    { 0x8257, "Light Lightness Range Get" },
    { 0x8258, "Light Lightness Range Status" },
    { 0x8259, "Light Lightness Default Set" },
    { 0x825A, "Light Lightness Default Set Unacknowledged" },
    { 0x825B, "Light Lightness Range Set" },
    { 0x825C, "Light Lightness Range Set Unacknowledged" },
    { 0x825D, "Light CTL Get" },
    { 0x825E, "Light CTL Set" },
    { 0x825F, "Light CTL Set Unacknowledged" },
    { 0x8260, "Light CTL Status" },
    { 0x8261, "Light CTL Temperature Get" },
    { 0x8262, "Light CTL Temperature Range Get" },
    { 0x8263, "Light CTL Temperature Range Status" },
    { 0x8264, "Light CTL Temperature Set" },
    { 0x8265, "Light CTL Temperature Set Unacknowledged" },
    { 0x8266, "Light CTL Temperature Status" },
    { 0x8267, "Light CTL Default Get" },
    { 0x8268, "Light CTL Default Status" },
    { 0x8269, "Light CTL Default Set" },
    { 0x826A, "Light CTL Default Set Unacknowledged" },
    { 0x826B, "Light CTL Temperature Range Set" },
    { 0x826C, "Light CTL Temperature Range Set Unacknowledged" },
    { 0x826D, "Light HSL Get" },
    { 0x826E, "Light HSL Hue Get" },
    { 0x826F, "Light HSL Hue Set" },
    { 0x8270, "Light HSL Hue Set Unacknowledged" },
    { 0x8271, "Light HSL Hue Status" },
    { 0x8272, "Light HSL Saturation Get" },
    { 0x8273, "Light HSL Saturation Set" },
    { 0x8274, "Light HSL Saturation Set Unacknowledged" },
    { 0x8275, "Light HSL Saturation Status" },
    { 0x8276, "Light HSL Set" },
    { 0x8277, "Light HSL Set Unacknowledged" },
    { 0x8278, "Light HSL Status" },
    { 0x8279, "Light HSL Target Get" },
    { 0x827A, "Light HSL Target Status" },
    { 0x827B, "Light HSL Default Get" },
    { 0x827C, "Light HSL Default Status" },
    { 0x827D, "Light HSL Range Get" },
    { 0x827E, "Light HSL Range Status" },
    { 0x827F, "Light HSL Default Set" },
    { 0x8280, "Light HSL Default Set Unacknowledged" },
    { 0x8281, "Light HSL Range Set" },
    { 0x8282, "Light HSL Range Set Unacknowledged" },
    { 0x8283, "Light xyL Get" },
    { 0x8284, "Light xyL Set" },
    { 0x8285, "Light xyL Set Unacknowledged" },
    { 0x8286, "Light xyL Status" },
    { 0x8287, "Light xyL Target Get" },
    { 0x8288, "Light xyL Target Status" },
    { 0x8289, "Light xyL Default Get" },
    { 0x828A, "Light xyL Default Status" },
    { 0x828B, "Light xyL Range Get" },
    { 0x828C, "Light xyL Range Status" },
    { 0x828D, "Light xyL Default Set" },
    { 0x828E, "Light xyL Default Set Unacknowledged" },
    { 0x828F, "Light xyL Range Set" },
    { 0x8290, "Light xyL Range Set Unacknowledged" },
    { 0x8291, "Light LC Mode Get" },
    { 0x8292, "Light LC Mode Set" },
    { 0x8293, "Light LC Mode Set Unacknowledged" },
    { 0x8294, "Light LC Mode Status" },
    { 0x8295, "Light LC OM Get" },
    { 0x8296, "Light LC OM Set" },
    { 0x8297, "Light LC OM Set Unacknowledged" },
    { 0x8298, "Light LC OM Status" },
    { 0x8299, "Light LC Light OnOff Get" },
    { 0x829A, "Light LC Light OnOff Set" },
    { 0x829B, "Light LC Light OnOff Set Unacknowledged" },
    { 0x829C, "Light LC Light OnOff Status" },
    { 0x829D, "Light LC Property Get" },
    { 0x62, "Light LC Property Set" },
    { 0x63, "Light LC Property Set Unacknowledged" },
    { 0x64, "Light LC Property Status" },
    { 0, NULL }
};

static const value_string btmesh_beacon_broadcast_vals[] = {
    { 0x00, "Not broadcasting a Secure Network beacon" },
    { 0x01, "Broadcasting a Secure Network beacon" },
    { 0, NULL }
};

static const value_string btmesh_gatt_proxy_vals[] = {
    { 0x00, "Proxy feature is supported and disabled" },
    { 0x01, "Proxy feature is supported and enabled" },
    { 0x02, "Proxy feature is not supported" },
    { 0, NULL }
};

static const value_string btmesh_relay_vals[] = {
    { 0x00, "Relay feature is supported and disabled" },
    { 0x01, "Relay feature is supported and enabled" },
    { 0x02, "Relay feature is not supported" },
    { 0, NULL }
};

static const value_string btmesh_friend_vals[] = {
    { 0x00, "Friend feature is supported and disabled" },
    { 0x01, "Friend feature is supported and enabled" },
    { 0x02, "Friend feature is not supported" },
    { 0, NULL }
};

static const value_string btmesh_publishperiod_resolution_vals[] = {
    { 0x00, "100 milliseconds" },
    { 0x01, "1 second" },
    { 0x02, "10 seconds" },
    { 0x03, "10 minutes" },
    { 0, NULL }
};

static const value_string btmesh_friendship_credentials_flag_vals[] = {
    { 0x00, "Master security material is used" },
    { 0x01, "Friendship security material is used" },
    { 0, NULL }
};

static const value_string btmesh_phase_vals[] = {
    { 0x00, "Normal operation" },
    { 0x01, "First phase of Key Refresh procedure" },
    { 0x02, "Second phase of Key Refresh procedure" },
    { 0, NULL }
};

static const range_string btmesh_transition_vals[] = {
    { 0x00, 0x01, "Prohibited" },
    { 0x02, 0x02, "Transition 2" },
    { 0x03, 0x03, "Transition 3" },
    { 0x04, 0xFF, "Prohibited" },
    { 0, 0, NULL }
};

static const value_string btmesh_fault_array_vals[] = {
    { 0x00, "No Fault" },
    { 0x01, "Battery Low Warning" },
    { 0x02, "Battery Low Error" },
    { 0x03, "Supply Voltage Too Low Warning" },
    { 0x04, "Supply Voltage Too Low Error" },
    { 0x05, "Supply Voltage Too High Warning" },
    { 0x06, "Supply Voltage Too High Error" },
    { 0x07, "Power Supply Interrupted Warning" },
    { 0x08, "Power Supply Interrupted Error" },
    { 0x09, "No Load Warning" },
    { 0x0A, "No Load Error" },
    { 0x0B, "Overload Warning" },
    { 0x0C, "Overload Error" },
    { 0x0D, "Overheat Warning" },
    { 0x0E, "Overheat Error" },
    { 0x0F, "Condensation Warning" },
    { 0x10, "Condensation Error" },
    { 0x11, "Vibration Warning" },
    { 0x12, "Vibration Error" },
    { 0x13, "Configuration Warning" },
    { 0x14, "Configuration Error" },
    { 0x15, "Element Not Calibrated Warning" },
    { 0x16, "Element Not Calibrated Error" },
    { 0x17, "Memory Warning" },
    { 0x18, "Memory Error" },
    { 0x19, "Self-Test Warning" },
    { 0x1A, "Self-Test Error" },
    { 0x1B, "Input Too Low Warning" },
    { 0x1C, "Input Too Low Error" },
    { 0x1D, "Input Too High Warning" },
    { 0x1E, "Input Too High Error" },
    { 0x1F, "Input No Change Warning" },
    { 0x20, "Input No Change Error" },
    { 0x21, "Actuator Blocked Warning" },
    { 0x22, "Actuator Blocked Error" },
    { 0x23, "Housing Opened Warning" },
    { 0x24, "Housing Opened Error" },
    { 0x25, "Tamper Warning" },
    { 0x26, "Tamper Error" },
    { 0x27, "Device Moved Warning" },
    { 0x28, "Device Moved Error" },
    { 0x29, "Device Dropped Warning" },
    { 0x2A, "Device Dropped Error" },
    { 0x2B, "Overflow Warning" },
    { 0x2C, "Overflow Error" },
    { 0x2D, "Empty Warning" },
    { 0x2E, "Empty Error" },
    { 0x2F, "Internal Bus Warning" },
    { 0x30, "Internal Bus Error" },
    { 0x31, "Mechanism Jammed Warning" },
    { 0x32, "Mechanism Jammed Error" },
    { 0, NULL }
};

#if GCRYPT_VERSION_NUMBER >= 0x010600 /* 1.6.0 */

static const int *config_composition_data_status_features_headers[] = {
    &hf_btmesh_config_composition_data_status_features_relay,
    &hf_btmesh_config_composition_data_status_features_proxy,
    &hf_btmesh_config_composition_data_status_features_friend,
    &hf_btmesh_config_composition_data_status_features_low_power,
    &hf_btmesh_config_composition_data_status_features_rfu,
    NULL
};

static const int *config_heartbeat_publication_set_features_headers[] = {
    &hf_btmesh_config_heartbeat_publication_set_features_relay,
    &hf_btmesh_config_heartbeat_publication_set_features_proxy,
    &hf_btmesh_config_heartbeat_publication_set_features_friend,
    &hf_btmesh_config_heartbeat_publication_set_features_low_power,
    &hf_btmesh_config_heartbeat_publication_set_features_rfu,
    NULL
};

static const int *config_heartbeat_publication_status_features_headers[] = {
    &hf_btmesh_config_heartbeat_publication_status_features_relay,
    &hf_btmesh_config_heartbeat_publication_status_features_proxy,
    &hf_btmesh_config_heartbeat_publication_status_features_friend,
    &hf_btmesh_config_heartbeat_publication_status_features_low_power,
    &hf_btmesh_config_heartbeat_publication_status_features_rfu,
    NULL
};

#endif

static const value_string btmesh_status_code_vals[] = {
    { 0x00, "Success" },
    { 0x01, "Invalid Address" },
    { 0x02, "Invalid Model" },
    { 0x03, "Invalid AppKey Index" },
    { 0x04, "Invalid NetKey Index" },
    { 0x05, "Insufficient Resources" },
    { 0x06, "Key Index Already Stored" },
    { 0x07, "Invalid Publish Parameters" },
    { 0x08, "Not a Subscribe Model" },
    { 0x09, "Storage Failure" },
    { 0x0A, "Feature Not Supported" },
    { 0x0B, "Cannot Update" },
    { 0x0C, "Cannot Remove" },
    { 0x0D, "Cannot Bind" },
    { 0x0E, "Temporarily Unable to Change State" },
    { 0x0F, "Cannot Set" },
    { 0x10, "Unspecified Error" },
    { 0x11, "Invalid Binding" },
    { 0, NULL }
};

static const value_string btmesh_model_vals[] = {
    { 0x0000, "Configuration Server" },
    { 0x0001, "Configuration Client" },
    { 0x0002, "Health Server" },
    { 0x0003, "Health Client" },
    { 0x1000, "Generic OnOff Server" },
    { 0x1001, "Generic OnOff Client" },
    { 0x1002, "Generic Level Server" },
    { 0x1003, "Generic Level Client" },
    { 0x1004, "Generic Default Transition Time Server" },
    { 0x1005, "Generic Default Transition Time Client" },
    { 0x1006, "Generic Power OnOff Server" },
    { 0x1007, "Generic Power OnOff Setup Server" },
    { 0x1008, "Generic Power OnOff Client" },
    { 0x1009, "Generic Power Level Server" },
    { 0x100A, "Generic Power Level Setup Server" },
    { 0x100B, "Generic Power Level Client" },
    { 0x100C, "Generic Battery Server" },
    { 0x100D, "Generic Battery Client" },
    { 0x100E, "Generic Location Server" },
    { 0x100F, "Generic Location Setup Server" },
    { 0x1010, "Generic Location Client" },
    { 0x1011, "Generic Admin Property Server" },
    { 0x1012, "Generic Manufacturer Property Server" },
    { 0x1013, "Generic User Property Server" },
    { 0x1014, "Generic Client Property Server" },
    { 0x1015, "Generic Property Clien" },
    { 0x1100, "Sensors Sensor Server" },
    { 0x1101, "Sensor Setup Server" },
    { 0x1102, "Sensor Client" },
    { 0x1200, "Time Server" },
    { 0x1201, "Time Setup Server" },
    { 0x1202, "Time Client" },
    { 0x1203, "Scene Server" },
    { 0x1204, "Scene Setup Server" },
    { 0x1205, "Scene Client" },
    { 0x1206, "Scheduler Server" },
    { 0x1207, "Scheduler Setup Server" },
    { 0x1208, "Scheduler Client" },
    { 0x1300, "Light Lightness Server" },
    { 0x1301, "Light Lightness Setup Server" },
    { 0x1302, "Light Lightness Client" },
    { 0x1303, "Light CTL Server" },
    { 0x1304, "Light CTL Setup Server" },
    { 0x1305, "Light CTL Client" },
    { 0x1306, "Light CTL Temperature Server" },
    { 0x1307, "Light HSL Server" },
    { 0x1308, "Light HSL Setup Server" },
    { 0x1309, "Light HSL Client" },
    { 0x130A, "Light HSL Hue Server" },
    { 0x130B, "Light HSL Saturation Server" },
    { 0x130C, "Light xyL Server" },
    { 0x130D, "Light xyL Setup Server" },
    { 0x130E, "Light xyL Client" },
    { 0x130F, "Light LC Server" },
    { 0x1310, "Light LC Setup Server" },
    { 0x1311, "Light LC Client" },
    { 0, NULL }
};


/* Upper Transport Message reassembly */

static reassembly_table upper_transport_reassembly_table;

static const fragment_items btmesh_segmented_access_frag_items = {
    &ett_btmesh_segmented_access_fragments,
    &ett_btmesh_segmented_access_fragment,

    &hf_btmesh_segmented_access_fragments,
    &hf_btmesh_segmented_access_fragment,
    &hf_btmesh_segmented_access_fragment_overlap,
    &hf_btmesh_segmented_access_fragment_overlap_conflict,
    &hf_btmesh_segmented_access_fragment_multiple_tails,
    &hf_btmesh_segmented_access_fragment_too_long_fragment,
    &hf_btmesh_segmented_access_fragment_error,
    &hf_btmesh_segmented_access_fragment_count,
    NULL,
    &hf_btmesh_segmented_access_reassembled_length,
    /* Reassembled data field */
    NULL,
    "fragments"
};

static const fragment_items btmesh_segmented_control_frag_items = {
    &ett_btmesh_segmented_control_fragments,
    &ett_btmesh_segmented_control_fragment,

    &hf_btmesh_segmented_control_fragments,
    &hf_btmesh_segmented_control_fragment,
    &hf_btmesh_segmented_control_fragment_overlap,
    &hf_btmesh_segmented_control_fragment_overlap_conflict,
    &hf_btmesh_segmented_control_fragment_multiple_tails,
    &hf_btmesh_segmented_control_fragment_too_long_fragment,
    &hf_btmesh_segmented_control_fragment_error,
    &hf_btmesh_segmented_control_fragment_count,
    NULL,
    &hf_btmesh_segmented_control_reassembled_length,
    /* Reassembled data field */
    NULL,
    "fragments"
};

typedef struct _upper_transport_fragment_key {
    guint16 src;
    guint16 seq0;
} upper_transport_fragment_key;

static guint
upper_transport_fragment_hash(gconstpointer k)
{
    const upper_transport_fragment_key* key = (const upper_transport_fragment_key*) k;
    guint hash_val;

    hash_val = key->src;
    hash_val += ( ((guint)key->seq0) << 16);
    return hash_val;
}

static gint
upper_transport_fragment_equal(gconstpointer k1, gconstpointer k2)
{
    const upper_transport_fragment_key* key1 = (const upper_transport_fragment_key*) k1;
    const upper_transport_fragment_key* key2 = (const upper_transport_fragment_key*) k2;

    return ((key1->src == key2->src) && (key1->seq0 == key2->seq0)
            ? TRUE : FALSE);
}

static void *
upper_transport_fragment_temporary_key(const packet_info *pinfo _U_, const guint32 id _U_,
                              const void *data)
{
    upper_transport_fragment_key *key = g_slice_new(upper_transport_fragment_key);
    const upper_transport_fragment_key *pkt = (const upper_transport_fragment_key *)data;

    key->src = pkt->src;
    key->seq0 = pkt->seq0;

    return key;
}

static void
upper_transport_fragment_free_temporary_key(gpointer ptr)
{
    upper_transport_fragment_key *key = (upper_transport_fragment_key *)ptr;

    g_slice_free(upper_transport_fragment_key, key);
}

static void *
upper_transport_fragment_persistent_key(const packet_info *pinfo _U_, const guint32 id _U_,
                              const void *data)
{
    upper_transport_fragment_key *key = g_slice_new(upper_transport_fragment_key);
    const upper_transport_fragment_key *pkt = (const upper_transport_fragment_key *)data;

    key->src = pkt->src;
    key->seq0 = pkt->seq0;

    return key;
}

static void
upper_transport_fragment_free_persistent_key(gpointer ptr)
{
    upper_transport_fragment_key *key = (upper_transport_fragment_key *)ptr;
    if (key) {
        g_slice_free(upper_transport_fragment_key, key);
    }
}

static const reassembly_table_functions upper_transport_reassembly_table_functions = {
    upper_transport_fragment_hash,
    upper_transport_fragment_equal,
    upper_transport_fragment_temporary_key,
    upper_transport_fragment_persistent_key,
    upper_transport_fragment_free_temporary_key,
    upper_transport_fragment_free_persistent_key
};

static void
upper_transport_init_routine(void)
{
    reassembly_table_register(&upper_transport_reassembly_table, &upper_transport_reassembly_table_functions);
}

/* A BT Mesh dissector is not realy useful without decryption as all packets are encrypted. Just leave a stub dissector outside of */
#if GCRYPT_VERSION_NUMBER >= 0x010600 /* 1.6.0 */

/* BT Mesh s1 function */
static gboolean
s1(guint8 *m, size_t mlen, guint8 *salt)
{

    gcry_mac_hd_t mac_hd;
    gcry_error_t gcrypt_err;
    size_t read_digest_length = 16;
    guint8  zero[16] = { 0 };

    /* Open gcrypt handle */
    gcrypt_err = gcry_mac_open(&mac_hd, GCRY_MAC_CMAC_AES, 0, NULL);
    if (gcrypt_err != 0) {
        return FALSE;
    }

    /* Set the key */
    gcrypt_err = gcry_mac_setkey(mac_hd, &zero, 16);
    if (gcrypt_err != 0) {
        gcry_mac_close(mac_hd);
        return FALSE;
    }

    gcrypt_err = gcry_mac_write(mac_hd, m, mlen);
    if (gcrypt_err != 0) {
        gcry_mac_close(mac_hd);
        return FALSE;
    }

    /* Read out the digest */
    gcrypt_err = gcry_mac_read(mac_hd, salt, &read_digest_length);
    if (gcrypt_err != 0) {
        gcry_mac_close(mac_hd);
        return FALSE;
    }

    /* Now close the mac handle */
    gcry_mac_close(mac_hd);
    return TRUE;
}

/* BT Mesh Labebl UUID hash function
 *
 * SALT = s1 ("vtad")
 * hash = AES-CMAC(SALT, Label UUID) mod 2(pow)14
 *
 */
static gboolean
label_uuid_hash(uat_btmesh_label_uuid_record_t *label_uuid_record)
{
    gcry_mac_hd_t mac_hd;
    gcry_error_t gcrypt_err;
    guint8 vtad[4] = { 'v', 't', 'a', 'd' };
    size_t mlen = 4;
    guint8 salt[16];
    guint8 hash[16];
    size_t read_digest_length = 16;

    if (label_uuid_record->label_uuid_length != 16) {
        return FALSE;
    }

    /* SALT = s1("vtad") */
    if (s1(vtad, mlen, salt) == FALSE) {
        return FALSE;
    }

    /* hash = AES-CMAC(SALT, Label UUID) */
    /* Open gcrypt handle */
    gcrypt_err = gcry_mac_open(&mac_hd, GCRY_MAC_CMAC_AES, 0, NULL);
    if (gcrypt_err != 0) {
        return FALSE;
    }

    /* Set the key */
    gcrypt_err = gcry_mac_setkey(mac_hd, &salt, 16);
    if (gcrypt_err != 0) {
        gcry_mac_close(mac_hd);
        return FALSE;
    }

    gcrypt_err = gcry_mac_write(mac_hd, label_uuid_record->label_uuid, 16);
    if (gcrypt_err != 0) {
        gcry_mac_close(mac_hd);
        return FALSE;
    }

    /* Read out the digest */
    gcrypt_err = gcry_mac_read(mac_hd, hash, &read_digest_length);
    if (gcrypt_err != 0) {
        gcry_mac_close(mac_hd);
        return FALSE;
    }

    label_uuid_record->hash = hash[15] + ((guint16)(hash[14] & 0x3f) << 8) + 0x8000;

    /* Now close the mac handle */
    gcry_mac_close(mac_hd);
    return TRUE;
}

/* BT Mesh K2 function
 * Allow plen up to 9 char
 *
 * The key (T) is computed as follows:
 * T = AES-CMACSALT (N)
 * SALT is the 128-bit value computed as follows
 * SALT = s1("smk2")
 * The output of the key generation function k2 is as follows:
 * T0 = empty string (zero length)
 * T1 = AES-CMACT (T0 || P || 0x01)
 * T2 = AES-CMACT (T1 || P || 0x02)
 * T3 = AES-CMACT (T2 || P || 0x03)
 * k2(N, P) = (T1 || T2 || T3) mod 2(pow)263
 */
static gboolean
k2(uat_btmesh_record_t * net_key_set, guint8 *p, size_t plen)
{
    gcry_mac_hd_t mac_hd;
    gcry_error_t gcrypt_err;
    guint8 smk2[4] = { 's', 'm', 'k', '2' };
    size_t mlen = 4;
    guint8 salt[16];
    guint8 t[16];
    guint8 t1[16];
    guint8 p_t1[9 + 1];
    guint8 p_t2[16 + 9 + 1];
    guint8 p_t3[16 + 9 + 1];

    size_t read_digest_length = 16;

    if (plen > 8) {
        return FALSE;
    }

    if (net_key_set->network_key_length != 16) {
        return FALSE;
    }

    /* SALT = s1("smk2") */
    if (s1(smk2, mlen, salt) == FALSE) {
        return FALSE;
    }

    /* T = AES-CMAC_SALT(N) */
    /* Open gcrypt handle */
    gcrypt_err = gcry_mac_open(&mac_hd, GCRY_MAC_CMAC_AES, 0, NULL);
    if (gcrypt_err != 0) {
        return FALSE;
    }

    /* Set the key */
    gcrypt_err = gcry_mac_setkey(mac_hd, &salt, 16);
    if (gcrypt_err != 0) {
        gcry_mac_close(mac_hd);
        return FALSE;
    }

    gcrypt_err = gcry_mac_write(mac_hd, net_key_set->network_key, 16);
    if (gcrypt_err != 0) {
        gcry_mac_close(mac_hd);
        return FALSE;
    }

    /* Read out the digest */
    gcrypt_err = gcry_mac_read(mac_hd, t, &read_digest_length);
    if (gcrypt_err != 0) {
        gcry_mac_close(mac_hd);
        return FALSE;
    }

    /* Now close the mac handle */
    gcry_mac_close(mac_hd);

    /*
     * T0 = empty string (zero length)
     * T1 = AES-CMAC_T(T0 || P || 0x01)
     */
    memcpy(p_t1, p, plen);
    p_t1[plen] = 0x01;

    /* Open gcrypt handle */
    gcrypt_err = gcry_mac_open(&mac_hd, GCRY_MAC_CMAC_AES, 0, NULL);
    if (gcrypt_err != 0) {
        return FALSE;
    }

    /* Set the key */
    gcrypt_err = gcry_mac_setkey(mac_hd, &t, 16);
    if (gcrypt_err != 0) {
        gcry_mac_close(mac_hd);
        return FALSE;
    }

    gcrypt_err = gcry_mac_write(mac_hd, &p_t1, plen + 1);
    if (gcrypt_err != 0) {
        gcry_mac_close(mac_hd);
        return FALSE;
    }

    /* Read out the digest */
    gcrypt_err = gcry_mac_read(mac_hd, t1, &read_digest_length);
    if (gcrypt_err != 0) {
        gcry_mac_close(mac_hd);
        return FALSE;
    }
    net_key_set->nid = (t1[15] & 0x7f);
    /*
     * T2 = AES-CMAC_T(T1 || P || 0x02)
     * (EncryptionKey)
     */

    /* Now close the mac handle */
    gcry_mac_close(mac_hd);

    memcpy(p_t2, t1, 16);
    memcpy(&p_t2[16], p, plen);
    p_t2[16 + plen] = 0x02;

    /* Open gcrypt handle */
    gcrypt_err = gcry_mac_open(&mac_hd, GCRY_MAC_CMAC_AES, 0, NULL);
    if (gcrypt_err != 0) {
        return FALSE;
    }

    /* Set the key */
    gcrypt_err = gcry_mac_setkey(mac_hd, &t, 16);
    if (gcrypt_err != 0) {
        gcry_mac_close(mac_hd);
        return FALSE;
    }

    gcrypt_err = gcry_mac_write(mac_hd, &p_t2, 16 + plen + 1);
    if (gcrypt_err != 0) {
        gcry_mac_close(mac_hd);
        return FALSE;
    }

    /* Read out the digest */
    gcrypt_err = gcry_mac_read(mac_hd, net_key_set->encryptionkey, &read_digest_length);
    if (gcrypt_err != 0) {
        gcry_mac_close(mac_hd);
        return FALSE;
    }

    /* Now close the mac handle */
    gcry_mac_close(mac_hd);

    /* T3 = AES-CMAC_T(T2 || P || 0x03) */
    /* PrivacyKey */
    memcpy(p_t3, net_key_set->encryptionkey, 16);
    memcpy(&p_t3[16], p, plen);
    p_t3[16 + plen] = 0x03;

    /* Open gcrypt handle */
    gcrypt_err = gcry_mac_open(&mac_hd, GCRY_MAC_CMAC_AES, 0, NULL);
    if (gcrypt_err != 0) {
        return FALSE;
    }

    /* Set the key */
    gcrypt_err = gcry_mac_setkey(mac_hd, t, 16);
    if (gcrypt_err != 0) {
        gcry_mac_close(mac_hd);
        return FALSE;
    }

    gcrypt_err = gcry_mac_write(mac_hd, p_t3, 16 + plen + 1);
    if (gcrypt_err != 0) {
        gcry_mac_close(mac_hd);
        return FALSE;
    }

    /* Read out the digest */
    gcrypt_err = gcry_mac_read(mac_hd, net_key_set->privacykey, &read_digest_length);
    if (gcrypt_err != 0) {
        gcry_mac_close(mac_hd);
        return FALSE;
    }

    /* Now close the mac handle */
    gcry_mac_close(mac_hd);
    return TRUE;
}

/* BT Mesh K4 function

   The inputs to function k4 is:
   N is 128 bits

   The key (T) is computed as follows:
   T = AES-CMAC (SALT, N)

   SALT is the 128-bit value computed as follows:
   SALT = s1("smk4")

   The output of the derivation function k4 is as follows:
   K4(N) = AES-CMAC (T, "id6" || 0x01 ) mod 2(pow)6
*/

static gboolean
k4(uat_btmesh_record_t *key_set)
{
    gcry_mac_hd_t mac_hd;
    gcry_error_t gcrypt_err;

    guint8 smk4[4] = { 's', 'm', 'k', '4' };
    size_t mlen = 4;
    guint8 id6[4] = { 'i', 'd', '6', 0x01 };
    size_t id6len = 4;
    guint8 salt[16];
    guint8 t[16];
    guint8 t1[16];

    size_t read_digest_length = 16;

    if (key_set->application_key_length != 16) {
        return FALSE;
    }

    /* SALT = s1("smk4") */
    if (s1(smk4, mlen, salt) == FALSE) {
        return FALSE;
    }

    gcrypt_err = gcry_mac_open(&mac_hd, GCRY_MAC_CMAC_AES, 0, NULL);
    if (gcrypt_err != 0) {
        return FALSE;
    }

    /* Set the key */
    gcrypt_err = gcry_mac_setkey(mac_hd, &salt, 16);
    if (gcrypt_err != 0) {
        gcry_mac_close(mac_hd);
        return FALSE;
    }

    gcrypt_err = gcry_mac_write(mac_hd, key_set->application_key, 16);
    if (gcrypt_err != 0) {
        gcry_mac_close(mac_hd);
        return FALSE;
    }

    /* Read out the digest */
    gcrypt_err = gcry_mac_read(mac_hd, t, &read_digest_length);
    if (gcrypt_err != 0) {
        gcry_mac_close(mac_hd);
        return FALSE;
    }

    /* Now close the mac handle */
    gcry_mac_close(mac_hd);

    /* Open gcrypt handle */
    gcrypt_err = gcry_mac_open(&mac_hd, GCRY_MAC_CMAC_AES, 0, NULL);
    if (gcrypt_err != 0) {
        return FALSE;
    }

    /* Set the key */
    gcrypt_err = gcry_mac_setkey(mac_hd, &t, 16);
    if (gcrypt_err != 0) {
        gcry_mac_close(mac_hd);
        return FALSE;
    }

    gcrypt_err = gcry_mac_write(mac_hd, &id6, id6len);
    if (gcrypt_err != 0) {
        gcry_mac_close(mac_hd);
        return FALSE;
    }

    /* Read out the digest */
    gcrypt_err = gcry_mac_read(mac_hd, t1, &read_digest_length);
    if (gcrypt_err != 0) {
        gcry_mac_close(mac_hd);
        return FALSE;
    }

    key_set->aid = (t1[15] & 0x3f);

    /* Now close the mac handle */
    gcry_mac_close(mac_hd);
    return TRUE;
}

static gboolean
create_master_security_keys(uat_btmesh_record_t * net_key_set)
{
    guint8 p[1] = { 0 };
    size_t plen = 1;

    return k2(net_key_set, p, plen);
}

static tvbuff_t *
btmesh_deobfuscate(tvbuff_t *tvb, packet_info *pinfo, int offset _U_, uat_btmesh_record_t *net_key_set)
{
    tvbuff_t *de_obf_tvb = NULL;

    /* Decode ObfuscatedData
     * Privacy Random = (EncDST || EncTransportPDU || NetMIC)[0-6]
     * PECB = e ((PrivacyKey, 0x0000000000 || IV Index || Privacy Random)
     * (CTL || TTL || SEQ || SRC) = ObfuscatedData
     */
    guint8 in[16]; /*  0x0000000000 || IV Index || Privacy Random */
    gcry_cipher_hd_t cipher_hd;
    guint8 pecb[16];
    guint8 *plaintextnetworkheader = (guint8 *)wmem_alloc(pinfo->pool, 6);
    int i;

    /* at least 1 + 6 + 2 + 1 + 4 + 4 = 18 octets must be present in tvb to decrypt */
    if (!tvb_bytes_exist(tvb, 0, 18)) {
        return NULL;
    }

    memset(in, 0x00, 5);
    memcpy((guint8 *)&in + 5, net_key_set->ivindex, 4);

    /* Privacy random */
    tvb_memcpy(tvb, (guint8 *)&in + 9, 7, 7);

    if (gcry_cipher_open(&cipher_hd, GCRY_CIPHER_AES128, GCRY_CIPHER_MODE_ECB, 0)) {
        return NULL;
    }

    if (gcry_cipher_setkey(cipher_hd, net_key_set->privacykey, 16)) {
        gcry_cipher_close(cipher_hd);
        return NULL;
    }

    /* Decrypt */
    if (gcry_cipher_encrypt(cipher_hd, &pecb, 16, &in, 16)) {
        gcry_cipher_close(cipher_hd);
        return NULL;
    }

    /* Now close the cipher handle */
    gcry_cipher_close(cipher_hd);

    for ( i = 0; i < 6; i++) {
        plaintextnetworkheader[i] = tvb_get_guint8(tvb, i + 1) ^ pecb[i];
    }

    de_obf_tvb = tvb_new_child_real_data(tvb, plaintextnetworkheader, 6, 6);
    return de_obf_tvb;
}

static const gchar *period_interval_unit[] = {"ms", "s", "s", "min"};
static const guint32 period_interval_multiplier[] = {100, 1, 10, 10};

static void
format_publish_period(gchar *buf, guint32 value) {
    guint32 idx = (value & 0xC0 ) >> 5;
    guint32 val = (value & 0x3F ) * period_interval_multiplier[idx];
    g_snprintf(buf, ITEM_LABEL_LENGTH, "%u %s", val, period_interval_unit[idx]);
}

static void
format_transmit(gchar *buf, guint32 value) {
    guint32 prd = (((value & 0xF8 ) >> 3 ) + 1 ) * 10;
    guint32 ctr = (value & 0x07 );
    switch (ctr) {
    case 0:
        g_snprintf(buf, ITEM_LABEL_LENGTH, "One transmissions");
        break;

    default:
        g_snprintf(buf, ITEM_LABEL_LENGTH, "%u transmissions at interval of %u ms", ctr, prd);
    }
}

static void
format_retransmit(gchar *buf, guint32 value) {
    guint32 prd = (((value & 0xF8 ) >> 3 ) + 1 ) * 10;
    guint32 ctr = (value & 0x07 );
    switch (ctr) {
    case 0:
        g_snprintf(buf, ITEM_LABEL_LENGTH, "No retransmissions");
        break;

    case 1:
        g_snprintf(buf, ITEM_LABEL_LENGTH, "One retransmission after %u ms", prd);
        break;

    default:
        g_snprintf(buf, ITEM_LABEL_LENGTH, "%u retransmissions at interval of %u ms", ctr, prd);
    }
}

static void
format_interval_steps(gchar *buf, guint32 value) {
    g_snprintf(buf, ITEM_LABEL_LENGTH, "%u ms (%u)", (value + 1) * 10, value);
}

static void
format_key_index(gchar *buf, guint32 value) {
    g_snprintf(buf, ITEM_LABEL_LENGTH, "%u (0x%03x)", value & 0xFFF, value & 0xFFF);
}

static void
format_key_index_rfu(gchar *buf, guint32 value) {
    g_snprintf(buf, ITEM_LABEL_LENGTH, "0x%1x", (value & 0xF000) >> 12);
}

static void
format_dual_key_index(gchar *buf, guint32 value) {
    g_snprintf(buf, ITEM_LABEL_LENGTH, "%u (0x%03x), %u (0x%03x)", value & 0xFFF, value & 0xFFF, ( value & 0xFFF000 ) >> 12, ( value & 0xFFF000 ) >> 12);
}

static void
format_vendor_model(gchar *buf, guint32 value) {
    g_snprintf(buf, ITEM_LABEL_LENGTH, "0x%04x of %s", value >> 16, val_to_str_ext_const(value & 0xFFFF, &bluetooth_company_id_vals_ext, "Unknown"));
}

static void
format_publish_appkeyindex_model(gchar *buf, guint32 value) {
    g_snprintf(buf, ITEM_LABEL_LENGTH, "%u (0x%03x) using %s security material", value & 0x0FFF, value & 0x0FFF, (value & 0x1000 ? "Friendship" : "Master"));
}

static void
dissect_btmesh_model_layer(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
{
    proto_tree *sub_tree;
    tvbuff_t *payload_tvb;
    guint32 opcode;
    guint16 vendor;
    proto_item *netapp_index_item, *app_index_item, *pub_app_index_item, *net_index_item;
    proto_item *relayretransmit_index, *transmit_index;
    proto_item *publishperiod_item, *publishretransmit_item;

    proto_tree *netapp_index_sub_tree, *app_index_sub_tree, *pub_app_index_sub_tree, *net_index_sub_tree;
    proto_tree *relayretransmit_sub_tree, *transmit_sub_tree, *subscriptionlist_tree;
    proto_tree *publishperiod_sub_tree, *publishretransmit_sub_tree;
    proto_tree *element_sub_tree, *model_sub_tree, *vendor_sub_tree;
    proto_tree *netkeylist_tree, *appkeylist_tree;
    proto_tree *fault_array_tree;

    guint32 netkeyindexes, appkeyindexes;
    guint32 nums, numv, element;
    guint i;

    sub_tree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_btmesh_model_layer, NULL, "Model Layer");

    opcode = tvb_get_guint8(tvb, offset);
    if (opcode & 0x80) {
        if (opcode & 0x40) {
            /* Vendor opcode */
            proto_tree_add_item(sub_tree, hf_btmesh_model_layer_vendor_opcode, tvb, offset, 1, ENC_NA);
            vendor = tvb_get_guint16(tvb, offset+1, ENC_BIG_ENDIAN);
            proto_tree_add_item(sub_tree, hf_btmesh_model_layer_vendor, tvb, offset+1, 2, ENC_NA);
            payload_tvb = tvb_new_subset_remaining(tvb, offset);
            dissector_try_uint_new(btmesh_model_vendor_dissector_table, vendor, payload_tvb, pinfo, tree, TRUE, GUINT_TO_POINTER(vendor));
            offset+=3;
        } else {
        /* Two octet opcode */
        proto_tree_add_item_ret_uint(sub_tree, hf_btmesh_model_layer_opcode, tvb, offset, 2, ENC_NA, &opcode);
        col_set_str(pinfo->cinfo, COL_INFO, val_to_str(opcode, btmesh_models_opcode_vals, "Unknown"));
        offset+=2;
        }
    } else {
        /* One octet opcode */
        proto_tree_add_item(sub_tree, hf_btmesh_model_layer_opcode, tvb, offset, 1, ENC_NA);
        col_set_str(pinfo->cinfo, COL_INFO, val_to_str(opcode, btmesh_models_opcode_vals, "Unknown"));
        offset++;
    }

    switch (opcode) {
    case CONFIG_APPKEY_ADD:
        netapp_index_item = proto_tree_add_item(sub_tree, hf_btmesh_config_appkey_add_netkeyindexandappkeyindex, tvb, offset, 3, ENC_LITTLE_ENDIAN);
        netapp_index_sub_tree = proto_item_add_subtree(netapp_index_item, ett_btmesh_config_model_netapp_index);
        proto_tree_add_item(netapp_index_sub_tree, hf_btmesh_config_appkey_add_netkeyindexandappkeyindex_net, tvb, offset, 3, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(netapp_index_sub_tree, hf_btmesh_config_appkey_add_netkeyindexandappkeyindex_app, tvb, offset, 3, ENC_LITTLE_ENDIAN);
        offset+=3;
        proto_tree_add_item(sub_tree, hf_btmesh_config_appkey_add_appkey, tvb, offset, 16, ENC_NA);
        offset+=16;
        break;
    case CONFIG_APPKEY_UPDATE:
        netapp_index_item = proto_tree_add_item(sub_tree, hf_btmesh_config_appkey_update_netkeyindexandappkeyindex, tvb, offset, 3, ENC_LITTLE_ENDIAN);
        netapp_index_sub_tree = proto_item_add_subtree(netapp_index_item, ett_btmesh_config_model_netapp_index);
        proto_tree_add_item(netapp_index_sub_tree, hf_btmesh_config_appkey_update_netkeyindexandappkeyindex_net, tvb, offset, 3, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(netapp_index_sub_tree, hf_btmesh_config_appkey_update_netkeyindexandappkeyindex_app, tvb, offset, 3, ENC_LITTLE_ENDIAN);
        offset+=3;
        proto_tree_add_item(sub_tree, hf_btmesh_config_appkey_update_appkey, tvb, offset, 16, ENC_NA);
        offset+=16;
        break;
    case CONFIG_COMPOSITION_DATA_STATUS:
        proto_tree_add_item(sub_tree, hf_btmesh_config_composition_data_status_page, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        proto_tree_add_item(sub_tree, hf_btmesh_config_composition_data_status_cid, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        proto_tree_add_item(sub_tree, hf_btmesh_config_composition_data_status_pid, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        proto_tree_add_item(sub_tree, hf_btmesh_config_composition_data_status_vid, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        proto_tree_add_item(sub_tree, hf_btmesh_config_composition_data_status_crpl, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        proto_tree_add_bitmask_with_flags(sub_tree, tvb, offset,
            hf_btmesh_config_composition_data_status_features,
            ett_btmesh_config_composition_data_status_features,
            config_composition_data_status_features_headers,
            ENC_LITTLE_ENDIAN, BMT_NO_APPEND);
        offset+=2;
        /* Elements */
        element = 1;
        while (tvb_reported_length_remaining(tvb, offset) > 2) {
            nums = tvb_get_guint8(tvb, offset + 2 );
            numv = tvb_get_guint8(tvb, offset + 2 + 1);
            element_sub_tree = proto_tree_add_subtree_format(sub_tree, tvb, offset, 4 + nums * 2 + numv * 4, ett_btmesh_config_model_element, NULL, "Element #%u", element);
            proto_tree_add_item(element_sub_tree, hf_btmesh_config_composition_data_status_loc, tvb, offset, 2, ENC_LITTLE_ENDIAN);
            offset+=2;
            proto_tree_add_item(element_sub_tree, hf_btmesh_config_composition_data_status_nums, tvb, offset, 1, ENC_LITTLE_ENDIAN);
            offset++;
            proto_tree_add_item(element_sub_tree, hf_btmesh_config_composition_data_status_numv, tvb, offset, 1, ENC_LITTLE_ENDIAN);
            offset++;
            if (nums > 0 ) {
                model_sub_tree = proto_tree_add_subtree(element_sub_tree, tvb, offset, nums * 2, ett_btmesh_config_model_model, NULL, "SIG Models");
                for (i = 0; i < nums; i++) {
                    proto_tree_add_item(model_sub_tree, hf_btmesh_config_composition_data_status_sig_model, tvb, offset, 2, ENC_LITTLE_ENDIAN);
                    offset+=2;
                }
            }
            if (numv > 0 ) {
                vendor_sub_tree = proto_tree_add_subtree(element_sub_tree, tvb, offset, numv * 4, ett_btmesh_config_model_vendor, NULL, "Vendor Models");
                for (i = 0; i < numv; i++) {
                    proto_tree_add_item(vendor_sub_tree, hf_btmesh_config_composition_data_status_vendor_model, tvb, offset, 4, ENC_LITTLE_ENDIAN);
                    offset+=4;
                }
            }
            element++;
        }
        break;
    case CONFIG_MODEL_PUBLICATION_SET:
        proto_tree_add_item(sub_tree, hf_btmesh_config_model_publication_set_elementaddress, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        proto_tree_add_item(sub_tree, hf_btmesh_config_model_publication_set_publishaddress, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        pub_app_index_item = proto_tree_add_item(sub_tree, hf_btmesh_config_model_publication_set_appkey, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        pub_app_index_sub_tree= proto_item_add_subtree(pub_app_index_item, ett_btmesh_config_model_pub_app_index);
        proto_tree_add_item(pub_app_index_sub_tree, hf_btmesh_config_model_publication_set_appkeyindex, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(pub_app_index_sub_tree, hf_btmesh_config_model_publication_set_credentialflag, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(pub_app_index_sub_tree, hf_btmesh_config_model_publication_set_rfu, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        proto_tree_add_item(sub_tree, hf_btmesh_config_model_publication_set_publishttl, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        publishperiod_item = proto_tree_add_item(sub_tree, hf_btmesh_config_model_publication_set_publishperiod, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        publishperiod_sub_tree = proto_item_add_subtree(publishperiod_item, ett_btmesh_config_model_publishperiod);
        proto_tree_add_item(publishperiod_sub_tree, hf_btmesh_config_model_publication_set_publishperiod_steps, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(publishperiod_sub_tree, hf_btmesh_config_model_publication_set_publishperiod_resolution, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        publishretransmit_item = proto_tree_add_item(sub_tree, hf_btmesh_config_model_publication_set_publishretransmit, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        publishretransmit_sub_tree = proto_item_add_subtree(publishretransmit_item, ett_btmesh_config_model_publishretransmit);
        proto_tree_add_item(publishretransmit_sub_tree, hf_btmesh_config_model_publication_set_publishretransmit_count, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(publishretransmit_sub_tree, hf_btmesh_config_model_publication_set_publishretransmit_intervalsteps, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        if (tvb_reported_length_remaining(tvb, offset) > 2) {
            proto_tree_add_item(sub_tree, hf_btmesh_config_model_publication_set_vendormodelidentifier, tvb, offset, 4, ENC_LITTLE_ENDIAN);
            offset+=4;
        } else {
            proto_tree_add_item(sub_tree, hf_btmesh_config_model_publication_set_modelidentifier, tvb, offset, 2, ENC_LITTLE_ENDIAN);
            offset+=2;
        }
        break;
    case HEALTH_CURRENT_STATUS:
        proto_tree_add_item(sub_tree, hf_btmesh_health_current_status_test_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        proto_tree_add_item(sub_tree, hf_btmesh_health_current_status_company_id, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        fault_array_tree = proto_tree_add_subtree(sub_tree, tvb, offset, tvb_reported_length_remaining(tvb, offset), ett_btmesh_config_model_fault_array, NULL, "FaultArray");
        while (tvb_reported_length_remaining(tvb, offset) > 0) {
            proto_tree_add_item(fault_array_tree, hf_btmesh_health_current_status_fault, tvb, offset, 1, ENC_LITTLE_ENDIAN);
            offset++;
        }
        break;
    case HEALTH_FAULT_STATUS:
        proto_tree_add_item(sub_tree, hf_btmesh_health_fault_status_test_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        proto_tree_add_item(sub_tree, hf_btmesh_health_fault_status_company_id, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        fault_array_tree = proto_tree_add_subtree(sub_tree, tvb, offset, tvb_reported_length_remaining(tvb, offset), ett_btmesh_config_model_fault_array, NULL, "FaultArray");
        while (tvb_reported_length_remaining(tvb, offset) > 0) {
            proto_tree_add_item(fault_array_tree, hf_btmesh_health_fault_status_fault, tvb, offset, 1, ENC_LITTLE_ENDIAN);
            offset++;
        }
        break;
    case CONFIG_HEARTBEAT_PUBLICATION_STATUS:
        proto_tree_add_item(sub_tree, hf_btmesh_config_heartbeat_publication_status_status, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        proto_tree_add_item(sub_tree, hf_btmesh_config_heartbeat_publication_status_destination, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        proto_tree_add_item(sub_tree, hf_btmesh_config_heartbeat_publication_status_countlog, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        proto_tree_add_item(sub_tree, hf_btmesh_config_heartbeat_publication_status_periodlog, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        proto_tree_add_item(sub_tree, hf_btmesh_config_heartbeat_publication_status_ttl, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        proto_tree_add_bitmask_with_flags(sub_tree, tvb, offset,
            hf_btmesh_config_heartbeat_publication_status_features,
            ett_btmesh_config_heartbeat_publication_status_features,
            config_heartbeat_publication_status_features_headers,
            ENC_LITTLE_ENDIAN, BMT_NO_APPEND);
        offset+=2;
        net_index_item = proto_tree_add_item(sub_tree, hf_btmesh_config_heartbeat_publication_status_netkeyindex, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        net_index_sub_tree = proto_item_add_subtree(net_index_item, ett_btmesh_config_model_net_index);
        proto_tree_add_item(net_index_sub_tree, hf_btmesh_config_heartbeat_publication_status_netkeyindex_idx, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(net_index_sub_tree, hf_btmesh_config_heartbeat_publication_status_netkeyindex_rfu, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        break;
    case CONFIG_APPKEY_DELETE:
        netapp_index_item = proto_tree_add_item(sub_tree, hf_btmesh_config_appkey_delete_netkeyindexandappkeyindex, tvb, offset, 3, ENC_LITTLE_ENDIAN);
        netapp_index_sub_tree = proto_item_add_subtree(netapp_index_item, ett_btmesh_config_model_netapp_index);
        proto_tree_add_item(netapp_index_sub_tree, hf_btmesh_config_appkey_delete_netkeyindexandappkeyindex_net, tvb, offset, 3, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(netapp_index_sub_tree, hf_btmesh_config_appkey_delete_netkeyindexandappkeyindex_app, tvb, offset, 3, ENC_LITTLE_ENDIAN);
        offset+=3;
        break;
    case CONFIG_APPKEY_GET:
        net_index_item = proto_tree_add_item(sub_tree, hf_btmesh_config_appkey_get_netkeyindex, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        net_index_sub_tree = proto_item_add_subtree(net_index_item, ett_btmesh_config_model_net_index);
        proto_tree_add_item(net_index_sub_tree, hf_btmesh_config_appkey_get_netkeyindex_idx, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(net_index_sub_tree, hf_btmesh_config_appkey_get_netkeyindex_rfu, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        break;
    case CONFIG_APPKEY_LIST:
        proto_tree_add_item(sub_tree, hf_btmesh_config_appkey_list_status, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        net_index_item = proto_tree_add_item(sub_tree, hf_btmesh_config_appkey_list_netkeyindex, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        net_index_sub_tree = proto_item_add_subtree(net_index_item, ett_btmesh_config_model_net_index);
        proto_tree_add_item(net_index_sub_tree, hf_btmesh_config_appkey_list_netkeyindex_idx, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(net_index_sub_tree, hf_btmesh_config_appkey_list_netkeyindex_rfu, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        appkeylist_tree = proto_tree_add_subtree(sub_tree, tvb, offset, tvb_reported_length_remaining(tvb, offset), ett_btmesh_config_model_appkey_list, NULL, "AppKeyIndexes");
        while (tvb_reported_length_remaining(tvb, offset) >= 2) {
            if (tvb_reported_length_remaining(tvb, offset) >= 3) {
                appkeyindexes = tvb_get_guint24(tvb, offset, ENC_LITTLE_ENDIAN);
                proto_tree_add_uint(appkeylist_tree, hf_btmesh_config_appkey_list_appkeyindex, tvb, offset, 2, appkeyindexes & 0x000FFF);
                proto_tree_add_uint(appkeylist_tree, hf_btmesh_config_appkey_list_appkeyindex, tvb, offset +1 , 2, (appkeyindexes >> 12 ) & 0x000FFF);
                offset+=3;
            } else {
                appkeyindexes = tvb_get_guint16(tvb, offset, ENC_LITTLE_ENDIAN);
                proto_tree_add_uint(appkeylist_tree, hf_btmesh_config_appkey_list_appkeyindex, tvb, offset, 2, appkeyindexes & 0x0FFF);
                proto_tree_add_uint(appkeylist_tree, hf_btmesh_config_appkey_list_appkeyindex_rfu, tvb, offset, 2, (appkeyindexes >> 12 ) & 0xF);
                offset+=2;
            }
        }
        break;
    case CONFIG_APPKEY_STATUS:
        proto_tree_add_item(sub_tree, hf_btmesh_config_appkey_status_status, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        netapp_index_item = proto_tree_add_item(sub_tree, hf_btmesh_config_appkey_status_netkeyindexandappkeyindex, tvb, offset, 3, ENC_LITTLE_ENDIAN);
        netapp_index_sub_tree = proto_item_add_subtree(netapp_index_item, ett_btmesh_config_model_netapp_index);
        proto_tree_add_item(netapp_index_sub_tree, hf_btmesh_config_appkey_status_netkeyindexandappkeyindex_net, tvb, offset, 3, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(netapp_index_sub_tree, hf_btmesh_config_appkey_status_netkeyindexandappkeyindex_app, tvb, offset, 3, ENC_LITTLE_ENDIAN);
        offset+=3;
        break;
    case HEALTH_ATTENTION_GET:
        break;
    case HEALTH_ATTENTION_SET:
        proto_tree_add_item(sub_tree, hf_btmesh_health_attention_set_attention, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        break;
    case HEALTH_ATTENTION_SET_UNACKNOWLEDGED:
        proto_tree_add_item(sub_tree, hf_btmesh_health_attention_set_unacknowledged_attention, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        break;
    case HEALTH_ATTENTION_STATUS:
        proto_tree_add_item(sub_tree, hf_btmesh_health_attention_status_attention, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        break;
    case CONFIG_COMPOSITION_DATA_GET:
        proto_tree_add_item(sub_tree, hf_btmesh_config_composition_data_get_page, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        break;
    case CONFIG_BEACON_GET:
        break;
    case CONFIG_BEACON_SET:
        proto_tree_add_item(sub_tree, hf_btmesh_config_beacon_set_beacon, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        break;
    case CONFIG_BEACON_STATUS:
        proto_tree_add_item(sub_tree, hf_btmesh_config_beacon_status_beacon, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        break;
    case CONFIG_DEFAULT_TTL_GET:
        break;
    case CONFIG_DEFAULT_TTL_SET:
        proto_tree_add_item(sub_tree, hf_btmesh_config_default_ttl_set_ttl, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        break;
    case CONFIG_DEFAULT_TTL_STATUS:
        proto_tree_add_item(sub_tree, hf_btmesh_config_default_ttl_status_ttl, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        break;
    case CONFIG_FRIEND_GET:
        break;
    case CONFIG_FRIEND_SET:
        proto_tree_add_item(sub_tree, hf_btmesh_config_friend_set_friend, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        break;
    case CONFIG_FRIEND_STATUS:
        proto_tree_add_item(sub_tree, hf_btmesh_config_friend_status_friend, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        break;
    case CONFIG_GATT_PROXY_GET:
        break;
    case CONFIG_GATT_PROXY_SET:
        proto_tree_add_item(sub_tree, hf_btmesh_config_gatt_proxy_set_gattproxy, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        break;
    case CONFIG_GATT_PROXY_STATUS:
        proto_tree_add_item(sub_tree, hf_btmesh_config_gatt_proxy_status_gattproxy, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        break;
    case CONFIG_KEY_REFRESH_PHASE_GET:
        net_index_item = proto_tree_add_item(sub_tree, hf_btmesh_config_key_refresh_phase_get_netkeyindex, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        net_index_sub_tree = proto_item_add_subtree(net_index_item, ett_btmesh_config_model_net_index);
        proto_tree_add_item(net_index_sub_tree, hf_btmesh_config_key_refresh_phase_get_netkeyindex_idx, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(net_index_sub_tree, hf_btmesh_config_key_refresh_phase_get_netkeyindex_rfu, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        break;
    case CONFIG_KEY_REFRESH_PHASE_SET:
        net_index_item = proto_tree_add_item(sub_tree, hf_btmesh_config_key_refresh_phase_set_netkeyindex, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        net_index_sub_tree = proto_item_add_subtree(net_index_item, ett_btmesh_config_model_net_index);
        proto_tree_add_item(net_index_sub_tree, hf_btmesh_config_key_refresh_phase_set_netkeyindex_idx, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(net_index_sub_tree, hf_btmesh_config_key_refresh_phase_set_netkeyindex_rfu, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        proto_tree_add_item(sub_tree, hf_btmesh_config_key_refresh_phase_set_transition, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        break;
    case CONFIG_KEY_REFRESH_PHASE_STATUS:
        proto_tree_add_item(sub_tree, hf_btmesh_config_key_refresh_phase_status_status, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        net_index_item = proto_tree_add_item(sub_tree, hf_btmesh_config_key_refresh_phase_status_netkeyindex, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        net_index_sub_tree = proto_item_add_subtree(net_index_item, ett_btmesh_config_model_net_index);
        proto_tree_add_item(net_index_sub_tree, hf_btmesh_config_key_refresh_phase_status_netkeyindex_idx, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(net_index_sub_tree, hf_btmesh_config_key_refresh_phase_status_netkeyindex_rfu, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        proto_tree_add_item(sub_tree, hf_btmesh_config_key_refresh_phase_status_phase, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        break;
    case CONFIG_MODEL_PUBLICATION_GET:
        proto_tree_add_item(sub_tree, hf_btmesh_config_model_publication_get_elementaddress, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        if (tvb_reported_length_remaining(tvb, offset) > 2) {
            proto_tree_add_item(sub_tree, hf_btmesh_config_model_publication_get_vendormodelidentifier, tvb, offset, 4, ENC_LITTLE_ENDIAN);
            offset+=4;
        } else {
            proto_tree_add_item(sub_tree, hf_btmesh_config_model_publication_get_modelidentifier, tvb, offset, 2, ENC_LITTLE_ENDIAN);
            offset+=2;
        }
        break;
    case CONFIG_MODEL_PUBLICATION_STATUS:
        proto_tree_add_item(sub_tree, hf_btmesh_config_model_publication_status_status, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        proto_tree_add_item(sub_tree, hf_btmesh_config_model_publication_status_elementaddress, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        proto_tree_add_item(sub_tree, hf_btmesh_config_model_publication_status_publishaddress, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        pub_app_index_item = proto_tree_add_item(sub_tree, hf_btmesh_config_model_publication_status_appkey, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        pub_app_index_sub_tree= proto_item_add_subtree(pub_app_index_item, ett_btmesh_config_model_pub_app_index);
        proto_tree_add_item(pub_app_index_sub_tree, hf_btmesh_config_model_publication_status_appkeyindex, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(pub_app_index_sub_tree, hf_btmesh_config_model_publication_status_credentialflag, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(pub_app_index_sub_tree, hf_btmesh_config_model_publication_status_rfu, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        proto_tree_add_item(sub_tree, hf_btmesh_config_model_publication_status_publishttl, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        publishperiod_item = proto_tree_add_item(sub_tree, hf_btmesh_config_model_publication_status_publishperiod, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        publishperiod_sub_tree = proto_item_add_subtree(publishperiod_item, ett_btmesh_config_model_publishperiod);
        proto_tree_add_item(publishperiod_sub_tree, hf_btmesh_config_model_publication_status_publishperiod_steps, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(publishperiod_sub_tree, hf_btmesh_config_model_publication_status_publishperiod_resolution, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        publishretransmit_item = proto_tree_add_item(sub_tree, hf_btmesh_config_model_publication_status_publishretransmit, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        publishretransmit_sub_tree = proto_item_add_subtree(publishretransmit_item, ett_btmesh_config_model_publishretransmit);
        proto_tree_add_item(publishretransmit_sub_tree, hf_btmesh_config_model_publication_status_publishretransmit_count, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(publishretransmit_sub_tree, hf_btmesh_config_model_publication_status_publishretransmit_intervalsteps, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        if (tvb_reported_length_remaining(tvb, offset) > 2) {
            proto_tree_add_item(sub_tree, hf_btmesh_config_model_publication_status_vendormodelidentifier, tvb, offset, 4, ENC_LITTLE_ENDIAN);
            offset+=4;
        } else {
            proto_tree_add_item(sub_tree, hf_btmesh_config_model_publication_status_modelidentifier, tvb, offset, 2, ENC_LITTLE_ENDIAN);
            offset+=2;
        }
        break;
    case CONFIG_MODEL_PUBLICATION_VIRTUAL_ADDRESS_SET:
        proto_tree_add_item(sub_tree, hf_btmesh_config_model_publication_virtual_address_set_elementaddress, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        proto_tree_add_item(sub_tree, hf_btmesh_config_model_publication_virtual_address_set_publishaddress, tvb, offset, 16, ENC_NA);
        offset+=16;
        pub_app_index_item = proto_tree_add_item(sub_tree, hf_btmesh_config_model_publication_virtual_address_set_appkey, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        pub_app_index_sub_tree= proto_item_add_subtree(pub_app_index_item, ett_btmesh_config_model_pub_app_index);
        proto_tree_add_item(pub_app_index_sub_tree, hf_btmesh_config_model_publication_virtual_address_set_appkeyindex, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(pub_app_index_sub_tree, hf_btmesh_config_model_publication_virtual_address_set_credentialflag, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(pub_app_index_sub_tree, hf_btmesh_config_model_publication_virtual_address_set_rfu, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        proto_tree_add_item(sub_tree, hf_btmesh_config_model_publication_virtual_address_set_publishttl, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        publishperiod_item = proto_tree_add_item(sub_tree, hf_btmesh_config_model_publication_virtual_address_set_publishperiod, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        publishperiod_sub_tree = proto_item_add_subtree(publishperiod_item, ett_btmesh_config_model_publishperiod);
        proto_tree_add_item(publishperiod_sub_tree, hf_btmesh_config_model_publication_virtual_address_set_publishperiod_steps, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(publishperiod_sub_tree, hf_btmesh_config_model_publication_virtual_address_set_publishperiod_resolution, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        publishretransmit_item = proto_tree_add_item(sub_tree, hf_btmesh_config_model_publication_virtual_address_set_publishretransmit, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        publishretransmit_sub_tree = proto_item_add_subtree(publishretransmit_item, ett_btmesh_config_model_publishretransmit);
        proto_tree_add_item(publishretransmit_sub_tree, hf_btmesh_config_model_publication_virtual_address_set_publishretransmit_count, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(publishretransmit_sub_tree, hf_btmesh_config_model_publication_virtual_address_set_publishretransmit_intervalsteps, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        if (tvb_reported_length_remaining(tvb, offset) > 2) {
            proto_tree_add_item(sub_tree, hf_btmesh_config_model_publication_virtual_address_set_vendormodelidentifier, tvb, offset, 4, ENC_LITTLE_ENDIAN);
            offset+=4;
        } else {
            proto_tree_add_item(sub_tree, hf_btmesh_config_model_publication_virtual_address_set_modelidentifier, tvb, offset, 2, ENC_LITTLE_ENDIAN);
            offset+=2;
        }
        break;
    case CONFIG_MODEL_SUBSCRIPTION_ADD:
        proto_tree_add_item(sub_tree, hf_btmesh_config_model_subscription_add_elementaddress, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        proto_tree_add_item(sub_tree, hf_btmesh_config_model_subscription_add_address, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        if (tvb_reported_length_remaining(tvb, offset) > 2) {
            proto_tree_add_item(sub_tree, hf_btmesh_config_model_subscription_add_vendormodelidentifier, tvb, offset, 4, ENC_LITTLE_ENDIAN);
            offset+=4;
        } else {
            proto_tree_add_item(sub_tree, hf_btmesh_config_model_subscription_add_modelidentifier, tvb, offset, 2, ENC_LITTLE_ENDIAN);
            offset+=2;
        }
        break;
    case CONFIG_MODEL_SUBSCRIPTION_DELETE:
        proto_tree_add_item(sub_tree, hf_btmesh_config_model_subscription_delete_elementaddress, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        proto_tree_add_item(sub_tree, hf_btmesh_config_model_subscription_delete_address, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        if (tvb_reported_length_remaining(tvb, offset) > 2) {
            proto_tree_add_item(sub_tree, hf_btmesh_config_model_subscription_delete_vendormodelidentifier, tvb, offset, 4, ENC_LITTLE_ENDIAN);
            offset+=4;
        } else {
            proto_tree_add_item(sub_tree, hf_btmesh_config_model_subscription_delete_modelidentifier, tvb, offset, 2, ENC_LITTLE_ENDIAN);
            offset+=2;
        }
        break;
    case CONFIG_MODEL_SUBSCRIPTION_DELETE_ALL:
        proto_tree_add_item(sub_tree, hf_btmesh_config_model_subscription_delete_all_elementaddress, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        if (tvb_reported_length_remaining(tvb, offset) > 2) {
            proto_tree_add_item(sub_tree, hf_btmesh_config_model_subscription_delete_all_vendormodelidentifier, tvb, offset, 4, ENC_LITTLE_ENDIAN);
            offset+=4;
        } else {
            proto_tree_add_item(sub_tree, hf_btmesh_config_model_subscription_delete_all_modelidentifier, tvb, offset, 2, ENC_LITTLE_ENDIAN);
            offset+=2;
        }
        break;
    case CONFIG_MODEL_SUBSCRIPTION_OVERWRITE:
        proto_tree_add_item(sub_tree, hf_btmesh_config_model_subscription_overwrite_elementaddress, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        proto_tree_add_item(sub_tree, hf_btmesh_config_model_subscription_overwrite_address, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        if (tvb_reported_length_remaining(tvb, offset) > 2) {
            proto_tree_add_item(sub_tree, hf_btmesh_config_model_subscription_overwrite_vendormodelidentifier, tvb, offset, 4, ENC_LITTLE_ENDIAN);
            offset+=4;
        } else {
            proto_tree_add_item(sub_tree, hf_btmesh_config_model_subscription_overwrite_modelidentifier, tvb, offset, 2, ENC_LITTLE_ENDIAN);
            offset+=2;
        }
        break;
    case CONFIG_MODEL_SUBSCRIPTION_STATUS:
        proto_tree_add_item(sub_tree, hf_btmesh_config_model_subscription_status_status, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        proto_tree_add_item(sub_tree, hf_btmesh_config_model_subscription_status_elementaddress, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        proto_tree_add_item(sub_tree, hf_btmesh_config_model_subscription_status_address, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        if (tvb_reported_length_remaining(tvb, offset) > 2) {
            proto_tree_add_item(sub_tree, hf_btmesh_config_model_subscription_status_vendormodelidentifier, tvb, offset, 4, ENC_LITTLE_ENDIAN);
            offset+=4;
        } else {
            proto_tree_add_item(sub_tree, hf_btmesh_config_model_subscription_status_modelidentifier, tvb, offset, 2, ENC_LITTLE_ENDIAN);
            offset+=2;
        }
        break;
    case CONFIG_MODEL_SUBSCRIPTION_VIRTUAL_ADDRESS_ADD:
        proto_tree_add_item(sub_tree, hf_btmesh_config_model_subscription_virtual_address_add_elementaddress, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        proto_tree_add_item(sub_tree, hf_btmesh_config_model_subscription_virtual_address_add_label, tvb, offset, 16, ENC_NA);
        offset+=16;
        if (tvb_reported_length_remaining(tvb, offset) > 2) {
            proto_tree_add_item(sub_tree, hf_btmesh_config_model_subscription_virtual_address_add_vendormodelidentifier, tvb, offset, 4, ENC_LITTLE_ENDIAN);
            offset+=4;
        } else {
            proto_tree_add_item(sub_tree, hf_btmesh_config_model_subscription_virtual_address_add_modelidentifier, tvb, offset, 2, ENC_LITTLE_ENDIAN);
            offset+=2;
        }
        break;
    case CONFIG_MODEL_SUBSCRIPTION_VIRTUAL_ADDRESS_DELETE:
        proto_tree_add_item(sub_tree, hf_btmesh_config_model_subscription_virtual_address_delete_elementaddress, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        proto_tree_add_item(sub_tree, hf_btmesh_config_model_subscription_virtual_address_delete_label, tvb, offset, 16, ENC_NA);
        offset+=16;
        if (tvb_reported_length_remaining(tvb, offset) > 2) {
            proto_tree_add_item(sub_tree, hf_btmesh_config_model_subscription_virtual_address_delete_vendormodelidentifier, tvb, offset, 4, ENC_LITTLE_ENDIAN);
            offset+=4;
        } else {
            proto_tree_add_item(sub_tree, hf_btmesh_config_model_subscription_virtual_address_delete_modelidentifier, tvb, offset, 2, ENC_LITTLE_ENDIAN);
            offset+=2;
        }
        break;
    case CONFIG_MODEL_SUBSCRIPTION_VIRTUAL_ADDRESS_OVERWRITE:
        proto_tree_add_item(sub_tree, hf_btmesh_config_model_subscription_virtual_address_overwrite_elementaddress, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        proto_tree_add_item(sub_tree, hf_btmesh_config_model_subscription_virtual_address_overwrite_label, tvb, offset, 16, ENC_NA);
        offset+=16;
        if (tvb_reported_length_remaining(tvb, offset) > 2) {
            proto_tree_add_item(sub_tree, hf_btmesh_config_model_subscription_virtual_address_overwrite_vendormodelidentifier, tvb, offset, 4, ENC_LITTLE_ENDIAN);
            offset+=4;
        } else {
            proto_tree_add_item(sub_tree, hf_btmesh_config_model_subscription_virtual_address_overwrite_modelidentifier, tvb, offset, 2, ENC_LITTLE_ENDIAN);
            offset+=2;
        }
        break;
    case CONFIG_NETWORK_TRANSMIT_GET:
        break;
    case CONFIG_NETWORK_TRANSMIT_SET:
        transmit_index = proto_tree_add_item(sub_tree, hf_btmesh_config_network_transmit_set_networktransmit, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        transmit_sub_tree = proto_item_add_subtree(transmit_index, ett_btmesh_config_model_network_transmit);
        proto_tree_add_item(transmit_sub_tree, hf_btmesh_config_network_transmit_set_networktransmit_count, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(transmit_sub_tree, hf_btmesh_config_network_transmit_set_networktransmit_intervalsteps, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        break;
    case CONFIG_NETWORK_TRANSMIT_STATUS:
        transmit_index = proto_tree_add_item(sub_tree, hf_btmesh_config_network_transmit_status_networktransmit, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        transmit_sub_tree = proto_item_add_subtree(transmit_index, ett_btmesh_config_model_network_transmit);
        proto_tree_add_item(transmit_sub_tree, hf_btmesh_config_network_transmit_status_networktransmit_count, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(transmit_sub_tree, hf_btmesh_config_network_transmit_status_networktransmit_intervalsteps, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        break;
    case CONFIG_RELAY_GET:
        break;
    case CONFIG_RELAY_SET:
        proto_tree_add_item(sub_tree, hf_btmesh_config_relay_set_relay, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        relayretransmit_index = proto_tree_add_item(sub_tree, hf_btmesh_config_relay_set_relayretransmit, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        relayretransmit_sub_tree = proto_item_add_subtree(relayretransmit_index, ett_btmesh_config_model_relayretransmit);
        proto_tree_add_item(relayretransmit_sub_tree, hf_btmesh_config_relay_set_relayretransmit_count, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(relayretransmit_sub_tree, hf_btmesh_config_relay_set_relayretransmit_intervalsteps, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        break;
    case CONFIG_RELAY_STATUS:
        proto_tree_add_item(sub_tree, hf_btmesh_config_relay_status_relay, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        relayretransmit_index = proto_tree_add_item(sub_tree, hf_btmesh_config_relay_status_relayretransmit, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        relayretransmit_sub_tree = proto_item_add_subtree(relayretransmit_index, ett_btmesh_config_model_relayretransmit);
        proto_tree_add_item(relayretransmit_sub_tree, hf_btmesh_config_relay_status_relayretransmit_count, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(relayretransmit_sub_tree, hf_btmesh_config_relay_status_relayretransmit_intervalsteps, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        break;
    case CONFIG_SIG_MODEL_SUBSCRIPTION_GET:
        proto_tree_add_item(sub_tree, hf_btmesh_config_sig_model_subscription_get_elementaddress, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        proto_tree_add_item(sub_tree, hf_btmesh_config_sig_model_subscription_get_modelidentifier, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        break;
    case CONFIG_SIG_MODEL_SUBSCRIPTION_LIST:
        proto_tree_add_item(sub_tree, hf_btmesh_config_sig_model_subscription_list_status, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        proto_tree_add_item(sub_tree, hf_btmesh_config_sig_model_subscription_list_elementaddress, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        proto_tree_add_item(sub_tree, hf_btmesh_config_sig_model_subscription_list_modelidentifier, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        subscriptionlist_tree = proto_tree_add_subtree(sub_tree, tvb, offset, tvb_reported_length_remaining(tvb, offset), ett_btmesh_config_model_addresses, NULL, "Addresses");
        while (tvb_reported_length_remaining(tvb, offset) > 1) {
            proto_tree_add_item(subscriptionlist_tree, hf_btmesh_config_sig_model_subscription_list_address, tvb, offset, 2, ENC_LITTLE_ENDIAN);
            offset+=2;
        }
        break;
    case CONFIG_VENDOR_MODEL_SUBSCRIPTION_GET:
        proto_tree_add_item(sub_tree, hf_btmesh_config_vendor_model_subscription_get_elementaddress, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        proto_tree_add_item(sub_tree, hf_btmesh_config_vendor_model_subscription_get_modelidentifier, tvb, offset, 4, ENC_LITTLE_ENDIAN);
        offset+=4;
        break;
    case CONFIG_VENDOR_MODEL_SUBSCRIPTION_LIST:
        proto_tree_add_item(sub_tree, hf_btmesh_config_vendor_model_subscription_list_status, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        proto_tree_add_item(sub_tree, hf_btmesh_config_vendor_model_subscription_list_elementaddress, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        proto_tree_add_item(sub_tree, hf_btmesh_config_vendor_model_subscription_list_modelidentifier, tvb, offset, 4, ENC_LITTLE_ENDIAN);
        offset+=4;
        subscriptionlist_tree = proto_tree_add_subtree(sub_tree, tvb, offset, tvb_reported_length_remaining(tvb, offset), ett_btmesh_config_model_addresses, NULL, "Addresses");
        while (tvb_reported_length_remaining(tvb, offset) > 1) {
            proto_tree_add_item(subscriptionlist_tree, hf_btmesh_config_vendor_model_subscription_list_address, tvb, offset, 2, ENC_LITTLE_ENDIAN);
            offset+=2;
        }
        break;
    case CONFIG_LOW_POWER_NODE_POLLTIMEOUT_GET:
        proto_tree_add_item(sub_tree, hf_btmesh_config_low_power_node_polltimeout_get_lpnaddress, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        break;
    case CONFIG_LOW_POWER_NODE_POLLTIMEOUT_STATUS:
        proto_tree_add_item(sub_tree, hf_btmesh_config_low_power_node_polltimeout_status_lpnaddress, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        proto_tree_add_item(sub_tree, hf_btmesh_config_low_power_node_polltimeout_status_polltimeout, tvb, offset, 3, ENC_LITTLE_ENDIAN);
        offset+=3;
        break;
    case HEALTH_FAULT_CLEAR:
        proto_tree_add_item(sub_tree, hf_btmesh_health_fault_clear_company_id, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        break;
    case HEALTH_FAULT_CLEAR_UNACKNOWLEDGED:
        proto_tree_add_item(sub_tree, hf_btmesh_health_fault_clear_unacknowledged_company_id, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        break;
    case HEALTH_FAULT_GET:
        proto_tree_add_item(sub_tree, hf_btmesh_health_fault_get_company_id, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        break;
    case HEALTH_FAULT_TEST:
        proto_tree_add_item(sub_tree, hf_btmesh_health_fault_test_test_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        proto_tree_add_item(sub_tree, hf_btmesh_health_fault_test_company_id, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        break;
    case HEALTH_FAULT_TEST_UNACKNOWLEDGED:
        proto_tree_add_item(sub_tree, hf_btmesh_health_fault_test_unacknowledged_test_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        proto_tree_add_item(sub_tree, hf_btmesh_health_fault_test_unacknowledged_company_id, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        break;
    case HEALTH_PERIOD_GET:
        break;
    case HEALTH_PERIOD_SET:
        proto_tree_add_item(sub_tree, hf_btmesh_health_period_set_fastperioddivisor, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        break;
    case HEALTH_PERIOD_SET_UNACKNOWLEDGED:
        proto_tree_add_item(sub_tree, hf_btmesh_health_period_set_unacknowledged_fastperioddivisor, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        break;
    case HEALTH_PERIOD_STATUS:
        proto_tree_add_item(sub_tree, hf_btmesh_health_period_status_fastperioddivisor, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        break;
    case CONFIG_HEARTBEAT_PUBLICATION_GET:
        break;
    case CONFIG_HEARTBEAT_PUBLICATION_SET:
        proto_tree_add_item(sub_tree, hf_btmesh_config_heartbeat_publication_set_destination, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        proto_tree_add_item(sub_tree, hf_btmesh_config_heartbeat_publication_set_countlog, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        proto_tree_add_item(sub_tree, hf_btmesh_config_heartbeat_publication_set_periodlog, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        proto_tree_add_item(sub_tree, hf_btmesh_config_heartbeat_publication_set_ttl, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        proto_tree_add_bitmask_with_flags(sub_tree, tvb, offset,
            hf_btmesh_config_heartbeat_publication_set_features,
            ett_btmesh_config_heartbeat_publication_set_features,
            config_heartbeat_publication_set_features_headers,
            ENC_LITTLE_ENDIAN, BMT_NO_APPEND);
        offset+=2;
        net_index_item = proto_tree_add_item(sub_tree, hf_btmesh_config_heartbeat_publication_set_netkeyindex, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        net_index_sub_tree = proto_item_add_subtree(net_index_item, ett_btmesh_config_model_net_index);
        proto_tree_add_item(net_index_sub_tree, hf_btmesh_config_heartbeat_publication_set_netkeyindex_idx, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(net_index_sub_tree, hf_btmesh_config_heartbeat_publication_set_netkeyindex_rfu, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        break;
    case CONFIG_HEARTBEAT_SUBSCRIPTION_GET:
        break;
    case CONFIG_HEARTBEAT_SUBSCRIPTION_SET:
        proto_tree_add_item(sub_tree, hf_btmesh_config_heartbeat_subscription_set_source, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        proto_tree_add_item(sub_tree, hf_btmesh_config_heartbeat_subscription_set_destination, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        proto_tree_add_item(sub_tree, hf_btmesh_config_heartbeat_subscription_set_periodlog, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        break;
    case CONFIG_HEARTBEAT_SUBSCRIPTION_STATUS:
        proto_tree_add_item(sub_tree, hf_btmesh_config_heartbeat_subscription_status_status, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        proto_tree_add_item(sub_tree, hf_btmesh_config_heartbeat_subscription_status_source, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        proto_tree_add_item(sub_tree, hf_btmesh_config_heartbeat_subscription_status_destination, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        proto_tree_add_item(sub_tree, hf_btmesh_config_heartbeat_subscription_status_periodlog, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        proto_tree_add_item(sub_tree, hf_btmesh_config_heartbeat_subscription_status_countlog, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        proto_tree_add_item(sub_tree, hf_btmesh_config_heartbeat_subscription_status_minhops, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        proto_tree_add_item(sub_tree, hf_btmesh_config_heartbeat_subscription_status_maxhops, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        break;
    case CONFIG_MODEL_APP_BIND:
        proto_tree_add_item(sub_tree, hf_btmesh_config_model_app_bind_elementaddress, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        app_index_item = proto_tree_add_item(sub_tree, hf_btmesh_config_model_app_bind_appkeyindex, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        app_index_sub_tree = proto_item_add_subtree(app_index_item, ett_btmesh_config_model_app_index);
        proto_tree_add_item(app_index_sub_tree, hf_btmesh_config_model_app_bind_appkeyindex_idx, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(app_index_sub_tree, hf_btmesh_config_model_app_bind_appkeyindex_rfu, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        if (tvb_reported_length_remaining(tvb, offset) > 2) {
            proto_tree_add_item(sub_tree, hf_btmesh_config_model_app_bind_vendormodelidentifier, tvb, offset, 4, ENC_LITTLE_ENDIAN);
            offset+=4;
        } else {
            proto_tree_add_item(sub_tree, hf_btmesh_config_model_app_bind_modelidentifier, tvb, offset, 2, ENC_LITTLE_ENDIAN);
            offset+=2;
        }
        break;
    case CONFIG_MODEL_APP_STATUS:
        proto_tree_add_item(sub_tree, hf_btmesh_config_model_app_status_status, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        proto_tree_add_item(sub_tree, hf_btmesh_config_model_app_status_elementaddress, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        app_index_item = proto_tree_add_item(sub_tree, hf_btmesh_config_model_app_status_appkeyindex, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        app_index_sub_tree = proto_item_add_subtree(app_index_item, ett_btmesh_config_model_app_index);
        proto_tree_add_item(app_index_sub_tree, hf_btmesh_config_model_app_status_appkeyindex_idx, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(app_index_sub_tree, hf_btmesh_config_model_app_status_appkeyindex_rfu, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        if (tvb_reported_length_remaining(tvb, offset) > 2) {
            proto_tree_add_item(sub_tree, hf_btmesh_config_model_app_status_vendormodelidentifier, tvb, offset, 4, ENC_LITTLE_ENDIAN);
            offset+=4;
        } else {
            proto_tree_add_item(sub_tree, hf_btmesh_config_model_app_status_modelidentifier, tvb, offset, 2, ENC_LITTLE_ENDIAN);
            offset+=2;
        }
        break;
    case CONFIG_MODEL_APP_UNBIND:
        proto_tree_add_item(sub_tree, hf_btmesh_config_model_app_unbind_elementaddress, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        app_index_item = proto_tree_add_item(sub_tree, hf_btmesh_config_model_app_unbind_appkeyindex, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        app_index_sub_tree = proto_item_add_subtree(app_index_item, ett_btmesh_config_model_app_index);
        proto_tree_add_item(app_index_sub_tree, hf_btmesh_config_model_app_unbind_appkeyindex_idx, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(app_index_sub_tree, hf_btmesh_config_model_app_unbind_appkeyindex_rfu, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        if (tvb_reported_length_remaining(tvb, offset) > 2) {
            proto_tree_add_item(sub_tree, hf_btmesh_config_model_app_unbind_vendormodelidentifier, tvb, offset, 4, ENC_LITTLE_ENDIAN);
            offset+=4;
        } else {
            proto_tree_add_item(sub_tree, hf_btmesh_config_model_app_unbind_modelidentifier, tvb, offset, 2, ENC_LITTLE_ENDIAN);
            offset+=2;
        }
        break;
    case CONFIG_NETKEY_ADD:
        net_index_item = proto_tree_add_item(sub_tree, hf_btmesh_config_netkey_add_netkeyindex, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        net_index_sub_tree = proto_item_add_subtree(net_index_item, ett_btmesh_config_model_net_index);
        proto_tree_add_item(net_index_sub_tree, hf_btmesh_config_netkey_add_netkeyindex_idx, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(net_index_sub_tree, hf_btmesh_config_netkey_add_netkeyindex_rfu, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        proto_tree_add_item(sub_tree, hf_btmesh_config_netkey_add_netkey, tvb, offset, 16, ENC_NA);
        offset+=16;
        break;
    case CONFIG_NETKEY_DELETE:
        net_index_item = proto_tree_add_item(sub_tree, hf_btmesh_config_netkey_delete_netkeyindex, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        net_index_sub_tree = proto_item_add_subtree(net_index_item, ett_btmesh_config_model_net_index);
        proto_tree_add_item(net_index_sub_tree, hf_btmesh_config_netkey_delete_netkeyindex_idx, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(net_index_sub_tree, hf_btmesh_config_netkey_delete_netkeyindex_rfu, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        break;
    case CONFIG_NETKEY_GET:
        break;
    case CONFIG_NETKEY_LIST:
        netkeylist_tree = proto_tree_add_subtree(sub_tree, tvb, offset, tvb_reported_length_remaining(tvb, offset), ett_btmesh_config_model_netkey_list, NULL, "NetKeyIndexes");
        while (tvb_reported_length_remaining(tvb, offset) >= 2) {
            if (tvb_reported_length_remaining(tvb, offset) >= 3) {
                netkeyindexes = tvb_get_guint24(tvb, offset, ENC_LITTLE_ENDIAN);
                proto_tree_add_uint(netkeylist_tree, hf_btmesh_config_netkey_list_netkeyindex, tvb, offset, 2, netkeyindexes & 0x000FFF);
                proto_tree_add_uint(netkeylist_tree, hf_btmesh_config_netkey_list_netkeyindex, tvb, offset + 1, 2, (netkeyindexes >> 12 ) & 0x000FFF);
                offset+=3;
            } else {
                netkeyindexes = tvb_get_guint16(tvb, offset, ENC_LITTLE_ENDIAN);
                proto_tree_add_uint(netkeylist_tree, hf_btmesh_config_netkey_list_netkeyindex, tvb, offset, 2, netkeyindexes & 0x0FFF);
                proto_tree_add_uint(netkeylist_tree, hf_btmesh_config_netkey_list_netkeyindex_rfu, tvb, offset, 2, (netkeyindexes >> 12 ) & 0xF);
                offset+=2;
            }
        }
        break;
    case CONFIG_NETKEY_STATUS:
        proto_tree_add_item(sub_tree, hf_btmesh_config_netkey_status_status, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        net_index_item = proto_tree_add_item(sub_tree, hf_btmesh_config_netkey_status_netkeyindex, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        net_index_sub_tree = proto_item_add_subtree(net_index_item, ett_btmesh_config_model_net_index);
        proto_tree_add_item(net_index_sub_tree, hf_btmesh_config_netkey_status_netkeyindex_idx, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(net_index_sub_tree, hf_btmesh_config_netkey_status_netkeyindex_rfu, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        break;
    case CONFIG_NETKEY_UPDATE:
        net_index_item = proto_tree_add_item(sub_tree, hf_btmesh_config_netkey_update_netkeyindex, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        net_index_sub_tree = proto_item_add_subtree(net_index_item, ett_btmesh_config_model_net_index);
        proto_tree_add_item(net_index_sub_tree, hf_btmesh_config_netkey_update_netkeyindex_idx, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(net_index_sub_tree, hf_btmesh_config_netkey_update_netkeyindex_rfu, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        proto_tree_add_item(sub_tree, hf_btmesh_config_netkey_update_netkey, tvb, offset, 16, ENC_NA);
        offset+=16;
        break;
    case CONFIG_NODE_IDENTITY_GET:
        net_index_item = proto_tree_add_item(sub_tree, hf_btmesh_config_node_identity_get_netkeyindex, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        net_index_sub_tree = proto_item_add_subtree(net_index_item, ett_btmesh_config_model_net_index);
        proto_tree_add_item(net_index_sub_tree, hf_btmesh_config_node_identity_get_netkeyindex_idx, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(net_index_sub_tree, hf_btmesh_config_node_identity_get_netkeyindex_rfu, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        break;
    case CONFIG_NODE_IDENTITY_SET:
        net_index_item = proto_tree_add_item(sub_tree, hf_btmesh_config_node_identity_set_netkeyindex, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        net_index_sub_tree = proto_item_add_subtree(net_index_item, ett_btmesh_config_model_net_index);
        proto_tree_add_item(net_index_sub_tree, hf_btmesh_config_node_identity_set_netkeyindex_idx, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(net_index_sub_tree, hf_btmesh_config_node_identity_set_netkeyindex_rfu, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        proto_tree_add_item(sub_tree, hf_btmesh_config_node_identity_set_identity, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        break;
    case CONFIG_NODE_IDENTITY_STATUS:
        proto_tree_add_item(sub_tree, hf_btmesh_config_node_identity_status_status, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        net_index_item = proto_tree_add_item(sub_tree, hf_btmesh_config_node_identity_status_netkeyindex, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        net_index_sub_tree = proto_item_add_subtree(net_index_item, ett_btmesh_config_model_net_index);
        proto_tree_add_item(net_index_sub_tree, hf_btmesh_config_node_identity_status_netkeyindex_idx, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        proto_tree_add_item(net_index_sub_tree, hf_btmesh_config_node_identity_status_netkeyindex_rfu, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        proto_tree_add_item(sub_tree, hf_btmesh_config_node_identity_status_identity, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        break;
    case CONFIG_NODE_RESET:
        break;
    case CONFIG_NODE_RESET_STATUS:
        break;
    case CONFIG_SIG_MODEL_APP_GET:
        proto_tree_add_item(sub_tree, hf_btmesh_config_sig_model_app_get_elementaddress, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        proto_tree_add_item(sub_tree, hf_btmesh_config_sig_model_app_get_modelidentifier, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        break;
    case CONFIG_SIG_MODEL_APP_LIST:
        proto_tree_add_item(sub_tree, hf_btmesh_config_sig_model_app_list_status, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        proto_tree_add_item(sub_tree, hf_btmesh_config_sig_model_app_list_elementaddress, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        proto_tree_add_item(sub_tree, hf_btmesh_config_sig_model_app_list_modelidentifier, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        appkeylist_tree = proto_tree_add_subtree(sub_tree, tvb, offset, tvb_reported_length_remaining(tvb, offset), ett_btmesh_config_model_appkey_list, NULL, "AppKeyIndexes");
        while (tvb_reported_length_remaining(tvb, offset) >= 2) {
            if (tvb_reported_length_remaining(tvb, offset) >= 3) {
                appkeyindexes = tvb_get_guint24(tvb, offset, ENC_LITTLE_ENDIAN);
                proto_tree_add_uint(appkeylist_tree, hf_btmesh_config_sig_model_app_list_appkeyindex, tvb, offset, 2, appkeyindexes & 0x000FFF);
                proto_tree_add_uint(appkeylist_tree, hf_btmesh_config_sig_model_app_list_appkeyindex, tvb, offset +1 , 2, (appkeyindexes >> 12 ) & 0x000FFF);
                offset+=3;
            } else {
                appkeyindexes = tvb_get_guint16(tvb, offset, ENC_LITTLE_ENDIAN);
                proto_tree_add_uint(appkeylist_tree, hf_btmesh_config_sig_model_app_list_appkeyindex, tvb, offset, 2, appkeyindexes & 0x0FFF);
                proto_tree_add_uint(appkeylist_tree, hf_btmesh_config_sig_model_app_list_appkeyindex_rfu, tvb, offset, 2, (appkeyindexes >> 12 ) & 0xF);
                offset+=2;
            }
        }
        break;
    case CONFIG_VENDOR_MODEL_APP_GET:
        proto_tree_add_item(sub_tree, hf_btmesh_config_vendor_model_app_get_elementaddress, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        proto_tree_add_item(sub_tree, hf_btmesh_config_vendor_model_app_get_modelidentifier, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=4;
        break;
    case CONFIG_VENDOR_MODEL_APP_LIST:
        proto_tree_add_item(sub_tree, hf_btmesh_config_vendor_model_app_list_status, tvb, offset, 1, ENC_LITTLE_ENDIAN);
        offset++;
        proto_tree_add_item(sub_tree, hf_btmesh_config_vendor_model_app_list_elementaddress, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=2;
        proto_tree_add_item(sub_tree, hf_btmesh_config_vendor_model_app_list_modelidentifier, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        offset+=4;
        appkeylist_tree = proto_tree_add_subtree(sub_tree, tvb, offset, tvb_reported_length_remaining(tvb, offset), ett_btmesh_config_model_appkey_list, NULL, "AppKeyIndexes");
        while (tvb_reported_length_remaining(tvb, offset) >= 2) {
            if (tvb_reported_length_remaining(tvb, offset) >= 3) {
                appkeyindexes = tvb_get_guint24(tvb, offset, ENC_LITTLE_ENDIAN);
                proto_tree_add_uint(appkeylist_tree, hf_btmesh_config_vendor_model_app_list_appkeyindex, tvb, offset, 2, appkeyindexes & 0x000FFF);
                proto_tree_add_uint(appkeylist_tree, hf_btmesh_config_vendor_model_app_list_appkeyindex, tvb, offset +1 , 2, (appkeyindexes >> 12 ) & 0x000FFF);
                offset+=3;
            } else {
                appkeyindexes = tvb_get_guint16(tvb, offset, ENC_LITTLE_ENDIAN);
                proto_tree_add_uint(appkeylist_tree, hf_btmesh_config_vendor_model_app_list_appkeyindex, tvb, offset, 2, appkeyindexes & 0x0FFF);
                proto_tree_add_uint(appkeylist_tree, hf_btmesh_config_vendor_model_app_list_appkeyindex_rfu, tvb, offset, 2, (appkeyindexes >> 12 ) & 0xF);
                offset+=2;
            }
        }
        break;
    default:
        if (tvb_reported_length_remaining(tvb, offset)) {
            proto_tree_add_item(sub_tree, hf_btmesh_model_layer_parameters, tvb, offset, -1, ENC_NA);
            offset+=tvb_reported_length_remaining(tvb, offset);
        }
    }
    /* Still some octets left */
    if (tvb_reported_length_remaining(tvb, offset)) {
        proto_tree_add_expert(sub_tree, pinfo, &ei_btmesh_unknown_payload, tvb, offset, -1);
    }
}

static void
dissect_btmesh_access_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
{
   proto_tree *sub_tree;

   sub_tree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_btmesh_access_pdu, NULL, "Access PDU");
   proto_tree_add_item(sub_tree, hf_btmesh_decrypted_access, tvb, offset, -1, ENC_NA);

   dissect_btmesh_model_layer(tvb, pinfo, tree, offset);
}

static void
dissect_btmesh_transport_control_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, guint32 opcode)
{
    proto_tree *sub_tree;

    sub_tree = proto_tree_add_subtree_format(tree, tvb, offset, -1, ett_btmesh_transp_ctrl_msg, NULL, "Transport Control Message %s",
        val_to_str_const(opcode, btmesh_ctrl_opcode_vals, "Unknown"));

    switch (opcode) {
    case 1:
        /* 3.6.5.1 Friend Poll */
        /* Padding 7 bits */
        proto_tree_add_item(sub_tree, hf_btmesh_cntr_padding, tvb, offset, 1, ENC_BIG_ENDIAN);
        /* FSN 1 bit*/
        proto_tree_add_item(sub_tree, hf_btmesh_cntr_fsn, tvb, offset, 1, ENC_BIG_ENDIAN);
        break;
    case 2:
        /* 3.6.5.2 Friend Update */
        /* Flags 1 octet */
        proto_tree_add_item(sub_tree, hf_btmesh_cntr_key_refresh_flag, tvb, offset, 1, ENC_BIG_ENDIAN);
        proto_tree_add_item(sub_tree, hf_btmesh_cntr_iv_update_flag, tvb, offset, 1, ENC_BIG_ENDIAN);
        proto_tree_add_item(sub_tree, hf_btmesh_cntr_flags_rfu, tvb, offset, 1, ENC_BIG_ENDIAN);
        offset++;
        /* IV Index 4 octets*/
        proto_tree_add_item(sub_tree, hf_btmesh_cntr_iv_index, tvb, offset, 4, ENC_BIG_ENDIAN);
        offset+=4;
        /* MD 1 octet */
        proto_tree_add_item(sub_tree, hf_btmesh_cntr_md, tvb, offset, 1, ENC_BIG_ENDIAN);
        offset++;
        break;
    case 3:
        /* Friend Request */
        /* Criteria 1 octet */
        /* RFU 1 bit */
        proto_tree_add_item(sub_tree, hf_btmesh_cntr_criteria_rfu, tvb, offset, 1, ENC_BIG_ENDIAN);
        /* RSSIFactor 2 bits */
        proto_tree_add_item(sub_tree, hf_btmesh_cntr_criteria_rssifactor, tvb, offset, 1, ENC_BIG_ENDIAN);
        /* ReceiveWindowFactor 2 bits */
        proto_tree_add_item(sub_tree, hf_btmesh_cntr_criteria_receivewindowfactor, tvb, offset, 1, ENC_BIG_ENDIAN);
        /* MinQueueSizeLog 3 bits */
        proto_tree_add_item(sub_tree, hf_btmesh_cntr_criteria_minqueuesizelog, tvb, offset, 1, ENC_BIG_ENDIAN);
        offset++;
        /* ReceiveDelay 1 octet */
        proto_tree_add_item(sub_tree, hf_btmesh_cntr_receivedelay, tvb, offset, 1, ENC_BIG_ENDIAN);
        offset++;
        /* PollTimeout 3 octets */
        proto_tree_add_item(sub_tree, hf_btmesh_cntr_polltimeout, tvb, offset, 3, ENC_BIG_ENDIAN);
        offset+=3;
        /* PreviousAddress 2 octets */
        proto_tree_add_item(sub_tree, hf_btmesh_cntr_previousaddress, tvb, offset, 2, ENC_BIG_ENDIAN);
        offset+=2;
        /* NumElements 1 octets */
        proto_tree_add_item(sub_tree, hf_btmesh_cntr_numelements, tvb, offset, 1, ENC_BIG_ENDIAN);
        offset += 1;
        /* LPNCounter 1 octets */
        proto_tree_add_item(sub_tree, hf_btmesh_cntr_lpncounter, tvb, offset, 1, ENC_BIG_ENDIAN);
        break;
    case 4:
        /* 3.6.5.4 Friend Offer */
        /* ReceiveWindow 1 octet */
        proto_tree_add_item(sub_tree, hf_btmesh_cntr_receivewindow, tvb, offset, 1, ENC_BIG_ENDIAN);
        offset++;
        /* QueueSize 1 octet */
        proto_tree_add_item(sub_tree, hf_btmesh_cntr_queuesize, tvb, offset, 1, ENC_BIG_ENDIAN);
        offset++;
        /* SubscriptionListSize 1 octet */
        proto_tree_add_item(sub_tree, hf_btmesh_cntr_subscriptionlistsize, tvb, offset, 1, ENC_BIG_ENDIAN);
        offset++;
        /* RSSI 1 octet */
        proto_tree_add_item(sub_tree, hf_btmesh_cntr_rssi, tvb, offset, 1, ENC_BIG_ENDIAN);
        offset++;
        /* FriendCounter 2 octets */
        proto_tree_add_item(sub_tree, hf_btmesh_cntr_friendcounter, tvb, offset, 1, ENC_BIG_ENDIAN);
        break;
    case 5:
        /* 3.6.5.5 Friend Clear */
        /* LPNAddress 2 octets */
        proto_tree_add_item(sub_tree, hf_btmesh_cntr_lpnaddress, tvb, offset, 1, ENC_BIG_ENDIAN);
        offset += 2;
        /* LPNCounter 2 octets */
        proto_tree_add_item(sub_tree, hf_btmesh_cntr_lpncounter, tvb, offset, 1, ENC_BIG_ENDIAN);
        break;
    case 6:
        /* 3.6.5.6 Friend Clear Confirm */
        /* LPNAddress 2 octets */
        proto_tree_add_item(sub_tree, hf_btmesh_cntr_lpnaddress, tvb, offset, 1, ENC_BIG_ENDIAN);
        offset += 2;
        /* LPNCounter 2 octets */
        proto_tree_add_item(sub_tree, hf_btmesh_cntr_lpncounter, tvb, offset, 1, ENC_BIG_ENDIAN);

        break;
    case 7:
        /* 3.6.5.7 Friend Subscription List Add */
        /* TransactionNumber 1 octet */
        proto_tree_add_item(sub_tree, hf_btmesh_cntr_transactionnumber, tvb, offset, 1, ENC_BIG_ENDIAN);
        offset++;
        /* AddressList 2 * N */
        proto_tree_add_expert(sub_tree, pinfo, &ei_btmesh_not_decoded_yet, tvb, offset, -1);
        break;
    case 8:
        /* 3.6.5.8 Friend Subscription List Remove */
        proto_tree_add_item(sub_tree, hf_btmesh_cntr_transactionnumber, tvb, offset, 1, ENC_BIG_ENDIAN);
        offset++;
        /* AddressList 2 * N */
        proto_tree_add_expert(sub_tree, pinfo, &ei_btmesh_not_decoded_yet, tvb, offset, -1);
        break;
    case 9:
        /* 3.6.5.9 Friend Subscription List Confirm */
        proto_tree_add_item(sub_tree, hf_btmesh_cntr_transactionnumber, tvb, offset, 1, ENC_BIG_ENDIAN);
        offset++;
        break;
    case 10:
        /* 3.6.5.10 Heartbeat */
        /* RFU & InitTTL */
        proto_tree_add_item(sub_tree, hf_btmesh_cntr_heartbeat_rfu, tvb, offset, 1, ENC_BIG_ENDIAN);
        proto_tree_add_item(sub_tree, hf_btmesh_cntr_init_ttl, tvb, offset, 1, ENC_BIG_ENDIAN);
        offset++;
        /* Features */
        proto_tree_add_item(sub_tree, hf_btmesh_cntr_feature_relay, tvb, offset, 2, ENC_BIG_ENDIAN);
        proto_tree_add_item(sub_tree, hf_btmesh_cntr_feature_proxy, tvb, offset, 2, ENC_BIG_ENDIAN);
        proto_tree_add_item(sub_tree, hf_btmesh_cntr_feature_friend, tvb, offset, 2, ENC_BIG_ENDIAN);
        proto_tree_add_item(sub_tree, hf_btmesh_cntr_feature_low_power, tvb, offset, 2, ENC_BIG_ENDIAN);
        proto_tree_add_item(sub_tree, hf_btmesh_cntr_feature_rfu, tvb, offset, 2, ENC_BIG_ENDIAN);
        break;
    default:
        /* Unknown Control Message */
        proto_tree_add_item(sub_tree, hf_btmesh_cntr_unknown_payload, tvb, offset, -1, ENC_NA);
        proto_tree_add_expert(sub_tree, pinfo, &ei_btmesh_not_decoded_yet, tvb, offset, -1);
        break;
    }
}

static gboolean
try_access_decrypt(tvbuff_t *tvb, int offset, guint8 *decrypted_data, int enc_data_len, guint8 *key, network_decryption_ctx_t *dec_ctx)
{
    guint8 accessnonce[13];
    guint32 seq0;
    gcry_cipher_hd_t cipher_hd;
    gcry_error_t gcrypt_err;
    guint64 ccm_lengths[3];
    guint8 *tag;

    accessnonce[0] = dec_ctx->app_nonce_type;
    accessnonce[1] = (dec_ctx->transmic_size == 4 ? 0x00 : 0x80 );
    memcpy((guint8 *)&accessnonce + 2, dec_ctx->seq_src_buf, 5);
    if (dec_ctx->seg) {
        /* Use 13 Lsbs from seqzero */
        seq0 = dec_ctx->seq;
        /* Check for overflow */
        if ((dec_ctx->seq & 0x1fff) < dec_ctx->seqzero) {
            seq0 -= 0x2000;
        }
        seq0 = seq0 & ~0x1fff;
        seq0 += dec_ctx->seqzero;
        accessnonce[2] = (seq0 & 0xff0000 ) >> 16;
        accessnonce[3] = (seq0 & 0x00ff00 ) >> 8;
        accessnonce[4] = (seq0 & 0x0000ff ) ;
    }
    memcpy((guint8 *)&accessnonce + 7, dec_ctx->dst_buf, 2);
    memcpy((guint8 *)&accessnonce + 9, dec_ctx->ivindex_buf, 4);

    /* Decrypt packet EXPERIMENTAL CODE */
    if (gcry_cipher_open(&cipher_hd, GCRY_CIPHER_AES128, GCRY_CIPHER_MODE_CCM, 0)) {
        return FALSE;
    }
    /* Set key */
    gcrypt_err = gcry_cipher_setkey(cipher_hd, key, 16);
    if (gcrypt_err != 0) {
        gcry_cipher_close(cipher_hd);
        return FALSE;
    }
   /* Load nonce */
    gcrypt_err = gcry_cipher_setiv(cipher_hd, &accessnonce, 13);
    if (gcrypt_err != 0) {
        gcry_cipher_close(cipher_hd);
        return FALSE;
    }
    ccm_lengths[0] = enc_data_len;
    ccm_lengths[1] = (dec_ctx->label_uuid_idx == NO_LABEL_UUID_IDX_USED ? 0 : 16);
    ccm_lengths[2] = dec_ctx->transmic_size;

    gcrypt_err = gcry_cipher_ctl(cipher_hd, GCRYCTL_SET_CCM_LENGTHS, ccm_lengths, sizeof(ccm_lengths));
    if (gcrypt_err != 0) {
        gcry_cipher_close(cipher_hd);
        return FALSE;
    }

    if (dec_ctx->label_uuid_idx != NO_LABEL_UUID_IDX_USED) {
        gcrypt_err = gcry_cipher_authenticate(cipher_hd, uat_btmesh_label_uuid_records[dec_ctx->label_uuid_idx].label_uuid, 16);
        if (gcrypt_err != 0) {
            gcry_cipher_close(cipher_hd);
            return FALSE;
        }
    }

    /* Decrypt */
    gcrypt_err = gcry_cipher_decrypt(cipher_hd, decrypted_data, enc_data_len, tvb_get_ptr(tvb, offset, enc_data_len), enc_data_len);
    if (gcrypt_err != 0) {
        gcry_cipher_close(cipher_hd);
        return FALSE;
    }

    tag = (guint8 *)wmem_alloc(wmem_packet_scope(), dec_ctx->transmic_size);
    gcrypt_err = gcry_cipher_gettag(cipher_hd, tag, dec_ctx->transmic_size);
    gcry_cipher_close(cipher_hd);

    if (gcrypt_err != 0 || memcmp(tag, tvb_get_ptr(tvb, offset + enc_data_len, dec_ctx->transmic_size), dec_ctx->transmic_size)) {
        /* Tag mismatch or cipher error */
        return FALSE;
    }
    /* Tag authenticated */
    return TRUE;
}

static guint
check_address_type(guint32 btmesh_address)
{
    if (btmesh_address & 0x8000 ) {
        if (btmesh_address & 0x4000) {
            return BTMESH_ADDRESS_GROUP;
        }
        return BTMESH_ADDRESS_VIRTUAL;
    } else {
        if (btmesh_address) {
            return BTMESH_ADDRESS_UNICAST;
        }
        return BTMESH_ADDRESS_UNASSIGNED;
    }
}

static tvbuff_t *
btmesh_access_find_key_and_decrypt(tvbuff_t *tvb, packet_info *pinfo, int offset, network_decryption_ctx_t *dec_ctx)
{
    guint i, j, dst_address_type;
    uat_btmesh_record_t *record;
    uat_btmesh_dev_key_record_t *dev_record;
    uat_btmesh_label_uuid_record_t *label_record;
    int enc_data_len;
    guint8 *decrypted_data;

    enc_data_len = tvb_reported_length_remaining(tvb, offset) - dec_ctx->transmic_size;
    decrypted_data = (guint8 *)wmem_alloc(pinfo->pool, enc_data_len);
    dec_ctx->label_uuid_idx = NO_LABEL_UUID_IDX_USED;

    if (enc_data_len <= 0) {
        return NULL;
    }

    dst_address_type = check_address_type(dec_ctx->dst);

    /* Application key */
    if (dec_ctx->app_nonce_type == BTMESH_NONCE_TYPE_APPLICATION) {
        for (i = 0; i < num_btmesh_uat; i++) {
            record = &uat_btmesh_records[i];
            if (record->valid == BTMESH_KEY_ENTRY_VALID) {
                if (dec_ctx->net_key_iv_index_hash == record->net_key_iv_index_hash && dec_ctx->aid == record->aid) {
                    /* Try Label UUID */
                    if (dst_address_type == BTMESH_ADDRESS_VIRTUAL) {
                        for (j = 0; j < num_btmesh_label_uuid_uat; j++) {
                            label_record = &uat_btmesh_label_uuid_records[j];
                            if (label_record->valid == BTMESH_LABEL_UUID_ENTRY_VALID && label_record->hash == dec_ctx->dst){
                                dec_ctx->label_uuid_idx = j;
                                if (try_access_decrypt(tvb, offset, decrypted_data, enc_data_len, record->application_key, dec_ctx)) {
                                    return tvb_new_child_real_data(tvb, decrypted_data, enc_data_len, enc_data_len);
                                }
                            }
                        }
                    } else {
                        if (try_access_decrypt(tvb, offset, decrypted_data, enc_data_len, record->application_key, dec_ctx)) {
                            return tvb_new_child_real_data(tvb, decrypted_data, enc_data_len, enc_data_len);
                        }
                    }
                }
            }
        }
    }
    /* Device key */
    if (dec_ctx->app_nonce_type == BTMESH_NONCE_TYPE_DEVICE) {
        for (i = 0; i < num_btmesh_dev_key_uat; i++) {
            dev_record = &uat_btmesh_dev_key_records[i];
            if (dev_record->valid == BTMESH_DEVICE_KEY_ENTRY_VALID) {
                /* Try Device Key from SRC */
                if ( !memcmp(dev_record->src, dec_ctx->seq_src_buf + 3, 2) ) {
                    /* Try Label UUID */
                    if (dst_address_type == BTMESH_ADDRESS_VIRTUAL) {
                        for (j = 0; j < num_btmesh_label_uuid_uat; j++) {
                            label_record = &uat_btmesh_label_uuid_records[j];
                            if (label_record->valid == BTMESH_LABEL_UUID_ENTRY_VALID && label_record->hash == dec_ctx->dst){
                                dec_ctx->label_uuid_idx = j;
                                if (try_access_decrypt(tvb, offset, decrypted_data, enc_data_len, dev_record->device_key, dec_ctx)) {
                                    return tvb_new_child_real_data(tvb, decrypted_data, enc_data_len, enc_data_len);
                                }
                            }
                        }
                    } else {
                        if (try_access_decrypt(tvb, offset, decrypted_data, enc_data_len, dev_record->device_key, dec_ctx)) {
                            return tvb_new_child_real_data(tvb, decrypted_data, enc_data_len, enc_data_len);
                        }
                    }
                }
                /* Try Device Key from DST when DST is a unicast address */
                if (dst_address_type == BTMESH_ADDRESS_UNICAST) {
                    if ( !memcmp(dev_record->src, dec_ctx->dst_buf, 2) ) {
                        if (try_access_decrypt(tvb, offset, decrypted_data, enc_data_len, dev_record->device_key, dec_ctx)) {
                            return tvb_new_child_real_data(tvb, decrypted_data, enc_data_len, enc_data_len);
                        }
                    }
                }
            }
        }
    }
    return NULL;
}

static void
dissect_btmesh_transport_access_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, network_decryption_ctx_t *dec_ctx)
{
    tvbuff_t *de_acc_tvb;
    proto_tree *sub_tree;

    int length = tvb_reported_length_remaining(tvb, offset);

    sub_tree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_btmesh_upper_transp_acc_pdu, NULL, "Upper Transport Access PDU");
    de_acc_tvb = btmesh_access_find_key_and_decrypt(tvb, pinfo, offset, dec_ctx);

    proto_tree_add_item(sub_tree, hf_btmesh_enc_access_pld, tvb, offset, length - dec_ctx->transmic_size, ENC_NA);
    offset += (length - dec_ctx->transmic_size);

    proto_tree_add_item(sub_tree, hf_btmesh_transtmic, tvb, offset, dec_ctx->transmic_size, ENC_NA);

    if (de_acc_tvb) {
        add_new_data_source(pinfo, de_acc_tvb, "Decrypted access data");
        dissect_btmesh_access_message(de_acc_tvb, pinfo, tree, 0);
    }
}

static void
dissect_btmesh_transport_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean cntrl, network_decryption_ctx_t *dec_ctx)
{
    proto_tree *sub_tree;
    proto_item *ti;
    int offset = 0;
    guint32 seg, opcode, rfu;
    guint32 seqzero, sego, segn;

    /* We receive the full decrypted buffer including DST, skip to opcode */
    offset += 2;
    sub_tree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_btmesh_transp_pdu, &ti, "Lower Transport PDU");
    if (cntrl) {
        proto_tree_add_item_ret_uint(sub_tree, hf_btmesh_cntr_seg, tvb, offset, 1, ENC_BIG_ENDIAN, &seg);
        proto_tree_add_item_ret_uint(sub_tree, hf_btmesh_cntr_opcode, tvb, offset, 1, ENC_BIG_ENDIAN, &opcode);
        offset++;

        if (seg) {
            /* Segmented */
            fragment_head *fd_head = NULL;

            /* RFU */
            proto_tree_add_item_ret_uint(sub_tree, hf_btmesh_seg_rfu, tvb, offset, 3, ENC_BIG_ENDIAN, &rfu);
            /* SeqZero 13 */
            proto_tree_add_item_ret_uint(sub_tree, hf_btmesh_seqzero_data, tvb, offset, 3, ENC_BIG_ENDIAN, &seqzero);
            /* SegO 5 Segment Offset number */
            proto_tree_add_item_ret_uint(sub_tree, hf_btmesh_sego, tvb, offset, 3, ENC_BIG_ENDIAN, &sego);
            /* SegN 5 Last Segment number */
            proto_tree_add_item_ret_uint(sub_tree, hf_btmesh_segn, tvb, offset, 3, ENC_BIG_ENDIAN, &segn);
            offset += 3;

            /* Segment */
            proto_tree_add_item(sub_tree, hf_btmesh_segment, tvb, offset, -1, ENC_NA);

            upper_transport_fragment_key frg_key;
            /* src is 15 bit, seqzero is 13 bit*/
            frg_key.src = dec_ctx->src;
            frg_key.seq0 = seqzero;

            if (!pinfo->fd->visited) {
                guint32 total_length = 0;
                if (segn == sego) {
                    total_length = segn * 8 + tvb_captured_length_remaining(tvb, offset);
                }

                /* Last fragment can be delivered out of order, and can be the first one. */
                fd_head = fragment_get(&upper_transport_reassembly_table, pinfo, BTMESH_NOT_USED, &frg_key);

                if ((fd_head) && (total_length)) {
                    fragment_set_tot_len(&upper_transport_reassembly_table, pinfo, BTMESH_NOT_USED, &frg_key, total_length);
                }
                fd_head = fragment_add(&upper_transport_reassembly_table,
                            tvb, offset, pinfo,
                            BTMESH_NOT_USED, &frg_key,
                            8 * sego,
                            tvb_captured_length_remaining(tvb, offset),
                            ( segn == 0 ? FALSE : TRUE) );

                if ((!fd_head) && (total_length)) {
                    fragment_set_tot_len(&upper_transport_reassembly_table, pinfo, BTMESH_NOT_USED, &frg_key, total_length);
                }
            } else {
                fd_head = fragment_get(&upper_transport_reassembly_table, pinfo, BTMESH_NOT_USED, &frg_key);
                if (fd_head && (fd_head->flags&FD_DEFRAGMENTED)) {
                    tvbuff_t *next_tvb;
                    next_tvb = process_reassembled_data(tvb, offset, pinfo, "Reassembled Control PDU", fd_head, &btmesh_segmented_control_frag_items, NULL, sub_tree);
                    if (next_tvb) {
                        dissect_btmesh_transport_control_message(next_tvb, pinfo, tree, 0, opcode);
                        col_append_str(pinfo->cinfo, COL_INFO, " (Message Reassembled)");
                    } else {
                        col_append_fstr(pinfo->cinfo, COL_INFO," (Message fragment %u)", sego);
                    }
                }
            }
        } else {
            col_append_fstr(pinfo->cinfo, COL_INFO, "%s",
                val_to_str_const(opcode, btmesh_ctrl_opcode_vals, "Unknown"));
            if (opcode == 0) {
                /* OBO 1 */
                proto_tree_add_item(sub_tree, hf_btmesh_obo, tvb, offset, 2, ENC_BIG_ENDIAN);
                /* SeqZero 13 */
                proto_tree_add_item(sub_tree, hf_btmesh_seqzero, tvb, offset, 2, ENC_BIG_ENDIAN);
                /* RFU 2 */
                proto_tree_add_item(sub_tree, hf_btmesh_rfu, tvb, offset, 2, ENC_BIG_ENDIAN);
                offset += 2;
                /* BlockAck 32 */
                proto_tree_add_item(sub_tree, hf_btmesh_blockack, tvb, offset, 4, ENC_BIG_ENDIAN);
                return;
            }
            dissect_btmesh_transport_control_message(tvb, pinfo, tree, offset, opcode);
        }
    } else {
        /* Access message */
        guint32 afk, aid, szmic;
        /* Access message */
        proto_tree_add_item_ret_uint(sub_tree, hf_btmesh_acc_seg, tvb, offset, 1, ENC_BIG_ENDIAN, &seg);
        /* AKF 1 Application Key Flag */
        proto_tree_add_item_ret_uint(sub_tree, hf_btmesh_acc_akf, tvb, offset, 1, ENC_BIG_ENDIAN, &afk);
        /* AID 6 Application key identifier */
        proto_tree_add_item_ret_uint(sub_tree, hf_btmesh_acc_aid, tvb, offset, 1, ENC_BIG_ENDIAN, &aid);
        offset++;

        dec_ctx->seg = seg;
        dec_ctx->aid = aid;
        dec_ctx->app_nonce_type = (afk ? BTMESH_NONCE_TYPE_APPLICATION : BTMESH_NONCE_TYPE_DEVICE);

        if (seg) {
            /* Segmented */
            fragment_head *fd_head = NULL;

            /* SZMIC 1 Size of TransMIC */
            proto_tree_add_item_ret_uint(sub_tree, hf_btmesh_szmic, tvb, offset, 3, ENC_BIG_ENDIAN, &szmic);
            /* SeqZero 13 Least significant bits of SeqAuth */
            proto_tree_add_item_ret_uint(sub_tree, hf_btmesh_seqzero_data, tvb, offset, 3, ENC_BIG_ENDIAN, &seqzero);
            /* SegO 5 Segment Offset number */
            proto_tree_add_item_ret_uint(sub_tree, hf_btmesh_sego, tvb, offset, 3, ENC_BIG_ENDIAN, &sego);
            /* SegN 5 Last Segment number */
            proto_tree_add_item_ret_uint(sub_tree, hf_btmesh_segn, tvb, offset, 3, ENC_BIG_ENDIAN, &segn);
            offset += 3;

            dec_ctx->seqzero = seqzero;

            /* Segment m 8 to 96 Segment m of the Upper Transport Access PDU */
            proto_tree_add_item(sub_tree, hf_btmesh_segment, tvb, offset, -1, ENC_NA);

            upper_transport_fragment_key frg_key;
            /* src is 15 bit, seqzero is 13 bit*/
            frg_key.src = dec_ctx->src;
            frg_key.seq0 = seqzero;

            if (!pinfo->fd->visited) {
                guint32 total_length = 0;
                if (segn == sego) {
                    total_length = segn * 12 + tvb_captured_length_remaining(tvb, offset);
                }

                /* Last fragment can be delivered out of order, and can be the first one. */
                fd_head = fragment_get(&upper_transport_reassembly_table, pinfo, BTMESH_NOT_USED, &frg_key);

                if ((fd_head) && (total_length)) {
                    fragment_set_tot_len(&upper_transport_reassembly_table, pinfo, BTMESH_NOT_USED, &frg_key, total_length);
                }
                fd_head = fragment_add(&upper_transport_reassembly_table,
                            tvb, offset, pinfo,
                            BTMESH_NOT_USED, &frg_key,
                            12 * sego,
                            tvb_captured_length_remaining(tvb, offset),
                            ( segn == 0 ? FALSE : TRUE) );

                if ((!fd_head) && (total_length)) {
                    fragment_set_tot_len(&upper_transport_reassembly_table, pinfo, BTMESH_NOT_USED, &frg_key, total_length);
                }
            } else {
                fd_head = fragment_get(&upper_transport_reassembly_table, pinfo, BTMESH_NOT_USED, &frg_key);
                if (fd_head && (fd_head->flags&FD_DEFRAGMENTED)) {
                    tvbuff_t *next_tvb;
                    next_tvb = process_reassembled_data(tvb, offset, pinfo, "Reassembled Access PDU", fd_head, &btmesh_segmented_access_frag_items, NULL, sub_tree);
                    if (next_tvb) {
                        dec_ctx->transmic_size = (szmic ? 8 : 4 );
                        dissect_btmesh_transport_access_message(next_tvb, pinfo, tree, 0, dec_ctx);
                        col_append_str(pinfo->cinfo, COL_INFO, " (Message Reassembled)");
                    } else {
                        col_append_fstr(pinfo->cinfo, COL_INFO," (Message fragment %u)", sego);
                    }
                }
            }
        } else {
            proto_item_set_len(ti, 1);
            dec_ctx->transmic_size = 4; /*TransMic is 32 bits*/
            dissect_btmesh_transport_access_message(tvb, pinfo, tree, offset, dec_ctx);
        }
    }
}

tvbuff_t *
btmesh_network_find_key_and_decrypt(tvbuff_t *tvb, packet_info *pinfo, guint8 **decrypted_data, int *enc_data_len, network_decryption_ctx_t *dec_ctx) {
    guint i;
    guint8 nid;
    int offset = 0;
    tvbuff_t *de_obf_tvb;
    guint8 networknonce[13];
    uat_btmesh_record_t *record;
    gcry_cipher_hd_t cipher_hd;
    guint32 net_mic_size;
    gcry_error_t gcrypt_err;
    guint64 ccm_lengths[3];
    int enc_offset;

    nid = tvb_get_guint8(tvb, offset) & 0x7f;

    /* Get the next record to try */
    for (i = 0; i < num_btmesh_uat; i++) {
        record = &uat_btmesh_records[i];
        if (nid == record->nid) {
            offset = 1;
            de_obf_tvb = btmesh_deobfuscate(tvb, pinfo, offset, record);

            if (de_obf_tvb == NULL) {
                continue;
            }
            net_mic_size = (((tvb_get_guint8(de_obf_tvb, 0) & 0x80) >> 7 ) + 1 ) * 4; /* CTL */
            offset +=6;

            (*enc_data_len) = tvb_reported_length(tvb) - offset - net_mic_size;
            enc_offset = offset;

            /* Start setting network nounce.*/
            networknonce[0] = dec_ctx->net_nonce_type; /* Nonce Type */

            tvb_memcpy(de_obf_tvb, (guint8 *)&networknonce + 1, 0, 6);
            if (dec_ctx->net_nonce_type == BTMESH_NONCE_TYPE_PROXY) {
                networknonce[1] = 0x00;    /*Pad*/
            }
            networknonce[7] = 0x00;    /*Pad*/
            networknonce[8] = 0x00;    /*Pad*/

            memcpy((guint8 *)&networknonce + 9, record->ivindex, 4);
            /* Decrypt packet EXPERIMENTAL CODE */
            if (gcry_cipher_open(&cipher_hd, GCRY_CIPHER_AES128, GCRY_CIPHER_MODE_CCM, 0)) {
                return NULL;
            }

            gcrypt_err = gcry_cipher_setkey(cipher_hd, record->encryptionkey, 16);
            if (gcrypt_err != 0) {
                gcry_cipher_close(cipher_hd);
                continue;
            }

            /* Load nonce */
            gcrypt_err = gcry_cipher_setiv(cipher_hd, &networknonce, 13);
            if (gcrypt_err != 0) {
                gcry_cipher_close(cipher_hd);
                continue;
            }
            /* */
            ccm_lengths[0] = (*enc_data_len);
            ccm_lengths[1] = 0; /* aad */
            ccm_lengths[2] = net_mic_size; /* icv */

            gcrypt_err = gcry_cipher_ctl(cipher_hd, GCRYCTL_SET_CCM_LENGTHS, ccm_lengths, sizeof(ccm_lengths));
            if (gcrypt_err != 0) {
                gcry_cipher_close(cipher_hd);
                continue;
            }

            (*decrypted_data) = (guint8 *)wmem_alloc(pinfo->pool, *enc_data_len);
            /* Decrypt */
            gcrypt_err = gcry_cipher_decrypt(cipher_hd, (*decrypted_data), *enc_data_len, tvb_get_ptr(tvb, enc_offset, *enc_data_len), *enc_data_len);
            if (gcrypt_err != 0) {
                gcry_cipher_close(cipher_hd);
                continue;
            }

            guint8 *tag;
            tag = (guint8 *)wmem_alloc(wmem_packet_scope(), net_mic_size);
            gcrypt_err = gcry_cipher_gettag(cipher_hd, tag, net_mic_size);

            if (gcrypt_err == 0 && !memcmp(tag, tvb_get_ptr(tvb, enc_offset + (*enc_data_len), net_mic_size), net_mic_size)) {
                /* Tag authenticated, now close the cypher handle */
                gcry_cipher_close(cipher_hd);
                dec_ctx->net_key_iv_index_hash = record->net_key_iv_index_hash;
                memcpy(dec_ctx->ivindex_buf, record->ivindex, 4);

                return de_obf_tvb;
            }  else {
                /* Now close the cypher handle */
                gcry_cipher_close(cipher_hd);

                /* Tag mismatch or cipher error */
                continue;
            }
        }
    }
    return NULL;
}

static gint
dissect_btmesh_msg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
    proto_item *item;
    proto_tree *netw_tree, *sub_tree;
    int offset = 0;
    guint32 net_mic_size, seq, src, dst;
    int enc_data_len = 0;
    tvbuff_t *de_obf_tvb;
    tvbuff_t *de_cry_tvb;
    int decry_off;
    guint8 *decrypted_data = NULL;
    network_decryption_ctx_t *dec_ctx;

    col_set_str(pinfo->cinfo, COL_PROTOCOL, "BT Mesh");
    col_clear(pinfo->cinfo, COL_INFO);

    item = proto_tree_add_item(tree, proto_btmesh, tvb, offset, -1, ENC_NA);
    netw_tree = proto_item_add_subtree(item, ett_btmesh);

    sub_tree = proto_tree_add_subtree(netw_tree, tvb, offset, -1, ett_btmesh_net_pdu, NULL, "Network PDU");
    /* Check length >= , if not error packet */
    /* First byte in plaintext */
    /* IVI 1 bit Least significant bit of IV Index */
    proto_tree_add_item(sub_tree, hf_btmesh_ivi, tvb, offset, 1, ENC_BIG_ENDIAN);
    proto_tree_add_item(sub_tree, hf_btmesh_nid, tvb, offset, 1, ENC_BIG_ENDIAN);
    offset++;

    dec_ctx = (network_decryption_ctx_t *)wmem_alloc(wmem_packet_scope(), sizeof(network_decryption_ctx_t));
    dec_ctx->net_nonce_type = BTMESH_NONCE_TYPE_NETWORK;

    de_obf_tvb = btmesh_network_find_key_and_decrypt(tvb, pinfo, &decrypted_data, &enc_data_len, dec_ctx);

    if (de_obf_tvb) {
        add_new_data_source(pinfo, de_obf_tvb, "Deobfuscated data");

        gboolean cntrl;

        /* CTL 1 bit Network Control*/
        proto_tree_add_item_ret_uint(sub_tree, hf_btmesh_ctl, de_obf_tvb, 0, 1, ENC_BIG_ENDIAN, &net_mic_size);
        /* 32 or 64 bits ( 0 or 1 )*/
        cntrl = net_mic_size;
        net_mic_size = (net_mic_size + 1) * 4;
        /* The TTL field is a 7-bit field */
        proto_tree_add_item(sub_tree, hf_btmesh_ttl, de_obf_tvb, 0, 1, ENC_BIG_ENDIAN);

        /* SEQ field is a 24-bit integer */
        proto_tree_add_item_ret_uint(sub_tree, hf_btmesh_seq, de_obf_tvb, 1, 3, ENC_BIG_ENDIAN, &seq);

        /* SRC field is a 16-bit value */
        proto_tree_add_item_ret_uint(sub_tree, hf_btmesh_src, de_obf_tvb, 4, 2, ENC_BIG_ENDIAN, &src);
        offset += 6;

        de_cry_tvb = tvb_new_child_real_data(tvb, decrypted_data, enc_data_len, enc_data_len);
        add_new_data_source(pinfo, de_cry_tvb, "Decrypted network data");

        decry_off = 0;
        proto_tree_add_item_ret_uint(sub_tree, hf_btmesh_dst, de_cry_tvb, decry_off, 2, ENC_BIG_ENDIAN, &dst);
        decry_off += 2;
        /* TransportPDU */
        proto_tree_add_item(sub_tree, hf_btmesh_transp_pdu, de_cry_tvb, decry_off, enc_data_len-2, ENC_NA);
        offset += enc_data_len;

        proto_tree_add_item(sub_tree, hf_btmesh_netmic, tvb, offset, net_mic_size, ENC_BIG_ENDIAN);
        offset += net_mic_size;

        if (de_cry_tvb) {
            dec_ctx->src = src;
            dec_ctx->seq = seq;
            dec_ctx->dst = dst;
            tvb_memcpy(de_obf_tvb, dec_ctx->seq_src_buf, 1, 5);
            tvb_memcpy(de_cry_tvb, dec_ctx->dst_buf, 0, 2);

            dissect_btmesh_transport_pdu(de_cry_tvb, pinfo, netw_tree, cntrl, dec_ctx);
        }
    } else {
        proto_tree_add_item(sub_tree, hf_btmesh_obfuscated, tvb, offset, 6, ENC_NA);
        offset += 6;

        proto_tree_add_item(sub_tree, hf_btmesh_encrypted, tvb, offset, -1, ENC_NA);
        offset = tvb_reported_length(tvb);
    }

    return offset;
}

#else /* GCRYPT_VERSION_NUMBER >= 0x010600 */

static void
format_transmit(gchar *buf _U_, guint32 value _U_)
{
}

static void
format_key_index_rfu(gchar *buf _U_, guint32 value _U_)
{
}

static void
format_interval_steps(gchar *buf _U_, guint32 value _U_)
{
}

static void
format_retransmit(gchar *buf _U_, guint32 value _U_)
{
}

static void
format_publish_period(gchar *buf _U_, guint32 value _U_)
{
}

static void
format_publish_appkeyindex_model(gchar *buf _U_, guint32 value _U_)
{
}

static void
format_vendor_model(gchar *buf _U_, guint32 value _U_)
{
}

static void
format_key_index(gchar *buf _U_, guint32 value _U_)
{
}

static void
format_dual_key_index(gchar *buf _U_, guint32 value _U_)
{
}

static gboolean
create_master_security_keys(uat_btmesh_record_t * net_key_set _U_)
{
    return FALSE;
}

static gboolean
k4(uat_btmesh_record_t *key_set _U_)
{
    return FALSE;
}

static gboolean
label_uuid_hash(uat_btmesh_label_uuid_record_t *label_uuid_record _U_)
{
    return FALSE;
}

/* Stub dissector if decryption not available on build system */
static gint
dissect_btmesh_msg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
    proto_item *item;
    proto_tree *sub_tree;
    int offset = 0;

    col_set_str(pinfo->cinfo, COL_PROTOCOL, "BT Mesh");
    col_clear(pinfo->cinfo, COL_INFO);

    item = proto_tree_add_item(tree, proto_btmesh, tvb, offset, -1, ENC_NA);
    sub_tree = proto_item_add_subtree(item, ett_btmesh);

    /* First byte in plaintext */
    /* IVI 1 bit Least significant bit of IV Index */
    proto_tree_add_item(sub_tree, hf_btmesh_ivi, tvb, offset, 1, ENC_BIG_ENDIAN);
    proto_tree_add_item(sub_tree, hf_btmesh_nid, tvb, offset, 1, ENC_BIG_ENDIAN);
    offset++;

    proto_tree_add_item(sub_tree, hf_btmesh_obfuscated, tvb, offset, 6, ENC_NA);
    offset += 6;

    proto_tree_add_item(sub_tree, hf_btmesh_encrypted, tvb, offset, -1, ENC_NA);

    return tvb_reported_length(tvb);
}

#endif /* GCRYPT_VERSION_NUMBER >= 0x010600 */

static gint
compute_ascii_key(guchar **ascii_key, const gchar *key)
{
    guint key_len = 0, raw_key_len;
    gint hex_digit;
    guchar key_byte;
    guint i, j;

    if (key != NULL)
    {
        raw_key_len = (guint)strlen(key);
        if ((raw_key_len > 2) && (key[0] == '0') && ((key[1] == 'x') || (key[1] == 'X')))
        {
            /*
             * Key begins with "0x" or "0X"; skip that and treat the rest
             * as a sequence of hex digits.
             */
            i = 2;    /* first character after "0[Xx]" */
            j = 0;
            if (raw_key_len % 2 == 1)
            {
                /*
                 * Key has an odd number of characters; we act as if the
                 * first character had a 0 in front of it, making the
                 * number of characters even.
                 */
                key_len = (raw_key_len - 2) / 2 + 1;
                *ascii_key = (gchar *)g_malloc((key_len + 1) * sizeof(gchar));
                hex_digit = g_ascii_xdigit_value(key[i]);
                i++;
                if (hex_digit == -1)
                {
                    g_free(*ascii_key);
                    *ascii_key = NULL;
                    return -1;    /* not a valid hex digit */
                }
                (*ascii_key)[j] = (guchar)hex_digit;
                j++;
            }
            else
            {
                /*
                 * Key has an even number of characters, so we treat each
                 * pair of hex digits as a single byte value.
                 */
                key_len = (raw_key_len - 2) / 2;
                *ascii_key = (gchar *)g_malloc((key_len + 1) * sizeof(gchar));
            }

            while (i < (raw_key_len - 1))
            {
                hex_digit = g_ascii_xdigit_value(key[i]);
                i++;
                if (hex_digit == -1)
                {
                    g_free(*ascii_key);
                    *ascii_key = NULL;
                    return -1;    /* not a valid hex digit */
                }
                key_byte = ((guchar)hex_digit) << 4;
                hex_digit = g_ascii_xdigit_value(key[i]);
                i++;
                if (hex_digit == -1)
                {
                    g_free(*ascii_key);
                    *ascii_key = NULL;
                    return -1;    /* not a valid hex digit */
                }
                key_byte |= (guchar)hex_digit;
                (*ascii_key)[j] = key_byte;
                j++;
            }
            (*ascii_key)[j] = '\0';
        }

        else if ((raw_key_len == 2) && (key[0] == '0') && ((key[1] == 'x') || (key[1] == 'X')))
        {
            return 0;
        }
        else
        {
            key_len = raw_key_len;
            *ascii_key = g_strdup(key);
        }
    }
    return key_len;
}

static gboolean
uat_btmesh_record_update_cb(void *r, char **err _U_)
{
    uat_btmesh_record_t *rec = (uat_btmesh_record_t *)r;

    rec->valid = 0;

    /* Compute keys & lengths once and for all */
    if (rec->network_key_string) {
        g_free(rec->network_key);
        rec->network_key_length = compute_ascii_key(&rec->network_key, rec->network_key_string);
        g_free(rec->encryptionkey);
        rec->encryptionkey = (guint8 *)g_malloc(16 * sizeof(guint8));
        memset(rec->encryptionkey, 0, 16 * sizeof(guint8));
        g_free(rec->privacykey);
        rec->privacykey = (guint8 *)g_malloc(16 * sizeof(guint8));
        if (create_master_security_keys(rec)) {
            rec->valid++;
        }
    } else {
        rec->network_key_length = 0;
        rec->network_key = NULL;
    }
    if (rec->application_key_string) {
        g_free(rec->application_key);
        rec->application_key_length = compute_ascii_key(&rec->application_key, rec->application_key_string);
        /* compute AID */
        if (k4(rec)) {
            rec->valid++;
        }
    } else {
        rec->application_key_length = 0;
        rec->application_key = NULL;
    }
    if (rec->ivindex_string) {
        g_free(rec->ivindex);
        rec->ivindex_string_length = compute_ascii_key(&rec->ivindex, rec->ivindex_string);
        if (rec->ivindex_string_length == 4) {
            rec->valid++;
        }
    }
    if (rec->valid == BTMESH_KEY_ENTRY_VALID - 1) {
        /* Compute net_key_index_hash */
        rec->net_key_iv_index_hash =    (guint32) rec->encryptionkey[0];
        rec->net_key_iv_index_hash +=  ((guint32)(rec->encryptionkey[1]) << 8);
        rec->net_key_iv_index_hash +=  ((guint32)(rec->encryptionkey[2]) << 16);
        rec->net_key_iv_index_hash +=  ((guint32)(rec->encryptionkey[3]) << 24);
        rec->net_key_iv_index_hash +=   (guint32) rec->ivindex[0];
        rec->net_key_iv_index_hash +=  ((guint32)(rec->ivindex[1]) << 8);
        rec->net_key_iv_index_hash +=  ((guint32)(rec->ivindex[2]) << 16);
        rec->net_key_iv_index_hash +=  ((guint32)(rec->ivindex[3]) << 24);
        rec->valid++;
    }
    return TRUE;
}

static void *
uat_btmesh_record_copy_cb(void *n, const void *o, size_t siz _U_)
{
    uat_btmesh_record_t *new_rec = (uat_btmesh_record_t *)n;
    const uat_btmesh_record_t* old_rec = (const uat_btmesh_record_t *)o;

    memset(new_rec, 0x00, sizeof(uat_btmesh_record_t));

    /* Copy UAT fields */
    new_rec->network_key_string = g_strdup(old_rec->network_key_string);
    new_rec->application_key_string = g_strdup(old_rec->application_key_string);
    new_rec->ivindex_string = g_strdup(old_rec->ivindex_string);

    /* Parse keys as in an update */
    uat_btmesh_record_update_cb(new_rec, NULL);

    return new_rec;
}

static void
uat_btmesh_record_free_cb(void *r)
{
    uat_btmesh_record_t *rec = (uat_btmesh_record_t *)r;

    g_free(rec->network_key_string);
    g_free(rec->network_key);
    g_free(rec->application_key_string);
    g_free(rec->application_key);
    g_free(rec->ivindex_string);
    g_free(rec->ivindex);
    g_free(rec->privacykey);
    g_free(rec->encryptionkey);
}

UAT_CSTRING_CB_DEF(uat_btmesh_records, network_key_string, uat_btmesh_record_t)
UAT_CSTRING_CB_DEF(uat_btmesh_records, application_key_string, uat_btmesh_record_t)
UAT_CSTRING_CB_DEF(uat_btmesh_records, ivindex_string, uat_btmesh_record_t)

static gboolean
uat_btmesh_dev_key_record_update_cb(void *r, char **err _U_)
{
    uat_btmesh_dev_key_record_t *rec = (uat_btmesh_dev_key_record_t *)r;

    rec->valid = 0;

    /* Compute key & lengths once and for all */
    if (rec->device_key_string) {
        g_free(rec->device_key);
        rec->device_key_length = compute_ascii_key(&rec->device_key, rec->device_key_string);
        if (rec->device_key_length == 16) {
            rec->valid++;
        }
    } else {
        rec->device_key_length = 0;
        rec->device_key = NULL;
    }
    if (rec->src_string) {
        g_free(rec->src);
        rec->src_length = compute_ascii_key(&rec->src, rec->src_string);
        if (rec->src_length == 2) {
            rec->valid++;
        }
    } else {
        rec->src_length = 0;
        rec->src = NULL;
    }
    return TRUE;
}

static void *
uat_btmesh_dev_key_record_copy_cb(void *n, const void *o, size_t siz _U_)
{
    uat_btmesh_dev_key_record_t *new_rec = (uat_btmesh_dev_key_record_t *)n;
    const uat_btmesh_dev_key_record_t* old_rec = (const uat_btmesh_dev_key_record_t *)o;

    memset(new_rec, 0x00, sizeof(uat_btmesh_dev_key_record_t));

    /* Copy UAT fields */
    new_rec->device_key_string = g_strdup(old_rec->device_key_string);
    new_rec->src_string = g_strdup(old_rec->src_string);

    /* Parse key and src as in an update */
    uat_btmesh_dev_key_record_update_cb(new_rec, NULL);

    return new_rec;
}

static void
uat_btmesh_dev_key_record_free_cb(void *r)
{
    uat_btmesh_dev_key_record_t *rec = (uat_btmesh_dev_key_record_t *)r;

    g_free(rec->device_key_string);
    g_free(rec->device_key);
    g_free(rec->src_string);
    g_free(rec->src);
}

UAT_CSTRING_CB_DEF(uat_btmesh_dev_key_records, device_key_string, uat_btmesh_dev_key_record_t)
UAT_CSTRING_CB_DEF(uat_btmesh_dev_key_records, src_string, uat_btmesh_dev_key_record_t)

static gboolean
uat_btmesh_label_uuid_record_update_cb(void *r, char **err _U_)
{
    uat_btmesh_label_uuid_record_t *rec = (uat_btmesh_label_uuid_record_t *)r;

    rec->valid = 0;

    /* Compute label UUID & lengths */
    if (rec->label_uuid_string) {
        g_free(rec->label_uuid);
        rec->label_uuid_length = compute_ascii_key(&rec->label_uuid, rec->label_uuid_string);
        if (label_uuid_hash(rec)) {
            rec->valid++;
        }
    } else {
        rec->label_uuid_length = 0;
        rec->label_uuid = NULL;
    }
    return TRUE;
}

static void *
uat_btmesh_label_uuid_record_copy_cb(void *n, const void *o, size_t siz _U_)
{
    uat_btmesh_label_uuid_record_t *new_rec = (uat_btmesh_label_uuid_record_t *)n;
    const uat_btmesh_label_uuid_record_t* old_rec = (const uat_btmesh_label_uuid_record_t *)o;

    memset(new_rec, 0x00, sizeof(uat_btmesh_label_uuid_record_t));

    /* Copy UAT field */
    new_rec->label_uuid_string = g_strdup(old_rec->label_uuid_string);

    /* Parse Label UUID as in an update */
    uat_btmesh_label_uuid_record_update_cb(new_rec, NULL);

    return new_rec;
}

static void
uat_btmesh_label_uuid_record_free_cb(void *r)
{
    uat_btmesh_label_uuid_record_t *rec = (uat_btmesh_label_uuid_record_t *)r;

    g_free(rec->label_uuid_string);
    g_free(rec->label_uuid);
}

UAT_CSTRING_CB_DEF(uat_btmesh_label_uuid_records, label_uuid_string, uat_btmesh_label_uuid_record_t)

void
proto_register_btmesh(void)
{
    static hf_register_info hf[] = {
        { &hf_btmesh_ivi,
            { "IVI", "btmesh.ivi",
                FT_UINT8, BASE_DEC, NULL, 0x80,
                NULL, HFILL }
        },
        { &hf_btmesh_nid,
            { "NID", "btmesh.nid",
                FT_UINT8, BASE_DEC, NULL, 0x7f,
                NULL, HFILL }
        },
        { &hf_btmesh_obfuscated,
            { "Obfuscated", "btmesh.obfuscated",
                FT_BYTES, BASE_NONE, NULL, 0x0,
                NULL, HFILL }
        },
        { &hf_btmesh_encrypted,
            { "Encrypted data and NetMIC", "btmesh.encrypted",
                FT_BYTES, BASE_NONE, NULL, 0x0,
                NULL, HFILL }
        },
        { &hf_btmesh_netmic,
            { "NetMIC", "btmesh.netmic",
                FT_UINT64, BASE_HEX, NULL, 0x0,
                NULL, HFILL }
        },
        { &hf_btmesh_ctl,
            { "CTL", "btmesh.ctl",
                FT_UINT8, BASE_DEC, VALS(btmesh_ctl_vals), 0x80,
                NULL, HFILL }
        },
        { &hf_btmesh_ttl,
            { "TTL", "btmesh.ttl",
                FT_UINT8, BASE_DEC, NULL, 0x7f,
                NULL, HFILL }
        },
        { &hf_btmesh_seq,
            { "SEQ", "btmesh.seq",
                FT_UINT24, BASE_DEC, NULL, 0x0,
                NULL, HFILL }
        },
        { &hf_btmesh_src,
            { "SRC", "btmesh.src",
                FT_UINT16, BASE_DEC, NULL, 0x0,
                NULL, HFILL }
        },
        { &hf_btmesh_dst,
            { "DST", "btmesh.dst",
                FT_UINT16, BASE_DEC, NULL, 0x0,
                NULL, HFILL }
        },
        { &hf_btmesh_transp_pdu,
            { "TransportPDU", "btmesh.transp_pdu",
                FT_BYTES, BASE_NONE, NULL, 0x0,
                NULL, HFILL }
        },
        { &hf_btmesh_cntr_seg,
            { "SEG", "btmesh.cntr.seg",
                FT_UINT8, BASE_DEC, VALS(btmesh_ctrl_seg_vals), 0x80,
                NULL, HFILL }
        },
        { &hf_btmesh_acc_seg,
            { "SEG", "btmesh.acc.seg",
                FT_UINT8, BASE_DEC, VALS(btmesh_acc_seg_vals), 0x80,
                NULL, HFILL }
        },
        { &hf_btmesh_cntr_opcode,
            { "Opcode", "btmesh.cntr.opcode",
                FT_UINT8, BASE_DEC, VALS(btmesh_ctrl_opcode_vals), 0x7f,
                NULL, HFILL }
        },
        { &hf_btmesh_acc_akf,
            { "AKF", "btmesh.acc.akf",
                FT_UINT8, BASE_DEC, VALS(btmesh_acc_akf_vals), 0x40,
                NULL, HFILL }
        },
        { &hf_btmesh_acc_aid,
            { "AID", "btmesh.acc.aid",
                FT_UINT8, BASE_DEC, NULL, 0x3f,
                NULL, HFILL }
        },
        { &hf_btmesh_obo,
            { "OBO", "btmesh.obo",
                FT_BOOLEAN, 16, TFS(&btmesh_obo), 0x8000,
                NULL, HFILL }
        },
        { &hf_btmesh_seqzero,
            { "SeqZero", "btmesh.seqzero",
                FT_UINT16, BASE_DEC, NULL, 0x7ffc,
                NULL, HFILL }
        },
        { &hf_btmesh_rfu,
            { "Reserved for Future Use", "btmesh.rfu",
                FT_UINT16, BASE_DEC, NULL, 0x0003,
                NULL, HFILL }
        },
        { &hf_btmesh_blockack,
            { "BlockAck", "btmesh.blockack",
                FT_UINT32, BASE_DEC, NULL, 0x0,
                NULL, HFILL }
        },
        { &hf_btmesh_cntr_criteria_rfu,
            { "RFU", "btmesh.cntr.criteria.rfu",
                FT_UINT8, BASE_DEC, NULL, 0x80,
                NULL, HFILL }
        },
        { &hf_btmesh_cntr_padding,
            { "Padding", "btmesh.cntr.padding",
                FT_UINT8, BASE_DEC, NULL, 0xfe,
                NULL, HFILL }
        },
        { &hf_btmesh_cntr_fsn,
            { "Friend Sequence Number(FSN)", "btmesh.cntr.fsn",
                FT_UINT8, BASE_DEC, NULL, 0x01,
                NULL, HFILL }
        },
        { &hf_btmesh_cntr_key_refresh_flag,
            { "Key Refresh Flag", "btmesh.cntr.keyrefreshflag",
                FT_UINT8, BASE_DEC, VALS(btmesh_cntr_key_refresh_flag_vals), 0x01,
                NULL, HFILL }
        },
        { &hf_btmesh_cntr_iv_update_flag,
            { "IV Update Flag", "btmesh.cntr.ivupdateflag",
                FT_UINT8, BASE_DEC, VALS(btmesh_cntr_iv_update_flag_vals), 0x02,
                NULL, HFILL }
        },
        { &hf_btmesh_cntr_flags_rfu,
            { "IV Update Flag", "btmesh.cntr.flagsrfu",
                FT_UINT8, BASE_DEC, NULL, 0xFC,
                NULL, HFILL }
        },
        { &hf_btmesh_cntr_iv_index,
            { "IV Index", "btmesh.cntr.ivindex",
                FT_UINT32, BASE_DEC, NULL, 0x0,
                NULL, HFILL }
        },
        { &hf_btmesh_cntr_md,
            { "MD (More Data)", "btmesh.cntr.md",
                FT_UINT8, BASE_DEC, VALS(btmesh_cntr_md_vals), 0x0,
                NULL, HFILL }
        },
        { &hf_btmesh_cntr_criteria_rssifactor,
            { "RSSIFactor", "btmesh.cntr.criteria.rssifactor",
                FT_UINT8, BASE_DEC, VALS(btmesh_criteria_rssifactor_vals), 0x60,
                NULL, HFILL }
        },
        { &hf_btmesh_cntr_criteria_receivewindowfactor,
            { "ReceiveWindowFactor", "btmesh.cntr.criteria.receivewindowfactor",
                FT_UINT8, BASE_DEC, VALS(btmesh_criteria_receivewindowfactor_vals), 0x18,
                NULL, HFILL }
        },
        { &hf_btmesh_cntr_criteria_minqueuesizelog,
            { "MinQueueSizeLog", "btmesh.cntr.criteria.minqueuesizelog",
                FT_UINT8, BASE_DEC, VALS(btmesh_criteria_minqueuesizelog_vals), 0x07,
                NULL, HFILL }
        },
        { &hf_btmesh_cntr_receivedelay,
            { "ReceiveDelay", "btmesh.cntr.receivedelay",
                FT_UINT8, BASE_DEC, NULL, 0x0,
                NULL, HFILL }
        },
        { &hf_btmesh_cntr_polltimeout,
            { "PollTimeout", "btmesh.cntr.polltimeout",
                FT_UINT24, BASE_DEC, NULL, 0x0,
                NULL, HFILL }
        },
        { &hf_btmesh_cntr_previousaddress,
            { "PreviousAddress", "btmesh.cntr.previousaddress",
                FT_UINT16, BASE_DEC, NULL, 0x0,
                NULL, HFILL }
        },
        { &hf_btmesh_cntr_numelements,
            { "NumElements", "btmesh.cntr.numelements",
                FT_UINT8, BASE_DEC, NULL, 0x0,
                NULL, HFILL }
        },
        { &hf_btmesh_cntr_lpncounter,
            { "LPNCounter", "btmesh.cntr.lpncounter",
                FT_UINT8, BASE_DEC, NULL, 0x0,
                NULL, HFILL }
        },
        { &hf_btmesh_cntr_receivewindow,
            { "ReceiveWindow", "btmesh.cntr.receivewindow",
                FT_UINT8, BASE_DEC | BASE_UNIT_STRING, &units_milliseconds, 0x0,
                NULL, HFILL }
        },
        { &hf_btmesh_cntr_queuesize,
            { "QueueSize", "btmesh.cntr.queuesize",
                FT_UINT8, BASE_DEC, NULL, 0x0,
                NULL, HFILL }
        },
        { &hf_btmesh_cntr_subscriptionlistsize,
            { "SubscriptionListSize", "btmesh.cntr.subscriptionlistsize",
                FT_UINT8, BASE_DEC, NULL, 0x0,
                NULL, HFILL }
        },
        { &hf_btmesh_cntr_rssi,
            { "RSSI", "btmesh.cntr.rssi",
                FT_UINT8, BASE_DEC, NULL, 0x0,
                NULL, HFILL }
        },
        { &hf_btmesh_cntr_friendcounter,
            { "FriendCounter", "btmesh.cntr.friendcounter",
                FT_UINT16, BASE_DEC, NULL, 0x0,
                NULL, HFILL }
        },
        { &hf_btmesh_cntr_lpnaddress,
            { "LPNAddress", "btmesh.cntr.lpnaddress",
                FT_UINT16, BASE_DEC, NULL, 0x0,
                NULL, HFILL }
        },
        { &hf_btmesh_cntr_transactionnumber,
            { "TransactionNumber", "btmesh.cntr.transactionnumber",
                FT_UINT8, BASE_DEC, NULL, 0x0,
                NULL, HFILL }
        },
        { &hf_btmesh_cntr_heartbeat_rfu,
            { "Reserved for Future Use", "btmesh.cntr.heartbeatrfu",
                FT_UINT8, BASE_DEC, NULL, 0x80,
                NULL, HFILL }
        },
        { &hf_btmesh_cntr_init_ttl,
            { "InitTTL", "btmesh.cntr.initttl",
                FT_UINT8, BASE_DEC, NULL, 0x7F,
                NULL, HFILL }
        },
        { &hf_btmesh_cntr_feature_relay,
            { "Relay feature in use", "btmesh.cntr.feature.relay",
                FT_BOOLEAN, 16, TFS(&tfs_true_false), 0x0001,
                NULL, HFILL }
        },
        { &hf_btmesh_cntr_feature_proxy,
            { "Proxy feature in use", "btmesh.cntr.feature.proxy",
                FT_BOOLEAN, 16, TFS(&tfs_true_false), 0x0002,
                NULL, HFILL }
        },
        { &hf_btmesh_cntr_feature_friend,
            { "Friend feature in use", "btmesh.cntr.feature.friend",
                FT_BOOLEAN, 16, TFS(&tfs_true_false), 0x0004,
                NULL, HFILL }
        },
        { &hf_btmesh_cntr_feature_low_power,
            { "Low Power feature in use", "btmesh.cntr.feature.lowpower",
                FT_BOOLEAN, 16, TFS(&tfs_true_false), 0x0008,
                NULL, HFILL }
        },
        { &hf_btmesh_cntr_feature_rfu,
            { "Reserved for Future Use", "btmesh.cntr.feature.rfu",
                FT_UINT16, BASE_DEC, NULL, 0xfff0,
                NULL, HFILL }
        },
        { &hf_btmesh_cntr_unknown_payload,
        { "Unknown Control Message payload", "btmesh.cntr.unknownpayload",
            FT_BYTES, BASE_NONE, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_enc_access_pld,
        { "Encrypted Access Payload", "btmesh.enc_access_pld",
            FT_BYTES, BASE_NONE, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_transtmic,
        { "TransMIC", "btmesh.transtmic",
            FT_BYTES, BASE_NONE, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_szmic,
        { "SZMIC", "btmesh.szmic",
            FT_UINT24, BASE_DEC, VALS(btmesh_szmic_vals), 0x800000,
            NULL, HFILL }
        },
        { &hf_btmesh_seqzero_data,
        { "SeqZero", "btmesh.seqzero_data",
            FT_UINT24, BASE_DEC, NULL, 0x7ffc00,
            NULL, HFILL }
        },
        { &hf_btmesh_sego,
        { "Segment Offset number(SegO)", "btmesh.sego",
            FT_UINT24, BASE_DEC, NULL, 0x0003e0,
            NULL, HFILL }
        },
        { &hf_btmesh_segn,
        { "Last Segment number(SegN)", "btmesh.segn",
            FT_UINT24, BASE_DEC, NULL, 0x00001f,
            NULL, HFILL }
        },
        { &hf_btmesh_seg_rfu,
        { "RFU", "btmesh.seg.rfu",
            FT_UINT24, BASE_DEC, NULL, 0x800000,
            NULL, HFILL }
        },
        { &hf_btmesh_segment,
        { "Segment", "btmesh.segment",
            FT_BYTES, BASE_NONE, NULL, 0x0,
            NULL, HFILL }
        },
        /* Access Message Reassembly */
        { &hf_btmesh_segmented_access_fragments,
            { "Reassembled Segmented Access Message Fragments", "btmesh.segmented.access.fragments",
                FT_NONE, BASE_NONE, NULL, 0x0,
                "Segmented Access Message Fragments", HFILL }
        },
        { &hf_btmesh_segmented_access_fragment,
            { "Segmented Access Message Fragment", "btmesh.segmented.access.fragment",
                FT_FRAMENUM, BASE_NONE, NULL, 0x0,
                NULL, HFILL }
        },
        { &hf_btmesh_segmented_access_fragment_overlap,
            { "Fragment overlap", "btmesh.segmented.access.fragment.overlap",
                FT_BOOLEAN, BASE_NONE, NULL, 0x0,
                "Fragment overlaps with other fragments", HFILL }
        },
        { &hf_btmesh_segmented_access_fragment_overlap_conflict,
            { "Conflicting data in fragment overlap", "btmesh.segmented.access.fragment.overlap.conflict",
                FT_BOOLEAN, BASE_NONE, NULL, 0x0,
                "Overlapping fragments contained conflicting data", HFILL }
        },
        { &hf_btmesh_segmented_access_fragment_multiple_tails,
            { "Multiple tail fragments found", "btmesh.segmented.access.fragment.multipletails",
                FT_BOOLEAN, BASE_NONE, NULL, 0x0,
                "Several tails were found when defragmenting the packet", HFILL }
        },
        { &hf_btmesh_segmented_access_fragment_too_long_fragment,
            { "Fragment too long", "btmesh.segmented.access.fragment.toolongfragment",
                FT_BOOLEAN, BASE_NONE, NULL, 0x0,
                "Fragment contained data past end of packet", HFILL }
        },
        { &hf_btmesh_segmented_access_fragment_error,
            { "Defragmentation error", "btmesh.segmented.access.fragment.error",
                FT_FRAMENUM, BASE_NONE, NULL, 0x0,
                "Defragmentation error due to illegal fragments", HFILL }
        },
        { &hf_btmesh_segmented_access_fragment_count,
            { "Fragment count", "btmesh.segmented.access.fragment.count",
                FT_UINT32, BASE_DEC, NULL, 0x0,
                NULL, HFILL }
        },
        { &hf_btmesh_segmented_access_reassembled_length,
            { "Reassembled Segmented Access Message length", "btmesh.segmented.access.reassembled.length",
                FT_UINT32, BASE_DEC, NULL, 0x0,
                "The total length of the reassembled payload", HFILL }
        },
        /* Control Message Reassembly */
        { &hf_btmesh_segmented_control_fragments,
            { "Reassembled Segmented Control Message Fragments", "btmesh.segmented.control.fragments",
                FT_NONE, BASE_NONE, NULL, 0x0,
                "Segmented Access Message Fragments", HFILL }
        },
        { &hf_btmesh_segmented_control_fragment,
            { "Segmented Control Message Fragment", "btmesh.segmented.control.fragment",
                FT_FRAMENUM, BASE_NONE, NULL, 0x0,
                NULL, HFILL }
        },
        { &hf_btmesh_segmented_control_fragment_overlap,
            { "Fragment overlap", "btmesh.segmented.control.fragment.overlap",
                FT_BOOLEAN, BASE_NONE, NULL, 0x0,
                "Fragment overlaps with other fragments", HFILL }
        },
        { &hf_btmesh_segmented_control_fragment_overlap_conflict,
            { "Conflicting data in fragment overlap", "btmesh.segmented.control.fragment.overlap.conflict",
                FT_BOOLEAN, BASE_NONE, NULL, 0x0,
                "Overlapping fragments contained conflicting data", HFILL }
        },
        { &hf_btmesh_segmented_control_fragment_multiple_tails,
            { "Multiple tail fragments found", "btmesh.segmented.control.fragment.multipletails",
                FT_BOOLEAN, BASE_NONE, NULL, 0x0,
                "Several tails were found when defragmenting the packet", HFILL }
        },
        { &hf_btmesh_segmented_control_fragment_too_long_fragment,
            { "Fragment too long", "btmesh.segmented.control.fragment.toolongfragment",
                FT_BOOLEAN, BASE_NONE, NULL, 0x0,
                "Fragment contained data past end of packet", HFILL }
        },
        { &hf_btmesh_segmented_control_fragment_error,
            { "Defragmentation error", "btmesh.segmented.control.fragment.error",
                FT_FRAMENUM, BASE_NONE, NULL, 0x0,
                "Defragmentation error due to illegal fragments", HFILL }
        },
        { &hf_btmesh_segmented_control_fragment_count,
            { "Fragment count", "btmesh.segmented.control.fragment.count",
                FT_UINT32, BASE_DEC, NULL, 0x0,
                NULL, HFILL }
        },
        { &hf_btmesh_segmented_control_reassembled_length,
            { "Reassembled Segmented Control Message length", "btmesh.segmented.control.reassembled.length",
                FT_UINT32, BASE_DEC, NULL, 0x0,
                "The total length of the reassembled payload", HFILL }
        },
        { &hf_btmesh_decrypted_access,
            { "Decrypted Accesss", "btmesh.accesss.decrypted",
                FT_BYTES, BASE_NONE, NULL, 0x0,
                NULL, HFILL }
        },
        { &hf_btmesh_model_layer_vendor_opcode,
            { "Opcode", "btmesh.model.vendor.opcode",
                FT_UINT8, BASE_DEC, NULL, 0x3f,
                NULL, HFILL }
        },
        { &hf_btmesh_model_layer_vendor,
            { "Opcode", "btmesh.model.vendor",
                FT_UINT16, BASE_DEC, NULL, 0x0,
                NULL, HFILL }
        },
        { &hf_btmesh_model_layer_opcode,
            { "Opcode", "btmesh.model.opcode",
                FT_UINT16, BASE_HEX, VALS(btmesh_models_opcode_vals), 0x0,
                NULL, HFILL }
        },
        { &hf_btmesh_model_layer_parameters,
            { "Parameters", "btmesh.model.parameters",
                FT_BYTES, BASE_NONE, NULL, 0x0,
                NULL, HFILL }
        },
        /* Config Model opcodes parameters */
        { &hf_btmesh_config_appkey_add_netkeyindexandappkeyindex,
            { "NetKeyIndexAndAppKeyIndex", "btmesh.model.config_appkey_add.netkeyindexandappkeyindex",
            FT_UINT24, BASE_CUSTOM, CF_FUNC(format_dual_key_index), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_appkey_add_netkeyindexandappkeyindex_net,
            { "NetKeyIndex", "btmesh.model.config_appkey_add.netkeyindexandappkeyindex.net",
            FT_UINT24, BASE_CUSTOM, CF_FUNC(format_key_index), 0xFFF,
            NULL, HFILL }
        },
        { &hf_btmesh_config_appkey_add_netkeyindexandappkeyindex_app,
            { "AppKeyIndex", "btmesh.model.config_appkey_add.netkeyindexandappkeyindex.app",
            FT_UINT24, BASE_CUSTOM, CF_FUNC(format_key_index), 0xFFF000,
            NULL, HFILL }
        },
        { &hf_btmesh_config_appkey_add_appkey,
            { "AppKey", "btmesh.model.config_appkey_add.appkey",
            FT_BYTES, BASE_NONE, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_appkey_update_netkeyindexandappkeyindex,
            { "NetKeyIndexAndAppKeyIndex", "btmesh.model.config_appkey_update.netkeyindexandappkeyindex",
            FT_UINT24, BASE_CUSTOM, CF_FUNC(format_dual_key_index), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_appkey_update_netkeyindexandappkeyindex_net,
            { "NetKeyIndex", "btmesh.model.config_appkey_update.netkeyindexandappkeyindex.net",
            FT_UINT24, BASE_CUSTOM, CF_FUNC(format_key_index), 0xFFF,
            NULL, HFILL }
        },
        { &hf_btmesh_config_appkey_update_netkeyindexandappkeyindex_app,
            { "AppKeyIndex", "btmesh.model.config_appkey_update.netkeyindexandappkeyindex.app",
            FT_UINT24, BASE_CUSTOM, CF_FUNC(format_key_index), 0xFFF000,
            NULL, HFILL }
        },
        { &hf_btmesh_config_appkey_update_appkey,
            { "AppKey", "btmesh.model.config_appkey_update.appkey",
            FT_BYTES, BASE_NONE, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_composition_data_status_page,
            { "Page", "btmesh.model.config_composition_data_status.page",
            FT_UINT8, BASE_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_composition_data_status_cid,
            { "CID", "btmesh.model.config_composition_data_status.cid",
            FT_UINT16, BASE_HEX | BASE_EXT_STRING, &bluetooth_company_id_vals_ext, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_composition_data_status_pid,
            { "PID", "btmesh.model.config_composition_data_status.pid",
            FT_UINT16, BASE_DEC_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_composition_data_status_vid,
            { "VID", "btmesh.model.config_composition_data_status.vid",
            FT_UINT16, BASE_DEC_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_composition_data_status_crpl,
            { "CRPL", "btmesh.model.config_composition_data_status.crpl",
            FT_UINT16, BASE_DEC_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_composition_data_status_features_relay,
            { "Relay feature", "btmesh.model.config_composition_data_status.features.relay",
            FT_BOOLEAN, 16, TFS(&tfs_supported_not_supported), 0x0001,
            NULL, HFILL }
        },
        { &hf_btmesh_config_composition_data_status_features_proxy,
            { "Proxy feature", "btmesh.model.config_composition_data_status.features.proxy",
            FT_BOOLEAN, 16, TFS(&tfs_supported_not_supported), 0x0002,
            NULL, HFILL }
        },
        { &hf_btmesh_config_composition_data_status_features_friend,
            { "Friend feature", "btmesh.model.config_composition_data_status.features.friend",
            FT_BOOLEAN, 16, TFS(&tfs_supported_not_supported), 0x0004,
            NULL, HFILL }
        },
        { &hf_btmesh_config_composition_data_status_features_low_power,
            { "Low Power feature", "btmesh.model.config_composition_data_status.features.low_power",
            FT_BOOLEAN, 16, TFS(&tfs_supported_not_supported), 0x0008,
            NULL, HFILL }
        },
        { &hf_btmesh_config_composition_data_status_features_rfu,
            { "RFU", "btmesh.model.config_composition_data_status.features.rfu",
            FT_UINT16, BASE_HEX, NULL, 0xFFF0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_composition_data_status_features,
            { "Features", "btmesh.model.config_composition_data_status.features",
            FT_UINT16, BASE_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_composition_data_status_loc,
            { "Loc", "btmesh.model.config_composition_data_status.loc",
            FT_UINT16, BASE_HEX, VALS(characteristic_presentation_namespace_description_btsig_vals), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_composition_data_status_nums,
            { "NumS", "btmesh.model.config_composition_data_status.nums",
            FT_UINT8, BASE_DEC, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_composition_data_status_numv,
            { "NumV", "btmesh.model.config_composition_data_status.numv",
            FT_UINT8, BASE_DEC, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_composition_data_status_sig_model,
            { "SIG Model", "btmesh.model.config_composition_data_status.sig_model",
            FT_UINT16, BASE_HEX, VALS(btmesh_model_vals), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_composition_data_status_vendor_model,
            { "Vendor Model", "btmesh.model.config_composition_data_status.vendor_model",
            FT_UINT32, BASE_CUSTOM, CF_FUNC(format_vendor_model), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_publication_set_elementaddress,
            { "ElementAddress", "btmesh.model.config_model_publication_set.elementaddress",
            FT_UINT16, BASE_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_publication_set_publishaddress,
            { "PublishAddress", "btmesh.model.config_model_publication_set.publishaddress",
            FT_UINT16, BASE_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_publication_set_appkey,
            { "AppKeyIndex", "btmesh.model.config_model_publication_set.appkey",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_publish_appkeyindex_model), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_publication_set_appkeyindex,
            { "AppKeyIndex", "btmesh.model.config_model_publication_set.appkeyindex",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index), 0x0FFF,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_publication_set_credentialflag,
            { "CredentialFlag", "btmesh.model.config_model_publication_set.credentialflag",
            FT_UINT16, BASE_DEC, VALS(btmesh_friendship_credentials_flag_vals), 0x1000,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_publication_set_rfu,
            { "RFU", "btmesh.model.config_model_publication_set.rfu",
            FT_UINT16, BASE_DEC, VALS(btmesh_friendship_credentials_flag_vals), 0xE000,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_publication_set_publishttl,
            { "PublishTTL", "btmesh.model.config_model_publication_set.publishttl",
            FT_UINT8, BASE_DEC, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_publication_set_publishperiod,
            { "PublishPeriod", "btmesh.model.config_model_publication_set.publishperiod",
            FT_UINT8, BASE_CUSTOM, CF_FUNC(format_publish_period), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_publication_set_publishperiod_resolution,
            { "Step Resolution", "btmesh.model.config_model_publication_set.publishperiod.resolution",
            FT_UINT8, BASE_DEC, VALS(btmesh_publishperiod_resolution_vals), 0xC0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_publication_set_publishperiod_steps,
            { "Number of Steps", "btmesh.model.config_model_publication_set.publishperiod.steps",
            FT_UINT8, BASE_DEC, NULL, 0x3F,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_publication_set_publishretransmit,
            { "PublishRetransmit", "btmesh.model.config_model_publication_set.publishretransmit",
            FT_UINT8, BASE_CUSTOM, CF_FUNC(format_retransmit), 0x00,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_publication_set_publishretransmit_count,
            { "PublishRetransmitCount", "btmesh.model.config_model_publication_set.publishretransmit.count",
            FT_UINT8, BASE_DEC, NULL, 0x07,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_publication_set_publishretransmit_intervalsteps,
            { "PublishRetransmitIntervalSteps", "btmesh.model.config_model_publication_set.publishretransmit.intervalsteps",
            FT_UINT8, BASE_CUSTOM, CF_FUNC(format_interval_steps), 0xF8,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_publication_set_modelidentifier,
            { "ModelIdentifier", "btmesh.model.config_model_publication_set.modelidentifier",
            FT_UINT16, BASE_HEX, VALS(btmesh_model_vals), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_publication_set_vendormodelidentifier,
            { "ModelIdentifier", "btmesh.model.config_model_publication_set.vendormodelidentifier",
            FT_UINT32, BASE_CUSTOM, CF_FUNC(format_vendor_model), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_health_current_status_test_id,
            { "Test ID", "btmesh.model.health_current_status.test_id",
            FT_UINT8, BASE_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_health_current_status_company_id,
            { "Company ID", "btmesh.model.health_current_status.company_id",
            FT_UINT16, BASE_HEX | BASE_EXT_STRING, &bluetooth_company_id_vals_ext, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_health_current_status_fault,
            { "Fault", "btmesh.model.health_current_status.fault",
            FT_UINT8, BASE_DEC, VALS(btmesh_fault_array_vals), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_health_fault_status_test_id,
            { "Test ID", "btmesh.model.health_fault_status.test_id",
            FT_UINT8, BASE_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_health_fault_status_company_id,
            { "Company ID", "btmesh.model.health_fault_status.company_id",
            FT_UINT16, BASE_HEX | BASE_EXT_STRING, &bluetooth_company_id_vals_ext, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_health_fault_status_fault,
            { "Fault", "btmesh.model.health_fault_status.fault",
            FT_UINT8, BASE_DEC, VALS(btmesh_fault_array_vals), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_heartbeat_publication_status_status,
            { "Status", "btmesh.model.config_heartbeat_publication_status.status",
            FT_UINT8, BASE_DEC, VALS(btmesh_status_code_vals), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_heartbeat_publication_status_destination,
            { "Destination", "btmesh.model.config_heartbeat_publication_status.destination",
            FT_UINT16, BASE_DEC_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_heartbeat_publication_status_countlog,
            { "CountLog", "btmesh.model.config_heartbeat_publication_status.countlog",
            FT_UINT8, BASE_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_heartbeat_publication_status_periodlog,
            { "PeriodLog", "btmesh.model.config_heartbeat_publication_status.periodlog",
            FT_UINT8, BASE_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_heartbeat_publication_status_ttl,
            { "TTL", "btmesh.model.config_heartbeat_publication_status.ttl",
            FT_UINT8, BASE_DEC, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_heartbeat_publication_status_features_relay,
            { "Relay feature change triggers a Heartbeat message", "btmesh.model.config_heartbeat_publication_status.features.relay",
            FT_BOOLEAN, 16, TFS(&tfs_true_false), 0x0001,
            NULL, HFILL }
        },
        { &hf_btmesh_config_heartbeat_publication_status_features_proxy,
            { "Proxy feature change triggers a Heartbeat message", "btmesh.model.config_heartbeat_publication_status.features.proxy",
            FT_BOOLEAN, 16, TFS(&tfs_true_false), 0x0002,
            NULL, HFILL }
        },
        { &hf_btmesh_config_heartbeat_publication_status_features_friend,
            { "Friend feature change triggers a Heartbeat message", "btmesh.model.config_heartbeat_publication_status.features.friend",
            FT_BOOLEAN, 16, TFS(&tfs_true_false), 0x0004,
            NULL, HFILL }
        },
        { &hf_btmesh_config_heartbeat_publication_status_features_low_power,
            { "Low Power feature change triggers a Heartbeat message", "btmesh.model.config_heartbeat_publication_status.features.low_power",
            FT_BOOLEAN, 16, TFS(&tfs_true_false), 0x0008,
            NULL, HFILL }
        },
        { &hf_btmesh_config_heartbeat_publication_status_features_rfu,
            { "RFU", "btmesh.model.config_heartbeat_publication_status.features.rfu",
            FT_UINT16, BASE_HEX, NULL, 0xFFF0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_heartbeat_publication_status_features,
            { "Features", "btmesh.model.config_heartbeat_publication_status.features",
            FT_UINT16, BASE_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_heartbeat_publication_status_netkeyindex,
            { "NetKeyIndex", "btmesh.model.config_heartbeat_publication_status.netkeyindex",
                FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index), 0x0,
                NULL, HFILL }
        },
        { &hf_btmesh_config_heartbeat_publication_status_netkeyindex_idx,
            { "NetKeyIndex", "btmesh.model.config_heartbeat_publication_status.netkeyindex.idx",
                FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index), 0x0FFF,
                NULL, HFILL }
        },
        { &hf_btmesh_config_heartbeat_publication_status_netkeyindex_rfu,
            { "RFU", "btmesh.model.config_heartbeat_publication_status.netkeyindex.rfu",
                FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index_rfu), 0xF000,
                NULL, HFILL }
        },
        { &hf_btmesh_config_appkey_delete_netkeyindexandappkeyindex,
            { "NetKeyIndexAndAppKeyIndex", "btmesh.model.config_appkey_delete.netkeyindexandappkeyindex",
            FT_UINT24, BASE_CUSTOM, CF_FUNC(format_dual_key_index), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_appkey_delete_netkeyindexandappkeyindex_net,
            { "NetKeyIndex", "btmesh.model.config_appkey_delete.netkeyindexandappkeyindex.net",
            FT_UINT24, BASE_CUSTOM, CF_FUNC(format_key_index), 0xFFF,
            NULL, HFILL }
        },
        { &hf_btmesh_config_appkey_delete_netkeyindexandappkeyindex_app,
            { "AppKeyIndex", "btmesh.model.config_appkey_delete.netkeyindexandappkeyindex.app",
            FT_UINT24, BASE_CUSTOM, CF_FUNC(format_key_index), 0xFFF000,
            NULL, HFILL }
        },
        { &hf_btmesh_config_appkey_get_netkeyindex,
            { "NetKeyIndex", "btmesh.model.config_appkey_get.netkeyindex",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_appkey_get_netkeyindex_idx,
            { "NetKeyIndex", "btmesh.model.config_appkey_get.netkeyindex.idx",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index), 0x0FFF,
            NULL, HFILL }
        },
        { &hf_btmesh_config_appkey_get_netkeyindex_rfu,
            { "RFU", "btmesh.model.config_appkey_get.netkeyindex.rfu",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index_rfu), 0xF000,
            NULL, HFILL }
        },
        { &hf_btmesh_config_appkey_list_status,
            { "Status", "btmesh.model.config_appkey_list.status",
            FT_UINT8, BASE_DEC, VALS(btmesh_status_code_vals), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_appkey_list_netkeyindex,
            { "NetKeyIndex", "btmesh.model.config_appkey_list.netkeyindex",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_appkey_list_netkeyindex_idx,
            { "NetKeyIndex", "btmesh.model.config_appkey_list.netkeyindex.idx",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index), 0x0FFF,
            NULL, HFILL }
        },
        { &hf_btmesh_config_appkey_list_netkeyindex_rfu,
            { "RFU", "btmesh.model.config_appkey_list.netkeyindex.rfu",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index_rfu), 0xF000,
            NULL, HFILL }
        },
        { &hf_btmesh_config_appkey_list_appkeyindex,
            { "AppKeyIndex", "btmesh.model.config_appkey_list.appkeyindex",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_appkey_list_appkeyindex_rfu,
            { "RFU", "btmesh.model.config_appkey_list.appkeyindex.rfu",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index_rfu), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_appkey_status_status,
            { "Status", "btmesh.model.config_appkey_status.status",
            FT_UINT8, BASE_DEC, VALS(btmesh_status_code_vals), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_appkey_status_netkeyindexandappkeyindex,
            { "NetKeyIndexAndAppKeyIndex", "btmesh.model.config_appkey_status.netkeyindexandappkeyindex",
            FT_UINT24, BASE_CUSTOM, CF_FUNC(format_dual_key_index), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_appkey_status_netkeyindexandappkeyindex_net,
            { "NetKeyIndex", "btmesh.model.config_appkey_status.netkeyindexandappkeyindex.net",
            FT_UINT24, BASE_CUSTOM, CF_FUNC(format_key_index), 0xFFF,
            NULL, HFILL }
        },
        { &hf_btmesh_config_appkey_status_netkeyindexandappkeyindex_app,
            { "AppKeyIndex", "btmesh.model.config_appkey_status.netkeyindexandappkeyindex.app",
            FT_UINT24, BASE_CUSTOM, CF_FUNC(format_key_index), 0xFFF000,
            NULL, HFILL }
        },
        { &hf_btmesh_health_attention_set_attention,
            { "Attention", "btmesh.model.health_attention_set.attention",
            FT_UINT8, BASE_DEC, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_health_attention_set_unacknowledged_attention,
            { "Attention", "btmesh.model.health_attention_set_unacknowledged.attention",
            FT_UINT8, BASE_DEC, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_health_attention_status_attention,
            { "Attention", "btmesh.model.health_attention_status.attention",
            FT_UINT8, BASE_DEC, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_composition_data_get_page,
            { "Page", "btmesh.model.config_composition_data_get.page",
            FT_UINT8, BASE_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_beacon_set_beacon,
            { "Beacon", "btmesh.model.config_beacon_set.beacon",
            FT_UINT8, BASE_DEC, VALS(btmesh_beacon_broadcast_vals), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_beacon_status_beacon,
            { "Beacon", "btmesh.model.config_beacon_status.beacon",
            FT_UINT8, BASE_DEC, VALS(btmesh_beacon_broadcast_vals), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_default_ttl_set_ttl,
            { "TTL", "btmesh.model.config_default_ttl_set.ttl",
            FT_UINT8, BASE_DEC, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_default_ttl_status_ttl,
            { "TTL", "btmesh.model.config_default_ttl_status.ttl",
            FT_UINT8, BASE_DEC, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_friend_set_friend,
            { "Friend", "btmesh.model.config_friend_set.friend",
            FT_UINT8, BASE_DEC, VALS(btmesh_friend_vals), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_friend_status_friend,
            { "Friend", "btmesh.model.config_friend_status.friend",
            FT_UINT8, BASE_DEC, VALS(btmesh_friend_vals), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_gatt_proxy_set_gattproxy,
            { "GATTProxy", "btmesh.model.config_gatt_proxy_set.gattproxy",
            FT_UINT8, BASE_HEX, VALS(btmesh_gatt_proxy_vals), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_gatt_proxy_status_gattproxy,
            { "GATTProxy", "btmesh.model.config_gatt_proxy_status.gattproxy",
            FT_UINT8, BASE_HEX, VALS(btmesh_gatt_proxy_vals), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_key_refresh_phase_get_netkeyindex,
            { "NetKeyIndex", "btmesh.model.config_key_refresh_phase_get.netkeyindex",
                FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index), 0x0,
                NULL, HFILL }
        },
        { &hf_btmesh_config_key_refresh_phase_get_netkeyindex_idx,
            { "NetKeyIndex", "btmesh.model.config_key_refresh_phase_get.netkeyindex.idx",
                FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index), 0x0FFF,
                NULL, HFILL }
        },
        { &hf_btmesh_config_key_refresh_phase_get_netkeyindex_rfu,
            { "RFU", "btmesh.model.config_key_refresh_phase_get.netkeyindex.rfu",
                FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index_rfu), 0xF000,
                NULL, HFILL }
        },
        { &hf_btmesh_config_key_refresh_phase_set_netkeyindex,
            { "NetKeyIndex", "btmesh.model.config_key_refresh_phase_set.netkeyindex",
                FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index), 0x0,
                NULL, HFILL }
        },
        { &hf_btmesh_config_key_refresh_phase_set_netkeyindex_idx,
            { "NetKeyIndex", "btmesh.model.config_key_refresh_phase_set.netkeyindex.idx",
                FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index), 0x0FFF,
                NULL, HFILL }
        },
        { &hf_btmesh_config_key_refresh_phase_set_netkeyindex_rfu,
            { "RFU", "btmesh.model.config_key_refresh_phase_set.netkeyindex.rfu",
                FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index_rfu), 0xF000,
                NULL, HFILL }
        },
        { &hf_btmesh_config_key_refresh_phase_set_transition,
            { "Transition", "btmesh.model.config_key_refresh_phase_set.transition",
            FT_UINT8, BASE_DEC | BASE_RANGE_STRING, RVALS(btmesh_transition_vals), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_key_refresh_phase_status_status,
            { "Status", "btmesh.model.config_key_refresh_phase_status.status",
            FT_UINT8, BASE_DEC, VALS(btmesh_status_code_vals), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_key_refresh_phase_status_netkeyindex,
            { "NetKeyIndex", "btmesh.model.config_key_refresh_phase_status.netkeyindex",
                FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index), 0x0,
                NULL, HFILL }
        },
        { &hf_btmesh_config_key_refresh_phase_status_netkeyindex_idx,
            { "NetKeyIndex", "btmesh.model.config_key_refresh_phase_status.netkeyindex.idx",
                FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index), 0x0FFF,
                NULL, HFILL }
        },
        { &hf_btmesh_config_key_refresh_phase_status_netkeyindex_rfu,
            { "RFU", "btmesh.model.config_key_refresh_phase_status.netkeyindex.rfu",
                FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index_rfu), 0xF000,
                NULL, HFILL }
        },
        { &hf_btmesh_config_key_refresh_phase_status_phase,
            { "Phase", "btmesh.model.config_key_refresh_phase_status.phase",
            FT_UINT8, BASE_DEC, VALS(btmesh_phase_vals), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_publication_get_elementaddress,
            { "ElementAddress", "btmesh.model.config_model_publication_get.elementaddress",
            FT_UINT16, BASE_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_publication_get_modelidentifier,
            { "ModelIdentifier", "btmesh.model.config_model_publication_get.modelidentifier",
            FT_UINT16, BASE_HEX, VALS(btmesh_model_vals), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_publication_get_vendormodelidentifier,
            { "ModelIdentifier", "btmesh.model.config_model_publication_get.vendormodelidentifier",
            FT_UINT32, BASE_CUSTOM, CF_FUNC(format_vendor_model), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_publication_status_status,
            { "Status", "btmesh.model.config_model_publication_status.status",
            FT_UINT8, BASE_DEC, VALS(btmesh_status_code_vals), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_publication_status_elementaddress,
            { "ElementAddress", "btmesh.model.config_model_publication_status.elementaddress",
            FT_UINT16, BASE_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_publication_status_publishaddress,
            { "PublishAddress", "btmesh.model.config_model_publication_status.publishaddress",
            FT_UINT16, BASE_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_publication_status_appkey,
            { "AppKeyIndex", "btmesh.model.config_model_publication_status.appkey",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_publish_appkeyindex_model), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_publication_status_appkeyindex,
            { "AppKeyIndex", "btmesh.model.config_model_publication_status.appkeyindex",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index), 0x0FFF,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_publication_status_credentialflag,
            { "CredentialFlag", "btmesh.model.config_model_publication_status.credentialflag",
            FT_UINT16, BASE_DEC, VALS(btmesh_friendship_credentials_flag_vals), 0x1000,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_publication_status_rfu,
            { "RFU", "btmesh.model.config_model_publication_status.rfu",
            FT_UINT16, BASE_HEX, NULL, 0xE000,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_publication_status_publishttl,
            { "PublishTTL", "btmesh.model.config_model_publication_status.publishttl",
            FT_UINT8, BASE_DEC, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_publication_status_publishperiod,
            { "PublishPeriod", "btmesh.model.config_model_publication_status.publishperiod",
            FT_UINT8, BASE_CUSTOM, CF_FUNC(format_publish_period), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_publication_status_publishperiod_resolution,
            { "Step Resolution", "btmesh.model.config_model_publication_status.publishperiod.resolution",
            FT_UINT8, BASE_DEC, VALS(btmesh_publishperiod_resolution_vals), 0xC0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_publication_status_publishperiod_steps,
            { "Number of Steps", "btmesh.model.config_model_publication_status.publishperiod.steps",
            FT_UINT8, BASE_DEC, NULL, 0x3F,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_publication_status_publishretransmit,
            { "PublishRetransmit", "btmesh.model.config_model_publication_status.publishretransmit",
            FT_UINT8, BASE_CUSTOM, CF_FUNC(format_retransmit), 0x00,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_publication_status_publishretransmit_count,
            { "PublishRetransmitCount", "btmesh.model.config_model_publication_status.publishretransmit.count",
            FT_UINT8, BASE_DEC, NULL, 0x07,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_publication_status_publishretransmit_intervalsteps,
            { "PublishRetransmitIntervalSteps", "btmesh.model.config_model_publication_status.publishretransmit.intervalsteps",
            FT_UINT8, BASE_CUSTOM, CF_FUNC(format_interval_steps), 0xF8,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_publication_status_modelidentifier,
            { "ModelIdentifier", "btmesh.model.config_model_publication_status.modelidentifier",
            FT_UINT16, BASE_HEX, VALS(btmesh_model_vals), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_publication_status_vendormodelidentifier,
            { "ModelIdentifier", "btmesh.model.config_model_publication_status.vendormodelidentifier",
            FT_UINT32, BASE_CUSTOM, CF_FUNC(format_vendor_model), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_publication_virtual_address_set_elementaddress,
            { "ElementAddress", "btmesh.model.config_model_publication_virtual_address_set.elementaddress",
            FT_UINT16, BASE_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_publication_virtual_address_set_publishaddress,
            { "PublishAddress", "btmesh.model.config_model_publication_virtual_address_set.publishaddress",
            FT_BYTES, BASE_NONE, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_publication_virtual_address_set_appkey,
            { "AppKeyIndex", "btmesh.model.config_model_publication_virtual_address_set.appkey",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_publish_appkeyindex_model), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_publication_virtual_address_set_appkeyindex,
            { "AppKeyIndex", "btmesh.model.config_model_publication_virtual_address_set.appkeyindex",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index), 0x0FFF,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_publication_virtual_address_set_credentialflag,
            { "CredentialFlag", "btmesh.model.config_model_publication_virtual_address_set.credentialflag",
            FT_UINT16, BASE_DEC, VALS(btmesh_friendship_credentials_flag_vals), 0x1000,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_publication_virtual_address_set_rfu,
            { "RFU", "btmesh.model.config_model_publication_virtual_address_set.rfu",
            FT_UINT16, BASE_HEX, NULL, 0xE000,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_publication_virtual_address_set_publishttl,
            { "PublishTTL", "btmesh.model.config_model_publication_virtual_address_set.publishttl",
            FT_UINT8, BASE_DEC, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_publication_virtual_address_set_publishperiod,
            { "PublishPeriod", "btmesh.model.config_model_publication_virtual_address_set.publishperiod",
            FT_UINT8, BASE_CUSTOM, CF_FUNC(format_publish_period), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_publication_virtual_address_set_publishperiod_resolution,
            { "Step Resolution", "btmesh.model.config_model_publication_virtual_address_set.publishperiod.resolution",
            FT_UINT8, BASE_DEC, VALS(btmesh_publishperiod_resolution_vals), 0xC0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_publication_virtual_address_set_publishperiod_steps,
            { "Number of Steps", "btmesh.model.config_model_publication_virtual_address_set.publishperiod.steps",
            FT_UINT8, BASE_DEC, NULL, 0x3F,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_publication_virtual_address_set_publishretransmit,
            { "PublishRetransmit", "btmesh.model.config_model_publication_virtual_address_set.publishretransmit",
            FT_UINT8, BASE_CUSTOM, CF_FUNC(format_retransmit), 0x00,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_publication_virtual_address_set_publishretransmit_count,
            { "PublishRetransmitCount", "btmesh.model.config_model_publication_virtual_address_set.publishretransmit.count",
            FT_UINT8, BASE_DEC, NULL, 0x07,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_publication_virtual_address_set_publishretransmit_intervalsteps,
            { "PublishRetransmitIntervalSteps", "btmesh.model.config_model_publication_virtual_address_set.publishretransmit.intervalsteps",
            FT_UINT8, BASE_CUSTOM, CF_FUNC(format_interval_steps), 0xF8,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_publication_virtual_address_set_vendormodelidentifier,
            { "ModelIdentifier", "btmesh.model.config_model_publication_virtual_address_set.vendormodelidentifier",
            FT_UINT32, BASE_CUSTOM, CF_FUNC(format_vendor_model), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_publication_virtual_address_set_modelidentifier,
            { "ModelIdentifier", "btmesh.model.config_model_publication_virtual_address_set.modelidentifier",
            FT_UINT16, BASE_HEX, VALS(btmesh_model_vals), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_subscription_add_elementaddress,
            { "ElementAddress", "btmesh.model.config_model_subscription_add.elementaddress",
            FT_UINT16, BASE_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_subscription_add_address,
            { "Address", "btmesh.model.config_model_subscription_add.address",
            FT_UINT16, BASE_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_subscription_add_modelidentifier,
            { "ModelIdentifier", "btmesh.model.config_model_subscription_add.modelidentifier",
            FT_UINT16, BASE_HEX, VALS(btmesh_model_vals), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_subscription_add_vendormodelidentifier,
            { "ModelIdentifier", "btmesh.model.config_model_subscription_add.vendormodelidentifier",
            FT_UINT32, BASE_CUSTOM, CF_FUNC(format_vendor_model), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_subscription_delete_elementaddress,
            { "ElementAddress", "btmesh.model.config_model_subscription_delete.elementaddress",
            FT_UINT16, BASE_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_subscription_delete_address,
            { "Address", "btmesh.model.config_model_subscription_delete.address",
            FT_UINT16, BASE_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_subscription_delete_modelidentifier,
            { "ModelIdentifier", "btmesh.model.config_model_subscription_delete.modelidentifier",
            FT_UINT16, BASE_HEX, VALS(btmesh_model_vals), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_subscription_delete_vendormodelidentifier,
            { "ModelIdentifier", "btmesh.model.config_model_subscription_delete.vendormodelidentifier",
            FT_UINT32, BASE_CUSTOM, CF_FUNC(format_vendor_model), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_subscription_delete_all_elementaddress,
            { "ElementAddress", "btmesh.model.config_model_subscription_delete_all.elementaddress",
            FT_UINT16, BASE_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_subscription_delete_all_modelidentifier,
            { "ModelIdentifier", "btmesh.model.config_model_subscription_delete_all.modelidentifier",
            FT_UINT16, BASE_HEX, VALS(btmesh_model_vals), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_subscription_delete_all_vendormodelidentifier,
            { "ModelIdentifier", "btmesh.model.config_model_subscription_delete_all.vendormodelidentifier",
            FT_UINT32, BASE_CUSTOM, CF_FUNC(format_vendor_model), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_subscription_overwrite_elementaddress,
            { "ElementAddress", "btmesh.model.config_model_subscription_overwrite.elementaddress",
            FT_UINT16, BASE_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_subscription_overwrite_address,
            { "Address", "btmesh.model.config_model_subscription_overwrite.address",
            FT_UINT16, BASE_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_subscription_overwrite_modelidentifier,
            { "ModelIdentifier", "btmesh.model.config_model_subscription_overwrite.modelidentifier",
            FT_UINT16, BASE_HEX, VALS(btmesh_model_vals), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_subscription_overwrite_vendormodelidentifier,
            { "ModelIdentifier", "btmesh.model.config_model_subscription_overwrite.vendormodelidentifier",
            FT_UINT32, BASE_CUSTOM, CF_FUNC(format_vendor_model), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_subscription_status_status,
            { "Status", "btmesh.model.config_model_subscription_status.status",
            FT_UINT8, BASE_DEC, VALS(btmesh_status_code_vals), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_subscription_status_elementaddress,
            { "ElementAddress", "btmesh.model.config_model_subscription_status.elementaddress",
            FT_UINT16, BASE_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_subscription_status_address,
            { "Address", "btmesh.model.config_model_subscription_status.address",
            FT_UINT16, BASE_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_subscription_status_modelidentifier,
            { "ModelIdentifier", "btmesh.model.config_model_subscription_status.modelidentifier",
            FT_UINT16, BASE_HEX, VALS(btmesh_model_vals), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_subscription_status_vendormodelidentifier,
            { "ModelIdentifier", "btmesh.model.config_model_subscription_status.vendormodelidentifier",
            FT_UINT32, BASE_CUSTOM, CF_FUNC(format_vendor_model), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_subscription_virtual_address_add_elementaddress,
            { "ElementAddress", "btmesh.model.config_model_subscription_virtual_address_add.elementaddress",
            FT_UINT16, BASE_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_subscription_virtual_address_add_label,
            { "Label", "btmesh.model.config_model_subscription_virtual_address_add.label",
            FT_BYTES, BASE_NONE, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_subscription_virtual_address_add_modelidentifier,
            { "ModelIdentifier", "btmesh.model.config_model_subscription_virtual_address_add.modelidentifier",
            FT_UINT16, BASE_HEX, VALS(btmesh_model_vals), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_subscription_virtual_address_add_vendormodelidentifier,
            { "ModelIdentifier", "btmesh.model.config_model_subscription_virtual_address_add.vendormodelidentifier",
            FT_UINT32, BASE_CUSTOM, CF_FUNC(format_vendor_model), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_subscription_virtual_address_delete_elementaddress,
            { "ElementAddress", "btmesh.model.config_model_subscription_virtual_address_delete.elementaddress",
            FT_UINT16, BASE_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_subscription_virtual_address_delete_label,
            { "Label", "btmesh.model.config_model_subscription_virtual_address_delete.label",
            FT_BYTES, BASE_NONE, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_subscription_virtual_address_delete_modelidentifier,
            { "ModelIdentifier", "btmesh.model.config_model_subscription_virtual_address_delete.modelidentifier",
            FT_UINT16, BASE_HEX, VALS(btmesh_model_vals), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_subscription_virtual_address_delete_vendormodelidentifier,
            { "ModelIdentifier", "btmesh.model.config_model_subscription_virtual_address_delete.vendormodelidentifier",
            FT_UINT32, BASE_CUSTOM, CF_FUNC(format_vendor_model), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_subscription_virtual_address_overwrite_elementaddress,
            { "ElementAddress", "btmesh.model.config_model_subscription_virtual_address_overwrite.elementaddress",
            FT_UINT16, BASE_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_subscription_virtual_address_overwrite_label,
            { "Label", "btmesh.model.config_model_subscription_virtual_address_overwrite.label",
            FT_BYTES, BASE_NONE, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_subscription_virtual_address_overwrite_modelidentifier,
            { "ModelIdentifier", "btmesh.model.config_model_subscription_virtual_address_overwrite.modelidentifier",
            FT_UINT16, BASE_HEX, VALS(btmesh_model_vals), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_subscription_virtual_address_overwrite_vendormodelidentifier,
            { "ModelIdentifier", "btmesh.model.config_model_subscription_virtual_address_overwrite.vendormodelidentifier",
            FT_UINT32, BASE_CUSTOM, CF_FUNC(format_vendor_model), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_network_transmit_set_networktransmit,
            { "NetworkTransmitCount", "btmesh.model.config_network_transmit_set.networktransmit",
            FT_UINT8, BASE_CUSTOM, CF_FUNC(format_transmit), 0x00,
            NULL, HFILL }
        },
        { &hf_btmesh_config_network_transmit_set_networktransmit_count,
            { "NetworkTransmitCount", "btmesh.model.config_network_transmit_set.networktransmit.count",
            FT_UINT8, BASE_DEC, NULL, 0x07,
            NULL, HFILL }
        },
        { &hf_btmesh_config_network_transmit_set_networktransmit_intervalsteps,
            { "NetworkTransmitIntervalSteps", "btmesh.model.config_network_transmit_set.networktransmitinterval.steps",
            FT_UINT8, BASE_CUSTOM, CF_FUNC(format_interval_steps), 0xF8,
            NULL, HFILL }
        },
        { &hf_btmesh_config_network_transmit_status_networktransmit,
            { "NetworkTransmitCount", "btmesh.model.config_network_transmit_status.networktransmit",
            FT_UINT8, BASE_CUSTOM, CF_FUNC(format_transmit), 0x00,
            NULL, HFILL }
        },
        { &hf_btmesh_config_network_transmit_status_networktransmit_count,
            { "NetworkTransmitCount", "btmesh.model.config_network_transmit_status.networktransmit.count",
            FT_UINT8, BASE_DEC, NULL, 0x07,
            NULL, HFILL }
        },
        { &hf_btmesh_config_network_transmit_status_networktransmit_intervalsteps,
            { "NetworkTransmitIntervalSteps", "btmesh.model.config_network_transmit_status.networktransmit.intervalsteps",
            FT_UINT8, BASE_CUSTOM, CF_FUNC(format_interval_steps), 0xF8,
            NULL, HFILL }
        },
        { &hf_btmesh_config_relay_set_relay,
            { "Relay", "btmesh.model.config_relay_set.relay",
            FT_UINT8, BASE_DEC, VALS(btmesh_relay_vals), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_relay_set_relayretransmit,
            { "RelayRetransmitCount", "btmesh.model.config_relay_set.relayretransmit",
            FT_UINT8, BASE_CUSTOM, CF_FUNC(format_retransmit), 0x00,
            NULL, HFILL }
        },
        { &hf_btmesh_config_relay_set_relayretransmit_count,
            { "RelayRetransmitCount", "btmesh.model.config_relay_set.relayretransmit.count",
            FT_UINT8, BASE_DEC, NULL, 0x07,
            NULL, HFILL }
        },
        { &hf_btmesh_config_relay_set_relayretransmit_intervalsteps,
            { "RelayRetransmitIntervalSteps", "btmesh.model.config_relay_set.relayretransmit.intervalsteps",
            FT_UINT8, BASE_CUSTOM, CF_FUNC(format_interval_steps), 0xF8,
            NULL, HFILL }
        },
        { &hf_btmesh_config_relay_status_relay,
            { "Relay", "btmesh.model.config_relay_status.relay",
            FT_UINT8, BASE_DEC, VALS(btmesh_relay_vals), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_relay_status_relayretransmit,
            { "RelayRetransmit", "btmesh.model.config_relay_status.relayretransmit",
            FT_UINT8, BASE_CUSTOM, CF_FUNC(format_retransmit), 0x00,
            NULL, HFILL }
        },
        { &hf_btmesh_config_relay_status_relayretransmit_count,
            { "RelayRetransmitCount", "btmesh.model.config_relay_status.relayretransmit.count",
            FT_UINT8, BASE_DEC, NULL, 0x07,
            NULL, HFILL }
        },
        { &hf_btmesh_config_relay_status_relayretransmit_intervalsteps,
            { "RelayRetransmitIntervalSteps", "btmesh.model.config_relay_status.relayretransmit.intervalsteps",
            FT_UINT8, BASE_CUSTOM, CF_FUNC(format_interval_steps), 0xF8,
            NULL, HFILL }
        },
        { &hf_btmesh_config_sig_model_subscription_get_elementaddress,
            { "ElementAddress", "btmesh.model.config_sig_model_subscription_get.elementaddress",
            FT_UINT16, BASE_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_sig_model_subscription_get_modelidentifier,
            { "ModelIdentifier", "btmesh.model.config_sig_model_subscription_get.modelidentifier",
            FT_UINT16, BASE_HEX, VALS(btmesh_model_vals), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_sig_model_subscription_list_status,
            { "Status", "btmesh.model.config_sig_model_subscription_list.status",
            FT_UINT8, BASE_DEC, VALS(btmesh_status_code_vals), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_sig_model_subscription_list_elementaddress,
            { "ElementAddress", "btmesh.model.config_sig_model_subscription_list.elementaddress",
            FT_UINT16, BASE_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_sig_model_subscription_list_modelidentifier,
            { "ModelIdentifier", "btmesh.model.config_sig_model_subscription_list.modelidentifier",
            FT_UINT16, BASE_HEX, VALS(btmesh_model_vals), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_sig_model_subscription_list_address,
            { "Address", "btmesh.model.config_sig_model_subscription_list.address",
            FT_UINT16, BASE_DEC_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_vendor_model_subscription_get_elementaddress,
            { "ElementAddress", "btmesh.model.config_vendor_model_subscription_get.elementaddress",
            FT_UINT16, BASE_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_vendor_model_subscription_get_modelidentifier,
            { "ModelIdentifier", "btmesh.model.config_vendor_model_subscription_get.modelidentifier",
            FT_UINT32, BASE_CUSTOM, CF_FUNC(format_vendor_model), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_vendor_model_subscription_list_status,
            { "Status", "btmesh.model.config_vendor_model_subscription_list.status",
            FT_UINT8, BASE_DEC, VALS(btmesh_status_code_vals), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_vendor_model_subscription_list_elementaddress,
            { "ElementAddress", "btmesh.model.config_vendor_model_subscription_list.elementaddress",
            FT_UINT16, BASE_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_vendor_model_subscription_list_modelidentifier,
            { "ModelIdentifier", "btmesh.model.config_vendor_model_subscription_list.modelidentifier",
            FT_UINT32, BASE_CUSTOM, CF_FUNC(format_vendor_model), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_vendor_model_subscription_list_address,
            { "Address", "btmesh.model.config_vendor_model_subscription_list.address",
            FT_UINT16, BASE_DEC_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_low_power_node_polltimeout_get_lpnaddress,
            { "LPNAddress", "btmesh.model.config_low_power_node_polltimeout_get.lpnaddress",
            FT_UINT16, BASE_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_low_power_node_polltimeout_status_lpnaddress,
            { "LPNAddress", "btmesh.model.config_low_power_node_polltimeout_status.lpnaddress",
            FT_UINT16, BASE_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_low_power_node_polltimeout_status_polltimeout,
            { "PollTimeout", "btmesh.model.config_low_power_node_polltimeout_status.polltimeout",
            FT_UINT24, BASE_DEC, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_health_fault_clear_company_id,
            { "Company ID", "btmesh.model.health_fault_clear.company_id",
            FT_UINT16, BASE_HEX | BASE_EXT_STRING, &bluetooth_company_id_vals_ext, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_health_fault_clear_unacknowledged_company_id,
            { "Company ID", "btmesh.model.health_fault_clear_unacknowledged.company_id",
            FT_UINT16, BASE_HEX | BASE_EXT_STRING, &bluetooth_company_id_vals_ext, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_health_fault_get_company_id,
            { "Company ID", "btmesh.model.health_fault_get.company_id",
            FT_UINT16, BASE_HEX | BASE_EXT_STRING, &bluetooth_company_id_vals_ext, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_health_fault_test_test_id,
            { "Test ID", "btmesh.model.health_fault_test.test_id",
            FT_UINT8, BASE_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_health_fault_test_company_id,
            { "Company ID", "btmesh.model.health_fault_test.company_id",
            FT_UINT16, BASE_HEX | BASE_EXT_STRING, &bluetooth_company_id_vals_ext, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_health_fault_test_unacknowledged_test_id,
            { "Test ID", "btmesh.model.health_fault_test_unacknowledged.test_id",
            FT_UINT8, BASE_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_health_fault_test_unacknowledged_company_id,
            { "Company ID", "btmesh.model.health_fault_test_unacknowledged.company_id",
            FT_UINT16, BASE_HEX | BASE_EXT_STRING, &bluetooth_company_id_vals_ext, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_health_period_set_fastperioddivisor,
            { "FastPeriodDivisor", "btmesh.model.health_period_set.fastperioddivisor",
            FT_UINT8, BASE_DEC, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_health_period_set_unacknowledged_fastperioddivisor,
            { "FastPeriodDivisor", "btmesh.model.health_period_set_unacknowledged.fastperioddivisor",
            FT_UINT8, BASE_DEC, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_health_period_status_fastperioddivisor,
            { "FastPeriodDivisor", "btmesh.model.health_period_status.fastperioddivisor",
            FT_UINT8, BASE_DEC, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_heartbeat_publication_set_destination,
            { "Destination", "btmesh.model.config_heartbeat_publication_set.destination",
            FT_UINT16, BASE_DEC_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_heartbeat_publication_set_countlog,
            { "CountLog", "btmesh.model.config_heartbeat_publication_set.countlog",
            FT_UINT8, BASE_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_heartbeat_publication_set_periodlog,
            { "PeriodLog", "btmesh.model.config_heartbeat_publication_set.periodlog",
            FT_UINT8, BASE_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_heartbeat_publication_set_ttl,
            { "TTL", "btmesh.model.config_heartbeat_publication_set.ttl",
            FT_UINT8, BASE_DEC, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_heartbeat_publication_set_features_relay,
            { "Relay feature change triggers a Heartbeat message", "btmesh.model.config_heartbeat_publication_set.features.relay",
            FT_BOOLEAN, 16, TFS(&tfs_true_false), 0x0001,
            NULL, HFILL }
        },
        { &hf_btmesh_config_heartbeat_publication_set_features_proxy,
            { "Proxy feature change triggers a Heartbeat message", "btmesh.model.config_heartbeat_publication_set.features.proxy",
            FT_BOOLEAN, 16, TFS(&tfs_true_false), 0x0002,
            NULL, HFILL }
        },
        { &hf_btmesh_config_heartbeat_publication_set_features_friend,
            { "Friend feature change triggers a Heartbeat message", "btmesh.model.config_heartbeat_publication_set.features.friend",
            FT_BOOLEAN, 16, TFS(&tfs_true_false), 0x0004,
            NULL, HFILL }
        },
        { &hf_btmesh_config_heartbeat_publication_set_features_low_power,
            { "Low Power feature change triggers a Heartbeat message", "btmesh.model.config_heartbeat_publication_set.features.low_power",
            FT_BOOLEAN, 16, TFS(&tfs_true_false), 0x0008,
            NULL, HFILL }
        },
        { &hf_btmesh_config_heartbeat_publication_set_features_rfu,
            { "RFU", "btmesh.model.config_heartbeat_publication_set.features.rfu",
            FT_UINT16, BASE_HEX, NULL, 0xFFF0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_heartbeat_publication_set_features,
            { "Features", "btmesh.model.config_heartbeat_publication_set.features",
            FT_UINT16, BASE_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_heartbeat_publication_set_netkeyindex,
            { "NetKeyIndex", "btmesh.model.config_heartbeat_publication_set.netkeyindex",
                FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index), 0x0,
                NULL, HFILL }
        },
        { &hf_btmesh_config_heartbeat_publication_set_netkeyindex_idx,
            { "NetKeyIndex", "btmesh.model.config_heartbeat_publication_set.netkeyindex.idx",
                FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index), 0x0FFF,
                NULL, HFILL }
        },
        { &hf_btmesh_config_heartbeat_publication_set_netkeyindex_rfu,
            { "RFU", "btmesh.model.config_heartbeat_publication_set.netkeyindex.rfu",
                FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index_rfu), 0xF000,
                NULL, HFILL }
        },
        { &hf_btmesh_config_heartbeat_subscription_set_source,
            { "Source", "btmesh.model.config_heartbeat_subscription_set.source",
            FT_UINT16, BASE_DEC_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_heartbeat_subscription_set_destination,
            { "Destination", "btmesh.model.config_heartbeat_subscription_set.destination",
            FT_UINT16, BASE_DEC_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_heartbeat_subscription_set_periodlog,
            { "PeriodLog", "btmesh.model.config_heartbeat_subscription_set.periodlog",
            FT_UINT8, BASE_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_heartbeat_subscription_status_status,
            { "Status", "btmesh.model.config_heartbeat_subscription_status.status",
            FT_UINT8, BASE_DEC, VALS(btmesh_status_code_vals), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_heartbeat_subscription_status_source,
            { "Source", "btmesh.model.config_heartbeat_subscription_status.source",
            FT_UINT16, BASE_DEC_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_heartbeat_subscription_status_destination,
            { "Destination", "btmesh.model.config_heartbeat_subscription_status.destination",
            FT_UINT16, BASE_DEC_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_heartbeat_subscription_status_periodlog,
            { "PeriodLog", "btmesh.model.config_heartbeat_subscription_status.periodlog",
            FT_UINT8, BASE_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_heartbeat_subscription_status_countlog,
            { "CountLog", "btmesh.model.config_heartbeat_subscription_status.countlog",
            FT_UINT8, BASE_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_heartbeat_subscription_status_minhops,
            { "MinHops", "btmesh.model.config_heartbeat_subscription_status.minhops",
            FT_UINT8, BASE_DEC, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_heartbeat_subscription_status_maxhops,
            { "MaxHops", "btmesh.model.config_heartbeat_subscription_status.maxhops",
            FT_UINT8, BASE_DEC, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_app_bind_elementaddress,
            { "ElementAddress", "btmesh.model.config_model_app_bind.elementaddress",
            FT_UINT16, BASE_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_app_bind_appkeyindex,
            { "AppKeyIndex", "btmesh.model.config_model_app_bind.appkeyindex",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_app_bind_appkeyindex_idx,
            { "AppKeyIndex", "btmesh.model.config_model_app_bind.appkeyindex.idx",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index), 0x0FFF,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_app_bind_appkeyindex_rfu,
            { "RFU", "btmesh.model.config_model_app_bind.appkeyindex.rfu",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index_rfu), 0xF000,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_app_bind_modelidentifier,
            { "ModelIdentifier", "btmesh.model.config_model_app_bind.modelidentifier",
            FT_UINT16, BASE_HEX, VALS(btmesh_model_vals), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_app_bind_vendormodelidentifier,
            { "ModelIdentifier", "btmesh.model.config_model_app_bind.vendormodelidentifier",
            FT_UINT32, BASE_CUSTOM, CF_FUNC(format_vendor_model), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_app_status_status,
            { "Status", "btmesh.model.config_model_app_status.status",
            FT_UINT8, BASE_DEC, VALS(btmesh_status_code_vals), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_app_status_elementaddress,
            { "ElementAddress", "btmesh.model.config_model_app_status.elementaddress",
            FT_UINT16, BASE_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_app_status_appkeyindex,
            { "AppKeyIndex", "btmesh.model.config_model_app_status.appkeyindex",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_app_status_appkeyindex_idx,
            { "AppKeyIndex", "btmesh.model.config_model_app_status.appkeyindex.idx",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index), 0x0FFF,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_app_status_appkeyindex_rfu,
            { "RFU", "btmesh.model.config_model_app_status.appkeyindex.rfu",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index_rfu), 0xF000,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_app_status_modelidentifier,
            { "ModelIdentifier", "btmesh.model.config_model_app_status.modelidentifier",
            FT_UINT16, BASE_HEX, VALS(btmesh_model_vals), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_app_status_vendormodelidentifier,
            { "ModelIdentifier", "btmesh.model.config_model_app_status.vendormodelidentifier",
            FT_UINT32, BASE_CUSTOM, CF_FUNC(format_vendor_model), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_app_unbind_elementaddress,
            { "ElementAddress", "btmesh.model.config_model_app_unbind.elementaddress",
            FT_UINT16, BASE_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_app_unbind_appkeyindex,
            { "AppKeyIndex", "btmesh.model.config_model_app_unbind.appkeyindex",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_app_unbind_appkeyindex_idx,
            { "AppKeyIndex", "btmesh.model.config_model_app_unbind.appkeyindex.idx",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index), 0x0FFF,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_app_unbind_appkeyindex_rfu,
            { "AppKeyIndex", "btmesh.model.config_model_app_unbind.appkeyindex.rfu",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index_rfu), 0xF000,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_app_unbind_modelidentifier,
            { "ModelIdentifier", "btmesh.model.config_model_app_unbind.modelidentifier",
            FT_UINT16, BASE_HEX, VALS(btmesh_model_vals), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_model_app_unbind_vendormodelidentifier,
            { "ModelIdentifier", "btmesh.model.config_model_app_unbind.vendormodelidentifier",
            FT_UINT32, BASE_CUSTOM, CF_FUNC(format_vendor_model), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_netkey_add_netkeyindex,
            { "NetKeyIndex", "btmesh.model.config_netkey_add.netkeyindex",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_netkey_add_netkeyindex_idx,
            { "NetKeyIndex", "btmesh.model.config_netkey_add.netkeyindex.idx",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index), 0x0FFF,
            NULL, HFILL }
        },
        { &hf_btmesh_config_netkey_add_netkeyindex_rfu,
            { "RFU", "btmesh.model.config_netkey_add.netkeyindex.rfu",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index_rfu), 0xF000,
            NULL, HFILL }
        },
        { &hf_btmesh_config_netkey_add_netkey,
            { "NetKey", "btmesh.model.config_netkey_add.netkey",
            FT_BYTES, BASE_NONE, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_netkey_delete_netkeyindex,
            { "NetKeyIndex", "btmesh.model.config_netkey_delete.netkeyindex",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_netkey_delete_netkeyindex_idx,
            { "NetKeyIndex", "btmesh.model.config_netkey_delete.netkeyindex.idx",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index), 0x0FFF,
            NULL, HFILL }
        },
        { &hf_btmesh_config_netkey_delete_netkeyindex_rfu,
            { "RFU", "btmesh.model.config_netkey_delete.netkeyindex.rfu",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index_rfu), 0xF000,
            NULL, HFILL }
        },
        { &hf_btmesh_config_netkey_list_netkeyindex,
            { "NetKeyIndex", "btmesh.model.config_netkey_list.netkeyindex",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_netkey_list_netkeyindex_rfu,
            { "NetKeyIndex RFU", "btmesh.model.config_netkey_list.netkeyindex.rfu",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index_rfu), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_netkey_status_status,
            { "Status", "btmesh.model.config_netkey_status.status",
            FT_UINT8, BASE_DEC, VALS(btmesh_status_code_vals), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_netkey_status_netkeyindex,
            { "NetKeyIndex", "btmesh.model.config_netkey_status.netkeyindex",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_netkey_status_netkeyindex_idx,
            { "NetKeyIndex", "btmesh.model.config_netkey_status.netkeyindex.idx",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index), 0x0FFF,
            NULL, HFILL }
        },
        { &hf_btmesh_config_netkey_status_netkeyindex_rfu,
            { "RFU", "btmesh.model.config_netkey_status.netkeyindex.rfu",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index_rfu), 0xF000,
            NULL, HFILL }
        },
        { &hf_btmesh_config_netkey_update_netkeyindex,
            { "NetKeyIndex", "btmesh.model.config_netkey_update.netkeyindex",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_netkey_update_netkeyindex_idx,
            { "NetKeyIndex", "btmesh.model.config_netkey_update.netkeyindex.idx",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index), 0x0FFF,
            NULL, HFILL }
        },
        { &hf_btmesh_config_netkey_update_netkeyindex_rfu,
            { "RFU", "btmesh.model.config_netkey_update.netkeyindex.rfu",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index_rfu), 0xF000,
            NULL, HFILL }
        },
        { &hf_btmesh_config_netkey_update_netkey,
            { "NetKey", "btmesh.model.config_netkey_update.netkey",
            FT_BYTES, BASE_NONE, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_node_identity_get_netkeyindex,
            { "NetKeyIndex", "btmesh.model.config_node_identity_get.netkeyindex",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_node_identity_get_netkeyindex_idx,
            { "NetKeyIndex", "btmesh.model.config_node_identity_get.netkeyindex.idx",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index), 0x0FFF,
            NULL, HFILL }
        },
        { &hf_btmesh_config_node_identity_get_netkeyindex_rfu,
            { "RFU", "btmesh.model.config_node_identity_get.netkeyindex.rfu",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index_rfu), 0xF000,
            NULL, HFILL }
        },
        { &hf_btmesh_config_node_identity_set_netkeyindex,
            { "NetKeyIndex", "btmesh.model.config_node_identity_set.netkeyindex",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_node_identity_set_netkeyindex_idx,
            { "NetKeyIndex", "btmesh.model.config_node_identity_set.netkeyindex.idx",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index), 0x0FFF,
            NULL, HFILL }
        },
        { &hf_btmesh_config_node_identity_set_netkeyindex_rfu,
            { "RFU", "btmesh.model.config_node_identity_set.netkeyindex.rfu",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index_rfu), 0xF000,
            NULL, HFILL }
        },
        { &hf_btmesh_config_node_identity_set_identity,
            { "Identity", "btmesh.model.config_node_identity_set.identity",
            FT_UINT8, BASE_DEC, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_node_identity_status_status,
            { "Status", "btmesh.model.config_node_identity_status.status",
            FT_UINT8, BASE_DEC, VALS(btmesh_status_code_vals), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_node_identity_status_netkeyindex,
            { "NetKeyIndex", "btmesh.model.config_node_identity_status.netkeyindex",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_node_identity_status_netkeyindex_idx,
            { "NetKeyIndex", "btmesh.model.config_node_identity_status.netkeyindex.idx",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index), 0x0FFF,
            NULL, HFILL }
        },
        { &hf_btmesh_config_node_identity_status_netkeyindex_rfu,
            { "RFU", "btmesh.model.config_node_identity_status.netkeyindex.rfu",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index_rfu), 0xF000,
            NULL, HFILL }
        },
        { &hf_btmesh_config_node_identity_status_identity,
            { "Identity", "btmesh.model.config_node_identity_status.identity",
            FT_UINT8, BASE_DEC, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_sig_model_app_get_elementaddress,
            { "ElementAddress", "btmesh.model.config_sig_model_app_get.elementaddress",
            FT_UINT16, BASE_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_sig_model_app_get_modelidentifier,
            { "ModelIdentifier", "btmesh.model.config_sig_model_app_get.modelidentifier",
            FT_UINT16, BASE_HEX, VALS(btmesh_model_vals), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_sig_model_app_list_status,
            { "Status", "btmesh.model.config_sig_model_app_list.status",
            FT_UINT8, BASE_DEC, VALS(btmesh_status_code_vals), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_sig_model_app_list_elementaddress,
            { "ElementAddress", "btmesh.model.config_sig_model_app_list.elementaddress",
            FT_UINT16, BASE_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_sig_model_app_list_modelidentifier,
            { "ModelIdentifier", "btmesh.model.config_sig_model_app_list.modelidentifier",
            FT_UINT16, BASE_HEX, VALS(btmesh_model_vals), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_sig_model_app_list_appkeyindex,
            { "AppKeyIndex", "btmesh.model.config_sig_model_app_list.appkeyindex",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_sig_model_app_list_appkeyindex_rfu,
            { "RFU", "btmesh.model.config_sig_model_app_list.appkeyindex.rfu",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index_rfu), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_vendor_model_app_get_elementaddress,
            { "ElementAddress", "btmesh.model.config_vendor_model_app_get.elementaddress",
            FT_UINT16, BASE_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_vendor_model_app_get_modelidentifier,
            { "ModelIdentifier", "btmesh.model.config_vendor_model_app_get.modelidentifier",
            FT_UINT32, BASE_CUSTOM, CF_FUNC(format_vendor_model), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_vendor_model_app_list_status,
            { "Status", "btmesh.model.config_vendor_model_app_list.status",
            FT_UINT8, BASE_DEC, VALS(btmesh_status_code_vals), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_vendor_model_app_list_elementaddress,
            { "ElementAddress", "btmesh.model.config_vendor_model_app_list.elementaddress",
            FT_UINT16, BASE_HEX, NULL, 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_vendor_model_app_list_modelidentifier,
            { "ModelIdentifier", "btmesh.model.config_vendor_model_app_list.modelidentifier",
            FT_UINT32, BASE_CUSTOM, CF_FUNC(format_vendor_model), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_vendor_model_app_list_appkeyindex,
            { "AppKeyIndex", "btmesh.model.config_vendor_model_app_list.appkeyindex",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index), 0x0,
            NULL, HFILL }
        },
        { &hf_btmesh_config_vendor_model_app_list_appkeyindex_rfu,
            { "RFU", "btmesh.model.config_vendor_model_app_list.appkeyindex.rfu",
            FT_UINT16, BASE_CUSTOM, CF_FUNC(format_key_index_rfu), 0x0,
            NULL, HFILL }
        },
};

    static gint *ett[] = {
        &ett_btmesh,
        &ett_btmesh_net_pdu,
        &ett_btmesh_transp_pdu,
        &ett_btmesh_transp_ctrl_msg,
        &ett_btmesh_upper_transp_acc_pdu,
        &ett_btmesh_segmented_access_fragments,
        &ett_btmesh_segmented_access_fragment,
        &ett_btmesh_segmented_control_fragments,
        &ett_btmesh_segmented_control_fragment,
        &ett_btmesh_access_pdu,
        &ett_btmesh_model_layer,
        &ett_btmesh_config_model_netapp_index,
        &ett_btmesh_config_model_publishperiod,
        &ett_btmesh_config_model_publishretransmit,
        &ett_btmesh_config_model_relayretransmit,
        &ett_btmesh_config_model_network_transmit,
        &ett_btmesh_config_model_element,
        &ett_btmesh_config_model_model,
        &ett_btmesh_config_model_vendor,
        &ett_btmesh_config_composition_data_status_features,
        &ett_btmesh_config_model_pub_app_index,
        &ett_btmesh_config_model_addresses,
        &ett_btmesh_config_model_netkey_list,
        &ett_btmesh_config_model_appkey_list,
        &ett_btmesh_config_model_net_index,
        &ett_btmesh_config_model_app_index,
        &ett_btmesh_config_heartbeat_publication_set_features,
        &ett_btmesh_config_heartbeat_publication_status_features,
        &ett_btmesh_config_model_fault_array,
    };

    static ei_register_info ei[] = {
        { &ei_btmesh_not_decoded_yet,{ "btmesh.not_decoded_yet", PI_PROTOCOL, PI_NOTE, "Not decoded yet", EXPFILL } },
        { &ei_btmesh_unknown_payload,{ "btmesh.unknown_payload", PI_PROTOCOL, PI_ERROR, "Unknown Payload", EXPFILL } },
    };

    expert_module_t* expert_btmesh;

    module_t *btmesh_module;

    /* UAT Net Key and App Key definitions */
    static uat_field_t btmesh_uat_flds[] = {
        UAT_FLD_CSTRING(uat_btmesh_records, network_key_string, "Network Key", "Network Key"),
        UAT_FLD_CSTRING(uat_btmesh_records, application_key_string, "Application Key", "Application Key"),
        UAT_FLD_CSTRING(uat_btmesh_records, ivindex_string, "IVindex", "IVindex"),
        UAT_END_FIELDS
    };

    /* UAT Device Key definition */
    static uat_field_t btmesh_dev_key_uat_flds[] = {
        UAT_FLD_CSTRING(uat_btmesh_dev_key_records, device_key_string, "Device Key", "Device Key"),
        UAT_FLD_CSTRING(uat_btmesh_dev_key_records, src_string, "SRC Address", "SRC Address"),
        UAT_END_FIELDS
    };

    /* UAT Label UUID definition */
    static uat_field_t btmesh_label_uuid_uat_flds[] = {
        UAT_FLD_CSTRING(uat_btmesh_label_uuid_records, label_uuid_string, "Label UUID", "Label UUID"),
        UAT_END_FIELDS
    };

    proto_btmesh = proto_register_protocol("Bluetooth Mesh", "BT Mesh", "btmesh");

    proto_register_field_array(proto_btmesh, hf, array_length(hf));
    proto_register_subtree_array(ett, array_length(ett));

    expert_btmesh = expert_register_protocol(proto_btmesh);
    expert_register_field_array(expert_btmesh, ei, array_length(ei));

    btmesh_module = prefs_register_protocol_subtree("Bluetooth", proto_btmesh, NULL);

    prefs_register_static_text_preference(btmesh_module, "version",
            "Bluetooth Mesh Profile v1.0",
            "Version of protocol supported by this dissector.");

    btmesh_uat = uat_new("BTMesh Network and Application keys",
        sizeof(uat_btmesh_record_t),    /* record size */
        "btmesh_nw_keys",               /* filename */
        TRUE,                           /* from_profile */
        &uat_btmesh_records,            /* data_ptr */
        &num_btmesh_uat,                /* numitems_ptr */
        UAT_AFFECTS_DISSECTION,         /* affects dissection of packets, but not set of named fields */
        NULL,                           /* help */
        uat_btmesh_record_copy_cb,      /* copy callback */
        uat_btmesh_record_update_cb,    /* update callback */
        uat_btmesh_record_free_cb,      /* free callback */
        NULL,                           /* post update callback */
        NULL,                           /* reset callback */
        btmesh_uat_flds);               /* UAT field definitions */

    prefs_register_uat_preference(btmesh_module,
        "mesh_keys_table",
        "Mesh Keys",
        "Configured Mesh Keys",
        btmesh_uat);

    btmesh_dev_key_uat = uat_new("BTMesh Device keys",
        sizeof(uat_btmesh_dev_key_record_t),  /* record size */
        "btmesh_dev_keys",                    /* filename */
        TRUE,                                 /* from_profile */
        &uat_btmesh_dev_key_records,          /* data_ptr */
        &num_btmesh_dev_key_uat,              /* numitems_ptr */
        UAT_AFFECTS_DISSECTION,               /* affects dissection of packets, but not set of named fields */
        NULL,                                 /* help */
        uat_btmesh_dev_key_record_copy_cb,    /* copy callback */
        uat_btmesh_dev_key_record_update_cb,  /* update callback */
        uat_btmesh_dev_key_record_free_cb,    /* free callback */
        NULL,                                 /* post update callback */
        NULL,                                 /* reset callback */
        btmesh_dev_key_uat_flds);             /* UAT field definitions */

    prefs_register_uat_preference(btmesh_module,
        "mesh_dev_key_table",
        "Device Keys",
        "Configured Mesh Device Keys",
        btmesh_dev_key_uat);

    btmesh_label_uuid_uat = uat_new("BTMesh Label UUIDs",
        sizeof(uat_btmesh_label_uuid_record_t),  /* record size */
        "btmesh_label_uuids",                    /* filename */
        TRUE,                                    /* from_profile */
        &uat_btmesh_label_uuid_records,          /* data_ptr */
        &num_btmesh_label_uuid_uat,              /* numitems_ptr */
        UAT_AFFECTS_DISSECTION,                  /* affects dissection of packets, but not set of named fields */
        NULL,                                    /* help */
        uat_btmesh_label_uuid_record_copy_cb,    /* copy callback */
        uat_btmesh_label_uuid_record_update_cb,  /* update callback */
        uat_btmesh_label_uuid_record_free_cb,    /* free callback */
        NULL,                                    /* post update callback */
        NULL,                                    /* reset callback */
        btmesh_label_uuid_uat_flds);             /* UAT field definitions */

    prefs_register_uat_preference(btmesh_module,
        "mesh_label_uuid_table",
        "Label UUIDs",
        "Configured Mesh Label UUIDs",
        btmesh_label_uuid_uat);

    btmesh_model_vendor_dissector_table  = register_dissector_table("btmesh.model.vendor",  "BT Mesh model vendor", proto_btmesh, FT_UINT16, BASE_DEC);

    register_dissector("btmesh.msg", dissect_btmesh_msg, proto_btmesh);

    register_init_routine(&upper_transport_init_routine);
}

/*
 * Editor modelines
 *
 * Local Variables:
 * c-basic-offset: 4
 * tab-width: 8
 * indent-tabs-mode: nil
 * End:
 *
 * ex: set shiftwidth=4 tabstop=8 expandtab:
 * :indentSize=4:tabSize=8:noTabs=true:
 */