Philipp Maier | 9828d28 | 2021-01-06 20:40:23 +0100 | [diff] [blame] | 1 | /* Test routines for the BSSGP implementation in libosmogb |
| 2 | * |
| 3 | * (C) 2020 by sysmocom - s.f.m.c. GmbH |
| 4 | * Author: Philipp Maier <pmaier@sysmocom.de> |
| 5 | * |
| 6 | * Skeleton based on bssgp_fc_test.c |
| 7 | * (C) 2012 by Harald Welte <laforge@gnumonks.org> |
| 8 | * |
| 9 | * SPDX-License-Identifier: GPL-2.0+ |
| 10 | */ |
| 11 | |
| 12 | #undef _GNU_SOURCE |
| 13 | #define _GNU_SOURCE |
| 14 | |
| 15 | #include <osmocom/core/application.h> |
| 16 | #include <osmocom/core/utils.h> |
| 17 | #include <osmocom/gprs/gprs_bssgp.h> |
| 18 | #include <osmocom/gprs/gprs_ns.h> |
| 19 | #include <osmocom/gprs/gprs_bssgp_rim.h> |
| 20 | |
| 21 | #include <stdio.h> |
| 22 | #include <stdlib.h> |
| 23 | #include <stdint.h> |
| 24 | #include <string.h> |
| 25 | #include <unistd.h> |
| 26 | |
Philipp Maier | 7450f77 | 2021-01-06 20:56:43 +0100 | [diff] [blame] | 27 | void dump_rim_ri(struct bssgp_rim_routing_info *ri) |
| 28 | { |
| 29 | switch (ri->discr) { |
| 30 | case BSSGP_RIM_ROUTING_INFO_GERAN: |
| 31 | printf("GERAN cell identifier\n"); |
| 32 | printf(" * mcc: %u\n", ri->geran.raid.mcc); |
| 33 | printf(" mnc: %u\n", ri->geran.raid.mnc); |
| 34 | printf(" mnc 3 digits: %u\n", ri->geran.raid.mnc_3_digits); |
| 35 | printf(" lac: %u\n", ri->geran.raid.lac); |
| 36 | printf(" rac: %u\n", ri->geran.raid.rac); |
| 37 | printf(" * cell id: %04x\n", ri->geran.cid); |
| 38 | break; |
| 39 | case BSSGP_RIM_ROUTING_INFO_UTRAN: |
| 40 | printf("UTRAN RNC identifier\n"); |
| 41 | printf(" * mcc: %u\n", ri->utran.raid.mcc); |
| 42 | printf(" mnc: %u\n", ri->utran.raid.mnc); |
| 43 | printf(" mnc 3 digits: %u\n", ri->utran.raid.mnc_3_digits); |
| 44 | printf(" lac: %u\n", ri->utran.raid.lac); |
| 45 | printf(" rac: %u\n", ri->utran.raid.rac); |
| 46 | printf(" * rnc id: %04x\n", ri->utran.rncid); |
| 47 | break; |
| 48 | case BSSGP_RIM_ROUTING_INFO_EUTRAN: |
| 49 | printf("EUTRAN eNB identifier\n"); |
| 50 | printf(" * mcc: %u\n", ri->eutran.tai.mcc); |
| 51 | printf(" mnc: %u\n", ri->eutran.tai.mnc); |
| 52 | printf(" mnc 3 digits: %u\n", ri->eutran.tai.mnc_3_digits); |
| 53 | printf(" tac: %u\n", ri->eutran.tai.tac); |
| 54 | printf(" * global_enb_id: %s\n", |
| 55 | osmo_hexdump_nospc(ri->eutran.global_enb_id, |
| 56 | ri->eutran.global_enb_id_len)); |
| 57 | break; |
| 58 | default: |
| 59 | OSMO_ASSERT(false); |
| 60 | } |
| 61 | } |
| 62 | |
Harald Welte | e61d459 | 2022-11-03 11:05:58 +0100 | [diff] [blame] | 63 | static void test_bssgp_parse_rim_ri(void) |
Philipp Maier | 7450f77 | 2021-01-06 20:56:43 +0100 | [diff] [blame] | 64 | { |
| 65 | int rc; |
| 66 | struct bssgp_rim_routing_info result; |
| 67 | uint8_t testvec_geran[] = |
| 68 | { 0x00, 0x62, 0xf2, 0x24, 0x33, 0x90, 0x00, 0x51, 0xe1 }; |
| 69 | uint8_t testvec_utran[] = |
| 70 | { 0x01, 0x62, 0xf2, 0x24, 0x33, 0x90, 0x00, 0x51, 0xe1 }; |
| 71 | uint8_t testvec_eutran[] = |
| 72 | { 0x02, 0x62, 0xf2, 0x24, 0x33, 0x90, 0x00, 0x51, 0xe1 }; |
| 73 | |
| 74 | printf("----- %s START\n", __func__); |
| 75 | |
| 76 | rc = bssgp_parse_rim_ri(&result, testvec_geran, |
| 77 | sizeof(testvec_geran)); |
| 78 | printf("rc=%d\n", rc); |
| 79 | dump_rim_ri(&result); |
| 80 | printf("\n"); |
| 81 | |
| 82 | rc = bssgp_parse_rim_ri(&result, testvec_utran, |
| 83 | sizeof(testvec_utran)); |
| 84 | printf("rc=%d\n", rc); |
| 85 | dump_rim_ri(&result); |
| 86 | printf("\n"); |
| 87 | |
| 88 | rc = bssgp_parse_rim_ri(&result, testvec_eutran, |
| 89 | sizeof(testvec_eutran)); |
| 90 | printf("rc=%d\n", rc); |
| 91 | dump_rim_ri(&result); |
| 92 | printf("\n"); |
| 93 | |
| 94 | printf("----- %s END\n", __func__); |
| 95 | } |
| 96 | |
Harald Welte | e61d459 | 2022-11-03 11:05:58 +0100 | [diff] [blame] | 97 | static void test_bssgp_create_rim_ri(void) |
Philipp Maier | 7450f77 | 2021-01-06 20:56:43 +0100 | [diff] [blame] | 98 | { |
| 99 | int rc; |
| 100 | struct bssgp_rim_routing_info ri; |
| 101 | uint8_t result[15]; |
| 102 | |
| 103 | printf("----- %s START\n", __func__); |
| 104 | memset(&ri, 0, sizeof(ri)); |
| 105 | memset(result, 0, sizeof(result)); |
| 106 | ri.discr = BSSGP_RIM_ROUTING_INFO_GERAN; |
| 107 | |
| 108 | ri.geran.raid.mcc = 262; |
| 109 | ri.geran.raid.mnc = 42; |
| 110 | ri.geran.raid.mnc_3_digits = false; |
| 111 | ri.geran.raid.lac = 13200; |
| 112 | ri.geran.raid.rac = 0; |
| 113 | ri.geran.cid = 0x51e1; |
| 114 | dump_rim_ri(&ri); |
| 115 | rc = bssgp_create_rim_ri(result, &ri); |
| 116 | printf("rc=%d, ", rc); |
| 117 | if (rc > 0) |
| 118 | printf("result=%s", osmo_hexdump_nospc(result, rc)); |
| 119 | printf("\n\n"); |
| 120 | |
| 121 | memset(&ri, 0, sizeof(ri)); |
| 122 | memset(result, 0, sizeof(result)); |
| 123 | ri.discr = BSSGP_RIM_ROUTING_INFO_UTRAN; |
| 124 | ri.utran.raid.mcc = 262; |
| 125 | ri.utran.raid.mnc = 42; |
| 126 | ri.utran.raid.mnc_3_digits = 0; |
| 127 | ri.utran.raid.lac = 13200; |
| 128 | ri.utran.raid.rac = 0; |
| 129 | ri.utran.rncid = 0x51e1; |
| 130 | dump_rim_ri(&ri); |
| 131 | rc = bssgp_create_rim_ri(result, &ri); |
| 132 | printf("rc=%d, ", rc); |
| 133 | if (rc > 0) |
| 134 | printf("result=%s", osmo_hexdump_nospc(result, rc)); |
| 135 | printf("\n\n"); |
| 136 | |
| 137 | memset(&ri, 0, sizeof(ri)); |
| 138 | memset(result, 0, sizeof(result)); |
| 139 | ri.discr = BSSGP_RIM_ROUTING_INFO_EUTRAN; |
| 140 | ri.eutran.tai.mcc = 262; |
| 141 | ri.eutran.tai.mnc = 42; |
| 142 | ri.eutran.tai.mnc_3_digits = 0; |
| 143 | ri.eutran.tai.tac = 13200; |
| 144 | ri.eutran.global_enb_id[0] = 0x00; |
| 145 | ri.eutran.global_enb_id[1] = 0x51; |
| 146 | ri.eutran.global_enb_id[2] = 0xe1; |
| 147 | ri.eutran.global_enb_id_len = 3; |
| 148 | dump_rim_ri(&ri); |
| 149 | rc = bssgp_create_rim_ri(result, &ri); |
| 150 | printf("rc=%d, ", rc); |
| 151 | if (rc > 0) |
| 152 | printf("result=%s", osmo_hexdump_nospc(result, rc)); |
| 153 | printf("\n\n"); |
| 154 | |
| 155 | printf("----- %s END\n", __func__); |
| 156 | } |
| 157 | |
Philipp Maier | 9828d28 | 2021-01-06 20:40:23 +0100 | [diff] [blame] | 158 | void dump_bssgp_ran_inf_req_app_cont_nacc(struct bssgp_ran_inf_req_app_cont_nacc *app_cont) |
| 159 | { |
| 160 | printf(" app_cont: bssgp_ran_inf_req_app_cont_nacc:\n"); |
| 161 | printf(" reprt_cell.rai.lac.plmn.mcc = %u\n", app_cont->reprt_cell.rai.lac.plmn.mcc); |
| 162 | printf(" reprt_cell.rai.lac.plmn.mnc = %u\n", app_cont->reprt_cell.rai.lac.plmn.mnc); |
| 163 | printf(" reprt_cell.rai.lac.plmn.mnc_3_digits = %u\n", app_cont->reprt_cell.rai.lac.plmn.mnc_3_digits); |
| 164 | printf(" reprt_cell.rai.lac.lac = %u\n", app_cont->reprt_cell.rai.lac.lac); |
| 165 | printf(" reprt_cell.rai.rac = %u\n", app_cont->reprt_cell.rai.rac); |
| 166 | printf(" reprt_cell.cell_identity = %04x\n", app_cont->reprt_cell.cell_identity); |
| 167 | } |
| 168 | |
| 169 | void dump_bssgp_ran_inf_req_rim_cont(struct bssgp_ran_inf_req_rim_cont *rim_cont) |
| 170 | { |
| 171 | printf("bssgp_ran_inf_req_rim_cont:\n"); |
| 172 | printf(" app_id = %02x\n", rim_cont->app_id); |
| 173 | printf(" seq_num = %08x\n", rim_cont->seq_num); |
| 174 | printf(" pdu_ind.ack_requested = %u\n", rim_cont->pdu_ind.ack_requested); |
| 175 | printf(" pdu_ind.pdu_type_ext = %u\n", rim_cont->pdu_ind.pdu_type_ext); |
| 176 | printf(" prot_ver = %u\n", rim_cont->prot_ver); |
| 177 | switch (rim_cont->app_id) { |
| 178 | case BSSGP_RAN_INF_APP_ID_NACC: |
| 179 | dump_bssgp_ran_inf_req_app_cont_nacc(&rim_cont->u.app_cont_nacc); |
| 180 | break; |
| 181 | case BSSGP_RAN_INF_APP_ID_SI3: |
| 182 | case BSSGP_RAN_INF_APP_ID_MBMS: |
| 183 | case BSSGP_RAN_INF_APP_ID_SON: |
| 184 | case BSSGP_RAN_INF_APP_ID_UTRA_SI: |
| 185 | printf(" app_cont: (not implemented yet)\n"); |
| 186 | break; |
| 187 | default: |
| 188 | printf(" app_cont: (illegal application identifier)\n"); |
| 189 | } |
| 190 | if (rim_cont->son_trans_app_id) { |
| 191 | printf(" son_trans_app_id: %s\n", |
| 192 | osmo_hexdump_nospc(rim_cont->son_trans_app_id, rim_cont->son_trans_app_id_len)); |
Pau Espin Pedrol | e75fa1e | 2021-02-24 19:16:42 +0100 | [diff] [blame] | 193 | printf(" son_trans_app_id_len: %zu\n", rim_cont->son_trans_app_id_len); |
Philipp Maier | 9828d28 | 2021-01-06 20:40:23 +0100 | [diff] [blame] | 194 | } |
| 195 | } |
| 196 | |
Harald Welte | e61d459 | 2022-11-03 11:05:58 +0100 | [diff] [blame] | 197 | static void test_bssgp_dec_ran_inf_req_rim_cont_nacc(void) |
Philipp Maier | 9828d28 | 2021-01-06 20:40:23 +0100 | [diff] [blame] | 198 | { |
| 199 | int rc; |
| 200 | struct bssgp_ran_inf_req_rim_cont rim_cont_dec; |
| 201 | uint8_t testvec[] = |
| 202 | { 0x4b, 0x81, 0x01, 0x4c, 0x84, 0x00, 0x00, 0x00, 0x01, 0x4f, 0x81, 0x02, 0x55, 0x81, 0x01, 0x4d, 0x88, |
| 203 | 0x62, 0xf2, 0x24, 0x33, 0x90, 0x00, 0x51, 0xe1 }; |
| 204 | |
| 205 | printf("----- %s START\n", __func__); |
| 206 | |
| 207 | rc = bssgp_dec_ran_inf_req_rim_cont(&rim_cont_dec, testvec, sizeof(testvec)); |
| 208 | printf("rc=%d, ", rc); |
| 209 | if (rc == 0) |
| 210 | dump_bssgp_ran_inf_req_rim_cont(&rim_cont_dec); |
| 211 | |
| 212 | printf("----- %s END\n", __func__); |
| 213 | } |
| 214 | |
Harald Welte | e61d459 | 2022-11-03 11:05:58 +0100 | [diff] [blame] | 215 | static void test_bssgp_enc_ran_inf_req_rim_cont_nacc(void) |
Philipp Maier | 9828d28 | 2021-01-06 20:40:23 +0100 | [diff] [blame] | 216 | { |
| 217 | int rc; |
| 218 | struct bssgp_ran_inf_req_rim_cont rim_cont = { }; |
| 219 | uint8_t result[256]; |
| 220 | printf("----- %s START\n", __func__); |
| 221 | |
| 222 | rim_cont.app_id = BSSGP_RAN_INF_APP_ID_NACC; |
| 223 | rim_cont.seq_num = 1; |
| 224 | rim_cont.pdu_ind.ack_requested = 0; |
| 225 | rim_cont.pdu_ind.pdu_type_ext = 1; |
| 226 | rim_cont.prot_ver = 1; |
| 227 | rim_cont.son_trans_app_id = NULL; |
| 228 | rim_cont.son_trans_app_id_len = 0; |
| 229 | rim_cont.u.app_cont_nacc.reprt_cell.rai.lac.plmn.mcc = 262; |
| 230 | rim_cont.u.app_cont_nacc.reprt_cell.rai.lac.plmn.mnc = 42; |
| 231 | rim_cont.u.app_cont_nacc.reprt_cell.rai.lac.plmn.mnc_3_digits = 0; |
| 232 | rim_cont.u.app_cont_nacc.reprt_cell.rai.lac.lac = 13200; |
| 233 | rim_cont.u.app_cont_nacc.reprt_cell.rai.rac = 0; |
| 234 | rim_cont.u.app_cont_nacc.reprt_cell.cell_identity = 0x51e1; |
| 235 | |
| 236 | dump_bssgp_ran_inf_req_rim_cont(&rim_cont); |
| 237 | |
| 238 | rc = bssgp_enc_ran_inf_req_rim_cont(result, sizeof(result), &rim_cont); |
| 239 | printf("rc=%d, ", rc); |
| 240 | if (rc > 0) |
| 241 | printf("result=%s", osmo_hexdump_nospc(result, rc)); |
| 242 | printf("\n"); |
| 243 | printf("----- %s END\n", __func__); |
| 244 | } |
| 245 | |
| 246 | static void dump_bssgp_ran_inf_app_cont_nacc(struct bssgp_ran_inf_app_cont_nacc *app_cont) |
| 247 | { |
| 248 | unsigned int i; |
| 249 | unsigned int silen; |
| 250 | printf(" app_cont: bssgp_ran_inf_app_cont_nacc:\n"); |
| 251 | printf(" reprt_cell.rai.lac.plmn.mcc = %u\n", app_cont->reprt_cell.rai.lac.plmn.mcc); |
| 252 | printf(" reprt_cell.rai.lac.plmn.mnc = %u\n", app_cont->reprt_cell.rai.lac.plmn.mnc); |
| 253 | printf(" reprt_cell.rai.lac.plmn.mnc_3_digits = %u\n", app_cont->reprt_cell.rai.lac.plmn.mnc_3_digits); |
| 254 | printf(" reprt_cell.rai.lac.lac = %u\n", app_cont->reprt_cell.rai.lac.lac); |
| 255 | printf(" reprt_cell.rai.rac = %u\n", app_cont->reprt_cell.rai.rac); |
| 256 | printf(" reprt_cell.cell_identity = %04x\n", app_cont->reprt_cell.cell_identity); |
| 257 | printf(" type_psi = %u\n", app_cont->type_psi); |
| 258 | printf(" num_si = %u\n", app_cont->num_si); |
| 259 | |
| 260 | if (app_cont->type_psi) |
| 261 | silen = 22; |
| 262 | else |
| 263 | silen = 21; |
| 264 | |
| 265 | for (i = 0; i < app_cont->num_si; i++) |
| 266 | printf(" si[%u] = %s\n", i, osmo_hexdump_nospc(app_cont->si[i], silen)); |
| 267 | } |
| 268 | |
| 269 | static void dump_bssgp_app_err_cont_nacc(struct bssgp_app_err_cont_nacc *app_cont) |
| 270 | { |
| 271 | printf(" app_err_cont: bssgp_app_err_cont_nacc:\n"); |
| 272 | printf(" macc_cause = %02x\n", app_cont->nacc_cause); |
| 273 | if (app_cont->err_app_cont) { |
| 274 | printf(" err_app_cont: %s\n", osmo_hexdump_nospc(app_cont->err_app_cont, app_cont->err_app_cont_len)); |
Pau Espin Pedrol | e75fa1e | 2021-02-24 19:16:42 +0100 | [diff] [blame] | 275 | printf(" err_app_cont_len: %zu\n", app_cont->err_app_cont_len); |
Philipp Maier | 9828d28 | 2021-01-06 20:40:23 +0100 | [diff] [blame] | 276 | } |
| 277 | } |
| 278 | |
| 279 | static void dump_bssgp_ran_inf_rim_cont(struct bssgp_ran_inf_rim_cont *rim_cont) |
| 280 | { |
| 281 | printf("bssgp_ran_inf_rim_cont:\n"); |
| 282 | printf(" app_id = %02x\n", rim_cont->app_id); |
| 283 | printf(" seq_num = %08x\n", rim_cont->seq_num); |
| 284 | printf(" pdu_ind.ack_requested = %u\n", rim_cont->pdu_ind.ack_requested); |
| 285 | printf(" pdu_ind.pdu_type_ext = %u\n", rim_cont->pdu_ind.pdu_type_ext); |
| 286 | printf(" prot_ver = %u\n", rim_cont->prot_ver); |
| 287 | printf(" app_err = %u\n", rim_cont->app_err); |
| 288 | if (rim_cont->app_err) { |
| 289 | switch (rim_cont->app_id) { |
| 290 | case BSSGP_RAN_INF_APP_ID_NACC: |
| 291 | dump_bssgp_app_err_cont_nacc(&rim_cont->u.app_err_cont_nacc); |
| 292 | break; |
| 293 | case BSSGP_RAN_INF_APP_ID_SI3: |
| 294 | case BSSGP_RAN_INF_APP_ID_MBMS: |
| 295 | case BSSGP_RAN_INF_APP_ID_SON: |
| 296 | case BSSGP_RAN_INF_APP_ID_UTRA_SI: |
| 297 | printf(" app_err_cont: (not implemented yet)\n"); |
| 298 | break; |
| 299 | default: |
| 300 | printf(" app_err_cont: (illegal application identifier)\n"); |
| 301 | } |
| 302 | } else { |
| 303 | switch (rim_cont->app_id) { |
| 304 | case BSSGP_RAN_INF_APP_ID_NACC: |
| 305 | dump_bssgp_ran_inf_app_cont_nacc(&rim_cont->u.app_cont_nacc); |
| 306 | break; |
| 307 | case BSSGP_RAN_INF_APP_ID_SI3: |
| 308 | case BSSGP_RAN_INF_APP_ID_MBMS: |
| 309 | case BSSGP_RAN_INF_APP_ID_SON: |
| 310 | case BSSGP_RAN_INF_APP_ID_UTRA_SI: |
| 311 | printf(" app_cont: (not implemented yet)\n"); |
| 312 | break; |
| 313 | default: |
| 314 | printf(" app_cont: (illegal application identifier)\n"); |
| 315 | } |
| 316 | } |
| 317 | if (rim_cont->son_trans_app_id) { |
| 318 | printf(" son_trans_app_id: %s\n", |
| 319 | osmo_hexdump_nospc(rim_cont->son_trans_app_id, rim_cont->son_trans_app_id_len)); |
Pau Espin Pedrol | e75fa1e | 2021-02-24 19:16:42 +0100 | [diff] [blame] | 320 | printf(" son_trans_app_id_len: %zu\n", rim_cont->son_trans_app_id_len); |
Philipp Maier | 9828d28 | 2021-01-06 20:40:23 +0100 | [diff] [blame] | 321 | } |
| 322 | } |
| 323 | |
Harald Welte | e61d459 | 2022-11-03 11:05:58 +0100 | [diff] [blame] | 324 | static void test_bssgp_dec_ran_inf_rim_cont_nacc(void) |
Philipp Maier | 9828d28 | 2021-01-06 20:40:23 +0100 | [diff] [blame] | 325 | { |
| 326 | int rc; |
| 327 | struct bssgp_ran_inf_rim_cont rim_cont_dec; |
| 328 | uint8_t testvec[] = |
| 329 | { 0x4b, 0x81, 0x01, 0x4c, 0x84, 0x00, 0x00, 0x00, 0x02, 0x4f, 0x81, 0x02, 0x55, 0x81, 0x01, 0x4e, 0xc8, |
| 330 | 0x62, 0xf2, 0x24, 0x33, 0x4f, 0x00, 0x51, 0xe0, 0x06, 0x19, 0x8f, 0xb1, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 331 | 0x00, 0x00, |
| 332 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x79, 0x00, 0x00, 0x2b, 0x1b, 0x75, 0x30, 0x00, 0xf1, 0x10, |
| 333 | 0x23, 0x6e, |
| 334 | 0xc9, 0x03, 0x3c, 0x27, 0x47, 0x40, 0x79, 0x00, 0x00, 0x3c, 0x0b, 0x2b, 0x2b, 0x00, 0x90, 0x00, 0x18, |
| 335 | 0x5a, 0x6f, |
| 336 | 0xc9, 0xe0, 0x84, 0x10, 0xab, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b |
| 337 | }; |
| 338 | |
| 339 | printf("----- %s START\n", __func__); |
| 340 | |
| 341 | rc = bssgp_dec_ran_inf_rim_cont(&rim_cont_dec, testvec, sizeof(testvec)); |
| 342 | printf("rc=%d, ", rc); |
| 343 | if (rc == 0) |
| 344 | dump_bssgp_ran_inf_rim_cont(&rim_cont_dec); |
| 345 | |
| 346 | printf("----- %s END\n", __func__); |
| 347 | } |
| 348 | |
Harald Welte | e61d459 | 2022-11-03 11:05:58 +0100 | [diff] [blame] | 349 | static void test_bssgp_dec_ran_inf_rim_cont_err_nacc(void) |
Philipp Maier | 9828d28 | 2021-01-06 20:40:23 +0100 | [diff] [blame] | 350 | { |
| 351 | int rc; |
| 352 | struct bssgp_ran_inf_rim_cont rim_cont_dec; |
| 353 | uint8_t testvec[] = |
| 354 | { 0x4b, 0x81, 0x01, 0x4c, 0x84, 0x00, 0x00, 0x00, 0x01, 0x4f, 0x81, 0x02, 0x55, 0x81, 0x01, 0x56, 0x86, |
| 355 | 0x01, 0xaa, 0xbb, 0xcc, 0xdd, 0xee }; |
| 356 | |
| 357 | printf("----- %s START\n", __func__); |
| 358 | |
| 359 | rc = bssgp_dec_ran_inf_rim_cont(&rim_cont_dec, testvec, sizeof(testvec)); |
| 360 | printf("rc=%d, ", rc); |
| 361 | if (rc == 0) |
| 362 | dump_bssgp_ran_inf_rim_cont(&rim_cont_dec); |
| 363 | |
| 364 | printf("----- %s END\n", __func__); |
| 365 | } |
| 366 | |
Harald Welte | e61d459 | 2022-11-03 11:05:58 +0100 | [diff] [blame] | 367 | static void test_bssgp_enc_ran_inf_rim_cont_nacc(void) |
Philipp Maier | 9828d28 | 2021-01-06 20:40:23 +0100 | [diff] [blame] | 368 | { |
| 369 | int rc; |
| 370 | struct bssgp_ran_inf_rim_cont rim_cont = { }; |
| 371 | |
| 372 | uint8_t si1[] = |
| 373 | { 0x19, 0x8f, 0xb1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 374 | 0x79, 0x00, 0x00, 0x2b |
| 375 | }; |
| 376 | uint8_t si3[] = |
| 377 | { 0x1b, 0x75, 0x30, 0x00, 0xf1, 0x10, 0x23, 0x6e, 0xc9, 0x03, 0x3c, 0x27, 0x47, 0x40, 0x79, 0x00, 0x00, |
| 378 | 0x3c, 0x0b, 0x2b, 0x2b |
| 379 | }; |
| 380 | uint8_t si13[] = |
| 381 | { 0x00, 0x90, 0x00, 0x18, 0x5a, 0x6f, 0xc9, 0xe0, 0x84, 0x10, 0xab, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, |
| 382 | 0x2b, 0x2b, 0x2b, 0x2b |
| 383 | }; |
| 384 | |
| 385 | uint8_t result[256]; |
| 386 | printf("----- %s START\n", __func__); |
| 387 | |
| 388 | rim_cont.app_id = BSSGP_RAN_INF_APP_ID_NACC; |
| 389 | rim_cont.seq_num = 1; |
| 390 | rim_cont.pdu_ind.ack_requested = 0; |
| 391 | rim_cont.pdu_ind.pdu_type_ext = 1; |
| 392 | rim_cont.prot_ver = 1; |
| 393 | rim_cont.son_trans_app_id = NULL; |
| 394 | rim_cont.son_trans_app_id_len = 0; |
| 395 | rim_cont.app_err = false; |
| 396 | rim_cont.u.app_cont_nacc.reprt_cell.rai.lac.plmn.mcc = 262; |
| 397 | rim_cont.u.app_cont_nacc.reprt_cell.rai.lac.plmn.mnc = 42; |
| 398 | rim_cont.u.app_cont_nacc.reprt_cell.rai.lac.plmn.mnc_3_digits = 0; |
| 399 | rim_cont.u.app_cont_nacc.reprt_cell.rai.lac.lac = 13135; |
| 400 | rim_cont.u.app_cont_nacc.reprt_cell.rai.rac = 0; |
| 401 | rim_cont.u.app_cont_nacc.reprt_cell.cell_identity = 0x51e0; |
| 402 | rim_cont.u.app_cont_nacc.type_psi = 0; |
| 403 | rim_cont.u.app_cont_nacc.num_si = 3; |
| 404 | rim_cont.u.app_cont_nacc.si[0] = si1; |
| 405 | rim_cont.u.app_cont_nacc.si[1] = si3; |
| 406 | rim_cont.u.app_cont_nacc.si[2] = si13; |
| 407 | |
| 408 | dump_bssgp_ran_inf_rim_cont(&rim_cont); |
| 409 | |
| 410 | rc = bssgp_enc_ran_inf_rim_cont(result, sizeof(result), &rim_cont); |
| 411 | printf("rc=%d, ", rc); |
| 412 | if (rc > 0) |
| 413 | printf("result=%s", osmo_hexdump_nospc(result, rc)); |
| 414 | printf("\n"); |
| 415 | printf("----- %s END\n", __func__); |
| 416 | } |
| 417 | |
Harald Welte | e61d459 | 2022-11-03 11:05:58 +0100 | [diff] [blame] | 418 | static void test_bssgp_enc_ran_inf_rim_cont_err_nacc(void) |
Philipp Maier | 9828d28 | 2021-01-06 20:40:23 +0100 | [diff] [blame] | 419 | { |
| 420 | int rc; |
| 421 | struct bssgp_ran_inf_rim_cont rim_cont = { }; |
| 422 | uint8_t err_app_cont[] = { 0xaa, 0xbb, 0xcc, 0xdd, 0xee }; |
| 423 | |
| 424 | uint8_t result[256]; |
| 425 | printf("----- %s START\n", __func__); |
| 426 | |
| 427 | rim_cont.app_id = BSSGP_RAN_INF_APP_ID_NACC; |
| 428 | rim_cont.seq_num = 1; |
| 429 | rim_cont.pdu_ind.ack_requested = 0; |
| 430 | rim_cont.pdu_ind.pdu_type_ext = 1; |
| 431 | rim_cont.prot_ver = 1; |
| 432 | rim_cont.son_trans_app_id = NULL; |
| 433 | rim_cont.son_trans_app_id_len = 0; |
| 434 | rim_cont.app_err = true; |
| 435 | rim_cont.u.app_err_cont_nacc.nacc_cause = BSSGP_NACC_CAUSE_SYNTAX_ERR; |
| 436 | rim_cont.u.app_err_cont_nacc.err_app_cont = err_app_cont; |
| 437 | rim_cont.u.app_err_cont_nacc.err_app_cont_len = sizeof(err_app_cont); |
| 438 | dump_bssgp_ran_inf_rim_cont(&rim_cont); |
| 439 | |
| 440 | rc = bssgp_enc_ran_inf_rim_cont(result, sizeof(result), &rim_cont); |
| 441 | printf("rc=%d, ", rc); |
| 442 | if (rc > 0) |
| 443 | printf("result=%s", osmo_hexdump_nospc(result, rc)); |
| 444 | printf("\n"); |
| 445 | printf("----- %s END\n", __func__); |
| 446 | } |
| 447 | |
| 448 | static void dump_bssgp_ran_inf_ack_rim_cont(struct bssgp_ran_inf_ack_rim_cont *rim_cont) |
| 449 | { |
| 450 | printf("bssgp_ran_inf_ack_rim_cont:\n"); |
| 451 | printf(" app_id = %02x\n", rim_cont->app_id); |
| 452 | printf(" seq_num = %08x\n", rim_cont->seq_num); |
| 453 | printf(" prot_ver = %u\n", rim_cont->prot_ver); |
| 454 | if (rim_cont->son_trans_app_id) { |
| 455 | printf(" son_trans_app_id: %s\n", |
| 456 | osmo_hexdump_nospc(rim_cont->son_trans_app_id, rim_cont->son_trans_app_id_len)); |
Pau Espin Pedrol | e75fa1e | 2021-02-24 19:16:42 +0100 | [diff] [blame] | 457 | printf(" son_trans_app_id_len: %zu\n", rim_cont->son_trans_app_id_len); |
Philipp Maier | 9828d28 | 2021-01-06 20:40:23 +0100 | [diff] [blame] | 458 | } |
| 459 | } |
| 460 | |
Harald Welte | e61d459 | 2022-11-03 11:05:58 +0100 | [diff] [blame] | 461 | static void test_bssgp_dec_ran_inf_ack_rim_cont(void) |
Philipp Maier | 9828d28 | 2021-01-06 20:40:23 +0100 | [diff] [blame] | 462 | { |
| 463 | int rc; |
| 464 | struct bssgp_ran_inf_ack_rim_cont rim_cont_dec; |
| 465 | uint8_t testvec[] = { 0x4b, 0x81, 0x01, 0x4c, 0x84, 0x00, 0x00, 0x00, 0x01, 0x55, 0x81, 0x01 }; |
| 466 | |
| 467 | printf("----- %s START\n", __func__); |
| 468 | |
| 469 | rc = bssgp_dec_ran_inf_ack_rim_cont(&rim_cont_dec, testvec, sizeof(testvec)); |
| 470 | printf("rc=%d, ", rc); |
| 471 | if (rc == 0) |
| 472 | dump_bssgp_ran_inf_ack_rim_cont(&rim_cont_dec); |
| 473 | |
| 474 | printf("----- %s END\n", __func__); |
| 475 | } |
| 476 | |
Harald Welte | e61d459 | 2022-11-03 11:05:58 +0100 | [diff] [blame] | 477 | static void test_bssgp_enc_ran_inf_ack_rim_cont(void) |
Philipp Maier | 9828d28 | 2021-01-06 20:40:23 +0100 | [diff] [blame] | 478 | { |
| 479 | int rc; |
| 480 | struct bssgp_ran_inf_ack_rim_cont rim_cont = { }; |
| 481 | uint8_t result[256]; |
| 482 | printf("----- %s START\n", __func__); |
| 483 | |
| 484 | rim_cont.app_id = BSSGP_RAN_INF_APP_ID_NACC; |
| 485 | rim_cont.seq_num = 1; |
| 486 | rim_cont.prot_ver = 1; |
| 487 | rim_cont.son_trans_app_id = NULL; |
| 488 | rim_cont.son_trans_app_id_len = 0; |
| 489 | dump_bssgp_ran_inf_ack_rim_cont(&rim_cont); |
| 490 | |
| 491 | rc = bssgp_enc_ran_inf_ack_rim_cont(result, sizeof(result), &rim_cont); |
| 492 | printf("rc=%d, ", rc); |
| 493 | if (rc > 0) |
| 494 | printf("result=%s", osmo_hexdump_nospc(result, rc)); |
| 495 | printf("\n"); |
| 496 | printf("----- %s END\n", __func__); |
| 497 | } |
| 498 | |
| 499 | void dump_bssgp_ran_inf_err_rim_cont(struct bssgp_ran_inf_err_rim_cont *rim_cont) |
| 500 | { |
| 501 | printf("bssgp_ran_inf_err_rim_cont:\n"); |
| 502 | printf(" app_id = %02x\n", rim_cont->app_id); |
| 503 | printf(" cause = %02x\n", rim_cont->cause); |
| 504 | printf(" prot_ver = %u\n", rim_cont->prot_ver); |
| 505 | if (rim_cont->err_pdu) { |
| 506 | printf(" err_pdu: %s\n", osmo_hexdump_nospc(rim_cont->err_pdu, rim_cont->err_pdu_len)); |
Pau Espin Pedrol | e75fa1e | 2021-02-24 19:16:42 +0100 | [diff] [blame] | 507 | printf(" err_pdu_len: %zu\n", rim_cont->err_pdu_len); |
Philipp Maier | 9828d28 | 2021-01-06 20:40:23 +0100 | [diff] [blame] | 508 | } |
| 509 | if (rim_cont->son_trans_app_id) { |
| 510 | printf(" son_trans_app_id: %s\n", |
| 511 | osmo_hexdump_nospc(rim_cont->son_trans_app_id, rim_cont->son_trans_app_id_len)); |
Pau Espin Pedrol | e75fa1e | 2021-02-24 19:16:42 +0100 | [diff] [blame] | 512 | printf(" son_trans_app_id_len: %zu\n", rim_cont->son_trans_app_id_len); |
Philipp Maier | 9828d28 | 2021-01-06 20:40:23 +0100 | [diff] [blame] | 513 | } |
| 514 | } |
| 515 | |
Harald Welte | e61d459 | 2022-11-03 11:05:58 +0100 | [diff] [blame] | 516 | static void test_bssgp_dec_ran_inf_err_rim_cont(void) |
Philipp Maier | 9828d28 | 2021-01-06 20:40:23 +0100 | [diff] [blame] | 517 | { |
| 518 | int rc; |
| 519 | struct bssgp_ran_inf_err_rim_cont rim_cont_dec; |
| 520 | uint8_t testvec[] = |
| 521 | { 0x4b, 0x81, 0x17, 0x07, 0x81, 0x2b, 0x55, 0x81, 0x01, 0x15, 0x85, 0xaa, 0xbb, 0xcc, 0xdd, 0xee }; |
| 522 | |
| 523 | printf("----- %s START\n", __func__); |
| 524 | |
| 525 | rc = bssgp_dec_ran_inf_err_rim_cont(&rim_cont_dec, testvec, sizeof(testvec)); |
| 526 | printf("rc=%d, ", rc); |
| 527 | if (rc == 0) |
| 528 | dump_bssgp_ran_inf_err_rim_cont(&rim_cont_dec); |
| 529 | |
| 530 | printf("----- %s END\n", __func__); |
| 531 | } |
| 532 | |
Harald Welte | e61d459 | 2022-11-03 11:05:58 +0100 | [diff] [blame] | 533 | static void test_bssgp_enc_ran_inf_err_rim_cont(void) |
Philipp Maier | 9828d28 | 2021-01-06 20:40:23 +0100 | [diff] [blame] | 534 | { |
| 535 | int rc; |
| 536 | struct bssgp_ran_inf_err_rim_cont rim_cont = { }; |
| 537 | uint8_t err_pdu[] = { 0xaa, 0xbb, 0xcc, 0xdd, 0xee }; |
| 538 | uint8_t result[256]; |
| 539 | printf("----- %s START\n", __func__); |
| 540 | |
| 541 | rim_cont.app_id = 23; |
| 542 | rim_cont.cause = 0x2b; |
| 543 | rim_cont.prot_ver = 1; |
| 544 | rim_cont.err_pdu = err_pdu; |
| 545 | rim_cont.err_pdu_len = sizeof(err_pdu); |
| 546 | rim_cont.son_trans_app_id = NULL; |
| 547 | rim_cont.son_trans_app_id_len = 0; |
| 548 | dump_bssgp_ran_inf_err_rim_cont(&rim_cont); |
| 549 | |
| 550 | rc = bssgp_enc_ran_inf_err_rim_cont(result, sizeof(result), &rim_cont); |
| 551 | printf("rc=%d, ", rc); |
| 552 | if (rc > 0) |
| 553 | printf("result=%s", osmo_hexdump_nospc(result, rc)); |
| 554 | printf("\n"); |
| 555 | printf("----- %s END\n", __func__); |
| 556 | } |
| 557 | |
| 558 | void dump_bssgp_ran_inf_app_err_rim_cont(struct bssgp_ran_inf_app_err_rim_cont *rim_cont) |
| 559 | { |
| 560 | printf("bssgp_ran_inf_app_err_rim_cont:\n"); |
| 561 | printf(" app_id = %02x\n", rim_cont->app_id); |
| 562 | printf(" seq_num = %08x\n", rim_cont->seq_num); |
| 563 | printf(" pdu_ind.ack_requested = %u\n", rim_cont->pdu_ind.ack_requested); |
| 564 | printf(" pdu_ind.pdu_type_ext = %u\n", rim_cont->pdu_ind.pdu_type_ext); |
| 565 | printf(" prot_ver = %u\n", rim_cont->prot_ver); |
| 566 | switch (rim_cont->app_id) { |
| 567 | case BSSGP_RAN_INF_APP_ID_NACC: |
| 568 | dump_bssgp_app_err_cont_nacc(&rim_cont->u.app_err_cont_nacc); |
| 569 | break; |
| 570 | case BSSGP_RAN_INF_APP_ID_SI3: |
| 571 | case BSSGP_RAN_INF_APP_ID_MBMS: |
| 572 | case BSSGP_RAN_INF_APP_ID_SON: |
| 573 | case BSSGP_RAN_INF_APP_ID_UTRA_SI: |
| 574 | printf(" app_err_cont: (not implemented yet)\n"); |
| 575 | break; |
| 576 | default: |
| 577 | printf(" app_err_cont: (illegal application identifier)\n"); |
| 578 | } |
| 579 | } |
| 580 | |
Harald Welte | e61d459 | 2022-11-03 11:05:58 +0100 | [diff] [blame] | 581 | static void test_bssgp_dec_ran_inf_app_err_rim_cont_nacc(void) |
Philipp Maier | 9828d28 | 2021-01-06 20:40:23 +0100 | [diff] [blame] | 582 | { |
| 583 | int rc; |
| 584 | struct bssgp_ran_inf_app_err_rim_cont rim_cont_dec; |
| 585 | uint8_t testvec[] = |
| 586 | { 0x4b, 0x81, 0x01, 0x4c, 0x84, 0x00, 0x00, 0x00, 0x01, 0x4f, 0x81, 0x02, 0x55, 0x81, 0x01, 0x56, 0x85, |
| 587 | 0xaa, 0xbb, 0xcc, 0xdd, 0xee |
| 588 | }; |
| 589 | |
| 590 | printf("----- %s START\n", __func__); |
| 591 | |
| 592 | rc = bssgp_dec_ran_inf_app_err_rim_cont(&rim_cont_dec, testvec, sizeof(testvec)); |
| 593 | printf("rc=%d, ", rc); |
| 594 | if (rc == 0) |
| 595 | dump_bssgp_ran_inf_app_err_rim_cont(&rim_cont_dec); |
| 596 | |
| 597 | printf("----- %s END\n", __func__); |
| 598 | } |
| 599 | |
Harald Welte | e61d459 | 2022-11-03 11:05:58 +0100 | [diff] [blame] | 600 | static void test_bssgp_enc_ran_inf_app_err_rim_cont_nacc(void) |
Philipp Maier | 9828d28 | 2021-01-06 20:40:23 +0100 | [diff] [blame] | 601 | { |
| 602 | int rc; |
| 603 | struct bssgp_ran_inf_app_err_rim_cont rim_cont = { }; |
| 604 | uint8_t err_app_cont[] = { 0xaa, 0xbb, 0xcc, 0xdd, 0xee }; |
| 605 | uint8_t result[256]; |
| 606 | |
| 607 | printf("----- %s START\n", __func__); |
| 608 | rim_cont.app_id = BSSGP_RAN_INF_APP_ID_NACC; |
| 609 | rim_cont.seq_num = 1; |
| 610 | rim_cont.pdu_ind.ack_requested = 0; |
| 611 | rim_cont.pdu_ind.pdu_type_ext = 1; |
| 612 | rim_cont.prot_ver = 1; |
| 613 | rim_cont.u.app_err_cont_nacc.nacc_cause = BSSGP_NACC_CAUSE_SYNTAX_ERR; |
| 614 | rim_cont.u.app_err_cont_nacc.err_app_cont = err_app_cont; |
| 615 | rim_cont.u.app_err_cont_nacc.err_app_cont_len = sizeof(err_app_cont); |
| 616 | dump_bssgp_ran_inf_app_err_rim_cont(&rim_cont); |
| 617 | |
| 618 | rc = bssgp_enc_ran_inf_app_err_rim_cont(result, sizeof(result), &rim_cont); |
| 619 | printf("rc=%d, ", rc); |
| 620 | if (rc > 0) |
| 621 | printf("result=%s", osmo_hexdump_nospc(result, rc)); |
| 622 | printf("\n"); |
| 623 | printf("----- %s END\n", __func__); |
| 624 | } |
| 625 | |
Harald Welte | e61d459 | 2022-11-03 11:05:58 +0100 | [diff] [blame] | 626 | static void test_bssgp_dec_ran_inf_req_app_cont_nacc(void) |
Philipp Maier | 9828d28 | 2021-01-06 20:40:23 +0100 | [diff] [blame] | 627 | { |
| 628 | int rc; |
| 629 | struct bssgp_ran_inf_req_app_cont_nacc app_cont_dec; |
| 630 | uint8_t testvec[] = { 0x62, 0xf2, 0x24, 0x33, 0x90, 0x00, 0x51, 0xe1 }; |
| 631 | |
| 632 | printf("----- %s START\n", __func__); |
| 633 | |
| 634 | rc = bssgp_dec_ran_inf_req_app_cont_nacc(&app_cont_dec, testvec, sizeof(testvec)); |
| 635 | printf("rc=%d, ", rc); |
| 636 | if (rc == 0) |
| 637 | dump_bssgp_ran_inf_req_app_cont_nacc(&app_cont_dec); |
| 638 | |
| 639 | printf("----- %s END\n", __func__); |
| 640 | } |
| 641 | |
Harald Welte | e61d459 | 2022-11-03 11:05:58 +0100 | [diff] [blame] | 642 | static void test_bssgp_enc_ran_inf_req_app_cont_nacc(void) |
Philipp Maier | 9828d28 | 2021-01-06 20:40:23 +0100 | [diff] [blame] | 643 | { |
| 644 | int rc; |
| 645 | struct bssgp_ran_inf_req_app_cont_nacc app_cont = { }; |
| 646 | uint8_t result[256]; |
| 647 | printf("----- %s START\n", __func__); |
| 648 | |
| 649 | app_cont.reprt_cell.rai.lac.plmn.mcc = 262; |
| 650 | app_cont.reprt_cell.rai.lac.plmn.mnc = 42; |
| 651 | app_cont.reprt_cell.rai.lac.plmn.mnc_3_digits = 0; |
| 652 | app_cont.reprt_cell.rai.lac.lac = 13200; |
| 653 | app_cont.reprt_cell.rai.rac = 0; |
| 654 | app_cont.reprt_cell.cell_identity = 0x51e1; |
| 655 | dump_bssgp_ran_inf_req_app_cont_nacc(&app_cont); |
| 656 | |
| 657 | rc = bssgp_enc_ran_inf_req_app_cont_nacc(result, sizeof(result), &app_cont); |
| 658 | printf("rc=%d, ", rc); |
| 659 | if (rc > 0) |
| 660 | printf("result=%s", osmo_hexdump_nospc(result, rc)); |
| 661 | printf("\n"); |
| 662 | printf("----- %s END\n", __func__); |
| 663 | } |
| 664 | |
Harald Welte | e61d459 | 2022-11-03 11:05:58 +0100 | [diff] [blame] | 665 | static void test_bssgp_dec_ran_inf_app_cont_nacc(void) |
Philipp Maier | 9828d28 | 2021-01-06 20:40:23 +0100 | [diff] [blame] | 666 | { |
| 667 | int rc; |
| 668 | struct bssgp_ran_inf_app_cont_nacc app_cont_dec; |
| 669 | uint8_t testvec[] = |
| 670 | { 0x62, 0xf2, 0x24, 0x33, 0x4f, 0x00, 0x51, 0xe0, 0x06, 0x19, 0x8f, 0xb1, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 671 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x79, 0x00, 0x00, 0x2b, 0x1b, 0x75, 0x30, 0x00, 0xf1, 0x10, |
| 672 | 0x23, 0x6e, 0xc9, 0x03, 0x3c, 0x27, 0x47, 0x40, 0x79, 0x00, 0x00, 0x3c, 0x0b, 0x2b, 0x2b, 0x00, 0x90, 0x00, 0x18, |
| 673 | 0x5a, 0x6f, 0xc9, 0xe0, 0x84, 0x10, 0xab, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b }; |
| 674 | |
| 675 | printf("----- %s START\n", __func__); |
| 676 | |
| 677 | rc = bssgp_dec_ran_inf_app_cont_nacc(&app_cont_dec, testvec, sizeof(testvec)); |
| 678 | printf("rc=%d, ", rc); |
| 679 | if (rc == 0) |
| 680 | dump_bssgp_ran_inf_app_cont_nacc(&app_cont_dec); |
| 681 | |
| 682 | printf("----- %s END\n", __func__); |
| 683 | } |
| 684 | |
Harald Welte | e61d459 | 2022-11-03 11:05:58 +0100 | [diff] [blame] | 685 | static void test_bssgp_enc_ran_inf_app_cont_nacc(void) |
Philipp Maier | 9828d28 | 2021-01-06 20:40:23 +0100 | [diff] [blame] | 686 | { |
| 687 | int rc; |
| 688 | struct bssgp_ran_inf_app_cont_nacc app_cont = { }; |
| 689 | |
| 690 | uint8_t si1[] = |
| 691 | { 0x19, 0x8f, 0xb1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 692 | 0x79, 0x00, 0x00, 0x2b }; |
| 693 | uint8_t si3[] = |
| 694 | { 0x1b, 0x75, 0x30, 0x00, 0xf1, 0x10, 0x23, 0x6e, 0xc9, 0x03, 0x3c, 0x27, 0x47, 0x40, 0x79, 0x00, 0x00, |
| 695 | 0x3c, 0x0b, 0x2b, 0x2b }; |
| 696 | uint8_t si13[] = |
| 697 | { 0x00, 0x90, 0x00, 0x18, 0x5a, 0x6f, 0xc9, 0xe0, 0x84, 0x10, 0xab, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, |
| 698 | 0x2b, 0x2b, 0x2b, 0x2b }; |
| 699 | |
| 700 | uint8_t result[256]; |
| 701 | printf("----- %s START\n", __func__); |
| 702 | |
| 703 | app_cont.reprt_cell.rai.lac.plmn.mcc = 262; |
| 704 | app_cont.reprt_cell.rai.lac.plmn.mnc = 42; |
| 705 | app_cont.reprt_cell.rai.lac.plmn.mnc_3_digits = 0; |
| 706 | app_cont.reprt_cell.rai.lac.lac = 13135; |
| 707 | app_cont.reprt_cell.rai.rac = 0; |
| 708 | app_cont.reprt_cell.cell_identity = 0x51e1; |
| 709 | app_cont.type_psi = false; |
| 710 | app_cont.num_si = 3; |
| 711 | app_cont.si[0] = si1; |
| 712 | app_cont.si[1] = si3; |
| 713 | app_cont.si[2] = si13; |
| 714 | dump_bssgp_ran_inf_app_cont_nacc(&app_cont); |
| 715 | |
| 716 | rc = bssgp_enc_ran_inf_app_cont_nacc(result, sizeof(result), &app_cont); |
| 717 | printf("rc=%d, ", rc); |
| 718 | if (rc > 0) |
| 719 | printf("result=%s", osmo_hexdump_nospc(result, rc)); |
| 720 | printf("\n"); |
| 721 | printf("----- %s END\n", __func__); |
| 722 | } |
| 723 | |
Harald Welte | e61d459 | 2022-11-03 11:05:58 +0100 | [diff] [blame] | 724 | static void test_bssgp_dec_app_err_cont_nacc(void) |
Philipp Maier | 9828d28 | 2021-01-06 20:40:23 +0100 | [diff] [blame] | 725 | { |
| 726 | int rc; |
| 727 | struct bssgp_app_err_cont_nacc app_cont_dec; |
| 728 | uint8_t testvec[] = { 0x01, 0xaa, 0xbb, 0xcc, 0xdd, 0xee }; |
| 729 | |
| 730 | printf("----- %s START\n", __func__); |
| 731 | |
| 732 | rc = bssgp_dec_app_err_cont_nacc(&app_cont_dec, testvec, sizeof(testvec)); |
| 733 | printf("rc=%d, ", rc); |
| 734 | if (rc == 0) |
| 735 | dump_bssgp_app_err_cont_nacc(&app_cont_dec); |
| 736 | |
| 737 | printf("----- %s END\n", __func__); |
| 738 | } |
| 739 | |
Harald Welte | e61d459 | 2022-11-03 11:05:58 +0100 | [diff] [blame] | 740 | static void test_bssgp_enc_app_err_cont_nacc(void) |
Philipp Maier | 9828d28 | 2021-01-06 20:40:23 +0100 | [diff] [blame] | 741 | { |
| 742 | int rc; |
| 743 | struct bssgp_app_err_cont_nacc app_cont = { }; |
| 744 | uint8_t err_app_cont[] = { 0xaa, 0xbb, 0xcc, 0xdd, 0xee }; |
| 745 | uint8_t result[256]; |
| 746 | printf("----- %s START\n", __func__); |
| 747 | |
| 748 | app_cont.nacc_cause = BSSGP_NACC_CAUSE_SYNTAX_ERR; |
| 749 | app_cont.err_app_cont = err_app_cont; |
| 750 | app_cont.err_app_cont_len = sizeof(err_app_cont); |
| 751 | dump_bssgp_app_err_cont_nacc(&app_cont); |
| 752 | |
| 753 | rc = bssgp_enc_app_err_cont_nacc(result, sizeof(result), &app_cont); |
| 754 | printf("rc=%d, ", rc); |
| 755 | if (rc > 0) |
| 756 | printf("result=%s", osmo_hexdump_nospc(result, rc)); |
| 757 | printf("\n"); |
| 758 | printf("----- %s END\n", __func__); |
| 759 | } |
| 760 | |
| 761 | int bssgp_prim_cb(struct osmo_prim_hdr *oph, void *ctx) |
| 762 | { |
| 763 | return 0; |
| 764 | } |
| 765 | |
| 766 | int main(int argc, char **argv) |
| 767 | { |
| 768 | printf("===== BSSGP RIM test START\n"); |
| 769 | |
Philipp Maier | 7450f77 | 2021-01-06 20:56:43 +0100 | [diff] [blame] | 770 | /* RIM routing information */ |
| 771 | test_bssgp_parse_rim_ri(); |
| 772 | test_bssgp_create_rim_ri(); |
| 773 | |
Philipp Maier | 9828d28 | 2021-01-06 20:40:23 +0100 | [diff] [blame] | 774 | /* RIM containers */ |
| 775 | test_bssgp_dec_ran_inf_req_rim_cont_nacc(); |
| 776 | test_bssgp_enc_ran_inf_req_rim_cont_nacc(); |
| 777 | test_bssgp_dec_ran_inf_rim_cont_nacc(); |
| 778 | test_bssgp_dec_ran_inf_rim_cont_err_nacc(); |
| 779 | test_bssgp_enc_ran_inf_rim_cont_nacc(); |
| 780 | test_bssgp_enc_ran_inf_rim_cont_err_nacc(); |
| 781 | test_bssgp_dec_ran_inf_ack_rim_cont(); |
| 782 | test_bssgp_enc_ran_inf_ack_rim_cont(); |
| 783 | test_bssgp_dec_ran_inf_err_rim_cont(); |
| 784 | test_bssgp_enc_ran_inf_err_rim_cont(); |
| 785 | test_bssgp_dec_ran_inf_app_err_rim_cont_nacc(); |
| 786 | test_bssgp_enc_ran_inf_app_err_rim_cont_nacc(); |
| 787 | |
| 788 | /* Application containers */ |
| 789 | test_bssgp_dec_ran_inf_req_app_cont_nacc(); |
| 790 | test_bssgp_enc_ran_inf_req_app_cont_nacc(); |
| 791 | test_bssgp_dec_ran_inf_app_cont_nacc(); |
| 792 | test_bssgp_enc_ran_inf_app_cont_nacc(); |
| 793 | test_bssgp_dec_app_err_cont_nacc(); |
| 794 | test_bssgp_enc_app_err_cont_nacc(); |
| 795 | |
| 796 | printf("===== BSSGP RIM test END\n\n"); |
| 797 | |
| 798 | exit(EXIT_SUCCESS); |
| 799 | } |