aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-sigcomp.c
blob: b4055fbb149266135b6677b8aa2bf28f35e628ca (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
/* packet-sigcomp.c
 * Routines for Signaling Compression (SigComp) dissection.
 * Copyright 2004, Anders Broman <anders.broman@ericsson.com>
 *
 * $Id$
 *
 * Ethereal - Network traffic analyzer
 * By Gerald Combs <gerald@ethereal.com>
 * Copyright 1998 Gerald Combs
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 * References:
 * http://www.ietf.org/rfc/rfc3320.txt?number=3320
 * http://www.ietf.org/rfc/rfc3321.txt?number=3321
 * Useful links :
 * http://www.ietf.org/internet-drafts/draft-ietf-rohc-sigcomp-impl-guide-03.txt
 * http://www.ietf.org/internet-drafts/draft-ietf-rohc-sigcomp-sip-01.txt
 */

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <glib.h>

#ifdef NEED_SNPRINTF_H
# include "snprintf.h"
#endif

#include <epan/packet.h>
#include "prefs.h"
#include "strutil.h"
#include <epan/sigcomp-udvm.h>
#include <epan/sigcomp_state_hdlr.h>

/* Initialize the protocol and registered fields */
static int proto_sigcomp							= -1;
static int proto_raw_sigcomp						= -1;
static int hf_sigcomp_t_bit							= -1;
static int hf_sigcomp_len							= -1;
static int hf_sigcomp_returned_feedback_item		= -1;
static int hf_sigcomp_returned_feedback_item_len	= -1;
static int hf_sigcomp_code_len						= -1;
static int hf_sigcomp_destination					= -1;
static int hf_sigcomp_partial_state					= -1;
static int hf_sigcomp_udvm_instr					= -1;
static int hf_udvm_multitype_bytecode				= -1;
static int hf_udvm_reference_bytecode				= -1;
static int hf_udvm_literal_bytecode					= -1;
static int hf_udvm_operand							= -1;
static int hf_udvm_length							= -1;
static int hf_udvm_addr_length						= -1;
static int hf_udvm_destination						= -1;
static int hf_udvm_addr_destination					= -1;
static int hf_udvm_at_address						= -1;
static int hf_udvm_address							= -1;
static int hf_udvm_literal_num						= -1;
static int hf_udvm_value							= -1;
static int hf_udvm_addr_value						= -1;
static int hf_partial_identifier_start				= -1;
static int hf_partial_identifier_length				= -1;
static int hf_state_begin							= -1;
static int hf_udvm_state_length						= -1;
static int hf_udvm_state_length_addr				= -1;
static int hf_udvm_state_address					= -1;
static int hf_udvm_state_address_addr				= -1;
static int hf_udvm_state_instr						= -1;
static int hf_udvm_operand_1						= -1;
static int hf_udvm_operand_2						= -1;
static int hf_udvm_operand_2_addr					= -1;
static int hf_udvm_j								= -1;
static int hf_udvm_addr_j							= -1;
static int hf_udvm_output_start						= -1;
static int hf_udvm_addr_output_start				= -1;
static int hf_udvm_output_length					= -1;
static int hf_udvm_output_length_addr				= -1;
static int hf_udvm_req_feedback_loc					= -1;
static int hf_udvm_min_acc_len						= -1;
static int hf_udvm_state_ret_pri					= -1;
static int hf_udvm_ret_param_loc					= -1;
static int hf_udvm_position							= -1;
static int hf_udvm_ref_dest							= -1;
static int hf_udvm_bits								= -1;
static int hf_udvm_lower_bound						= -1;
static int hf_udvm_upper_bound						= -1;
static int hf_udvm_uncompressed						= -1;
static int hf_udvm_offset							= -1;
static int hf_udvm_addr_offset						= -1;
static int hf_udvm_start_value						= -1;

/* Initialize the subtree pointers */
static gint ett_sigcomp				= -1;
static gint ett_sigcomp_udvm		= -1;
static gint ett_sigcomp_udvm_exe	= -1;
static gint ett_raw_text			= -1;

static dissector_handle_t sip_handle;
/* set the tcp port */
static guint SigCompUDPPort1 = 5555;
static guint SigCompUDPPort2 = 6666;

/* Default preference wether to display the bytecode in UDVM operands or not */
static gboolean display_udvm_bytecode = FALSE;
/* Default preference wether to dissect the UDVM code or not */
static gboolean dissect_udvm_code = TRUE;
static gboolean display_raw_txt = FALSE;
/* Default preference wether to decompress the message or not */
static gboolean decompress = TRUE;
/* Default preference wether to print debug info at execution of UDVM 
 * 0 = No printout
 * 1 = details level 1
 * 2 = details level 2
 * 3 = details level 3
 * 4 = details level 4
 */
static gint udvm_print_detail_level = 0;

/* Value strings */
static const value_string length_encoding_vals[] = {
	{ 0x00,	"No partial state(Message type 2)" },
	{ 0x01,	"6 bytes)" },
	{ 0x02,	"9 bytes)" },
	{ 0x03,	"12 bytes)" },
	{ 0,	NULL }
};


static const value_string destination_address_encoding_vals[] = {
	{ 0x00,	"Reserved" },
	{ 0x01,	"128" },
	{ 0x02,	"192" },
	{ 0x03,	"256" },
	{ 0x04,	"320" },
	{ 0x05,	"384" },
	{ 0x06,	"448" },
	{ 0x07,	"512" },
	{ 0x08,	"576" },
	{ 0x09,	"640" },
	{ 0x0a,	"704" },
	{ 0x0b,	"768" },
	{ 0x0c,	"832" },
	{ 0x0d,	"896" },
	{ 0x0e,	"960" },
	{ 0x0F,	"1024" },
	{ 0,	NULL }
};

static const value_string udvm_instruction_code_vals[] = {
	{ 0,	"DECOMPRESSION-FAILURE" },
	{ 1,	"AND" },
	{ 2,	"OR" },
	{ 3,	"NOT" },
	{ 4,	"LSHIFT" },
	{ 5,	"RSHIFT" },
	{ 6,	"ADD" },
	{ 7,	"SUBTRACT" },
	{ 8,	"MULTIPLY" },
	{ 9,	"DIVIDE" },
	{ 10,	"REMAINDER" },
	{ 11,	"SORT-ASCENDING" },
	{ 12,	"SORT-DESCENDING" },
	{ 13,	"SHA-1" },
	{ 14,	"LOAD" },
	{ 15,	"MULTILOAD" },
	{ 16,	"PUSH" },
	{ 17,	"POP" },
	{ 18,	"COPY" },
	{ 19,	"COPY-LITERAL" },
	{ 20,	"COPY-OFFSET" },
	{ 21,	"MEMSET" },
	{ 22,	"JUMP" },
	{ 23,	"COMPARE" },
	{ 24,	"CALL" },
	{ 25,	"RETURN" },
	{ 26,	"SWITCH" },
	{ 27,	"CRC" },
	{ 28,	"INPUT-BYTES" },
	{ 29,	"INPUT-BITS" },
	{ 30,	"INPUT-HUFFMAN" },
	{ 31,	"STATE-ACCESS" },
	{ 32,	"STATE-CREATE" },
	{ 33,	"STATE-FREE" },
	{ 34,	"OUTPUT" },
	{ 35,	"END-MESSAGE" },
	{ 0,	NULL }
};
	/* RFC3320
	 * Figure 10: Bytecode for a multitype (%) operand
	 * Bytecode:                       Operand value:      Range:               HEX val
	 * 00nnnnnn                        N                   0 - 63				0x00
	 * 01nnnnnn                        memory[2 * N]       0 - 65535			0x40
	 * 1000011n                        2 ^ (N + 6)        64 , 128				0x86	
	 * 10001nnn                        2 ^ (N + 8)    256 , ... , 32768			0x88
	 * 111nnnnn                        N + 65504       65504 - 65535			0xe0
	 * 1001nnnn nnnnnnnn               N + 61440       61440 - 65535			0x90
	 * 101nnnnn nnnnnnnn               N                   0 - 8191				0xa0
	 * 110nnnnn nnnnnnnn               memory[N]           0 - 65535			0xc0
	 * 10000000 nnnnnnnn nnnnnnnn      N                   0 - 65535			0x80
	 * 10000001 nnnnnnnn nnnnnnnn      memory[N]           0 - 65535			0x81
	 */

static const value_string display_bytecode_vals[] = {
	{ 0x00,	"00nnnnnn, N, 0 - 63" },
	{ 0x40,	"01nnnnnn, memory[2 * N],0 - 65535" },
	{ 0x86,	"1000011n, 2 ^ (N + 6), 64 , 128" },
	{ 0x88,	"10001nnn, 2 ^ (N + 8), 256,..., 32768" },
	{ 0xe0,	"111nnnnn N + 65504, 65504 - 65535" },
	{ 0x90,	"1001nnnn nnnnnnnn, N + 61440, 61440 - 65535" },
	{ 0xa0,	"101nnnnn nnnnnnnn, N, 0 - 8191" },
	{ 0xc0,	"110nnnnn nnnnnnnn, memory[N], 0 - 65535" },
	{ 0x80,	"10000000 nnnnnnnn nnnnnnnn, N, 0 - 65535" },
	{ 0x81,	"10000001 nnnnnnnn nnnnnnnn, memory[N], 0 - 65535" },
	{ 0,	NULL }
};
/* RFC3320
 * 0nnnnnnn                        memory[2 * N]       0 - 65535
 * 10nnnnnn nnnnnnnn               memory[2 * N]       0 - 65535
 * 11000000 nnnnnnnn nnnnnnnn      memory[N]           0 - 65535
 */
static const value_string display_ref_bytecode_vals[] = {
	{ 0x00,	"0nnnnnnn memory[2 * N] 0 - 65535" },
	{ 0x80,	"10nnnnnn nnnnnnnn memory[2 * N] 0 - 65535" },
	{ 0xc0,	"11000000 nnnnnnnn nnnnnnnn memory[N] 0 - 65535" },
	{ 0,	NULL }
};
 /*  The simplest operand type is the literal (#), which encodes a
  * constant integer from 0 to 65535 inclusive.  A literal operand may
  * require between 1 and 3 bytes depending on its value.
  * Bytecode:                       Operand value:      Range:
  * 0nnnnnnn                        N                   0 - 127
  * 10nnnnnn nnnnnnnn               N                   0 - 16383
  * 11000000 nnnnnnnn nnnnnnnn      N                   0 - 65535
  *
  *            Figure 8: Bytecode for a literal (#) operand
  *
  */

static const value_string display_lit_bytecode_vals[] = {
	{ 0x00,	"0nnnnnnn N 0 - 127" },
	{ 0x80,	"10nnnnnn nnnnnnnn N 0 - 16383" },
	{ 0xc0,	"11000000 nnnnnnnn nnnnnnnn N 0 - 65535" },
	{ 0,	NULL }
};

static void dissect_udvm_bytecode(tvbuff_t *udvm_tvb, proto_tree *sigcomp_udvm_tree, guint destination);

static int dissect_udvm_multitype_operand(tvbuff_t *udvm_tvb, proto_tree *sigcomp_udvm_tree, 
										  gint offset,gboolean is_addr,gint *start_offset,
										  guint16 *value, gboolean *is_memory_address );

static int dissect_udvm_literal_operand(tvbuff_t *udvm_tvb, proto_tree *sigcomp_udvm_tree, 
							   gint offset, gint *start_offset, guint16 *value);

static int dissect_udvm_reference_operand(tvbuff_t *udvm_tvb, proto_tree *sigcomp_udvm_tree, 
							   gint offset, gint *start_offset, guint16 *value);
static void tvb_raw_text_add(tvbuff_t *tvb, proto_tree *tree);
/* Initialize the state handler
 *
 */
static void
sigcomp_init_protocol(void)
{
	sigcomp_init_udvm();
} 

/* Code to actually dissect the packets */
static int
dissect_sigcomp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{

/* Set up structures needed to add the protocol subtree and manage it */
	tvbuff_t	 *udvm_tvb, *msg_tvb, *udvm2_tvb;
	tvbuff_t	*decomp_tvb = NULL;
	proto_item *ti, *udvm_bytecode_item, *udvm_exe_item;
	proto_tree *sigcomp_tree, *sigcomp_udvm_tree, *sigcomp_udvm_exe_tree;
	gint		offset = 0;
	gint		bytecode_offset;
	guint16		partial_state_len;
	guint		octet;
	guint8		returned_feedback_field[128];
	guint8		partial_state[12];
	guint		tbit;
	guint16		len = 0;
	guint16		bytecode_len = 0;
	guint		destination;
	gint		msg_len = 0;
	guint8		*buff;
	guint16		p_id_start;
	guint8		i;
	guint16		state_begin;
	guint16		state_length;
	guint16		state_address;
	guint16		state_instruction;
	guint16		result_code;
	gchar		*partial_state_str;

/* Is this a SigComp message or not ? */
	octet = tvb_get_guint8(tvb, offset);
	if ((octet  & 0xf8) != 0xf8)
	 return 0;

/* Make entries in Protocol column and Info column on summary display */
	if (check_col(pinfo->cinfo, COL_PROTOCOL))
		col_set_str(pinfo->cinfo, COL_PROTOCOL, "SIGCOMP");

	if (check_col(pinfo->cinfo, COL_INFO)) 
		col_clear(pinfo->cinfo, COL_INFO);

/* create display subtree for the protocol */
	ti = proto_tree_add_item(tree, proto_sigcomp, tvb, 0, -1, FALSE);
	sigcomp_tree = proto_item_add_subtree(ti, ett_sigcomp);

/* add an item to the subtree, see section 1.6 for more information */
	octet = tvb_get_guint8(tvb, offset);

/*	 A SigComp message takes one of two forms depending on whether it
 *  accesses a state item at the receiving endpoint.  The two variants of
 *  a SigComp message are given in Figure 3.  (The T-bit controls the
 *  format of the returned feedback item and is defined in Section 7.1.)
 *
 *   0   1   2   3   4   5   6   7       0   1   2   3   4   5   6   7
 * +---+---+---+---+---+---+---+---+   +---+---+---+---+---+---+---+---+
 * | 1   1   1   1   1 | T |  len  |   | 1   1   1   1   1 | T |   0   |
 * +---+---+---+---+---+---+---+---+   +---+---+---+---+---+---+---+---+
 * |                               |   |                               |
 * :    returned feedback item     :   :    returned feedback item     :
 * |                               |   |                               |
 * +---+---+---+---+---+---+---+---+   +---+---+---+---+---+---+---+---+
 * |                               |   |           code_len            |
 * :   partial state identifier    :   +---+---+---+---+---+---+---+---+
 *
 * |                               |   |   code_len    |  destination  |
 * +---+---+---+---+---+---+---+---+   +---+---+---+---+---+---+---+---+
 * |                               |   |                               |
 * :   remaining SigComp message   :   :    uploaded UDVM bytecode     :
 * |                               |   |                               |
 * +---+---+---+---+---+---+---+---+   +---+---+---+---+---+---+---+---+
 *                                     |                               |
 *                                     :   remaining SigComp message   :
 *                                     |                               |
 *                                     +---+---+---+---+---+---+---+---+
 *
 */

	proto_tree_add_item(sigcomp_tree,hf_sigcomp_t_bit, tvb, offset, 1, FALSE);
	proto_tree_add_item(sigcomp_tree,hf_sigcomp_len, tvb, offset, 1, FALSE);
	tbit = ( octet & 0x04)>>2;
	partial_state_len = octet & 0x03;
	offset ++;
	if ( partial_state_len != 0 ){
		/*
		 * The len field encodes the number of transmitted bytes as follows:
		 *
		 *   Encoding:   Length of partial state identifier
		 *
		 *   01          6 bytes
		 *	 10          9 bytes
		 *	 11          12 bytes
		 * 
		 */
		partial_state_len = partial_state_len * 3 + 3;

		/*
		 * Message format 1
		 */
		if (check_col(pinfo->cinfo, COL_INFO))
			col_add_fstr(pinfo->cinfo, COL_INFO, "Msg format 1");

		if ( tbit == 1 ) {
			/*
			 * Returned feedback item exists
			 */
			len = 1;
			octet = tvb_get_guint8(tvb, offset);
			/* 0   1   2   3   4   5   6   7       0   1   2   3   4   5   6   7
			 * +---+---+---+---+---+---+---+---+   +---+---+---+---+---+---+---+---+
			 * | 0 |  returned_feedback_field  |   | 1 | returned_feedback_length  |
			 * +---+---+---+---+---+---+---+---+   +---+---+---+---+---+---+---+---+
			 *				       |                               |
			 *				       :    returned_feedback_field    :
			 *				       |                               |
			 *				       +---+---+---+---+---+---+---+---+
			 * Figure 4: Format of returned feedback item
			 */

			if ( (octet & 0x80) != 0 ){
				len = octet & 0x7f;
				proto_tree_add_uint(sigcomp_tree,hf_sigcomp_returned_feedback_item_len,
					tvb, offset, 1, len);
				offset ++;
				tvb_memcpy(tvb,returned_feedback_field,offset, len);
			} else {
				returned_feedback_field[0] = tvb_get_guint8(tvb, offset) & 0x7f;
			}
			proto_tree_add_bytes(sigcomp_tree,hf_sigcomp_returned_feedback_item,
				tvb, offset, len, returned_feedback_field);
			offset = offset + len;
		}
		tvb_memcpy(tvb, partial_state, offset, partial_state_len);
		partial_state_str = bytes_to_str(partial_state, partial_state_len);
		proto_tree_add_string(sigcomp_tree,hf_sigcomp_partial_state,
			tvb, offset, partial_state_len, partial_state_str);
		offset = offset + partial_state_len;
		if(msg_len>0)
			proto_tree_add_text(sigcomp_tree, tvb, offset, -1, "Remaining SigComp message %u bytes",
				tvb_reported_length_remaining(tvb, offset));

		if ( decompress ) {
			msg_len = tvb_reported_length_remaining(tvb, offset);
			msg_tvb = tvb_new_subset(tvb, offset, msg_len, msg_len);
			/*
			 * buff					= Where "state" will be stored
			 * p_id_start			= Partial state identifier start pos in the buffer(buff)
			 * partial_state_len	= Partial state identifier length
			 * state_begin			= Where to start to read state from
			 * state_length			= Length of state
			 * state_address			= Address where to store the state in the buffer(buff)
			 * state_instruction	=
			 * TRUE					= Indicates that state_* is in the stored state 
			 */
			/* 
			 * Note: The allocate buffer must be zeroed or some strange effects might occur.
			 */
			buff = g_malloc0(UDVM_MEMORY_SIZE);


			p_id_start = 0;
			state_begin = 0;
			/* These values will be loaded from the buffered state in sigcomp_state_hdlr 
			 */
			state_length = 0;
			state_address = 0;
			state_instruction =0;

			i = 0;
			while ( i < partial_state_len ){
				buff[i] = partial_state[i];
				i++;
			}

			result_code = udvm_state_access(tvb, sigcomp_tree, buff, p_id_start, partial_state_len, state_begin, &state_length, 
				&state_address, &state_instruction, hf_sigcomp_partial_state);


			if ( result_code != 0 ){
				proto_tree_add_text(sigcomp_tree, tvb, 0, -1,"Failed to Access state Ethereal UDVM diagnostic: %s.",
					    val_to_str(result_code, result_code_vals,"Unknown (%u)"));
				g_free(buff);
				return tvb_length(tvb);
			}

			udvm_tvb = tvb_new_real_data(buff,state_length+128,state_length+128);
			/* Arrange that the allocated packet data copy be freed when the
			 * tvbuff is freed. 
			 */
			tvb_set_free_cb( udvm_tvb, g_free );
			/* Add the tvbuff to the list of tvbuffs to which the tvbuff we
			 * were handed refers, so it'll get cleaned up when that tvbuff
			 * is cleaned up. 
			 */
			tvb_set_child_real_data_tvbuff( tvb, udvm_tvb );


			udvm2_tvb = tvb_new_subset(udvm_tvb, 128, state_length, state_length);
			/* TODO Check if buff needs to be free'd */
			udvm_exe_item = proto_tree_add_text(sigcomp_tree, udvm2_tvb, 0, state_length, 
				"UDVM execution trace");
			sigcomp_udvm_exe_tree = proto_item_add_subtree( udvm_exe_item, ett_sigcomp_udvm_exe);

			decomp_tvb = decompress_sigcomp_message(udvm2_tvb, msg_tvb, pinfo,
						   sigcomp_udvm_exe_tree, state_address, 
						   udvm_print_detail_level, hf_sigcomp_partial_state,
						   offset, state_length, partial_state_len);
		

			if ( decomp_tvb ){
				proto_tree_add_text(sigcomp_tree, decomp_tvb, 0, -1,"SigComp message Decompressed WOHO!!");
				if ( display_raw_txt )
					tvb_raw_text_add(decomp_tvb, tree);
				if (check_col(pinfo->cinfo, COL_PROTOCOL)){
					col_append_str(pinfo->cinfo, COL_PROTOCOL, "/");
					col_set_fence(pinfo->cinfo,COL_PROTOCOL);
				}
				call_dissector(sip_handle, decomp_tvb, pinfo, tree);
			}
		}/* if decompress */

	}
	else{
		/*
		 * Message format 2
		 */
	if (check_col(pinfo->cinfo, COL_INFO))
		col_add_fstr(pinfo->cinfo, COL_INFO, "Msg format 2");
		if ( tbit == 1 ) {
			/*
			 * Returned feedback item exists
			 */
			len = 1;
			octet = tvb_get_guint8(tvb, offset);
			if ( (octet & 0x80) != 0 ){
				len = octet & 0x7f;
				proto_tree_add_uint(sigcomp_tree,hf_sigcomp_returned_feedback_item_len,
					tvb, offset, 1, len);
				offset ++;
			}
			tvb_memcpy(tvb,returned_feedback_field,offset, len);
			proto_tree_add_bytes(sigcomp_tree,hf_sigcomp_returned_feedback_item,
				tvb, offset, 1, returned_feedback_field);
			offset = offset + len;
		}
		len = tvb_get_ntohs(tvb, offset) >> 4;
		octet =  tvb_get_guint8(tvb, (offset + 1));
		destination = (octet & 0x0f);
		if ( destination != 0 )
			destination = 64 + ( destination * 64 );
		proto_tree_add_uint(sigcomp_tree,hf_sigcomp_code_len, tvb, offset, 2, len);
		proto_tree_add_item(sigcomp_tree,hf_sigcomp_destination, tvb, (offset+ 1), 1, FALSE);
		offset = offset +2;

		bytecode_len = len;
		bytecode_offset = offset;
		udvm_bytecode_item = proto_tree_add_text(sigcomp_tree, tvb, bytecode_offset, bytecode_len, 
			"Uploaded UDVM bytecode %u (0x%x) bytes", bytecode_len, bytecode_len);
		sigcomp_udvm_tree = proto_item_add_subtree( udvm_bytecode_item, ett_sigcomp_udvm);

		udvm_tvb = tvb_new_subset(tvb, offset, len, len);
		if ( dissect_udvm_code )
			dissect_udvm_bytecode(udvm_tvb, sigcomp_udvm_tree, destination); 

		offset = offset + len;
		msg_len = tvb_reported_length_remaining(tvb, offset);
		if(msg_len>0)
			proto_tree_add_text(sigcomp_tree, tvb, offset, -1, "Remaining SigComp message %u bytes",
				tvb_reported_length_remaining(tvb, offset));
		if ( decompress ){

			msg_tvb = tvb_new_subset(tvb, offset, msg_len, msg_len);
	
			udvm_exe_item = proto_tree_add_text(sigcomp_tree, tvb, bytecode_offset, bytecode_len, 
				"UDVM execution trace");
			sigcomp_udvm_exe_tree = proto_item_add_subtree( udvm_exe_item, ett_sigcomp_udvm_exe);
			decomp_tvb = decompress_sigcomp_message(udvm_tvb, msg_tvb, pinfo,
						   sigcomp_udvm_exe_tree, destination, 
						   udvm_print_detail_level, hf_sigcomp_partial_state,
						   offset, 0, 0);
			if ( decomp_tvb ){
				proto_tree_add_text(sigcomp_tree, decomp_tvb, 0, -1,"SigComp message Decompressed WOHO!!");
				if ( display_raw_txt )
					tvb_raw_text_add(decomp_tvb, tree);
				if (check_col(pinfo->cinfo, COL_PROTOCOL)){
					col_append_str(pinfo->cinfo, COL_PROTOCOL, "/");
					col_set_fence(pinfo->cinfo,COL_PROTOCOL);
				}
				call_dissector(sip_handle, decomp_tvb, pinfo, tree);
			}
		} /* if decompress */

	}
	return tvb_length(tvb);
}

		
#define	SIGCOMP_INSTR_DECOMPRESSION_FAILURE     0
#define SIGCOMP_INSTR_AND                       1
#define SIGCOMP_INSTR_OR                        2
#define SIGCOMP_INSTR_NOT                       3
#define SIGCOMP_INSTR_LSHIFT                    4
#define SIGCOMP_INSTR_RSHIFT                    5
#define SIGCOMP_INSTR_ADD                       6
#define SIGCOMP_INSTR_SUBTRACT                  7
#define SIGCOMP_INSTR_MULTIPLY                  8
#define SIGCOMP_INSTR_DIVIDE                    9
#define SIGCOMP_INSTR_REMAINDER                 10
#define SIGCOMP_INSTR_SORT_ASCENDING            11
#define SIGCOMP_INSTR_SORT_DESCENDING           12
#define SIGCOMP_INSTR_SHA_1                     13
#define SIGCOMP_INSTR_LOAD                      14
#define SIGCOMP_INSTR_MULTILOAD                 15
#define SIGCOMP_INSTR_PUSH                      16
#define SIGCOMP_INSTR_POP                       17
#define SIGCOMP_INSTR_COPY                      18
#define SIGCOMP_INSTR_COPY_LITERAL              19
#define SIGCOMP_INSTR_COPY_OFFSET               20
#define SIGCOMP_INSTR_MEMSET                    21
#define SIGCOMP_INSTR_JUMP                      22
#define SIGCOMP_INSTR_COMPARE                   23
#define SIGCOMP_INSTR_CALL                      24
#define SIGCOMP_INSTR_RETURN                    25
#define SIGCOMP_INSTR_SWITCH                    26
#define SIGCOMP_INSTR_CRC                       27
#define SIGCOMP_INSTR_INPUT_BYTES               28
#define SIGCOMP_INSTR_INPUT_BITS                29
#define SIGCOMP_INSTR_INPUT_HUFFMAN             30
#define SIGCOMP_INSTR_STATE_ACCESS              31
#define SIGCOMP_INSTR_STATE_CREATE              32
#define SIGCOMP_INSTR_STATE_FREE                33
#define SIGCOMP_INSTR_OUTPUT                    34
#define SIGCOMP_INSTR_END_MESSAGE               35	


static void
dissect_udvm_bytecode(tvbuff_t *udvm_tvb, proto_tree *sigcomp_udvm_tree,guint start_address)
{
	guint instruction;
	gint offset = 0;
	gint start_offset;
	gint len;
	gint n;
	guint instruction_no = 0;
	guint16 value = 0;
	proto_item *item, *item2;
	guint UDVM_address = start_address;
	gboolean is_memory_address;
	guint16 msg_length = tvb_reported_length_remaining(udvm_tvb, offset);


	while (msg_length > offset) { 
		instruction = tvb_get_guint8(udvm_tvb, offset);
		instruction_no ++;
		UDVM_address = start_address + offset;
;

		item = proto_tree_add_text(sigcomp_udvm_tree, udvm_tvb, offset, 1,
					"######### UDVM instruction %u at UDVM-address %u (0x%x) #########",
					instruction_no,UDVM_address,UDVM_address);
		PROTO_ITEM_SET_GENERATED(item);
		proto_tree_add_item(sigcomp_udvm_tree, hf_sigcomp_udvm_instr, udvm_tvb, offset, 1, FALSE);
		offset ++;
		switch ( instruction ) {

		case SIGCOMP_INSTR_AND: /* 1 AND ($operand_1, %operand_2) */
			/* $operand_1*/
			offset = dissect_udvm_reference_operand(udvm_tvb, sigcomp_udvm_tree, offset, &start_offset, &value);
			len = offset - start_offset;
			proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_operand_1, 
				udvm_tvb, start_offset, len, value);
			/* %operand_2*/
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, FALSE,&start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			if ( is_memory_address ){
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_operand_2_addr, 
					udvm_tvb, start_offset, len, value);
			}else{
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_operand_2, 
					udvm_tvb, start_offset, len, value);
			}
			break;

		case SIGCOMP_INSTR_OR: /* 2 OR ($operand_1, %operand_2) */
			/* $operand_1*/
			offset = dissect_udvm_reference_operand(udvm_tvb, sigcomp_udvm_tree, offset, &start_offset, &value);
			len = offset - start_offset;
			proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_operand_1, 
				udvm_tvb, start_offset, len, value);
			/* %operand_2*/
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, FALSE,&start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			if ( is_memory_address ){
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_operand_2_addr, 
					udvm_tvb, start_offset, len, value);
			}else{
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_operand_2, 
					udvm_tvb, start_offset, len, value);
			}
			break;

		case SIGCOMP_INSTR_NOT: /* 3 NOT ($operand_1) */
			/* $operand_1*/
			offset = dissect_udvm_reference_operand(udvm_tvb, sigcomp_udvm_tree, offset, &start_offset, &value);
			len = offset - start_offset;
			proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_operand_1, 
				udvm_tvb, start_offset, len, value);
			break;

		case SIGCOMP_INSTR_LSHIFT: /* 4 LSHIFT ($operand_1, %operand_2) */
			/* $operand_1*/
			offset = dissect_udvm_reference_operand(udvm_tvb, sigcomp_udvm_tree, offset, &start_offset, &value);
			len = offset - start_offset;
			proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_operand_1, 
				udvm_tvb, start_offset, len, value);
			/* %operand_2*/
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, FALSE,&start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			if ( is_memory_address ){
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_operand_2_addr, 
					udvm_tvb, start_offset, len, value);
			}else{
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_operand_2, 
					udvm_tvb, start_offset, len, value);
			}
			break;

		case SIGCOMP_INSTR_RSHIFT: /* 5 RSHIFT ($operand_1, %operand_2) */
			/* $operand_1*/
			offset = dissect_udvm_reference_operand(udvm_tvb, sigcomp_udvm_tree, offset, &start_offset, &value);
			len = offset - start_offset;
			proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_operand_1, 
				udvm_tvb, start_offset, len, value);
			/* %operand_2*/
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, FALSE,&start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			if ( is_memory_address ){
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_operand_2_addr, 
					udvm_tvb, start_offset, len, value);
			}else{
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_operand_2, 
					udvm_tvb, start_offset, len, value);
			}
			break;

		case SIGCOMP_INSTR_ADD: /* 6 ADD ($operand_1, %operand_2) */
			/* $operand_1*/
			offset = dissect_udvm_reference_operand(udvm_tvb, sigcomp_udvm_tree, offset, &start_offset, &value);
			len = offset - start_offset;
			proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_operand_1, 
				udvm_tvb, start_offset, len, value);
			/* %operand_2*/
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, FALSE,&start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			if ( is_memory_address ){
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_operand_2_addr, 
					udvm_tvb, start_offset, len, value);
			}else{
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_operand_2, 
					udvm_tvb, start_offset, len, value);
			}
			break;

		case SIGCOMP_INSTR_SUBTRACT: /* 7 SUBTRACT ($operand_1, %operand_2) */
			/* $operand_1*/
			offset = dissect_udvm_reference_operand(udvm_tvb, sigcomp_udvm_tree, offset, &start_offset, &value);
			len = offset - start_offset;
			proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_operand_1, 
				udvm_tvb, start_offset, len, value);
			/* %operand_2*/
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, FALSE,&start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			if ( is_memory_address ){
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_operand_2_addr, 
					udvm_tvb, start_offset, len, value);
			}else{
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_operand_2, 
					udvm_tvb, start_offset, len, value);
			}
			break;

		case SIGCOMP_INSTR_MULTIPLY: /* 8 MULTIPLY ($operand_1, %operand_2) */
			/* $operand_1*/
			offset = dissect_udvm_reference_operand(udvm_tvb, sigcomp_udvm_tree, offset, &start_offset, &value);
			len = offset - start_offset;
			proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_operand_1, 
				udvm_tvb, start_offset, len, value);
			/* %operand_2*/
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, FALSE,&start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			if ( is_memory_address ){
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_operand_2_addr, 
					udvm_tvb, start_offset, len, value);
			}else{
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_operand_2, 
					udvm_tvb, start_offset, len, value);
			}
			break;

		case SIGCOMP_INSTR_DIVIDE: /* 9 DIVIDE ($operand_1, %operand_2) */
			/* $operand_1*/
			offset = dissect_udvm_reference_operand(udvm_tvb, sigcomp_udvm_tree, offset, &start_offset, &value);
			len = offset - start_offset;
			proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_operand_1, 
				udvm_tvb, start_offset, len, value);
			/* %operand_2*/
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, FALSE,&start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			if ( is_memory_address ){
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_operand_2_addr, 
					udvm_tvb, start_offset, len, value);
			}else{
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_operand_2, 
					udvm_tvb, start_offset, len, value);
			}
			break;

		case SIGCOMP_INSTR_REMAINDER: /* 10 REMAINDER ($operand_1, %operand_2) */
			/* $operand_1*/
			offset = dissect_udvm_reference_operand(udvm_tvb, sigcomp_udvm_tree, offset, &start_offset, &value);
			len = offset - start_offset;
			proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_operand_1, 
				udvm_tvb, start_offset, len, value);
			/* %operand_2*/
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, FALSE,&start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			if ( is_memory_address ){
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_operand_2_addr, 
					udvm_tvb, start_offset, len, value);
			}else{
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_operand_2, 
					udvm_tvb, start_offset, len, value);
			}
			break;
		case SIGCOMP_INSTR_SORT_ASCENDING: /* 11 SORT-ASCENDING (%start, %n, %k) */
						/* while programming stop while loop */
			offset = offset + tvb_reported_length_remaining(udvm_tvb, offset);
			break;

		case SIGCOMP_INSTR_SORT_DESCENDING: /* 12 SORT-DESCENDING (%start, %n, %k) */
			offset = offset + tvb_reported_length_remaining(udvm_tvb, offset);
			break;
		case SIGCOMP_INSTR_SHA_1: /* 13 SHA-1 (%position, %length, %destination) */
			/* %position */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, FALSE,&start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_position, 
				udvm_tvb, start_offset, len, value);

			/*  %length, */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, FALSE,&start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			if ( is_memory_address ){
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_addr_length, 
					udvm_tvb, start_offset, len, value);
			}else{
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_length, 
					udvm_tvb, start_offset, len, value);
			}

			/* $destination */
			offset = dissect_udvm_reference_operand(udvm_tvb, sigcomp_udvm_tree, offset, &start_offset, &value);
			len = offset - start_offset;
			proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_ref_dest, 
				udvm_tvb, start_offset, len, value);
			break;

		case SIGCOMP_INSTR_LOAD: /* 14 LOAD (%address, %value) */
			/* %address */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, TRUE,&start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_address, 
				udvm_tvb, start_offset, len, value);
			/* %value */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, FALSE,&start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			if ( is_memory_address ){
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_addr_value, 
					udvm_tvb, start_offset, len, value);
			}else{
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_value, 
					udvm_tvb, start_offset, len, value);
			}
			break;

		case SIGCOMP_INSTR_MULTILOAD: /* 15 MULTILOAD (%address, #n, %value_0, ..., %value_n-1) */
			/* %address */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, TRUE, &start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_address, 
				udvm_tvb, start_offset, len, value);
			/* #n */
			offset = dissect_udvm_literal_operand(udvm_tvb, sigcomp_udvm_tree, offset, &start_offset, &value);
			len = offset - start_offset;
			proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_literal_num, 
				udvm_tvb, start_offset, len, value);
			n = value;
			while ( n > 0) {
				n = n -1;
				/* %value */
				offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, FALSE,&start_offset, &value, &is_memory_address);
				len = offset - start_offset;
				if ( is_memory_address ){
					proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_addr_value, 
						udvm_tvb, start_offset, len, value);
				}else{
					proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_value, 
						udvm_tvb, start_offset, len, value);
				}
			}
			break;
			 
		case SIGCOMP_INSTR_PUSH: /* 16 PUSH (%value) */
			/* %value */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, FALSE,&start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			if ( is_memory_address ){
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_addr_value, 
					udvm_tvb, start_offset, len, value);
			}else{
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_value, 
					udvm_tvb, start_offset, len, value);
			}
			break;

		case SIGCOMP_INSTR_POP: /* 17 POP (%address) */
			/* %address */			
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, TRUE, &start_offset, &value, &is_memory_address);

			len = offset - start_offset;
			proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_address, 
				udvm_tvb, start_offset, len, value);
			break;

		case SIGCOMP_INSTR_COPY: /* 18 COPY (%position, %length, %destination) */
			/* %position */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, FALSE,&start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_position, 
				udvm_tvb, start_offset, len, value);

			/*  %length, */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, FALSE,&start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			if ( is_memory_address ){
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_addr_length, 
					udvm_tvb, start_offset, len, value);
			}else{
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_length, 
					udvm_tvb, start_offset, len, value);
			}

			/* $destination */
			offset = dissect_udvm_reference_operand(udvm_tvb, sigcomp_udvm_tree, offset, &start_offset, &value);
			len = offset - start_offset;
			proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_ref_dest, 
				udvm_tvb, start_offset, len, value);
			break;

		case SIGCOMP_INSTR_COPY_LITERAL: /* 19 COPY-LITERAL (%position, %length, $destination) */
			/* %position */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, FALSE,&start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_position, 
				udvm_tvb, start_offset, len, value);

			/*  %length, */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, FALSE,&start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			if ( is_memory_address ){
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_addr_length, 
					udvm_tvb, start_offset, len, value);
			}else{
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_length, 
					udvm_tvb, start_offset, len, value);
			}

			/* $destination */
			offset = dissect_udvm_reference_operand(udvm_tvb, sigcomp_udvm_tree, offset, &start_offset, &value);
			len = offset - start_offset;
			proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_ref_dest, 
				udvm_tvb, start_offset, len, value);
			break;
 
		case SIGCOMP_INSTR_COPY_OFFSET: /* 20 COPY-OFFSET (%offset, %length, $destination) */
			/* %offset */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, FALSE,&start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			if ( is_memory_address ){
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_addr_offset, 
					udvm_tvb, start_offset, len, value);
			}else{
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_offset, 
					udvm_tvb, start_offset, len, value);
			}

			/*  %length, */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, FALSE,&start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			if ( is_memory_address ){
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_addr_length, 
					udvm_tvb, start_offset, len, value);
			}else{
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_length, 
					udvm_tvb, start_offset, len, value);
			}

			/* $destination */
			offset = dissect_udvm_reference_operand(udvm_tvb, sigcomp_udvm_tree, offset, &start_offset, &value);
			len = offset - start_offset;
			proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_ref_dest, 
				udvm_tvb, start_offset, len, value);
			break;
		case SIGCOMP_INSTR_MEMSET: /* 21 MEMSET (%address, %length, %start_value, %offset) */

			/* %address */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, TRUE, &start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_address, 
				udvm_tvb, start_offset, len, value);

			/*  %length, */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, FALSE, &start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			if ( is_memory_address ){
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_addr_length, 
					udvm_tvb, start_offset, len, value);
			}else{
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_length, 
					udvm_tvb, start_offset, len, value);
			}

			/* %start_value */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, FALSE,&start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_start_value, 
				udvm_tvb, start_offset, len, value);

			/* %offset */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, FALSE,&start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_offset, 
				udvm_tvb, start_offset, len, value);
			break;


		case SIGCOMP_INSTR_JUMP: /* 22 JUMP (@address) */
			/* @address */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, TRUE, &start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			 /* operand_value = (memory_address_of_instruction + D) modulo 2^16 */
			value = ( value + UDVM_address ) & 0xffff;
			proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_at_address, 
				udvm_tvb, start_offset, len, value);
			break;

		case SIGCOMP_INSTR_COMPARE: /* 23 */
			/* COMPARE (%value_1, %value_2, @address_1, @address_2, @address_3)
			 */
			/* %value_1 */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, FALSE,&start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			if ( is_memory_address ){
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_addr_value, 
					udvm_tvb, start_offset, len, value);
			}else{
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_value, 
					udvm_tvb, start_offset, len, value);
			}

			/* %value_2 */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, FALSE,&start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			if ( is_memory_address ){
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_addr_value, 
					udvm_tvb, start_offset, len, value);
			}else{
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_value, 
					udvm_tvb, start_offset, len, value);
			}

			/* @address_1 */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, TRUE, &start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			 /* operand_value = (memory_address_of_instruction + D) modulo 2^16 */
			value = ( value + UDVM_address ) & 0xffff;
			proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_at_address, 
				udvm_tvb, start_offset, len, value);

			/* @address_2 */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, TRUE, &start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			 /* operand_value = (memory_address_of_instruction + D) modulo 2^16 */
			value = ( value + UDVM_address ) & 0xffff;
			proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_at_address, 
				udvm_tvb, start_offset, len, value);

			/* @address_3 */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, TRUE, &start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			 /* operand_value = (memory_address_of_instruction + D) modulo 2^16 */
			value = ( value + UDVM_address ) & 0xffff;
			proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_at_address, 
				udvm_tvb, start_offset, len, value);
			break;

		case SIGCOMP_INSTR_CALL: /* 24 CALL (@address) (PUSH addr )*/
			/* @address */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, TRUE, &start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			 /* operand_value = (memory_address_of_instruction + D) modulo 2^16 */
			value = ( value + UDVM_address ) & 0xffff;
			proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_at_address, 
				udvm_tvb, start_offset, len, value);
			break;
		case SIGCOMP_INSTR_RETURN: /* 25 POP and return */

		break;

		case SIGCOMP_INSTR_SWITCH: /* 26 SWITCH (#n, %j, @address_0, @address_1, ... , @address_n-1) */
			/* #n */
			offset = dissect_udvm_literal_operand(udvm_tvb, sigcomp_udvm_tree, offset, &start_offset, &value);
			len = offset - start_offset;
			proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_literal_num, 
				udvm_tvb, start_offset, len, value);

			/* Number of addresses in the instruction */
			n = value;
			/* %j */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, FALSE,&start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			if ( is_memory_address ){
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_addr_j, 
					udvm_tvb, start_offset, len, value);
			}else{
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_j, 
					udvm_tvb, start_offset, len, value);
			}

			while ( n > 0) {
				n = n -1;
				/* @address_n-1 */
				offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, TRUE,&start_offset, &value, &is_memory_address);
				len = offset - start_offset;
				 /* operand_value = (memory_address_of_instruction + D) modulo 2^16 */
				value = ( value + UDVM_address ) & 0xffff;
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_at_address, 
					udvm_tvb, start_offset, len, value);
			}
			break;
		case SIGCOMP_INSTR_CRC: /* 27 CRC (%value, %position, %length, @address) */
			/* %value */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, FALSE,&start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			if ( is_memory_address ){
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_addr_value, 
					udvm_tvb, start_offset, len, value);
			}else{
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_value, 
					udvm_tvb, start_offset, len, value);
			}

			/* %position */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, FALSE,&start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_position, 
				udvm_tvb, start_offset, len, value);

			/* %length */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, FALSE,&start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			if ( is_memory_address ){
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_addr_length, 
					udvm_tvb, start_offset, len, value);
			}else{
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_length, 
					udvm_tvb, start_offset, len, value);
			}

			/* @address */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, TRUE, &start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			 /* operand_value = (memory_address_of_instruction + D) modulo 2^16 */
			value = ( value + UDVM_address ) & 0xffff;
			proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_at_address, 
				udvm_tvb, start_offset, len, value);
			break;


		case SIGCOMP_INSTR_INPUT_BYTES: /* 28 INPUT-BYTES (%length, %destination, @address) */
			/* %length */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, FALSE,&start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			if ( is_memory_address ){
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_addr_length, 
					udvm_tvb, start_offset, len, value);
			}else{
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_length, 
					udvm_tvb, start_offset, len, value);
			}

			/* %destination */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, FALSE,&start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			if ( is_memory_address ){
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_addr_destination, 
					udvm_tvb, start_offset, len, value);
			}else{
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_destination, 
					udvm_tvb, start_offset, len, value);
			}

			/* @address */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, TRUE, &start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			 /* operand_value = (memory_address_of_instruction + D) modulo 2^16 */
			value = ( value + UDVM_address ) & 0xffff;
			proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_at_address, 
				udvm_tvb, start_offset, len, value);
			break;
		case SIGCOMP_INSTR_INPUT_BITS:/* 29   INPUT-BITS (%length, %destination, @address) */
			/* %length */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, FALSE,&start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			if ( is_memory_address ){
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_addr_length, 
					udvm_tvb, start_offset, len, value);
			}else{
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_length, 
					udvm_tvb, start_offset, len, value);
			}

			/* %destination */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, FALSE,&start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			if ( is_memory_address ){
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_addr_destination, 
					udvm_tvb, start_offset, len, value);
			}else{
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_destination, 
					udvm_tvb, start_offset, len, value);
			}

			/* @address */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, TRUE, &start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			 /* operand_value = (memory_address_of_instruction + D) modulo 2^16 */
			value = ( value + UDVM_address ) & 0xffff;
			proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_at_address, 
				udvm_tvb, start_offset, len, value);
			break;
		case SIGCOMP_INSTR_INPUT_HUFFMAN: /* 30 */
			/*
			 * INPUT-HUFFMAN (%destination, @address, #n, %bits_1, %lower_bound_1,
			 *  %upper_bound_1, %uncompressed_1, ... , %bits_n, %lower_bound_n,
			 *  %upper_bound_n, %uncompressed_n)
			 */
			/* %destination */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, FALSE,&start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			if ( is_memory_address ){
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_addr_destination, 
					udvm_tvb, start_offset, len, value);
			}else{
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_destination, 
					udvm_tvb, start_offset, len, value);
			}
			/* @address */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, TRUE, &start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			 /* operand_value = (memory_address_of_instruction + D) modulo 2^16 */
			value = ( value + UDVM_address ) & 0xffff;
			proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_at_address, 
				udvm_tvb, start_offset, len, value);
			/* #n */
			offset = dissect_udvm_literal_operand(udvm_tvb, sigcomp_udvm_tree, offset, &start_offset, &value);
			len = offset - start_offset;
			proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_literal_num, 
				udvm_tvb, start_offset, len, value);
			n = value;
			while ( n > 0) {
				n = n -1;
				/* %bits_n */
				offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, FALSE,&start_offset, &value, &is_memory_address);
				len = offset - start_offset;
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_bits, 
					udvm_tvb, start_offset, len, value);
				/* %lower_bound_n*/
				offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, FALSE,&start_offset, &value, &is_memory_address);
				len = offset - start_offset;
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_lower_bound, 
					udvm_tvb, start_offset, len, value);
				/* %upper_bound_n */
				offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, FALSE,&start_offset, &value, &is_memory_address);
				len = offset - start_offset;
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_upper_bound, 
					udvm_tvb, start_offset, len, value);
				/* %uncompressed_n */
				offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, FALSE,&start_offset, &value, &is_memory_address);
				len = offset - start_offset;
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_uncompressed, 
					udvm_tvb, start_offset, len, value);
			}
			break;

		case SIGCOMP_INSTR_STATE_ACCESS: /* 31 */
			/*   STATE-ACCESS (%partial_identifier_start, %partial_identifier_length,
			 * %state_begin, %state_length, %state_address, %state_instruction)
			 */

			/* 
			 * %partial_identifier_start
			 */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, TRUE, &start_offset, &value ,&is_memory_address);
			len = offset - start_offset;
			proto_tree_add_uint(sigcomp_udvm_tree, hf_partial_identifier_start, 
				udvm_tvb, start_offset, len, value);

			/*
			 * %partial_identifier_length
			 */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, TRUE, &start_offset, &value ,&is_memory_address);
			len = offset - start_offset;
			proto_tree_add_uint(sigcomp_udvm_tree, hf_partial_identifier_length, 
				udvm_tvb, start_offset, len, value);
			/*
			 * %state_begin
			 */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, TRUE, &start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			proto_tree_add_uint(sigcomp_udvm_tree, hf_state_begin, 
				udvm_tvb, start_offset, len, value);

			/*
			 * %state_length
			 */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, TRUE, &start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			if ( is_memory_address ) {
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_state_length_addr, 
					udvm_tvb, start_offset, len, value);
			}else{
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_state_length, 
					udvm_tvb, start_offset, len, value);
			}
			/*
			 * %state_address
			 */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, TRUE, &start_offset, &value ,&is_memory_address);
			len = offset - start_offset;
			if ( is_memory_address ) {
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_state_address_addr, 
					udvm_tvb, start_offset, len, value);
			}else{
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_state_address, 
					udvm_tvb, start_offset, len, value);
			}
			/*
			 * %state_instruction
			 */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, TRUE, &start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_state_instr, 
				udvm_tvb, start_offset, len, value);
			break;
		case SIGCOMP_INSTR_STATE_CREATE: /* 32 */
			/*
			 * STATE-CREATE (%state_length, %state_address, %state_instruction,
			 * %minimum_access_length, %state_retention_priority)
			 */

			/*
			 * %state_length
			 */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, TRUE, &start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			if ( is_memory_address ) {
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_state_length_addr, 
					udvm_tvb, start_offset, len, value);
			}else{
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_state_length, 
					udvm_tvb, start_offset, len, value);
			}
			/*
			 * %state_address
			 */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, TRUE, &start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			if ( is_memory_address ) {
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_state_address_addr, 
					udvm_tvb, start_offset, len, value);
			}else{
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_state_address, 
					udvm_tvb, start_offset, len, value);
			}
			/*
			 * %state_instruction
			 */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, TRUE, &start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_state_instr, 
				udvm_tvb, start_offset, len, value);
			/*
			 * %minimum_access_length
			 */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, TRUE, &start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_min_acc_len, 
				udvm_tvb, start_offset, len, value);
			/*
			 * %state_retention_priority
			 */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, TRUE, &start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_state_ret_pri, 
				udvm_tvb, start_offset, len, value);

			break;
		case SIGCOMP_INSTR_STATE_FREE: /* 33 */
			/*
			 * STATE-FREE (%partial_identifier_start, %partial_identifier_length)
			 */
			/* 
			 * %partial_identifier_start
			 */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, TRUE, &start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			proto_tree_add_uint(sigcomp_udvm_tree, hf_partial_identifier_start, 
				udvm_tvb, start_offset, len, value);

			/*
			 * %partial_identifier_length
			 */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, TRUE, &start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			proto_tree_add_uint(sigcomp_udvm_tree, hf_partial_identifier_length, 
				udvm_tvb, start_offset, len, value);
			break;
		case SIGCOMP_INSTR_OUTPUT: /* 34 OUTPUT (%output_start, %output_length) */
			/* 
			 * %output_start
			 */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, TRUE, &start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			if ( is_memory_address ) {
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_addr_output_start, 
					udvm_tvb, start_offset, len, value);
			}else{
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_output_start, 
					udvm_tvb, start_offset, len, value);
			}
			/* 
			 * %output_length
			 */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, TRUE, &start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			if ( is_memory_address ) {
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_output_length_addr, 
					udvm_tvb, start_offset, len, value);
			}else{
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_output_length, 
					udvm_tvb, start_offset, len, value);
			}
			break;
		case SIGCOMP_INSTR_END_MESSAGE: /* 35 */
			/*
			 * END-MESSAGE (%requested_feedback_location,
			 * %returned_parameters_location, %state_length, %state_address,
			 * %state_instruction, %minimum_access_length,
			 * %state_retention_priority)
			 */
			/* %requested_feedback_location */
			if ((msg_length-1) < offset){
				item2 = proto_tree_add_text(sigcomp_udvm_tree, udvm_tvb, 0, -1,
						"All remaining parameters = 0(Not in the uploaded code as UDVM buffer initalized to Zero");
				PROTO_ITEM_SET_GENERATED(item2);
				return;
			}
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, TRUE, &start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_req_feedback_loc, 
				udvm_tvb, start_offset, len, value);
			/* returned_parameters_location */
			if ((msg_length-1) < offset){
				item2 = proto_tree_add_text(sigcomp_udvm_tree, udvm_tvb, offset-1, -1,
						"All remaining parameters = 0(Not in the uploaded code as UDVM buffer initalized to Zero");
				PROTO_ITEM_SET_GENERATED(item2);
				return;
			}
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, TRUE, &start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_ret_param_loc, 
				udvm_tvb, start_offset, len, value);
			/*
			 * %state_length
			 */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, TRUE, &start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			if ( is_memory_address ) {
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_state_length_addr, 
					udvm_tvb, start_offset, len, value);
			}else{
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_state_length, 
					udvm_tvb, start_offset, len, value);
			}
			/*
			 * %state_address
			 */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, TRUE, &start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			if ( is_memory_address ) {
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_state_address_addr, 
					udvm_tvb, start_offset, len, value);
			}else{
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_state_address, 
					udvm_tvb, start_offset, len, value);
			}
			/*
			 * %state_instruction
			 */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, TRUE, &start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_state_instr, 
				udvm_tvb, start_offset, len, value);
			/*
			 * %minimum_access_length
			 */
			offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, TRUE, &start_offset, &value, &is_memory_address);
			len = offset - start_offset;
			proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_min_acc_len, 
				udvm_tvb, start_offset, len, value);
			/*
			 * %state_retention_priority
			 */
			if ( tvb_reported_length_remaining(udvm_tvb, offset) != 0 ){
				offset = dissect_udvm_multitype_operand(udvm_tvb, sigcomp_udvm_tree, offset, TRUE, &start_offset, &value, &is_memory_address);
				len = offset - start_offset;
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_state_ret_pri, 
					udvm_tvb, start_offset, len, value);
			}else{
				item2 = proto_tree_add_text(sigcomp_udvm_tree, udvm_tvb, offset, 1,
						"state_retention_priority = 0(Not in the uploaded code as UDVM buffer initalized to Zero");
				PROTO_ITEM_SET_GENERATED(item2);
			}
			if ( tvb_reported_length_remaining(udvm_tvb, offset) != 0 ){
				len = tvb_reported_length_remaining(udvm_tvb, offset);
				UDVM_address = start_address + offset;
				proto_tree_add_text(sigcomp_udvm_tree, udvm_tvb, offset, len,
						"Remaning %u bytes starting at UDVM addr %u (0x%x)- State information ?",len, UDVM_address, UDVM_address);
			}
			offset = offset + tvb_reported_length_remaining(udvm_tvb, offset);			
			break;

		default:
			offset = offset + tvb_reported_length_remaining(udvm_tvb, offset);			
			break;
		}

		
	} 
	return;
}
 /*  The simplest operand type is the literal (#), which encodes a
  * constant integer from 0 to 65535 inclusive.  A literal operand may
  * require between 1 and 3 bytes depending on its value.
  * Bytecode:                       Operand value:      Range:
  * 0nnnnnnn                        N                   0 - 127
  * 10nnnnnn nnnnnnnn               N                   0 - 16383
  * 11000000 nnnnnnnn nnnnnnnn      N                   0 - 65535
  *
  *            Figure 8: Bytecode for a literal (#) operand
  *
  */
