osmith has submitted this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/31536 )

Change subject: gsm0808_enc/dec_channel_type: fix transparent flag
......................................................................

gsm0808_enc/dec_channel_type: fix transparent flag

According to 3GPP TS 48.008 3.2.2.11, it is inverted.

0: Transparent service
1: Non-transparent service

Change-Id: I2e5786ad053ee871079b4a8d95caccd6b03b59b6
---
M src/gsm/gsm0808_utils.c
M tests/gsm0808/gsm0808_test.c
2 files changed, 21 insertions(+), 7 deletions(-)

Approvals:
  fixeria: Looks good to me, approved
  pespin: Looks good to me, but someone else must approve
  Jenkins Builder: Verified




diff --git a/src/gsm/gsm0808_utils.c b/src/gsm/gsm0808_utils.c
index d8c275a..efa9305 100644
--- a/src/gsm/gsm0808_utils.c
+++ b/src/gsm/gsm0808_utils.c
@@ -510,7 +510,7 @@
        case GSM0808_CHAN_DATA:
                byte = ct->data_rate;

-               if (ct->data_transparent)
+               if (!ct->data_transparent)
                        byte |= 0x40; /* Set T/NT */

                if (ct->data_rate_allowed_is_set) {
@@ -580,7 +580,7 @@
        case GSM0808_CHAN_DATA:
                byte = *elem;
                elem++;
-               ct->data_transparent = byte & 0x40; /* T/NT */
+               ct->data_transparent = !(byte & 0x40); /* T/NT */
                ct->data_rate = byte & 0x3f;

                /* Optional extension for non-transparent service */
diff --git a/tests/gsm0808/gsm0808_test.c b/tests/gsm0808/gsm0808_test.c
index 9a6de1e..d7c278f 100644
--- a/tests/gsm0808/gsm0808_test.c
+++ b/tests/gsm0808/gsm0808_test.c
@@ -1098,7 +1098,7 @@
        struct gsm0808_channel_type dec_ct = {};
        struct msgb *msg;
        uint8_t ct_enc_expected[] = { GSM0808_IE_CHANNEL_TYPE,
-               0x03, 0x02, 0x0b, 0x51,
+               0x03, 0x02, 0x0b, 0x11,
        };
        uint8_t rc_enc;
        int rc_dec;
@@ -1142,7 +1142,7 @@
        struct gsm0808_channel_type dec_ct = {};
        struct msgb *msg;
        uint8_t ct_enc_expected[] = { GSM0808_IE_CHANNEL_TYPE,
-               0x05, 0x02, 0x0b, 0x91, 0x8b, 0x20,
+               0x05, 0x02, 0x0b, 0xd1, 0x8b, 0x20,
        };
        uint8_t rc_enc;
        int rc_dec;
@@ -1237,17 +1237,17 @@
        OSMO_ASSERT(rc == -ENOTSUP);

        /* Data: ext in Octet 5 with transparent service */
-       const uint8_t hex2[] = { 0x02, 0x0b, 0xc0, 0x00 };
+       const uint8_t hex2[] = { 0x02, 0x0b, 0x80, 0x00 };
        rc = gsm0808_dec_channel_type(&ct, hex2, sizeof(hex2));
        OSMO_ASSERT(rc == -EINVAL);

        /* Data: ext in Octet 5, but too short */
-       const uint8_t hex3[] = { 0x02, 0x0b, 0x80 };
+       const uint8_t hex3[] = { 0x02, 0x0b, 0xc0 };
        rc = gsm0808_dec_channel_type(&ct, hex3, sizeof(hex3));
        OSMO_ASSERT(rc == -EOVERFLOW);

        /* Data: ext in Octet 5a, but too short */
-       const uint8_t hex4[] = { 0x02, 0x0b, 0x80, 0x80 };
+       const uint8_t hex4[] = { 0x02, 0x0b, 0xc0, 0x80 };
        rc = gsm0808_dec_channel_type(&ct, hex4, sizeof(hex4));
        OSMO_ASSERT(rc == -EOVERFLOW);


--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/31536
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I2e5786ad053ee871079b4a8d95caccd6b03b59b6
Gerrit-Change-Number: 31536
Gerrit-PatchSet: 2
Gerrit-Owner: osmith <osm...@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanits...@sysmocom.de>
Gerrit-Reviewer: osmith <osm...@sysmocom.de>
Gerrit-Reviewer: pespin <pes...@sysmocom.de>
Gerrit-MessageType: merged

Reply via email to