From 4d7e49bc0a094c27352f43cad0a8556a9bd3befa Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Thu, 2 May 2013 22:37:16 +0200 Subject: sms: Implement encoding the address as alphanumeric type The number of digits is the number of used octets times two (two digits per octet). The result has been successfully dissected by wireshark. It has not been tested with real phones. --- tests/sms/sms_test.c | 44 +++++++++++++++++++++++++++++++++++++++++++- tests/sms/sms_test.ok | 6 ++++++ 2 files changed, 49 insertions(+), 1 deletion(-) (limited to 'tests/sms') diff --git a/tests/sms/sms_test.c b/tests/sms/sms_test.c index 3188a187..a79d4547 100644 --- a/tests/sms/sms_test.c +++ b/tests/sms/sms_test.c @@ -22,8 +22,13 @@ #include #include #include -#include + +#include + #include +#include + +#include #include struct test_case { @@ -222,6 +227,42 @@ static void test_octet_return() printf("Done\n"); } +static void test_gen_oa(void) +{ + uint8_t oa[12]; + int len; + + printf("Testing gsm340_gen_oa\n"); + + /* first try... */ + len = gsm340_gen_oa(oa, ARRAY_SIZE(oa), GSM340_TYPE_UNKNOWN, + GSM340_PLAN_ISDN, "12345678901234567891"); + OSMO_ASSERT(len == 12); + printf("Result: len(%d) data(%s)\n", len, osmo_hexdump(oa, len)); + len = gsm340_gen_oa(oa, ARRAY_SIZE(oa), GSM340_TYPE_NATIONAL, + GSM340_PLAN_ISDN, "12345678901234567891"); + OSMO_ASSERT(len == 12); + printf("Result: len(%d) data(%s)\n", len, osmo_hexdump(oa, len)); + + /* long input.. will fail and just prints the header*/ + len = gsm340_gen_oa(oa, ARRAY_SIZE(oa), GSM340_TYPE_INTERNATIONAL, + GSM340_PLAN_ISDN, "123456789123456789120"); + OSMO_ASSERT(len == 2); + printf("Result: len(%d) data(%s)\n", len, osmo_hexdump(oa, len)); + + /* try the alpha numeric encoding */ + len = gsm340_gen_oa(oa, ARRAY_SIZE(oa), GSM340_TYPE_ALPHA_NUMERIC, + GSM340_PLAN_UNKNOWN, "OpenBSC"); + OSMO_ASSERT(len == 9); + printf("Result: len(%d) data(%s)\n", len, osmo_hexdump(oa, len)); + + /* long alpha numeric text */ + len = gsm340_gen_oa(oa, ARRAY_SIZE(oa), GSM340_TYPE_ALPHA_NUMERIC, + GSM340_PLAN_UNKNOWN, "OpenBSCabcdefghijklm"); + OSMO_ASSERT(len == 12); + printf("Result: len(%d) data(%s)\n", len, osmo_hexdump(oa, len)); +} + int main(int argc, char** argv) { printf("SMS testing\n"); @@ -344,6 +385,7 @@ int main(int argc, char** argv) } test_octet_return(); + test_gen_oa(); printf("OK\n"); return 0; diff --git a/tests/sms/sms_test.ok b/tests/sms/sms_test.ok index 915a59c8..a71567de 100644 --- a/tests/sms/sms_test.ok +++ b/tests/sms/sms_test.ok @@ -12,4 +12,10 @@ Decode case 5: return value 40 (expected 40) Encoding some tests and printing number of septets/octets SEPTETS: 8 OCTETS: 7 Done +Testing gsm340_gen_oa +Result: len(12) data(14 81 21 43 65 87 09 21 43 65 87 19 ) +Result: len(12) data(14 a1 21 43 65 87 09 21 43 65 87 19 ) +Result: len(2) data(00 91 ) +Result: len(9) data(0e d0 4f 78 d9 2d 9c 0e 01 ) +Result: len(12) data(14 d0 4f 78 d9 2d 9c 0e c3 e2 31 19 ) OK -- cgit v1.2.3