Coverage Report

Created: 2026-08-14 06:45

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wireshark/epan/dissectors/packet-synergy.c
Line
Count
Source
1
/* packet-synergy.c
2
 * Routines for synergy dissection
3
 * Copyright 2005, Vasanth Manickam <vasanthm@gmail.com>
4
 *
5
 * Wireshark - Network traffic analyzer
6
 * By Gerald Combs <gerald@wireshark.org>
7
 * Copyright 1998 Gerald Combs
8
 *
9
 * SPDX-License-Identifier: GPL-2.0-or-later
10
 */
11
12
#include "config.h"
13
14
#include <epan/packet.h>
15
16
#include "packet-tcp.h"
17
18
void proto_register_synergy(void);
19
void proto_reg_handoff_synergy(void);
20
21
16
#define SYNERGY_PORT        24800 /* Not IANA registered */
22
23
static int proto_synergy;
24
25
static int hf_synergy_packet_len;
26
static int hf_synergy_packet_type;
27
28
static int hf_synergy_unknown;
29
static int hf_synergy_handshake;
30
static int hf_synergy_handshake_majorversion;
31
static int hf_synergy_handshake_minorversion;
32
static int hf_synergy_handshake_clientname;
33
34
static int hf_synergy_cbye;
35
36
static int hf_synergy_cinn;
37
static int hf_synergy_cinn_x;
38
static int hf_synergy_cinn_y;
39
static int hf_synergy_cinn_sequence;
40
static int hf_synergy_cinn_modifiermask;
41
42
static int hf_synergy_cout;
43
44
static int hf_synergy_cclp;
45
static int hf_synergy_cclp_clipboardidentifier;
46
static int hf_synergy_cclp_sequencenumber;
47
48
static int hf_synergy_csec;
49
50
static int hf_synergy_crop;
51
52
static int hf_synergy_ciak;
53
54
static int hf_synergy_dkdn;
55
static int hf_synergy_dkdn_keyid;
56
static int hf_synergy_dkdn_keymodifiermask;
57
static int hf_synergy_dkdn_keybutton;
58
59
static int hf_synergy_dkrp;
60
static int hf_synergy_dkrp_keyid;
61
static int hf_synergy_dkrp_keymodifiermask;
62
static int hf_synergy_dkrp_numberofrepeats;
63
static int hf_synergy_dkrp_keybutton;
64
65
static int hf_synergy_dkup;
66
static int hf_synergy_dkup_keyid;
67
static int hf_synergy_dkup_keymodifiermask;
68
static int hf_synergy_dkup_keybutton;
69
70
static int hf_synergy_dmdn;
71
static int hf_synergy_dmup;
72
73
static int hf_synergy_dmmv;
74
static int hf_synergy_dmmv_x;
75
static int hf_synergy_dmmv_y;
76
77
static int hf_synergy_dmrm;
78
static int hf_synergy_dmrm_x;
79
static int hf_synergy_dmrm_y;
80
81
static int hf_synergy_dmwm;
82
83
static int hf_synergy_dclp;
84
static int hf_synergy_dclp_clipboardidentifier;
85
static int hf_synergy_dclp_sequencenumber;
86
static int hf_synergy_dclp_clipboarddata;
87
88
static int hf_synergy_dinf;
89
static int hf_synergy_dinf_clp;
90
static int hf_synergy_dinf_ctp;
91
static int hf_synergy_dinf_wsp;
92
static int hf_synergy_dinf_hsp;
93
static int hf_synergy_dinf_swz;
94
static int hf_synergy_dinf_x;
95
static int hf_synergy_dinf_y;
96
97
static int hf_synergy_dsop;
98
99
static int hf_synergy_qinf;
100
101
static int hf_synergy_eicv;
102
static int hf_synergy_eicv_majorversion;
103
static int hf_synergy_eicv_minorversion;
104
105
static int hf_synergy_ebsy;
106
107
static int hf_synergy_eunk;
108
109
static int hf_synergy_ebad;
110
111
/* Initialize the subtree pointers */
112
static int ett_synergy;
113
114
static dissector_handle_t synergy_handle;
115
116
static const string_string packet_type_vals[] = {
117
118
    { "CNOP", "No Operation" },
119
    { "CALV", "Keep Alive" },
120
    { "CBYE", "Close Connection" },
121
    { "CINN", "Enter Screen" },
122
    { "COUT", "Leave Screen" },
123
    { "CCLP", "Grab Clipboard" },
124
    { "CSEC", "Screen Saver Change" },
125
    { "CROP", "Reset Options" },
126
    { "CIAK", "Resolution Change Acknowledgment" },
127
    { "DKDN", "Key Pressed" },
128
    { "DKRP", "Key Auto-Repeat" },
129
    { "DKUP", "Key Released" },
130
    { "DMDN", "Mouse Button Pressed" },
131
    { "DMUP", "Mouse Button Released" },
132
    { "DMMV", "Mouse Moved" },
133
    { "DMRM", "Relative Mouse Move" },
134
    { "DMWM", "Mouse Button Pressed" },
135
    { "DCLP", "Clipboard Data" },
136
    { "DINF", "Client Data" },
137
    { "DSOP", "Set Options" },
138
    { "QINF", "Query Screen Info" },
139
    { "EICV", "Incompatible Versions" },
140
    { "EBSY", "Connection Already in Use" },
141
    { "EUNK", "Unknown Client" },
142
    { "EBAD", "Protocol Violation" },
143
    { NULL  , NULL }
144
};
145
146
static void dissect_synergy_handshake(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,int offset);
147
static void dissect_synergy_cinn(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,int offset);
148
static void dissect_synergy_cclp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,int offset);
149
static void dissect_synergy_dkdn(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,int offset);
150
static void dissect_synergy_dkrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,int offset);
151
static void dissect_synergy_dkup(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,int offset);
152
static void dissect_synergy_dmmv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,int offset);
153
static void dissect_synergy_dmrm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,int offset);
154
static void dissect_synergy_dclp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,int offset);
155
static void dissect_synergy_dinf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,int offset);
156
static void dissect_synergy_eicv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,int offset);
157
158
159
/* Code to dissect a single Synergy packet */
160
static int
161
dissect_synergy_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
162
131
{
163
164
131
    col_set_str(pinfo->cinfo, COL_PROTOCOL, "synergy");
165
131
    col_clear(pinfo->cinfo, COL_INFO);
166
167
131
    if (tree) {
168
131
        int offset=0;
169
131
        const char* packet_type;
170
131
        proto_item *ti = NULL;
171
131
        proto_tree *synergy_tree = NULL;
172
131
        ti = proto_tree_add_protocol_format(tree, proto_synergy, tvb, 0, -1,"Synergy Protocol");
173
131
        synergy_tree = proto_item_add_subtree(ti, ett_synergy);
174
175
131
        proto_tree_add_item(synergy_tree,hf_synergy_packet_len,tvb,offset,4,ENC_BIG_ENDIAN);
176
177
        /* Are the first 7 bytes of the payload "Synergy"?
178
         * (Note this never throws an exception)
179
         */
180
131
        if (tvb_strneql(tvb, offset+4, "Synergy", 7) == 0) {
181
            /* Yes - dissect as a handshake. */
182
0
            dissect_synergy_handshake(tvb,pinfo,synergy_tree,offset+11);
183
184
0
            return tvb_captured_length(tvb);
185
0
        }
186
187
        /* No, so the first 4 bytes of the payload should be a packet type */
188
131
        packet_type = (char*)tvb_get_string_enc(pinfo->pool, tvb, offset+4, 4, ENC_ASCII);
189
131
        proto_tree_add_string_format_value(synergy_tree,hf_synergy_packet_type,tvb,offset+4,4, packet_type, "%s (%s)", str_to_str_wmem(pinfo->pool, packet_type, packet_type_vals, "Unknown"), packet_type);
190
191
131
        if(strncmp(packet_type,"CNOP",4)==0) {
192
131
        } else if(strncmp(packet_type,"CALV",4)==0) {
193
131
        } else if(strncmp(packet_type,"CBYE",4)==0) {
194
0
            proto_tree_add_item(synergy_tree,hf_synergy_cbye,tvb,offset+8,-1,ENC_NA);
195
131
        } else if(strncmp(packet_type,"CINN",4)==0) {
196
0
            dissect_synergy_cinn(tvb,pinfo,synergy_tree,offset+8);
197
131
        } else if(strncmp(packet_type,"COUT",4)==0) {
198
0
            proto_tree_add_item(synergy_tree,hf_synergy_cout,tvb,offset+8,-1,ENC_NA);
199
131
        } else if(strncmp(packet_type,"CCLP",4)==0) {
200
0
            dissect_synergy_cclp(tvb,pinfo,synergy_tree,offset+8);
201
131
        } else if(strncmp(packet_type,"CSEC",4)==0) {
202
0
            proto_tree_add_item(synergy_tree,hf_synergy_csec,tvb,offset+8,1,ENC_BIG_ENDIAN);
203
131
        } else if(strncmp(packet_type,"CROP",4)==0) {
204
0
            proto_tree_add_item(synergy_tree,hf_synergy_crop,tvb,offset+8,-1,ENC_NA);
205
131
        } else if(strncmp(packet_type,"CIAK",4)==0) {
206
0
            proto_tree_add_item(synergy_tree,hf_synergy_ciak,tvb,offset+8,-1,ENC_NA);
207
131
        } else if(strncmp(packet_type,"DKDN",4)==0) {
208
0
            dissect_synergy_dkdn(tvb,pinfo,synergy_tree,offset+8);
209
131
        } else if(strncmp(packet_type,"DKRP",4)==0) {
210
0
            dissect_synergy_dkrp(tvb,pinfo,synergy_tree,offset+8);
211
131
        } else if(strncmp(packet_type,"DKUP",4)==0) {
212
1
            dissect_synergy_dkup(tvb,pinfo,synergy_tree,offset+8);
213
130
        } else if(strncmp(packet_type,"DMDN",4)==0) {
214
0
            proto_tree_add_item(synergy_tree,hf_synergy_dmdn,tvb,offset+8,1,ENC_BIG_ENDIAN);
215
130
        } else if(strncmp(packet_type,"DMUP",4)==0) {
216
0
            proto_tree_add_item(synergy_tree,hf_synergy_dmup,tvb,offset+8,1,ENC_BIG_ENDIAN);
217
130
        } else if(strncmp(packet_type,"DMMV",4)==0) {
218
0
            dissect_synergy_dmmv(tvb,pinfo,synergy_tree,offset+8);
219
130
        } else if(strncmp(packet_type,"DMRM",4)==0) {
220
0
            dissect_synergy_dmrm(tvb,pinfo,synergy_tree,offset+8);
221
130
        } else if(strncmp(packet_type,"DMWM",4)==0) {
222
0
            proto_tree_add_item(synergy_tree,hf_synergy_dmwm,tvb,offset+8,2,ENC_BIG_ENDIAN);
223
130
        } else if(strncmp(packet_type,"DCLP",4)==0) {
224
1
            dissect_synergy_dclp(tvb,pinfo,synergy_tree,offset+8);
225
129
        } else if(strncmp(packet_type,"DINF",4)==0) {
226
0
            dissect_synergy_dinf(tvb,pinfo,synergy_tree,offset+8);
227
129
        } else if(strncmp(packet_type,"DSOP",4)==0) {
228
0
            proto_tree_add_item(synergy_tree,hf_synergy_dsop,tvb,offset+8,4,ENC_BIG_ENDIAN);
229
129
        } else if(strncmp(packet_type,"QINF",4)==0) {
230
0
            proto_tree_add_item(synergy_tree,hf_synergy_qinf,tvb,offset+8,-1,ENC_NA);
231
129
        } else if(strncmp(packet_type,"EICV",4)==0) {
232
0
            dissect_synergy_eicv(tvb,pinfo,synergy_tree,offset+8);
233
129
        } else if(strncmp(packet_type,"EBSY",4)==0) {
234
0
            proto_tree_add_item(synergy_tree,hf_synergy_ebsy,tvb,offset+8,-1,ENC_NA);
235
129
        } else if(strncmp(packet_type,"EUNK",4)==0) {
236
0
            proto_tree_add_item(synergy_tree,hf_synergy_eunk,tvb,offset+8,-1,ENC_NA);
237
129
        } else if(strncmp(packet_type,"EBAD",4)==0) {
238
0
            proto_tree_add_item(synergy_tree,hf_synergy_ebad,tvb,offset+8,-1,ENC_NA);
239
129
        } else {
240
129
            proto_tree_add_item(synergy_tree,hf_synergy_unknown,tvb,offset+8,-1,ENC_NA);
241
129
        }
242
131
    }
243
244
131
    return tvb_captured_length(tvb);
245
131
}
246
247
static void dissect_synergy_handshake( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset )
248
0
{
249
0
    proto_item *ti = NULL;
250
0
    proto_tree *sub_tree = NULL;
251
0
    ti = proto_tree_add_item(tree, hf_synergy_handshake, tvb, offset, -1, ENC_NA);
252
0
    sub_tree = proto_item_add_subtree(ti, ett_synergy);
253
254
0
    proto_tree_add_item(sub_tree, hf_synergy_handshake_majorversion, tvb, offset, 2, ENC_BIG_ENDIAN);
255
0
    proto_tree_add_item(sub_tree, hf_synergy_handshake_minorversion, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
256
257
0
    if (tvb_reported_length_remaining(tvb, offset + 4) != 0)
258
0
    {
259
0
        proto_tree_add_item(sub_tree, hf_synergy_unknown, tvb, offset + 4, 4, ENC_NA);
260
0
        proto_tree_add_item(sub_tree, hf_synergy_handshake_clientname, tvb, offset + 8, -1, ENC_ASCII);
261
0
    }
262
0
}
263
264
static void dissect_synergy_cinn( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset )
265
0
{
266
0
    proto_item *ti = NULL;
267
0
    proto_tree *sub_tree = NULL;
268
0
    ti = proto_tree_add_item(tree, hf_synergy_cinn, tvb, offset, -1, ENC_NA);
269
0
    sub_tree = proto_item_add_subtree(ti, ett_synergy);
270
271
0
    proto_tree_add_item(sub_tree, hf_synergy_cinn_x, tvb, offset, 2, ENC_BIG_ENDIAN);
272
0
    proto_tree_add_item(sub_tree, hf_synergy_cinn_y, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
273
0
    proto_tree_add_item(sub_tree, hf_synergy_cinn_sequence, tvb, offset + 4, 4, ENC_BIG_ENDIAN);
274
0
    proto_tree_add_item(sub_tree, hf_synergy_cinn_modifiermask, tvb, offset + 8, 2, ENC_BIG_ENDIAN);
275
0
}
276
277
static void dissect_synergy_cclp( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset )
278
0
{
279
0
    proto_item *ti = NULL;
280
0
    proto_tree *sub_tree = NULL;
281
0
    ti = proto_tree_add_item(tree, hf_synergy_cclp, tvb, offset, -1, ENC_NA);
282
0
    sub_tree = proto_item_add_subtree(ti, ett_synergy);
283
284
0
    proto_tree_add_item(sub_tree, hf_synergy_cclp_clipboardidentifier, tvb, offset, 1, ENC_BIG_ENDIAN);
285
0
    proto_tree_add_item(sub_tree, hf_synergy_cclp_sequencenumber, tvb, offset + 1, 4, ENC_BIG_ENDIAN);
286
0
}
287
288
static void dissect_synergy_dkdn( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset )
289
0
{
290
0
    proto_item *ti = NULL;
291
0
    proto_tree *sub_tree = NULL;
292
0
    ti = proto_tree_add_item(tree, hf_synergy_dkdn, tvb, offset, -1, ENC_NA);
293
0
    sub_tree = proto_item_add_subtree(ti, ett_synergy);
294
295
0
    proto_tree_add_item(sub_tree, hf_synergy_dkdn_keyid, tvb, offset, 2, ENC_BIG_ENDIAN);
296
0
    proto_tree_add_item(sub_tree, hf_synergy_dkdn_keymodifiermask, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
297
298
0
    if (tvb_reported_length_remaining(tvb, offset + 4) != 0)
299
0
        proto_tree_add_item(sub_tree, hf_synergy_dkdn_keybutton, tvb, offset + 4, 2, ENC_BIG_ENDIAN);
300
0
}
301
302
static void dissect_synergy_dkrp( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset )
303
0
{
304
0
    proto_item *ti = NULL;
305
0
    proto_tree *sub_tree = NULL;
306
0
    ti = proto_tree_add_item(tree, hf_synergy_dkrp, tvb, offset, -1, ENC_NA);
307
0
    sub_tree = proto_item_add_subtree(ti, ett_synergy);
308
309
0
    proto_tree_add_item(sub_tree, hf_synergy_dkrp_keyid, tvb, offset, 2, ENC_BIG_ENDIAN);
310
0
    proto_tree_add_item(sub_tree, hf_synergy_dkrp_keymodifiermask, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
311
0
    proto_tree_add_item(sub_tree, hf_synergy_dkrp_numberofrepeats, tvb, offset + 4, 2, ENC_BIG_ENDIAN);
312
313
0
    if (tvb_reported_length_remaining(tvb, offset + 6) != 0)
314
0
        proto_tree_add_item(sub_tree, hf_synergy_dkrp_keybutton, tvb, offset + 6, 2, ENC_BIG_ENDIAN);
315
0
}
316
317
static void dissect_synergy_dkup( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset )
318
1
{
319
1
    proto_item *ti = NULL;
320
1
    proto_tree *sub_tree = NULL;
321
1
    ti = proto_tree_add_item(tree, hf_synergy_dkup, tvb, offset, -1, ENC_NA);
322
1
    sub_tree = proto_item_add_subtree(ti, ett_synergy);
323
324
1
    proto_tree_add_item(sub_tree, hf_synergy_dkup_keyid, tvb, offset, 2, ENC_BIG_ENDIAN);
325
1
    proto_tree_add_item(sub_tree, hf_synergy_dkup_keymodifiermask, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
326
327
1
    if (tvb_reported_length_remaining(tvb, offset + 4) != 0)
328
1
        proto_tree_add_item(sub_tree, hf_synergy_dkup_keybutton, tvb, offset + 4, 2, ENC_BIG_ENDIAN);
329
1
}
330
331
static void dissect_synergy_dmmv( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset )
332
0
{
333
0
    proto_item *ti = NULL;
334
0
    proto_tree *sub_tree = NULL;
335
0
    ti = proto_tree_add_item(tree, hf_synergy_dmmv, tvb, offset, -1, ENC_NA);
336
0
    sub_tree = proto_item_add_subtree(ti, ett_synergy);
337
338
0
    proto_tree_add_item(sub_tree, hf_synergy_dmmv_x, tvb, offset, 2, ENC_BIG_ENDIAN);
339
0
    proto_tree_add_item(sub_tree, hf_synergy_dmmv_y, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
340
0
}
341
342
static void dissect_synergy_dmrm( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset )
343
0
{
344
0
    proto_item *ti = NULL;
345
0
    proto_tree *sub_tree = NULL;
346
0
    ti = proto_tree_add_item(tree, hf_synergy_dmrm, tvb, offset, -1, ENC_NA);
347
0
    sub_tree = proto_item_add_subtree(ti, ett_synergy);
348
349
0
    proto_tree_add_item(sub_tree, hf_synergy_dmrm_x, tvb, offset, 2, ENC_BIG_ENDIAN);
350
0
    proto_tree_add_item(sub_tree, hf_synergy_dmrm_y, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
351
0
}
352
353
static void dissect_synergy_dclp( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset )
354
1
{
355
1
    proto_item *ti = NULL;
356
1
    proto_tree *sub_tree = NULL;
357
1
    ti = proto_tree_add_item(tree, hf_synergy_dclp, tvb, offset, -1, ENC_NA);
358
1
    sub_tree = proto_item_add_subtree(ti, ett_synergy);
359
360
1
    proto_tree_add_item(sub_tree, hf_synergy_dclp_clipboardidentifier, tvb, offset, 1, ENC_BIG_ENDIAN);
361
1
    proto_tree_add_item(sub_tree, hf_synergy_dclp_sequencenumber, tvb, offset + 1, 4, ENC_BIG_ENDIAN);
362
1
    proto_tree_add_item(sub_tree, hf_synergy_dclp_clipboarddata, tvb, offset + 5, -1, ENC_ASCII);
363
1
}
364
365
static void dissect_synergy_dinf( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset )
366
0
{
367
0
    proto_item *ti = NULL;
368
0
    proto_tree *sub_tree = NULL;
369
0
    ti = proto_tree_add_item(tree, hf_synergy_dinf, tvb, offset, -1, ENC_NA);
370
0
    sub_tree = proto_item_add_subtree(ti, ett_synergy);
371
372
0
    proto_tree_add_item(sub_tree, hf_synergy_dinf_clp, tvb, offset, 2, ENC_BIG_ENDIAN);
373
0
    proto_tree_add_item(sub_tree, hf_synergy_dinf_ctp, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
374
0
    proto_tree_add_item(sub_tree, hf_synergy_dinf_wsp, tvb, offset + 4, 2, ENC_BIG_ENDIAN);
375
0
    proto_tree_add_item(sub_tree, hf_synergy_dinf_hsp, tvb, offset + 6, 2, ENC_BIG_ENDIAN);
376
0
    proto_tree_add_item(sub_tree, hf_synergy_dinf_swz, tvb, offset + 8, 2, ENC_BIG_ENDIAN);
377
0
    proto_tree_add_item(sub_tree, hf_synergy_dinf_x, tvb, offset + 10, 2, ENC_BIG_ENDIAN);
378
0
    proto_tree_add_item(sub_tree, hf_synergy_dinf_y, tvb, offset + 12, 2, ENC_BIG_ENDIAN);
379
0
}
380
381
static void dissect_synergy_eicv( tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset )
382
0
{
383
0
    proto_item *ti = NULL;
384
0
    proto_tree *sub_tree = NULL;
385
0
    ti = proto_tree_add_item(tree, hf_synergy_eicv, tvb, offset, -1, ENC_NA);
386
0
    sub_tree = proto_item_add_subtree(ti, ett_synergy);
387
388
0
    proto_tree_add_item(sub_tree, hf_synergy_eicv_majorversion, tvb, offset, 2, ENC_BIG_ENDIAN);
389
0
    proto_tree_add_item(sub_tree, hf_synergy_eicv_minorversion, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
390
0
}
391
392
static unsigned
393
synergy_get_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset, void *data _U_)
394
132
{
395
132
  return tvb_get_ntohl(tvb, offset) + 4;
396
132
}
397
398
static int
399
dissect_synergy(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
400
18
{
401
18
    tcp_dissect_pdus(tvb, pinfo, tree, true, 4, synergy_get_pdu_len,
402
18
                     dissect_synergy_pdu, NULL);
403
18
    return tvb_captured_length(tvb);
404
18
}
405
406
void
407
proto_register_synergy(void)
408
16
{
409
16
    static hf_register_info hf[] = {
410
411
16
        { &hf_synergy_packet_len,
412
16
            { "Packet Length","synergy.packet_len",FT_UINT32, BASE_DEC, NULL, 0x0,NULL, HFILL }
413
16
        },
414
16
        { &hf_synergy_packet_type,
415
16
            { "Packet Type","synergy.packet_type",FT_STRING, BASE_NONE, NULL, 0x0,NULL, HFILL }
416
16
        },
417
16
        { &hf_synergy_unknown,
418
16
            { "unknown","synergy.unknown",FT_NONE, BASE_NONE, NULL, 0x0,NULL, HFILL }
419
16
        },
420
16
        { &hf_synergy_handshake,
421
16
            { "Handshake","synergy.handshake",FT_NONE, BASE_NONE, NULL, 0x0,NULL, HFILL }
422
16
        },
423
16
        { &hf_synergy_handshake_majorversion,
424
16
            { "Major Version","synergy.handshake.majorversion",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
425
16
        },
426
16
        { &hf_synergy_handshake_minorversion,
427
16
            { "Minor Version","synergy.handshake.minorversion",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
428
16
        },
429
16
        { &hf_synergy_handshake_clientname,
430
16
            { "Client Name","synergy.handshake.client",FT_STRING, BASE_NONE, NULL, 0x0,NULL, HFILL }
431
16
        },
432
16
        { &hf_synergy_cbye,
433
16
            { "Close Connection","synergy.cbye",FT_NONE, BASE_NONE, NULL, 0x0,NULL, HFILL }
434
16
        },
435
16
        { &hf_synergy_cinn,
436
16
            { "Enter Screen","synergy.cinn",FT_NONE, BASE_NONE, NULL, 0x0,NULL, HFILL }
437
16
        },
438
16
        { &hf_synergy_cinn_x,
439
16
            { "Screen X","synergy.cinn.x",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
440
16
        },
441
16
        { &hf_synergy_cinn_y,
442
16
            { "Screen Y","synergy.cinn.y",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
443
16
        },
444
16
        { &hf_synergy_cinn_sequence,
445
16
            { "Sequence Number","synergy.cinn.sequence",FT_UINT32, BASE_DEC, NULL, 0x0,NULL, HFILL }
446
16
        },
447
16
        { &hf_synergy_cinn_modifiermask,
448
16
            { "Modifier Key Mask","synergy.cinn.mask",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
449
16
        },
450
16
        { &hf_synergy_cout,
451
16
            { "Leave Screen","synergy.cout",FT_NONE, BASE_NONE, NULL, 0x0,NULL, HFILL }
452
16
        },
453
16
        { &hf_synergy_cclp,
454
16
            { "Grab Clipboard","synergy.clipboard",FT_NONE, BASE_NONE, NULL, 0x0,NULL, HFILL }
455
16
        },
456
16
        { &hf_synergy_cclp_clipboardidentifier,
457
16
            { "Identifier","synergy.clipboard.identifier",FT_UINT8, BASE_DEC, NULL, 0x0,NULL, HFILL }
458
16
        },
459
16
        { &hf_synergy_cclp_sequencenumber,
460
16
            { "Sequence Number","synergy.clipboard.sequence",FT_UINT32, BASE_DEC, NULL, 0x0,NULL, HFILL }
461
16
        },
462
16
        { &hf_synergy_csec,
463
16
            { "Screen Saver Change","synergy.screensaver",FT_BOOLEAN, BASE_NONE, NULL, 0x0,NULL, HFILL }
464
16
        },
465
16
        { &hf_synergy_crop,
466
16
            { "Reset Options","synergy.resetoptions",FT_NONE, BASE_NONE, NULL, 0x0,NULL, HFILL }
467
16
        },
468
16
        { &hf_synergy_ciak,
469
16
            { "Resolution Change Acknowledgment","synergy.ack",FT_NONE, BASE_NONE, NULL, 0x0,NULL, HFILL }
470
16
        },
471
16
        { &hf_synergy_dkdn,
472
16
            { "Key Pressed","synergy.keypressed",FT_NONE, BASE_NONE, NULL, 0x0,NULL, HFILL }
473
16
        },
474
16
        { &hf_synergy_dkdn_keyid,
475
16
            { "Key Id","synergy.keypressed.keyid",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
476
16
        },
477
16
        { &hf_synergy_dkdn_keymodifiermask,
478
16
            { "Key Modifier Mask","synergy.keypressed.mask",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
479
16
        },
480
16
        { &hf_synergy_dkdn_keybutton,
481
16
            { "Key Button","synergy.keypressed.key",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
482
16
        },
483
16
        { &hf_synergy_dkrp,
484
16
            { "Key Auto-Repeat","synergy.keyautorepeat",FT_NONE, BASE_NONE, NULL, 0x0,NULL, HFILL }
485
16
        },
486
16
        { &hf_synergy_dkrp_keyid,
487
16
            { "Key ID","synergy.keyautorepeat.keyid",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
488
16
        },
489
16
        { &hf_synergy_dkrp_keymodifiermask,
490
16
            { "Key modifier Mask","synergy.keyautorepeat.mask",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
491
16
        },
492
16
        { &hf_synergy_dkrp_numberofrepeats,
493
16
            { "Number of Repeats","synergy.keyautorepeat.repeat",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
494
16
        },
495
16
        { &hf_synergy_dkrp_keybutton,
496
16
            { "Key Button","synergy.keyautorepeat.key",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
497
16
        },
498
16
        { &hf_synergy_dkup,
499
16
            { "Key Released","synergy.keyreleased",FT_NONE, BASE_NONE, NULL, 0x0,NULL, HFILL }
500
16
        },
501
16
        { &hf_synergy_dkup_keyid,
502
16
            { "Key Id","synergy.keyreleased.keyid",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
503
16
        },
504
16
        { &hf_synergy_dkup_keymodifiermask,
505
16
            { "Key Modifier Mask","synergy.keyreleased.mask",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
506
16
        },
507
16
        { &hf_synergy_dkup_keybutton,
508
16
            { "Key Button","synergy.keyreleased.key",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
509
16
        },
510
16
        { &hf_synergy_dmdn,
511
16
            { "Mouse Button Pressed","synergy.mousebuttonpressed",FT_UINT8, BASE_DEC, NULL, 0x0,NULL, HFILL }
512
16
        },
513
16
        { &hf_synergy_dmup,
514
16
            { "Mouse Button Released","synergy.mousebuttonreleased",FT_UINT8, BASE_DEC, NULL, 0x0,NULL, HFILL }
515
16
        },
516
16
        { &hf_synergy_dmmv,
517
16
            { "Mouse Moved","synergy.mousemoved",FT_NONE, BASE_NONE, NULL, 0x0,NULL, HFILL }
518
16
        },
519
16
        { &hf_synergy_dmmv_x,
520
16
            { "X Axis","synergy.mousemoved.x",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
521
16
        },
522
16
        { &hf_synergy_dmmv_y,
523
16
            { "Y Axis","synergy.mousemoved.y",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
524
16
        },
525
16
        { &hf_synergy_dmrm,
526
16
            { "Relative Mouse Move","synergy.relativemousemove",FT_NONE, BASE_NONE, NULL, 0x0,NULL, HFILL }
527
16
        },
528
16
        { &hf_synergy_dmrm_x,
529
16
            { "X Axis","synergy.relativemousemove.x",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
530
16
        },
531
16
        { &hf_synergy_dmrm_y,
532
16
            { "Y Axis","synergy.relativemousemove.y",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
533
16
        },
534
16
        { &hf_synergy_dmwm,
535
16
            { "Mouse Button Pressed","synergy.mousebuttonpressed",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
536
16
        },
537
16
        { &hf_synergy_dclp,
538
16
            { "Clipboard Data","synergy.clipboarddata",FT_NONE, BASE_NONE, NULL, 0x0,NULL, HFILL }
539
16
        },
540
16
        { &hf_synergy_dclp_clipboardidentifier,
541
16
            { "Clipboard Identifier","synergy.clipboarddata.identifier",FT_UINT8, BASE_DEC, NULL, 0x0,NULL, HFILL }
542
16
        },
543
16
        { &hf_synergy_dclp_sequencenumber,
544
16
            { "Sequence Number","synergy.clipboarddata.sequence",FT_UINT32, BASE_DEC, NULL, 0x0,NULL, HFILL }
545
16
        },
546
16
        { &hf_synergy_dclp_clipboarddata,
547
16
            { "Clipboard Data","synergy.clipboarddata.data",FT_STRING, BASE_NONE, NULL, 0x0,NULL, HFILL }
548
16
        },
549
16
        { &hf_synergy_dinf,
550
16
            { "Client Data","synergy.clientdata",FT_NONE, BASE_NONE, NULL, 0x0,NULL, HFILL }
551
16
        },
552
16
        { &hf_synergy_dinf_clp,
553
16
            { "coordinate of leftmost pixel on secondary screen","synergy.clps",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
554
16
        },
555
16
        { &hf_synergy_dinf_ctp,
556
16
            { "coordinate of topmost pixel on secondary screen","synergy.clps.ctp",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
557
16
        },
558
16
        { &hf_synergy_dinf_wsp,
559
16
            { "width of secondary screen in pixels","synergy.clps.wsp",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
560
16
        },
561
16
        { &hf_synergy_dinf_hsp,
562
16
            { "height of secondary screen in pixels","synergy.clps.hsp",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
563
16
        },
564
16
        { &hf_synergy_dinf_swz,
565
16
            { "size of warp zone","synergy.clps.swz",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
566
16
        },
567
16
        { &hf_synergy_dinf_x,
568
16
            { "x position of the mouse on the secondary screen","synergy.clps.x",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
569
16
        },
570
16
        { &hf_synergy_dinf_y,
571
16
            { "y position of the mouse on the secondary screen","synergy.clps.y",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
572
16
        },
573
16
        { &hf_synergy_dsop,
574
16
            { "Set Options","synergy.setoptions",FT_UINT32, BASE_DEC, NULL, 0x0,NULL, HFILL }
575
16
        },
576
16
        { &hf_synergy_qinf,
577
16
            { "Query Screen Info","synergy.qinf",FT_NONE, BASE_NONE, NULL, 0x0,NULL, HFILL }
578
16
        },
579
16
        { &hf_synergy_eicv,
580
16
            { "Incompatible Versions","synergy.eicv",FT_NONE, BASE_NONE, NULL, 0x0,NULL, HFILL }
581
16
        },
582
16
        { &hf_synergy_eicv_majorversion,
583
16
            { "Major Version Number","synergy.eicv.major",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
584
16
        },
585
16
        { &hf_synergy_eicv_minorversion,
586
16
            { "Minor Version Number","synergy.eicv.minor",FT_UINT16, BASE_DEC, NULL, 0x0,NULL, HFILL }
587
16
        },
588
16
        { &hf_synergy_ebsy,
589
16
            { "Connection Already in Use","synergy.ebsy",FT_NONE, BASE_NONE, NULL, 0x0,NULL, HFILL }
590
16
        },
591
16
        { &hf_synergy_eunk,
592
16
            { "Unknown Client","synergy.unknown",FT_NONE, BASE_NONE, NULL, 0x0,NULL, HFILL }
593
16
        },
594
16
        { &hf_synergy_ebad,
595
16
            { "Protocol Violation","synergy.violation",FT_NONE, BASE_NONE, NULL, 0x0,NULL, HFILL }
596
16
        },
597
16
    };
598
599
600
/* Setup protocol subtree array */
601
16
    static int *ett[] = {
602
16
        &ett_synergy,
603
16
    };
604
605
/* Register the protocol name and description */
606
16
    proto_synergy = proto_register_protocol("Synergy", "Synergy", "synergy");
607
608
/* Required function calls to register the header fields and subtrees used */
609
16
    proto_register_field_array(proto_synergy, hf, array_length(hf));
610
16
    proto_register_subtree_array(ett, array_length(ett));
611
16
    synergy_handle = register_dissector("synergy", dissect_synergy, proto_synergy);
612
16
}
613
614
void
615
proto_reg_handoff_synergy(void)
616
16
{
617
16
    dissector_add_uint_with_preference("tcp.port", SYNERGY_PORT, synergy_handle);
618
16
}
619
620
/*
621
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
622
 *
623
 * Local variables:
624
 * c-basic-offset: 4
625
 * tab-width: 8
626
 * indent-tabs-mode: nil
627
 * End:
628
 *
629
 * vi: set shiftwidth=4 tabstop=8 expandtab:
630
 * :indentSize=4:tabSize=8:noTabs=true:
631
 */