diff options
Diffstat (limited to 'tests/smscb')
-rw-r--r-- | tests/smscb/cbsp_test.c | 108 | ||||
-rw-r--r-- | tests/smscb/cbsp_test.ok | 2 | ||||
-rw-r--r-- | tests/smscb/gsm0341_test.c | 14 | ||||
-rw-r--r-- | tests/smscb/gsm0341_test.ok | 1 | ||||
-rw-r--r-- | tests/smscb/smscb_test.c | 4 |
5 files changed, 117 insertions, 12 deletions
diff --git a/tests/smscb/cbsp_test.c b/tests/smscb/cbsp_test.c new file mode 100644 index 00000000..2dbdded7 --- /dev/null +++ b/tests/smscb/cbsp_test.c @@ -0,0 +1,108 @@ +/* + * (C) 2022 by sysmocom - s.f.m.c. GmbH + * All Rights Reserved + * + * Author: Pau Espin Pedrol <pespin@sysmocom.de> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include <string.h> +#include <stdio.h> +#include <stdlib.h> + +#include <osmocom/core/utils.h> +#include <osmocom/core/msgb.h> + +#include <osmocom/gsm/protocol/gsm_48_049.h> +#include <osmocom/gsm/cbsp.h> + +/* +CBSP WRITE-REPLACE FAILURE + Message Type: WRITE-REPLACE FAILURE (3) + Message Length: 44 + IE: Message Identifier: 0x0031 + Information Element Identifier: Message Identifier (14) + Message Identifier: 0x0031 + IE: New Serial Number: 0x4170 + Information Element Identifier: New Serial Number (3) + New Serial Number: 0x4170 + IE: Failure List: 2 items + Information Element Identifier: Failure List (9) + Information Element Length: 15 + Failure List Item: MCC 901 International Mobile, shared code, MNC 70 Clementvale Baltic OÜ, LAC 0x0018, CI 0x0030: Cause Cell-identity-not-valid + Cell ID Discriminator: CGI (0) + Mobile Country Code (MCC): International Mobile, shared code (901) + Mobile Network Code (MNC): Clementvale Baltic OÜ (70) + Location Area Code (LAC): 0x0018 + Cell Identifier (CI): 0x0030 + Cause: Cell-identity-not-valid (0x03) + Failure List Item: LAC 02711, CI 0xc351: Cause LAI-or-LAC-not-valid + Cell ID Discriminator: LAC+CI (1) + Location Area Code (LAC): 0x2711 + Cell Identifier (CI): 0xc351 + Cause: LAI-or-LAC-not-valid (0x0f) + IE: Cell List (CGI): 2 items + Information Element Identifier: Cell List (4) + Information Element Length: 15 + Cell ID Discriminator: CGI (0) + Cell List Item: MCC 901 International Mobile, shared code, MNC 70 Clementvale Baltic OÜ, LAC 0x0017, CI 0x002a + Mobile Country Code (MCC): International Mobile, shared code (901) + Mobile Network Code (MNC): Clementvale Baltic OÜ (70) + Location Area Code (LAC): 0x0017 + Cell Identifier (CI): 0x002a + Cell List Item: MCC 901 International Mobile, shared code, MNC 70 Clementvale Baltic OÜ, LAC 0x0018, CI 0x002a + Mobile Country Code (MCC): International Mobile, shared code (901) + Mobile Network Code (MNC): Clementvale Baltic OÜ (70) + Location Area Code (LAC): 0x0018 + Cell Identifier (CI): 0x002a + IE: Channel Indicator: basic channel + Information Element Identifier: Channel Indicator (18) + Channel Indicator: basic channel (0x00) +*/ +static const char write_repl_fail_with_failure_list[] = + "0300002c0e003103417009000f0009f1070018003003012711c3510f04000f0009f1070017002a09f1070018002a1200"; + +static struct msgb *msgb_from_hex(unsigned int size, const char *hex) +{ + struct msgb *msg = msgb_alloc(size, "test_cbsp"); + OSMO_ASSERT(msg); + msg->l1h = msgb_put(msg, osmo_hexparse(hex, msg->data, msgb_tailroom(msg))); + msg->l2h = msg->l1h + sizeof(struct cbsp_header); + return msg; +} + +static void test_decode(void) +{ + struct msgb *msg; + struct osmo_cbsp_decoded *cbsp_dec; + + printf("=== %s start ===\n", __func__); + + msg = msgb_from_hex(sizeof(write_repl_fail_with_failure_list), + write_repl_fail_with_failure_list); + + cbsp_dec = osmo_cbsp_decode(NULL, msg); + OSMO_ASSERT(cbsp_dec); + + talloc_free(cbsp_dec); + msgb_free(msg); + + printf("=== %s end ===\n", __func__); +} + +int main(int argc, char **argv) +{ + test_decode(); + + return EXIT_SUCCESS; +} diff --git a/tests/smscb/cbsp_test.ok b/tests/smscb/cbsp_test.ok new file mode 100644 index 00000000..a837de57 --- /dev/null +++ b/tests/smscb/cbsp_test.ok @@ -0,0 +1,2 @@ +=== test_decode start === +=== test_decode end === diff --git a/tests/smscb/gsm0341_test.c b/tests/smscb/gsm0341_test.c index c400f5c8..966a00fd 100644 --- a/tests/smscb/gsm0341_test.c +++ b/tests/smscb/gsm0341_test.c @@ -12,10 +12,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * */ #include <string.h> @@ -29,7 +25,7 @@ #include <osmocom/core/utils.h> #include <osmocom/core/msgb.h> -struct gsm341_ms_message *gen_msg_from_text(uint16_t msg_id, const char *text) +struct gsm341_ms_message *gen_msg_from_text(uint16_t msg_id, uint8_t msg_code, const char *text) { struct gsm341_ms_message *cbmsg; int text_len = strlen(text); @@ -38,11 +34,11 @@ struct gsm341_ms_message *gen_msg_from_text(uint16_t msg_id, const char *text) uint8_t payload[text_len]; int payload_octets; - srand(time(NULL)); + //srand(time(NULL)); gsm_7bit_encode_n(payload, sizeof(payload), text, &payload_octets); //cbmsg = gsm0341_build_msg(NULL, 0, rand(), 0, msg_id, 0x0f, 1, 1, payload, payload_octets); - cbmsg = gsm0341_build_msg(NULL, 0, rand(), 0, msg_id, 0x00, 1, 1, payload, payload_octets); + cbmsg = gsm0341_build_msg(NULL, 0, msg_code, 0, msg_id, 0x00, 1, 1, payload, payload_octets); printf("%s\n", osmo_hexdump_nospc((uint8_t *)cbmsg, sizeof(*cbmsg)+payload_octets)); @@ -54,6 +50,7 @@ int main(int argc, char **argv) uint16_t msg_id = GSM341_MSGID_ETWS_CMAS_MONTHLY_TEST; char *text = "Mahlzeit!"; char tbuf[GSM341_MAX_CHARS+1]; + struct gsm341_ms_message *cbmsg; if (argc > 1) msg_id = atoi(argv[1]); @@ -67,7 +64,8 @@ int main(int argc, char **argv) sizeof(tbuf)-strlen(text)); tbuf[GSM341_MAX_CHARS] = 0; - gen_msg_from_text(msg_id, tbuf); + cbmsg = gen_msg_from_text(msg_id, 1, tbuf); + talloc_free(cbmsg); return EXIT_SUCCESS; } diff --git a/tests/smscb/gsm0341_test.ok b/tests/smscb/gsm0341_test.ok new file mode 100644 index 00000000..600797c3 --- /dev/null +++ b/tests/smscb/gsm0341_test.ok @@ -0,0 +1 @@ +0010111c0011cd309aad2fa7e9a146a3d168341a8d46a3d168341a8d46a3d168341a8d46a3d168341a8d46a3d168341a8d46a3d168341a8d46a3d168341a8d46a3d168341a8d46a3d168341a8d46a3d168341a8d46a3d100 diff --git a/tests/smscb/smscb_test.c b/tests/smscb/smscb_test.c index 5925f69b..3b6b74d3 100644 --- a/tests/smscb/smscb_test.c +++ b/tests/smscb/smscb_test.c @@ -12,10 +12,6 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * */ #include <osmocom/gsm/protocol/gsm_03_41.h> |