Coverage Report

Created: 2025-02-15 06:25

/src/wireshark/epan/dissectors/packet-vnc.c
Line
Count
Source (jump to first uncovered line)
1
/* packet-vnc.c
2
 * Routines for VNC dissection (Virtual Network Computing)
3
 * Copyright 2005, Ulf Lamping <ulf.lamping@web.de>
4
 * Copyright 2006-2007, Stephen Fisher (see AUTHORS file)
5
 *
6
 * Wireshark - Network traffic analyzer
7
 * By Gerald Combs <gerald@wireshark.org>
8
 * Copyright 1998 Gerald Combs
9
 *
10
 * SPDX-License-Identifier: GPL-2.0-or-later
11
 */
12
13
/* Dissection of the VNC (Virtual Network Computing) network traffic.
14
 *
15
 * All versions of RealVNC and TightVNC are supported.
16
 * Note: The addition of TightVNC support is not yet complete.
17
 *
18
 * Several VNC implementations available, see:
19
 * http://www.realvnc.com/
20
 * http://www.tightvnc.com/
21
 * http://ultravnc.sourceforge.net/
22
 * [Fedora TigerVNC]
23
 * ...
24
 *
25
 * The protocol itself is known as RFB - Remote Frame Buffer Protocol.
26
 *
27
 * This code is based on the protocol specification published in RFC 6143
28
 *  and the RealVNC free edition & TightVNC source code
29
 *  Note: rfbproto.rst [ https://github.com/svn2github/tigervnc/blob/master/rfbproto/rfbproto.rst ]
30
 *        seems to have additional information over rfbproto.pdf.
31
 */
32
33
/* XXX:
34
 *  This dissector adds items to the protocol tree before completing re-assembly
35
 *   of a VNC PDU which extends over more than one TCP segment.
36
 *  This is not correct. As noted in Bug #5366 (and elsewhere), the correct method
37
 *  is that:
38
 *   "one must walk over all the message first, to determine its exact length
39
 *    (one of the characteristics of the protocol, hard to determine prior to
40
 *    going over the message what its final size would be)".
41
 *
42
 *  The original method of reassembly:
43
 *    When more data is needed to continue dissecting a PDU, repeatedly request
44
 *    a few additional bytes (for one or a few more fields of the PDU).
45
 *   This resulted in 'one-pass' tshark dissection redissecting
46
 *    the PDU repeatedly many, many times with each time dissecting
47
 *    the PDU with one or a few more additional fields.
48
 *    This generated *lots* of (repeated) output since a reassembled
49
 *    VNC PDU can contain many fields (each of short length).
50
 *    It also resulted in the fragment table containing many, many small fragments
51
 *     for VNC PDUS containing many small fields.
52
 *
53
 *  The current reassembly method:
54
 *    Use DESEGMENT_ONE_MORE_SEGMENT when requesting additional data for a PDU.
55
 *    This significantly reduces the amount of repeated data in a dissection,
56
 *    but will still result in "partial" repeated dissection output in some cases.
57
 */
58
59
/* (Somewhat random notes while reviewing the code):
60
   Check types, etc against IANA list
61
   Optimize: Do col_set(..., COL_INFO) once (after fetching message type & before dispatching ?)
62
   Dispatch via a message table (instead of using a switch(...)
63
   Msg type 150: client-server: enable/disable (1+9 bytes); server-client: endofContinousUpdates(1+0 bytes) ?
64
*/
65
66
#include "config.h"
67
68
#include <epan/packet.h>
69
#include <epan/conversation.h>
70
#include <epan/prefs.h>
71
#include <epan/expert.h>
72
#include <epan/proto_data.h>
73
#include <epan/tfs.h>
74
#include <wsutil/array.h>
75
#include "packet-x11.h" /* This contains the extern for the X11 value_string_ext
76
       * "x11_keysym_vals_source_ext" that VNC uses. */
77
78
void proto_register_vnc(void);
79
80
typedef enum {
81
  VNC_SECURITY_TYPE_INVALID       =  0,
82
  VNC_SECURITY_TYPE_NONE          =  1,
83
  VNC_SECURITY_TYPE_VNC           =  2,
84
  VNC_SECURITY_TYPE_RA2           =  5,
85
  VNC_SECURITY_TYPE_RA2ne         =  6,
86
  VNC_SECURITY_TYPE_TIGHT         = 16,
87
  VNC_SECURITY_TYPE_ULTRA         = 17,
88
  VNC_SECURITY_TYPE_TLS           = 18,
89
  VNC_SECURITY_TYPE_VENCRYPT      = 19,
90
  VNC_SECURITY_TYPE_GTK_VNC_SASL  = 20,
91
  VNC_SECURITY_TYPE_MD5_HASH_AUTH = 21,
92
  VNC_SECURITY_TYPE_XVP           = 22,
93
  VNC_SECURITY_TYPE_ARD           = 30,
94
  VNC_TIGHT_AUTH_TGHT_ULGNAUTH    = 119,
95
  VNC_TIGHT_AUTH_TGHT_XTRNAUTH    = 130,
96
  VNC_VENCRYPT_AUTH_PLAIN         = 256,
97
  VNC_VENCRYPT_AUTH_TLSNONE       = 257,
98
  VNC_VENCRYPT_AUTH_TLSVNC        = 258,
99
  VNC_VENCRYPT_AUTH_TLSPLAIN      = 259,
100
  VNC_VENCRYPT_AUTH_X509_NONE     = 260,
101
  VNC_VENCRYPT_AUTH_X509_VNC      = 261,
102
  VNC_VENCRYPT_AUTH_X509_PLAIN    = 262,
103
  VNC_VENCRYPT_AUTH_TLSSASL       = 263,
104
  VNC_VENCRYPT_AUTH_X509_SASL     = 264
105
} vnc_security_types_e;
106
107
static const value_string vnc_security_types_vs[] = {
108
  { VNC_SECURITY_TYPE_INVALID,      "Invalid"              },
109
  { VNC_SECURITY_TYPE_NONE,         "None"                 },
110
  { VNC_SECURITY_TYPE_VNC,          "VNC"                  },
111
  { VNC_SECURITY_TYPE_RA2,          "RA2"                  },
112
  { VNC_SECURITY_TYPE_RA2ne,        "RA2ne"                },
113
  { VNC_SECURITY_TYPE_TIGHT,        "Tight"                },
114
  { VNC_SECURITY_TYPE_ULTRA,        "Ultra"                },
115
  { VNC_SECURITY_TYPE_TLS,          "TLS"                  },
116
  { VNC_SECURITY_TYPE_VENCRYPT,     "VeNCrypt"             },
117
  { VNC_SECURITY_TYPE_GTK_VNC_SASL, "GTK-VNC SASL"         },
118
  { VNC_SECURITY_TYPE_ARD,          "Apple Remote Desktop" },
119
  { 0,  NULL                     }
120
};
121
122
static const value_string vnc_vencrypt_auth_types_vs[] = {
123
  { VNC_SECURITY_TYPE_NONE,       "None"        },
124
  { VNC_SECURITY_TYPE_VNC,        "VNC"         },
125
  { VNC_VENCRYPT_AUTH_PLAIN,      "Plain"       },
126
  { VNC_VENCRYPT_AUTH_TLSNONE,    "TLS None"    },
127
  { VNC_VENCRYPT_AUTH_TLSVNC,     "TLS VNC"     },
128
  { VNC_VENCRYPT_AUTH_TLSPLAIN,   "TLS Plain"   },
129
  { VNC_VENCRYPT_AUTH_X509_NONE,  "X.509 None"  },
130
  { VNC_VENCRYPT_AUTH_X509_VNC,   "X.509 VNC"   },
131
  { VNC_VENCRYPT_AUTH_X509_PLAIN, "X.509 Plain" },
132
  { VNC_VENCRYPT_AUTH_TLSSASL,    "TLS SASL"    },
133
  { VNC_VENCRYPT_AUTH_X509_SASL,  "X.509 SASL"  },
134
  { 0,  NULL                     }
135
};
136
137
static const true_false_string auth_result_tfs = {
138
  "Failed",
139
  "OK"
140
};
141
142
typedef enum {
143
  /* Required */
144
  VNC_CLIENT_MESSAGE_TYPE_SET_PIXEL_FORMAT    =   0,
145
  VNC_CLIENT_MESSAGE_TYPE_SET_ENCODINGS     =   2,
146
  VNC_CLIENT_MESSAGE_TYPE_FRAMEBUF_UPDATE_REQ   =   3,
147
  VNC_CLIENT_MESSAGE_TYPE_KEY_EVENT     =   4,
148
  VNC_CLIENT_MESSAGE_TYPE_POINTER_EVENT     =   5,
149
  VNC_CLIENT_MESSAGE_TYPE_CLIENT_CUT_TEXT     =   6,
150
  /* Optional */
151
  VNC_CLIENT_MESSAGE_TYPE_MIRRORLINK      = 128,
152
  VNC_CLIENT_MESSAGE_TYPE_ENABLE_CONTINUOUS_UPDATES = 150,  /* TightVNC */
153
  VNC_CLIENT_MESSAGE_TYPE_FENCE       = 248,  /* TigerVNC */
154
  VNC_CLIENT_MESSAGE_TYPE_XVP       = 250,
155
  VNC_CLIENT_MESSAGE_TYPE_SETR_DESKTOP_SIZE   = 251,
156
  VNC_CLIENT_MESSAGE_TYPE_TIGHT       = 252,
157
  VNC_CLIENT_MESSAGE_TYPE_GII       = 253,
158
  VNC_CLIENT_MESSAGE_TYPE_QEMU        = 255
159
} vnc_client_message_types_e;
160
161
static const value_string vnc_client_message_types_vs[] = {
162
  /* Required */
163
  { VNC_CLIENT_MESSAGE_TYPE_SET_PIXEL_FORMAT,      "Set Pixel Format"     },
164
  { VNC_CLIENT_MESSAGE_TYPE_SET_ENCODINGS,       "Set Encodings"      },
165
  { VNC_CLIENT_MESSAGE_TYPE_FRAMEBUF_UPDATE_REQ,       "Framebuffer Update Request" },
166
  { VNC_CLIENT_MESSAGE_TYPE_KEY_EVENT,         "Key Event"      },
167
  { VNC_CLIENT_MESSAGE_TYPE_POINTER_EVENT,       "Pointer Event"            },
168
  { VNC_CLIENT_MESSAGE_TYPE_CLIENT_CUT_TEXT,       "Cut Text"                   },
169
  /* Optional */
170
  { VNC_CLIENT_MESSAGE_TYPE_MIRRORLINK,        "MirrorLink"     },
171
  { VNC_CLIENT_MESSAGE_TYPE_ENABLE_CONTINUOUS_UPDATES, "Enable Continuous Updates"  },
172
  { VNC_CLIENT_MESSAGE_TYPE_FENCE,         "Fence"        },
173
  { VNC_CLIENT_MESSAGE_TYPE_XVP,           "Xvp"        },
174
  { VNC_CLIENT_MESSAGE_TYPE_SETR_DESKTOP_SIZE,       "Setr Desktop Size"    },
175
  { VNC_CLIENT_MESSAGE_TYPE_TIGHT,         "Tight"        },
176
  { VNC_CLIENT_MESSAGE_TYPE_GII,           "Gii"        },
177
  { VNC_CLIENT_MESSAGE_TYPE_QEMU,          "Qemu"       },
178
  { 0,  NULL                                      }
179
};
180
181
typedef enum {
182
  VNC_SERVER_MESSAGE_TYPE_FRAMEBUFFER_UPDATE    =   0,
183
  VNC_SERVER_MESSAGE_TYPE_SET_COLORMAP_ENTRIES    =   1,
184
  VNC_SERVER_MESSAGE_TYPE_RING_BELL     =   2,
185
  VNC_SERVER_MESSAGE_TYPE_CUT_TEXT      =   3,
186
  VNC_SERVER_MESSAGE_TYPE_MIRRORLINK      = 128,
187
  VNC_SERVER_MESSAGE_TYPE_END_CONTINUOUS_UPDATES    = 150,  /* TightVNC */
188
  VNC_SERVER_MESSAGE_TYPE_FENCE       = 248,  /* TigerVNC */
189
  VNC_SERVER_MESSAGE_TYPE_XVP       = 250,
190
  VNC_SERVER_MESSAGE_TYPE_TIGHT       = 252,
191
  VNC_SERVER_MESSAGE_TYPE_GII       = 253,
192
  VNC_SERVER_MESSAGE_TYPE_QEMU        = 255
193
} vnc_server_message_types_e;
194
195
static const value_string vnc_server_message_types_vs[] = {
196
  { VNC_SERVER_MESSAGE_TYPE_FRAMEBUFFER_UPDATE,      "Framebuffer Update"  },
197
  { VNC_SERVER_MESSAGE_TYPE_SET_COLORMAP_ENTRIES,      "Set Colormap Entries"  },
198
  { VNC_SERVER_MESSAGE_TYPE_RING_BELL,         "Ring Bell"     },
199
  { VNC_SERVER_MESSAGE_TYPE_CUT_TEXT,        "Cut Text"      },
200
  { VNC_SERVER_MESSAGE_TYPE_MIRRORLINK,        "MirrorLink"    },
201
  { VNC_SERVER_MESSAGE_TYPE_END_CONTINUOUS_UPDATES,    "End Continuous Updates" },
202
  { VNC_SERVER_MESSAGE_TYPE_FENCE,         "Fence"       },
203
  { VNC_SERVER_MESSAGE_TYPE_XVP,           "Xvp"       },
204
  { VNC_SERVER_MESSAGE_TYPE_TIGHT,         "Tight"       },
205
  { VNC_SERVER_MESSAGE_TYPE_GII,           "Gii"       },
206
  { VNC_SERVER_MESSAGE_TYPE_QEMU,          "Qemu"      },
207
  { 0,  NULL                   }
208
};
209
210
211
0
#define VNC_ENCODING_TYPE_DESKTOP_SIZE       0xFFFFFF21
212
0
#define VNC_ENCODING_TYPE_LAST_RECT          0xFFFFFF20
213
0
#define VNC_ENCODING_TYPE_POINTER_POS        0xFFFFFF18
214
0
#define VNC_ENCODING_TYPE_RICH_CURSOR        0xFFFFFF11
215
0
#define VNC_ENCODING_TYPE_X_CURSOR           0xFFFFFF10
216
0
#define VNC_ENCODING_TYPE_RAW                0
217
0
#define VNC_ENCODING_TYPE_COPY_RECT          1
218
0
#define VNC_ENCODING_TYPE_RRE                2
219
0
#define VNC_ENCODING_TYPE_CORRE              4
220
0
#define VNC_ENCODING_TYPE_HEXTILE            5
221
0
#define VNC_ENCODING_TYPE_ZLIB               6
222
0
#define VNC_ENCODING_TYPE_TIGHT              7
223
#define VNC_ENCODING_TYPE_ZLIBHEX            8
224
#define VNC_ENCODING_TYPE_ULTRA              9
225
#define VNC_ENCODING_TYPE_TRLE               15
226
0
#define VNC_ENCODING_TYPE_RLE              16
227
#define VNC_ENCODING_TYPE_HITACHI_ZYWRLE     17
228
#define VNC_ENCODING_TYPE_JPEG_0             -32
229
#define VNC_ENCODING_TYPE_JPEG_1             -31
230
#define VNC_ENCODING_TYPE_JPEG_2             -30
231
#define VNC_ENCODING_TYPE_JPEG_3             -29
232
#define VNC_ENCODING_TYPE_JPEG_4             -28
233
#define VNC_ENCODING_TYPE_JPEG_5             -27
234
#define VNC_ENCODING_TYPE_JPEG_6             -26
235
#define VNC_ENCODING_TYPE_JPEG_7             -25
236
#define VNC_ENCODING_TYPE_JPEG_8             -24
237
#define VNC_ENCODING_TYPE_JPEG_9             -23
238
#define VNC_ENCODING_TYPE_COMPRESSION_0      0xFFFFFF00
239
#define VNC_ENCODING_TYPE_COMPRESSION_1      0xFFFFFF01
240
#define VNC_ENCODING_TYPE_COMPRESSION_2      0xFFFFFF02
241
#define VNC_ENCODING_TYPE_COMPRESSION_3      0xFFFFFF03
242
#define VNC_ENCODING_TYPE_COMPRESSION_4      0xFFFFFF04
243
#define VNC_ENCODING_TYPE_COMPRESSION_5      0xFFFFFF05
244
#define VNC_ENCODING_TYPE_COMPRESSION_6      0xFFFFFF06
245
#define VNC_ENCODING_TYPE_COMPRESSION_7      0xFFFFFF07
246
#define VNC_ENCODING_TYPE_COMPRESSION_8      0xFFFFFF08
247
#define VNC_ENCODING_TYPE_COMPRESSION_9      0xFFFFFF09
248
#define VNC_ENCODING_TYPE_WMVi               0x574D5669
249
#define VNC_ENCODING_TYPE_CACHE              0xFFFF0000
250
#define VNC_ENCODING_TYPE_CACHE_ENABLE       0xFFFF0001
251
#define VNC_ENCODING_TYPE_XOR_ZLIB           0xFFFF0002
252
#define VNC_ENCODING_TYPE_XOR_MONO_ZLIB      0xFFFF0003
253
#define VNC_ENCODING_TYPE_XOR_MULTI_ZLIB     0xFFFF0004
254
#define VNC_ENCODING_TYPE_SOLID_COLOR        0xFFFF0005
255
#define VNC_ENCODING_TYPE_XOR_ENABLE         0xFFFF0006
256
#define VNC_ENCODING_TYPE_CACHE_ZIP          0xFFFF0007
257
#define VNC_ENCODING_TYPE_SOL_MONO_ZIP       0xFFFF0008
258
#define VNC_ENCODING_TYPE_ULTRA_ZIP          0xFFFF0009
259
#define VNC_ENCODING_TYPE_SERVER_STATE       0xFFFF8000
260
#define VNC_ENCODING_TYPE_ENABLE_KEEP_ALIVE  0xFFFF8001
261
#define VNC_ENCODING_TYPE_FTP_PROTO_VER      0xFFFF8002
262
#define VNC_ENCODING_TYPE_POINTER_CHANGE     -257
263
#define VNC_ENCODING_TYPE_EXT_KEY_EVENT      -258
264
#define VNC_ENCODING_TYPE_AUDIO               259
265
#define VNC_ENCODING_TYPE_DESKTOP_NAME       -307
266
0
#define VNC_ENCODING_TYPE_EXTENDED_DESK_SIZE -308
267
0
#define VNC_ENCODING_TYPE_KEYBOARD_LED_STATE 0XFFFE0000
268
0
#define VNC_ENCODING_TYPE_SUPPORTED_MESSAGES 0XFFFE0001
269
0
#define VNC_ENCODING_TYPE_SUPPORTED_ENCODINGS 0XFFFE0002
270
0
#define VNC_ENCODING_TYPE_SERVER_IDENTITY    0XFFFE0003
271
#define VNC_ENCODING_TYPE_MIRRORLINK         0xFFFFFDF5
272
0
#define VNC_ENCODING_TYPE_CONTEXT_INFORMATION 0xFFFFFDF4
273
0
#define VNC_ENCODING_TYPE_SLRLE              0xFFFFFDF3
274
#define VNC_ENCODING_TYPE_TRANSFORM          0xFFFFFDF2
275
#define VNC_ENCODING_TYPE_HSML               0xFFFFFDF1
276
0
#define VNC_ENCODING_TYPE_H264               0X48323634
277
278
static const value_string encoding_types_vs[] = {
279
  { VNC_ENCODING_TYPE_DESKTOP_SIZE, "DesktopSize (pseudo)" },
280
  { VNC_ENCODING_TYPE_LAST_RECT,    "LastRect (pseudo)"    },
281
  { VNC_ENCODING_TYPE_POINTER_POS,  "Pointer pos (pseudo)" },
282
  { VNC_ENCODING_TYPE_RICH_CURSOR,  "Rich Cursor (pseudo)" },
283
  { VNC_ENCODING_TYPE_X_CURSOR,   "X Cursor (pseudo)"    },
284
  { VNC_ENCODING_TYPE_RAW,    "Raw"                  },
285
  { VNC_ENCODING_TYPE_COPY_RECT,    "CopyRect"             },
286
  { VNC_ENCODING_TYPE_RRE,    "RRE"                  },
287
  { VNC_ENCODING_TYPE_CORRE,    "CoRRE"                },
288
  { VNC_ENCODING_TYPE_HEXTILE,    "Hextile"              },
289
  { VNC_ENCODING_TYPE_ZLIB,   "Zlib"                 },
290
  { VNC_ENCODING_TYPE_TIGHT,    "Tight"                },
291
  { VNC_ENCODING_TYPE_ZLIBHEX,    "ZlibHex"              },
292
  { VNC_ENCODING_TYPE_ULTRA,    "Ultra"          },
293
  { VNC_ENCODING_TYPE_RLE,    "ZRLE"                 },
294
  { VNC_ENCODING_TYPE_HITACHI_ZYWRLE, "Hitachi ZYWRLE"       },
295
  { VNC_ENCODING_TYPE_JPEG_0,   "JPEG quality level 0" },
296
  { VNC_ENCODING_TYPE_JPEG_1,   "JPEG quality level 1" },
297
  { VNC_ENCODING_TYPE_JPEG_2,   "JPEG quality level 2" },
298
  { VNC_ENCODING_TYPE_JPEG_3,   "JPEG quality level 3" },
299
  { VNC_ENCODING_TYPE_JPEG_4,   "JPEG quality level 4" },
300
  { VNC_ENCODING_TYPE_JPEG_5,   "JPEG quality level 5" },
301
  { VNC_ENCODING_TYPE_JPEG_6,   "JPEG quality level 6" },
302
  { VNC_ENCODING_TYPE_JPEG_7,   "JPEG quality level 7" },
303
  { VNC_ENCODING_TYPE_JPEG_8,   "JPEG quality level 8" },
304
  { VNC_ENCODING_TYPE_JPEG_9,   "JPEG quality level 9" },
305
  { VNC_ENCODING_TYPE_COMPRESSION_0,  "Compression level 0"  },
306
  { VNC_ENCODING_TYPE_COMPRESSION_1,  "Compression level 1"  },
307
  { VNC_ENCODING_TYPE_COMPRESSION_2,  "Compression level 2"  },
308
  { VNC_ENCODING_TYPE_COMPRESSION_3,  "Compression level 3"  },
309
  { VNC_ENCODING_TYPE_COMPRESSION_4,  "Compression level 4"  },
310
  { VNC_ENCODING_TYPE_COMPRESSION_5,  "Compression level 5"  },
311
  { VNC_ENCODING_TYPE_COMPRESSION_6,  "Compression level 6"  },
312
  { VNC_ENCODING_TYPE_COMPRESSION_7,  "Compression level 7"  },
313
  { VNC_ENCODING_TYPE_COMPRESSION_8,  "Compression level 8"  },
314
  { VNC_ENCODING_TYPE_COMPRESSION_9,  "Compression level 9"  },
315
  /* FIXME understand for real what the below mean. Taken from Ultra VNC source code */
316
/*  { VNC_ENCODING_TYPE_CACHE,     */
317
  { VNC_ENCODING_TYPE_CACHE_ENABLE,   "Enable Caching"},
318
/*  { VNC_ENCODING_TYPE_XOR_ZLIB,
319
  { VNC_ENCODING_TYPE_XOR_MONO_ZLIB,
320
  { VNC_ENCODING_TYPE_XOR_MULTI_ZLIB,
321
  { VNC_ENCODING_TYPE_SOLID_COLOR,
322
  { VNC_ENCODING_TYPE_XOR_ENABLE,
323
  { VNC_ENCODING_TYPE_CACHE_ZIP,
324
  { VNC_ENCODING_TYPE_SOL_MONO_ZIP,
325
  { VNC_ENCODING_TYPE_ULTRA_ZIP,
326
*/  { VNC_ENCODING_TYPE_SERVER_STATE,   "Server State"         },
327
  { VNC_ENCODING_TYPE_ENABLE_KEEP_ALIVE,  "Enable Keep Alive"    },
328
  { VNC_ENCODING_TYPE_FTP_PROTO_VER,  "FTP protocol version" },
329
  { VNC_ENCODING_TYPE_EXTENDED_DESK_SIZE, "Extended Desktop Size"},
330
  { VNC_ENCODING_TYPE_DESKTOP_NAME, "Desktop Name"         },
331
  { VNC_ENCODING_TYPE_KEYBOARD_LED_STATE, "Keyboard LED State"   },
332
  { VNC_ENCODING_TYPE_SUPPORTED_MESSAGES, "Supported Messages"   },
333
  { VNC_ENCODING_TYPE_SUPPORTED_ENCODINGS, "Supported Encodings" },
334
  { VNC_ENCODING_TYPE_SERVER_IDENTITY,  "Server Identity"      },
335
  { VNC_ENCODING_TYPE_MIRRORLINK,   "MirrorLink"           },
336
  { VNC_ENCODING_TYPE_CONTEXT_INFORMATION, "Context Information" },
337
  { VNC_ENCODING_TYPE_SLRLE,    "SLRLE"                },
338
  { VNC_ENCODING_TYPE_TRANSFORM,    "Transform"            },
339
  { VNC_ENCODING_TYPE_HSML,   "HSML"                 },
340
  { VNC_ENCODING_TYPE_H264,   "H264"                 },
341
  { 0,        NULL                   }
342
};
343
344
/* Rectangle types for Tight encoding.  These come in the "control byte" at the
345
 * start of a rectangle's payload.  Note that these are with respect to the most
346
 * significant bits 4-7 of the control byte, so you must shift it to the right 4
347
 * bits before comparing against these values.
348
 */
349
0
#define TIGHT_RECT_FILL      0x08
350
0
#define TIGHT_RECT_JPEG      0x09
351
0
#define TIGHT_RECT_MAX_VALUE 0x09
352
353
0
#define TIGHT_RECT_EXPLICIT_FILTER_FLAG 0x04
354
355
/* Filter types for Basic encoding of Tight rectangles */
356
0
#define TIGHT_RECT_FILTER_COPY     0x00
357
0
#define TIGHT_RECT_FILTER_PALETTE  0x01
358
0
#define TIGHT_RECT_FILTER_GRADIENT 0x02
359
360
/* Minimum number of bytes to compress for Tight encoding */
361
0
#define TIGHT_MIN_BYTES_TO_COMPRESS 12
362
363
static const value_string tight_filter_ids_vs[] = {
364
  { TIGHT_RECT_FILTER_COPY,     "Copy"     },
365
  { TIGHT_RECT_FILTER_PALETTE,  "Palette"  },
366
  { TIGHT_RECT_FILTER_GRADIENT, "Gradient" },
367
  { 0, NULL }
368
};
369
370
/* MirrorLink messages */
371
typedef enum {
372
  VNC_ML_EXT_BYE_BYE                      = 0,
373
  VNC_ML_EXT_SERVER_DISPLAY_CONFIGURATION = 1,
374
  VNC_ML_EXT_CLIENT_DISPLAY_CONFIGURATION = 2,
375
  VNC_ML_EXT_SERVER_EVENT_CONFIGURATION   = 3,
376
  VNC_ML_EXT_CLIENT_EVENT_CONFIGURATION   = 4,
377
  VNC_ML_EXT_EVENT_MAPPING                = 5,
378
  VNC_ML_EXT_EVENT_MAPPING_REQUEST        = 6,
379
  VNC_ML_EXT_KEY_EVENT_LISTING            = 7,
380
  VNC_ML_EXT_KEY_EVENT_LISTING_REQUEST    = 8,
381
  VNC_ML_EXT_VIRTUAL_KEYBOARD             = 9,
382
  VNC_ML_EXT_VIRTUAL_KEYBOARD_REQUEST     = 10,
383
  VNC_ML_EXT_DEVICE_STATUS                = 11,
384
  VNC_ML_EXT_DEVICE_STATUS_REQUEST        = 12,
385
  VNC_ML_EXT_CONTENT_ATTESTATION          = 13,
386
  VNC_ML_EXT_CONTENT_ATTESTATION_REQUEST  = 14,
387
  VNC_ML_EXT_FB_BLOCKING_NOTIFICATION     = 16,
388
  VNC_ML_EXT_AUDIO_BLOCKING_NOTIFICATION  = 18,
389
  VNC_ML_EXT_TOUCH_EVENT                  = 20,
390
  VNC_ML_EXT_FB_ALTERNATIVE_TEXT          = 21,
391
  VNC_ML_EXT_FB_ALTERNATIVE_TEXT_REQUEST  = 22
392
} vnc_mirrorlink_ext_types_e;
393
394
static const value_string vnc_mirrorlink_types_vs[] = {
395
  { VNC_ML_EXT_BYE_BYE,                      "ByeBye"                               },
396
  { VNC_ML_EXT_SERVER_DISPLAY_CONFIGURATION, "Server Display Configuration"         },
397
  { VNC_ML_EXT_CLIENT_DISPLAY_CONFIGURATION, "Client Display Configuration"         },
398
  { VNC_ML_EXT_SERVER_EVENT_CONFIGURATION,   "Server Event Configuration"           },
399
  { VNC_ML_EXT_CLIENT_EVENT_CONFIGURATION,   "Client Event Configuration"           },
400
  { VNC_ML_EXT_EVENT_MAPPING,                "Event Mapping"                        },
401
  { VNC_ML_EXT_EVENT_MAPPING_REQUEST,        "Event Mapping Request"                },
402
  { VNC_ML_EXT_KEY_EVENT_LISTING,            "Key Event Listing"                    },
403
  { VNC_ML_EXT_KEY_EVENT_LISTING_REQUEST,    "Key Event Listing Request"            },
404
  { VNC_ML_EXT_VIRTUAL_KEYBOARD,             "Virtual Keyboard Trigger"             },
405
  { VNC_ML_EXT_VIRTUAL_KEYBOARD_REQUEST,     "Virtual Keyboard Trigger Request"     },
406
  { VNC_ML_EXT_DEVICE_STATUS,                "Device Status"                        },
407
  { VNC_ML_EXT_DEVICE_STATUS_REQUEST,        "Device Status Request"                },
408
  { VNC_ML_EXT_CONTENT_ATTESTATION,          "Content Attestation"                  },
409
  { VNC_ML_EXT_CONTENT_ATTESTATION_REQUEST,  "Content Attestation Request"          },
410
  { VNC_ML_EXT_FB_BLOCKING_NOTIFICATION,     "Framebuffer Blocking Notification"    },
411
  { VNC_ML_EXT_AUDIO_BLOCKING_NOTIFICATION,  "Audio Blocking Notification"          },
412
  { VNC_ML_EXT_TOUCH_EVENT,                  "Touch Event"                          },
413
  { VNC_ML_EXT_FB_ALTERNATIVE_TEXT,          "Framebuffer Alternative Text"         },
414
  { VNC_ML_EXT_FB_ALTERNATIVE_TEXT_REQUEST,  "Framebuffer Alternative Text Request" },
415
  { 0,  NULL                                                                        }
416
};
417
418
/* Slice types for H.264 encoding */
419
typedef enum {
420
  VNC_H264_SLICE_TYPE_P = 0,
421
  VNC_H264_SLICE_TYPE_B = 1,
422
  VNC_H264_SLICE_TYPE_I = 2
423
} vnc_h264_slice_types_e;
424
425
static const value_string vnc_h264_slice_types_vs[] = {
426
  { VNC_H264_SLICE_TYPE_P, "Predicted"    },
427
  { VNC_H264_SLICE_TYPE_B, "Bi-predicted" },
428
  { VNC_H264_SLICE_TYPE_I, "Intra coded"  },
429
  { 0, NULL                               }
430
};
431
432
433
typedef enum {
434
  VNC_SESSION_STATE_SERVER_VERSION,
435
  VNC_SESSION_STATE_CLIENT_VERSION,
436
437
  VNC_SESSION_STATE_SECURITY,
438
  VNC_SESSION_STATE_SECURITY_TYPES,
439
440
  VNC_SESSION_STATE_TIGHT_TUNNELING_CAPABILITIES,
441
  VNC_SESSION_STATE_TIGHT_TUNNEL_TYPE_REPLY,
442
  VNC_SESSION_STATE_TIGHT_AUTH_CAPABILITIES,
443
  VNC_SESSION_STATE_TIGHT_AUTH_TYPE_REPLY,
444
  VNC_SESSION_STATE_TIGHT_UNKNOWN_PACKET3,
445
446
  VNC_SESSION_STATE_VNC_AUTHENTICATION_CHALLENGE,
447
  VNC_SESSION_STATE_VNC_AUTHENTICATION_RESPONSE,
448
449
  VNC_SESSION_STATE_ARD_AUTHENTICATION_CHALLENGE,
450
  VNC_SESSION_STATE_ARD_AUTHENTICATION_RESPONSE,
451
452
  VNC_SESSION_STATE_SECURITY_RESULT,
453
454
  VNC_SESSION_STATE_VENCRYPT_SERVER_VERSION,
455
  VNC_SESSION_STATE_VENCRYPT_CLIENT_VERSION,
456
  VNC_SESSION_STATE_VENCRYPT_AUTH_CAPABILITIES,
457
  VNC_SESSION_STATE_VENCRYPT_AUTH_TYPE_REPLY,
458
  VNC_SESSION_STATE_VENCRYPT_AUTH_ACK,
459
460
  VNC_SESSION_STATE_CLIENT_INIT,
461
  VNC_SESSION_STATE_SERVER_INIT,
462
463
  VNC_SESSION_STATE_TIGHT_INTERACTION_CAPS,
464
465
  VNC_SESSION_STATE_NORMAL_TRAFFIC
466
} vnc_session_state_e;
467
468
14
#define VNC_FENCE_BLOCK_BEFORE   0x00000001
469
14
#define VNC_FENCE_BLOCK_AFTER    0x00000002
470
14
#define VNC_FENCE_SYNC_NEXT      0x00000004
471
14
#define VNC_FENCE_REQUEST        0x80000000
472
473
/* This structure will be tied to each conversation. */
474
typedef struct {
475
  double server_proto_ver, client_proto_ver;
476
  uint32_t server_port;
477
  /* These are specific to TightVNC */
478
  int num_server_message_types;
479
  int num_client_message_types;
480
  int num_encoding_types;
481
  uint8_t security_type_selected;
482
  bool tight_enabled;
483
  /* This is specific to Apple Remote Desktop */
484
  uint16_t ard_key_length;
485
  /* State information valid on first sequential pass;
486
   * stored in per-packet info for subsequent passes. */
487
  uint8_t bytes_per_pixel;
488
  uint8_t depth;
489
  vnc_session_state_e vnc_next_state;
490
  int preferred_encoding;
491
} vnc_conversation_t;
492
493
/* This structure will be tied to each packet */
494
typedef struct {
495
  vnc_session_state_e state;
496
  //int preferred_encoding; XXX: Not actually used?
497
  uint8_t bytes_per_pixel;
498
  uint8_t depth;
499
} vnc_packet_t;
500
501
void proto_reg_handoff_vnc(void);
502
503
static bool vnc_startup_messages(tvbuff_t *tvb, packet_info *pinfo,
504
             int offset, proto_tree *tree,
505
             vnc_conversation_t *per_conversation_info);
