diff options
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/l1sap.c | 13 | ||||
-rw-r--r-- | src/common/main.c | 6 | ||||
-rw-r--r-- | src/common/vty.c | 24 |
3 files changed, 22 insertions, 21 deletions
diff --git a/src/common/l1sap.c b/src/common/l1sap.c index 9b3b0870..eb652db8 100644 --- a/src/common/l1sap.c +++ b/src/common/l1sap.c @@ -346,10 +346,6 @@ static enum l1sap_common_sapi get_common_sapi_by_trx_prim(struct gsm_bts_trx *tr } } -struct gsmtap_inst *gsmtap = NULL; -uint32_t gsmtap_sapi_mask = 0; -uint8_t gsmtap_sapi_acch = 0; - /* send primitive as gsmtap */ static int gsmtap_ph_data(const struct osmo_phsap_prim *l1sap, uint8_t *chan_type, uint8_t *ss, uint32_t fn, @@ -491,7 +487,8 @@ static int to_gsmtap(struct gsm_bts_trx *trx, struct osmo_phsap_prim *l1sap) int8_t signal_dbm; int rc; - if (!gsmtap) + struct gsmtap_inst *inst = trx->bts->gsmtap.inst; + if (!inst) return 0; switch (OSMO_PRIM_HDR(&l1sap->oph)) { @@ -524,10 +521,10 @@ static int to_gsmtap(struct gsm_bts_trx *trx, struct osmo_phsap_prim *l1sap) if (len == 0) return 0; if ((chan_type & GSMTAP_CHANNEL_ACCH)) { - if (!gsmtap_sapi_acch) + if (!trx->bts->gsmtap.sapi_acch) return 0; } else { - if (!((1 << (chan_type & 31)) & gsmtap_sapi_mask)) + if (!((1 << (chan_type & 31)) & trx->bts->gsmtap.sapi_mask)) return 0; } @@ -536,7 +533,7 @@ static int to_gsmtap(struct gsm_bts_trx *trx, struct osmo_phsap_prim *l1sap) if (is_fill_frame(chan_type, data, len)) return 0; - gsmtap_send(gsmtap, trx->arfcn | uplink, tn, chan_type, ss, fn, + gsmtap_send(inst, trx->arfcn | uplink, tn, chan_type, ss, fn, signal_dbm, 0 /* TODO: SNR */, data, len); return 0; diff --git a/src/common/main.c b/src/common/main.c index 76e0d430..38f517c2 100644 --- a/src/common/main.c +++ b/src/common/main.c @@ -321,12 +321,12 @@ int bts_main(int argc, char **argv) } if (gsmtap_ip) { - gsmtap = gsmtap_source_init(gsmtap_ip, GSMTAP_UDP_PORT, 1); - if (!gsmtap) { + g_bts->gsmtap.inst = gsmtap_source_init(gsmtap_ip, GSMTAP_UDP_PORT, 1); + if (g_bts->gsmtap.inst == NULL) { fprintf(stderr, "Failed during gsmtap_init()\n"); exit(1); } - gsmtap_source_add_sink(gsmtap); + gsmtap_source_add_sink(g_bts->gsmtap.inst); } if (bts_init(g_bts) < 0) { diff --git a/src/common/vty.c b/src/common/vty.c index 976ccfa8..f2c79547 100644 --- a/src/common/vty.c +++ b/src/common/vty.c @@ -316,7 +316,7 @@ static void config_write_bts_single(struct vty *vty, const struct gsm_bts *bts) bts->agch_queue.high_level, VTY_NEWLINE); for (i = 0; i < sizeof(uint32_t) * 8; i++) { - if (gsmtap_sapi_mask & ((uint32_t) 1 << i)) { + if (bts->gsmtap.sapi_mask & ((uint32_t) 1 << i)) { sapi_buf = get_value_string_or_null(gsmtap_sapi_names, i); if (sapi_buf == NULL) continue; @@ -324,7 +324,7 @@ static void config_write_bts_single(struct vty *vty, const struct gsm_bts *bts) vty_out(vty, " gsmtap-sapi %s%s", sapi_buf, VTY_NEWLINE); } } - if (gsmtap_sapi_acch) { + if (bts->gsmtap.sapi_acch) { sapi_buf = osmo_str_tolower(get_value_string(gsmtap_sapi_names, GSMTAP_CHANNEL_ACCH)); vty_out(vty, " gsmtap-sapi %s%s", sapi_buf, VTY_NEWLINE); } @@ -1832,12 +1832,14 @@ DEFUN(cfg_bts_gsmtap_sapi_all, cfg_bts_gsmtap_sapi_all_cmd, "Enable all kinds of messages (all SAPI)\n" "Disable all kinds of messages (all SAPI)\n") { + struct gsm_bts *bts = vty->index; + if (argv[0][0] == 'e') { - gsmtap_sapi_mask = UINT32_MAX; - gsmtap_sapi_acch = 1; + bts->gsmtap.sapi_mask = UINT32_MAX; + bts->gsmtap.sapi_acch = 1; } else { - gsmtap_sapi_mask = 0x00; - gsmtap_sapi_acch = 0; + bts->gsmtap.sapi_mask = 0x00; + bts->gsmtap.sapi_acch = 0; } return CMD_SUCCESS; @@ -1846,15 +1848,16 @@ DEFUN(cfg_bts_gsmtap_sapi_all, cfg_bts_gsmtap_sapi_all_cmd, DEFUN(cfg_bts_gsmtap_sapi, cfg_bts_gsmtap_sapi_cmd, "HIDDEN", "HIDDEN") { + struct gsm_bts *bts = vty->index; int sapi; sapi = get_string_value(gsmtap_sapi_names, argv[0]); OSMO_ASSERT(sapi >= 0); if (sapi == GSMTAP_CHANNEL_ACCH) - gsmtap_sapi_acch = 1; + bts->gsmtap.sapi_acch = 1; else - gsmtap_sapi_mask |= (1 << sapi); + bts->gsmtap.sapi_mask |= (1 << sapi); return CMD_SUCCESS; } @@ -1862,15 +1865,16 @@ DEFUN(cfg_bts_gsmtap_sapi, cfg_bts_gsmtap_sapi_cmd, DEFUN(cfg_trx_no_gsmtap_sapi, cfg_bts_no_gsmtap_sapi_cmd, "HIDDEN", "HIDDEN") { + struct gsm_bts *bts = vty->index; int sapi; sapi = get_string_value(gsmtap_sapi_names, argv[0]); OSMO_ASSERT(sapi >= 0); if (sapi == GSMTAP_CHANNEL_ACCH) - gsmtap_sapi_acch = 0; + bts->gsmtap.sapi_acch = 0; else - gsmtap_sapi_mask &= ~(1 << sapi); + bts->gsmtap.sapi_mask &= ~(1 << sapi); return CMD_SUCCESS; } |