csn1: fix M_UINT_OFFSET: show value after applying the offset
Some integer fields in CSN.1 structures can be encoded with an offset. A good example is GPRS Mobile Allocation IE defined in 3GPP TS 44.060, section 12.10a, table 12.10a.1: < GPRS Mobile Allocation IE > ::= < HSN : bit (6) > { 0 | 1 < RFL number list : < RFL number list struct > > } { 0 < MA_LENGTH : bit (6) > < MA_BITMAP : bit (val(MA_LENGTH) + 1) > | 1 { 0 | 1 < ARFCN index list : < ARFCN index list struct > > } } ; so in this case the variable-length MA_BITMAP is defined as follows: < MA_BITMAP : bit (val(MA_LENGTH) + 1) > what basically means that its bit length shall be encoded with a negative offset 1, therefore the following statements apply: MA_LENGTH=0 defines MA_BITMAP of bit length 1 MA_LENGTH=1 defines MA_BITMAP of bit length 2 ... MA_LENGTH=63 defines MA_BITMAP of bit length 64 == What's wrong? == For some reason, Wireshark shows the raw values without applying the offset. Here is an example of GPRS Mobile Allocation IE: GPRS_Mobile_Allocation .... .101 010. .... = HSN: 42 ...0 .... = RFL_NUMBER Exist: 0 .... 0... = Mobile Allocation: (Union) u.MA .... .001 111. .... = Bit length: 15 ...0 .... = Bitmap: 0 // 1st .... 1... = Bitmap: 1 .... .0.. = Bitmap: 0 .... ..1. = Bitmap: 1 .... ...0 = Bitmap: 0 1... .... = Bitmap: 1 .0.. .... = Bitmap: 0 ..1. .... = Bitmap: 1 // 8th ...0 .... = Bitmap: 0 .... 1... = Bitmap: 1 .... .0.. = Bitmap: 0 .... ..1. = Bitmap: 1 .... ...0 = Bitmap: 0 1... .... = Bitmap: 1 .0.. .... = Bitmap: 0 ..1. .... = Bitmap: 1 // 16th == Solution == Let's use proto_tree_add_uint_bits_format_value(), so we can print the final value with the offset applied, as well as the original one and the offset itself: GPRS_Mobile_Allocation .... .101 010. .... = HSN: 42 ...0 .... = RFL_NUMBER Exist: 0 .... 0... = Mobile Allocation: (Union) u.MA .... .001 111. .... = Bit length: 16 (Raw 15 + Offset 1) Change-Id: Ic4eaf2d8a3c2fedca855726e4175ddf47d16c5af Reviewed-on: https://code.wireshark.org/review/37931 Petri-Dish: Anders Broman <a.broman58@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
parent
26c4120204
commit
2046666b97
|
@ -278,7 +278,9 @@ csnStreamDissector(proto_tree *tree, csnStream_t* ar, const CSN_DESCR* pDescr, t
|
|||
pui8 = pui8DATA(data, pDescr->offset);
|
||||
*pui8 = ui8 + (guint8)pDescr->descr.value;
|
||||
|
||||
proto_tree_add_bits_item(tree, *(pDescr->hf_ptr), 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,
|
||||
*pui8, "%u (Raw %u + Offset %u)", *pui8, ui8,
|
||||
(guint8) pDescr->descr.value);
|
||||
}
|
||||
else if (no_of_bits <= 16)
|
||||
{
|
||||
|
@ -286,7 +288,9 @@ csnStreamDissector(proto_tree *tree, csnStream_t* ar, const CSN_DESCR* pDescr, t
|
|||
pui16 = pui16DATA(data, pDescr->offset);
|
||||
*pui16 = ui16 + (guint16)pDescr->descr.value;
|
||||
|
||||
proto_tree_add_bits_item(tree, *(pDescr->hf_ptr), 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, "%u (Raw %u + Offset %u)", *pui16, ui16,
|
||||
(guint16) pDescr->descr.value);
|
||||
}
|
||||
else if (no_of_bits <= 32)
|
||||
{
|
||||
|
@ -294,7 +298,9 @@ csnStreamDissector(proto_tree *tree, csnStream_t* ar, const CSN_DESCR* pDescr, t
|
|||
pui32 = pui32DATA(data, pDescr->offset);
|
||||
*pui32 = ui32 + (guint16)pDescr->descr.value;
|
||||
|
||||
proto_tree_add_bits_item(tree, *(pDescr->hf_ptr), 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,
|
||||
*pui32, "%u (Raw %u + Offset %u)", *pui32, ui32,
|
||||
(guint16) pDescr->descr.value);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue