2008-12-28 21:55:40 +00:00
|
|
|
/* simple test for the gsm0408 formatting functions */
|
|
|
|
/*
|
|
|
|
* (C) 2008 by Holger Hans Peter Freyther <zecke@selfish.org>
|
|
|
|
* All Rights Reserved
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
2011-01-01 14:25:50 +00:00
|
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2008-12-28 21:55:40 +00:00
|
|
|
* (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.
|
|
|
|
*
|
2011-01-01 14:25:50 +00:00
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2008-12-28 21:55:40 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2016-05-18 11:04:47 +00:00
|
|
|
#include <stdbool.h>
|
2010-03-04 09:55:40 +00:00
|
|
|
#include <arpa/inet.h>
|
|
|
|
|
2017-12-17 20:48:47 +00:00
|
|
|
#include <osmocom/bsc/gsm_data.h>
|
2017-09-04 13:15:32 +00:00
|
|
|
#include <osmocom/bsc/debug.h>
|
|
|
|
#include <osmocom/bsc/system_information.h>
|
|
|
|
#include <osmocom/bsc/abis_rsl.h>
|
2020-07-15 18:53:16 +00:00
|
|
|
#include <osmocom/bsc/bts.h>
|
2022-03-02 20:40:08 +00:00
|
|
|
#include <osmocom/bsc/bss.h>
|
2016-04-15 14:04:46 +00:00
|
|
|
|
2014-01-10 16:43:41 +00:00
|
|
|
#include <osmocom/core/application.h>
|
2018-03-04 22:45:05 +00:00
|
|
|
#include <osmocom/core/byteswap.h>
|
2016-04-15 14:04:46 +00:00
|
|
|
#include <osmocom/gsm/sysinfo.h>
|
2017-07-09 20:09:18 +00:00
|
|
|
#include <osmocom/gsm/gsm48.h>
|
2008-12-28 21:55:40 +00:00
|
|
|
|
2018-10-22 12:21:57 +00:00
|
|
|
#include <osmocom/bsc/gsm_04_08_rr.h>
|
|
|
|
|
2008-12-28 21:55:40 +00:00
|
|
|
#define COMPARE(result, op, value) \
|
|
|
|
if (!((result) op (value))) {\
|
|
|
|
fprintf(stderr, "Compare failed. Was %x should be %x in %s:%d\n",result, value, __FILE__, __LINE__); \
|
|
|
|
exit(-1); \
|
|
|
|
}
|
2009-08-20 06:41:24 +00:00
|
|
|
|
|
|
|
#define COMPARE_STR(result, value) \
|
|
|
|
if (strcmp(result, value) != 0) { \
|
|
|
|
fprintf(stderr, "Compare failed. Was %s should be %s in %s:%d\n",result, value, __FILE__, __LINE__); \
|
|
|
|
exit(-1); \
|
|
|
|
}
|
2008-12-28 21:55:40 +00:00
|
|
|
|
2014-01-13 13:43:40 +00:00
|
|
|
#define DBG(...)
|
|
|
|
|
|
|
|
#define VERIFY(res, cmp, wanted) \
|
|
|
|
if (!(res cmp wanted)) { \
|
|
|
|
printf("ASSERT failed: %s:%d Wanted: %d %s %d\n", \
|
2015-08-03 07:28:41 +00:00
|
|
|
__FILE__, __LINE__, (int) res, # cmp, (int) wanted); \
|
2014-01-13 13:43:40 +00:00
|
|
|
}
|
|
|
|
|
2017-05-12 15:00:30 +00:00
|
|
|
static inline void gen(struct gsm_bts *bts, const char *s)
|
2016-04-15 14:04:46 +00:00
|
|
|
{
|
2017-05-15 10:02:29 +00:00
|
|
|
int r;
|
|
|
|
|
2016-05-18 11:04:47 +00:00
|
|
|
bts->si_valid = 0;
|
|
|
|
bts->si_valid |= (1 << SYSINFO_TYPE_2quater);
|
2017-05-15 10:02:29 +00:00
|
|
|
|
|
|
|
printf("generating SI2quater for %zu EARFCNs and %zu UARFCNs...\n",
|
|
|
|
si2q_earfcn_count(&bts->si_common.si2quater_neigh_list), bts->si_common.uarfcn_length);
|
|
|
|
|
|
|
|
r = gsm_generate_si(bts, SYSINFO_TYPE_2quater);
|
2016-04-15 14:04:46 +00:00
|
|
|
if (r > 0)
|
2017-06-15 13:10:53 +00:00
|
|
|
for (bts->si2q_index = 0; bts->si2q_index < bts->si2q_count + 1; bts->si2q_index++)
|
|
|
|
printf("generated %s SI2quater [%02u/%02u]: [%d] %s\n",
|
|
|
|
GSM_BTS_HAS_SI(bts, SYSINFO_TYPE_2quater) ? "valid" : "invalid",
|
|
|
|
bts->si2q_index, bts->si2q_count, r,
|
|
|
|
osmo_hexdump((void *)GSM_BTS_SI2Q(bts, bts->si2q_index), GSM_MACBLOCK_LEN));
|
2016-04-15 14:04:46 +00:00
|
|
|
else
|
2017-05-12 15:00:30 +00:00
|
|
|
printf("%s() failed to generate SI2quater: %s\n", s, strerror(-r));
|
2016-04-15 14:04:46 +00:00
|
|
|
}
|
|
|
|
|
2017-05-15 10:02:29 +00:00
|
|
|
static inline void del_earfcn_b(struct gsm_bts *bts, uint16_t earfcn)
|
|
|
|
{
|
|
|
|
struct osmo_earfcn_si2q *e = &bts->si_common.si2quater_neigh_list;
|
|
|
|
int r = osmo_earfcn_del(e, earfcn);
|
|
|
|
if (r)
|
|
|
|
printf("failed to remove EARFCN %u: %s\n", earfcn, strerror(-r));
|
|
|
|
else
|
|
|
|
printf("removed EARFCN %u - ", earfcn);
|
|
|
|
|
|
|
|
gen(bts, __func__);
|
|
|
|
}
|
|
|
|
|
2017-05-12 15:00:30 +00:00
|
|
|
static inline void add_earfcn_b(struct gsm_bts *bts, uint16_t earfcn, uint8_t bw)
|
2016-04-20 13:57:14 +00:00
|
|
|
{
|
2017-05-12 15:00:30 +00:00
|
|
|
struct osmo_earfcn_si2q *e = &bts->si_common.si2quater_neigh_list;
|
|
|
|
int r = osmo_earfcn_add(e, earfcn, bw);
|
|
|
|
if (r)
|
|
|
|
printf("failed to add EARFCN %u: %s\n", earfcn, strerror(-r));
|
|
|
|
else
|
|
|
|
printf("added EARFCN %u - ", earfcn);
|
|
|
|
|
|
|
|
gen(bts, __func__);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void _bts_uarfcn_add(struct gsm_bts *bts, uint16_t arfcn, uint16_t scramble, bool diversity)
|
|
|
|
{
|
|
|
|
int r;
|
|
|
|
|
|
|
|
bts->u_offset = 0;
|
|
|
|
|
|
|
|
r = bts_uarfcn_add(bts, arfcn, scramble, diversity);
|
2016-04-20 13:57:14 +00:00
|
|
|
if (r < 0)
|
|
|
|
printf("failed to add UARFCN to SI2quater: %s\n", strerror(-r));
|
2017-06-15 13:10:53 +00:00
|
|
|
else {
|
|
|
|
bts->si2q_count = si2q_num(bts) - 1;
|
2017-05-12 15:00:30 +00:00
|
|
|
gen(bts, __func__);
|
2017-06-15 13:10:53 +00:00
|
|
|
}
|
2016-04-20 13:57:14 +00:00
|
|
|
}
|
|
|
|
|
2018-03-28 16:15:13 +00:00
|
|
|
#define bts_init(net) _bts_init(net, __func__)
|
|
|
|
static inline struct gsm_bts *_bts_init(struct gsm_network *net, const char *msg)
|
2016-12-14 13:51:40 +00:00
|
|
|
{
|
2020-12-01 16:25:28 +00:00
|
|
|
struct gsm_bts_sm *bts_sm = gsm_bts_sm_alloc(net, 0);
|
|
|
|
struct gsm_bts *bts = bts_sm->bts[0];
|
2017-12-18 17:19:49 +00:00
|
|
|
if (!bts) {
|
|
|
|
printf("BTS allocation failure in %s()\n", msg);
|
2016-12-14 13:51:40 +00:00
|
|
|
exit(1);
|
2017-12-18 17:19:49 +00:00
|
|
|
}
|
|
|
|
printf("BTS allocation OK in %s()\n", msg);
|
|
|
|
|
|
|
|
bts->network = net;
|
|
|
|
|
|
|
|
return bts;
|
|
|
|
}
|
|
|
|
|
2018-03-28 16:14:27 +00:00
|
|
|
#define bts_del(bts) _bts_del(bts, __func__)
|
|
|
|
static inline void _bts_del(struct gsm_bts *bts, const char *msg)
|
|
|
|
{
|
2022-07-21 20:39:11 +00:00
|
|
|
osmo_timer_del(&bts->acc_mgr.rotate_timer);
|
2018-03-28 16:14:27 +00:00
|
|
|
/* no need to llist_del(&bts->list), we never registered the bts there. */
|
2020-12-01 16:25:28 +00:00
|
|
|
talloc_free(bts->site_mgr);
|
2018-03-28 16:14:27 +00:00
|
|
|
printf("BTS deallocated OK in %s()\n", msg);
|
|
|
|
}
|
|
|
|
|
2017-12-18 17:19:49 +00:00
|
|
|
static inline void test_si2q_segfault(struct gsm_network *net)
|
|
|
|
{
|
2018-03-28 16:15:13 +00:00
|
|
|
struct gsm_bts *bts = bts_init(net);
|
2017-12-18 17:19:49 +00:00
|
|
|
printf("Test SI2quater UARFCN (same scrambling code and diversity):\n");
|
2016-12-14 13:51:40 +00:00
|
|
|
|
|
|
|
_bts_uarfcn_add(bts, 10564, 319, 0);
|
|
|
|
_bts_uarfcn_add(bts, 10612, 319, 0);
|
2017-05-12 15:00:30 +00:00
|
|
|
gen(bts, __func__);
|
2017-12-18 17:19:49 +00:00
|
|
|
|
2018-03-28 16:14:27 +00:00
|
|
|
bts_del(bts);
|
2016-12-14 13:51:40 +00:00
|
|
|
}
|
|
|
|
|
2017-12-18 17:19:49 +00:00
|
|
|
static inline void test_si2q_mu(struct gsm_network *net)
|
2016-12-19 12:41:48 +00:00
|
|
|
{
|
2018-03-28 16:15:13 +00:00
|
|
|
struct gsm_bts *bts = bts_init(net);
|
2016-12-19 12:41:48 +00:00
|
|
|
printf("Test SI2quater multiple UARFCNs:\n");
|
|
|
|
|
|
|
|
_bts_uarfcn_add(bts, 10564, 318, 0);
|
|
|
|
_bts_uarfcn_add(bts, 10612, 319, 0);
|
|
|
|
_bts_uarfcn_add(bts, 10612, 31, 0);
|
|
|
|
_bts_uarfcn_add(bts, 10612, 19, 0);
|
|
|
|
_bts_uarfcn_add(bts, 10613, 64, 0);
|
|
|
|
_bts_uarfcn_add(bts, 10613, 164, 0);
|
|
|
|
_bts_uarfcn_add(bts, 10613, 14, 0);
|
2017-12-18 17:19:49 +00:00
|
|
|
|
2018-03-28 16:14:27 +00:00
|
|
|
bts_del(bts);
|
2016-12-19 12:41:48 +00:00
|
|
|
}
|
|
|
|
|
2017-12-18 17:19:49 +00:00
|
|
|
static inline void test_si2q_u(struct gsm_network *net)
|
2016-04-15 14:04:46 +00:00
|
|
|
{
|
2018-03-28 16:15:13 +00:00
|
|
|
struct gsm_bts *bts = bts_init(net);
|
2016-04-20 13:57:13 +00:00
|
|
|
printf("Testing SYSINFO_TYPE_2quater UARFCN generation:\n");
|
|
|
|
|
2016-05-18 11:04:47 +00:00
|
|
|
/* first generate invalid SI as no UARFCN added */
|
2017-05-12 15:00:30 +00:00
|
|
|
gen(bts, __func__);
|
2017-06-15 13:10:53 +00:00
|
|
|
|
2016-05-18 11:04:47 +00:00
|
|
|
/* subsequent calls should produce valid SI if there's enough memory */
|
2016-04-20 13:57:14 +00:00
|
|
|
_bts_uarfcn_add(bts, 1982, 13, 1);
|
|
|
|
_bts_uarfcn_add(bts, 1982, 44, 0);
|
|
|
|
_bts_uarfcn_add(bts, 1982, 61, 1);
|
|
|
|
_bts_uarfcn_add(bts, 1982, 89, 1);
|
|
|
|
_bts_uarfcn_add(bts, 1982, 113, 0);
|
|
|
|
_bts_uarfcn_add(bts, 1982, 123, 0);
|
|
|
|
_bts_uarfcn_add(bts, 1982, 56, 1);
|
|
|
|
_bts_uarfcn_add(bts, 1982, 72, 1);
|
|
|
|
_bts_uarfcn_add(bts, 1982, 223, 1);
|
|
|
|
_bts_uarfcn_add(bts, 1982, 14, 0);
|
|
|
|
_bts_uarfcn_add(bts, 1982, 88, 0);
|
2017-12-18 17:19:49 +00:00
|
|
|
|
2018-03-28 16:14:27 +00:00
|
|
|
bts_del(bts);
|
2016-04-20 13:57:13 +00:00
|
|
|
}
|
|
|
|
|
2017-12-18 17:19:49 +00:00
|
|
|
static inline void test_si2q_e(struct gsm_network *net)
|
2016-04-20 13:57:13 +00:00
|
|
|
{
|
2018-03-28 16:15:13 +00:00
|
|
|
struct gsm_bts *bts = bts_init(net);
|
2016-04-20 13:57:13 +00:00
|
|
|
printf("Testing SYSINFO_TYPE_2quater EARFCN generation:\n");
|
2016-04-15 14:04:46 +00:00
|
|
|
|
2017-05-12 15:00:30 +00:00
|
|
|
bts->si_common.si2quater_neigh_list.arfcn = bts->si_common.data.earfcn_list;
|
|
|
|
bts->si_common.si2quater_neigh_list.meas_bw = bts->si_common.data.meas_bw_list;
|
2016-04-15 14:04:46 +00:00
|
|
|
bts->si_common.si2quater_neigh_list.length = MAX_EARFCN_LIST;
|
|
|
|
bts->si_common.si2quater_neigh_list.thresh_hi = 5;
|
|
|
|
|
|
|
|
osmo_earfcn_init(&bts->si_common.si2quater_neigh_list);
|
2017-06-15 13:10:53 +00:00
|
|
|
|
2016-05-18 11:04:47 +00:00
|
|
|
/* first generate invalid SI as no EARFCN added */
|
2017-05-12 15:00:30 +00:00
|
|
|
gen(bts, __func__);
|
2017-06-15 13:10:53 +00:00
|
|
|
|
2017-05-15 10:02:29 +00:00
|
|
|
/* subsequent calls should produce valid SI if there's enough memory and EARFCNs */
|
|
|
|
add_earfcn_b(bts, 1917, 5);
|
|
|
|
del_earfcn_b(bts, 1917);
|
2017-05-12 15:00:30 +00:00
|
|
|
add_earfcn_b(bts, 1917, 1);
|
|
|
|
add_earfcn_b(bts, 1932, OSMO_EARFCN_MEAS_INVALID);
|
|
|
|
add_earfcn_b(bts, 1937, 2);
|
|
|
|
add_earfcn_b(bts, 1945, OSMO_EARFCN_MEAS_INVALID);
|
|
|
|
add_earfcn_b(bts, 1965, OSMO_EARFCN_MEAS_INVALID);
|
|
|
|
add_earfcn_b(bts, 1967, 4);
|
|
|
|
add_earfcn_b(bts, 1982, 3);
|
2017-12-18 17:19:49 +00:00
|
|
|
|
2018-03-28 16:14:27 +00:00
|
|
|
bts_del(bts);
|
2016-04-15 14:04:46 +00:00
|
|
|
}
|
|
|
|
|
2017-12-18 17:19:49 +00:00
|
|
|
static inline void test_si2q_long(struct gsm_network *net)
|
2017-06-15 13:10:53 +00:00
|
|
|
{
|
2018-03-28 16:15:13 +00:00
|
|
|
struct gsm_bts *bts = bts_init(net);
|
2017-06-15 13:10:53 +00:00
|
|
|
printf("Testing SYSINFO_TYPE_2quater combined EARFCN & UARFCN generation:\n");
|
|
|
|
|
|
|
|
bts->si_common.si2quater_neigh_list.arfcn = bts->si_common.data.earfcn_list;
|
|
|
|
bts->si_common.si2quater_neigh_list.meas_bw = bts->si_common.data.meas_bw_list;
|
|
|
|
bts->si_common.si2quater_neigh_list.length = MAX_EARFCN_LIST;
|
|
|
|
bts->si_common.si2quater_neigh_list.thresh_hi = 5;
|
|
|
|
|
|
|
|
osmo_earfcn_init(&bts->si_common.si2quater_neigh_list);
|
|
|
|
|
|
|
|
bts_earfcn_add(bts, 1922, 11, 22, 8,32, 8);
|
|
|
|
bts_earfcn_add(bts, 1922, 11, 22, 8, 32, 8);
|
|
|
|
bts_earfcn_add(bts, 1924, 11, 12, 6, 11, 5);
|
|
|
|
bts_earfcn_add(bts, 1923, 11, 12, 6, 11, 5);
|
|
|
|
bts_earfcn_add(bts, 1925, 11, 12, 6, 11, 5);
|
|
|
|
bts_earfcn_add(bts, 2111, 11, 12, 6, 11, 5);
|
|
|
|
bts_earfcn_add(bts, 2112, 11, 12, 6, 11, 4);
|
|
|
|
bts_earfcn_add(bts, 2113, 11, 12, 6, 11, 3);
|
|
|
|
bts_earfcn_add(bts, 2114, 11, 12, 6, 11, 2);
|
|
|
|
bts_earfcn_add(bts, 2131, 11, 12, 6, 11, 5);
|
|
|
|
bts_earfcn_add(bts, 2132, 11, 12, 6, 11, 4);
|
|
|
|
bts_earfcn_add(bts, 2133, 11, 12, 6, 11, 3);
|
|
|
|
bts_earfcn_add(bts, 2134, 11, 12, 6, 11, 2);
|
|
|
|
bts_earfcn_add(bts, 2121, 11, 12, 6, 11, 5);
|
|
|
|
bts_earfcn_add(bts, 2122, 11, 12, 6, 11, 4);
|
|
|
|
bts_earfcn_add(bts, 2123, 11, 12, 6, 11, 3);
|
|
|
|
bts_earfcn_add(bts, 2124, 11, 12, 6, 11, 2);
|
|
|
|
_bts_uarfcn_add(bts, 1976, 13, 1);
|
|
|
|
_bts_uarfcn_add(bts, 1976, 38, 1);
|
|
|
|
_bts_uarfcn_add(bts, 1976, 44, 1);
|
|
|
|
_bts_uarfcn_add(bts, 1976, 120, 1);
|
|
|
|
_bts_uarfcn_add(bts, 1976, 140, 1);
|
|
|
|
_bts_uarfcn_add(bts, 1976, 163, 1);
|
|
|
|
_bts_uarfcn_add(bts, 1976, 166, 1);
|
|
|
|
_bts_uarfcn_add(bts, 1976, 217, 1);
|
|
|
|
_bts_uarfcn_add(bts, 1976, 224, 1);
|
|
|
|
_bts_uarfcn_add(bts, 1976, 225, 1);
|
|
|
|
_bts_uarfcn_add(bts, 1976, 226, 1);
|
2017-12-18 17:19:49 +00:00
|
|
|
|
2018-03-28 16:14:27 +00:00
|
|
|
bts_del(bts);
|
2017-06-15 13:10:53 +00:00
|
|
|
}
|
|
|
|
|
2017-12-18 17:19:49 +00:00
|
|
|
static void test_si_ba_ind(struct gsm_network *net)
|
2017-10-01 03:09:47 +00:00
|
|
|
{
|
2018-03-28 16:15:13 +00:00
|
|
|
struct gsm_bts *bts = bts_init(net);
|
2017-12-18 17:19:49 +00:00
|
|
|
|
2017-10-01 03:09:47 +00:00
|
|
|
const struct gsm48_system_information_type_2 *si2 =
|
|
|
|
(struct gsm48_system_information_type_2 *) GSM_BTS_SI(bts, SYSINFO_TYPE_2);
|
|
|
|
const struct gsm48_system_information_type_2bis *si2bis =
|
|
|
|
(struct gsm48_system_information_type_2bis *) GSM_BTS_SI(bts, SYSINFO_TYPE_2bis);
|
|
|
|
const struct gsm48_system_information_type_2ter *si2ter =
|
|
|
|
(struct gsm48_system_information_type_2ter *) GSM_BTS_SI(bts, SYSINFO_TYPE_2ter);
|
|
|
|
const struct gsm48_system_information_type_5 *si5 =
|
|
|
|
(struct gsm48_system_information_type_5 *) GSM_BTS_SI(bts, SYSINFO_TYPE_5);
|
|
|
|
const struct gsm48_system_information_type_5bis *si5bis =
|
|
|
|
(struct gsm48_system_information_type_5bis *) GSM_BTS_SI(bts, SYSINFO_TYPE_5bis);
|
|
|
|
const struct gsm48_system_information_type_5ter *si5ter =
|
|
|
|
(struct gsm48_system_information_type_5ter *) GSM_BTS_SI(bts, SYSINFO_TYPE_5ter);
|
|
|
|
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
bts->c0->arfcn = 23;
|
|
|
|
|
|
|
|
printf("Testing if BA-IND is set as expected in SI2xxx and SI5xxx\n");
|
|
|
|
|
|
|
|
rc = gsm_generate_si(bts, SYSINFO_TYPE_2);
|
|
|
|
OSMO_ASSERT(rc > 0);
|
|
|
|
printf("SI2: %s\n", osmo_hexdump((uint8_t *)si2, rc));
|
|
|
|
/* Validate BA-IND == 0 */
|
|
|
|
OSMO_ASSERT(!(si2->bcch_frequency_list[0] & 0x10));
|
|
|
|
|
|
|
|
rc = gsm_generate_si(bts, SYSINFO_TYPE_2bis);
|
|
|
|
OSMO_ASSERT(rc > 0);
|
|
|
|
printf("SI2bis: %s\n", osmo_hexdump((uint8_t *)si2bis, rc));
|
|
|
|
/* Validate BA-IND == 0 */
|
|
|
|
OSMO_ASSERT(!(si2bis->bcch_frequency_list[0] & 0x10));
|
|
|
|
|
|
|
|
rc = gsm_generate_si(bts, SYSINFO_TYPE_2ter);
|
|
|
|
OSMO_ASSERT(rc > 0);
|
|
|
|
printf("SI2ter: %s\n", osmo_hexdump((uint8_t *)si2ter, rc));
|
|
|
|
/* Validate BA-IND == 0 */
|
|
|
|
OSMO_ASSERT(!(si2ter->ext_bcch_frequency_list[0] & 0x10));
|
|
|
|
|
|
|
|
rc = gsm_generate_si(bts, SYSINFO_TYPE_5);
|
|
|
|
OSMO_ASSERT(rc > 0);
|
|
|
|
printf("SI5: %s\n", osmo_hexdump((uint8_t *)si5, rc));
|
|
|
|
/* Validate BA-IND == 1 */
|
|
|
|
OSMO_ASSERT(si5->bcch_frequency_list[0] & 0x10);
|
|
|
|
|
|
|
|
rc = gsm_generate_si(bts, SYSINFO_TYPE_5bis);
|
|
|
|
OSMO_ASSERT(rc > 0);
|
|
|
|
printf("SI5bis: %s\n", osmo_hexdump((uint8_t *)si5bis, rc));
|
|
|
|
/* Validate BA-IND == 1 */
|
|
|
|
OSMO_ASSERT(si5bis->bcch_frequency_list[0] & 0x10);
|
|
|
|
|
|
|
|
rc = gsm_generate_si(bts, SYSINFO_TYPE_5ter);
|
|
|
|
OSMO_ASSERT(rc > 0);
|
|
|
|
printf("SI5ter: %s\n", osmo_hexdump((uint8_t *)si5ter, rc));
|
|
|
|
/* Validate BA-IND == 1 */
|
|
|
|
OSMO_ASSERT(si5ter->bcch_frequency_list[0] & 0x10);
|
2018-03-28 16:14:27 +00:00
|
|
|
|
|
|
|
bts_del(bts);
|
2017-10-01 03:09:47 +00:00
|
|
|
}
|
|
|
|
|
2018-03-04 22:45:05 +00:00
|
|
|
struct test_gsm48_ra_id_by_bts {
|
|
|
|
struct osmo_plmn_id plmn;
|
|
|
|
uint16_t lac;
|
|
|
|
uint8_t rac;
|
|
|
|
struct gsm48_ra_id expect;
|
|
|
|
};
|
|
|
|
static const struct test_gsm48_ra_id_by_bts test_gsm48_ra_id_by_bts_data[] = {
|
|
|
|
{
|
|
|
|
.plmn = { .mcc = 1, .mnc = 2, .mnc_3_digits = false },
|
|
|
|
.lac = 3,
|
|
|
|
.rac = 4,
|
|
|
|
.expect = {
|
|
|
|
.digits = { 0x00, 0xf1, 0x20 },
|
|
|
|
.lac = 0x0300, /* network byte order of 3 */
|
|
|
|
.rac = 4,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.plmn = { .mcc = 1, .mnc = 2, .mnc_3_digits = true },
|
|
|
|
.lac = 3,
|
|
|
|
.rac = 4,
|
|
|
|
.expect = {
|
2018-03-05 01:09:40 +00:00
|
|
|
.digits = { 0x00, 0x21, 0x00 },
|
2018-03-04 22:45:05 +00:00
|
|
|
.lac = 0x0300, /* network byte order of 3 */
|
|
|
|
.rac = 4,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.plmn = { .mcc = 0, .mnc = 0, .mnc_3_digits = false },
|
|
|
|
.lac = 0,
|
|
|
|
.rac = 0,
|
|
|
|
.expect = {
|
|
|
|
.digits = { 0x00, 0xf0, 0x00 },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.plmn = { .mcc = 0, .mnc = 0, .mnc_3_digits = true },
|
|
|
|
.lac = 0,
|
|
|
|
.rac = 0,
|
|
|
|
.expect = {
|
2018-03-05 01:09:40 +00:00
|
|
|
.digits = {},
|
2018-03-04 22:45:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.plmn = { .mcc = 999, .mnc = 999, .mnc_3_digits = false },
|
|
|
|
.lac = 65535,
|
|
|
|
.rac = 255,
|
|
|
|
.expect = {
|
|
|
|
.digits = { 0x99, 0x99, 0x99 },
|
|
|
|
.lac = 0xffff,
|
|
|
|
.rac = 0xff,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.plmn = { .mcc = 909, .mnc = 90, .mnc_3_digits = false },
|
|
|
|
.lac = 0xabcd,
|
|
|
|
.rac = 0xab,
|
|
|
|
.expect = {
|
|
|
|
.digits = { 0x09, 0xf9, 0x09 },
|
|
|
|
.lac = 0xcdab,
|
|
|
|
.rac = 0xab,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.plmn = { .mcc = 909, .mnc = 90, .mnc_3_digits = true },
|
|
|
|
.lac = 0xabcd,
|
|
|
|
.rac = 0xab,
|
|
|
|
.expect = {
|
2018-03-05 01:09:40 +00:00
|
|
|
.digits = { 0x09, 0x09, 0x90 },
|
2018-03-04 22:45:05 +00:00
|
|
|
.lac = 0xcdab,
|
|
|
|
.rac = 0xab,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2022-11-03 12:06:34 +00:00
|
|
|
static void test_gsm48_ra_id_by_bts(void)
|
2018-03-04 22:45:05 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
bool pass = true;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(test_gsm48_ra_id_by_bts_data); i++) {
|
|
|
|
struct gsm_network net;
|
|
|
|
struct gsm_bts bts;
|
|
|
|
const struct test_gsm48_ra_id_by_bts *t = &test_gsm48_ra_id_by_bts_data[i];
|
|
|
|
struct gsm48_ra_id result = {};
|
|
|
|
bool ok;
|
|
|
|
|
2018-03-05 01:09:40 +00:00
|
|
|
net.plmn = t->plmn;
|
2018-03-04 22:45:05 +00:00
|
|
|
bts.network = &net;
|
|
|
|
bts.location_area_code = t->lac;
|
|
|
|
bts.gprs.rac = t->rac;
|
|
|
|
|
2018-02-22 02:19:05 +00:00
|
|
|
gsm48_ra_id_by_bts(&result, &bts);
|
2018-03-04 22:45:05 +00:00
|
|
|
|
|
|
|
ok = (t->expect.digits[0] == result.digits[0])
|
|
|
|
&& (t->expect.digits[1] == result.digits[1])
|
|
|
|
&& (t->expect.digits[2] == result.digits[2])
|
|
|
|
&& (t->expect.lac == result.lac)
|
|
|
|
&& (t->expect.rac == result.rac);
|
|
|
|
printf("%s[%d]: digits='%02x%02x%02x' lac=0x%04x=htons(%u) rac=0x%02x=%u %s\n",
|
|
|
|
__func__, i,
|
|
|
|
result.digits[0], result.digits[1], result.digits[2],
|
|
|
|
result.lac, osmo_ntohs(result.lac), result.rac, result.rac,
|
|
|
|
ok ? "pass" : "FAIL");
|
|
|
|
pass = pass && ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
OSMO_ASSERT(pass);
|
|
|
|
}
|
|
|
|
|
2022-11-03 12:06:34 +00:00
|
|
|
static void test_gsm48_multirate_config(void)
|
2018-10-22 12:21:57 +00:00
|
|
|
{
|
|
|
|
struct gsm48_multi_rate_conf *gsm48_ie;
|
|
|
|
struct amr_multirate_conf mr;
|
|
|
|
int rc;
|
AMR config cleanup step 3: generate AMR LV on msg composition
Firstly, do not store the encoded AMR length-value bits in gsm_lchan->*
before an activation/modify has actually succeeded.
And secondly, do not store the AMR LV structure in struct gsm_lchan at
all, but only generate the TLV exactly when a message is being composed.
In gsm48_multirate_config(), generate the LV directly to a msgb instead
of a static buffer first. gsm0408_test.c expected output verifies that
the generated LV bytes remain unchanged.
In lchan_mr_config(), introduce a target mr_conf argument, so that Chan
Act and Mode Modify may generate the filtered AMR config to different
locations (lchan->{activate,modify}.mr_conf_filtered).
Only after receiving an ACK for Activate/Modify, set
lchan->current_mr_conf from lchan->{activate,modify}.mr_conf_filtered.
Use the properly scoped lchan->activate.mr_conf_filtered for Chan Act,
lchan->modify.mr_conf_filtered for Mode Modify and
new_lchan->current_mr_conf for Handover Command as appropriate.
Related: SYS#5315 OS#4940 OS#3787 OS#3833
Change-Id: Ie57f9d0e3912632903d9740291225bfd1634ed47
2021-04-29 17:58:52 +00:00
|
|
|
struct msgb *msg = msgb_alloc(32, "test_gsm48_multirate_config");
|
2018-10-22 12:21:57 +00:00
|
|
|
|
|
|
|
memset(&mr, 0, sizeof(mr));
|
|
|
|
|
|
|
|
/* Use some made up threshold and hysteresis values */
|
|
|
|
mr.ms_mode[0].threshold = 11;
|
|
|
|
mr.ms_mode[1].threshold = 12;
|
|
|
|
mr.ms_mode[2].threshold = 13;
|
|
|
|
mr.ms_mode[0].hysteresis = 15;
|
|
|
|
mr.ms_mode[1].hysteresis = 12;
|
|
|
|
mr.ms_mode[2].hysteresis = 8;
|
|
|
|
|
|
|
|
gsm48_ie = (struct gsm48_multi_rate_conf *)&mr.gsm48_ie;
|
|
|
|
gsm48_ie->ver = 1;
|
|
|
|
gsm48_ie->m5_90 = 1;
|
|
|
|
gsm48_ie->m7_40 = 1;
|
|
|
|
gsm48_ie->m7_95 = 1;
|
|
|
|
gsm48_ie->m12_2 = 1;
|
|
|
|
|
|
|
|
/* Test #1: Normal configuration with 4 active set members */
|
|
|
|
mr.ms_mode[0].mode = 2;
|
|
|
|
mr.ms_mode[1].mode = 4;
|
|
|
|
mr.ms_mode[2].mode = 5;
|
|
|
|
mr.ms_mode[3].mode = 7;
|
AMR config cleanup step 3: generate AMR LV on msg composition
Firstly, do not store the encoded AMR length-value bits in gsm_lchan->*
before an activation/modify has actually succeeded.
And secondly, do not store the AMR LV structure in struct gsm_lchan at
all, but only generate the TLV exactly when a message is being composed.
In gsm48_multirate_config(), generate the LV directly to a msgb instead
of a static buffer first. gsm0408_test.c expected output verifies that
the generated LV bytes remain unchanged.
In lchan_mr_config(), introduce a target mr_conf argument, so that Chan
Act and Mode Modify may generate the filtered AMR config to different
locations (lchan->{activate,modify}.mr_conf_filtered).
Only after receiving an ACK for Activate/Modify, set
lchan->current_mr_conf from lchan->{activate,modify}.mr_conf_filtered.
Use the properly scoped lchan->activate.mr_conf_filtered for Chan Act,
lchan->modify.mr_conf_filtered for Mode Modify and
new_lchan->current_mr_conf for Handover Command as appropriate.
Related: SYS#5315 OS#4940 OS#3787 OS#3833
Change-Id: Ie57f9d0e3912632903d9740291225bfd1634ed47
2021-04-29 17:58:52 +00:00
|
|
|
msgb_trim(msg, 0);
|
|
|
|
rc = gsm48_multirate_config(msg, gsm48_ie, mr.ms_mode, 4);
|
2018-10-22 12:21:57 +00:00
|
|
|
OSMO_ASSERT(rc == 0);
|
|
|
|
printf("gsm48_multirate_config(): rc=%i, lv=%s\n", rc,
|
AMR config cleanup step 3: generate AMR LV on msg composition
Firstly, do not store the encoded AMR length-value bits in gsm_lchan->*
before an activation/modify has actually succeeded.
And secondly, do not store the AMR LV structure in struct gsm_lchan at
all, but only generate the TLV exactly when a message is being composed.
In gsm48_multirate_config(), generate the LV directly to a msgb instead
of a static buffer first. gsm0408_test.c expected output verifies that
the generated LV bytes remain unchanged.
In lchan_mr_config(), introduce a target mr_conf argument, so that Chan
Act and Mode Modify may generate the filtered AMR config to different
locations (lchan->{activate,modify}.mr_conf_filtered).
Only after receiving an ACK for Activate/Modify, set
lchan->current_mr_conf from lchan->{activate,modify}.mr_conf_filtered.
Use the properly scoped lchan->activate.mr_conf_filtered for Chan Act,
lchan->modify.mr_conf_filtered for Mode Modify and
new_lchan->current_mr_conf for Handover Command as appropriate.
Related: SYS#5315 OS#4940 OS#3787 OS#3833
Change-Id: Ie57f9d0e3912632903d9740291225bfd1634ed47
2021-04-29 17:58:52 +00:00
|
|
|
osmo_hexdump_nospc(msg->data, msg->len));
|
2018-10-22 12:21:57 +00:00
|
|
|
|
|
|
|
/* Test #2: 4 active set members, but wrong mode order: */
|
|
|
|
mr.ms_mode[3].mode = 2;
|
|
|
|
mr.ms_mode[2].mode = 4;
|
|
|
|
mr.ms_mode[1].mode = 5;
|
|
|
|
mr.ms_mode[0].mode = 7;
|
AMR config cleanup step 3: generate AMR LV on msg composition
Firstly, do not store the encoded AMR length-value bits in gsm_lchan->*
before an activation/modify has actually succeeded.
And secondly, do not store the AMR LV structure in struct gsm_lchan at
all, but only generate the TLV exactly when a message is being composed.
In gsm48_multirate_config(), generate the LV directly to a msgb instead
of a static buffer first. gsm0408_test.c expected output verifies that
the generated LV bytes remain unchanged.
In lchan_mr_config(), introduce a target mr_conf argument, so that Chan
Act and Mode Modify may generate the filtered AMR config to different
locations (lchan->{activate,modify}.mr_conf_filtered).
Only after receiving an ACK for Activate/Modify, set
lchan->current_mr_conf from lchan->{activate,modify}.mr_conf_filtered.
Use the properly scoped lchan->activate.mr_conf_filtered for Chan Act,
lchan->modify.mr_conf_filtered for Mode Modify and
new_lchan->current_mr_conf for Handover Command as appropriate.
Related: SYS#5315 OS#4940 OS#3787 OS#3833
Change-Id: Ie57f9d0e3912632903d9740291225bfd1634ed47
2021-04-29 17:58:52 +00:00
|
|
|
msgb_trim(msg, 0);
|
|
|
|
rc = gsm48_multirate_config(msg, gsm48_ie, mr.ms_mode, 4);
|
2018-10-22 12:21:57 +00:00
|
|
|
OSMO_ASSERT(rc == -EINVAL);
|
|
|
|
|
|
|
|
/* Test #3: Normal configuration with 3 active set members */
|
|
|
|
mr.ms_mode[0].mode = 2;
|
|
|
|
mr.ms_mode[1].mode = 4;
|
|
|
|
mr.ms_mode[2].mode = 5;
|
2021-04-30 14:32:12 +00:00
|
|
|
mr.ms_mode[3].mode = 7;
|
2018-10-22 12:21:57 +00:00
|
|
|
gsm48_ie->m12_2 = 0;
|
|
|
|
mr.ms_mode[2].threshold = 0;
|
|
|
|
mr.ms_mode[2].hysteresis = 0;
|
|
|
|
|
AMR config cleanup step 3: generate AMR LV on msg composition
Firstly, do not store the encoded AMR length-value bits in gsm_lchan->*
before an activation/modify has actually succeeded.
And secondly, do not store the AMR LV structure in struct gsm_lchan at
all, but only generate the TLV exactly when a message is being composed.
In gsm48_multirate_config(), generate the LV directly to a msgb instead
of a static buffer first. gsm0408_test.c expected output verifies that
the generated LV bytes remain unchanged.
In lchan_mr_config(), introduce a target mr_conf argument, so that Chan
Act and Mode Modify may generate the filtered AMR config to different
locations (lchan->{activate,modify}.mr_conf_filtered).
Only after receiving an ACK for Activate/Modify, set
lchan->current_mr_conf from lchan->{activate,modify}.mr_conf_filtered.
Use the properly scoped lchan->activate.mr_conf_filtered for Chan Act,
lchan->modify.mr_conf_filtered for Mode Modify and
new_lchan->current_mr_conf for Handover Command as appropriate.
Related: SYS#5315 OS#4940 OS#3787 OS#3833
Change-Id: Ie57f9d0e3912632903d9740291225bfd1634ed47
2021-04-29 17:58:52 +00:00
|
|
|
msgb_trim(msg, 0);
|
|
|
|
rc = gsm48_multirate_config(msg, gsm48_ie, mr.ms_mode, 3);
|
2018-10-22 12:21:57 +00:00
|
|
|
OSMO_ASSERT(rc == 0);
|
|
|
|
printf("gsm48_multirate_config(): rc=%i, lv=%s\n", rc,
|
AMR config cleanup step 3: generate AMR LV on msg composition
Firstly, do not store the encoded AMR length-value bits in gsm_lchan->*
before an activation/modify has actually succeeded.
And secondly, do not store the AMR LV structure in struct gsm_lchan at
all, but only generate the TLV exactly when a message is being composed.
In gsm48_multirate_config(), generate the LV directly to a msgb instead
of a static buffer first. gsm0408_test.c expected output verifies that
the generated LV bytes remain unchanged.
In lchan_mr_config(), introduce a target mr_conf argument, so that Chan
Act and Mode Modify may generate the filtered AMR config to different
locations (lchan->{activate,modify}.mr_conf_filtered).
Only after receiving an ACK for Activate/Modify, set
lchan->current_mr_conf from lchan->{activate,modify}.mr_conf_filtered.
Use the properly scoped lchan->activate.mr_conf_filtered for Chan Act,
lchan->modify.mr_conf_filtered for Mode Modify and
new_lchan->current_mr_conf for Handover Command as appropriate.
Related: SYS#5315 OS#4940 OS#3787 OS#3833
Change-Id: Ie57f9d0e3912632903d9740291225bfd1634ed47
2021-04-29 17:58:52 +00:00
|
|
|
osmo_hexdump_nospc(msg->data, msg->len));
|
2018-10-22 12:21:57 +00:00
|
|
|
|
|
|
|
/* Test #4: 3 active set members, but wrong mode order: */
|
|
|
|
mr.ms_mode[0].mode = 2;
|
|
|
|
mr.ms_mode[2].mode = 4;
|
|
|
|
mr.ms_mode[1].mode = 5;
|
AMR config cleanup step 3: generate AMR LV on msg composition
Firstly, do not store the encoded AMR length-value bits in gsm_lchan->*
before an activation/modify has actually succeeded.
And secondly, do not store the AMR LV structure in struct gsm_lchan at
all, but only generate the TLV exactly when a message is being composed.
In gsm48_multirate_config(), generate the LV directly to a msgb instead
of a static buffer first. gsm0408_test.c expected output verifies that
the generated LV bytes remain unchanged.
In lchan_mr_config(), introduce a target mr_conf argument, so that Chan
Act and Mode Modify may generate the filtered AMR config to different
locations (lchan->{activate,modify}.mr_conf_filtered).
Only after receiving an ACK for Activate/Modify, set
lchan->current_mr_conf from lchan->{activate,modify}.mr_conf_filtered.
Use the properly scoped lchan->activate.mr_conf_filtered for Chan Act,
lchan->modify.mr_conf_filtered for Mode Modify and
new_lchan->current_mr_conf for Handover Command as appropriate.
Related: SYS#5315 OS#4940 OS#3787 OS#3833
Change-Id: Ie57f9d0e3912632903d9740291225bfd1634ed47
2021-04-29 17:58:52 +00:00
|
|
|
msgb_trim(msg, 0);
|
|
|
|
rc = gsm48_multirate_config(msg, gsm48_ie, mr.ms_mode, 3);
|
2018-10-22 12:21:57 +00:00
|
|
|
OSMO_ASSERT(rc == -EINVAL);
|
|
|
|
|
|
|
|
/* Test #5: Normal configuration with 2 active set members */
|
|
|
|
mr.ms_mode[0].mode = 2;
|
|
|
|
mr.ms_mode[1].mode = 4;
|
2021-04-30 14:32:12 +00:00
|
|
|
mr.ms_mode[2].mode = 5;
|
|
|
|
mr.ms_mode[3].mode = 7;
|
2018-10-22 12:21:57 +00:00
|
|
|
gsm48_ie->m7_95 = 0;
|
|
|
|
mr.ms_mode[1].threshold = 0;
|
|
|
|
mr.ms_mode[1].hysteresis = 0;
|
|
|
|
|
AMR config cleanup step 3: generate AMR LV on msg composition
Firstly, do not store the encoded AMR length-value bits in gsm_lchan->*
before an activation/modify has actually succeeded.
And secondly, do not store the AMR LV structure in struct gsm_lchan at
all, but only generate the TLV exactly when a message is being composed.
In gsm48_multirate_config(), generate the LV directly to a msgb instead
of a static buffer first. gsm0408_test.c expected output verifies that
the generated LV bytes remain unchanged.
In lchan_mr_config(), introduce a target mr_conf argument, so that Chan
Act and Mode Modify may generate the filtered AMR config to different
locations (lchan->{activate,modify}.mr_conf_filtered).
Only after receiving an ACK for Activate/Modify, set
lchan->current_mr_conf from lchan->{activate,modify}.mr_conf_filtered.
Use the properly scoped lchan->activate.mr_conf_filtered for Chan Act,
lchan->modify.mr_conf_filtered for Mode Modify and
new_lchan->current_mr_conf for Handover Command as appropriate.
Related: SYS#5315 OS#4940 OS#3787 OS#3833
Change-Id: Ie57f9d0e3912632903d9740291225bfd1634ed47
2021-04-29 17:58:52 +00:00
|
|
|
msgb_trim(msg, 0);
|
|
|
|
rc = gsm48_multirate_config(msg, gsm48_ie, mr.ms_mode, 2);
|
2018-10-22 12:21:57 +00:00
|
|
|
OSMO_ASSERT(rc == 0);
|
|
|
|
printf("gsm48_multirate_config(): rc=%i, lv=%s\n", rc,
|
AMR config cleanup step 3: generate AMR LV on msg composition
Firstly, do not store the encoded AMR length-value bits in gsm_lchan->*
before an activation/modify has actually succeeded.
And secondly, do not store the AMR LV structure in struct gsm_lchan at
all, but only generate the TLV exactly when a message is being composed.
In gsm48_multirate_config(), generate the LV directly to a msgb instead
of a static buffer first. gsm0408_test.c expected output verifies that
the generated LV bytes remain unchanged.
In lchan_mr_config(), introduce a target mr_conf argument, so that Chan
Act and Mode Modify may generate the filtered AMR config to different
locations (lchan->{activate,modify}.mr_conf_filtered).
Only after receiving an ACK for Activate/Modify, set
lchan->current_mr_conf from lchan->{activate,modify}.mr_conf_filtered.
Use the properly scoped lchan->activate.mr_conf_filtered for Chan Act,
lchan->modify.mr_conf_filtered for Mode Modify and
new_lchan->current_mr_conf for Handover Command as appropriate.
Related: SYS#5315 OS#4940 OS#3787 OS#3833
Change-Id: Ie57f9d0e3912632903d9740291225bfd1634ed47
2021-04-29 17:58:52 +00:00
|
|
|
osmo_hexdump_nospc(msg->data, msg->len));
|
2018-10-22 12:21:57 +00:00
|
|
|
|
|
|
|
/* Test #6: 2 active set members, but wrong mode order: */
|
|
|
|
mr.ms_mode[1].mode = 2;
|
|
|
|
mr.ms_mode[0].mode = 4;
|
AMR config cleanup step 3: generate AMR LV on msg composition
Firstly, do not store the encoded AMR length-value bits in gsm_lchan->*
before an activation/modify has actually succeeded.
And secondly, do not store the AMR LV structure in struct gsm_lchan at
all, but only generate the TLV exactly when a message is being composed.
In gsm48_multirate_config(), generate the LV directly to a msgb instead
of a static buffer first. gsm0408_test.c expected output verifies that
the generated LV bytes remain unchanged.
In lchan_mr_config(), introduce a target mr_conf argument, so that Chan
Act and Mode Modify may generate the filtered AMR config to different
locations (lchan->{activate,modify}.mr_conf_filtered).
Only after receiving an ACK for Activate/Modify, set
lchan->current_mr_conf from lchan->{activate,modify}.mr_conf_filtered.
Use the properly scoped lchan->activate.mr_conf_filtered for Chan Act,
lchan->modify.mr_conf_filtered for Mode Modify and
new_lchan->current_mr_conf for Handover Command as appropriate.
Related: SYS#5315 OS#4940 OS#3787 OS#3833
Change-Id: Ie57f9d0e3912632903d9740291225bfd1634ed47
2021-04-29 17:58:52 +00:00
|
|
|
msgb_trim(msg, 0);
|
|
|
|
rc = gsm48_multirate_config(msg, gsm48_ie, mr.ms_mode, 2);
|
2018-10-22 12:21:57 +00:00
|
|
|
OSMO_ASSERT(rc == -EINVAL);
|
|
|
|
|
|
|
|
/* Test #7: Normal configuration with 1 active set member */
|
|
|
|
mr.ms_mode[0].mode = 2;
|
2021-04-30 14:32:12 +00:00
|
|
|
mr.ms_mode[1].mode = 4;
|
|
|
|
mr.ms_mode[2].mode = 5;
|
|
|
|
mr.ms_mode[3].mode = 7;
|
2018-10-22 12:21:57 +00:00
|
|
|
gsm48_ie->m7_40 = 0;
|
|
|
|
mr.ms_mode[0].threshold = 0;
|
|
|
|
mr.ms_mode[0].hysteresis = 0;
|
|
|
|
|
AMR config cleanup step 3: generate AMR LV on msg composition
Firstly, do not store the encoded AMR length-value bits in gsm_lchan->*
before an activation/modify has actually succeeded.
And secondly, do not store the AMR LV structure in struct gsm_lchan at
all, but only generate the TLV exactly when a message is being composed.
In gsm48_multirate_config(), generate the LV directly to a msgb instead
of a static buffer first. gsm0408_test.c expected output verifies that
the generated LV bytes remain unchanged.
In lchan_mr_config(), introduce a target mr_conf argument, so that Chan
Act and Mode Modify may generate the filtered AMR config to different
locations (lchan->{activate,modify}.mr_conf_filtered).
Only after receiving an ACK for Activate/Modify, set
lchan->current_mr_conf from lchan->{activate,modify}.mr_conf_filtered.
Use the properly scoped lchan->activate.mr_conf_filtered for Chan Act,
lchan->modify.mr_conf_filtered for Mode Modify and
new_lchan->current_mr_conf for Handover Command as appropriate.
Related: SYS#5315 OS#4940 OS#3787 OS#3833
Change-Id: Ie57f9d0e3912632903d9740291225bfd1634ed47
2021-04-29 17:58:52 +00:00
|
|
|
msgb_trim(msg, 0);
|
|
|
|
rc = gsm48_multirate_config(msg, gsm48_ie, mr.ms_mode, 1);
|
2018-10-22 12:21:57 +00:00
|
|
|
OSMO_ASSERT(rc == 0);
|
|
|
|
printf("gsm48_multirate_config(): rc=%i, lv=%s\n", rc,
|
AMR config cleanup step 3: generate AMR LV on msg composition
Firstly, do not store the encoded AMR length-value bits in gsm_lchan->*
before an activation/modify has actually succeeded.
And secondly, do not store the AMR LV structure in struct gsm_lchan at
all, but only generate the TLV exactly when a message is being composed.
In gsm48_multirate_config(), generate the LV directly to a msgb instead
of a static buffer first. gsm0408_test.c expected output verifies that
the generated LV bytes remain unchanged.
In lchan_mr_config(), introduce a target mr_conf argument, so that Chan
Act and Mode Modify may generate the filtered AMR config to different
locations (lchan->{activate,modify}.mr_conf_filtered).
Only after receiving an ACK for Activate/Modify, set
lchan->current_mr_conf from lchan->{activate,modify}.mr_conf_filtered.
Use the properly scoped lchan->activate.mr_conf_filtered for Chan Act,
lchan->modify.mr_conf_filtered for Mode Modify and
new_lchan->current_mr_conf for Handover Command as appropriate.
Related: SYS#5315 OS#4940 OS#3787 OS#3833
Change-Id: Ie57f9d0e3912632903d9740291225bfd1634ed47
2021-04-29 17:58:52 +00:00
|
|
|
osmo_hexdump_nospc(msg->data, msg->len));
|
2018-10-22 12:21:57 +00:00
|
|
|
|
|
|
|
/* Test #8: 0 active set members: */
|
|
|
|
mr.ms_mode[0].mode = 0;
|
AMR config cleanup step 3: generate AMR LV on msg composition
Firstly, do not store the encoded AMR length-value bits in gsm_lchan->*
before an activation/modify has actually succeeded.
And secondly, do not store the AMR LV structure in struct gsm_lchan at
all, but only generate the TLV exactly when a message is being composed.
In gsm48_multirate_config(), generate the LV directly to a msgb instead
of a static buffer first. gsm0408_test.c expected output verifies that
the generated LV bytes remain unchanged.
In lchan_mr_config(), introduce a target mr_conf argument, so that Chan
Act and Mode Modify may generate the filtered AMR config to different
locations (lchan->{activate,modify}.mr_conf_filtered).
Only after receiving an ACK for Activate/Modify, set
lchan->current_mr_conf from lchan->{activate,modify}.mr_conf_filtered.
Use the properly scoped lchan->activate.mr_conf_filtered for Chan Act,
lchan->modify.mr_conf_filtered for Mode Modify and
new_lchan->current_mr_conf for Handover Command as appropriate.
Related: SYS#5315 OS#4940 OS#3787 OS#3833
Change-Id: Ie57f9d0e3912632903d9740291225bfd1634ed47
2021-04-29 17:58:52 +00:00
|
|
|
msgb_trim(msg, 0);
|
|
|
|
rc = gsm48_multirate_config(msg, gsm48_ie, mr.ms_mode, 1);
|
2018-10-22 12:21:57 +00:00
|
|
|
OSMO_ASSERT(rc == -EINVAL);
|
AMR config cleanup step 3: generate AMR LV on msg composition
Firstly, do not store the encoded AMR length-value bits in gsm_lchan->*
before an activation/modify has actually succeeded.
And secondly, do not store the AMR LV structure in struct gsm_lchan at
all, but only generate the TLV exactly when a message is being composed.
In gsm48_multirate_config(), generate the LV directly to a msgb instead
of a static buffer first. gsm0408_test.c expected output verifies that
the generated LV bytes remain unchanged.
In lchan_mr_config(), introduce a target mr_conf argument, so that Chan
Act and Mode Modify may generate the filtered AMR config to different
locations (lchan->{activate,modify}.mr_conf_filtered).
Only after receiving an ACK for Activate/Modify, set
lchan->current_mr_conf from lchan->{activate,modify}.mr_conf_filtered.
Use the properly scoped lchan->activate.mr_conf_filtered for Chan Act,
lchan->modify.mr_conf_filtered for Mode Modify and
new_lchan->current_mr_conf for Handover Command as appropriate.
Related: SYS#5315 OS#4940 OS#3787 OS#3833
Change-Id: Ie57f9d0e3912632903d9740291225bfd1634ed47
2021-04-29 17:58:52 +00:00
|
|
|
|
|
|
|
msgb_free(msg);
|
2018-10-22 12:21:57 +00:00
|
|
|
}
|
|
|
|
|
2022-03-02 20:40:08 +00:00
|
|
|
/* Similar to list_arfcn() from system_information.c, but uses printf().
|
|
|
|
* Another difference is that the text is printed even if n is 0. */
|
|
|
|
static void print_cell_chan_desc(uint8_t *cd, const char *text)
|
|
|
|
{
|
|
|
|
struct gsm_sysinfo_freq freq[1024];
|
|
|
|
unsigned int n = 0, i;
|
|
|
|
|
|
|
|
memset(freq, 0, sizeof(freq));
|
|
|
|
gsm48_decode_freq_list(freq, cd, 16, 0xce, 1);
|
|
|
|
|
|
|
|
printf("%s:", text);
|
|
|
|
for (i = 0; i < 1024; i++) {
|
|
|
|
if (!freq[i].mask)
|
|
|
|
continue;
|
|
|
|
printf(" %u", i);
|
|
|
|
n++;
|
|
|
|
}
|
|
|
|
if (!n)
|
|
|
|
printf(" (empty set)");
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_cell_chan_desc(struct gsm_network *net)
|
|
|
|
{
|
|
|
|
struct gsm_bts *bts = bts_init(net);
|
|
|
|
uint8_t cell_chan_desc[16];
|
|
|
|
|
|
|
|
printf("Testing generation of the Cell Channel Description IE:\n");
|
|
|
|
|
|
|
|
bts_model_unknown_init();
|
|
|
|
bts->type = GSM_BTS_TYPE_UNKNOWN;
|
|
|
|
bts->model = bts_model_find(bts->type);
|
|
|
|
OSMO_ASSERT(bts->model != NULL);
|
|
|
|
|
|
|
|
bts->band = GSM_BAND_900;
|
|
|
|
bts->c0->arfcn = 10; /* BCCH carrier */
|
|
|
|
|
|
|
|
/* Case a) only the BCCH carrier */
|
|
|
|
bitvec_set_bit_pos(&bts->si_common.cell_alloc, bts->c0->arfcn, ONE);
|
|
|
|
|
|
|
|
OSMO_ASSERT(generate_cell_chan_list(&cell_chan_desc[0], bts) == 0);
|
|
|
|
print_cell_chan_desc(&cell_chan_desc[0], "Case a) only the BCCH carrier");
|
|
|
|
|
|
|
|
/* Case b) more carriers from P-GSM band */
|
|
|
|
bitvec_set_bit_pos(&bts->si_common.cell_alloc, 1, ONE);
|
|
|
|
bitvec_set_bit_pos(&bts->si_common.cell_alloc, 3, ONE);
|
|
|
|
bitvec_set_bit_pos(&bts->si_common.cell_alloc, 64, ONE);
|
|
|
|
bitvec_set_bit_pos(&bts->si_common.cell_alloc, 99, ONE);
|
|
|
|
bitvec_set_bit_pos(&bts->si_common.cell_alloc, 124, ONE);
|
|
|
|
|
|
|
|
OSMO_ASSERT(generate_cell_chan_list(&cell_chan_desc[0], bts) == 0);
|
|
|
|
print_cell_chan_desc(&cell_chan_desc[0], "Case b) more carriers from P-GSM band");
|
|
|
|
|
|
|
|
/* Case c) more carriers from E-GSM band */
|
|
|
|
bitvec_set_bit_pos(&bts->si_common.cell_alloc, 0, ONE);
|
|
|
|
bitvec_set_bit_pos(&bts->si_common.cell_alloc, 975, ONE);
|
|
|
|
bitvec_set_bit_pos(&bts->si_common.cell_alloc, 1001, ONE);
|
|
|
|
bitvec_set_bit_pos(&bts->si_common.cell_alloc, 1023, ONE);
|
|
|
|
|
|
|
|
OSMO_ASSERT(generate_cell_chan_list(&cell_chan_desc[0], bts) == 0);
|
|
|
|
print_cell_chan_desc(&cell_chan_desc[0], "Case c) more carriers from E-GSM band");
|
|
|
|
|
|
|
|
bts_del(bts);
|
|
|
|
}
|
|
|
|
|
2018-02-13 16:16:44 +00:00
|
|
|
static const struct log_info_cat log_categories[] = {
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct log_info log_info = {
|
|
|
|
.cat = log_categories,
|
|
|
|
.num_cat = ARRAY_SIZE(log_categories),
|
|
|
|
};
|
|
|
|
|
2010-09-17 22:44:24 +00:00
|
|
|
int main(int argc, char **argv)
|
2008-12-28 21:55:40 +00:00
|
|
|
{
|
2017-12-18 17:19:49 +00:00
|
|
|
struct gsm_network *net;
|
|
|
|
|
2018-03-05 04:31:14 +00:00
|
|
|
tall_bsc_ctx = talloc_named_const(NULL, 0, "gsm0408_test");
|
|
|
|
|
|
|
|
osmo_init_logging2(tall_bsc_ctx, &log_info);
|
2014-01-10 16:43:41 +00:00
|
|
|
log_set_log_level(osmo_stderr_target, LOGL_INFO);
|
|
|
|
|
dissolve libbsc: move all to src/osmo-bsc, link .o files
Move all of libbsc/ into osmo-bsc/, and separate/move some implementations to
allow linking from utils/* and ipaccess/* without pulling in unccessary
dependencies.
Some utilities use gsm_network and gsm_bts structs, which already include data
structures for fairly advanced uses. Move initialization that only osmo-bsc
needs into new bsc_network_init() and bsc_bts_alloc_register() functions, so
that the leaner tools can use the old gsm_* versions without the need to link
everything (e.g. handover and lchan alloc code).
In some instances, there need to be stubs if to cut off linking "just before
the RSL level" and prevent dependencies from creeping in.
- abis_rsl_rcvmsg(): the only program currently interpreting RSL messages is
osmo-bsc, the utils are merely concerned with OML, if at all.
- paging_flush_bts(): ip.access nanobts models call this when the RSL link is
dropped. Only osmo-bsc actually needs to do anything there.
- on_gsm_ts_init(): the mechanism to trigger timeslot initialization is related
to OML, while this action to take on init would pull in RSL dependencies.
utils/ and ipaccess/ each have a stubs.c file to implement these stubs. Tests
implement stubs inline where required.
From src/utils/, src/ipaccess/ and tests/*/, link in .o files from osmo-bsc/.
In order for this to work, the osmo-bsc subdir must be built before the other
source trees. (An alternative would be to include the .c files as sources, but
that would re-compile them in every source tree. Not a large burden really, but
unless linking .o files gives problems, let's have the quicker build.)
Minor obvious cleanups creep in with this patch, I will not bother to name them
individually now unless code review asks me to.
Rationale:
1) libbsc has been separate to use it for osmo-nitb and osmo-bsc in the old
openbsc.git. This is no longer required, and spreading over libbsc and osmo-bsc
is distracting.
2) Recently, ridiculous linking requirements have made adding new functions
cumbersome, because libbsc has started depending on osmo-bsc/*.c
implementations: on gscon FSM and bssap functions. For example, neither
bs11_config nor ipaccess-config nor bts_test need handover_cfg or BSSMAP
message composition. It makes no sense to link the entire osmo-bsc to it, nor
do we want to keep adding stubs to each linking realm.
Change-Id: I36a586726f5818121abe54d25654819fc451d3bf
2018-05-26 23:26:31 +00:00
|
|
|
net = gsm_network_init(tall_bsc_ctx);
|
2017-12-18 17:19:49 +00:00
|
|
|
if (!net) {
|
|
|
|
printf("Network init failure.\n");
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
2021-03-09 16:11:45 +00:00
|
|
|
bsc_gsmnet = net;
|
2017-12-18 17:19:49 +00:00
|
|
|
|
|
|
|
test_si2q_segfault(net);
|
|
|
|
test_si2q_e(net);
|
|
|
|
test_si2q_u(net);
|
|
|
|
test_si2q_mu(net);
|
|
|
|
test_si2q_long(net);
|
2017-06-15 13:10:53 +00:00
|
|
|
|
2017-12-18 17:19:49 +00:00
|
|
|
test_si_ba_ind(net);
|
2017-10-01 03:09:47 +00:00
|
|
|
|
2018-03-04 22:45:05 +00:00
|
|
|
test_gsm48_ra_id_by_bts();
|
|
|
|
|
2018-10-22 12:21:57 +00:00
|
|
|
test_gsm48_multirate_config();
|
|
|
|
|
2022-03-02 20:40:08 +00:00
|
|
|
test_cell_chan_desc(net);
|
|
|
|
|
2012-01-06 14:03:28 +00:00
|
|
|
printf("Done.\n");
|
2017-06-15 13:10:53 +00:00
|
|
|
|
2012-01-06 14:03:28 +00:00
|
|
|
return EXIT_SUCCESS;
|
2008-12-28 21:55:40 +00:00
|
|
|
}
|