506
static void vnc_client_to_server(tvbuff_t *tvb, packet_info *pinfo,
507
         int *offset, proto_tree *tree,
508
         vnc_conversation_t *per_conversation_info);
509
static void vnc_server_to_client(tvbuff_t *tvb, packet_info *pinfo,
510
         int *offset, proto_tree *tree);
511
static void vnc_client_set_pixel_format(tvbuff_t *tvb, packet_info *pinfo,
512
          int *offset, proto_tree *tree,
513
          vnc_conversation_t *per_conversation_info);
514
static void vnc_client_set_encodings(tvbuff_t *tvb, packet_info *pinfo,
515
             int *offset, proto_tree *tree,
516
             vnc_conversation_t *per_conversation_info);
517
static void vnc_client_framebuffer_update_request(tvbuff_t *tvb,
518
              packet_info *pinfo,
519
              int *offset,
520
              proto_tree *tree);
521
static void vnc_client_key_event(tvbuff_t *tvb, packet_info *pinfo,
522
         int *offset, proto_tree *tree);
523
static void vnc_client_pointer_event(tvbuff_t *tvb, packet_info *pinfo,
524
             int *offset, proto_tree *tree);
525
static void vnc_client_cut_text(tvbuff_t *tvb, packet_info *pinfo, int *offset,
526
        proto_tree *tree);
527
528
static unsigned vnc_server_framebuffer_update(tvbuff_t *tvb, packet_info *pinfo,
529
             int *offset, proto_tree *tree);
530
static unsigned vnc_raw_encoding(tvbuff_t *tvb, packet_info *pinfo, int *offset,
531
            proto_tree *tree, const uint16_t width, const uint16_t height);
532
static unsigned vnc_copyrect_encoding(tvbuff_t *tvb, packet_info *pinfo,
533
           int *offset, proto_tree *tree,
534
           const uint16_t width, const uint16_t height);
535
static unsigned vnc_rre_encoding(tvbuff_t *tvb, packet_info *pinfo, int *offset,
536
            proto_tree *tree, const uint16_t width, const uint16_t height);
537
static unsigned vnc_hextile_encoding(tvbuff_t *tvb, packet_info *pinfo,
538
          int *offset, proto_tree *tree,
539
          const uint16_t width, const uint16_t height);
540
static unsigned vnc_zrle_encoding(tvbuff_t *tvb, packet_info *pinfo, int *offset,
541
             proto_tree *tree, const uint16_t width, const uint16_t height);
542
static unsigned vnc_tight_encoding(tvbuff_t *tvb, packet_info *pinfo, int *offset,
543
        proto_tree *tree, const uint16_t width, const uint16_t height);
544
static unsigned vnc_rich_cursor_encoding(tvbuff_t *tvb, packet_info *pinfo,
545
              int *offset, proto_tree *tree, const uint16_t width,
546
              const uint16_t height);
547
static unsigned vnc_x_cursor_encoding(tvbuff_t *tvb, packet_info *pinfo,
548
           int *offset, proto_tree *tree, const uint16_t width,
549
           const uint16_t height);
550
static unsigned vnc_server_set_colormap_entries(tvbuff_t *tvb, packet_info *pinfo,
551
               int *offset, proto_tree *tree);
552
static void vnc_server_ring_bell(tvbuff_t *tvb, packet_info *pinfo,
553
         int *offset, proto_tree *tree);
554
static unsigned vnc_server_cut_text(tvbuff_t *tvb, packet_info *pinfo,
555
         int *offset, proto_tree *tree);
556
static void vnc_set_bytes_per_pixel(packet_info *pinfo, vnc_conversation_t *per_conversation_info, const uint8_t bytes_per_pixel);
557
static void vnc_set_depth(packet_info *pinfo, vnc_conversation_t *per_conversation_info, const uint8_t depth);
558
static uint8_t vnc_get_bytes_per_pixel(packet_info *pinfo);
559
static uint8_t vnc_get_depth(packet_info *pinfo);
560
static uint32_t vnc_extended_desktop_size(tvbuff_t *tvb, int *offset, proto_tree *tree);
561
562
static unsigned vnc_supported_messages(tvbuff_t *tvb, int *offset,
563
            proto_tree *tree, const uint16_t width);
564
static unsigned vnc_supported_encodings(tvbuff_t *tvb, int *offset,
565
             proto_tree *tree, const uint16_t width,
566
             const uint16_t height);
567
static unsigned vnc_server_identity(tvbuff_t *tvb, int *offset,
568
         proto_tree *tree, const uint16_t width);
569
570
static unsigned vnc_fence(tvbuff_t *tvb, packet_info *pinfo, int *offset,
571
          proto_tree *tree);
572
static unsigned vnc_mirrorlink(tvbuff_t *tvb, packet_info *pinfo, int *offset,
573
          proto_tree *tree);
574
static unsigned vnc_context_information(tvbuff_t *tvb, int *offset,
575
             proto_tree *tree);
576
static unsigned vnc_slrle_encoding(tvbuff_t *tvb, packet_info *pinfo, int *offset,
577
        proto_tree *tree, const uint16_t height);
578
579
static unsigned vnc_h264_encoding(tvbuff_t *tvb, int *offset, proto_tree *tree);
580
581
#define VNC_BYTES_NEEDED(a)         \
582
0
  if((a) > (unsigned)tvb_reported_length_remaining(tvb, *offset)) \
583
0
    return (a);
584
585
/* Initialize the protocol and registered fields */
586
static int proto_vnc; /* Protocol subtree */
587
static int hf_vnc_padding;
588
static int hf_vnc_server_proto_ver;
589
static int hf_vnc_client_proto_ver;
590
static int hf_vnc_num_security_types;
591
static int hf_vnc_security_type;
592
static int hf_vnc_server_security_type;
593
static int hf_vnc_client_security_type;
594
static int hf_vnc_auth_challenge;
595
static int hf_vnc_auth_response;
596
static int hf_vnc_auth_result;
597
static int hf_vnc_auth_error;
598
static int hf_vnc_auth_error_length;
599
600
static int hf_vnc_ard_auth_generator;
601
static int hf_vnc_ard_auth_key_len;
602
static int hf_vnc_ard_auth_modulus;
603
static int hf_vnc_ard_auth_server_key;
604
static int hf_vnc_ard_auth_credentials;
605
static int hf_vnc_ard_auth_client_key;
606
607
static int hf_vnc_share_desktop_flag;
608
static int hf_vnc_width;
609
static int hf_vnc_height;
610
static int hf_vnc_server_bits_per_pixel;
611
static int hf_vnc_server_depth;
612
static int hf_vnc_server_big_endian_flag;
613
static int hf_vnc_server_true_color_flag;
614
static int hf_vnc_server_red_max;
615
static int hf_vnc_server_green_max;
616
static int hf_vnc_server_blue_max;
617
static int hf_vnc_server_red_shift;
618
static int hf_vnc_server_green_shift;
619
static int hf_vnc_server_blue_shift;
620
static int hf_vnc_desktop_name;
621
static int hf_vnc_desktop_name_len;
622
static int hf_vnc_desktop_screen_num;
623
static int hf_vnc_desktop_screen_id;
624
static int hf_vnc_desktop_screen_x;
625
static int hf_vnc_desktop_screen_y;
626
static int hf_vnc_desktop_screen_width;
627
static int hf_vnc_desktop_screen_height;
628
static int hf_vnc_desktop_screen_flags;
629
static int hf_vnc_num_server_message_types;
630
static int hf_vnc_num_client_message_types;
631
static int hf_vnc_num_encoding_types;
632
633
/********** Client Message Types **********/
634
635
static int hf_vnc_client_message_type; /* A subtree under VNC */
636
static int hf_vnc_client_bits_per_pixel;
637
static int hf_vnc_client_depth;
638
static int hf_vnc_client_big_endian_flag;
639
static int hf_vnc_client_true_color_flag;
640
static int hf_vnc_client_red_max;
641
static int hf_vnc_client_green_max;
642
static int hf_vnc_client_blue_max;
643
static int hf_vnc_client_red_shift;
644
static int hf_vnc_client_green_shift;
645
static int hf_vnc_client_blue_shift;
646
647
/* Client Key Event */
648
static int hf_vnc_key_down;
649
static int hf_vnc_key;
650
651
/* Client Pointer Event */
652
static int hf_vnc_button_1_pos;
653
static int hf_vnc_button_2_pos;
654
static int hf_vnc_button_3_pos;
655
static int hf_vnc_button_4_pos;
656
static int hf_vnc_button_5_pos;
657
static int hf_vnc_button_6_pos;
658
static int hf_vnc_button_7_pos;
659
static int hf_vnc_button_8_pos;
660
static int hf_vnc_pointer_x_pos;
661
static int hf_vnc_pointer_y_pos;
662
663
/* Client Framebuffer Update Request */
664
static int hf_vnc_update_req_incremental;
665
static int hf_vnc_update_req_x_pos;
666
static int hf_vnc_update_req_y_pos;
667
static int hf_vnc_update_req_width;
668
static int hf_vnc_update_req_height;
669
670
/* Client Set Encodings */
671
static int hf_vnc_encoding_num;
672
static int hf_vnc_client_set_encodings_encoding_type;
673
674
/* Client Cut Text */
675
static int hf_vnc_client_cut_text_len;
676
static int hf_vnc_client_cut_text;
677
678
/********** Server Message Types **********/
679
680
static int hf_vnc_server_message_type; /* Subtree */
681
682
/* Tunneling capabilities (TightVNC extension) */
683
static int hf_vnc_tight_num_tunnel_types;
684
static int hf_vnc_tight_tunnel_type_code;
685
static int hf_vnc_tight_tunnel_type_vendor;
686
static int hf_vnc_tight_tunnel_type_signature;
687
688
/* Authentication capabilities (TightVNC extension) */
689
static int hf_vnc_tight_num_auth_types;
690
static int hf_vnc_tight_auth_code;
691
/* TightVNC capabilities */
692
static int hf_vnc_tight_server_message_type;
693
static int hf_vnc_tight_server_vendor;
694
static int hf_vnc_tight_signature;
695
static int hf_vnc_tight_server_name;
696
697
static int hf_vnc_tight_client_message_type;
698
static int hf_vnc_tight_client_vendor;
699
static int hf_vnc_tight_client_name;
700
701
static int hf_vnc_tight_encoding_type;
702
static int hf_vnc_tight_encoding_vendor;
703
static int hf_vnc_tight_encoding_name;
704
705
/* VeNCrypt capabilities */
706
static int hf_vnc_vencrypt_server_major_ver;
707
static int hf_vnc_vencrypt_server_minor_ver;
708
static int hf_vnc_vencrypt_client_major_ver;
709
static int hf_vnc_vencrypt_client_minor_ver;
710
static int hf_vnc_vencrypt_version_ack;
711
static int hf_vnc_vencrypt_num_auth_types;
712
static int hf_vnc_vencrypt_auth_type;
713
static int hf_vnc_vencrypt_auth_type_ack;
714
715
/* Tight compression parameters */
716
static int hf_vnc_tight_reset_stream0;
717
static int hf_vnc_tight_reset_stream1;
718
static int hf_vnc_tight_reset_stream2;
719
static int hf_vnc_tight_reset_stream3;
720
721
static int hf_vnc_tight_rect_type;
722
723
static int hf_vnc_tight_image_len;
724
static int hf_vnc_tight_image_data;
725
726
static int hf_vnc_tight_fill_color;
727
728
static int hf_vnc_tight_filter_flag;
729
static int hf_vnc_tight_filter_id;
730
731
static int hf_vnc_tight_palette_num_colors;
732
static int hf_vnc_tight_palette_data;
733
734
/* Server Framebuffer Update */
735
static int hf_vnc_rectangle_num;
736
static int hf_vnc_fb_update_x_pos;
737
static int hf_vnc_fb_update_y_pos;
738
static int hf_vnc_fb_update_width;
739
static int hf_vnc_fb_update_height;
740
static int hf_vnc_fb_update_encoding_type;
741
742
/* Raw Encoding */
743
static int hf_vnc_raw_pixel_data;
744
745
/* CopyRect Encoding */
746
static int hf_vnc_copyrect_src_x_pos;
747
static int hf_vnc_copyrect_src_y_pos;
748
749
/* RRE Encoding */
750
static int hf_vnc_rre_num_subrects;
751
static int hf_vnc_rre_bg_pixel;
752
753
static int hf_vnc_rre_subrect_pixel;
754
static int hf_vnc_rre_subrect_x_pos;
755
static int hf_vnc_rre_subrect_y_pos;
756
static int hf_vnc_rre_subrect_width;
757
static int hf_vnc_rre_subrect_height;
758
759
/* Hextile Encoding */
760
static int hf_vnc_hextile_subencoding_mask;
761
static int hf_vnc_hextile_raw;
762
static int hf_vnc_hextile_raw_value;
763
static int hf_vnc_hextile_bg;
764
static int hf_vnc_hextile_bg_value;
765
static int hf_vnc_hextile_fg;
766
static int hf_vnc_hextile_fg_value;
767
static int hf_vnc_hextile_anysubrects;
768
static int hf_vnc_hextile_num_subrects;
769
static int hf_vnc_hextile_subrectscolored;
770
static int hf_vnc_hextile_subrect_pixel_value;
771
static int hf_vnc_hextile_subrect_x_pos;
772
static int hf_vnc_hextile_subrect_y_pos;
773
static int hf_vnc_hextile_subrect_width;
774
static int hf_vnc_hextile_subrect_height;
775
776
/* ZRLE Encoding */
777
static int hf_vnc_zrle_len;
778
static int hf_vnc_zrle_subencoding;
779
static int hf_vnc_zrle_rle;
780
static int hf_vnc_zrle_palette_size;
781
static int hf_vnc_zrle_data;
782
static int hf_vnc_zrle_raw;
783
static int hf_vnc_zrle_palette;
784
785
/* Cursor Encoding */
786
static int hf_vnc_cursor_x_fore_back;
787
static int hf_vnc_cursor_encoding_pixels;
788
static int hf_vnc_cursor_encoding_bitmask;
789
790
/* Server Set Colormap Entries */
791
static int hf_vnc_color_groups;
792
static int hf_vnc_colormap_first_color;
793
static int hf_vnc_colormap_num_colors;
794
static int hf_vnc_colormap_red;
795
static int hf_vnc_colormap_green;
796
static int hf_vnc_colormap_blue;
797
798
/* Server Cut Text */
799
static int hf_vnc_server_cut_text_len;
800
static int hf_vnc_server_cut_text;
801
802
/* LibVNCServer additions */
803
static int hf_vnc_supported_messages_client2server;
804
static int hf_vnc_supported_messages_server2client;
805
static int hf_vnc_num_supported_encodings;
806
static int hf_vnc_supported_encodings;
807
static int hf_vnc_server_identity;
808
809
/* MirrorLink */
810
static int hf_vnc_mirrorlink_type;
811
static int hf_vnc_mirrorlink_length;
812
static int hf_vnc_mirrorlink_version_major;
813
static int hf_vnc_mirrorlink_version_minor;
814
static int hf_vnc_mirrorlink_framebuffer_configuration;
815
static int hf_vnc_mirrorlink_pixel_width;
816
static int hf_vnc_mirrorlink_pixel_height;
817
static int hf_vnc_mirrorlink_pixel_format;
818
static int hf_vnc_mirrorlink_display_width;
819
static int hf_vnc_mirrorlink_display_height;
820
static int hf_vnc_mirrorlink_display_distance;
821
static int hf_vnc_mirrorlink_keyboard_language;
822
static int hf_vnc_mirrorlink_keyboard_country;
823
static int hf_vnc_mirrorlink_ui_language;
824
static int hf_vnc_mirrorlink_ui_country;
825
static int hf_vnc_mirrorlink_knob_keys;
826
static int hf_vnc_mirrorlink_device_keys;
827
static int hf_vnc_mirrorlink_multimedia_keys;
828
static int hf_vnc_mirrorlink_key_related;
829
static int hf_vnc_mirrorlink_pointer_related;
830
static int hf_vnc_mirrorlink_key_symbol_value_client;
831
static int hf_vnc_mirrorlink_key_symbol_value_server;
832
static int hf_vnc_mirrorlink_key_configuration;
833
static int hf_vnc_mirrorlink_key_num_events;
834
static int hf_vnc_mirrorlink_key_event_counter;
835
static int hf_vnc_mirrorlink_key_symbol_value;
836
static int hf_vnc_mirrorlink_key_request_configuration;
837
static int hf_vnc_mirrorlink_keyboard_configuration;
838
static int hf_vnc_mirrorlink_cursor_x;
839
static int hf_vnc_mirrorlink_cursor_y;
840
static int hf_vnc_mirrorlink_text_x;
841
static int hf_vnc_mirrorlink_text_y;
842
static int hf_vnc_mirrorlink_text_width;
843
static int hf_vnc_mirrorlink_text_height;
844
static int hf_vnc_mirrorlink_keyboard_request_configuration;
845
static int hf_vnc_mirrorlink_device_status;
846
static int hf_vnc_mirrorlink_app_id;
847
static int hf_vnc_mirrorlink_fb_block_x;
848
static int hf_vnc_mirrorlink_fb_block_y;
849
static int hf_vnc_mirrorlink_fb_block_width;
850
static int hf_vnc_mirrorlink_fb_block_height;
851
static int hf_vnc_mirrorlink_fb_block_reason;
852
static int hf_vnc_mirrorlink_audio_block_reason;
853
static int hf_vnc_mirrorlink_touch_num_events;
854
static int hf_vnc_mirrorlink_touch_x;
855
static int hf_vnc_mirrorlink_touch_y;
856
static int hf_vnc_mirrorlink_touch_id;
857
static int hf_vnc_mirrorlink_touch_pressure;
858
static int hf_vnc_mirrorlink_text;
859
static int hf_vnc_mirrorlink_text_length;
860
static int hf_vnc_mirrorlink_text_max_length;
861
static int hf_vnc_mirrorlink_unknown;
862
863
/* Fence */
864
static int hf_vnc_fence_flags;
865
static int hf_vnc_fence_request;
866
static int hf_vnc_fence_sync_next;
867
static int hf_vnc_fence_block_after;
868
static int hf_vnc_fence_block_before;
869
static int hf_vnc_fence_payload_length;
870
static int hf_vnc_fence_payload;
871
872
static int * const vnc_fence_flags[] = {
873
  &hf_vnc_fence_request,
874
  &hf_vnc_fence_sync_next,
875
  &hf_vnc_fence_block_after,
876
  &hf_vnc_fence_block_before,
877
  NULL
878
};
879
880
/* Context Information */
881
static int hf_vnc_context_information_app_id;
882
static int hf_vnc_context_information_app_category;
883
static int hf_vnc_context_information_app_trust_level;
884
static int hf_vnc_context_information_content_category;
885
static int hf_vnc_context_information_content_rules;
886
static int hf_vnc_context_information_content_trust_level;
887
888
/* Scan Line based Run-Length Encoding */
889
static int hf_vnc_slrle_run_num;
890
static int hf_vnc_slrle_run_data;
891
892
/* H.264 Encoding */
893
static int hf_vnc_h264_slice_type;
894
static int hf_vnc_h264_nbytes;
895
static int hf_vnc_h264_width;
896
static int hf_vnc_h264_height;
897
static int hf_vnc_h264_data;
898
899
/********** End of Server Message Types **********/
900
901
static bool vnc_preference_desegment = true;
902
903
/* Initialize the subtree pointers */
904
static int ett_vnc;
905
static int ett_vnc_client_message_type;
906
static int ett_vnc_server_message_type;
907
static int ett_vnc_rect;
908
static int ett_vnc_encoding_type;
909
static int ett_vnc_rre_subrect;
910
static int ett_vnc_hextile_subencoding_mask;
911
static int ett_vnc_hextile_num_subrects;
912
static int ett_vnc_hextile_subrect;
913
static int ett_vnc_hextile_tile;
914
static int ett_vnc_zrle_subencoding;
915
static int ett_vnc_colormap_num_groups;
916
static int ett_vnc_colormap_color_group;
917
static int ett_vnc_desktop_screen;
918
static int ett_vnc_key_events;
919
static int ett_vnc_touch_events;
920
static int ett_vnc_slrle_subline;
921
static int ett_vnc_fence_flags;
922
923
static expert_field ei_vnc_possible_gtk_vnc_bug;
924
static expert_field ei_vnc_auth_code_mismatch;
925
static expert_field ei_vnc_unknown_tight_vnc_auth;
926
static expert_field ei_vnc_too_many_rectangles;
927
static expert_field ei_vnc_too_many_sub_rectangles;
928
static expert_field ei_vnc_invalid_encoding;
929
static expert_field ei_vnc_too_many_colors;
930
static expert_field ei_vnc_too_many_cut_text;
931
static expert_field ei_vnc_zrle_failed;
932
static expert_field ei_vnc_unknown_tight;
933
static expert_field ei_vnc_reassemble;
934
935
14
#define VNC_PORT_RANGE "5500-5501,5900-5901"
936
/* Port 5900 is IANA registered (under the service name "Remote Framebuffer"),
937
 * the others are customary but not registered as mentioned in RFC 6143.
938
 * (5900+N is commonly used in the case of multiple servers, analogous to
939
 * X11.) */
940
941
static range_t *vnc_tcp_range;
942
static dissector_handle_t vnc_handle;
943
static dissector_handle_t tls_handle;
944
945
/* Code to dissect the packets */
946
static int
947
dissect_vnc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
948
0
{
949
0
  bool ret;
950
0
  int      offset = 0;
951
952
  /* Set up structures needed to add the protocol subtree and manage it */
953
0
  proto_item     *ti;
954
0
  proto_tree     *vnc_tree;
955
956
0
  conversation_t     *conversation;
957
0
  vnc_conversation_t *per_conversation_info;
958
959
0
  conversation = find_or_create_conversation(pinfo);
960
961
  /* Retrieve information from conversation, or add it if it isn't
962
   * there yet */
963
0
  per_conversation_info = (vnc_conversation_t *)conversation_get_proto_data(conversation, proto_vnc);
964
0
  if(!per_conversation_info) {
965
0
    per_conversation_info = wmem_new(wmem_file_scope(), vnc_conversation_t);
966
967
0
    per_conversation_info->vnc_next_state = VNC_SESSION_STATE_SERVER_VERSION;
968
0
    per_conversation_info->security_type_selected = VNC_SECURITY_TYPE_INVALID;
969
0
    per_conversation_info->tight_enabled = false;
970
0
    per_conversation_info->preferred_encoding = VNC_ENCODING_TYPE_RAW;
971
    /* Initial values for depth and bytes_per_pixel are set in
972
     * in the mandatory VNC_SESSION_STATE_SERVER_INIT startup
973
     * message. "This pixel format will be used unless the
974
     * client requests a different format using the SetPixelFormat
975
     * message" (RFC 6143 7.3.2 ServerInit) */
976
977
0
    conversation_add_proto_data(conversation, proto_vnc, per_conversation_info);
978
0
  }
979
980
981
  /* Make entries in Protocol column and Info column on summary display */
982
0
  col_set_str(pinfo->cinfo, COL_PROTOCOL, "VNC");
983
984
  /* First, clear the info column */
985
0
  col_clear(pinfo->cinfo, COL_INFO);
986
987
  /* create display subtree for the protocol */
988
0
  ti = proto_tree_add_item(tree, proto_vnc, tvb, 0, -1, ENC_NA);
989
0
  vnc_tree = proto_item_add_subtree(ti, ett_vnc);
990
991
  /* Dissect any remaining session startup messages */
992
0
  ret = vnc_startup_messages(tvb, pinfo, offset, vnc_tree,
993
0
           per_conversation_info);
994
995
0
  if (ret) {
996
0
    return tvb_captured_length(tvb);  /* We're in a "startup" state; Cannot yet do "normal" processing */
997
0
  }
998
999
0
  if (per_conversation_info->security_type_selected == VNC_SECURITY_TYPE_VENCRYPT) {
1000
0
    call_dissector_with_data(tls_handle, tvb, pinfo, vnc_tree, GUINT_TO_POINTER(offset));
1001
0
    return tvb_captured_length(tvb);
1002
0
  }
1003
1004
0
  if(value_is_in_range(vnc_tcp_range, pinfo->destport) || per_conversation_info->server_port == pinfo->destport) {
1005
0
    vnc_client_to_server(tvb, pinfo, &offset, vnc_tree, per_conversation_info);
1006
0
  }
1007
0
  else {
1008
0
    vnc_server_to_client(tvb, pinfo, &offset, vnc_tree);
1009
0
  }
1010
0
  return tvb_captured_length(tvb);
1011
0
}
1012
1013
/* Returns the new offset after processing the 4-byte vendor string */
1014
static int
1015
process_vendor(proto_tree *tree, int hfindex, tvbuff_t *tvb, int offset)
1016
0
{
1017
0
  const uint8_t *vendor;
1018
0
  proto_item *ti;
1019
1020
0
  if (tree) {
1021
0
    ti = proto_tree_add_item_ret_string(tree, hfindex, tvb, offset, 4, ENC_ASCII|ENC_NA, wmem_packet_scope(), &vendor);
1022
1023
0
    if(g_ascii_strcasecmp(vendor, "STDV") == 0)
1024
0
      proto_item_append_text(ti, " (Standard VNC vendor)");
1025
0
    else if(g_ascii_strcasecmp(vendor, "TRDV") == 0)
1026
0
      proto_item_append_text(ti, " (Tridia VNC vendor)");
1027
0
    else if(g_ascii_strcasecmp(vendor, "TGHT") == 0)
1028
0
      proto_item_append_text(ti, " (Tight VNC vendor)");
1029
0
  }
1030
1031
0
  offset += 4;
1032
0
  return offset;
1033
0
}
1034
1035
/* Returns the new offset after processing the specified number of capabilities */
1036
static int
1037
process_tight_capabilities(proto_tree *tree,
1038
         int type_index, int vendor_index, int name_index,
1039
         tvbuff_t *tvb, int offset, const int num_capabilities)
1040
0
{
1041
0
  int i;
1042
  /* See vnc_unixsrc/include/rfbproto.h:rfbCapabilityInfo */
1043
1044
0
  for (i = 0; i < num_capabilities; i++) {
1045
1046
0
    proto_tree_add_item(tree, type_index, tvb, offset, 4, ENC_BIG_ENDIAN);
1047
0
    offset += 4;
1048
1049
0
    offset = process_vendor(tree, vendor_index, tvb, offset);
1050
1051
0
    proto_tree_add_item(tree, name_index, tvb, offset, 8, ENC_ASCII|ENC_NA);
1052
0
    offset += 8;
1053
0
  }
1054
1055
0
  return offset;
1056
0
}
1057
1058
/* Returns true if this looks like a client or server version packet: 12 bytes, in the format "RFB xxx.yyy\n" .
1059
* Will check for the 12 bytes exact length, the 'RFB ' string and that it ends with a '\n'.
1060
* The exact 'xxx.yyy' is checked later, by trying to convert it to a double using g_ascii_strtod.
1061
* pinfo and tree are NULL when using this function to check the heuristics for dissection.  If we're
1062
* checking the heuristics, we don't need to add expert_info, we just reject that packet as not
1063
* being a VNC packet.
1064
*/
1065
static bool
1066
vnc_is_client_or_server_version_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1067
1.91k
{
1068
1.91k
  if(tvb_captured_length(tvb) != 12) {
1069
1.87k
    return false;
1070
1.87k
  }
1071
1072
38
  if(tvb_strncaseeql(tvb, 0, "RFB ", 4) != 0) {
1073
38
    return false;
1074
38
  }
1075
1076
  /* 0x2e = '.'   0xa = '\n' */
1077
0
  if (tvb_get_uint8(tvb, 7) != 0x2e) {
1078
0
    return false;
1079
0
  }
1080
1081
0
  if (tvb_get_uint8(tvb,11) != 0xa) {
1082
0
    if (tvb_get_uint8(tvb,11) == 0) {
1083
      /* Per bug 5469,  It appears that any VNC clients using gtk-vnc before [1] was
1084
      * fixed will exhibit the described protocol violation that prevents wireshark
1085
      * from dissecting the session.
1086
      *
1087
      * [1] http://git.gnome.org/browse/gtk-vnc/commit/?id=bc9e2b19167686dd381a0508af1a5113675d08a2
1088
      */
1089
0
      if ((pinfo != NULL) && (tree != NULL)) {
1090
0
        proto_tree_add_expert(tree, pinfo, &ei_vnc_possible_gtk_vnc_bug, tvb, -1, 0);
1091
0
      }
1092
1093
0
      return true;
1094
0
    }
1095
1096
0
    return false;
1097
0
  }
1098
1099
0
  return true;
1100
0
}
1101
1102
static bool test_vnc_protocol(tvbuff_t *tvb, packet_info *pinfo,
1103
          proto_tree *tree, void *data _U_)
1104
1.91k
{
1105
1.91k
  conversation_t *conversation;
1106
1107
1.91k
  if (vnc_is_client_or_server_version_message(tvb, NULL, NULL)) {
1108
0
    conversation = conversation_new(pinfo->num, &pinfo->src,
1109
0
            &pinfo->dst, conversation_pt_to_conversation_type(pinfo->ptype),
1110
0
            pinfo->srcport,
1111
0
            pinfo->destport, 0);
1112
0
    conversation_set_dissector(conversation, vnc_handle);
1113
0
    dissect_vnc(tvb, pinfo, tree, data);
1114
0
    return true;
1115
0
  }
1116
1.91k
  return false;
1117
1.91k
}
1118
1119
/* Returns true if additional session startup messages follow */
1120
static bool
1121
vnc_startup_messages(tvbuff_t *tvb, packet_info *pinfo, int offset,
1122
         proto_tree *tree, vnc_conversation_t
1123
         *per_conversation_info)
