aboutsummaryrefslogtreecommitdiffstats
path: root/src/hnbgw_vty.c
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-10-13 15:12:18 +0200
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-10-27 14:01:25 +0200
commit5ee050c1e7fde4e32e3334e7bf02c4f663474d55 (patch)
tree37d78c5ecd479ad0aa4293ba6db855453133b828 /src/hnbgw_vty.c
parentc510fc29fcf4999de8ba4992dd305968909ed69b (diff)
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
Diffstat (limited to 'src/hnbgw_vty.c')
-rw-r--r--src/hnbgw_vty.c113
1 files changed, 113 insertions, 0 deletions
diff --git a/src/hnbgw_vty.c b/src/hnbgw_vty.c
index a458c76..59871da 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,10 +55,38 @@ DEFUN(cfg_hnbgw_iuh, cfg_hnbgw_iuh_cmd,
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 IUH_NODE:
+ case IUCS_NODE:
+ case IUPS_NODE:
vty->node = HNBGW_NODE;
vty->index = NULL;
break;
@@ -153,6 +182,40 @@ DEFUN(cfg_hnbgw_iuh_hnbap_allow_tmsi, cfg_hnbgw_iuh_hnbap_allow_tmsi_cmd,
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)")
+{
+ g_hnb_gw->config.iucs_remote_port = atoi(argv[0]);
+ 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)")
+{
+ g_hnb_gw->config.iups_remote_port = atoi(argv[0]);
+ return CMD_SUCCESS;
+}
+
static int config_write_hnbgw(struct vty *vty)
{
vty_out(vty, "hnbgw%s", VTY_NEWLINE);
@@ -180,6 +243,42 @@ static int config_write_hnbgw_iuh(struct vty *vty)
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;
@@ -197,6 +296,20 @@ void hnbgw_vty_init(struct hnb_gw *gw, void *tall_ctx)
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);