static int
dissect_udvm_literal_operand(tvbuff_t *udvm_tvb, proto_tree *sigcomp_udvm_tree, 
							   gint offset, gint *start_offset, guint16 *value)
{
	guint bytecode;
	guint16 operand;
	guint test_bits;
	guint display_bytecode;

	bytecode = tvb_get_guint8(udvm_tvb, offset);
	test_bits = bytecode >> 7;
	if (test_bits == 1){
		test_bits = bytecode >> 6;
		if (test_bits == 2){
			/*
			 * 10nnnnnn nnnnnnnn               N                   0 - 16383
			 */
			display_bytecode = bytecode & 0xc0;
			if ( display_udvm_bytecode )
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_literal_bytecode,
					udvm_tvb, offset, 1, display_bytecode);
			operand = tvb_get_ntohs(udvm_tvb, offset) & 0x3fff;
			*value = operand;
			*start_offset = offset;
			offset = offset + 2;

		}else{
			/*
			 * 111000000 nnnnnnnn nnnnnnnn      N                   0 - 65535
			 */
			display_bytecode = bytecode & 0xc0;
			if ( display_udvm_bytecode )
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_literal_bytecode,
					udvm_tvb, offset, 1, display_bytecode);
			offset ++;
			operand = tvb_get_ntohs(udvm_tvb, offset);
			*value = operand;
			*start_offset = offset;
			offset = offset + 2;

		}
	}else{
		/*
		 * 0nnnnnnn                        N                   0 - 127
		 */
		display_bytecode = bytecode & 0xc0;
		if ( display_udvm_bytecode )
			proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_literal_bytecode,
				udvm_tvb, offset, 1, display_bytecode);
		operand = ( bytecode & 0x7f);
		*value = operand;
		*start_offset = offset;
		offset ++;
	}

	return offset;

}
/*
 * The second operand type is the reference ($), which is always used to
 * access a 2-byte value located elsewhere in the UDVM memory.  The
 * bytecode for a reference operand is decoded to be a constant integer
 * from 0 to 65535 inclusive, which is interpreted as the memory address
 * containing the actual value of the operand.
 * Bytecode:                       Operand value:      Range:
 *
 * 0nnnnnnn                        memory[2 * N]       0 - 65535
 * 10nnnnnn nnnnnnnn               memory[2 * N]       0 - 65535
 * 11000000 nnnnnnnn nnnnnnnn      memory[N]           0 - 65535
 *
 *            Figure 9: Bytecode for a reference ($) operand
 */
