diff options
author | Neels Hofmeyr <neels@hofmeyr.de> | 2017-12-25 00:35:05 +0100 |
---|---|---|
committer | Neels Hofmeyr <neels@hofmeyr.de> | 2017-12-25 00:46:12 +0100 |
commit | 9e17e054e4bc48cf608c6fec1d7729a9ce74b872 (patch) | |
tree | 8681d6f7b086b260e8e5a543d8e959b0d42e87f0 | |
parent | 140f38c55ec208f9ed4c8b81e228bf0091cb1731 (diff) |
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@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
-rw-r--r-- | include/osmocom/iuh/context_map.h | 5 | ||||
-rw-r--r-- | src/context_map.c | 8 | ||||
-rw-r--r-- | src/hnbgw_vty.c | 31 |
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; } |