Change in osmo-bts[master]: vty: add a command to show GPRS related info

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

fixeria gerrit-no-reply at lists.osmocom.org
Thu Jan 7 13:26:16 UTC 2021


fixeria has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bts/+/20484 )

Change subject: vty: add a command to show GPRS related info
......................................................................

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
---
M src/common/vty.c
1 file changed, 70 insertions(+), 0 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, but someone else must approve
  pespin: Looks good to me, approved



diff --git a/src/common/vty.c b/src/common/vty.c
index 326e332..1c3b496 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 @@
 	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 @@
 	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);
 

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/20484
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I149eea0b1c109020406eb67c9082c335a77aab06
Gerrit-Change-Number: 20484
Gerrit-PatchSet: 4
Gerrit-Owner: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210107/1afef258/attachment.htm>


More information about the gerrit-log mailing list