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@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@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
This commit is contained in:
Neels Hofmeyr 2017-12-20 23:48:02 +01:00
parent 6eeef115a9
commit 140f38c55e
1 changed files with 65 additions and 7 deletions

View File

@ -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 @@ int hnbgw_vty_go_parent(struct vty *vty)
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);
}
}
@ -133,6 +185,11 @@ DEFUN(show_hnb, show_hnb_cmd, "show hnb all", SHOW_STR "Display information abou
{
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 @@ void hnbgw_vty_init(struct hnb_gw *gw, void *tall_ctx)
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);