aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBhargava Abhyankar <Bhargava.Abhyankar@radisys.com>2016-03-22 18:42:30 +0530
committerHarald Welte <laforge@gnumonks.org>2016-03-30 22:01:52 +0200
commite44383baa4a883beb49a4b0ec370ba3256389b94 (patch)
tree878da639284c5e412d34e89d4a903151be8cf2cd
parent5a5d2b7a27e64deef8b7b48842204414c611942b (diff)
Refactor the Uplink RLC header parsing function
Parsing the uplink data header for GPRS and EGPRS header type 3 is handled in separate functions. This patch will enhance modularity of the code.
-rw-r--r--src/decoding.cpp140
-rw-r--r--src/decoding.h9
2 files changed, 84 insertions, 65 deletions
diff --git a/src/decoding.cpp b/src/decoding.cpp
index f2b548c..0c81b2a 100644
--- a/src/decoding.cpp
+++ b/src/decoding.cpp
@@ -344,74 +344,14 @@ void Decoding::extract_rbb(const struct bitvec *rbb, char *show_rbb)
int Decoding::rlc_parse_ul_data_header(struct gprs_rlc_data_info *rlc,
const uint8_t *data, GprsCodingScheme cs)
{
- const struct gprs_rlc_ul_header_egprs_3 *egprs3;
- const struct rlc_ul_header *gprs;
- unsigned int e_ti_header;
unsigned int cur_bit = 0;
- int punct, punct2, with_padding, cps;
- unsigned int offs;
-
switch(cs.headerTypeData()) {
- case GprsCodingScheme::HEADER_GPRS_DATA:
- gprs = static_cast<struct rlc_ul_header *>
- ((void *)data);
-
- gprs_rlc_data_info_init_ul(rlc, cs, false);
-
- rlc->r = gprs->r;
- rlc->si = gprs->si;
- rlc->tfi = gprs->tfi;
- rlc->cps = 0;
- rlc->rsb = 0;
-
- rlc->num_data_blocks = 1;
- rlc->block_info[0].cv = gprs->cv;
- rlc->block_info[0].pi = gprs->pi;
- rlc->block_info[0].bsn = gprs->bsn;
- rlc->block_info[0].e = gprs->e;
- rlc->block_info[0].ti = gprs->ti;
- rlc->block_info[0].spb = 0;
-
- cur_bit += rlc->data_offs_bits[0];
-
- /* skip data area */
- cur_bit += cs.maxDataBlockBytes() * 8;
+ case GprsCodingScheme::HEADER_GPRS_DATA :
+ cur_bit = rlc_parse_ul_data_header_gprs(rlc, data, cs);
break;
- case GprsCodingScheme::HEADER_EGPRS_DATA_TYPE_3:
- egprs3 = static_cast<struct gprs_rlc_ul_header_egprs_3 *>
- ((void *)data);
-
- cps = (egprs3->cps_a << 0) | (egprs3->cps_b << 2);
- gprs_rlc_mcs_cps_decode(cps, cs, &punct, &punct2, &with_padding);
- gprs_rlc_data_info_init_ul(rlc, cs, with_padding);
-
- rlc->r = egprs3->r;
- rlc->si = egprs3->si;
- rlc->tfi = (egprs3->tfi_a << 0) | (egprs3->tfi_b << 2);
- rlc->cps = cps;
- rlc->rsb = egprs3->rsb;
-
- rlc->num_data_blocks = 1;
- rlc->block_info[0].cv = egprs3->cv;
- rlc->block_info[0].pi = egprs3->pi;
- rlc->block_info[0].spb = egprs3->spb;
- rlc->block_info[0].bsn =
- (egprs3->bsn1_a << 0) | (egprs3->bsn1_b << 5);
-
- cur_bit += rlc->data_offs_bits[0] - 2;
-
- offs = rlc->data_offs_bits[0] / 8;
- OSMO_ASSERT(rlc->data_offs_bits[0] % 8 == 1);
-
- e_ti_header = (data[offs-1] + (data[offs] << 8)) >> 7;
- rlc->block_info[0].e = !!(e_ti_header & 0x01);
- rlc->block_info[0].ti = !!(e_ti_header & 0x02);
- cur_bit += 2;
-
- /* skip data area */
- cur_bit += cs.maxDataBlockBytes() * 8;
+ case GprsCodingScheme::HEADER_EGPRS_DATA_TYPE_3 :
+ cur_bit = rlc_parse_ul_data_header_egprs_type_3(rlc, data, cs);
break;
-
case GprsCodingScheme::HEADER_EGPRS_DATA_TYPE_1:
case GprsCodingScheme::HEADER_EGPRS_DATA_TYPE_2:
/* TODO: Support both header types */
@@ -426,6 +366,78 @@ int Decoding::rlc_parse_ul_data_header(struct gprs_rlc_data_info *rlc,
return cur_bit;
}
+int Decoding::rlc_parse_ul_data_header_egprs_type_3(
+ struct gprs_rlc_data_info *rlc,
+ const uint8_t *data,
+ const GprsCodingScheme &cs)
+{
+ int punct, punct2, with_padding, cps;
+ unsigned int e_ti_header, offs, cur_bit = 0;
+ const struct gprs_rlc_ul_header_egprs_3 *egprs3;
+
+ egprs3 = static_cast < struct gprs_rlc_ul_header_egprs_3 * >
+ ((void *)data);
+
+ cps = (egprs3->cps_a << 0) | (egprs3->cps_b << 2);
+ gprs_rlc_mcs_cps_decode(cps, cs, &punct, &punct2, &with_padding);
+ gprs_rlc_data_info_init_ul(rlc, cs, with_padding);
+
+ rlc->r = egprs3->r;
+ rlc->si = egprs3->si;
+ rlc->tfi = (egprs3->tfi_a << 0) | (egprs3->tfi_b << 2);
+ rlc->cps = cps;
+ rlc->rsb = egprs3->rsb;
+
+ rlc->num_data_blocks = 1;
+ rlc->block_info[0].cv = egprs3->cv;
+ rlc->block_info[0].pi = egprs3->pi;
+ rlc->block_info[0].spb = egprs3->spb;
+ rlc->block_info[0].bsn =
+ (egprs3->bsn1_a << 0) | (egprs3->bsn1_b << 5);
+
+ cur_bit += rlc->data_offs_bits[0] - 2;
+ offs = rlc->data_offs_bits[0] / 8;
+ OSMO_ASSERT(rlc->data_offs_bits[0] % 8 == 1);
+ e_ti_header = (data[offs-1] + (data[offs] << 8)) >> 7;
+ rlc->block_info[0].e = !!(e_ti_header & 0x01);
+ rlc->block_info[0].ti = !!(e_ti_header & 0x02);
+ cur_bit += 2;
+ /* skip data area */
+ cur_bit += cs.maxDataBlockBytes() * 8;
+
+ return cur_bit;
+}
+
+int Decoding::rlc_parse_ul_data_header_gprs(struct gprs_rlc_data_info *rlc,
+ const uint8_t *data, const GprsCodingScheme &cs)
+{
+ const struct rlc_ul_header *gprs;
+ unsigned int cur_bit = 0;
+
+ gprs = static_cast < struct rlc_ul_header * >
+ ((void *)data);
+
+ gprs_rlc_data_info_init_ul(rlc, cs, false);
+
+ rlc->r = gprs->r;
+ rlc->si = gprs->si;
+ rlc->tfi = gprs->tfi;
+ rlc->cps = 0;
+ rlc->rsb = 0;
+ rlc->num_data_blocks = 1;
+ rlc->block_info[0].cv = gprs->cv;
+ rlc->block_info[0].pi = gprs->pi;
+ rlc->block_info[0].bsn = gprs->bsn;
+ rlc->block_info[0].e = gprs->e;
+ rlc->block_info[0].ti = gprs->ti;
+ rlc->block_info[0].spb = 0;
+ cur_bit += rlc->data_offs_bits[0];
+ /* skip data area */
+ cur_bit += cs.maxDataBlockBytes() * 8;
+
+ return cur_bit;
+}
+
/**
* \brief Copy LSB bitstream RLC data block to byte aligned buffer.
*
diff --git a/src/decoding.h b/src/decoding.h
index 58ecd18..1043d67 100644
--- a/src/decoding.h
+++ b/src/decoding.h
@@ -43,7 +43,14 @@ public:
static void extract_rbb(const uint8_t *rbb, char *extracted_rbb);
static void extract_rbb(const struct bitvec *rbb, char *show_rbb);
-
+ static int rlc_parse_ul_data_header_egprs_type_3(
+ struct gprs_rlc_data_info *rlc,
+ const uint8_t *data,
+ const GprsCodingScheme &cs);
+ static int rlc_parse_ul_data_header_gprs(
+ struct gprs_rlc_data_info *rlc,
+ const uint8_t *data,
+ const GprsCodingScheme &cs);
static int rlc_parse_ul_data_header(struct gprs_rlc_data_info *rlc,
const uint8_t *data, GprsCodingScheme cs);
static unsigned int rlc_copy_to_aligned_buffer(