From 605c9e63bb0db9c86bde06fd504d25e0969b0130 Mon Sep 17 00:00:00 2001 From: Mychaela Falconia Date: Sun, 3 Jul 2022 05:15:30 +0700 Subject: [PATCH] gsm48_ie: fix parsing of Bearer capability IE without octet 3a The testcase in gsm0408_test is still failing because the encoder produces a different result (with octet 3a present). There is no way to tell the encoder to use the implicit coding, and in general this is not that critical, so we can live with that. Change-Id: I722c168f01bffa915cb155eac234a796549d3762 --- src/gsm/gsm48_ie.c | 17 +++++++++++++++++ tests/gsm0408/gsm0408_test.err | 6 +++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/gsm/gsm48_ie.c b/src/gsm/gsm48_ie.c index 4fa4924a7..bbaec3dac 100644 --- a/src/gsm/gsm48_ie.c +++ b/src/gsm/gsm48_ie.c @@ -203,6 +203,23 @@ int gsm48_decode_bearer_cap(struct gsm_mncc_bearer_cap *bcap, case GSM_MNCC_BCAP_SPEECH: i = 1; s = 0; + if ((lv[1] & 0x80) != 0) { /* octet 3a is absent */ + switch (bcap->radio) { + case GSM48_BCAP_RRQ_FR_ONLY: + bcap->speech_ver[s++] = GSM48_BCAP_SV_FR; + break; + case GSM48_BCAP_RRQ_DUAL_HR: + bcap->speech_ver[s++] = GSM48_BCAP_SV_HR; + bcap->speech_ver[s++] = GSM48_BCAP_SV_FR; + break; + case GSM48_BCAP_RRQ_DUAL_FR: + bcap->speech_ver[s++] = GSM48_BCAP_SV_FR; + bcap->speech_ver[s++] = GSM48_BCAP_SV_HR; + break; + } + bcap->speech_ver[s] = -1; /* end of list */ + return 0; + } while (!(lv[i] & 0x80)) { i++; /* octet 3a etc */ if (in_len < i) diff --git a/tests/gsm0408/gsm0408_test.err b/tests/gsm0408/gsm0408_test.err index 1f0236ce1..8aeda3ede 100644 --- a/tests/gsm0408/gsm0408_test.err +++ b/tests/gsm0408/gsm0408_test.err @@ -1,3 +1,3 @@ -Incorrect decoded result of Speech, without octet 3a: - should: 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 ff ff ff ff 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - is: 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 ff ff ff ff 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +Incorrect encoded result of Speech, without octet 3a: + should: 01 a0 + is: 02 20 80