Change in osmo-bts[master]: add vty config for GSMTAP-SAPI host (-i)

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/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Thu Sep 6 13:27:29 UTC 2018


Neels Hofmeyr has uploaded this change for review. ( https://gerrit.osmocom.org/10808


Change subject: add vty config for GSMTAP-SAPI host (-i)
......................................................................

add vty config for GSMTAP-SAPI host (-i)

So far, the only way to configure the target for SAPI GSMTAP is to use the
cmdline argument -i. Add a vty command to allow configuring from cfg file.

Add 'bts 0' / 'gsmtap-host HOSTNAME' and 'no gsmtap-host'.

The -i option, if provided, overrides the cfg file option.

In order to set up the SAPI GSMTAP socket after reading the config file, shift
the socket init a bit further down in main.c.

BTW, if the user passed an -i option, the gsmtap host shows up in 'show
running-config' and hence will also appear in 'write file'.

Change-Id: I17676a21c4e0c9cbc88f2c5c53a39c6c6c473ca1
---
M include/osmo-bts/gsm_data_shared.h
M src/common/main.c
M src/common/vty.c
3 files changed, 52 insertions(+), 9 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/08/10808/1

diff --git a/include/osmo-bts/gsm_data_shared.h b/include/osmo-bts/gsm_data_shared.h
index 794eaea..ef468cb 100644
--- a/include/osmo-bts/gsm_data_shared.h
+++ b/include/osmo-bts/gsm_data_shared.h
@@ -747,6 +747,7 @@
 		struct osmo_timer_list fn_timer;
 	} vbts;
 
+	char *gsmtap_sapi_host;
 };
 
 
diff --git a/src/common/main.c b/src/common/main.c
index 9121a2a..c08088a 100644
--- a/src/common/main.c
+++ b/src/common/main.c
@@ -275,15 +275,6 @@
 		}
 	}
 
-        if (gsmtap_ip) {
-		gsmtap = gsmtap_source_init(gsmtap_ip, GSMTAP_UDP_PORT, 1);
-		if (!gsmtap) {
-			fprintf(stderr, "Failed during gsmtap_init()\n");
-			exit(1);
-		}
-		gsmtap_source_add_sink(gsmtap);
-	}
-
 	if (bts_init(bts) < 0) {
 		fprintf(stderr, "unable to open bts\n");
 		exit(1);
@@ -313,6 +304,26 @@
 
 	write_pid_file("osmo-bts");
 
+	/* Accept a GSMTAP-SAPI host from VTY config, but a commandline option overrides that. */
+	if (gsmtap_ip) {
+		if (bts->gsmtap_sapi_host) {
+			LOGP(DLGLOBAL, LOGL_NOTICE,
+			     "Command line argument -i overrides 'gsmtap-host' config\n");
+			talloc_free(bts->gsmtap_sapi_host);
+		}
+		bts->gsmtap_sapi_host = talloc_strdup(bts, gsmtap_ip);
+	}
+	if (bts->gsmtap_sapi_host) {
+		LOGP(DLGLOBAL, LOGL_NOTICE, "Setting up GSMTAP SAPI forwarding to %s:%d\n",
+		     bts->gsmtap_sapi_host, GSMTAP_UDP_PORT);
+		gsmtap = gsmtap_source_init(bts->gsmtap_sapi_host, GSMTAP_UDP_PORT, 1);
+		if (!gsmtap) {
+			fprintf(stderr, "Failed during gsmtap_init()\n");
+			exit(1);
+		}
+		gsmtap_source_add_sink(gsmtap);
+	}
+
 	bts_controlif_setup(bts, ctrl_vty_get_bind_addr(), OSMO_CTRL_PORT_BTS);
 
 	rc = telnet_init_dynif(tall_bts_ctx, NULL, vty_get_bind_addr(),
diff --git a/src/common/vty.c b/src/common/vty.c
index 6061335..98e874f 100644
--- a/src/common/vty.c
+++ b/src/common/vty.c
@@ -276,6 +276,8 @@
 			bts->agch_queue.thresh_level, bts->agch_queue.low_level,
 			bts->agch_queue.high_level, VTY_NEWLINE);
 
+	if (bts->gsmtap_sapi_host)
+		vty_out(vty, " gsmtap-host %s%s", bts->gsmtap_sapi_host, VTY_NEWLINE);
 	for (i = 0; i < 32; i++) {
 		if (gsmtap_sapi_mask & (1 << i)) {
 			osmo_str2lower(buf_casecnvt, get_value_string(gsmtap_sapi_names, i));
@@ -1392,6 +1394,33 @@
 	return CMD_SUCCESS;
 }
 
+#define GSMTAP_HOST_STR \
+      "Set the host to send GSMTAP of selected SAPIs to, see gsmtap-sapi and command line option -i." \
+      " (Not related to 'log gsmtap'.)\n"
+
+DEFUN(cfg_bts_gsmtap_host, cfg_bts_gsmtap_host_cmd,
+      "gsmtap-host HOSTNAME",
+      GSMTAP_HOST_STR
+      "Remote IP address or hostname\n")
+{
+	struct gsm_bts *bts = vty->index;
+	if (bts->gsmtap_sapi_host)
+		talloc_free(bts->gsmtap_sapi_host);
+	bts->gsmtap_sapi_host = talloc_strdup(bts, argv[0]);
+	return CMD_SUCCESS;
+}
+
+DEFUN(cfg_bts_no_gsmtap_host, cfg_bts_no_gsmtap_host_cmd,
+      "no gsmtap-host",
+      NO_STR GSMTAP_HOST_STR)
+{
+	struct gsm_bts *bts = vty->index;
+	if (bts->gsmtap_sapi_host)
+		talloc_free(bts->gsmtap_sapi_host);
+	bts->gsmtap_sapi_host = NULL;
+	return CMD_SUCCESS;
+}
+
 static struct cmd_node phy_node = {
 	PHY_NODE,
 	"%s(phy)# ",
@@ -1609,6 +1638,8 @@
 	install_element(BTS_NODE, &cfg_bts_supp_meas_toa256_cmd);
 	install_element(BTS_NODE, &cfg_bts_no_supp_meas_toa256_cmd);
 
+	install_element(BTS_NODE, &cfg_bts_gsmtap_host_cmd);
+	install_element(BTS_NODE, &cfg_bts_no_gsmtap_host_cmd);
 	install_element(BTS_NODE, &cfg_trx_gsmtap_sapi_cmd);
 	install_element(BTS_NODE, &cfg_trx_no_gsmtap_sapi_cmd);
 

-- 
To view, visit https://gerrit.osmocom.org/10808
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I17676a21c4e0c9cbc88f2c5c53a39c6c6c473ca1
Gerrit-Change-Number: 10808
Gerrit-PatchSet: 1
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180906/7b5df7ad/attachment.htm>


More information about the gerrit-log mailing list