[PATCH] osmo-iuh[master]: vty: tweak / improve HNB and cnlink introspection

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 Dec 21 04:16:17 UTC 2017


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

vty: tweak / improve HNB and cnlink introspection

Add 'show cnlink'.

Tweak 'show hnb all'.

The result looks something like:

  OsmoHNBGW> show cnlink
  IuCS: 'OsmoHNBGW'=RI=SSN_PC,PC=0.23.5,SSN=RANAP <-> RI=SSN_PC,PC=0.23.1,SSN=RANAP
  IuPS: 'OsmoHNBGW'=RI=SSN_PC,PC=0.23.5,SSN=RANAP <-> RI=SSN_PC,PC=0.23.4,SSN=RANAP

  OsmoHNBGW> show hnb all
  No HNB connected

  OsmoHNBGW> show hnb all
  HNB 192.168.0.15:61809 "000295-0000154153 at ap.ipaccess.com"
      MCC 901 MNC 70 LAC 24358 RAC 22 SAC 65535 CID 1048575 SCCP-stream:HNBAP=0,RUA=0

  OsmoHNBGW> show hnb all
  HNB 192.168.0.15:61809 "000295-0000154153 at ap.ipaccess.com"
      MCC 901 MNC 70 LAC 24358 RAC 22 SAC 65535 CID 1048575 SCCP-stream:HNBAP=0,RUA=0
  HNB 192.168.0.124:61809 "000295-0000152614 at ap.ipaccess.com"
      MCC 901 MNC 70 LAC 14357 RAC 11 SAC 1 CID 8595638 SCCP-stream:HNBAP=0,RUA=0

  OsmoHNBGW> show hnb all
  HNB 192.168.0.15:61809 "000295-0000154153 at ap.ipaccess.com"
      MCC 901 MNC 70 LAC 24358 RAC 22 SAC 65535 CID 1048575 SCCP-stream:HNBAP=0,RUA=0
  HNB 192.168.0.124:61809 "000295-0000152614 at ap.ipaccess.com"
      MCC 901 MNC 70 LAC 14357 RAC 11 SAC 1 CID 8595638 SCCP-stream:HNBAP=0,RUA=0
      IuCS 23->1000 (RUA->SUA) state=1
      IuPS 23->1001 (RUA->SUA) state=1

  OsmoHNBGW> show hnb all
  HNB 192.168.0.15:61809 "000295-0000154153 at ap.ipaccess.com"
      MCC 901 MNC 70 LAC 24358 RAC 22 SAC 65535 CID 1048575 SCCP-stream:HNBAP=0,RUA=0
      IuCS 24->1002 (RUA->SUA) state=1
      IuPS 24->1003 (RUA->SUA) state=1
  HNB 192.168.0.124:61809 "000295-0000152614 at ap.ipaccess.com"
      MCC 901 MNC 70 LAC 14357 RAC 11 SAC 1 CID 8595638 SCCP-stream:HNBAP=0,RUA=0
      IuCS 23->1000 (RUA->SUA) state=1
      IuPS 23->1001 (RUA->SUA) state=1

Related: OS#2772 OS#2773
Change-Id: I3c937306a011715e163a40bc8ef8ec7e8d4e5d08
---
M src/hnbgw_vty.c
1 file changed, 59 insertions(+), 7 deletions(-)


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

diff --git a/src/hnbgw_vty.c b/src/hnbgw_vty.c
index 3d16970..16efb05 100644
--- a/src/hnbgw_vty.c
+++ b/src/hnbgw_vty.c
@@ -19,6 +19,7 @@
  */
 
 #include <string.h>
+#include <arpa/inet.h>
 
 #include <osmocom/vty/command.h>
 
@@ -27,6 +28,8 @@
 #include <osmocom/iuh/hnbgw.h>
 #include <osmocom/iuh/context_map.h>
 #include <osmocom/sigtran/protocol/sua.h>
+#include <osmocom/sigtran/sccp_helpers.h>
+#include <osmocom/netif/stream.h>
 
 static void *tall_hnb_ctx = NULL;
 static struct hnb_gw *g_hnb_gw = NULL;
@@ -108,19 +111,62 @@
 	return vty->node;
 }
 
