summaryrefslogtreecommitdiff
path: root/epan/dissectors/packet-bzr.c
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2014-02-03 00:36:50 +0000
committerEvan Huus <eapache@gmail.com>2014-02-04 14:24:13 +0000
commit53404776be11d66574c4849ddfb7dd10f63f8854 (patch)
tree5b022220ec7b4715fabacd4b1461ae4fa08acf78 /epan/dissectors/packet-bzr.c
parent19873060150648c91fcc19b099f332f7d9f119e3 (diff)
downloadwireshark-53404776be11d66574c4849ddfb7dd10f63f8854.tar.gz
Split out bencode dissector and use it in the bzr dissector.
Change-Id: I5b2ef173faf7670fad64298d67f2aaf055b8d6d8 Signed-Off-By: Jelmer Vernooij <jelmer@samba.org> Reviewed-on: https://code.wireshark.org/review/82 Reviewed-by: Evan Huus <eapache@gmail.com> Tested-by: Evan Huus <eapache@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-bzr.c')
-rw-r--r--epan/dissectors/packet-bzr.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/epan/dissectors/packet-bzr.c b/epan/dissectors/packet-bzr.c
index 1b89a086b2..709ca04c70 100644
--- a/epan/dissectors/packet-bzr.c
+++ b/epan/dissectors/packet-bzr.c
@@ -1,6 +1,6 @@
/* packet-bzr.c
* Routines for Bazaar packet dissection
- * Copyright 2011, Jelmer Vernooij <jelmer@samba.org>
+ * Copyright 2011,2013 Jelmer Vernooij <jelmer@samba.org>
*
* http://doc.bazaar.canonical.com/developers/network-protocol.html
*
@@ -45,7 +45,6 @@ static gint ett_prefixed_bytes = -1;
static gint hf_bzr_prefixed_bencode = -1;
static gint hf_bzr_prefixed_bencode_len = -1;
-static gint hf_bzr_prefixed_bencode_data = -1;
static gint hf_bzr_bytes = -1;
static gint hf_bzr_bytes_data = -1;
static gint hf_bzr_bytes_length = -1;
@@ -53,6 +52,8 @@ static gint hf_bzr_result = -1;
static gint hf_bzr_packet_protocol_version = -1;
static gint hf_bzr_packet_kind = -1;
+static dissector_handle_t bencode_handle;
+
#define REQUEST_VERSION_TWO "bzr request 2\n"
#define RESPONSE_VERSION_TWO "bzr response 2\n"
#define MESSAGE_VERSION_THREE "bzr message 3 (bzr 1.6)\n"
@@ -123,7 +124,7 @@ get_bzr_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset)
}
static gint
-dissect_prefixed_bencode(tvbuff_t *tvb, gint offset, packet_info *pinfo _U_,
+dissect_prefixed_bencode(tvbuff_t *tvb, gint offset, packet_info *pinfo,
proto_tree *tree)
{
guint32 plen;
@@ -138,11 +139,12 @@ dissect_prefixed_bencode(tvbuff_t *tvb, gint offset, packet_info *pinfo _U_,
if (prefixed_bencode_tree)
{
+ tvbuff_t *subtvb;
proto_tree_add_item(prefixed_bencode_tree, hf_bzr_prefixed_bencode_len,
tvb, offset, 4, ENC_BIG_ENDIAN);
- proto_tree_add_item(prefixed_bencode_tree, hf_bzr_prefixed_bencode_data,
- tvb, offset+4, plen, ENC_NA);
+ subtvb = tvb_new_subset(tvb, offset+4, plen, plen);
+ call_dissector(bencode_handle, subtvb, pinfo, prefixed_bencode_tree);
}
return 4 + plen;
@@ -277,10 +279,6 @@ proto_register_bzr(void)
{ "Bencode packet length", "bzr.bencode.length", FT_UINT32,
BASE_HEX, NULL, 0x0, NULL, HFILL },
},
- { &hf_bzr_prefixed_bencode_data,
- { "Bencode packet data", "bzr.bencode.data", FT_BYTES, BASE_NONE,
- NULL, 0x0, NULL, HFILL },
- },
{ &hf_bzr_bytes,
{ "Prefixed bytes", "bzr.bytes", FT_BYTES, BASE_NONE, NULL, 0x0,
"Bytes field with prefixed 32-bit length", HFILL },
@@ -328,6 +326,8 @@ proto_reg_handoff_bzr(void)
{
dissector_handle_t bzr_handle;
+ bencode_handle = find_dissector("bencode");
+
bzr_handle = find_dissector("bzr");
dissector_add_uint("tcp.port", TCP_PORT_BZR, bzr_handle);
}