]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Adds filtering to 'show symbols' command.
authorOndrej Zajicek <santiago@crfreenet.org>
Fri, 16 Mar 2012 11:47:12 +0000 (12:47 +0100)
committerOndrej Zajicek <santiago@crfreenet.org>
Fri, 16 Mar 2012 11:47:12 +0000 (12:47 +0100)
Thanks Alexander V. Chernikov for the original patch.

conf/confbase.Y
doc/bird.sgml
nest/cmds.c
nest/cmds.h
nest/config.Y

index b952f314a89d920e1501d7d34580545144c10d31..b9bc048e4646fd6c2763f3a849d427aa1caceaa6 100644 (file)
@@ -50,6 +50,7 @@ CF_DECLS
   struct f_path_mask *h;
   struct password_item *p;
   struct rt_show_data *ra;
+  struct sym_show_data *sd;
   struct lsadb_show_data *ld;
   struct iface *iface;
   void *g;
index f5cfdfb124075725d1ea9e2c0c6be089ad063002..aabb98576c4e6b1dc3ab592e2a1a4fb4fdad6265 100644 (file)
@@ -570,7 +570,7 @@ This argument can be omitted if there exists only a single instance.
        <tag>show interfaces [summary]</tag>
        Show the list of interfaces. For each interface, print its type, state, MTU and addresses assigned. 
 
-       <tag>show symbols</tag>
+       <tag>show symbols [table|filter|function|protocol|template|<symbol>]</tag>
        Show the list of symbols defined in the configuration (names of protocols, routing tables etc.).
 
        <tag>show route [[for] <m/prefix/|<m/IP/] [table <m/sym/] [filter <m/f/|where <m/c/] [(export|preexport) <m/p/] [protocol <m/p/] [<m/options/]</tag>
index 8ac32096d78be81cb27830ce570fbd29974bb836..62d7c9b483a4b10e731a9e5d9dcde4ae1a0f4900 100644 (file)
@@ -7,6 +7,7 @@
  */
 
 #include "nest/bird.h"
+#include "nest/route.h"
 #include "nest/cli.h"
 #include "conf/conf.h"
 #include "nest/cmds.h"
@@ -35,16 +36,22 @@ cmd_show_status(void)
 }
 
 void
-cmd_show_symbols(struct symbol *sym)
+cmd_show_symbols(struct sym_show_data *sd)
 {
   int pos = 0;
+  struct symbol *sym = sd->sym;
 
   if (sym)
-    cli_msg(1010, "%s\t%s", sym->name, cf_symbol_class_name(sym));
+    cli_msg(1010, "%-8s\t%s", sym->name, cf_symbol_class_name(sym));
   else
     {
       while (sym = cf_walk_symbols(config, sym, &pos))
-       cli_msg(-1010, "%s\t%s", sym->name, cf_symbol_class_name(sym));
+       {
+         if (sd->type && (sym->class != sd->type))
+           continue;
+
+         cli_msg(-1010, "%-8s\t%s", sym->name, cf_symbol_class_name(sym));
+       }
       cli_msg(0, "");
     }
 }
index 3b86a92424c9d511122a814b2b55bcefc310e22b..8b0bff7e80721552e5b672269d4a27d443f6231b 100644 (file)
@@ -6,6 +6,11 @@
  *     Can be freely distributed and used under the terms of the GNU GPL.
  */
 
+struct sym_show_data {
+       int     type;   /* Symbols type to show */
+       struct symbol   *sym;
+};
+
 void cmd_show_status(void);
-void cmd_show_symbols(struct symbol *sym);
+void cmd_show_symbols(struct sym_show_data *sym);
 void cmd_show_memory(void);
index 3fcfa52815d8202a31a23fb8d1ab8c88750972e7..f6795df4f023d8d8c03455dfc4cc7b9359d1a515 100644 (file)
@@ -59,6 +59,7 @@ CF_ENUM(T_ENUM_RTD, RTD_, ROUTER, DEVICE, BLACKHOLE, UNREACHABLE, PROHIBIT, MULT
 %type <r> rtable
 %type <s> optsym
 %type <ra> r_args
+%type <sd> sym_args
 %type <i> proto_start echo_mask echo_size debug_mask debug_list debug_flag mrtdump_mask mrtdump_list mrtdump_flag export_or_preexport
 %type <ps> proto_patt proto_patt2
 
@@ -432,9 +433,21 @@ export_or_preexport:
  | EXPORT { $$ = 2; }
  ;
 
-CF_CLI(SHOW SYMBOLS, optsym, [<symbol>], [[Show all known symbolic names]])
+CF_CLI(SHOW SYMBOLS, sym_args, [table|filter|function|protocol|template|<symbol>], [[Show all known symbolic names]])
 { cmd_show_symbols($3); } ;
 
+sym_args:
+   /* empty */ {
+     $$ = cfg_allocz(sizeof(struct sym_show_data));
+   }
+ | sym_args TABLE { $$ = $1; $$->type = SYM_TABLE; }
+ | sym_args FUNCTION { $$ = $1; $$->type = SYM_FUNCTION; }
+ | sym_args FILTER { $$ = $1; $$->type = SYM_FILTER; }
+ | sym_args PROTOCOL { $$ = $1; $$->type = SYM_PROTO; }
+ | sym_args TEMPLATE { $$ = $1; $$->type = SYM_TEMPLATE; }
+ | sym_args SYM { $$ = $1; $$->sym = $2; }
+ ;
+
 CF_CLI_HELP(DUMP, ..., [[Dump debugging information]])
 CF_CLI(DUMP RESOURCES,,, [[Dump all allocated resource]])
 { rdump(&root_pool); cli_msg(0, ""); } ;