aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2016-12-13 21:06:49 -0500
committerMichael Mann <mmann78@netscape.net>2016-12-14 03:53:52 +0000
commitb1ed5284a3166d0dc169c3f9ae5cf9da14b37fea (patch)
tree3384bcc4dd3ad6dbb40385e3136da05e2f497b47
parent8156e138481a16e577399f9950430fb56a1dabdb (diff)
Remove add_item_text
It's a manual attempt at what proto_tree_add_bitmask can do anyway. Change-Id: If551e8afa346a33b8e15dc441aae75ba0752ab46 Reviewed-on: https://code.wireshark.org/review/19257 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
-rw-r--r--epan/dissectors/packet-dnp.c72
-rw-r--r--epan/dissectors/packet-lg8979.c93
2 files changed, 53 insertions, 112 deletions
diff --git a/epan/dissectors/packet-dnp.c b/epan/dissectors/packet-dnp.c
index e29a9bef7e..5b7410a0c6 100644
--- a/epan/dissectors/packet-dnp.c
+++ b/epan/dissectors/packet-dnp.c
@@ -1413,71 +1413,39 @@ calculateCRCtvb(tvbuff_t *tvb, guint offset, guint len) {
}
/*****************************************************************/
-/* Adds text to item, with trailing "," if required */
-/*****************************************************************/
-static gboolean
-add_item_text(proto_item *item, const gchar *text, gboolean comma_needed)
-{
- if (comma_needed) {
- proto_item_append_text(item, ", ");
- }
- proto_item_append_text(item, "%s", text);
- return TRUE;
-}
-
-/*****************************************************************/
/* Application Layer Process Internal Indications (IIN) */
/*****************************************************************/
static void
dnp3_al_process_iin(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *al_tree)
{
-
guint16 al_iin;
proto_item *tiin;
- proto_tree *iin_tree;
- gboolean comma_needed = FALSE;
+ static const int* indications[] = {
+ &hf_dnp3_al_iin_rst,
+ &hf_dnp3_al_iin_dt,
+ &hf_dnp3_al_iin_dol,
+ &hf_dnp3_al_iin_tsr,
+ &hf_dnp3_al_iin_cls3d,
+ &hf_dnp3_al_iin_cls2d,
+ &hf_dnp3_al_iin_cls1d,
+ &hf_dnp3_al_iin_bmsg,
+ &hf_dnp3_al_iin_cc,
+ &hf_dnp3_al_iin_oae,
+ &hf_dnp3_al_iin_ebo,
+ &hf_dnp3_al_iin_pioor,
+ &hf_dnp3_al_iin_obju,
+ &hf_dnp3_al_iin_fcni,
+ NULL
+ };
+ tiin = proto_tree_add_bitmask(al_tree, tvb, offset, hf_dnp3_al_iin, ett_dnp3_al_iin, indications, ENC_BIG_ENDIAN);
al_iin = tvb_get_ntohs(tvb, offset);
- tiin = proto_tree_add_uint_format(al_tree, hf_dnp3_al_iin, tvb, offset, 2, al_iin,
- "Internal Indications: ");
- if (al_iin & AL_IIN_RST) comma_needed = add_item_text(tiin, "Device Restart", comma_needed);
- if (al_iin & AL_IIN_DOL) comma_needed = add_item_text(tiin, "Outputs in Local", comma_needed);
- if (al_iin & AL_IIN_DT) comma_needed = add_item_text(tiin, "Device Trouble", comma_needed);
- if (al_iin & AL_IIN_TSR) comma_needed = add_item_text(tiin, "Time Sync Required", comma_needed);
- if (al_iin & AL_IIN_CLS3D) comma_needed = add_item_text(tiin, "Class 3 Data Available", comma_needed);
- if (al_iin & AL_IIN_CLS2D) comma_needed = add_item_text(tiin, "Class 2 Data Available", comma_needed);
- if (al_iin & AL_IIN_CLS1D) comma_needed = add_item_text(tiin, "Class 1 Data Available", comma_needed);
- if (al_iin & AL_IIN_BMSG) comma_needed = add_item_text(tiin, "Broadcast Message Rx'd", comma_needed);
- if (al_iin & AL_IIN_CC) comma_needed = add_item_text(tiin, "Device Configuration Corrupt", comma_needed);
- if (al_iin & AL_IIN_OAE) comma_needed = add_item_text(tiin, "Operation Already Executing", comma_needed);
- if (al_iin & AL_IIN_EBO) comma_needed = add_item_text(tiin, "Event Buffer Overflow", comma_needed);
- if (al_iin & AL_IIN_PIOOR) comma_needed = add_item_text(tiin, "Parameters Invalid or Out of Range", comma_needed);
- if (al_iin & AL_IIN_OBJU) comma_needed = add_item_text(tiin, "Requested Objects Unknown", comma_needed);
- if (al_iin & AL_IIN_FCNI) /*comma_needed = */add_item_text(tiin, "Function code not implemented", comma_needed);
- proto_item_append_text(tiin, " (0x%04x)", al_iin);
-
/* If IIN indicates an abnormal condition, add expert info */
if ((al_iin & AL_IIN_DT) || (al_iin & AL_IIN_CC) || (al_iin & AL_IIN_OAE) || (al_iin & AL_IIN_EBO) ||
(al_iin & AL_IIN_PIOOR) || (al_iin & AL_IIN_OBJU) || (al_iin & AL_IIN_FCNI)) {
expert_add_info(pinfo, tiin, &ei_dnp_iin_abnormal);
}
-
- iin_tree = proto_item_add_subtree(tiin, ett_dnp3_al_iin);
- proto_tree_add_item(iin_tree, hf_dnp3_al_iin_rst, tvb, offset, 2, ENC_BIG_ENDIAN);
- proto_tree_add_item(iin_tree, hf_dnp3_al_iin_dt, tvb, offset, 2, ENC_BIG_ENDIAN);
- proto_tree_add_item(iin_tree, hf_dnp3_al_iin_dol, tvb, offset, 2, ENC_BIG_ENDIAN);
- proto_tree_add_item(iin_tree, hf_dnp3_al_iin_tsr, tvb, offset, 2, ENC_BIG_ENDIAN);
- proto_tree_add_item(iin_tree, hf_dnp3_al_iin_cls3d, tvb, offset, 2, ENC_BIG_ENDIAN);
- proto_tree_add_item(iin_tree, hf_dnp3_al_iin_cls2d, tvb, offset, 2, ENC_BIG_ENDIAN);
- proto_tree_add_item(iin_tree, hf_dnp3_al_iin_cls1d, tvb, offset, 2, ENC_BIG_ENDIAN);
- proto_tree_add_item(iin_tree, hf_dnp3_al_iin_bmsg, tvb, offset, 2, ENC_BIG_ENDIAN);
- proto_tree_add_item(iin_tree, hf_dnp3_al_iin_cc, tvb, offset, 2, ENC_BIG_ENDIAN);
- proto_tree_add_item(iin_tree, hf_dnp3_al_iin_oae, tvb, offset, 2, ENC_BIG_ENDIAN);
- proto_tree_add_item(iin_tree, hf_dnp3_al_iin_ebo, tvb, offset, 2, ENC_BIG_ENDIAN);
- proto_tree_add_item(iin_tree, hf_dnp3_al_iin_pioor, tvb, offset, 2, ENC_BIG_ENDIAN);
- proto_tree_add_item(iin_tree, hf_dnp3_al_iin_obju, tvb, offset, 2, ENC_BIG_ENDIAN);
- proto_tree_add_item(iin_tree, hf_dnp3_al_iin_fcni, tvb, offset, 2, ENC_BIG_ENDIAN);
}
/**************************************************************/
@@ -3772,8 +3740,8 @@ proto_register_dnp3(void)
},
{ &hf_dnp3_al_iin,
- { "Application Layer IIN bits", "dnp3.al.iin",
- FT_UINT16, BASE_DEC, NULL, 0x0,
+ { "Internal Indications", "dnp3.al.iin",
+ FT_UINT16, BASE_HEX, NULL, 0x0,
"Application Layer IIN", HFILL }
},
diff --git a/epan/dissectors/packet-lg8979.c b/epan/dissectors/packet-lg8979.c
index 0a0d2573ee..30e75f7d76 100644
--- a/epan/dissectors/packet-lg8979.c
+++ b/epan/dissectors/packet-lg8979.c
@@ -34,6 +34,7 @@ void proto_register_lg8979(void);
/* Initialize the protocol and registered fields */
static int proto_lg8979 = -1;
static int hf_lg8979_header = -1;
+static int hf_lg8979_flags = -1;
static int hf_lg8979_shr = -1;
static int hf_lg8979_mfc = -1;
static int hf_lg8979_ack = -1;
@@ -351,20 +352,6 @@ static const value_string lg8979_pul_output_rl_vals[] = {
{ 0, NULL }
};
-
-/*****************************************************************/
-/* Adds text to item, with trailing "," if required */
-/*****************************************************************/
-static gboolean
-add_item_text(proto_item *item, const gchar *text, gboolean comma_needed)
-{
- if (comma_needed) {
- proto_item_append_text(item, ", ");
- }
- proto_item_append_text(item, "%s", text);
- return TRUE;
-}
-
/*************************************************************/
/* Try to determine "direction" of message. */
/* Check the data length within the packet and compare */
@@ -497,9 +484,9 @@ static int
dissect_lg8979(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
/* Set up structures needed to add the protocol subtree and manage it */
- proto_item *lg8979_item, *lg8979_flags_item = NULL, *lg8979_point_item = NULL;
+ proto_item *lg8979_item, *lg8979_point_item = NULL;
proto_item *lg8979_slot_item = NULL, *lg8979_ang_group_pts_item = NULL;
- proto_tree *lg8979_tree, *lg8979_flags_tree = NULL, *lg8979_fc_tree = NULL;
+ proto_tree *lg8979_tree, *lg8979_fc_tree = NULL;
proto_tree *lg8979_point_tree = NULL, *lg8979_ts_tree = NULL;
int offset = 0;
guint8 rtu_addr, func, packet_type, data_len, ptnum8, tripclose, rl, exp_code, num_chassis;
@@ -507,7 +494,7 @@ dissect_lg8979(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _
guint16 ptnum, ptval, ana12_val;
guint16 ts_ms;
gint num_points = 0, cnt = 0, cnt1 = 0;
- gboolean shr, con, frz, ind, sch, slg, ack, comma_needed = FALSE, new_status, change;
+ gboolean shr, new_status, change;
/* Make entries in Protocol column on summary display */
col_set_str(pinfo->cinfo, COL_PROTOCOL, "L&G 8979");
@@ -525,24 +512,19 @@ dissect_lg8979(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _
/* This packet type is classified as a "Request" and is deemed in the direction of "master -> RTU" */
if (packet_type == LG8979_DIR_MASTER_TO_RTU) {
+ static const int * request_flags[] = {
+ &hf_lg8979_shr,
+ &hf_lg8979_mfc,
+ &hf_lg8979_ack,
+ NULL
+ };
col_add_str(pinfo->cinfo, COL_INFO, "Master -> RTU");
/* Add Flags to Protocol Tree */
shr = tvb_get_guint8(tvb, offset) & 0x80;
- ack = tvb_get_guint8(tvb, offset) & 0x04;
- lg8979_flags_tree = proto_tree_add_subtree(lg8979_tree, tvb, offset, 1,
- ett_lg8979_flags, &lg8979_flags_item, "Flags");
-
- proto_item_append_text(lg8979_flags_item, " (");
- if (shr) comma_needed = add_item_text(lg8979_flags_item, "SHR", comma_needed);
- if (ack) add_item_text(lg8979_flags_item, "ACK", comma_needed);
- proto_item_append_text(lg8979_flags_item, ")");
-
- proto_tree_add_item(lg8979_flags_tree, hf_lg8979_shr, tvb, offset, 1, ENC_LITTLE_ENDIAN);
- proto_tree_add_item(lg8979_flags_tree, hf_lg8979_mfc, tvb, offset, 1, ENC_LITTLE_ENDIAN);
- proto_tree_add_item(lg8979_flags_tree, hf_lg8979_ack, tvb, offset, 1, ENC_LITTLE_ENDIAN);
+ proto_tree_add_bitmask(lg8979_tree, tvb, offset, hf_lg8979_flags, ett_lg8979_flags, request_flags, ENC_LITTLE_ENDIAN);
offset += 1;
/* Add RTU Address to Protocol Tree */
@@ -771,33 +753,22 @@ dissect_lg8979(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _
/* This packet type is classified as a "Response" and is deemed in the direction of "RTU -> master" */
else if (packet_type == LG8979_DIR_RTU_TO_MASTER) {
+ static const int * response_flags[] = {
+ &hf_lg8979_shr,
+ &hf_lg8979_con,
+ &hf_lg8979_frz,
+ &hf_lg8979_ind,
+ &hf_lg8979_sch,
+ &hf_lg8979_slg,
+ NULL
+ };
+
col_add_str(pinfo->cinfo, COL_INFO, "RTU -> Master");
/* Retrieve and add Flags to Protocol Tree */
shr = tvb_get_guint8(tvb, offset) & 0x80;
- con = tvb_get_guint8(tvb, offset) & 0x40;
- frz = tvb_get_guint8(tvb, offset) & 0x20;
- ind = tvb_get_guint8(tvb, offset) & 0x10;
- sch = tvb_get_guint8(tvb, offset) & 0x08;
- slg = tvb_get_guint8(tvb, offset) & 0x04;
-
- lg8979_flags_tree = proto_tree_add_subtree(lg8979_tree, tvb, offset, 1, ett_lg8979_flags, &lg8979_flags_item, "Flags");
-
- proto_item_append_text(lg8979_flags_item, " (");
- if (shr) comma_needed = add_item_text(lg8979_flags_item, "SHR", comma_needed);
- if (con) comma_needed = add_item_text(lg8979_flags_item, "CON", comma_needed);
- if (frz) comma_needed = add_item_text(lg8979_flags_item, "FRZ", comma_needed);
- if (ind) comma_needed = add_item_text(lg8979_flags_item, "IND", comma_needed);
- if (sch) comma_needed = add_item_text(lg8979_flags_item, "SCH", comma_needed);
- if (slg) add_item_text(lg8979_flags_item, "SLG", comma_needed);
- proto_item_append_text(lg8979_flags_item, ")");
-
- proto_tree_add_item(lg8979_flags_tree, hf_lg8979_shr, tvb, offset, 1, ENC_BIG_ENDIAN);
- proto_tree_add_item(lg8979_flags_tree, hf_lg8979_con, tvb, offset, 1, ENC_BIG_ENDIAN);
- proto_tree_add_item(lg8979_flags_tree, hf_lg8979_frz, tvb, offset, 1, ENC_BIG_ENDIAN);
- proto_tree_add_item(lg8979_flags_tree, hf_lg8979_ind, tvb, offset, 1, ENC_BIG_ENDIAN);
- proto_tree_add_item(lg8979_flags_tree, hf_lg8979_sch, tvb, offset, 1, ENC_BIG_ENDIAN);
- proto_tree_add_item(lg8979_flags_tree, hf_lg8979_slg, tvb, offset, 1, ENC_BIG_ENDIAN);
+
+ proto_tree_add_bitmask(lg8979_tree, tvb, offset, hf_lg8979_flags, ett_lg8979_flags, response_flags, ENC_LITTLE_ENDIAN);
offset += 1;
/* Add RTU Address to Protocol Tree */
@@ -1294,22 +1265,24 @@ proto_register_lg8979(void)
static hf_register_info lg8979_hf[] = {
{ &hf_lg8979_header,
{ "Header", "lg8979.header", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
+ { &hf_lg8979_flags,
+ { "Flags", "lg8979.flags", FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL }},
{ &hf_lg8979_shr,
- { "SHR: Short Response Flag", "lg8979.shr", FT_UINT8, BASE_DEC, NULL, 0x80, NULL, HFILL }},
+ { "SHR", "lg8979.shr", FT_UINT8, BASE_DEC, NULL, 0x80, "Short Response Flag", HFILL }},
{ &hf_lg8979_mfc,
- { "MFC: Multi Function Code", "lg8979.mfc", FT_UINT8, BASE_DEC, NULL, 0x78, NULL, HFILL }},
+ { "MFC", "lg8979.mfc", FT_UINT8, BASE_DEC, NULL, 0x78, "Multi Function Code", HFILL }},
{ &hf_lg8979_ack,
- { "ACK: Acknowledge Flag", "lg8979.ack", FT_UINT8, BASE_DEC, NULL, 0x04, NULL, HFILL }},
+ { "ACK", "lg8979.ack", FT_UINT8, BASE_DEC, NULL, 0x04, "Acknowledge Flag", HFILL }},
{ &hf_lg8979_con,
- { "CON: Continuation Flag", "lg8979.con", FT_UINT8, BASE_DEC, NULL, 0x40, NULL, HFILL }},
+ { "CON", "lg8979.con", FT_UINT8, BASE_DEC, NULL, 0x40, "Continuation Flag", HFILL }},
{ &hf_lg8979_frz,
- { "FRZ: Accumulator Freeze Flag", "lg8979.frz", FT_UINT8, BASE_DEC, NULL, 0x20, NULL, HFILL }},
+ { "FRZ", "lg8979.frz", FT_UINT8, BASE_DEC, NULL, 0x20, "Accumulator Freeze Flag", HFILL }},
{ &hf_lg8979_ind,
- { "IND: Indication Change Flag", "lg8979.ind", FT_UINT8, BASE_DEC, NULL, 0x10, NULL, HFILL }},
+ { "IND", "lg8979.ind", FT_UINT8, BASE_DEC, NULL, 0x10, "Indication Change Flag", HFILL }},
{ &hf_lg8979_sch,
- { "SCH: SOE Change Flag", "lg8979.sch", FT_UINT8, BASE_DEC, NULL, 0x08, NULL, HFILL }},
+ { "SCH", "lg8979.sch", FT_UINT8, BASE_DEC, NULL, 0x08, "SOE Change Flag", HFILL }},
{ &hf_lg8979_slg,
- { "SLG: SOE Log Flag", "lg8979.slg", FT_UINT8, BASE_DEC, NULL, 0x04, NULL, HFILL }},
+ { "SLG", "lg8979.slg", FT_UINT8, BASE_DEC, NULL, 0x04, "SOE Log Flag", HFILL }},
{ &hf_lg8979_address,
{ "RTU Address", "lg8979.address", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
{ &hf_lg8979_lastblock,