1124
0
{
1125
0
  uint8_t num_security_types;
1126
0
  uint32_t desktop_name_len, auth_result, text_len, auth_code;
1127
0
  vnc_packet_t *per_packet_info;
1128
0
  int num_tunnel_types;
1129
0
  int num_auth_types;
1130
0
  proto_item* auth_item;
1131
0
  int bytes_available;
1132
0
  int bytes_needed = 0;
1133
1134
0
  per_packet_info = (vnc_packet_t *)p_get_proto_data(wmem_file_scope(), pinfo, proto_vnc, 0);
1135
1136
0
  if(!per_packet_info) {
1137
0
    per_packet_info = wmem_new(wmem_file_scope(), vnc_packet_t);
1138
1139
0
    per_packet_info->state = per_conversation_info->vnc_next_state;
1140
0
    per_packet_info->bytes_per_pixel = per_conversation_info->bytes_per_pixel;
1141
0
    per_packet_info->depth = per_conversation_info->depth;
1142
1143
0
    p_add_proto_data(wmem_file_scope(), pinfo, proto_vnc, 0, per_packet_info);
1144
0
  }
1145
1146
0
  bytes_available = tvb_reported_length_remaining(tvb, offset);
1147
1148
  /* Packet dissection follows */
1149
0
  switch(per_packet_info->state) {
1150
1151
0
  case VNC_SESSION_STATE_SERVER_VERSION :
1152
0
    if (!vnc_is_client_or_server_version_message(tvb, pinfo, tree))
1153
0
      return true; /* we still hope to get a SERVER_VERSION message some day. Do not proceed yet */
1154
1155
0
    proto_tree_add_item(tree, hf_vnc_server_proto_ver, tvb, 4,
1156
0
            7, ENC_ASCII);
1157
0
    per_conversation_info->server_proto_ver =
1158
0
      g_ascii_strtod((char *)tvb_get_string_enc(wmem_packet_scope(), tvb, 4, 7, ENC_ASCII), NULL);
1159
0
    per_conversation_info->server_port = pinfo->srcport;
1160
1161
0
    col_add_fstr(pinfo->cinfo, COL_INFO,
1162
0
             "Server protocol version: %s",
1163
0
             tvb_format_text(pinfo->pool, tvb, 4, 7));
1164
1165
0
    per_conversation_info->vnc_next_state = VNC_SESSION_STATE_CLIENT_VERSION;
1166
0
    break;
1167
1168
0
  case VNC_SESSION_STATE_CLIENT_VERSION :
1169
0
    if (!vnc_is_client_or_server_version_message(tvb, pinfo, tree))
1170
0
      return true; /* we still hope to get a CLIENT_VERSION message some day. Do not proceed yet */
1171
1172
0
    proto_tree_add_item(tree, hf_vnc_client_proto_ver, tvb,
1173
0
            4, 7, ENC_ASCII);
1174
0
    per_conversation_info->client_proto_ver =
1175
0
      g_ascii_strtod((char *)tvb_get_string_enc(wmem_packet_scope(), tvb, 4, 7, ENC_ASCII), NULL);
1176
1177
0
    col_add_fstr(pinfo->cinfo, COL_INFO,
1178
0
             "Client protocol version: %s",
1179
0
             tvb_format_text(pinfo->pool, tvb, 4, 7));
1180
1181
0
    per_conversation_info->vnc_next_state = VNC_SESSION_STATE_SECURITY;
1182
0
    break;
1183
1184
0
  case VNC_SESSION_STATE_SECURITY :
1185
0
    col_set_str(pinfo->cinfo, COL_INFO, "Security types supported");
1186
1187
    /* We're checking against the client protocol version because
1188
     * the client is the final decider on which version to use
1189
     * after the server offers the highest version it supports. */
1190
1191
0
    if(per_conversation_info->client_proto_ver >= 3.007) {
1192
0
      num_security_types = tvb_get_uint8(tvb, offset);
1193
0
      bytes_needed = 1 + num_security_types;
1194
0
      if (bytes_available < bytes_needed && vnc_preference_desegment && pinfo->can_desegment) {
1195
0
        pinfo->desegment_offset = offset;
1196
0
        pinfo->desegment_len = bytes_needed - bytes_available;
1197
0
        break;
1198
0
      }
1199
1200
0
      if (tree) {
1201
0
        proto_tree_add_item(tree,
1202
0
                hf_vnc_num_security_types,
1203
0
                tvb, offset, 1, ENC_BIG_ENDIAN);
1204
1205
0
        for(offset = 1; offset <= num_security_types; offset++){
1206
0
          proto_tree_add_item(tree,
1207
0
                  hf_vnc_security_type, tvb,
1208
0
                  offset, 1, ENC_BIG_ENDIAN);
1209
0
        }
1210
0
      }
1211
0
      per_conversation_info->vnc_next_state = VNC_SESSION_STATE_SECURITY_TYPES;
1212
0
    } else {
1213
      /* Version < 3.007: The server decides the
1214
       * authentication type for us to use */
1215
0
      proto_tree_add_item(tree, hf_vnc_server_security_type,
1216
0
              tvb, offset, 4, ENC_BIG_ENDIAN);
1217
      /* The cast below is possible since in older versions of the protocol the only possible values are 0,1,2 */
1218
0
      per_conversation_info->security_type_selected = (uint8_t)tvb_get_ntohl(tvb, offset);
1219
0
      switch(per_conversation_info->security_type_selected) {
1220
1221
0
      case VNC_SECURITY_TYPE_INVALID:
1222
        /* TODO: In this case (INVALID) the connection has failed */
1223
        /* and there should be an error string describing the error */
1224
0
        per_conversation_info->vnc_next_state = VNC_SESSION_STATE_SECURITY_TYPES;
1225
0
        break;
1226
1227
0
      case VNC_SECURITY_TYPE_NONE:
1228
0
        per_conversation_info->vnc_next_state = VNC_SESSION_STATE_CLIENT_INIT;
1229
0
        break;
1230
1231
0
      case VNC_SECURITY_TYPE_VNC:
1232
0
        per_conversation_info->vnc_next_state = VNC_SESSION_STATE_VNC_AUTHENTICATION_CHALLENGE;
1233
0
        break;
1234
1235
0
      case VNC_SECURITY_TYPE_ARD:
1236
0
        per_conversation_info->vnc_next_state = VNC_SESSION_STATE_ARD_AUTHENTICATION_CHALLENGE;
1237
0
        break;
1238
1239
0
      default:
1240
        /* Security type not supported by this dissector */
1241
0
        break;
1242
0
      }
1243
0
    }
1244
1245
0
    break;
1246
1247
0
  case VNC_SESSION_STATE_SECURITY_TYPES :
1248
0
    proto_tree_add_item(tree, hf_vnc_client_security_type, tvb, offset, 1, ENC_BIG_ENDIAN);
1249
0
    per_conversation_info->security_type_selected =
1250
0
      tvb_get_uint8(tvb, offset);
1251
0
    col_add_fstr(pinfo->cinfo, COL_INFO, "Security type %s (%d) selected by client",
1252
0
           val_to_str_const(per_conversation_info->security_type_selected, vnc_security_types_vs, "Unknown"),
1253
0
           per_conversation_info->security_type_selected);
1254
1255
0
    switch(per_conversation_info->security_type_selected) {
1256
1257
0
    case VNC_SECURITY_TYPE_NONE :
1258
0
      if(per_conversation_info->client_proto_ver >= 3.008)
1259
0
        per_conversation_info->vnc_next_state =
1260
0
          VNC_SESSION_STATE_SECURITY_RESULT;
1261
0
      else
1262
0
        per_conversation_info->vnc_next_state =
1263
0
          VNC_SESSION_STATE_CLIENT_INIT;
1264
1265
0
      break;
1266
1267
0
    case VNC_SECURITY_TYPE_VNC :
1268
0
      per_conversation_info->vnc_next_state =
1269
0
        VNC_SESSION_STATE_VNC_AUTHENTICATION_CHALLENGE;
1270
0
      break;
1271
1272
0
    case VNC_SECURITY_TYPE_TIGHT :
1273
0
      per_conversation_info->vnc_next_state =
1274
0
        VNC_SESSION_STATE_TIGHT_TUNNELING_CAPABILITIES;
1275
0
      per_conversation_info->tight_enabled = true;
1276
0
      break;
1277
1278
0
    case VNC_SECURITY_TYPE_ARD:
1279
0
      per_conversation_info->vnc_next_state = VNC_SESSION_STATE_ARD_AUTHENTICATION_CHALLENGE;
1280
0
      break;
1281
1282
0
    case VNC_SECURITY_TYPE_VENCRYPT:
1283
0
      per_conversation_info->vnc_next_state = VNC_SESSION_STATE_VENCRYPT_SERVER_VERSION;
1284
0
      break;
1285
0
    default :
1286
      /* Security type not supported by this dissector */
1287
0
      break;
1288
0
    }
1289
1290
0
    break;
1291
1292
0
  case VNC_SESSION_STATE_TIGHT_TUNNELING_CAPABILITIES :
1293
0
  {
1294
0
    int i;
1295
1296
0
    col_set_str(pinfo->cinfo, COL_INFO, "TightVNC tunneling capabilities supported");
1297
1298
0
    proto_tree_add_item(tree, hf_vnc_tight_num_tunnel_types, tvb, offset, 4, ENC_BIG_ENDIAN);
1299
0
    num_tunnel_types = tvb_get_ntohl(tvb, offset);
1300
1301
0
    offset += 4;
1302
1303
0
    for(i = 0; i < num_tunnel_types; i++) {
1304
      /* TightVNC and Xvnc don't support any tunnel capabilities yet, but each capability
1305
       * is 16 bytes, so skip them.
1306
       */
1307
1308
0
      proto_tree_add_item(tree, hf_vnc_tight_tunnel_type_code, tvb, offset, 4, ENC_BIG_ENDIAN);
1309
0
      proto_tree_add_item(tree, hf_vnc_tight_tunnel_type_vendor, tvb, offset + 4, 4, ENC_ASCII);
1310
0
      proto_tree_add_item(tree, hf_vnc_tight_tunnel_type_signature, tvb, offset + 8, 8, ENC_ASCII);
1311
0
      offset += 16;
1312
0
    }
1313
1314
0
    if (num_tunnel_types == 0)
1315
0
      per_conversation_info->vnc_next_state = VNC_SESSION_STATE_TIGHT_AUTH_CAPABILITIES;
1316
0
    else
1317
0
      per_conversation_info->vnc_next_state = VNC_SESSION_STATE_TIGHT_TUNNEL_TYPE_REPLY;
1318
0
    break;
1319
0
  }
1320
0
  case VNC_SESSION_STATE_TIGHT_TUNNEL_TYPE_REPLY:
1321
    /* Neither TightVNC nor Xvnc implement this; they just have a placeholder that emits an error
1322
     * message and closes the connection (xserver/hw/vnc/auth.c:rfbProcessClientTunnelingType).
1323
     * We should actually never get here...
1324
     */
1325
0
    break;
1326
1327
0
  case VNC_SESSION_STATE_TIGHT_AUTH_CAPABILITIES:
1328
0
  {
1329
0
    const uint8_t *vendor, *signature;
1330
1331
0
    col_set_str(pinfo->cinfo, COL_INFO, "TightVNC authentication capabilities supported");
1332
1333
0
    proto_tree_add_item(tree, hf_vnc_tight_num_auth_types, tvb, offset, 4, ENC_BIG_ENDIAN);
1334
0
    num_auth_types = tvb_get_ntohl(tvb, offset);
1335
0
    offset += 4;
1336
1337
0
    auth_code = tvb_get_ntohl(tvb, offset);
1338
0
    auth_item = proto_tree_add_item(tree, hf_vnc_tight_auth_code, tvb, offset, 4, ENC_BIG_ENDIAN);
1339
0
    offset += 4;
1340
0
    vendor = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 4, ENC_ASCII);
1341
0
    process_vendor(tree, hf_vnc_tight_server_vendor, tvb, offset);
1342
0
    offset += 4;
1343
0
    proto_tree_add_item_ret_string(tree, hf_vnc_tight_signature, tvb, offset, 8, ENC_ASCII|ENC_NA, wmem_packet_scope(), &signature);
1344
1345
0
    switch(auth_code) {
1346
0
      case VNC_SECURITY_TYPE_NONE:
1347
0
        if ((g_ascii_strcasecmp(vendor, "STDV") != 0) || (g_ascii_strcasecmp(signature, "NOAUTH__") != 0)) {
1348
0
          expert_add_info(pinfo, auth_item, &ei_vnc_auth_code_mismatch);
1349
0
        }
1350
0
        break;
1351
0
      case VNC_SECURITY_TYPE_VNC:
1352
0
        if ((g_ascii_strcasecmp(vendor, "STDV") != 0) || (g_ascii_strcasecmp(signature, "VNCAUTH_") != 0)) {
1353
0
          expert_add_info(pinfo, auth_item, &ei_vnc_auth_code_mismatch);
1354
0
        }
1355
0
        break;
1356
0
      case VNC_SECURITY_TYPE_VENCRYPT:
1357
0
        if ((g_ascii_strcasecmp(vendor, "VENC") != 0) || (g_ascii_strcasecmp(signature, "VENCRYPT") != 0)) {
1358
0
          expert_add_info(pinfo, auth_item, &ei_vnc_auth_code_mismatch);
1359
0
        }
1360
0
        break;
1361
0
      case VNC_SECURITY_TYPE_GTK_VNC_SASL:
1362
0
        if ((g_ascii_strcasecmp(vendor, "GTKV") != 0) || (g_ascii_strcasecmp(signature, "SASL____") != 0)) {
1363
0
          expert_add_info(pinfo, auth_item, &ei_vnc_auth_code_mismatch);
1364
0
        }
1365
0
        break;
1366
0
      case VNC_TIGHT_AUTH_TGHT_ULGNAUTH:
1367
0
        if ((g_ascii_strcasecmp(vendor, "TGHT") != 0) || (g_ascii_strcasecmp(signature, "ULGNAUTH") != 0)) {
1368
0
          expert_add_info(pinfo, auth_item, &ei_vnc_auth_code_mismatch);
1369
0
        }
1370
0
        break;
1371
0
      case VNC_TIGHT_AUTH_TGHT_XTRNAUTH:
1372
0
        if ((g_ascii_strcasecmp(vendor, "TGHT") != 0) || (g_ascii_strcasecmp(signature, "XTRNAUTH") != 0)) {
1373
0
          expert_add_info(pinfo, auth_item, &ei_vnc_auth_code_mismatch);
1374
0
        }
1375
0
        break;
1376
0
      default:
1377
0
        expert_add_info(pinfo, auth_item, &ei_vnc_unknown_tight_vnc_auth);
1378
0
        break;
1379
0
    }
1380
1381
0
    if (num_auth_types == 0)
1382
0
      per_conversation_info->vnc_next_state = VNC_SESSION_STATE_CLIENT_INIT;
1383
0
    else
1384
0
      per_conversation_info->vnc_next_state = VNC_SESSION_STATE_TIGHT_AUTH_TYPE_REPLY;
1385
0
    break;
1386
0
  }
1387
0
  case VNC_SESSION_STATE_TIGHT_AUTH_TYPE_REPLY:
1388
0
    col_set_str(pinfo->cinfo, COL_INFO, "TightVNC authentication type selected by client");
1389
0
    auth_code = tvb_get_ntohl(tvb, offset);
1390
0
    auth_item = proto_tree_add_item(tree, hf_vnc_tight_auth_code, tvb, offset, 4, ENC_BIG_ENDIAN);
1391
1392
0
    switch(auth_code) {
1393
0
      case VNC_SECURITY_TYPE_NONE:
1394
0
        per_conversation_info->security_type_selected = VNC_SECURITY_TYPE_NONE;
1395
0
        per_conversation_info->vnc_next_state = VNC_SESSION_STATE_CLIENT_INIT;
1396
0
      break;
1397
0
      case VNC_SECURITY_TYPE_VNC:
1398
0
        per_conversation_info->security_type_selected = VNC_SECURITY_TYPE_VNC;
1399
0
        per_conversation_info->vnc_next_state = VNC_SESSION_STATE_VNC_AUTHENTICATION_CHALLENGE;
1400
0
      break;
1401
0
      case VNC_SECURITY_TYPE_GTK_VNC_SASL:
1402
0
        per_conversation_info->security_type_selected = VNC_SECURITY_TYPE_GTK_VNC_SASL;
1403
        /* TODO: dissection not implemented yet */
1404
0
        per_conversation_info->vnc_next_state = VNC_SESSION_STATE_TIGHT_UNKNOWN_PACKET3;
1405
0
        break;
1406
0
      case VNC_TIGHT_AUTH_TGHT_ULGNAUTH:
1407
0
        per_conversation_info->security_type_selected = VNC_TIGHT_AUTH_TGHT_ULGNAUTH;
1408
        /* TODO: dissection not implemented yet */
1409
0
        per_conversation_info->vnc_next_state = VNC_SESSION_STATE_TIGHT_UNKNOWN_PACKET3;
1410
0
        break;
1411
0
      case VNC_TIGHT_AUTH_TGHT_XTRNAUTH:
1412
0
        per_conversation_info->security_type_selected = VNC_TIGHT_AUTH_TGHT_XTRNAUTH;
1413
        /* TODO: dissection not implemented yet */
1414
0
        per_conversation_info->vnc_next_state = VNC_SESSION_STATE_TIGHT_UNKNOWN_PACKET3;
1415
0
        break;
1416
0
      default:
1417
0
        expert_add_info(pinfo, auth_item, &ei_vnc_unknown_tight_vnc_auth);
1418
0
        per_conversation_info->vnc_next_state = VNC_SESSION_STATE_TIGHT_UNKNOWN_PACKET3;
1419
0
        break;
1420
0
    }
1421
1422
0
    break;
1423
1424
0
  case VNC_SESSION_STATE_TIGHT_UNKNOWN_PACKET3 :
1425
0
    col_set_str(pinfo->cinfo, COL_INFO, "Unknown packet (TightVNC)");
1426
1427
0
    proto_tree_add_expert(tree, pinfo, &ei_vnc_unknown_tight, tvb, offset, -1);
1428
1429
0
    per_conversation_info->vnc_next_state =
1430
0
      VNC_SESSION_STATE_VNC_AUTHENTICATION_CHALLENGE;
1431
1432
0
    break;
1433
1434
0
  case VNC_SESSION_STATE_VNC_AUTHENTICATION_CHALLENGE :
1435
0
    col_set_str(pinfo->cinfo, COL_INFO, "Authentication challenge from server");
1436
1437
0
    proto_tree_add_item(tree, hf_vnc_auth_challenge, tvb,
1438
0
            offset, 16, ENC_NA);
1439
1440
0
    per_conversation_info->vnc_next_state =
1441
0
      VNC_SESSION_STATE_VNC_AUTHENTICATION_RESPONSE;
1442
0
    break;
1443
1444
0
  case VNC_SESSION_STATE_VNC_AUTHENTICATION_RESPONSE :
1445
0
    col_set_str(pinfo->cinfo, COL_INFO, "Authentication response from client");
1446
1447
0
    proto_tree_add_item(tree, hf_vnc_auth_response, tvb,
1448
0
            offset, 16, ENC_NA);
1449
1450
0
    per_conversation_info->vnc_next_state = VNC_SESSION_STATE_SECURITY_RESULT;
1451
0
    break;
1452
1453
0
  case VNC_SESSION_STATE_ARD_AUTHENTICATION_CHALLENGE :
1454
0
    {
1455
0
      int key_len;
1456
1457
0
      col_set_str(pinfo->cinfo, COL_INFO, "ARD authentication challenge");
1458
1459
0
      proto_tree_add_item(tree, hf_vnc_ard_auth_generator, tvb,
1460
0
            offset, 2, ENC_BIG_ENDIAN);
1461
0
      proto_tree_add_item(tree, hf_vnc_ard_auth_key_len, tvb,
1462
0
            offset + 2, 2, ENC_BIG_ENDIAN);
1463
1464
0
      key_len = tvb_get_ntohs(tvb, offset + 2);
1465
1466
0
      offset += 4;
1467
1468
0
      proto_tree_add_item(tree, hf_vnc_ard_auth_modulus, tvb,
1469
0
            offset, key_len, ENC_NA);
1470
0
      proto_tree_add_item(tree, hf_vnc_ard_auth_server_key, tvb,
1471
0
            offset + key_len, key_len, ENC_NA);
1472
1473
0
      per_conversation_info->ard_key_length = key_len;
1474
0
      per_conversation_info->vnc_next_state =
1475
0
        VNC_SESSION_STATE_ARD_AUTHENTICATION_RESPONSE;
1476
0
    }
1477
0
    break;
1478
1479
0
  case VNC_SESSION_STATE_ARD_AUTHENTICATION_RESPONSE :
1480
0
    col_set_str(pinfo->cinfo, COL_INFO, "ARD authentication response");
1481
1482
0
    proto_tree_add_item(tree, hf_vnc_ard_auth_credentials, tvb,
1483
0
          offset, 128, ENC_NA);
1484
0
    proto_tree_add_item(tree, hf_vnc_ard_auth_client_key, tvb,
1485
0
          offset + 128, per_conversation_info->ard_key_length, ENC_NA);
1486
1487
0
    per_conversation_info->vnc_next_state = VNC_SESSION_STATE_SECURITY_RESULT;
1488
0
    break;
1489
1490
0
  case VNC_SESSION_STATE_SECURITY_RESULT :
1491
0
    col_set_str(pinfo->cinfo, COL_INFO, "Authentication result");
1492
1493
0
    proto_tree_add_item(tree, hf_vnc_auth_result, tvb, offset,
1494
0
            4, ENC_BIG_ENDIAN);
1495
0
    auth_result = tvb_get_ntohl(tvb, offset);
1496
0
    offset += 4;
1497
1498
0
    switch(auth_result) {
1499
1500
0
    case 0 : /* OK */
1501
0
      per_conversation_info->vnc_next_state = VNC_SESSION_STATE_CLIENT_INIT;
1502
0
      break;
1503
1504
0
    case 1 : /* Failed */
1505
0
      if(per_conversation_info->client_proto_ver >= 3.008) {
1506
0
        text_len = tvb_get_ntohl(tvb, offset);
1507
0
        proto_tree_add_item(tree, hf_vnc_auth_error_length, tvb, offset, 4, ENC_BIG_ENDIAN);
1508
0
        offset += 4;
1509
1510
0
        proto_tree_add_item(tree, hf_vnc_auth_error, tvb,
1511
0
                offset, text_len, ENC_ASCII);
1512
0
      }
1513
1514
0
      return true; /* All versions: Do not continue
1515
          processing VNC packets as connection
1516
          will be closed after this packet. */
1517
1518
0
      break;
1519
0
    }
1520
1521
0
    break;
1522
0
  case VNC_SESSION_STATE_VENCRYPT_SERVER_VERSION:
1523
0
  {
1524
0
    bytes_needed = 2;
1525
0
    if (bytes_available < bytes_needed && vnc_preference_desegment && pinfo->can_desegment) {
1526
0
      pinfo->desegment_offset = offset;
1527
0
      pinfo->desegment_len = bytes_needed - bytes_available;
1528
0
      break;
1529
0
    }
1530
0
    proto_tree_add_item(tree, hf_vnc_vencrypt_server_major_ver, tvb, offset, 1, ENC_BIG_ENDIAN);
1531
0
    int major = tvb_get_uint8(tvb, offset++);
1532
0
    proto_tree_add_item(tree, hf_vnc_vencrypt_server_minor_ver, tvb, offset, 1, ENC_BIG_ENDIAN);
1533
0
    int minor = tvb_get_uint8(tvb, offset++);
1534
0
    col_add_fstr(pinfo->cinfo, COL_INFO, "VeNCrypt server version %d.%d", major, minor);
1535
0
    per_conversation_info->vnc_next_state = VNC_SESSION_STATE_VENCRYPT_CLIENT_VERSION;
1536
0
    break;
1537
0
  }
1538
0
  case VNC_SESSION_STATE_VENCRYPT_CLIENT_VERSION:
1539
0
  {
1540
0
    bytes_needed = 2;
1541
0
    if (bytes_available < bytes_needed && vnc_preference_desegment && pinfo->can_desegment) {
1542
0
      pinfo->desegment_offset = offset;
1543
0
      pinfo->desegment_len = bytes_needed - bytes_available;
1544
0
      break;
1545
0
    }
1546
0
    proto_tree_add_item(tree, hf_vnc_vencrypt_client_major_ver, tvb, offset, 1, ENC_BIG_ENDIAN);
1547
0
    int major = tvb_get_uint8(tvb, offset++);
1548
0
    proto_tree_add_item(tree, hf_vnc_vencrypt_client_minor_ver, tvb, offset, 1, ENC_BIG_ENDIAN);
1549
0
    int minor = tvb_get_uint8(tvb, offset++);
1550
0
    col_add_fstr(pinfo->cinfo, COL_INFO, "VeNCrypt client version %d.%d", major, minor);
1551
0
    per_conversation_info->vnc_next_state = VNC_SESSION_STATE_VENCRYPT_AUTH_CAPABILITIES;
1552
0
    break;
1553
0
  }
1554
0
  case VNC_SESSION_STATE_VENCRYPT_AUTH_CAPABILITIES:
1555
0
  {
1556
0
    int i;
1557
0
    bytes_needed = 2;
1558
0
    if (bytes_available < bytes_needed && vnc_preference_desegment && pinfo->can_desegment) {
1559
0
      pinfo->desegment_offset = offset;
1560
0
      pinfo->desegment_len = DESEGMENT_ONE_MORE_SEGMENT;
1561
0
      break;
1562
0
    }
1563
0
    num_auth_types = tvb_get_uint8(tvb, offset + 1);
1564
0
    bytes_needed = 2 + 4 * num_auth_types;
1565
0
    if (bytes_available < bytes_needed && vnc_preference_desegment && pinfo->can_desegment) {
1566
0
      pinfo->desegment_offset = offset;
1567
0
      pinfo->desegment_len = bytes_needed - bytes_available;
1568
0
      break;
1569
0
    }
1570
0
    col_set_str(pinfo->cinfo, COL_INFO, "VeNCrypt authentication types supported");
1571
0
    proto_tree_add_item(tree, hf_vnc_vencrypt_version_ack, tvb, offset, 1, ENC_BIG_ENDIAN);
1572
0
    offset += 1;
1573
0
    proto_tree_add_item(tree, hf_vnc_vencrypt_num_auth_types, tvb, offset, 1, ENC_BIG_ENDIAN);
1574
0
    offset += 1;
1575
1576
0
    for(i = 0; i < num_auth_types; i++) {
1577
0
      proto_tree_add_item(tree, hf_vnc_vencrypt_auth_type, tvb, offset, 4, ENC_BIG_ENDIAN);
1578
0
      offset += 4;
1579
0
    }
1580
1581
0
    per_conversation_info->vnc_next_state = VNC_SESSION_STATE_VENCRYPT_AUTH_TYPE_REPLY;
1582
0
    break;
1583
0
  }
1584
0
  case VNC_SESSION_STATE_VENCRYPT_AUTH_TYPE_REPLY:
1585
0
  {
1586
0
    bytes_needed = 4;
1587
0
    if (bytes_available < bytes_needed && vnc_preference_desegment && pinfo->can_desegment) {
1588
0
      pinfo->desegment_offset = offset;
1589
0
      pinfo->desegment_len = bytes_needed - bytes_available;
1590
0
      break;
1591
0
    }
1592
0
    uint32_t authtype = tvb_get_ntohl(tvb, offset);
1593
0
    col_add_fstr(pinfo->cinfo, COL_INFO, "VeNCrypt authentication type %s (%d) selected by client",
1594
0
      val_to_str_const(authtype, vnc_vencrypt_auth_types_vs, "Unknown"),
1595
0
      authtype);
1596
0
    proto_tree_add_item(tree, hf_vnc_vencrypt_auth_type, tvb, offset, 4, ENC_BIG_ENDIAN);
1597
    /* offset+=4; */
1598
0
    if (authtype == VNC_SECURITY_TYPE_NONE) {
1599
0
      per_conversation_info->vnc_next_state = VNC_SESSION_STATE_CLIENT_INIT;
1600
0
      per_conversation_info->security_type_selected = VNC_SECURITY_TYPE_NONE;
1601
0
    } else if (authtype == VNC_SECURITY_TYPE_VNC) {
1602
0
      per_conversation_info->vnc_next_state = VNC_SESSION_STATE_VNC_AUTHENTICATION_CHALLENGE;
1603
0
      per_conversation_info->security_type_selected = VNC_SECURITY_TYPE_VNC;
1604
0
    } else {
1605
0
      per_conversation_info->vnc_next_state = VNC_SESSION_STATE_VENCRYPT_AUTH_ACK;
1606
0
    }
1607
0
    break;
1608
0
  }
1609
0
  case VNC_SESSION_STATE_VENCRYPT_AUTH_ACK:
1610
0
    col_set_str(pinfo->cinfo, COL_INFO, "VeNCrypt server ack");
1611
0
    proto_tree_add_item(tree, hf_vnc_vencrypt_auth_type_ack, tvb, offset, 1, ENC_BIG_ENDIAN);
1612
0
    tls_handle = find_dissector("tls");
1613
0
    per_conversation_info->vnc_next_state = VNC_SESSION_STATE_NORMAL_TRAFFIC;
1614
0
    break;
1615
1616
0
  case VNC_SESSION_STATE_CLIENT_INIT :
1617
0
    col_set_str(pinfo->cinfo, COL_INFO, "Share desktop flag");
1618
1619
0
    proto_tree_add_item(tree, hf_vnc_share_desktop_flag, tvb,
1620
0
            offset, 1, ENC_BIG_ENDIAN);
1621
1622
0
    per_conversation_info->vnc_next_state = VNC_SESSION_STATE_SERVER_INIT;
1623
1624
0
    break;
1625
1626
0
  case VNC_SESSION_STATE_SERVER_INIT :
1627
0
    col_set_str(pinfo->cinfo, COL_INFO, "Server framebuffer parameters");
1628
1629
0
    proto_tree_add_item(tree, hf_vnc_width, tvb, offset, 2,
1630
0
            ENC_BIG_ENDIAN);
1631
0
    offset += 2;
1632
1633
0
    proto_tree_add_item(tree, hf_vnc_height, tvb, offset, 2,
1634
0
            ENC_BIG_ENDIAN);
1635
0
    offset += 2;
1636
1637
0
    proto_tree_add_item(tree, hf_vnc_server_bits_per_pixel,
1638
0
            tvb, offset, 1, ENC_BIG_ENDIAN);
1639
0
    vnc_set_bytes_per_pixel(pinfo, per_conversation_info, tvb_get_uint8(tvb, offset) / 8);
1640
0
    offset += 1;
1641
1642
0
    proto_tree_add_item(tree, hf_vnc_server_depth, tvb, offset,
1643
0
            1, ENC_BIG_ENDIAN);
1644
0
    vnc_set_depth(pinfo, per_conversation_info, tvb_get_uint8(tvb, offset));
1645
0
    offset += 1;
1646
1647
0
    proto_tree_add_item(tree, hf_vnc_server_big_endian_flag,
1648
0
            tvb, offset, 1, ENC_BIG_ENDIAN);
1649
0
    offset += 1;
1650
1651
0
    proto_tree_add_item(tree, hf_vnc_server_true_color_flag,
1652
0
            tvb, offset, 1, ENC_BIG_ENDIAN);
1653
0
    offset += 1;
1654
1655
0
    proto_tree_add_item(tree, hf_vnc_server_red_max,
1656
0
            tvb, offset, 2, ENC_BIG_ENDIAN);
1657
0
    offset += 2;
1658
1659
0
    proto_tree_add_item(tree, hf_vnc_server_green_max,
1660
0
            tvb, offset, 2, ENC_BIG_ENDIAN);
1661
0
    offset += 2;
1662
1663
0
    proto_tree_add_item(tree, hf_vnc_server_blue_max,
1664
0
            tvb, offset, 2, ENC_BIG_ENDIAN);
1665
0
    offset += 2;
1666
1667
0
    proto_tree_add_item(tree, hf_vnc_server_red_shift,
1668
0
            tvb, offset, 1, ENC_BIG_ENDIAN);
1669
0
    offset += 1;
1670
1671
0
    proto_tree_add_item(tree, hf_vnc_server_green_shift,
1672
0
            tvb, offset, 1, ENC_BIG_ENDIAN);
1673
0
    offset += 1;
1674
1675
0
    proto_tree_add_item(tree, hf_vnc_server_blue_shift,
1676
0
            tvb, offset, 1, ENC_BIG_ENDIAN);
1677
0
    offset += 1;
1678
1679
0
    proto_tree_add_item(tree, hf_vnc_padding,
1680
0
            tvb, offset, 3, ENC_NA);
1681
0
    offset += 3; /* Skip over 3 bytes of padding */
1682
1683
0
    if(tvb_reported_length_remaining(tvb, offset) > 4) {
1684
      /* Sometimes the desktop name & length is skipped */
1685
0
      proto_tree_add_item(tree, hf_vnc_desktop_name_len,
1686
0
              tvb, offset, 4, ENC_BIG_ENDIAN);
1687
0
      desktop_name_len = tvb_get_ntohl(tvb, offset);
1688
0
      offset += 4;
1689
1690
0
      proto_tree_add_item(tree, hf_vnc_desktop_name,
1691
0
              tvb, offset, desktop_name_len,
1692
0
              ENC_ASCII);
1693
0
    }
1694
1695
0
    if(per_conversation_info->tight_enabled == true)
1696
0
      per_conversation_info->vnc_next_state =
1697
0
        VNC_SESSION_STATE_TIGHT_INTERACTION_CAPS;
1698
0
    else
1699
0
      per_conversation_info->vnc_next_state = VNC_SESSION_STATE_NORMAL_TRAFFIC;
1700
0
    break;
1701
1702
0
  case VNC_SESSION_STATE_TIGHT_INTERACTION_CAPS :
1703
0
    col_set_str(pinfo->cinfo, COL_INFO, "TightVNC Interaction Capabilities");
1704
1705
0
    proto_tree_add_item(tree, hf_vnc_num_server_message_types,
1706
0
            tvb, offset, 2, ENC_BIG_ENDIAN);
1707
0
    per_conversation_info->num_server_message_types = tvb_get_ntohs(tvb, offset);
1708
0
    offset += 2;
1709
1710
0
    proto_tree_add_item(tree, hf_vnc_num_client_message_types,
1711
0
            tvb, offset, 2, ENC_BIG_ENDIAN);
1712
0
    per_conversation_info->num_client_message_types = tvb_get_ntohs(tvb, offset);
1713
0
    offset += 2;
1714
1715
0
    proto_tree_add_item(tree, hf_vnc_num_encoding_types,
1716
0
            tvb, offset, 2, ENC_BIG_ENDIAN);
1717
0
    per_conversation_info->num_encoding_types = tvb_get_ntohs(tvb, offset);
1718
0
    offset += 2;
1719
1720
0
    proto_tree_add_item(tree, hf_vnc_padding, tvb, offset, 2, ENC_NA);
1721
0
    offset += 2;
1722
1723
0
    offset = process_tight_capabilities(tree,
1724
0
                hf_vnc_tight_server_message_type,
1725
0
                hf_vnc_tight_server_vendor,
1726
0
                hf_vnc_tight_server_name,
1727
0
                tvb, offset, per_conversation_info->num_server_message_types);
1728
0
    offset = process_tight_capabilities(tree,
1729
0
                hf_vnc_tight_client_message_type,
1730
0
                hf_vnc_tight_client_vendor,
1731
0
                hf_vnc_tight_client_name,
1732
0
                tvb, offset, per_conversation_info->num_client_message_types);
1733
0
    process_tight_capabilities(tree,
1734
0
                hf_vnc_tight_encoding_type,
1735
0
                hf_vnc_tight_encoding_vendor,
1736
0
                hf_vnc_tight_encoding_name,
1737
0
                tvb, offset, per_conversation_info->num_encoding_types);
1738
1739
0
    per_conversation_info->vnc_next_state = VNC_SESSION_STATE_NORMAL_TRAFFIC;
1740
0
    break;
1741
1742
0
  case VNC_SESSION_STATE_NORMAL_TRAFFIC :
1743
0
    return false;
1744
0
  }
