diff options
author | Michael Mann <mmann78@netscape.net> | 2014-08-09 13:43:44 -0400 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2014-08-10 21:39:20 +0000 |
commit | 3635d7bed70aaf14e8172654f2b40be318e7dbfe (patch) | |
tree | 4b0fce1dba327df9a24b4ddc267a83375c817683 /epan/dissectors/packet-homeplug.c | |
parent | 18346c84778019fe6eee6906758daa120f84d5d0 (diff) |
Eliminate proto_tree_add_text from some dissectors.
Other minor cleanup while in the neighborhood.
Change-Id: Ib76f4a9f89b5933425760af0a980c6a549031b8f
Reviewed-on: https://code.wireshark.org/review/3537
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/dissectors/packet-homeplug.c')
-rw-r--r-- | epan/dissectors/packet-homeplug.c | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/epan/dissectors/packet-homeplug.c b/epan/dissectors/packet-homeplug.c index 9cad7a3b59..2ef8840eb8 100644 --- a/epan/dissectors/packet-homeplug.c +++ b/epan/dissectors/packet-homeplug.c @@ -28,6 +28,7 @@ #include <glib.h> #include <epan/packet.h> +#include <epan/expert.h> #include <epan/etypes.h> @@ -159,6 +160,7 @@ static int hf_homeplug_ns_extended = -1; static int hf_homeplug_ns_netw_ctrl_ac = -1; static int hf_homeplug_ns_netw_ctrl_icid = -1; static int hf_homeplug_ns_bytes40_robo = -1; +static int hf_homeplug_ns_mhz = -1; static int hf_homeplug_ns_fails_robo = -1; static int hf_homeplug_ns_drops_robo = -1; static int hf_homeplug_ns_netw_da = -1; @@ -228,6 +230,7 @@ static gint ett_homeplug_bcn = -1; static gint ett_homeplug_bcl = -1; static gint ett_homeplug_stc = -1; +static expert_field ei_homeplug_tone_map_not_exist = EI_INIT; static guint8 homeplug_ne = 0; static guint8 homeplug_melen = 0; @@ -1016,7 +1019,6 @@ static void dissect_homeplug_ns(ptvcursor_t * cursor, packet_info * pinfo) guint8 iTone = 0; guint8 i_buffer = 0; - guint16 ns_bytes40 = 0; guint64 newt_da = 0; gboolean extended = (homeplug_melen >= HOMEPLUG_NS_EXT_LEN); proto_item * ti; @@ -1038,11 +1040,7 @@ static void dissect_homeplug_ns(ptvcursor_t * cursor, packet_info * pinfo) ptvcursor_add(cursor, hf_homeplug_ns_netw_ctrl_icid, 1, ENC_BIG_ENDIAN); ptvcursor_add_no_advance(cursor, hf_homeplug_ns_bytes40_robo, 2, ENC_LITTLE_ENDIAN); - ns_bytes40 = tvb_get_letohs(ptvcursor_tvbuff(cursor), - ptvcursor_current_offset(cursor)); - proto_tree_add_text(ptvcursor_tree(cursor), ptvcursor_tvbuff(cursor), - ptvcursor_current_offset(cursor), 2, "MHz : %.3f", (float)(ns_bytes40)/42); - ptvcursor_advance(cursor, 2); + ptvcursor_add(cursor, hf_homeplug_ns_mhz, 2, ENC_BIG_ENDIAN); ptvcursor_add(cursor, hf_homeplug_ns_fails_robo, 2, ENC_LITTLE_ENDIAN); ptvcursor_add(cursor, hf_homeplug_ns_drops_robo, 2, ENC_LITTLE_ENDIAN); @@ -1060,18 +1058,14 @@ static void dissect_homeplug_ns(ptvcursor_t * cursor, packet_info * pinfo) ptvcursor_add(cursor, hf_homeplug_ns_netw_da, 6, ENC_NA); ptvcursor_add_no_advance(cursor, hf_homeplug_ns_bytes40, 2, ENC_LITTLE_ENDIAN); - ns_bytes40 = tvb_get_letohs(ptvcursor_tvbuff(cursor), - ptvcursor_current_offset(cursor)); - proto_tree_add_text(ptvcursor_tree(cursor), ptvcursor_tvbuff(cursor), - ptvcursor_current_offset(cursor), 2, "MHz : %.3f", (float)(ns_bytes40)/42); - ptvcursor_advance(cursor, 2); + ptvcursor_add(cursor, hf_homeplug_ns_mhz, 2, ENC_BIG_ENDIAN); ptvcursor_add(cursor, hf_homeplug_ns_fails, 2, ENC_LITTLE_ENDIAN); ptvcursor_add(cursor, hf_homeplug_ns_drops, 2, ENC_LITTLE_ENDIAN); } ptvcursor_pop_subtree(cursor); } else { - proto_tree_add_text(ptvcursor_tree(cursor), ptvcursor_tvbuff(cursor), + proto_tree_add_expert_format(ptvcursor_tree(cursor), pinfo, &ei_homeplug_tone_map_not_exist, ptvcursor_tvbuff(cursor), ptvcursor_current_offset(cursor), 12, "Tone Map #%d does not exist", iTone+1); } @@ -1353,6 +1347,11 @@ dissect_homeplug(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree) ptvcursor_free(cursor); } +static void +homeplug_fmt_mhz( gchar *result, guint32 ns_bytes40 ) +{ + g_snprintf( result, ITEM_LABEL_LENGTH, "%.3f", (float)(ns_bytes40)/42); +} void proto_reg_handoff_homeplug(void) @@ -1915,6 +1914,11 @@ proto_register_homeplug(void) FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } }, + { &hf_homeplug_ns_mhz, + { "Mhz", "homeplug.ns.mhz", + FT_UINT16, BASE_CUSTOM, homeplug_fmt_mhz, 0x0, NULL, HFILL } + }, + { &hf_homeplug_ns_fails_robo, { "Fails Received in ROBO", "homeplug.ns.fails_robo", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } @@ -2174,9 +2178,16 @@ proto_register_homeplug(void) &ett_homeplug_stc }; + static ei_register_info ei[] = { + { &ei_homeplug_tone_map_not_exist, { "homeplug.tone_map_not_exist", PI_PROTOCOL, PI_WARN, "Tone Map does not exist", EXPFILL }}, + }; + + expert_module_t* expert_homeplug; + proto_homeplug = proto_register_protocol("HomePlug protocol", "HomePlug", "homeplug"); proto_register_field_array(proto_homeplug, hf, array_length(hf)); - proto_register_subtree_array(ett, array_length(ett)); + expert_homeplug = expert_register_protocol(proto_homeplug); + expert_register_field_array(expert_homeplug, ei, array_length(ei)); } |