+static void vty_dump_cnlink_info(struct vty *vty)
+{
+#define QUOTE(STR) \
+	STR ? "'" : "", \
+	STR ? STR : "", \
+	STR ? "':" : ""
+	
+	vty_out(vty, "IuCS: %s <->",
+		osmo_sccp_user_name(g_hnb_gw->sccp.cnlink->sccp_user));
+	vty_out(vty, " %s%s%s%s%s",
+		QUOTE(g_hnb_gw->config.iucs_remote_addr_name),
+		osmo_sccp_inst_addr_name(g_hnb_gw->sccp.client, &g_hnb_gw->sccp.iucs_remote_addr),
+		VTY_NEWLINE);
+	vty_out(vty, "IuPS: %s <->",
+		osmo_sccp_user_name(g_hnb_gw->sccp.cnlink->sccp_user));
+	vty_out(vty, " %s%s%s%s%s",
+		QUOTE(g_hnb_gw->config.iups_remote_addr_name),
+		osmo_sccp_inst_addr_name(g_hnb_gw->sccp.client, &g_hnb_gw->sccp.iups_remote_addr),
+		VTY_NEWLINE);
+}
+
+DEFUN(show_cnlink, show_cnlink_cmd, "show cnlink",
+      SHOW_STR "Display information on core network link\n")
+{
+	vty_dump_cnlink_info(vty);
+	return CMD_SUCCESS;
+}
+
+static void vty_out_ofd_addr(struct vty *vty, struct osmo_fd *ofd)
+{
+    struct sockaddr_in addr;
+    socklen_t addr_size = sizeof(struct sockaddr_in);
+    if (!ofd || ofd->fd < 0
+	|| getpeername(ofd->fd, (struct sockaddr *)&addr, &addr_size)) {
+	    vty_out(vty, "(no addr)");
+	    return;
+    }
+    vty_out(vty, "%s:%u", inet_ntoa(addr.sin_addr), addr.sin_port);
+}
+
 static void vty_dump_hnb_info(struct vty *vty, struct hnb_context *hnb)
 {
 	struct hnbgw_context_map *map;
 
-	vty_out(vty, "HNB \"%s\" MCC %u MNC %u LAC %u RAC %u SAC %u CID %u%s", hnb->identity_info,
-			hnb->id.mcc, hnb->id.mnc, hnb->id.lac, hnb->id.rac, hnb->id.sac, hnb->id.cid,
-			VTY_NEWLINE);
-	vty_out(vty, "   HNBAP ID %u RUA ID %u%s", hnb->hnbap_stream, hnb->rua_stream, VTY_NEWLINE);
+	vty_out(vty, "HNB ");
+	vty_out_ofd_addr(vty, hnb->conn? osmo_stream_srv_get_ofd(hnb->conn) : NULL);
+	vty_out(vty, " \"%s\"%s", hnb->identity_info, VTY_NEWLINE);
+	vty_out(vty, "    MCC %u MNC %u LAC %u RAC %u SAC %u CID %u SCCP-stream:HNBAP=%u,RUA=%u%s",
+		hnb->id.mcc, hnb->id.mnc, hnb->id.lac, hnb->id.rac, hnb->id.sac, hnb->id.cid,
+		hnb->hnbap_stream, hnb->rua_stream, VTY_NEWLINE);
 
 	llist_for_each_entry(map, &hnb->map_list, hnb_list) {
-		vty_out(vty, " Map %u->%u (RUA->SUA) cnlink=%p state=%u%s", map->rua_ctx_id, map->scu_conn_id,
-			map->cn_link, map->state, VTY_NEWLINE);
-
+		vty_out(vty, "    %s %u->%u (RUA->SUA) state=%u%s",
+			map->is_ps ? "IuPS" : "IuCS",
+			map->rua_ctx_id, map->scu_conn_id,
+			map->state, VTY_NEWLINE);
 	}
 }
 
@@ -132,6 +178,11 @@
 DEFUN(show_hnb, show_hnb_cmd, "show hnb all", SHOW_STR "Display information about a HNB")
 {
 	struct hnb_context *hnb;
+
+	if (llist_empty(&g_hnb_gw->hnb_list)) {
+		vty_out(vty, "No HNB connected%s", VTY_NEWLINE);
+		return CMD_SUCCESS;
+	}
 
 	llist_for_each_entry(hnb, &g_hnb_gw->hnb_list, list) {
 		vty_dump_hnb_info(vty, hnb);
@@ -282,6 +333,7 @@
 
 	install_element(IUPS_NODE, &cfg_hnbgw_iups_remote_addr_cmd);
 
+	install_element_ve(&show_cnlink_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/5532
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3c937306a011715e163a40bc8ef8ec7e8d4e5d08
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