add a VTY command which shows a specific HNB

Add the 'show hnb NAME' VTY command which displays just
one specific HNB, addressed by its identity string.
This augments the functionality provided by 'show hnb all'.

Change-Id: Iab12aa4ab090b72c472358b84daf6919b30747f6
Related: OS#2774
This commit is contained in:
Stefan Sperling 2018-10-29 18:19:14 +01:00
parent 9aad185151
commit 319c28581e
3 changed files with 37 additions and 1 deletions

View File

@ -151,6 +151,7 @@ struct hnb_gw {
extern void *talloc_asn1_ctx;
struct hnb_context *hnb_context_by_id(struct hnb_gw *gw, uint32_t cid);
struct hnb_context *hnb_context_by_identity_info(struct hnb_gw *gw, const char *identity_info);
unsigned hnb_contexts(const struct hnb_gw *gw);
struct ue_context *ue_context_by_id(struct hnb_gw *gw, uint32_t id);

View File

@ -105,6 +105,19 @@ struct hnb_context *hnb_context_by_id(struct hnb_gw *gw, uint32_t cid)
return NULL;
}
struct hnb_context *hnb_context_by_identity_info(struct hnb_gw *gw, const char *identity_info)
{
struct hnb_context *hnb;
llist_for_each_entry(hnb, &gw->hnb_list, list) {
if (strcmp(identity_info, hnb->identity_info) == 0)
return hnb;
}
return NULL;
}
unsigned hnb_contexts(const struct hnb_gw *gw)
{
unsigned num_ctx = 0;

View File

@ -200,7 +200,7 @@ static void vty_dump_ue_info(struct vty *vty, struct ue_context *ue)
vty_out(vty, "UE IMSI \"%s\" context ID %u%s", ue->imsi, ue->context_id, VTY_NEWLINE);
}
DEFUN(show_hnb, show_hnb_cmd, "show hnb all", SHOW_STR "Display information about a HNB")
DEFUN(show_hnb, show_hnb_cmd, "show hnb all", SHOW_STR "Display information about all HNB")
{
struct hnb_context *hnb;
unsigned int count = 0;
@ -220,6 +220,27 @@ DEFUN(show_hnb, show_hnb_cmd, "show hnb all", SHOW_STR "Display information abou
return CMD_SUCCESS;
}
DEFUN(show_one_hnb, show_one_hnb_cmd, "show hnb NAME ", SHOW_STR "Display information about a HNB")
{
struct hnb_context *hnb;
int found = 0;
const char *identity_info = argv[0];
if (llist_empty(&g_hnb_gw->hnb_list)) {
vty_out(vty, "No HNB connected%s", VTY_NEWLINE);
return CMD_SUCCESS;
}
hnb = hnb_context_by_identity_info(&g_hnb_gw, identity_info);
if (hnb == NULL) {
vty_out(vty, "No HNB found with identity '%s'%s", identity_info, VTY_NEWLINE);
return CMD_SUCCESS;
}
vty_dump_hnb_info(vty, hnb);
return CMD_SUCCESS;
}
DEFUN(show_ue, show_ue_cmd, "show ue all", SHOW_STR "Display information about a UE")
{
struct ue_context *ue;
@ -377,6 +398,7 @@ void hnbgw_vty_init(struct hnb_gw *gw, void *tall_ctx)
install_element_ve(&show_cnlink_cmd);
install_element_ve(&show_hnb_cmd);
install_element_ve(&show_one_hnb_cmd);
install_element_ve(&show_ue_cmd);
install_element_ve(&show_talloc_cmd);
}