tvb_get_bits{16,32,64} get passed encoding values. Rename the argument
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Mon, 3 Oct 2011 06:12:11 +0000 (06:12 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Mon, 3 Oct 2011 06:12:11 +0000 (06:12 +0000)
appropriately; the only valid encoding is big-endian, so we don't
actually do anything different with the argument, so as not to break
code that passed it a gboolean endian flag.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@39237 f5534014-38df-0310-8fa8-9805f1628bb7

epan/tvbuff.c
epan/tvbuff.h

index 92aecc9495424eb72a67abb8825592e0181cdd0c..654947ba00fedd88ddbfb89ecb6a794469974312 100644 (file)
@@ -1790,7 +1790,7 @@ static const guint32 bit_mask32[] = {
 };
 
 guint16
-tvb_get_bits16(tvbuff_t *tvb, gint bit_offset, const gint no_of_bits,const gboolean little_endian)
+tvb_get_bits16(tvbuff_t *tvb, gint bit_offset, const gint no_of_bits,const guint encoding)
 {
        gint    offset;
        guint16 value = 0;
@@ -1801,7 +1801,11 @@ tvb_get_bits16(tvbuff_t *tvb, gint bit_offset, const gint no_of_bits,const gbool
                /* If bits <= 8 use tvb_get_bits8 */
                DISSECTOR_ASSERT_NOT_REACHED();
        }
-       if(little_endian){
+       /*
+        * For backwards compatibility, treat all non-zero values as
+        * meaning "little-endian".
+        */
+       if(encoding){
                DISSECTOR_ASSERT_NOT_REACHED();
                /* This part is not implemented yet */
        }
@@ -1844,7 +1848,7 @@ static const guint64 bit_mask64[] = {
 };
 
 guint32
-tvb_get_bits32(tvbuff_t *tvb, gint bit_offset, const gint no_of_bits, const gboolean little_endian)
+tvb_get_bits32(tvbuff_t *tvb, gint bit_offset, const gint no_of_bits, const guint encoding)
 {
        gint    offset;
        guint32 value = 0;
@@ -1858,7 +1862,11 @@ tvb_get_bits32(tvbuff_t *tvb, gint bit_offset, const gint no_of_bits, const gboo
                /* If bits <= 16 use tvb_get_bits8 or tvb_get_bits16 */
                DISSECTOR_ASSERT_NOT_REACHED();
        }
-       if(little_endian){
+       /*
+        * For backwards compatibility, treat all non-zero values as
+        * meaning "little-endian".
+        */
+       if(encoding){
                DISSECTOR_ASSERT_NOT_REACHED();
                /* This part is not implemented yet */
        }
@@ -1895,7 +1903,7 @@ tvb_get_bits32(tvbuff_t *tvb, gint bit_offset, const gint no_of_bits, const gboo
 }
 
 guint64
-tvb_get_bits64(tvbuff_t *tvb, gint bit_offset, const gint no_of_bits, const gboolean little_endian)
+tvb_get_bits64(tvbuff_t *tvb, gint bit_offset, const gint no_of_bits, const guint encoding)
 {
        gint    offset;
        guint64 value = 0;
@@ -1906,7 +1914,11 @@ tvb_get_bits64(tvbuff_t *tvb, gint bit_offset, const gint no_of_bits, const gboo
                /* If bits <= 32 use tvb_get_bits8, tvb_get_bits16 or tvb_get_bits32 */
                DISSECTOR_ASSERT_NOT_REACHED();
        }
-       if(little_endian){
+       /*
+        * For backwards compatibility, treat all non-zero values as
+        * meaning "little-endian".
+        */
+       if(encoding){
                DISSECTOR_ASSERT_NOT_REACHED();
                /* This part is not implemented yet */
        }
@@ -1937,7 +1949,7 @@ tvb_get_bits64(tvbuff_t *tvb, gint bit_offset, const gint no_of_bits, const gboo
 }
 
 guint32
-tvb_get_bits(tvbuff_t *tvb, const gint bit_offset, const gint no_of_bits, const gboolean little_endian)
+tvb_get_bits(tvbuff_t *tvb, const gint bit_offset, const gint no_of_bits, const guint encoding)
 {
        /* This function can handle only up to 32 requested bits */
        if (no_of_bits > 32)
@@ -1948,11 +1960,11 @@ tvb_get_bits(tvbuff_t *tvb, const gint bit_offset, const gint no_of_bits, const
 
        /* Number of requested bits is in range [17, 32] */
        if (no_of_bits > 16)
-               return tvb_get_bits32(tvb, bit_offset, no_of_bits, little_endian);
+               return tvb_get_bits32(tvb, bit_offset, no_of_bits, encoding);
 
        /* Number of requested bits is in range [9, 16] */
        if (no_of_bits > 8)
-               return tvb_get_bits16(tvb, bit_offset, no_of_bits, little_endian);
+               return tvb_get_bits16(tvb, bit_offset, no_of_bits, encoding);
 
        /* Number of requested bits is in range [1, 8] */
        return tvb_get_bits8(tvb, bit_offset, no_of_bits);
index 896b2d304299aacda0f4670f4499eeafa944601f..be4bbe4946149ad45c1492016dd0b8adf9fe9969 100644 (file)
@@ -287,16 +287,16 @@ extern void tvb_get_guid(tvbuff_t *tvb, const gint offset, e_guid_t *guid, const
 
 /* Fetch a specified number of bits from bit offset in a tvb */
 extern guint8 tvb_get_bits8(tvbuff_t *tvb, gint bit_offset, const gint no_of_bits);
-extern guint16 tvb_get_bits16(tvbuff_t *tvb, gint bit_offset, const gint no_of_bits, const gboolean little_endian);
-extern guint32 tvb_get_bits32(tvbuff_t *tvb, gint bit_offset, const gint no_of_bits, const gboolean little_endian);
-extern guint64 tvb_get_bits64(tvbuff_t *tvb, gint bit_offset, const gint no_of_bits, const gboolean little_endian);
+extern guint16 tvb_get_bits16(tvbuff_t *tvb, gint bit_offset, const gint no_of_bits, const gint encoding);
+extern guint32 tvb_get_bits32(tvbuff_t *tvb, gint bit_offset, const gint no_of_bits, const guint encoding);
+extern guint64 tvb_get_bits64(tvbuff_t *tvb, gint bit_offset, const gint no_of_bits, const guint encoding);
 
 /* Fetch a specified number of bits from bit offset in a tvb, but allow number
  * of bits to range between 1 and 32. If the requested number of bits is known
  * beforehand, or its range can be handled by a single function of the group
  * above, use one of them instead.
  */
-extern guint32 tvb_get_bits(tvbuff_t *tvb, const gint bit_offset, const gint no_of_bits, const gboolean little_endian);
+extern guint32 tvb_get_bits(tvbuff_t *tvb, const gint bit_offset, const gint no_of_bits, const guint encoding);
 
 void tvb_get_bits_buf(tvbuff_t *tvb, gint bit_offset, gint no_of_bits, guint8 *buf, gboolean lsb0);
 guint8 *ep_tvb_get_bits(tvbuff_t *tvb, gint bit_offset, gint no_of_bits, gboolean lsb0);