Vadim Yanitskiy has uploaded this change for review. ( 
https://gerrit.osmocom.org/14009


Change subject: osmo-ggsn: fix VTY command for getting PDP contexts by APN
......................................................................

osmo-ggsn: fix VTY command for getting PDP contexts by APN

Change-Id: I0a7f4b245c4664afdae83c660358acb1a5f88ce5
---
M ggsn/ggsn_vty.c
1 file changed, 38 insertions(+), 12 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ggsn refs/changes/09/14009/1

diff --git a/ggsn/ggsn_vty.c b/ggsn/ggsn_vty.c
index 53f4ebf..7a3bf07 100644
--- a/ggsn/ggsn_vty.c
+++ b/ggsn/ggsn_vty.c
@@ -805,9 +805,9 @@
 }

 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 @@
                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 has been interpreting
+ * "[apn APN]" as two separate elements: "[apn" and "APN]",
+ * but the first part  */
+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 @@
 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);


--
To view, visit https://gerrit.osmocom.org/14009
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ggsn
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0a7f4b245c4664afdae83c660358acb1a5f88ce5
Gerrit-Change-Number: 14009
Gerrit-PatchSet: 1
Gerrit-Owner: Vadim Yanitskiy <[email protected]>

Reply via email to