[PATCH] osmo-iuh[master]: hnbgw: parameterize IuCS and IuPS ips and ports: add vty cmds

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 Oct 13 15:04:39 UTC 2016


Review at  https://gerrit.osmocom.org/1062

hnbgw: parameterize IuCS and IuPS ips and ports: add vty cmds

Basically copy-paste the Iuh local-ip and local-port code to provide
parameterization of the IuCS and IuPS remote addresses.

Add IUCS and IUPS nodes, enhance go_parent_cb and config writing accordingly.

Change-Id: I2c28977011009df4e1fa472290bbbc359e406971
---
M include/osmocom/iuh/hnbgw.h
M include/osmocom/iuh/vty.h
M src/hnbgw.c
M src/hnbgw_vty.c
4 files changed, 188 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-iuh refs/changes/62/1062/1

diff --git a/include/osmocom/iuh/hnbgw.h b/include/osmocom/iuh/hnbgw.h
index 6cc7984..2a776d4 100644
--- a/include/osmocom/iuh/hnbgw.h
+++ b/include/osmocom/iuh/hnbgw.h
@@ -20,6 +20,8 @@
 
 
 #define HNBGW_LOCAL_IP_DEFAULT "0.0.0.0"
+#define HNBGW_IUCS_REMOTE_IP_DEFAULT "127.0.0.1"
+#define HNBGW_IUPS_REMOTE_IP_DEFAULT "127.0.0.2"
 
 /* 25.467 Section 7.1 */
 #define IUH_DEFAULT_SCTP_PORT	29169
@@ -116,6 +118,10 @@
 		/*! The UDP port where we receive multiplexed CS user
 		 * plane traffic from HNBs */
 		uint16_t iuh_cs_mux_port;
+		const char *iucs_remote_ip;
+		uint16_t iucs_remote_port;
+		const char *iups_remote_ip;
+		uint16_t iups_remote_port;
 		uint16_t rnc_id;
 		bool hnbap_allow_tmsi;
 	} config;
@@ -152,3 +158,7 @@
 
 const char *hnbgw_get_iuh_local_ip(struct hnb_gw *gw);
 uint16_t hnbgw_get_iuh_local_port(struct hnb_gw *gw);
+const char *hnbgw_get_iucs_remote_ip(struct hnb_gw *gw);
+uint16_t hnbgw_get_iucs_remote_port(struct hnb_gw *gw);
+const char *hnbgw_get_iups_remote_ip(struct hnb_gw *gw);
+uint16_t hnbgw_get_iups_remote_port(struct hnb_gw *gw);
diff --git a/include/osmocom/iuh/vty.h b/include/osmocom/iuh/vty.h
index 905a949..3d05da5 100644
--- a/include/osmocom/iuh/vty.h
+++ b/include/osmocom/iuh/vty.h
@@ -5,5 +5,7 @@
 enum osmo_iuh_vty_node {
 	HNBGW_NODE = _LAST_OSMOVTY_NODE + 1,
 	IUH_NODE,
+	IUCS_NODE,
+	IUPS_NODE,
 };
 
diff --git a/src/hnbgw.c b/src/hnbgw.c
index ac988d8..c344235 100644
--- a/src/hnbgw.c
+++ b/src/hnbgw.c
@@ -329,6 +329,52 @@
 	return g_hnb_gw->config.iuh_local_port;
 }
 
