Make other_decode_bitfield_value private to proto.c.
authorMichael Mann <mmann78@netscape.net>
Fri, 11 Sep 2015 23:38:05 +0000 (19:38 -0400)
committerMichael Mann <mmann78@netscape.net>
Sun, 13 Sep 2015 00:15:35 +0000 (00:15 +0000)
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>
asn1/camel/packet-camel-template.c
debian/libwireshark0.symbols
epan/dissectors/packet-ansi_a.c
epan/dissectors/packet-camel.c
epan/proto.c
epan/to_str.c
epan/to_str.h

index c9c8b79e695013a66254f10924f870710ef2dd5d..9986abbea1b81b9b03d3e6e6e40d1e2014bf47bc 100644 (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,
index 21c9a9f6f224aac50233e1ef2c2469d3e52c2a30..4b3f2a346ae4f56cf67f9dbc88a7b9eddd2bbf11 100644 (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
index 3e7d5555946b1f430bc4be512fc8c138aef5ebc1..d157f90c005184348cdcef7995c6b4f1549007a8 100644 (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);
     }
 }
 
index 838fe080713451d0220462e41b42f4df7b209ec9..7ca875a5fa7ad08d381c40456bb2b262b5f0970c 100644 (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[] = {
index f27bc79b4ebcc0f42d7f82232cc6351babebf10f..363b0d74d9fe1e138350a0f6220837539b869810 100644 (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)
 {
index 3e2aa7d9dd9843675715dac7b4f267ff9d9dde42..b24eeff65a59c0be48a734b7fc73cb987b8dcb09 100644 (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.
index 082aea99c4d8e3f79df69150ff646a432c2f4cbe..5582f16bd77254229a8cdc4265b7868f48b6c420 100644 (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.