1745
1746
0
  return true;
1747
0
}
1748
1749
1750
static void
1751
vnc_client_to_server(tvbuff_t *tvb, packet_info *pinfo, int *offset,
1752
         proto_tree *tree,
1753
         vnc_conversation_t *per_conversation_info)
1754
0
{
1755
0
  uint8_t message_type;
1756
1757
0
  proto_item *ti;
1758
0
  proto_tree *vnc_client_message_type_tree;
1759
1760
0
  message_type = tvb_get_uint8(tvb, *offset);
1761
1762
0
  ti = proto_tree_add_item(tree, hf_vnc_client_message_type, tvb,
1763
0
         *offset, 1, ENC_BIG_ENDIAN);
1764
1765
0
  vnc_client_message_type_tree =
1766
0
    proto_item_add_subtree(ti, ett_vnc_client_message_type);
1767
1768
0
  *offset += 1;
1769
1770
0
  switch(message_type) {
1771
1772
0
  case VNC_CLIENT_MESSAGE_TYPE_SET_PIXEL_FORMAT :
1773
0
    vnc_client_set_pixel_format(tvb, pinfo, offset,
1774
0
              vnc_client_message_type_tree,
1775
0
              per_conversation_info);
1776
0
    break;
1777
1778
0
  case VNC_CLIENT_MESSAGE_TYPE_SET_ENCODINGS :
1779
0
    vnc_client_set_encodings(tvb, pinfo, offset,
1780
0
           vnc_client_message_type_tree,
1781
0
           per_conversation_info);
1782
0
    break;
1783
1784
0
  case VNC_CLIENT_MESSAGE_TYPE_FRAMEBUF_UPDATE_REQ :
1785
0
    vnc_client_framebuffer_update_request(tvb, pinfo, offset,
1786
0
                  vnc_client_message_type_tree);
1787
0
    break;
1788
1789
0
  case VNC_CLIENT_MESSAGE_TYPE_KEY_EVENT :
1790
0
    vnc_client_key_event(tvb, pinfo, offset,
1791
0
             vnc_client_message_type_tree);
1792
0
    break;
1793
1794
0
  case VNC_CLIENT_MESSAGE_TYPE_POINTER_EVENT:
1795
0
    vnc_client_pointer_event(tvb, pinfo, offset,
1796
0
           vnc_client_message_type_tree);
1797
0
    break;
1798
1799
0
  case VNC_CLIENT_MESSAGE_TYPE_CLIENT_CUT_TEXT :
1800
0
    vnc_client_cut_text(tvb, pinfo, offset,
1801
0
            vnc_client_message_type_tree);
1802
0
    break;
1803
1804
0
  case VNC_CLIENT_MESSAGE_TYPE_MIRRORLINK :
1805
0
    vnc_mirrorlink(tvb, pinfo, offset,
1806
0
             vnc_client_message_type_tree);
1807
0
    break;
1808
1809
0
  case VNC_CLIENT_MESSAGE_TYPE_ENABLE_CONTINUOUS_UPDATES :
1810
0
    col_append_sep_str(pinfo->cinfo, COL_INFO, "; ", "Client Enable Continuous Updates");
1811
0
    *offset += 9;
1812
0
    break;
1813
1814
0
  case VNC_CLIENT_MESSAGE_TYPE_FENCE :
1815
0
    vnc_fence(tvb, pinfo, offset,
1816
0
        vnc_client_message_type_tree);
1817
0
    break;
1818
1819
0
  default :
1820
0
    col_append_sep_fstr(pinfo->cinfo, COL_INFO, "; ",
1821
0
        "Unknown client message type (%u)",
1822
0
        message_type);
1823
0
    break;
1824
0
  }
1825
0
}
1826
1827
static void
1828
vnc_server_to_client(tvbuff_t *tvb, packet_info *pinfo, int *offset,
1829
         proto_tree *tree)
1830
0
{
1831
0
  int start_offset;
1832
0
  uint8_t message_type;
1833
0
  int bytes_needed = 0;
1834
1835
0
  proto_item *ti;
1836
0
  proto_tree *vnc_server_message_type_tree;
1837
1838
0
again:
1839
0
  start_offset = *offset;
1840
1841
0
  message_type = tvb_get_uint8(tvb, *offset);
1842
1843
0
  ti = proto_tree_add_item(tree, hf_vnc_server_message_type, tvb,
1844
0
         *offset, 1, ENC_BIG_ENDIAN);
1845
0
  vnc_server_message_type_tree =
1846
0
    proto_item_add_subtree(ti, ett_vnc_server_message_type);
1847
1848
0
  *offset += 1;
1849
1850
0
  switch(message_type) {
1851
1852
0
  case VNC_SERVER_MESSAGE_TYPE_FRAMEBUFFER_UPDATE :
1853
0
    bytes_needed =
1854
0
      vnc_server_framebuffer_update(tvb, pinfo, offset,
1855
0
                  vnc_server_message_type_tree);
1856
0
    break;
1857
1858
0
  case VNC_SERVER_MESSAGE_TYPE_SET_COLORMAP_ENTRIES :
1859
0
    bytes_needed = vnc_server_set_colormap_entries(tvb, pinfo, offset, vnc_server_message_type_tree);
1860
0
    break;
1861
1862
0
  case VNC_SERVER_MESSAGE_TYPE_RING_BELL :
1863
0
    vnc_server_ring_bell(tvb, pinfo, offset,
1864
0
             vnc_server_message_type_tree);
1865
0
    break;
1866
1867
0
  case VNC_SERVER_MESSAGE_TYPE_CUT_TEXT :
1868
0
    bytes_needed = vnc_server_cut_text(tvb, pinfo, offset,
1869
0
               vnc_server_message_type_tree);
1870
0
    break;
1871
1872
0
  case VNC_SERVER_MESSAGE_TYPE_MIRRORLINK :
1873
0
    bytes_needed = vnc_mirrorlink(tvb, pinfo, offset,
1874
0
                vnc_server_message_type_tree);
1875
0
    break;
1876
1877
0
  case VNC_SERVER_MESSAGE_TYPE_END_CONTINUOUS_UPDATES :
1878
0
    col_append_sep_str(pinfo->cinfo, COL_INFO, "; ", "Server End Continuous Updates");
1879
0
    *offset += 1;
1880
0
    break;
1881
1882
0
  case VNC_SERVER_MESSAGE_TYPE_FENCE :
1883
0
    bytes_needed = vnc_fence(tvb, pinfo, offset,
1884
0
        vnc_server_message_type_tree);
1885
0
    break;
1886
1887
0
  default :
1888
0
    col_append_sep_str(pinfo->cinfo, COL_INFO, "; ",
1889
0
               "Unknown server message type");
1890
0
    *offset = tvb_reported_length(tvb);  /* Swallow the rest of the segment */
1891
0
    break;
1892
0
  }
1893
1894
0
  if(bytes_needed > 0 && vnc_preference_desegment && pinfo->can_desegment) {
1895
0
    proto_tree_add_expert(vnc_server_message_type_tree, pinfo, &ei_vnc_reassemble, tvb, start_offset, -1);
1896
0
    pinfo->desegment_offset = start_offset;
1897
0
    pinfo->desegment_len = DESEGMENT_ONE_MORE_SEGMENT;
1898
0
    return;
1899
0
  }
1900
1901
0
  if ((unsigned)*offset < tvb_reported_length(tvb)) {
1902
0
    goto again;
1903
0
  }
1904
0
}
1905
1906
1907
static void
1908
vnc_client_set_pixel_format(tvbuff_t *tvb, packet_info *pinfo, int *offset,
1909
          proto_tree *tree,
1910
          vnc_conversation_t *per_conversation_info)
1911
0
{
1912
0
  col_set_str(pinfo->cinfo, COL_INFO, "Client set pixel format");
1913
1914
0
  proto_tree_add_item(tree, hf_vnc_padding, tvb, *offset, 3, ENC_NA);
1915
0
  *offset += 3; /* Skip over 3 bytes of padding */
1916
1917
0
  proto_tree_add_item(tree, hf_vnc_client_bits_per_pixel, tvb, *offset,
1918
0
          1, ENC_BIG_ENDIAN);
1919
0
  vnc_set_bytes_per_pixel(pinfo, per_conversation_info, tvb_get_uint8(tvb, *offset) / 8);
1920
0
  *offset += 1;
1921
1922
0
  proto_tree_add_item(tree, hf_vnc_client_depth, tvb, *offset,
1923
0
          1, ENC_BIG_ENDIAN);
1924
0
  vnc_set_depth(pinfo, per_conversation_info, tvb_get_uint8(tvb, *offset));
1925
0
  *offset += 1;
1926
1927
0
  proto_tree_add_item(tree, hf_vnc_client_big_endian_flag, tvb, *offset,
1928
0
          1, ENC_BIG_ENDIAN);
1929
0
  *offset += 1;
1930
1931
0
  proto_tree_add_item(tree, hf_vnc_client_true_color_flag, tvb, *offset,
1932
0
          1, ENC_BIG_ENDIAN);
1933
0
  *offset += 1;
1934
1935
0
  proto_tree_add_item(tree, hf_vnc_client_red_max, tvb, *offset,
1936
0
          2, ENC_BIG_ENDIAN);
1937
0
  *offset += 2;
1938
1939
0
  proto_tree_add_item(tree, hf_vnc_client_green_max, tvb, *offset,
1940
0
          2, ENC_BIG_ENDIAN);
1941
0
  *offset += 2;
1942
1943
0
  proto_tree_add_item(tree, hf_vnc_client_blue_max, tvb, *offset,
1944
0
          2, ENC_BIG_ENDIAN);
1945
0
  *offset += 2;
1946
1947
0
  proto_tree_add_item(tree, hf_vnc_client_red_shift, tvb, *offset,
1948
0
          1, ENC_BIG_ENDIAN);
1949
0
  *offset += 1;
1950
1951
0
  proto_tree_add_item(tree, hf_vnc_client_green_shift, tvb, *offset,
1952
0
          1, ENC_BIG_ENDIAN);
1953
0
  *offset += 1;
1954
1955
0
  proto_tree_add_item(tree, hf_vnc_client_blue_shift, tvb, *offset,
1956
0
          1, ENC_BIG_ENDIAN);
1957
0
  *offset += 1;
1958
1959
0
  proto_tree_add_item(tree, hf_vnc_padding, tvb, *offset, 3, ENC_NA);
1960
0
  *offset += 3; /* Skip over 3 bytes of padding */
1961
0
}
1962
1963
1964
static void
1965
vnc_client_set_encodings(tvbuff_t *tvb, packet_info *pinfo, int *offset,
1966
       proto_tree *tree,
1967
       vnc_conversation_t *per_conversation_info)
1968
0
{
1969
0
  uint16_t      number_of_encodings;
1970
0
  unsigned      counter;
1971
1972
0
  col_set_str(pinfo->cinfo, COL_INFO, "Client set encodings");
1973
1974
0
  proto_tree_add_item(tree, hf_vnc_padding, tvb, *offset, 1, ENC_NA);
1975
0
  *offset += 1; /* Skip over 1 byte of padding */
1976
1977
0
  number_of_encodings = tvb_get_ntohs(tvb, *offset);
1978
0
  proto_tree_add_item(tree, hf_vnc_encoding_num, tvb, *offset, 2, ENC_BIG_ENDIAN);
1979
0
  *offset += 2;
1980
1981
0
  per_conversation_info->preferred_encoding = -1;
1982
1983
0
  for(counter = 0; counter < number_of_encodings; counter++) {
1984
0
    proto_tree_add_item(tree,
1985
0
            hf_vnc_client_set_encodings_encoding_type,
1986
0
            tvb, *offset, 4, ENC_BIG_ENDIAN);
1987
1988
    /* Remember the first real encoding as the preferred encoding,
1989
     * per xserver/hw/vnc/rfbserver.c:rfbProcessClientNormalMessage().
1990
     * Otherwise, use RAW as the preferred encoding.
1991
     */
1992
0
    if (per_conversation_info->preferred_encoding == -1) {
1993
0
      int encoding;
1994
1995
0
      encoding = tvb_get_ntohl(tvb, *offset);
1996
1997
0
      switch(encoding) {
1998
0
      case VNC_ENCODING_TYPE_RAW:
1999
0
      case VNC_ENCODING_TYPE_RRE:
2000
0
      case VNC_ENCODING_TYPE_CORRE:
2001
0
      case VNC_ENCODING_TYPE_HEXTILE:
2002
0
      case VNC_ENCODING_TYPE_ZLIB:
2003
0
      case VNC_ENCODING_TYPE_TIGHT:
2004
0
        per_conversation_info->preferred_encoding = encoding;
2005
0
        break;
2006
0
      }
2007
0
    }
2008
2009
0
    *offset += 4;
2010
0
  }
2011
2012
0
  if (per_conversation_info->preferred_encoding == -1)
2013
0
    per_conversation_info->preferred_encoding = VNC_ENCODING_TYPE_RAW;
2014
0
}
2015
2016
2017
static void
2018
vnc_client_framebuffer_update_request(tvbuff_t *tvb, packet_info *pinfo,
2019
              int *offset, proto_tree *tree)
2020
0
{
2021
0
  col_set_str(pinfo->cinfo, COL_INFO, "Client framebuffer update request");
2022
2023
0
  proto_tree_add_item(tree, hf_vnc_update_req_incremental,
2024
0
          tvb, *offset, 1, ENC_BIG_ENDIAN);
2025
0
  *offset += 1;
2026
2027
0
  proto_tree_add_item(tree, hf_vnc_update_req_x_pos,
2028
0
          tvb, *offset, 2, ENC_BIG_ENDIAN);
2029
0
  *offset += 2;
2030
2031
0
  proto_tree_add_item(tree, hf_vnc_update_req_y_pos,
2032
0
          tvb, *offset, 2, ENC_BIG_ENDIAN);
2033
0
  *offset += 2;
2034
2035
0
  proto_tree_add_item(tree, hf_vnc_update_req_width, tvb,
2036
0
          *offset, 2, ENC_BIG_ENDIAN);
2037
0
  *offset += 2;
2038
2039
0
  proto_tree_add_item(tree, hf_vnc_update_req_height, tvb,
2040
0
          *offset, 2, ENC_BIG_ENDIAN);
2041
0
  *offset += 2;
2042
0
}
2043
2044
2045
static void
2046
vnc_client_key_event(tvbuff_t *tvb, packet_info *pinfo, int *offset,
2047
         proto_tree *tree)
2048
0
{
2049
0
  col_set_str(pinfo->cinfo, COL_INFO, "Client key event");
2050
2051
0
  proto_tree_add_item(tree, hf_vnc_key_down, tvb, *offset, 1, ENC_BIG_ENDIAN);
2052
0
  *offset += 1;
2053
2054
0
  proto_tree_add_item(tree, hf_vnc_padding, tvb, *offset, 2, ENC_NA);
2055
0
  *offset += 2; /* Skip over 2 bytes of padding */
2056
2057
0
  proto_tree_add_item(tree, hf_vnc_key, tvb, *offset, 4, ENC_BIG_ENDIAN);
2058
0
  *offset += 4;
2059
0
}
2060
2061
2062
static void
2063
vnc_client_pointer_event(tvbuff_t *tvb, packet_info *pinfo, int *offset,
2064
       proto_tree *tree)
2065
0
{
2066
0
  col_set_str(pinfo->cinfo, COL_INFO, "Client pointer event");
2067
2068
0
  proto_tree_add_item(tree, hf_vnc_button_1_pos, tvb, *offset, 1, ENC_BIG_ENDIAN);
2069
0
  proto_tree_add_item(tree, hf_vnc_button_2_pos, tvb, *offset, 1, ENC_BIG_ENDIAN);
2070
0
  proto_tree_add_item(tree, hf_vnc_button_3_pos, tvb, *offset, 1, ENC_BIG_ENDIAN);
2071
0
  proto_tree_add_item(tree, hf_vnc_button_4_pos, tvb, *offset, 1, ENC_BIG_ENDIAN);
2072
0
  proto_tree_add_item(tree, hf_vnc_button_5_pos, tvb, *offset, 1, ENC_BIG_ENDIAN);
2073
0
  proto_tree_add_item(tree, hf_vnc_button_6_pos, tvb, *offset, 1, ENC_BIG_ENDIAN);
2074
0
  proto_tree_add_item(tree, hf_vnc_button_7_pos, tvb, *offset, 1, ENC_BIG_ENDIAN);
2075
0
  proto_tree_add_item(tree, hf_vnc_button_8_pos, tvb, *offset, 1, ENC_BIG_ENDIAN);
2076
0
  *offset += 1;
2077
2078
0
  proto_tree_add_item(tree, hf_vnc_pointer_x_pos, tvb, *offset, 2, ENC_BIG_ENDIAN);
2079
0
  *offset += 2;
2080
2081
0
  proto_tree_add_item(tree, hf_vnc_pointer_y_pos, tvb, *offset, 2, ENC_BIG_ENDIAN);
2082
0
  *offset += 2;
2083
0
}
2084
2085
2086
static void
2087
vnc_client_cut_text(tvbuff_t *tvb, packet_info *pinfo, int *offset,
2088
        proto_tree *tree)
2089
0
{
2090
0
  uint32_t text_len;
2091
2092
0
  col_set_str(pinfo->cinfo, COL_INFO, "Client cut text");
2093
2094
0
  proto_tree_add_item(tree, hf_vnc_padding, tvb, *offset, 3, ENC_NA);
2095
0
  *offset += 3; /* Skip over 3 bytes of padding */
2096
2097
0
  text_len = tvb_get_ntohl(tvb, *offset);
2098
0
  proto_tree_add_item(tree, hf_vnc_client_cut_text_len, tvb, *offset, 4,
2099
0
          ENC_BIG_ENDIAN);
2100
0
  *offset += 4;
2101
2102
0
  proto_tree_add_item(tree, hf_vnc_client_cut_text, tvb, *offset,
2103
0
          text_len, ENC_ASCII);
2104
0
  *offset += text_len;
2105
2106
0
}
2107
2108
2109
static unsigned
2110
vnc_server_framebuffer_update(tvbuff_t *tvb, packet_info *pinfo, int *offset,
2111
            proto_tree *tree)
2112
0
{
2113
0
  unsigned    ii;
2114
0
  unsigned    num_rects;
2115
0
  uint16_t    width, height;
2116
0
  unsigned    bytes_needed = 0;
2117
0
  uint32_t    encoding_type;
2118
0
  proto_item *ti, *ti_x, *ti_y, *ti_width, *ti_height;
2119
0
  proto_tree *vnc_rect_tree, *vnc_encoding_type_tree;
2120
2121
0
  col_append_sep_str(pinfo->cinfo, COL_INFO, "; ", "Server framebuffer update");
2122
2123
0
  proto_tree_add_item(tree, hf_vnc_padding, tvb, *offset, 1, ENC_NA);
2124
0
  *offset += 1;
2125
2126
0
  num_rects = tvb_get_ntohs(tvb, *offset);
2127
0
  ti = proto_tree_add_item(tree, hf_vnc_rectangle_num, tvb, *offset, 2, ENC_BIG_ENDIAN);
2128
2129
  /* In some cases, TIGHT encoding ignores the "number of rectangles" field;    */
2130
  /* VNC_ENCODING_TYPE_LAST_RECT is used to indicate the end of the rectangle list. */
2131
  /* (It appears that TIGHT encoding uses 0xFFFF for the num_rects field when the   */
2132
  /*  field is not being used). For now: we'll assume that a value 0f 0xFFFF means  */
2133
  /*  that the field is not being used.             */
2134
0
  if (num_rects == 0xFFFF) {
2135
0
    proto_item_append_text(ti, " [TIGHT encoding assumed (field is not used)]");
2136
0
  }
2137
0
  if ((num_rects != 0xFFFF) && (num_rects > 5000)) {
2138
0
    expert_add_info_format(pinfo, ti, &ei_vnc_too_many_rectangles,
2139
0
        "Too many rectangles (%d), aborting dissection", num_rects);
2140
0
    return 0;
2141
0
  }
2142
2143
0
  *offset += 2;
2144
2145
0
  for(ii = 0; ii < num_rects; ii++) {
2146
0
    if (ii > 5000) {
2147
0
      expert_add_info_format(pinfo, ti, &ei_vnc_too_many_rectangles,
2148
0
                 "Too many rectangles (%d), aborting dissection", ii);
2149
0
      return 0;
2150
0
    }
2151
0
    VNC_BYTES_NEEDED(12);
2152
2153
0
    vnc_rect_tree = proto_tree_add_subtree_format(tree, tvb, *offset, 12,
2154
0
           ett_vnc_rect, NULL, "Rectangle #%d", ii+1);
2155
2156
2157
0
    ti_x = proto_tree_add_item(vnc_rect_tree, hf_vnc_fb_update_x_pos,
2158
0
             tvb, *offset, 2, ENC_BIG_ENDIAN);
2159
0
    *offset += 2;
2160
2161
0
    ti_y = proto_tree_add_item(vnc_rect_tree, hf_vnc_fb_update_y_pos,
2162
0
             tvb, *offset, 2, ENC_BIG_ENDIAN);
2163
0
    *offset += 2;
2164
2165
0
    ti_width = proto_tree_add_item(vnc_rect_tree, hf_vnc_fb_update_width,
2166
0
                 tvb, *offset, 2, ENC_BIG_ENDIAN);
2167
0
    width = tvb_get_ntohs(tvb, *offset);
2168
0
    *offset += 2;
2169
2170
0
    ti_height = proto_tree_add_item(vnc_rect_tree, hf_vnc_fb_update_height,
2171
0
            tvb, *offset, 2, ENC_BIG_ENDIAN);
2172
0
    height = tvb_get_ntohs(tvb, *offset);
2173
0
    *offset += 2;
2174
2175
0
    ti = proto_tree_add_item(vnc_rect_tree,
2176
0
           hf_vnc_fb_update_encoding_type,
2177
0
           tvb, *offset, 4, ENC_BIG_ENDIAN);
2178
2179
0
    encoding_type = tvb_get_ntohl(tvb, *offset);
2180
0
    *offset += 4;
2181
2182
0
    if (encoding_type == VNC_ENCODING_TYPE_LAST_RECT)
2183
0
      break; /* exit the loop */
2184
2185
0
    vnc_encoding_type_tree =
2186
0
      proto_item_add_subtree(ti, ett_vnc_encoding_type);
2187
2188
0
    switch(encoding_type) {
2189
2190
0
    case VNC_ENCODING_TYPE_RAW:
2191
0
      bytes_needed = vnc_raw_encoding(tvb, pinfo, offset,
2192
0
              vnc_encoding_type_tree,
2193
0
              width, height);
2194
0
      break;
2195
2196
0
    case VNC_ENCODING_TYPE_COPY_RECT:
2197
0
      bytes_needed =
2198
0
        vnc_copyrect_encoding(tvb, pinfo, offset,
2199
0
                  vnc_encoding_type_tree,
2200
0
                  width, height);
2201
0
      break;
2202
2203
0
    case VNC_ENCODING_TYPE_RRE:
2204
0
      bytes_needed =
2205
0
        vnc_rre_encoding(tvb, pinfo, offset,
2206
0
             vnc_encoding_type_tree,
2207
0
             width, height);
2208
0
      break;
2209
2210
0
    case VNC_ENCODING_TYPE_HEXTILE:
2211
0
      bytes_needed =
2212
0
        vnc_hextile_encoding(tvb, pinfo, offset,
2213
0
                 vnc_encoding_type_tree,
2214
0
                 width, height);
2215
0
      break;
2216
2217
0
    case VNC_ENCODING_TYPE_RLE:
2218
0
      bytes_needed =
2219
0
        vnc_zrle_encoding(tvb, pinfo, offset,
2220
0
              vnc_encoding_type_tree,
2221
0
              width, height);
2222
0
      break;
2223
2224
0
    case VNC_ENCODING_TYPE_TIGHT:
2225
0
      bytes_needed =
2226
0
        vnc_tight_encoding(tvb, pinfo, offset,
2227
0
               vnc_encoding_type_tree,
2228
0
               width, height);
2229
0
      break;
2230
2231
0
    case VNC_ENCODING_TYPE_RICH_CURSOR:
2232
0
    case VNC_ENCODING_TYPE_X_CURSOR:
2233
0
      proto_item_append_text (ti_x,      " (hotspot X)");
2234
0
      proto_item_append_text (ti_y,      " (hotspot Y)");
2235
0
      proto_item_append_text (ti_width,  " (cursor width)");
2236
0
      proto_item_append_text (ti_height, " (cursor height)");
2237
2238
0
      if (encoding_type == VNC_ENCODING_TYPE_RICH_CURSOR)
2239
0
        bytes_needed = vnc_rich_cursor_encoding(tvb, pinfo, offset, vnc_encoding_type_tree, width, height);
2240
0
      else
2241
0
        bytes_needed = vnc_x_cursor_encoding(tvb, pinfo, offset, vnc_encoding_type_tree, width, height);
2242
2243
0
      break;
2244
2245
0
    case VNC_ENCODING_TYPE_POINTER_POS:
2246
0
      proto_item_append_text (ti_x,      " (pointer X)");
2247
0
      proto_item_append_text (ti_y,      " (pointer Y)");
2248
0
      proto_item_append_text (ti_width,  " (unused)");
2249
0
      proto_item_append_text (ti_height, " (unused)");
2250
0
      bytes_needed = 0;
2251
0
      break;
2252
2253
0
    case VNC_ENCODING_TYPE_DESKTOP_SIZE:
2254
2255
      /* There is no payload for this message type */
2256
2257
0
      bytes_needed = 0;
2258
0
      break;
2259
2260
0
    case VNC_ENCODING_TYPE_EXTENDED_DESK_SIZE :
2261
0
      bytes_needed = vnc_extended_desktop_size(tvb, offset, vnc_encoding_type_tree);
2262
0
      break;
2263
2264
0
    case VNC_ENCODING_TYPE_KEYBOARD_LED_STATE :
2265
2266
      /* There is no payload for this message type */
2267
2268
0
      bytes_needed = 0;
2269
0
      break;
2270
2271
0
    case VNC_ENCODING_TYPE_SUPPORTED_MESSAGES :
2272
0
      bytes_needed = vnc_supported_messages(tvb, offset,
2273
0
                    vnc_encoding_type_tree,
2274
0
                    width);
2275
0
      break;
2276
2277
0
    case VNC_ENCODING_TYPE_SUPPORTED_ENCODINGS :
2278
0
      bytes_needed = vnc_supported_encodings(tvb, offset,
2279
0
                     vnc_encoding_type_tree,
2280
0
                     width, height);
2281
0
      break;
2282
2283
0
    case VNC_ENCODING_TYPE_SERVER_IDENTITY :
2284
0
      bytes_needed = vnc_server_identity(tvb, offset,
2285
0
                 vnc_encoding_type_tree,
2286
0
                 width);
2287
0
      break;
2288
2289
0
    case VNC_ENCODING_TYPE_CONTEXT_INFORMATION :
2290
0
      bytes_needed = vnc_context_information(tvb, offset,
2291
0
                     vnc_encoding_type_tree);
2292
0
      break;
2293
2294
0
    case VNC_ENCODING_TYPE_SLRLE :
2295
0
      bytes_needed = vnc_slrle_encoding(tvb, pinfo, offset,
2296
0
                vnc_encoding_type_tree,
2297
0
                height);
2298
0
      break;
2299
2300
0
    case VNC_ENCODING_TYPE_H264 :
2301
0
      bytes_needed = vnc_h264_encoding(tvb, offset,
2302
0
               vnc_encoding_type_tree);
2303
0
      break;
2304
2305
0
    }
2306
2307
    /* Check if the routines above requested more bytes to
2308
     * be desegmented. */
2309
0
    if(bytes_needed > 0)
2310
0
      return bytes_needed;
2311
0
  }
2312
2313
0
  return 0;
2314
0
}
2315
2316
static uint32_t
2317
vnc_extended_desktop_size(tvbuff_t *tvb, int *offset, proto_tree *tree)
2318
0
{
2319
2320
0
  uint8_t     i, num_of_screens;
2321
0
  proto_tree *screen_tree;
2322
2323
0
  num_of_screens = tvb_get_uint8(tvb, *offset);
2324
0
  proto_tree_add_item(tree, hf_vnc_desktop_screen_num, tvb, *offset, 1, ENC_BIG_ENDIAN);
2325
0
  *offset += 1;
2326
0
  proto_tree_add_item(tree, hf_vnc_padding, tvb, *offset, 3, ENC_NA);
2327
2328
0
  VNC_BYTES_NEEDED((uint32_t)(3 + (num_of_screens * 16)));
2329
0
  *offset += 3;
2330
0
  for(i = 0; i < num_of_screens; i++) {
2331
0
    screen_tree = proto_tree_add_subtree_format(tree, tvb, *offset, 16, ett_vnc_desktop_screen, NULL, "Screen #%u", i+1);
2332
2333
0
    proto_tree_add_item(screen_tree, hf_vnc_desktop_screen_id, tvb, *offset, 4, ENC_BIG_ENDIAN);
2334
0
    *offset += 4;
2335
0
    proto_tree_add_item(screen_tree, hf_vnc_desktop_screen_x, tvb, *offset, 2, ENC_BIG_ENDIAN);
2336
0
    *offset += 2;
2337
0
    proto_tree_add_item(screen_tree, hf_vnc_desktop_screen_y, tvb, *offset, 2, ENC_BIG_ENDIAN);
2338
0
    *offset += 2;
2339
0
    proto_tree_add_item(screen_tree, hf_vnc_desktop_screen_width, tvb, *offset, 2, ENC_BIG_ENDIAN);
2340
0
    *offset += 2;
2341
0
    proto_tree_add_item(screen_tree, hf_vnc_desktop_screen_height, tvb, *offset, 2, ENC_BIG_ENDIAN);
2342
0
    *offset += 2;
2343
0
    proto_tree_add_item(screen_tree, hf_vnc_desktop_screen_flags, tvb, *offset, 4, ENC_BIG_ENDIAN);
2344
0
    *offset += 4;
2345
0
  }
2346
2347
0
  return 0;
2348
0
}
2349
2350
static unsigned
2351
vnc_raw_encoding(tvbuff_t *tvb, packet_info *pinfo, int *offset,
2352
     proto_tree *tree, const uint16_t width, const uint16_t height)
2353
0
{
2354
0
  uint8_t bytes_per_pixel = vnc_get_bytes_per_pixel(pinfo);
2355
0
  unsigned length;
2356
2357
0
  length = width * height * bytes_per_pixel;
2358
0
  VNC_BYTES_NEEDED(length);
2359
2360
0
  proto_tree_add_item(tree, hf_vnc_raw_pixel_data, tvb, *offset,
2361
0
          length, ENC_NA);
2362
0
  *offset += length;
2363
2364
0
  return 0; /* bytes_needed */
2365
0
}
2366
2367
2368
static unsigned
2369
vnc_copyrect_encoding(tvbuff_t *tvb, packet_info *pinfo _U_, int *offset,
2370
          proto_tree *tree, const uint16_t width _U_, const uint16_t height _U_)
2371
0
{
2372
0
  proto_tree_add_item(tree, hf_vnc_copyrect_src_x_pos, tvb, *offset,
2373
0
          2, ENC_BIG_ENDIAN);
2374
0
  *offset += 2;
2375
2376
0
  proto_tree_add_item(tree, hf_vnc_copyrect_src_y_pos, tvb, *offset,
2377
0
          2, ENC_BIG_ENDIAN);
2378
0
  *offset += 2;
2379
2380
0
  return 0; /* bytes_needed */
2381
0
}
2382
2383
2384
static unsigned
2385
vnc_rre_encoding(tvbuff_t *tvb, packet_info *pinfo, int *offset,
2386
     proto_tree *tree, const uint16_t width _U_, const uint16_t height _U_)
