diff options
author | Michael Mann <mmann78@netscape.net> | 2014-07-14 07:04:33 -0400 |
---|---|---|
committer | Evan Huus <eapache@gmail.com> | 2014-07-18 20:13:23 +0000 |
commit | e28a8ff5afc06cbeb746ad4ad23e575d65a43571 (patch) | |
tree | 79d9b663ae7817a3f535b111e19d27b71ea52e34 /epan/dissectors/packet-maccontrol.c | |
parent | deb1d8d07f17911914216c5769cd69b9a29c5999 (diff) |
Add some expert info to the MAC Control dissector
Partial-bug: 6121
Change-Id: If7a367671cf55793799e0d72f8846bd6fe2a2222
Reviewed-on: https://code.wireshark.org/review/3038
Reviewed-by: Evan Huus <eapache@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-maccontrol.c')
-rw-r--r-- | epan/dissectors/packet-maccontrol.c | 40 |
1 files changed, 35 insertions, 5 deletions
diff --git a/epan/dissectors/packet-maccontrol.c b/epan/dissectors/packet-maccontrol.c index d6ccdecd78..f4132e82cc 100644 --- a/epan/dissectors/packet-maccontrol.c +++ b/epan/dissectors/packet-maccontrol.c @@ -32,6 +32,7 @@ #include <glib.h> #include <epan/packet.h> +#include <epan/expert.h> #include "packet-llc.h" #include <epan/etypes.h> @@ -73,6 +74,10 @@ static gint ett_macctrl = -1; static gint ett_macctrl_cbfc_enbv = -1; static gint ett_macctrl_cbfc_pause_times = -1; +static expert_field ei_macctrl_opcode = EI_INIT; +static expert_field ei_macctrl_cbfc_enbv = EI_INIT; +static expert_field ei_macctrl_dst_address = EI_INIT; + static const int *macctrl_cbfc_enbv_list[] = { &hf_macctrl_cbfc_enbv_c0, &hf_macctrl_cbfc_enbv_c1, @@ -123,12 +128,13 @@ static const value_string reg_flags_vals[] = { { 0, NULL } }; - +static const guint8 dst_addr[] = {0x01, 0x80, 0xC2, 0x00, 0x00, 0x01}; +static const address macctrl_dst_address = { AT_ETHER, -1, 6, dst_addr}; static void dissect_macctrl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { - proto_tree *ti; + proto_item *ti, *opcode_item; proto_tree *macctrl_tree = NULL; proto_tree *pause_times_tree = NULL; guint16 opcode; @@ -143,13 +149,17 @@ dissect_macctrl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) ti = proto_tree_add_item(tree, proto_macctrl, tvb, 0, 46, ENC_NA); macctrl_tree = proto_item_add_subtree(ti, ett_macctrl); - proto_tree_add_uint(macctrl_tree, hf_macctrl_opcode, tvb, 0, 2, opcode); + opcode_item = proto_tree_add_uint(macctrl_tree, hf_macctrl_opcode, tvb, 0, 2, opcode); proto_tree_add_item(macctrl_tree, hf_macctrl_timestamp, tvb, 2, 4, ENC_BIG_ENDIAN); col_add_str(pinfo->cinfo, COL_INFO, val_to_str(opcode, opcode_vals, "Unknown")); switch (opcode) { case MACCTRL_PAUSE: + if (!addresses_equal(&pinfo->dst, &macctrl_dst_address)) { + expert_add_info(pinfo, opcode_item, &ei_macctrl_dst_address); + } + pause_time = tvb_get_ntohs(tvb, 6); col_append_fstr(pinfo->cinfo, COL_INFO, ": pause_time: %u quanta", pause_time); @@ -207,8 +217,15 @@ dissect_macctrl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) break; case MACCTRL_CLASS_BASED_FLOW_CNTRL_PAUSE: - proto_tree_add_bitmask(macctrl_tree, tvb, 2, hf_macctrl_cbfc_enbv, + if (!addresses_equal(&pinfo->dst, &macctrl_dst_address)) { + expert_add_info(pinfo, opcode_item, &ei_macctrl_dst_address); + } + + ti = proto_tree_add_bitmask(macctrl_tree, tvb, 2, hf_macctrl_cbfc_enbv, ett_macctrl_cbfc_enbv, macctrl_cbfc_enbv_list, ENC_BIG_ENDIAN); + if (tvb_get_guint8(tvb, 2) != 0) { + expert_add_info(pinfo, ti, &ei_macctrl_cbfc_enbv); + } pause_times_tree = proto_tree_add_subtree(macctrl_tree, tvb, 4, 8*2, ett_macctrl_cbfc_pause_times, NULL, "CBFC Class Pause Times"); @@ -216,7 +233,9 @@ dissect_macctrl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_tree_add_item(pause_times_tree, *macctrl_cbfc_pause_times_list[i], tvb, 4+i*2, 2, ENC_BIG_ENDIAN); } break; - + default: + expert_add_info(pinfo, opcode_item, &ei_macctrl_opcode); + break; } } @@ -338,9 +357,20 @@ proto_register_macctrl(void) &ett_macctrl_cbfc_enbv, &ett_macctrl_cbfc_pause_times }; + + static ei_register_info ei[] = { + { &ei_macctrl_opcode, { "macc.opcode.unknown", PI_PROTOCOL, PI_WARN, "Unknown opcode", EXPFILL }}, + { &ei_macctrl_cbfc_enbv, { "macc.cbfc.enbv.not_zero", PI_PROTOCOL, PI_WARN, "8 MSbs of ENBV must be 0", EXPFILL }}, + { &ei_macctrl_dst_address, { "macc.dst_address_invalid", PI_PROTOCOL, PI_WARN, "Destination address must be 01-80-C2-00-00-01", EXPFILL }}, + }; + + expert_module_t* expert_macctrl; + proto_macctrl = proto_register_protocol("MAC Control", "MACC", "macc"); proto_register_field_array(proto_macctrl, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); + expert_macctrl = expert_register_protocol(proto_macctrl); + expert_register_field_array(expert_macctrl, ei, array_length(ei)); } void |