Coverage Report

Created: 2026-01-02 06:13

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wireshark/epan/dissectors/packet-netsync.c
Line
Count
Source
1
/* packet-netsync.c
2
 * Routines for Monotone Netsync packet disassembly
3
 *
4
 * Copyright (c) 2005 by Erwin Rol <erwin@erwinrol.com>
5
 *
6
 * Wireshark - Network traffic analyzer
7
 * By Gerald Combs <gerald@wireshark.org>
8
 * Copyright 1999 Gerald Combs
9
 *
10
 * SPDX-License-Identifier: GPL-2.0-or-later
11
 */
12
13
/* Include files */
14
15
#include "config.h"
16
17
#include <epan/packet.h>
18
#include <epan/prefs.h>
19
#include "packet-tcp.h"
20
21
void proto_register_netsync(void);
22
void proto_reg_handoff_netsync(void);
23
24
static dissector_handle_t netsync_handle;
25
26
/*
27
 * See
28
 *
29
 *  http://www.monotone.ca
30
 */
31
32
/* Define TCP ports for Monotone netsync */
33
34
14
#define TCP_PORT_NETSYNC 5253
35
36
#define NETSYNC_ROLE_SOURCE 1
37
#define NETSYNC_ROLE_SINK 2
38
#define NETSYNC_ROLE_BOTH 3
39
40
static const value_string netsync_role_vals[] = {
41
  { NETSYNC_ROLE_SOURCE,  "Source" },
42
  { NETSYNC_ROLE_SINK,  "Sink" },
43
  { NETSYNC_ROLE_BOTH,  "Both" },
44
  { 0,      NULL }
45
};
46
47
48
180
#define NETSYNC_CMD_ERROR 0
49
24
#define NETSYNC_CMD_BYE   1
50
63
#define NETSYNC_CMD_HELLO 2
51
71
#define NETSYNC_CMD_ANONYMOUS 3
52
29
#define NETSYNC_CMD_AUTH  4
53
37
#define NETSYNC_CMD_CONFIRM 5
54
25
#define NETSYNC_CMD_REFINE  6
55
5
#define NETSYNC_CMD_DONE  7
56
33
#define NETSYNC_CMD_SEND_DATA 8
57
2
#define NETSYNC_CMD_SEND_DELTA  9
58
21
#define NETSYNC_CMD_DATA  10
59
47
#define NETSYNC_CMD_DELTA 11
60
10
#define NETSYNC_CMD_NONEXISTENT 12
61
62
static const value_string netsync_cmd_vals[] = {
63
  { NETSYNC_CMD_ERROR,    "Error" },
64
  { NETSYNC_CMD_BYE,    "Bye" },
65
  { NETSYNC_CMD_HELLO,    "Hello" },
66
  { NETSYNC_CMD_ANONYMOUS,  "Anonymous" },
67
  { NETSYNC_CMD_AUTH,     "Auth" },
68
  { NETSYNC_CMD_CONFIRM,    "Confirm" },
69
  { NETSYNC_CMD_REFINE,     "Refine" },
70
  { NETSYNC_CMD_DONE,     "Done" },
71
  { NETSYNC_CMD_SEND_DATA,  "Send Data" },
72
  { NETSYNC_CMD_SEND_DELTA,   "Send Delta" },
73
  { NETSYNC_CMD_DATA,   "Data" },
74
  { NETSYNC_CMD_DELTA,    "Delta" },
75
  { NETSYNC_CMD_NONEXISTENT,  "Nonexistent" },
76
  { 0,        NULL }
77
};
78
79
766
#define NETSNYC_MERKLE_HASH_LENGTH 20
80
81
/* Define the monotone netsync proto */
82
static int proto_netsync;
83
84
static int hf_netsync_version;
85
static int hf_netsync_command;
86
static int hf_netsync_size;
87
static int hf_netsync_data;
88
static int hf_netsync_checksum;
89
90
static int hf_netsync_cmd_done_level;
91
static int hf_netsync_cmd_done_type;
92
93
static int hf_netsync_cmd_hello_keyname;
94
static int hf_netsync_cmd_hello_key;
95
static int hf_netsync_cmd_nonce;
96
97
static int hf_netsync_cmd_anonymous_role;
98
static int hf_netsync_cmd_anonymous_collection;
99
100
static int hf_netsync_cmd_send_data_type;
101
static int hf_netsync_cmd_send_data_id;
102
103
static int hf_netsync_cmd_error_msg;
104
105
106
static int hf_netsync_cmd_confirm_sig;
107
108
static int hf_netsync_cmd_auth_role;
109
static int hf_netsync_cmd_auth_collection;
110
static int hf_netsync_cmd_auth_id;
111
static int hf_netsync_cmd_auth_nonce1;
112
static int hf_netsync_cmd_auth_nonce2;
113
static int hf_netsync_cmd_auth_sig;
114
115
static int hf_netsync_cmd_data_type;
116
static int hf_netsync_cmd_data_id;
117
static int hf_netsync_cmd_data_compressed;
118
static int hf_netsync_cmd_data_payload;
119
120
static int hf_netsync_cmd_delta_type;
121
static int hf_netsync_cmd_delta_base_id;
122
static int hf_netsync_cmd_delta_ident_id;
123
static int hf_netsync_cmd_delta_compressed;
124
static int hf_netsync_cmd_delta_payload;
125
126
static int hf_netsync_cmd_refine_tree_node;
127
128
static int hf_netsync_cmd_send_delta_type;
129
static int hf_netsync_cmd_send_delta_base_id;
130
static int hf_netsync_cmd_send_delta_ident_id;
131
132
static int hf_netsync_cmd_nonexistent_type;
133
static int hf_netsync_cmd_nonexistent_id;
134
135
/* Define the tree for netsync */
136
static int ett_netsync;
137
138
139
/*
140
 * Here are the global variables associated with the preferences
141
 * for monotone netsync
142
 */
