Coverage Report

Created: 2026-03-30 07:00

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
116
#define NETSYNC_CMD_ERROR 0
49
7
#define NETSYNC_CMD_BYE   1
50
12
#define NETSYNC_CMD_HELLO 2
51
34
#define NETSYNC_CMD_ANONYMOUS 3
52
8
#define NETSYNC_CMD_AUTH  4
53
9
#define NETSYNC_CMD_CONFIRM 5
54
2
#define NETSYNC_CMD_REFINE  6
55
2
#define NETSYNC_CMD_DONE  7
56
1
#define NETSYNC_CMD_SEND_DATA 8
57
1
#define NETSYNC_CMD_SEND_DELTA  9
58
9
#define NETSYNC_CMD_DATA  10
59
8
#define NETSYNC_CMD_DELTA 11
60
0
#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
196
#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
116
{
148
116
  uint64_t len = 0;
149
150
116
  offset += tvb_get_varint( tvb, offset, FT_VARINT_MAX_LEN, &len, ENC_VARINT_PROTOBUF );
151
152
116
  proto_tree_add_item(tree, hf_netsync_cmd_error_msg, tvb,
153
116
        offset, (int)len, ENC_ASCII );
154
116
  offset += (int)len;
155
156
116
  return offset;
157
116
}
158
159
static int dissect_netsync_cmd_bye(tvbuff_t *tvb _U_,  int offset, proto_tree *tree _U_, unsigned size _U_)
160
7
{
161
7
  return offset;
162
7
}
163
164
165
static int dissect_netsync_cmd_hello(tvbuff_t *tvb,  int offset, proto_tree *tree, unsigned size _U_)
166
12
{
167
12
  uint64_t len = 0;
168
169
12
  offset += tvb_get_varint( tvb, offset, FT_VARINT_MAX_LEN, &len, ENC_VARINT_PROTOBUF );
170
12
  proto_tree_add_item(tree, hf_netsync_cmd_hello_keyname, tvb,
171
12
        offset, (int)len, ENC_ASCII );
172
12
  offset += (int)len;
173
174
175
12
  offset += tvb_get_varint( tvb, offset, FT_VARINT_MAX_LEN, &len, ENC_VARINT_PROTOBUF );
176
12
  proto_tree_add_item(tree, hf_netsync_cmd_hello_key, tvb,
177
12
        offset, (int)len, ENC_NA );
178
12
  offset += (int)len;
179
180
12
  proto_tree_add_item(tree, hf_netsync_cmd_nonce, tvb,
181
12
        offset, NETSNYC_MERKLE_HASH_LENGTH, ENC_NA );
182
12
  offset += NETSNYC_MERKLE_HASH_LENGTH;
183
184
12
  return offset;
185
12
}
186
187
188
static int dissect_netsync_cmd_anonymous(tvbuff_t *tvb,  int offset, proto_tree *tree, unsigned size _U_)
189
34
{
190
34
  uint64_t len = 0;
191
192
34
  proto_tree_add_item(tree, hf_netsync_cmd_anonymous_role, tvb,
193
34
        offset, 1, ENC_BIG_ENDIAN );
194
34
  offset += 1;
195
196
34
  offset += tvb_get_varint( tvb, offset, FT_VARINT_MAX_LEN, &len, ENC_VARINT_PROTOBUF );
197
34
  proto_tree_add_item(tree, hf_netsync_cmd_anonymous_collection, tvb,
198
34
        offset, (int)len, ENC_ASCII );
199
34
  offset += (int)len;
200
201
34
  proto_tree_add_item(tree, hf_netsync_cmd_nonce, tvb,
202
34
        offset, NETSNYC_MERKLE_HASH_LENGTH, ENC_NA );
203
34
  offset += NETSNYC_MERKLE_HASH_LENGTH;
204
205
34
  return offset;
206
34
}
207
208
209
static int dissect_netsync_cmd_auth(tvbuff_t *tvb,  int offset, proto_tree *tree, unsigned size _U_)
210
8
{
211
8
  uint64_t len = 0;
212
213
8
  proto_tree_add_item(tree, hf_netsync_cmd_auth_role, tvb,
214
8
        offset, 1, ENC_BIG_ENDIAN );
215
8
  offset += 1;
216
217
218
8
  offset += tvb_get_varint( tvb, offset, FT_VARINT_MAX_LEN, &len, ENC_VARINT_PROTOBUF );
219
8
  proto_tree_add_item(tree, hf_netsync_cmd_auth_collection, tvb,
220
8
        offset, (int)len, ENC_ASCII );
221
8
  offset += (int)len;
222
223
8
  proto_tree_add_item(tree, hf_netsync_cmd_auth_id, tvb,
224
8
        offset, NETSNYC_MERKLE_HASH_LENGTH, ENC_NA );
225
8
  offset += NETSNYC_MERKLE_HASH_LENGTH;
226
227
8
  offset += (int)len;
228
229
8
  proto_tree_add_item(tree, hf_netsync_cmd_auth_nonce1, tvb,
230
8
        offset, NETSNYC_MERKLE_HASH_LENGTH, ENC_NA );
231
8
  offset += NETSNYC_MERKLE_HASH_LENGTH;
232
233
8
  offset += (int)len;
234
235
8
  proto_tree_add_item(tree, hf_netsync_cmd_auth_nonce2, tvb,
236
8
        offset, NETSNYC_MERKLE_HASH_LENGTH, ENC_NA );
237
8
  offset += NETSNYC_MERKLE_HASH_LENGTH;
238
239
8
  offset += tvb_get_varint( tvb, offset, FT_VARINT_MAX_LEN, &len, ENC_VARINT_PROTOBUF );
240
8
  proto_tree_add_item(tree, hf_netsync_cmd_auth_sig, tvb,
241
8
        offset, (int)len, ENC_NA );
242
8
  offset += (int)len;
243
244
8
  return offset;
245
8
}
246
247
248
static int dissect_netsync_cmd_confirm(tvbuff_t *tvb,  int offset, proto_tree *tree, unsigned size _U_)
249
9
{
250
9
  uint64_t len = 0;
251
252
9
  offset += tvb_get_varint( tvb, offset, FT_VARINT_MAX_LEN, &len, ENC_VARINT_PROTOBUF );
253
9
  proto_tree_add_item(tree, hf_netsync_cmd_confirm_sig, tvb,
254
9
        offset, (int)len, ENC_NA );
255
9
  offset += (int)len;
256
257
258
9
  return offset;
259
9
}
260
261
262
static int dissect_netsync_cmd_refine(tvbuff_t *tvb,  int offset, proto_tree *tree, unsigned size)
263
2
{
264
2
  proto_tree_add_item(tree, hf_netsync_cmd_refine_tree_node, tvb,
265
2
        offset, size, ENC_NA );
266
2
  offset += size;
267
268
2
  return offset;
269
2
}
270
271
272
static int dissect_netsync_cmd_done(tvbuff_t *tvb,  int offset, proto_tree *tree, unsigned size _U_)
273
2
{
274
2
  int bytes = 0;
275
276
2
  proto_tree_add_item_ret_length(tree, hf_netsync_cmd_done_level, tvb,
277
2
          offset, -1, ENC_LITTLE_ENDIAN|ENC_VARINT_PROTOBUF, &bytes);
278
2
  offset += bytes;
279
280
2
  proto_tree_add_item(tree, hf_netsync_cmd_done_type, tvb,
281
2
        offset, 1, ENC_BIG_ENDIAN );
282
2
  offset += 1;
283
284
2
  return offset;
285
2
}
286
287
288
static int dissect_netsync_cmd_send_data(tvbuff_t *tvb,  int offset, proto_tree *tree, unsigned size _U_)
289
1
{
290
1
  proto_tree_add_item(tree, hf_netsync_cmd_send_data_type, tvb,
291
1
          offset, 1, ENC_BIG_ENDIAN );
292
1
  offset += 1;
293
294
1
  proto_tree_add_item(tree, hf_netsync_cmd_send_data_id, tvb,
295
1
        offset, NETSNYC_MERKLE_HASH_LENGTH, ENC_NA );
296
1
  offset += NETSNYC_MERKLE_HASH_LENGTH;
297
298
1
  return offset;
299
1
}
300
301
302
static int dissect_netsync_cmd_send_delta(tvbuff_t *tvb,  int offset, proto_tree *tree, unsigned size _U_)
303
1
{
304
1
  proto_tree_add_item(tree, hf_netsync_cmd_send_delta_type, tvb,
305
1
          offset, 1, ENC_BIG_ENDIAN );
306
1
  offset += 1;
307
308
1
  proto_tree_add_item(tree, hf_netsync_cmd_send_delta_base_id, tvb,
309
1
        offset, NETSNYC_MERKLE_HASH_LENGTH, ENC_NA );
310
1
  offset += NETSNYC_MERKLE_HASH_LENGTH;
311
312
313
1
  proto_tree_add_item(tree, hf_netsync_cmd_send_delta_ident_id, tvb,
314
1
        offset, NETSNYC_MERKLE_HASH_LENGTH, ENC_NA );
315
1
  offset += NETSNYC_MERKLE_HASH_LENGTH;
316
317
1
  return offset;
318
1
}
319
320
321
static int dissect_netsync_cmd_data(tvbuff_t *tvb,  int offset, proto_tree *tree, unsigned size _U_)
322
9
{
323
9
  uint64_t len = 0;
324
325
9
  proto_tree_add_item(tree, hf_netsync_cmd_data_type, tvb,
326
9
        offset, 1, ENC_BIG_ENDIAN );
327
9
  offset += 1;
328
329
9
  proto_tree_add_item(tree, hf_netsync_cmd_data_id, tvb,
330
9
        offset, NETSNYC_MERKLE_HASH_LENGTH, ENC_NA );
331
9
  offset += NETSNYC_MERKLE_HASH_LENGTH;
332
333
9
  proto_tree_add_item(tree, hf_netsync_cmd_data_compressed, tvb,
334
9
        offset, 1, ENC_BIG_ENDIAN );
335
9
  offset += 1;
336
337
9
  offset += tvb_get_varint( tvb, offset, FT_VARINT_MAX_LEN, &len, ENC_VARINT_PROTOBUF );
338
9
  proto_tree_add_item(tree, hf_netsync_cmd_data_payload, tvb,
339
9
        offset, (int)len, ENC_NA );
340
9
  offset += (int)len;
341
342
9
  return offset;
343
9
}
344
345
346
static int dissect_netsync_cmd_delta(tvbuff_t *tvb,  int offset, proto_tree *tree, unsigned size _U_)
347
8
{
348
8
  uint64_t len = 0;
349
350
8
  proto_tree_add_item(tree, hf_netsync_cmd_delta_type, tvb,
351
8
        offset, 1, ENC_BIG_ENDIAN );
352
8
  offset += 1;
353
354
8
  proto_tree_add_item(tree, hf_netsync_cmd_delta_base_id, tvb,
355
8
        offset, NETSNYC_MERKLE_HASH_LENGTH, ENC_NA );
356
8
  offset += NETSNYC_MERKLE_HASH_LENGTH;
357
358
8
  proto_tree_add_item(tree, hf_netsync_cmd_delta_ident_id, tvb,
359
8
        offset, NETSNYC_MERKLE_HASH_LENGTH, ENC_NA );
360
8
  offset += NETSNYC_MERKLE_HASH_LENGTH;
361
362
8
  proto_tree_add_item(tree, hf_netsync_cmd_delta_compressed, tvb,
363
8
        offset, 1, ENC_BIG_ENDIAN );
364
8
  offset += 1;
365
366
8
  offset += tvb_get_varint( tvb, offset, FT_VARINT_MAX_LEN, &len, ENC_VARINT_PROTOBUF );
367
8
  proto_tree_add_item(tree, hf_netsync_cmd_delta_payload, tvb,
368
8
        offset, (int)len, ENC_NA );
369
8
  offset += (int)len;
370
371
8
  return offset;
372
8
}
373
374
375
static int dissect_netsync_cmd_nonexistent(tvbuff_t *tvb,  int offset, proto_tree *tree, unsigned size _U_)
376
0
{
377
0
  proto_tree_add_item(tree, hf_netsync_cmd_nonexistent_type, tvb,
378
0
        offset, 1, ENC_BIG_ENDIAN );
379
0
  offset += 1;
380
381
0
  proto_tree_add_item(tree, hf_netsync_cmd_nonexistent_id, tvb,
382
0
        offset, NETSNYC_MERKLE_HASH_LENGTH, ENC_NA );
383
0
  offset += NETSNYC_MERKLE_HASH_LENGTH;
384
385
0
  return offset;
386
0
}
387
388
static unsigned
389
get_netsync_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset, void *data _U_)
390
245
{
391
245
  uint64_t size = 0;
392
245
  unsigned   size_bytes;
393
394
  /* skip version and command */
395
245
  offset += 2;
396
397
245
  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
245
  return 1 + 1 + size_bytes + (unsigned)size + 4;
405
245
}
406
407
static int
408
dissect_netsync_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
409
243
{
410
243
  int offset = 0;
411
243
  uint8_t tmp;
412
243
  uint8_t cmd, version;
413
243
  uint32_t size, size_bytes, shift;
414
243
  proto_tree *ti,*netsync_tree=NULL;
415
416
  /* Set the protocol column */
417
243
  col_set_str(pinfo->cinfo, COL_PROTOCOL, "Netsync");
418
419
243
  if (tree == NULL)
420
0
    return tvb_captured_length(tvb);
421
422
397
  while (tvb_reported_length_remaining(tvb, offset)  > 0) {
423
245
    ti = proto_tree_add_item(tree, proto_netsync, tvb, offset, -1, ENC_NA);
424
245
    netsync_tree = proto_item_add_subtree(ti, ett_netsync);
425
426
245
    version = tvb_get_uint8(tvb, offset);
427
245
    proto_tree_add_item(netsync_tree, hf_netsync_version, tvb,
428
245
          offset, 1, ENC_BIG_ENDIAN );
429
245
    offset += 1;
430
431
245
    cmd = tvb_get_uint8(tvb, offset);
432
245
    proto_tree_add_item(netsync_tree, hf_netsync_command, tvb,
433
245
          offset, 1, ENC_BIG_ENDIAN );
434
245
    offset += 1;
435
436
437
    /* get size */
438
245
    size = 0;
439
245
    size_bytes = 0;
440
245
    shift = 0;
441
285
    do {
442
285
      tmp = tvb_get_uint8(tvb, offset + size_bytes);
443
285
      size_bytes += 1;
444
445
285
      size |= (tmp & 0x7F) << shift;
446
285
      shift += 7;
447
285
    } while ((tmp & 0x80) && (shift < 32));
448
449
450
245
    proto_tree_add_uint(netsync_tree, hf_netsync_size, tvb,
451
245
            offset, size_bytes, size );
452
245
    offset += size_bytes;
453
454
245
    switch (cmd) {
455
2
      case NETSYNC_CMD_DONE:
456
2
        dissect_netsync_cmd_done( tvb, offset, netsync_tree, size );
457
2
        break;
458
459
116
      case NETSYNC_CMD_ERROR:
460
116
        dissect_netsync_cmd_error( tvb, offset, netsync_tree, size );
461
116
        break;
462
463
7
      case NETSYNC_CMD_BYE:
464
7
        dissect_netsync_cmd_bye( tvb, offset, netsync_tree, size );
465
7
        break;
466
467
12
      case NETSYNC_CMD_HELLO:
468
12
        dissect_netsync_cmd_hello( tvb, offset, netsync_tree, size );
469
12
        break;
470
471
34
      case NETSYNC_CMD_ANONYMOUS:
472
34
        dissect_netsync_cmd_anonymous( tvb, offset, netsync_tree, size );
473
34
        break;
474
475
8
      case NETSYNC_CMD_AUTH:
476
8
        dissect_netsync_cmd_auth( tvb, offset, netsync_tree, size );
477
8
        break;
478
479
9
      case NETSYNC_CMD_CONFIRM:
480
9
        dissect_netsync_cmd_confirm( tvb, offset, netsync_tree, size );
481
9
        break;
482
483
2
      case NETSYNC_CMD_REFINE:
484
2
        dissect_netsync_cmd_refine( tvb, offset, netsync_tree, size );
485
2
        break;
486
487
1
      case NETSYNC_CMD_SEND_DATA:
488
1
        dissect_netsync_cmd_send_data( tvb, offset, netsync_tree, size );
489
1
        break;
490
491
1
      case NETSYNC_CMD_SEND_DELTA:
492
1
        dissect_netsync_cmd_send_delta( tvb, offset, netsync_tree, size );
493
1
        break;
494
495
9
      case NETSYNC_CMD_DATA:
496
9
        dissect_netsync_cmd_data( tvb, offset, netsync_tree, size );
497
9
        break;
498
499
8
      case NETSYNC_CMD_DELTA:
500
8
        dissect_netsync_cmd_delta( tvb, offset, netsync_tree, size );
501
8
        break;
502
503
0
      case NETSYNC_CMD_NONEXISTENT:
504
0
        dissect_netsync_cmd_nonexistent( tvb, offset, netsync_tree, size );
505
0
        break;
506
507
34
      default:
508
34
        proto_tree_add_item(netsync_tree, hf_netsync_data, tvb,
509
34
          offset, size, ENC_NA );
510
34
        break;
511
245
    }
512
513
154
    offset += size;
514
515
154
    proto_tree_add_checksum(netsync_tree, tvb, offset, hf_netsync_checksum,
516
154
          -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS );
517
154
    offset += 4;
518
519
520
154
    proto_item_append_text(netsync_tree, " V%d, Cmd: %s (%d), Size: %d",
521
154
          version, val_to_str(pinfo->pool, cmd, netsync_cmd_vals, "(0x%x)"), cmd, size );
522
523
154
    proto_item_set_len(netsync_tree, 1+1+size_bytes+size+4);
524
154
  }
525
526
152
  return tvb_captured_length(tvb);
527
243
}
528
529
static int
530
dissect_netsync(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
531
17
{
532
17
  tcp_dissect_pdus(tvb, pinfo, tree, netsync_desegment, 7, get_netsync_pdu_len,
533
17
          dissect_netsync_pdu, data);
534
17
  return tvb_captured_length(tvb);
535
17
}
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
 */