summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2016-11-15 21:18:35 +0100
committerAlexander Couzens <lynxis@fe80.eu>2017-03-13 10:35:47 +0100
commit1729041aeda9a4b1e3ebb84a6fac4f177cde78e2 (patch)
tree7eb9687740f3c1458dcd1e215001726d2e972651
parentaa7568c1cf0ffc17cada5a436ccd77fa9db21a1f (diff)
HACK: Don't require TRX numbers to start at 0
-rw-r--r--openbsc/src/libbsc/abis_om2000.c2
-rw-r--r--openbsc/src/libbsc/bsc_vty.c47
-rw-r--r--openbsc/src/libcommon/gsm_data_shared.c44
3 files changed, 43 insertions, 50 deletions
diff --git a/openbsc/src/libbsc/abis_om2000.c b/openbsc/src/libbsc/abis_om2000.c
index 82a14b2..2ec28d8 100644
--- a/openbsc/src/libbsc/abis_om2000.c
+++ b/openbsc/src/libbsc/abis_om2000.c
@@ -2212,7 +2212,7 @@ static void om2k_bts_s_wait_is(struct osmo_fsm_inst *fi, uint32_t event, void *d
osmo_fsm_inst_state_chg(fi, OM2K_BTS_S_WAIT_TRX,
BTS_FSM_TIMEOUT, 0);
- obfp->next_trx_nr = 0;
+ obfp->next_trx_nr = 1;
trx = gsm_bts_trx_num(obfp->bts, obfp->next_trx_nr++);
om2k_trx_fsm_start(fi, trx, OM2K_BTS_EVT_TRX_DONE);
}
diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c
index b1747aa..12b0353 100644
--- a/openbsc/src/libbsc/bsc_vty.c
+++ b/openbsc/src/libbsc/bsc_vty.c
@@ -883,29 +883,31 @@ DEFUN(show_trx,
}
if (argc >= 2) {
trx_nr = atoi(argv[1]);
- if (trx_nr >= bts->num_trx) {
+ trx = gsm_bts_trx_num(bts, trx_nr);
+ if (!trx) {
vty_out(vty, "%% can't find TRX '%s'%s", argv[1],
VTY_NEWLINE);
return CMD_WARNING;
}
- trx = gsm_bts_trx_num(bts, trx_nr);
trx_dump_vty(vty, trx);
return CMD_SUCCESS;
}
if (bts) {
/* print all TRX in this BTS */
- for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
+ for (trx_nr = 0; trx_nr < 255; trx_nr++) {
trx = gsm_bts_trx_num(bts, trx_nr);
- trx_dump_vty(vty, trx);
+ if (trx)
+ trx_dump_vty(vty, trx);
}
return CMD_SUCCESS;
}
for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
bts = gsm_bts_num(net, bts_nr);
- for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
+ for (trx_nr = 0; trx_nr < 255; trx_nr++) {
trx = gsm_bts_trx_num(bts, trx_nr);
- trx_dump_vty(vty, trx);
+ if (trx)
+ trx_dump_vty(vty, trx);
}
}
@@ -954,12 +956,12 @@ DEFUN(show_ts,
}
if (argc >= 2) {
trx_nr = atoi(argv[1]);
- if (trx_nr >= bts->num_trx) {
+ trx = gsm_bts_trx_num(bts, trx_nr);
+ if (!trx) {
vty_out(vty, "%% can't find TRX '%s'%s", argv[1],
VTY_NEWLINE);
return CMD_WARNING;
}
- trx = gsm_bts_trx_num(bts, trx_nr);
}
if (argc >= 3) {
ts_nr = atoi(argv[2]);
@@ -982,8 +984,10 @@ DEFUN(show_ts,
}
} else if (bts) {
/* Iterate over all TRX in this BTS, TS in each TRX */
- for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
+ for (trx_nr = 0; trx_nr < 255; trx_nr++) {
trx = gsm_bts_trx_num(bts, trx_nr);
+ if (!trx)
+ continue;
for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
ts = &trx->ts[ts_nr];
ts_dump_vty(vty, ts);
@@ -993,8 +997,10 @@ DEFUN(show_ts,
/* Iterate over all BTS, TRX in each BTS, TS in each TRX */
for (bts_nr = 0; bts_nr < net->num_bts; bts_nr++) {
bts = gsm_bts_num(net, bts_nr);
- for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
+ for (trx_nr = 0; trx_nr < 255; trx_nr++) {
trx = gsm_bts_trx_num(bts, trx_nr);
+ if (!trx)
+ continue;
for (ts_nr = 0; ts_nr < TRX_NR_TS; ts_nr++) {
ts = &trx->ts[ts_nr];
ts_dump_vty(vty, ts);
@@ -1226,9 +1232,10 @@ static int dump_lchan_bts(struct gsm_bts *bts, struct vty *vty,
{
int trx_nr;
- for (trx_nr = 0; trx_nr < bts->num_trx; trx_nr++) {
+ for (trx_nr = 0; trx_nr < 255; trx_nr++) {
struct gsm_bts_trx *trx = gsm_bts_trx_num(bts, trx_nr);
- dump_lchan_trx(trx, vty, dump_cb);
+ if (trx)
+ dump_lchan_trx(trx, vty, dump_cb);
}
return CMD_SUCCESS;
@@ -1259,13 +1266,12 @@ static int lchan_summary(struct vty *vty, int argc, const char **argv,
}
if (argc >= 2) {
trx_nr = atoi(argv[1]);
- if (trx_nr >= bts->num_trx) {
+ trx = gsm_bts_trx_num(bts, trx_nr);
+ if (!trx) {
vty_out(vty, "%% can't find TRX %s%s", argv[1],
VTY_NEWLINE);
return CMD_WARNING;
}
- trx = gsm_bts_trx_num(bts, trx_nr);
-
if (argc == 2)
return dump_lchan_trx(trx, vty, dump_cb);
}
@@ -3373,16 +3379,11 @@ DEFUN(cfg_trx,
struct gsm_bts *bts = vty->index;
struct gsm_bts_trx *trx;
- if (trx_nr > bts->num_trx) {
- vty_out(vty, "%% The next unused TRX number in this BTS is %u%s",
- bts->num_trx, VTY_NEWLINE);
- return CMD_WARNING;
- } else if (trx_nr == bts->num_trx) {
+ trx = gsm_bts_trx_num(bts, trx_nr);
+ if (!trx) {
/* we need to allocate a new one */
trx = gsm_bts_trx_alloc(bts);
- } else
- trx = gsm_bts_trx_num(bts, trx_nr);
-
+ }
if (!trx)
return CMD_WARNING;
diff --git a/openbsc/src/libcommon/gsm_data_shared.c b/openbsc/src/libcommon/gsm_data_shared.c
index dc1cf8d..f40cd87 100644
--- a/openbsc/src/libcommon/gsm_data_shared.c
+++ b/openbsc/src/libcommon/gsm_data_shared.c
@@ -165,6 +165,7 @@ struct gsm_bts_trx *gsm_bts_trx_alloc(struct gsm_bts *bts)
trx->bts = bts;
trx->nr = bts->num_trx++;
+ trx->nr = 1; /* HACK */
trx->mo.nm_state.administrative = NM_STATE_UNLOCKED;
gsm_mo_init(&trx->mo, bts, NM_OC_RADIO_CARRIER,
@@ -208,7 +209,7 @@ struct gsm_bts_trx *gsm_bts_trx_alloc(struct gsm_bts *bts)
}
}
- if (trx->nr != 0)
+ if (trx->nr != 1)
trx->nominal_power = bts->c0->nominal_power;
llist_add_tail(&trx->list, &bts->trx_list);
@@ -323,9 +324,6 @@ struct gsm_bts_trx *gsm_bts_trx_num(const struct gsm_bts *bts, int num)
{
struct gsm_bts_trx *trx;
- if (num >= bts->num_trx)
- return NULL;
-
llist_for_each_entry(trx, &bts->trx_list, list) {
if (trx->nr == num)
return trx;
@@ -428,24 +426,21 @@ gsm_objclass2mo(struct gsm_bts *bts, uint8_t obj_class,
mo = &bts->mo;
break;
case NM_OC_RADIO_CARRIER:
- if (obj_inst->trx_nr >= bts->num_trx) {
- return NULL;
- }
trx = gsm_bts_trx_num(bts, obj_inst->trx_nr);
+ if (!trx)
+ return NULL;
mo = &trx->mo;
break;
case NM_OC_BASEB_TRANSC:
- if (obj_inst->trx_nr >= bts->num_trx) {
- return NULL;
- }
trx = gsm_bts_trx_num(bts, obj_inst->trx_nr);
+ if (!trx)
+ return NULL;
mo = &trx->bb_transc.mo;
break;
case NM_OC_CHANNEL:
- if (obj_inst->trx_nr >= bts->num_trx) {
- return NULL;
- }
trx = gsm_bts_trx_num(bts, obj_inst->trx_nr);
+ if (!trx)
+ return NULL;
if (obj_inst->ts_nr >= TRX_NR_TS)
return NULL;
mo = &trx->ts[obj_inst->ts_nr].mo;
@@ -459,15 +454,15 @@ gsm_objclass2mo(struct gsm_bts *bts, uint8_t obj_class,
mo = &bts->bs11.cclk.mo;
break;
case BS11_OBJ_BBSIG:
- if (obj_inst->ts_nr > bts->num_trx)
- return NULL;
trx = gsm_bts_trx_num(bts, obj_inst->trx_nr);
+ if (!trx)
+ return NULL;
mo = &trx->bs11.bbsig.mo;
break;
case BS11_OBJ_PA:
- if (obj_inst->ts_nr > bts->num_trx)
- return NULL;
trx = gsm_bts_trx_num(bts, obj_inst->trx_nr);
+ if (!trx)
+ return NULL;
mo = &trx->bs11.pa.mo;
break;
default:
@@ -524,24 +519,21 @@ gsm_objclass2obj(struct gsm_bts *bts, uint8_t obj_class,
obj = bts;
break;
case NM_OC_RADIO_CARRIER:
- if (obj_inst->trx_nr >= bts->num_trx) {
- return NULL;
- }
trx = gsm_bts_trx_num(bts, obj_inst->trx_nr);
+ if (!trx)
+ return NULL;
obj = trx;
break;
case NM_OC_BASEB_TRANSC:
- if (obj_inst->trx_nr >= bts->num_trx) {
- return NULL;
- }
trx = gsm_bts_trx_num(bts, obj_inst->trx_nr);
+ if (!trx)
+ return NULL;
obj = &trx->bb_transc;
break;
case NM_OC_CHANNEL:
- if (obj_inst->trx_nr >= bts->num_trx) {
- return NULL;
- }
trx = gsm_bts_trx_num(bts, obj_inst->trx_nr);
+ if (!trx)
+ return NULL;
if (obj_inst->ts_nr >= TRX_NR_TS)
return NULL;
obj = &trx->ts[obj_inst->ts_nr];