From c8cf82059518855298b87da4757e8e1face74359 Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 22 May 2017 16:07:04 +0200 Subject: 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 --- src/coding/gsm0503_coding.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/coding') 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 #include #include +#include #include #include @@ -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; -- cgit v1.2.3