aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--debian/libwireshark0.symbols1
-rw-r--r--epan/dissectors/asn1/lpp/lpp.cnf4
-rw-r--r--epan/dissectors/packet-6lowpan.c2
-rw-r--r--epan/dissectors/packet-ansi_801.c30
-rw-r--r--epan/dissectors/packet-cl3.c2
-rw-r--r--epan/dissectors/packet-csn1.c22
-rw-r--r--epan/dissectors/packet-evs.c2
-rw-r--r--epan/dissectors/packet-geonw.c6
-rw-r--r--epan/dissectors/packet-gmr1_bcch.c10
-rw-r--r--epan/dissectors/packet-gsm_a_dtap.c2
-rw-r--r--epan/dissectors/packet-gsm_a_gm.c4
-rw-r--r--epan/dissectors/packet-gsm_a_rr.c2
-rw-r--r--epan/dissectors/packet-ieee80211.c8
-rw-r--r--epan/dissectors/packet-ip.c4
-rw-r--r--epan/dissectors/packet-iso14443.c30
-rw-r--r--epan/dissectors/packet-isup.c2
-rw-r--r--epan/dissectors/packet-lpp.c4
-rw-r--r--epan/dissectors/packet-per.c6
-rw-r--r--epan/dissectors/packet-tcp.c4
-rw-r--r--epan/dissectors/packet-usb-hid.c52
-rw-r--r--epan/dissectors/packet-wsmp.c2
-rw-r--r--epan/proto.c38
-rw-r--r--epan/proto.h42
-rw-r--r--epan/to_str.c15
-rw-r--r--epan/to_str.h2
-rw-r--r--epan/tvbuff.c185
-rw-r--r--epan/tvbuff.h9
-rwxr-xr-xtools/checkAPIs.pl2
28 files changed, 330 insertions, 162 deletions
diff --git a/debian/libwireshark0.symbols b/debian/libwireshark0.symbols
index 97ddf08852..c89534bb47 100644
--- a/debian/libwireshark0.symbols
+++ b/debian/libwireshark0.symbols
@@ -1833,6 +1833,7 @@ libwireshark.so.0 libwireshark0 #MINVER#
tvb_new_child_real_data@Base 1.9.1
tvb_new_composite@Base 1.9.1
tvb_new_octet_aligned@Base 1.9.1
+ tvb_new_octet_right_aligned@Base 3.5.1
tvb_new_real_data@Base 1.9.1
tvb_new_subset_length@Base 1.9.1
tvb_new_subset_length_caplen@Base 2.3.0
diff --git a/epan/dissectors/asn1/lpp/lpp.cnf b/epan/dissectors/asn1/lpp/lpp.cnf
index 0e190a6ef1..15c5fbf843 100644
--- a/epan/dissectors/asn1/lpp/lpp.cnf
+++ b/epan/dissectors/asn1/lpp/lpp.cnf
@@ -1297,10 +1297,10 @@ AlmanacBDS-AlmanacSet-r12/bdsAlmA1-r12 DISPLAY=BASE_CUSTOM STRINGS=CF_FUNC(lpp_b
bits = tvb_get_bits16(bdsSvHealth_tvb, 0, 9,ENC_BIG_ENDIAN);
if (bits == 0x1ff) {
proto_tree_add_boolean_bits_format_value(subtree, hf_lpp_bdsSvHealth_r12_sat_clock, bdsSvHealth_tvb, 0, 1, 1,
- "Satellite is in failure or permanently shut off (1)");
+ ENC_BIG_ENDIAN, "Satellite is in failure or permanently shut off (1)");
} else if (bits == 0x100) {
proto_tree_add_boolean_bits_format_value(subtree, hf_lpp_bdsSvHealth_r12_sat_clock, bdsSvHealth_tvb, 0, 1, 1,
- "Satellite clock is unavailable (1)");
+ ENC_BIG_ENDIAN, "Satellite clock is unavailable (1)");
} else {
proto_tree_add_bits_item(subtree, hf_lpp_bdsSvHealth_r12_sat_clock, bdsSvHealth_tvb, 0, 1, ENC_BIG_ENDIAN);
proto_tree_add_bits_item(subtree, hf_lpp_bdsSvHealth_r12_b1i, bdsSvHealth_tvb, 1, 1, ENC_BIG_ENDIAN);
diff --git a/epan/dissectors/packet-6lowpan.c b/epan/dissectors/packet-6lowpan.c
index 61d7d88884..8a76656a98 100644
--- a/epan/dissectors/packet-6lowpan.c
+++ b/epan/dissectors/packet-6lowpan.c
@@ -3192,7 +3192,7 @@ dissect_6lowpan_unknown(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
}
else {
guint8 pattern = tvb_get_guint8(tvb, 0);
- proto_tree_add_uint_bits_format_value(tree, hf_6lowpan_pattern, tvb, 0, 8, pattern, "Unknown (0x%02x)", pattern);
+ proto_tree_add_uint_bits_format_value(tree, hf_6lowpan_pattern, tvb, 0, 8, pattern, ENC_BIG_ENDIAN, "Unknown (0x%02x)", pattern);
}
/* Create a tvbuff subset for the remaining data. */
diff --git a/epan/dissectors/packet-ansi_801.c b/epan/dissectors/packet-ansi_801.c
index 37f54488ff..35962a8bbd 100644
--- a/epan/dissectors/packet-ansi_801.c
+++ b/epan/dissectors/packet-ansi_801.c
@@ -562,20 +562,20 @@ pr_loc_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint len,
/* TIME_REF_CDMA */
value = tvb_get_bits16(tvb, bit_offset, 14, ENC_BIG_ENDIAN);
proto_tree_add_uint_bits_format_value(tree, hf_ansi_801_time_ref_cdma, tvb, bit_offset, 14, value * 50,
- "%u frames (0x%04x)", value * 50, value);
+ ENC_BIG_ENDIAN, "%u frames (0x%04x)", value * 50, value);
bit_offset += 14;
/* LAT */
value = tvb_get_bits32(tvb, bit_offset, 25, ENC_BIG_ENDIAN);
fl_value = (float)(-90.0 + ((float)value * 180 / 33554432));
- proto_tree_add_float_bits_format_value(tree, hf_ansi_801_lat, tvb, bit_offset, 25, fl_value,
+ proto_tree_add_float_bits_format_value(tree, hf_ansi_801_lat, tvb, bit_offset, 25, fl_value, ENC_BIG_ENDIAN,
"%.5f degrees %s (0x%08x)", fabs(fl_value), fl_value < 0 ? "South" : "North", value);
bit_offset += 25;
/* LONG */
value = tvb_get_bits32(tvb, bit_offset, 26, ENC_BIG_ENDIAN);
fl_value = (float)(-180.0 + ((float)value * 180 / 33554432));
- proto_tree_add_float_bits_format_value(tree, hf_ansi_801_long, tvb, bit_offset, 26, fl_value,
+ proto_tree_add_float_bits_format_value(tree, hf_ansi_801_long, tvb, bit_offset, 26, fl_value, ENC_BIG_ENDIAN,
"%.5f degrees %s (0x%08x)", fabs(fl_value), fl_value < 0 ? "West" : "East", value);
bit_offset += 26;
@@ -583,7 +583,7 @@ pr_loc_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint len,
value = tvb_get_bits8(tvb, bit_offset, 4);
fl_value = (float)(5.625 * value);
proto_tree_add_float_bits_format_value(tree, hf_ansi_801_loc_uncrtnty_ang, tvb, bit_offset, 4, fl_value,
- "%.5f degrees (0x%02x)", fl_value, value);
+ ENC_BIG_ENDIAN, "%.5f degrees (0x%02x)", fl_value, value);
bit_offset += 4;
/* LOC_UNCRTNTY_A */
@@ -599,7 +599,7 @@ pr_loc_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint len,
str = wmem_strdup_printf(pinfo->pool, "%.2f meters", fl_value);
}
proto_tree_add_uint_bits_format_value(tree, hf_ansi_801_loc_uncrtnty_a, tvb, bit_offset, 5, value,
- "%s (0x%02x)", str, value);
+ ENC_BIG_ENDIAN, "%s (0x%02x)", str, value);
bit_offset += 5;
/* LOC_UNCRTNTY_P */
@@ -615,7 +615,7 @@ pr_loc_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint len,
str = wmem_strdup_printf(pinfo->pool, "%.2f meters", fl_value);
}
proto_tree_add_uint_bits_format_value(tree, hf_ansi_801_loc_uncrtnty_p, tvb, bit_offset, 5, value,
- "%s (0x%02x)", str, value);
+ ENC_BIG_ENDIAN, "%s (0x%02x)", str, value);
bit_offset += 5;
/* FIX_TYPE */
@@ -631,14 +631,14 @@ pr_loc_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint len,
value = tvb_get_bits16(tvb, bit_offset, 9, ENC_BIG_ENDIAN);
fl_value = (float)(0.25 * value);
proto_tree_add_float_bits_format_value(tree, hf_ansi_801_velocity_hor, tvb, bit_offset, 9, fl_value,
- "%.2f m/s (0x%04x)", fl_value, value);
+ ENC_BIG_ENDIAN, "%.2f m/s (0x%04x)", fl_value, value);
bit_offset += 9;
/* HEADING */
value = tvb_get_bits16(tvb, bit_offset, 10, ENC_BIG_ENDIAN);
fl_value = (float)value * 360 / 1024;
proto_tree_add_float_bits_format_value(tree, hf_ansi_801_heading, tvb, bit_offset, 10, fl_value,
- "%.3f degrees (0x%04x)", fl_value, value);
+ ENC_BIG_ENDIAN, "%.3f degrees (0x%04x)", fl_value, value);
bit_offset += 10;
if(fix_type)
@@ -647,7 +647,7 @@ pr_loc_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint len,
value = tvb_get_bits8(tvb, bit_offset, 8);
fl_value = (float)(-64 + 0.5 * value);
proto_tree_add_float_bits_format_value(tree, hf_ansi_801_velocity_ver, tvb, bit_offset, 8, fl_value,
- "%.1f m/s (0x%02x)", fl_value, value);
+ ENC_BIG_ENDIAN, "%.1f m/s (0x%02x)", fl_value, value);
bit_offset += 8;
}
}
@@ -660,13 +660,13 @@ pr_loc_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint len,
/* CLOCK_BIAS */
value = tvb_get_bits32(tvb, bit_offset, 18, ENC_BIG_ENDIAN);
proto_tree_add_int_bits_format_value(tree, hf_ansi_801_clock_bias, tvb, bit_offset, 18, (gint32)value - 13000,
- "%d ns (0x%06x)", (gint32)value - 13000, value);
+ ENC_BIG_ENDIAN, "%d ns (0x%06x)", (gint32)value - 13000, value);
bit_offset += 18;
/* CLOCK_DRIFT */
value = tvb_get_bits16(tvb, bit_offset, 16, ENC_BIG_ENDIAN);
proto_tree_add_int_bits_format_value(tree, hf_ansi_801_clock_drift, tvb, bit_offset, 16, (gint16)value,
- "%d ppb (ns/s) (0x%04x)", (gint16)value, value);
+ ENC_BIG_ENDIAN, "%d ppb (ns/s) (0x%04x)", (gint16)value, value);
bit_offset += 16;
}
@@ -678,7 +678,7 @@ pr_loc_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint len,
/* HEIGHT */
value = tvb_get_bits16(tvb, bit_offset, 14, ENC_BIG_ENDIAN);
proto_tree_add_int_bits_format_value(tree, hf_ansi_801_height, tvb, bit_offset, 14, (gint32)value - 500,
- "%d m (0x%04x)", (gint32)value - 500, value);
+ ENC_BIG_ENDIAN, "%d m (0x%04x)", (gint32)value - 500, value);
bit_offset += 14;
/* LOC_UNCRTNTY_V */
@@ -694,7 +694,7 @@ pr_loc_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint len,
str = wmem_strdup_printf(pinfo->pool, "%.2f meters", fl_value);
}
proto_tree_add_uint_bits_format_value(tree, hf_ansi_801_loc_uncrtnty_v, tvb, bit_offset, 5, value,
- "%s (0x%02x)", str, value);
+ ENC_BIG_ENDIAN, "%s (0x%02x)", str, value);
bit_offset += 5;
}
@@ -736,7 +736,7 @@ for_pr_gps_sat_health(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint
/* NUM_BAD_SV */
num_bad_sv = tvb_get_bits8(tvb, bit_offset, 4) + 1;
proto_tree_add_uint_bits_format_value(tree, hf_ansi_801_num_bad_sv, tvb, bit_offset, 4, num_bad_sv,
- "%u", num_bad_sv);
+ ENC_BIG_ENDIAN, "%u", num_bad_sv);
bit_offset += 4;
for (i=0; i < num_bad_sv; i++)
@@ -744,7 +744,7 @@ for_pr_gps_sat_health(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint
/* BAD_SV_PRN_NUM */
bad_sv_prn_num = tvb_get_bits8(tvb, bit_offset, 5) + 1;
proto_tree_add_uint_bits_format_value(tree, hf_ansi_801_bad_sv_prn_num, tvb, bit_offset, 5, bad_sv_prn_num,
- "%u", bad_sv_prn_num);
+ ENC_BIG_ENDIAN, "%u", bad_sv_prn_num);
bit_offset += 5;
}
}
diff --git a/epan/dissectors/packet-cl3.c b/epan/dissectors/packet-cl3.c
index d3e2827616..ce46148de3 100644
--- a/epan/dissectors/packet-cl3.c
+++ b/epan/dissectors/packet-cl3.c
@@ -123,7 +123,7 @@ dissect_cl3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
/* CL3 version agnostic fields: (pretty much just the first byte; like ipv4, version + length) */
proto_tree_add_item(cl3_tree, hf_cl3_version, tvb, 0, 1, ENC_NA);
proto_tree_add_uint_bits_format_value(cl3_tree, hf_cl3_headerlen, tvb, 0 + 4, 4, header_length,
- "%u bytes (%u)", header_length, header_length >> 2);
+ ENC_BIG_ENDIAN, "%u bytes (%u)", header_length, header_length >> 2);
/* validate the header length... */
if ((header_length < 1) || (header_length > tvb_captured_length(tvb))) {
diff --git a/epan/dissectors/packet-csn1.c b/epan/dissectors/packet-csn1.c
index 5f3ee215d8..447b6e35cf 100644
--- a/epan/dissectors/packet-csn1.c
+++ b/epan/dissectors/packet-csn1.c
@@ -279,7 +279,7 @@ csnStreamDissector(proto_tree *tree, csnStream_t* ar, const CSN_DESCR* pDescr, t
*pui8 = ui8 + (guint8)pDescr->descr.value;
proto_tree_add_uint_bits_format_value(tree, *(pDescr->hf_ptr), tvb, bit_offset, no_of_bits,
- *pui8, "%u (Raw %u + Offset %u)", *pui8, ui8,
+ *pui8, ENC_BIG_ENDIAN, "%u (Raw %u + Offset %u)", *pui8, ui8,
(guint8) pDescr->descr.value);
}
else if (no_of_bits <= 16)
@@ -289,7 +289,7 @@ csnStreamDissector(proto_tree *tree, csnStream_t* ar, const CSN_DESCR* pDescr, t
*pui16 = ui16 + (guint16)pDescr->descr.value;
proto_tree_add_uint_bits_format_value(tree, *(pDescr->hf_ptr), tvb, bit_offset, no_of_bits,
- *pui16, "%u (Raw %u + Offset %u)", *pui16, ui16,
+ *pui16, ENC_BIG_ENDIAN, "%u (Raw %u + Offset %u)", *pui16, ui16,
(guint16) pDescr->descr.value);
}
else if (no_of_bits <= 32)
@@ -299,7 +299,7 @@ csnStreamDissector(proto_tree *tree, csnStream_t* ar, const CSN_DESCR* pDescr, t
*pui32 = ui32 + (guint16)pDescr->descr.value;
proto_tree_add_uint_bits_format_value(tree, *(pDescr->hf_ptr), tvb, bit_offset, no_of_bits,
- *pui32, "%u (Raw %u + Offset %u)", *pui32, ui32,
+ *pui32, ENC_BIG_ENDIAN, "%u (Raw %u + Offset %u)", *pui32, ui32,
(guint16) pDescr->descr.value);
}
else
@@ -417,7 +417,7 @@ csnStreamDissector(proto_tree *tree, csnStream_t* ar, const CSN_DESCR* pDescr, t
do
{
*pui8++ = tvb_get_bits8(tvb, bit_offset, no_of_bits);
- proto_tree_add_uint_bits_format_value(tree, *(pDescr->hf_ptr), tvb, bit_offset, no_of_bits, *pui8, " (Count %d)", i++);
+ proto_tree_add_uint_bits_format_value(tree, *(pDescr->hf_ptr), tvb, bit_offset, no_of_bits, *pui8, ENC_BIG_ENDIAN, " (Count %d)", i++);
bit_offset += no_of_bits;
} while (--nCount > 0);
}
@@ -697,7 +697,7 @@ csnStreamDissector(proto_tree *tree, csnStream_t* ar, const CSN_DESCR* pDescr, t
/* Now get the bits to extract the index */
Bits = ixBitsTab[count];
- proto_tree_add_uint_bits_format_value(tree, *(pDescr->hf_ptr), tvb, bit_offset, Bits, tvb_get_bits8(tvb, bit_offset, Bits), " (Union)");
+ proto_tree_add_uint_bits_format_value(tree, *(pDescr->hf_ptr), tvb, bit_offset, Bits, tvb_get_bits8(tvb, bit_offset, Bits), ENC_BIG_ENDIAN, " (Union)");
t_index = 0;
while (Bits > 0)
@@ -807,21 +807,21 @@ csnStreamDissector(proto_tree *tree, csnStream_t* ar, const CSN_DESCR* pDescr, t
guint8 ui8 = tvb_get_bits8(tvb, bit_offset, no_of_bits);
pui8 = pui8DATA(data, pDescr->offset);
*pui8 = ui8 + (guint8)pDescr->descr.value;
- proto_tree_add_uint_bits_format_value(tree, *(pDescr->hf_ptr), tvb, bit_offset, no_of_bits, ui8, "%d", ui8);
+ proto_tree_add_uint_bits_format_value(tree, *(pDescr->hf_ptr), tvb, bit_offset, no_of_bits, ui8, ENC_BIG_ENDIAN, "%d", ui8);
}
else if (no_of_bits <= 16)
{
guint16 ui16 = tvb_get_bits16(tvb, bit_offset, no_of_bits, ENC_BIG_ENDIAN);
pui16 = pui16DATA(data, pDescr->offset);
*pui16 = ui16 + (guint16)pDescr->descr.value;
- proto_tree_add_uint_bits_format_value(tree, *(pDescr->hf_ptr), tvb, bit_offset, no_of_bits, ui16, "%d", ui16);
+ proto_tree_add_uint_bits_format_value(tree, *(pDescr->hf_ptr), tvb, bit_offset, no_of_bits, ui16, ENC_BIG_ENDIAN, "%d", ui16);
}
else if (no_of_bits <= 32)
{
guint32 ui32 = tvb_get_bits32(tvb, bit_offset, no_of_bits, ENC_BIG_ENDIAN);
pui32 = pui32DATA(data, pDescr->offset);
*pui32 = ui32 + (guint16)pDescr->descr.value;
- proto_tree_add_uint_bits_format_value(tree, *(pDescr->hf_ptr), tvb, bit_offset, no_of_bits, ui32, "%d", ui32);
+ proto_tree_add_uint_bits_format_value(tree, *(pDescr->hf_ptr), tvb, bit_offset, no_of_bits, ui32, ENC_BIG_ENDIAN, "%d", ui32);
}
else
{
@@ -889,7 +889,7 @@ csnStreamDissector(proto_tree *tree, csnStream_t* ar, const CSN_DESCR* pDescr, t
while (nCount > 0)
{
*pui8 = tvb_get_bits8(tvb, bit_offset, no_of_bits);
- proto_tree_add_uint_bits_format_value(tree, *(pDescr->hf_ptr), tvb, bit_offset, no_of_bits, *pui8, " (Count %d)", i++);
+ proto_tree_add_uint_bits_format_value(tree, *(pDescr->hf_ptr), tvb, bit_offset, no_of_bits, *pui8, ENC_BIG_ENDIAN, " (Count %d)", i++);
pui8++;
bit_offset += no_of_bits;
nCount--;
@@ -902,7 +902,7 @@ csnStreamDissector(proto_tree *tree, csnStream_t* ar, const CSN_DESCR* pDescr, t
while (nCount > 0)
{
*pui16 = tvb_get_bits16(tvb, bit_offset, no_of_bits, ENC_BIG_ENDIAN);
- proto_tree_add_uint_bits_format_value(tree, *(pDescr->hf_ptr), tvb, bit_offset, no_of_bits, *pui16, " (Count %d)", i++);
+ proto_tree_add_uint_bits_format_value(tree, *(pDescr->hf_ptr), tvb, bit_offset, no_of_bits, *pui16, ENC_BIG_ENDIAN, " (Count %d)", i++);
bit_offset += no_of_bits;
nCount--;
}
@@ -1459,7 +1459,7 @@ csnStreamDissector(proto_tree *tree, csnStream_t* ar, const CSN_DESCR* pDescr, t
}
/* control of next element's tag */
- proto_tree_add_uint_bits_format_value(tree, *(pDescr->hf_ptr), tvb, bit_offset, 1, tvb_get_bits8(tvb, bit_offset, 1), "%s[%d]",
+ proto_tree_add_uint_bits_format_value(tree, *(pDescr->hf_ptr), tvb, bit_offset, 1, tvb_get_bits8(tvb, bit_offset, 1), ENC_BIG_ENDIAN, "%s[%d]",
proto_registrar_get_name(*(pDescr->hf_ptr)), ElementCount);
EndOfList = !(existNextElement(tvb, bit_offset, Tag));
diff --git a/epan/dissectors/packet-evs.c b/epan/dissectors/packet-evs.c
index 134f48b6a5..138a574df5 100644
--- a/epan/dissectors/packet-evs.c
+++ b/epan/dissectors/packet-evs.c
@@ -600,7 +600,7 @@ dissect_evs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
/* LP-CNG SID frame */
/* Bandwidth indicator 1 bit */
oct = tvb_get_bits8(tvb, bit_offset, 1);
- proto_tree_add_uint_bits_format_value(vd_tree, hf_evs_bw, tvb, bit_offset, 1, 1,"BW: %s (%u)",
+ proto_tree_add_uint_bits_format_value(vd_tree, hf_evs_bw, tvb, bit_offset, 1, 1, ENC_BIG_ENDIAN, "BW: %s (%u)",
val_to_str_const(oct << 1, evs_bw_values, "Unknown value"),
oct << 1);
bit_offset++;
diff --git a/epan/dissectors/packet-geonw.c b/epan/dissectors/packet-geonw.c
index 807252a639..3df6dcb0e4 100644
--- a/epan/dissectors/packet-geonw.c
+++ b/epan/dissectors/packet-geonw.c
@@ -1213,7 +1213,7 @@ dissect_sec_var_len(tvbuff_t *tvb, gint *offset, packet_info *pinfo, proto_tree
ti = proto_tree_add_item(tree, hf_sgeonw_var_len, tvb, start, (*offset) - start, ENC_NA); // Length cannot be determined now
subtree = proto_item_add_subtree(ti, ett_sgeonw_var_len);
proto_tree_add_bits_item(subtree, hf_sgeonw_var_len_det, tvb, start << 3, (*offset) - start, ENC_NA);
- proto_tree_add_uint_bits_format_value(subtree, hf_sgeonw_var_len_val, tvb, (start << 3) + (*offset) - start, (((*offset) - start) << 3) - ((*offset) - start),var_len,"%u",var_len);
+ proto_tree_add_uint_bits_format_value(subtree, hf_sgeonw_var_len_val, tvb, (start << 3) + (*offset) - start, (((*offset) - start) << 3) - ((*offset) - start),var_len,ENC_BIG_ENDIAN,"%u",var_len);
// EI Error if !mask (more than 32 bits)
if (!mask)
expert_add_info(pinfo, ti, &ei_sgeonw_len_unsupported);
@@ -1248,11 +1248,11 @@ dissect_sec_intx(tvbuff_t *tvb, gint *offset, packet_info *pinfo, proto_tree *tr
proto_tree_add_bits_item(subtree, hf_sgeonw_var_len_det, tvb, start << 3, (*offset) - start, ENC_NA);
if ((hf != hf_sgeonw_app_id) || ((*offset) - start) > 4) {
proto_tree_add_uint64_bits_format_value(subtree, hf, tvb, (start << 3) + (*offset) - start,
- (((*offset) - start) << 3) - ((*offset) - start), tmp_val, "%" G_GUINT64_FORMAT, tmp_val);
+ (((*offset) - start) << 3) - ((*offset) - start), tmp_val, ENC_BIG_ENDIAN, "%" G_GUINT64_FORMAT, tmp_val);
}
else {
proto_tree_add_uint_bits_format_value(subtree, hf, tvb, (start << 3) + (*offset) - start,
- (((*offset) - start) << 3) - ((*offset) - start), (guint32)tmp_val, "%s(%u)", val64_to_str_const(tmp_val, ieee1609dot2_Psid_vals, "Unknown") , (guint32)tmp_val);
+ (((*offset) - start) << 3) - ((*offset) - start), (guint32)tmp_val, ENC_BIG_ENDIAN, "%s(%u)", val64_to_str_const(tmp_val, ieee1609dot2_Psid_vals, "Unknown") , (guint32)tmp_val);
}
// ETSI TS 103 097 V1.2.1: The encoding of the length shall use at most 7 bits set to 1.
if (!mask)
diff --git a/epan/dissectors/packet-gmr1_bcch.c b/epan/dissectors/packet-gmr1_bcch.c
index c50459d636..848610fe7b 100644
--- a/epan/dissectors/packet-gmr1_bcch.c
+++ b/epan/dissectors/packet-gmr1_bcch.c
@@ -649,14 +649,14 @@ Seg3A_LAI_Dissector(proto_tree *tree, csnStream_t* ar, tvbuff_t *tvb, void* data
LAI->MSC_ID = (LAI->LAC >> 10) & 0x3f;
LAI->Spot_Beam_ID = LAI->LAC & 0x03ff;
- proto_tree_add_uint_bits_format_value(tree, hf_seg3a_lai_mcc, tvb, ar->bit_offset, 16, (guint32)LAI->MCC, "%d", LAI->MCC);
- proto_tree_add_uint_bits_format_value(tree, hf_seg3a_lai_mnc, tvb, ar->bit_offset+16, 8, (guint32)LAI->MNC, "%d", LAI->MNC);
+ proto_tree_add_uint_bits_format_value(tree, hf_seg3a_lai_mcc, tvb, ar->bit_offset, 16, (guint32)LAI->MCC, ENC_BIG_ENDIAN, "%d", LAI->MCC);
+ proto_tree_add_uint_bits_format_value(tree, hf_seg3a_lai_mnc, tvb, ar->bit_offset+16, 8, (guint32)LAI->MNC, ENC_BIG_ENDIAN, "%d", LAI->MNC);
- lac_item = proto_tree_add_uint_bits_format_value(tree, hf_seg3a_lai_lac, tvb, ar->bit_offset+24, 16, (guint32)LAI->LAC, "0x%04x", LAI->LAC);
+ lac_item = proto_tree_add_uint_bits_format_value(tree, hf_seg3a_lai_lac, tvb, ar->bit_offset+24, 16, (guint32)LAI->LAC, ENC_BIG_ENDIAN, "0x%04x", LAI->LAC);
lac_tree = proto_item_add_subtree(lac_item, ett_csn1);
- proto_tree_add_uint_bits_format_value(lac_tree, hf_seg3a_lai_msc_id, tvb, ar->bit_offset+24, 6, (guint32)LAI->MSC_ID, "%d", LAI->MSC_ID);
- proto_tree_add_uint_bits_format_value(lac_tree, hf_seg3a_lai_spot_beam_id, tvb, ar->bit_offset+30, 10, (guint32)LAI->Spot_Beam_ID, "%d", LAI->Spot_Beam_ID);
+ proto_tree_add_uint_bits_format_value(lac_tree, hf_seg3a_lai_msc_id, tvb, ar->bit_offset+24, 6, (guint32)LAI->MSC_ID, ENC_BIG_ENDIAN, "%d", LAI->MSC_ID);
+ proto_tree_add_uint_bits_format_value(lac_tree, hf_seg3a_lai_spot_beam_id, tvb, ar->bit_offset+30, 10, (guint32)LAI->Spot_Beam_ID, ENC_BIG_ENDIAN, "%d", LAI->Spot_Beam_ID);
ar->remaining_bits_len -= 5*8;
ar->bit_offset += 5*8;
diff --git a/epan/dissectors/packet-gsm_a_dtap.c b/epan/dissectors/packet-gsm_a_dtap.c
index 7f598405ac..e230e3ba04 100644
--- a/epan/dissectors/packet-gsm_a_dtap.c
+++ b/epan/dissectors/packet-gsm_a_dtap.c
@@ -3959,7 +3959,7 @@ de_tp_epc_ellipsoid_point_with_alt(tvbuff_t *tvb, proto_tree *tree, packet_info
curr_offset += 3;
longitude = tvb_get_ntoh24(tvb, curr_offset);
proto_tree_add_int_format(tree, hf_gsm_a_dtap_epc_degrees_longitude, tvb, curr_offset, 3, longitude,
- "%s = %s: %d", decode_bits_in_field(curr_offset<<3, 24, longitude),
+ "%s = %s: %d", decode_bits_in_field(curr_offset<<3, 24, longitude, ENC_BIG_ENDIAN),
proto_registrar_get_name(hf_gsm_a_dtap_epc_degrees_longitude), longitude-8388608);
curr_offset += 3;
proto_tree_add_bits_item(tree, hf_gsm_a_dtap_epc_altitude_dir, tvb, curr_offset<<3, 1, ENC_BIG_ENDIAN);
diff --git a/epan/dissectors/packet-gsm_a_gm.c b/epan/dissectors/packet-gsm_a_gm.c
index 9238a41fe6..8b4c8f0cdf 100644
--- a/epan/dissectors/packet-gsm_a_gm.c
+++ b/epan/dissectors/packet-gsm_a_gm.c
@@ -1880,7 +1880,7 @@ de_gmm_ms_radio_acc_cap(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, gui
/* decode_bits_in_field(gint bit_offset, gint no_of_bits, guint64 value)*/
proto_tree_add_uint_format(tf_tree, hf_gsm_a_gm_rf_power_capability, tvb, curr_offset-1-add_octets, 1+add_octets, value,
- "%s RF Power Capability, GMSK Power Class: %s (%u)", decode_bits_in_field(bit_offset, 3, value), str, value);
+ "%s RF Power Capability, GMSK Power Class: %s (%u)", decode_bits_in_field(bit_offset, 3, value, ENC_BIG_ENDIAN), str, value);
bit_offset += 3;
curr_bits_length -= bits_needed;
oct <<= bits_needed;
@@ -1948,7 +1948,7 @@ de_gmm_ms_radio_acc_cap(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, gui
str = "Not specified??";
proto_tree_add_uint_format(tf_tree, hf_gsm_a_gm_rf_power_capability, tvb, curr_offset-1-add_octets, 1+add_octets, value,
- "%s RF Power Capability, GMSK Power Class: %s (%u)", decode_bits_in_field(bit_offset, 3, value), str, value);
+ "%s RF Power Capability, GMSK Power Class: %s (%u)", decode_bits_in_field(bit_offset, 3, value, ENC_BIG_ENDIAN), str, value);
bit_offset += 3;
curr_bits_length -= bits_needed;
diff --git a/epan/dissectors/packet-gsm_a_rr.c b/epan/dissectors/packet-gsm_a_rr.c
index ee0f7a76e4..745bde8fe8 100644
--- a/epan/dissectors/packet-gsm_a_rr.c
+++ b/epan/dissectors/packet-gsm_a_rr.c
@@ -1599,7 +1599,7 @@ static void dissect_channel_list_n_range(tvbuff_t *tvb, proto_tree *tree, packet
for (i=1; i<=imax; i++) {
w[i] = (gint) tvb_get_bits(tvb, bit_offset, wsize, FALSE);
proto_tree_add_bytes_format(subtree, hf_gsm_a_rr_w_elements, tvb, bit_offset>>3, ((bit_offset+wsize-1)>>3) - (bit_offset>>3) + 1 , NULL, "%s W(%d): %d",
- decode_bits_in_field(bit_offset, wsize, w[i]),
+ decode_bits_in_field(bit_offset, wsize, w[i], ENC_BIG_ENDIAN),
i,
w[i]);
bit_offset += wsize;
diff --git a/epan/dissectors/packet-ieee80211.c b/epan/dissectors/packet-ieee80211.c
index 3e4e7ff888..5388b5aa1d 100644
--- a/epan/dissectors/packet-ieee80211.c
+++ b/epan/dissectors/packet-ieee80211.c
@@ -24270,7 +24270,7 @@ dissect_pvb_encoded_block_bitmap(tvbuff_t *tvb, packet_info *pinfo _U_,
proto_tree_add_uint_bits_format_value(sb_tree,
hf_ieee80211_s1g_block_bitmap_sta_aid13,
tvb, offset * 8 + (7 - bit_pos), 1, 1,
- " 0x%0x", aid13);
+ ENC_BIG_ENDIAN, " 0x%0x", aid13);
}
bit_pos += 1;
@@ -24342,7 +24342,7 @@ dissect_pvb_encoded_olb(tvbuff_t *tvb, packet_info *pinfo _U_,
proto_tree_add_uint_bits_format_value(sb_tree,
hf_ieee80211_s1g_block_bitmap_sta_aid13,
tvb, offset * 8 + (7 - bit_pos), 1, 1,
- " 0x%0x", aid13);
+ ENC_BIG_ENDIAN, " 0x%0x", aid13);
}
bit_pos += 1;
@@ -24383,11 +24383,11 @@ dissect_pvb_encoded_ade(tvbuff_t *tvb, packet_info *pinfo _U_,
proto_tree_add_uint_bits_format_value(cntl_tree,
hf_ieee80211_s1g_block_bitmap_ewl,
tvb, offset *8, 3, ewl,
- "EWL: %u", ewl);
+ ENC_BIG_ENDIAN, "EWL: %u", ewl);
proto_tree_add_uint_bits_format_value(cntl_tree,
hf_ieee80211_s1g_block_bitmap_len,
tvb, offset * 8 + 3, 5, ade_bytes,
- "Length: %u", ade_bytes);
+ ENC_BIG_ENDIAN, "Length: %u", ade_bytes);
offset += 1;
/* TODO: Add each subblock */
diff --git a/epan/dissectors/packet-ip.c b/epan/dissectors/packet-ip.c
index b9242ec827..b3b7ba1055 100644
--- a/epan/dissectors/packet-ip.c
+++ b/epan/dissectors/packet-ip.c
@@ -1889,7 +1889,7 @@ dissect_ip_v4(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void*
"Bogus IP header length (%u, must be at least %u)",
hlen, IPH_MIN_LEN);
tf = proto_tree_add_uint_bits_format_value(ip_tree, hf_ip_hdr_len, tvb, (offset<<3)+4, 4, hlen,
- "%u bytes (%u)", hlen, hlen>>2);
+ ENC_BIG_ENDIAN, "%u bytes (%u)", hlen, hlen>>2);
expert_add_info_format(pinfo, tf, &ei_ip_bogus_header_length,
"Bogus IP header length (%u, must be at least %u)", hlen, IPH_MIN_LEN);
return tvb_captured_length(tvb);
@@ -1897,7 +1897,7 @@ dissect_ip_v4(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void*
// This should be consistent with tcp.hdr_len.
proto_tree_add_uint_bits_format_value(ip_tree, hf_ip_hdr_len, tvb, (offset<<3)+4, 4, hlen,
- "%u bytes (%u)", hlen, hlen>>2);
+ ENC_BIG_ENDIAN, "%u bytes (%u)", hlen, hlen>>2);
iph->ip_tos = tvb_get_guint8(tvb, offset + 1);
if (g_ip_dscp_actif) {
diff --git a/epan/dissectors/packet-iso14443.c b/epan/dissectors/packet-iso14443.c
index abb22cfd11..69da2e9a3c 100644
--- a/epan/dissectors/packet-iso14443.c
+++ b/epan/dissectors/packet-iso14443.c
@@ -469,7 +469,7 @@ static int dissect_iso14443_atqb(tvbuff_t *tvb, gint offset,
max_frame_size_code = (tvb_get_guint8(tvb, offset) & 0xF0) >> 4;
proto_tree_add_uint_bits_format_value(prot_inf_tree,
hf_iso14443_max_frame_size_code,
- tvb, offset*8, 4, max_frame_size_code, "%d",
+ tvb, offset*8, 4, max_frame_size_code, ENC_BIG_ENDIAN, "%d",
max_frame_size_code);
if (max_frame_size_code < LEN_CODE_MAX) {
pi = proto_tree_add_uint(prot_inf_tree, hf_iso14443_max_frame_size,
@@ -487,7 +487,7 @@ static int dissect_iso14443_atqb(tvbuff_t *tvb, gint offset,
offset++;
fwi = (tvb_get_guint8(tvb, offset) & 0xF0) >> 4;
proto_tree_add_uint_bits_format_value(prot_inf_tree, hf_iso14443_fwi,
- tvb, offset*8, 4, fwi, "%d", fwi);
+ tvb, offset*8, 4, fwi, ENC_BIG_ENDIAN, "%d", fwi);
iso14443_adc = tvb_get_guint8(tvb, offset) & 0x04;
proto_tree_add_item(prot_inf_tree, hf_iso14443_adc,
tvb, offset, 1, ENC_BIG_ENDIAN);
@@ -508,11 +508,11 @@ static int dissect_iso14443_atqb(tvbuff_t *tvb, gint offset,
nad_supported = tvb_get_guint8(tvb, offset) & 0x02;
proto_tree_add_boolean_bits_format_value(prot_inf_tree,
hf_iso14443_nad_supported, tvb, 8*offset+6, 1, nad_supported,
- "%s", tfs_get_string(nad_supported, &tfs_supported_not_supported));
+ ENC_BIG_ENDIAN, "%s", tfs_get_string(nad_supported, &tfs_supported_not_supported));
cid_supported = tvb_get_guint8(tvb, offset) & 0x01;
proto_tree_add_boolean_bits_format_value(prot_inf_tree,
hf_iso14443_cid_supported, tvb, 8*offset+7, 1, cid_supported,
- "%s", tfs_get_string(cid_supported, &tfs_supported_not_supported));
+ ENC_BIG_ENDIAN, "%s", tfs_get_string(cid_supported, &tfs_supported_not_supported));
offset++;
/* XXX - extended ATQB */
@@ -559,7 +559,7 @@ dissect_iso14443_cmd_type_wupb(tvbuff_t *tvb, packet_info *pinfo,
proto_item_append_text(ti, ": %s", msg_type);
proto_tree_add_uint_bits_format_value(tree, hf_iso14443_n,
tvb, offset*8+5, 3, pow2(guint32, param&0x07),
- "%u", pow2(guint32, param&0x07));
+ ENC_BIG_ENDIAN, "%u", pow2(guint32, param&0x07));
offset++;
if (!crc_dropped) {
@@ -740,10 +740,10 @@ static int dissect_iso14443_ats(tvbuff_t *tvb, gint offset,
tb1_tree = proto_item_add_subtree(tb1_it, ett_iso14443_ats_tb1);
fwi = (tvb_get_guint8(tvb, offset) & 0xF0) >> 4;
proto_tree_add_uint_bits_format_value(tb1_tree, hf_iso14443_fwi,
- tvb, offset*8, 4, fwi, "%d", fwi);
+ tvb, offset*8, 4, fwi, ENC_BIG_ENDIAN, "%d", fwi);
sfgi = tvb_get_guint8(tvb, offset) & 0x0F;
proto_tree_add_uint_bits_format_value(tb1_tree, hf_iso14443_sfgi,
- tvb, offset*8+4, 4, sfgi, "%d", sfgi);
+ tvb, offset*8+4, 4, sfgi, ENC_BIG_ENDIAN, "%d", sfgi);
offset++;
}
if (t0 & HAVE_TC1) {
@@ -754,11 +754,11 @@ static int dissect_iso14443_ats(tvbuff_t *tvb, gint offset,
cid_supported = tvb_get_guint8(tvb, offset) & 0x02;
proto_tree_add_boolean_bits_format_value(tc1_tree,
hf_iso14443_cid_supported, tvb, 8*offset+6, 1, cid_supported,
- "%s", tfs_get_string(cid_supported, &tfs_supported_not_supported));
+ ENC_BIG_ENDIAN, "%s", tfs_get_string(cid_supported, &tfs_supported_not_supported));
nad_supported = tvb_get_guint8(tvb, offset) & 0x01;
proto_tree_add_boolean_bits_format_value(tc1_tree,
hf_iso14443_nad_supported, tvb, 8*offset+7, 1, nad_supported,
- "%s", tfs_get_string(nad_supported, &tfs_supported_not_supported));
+ ENC_BIG_ENDIAN, "%s", tfs_get_string(nad_supported, &tfs_supported_not_supported));
offset++;
}
hist_len = tl - (offset - offset_tl);
@@ -798,7 +798,7 @@ dissect_iso14443_cmd_type_ats(tvbuff_t *tvb, packet_info *pinfo,
offset++;
fsdi = tvb_get_guint8(tvb, offset) >> 4;
proto_tree_add_uint_bits_format_value(tree, hf_iso14443_fsdi,
- tvb, offset*8, 4, fsdi, "%d", fsdi);
+ tvb, offset*8, 4, fsdi, ENC_BIG_ENDIAN, "%d", fsdi);
if (fsdi < LEN_CODE_MAX) {
pi = proto_tree_add_uint(tree, hf_iso14443_fsd,
tvb, offset, 1, code_to_len[fsdi]);
@@ -806,7 +806,7 @@ dissect_iso14443_cmd_type_ats(tvbuff_t *tvb, packet_info *pinfo,
}
cid = tvb_get_guint8(tvb, offset) & 0x0F;
proto_tree_add_uint_bits_format_value(tree, hf_iso14443_cid,
- tvb, offset*8+4, 4, cid, "%d", cid);
+ tvb, offset*8+4, 4, cid, ENC_BIG_ENDIAN, "%d", cid);
offset++;
if (!crc_dropped) {
proto_tree_add_checksum(tree, tvb, offset,
@@ -866,7 +866,7 @@ static int dissect_iso14443_attrib(tvbuff_t *tvb, gint offset,
max_frame_size_code = tvb_get_guint8(tvb, offset) & 0x0F;
proto_tree_add_uint_bits_format_value(p2_tree,
hf_iso14443_max_frame_size_code,
- tvb, offset*8+4, 4, max_frame_size_code, "%d",
+ tvb, offset*8+4, 4, max_frame_size_code, ENC_BIG_ENDIAN, "%d",
max_frame_size_code);
if (max_frame_size_code < LEN_CODE_MAX) {
pi = proto_tree_add_uint(p2_tree, hf_iso14443_max_frame_size,
@@ -889,7 +889,7 @@ static int dissect_iso14443_attrib(tvbuff_t *tvb, gint offset,
p4_tree = proto_item_add_subtree(p4_it, ett_iso14443_attr_p4);
cid = tvb_get_guint8(tvb, offset) & 0x0F;
proto_tree_add_uint_bits_format_value(p4_tree, hf_iso14443_cid,
- tvb, offset*8+4, 4, cid, "%d", cid);
+ tvb, offset*8+4, 4, cid, ENC_BIG_ENDIAN, "%d", cid);
offset++;
hl_inf_len = crc_dropped ?
@@ -934,10 +934,10 @@ dissect_iso14443_cmd_type_attrib(tvbuff_t *tvb, packet_info *pinfo,
mbli = tvb_get_guint8(tvb, offset) >> 4;
proto_tree_add_uint_bits_format_value(tree, hf_iso14443_mbli,
- tvb, offset*8, 4, mbli, "%d", mbli);
+ tvb, offset*8, 4, mbli, ENC_BIG_ENDIAN, "%d", mbli);
cid = tvb_get_guint8(tvb, offset) & 0x0F;
proto_tree_add_uint_bits_format_value(tree, hf_iso14443_cid,
- tvb, offset*8+4, 4, cid, "%d", cid);
+ tvb, offset*8+4, 4, cid, ENC_BIG_ENDIAN, "%d", cid);
offset++;
hl_resp_len = crc_dropped ?
diff --git a/epan/dissectors/packet-isup.c b/epan/dissectors/packet-isup.c
index 9e7205a383..af555543db 100644
--- a/epan/dissectors/packet-isup.c
+++ b/epan/dissectors/packet-isup.c
@@ -4045,7 +4045,7 @@ dissect_isup_range_and_status_parameter(tvbuff_t *parameter_tvb, packet_info *pi
range_tree = proto_tree_add_subtree(parameter_tree, parameter_tvb, offset, -1, ett_isup_range, NULL, "Status subfield");
if (range<9) {
proto_tree_add_uint_bits_format_value(range_tree, hf_isup_bitbucket, parameter_tvb, (offset*8)+(8-range), range,
- tvb_get_guint8(parameter_tvb, offset), "%u bit 1", range);
+ tvb_get_guint8(parameter_tvb, offset), ENC_BIG_ENDIAN, "%u bit 1", range);
}
} else {
expert_add_info(pinfo, parameter_item, &ei_isup_status_subfield_not_present);
diff --git a/epan/dissectors/packet-lpp.c b/epan/dissectors/packet-lpp.c
index 446b414ba5..88b722fca6 100644
--- a/epan/dissectors/packet-lpp.c
+++ b/epan/dissectors/packet-lpp.c
@@ -14583,10 +14583,10 @@ dissect_lpp_T_bdsSvHealth_r12(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *act
bits = tvb_get_bits16(bdsSvHealth_tvb, 0, 9,ENC_BIG_ENDIAN);
if (bits == 0x1ff) {
proto_tree_add_boolean_bits_format_value(subtree, hf_lpp_bdsSvHealth_r12_sat_clock, bdsSvHealth_tvb, 0, 1, 1,
- "Satellite is in failure or permanently shut off (1)");
+ ENC_BIG_ENDIAN, "Satellite is in failure or permanently shut off (1)");
} else if (bits == 0x100) {
proto_tree_add_boolean_bits_format_value(subtree, hf_lpp_bdsSvHealth_r12_sat_clock, bdsSvHealth_tvb, 0, 1, 1,
- "Satellite clock is unavailable (1)");
+ ENC_BIG_ENDIAN, "Satellite clock is unavailable (1)");
} else {
proto_tree_add_bits_item(subtree, hf_lpp_bdsSvHealth_r12_sat_clock, bdsSvHealth_tvb, 0, 1, ENC_BIG_ENDIAN);
proto_tree_add_bits_item(subtree, hf_lpp_bdsSvHealth_r12_b1i, bdsSvHealth_tvb, 1, 1, ENC_BIG_ENDIAN);
diff --git a/epan/dissectors/packet-per.c b/epan/dissectors/packet-per.c
index a284db088c..3a5e2cdbbd 100644
--- a/epan/dissectors/packet-per.c
+++ b/epan/dissectors/packet-per.c
@@ -1331,10 +1331,10 @@ DEBUG_ENTRY("dissect_per_constrained_integer");
val_start = (offset)>>3;
val_length = length;
- val = (guint32)tvb_get_bits64(tvb,offset,num_bits, ENC_BIG_ENDIAN);
+ val = (guint32)tvb_get_bits64(tvb,offset,num_bits,ENC_BIG_ENDIAN);
if (display_internal_per_fields){
- str = decode_bits_in_field((offset&0x07),num_bits,val);
+ str = decode_bits_in_field((offset&0x07),num_bits,val,ENC_BIG_ENDIAN);
proto_tree_add_uint(tree, hf_per_internal_min, tvb, val_start,val_length, min);
proto_tree_add_uint64(tree, hf_per_internal_range, tvb, val_start, val_length, range);
proto_tree_add_uint(tree, hf_per_internal_num_bits, tvb, val_start, val_length, num_bits);
@@ -2134,7 +2134,7 @@ static tvbuff_t *dissect_per_bit_string_display(tvbuff_t *tvb, guint32 offset, a
value = tvb_get_bits64(out_tvb, 0, length, ENC_BIG_ENDIAN);
}
proto_item_append_text(actx->created_item, ", %s decimal value %" G_GINT64_MODIFIER "u",
- decode_bits_in_field(0, length, value), value);
+ decode_bits_in_field(0, length, value, ENC_BIG_ENDIAN), value);
if (named_bits) {
const guint32 named_bits_bytelen = (num_named_bits + 7) / 8;
proto_tree *subtree = proto_item_add_subtree(actx->created_item, ett_per_named_bits);
diff --git a/epan/dissectors/packet-tcp.c b/epan/dissectors/packet-tcp.c
index 4e325a3e6e..f7ad491812 100644
--- a/epan/dissectors/packet-tcp.c
+++ b/epan/dissectors/packet-tcp.c
@@ -6752,7 +6752,7 @@ dissect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
tcph->th_hlen, TCPH_MIN_LEN);
if (tree) {
tf = proto_tree_add_uint_bits_format_value(tcp_tree, hf_tcp_hdr_len, tvb, (offset + 12) << 3, 4, tcph->th_hlen,
- "%u bytes (%u)", tcph->th_hlen, tcph->th_hlen >> 2);
+ ENC_BIG_ENDIAN, "%u bytes (%u)", tcph->th_hlen, tcph->th_hlen >> 2);
expert_add_info_format(pinfo, tf, &ei_tcp_bogus_header_length,
"Bogus TCP header length (%u, must be at least %u)", tcph->th_hlen, TCPH_MIN_LEN);
}
@@ -6851,7 +6851,7 @@ dissect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
if (tree) {
// This should be consistent with ip.hdr_len.
proto_tree_add_uint_bits_format_value(tcp_tree, hf_tcp_hdr_len, tvb, (offset + 12) << 3, 4, tcph->th_hlen,
- "%u bytes (%u)", tcph->th_hlen, tcph->th_hlen>>2);
+ ENC_BIG_ENDIAN, "%u bytes (%u)", tcph->th_hlen, tcph->th_hlen>>2);
tf = proto_tree_add_uint_format(tcp_tree, hf_tcp_flags, tvb, offset + 12, 2,
tcph->th_flags, "Flags: 0x%03x (%s)", tcph->th_flags, flags_str);
field_tree = proto_item_add_subtree(tf, ett_tcp_flags);
diff --git a/epan/dissectors/packet-usb-hid.c b/epan/dissectors/packet-usb-hid.c
index dea897b7f9..8fb9f9dcae 100644
--- a/epan/dissectors/packet-usb-hid.c
+++ b/epan/dissectors/packet-usb-hid.c
@@ -5016,41 +5016,15 @@ dissect_usb_hid_control_class_intf(tvbuff_t *tvb, packet_info *pinfo,
/* unpack a HID logical report field */
static int hid_unpack_logical(tvbuff_t *tvb, int bit_offset, guint32 size, gint32 min, gint32 *val)
{
- size_t bytes_length;
- guint8 *bytes = tvb_get_bits_array(NULL, tvb, bit_offset, size, &bytes_length);
-
- switch (size / 8)
- {
- case 0:
- case 1:
- *val = bytes[0];
- break;
-
- case 2:
- *val = pletoh16(bytes);
- break;
-
- case 3:
- *val = pletoh24(bytes);
- break;
+ if (size > 32)
+ return -1;
- case 4:
- *val = pletoh32(bytes);
- break;
-
- default:
- goto err;
- }
+ *val = tvb_get_bits32(tvb, bit_offset, size, ENC_LITTLE_ENDIAN);
if (min < 0)
*val = ws_sign_ext32(*val, size);
- wmem_free(NULL, bytes);
return 0;
-
-err:
- wmem_free(NULL, bytes);
- return -1;
}
static gint
@@ -5062,7 +5036,7 @@ dissect_usb_hid_int_dynamic_value_variable(tvbuff_t *tvb, proto_tree *tree, hid_
if (hid_unpack_logical(tvb, bit_offset, field->report_size, field->logical_min, &val))
return -1;
- proto_tree_add_int_bits_format_value(tree, hf, tvb, bit_offset, field->report_size, val, "%d", val);
+ proto_tree_add_int_bits_format_value(tree, hf, tvb, bit_offset, field->report_size, val, ENC_LITTLE_ENDIAN, "%d", val);
return 0;
}
@@ -5155,7 +5129,7 @@ dissect_usb_hid_keyboard_page(tvbuff_t *tvb, packet_info _U_ *pinfo,
DISSECTOR_ASSERT(USAGE_PAGE(usage) == KEYBOARD_KEYPAD_PAGE);
usage = USAGE_ID(usage);
- proto_tree_add_boolean_bits_format_value(tree, hf_usbhid_key, tvb, bit_offset, field->report_size, val,
+ proto_tree_add_boolean_bits_format_value(tree, hf_usbhid_key, tvb, bit_offset, field->report_size, val, ENC_LITTLE_ENDIAN,
"%s (0x%02x) = %s", val_to_str_ext(usage, &keycode_vals_ext, "Unknown"), usage, val ? "DOWN" : "UP");
return 0;
}
@@ -5174,7 +5148,7 @@ dissect_usb_hid_button_page(tvbuff_t *tvb, packet_info _U_ *pinfo,
if (hid_unpack_logical(tvb, bit_offset, field->report_size, field->logical_min, &val))
return -1;
- ti = proto_tree_add_boolean_bits_format_value(tree, hf_usbhid_button, tvb, bit_offset, field->report_size, val, "%u", usage);
+ ti = proto_tree_add_boolean_bits_format_value(tree, hf_usbhid_button, tvb, bit_offset, field->report_size, val, ENC_LITTLE_ENDIAN, "%u", usage);
if (usage == 0)
proto_item_append_text(ti, " (No button pressed)");
@@ -5197,7 +5171,7 @@ dissect_hid_variable(tvbuff_t* tvb, packet_info _U_* pinfo, proto_tree* tree, hi
/* vendor data (0xff00 - 0xffff) */
if ((USAGE_PAGE(usage) & 0xff00) == 0xff00) {
- proto_tree_add_bits_item(tree, hf_usbhid_vendor_data, tvb, bit_offset, field->report_size, ENC_NA);
+ proto_tree_add_bits_item(tree, hf_usbhid_vendor_data, tvb, bit_offset, field->report_size, ENC_LITTLE_ENDIAN);
return;
}
@@ -5222,7 +5196,7 @@ dissect_hid_variable(tvbuff_t* tvb, packet_info _U_* pinfo, proto_tree* tree, hi
if (ret) {
proto_tree_add_uint_bits_format_value(tree, hf_usb_hid_localitem_usage, tvb, bit_offset, field->report_size,
- usage, "%s", get_usage_page_item_string(pinfo->pool, USAGE_PAGE(usage), USAGE_ID(usage)));
+ usage, ENC_LITTLE_ENDIAN, "%s", get_usage_page_item_string(pinfo->pool, USAGE_PAGE(usage), USAGE_ID(usage)));
}
}
@@ -5248,7 +5222,7 @@ dissect_hid_field(tvbuff_t *tvb, packet_info _U_ *pinfo, proto_tree *tree, hid_f
proto_tree *array_tree;
array_ti = proto_tree_add_bits_item(tree, hf_usbhid_array, tvb, bit_offset,
- field->report_size * field->report_count, ENC_NA);
+ field->report_size * field->report_count, ENC_LITTLE_ENDIAN);
array_tree = proto_item_add_subtree(array_ti, ett_usb_hid_array);
for(unsigned int j = 0; j < field->report_count; j++) {
@@ -5261,11 +5235,11 @@ dissect_hid_field(tvbuff_t *tvb, packet_info _U_ *pinfo, proto_tree *tree, hid_f
}
if (in_range) {
proto_tree_add_boolean_bits_format_value(array_tree, hf_usbhid_array_usage, tvb, bit_offset, field->report_size,
- val, "%s (0x%04x, 0x%04x)", get_usage_page_item_string(pinfo->pool, USAGE_PAGE(val), USAGE_ID(val)),
+ val, ENC_LITTLE_ENDIAN, "%s (0x%04x, 0x%04x)", get_usage_page_item_string(pinfo->pool, USAGE_PAGE(val), USAGE_ID(val)),
USAGE_PAGE(val), USAGE_ID(val));
} else {
proto_tree_add_boolean_bits_format_value(array_tree, hf_usbhid_array_usage, tvb, bit_offset, field->report_size,
- val, "No controls asserted");
+ val, ENC_LITTLE_ENDIAN, "No controls asserted");
}
bit_offset += field->report_size;
}
@@ -5282,7 +5256,7 @@ dissect_hid_field(tvbuff_t *tvb, packet_info _U_ *pinfo, proto_tree *tree, hid_f
}
if (field->report_count > count) {
gint remaining_bits = (field->report_count - count) * field->report_size;
- proto_tree_add_bits_item(tree, hf_usbhid_padding, tvb, bit_offset, remaining_bits, ENC_NA);
+ proto_tree_add_bits_item(tree, hf_usbhid_padding, tvb, bit_offset, remaining_bits, ENC_LITTLE_ENDIAN);
bit_offset += remaining_bits;
}
}
@@ -5330,7 +5304,7 @@ dissect_usb_hid_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *
/* if the item has no usages, it is padding - HID spec 6.2.2.9 */
if (wmem_array_get_count(field->usages) == 0) {
- proto_tree_add_bits_item(hid_tree, hf_usbhid_padding, tvb, hid_bit_offset, data_size, ENC_NA);
+ proto_tree_add_bits_item(hid_tree, hf_usbhid_padding, tvb, hid_bit_offset, data_size, ENC_LITTLE_ENDIAN);
hid_bit_offset += data_size;
continue;
}
diff --git a/epan/dissectors/packet-wsmp.c b/epan/dissectors/packet-wsmp.c
index 60b7a25901..2046f8b414 100644
--- a/epan/dissectors/packet-wsmp.c
+++ b/epan/dissectors/packet-wsmp.c
@@ -162,7 +162,7 @@ dissect_wsmp_psid(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int o
proto_tree_add_bits_item(tree, hf_wsmp_var_len_det, tvb, offset << 3, psidLen, ENC_NA);
proto_tree_add_uint_bits_format_value(tree, hf_wsmp_psid, tvb, (offset << 3) + psidLen,
- (psidLen << 3) - psidLen,*psid,"%s(%u)", val64_to_str_const(*psid, ieee1609dot2_Psid_vals, "Unknown"), *psid);
+ (psidLen << 3) - psidLen,*psid,ENC_BIG_ENDIAN,"%s(%u)", val64_to_str_const(*psid, ieee1609dot2_Psid_vals, "Unknown"), *psid);
offset += psidLen;
return offset;
diff --git a/epan/proto.c b/epan/proto.c
index cf2cc6b5b7..104eef55ec 100644
--- a/epan/proto.c
+++ b/epan/proto.c
@@ -12272,7 +12272,7 @@ _proto_tree_add_bits_ret_val(proto_tree *tree, const int hfindex, tvbuff_t *tvb,
CHECK_FOR_NULL_TREE(tree);
TRY_TO_FAKE_THIS_ITEM(tree, hfindex, hf_field);
- bf_str = decode_bits_in_field(bit_offset, no_of_bits, value);
+ bf_str = decode_bits_in_field(bit_offset, no_of_bits, value, encoding);
switch (hf_field->type) {
case FT_BOOLEAN:
@@ -12323,7 +12323,7 @@ _proto_tree_add_bits_ret_val(proto_tree *tree, const int hfindex, tvbuff_t *tvb,
break;
case FT_BYTES:
- bytes = tvb_get_bits_array(PNODE_POOL(tree), tvb, bit_offset, no_of_bits, &bytes_length);
+ bytes = tvb_get_bits_array(PNODE_POOL(tree), tvb, bit_offset, no_of_bits, &bytes_length, encoding);
pi = proto_tree_add_bytes_with_length(tree, hfindex, tvb, offset, length, bytes, (gint) bytes_length);
proto_item_fill_label(PITEM_FINFO(pi), lbl_str);
proto_item_set_text(pi, "%s", lbl_str);
@@ -12541,7 +12541,8 @@ proto_tree_add_split_bits_crumb(proto_tree *tree, const int hfindex, tvbuff_t *t
tvb_get_bits(tvb,
bit_offset,
crumb_spec[crumb_index].crumb_bit_length,
- ENC_BIG_ENDIAN)),
+ ENC_BIG_ENDIAN),
+ ENC_BIG_ENDIAN),
crumb_index,
hfinfo->name);
}
@@ -12566,7 +12567,7 @@ static proto_item *
_proto_tree_add_bits_format_value(proto_tree *tree, const int hfindex,
tvbuff_t *tvb, const guint bit_offset,
const gint no_of_bits, void *value_ptr,
- gchar *value_str)
+ const guint encoding, gchar *value_str)
{
gint offset;
guint length;
@@ -12603,14 +12604,14 @@ _proto_tree_add_bits_format_value(proto_tree *tree, const int hfindex,
length++;
if (no_of_bits < 65) {
- value = tvb_get_bits64(tvb, bit_offset, no_of_bits, ENC_BIG_ENDIAN);
+ value = tvb_get_bits64(tvb, bit_offset, no_of_bits, encoding);
} else {
REPORT_DISSECTOR_BUG("field %s passed to proto_tree_add_bits_format_value() has a bit width of %u > 65",
hf_field->abbrev, no_of_bits);
return NULL;
}
- str = decode_bits_in_field(bit_offset, no_of_bits, value);
+ str = decode_bits_in_field(bit_offset, no_of_bits, value, encoding);
(void) g_strlcat(str, " = ", 256+64);
(void) g_strlcat(str, hf_field->name, 256+64);
@@ -12680,13 +12681,13 @@ static proto_item *
proto_tree_add_bits_format_value(proto_tree *tree, const int hfindex,
tvbuff_t *tvb, const guint bit_offset,
const gint no_of_bits, void *value_ptr,
- gchar *value_str)
+ const guint encoding, gchar *value_str)
{
proto_item *item;
if ((item = _proto_tree_add_bits_format_value(tree, hfindex,
tvb, bit_offset, no_of_bits,
- value_ptr, value_str))) {
+ value_ptr, encoding, value_str))) {
FI_SET_FLAG(PNODE_FINFO(item), FI_BITS_OFFSET(bit_offset));
FI_SET_FLAG(PNODE_FINFO(item), FI_BITS_SIZE(no_of_bits));
}
@@ -12702,6 +12703,7 @@ proto_item *
proto_tree_add_uint_bits_format_value(proto_tree *tree, const int hfindex,
tvbuff_t *tvb, const guint bit_offset,
const gint no_of_bits, guint32 value,
+ const guint encoding,
const char *format, ...)
{
va_list ap;
@@ -12728,13 +12730,14 @@ proto_tree_add_uint_bits_format_value(proto_tree *tree, const int hfindex,
CREATE_VALUE_STRING(tree, dst, format, ap);
- return proto_tree_add_bits_format_value(tree, hfindex, tvb, bit_offset, no_of_bits, &value, dst);
+ return proto_tree_add_bits_format_value(tree, hfindex, tvb, bit_offset, no_of_bits, &value, encoding, dst);
}
proto_item *
proto_tree_add_uint64_bits_format_value(proto_tree *tree, const int hfindex,
tvbuff_t *tvb, const guint bit_offset,
const gint no_of_bits, guint64 value,
+ const guint encoding,
const char *format, ...)
{
va_list ap;
@@ -12761,13 +12764,14 @@ proto_tree_add_uint64_bits_format_value(proto_tree *tree, const int hfindex,
CREATE_VALUE_STRING(tree, dst, format, ap);
- return proto_tree_add_bits_format_value(tree, hfindex, tvb, bit_offset, no_of_bits, &value, dst);
+ return proto_tree_add_bits_format_value(tree, hfindex, tvb, bit_offset, no_of_bits, &value, encoding, dst);
}
proto_item *
proto_tree_add_float_bits_format_value(proto_tree *tree, const int hfindex,
tvbuff_t *tvb, const guint bit_offset,
const gint no_of_bits, float value,
+ const guint encoding,
const char *format, ...)
{
va_list ap;
@@ -12782,13 +12786,14 @@ proto_tree_add_float_bits_format_value(proto_tree *tree, const int hfindex,
CREATE_VALUE_STRING(tree, dst, format, ap);
- return proto_tree_add_bits_format_value(tree, hfindex, tvb, bit_offset, no_of_bits, &value, dst);
+ return proto_tree_add_bits_format_value(tree, hfindex, tvb, bit_offset, no_of_bits, &value, encoding, dst);
}
proto_item *
proto_tree_add_int_bits_format_value(proto_tree *tree, const int hfindex,
tvbuff_t *tvb, const guint bit_offset,
const gint no_of_bits, gint32 value,
+ const guint encoding,
const char *format, ...)
{
va_list ap;
@@ -12815,13 +12820,14 @@ proto_tree_add_int_bits_format_value(proto_tree *tree, const int hfindex,
CREATE_VALUE_STRING(tree, dst, format, ap);
- return proto_tree_add_bits_format_value(tree, hfindex, tvb, bit_offset, no_of_bits, &value, dst);
+ return proto_tree_add_bits_format_value(tree, hfindex, tvb, bit_offset, no_of_bits, &value, encoding, dst);
}
proto_item *
proto_tree_add_int64_bits_format_value(proto_tree *tree, const int hfindex,
tvbuff_t *tvb, const guint bit_offset,
const gint no_of_bits, gint64 value,
+ const guint encoding,
const char *format, ...)
{
va_list ap;
@@ -12848,13 +12854,14 @@ proto_tree_add_int64_bits_format_value(proto_tree *tree, const int hfindex,
CREATE_VALUE_STRING(tree, dst, format, ap);
- return proto_tree_add_bits_format_value(tree, hfindex, tvb, bit_offset, no_of_bits, &value, dst);
+ return proto_tree_add_bits_format_value(tree, hfindex, tvb, bit_offset, no_of_bits, &value, encoding, dst);
}
proto_item *
proto_tree_add_boolean_bits_format_value(proto_tree *tree, const int hfindex,
tvbuff_t *tvb, const guint bit_offset,
const gint no_of_bits, guint32 value,
+ const guint encoding,
const char *format, ...)
{
va_list ap;
@@ -12869,13 +12876,14 @@ proto_tree_add_boolean_bits_format_value(proto_tree *tree, const int hfindex,
CREATE_VALUE_STRING(tree, dst, format, ap);
- return proto_tree_add_bits_format_value(tree, hfindex, tvb, bit_offset, no_of_bits, &value, dst);
+ return proto_tree_add_bits_format_value(tree, hfindex, tvb, bit_offset, no_of_bits, &value, encoding, dst);
}
proto_item *
proto_tree_add_boolean_bits_format_value64(proto_tree *tree, const int hfindex,
tvbuff_t *tvb, const guint bit_offset,
const gint no_of_bits, guint64 value,
+ const guint encoding,
const char *format, ...)
{
va_list ap;
@@ -12890,7 +12898,7 @@ proto_tree_add_boolean_bits_format_value64(proto_tree *tree, const int hfindex,
CREATE_VALUE_STRING(tree, dst, format, ap);
- return proto_tree_add_bits_format_value(tree, hfindex, tvb, bit_offset, no_of_bits, &value, dst);
+ return proto_tree_add_bits_format_value(tree, hfindex, tvb, bit_offset, no_of_bits, &value, encoding, dst);
}
proto_item *
diff --git a/epan/proto.h b/epan/proto.h
index 0fd8bfbe88..3c45270ddb 100644
--- a/epan/proto.h
+++ b/epan/proto.h
@@ -3112,12 +3112,14 @@ proto_tree_add_bits_ret_val(proto_tree *tree, const int hf_index, tvbuff_t *tvb,
@param bit_offset start of data in tvb expressed in bits
@param no_of_bits length of data in tvb expressed in bit
@param value data to display
+ @param encoding data encoding
@param format printf like format string
@return the newly created item */
WS_DLL_PUBLIC proto_item *
proto_tree_add_uint_bits_format_value(proto_tree *tree, const int hf_index, tvbuff_t *tvb,
- const guint bit_offset, const gint no_of_bits, guint32 value, const char *format, ...)
- G_GNUC_PRINTF(7,8);
+ const guint bit_offset, const gint no_of_bits, guint32 value, const guint encoding,
+ const char *format, ...)
+ G_GNUC_PRINTF(8,9);
/** Add bits for a FT_UINT8, FT_UINT16, FT_UINT24 or FT_UINT32
header field to a proto_tree, with the format generating the
@@ -3128,12 +3130,14 @@ proto_tree_add_uint_bits_format_value(proto_tree *tree, const int hf_index, tvbu
@param bit_offset start of data in tvb expressed in bits
@param no_of_bits length of data in tvb expressed in bit
@param value data to display
+ @param encoding data encoding
@param format printf like format string
@return the newly created item */
WS_DLL_PUBLIC proto_item *
proto_tree_add_uint64_bits_format_value(proto_tree *tree, const int hf_index, tvbuff_t *tvb,
- const guint bit_offset, const gint no_of_bits, guint64 value, const char *format, ...)
- G_GNUC_PRINTF(7,8);
+ const guint bit_offset, const gint no_of_bits, guint64 value, const guint encoding,
+ const char *format, ...)
+ G_GNUC_PRINTF(8,9);
/** Add bits for a FT_BOOLEAN header field to a proto_tree, with
the format generating the string for the value and with the field
@@ -3144,13 +3148,15 @@ proto_tree_add_uint64_bits_format_value(proto_tree *tree, const int hf_index, tv
@param bit_offset start of data in tvb expressed in bits
@param no_of_bits length of data in tvb expressed in bit
@param value data to display
+ @param encoding data encoding
@param format printf like format string
@param ... printf like parameters
@return the newly created item */
proto_item *
proto_tree_add_boolean_bits_format_value(proto_tree *tree, const int hf_index, tvbuff_t *tvb,
- const guint bit_offset, const gint no_of_bits, guint32 value, const char *format, ...)
- G_GNUC_PRINTF(7,8);
+ const guint bit_offset, const gint no_of_bits, guint32 value, const guint encoding,
+ const char *format, ...)
+ G_GNUC_PRINTF(8,9);
/** Add bits for a FT_BOOLEAN header field to a proto_tree, with
the format generating the string for the value and with the field
@@ -3161,13 +3167,15 @@ proto_tree_add_boolean_bits_format_value(proto_tree *tree, const int hf_index, t
@param bit_offset start of data in tvb expressed in bits
@param no_of_bits length of data in tvb expressed in bit
@param value data to display
+ @param encoding data encoding
@param format printf like format string
@param ... printf like parameters
@return the newly created item */
proto_item *
proto_tree_add_boolean_bits_format_value64(proto_tree *tree, const int hf_index, tvbuff_t *tvb,
- const guint bit_offset, const gint no_of_bits, guint64 value, const char *format, ...)
- G_GNUC_PRINTF(7,8);
+ const guint bit_offset, const gint no_of_bits, guint64 value, const guint encoding,
+ const char *format, ...)
+ G_GNUC_PRINTF(8,9);
/** Add bits for a FT_INT8, FT_INT16, FT_INT24 or FT_INT32
header field to a proto_tree, with the format generating the
@@ -3178,13 +3186,15 @@ proto_tree_add_boolean_bits_format_value64(proto_tree *tree, const int hf_index,
@param bit_offset start of data in tvb expressed in bits
@param no_of_bits length of data in tvb expressed in bit
@param value data to display
+ @param encoding data encoding
@param format printf like format string
@param ... printf like parameters
@return the newly created item */
proto_item *
proto_tree_add_int_bits_format_value(proto_tree *tree, const int hf_index, tvbuff_t *tvb,
- const guint bit_offset, const gint no_of_bits, gint32 value, const char *format, ...)
- G_GNUC_PRINTF(7,8);
+ const guint bit_offset, const gint no_of_bits, gint32 value, const guint encoding,
+ const char *format, ...)
+ G_GNUC_PRINTF(8,9);
/** Add bits for a FT_INT8, FT_INT16, FT_INT24 or FT_INT32
header field to a proto_tree, with the format generating the
@@ -3195,13 +3205,15 @@ proto_tree_add_int_bits_format_value(proto_tree *tree, const int hf_index, tvbuf
@param bit_offset start of data in tvb expressed in bits
@param no_of_bits length of data in tvb expressed in bit
@param value data to display
+ @param encoding data encoding
@param format printf like format string
@param ... printf like parameters
@return the newly created item */
proto_item *
proto_tree_add_int64_bits_format_value(proto_tree *tree, const int hf_index, tvbuff_t *tvb,
- const guint bit_offset, const gint no_of_bits, gint64 value, const char *format, ...)
- G_GNUC_PRINTF(7,8);
+ const guint bit_offset, const gint no_of_bits, gint64 value, const guint encoding,
+ const char *format, ...)
+ G_GNUC_PRINTF(8,9);
/** Add bits for a FT_FLOAT header field to a proto_tree, with
the format generating the string for the value and with the field
@@ -3212,13 +3224,15 @@ proto_tree_add_int64_bits_format_value(proto_tree *tree, const int hf_index, tvb
@param bit_offset start of data in tvb expressed in bits
@param no_of_bits length of data in tvb expressed in bit
@param value data to display
+ @param encoding data encoding
@param format printf like format string
@param ... printf like parameters
@return the newly created item */
proto_item *
proto_tree_add_float_bits_format_value(proto_tree *tree, const int hf_index, tvbuff_t *tvb,
- const guint bit_offset, const gint no_of_bits, float value, const char *format, ...)
- G_GNUC_PRINTF(7,8);
+ const guint bit_offset, const gint no_of_bits, float value, const guint encoding,
+ const char *format, ...)
+ G_GNUC_PRINTF(8,9);
/** Add a FT_STRING with ENC_3GPP_TS_23_038_7BITS_PACKED encoding to a
diff --git a/epan/to_str.c b/epan/to_str.c
index 2d48df96ad..8f260cc392 100644
--- a/epan/to_str.c
+++ b/epan/to_str.c
@@ -645,19 +645,30 @@ rel_time_to_secs_str(wmem_allocator_t *scope, const nstime_t *rel_time)
*/
char *
-decode_bits_in_field(const guint bit_offset, const gint no_of_bits, const guint64 value)
+decode_bits_in_field(const guint bit_offset, const gint no_of_bits, const guint64 value, const guint encoding)
{
guint64 mask;
char *str;
int bit, str_p = 0;
int i;
int max_bits = MIN(64, no_of_bits);
+ int no_leading_dots;
mask = G_GUINT64_CONSTANT(1) << (max_bits-1);
+ if(encoding & ENC_LITTLE_ENDIAN){
+ /* Bits within octet are numbered from LSB (0) to MSB (7).
+ * The value in string is from most significant bit to lowest.
+ * Calculate how many dots have to be printed at the beginning of string.
+ */
+ no_leading_dots = (8 - ((bit_offset + no_of_bits) % 8)) % 8;
+ } else {
+ no_leading_dots = bit_offset % 8;
+ }
+
/* Prepare the string, 256 pos for the bits and zero termination, + 64 for the spaces */
str=(char *)wmem_alloc0(wmem_packet_scope(), 256+64);
- for(bit=0;bit<((int)(bit_offset&0x07));bit++){
+ for(bit=0;bit<no_leading_dots;bit++){
if(bit&&(!(bit%4))){
str[str_p] = ' ';
str_p++;
diff --git a/epan/to_str.h b/epan/to_str.h
index 40a7ccab99..bb1de6b23f 100644
--- a/epan/to_str.h
+++ b/epan/to_str.h
@@ -149,7 +149,7 @@ WS_DLL_PUBLIC gchar *guid_to_str_buf(const e_guid_t *, gchar *, int);
WS_DLL_PUBLIC gchar *guid_to_str(wmem_allocator_t *scope, const e_guid_t *);
-WS_DLL_PUBLIC char *decode_bits_in_field(const guint bit_offset, const gint no_of_bits, const guint64 value);
+WS_DLL_PUBLIC char *decode_bits_in_field(const guint bit_offset, const gint no_of_bits, const guint64 value, const guint encoding);
#ifdef __cplusplus
}
diff --git a/epan/tvbuff.c b/epan/tvbuff.c
index c44bca3338..24fbd167c9 100644
--- a/epan/tvbuff.c
+++ b/epan/tvbuff.c
@@ -56,6 +56,9 @@
static guint64
_tvb_get_bits64(tvbuff_t *tvb, guint bit_offset, const gint total_no_of_bits);
+static guint64
+_tvb_get_bits64_le(tvbuff_t *tvb, guint bit_offset, const gint total_no_of_bits);
+
static inline gint
_tvb_captured_length_remaining(const tvbuff_t *tvb, const gint offset);
@@ -434,6 +437,72 @@ tvb_new_octet_aligned(tvbuff_t *tvb, guint32 bit_offset, gint32 no_of_bits)
return sub_tvb;
}
+tvbuff_t *
+tvb_new_octet_right_aligned(tvbuff_t *tvb, guint32 bit_offset, gint32 no_of_bits)
+{
+ tvbuff_t *sub_tvb = NULL;
+ guint32 byte_offset;
+ gint src_len, dst_len, i;
+ guint8 left, right, remaining_bits, *buf;
+ const guint8 *data;
+
+ DISSECTOR_ASSERT(tvb && tvb->initialized);
+
+ byte_offset = bit_offset / 8;
+ /* right shift to put bits in place and discard least significant bits */
+ right = bit_offset % 8;
+ /* left shift to get most significant bits from next octet */
+ left = 8 - right;
+
+ if (no_of_bits == -1) {
+ dst_len = _tvb_captured_length_remaining(tvb, byte_offset);
+ remaining_bits = 0;
+ } else {
+ dst_len = no_of_bits / 8;
+ remaining_bits = no_of_bits % 8;
+ if (remaining_bits) {
+ dst_len++;
+ }
+ }
+
+ /* already aligned -> shortcut */
+ if ((right == 0) && (remaining_bits == 0)) {
+ return tvb_new_subset_length_caplen(tvb, byte_offset, dst_len, dst_len);
+ }
+
+ DISSECTOR_ASSERT(dst_len>0);
+
+ if (_tvb_captured_length_remaining(tvb, byte_offset) > dst_len) {
+ /* last octet will get data from trailing octet */
+ src_len = dst_len + 1;
+ } else {
+ /* last octet will be zero padded */
+ src_len = dst_len;
+ }
+
+ data = ensure_contiguous(tvb, byte_offset, src_len); /* tvb_get_ptr */
+
+ /* Do this allocation AFTER tvb_get_ptr() (which could throw an exception) */
+ buf = (guint8 *)g_malloc(dst_len);
+
+ for (i = 0; i < (dst_len - 1); i++)
+ buf[i] = (data[i] >> right) | (data[i+1] << left);
+
+ /* Special handling for last octet */
+ buf[i] = (data[i] >> right);
+ /* Shift most significant bits from trailing octet if available */
+ if (src_len > dst_len)
+ buf[i] |= (data[i+1] << left);
+ /* Preserve only remaining bits in last octet if not multiple of 8 */
+ if (remaining_bits)
+ buf[i] &= ((1 << remaining_bits) - 1);
+
+ sub_tvb = tvb_new_child_real_data(tvb, buf, dst_len, dst_len);
+ tvb_set_free_cb(sub_tvb, g_free);
+
+ return sub_tvb;
+}
+
static tvbuff_t *
tvb_generic_clone_offset_len(tvbuff_t *tvb, guint offset, guint len)
{
@@ -2007,12 +2076,20 @@ static const guint8 bit_mask8[] = {
/* Get a variable ammount of bits
*
- * Return a byte array with bit limited data. The data is aligned to the right.
+ * Return a byte array with bit limited data.
+ * When encoding is ENC_BIG_ENDIAN, the data is aligned to the left.
+ * When encoding is ENC_LITTLE_ENDIAN, 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)
+tvb_get_bits_array(wmem_allocator_t *scope, tvbuff_t *tvb, const gint bit_offset,
+ size_t no_of_bits, size_t *data_length, const guint encoding)
{
- tvbuff_t *sub_tvb = tvb_new_octet_aligned(tvb, bit_offset, (gint32) no_of_bits);
+ tvbuff_t *sub_tvb;
+ if (encoding & ENC_LITTLE_ENDIAN) {
+ sub_tvb = tvb_new_octet_right_aligned(tvb, bit_offset, (gint32) no_of_bits);
+ } else {
+ 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);
}
@@ -2024,33 +2101,37 @@ tvb_get_bits8(tvbuff_t *tvb, guint bit_offset, const gint no_of_bits)
return (guint8)_tvb_get_bits64(tvb, bit_offset, no_of_bits);
}
-/* Get 9 - 16 bits */
+/* Get 1 - 16 bits */
guint16
-tvb_get_bits16(tvbuff_t *tvb, guint bit_offset, const gint no_of_bits,const guint encoding _U_)
+tvb_get_bits16(tvbuff_t *tvb, guint bit_offset, const gint no_of_bits, const guint encoding)
{
- /* note that encoding has no meaning here, as the tvb is considered to contain an octet array */
- return (guint16)_tvb_get_bits64(tvb, bit_offset, no_of_bits);
+ return (guint16)tvb_get_bits64(tvb, bit_offset, no_of_bits, encoding);
}
/* Get 1 - 32 bits */
guint32
-tvb_get_bits32(tvbuff_t *tvb, guint bit_offset, const gint no_of_bits, const guint encoding _U_)
+tvb_get_bits32(tvbuff_t *tvb, guint bit_offset, const gint no_of_bits, const guint encoding)
{
- /* note that encoding has no meaning here, as the tvb is considered to contain an octet array */
- return (guint32)_tvb_get_bits64(tvb, bit_offset, no_of_bits);
+ return (guint32)tvb_get_bits64(tvb, bit_offset, no_of_bits, encoding);
}
/* Get 1 - 64 bits */
guint64
-tvb_get_bits64(tvbuff_t *tvb, guint bit_offset, const gint no_of_bits, const guint encoding _U_)
+tvb_get_bits64(tvbuff_t *tvb, guint bit_offset, const gint no_of_bits, const guint encoding)
{
- /* note that encoding has no meaning here, as the tvb is considered to contain an octet array */
- return _tvb_get_bits64(tvb, bit_offset, no_of_bits);
+ /* encoding determines bit numbering within octet array */
+ if (encoding & ENC_LITTLE_ENDIAN) {
+ return _tvb_get_bits64_le(tvb, bit_offset, no_of_bits);
+ } else {
+ return _tvb_get_bits64(tvb, bit_offset, no_of_bits);
+ }
}
+
/*
* This function will dissect a sequence of bits that does not need to be byte aligned; the bits
* set will be shown in the tree as ..10 10.. and the integer value returned if return_value is set.
* Offset should be given in bits from the start of the tvb.
+ * Bits within octet are numbered from MSB (0) to LSB (7). Bit at bit_offset is return value most significant bit.
* The function tolerates requests for more than 64 bits, but will only return the least significant 64 bits.
*/
static guint64
@@ -2126,12 +2207,84 @@ _tvb_get_bits64(tvbuff_t *tvb, guint bit_offset, const gint total_no_of_bits)
}
return value;
}
+
+/*
+ * Offset should be given in bits from the start of the tvb.
+ * Bits within octet are numbered from LSB (0) to MSB (7). Bit at bit_offset is return value least significant bit.
+ * The function tolerates requests for more than 64 bits, but will only return the least significant 64 bits.
+ */
+static guint64
+_tvb_get_bits64_le(tvbuff_t *tvb, guint bit_offset, const gint total_no_of_bits)
+{
+ guint64 value = 0;
+ guint octet_offset = bit_offset / 8;
+ gint remaining_bits = total_no_of_bits;
+ gint shift = 0;
+
+ if (remaining_bits > 64)
+ {
+ remaining_bits = 64;
+ }
+
+ if (bit_offset % 8)
+ {
+ /* not aligned, extract bits from first octet */
+ shift = 8 - (bit_offset % 8);
+ value = tvb_get_guint8(tvb, octet_offset) >> (bit_offset % 8);
+ if (shift > total_no_of_bits)
+ {
+ /* keep only the requested bits */
+ value &= (G_GUINT64_CONSTANT(1) << total_no_of_bits) - 1;
+ remaining_bits = 0;
+ }
+ else
+ {
+ remaining_bits = total_no_of_bits - shift;
+ }
+ octet_offset++;
+ }
+
+ while (remaining_bits > 0)
+ {
+ /* take the biggest words, shorts or octets that we can */
+ if (remaining_bits >= 32)
+ {
+ value |= ((guint64)tvb_get_letohl(tvb, octet_offset) << shift);
+ shift += 32;
+ remaining_bits -= 32;
+ octet_offset += 4;
+ }
+ else if (remaining_bits >= 16)
+ {
+ value |= ((guint64)tvb_get_letohs(tvb, octet_offset) << shift);
+ shift += 16;
+ remaining_bits -= 16;
+ octet_offset += 2;
+ }
+ else if (remaining_bits >= 8)
+ {
+ value |= ((guint64)tvb_get_guint8(tvb, octet_offset) << shift);
+ shift += 8;
+ remaining_bits -= 8;
+ octet_offset += 1;
+ }
+ else
+ {
+ guint mask = (1 << remaining_bits) - 1;
+ value |= (((guint64)tvb_get_guint8(tvb, octet_offset) & mask) << shift);
+ shift += remaining_bits;
+ remaining_bits = 0;
+ octet_offset += 1;
+ }
+ }
+ return value;
+}
+
/* Get 1 - 32 bits (should be deprecated as same as tvb_get_bits32??) */
guint32
-tvb_get_bits(tvbuff_t *tvb, const guint bit_offset, const gint no_of_bits, const guint encoding _U_)
+tvb_get_bits(tvbuff_t *tvb, const guint bit_offset, const gint no_of_bits, const guint encoding)
{
- /* note that encoding has no meaning here, as the tvb is considered to contain an octet array */
- return (guint32)_tvb_get_bits64(tvb, bit_offset, no_of_bits);
+ return (guint32)tvb_get_bits64(tvb, bit_offset, no_of_bits, encoding);
}
static gint
diff --git a/epan/tvbuff.h b/epan/tvbuff.h
index 63b17e022d..2264a6b25b 100644
--- a/epan/tvbuff.h
+++ b/epan/tvbuff.h
@@ -104,10 +104,17 @@ typedef void (*tvbuff_free_cb_t)(void*);
/** Extracts 'number of bits' starting at 'bit offset'.
* Returns a pointer to a newly initialized g_malloc'd REAL_DATA
* tvbuff with the bits octet aligned.
+ * Bits are counted from MSB (0) to LSB (7) within octets.
*/
WS_DLL_PUBLIC tvbuff_t *tvb_new_octet_aligned(tvbuff_t *tvb,
guint32 bit_offset, gint32 no_of_bits);
+/** Extracts 'number of bits' starting at 'bit offset'.
+ * Bits are counted from LSB (0) to MSB (7) within octets.
+ */
+WS_DLL_PUBLIC tvbuff_t *tvb_new_octet_right_aligned(tvbuff_t *tvb,
+ guint32 bit_offset, gint32 no_of_bits);
+
WS_DLL_PUBLIC tvbuff_t *tvb_new_chain(tvbuff_t *parent, tvbuff_t *backing);
WS_DLL_PUBLIC tvbuff_t *tvb_clone(tvbuff_t *tvb);
@@ -414,7 +421,7 @@ WS_DLL_PUBLIC void tvb_get_guid(tvbuff_t *tvb, const gint offset,
/* 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);
+ const gint offset, size_t length, size_t *data_length, const guint encoding);
/* 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
diff --git a/tools/checkAPIs.pl b/tools/checkAPIs.pl
index 68c9caf82e..7679dbdc95 100755
--- a/tools/checkAPIs.pl
+++ b/tools/checkAPIs.pl
@@ -608,7 +608,7 @@ sub check_proto_tree_add_XXX($$)
#Check for accidental usage of ENC_ parameter
if ($args =~ /,\s*ENC_/xos) {
- if (!($func =~ /proto_tree_add_(time|item|bitmask|bits_item|bits_ret_val|item_ret_int|item_ret_uint|bytes_item|checksum)/xos)
+ if (!($func =~ /proto_tree_add_(time|item|bitmask|[a-z0-9]+_bits_format_value|bits_item|bits_ret_val|item_ret_int|item_ret_uint|bytes_item|checksum)/xos)
) {
print STDERR "Error: ".$filename." uses $func with ENC_*.\n";
$errorCount++;