<p>pespin <strong>submitted</strong> this change.</p><p><a href="https://gerrit.osmocom.org/c/osmo-hnodeb/+/26014">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  pespin: Verified
  laforge: Looks good to me, approved
  fixeria: Looks good to me, but someone else must approve

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Set up Iuh conn params through VTY<br><br>Change-Id: Id5a17742643e8f02c22228e3055bcc213423a416<br>---<br>M include/osmocom/hnodeb/hnodeb.h<br>M include/osmocom/hnodeb/vty.h<br>M src/osmo-hnodeb/hnb.c<br>M src/osmo-hnodeb/main.c<br>M src/osmo-hnodeb/vty.c<br>5 files changed, 146 insertions(+), 19 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/include/osmocom/hnodeb/hnodeb.h b/include/osmocom/hnodeb/hnodeb.h</span><br><span>index 50432d1..effd1b8 100644</span><br><span>--- a/include/osmocom/hnodeb/hnodeb.h</span><br><span>+++ b/include/osmocom/hnodeb/hnodeb.h</span><br><span>@@ -70,8 +70,12 @@</span><br><span> };</span><br><span> </span><br><span> struct hnb {</span><br><span style="color: hsl(0, 100%, 40%);">-    const char *gw_addr;</span><br><span style="color: hsl(0, 100%, 40%);">-    uint16_t gw_port;</span><br><span style="color: hsl(120, 100%, 40%);">+     struct {</span><br><span style="color: hsl(120, 100%, 40%);">+              char *local_addr;</span><br><span style="color: hsl(120, 100%, 40%);">+             uint16_t local_port;</span><br><span style="color: hsl(120, 100%, 40%);">+          char *remote_addr;</span><br><span style="color: hsl(120, 100%, 40%);">+            uint16_t remote_port;</span><br><span style="color: hsl(120, 100%, 40%);">+ } iuh;</span><br><span>       /*! SCTP listen socket for incoming connections */</span><br><span>   struct osmo_fd conn_fd;</span><br><span> </span><br><span>@@ -91,8 +95,6 @@</span><br><span> </span><br><span>  uint32_t ctx_id;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-    int ues;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span>     struct {</span><br><span>             struct hnb_chan *chan;</span><br><span>       } cs;</span><br><span>diff --git a/include/osmocom/hnodeb/vty.h b/include/osmocom/hnodeb/vty.h</span><br><span>index 7e3f29f..7144d3f 100644</span><br><span>--- a/include/osmocom/hnodeb/vty.h</span><br><span>+++ b/include/osmocom/hnodeb/vty.h</span><br><span>@@ -25,7 +25,10 @@</span><br><span> #include <osmocom/vty/command.h></span><br><span> </span><br><span> enum hnb_vty_nodes {</span><br><span style="color: hsl(0, 100%, 40%);">-   CHAN_NODE = _LAST_OSMOVTY_NODE,</span><br><span style="color: hsl(120, 100%, 40%);">+       HNODEB_NODE = _LAST_OSMOVTY_NODE,</span><br><span style="color: hsl(120, 100%, 40%);">+     IUH_NODE,</span><br><span style="color: hsl(120, 100%, 40%);">+     CHAN_NODE,</span><br><span> };</span><br><span> </span><br><span> void hnb_vty_init(void);</span><br><span style="color: hsl(120, 100%, 40%);">+int hnb_vty_go_parent(struct vty *vty);</span><br><span>diff --git a/src/osmo-hnodeb/hnb.c b/src/osmo-hnodeb/hnb.c</span><br><span>index 335fd3a..85ca937 100644</span><br><span>--- a/src/osmo-hnodeb/hnb.c</span><br><span>+++ b/src/osmo-hnodeb/hnb.c</span><br><span>@@ -137,8 +137,10 @@</span><br><span>    if (!hnb)</span><br><span>            return NULL;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-        hnb->gw_addr = "127.0.0.1",</span><br><span style="color: hsl(0, 100%, 40%);">-        hnb->gw_port = IUH_DEFAULT_SCTP_PORT,</span><br><span style="color: hsl(120, 100%, 40%);">+      hnb->iuh.local_addr = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+        hnb->iuh.local_port = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+   hnb->iuh.remote_addr = talloc_strdup(hnb, "127.0.0.1");</span><br><span style="color: hsl(120, 100%, 40%);">+  hnb->iuh.remote_port = IUH_DEFAULT_SCTP_PORT;</span><br><span> </span><br><span>         osmo_wqueue_init(&hnb->wqueue, 16);</span><br><span>   hnb->wqueue.bfd.data = hnb;</span><br><span>@@ -151,9 +153,14 @@</span><br><span> int hnb_connect(struct hnb *hnb)</span><br><span> {</span><br><span>       int rc;</span><br><span style="color: hsl(0, 100%, 40%);">- rc = osmo_sock_init_ofd(&hnb->wqueue.bfd, AF_INET, SOCK_STREAM,</span><br><span style="color: hsl(0, 100%, 40%);">-                     IPPROTO_SCTP, hnb->gw_addr,</span><br><span style="color: hsl(0, 100%, 40%);">-                          hnb->gw_port, OSMO_SOCK_F_CONNECT);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   LOGP(DMAIN, LOGL_INFO, "Iuh Connect: %s[:%u] => %s[:%u]\n",</span><br><span style="color: hsl(120, 100%, 40%);">+           hnb->iuh.local_addr, hnb->iuh.local_port, hnb->iuh.remote_addr, hnb->iuh.remote_port);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     rc = osmo_sock_init2_ofd(&hnb->wqueue.bfd, AF_INET, SOCK_STREAM, IPPROTO_SCTP,</span><br><span style="color: hsl(120, 100%, 40%);">+                    hnb->iuh.local_addr, hnb->iuh.local_port,</span><br><span style="color: hsl(120, 100%, 40%);">+                       hnb->iuh.remote_addr, hnb->iuh.remote_port,</span><br><span style="color: hsl(120, 100%, 40%);">+                     OSMO_SOCK_F_BIND |OSMO_SOCK_F_CONNECT);</span><br><span>   if (rc < 0)</span><br><span>               return rc;</span><br><span>   sctp_sock_init(hnb->wqueue.bfd.fd);</span><br><span>diff --git a/src/osmo-hnodeb/main.c b/src/osmo-hnodeb/main.c</span><br><span>index cbf606d..3376d8e 100644</span><br><span>--- a/src/osmo-hnodeb/main.c</span><br><span>+++ b/src/osmo-hnodeb/main.c</span><br><span>@@ -75,6 +75,7 @@</span><br><span> static struct vty_app_info vty_info = {</span><br><span>   .name           = "OsmoHNodeB",</span><br><span>    .version        = PACKAGE_VERSION,</span><br><span style="color: hsl(120, 100%, 40%);">+    .go_parent_cb   = hnb_vty_go_parent,</span><br><span> };</span><br><span> </span><br><span> static void print_usage()</span><br><span>@@ -140,12 +141,10 @@</span><br><span>                  {"log-level", 1, 0, 'e'},</span><br><span>                  {"vty-ref-mode", 1, &long_option, 1},</span><br><span>                  {"vty-ref-xml", 0, &long_option, 2},</span><br><span style="color: hsl(0, 100%, 40%);">-                      { "ues", 1, 0, 'u' },</span><br><span style="color: hsl(0, 100%, 40%);">-                 { "gw-addr", 1, 0, 'g' },</span><br><span>                  { 0, 0, 0, 0 },</span><br><span>              };</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-          c = getopt_long(argc, argv, "hd:Dc:sTVe:u:g:", long_options, &idx);</span><br><span style="color: hsl(120, 100%, 40%);">+             c = getopt_long(argc, argv, "hd:Dc:sTVe:", long_options, &idx);</span><br><span> </span><br><span>            if (c == -1)</span><br><span>                         break;</span><br><span>@@ -180,12 +179,6 @@</span><br><span>                case 'e':</span><br><span>                    log_set_log_level(osmo_stderr_target, atoi(optarg));</span><br><span>                         break;</span><br><span style="color: hsl(0, 100%, 40%);">-          case 'u':</span><br><span style="color: hsl(0, 100%, 40%);">-                       g_hnb->ues = atoi(optarg);</span><br><span style="color: hsl(0, 100%, 40%);">-                   break;</span><br><span style="color: hsl(0, 100%, 40%);">-          case 'g':</span><br><span style="color: hsl(0, 100%, 40%);">-                       g_hnb->gw_addr = optarg;</span><br><span style="color: hsl(0, 100%, 40%);">-                     break;</span><br><span>               default:</span><br><span>                     /* catch unknown options *as well as* missing arguments. */</span><br><span>                  fprintf(stderr, "Error in command line options. Exiting.\n");</span><br><span>diff --git a/src/osmo-hnodeb/vty.c b/src/osmo-hnodeb/vty.c</span><br><span>index 114f1c0..4d665f8 100644</span><br><span>--- a/src/osmo-hnodeb/vty.c</span><br><span>+++ b/src/osmo-hnodeb/vty.c</span><br><span>@@ -37,6 +37,119 @@</span><br><span> #include <osmocom/hnodeb/vty.h></span><br><span> #include <osmocom/hnodeb/hnodeb.h></span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+int hnb_vty_go_parent(struct vty *vty)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+    switch (vty->node) {</span><br><span style="color: hsl(120, 100%, 40%);">+       case IUH_NODE:</span><br><span style="color: hsl(120, 100%, 40%);">+                vty->node = HNODEB_NODE;</span><br><span style="color: hsl(120, 100%, 40%);">+           vty->index = g_hnb;</span><br><span style="color: hsl(120, 100%, 40%);">+                break;</span><br><span style="color: hsl(120, 100%, 40%);">+        case HNODEB_NODE:</span><br><span style="color: hsl(120, 100%, 40%);">+             vty->node = CONFIG_NODE;</span><br><span style="color: hsl(120, 100%, 40%);">+           vty->index = g_hnb;</span><br><span style="color: hsl(120, 100%, 40%);">+                break;</span><br><span style="color: hsl(120, 100%, 40%);">+        case CONFIG_NODE:</span><br><span style="color: hsl(120, 100%, 40%);">+             vty->node = ENABLE_NODE;</span><br><span style="color: hsl(120, 100%, 40%);">+           vty->index = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+         break;</span><br><span style="color: hsl(120, 100%, 40%);">+        default:</span><br><span style="color: hsl(120, 100%, 40%);">+              vty->node = CONFIG_NODE;</span><br><span style="color: hsl(120, 100%, 40%);">+           vty->index = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+         break;</span><br><span style="color: hsl(120, 100%, 40%);">+        }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   return vty->node;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static struct cmd_node hnodeb_node = {</span><br><span style="color: hsl(120, 100%, 40%);">+     HNODEB_NODE,</span><br><span style="color: hsl(120, 100%, 40%);">+  "%s(config-hnodeb)# ",</span><br><span style="color: hsl(120, 100%, 40%);">+      1,</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#define HNODEB_STR "Configure the HNodeB\n"</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+DEFUN(cfg_hnodeb,</span><br><span style="color: hsl(120, 100%, 40%);">+      cfg_hnodeb_cmd,</span><br><span style="color: hsl(120, 100%, 40%);">+      "hnodeb", HNODEB_STR)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ OSMO_ASSERT(g_hnb);</span><br><span style="color: hsl(120, 100%, 40%);">+   vty->index = g_hnb;</span><br><span style="color: hsl(120, 100%, 40%);">+        vty->node = HNODEB_NODE;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ return CMD_SUCCESS;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static struct cmd_node iuh_node = {</span><br><span style="color: hsl(120, 100%, 40%);">+ IUH_NODE,</span><br><span style="color: hsl(120, 100%, 40%);">+     "%s(config-iuh)# ",</span><br><span style="color: hsl(120, 100%, 40%);">+ 1,</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+DEFUN(cfg_hnodeb_iuh,</span><br><span style="color: hsl(120, 100%, 40%);">+      cfg_hnodeb_iuh_cmd,</span><br><span style="color: hsl(120, 100%, 40%);">+      "iuh", "Configure Iuh options\n")</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+    OSMO_ASSERT(g_hnb);</span><br><span style="color: hsl(120, 100%, 40%);">+   vty->index = g_hnb;</span><br><span style="color: hsl(120, 100%, 40%);">+        vty->node = IUH_NODE;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+    return CMD_SUCCESS;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+DEFUN(cfg_hnodeb_iuh_local_ip, cfg_hnodeb_iuh_local_ip_cmd,</span><br><span style="color: hsl(120, 100%, 40%);">+      "local-ip " VTY_IPV46_CMD,</span><br><span style="color: hsl(120, 100%, 40%);">+      "Bind Iuh connection on local IP address\n"</span><br><span style="color: hsl(120, 100%, 40%);">+      "Local interface IPv4 address\n"</span><br><span style="color: hsl(120, 100%, 40%);">+      "Local interface IPv6 address\n")</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+        osmo_talloc_replace_string(g_hnb, &g_hnb->iuh.local_addr, argv[0]);</span><br><span style="color: hsl(120, 100%, 40%);">+    return CMD_SUCCESS;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+DEFUN(cfg_hnodeb_iuh_local_port, cfg_hnodeb_iuh_local_port_cmd,</span><br><span style="color: hsl(120, 100%, 40%);">+      "local-port <1-65535>",</span><br><span style="color: hsl(120, 100%, 40%);">+      "Bind Iuh connection on local SCTP port\n"</span><br><span style="color: hsl(120, 100%, 40%);">+      "Local interface port\n")</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+    g_hnb->iuh.local_port = atoi(argv[0]);</span><br><span style="color: hsl(120, 100%, 40%);">+     return CMD_SUCCESS;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+DEFUN(cfg_hnodeb_iuh_remote_ip, cfg_hnodeb_iuh_remote_ip_cmd,</span><br><span style="color: hsl(120, 100%, 40%);">+      "remote-ip " VTY_IPV46_CMD,</span><br><span style="color: hsl(120, 100%, 40%);">+      "Connect to HNBGW over Iuh on remote IP address\n"</span><br><span style="color: hsl(120, 100%, 40%);">+      "Remote interface IPv4 address\n"</span><br><span style="color: hsl(120, 100%, 40%);">+      "Remote interface IPv6 address\n")</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+    osmo_talloc_replace_string(g_hnb, &g_hnb->iuh.remote_addr, argv[0]);</span><br><span style="color: hsl(120, 100%, 40%);">+   return CMD_SUCCESS;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+DEFUN(cfg_hnodeb_iuh_remote_port, cfg_hnodeb_iuh_remote_port_cmd,</span><br><span style="color: hsl(120, 100%, 40%);">+      "remote-port <1-65535>",</span><br><span style="color: hsl(120, 100%, 40%);">+      "Connect to HNBGW over Iuh on remote SCTP port\n"</span><br><span style="color: hsl(120, 100%, 40%);">+      "Remote interface port (default: "OSMO_STRINGIFY_VAL(IUH_DEFAULT_SCTP_PORT) ")\n")</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+       g_hnb->iuh.remote_port = atoi(argv[0]);</span><br><span style="color: hsl(120, 100%, 40%);">+    return CMD_SUCCESS;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static int config_write_hnodeb(struct vty *vty)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+        vty_out(vty, "hnodeb%s", VTY_NEWLINE);</span><br><span style="color: hsl(120, 100%, 40%);">+      vty_out(vty, " iuh%s", VTY_NEWLINE);</span><br><span style="color: hsl(120, 100%, 40%);">+        if (g_hnb->iuh.local_addr)</span><br><span style="color: hsl(120, 100%, 40%);">+         vty_out(vty, "  local-ip %s%s", g_hnb->iuh.local_addr, VTY_NEWLINE);</span><br><span style="color: hsl(120, 100%, 40%);">+     if (g_hnb->iuh.local_port)</span><br><span style="color: hsl(120, 100%, 40%);">+         vty_out(vty, "  local-port %u%s", g_hnb->iuh.local_port, VTY_NEWLINE);</span><br><span style="color: hsl(120, 100%, 40%);">+   vty_out(vty, "  remote-ip %s%s", g_hnb->iuh.remote_addr, VTY_NEWLINE);</span><br><span style="color: hsl(120, 100%, 40%);">+   vty_out(vty, "  remote-port %u%s", g_hnb->iuh.remote_port, VTY_NEWLINE);</span><br><span style="color: hsl(120, 100%, 40%);">+ return CMD_SUCCESS;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> static struct cmd_node chan_node = {</span><br><span>   CHAN_NODE,</span><br><span>   "%s(chan)> ",</span><br><span>@@ -139,6 +252,15 @@</span><br><span> </span><br><span> void hnb_vty_init(void)</span><br><span> {</span><br><span style="color: hsl(120, 100%, 40%);">+ install_element(CONFIG_NODE, &cfg_hnodeb_cmd);</span><br><span style="color: hsl(120, 100%, 40%);">+    install_node(&hnodeb_node, config_write_hnodeb);</span><br><span style="color: hsl(120, 100%, 40%);">+  install_element(HNODEB_NODE, &cfg_hnodeb_iuh_cmd);</span><br><span style="color: hsl(120, 100%, 40%);">+        install_node(&iuh_node, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+    install_element(IUH_NODE, &cfg_hnodeb_iuh_local_ip_cmd);</span><br><span style="color: hsl(120, 100%, 40%);">+  install_element(IUH_NODE, &cfg_hnodeb_iuh_local_port_cmd);</span><br><span style="color: hsl(120, 100%, 40%);">+        install_element(IUH_NODE, &cfg_hnodeb_iuh_remote_ip_cmd);</span><br><span style="color: hsl(120, 100%, 40%);">+ install_element(IUH_NODE, &cfg_hnodeb_iuh_remote_port_cmd);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>    install_element_ve(&asn_dbg_cmd);</span><br><span>        install_element_ve(&hnb_register_cmd);</span><br><span>   install_element_ve(&hnb_deregister_cmd);</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-hnodeb/+/26014">change 26014</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/osmo-hnodeb/+/26014"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-hnodeb </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Id5a17742643e8f02c22228e3055bcc213423a416 </div>
<div style="display:none"> Gerrit-Change-Number: 26014 </div>
<div style="display:none"> Gerrit-PatchSet: 3 </div>
<div style="display:none"> Gerrit-Owner: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: fixeria <vyanitskiy@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-Reviewer: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>