tvb: add tvb_get_bits_array

Change-Id: I2fad824ca417dcd089fabfdf06f28529c7ee9e87
Signed-off-by: Filipe Laíns <lains@archlinux.org>
Reviewed-on: https://code.wireshark.org/review/37949
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Filipe Laíns 2020-07-24 17:12:19 +01:00 committed by Anders Broman
parent bd7d0742db
commit e59b3c2338
3 changed files with 19 additions and 0 deletions

View File

@ -245,6 +245,7 @@ libwireshark.so.0 libwireshark0 #MINVER#
decode_as_default_reset@Base 1.12.0~rc1
decode_as_list@Base 1.12.0~rc1
decode_bits_in_field@Base 1.9.1
decode_bits_in_field_long@Base 3.3.0
decode_build_reset_list@Base 2.3.0
decode_cleanup@Base 3.3.0
decode_clear_all@Base 2.3.0
@ -1732,6 +1733,7 @@ libwireshark.so.0 libwireshark0 #MINVER#
tvb_get_bits64@Base 1.9.1
tvb_get_bits8@Base 1.9.1
tvb_get_bits@Base 1.9.1
tvb_get_bits_array@Base 3.3.0
tvb_get_const_stringz@Base 1.9.1
tvb_get_ds_tvb@Base 1.9.1
tvb_get_ether_name@Base 1.99.3

View File

@ -1955,6 +1955,19 @@ static const guint8 bit_mask8[] = {
0xff
};
/* Get a variable ammount of bits
*
* Return a byte array with bit limited data. The data is aligned to the right.
*/
guint8 *
tvb_get_bits_array(wmem_allocator_t *scope, tvbuff_t *tvb, const gint bit_offset, size_t no_of_bits, size_t *data_length)
{
tvbuff_t *sub_tvb = tvb_new_octet_aligned(tvb, bit_offset, (gint32) no_of_bits);
*data_length = tvb_reported_length(sub_tvb);
return (guint8*)tvb_memdup(scope, sub_tvb, 0, *data_length);
}
/* Get 1 - 8 bits */
guint8
tvb_get_bits8(tvbuff_t *tvb, guint bit_offset, const gint no_of_bits)

View File

@ -408,6 +408,10 @@ WS_DLL_PUBLIC void tvb_get_letohguid(tvbuff_t *tvb, const gint offset,
WS_DLL_PUBLIC void tvb_get_guid(tvbuff_t *tvb, const gint offset,
e_guid_t *guid, const guint encoding);
/* Fetches a byte array given a bit offset in a tvb */
WS_DLL_PUBLIC guint8* tvb_get_bits_array(wmem_allocator_t *scope, tvbuff_t *tvb,
const gint offset, size_t length, size_t *data_length);
/* Fetch a specified number of bits from bit offset in a tvb. All of these
* functions are equivalent, except for the type of the return value. Note
* that the parameter encoding (where supplied) is meaningless and ignored */