From: Ondrej Zajicek Date: Thu, 22 Mar 2012 10:46:38 +0000 (+0100) Subject: Some minor changes to CLI. X-Git-Tag: v1.3.7~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c47d037ecb5b9c835700b152eed7589409a2e42f;p=thirdparty%2Fbird.git Some minor changes to CLI. --- diff --git a/client/commands.c b/client/commands.c index 7612b64cf..08e7949a1 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 7b163c7bb..90265b80a 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 show xroa [] + show roa [] Show contents of a ROA table (by default of the first one). You can specify a for , you'll diff --git a/doc/reply_codes b/doc/reply_codes index a0db2cad5..7ec2e27dd 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 24ef58d07..f889828af 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, [[[|for |for ] [table ] [filter |where ] [all] [primary] [(export|preexport)

] [protocol

] [stats|count]]], [[Show routing table]]) { rt_show($3); } ; @@ -456,7 +457,8 @@ export_or_preexport: ; -CF_CLI(SHOW XROA, roa_args, [ | in | for ] [as ] [table ], [[Show ROA table]]) +CF_CLI_HELP(SHOW ROA, ..., [[Show ROA table]]) +CF_CLI(SHOW ROA, roa_args, [ | in | for ] [as ] [table ], [[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|], [[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, max as [table ], [[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, max as [table ], [[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 ], [[Removes all dynamic ROA records]]) CF_CLI(FLUSH ROA, roa_table_arg, [table ], [[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 f94842c43..aa453f16f 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 75c132da0..38e598865 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, [], [[Show information about OSPF protocol]]) +CF_CLI_HELP(SHOW OSPF, ..., [[Show information about OSPF protocol]]); +CF_CLI(SHOW OSPF, optsym, [], [[Show information about OSPF protocol XXX]]) { ospf_sh(proto_get_named($3, &proto_ospf)); }; CF_CLI(SHOW OSPF NEIGHBORS, optsym opttext, [] [\"\"], [[Show information about OSPF neighbors]]) @@ -413,6 +414,7 @@ CF_CLI(SHOW OSPF STATE, optsym opttext, [], [[Show information about reach CF_CLI(SHOW OSPF STATE ALL, optsym opttext, [], [[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 | link] [type ] [lsid ] [self | router ] [], [[Show content of OSPF LSA database]]) { ospf_sh_lsadb($4); };