Make other_decode_bitfield_value private to proto.c.

This is further encouragement to not try to manually create a bitstring while formatting a field.

Change-Id: I4efbeb39a210cf1fd26203cd8560859276b333b0
Reviewed-on: https://code.wireshark.org/review/10494
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
Michael Mann 2015-09-11 19:38:05 -04:00
parent e4c0e510b8
commit 648cf995b1
7 changed files with 45 additions and 72 deletions

View File

@ -386,20 +386,13 @@ dissect_RP_cause_ie(tvbuff_t *tvb, guint32 offset, _U_ guint len,
{
guint8 oct;
guint32 curr_offset;
static char a_bigbuf[1024];
curr_offset = offset;
oct = tvb_get_guint8(tvb, curr_offset);
*cause_value = oct & 0x7f;
other_decode_bitfield_value(a_bigbuf, oct, 0x7f, 8);
proto_tree_add_uint_format(tree, hf_cause_value,
tvb, curr_offset, 1, *cause_value,
"%s : %s",
a_bigbuf,
val_to_str(*cause_value, camel_RP_Cause_values,
"Unknown Cause (%u), treated as (41) \"Temporary failure\" for MO-SMS or (111) \"Protocol error,unspecified\" for MT-SMS"));
proto_tree_add_uint(tree, hf_cause_value, tvb, curr_offset, 1, oct);
curr_offset++;
if ((oct & 0x80)) {
@ -1387,7 +1380,7 @@ void proto_register_camel(void) {
"LocationInformationGPRS/CellGlobalIdOrServiceAreaIdOrLAI", HFILL }},
{ &hf_camel_RP_Cause,
{ "RP Cause", "camel.RP_Cause",
FT_UINT8, BASE_DEC, NULL, 0,
FT_UINT8, BASE_DEC, VALS(camel_RP_Cause_values), 0x7F,
"RP Cause Value", HFILL }},
{ &hf_camel_CAMEL_AChBillingChargingCharacteristics,

View File

@ -844,7 +844,6 @@ libwireshark.so.0 libwireshark0 #MINVER#
oid_subid2string@Base 1.9.1
oids_cleanup@Base 1.9.1
oids_init@Base 1.9.1
other_decode_bitfield_value@Base 1.9.1
output_fields_add@Base 1.12.0~rc1
output_fields_free@Base 1.12.0~rc1
output_fields_has_cols@Base 1.12.0~rc1

View File

@ -1725,22 +1725,13 @@ content_fill_aux(
int hf_content,
int hf_content_fill_bits)
{
static guint8 lo_masks[8] = { 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff };
guint8 oct;
proto_tree_add_item(tree, hf_content, tvb, offset, content_len, ENC_NA);
offset += content_len;
if (fill_bits)
{
oct = tvb_get_guint8(tvb, offset - 1);
other_decode_bitfield_value(a_bigbuf, oct, lo_masks[fill_bits-1], 8);
proto_tree_add_uint_format(tree, hf_content_fill_bits, tvb, offset - 1, 1,
oct & lo_masks[fill_bits-1],
"%s = Fill Bits",
a_bigbuf);
proto_tree_add_bits_item(tree, hf_content_fill_bits, tvb, (offset - 1)*8, fill_bits-1, ENC_NA);
}
}

View File

@ -1359,20 +1359,13 @@ dissect_RP_cause_ie(tvbuff_t *tvb, guint32 offset, _U_ guint len,
{
guint8 oct;
guint32 curr_offset;
static char a_bigbuf[1024];
curr_offset = offset;
oct = tvb_get_guint8(tvb, curr_offset);
*cause_value = oct & 0x7f;
other_decode_bitfield_value(a_bigbuf, oct, 0x7f, 8);
proto_tree_add_uint_format(tree, hf_cause_value,
tvb, curr_offset, 1, *cause_value,
"%s : %s",
a_bigbuf,
val_to_str(*cause_value, camel_RP_Cause_values,
"Unknown Cause (%u), treated as (41) \"Temporary failure\" for MO-SMS or (111) \"Protocol error,unspecified\" for MT-SMS"));
proto_tree_add_uint(tree, hf_cause_value, tvb, curr_offset, 1, oct);
curr_offset++;
if ((oct & 0x80)) {
@ -7170,7 +7163,7 @@ static int dissect_CAP_U_ABORT_REASON_PDU(tvbuff_t *tvb _U_, packet_info *pinfo
/*--- End of included file: packet-camel-fn.c ---*/
#line 418 "../../asn1/camel/packet-camel-template.c"
#line 411 "../../asn1/camel/packet-camel-template.c"
/*--- Included file: packet-camel-table2.c ---*/
@ -7377,7 +7370,7 @@ static int dissect_returnErrorData(proto_tree *tree, tvbuff_t *tvb, int offset,a
/*--- End of included file: packet-camel-table2.c ---*/
#line 420 "../../asn1/camel/packet-camel-template.c"
#line 413 "../../asn1/camel/packet-camel-template.c"
/*
* Functions needed for Hash-Table
@ -8303,7 +8296,7 @@ void proto_reg_handoff_camel(void) {
/*--- End of included file: packet-camel-dis-tab.c ---*/
#line 1338 "../../asn1/camel/packet-camel-template.c"
#line 1331 "../../asn1/camel/packet-camel-template.c"
} else {
range_foreach(ssn_range, range_delete_callback);
g_free(ssn_range);
@ -8356,7 +8349,7 @@ void proto_register_camel(void) {
"LocationInformationGPRS/CellGlobalIdOrServiceAreaIdOrLAI", HFILL }},
{ &hf_camel_RP_Cause,
{ "RP Cause", "camel.RP_Cause",
FT_UINT8, BASE_DEC, NULL, 0,
FT_UINT8, BASE_DEC, VALS(camel_RP_Cause_values), 0x7F,
"RP Cause Value", HFILL }},
{ &hf_camel_CAMEL_AChBillingChargingCharacteristics,
@ -10425,7 +10418,7 @@ void proto_register_camel(void) {
"InvokeId_present", HFILL }},
/*--- End of included file: packet-camel-hfarr.c ---*/
#line 1511 "../../asn1/camel/packet-camel-template.c"
#line 1504 "../../asn1/camel/packet-camel-template.c"
};
/* List of subtrees */
@ -10643,7 +10636,7 @@ void proto_register_camel(void) {
&ett_camel_InvokeId,
/*--- End of included file: packet-camel-ettarr.c ---*/
#line 1528 "../../asn1/camel/packet-camel-template.c"
#line 1521 "../../asn1/camel/packet-camel-template.c"
};
static ei_register_info ei[] = {

View File

@ -3487,6 +3487,41 @@ proto_tree_set_boolean(field_info *fi, guint64 value)
proto_tree_set_uint64(fi, value);
}
/* Generate, into "buf", a string showing the bits of a bitfield.
Return a pointer to the character after that string. */
/*XXX this needs a buf_len check */
static char *
other_decode_bitfield_value(char *buf, const guint64 val, const guint64 mask, const int width)
{
int i;
guint64 bit;
char *p;
i = 0;
p = buf;
bit = G_GUINT64_CONSTANT(1) << (width - 1);
for (;;) {
if (mask & bit) {
/* This bit is part of the field. Show its value. */
if (val & bit)
*p++ = '1';
else
*p++ = '0';
} else {
/* This bit is not part of the field. */
*p++ = '.';
}
bit >>= 1;
i++;
if (i >= width)
break;
if (i % 4 == 0)
*p++ = ' ';
}
*p = '\0';
return p;
}
static char *
decode_bitfield_value(char *buf, const guint64 val, const guint64 mask, const int width)
{

View File

@ -1000,41 +1000,6 @@ decode_bits_in_field(const guint bit_offset, const gint no_of_bits, const guint6
return str;
}
/* Generate, into "buf", a string showing the bits of a bitfield.
Return a pointer to the character after that string. */
/*XXX this needs a buf_len check */
char *
other_decode_bitfield_value(char *buf, const guint64 val, const guint64 mask, const int width)
{
int i;
guint64 bit;
char *p;
i = 0;
p = buf;
bit = G_GUINT64_CONSTANT(1) << (width - 1);
for (;;) {
if (mask & bit) {
/* This bit is part of the field. Show its value. */
if (val & bit)
*p++ = '1';
else
*p++ = '0';
} else {
/* This bit is not part of the field. */
*p++ = '.';
}
bit >>= 1;
i++;
if (i >= width)
break;
if (i % 4 == 0)
*p++ = ' ';
}
*p = '\0';
return p;
}
/*
This function is very fast and this function is called a lot.
XXX update the address_to_str stuff to use this function.

View File

@ -117,9 +117,6 @@ gchar* guid_to_str_buf(const e_guid_t*, gchar*, int);
WS_DLL_PUBLIC char *decode_bits_in_field(const guint bit_offset, const gint no_of_bits, const guint64 value);
WS_DLL_PUBLIC char *other_decode_bitfield_value(char *buf, const guint64 val, const guint64 mask,
const int width);
WS_DLL_PUBLIC const gchar* port_type_to_str (port_type type);
/** Turn an address type retrieved from a tvb into a string.