diff --git a/epan/dissectors/packet-oran.c b/epan/dissectors/packet-oran.c index f29c06bba1..df3fa43388 100755 --- a/epan/dissectors/packet-oran.c +++ b/epan/dissectors/packet-oran.c @@ -487,7 +487,8 @@ addSeqid(tvbuff_t *tvb, proto_tree *oran_tree, gint *offset) proto_item_append_text(seqIdItem, ", SeqId: %d, SubSeqId: %d, E: %d", seqId, subSeqId, e); } -static float scale_to_float(guint32 h) +/* Special case for uncompressed/16-bit value */ +static float uncompressed_to_float(guint32 h) { gint16 i16 = h & 0x0000ffff; return ((float)i16) / 0x7fff; @@ -506,26 +507,28 @@ static int dissect_bfwCompHdr(tvbuff_t *tvb, proto_tree *tree, gint offset, /* Fields present (if any) depend upon passed-in bfwCompMeth */ static int dissect_bfwCompParam(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, gint offset, - proto_item *ti, guint32 bfwcomphdr_comp_method, gboolean *supported) + proto_item *ti, guint32 bfwcomphdr_comp_method, + guint32 *exponent, gboolean *supported) { *supported = FALSE; switch (bfwcomphdr_comp_method) { - case 0: /* no compression */ + case COMP_NONE: /* In this case, bfwCompParam is absent */ *supported = TRUE; break; - case 1: /* block fl. point */ + case COMP_BLOCK_FP: /* 4 reserved bits + exponent */ - proto_tree_add_item(tree, hf_oran_exponent, - tvb, offset, 1, ENC_BIG_ENDIAN); + proto_tree_add_item_ret_uint(tree, hf_oran_exponent, + tvb, offset, 1, ENC_BIG_ENDIAN, exponent); + *supported = TRUE; offset++; break; - case 2: /* block scaling */ + case COMP_BLOCK_SCALE: proto_tree_add_item(tree, hf_oran_blockScaler, tvb, offset, 1, ENC_BIG_ENDIAN); offset++; break; - case 3: /* u-law */ + case COMP_U_LAW: /* compBitWidth, compShift */ proto_tree_add_item(tree, hf_oran_compBitWidth, tvb, offset, 1, ENC_BIG_ENDIAN); @@ -533,7 +536,7 @@ static int dissect_bfwCompParam(tvbuff_t *tvb, proto_tree *tree, packet_info *pi tvb, offset, 1, ENC_BIG_ENDIAN); offset++; break; - case 4: /* beamspace */ + case COMP_MODULATION: /* beamspace */ /* TODO: activeBeamspaceCoefficientMask - ceil(K/8) octets */ /* proto_tree_add_item(extension_tree, hf_oran_blockScaler, tvb, offset, 1, ENC_BIG_ENDIAN); @@ -554,6 +557,38 @@ static int dissect_bfwCompParam(tvbuff_t *tvb, proto_tree *tree, packet_info *pi return offset; } + +static gfloat decompress_value(guint32 bits, guint32 comp_method, guint8 iq_width _U_, guint32 exponent) +{ + switch (comp_method) { + case COMP_NONE: /* no compression */ + return uncompressed_to_float(bits); + + case COMP_BLOCK_FP: /* block floating point */ + { + /* A.1.2 Block Floating Point Decompression Algorithm */ + gint32 cPRB = bits; + guint32 scaler = 2 << (exponent-1); /* i.e. 2^exponent */ + + /* Check last bit, in case we need to flip to -ve */ + if (cPRB >= (1<<(iq_width-1))) { + cPRB -= (1<