aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwmeier <wmeier@f5534014-38df-0310-8fa8-9805f1628bb7>2011-10-10 23:34:24 +0000
committerwmeier <wmeier@f5534014-38df-0310-8fa8-9805f1628bb7>2011-10-10 23:34:24 +0000
commitc7c95482c0cbca11d78de57a32fe7b870e9c51db (patch)
treefb477294dd74bd9634393848f616627baec65f38
parent8ba352045f72abcd267c898df81edebba7391d90 (diff)
Fix bugs which caused certain fields to display with the wrong endianness;
Specifically: some proto_tree_add_item() 'encoding' args were incorrect. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@39350 f5534014-38df-0310-8fa8-9805f1628bb7
-rw-r--r--epan/dissectors/packet-bittorrent.c2
-rw-r--r--epan/dissectors/packet-manolito.c69
2 files changed, 30 insertions, 41 deletions
diff --git a/epan/dissectors/packet-bittorrent.c b/epan/dissectors/packet-bittorrent.c
index c6abd8c9be..ba411dab3f 100644
--- a/epan/dissectors/packet-bittorrent.c
+++ b/epan/dissectors/packet-bittorrent.c
@@ -726,7 +726,7 @@ static void dissect_bittorrent_message (tvbuff_t *tvb, packet_info *pinfo, proto
offset += 4;
length -= 4;
piece_begin = tvb_get_ntohl(tvb, offset);
- proto_tree_add_item(mtree, hf_bittorrent_piece_begin, tvb, offset, 4, piece_begin);
+ proto_tree_add_item(mtree, hf_bittorrent_piece_begin, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
length -= 4;
proto_tree_add_item(mtree, hf_bittorrent_piece_data, tvb, offset, length, ENC_NA);
diff --git a/epan/dissectors/packet-manolito.c b/epan/dissectors/packet-manolito.c
index 04f999b49b..9d7745628b 100644
--- a/epan/dissectors/packet-manolito.c
+++ b/epan/dissectors/packet-manolito.c
@@ -14,12 +14,12 @@
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@@ -42,24 +42,16 @@ static int hf_manolito_checksum = -1;
static int hf_manolito_seqno = -1;
static int hf_manolito_src = -1;
static int hf_manolito_dest = -1;
+static int hf_manolito_options_short = -1;
static int hf_manolito_options = -1;
/* Initialize the subtree pointers */
static gint ett_manolito = -1;
-struct MANOLITO_HEADER {
- guint32 checksum;
- guint32 seqno;
- guint32 src;
- guint32 dest;
- guint32 options;
-};
-
/* Code to actually dissect the packets */
static void
dissect_manolito(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
- struct MANOLITO_HEADER header;
unsigned int offset;
/* Set up structures needed to add the protocol subtree and manage it */
@@ -69,39 +61,31 @@ dissect_manolito(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
/* Make entries in Protocol column and Info column on summary display */
col_set_str(pinfo->cinfo, COL_PROTOCOL, "MANOLITO");
-
+
ti = proto_tree_add_item(tree, proto_manolito, tvb, 0, -1, FALSE);
manolito_tree = proto_item_add_subtree(ti, ett_manolito);
/* MANOLITO packet header (network byte order) */
- header.checksum = tvb_get_ntohl(tvb, 0);
- header.seqno = tvb_get_ntohl(tvb, 4);
- header.src = tvb_get_ipv4(tvb, 8);
- header.dest = tvb_get_ipv4(tvb, 12);
- if (tvb_reported_length(tvb) == 19)
- {
- header.options = (tvb_get_ntohs(tvb, 16) << 8) +
- tvb_get_guint8(tvb, 18);
- packet_type = "Ping (truncated)";
- } else {
- header.options = tvb_get_ntohl(tvb, 16);
- }
-
proto_tree_add_item(manolito_tree,
- hf_manolito_checksum, tvb, 0, 4, header.checksum);
+ hf_manolito_checksum, tvb, 0, 4, ENC_BIG_ENDIAN);
proto_tree_add_item(manolito_tree,
- hf_manolito_seqno, tvb, 4, 4, header.seqno);
-
- proto_tree_add_ipv4(manolito_tree,
- hf_manolito_src, tvb, 8, 4, header.src);
+ hf_manolito_seqno, tvb, 4, 4, ENC_BIG_ENDIAN);
- proto_tree_add_ipv4(manolito_tree,
- hf_manolito_dest, tvb, 12, 4, header.dest);
+ proto_tree_add_item(manolito_tree,
+ hf_manolito_src, tvb, 8, 4, ENC_BIG_ENDIAN);
proto_tree_add_item(manolito_tree,
- hf_manolito_options, tvb, 16, 4, header.options);
+ hf_manolito_dest, tvb, 12, 4, ENC_BIG_ENDIAN);
+ if (tvb_reported_length(tvb) == 19) {
+ packet_type = "Ping (truncated)";
+ proto_tree_add_item(manolito_tree,
+ hf_manolito_options_short, tvb, 16, 3, ENC_BIG_ENDIAN);
+ } else {
+ proto_tree_add_item(manolito_tree,
+ hf_manolito_options, tvb, 16, 4, ENC_BIG_ENDIAN);
+ }
if (tvb_reported_length(tvb) <= 20) /* no payload, just headers */
{
@@ -112,7 +96,7 @@ dissect_manolito(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
/* fields format: 2-byte name, optional NULL, 1-byte lenlen, */
/* that many bytes(len or data), for NI,CN,VL is len, more */
/* (that many bytes) data follows; else is raw data. */
- do
+ do
{
guint16 field_name; /* 16-bit field name */
guint8 dtype; /* data-type */
@@ -188,7 +172,7 @@ dissect_manolito(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
*/
data = ep_alloc((guint)length + 1);
tvb_memcpy(tvb, data, ++offset, length);
- offset += length;
+ offset += length;
/* convert the 16-bit integer field name to a string */
/* XXX: changed this to use g_htons */
@@ -196,7 +180,7 @@ dissect_manolito(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
field_name_str[1] = (g_htons(field_name) & 0xff00) >> 8;
field_name_str[2] = 0;
- if (dtype == MANOLITO_STRING)
+ if (dtype == MANOLITO_STRING)
{
data[length] = 0;
proto_tree_add_text(manolito_tree, tvb, start,
@@ -237,13 +221,13 @@ dissect_manolito(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
void
proto_register_manolito(void)
-{
+{
/* Setup list of header fields See Section 1.6.1 for details*/
static hf_register_info hf[] = {
{ &hf_manolito_checksum,
{ "Checksum", "manolito.checksum",
- FT_UINT32, BASE_HEX, NULL, 0,
+ FT_UINT32, BASE_HEX, NULL, 0,
"Checksum used for verifying integrity", HFILL }
},
{ &hf_manolito_seqno,
@@ -261,11 +245,16 @@ proto_register_manolito(void)
FT_IPv4, BASE_NONE, NULL, 0,
"Destination IPv4 address", HFILL }
},
+ { &hf_manolito_options_short,
+ { "Options", "manolito.options",
+ FT_UINT24, BASE_HEX, NULL, 0,
+ "Packet-dependent data", HFILL }
+ },
{ &hf_manolito_options,
{ "Options", "manolito.options",
- FT_UINT32, BASE_HEX, NULL, 0,
+ FT_UINT32, BASE_HEX, NULL, 0,
"Packet-dependent data", HFILL }
- },
+ },
};
static gint *ett[] = {