blob: 2dbdded76d002923044857607ad33bac497aef08 [file] [log] [blame]
Pau Espin Pedrol9eb698a2022-08-05 13:58:17 +02001/*
2 * (C) 2022 by sysmocom - s.f.m.c. GmbH
3 * All Rights Reserved
4 *
5 * Author: Pau Espin Pedrol <pespin@sysmocom.de>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 */
18
19#include <string.h>
20#include <stdio.h>
21#include <stdlib.h>
22
23#include <osmocom/core/utils.h>
24#include <osmocom/core/msgb.h>
25
26#include <osmocom/gsm/protocol/gsm_48_049.h>
27#include <osmocom/gsm/cbsp.h>
28
29/*
30CBSP WRITE-REPLACE FAILURE
31 Message Type: WRITE-REPLACE FAILURE (3)
32 Message Length: 44
33 IE: Message Identifier: 0x0031
34 Information Element Identifier: Message Identifier (14)
35 Message Identifier: 0x0031
36 IE: New Serial Number: 0x4170
37 Information Element Identifier: New Serial Number (3)
38 New Serial Number: 0x4170
39 IE: Failure List: 2 items
40 Information Element Identifier: Failure List (9)
41 Information Element Length: 15
42 Failure List Item: MCC 901 International Mobile, shared code, MNC 70 Clementvale Baltic OÜ, LAC 0x0018, CI 0x0030: Cause Cell-identity-not-valid
43 Cell ID Discriminator: CGI (0)
44 Mobile Country Code (MCC): International Mobile, shared code (901)
45 Mobile Network Code (MNC): Clementvale Baltic OÜ (70)
46 Location Area Code (LAC): 0x0018
47 Cell Identifier (CI): 0x0030
48 Cause: Cell-identity-not-valid (0x03)
49 Failure List Item: LAC 02711, CI 0xc351: Cause LAI-or-LAC-not-valid
50 Cell ID Discriminator: LAC+CI (1)
51 Location Area Code (LAC): 0x2711
52 Cell Identifier (CI): 0xc351
53 Cause: LAI-or-LAC-not-valid (0x0f)
54 IE: Cell List (CGI): 2 items
55 Information Element Identifier: Cell List (4)
56 Information Element Length: 15
57 Cell ID Discriminator: CGI (0)
58 Cell List Item: MCC 901 International Mobile, shared code, MNC 70 Clementvale Baltic OÜ, LAC 0x0017, CI 0x002a
59 Mobile Country Code (MCC): International Mobile, shared code (901)
60 Mobile Network Code (MNC): Clementvale Baltic OÜ (70)
61 Location Area Code (LAC): 0x0017
62 Cell Identifier (CI): 0x002a
63 Cell List Item: MCC 901 International Mobile, shared code, MNC 70 Clementvale Baltic OÜ, LAC 0x0018, CI 0x002a
64 Mobile Country Code (MCC): International Mobile, shared code (901)
65 Mobile Network Code (MNC): Clementvale Baltic OÜ (70)
66 Location Area Code (LAC): 0x0018
67 Cell Identifier (CI): 0x002a
68 IE: Channel Indicator: basic channel
69 Information Element Identifier: Channel Indicator (18)
70 Channel Indicator: basic channel (0x00)
71*/
72static const char write_repl_fail_with_failure_list[] =
73 "0300002c0e003103417009000f0009f1070018003003012711c3510f04000f0009f1070017002a09f1070018002a1200";
74
75static struct msgb *msgb_from_hex(unsigned int size, const char *hex)
76{
77 struct msgb *msg = msgb_alloc(size, "test_cbsp");
78 OSMO_ASSERT(msg);
79 msg->l1h = msgb_put(msg, osmo_hexparse(hex, msg->data, msgb_tailroom(msg)));
80 msg->l2h = msg->l1h + sizeof(struct cbsp_header);
81 return msg;
82}
83
Harald Weltee61d4592022-11-03 11:05:58 +010084static void test_decode(void)
Pau Espin Pedrol9eb698a2022-08-05 13:58:17 +020085{
86 struct msgb *msg;
87 struct osmo_cbsp_decoded *cbsp_dec;
88
89 printf("=== %s start ===\n", __func__);
90
91 msg = msgb_from_hex(sizeof(write_repl_fail_with_failure_list),
92 write_repl_fail_with_failure_list);
93
94 cbsp_dec = osmo_cbsp_decode(NULL, msg);
95 OSMO_ASSERT(cbsp_dec);
96
97 talloc_free(cbsp_dec);
98 msgb_free(msg);
99
100 printf("=== %s end ===\n", __func__);
101}
102
103int main(int argc, char **argv)
104{
105 test_decode();
106
107 return EXIT_SUCCESS;
108}