[MERGED] 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
Mon Dec 25 13:45:00 UTC 2017


Neels Hofmeyr has submitted this change and it was merged.

Change subject: vty: tweak / improve HNB and cnlink introspection
......................................................................


vty: tweak / improve HNB and cnlink introspection

Add 'show cnlink' (uses new osmo_sccp_user_name(), see 'Depends' below).

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
        SS7 route: pc=0=0.0.0 mask=0x0=0.0.0 via AS as-clnt-OsmoHNBGW proto=m3ua ASP asp-clnt-OsmoHNBGW (r=127.0.0.1:2905<->l=127.0.0.1:37699)
  IuPS: OsmoHNBGW:RI=SSN_PC,PC=0.23.5,SSN=RANAP <-> RI=SSN_PC,PC=0.23.4,SSN=RANAP
        SS7 route: pc=0=0.0.0 mask=0x0=0.0.0 via AS as-clnt-OsmoHNBGW proto=m3ua ASP asp-clnt-OsmoHNBGW (r=127.0.0.1:2905<->l=127.0.0.1:37699)

  OsmoHNBGW> show hnb all
  No HNB connected

  OsmoHNBGW> show hnb all
  HNB (r=192.168.0.124:29169<->l=192.168.0.9:29169) "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 24->1002 (RUA->SUA) state=1
      IuPS 24->1003 (RUA->SUA) state=1
  HNB (r=192.168.0.15:29169<->l=192.168.0.9:29169) "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 23->1000 (RUA->SUA) state=1
      IuPS 23->1001 (RUA->SUA) state=1
  2 HNB connected

Related: OS#2772 OS#2773
Depends: Ib7abf69cfcf4c56273223054b280458451e6c2f6 (libosmo-sccp)
         Ia0d15a2814b08bc3f052a1ed12dbb68bade55309 (libosmo-sccp)
Change-Id: I3c937306a011715e163a40bc8ef8ec7e8d4e5d08
---
M src/hnbgw_vty.c
1 file changed, 65 insertions(+), 7 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/hnbgw_vty.c b/src/hnbgw_vty.c
index 3d16970..d50c4a5 100644
--- a/src/hnbgw_vty.c
+++ b/src/hnbgw_vty.c
@@ -20,6 +20,7 @@
 
 #include <string.h>
 
+#include <osmocom/core/socket.h>
 #include <osmocom/vty/command.h>
 
 #include <osmocom/iuh/vty.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,68 @@
 	return vty->node;
 }
 
+DEFUN(show_cnlink, show_cnlink_cmd, "show cnlink",
+      SHOW_STR "Display information on core network link\n")
+{
+	struct osmo_ss7_route *rt;
+	struct osmo_ss7_instance *ss7 = osmo_sccp_get_ss7(g_hnb_gw->sccp.client);
+	int i;
+#define GUARD(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",
+		GUARD(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);
+
+	rt = osmo_ss7_route_lookup(ss7, g_hnb_gw->sccp.iucs_remote_addr.pc);
+	vty_out(vty, "      SS7 route: %s%s", osmo_ss7_route_name(rt, true), 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",
+		GUARD(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);
+
+	rt = osmo_ss7_route_lookup(ss7, g_hnb_gw->sccp.iups_remote_addr.pc);
+	vty_out(vty, "      SS7 route: %s%s", osmo_ss7_route_name(rt, true), VTY_NEWLINE);
+
+#undef GUARD
+	return CMD_SUCCESS;
+}
+
+static void vty_out_ofd_addr(struct vty *vty, struct osmo_fd *ofd)
+{
+    char *name;
+    if (!ofd || ofd->fd < 0
+	|| !(name = osmo_sock_get_name(vty, ofd->fd))) {
+	    vty_out(vty, "(no addr)");
+	    return;
+    }
+    vty_out(vty, name);
+    talloc_free(name);
+}
+
 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 +184,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 +339,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: merged
Gerrit-Change-Id: I3c937306a011715e163a40bc8ef8ec7e8d4e5d08
Gerrit-PatchSet: 2
Gerrit-Project: osmo-iuh
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list