2387
0
{
2388
0
  uint8_t     bytes_per_pixel = vnc_get_bytes_per_pixel(pinfo);
2389
0
  uint32_t    num_subrects, i;
2390
0
  unsigned    bytes_needed;
2391
0
  proto_item *ti;
2392
0
  proto_tree *subrect_tree;
2393
2394
0
  VNC_BYTES_NEEDED(4);
2395
0
  ti = proto_tree_add_item(tree, hf_vnc_rre_num_subrects, tvb, *offset,
2396
0
         4, ENC_BIG_ENDIAN);
2397
0
  num_subrects = tvb_get_ntohl(tvb, *offset);
2398
0
  *offset += 4;
2399
2400
0
  if (num_subrects > 10000) {
2401
0
    expert_add_info_format(pinfo, ti, &ei_vnc_too_many_sub_rectangles,
2402
0
        "Too many sub-rectangles (%d), aborting dissection", num_subrects);
2403
0
    return 0;
2404
0
  }
2405
2406
0
  VNC_BYTES_NEEDED(bytes_per_pixel);
2407
0
  proto_tree_add_item(tree, hf_vnc_rre_bg_pixel, tvb, *offset,
2408
0
          bytes_per_pixel, ENC_NA);
2409
0
  *offset += bytes_per_pixel;
2410
2411
  /*  We know we need (at least) all these bytes, so ask for them now
2412
   *  (instead of a few at a time...).
2413
   */
2414
0
  bytes_needed = bytes_per_pixel + 8;
2415
0
  VNC_BYTES_NEEDED(bytes_needed * num_subrects);
2416
0
  for(i = 0; i < num_subrects; i++) {
2417
2418
0
    subrect_tree = proto_tree_add_subtree_format(tree, tvb, *offset, bytes_per_pixel +
2419
0
           8, ett_vnc_rre_subrect, NULL, "Subrectangle #%d", i+1);
2420
2421
0
    proto_tree_add_item(subrect_tree, hf_vnc_rre_subrect_pixel,
2422
0
            tvb, *offset, bytes_per_pixel, ENC_NA);
2423
0
    *offset += bytes_per_pixel;
2424
2425
0
    proto_tree_add_item(subrect_tree, hf_vnc_rre_subrect_x_pos,
2426
0
            tvb, *offset, 2, ENC_BIG_ENDIAN);
2427
0
    *offset += 2;
2428
2429
0
    proto_tree_add_item(subrect_tree, hf_vnc_rre_subrect_y_pos,
2430
0
            tvb, *offset, 2, ENC_BIG_ENDIAN);
2431
0
    *offset += 2;
2432
2433
0
    proto_tree_add_item(subrect_tree, hf_vnc_rre_subrect_width,
2434
0
            tvb, *offset, 2, ENC_BIG_ENDIAN);
2435
0
    *offset += 2;
2436
2437
0
    proto_tree_add_item(subrect_tree, hf_vnc_rre_subrect_height,
2438
0
            tvb, *offset, 2, ENC_BIG_ENDIAN);
2439
0
    *offset += 2;
2440
0
  }
2441
2442
0
  return 0; /* bytes_needed */
2443
0
}
2444
2445
2446
static unsigned
2447
vnc_hextile_encoding(tvbuff_t *tvb, packet_info *pinfo, int *offset,
2448
         proto_tree *tree, const uint16_t width, const uint16_t height)
2449
0
{
2450
0
  uint8_t     bytes_per_pixel = vnc_get_bytes_per_pixel(pinfo);
2451
0
  uint8_t     i, subencoding_mask, num_subrects, subrect_len, tile_height, tile_width;
2452
0
  uint32_t    raw_length;
2453
0
  proto_tree *tile_tree, *subencoding_mask_tree, *subrect_tree, *num_subrects_tree;
2454
0
  proto_item *ti;
2455
0
  uint16_t    current_height  = 0, current_width;
2456
2457
0
  while(current_height != height) {
2458
0
    if (current_height + 16 > height)
2459
0
      tile_height = height - current_height;
2460
0
    else
2461
0
      tile_height = 16;
2462
0
    current_height += tile_height;
2463
0
    current_width = 0;
2464
0
    while(current_width != width) {
2465
0
      if (current_width + 16 > width)
2466
0
        tile_width = width - current_width;
2467
0
      else
2468
0
        tile_width = 16;
2469
2470
0
      current_width += tile_width;
2471
2472
0
      VNC_BYTES_NEEDED(1);
2473
0
      subencoding_mask = tvb_get_uint8(tvb, *offset);
2474
2475
0
      tile_tree = proto_tree_add_subtree_format(tree, tvb, *offset, 1, ett_vnc_hextile_tile, NULL,
2476
0
              "Tile {%d:%d}, sub encoding mask %u", current_width, current_height, subencoding_mask);
2477
2478
0
      ti = proto_tree_add_item(tile_tree, hf_vnc_hextile_subencoding_mask, tvb,
2479
0
             *offset, 1, ENC_BIG_ENDIAN);
2480
2481
0
      subencoding_mask_tree =
2482
0
        proto_item_add_subtree(ti, ett_vnc_hextile_subencoding_mask);
2483
2484
0
      proto_tree_add_item(subencoding_mask_tree,
2485
0
              hf_vnc_hextile_raw, tvb, *offset, 1,
2486
0
              ENC_BIG_ENDIAN);
2487
0
      proto_tree_add_item(subencoding_mask_tree,
2488
0
              hf_vnc_hextile_bg, tvb, *offset, 1,
2489
0
              ENC_BIG_ENDIAN);
2490
0
      proto_tree_add_item(subencoding_mask_tree,
2491
0
              hf_vnc_hextile_fg, tvb, *offset, 1,
2492
0
              ENC_BIG_ENDIAN);
2493
0
      proto_tree_add_item(subencoding_mask_tree,
2494
0
              hf_vnc_hextile_anysubrects, tvb, *offset, 1,
2495
0
              ENC_BIG_ENDIAN);
2496
0
      proto_tree_add_item(subencoding_mask_tree,
2497
0
              hf_vnc_hextile_subrectscolored, tvb, *offset, 1,
2498
0
              ENC_BIG_ENDIAN);
2499
0
      *offset += 1;
2500
2501
0
      if(subencoding_mask & 0x1) { /* Raw */
2502
0
        raw_length = tile_width * tile_height * bytes_per_pixel;
2503
2504
0
        VNC_BYTES_NEEDED(raw_length);
2505
0
        proto_tree_add_item(tile_tree, hf_vnc_hextile_raw_value, tvb,
2506
0
                *offset, raw_length, ENC_NA);
2507
0
        *offset += raw_length;
2508
0
      } else {
2509
0
        if(subencoding_mask & 0x2) { /* Background Specified */
2510
0
          VNC_BYTES_NEEDED(bytes_per_pixel);
2511
0
          proto_tree_add_item(tile_tree, hf_vnc_hextile_bg_value,
2512
0
                  tvb, *offset, bytes_per_pixel,
2513
0
                  ENC_NA);
2514
0
          *offset += bytes_per_pixel;
2515
0
        }
2516
2517
0
        if(subencoding_mask & 0x4) { /* Foreground Specified */
2518
0
          VNC_BYTES_NEEDED(bytes_per_pixel);
2519
0
          proto_tree_add_item(tile_tree, hf_vnc_hextile_fg_value,
2520
0
                  tvb, *offset, bytes_per_pixel,
2521
0
                  ENC_NA);
2522
0
          *offset += bytes_per_pixel;
2523
0
        }
2524
2525
0
        if(subencoding_mask & 0x8) { /* Any Subrects */
2526
0
          VNC_BYTES_NEEDED(3); /* 1 byte for number of subrects field, +2 at least for 1 subrect */
2527
0
          ti = proto_tree_add_item(tile_tree,
2528
0
                 hf_vnc_hextile_num_subrects,
2529
0
                 tvb, *offset, 1,
2530
0
                 ENC_BIG_ENDIAN);
2531
0
          num_subrects = tvb_get_uint8(tvb, *offset);
2532
0
          *offset += 1;
2533
2534
0
          if(subencoding_mask & 0x10)
2535
0
            subrect_len = bytes_per_pixel + 2;
2536
0
          else
2537
0
            subrect_len = 2;
2538
0
          VNC_BYTES_NEEDED((unsigned)(subrect_len * num_subrects));
2539
2540
0
          num_subrects_tree =
2541
0
            proto_item_add_subtree(ti, ett_vnc_hextile_num_subrects);
2542
2543
0
          for(i = 0; i < num_subrects; i++) {
2544
0
            subrect_tree = proto_tree_add_subtree_format(num_subrects_tree, tvb,
2545
0
                   *offset, subrect_len, ett_vnc_hextile_subrect, NULL,
2546
0
                   "Subrectangle #%d", i+1);
2547
2548
0
            if(subencoding_mask & 0x10) {
2549
              /* Subrects Colored */
2550
0
              proto_tree_add_item(subrect_tree, hf_vnc_hextile_subrect_pixel_value, tvb, *offset, bytes_per_pixel, ENC_NA);
2551
2552
0
              *offset += bytes_per_pixel;
2553
0
            }
2554
2555
0
            proto_tree_add_item(subrect_tree,
2556
0
                    hf_vnc_hextile_subrect_x_pos, tvb, *offset, 1, ENC_BIG_ENDIAN);
2557
2558
0
            proto_tree_add_item(subrect_tree, hf_vnc_hextile_subrect_y_pos, tvb, *offset, 1, ENC_BIG_ENDIAN);
2559
2560
0
            *offset += 1;
2561
2562
0
            proto_tree_add_item(subrect_tree, hf_vnc_hextile_subrect_width, tvb, *offset, 1, ENC_BIG_ENDIAN);
2563
2564
0
            proto_tree_add_item(subrect_tree, hf_vnc_hextile_subrect_height, tvb, *offset, 1, ENC_BIG_ENDIAN);
2565
2566
0
            *offset += 1;
2567
0
          }
2568
0
        }
2569
0
      }
2570
0
    }
2571
0
  }
2572
0
  return 0; /* bytes_needed */
2573
0
}
2574
2575
static unsigned
2576
vnc_supported_messages(tvbuff_t *tvb, int *offset, proto_tree *tree,
2577
           const uint16_t width)
2578
0
{
2579
0
  VNC_BYTES_NEEDED(width);
2580
0
  if (width >= 64) {
2581
0
    proto_tree_add_item(tree,
2582
0
            hf_vnc_supported_messages_client2server,
2583
0
            tvb, *offset, 32, ENC_NA);
2584
0
    *offset += 32;
2585
0
    proto_tree_add_item(tree,
2586
0
            hf_vnc_supported_messages_server2client,
2587
0
            tvb, *offset, 32, ENC_NA);
2588
0
    *offset += 32;
2589
0
    *offset += width - 64;
2590
0
  } else {
2591
0
    *offset += width;
2592
0
  }
2593
2594
0
  return 0; /* bytes_needed */
2595
0
}
2596
2597
static unsigned
2598
vnc_supported_encodings(tvbuff_t *tvb, int *offset, proto_tree *tree,
2599
            const uint16_t width, const uint16_t height)
2600
0
{
2601
0
  uint16_t i = width;
2602
2603
0
  proto_tree_add_uint(tree, hf_vnc_num_supported_encodings, tvb, *offset, 0, height);
2604
2605
0
  VNC_BYTES_NEEDED(width);
2606
0
  for (; i >= 4; i -= 4) {
2607
0
    proto_tree_add_item(tree, hf_vnc_supported_encodings,
2608
0
            tvb, *offset, 4, ENC_BIG_ENDIAN);
2609
0
    *offset += 4;
2610
0
  }
2611
0
  *offset += i;
2612
2613
0
  return 0; /* bytes_needed */
2614
0
}
2615
2616
static unsigned
2617
vnc_server_identity(tvbuff_t *tvb, int *offset, proto_tree *tree,
2618
        const uint16_t width)
2619
0
{
2620
0
  VNC_BYTES_NEEDED(width);
2621
0
  proto_tree_add_item(tree, hf_vnc_server_identity,
2622
0
          tvb, *offset, width, ENC_ASCII);
2623
0
  *offset += width;
2624
2625
0
  return 0; /* bytes_needed */
2626
0
}
2627
2628
static unsigned
2629
vnc_mirrorlink(tvbuff_t *tvb, packet_info *pinfo, int *offset,
2630
         proto_tree *tree)
2631
0
{
2632
0
  uint8_t type;
2633
0
  uint16_t length;
2634
0
  uint16_t num, i;
2635
0
  int end;
2636
0
  proto_tree *sub_tree;
2637
2638
  /* Header */
2639
0
  VNC_BYTES_NEEDED(3);
2640
2641
0
  type = tvb_get_uint8(tvb, *offset);
2642
0
  proto_tree_add_item(tree, hf_vnc_mirrorlink_type,
2643
0
          tvb, *offset, 1, ENC_BIG_ENDIAN);
2644
0
  *offset += 1;
2645
2646
0
  length = tvb_get_ntohs(tvb, *offset);
2647
0
  proto_tree_add_item(tree, hf_vnc_mirrorlink_length,
2648
0
          tvb, *offset, 2, ENC_BIG_ENDIAN);
2649
0
  *offset += 2;
2650
2651
0
  col_add_fstr(pinfo->cinfo, COL_INFO, "MirrorLink (%s)",
2652
0
         val_to_str_const(type, vnc_mirrorlink_types_vs,
2653
0
              "Unknown"));
2654
2655
  /* Payload */
2656
0
  end = *offset + length;
2657
2658
0
  switch(type) {
2659
2660
0
  case VNC_ML_EXT_BYE_BYE :
2661
0
    break;
2662
2663
0
  case VNC_ML_EXT_SERVER_DISPLAY_CONFIGURATION :
2664
0
    VNC_BYTES_NEEDED(12);
2665
0
    proto_tree_add_item(tree, hf_vnc_mirrorlink_version_major,
2666
0
            tvb, *offset, 1, ENC_BIG_ENDIAN);
2667
0
    *offset += 1;
2668
0
    proto_tree_add_item(tree, hf_vnc_mirrorlink_version_minor,
2669
0
            tvb, *offset, 1, ENC_BIG_ENDIAN);
2670
0
    *offset += 1;
2671
0
    proto_tree_add_item(tree,
2672
0
            hf_vnc_mirrorlink_framebuffer_configuration,
2673
0
            tvb, *offset, 2, ENC_BIG_ENDIAN);
2674
0
    *offset += 2;
2675
0
    proto_tree_add_item(tree, hf_vnc_mirrorlink_pixel_width,
2676
0
            tvb, *offset, 2, ENC_BIG_ENDIAN);
2677
0
    *offset += 2;
2678
0
    proto_tree_add_item(tree, hf_vnc_mirrorlink_pixel_height,
2679
0
            tvb, *offset, 2, ENC_BIG_ENDIAN);
2680
0
    *offset += 2;
2681
0
    proto_tree_add_item(tree, hf_vnc_mirrorlink_pixel_format,
2682
0
            tvb, *offset, 4, ENC_BIG_ENDIAN);
2683
0
    *offset += 4;
2684
0
    break;
2685
2686
0
  case VNC_ML_EXT_CLIENT_DISPLAY_CONFIGURATION :
2687
0
    VNC_BYTES_NEEDED(14);
2688
0
    proto_tree_add_item(tree, hf_vnc_mirrorlink_version_major,
2689
0
            tvb, *offset, 1, ENC_BIG_ENDIAN);
2690
0
    *offset += 1;
2691
0
    proto_tree_add_item(tree, hf_vnc_mirrorlink_version_minor,
2692
0
            tvb, *offset, 1, ENC_BIG_ENDIAN);
2693
0
    *offset += 1;
2694
0
    proto_tree_add_item(tree,
2695
0
            hf_vnc_mirrorlink_framebuffer_configuration,
2696
0
            tvb, *offset, 2, ENC_BIG_ENDIAN);
2697
0
    *offset += 2;
2698
0
    proto_tree_add_item(tree, hf_vnc_mirrorlink_pixel_width,
2699
0
            tvb, *offset, 2, ENC_BIG_ENDIAN);
2700
0
    *offset += 2;
2701
0
    proto_tree_add_item(tree, hf_vnc_mirrorlink_pixel_height,
2702
0
            tvb, *offset, 2, ENC_BIG_ENDIAN);
2703
0
    *offset += 2;
2704
0
    proto_tree_add_item(tree, hf_vnc_mirrorlink_display_width,
2705
0
            tvb, *offset, 2, ENC_BIG_ENDIAN);
2706
0
    *offset += 2;
2707
0
    proto_tree_add_item(tree, hf_vnc_mirrorlink_display_height,
2708
0
            tvb, *offset, 2, ENC_BIG_ENDIAN);
2709
0
    *offset += 2;
2710
0
    proto_tree_add_item(tree, hf_vnc_mirrorlink_display_distance,
2711
0
            tvb, *offset, 2, ENC_BIG_ENDIAN);
2712
0
    *offset += 2;
2713
0
    break;
2714
2715
0
  case VNC_ML_EXT_SERVER_EVENT_CONFIGURATION :
2716
0
  case VNC_ML_EXT_CLIENT_EVENT_CONFIGURATION :
2717
0
    VNC_BYTES_NEEDED(28);
2718
0
    proto_tree_add_item(tree, hf_vnc_mirrorlink_keyboard_language,
2719
0
            tvb, *offset, 2, ENC_ASCII);
2720
0
    *offset += 2;
2721
0
    proto_tree_add_item(tree, hf_vnc_mirrorlink_keyboard_country,
2722
0
            tvb, *offset, 2, ENC_ASCII);
2723
0
    *offset += 2;
2724
0
    proto_tree_add_item(tree, hf_vnc_mirrorlink_ui_language,
2725
0
            tvb, *offset, 2, ENC_ASCII);
2726
0
    *offset += 2;
2727
0
    proto_tree_add_item(tree, hf_vnc_mirrorlink_ui_country,
2728
0
            tvb, *offset, 2, ENC_ASCII);
2729
0
    *offset += 2;
2730
0
    proto_tree_add_item(tree, hf_vnc_mirrorlink_knob_keys,
2731
0
            tvb, *offset, 4, ENC_BIG_ENDIAN);
2732
0
    *offset += 4;
2733
0
    proto_tree_add_item(tree, hf_vnc_mirrorlink_device_keys,
2734
0
            tvb, *offset, 4, ENC_BIG_ENDIAN);
2735
0
    *offset += 4;
2736
0
    proto_tree_add_item(tree, hf_vnc_mirrorlink_multimedia_keys,
2737
0
            tvb, *offset, 4, ENC_BIG_ENDIAN);
2738
0
    *offset += 4;
2739
0
    proto_tree_add_item(tree, hf_vnc_mirrorlink_key_related,
2740
0
            tvb, *offset, 4, ENC_BIG_ENDIAN);
2741
0
    *offset += 4;
2742
0
    proto_tree_add_item(tree, hf_vnc_mirrorlink_pointer_related,
2743
0
            tvb, *offset, 4, ENC_BIG_ENDIAN);
2744
0
    *offset += 4;
2745
0
    break;
2746
2747
0
  case VNC_ML_EXT_EVENT_MAPPING :
2748
0
  case VNC_ML_EXT_EVENT_MAPPING_REQUEST :
2749
0
    VNC_BYTES_NEEDED(8);
2750
0
    proto_tree_add_item(tree,
2751
0
            hf_vnc_mirrorlink_key_symbol_value_client,
2752
0
            tvb, *offset, 4, ENC_BIG_ENDIAN);
2753
0
    *offset += 4;
2754
0
    proto_tree_add_item(tree,
2755
0
            hf_vnc_mirrorlink_key_symbol_value_server,
2756
0
            tvb, *offset, 4, ENC_BIG_ENDIAN);
2757
0
    *offset += 4;
2758
0
    break;
2759
2760
0
  case VNC_ML_EXT_KEY_EVENT_LISTING :
2761
0
    VNC_BYTES_NEEDED(4);
2762
0
    proto_tree_add_item(tree, hf_vnc_mirrorlink_key_configuration,
2763
0
            tvb, *offset, 1, ENC_BIG_ENDIAN);
2764
0
    *offset += 1;
2765
0
    num = tvb_get_uint8(tvb, *offset);
2766
0
    proto_tree_add_item(tree, hf_vnc_mirrorlink_key_num_events,
2767
0
            tvb, *offset, 1, ENC_BIG_ENDIAN);
2768
0
    *offset += 1;
2769
0
    proto_tree_add_item(tree, hf_vnc_mirrorlink_key_event_counter,
2770
0
            tvb, *offset, 2, ENC_BIG_ENDIAN);
2771
0
    *offset += 2;
2772
0
    VNC_BYTES_NEEDED((unsigned)(4 * num));
2773
0
    sub_tree = proto_tree_add_subtree(tree, tvb, *offset, 4 * num,
2774
0
           ett_vnc_key_events, NULL, "Key Event List");
2775
0
    for (; num > 0; num--) {
2776
0
      proto_tree_add_item(sub_tree,
2777
0
              hf_vnc_mirrorlink_key_symbol_value,
2778
0
              tvb, *offset, 4, ENC_BIG_ENDIAN);
2779
0
      *offset += 4 ;
2780
0
    }
2781
0
    break;
2782
2783
0
  case VNC_ML_EXT_KEY_EVENT_LISTING_REQUEST :
2784
0
    VNC_BYTES_NEEDED(4);
2785
0
    proto_tree_add_item(tree,
2786
0
            hf_vnc_mirrorlink_key_request_configuration,
2787
0
            tvb, *offset, 4, ENC_BIG_ENDIAN);
2788
0
    *offset += 4;
2789
0
    break;
2790
2791
0
  case VNC_ML_EXT_VIRTUAL_KEYBOARD :
2792
0
    VNC_BYTES_NEEDED(16);
2793
0
    proto_tree_add_item(tree,
2794
0
            hf_vnc_mirrorlink_keyboard_configuration,
2795
0
            tvb, *offset, 4, ENC_BIG_ENDIAN);
2796
0
    *offset += 4;
2797
0
    proto_tree_add_item(tree, hf_vnc_mirrorlink_cursor_x,
2798
0
            tvb, *offset, 2, ENC_BIG_ENDIAN);
2799
0
    *offset += 2;
2800
0
    proto_tree_add_item(tree, hf_vnc_mirrorlink_cursor_y,
2801
0
            tvb, *offset, 2, ENC_BIG_ENDIAN);
2802
0
    *offset += 2;
2803
0
    proto_tree_add_item(tree, hf_vnc_mirrorlink_text_x,
2804
0
            tvb, *offset, 2, ENC_BIG_ENDIAN);
2805
0
    *offset += 2;
2806
0
    proto_tree_add_item(tree, hf_vnc_mirrorlink_text_y,
2807
0
            tvb, *offset, 2, ENC_BIG_ENDIAN);
2808
0
    *offset += 2;
2809
0
    proto_tree_add_item(tree, hf_vnc_mirrorlink_text_width,
2810
0
            tvb, *offset, 2, ENC_BIG_ENDIAN);
2811
0
    *offset += 2;
2812
0
    proto_tree_add_item(tree, hf_vnc_mirrorlink_text_height,
2813
0
            tvb, *offset, 2, ENC_BIG_ENDIAN);
2814
0
    *offset += 2;
2815
0
    break;
2816
2817
0
  case VNC_ML_EXT_VIRTUAL_KEYBOARD_REQUEST :
2818
0
    VNC_BYTES_NEEDED(4);
2819
0
    proto_tree_add_item(tree,
2820
0
            hf_vnc_mirrorlink_keyboard_request_configuration,
2821
0
            tvb, *offset, 4, ENC_BIG_ENDIAN);
2822
0
    *offset += 4;
2823
0
    break;
2824
2825
0
  case VNC_ML_EXT_DEVICE_STATUS :
2826
0
  case VNC_ML_EXT_DEVICE_STATUS_REQUEST :
2827
0
    VNC_BYTES_NEEDED(4);
2828
0
    proto_tree_add_item(tree, hf_vnc_mirrorlink_device_status,
2829
0
            tvb, *offset, 4, ENC_BIG_ENDIAN);
2830
0
    *offset += 4;
2831
0
    break;
2832
/*
2833
  case VNC_ML_EXT_CONTENT_ATTESTATION :
2834
    break;
2835
2836
  case VNC_ML_EXT_CONTENT_ATTESTATION_REQUEST :
2837
    break;
2838
*/
2839
0
  case VNC_ML_EXT_FB_BLOCKING_NOTIFICATION :
2840
0
    VNC_BYTES_NEEDED(14);
2841
0
    proto_tree_add_item(tree, hf_vnc_mirrorlink_fb_block_x,
2842
0
            tvb, *offset, 2, ENC_BIG_ENDIAN);
2843
0
    *offset += 2;
2844
0
    proto_tree_add_item(tree, hf_vnc_mirrorlink_fb_block_y,
2845
0
            tvb, *offset, 2, ENC_BIG_ENDIAN);
2846
0
    *offset += 2;
2847
0
    proto_tree_add_item(tree, hf_vnc_mirrorlink_fb_block_width,
2848
0
            tvb, *offset, 2, ENC_BIG_ENDIAN);
2849
0
    *offset += 2;
2850
0
    proto_tree_add_item(tree, hf_vnc_mirrorlink_fb_block_height,
2851
0
            tvb, *offset, 2, ENC_BIG_ENDIAN);
2852
0
    *offset += 2;
2853
0
    proto_tree_add_item(tree, hf_vnc_mirrorlink_app_id,
2854
0
            tvb, *offset, 4, ENC_BIG_ENDIAN);
2855
0
    *offset += 4;
2856
0
    proto_tree_add_item(tree, hf_vnc_mirrorlink_fb_block_reason,
2857
0
            tvb, *offset, 2, ENC_BIG_ENDIAN);
2858
0
    *offset += 2;
2859
0
    break;
2860
2861
0
  case VNC_ML_EXT_AUDIO_BLOCKING_NOTIFICATION :
2862
0
    VNC_BYTES_NEEDED(6);
2863
0
    proto_tree_add_item(tree, hf_vnc_mirrorlink_app_id,
2864
0
            tvb, *offset, 4, ENC_BIG_ENDIAN);
2865
0
    *offset += 4;
2866
0
    proto_tree_add_item(tree, hf_vnc_mirrorlink_audio_block_reason,
2867
0
            tvb, *offset, 2, ENC_BIG_ENDIAN);
2868
0
    *offset += 2;
2869
0
    break;
2870
2871
0
  case VNC_ML_EXT_TOUCH_EVENT :
2872
0
    VNC_BYTES_NEEDED(1);
2873
0
    num = tvb_get_uint8(tvb, *offset);
2874
0
    proto_tree_add_item(tree, hf_vnc_mirrorlink_touch_num_events,
2875
0
            tvb, *offset, 1, ENC_BIG_ENDIAN);
2876
0
    *offset += 1;
2877
0
    VNC_BYTES_NEEDED((unsigned)(6 * num));
2878
    /*sub_tree = proto_item_add_subtree(tree, ett_vnc_touch_events);*/
2879
0
    for (i = 0; i < num; i++) {
2880
0
      sub_tree = proto_tree_add_subtree_format(tree, tvb, *offset, 6,
2881
0
             ett_vnc_touch_events, NULL, "Touch Event #%d", i + 1);
2882
2883
0
      proto_tree_add_item(sub_tree, hf_vnc_mirrorlink_touch_x,
2884
0
              tvb, *offset, 2, ENC_BIG_ENDIAN);
2885
0
      *offset += 2;
2886
0
      proto_tree_add_item(sub_tree, hf_vnc_mirrorlink_touch_y,
2887
0
              tvb, *offset, 2, ENC_BIG_ENDIAN);
2888
0
      *offset += 2;
2889
0
      proto_tree_add_item(sub_tree,
2890
0
              hf_vnc_mirrorlink_touch_id,
2891
0
              tvb, *offset, 1, ENC_BIG_ENDIAN);
2892
0
      *offset += 1;
2893
0
      proto_tree_add_item(sub_tree,
2894
0
              hf_vnc_mirrorlink_touch_pressure,
2895
0
              tvb, *offset, 1, ENC_BIG_ENDIAN);
2896
0
      *offset += 1;
2897
0
    }
2898
0
    break;
2899
2900
0
  case VNC_ML_EXT_FB_ALTERNATIVE_TEXT :
2901
0
    VNC_BYTES_NEEDED(6);
2902
0
    proto_tree_add_item(tree, hf_vnc_mirrorlink_app_id,
2903
0
            tvb, *offset, 4, ENC_BIG_ENDIAN);
2904
0
    *offset += 4;
2905
0
    num = tvb_get_ntohs(tvb, *offset);
2906
0
    proto_tree_add_item(tree, hf_vnc_mirrorlink_text_length,
2907
0
            tvb, *offset, 2, ENC_BIG_ENDIAN);
2908
0
    *offset += 2;
2909
0
    VNC_BYTES_NEEDED(num);
2910
0
    proto_tree_add_item(tree, hf_vnc_mirrorlink_text,
2911
0
            tvb, *offset, num, ENC_ASCII);
2912
0
    *offset += num;
2913
0
    break;
2914
2915
0
  case VNC_ML_EXT_FB_ALTERNATIVE_TEXT_REQUEST :
2916
0
    VNC_BYTES_NEEDED(2);
2917
0
    proto_tree_add_item(tree, hf_vnc_mirrorlink_text_max_length,
2918
0
            tvb, *offset, 2, ENC_BIG_ENDIAN);
2919
0
    *offset += 2;
2920
0
    break;
2921
2922
0
  }
2923
2924
0
  if (end > *offset) {
2925
0
    length = end - *offset;
2926
0
    VNC_BYTES_NEEDED(length);
2927
0
    proto_tree_add_item(tree, hf_vnc_mirrorlink_unknown,
2928
0
            tvb, *offset, length, ENC_NA);
2929
0
    *offset = end;
2930
0
  }
2931
2932
0
  return 0; /* bytes_needed */
2933
0
}
2934
2935
static unsigned
2936
vnc_fence(tvbuff_t *tvb, packet_info *pinfo, int *offset,
2937
    proto_tree *tree)
2938
0
{
2939
0
  unsigned payload_length;
2940
2941
0
  VNC_BYTES_NEEDED(8);
2942
2943
0
  payload_length = tvb_get_uint8(tvb, *offset+7);
2944
0
  VNC_BYTES_NEEDED((8+payload_length));
2945
2946
0
  col_append_sep_str(pinfo->cinfo, COL_INFO, "; ", "Fence");
2947
2948
0
  proto_tree_add_item(tree, hf_vnc_padding, tvb, *offset, 3, ENC_NA);
2949
0
  *offset += 3;  /* skip padding */
2950
2951
0
  proto_tree_add_bitmask(tree, tvb, *offset, hf_vnc_fence_flags,
2952
0
             ett_vnc_fence_flags, vnc_fence_flags, ENC_BIG_ENDIAN);
2953
2954
0
  *offset += 4;
2955
2956
0
  proto_tree_add_item(tree, hf_vnc_fence_payload_length,
2957
0
          tvb, *offset, 1, ENC_BIG_ENDIAN);
2958
2959
0
  *offset += 1;
2960
2961
0
  if (payload_length > 0) {
2962
0
    proto_tree_add_item(tree, hf_vnc_fence_payload,
2963
0
            tvb, *offset, payload_length, ENC_NA);
2964
0
    *offset += payload_length;
2965
0
  }
2966
0
  return 0;
2967
0
}
2968
2969
static unsigned
2970
vnc_context_information(tvbuff_t *tvb, int *offset, proto_tree *tree)
2971
0
{
2972
0
  VNC_BYTES_NEEDED(20);
2973
2974
0
  proto_tree_add_item(tree, hf_vnc_context_information_app_id,
2975
0
          tvb, *offset, 4, ENC_BIG_ENDIAN);
2976
0
  *offset += 4;
2977
2978
0
  proto_tree_add_item(tree, hf_vnc_context_information_app_trust_level,
2979
0
          tvb, *offset, 2, ENC_BIG_ENDIAN);
2980
0
  *offset += 2;
2981
2982
0
  proto_tree_add_item(tree,
2983
0
          hf_vnc_context_information_content_trust_level,
2984
0
          tvb, *offset, 2, ENC_BIG_ENDIAN);
2985
0
  *offset += 2;
2986
2987
0
  proto_tree_add_item(tree, hf_vnc_context_information_app_category,
2988
0
          tvb, *offset, 4, ENC_BIG_ENDIAN);
2989
0
  *offset += 4;
2990
2991
0
  proto_tree_add_item(tree, hf_vnc_context_information_content_category,
2992
0
          tvb, *offset, 4, ENC_BIG_ENDIAN);
2993
0
  *offset += 4;
2994
2995
0
  proto_tree_add_item(tree, hf_vnc_context_information_content_rules,
2996
0
          tvb, *offset, 4, ENC_BIG_ENDIAN);
2997
0
  *offset += 4;
2998
2999
0
  return 0; /* bytes_needed */
3000
0
}
3001
3002
static unsigned
3003
vnc_slrle_encoding(tvbuff_t *tvb, packet_info *pinfo, int *offset,
3004
       proto_tree *tree, const uint16_t height)
