Change in osmo-mgw[master]: Add CTRL interface to osmo-mgw

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

laforge gerrit-no-reply at lists.osmocom.org
Sun Mar 8 09:47:05 UTC 2020


laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-mgw/+/17421 )


Change subject: Add CTRL interface to osmo-mgw
......................................................................

Add CTRL interface to osmo-mgw

OsmoMGW has a lot of nice built-in statistics (rate_ctr,...) but it
seems the only way to look at them is via the VTY. While libosmocore
contains automatic exposure of all rate counters via CTRL, the CTRL
interface simply is not used by osmo-mgw so far.

Closes: OS#4441
Change-Id: I7ed6bdb9f4749c24ca11a5905a620546cfe42952
---
M configure.ac
M include/osmocom/mgcp/Makefile.am
M include/osmocom/mgcp/mgcp.h
A include/osmocom/mgcp/mgcp_ctrl.h
M src/libosmo-mgcp/Makefile.am
A src/libosmo-mgcp/mgcp_ctrl.c
M src/osmo-mgw/Makefile.am
M src/osmo-mgw/mgw_main.c
8 files changed, 83 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/21/17421/1

diff --git a/configure.ac b/configure.ac
index c74526b..880a756 100644
--- a/configure.ac
+++ b/configure.ac
@@ -41,6 +41,7 @@
 
 PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 1.1.0)
 PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 1.1.0)
+PKG_CHECK_MODULES(LIBOSMOCTRL, libosmoctrl >= 1.1.0)
 PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 1.1.0)
 PKG_CHECK_MODULES(LIBOSMONETIF, libosmo-netif >= 0.6.0)
 
diff --git a/include/osmocom/mgcp/Makefile.am b/include/osmocom/mgcp/Makefile.am
index 65ca670..036b4ca 100644
--- a/include/osmocom/mgcp/Makefile.am
+++ b/include/osmocom/mgcp/Makefile.am
@@ -6,5 +6,6 @@
 	mgcp_endp.h \
 	mgcp_sdp.h \
 	mgcp_codec.h \
+	mgcp_ctrl.h \
 	debug.h \
 	$(NULL)
diff --git a/include/osmocom/mgcp/mgcp.h b/include/osmocom/mgcp/mgcp.h
index 71d6342..a479fbb 100644
--- a/include/osmocom/mgcp/mgcp.h
+++ b/include/osmocom/mgcp/mgcp.h
@@ -279,6 +279,9 @@
 
 	/* time after which inactive connections (CIs) get closed */
 	int conn_timeout;
+
+	/* osmocom CTRL interface */
+	struct ctrl_handle *ctrl;
 };
 
 /* config management */
