libcommon: Fix log output for bts>0.
Fixes regression probably introduced in c696cc28
.
For bts>0 logging doesn't show bts number correctly when printing lchan
identification string - it will always show it as "bts=0". The reason for
this is that the identification string is cached before bts->nr value is
set to a proper value.
This patch sets bts->nr as part of the first step of the bts structure
initialization, before caching happens thus making sure the cached
identification string is cached with the correct values.
Change-Id: I61c18a7f021fcb1ec00d34a745f4e3ab03416c2d
This commit is contained in:
parent
03a3cc7ba5
commit
ff4cb11e17
|
@ -899,7 +899,7 @@ struct gsm_bts {
|
|||
};
|
||||
|
||||
|
||||
struct gsm_bts *gsm_bts_alloc(void *talloc_ctx);
|
||||
struct gsm_bts *gsm_bts_alloc(void *talloc_ctx, uint8_t bts_num);
|
||||
struct gsm_bts *gsm_bts_num(struct gsm_network *net, int num);
|
||||
|
||||
struct gsm_bts_trx *gsm_bts_trx_alloc(struct gsm_bts *bts);
|
||||
|
|
|
@ -254,12 +254,13 @@ struct gsm_bts *gsm_bts_alloc_register(struct gsm_network *net, enum gsm_bts_typ
|
|||
if (!model && type != GSM_BTS_TYPE_UNKNOWN)
|
||||
return NULL;
|
||||
|
||||
bts = gsm_bts_alloc(net);
|
||||
bts = gsm_bts_alloc(net, net->num_bts);
|
||||
if (!bts)
|
||||
return NULL;
|
||||
|
||||
net->num_bts++;
|
||||
|
||||
bts->network = net;
|
||||
bts->nr = net->num_bts++;
|
||||
bts->type = type;
|
||||
bts->model = model;
|
||||
bts->bsic = bsic;
|
||||
|
|
|
@ -312,7 +312,7 @@ static const struct gprs_rlc_cfg rlc_cfg_default = {
|
|||
.initial_mcs = 6,
|
||||
};
|
||||
|
||||
struct gsm_bts *gsm_bts_alloc(void *ctx)
|
||||
struct gsm_bts *gsm_bts_alloc(void *ctx, uint8_t bts_num)
|
||||
{
|
||||
struct gsm_bts *bts = talloc_zero(ctx, struct gsm_bts);
|
||||
int i;
|
||||
|
@ -320,6 +320,7 @@ struct gsm_bts *gsm_bts_alloc(void *ctx)
|
|||
if (!bts)
|
||||
return NULL;
|
||||
|
||||
bts->nr = bts_num;
|
||||
bts->num_trx = 0;
|
||||
INIT_LLIST_HEAD(&bts->trx_list);
|
||||
bts->ms_max_power = 15; /* dBm */
|
||||
|
|
|
@ -31,6 +31,35 @@
|
|||
#include <openbsc/gsm_subscriber.h>
|
||||
#include <openbsc/vlr.h>
|
||||
|
||||
void test_bts_debug_print(void)
|
||||
{
|
||||
struct gsm_network *network;
|
||||
struct gsm_bts *bts;
|
||||
struct gsm_bts_trx *trx;
|
||||
|
||||
printf("Testing the lchan printing:");
|
||||
|
||||
/* Create a dummy network */
|
||||
network = bsc_network_init(tall_bsc_ctx, 1, 1, NULL);
|
||||
if (!network)
|
||||
exit(1);
|
||||
/* Add a BTS with some reasonanbly non-zero id */
|
||||
bts = gsm_bts_alloc(network, 45);
|
||||
/* Add a second TRX to test on multiple TRXs */
|
||||
gsm_bts_trx_alloc(bts);
|
||||
|
||||
llist_for_each_entry(trx, &bts->trx_list, list) {
|
||||
char *name = gsm_lchan_name(&trx->ts[3].lchan[4]);
|
||||
|
||||
if (name)
|
||||
printf(" %s", name);
|
||||
else
|
||||
printf("NULL name");
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
|
||||
void test_dyn_ts_subslots(void)
|
||||
{
|
||||
struct gsm_bts_trx_ts ts;
|
||||
|
@ -66,6 +95,7 @@ int main(int argc, char **argv)
|
|||
osmo_init_logging(&log_info);
|
||||
|
||||
test_dyn_ts_subslots();
|
||||
test_bts_debug_print();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
Testing subslot numbers for pchan types
|
||||
Testing the lchan printing: (bts=45,trx=0,ts=3,ss=4) (bts=45,trx=1,ts=3,ss=4)
|
||||
|
|
|
@ -153,7 +153,7 @@ static inline void test_si2q_segfault(void)
|
|||
|
||||
if (!network)
|
||||
exit(1);
|
||||
bts = gsm_bts_alloc(network);
|
||||
bts = gsm_bts_alloc(network, 0);
|
||||
|
||||
_bts_uarfcn_add(bts, 10564, 319, 0);
|
||||
_bts_uarfcn_add(bts, 10612, 319, 0);
|
||||
|
@ -168,7 +168,7 @@ static inline void test_si2q_mu(void)
|
|||
|
||||
if (!network)
|
||||
exit(1);
|
||||
bts = gsm_bts_alloc(network);
|
||||
bts = gsm_bts_alloc(network, 0);
|
||||
|
||||
_bts_uarfcn_add(bts, 10564, 318, 0);
|
||||
_bts_uarfcn_add(bts, 10612, 319, 0);
|
||||
|
@ -188,7 +188,7 @@ static inline void test_si2q_u(void)
|
|||
if (!network)
|
||||
exit(1);
|
||||
|
||||
bts = gsm_bts_alloc(network);
|
||||
bts = gsm_bts_alloc(network, 0);
|
||||
|
||||
/* first generate invalid SI as no UARFCN added */
|
||||
gen(bts, __func__);
|
||||
|
@ -216,7 +216,7 @@ static inline void test_si2q_e(void)
|
|||
if (!network)
|
||||
exit(1);
|
||||
|
||||
bts = gsm_bts_alloc(network);
|
||||
bts = gsm_bts_alloc(network, 0);
|
||||
|
||||
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;
|
||||
|
@ -249,7 +249,7 @@ static inline void test_si2q_long(void)
|
|||
if (!network)
|
||||
exit(1);
|
||||
|
||||
bts = gsm_bts_alloc(network);
|
||||
bts = gsm_bts_alloc(network, 0);
|
||||
|
||||
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;
|
||||
|
|
Loading…
Reference in New Issue