3005
0
{
3006
0
  uint8_t depth = vnc_get_depth(pinfo);
3007
0
  uint8_t depth_mod = depth % 8;
3008
0
  uint8_t bytes_per_run;
3009
0
  uint16_t num_runs, i;
3010
0
  unsigned length;
3011
0
  proto_tree *sub_tree;
3012
3013
0
  if (depth_mod <= 4)
3014
0
    bytes_per_run = ( 8 - depth_mod + depth) / 8;
3015
0
  else
3016
0
    bytes_per_run = (16 - depth_mod + depth) / 8;
3017
3018
0
  for (i = 0; i < height; i++) {
3019
0
    VNC_BYTES_NEEDED(2);
3020
0
    num_runs = tvb_get_ntohs(tvb, *offset);
3021
3022
0
    length = num_runs * bytes_per_run;
3023
3024
0
    sub_tree = proto_tree_add_subtree_format(tree, tvb, *offset, 2 + length,
3025
0
           ett_vnc_slrle_subline, NULL, "Scanline #%d", i+1);
3026
3027
0
    proto_tree_add_item(sub_tree, hf_vnc_slrle_run_num,
3028
0
            tvb, *offset, 2, ENC_BIG_ENDIAN);
3029
0
    *offset += 2;
3030
3031
0
    VNC_BYTES_NEEDED(length);
3032
0
    proto_tree_add_item(sub_tree, hf_vnc_slrle_run_data,
3033
0
            tvb, *offset, length, ENC_NA);
3034
0
    *offset += length;
3035
0
  }
3036
3037
0
  return 0; /* bytes_needed */
3038
0
}
3039
3040
static unsigned
3041
vnc_h264_encoding(tvbuff_t *tvb, int *offset, proto_tree *tree)
3042
0
{
3043
0
  uint32_t nbytes;
3044
3045
0
  VNC_BYTES_NEEDED(16);
3046
3047
0
  nbytes = tvb_get_ntohl(tvb, *offset);
3048
0
  proto_tree_add_item(tree, hf_vnc_h264_nbytes,
3049
0
          tvb, *offset, 4, ENC_BIG_ENDIAN);
3050
0
  *offset += 4;
3051
3052
  /*0 == P-Frame; 1 == B-Frame; 2 == I-Frame*/
3053
0
  proto_tree_add_item(tree, hf_vnc_h264_slice_type,
3054
0
          tvb, *offset, 4, ENC_BIG_ENDIAN);
3055
0
  *offset += 4;
3056
3057
0
  proto_tree_add_item(tree, hf_vnc_h264_width,
3058
0
          tvb, *offset, 4, ENC_BIG_ENDIAN);
3059
0
  *offset += 4;
3060
3061
0
  proto_tree_add_item(tree, hf_vnc_h264_height,
3062
0
          tvb, *offset, 4, ENC_BIG_ENDIAN);
3063
0
  *offset += 4;
3064
3065
0
  VNC_BYTES_NEEDED(nbytes);
3066
0
  proto_tree_add_item(tree, hf_vnc_h264_data,
3067
0
          tvb, *offset, nbytes, ENC_NA);
3068
0
  *offset += nbytes;
3069
3070
0
  return 0; /* bytes_needed */
3071
0
}
3072
3073
#if defined(HAVE_ZLIB) || defined(HAVE_ZLIBNG)
3074
static unsigned
3075
vnc_zrle_encoding(tvbuff_t *tvb, packet_info *pinfo, int *offset,
3076
      proto_tree *tree, const uint16_t width, const uint16_t height)
3077
#else
3078
static unsigned
3079
vnc_zrle_encoding(tvbuff_t *tvb, packet_info *pinfo _U_, int *offset,
3080
      proto_tree *tree, const uint16_t width _U_, const uint16_t height _U_)
3081
#endif
3082
0
{
3083
0
  uint32_t data_len;
3084
0
#if defined (HAVE_ZLIB) || defined (HAVE_ZLIBNG)
3085
0
  uint8_t palette_size;
3086
0
  uint8_t bytes_per_cpixel = vnc_get_bytes_per_pixel(pinfo);
3087
0
  int uncomp_offset = 0;
3088
0
  unsigned length;
3089
0
  int subencoding_type;
3090
0
  tvbuff_t *uncomp_tvb;
3091
0
  proto_tree *zrle_subencoding_tree;
3092
0
  proto_item *ti;
3093
0
#endif
3094
3095
0
  VNC_BYTES_NEEDED(4);
3096
0
  proto_tree_add_item(tree, hf_vnc_zrle_len, tvb, *offset,
3097
0
          4, ENC_BIG_ENDIAN);
3098
0
  data_len = tvb_get_ntohl(tvb, *offset);
3099
3100
0
  *offset += 4;
3101
3102
0
  VNC_BYTES_NEEDED(data_len);
3103
3104
0
  proto_tree_add_item(tree, hf_vnc_zrle_data, tvb, *offset,
3105
0
          data_len, ENC_NA);
3106
3107
0
#if defined (HAVE_ZLIB) || defined (HAVE_ZLIBNG)
3108
0
  uncomp_tvb = tvb_child_uncompress_zlib(tvb, tvb, *offset, data_len);
3109
3110
0
  if(uncomp_tvb != NULL) {
3111
0
    add_new_data_source(pinfo, uncomp_tvb,
3112
0
            "Uncompressed ZRLE data");
3113
3114
0
    ti = proto_tree_add_item(tree, hf_vnc_zrle_subencoding,
3115
0
           uncomp_tvb, uncomp_offset, 1, ENC_BIG_ENDIAN);
3116
0
    zrle_subencoding_tree =
3117
0
      proto_item_add_subtree(ti, ett_vnc_zrle_subencoding);
3118
3119
0
    proto_tree_add_item(zrle_subencoding_tree, hf_vnc_zrle_rle,
3120
0
            uncomp_tvb, uncomp_offset, 1, ENC_BIG_ENDIAN);
3121
3122
0
    proto_tree_add_item(zrle_subencoding_tree,
3123
0
            hf_vnc_zrle_palette_size, uncomp_tvb,
3124
0
            uncomp_offset, 1, ENC_BIG_ENDIAN);
3125
3126
0
    subencoding_type = tvb_get_uint8(uncomp_tvb, uncomp_offset);
3127
0
    palette_size = subencoding_type & 0x7F;
3128
3129
0
    uncomp_offset += 1;
3130
3131
0
    if(subencoding_type == 0) { /* Raw */
3132
0
      length = width * height * bytes_per_cpixel;
3133
0
      VNC_BYTES_NEEDED(length);
3134
3135
      /* XXX - not working yet! */
3136
3137
0
      proto_tree_add_item(zrle_subencoding_tree,
3138
0
              hf_vnc_zrle_raw, uncomp_tvb,
3139
0
              uncomp_offset, length, ENC_NA);
3140
3141
0
    } else if(subencoding_type >= 130 && subencoding_type <= 255) {
3142
0
      length = palette_size * bytes_per_cpixel;
3143
0
      VNC_BYTES_NEEDED(length);
3144
3145
0
      proto_tree_add_item(zrle_subencoding_tree,
3146
0
              hf_vnc_zrle_palette, uncomp_tvb,
3147
0
              uncomp_offset, length, ENC_NA);
3148
3149
      /* XXX - Not complete! */
3150
0
    }
3151
3152
0
  } else {
3153
0
    proto_tree_add_expert(tree, pinfo, &ei_vnc_zrle_failed, tvb, *offset, data_len);
3154
0
  }
3155
0
#endif /* HAVE_ZLIB */
3156
3157
0
  *offset += data_len;
3158
3159
0
  return 0; /* bytes_needed */
3160
0
}
3161
3162
3163
static unsigned
3164
read_compact_len(tvbuff_t *tvb, int *offset, int *length, int *value_length)
3165
0
{
3166
0
  int b;
3167
3168
0
  VNC_BYTES_NEEDED(1);
3169
3170
0
  *value_length = 0;
3171
3172
0
  b = tvb_get_uint8(tvb, *offset);
3173
0
  *offset += 1;
3174
0
  *value_length += 1;
3175
3176
0
  *length = b & 0x7f;
3177
0
  if ((b & 0x80) != 0) {
3178
0
    VNC_BYTES_NEEDED(1);
3179
3180
0
    b = tvb_get_uint8(tvb, *offset);
3181
0
    *offset += 1;
3182
0
    *value_length += 1;
3183
3184
0
    *length |= (b & 0x7f) << 7;
3185
3186
0
    if ((b & 0x80) != 0) {
3187
0
      VNC_BYTES_NEEDED (1);
3188
3189
0
      b = tvb_get_uint8(tvb, *offset);
3190
0
      *offset += 1;
3191
0
      *value_length += 1;
3192
3193
0
      *length |= (b & 0xff) << 14;
3194
0
    }
3195
0
  }
3196
3197
0
  return 0;
3198
0
}
3199
3200
3201
static unsigned
3202
process_compact_length_and_image_data(tvbuff_t *tvb, int *offset, proto_tree *tree)
3203
0
{
3204
0
  unsigned bytes_needed;
3205
0
  unsigned length, value_length;
3206
3207
0
  bytes_needed = read_compact_len (tvb, offset, &length, &value_length);
3208
0
  if (bytes_needed != 0)
3209
0
    return bytes_needed;
3210
3211
0
  proto_tree_add_uint(tree, hf_vnc_tight_image_len, tvb, *offset - value_length, value_length, length);
3212
3213
0
  VNC_BYTES_NEEDED(length);
3214
0
  proto_tree_add_item(tree, hf_vnc_tight_image_data, tvb, *offset, length, ENC_NA);
3215
0
  *offset += length;
3216
3217
0
  return 0; /* bytes_needed */
3218
0
}
3219
3220
3221
static unsigned
3222
process_tight_rect_filter_palette(tvbuff_t *tvb, packet_info *pinfo, int *offset,
3223
          proto_tree *tree, int *bits_per_pixel)
3224
0
{
3225
0
  vnc_packet_t *per_packet_info;
3226
0
  int num_colors;
3227
0
  unsigned palette_bytes;
3228
3229
  /* See TightVNC's vnc_unixsrc/vncviewer/tight.c:InitFilterPaletteBPP() */
3230
3231
0
  per_packet_info = (vnc_packet_t *)p_get_proto_data(wmem_file_scope(), pinfo, proto_vnc, 0);
3232
  /* Our calling function should have set the packet's proto data already */
3233
0
  DISSECTOR_ASSERT(per_packet_info != NULL);
3234
3235
0
  VNC_BYTES_NEEDED(1);
3236
0
  proto_tree_add_item(tree, hf_vnc_tight_palette_num_colors, tvb, *offset, 1, ENC_BIG_ENDIAN);
3237
0
  num_colors = tvb_get_uint8(tvb, *offset);
3238
0
  *offset += 1;
3239
3240
0
  num_colors++;
3241
0
  if (num_colors < 2)
3242
0
    return 0;
3243
3244
0
  if (per_packet_info->depth == 24)
3245
0
    palette_bytes = num_colors * 3;
3246
0
  else
3247
0
    palette_bytes = num_colors * per_packet_info->depth / 8;
3248
3249
0
  VNC_BYTES_NEEDED(palette_bytes);
3250
0
  proto_tree_add_item(tree, hf_vnc_tight_palette_data, tvb, *offset, palette_bytes, ENC_NA);
3251
0
  *offset += palette_bytes;
3252
3253
  /* This is the number of bits per pixel *in the image data*, not the actual client depth */
3254
0
  if (num_colors == 2)
3255
0
    *bits_per_pixel = 1;
3256
0
  else
3257
0
    *bits_per_pixel = 8;
3258
3259
0
  return 0;
3260
0
}
3261
3262
static unsigned
3263
vnc_tight_encoding(tvbuff_t *tvb, packet_info *pinfo, int *offset,
3264
       proto_tree *tree, const uint16_t width _U_, const uint16_t height _U_)
3265
0
{
3266
0
  vnc_packet_t *per_packet_info;
3267
0
  uint8_t comp_ctl;
3268
0
  proto_item *compression_type_ti;
3269
0
  int bit_offset;
3270
0
  int bytes_needed = -1;
3271
3272
0
  per_packet_info = (vnc_packet_t *)p_get_proto_data(wmem_file_scope(), pinfo, proto_vnc, 0);
3273
  /* Our calling function should have set the packet's proto data already */
3274
0
  DISSECTOR_ASSERT(per_packet_info != NULL);
3275
3276
  /* See xserver/hw/vnc/rfbproto.h and grep for "Tight Encoding." for the following layout */
3277
3278
0
  VNC_BYTES_NEEDED(1);
3279
3280
  /* least significant bits 0-3 are "reset compression stream N" */
3281
0
  bit_offset = *offset * 8;
3282
0
  proto_tree_add_bits_item(tree, hf_vnc_tight_reset_stream0, tvb, bit_offset + 7, 1, ENC_BIG_ENDIAN);
3283
0
  proto_tree_add_bits_item(tree, hf_vnc_tight_reset_stream1, tvb, bit_offset + 6, 1, ENC_BIG_ENDIAN);
3284
0
  proto_tree_add_bits_item(tree, hf_vnc_tight_reset_stream2, tvb, bit_offset + 5, 1, ENC_BIG_ENDIAN);
3285
0
  proto_tree_add_bits_item(tree, hf_vnc_tight_reset_stream3, tvb, bit_offset + 4, 1, ENC_BIG_ENDIAN);
3286
3287
  /* most significant bits 4-7 are "compression type" */
3288
0
  compression_type_ti = proto_tree_add_bits_item(tree, hf_vnc_tight_rect_type, tvb, bit_offset + 0, 4, ENC_BIG_ENDIAN);
3289
3290
0
  comp_ctl = tvb_get_uint8(tvb, *offset);
3291
0
  *offset += 1;
3292
3293
0
  comp_ctl >>= 4; /* skip over the "reset compression" bits from above */
3294
3295
  /* compression format */
3296
3297
0
  if (comp_ctl == TIGHT_RECT_FILL) {
3298
    /* "fill" encoding (solid rectangle) */
3299
3300
0
    proto_item_append_text(compression_type_ti, " (fill encoding - solid rectangle)");
3301
3302
0
    if (per_packet_info->depth == 24) {
3303
0
      VNC_BYTES_NEEDED(3);
3304
0
      proto_tree_add_item(tree, hf_vnc_tight_fill_color, tvb, *offset, 3, ENC_NA);
3305
0
      *offset += 3;
3306
0
    } else {
3307
0
      VNC_BYTES_NEEDED(per_packet_info->bytes_per_pixel);
3308
0
      proto_tree_add_item(tree, hf_vnc_tight_fill_color, tvb, *offset, per_packet_info->bytes_per_pixel, ENC_NA);
3309
0
      *offset += per_packet_info->bytes_per_pixel;
3310
0
    }
3311
3312
0
    bytes_needed = 0;
3313
0
  } else if (comp_ctl == TIGHT_RECT_JPEG) {
3314
    /* jpeg encoding */
3315
3316
0
    proto_item_append_text(compression_type_ti, " (JPEG encoding)");
3317
0
    bytes_needed = process_compact_length_and_image_data(tvb, offset, tree);
3318
0
    if (bytes_needed != 0)
3319
0
      return bytes_needed;
3320
0
  } else if (comp_ctl > TIGHT_RECT_MAX_VALUE) {
3321
    /* invalid encoding */
3322
3323
0
    expert_add_info(pinfo, compression_type_ti, &ei_vnc_invalid_encoding);
3324
0
  } else {
3325
0
    unsigned row_size;
3326
0
    int bits_per_pixel;
3327
3328
    /* basic encoding */
3329
3330
0
    proto_item_append_text(compression_type_ti, " (basic encoding)");
3331
3332
0
    proto_tree_add_bits_item(tree, hf_vnc_tight_filter_flag, tvb, bit_offset + 1, 1, ENC_BIG_ENDIAN);
3333
3334
0
    bits_per_pixel = per_packet_info->depth;
3335
3336
0
    if ((comp_ctl & TIGHT_RECT_EXPLICIT_FILTER_FLAG) != 0) {
3337
0
      uint8_t filter_id;
3338
3339
      /* explicit filter */
3340
3341
0
      VNC_BYTES_NEEDED(1);
3342
0
      proto_tree_add_item(tree, hf_vnc_tight_filter_id, tvb, *offset, 1, ENC_BIG_ENDIAN);
3343
0
      filter_id = tvb_get_uint8(tvb, *offset);
3344
0
      *offset += 1;
3345
3346
0
      switch (filter_id) {
3347
0
      case TIGHT_RECT_FILTER_COPY:
3348
        /* nothing to do */
3349
0
        break;
3350
3351
0
      case TIGHT_RECT_FILTER_PALETTE:
3352
0
        bytes_needed = process_tight_rect_filter_palette(tvb, pinfo, offset, tree, &bits_per_pixel);
3353
0
        if (bytes_needed != 0)
3354
0
          return bytes_needed;
3355
3356
0
        break;
3357
3358
0
      case TIGHT_RECT_FILTER_GRADIENT:
3359
        /* nothing to do */
3360
0
        break;
3361
0
      }
3362
0
    } else {
3363
      /* this is the same case as TIGHT_RECT_FILTER_COPY, so there's nothing special to do */
3364
0
    }
3365
3366
0
    row_size = ((unsigned) width * bits_per_pixel + 7) / 8;
3367
0
    if (row_size * height < TIGHT_MIN_BYTES_TO_COMPRESS) {
3368
0
      unsigned num_bytes;
3369
3370
      /* The data is not compressed; just skip over it */
3371
3372
0
      num_bytes = row_size * height;
3373
0
      VNC_BYTES_NEEDED(num_bytes);
3374
0
      proto_tree_add_item(tree, hf_vnc_tight_image_data, tvb, *offset, num_bytes, ENC_NA);
3375
0
      *offset += num_bytes;
3376
3377
0
      bytes_needed = 0;
3378
0
    } else {
3379
      /* The data is compressed; read its length and data */
3380
0
      bytes_needed = process_compact_length_and_image_data(tvb, offset, tree);
3381
0
      if (bytes_needed != 0)
3382
0
        return bytes_needed;
3383
0
    }
3384
0
  }
3385
3386
0
  DISSECTOR_ASSERT(bytes_needed != -1);
3387
3388
0
  return bytes_needed;
3389
0
}
3390
3391
3392
static unsigned
3393
decode_cursor(tvbuff_t *tvb, int *offset, proto_tree *tree,
3394
        unsigned pixels_bytes, unsigned mask_bytes)
3395
0
{
3396
0
  unsigned total_bytes;
3397
3398
0
  total_bytes = pixels_bytes + mask_bytes;
3399
0
  VNC_BYTES_NEEDED (total_bytes);
3400
3401
0
  proto_tree_add_item(tree, hf_vnc_cursor_encoding_pixels, tvb, *offset,
3402
0
          pixels_bytes, ENC_NA);
3403
0
  *offset += pixels_bytes;
3404
3405
0
  proto_tree_add_item(tree, hf_vnc_cursor_encoding_bitmask, tvb, *offset,
3406
0
          mask_bytes, ENC_NA);
3407
0
  *offset += mask_bytes;
3408
3409
0
  return 0; /* bytes_needed */
3410
0
}
3411
3412
3413
static unsigned
3414
vnc_rich_cursor_encoding(tvbuff_t *tvb, packet_info *pinfo, int *offset,
3415
       proto_tree *tree, const uint16_t width, const uint16_t height)
3416
0
{
3417
0
  uint8_t bytes_per_pixel = vnc_get_bytes_per_pixel(pinfo);
3418
0
  unsigned  pixels_bytes, mask_bytes;
3419
3420
0
  pixels_bytes = width * height * bytes_per_pixel;
3421
0
  mask_bytes   = ((width + 7) / 8) * height;
3422
3423
0
  return decode_cursor(tvb, offset, tree,
3424
0
           pixels_bytes, mask_bytes);
3425
0
}
3426
3427
3428
static unsigned
3429
vnc_x_cursor_encoding(tvbuff_t *tvb, packet_info *pinfo _U_, int *offset,
3430
          proto_tree *tree, const uint16_t width, const uint16_t height)
3431
0
{
3432
0
  int bitmap_row_bytes = (width + 7) / 8;
3433
0
  int mask_bytes       = bitmap_row_bytes * height;
3434
3435
0
  VNC_BYTES_NEEDED (6);
3436
0
  proto_tree_add_item(tree, hf_vnc_cursor_x_fore_back, tvb, *offset, 6, ENC_NA);
3437
0
  *offset += 6;
3438
3439
  /* The length of the pixel data is the same as the length of the mask data (X cursors are strictly black/white) */
3440
0
  return decode_cursor(tvb, offset, tree,
3441
0
           mask_bytes, mask_bytes);
3442
0
}
3443
3444
3445
static unsigned
3446
vnc_server_set_colormap_entries(tvbuff_t *tvb, packet_info *pinfo, int *offset,
3447
        proto_tree *tree)
3448
0
{
3449
0
  uint16_t number_of_colors;
3450
0
  unsigned counter, bytes_needed;
3451
0
  proto_item *ti;
3452
0
  proto_tree *vnc_colormap_num_groups, *vnc_colormap_color_group;
3453
3454
0
  col_append_sep_str(pinfo->cinfo, COL_INFO, "; ", "Server set colormap entries");
3455
3456
0
  number_of_colors = tvb_get_ntohs(tvb, 4);
3457
3458
0
  VNC_BYTES_NEEDED(3);
3459
0
  proto_tree_add_item(tree, hf_vnc_padding, tvb, *offset, 1, ENC_NA);
3460
0
  *offset += 1; /* Skip over 1 byte of padding */
3461
3462
0
  proto_tree_add_item(tree, hf_vnc_colormap_first_color,
3463
0
          tvb, *offset, 2, ENC_BIG_ENDIAN);
3464
0
  *offset += 2;
3465
3466
  /*  XXX - this is 3 bytes into the tvb, but number_of_colors is set off
3467
   *  of 4 bytes in... Bug???
3468
   */
3469
0
  ti = proto_tree_add_item(tree, hf_vnc_colormap_num_colors, tvb,
3470
0
         *offset, 2, ENC_BIG_ENDIAN);
3471
3472
0
  if (number_of_colors > 10000) {
3473
0
    expert_add_info_format(pinfo, ti, &ei_vnc_too_many_colors,"Too many colors (%d), aborting dissection",
3474
0
               number_of_colors);
3475
0
    return 0;
3476
0
  }
3477
3478
0
  bytes_needed = (number_of_colors * 6) + 5;
3479
0
  VNC_BYTES_NEEDED(bytes_needed);
3480
3481
0
  *offset += 2;
3482
3483
0
  ti = proto_tree_add_item(tree, hf_vnc_color_groups, tvb,
3484
0
        *offset, number_of_colors * 6, ENC_NA);
3485
0
  vnc_colormap_num_groups =
3486
0
    proto_item_add_subtree(ti, ett_vnc_colormap_num_groups);
3487
3488
0
  for(counter = 0; counter < number_of_colors; counter++) {
3489
0
    vnc_colormap_color_group = proto_tree_add_subtree_format(vnc_colormap_num_groups, tvb,
3490
0
           *offset, 6, ett_vnc_colormap_color_group, NULL,
3491
0
           "Color group #%d", counter+1);
3492
3493
0
    proto_tree_add_item(vnc_colormap_color_group,
3494
0
            hf_vnc_colormap_red, tvb,
3495
0
            *offset, 2, ENC_BIG_ENDIAN);
3496
0
    *offset += 2;
3497
3498
0
    proto_tree_add_item(vnc_colormap_color_group,
3499
0
            hf_vnc_colormap_green, tvb,
3500
0
            *offset, 2, ENC_BIG_ENDIAN);
3501
0
    *offset += 2;
3502
3503
0
    proto_tree_add_item(vnc_colormap_color_group,
3504
0
            hf_vnc_colormap_blue, tvb,
3505
0
            *offset, 2, ENC_BIG_ENDIAN);
3506
0
    *offset += 2;
3507
0
  }
3508
0
  return 0;
3509
0
}
3510
3511
3512
static void
3513
vnc_server_ring_bell(tvbuff_t *tvb _U_, packet_info *pinfo, int *offset _U_,
3514
         proto_tree *tree _U_)
3515
0
{
3516
0
  col_append_sep_str(pinfo->cinfo, COL_INFO, "; ", "Server ring bell on client");
3517
  /* This message type has no payload... */
3518
0
}
3519
3520
3521
static unsigned
3522
vnc_server_cut_text(tvbuff_t *tvb, packet_info *pinfo, int *offset,
3523
        proto_tree *tree)
