Add versions of a function that doesn't need do substitute specifiers.

svn path=/trunk/; revision=46298
This commit is contained in:
Martin Mathieson 2012-11-29 22:25:18 +00:00
parent b39a7b487a
commit 5e90582d54
2 changed files with 49 additions and 14 deletions

View File

@ -1324,6 +1324,28 @@ static void write_pdu_label_and_info(proto_item *ti1, proto_item *ti2,
}
}
/* Version of function above, where no g_vsnprintf() call needed */
static void write_pdu_label_and_info_literal(proto_item *ti1, proto_item *ti2,
packet_info *pinfo, const char *info_buffer)
{
if ((ti1 == NULL) && (ti2 == NULL) && (pinfo == NULL)) {
return;
}
/* Add to indicated places */
if (pinfo != NULL) {
col_append_str(pinfo->cinfo, COL_INFO, info_buffer);
}
if (ti1 != NULL) {
proto_item_append_text(ti1, "%s", info_buffer);
}
if (ti2 != NULL) {
proto_item_append_text(ti2, "%s", info_buffer);
}
}
/* Show extra PHY parameters (if present) */
static void show_extra_phy_parameters(packet_info *pinfo, tvbuff_t *tvb, proto_tree *tree,
struct mac_lte_info *p_mac_lte_info)
@ -1911,7 +1933,7 @@ static void call_rlc_dissector(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tr
}
else {
/* Add a separator and protect column contents here */
write_pdu_label_and_info(pdu_ti, NULL, pinfo, " || ");
write_pdu_label_and_info_literal(pdu_ti, NULL, pinfo, " || ");
col_set_fence(pinfo->cinfo, COL_INFO);
}
}
@ -2858,10 +2880,10 @@ static void dissect_ulsch_or_dlsch(tvbuff_t *tvb, packet_info *pinfo, proto_tree
/* Close off description in info column */
switch (pdu_lengths[number_of_headers]) {
case 0:
write_pdu_label_and_info(pdu_ti, NULL, pinfo, ") ");
write_pdu_label_and_info_literal(pdu_ti, NULL, pinfo, ") ");
break;
case -1:
write_pdu_label_and_info(pdu_ti, NULL, pinfo, ":remainder) ");
write_pdu_label_and_info_literal(pdu_ti, NULL, pinfo, ":remainder) ");
break;
default:
write_pdu_label_and_info(pdu_ti, NULL, pinfo, ":%u bytes) ",
@ -3748,9 +3770,7 @@ static void dissect_mch(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, pro
gboolean expecting_body_data = FALSE;
volatile guint32 is_truncated = FALSE;
write_pdu_label_and_info(pdu_ti, NULL, pinfo,
"MCH: ",
p_mac_lte_info->subframeNumber);
write_pdu_label_and_info_literal(pdu_ti, NULL, pinfo, "MCH: ");
/* Add hidden item to filter on */
hidden_root_ti = proto_tree_add_string_format(tree, hf_mac_lte_mch, tvb,
@ -3897,10 +3917,10 @@ static void dissect_mch(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, pro
/* Close off description in info column */
switch (pdu_lengths[number_of_headers]) {
case 0:
write_pdu_label_and_info(pdu_ti, NULL, pinfo, ") ");
write_pdu_label_and_info_literal(pdu_ti, NULL, pinfo, ") ");
break;
case -1:
write_pdu_label_and_info(pdu_ti, NULL, pinfo, ":remainder) ");
write_pdu_label_and_info_literal(pdu_ti, NULL, pinfo, ":remainder) ");
break;
default:
write_pdu_label_and_info(pdu_ti, NULL, pinfo, ":%u bytes) ",

View File

@ -622,6 +622,21 @@ static void write_pdu_label_and_info(proto_item *pdu_ti, proto_item *sub_ti,
}
}
/* Version of function above, where no g_vsnprintf() call needed
- the info column
- the top-level RLC PDU item
- another subtree item (if supplied) */
static void write_pdu_label_and_info_literal(proto_item *pdu_ti, proto_item *sub_ti,
packet_info *pinfo, const char *info_buffer)
{
/* Add to indicated places */
col_append_str(pinfo->cinfo, COL_INFO, info_buffer);
proto_item_append_text(pdu_ti, "%s", info_buffer);
if (sub_ti != NULL) {
proto_item_append_text(sub_ti, "%s", info_buffer);
}
}
/* Dissect extension headers (common to both UM and AM) */
@ -2350,7 +2365,7 @@ static void dissect_rlc_lte_am(tvbuff_t *tvb, packet_info *pinfo,
if (!is_data) {
/**********************/
/* Status PDU */
write_pdu_label_and_info(top_ti, NULL, pinfo, " [CONTROL]");
write_pdu_label_and_info_literal(top_ti, NULL, pinfo, " [CONTROL]");
/* Control PDUs are a completely separate format */
dissect_rlc_lte_am_status_pdu(tvb, pinfo, am_header_tree, am_header_ti,
@ -2367,14 +2382,14 @@ static void dissect_rlc_lte_am(tvbuff_t *tvb, packet_info *pinfo,
proto_tree_add_item(am_header_tree, hf_rlc_lte_am_rf, tvb, offset, 1, ENC_BIG_ENDIAN);
tap_info->isResegmented = is_resegmented;
write_pdu_label_and_info(top_ti, NULL, pinfo,
(is_resegmented) ? " [DATA-SEGMENT]" : " [DATA]");
write_pdu_label_and_info_literal(top_ti, NULL, pinfo,
(is_resegmented) ? " [DATA-SEGMENT]" : " [DATA]");
/* Polling bit */
polling = (tvb_get_guint8(tvb, offset) & 0x20) >> 5;
proto_tree_add_item(am_header_tree, hf_rlc_lte_am_p, tvb, offset, 1, ENC_BIG_ENDIAN);
write_pdu_label_and_info(top_ti, NULL, pinfo, (polling) ? " (P) " : " ");
write_pdu_label_and_info_literal(top_ti, NULL, pinfo, (polling) ? " (P) " : " ");
if (polling) {
proto_item_append_text(am_header_ti, " (P) ");
}
@ -2764,8 +2779,8 @@ static void dissect_rlc_lte(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
col_append_fstr(pinfo->cinfo, COL_INFO, "UEId=%-4u ", p_rlc_lte_info->ueid);
}
if (p_rlc_lte_info->channelId == 0) {
write_pdu_label_and_info(top_ti, NULL, pinfo, "%s",
val_to_str_const(p_rlc_lte_info->channelType, rlc_channel_type_vals, "Unknown"));
write_pdu_label_and_info_literal(top_ti, NULL, pinfo,
val_to_str_const(p_rlc_lte_info->channelType, rlc_channel_type_vals, "Unknown"));
}
else {
write_pdu_label_and_info(top_ti, NULL, pinfo, "%s:%-2u",