diff --git a/include/osmocom/mgcp/mgcp_ctrl.h b/include/osmocom/mgcp/mgcp_ctrl.h
new file mode 100644
index 0000000..d7ab7cb
--- /dev/null
+++ b/include/osmocom/mgcp/mgcp_ctrl.h
@@ -0,0 +1,24 @@
+/*
+ * (C) 2020 by Harald Welte <laforge at gnumonks.org>
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#pragma once
+
+struct ctrl_handle *mgw_ctrl_interface_setup(struct mgcp_config *cfg,
+                                             const char *bind_addr, uint16_t port);
+
diff --git a/src/libosmo-mgcp/Makefile.am b/src/libosmo-mgcp/Makefile.am
index 587bdd4..a0c015b 100644
--- a/src/libosmo-mgcp/Makefile.am
+++ b/src/libosmo-mgcp/Makefile.am
@@ -40,4 +40,5 @@
 	mgcp_conn.c \
 	mgcp_stat.c \
 	mgcp_endp.c \
+	mgcp_ctrl.c \
 	$(NULL)
diff --git a/src/libosmo-mgcp/mgcp_ctrl.c b/src/libosmo-mgcp/mgcp_ctrl.c
new file mode 100644
index 0000000..0ba231b
--- /dev/null
+++ b/src/libosmo-mgcp/mgcp_ctrl.c
@@ -0,0 +1,36 @@
+/*
+ * (C) 2020 by Harald Welte <laforge at gnumonks.org>
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <osmocom/ctrl/control_if.h>
+#include <osmocom/mgcp/mgcp.h>
+
+
+static int mgw_ctrl_node_lookup(void *data, vector vline, int *node_type,
+				void **node_data, int *i)
+{
+	return 0;
+}
+
+
+struct ctrl_handle *mgw_ctrl_interface_setup(struct mgcp_config *cfg,
+					     const char *bind_addr, uint16_t port)
+{
+	return ctrl_interface_setup_dynip2(cfg, bind_addr, port, mgw_ctrl_node_lookup,
+					   _LAST_CTRL_NODE);
+}
diff --git a/src/osmo-mgw/Makefile.am b/src/osmo-mgw/Makefile.am
index a076d4c..d38df9f 100644
--- a/src/osmo-mgw/Makefile.am
+++ b/src/osmo-mgw/Makefile.am
@@ -9,6 +9,7 @@
 	$(LIBOSMOCORE_CFLAGS) \
 	$(LIBOSMOVTY_CFLAGS) \
 	$(LIBOSMOGSM_CFLAGS) \
+	$(LIBOSMOCTRL_CFLAGS) \
 	$(LIBOSMONETIF_CFLAGS) \
 	$(COVERAGE_CFLAGS) \
 	$(NULL)
@@ -26,5 +27,6 @@
 	$(LIBOSMOCORE_LIBS) \
 	$(LIBOSMOVTY_LIBS) \
 	$(LIBOSMOGSM_LIBS) \
+	$(LIBOSMOCTRL_LIBS) \
 	$(LIBOSMONETIF_LIBS) \
 	$(NULL)
diff --git a/src/osmo-mgw/mgw_main.c b/src/osmo-mgw/mgw_main.c
index 4168e0d..48869c4 100644
--- a/src/osmo-mgw/mgw_main.c
+++ b/src/osmo-mgw/mgw_main.c
@@ -38,6 +38,7 @@
 #include <osmocom/mgcp/vty.h>
 #include <osmocom/mgcp/debug.h>
 #include <osmocom/mgcp/mgcp_endp.h>
+#include <osmocom/mgcp/mgcp_ctrl.h>
 
 #include <osmocom/core/application.h>
 #include <osmocom/core/msgb.h>
@@ -48,6 +49,8 @@
 #include <osmocom/core/logging.h>
 #include <osmocom/core/socket.h>
 
+#include <osmocom/ctrl/control_vty.h>
+
 #include <osmocom/vty/telnet_interface.h>
 #include <osmocom/vty/logging.h>
 #include <osmocom/vty/ports.h>
@@ -60,6 +63,11 @@
 #define _GNU_SOURCE
 #include <getopt.h>
 
+/* can be changed once libosmocore 1.4.0 is released */
+#ifndef OSMO_CTRL_PORT_MGW
+#define OSMO_CTRL_PORT_MGW 4267
+#endif
+
 /* FIXME: Make use of the rtp proxy code */
 
 static struct mgcp_config *cfg;
@@ -278,6 +286,7 @@
 	osmo_talloc_vty_add_cmds();
 	osmo_stats_vty_add_cmds();
 	mgcp_vty_init();
+	ctrl_vty_init(cfg);
 
 	handle_options(argc, argv);
 
@@ -294,6 +303,12 @@
 	if (rc < 0)
 		return rc;
 
+	cfg->ctrl = mgw_ctrl_interface_setup(cfg, ctrl_vty_get_bind_addr(), OSMO_CTRL_PORT_MGW);
+	if (!cfg->ctrl) {
+		fprintf(stderr, "Failed to init the control interface on %s:%u. Exiting\n",
+			ctrl_vty_get_bind_addr(), OSMO_CTRL_PORT_MGW);
+	}
+
 	/* Set the reset callback function. This functions is called when the
 	 * mgcp-command "RSIP" (Reset in Progress) is received */
 	cfg->reset_cb = mgcp_rsip_cb;

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

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: I7ed6bdb9f4749c24ca11a5905a620546cfe42952
Gerrit-Change-Number: 17421
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200308/b38f0282/attachment.htm>


More information about the gerrit-log mailing list