[PATCH 3/3] libabis: add IPA VTY command to setup ip.access nanoBTS OML and RSL links

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/OpenBSC@lists.osmocom.org/.

pablo at gnumonks.org pablo at gnumonks.org
Tue Apr 19 17:47:47 UTC 2011


From: Pablo Neira Ayuso <pablo at gnumonks.org>

This patch adds the following command:

$ telnet localhost 4242
> enable
# ipa setup

To explicitly setup OML and RSL links. You can check that the sockets
have been up by means of netstat:

$ netstat -untap
tcp        0      0 0.0.0.0:3002            0.0.0.0:*               LISTEN      15204/osmo-nitb
tcp        0      0 0.0.0.0:3003            0.0.0.0:*               LISTEN      15204/osmo-nitb

This changes the current behaviour of OpenBSC since it creates the OML
and RSL sockets by default. I think that this is useful to have in case
that you have no nanoBTS in your setup (for example, you use HSL femto
instead).

The command to disable nanoBTS OML and RSL links in runtime is not yet
implemented, it shows the following:

# ipa no setup
%% sorry, disabling OML and RSL links in runtime is not yet implemented

The main point of this patch is that we will be able to use openBSC as
IPA proxy, instead of the standalone ipaccess-proxy tool. Since the OML
and RSL ports for nanoBTS are no used by default, we can add an IPA
route rule to bind to OML and RSL ports and forward them to the real BSC.

Still, there are some features in ipaccess-proxy that are not
available (like the UDP packet injection) but I expect to include
them soon.
---
 openbsc/include/openbsc/ipaccess.h       |    1 +
 openbsc/src/libabis/e1_input.c           |    2 +
 openbsc/src/libabis/input/ipaccess.c     |   83 +++++++++++++++++++++++-------
 openbsc/src/openbsc.cfg.nanobts          |    3 +
 openbsc/src/openbsc.cfg.nanobts.multitrx |    3 +
 5 files changed, 74 insertions(+), 18 deletions(-)

diff --git a/openbsc/include/openbsc/ipaccess.h b/openbsc/include/openbsc/ipaccess.h
index 28ec49a..a9d31cb 100644
--- a/openbsc/include/openbsc/ipaccess.h
+++ b/openbsc/include/openbsc/ipaccess.h
@@ -87,6 +87,7 @@ int ipaccess_drop_oml(struct gsm_bts *bts);
 int ipaccess_drop_rsl(struct gsm_bts_trx *trx);
 
 void ipaccess_vty_init(void);
+int e1inp_ipaccess_init(void);
 
 /*
  * Firmware specific header
diff --git a/openbsc/src/libabis/e1_input.c b/openbsc/src/libabis/e1_input.c
index 1a79261..8efef13 100644
--- a/openbsc/src/libabis/e1_input.c
+++ b/openbsc/src/libabis/e1_input.c
@@ -52,6 +52,7 @@
 #include <osmocom/core/talloc.h>
 #include <openbsc/signal.h>
 #include <openbsc/misdn.h>
+#include <openbsc/ipaccess.h>
 
 #include "../../bscconfig.h"
 
@@ -645,4 +646,5 @@ void e1inp_init(void)
 #ifdef HAVE_DAHDI_USER_H
 	e1inp_dahdi_init();
 #endif
+	e1inp_ipaccess_init();
 }
diff --git a/openbsc/src/libabis/input/ipaccess.c b/openbsc/src/libabis/input/ipaccess.c
index 0cd3b2d..d117547 100644
--- a/openbsc/src/libabis/input/ipaccess.c
+++ b/openbsc/src/libabis/input/ipaccess.c
@@ -1621,6 +1621,50 @@ DEFUN(ipa_route_show, ipa_route_show_cmd,
 	return CMD_SUCCESS;
 }
 
+static bool ipa_setup_already = false;
+
+static int __ipa_setup(struct vty *vty, int argc, const char *argv[])
+{
+	int ret;
+
+	if (ipa_setup_already) {
+		vty_out(vty, "%% OML and RSL links has been already set up%s",
+			VTY_NEWLINE);
+		return CMD_WARNING;
+	}
+	/* Listen for OML connections */
+	ret = make_sock(&e1h->listen_fd, IPPROTO_TCP, INADDR_ANY,
+			IPA_TCP_PORT_OML, 0, listen_fd_cb, NULL);
+	if (ret < 0) {
+		vty_out(vty, "%% cannot setup OML link, reason=`%s'%s",
+			strerror(errno), VTY_NEWLINE);
+		return CMD_WARNING;
+	}
+	/* Listen for RSL connections */
+	ret = make_sock(&e1h->rsl_listen_fd, IPPROTO_TCP, INADDR_ANY,
+			IPA_TCP_PORT_RSL, 0, rsl_listen_fd_cb, NULL);
+	if (ret < 0) {
+		vty_out(vty, "%% cannot setup RSL link, reason=`%s'%s",
+			strerror(errno), VTY_NEWLINE);
+		return CMD_WARNING;
+	}
+	return CMD_SUCCESS;
+}
+
+DEFUN(ipa_setup, ipa_setup_cmd,
+      "ipa setup", "Set up OML and RSL links for ip.access nanoBTS")
+{
+	return __ipa_setup(vty, argc, argv);
+}
+
+DEFUN(ipa_setup_del, ipa_setup_del_cmd,
+      "ipa no setup", "Disable OML and RSL links for ip.access nanoBTS")
+{
+	vty_out(vty, "%% sorry, disabling OML and RSL links in runtime "
+		     "is not yet implemented%s", VTY_NEWLINE);
+	return CMD_WARNING;
+}
+
 /*
  * Config for ipaccess-proxy
  */
