Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-netsync.c
blob25c8eaa90baf1a8d37a495bb47f118afedfc7337
1 /* packet-netsync.c
2 * Routines for Monotone Netsync packet disassembly
4 * Copyright (c) 2005 by Erwin Rol <erwin@erwinrol.com>
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1999 Gerald Combs
10 * SPDX-License-Identifier: GPL-2.0-or-later
13 /* Include files */
15 #include "config.h"
17 #include <epan/packet.h>
18 #include <epan/prefs.h>
19 #include "packet-tcp.h"
21 void proto_register_netsync(void);
22 void proto_reg_handoff_netsync(void);
24 static dissector_handle_t netsync_handle;
27 * See
29 * http://www.monotone.ca
32 /* Define TCP ports for Monotone netsync */
34 #define TCP_PORT_NETSYNC 5253
36 #define NETSYNC_ROLE_SOURCE 1
37 #define NETSYNC_ROLE_SINK 2
38 #define NETSYNC_ROLE_BOTH 3
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 }
48 #define NETSYNC_CMD_ERROR 0
49 #define NETSYNC_CMD_BYE 1
50 #define NETSYNC_CMD_HELLO 2
51 #define NETSYNC_CMD_ANONYMOUS 3
52 #define NETSYNC_CMD_AUTH 4
53 #define NETSYNC_CMD_CONFIRM 5
54 #define NETSYNC_CMD_REFINE 6
55 #define NETSYNC_CMD_DONE 7
56 #define NETSYNC_CMD_SEND_DATA 8
57 #define NETSYNC_CMD_SEND_DELTA 9
58 #define NETSYNC_CMD_DATA 10
59 #define NETSYNC_CMD_DELTA 11
60 #define NETSYNC_CMD_NONEXISTENT 12
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 }
79 #define NETSNYC_MERKLE_HASH_LENGTH 20
81 /* Define the monotone netsync proto */
82 static int proto_netsync;
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;
90 static int hf_netsync_cmd_done_level;
91 static int hf_netsync_cmd_done_type;
93 static int hf_netsync_cmd_hello_keyname;
94 static int hf_netsync_cmd_hello_key;
95 static int hf_netsync_cmd_nonce;
97 static int hf_netsync_cmd_anonymous_role;
98 static int hf_netsync_cmd_anonymous_collection;
100 static int hf_netsync_cmd_send_data_type;
101 static int hf_netsync_cmd_send_data_id;
103 static int hf_netsync_cmd_error_msg;
106 static int hf_netsync_cmd_confirm_sig;
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;
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;
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;
126 static int hf_netsync_cmd_refine_tree_node;
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;
132 static int hf_netsync_cmd_nonexistent_type;
133 static int hf_netsync_cmd_nonexistent_id;
135 /* Define the tree for netsync */
136 static int ett_netsync;
140 * Here are the global variables associated with the preferences
141 * for monotone netsync
144 static bool netsync_desegment = true;
146 static int dissect_netsync_cmd_error( tvbuff_t *tvb, int offset, proto_tree *tree, unsigned size _U_)
148 uint64_t len = 0;
150 offset += tvb_get_varint( tvb, offset, FT_VARINT_MAX_LEN, &len, ENC_VARINT_PROTOBUF );
152 proto_tree_add_item(tree, hf_netsync_cmd_error_msg, tvb,
153 offset, (int)len, ENC_ASCII );
154 offset += (int)len;
156 return offset;
159 static int dissect_netsync_cmd_bye(tvbuff_t *tvb _U_, int offset, proto_tree *tree _U_, unsigned size _U_)
161 return offset;
165 static int dissect_netsync_cmd_hello(tvbuff_t *tvb, int offset, proto_tree *tree, unsigned size _U_)
167 uint64_t len = 0;
169 offset += tvb_get_varint( tvb, offset, FT_VARINT_MAX_LEN, &len, ENC_VARINT_PROTOBUF );
170 proto_tree_add_item(tree, hf_netsync_cmd_hello_keyname, tvb,
171 offset, (int)len, ENC_ASCII );
172 offset += (int)len;
175 offset += tvb_get_varint( tvb, offset, FT_VARINT_MAX_LEN, &len, ENC_VARINT_PROTOBUF );
176 proto_tree_add_item(tree, hf_netsync_cmd_hello_key, tvb,
177 offset, (int)len, ENC_NA );
178 offset += (int)len;
180 proto_tree_add_item(tree, hf_netsync_cmd_nonce, tvb,
181 offset, NETSNYC_MERKLE_HASH_LENGTH, ENC_NA );
182 offset += NETSNYC_MERKLE_HASH_LENGTH;
184 return offset;
188 static int dissect_netsync_cmd_anonymous(tvbuff_t *tvb, int offset, proto_tree *tree, unsigned size _U_)
190 uint64_t len = 0;
192 proto_tree_add_item(tree, hf_netsync_cmd_anonymous_role, tvb,
193 offset, 1, ENC_BIG_ENDIAN );
194 offset += 1;
196 offset += tvb_get_varint( tvb, offset, FT_VARINT_MAX_LEN, &len, ENC_VARINT_PROTOBUF );
197 proto_tree_add_item(tree, hf_netsync_cmd_anonymous_collection, tvb,
198 offset, (int)len, ENC_ASCII );
199 offset += (int)len;
201 proto_tree_add_item(tree, hf_netsync_cmd_nonce, tvb,
202 offset, NETSNYC_MERKLE_HASH_LENGTH, ENC_NA );
203 offset += NETSNYC_MERKLE_HASH_LENGTH;
205 return offset;
209 static int dissect_netsync_cmd_auth(tvbuff_t *tvb, int offset, proto_tree *tree, unsigned size _U_)
211 uint64_t len = 0;
213 proto_tree_add_item(tree, hf_netsync_cmd_auth_role, tvb,
214 offset, 1, ENC_BIG_ENDIAN );
215 offset += 1;
218 offset += tvb_get_varint( tvb, offset, FT_VARINT_MAX_LEN, &len, ENC_VARINT_PROTOBUF );
219 proto_tree_add_item(tree, hf_netsync_cmd_auth_collection, tvb,
220 offset, (int)len, ENC_ASCII );
221 offset += (int)len;
223 proto_tree_add_item(tree, hf_netsync_cmd_auth_id, tvb,
224 offset, NETSNYC_MERKLE_HASH_LENGTH, ENC_NA );
225 offset += NETSNYC_MERKLE_HASH_LENGTH;
227 offset += (int)len;
229 proto_tree_add_item(tree, hf_netsync_cmd_auth_nonce1, tvb,
230 offset, NETSNYC_MERKLE_HASH_LENGTH, ENC_NA );
231 offset += NETSNYC_MERKLE_HASH_LENGTH;
233 offset += (int)len;
235 proto_tree_add_item(tree, hf_netsync_cmd_auth_nonce2, tvb,
236 offset, NETSNYC_MERKLE_HASH_LENGTH, ENC_NA );
237 offset += NETSNYC_MERKLE_HASH_LENGTH;
239 offset += tvb_get_varint( tvb, offset, FT_VARINT_MAX_LEN, &len, ENC_VARINT_PROTOBUF );
240 proto_tree_add_item(tree, hf_netsync_cmd_auth_sig, tvb,
241 offset, (int)len, ENC_NA );
242 offset += (int)len;
244 return offset;
248 static int dissect_netsync_cmd_confirm(tvbuff_t *tvb, int offset, proto_tree *tree, unsigned size _U_)
250 uint64_t len = 0;
252 offset += tvb_get_varint( tvb, offset, FT_VARINT_MAX_LEN, &len, ENC_VARINT_PROTOBUF );
253 proto_tree_add_item(tree, hf_netsync_cmd_confirm_sig, tvb,
254 offset, (int)len, ENC_NA );
255 offset += (int)len;
258 return offset;
262 static int dissect_netsync_cmd_refine(tvbuff_t *tvb, int offset, proto_tree *tree, unsigned size)
264 proto_tree_add_item(tree, hf_netsync_cmd_refine_tree_node, tvb,
265 offset, size, ENC_NA );
266 offset += size;
268 return offset;
272 static int dissect_netsync_cmd_done(tvbuff_t *tvb, int offset, proto_tree *tree, unsigned size _U_)
274 int bytes = 0;
276 proto_tree_add_item_ret_length(tree, hf_netsync_cmd_done_level, tvb,
277 offset, -1, ENC_LITTLE_ENDIAN|ENC_VARINT_PROTOBUF, &bytes);
278 offset += bytes;
280 proto_tree_add_item(tree, hf_netsync_cmd_done_type, tvb,
281 offset, 1, ENC_BIG_ENDIAN );
282 offset += 1;
284 return offset;
288 static int dissect_netsync_cmd_send_data(tvbuff_t *tvb, int offset, proto_tree *tree, unsigned size _U_)
290 proto_tree_add_item(tree, hf_netsync_cmd_send_data_type, tvb,
291 offset, 1, ENC_BIG_ENDIAN );
292 offset += 1;
294 proto_tree_add_item(tree, hf_netsync_cmd_send_data_id, tvb,
295 offset, NETSNYC_MERKLE_HASH_LENGTH, ENC_NA );
296 offset += NETSNYC_MERKLE_HASH_LENGTH;
298 return offset;
302 static int dissect_netsync_cmd_send_delta(tvbuff_t *tvb, int offset, proto_tree *tree, unsigned size _U_)
304 proto_tree_add_item(tree, hf_netsync_cmd_send_delta_type, tvb,
305 offset, 1, ENC_BIG_ENDIAN );
306 offset += 1;
308 proto_tree_add_item(tree, hf_netsync_cmd_send_delta_base_id, tvb,
309 offset, NETSNYC_MERKLE_HASH_LENGTH, ENC_NA );
310 offset += NETSNYC_MERKLE_HASH_LENGTH;
313 proto_tree_add_item(tree, hf_netsync_cmd_send_delta_ident_id, tvb,
314 offset, NETSNYC_MERKLE_HASH_LENGTH, ENC_NA );
315 offset += NETSNYC_MERKLE_HASH_LENGTH;
317 return offset;
321 static int dissect_netsync_cmd_data(tvbuff_t *tvb, int offset, proto_tree *tree, unsigned size _U_)
323 uint64_t len = 0;
325 proto_tree_add_item(tree, hf_netsync_cmd_data_type, tvb,
326 offset, 1, ENC_BIG_ENDIAN );
327 offset += 1;
329 proto_tree_add_item(tree, hf_netsync_cmd_data_id, tvb,
330 offset, NETSNYC_MERKLE_HASH_LENGTH, ENC_NA );
331 offset += NETSNYC_MERKLE_HASH_LENGTH;
333 proto_tree_add_item(tree, hf_netsync_cmd_data_compressed, tvb,
334 offset, 1, ENC_BIG_ENDIAN );
335 offset += 1;
337 offset += tvb_get_varint( tvb, offset, FT_VARINT_MAX_LEN, &len, ENC_VARINT_PROTOBUF );
338 proto_tree_add_item(tree, hf_netsync_cmd_data_payload, tvb,
339 offset, (int)len, ENC_NA );
340 offset += (int)len;
342 return offset;
346 static int dissect_netsync_cmd_delta(tvbuff_t *tvb, int offset, proto_tree *tree, unsigned size _U_)
348 uint64_t len = 0;
350 proto_tree_add_item(tree, hf_netsync_cmd_delta_type, tvb,
351 offset, 1, ENC_BIG_ENDIAN );
352 offset += 1;
354 proto_tree_add_item(tree, hf_netsync_cmd_delta_base_id, tvb,
355 offset, NETSNYC_MERKLE_HASH_LENGTH, ENC_NA );
356 offset += NETSNYC_MERKLE_HASH_LENGTH;
358 proto_tree_add_item(tree, hf_netsync_cmd_delta_ident_id, tvb,
359 offset, NETSNYC_MERKLE_HASH_LENGTH, ENC_NA );
360 offset += NETSNYC_MERKLE_HASH_LENGTH;
362 proto_tree_add_item(tree, hf_netsync_cmd_delta_compressed, tvb,
363 offset, 1, ENC_BIG_ENDIAN );
364 offset += 1;
366 offset += tvb_get_varint( tvb, offset, FT_VARINT_MAX_LEN, &len, ENC_VARINT_PROTOBUF );
367 proto_tree_add_item(tree, hf_netsync_cmd_delta_payload, tvb,
368 offset, (int)len, ENC_NA );
369 offset += (int)len;
371 return offset;
375 static int dissect_netsync_cmd_nonexistent(tvbuff_t *tvb, int offset, proto_tree *tree, unsigned size _U_)
377 proto_tree_add_item(tree, hf_netsync_cmd_nonexistent_type, tvb,
378 offset, 1, ENC_BIG_ENDIAN );
379 offset += 1;
381 proto_tree_add_item(tree, hf_netsync_cmd_nonexistent_id, tvb,
382 offset, NETSNYC_MERKLE_HASH_LENGTH, ENC_NA );
383 offset += NETSNYC_MERKLE_HASH_LENGTH;
385 return offset;
388 static unsigned
389 get_netsync_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset, void *data _U_)
391 uint64_t size = 0;
392 unsigned size_bytes;
394 /* skip version and command */
395 offset += 2;
397 size_bytes = tvb_get_varint( tvb, offset, FT_VARINT_MAX_LEN, &size, ENC_VARINT_PROTOBUF );
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)
404 return 1 + 1 + size_bytes + (unsigned)size + 4;
407 static int
408 dissect_netsync_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
410 int offset = 0;
411 uint8_t tmp;
412 uint8_t cmd, version;
413 uint32_t size, size_bytes, shift;
414 proto_tree *ti,*netsync_tree=NULL;
416 /* Set the protocol column */
417 col_set_str(pinfo->cinfo, COL_PROTOCOL, "Netsync");
419 if (tree == NULL)
420 return tvb_captured_length(tvb);
422 while (tvb_reported_length_remaining(tvb, offset) > 0) {
423 ti = proto_tree_add_item(tree, proto_netsync, tvb, offset, -1, ENC_NA);
424 netsync_tree = proto_item_add_subtree(ti, ett_netsync);
426 version = tvb_get_uint8(tvb, offset);
427 proto_tree_add_item(netsync_tree, hf_netsync_version, tvb,
428 offset, 1, ENC_BIG_ENDIAN );
429 offset += 1;
431 cmd = tvb_get_uint8(tvb, offset);
432 proto_tree_add_item(netsync_tree, hf_netsync_command, tvb,
433 offset, 1, ENC_BIG_ENDIAN );
434 offset += 1;
437 /* get size */
438 size = 0;
439 size_bytes = 0;
440 shift = 0;
441 do {
442 tmp = tvb_get_uint8(tvb, offset + size_bytes);
443 size_bytes += 1;
445 size |= (tmp & 0x7F) << shift;
446 shift += 7;
447 } while ((tmp & 0x80) && (shift < 32));
450 proto_tree_add_uint(netsync_tree, hf_netsync_size, tvb,
451 offset, size_bytes, size );
452 offset += size_bytes;
454 switch (cmd) {
455 case NETSYNC_CMD_DONE:
456 dissect_netsync_cmd_done( tvb, offset, netsync_tree, size );
457 break;
459 case NETSYNC_CMD_ERROR:
460 dissect_netsync_cmd_error( tvb, offset, netsync_tree, size );
461 break;
463 case NETSYNC_CMD_BYE:
464 dissect_netsync_cmd_bye( tvb, offset, netsync_tree, size );
465 break;
467 case NETSYNC_CMD_HELLO:
468 dissect_netsync_cmd_hello( tvb, offset, netsync_tree, size );
469 break;
471 case NETSYNC_CMD_ANONYMOUS:
472 dissect_netsync_cmd_anonymous( tvb, offset, netsync_tree, size );
473 break;
475 case NETSYNC_CMD_AUTH:
476 dissect_netsync_cmd_auth( tvb, offset, netsync_tree, size );
477 break;
479 case NETSYNC_CMD_CONFIRM:
480 dissect_netsync_cmd_confirm( tvb, offset, netsync_tree, size );
481 break;
483 case NETSYNC_CMD_REFINE:
484 dissect_netsync_cmd_refine( tvb, offset, netsync_tree, size );
485 break;
487 case NETSYNC_CMD_SEND_DATA:
488 dissect_netsync_cmd_send_data( tvb, offset, netsync_tree, size );
489 break;
491 case NETSYNC_CMD_SEND_DELTA:
492 dissect_netsync_cmd_send_delta( tvb, offset, netsync_tree, size );
493 break;
495 case NETSYNC_CMD_DATA:
496 dissect_netsync_cmd_data( tvb, offset, netsync_tree, size );
497 break;
499 case NETSYNC_CMD_DELTA:
500 dissect_netsync_cmd_delta( tvb, offset, netsync_tree, size );
501 break;
503 case NETSYNC_CMD_NONEXISTENT:
504 dissect_netsync_cmd_nonexistent( tvb, offset, netsync_tree, size );
505 break;
507 default:
508 proto_tree_add_item(netsync_tree, hf_netsync_data, tvb,
509 offset, size, ENC_NA );
510 break;
513 offset += size;
515 proto_tree_add_checksum(netsync_tree, tvb, offset, hf_netsync_checksum,
516 -1, NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS );
517 offset += 4;
520 proto_item_append_text(netsync_tree, " V%d, Cmd: %s (%d), Size: %d",
521 version, val_to_str(cmd, netsync_cmd_vals, "(0x%x)"), cmd, size );
523 proto_item_set_len(netsync_tree, 1+1+size_bytes+size+4);
526 return tvb_captured_length(tvb);
529 static int
530 dissect_netsync(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
532 tcp_dissect_pdus(tvb, pinfo, tree, netsync_desegment, 7, get_netsync_pdu_len,
533 dissect_netsync_pdu, data);
534 return tvb_captured_length(tvb);
537 void
538 proto_register_netsync(void)
540 static hf_register_info hf[] = {
541 /* General */
542 { &hf_netsync_version,
543 { "Version", "netsync.version",
544 FT_UINT8, BASE_DEC, NULL, 0x0,
545 NULL, HFILL } },
546 { &hf_netsync_command,
547 { "Command", "netsync.command",
548 FT_UINT8, BASE_HEX, VALS(netsync_cmd_vals), 0x0,
549 NULL, HFILL } },
550 { &hf_netsync_size,
551 { "Size", "netsync.size",
552 FT_UINT32, BASE_DEC, NULL, 0x0,
553 NULL, HFILL } },
554 { &hf_netsync_data,
555 { "Data", "netsync.data",
556 FT_BYTES, BASE_NONE, NULL, 0x0,
557 NULL, HFILL } },
558 { &hf_netsync_checksum,
559 { "Checksum", "netsync.checksum",
560 FT_UINT32, BASE_HEX, NULL, 0x0,
561 NULL, HFILL } },
562 { &hf_netsync_cmd_hello_keyname,
563 { "Key Name", "netsync.cmd.hello.keyname",
564 FT_STRING, BASE_NONE, NULL, 0x0,
565 NULL, HFILL } },
566 { &hf_netsync_cmd_hello_key,
567 { "Key", "netsync.cmd.hello.key",
568 FT_BYTES, BASE_NONE, NULL, 0x0,
569 NULL, HFILL } },
570 { &hf_netsync_cmd_nonce,
571 { "Nonce", "netsync.cmd.nonce",
572 FT_BYTES, BASE_NONE, NULL, 0x0,
573 NULL, HFILL } },
574 { &hf_netsync_cmd_anonymous_role,
575 { "Role", "netsync.cmd.anonymous.role",
576 FT_UINT8, BASE_DEC, VALS(netsync_role_vals), 0x0,
577 NULL, HFILL } },
578 { &hf_netsync_cmd_anonymous_collection,
579 { "Collection", "netsync.cmd.anonymous.collection",
580 FT_STRING, BASE_NONE, NULL, 0x0,
581 NULL, HFILL } },
582 { &hf_netsync_cmd_confirm_sig,
583 { "Signature", "netsync.cmd.confirm.signature",
584 FT_BYTES, BASE_NONE, NULL, 0x0,
585 NULL, HFILL } },
586 { &hf_netsync_cmd_send_data_type,
587 { "Type", "netsync.cmd.send_data.type",
588 FT_UINT8, BASE_DEC, NULL, 0x0,
589 NULL, HFILL } },
590 { &hf_netsync_cmd_send_data_id,
591 { "ID", "netsync.cmd.send_data.id",
592 FT_BYTES, BASE_NONE, NULL, 0x0,
593 NULL, HFILL } },
594 { &hf_netsync_cmd_error_msg,
595 { "Message", "netsync.cmd.error.msg",
596 FT_STRING, BASE_NONE, NULL, 0x0,
597 NULL, HFILL } },
599 { &hf_netsync_cmd_done_level,
600 { "Level", "netsync.cmd.done.level",
601 FT_UINT32, BASE_DEC, NULL, 0x0,
602 NULL, HFILL } },
603 { &hf_netsync_cmd_auth_role,
604 { "Role", "netsync.cmd.auth.role",
605 FT_UINT8, BASE_DEC, VALS(netsync_role_vals), 0x0,
606 NULL, HFILL } },
607 { &hf_netsync_cmd_auth_collection,
608 { "Collection", "netsync.cmd.auth.collection",
609 FT_STRING, BASE_NONE, NULL, 0x0,
610 NULL, HFILL } },
611 { &hf_netsync_cmd_auth_id,
612 { "ID", "netsync.cmd.auth.id",
613 FT_BYTES, BASE_NONE, NULL, 0x0,
614 NULL, HFILL } },
615 { &hf_netsync_cmd_auth_nonce1,
616 { "Nonce 1", "netsync.cmd.auth.nonce1",
617 FT_BYTES, BASE_NONE, NULL, 0x0,
618 NULL, HFILL } },
619 { &hf_netsync_cmd_auth_nonce2,
620 { "Nonce 2", "netsync.cmd.auth.nonce2",
621 FT_BYTES, BASE_NONE, NULL, 0x0,
622 NULL, HFILL } },
623 { &hf_netsync_cmd_auth_sig,
624 { "Signature", "netsync.cmd.auth.sig",
625 FT_BYTES, BASE_NONE, NULL, 0x0,
626 NULL, HFILL } },
627 { &hf_netsync_cmd_data_type,
628 { "Type", "netsync.cmd.data.type",
629 FT_UINT8, BASE_DEC, NULL, 0x0,
630 NULL, HFILL } },
631 { &hf_netsync_cmd_data_id,
632 { "ID", "netsync.cmd.data.id",
633 FT_BYTES, BASE_NONE, NULL, 0x0,
634 NULL, HFILL } },
635 { &hf_netsync_cmd_data_compressed,
636 { "Compressed", "netsync.cmd.data.compressed",
637 FT_UINT8, BASE_DEC, NULL, 0x0,
638 NULL, HFILL } },
639 { &hf_netsync_cmd_data_payload,
640 { "Payload", "netsync.cmd.data.payload",
641 FT_BYTES, BASE_NONE, NULL, 0x0,
642 NULL, HFILL } },
643 { &hf_netsync_cmd_delta_type,
644 { "Type", "netsync.cmd.delta.type",
645 FT_UINT8, BASE_DEC, NULL, 0x0,
646 NULL, HFILL } },
647 { &hf_netsync_cmd_delta_base_id,
648 { "Base ID", "netsync.cmd.delta.base_id",
649 FT_BYTES, BASE_NONE, NULL, 0x0,
650 NULL, HFILL } },
651 { &hf_netsync_cmd_delta_ident_id,
652 { "Ident ID", "netsync.cmd.delta.ident_id",
653 FT_BYTES, BASE_NONE, NULL, 0x0,
654 NULL, HFILL } },
655 { &hf_netsync_cmd_delta_compressed,
656 { "Compressed", "netsync.cmd.delta.compressed",
657 FT_UINT8, BASE_DEC, NULL, 0x0,
658 NULL, HFILL } },
659 { &hf_netsync_cmd_delta_payload,
660 { "Payload", "netsync.cmd.delta.payload",
661 FT_BYTES, BASE_NONE, NULL, 0x0,
662 NULL, HFILL } },
663 { &hf_netsync_cmd_refine_tree_node,
664 { "Tree Node", "netsync.cmd.refine.tree_node",
665 FT_BYTES, BASE_NONE, NULL, 0x0,
666 NULL, HFILL } },
667 { &hf_netsync_cmd_send_delta_type,
668 { "Type", "netsync.cmd.send_delta.type",
669 FT_UINT8, BASE_DEC, NULL, 0x0,
670 NULL, HFILL } },
671 { &hf_netsync_cmd_send_delta_base_id,
672 { "Base ID", "netsync.cmd.send_delta.base_id",
673 FT_BYTES, BASE_NONE, NULL, 0x0,
674 NULL, HFILL } },
675 { &hf_netsync_cmd_send_delta_ident_id,
676 { "Ident ID", "netsync.cmd.send_delta.ident_id",
677 FT_BYTES, BASE_NONE, NULL, 0x0,
678 NULL, HFILL } },
679 { &hf_netsync_cmd_nonexistent_id,
680 { "ID", "netsync.cmd.nonexistent.id",
681 FT_BYTES, BASE_NONE, NULL, 0x0,
682 NULL, HFILL } },
683 { &hf_netsync_cmd_nonexistent_type,
684 { "Type", "netsync.cmd.nonexistent.type",
685 FT_UINT8, BASE_DEC, NULL, 0x0,
686 NULL, HFILL } },
687 { &hf_netsync_cmd_done_type,
688 { "Type", "netsync.cmd.done.type",
689 FT_UINT8, BASE_DEC, NULL, 0x0,
690 NULL, HFILL } }
695 static int *ett[] = {
696 &ett_netsync,
699 module_t *netsync_module;
701 proto_netsync = proto_register_protocol("Monotone Netsync", "Netsync", "netsync");
702 proto_register_field_array(proto_netsync, hf, array_length(hf));
703 proto_register_subtree_array(ett, array_length(ett));
705 netsync_module = prefs_register_protocol(proto_netsync, NULL);
707 prefs_register_bool_preference(netsync_module, "desegment_netsync_messages",
708 "Reassemble Netsync messages spanning multiple TCP segments",
709 "Whether the Netsync dissector should reassemble messages spanning multiple TCP segments."
710 " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
711 &netsync_desegment);
713 netsync_handle = register_dissector("netsync", dissect_netsync, proto_netsync);
716 void
717 proto_reg_handoff_netsync(void)
719 dissector_add_uint_with_preference("tcp.port", TCP_PORT_NETSYNC, netsync_handle);
723 * Editor modelines - https://www.wireshark.org/tools/modelines.html
725 * Local variables:
726 * c-basic-offset: 8
727 * tab-width: 8
728 * indent-tabs-mode: t
729 * End:
731 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
732 * :indentSize=8:tabSize=8:noTabs=false: