]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Split off general commands to cmds.c.
authorMartin Mares <mj@ucw.cz>
Wed, 19 Jan 2000 12:30:19 +0000 (12:30 +0000)
committerMartin Mares <mj@ucw.cz>
Wed, 19 Jan 2000 12:30:19 +0000 (12:30 +0000)
Added `show symbols' command which dumps whole symbol table together
with symbol types etc.

TODO
conf/cf-lex.l
conf/conf.h
doc/reply_codes
nest/Makefile
nest/cli.h
nest/cmds.c [new file with mode: 0644]
nest/cmds.h [new file with mode: 0644]
nest/config.Y

diff --git a/TODO b/TODO
index 2b752ac337ee7f93a4805060a1764c75d4b5e62d..b9ba13fdc0957ae4cd32864576adc97d8b57e69b 100644 (file)
--- a/TODO
+++ b/TODO
@@ -21,13 +21,10 @@ Core
 
 - netlink: import Linux route attributes to our rta's, so that they can be filtered?
 
-- socket: Use IP_RECVERR for BGP TCP sockets?
-
 - config: executable config files
 - config: when parsing prefix, check zero bits
 - config: useless rules when protocols disabled
 - config: better datetime format
-- config: long disable/enable/restart sequences hang
 
 - krt: rescan interfaces when route addition fails?
 
@@ -37,11 +34,6 @@ Core
 
 Commands
 ~~~~~~~~
-show   <name>                  # show everything you know about symbol <name>
-       rip ??? [<name>]
-       ospf ??? [<name>]
-       static ??? [<name>]
-       symbols
 - showing of routing table as seen by given protocol
 
 Roadmap
@@ -51,7 +43,6 @@ Roadmap
 - Remaining bits of IPv6 support (radvd)
 - RIPv6
 - BGP?
-- Logging and debugging messages
 
 Client
 ~~~~~~
@@ -62,7 +53,7 @@ Documentation
 - write doctool
 - write documentation :|
 
-Cleanup
+Globals
 ~~~~~~~
 - right usage of DBG vs. debug
 - cleanup debugging calls
@@ -73,8 +64,8 @@ Cleanup
 - replace all NUM, IPA and expr tokens by constant filter expressions
 - try compiling with -Wunused
 - does everybody test return value of sk_open?
-- add references to RFC's we did follow
-- protocols: implement CLI hooks
+- doc: references to RFC's we did follow
+- protocols: implement CLI hooks and per-procotol CLI commands
 - protocols: implement reconfigure hook
 - protocols: use locking
 
@@ -122,3 +113,4 @@ BGP
        - hold time
        - idle timer after error: initial value, exponential growth, maximum value
        - import of IGP routes (use external route tags from OSPF)
+       - Use IP_RECVERR for BGP TCP sockets?
index df0f3c1d13a1384369f6c934236a6e23de21fb44..a54cdd9986ba15206ad40e4b63cca3220d156d04 100644 (file)
@@ -308,3 +308,43 @@ cf_pop_scope(void)
   conf_this_scope = conf_this_scope->next;
   ASSERT(conf_this_scope);
 }
+
+struct symbol *
+cf_walk_symbols(struct config *cf, struct symbol *sym, int *pos)
+{
+  for(;;)
+    {
+      if (!sym)
+       {
+         if (*pos >= SYM_HASH_SIZE)
+           return NULL;
+         sym = cf->sym_hash[(*pos)++];
+       }
+      else
+       sym = sym->next;
+      if (sym && sym->scope->active)
+       return sym;
+    }
+}
+
+char *
+cf_symbol_class_name(struct symbol *sym)
+{
+  switch (sym->class)
+    {
+    case SYM_VOID:
+      return "undefined";
+    case SYM_PROTO:
+      return "protocol";
+    case SYM_NUMBER:
+      return "numeric constant";
+    case SYM_FUNCTION:
+      return "function";
+    case SYM_FILTER:
+      return "filter";
+    case SYM_TABLE:
+      return "routing table";
+    default:
+      return "unknown type";
+    }
+}
index 178cdb6e06b7070d7f64d15bd35f29940d815610..5b80b0dd14a9de13b92863c564b0cdc8fdfac1ea 100644 (file)
@@ -94,6 +94,8 @@ struct symbol *cf_default_name(char *template, int *counter);
 void cf_define_symbol(struct symbol *symbol, int type, void *def);
 void cf_push_scope(struct symbol *);
 void cf_pop_scope(void);
+struct symbol *cf_walk_symbols(struct config *cf, struct symbol *sym, int *pos);
+char *cf_symbol_class_name(struct symbol *sym);
 
 /* Parser */
 
index b6a1c045f5064ec05a636c3eb6a0f9e7d8a2883a..711c6342ad0587d27b04e8d27aca096d487bdb79 100644 (file)
@@ -32,6 +32,7 @@ Reply codes of BIRD command-line interface
 1007   Route list
 1008   Route details
 1009   Static route list
+1010   Symbol list
 
 8000   Reply too long
 8001   Route not found
index 69bc06c3bcfadb91812ff24c510add2190385352..b9cb69b08b8cf76e8adf5d37e160335bb5d7498b 100644 (file)
@@ -1,4 +1,4 @@
-source=rt-table.c rt-fib.c rt-attr.c proto.c iface.c rt-dev.c password.c cli.c locks.c
+source=rt-table.c rt-fib.c rt-attr.c proto.c iface.c rt-dev.c password.c cli.c locks.c cmds.c
 root-rel=../
 dir-name=nest
 
index 3375f21341e26cd8532a7c33f86a02873f64e69b..2e76db7650be737943216577e29777a8c34269c4 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *     BIRD Internet Routing Daemon -- Command-Line Interface
  *
- *     (c) 1999 Martin Mares <mj@ucw.cz>
+ *     (c) 1999--2000 Martin Mares <mj@ucw.cz>
  *
  *     Can be freely distributed and used under the terms of the GNU GPL.
  */
diff --git a/nest/cmds.c b/nest/cmds.c
new file mode 100644 (file)
index 0000000..c4443f9
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ *     BIRD Internet Routing Daemon -- CLI Commands Which Don't Fit Anywhere Else
+ *
+ *     (c) 2000 Martin Mares <mj@ucw.cz>
+ *
+ *     Can be freely distributed and used under the terms of the GNU GPL.
+ */
+
+#include "nest/bird.h"
+#include "nest/cli.h"
+#include "conf/conf.h"
+#include "nest/cmds.h"
+#include "lib/string.h"
+
+void
+cmd_show_status(void)
+{
+  cli_msg(1000, "BIRD " BIRD_VERSION);
+  /* FIXME: Should include uptime, shutdown flag et cetera */
+}
+
+void
+cmd_show_symbols(struct symbol *sym)
+{
+  int pos = 0;
+
+  if (sym)
+    cli_msg(1010, "%s\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));
+      cli_msg(0, "");
+    }
+}
diff --git a/nest/cmds.h b/nest/cmds.h
new file mode 100644 (file)
index 0000000..ae1c9e2
--- /dev/null
@@ -0,0 +1,10 @@
+/*
+ *     BIRD Internet Routing Daemon -- CLI Commands Which Don't Fit Anywhere Else
+ *
+ *     (c) 2000 Martin Mares <mj@ucw.cz>
+ *
+ *     Can be freely distributed and used under the terms of the GNU GPL.
+ */
+
+void cmd_show_status(void);
+void cmd_show_symbols(struct symbol *sym);
index 4bccc1665f85334304fa34859b9ae8b6bad40322..d5fdc4e1d68128307c1b580de62bfaad3f514d72 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *     BIRD -- Core Configuration
  *
- *     (c) 1998--1999 Martin Mares <mj@ucw.cz>
+ *     (c) 1998--2000 Martin Mares <mj@ucw.cz>
  *
  *     Can be freely distributed and used under the terms of the GNU GPL.
  */
@@ -13,6 +13,7 @@ static struct iface_patt *this_ipatt;
 
 #include "nest/rt-dev.h"
 #include "nest/password.h"
+#include "nest/cmds.h"
 
 CF_DECLS
 
@@ -193,10 +194,8 @@ password_list:
 
 CF_CLI_HELP(SHOW,,[[Show status information]])
 
-CF_CLI(SHOW STATUS,,, [[Show router status]]) {
-  cli_msg(1000, "BIRD " BIRD_VERSION);
-  /* FIXME: Should include uptime, shutdown flag et cetera */
-} ;
+CF_CLI(SHOW STATUS,,, [[Show router status]])
+{ cmd_show_status(); }
 
 CF_CLI(SHOW PROTOCOLS, optsym, [<name>], [[Show routing protocols]])
 { proto_show($3, 0); } ;
@@ -253,6 +252,9 @@ r_args:
    }
  ;
 
+CF_CLI(SHOW SYMBOLS, optsym, [<symbol>], [[Show all known symbolic names]])
+{ cmd_show_symbols($3); } ;
+
 CF_CLI_HELP(DEBUG, <subsystem>, [[Show debugging information]])
 CF_CLI(DEBUG RESOURCES,,, [[Show all allocated resource]])
 { rdump(&root_pool); cli_msg(0, ""); } ;