@@ -1646,6 +1690,12 @@ DEFUN(ipa_instance_cfg_add, ipa_instance_cfg_add_cmd,
 	return __ipa_instance_add(vty, argc, argv);
 }
 
+DEFUN(ipa_setup_cfg, ipa_setup_cfg_cmd,
+      "setup", "Set up OML and RSL links for ip.access nanoBTS")
+{
+	return __ipa_setup(vty, argc, argv);
+}
+
 struct cmd_node ipa_node = {
 	IPA_NODE,
 	"%s(ipa)#",
@@ -1677,12 +1727,17 @@ static int ipa_cfg_write(struct vty *vty)
 			route->shared->dst.inst->name, route->dst.streamid,
 			VTY_NEWLINE);
 	}
+	if (ipa_setup_already)
+		vty_out(vty, " setup%s", VTY_NEWLINE);
+
 	return CMD_SUCCESS;
 }
 
 void ipaccess_vty_init(void)
 {
 	install_element(ENABLE_NODE, &ipa_cmd);
+	install_element(ENABLE_NODE, &ipa_setup_cmd);
+	install_element(ENABLE_NODE, &ipa_setup_del_cmd);
 	install_element(ENABLE_NODE, &ipa_instance_add_cmd);
 	install_element(ENABLE_NODE, &ipa_instance_del_cmd);
 	install_element(ENABLE_NODE, &ipa_instance_show_cmd);
@@ -1695,37 +1750,29 @@ void ipaccess_vty_init(void)
 	install_default(IPA_NODE);
 	install_element(IPA_NODE, &ournode_exit_cmd);
 	install_element(IPA_NODE, &ournode_end_cmd);
+	install_element(IPA_NODE, &ipa_setup_cfg_cmd);
 	install_element(IPA_NODE, &ipa_instance_cfg_add_cmd);
 	install_element(IPA_NODE, &ipa_route_cfg_add_cmd);
 }
 
 int ipaccess_setup(struct gsm_network *gsmnet)
 {
+	e1h->gsmnet = gsmnet;
+	return 0;
+}
+
+int e1inp_ipaccess_init(void)
+{
 	int ret;
 
-	/* register the driver with the core */
-	/* FIXME: do this in the plugin initializer function */
 	ret = e1inp_driver_register(&ipaccess_driver);
-	if (ret)
+	if (ret < 0)
 		return ret;
 
+	/* this is initialized via VTY commands and later ipaccess_setup(). */
 	e1h = talloc_zero(tall_bsc_ctx, struct ia_e1_handle);
 	if (!e1h)
 		return -ENOMEM;
 
-	e1h->gsmnet = gsmnet;
-
-	/* Listen for OML connections */
-	ret = make_sock(&e1h->listen_fd, IPPROTO_TCP, INADDR_ANY,
-			IPA_TCP_PORT_OML, 0, listen_fd_cb, NULL);
-	if (ret < 0)
-		return ret;
-
-	/* Listen for RSL connections */
-	ret = make_sock(&e1h->rsl_listen_fd, IPPROTO_TCP, INADDR_ANY,
-			IPA_TCP_PORT_RSL, 0, rsl_listen_fd_cb, NULL);
-	if (ret < 0)
-		return ret;
-
-	return ret;
+	return 0;
 }
diff --git a/openbsc/src/openbsc.cfg.nanobts b/openbsc/src/openbsc.cfg.nanobts
index 3e7b932..e132655 100644
--- a/openbsc/src/openbsc.cfg.nanobts
+++ b/openbsc/src/openbsc.cfg.nanobts
@@ -73,3 +73,6 @@ network
      phys_chan_config TCH/F
     timeslot 7
      phys_chan_config TCH/F
+
+ipa
+ setup
diff --git a/openbsc/src/openbsc.cfg.nanobts.multitrx b/openbsc/src/openbsc.cfg.nanobts.multitrx
index 9c9108c..969f50d 100644
--- a/openbsc/src/openbsc.cfg.nanobts.multitrx
+++ b/openbsc/src/openbsc.cfg.nanobts.multitrx
@@ -95,3 +95,6 @@ network
      phys_chan_config TCH/F
     timeslot 7
      phys_chan_config TCH/F
+
+ipa
+ setup
-- 
1.7.2.3





More information about the OpenBSC mailing list