aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2016-02-03 18:31:19 +0100
committerJacob Erlbeck <jerlbeck@sysmocom.de>2016-02-03 19:23:49 +0100
commitfb7b02923ce292edad312d75dbc900712defa017 (patch)
treef72983cb2a8e14f3085a007baffd4d777787bc84
parentfc6d572c07df78de6066e376e88dfbcee2a62cf9 (diff)
rlc: Add gprs_rlc_mcs_cps_decode
To access EGPRS data blocks, the optional padding must be taken into account. Whether padding has been used must be dervied from the CPS field in the header of the RLC EGPRS data message. Add this function to decode the CPS value and extract that information. Sponsored-by: On-Waves ehf
-rw-r--r--src/rlc.cpp29
-rw-r--r--src/rlc.h2
2 files changed, 31 insertions, 0 deletions
diff --git a/src/rlc.cpp b/src/rlc.cpp
index ca12e91..79d8f48 100644
--- a/src/rlc.cpp
+++ b/src/rlc.cpp
@@ -356,3 +356,32 @@ unsigned int gprs_rlc_mcs_cps(GprsCodingScheme cs, int punct, int punct2,
return -1;
}
+
+void gprs_rlc_mcs_cps_decode(unsigned int cps,
+ GprsCodingScheme cs, int *punct, int *punct2, int *with_padding)
+{
+ *punct2 = -1;
+ *with_padding = 0;
+
+ switch (GprsCodingScheme::Scheme(cs)) {
+ case GprsCodingScheme::MCS1:
+ cps -= 0b1011; *punct = cps % 2; break;
+ case GprsCodingScheme::MCS2:
+ cps -= 0b1001; *punct = cps % 2; break;
+ case GprsCodingScheme::MCS3:
+ cps -= 0b0011; *punct = cps % 3; *with_padding = cps >= 3; break;
+ case GprsCodingScheme::MCS4:
+ cps -= 0b0000; *punct = cps % 3; break;
+ case GprsCodingScheme::MCS5:
+ cps -= 0b100; *punct = cps % 2; break;
+ case GprsCodingScheme::MCS6:
+ cps -= 0b000; *punct = cps % 2; *with_padding = cps >= 2; break;
+ case GprsCodingScheme::MCS7:
+ cps -= 0b10100; *punct = cps / 3; *punct2 = cps % 3; break;
+ case GprsCodingScheme::MCS8:
+ cps -= 0b01011; *punct = cps / 3; *punct2 = cps % 3; break;
+ case GprsCodingScheme::MCS9:
+ cps -= 0b00000; *punct = cps / 4; *punct2 = cps % 3; break;
+ default: ;
+ }
+}
diff --git a/src/rlc.h b/src/rlc.h
index dcb1877..54f28df 100644
--- a/src/rlc.h
+++ b/src/rlc.h
@@ -110,6 +110,8 @@ void gprs_rlc_data_block_info_init(struct gprs_rlc_data_block_info *rdbi,
GprsCodingScheme cs, bool with_padding);
unsigned int gprs_rlc_mcs_cps(GprsCodingScheme cs, int punct, int punct2,
int with_padding);
+void gprs_rlc_mcs_cps_decode(unsigned int cps, GprsCodingScheme cs,
+ int *punct, int *punct2, int *with_padding);
/*
* I hold the currently transferred blocks and will provide