static int
dissect_udvm_reference_operand(tvbuff_t *udvm_tvb, proto_tree *sigcomp_udvm_tree, 
							   gint offset, gint *start_offset, guint16 *value)
{
	guint bytecode;
	guint16 operand;
	guint test_bits;
	guint display_bytecode;

	bytecode = tvb_get_guint8(udvm_tvb, offset);
	test_bits = bytecode >> 7;
	if (test_bits == 1){
		test_bits = bytecode >> 6;
		if (test_bits == 2){
			/*
			 * 10nnnnnn nnnnnnnn               memory[2 * N]       0 - 65535
			 */
			display_bytecode = bytecode & 0xc0;
			if ( display_udvm_bytecode )
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_reference_bytecode,
					udvm_tvb, offset, 1, display_bytecode);
			operand = tvb_get_ntohs(udvm_tvb, offset) & 0x3fff;
			*value = (operand * 2);
			*start_offset = offset;
			offset = offset + 2;

		}else{
			/*
			 * 11000000 nnnnnnnn nnnnnnnn      memory[N]           0 - 65535
			 */
			display_bytecode = bytecode & 0xc0;
			if ( display_udvm_bytecode )
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_reference_bytecode,
					udvm_tvb, offset, 1, display_bytecode);
			offset ++;
			operand = tvb_get_ntohs(udvm_tvb, offset);
			*value = operand;
			*start_offset = offset;
			offset = offset + 2;

		}
	}else{
		/*
		 * 0nnnnnnn                        memory[2 * N]       0 - 65535
		 */
		display_bytecode = bytecode & 0xc0;
		if ( display_udvm_bytecode )
			proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_reference_bytecode,
				udvm_tvb, offset, 1, display_bytecode);
		operand = ( bytecode & 0x7f);
		*value = (operand * 2);
		*start_offset = offset;
		offset ++;
	}

	return offset;
}

