diff options
author | Ondrej Zajicek <santiago@crfreenet.org> | 2012-03-22 11:46:38 +0100 |
---|---|---|
committer | Ondrej Zajicek <santiago@crfreenet.org> | 2012-03-22 12:13:26 +0100 |
commit | c47d037ecb5b9c835700b152eed7589409a2e42f (patch) | |
tree | 5b68978bc6af43b93d2772dece1b66a9996e4fcf | |
parent | df27911880bffb88c1eae90e36c755a3ed3d77ad (diff) |
Some minor changes to CLI.
-rw-r--r-- | client/commands.c | 21 | ||||
-rw-r--r-- | doc/bird.sgml | 2 | ||||
-rw-r--r-- | doc/reply_codes | 1 | ||||
-rw-r--r-- | nest/config.Y | 25 | ||||
-rw-r--r-- | nest/rt-roa.c | 2 | ||||
-rw-r--r-- | proto/ospf/config.Y | 4 |
6 files changed, 45 insertions, 10 deletions
diff --git a/client/commands.c b/client/commands.c index 7612b64c..08e7949a 100644 --- a/client/commands.c +++ b/client/commands.c @@ -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 { diff --git a/doc/bird.sgml b/doc/bird.sgml index 7b163c7b..90265b80 100644 --- a/doc/bird.sgml +++ b/doc/bird.sgml @@ -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 diff --git a/doc/reply_codes b/doc/reply_codes index a0db2cad..7ec2e27d 100644 --- a/doc/reply_codes +++ b/doc/reply_codes @@ -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 diff --git a/nest/config.Y b/nest/config.Y index 24ef58d0..f889828a 100644 --- a/nest/config.Y +++ b/nest/config.Y @@ -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]]) diff --git a/nest/rt-roa.c b/nest/rt-roa.c index f94842c4..aa453f16 100644 --- a/nest/rt-roa.c +++ b/nest/rt-roa.c @@ -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 diff --git a/proto/ospf/config.Y b/proto/ospf/config.Y index 75c132da..38e59886 100644 --- a/proto/ospf/config.Y +++ b/proto/ospf/config.Y @@ -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); }; |