+/*
+ * Return IP address passed to the hnbgw/iucs/remote-ip command, or
+ * HNBGW_IUCS_REMOTE_IP_DEFAULT.
+ */
+const char *hnbgw_get_iucs_remote_ip(struct hnb_gw *gw)
+{
+	const char *addr = gw->config.iucs_remote_ip;
+	if (!addr)
+		addr = HNBGW_IUCS_REMOTE_IP_DEFAULT;
+	return addr;
+}
+
+/*
+ * Return IP address passed to the hnbgw/iucs/remote-port command, or
+ * SUA_PORT.
+ */
+uint16_t hnbgw_get_iucs_remote_port(struct hnb_gw *gw)
+{
+	if (!g_hnb_gw->config.iucs_remote_port)
+		return SUA_PORT;
+	return g_hnb_gw->config.iucs_remote_port;
+}
+
+/*
+ * Return IP address passed to the hnbgw/iups/remote-ip command, or
+ * HNBGW_IUPS_REMOTE_IP_DEFAULT.
+ */
+const char *hnbgw_get_iups_remote_ip(struct hnb_gw *gw)
+{
+	const char *addr = gw->config.iups_remote_ip;
+	if (!addr)
+		addr = HNBGW_IUPS_REMOTE_IP_DEFAULT;
+	return addr;
+}
+
+/*
+ * Return IP address passed to the hnbgw/iups/remote-port command, or
+ * SUA_PORT.
+ */
+uint16_t hnbgw_get_iups_remote_port(struct hnb_gw *gw)
+{
+	if (!g_hnb_gw->config.iups_remote_port)
+		return SUA_PORT;
+	return g_hnb_gw->config.iups_remote_port;
+}
+
 static const struct log_info_cat log_cat[] = {
 	[DMAIN] = {
 		.name = "DMAIN", .loglevel = LOGL_DEBUG, .enabled = 1,
@@ -517,8 +563,14 @@
 	osmo_sua_set_log_area(DSUA);
 	ranap_set_log_area(DRANAP);
 
-	g_hnb_gw->cnlink_cs = hnbgw_cnlink_init(g_hnb_gw, "127.0.0.1", SUA_PORT, 0);
-	g_hnb_gw->cnlink_ps = hnbgw_cnlink_init(g_hnb_gw, "127.0.0.2", SUA_PORT, 1);
+	g_hnb_gw->cnlink_cs = hnbgw_cnlink_init(g_hnb_gw,
+						hnbgw_get_iucs_remote_ip(g_hnb_gw),
+						hnbgw_get_iucs_remote_port(g_hnb_gw),
+						0);
+	g_hnb_gw->cnlink_ps = hnbgw_cnlink_init(g_hnb_gw,
+						hnbgw_get_iups_remote_ip(g_hnb_gw),
+						hnbgw_get_iups_remote_port(g_hnb_gw),
+						1);
 
 	LOGP(DMAIN, LOGL_NOTICE, "Listening for Iuh at %s %d\n",
 	     hnbgw_get_iuh_local_ip(g_hnb_gw),
diff --git a/src/hnbgw_vty.c b/src/hnbgw_vty.c
index 25930d1..8fdd7d6 100644
--- a/src/hnbgw_vty.c
+++ b/src/hnbgw_vty.c
@@ -24,6 +24,7 @@
 
 #include <osmocom/iuh/hnbgw.h>
 #include <osmocom/iuh/context_map.h>
+#include <osmocom/sigtran/protocol/sua.h>
 
 static void *tall_hnb_ctx = NULL;
 static struct hnb_gw *g_hnb_gw = NULL;
@@ -54,9 +55,40 @@
 	return CMD_SUCCESS;
 }
 
+static struct cmd_node iucs_node = {
+	IUCS_NODE,
+	"%s(config-hnbgw-iucs)# ",
+	1,
+};
+
+DEFUN(cfg_hnbgw_iucs, cfg_hnbgw_iucs_cmd,
+      "iucs", "Configure IuCS options")
+{
+	vty->node = IUCS_NODE;
+	return CMD_SUCCESS;
+}
+
+static struct cmd_node iups_node = {
+	IUPS_NODE,
+	"%s(config-hnbgw-iups)# ",
+	1,
+};
+
+DEFUN(cfg_hnbgw_iups, cfg_hnbgw_iups_cmd,
+      "iups", "Configure IuPS options")
+{
+	vty->node = IUPS_NODE;
+	return CMD_SUCCESS;
+}
+
 int hnbgw_vty_go_parent(struct vty *vty)
 {
 	switch (vty->node) {
+	case IUCS_NODE:
+	case IUPS_NODE:
+		vty->node = HNBGW_NODE;
+		vty->index = NULL;
+		break;
 	default:
 	case HNBGW_NODE:
 		vty->node = CONFIG_NODE;
@@ -152,6 +184,46 @@
 	return CMD_SUCCESS;
 }
 
+DEFUN(cfg_hnbgw_iucs_remote_ip, cfg_hnbgw_iucs_remote_ip_cmd, "remote-ip A.B.C.D",
+      "Address to establish IuCS core network link to\n"
+      "Remote IuCS IP address (default: " HNBGW_IUCS_REMOTE_IP_DEFAULT ")")
+{
+	talloc_free((void*)g_hnb_gw->config.iucs_remote_ip);
+	g_hnb_gw->config.iucs_remote_ip = talloc_strdup(tall_hnb_ctx, argv[0]);
+	return CMD_SUCCESS;
+}
+
+DEFUN(cfg_hnbgw_iucs_remote_port, cfg_hnbgw_iucs_remote_port_cmd, "remote-port <1-65535>",
+      "Remote port to establish IuCS core network link to\n"
+      "Remote IuCS port (default: 14001)")
+{
+	uint16_t port = atoi(argv[0]);
+	if (port == SUA_PORT)
+		port = 0;
+	g_hnb_gw->config.iucs_remote_port = port;
+	return CMD_SUCCESS;
+}
+
+DEFUN(cfg_hnbgw_iups_remote_ip, cfg_hnbgw_iups_remote_ip_cmd, "remote-ip A.B.C.D",
+      "Address to establish IuPS core network link to\n"
+      "Remote IuPS IP address (default: " HNBGW_IUPS_REMOTE_IP_DEFAULT ")")
+{
+	talloc_free((void*)g_hnb_gw->config.iups_remote_ip);
+	g_hnb_gw->config.iups_remote_ip = talloc_strdup(tall_hnb_ctx, argv[0]);
+	return CMD_SUCCESS;
+}
+
+DEFUN(cfg_hnbgw_iups_remote_port, cfg_hnbgw_iups_remote_port_cmd, "remote-port <1-65535>",
+      "Remote port to establish IuPS core network link to\n"
+      "Remote IuPS port (default: 14001)")
+{
+	uint16_t port = atoi(argv[0]);
+	if (port == SUA_PORT)
+		port = 0;
+	g_hnb_gw->config.iups_remote_port = port;
+	return CMD_SUCCESS;
+}
+
 static int config_write_hnbgw(struct vty *vty)
 {
 	vty_out(vty, "hnbgw%s", VTY_NEWLINE);
@@ -179,6 +251,42 @@
 	return CMD_SUCCESS;
 }
 
+static int config_write_hnbgw_iucs(struct vty *vty)
+{
+	const char *addr;
+	uint16_t port;
+
+	vty_out(vty, " iucs%s", VTY_NEWLINE);
+
+	addr = g_hnb_gw->config.iucs_remote_ip;
+	if (addr && (strcmp(addr, HNBGW_IUCS_REMOTE_IP_DEFAULT) != 0))
+		vty_out(vty, "  remote-ip %s%s", addr, VTY_NEWLINE);
+
+	port = g_hnb_gw->config.iucs_remote_port;
+	if (port && port != SUA_PORT)
+		vty_out(vty, "  remote-port %u%s", port, VTY_NEWLINE);
+
+	return CMD_SUCCESS;
+}
+
+static int config_write_hnbgw_iups(struct vty *vty)
+{
+	const char *addr;
+	uint16_t port;
+
+	vty_out(vty, " iups%s", VTY_NEWLINE);
+
+	addr = g_hnb_gw->config.iups_remote_ip;
+	if (addr && (strcmp(addr, HNBGW_IUPS_REMOTE_IP_DEFAULT) != 0))
+		vty_out(vty, "  remote-ip %s%s", addr, VTY_NEWLINE);
+
+	port = g_hnb_gw->config.iups_remote_port;
+	if (port && port != SUA_PORT)
+		vty_out(vty, "  remote-port %u%s", port, VTY_NEWLINE);
+
+	return CMD_SUCCESS;
+}
+
 void hnbgw_vty_init(struct hnb_gw *gw, void *tall_ctx)
 {
 	g_hnb_gw = gw;
@@ -196,6 +304,20 @@
 	install_element(IUH_NODE, &cfg_hnbgw_iuh_local_port_cmd);
 	install_element(IUH_NODE, &cfg_hnbgw_iuh_hnbap_allow_tmsi_cmd);
 
+	install_element(HNBGW_NODE, &cfg_hnbgw_iucs_cmd);
+	install_node(&iucs_node, config_write_hnbgw_iucs);
+	vty_install_default(IUCS_NODE);
+
+	install_element(IUCS_NODE, &cfg_hnbgw_iucs_remote_ip_cmd);
+	install_element(IUCS_NODE, &cfg_hnbgw_iucs_remote_port_cmd);
+
+	install_element(HNBGW_NODE, &cfg_hnbgw_iups_cmd);
+	install_node(&iups_node, config_write_hnbgw_iups);
+	vty_install_default(IUPS_NODE);
+
+	install_element(IUPS_NODE, &cfg_hnbgw_iups_remote_ip_cmd);
+	install_element(IUPS_NODE, &cfg_hnbgw_iups_remote_port_cmd);
+
 	install_element_ve(&show_hnb_cmd);
 	install_element_ve(&show_ue_cmd);
 	install_element_ve(&show_talloc_cmd);

-- 
To view, visit https://gerrit.osmocom.org/1062
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2c28977011009df4e1fa472290bbbc359e406971
Gerrit-PatchSet: 1
Gerrit-Project: osmo-iuh
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list