fixeria has uploaded this change for review.

View Change

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 simple live with that.

Change-Id: I722c168f01bffa915cb155eac234a796549d3762
---
M src/gsm/gsm48_ie.c
M tests/gsm0408/gsm0408_test.err
2 files changed, 30 insertions(+), 12 deletions(-)

git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/08/28508/1
diff --git a/src/gsm/gsm48_ie.c b/src/gsm/gsm48_ie.c
index 4fa4924..df765cf 100644
--- a/src/gsm/gsm48_ie.c
+++ b/src/gsm/gsm48_ie.c
@@ -203,16 +203,34 @@
case GSM_MNCC_BCAP_SPEECH:
i = 1;
s = 0;
- while (!(lv[i] & 0x80)) {
- i++; /* octet 3a etc */
- if (in_len < i)
- return 0;
- bcap->speech_ver[s++] = lv[i] & 0x0f;
+ if ((lv[1] & 0x80) != 0) {
+ 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 */
- if (i == 2) /* octet 3a */
- bcap->speech_ctm = (lv[i] & 0x20) >> 5;
- if (s == 7) /* maximum speech versions + end of list */
- return 0;
+ return 0;
+ } else {
+ while (!(lv[i] & 0x80)) {
+ i++; /* octet 3a etc */
+ if (in_len < i)
+ return 0;
+ bcap->speech_ver[s++] = lv[i] & 0x0f;
+ bcap->speech_ver[s] = -1; /* end of list */
+ if (i == 2) /* octet 3a */
+ bcap->speech_ctm = (lv[i] & 0x20) >> 5;
+ if (s == 7) /* maximum speech versions + end of list */
+ return 0;
+ }
}
break;
case GSM_MNCC_BCAP_UNR_DIG:
diff --git a/tests/gsm0408/gsm0408_test.err b/tests/gsm0408/gsm0408_test.err
index 1f0236c..8aeda3e 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

To view, visit change 28508. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I722c168f01bffa915cb155eac234a796549d3762
Gerrit-Change-Number: 28508
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy@sysmocom.de>
Gerrit-MessageType: newchange