Split tvb_get_bits64 into tvb_get_bits8 tvb_get_bits16 tvb_get_bits32 and tvb_get_bits64

and use them in proto_tree_add_bits_ret_val().

svn path=/trunk/; revision=21828
This commit is contained in:
Anders Broman 2007-05-18 16:46:35 +00:00
parent 434334f24d
commit b688f9154a
5 changed files with 218 additions and 138 deletions

View File

@ -583,7 +583,7 @@ make_mask(guint8 num_bits, guint8 shift_value) {
}
static guint8
tvb_get_bits8(tvbuff_t *tvb, guint64 bo, guint8 num_bits) {
bssgp_tvb_get_bits8(tvbuff_t *tvb, guint64 bo, guint8 num_bits) {
/* Returns 0-8 bits from tvb */
guint8 shift_value;
guint16 mask, data;
@ -2024,7 +2024,7 @@ decode_msrac_additional_access_technologies(proto_tree *tree, tvbuff_t *tvb,
guint8 bl; /* Bit length */
bl = 4;
value = tvb_get_bits8(tvb, bo, bl);
value = bssgp_tvb_get_bits8(tvb, bo, bl);
pi = bit_proto_tree_add_bit_field8(tree, tvb, bo, bl);
bo += bl;
proto_item_append_text(pi, "Access Technology Type: %s (%#01x)",
@ -2032,13 +2032,13 @@ decode_msrac_additional_access_technologies(proto_tree *tree, tvbuff_t *tvb,
value);
bl = 3;
value = tvb_get_bits8(tvb, bo, bl);
value = bssgp_tvb_get_bits8(tvb, bo, bl);
pi = bit_proto_tree_add_bit_field8(tree, tvb, bo, bl);
bo += bl;
proto_item_append_text(pi, "GMSK Power Class: Power class %u", value);
bl = 2;
value = tvb_get_bits8(tvb, bo, bl);
value = bssgp_tvb_get_bits8(tvb, bo, bl);
pi = bit_proto_tree_add_bit_field8(tree, tvb, bo, bl);
bo += bl;
proto_item_append_text(pi, "8PSK Power Class");
@ -2073,7 +2073,7 @@ decode_msrac_access_capabilities(proto_tree *tree, tvbuff_t *tvb,
/* RF Power Capability */
bl = 3;
if (!struct_bits_exist(start_bo, struct_length, bo, bl)) return;
value = tvb_get_bits8(tvb, bo, bl);
value = bssgp_tvb_get_bits8(tvb, bo, bl);
pi = bit_proto_tree_add_bit_field8(tree, tvb, bo, bl);
bo += bl;
proto_item_append_text(pi, "RF Power Capability");
@ -2087,12 +2087,12 @@ decode_msrac_access_capabilities(proto_tree *tree, tvbuff_t *tvb,
/* A5 bits */
bl = 1;
if (!struct_bits_exist(start_bo, struct_length, bo, bl)) return;
value = tvb_get_bits8(tvb, bo, bl);
value = bssgp_tvb_get_bits8(tvb, bo, bl);
if (value == 1) {
bo += bl;
bl = 7;
if (!struct_bits_exist(start_bo, struct_length, bo, bl)) return;
value = tvb_get_bits8(tvb, bo, bl);
value = bssgp_tvb_get_bits8(tvb, bo, bl);
ti = bit_proto_tree_add_bit_field8(tree, tvb, bo, bl);
proto_item_append_text(ti, "A5 Bits: %#02x", value);
tf = proto_item_add_subtree(ti, ett_bssgp_msrac_a5_bits);
@ -2113,7 +2113,7 @@ decode_msrac_access_capabilities(proto_tree *tree, tvbuff_t *tvb,
/* ES IND */
bl = 1;
if (!struct_bits_exist(start_bo, struct_length, bo, bl)) return;
value = tvb_get_bits8(tvb, bo, bl);
value = bssgp_tvb_get_bits8(tvb, bo, bl);
pi = bit_proto_tree_add_bit_field8(tree, tvb, bo, bl);
bo += bl;
proto_item_append_text(pi, "ESD IND: Controlled Early Classmark Sending"" option is%s implemented",
@ -2122,7 +2122,7 @@ decode_msrac_access_capabilities(proto_tree *tree, tvbuff_t *tvb,
/* PS */
bl = 1;
if (!struct_bits_exist(start_bo, struct_length, bo, bl)) return;
value = tvb_get_bits8(tvb, bo, bl);
value = bssgp_tvb_get_bits8(tvb, bo, bl);
pi = bit_proto_tree_add_bit_field8(tree, tvb, bo, bl);
bo += bl;
proto_item_append_text(pi, "PS: PS capability%s present",
@ -2131,7 +2131,7 @@ decode_msrac_access_capabilities(proto_tree *tree, tvbuff_t *tvb,
/* VGCS */
bl = 1;
if (!struct_bits_exist(start_bo, struct_length, bo, bl)) return;
value = tvb_get_bits8(tvb, bo, bl);
value = bssgp_tvb_get_bits8(tvb, bo, bl);
pi = bit_proto_tree_add_bit_field8(tree, tvb, bo, bl);
bo += bl;
proto_item_append_text(pi, "VBCS:%s VGCS capability %s notifications wanted",
@ -2141,7 +2141,7 @@ decode_msrac_access_capabilities(proto_tree *tree, tvbuff_t *tvb,
/* VBS */
bl = 1;
if (!struct_bits_exist(start_bo, struct_length, bo, bl)) return;
value = tvb_get_bits8(tvb, bo, bl);
value = bssgp_tvb_get_bits8(tvb, bo, bl);
pi = bit_proto_tree_add_bit_field8(tree, tvb, bo, bl);
bo += bl;
proto_item_append_text(pi, "VBS:%s VBS capability %s notifications wanted",
@ -2153,7 +2153,7 @@ decode_msrac_access_capabilities(proto_tree *tree, tvbuff_t *tvb,
No length is given! */
bl = 1;
if (!struct_bits_exist(start_bo, struct_length, bo, bl)) return;
value = tvb_get_bits8(tvb, bo, bl);
value = bssgp_tvb_get_bits8(tvb, bo, bl);
if (value == 1) {
bo += bl;
ti = bit_proto_tree_add_text(tree, tvb, bo, bl, "Multislot capability");
@ -2162,12 +2162,12 @@ decode_msrac_access_capabilities(proto_tree *tree, tvbuff_t *tvb,
/* HSCSD Multislot Class */
bl = 1;
if (!struct_bits_exist(start_bo, struct_length, bo, bl)) return;
value = tvb_get_bits8(tvb, bo, bl);
value = bssgp_tvb_get_bits8(tvb, bo, bl);
bo += bl;
if (value == 1) {
bl = 5;
if (!struct_bits_exist(start_bo, struct_length, bo, bl)) return;
value = tvb_get_bits8(tvb, bo, bl);
value = bssgp_tvb_get_bits8(tvb, bo, bl);
pi = bit_proto_tree_add_bit_field8(tf, tvb, bo, bl);
bo += bl;
proto_item_append_text(pi, "HSCSD Multislot Class");
@ -2187,12 +2187,12 @@ decode_msrac_access_capabilities(proto_tree *tree, tvbuff_t *tvb,
/* GPRS Multislot Class, GPRS Extended Dynamic Allocation Capability */
bl = 1;
if (!struct_bits_exist(start_bo, struct_length, bo, bl)) return;
value = tvb_get_bits8(tvb, bo, bl);
value = bssgp_tvb_get_bits8(tvb, bo, bl);
bo += bl;
if (value == 1) {
bl = 5;
if (!struct_bits_exist(start_bo, struct_length, bo, bl)) return;
value = tvb_get_bits8(tvb, bo, bl);
value = bssgp_tvb_get_bits8(tvb, bo, bl);
pi = bit_proto_tree_add_bit_field8(tf, tvb, bo, bl);
bo += bl;
proto_item_append_text(pi, "GPRS Multislot Class: Multislot Class %u",
@ -2200,7 +2200,7 @@ decode_msrac_access_capabilities(proto_tree *tree, tvbuff_t *tvb,
bl = 1;
if (!struct_bits_exist(start_bo, struct_length, bo, bl)) return;
value = tvb_get_bits8(tvb, bo, bl);
value = bssgp_tvb_get_bits8(tvb, bo, bl);
pi = bit_proto_tree_add_bit_field8(tf, tvb, bo, bl);
bo += bl;
proto_item_append_text(pi, "GPRS Extended Dynamic Allocation Capability: Extended Dynamic Allocation for GPRS is%s implemented",
@ -2215,12 +2215,12 @@ decode_msrac_access_capabilities(proto_tree *tree, tvbuff_t *tvb,
/* SMS Value, SM Value */
bl = 1;
if (!struct_bits_exist(start_bo, struct_length, bo, bl)) return;
value = tvb_get_bits8(tvb, bo, bl);
value = bssgp_tvb_get_bits8(tvb, bo, bl);
bo += bl;
if (value == 1) {
bl = 4;
if (!struct_bits_exist(start_bo, struct_length, bo, bl)) return;
value = tvb_get_bits8(tvb, bo, bl);
value = bssgp_tvb_get_bits8(tvb, bo, bl);
pi = bit_proto_tree_add_bit_field8(tf, tvb, bo, bl);
bo += bl;
proto_item_append_text(pi,
@ -2229,7 +2229,7 @@ decode_msrac_access_capabilities(proto_tree *tree, tvbuff_t *tvb,
bl = 4;
if (!struct_bits_exist(start_bo, struct_length, bo, bl)) return;
value = tvb_get_bits8(tvb, bo, bl);
value = bssgp_tvb_get_bits8(tvb, bo, bl);
pi = bit_proto_tree_add_bit_field8(tf, tvb, bo, bl);
bo += bl;
proto_item_append_text(pi,
@ -2247,12 +2247,12 @@ decode_msrac_access_capabilities(proto_tree *tree, tvbuff_t *tvb,
/* ECSD Multislot Class */
bl = 1;
if (!struct_bits_exist(start_bo, struct_length, bo, bl)) return;
value = tvb_get_bits8(tvb, bo, bl);
value = bssgp_tvb_get_bits8(tvb, bo, bl);
bo += bl;
if (value == 1) {
bl = 5;
if (!struct_bits_exist(start_bo, struct_length, bo, bl)) return;
value = tvb_get_bits8(tvb, bo, bl);
value = bssgp_tvb_get_bits8(tvb, bo, bl);
pi = bit_proto_tree_add_bit_field8(tf, tvb, bo, bl);
bo += bl;
proto_item_append_text(pi, "ECSD Multislot Class");
@ -2272,12 +2272,12 @@ decode_msrac_access_capabilities(proto_tree *tree, tvbuff_t *tvb,
/* EGPRS Multislot Class, EGPRS Extended Dynamic Allocation Capability */
bl = 1;
if (!struct_bits_exist(start_bo, struct_length, bo, bl)) return;
value = tvb_get_bits8(tvb, bo, bl);
value = bssgp_tvb_get_bits8(tvb, bo, bl);
bo += bl;
if (value == 1) {
bl = 5;
if (!struct_bits_exist(start_bo, struct_length, bo, bl)) return;
value = tvb_get_bits8(tvb, bo, bl);
value = bssgp_tvb_get_bits8(tvb, bo, bl);
pi = bit_proto_tree_add_bit_field8(tf, tvb, bo, bl);
bo += bl;
proto_item_append_text(pi, "EGPRS Multislot Class: Multislot Class %u",
@ -2285,7 +2285,7 @@ decode_msrac_access_capabilities(proto_tree *tree, tvbuff_t *tvb,
bl = 1;
if (!struct_bits_exist(start_bo, struct_length, bo, bl)) return;
value = tvb_get_bits8(tvb, bo, bl);
value = bssgp_tvb_get_bits8(tvb, bo, bl);
pi = bit_proto_tree_add_bit_field8(tf, tvb, bo, bl);
bo += bl;
proto_item_append_text(pi, "EGPRS Extended Dynamic Allocation Capability: Extended Dynamic Allocation for EGPRS is%s implemented",
@ -2300,12 +2300,12 @@ decode_msrac_access_capabilities(proto_tree *tree, tvbuff_t *tvb,
/* DTM GPRS Multislot Class */
bl = 1;
if (!struct_bits_exist(start_bo, struct_length, bo, bl)) return;
value = tvb_get_bits8(tvb, bo, bl);
value = bssgp_tvb_get_bits8(tvb, bo, bl);
bo += bl;
if (value == 1) {
bl = 2;
if (!struct_bits_exist(start_bo, struct_length, bo, bl)) return;
dgmsc = tvb_get_bits8(tvb, bo, bl);
dgmsc = bssgp_tvb_get_bits8(tvb, bo, bl);
pi = bit_proto_tree_add_bit_field8(tf, tvb, bo, bl);
bo += bl;
proto_item_append_text(pi, "DTM GPRS Multislot Class: %s",
@ -2314,7 +2314,7 @@ decode_msrac_access_capabilities(proto_tree *tree, tvbuff_t *tvb,
/* Single slot DTM */
bl = 1;
if (!struct_bits_exist(start_bo, struct_length, bo, bl)) return;
value = tvb_get_bits8(tvb, bo, bl);
value = bssgp_tvb_get_bits8(tvb, bo, bl);
pi = bit_proto_tree_add_bit_field8(tf, tvb, bo, bl);
bo += bl;
proto_item_append_text(pi,
@ -2324,12 +2324,12 @@ decode_msrac_access_capabilities(proto_tree *tree, tvbuff_t *tvb,
/* DTM EGPRS Multislot Class */
bl = 1;
if (!struct_bits_exist(start_bo, struct_length, bo, bl)) return;
value = tvb_get_bits8(tvb, bo, bl);
value = bssgp_tvb_get_bits8(tvb, bo, bl);
bo += bl;
if (value == 1) {
bl = 2;
if (!struct_bits_exist(start_bo, struct_length, bo, bl)) return;
demsc = tvb_get_bits8(tvb, bo, bl);
demsc = bssgp_tvb_get_bits8(tvb, bo, bl);
pi = bit_proto_tree_add_bit_field8(tf, tvb, bo, bl);
bo += bl;
proto_item_append_text(pi, "DTM EGPRS Multislot Class: %s",
@ -2350,12 +2350,12 @@ decode_msrac_access_capabilities(proto_tree *tree, tvbuff_t *tvb,
/* 8PSK Power Capability */
bl = 1;
if (!struct_bits_exist(start_bo, struct_length, bo, bl)) return;
value = tvb_get_bits8(tvb, bo, bl);
value = bssgp_tvb_get_bits8(tvb, bo, bl);
bo += bl;
if (value == 1) {
bl = 2;
if (!struct_bits_exist(start_bo, struct_length, bo, bl)) return;
value = tvb_get_bits8(tvb, bo, bl);
value = bssgp_tvb_get_bits8(tvb, bo, bl);
pi = bit_proto_tree_add_bit_field8(tree, tvb, bo, bl);
bo += bl;
proto_item_append_text(pi, "8PSK Power Capability");
@ -2372,7 +2372,7 @@ decode_msrac_access_capabilities(proto_tree *tree, tvbuff_t *tvb,
/* COMPACT Interference Measurement Capability */
bl = 1;
if (!struct_bits_exist(start_bo, struct_length, bo, bl)) return;
value = tvb_get_bits8(tvb, bo, bl);
value = bssgp_tvb_get_bits8(tvb, bo, bl);
pi = bit_proto_tree_add_bit_field8(tree, tvb, bo, bl);
bo += bl;
proto_item_append_text(pi,
@ -2382,7 +2382,7 @@ decode_msrac_access_capabilities(proto_tree *tree, tvbuff_t *tvb,
/* Revision level indicator */
bl = 1;
if (!struct_bits_exist(start_bo, struct_length, bo, bl)) return;
value = tvb_get_bits8(tvb, bo, bl);
value = bssgp_tvb_get_bits8(tvb, bo, bl);
pi = bit_proto_tree_add_bit_field8(tree, tvb, bo, bl);
bo += bl;
proto_item_append_text(pi, "Revision Level Indicator: The ME is Release '%u %s",
@ -2393,7 +2393,7 @@ decode_msrac_access_capabilities(proto_tree *tree, tvbuff_t *tvb,
/* 3G RAT */
bl = 1;
if (!struct_bits_exist(start_bo, struct_length, bo, bl)) return;
value = tvb_get_bits8(tvb, bo, bl);
value = bssgp_tvb_get_bits8(tvb, bo, bl);
pi = bit_proto_tree_add_bit_field8(tree, tvb, bo, bl);
bo += bl;
proto_item_append_text(pi, "UMTS FDD Radio Access Technology Capability: UMTS FDD%s supported",
@ -2401,7 +2401,7 @@ decode_msrac_access_capabilities(proto_tree *tree, tvbuff_t *tvb,
bl = 1;
if (!struct_bits_exist(start_bo, struct_length, bo, bl)) return;
value = tvb_get_bits8(tvb, bo, bl);
value = bssgp_tvb_get_bits8(tvb, bo, bl);
pi = bit_proto_tree_add_bit_field8(tree, tvb, bo, bl);
bo += bl;
proto_item_append_text(pi, "UMTS 3.84 Mcps TDD Radio Access Technology Capability: UMTS 3.84 Mcps TDD%s supported",
@ -2409,7 +2409,7 @@ decode_msrac_access_capabilities(proto_tree *tree, tvbuff_t *tvb,
bl = 1;
if (!struct_bits_exist(start_bo, struct_length, bo, bl)) return;
value = tvb_get_bits8(tvb, bo, bl);
value = bssgp_tvb_get_bits8(tvb, bo, bl);
pi = bit_proto_tree_add_bit_field8(tree, tvb, bo, bl);
bo += bl;
proto_item_append_text(pi, "CDMA 2000 Radio Access Technology Capability: CDMA 2000%s supported",
@ -2419,7 +2419,7 @@ decode_msrac_access_capabilities(proto_tree *tree, tvbuff_t *tvb,
/* Additions in release 4*/
bl = 1;
if (!struct_bits_exist(start_bo, struct_length, bo, bl)) return;
value = tvb_get_bits8(tvb, bo, bl);
value = bssgp_tvb_get_bits8(tvb, bo, bl);
pi = bit_proto_tree_add_bit_field8(tree, tvb, bo, bl);
bo += bl;
proto_item_append_text(pi, "UMTS 1.28 Mcps TDD Radio Access Technology Capability: UMTS 1.28 Mcps TDD%s supported",
@ -2429,7 +2429,7 @@ decode_msrac_access_capabilities(proto_tree *tree, tvbuff_t *tvb,
/* GERAN Feature Package 1 */
bl = 1;
if (!struct_bits_exist(start_bo, struct_length, bo, bl)) return;
value = tvb_get_bits8(tvb, bo, bl);
value = bssgp_tvb_get_bits8(tvb, bo, bl);
pi = bit_proto_tree_add_bit_field8(tree, tvb, bo, bl);
bo += bl;
proto_item_append_text(pi, "GERAN Feature Package 1: GERAN Feature Package 1%s supported",
@ -2439,12 +2439,12 @@ decode_msrac_access_capabilities(proto_tree *tree, tvbuff_t *tvb,
/* Extended DTM xGPRS Multislot Class */
bl = 1;
if (!struct_bits_exist(start_bo, struct_length, bo, bl)) return;
value = tvb_get_bits8(tvb, bo, bl);
value = bssgp_tvb_get_bits8(tvb, bo, bl);
bo += bl;
if (value == 1) {
bl = 2;
if (!struct_bits_exist(start_bo, struct_length, bo, bl)) return;
value = tvb_get_bits8(tvb, bo, bl);
value = bssgp_tvb_get_bits8(tvb, bo, bl);
pi = bit_proto_tree_add_bit_field8(tree, tvb, bo, bl);
bo += bl;
proto_item_append_text(pi, "Extended DTM GPRS Multi Slot Class: %s",
@ -2454,7 +2454,7 @@ decode_msrac_access_capabilities(proto_tree *tree, tvbuff_t *tvb,
How know? */
bl = 2;
if (!struct_bits_exist(start_bo, struct_length, bo, bl)) return;
value = tvb_get_bits8(tvb, bo, bl);
value = bssgp_tvb_get_bits8(tvb, bo, bl);
pi = bit_proto_tree_add_bit_field8(tree, tvb, bo, bl);
bo += bl;
proto_item_append_text(pi, "Extended DTM EGPRS Multi Slot Class: %s",
@ -2464,7 +2464,7 @@ decode_msrac_access_capabilities(proto_tree *tree, tvbuff_t *tvb,
/* Modulation based multislot class support */
bl = 1;
if (!struct_bits_exist(start_bo, struct_length, bo, bl)) return;
value = tvb_get_bits8(tvb, bo, bl);
value = bssgp_tvb_get_bits8(tvb, bo, bl);
pi = bit_proto_tree_add_bit_field8(tree, tvb, bo, bl);
bo += bl;
proto_item_append_text(pi, "Modulation based multislot class support: %s supported",
@ -2475,12 +2475,12 @@ decode_msrac_access_capabilities(proto_tree *tree, tvbuff_t *tvb,
/* High multislot capability */
bl = 1;
if (!struct_bits_exist(start_bo, struct_length, bo, bl)) return;
value = tvb_get_bits8(tvb, bo, bl);
value = bssgp_tvb_get_bits8(tvb, bo, bl);
bo += bl;
if (value == 1) {
bl = 2;
if (!struct_bits_exist(start_bo, struct_length, bo, bl)) return;
value = tvb_get_bits8(tvb, bo, bl);
value = bssgp_tvb_get_bits8(tvb, bo, bl);
pi = bit_proto_tree_add_bit_field8(tree, tvb, bo, bl);
bo += bl;
proto_item_append_text(pi, "High Multislot Capability: %u", value);
@ -2492,7 +2492,7 @@ decode_msrac_access_capabilities(proto_tree *tree, tvbuff_t *tvb,
/* XXX: Interpretation? Length? */
bl = 1;
if (!struct_bits_exist(start_bo, struct_length, bo, bl)) return;
value = tvb_get_bits8(tvb, bo, bl);
value = bssgp_tvb_get_bits8(tvb, bo, bl);
pi = bit_proto_tree_add_bit_field8(tree, tvb, bo, bl);
bo += bl;
proto_item_append_text(pi, "GERAN Iu Mode Capabilities: %s",
@ -2501,7 +2501,7 @@ decode_msrac_access_capabilities(proto_tree *tree, tvbuff_t *tvb,
/* GMSK Multislot Power Profile */
bl = 2;
if (!struct_bits_exist(start_bo, struct_length, bo, bl)) return;
value = tvb_get_bits8(tvb, bo, bl);
value = bssgp_tvb_get_bits8(tvb, bo, bl);
pi = bit_proto_tree_add_bit_field8(tree, tvb, bo, bl);
bo += bl;
proto_item_append_text(pi, "GMSK Multislot Power Profile: GMSK_MULTI_SLOT_POWER_PROFILE %u",
@ -2512,7 +2512,7 @@ decode_msrac_access_capabilities(proto_tree *tree, tvbuff_t *tvb,
set this field to 00' */
bl = 2;
if (!struct_bits_exist(start_bo, struct_length, bo, bl)) return;
value = tvb_get_bits8(tvb, bo, bl);
value = bssgp_tvb_get_bits8(tvb, bo, bl);
pi = bit_proto_tree_add_bit_field8(tree, tvb, bo, bl);
bo += bl;
proto_item_append_text(pi, "8PSK Multislot Power Profile: 8PSK_MULTI_SLOT_POWER_PROFILE %u",
@ -2523,7 +2523,7 @@ decode_msrac_access_capabilities(proto_tree *tree, tvbuff_t *tvb,
/* Multiple TBF Capability */
bl = 1;
if (!struct_bits_exist(start_bo, struct_length, bo, bl)) return;
value = tvb_get_bits8(tvb, bo, bl);
value = bssgp_tvb_get_bits8(tvb, bo, bl);
pi = bit_proto_tree_add_bit_field8(tree, tvb, bo, bl);
bo += bl;
proto_item_append_text(pi, "Multiple TBF Capability: Multiple TBF procedures in A/Gb mode%s supported",
@ -2532,7 +2532,7 @@ decode_msrac_access_capabilities(proto_tree *tree, tvbuff_t *tvb,
/* Downlink Advanced Receiver Performance */
bl = 2;
if (!struct_bits_exist(start_bo, struct_length, bo, bl)) return;
value = tvb_get_bits8(tvb, bo, bl);
value = bssgp_tvb_get_bits8(tvb, bo, bl);
pi = bit_proto_tree_add_bit_field8(tree, tvb, bo, bl);
bo += bl;
proto_item_append_text(pi, "Donwlink Advanced Receiver Performance: Downlink Advanced Receiver Performance %s supported",
@ -2542,7 +2542,7 @@ decode_msrac_access_capabilities(proto_tree *tree, tvbuff_t *tvb,
/* Extended RLC_MAC Control Message Segmentation Capability */
bl = 1;
if (!struct_bits_exist(start_bo, struct_length, bo, bl)) return;
value = tvb_get_bits8(tvb, bo, bl);
value = bssgp_tvb_get_bits8(tvb, bo, bl);
pi = bit_proto_tree_add_bit_field8(tree, tvb, bo, bl);
bo += bl;
proto_item_append_text(pi, "Extended RLC/MAC Control Message Segmentation Capability: Extended RLC/MAC Control Message Segmentation%s supported",
@ -2566,7 +2566,7 @@ decode_msrac_value_part(proto_tree *tree, tvbuff_t *tvb, guint64 bo) {
tf = proto_item_add_subtree(ti, ett_bssgp_msrac_value_part);
bl = 4;
att = tvb_get_bits8(tvb, bo, bl);
att = bssgp_tvb_get_bits8(tvb, bo, bl);
att_name = translate_msrac_access_technology_type(att);
pi = bit_proto_tree_add_bit_field8(tf, tvb, bo, bl);
proto_item_append_text(pi, "Access Technology Type: %s (%#01x)", att_name, att);
@ -2574,7 +2574,7 @@ decode_msrac_value_part(proto_tree *tree, tvbuff_t *tvb, guint64 bo) {
bo += bl;
bl = 7;
length = tvb_get_bits8(tvb, bo, bl);
length = bssgp_tvb_get_bits8(tvb, bo, bl);
pi = bit_proto_tree_add_bit_field8(tf, tvb, bo, bl);
proto_item_append_text(pi, "Length: %u bits", length);
bo += bl;
@ -2596,7 +2596,7 @@ decode_msrac_value_part(proto_tree *tree, tvbuff_t *tvb, guint64 bo) {
/* else unknown Access Technology Type */
bo += length;
bit = tvb_get_bits8(tvb, bo, 1);
bit = bssgp_tvb_get_bits8(tvb, bo, 1);
bo++;
if (bit == 1) {
decode_msrac_value_part(tree, tvb, bo);

View File

@ -5587,7 +5587,7 @@ proto_tree_add_bitmask(proto_tree *parent_tree, tvbuff_t *tvb, int offset, int h
}
proto_item *
proto_tree_add_bits(proto_tree *tree, int hf_index, tvbuff_t *tvb, gint bit_offset, gint no_of_bits, gboolean little_endian)
proto_tree_add_bits_item(proto_tree *tree, int hf_index, tvbuff_t *tvb, gint bit_offset, gint no_of_bits, gboolean little_endian)
{
return proto_tree_add_bits_ret_val(tree, hf_index, tvb, bit_offset, no_of_bits, NULL, little_endian);
@ -5627,8 +5627,19 @@ proto_tree_add_bits_ret_val(proto_tree *tree, int hf_index, tvbuff_t *tvb, gint
if ((remaining_bits)!=0)
length++;
if (no_of_bits < 9){
value = tvb_get_bits8(tvb, bit_offset, no_of_bits);
}else if(no_of_bits < 17){
value = tvb_get_bits16(tvb, bit_offset, no_of_bits, little_endian);
}else if(no_of_bits < 33){
value = tvb_get_bits32(tvb, bit_offset, no_of_bits, little_endian);
}else if(no_of_bits < 65){
value = tvb_get_bits64(tvb, bit_offset, no_of_bits, little_endian);
}else if(no_of_bits>64){
DISSECTOR_ASSERT_NOT_REACHED();
return NULL;
}
value = tvb_get_bits(tvb, bit_offset, no_of_bits, little_endian);
mask = 1;
mask = mask << (no_of_bits-1);

View File

@ -1586,7 +1586,7 @@ proto_tree_add_bitmask(proto_tree *tree, tvbuff_t *tvb, int offset, int hf_hdr,
@return the newly created item */
extern proto_item *
proto_tree_add_bits(proto_tree *tree, int hf_index, tvbuff_t *tvb, gint bit_offset, gint no_of_bits, gboolean little_endian);
proto_tree_add_bits_item(proto_tree *tree, int hf_index, tvbuff_t *tvb, gint bit_offset, gint no_of_bits, gboolean little_endian);
/** Add bitts to a proto_tree, using the text label registered to that item.
The item is extracted from the tvbuff handed to it.

View File

@ -1446,7 +1446,7 @@ tvb_get_guid(tvbuff_t *tvb, gint offset, e_guid_t *guid, gboolean little_endian)
}
}
static const guint8 bit_mask[] = {
static const guint8 bit_mask8[] = {
0xff,
0x7f,
0x3f,
@ -1457,18 +1457,69 @@ static const guint8 bit_mask[] = {
0x01
};
guint64
tvb_get_bits(tvbuff_t *tvb, gint bit_offset, gint no_of_bits, gboolean little_endian)
/* Bit offset mask for number of bits = 8 - 16 */
static const guint16 bit_mask16[] = {
0xffff,
0x7fff,
0x3fff,
0x1fff,
0x0fff,
0x07ff,
0x03ff,
0x01ff
};
/* Get 1 - 8 bits */
guint8
tvb_get_bits8(tvbuff_t *tvb, gint bit_offset, gint no_of_bits)
{
gint offset;
guint64 value = 0;
guint64 tempval = 0;
guint16 value = 0;
guint8 tot_no_bits;
guint8 num_octs;
guint8 shift;
if (no_of_bits>64)
if (no_of_bits>8)
DISSECTOR_ASSERT_NOT_REACHED();
/* Byte align offset */
offset = bit_offset>>3;
/* Find out which mask to use for the most significant octet
* by convering bit_offset into the offset into the first
* fetched octet.
*/
bit_offset = bit_offset & 0x7;
tot_no_bits = bit_offset+no_of_bits;
/* Read two octets, mask off bit_offset bits and left shift out the unused bits */
value = tvb_get_ntohs(tvb,offset) & bit_mask16[bit_offset];
value = value >> (16 - tot_no_bits);
return (guint8)value;
}
/* Get 9 - 16 bits */
/* Bit offset mask for number of bits = 9 - 32 */
static const guint32 bit_mask32[] = {
0xffffffff,
0x7fffffff,
0x3fffffff,
0x1fffffff,
0x0fffffff,
0x07ffffff,
0x03ffffff,
0x01ffffff
};
guint16
tvb_get_bits16(tvbuff_t *tvb, gint bit_offset, gint no_of_bits,gboolean little_endian)
{
gint offset;
guint32 value = 0;
guint32 tempval = 0;
guint8 tot_no_bits;
if ((no_of_bits<8)||(no_of_bits>16))
/* If bits < 8 use tvb_get_bits8 */
DISSECTOR_ASSERT_NOT_REACHED();
if(little_endian){
DISSECTOR_ASSERT_NOT_REACHED();
@ -1483,85 +1534,100 @@ tvb_get_bits(tvbuff_t *tvb, gint bit_offset, gint no_of_bits, gboolean little_en
* fetched octet.
*/
bit_offset = bit_offset & 0x7;
/* calculate number of octets to read */
tot_no_bits = bit_offset + no_of_bits;
num_octs = tot_no_bits>>3;
/* We need at least one */
if (num_octs == 0){
num_octs = 1;
}
tot_no_bits = bit_offset+no_of_bits;
/* Read four octets, mask off bit_offset bits and left shift out the unused bits */
value = tvb_get_ntohl(tvb,offset) & bit_mask32[bit_offset];
value = value >> (32 - tot_no_bits);
/* Calculate shift value for most significant bits in the first octet */
shift = 8 * (num_octs-1);
return (guint16)value;
}
if ((tot_no_bits&0x7)!=0)
num_octs++;
/* Get 9 - 16 bits */
/* Bit offset mask for number of bits = 32 - 64 */
static const guint64 bit_mask64[] = {
0xffffffffffffff,
0x7fffffffffffff,
0x3fffffffffffff,
0x1fffffffffffff,
0x0fffffffffffff,
0x07ffffffffffff,
0x03ffffffffffff,
0x01ffffffffffff
};
tempval = tvb_get_guint8(tvb,offset) & bit_mask[bit_offset];
tempval = tempval << shift;
guint32
tvb_get_bits32(tvbuff_t *tvb, gint bit_offset, gint no_of_bits, gboolean little_endian)
{
gint offset;
guint64 value = 0;
guint64 tempval = 0;
guint8 tot_no_bits;
switch(num_octs){
case 1:
/* Total 8 bits */
value = tempval;
break;
case 2:
/* Total 8 + 8 = 16*/
value = (tempval << 8) | tvb_get_guint8(tvb,offset+1);
value = value >> (16 - tot_no_bits);
break;
case 3:
/* Total 8 + 16 = 24*/
value = (tempval << 16) | tvb_get_ntohs(tvb,offset+1);
value = value >> (24 - tot_no_bits);
break;
case 4:
/* Total 8 + 24 = 32*/
value = (tempval << 24) | tvb_get_ntoh24(tvb,offset+1);
value = value >> (32 - tot_no_bits);
break;
case 5:
/* total 8 + 32 = 40*/
value = (tempval << 32) | (tvb_get_ntohl(tvb,offset+1));
value = value >> (40 - tot_no_bits);
break;
case 6:
/* total 8 + 32 + 8 = 48*/
tempval = tvb_get_ntohl(tvb,offset+1);
tempval = tempval <<8;
value = value | tempval;
value = value | tvb_get_guint8(tvb,offset+5);
value = value >> (48 - tot_no_bits);
break;
case 7:
/* total 8 + 32 + 16 = 56*/
tempval = tvb_get_ntohl(tvb,offset+1);
tempval = tempval <<16;
value = value | tempval;
value = value >> (56 - tot_no_bits);
break;
case 8:
/* total 8 + 32 + 24 = 64*/
tempval = tvb_get_ntohl(tvb,offset+1);
tempval = tempval <<24;
value = value | tempval;
value = value | tvb_get_ntoh24(tvb,offset+5);
value = value >> (64 - tot_no_bits);
break;
case 9:
/* total 8 +64 = 72
* If bit_offset = 7 and no_of_bits=64 nine bytes is needed.
*/
value = tempval | tvb_get_ntoh64(tvb,offset+1);
value = value >> (72 - tot_no_bits);
break;
default:
if ((no_of_bits<17)||(no_of_bits>32))
/* If bits < 17 use tvb_get_bits8 or tvb_get_bits_ntohs */
DISSECTOR_ASSERT_NOT_REACHED();
return 0;
break;
if(little_endian){
DISSECTOR_ASSERT_NOT_REACHED();
/* This part is not implemented yet */
}
/* Byte align offset */
offset = bit_offset>>3;
/* Find out which mask to use for the most significant octet
* by convering bit_offset into the offset into the first
* fetched octet.
*/
bit_offset = bit_offset & 0x7;
tot_no_bits = bit_offset+no_of_bits;
/* Read eighth octets, mask off bit_offset bits and left shift out the unused bits */
value = tvb_get_ntoh64(tvb,offset) & bit_mask64[bit_offset];
value = value >> (64 - tot_no_bits);
return (guint32)value;
}
guint64
tvb_get_bits64(tvbuff_t *tvb, gint bit_offset, gint no_of_bits, gboolean little_endian)
{
gint offset;
guint64 value = 0;
guint64 tempval = 0;
guint8 tot_no_bits;
if ((no_of_bits<32)||(no_of_bits>64))
/* If bits < 17 use tvb_get_bits8 or tvb_get_bits_ntohs */
DISSECTOR_ASSERT_NOT_REACHED();
if(little_endian){
DISSECTOR_ASSERT_NOT_REACHED();
/* This part is not implemented yet */
}
/* Byte align offset */
offset = bit_offset>>3;
/* Find out which mask to use for the most significant octet
* by convering bit_offset into the offset into the first
* fetched octet.
*/
bit_offset = bit_offset & 0x7;
tot_no_bits = bit_offset+no_of_bits;
/* Read eighth octets, mask off bit_offset bits and left shift out the unused bits */
if (tot_no_bits < 65){
value = tvb_get_ntoh64(tvb,offset) & bit_mask64[bit_offset];
value = value >> (64 - tot_no_bits);
}else{
value = tvb_get_ntoh64(tvb,offset) & bit_mask64[bit_offset];
value = value << bit_offset;
tempval = tvb_get_guint8(tvb,offset+8);
tempval = tempval >> (8-bit_offset);
value = value | tempval;
}
return value;
}

View File

@ -337,7 +337,10 @@ extern void tvb_get_letohguid(tvbuff_t *tvb, gint offset, e_guid_t *guid);
extern void tvb_get_guid(tvbuff_t *tvb, gint offset, e_guid_t *guid, gboolean little_endian);
/* Fetch a specified number of bits from bit offset in a tvb */
extern guint64 tvb_get_bits(tvbuff_t *tvb, gint bit_offset, gint no_of_bits, gboolean little_endian);
extern guint8 tvb_get_bits8(tvbuff_t *tvb, gint bit_offset, gint no_of_bits);
extern guint16 tvb_get_bits16(tvbuff_t *tvb, gint bit_offset, gint no_of_bits, gboolean little_endian);
extern guint32 tvb_get_bits32(tvbuff_t *tvb, gint bit_offset, gint no_of_bits, gboolean little_endian);
extern guint64 tvb_get_bits64(tvbuff_t *tvb, gint bit_offset, gint no_of_bits, gboolean little_endian);
/** Returns target for convenience. Does not suffer from possible
* expense of tvb_get_ptr(), since this routine is smart enough