diff options
author | Vadim Yanitskiy <vyanitskiy@sysmocom.de> | 2021-02-13 05:03:36 +0100 |
---|---|---|
committer | Vadim Yanitskiy <vyanitskiy@sysmocom.de> | 2021-02-13 05:15:37 +0100 |
commit | 6b93f0f366da5091db791df7c6bf7170a1438ec4 (patch) | |
tree | 97d8f2d5af8af393bd836c405560b0df8439036f | |
parent | 9eb37bc3cb94900a818cfca0a5b5b8f1724afce8 (diff) |
GSMTAP: move 'struct gsmtap_inst' and masks to 'struct gsm_bts'
Change-Id: I1c5cb8561dfdcbfd1b23ab28cf95aea7a18c7481
-rw-r--r-- | include/osmo-bts/bts.h | 7 | ||||
-rw-r--r-- | include/osmo-bts/l1sap.h | 4 | ||||
-rw-r--r-- | src/common/l1sap.c | 13 | ||||
-rw-r--r-- | src/common/main.c | 6 | ||||
-rw-r--r-- | src/common/vty.c | 24 |
5 files changed, 29 insertions, 25 deletions
diff --git a/include/osmo-bts/bts.h b/include/osmo-bts/bts.h index f6389ade..3adafcc0 100644 --- a/include/osmo-bts/bts.h +++ b/include/osmo-bts/bts.h @@ -343,6 +343,13 @@ struct gsm_bts { char *sock_path; } pcu; + /* GSMTAP Um logging (disabled by default) */ + struct { + struct gsmtap_inst *inst; + uint32_t sapi_mask; + uint8_t sapi_acch; + } gsmtap; + struct osmo_fsm_inst *shutdown_fi; /* FSM instance to manage shutdown procedure during process exit */ struct osmo_tdef *T_defs; /* Timer defines */ diff --git a/include/osmo-bts/l1sap.h b/include/osmo-bts/l1sap.h index af58d5e3..fe774312 100644 --- a/include/osmo-bts/l1sap.h +++ b/include/osmo-bts/l1sap.h @@ -127,10 +127,6 @@ enum l1sap_common_sapi { extern uint16_t l1sap_log_ctx_sapi; extern const struct value_string l1sap_common_sapi_names[]; -extern struct gsmtap_inst *gsmtap; -extern uint32_t gsmtap_sapi_mask; -extern uint8_t gsmtap_sapi_acch; - int add_l1sap_header(struct gsm_bts_trx *trx, struct msgb *rmsg, struct gsm_lchan *lchan, uint8_t chan_nr, uint32_t fn, uint16_t ber10k, int16_t lqual_cb, int8_t rssi, 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; } |