/*
 *The fourth operand type is the address (@).  This operand is decoded
 * as a multitype operand followed by a further step: the memory address
 * of the UDVM instruction containing the address operand is added to
 * obtain the correct operand value.  So if the operand value from
 * Figure 10 is D then the actual operand value of an address is
 * calculated as follows:
 *
 * operand_value = (is_memory_address_of_instruction + D) modulo 2^16
 * TODO calculate correct value for operand in case of ADDR
 */
static int
dissect_udvm_multitype_operand(tvbuff_t *udvm_tvb, proto_tree *sigcomp_udvm_tree, 
							   gint offset, gboolean is_addr _U_, gint *start_offset, guint16 *value, gboolean *is_memory_address )
{
	guint bytecode;
	guint display_bytecode;
	guint16 operand;
	guint32 result;
	guint test_bits;
	/* RFC3320
	 * Figure 10: Bytecode for a multitype (%) operand
	 * Bytecode:                       Operand value:      Range:               HEX val
	 * 00nnnnnn                        N                   0 - 63				0x00
	 * 01nnnnnn                        memory[2 * N]       0 - 65535			0x40
	 * 1000011n                        2 ^ (N + 6)        64 , 128				0x86	
	 * 10001nnn                        2 ^ (N + 8)    256 , ... , 32768			0x88
	 * 111nnnnn                        N + 65504       65504 - 65535			0xe0
	 * 1001nnnn nnnnnnnn               N + 61440       61440 - 65535			0x90
	 * 101nnnnn nnnnnnnn               N                   0 - 8191				0xa0
	 * 110nnnnn nnnnnnnn               memory[N]           0 - 65535			0xc0
	 * 10000000 nnnnnnnn nnnnnnnn      N                   0 - 65535			0x80
	 * 10000001 nnnnnnnn nnnnnnnn      memory[N]           0 - 65535			0x81
	 */
	*is_memory_address = FALSE; 
	bytecode = tvb_get_guint8(udvm_tvb, offset);
	test_bits = ( bytecode & 0xc0 ) >> 6;
	switch (test_bits ){
	case 0:
		/*  
		 * 00nnnnnn                        N                   0 - 63
		 */
		display_bytecode = bytecode & 0xc0;
		if ( display_udvm_bytecode )
		proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_multitype_bytecode,
			udvm_tvb, offset, 1, display_bytecode);
		operand = ( bytecode & 0x3f);
		*value = operand;
		*start_offset = offset;
		offset ++;
		break;
	case 1:
		/*  
		 * 01nnnnnn                        memory[2 * N]       0 - 65535
		 */
		display_bytecode = bytecode & 0xc0;
		if ( display_udvm_bytecode )
			proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_multitype_bytecode,
				udvm_tvb, offset, 1, display_bytecode);
		operand = ( bytecode & 0x3f) * 2;
		*is_memory_address = TRUE;
		*value = operand;
		*start_offset = offset;
		offset ++;
		break;
	case 2:
		/* Check tree most significant bits */
		test_bits = ( bytecode & 0xe0 ) >> 5;
		if ( test_bits == 5 ){
		/*
		 * 101nnnnn nnnnnnnn               N                   0 - 8191
		 */
			display_bytecode = bytecode & 0xe0;
			if ( display_udvm_bytecode )
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_multitype_bytecode,
					udvm_tvb, offset, 1, display_bytecode);
			operand = tvb_get_ntohs(udvm_tvb, offset) & 0x1fff;
			*value = operand;
			*start_offset = offset;
			offset = offset + 2;
		}else{
			test_bits = ( bytecode & 0xf0 ) >> 4;
			if ( test_bits == 9 ){
		/*
		 * 1001nnnn nnnnnnnn               N + 61440       61440 - 65535
		 */
				display_bytecode = bytecode & 0xf0;
				if ( display_udvm_bytecode )
					proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_multitype_bytecode,
							udvm_tvb, offset, 1, display_bytecode);
				operand = (tvb_get_ntohs(udvm_tvb, offset) & 0x0fff) + 61440;
				*start_offset = offset;
				*value = operand;
				offset = offset + 2;
			}else{
				test_bits = ( bytecode & 0x08 ) >> 3;
				if ( test_bits == 1){
		/*
		 * 10001nnn                        2 ^ (N + 8)    256 , ... , 32768
		 */
					display_bytecode = bytecode & 0xf8;
					if ( display_udvm_bytecode )
						proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_multitype_bytecode,
								udvm_tvb, offset, 1, display_bytecode);
					result = (guint32)pow(2,( bytecode & 0x07) + 8);
					operand = result & 0xffff;
					*start_offset = offset;
					*value = operand;
					offset ++;
				}else{
					test_bits = ( bytecode & 0x0e ) >> 1;
					if ( test_bits == 3 ){
						/*
						 * 1000 011n                        2 ^ (N + 6)        64 , 128
						 */
						display_bytecode = bytecode & 0xfe;
						if ( display_udvm_bytecode )
							proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_multitype_bytecode,
								udvm_tvb, offset, 1, display_bytecode);
						result = (guint32)pow(2,( bytecode & 0x01) + 6);
						operand = result & 0xffff;
						*start_offset = offset;
						*value = operand;
						offset ++;
					}else{
					/*
					 * 1000 0000 nnnnnnnn nnnnnnnn      N                   0 - 65535
					 * 1000 0001 nnnnnnnn nnnnnnnn      memory[N]           0 - 65535
					 */
						display_bytecode = bytecode;
						if ( display_udvm_bytecode )
							proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_multitype_bytecode,
								udvm_tvb, offset, 1, display_bytecode);
						if ( (bytecode & 0x01) == 1 )
							*is_memory_address = TRUE;
						offset ++;
						operand = tvb_get_ntohs(udvm_tvb, offset);
						*value = operand;
						*start_offset = offset;
						offset = offset +2;
					}


				}
			}
		}
		break;

	case 3:
		test_bits = ( bytecode & 0x20 ) >> 5;
		if ( test_bits == 1 ){
		/*
		 * 111nnnnn                        N + 65504       65504 - 65535
		 */
			display_bytecode = bytecode & 0xe0;
			if ( display_udvm_bytecode )
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_multitype_bytecode,
						udvm_tvb, offset, 1, display_bytecode);
			operand = ( bytecode & 0x1f) + 65504;
			*start_offset = offset;
			*value = operand;
			offset ++;
		}else{
		/*
		 * 110nnnnn nnnnnnnn               memory[N]           0 - 65535
		 */
			display_bytecode = bytecode & 0xe0;
			if ( display_udvm_bytecode )
				proto_tree_add_uint(sigcomp_udvm_tree, hf_udvm_multitype_bytecode,
						udvm_tvb, offset, 1, display_bytecode);
			operand = (tvb_get_ntohs(udvm_tvb, offset) & 0x1fff);
			*is_memory_address = TRUE;
			*start_offset = offset;
			*value = operand;
			offset = offset +2;
		}
			
	default :
		break;
	}
	return offset;
}

