aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/osmocom/iuh/context_map.h5
-rw-r--r--src/context_map.c8
-rw-r--r--src/hnbgw_vty.c31
3 files changed, 40 insertions, 4 deletions
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 @@ enum hnbgw_context_map_state {
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 @@ static void vty_out_ofd_addr(struct vty *vty, struct osmo_fd *ofd)
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 @@ static void vty_dump_hnb_info(struct vty *vty, struct hnb_context *hnb)
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 @@ static void vty_dump_ue_info(struct vty *vty, struct ue_context *ue)
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 @@ DEFUN(show_hnb, show_hnb_cmd, "show hnb all", SHOW_STR "Display information abou
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;
}