diff options
author | Oliver Smith <osmith@sysmocom.de> | 2023-02-27 10:28:40 +0100 |
---|---|---|
committer | osmith <osmith@sysmocom.de> | 2023-02-27 13:49:34 +0000 |
commit | 57d4fae8325f7c8cccc03958d5f87f9174d13ba7 (patch) | |
tree | 0141a700afdb6135ce29132ab32fb12144c6c983 | |
parent | 6345333fb101d5fc3ebe70e87c90673ac40cae3f (diff) |
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
-rw-r--r-- | src/gsm/gsm0808_utils.c | 4 | ||||
-rw-r--r-- | tests/gsm0808/gsm0808_test.c | 10 |
2 files changed, 7 insertions, 7 deletions
diff --git a/src/gsm/gsm0808_utils.c b/src/gsm/gsm0808_utils.c index d8c275a7..efa9305f 100644 --- a/src/gsm/gsm0808_utils.c +++ b/src/gsm/gsm0808_utils.c @@ -510,7 +510,7 @@ uint8_t gsm0808_enc_channel_type(struct msgb *msg, 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 @@ int gsm0808_dec_channel_type(struct gsm0808_channel_type *ct, 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 9a6de1e7..d7c278fa 100644 --- a/tests/gsm0808/gsm0808_test.c +++ b/tests/gsm0808/gsm0808_test.c @@ -1098,7 +1098,7 @@ static void test_gsm0808_enc_dec_channel_type_data(void) 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 @@ static void test_gsm0808_enc_dec_channel_type_data_asym_pref(void) 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 @@ static void test_gsm0808_dec_channel_type_err(void) 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); |