]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Some minor changes to CLI.
authorOndrej Zajicek <santiago@crfreenet.org>
Thu, 22 Mar 2012 10:46:38 +0000 (11:46 +0100)
committerOndrej Zajicek <santiago@crfreenet.org>
Thu, 22 Mar 2012 11:13:26 +0000 (12:13 +0100)
client/commands.c
doc/bird.sgml
doc/reply_codes
nest/config.Y
nest/rt-roa.c
proto/ospf/config.Y

index 7612b64cffbdf63071905438cd90fbe185d749ab..08e7949a15e406fbc1b4cb31d14a91a6521f5b87 100644 (file)
@@ -29,6 +29,7 @@ struct cmd_node {
   struct cmd_node *sibling, *son, **plastson;
   struct cmd_info *cmd, *help;
   int len;
+  signed char prio;
   char token[1];
 };
 
@@ -66,6 +67,7 @@ cmd_build_tree(void)
              new->plastson = &new->son;
              new->len = c-d;
              memcpy(new->token, d, c-d);
+             new->prio = (new->len == 3 && !memcmp(new->token, "roa", 3)) ? 0 : 1; /* Hack */
            }
          old = new;
          while (isspace(*c))
@@ -108,7 +110,10 @@ cmd_find_abbrev(struct cmd_node *root, char *cmd, int len, int *pambiguous)
        return m;
       if (m->len > len && !memcmp(m->token, cmd, len))
        {
-         best2 = best;
+         if (best && best->prio > m->prio)
+           continue;
+         if (best && best->prio == m->prio)
+           best2 = best;
          best = m;
        }
     }
@@ -168,19 +173,31 @@ static int
 cmd_find_common_match(struct cmd_node *root, char *cmd, int len, int *pcount, char *buf)
 {
   struct cmd_node *m;
-  int best, i;
+  int best, best_prio, i;
 
   *pcount = 0;
   best = -1;
+  best_prio = -1;
   for(m=root->son; m; m=m->sibling)
     {
       if (m->len < len || memcmp(m->token, cmd, len))
        continue;
+
+      if (best_prio > m->prio)
+       continue;
+
+      if (best_prio < m->prio)
+       {
+         *pcount = 0;
+         best = -1;
+       }
+
       (*pcount)++;
       if (best < 0)
        {
          strcpy(buf, m->token + len);
          best = m->len - len;
+         best_prio = m->prio;
        }
       else
        {
index 7b163c7bb76935a0e5d42fcbcc879fef61909954..90265b80a7c71ce88bcb023293efa613d05d0d2a 100644 (file)
@@ -615,7 +615,7 @@ This argument can be omitted if there exists only a single instance.
        number of networks, number of routes before and after filtering). If
        you use <cf/count/ instead, only the statistics will be printed.
 
-       <tag>show xroa [<m/prefix/ | in <m/prefix/ | for <m/prefix/] [as <m/num/] [table <m/t/>]</tag>
+       <tag>show roa [<m/prefix/ | in <m/prefix/ | for <m/prefix/] [as <m/num/] [table <m/t/>]</tag>
        Show contents of a ROA table (by default of the first one).
        You can specify a <m/prefix/ to print ROA entries for a
        specific network. If you use <cf>for <m/prefix/</cf>, you'll
index a0db2cad59202f87638edaa79a4b2b6a0ac86ec6..7ec2e27dd1cac0d4e15a7b02e0d65d99819fb6a0 100644 (file)
@@ -45,6 +45,7 @@ Reply codes of BIRD command-line interface
 1016   Show ospf state/topology
 1017   Show ospf lsadb
 1018   Show memory
+1019   Show ROA list
 
 8000   Reply too long
 8001   Route not found
index 24ef58d076356c982b27ac2147a4adf64abd8474..f889828afc640dd97fc210bdffb629d79a41f959 100644 (file)
@@ -45,7 +45,7 @@ CF_DECLS
 CF_KEYWORDS(ROUTER, ID, PROTOCOL, TEMPLATE, PREFERENCE, DISABLED, DEBUG, ALL, OFF, DIRECT)
 CF_KEYWORDS(INTERFACE, IMPORT, EXPORT, FILTER, NONE, TABLE, STATES, ROUTES, FILTERS)
 CF_KEYWORDS(PASSWORD, FROM, PASSIVE, TO, ID, EVENTS, PACKETS, PROTOCOLS, INTERFACES)
-CF_KEYWORDS(PRIMARY, STATS, COUNT, FOR, COMMANDS, PREEXPORT, GENERATE, ROA, XROA, MAX, FLUSH)
+CF_KEYWORDS(PRIMARY, STATS, COUNT, FOR, COMMANDS, PREEXPORT, GENERATE, ROA, MAX, FLUSH)
 CF_KEYWORDS(LISTEN, BGP, V6ONLY, DUAL, ADDRESS, PORT, PASSWORDS, DESCRIPTION)
 CF_KEYWORDS(RELOAD, IN, OUT, MRTDUMP, MESSAGES, RESTRICT, MEMORY, IGP_METRIC)
 
@@ -376,6 +376,7 @@ CF_CLI(SHOW INTERFACES,,, [[Show network interfaces]])
 CF_CLI(SHOW INTERFACES SUMMARY,,, [[Show summary of network interfaces]])
 { if_show_summary(); } ;
 
+CF_CLI_HELP(SHOW ROUTE, ..., [[Show routing table]])
 CF_CLI(SHOW ROUTE, r_args, [[[<prefix>|for <prefix>|for <ip>] [table <t>] [filter <f>|where <cond>] [all] [primary] [(export|preexport) <p>] [protocol <p>] [stats|count]]], [[Show routing table]])
 { rt_show($3); } ;
 
@@ -456,7 +457,8 @@ export_or_preexport:
  ;
 
 
-CF_CLI(SHOW XROA, roa_args, [<prefix> | in <prefix> | for <prefix>] [as <num>] [table <t>], [[Show ROA table]])
+CF_CLI_HELP(SHOW ROA, ..., [[Show ROA table]])
+CF_CLI(SHOW ROA, roa_args, [<prefix> | in <prefix> | for <prefix>] [as <num>] [table <t>], [[Show ROA table]])
 { roa_show($3); } ;
 
 roa_args:
@@ -492,6 +494,7 @@ roa_mode:
  ;
 
 
+CF_CLI_HELP(SHOW SYMBOLS, ..., [[Show all known symbolic names]])
 CF_CLI(SHOW SYMBOLS, sym_args, [table|filter|function|protocol|template|roa|<symbol>], [[Show all known symbolic names]])
 { cmd_show_symbols($3); } ;
 
@@ -522,14 +525,26 @@ roa_table_arg:
    }
  ;
 
+CF_CLI_HELP(ADD, roa ..., [[Add ROA record]])
 CF_CLI(ADD ROA, prefix MAX NUM AS NUM roa_table_arg, <prefix> max <num> as <num> [table <name>], [[Add ROA record]])
-{ roa_add_item($8, $3.addr, $3.len, $5, $7, ROA_SRC_DYNAMIC); cli_msg(0, ""); } ;
+{
+  if (! cli_access_restricted())
+    { roa_add_item($8, $3.addr, $3.len, $5, $7, ROA_SRC_DYNAMIC); cli_msg(0, ""); }
+};
 
+CF_CLI_HELP(DELETE, roa ..., [[Delete ROA record]])
 CF_CLI(DELETE ROA, prefix MAX NUM AS NUM roa_table_arg, <prefix> max <num> as <num> [table <name>], [[Delete ROA record]])
-{ roa_delete_item($8, $3.addr, $3.len, $5, $7, ROA_SRC_DYNAMIC); cli_msg(0, ""); } ;
+{
+  if (! cli_access_restricted())
+    { roa_delete_item($8, $3.addr, $3.len, $5, $7, ROA_SRC_DYNAMIC); cli_msg(0, ""); }
+};
 
+CF_CLI_HELP(FLUSH, roa [table <name>], [[Removes all dynamic ROA records]])
 CF_CLI(FLUSH ROA, roa_table_arg, [table <name>], [[Removes all dynamic ROA records]])
-{ roa_flush($3, ROA_SRC_DYNAMIC); cli_msg(0, ""); } ;
+{
+  if (! cli_access_restricted())
+    { roa_flush($3, ROA_SRC_DYNAMIC); cli_msg(0, ""); }
+};
 
 
 CF_CLI_HELP(DUMP, ..., [[Dump debugging information]])
index f94842c4315fc225d07d6ad7652ed3300a6a7bc6..aa453f16f57f381922629b57e5763bb9d291d8b2 100644 (file)
@@ -354,7 +354,7 @@ roa_show_node(struct cli *c, struct roa_node *rn, int len, u32 asn)
 
   for (ri = rn->items; ri; ri = ri->next)
     if ((ri->maxlen >= len) && (!asn || (ri->asn == asn)))
-      cli_printf(c, -1111, "%I/%d max %d as %u", rn->n.prefix, rn->n.pxlen, ri->maxlen, ri->asn);
+      cli_printf(c, -1019, "%I/%d max %d as %u", rn->n.prefix, rn->n.pxlen, ri->maxlen, ri->asn);
 }
 
 static void
