summaryrefslogtreecommitdiffstats
path: root/tests/gsm0808
diff options
context:
space:
mode:
authorPhilipp Maier <pmaier@sysmocom.de>2017-03-28 17:05:40 +0200
committerHarald Welte <laforge@gnumonks.org>2017-04-08 07:44:46 +0000
commite0c65301d5786be04cf4731f1cdeed05c4442482 (patch)
tree379c1481eb20eb43970e5b4cf915285eb46d1217 /tests/gsm0808
parentfa896abbb3c18af46aa398d6e6708a275d42a863 (diff)
gsm0808: Add utils for Channel Type
The planned support for true A over IP requires the encoding of the a Channel Type element (see also ASSIGNMENT REQUEST). This commt adds encoding/decoding functionality and tests for the element mentioned above, however, it is not yet actively used. Change-Id: Id0e2164d84b8cbcc6fe6a090fc7f40a1251421d7
Diffstat (limited to 'tests/gsm0808')
-rw-r--r--tests/gsm0808/gsm0808_test.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/gsm0808/gsm0808_test.c b/tests/gsm0808/gsm0808_test.c
index 4a4a1084..0dd9e846 100644
--- a/tests/gsm0808/gsm0808_test.c
+++ b/tests/gsm0808/gsm0808_test.c
@@ -541,6 +541,36 @@ static void test_gsm0808_enc_dec_speech_codec_list()
msgb_free(msg);
}
+static void test_gsm0808_enc_dec_channel_type()
+{
+ struct gsm0808_channel_type enc_ct;
+ struct gsm0808_channel_type dec_ct;
+ struct msgb *msg;
+ uint8_t ct_enc_expected[] = { GSM0808_IE_CHANNEL_TYPE,
+ 0x04, 0x01, 0x0b, 0xa1, 0x25
+ };
+ uint8_t rc_enc;
+ int rc_dec;
+
+ memset(&enc_ct, 0, sizeof(enc_ct));
+ enc_ct.ch_indctr = GSM0808_CHAN_SPEECH;
+ enc_ct.ch_rate_type = GSM0808_SPEECH_HALF_PREF;
+ enc_ct.perm_spch[0] = GSM0808_PERM_FR3;
+ enc_ct.perm_spch[1] = GSM0808_PERM_HR3;
+ enc_ct.perm_spch_len = 2;
+
+ msg = msgb_alloc(1024, "output buffer");
+ rc_enc = gsm0808_enc_channel_type(msg, &enc_ct);
+ OSMO_ASSERT(rc_enc == 6);
+ OSMO_ASSERT(memcmp(ct_enc_expected, msg->data, msg->len) == 0);
+
+ rc_dec = gsm0808_dec_channel_type(&dec_ct, msg->data + 2, msg->len - 2);
+ OSMO_ASSERT(rc_dec == 4);
+ OSMO_ASSERT(memcmp(&enc_ct, &dec_ct, sizeof(enc_ct)) == 0);
+
+ msgb_free(msg);
+}
+
int main(int argc, char **argv)
{
printf("Testing generation of GSM0808 messages\n");
@@ -566,6 +596,7 @@ int main(int argc, char **argv)
test_gsm0808_enc_dec_speech_codec_ext();
test_gsm0808_enc_dec_speech_codec_ext_with_cfg();
test_gsm0808_enc_dec_speech_codec_list();
+ test_gsm0808_enc_dec_channel_type();
printf("Done\n");
return EXIT_SUCCESS;