[MERGED] osmo-iuh[master]: osmo-hnbgw: vty: revamp output of context maps on 'show hnb'

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: osmo-hnbgw: vty: revamp output of context maps on 'show hnb'
......................................................................


osmo-hnbgw: vty: revamp output of context maps on 'show hnb'

Instead of listing each and every context map, rather output a summary of
context counts.

Rationale: in a list of a hundred HNBs, I don't want to also see a dozen (or
potentially thousands of) context map lines for each. Furthermore, the conn IDs
aren't necessarily useful on network traces either.

For example, what was shown as SUA Id is incidentally the SCCP Reference, but
this is not a hard requirement and may change. Also, the reference is shown in
wireshark as a hex in mismatching byte order ... so rather don't bother.

The result now looks like

  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: 1 contexts: inactive-reserved:1
      IuPS: 1 contexts: active:1
  1 HNB connected

Related: OS#2772 OS#2773
Change-Id: Iae76b68e85863c8663bb5c508b85534c00e1d2c9
---
M include/osmocom/iuh/context_map.h
M src/context_map.c
M src/hnbgw_vty.c
3 files changed, 40 insertions(+), 4 deletions(-)

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



diff --git a/include/osmocom/iuh/context_map.h b/include/osmocom/iuh/context_map.h
index 8d957d6..6279b91 100644
--- a/include/osmocom/iuh/context_map.h
+++ b/include/osmocom/iuh/context_map.h
@@ -8,8 +8,13 @@
 	MAP_S_ACTIVE,		/* currently active map */
 	MAP_S_RESERVED1,	/* just disconnected, still resrved */
 	MAP_S_RESERVED2,	/* still reserved */
+	MAP_S_NUM_STATES	/* Number of states, keep this at the end */
 };
 
+extern const struct value_string hnbgw_context_map_state_names[];
+static inline const char *hnbgw_context_map_state_name(enum hnbgw_context_map_state val)
+{ return get_value_string(hnbgw_context_map_state_names, val); }
+
 struct hnb_context;
 struct hnbgw_cnlink;
 
diff --git a/src/context_map.c b/src/context_map.c
index b90f555..0c891cf 100644
--- a/src/context_map.c
+++ b/src/context_map.c
@@ -27,6 +27,14 @@
 #include <osmocom/iuh/hnbgw.h>
 #include <osmocom/iuh/context_map.h>
 
+const struct value_string hnbgw_context_map_state_names[] = {
+	{MAP_S_NULL     , "not-initialized"},
+	{MAP_S_ACTIVE   , "active"},
+	{MAP_S_RESERVED1, "inactive-reserved"},
+	{MAP_S_RESERVED2, "inactive-discard"},
+	{0, NULL}
+};
+
 /* is a given SCCP USER SAP Connection ID in use for a given CN link? */
 static int cn_id_in_use(struct hnbgw_cnlink *cn, uint32_t id)
 {
diff --git a/src/hnbgw_vty.c b/src/hnbgw_vty.c
index d50c4a5..4e512e4 100644
--- a/src/hnbgw_vty.c
+++ b/src/hnbgw_vty.c
@@ -157,9 +157,26 @@
     talloc_free(name);
 }
 
+static void vty_dump_hnb_info__map_states(struct vty *vty, const char *name, unsigned int count,
+					  unsigned int state_count[])
+{
+	unsigned int i;
+	if (!count)
+		return;
+	vty_out(vty, "    %s: %u contexts:", name, count);
+	for (i = 0; i <= MAP_S_NUM_STATES; i++) {
+		if (!state_count[i])
+			continue;
+		vty_out(vty, " %s:%u", hnbgw_context_map_state_name(i), state_count[i]);
+	}
+	vty_out(vty, VTY_NEWLINE);
+}
+
 static void vty_dump_hnb_info(struct vty *vty, struct hnb_context *hnb)
 {
 	struct hnbgw_context_map *map;
+	unsigned int map_count[2] = {};
+	unsigned int state_count[2][MAP_S_NUM_STATES + 1] = {};
 
 	vty_out(vty, "HNB ");
 	vty_out_ofd_addr(vty, hnb->conn? osmo_stream_srv_get_ofd(hnb->conn) : NULL);
@@ -169,11 +186,13 @@
 		hnb->hnbap_stream, hnb->rua_stream, VTY_NEWLINE);
 
 	llist_for_each_entry(map, &hnb->map_list, hnb_list) {
-		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);
+		map_count[map->is_ps? 1 : 0]++;
+		state_count[map->is_ps? 1 : 0]
+			   [(map->state >= 0 && map->state < MAP_S_NUM_STATES)?
+			    map->state : MAP_S_NUM_STATES]++;
 	}
+	vty_dump_hnb_info__map_states(vty, "IuCS", map_count[0], state_count[0]);
+	vty_dump_hnb_info__map_states(vty, "IuPS", map_count[1], state_count[1]);
 }
 
 static void vty_dump_ue_info(struct vty *vty, struct ue_context *ue)
@@ -184,6 +203,7 @@
 DEFUN(show_hnb, show_hnb_cmd, "show hnb all", SHOW_STR "Display information about a HNB")
 {
 	struct hnb_context *hnb;
+	unsigned int count = 0;
 
 	if (llist_empty(&g_hnb_gw->hnb_list)) {
 		vty_out(vty, "No HNB connected%s", VTY_NEWLINE);
@@ -192,8 +212,11 @@
 
 	llist_for_each_entry(hnb, &g_hnb_gw->hnb_list, list) {
 		vty_dump_hnb_info(vty, hnb);
+		count++;
 	}
 
+	vty_out(vty, "%u HNB connected%s", count, VTY_NEWLINE);
+
 	return CMD_SUCCESS;
 }
 

-- 
To view, visit https://gerrit.osmocom.org/5573
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Iae76b68e85863c8663bb5c508b85534c00e1d2c9
Gerrit-PatchSet: 1
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