summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--epan/dissectors/packet-bfd.c52
-rw-r--r--epan/dissectors/packet-dec-bpdu.c42
-rw-r--r--epan/dissectors/packet-isis-hello.c28
-rw-r--r--epan/dissectors/packet-oampdu.c134
4 files changed, 30 insertions, 226 deletions
diff --git a/epan/dissectors/packet-bfd.c b/epan/dissectors/packet-bfd.c
index e717a3a7cd..5cf7e10943 100644
--- a/epan/dissectors/packet-bfd.c
+++ b/epan/dissectors/packet-bfd.c
@@ -116,15 +116,6 @@ static const value_string bfd_control_auth_type_values[] = {
#define SHA1_AUTH_LEN 28
#define SHA1_CHECKSUM_LEN 20
-#define APPEND_BOOLEAN_FLAG(flag, item, string) \
- if(flag){ \
- if(item) \
- proto_item_append_text(item, string, sep); \
- sep = cont_sep; \
- }
-static const char *const initial_sep = " (";
-static const char *const cont_sep = ", ";
-
static gint proto_bfd = -1;
static gint hf_bfd_version = -1;
@@ -382,16 +373,7 @@ dissect_bfd_control(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* d
guint bfd_diag;
guint bfd_sta = 0;
guint bfd_flags;
- guint bfd_flags_h = 0;
- guint bfd_flags_p = 0;
- guint bfd_flags_f = 0;
- guint bfd_flags_c = 0;
guint bfd_flags_a = 0;
- guint bfd_flags_d = 0;
- guint bfd_flags_m = 0;
- guint bfd_flags_d_v0 = 0;
- guint bfd_flags_p_v0 = 0;
- guint bfd_flags_f_v0 = 0;
guint bfd_detect_time_multiplier;
guint bfd_length;
guint bfd_my_discriminator;
@@ -410,21 +392,12 @@ dissect_bfd_control(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* d
switch (bfd_version) {
case 0:
bfd_flags = flags;
- bfd_flags_h = flags & 0x80;
- bfd_flags_d_v0 = flags & 0x40;
- bfd_flags_p_v0 = flags & 0x20;
- bfd_flags_f_v0 = flags & 0x10;
break;
case 1:
default:
bfd_sta = flags & 0xc0;
bfd_flags = flags & 0x3e;
- bfd_flags_p = flags & 0x20;
- bfd_flags_f = flags & 0x10;
- bfd_flags_c = flags & 0x08;
bfd_flags_a = flags & 0x04;
- bfd_flags_d = flags & 0x02;
- bfd_flags_m = flags & 0x01;
break;
}
@@ -453,7 +426,6 @@ dissect_bfd_control(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* d
if (tree) {
proto_item *ti;
- const char *sep;
ti = proto_tree_add_protocol_format(tree, proto_bfd, tvb, 0, bfd_length,
"BFD Control message");
@@ -486,16 +458,7 @@ dissect_bfd_control(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* d
&hf_bfd_flags_f_v0,
NULL
};
- proto_tree_add_bitmask(bfd_tree, tvb, 1, hf_bfd_flags, ett_bfd_flags, bfd_message_flags, ENC_NA);
-
- sep = initial_sep;
- APPEND_BOOLEAN_FLAG(bfd_flags_h, ti, "%sH");
- APPEND_BOOLEAN_FLAG(bfd_flags_d_v0, ti, "%sD");
- APPEND_BOOLEAN_FLAG(bfd_flags_p_v0, ti, "%sP");
- APPEND_BOOLEAN_FLAG(bfd_flags_f_v0, ti, "%sF");
- if (sep != initial_sep) {
- proto_item_append_text (ti, ")");
- }
+ proto_tree_add_bitmask_with_flags(bfd_tree, tvb, 1, hf_bfd_flags, ett_bfd_flags, bfd_message_flags, ENC_NA, BMT_NO_FALSE);
}
break;
case 1:
@@ -510,18 +473,7 @@ dissect_bfd_control(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* d
&hf_bfd_flags_m,
NULL
};
- ti = proto_tree_add_bitmask(bfd_tree, tvb, 1, hf_bfd_flags, ett_bfd_flags, bfd_message_flags, ENC_NA);
-
- sep = initial_sep;
- APPEND_BOOLEAN_FLAG(bfd_flags_p, ti, "%sP");
- APPEND_BOOLEAN_FLAG(bfd_flags_f, ti, "%sF");
- APPEND_BOOLEAN_FLAG(bfd_flags_c, ti, "%sC");
- APPEND_BOOLEAN_FLAG(bfd_flags_a, ti, "%sA");
- APPEND_BOOLEAN_FLAG(bfd_flags_d, ti, "%sD");
- APPEND_BOOLEAN_FLAG(bfd_flags_m, ti, "%sM");
- if (sep != initial_sep) {
- proto_item_append_text (ti, ")");
- }
+ proto_tree_add_bitmask_with_flags(bfd_tree, tvb, 1, hf_bfd_flags, ett_bfd_flags, bfd_message_flags, ENC_NA, BMT_NO_FALSE);
}
break;
}
diff --git a/epan/dissectors/packet-dec-bpdu.c b/epan/dissectors/packet-dec-bpdu.c
index 4119498563..06772d5d5f 100644
--- a/epan/dissectors/packet-dec-bpdu.c
+++ b/epan/dissectors/packet-dec-bpdu.c
@@ -92,25 +92,18 @@ static const value_string bpdu_type_vals[] = {
{ 0, NULL }
};
-static const char initial_sep[] = " (";
-static const char cont_sep[] = ", ";
-
-#define APPEND_BOOLEAN_FLAG(flag, item, string) \
- if(flag){ \
- if(item) \
- proto_item_append_text(item, string, sep); \
- sep = cont_sep; \
- }
-
static int
dissect_dec_bpdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
guint8 bpdu_type;
- guint8 flags;
proto_tree *bpdu_tree;
- proto_tree *flags_tree;
proto_item *ti;
- const char *sep;
+ static const int * bpdu_flags[] = {
+ &hf_dec_bpdu_flags_short_timers,
+ &hf_dec_bpdu_flags_tcack,
+ &hf_dec_bpdu_flags_tc,
+ NULL
+ };
col_set_str(pinfo->cinfo, COL_PROTOCOL, "DEC_STP");
col_clear(pinfo->cinfo, COL_INFO);
@@ -137,28 +130,7 @@ dissect_dec_bpdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data
proto_tree_add_item(bpdu_tree, hf_dec_bpdu_version_id, tvb,
BPDU_VERSION, 1, ENC_BIG_ENDIAN);
- flags = tvb_get_guint8(tvb, BPDU_FLAGS);
- ti = proto_tree_add_uint(bpdu_tree, hf_dec_bpdu_flags, tvb,
- BPDU_FLAGS, 1, flags);
- flags_tree = proto_item_add_subtree(ti, ett_dec_bpdu_flags);
- sep = initial_sep;
- APPEND_BOOLEAN_FLAG(flags & BPDU_FLAGS_SHORT_TIMERS, ti,
- "%sUse short timers");
- proto_tree_add_boolean(flags_tree, hf_dec_bpdu_flags_short_timers, tvb,
- BPDU_FLAGS, 1, flags);
- APPEND_BOOLEAN_FLAG(flags & BPDU_FLAGS_TCACK, ti,
- "%sTopology Change Acknowledgment");
- proto_tree_add_boolean(flags_tree, hf_dec_bpdu_flags_tcack, tvb,
- BPDU_FLAGS, 1, flags);
- APPEND_BOOLEAN_FLAG(flags & BPDU_FLAGS_TC, ti,
- "%sTopology Change");
- proto_tree_add_boolean(flags_tree, hf_dec_bpdu_flags_tc, tvb,
- BPDU_FLAGS, 1, flags);
- if (sep != initial_sep) {
- /* We put something in; put in the terminating ")" */
- proto_item_append_text(ti, ")");
- }
-
+ proto_tree_add_bitmask_with_flags(bpdu_tree, tvb, BPDU_FLAGS, hf_dec_bpdu_flags, ett_dec_bpdu_flags, bpdu_flags, ENC_NA, BMT_NO_FALSE|BMT_NO_TFS);
proto_tree_add_item(bpdu_tree, hf_dec_bpdu_root_pri, tvb,
BPDU_ROOT_PRI, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(bpdu_tree, hf_dec_bpdu_root_mac, tvb,
diff --git a/epan/dissectors/packet-isis-hello.c b/epan/dissectors/packet-isis-hello.c
index e9bf91030b..1db57c8174 100644
--- a/epan/dissectors/packet-isis-hello.c
+++ b/epan/dissectors/packet-isis-hello.c
@@ -55,17 +55,6 @@
#define ISIS_MASK_RESTART_RA(x) ((x)&ISIS_RESTART_RA)
#define ISIS_MASK_RESTART_SA(x) ((x)&ISIS_RESTART_SA)
-
-#define APPEND_BOOLEAN_FLAG(flag, item, string) \
- if(flag){ \
- if(item) \
- proto_item_append_text(item, string, sep); \
- sep = cont_sep; \
- }
-
-static const char initial_sep[] = " (";
-static const char cont_sep[] = ", ";
-
void proto_register_isis_hello(void);
void proto_reg_handoff_isis_hello(void);
@@ -517,9 +506,7 @@ dissect_hello_restart_clv(tvbuff_t *tvb, packet_info* pinfo _U_,
proto_tree *tree, int offset, int id_length, int length)
{
int restart_options=0;
- proto_item *restart_flags_item;
proto_item *hold_time_item;
- const char *sep;
if (length >= 1) {
static const int * flags[] = {
@@ -530,20 +517,7 @@ dissect_hello_restart_clv(tvbuff_t *tvb, packet_info* pinfo _U_,
};
restart_options = tvb_get_guint8(tvb, offset);
- restart_flags_item = proto_tree_add_bitmask(tree, tvb, offset, hf_isis_hello_clv_restart_flags, ett_isis_hello_clv_restart_flags, flags, ENC_NA);
-
- /* Append an indication of which flags are set in the restart
- * options
- */
- sep = initial_sep;
- APPEND_BOOLEAN_FLAG(ISIS_MASK_RESTART_SA(restart_options), restart_flags_item, "%sSA");
- APPEND_BOOLEAN_FLAG(ISIS_MASK_RESTART_RA(restart_options), restart_flags_item, "%sRA");
- APPEND_BOOLEAN_FLAG(ISIS_MASK_RESTART_RR(restart_options), restart_flags_item, "%sRR");
- if (sep != initial_sep)
- {
- proto_item_append_text (restart_flags_item, ")");
- }
-
+ proto_tree_add_bitmask_with_flags(tree, tvb, offset, hf_isis_hello_clv_restart_flags, ett_isis_hello_clv_restart_flags, flags, ENC_NA, BMT_NO_FALSE|BMT_NO_TFS);
}
/* The Remaining Time field should only be present if the RA flag is
diff --git a/epan/dissectors/packet-oampdu.c b/epan/dissectors/packet-oampdu.c
index 9b1fc12338..71ebf546a7 100644
--- a/epan/dissectors/packet-oampdu.c
+++ b/epan/dissectors/packet-oampdu.c
@@ -954,15 +954,6 @@ static gint ett_oampdu_lpbk_ctrl = -1;
static expert_field ei_oampdu_event_length_bad = EI_INIT;
-static const char initial_sep[] = " (";
-static const char cont_sep[] = ", ";
-
-#define APPEND_BOOLEAN_FLAG(flag, item, string) \
- if(flag){ \
- proto_item_append_text(item, string, sep); \
- sep = cont_sep; \
- }
-
#define APPEND_OUI_NAME(item, string, tvb, offset) \
string = tvb_get_manuf_name(tvb, offset); \
proto_item_append_text(item, " (%s)", string);
@@ -1019,15 +1010,20 @@ dissect_oampdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _
{
int offset = 0;
guint8 oampdu_code;
- guint16 flags,state;
- guint32 i;
proto_tree *oampdu_tree;
proto_item *oampdu_item;
- proto_tree *flags_tree;
- proto_item *flags_item;
- const char *sep = initial_sep;
+ static const int * oampdu_flags[] = {
+ &hf_oampdu_flags_link_fault,
+ &hf_oampdu_flags_dying_gasp,
+ &hf_oampdu_flags_critical_event,
+ &hf_oampdu_flags_local_evaluating,
+ &hf_oampdu_flags_local_stable,
+ &hf_oampdu_flags_remote_evaluating,
+ &hf_oampdu_flags_remote_stable,
+ NULL
+ };
col_set_str(pinfo->cinfo, COL_PROTOCOL, "OAM");
col_clear(pinfo->cinfo, COL_INFO);
@@ -1036,88 +1032,8 @@ dissect_oampdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _
tvb, 0, -1, "OAM Protocol");
oampdu_tree = proto_item_add_subtree(oampdu_item, ett_oampdu);
- if (oampdu_tree)
- {
- /* Flags field */
- flags = tvb_get_ntohs(tvb, offset);
- flags_item = proto_tree_add_uint(oampdu_tree, hf_oampdu_flags, tvb,
- offset, 2, flags);
- flags_tree = proto_item_add_subtree(flags_item, ett_oampdu_flags);
-
- /*
- * In this section we add keywords for the bit set on the Flags's line.
- * We also add all the bit inside the subtree.
- */
- APPEND_BOOLEAN_FLAG(flags & OAMPDU_FLAGS_LINK_FAULT, flags_item,
- "%sLink Fault");
- proto_tree_add_boolean(flags_tree, hf_oampdu_flags_link_fault,
- tvb, offset, 1, flags);
-
- APPEND_BOOLEAN_FLAG(flags & OAMPDU_FLAGS_DYING_GASP, flags_item,
- "%sDying Gasp");
- proto_tree_add_boolean(flags_tree, hf_oampdu_flags_dying_gasp,
- tvb, offset, 1, flags);
-
- APPEND_BOOLEAN_FLAG(flags & OAMPDU_FLAGS_CRITICAL_EVENT, flags_item,
- "%sCriticalEvent");
- proto_tree_add_boolean(flags_tree, hf_oampdu_flags_critical_event,
- tvb, offset, 1, flags);
-
- proto_tree_add_boolean(flags_tree, hf_oampdu_flags_local_evaluating,
- tvb, offset, 1, flags);
-
- proto_tree_add_boolean(flags_tree, hf_oampdu_flags_local_stable,
- tvb, offset, 1, flags);
-
- proto_tree_add_boolean(flags_tree, hf_oampdu_flags_remote_evaluating,
- tvb, offset, 1, flags);
-
- proto_tree_add_boolean(flags_tree, hf_oampdu_flags_remote_stable,
- tvb, offset, 1, flags);
-
- if (sep != cont_sep)
- proto_item_append_text(flags_item, " (");
- else
- proto_item_append_text(flags_item, ", ");
-
- for(i=0;i<2;i++)
- {
- if (i==0)
- {
- proto_item_append_text(flags_item, "local: ");
- state = (flags&(OAMPDU_FLAGS_LOCAL_EVAL|OAMPDU_FLAGS_LOCAL_STABLE));
- state = state>>3;
- }
- else
- {
- proto_item_append_text(flags_item, "remote: ");
- state = (flags&(OAMPDU_FLAGS_REMOTE_EVAL|OAMPDU_FLAGS_REMOTE_STABLE));
- state = state>>5;
- }
-
- switch (state)
- {
- case 0:
- proto_item_append_text(flags_item, "Unsatisfied");
- break;
- case 1:
- proto_item_append_text(flags_item, "Discovery in process");
- break;
- case 2:
- proto_item_append_text(flags_item, "Discovery complete");
- break;
- default:
- proto_item_append_text(flags_item, "Reserved");
- break;
- }
-
- if (i==0)
- proto_item_append_text(flags_item, ", ");
-
- }
-
- proto_item_append_text(flags_item, ")");
- }
+ /* Flags field */
+ proto_tree_add_bitmask_with_flags(oampdu_tree, tvb, offset, hf_oampdu_flags, ett_oampdu_flags, oampdu_flags, ENC_BIG_ENDIAN, BMT_NO_FALSE|BMT_NO_TFS);
offset += 2;
/* OAMPDU code */
@@ -1125,37 +1041,27 @@ dissect_oampdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _
proto_tree_add_uint(oampdu_tree, hf_oampdu_code, tvb,
offset, 1, oampdu_code);
+ col_add_fstr(pinfo->cinfo, COL_INFO, "OAMPDU: %s", val_to_str_const(oampdu_code, code_vals, "Unknown"));
+
switch (oampdu_code)
{
case OAMPDU_INFORMATION:
- col_set_str(pinfo->cinfo, COL_INFO, "OAMPDU: Information");
- if (tree)
- dissect_oampdu_information(tvb, oampdu_tree);
+ dissect_oampdu_information(tvb, oampdu_tree);
break;
case OAMPDU_EVENT_NOTIFICATION:
- col_set_str(pinfo->cinfo, COL_INFO, "OAMPDU: Event Notification");
- if (tree)
- dissect_oampdu_event_notification(tvb, pinfo, oampdu_tree);
+ dissect_oampdu_event_notification(tvb, pinfo, oampdu_tree);
break;
case OAMPDU_VAR_REQUEST:
- col_set_str(pinfo->cinfo, COL_INFO, "OAMPDU: Variable Request");
- if (tree)
- dissect_oampdu_variable_request(tvb, oampdu_tree);
+ dissect_oampdu_variable_request(tvb, oampdu_tree);
break;
case OAMPDU_VAR_RESPONSE:
- col_set_str(pinfo->cinfo, COL_INFO, "OAMPDU: Variable Response");
- if (tree)
- dissect_oampdu_variable_response(tvb, oampdu_tree);
+ dissect_oampdu_variable_response(tvb, oampdu_tree);
break;
case OAMPDU_LOOPBACK_CTRL:
- col_set_str(pinfo->cinfo, COL_INFO, "OAMPDU: Loopback Control");
- if (tree)
- dissect_oampdu_loopback_control(tvb, oampdu_tree);
+ dissect_oampdu_loopback_control(tvb, oampdu_tree);
break;
case OAMPDU_VENDOR_SPECIFIC:
- col_set_str(pinfo->cinfo, COL_INFO, "OAMPDU: Organization Specific");
- if (tree)
- dissect_oampdu_vendor_specific(tvb, oampdu_tree);
+ dissect_oampdu_vendor_specific(tvb, oampdu_tree);
default:
break;
}