osmith submitted this change.
Initialize MGW pool on start up
Make the MGW pool configurable in the VTY and connect to each configured
MGW instance on start up. This is in preparation for the
subscr_conn_fsm, which will allocate own MGCP connections while
processing BSSMAP assignment request and related messages.
Related: SYS#5560
Change-Id: I6030a1f5a9d5fb06f148b2a2e03ae57bcb6b3766
---
M configure.ac
M contrib/jenkins.sh
M contrib/osmo-bsc-nat.spec.in
M debian/control
M doc/examples/osmo-bsc-nat/osmo-bsc-nat.cfg
M include/osmocom/bsc_nat/bsc_nat.h
M include/osmocom/bsc_nat/vty.h
M src/osmo-bsc-nat/Makefile.am
M src/osmo-bsc-nat/bsc_nat.c
M src/osmo-bsc-nat/bsc_nat_fsm.c
M src/osmo-bsc-nat/vty.c
11 files changed, 65 insertions(+), 0 deletions(-)
diff --git a/configure.ac b/configure.ac
index 43f38f7..e3d3aeb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -57,6 +57,7 @@
PKG_CHECK_MODULES(LIBOSMOABIS, libosmoabis >= 1.2.0)
PKG_CHECK_MODULES(LIBOSMONETIF, libosmo-netif >= 1.1.0)
PKG_CHECK_MODULES(LIBOSMOSIGTRAN, libosmo-sigtran >= 1.5.0)
+PKG_CHECK_MODULES(LIBOSMOMGCPCLIENT, libosmo-mgcp-client >= 1.9.0)
dnl checks for header files
AC_HEADER_STDC
diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index 8441344..d4d6733 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -33,6 +33,7 @@
osmo-build-dep.sh libosmo-abis
osmo-build-dep.sh libosmo-netif
osmo-build-dep.sh libosmo-sccp
+osmo-build-dep.sh osmo-mgw
# Additional configure options and depends
CONFIG=""
diff --git a/contrib/osmo-bsc-nat.spec.in b/contrib/osmo-bsc-nat.spec.in
index 97a07ae..ed89f27 100644
--- a/contrib/osmo-bsc-nat.spec.in
+++ b/contrib/osmo-bsc-nat.spec.in
@@ -35,6 +35,7 @@
BuildRequires: pkgconfig(libcrypto) >= 0.9.5
BuildRequires: pkgconfig(libosmo-netif) >= 1.1.0
BuildRequires: pkgconfig(libosmo-sigtran) >= 1.5.0
+BuildRequires: pkgconfig(libosmo-mgcp-client) >= 1.9.0
BuildRequires: pkgconfig(libosmoabis) >= 1.2.0
BuildRequires: pkgconfig(libosmocore) >= 1.6.0
BuildRequires: pkgconfig(libosmoctrl) >= 1.6.0
diff --git a/debian/control b/debian/control
index c542881..35edf84 100644
--- a/debian/control
+++ b/debian/control
@@ -15,6 +15,7 @@
libosmo-sigtran-dev (>= 1.5.0),
libosmo-abis-dev (>= 1.2.0),
libosmo-netif-dev (>= 1.1.0),
+ libosmo-mgcp-client-dev (>= 1.9.0),
osmo-gsm-manuals-dev (>= 1.2.0)
Standards-Version: 3.9.8
Vcs-Git: git://git.osmocom.org/osmo-bsc-nat.git
diff --git a/doc/examples/osmo-bsc-nat/osmo-bsc-nat.cfg b/doc/examples/osmo-bsc-nat/osmo-bsc-nat.cfg
index 2f5ff39..a82b451 100644
--- a/doc/examples/osmo-bsc-nat/osmo-bsc-nat.cfg
+++ b/doc/examples/osmo-bsc-nat/osmo-bsc-nat.cfg
@@ -17,3 +17,10 @@
bsc-nat
cs7-instance-cn 0
cs7-instance-ran 1
+
+mgw 0
+ mgw remote-ip 127.0.0.14
+ mgw remote-port 2427
+ mgw local-ip 127.0.0.15
+ mgw local-port 2427
+ mgw endpoint-domain bscnat
diff --git a/include/osmocom/bsc_nat/bsc_nat.h b/include/osmocom/bsc_nat/bsc_nat.h
index 93717cc..032386a 100644
--- a/include/osmocom/bsc_nat/bsc_nat.h
+++ b/include/osmocom/bsc_nat/bsc_nat.h
@@ -20,6 +20,8 @@
#pragma once
#include <osmocom/core/fsm.h>
+#include <osmocom/core/tdef.h>
+#include <osmocom/mgcp_client/mgcp_client_pool.h>
#include <osmocom/sigtran/sccp_sap.h>
enum bsc_nat_net {
@@ -40,6 +42,11 @@
struct llist_head subscr_conns; /* list of struct subscr_conn */
struct {
+ struct mgcp_client_pool *pool;
+ struct osmo_tdef *tdefs;
+ } mgw;
+
+ struct {
struct bsc_nat_sccp_inst *sccp_inst;
uint32_t subscr_conn_id_next;
struct llist_head mscs; /* list of struct msc */
@@ -61,3 +68,4 @@
extern void *tall_bsc_nat_ctx;
extern struct bsc_nat *g_bsc_nat;
+extern struct osmo_tdef_group g_bsc_nat_tdef_group[];
diff --git a/include/osmocom/bsc_nat/vty.h b/include/osmocom/bsc_nat/vty.h
index 9a842b5..9ced790 100644
--- a/include/osmocom/bsc_nat/vty.h
+++ b/include/osmocom/bsc_nat/vty.h
@@ -24,6 +24,7 @@
#include <osmocom/vty/command.h>
enum bsc_nat_vty_nodes {
+ MGW_NODE,
BSC_NAT_NODE = _LAST_OSMOVTY_NODE,
};
diff --git a/src/osmo-bsc-nat/Makefile.am b/src/osmo-bsc-nat/Makefile.am
index e2b11ca..1ddb8ca 100644
--- a/src/osmo-bsc-nat/Makefile.am
+++ b/src/osmo-bsc-nat/Makefile.am
@@ -13,6 +13,7 @@
$(LIBOSMONETIF_CFLAGS) \
$(COVERAGE_CFLAGS) \
$(LIBOSMOABIS_CFLAGS) \
+ $(LIBOSMOMGCPCLIENT_CFLAGS) \
$(LIBOSMOSIGTRAN_CFLAGS) \
$(NULL)
@@ -45,5 +46,6 @@
$(LIBOSMONETIF_LIBS) \
$(COVERAGE_LDFLAGS) \
$(LIBOSMOABIS_LIBS) \
+ $(LIBOSMOMGCPCLIENT_LIBS) \
$(LIBOSMOSIGTRAN_LIBS) \
$(NULL)
diff --git a/src/osmo-bsc-nat/bsc_nat.c b/src/osmo-bsc-nat/bsc_nat.c
index 7ba24e6..b847679 100644
--- a/src/osmo-bsc-nat/bsc_nat.c
+++ b/src/osmo-bsc-nat/bsc_nat.c
@@ -28,6 +28,16 @@
#include <osmocom/bsc_nat/msc.h>
#include <osmocom/bsc_nat/subscr_conn.h>
+struct osmo_tdef g_mgw_tdefs[] = {
+ { .T = -2427, .default_val = 5, .desc = "timeout for MGCP response from MGW" },
+ {}
+};
+
+struct osmo_tdef_group g_bsc_nat_tdef_group[] = {
+ { .name = "mgw", .tdefs = g_mgw_tdefs, .desc = "MGW (Media Gateway) interface" },
+ {}
+};
+
struct bsc_nat *bsc_nat_alloc(void *tall_ctx)
{
struct bsc_nat *bsc_nat;
@@ -35,6 +45,10 @@
bsc_nat = talloc_zero(tall_ctx, struct bsc_nat);
OSMO_ASSERT(bsc_nat);
+ bsc_nat->mgw.pool = mgcp_client_pool_alloc(bsc_nat);
+ bsc_nat->mgw.tdefs = g_mgw_tdefs;
+ osmo_tdefs_reset(bsc_nat->mgw.tdefs);
+
bsc_nat->cn.sccp_inst = talloc_zero(bsc_nat, struct bsc_nat_sccp_inst);
OSMO_ASSERT(bsc_nat->cn.sccp_inst);
talloc_set_name_const(bsc_nat->cn.sccp_inst, "struct bsc_nat_sccp_inst (CN)");
diff --git a/src/osmo-bsc-nat/bsc_nat_fsm.c b/src/osmo-bsc-nat/bsc_nat_fsm.c
index d3a3b01..30486ce 100644
--- a/src/osmo-bsc-nat/bsc_nat_fsm.c
+++ b/src/osmo-bsc-nat/bsc_nat_fsm.c
@@ -344,6 +344,24 @@
talloc_free(sccp_inst);
}
+static int mgw_init(struct mgcp_client_pool *pool)
+{
+ unsigned int pool_members_initialized;
+
+ /* Initialize MGW pool. This initalizes and connects all MGCP clients that are currently configured in
+ * the pool. Adding additional MGCP clients to the pool is possible but the user has to configure and
+ * (re)connect them manually from the VTY. */
+ pool_members_initialized = mgcp_client_pool_connect(pool);
+ if (!pool_members_initialized) {
+ LOGP(DMAIN, LOGL_ERROR, "Failed to initialize any MGW pool members!\n");
+ return -1;
+ }
+
+ LOGP(DMAIN, LOGL_NOTICE, "MGW pool with %u pool member(s) initialized\n", pool_members_initialized);
+
+ return 0;
+}
+
static void st_starting_on_enter(struct osmo_fsm_inst *fi, uint32_t prev_state)
{
struct bsc_nat *bsc_nat = (struct bsc_nat *)fi->priv;
@@ -358,6 +376,11 @@
return;
}
+ if (mgw_init(bsc_nat->mgw.pool) < 0) {
+ osmo_fsm_inst_state_chg(fi, BSC_NAT_FSM_ST_STOPPED, 0, 0);
+ return;
+ }
+
osmo_fsm_inst_state_chg(fi, BSC_NAT_FSM_ST_STARTED, 0, 0);
}
diff --git a/src/osmo-bsc-nat/vty.c b/src/osmo-bsc-nat/vty.c
index bf86faa..852b1db 100644
--- a/src/osmo-bsc-nat/vty.c
+++ b/src/osmo-bsc-nat/vty.c
@@ -19,8 +19,10 @@
#include "config.h"
#include <unistd.h>
+#include <osmocom/mgcp_client/mgcp_client_pool.h>
#include <osmocom/vty/command.h>
#include <osmocom/vty/logging.h>
+#include <osmocom/vty/tdef_vty.h>
#include <osmocom/vty/telnet_interface.h>
#include <osmocom/bsc_nat/bsc_nat.h>
#include <osmocom/bsc_nat/vty.h>
@@ -77,4 +79,8 @@
install_node(&bsc_nat_node, config_write_bsc_nat);
install_element(BSC_NAT_NODE, &cfg_cs7_instance_cn_cmd);
install_element(BSC_NAT_NODE, &cfg_cs7_instance_ran_cmd);
+
+ osmo_tdef_vty_groups_init(CONFIG_NODE, g_bsc_nat_tdef_group);
+
+ mgcp_client_pool_vty_init(CONFIG_NODE, MGW_NODE, "", g_bsc_nat->mgw.pool);
}
To view, visit change 27707. To unsubscribe, or for help writing mail filters, visit settings.