aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <vyanitskiy@sysmocom.de>2020-10-08 22:17:21 +0700
committerVadim Yanitskiy <vyanitskiy@sysmocom.de>2021-01-07 13:58:21 +0100
commit4a0a6fd014e1ce1886fb88e7e37d67ca252b63b2 (patch)
tree94226d81a7182e416698f9c7b13b6cfb2f938646
parentpower_control: handle MS/BS Power control params on A-bis/RSL (diff)
downloadOsmoBTS-4a0a6fd014e1ce1886fb88e7e37d67ca252b63b2.tar.xz
OsmoBTS-4a0a6fd014e1ce1886fb88e7e37d67ca252b63b2.zip
vty: add a command to show GPRS related info
Here is a sample output: OsmoBTS# show bts 0 gprs BTS 0, RAC 0, NSEI 101, BVCI 2 Cell NM state: Oper 'Enabled', Admin 'Unlocked', Avail 'OK' NSE NM state: Oper 'Enabled', Admin 'Unlocked', Avail 'OK' NSVC0 (NSVCI 101) NM state: Oper 'Enabled', Admin 'Unlocked', Avail 'OK' Address: r=127.0.0.1:23010<->l=0.0.0.0:55385 NSVC1 (NSVCI 0) NM state: Oper 'Disabled', Admin 'Locked', Avail 'Off line' This command is useful for debugging NS connection problems. Change-Id: I149eea0b1c109020406eb67c9082c335a77aab06
-rw-r--r--src/common/vty.c70
1 files changed, 70 insertions, 0 deletions
diff --git a/src/common/vty.c b/src/common/vty.c
index 326e332e..1c3b4967 100644
--- a/src/common/vty.c
+++ b/src/common/vty.c
@@ -39,6 +39,7 @@
#include <osmocom/vty/ports.h>
#include <osmocom/core/gsmtap.h>
#include <osmocom/core/utils.h>
+#include <osmocom/core/sockaddr_str.h>
#include <osmocom/trau/osmo_ortp.h>
@@ -1104,6 +1105,73 @@ DEFUN(show_bts, show_bts_cmd, "show bts [<0-255>]",
return CMD_SUCCESS;
}
+static void gprs_dump_vty(struct vty *vty, const struct gsm_bts *bts)
+{
+ unsigned int i;
+
+ /* GPRS parameters received from the BSC */
+ vty_out(vty, "BTS %u, RAC %u, NSEI %u, BVCI %u%s",
+ bts->nr, bts->gprs.rac,
+ bts->gprs.nse.nsei,
+ bts->gprs.cell.bvci,
+ VTY_NEWLINE);
+
+ vty_out(vty, " Cell NM state: ");
+ net_dump_nmstate(vty, &bts->gprs.cell.mo.nm_state);
+ vty_out(vty, " NSE NM state: ");
+ net_dump_nmstate(vty, &bts->gprs.nse.mo.nm_state);
+
+ for (i = 0; i < ARRAY_SIZE(bts->gprs.nsvc); i++) {
+ const struct gsm_bts_gprs_nsvc *nsvc = &bts->gprs.nsvc[i];
+
+ vty_out(vty, " NSVC%u (NSVCI %u) NM state: ", i, nsvc->nsvci);
+ net_dump_nmstate(vty, &nsvc->mo.nm_state);
+
+ if (nsvc->mo.nm_state.operational == NM_OPSTATE_ENABLED) {
+ struct osmo_sockaddr_str remote;
+ struct osmo_sockaddr_str local;
+
+ if (osmo_sockaddr_str_from_sockaddr(&remote, &nsvc->remote.u.sas) != 0)
+ remote = (struct osmo_sockaddr_str) { .ip = "<INVALID>" };
+ if (osmo_sockaddr_str_from_sockaddr(&local, &nsvc->local.u.sas) != 0)
+ local = (struct osmo_sockaddr_str) { .ip = "<INVALID>" };
+
+ /* Work around for over-defensiveness of OSMO_SOCKADDR_STR_FMT_ARGS():
+ * error: the address of ‘remote’ will always evaluate as ‘true’
+ * error: the address of ‘local’ will always evaluate as ‘true’ */
+ const struct osmo_sockaddr_str *r = &remote;
+ const struct osmo_sockaddr_str *l = &local;
+
+ /* Getting remote/local address info has never been so easy, right? */
+ vty_out(vty, " Address: r=" OSMO_SOCKADDR_STR_FMT
+ "<->l=" OSMO_SOCKADDR_STR_FMT "%s",
+ OSMO_SOCKADDR_STR_FMT_ARGS(r),
+ OSMO_SOCKADDR_STR_FMT_ARGS(l),
+ VTY_NEWLINE);
+ }
+ }
+}
+
+DEFUN(show_bts_gprs, show_bts_gprs_cmd,
+ "show bts <0-255> gprs",
+ SHOW_STR "Display information about a BTS\n"
+ BTS_NR_STR "GPRS/EGPRS configuration\n")
+{
+ const struct gsm_network *net = gsmnet_from_vty(vty);
+ const struct gsm_bts *bts;
+
+ bts = gsm_bts_num(net, atoi(argv[0]));
+ if (bts == NULL) {
+ vty_out(vty, "%% can't find BTS '%s'%s",
+ argv[0], VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ /* TODO: also print info about PCUIF connection */
+ gprs_dump_vty(vty, bts);
+ return CMD_SUCCESS;
+}
+
DEFUN(test_send_failure_event_report, test_send_failure_event_report_cmd, "test send-failure-event-report <0-255>",
"Various testing commands\n"
"Send a test OML failure event report to the BSC\n" BTS_NR_STR)
@@ -2032,6 +2100,8 @@ int bts_vty_init(void *ctx)
install_element_ve(&show_ts_cmd);
install_element_ve(&show_lchan_cmd);
install_element_ve(&show_lchan_summary_cmd);
+ install_element_ve(&show_bts_gprs_cmd);
+
install_element_ve(&logging_fltr_l1_sapi_cmd);
install_element_ve(&no_logging_fltr_l1_sapi_cmd);