Add community/large-community commands and retain parameter input in form
authorjob <job@openbsd.org>
Sun, 17 Dec 2017 18:41:17 +0000 (18:41 +0000)
committerjob <job@openbsd.org>
Sun, 17 Dec 2017 18:41:17 +0000 (18:41 +0000)
OK deraadt@

usr.bin/bgplg/bgplg.c
usr.bin/bgplg/bgplg.h

index fa1fb36..3654e41 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: bgplg.c,v 1.16 2016/04/05 21:57:58 sthen Exp $        */
+/*     $OpenBSD: bgplg.c,v 1.17 2017/12/17 18:41:17 job Exp $  */
 
 /*
  * Copyright (c) 2005, 2006 Reyk Floeter <reyk@openbsd.org>
@@ -304,12 +304,18 @@ main(void)
                        printf("<option value='%s'>%s</option>\n",
                            cmds[i].name, cmds[i].name);
        }
+
+       if ((req = lg_getarg("req=", query, query_length)) != NULL) {
+               /* Could be NULL */
+               argv = lg_arg2argv(req, &argc);
+       }
+
        printf("</select>\n"
-           "<input type='text' name='req'/>\n"
+           "<input type='text' value='%s' name='req'/>\n"
            "<input type='submit' value='submit'/>\n"
            "</div>\n"
            "</form>\n"
-           "<pre>\n");
+           "<pre>\n", req ? req : "");
        fflush(stdout);
 
 #ifdef DEBUG
@@ -328,10 +334,6 @@ main(void)
                printf("unspecified command\n");
                goto err;
        }
-       if ((req = lg_getarg("req=", query, query_length)) != NULL) {
-               /* Could be NULL */
-               argv = lg_arg2argv(req, &argc);
-       }
 
        for (i = 0; cmds[i].name != NULL; i++) {
                if (strcmp(cmd, cmds[i].name) == 0) {
index a33d32a..4be65ca 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: bgplg.h,v 1.11 2017/08/09 19:15:18 phessler Exp $     */
+/*     $OpenBSD: bgplg.h,v 1.12 2017/12/17 18:41:17 job Exp $  */
 
 /*
  * Copyright (c) 2005, 2006 Reyk Floeter <reyk@openbsd.org>
@@ -49,6 +49,14 @@ struct cmd {
            { BGPCTL, "show", "ip", "bgp", "empty-as", NULL } },        \
        { "show ip bgp summary", 0, 0, NULL,                            \
            { BGPCTL, "show", "ip", "bgp", "summary", NULL } },         \
+       { "show ip bgp community", 1, 1, "&lt;community&gt;",           \
+           { BGPCTL, "show","ip", "bgp", "community", NULL } },        \
+       { "show ip bgp detail community", 1, 1, "&lt;community&gt;",    \
+           { BGPCTL, "show","ip", "bgp", "detail", "community", NULL } },\
+       { "show ip bgp large-community", 1, 1, "&lt;large-community&gt;",\
+           { BGPCTL, "show","ip", "bgp", "large-community", NULL } },  \
+       { "show ip bgp detail large-community", 1, 1, "&lt;large-community&gt;",\
+           { BGPCTL, "show","ip", "bgp", "detail", "large-community", NULL } },\
        { "show ip bgp detail", 1, 1, "&lt;prefix&gt;",                 \
            { BGPCTL, "show","ip", "bgp", "detail", NULL } },           \
        { "show ip bgp detail as", 1, 1, "&lt;prefix&gt;",              \