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.
36 #include <epan/packet.h>
37 #include <epan/addr_resolv.h>
38 #include <epan/prefs.h>
39 #include <epan/strutil.h>
40 #include "packet-tcp.h"
45 * http://www.venge.net/monotone/
48 /* Define TCP ports for Monotone netsync */
50 #define TCP_PORT_NETSYNC 5253
52 #define NETSYNC_ROLE_SOURCE 1
53 #define NETSYNC_ROLE_SINK 2
54 #define NETSYNC_ROLE_BOTH 3
56 static const value_string netsync_role_vals[] = {
57 { NETSYNC_ROLE_SOURCE, "Source" },
58 { NETSYNC_ROLE_SINK, "Sink" },
59 { NETSYNC_ROLE_BOTH, "Both" },
64 #define NETSYNC_CMD_ERROR 0
65 #define NETSYNC_CMD_BYE 1
66 #define NETSYNC_CMD_HELLO 2
67 #define NETSYNC_CMD_ANONYMOUS 3
68 #define NETSYNC_CMD_AUTH 4
69 #define NETSYNC_CMD_CONFIRM 5
70 #define NETSYNC_CMD_REFINE 6
71 #define NETSYNC_CMD_DONE 7
72 #define NETSYNC_CMD_SEND_DATA 8
73 #define NETSYNC_CMD_SEND_DELTA 9
74 #define NETSYNC_CMD_DATA 10
75 #define NETSYNC_CMD_DELTA 11
76 #define NETSYNC_CMD_NONEXISTENT 12
78 static const value_string netsync_cmd_vals[] = {
79 { NETSYNC_CMD_ERROR, "Error" },
80 { NETSYNC_CMD_BYE, "Bye" },
81 { NETSYNC_CMD_HELLO, "Hello" },
82 { NETSYNC_CMD_ANONYMOUS, "Anonymous" },
83 { NETSYNC_CMD_AUTH, "Auth" },
84 { NETSYNC_CMD_CONFIRM, "Confirm" },
85 { NETSYNC_CMD_REFINE, "Refine" },
86 { NETSYNC_CMD_DONE, "Done" },
87 { NETSYNC_CMD_SEND_DATA, "Send Data" },
88 { NETSYNC_CMD_SEND_DELTA, "Send Delta" },
89 { NETSYNC_CMD_DATA, "Data" },
90 { NETSYNC_CMD_DELTA, "Delta" },
91 { NETSYNC_CMD_NONEXISTENT, "Nonexistent" },
95 #define NETSNYC_MERKLE_HASH_LENGTH 20
97 void proto_reg_handoff_netsync(void);
99 /* Define the monotone netsync proto */
100 static int proto_netsync = -1;
102 static int hf_netsync_version = -1;
103 static int hf_netsync_command = -1;
104 static int hf_netsync_size = -1;
105 static int hf_netsync_data = -1;
106 static int hf_netsync_checksum = -1;
108 static int hf_netsync_cmd_done_level = -1;
109 static int hf_netsync_cmd_done_type = -1;
111 static int hf_netsync_cmd_hello_keyname = -1;
112 static int hf_netsync_cmd_hello_key = -1;
113 static int hf_netsync_cmd_nonce = -1;
115 static int hf_netsync_cmd_anonymous_role = -1;
116 static int hf_netsync_cmd_anonymous_collection = -1;
118 static int hf_netsync_cmd_send_data_type = -1;
119 static int hf_netsync_cmd_send_data_id = -1;
121 static int hf_netsync_cmd_error_msg = -1;
124 static int hf_netsync_cmd_confirm_sig = -1;
126 static int hf_netsync_cmd_auth_role = -1;
127 static int hf_netsync_cmd_auth_collection = -1;
128 static int hf_netsync_cmd_auth_id = -1;
129 static int hf_netsync_cmd_auth_nonce1 = -1;
130 static int hf_netsync_cmd_auth_nonce2 = -1;
131 static int hf_netsync_cmd_auth_sig = -1;
133 static int hf_netsync_cmd_data_type = -1;
134 static int hf_netsync_cmd_data_id = -1;
135 static int hf_netsync_cmd_data_compressed = -1;
136 static int hf_netsync_cmd_data_payload = -1;
138 static int hf_netsync_cmd_delta_type = -1;
139 static int hf_netsync_cmd_delta_base_id = -1;
140 static int hf_netsync_cmd_delta_ident_id = -1;
141 static int hf_netsync_cmd_delta_compressed = -1;
142 static int hf_netsync_cmd_delta_payload = -1;
144 static int hf_netsync_cmd_refine_tree_node = -1;
146 static int hf_netsync_cmd_send_delta_type = -1;
147 static int hf_netsync_cmd_send_delta_base_id = -1;
148 static int hf_netsync_cmd_send_delta_ident_id = -1;
150 static int hf_netsync_cmd_nonexistent_type = -1;
151 static int hf_netsync_cmd_nonexistent_id = -1;
153 /* Define the tree for netsync */
154 static int ett_netsync = -1;
158 * Here are the global variables associated with the preferences
159 * for monotone netsync
162 static guint global_tcp_port_netsync = TCP_PORT_NETSYNC;
163 static gboolean netsync_desegment = TRUE;
165 static gint dissect_uleb128( tvbuff_t *tvb, gint offset, guint* size)
169 guint start_offset = offset;
175 tmp = tvb_get_guint8(tvb, offset);
178 *size |= (tmp & 0x7F) << shift;
180 } while (tmp & 0x80);
183 return offset - start_offset;
186 static gint dissect_netsync_cmd_error( tvbuff_t *tvb, gint offset, proto_tree *tree, guint size _U_)
190 offset += dissect_uleb128( tvb, offset, &len );
192 proto_tree_add_item(tree, hf_netsync_cmd_error_msg, tvb,
193 offset, len, ENC_ASCII|ENC_NA );
199 static gint dissect_netsync_cmd_bye(tvbuff_t *tvb _U_, gint offset, proto_tree *tree _U_, guint size _U_)
205 static gint dissect_netsync_cmd_hello(tvbuff_t *tvb, gint offset, proto_tree *tree, guint size _U_)
209 offset += dissect_uleb128( tvb, offset, &len );
211 proto_tree_add_item(tree, hf_netsync_cmd_hello_keyname, tvb,
212 offset, len, ENC_ASCII|ENC_NA );
216 offset += dissect_uleb128( tvb, offset, &len );
218 proto_tree_add_item(tree, hf_netsync_cmd_hello_key, tvb,
219 offset, len, ENC_NA );
222 proto_tree_add_item(tree, hf_netsync_cmd_nonce, tvb,
223 offset, NETSNYC_MERKLE_HASH_LENGTH, ENC_NA );
224 offset += NETSNYC_MERKLE_HASH_LENGTH;
230 static gint dissect_netsync_cmd_anonymous(tvbuff_t *tvb, gint offset, proto_tree *tree, guint size _U_)
234 proto_tree_add_item(tree, hf_netsync_cmd_anonymous_role, tvb,
235 offset, 1, ENC_BIG_ENDIAN );
238 offset += dissect_uleb128( tvb, offset, &len );
240 proto_tree_add_item(tree, hf_netsync_cmd_anonymous_collection, tvb,
241 offset, len, ENC_ASCII|ENC_NA );
244 proto_tree_add_item(tree, hf_netsync_cmd_nonce, tvb,
245 offset, NETSNYC_MERKLE_HASH_LENGTH, ENC_NA );
246 offset += NETSNYC_MERKLE_HASH_LENGTH;
252 static gint dissect_netsync_cmd_auth(tvbuff_t *tvb, gint offset, proto_tree *tree, guint size _U_)
256 proto_tree_add_item(tree, hf_netsync_cmd_auth_role, tvb,
257 offset, 1, ENC_BIG_ENDIAN );
261 offset += dissect_uleb128( tvb, offset, &len );
263 proto_tree_add_item(tree, hf_netsync_cmd_auth_collection, tvb,
264 offset, len, ENC_ASCII|ENC_NA );
267 proto_tree_add_item(tree, hf_netsync_cmd_auth_id, tvb,
268 offset, NETSNYC_MERKLE_HASH_LENGTH, ENC_NA );
269 offset += NETSNYC_MERKLE_HASH_LENGTH;
273 proto_tree_add_item(tree, hf_netsync_cmd_auth_nonce1, tvb,
274 offset, NETSNYC_MERKLE_HASH_LENGTH, ENC_NA );
275 offset += NETSNYC_MERKLE_HASH_LENGTH;
279 proto_tree_add_item(tree, hf_netsync_cmd_auth_nonce2, tvb,
280 offset, NETSNYC_MERKLE_HASH_LENGTH, ENC_NA );
281 offset += NETSNYC_MERKLE_HASH_LENGTH;
283 offset += dissect_uleb128( tvb, offset, &len );
285 proto_tree_add_item(tree, hf_netsync_cmd_auth_sig, tvb,
286 offset, len, ENC_NA );
293 static gint dissect_netsync_cmd_confirm(tvbuff_t *tvb, gint offset, proto_tree *tree, guint size _U_)
297 offset += dissect_uleb128( tvb, offset, &len );
299 proto_tree_add_item(tree, hf_netsync_cmd_confirm_sig, tvb,
300 offset, len, ENC_NA );
308 static gint dissect_netsync_cmd_refine(tvbuff_t *tvb, gint offset, proto_tree *tree, guint size)
310 proto_tree_add_item(tree, hf_netsync_cmd_refine_tree_node, tvb,
311 offset, size, ENC_NA );
318 static gint dissect_netsync_cmd_done(tvbuff_t *tvb, gint offset, proto_tree *tree, guint size _U_)
323 bytes = dissect_uleb128( tvb, offset, &len );
325 proto_tree_add_uint(tree, hf_netsync_cmd_done_level, tvb,
326 offset, bytes, len );
329 proto_tree_add_item(tree, hf_netsync_cmd_done_type, tvb,
330 offset, 1, ENC_BIG_ENDIAN );
337 static gint dissect_netsync_cmd_send_data(tvbuff_t *tvb, gint offset, proto_tree *tree, guint size _U_)
339 proto_tree_add_item(tree, hf_netsync_cmd_send_data_type, tvb,
340 offset, 1, ENC_BIG_ENDIAN );
343 proto_tree_add_item(tree, hf_netsync_cmd_send_data_id, tvb,
344 offset, NETSNYC_MERKLE_HASH_LENGTH, ENC_NA );
345 offset += NETSNYC_MERKLE_HASH_LENGTH;
351 static gint dissect_netsync_cmd_send_delta(tvbuff_t *tvb, gint offset, proto_tree *tree, guint size _U_)
353 proto_tree_add_item(tree, hf_netsync_cmd_send_delta_type, tvb,
354 offset, 1, ENC_BIG_ENDIAN );
357 proto_tree_add_item(tree, hf_netsync_cmd_send_delta_base_id, tvb,
358 offset, NETSNYC_MERKLE_HASH_LENGTH, ENC_NA );
359 offset += NETSNYC_MERKLE_HASH_LENGTH;
362 proto_tree_add_item(tree, hf_netsync_cmd_send_delta_ident_id, tvb,
363 offset, NETSNYC_MERKLE_HASH_LENGTH, ENC_NA );
364 offset += NETSNYC_MERKLE_HASH_LENGTH;
370 static gint dissect_netsync_cmd_data(tvbuff_t *tvb, gint offset, proto_tree *tree, guint size _U_)
374 proto_tree_add_item(tree, hf_netsync_cmd_data_type, tvb,
375 offset, 1, ENC_BIG_ENDIAN );
378 proto_tree_add_item(tree, hf_netsync_cmd_data_id, tvb,
379 offset, NETSNYC_MERKLE_HASH_LENGTH, ENC_NA );
380 offset += NETSNYC_MERKLE_HASH_LENGTH;
382 proto_tree_add_item(tree, hf_netsync_cmd_data_compressed, tvb,
383 offset, 1, ENC_BIG_ENDIAN );
386 offset += dissect_uleb128( tvb, offset, &len );
388 proto_tree_add_item(tree, hf_netsync_cmd_data_payload, tvb,
389 offset, len, ENC_NA );
396 static gint dissect_netsync_cmd_delta(tvbuff_t *tvb, gint offset, proto_tree *tree, guint size _U_)
400 proto_tree_add_item(tree, hf_netsync_cmd_delta_type, tvb,
401 offset, 1, ENC_BIG_ENDIAN );
404 proto_tree_add_item(tree, hf_netsync_cmd_delta_base_id, tvb,
405 offset, NETSNYC_MERKLE_HASH_LENGTH, ENC_NA );
406 offset += NETSNYC_MERKLE_HASH_LENGTH;
408 proto_tree_add_item(tree, hf_netsync_cmd_delta_ident_id, tvb,
409 offset, NETSNYC_MERKLE_HASH_LENGTH, ENC_NA );
410 offset += NETSNYC_MERKLE_HASH_LENGTH;
412 proto_tree_add_item(tree, hf_netsync_cmd_delta_compressed, tvb,
413 offset, 1, ENC_BIG_ENDIAN );
416 offset += dissect_uleb128( tvb, offset, &len );
418 proto_tree_add_item(tree, hf_netsync_cmd_delta_payload, tvb,
419 offset, len, ENC_NA );
426 static gint dissect_netsync_cmd_nonexistent(tvbuff_t *tvb, gint offset, proto_tree *tree, guint size _U_)
428 proto_tree_add_item(tree, hf_netsync_cmd_nonexistent_type, tvb,
429 offset, 1, ENC_BIG_ENDIAN );
432 proto_tree_add_item(tree, hf_netsync_cmd_nonexistent_id, tvb,
433 offset, NETSNYC_MERKLE_HASH_LENGTH, ENC_NA );
434 offset += NETSNYC_MERKLE_HASH_LENGTH;
440 get_netsync_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset)
442 guint size = 0, size_bytes;
444 /* skip version and command */
447 size_bytes = dissect_uleb128( tvb, offset, &size );
449 /* the calculated size if for the data only, this doesn't
450 * include the version (1 byte), command (1 byte),
451 * length (size_bytes bytes) and checksum (4 bytes)
454 return 1 + 1 + size_bytes + size + 4;
458 dissect_netsync_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
463 guint32 size, size_bytes, shift;
464 proto_tree *ti,*netsync_tree=NULL;
466 /* Set the protocol column */
467 col_set_str(pinfo->cinfo, COL_PROTOCOL, "Netsync");
473 while (tvb_reported_length_remaining(tvb, offset) > 0) {
474 ti = proto_tree_add_item(tree, proto_netsync, tvb, offset, -1, FALSE);
475 netsync_tree = proto_item_add_subtree(ti, ett_netsync);
477 version = tvb_get_guint8(tvb, offset);
478 proto_tree_add_item(netsync_tree, hf_netsync_version, tvb,
479 offset, 1, ENC_BIG_ENDIAN );
482 cmd = tvb_get_guint8(tvb, offset);
483 proto_tree_add_item(netsync_tree, hf_netsync_command, tvb,
484 offset, 1, ENC_BIG_ENDIAN );
493 tmp = tvb_get_guint8(tvb, offset + size_bytes);
496 size |= (tmp & 0x7F) << shift;
498 } while (tmp & 0x80);
501 proto_tree_add_uint(netsync_tree, hf_netsync_size, tvb,
502 offset, size_bytes, size );
503 offset += size_bytes;
506 case NETSYNC_CMD_DONE:
507 dissect_netsync_cmd_done( tvb, offset, netsync_tree, size );
510 case NETSYNC_CMD_ERROR:
511 dissect_netsync_cmd_error( tvb, offset, netsync_tree, size );
514 case NETSYNC_CMD_BYE:
515 dissect_netsync_cmd_bye( tvb, offset, netsync_tree, size );
518 case NETSYNC_CMD_HELLO:
519 dissect_netsync_cmd_hello( tvb, offset, netsync_tree, size );
522 case NETSYNC_CMD_ANONYMOUS:
523 dissect_netsync_cmd_anonymous( tvb, offset, netsync_tree, size );
526 case NETSYNC_CMD_AUTH:
527 dissect_netsync_cmd_auth( tvb, offset, netsync_tree, size );
530 case NETSYNC_CMD_CONFIRM:
531 dissect_netsync_cmd_confirm( tvb, offset, netsync_tree, size );
534 case NETSYNC_CMD_REFINE:
535 dissect_netsync_cmd_refine( tvb, offset, netsync_tree, size );
538 case NETSYNC_CMD_SEND_DATA:
539 dissect_netsync_cmd_send_data( tvb, offset, netsync_tree, size );
542 case NETSYNC_CMD_SEND_DELTA:
543 dissect_netsync_cmd_send_delta( tvb, offset, netsync_tree, size );
546 case NETSYNC_CMD_DATA:
547 dissect_netsync_cmd_data( tvb, offset, netsync_tree, size );
550 case NETSYNC_CMD_DELTA:
551 dissect_netsync_cmd_delta( tvb, offset, netsync_tree, size );
554 case NETSYNC_CMD_NONEXISTENT:
555 dissect_netsync_cmd_nonexistent( tvb, offset, netsync_tree, size );
559 proto_tree_add_item(netsync_tree, hf_netsync_data, tvb,
560 offset, size, ENC_NA );
566 proto_tree_add_item(netsync_tree, hf_netsync_checksum, tvb,
567 offset, 4, ENC_BIG_ENDIAN );
571 proto_item_append_text(netsync_tree, " V%d, Cmd: %s (%d), Size: %d",
572 version, val_to_str(cmd, netsync_cmd_vals, "(0x%x)"), cmd, size );
574 proto_item_set_len(netsync_tree, 1+1+size_bytes+size+4);
579 dissect_netsync(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
581 tcp_dissect_pdus(tvb, pinfo, tree, netsync_desegment, 7, get_netsync_pdu_len,
582 dissect_netsync_pdu);
586 proto_register_netsync(void)
588 static hf_register_info hf[] = {
590 { &hf_netsync_version,
591 { "Version", "netsync.version",
592 FT_UINT8, BASE_DEC, NULL, 0x0,
594 { &hf_netsync_command,
595 { "Command", "netsync.command",
596 FT_UINT8, BASE_HEX, VALS(netsync_cmd_vals), 0x0,
599 { "Size", "netsync.size",
600 FT_UINT32, BASE_DEC, NULL, 0x0,
603 { "Data", "netsync.data",
604 FT_BYTES, BASE_NONE, NULL, 0x0,
606 { &hf_netsync_checksum,
607 { "Checksum", "netsync.checksum",
608 FT_UINT32, BASE_HEX, NULL, 0x0,
610 { &hf_netsync_cmd_hello_keyname,
611 { "Key Name", "netsync.cmd.hello.keyname",
612 FT_STRING, BASE_NONE, NULL, 0x0,
614 { &hf_netsync_cmd_hello_key,
615 { "Key", "netsync.cmd.hello.key",
616 FT_BYTES, BASE_NONE, NULL, 0x0,
618 { &hf_netsync_cmd_nonce,
619 { "Nonce", "netsync.cmd.nonce",
620 FT_BYTES, BASE_NONE, NULL, 0x0,
622 { &hf_netsync_cmd_anonymous_role,
623 { "Role", "netsync.cmd.anonymous.role",
624 FT_UINT8, BASE_DEC, VALS(netsync_role_vals), 0x0,
626 { &hf_netsync_cmd_anonymous_collection,
627 { "Collection", "netsync.cmd.anonymous.collection",
628 FT_STRING, BASE_NONE, NULL, 0x0,
630 { &hf_netsync_cmd_confirm_sig,
631 { "Signature", "netsync.cmd.confirm.signature",
632 FT_BYTES, BASE_NONE, NULL, 0x0,
634 { &hf_netsync_cmd_send_data_type,
635 { "Type", "netsync.cmd.send_data.type",
636 FT_UINT8, BASE_DEC, NULL, 0x0,
638 { &hf_netsync_cmd_send_data_id,
639 { "ID", "netsync.cmd.send_data.id",
640 FT_BYTES, BASE_NONE, NULL, 0x0,
642 { &hf_netsync_cmd_error_msg,
643 { "Message", "netsync.cmd.error.msg",
644 FT_STRING, BASE_NONE, NULL, 0x0,
647 { &hf_netsync_cmd_done_level,
648 { "Level", "netsync.cmd.done.level",
649 FT_UINT32, BASE_DEC, NULL, 0x0,
651 { &hf_netsync_cmd_auth_role,
652 { "Role", "netsync.cmd.auth.role",
653 FT_UINT8, BASE_DEC, VALS(netsync_role_vals), 0x0,
655 { &hf_netsync_cmd_auth_collection,
656 { "Collection", "netsync.cmd.auth.collection",
657 FT_STRING, BASE_NONE, NULL, 0x0,
659 { &hf_netsync_cmd_auth_id,
660 { "ID", "netsync.cmd.auth.id",
661 FT_BYTES, BASE_NONE, NULL, 0x0,
663 { &hf_netsync_cmd_auth_nonce1,
664 { "Nonce 1", "netsync.cmd.auth.nonce1",
665 FT_BYTES, BASE_NONE, NULL, 0x0,
667 { &hf_netsync_cmd_auth_nonce2,
668 { "Nonce 2", "netsync.cmd.auth.nonce2",
669 FT_BYTES, BASE_NONE, NULL, 0x0,
671 { &hf_netsync_cmd_auth_sig,
672 { "Signature", "netsync.cmd.auth.sig",
673 FT_BYTES, BASE_NONE, NULL, 0x0,
675 { &hf_netsync_cmd_data_type,
676 { "Type", "netsync.cmd.data.type",
677 FT_UINT8, BASE_DEC, NULL, 0x0,
679 { &hf_netsync_cmd_data_id,
680 { "ID", "netsync.cmd.data.id",
681 FT_BYTES, BASE_NONE, NULL, 0x0,
683 { &hf_netsync_cmd_data_compressed,
684 { "Compressed", "netsync.cmd.data.compressed",
685 FT_UINT8, BASE_DEC, NULL, 0x0,
687 { &hf_netsync_cmd_data_payload,
688 { "Payload", "netsync.cmd.data.payload",
689 FT_BYTES, BASE_NONE, NULL, 0x0,
691 { &hf_netsync_cmd_delta_type,
692 { "Type", "netsync.cmd.delta.type",
693 FT_UINT8, BASE_DEC, NULL, 0x0,
695 { &hf_netsync_cmd_delta_base_id,
696 { "Base ID", "netsync.cmd.delta.base_id",
697 FT_BYTES, BASE_NONE, NULL, 0x0,
699 { &hf_netsync_cmd_delta_ident_id,
700 { "Ident ID", "netsync.cmd.delta.ident_id",
701 FT_BYTES, BASE_NONE, NULL, 0x0,
703 { &hf_netsync_cmd_delta_compressed,
704 { "Compressed", "netsync.cmd.delta.compressed",
705 FT_UINT8, BASE_DEC, NULL, 0x0,
707 { &hf_netsync_cmd_delta_payload,
708 { "Payload", "netsync.cmd.delta.payload",
709 FT_BYTES, BASE_NONE, NULL, 0x0,
711 { &hf_netsync_cmd_refine_tree_node,
712 { "Tree Node", "netsync.cmd.refine.tree_node",
713 FT_BYTES, BASE_NONE, NULL, 0x0,
715 { &hf_netsync_cmd_send_delta_type,
716 { "Type", "netsync.cmd.send_delta.type",
717 FT_UINT8, BASE_DEC, NULL, 0x0,
719 { &hf_netsync_cmd_send_delta_base_id,
720 { "Base ID", "netsync.cmd.send_delta.base_id",
721 FT_BYTES, BASE_NONE, NULL, 0x0,
723 { &hf_netsync_cmd_send_delta_ident_id,
724 { "Ident ID", "netsync.cmd.send_delta.ident_id",
725 FT_BYTES, BASE_NONE, NULL, 0x0,
727 { &hf_netsync_cmd_nonexistent_id,
728 { "ID", "netsync.cmd.nonexistent.id",
729 FT_BYTES, BASE_NONE, NULL, 0x0,
731 { &hf_netsync_cmd_nonexistent_type,
732 { "Type", "netsync.cmd.nonexistent.type",
733 FT_UINT8, BASE_DEC, NULL, 0x0,
735 { &hf_netsync_cmd_done_type,
736 { "Type", "netsync.cmd.done.type",
737 FT_UINT8, BASE_DEC, NULL, 0x0,
743 static gint *ett[] = {
747 module_t *netsync_module;
749 proto_netsync = proto_register_protocol("Monotone Netsync", "Netsync", "netsync");
750 proto_register_field_array(proto_netsync, hf, array_length(hf));
751 proto_register_subtree_array(ett, array_length(ett));
753 netsync_module = prefs_register_protocol(proto_netsync,
754 proto_reg_handoff_netsync);
756 prefs_register_uint_preference(netsync_module, "tcp_port",
757 "Monotone Netsync TCP Port",
758 "The TCP port on which Monotone Netsync packets will be sent",
759 10, &global_tcp_port_netsync);
762 prefs_register_bool_preference(netsync_module, "desegment_netsync_messages",
763 "Reassemble Netsync messages spanning multiple TCP segments",
764 "Whether the Netsync dissector should reassemble messages spanning multiple TCP segments."
765 " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
771 proto_reg_handoff_netsync(void)
773 static dissector_handle_t netsync_handle;
774 static guint tcp_port_netsync;
775 static gboolean initialized = FALSE;
778 netsync_handle = create_dissector_handle(dissect_netsync, proto_netsync);
781 dissector_delete_uint("tcp.port", tcp_port_netsync, netsync_handle);
784 tcp_port_netsync = global_tcp_port_netsync;
785 dissector_add_uint("tcp.port", global_tcp_port_netsync, netsync_handle);