index 75c132da0f874bb53d3d616e5c300c2387d1307d..38e59886529eff9df21dbf4218ff89abe703f367 100644 (file)
@@ -388,7 +388,8 @@ CF_ADDTO(dynamic_attr, OSPF_METRIC2 { $$ = f_new_dynamic_attr(EAF_TYPE_INT | EAF
 CF_ADDTO(dynamic_attr, OSPF_TAG { $$ = f_new_dynamic_attr(EAF_TYPE_INT | EAF_TEMP, T_INT, EA_OSPF_TAG); })
 CF_ADDTO(dynamic_attr, OSPF_ROUTER_ID { $$ = f_new_dynamic_attr(EAF_TYPE_ROUTER_ID | EAF_TEMP, T_QUAD, EA_OSPF_ROUTER_ID); })
 
-CF_CLI(SHOW OSPF, optsym, [<name>], [[Show information about OSPF protocol]])
+CF_CLI_HELP(SHOW OSPF, ..., [[Show information about OSPF protocol]]);
+CF_CLI(SHOW OSPF, optsym, [<name>], [[Show information about OSPF protocol XXX]])
 { ospf_sh(proto_get_named($3, &proto_ospf)); };
 
 CF_CLI(SHOW OSPF NEIGHBORS, optsym opttext, [<name>] [\"<interface>\"], [[Show information about OSPF neighbors]])
@@ -413,6 +414,7 @@ CF_CLI(SHOW OSPF STATE, optsym opttext, [<name>], [[Show information about reach
 CF_CLI(SHOW OSPF STATE ALL, optsym opttext, [<name>], [[Show information about all OSPF network state]])
 { ospf_sh_state(proto_get_named($5, &proto_ospf), 1, 0); };
 
+CF_CLI_HELP(SHOW OSPF LSADB, ..., [[Show content of OSPF LSA database]]);
 CF_CLI(SHOW OSPF LSADB, lsadb_args, [global | area <id> | link] [type <num>] [lsid <id>] [self | router <id>] [<proto>], [[Show content of OSPF LSA database]])
 { ospf_sh_lsadb($4); };