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>
|
|
|
|
|
2016-05-13 22:57:04 +00:00
|
|
|
#include <openbsc/common_bsc.h>
|
2008-12-28 21:55:40 +00:00
|
|
|
#include <openbsc/gsm_04_08.h>
|
2014-02-08 14:20:48 +00:00
|
|
|
#include <openbsc/gsm_04_11.h>
|
2009-08-20 06:41:24 +00:00
|
|
|
#include <openbsc/gsm_subscriber.h>
|
2017-05-15 10:02:29 +00:00
|
|
|
#include <openbsc/gsm_data_shared.h>
|
2009-08-20 06:41:24 +00:00
|
|
|
#include <openbsc/debug.h>
|
2014-01-10 16:43:41 +00:00
|
|
|
#include <openbsc/arfcn_range_encode.h>
|
2016-04-15 14:04:46 +00:00
|
|
|
#include <openbsc/system_information.h>
|
|
|
|
#include <openbsc/abis_rsl.h>
|
|
|
|
|
2014-01-10 16:43:41 +00:00
|
|
|
#include <osmocom/core/application.h>
|
2016-04-15 14:04:46 +00:00
|
|
|
#include <osmocom/gsm/sysinfo.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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-12-28 21:55:40 +00:00
|
|
|
/*
|
|
|
|
* Test Location Area Identifier formatting. Table 10.5.3 of 04.08
|
|
|
|
*/
|
|
|
|
static void test_location_area_identifier(void)
|
|
|
|
{
|
|
|
|
struct gsm48_loc_area_id lai48;
|
|
|
|
|
|
|
|
printf("Testing test location area identifier\n");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Test the default/test setup. Coming from
|
|
|
|
* bsc_hack.c dumps
|
|
|
|
*/
|
2010-03-04 09:55:40 +00:00
|
|
|
gsm48_generate_lai(&lai48, 1, 1, 1);
|
2008-12-28 21:55:40 +00:00
|
|
|
COMPARE(lai48.digits[0], ==, 0x00);
|
|
|
|
COMPARE(lai48.digits[1], ==, 0xF1);
|
|
|
|
COMPARE(lai48.digits[2], ==, 0x10);
|
|
|
|
COMPARE(lai48.lac, ==, htons(0x0001));
|
|
|
|
|
2010-03-04 09:55:40 +00:00
|
|
|
gsm48_generate_lai(&lai48, 602, 1, 15);
|
2008-12-28 21:55:40 +00:00
|
|
|
COMPARE(lai48.digits[0], ==, 0x06);
|
|
|
|
COMPARE(lai48.digits[1], ==, 0xF2);
|
|
|
|
COMPARE(lai48.digits[2], ==, 0x10);
|
|
|
|
COMPARE(lai48.lac, ==, htons(0x000f));
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2016-12-14 13:51:40 +00:00
|
|
|
static inline void test_si2q_segfault(void)
|
|
|
|
{
|
|
|
|
struct gsm_bts *bts;
|
|
|
|
struct gsm_network *network = bsc_network_init(tall_bsc_ctx, 1, 1, NULL);
|
|
|
|
printf("Test SI2quater UARFCN (same scrambling code and diversity):\n");
|
|
|
|
|
|
|
|
if (!network)
|
|
|
|
exit(1);
|
|
|
|
bts = gsm_bts_alloc(network);
|
|
|
|
|
|
|
|
_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__);
|
2016-12-14 13:51:40 +00:00
|
|
|
}
|
|
|
|
|
2016-12-19 12:41:48 +00:00
|
|
|
static inline void test_si2q_mu(void)
|
|
|
|
{
|
|
|
|
struct gsm_bts *bts;
|
|
|
|
struct gsm_network *network = bsc_network_init(tall_bsc_ctx, 1, 1, NULL);
|
|
|
|
printf("Test SI2quater multiple UARFCNs:\n");
|
|
|
|
|
|
|
|
if (!network)
|
|
|
|
exit(1);
|
|
|
|
bts = gsm_bts_alloc(network);
|
|
|
|
|
|
|
|
_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);
|
|
|
|
}
|
|
|
|
|
2016-04-20 13:57:13 +00:00
|
|
|
static inline void test_si2q_u(void)
|
2016-04-15 14:04:46 +00:00
|
|
|
{
|
|
|
|
struct gsm_bts *bts;
|
mscsplit: various preparations to separate MSC from BSC
Disable large parts of the code that depend on BSC presence. The code sections
disabled by #if BEFORE_MSCSPLIT shall be modified or dropped in the course of
adding the A-interface.
Don't set msg->lchan nor msg->dst.
Don't use lchan in libmsc.
Decouple lac from bts.
Prepare entry/exit point for MSC -> BSC and MSC -> RNC communication:
Add msc_ifaces.[hc], a_iface.c, with a general msc_tx_dtap() to redirect to
different interfaces depending on the actual subscriber connection.
While iu_tx() is going to be functional fairly soon, the a_tx() is going to be
just a dummy for some time (see comment).
Add Iu specific fields in gsm_subscriber_connection: the UE connection pointer
and an indicator for the Integrity Protection status on Iu (to be fully
implemented in later commits).
Add lac member to gsm_subscriber_connection, to allow decoupling from
bts->location_area_code. The conn->lac will actually be set in iu.c in an
upcoming commit ("add iucs.[hc]").
move to libcommon-cs: gsm48_extract_mi(), gsm48_paging_extract_mi().
libmsc: duplicate gsm0808 / gsm48 functions (towards BSC).
In osmo-nitb, libmsc would directly call the functions on the BSC level, not
always via the bsc_api. When separating libmsc from libbsc, some functions are
missing from the linkage.
Hence duplicate these functions to libmsc, add an msc_ prefix for clarity, also
add a _tx to gsm0808_cipher_mode():
* add msc_gsm0808_tx_cipher_mode() (dummy/stub)
* add msc_gsm48_tx_mm_serv_ack()
* add msc_gsm48_tx_mm_serv_rej()
Call these from libmsc instead of
* gsm0808_cipher_mode()
* gsm48_tx_mm_serv_ack()
* gsm48_tx_mm_serv_rej()
Also add a comment related to msc_gsm0808_tx_cipher_mode() in two places.
Remove internal RTP streaming code; OsmoNITB supported that, but for OsmoMSC,
this will be done with an external MGCP gateway.
Remove LCHAN_MODIFY from internal MNCC state machine.
Temporarily disable all paging to be able to link libmsc without libbsc.
Skip the paging part of channel_test because the paging is now disabled.
Employ fake paging shims in order for msc_vlr_tests to still work.
msc_compl_l3(): publish in .h, tweak return value. Use new libmsc enum values
for return val, to avoid dependency on libbsc headers. Make callable from
other scopes: publish in osmo_msc.h and remove 'static' in osmo_msc.c
add gsm_encr to subscr_conn
move subscr_request to gsm_subscriber.h
subscr_request_channel() -> subscr_request_conn()
move to libmsc: osmo_stats_vty_add_cmds()
gsm_04_08: remove apply_codec_restrictions()
gsm0408_test: use NULL for root ctx
move to libbsc: gsm_bts_neighbor()
move to libbsc: lchan_next_meas_rep()
move vty config for t3212 to network level (periodic lu)
remove unneccessary linking from some tests
remove handle_abisip_signal()
abis_rsl.c: don't use libvlr from libbsc
gsm_subscriber_connection: put the LAC here, so that it is available without
accessing conn->bts. In bsc_api.c, place this lac in conn for the sake of
transition: Iu and A will use this new field to pass the LAC around, but in a
completely separate OsmoBSC this is not actually needed. It can be removed
again from osmo-bsc.git when the time has come.
Siemens MRPCI: completely drop sending the MRPCI messages for now, they shall
be added in osmo-bsc once the A-Interface code has settled. See OS#2389.
Related: OS#1845 OS#2257 OS#2389
Change-Id: Id3705236350d5f69e447046b0a764bbabc3d493c
2017-05-08 13:12:20 +00:00
|
|
|
struct gsm_network *network = bsc_network_init(NULL, 1, 1, NULL);
|
2016-04-20 13:57:13 +00:00
|
|
|
printf("Testing SYSINFO_TYPE_2quater UARFCN generation:\n");
|
|
|
|
|
|
|
|
if (!network)
|
|
|
|
exit(1);
|
2017-06-15 13:10:53 +00:00
|
|
|
|
2016-04-20 13:57:13 +00:00
|
|
|
bts = gsm_bts_alloc(network);
|
|
|
|
|
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);
|
2016-04-20 13:57:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void test_si2q_e(void)
|
|
|
|
{
|
|
|
|
struct gsm_bts *bts;
|
mscsplit: various preparations to separate MSC from BSC
Disable large parts of the code that depend on BSC presence. The code sections
disabled by #if BEFORE_MSCSPLIT shall be modified or dropped in the course of
adding the A-interface.
Don't set msg->lchan nor msg->dst.
Don't use lchan in libmsc.
Decouple lac from bts.
Prepare entry/exit point for MSC -> BSC and MSC -> RNC communication:
Add msc_ifaces.[hc], a_iface.c, with a general msc_tx_dtap() to redirect to
different interfaces depending on the actual subscriber connection.
While iu_tx() is going to be functional fairly soon, the a_tx() is going to be
just a dummy for some time (see comment).
Add Iu specific fields in gsm_subscriber_connection: the UE connection pointer
and an indicator for the Integrity Protection status on Iu (to be fully
implemented in later commits).
Add lac member to gsm_subscriber_connection, to allow decoupling from
bts->location_area_code. The conn->lac will actually be set in iu.c in an
upcoming commit ("add iucs.[hc]").
move to libcommon-cs: gsm48_extract_mi(), gsm48_paging_extract_mi().
libmsc: duplicate gsm0808 / gsm48 functions (towards BSC).
In osmo-nitb, libmsc would directly call the functions on the BSC level, not
always via the bsc_api. When separating libmsc from libbsc, some functions are
missing from the linkage.
Hence duplicate these functions to libmsc, add an msc_ prefix for clarity, also
add a _tx to gsm0808_cipher_mode():
* add msc_gsm0808_tx_cipher_mode() (dummy/stub)
* add msc_gsm48_tx_mm_serv_ack()
* add msc_gsm48_tx_mm_serv_rej()
Call these from libmsc instead of
* gsm0808_cipher_mode()
* gsm48_tx_mm_serv_ack()
* gsm48_tx_mm_serv_rej()
Also add a comment related to msc_gsm0808_tx_cipher_mode() in two places.
Remove internal RTP streaming code; OsmoNITB supported that, but for OsmoMSC,
this will be done with an external MGCP gateway.
Remove LCHAN_MODIFY from internal MNCC state machine.
Temporarily disable all paging to be able to link libmsc without libbsc.
Skip the paging part of channel_test because the paging is now disabled.
Employ fake paging shims in order for msc_vlr_tests to still work.
msc_compl_l3(): publish in .h, tweak return value. Use new libmsc enum values
for return val, to avoid dependency on libbsc headers. Make callable from
other scopes: publish in osmo_msc.h and remove 'static' in osmo_msc.c
add gsm_encr to subscr_conn
move subscr_request to gsm_subscriber.h
subscr_request_channel() -> subscr_request_conn()
move to libmsc: osmo_stats_vty_add_cmds()
gsm_04_08: remove apply_codec_restrictions()
gsm0408_test: use NULL for root ctx
move to libbsc: gsm_bts_neighbor()
move to libbsc: lchan_next_meas_rep()
move vty config for t3212 to network level (periodic lu)
remove unneccessary linking from some tests
remove handle_abisip_signal()
abis_rsl.c: don't use libvlr from libbsc
gsm_subscriber_connection: put the LAC here, so that it is available without
accessing conn->bts. In bsc_api.c, place this lac in conn for the sake of
transition: Iu and A will use this new field to pass the LAC around, but in a
completely separate OsmoBSC this is not actually needed. It can be removed
again from osmo-bsc.git when the time has come.
Siemens MRPCI: completely drop sending the MRPCI messages for now, they shall
be added in osmo-bsc once the A-Interface code has settled. See OS#2389.
Related: OS#1845 OS#2257 OS#2389
Change-Id: Id3705236350d5f69e447046b0a764bbabc3d493c
2017-05-08 13:12:20 +00:00
|
|
|
struct gsm_network *network = bsc_network_init(NULL, 1, 1, NULL);
|
2016-04-20 13:57:13 +00:00
|
|
|
printf("Testing SYSINFO_TYPE_2quater EARFCN generation:\n");
|
2016-04-15 14:04:46 +00:00
|
|
|
|
|
|
|
if (!network)
|
|
|
|
exit(1);
|
2017-06-15 13:10:53 +00:00
|
|
|
|
2016-04-15 14:04:46 +00:00
|
|
|
bts = gsm_bts_alloc(network);
|
|
|
|
|
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);
|
2016-04-15 14:04:46 +00:00
|
|
|
}
|
|
|
|
|
2017-06-15 13:10:53 +00:00
|
|
|
static inline void test_si2q_long(void)
|
|
|
|
{
|
|
|
|
struct gsm_bts *bts;
|
|
|
|
struct gsm_network *network = bsc_network_init(tall_bsc_ctx, 1, 1, NULL);
|
|
|
|
printf("Testing SYSINFO_TYPE_2quater combined EARFCN & UARFCN generation:\n");
|
|
|
|
|
|
|
|
if (!network)
|
|
|
|
exit(1);
|
|
|
|
|
|
|
|
bts = gsm_bts_alloc(network);
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2009-08-20 06:41:24 +00:00
|
|
|
static void test_mi_functionality(void)
|
|
|
|
{
|
|
|
|
const char *imsi_odd = "987654321098763";
|
|
|
|
const char *imsi_even = "9876543210987654";
|
2011-04-18 15:04:00 +00:00
|
|
|
const uint32_t tmsi = 0xfabeacd0;
|
|
|
|
uint8_t mi[128];
|
2009-08-20 06:41:24 +00:00
|
|
|
unsigned int mi_len;
|
|
|
|
char mi_parsed[GSM48_MI_SIZE];
|
|
|
|
|
|
|
|
printf("Testing parsing and generating TMSI/IMSI\n");
|
|
|
|
|
|
|
|
/* tmsi code */
|
|
|
|
mi_len = gsm48_generate_mid_from_tmsi(mi, tmsi);
|
|
|
|
gsm48_mi_to_string(mi_parsed, sizeof(mi_parsed), mi + 2, mi_len - 2);
|
2016-03-17 13:41:26 +00:00
|
|
|
COMPARE((uint32_t)strtoul(mi_parsed, NULL, 10), ==, tmsi);
|
2009-08-20 06:41:24 +00:00
|
|
|
|
|
|
|
/* imsi code */
|
|
|
|
mi_len = gsm48_generate_mid_from_imsi(mi, imsi_odd);
|
|
|
|
gsm48_mi_to_string(mi_parsed, sizeof(mi_parsed), mi + 2, mi_len -2);
|
2011-05-07 10:12:48 +00:00
|
|
|
printf("hex: %s\n", osmo_hexdump(mi, mi_len));
|
2009-08-20 06:41:24 +00:00
|
|
|
COMPARE_STR(mi_parsed, imsi_odd);
|
|
|
|
|
|
|
|
mi_len = gsm48_generate_mid_from_imsi(mi, imsi_even);
|
|
|
|
gsm48_mi_to_string(mi_parsed, sizeof(mi_parsed), mi + 2, mi_len -2);
|
2011-05-07 10:12:48 +00:00
|
|
|
printf("hex: %s\n", osmo_hexdump(mi, mi_len));
|
2009-08-20 06:41:24 +00:00
|
|
|
COMPARE_STR(mi_parsed, imsi_even);
|
|
|
|
}
|
|
|
|
|
2014-01-10 16:43:41 +00:00
|
|
|
struct {
|
|
|
|
int range;
|
|
|
|
int arfcns_num;
|
|
|
|
int arfcns[RANGE_ENC_MAX_ARFCNS];
|
|
|
|
} arfcn_test_ranges[] = {
|
|
|
|
{ARFCN_RANGE_512, 12,
|
|
|
|
{ 1, 12, 31, 51, 57, 91, 97, 98, 113, 117, 120, 125 }},
|
|
|
|
{ARFCN_RANGE_512, 17,
|
|
|
|
{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 }},
|
|
|
|
{ARFCN_RANGE_512, 18,
|
|
|
|
{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 }},
|
|
|
|
{ARFCN_RANGE_512, 18,
|
|
|
|
{ 1, 17, 31, 45, 58, 79, 81, 97,
|
|
|
|
113, 127, 213, 277, 287, 311, 331, 391,
|
|
|
|
417, 511 }},
|
|
|
|
{ARFCN_RANGE_512, 6,
|
|
|
|
{ 1, 17, 31, 45, 58, 79 }},
|
|
|
|
{ARFCN_RANGE_512, 6,
|
|
|
|
{ 10, 17, 31, 45, 58, 79 }},
|
|
|
|
{ARFCN_RANGE_1024, 17,
|
|
|
|
{ 0, 17, 31, 45, 58, 79, 81, 97,
|
|
|
|
113, 127, 213, 277, 287, 311, 331, 391,
|
|
|
|
1023 }},
|
|
|
|
{ARFCN_RANGE_1024, 16,
|
|
|
|
{ 17, 31, 45, 58, 79, 81, 97, 113,
|
|
|
|
127, 213, 277, 287, 311, 331, 391, 1023 }},
|
|
|
|
{-1}
|
|
|
|
};
|
|
|
|
|
|
|
|
static int test_single_range_encoding(int range, const int *orig_arfcns,
|
|
|
|
int arfcns_num, int silent)
|
|
|
|
{
|
|
|
|
int arfcns[RANGE_ENC_MAX_ARFCNS];
|
|
|
|
int w[RANGE_ENC_MAX_ARFCNS];
|
|
|
|
int f0_included = 0;
|
|
|
|
int rc, f0;
|
|
|
|
uint8_t chan_list[16] = {0};
|
|
|
|
struct gsm_sysinfo_freq dec_freq[1024] = {{0}};
|
|
|
|
int dec_arfcns[RANGE_ENC_MAX_ARFCNS] = {0};
|
|
|
|
int dec_arfcns_count = 0;
|
|
|
|
int arfcns_used = 0;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
arfcns_used = arfcns_num;
|
|
|
|
memmove(arfcns, orig_arfcns, sizeof(arfcns));
|
|
|
|
|
2014-01-14 09:42:58 +00:00
|
|
|
f0 = range == ARFCN_RANGE_1024 ? 0 : arfcns[0];
|
2014-01-10 16:43:41 +00:00
|
|
|
/*
|
|
|
|
* Manipulate the ARFCN list according to the rules in J4 depending
|
|
|
|
* on the selected range.
|
|
|
|
*/
|
2014-01-14 09:42:58 +00:00
|
|
|
arfcns_used = range_enc_filter_arfcns(arfcns, arfcns_used,
|
2014-01-10 16:43:41 +00:00
|
|
|
f0, &f0_included);
|
|
|
|
|
|
|
|
memset(w, 0, sizeof(w));
|
2016-04-20 13:57:13 +00:00
|
|
|
range_enc_arfcns(range, arfcns, arfcns_used, w, 0);
|
2014-01-10 16:43:41 +00:00
|
|
|
|
|
|
|
if (!silent)
|
|
|
|
fprintf(stderr, "range=%d, arfcns_used=%d, f0=%d, f0_included=%d\n",
|
|
|
|
range, arfcns_used, f0, f0_included);
|
|
|
|
|
|
|
|
/* Select the range and the amount of bits needed */
|
|
|
|
switch (range) {
|
|
|
|
case ARFCN_RANGE_128:
|
2016-04-20 13:57:13 +00:00
|
|
|
range_enc_range128(chan_list, f0, w);
|
2014-01-10 16:43:41 +00:00
|
|
|
break;
|
|
|
|
case ARFCN_RANGE_256:
|
2016-04-20 13:57:13 +00:00
|
|
|
range_enc_range256(chan_list, f0, w);
|
2014-01-10 16:43:41 +00:00
|
|
|
break;
|
|
|
|
case ARFCN_RANGE_512:
|
2016-04-20 13:57:13 +00:00
|
|
|
range_enc_range512(chan_list, f0, w);
|
2014-01-10 16:43:41 +00:00
|
|
|
break;
|
|
|
|
case ARFCN_RANGE_1024:
|
2016-04-20 13:57:13 +00:00
|
|
|
range_enc_range1024(chan_list, f0, f0_included, w);
|
2014-01-10 16:43:41 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return 1;
|
|
|
|
};
|
|
|
|
|
|
|
|
if (!silent)
|
|
|
|
printf("chan_list = %s\n",
|
|
|
|
osmo_hexdump(chan_list, sizeof(chan_list)));
|
|
|
|
|
|
|
|
rc = gsm48_decode_freq_list(dec_freq, chan_list, sizeof(chan_list),
|
|
|
|
0xfe, 1);
|
|
|
|
if (rc != 0) {
|
|
|
|
printf("Cannot decode freq list, rc = %d\n", rc);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(dec_freq); i++) {
|
|
|
|
if (dec_freq[i].mask &&
|
|
|
|
dec_arfcns_count < ARRAY_SIZE(dec_arfcns))
|
|
|
|
dec_arfcns[dec_arfcns_count++] = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!silent) {
|
|
|
|
printf("Decoded freqs %d (expected %d)\n",
|
|
|
|
dec_arfcns_count, arfcns_num);
|
|
|
|
printf("Decoded: ");
|
|
|
|
for (i = 0; i < dec_arfcns_count; i++) {
|
|
|
|
printf("%d ", dec_arfcns[i]);
|
|
|
|
if (dec_arfcns[i] != orig_arfcns[i])
|
|
|
|
printf("(!= %d) ", orig_arfcns[i]);
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dec_arfcns_count != arfcns_num) {
|
|
|
|
printf("Wrong number of arfcns\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (memcmp(dec_arfcns, orig_arfcns, sizeof(dec_arfcns)) != 0) {
|
|
|
|
printf("Decoding error, got wrong freqs\n");
|
|
|
|
fprintf(stderr, " w = ");
|
|
|
|
for (i = 0; i < ARRAY_SIZE(w); i++)
|
|
|
|
fprintf(stderr, "%d ", w[i]);
|
|
|
|
fprintf(stderr, "\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_random_range_encoding(int range, int max_arfcn_num)
|
|
|
|
{
|
|
|
|
int arfcns_num = 0;
|
|
|
|
int test_idx;
|
|
|
|
int rc, max_count;
|
|
|
|
int num_tests = 1024;
|
|
|
|
|
|
|
|
printf("Random range test: range %d, max num ARFCNs %d\n",
|
|
|
|
range, max_arfcn_num);
|
|
|
|
|
|
|
|
srandom(1);
|
|
|
|
|
|
|
|
for (max_count = 1; max_count < max_arfcn_num; max_count++) {
|
|
|
|
for (test_idx = 0; test_idx < num_tests; test_idx++) {
|
|
|
|
int count;
|
|
|
|
int i;
|
|
|
|
int min_freq = 0;
|
|
|
|
|
|
|
|
int rnd_arfcns[RANGE_ENC_MAX_ARFCNS] = {0};
|
|
|
|
char rnd_arfcns_set[1024] = {0};
|
|
|
|
|
|
|
|
if (range < ARFCN_RANGE_1024)
|
|
|
|
min_freq = random() % (1023 - range);
|
|
|
|
|
|
|
|
for (count = max_count; count; ) {
|
|
|
|
int arfcn = min_freq + random() % (range + 1);
|
|
|
|
OSMO_ASSERT(arfcn < ARRAY_SIZE(rnd_arfcns_set));
|
|
|
|
|
|
|
|
if (!rnd_arfcns_set[arfcn]) {
|
|
|
|
rnd_arfcns_set[arfcn] = 1;
|
|
|
|
count -= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
arfcns_num = 0;
|
|
|
|
for (i = 0; i < ARRAY_SIZE(rnd_arfcns_set); i++)
|
|
|
|
if (rnd_arfcns_set[i])
|
|
|
|
rnd_arfcns[arfcns_num++] = i;
|
|
|
|
|
|
|
|
rc = test_single_range_encoding(range, rnd_arfcns,
|
|
|
|
arfcns_num, 1);
|
|
|
|
if (rc != 0) {
|
|
|
|
printf("Failed on test %d, range %d, num ARFCNs %d\n",
|
|
|
|
test_idx, range, max_count);
|
|
|
|
test_single_range_encoding(range, rnd_arfcns,
|
|
|
|
arfcns_num, 0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_range_encoding()
|
|
|
|
{
|
|
|
|
int *arfcns;
|
|
|
|
int arfcns_num = 0;
|
|
|
|
int test_idx;
|
|
|
|
int range;
|
|
|
|
|
|
|
|
for (test_idx = 0; arfcn_test_ranges[test_idx].arfcns_num > 0; test_idx++)
|
|
|
|
{
|
|
|
|
arfcns_num = arfcn_test_ranges[test_idx].arfcns_num;
|
|
|
|
arfcns = &arfcn_test_ranges[test_idx].arfcns[0];
|
|
|
|
range = arfcn_test_ranges[test_idx].range;
|
|
|
|
|
|
|
|
printf("Range test %d: range %d, num ARFCNs %d\n",
|
|
|
|
test_idx, range, arfcns_num);
|
|
|
|
|
|
|
|
test_single_range_encoding(range, arfcns, arfcns_num, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
test_random_range_encoding(ARFCN_RANGE_128, 29);
|
|
|
|
test_random_range_encoding(ARFCN_RANGE_256, 22);
|
|
|
|
test_random_range_encoding(ARFCN_RANGE_512, 18);
|
|
|
|
test_random_range_encoding(ARFCN_RANGE_1024, 16);
|
|
|
|
}
|
|
|
|
|
2014-01-13 13:43:40 +00:00
|
|
|
static int freqs1[] = {
|
|
|
|
12, 70, 121, 190, 250, 320, 401, 475, 520, 574, 634, 700, 764, 830, 905, 980
|
|
|
|
};
|
|
|
|
|
|
|
|
static int freqs2[] = {
|
|
|
|
402, 460, 1, 67, 131, 197, 272, 347,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int freqs3[] = {
|
|
|
|
68, 128, 198, 279, 353, 398, 452,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
static int w_out[] = {
|
|
|
|
122, 2, 69, 204, 75, 66, 60, 70, 83, 3, 24, 67, 54, 64, 70, 9,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int range128[] = {
|
|
|
|
1, 1 + 127,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int range256[] = {
|
|
|
|
1, 1 + 128,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int range512[] = {
|
|
|
|
1, 1+ 511,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static void test_arfcn_filter()
|
|
|
|
{
|
|
|
|
int arfcns[50], i, res, f0_included;
|
|
|
|
for (i = 0; i < ARRAY_SIZE(arfcns); ++i)
|
|
|
|
arfcns[i] = (i + 1) * 2;
|
|
|
|
|
|
|
|
/* check that the arfcn is taken out. f0_included is only set for Range1024 */
|
|
|
|
f0_included = 24;
|
2014-01-14 09:42:58 +00:00
|
|
|
res = range_enc_filter_arfcns(arfcns, ARRAY_SIZE(arfcns),
|
2014-01-13 13:43:40 +00:00
|
|
|
arfcns[0], &f0_included);
|
|
|
|
VERIFY(res, ==, ARRAY_SIZE(arfcns) - 1);
|
2014-01-14 09:42:58 +00:00
|
|
|
VERIFY(f0_included, ==, 1);
|
2014-01-13 13:43:40 +00:00
|
|
|
for (i = 0; i < res; ++i)
|
|
|
|
VERIFY(arfcns[i], ==, ((i+2) * 2) - (2+1));
|
|
|
|
|
2014-01-14 09:42:58 +00:00
|
|
|
/* check with range1024, ARFCN 0 is included */
|
2014-01-13 13:43:40 +00:00
|
|
|
for (i = 0; i < ARRAY_SIZE(arfcns); ++i)
|
2014-01-14 09:42:58 +00:00
|
|
|
arfcns[i] = i * 2;
|
|
|
|
res = range_enc_filter_arfcns(arfcns, ARRAY_SIZE(arfcns),
|
|
|
|
0, &f0_included);
|
2014-01-13 13:43:40 +00:00
|
|
|
VERIFY(res, ==, ARRAY_SIZE(arfcns) - 1);
|
|
|
|
VERIFY(f0_included, ==, 1);
|
|
|
|
for (i = 0; i < res; ++i)
|
2014-01-14 09:42:58 +00:00
|
|
|
VERIFY(arfcns[i], ==, (i + 1) * 2 - 1);
|
2014-01-13 13:43:40 +00:00
|
|
|
|
2014-01-14 09:42:58 +00:00
|
|
|
/* check with range1024, ARFCN 0 not included */
|
2014-01-13 13:43:40 +00:00
|
|
|
for (i = 0; i < ARRAY_SIZE(arfcns); ++i)
|
|
|
|
arfcns[i] = (i + 1) * 2;
|
2014-01-14 09:42:58 +00:00
|
|
|
res = range_enc_filter_arfcns(arfcns, ARRAY_SIZE(arfcns),
|
|
|
|
0, &f0_included);
|
2014-01-13 13:43:40 +00:00
|
|
|
VERIFY(res, ==, ARRAY_SIZE(arfcns));
|
|
|
|
VERIFY(f0_included, ==, 0);
|
|
|
|
for (i = 0; i < res; ++i)
|
|
|
|
VERIFY(arfcns[i], ==, ((i + 1) * 2) - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_print_encoding()
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
int w[17];
|
|
|
|
uint8_t chan_list[16];
|
|
|
|
memset(chan_list, 0x23, sizeof(chan_list));
|
|
|
|
|
|
|
|
for (rc = 0; rc < ARRAY_SIZE(w); ++rc)
|
|
|
|
switch (rc % 3) {
|
|
|
|
case 0:
|
|
|
|
w[rc] = 0xAAAA;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
w[rc] = 0x5555;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
w[rc] = 0x9696;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-04-20 13:57:13 +00:00
|
|
|
range_enc_range512(chan_list, (1 << 9) | 0x96, w);
|
2014-01-13 13:43:40 +00:00
|
|
|
|
|
|
|
printf("Range512: %s\n", osmo_hexdump(chan_list, ARRAY_SIZE(chan_list)));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_si_range_helpers()
|
|
|
|
{
|
|
|
|
int ws[(sizeof(freqs1)/sizeof(freqs1[0]))];
|
|
|
|
int i, f0 = 0xFFFFFF;
|
|
|
|
|
|
|
|
memset(&ws[0], 0x23, sizeof(ws));
|
|
|
|
|
|
|
|
i = range_enc_find_index(1023, freqs1, ARRAY_SIZE(freqs1));
|
2014-01-17 08:22:57 +00:00
|
|
|
printf("Element is: %d => freqs[i] = %d\n", i, i >= 0 ? freqs1[i] : -1);
|
2014-01-13 13:43:40 +00:00
|
|
|
VERIFY(i, ==, 2);
|
|
|
|
|
|
|
|
i = range_enc_find_index(511, freqs2, ARRAY_SIZE(freqs2));
|
2014-01-17 08:22:57 +00:00
|
|
|
printf("Element is: %d => freqs[i] = %d\n", i, i >= 0 ? freqs2[i] : -1);
|
2014-01-13 13:43:40 +00:00
|
|
|
VERIFY(i, ==, 2);
|
|
|
|
|
|
|
|
i = range_enc_find_index(511, freqs3, ARRAY_SIZE(freqs3));
|
2014-01-17 08:22:57 +00:00
|
|
|
printf("Element is: %d => freqs[i] = %d\n", i, i >= 0 ? freqs3[i] : -1);
|
2014-01-13 13:43:40 +00:00
|
|
|
VERIFY(i, ==, 0);
|
|
|
|
|
2016-04-20 13:57:13 +00:00
|
|
|
range_enc_arfcns(1023, freqs1, ARRAY_SIZE(freqs1), ws, 0);
|
2014-01-13 13:43:40 +00:00
|
|
|
|
|
|
|
for (i = 0; i < sizeof(freqs1)/sizeof(freqs1[0]); ++i) {
|
|
|
|
printf("w[%d]=%d\n", i, ws[i]);
|
|
|
|
VERIFY(ws[i], ==, w_out[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
i = range_enc_determine_range(range128, ARRAY_SIZE(range128), &f0);
|
|
|
|
VERIFY(i, ==, ARFCN_RANGE_128);
|
|
|
|
VERIFY(f0, ==, 1);
|
|
|
|
|
|
|
|
i = range_enc_determine_range(range256, ARRAY_SIZE(range256), &f0);
|
|
|
|
VERIFY(i, ==, ARFCN_RANGE_256);
|
|
|
|
VERIFY(f0, ==, 1);
|
|
|
|
|
|
|
|
i = range_enc_determine_range(range512, ARRAY_SIZE(range512), &f0);
|
|
|
|
VERIFY(i, ==, ARFCN_RANGE_512);
|
|
|
|
VERIFY(f0, ==, 1);
|
|
|
|
}
|
|
|
|
|
2014-02-08 14:20:48 +00:00
|
|
|
static void test_gsm411_rp_ref_wrap(void)
|
|
|
|
{
|
|
|
|
struct gsm_subscriber_connection conn;
|
|
|
|
int res;
|
|
|
|
|
|
|
|
printf("testing RP-Reference wrap\n");
|
|
|
|
|
|
|
|
memset(&conn, 0, sizeof(conn));
|
|
|
|
conn.next_rp_ref = 255;
|
|
|
|
|
2016-05-10 11:27:32 +00:00
|
|
|
res = sms_next_rp_msg_ref(&conn.next_rp_ref);
|
2014-02-08 14:20:48 +00:00
|
|
|
printf("Allocated reference: %d\n", res);
|
|
|
|
OSMO_ASSERT(res == 255);
|
|
|
|
|
2016-05-10 11:27:32 +00:00
|
|
|
res = sms_next_rp_msg_ref(&conn.next_rp_ref);
|
2014-02-08 14:20:48 +00:00
|
|
|
printf("Allocated reference: %d\n", res);
|
|
|
|
OSMO_ASSERT(res == 0);
|
|
|
|
|
2016-05-10 11:27:32 +00:00
|
|
|
res = sms_next_rp_msg_ref(&conn.next_rp_ref);
|
2014-02-08 14:20:48 +00:00
|
|
|
printf("Allocated reference: %d\n", res);
|
|
|
|
OSMO_ASSERT(res == 1);
|
|
|
|
}
|
|
|
|
|
2010-09-17 22:44:24 +00:00
|
|
|
int main(int argc, char **argv)
|
2008-12-28 21:55:40 +00:00
|
|
|
{
|
2014-01-10 16:43:41 +00:00
|
|
|
osmo_init_logging(&log_info);
|
|
|
|
log_set_log_level(osmo_stderr_target, LOGL_INFO);
|
|
|
|
|
2009-08-20 06:41:24 +00:00
|
|
|
test_location_area_identifier();
|
|
|
|
test_mi_functionality();
|
2014-01-13 13:43:40 +00:00
|
|
|
|
|
|
|
test_si_range_helpers();
|
|
|
|
test_arfcn_filter();
|
|
|
|
test_print_encoding();
|
2014-01-10 16:43:41 +00:00
|
|
|
test_range_encoding();
|
2014-02-08 14:20:48 +00:00
|
|
|
test_gsm411_rp_ref_wrap();
|
2010-03-04 09:55:40 +00:00
|
|
|
|
2016-12-14 13:51:40 +00:00
|
|
|
test_si2q_segfault();
|
2016-04-20 13:57:13 +00:00
|
|
|
test_si2q_e();
|
|
|
|
test_si2q_u();
|
2016-12-19 12:41:48 +00:00
|
|
|
test_si2q_mu();
|
2017-06-15 13:10:53 +00:00
|
|
|
test_si2q_long();
|
|
|
|
|
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
|
|
|
}
|