Fixes/Updates:

- Call conversation_set_dissector();
- Fix encoding args related to use of FT_ABSOLUTE_TIME;
- Remove unneeded #include;
- Cleanup some whitespace.

svn path=/trunk/; revision=47631
This commit is contained in:
Bill Meier 2013-02-11 14:59:03 +00:00
parent 8f96a14263
commit 07d2692cad
1 changed files with 122 additions and 117 deletions

View File

@ -30,10 +30,9 @@
#include <glib.h>
#include <epan/prefs.h>
#include <epan/packet.h>
#include <epan/prefs.h>
#include <epan/expert.h>
#include <epan/strutil.h>
#include "packet-tcp.h"
@ -173,6 +172,7 @@ static gint ett_tx_in_list = -1;
static gint ett_tx_in_outp = -1;
static gint ett_tx_out_list = -1;
static dissector_handle_t bitcoin_handle;
static gboolean bitcoin_desegment = TRUE;
static const value_string inv_types[] =
@ -182,13 +182,13 @@ static const value_string inv_types[] =
{ 2, "MSG_BLOCK" },
{ 0, NULL }
};
static guint get_bitcoin_pdu_length(packet_info *pinfo _U_, tvbuff_t *tvb, int offset)
{
guint32 length;
length = BITCOIN_HEADER_LENGTH;
if(tvb_memeql(tvb, offset+4, "version", 7) != 0 &&
if (tvb_memeql(tvb, offset+4, "version", 7) != 0 &&
tvb_memeql(tvb, offset+4, "verack", 6) != 0)
{
/* add checksum field */
@ -214,7 +214,7 @@ static proto_tree *create_services_tree(tvbuff_t *tvb, proto_item *ti, guint32 o
/* start of services */
/* NOTE:
* - 2011-06-05
* Currently the boolean tree only supports a maximum of
* Currently the boolean tree only supports a maximum of
* 32 bits - so we split services in two
*/
services = tvb_get_letoh64(tvb, offset);
@ -242,11 +242,11 @@ static proto_tree *create_address_tree(tvbuff_t *tvb, proto_item *ti, guint32 of
offset += 8;
/* IPv6 address */
proto_tree_add_item(tree, hf_address_address, tvb, offset, 16, ENC_NA);
proto_tree_add_item(tree, hf_address_address, tvb, offset, 16, ENC_NA);
offset += 16;
/* port */
proto_tree_add_item(tree, hf_address_port, tvb, offset, 2, ENC_LITTLE_ENDIAN);
proto_tree_add_item(tree, hf_address_port, tvb, offset, 2, ENC_LITTLE_ENDIAN);
return tree;
}
@ -256,41 +256,41 @@ static proto_tree *create_address_tree(tvbuff_t *tvb, proto_item *ti, guint32 of
*/
static gint get_varint(tvbuff_t *tvb, const gint offset, gint *length, guint64 *ret)
{
guint64 value;
guint value;
gint remain;
remain = tvb_reported_length_remaining(tvb, offset);
if(remain < 1)
if (remain < 1)
return -1;
/* calculate variable length */
value = tvb_get_guint8(tvb, offset);
if(value < 0xfd)
if (value < 0xfd)
{
*length = 1;
*ret = value;
return 0;
}
if(value == 0xfd && remain >= 3)
if (value == 0xfd && remain >= 3)
{
*length = 3;
*ret = tvb_get_letohs(tvb, offset+1);
return 0;
}
if(value == 0xfe && remain >= 5)
if (value == 0xfe && remain >= 5)
{
*length = 5;
*ret = tvb_get_letohl(tvb, offset+1);
return 0;
}
if(remain >= 9)
if (remain >= 9)
{
*length = 9;
*ret = tvb_get_letoh64(tvb, offset+1);
return 0;
}
/* could not get varint */
return -1;
}
@ -298,10 +298,10 @@ static gint get_varint(tvbuff_t *tvb, const gint offset, gint *length, guint64 *
static void add_varint_item(proto_tree *tree, tvbuff_t *tvb, const gint offset, gint length,
gint hf8, gint hf16, gint hf32, gint hf64)
{
switch(length)
switch (length)
{
case 1:
proto_tree_add_item(tree, hf8, tvb, offset, 1, ENC_LITTLE_ENDIAN);
proto_tree_add_item(tree, hf8, tvb, offset, 1, ENC_LITTLE_ENDIAN);
break;
case 3:
proto_tree_add_item(tree, hf16, tvb, offset+1, 2, ENC_LITTLE_ENDIAN);
@ -318,7 +318,7 @@ static void add_varint_item(proto_tree *tree, tvbuff_t *tvb, const gint offset,
/**
* Handler for version messages
*/
static guint32 dissect_bitcoin_msg_version(tvbuff_t *tvb, packet_info *pinfo _U_,
static guint32 dissect_bitcoin_msg_version(tvbuff_t *tvb, packet_info *pinfo _U_,
proto_tree *tree)
{
proto_item *ti;
@ -331,23 +331,23 @@ static guint32 dissect_bitcoin_msg_version(tvbuff_t *tvb, packet_info *pinfo _U_
version = tvb_get_letohl(tvb, offset);
proto_tree_add_item(tree, hf_msg_version_version, tvb, offset, 4, ENC_LITTLE_ENDIAN);
proto_tree_add_item(tree, hf_msg_version_version, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
ti = proto_tree_add_item(tree, hf_msg_version_services, tvb, offset, 8, ENC_LITTLE_ENDIAN);
create_services_tree(tvb, ti, offset);
offset += 8;
proto_tree_add_item(tree, hf_msg_version_timestamp, tvb, offset, 8, TRUE);
proto_tree_add_item(tree, hf_msg_version_timestamp, tvb, offset, 8, ENC_TIME_TIMESPEC|ENC_LITTLE_ENDIAN);
offset += 8;
ti = proto_tree_add_item(tree, hf_msg_version_addr_me, tvb, offset, 26, ENC_NA);
create_address_tree(tvb, ti, offset);
offset += 26;
if(version >= 106)
if (version >= 106)
{
ti = proto_tree_add_item(tree, hf_msg_version_addr_you, tvb, offset, 26, ENC_NA);
ti = proto_tree_add_item(tree, hf_msg_version_addr_you, tvb, offset, 26, ENC_NA);
create_address_tree(tvb, ti, offset);
offset += 26;
@ -360,9 +360,9 @@ static guint32 dissect_bitcoin_msg_version(tvbuff_t *tvb, packet_info *pinfo _U_
proto_tree_add_item(tree, hf_msg_version_subver, tvb, offset, subver_length, ENC_ASCII|ENC_NA);
offset += subver_length;
if(version >= 209)
if (version >= 209)
{
proto_tree_add_item(tree, hf_msg_version_start_height, tvb, offset, 4, ENC_LITTLE_ENDIAN);
proto_tree_add_item(tree, hf_msg_version_start_height, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
}
}
@ -373,7 +373,7 @@ static guint32 dissect_bitcoin_msg_version(tvbuff_t *tvb, packet_info *pinfo _U_
/**
* Handler for address messages
*/
static guint32 dissect_bitcoin_msg_addr(tvbuff_t *tvb, packet_info *pinfo _U_,
static guint32 dissect_bitcoin_msg_addr(tvbuff_t *tvb, packet_info *pinfo _U_,
proto_tree *tree)
{
proto_item *ti;
@ -383,21 +383,21 @@ static guint32 dissect_bitcoin_msg_addr(tvbuff_t *tvb, packet_info *pinfo _U_,
ti = proto_tree_add_item(tree, hf_bitcoin_msg_addr, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(ti, ett_bitcoin_msg);
if (get_varint(tvb, offset, &length, &count))
return offset;
add_varint_item(tree, tvb, offset, length, hf_msg_addr_count8, hf_msg_addr_count16,
add_varint_item(tree, tvb, offset, length, hf_msg_addr_count8, hf_msg_addr_count16,
hf_msg_addr_count32, hf_msg_addr_count64);
offset += length;
for(; count > 0; count--)
for (; count > 0; count--)
{
proto_tree *subtree;
ti = proto_tree_add_item(tree, hf_msg_addr_address, tvb, offset, 30, ENC_NA);
subtree = create_address_tree(tvb, ti, offset+4);
proto_tree_add_item(subtree, hf_msg_addr_timestamp, tvb, offset, 4, TRUE);
proto_tree_add_item(subtree, hf_msg_addr_timestamp, tvb, offset, 4, ENC_TIME_TIMESPEC|ENC_LITTLE_ENDIAN);
offset += 26;
offset += 4;
}
@ -421,10 +421,10 @@ static guint32 dissect_bitcoin_msg_inv(tvbuff_t *tvb, packet_info *pinfo _U_,
if (get_varint(tvb, offset, &length, &count))
return offset;
add_varint_item(tree, tvb, offset, length, hf_msg_inv_count8, hf_msg_inv_count16,
add_varint_item(tree, tvb, offset, length, hf_msg_inv_count8, hf_msg_inv_count16,
hf_msg_inv_count32, hf_msg_inv_count64);
for(; count > 0; count--)
for (; count > 0; count--)
{
proto_tree *subtree;
@ -457,7 +457,7 @@ static guint32 dissect_bitcoin_msg_getdata(tvbuff_t *tvb, packet_info *pinfo _U_
if (get_varint(tvb, offset, &length, &count))
return offset;
add_varint_item(tree, tvb, offset, length, hf_msg_getdata_count8, hf_msg_getdata_count16,
add_varint_item(tree, tvb, offset, length, hf_msg_getdata_count8, hf_msg_getdata_count16,
hf_msg_getdata_count32, hf_msg_getdata_count64);
/* The if (tree) check is necessary, as otherwise very large values for
@ -470,7 +470,7 @@ static guint32 dissect_bitcoin_msg_getdata(tvbuff_t *tvb, packet_info *pinfo _U_
*/
if (tree)
{
for(; count > 0; count--)
for (; count > 0; count--)
{
proto_tree *subtree;
@ -501,17 +501,17 @@ static guint32 dissect_bitcoin_msg_getblocks(tvbuff_t *tvb, packet_info *pinfo _
ti = proto_tree_add_item(tree, hf_bitcoin_msg_getblocks, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(ti, ett_bitcoin_msg);
/* why the protcol version is sent here nobody knows */
proto_tree_add_item(tree, hf_msg_version_version, tvb, offset, 4, ENC_LITTLE_ENDIAN);
proto_tree_add_item(tree, hf_msg_version_version, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
if (get_varint(tvb, offset, &length, &count))
return offset;
add_varint_item(tree, tvb, offset, length, hf_msg_getblocks_count8, hf_msg_getblocks_count16,
add_varint_item(tree, tvb, offset, length, hf_msg_getblocks_count8, hf_msg_getblocks_count16,
hf_msg_getblocks_count32, hf_msg_getblocks_count64);
for(; count > 0; count--)
for (; count > 0; count--)
{
proto_tree_add_item(tree, hf_msg_getblocks_start, tvb, offset, 32, ENC_NA);
offset += 32;
@ -535,13 +535,13 @@ static guint32 dissect_bitcoin_msg_getheaders(tvbuff_t *tvb, packet_info *pinfo
ti = proto_tree_add_item(tree, hf_bitcoin_msg_getheaders, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(ti, ett_bitcoin_msg);
if (get_varint(tvb, offset, &length, &count))
return offset;
add_varint_item(tree, tvb, offset, length, hf_msg_getheaders_count8, hf_msg_getheaders_count16,
add_varint_item(tree, tvb, offset, length, hf_msg_getheaders_count8, hf_msg_getheaders_count16,
hf_msg_getheaders_count32, hf_msg_getheaders_count64);
for(; count > 0; count--)
for (; count > 0; count--)
{
proto_tree_add_item(tree, hf_msg_getheaders_start, tvb, offset, 32, ENC_NA);
offset += 32;
@ -571,10 +571,10 @@ static guint32 dissect_bitcoin_msg_tx(tvbuff_t *tvb, packet_info *pinfo _U_,
if (get_varint(tvb, offset, &count_length, &in_count))
return offset;
add_varint_item(tree, tvb, offset, count_length, hf_msg_tx_in_count8, hf_msg_tx_in_count16,
add_varint_item(tree, tvb, offset, count_length, hf_msg_tx_in_count8, hf_msg_tx_in_count16,
hf_msg_tx_in_count32, hf_msg_tx_in_count64);
for(; in_count > 0; in_count--)
for (; in_count > 0; in_count--)
{
proto_tree *subtree;
proto_tree *prevtree;
@ -585,11 +585,11 @@ static guint32 dissect_bitcoin_msg_tx(tvbuff_t *tvb, packet_info *pinfo _U_,
if (get_varint(tvb, offset, &count_length, &script_length))
return offset;
ti = proto_tree_add_item(tree, hf_msg_tx_in, tvb, offset,
ti = proto_tree_add_item(tree, hf_msg_tx_in, tvb, offset,
40+count_length+(guint)script_length, ENC_NA);
subtree = proto_item_add_subtree(ti, ett_tx_in_list);
add_varint_item(subtree, tvb, offset, count_length, hf_msg_tx_in_script8, hf_msg_tx_in_script16,
add_varint_item(subtree, tvb, offset, count_length, hf_msg_tx_in_script8, hf_msg_tx_in_script16,
hf_msg_tx_in_script32, hf_msg_tx_in_script64);
/* previous output */
@ -614,17 +614,17 @@ static guint32 dissect_bitcoin_msg_tx(tvbuff_t *tvb, packet_info *pinfo _U_,
if (get_varint(tvb, offset, &count_length, &out_count))
return offset;
add_varint_item(tree, tvb, offset, count_length, hf_msg_tx_out_count8, hf_msg_tx_out_count16,
add_varint_item(tree, tvb, offset, count_length, hf_msg_tx_out_count8, hf_msg_tx_out_count16,
hf_msg_tx_out_count32, hf_msg_tx_out_count64);
for(; out_count > 0; out_count--)
for (; out_count > 0; out_count--)
{
proto_item *ti;
proto_tree *subtree;
/* XXX - currently isn't read, may need to be a 64-bit value */
guint script_length = 0;
ti = proto_tree_add_item(tree, hf_msg_tx_out, tvb, offset,
ti = proto_tree_add_item(tree, hf_msg_tx_out, tvb, offset,
8+script_length+count_length, ENC_NA);
subtree = proto_item_add_subtree(ti, ett_tx_out_list);
@ -669,9 +669,9 @@ static guint32 dissect_bitcoin_msg_block(tvbuff_t *tvb, packet_info *pinfo _U_,
proto_tree_add_item(tree, hf_msg_block_merkle_root, tvb, offset, 32, ENC_NA);
offset += 32;
proto_tree_add_item(tree, hf_msg_block_time, tvb, offset, 4, TRUE);
proto_tree_add_item(tree, hf_msg_block_time, tvb, offset, 4, ENC_TIME_TIMESPEC|ENC_LITTLE_ENDIAN);
offset += 4;
proto_tree_add_item(tree, hf_msg_block_bits, tvb, offset, 4, ENC_LITTLE_ENDIAN);
offset += 4;
@ -680,10 +680,10 @@ static guint32 dissect_bitcoin_msg_block(tvbuff_t *tvb, packet_info *pinfo _U_,
if (get_varint(tvb, offset, &length, &count))
return offset;
add_varint_item(tree, tvb, offset, length, hf_msg_block_transactions8, hf_msg_block_transactions16,
add_varint_item(tree, tvb, offset, length, hf_msg_block_transactions8, hf_msg_block_transactions16,
hf_msg_block_transactions32, hf_msg_block_transactions64);
for(; count > 0; count--)
for (; count > 0; count--)
{
tvbuff_t *tvb_sub;
guint32 tx_offset;
@ -692,7 +692,7 @@ static guint32 dissect_bitcoin_msg_block(tvbuff_t *tvb, packet_info *pinfo _U_,
tx_offset = dissect_bitcoin_msg_tx(tvb_sub, pinfo, tree);
/* check for errors */
if(tx_offset == (guint32)-1)
if (tx_offset == (guint32)-1)
return -1;
offset += tx_offset;
@ -710,38 +710,38 @@ static guint32 dissect_bitcoin_msg_empty(tvbuff_t *tvb _U_, packet_info *pinfo _
return 0;
}
typedef guint32 (*msg_dissector_func_t)(tvbuff_t *tvb, packet_info *pinfo,
typedef guint32 (*msg_dissector_func_t)(tvbuff_t *tvb, packet_info *pinfo,
proto_tree *tree);
typedef struct msg_dissector
{
{
const gchar *command;
msg_dissector_func_t function;
} msg_dissector_t;
static msg_dissector_t msg_dissectors[] =
{
{"version", dissect_bitcoin_msg_version},
{"addr", dissect_bitcoin_msg_addr},
{"inv", dissect_bitcoin_msg_inv},
{"getdata", dissect_bitcoin_msg_getdata},
{"getblocks", dissect_bitcoin_msg_getblocks},
{"getheaders", dissect_bitcoin_msg_getheaders},
{"tx", dissect_bitcoin_msg_tx},
{"block", dissect_bitcoin_msg_block},
{"version", dissect_bitcoin_msg_version},
{"addr", dissect_bitcoin_msg_addr},
{"inv", dissect_bitcoin_msg_inv},
{"getdata", dissect_bitcoin_msg_getdata},
{"getblocks", dissect_bitcoin_msg_getblocks},
{"getheaders", dissect_bitcoin_msg_getheaders},
{"tx", dissect_bitcoin_msg_tx},
{"block", dissect_bitcoin_msg_block},
/* messages with no payload */
{"verack", dissect_bitcoin_msg_empty},
{"getaddr", dissect_bitcoin_msg_empty},
{"block", dissect_bitcoin_msg_empty},
{"ping", dissect_bitcoin_msg_empty},
{"verack", dissect_bitcoin_msg_empty},
{"getaddr", dissect_bitcoin_msg_empty},
{"block", dissect_bitcoin_msg_empty},
{"ping", dissect_bitcoin_msg_empty},
/* messages not implemented */
{"headers", dissect_bitcoin_msg_empty},
{"checkorder", dissect_bitcoin_msg_empty},
{"headers", dissect_bitcoin_msg_empty},
{"checkorder", dissect_bitcoin_msg_empty},
{"submitorder", dissect_bitcoin_msg_empty},
{"reply", dissect_bitcoin_msg_empty},
{"alert", dissect_bitcoin_msg_empty}
{"reply", dissect_bitcoin_msg_empty},
{"alert", dissect_bitcoin_msg_empty}
};
static void dissect_bitcoin_tcp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
@ -762,7 +762,7 @@ static void dissect_bitcoin_tcp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tre
offset = 20;
if(tvb_memeql(tvb, 4, "version", 7) != 0 &&
if (tvb_memeql(tvb, 4, "version", 7) != 0 &&
tvb_memeql(tvb, 4, "verack", 6) != 0)
{
proto_tree_add_item(tree, hf_bitcoin_checksum, tvb, 20, 4, ENC_BIG_ENDIAN);
@ -772,9 +772,9 @@ static void dissect_bitcoin_tcp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tre
}
/* handle command specific message part */
for(i = 0; i < array_length(msg_dissectors); i++)
for (i = 0; i < array_length(msg_dissectors); i++)
{
if(tvb_memeql(tvb, 4, msg_dissectors[i].command,
if (tvb_memeql(tvb, 4, msg_dissectors[i].command,
strlen(msg_dissectors[i].command)) == 0)
{
tvbuff_t *tvb_sub;
@ -797,7 +797,7 @@ static int
dissect_bitcoin(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
col_clear(pinfo->cinfo, COL_INFO);
tcp_dissect_pdus(tvb, pinfo, tree, bitcoin_desegment, BITCOIN_HEADER_LENGTH,
tcp_dissect_pdus(tvb, pinfo, tree, bitcoin_desegment, BITCOIN_HEADER_LENGTH,
get_bitcoin_pdu_length, dissect_bitcoin_tcp_pdu);
return tvb_reported_length(tvb);
@ -807,7 +807,9 @@ static gboolean
dissect_bitcoin_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
guint32 magic_number;
if (tvb_reported_length(tvb) < 4)
conversation_t *conversation;
if (tvb_length(tvb) < 4)
return FALSE;
magic_number = tvb_get_letohl(tvb, 0);
@ -816,6 +818,10 @@ dissect_bitcoin_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *
(magic_number != BITCOIN_TESTNET3_MAGIC_NUMBER))
return FALSE;
/* Ok: This connection should always use the bitcoin dissector */
conversation = find_or_create_conversation(pinfo);
conversation_set_dissector(conversation, bitcoin_handle);
dissect_bitcoin(tvb, pinfo, tree, data);
return TRUE;
}
@ -826,10 +832,10 @@ proto_register_bitcoin(void)
static hf_register_info hf[] = {
{ &hf_bitcoin_magic,
{ "Packet magic", "bitcoin.magic", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }
},
},
{ &hf_bitcoin_command,
{ "Command name", "bitcoin.command", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
},
{ &hf_bitcoin_length,
{ "Payload Length", "bitcoin.length", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
@ -846,13 +852,13 @@ proto_register_bitcoin(void)
},
{ &hf_msg_version_services,
{ "Node services", "bitcoin.version.services", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL }
},
},
{ &hf_msg_version_addr_me,
{ "Address of emmitting node", "bitcoin.version.addr_me", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
},
{ &hf_msg_version_addr_you,
{ "Address as seen by the emitting node", "bitcoin.version.addr_you", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
},
{ &hf_msg_version_timestamp,
{ "Node timestamp", "bitcoin.version.timestamp", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0, NULL, HFILL }
},
@ -884,10 +890,10 @@ proto_register_bitcoin(void)
},
{ &hf_msg_addr_address,
{ "Address", "bitcoin.addr.address", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
},
{ &hf_msg_addr_timestamp,
{ "Address timestamp", "bitcoin.addr.timestamp", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0, NULL, HFILL }
},
},
/* inv message */
{ &hf_msg_inv_count8,
@ -907,10 +913,10 @@ proto_register_bitcoin(void)
},
{ &hf_msg_inv_type,
{ "Type", "bitcoin.inv.type", FT_UINT32, BASE_DEC, VALS(inv_types), 0x0, NULL, HFILL }
},
},
{ &hf_msg_inv_hash,
{ "Data hash", "bitcoin.inv.hash", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
},
/* getdata message */
{ &hf_msg_getdata_count8,
@ -930,10 +936,10 @@ proto_register_bitcoin(void)
},
{ &hf_msg_getdata_type,
{ "Type", "bitcoin.getdata.type", FT_UINT32, BASE_DEC, VALS(inv_types), 0x0, NULL, HFILL }
},
},
{ &hf_msg_getdata_hash,
{ "Data hash", "bitcoin.getdata.hash", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
},
/* getblocks message */
{ &hf_msg_getblocks_count8,
@ -953,10 +959,10 @@ proto_register_bitcoin(void)
},
{ &hf_msg_getblocks_start,
{ "Starting hash", "bitcoin.getblocks.hash_start", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
},
{ &hf_msg_getblocks_stop,
{ "Stopping hash", "bitcoin.getblocks.hash_stop", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
},
/* getheaders message */
{ &hf_msg_getheaders_count8,
@ -976,10 +982,10 @@ proto_register_bitcoin(void)
},
{ &hf_msg_getheaders_start,
{ "Starting hash", "bitcoin.getheaders.hash_start", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
},
{ &hf_msg_getheaders_stop,
{ "Stopping hash", "bitcoin.getheaders.hash_stop", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
},
/* tx message */
{ &hf_msg_tx_in_count8,
@ -999,7 +1005,7 @@ proto_register_bitcoin(void)
},
{ &hf_msg_tx_version,
{ "Transaction version", "bitcoin.tx.version", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
},
/* tx message - input */
{ &hf_msg_tx_in_script8,
{ "Script Length", "bitcoin.tx.in.script_length", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }
@ -1015,10 +1021,10 @@ proto_register_bitcoin(void)
},
{ &hf_msg_tx_in,
{ "Transaction input", "bitcoin.tx.in", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
},
{ &hf_msg_tx_in_prev_output,
{ "Previous output", "bitcoin.tx.in.prev_output", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
},
{ &hf_msg_tx_out_count8,
{ "Output Count", "bitcoin.tx.output_count", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
@ -1033,29 +1039,29 @@ proto_register_bitcoin(void)
},
{ &hf_msg_tx_outp_hash,
{ "Hash", "bitcoin.tx.in.prev_output.hash", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
},
{ &hf_msg_tx_outp_index,
{ "Index", "bitcoin.tx.in.prev_output.index", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
},
{ &hf_msg_tx_in_sig_script,
{ "Signature script", "bitcoin.tx.in.sig_script", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
},
{ &hf_msg_tx_in_seq,
{ "Sequence", "bitcoin.tx.in.seq", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
/* tx message - output */
},
/* tx message - output */
{ &hf_msg_tx_out,
{ "Transaction output", "bitcoin.tx.out", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
},
{ &hf_msg_tx_out_value,
{ "Value", "bitcoin.tx.out.value", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
},
{ &hf_msg_tx_out_script,
{ "Script", "bitcoin.tx.out.script", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
},
{ &hf_msg_tx_lock_time,
{ "Block lock time or block ID", "bitcoin.tx.lock_time", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
},
/* block message */
{ &hf_msg_block_transactions8,
@ -1075,38 +1081,38 @@ proto_register_bitcoin(void)
},
{ &hf_msg_block_version,
{ "Block version", "bitcoin.block.version", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
},
},
{ &hf_msg_block_prev_block,
{ "Previous block", "bitcoin.block.prev_block", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
},
{ &hf_msg_block_merkle_root,
{ "Merkle root", "bitcoin.block.merkle_root", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
},
{ &hf_msg_block_time,
{ "Block timestamp", "bitcoin.block.timestamp", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0, NULL, HFILL }
},
{ &hf_msg_block_bits,
{ "Bits", "bitcoin.block.merkle_root", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }
},
},
{ &hf_msg_block_nonce,
{ "Nonce", "bitcoin.block.nonce", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }
},
},
/* services */
{ &hf_services_network,
{ "Network node", "bitcoin.services.network", FT_BOOLEAN, 32, TFS(&tfs_set_notset), 0x1, NULL, HFILL }
},
},
/* address */
{ &hf_address_services,
{ "Node services", "bitcoin.address.services", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL }
},
},
{ &hf_address_address,
{ "Node address", "bitcoin.address.address", FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }
},
},
{ &hf_address_port,
{ "Node port", "bitcoin.address.port", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
}
}
};
static gint *ett[] = {
@ -1136,19 +1142,18 @@ proto_register_bitcoin(void)
bitcoin_module = prefs_register_protocol(proto_bitcoin, NULL);
prefs_register_bool_preference(bitcoin_module, "desegment",
"Desegment all Bitcoin messages spanning multiple TCP segments",
"Whether the Bitcoin dissector should desegment all messages spanning multiple TCP segments",
&bitcoin_desegment);
"Desegment all Bitcoin messages spanning multiple TCP segments",
"Whether the Bitcoin dissector should desegment all messages"
" spanning multiple TCP segments",
&bitcoin_desegment);
}
void
void
proto_reg_handoff_bitcoin(void)
{
static dissector_handle_t bitcoin_handle;
bitcoin_handle = find_dissector("bitcoin");
dissector_add_handle("tcp.port", bitcoin_handle);
dissector_add_handle("tcp.port", bitcoin_handle); /* for 'decode-as' */
heur_dissector_add( "tcp", dissect_bitcoin_heur, proto_bitcoin);
}