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>
{
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)) {
"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,
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
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);
}
}
{
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)) {
/*--- 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 ---*/
/*--- 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
/*--- 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);
"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,
"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 */
&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[] = {
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)
{
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.
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.