3524
0
{
3525
0
  uint32_t    text_len;
3526
0
  proto_item *pi;
3527
3528
0
  col_append_sep_str(pinfo->cinfo, COL_INFO, "; ", "Server cut text");
3529
3530
0
  text_len = tvb_get_ntohl(tvb, *offset);
3531
0
  pi = proto_tree_add_item(tree, hf_vnc_server_cut_text_len, tvb, *offset, 4,
3532
0
          ENC_BIG_ENDIAN);
3533
0
  *offset += 4;
3534
3535
0
  if (text_len > 100000) {
3536
0
    expert_add_info_format(pinfo, pi, &ei_vnc_too_many_cut_text,
3537
0
        "Too much cut text (%d), aborting dissection", text_len);
3538
0
    return 0;
3539
0
  }
3540
3541
0
  VNC_BYTES_NEEDED(text_len);
3542
3543
0
  proto_tree_add_item(tree, hf_vnc_server_cut_text, tvb, *offset,
3544
0
          text_len, ENC_ASCII);
3545
0
  *offset += text_len;
3546
3547
0
  return *offset;
3548
0
}
3549
3550
3551
static void
3552
vnc_set_bytes_per_pixel(packet_info *pinfo, vnc_conversation_t *per_conversation_info, const uint8_t bytes_per_pixel)
3553
0
{
3554
0
  if (PINFO_FD_VISITED(pinfo)) {
3555
0
    return;
3556
0
  }
3557
3558
0
  vnc_packet_t *per_packet_info;
3559
3560
0
  per_packet_info = (vnc_packet_t *)p_get_proto_data(wmem_file_scope(), pinfo, proto_vnc, 0);
3561
  /* Our calling function should have set the packet's proto data already */
3562
0
  DISSECTOR_ASSERT(per_packet_info != NULL);
3563
3564
0
  per_packet_info->bytes_per_pixel = per_conversation_info->bytes_per_pixel = bytes_per_pixel;
3565
0
}
3566
3567
3568
static void
3569
vnc_set_depth(packet_info *pinfo, vnc_conversation_t *per_conversation_info, const uint8_t depth)
3570
0
{
3571
0
  if (PINFO_FD_VISITED(pinfo)) {
3572
0
    return;
3573
0
  }
3574
3575
0
  vnc_packet_t *per_packet_info;
3576
3577
0
  per_packet_info = (vnc_packet_t *)p_get_proto_data(wmem_file_scope(), pinfo, proto_vnc, 0);
3578
  /* Our calling function should have set the packet's proto data already */
3579
0
  DISSECTOR_ASSERT(per_packet_info != NULL);
3580
3581
0
  per_packet_info->depth = per_conversation_info->depth = depth;
3582
0
}
3583
3584
3585
static uint8_t
3586
vnc_get_bytes_per_pixel(packet_info *pinfo)
3587
0
{
3588
0
  vnc_packet_t *per_packet_info;
3589
3590
0
  per_packet_info = (vnc_packet_t *)p_get_proto_data(wmem_file_scope(), pinfo, proto_vnc, 0);
3591
  /* Our calling function should have set the packet's proto data already */
3592
0
  DISSECTOR_ASSERT(per_packet_info != NULL);
3593
3594
0
  return per_packet_info->bytes_per_pixel;
3595
0
}
3596
3597
3598
static uint8_t
3599
vnc_get_depth(packet_info *pinfo)
3600
0
{
3601
0
  vnc_packet_t *per_packet_info;
3602
3603
0
  per_packet_info = (vnc_packet_t *)p_get_proto_data(wmem_file_scope(), pinfo, proto_vnc, 0);
3604
  /* Our calling function should have set the packet's proto data already */
3605
0
  DISSECTOR_ASSERT(per_packet_info != NULL);
3606
3607
0
  return per_packet_info->depth;
3608
0
}
3609
3610
/* Preference callbacks */
3611
static void
3612
0
apply_vnc_prefs(void) {
3613
0
    vnc_tcp_range = prefs_get_range_value("vnc", "tcp.port");
3614
0
}
3615
3616
/* Register the protocol with Wireshark */
3617
void
3618
proto_register_vnc(void)
3619
14
{
3620
14
  module_t *vnc_module; /* To handle our preferences */
3621
14
  expert_module_t* expert_vnc;
3622
3623
  /* Setup list of header fields */
3624
14
  static hf_register_info hf[] = {
3625
14
    { &hf_vnc_padding,
3626
14
      { "Padding", "vnc.padding",
3627
14
        FT_NONE, BASE_NONE, NULL, 0x0,
3628
14
        "Unused space", HFILL }
3629
14
    },
3630
3631
14
    { &hf_vnc_server_proto_ver,
3632
14
      { "Server protocol version", "vnc.server_proto_ver",
3633
14
        FT_STRING, BASE_NONE, NULL, 0x0,
3634
14
        "VNC protocol version on server", HFILL }
3635
14
    },
3636
14
    { &hf_vnc_client_proto_ver,
3637
14
      { "Client protocol version", "vnc.client_proto_ver",
3638
14
        FT_STRING, BASE_NONE, NULL, 0x0,
3639
14
        "VNC protocol version on client", HFILL }
3640
14
    },
3641
14
    { &hf_vnc_num_security_types,
3642
14
      { "Number of security types", "vnc.num_security_types",
3643
14
        FT_UINT8, BASE_DEC, NULL, 0x0,
3644
14
        "Number of security (authentication) types supported by the server", HFILL }
3645
14
    },
3646
14
    { &hf_vnc_security_type,
3647
14
      { "Security type", "vnc.security_type",
3648
14
        FT_UINT8, BASE_DEC, VALS(vnc_security_types_vs), 0x0,
3649
14
        "Security types offered by the server (VNC versions => 3.007)", HFILL }
3650
14
    },
3651
14
    { &hf_vnc_server_security_type,
3652
14
      { "Security type", "vnc.server_security_type",
3653
14
        FT_UINT32, BASE_DEC, VALS(vnc_security_types_vs), 0x0,
3654
14
        "Security type mandated by the server", HFILL }
3655
14
    },
3656
14
    { &hf_vnc_client_security_type,
3657
14
      { "Security type selected", "vnc.client_security_type",
3658
14
        FT_UINT8, BASE_DEC, VALS(vnc_security_types_vs), 0x0,
3659
14
        "Security type selected by the client", HFILL }
3660
14
    },
3661
14
    { &hf_vnc_tight_num_tunnel_types,
3662
14
      { "Number of supported tunnel types",  "vnc.num_tunnel_types",
3663
14
        FT_UINT32, BASE_DEC, NULL, 0x0,
3664
14
        "Number of tunnel types for TightVNC", HFILL }
3665
14
    },
3666
14
    { &hf_vnc_tight_tunnel_type_code,
3667
14
      { "Tunnel type code", "vnc.tunnel_type_code",
3668
14
        FT_UINT32, BASE_DEC, NULL, 0x0,
3669
14
        "Tunnel type code specific to TightVNC", HFILL }
3670
14
    },
3671
14
    { &hf_vnc_tight_tunnel_type_vendor,
3672
14
      { "Tunnel type vendor", "vnc.tunnel_type_vendor",
3673
14
        FT_STRING, BASE_NONE, NULL, 0x0,
3674
14
        "Tunnel type vendor specific to TightVNC", HFILL }
3675
14
    },
3676
14
    { &hf_vnc_tight_tunnel_type_signature,
3677
14
      { "Tunnel type signature", "vnc.tunnel_type_signature",
3678
14
        FT_STRING, BASE_NONE, NULL, 0x0,
3679
14
        "Tunnel type signature specific to TightVNC", HFILL }
3680
14
    },
3681
14
    { &hf_vnc_tight_num_auth_types,
3682
14
      { "Number of supported authentication types", "vnc.num_auth_types",
3683
14
        FT_UINT32, BASE_DEC, NULL, 0x0,
3684
14
        "Authentication types specific to TightVNC", HFILL }
3685
14
    },
3686
14
    { &hf_vnc_tight_auth_code,
3687
14
      { "Authentication code", "vnc.tight_auth_code",
3688
14
        FT_UINT32, BASE_DEC, VALS(vnc_security_types_vs), 0x0,
3689
14
        "Authentication code specific to TightVNC", HFILL }
3690
14
    },
3691
14
    { &hf_vnc_tight_server_message_type,
3692
14
      { "Server message type (TightVNC)", "vnc.tight_server_message_type",
3693
14
        FT_INT32, BASE_DEC, NULL, 0x0,
3694
14
        "Server message type specific to TightVNC", HFILL }
3695
14
    },
3696
14
    { &hf_vnc_tight_server_vendor,
3697
14
      { "Server vendor code", "vnc.server_vendor",
3698
14
        FT_STRING, BASE_NONE, NULL, 0x0,
3699
14
        "Server vendor code specific to TightVNC", HFILL }
3700
14
    },
3701
14
    { &hf_vnc_tight_signature,
3702
14
      { "Signature", "vnc.signature",
3703
14
        FT_STRING, BASE_NONE, NULL, 0x0,
3704
14
        NULL, HFILL }
3705
14
    },
3706
14
    { &hf_vnc_tight_server_name,
3707
14
      { "Server name", "vnc.server_name",
3708
14
        FT_STRING, BASE_NONE, NULL, 0x0,
3709
14
        "Server name specific to TightVNC", HFILL }
3710
14
    },
3711
14
    { &hf_vnc_tight_client_message_type,
3712
14
      { "Client message type (TightVNC)", "vnc.tight_client_message_type",
3713
14
        FT_INT32, BASE_DEC, NULL, 0x0,
3714
14
        "Client message type specific to TightVNC", HFILL }
3715
14
    },
3716
14
    { &hf_vnc_tight_client_vendor,
3717
14
      { "Client vendor code", "vnc.client_vendor",
3718
14
        FT_STRING, BASE_NONE, NULL, 0x0,
3719
14
        "Client vendor code specific to TightVNC", HFILL }
3720
14
    },
3721
14
    { &hf_vnc_tight_client_name,
3722
14
      { "Client name", "vnc.client_name",
3723
14
        FT_STRING, BASE_NONE, NULL, 0x0,
3724
14
        "Client name specific to TightVNC", HFILL }
3725
14
    },
3726
14
    { &hf_vnc_tight_encoding_type,
3727
14
      { "Encoding type", "vnc.encoding_type",
3728
14
        FT_INT32, BASE_DEC, VALS(encoding_types_vs), 0x0,
3729
14
        "Encoding type specific to TightVNC", HFILL }
3730
14
    },
3731
14
    { &hf_vnc_tight_encoding_vendor,
3732
14
      { "Encoding vendor code", "vnc.encoding_vendor",
3733
14
        FT_STRING, BASE_NONE, NULL, 0x0,
3734
14
        "Encoding vendor code specific to TightVNC", HFILL }
3735
14
    },
3736
14
    { &hf_vnc_tight_encoding_name,
3737
14
      { "Encoding name", "vnc.encoding_name",
3738
14
        FT_STRING, BASE_NONE, NULL, 0x0,
3739
14
        "Encoding name specific to TightVNC", HFILL }
3740
14
    },
3741
14
    { &hf_vnc_tight_reset_stream0,
3742
14
      { "Reset compression stream 0", "vnc.tight_reset_stream0",
3743
14
        FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3744
14
        "Tight compression, reset compression stream 0", HFILL }
3745
14
    },
3746
14
    { &hf_vnc_tight_reset_stream1,
3747
14
      { "Reset compression stream 1", "vnc.tight_reset_stream1",
3748
14
        FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3749
14
        "Tight compression, reset compression stream 1", HFILL }
3750
14
    },
3751
14
    { &hf_vnc_tight_reset_stream2,
3752
14
      { "Reset compression stream 2", "vnc.tight_reset_stream2",
3753
14
        FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3754
14
        "Tight compression, reset compression stream 2", HFILL }
3755
14
    },
3756
14
    { &hf_vnc_tight_reset_stream3,
3757
14
      { "Reset compression stream 3", "vnc.tight_reset_stream3",
3758
14
        FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3759
14
        "Tight compression, reset compression stream 3", HFILL }
3760
14
    },
3761
14
    { &hf_vnc_tight_rect_type,
3762
14
      { "Rectangle type", "vnc.tight_rect_type",
3763
14
        FT_UINT8, BASE_HEX, NULL, 0x0,
3764
14
        "Tight compression, rectangle type", HFILL }
3765
14
    },
3766
14
    { &hf_vnc_tight_image_len,
3767
14
      { "Image data length", "vnc.tight_image_len",
3768
14
        FT_UINT32, BASE_DEC, NULL, 0x0,
3769
14
        "Tight compression, length of image data", HFILL }
3770
14
    },
3771
14
    { &hf_vnc_tight_image_data,
3772
14
      { "Image data", "vnc.tight_image_data",
3773
14
        FT_BYTES, BASE_NONE, NULL, 0x0,
3774
14
        "Tight compression, image data", HFILL }
3775
14
    },
3776
14
    { &hf_vnc_tight_fill_color,
3777
14
      { "Fill color (RGB)", "vnc.tight_fill_color",
3778
14
        FT_BYTES, BASE_NONE, NULL, 0x0,
3779
14
        "Tight compression, fill color for solid rectangle", HFILL }
3780
14
    },
3781
14
    { &hf_vnc_tight_filter_flag,
3782
14
      { "Explicit filter flag", "vnc.tight_filter_flag",
3783
14
        FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3784
14
        "Tight compression, explicit filter flag", HFILL }
3785
14
    },
3786
14
    { &hf_vnc_tight_filter_id,
3787
14
      { "Filter ID", "vnc.tight_filter_id",
3788
14
        FT_UINT8, BASE_DEC, VALS(tight_filter_ids_vs), 0x0,
3789
14
        "Tight compression, filter ID", HFILL }
3790
14
    },
3791
14
    { &hf_vnc_tight_palette_num_colors,
3792
14
      { "Number of colors in palette", "vnc.tight_palette_num_colors",
3793
14
        FT_UINT8, BASE_DEC, NULL, 0x0,
3794
14
        "Tight compression, number of colors in rectangle's palette", HFILL }
3795
14
    },
3796
14
    { &hf_vnc_tight_palette_data,
3797
14
      { "Palette data", "vnc.tight_palette_data",
3798
14
        FT_BYTES, BASE_NONE, NULL, 0x0,
3799
14
        "Tight compression, palette data for a rectangle", HFILL }
3800
14
    },
3801
14
    { &hf_vnc_auth_challenge,
3802
14
      { "Authentication challenge", "vnc.auth_challenge",
3803
14
        FT_BYTES, BASE_NONE, NULL, 0x0,
3804
14
        "Random authentication challenge from server to client", HFILL }
3805
14
    },
3806
14
    { &hf_vnc_auth_response,
3807
14
      { "Authentication response", "vnc.auth_response",
3808
14
        FT_BYTES, BASE_NONE, NULL, 0x0,
3809
14
        "Client's encrypted response to the server's authentication challenge", HFILL }
3810
14
    },
3811
14
    { &hf_vnc_auth_result,
3812
14
      { "Authentication result", "vnc.auth_result",
3813
14
        FT_BOOLEAN, 32, TFS(&auth_result_tfs), 0x1,
3814
14
        NULL, HFILL }
3815
14
    },
3816
14
    { &hf_vnc_auth_error_length,
3817
14
      { "Length of authentication error", "vnc.auth_error_len",
3818
14
        FT_UINT32, BASE_DEC, NULL, 0x0,
3819
14
        "Authentication error length (present only if the authentication result is fail)", HFILL }
3820
14
    },
3821
14
    { &hf_vnc_auth_error,
3822
14
      { "Authentication error", "vnc.auth_error",
3823
14
        FT_STRING, BASE_NONE, NULL, 0x0,
3824
14
        "Authentication error (present only if the authentication result is fail)", HFILL }
3825
14
    },
3826
14
    { &hf_vnc_ard_auth_generator,
3827
14
      { "Generator", "vnc.ard_auth_generator",
3828
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
3829
14
      "Generator for Diffie-Hellman key exchange", HFILL }
3830
14
    },
3831
14
    { &hf_vnc_ard_auth_key_len,
3832
14
      { "Key length", "vnc.ard_auth_key_len",
3833
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
3834
14
      "Diffie-Hellman key length", HFILL }
3835
14
    },
3836
14
    { &hf_vnc_ard_auth_modulus,
3837
14
      { "Prime modulus", "vnc.ard_auth_modulus",
3838
14
        FT_BYTES, BASE_NONE, NULL, 0x0,
3839
14
      "Prime modulus for Diffie-Hellman key exchange", HFILL }
3840
14
    },
3841
14
    { &hf_vnc_ard_auth_server_key,
3842
14
      { "Server public key", "vnc.ard_auth_server_key",
3843
14
        FT_BYTES, BASE_NONE, NULL, 0x0,
3844
14
      "Server's public Diffie-Hellman key", HFILL }
3845
14
    },
3846
14
    { &hf_vnc_ard_auth_credentials,
3847
14
      { "Encrypted credentials", "vnc.ard_auth_credentials",
3848
14
        FT_BYTES, BASE_NONE, NULL, 0x0,
3849
14
      "Encrypted client username and password", HFILL }
3850
14
    },
3851
14
    { &hf_vnc_ard_auth_client_key,
3852
14
      { "Client public key", "vnc.ard_auth_client_key",
3853
14
        FT_BYTES, BASE_NONE, NULL, 0x0,
3854
14
      "Client's public Diffie-Hellman key", HFILL }
3855
14
    },
3856
14
    { &hf_vnc_vencrypt_server_major_ver,
3857
14
      { "VeNCrypt server major version", "vnc.vencrypt_server_major_ver",
3858
14
        FT_UINT8, BASE_DEC, NULL, 0x0,
3859
14
        NULL, HFILL }
3860
14
    },
3861
14
    { &hf_vnc_vencrypt_server_minor_ver,
3862
14
      { "VeNCrypt server minor version", "vnc.vencrypt_server_minor_ver",
3863
14
        FT_UINT8, BASE_DEC, NULL, 0x0,
3864
14
        NULL, HFILL }
3865
14
    },
3866
14
    { &hf_vnc_vencrypt_client_major_ver,
3867
14
      { "VeNCrypt client major version", "vnc.vencrypt_client_major_ver",
3868
14
        FT_UINT8, BASE_DEC, NULL, 0x0,
3869
14
        NULL, HFILL }
3870
14
    },
3871
14
    { &hf_vnc_vencrypt_client_minor_ver,
3872
14
      { "VeNCrypt client minor version", "vnc.vencrypt_client_minor_ver",
3873
14
        FT_UINT8, BASE_DEC, NULL, 0x0,
3874
14
        NULL, HFILL }
3875
14
    },
3876
14
    { &hf_vnc_vencrypt_version_ack,
3877
14
      { "VeNCrypt version ack", "vnc.vencrypt_version_ack",
3878
14
        FT_BOOLEAN, 8, TFS(&tfs_error_ok), 0xFF,
3879
14
        NULL, HFILL }
3880
14
    },
3881
14
    { &hf_vnc_vencrypt_auth_type,
3882
14
      { "VeNCrypt authentication type", "vnc.vencrypt_auth_type",
3883
14
        FT_UINT32, BASE_DEC, VALS(vnc_vencrypt_auth_types_vs), 0x0,
3884
14
        "Authentication type specific to VeNCrypt", HFILL }
3885
14
    },
3886
14
    { &hf_vnc_vencrypt_num_auth_types,
3887
14
      { "VeNCrypt Number of supported authentication types", "vnc.vencrypt_num_auth_types",
3888
14
        FT_UINT32, BASE_DEC, NULL, 0x0,
3889
14
        NULL, HFILL }
3890
14
    },
3891
14
    { &hf_vnc_vencrypt_auth_type_ack,
3892
14
      { "VeNCrypt Authorization type ack", "vnc.vencrypt_auth_type_ack",
3893
14
        FT_BOOLEAN, 8, TFS(&tfs_ok_error), 0xFF,
3894
14
        NULL, HFILL }
3895
14
    },
3896
14
    { &hf_vnc_share_desktop_flag,
3897
14
      { "Share desktop flag", "vnc.share_desktop_flag",
3898
14
        FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3899
14
        "Client's desire to share the server's desktop with other clients", HFILL }
3900
14
    },
3901
14
    { &hf_vnc_width,
3902
14
      { "Framebuffer width", "vnc.width",
3903
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
3904
14
        "Width of the framebuffer (screen) in pixels", HFILL }
3905
14
    },
3906
14
    { &hf_vnc_height,
3907
14
      { "Framebuffer height", "vnc.height",
3908
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
3909
14
        "Height of the framebuffer (screen) in pixels", HFILL }
3910
14
    },
3911
14
    { &hf_vnc_server_bits_per_pixel,
3912
14
      { "Bits per pixel", "vnc.server_bits_per_pixel",
3913
14
        FT_UINT8, BASE_DEC, NULL, 0x0,
3914
14
        "Number of bits used by server for each pixel value on the wire from the server", HFILL }
3915
14
    },
3916
14
    { &hf_vnc_server_depth,
3917
14
      { "Depth", "vnc.server_depth",
3918
14
        FT_UINT8, BASE_DEC, NULL, 0x0,
3919
14
        "Number of useful bits in the pixel value on server", HFILL }
3920
14
    },
3921
14
    { &hf_vnc_server_big_endian_flag,
3922
14
      { "Big endian flag", "vnc.server_big_endian_flag",
3923
14
        FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3924
14
        "True if multi-byte pixels are interpreted as big endian by server", HFILL }
3925
14
    },
3926
14
    { &hf_vnc_server_true_color_flag,
3927
14
      { "True color flag", "vnc.server_true_color_flag",
3928
14
        FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3929
14
        "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 }
3930
14
    },
3931
14
    { &hf_vnc_server_red_max,
3932
14
      { "Red maximum", "vnc.server_red_max",
3933
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
3934
14
        "Maximum red value on server as n: 2^n - 1", HFILL }
3935
14
    },
3936
14
    { &hf_vnc_server_green_max,
3937
14
      { "Green maximum", "vnc.server_green_max",
3938
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
3939
14
        "Maximum green value on server as n: 2^n - 1", HFILL }
3940
14
    },
3941
14
    { &hf_vnc_server_blue_max,
3942
14
      { "Blue maximum", "vnc.server_blue_max",
3943
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
3944
14
        "Maximum blue value on server as n: 2^n - 1", HFILL }
3945
14
    },
3946
14
    { &hf_vnc_server_red_shift,
3947
14
      { "Red shift", "vnc.server_red_shift",
3948
14
        FT_UINT8, BASE_DEC, NULL, 0x0,
3949
14
        "Number of shifts needed to get the red value in a pixel to the least significant bit on the server", HFILL }
3950
14
    },
3951
14
    { &hf_vnc_server_green_shift,
3952
14
      { "Green shift", "vnc.server_green_shift",
3953
14
        FT_UINT8, BASE_DEC, NULL, 0x0,
3954
14
        "Number of shifts needed to get the green value in a pixel to the least significant bit on the server", HFILL }
3955
14
    },
3956
14
    { &hf_vnc_server_blue_shift,
3957
14
      { "Blue shift", "vnc.server_blue_shift",
3958
14
        FT_UINT8, BASE_DEC, NULL, 0x0,
3959
14
        "Number of shifts needed to get the blue value in a pixel to the least significant bit on the server", HFILL }
3960
14
    },
3961
14
    { &hf_vnc_desktop_name_len,
3962
14
      { "Desktop name length", "vnc.desktop_name_len",
3963
14
        FT_UINT32, BASE_DEC, NULL, 0x0,
3964
14
        "Length of desktop name in bytes", HFILL }
3965
14
    },
3966
14
    { &hf_vnc_desktop_screen_num,
3967
14
      { "Number of screens", "vnc.screen_num",
3968
14
        FT_UINT8, BASE_DEC, NULL, 0x0,
3969
14
        NULL, HFILL }
3970
14
    },
3971
14
    { &hf_vnc_desktop_screen_id,
3972
14
      { "Screen ID", "vnc.screen_id",
3973
14
        FT_UINT32, BASE_DEC, NULL, 0x0,
3974
14
        "ID of screen", HFILL }
3975
14
    },
3976
14
    { &hf_vnc_desktop_screen_x,
3977
14
      { "Screen X position", "vnc.screen_x",
3978
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
3979
14
        "X coordinate of screen", HFILL }
3980
14
    },
3981
14
    { &hf_vnc_desktop_screen_y,
3982
14
      { "Screen Y position", "vnc.screen_y",
3983
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
3984
14
        "Y coordinate of screen", HFILL }
3985
14
    },
3986
14
    { &hf_vnc_desktop_screen_width,
3987
14
      { "Screen width", "vnc.screen_width",
3988
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
3989
14
        "Width of screen", HFILL }
3990
14
    },
3991
14
    { &hf_vnc_desktop_screen_height,
3992
14
      { "Screen height", "vnc.screen_height",
3993
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
3994
14
        "Height of screen", HFILL }
3995
14
    },
3996
14
    { &hf_vnc_desktop_screen_flags,
3997
14
      { "Screen flags", "vnc.screen_flags",
3998
14
        FT_UINT32, BASE_DEC, NULL, 0x0,
3999
14
        "Flags of screen", HFILL }
4000
14
    },
4001
14
    { &hf_vnc_desktop_name,
4002
14
      { "Desktop name", "vnc.desktop_name",
4003
14
        FT_STRING, BASE_NONE, NULL, 0x0,
4004
14
        "Name of the VNC desktop on the server", HFILL }
4005
14
    },
4006
14
    { &hf_vnc_num_server_message_types,
4007
14
      { "Server message types", "vnc.num_server_message_types",
4008
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4009
14
        "Unknown", HFILL } /* XXX - Needs description */
4010
14
    },
4011
14
    { &hf_vnc_num_client_message_types,
4012
14
      { "Client message types", "vnc.num_client_message_types",
4013
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4014
14
        "Unknown", HFILL } /* XXX - Needs description */
4015
14
    },
4016
14
    { &hf_vnc_num_encoding_types,
4017
14
      { "Encoding types", "vnc.num_encoding_types",
4018
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4019
14
        "Unknown", HFILL } /* XXX - Needs description */
4020
14
    },
4021
14
    { &hf_vnc_client_message_type,
4022
14
      { "Client Message Type", "vnc.client_message_type",
4023
14
        FT_UINT8, BASE_DEC, VALS(vnc_client_message_types_vs), 0x0,
4024
14
        "Message type from client", HFILL }
4025
14
    },
4026
14
    { &hf_vnc_client_bits_per_pixel,
4027
14
      { "Bits per pixel", "vnc.client_bits_per_pixel",
4028
14
        FT_UINT8, BASE_DEC, NULL, 0x0,
4029
14
        "Number of bits used by server for each pixel value on the wire from the client", HFILL }
4030
14
    },
4031
14
    { &hf_vnc_client_depth,
4032
14
      { "Depth", "vnc.client_depth",
4033
14
        FT_UINT8, BASE_DEC, NULL, 0x0,
4034
14
        "Number of useful bits in the pixel value on client", HFILL }
4035
14
    },
4036
14
    { &hf_vnc_client_big_endian_flag,
4037
14
      { "Big endian flag", "vnc.client_big_endian_flag",
4038
14
        FT_BOOLEAN, BASE_NONE, NULL, 0x0,
4039
14
        "True if multi-byte pixels are interpreted as big endian by client", HFILL }
4040
14
    },
4041
14
    { &hf_vnc_client_true_color_flag,
4042
14
      { "True color flag", "vnc.client_true_color_flag",
4043
14
        FT_BOOLEAN, BASE_NONE, NULL, 0x0,
4044
14
        "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 }
4045
14
    },
4046
14
    { &hf_vnc_client_red_max,
4047
14
      { "Red maximum", "vnc.client_red_max",
4048
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4049
14
        "Maximum red value on client as n: 2^n - 1", HFILL }
4050
14
    },
4051
14
    { &hf_vnc_client_green_max,
4052
14
      { "Green maximum", "vnc.client_green_max",
4053
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4054
14
        "Maximum green value on client as n: 2^n - 1", HFILL }
4055
14
    },
4056
14
    { &hf_vnc_client_blue_max,
4057
14
      { "Blue maximum", "vnc.client_blue_max",
4058
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4059
14
        "Maximum blue value on client as n: 2^n - 1", HFILL }
4060
14
    },
4061
14
    { &hf_vnc_client_red_shift,
4062
14
      { "Red shift", "vnc.client_red_shift",
4063
14
        FT_UINT8, BASE_DEC, NULL, 0x0,
4064
14
        "Number of shifts needed to get the red value in a pixel to the least significant bit on the client", HFILL }
4065
14
    },
4066
14
    { &hf_vnc_client_green_shift,
4067
14
      { "Green shift", "vnc.client_green_shift",
4068
14
        FT_UINT8, BASE_DEC, NULL, 0x0,
4069
14
        "Number of shifts needed to get the green value in a pixel to the least significant bit on the client", HFILL }
4070
14
    },
4071
14
    { &hf_vnc_client_blue_shift,
4072
14
      { "Blue shift", "vnc.client_blue_shift",
4073
14
        FT_UINT8, BASE_DEC, NULL, 0x0,
4074
14
        "Number of shifts needed to get the blue value in a pixel to the least significant bit on the client", HFILL }
4075
14
    },
4076
4077
    /* Client Key Event */
4078
14
    { &hf_vnc_key_down,
4079
14
      { "Key down", "vnc.key_down",
4080
14
        FT_BOOLEAN, BASE_NONE, TFS(&tfs_yes_no), 0x0,
4081
14
        "Specifies whether the key is being pressed or not", HFILL }
4082
14
    },
4083
14
    { &hf_vnc_key,
4084
14
      { "Key", "vnc.key",
4085
14
        FT_UINT32, BASE_HEX | BASE_EXT_STRING, &x11_keysym_vals_source_ext, 0x0, /* keysym_vals_source_exr is from packet-x11.c */
4086
14
        "Key being pressed/depressed", HFILL }
4087
14
    },
4088
4089
    /* Client Pointer Event */
4090
14
    { &hf_vnc_button_1_pos,
4091
14
      { "Mouse button #1 position", "vnc.button_1_pos",
4092
14
        FT_BOOLEAN, 8, TFS(&tfs_pressed_not_pressed), 0x1,
4093
14
        "Whether mouse button #1 is being pressed or not", HFILL }
4094
14
    },
4095
14
    { &hf_vnc_button_2_pos,
4096
14
      { "Mouse button #2 position", "vnc.button_2_pos",
4097
14
        FT_BOOLEAN, 8, TFS(&tfs_pressed_not_pressed), 0x2,
4098
14
        "Whether mouse button #2 is being pressed or not", HFILL }
4099
14
    },
4100
14
    { &hf_vnc_button_3_pos,
4101
14
      { "Mouse button #3 position", "vnc.button_3_pos",
4102
14
        FT_BOOLEAN, 8, TFS(&tfs_pressed_not_pressed), 0x4,
4103
14
        "Whether mouse button #3 is being pressed or not", HFILL }
4104
14
    },
4105
14
    { &hf_vnc_button_4_pos,
4106
14
      { "Mouse button #4 position", "vnc.button_4_pos",
4107
14
        FT_BOOLEAN, 8, TFS(&tfs_pressed_not_pressed), 0x8,
4108
14
        "Whether mouse button #4 is being pressed or not", HFILL }
4109
14
    },
4110
14
    { &hf_vnc_button_5_pos,
4111
14
      { "Mouse button #5 position", "vnc.button_5_pos",
4112
14
        FT_BOOLEAN, 8, TFS(&tfs_pressed_not_pressed), 0x10,
4113
14
        "Whether mouse button #5 is being pressed or not", HFILL }
4114
14
    },
4115
14
    { &hf_vnc_button_6_pos,
4116
14
      { "Mouse button #6 position", "vnc.button_6_pos",
4117
14
        FT_BOOLEAN, 8, TFS(&tfs_pressed_not_pressed), 0x20,
4118
14
        "Whether mouse button #6 is being pressed or not", HFILL }
4119
14
    },
4120
14
    { &hf_vnc_button_7_pos,
4121
14
      { "Mouse button #7 position", "vnc.button_7_pos",
4122
14
        FT_BOOLEAN, 8, TFS(&tfs_pressed_not_pressed), 0x40,
4123
14
        "Whether mouse button #7 is being pressed or not", HFILL }
4124
14
    },
4125
14
    { &hf_vnc_button_8_pos,
4126
14
      { "Mouse button #8 position", "vnc.button_8_pos",
4127
14
        FT_BOOLEAN, 8, TFS(&tfs_pressed_not_pressed), 0x80,
4128
14
        "Whether mouse button #8 is being pressed or not", HFILL }
4129
14
    },
4130
14
    { &hf_vnc_pointer_x_pos,
4131
14
      { "X position", "vnc.pointer_x_pos",
4132
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4133
14
        "Position of mouse cursor on the x-axis", HFILL }
4134
14
    },
4135
14
    { &hf_vnc_pointer_y_pos,
4136
14
      { "Y position", "vnc.pointer_y_pos",
4137
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4138
14
        "Position of mouse cursor on the y-axis", HFILL }
4139
14
    },
4140
14
    { &hf_vnc_encoding_num,
4141
14
      { "Number of encodings", "vnc.client_set_encodings_num",
4142
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4143
14
        "Number of encodings used to send pixel data from server to client", HFILL }
4144
14
    },
4145
14
    { &hf_vnc_client_set_encodings_encoding_type,
4146
14
      { "Encoding type", "vnc.client_set_encodings_encoding_type",
4147
14
        FT_INT32, BASE_DEC, VALS(encoding_types_vs), 0x0,
4148
14
        "Type of encoding used to send pixel data from server to client", HFILL }
4149
14
    },
4150
4151
    /* Client Framebuffer Update Request */
4152
14
    { &hf_vnc_update_req_incremental,
4153
14
      { "Incremental update", "vnc.update_req_incremental",
4154
14
        FT_BOOLEAN, BASE_NONE, NULL, 0x0,
4155
14
        "Specifies if the client wants an incremental update instead of a full one", HFILL }
4156
14
    },
4157
14
    { &hf_vnc_update_req_x_pos,
4158
14
      { "X position", "vnc.update_req_x_pos",
4159
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4160
14
        "X position of framebuffer (screen) update requested", HFILL }
4161
14
    },
4162
14
    { &hf_vnc_update_req_y_pos,
4163
14
      { "Y position", "vnc.update_req_y_pos",
4164
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4165
14
        "Y position of framebuffer (screen) update request", HFILL }
4166
14
    },
4167
14
    { &hf_vnc_update_req_width,
4168
14
      { "Width", "vnc.update_req_width",
4169
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4170
14
        "Width of framebuffer (screen) update request", HFILL }
4171
14
    },
4172
14
    { &hf_vnc_update_req_height,
4173
14
      { "Height", "vnc.update_req_height",
4174
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4175
14
        "Height of framebuffer (screen) update request", HFILL }
4176
14
    },
4177
14
    { &hf_vnc_client_cut_text_len,
4178
14
      { "Length", "vnc.client_cut_text_len",
4179
14
        FT_UINT32, BASE_DEC, NULL, 0x0,
4180
14
        "Length of client's copy/cut text (clipboard) string in bytes", HFILL }
4181
14
    },
4182
14
    { &hf_vnc_client_cut_text,
4183
14
      { "Text", "vnc.client_cut_text",
4184
14
        FT_STRING, BASE_NONE, NULL, 0x0,
4185
14
        "Text string in the client's copy/cut text (clipboard)", HFILL }
4186
14
    },
4187
4188
4189
    /********** Server Message Types **********/
4190
14
    { &hf_vnc_server_message_type,
4191
14
      { "Server Message Type", "vnc.server_message_type",
4192
14
        FT_UINT8, BASE_DEC, VALS(vnc_server_message_types_vs), 0x0,
4193
14
        "Message type from server", HFILL }
4194
14
    },
4195
4196
14
    { &hf_vnc_rectangle_num,
4197
14
      { "Number of rectangles", "vnc.fb_update_num_rects",
4198
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4199
14
        "Number of rectangles of this server framebuffer update", HFILL }
4200
14
    },
4201
4202
14
    { &hf_vnc_fb_update_x_pos,
4203
14
      { "X position", "vnc.fb_update_x_pos",
4204
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4205
14
        "X position of this server framebuffer update", HFILL }
4206
14
    },
4207
4208
14
    { &hf_vnc_fb_update_y_pos,
4209
14
      { "Y position", "vnc.fb_update_y_pos",
4210
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4211
14
        "Y position of this server framebuffer update", HFILL }
4212
14
    },
4213
4214
14
    { &hf_vnc_fb_update_width,
4215
14
      { "Width", "vnc.fb_update_width",
4216
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4217
14
        "Width of this server framebuffer update", HFILL }
4218
14
    },
4219
4220
14
    { &hf_vnc_fb_update_height,
4221
14
      { "Height", "vnc.fb_update_height",
4222
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4223
14
        "Height of this server framebuffer update", HFILL }
4224
14
    },
4225
4226
14
    { &hf_vnc_fb_update_encoding_type,
4227
14
      { "Encoding type", "vnc.fb_update_encoding_type",
4228
14
        FT_INT32, BASE_DEC, VALS(encoding_types_vs), 0x0,
4229
14
        "Encoding type of this server framebuffer update", HFILL }
4230
14
    },
4231
4232
    /* Cursor encoding */
4233
14
    { &hf_vnc_cursor_x_fore_back,
4234
14
      { "X Cursor foreground RGB / background RGB", "vnc.cursor_x_fore_back",
4235
14
        FT_BYTES, BASE_NONE, NULL, 0x0,
4236
14
        "RGB values for the X cursor's foreground and background", HFILL }
4237
14
    },
4238
4239
14
    { &hf_vnc_cursor_encoding_pixels,
4240
14
      { "Cursor encoding pixels", "vnc.cursor_encoding_pixels",
4241
14
        FT_BYTES, BASE_NONE, NULL, 0x0,
4242
14
        "Cursor encoding pixel data", HFILL }
4243
14
    },
4244
4245
14
    { &hf_vnc_cursor_encoding_bitmask,
4246
14
      { "Cursor encoding bitmask", "vnc.cursor_encoding_bitmask",
4247
14
        FT_BYTES, BASE_NONE, NULL, 0x0,
4248
14
        "Cursor encoding pixel bitmask", HFILL }
4249
14
    },
4250
4251
    /* Raw Encoding */
4252
14
    { &hf_vnc_raw_pixel_data,
4253
14
      { "Pixel data", "vnc.raw_pixel_data",
4254
14
        FT_BYTES, BASE_NONE, NULL, 0x0,
4255
14
        "Raw pixel data.", HFILL }
4256
14
    },
4257
4258
    /* CopyRect Encoding*/
4259
14
    { &hf_vnc_copyrect_src_x_pos,
4260
14
      { "Source x position", "vnc.copyrect_src_x_pos",
4261
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4262
14
        "X position of the rectangle to copy from", HFILL }
4263
14
    },
4264
4265
14
    { &hf_vnc_copyrect_src_y_pos,
4266
14
      { "Source y position", "vnc.copyrect_src_y_pos",
4267
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4268
14
        "Y position of the rectangle to copy from", HFILL }
4269
14
    },
4270
4271
    /* RRE Encoding */
4272
14
    { &hf_vnc_rre_num_subrects,
4273
14
      { "Number of subrectangles", "vnc.rre_num_subrects",
4274
14
        FT_UINT32, BASE_DEC, NULL, 0x0,
4275
14
        "Number of subrectangles contained in this encoding type", HFILL }
4276
14
    },
4277
4278
14
    { &hf_vnc_rre_bg_pixel,
4279
14
      { "Background pixel value", "vnc.rre_bg_pixel",
4280
14
        FT_BYTES, BASE_NONE, NULL, 0x0,
4281
14
        NULL, HFILL }
4282
14
    },
4283
4284
14
    { &hf_vnc_rre_subrect_pixel,
4285
14
      { "Pixel value", "vnc.rre_subrect_pixel",
4286
14
        FT_BYTES, BASE_NONE, NULL, 0x0,
4287
14
        "Subrectangle pixel value", HFILL }
4288
14
    },
4289
4290
14
    { &hf_vnc_rre_subrect_x_pos,
4291
14
      { "X position", "vnc.rre_subrect_x_pos",
4292
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4293
14
        "Position of this subrectangle on the x axis", HFILL }
4294
14
    },
4295
4296
14
    { &hf_vnc_rre_subrect_y_pos,
4297
14
      { "Y position", "vnc.rre_subrect_y_pos",
4298
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4299
14
        "Position of this subrectangle on the y axis", HFILL }
4300
14
    },
4301
4302
14
    { &hf_vnc_rre_subrect_width,
4303
14
      { "Width", "vnc.rre_subrect_width",
4304
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4305
14
        "Width of this subrectangle", HFILL }
4306
14
    },
4307
4308
14
    { &hf_vnc_rre_subrect_height,
4309
14
      { "Height", "vnc.rre_subrect_height",
4310
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4311
14
        "Height of this subrectangle", HFILL }
4312
14
    },
4313
4314
4315
    /* Hextile Encoding */
4316
14
    { &hf_vnc_hextile_subencoding_mask,
4317
14
      { "Subencoding type", "vnc.hextile_subencoding",
4318
14
        FT_UINT8, BASE_DEC, NULL, 0x0,
4319
14
        "Hextile subencoding type.", HFILL }
4320
14
    },
4321
4322
14
    { &hf_vnc_hextile_raw,
4323
14
      { "Raw", "vnc.hextile_raw",
4324
14
        FT_BOOLEAN, 8, TFS(&tfs_yes_no), 0x1,
4325
14
        "Raw subencoding is used in this tile", HFILL }
4326
14
    },
4327
4328
14
    { &hf_vnc_hextile_raw_value,
4329
14
      { "Raw pixel values", "vnc.hextile_raw_value",
4330
14
        FT_BYTES, BASE_NONE, NULL, 0x0,
4331
14
        "Raw subencoding pixel values", HFILL }
4332
14
    },
4333
4334
14
    { &hf_vnc_hextile_bg,
4335
14
      { "Background Specified", "vnc.hextile_bg",
4336
14
        FT_BOOLEAN, 8, TFS(&tfs_yes_no), 0x2,
4337
14
        "Background Specified subencoding is used in this tile", HFILL }
4338
14
    },
4339
4340
14
    { &hf_vnc_hextile_bg_value,
4341
14
      { "Background pixel value", "vnc.hextile_bg_value",
4342
14
        FT_BYTES, BASE_NONE, NULL, 0x0,
4343
14
        "Background color for this tile", HFILL }
4344
14
    },
4345
4346
14
    { &hf_vnc_hextile_fg,
4347
14
      { "Foreground Specified", "vnc.hextile_fg",
4348
14
        FT_BOOLEAN, 8, TFS(&tfs_yes_no), 0x4,
4349
14
        "Foreground Specified subencoding is used in this tile", HFILL }
4350
14
    },
4351
4352
14
    { &hf_vnc_hextile_fg_value,
4353
14
      { "Foreground pixel value", "vnc.hextile_fg_value",
4354
14
        FT_BYTES, BASE_NONE, NULL, 0x0,
4355
14
        "Foreground color for this tile", HFILL }
4356
14
    },
4357
4358
14
    { &hf_vnc_hextile_anysubrects,
4359
14
      { "Any Subrects", "vnc.hextile_anysubrects",
4360
14
        FT_BOOLEAN, 8, TFS(&tfs_yes_no), 0x8,
4361
14
        "Any subrects subencoding is used in this tile", HFILL }
4362
14
    },
4363
4364
14
    { &hf_vnc_hextile_num_subrects,
4365
14
      { "Number of subrectangles", "vnc.hextile_num_subrects",
4366
14
        FT_UINT8, BASE_DEC, NULL, 0x0,
4367
14
        "Number of subrectangles that follow", HFILL }
4368
14
    },
4369
4370
14
    { &hf_vnc_hextile_subrectscolored,
4371
14
      { "Subrects Colored", "vnc.hextile_subrectscolored",
4372
14
        FT_BOOLEAN, 8, TFS(&tfs_yes_no), 0x10,
4373
14
        "Subrects colored subencoding is used in this tile", HFILL }
4374
14
    },
4375
4376
14
    { &hf_vnc_hextile_subrect_pixel_value,
4377
14
      { "Pixel value", "vnc.hextile_subrect_pixel_value",
4378
14
        FT_BYTES, BASE_NONE, NULL, 0x0,
4379
14
        "Pixel value of this subrectangle", HFILL }
4380
14
    },
4381
4382
14
    { &hf_vnc_hextile_subrect_x_pos,
4383
14
      { "X position", "vnc.hextile_subrect_x_pos",
4384
14
        FT_UINT8, BASE_DEC, NULL, 0xF0, /* Top 4 bits */
4385
14
        "X position of this subrectangle", HFILL }
4386
14
    },
4387
4388
14
    { &hf_vnc_hextile_subrect_y_pos,
4389
14
      { "Y position", "vnc.hextile_subrect_y_pos",
4390
14
        FT_UINT8, BASE_DEC, NULL, 0xF, /* Bottom 4 bits */
4391
14
        "Y position of this subrectangle", HFILL }
4392
14
    },
4393
4394
14
    { &hf_vnc_hextile_subrect_width,
4395
14
      { "Width", "vnc.hextile_subrect_width",
4396
14
        FT_UINT8, BASE_DEC, NULL, 0xF0, /* Top 4 bits */
4397
14
        "Subrectangle width minus one", HFILL }
4398
14
    },
4399
4400
14
    { &hf_vnc_hextile_subrect_height,
4401
14
      { "Height", "vnc.hextile_subrect_height",
4402
14
        FT_UINT8, BASE_DEC, NULL, 0xF, /* Bottom 4 bits */
4403
14
        "Subrectangle height minus one", HFILL }
4404
14
    },
4405
4406
4407
    /* ZRLE Encoding */
4408
14
    { &hf_vnc_zrle_len,
4409
14
      { "ZRLE compressed length", "vnc.zrle_len",
4410
14
        FT_UINT32, BASE_DEC, NULL, 0x0,
4411
14
        "Length of compressed ZRLE data that follows", HFILL }
4412
14
    },
4413
4414
14
    { &hf_vnc_zrle_subencoding,
4415
14
      { "Subencoding type", "vnc.zrle_subencoding",
4416
14
        FT_UINT8, BASE_DEC, NULL, 0x0,
4417
14
        "Subencoding type byte", HFILL }
4418
14
    },
4419
4420
14
    { &hf_vnc_zrle_rle,
4421
14
      { "RLE", "vnc.zrle_rle",
4422
14
        FT_BOOLEAN, 8, TFS(&tfs_yes_no), 0x80, /* Upper bit */
4423
14
        "Specifies that data is run-length encoded", HFILL }
4424
14
    },
4425
4426
14
    { &hf_vnc_zrle_palette_size,
4427
14
      { "Palette size", "vnc.zrle_palette_size",
4428
14
        FT_UINT8, BASE_DEC, NULL, 0x7F, /* Lower 7 bits */
4429
14
        NULL, HFILL }
4430
14
    },
4431
4432
14
    { &hf_vnc_zrle_data,
4433
14
      { "ZRLE compressed data", "vnc.zrle_data",
4434
14
        FT_BYTES, BASE_NONE, NULL, 0x0,
4435
14
        "Compressed ZRLE data.  Compiling with zlib support will uncompress and dissect this data", HFILL }
4436
14
    },
4437
4438
14
    { &hf_vnc_zrle_raw,
4439
14
      { "Pixel values", "vnc.zrle_raw",
4440
14
        FT_BYTES, BASE_NONE, NULL, 0x0,
4441
14
        "Raw pixel values for this tile", HFILL }
4442
14
    },
4443
4444
14
    { &hf_vnc_zrle_palette,
4445
14
      { "Palette", "vnc.zrle_palette",
4446
14
        FT_BYTES, BASE_NONE, NULL, 0x0,
4447
14
        "Palette pixel values", HFILL }
4448
14
    },
4449
4450
    /* Server Set Colormap Entries */
4451
14
    { &hf_vnc_colormap_first_color,
4452
14
      { "First color", "vnc.colormap_first_color",
4453
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4454
14
        "First color that should be mapped to given RGB intensities", HFILL }
4455
14
    },
4456
4457
14
    { &hf_vnc_color_groups,
4458
14
      { "Color groups", "vnc.color_groups",
4459
14
        FT_NONE, BASE_NONE, NULL, 0x0,
4460
14
        NULL, HFILL }
4461
14
    },
4462
4463
14
    { &hf_vnc_colormap_num_colors,
4464
14
      { "Number of color groups", "vnc.colormap_groups",
4465
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4466
14
        "Number of red/green/blue color groups", HFILL }
4467
14
    },
4468
14
    { &hf_vnc_colormap_red,
4469
14
      { "Red", "vnc.colormap_red",
4470
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4471
14
        "Red intensity", HFILL }
4472
14
    },
4473
14
    { &hf_vnc_colormap_green,
4474
14
      { "Green", "vnc.colormap_green",
4475
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4476
14
        "Green intensity", HFILL }
4477
14
    },
4478
14
    { &hf_vnc_colormap_blue,
4479
14
      { "Blue", "vnc.colormap_blue",
4480
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4481
14
        "Blue intensity", HFILL }
4482
14
    },
4483
4484
    /* Server Cut Text */
4485
14
    { &hf_vnc_server_cut_text_len,
4486
14
      { "Length", "vnc.server_cut_text_len",
4487
14
        FT_UINT32, BASE_DEC, NULL, 0x0,
4488
14
        "Length of server's copy/cut text (clipboard) string in bytes", HFILL }
4489
14
    },
4490
14
    { &hf_vnc_server_cut_text,
4491
14
      { "Text", "vnc.server_cut_text",
4492
14
        FT_STRING, BASE_NONE, NULL, 0x0,
4493
14
        "Text string in the server's copy/cut text (clipboard)", HFILL }
4494
14
    },
4495
4496
    /* LibVNCServer additions */
4497
14
    { &hf_vnc_supported_messages_client2server,
4498
14
      { "Client2server", "vnc.supported_messages_client2server",
4499
14
        FT_BYTES, BASE_NONE, NULL, 0x0,
4500
14
        "Supported client to server messages (bit flags)", HFILL }
4501
14
    },
4502
14
    { &hf_vnc_supported_messages_server2client,
4503
14
      { "Server2client", "vnc.supported_messages_server2client",
4504
14
        FT_BYTES, BASE_NONE, NULL, 0x0,
4505
14
        "Supported server to client messages (bit flags)", HFILL }
4506
14
    },
4507
14
    { &hf_vnc_num_supported_encodings,
4508
14
      { "Number of supported encodings", "vnc.num_supported_encodings",
4509
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4510
14
        NULL, HFILL }
4511
14
    },
4512
14
    { &hf_vnc_supported_encodings,
4513
14
      { "Encoding", "vnc.supported_encodings",
4514
14
        FT_UINT32, BASE_HEX, NULL, 0x0,
4515
14
        "Supported encoding", HFILL }
4516
14
    },
4517
14
    { &hf_vnc_server_identity,
4518
14
      { "Server Identity", "vnc.server_identity",
4519
14
        FT_STRING, BASE_NONE, NULL, 0x0,
4520
14
        "Server identity string", HFILL }
4521
14
    },
4522
4523
    /* MirrorLink */
4524
14
    { &hf_vnc_mirrorlink_type,
4525
14
      { "Type", "vnc.mirrorlink_type",
4526
14
        FT_UINT8, BASE_DEC, VALS(vnc_mirrorlink_types_vs), 0x0,
4527
14
        "MirrorLink extension message type", HFILL }
4528
14
    },
4529
14
    { &hf_vnc_mirrorlink_length,
4530
14
      { "Length", "vnc.mirrorlink_length",
4531
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4532
14
        "Payload length", HFILL }
4533
14
    },
4534
14
    { &hf_vnc_mirrorlink_version_major,
4535
14
      { "Major Version", "vnc.mirrorlink_version_major",
4536
14
        FT_UINT8, BASE_DEC, NULL, 0x0,
4537
14
        "MirrorLink major version", HFILL }
4538
14
    },
4539
14
    { &hf_vnc_mirrorlink_version_minor,
4540
14
      { "Minor Version", "vnc.mirrorlink_version_minor",
4541
14
        FT_UINT8, BASE_DEC, NULL, 0x0,
4542
14
        "MirrorLink minor version", HFILL }
4543
14
    },
4544
14
    { &hf_vnc_mirrorlink_framebuffer_configuration,
4545
14
      { "Configuration",
4546
14
        "vnc.mirrorlink_framebuffer_configuration",
4547
14
        FT_UINT16, BASE_HEX, NULL, 0x0,
4548
14
        "Framebuffer configuration", HFILL }
4549
14
    },
4550
14
    { &hf_vnc_mirrorlink_pixel_width,
4551
14
      { "Pixel Width", "vnc.mirrorlink_pixel_width",
4552
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4553
14
        "Display width [pixel]", HFILL }
4554
14
    },
4555
14
    { &hf_vnc_mirrorlink_pixel_height,
4556
14
      { "Pixel Height", "vnc.mirrorlink_pixel_height",
4557
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4558
14
        "Display height [pixel]", HFILL }
4559
14
    },
4560
14
    { &hf_vnc_mirrorlink_pixel_format,
4561
14
      { "Pixel Format", "vnc.mirrorlink_pixel_format",
4562
14
        FT_UINT32, BASE_HEX, NULL, 0x0,
4563
14
        "Pixel format support", HFILL }
4564
14
    },
4565
14
    { &hf_vnc_mirrorlink_display_width,
4566
14
      { "Display Width", "vnc.mirrorlink_display_width",
4567
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4568
14
        "Display width [mm]", HFILL }
4569
14
    },
4570
14
    { &hf_vnc_mirrorlink_display_height,
4571
14
      { "Display Height", "vnc.mirrorlink_display_height",
4572
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4573
14
        "Display height [mm]", HFILL }
4574
14
    },
4575
14
    { &hf_vnc_mirrorlink_display_distance,
4576
14
      { "Display Distance", "vnc.mirrorlink_display_distance",
4577
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4578
14
        "Display distance [mm]", HFILL }
4579
14
    },
4580
14
    { &hf_vnc_mirrorlink_keyboard_language,
4581
14
      { "Keyboard Language", "vnc.mirrorlink_keyboard_language",
4582
14
        FT_STRING, BASE_NONE, NULL, 0x0,
4583
14
        "Keyboard layout - Language code (according ISO 639-1)",
4584
14
        HFILL }
4585
14
    },
4586
14
    { &hf_vnc_mirrorlink_keyboard_country,
4587
14
      { "Keyboard Country", "vnc.mirrorlink_keyboard_country",
4588
14
        FT_STRING, BASE_NONE, NULL, 0x0,
4589
14
        "Keyboard layout - Country code (according ISO 3166-1 alpha-2)",
4590
14
        HFILL }
4591
14
    },
4592
14
    { &hf_vnc_mirrorlink_ui_language,
4593
14
      { "UI Language", "vnc.mirrorlink_ui_language",
4594
14
        FT_STRING, BASE_NONE, NULL, 0x0,
4595
14
        "UI language - Language code (according ISO 639-1)", HFILL }
4596
14
    },
4597
14
    { &hf_vnc_mirrorlink_ui_country,
4598
14
      { "UI Country", "vnc.mirrorlink_ui_country",
4599
14
        FT_STRING, BASE_NONE, NULL, 0x0,
4600
14
        "UI language - Country code (according ISO 3166-1 alpha 2)",
4601
14
        HFILL }
4602
14
    },
4603
14
    { &hf_vnc_mirrorlink_knob_keys,
4604
14
      { "Knob Keys", "vnc.mirrorlink_knob_keys",
4605
14
        FT_UINT32, BASE_HEX, NULL, 0x0,
4606
14
        "Supported knob keys", HFILL }
4607
14
    },
4608
14
    { &hf_vnc_mirrorlink_device_keys,
4609
14
      { "Device Keys", "vnc.mirrorlink_device_keys",
4610
14
        FT_UINT32, BASE_HEX, NULL, 0x0,
4611
14
        "Supported device keys", HFILL }
4612
14
    },
4613
14
    { &hf_vnc_mirrorlink_multimedia_keys,
4614
14
      { "Multimedia Keys", "vnc.mirrorlink_multimedia_keys",
4615
14
        FT_UINT32, BASE_HEX, NULL, 0x0,
4616
14
        "Supported multimedia keys", HFILL }
4617
14
    },
4618
14
    { &hf_vnc_mirrorlink_key_related,
4619
14
      { "Keyboard", "vnc.mirrorlink_key_related",
4620
14
        FT_UINT32, BASE_HEX, NULL, 0x0,
4621
14
        "Keyboard related", HFILL }
4622
14
    },
4623
14
    { &hf_vnc_mirrorlink_pointer_related,
4624
14
      { "Pointer", "vnc.mirrorlink_pointer_related",
4625
14
        FT_UINT32, BASE_HEX, NULL, 0x0,
4626
14
        "Pointer related", HFILL }
4627
14
    },
4628
14
    { &hf_vnc_mirrorlink_key_symbol_value_client,
4629
14
      { "Client KeySymValue",
4630
14
        "vnc.mirrorlink_key_symbol_value_client",
4631
14
        FT_UINT32, BASE_HEX, NULL, 0x0,
4632
14
        "Client key symbol value", HFILL }
4633
14
    },
4634
14
    { &hf_vnc_mirrorlink_key_symbol_value_server,
4635
14
      { "Server KeySymValue",
4636
14
        "vnc.mirrorlink_key_symbol_value_server",
4637
14
        FT_UINT32, BASE_HEX, NULL, 0x0,
4638
14
        "Server key symbol value", HFILL }
4639
14
    },
4640
14
    { &hf_vnc_mirrorlink_key_configuration,
4641
14
      { "Configuration", "vnc.mirrorlink_key_configuration",
4642
14
        FT_UINT8, BASE_HEX, NULL, 0x0,
4643
14
        "Key event listing configuration", HFILL }
4644
14
    },
4645
14
    { &hf_vnc_mirrorlink_key_num_events,
4646
14
      { "Number of Key Events", "vnc.mirrorlink_key_num_events",
4647
14
        FT_UINT8, BASE_DEC, NULL, 0x0,
4648
14
        "Number of key events in list", HFILL }
4649
14
    },
4650
14
    { &hf_vnc_mirrorlink_key_event_counter,
4651
14
      { "Key Event Counter", "vnc.mirrorlink_key_event_counter",
4652
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4653
14
        "Key event listing counter", HFILL }
4654
14
    },
4655
14
    { &hf_vnc_mirrorlink_key_symbol_value,
4656
14
      { "KeySymValue",
4657
14
        "vnc.mirrorlink_key_symbol_value",
4658
14
        FT_UINT32, BASE_HEX, NULL, 0x0,
4659
14
        "Key symbol value", HFILL }
4660
14
    },
4661
14
    { &hf_vnc_mirrorlink_key_request_configuration,
4662
14
      { "Configuration", "vnc.mirrorlink_key_request_configuration",
4663
14
        FT_UINT32, BASE_HEX, NULL, 0x0,
4664
14
        "Key event listing request configuration", HFILL }
4665
14
    },
4666
14
    { &hf_vnc_mirrorlink_keyboard_configuration,
4667
14
      { "Configuration", "vnc.mirrorlink_keyboard_configuration",
4668
14
        FT_UINT32, BASE_HEX, NULL, 0x0,
4669
14
        "Virtual keyboard configuration", HFILL }
4670
14
    },
4671
14
    { &hf_vnc_mirrorlink_cursor_x,
4672
14
      { "Cursor X", "vnc.mirrorlink_cursor_x",
4673
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4674
14
        "Cursor - X position", HFILL }
4675
14
    },
4676
14
    { &hf_vnc_mirrorlink_cursor_y,
4677
14
      { "Cursor Y", "vnc.mirrorlink_cursor_y",
4678
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4679
14
        "Cursor - Y position", HFILL }
4680
14
    },
4681
14
    { &hf_vnc_mirrorlink_text_x,
4682
14
      { "Text X", "vnc.mirrorlink_text_x",
4683
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4684
14
        "Text input area - X position", HFILL }
4685
14
    },
4686
14
    { &hf_vnc_mirrorlink_text_y,
4687
14
      { "Text Y", "vnc.mirrorlink_text_y",
4688
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4689
14
        "Text input area - Y position", HFILL }
4690
14
    },
4691
14
    { &hf_vnc_mirrorlink_text_width,
4692
14
      { "Text Width", "vnc.mirrorlink_text_width",
4693
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4694
14
        "Text input area - Width", HFILL }
4695
14
    },
4696
14
    { &hf_vnc_mirrorlink_text_height,
4697
14
      { "Text Height", "vnc.mirrorlink_text_height",
4698
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4699
14
        "Text input area - Height", HFILL }
4700
14
    },
4701
14
    { &hf_vnc_mirrorlink_keyboard_request_configuration,
4702
14
      { "Configuration",
4703
14
        "vnc.mirrorlink_keyboard_request_configuration",
4704
14
        FT_UINT32, BASE_HEX, NULL, 0x0,
4705
14
        "Virtual keyboard request configuration", HFILL }
4706
14
    },
4707
14
    { &hf_vnc_mirrorlink_device_status,
4708
14
      { "Device Status", "vnc.mirrorlink_device_status",
4709
14
        FT_UINT32, BASE_HEX, NULL, 0x0,
4710
14
        "Status of Device Features", HFILL }
4711
14
    },
4712
14
    { &hf_vnc_mirrorlink_app_id,
4713
14
      { "App Id", "vnc.mirrorlink_app_id",
4714
14
        FT_UINT32, BASE_HEX, NULL, 0x0,
4715
14
        "Unique application id", HFILL }
4716
14
    },
4717
14
    { &hf_vnc_mirrorlink_fb_block_x,
4718
14
      { "Framebuffer X", "vnc.mirrorlink_fb_block_x",
4719
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4720
14
        "Framebuffer blocking - X position", HFILL }
4721
14
    },
4722
14
    { &hf_vnc_mirrorlink_fb_block_y,
4723
14
      { "Framebuffer Y", "vnc.mirrorlink_fb_block_y",
4724
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4725
14
        "Framdbuffer blocking - Y position", HFILL }
4726
14
    },
4727
14
    { &hf_vnc_mirrorlink_fb_block_width,
4728
14
      { "Framebuffer Width", "vnc.mirrorlink_fb_block_width",
4729
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4730
14
        "Framebuffer blocking - Width", HFILL }
4731
14
    },
4732
14
    { &hf_vnc_mirrorlink_fb_block_height,
4733
14
      { "Framebuffer Height", "vnc.mirrorlink_fb_block_height",
4734
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4735
14
        "Framebuffer blocking - Height", HFILL }
4736
14
    },
4737
14
    { &hf_vnc_mirrorlink_fb_block_reason,
4738
14
      { "Reason", "vnc.mirrorlink_fb_block_reason",
4739
14
        FT_UINT16, BASE_HEX, NULL, 0x0,
4740
14
        "Reason for blocking", HFILL }
4741
14
    },
4742
14
    { &hf_vnc_mirrorlink_audio_block_reason,
4743
14
      { "Reason", "vnc.mirrorlink_audio_block_reason",
4744
14
        FT_UINT16, BASE_HEX, NULL, 0x0,
4745
14
        "Reason for blocking", HFILL }
4746
14
    },
4747
14
    { &hf_vnc_mirrorlink_touch_num_events,
4748
14
      { "Number of Touch Events", "vnc.mirrorlink_touch_num_events",
4749
14
        FT_UINT8, BASE_DEC, NULL, 0x0,
4750
14
        "Number of touch events in list", HFILL }
4751
14
    },
4752
14
    { &hf_vnc_mirrorlink_touch_x,
4753
14
      { "Touch X", "vnc.mirrorlink_touch_x",
4754
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4755
14
        "Touch event - X position", HFILL }
4756
14
    },
4757
14
    { &hf_vnc_mirrorlink_touch_y,
4758
14
      { "Touch Y", "vnc.mirrorlink_touch_y",
4759
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4760
14
        "Touch event - Y position", HFILL }
4761
14
    },
4762
14
    { &hf_vnc_mirrorlink_touch_id,
4763
14
      { "Touch Id", "vnc.mirrorlink_touch_id",
4764
14
        FT_UINT8, BASE_DEC, NULL, 0x0,
4765
14
        "Touch event - identifier", HFILL }
4766
14
    },
4767
14
    { &hf_vnc_mirrorlink_touch_pressure,
4768
14
      { "Touch Pressure", "vnc.mirrorlink_touch_pressure",
4769
14
        FT_UINT8, BASE_DEC, NULL, 0x0,
4770
14
        "Touch event - pressure value", HFILL }
4771
14
    },
4772
14
    { &hf_vnc_mirrorlink_text,
4773
14
      { "Text", "vnc.mirrorlink_text",
4774
14
        FT_STRING, BASE_NONE, NULL, 0x0,
4775
14
        "Textual information", HFILL }
4776
14
    },
4777
14
    { &hf_vnc_mirrorlink_text_length,
4778
14
      { "Length", "vnc.mirrorlink_text_length",
4779
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4780
14
        "Length of textual information", HFILL }
4781
14
    },
4782
14
    { &hf_vnc_mirrorlink_text_max_length,
4783
14
      { "Max Length", "vnc.mirrorlink_text_max_length",
4784
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4785
14
        "Maximum length of textual information", HFILL }
4786
14
    },
4787
14
    { &hf_vnc_mirrorlink_unknown,
4788
14
      { "Unknown", "vnc.mirrorlink_unknown",
4789
14
        FT_BYTES, BASE_NONE, NULL, 0x0,
4790
14
        "Unknown data", HFILL }
4791
14
    },
4792
4793
    /* Fence */
4794
14
    { &hf_vnc_fence_flags,
4795
14
      {"Fence flags", "vnc.fence_flags", FT_UINT32, BASE_HEX,
4796
14
       NULL, 0, NULL, HFILL}},
4797
4798
14
    { &hf_vnc_fence_request,
4799
14
      { "Fence_request", "vnc.fence_request",
4800
14
        FT_BOOLEAN, 32, NULL, VNC_FENCE_REQUEST,
4801
14
        NULL, HFILL }
4802
14
    },
4803
14
    { &hf_vnc_fence_sync_next,
4804
14
      { "Fence_sync_next", "vnc.fence_sync_next",
4805
14
        FT_BOOLEAN, 32, NULL, VNC_FENCE_SYNC_NEXT,
4806
14
        NULL, HFILL }
4807
14
    },
4808
14
    { &hf_vnc_fence_block_after,
4809
14
      { "Fence_block_after", "vnc.fence_block_after",
4810
14
        FT_BOOLEAN, 32, NULL, VNC_FENCE_BLOCK_AFTER,
4811
14
        NULL, HFILL }
4812
14
    },
4813
14
    { &hf_vnc_fence_block_before,
4814
14
      { "Fence block_before", "vnc.fence_block_before",
4815
14
        FT_BOOLEAN, 32, NULL, VNC_FENCE_BLOCK_BEFORE,
4816
14
        NULL, HFILL }
4817
14
    },
4818
14
    { &hf_vnc_fence_payload_length,
4819
14
      { "Fence payload length", "vnc.fence_payload_length",
4820
14
        FT_UINT8, BASE_DEC, NULL, 0x0,
4821
14
        NULL, HFILL }
4822
14
    },
4823
14
    { &hf_vnc_fence_payload,
4824
14
      { "Fence payload", "vnc.fence_payload",
4825
14
        FT_BYTES, BASE_NONE, NULL, 0x0,
4826
14
        NULL, HFILL }
4827
14
    },
4828
4829
    /* Context Information */
4830
14
    { &hf_vnc_context_information_app_id,
4831
14
      { "App Id", "vnc.context_information_app_id",
4832
14
        FT_UINT32, BASE_HEX, NULL, 0x0,
4833
14
        "Unique application id", HFILL }
4834
14
    },
4835
14
    { &hf_vnc_context_information_app_trust_level,
4836
14
      { "App Trust Level",
4837
14
        "vnc.context_information_app_trust_level",
4838
14
        FT_UINT16, BASE_HEX, NULL, 0x0,
4839
14
        "Trust Level for Application Category", HFILL }
4840
14
    },
4841
14
    { &hf_vnc_context_information_content_trust_level,
4842
14
      { "Content Trust Level",
4843
14
        "vnc.context_information_content_trust_level",
4844
14
        FT_UINT16, BASE_HEX, NULL, 0x0,
4845
14
        "Trust Level for Content Category", HFILL }
4846
14
    },
4847
14
    { &hf_vnc_context_information_app_category,
4848
14
      { "App Category", "vnc.context_information_app_category",
4849
14
        FT_UINT32, BASE_HEX, NULL, 0x0,
4850
14
        "Application Category", HFILL }
4851
14
    },
4852
14
    { &hf_vnc_context_information_content_category,
4853
14
      { "Content Category",
4854
14
        "vnc.context_information_content_category",
4855
14
        FT_UINT32, BASE_HEX, NULL, 0x0,
4856
14
        "Visual content category", HFILL }
4857
14
    },
4858
14
    { &hf_vnc_context_information_content_rules,
4859
14
      { "Content Rules", "vnc.context_information_content_rules",
4860
14
        FT_UINT32, BASE_HEX, NULL, 0x0,
4861
14
        "Visual content rules", HFILL }
4862
14
    },
4863
4864
    /* Scan Line based Run-Length Encoding */
4865
14
    { &hf_vnc_slrle_run_num,
4866
14
      { "Number of Runs", "vnc.slrle_run_num",
4867
14
        FT_UINT16, BASE_DEC, NULL, 0x0,
4868
14
        "Number of Runs within Line", HFILL }
4869
14
    },
4870
14
    { &hf_vnc_slrle_run_data,
4871
14
      { "Raw RLE data", "vnc.slrle_run_data",
4872
14
        FT_BYTES, BASE_NONE, NULL, 0x0,
4873
14
        "Raw Run-Length encoded data within Line", HFILL }
4874
14
    },
4875
4876
    /* H.264 Encoding */
4877
14
    { &hf_vnc_h264_slice_type,
4878
14
      { "Slice Type", "vnc.h264_slice_type",
4879
14
        FT_UINT32, BASE_DEC, VALS(vnc_h264_slice_types_vs), 0x0,
4880
14
        "Frame slice type", HFILL }
4881
14
    },
4882
14
    { &hf_vnc_h264_nbytes,
4883
14
      { "Number of Bytes", "vnc.h264_nbytes",
4884
14
        FT_UINT32, BASE_DEC, NULL, 0x0,
4885
14
        "Number of bytes within frame", HFILL }
4886
14
    },
4887
14
    { &hf_vnc_h264_width,
4888
14
      { "Width", "vnc.h264_width",
4889
14
        FT_UINT32, BASE_DEC, NULL, 0x0,
4890
14
        "Frame Width", HFILL }
4891
14
    },
4892
14
    { &hf_vnc_h264_height,
4893
14
      { "Height", "vnc.h264_height",
4894
14
        FT_UINT32, BASE_DEC, NULL, 0x0,
4895
14
        "Frame Height", HFILL }
4896
14
    },
4897
14
    { &hf_vnc_h264_data,
4898
14
      { "Data", "vnc.h264_data",
4899
14
        FT_BYTES, BASE_NONE, NULL, 0x0,
4900
14
        "Frame H.264 data", HFILL }
4901
14
    },
4902
4903
14
  };
4904
4905
  /* Setup protocol subtree arrays */
4906
14
  static int *ett[] = {
4907
14
    &ett_vnc,
4908
14
    &ett_vnc_client_message_type,
4909
14
    &ett_vnc_server_message_type,
4910
14
    &ett_vnc_rect,
4911
14
    &ett_vnc_encoding_type,
4912
14
    &ett_vnc_rre_subrect,
4913
14
    &ett_vnc_hextile_subencoding_mask,
4914
14
    &ett_vnc_hextile_num_subrects,
4915
14
    &ett_vnc_hextile_subrect,
4916
14
    &ett_vnc_hextile_tile,
4917
14
    &ett_vnc_zrle_subencoding,
4918
14
    &ett_vnc_colormap_num_groups,
4919
14
    &ett_vnc_desktop_screen,
4920
14
    &ett_vnc_colormap_color_group,
4921
14
    &ett_vnc_key_events,
4922
14
    &ett_vnc_touch_events,
4923
14
    &ett_vnc_slrle_subline,
4924
14
    &ett_vnc_fence_flags
4925
14
  };
4926
4927
14
  static ei_register_info ei[] = {
4928
14
    { &ei_vnc_possible_gtk_vnc_bug, { "vnc.possible_gtk_vnc_bug", PI_MALFORMED, PI_ERROR, "NULL found in greeting. client -> server greeting must be 12 bytes (possible gtk-vnc bug)", EXPFILL }},
4929
14
    { &ei_vnc_auth_code_mismatch, { "vnc.auth_code_mismatch", PI_PROTOCOL, PI_WARN, "Authentication code does not match vendor or signature", EXPFILL }},
4930
14
    { &ei_vnc_unknown_tight_vnc_auth, { "vnc.unknown_tight_vnc_auth", PI_PROTOCOL, PI_ERROR, "Unknown TIGHT VNC authentication", EXPFILL }},
4931
14
    { &ei_vnc_too_many_rectangles, { "vnc.too_many_rectangles", PI_MALFORMED, PI_ERROR, "Too many rectangles, aborting dissection", EXPFILL }},
4932
14
    { &ei_vnc_too_many_sub_rectangles, { "vnc.too_many_sub_rectangles", PI_MALFORMED, PI_ERROR, "Too many sub-rectangles, aborting dissection", EXPFILL }},
4933
14
    { &ei_vnc_invalid_encoding, { "vnc.invalid_encoding", PI_MALFORMED, PI_ERROR, "Invalid encoding", EXPFILL }},
4934
14
    { &ei_vnc_too_many_colors, { "vnc.too_many_colors", PI_MALFORMED, PI_ERROR, "Too many colors, aborting dissection", EXPFILL }},
4935
14
    { &ei_vnc_too_many_cut_text, { "vnc.too_many_cut_text", PI_MALFORMED, PI_ERROR, "Too much cut text, aborting dissection", EXPFILL }},
4936
14
    { &ei_vnc_zrle_failed, { "vnc.zrle_failed", PI_UNDECODED, PI_ERROR, "Decompression of ZRLE data failed", EXPFILL }},
4937
14
    { &ei_vnc_unknown_tight, { "vnc.unknown_tight_packet", PI_UNDECODED, PI_WARN, "Unknown packet (TightVNC)", EXPFILL }},
4938
14
    { &ei_vnc_reassemble, { "vnc.reassemble", PI_REASSEMBLE, PI_CHAT, "See further on for dissection of the complete (reassembled) PDU", EXPFILL }},
4939
14
  };
4940
4941
  /* Register the protocol name and description */
4942
14
  proto_vnc = proto_register_protocol("Virtual Network Computing", "VNC", "vnc");
4943
14
  vnc_handle = register_dissector("vnc", dissect_vnc, proto_vnc);
4944
4945
  /* Required function calls to register the header fields and subtrees */
4946
14
  proto_register_field_array(proto_vnc, hf, array_length(hf));
4947
14
  proto_register_subtree_array(ett, array_length(ett));
4948
14
  expert_vnc = expert_register_protocol(proto_vnc);
4949
14
  expert_register_field_array(expert_vnc, ei, array_length(ei));
4950
4951
  /* Register our preferences module */
4952
14
  vnc_module = prefs_register_protocol(proto_vnc, apply_vnc_prefs);
4953
4954
14
  prefs_register_bool_preference(vnc_module, "desegment",
4955
14
               "Reassemble VNC messages spanning multiple TCP segments.",
4956
14
               "Whether the VNC dissector should reassemble messages spanning "
4957
14
               "multiple TCP segments.  To use this option, you must also enable "
4958
14
               "\"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
4959
14
               &vnc_preference_desegment);
4960
14
}
4961
4962
void
4963
proto_reg_handoff_vnc(void)
4964
14
{
4965
14
  dissector_add_uint_range_with_preference("tcp.port", VNC_PORT_RANGE, vnc_handle);
4966
14
  heur_dissector_add("tcp", test_vnc_protocol, "VNC over TCP", "vnc_tcp", proto_vnc, HEURISTIC_ENABLE);
4967
  /* We don't register a port for the VNC HTTP server because
4968
   * that simply provides a java program for download via the
4969
   * HTTP protocol.  The java program then connects to a standard
4970
   * VNC port. */
4971
14
}
4972
4973
/*
4974
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
4975
 *
4976
 * Local variables:
4977
 * c-basic-offset: 8
4978
 * tab-width: 8
4979
 * indent-tabs-mode: t
4980
 * End:
4981
 *
4982
 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
4983
 * :indentSize=8:tabSize=8:noTabs=false:
4984
 */