143
144
static bool netsync_desegment = true;
145
146
static int dissect_netsync_cmd_error( tvbuff_t *tvb,  int offset, proto_tree *tree, unsigned size _U_)
147
180
{
148
180
  uint64_t len = 0;
149
150
180
  offset += tvb_get_varint( tvb, offset, FT_VARINT_MAX_LEN, &len, ENC_VARINT_PROTOBUF );
151
152
180
  proto_tree_add_item(tree, hf_netsync_cmd_error_msg, tvb,
153
180
        offset, (int)len, ENC_ASCII );
154
180
  offset += (int)len;
155
156
180
  return offset;
157
180
}
158
159
static int dissect_netsync_cmd_bye(tvbuff_t *tvb _U_,  int offset, proto_tree *tree _U_, unsigned size _U_)
160
24
{
161
24
  return offset;
162
24
}
163
164
165
static int dissect_netsync_cmd_hello(tvbuff_t *tvb,  int offset, proto_tree *tree, unsigned size _U_)
166
63
{
167
63
  uint64_t len = 0;
168
169
63
  offset += tvb_get_varint( tvb, offset, FT_VARINT_MAX_LEN, &len, ENC_VARINT_PROTOBUF );
170
63
  proto_tree_add_item(tree, hf_netsync_cmd_hello_keyname, tvb,
171
63
        offset, (int)len, ENC_ASCII );
172
63
  offset += (int)len;
173
174
175
63
  offset += tvb_get_varint( tvb, offset, FT_VARINT_MAX_LEN, &len, ENC_VARINT_PROTOBUF );
176
63
  proto_tree_add_item(tree, hf_netsync_cmd_hello_key, tvb,
177
63
        offset, (int)len, ENC_NA );
178
63
  offset += (int)len;
179
180
63
  proto_tree_add_item(tree, hf_netsync_cmd_nonce, tvb,
181
63
        offset, NETSNYC_MERKLE_HASH_LENGTH, ENC_NA );
182
63
  offset += NETSNYC_MERKLE_HASH_LENGTH;
183
184
63
  return offset;
185
63
}
186
187
188
static int dissect_netsync_cmd_anonymous(tvbuff_t *tvb,  int offset, proto_tree *tree, unsigned size _U_)
189
71
{
190
71
  uint64_t len = 0;
191
192
71
  proto_tree_add_item(tree, hf_netsync_cmd_anonymous_role, tvb,
193
71
        offset, 1, ENC_BIG_ENDIAN );
194
71
  offset += 1;
195
196
71
  offset += tvb_get_varint( tvb, offset, FT_VARINT_MAX_LEN, &len, ENC_VARINT_PROTOBUF );
197
71
  proto_tree_add_item(tree, hf_netsync_cmd_anonymous_collection, tvb,
198
71
        offset, (int)len, ENC_ASCII );
199
71
  offset += (int)len;
200
201
71
  proto_tree_add_item(tree, hf_netsync_cmd_nonce, tvb,
202
71
        offset, NETSNYC_MERKLE_HASH_LENGTH, ENC_NA );
203
71
  offset += NETSNYC_MERKLE_HASH_LENGTH;
204
205
71
  return offset;
206
71
}
207
208
209
static int dissect_netsync_cmd_auth(tvbuff_t *tvb,  int offset, proto_tree *tree, unsigned size _U_)
210
29
{
211
29
  uint64_t len = 0;
212
213
29
  proto_tree_add_item(tree, hf_netsync_cmd_auth_role, tvb,
214
29
        offset, 1, ENC_BIG_ENDIAN );
215
29
  offset += 1;
216
217
218
29
  offset += tvb_get_varint( tvb, offset, FT_VARINT_MAX_LEN, &len, ENC_VARINT_PROTOBUF );
219
29
  proto_tree_add_item(tree, hf_netsync_cmd_auth_collection, tvb,
220
29
        offset, (int)len, ENC_ASCII );
221
29
  offset += (int)len;
222
223
29
  proto_tree_add_item(tree, hf_netsync_cmd_auth_id, tvb,
224
29
        offset, NETSNYC_MERKLE_HASH_LENGTH, ENC_NA );
225
29
  offset += NETSNYC_MERKLE_HASH_LENGTH;
226
227
29
  offset += (int)len;
228
229
29
  proto_tree_add_item(tree, hf_netsync_cmd_auth_nonce1, tvb,
230
29
        offset, NETSNYC_MERKLE_HASH_LENGTH, ENC_NA );
231
29
  offset += NETSNYC_MERKLE_HASH_LENGTH;
232
233
29
  offset += (int)len;
234
235
29
  proto_tree_add_item(tree, hf_netsync_cmd_auth_nonce2, tvb,
236
29
        offset, NETSNYC_MERKLE_HASH_LENGTH, ENC_NA );
237
29
  offset += NETSNYC_MERKLE_HASH_LENGTH;
238
239
29
  offset += tvb_get_varint( tvb, offset, FT_VARINT_MAX_LEN, &len, ENC_VARINT_PROTOBUF );
240
29
  proto_tree_add_item(tree, hf_netsync_cmd_auth_sig, tvb,
241
29
        offset, (int)len, ENC_NA );
242
29
  offset += (int)len;
243
244
29
  return offset;
245
29
}
246
247
248
static int dissect_netsync_cmd_confirm(tvbuff_t *tvb,  int offset, proto_tree *tree, unsigned size _U_)
249
37
{
250
37
  uint64_t len = 0;
251
252
37
  offset += tvb_get_varint( tvb, offset, FT_VARINT_MAX_LEN, &len, ENC_VARINT_PROTOBUF );
253
37
  proto_tree_add_item(tree, hf_netsync_cmd_confirm_sig, tvb,
254
37
        offset, (int)len, ENC_NA );
255
37
  offset += (int)len;
256
257
258
37
  return offset;
259
37
}
260
261
262
static int dissect_netsync_cmd_refine(tvbuff_t *tvb,  int offset, proto_tree *tree, unsigned size)
263
25
{
264
25
  proto_tree_add_item(tree, hf_netsync_cmd_refine_tree_node, tvb,
265
25
        offset, size, ENC_NA );
266
25
  offset += size;
267
268
25
  return offset;
269
25
}
270
271
272
static int dissect_netsync_cmd_done(tvbuff_t *tvb,  int offset, proto_tree *tree, unsigned size _U_)
273
5
{
274
5
  int bytes = 0;
275
276
5
  proto_tree_add_item_ret_length(tree, hf_netsync_cmd_done_level, tvb,
277
5
          offset, -1, ENC_LITTLE_ENDIAN|ENC_VARINT_PROTOBUF, &bytes);
278
5
  offset += bytes;
279
280
5
  proto_tree_add_item(tree, hf_netsync_cmd_done_type, tvb,
281
5
        offset, 1, ENC_BIG_ENDIAN );
282
5
  offset += 1;
283
284
5
  return offset;
285
5
}
286
287
288
static int dissect_netsync_cmd_send_data(tvbuff_t *tvb,  int offset, proto_tree *tree, unsigned size _U_)
289
33
{
290
33
  proto_tree_add_item(tree, hf_netsync_cmd_send_data_type, tvb,
291
33
          offset, 1, ENC_BIG_ENDIAN );
292
33
  offset += 1;
293
294
33
  proto_tree_add_item(tree, hf_netsync_cmd_send_data_id, tvb,
295
33
        offset, NETSNYC_MERKLE_HASH_LENGTH, ENC_NA );
296
33
  offset += NETSNYC_MERKLE_HASH_LENGTH;
297
298
33
  return offset;
299
33
}
300
301
302
static int dissect_netsync_cmd_send_delta(tvbuff_t *tvb,  int offset, proto_tree *tree, unsigned size _U_)
303
2
{
304
2
  proto_tree_add_item(tree, hf_netsync_cmd_send_delta_type, tvb,
305
2
          offset, 1, ENC_BIG_ENDIAN );
306
2
  offset += 1;
307
308
2
  proto_tree_add_item(tree, hf_netsync_cmd_send_delta_base_id, tvb,
309
2
        offset, NETSNYC_MERKLE_HASH_LENGTH, ENC_NA );
310
2
  offset += NETSNYC_MERKLE_HASH_LENGTH;
311
312
313
2
  proto_tree_add_item(tree, hf_netsync_cmd_send_delta_ident_id, tvb,
314
2
        offset, NETSNYC_MERKLE_HASH_LENGTH, ENC_NA );
315
2
  offset += NETSNYC_MERKLE_HASH_LENGTH;
316
317
2
  return offset;
318
2
}
319
320
321
static int dissect_netsync_cmd_data(tvbuff_t *tvb,  int offset, proto_tree *tree, unsigned size _U_)
322
21
{
323
21
  uint64_t len = 0;
324
325
21
  proto_tree_add_item(tree, hf_netsync_cmd_data_type, tvb,
326
21
        offset, 1, ENC_BIG_ENDIAN );
327
21
  offset += 1;
328
329
21
  proto_tree_add_item(tree, hf_netsync_cmd_data_id, tvb,
330
21
        offset, NETSNYC_MERKLE_HASH_LENGTH, ENC_NA );
331
21
  offset += NETSNYC_MERKLE_HASH_LENGTH;
332
333
21
  proto_tree_add_item(tree, hf_netsync_cmd_data_compressed, tvb,
334
21
        offset, 1, ENC_BIG_ENDIAN );
335
21
  offset += 1;
336
337
21
  offset += tvb_get_varint( tvb, offset, FT_VARINT_MAX_LEN, &len, ENC_VARINT_PROTOBUF );
338
21
  proto_tree_add_item(tree, hf_netsync_cmd_data_payload, tvb,
339
21
        offset, (int)len, ENC_NA );
340
21
  offset += (int)len;
341
342
21
  return offset;
343
21
}
344
345
346
static int dissect_netsync_cmd_delta(tvbuff_t *tvb,  int offset, proto_tree *tree, unsigned size _U_)
347
47
{
348
47
  uint64_t len = 0;
349
350
47
  proto_tree_add_item(tree, hf_netsync_cmd_delta_type, tvb,
351
47
        offset, 1, ENC_BIG_ENDIAN );
352
47
  offset += 1;
353
354
47
  proto_tree_add_item(tree, hf_netsync_cmd_delta_base_id, tvb,
355
47
        offset, NETSNYC_MERKLE_HASH_LENGTH, ENC_NA );
356
47
  offset += NETSNYC_MERKLE_HASH_LENGTH;
357
358
47
  proto_tree_add_item(tree, hf_netsync_cmd_delta_ident_id, tvb,
359
47
        offset, NETSNYC_MERKLE_HASH_LENGTH, ENC_NA );
360
47
  offset += NETSNYC_MERKLE_HASH_LENGTH;
361
362
47
  proto_tree_add_item(tree, hf_netsync_cmd_delta_compressed, tvb,
363
47
        offset, 1, ENC_BIG_ENDIAN );
364
47
  offset += 1;
365
366
47
  offset += tvb_get_varint( tvb, offset, FT_VARINT_MAX_LEN, &len, ENC_VARINT_PROTOBUF );
367
47
  proto_tree_add_item(tree, hf_netsync_cmd_delta_payload, tvb,
368
47
        offset, (int)len, ENC_NA );
369
47
  offset += (int)len;
370
371
47
  return offset;
372
47
}
373
374
375
static int dissect_netsync_cmd_nonexistent(tvbuff_t *tvb,  int offset, proto_tree *tree, unsigned size _U_)
376
10
{
377
10
  proto_tree_add_item(tree, hf_netsync_cmd_nonexistent_type, tvb,
378
10
        offset, 1, ENC_BIG_ENDIAN );
379
10
  offset += 1;
380
381
10
  proto_tree_add_item(tree, hf_netsync_cmd_nonexistent_id, tvb,
382
10
        offset, NETSNYC_MERKLE_HASH_LENGTH, ENC_NA );
383
10
  offset += NETSNYC_MERKLE_HASH_LENGTH;
384
385
10
  return offset;
386
10
}
387
388
static unsigned
389
get_netsync_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset, void *data _U_)
390
719
{
391
719
  uint64_t size = 0;
392
719
  unsigned   size_bytes;
393
394
  /* skip version and command */
395
719
  offset += 2;
396
397
719
  size_bytes = tvb_get_varint( tvb, offset, FT_VARINT_MAX_LEN, &size, ENC_VARINT_PROTOBUF );
398
399
  /* the calculated size if for the data only, this doesn't
400
   * include the version (1 byte), command (1 byte),
401
   * length (size_bytes bytes) and checksum (4 bytes)
402
   */
403
404
719
  return 1 + 1 + size_bytes + (unsigned)size + 4;
405
719
}
406
407
static int
408
dissect_netsync_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
409
713
{
410
713
  int offset = 0;
411
713
  uint8_t tmp;
412
713
  uint8_t cmd, version;
413
713
  uint32_t size, size_bytes, shift;
414
713
  proto_tree *ti,*netsync_tree=NULL;
415
416
  /* Set the protocol column */
417
713
  col_set_str(pinfo->cinfo, COL_PROTOCOL, "Netsync");
418
419
713
  if (tree == NULL)
420
0
    return tvb_captured_length(tvb);
421
422
1.10k
  while (tvb_reported_length_remaining(tvb, offset)  > 0) {
423
733
    ti = proto_tree_add_item(tree, proto_netsync, tvb, offset, -1, ENC_NA);
424
733
    netsync_tree = proto_item_add_subtree(ti, ett_netsync);
425
426
733
    version = tvb_get_uint8(tvb, offset);
427
733
    proto_tree_add_item(netsync_tree, hf_netsync_version, tvb,
428
733
          offset, 1, ENC_BIG_ENDIAN );
429
733
    offset += 1;
430
431
733
    cmd = tvb_get_uint8(tvb, offset);
432
733
    proto_tree_add_item(netsync_tree, hf_netsync_command, tvb,
433
733
          offset, 1, ENC_BIG_ENDIAN );
434
733
    offset += 1;
435
436
437
    /* get size */
438
733
    size = 0;
439
733
    size_bytes = 0;
440
733
    shift = 0;
441
903
    do {
442
903
      tmp = tvb_get_uint8(tvb, offset + size_bytes);
443
903
      size_bytes += 1;
444
445
903
      size |= (tmp & 0x7F) << shift;
446
903
      shift += 7;
447
903
    } while ((tmp & 0x80) && (shift < 32));
448
449
450
733
    proto_tree_add_uint(netsync_tree, hf_netsync_size, tvb,
451
733
            offset, size_bytes, size );
452
733
    offset += size_bytes;
453
454
733
    switch (cmd) {
455
5
      case NETSYNC_CMD_DONE:
456
5
        dissect_netsync_cmd_done( tvb, offset, netsync_tree, size );
457
5
        break;
458
459
180
      case NETSYNC_CMD_ERROR:
460
180
        dissect_netsync_cmd_error( tvb, offset, netsync_tree, size );
461
180
        break;
462
463
24
      case NETSYNC_CMD_BYE:
464
24
        dissect_netsync_cmd_bye( tvb, offset, netsync_tree, size );
465
24
        break;
466
467
63
      case NETSYNC_CMD_HELLO:
468
63
        dissect_netsync_cmd_hello( tvb, offset, netsync_tree, size );
469
63
        break;
470
471
71
      case NETSYNC_CMD_ANONYMOUS:
472
71
        dissect_netsync_cmd_anonymous( tvb, offset, netsync_tree, size );
473
71
        break;
474
475
29
      case NETSYNC_CMD_AUTH:
476
29
        dissect_netsync_cmd_auth( tvb, offset, netsync_tree, size );
477
29
        break;
478
479
37
      case NETSYNC_CMD_CONFIRM:
480
37
        dissect_netsync_cmd_confirm( tvb, offset, netsync_tree, size );
481
37
        break;
482
483
25
      case NETSYNC_CMD_REFINE:
484
25
        dissect_netsync_cmd_refine( tvb, offset, netsync_tree, size );
485
25
        break;
486
487
33
      case NETSYNC_CMD_SEND_DATA:
488
33
        dissect_netsync_cmd_send_data( tvb, offset, netsync_tree, size );
489
33
        break;
490
491
2
      case NETSYNC_CMD_SEND_DELTA:
492
2
        dissect_netsync_cmd_send_delta( tvb, offset, netsync_tree, size );
493
2
        break;
494
495
21
      case NETSYNC_CMD_DATA:
496
21
        dissect_netsync_cmd_data( tvb, offset, netsync_tree, size );
497
21
        break;
498
499
47
      case NETSYNC_CMD_DELTA:
500
47
        dissect_netsync_cmd_delta( tvb, offset, netsync_tree, size );
501
47
        break;
502
503
10
      case NETSYNC_CMD_NONEXISTENT:
504
10
        dissect_netsync_cmd_nonexistent( tvb, offset, netsync_tree, size );
505
10
        break;
506
507
168
      default:
508
168
        proto_tree_add_item(netsync_tree, hf_netsync_data, tvb,
509
168
          offset, size, ENC_NA );
510
168
        break;
511
733
    }
512
513
394
    offset += size;
514
515
394
    proto_tree_add_checksum(netsync_tree, tvb, offset, hf_netsync_checksum,
516
394
          -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS );
517
394
    offset += 4;
518
519
520
394
    proto_item_append_text(netsync_tree, " V%d, Cmd: %s (%d), Size: %d",
521
394
          version, val_to_str(pinfo->pool, cmd, netsync_cmd_vals, "(0x%x)"), cmd, size );
522
523
394
    proto_item_set_len(netsync_tree, 1+1+size_bytes+size+4);
524
394
  }
525
526
374
  return tvb_captured_length(tvb);
527
713
}
528
529
static int
530
dissect_netsync(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
531
60
{
532
60
  tcp_dissect_pdus(tvb, pinfo, tree, netsync_desegment, 7, get_netsync_pdu_len,
533
60
          dissect_netsync_pdu, data);
534
60
  return tvb_captured_length(tvb);
535
60
}
536
537
void
538
proto_register_netsync(void)
539
14
{
540
14
  static hf_register_info hf[] = {
541
    /* General */
542
14
    { &hf_netsync_version,
543
14
      { "Version", "netsync.version",
544
14
        FT_UINT8, BASE_DEC, NULL, 0x0,
545
14
        NULL, HFILL } },
546
14
    { &hf_netsync_command,
547
14
      { "Command", "netsync.command",
548
14
        FT_UINT8, BASE_HEX, VALS(netsync_cmd_vals), 0x0,
549
14
        NULL, HFILL } },
550
14
    { &hf_netsync_size,
551
14
      { "Size", "netsync.size",
552
14
        FT_UINT32, BASE_DEC, NULL, 0x0,
553
14
        NULL, HFILL } },
554
14
    { &hf_netsync_data,
555
14
      { "Data", "netsync.data",
556
14
        FT_BYTES, BASE_NONE, NULL, 0x0,
557
14
        NULL, HFILL } },
558
14
    { &hf_netsync_checksum,
559
14
      { "Checksum", "netsync.checksum",
560
14
        FT_UINT32, BASE_HEX, NULL, 0x0,
561
14
        NULL, HFILL } },
562
14
    { &hf_netsync_cmd_hello_keyname,
563
14
      { "Key Name", "netsync.cmd.hello.keyname",
564
14
        FT_STRING, BASE_NONE, NULL, 0x0,
565
14
        NULL, HFILL } },
566
14
    { &hf_netsync_cmd_hello_key,
567
14
      { "Key", "netsync.cmd.hello.key",
568
14
        FT_BYTES, BASE_NONE, NULL, 0x0,
569
14
        NULL, HFILL } },
570
14
    { &hf_netsync_cmd_nonce,
571
14
      { "Nonce", "netsync.cmd.nonce",
572
14
        FT_BYTES, BASE_NONE, NULL, 0x0,
573
14
        NULL, HFILL } },
574
14
    { &hf_netsync_cmd_anonymous_role,
575
14
      { "Role", "netsync.cmd.anonymous.role",
576
14
        FT_UINT8, BASE_DEC, VALS(netsync_role_vals), 0x0,
577
14
        NULL, HFILL } },
578
14
    { &hf_netsync_cmd_anonymous_collection,
579
14
      { "Collection", "netsync.cmd.anonymous.collection",
580
14
        FT_STRING, BASE_NONE, NULL, 0x0,
581
14
        NULL, HFILL } },
582
14
    { &hf_netsync_cmd_confirm_sig,
583
14
      { "Signature", "netsync.cmd.confirm.signature",
584
14
        FT_BYTES, BASE_NONE, NULL, 0x0,
585
14
        NULL, HFILL } },
586
14
    { &hf_netsync_cmd_send_data_type,
587
14
      { "Type", "netsync.cmd.send_data.type",
588
14
        FT_UINT8, BASE_DEC, NULL, 0x0,
589
14
        NULL, HFILL } },
590
14
    { &hf_netsync_cmd_send_data_id,
591
14
      { "ID", "netsync.cmd.send_data.id",
592
14
        FT_BYTES, BASE_NONE, NULL, 0x0,
593
14
        NULL, HFILL } },
594
14
    { &hf_netsync_cmd_error_msg,
595
14
      { "Message", "netsync.cmd.error.msg",
596
14
        FT_STRING, BASE_NONE, NULL, 0x0,
597
14
        NULL, HFILL } },
598
599
14
    { &hf_netsync_cmd_done_level,
600
14
      { "Level", "netsync.cmd.done.level",
601
14
        FT_UINT32, BASE_DEC, NULL, 0x0,
602
14
        NULL, HFILL } },
603
14
    { &hf_netsync_cmd_auth_role,
604
14
      { "Role", "netsync.cmd.auth.role",
605
14
        FT_UINT8, BASE_DEC, VALS(netsync_role_vals), 0x0,
606
14
        NULL, HFILL } },
607
14
    { &hf_netsync_cmd_auth_collection,
608
14
      { "Collection", "netsync.cmd.auth.collection",
609
14
        FT_STRING, BASE_NONE, NULL, 0x0,
610
14
        NULL, HFILL } },
611
14
    { &hf_netsync_cmd_auth_id,
612
14
      { "ID", "netsync.cmd.auth.id",
613
14
        FT_BYTES, BASE_NONE, NULL, 0x0,
614
14
        NULL, HFILL } },
615
14
    { &hf_netsync_cmd_auth_nonce1,
616
14
      { "Nonce 1", "netsync.cmd.auth.nonce1",
617
14
        FT_BYTES, BASE_NONE, NULL, 0x0,
618
14
        NULL, HFILL } },
619
14
    { &hf_netsync_cmd_auth_nonce2,
620
14
      { "Nonce 2", "netsync.cmd.auth.nonce2",
621
14
        FT_BYTES, BASE_NONE, NULL, 0x0,
622
14
        NULL, HFILL } },
623
14
    { &hf_netsync_cmd_auth_sig,
624
14
      { "Signature", "netsync.cmd.auth.sig",
625
14
        FT_BYTES, BASE_NONE, NULL, 0x0,
626
14
        NULL, HFILL } },
627
14
    { &hf_netsync_cmd_data_type,
628
14
      { "Type", "netsync.cmd.data.type",
629
14
        FT_UINT8, BASE_DEC, NULL, 0x0,
630
14
        NULL, HFILL } },
631
14
    { &hf_netsync_cmd_data_id,
632
14
      { "ID", "netsync.cmd.data.id",
633
14
        FT_BYTES, BASE_NONE, NULL, 0x0,
634
14
        NULL, HFILL } },
635
14
    { &hf_netsync_cmd_data_compressed,
636
14
      { "Compressed", "netsync.cmd.data.compressed",
637
14
        FT_UINT8, BASE_DEC, NULL, 0x0,
638
14
        NULL, HFILL } },
639
14
    { &hf_netsync_cmd_data_payload,
640
14
      { "Payload", "netsync.cmd.data.payload",
641
14
        FT_BYTES, BASE_NONE, NULL, 0x0,
642
14
        NULL, HFILL } },
643
14
    { &hf_netsync_cmd_delta_type,
644
14
      { "Type", "netsync.cmd.delta.type",
645
14
        FT_UINT8, BASE_DEC, NULL, 0x0,
646
14
        NULL, HFILL } },
647
14
    { &hf_netsync_cmd_delta_base_id,
648
14
      { "Base ID", "netsync.cmd.delta.base_id",
649
14
        FT_BYTES, BASE_NONE, NULL, 0x0,
650
14
        NULL, HFILL } },
651
14
    { &hf_netsync_cmd_delta_ident_id,
652
14
      { "Ident ID", "netsync.cmd.delta.ident_id",
653
14
        FT_BYTES, BASE_NONE, NULL, 0x0,
654
14
        NULL, HFILL } },
655
14
    { &hf_netsync_cmd_delta_compressed,
656
14
      { "Compressed", "netsync.cmd.delta.compressed",
657
14
        FT_UINT8, BASE_DEC, NULL, 0x0,
658
14
        NULL, HFILL } },
659
14
    { &hf_netsync_cmd_delta_payload,
660
14
      { "Payload", "netsync.cmd.delta.payload",
661
14
        FT_BYTES, BASE_NONE, NULL, 0x0,
662
14
        NULL, HFILL } },
663
14
    { &hf_netsync_cmd_refine_tree_node,
664
14
      { "Tree Node", "netsync.cmd.refine.tree_node",
665
14
        FT_BYTES, BASE_NONE, NULL, 0x0,
666
14
        NULL, HFILL } },
667
14
    { &hf_netsync_cmd_send_delta_type,
668
14
      { "Type", "netsync.cmd.send_delta.type",
669
14
        FT_UINT8, BASE_DEC, NULL, 0x0,
670
14
        NULL, HFILL } },
671
14
    { &hf_netsync_cmd_send_delta_base_id,
672
14
      { "Base ID", "netsync.cmd.send_delta.base_id",
673
14
        FT_BYTES, BASE_NONE, NULL, 0x0,
674
14
        NULL, HFILL } },
675
14
    { &hf_netsync_cmd_send_delta_ident_id,
676
14
      { "Ident ID", "netsync.cmd.send_delta.ident_id",
677
14
        FT_BYTES, BASE_NONE, NULL, 0x0,
678
14
        NULL, HFILL } },
679
14
    { &hf_netsync_cmd_nonexistent_id,
680
14
      { "ID", "netsync.cmd.nonexistent.id",
681
14
        FT_BYTES, BASE_NONE, NULL, 0x0,
682
14
        NULL, HFILL } },
683
14
    { &hf_netsync_cmd_nonexistent_type,
684
14
      { "Type", "netsync.cmd.nonexistent.type",
685
14
        FT_UINT8, BASE_DEC, NULL, 0x0,
686
14
        NULL, HFILL } },
687
14
    { &hf_netsync_cmd_done_type,
688
14
      { "Type", "netsync.cmd.done.type",
689
14
        FT_UINT8, BASE_DEC, NULL, 0x0,
690
14
        NULL, HFILL } }
691
692
693
14
  };
694
695
14
  static int *ett[] = {
696
14
    &ett_netsync,
697
14
  };
698
699
14
  module_t *netsync_module;
700
701
14
  proto_netsync = proto_register_protocol("Monotone Netsync", "Netsync", "netsync");
702
14
  proto_register_field_array(proto_netsync, hf, array_length(hf));
703
14
  proto_register_subtree_array(ett, array_length(ett));
704
705
14
  netsync_module = prefs_register_protocol(proto_netsync, NULL);
706
707
14
  prefs_register_bool_preference(netsync_module, "desegment_netsync_messages",
708
14
    "Reassemble Netsync messages spanning multiple TCP segments",
709
14
    "Whether the Netsync dissector should reassemble messages spanning multiple TCP segments."
710
14
    " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
711
14
    &netsync_desegment);
712
713
14
  netsync_handle = register_dissector("netsync", dissect_netsync, proto_netsync);
714
14
}
715
716
void
717
proto_reg_handoff_netsync(void)
718
14
{
719
14
  dissector_add_uint_with_preference("tcp.port", TCP_PORT_NETSYNC, netsync_handle);
720
14
}
721
722
/*
723
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
724
 *
725
 * Local variables:
726
 * c-basic-offset: 8
727
 * tab-width: 8
728
 * indent-tabs-mode: t
729
 * End:
730
 *
731
 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
732
 * :indentSize=8:tabSize=8:noTabs=false:
733
 */