2 * Routines for Monotone Netsync packet disassembly
6 * Copyright (c) 2005 by Erwin Rol <erwin@erwinrol.com>
8 * Ethereal - Network traffic analyzer
9 * By Gerald Combs <gerald@ethereal.com>
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 <epan/emem.h>
43 #include "packet-tcp.h"
48 * http://www.venge.net/monotone/
51 /* Define TCP ports for Monotone netsync */
53 #define TCP_PORT_NETSYNC 5253
55 #define NETSYNC_ROLE_SOURCE 1
56 #define NETSYNC_ROLE_SINK 2
57 #define NETSYNC_ROLE_BOTH 3
59 static const value_string netsync_role_vals[] = {
60 { NETSYNC_ROLE_SOURCE, "Source" },
61 { NETSYNC_ROLE_SINK, "Sink" },
62 { NETSYNC_ROLE_BOTH, "Both" },
67 #define NETSYNC_CMD_ERROR 0
68 #define NETSYNC_CMD_BYE 1
69 #define NETSYNC_CMD_HELLO 2
70 #define NETSYNC_CMD_ANONYMOUS 3
71 #define NETSYNC_CMD_AUTH 4
72 #define NETSYNC_CMD_CONFIRM 5
73 #define NETSYNC_CMD_REFINE 6
74 #define NETSYNC_CMD_DONE 7
75 #define NETSYNC_CMD_SEND_DATA 8
76 #define NETSYNC_CMD_SEND_DELTA 9
77 #define NETSYNC_CMD_DATA 10
78 #define NETSYNC_CMD_DELTA 11
79 #define NETSYNC_CMD_NONEXISTANT 12
81 static const value_string netsync_cmd_vals[] = {
82 { NETSYNC_CMD_ERROR, "Error" },
83 { NETSYNC_CMD_BYE, "Bye" },
84 { NETSYNC_CMD_HELLO, "Hello" },
85 { NETSYNC_CMD_ANONYMOUS, "Anonymous" },
86 { NETSYNC_CMD_AUTH, "Auth" },
87 { NETSYNC_CMD_CONFIRM, "Confirm" },
88 { NETSYNC_CMD_REFINE, "Refine" },
89 { NETSYNC_CMD_DONE, "Done" },
90 { NETSYNC_CMD_SEND_DATA, "Send Data" },
91 { NETSYNC_CMD_SEND_DELTA, "Send Delta" },
92 { NETSYNC_CMD_DATA, "Data" },
93 { NETSYNC_CMD_DELTA, "Delta" },
94 { NETSYNC_CMD_NONEXISTANT, "Nonexistant" },
98 #define NETSNYC_MERKLE_HASH_LENGTH 20
100 void proto_reg_handoff_netsync(void);
102 /* Define the monotone netsync proto */
103 static int proto_netsync = -1;
105 static int hf_netsync_version = -1;
106 static int hf_netsync_command = -1;
107 static int hf_netsync_size = -1;
108 static int hf_netsync_data = -1;
109 static int hf_netsync_checksum = -1;
111 static int hf_netsync_cmd_done_level = -1;
112 static int hf_netsync_cmd_done_type = -1;
114 static int hf_netsync_cmd_hello_keyname = -1;
115 static int hf_netsync_cmd_hello_key = -1;
116 static int hf_netsync_cmd_nonce = -1;
118 static int hf_netsync_cmd_anonymous_role = -1;
119 static int hf_netsync_cmd_anonymous_collection = -1;
121 static int hf_netsync_cmd_send_data_type = -1;
122 static int hf_netsync_cmd_send_data_id = -1;
124 static int hf_netsync_cmd_error_msg = -1;
127 static int hf_netsync_cmd_confirm_sig = -1;
129 static int hf_netsync_cmd_auth_role = -1;
130 static int hf_netsync_cmd_auth_collection = -1;
131 static int hf_netsync_cmd_auth_id = -1;
132 static int hf_netsync_cmd_auth_nonce1 = -1;
133 static int hf_netsync_cmd_auth_nonce2 = -1;
134 static int hf_netsync_cmd_auth_sig = -1;
136 static int hf_netsync_cmd_data_type = -1;
137 static int hf_netsync_cmd_data_id = -1;
138 static int hf_netsync_cmd_data_compressed = -1;
139 static int hf_netsync_cmd_data_payload = -1;
141 static int hf_netsync_cmd_delta_type = -1;
142 static int hf_netsync_cmd_delta_base_id = -1;
143 static int hf_netsync_cmd_delta_ident_id = -1;
144 static int hf_netsync_cmd_delta_compressed = -1;
145 static int hf_netsync_cmd_delta_payload = -1;
147 static int hf_netsync_cmd_refine_tree_node = -1;
149 static int hf_netsync_cmd_send_delta_type = -1;
150 static int hf_netsync_cmd_send_delta_base_id = -1;
151 static int hf_netsync_cmd_send_delta_ident_id = -1;
153 static int hf_netsync_cmd_nonexistant_type = -1;
154 static int hf_netsync_cmd_nonexistant_id = -1;
156 /* Define the tree for netsync */
157 static int ett_netsync = -1;
161 * Here are the global variables associated with the preferences
162 * for monotone netsync
165 static dissector_handle_t netsync_handle;
167 static guint global_tcp_port_netsync = TCP_PORT_NETSYNC;
168 static guint tcp_port_netsync = TCP_PORT_NETSYNC;
169 static gboolean netsync_desegment = TRUE;
171 static gint dissect_uleb128( tvbuff_t *tvb, gint offset, guint* size)
175 guint start_offset = offset;
181 tmp = tvb_get_guint8(tvb, offset);
184 *size |= (tmp & 0x7F) << shift;
186 } while (tmp & 0x80);
189 return offset - start_offset;
192 static gint dissect_netsync_cmd_error( tvbuff_t *tvb, gint offset, proto_tree *tree, guint size _U_)
196 offset += dissect_uleb128( tvb, offset, &len );
198 proto_tree_add_item(tree, hf_netsync_cmd_error_msg, tvb,
199 offset, len, FALSE );
205 static gint dissect_netsync_cmd_bye(tvbuff_t *tvb _U_, gint offset, proto_tree *tree _U_, guint size _U_)
211 static gint dissect_netsync_cmd_hello(tvbuff_t *tvb, gint offset, proto_tree *tree, guint size _U_)
215 offset += dissect_uleb128( tvb, offset, &len );
217 proto_tree_add_item(tree, hf_netsync_cmd_hello_keyname, tvb,
218 offset, len, FALSE );
222 offset += dissect_uleb128( tvb, offset, &len );
224 proto_tree_add_item(tree, hf_netsync_cmd_hello_key, tvb,
225 offset, len, FALSE );
228 proto_tree_add_item(tree, hf_netsync_cmd_nonce, tvb,
229 offset, NETSNYC_MERKLE_HASH_LENGTH, FALSE );
230 offset += NETSNYC_MERKLE_HASH_LENGTH;
236 static gint dissect_netsync_cmd_anonymous(tvbuff_t *tvb, gint offset, proto_tree *tree, guint size _U_)
240 proto_tree_add_item(tree, hf_netsync_cmd_anonymous_role, tvb,
244 offset += dissect_uleb128( tvb, offset, &len );
246 proto_tree_add_item(tree, hf_netsync_cmd_anonymous_collection, tvb,
247 offset, len, FALSE );
250 proto_tree_add_item(tree, hf_netsync_cmd_nonce, tvb,
251 offset, NETSNYC_MERKLE_HASH_LENGTH, FALSE );
252 offset += NETSNYC_MERKLE_HASH_LENGTH;
258 static gint dissect_netsync_cmd_auth(tvbuff_t *tvb, gint offset, proto_tree *tree, guint size _U_)
262 proto_tree_add_item(tree, hf_netsync_cmd_auth_role, tvb,
267 offset += dissect_uleb128( tvb, offset, &len );
269 proto_tree_add_item(tree, hf_netsync_cmd_auth_collection, tvb,
270 offset, len, FALSE );
273 proto_tree_add_item(tree, hf_netsync_cmd_auth_id, tvb,
274 offset, NETSNYC_MERKLE_HASH_LENGTH, FALSE );
275 offset += NETSNYC_MERKLE_HASH_LENGTH;
279 proto_tree_add_item(tree, hf_netsync_cmd_auth_nonce1, tvb,
280 offset, NETSNYC_MERKLE_HASH_LENGTH, FALSE );
281 offset += NETSNYC_MERKLE_HASH_LENGTH;
285 proto_tree_add_item(tree, hf_netsync_cmd_auth_nonce2, tvb,
286 offset, NETSNYC_MERKLE_HASH_LENGTH, FALSE );
287 offset += NETSNYC_MERKLE_HASH_LENGTH;
289 offset += dissect_uleb128( tvb, offset, &len );
291 proto_tree_add_item(tree, hf_netsync_cmd_auth_sig, tvb,
292 offset, len, FALSE );
299 static gint dissect_netsync_cmd_confirm(tvbuff_t *tvb, gint offset, proto_tree *tree, guint size _U_)
303 offset += dissect_uleb128( tvb, offset, &len );
305 proto_tree_add_item(tree, hf_netsync_cmd_confirm_sig, tvb,
306 offset, len, FALSE );
314 static gint dissect_netsync_cmd_refine(tvbuff_t *tvb, gint offset, proto_tree *tree, guint size)
316 proto_tree_add_item(tree, hf_netsync_cmd_refine_tree_node, tvb,
317 offset, size, FALSE );
324 static gint dissect_netsync_cmd_done(tvbuff_t *tvb, gint offset, proto_tree *tree, guint size _U_)
329 bytes = dissect_uleb128( tvb, offset, &len );
331 proto_tree_add_uint(tree, hf_netsync_cmd_done_level, tvb,
332 offset, bytes, len );
335 proto_tree_add_item(tree, hf_netsync_cmd_done_type, tvb,
343 static gint dissect_netsync_cmd_send_data(tvbuff_t *tvb, gint offset, proto_tree *tree, guint size _U_)
345 proto_tree_add_item(tree, hf_netsync_cmd_send_data_type, tvb,
349 proto_tree_add_item(tree, hf_netsync_cmd_send_data_id, tvb,
350 offset, NETSNYC_MERKLE_HASH_LENGTH, FALSE );
351 offset += NETSNYC_MERKLE_HASH_LENGTH;
357 static gint dissect_netsync_cmd_send_delta(tvbuff_t *tvb, gint offset, proto_tree *tree, guint size _U_)
359 proto_tree_add_item(tree, hf_netsync_cmd_send_delta_type, tvb,
363 proto_tree_add_item(tree, hf_netsync_cmd_send_delta_base_id, tvb,
364 offset, NETSNYC_MERKLE_HASH_LENGTH, FALSE );
365 offset += NETSNYC_MERKLE_HASH_LENGTH;
368 proto_tree_add_item(tree, hf_netsync_cmd_send_delta_ident_id, tvb,
369 offset, NETSNYC_MERKLE_HASH_LENGTH, FALSE );
370 offset += NETSNYC_MERKLE_HASH_LENGTH;
376 static gint dissect_netsync_cmd_data(tvbuff_t *tvb, gint offset, proto_tree *tree, guint size _U_)
380 proto_tree_add_item(tree, hf_netsync_cmd_data_type, tvb,
384 proto_tree_add_item(tree, hf_netsync_cmd_data_id, tvb,
385 offset, NETSNYC_MERKLE_HASH_LENGTH, FALSE );
386 offset += NETSNYC_MERKLE_HASH_LENGTH;
388 proto_tree_add_item(tree, hf_netsync_cmd_data_compressed, tvb,
392 offset += dissect_uleb128( tvb, offset, &len );
394 proto_tree_add_item(tree, hf_netsync_cmd_data_payload, tvb,
395 offset, len, FALSE );
402 static gint dissect_netsync_cmd_delta(tvbuff_t *tvb, gint offset, proto_tree *tree, guint size _U_)
406 proto_tree_add_item(tree, hf_netsync_cmd_delta_type, tvb,
410 proto_tree_add_item(tree, hf_netsync_cmd_delta_base_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_ident_id, tvb,
415 offset, NETSNYC_MERKLE_HASH_LENGTH, FALSE );
416 offset += NETSNYC_MERKLE_HASH_LENGTH;
418 proto_tree_add_item(tree, hf_netsync_cmd_delta_compressed, tvb,
422 offset += dissect_uleb128( tvb, offset, &len );
424 proto_tree_add_item(tree, hf_netsync_cmd_delta_payload, tvb,
425 offset, len, FALSE );
432 static gint dissect_netsync_cmd_nonexistant(tvbuff_t *tvb, gint offset, proto_tree *tree, guint size _U_)
434 proto_tree_add_item(tree, hf_netsync_cmd_nonexistant_type, tvb,
438 proto_tree_add_item(tree, hf_netsync_cmd_nonexistant_id, tvb,
439 offset, NETSNYC_MERKLE_HASH_LENGTH, FALSE );
440 offset += NETSNYC_MERKLE_HASH_LENGTH;
446 get_netsync_pdu_len(tvbuff_t *tvb, int offset)
448 guint size = 0, size_bytes;
450 /* skip version and command */
453 size_bytes = dissect_uleb128( tvb, offset, &size );
455 /* the calculated size if for the data only, this doesn't
456 * include the version (1 byte), command (1 byte),
457 * lenght (size_bytes bytes) and checksum (4 bytes)
460 return 1 + 1 + size_bytes + size + 4;
464 dissect_netsync_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
469 guint32 size, size_bytes, shift;
470 proto_tree *ti,*netsync_tree=NULL;
472 /* Set the protocol column */
473 if (check_col(pinfo->cinfo,COL_PROTOCOL)) {
474 col_set_str(pinfo->cinfo,COL_PROTOCOL,"Netsync");
481 while (tvb_reported_length_remaining(tvb, offset) > 0) {
482 ti = proto_tree_add_item(tree, proto_netsync, tvb, offset, -1, FALSE);
483 netsync_tree = proto_item_add_subtree(ti, ett_netsync);
485 version = tvb_get_guint8(tvb, offset);
486 proto_tree_add_item(netsync_tree, hf_netsync_version, tvb,
490 cmd = tvb_get_guint8(tvb, offset);
491 proto_tree_add_item(netsync_tree, hf_netsync_command, tvb,
501 tmp = tvb_get_guint8(tvb, offset + size_bytes);
504 size |= (tmp & 0x7F) << shift;
506 } while (tmp & 0x80);
509 proto_tree_add_uint(netsync_tree, hf_netsync_size, tvb,
510 offset, size_bytes, size );
511 offset += size_bytes;
514 case NETSYNC_CMD_DONE:
515 dissect_netsync_cmd_done( tvb, offset, netsync_tree, size );
518 case NETSYNC_CMD_ERROR:
519 dissect_netsync_cmd_error( tvb, offset, netsync_tree, size );
522 case NETSYNC_CMD_BYE:
523 dissect_netsync_cmd_bye( tvb, offset, netsync_tree, size );
526 case NETSYNC_CMD_HELLO:
527 dissect_netsync_cmd_hello( tvb, offset, netsync_tree, size );
530 case NETSYNC_CMD_ANONYMOUS:
531 dissect_netsync_cmd_anonymous( tvb, offset, netsync_tree, size );
534 case NETSYNC_CMD_AUTH:
535 dissect_netsync_cmd_auth( tvb, offset, netsync_tree, size );
538 case NETSYNC_CMD_CONFIRM:
539 dissect_netsync_cmd_confirm( tvb, offset, netsync_tree, size );
542 case NETSYNC_CMD_REFINE:
543 dissect_netsync_cmd_refine( tvb, offset, netsync_tree, size );
546 case NETSYNC_CMD_SEND_DATA:
547 dissect_netsync_cmd_send_data( tvb, offset, netsync_tree, size );
550 case NETSYNC_CMD_SEND_DELTA:
551 dissect_netsync_cmd_send_delta( tvb, offset, netsync_tree, size );
554 case NETSYNC_CMD_DATA:
555 dissect_netsync_cmd_data( tvb, offset, netsync_tree, size );
558 case NETSYNC_CMD_DELTA:
559 dissect_netsync_cmd_delta( tvb, offset, netsync_tree, size );
562 case NETSYNC_CMD_NONEXISTANT:
563 dissect_netsync_cmd_nonexistant( tvb, offset, netsync_tree, size );
567 proto_tree_add_item(netsync_tree, hf_netsync_data, tvb,
568 offset, size, FALSE );
574 proto_tree_add_item(netsync_tree, hf_netsync_checksum, tvb,
579 proto_item_append_text(netsync_tree, " V%d, Cmd: %s (%d), Size: %d",
580 version, val_to_str(cmd, netsync_cmd_vals, "(0x%x)"), cmd, size );
582 proto_item_set_len(netsync_tree, 1+1+size_bytes+size+4);
587 dissect_netsync(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
589 tcp_dissect_pdus(tvb, pinfo, tree, netsync_desegment, 7, get_netsync_pdu_len,
590 dissect_netsync_pdu);
594 proto_register_netsync(void)
596 static hf_register_info hf[] = {
598 { &hf_netsync_version,
599 { "Version", "netsync.version",
600 FT_UINT8, BASE_DEC, NULL, 0x0,
601 "Version", HFILL } },
602 { &hf_netsync_command,
603 { "Command", "netsync.command",
604 FT_UINT8, BASE_HEX, VALS(netsync_cmd_vals), 0x0,
605 "Command", HFILL } },
607 { "Size", "netsync.size",
608 FT_UINT32, BASE_DEC, NULL, 0x0,
611 { "Data", "netsync.data",
612 FT_BYTES, BASE_HEX, NULL, 0x0,
614 { &hf_netsync_checksum,
615 { "Checksum", "netsync.checksum",
616 FT_UINT32, BASE_HEX, NULL, 0x0,
617 "Checksum", HFILL } },
618 { &hf_netsync_cmd_hello_keyname,
619 { "Key Name", "netsync.cmd.hello.keyname",
620 FT_STRING, BASE_HEX, NULL, 0x0,
621 "Key Name", HFILL } },
622 { &hf_netsync_cmd_hello_key,
623 { "Key", "netsync.cmd.hello.key",
624 FT_BYTES, BASE_HEX, NULL, 0x0,
626 { &hf_netsync_cmd_nonce,
627 { "Nonce", "netsync.cmd.nonce",
628 FT_BYTES, BASE_HEX, NULL, 0x0,
630 { &hf_netsync_cmd_anonymous_role,
631 { "Role", "netsync.cmd.anonymous.role",
632 FT_UINT8, BASE_DEC, VALS(netsync_role_vals), 0x0,
634 { &hf_netsync_cmd_anonymous_collection,
635 { "Collection", "netsync.cmd.anonymous.collection",
636 FT_STRING, BASE_DEC, NULL, 0x0,
637 "Collection", HFILL } },
638 { &hf_netsync_cmd_confirm_sig,
639 { "Signature", "netsync.cmd.confirm.signature",
640 FT_BYTES, BASE_HEX, NULL, 0x0,
641 "Signature", HFILL } },
642 { &hf_netsync_cmd_send_data_type,
643 { "Type", "netsync.cmd.send_data.type",
644 FT_UINT8, BASE_DEC, NULL, 0x0,
646 { &hf_netsync_cmd_send_data_id,
647 { "ID", "netsync.cmd.send_data.id",
648 FT_BYTES, BASE_HEX, NULL, 0x0,
650 { &hf_netsync_cmd_error_msg,
651 { "Message", "netsync.cmd.error.msg",
652 FT_STRING, BASE_DEC, NULL, 0x0,
653 "Message", HFILL } },
655 { &hf_netsync_cmd_done_level,
656 { "Level", "netsync.cmd.done.level",
657 FT_UINT32, BASE_DEC, NULL, 0x0,
659 { &hf_netsync_cmd_auth_role,
660 { "Role", "netsync.cmd.auth.role",
661 FT_UINT8, BASE_DEC, VALS(netsync_role_vals), 0x0,
663 { &hf_netsync_cmd_auth_collection,
664 { "Collection", "netsync.cmd.auth.collection",
665 FT_STRING, BASE_DEC, NULL, 0x0,
666 "Collection", HFILL } },
667 { &hf_netsync_cmd_auth_id,
668 { "ID", "netsync.cmd.auth.id",
669 FT_BYTES, BASE_DEC, NULL, 0x0,
671 { &hf_netsync_cmd_auth_nonce1,
672 { "Nonce 1", "netsync.cmd.auth.nonce1",
673 FT_BYTES, BASE_DEC, NULL, 0x0,
674 "Nonce 1", HFILL } },
675 { &hf_netsync_cmd_auth_nonce2,
676 { "Nonce 2", "netsync.cmd.auth.nonce2",
677 FT_BYTES, BASE_DEC, NULL, 0x0,
678 "Nonce 2", HFILL } },
679 { &hf_netsync_cmd_auth_sig,
680 { "Signature", "netsync.cmd.auth.sig",
681 FT_BYTES, BASE_DEC, NULL, 0x0,
682 "Signature", HFILL } },
683 { &hf_netsync_cmd_data_type,
684 { "Type", "netsync.cmd.data.type",
685 FT_UINT8, BASE_DEC, NULL, 0x0,
687 { &hf_netsync_cmd_data_id,
688 { "ID", "netsync.cmd.data.id",
689 FT_BYTES, BASE_DEC, NULL, 0x0,
691 { &hf_netsync_cmd_data_compressed,
692 { "Compressed", "netsync.cmd.data.compressed",
693 FT_UINT8, BASE_DEC, NULL, 0x0,
694 "Compressed", HFILL } },
695 { &hf_netsync_cmd_data_payload,
696 { "Payload", "netsync.cmd.data.payload",
697 FT_BYTES, BASE_DEC, NULL, 0x0,
698 "Payload", HFILL } },
699 { &hf_netsync_cmd_delta_type,
700 { "Type", "netsync.cmd.delta.type",
701 FT_UINT8, BASE_DEC, NULL, 0x0,
703 { &hf_netsync_cmd_delta_base_id,
704 { "Base ID", "netsync.cmd.delta.base_id",
705 FT_BYTES, BASE_DEC, NULL, 0x0,
706 "Base ID", HFILL } },
707 { &hf_netsync_cmd_delta_ident_id,
708 { "Ident ID", "netsync.cmd.delta.ident_id",
709 FT_BYTES, BASE_DEC, NULL, 0x0,
710 "Ident ID", HFILL } },
711 { &hf_netsync_cmd_delta_compressed,
712 { "Compressed", "netsync.cmd.delta.compressed",
713 FT_UINT8, BASE_DEC, NULL, 0x0,
714 "Compressed", HFILL } },
715 { &hf_netsync_cmd_delta_payload,
716 { "Payload", "netsync.cmd.delta.payload",
717 FT_BYTES, BASE_DEC, NULL, 0x0,
718 "Payload", HFILL } },
719 { &hf_netsync_cmd_refine_tree_node,
720 { "Tree Node", "netsync.cmd.refine.tree_node",
721 FT_BYTES, BASE_DEC, NULL, 0x0,
722 "Tree Node", HFILL } },
723 { &hf_netsync_cmd_send_delta_type,
724 { "Type", "netsync.cmd.send_delta.type",
725 FT_UINT8, BASE_DEC, NULL, 0x0,
727 { &hf_netsync_cmd_send_delta_base_id,
728 { "Base ID", "netsync.cmd.send_delta.base_id",
729 FT_BYTES, BASE_DEC, NULL, 0x0,
730 "Base ID", HFILL } },
731 { &hf_netsync_cmd_send_delta_ident_id,
732 { "Ident ID", "netsync.cmd.send_delta.ident_id",
733 FT_BYTES, BASE_DEC, NULL, 0x0,
734 "Ident ID", HFILL } },
735 { &hf_netsync_cmd_nonexistant_id,
736 { "ID", "netsync.cmd.nonexistant.id",
737 FT_BYTES, BASE_DEC, NULL, 0x0,
739 { &hf_netsync_cmd_nonexistant_type,
740 { "Type", "netsync.cmd.nonexistant.type",
741 FT_UINT8, BASE_DEC, NULL, 0x0,
743 { &hf_netsync_cmd_done_type,
744 { "Type", "netsync.cmd.done.type",
745 FT_UINT8, BASE_DEC, NULL, 0x0,
751 static gint *ett[] = {
755 module_t *netsync_module;
757 proto_netsync = proto_register_protocol("Monotone Netsync", "Netsync", "netsync");
758 proto_register_field_array(proto_netsync, hf, array_length(hf));
759 proto_register_subtree_array(ett, array_length(ett));
761 netsync_handle = create_dissector_handle(dissect_netsync, proto_netsync);
763 netsync_module = prefs_register_protocol(proto_netsync,
764 proto_reg_handoff_netsync);
766 prefs_register_uint_preference(netsync_module, "tcp_port",
767 "Monotone Netsync TCP Port",
768 "The TCP port on which Monotone Netsync packets will be sent",
769 10, &global_tcp_port_netsync);
772 prefs_register_bool_preference(netsync_module, "desegment_netsync_messages",
773 "Reassemble Netsync messages spanning multiple TCP segments",
774 "Whether the Netsync dissector should reassemble messages spanning multiple TCP segments."
775 " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
781 proto_reg_handoff_netsync(void)
783 static gint initialized = 0;
786 dissector_delete("tcp.port", tcp_port_netsync, netsync_handle);
791 tcp_port_netsync = global_tcp_port_netsync;
792 dissector_add("tcp.port", global_tcp_port_netsync, netsync_handle);