summaryrefslogtreecommitdiffstats
path: root/src/gsm/gprs_rlc.c
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2017-05-22 16:07:04 +0200
committerHarald Welte <laforge@gnumonks.org>2017-05-24 22:12:56 +0000
commitc8cf82059518855298b87da4757e8e1face74359 (patch)
tree29632a5a30ef38ea4ffebbc907f5949580e2ece9 /src/gsm/gprs_rlc.c
parent34e228a9bcf3ac37287bb5e684ace46818740f3b (diff)
Distinguish between unsupported and invalid MCS
Previously MCS0 was incorrectly set for some of type1 header values while according to 3GPP TS 44.060 it can only be set for type3. Fix this: * use EGPRS_MCS* constants instead of magic values * do not set MCS0 for reserved bits values in EGPRS header type1 * return different error codes for invalid and unsupported MCS as well as for other decoding errors Note: there's no need to adjust tests because MCS0 decoding is not supported but it's better to explicitly distinguish between unsupported and invalid values nevertheless. Change-Id: Id665d5c0cf50efa18b1bcbf4f17359418a380f9e Related: OS#1524
Diffstat (limited to 'src/gsm/gprs_rlc.c')
-rw-r--r--src/gsm/gprs_rlc.c107
1 files changed, 54 insertions, 53 deletions
diff --git a/src/gsm/gprs_rlc.c b/src/gsm/gprs_rlc.c
index d6ccbbe4..a4053ef6 100644
--- a/src/gsm/gprs_rlc.c
+++ b/src/gsm/gprs_rlc.c
@@ -2,6 +2,7 @@
#include <string.h>
#include <osmocom/gprs/gprs_rlc.h>
+#include <osmocom/coding/gsm0503_coding.h>
#include <osmocom/gprs/protocol/gsm_04_60.h>
#define EGPRS_CPS_TYPE1_TBL_SZ 29
@@ -10,35 +11,35 @@
/* 3GPP TS 44.060 10.4.8a.1.1 "Header type 1" */
static const struct egprs_cps egprs_cps_table_type1[EGPRS_CPS_TYPE1_TBL_SZ] = {
- { .bits = 0, .mcs = 9, .p = { EGPRS_CPS_P1, EGPRS_CPS_P1 } },
- { .bits = 1, .mcs = 9, .p = { EGPRS_CPS_P1, EGPRS_CPS_P2 } },
- { .bits = 2, .mcs = 9, .p = { EGPRS_CPS_P1, EGPRS_CPS_P3 } },
- { .bits = 3, .mcs = 0, .p = { EGPRS_CPS_NONE, EGPRS_CPS_NONE } },
- { .bits = 4, .mcs = 9, .p = { EGPRS_CPS_P2, EGPRS_CPS_P1 } },
- { .bits = 5, .mcs = 9, .p = { EGPRS_CPS_P2, EGPRS_CPS_P2 } },
- { .bits = 6, .mcs = 9, .p = { EGPRS_CPS_P2, EGPRS_CPS_P3 } },
- { .bits = 7, .mcs = 0, .p = { EGPRS_CPS_NONE, EGPRS_CPS_NONE } },
- { .bits = 8, .mcs = 9, .p = { EGPRS_CPS_P3, EGPRS_CPS_P1 } },
- { .bits = 9, .mcs = 9, .p = { EGPRS_CPS_P3, EGPRS_CPS_P2 } },
- { .bits = 10, .mcs = 9, .p = { EGPRS_CPS_P3, EGPRS_CPS_P3 } },
- { .bits = 11, .mcs = 8, .p = { EGPRS_CPS_P1, EGPRS_CPS_P1 } },
- { .bits = 12, .mcs = 8, .p = { EGPRS_CPS_P1, EGPRS_CPS_P2 } },
- { .bits = 13, .mcs = 8, .p = { EGPRS_CPS_P1, EGPRS_CPS_P3 } },
- { .bits = 14, .mcs = 8, .p = { EGPRS_CPS_P2, EGPRS_CPS_P1 } },
- { .bits = 15, .mcs = 8, .p = { EGPRS_CPS_P2, EGPRS_CPS_P2 } },
- { .bits = 16, .mcs = 8, .p = { EGPRS_CPS_P2, EGPRS_CPS_P3 } },
- { .bits = 17, .mcs = 8, .p = { EGPRS_CPS_P3, EGPRS_CPS_P1 } },
- { .bits = 18, .mcs = 8, .p = { EGPRS_CPS_P3, EGPRS_CPS_P2 } },
- { .bits = 19, .mcs = 8, .p = { EGPRS_CPS_P3, EGPRS_CPS_P3 } },
- { .bits = 20, .mcs = 7, .p = { EGPRS_CPS_P1, EGPRS_CPS_P1 } },
- { .bits = 21, .mcs = 7, .p = { EGPRS_CPS_P1, EGPRS_CPS_P2 } },
- { .bits = 22, .mcs = 7, .p = { EGPRS_CPS_P1, EGPRS_CPS_P3 } },
- { .bits = 23, .mcs = 7, .p = { EGPRS_CPS_P2, EGPRS_CPS_P1 } },
- { .bits = 24, .mcs = 7, .p = { EGPRS_CPS_P2, EGPRS_CPS_P2 } },
- { .bits = 25, .mcs = 7, .p = { EGPRS_CPS_P2, EGPRS_CPS_P3 } },
- { .bits = 26, .mcs = 7, .p = { EGPRS_CPS_P3, EGPRS_CPS_P1 } },
- { .bits = 27, .mcs = 7, .p = { EGPRS_CPS_P3, EGPRS_CPS_P2 } },
- { .bits = 28, .mcs = 7, .p = { EGPRS_CPS_P3, EGPRS_CPS_P3 } },
+ { .bits = 0, .mcs = EGPRS_MCS9, .p = { EGPRS_CPS_P1, EGPRS_CPS_P1 } },
+ { .bits = 1, .mcs = EGPRS_MCS9, .p = { EGPRS_CPS_P1, EGPRS_CPS_P2 } },
+ { .bits = 2, .mcs = EGPRS_MCS9, .p = { EGPRS_CPS_P1, EGPRS_CPS_P3 } },
+ { .bits = 3, .mcs = EGPRS_NUM_MCS, .p = { EGPRS_CPS_NONE, EGPRS_CPS_NONE } }, /* reserved for future use */
+ { .bits = 4, .mcs = EGPRS_MCS9, .p = { EGPRS_CPS_P2, EGPRS_CPS_P1 } },
+ { .bits = 5, .mcs = EGPRS_MCS9, .p = { EGPRS_CPS_P2, EGPRS_CPS_P2 } },
+ { .bits = 6, .mcs = EGPRS_MCS9, .p = { EGPRS_CPS_P2, EGPRS_CPS_P3 } },
+ { .bits = 7, .mcs = EGPRS_NUM_MCS, .p = { EGPRS_CPS_NONE, EGPRS_CPS_NONE } }, /* reserved for future use */
+ { .bits = 8, .mcs = EGPRS_MCS9, .p = { EGPRS_CPS_P3, EGPRS_CPS_P1 } },
+ { .bits = 9, .mcs = EGPRS_MCS9, .p = { EGPRS_CPS_P3, EGPRS_CPS_P2 } },
+ { .bits = 10, .mcs = EGPRS_MCS9, .p = { EGPRS_CPS_P3, EGPRS_CPS_P3 } },
+ { .bits = 11, .mcs = EGPRS_MCS8, .p = { EGPRS_CPS_P1, EGPRS_CPS_P1 } },
+ { .bits = 12, .mcs = EGPRS_MCS8, .p = { EGPRS_CPS_P1, EGPRS_CPS_P2 } },
+ { .bits = 13, .mcs = EGPRS_MCS8, .p = { EGPRS_CPS_P1, EGPRS_CPS_P3 } },
+ { .bits = 14, .mcs = EGPRS_MCS8, .p = { EGPRS_CPS_P2, EGPRS_CPS_P1 } },
+ { .bits = 15, .mcs = EGPRS_MCS8, .p = { EGPRS_CPS_P2, EGPRS_CPS_P2 } },
+ { .bits = 16, .mcs = EGPRS_MCS8, .p = { EGPRS_CPS_P2, EGPRS_CPS_P3 } },
+ { .bits = 17, .mcs = EGPRS_MCS8, .p = { EGPRS_CPS_P3, EGPRS_CPS_P1 } },
+ { .bits = 18, .mcs = EGPRS_MCS8, .p = { EGPRS_CPS_P3, EGPRS_CPS_P2 } },
+ { .bits = 19, .mcs = EGPRS_MCS8, .p = { EGPRS_CPS_P3, EGPRS_CPS_P3 } },
+ { .bits = 20, .mcs = EGPRS_MCS7, .p = { EGPRS_CPS_P1, EGPRS_CPS_P1 } },
+ { .bits = 21, .mcs = EGPRS_MCS7, .p = { EGPRS_CPS_P1, EGPRS_CPS_P2 } },
+ { .bits = 22, .mcs = EGPRS_MCS7, .p = { EGPRS_CPS_P1, EGPRS_CPS_P3 } },
+ { .bits = 23, .mcs = EGPRS_MCS7, .p = { EGPRS_CPS_P2, EGPRS_CPS_P1 } },
+ { .bits = 24, .mcs = EGPRS_MCS7, .p = { EGPRS_CPS_P2, EGPRS_CPS_P2 } },
+ { .bits = 25, .mcs = EGPRS_MCS7, .p = { EGPRS_CPS_P2, EGPRS_CPS_P3 } },
+ { .bits = 26, .mcs = EGPRS_MCS7, .p = { EGPRS_CPS_P3, EGPRS_CPS_P1 } },
+ { .bits = 27, .mcs = EGPRS_MCS7, .p = { EGPRS_CPS_P3, EGPRS_CPS_P2 } },
+ { .bits = 28, .mcs = EGPRS_MCS7, .p = { EGPRS_CPS_P3, EGPRS_CPS_P3 } },
};
/*
@@ -46,34 +47,34 @@ static const struct egprs_cps egprs_cps_table_type1[EGPRS_CPS_TYPE1_TBL_SZ] = {
* "Header type 2 in EGPRS TBF or uplink EGPRS2-A TBF"
*/
static const struct egprs_cps egprs_cps_table_type2[EGPRS_CPS_TYPE2_TBL_SZ] = {
- { .bits = 0, .mcs = 6, .p = { EGPRS_CPS_P1, EGPRS_CPS_NONE } },
- { .bits = 1, .mcs = 6, .p = { EGPRS_CPS_P2, EGPRS_CPS_NONE } },
- { .bits = 2, .mcs = 6, .p = { EGPRS_CPS_P1, EGPRS_CPS_NONE } },
- { .bits = 3, .mcs = 6, .p = { EGPRS_CPS_P2, EGPRS_CPS_NONE } },
- { .bits = 4, .mcs = 5, .p = { EGPRS_CPS_P1, EGPRS_CPS_NONE } },
- { .bits = 5, .mcs = 5, .p = { EGPRS_CPS_P2, EGPRS_CPS_NONE } },
- { .bits = 6, .mcs = 6, .p = { EGPRS_CPS_P1, EGPRS_CPS_NONE } },
- { .bits = 7, .mcs = 6, .p = { EGPRS_CPS_P2, EGPRS_CPS_NONE } },
+ { .bits = 0, .mcs = EGPRS_MCS6, .p = { EGPRS_CPS_P1, EGPRS_CPS_NONE } },
+ { .bits = 1, .mcs = EGPRS_MCS6, .p = { EGPRS_CPS_P2, EGPRS_CPS_NONE } },
+ { .bits = 2, .mcs = EGPRS_MCS6, .p = { EGPRS_CPS_P1, EGPRS_CPS_NONE } },
+ { .bits = 3, .mcs = EGPRS_MCS6, .p = { EGPRS_CPS_P2, EGPRS_CPS_NONE } },
+ { .bits = 4, .mcs = EGPRS_MCS5, .p = { EGPRS_CPS_P1, EGPRS_CPS_NONE } },
+ { .bits = 5, .mcs = EGPRS_MCS5, .p = { EGPRS_CPS_P2, EGPRS_CPS_NONE } },
+ { .bits = 6, .mcs = EGPRS_MCS6, .p = { EGPRS_CPS_P1, EGPRS_CPS_NONE } },
+ { .bits = 7, .mcs = EGPRS_MCS6, .p = { EGPRS_CPS_P2, EGPRS_CPS_NONE } },
};
/* 3GPP TS 44.060 10.4.8a.3 "Header type 3" */
static const struct egprs_cps egprs_cps_table_type3[EGPRS_CPS_TYPE3_TBL_SZ] = {
- { .bits = 0, .mcs = 4, .p = { EGPRS_CPS_P1, EGPRS_CPS_NONE } },
- { .bits = 1, .mcs = 4, .p = { EGPRS_CPS_P2, EGPRS_CPS_NONE } },
- { .bits = 2, .mcs = 4, .p = { EGPRS_CPS_P3, EGPRS_CPS_NONE } },
- { .bits = 3, .mcs = 3, .p = { EGPRS_CPS_P1, EGPRS_CPS_NONE } },
- { .bits = 4, .mcs = 3, .p = { EGPRS_CPS_P2, EGPRS_CPS_NONE } },
- { .bits = 5, .mcs = 3, .p = { EGPRS_CPS_P3, EGPRS_CPS_NONE } },
- { .bits = 6, .mcs = 3, .p = { EGPRS_CPS_P1, EGPRS_CPS_NONE } },
- { .bits = 7, .mcs = 3, .p = { EGPRS_CPS_P2, EGPRS_CPS_NONE } },
- { .bits = 8, .mcs = 3, .p = { EGPRS_CPS_P3, EGPRS_CPS_NONE } },
- { .bits = 9, .mcs = 2, .p = { EGPRS_CPS_P1, EGPRS_CPS_NONE } },
- { .bits = 10, .mcs = 2, .p = { EGPRS_CPS_P2, EGPRS_CPS_NONE } },
- { .bits = 11, .mcs = 1, .p = { EGPRS_CPS_P1, EGPRS_CPS_NONE } },
- { .bits = 12, .mcs = 1, .p = { EGPRS_CPS_P2, EGPRS_CPS_NONE } },
- { .bits = 13, .mcs = 2, .p = { EGPRS_CPS_P1, EGPRS_CPS_NONE } },
- { .bits = 14, .mcs = 2, .p = { EGPRS_CPS_P2, EGPRS_CPS_NONE } },
- { .bits = 15, .mcs = 0, .p = { EGPRS_CPS_NONE, EGPRS_CPS_NONE } },
+ { .bits = 0, .mcs = EGPRS_MCS4, .p = { EGPRS_CPS_P1, EGPRS_CPS_NONE } },
+ { .bits = 1, .mcs = EGPRS_MCS4, .p = { EGPRS_CPS_P2, EGPRS_CPS_NONE } },
+ { .bits = 2, .mcs = EGPRS_MCS4, .p = { EGPRS_CPS_P3, EGPRS_CPS_NONE } },
+ { .bits = 3, .mcs = EGPRS_MCS3, .p = { EGPRS_CPS_P1, EGPRS_CPS_NONE } },
+ { .bits = 4, .mcs = EGPRS_MCS3, .p = { EGPRS_CPS_P2, EGPRS_CPS_NONE } },
+ { .bits = 5, .mcs = EGPRS_MCS3, .p = { EGPRS_CPS_P3, EGPRS_CPS_NONE } },
+ { .bits = 6, .mcs = EGPRS_MCS3, .p = { EGPRS_CPS_P1, EGPRS_CPS_NONE } },
+ { .bits = 7, .mcs = EGPRS_MCS3, .p = { EGPRS_CPS_P2, EGPRS_CPS_NONE } },
+ { .bits = 8, .mcs = EGPRS_MCS3, .p = { EGPRS_CPS_P3, EGPRS_CPS_NONE } },
+ { .bits = 9, .mcs = EGPRS_MCS2, .p = { EGPRS_CPS_P1, EGPRS_CPS_NONE } },
+ { .bits = 10, .mcs = EGPRS_MCS2, .p = { EGPRS_CPS_P2, EGPRS_CPS_NONE } },
+ { .bits = 11, .mcs = EGPRS_MCS1, .p = { EGPRS_CPS_P1, EGPRS_CPS_NONE } },
+ { .bits = 12, .mcs = EGPRS_MCS1, .p = { EGPRS_CPS_P2, EGPRS_CPS_NONE } },
+ { .bits = 13, .mcs = EGPRS_MCS2, .p = { EGPRS_CPS_P1, EGPRS_CPS_NONE } },
+ { .bits = 14, .mcs = EGPRS_MCS2, .p = { EGPRS_CPS_P2, EGPRS_CPS_NONE } },
+ { .bits = 15, .mcs = EGPRS_MCS0, .p = { EGPRS_CPS_NONE, EGPRS_CPS_NONE } },
};
int egprs_get_cps(struct egprs_cps *cps, uint8_t type, uint8_t bits)