diff options
author | Vadim Yanitskiy <axilirator@gmail.com> | 2019-05-13 15:32:21 +0700 |
---|---|---|
committer | Vadim Yanitskiy <axilirator@gmail.com> | 2019-05-13 15:36:58 +0700 |
commit | 977b339abe53e68f5acddbf716f58c16c356825c (patch) | |
tree | 5099ae25afda7e0adc827a97f1c28cf8e7049887 /ggsn | |
parent | 9272d212c3f959b4829134ef5827f7652c6af30c (diff) |
osmo-ggsn: fix VTY command for getting PDP contexts by APN
Change-Id: I0a7f4b245c4664afdae83c660358acb1a5f88ce5
Diffstat (limited to 'ggsn')
-rw-r--r-- | ggsn/ggsn_vty.c | 48 |
1 files changed, 37 insertions, 11 deletions
diff --git a/ggsn/ggsn_vty.c b/ggsn/ggsn_vty.c index 53f4ebf..f55bd9b 100644 --- a/ggsn/ggsn_vty.c +++ b/ggsn/ggsn_vty.c @@ -805,9 +805,9 @@ static void apn_show_pdp_contexts(struct vty *vty, struct apn_ctx *apn) } DEFUN(show_pdpctx, show_pdpctx_cmd, - "show pdp-context ggsn NAME [apn APN]", + "show pdp-context ggsn NAME", SHOW_STR "Show PDP Context Information\n" - GGSN_STR "GGSN Name\n") // FIXME + GGSN_STR "GGSN Name\n") { struct ggsn_ctx *ggsn; struct apn_ctx *apn; @@ -817,21 +817,45 @@ DEFUN(show_pdpctx, show_pdpctx_cmd, vty_out(vty, "%% No such GGSN '%s'%s", argv[0], VTY_NEWLINE); return CMD_WARNING; } - if (argc < 2) { - llist_for_each_entry(apn, &ggsn->apn_list, list) - apn_show_pdp_contexts(vty, apn); - } else { - apn = ggsn_find_apn(ggsn, argv[1]); - if (!apn) { - vty_out(vty, "%% No such APN '%s'%s", argv[1], VTY_NEWLINE); - return CMD_WARNING; - } + + llist_for_each_entry(apn, &ggsn->apn_list, list) apn_show_pdp_contexts(vty, apn); + + return CMD_SUCCESS; +} + +DEFUN(show_pdpctx_apn, show_pdpctx_apn_cmd, + "show pdp-context ggsn NAME apn APN", + SHOW_STR "Show PDP Context Information\n" + GGSN_STR "GGSN Name\n" "Filter by APN\n" "APN name\n") +{ + struct ggsn_ctx *ggsn; + struct apn_ctx *apn; + + ggsn = ggsn_find(argv[0]); + if (!ggsn) { + vty_out(vty, "%% No such GGSN '%s'%s", argv[0], VTY_NEWLINE); + return CMD_WARNING; + } + + apn = ggsn_find_apn(ggsn, argv[1]); + if (!apn) { + vty_out(vty, "%% No such APN '%s'%s", argv[1], VTY_NEWLINE); + return CMD_WARNING; } + apn_show_pdp_contexts(vty, apn); return CMD_SUCCESS; } +/* Backwards compatibility: the VTY parser is (mis)interpreting + * "[apn APN]" as two separate elements: "[apn" and "APN]", + * but the first part somehow turns into command "ap". */ +ALIAS_DEPRECATED(show_pdpctx_apn, show_deprecated_pdpctx_apn_cmd, + "show pdp-context ggsn NAME ap APN", + SHOW_STR "Show PDP Context Information\n" + GGSN_STR "GGSN Name\n" "Filter by APN\n" "APN name\n"); + static void show_apn(struct vty *vty, struct apn_ctx *apn) { vty_out(vty, " APN: %s%s", apn->cfg.name, VTY_NEWLINE); @@ -871,6 +895,8 @@ DEFUN(show_ggsn, show_ggsn_cmd, int ggsn_vty_init(void) { install_element_ve(&show_pdpctx_cmd); + install_element_ve(&show_pdpctx_apn_cmd); + install_element_ve(&show_deprecated_pdpctx_apn_cmd); install_element_ve(&show_pdpctx_imsi_cmd); install_element_ve(&show_ggsn_cmd); |