static void
tvb_raw_text_add(tvbuff_t *tvb, proto_tree *tree)
{
	proto_tree *raw_tree = NULL;
	proto_item *ti = NULL;
	int offset, next_offset, linelen;

	if(tree) {
		ti = proto_tree_add_item(tree, proto_raw_sigcomp, tvb, 0, -1, FALSE);
		raw_tree = proto_item_add_subtree(ti, ett_raw_text);
	}

	offset = 0;

	while (tvb_offset_exists(tvb, offset)) {
		tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);
		linelen = next_offset - offset;
		if(raw_tree) {
			proto_tree_add_text(raw_tree, tvb, offset, linelen,
			    "%s", tvb_format_text(tvb, offset, linelen));
		}
		offset = next_offset;
	}
}

/* Register the protocol with Ethereal */


/* If this dissector uses sub-dissector registration add a registration routine.
   This format is required because a script is used to find these routines and
   create the code that calls these routines.
*/
void
proto_reg_handoff_sigcomp(void)
{
	static dissector_handle_t sigcomp_handle;
	static int Initialized=FALSE;
	static int udp_port1 = 5555;
	static int udp_port2 = 6666;

	if (!Initialized) {
		sigcomp_handle = new_create_dissector_handle(dissect_sigcomp,
			proto_sigcomp);
		Initialized=TRUE;
	}else{
		dissector_delete("udp.port", udp_port1, sigcomp_handle);
		dissector_delete("udp.port", udp_port2, sigcomp_handle);
	}

	udp_port1 = SigCompUDPPort1;
	udp_port2 = SigCompUDPPort2;


	dissector_add("udp.port", SigCompUDPPort1, sigcomp_handle);
	dissector_add("udp.port", SigCompUDPPort2, sigcomp_handle);

	sip_handle = find_dissector("sip");


}

/* this format is require because a script is used to build the C function
   that calls all the protocol registration.
*/

void
proto_register_sigcomp(void)
{                 

/* Setup list of header fields  See Section 1.6.1 for details*/
	static hf_register_info hf[] = {
		{ &hf_sigcomp_t_bit,
			{ "T bit", "sigcomp.t.bit",
			FT_UINT8, BASE_DEC, NULL, 0x04,          
			"Sigcomp T bit", HFILL }
		},
		{ &hf_sigcomp_len,
			{ "Partial state id. len.","sigcomp.length",
			FT_UINT8, BASE_HEX, VALS(&length_encoding_vals), 0x03,          
			"Sigcomp length", HFILL }
		},
		{ &hf_sigcomp_returned_feedback_item,
			{ "Returned_feedback item", "sigcomp.returned.feedback.item",
			FT_BYTES, BASE_HEX, NULL, 0x0,          
			"Returned feedback item", HFILL }
		},
		{ &hf_sigcomp_partial_state,
			{ "Partial state identifier", "sigcomp.partial.state.identifier",
			FT_STRING, BASE_NONE, NULL, 0x0,          
			"Partial state identifier", HFILL }
		},
		{ &hf_sigcomp_returned_feedback_item_len,
			{ "Returned feedback item length", "sigcomp.returned.feedback.item.len",
			FT_UINT8, BASE_DEC, NULL, 0x0,          
			"Returned feedback item length", HFILL }
		},
		{ &hf_sigcomp_code_len,
			{ "Code length","sigcomp.code.len",
			FT_UINT16, BASE_HEX, NULL, 0x0,          
			"Code length", HFILL }
		},
		{ &hf_sigcomp_destination,
			{ "Destination","sigcomp.destination",
			FT_UINT8, BASE_HEX, VALS(&destination_address_encoding_vals), 0xf,          
			"Destination", HFILL }
		},
		{ &hf_sigcomp_udvm_instr,
			{ "UDVM instruction code","sigcomp.udvm.instr",
			FT_UINT8, BASE_DEC, VALS(&udvm_instruction_code_vals), 0x0,          
			"UDVM instruction code", HFILL }
		},
		{ &hf_udvm_multitype_bytecode,
			{ "UDVM bytecode", "sigcomp.udvm.multyt.bytecode",
			FT_UINT8, BASE_HEX, VALS(&display_bytecode_vals), 0x0,          
			"UDVM bytecode", HFILL }
		},
		{ &hf_udvm_reference_bytecode,
			{ "UDVM bytecode", "sigcomp.udvm.ref.bytecode",
			FT_UINT8, BASE_HEX, VALS(&display_ref_bytecode_vals), 0x0,          
			"UDVM bytecode", HFILL }
		},
		{ &hf_udvm_literal_bytecode,
			{ "UDVM bytecode", "sigcomp.udvm.lit.bytecode",
			FT_UINT8, BASE_HEX, VALS(&display_lit_bytecode_vals), 0x0,          
			"UDVM bytecode", HFILL }
		},
		{ &hf_udvm_operand,
			{ "UDVM operand", "sigcomp.udvm.operand",
			FT_UINT16, BASE_DEC, NULL, 0x0,          
			"UDVM operand", HFILL }
		},
		{ &hf_udvm_length,
			{ " %Length", "sigcomp.udvm.length",
			FT_UINT16, BASE_DEC, NULL, 0x0,          
			"Length", HFILL }
		},
		{ &hf_udvm_addr_length,
			{ " %Length[memory address]", "sigcomp.udvm.addr.length",
			FT_UINT16, BASE_DEC, NULL, 0x0,          
			"Length", HFILL }
		},
		{ &hf_udvm_destination,
			{ " %Destination", "sigcomp.udvm.destination",
			FT_UINT16, BASE_DEC, NULL, 0x0,          
			"Destination", HFILL }
		},
		{ &hf_udvm_addr_destination,
			{ " %Destination[memory address]", "sigcomp.udvm.addr.destination",
			FT_UINT16, BASE_DEC, NULL, 0x0,          
			"Destination", HFILL }
		},
		{ &hf_udvm_at_address,
			{ " @Address(mem_add_of_inst + D) mod 2^16)", "sigcomp.udvm.at.address",
			FT_UINT16, BASE_DEC, NULL, 0x0,          
			"Address", HFILL }
		},
		{ &hf_udvm_address,
			{ " %Address", "sigcomp.udvm.length",
			FT_UINT16, BASE_DEC, NULL, 0x0,          
			"Address", HFILL }
		},
		{ &hf_udvm_literal_num,
			{ " #n", "sigcomp.udvm.literal-num",
			FT_UINT16, BASE_DEC, NULL, 0x0,          
			"Literal number", HFILL }
		},
		{ &hf_udvm_value,
			{ " %Value", "sigcomp.udvm.value",
			FT_UINT16, BASE_DEC, NULL, 0x0,          
			"Value", HFILL }
		},
		{ &hf_udvm_addr_value,
			{ " %Value[memory address]", "sigcomp.udvm.value",
			FT_UINT16, BASE_DEC, NULL, 0x0,          
			"Value", HFILL }
		},
		{ &hf_partial_identifier_start,
			{ " %Partial identifier start", "sigcomp.udvm.partial.identifier.start",
			FT_UINT16, BASE_DEC, NULL, 0x0,          
			"Partial identifier start", HFILL }
		},
		{ &hf_partial_identifier_length,
			{ " %Partial identifier length", "sigcomp.udvm.partial.identifier.length",
			FT_UINT16, BASE_DEC, NULL, 0x0,          
			"Partial identifier length", HFILL }
		},
		{ &hf_state_begin,
			{ " %State begin", "sigcomp.udvm.state.begin",
			FT_UINT16, BASE_DEC, NULL, 0x0,          
			"State begin", HFILL }
		},
		{ &hf_udvm_state_length,
			{ " %State length", "sigcomp.udvm.state.length",
			FT_UINT16, BASE_DEC, NULL, 0x0,          
			"State length", HFILL }
		},

		{ &hf_udvm_state_length_addr,
			{ " %State length[memory address]", "sigcomp.udvm.state.length.addr",
			FT_UINT16, BASE_DEC, NULL, 0x0,          
			"State length", HFILL }
		},
		{ &hf_udvm_state_address,
			{ " %State address", "sigcomp.udvm.start.address",
			FT_UINT16, BASE_DEC, NULL, 0x0,          
			"State address", HFILL }
		},
		{ &hf_udvm_state_address_addr,
			{ " %State address[memory address]", "sigcomp.udvm.start.address.addr",
			FT_UINT16, BASE_DEC, NULL, 0x0,          
			"State address", HFILL }
		},
		{ &hf_udvm_state_instr,
			{ " %State instruction", "sigcomp.udvm.start.instr",
			FT_UINT16, BASE_DEC, NULL, 0x0,          
			"State instruction", HFILL }
		},
		{ &hf_udvm_operand_1,
			{ " $Operand 1[memory address]", "sigcomp.udvm.operand.1",
			FT_UINT16, BASE_DEC, NULL, 0x0,          
			"Reference $ Operand 1", HFILL }
		},
		{ &hf_udvm_operand_2,
			{ " %Operand 2", "sigcomp.udvm.operand.2",
			FT_UINT16, BASE_DEC, NULL, 0x0,          
			"Operand 2", HFILL }
		},
		{ &hf_udvm_operand_2_addr,
			{ " %Operand 2[memory address]", "sigcomp.udvm.operand.2.addr",
			FT_UINT16, BASE_DEC, NULL, 0x0,          
			"Operand 2", HFILL }
		},
		{ &hf_udvm_j,
			{ " %j", "sigcomp.udvm.j",
			FT_UINT16, BASE_DEC, NULL, 0x0,          
			"j", HFILL }
		},
		{ &hf_udvm_addr_j,
			{ " %j[memory address]", "sigcomp.udvm.addr.j",
			FT_UINT16, BASE_DEC, NULL, 0x0,          
			"j", HFILL }
		},
		{ &hf_udvm_output_start,
			{ " %Output_start", "sigcomp.output.start",
			FT_UINT16, BASE_DEC, NULL, 0x0,          
			"Output start", HFILL }
		},
		{ &hf_udvm_addr_output_start,
			{ " %Output_start[memory address]", "sigcomp.addr.output.start",
			FT_UINT16, BASE_DEC, NULL, 0x0,          
			"Output start", HFILL }
		},
		{ &hf_udvm_output_length,
			{ " %Output_length", "sigcomp.output.length",
			FT_UINT16, BASE_DEC, NULL, 0x0,          
			"Output length", HFILL }
		},
		{ &hf_udvm_output_length_addr,
			{ " %Output_length[memory address]", "sigcomp.output.length.addr",
			FT_UINT16, BASE_DEC, NULL, 0x0,          
			"Output length", HFILL }
		},
		{ &hf_udvm_req_feedback_loc,
			{ " %Requested feedback location", "sigcomp.req.feedback.loc",
			FT_UINT16, BASE_DEC, NULL, 0x0,
			"Requested feedback location", HFILL }
		},
		{ &hf_udvm_min_acc_len,
			{ " %Minimum access length", "sigcomp.min.acc.len",
			FT_UINT16, BASE_DEC, NULL, 0x0,          
			"Output length", HFILL }
		},
		{ &hf_udvm_state_ret_pri,
			{ " %State retention priority", "sigcomp.udvm.state.ret.pri",
			FT_UINT16, BASE_DEC, NULL, 0x0,          
			"Output length", HFILL }
		},
		{ &hf_udvm_ret_param_loc,
			{ " %Returned parameters location", "sigcomp.ret.param.loc",
			FT_UINT16, BASE_DEC, NULL, 0x0,          
			"Output length", HFILL }
		},
		{ &hf_udvm_position,
			{ " %Position", "sigcomp.udvm.position",
			FT_UINT16, BASE_DEC, NULL, 0x0,          
			"Position", HFILL }
		},
		{ &hf_udvm_ref_dest,
			{ " $Destination[memory address]", "sigcomp.udvm.ref.destination",
			FT_UINT16, BASE_DEC, NULL, 0x0,          
			"(reference)Destination", HFILL }
		},
		{ &hf_udvm_bits,
			{ " %Bits", "sigcomp.udvm.bits",
			FT_UINT16, BASE_DEC, NULL, 0x0,          
			"Bits", HFILL }
		},
		{ &hf_udvm_lower_bound,
			{ " %Lower bound", "sigcomp.udvm.lower.bound",
			FT_UINT16, BASE_DEC, NULL, 0x0,          
			"Lower_bound", HFILL }
		},
		{ &hf_udvm_upper_bound,
			{ " %Upper bound", "sigcomp.udvm.upper.bound",
			FT_UINT16, BASE_DEC, NULL, 0x0,          
			"Upper bound", HFILL }
		},
		{ &hf_udvm_uncompressed,
			{ " %Uncompressed", "sigcomp.udvm.uncompressed",
			FT_UINT16, BASE_DEC, NULL, 0x0,          
			"Uncompressed", HFILL }
		},
		{ &hf_udvm_start_value,
			{ " %Start value", "sigcomp.udvm.start.value",
			FT_UINT16, BASE_DEC, NULL, 0x0,          
			"Start value", HFILL }
		},
		{ &hf_udvm_offset,
			{ " %Offset", "sigcomp.udvm.offset",
			FT_UINT16, BASE_DEC, NULL, 0x0,          
			"Offset", HFILL }
		},
		{ &hf_udvm_addr_offset,
			{ " %Offset[memory address]", "sigcomp.udvm.addr.offset",
			FT_UINT16, BASE_DEC, NULL, 0x0,          
			"Offset", HFILL }
		},
	};

/* Setup protocol subtree array */
	static gint *ett[] = {
		&ett_sigcomp,
		&ett_sigcomp_udvm,
		&ett_sigcomp_udvm_exe,
	};
	static gint *ett_raw[] = {
		&ett_raw_text,
	};

	module_t *sigcomp_module;
    static enum_val_t udvm_detail_vals[] = {
	{"no-printout", "No-Printout", 0},
	{"low-detail", "Low-detail", 1},
	{"medium-detail", "medium-detail", 2},
	{"high-detail", "High-detail", 3},
	{NULL, NULL, -1}
    };


/* Register the protocol name and description */
	proto_sigcomp = proto_register_protocol("Signaling Compression",
	    "SIGCOMP", "sigcomp");
	proto_raw_sigcomp = proto_register_protocol("Decompressed SigComp message as raw text",
		"Raw_SigComp", "raw_sigcomp");

	new_register_dissector("sigcomp", dissect_sigcomp, proto_sigcomp);

/* Required function calls to register the header fields and subtrees used */
	proto_register_field_array(proto_sigcomp, hf, array_length(hf));
	proto_register_subtree_array(ett, array_length(ett));
	proto_register_subtree_array(ett_raw, array_length(ett_raw));

/* Register a configuration option for port */
	sigcomp_module = prefs_register_protocol(proto_sigcomp,
											  proto_reg_handoff_sigcomp);

	prefs_register_uint_preference(sigcomp_module, "udp.port",
								   "Sigcomp UDP Port 1",
								   "Set UDP port 1 for SigComp messages",
								   10,
								   &SigCompUDPPort1);

	prefs_register_uint_preference(sigcomp_module, "udp.port2",
								   "Sigcomp UDP Port 2",
								   "Set UDP port 2 for SigComp messages",
								   10,
								   &SigCompUDPPort2);
	prefs_register_bool_preference(sigcomp_module, "display.udvm.code",
								   "Dissect the UDVM code",
								   "Preference wether to Dissect the UDVM code or not",
								   &dissect_udvm_code);

	prefs_register_bool_preference(sigcomp_module, "display.bytecode",
								   "Display the bytecode of operands",
								   "preference wether to display the bytecode in UDVM operands or not",
								   &display_udvm_bytecode);
	prefs_register_bool_preference(sigcomp_module, "decomp.msg",
								   "Decompress message",
								   "preference wether to decompress message or not",
								   &decompress);
	prefs_register_bool_preference(sigcomp_module, "display.decomp.msg.as.txt",
								   "Displays the decompressed message as text",
								   "preference wether to display the decompressed message as raw text or not",
								   &display_raw_txt);
    prefs_register_enum_preference(sigcomp_module, "show.udvm.execution",
      "Level of detail of UDVM execution",
      "0 = UDVM executes silently, then incrising detail about execution of UDVM instructions, Warning! CPU intense at high detail",
      &udvm_print_detail_level, udvm_detail_vals, FALSE);

	register_init_routine(&sigcomp_init_protocol);



}