summaryrefslogtreecommitdiffstats
path: root/src/coding
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/coding
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/coding')
-rw-r--r--src/coding/gsm0503_coding.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/coding/gsm0503_coding.c b/src/coding/gsm0503_coding.c
index 30ec387b..baf1ce15 100644
--- a/src/coding/gsm0503_coding.c
+++ b/src/coding/gsm0503_coding.c
@@ -24,6 +24,7 @@
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
+#include <errno.h>
#include <osmocom/core/bits.h>
#include <osmocom/core/conv.h>
@@ -820,15 +821,17 @@ int gsm0503_pdtch_egprs_decode(uint8_t *l2_data, sbit_t *bursts, uint16_t nbits,
if ((nbits != GSM0503_GPRS_BURSTS_NBITS) &&
(nbits != GSM0503_EGPRS_BURSTS_NBITS)) {
/* Invalid EGPRS bit length */
- return -1;
+ return -EOVERFLOW;
}
hdr = (union gprs_rlc_ul_hdr_egprs *) l2_data;
type = egprs_decode_hdr(hdr, bursts, nbits);
if (egprs_parse_ul_cps(&cps, hdr, type) < 0)
- return -1;
+ return -EIO;
switch (cps.mcs) {
+ case EGPRS_MCS0:
+ return -ENOTSUP;
case EGPRS_MCS1:
case EGPRS_MCS2:
case EGPRS_MCS3:
@@ -846,7 +849,7 @@ int gsm0503_pdtch_egprs_decode(uint8_t *l2_data, sbit_t *bursts, uint16_t nbits,
break;
default:
/* Invalid MCS-X */
- return -1;
+ return -EINVAL;
}
/* Decode MCS-X block, where X = cps.mcs */
@@ -854,19 +857,19 @@ int gsm0503_pdtch_egprs_decode(uint8_t *l2_data, sbit_t *bursts, uint16_t nbits,
rc = egprs_decode_data(l2_data, dc, cps.mcs, cps.p[0],
0, n_errors, n_bits_total);
if (rc < 0)
- return -1;
+ return -EFAULT;
} else {
/* MCS-7,8,9 block 1 */
rc = egprs_decode_data(l2_data, c1, cps.mcs, cps.p[0],
0, n_errors, n_bits_total);
if (rc < 0)
- return -1;
+ return -EFAULT;
/* MCS-7,8,9 block 2 */
rc = egprs_decode_data(l2_data, c2, cps.mcs, cps.p[1],
1, n_errors, n_bits_total);
if (rc < 0)
- return -1;
+ return -EFAULT;
}
return rc;