2 * Routines for Monotone Netsync packet disassembly
6 * Copyright (c) 2005 by Erwin Rol <erwin@erwinrol.com>
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1999 Gerald Combs
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
38 #include <epan/packet.h>
39 #include <epan/addr_resolv.h>
40 #include <epan/prefs.h>
41 #include <epan/strutil.h>
42 #include "packet-tcp.h"
47 * http://www.venge.net/monotone/
50 /* Define TCP ports for Monotone netsync */
52 #define TCP_PORT_NETSYNC 5253
54 #define NETSYNC_ROLE_SOURCE 1
55 #define NETSYNC_ROLE_SINK 2
56 #define NETSYNC_ROLE_BOTH 3
58 static const value_string netsync_role_vals[] = {
59 { NETSYNC_ROLE_SOURCE, "Source" },
60 { NETSYNC_ROLE_SINK, "Sink" },
61 { NETSYNC_ROLE_BOTH, "Both" },
66 #define NETSYNC_CMD_ERROR 0
67 #define NETSYNC_CMD_BYE 1
68 #define NETSYNC_CMD_HELLO 2
69 #define NETSYNC_CMD_ANONYMOUS 3
70 #define NETSYNC_CMD_AUTH 4
71 #define NETSYNC_CMD_CONFIRM 5
72 #define NETSYNC_CMD_REFINE 6
73 #define NETSYNC_CMD_DONE 7
74 #define NETSYNC_CMD_SEND_DATA 8
75 #define NETSYNC_CMD_SEND_DELTA 9
76 #define NETSYNC_CMD_DATA 10
77 #define NETSYNC_CMD_DELTA 11
78 #define NETSYNC_CMD_NONEXISTENT 12
80 static const value_string netsync_cmd_vals[] = {
81 { NETSYNC_CMD_ERROR, "Error" },
82 { NETSYNC_CMD_BYE, "Bye" },
83 { NETSYNC_CMD_HELLO, "Hello" },
84 { NETSYNC_CMD_ANONYMOUS, "Anonymous" },
85 { NETSYNC_CMD_AUTH, "Auth" },
86 { NETSYNC_CMD_CONFIRM, "Confirm" },
87 { NETSYNC_CMD_REFINE, "Refine" },
88 { NETSYNC_CMD_DONE, "Done" },
89 { NETSYNC_CMD_SEND_DATA, "Send Data" },
90 { NETSYNC_CMD_SEND_DELTA, "Send Delta" },
91 { NETSYNC_CMD_DATA, "Data" },
92 { NETSYNC_CMD_DELTA, "Delta" },
93 { NETSYNC_CMD_NONEXISTENT, "Nonexistent" },
97 #define NETSNYC_MERKLE_HASH_LENGTH 20
99 void proto_reg_handoff_netsync(void);
101 /* Define the monotone netsync proto */
102 static int proto_netsync = -1;
104 static int hf_netsync_version = -1;
105 static int hf_netsync_command = -1;
106 static int hf_netsync_size = -1;
107 static int hf_netsync_data = -1;
108 static int hf_netsync_checksum = -1;
110 static int hf_netsync_cmd_done_level = -1;
111 static int hf_netsync_cmd_done_type = -1;
113 static int hf_netsync_cmd_hello_keyname = -1;
114 static int hf_netsync_cmd_hello_key = -1;
115 static int hf_netsync_cmd_nonce = -1;
117 static int hf_netsync_cmd_anonymous_role = -1;
118 static int hf_netsync_cmd_anonymous_collection = -1;
120 static int hf_netsync_cmd_send_data_type = -1;
121 static int hf_netsync_cmd_send_data_id = -1;
123 static int hf_netsync_cmd_error_msg = -1;
126 static int hf_netsync_cmd_confirm_sig = -1;
128 static int hf_netsync_cmd_auth_role = -1;
129 static int hf_netsync_cmd_auth_collection = -1;
130 static int hf_netsync_cmd_auth_id = -1;
131 static int hf_netsync_cmd_auth_nonce1 = -1;
132 static int hf_netsync_cmd_auth_nonce2 = -1;
133 static int hf_netsync_cmd_auth_sig = -1;
135 static int hf_netsync_cmd_data_type = -1;
136 static int hf_netsync_cmd_data_id = -1;
137 static int hf_netsync_cmd_data_compressed = -1;
138 static int hf_netsync_cmd_data_payload = -1;
140 static int hf_netsync_cmd_delta_type = -1;
141 static int hf_netsync_cmd_delta_base_id = -1;
142 static int hf_netsync_cmd_delta_ident_id = -1;
143 static int hf_netsync_cmd_delta_compressed = -1;
144 static int hf_netsync_cmd_delta_payload = -1;
146 static int hf_netsync_cmd_refine_tree_node = -1;
148 static int hf_netsync_cmd_send_delta_type = -1;
149 static int hf_netsync_cmd_send_delta_base_id = -1;
150 static int hf_netsync_cmd_send_delta_ident_id = -1;
152 static int hf_netsync_cmd_nonexistent_type = -1;
153 static int hf_netsync_cmd_nonexistent_id = -1;
155 /* Define the tree for netsync */
156 static int ett_netsync = -1;
160 * Here are the global variables associated with the preferences
161 * for monotone netsync
164 static guint global_tcp_port_netsync = TCP_PORT_NETSYNC;
165 static gboolean netsync_desegment = TRUE;
167 static gint dissect_uleb128( tvbuff_t *tvb, gint offset, guint* size)
171 guint start_offset = offset;
177 tmp = tvb_get_guint8(tvb, offset);
180 *size |= (tmp & 0x7F) << shift;
182 } while (tmp & 0x80);
185 return offset - start_offset;
188 static gint dissect_netsync_cmd_error( tvbuff_t *tvb, gint offset, proto_tree *tree, guint size _U_)
192 offset += dissect_uleb128( tvb, offset, &len );
194 proto_tree_add_item(tree, hf_netsync_cmd_error_msg, tvb,
195 offset, len, FALSE );
201 static gint dissect_netsync_cmd_bye(tvbuff_t *tvb _U_, gint offset, proto_tree *tree _U_, guint size _U_)
207 static gint dissect_netsync_cmd_hello(tvbuff_t *tvb, gint offset, proto_tree *tree, guint size _U_)
211 offset += dissect_uleb128( tvb, offset, &len );
213 proto_tree_add_item(tree, hf_netsync_cmd_hello_keyname, tvb,
214 offset, len, FALSE );
218 offset += dissect_uleb128( tvb, offset, &len );
220 proto_tree_add_item(tree, hf_netsync_cmd_hello_key, tvb,
221 offset, len, FALSE );
224 proto_tree_add_item(tree, hf_netsync_cmd_nonce, tvb,
225 offset, NETSNYC_MERKLE_HASH_LENGTH, FALSE );
226 offset += NETSNYC_MERKLE_HASH_LENGTH;
232 static gint dissect_netsync_cmd_anonymous(tvbuff_t *tvb, gint offset, proto_tree *tree, guint size _U_)
236 proto_tree_add_item(tree, hf_netsync_cmd_anonymous_role, tvb,
240 offset += dissect_uleb128( tvb, offset, &len );
242 proto_tree_add_item(tree, hf_netsync_cmd_anonymous_collection, tvb,
243 offset, len, FALSE );
246 proto_tree_add_item(tree, hf_netsync_cmd_nonce, tvb,
247 offset, NETSNYC_MERKLE_HASH_LENGTH, FALSE );
248 offset += NETSNYC_MERKLE_HASH_LENGTH;
254 static gint dissect_netsync_cmd_auth(tvbuff_t *tvb, gint offset, proto_tree *tree, guint size _U_)
258 proto_tree_add_item(tree, hf_netsync_cmd_auth_role, tvb,
263 offset += dissect_uleb128( tvb, offset, &len );
265 proto_tree_add_item(tree, hf_netsync_cmd_auth_collection, tvb,
266 offset, len, FALSE );
269 proto_tree_add_item(tree, hf_netsync_cmd_auth_id, tvb,
270 offset, NETSNYC_MERKLE_HASH_LENGTH, FALSE );
271 offset += NETSNYC_MERKLE_HASH_LENGTH;
275 proto_tree_add_item(tree, hf_netsync_cmd_auth_nonce1, tvb,
276 offset, NETSNYC_MERKLE_HASH_LENGTH, FALSE );
277 offset += NETSNYC_MERKLE_HASH_LENGTH;
281 proto_tree_add_item(tree, hf_netsync_cmd_auth_nonce2, tvb,
282 offset, NETSNYC_MERKLE_HASH_LENGTH, FALSE );
283 offset += NETSNYC_MERKLE_HASH_LENGTH;
285 offset += dissect_uleb128( tvb, offset, &len );
287 proto_tree_add_item(tree, hf_netsync_cmd_auth_sig, tvb,
288 offset, len, FALSE );
295 static gint dissect_netsync_cmd_confirm(tvbuff_t *tvb, gint offset, proto_tree *tree, guint size _U_)
299 offset += dissect_uleb128( tvb, offset, &len );
301 proto_tree_add_item(tree, hf_netsync_cmd_confirm_sig, tvb,
302 offset, len, FALSE );
310 static gint dissect_netsync_cmd_refine(tvbuff_t *tvb, gint offset, proto_tree *tree, guint size)
312 proto_tree_add_item(tree, hf_netsync_cmd_refine_tree_node, tvb,
313 offset, size, FALSE );
320 static gint dissect_netsync_cmd_done(tvbuff_t *tvb, gint offset, proto_tree *tree, guint size _U_)
325 bytes = dissect_uleb128( tvb, offset, &len );
327 proto_tree_add_uint(tree, hf_netsync_cmd_done_level, tvb,
328 offset, bytes, len );
331 proto_tree_add_item(tree, hf_netsync_cmd_done_type, tvb,
339 static gint dissect_netsync_cmd_send_data(tvbuff_t *tvb, gint offset, proto_tree *tree, guint size _U_)
341 proto_tree_add_item(tree, hf_netsync_cmd_send_data_type, tvb,
345 proto_tree_add_item(tree, hf_netsync_cmd_send_data_id, tvb,
346 offset, NETSNYC_MERKLE_HASH_LENGTH, FALSE );
347 offset += NETSNYC_MERKLE_HASH_LENGTH;
353 static gint dissect_netsync_cmd_send_delta(tvbuff_t *tvb, gint offset, proto_tree *tree, guint size _U_)
355 proto_tree_add_item(tree, hf_netsync_cmd_send_delta_type, tvb,
359 proto_tree_add_item(tree, hf_netsync_cmd_send_delta_base_id, tvb,
360 offset, NETSNYC_MERKLE_HASH_LENGTH, FALSE );
361 offset += NETSNYC_MERKLE_HASH_LENGTH;
364 proto_tree_add_item(tree, hf_netsync_cmd_send_delta_ident_id, tvb,
365 offset, NETSNYC_MERKLE_HASH_LENGTH, FALSE );
366 offset += NETSNYC_MERKLE_HASH_LENGTH;
372 static gint dissect_netsync_cmd_data(tvbuff_t *tvb, gint offset, proto_tree *tree, guint size _U_)
376 proto_tree_add_item(tree, hf_netsync_cmd_data_type, tvb,
380 proto_tree_add_item(tree, hf_netsync_cmd_data_id, tvb,
381 offset, NETSNYC_MERKLE_HASH_LENGTH, FALSE );
382 offset += NETSNYC_MERKLE_HASH_LENGTH;
384 proto_tree_add_item(tree, hf_netsync_cmd_data_compressed, tvb,
388 offset += dissect_uleb128( tvb, offset, &len );
390 proto_tree_add_item(tree, hf_netsync_cmd_data_payload, tvb,
391 offset, len, FALSE );
398 static gint dissect_netsync_cmd_delta(tvbuff_t *tvb, gint offset, proto_tree *tree, guint size _U_)
402 proto_tree_add_item(tree, hf_netsync_cmd_delta_type, tvb,
406 proto_tree_add_item(tree, hf_netsync_cmd_delta_base_id, tvb,
407 offset, NETSNYC_MERKLE_HASH_LENGTH, FALSE );
408 offset += NETSNYC_MERKLE_HASH_LENGTH;
410 proto_tree_add_item(tree, hf_netsync_cmd_delta_ident_id, tvb,
411 offset, NETSNYC_MERKLE_HASH_LENGTH, FALSE );
412 offset += NETSNYC_MERKLE_HASH_LENGTH;
414 proto_tree_add_item(tree, hf_netsync_cmd_delta_compressed, tvb,
418 offset += dissect_uleb128( tvb, offset, &len );
420 proto_tree_add_item(tree, hf_netsync_cmd_delta_payload, tvb,
421 offset, len, FALSE );
428 static gint dissect_netsync_cmd_nonexistent(tvbuff_t *tvb, gint offset, proto_tree *tree, guint size _U_)
430 proto_tree_add_item(tree, hf_netsync_cmd_nonexistent_type, tvb,
434 proto_tree_add_item(tree, hf_netsync_cmd_nonexistent_id, tvb,
435 offset, NETSNYC_MERKLE_HASH_LENGTH, FALSE );
436 offset += NETSNYC_MERKLE_HASH_LENGTH;
442 get_netsync_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset)
444 guint size = 0, size_bytes;
446 /* skip version and command */
449 size_bytes = dissect_uleb128( tvb, offset, &size );
451 /* the calculated size if for the data only, this doesn't
452 * include the version (1 byte), command (1 byte),
453 * length (size_bytes bytes) and checksum (4 bytes)
456 return 1 + 1 + size_bytes + size + 4;
460 dissect_netsync_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
465 guint32 size, size_bytes, shift;
466 proto_tree *ti,*netsync_tree=NULL;
468 /* Set the protocol column */
469 if (check_col(pinfo->cinfo,COL_PROTOCOL)) {
470 col_set_str(pinfo->cinfo,COL_PROTOCOL,"Netsync");
477 while (tvb_reported_length_remaining(tvb, offset) > 0) {
478 ti = proto_tree_add_item(tree, proto_netsync, tvb, offset, -1, FALSE);
479 netsync_tree = proto_item_add_subtree(ti, ett_netsync);
481 version = tvb_get_guint8(tvb, offset);
482 proto_tree_add_item(netsync_tree, hf_netsync_version, tvb,
486 cmd = tvb_get_guint8(tvb, offset);
487 proto_tree_add_item(netsync_tree, hf_netsync_command, tvb,
497 tmp = tvb_get_guint8(tvb, offset + size_bytes);
500 size |= (tmp & 0x7F) << shift;
502 } while (tmp & 0x80);
505 proto_tree_add_uint(netsync_tree, hf_netsync_size, tvb,
506 offset, size_bytes, size );
507 offset += size_bytes;
510 case NETSYNC_CMD_DONE:
511 dissect_netsync_cmd_done( tvb, offset, netsync_tree, size );
514 case NETSYNC_CMD_ERROR:
515 dissect_netsync_cmd_error( tvb, offset, netsync_tree, size );
518 case NETSYNC_CMD_BYE:
519 dissect_netsync_cmd_bye( tvb, offset, netsync_tree, size );
522 case NETSYNC_CMD_HELLO:
523 dissect_netsync_cmd_hello( tvb, offset, netsync_tree, size );
526 case NETSYNC_CMD_ANONYMOUS:
527 dissect_netsync_cmd_anonymous( tvb, offset, netsync_tree, size );
530 case NETSYNC_CMD_AUTH:
531 dissect_netsync_cmd_auth( tvb, offset, netsync_tree, size );
534 case NETSYNC_CMD_CONFIRM:
535 dissect_netsync_cmd_confirm( tvb, offset, netsync_tree, size );
538 case NETSYNC_CMD_REFINE:
539 dissect_netsync_cmd_refine( tvb, offset, netsync_tree, size );
542 case NETSYNC_CMD_SEND_DATA:
543 dissect_netsync_cmd_send_data( tvb, offset, netsync_tree, size );
546 case NETSYNC_CMD_SEND_DELTA:
547 dissect_netsync_cmd_send_delta( tvb, offset, netsync_tree, size );
550 case NETSYNC_CMD_DATA:
551 dissect_netsync_cmd_data( tvb, offset, netsync_tree, size );
554 case NETSYNC_CMD_DELTA:
555 dissect_netsync_cmd_delta( tvb, offset, netsync_tree, size );
558 case NETSYNC_CMD_NONEXISTENT:
559 dissect_netsync_cmd_nonexistent( tvb, offset, netsync_tree, size );
563 proto_tree_add_item(netsync_tree, hf_netsync_data, tvb,
564 offset, size, FALSE );
570 proto_tree_add_item(netsync_tree, hf_netsync_checksum, tvb,
575 proto_item_append_text(netsync_tree, " V%d, Cmd: %s (%d), Size: %d",
576 version, val_to_str(cmd, netsync_cmd_vals, "(0x%x)"), cmd, size );
578 proto_item_set_len(netsync_tree, 1+1+size_bytes+size+4);
583 dissect_netsync(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
585 tcp_dissect_pdus(tvb, pinfo, tree, netsync_desegment, 7, get_netsync_pdu_len,
586 dissect_netsync_pdu);
590 proto_register_netsync(void)
592 static hf_register_info hf[] = {
594 { &hf_netsync_version,
595 { "Version", "netsync.version",
596 FT_UINT8, BASE_DEC, NULL, 0x0,
597 "Version", HFILL } },
598 { &hf_netsync_command,
599 { "Command", "netsync.command",
600 FT_UINT8, BASE_HEX, VALS(netsync_cmd_vals), 0x0,
601 "Command", HFILL } },
603 { "Size", "netsync.size",
604 FT_UINT32, BASE_DEC, NULL, 0x0,
607 { "Data", "netsync.data",
608 FT_BYTES, BASE_HEX, NULL, 0x0,
610 { &hf_netsync_checksum,
611 { "Checksum", "netsync.checksum",
612 FT_UINT32, BASE_HEX, NULL, 0x0,
613 "Checksum", HFILL } },
614 { &hf_netsync_cmd_hello_keyname,
615 { "Key Name", "netsync.cmd.hello.keyname",
616 FT_STRING, BASE_HEX, NULL, 0x0,
617 "Key Name", HFILL } },
618 { &hf_netsync_cmd_hello_key,
619 { "Key", "netsync.cmd.hello.key",
620 FT_BYTES, BASE_HEX, NULL, 0x0,
622 { &hf_netsync_cmd_nonce,
623 { "Nonce", "netsync.cmd.nonce",
624 FT_BYTES, BASE_HEX, NULL, 0x0,
626 { &hf_netsync_cmd_anonymous_role,
627 { "Role", "netsync.cmd.anonymous.role",
628 FT_UINT8, BASE_DEC, VALS(netsync_role_vals), 0x0,
630 { &hf_netsync_cmd_anonymous_collection,
631 { "Collection", "netsync.cmd.anonymous.collection",
632 FT_STRING, BASE_DEC, NULL, 0x0,
633 "Collection", HFILL } },
634 { &hf_netsync_cmd_confirm_sig,
635 { "Signature", "netsync.cmd.confirm.signature",
636 FT_BYTES, BASE_HEX, NULL, 0x0,
637 "Signature", HFILL } },
638 { &hf_netsync_cmd_send_data_type,
639 { "Type", "netsync.cmd.send_data.type",
640 FT_UINT8, BASE_DEC, NULL, 0x0,
642 { &hf_netsync_cmd_send_data_id,
643 { "ID", "netsync.cmd.send_data.id",
644 FT_BYTES, BASE_HEX, NULL, 0x0,
646 { &hf_netsync_cmd_error_msg,
647 { "Message", "netsync.cmd.error.msg",
648 FT_STRING, BASE_DEC, NULL, 0x0,
649 "Message", HFILL } },
651 { &hf_netsync_cmd_done_level,
652 { "Level", "netsync.cmd.done.level",
653 FT_UINT32, BASE_DEC, NULL, 0x0,
655 { &hf_netsync_cmd_auth_role,
656 { "Role", "netsync.cmd.auth.role",
657 FT_UINT8, BASE_DEC, VALS(netsync_role_vals), 0x0,
659 { &hf_netsync_cmd_auth_collection,
660 { "Collection", "netsync.cmd.auth.collection",
661 FT_STRING, BASE_DEC, NULL, 0x0,
662 "Collection", HFILL } },
663 { &hf_netsync_cmd_auth_id,
664 { "ID", "netsync.cmd.auth.id",
665 FT_BYTES, BASE_DEC, NULL, 0x0,
667 { &hf_netsync_cmd_auth_nonce1,
668 { "Nonce 1", "netsync.cmd.auth.nonce1",
669 FT_BYTES, BASE_DEC, NULL, 0x0,
670 "Nonce 1", HFILL } },
671 { &hf_netsync_cmd_auth_nonce2,
672 { "Nonce 2", "netsync.cmd.auth.nonce2",
673 FT_BYTES, BASE_DEC, NULL, 0x0,
674 "Nonce 2", HFILL } },
675 { &hf_netsync_cmd_auth_sig,
676 { "Signature", "netsync.cmd.auth.sig",
677 FT_BYTES, BASE_DEC, NULL, 0x0,
678 "Signature", HFILL } },
679 { &hf_netsync_cmd_data_type,
680 { "Type", "netsync.cmd.data.type",
681 FT_UINT8, BASE_DEC, NULL, 0x0,
683 { &hf_netsync_cmd_data_id,
684 { "ID", "netsync.cmd.data.id",
685 FT_BYTES, BASE_DEC, NULL, 0x0,
687 { &hf_netsync_cmd_data_compressed,
688 { "Compressed", "netsync.cmd.data.compressed",
689 FT_UINT8, BASE_DEC, NULL, 0x0,
690 "Compressed", HFILL } },
691 { &hf_netsync_cmd_data_payload,
692 { "Payload", "netsync.cmd.data.payload",
693 FT_BYTES, BASE_DEC, NULL, 0x0,
694 "Payload", HFILL } },
695 { &hf_netsync_cmd_delta_type,
696 { "Type", "netsync.cmd.delta.type",
697 FT_UINT8, BASE_DEC, NULL, 0x0,
699 { &hf_netsync_cmd_delta_base_id,
700 { "Base ID", "netsync.cmd.delta.base_id",
701 FT_BYTES, BASE_DEC, NULL, 0x0,
702 "Base ID", HFILL } },
703 { &hf_netsync_cmd_delta_ident_id,
704 { "Ident ID", "netsync.cmd.delta.ident_id",
705 FT_BYTES, BASE_DEC, NULL, 0x0,
706 "Ident ID", HFILL } },
707 { &hf_netsync_cmd_delta_compressed,
708 { "Compressed", "netsync.cmd.delta.compressed",
709 FT_UINT8, BASE_DEC, NULL, 0x0,
710 "Compressed", HFILL } },
711 { &hf_netsync_cmd_delta_payload,
712 { "Payload", "netsync.cmd.delta.payload",
713 FT_BYTES, BASE_DEC, NULL, 0x0,
714 "Payload", HFILL } },
715 { &hf_netsync_cmd_refine_tree_node,
716 { "Tree Node", "netsync.cmd.refine.tree_node",
717 FT_BYTES, BASE_DEC, NULL, 0x0,
718 "Tree Node", HFILL } },
719 { &hf_netsync_cmd_send_delta_type,
720 { "Type", "netsync.cmd.send_delta.type",
721 FT_UINT8, BASE_DEC, NULL, 0x0,
723 { &hf_netsync_cmd_send_delta_base_id,
724 { "Base ID", "netsync.cmd.send_delta.base_id",
725 FT_BYTES, BASE_DEC, NULL, 0x0,
726 "Base ID", HFILL } },
727 { &hf_netsync_cmd_send_delta_ident_id,
728 { "Ident ID", "netsync.cmd.send_delta.ident_id",
729 FT_BYTES, BASE_DEC, NULL, 0x0,
730 "Ident ID", HFILL } },
731 { &hf_netsync_cmd_nonexistent_id,
732 { "ID", "netsync.cmd.nonexistent.id",
733 FT_BYTES, BASE_DEC, NULL, 0x0,
735 { &hf_netsync_cmd_nonexistent_type,
736 { "Type", "netsync.cmd.nonexistent.type",
737 FT_UINT8, BASE_DEC, NULL, 0x0,
739 { &hf_netsync_cmd_done_type,
740 { "Type", "netsync.cmd.done.type",
741 FT_UINT8, BASE_DEC, NULL, 0x0,
747 static gint *ett[] = {
751 module_t *netsync_module;
753 proto_netsync = proto_register_protocol("Monotone Netsync", "Netsync", "netsync");
754 proto_register_field_array(proto_netsync, hf, array_length(hf));
755 proto_register_subtree_array(ett, array_length(ett));
757 netsync_module = prefs_register_protocol(proto_netsync,
758 proto_reg_handoff_netsync);
760 prefs_register_uint_preference(netsync_module, "tcp_port",
761 "Monotone Netsync TCP Port",
762 "The TCP port on which Monotone Netsync packets will be sent",
763 10, &global_tcp_port_netsync);
766 prefs_register_bool_preference(netsync_module, "desegment_netsync_messages",
767 "Reassemble Netsync messages spanning multiple TCP segments",
768 "Whether the Netsync dissector should reassemble messages spanning multiple TCP segments."
769 " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
775 proto_reg_handoff_netsync(void)
777 static dissector_handle_t netsync_handle;
778 static guint tcp_port_netsync;
779 static gboolean initialized = FALSE;
782 netsync_handle = create_dissector_handle(dissect_netsync, proto_netsync);
785 dissector_delete("tcp.port", tcp_port_netsync, netsync_handle);
788 tcp_port_netsync = global_tcp_port_netsync;
789 dissector_add("tcp.port", global_tcp_port_netsync, netsync_handle);