1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
|
/* packet-vnc.c
* Routines for VNC dissection (Virtual Network Computing)
* Copyright 2005, Ulf Lamping <ulf.lamping@web.de>
* Copyright 2006-2007, Stephen Fisher <stephentfisher@yahoo.com>
*
* $Id$
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* 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.
*/
/* Dissection of the VNC (Virtual Network Computing) network traffic.
*
* All versions of RealVNC and TightVNC are supported.
* Note: The addition of TightVNC support is not yet complete.
*
* Several VNC implementations available, see:
* http://www.realvnc.com/
* http://www.tightvnc.com/
* http://ultravnc.sourceforge.net/
* ...
*
* The protocol itself is known as RFB - Remote Frame Buffer Protocol.
*
* This code is based on the protocol specification:
* http://www.realvnc.com/docs/rfbproto.pdf
* and the RealVNC free edition & TightVNC source code
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <glib.h>
#include <epan/conversation.h>
#include <epan/emem.h>
#include <epan/packet.h>
#include <epan/prefs.h>
#include "packet-x11-keysym.h" /* This contains the X11 value_string
* "keysym_vals_source" that VNC also uses. */
static const value_string security_types_vs[] = {
{ 0, "Invalid" },
{ 1, "None" },
{ 2, "VNC" },
{ 5, "RA2" },
{ 6, "RA2ne" },
{ 16, "Tight" },
{ 17, "Ultra" },
{ 18, "TLS" },
{ 19, "VeNCrypt" },
{ 0, NULL }
};
typedef enum {
INVALID = 0,
NONE = 1,
VNC = 2,
RA2 = 5,
RA2ne = 6,
TIGHT = 16,
ULTRA = 17,
TLS = 18,
VENCRYPT = 19
} security_types_e;
static const value_string auth_result_vs[] = {
{ 0, "OK" },
{ 1, "Failed" },
{ 0, NULL }
};
static const value_string yes_no_vs[] = {
{ 0, "No" },
{ 1, "Yes" },
{ 0, NULL }
};
static const value_string client_message_types_vs[] = {
{ 0, "Set Pixel Format" },
{ 2, "Set Encodings" },
{ 3, "Framebuffer Update Request" },
{ 4, "Key Event" },
{ 5, "Pointer Event" },
{ 6, "Cut Text" },
{ 0, NULL }
};
static const value_string server_message_types_vs[] = {
{ 0, "Framebuffer Update" },
{ 1, "Set Colormap Entries" },
{ 2, "Ring Bell" },
{ 3, "Cut Text" },
{ 0, NULL }
};
static const value_string button_mask_vs[] = {
{ 0, "Not pressed" },
{ 1, "Pressed" },
{ 0, NULL }
};
static const value_string encoding_types_vs[] = {
{ -239, "Cursor (pseudo)" },
{ -223, "DesktopSize (pseudo)" },
{ 0, "Raw" },
{ 1, "CopyRect" },
{ 2, "RRE" },
{ 4, "CoRRE" },
{ 5, "Hextile" },
{ 6, "Zlib" },
{ 7, "Tight" },
{ 8, "ZlibHex" },
{ 16, "ZRLE" },
{ 0, NULL }
};
typedef enum {
SERVER_VERSION,
CLIENT_VERSION,
SECURITY,
SECURITY_TYPES,
TIGHT_UNKNOWN_PACKET1,
TIGHT_UNKNOWN_PACKET2,
TIGHT_AUTH_TYPE_AND_VENDOR_CODE,
TIGHT_UNKNOWN_PACKET3,
VNC_AUTHENTICATION_CHALLENGE,
VNC_AUTHENTICATION_RESPONSE,
SECURITY_RESULT,
CLIENT_INIT,
SERVER_INIT,
TIGHT_INTERACTION_CAPS,
TIGHT_UNKNOWN_PACKET4,
NORMAL_TRAFFIC
} vnc_session_state_e;
/* This structure will be tied to each conversation. */
typedef struct {
guint8 security_type_selected;
gdouble server_proto_ver, client_proto_ver;
vnc_session_state_e vnc_next_state;
} vnc_conversation_t;
/* This structure will be tied to each packet */
typedef struct {
guint8 bytes_per_pixel;
vnc_session_state_e state;
} vnc_packet_t;
void proto_reg_handoff_vnc(void);
static gboolean vnc_startup_messages(tvbuff_t *tvb, packet_info *pinfo,
gint offset, proto_tree *tree,
vnc_conversation_t *per_conversation_info);
static void vnc_client_to_server(tvbuff_t *tvb, packet_info *pinfo,
gint *offset, proto_tree *tree);
static void vnc_server_to_client(tvbuff_t *tvb, packet_info *pinfo,
gint *offset, proto_tree *tree);
static void vnc_client_set_pixel_format(tvbuff_t *tvb, packet_info *pinfo,
gint *offset, proto_tree *tree);
static void vnc_client_set_encodings(tvbuff_t *tvb, packet_info *pinfo,
gint *offset, proto_tree *tree);
static void vnc_client_framebuffer_update_request(tvbuff_t *tvb,
packet_info *pinfo,
gint *offset,
proto_tree *tree);
static void vnc_client_key_event(tvbuff_t *tvb, packet_info *pinfo,
gint *offset, proto_tree *tree);
static void vnc_client_pointer_event(tvbuff_t *tvb, packet_info *pinfo,
gint *offset, proto_tree *tree);
static void vnc_client_cut_text(tvbuff_t *tvb, packet_info *pinfo, gint *offset,
proto_tree *tree);
static guint vnc_server_framebuffer_update(tvbuff_t *tvb, packet_info *pinfo,
gint *offset, proto_tree *tree);
static guint vnc_raw_encoding(tvbuff_t *tvb, packet_info *pinfo, gint *offset,
proto_tree *tree, guint16 width, guint16 height);
static guint vnc_copyrect_encoding(tvbuff_t *tvb, packet_info *pinfo,
gint *offset, proto_tree *tree,
guint16 width, guint16 height);
static guint vnc_rre_encoding(tvbuff_t *tvb, packet_info *pinfo, gint *offset,
proto_tree *tree, guint16 width, guint16 height);
static guint vnc_hextile_encoding(tvbuff_t *tvb, packet_info *pinfo,
gint *offset, proto_tree *tree,
guint16 width, guint16 height);
static guint vnc_zrle_encoding(tvbuff_t *tvb, packet_info *pinfo, gint *offset,
proto_tree *tree, guint16 width, guint16 height);
static guint vnc_cursor_encoding(tvbuff_t *tvb, packet_info *pinfo,
gint *offset, proto_tree *tree, guint16 width,
guint16 height);
static guint vnc_server_set_colormap_entries(tvbuff_t *tvb, packet_info *pinfo,
gint *offset, proto_tree *tree);
static void vnc_server_ring_bell(tvbuff_t *tvb, packet_info *pinfo,
gint *offset, proto_tree *tree);
static guint vnc_server_cut_text(tvbuff_t *tvb, packet_info *pinfo,
gint *offset, proto_tree *tree);
static void vnc_set_bytes_per_pixel(packet_info *pinfo, guint8 bytes_per_pixel);
static guint8 vnc_get_bytes_per_pixel(packet_info *pinfo);
#define DEST_PORT_VNC pinfo->destport == 5500 || pinfo->destport == 5501 || \
pinfo->destport == 5900 || pinfo->destport == 5901 || \
pinfo->destport == vnc_preference_alternate_port
#define VNC_BYTES_NEEDED(a) \
if(a > (guint)tvb_length_remaining(tvb, *offset)) \
return a;
/* Variables for our preferences */
static guint vnc_preference_alternate_port = 0;
/* Initialize the protocol and registered fields */
static int proto_vnc = -1; /* Protocol subtree */
static int hf_vnc_padding = -1;
static int hf_vnc_server_proto_ver = -1;
static int hf_vnc_client_proto_ver = -1;
static int hf_vnc_num_security_types = -1;
static int hf_vnc_security_type = -1;
static int hf_vnc_server_security_type = -1;
static int hf_vnc_client_security_type = -1;
static int hf_vnc_vendor_code = -1;
static int hf_vnc_security_type_string = -1;
static int hf_vnc_auth_challenge = -1;
static int hf_vnc_auth_response = -1;
static int hf_vnc_auth_result = -1;
static int hf_vnc_auth_error = -1;
static int hf_vnc_share_desktop_flag = -1;
static int hf_vnc_width = -1;
static int hf_vnc_height = -1;
static int hf_vnc_server_bits_per_pixel = -1;
static int hf_vnc_server_depth = -1;
static int hf_vnc_server_big_endian_flag = -1;
static int hf_vnc_server_true_color_flag = -1;
static int hf_vnc_server_red_max = -1;
static int hf_vnc_server_green_max = -1;
static int hf_vnc_server_blue_max = -1;
static int hf_vnc_server_red_shift = -1;
static int hf_vnc_server_green_shift = -1;
static int hf_vnc_server_blue_shift = -1;
static int hf_vnc_desktop_name = -1;
static int hf_vnc_desktop_name_len = -1;
static int hf_vnc_num_server_message_types = -1;
static int hf_vnc_num_client_message_types = -1;
static int hf_vnc_num_encoding_types = -1;
/********** Client Message Types **********/
static int hf_vnc_client_message_type = -1; /* A subtree under VNC */
static int hf_vnc_client_bits_per_pixel = -1;
static int hf_vnc_client_depth = -1;
static int hf_vnc_client_big_endian_flag = -1;
static int hf_vnc_client_true_color_flag = -1;
static int hf_vnc_client_red_max = -1;
static int hf_vnc_client_green_max = -1;
static int hf_vnc_client_blue_max = -1;
static int hf_vnc_client_red_shift = -1;
static int hf_vnc_client_green_shift = -1;
static int hf_vnc_client_blue_shift = -1;
/* Client Key Event */
static int hf_vnc_key_down = -1;
static int hf_vnc_key = -1;
/* Client Pointer Event */
static int hf_vnc_button_1_pos = -1;
static int hf_vnc_button_2_pos = -1;
static int hf_vnc_button_3_pos = -1;
static int hf_vnc_button_4_pos = -1;
static int hf_vnc_button_5_pos = -1;
static int hf_vnc_button_6_pos = -1;
static int hf_vnc_button_7_pos = -1;
static int hf_vnc_button_8_pos = -1;
static int hf_vnc_pointer_x_pos = -1;
static int hf_vnc_pointer_y_pos = -1;
/* Client Framebuffer Update Request */
static int hf_vnc_update_req_incremental = -1;
static int hf_vnc_update_req_x_pos = -1;
static int hf_vnc_update_req_y_pos = -1;
static int hf_vnc_update_req_width = -1;
static int hf_vnc_update_req_height = -1;
/* Client Set Encodings */
static int hf_vnc_client_set_encodings_encoding_type = -1;
/* Client Cut Text */
static int hf_vnc_client_cut_text_len = -1;
static int hf_vnc_client_cut_text = -1;
/********** Server Message Types **********/
static int hf_vnc_server_message_type = -1; /* Subtree */
/* Server Framebuffer Update */
static int hf_vnc_fb_update_x_pos = -1;
static int hf_vnc_fb_update_y_pos = -1;
static int hf_vnc_fb_update_width = -1;
static int hf_vnc_fb_update_height = -1;
static int hf_vnc_fb_update_encoding_type = -1;
/* Raw Encoding */
static int hf_vnc_raw_pixel_data = -1;
/* CopyRect Encoding */
static int hf_vnc_copyrect_src_x_pos = -1;
static int hf_vnc_copyrect_src_y_pos = -1;
/* RRE Encoding */
static int hf_vnc_rre_num_subrects = -1;
static int hf_vnc_rre_bg_pixel = -1;
static int hf_vnc_rre_subrect_pixel = -1;
static int hf_vnc_rre_subrect_x_pos = -1;
static int hf_vnc_rre_subrect_y_pos = -1;
static int hf_vnc_rre_subrect_width = -1;
static int hf_vnc_rre_subrect_height = -1;
/* Hextile Encoding */
static int hf_vnc_hextile_subencoding_mask = -1;
static int hf_vnc_hextile_raw = -1;
static int hf_vnc_hextile_raw_value = -1;
static int hf_vnc_hextile_bg = -1;
static int hf_vnc_hextile_bg_value = -1;
static int hf_vnc_hextile_fg = -1;
static int hf_vnc_hextile_fg_value = -1;
static int hf_vnc_hextile_anysubrects = -1;
static int hf_vnc_hextile_num_subrects = -1;
static int hf_vnc_hextile_subrectscolored = -1;
static int hf_vnc_hextile_subrect_pixel_value = -1;
static int hf_vnc_hextile_subrect_x_pos = -1;
static int hf_vnc_hextile_subrect_y_pos = -1;
static int hf_vnc_hextile_subrect_width = -1;
static int hf_vnc_hextile_subrect_height = -1;
/* ZRLE Encoding */
static int hf_vnc_zrle_len = -1;
static int hf_vnc_zrle_subencoding = -1;
static int hf_vnc_zrle_rle = -1;
static int hf_vnc_zrle_palette_size = -1;
static int hf_vnc_zrle_data = -1;
static int hf_vnc_zrle_raw = -1;
static int hf_vnc_zrle_palette = -1;
/* Cursor Encoding */
static int hf_vnc_cursor_encoding_pixels = -1;
static int hf_vnc_cursor_encoding_bitmask = -1;
/* Server Set Colormap Entries */
static int hf_vnc_colormap_first_color = -1;
static int hf_vnc_colormap_num_colors = -1;
static int hf_vnc_colormap_red = -1;
static int hf_vnc_colormap_green = -1;
static int hf_vnc_colormap_blue = -1;
/* Server Cut Text */
static int hf_vnc_server_cut_text_len = -1;
static int hf_vnc_server_cut_text = -1;
/********** End of Server Message Types **********/
static gboolean vnc_preference_desegment = TRUE;
/* Initialize the subtree pointers */
static gint ett_vnc = -1;
static gint ett_vnc_client_message_type = -1;
static gint ett_vnc_server_message_type = -1;
static gint ett_vnc_rect = -1;
static gint ett_vnc_encoding_type = -1;
static gint ett_vnc_rre_subrect = -1;
static gint ett_vnc_hextile_subencoding_mask = -1;
static gint ett_vnc_hextile_num_subrects = -1;
static gint ett_vnc_hextile_subrect = -1;
static gint ett_vnc_zrle_subencoding = -1;
static gint ett_vnc_colormap_num_groups = -1;
static gint ett_vnc_colormap_color_group = -1;
guint8 vnc_bytes_per_pixel; /* Global so it keeps its value between packets */
/* Code to dissect the packets */
static void
dissect_vnc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
gboolean ret;
gint offset = 0;
/* Set up structures needed to add the protocol subtree and manage it */
proto_item *ti=NULL;
proto_tree *vnc_tree=NULL;
conversation_t *conversation;
vnc_conversation_t *per_conversation_info;
conversation = find_conversation(pinfo->fd->num, &pinfo->src,
&pinfo->dst, pinfo->ptype,
pinfo->srcport, pinfo->destport, 0);
if(!conversation) { /* Conversation does not exist yet - create it */
conversation = conversation_new(pinfo->fd->num, &pinfo->src,
&pinfo->dst, pinfo->ptype,
pinfo->srcport,
pinfo->destport, 0);
}
/* Retrieve information from conversation, or add it if it isn't
* there yet */
per_conversation_info = conversation_get_proto_data(conversation,
proto_vnc);
if(!per_conversation_info) {
per_conversation_info = se_alloc(sizeof(vnc_conversation_t));
per_conversation_info->vnc_next_state = SERVER_VERSION;
conversation_add_proto_data(conversation, proto_vnc,
per_conversation_info);
}
/* 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, "VNC");
/* First, clear the info column */
if(check_col(pinfo->cinfo, COL_INFO))
col_clear(pinfo->cinfo, COL_INFO);
/* create display subtree for the protocol */
if(tree) {
ti = proto_tree_add_item(tree, proto_vnc, tvb, 0, -1, FALSE);
vnc_tree = proto_item_add_subtree(ti, ett_vnc);
}
offset = 0; /* Start at the beginning of the VNC protocol data */
/* Dissect any remaining session startup messages */
ret = vnc_startup_messages(tvb, pinfo, offset, vnc_tree,
per_conversation_info);
vnc_set_bytes_per_pixel(pinfo, vnc_bytes_per_pixel);
if(!ret) {
if(DEST_PORT_VNC)
vnc_client_to_server(tvb, pinfo, &offset, vnc_tree);
else
vnc_server_to_client(tvb, pinfo, &offset, vnc_tree);
}
}
/* Returns true if additional session startup messages follow */
static gboolean
vnc_startup_messages(tvbuff_t *tvb, packet_info *pinfo, gint offset,
proto_tree *tree, vnc_conversation_t
*per_conversation_info)
{
guint8 num_security_types;
gchar *vendor;
guint32 desktop_name_len, auth_result, text_len;
vnc_packet_t *per_packet_info;
proto_item *ti;
per_packet_info = p_get_proto_data(pinfo->fd, proto_vnc);
if(!per_packet_info) {
per_packet_info = se_alloc(sizeof(vnc_packet_t));
per_packet_info->state = per_conversation_info->vnc_next_state;
p_add_proto_data(pinfo->fd, proto_vnc, per_packet_info);
}
/* Packet dissection follows */
switch(per_packet_info->state) {
case SERVER_VERSION :
proto_tree_add_item(tree, hf_vnc_server_proto_ver, tvb, 4,
7, FALSE);
per_conversation_info->server_proto_ver =
g_strtod((char *)tvb_get_ephemeral_string(tvb, 4, 7),
NULL);
if (check_col(pinfo->cinfo, COL_INFO))
col_add_fstr(pinfo->cinfo, COL_INFO,
"Server protocol version: %s",
tvb_format_text(tvb, 4, 7));
per_conversation_info->vnc_next_state = CLIENT_VERSION;
break;
case CLIENT_VERSION :
proto_tree_add_item(tree, hf_vnc_client_proto_ver, tvb,
4, 7, FALSE);
per_conversation_info->client_proto_ver =
g_strtod((char *)tvb_get_ephemeral_string(tvb, 4, 7),
NULL);
if (check_col(pinfo->cinfo, COL_INFO))
col_add_fstr(pinfo->cinfo, COL_INFO,
"Client protocol version: %s",
tvb_format_text(tvb, 4, 7));
per_conversation_info->vnc_next_state = SECURITY;
break;
case SECURITY :
if (check_col(pinfo->cinfo, COL_INFO))
col_set_str(pinfo->cinfo, COL_INFO,
"Security types supported");
/* We're checking against the client protocol version because
* the client is the final decider on which version to use
* after the server offers the highest version it supports. */
if(per_conversation_info->client_proto_ver >= 3.007) {
proto_tree_add_item(tree,
hf_vnc_num_security_types, tvb,
offset, 1, FALSE);
num_security_types = tvb_get_guint8(tvb, offset);
for(offset = 1; offset <= num_security_types; offset++){
proto_tree_add_item(tree,
hf_vnc_security_type, tvb,
offset, 1, FALSE);
}
} else {
/* Version < 3.007: The server decides the
* authentication type for us to use */
proto_tree_add_item(tree,
hf_vnc_server_security_type, tvb,
offset, 4, FALSE);
}
per_conversation_info->vnc_next_state = SECURITY_TYPES;
break;
case SECURITY_TYPES :
if (check_col(pinfo->cinfo, COL_INFO))
col_set_str(pinfo->cinfo, COL_INFO,
"Authentication type selected by client");
proto_tree_add_item(tree, hf_vnc_client_security_type, tvb,
offset, 1, FALSE);
per_conversation_info->security_type_selected =
tvb_get_guint8(tvb, offset);
switch(per_conversation_info->security_type_selected) {
case 1 : /* None */
if(per_conversation_info->client_proto_ver >= 3.008)
per_conversation_info->vnc_next_state =
SECURITY_RESULT;
else
per_conversation_info->vnc_next_state =
CLIENT_INIT;
break;
case 2 : /* VNC */
per_conversation_info->vnc_next_state =
VNC_AUTHENTICATION_CHALLENGE;
break;
case 16 : /* Tight */
per_conversation_info->vnc_next_state =
TIGHT_UNKNOWN_PACKET1;
default :
/* Security type not supported by this dissector */
break;
}
break;
case TIGHT_UNKNOWN_PACKET1 :
if (check_col(pinfo->cinfo, COL_INFO))
col_set_str(pinfo->cinfo, COL_INFO,
"Unknown packet (TightVNC)");
proto_tree_add_text(tree, tvb, offset, -1,
"Unknown packet (TightVNC)");
per_conversation_info->vnc_next_state =
TIGHT_UNKNOWN_PACKET2;
break;
case TIGHT_UNKNOWN_PACKET2 :
if (check_col(pinfo->cinfo, COL_INFO))
col_set_str(pinfo->cinfo, COL_INFO,
"Unknown packet (TightVNC)");
proto_tree_add_text(tree, tvb, offset, -1,
"Unknown packet (TightVNC)");
per_conversation_info->vnc_next_state =
TIGHT_AUTH_TYPE_AND_VENDOR_CODE;
break;
case TIGHT_AUTH_TYPE_AND_VENDOR_CODE :
if (check_col(pinfo->cinfo, COL_INFO))
col_set_str(pinfo->cinfo, COL_INFO,
"Authentication type / vendor code");
proto_tree_add_item(tree, hf_vnc_server_security_type, tvb,
offset, 4, FALSE);
offset += 4;
/* Display vendor code */
vendor = tvb_get_ephemeral_string(tvb, offset, 4);
ti = proto_tree_add_string(tree, hf_vnc_vendor_code, tvb,
offset, 4, vendor);
if(g_ascii_strcasecmp(vendor, "STDV") == 0)
proto_item_append_text(ti, " (Standard VNC vendor)");
else if(g_ascii_strcasecmp(vendor, "TRDV") == 0)
proto_item_append_text(ti, " (Tridia VNC vendor)");
else if(g_ascii_strcasecmp(vendor, "TGHT") == 0)
proto_item_append_text(ti, " (Tight VNC vendor)");
offset += 4;
/* Display authentication method string */
proto_tree_add_item(tree, hf_vnc_security_type_string, tvb,
offset, 8, FALSE);
per_conversation_info->vnc_next_state =
TIGHT_UNKNOWN_PACKET3;
break;
case TIGHT_UNKNOWN_PACKET3 :
if (check_col(pinfo->cinfo, COL_INFO))
col_set_str(pinfo->cinfo, COL_INFO,
"Unknown packet (TightVNC)");
proto_tree_add_text(tree, tvb, offset, -1,
"Unknown packet (TightVNC)");
per_conversation_info->vnc_next_state =
VNC_AUTHENTICATION_CHALLENGE;
break;
case VNC_AUTHENTICATION_CHALLENGE :
if (check_col(pinfo->cinfo, COL_INFO))
col_set_str(pinfo->cinfo, COL_INFO,
"Authentication challenge from server");
proto_tree_add_item(tree, hf_vnc_auth_challenge, tvb,
offset, 16, FALSE);
per_conversation_info->vnc_next_state =
VNC_AUTHENTICATION_RESPONSE;
break;
case VNC_AUTHENTICATION_RESPONSE :
if (check_col(pinfo->cinfo, COL_INFO))
col_set_str(pinfo->cinfo, COL_INFO,
"Authentication response from client");
proto_tree_add_item(tree, hf_vnc_auth_response, tvb,
offset, 16, FALSE);
per_conversation_info->vnc_next_state = SECURITY_RESULT;
break;
case SECURITY_RESULT :
if (check_col(pinfo->cinfo, COL_INFO))
col_set_str(pinfo->cinfo, COL_INFO,
"Authentication result");
proto_tree_add_item(tree, hf_vnc_auth_result, tvb, offset,
4, FALSE);
auth_result = tvb_get_ntohl(tvb, offset);
offset += 4;
switch(auth_result) {
case 0 : /* OK */
per_conversation_info->vnc_next_state = CLIENT_INIT;
break;
case 1 : /* Failed */
if(per_conversation_info->client_proto_ver >= 3.008) {
text_len = tvb_get_ntohl(tvb, offset);
proto_tree_add_text(tree, tvb, offset, 4, "Length of authentication error: %d", text_len);
offset += 4;
proto_tree_add_item(tree, hf_vnc_auth_error, tvb,
offset, text_len, FALSE);
offset += text_len;
}
return TRUE; /* All versions: Do not continue
processing VNC packets as connection
will be closed after this packet. */
break;
}
break;
case CLIENT_INIT :
if (check_col(pinfo->cinfo, COL_INFO))
col_set_str(pinfo->cinfo, COL_INFO,
"Share desktop flag");
proto_tree_add_item(tree, hf_vnc_share_desktop_flag, tvb,
offset, 1, FALSE);
per_conversation_info->vnc_next_state = SERVER_INIT;
break;
case SERVER_INIT :
if (check_col(pinfo->cinfo, COL_INFO))
col_set_str(pinfo->cinfo, COL_INFO,
"Server framebuffer parameters");
proto_tree_add_item(tree, hf_vnc_width, tvb, offset, 2,
FALSE);
offset += 2;
proto_tree_add_item(tree, hf_vnc_height, tvb, offset, 2,
FALSE);
offset += 2;
proto_tree_add_item(tree, hf_vnc_server_bits_per_pixel,
tvb, offset, 1, FALSE);
vnc_bytes_per_pixel = tvb_get_guint8(tvb, offset)/8;
vnc_set_bytes_per_pixel(pinfo, vnc_bytes_per_pixel);
offset += 1;
proto_tree_add_item(tree, hf_vnc_server_depth, tvb, offset,
1, FALSE);
offset += 1;
proto_tree_add_item(tree, hf_vnc_server_big_endian_flag,
tvb, offset, 1, FALSE);
offset += 1;
proto_tree_add_item(tree, hf_vnc_server_true_color_flag,
tvb, offset, 1, FALSE);
offset += 1;
proto_tree_add_item(tree, hf_vnc_server_red_max,
tvb, offset, 2, FALSE);
offset += 2;
proto_tree_add_item(tree, hf_vnc_server_green_max,
tvb, offset, 2, FALSE);
offset += 2;
proto_tree_add_item(tree, hf_vnc_server_blue_max,
tvb, offset, 2, FALSE);
offset += 2;
proto_tree_add_item(tree, hf_vnc_server_red_shift,
tvb, offset, 1, FALSE);
offset += 1;
proto_tree_add_item(tree, hf_vnc_server_green_shift,
tvb, offset, 1, FALSE);
offset += 1;
proto_tree_add_item(tree, hf_vnc_server_blue_shift,
tvb, offset, 1, FALSE);
offset += 1;
proto_tree_add_item(tree, hf_vnc_padding,
tvb, offset, 3, FALSE);
offset += 3; /* Skip over 3 bytes of padding */
if(tvb_length_remaining(tvb, offset) > 0) {
/* Sometimes the desktop name & length is skipped */
proto_tree_add_item(tree, hf_vnc_desktop_name_len,
tvb, offset, 4, FALSE);
desktop_name_len = tvb_get_ntohl(tvb, offset);
offset += 4;
proto_tree_add_item(tree, hf_vnc_desktop_name,
tvb, offset, desktop_name_len,
FALSE);
}
if(per_conversation_info->security_type_selected == TIGHT)
per_conversation_info->vnc_next_state =
TIGHT_INTERACTION_CAPS;
else
per_conversation_info->vnc_next_state = NORMAL_TRAFFIC;
break;
case TIGHT_INTERACTION_CAPS :
if (check_col(pinfo->cinfo, COL_INFO))
col_set_str(pinfo->cinfo, COL_INFO,
"Interaction Capabilities");
proto_tree_add_item(tree, hf_vnc_num_server_message_types,
tvb, offset, 2, FALSE);
offset += 2;
proto_tree_add_item(tree, hf_vnc_num_client_message_types,
tvb, offset, 2, FALSE);
offset += 2;
proto_tree_add_item(tree, hf_vnc_num_encoding_types,
tvb, offset, 2, FALSE);
offset += 2;
proto_tree_add_item(tree, hf_vnc_padding, tvb, offset, 2,
FALSE);
/* XXX - Display lists of server and client messages, the
* number of each in the packet is found above. */
per_conversation_info->vnc_next_state = TIGHT_UNKNOWN_PACKET4;
break;
case TIGHT_UNKNOWN_PACKET4 :
if (check_col(pinfo->cinfo, COL_INFO))
col_set_str(pinfo->cinfo, COL_INFO,
"Unknown packet (TightVNC)");
proto_tree_add_text(tree, tvb, offset, -1,
"Unknown packet (TightVNC)");
per_conversation_info->vnc_next_state = NORMAL_TRAFFIC;
break;
case NORMAL_TRAFFIC :
return FALSE;
}
return TRUE;
}
static void
vnc_client_to_server(tvbuff_t *tvb, packet_info *pinfo, gint *offset,
proto_tree *tree)
{
guint8 message_type;
proto_item *ti=NULL;
proto_tree *vnc_client_message_type_tree;
message_type = tvb_get_guint8(tvb, *offset);
ti = proto_tree_add_item(tree, hf_vnc_client_message_type, tvb,
*offset, 1, FALSE);
vnc_client_message_type_tree =
proto_item_add_subtree(ti, ett_vnc_client_message_type);
*offset += 1;
switch(message_type) {
case 0 :
vnc_client_set_pixel_format(tvb, pinfo, offset,
vnc_client_message_type_tree);
break;
case 2 :
vnc_client_set_encodings(tvb, pinfo, offset,
vnc_client_message_type_tree);
break;
case 3 :
vnc_client_framebuffer_update_request(tvb, pinfo, offset,
vnc_client_message_type_tree);
break;
case 4 :
vnc_client_key_event(tvb, pinfo, offset,
vnc_client_message_type_tree);
break;
case 5:
vnc_client_pointer_event(tvb, pinfo, offset,
vnc_client_message_type_tree);
break;
case 6 :
vnc_client_cut_text(tvb, pinfo, offset,
vnc_client_message_type_tree);
break;
default :
if (check_col(pinfo->cinfo, COL_INFO))
col_append_fstr(pinfo->cinfo, COL_INFO,
"Unknown client message type (%u)",
message_type);
break;
}
}
static void
vnc_server_to_client(tvbuff_t *tvb, packet_info *pinfo, gint *offset,
proto_tree *tree)
{
guint8 message_type;
gint bytes_needed = 0, length_remaining;
proto_item *ti=NULL;
proto_tree *vnc_server_message_type_tree;
message_type = tvb_get_guint8(tvb, *offset);
ti = proto_tree_add_item(tree, hf_vnc_server_message_type, tvb,
*offset, 1, FALSE);
vnc_server_message_type_tree =
proto_item_add_subtree(ti, ett_vnc_server_message_type);
*offset += 1;
switch(message_type) {
case 0 :
bytes_needed =
vnc_server_framebuffer_update(tvb, pinfo, offset,
vnc_server_message_type_tree);
break;
case 1 :
bytes_needed = vnc_server_set_colormap_entries(tvb, pinfo, offset, vnc_server_message_type_tree);
break;
case 2 :
vnc_server_ring_bell(tvb, pinfo, offset,
vnc_server_message_type_tree);
break;
case 3 :
bytes_needed = vnc_server_cut_text(tvb, pinfo, offset,
vnc_server_message_type_tree);
break;
default :
if (check_col(pinfo->cinfo, COL_INFO))
col_append_str(pinfo->cinfo, COL_INFO,
"Unknown server message type");
break;
}
if(bytes_needed > 0 && vnc_preference_desegment &&
pinfo->can_desegment) {
length_remaining = tvb_length_remaining(tvb, *offset);
pinfo->desegment_offset = 0;
pinfo->desegment_len = tvb_length(tvb) + bytes_needed -
length_remaining;
return;
}
}
static void
vnc_client_set_pixel_format(tvbuff_t *tvb, packet_info *pinfo, gint *offset,
proto_tree *tree)
{
if (check_col(pinfo->cinfo, COL_INFO))
col_set_str(pinfo->cinfo, COL_INFO, "Client set pixel format");
proto_tree_add_item(tree, hf_vnc_padding, tvb, *offset,
3, FALSE);
*offset += 3; /* Skip over 3 bytes of padding */
proto_tree_add_item(tree, hf_vnc_client_bits_per_pixel, tvb, *offset,
1, FALSE);
vnc_bytes_per_pixel = tvb_get_guint8(tvb, *offset)/8;
vnc_set_bytes_per_pixel(pinfo, vnc_bytes_per_pixel);
*offset += 1;
proto_tree_add_item(tree, hf_vnc_client_depth, tvb, *offset,
1, FALSE);
*offset += 1;
proto_tree_add_item(tree, hf_vnc_client_big_endian_flag, tvb, *offset,
1, FALSE);
*offset += 1;
proto_tree_add_item(tree, hf_vnc_client_true_color_flag, tvb, *offset,
1, FALSE);
*offset += 1;
proto_tree_add_item(tree, hf_vnc_client_red_max, tvb, *offset,
2, FALSE);
*offset += 2;
proto_tree_add_item(tree, hf_vnc_client_green_max, tvb, *offset,
2, FALSE);
*offset += 2;
proto_tree_add_item(tree, hf_vnc_client_blue_max, tvb, *offset,
2, FALSE);
*offset += 2;
proto_tree_add_item(tree, hf_vnc_client_red_shift, tvb, *offset,
1, FALSE);
*offset += 1;
proto_tree_add_item(tree, hf_vnc_client_green_shift, tvb, *offset,
1, FALSE);
*offset += 1;
proto_tree_add_item(tree, hf_vnc_client_blue_shift, tvb, *offset,
1, FALSE);
*offset += 1;
proto_tree_add_item(tree, hf_vnc_padding, tvb, *offset,
3, FALSE);
*offset += 3; /* Skip over 3 bytes of padding */
}
static void
vnc_client_set_encodings(tvbuff_t *tvb, packet_info *pinfo, gint *offset,
proto_tree *tree)
{
guint16 number_of_encodings;
guint counter;
if (check_col(pinfo->cinfo, COL_INFO))
col_set_str(pinfo->cinfo, COL_INFO, "Client set encodings");
proto_tree_add_item(tree, hf_vnc_padding,
tvb, *offset, 1, FALSE);
*offset += 1; /* Skip over 1 byte of padding */
number_of_encodings = tvb_get_ntohs(tvb, *offset);
proto_tree_add_text(tree, tvb, *offset, 2,
"Number of encodings: %d", number_of_encodings);
*offset += 2;
for(counter = 1; counter <= number_of_encodings; counter++) {
proto_tree_add_item(tree,
hf_vnc_client_set_encodings_encoding_type,
tvb, *offset, 4, FALSE);
*offset += 4;
}
}
static void
vnc_client_framebuffer_update_request(tvbuff_t *tvb, packet_info *pinfo,
gint *offset, proto_tree *tree)
{
if (check_col(pinfo->cinfo, COL_INFO))
col_set_str(pinfo->cinfo, COL_INFO,
"Client framebuffer update request");
proto_tree_add_item(tree, hf_vnc_update_req_incremental,
tvb, *offset, 1, FALSE);
*offset += 1;
proto_tree_add_item(tree, hf_vnc_update_req_x_pos,
tvb, *offset, 2, FALSE);
*offset += 2;
proto_tree_add_item(tree, hf_vnc_update_req_y_pos,
tvb, *offset, 2, FALSE);
*offset += 2;
proto_tree_add_item(tree, hf_vnc_update_req_width, tvb,
*offset, 2, FALSE);
*offset += 2;
proto_tree_add_item(tree, hf_vnc_update_req_height, tvb,
*offset, 2, FALSE);
*offset += 2;
}
static void
vnc_client_key_event(tvbuff_t *tvb, packet_info *pinfo, gint *offset,
proto_tree *tree)
{
if (check_col(pinfo->cinfo, COL_INFO))
col_set_str(pinfo->cinfo, COL_INFO, "Client key event");
proto_tree_add_item(tree, hf_vnc_key_down, tvb, *offset, 1, FALSE);
*offset += 1;
proto_tree_add_item(tree, hf_vnc_padding, tvb, *offset, 2, FALSE);
*offset += 2; /* Skip over 2 bytes of padding */
proto_tree_add_item(tree, hf_vnc_key, tvb, *offset, 4, FALSE);
*offset += 4;
}
static void
vnc_client_pointer_event(tvbuff_t *tvb, packet_info *pinfo, gint *offset,
proto_tree *tree)
{
if (check_col(pinfo->cinfo, COL_INFO))
col_set_str(pinfo->cinfo, COL_INFO, "Client pointer event");
proto_tree_add_item(tree, hf_vnc_button_1_pos, tvb, *offset, 1, FALSE);
proto_tree_add_item(tree, hf_vnc_button_2_pos, tvb, *offset, 1, FALSE);
proto_tree_add_item(tree, hf_vnc_button_3_pos, tvb, *offset, 1, FALSE);
proto_tree_add_item(tree, hf_vnc_button_4_pos, tvb, *offset, 1, FALSE);
proto_tree_add_item(tree, hf_vnc_button_5_pos, tvb, *offset, 1, FALSE);
proto_tree_add_item(tree, hf_vnc_button_6_pos, tvb, *offset, 1, FALSE);
proto_tree_add_item(tree, hf_vnc_button_7_pos, tvb, *offset, 1, FALSE);
proto_tree_add_item(tree, hf_vnc_button_8_pos, tvb, *offset, 1, FALSE);
*offset += 1;
proto_tree_add_item(tree, hf_vnc_pointer_x_pos, tvb, *offset, 2, FALSE);
*offset += 2;
proto_tree_add_item(tree, hf_vnc_pointer_y_pos, tvb, *offset, 2, FALSE);
*offset += 2;
}
static void
vnc_client_cut_text(tvbuff_t *tvb, packet_info *pinfo, gint *offset,
proto_tree *tree)
{
guint32 text_len;
if (check_col(pinfo->cinfo, COL_INFO))
col_set_str(pinfo->cinfo, COL_INFO, "Client cut text");
proto_tree_add_item(tree, hf_vnc_padding, tvb, *offset, 3, FALSE);
*offset += 3; /* Skip over 3 bytes of padding */
text_len = tvb_get_ntohl(tvb, *offset);
proto_tree_add_item(tree, hf_vnc_client_cut_text_len, tvb, *offset, 4,
FALSE);
*offset += 4;
proto_tree_add_item(tree, hf_vnc_client_cut_text, tvb, *offset,
text_len, FALSE);
*offset += text_len;
}
static guint
vnc_server_framebuffer_update(tvbuff_t *tvb, packet_info *pinfo, gint *offset,
proto_tree *tree)
{
guint16 num_rects, i, width, height;
guint bytes_needed = 0;
gint32 encoding_type;
proto_item *ti;
proto_tree *vnc_rect_tree, *vnc_encoding_type_tree;
if (check_col(pinfo->cinfo, COL_INFO))
col_set_str(pinfo->cinfo, COL_INFO,
"Server framebuffer update");
proto_tree_add_item(tree, hf_vnc_padding, tvb, *offset, 1, FALSE);
*offset += 1;
num_rects = tvb_get_ntohs(tvb, *offset);
proto_tree_add_text(tree, tvb, *offset, 2, "Number of rectangles: %d",
num_rects);
*offset += 2;
for(i = 1; i <= num_rects; i++) {
VNC_BYTES_NEEDED(12);
ti = proto_tree_add_text(tree, tvb, *offset, 12,
"Rectangle #%d", i);
vnc_rect_tree =
proto_item_add_subtree(ti, ett_vnc_rect);
proto_tree_add_item(vnc_rect_tree, hf_vnc_fb_update_x_pos,
tvb, *offset, 2, FALSE);
*offset += 2;
proto_tree_add_item(vnc_rect_tree, hf_vnc_fb_update_y_pos,
tvb, *offset, 2, FALSE);
*offset += 2;
proto_tree_add_item(vnc_rect_tree, hf_vnc_fb_update_width,
tvb, *offset, 2, FALSE);
width = tvb_get_ntohs(tvb, *offset);
*offset += 2;
proto_tree_add_item(vnc_rect_tree, hf_vnc_fb_update_height,
tvb, *offset, 2, FALSE);
height = tvb_get_ntohs(tvb, *offset);
*offset += 2;
ti = proto_tree_add_item(vnc_rect_tree,
hf_vnc_fb_update_encoding_type,
tvb, *offset, 4, FALSE);
vnc_encoding_type_tree =
proto_item_add_subtree(ti, ett_vnc_encoding_type);
encoding_type = tvb_get_ntohl(tvb, *offset);
*offset += 4;
switch(encoding_type) {
case 0 :
bytes_needed = vnc_raw_encoding(tvb, pinfo, offset,
vnc_encoding_type_tree,
width, height);
break;
case 1 :
bytes_needed =
vnc_copyrect_encoding(tvb, pinfo, offset,
vnc_encoding_type_tree,
width, height);
break;
case 2 :
bytes_needed =
vnc_rre_encoding(tvb, pinfo, offset,
vnc_encoding_type_tree,
width, height);
break;
case 5 :
bytes_needed =
vnc_hextile_encoding(tvb, pinfo, offset,
vnc_encoding_type_tree,
width, height);
break;
case 16 :
bytes_needed =
vnc_zrle_encoding(tvb, pinfo, offset,
vnc_encoding_type_tree,
width, height);
break;
case -239 :
bytes_needed =
vnc_cursor_encoding(tvb, pinfo, offset,
vnc_encoding_type_tree,
width, height);
break;
case -223 : /* DesktopSize */
/* There is no payload for this message type */
bytes_needed = 0;
break;
}
/* Check if the routines above requested more bytes to
* be desegmented. */
if(bytes_needed > 0)
return bytes_needed;
}
return 0;
}
static guint
vnc_raw_encoding(tvbuff_t *tvb, packet_info *pinfo, gint *offset,
proto_tree *tree, guint16 width, guint16 height)
{
guint8 bytes_per_pixel = vnc_get_bytes_per_pixel(pinfo);
guint length;
length = width * height * bytes_per_pixel;
VNC_BYTES_NEEDED(length);
proto_tree_add_item(tree, hf_vnc_raw_pixel_data, tvb, *offset,
length, FALSE);
*offset += length;
return 0; /* bytes_needed */
}
static guint
vnc_copyrect_encoding(tvbuff_t *tvb, packet_info *pinfo _U_, gint *offset,
proto_tree *tree, guint16 width _U_, guint16 height _U_)
{
proto_tree_add_item(tree, hf_vnc_copyrect_src_x_pos, tvb, *offset,
2, FALSE);
*offset += 2;
proto_tree_add_item(tree, hf_vnc_copyrect_src_y_pos, tvb, *offset,
2, FALSE);
*offset += 2;
return 0; /* bytes_needed */
}
static guint
vnc_rre_encoding(tvbuff_t *tvb, packet_info *pinfo, gint *offset,
proto_tree *tree, guint16 width _U_, guint16 height _U_)
{
guint8 bytes_per_pixel = vnc_get_bytes_per_pixel(pinfo);
guint32 num_subrects, i;
guint bytes_needed;
proto_item *ti;
proto_tree *subrect_tree;
VNC_BYTES_NEEDED(4);
proto_tree_add_item(tree, hf_vnc_rre_num_subrects, tvb, *offset,
4, FALSE);
num_subrects = tvb_get_ntohl(tvb, *offset);
*offset += 4;
VNC_BYTES_NEEDED(bytes_per_pixel);
proto_tree_add_item(tree, hf_vnc_rre_bg_pixel, tvb, *offset,
bytes_per_pixel, FALSE);
*offset += bytes_per_pixel;
for(i = 1; i <= num_subrects; i++) {
bytes_needed = bytes_per_pixel + 8;
VNC_BYTES_NEEDED(bytes_needed);
ti = proto_tree_add_text(tree, tvb, *offset, bytes_per_pixel +
8, "Subrectangle #%d", i);
subrect_tree =
proto_item_add_subtree(ti, ett_vnc_rre_subrect);
proto_tree_add_item(subrect_tree, hf_vnc_rre_subrect_pixel,
tvb, *offset, bytes_per_pixel, FALSE);
*offset += bytes_per_pixel;
proto_tree_add_item(subrect_tree, hf_vnc_rre_subrect_x_pos,
tvb, *offset, 2, FALSE);
*offset += 2;
proto_tree_add_item(subrect_tree, hf_vnc_rre_subrect_y_pos,
tvb, *offset, 2, FALSE);
*offset += 2;
proto_tree_add_item(subrect_tree, hf_vnc_rre_subrect_width,
tvb, *offset, 2, FALSE);
*offset += 2;
proto_tree_add_item(subrect_tree, hf_vnc_rre_subrect_height,
tvb, *offset, 2, FALSE);
*offset += 2;
}
return 0; /* bytes_needed */
}
static guint
vnc_hextile_encoding(tvbuff_t *tvb, packet_info *pinfo, gint *offset,
proto_tree *tree, guint16 width, guint16 height)
{
guint8 bytes_per_pixel = vnc_get_bytes_per_pixel(pinfo);
guint8 i, subencoding_mask, num_subrects, subrect_len;
guint length;
proto_tree *subencoding_mask_tree, *subrect_tree, *num_subrects_tree;
proto_item *ti;
VNC_BYTES_NEEDED(1);
ti = proto_tree_add_item(tree, hf_vnc_hextile_subencoding_mask, tvb,
*offset, 1, FALSE);
subencoding_mask = tvb_get_guint8(tvb, *offset);
subencoding_mask_tree =
proto_item_add_subtree(ti, ett_vnc_hextile_subencoding_mask);
proto_tree_add_item(subencoding_mask_tree,
hf_vnc_hextile_raw, tvb, *offset, 1,
FALSE);
proto_tree_add_item(subencoding_mask_tree,
hf_vnc_hextile_bg, tvb, *offset, 1,
FALSE);
proto_tree_add_item(subencoding_mask_tree,
hf_vnc_hextile_fg, tvb, *offset, 1,
FALSE);
proto_tree_add_item(subencoding_mask_tree,
hf_vnc_hextile_anysubrects, tvb, *offset, 1,
FALSE);
proto_tree_add_item(subencoding_mask_tree,
hf_vnc_hextile_subrectscolored, tvb, *offset, 1,
FALSE);
*offset += 1;
if(subencoding_mask & 0x1) { /* Raw */
length = width * height * bytes_per_pixel;
VNC_BYTES_NEEDED(length);
proto_tree_add_item(tree, hf_vnc_hextile_raw_value, tvb,
*offset, length, FALSE);
*offset += length;
} else {
if(subencoding_mask & 0x2) { /* Background Specified */
proto_tree_add_item(tree, hf_vnc_hextile_bg_value,
tvb, *offset, bytes_per_pixel,
FALSE);
*offset += bytes_per_pixel;
}
if(subencoding_mask & 0x4) { /* Foreground Specified */
proto_tree_add_item(tree, hf_vnc_hextile_fg_value,
tvb, *offset, bytes_per_pixel,
FALSE);
*offset += bytes_per_pixel;
}
if(subencoding_mask & 0x8) { /* Any Subrects */
ti = proto_tree_add_item(tree,
hf_vnc_hextile_num_subrects,
tvb, *offset, 1,
FALSE);
num_subrects = tvb_get_guint8(tvb, *offset);
*offset += 1;
num_subrects_tree =
proto_item_add_subtree(ti, ett_vnc_hextile_num_subrects);
for(i = 1; i <= num_subrects; i++) {
if(subencoding_mask & 0x16)
subrect_len = bytes_per_pixel + 2;
else
subrect_len = 2;
ti = proto_tree_add_text(num_subrects_tree, tvb,
*offset, subrect_len,
"Subrectangle #%d", i);
subrect_tree =
proto_item_add_subtree(ti, ett_vnc_hextile_subrect);
if(subencoding_mask & 0x16) {
/* Subrects Colored */
proto_tree_add_item(subrect_tree, hf_vnc_hextile_subrect_pixel_value, tvb, *offset, bytes_per_pixel, FALSE);
*offset += bytes_per_pixel;
}
proto_tree_add_item(subrect_tree,
hf_vnc_hextile_subrect_x_pos, tvb, *offset, 1, FALSE);
proto_tree_add_item(subrect_tree, hf_vnc_hextile_subrect_y_pos, tvb, *offset, 1, FALSE);
*offset += 1;
proto_tree_add_item(subrect_tree, hf_vnc_hextile_subrect_width, tvb, *offset, 1, FALSE);
proto_tree_add_item(subrect_tree, hf_vnc_hextile_subrect_height, tvb, *offset, 1, FALSE);
*offset += 1;
}
}
}
return 0; /* bytes_needed */
}
#ifdef HAVE_LIBZ
static guint
vnc_zrle_encoding(tvbuff_t *tvb, packet_info *pinfo, gint *offset,
proto_tree *tree, guint16 width, guint16 height)
#else
static guint
vnc_zrle_encoding(tvbuff_t *tvb, packet_info *pinfo _U_, gint *offset,
proto_tree *tree, guint16 width _U_, guint16 height _U_)
#endif
{
guint32 data_len;
#ifdef HAVE_LIBZ
guint8 palette_size;
guint8 bytes_per_cpixel = vnc_get_bytes_per_pixel(pinfo);
gint uncomp_offset = 0;
guint length;
gint subencoding_type;
tvbuff_t *uncomp_tvb = NULL;
proto_tree *zrle_subencoding_tree;
proto_item *ti;
#endif
VNC_BYTES_NEEDED(4);
proto_tree_add_item(tree, hf_vnc_zrle_len, tvb, *offset,
4, FALSE);
data_len = tvb_get_ntohl(tvb, *offset);
*offset += 4;
VNC_BYTES_NEEDED(data_len);
proto_tree_add_item(tree, hf_vnc_zrle_data, tvb, *offset,
data_len, FALSE);
#ifdef HAVE_LIBZ
uncomp_tvb = tvb_uncompress(tvb, *offset, data_len);
if(uncomp_tvb != NULL) {
tvb_set_child_real_data_tvbuff(tvb, uncomp_tvb);
add_new_data_source(pinfo, uncomp_tvb,
"Uncompressed ZRLE data");
ti = proto_tree_add_item(tree, hf_vnc_zrle_subencoding,
uncomp_tvb, uncomp_offset, 1, FALSE);
zrle_subencoding_tree =
proto_item_add_subtree(ti, ett_vnc_zrle_subencoding);
proto_tree_add_item(zrle_subencoding_tree, hf_vnc_zrle_rle,
uncomp_tvb, uncomp_offset, 1, FALSE);
proto_tree_add_item(zrle_subencoding_tree,
hf_vnc_zrle_palette_size, uncomp_tvb,
uncomp_offset, 1, FALSE);
subencoding_type = tvb_get_guint8(uncomp_tvb, uncomp_offset);
palette_size = subencoding_type & 0x7F;
uncomp_offset += 1;
if(subencoding_type == 0) { /* Raw */
length = width * height * bytes_per_cpixel;
VNC_BYTES_NEEDED(length);
/* XXX - not working yet! */
proto_tree_add_item(zrle_subencoding_tree,
hf_vnc_zrle_raw, uncomp_tvb,
uncomp_offset, length, FALSE);
} else if(subencoding_type >= 130 && subencoding_type <= 255) {
length = palette_size * bytes_per_cpixel;
VNC_BYTES_NEEDED(length);
proto_tree_add_item(zrle_subencoding_tree,
hf_vnc_zrle_palette, uncomp_tvb,
uncomp_offset, length, FALSE);
/* XXX - Not complete! */
}
} else {
proto_tree_add_text(tree, tvb, *offset, data_len,
"Decompression of ZRLE data failed");
}
#endif /* HAVE_LIBZ */
*offset += data_len;
return 0; /* bytes_needed */
}
static guint
vnc_cursor_encoding(tvbuff_t *tvb, packet_info *pinfo, gint *offset,
proto_tree *tree, guint16 width, guint16 height)
{
guint8 bytes_per_pixel = vnc_get_bytes_per_pixel(pinfo);
guint length;
length = width * height * bytes_per_pixel;
proto_tree_add_item(tree, hf_vnc_cursor_encoding_pixels, tvb, *offset,
length, FALSE);
*offset += length;
length = (guint) (floor((width + 7)/8) * height);
proto_tree_add_item(tree, hf_vnc_cursor_encoding_bitmask, tvb, *offset,
length, FALSE);
*offset += length;
return 0; /* bytes_needed */
}
static guint
vnc_server_set_colormap_entries(tvbuff_t *tvb, packet_info *pinfo, gint *offset,
proto_tree *tree)
{
guint16 number_of_colors;
guint counter, bytes_needed;
proto_item *ti;
proto_tree *vnc_colormap_num_groups, *vnc_colormap_color_group;
if (check_col(pinfo->cinfo, COL_INFO))
col_set_str(pinfo->cinfo, COL_INFO,
"Server set colormap entries");
number_of_colors = tvb_get_ntohs(tvb, 4);
bytes_needed = (number_of_colors * 6) + 6;
VNC_BYTES_NEEDED(bytes_needed);
ti = proto_tree_add_item(tree, hf_vnc_server_message_type, tvb,
*offset, 1, FALSE);
tree = proto_item_add_subtree(ti, ett_vnc_server_message_type);
*offset += 1;
proto_tree_add_item(tree, hf_vnc_padding, tvb, *offset, 1, FALSE);
*offset += 1; /* Skip over 1 byte of padding */
proto_tree_add_item(tree,
hf_vnc_colormap_first_color,
tvb, *offset, 2, FALSE);
*offset += 2;
ti = proto_tree_add_item(tree, hf_vnc_colormap_num_colors, tvb,
*offset, 2, FALSE);
vnc_colormap_num_groups =
proto_item_add_subtree(ti, ett_vnc_colormap_num_groups);
*offset += 2;
for(counter = 1; counter <= number_of_colors; counter++) {
ti = proto_tree_add_text(vnc_colormap_num_groups, tvb,
*offset, 6,
"Color group #%d", counter);
vnc_colormap_color_group =
proto_item_add_subtree(ti,
ett_vnc_colormap_color_group);
proto_tree_add_item(vnc_colormap_color_group,
hf_vnc_colormap_red, tvb,
*offset, 2, FALSE);
*offset += 2;
proto_tree_add_item(vnc_colormap_color_group,
hf_vnc_colormap_green, tvb,
*offset, 2, FALSE);
*offset += 2;
proto_tree_add_item(vnc_colormap_color_group,
hf_vnc_colormap_blue, tvb,
*offset, 2, FALSE);
*offset += 2;
}
return *offset;
}
static void
vnc_server_ring_bell(tvbuff_t *tvb _U_, packet_info *pinfo, gint *offset _U_,
proto_tree *tree _U_)
{
if (check_col(pinfo->cinfo, COL_INFO))
col_set_str(pinfo->cinfo, COL_INFO, "Server ring bell on client");
/* This message type has no payload... */
}
static guint
vnc_server_cut_text(tvbuff_t *tvb, packet_info *pinfo, gint *offset,
proto_tree *tree)
{
guint32 text_len;
if (check_col(pinfo->cinfo, COL_INFO))
col_set_str(pinfo->cinfo, COL_INFO,
"Server cut text");
text_len = tvb_get_ntohl(tvb, *offset);
proto_tree_add_item(tree,
hf_vnc_server_cut_text_len, tvb, *offset, 4,
FALSE);
*offset += 4;
VNC_BYTES_NEEDED(text_len);
proto_tree_add_item(tree, hf_vnc_server_cut_text, tvb, *offset,
text_len, FALSE);
*offset += text_len;
return *offset;
}
static void
vnc_set_bytes_per_pixel(packet_info *pinfo, guint8 bytes_per_pixel)
{
vnc_packet_t *per_packet_info;
/* The per_packet_info has already been created by the
* vnc_startup_messages() routine. */
per_packet_info = p_get_proto_data(pinfo->fd, proto_vnc);
per_packet_info->bytes_per_pixel = bytes_per_pixel;
}
static guint8
vnc_get_bytes_per_pixel(packet_info *pinfo)
{
vnc_packet_t *per_packet_info;
/* The per_packet_info has already been created by the
* vnc_startup_messages() routine. */
per_packet_info = p_get_proto_data(pinfo->fd, proto_vnc);
return per_packet_info->bytes_per_pixel;
}
/* Register the protocol with Wireshark */
void
proto_register_vnc(void)
{
module_t *vnc_module; /* To handle our preferences */
/* Setup list of header fields */
static hf_register_info hf[] = {
{ &hf_vnc_padding,
{ "Padding", "vnc.padding",
FT_NONE, BASE_NONE, NULL, 0x0,
"Unused space", HFILL }
},
{ &hf_vnc_server_proto_ver,
{ "Server protocol version", "vnc.server_proto_ver",
FT_STRING, BASE_NONE, NULL, 0x0,
"VNC protocol version on server", HFILL }
},
{ &hf_vnc_client_proto_ver,
{ "Client protocol version", "vnc.client_proto_ver",
FT_STRING, BASE_NONE, NULL, 0x0,
"VNC protocol version on client", HFILL }
},
{ &hf_vnc_num_security_types,
{ "Number of security types", "vnc.num_security_types",
FT_UINT8, BASE_DEC, NULL, 0x0,
"Number of security (authentication) types supported by the server", HFILL }
},
{ &hf_vnc_security_type,
{ "Security type", "vnc.security_type",
FT_UINT8, BASE_DEC, VALS(security_types_vs), 0x0,
"Security types offered by the server (VNC versions => 3.007", HFILL }
},
{ &hf_vnc_server_security_type,
{ "Security type", "vnc.server_security_type",
FT_UINT32, BASE_DEC, VALS(security_types_vs), 0x0,
"Security type mandated by the server", HFILL }
},
{ &hf_vnc_client_security_type,
{ "Security type selected", "vnc.security_type",
FT_UINT8, BASE_DEC, VALS(security_types_vs), 0x0,
"Security type selected by the client", HFILL }
},
{ &hf_vnc_vendor_code,
{ "Vendor code", "vnc.vendor_code",
FT_STRING, BASE_NONE, NULL, 0x0,
"Identifies the VNC server software's vendor", HFILL }
},
{ &hf_vnc_security_type_string,
{ "Security type string", "vnc.security_type_string",
FT_STRING, BASE_NONE, NULL, 0x0,
"Security type being used", HFILL }
},
{ &hf_vnc_auth_challenge,
{ "Authentication challenge", "vnc.auth_challenge",
FT_STRING, BASE_NONE, NULL, 0x0,
"Random authentication challenge from server to client", HFILL }
},
{ &hf_vnc_auth_response,
{ "Authentication response", "vnc.auth_response",
FT_STRING, BASE_NONE, NULL, 0x0,
"Client's encrypted response to the server's authentication challenge", HFILL }
},
{ &hf_vnc_auth_result,
{ "Authentication result", "vnc.auth_result",
FT_UINT32, BASE_DEC, VALS(auth_result_vs), 0x0,
"Authentication result", HFILL }
},
{ &hf_vnc_auth_error,
{ "Authentication error", "vnc.auth_error",
FT_STRING, BASE_NONE, NULL, 0x0,
"Authentication error (present only if the authentication result is fail", HFILL }
},
{ &hf_vnc_share_desktop_flag,
{ "Share desktop flag", "vnc.share_desktop_flag",
FT_UINT8, BASE_DEC, VALS(yes_no_vs), 0x0,
"Client's desire to share the server's desktop with other clients", HFILL }
},
{ &hf_vnc_width,
{ "Framebuffer width", "vnc.width",
FT_UINT16, BASE_DEC, NULL, 0x0,
"Width of the framebuffer (screen) in pixels", HFILL }
},
{ &hf_vnc_height,
{ "Framebuffer height", "vnc.width",
FT_UINT16, BASE_DEC, NULL, 0x0,
"Height of the framebuffer (screen) in pixels", HFILL }
},
{ &hf_vnc_server_bits_per_pixel,
{ "Bits per pixel", "vnc.server_bits_per_pixel",
FT_UINT8, BASE_DEC, NULL, 0x0,
"Number of bits used by server for each pixel value on the wire from the server", HFILL }
},
{ &hf_vnc_server_depth,
{ "Depth", "vnc.server_depth",
FT_UINT8, BASE_DEC, NULL, 0x0,
"Number of useful bits in the pixel value on server", HFILL }
},
{ &hf_vnc_server_big_endian_flag,
{ "Big endian flag", "vnc.server_big_endian_flag",
FT_BOOLEAN, BASE_NONE, NULL, 0x0,
"True if multi-byte pixels are interpreted as big endian by server", HFILL }
},
{ &hf_vnc_server_true_color_flag,
{ "True color flag", "vnc.server_true_color_flag",
FT_BOOLEAN, BASE_NONE, NULL, 0x0,
"If true, then the next six items specify how to extract the red, green and blue intensities from the pixel value on the server.", HFILL }
},
{ &hf_vnc_server_red_max,
{ "Red maximum", "vnc.server_red_max",
FT_UINT16, BASE_DEC, NULL, 0x0,
"Maximum red value on server as n: 2^n - 1", HFILL }
},
{ &hf_vnc_server_green_max,
{ "Green maximum", "vnc.server_green_max",
FT_UINT16, BASE_DEC, NULL, 0x0,
"Maximum green value on server as n: 2^n - 1", HFILL }
},
{ &hf_vnc_server_blue_max,
{ "Blue maximum", "vnc.server_blue_max",
FT_UINT16, BASE_DEC, NULL, 0x0,
"Maximum blue value on server as n: 2^n - 1", HFILL }
},
{ &hf_vnc_server_red_shift,
{ "Red shift", "vnc.server_red_shift",
FT_UINT8, BASE_DEC, NULL, 0x0,
"Number of shifts needed to get the red value in a pixel to the least significant bit on the server", HFILL }
},
{ &hf_vnc_server_green_shift,
{ "Green shift", "vnc.server_green_shift",
FT_UINT8, BASE_DEC, NULL, 0x0,
"Number of shifts needed to get the green value in a pixel to the least significant bit on the server", HFILL }
},
{ &hf_vnc_server_blue_shift,
{ "Blue shift", "vnc.server_blue_shift",
FT_UINT8, BASE_DEC, NULL, 0x0,
"Number of shifts needed to get the blue value in a pixel to the least significant bit on the server", HFILL }
},
{ &hf_vnc_desktop_name_len,
{ "Desktop name length", "vnc.desktop_name_len",
FT_UINT32, BASE_DEC, NULL, 0x0,
"Length of desktop name in bytes", HFILL }
},
{ &hf_vnc_desktop_name,
{ "Desktop name", "vnc.desktop_name",
FT_STRING, BASE_NONE, NULL, 0x0,
"Name of the VNC desktop on the server", HFILL }
},
{ &hf_vnc_num_server_message_types,
{ "Server message types", "vnc.num_server_message_types",
FT_UINT16, BASE_DEC, NULL, 0x0,
"Unknown", HFILL } /* XXX - Needs description */
},
{ &hf_vnc_num_client_message_types,
{ "Client message types", "vnc.num_client_message_types",
FT_UINT16, BASE_DEC, NULL, 0x0,
"Unknown", HFILL } /* XXX - Needs description */
},
{ &hf_vnc_num_encoding_types,
{ "Encoding types", "vnc.num_encoding_types",
FT_UINT16, BASE_DEC, NULL, 0x0,
"Unknown", HFILL } /* XXX - Needs description */
},
{ &hf_vnc_client_message_type,
{ "Client Message Type", "vnc.client_message_type",
FT_UINT8, BASE_DEC, VALS(client_message_types_vs), 0x0,
"Message type from client", HFILL }
},
{ &hf_vnc_client_bits_per_pixel,
{ "Bits per pixel", "vnc.client_bits_per_pixel",
FT_UINT8, BASE_DEC, NULL, 0x0,
"Number of bits used by server for each pixel value on the wire from the client", HFILL }
},
{ &hf_vnc_client_depth,
{ "Depth", "vnc.client_depth",
FT_UINT8, BASE_DEC, NULL, 0x0,
"Number of useful bits in the pixel value on client", HFILL }
},
{ &hf_vnc_client_big_endian_flag,
{ "Big endian flag", "vnc.client_big_endian_flag",
FT_BOOLEAN, BASE_NONE, NULL, 0x0,
"True if multi-byte pixels are interpreted as big endian by client", HFILL }
},
{ &hf_vnc_client_true_color_flag,
{ "True color flag", "vnc.client_true_color_flag",
FT_BOOLEAN, BASE_NONE, NULL, 0x0,
"If true, then the next six items specify how to extract the red, green and blue intensities from the pixel value on the client.", HFILL }
},
{ &hf_vnc_client_red_max,
{ "Red maximum", "vnc.client_red_max",
FT_UINT16, BASE_DEC, NULL, 0x0,
"Maximum red value on client as n: 2^n - 1", HFILL }
},
{ &hf_vnc_client_green_max,
{ "Green maximum", "vnc.client_green_max",
FT_UINT16, BASE_DEC, NULL, 0x0,
"Maximum green value on client as n: 2^n - 1", HFILL }
},
{ &hf_vnc_client_blue_max,
{ "Blue maximum", "vnc.client_blue_max",
FT_UINT16, BASE_DEC, NULL, 0x0,
"Maximum blue value on client as n: 2^n - 1", HFILL }
},
{ &hf_vnc_client_red_shift,
{ "Red shift", "vnc.client_red_shift",
FT_UINT8, BASE_DEC, NULL, 0x0,
"Number of shifts needed to get the red value in a pixel to the least significant bit on the client", HFILL }
},
{ &hf_vnc_client_green_shift,
{ "Green shift", "vnc.client_green_shift",
FT_UINT8, BASE_DEC, NULL, 0x0,
"Number of shifts needed to get the green value in a pixel to the least significant bit on the client", HFILL }
},
{ &hf_vnc_client_blue_shift,
{ "Blue shift", "vnc.client_blue_shift",
FT_UINT8, BASE_DEC, NULL, 0x0,
"Number of shifts needed to get the blue value in a pixel to the least significant bit on the client", HFILL }
},
/* Client Key Event */
{ &hf_vnc_key_down,
{ "Key down", "vnc.key_down",
FT_UINT8, BASE_DEC, VALS(yes_no_vs), 0x0,
"Specifies whether the key is being pressed or not", HFILL }
},
{ &hf_vnc_key,
{ "Key", "vnc.key",
FT_UINT32, BASE_HEX, VALS(keysym_vals_source), 0x0, /* keysym_vals_source is from packet-x11-keysym.h */
"Key being pressed/depressed", HFILL }
},
/* Client Pointer Event */
{ &hf_vnc_button_1_pos,
{ "Mouse button #1 position", "vnc.button_1_pos",
FT_UINT8, BASE_DEC, VALS(&button_mask_vs), 0x1,
"Whether mouse button #1 is being pressed or not", HFILL }
},
{ &hf_vnc_button_2_pos,
{ "Mouse button #2 position", "vnc.button_2_pos",
FT_UINT8, BASE_DEC, VALS(&button_mask_vs), 0x2,
"Whether mouse button #2 is being pressed or not", HFILL }
},
{ &hf_vnc_button_3_pos,
{ "Mouse button #3 position", "vnc.button_3_pos",
FT_UINT8, BASE_DEC, VALS(&button_mask_vs), 0x4,
"Whether mouse button #3 is being pressed or not", HFILL }
},
{ &hf_vnc_button_4_pos,
{ "Mouse button #4 position", "vnc.button_4_pos",
FT_UINT8, BASE_DEC, VALS(&button_mask_vs), 0x8,
"Whether mouse button #4 is being pressed or not", HFILL }
},
{ &hf_vnc_button_5_pos,
{ "Mouse button #5 position", "vnc.button_5_pos",
FT_UINT8, BASE_DEC, VALS(&button_mask_vs), 0x10,
"Whether mouse button #5 is being pressed or not", HFILL }
},
{ &hf_vnc_button_6_pos,
{ "Mouse button #6 position", "vnc.button_6_pos",
FT_UINT8, BASE_DEC, VALS(&button_mask_vs), 0x20,
"Whether mouse button #6 is being pressed or not", HFILL }
},
{ &hf_vnc_button_7_pos,
{ "Mouse button #7 position", "vnc.button_7_pos",
FT_UINT8, BASE_DEC, VALS(&button_mask_vs), 0x40,
"Whether mouse button #7 is being pressed or not", HFILL }
},
{ &hf_vnc_button_8_pos,
{ "Mouse button #8 position", "vnc.button_8_pos",
FT_UINT8, BASE_DEC, VALS(&button_mask_vs), 0x80,
"Whether mouse button #8 is being pressed or not", HFILL }
},
{ &hf_vnc_pointer_x_pos,
{ "X position", "vnc.pointer_x_pos",
FT_UINT16, BASE_DEC, NULL, 0x0,
"Position of mouse cursor on the x-axis", HFILL }
},
{ &hf_vnc_pointer_y_pos,
{ "Y position", "vnc.pointer_y_pos",
FT_UINT16, BASE_DEC, NULL, 0x0,
"Position of mouse cursor on the y-axis", HFILL }
},
{ &hf_vnc_client_set_encodings_encoding_type,
{ "Encoding type", "vnc.client_set_encodings_encoding_type",
FT_INT32, BASE_DEC, VALS(encoding_types_vs), 0x0,
"Type of encoding used to send pixel data from server to client", HFILL }
},
/* Client Framebuffer Update Request */
{ &hf_vnc_update_req_incremental,
{ "Incremental update", "vnc.update_req_incremental",
FT_BOOLEAN, BASE_DEC, NULL, 0x0,
"Specifies if the client wants an incremental update instead of a full one", HFILL }
},
{ &hf_vnc_update_req_x_pos,
{ "X position", "vnc.update_req_x_pos",
FT_UINT16, BASE_DEC, NULL, 0x0,
"X position of framebuffer (screen) update requested", HFILL }
},
{ &hf_vnc_update_req_y_pos,
{ "Y position", "vnc.update_req_y_pos",
FT_UINT16, BASE_DEC, NULL, 0x0,
"Y position of framebuffer (screen) update request", HFILL }
},
{ &hf_vnc_update_req_width,
{ "Width", "vnc.update_req_width",
FT_UINT16, BASE_DEC, NULL, 0x0,
"Width of framebuffer (screen) update request", HFILL }
},
{ &hf_vnc_update_req_height,
{ "Height", "vnc.update_req_height",
FT_UINT16, BASE_DEC, NULL, 0x0,
"Height of framebuffer (screen) update request", HFILL }
},
{ &hf_vnc_client_cut_text_len,
{ "Length", "vnc.client_cut_text_len",
FT_UINT32, BASE_DEC, NULL, 0x0,
"Length of client's copy/cut text (clipboard) string in bytes", HFILL }
},
{ &hf_vnc_client_cut_text,
{ "Text", "vnc.client_cut_text",
FT_STRING, BASE_NONE, NULL, 0x0,
"Text string in the client's copy/cut text (clipboard)", HFILL }
},
/********** Server Message Types **********/
{ &hf_vnc_server_message_type,
{ "Server Message Type", "vnc.server_message_type",
FT_UINT8, BASE_DEC, VALS(server_message_types_vs), 0x0,
"Message type from server", HFILL }
},
{ &hf_vnc_fb_update_x_pos,
{ "X position", "vnc.fb_update_x_pos",
FT_UINT16, BASE_DEC, NULL, 0x0,
"X position of this server framebuffer update", HFILL }
},
{ &hf_vnc_fb_update_y_pos,
{ "Y position", "vnc.fb_update_x_pos",
FT_UINT16, BASE_DEC, NULL, 0x0,
"Y position of this server framebuffer update", HFILL }
},
{ &hf_vnc_fb_update_width,
{ "Width", "vnc.fb_update_width",
FT_UINT16, BASE_DEC, NULL, 0x0,
"Width of this server framebuffer update", HFILL }
},
{ &hf_vnc_fb_update_height,
{ "Height", "vnc.fb_update_width",
FT_UINT16, BASE_DEC, NULL, 0x0,
"Height of this server framebuffer update", HFILL }
},
{ &hf_vnc_fb_update_encoding_type,
{ "Encoding type", "vnc.fb_update_encoding_type",
FT_INT32, BASE_DEC, VALS(encoding_types_vs), 0x0,
"Encoding type of this server framebuffer update", HFILL }
},
/* Cursor encoding */
{ &hf_vnc_cursor_encoding_pixels,
{ "Cursor encoding pixels", "vnc.cursor_encoding_pixels",
FT_BYTES, BASE_NONE, NULL, 0x0,
"Cursor encoding pixel data", HFILL }
},
{ &hf_vnc_cursor_encoding_bitmask,
{ "Cursor encoding bitmask", "vnc.cursor_encoding_bitmask",
FT_BYTES, BASE_NONE, NULL, 0x0,
"Cursor encoding pixel bitmask", HFILL }
},
/* Raw Encoding */
{ &hf_vnc_raw_pixel_data,
{ "Pixel data", "vnc.raw_pixel_data",
FT_BYTES, BASE_NONE, NULL, 0x0,
"Raw pixel data.", HFILL }
},
/* CopyRect Encoding*/
{ &hf_vnc_copyrect_src_x_pos,
{ "Source x position", "vnc.copyrect_src_x_pos",
FT_UINT16, BASE_DEC, NULL, 0x0,
"X position of the rectangle to copy from", HFILL }
},
{ &hf_vnc_copyrect_src_y_pos,
{ "Source y position", "vnc.copyrect_src_y_pos",
FT_UINT16, BASE_DEC, NULL, 0x0,
"Y position of the rectangle to copy from", HFILL }
},
/* RRE Encoding */
{ &hf_vnc_rre_num_subrects,
{ "Number of subrectangles", "vnc.rre_num_subrects",
FT_UINT32, BASE_DEC, NULL, 0x0,
"Number of subrectangles contained in this encoding type", HFILL }
},
{ &hf_vnc_rre_bg_pixel,
{ "Background pixel value", "vnc.rre_bg_pixel",
FT_BYTES, BASE_NONE, NULL, 0x0,
"Background pixel value", HFILL }
},
{ &hf_vnc_rre_subrect_pixel,
{ "Pixel value", "vnc.rre_subrect_pixel",
FT_BYTES, BASE_NONE, NULL, 0x0,
"Subrectangle pixel value", HFILL }
},
{ &hf_vnc_rre_subrect_x_pos,
{ "X position", "vnc.rre_subrect_x_pos",
FT_UINT16, BASE_DEC, NULL, 0x0,
"Position of this subrectangle on the x axis", HFILL }
},
{ &hf_vnc_rre_subrect_y_pos,
{ "Y position", "vnc.rre_subrect_y_pos",
FT_UINT16, BASE_DEC, NULL, 0x0,
"Position of this subrectangle on the y axis", HFILL }
},
{ &hf_vnc_rre_subrect_width,
{ "Width", "vnc.rre_subrect_width",
FT_UINT16, BASE_DEC, NULL, 0x0,
"Width of this subrectangle", HFILL }
},
{ &hf_vnc_rre_subrect_height,
{ "Height", "vnc.rre_subrect_height",
FT_UINT16, BASE_DEC, NULL, 0x0,
"Height of this subrectangle", HFILL }
},
/* Hextile Encoding */
{ &hf_vnc_hextile_subencoding_mask,
{ "Subencoding type", "vnc.hextile_subencoding",
FT_UINT8, BASE_DEC, NULL, 0x0,
"Hextile subencoding type.", HFILL }
},
{ &hf_vnc_hextile_raw,
{ "Raw", "vnc.hextile_raw",
FT_UINT8, BASE_DEC, VALS(yes_no_vs), 0x1,
"Raw subencoding is used in this tile", HFILL }
},
{ &hf_vnc_hextile_raw_value,
{ "Raw pixel values", "vnc.hextile_raw_value",
FT_BYTES, BASE_NONE, NULL, 0x0,
"Raw subencoding pixel values", HFILL }
},
{ &hf_vnc_hextile_bg,
{ "Background Specified", "vnc.hextile_bg",
FT_UINT8, BASE_DEC, VALS(yes_no_vs), 0x2,
"Background Specified subencoding is used in this tile", HFILL }
},
{ &hf_vnc_hextile_bg_value,
{ "Background pixel value", "vnc.hextile_bg_value",
FT_BYTES, BASE_NONE, NULL, 0x0,
"Background color for this tile", HFILL }
},
{ &hf_vnc_hextile_fg,
{ "Foreground Specified", "vnc.hextile_fg",
FT_UINT8, BASE_DEC, VALS(yes_no_vs), 0x4,
"Foreground Specified subencoding is used in this tile", HFILL }
},
{ &hf_vnc_hextile_fg_value,
{ "Foreground pixel value", "vnc.hextile_fg_value",
FT_BYTES, BASE_NONE, NULL, 0x0,
"Foreground color for this tile", HFILL }
},
{ &hf_vnc_hextile_anysubrects,
{ "Any Subrects", "vnc.hextile_anysubrects",
FT_UINT8, BASE_DEC, VALS(yes_no_vs), 0x8,
"Any subrects subencoding is used in this tile", HFILL }
},
{ &hf_vnc_hextile_num_subrects,
{ "Number of subrectangles", "vnc.hextile_num_subrects",
FT_UINT8, BASE_DEC, NULL, 0x0,
"Number of subrectangles that follow", HFILL }
},
{ &hf_vnc_hextile_subrectscolored,
{ "Subrects Colored", "vnc.hextile_subrectscolored",
FT_UINT8, BASE_DEC, VALS(yes_no_vs), 0x10,
"Subrects colored subencoding is used in this tile", HFILL }
},
{ &hf_vnc_hextile_subrect_pixel_value,
{ "Pixel value", "vnc.hextile_subrect_pixel_value",
FT_BYTES, BASE_NONE, NULL, 0x0,
"Pixel value of this subrectangle", HFILL }
},
{ &hf_vnc_hextile_subrect_x_pos,
{ "X position", "vnc.hextile_subrect_x_pos",
FT_UINT8, BASE_DEC, NULL, 0xF0, /* Top 4 bits */
"X position of this subrectangle", HFILL }
},
{ &hf_vnc_hextile_subrect_y_pos,
{ "Y position", "vnc.hextile_subrect_y_pos",
FT_UINT8, BASE_DEC, NULL, 0xF, /* Bottom 4 bits */
"Y position of this subrectangle", HFILL }
},
{ &hf_vnc_hextile_subrect_width,
{ "Width", "vnc.hextile_subrect_width",
FT_UINT8, BASE_DEC, NULL, 0xF0, /* Top 4 bits */
"Subrectangle width minus one", HFILL }
},
{ &hf_vnc_hextile_subrect_height,
{ "Height", "vnc.hextile_subrect_height",
FT_UINT8, BASE_DEC, NULL, 0xF, /* Bottom 4 bits */
"Subrectangle height minus one", HFILL }
},
/* ZRLE Encoding */
{ &hf_vnc_zrle_len,
{ "ZRLE compressed length", "vnc.zrle_len",
FT_UINT32, BASE_DEC, NULL, 0x0,
"Length of compressed ZRLE data that follows", HFILL }
},
{ &hf_vnc_zrle_subencoding,
{ "Subencoding type", "vnc.zrle_subencoding",
FT_UINT8, BASE_DEC, NULL, 0x0,
"Subencoding type byte", HFILL }
},
{ &hf_vnc_zrle_rle,
{ "RLE", "vnc.zrle_rle",
FT_UINT8, BASE_DEC, VALS(yes_no_vs), 0x80, /* Upper bit */
"Specifies that data is run-length encoded", HFILL }
},
{ &hf_vnc_zrle_palette_size,
{ "Palette size", "vnc.zrle_palette_size",
FT_UINT8, BASE_DEC, NULL, 0x7F, /* Lower 7 bits */
"Palette size", HFILL }
},
{ &hf_vnc_zrle_data,
{ "ZRLE compressed data", "vnc.zrle_data",
FT_BYTES, BASE_NONE, NULL, 0x0,
"Compressed ZRLE data. Compiling with zlib support will uncompress and dissect this data", HFILL }
},
{ &hf_vnc_zrle_raw,
{ "Pixel values", "vnc.zrle_raw",
FT_BYTES, BASE_NONE, NULL, 0x0,
"Raw pixel values for this tile", HFILL }
},
{ &hf_vnc_zrle_palette,
{ "Palette", "vnc.zrle_palette",
FT_BYTES, BASE_NONE, NULL, 0x0,
"Palette pixel values", HFILL }
},
/* Server Set Colormap Entries */
{ &hf_vnc_colormap_first_color,
{ "First color", "vnc.colormap_first_color",
FT_UINT16, BASE_DEC, NULL, 0x0,
"First color that should be mapped to given RGB intensities", HFILL }
},
{ &hf_vnc_colormap_num_colors,
{ "Number of color groups", "vnc.colormap_groups",
FT_UINT16, BASE_DEC, NULL, 0x0,
"Number of red/green/blue color groups", HFILL }
},
{ &hf_vnc_colormap_red,
{ "Red", "vnc.colormap_red",
FT_UINT16, BASE_DEC, NULL, 0x0,
"Red intensity", HFILL }
},
{ &hf_vnc_colormap_green,
{ "Green", "vnc.colormap_green",
FT_UINT16, BASE_DEC, NULL, 0x0,
"Green intensity", HFILL }
},
{ &hf_vnc_colormap_blue,
{ "Blue", "vnc.colormap_blue",
FT_UINT16, BASE_DEC, NULL, 0x0,
"Blue intensity", HFILL }
},
/* Server Cut Text */
{ &hf_vnc_server_cut_text_len,
{ "Length", "vnc.server_cut_text_len",
FT_UINT32, BASE_DEC, NULL, 0x0,
"Length of server's copy/cut text (clipboard) string in bytes", HFILL }
},
{ &hf_vnc_server_cut_text,
{ "Text", "vnc.server_cut_text",
FT_STRING, BASE_NONE, NULL, 0x0,
"Text string in the server's copy/cut text (clipboard)", HFILL }
},
};
/* Setup protocol subtree arrays */
static gint *ett[] = {
&ett_vnc,
&ett_vnc_client_message_type,
&ett_vnc_server_message_type,
&ett_vnc_rect,
&ett_vnc_encoding_type,
&ett_vnc_rre_subrect,
&ett_vnc_hextile_subencoding_mask,
&ett_vnc_hextile_num_subrects,
&ett_vnc_hextile_subrect,
&ett_vnc_zrle_subencoding,
&ett_vnc_colormap_num_groups,
&ett_vnc_colormap_color_group
};
/* Register the protocol name and description */
proto_vnc = proto_register_protocol("Virtual Network Computing",
"VNC", "vnc");
/* Required function calls to register the header fields and subtrees */
proto_register_field_array(proto_vnc, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
/* Register our preferences module */
vnc_module = prefs_register_protocol(proto_vnc, proto_reg_handoff_vnc);
prefs_register_bool_preference(vnc_module, "desegment", "Reassemble VNC messages spanning multiple TCP segments.", "Whether the VNC dissector should reasss emble messages spanning multiple TCP segments. To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.", &vnc_preference_desegment);
prefs_register_uint_preference(vnc_module, "alternate_port", "Alternate TCP port", "Decode this port's traffic as VNC in addition to the default ports (5500, 5501, 5900, 5901)", 10, &vnc_preference_alternate_port);
}
void
proto_reg_handoff_vnc(void)
{
static gboolean inited = FALSE;
static dissector_handle_t vnc_handle;
/* This is a behind the scenes variable that is not changed by the user.
* This stores last setting of the vnc_preference_alternate_port. Used to keep
* track of when the user has changed the setting so that we can delete
* and re-register with the new port number. */
static guint vnc_preference_alternate_port_last = 0;
if(!inited) {
vnc_handle = create_dissector_handle(dissect_vnc, proto_vnc);
dissector_add("tcp.port", 5500, vnc_handle);
dissector_add("tcp.port", 5501, vnc_handle);
dissector_add("tcp.port", 5900, vnc_handle);
dissector_add("tcp.port", 5901, vnc_handle);
/* We don't register a port for the VNC HTTP server because
* that simply provides a java program for download via the
* HTTP protocol. The java program then connects to a standard
* VNC port. */
inited = TRUE;
} else { /* only after preferences have been read/changed */
if(vnc_preference_alternate_port != vnc_preference_alternate_port_last &&
vnc_preference_alternate_port != 5500 &&
vnc_preference_alternate_port != 5501 &&
vnc_preference_alternate_port != 5900 &&
vnc_preference_alternate_port != 5901) {
if (vnc_preference_alternate_port_last != 0) {
dissector_delete("tcp.port",
vnc_preference_alternate_port_last,
vnc_handle);
}
/* Save this setting to see if has changed later */
vnc_preference_alternate_port_last =
vnc_preference_alternate_port;
/* Register the new port setting */
if (vnc_preference_alternate_port != 0) {
dissector_add("tcp.port",
vnc_preference_alternate_port,
vnc_handle);
}
}
}
}
|