Remember protocol instance in proto_config and use that for
`show protocols <name>'.
This commit is contained in:
parent
c9aae7f47f
commit
1d2664a4d4
5 changed files with 44 additions and 27 deletions
4
TODO
4
TODO
|
@ -47,14 +47,12 @@ Commands
|
||||||
shutdown # order system shutdown
|
shutdown # order system shutdown
|
||||||
configure [<file>]
|
configure [<file>]
|
||||||
debug <what> # dump debugging information to log
|
debug <what> # dump debugging information to log
|
||||||
show protocols [<name>]
|
show <name> # show everything you know about symbol <name>
|
||||||
<name> # show everything you know about symbol <name>
|
|
||||||
route [<route>] [table <name>] [filter (<name> | { <inline> })] [where <condition>] [all]
|
route [<route>] [table <name>] [filter (<name> | { <inline> })] [where <condition>] [all]
|
||||||
status # router id, version etc.
|
status # router id, version etc.
|
||||||
rip ??? [<name>]
|
rip ??? [<name>]
|
||||||
ospf ??? [<name>]
|
ospf ??? [<name>]
|
||||||
static ??? [<name>]
|
static ??? [<name>]
|
||||||
interfaces [<name>]
|
|
||||||
neighbors # ???
|
neighbors # ???
|
||||||
filters [<name>]
|
filters [<name>]
|
||||||
(disable|enable|restart) <protocol> # or ALL?
|
(disable|enable|restart) <protocol> # or ALL?
|
||||||
|
|
|
@ -23,3 +23,4 @@ Reply codes of BIRD command-line interface
|
||||||
|
|
||||||
9000 Command too long
|
9000 Command too long
|
||||||
9001 Parse error
|
9001 Parse error
|
||||||
|
9002 Invalid symbol type
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
* Can be freely distributed and used under the terms of the GNU GPL.
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "nest/bird.h"
|
#include "nest/bird.h"
|
||||||
#include "nest/cli.h"
|
#include "nest/cli.h"
|
||||||
#include "conf/conf.h"
|
#include "conf/conf.h"
|
||||||
|
@ -119,7 +121,7 @@ cli_command(struct cli *c)
|
||||||
struct config f;
|
struct config f;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
f.pool = NULL;
|
bzero(&f, sizeof(f));
|
||||||
f.mem = c->parser_pool;
|
f.mem = c->parser_pool;
|
||||||
cf_read_hook = cli_cmd_read_hook;
|
cf_read_hook = cli_cmd_read_hook;
|
||||||
cli_rh_pos = c->rx_buf;
|
cli_rh_pos = c->rx_buf;
|
||||||
|
|
41
nest/proto.c
41
nest/proto.c
|
@ -78,7 +78,7 @@ proto_relink(struct proto *p)
|
||||||
void *
|
void *
|
||||||
proto_new(struct proto_config *c, unsigned size)
|
proto_new(struct proto_config *c, unsigned size)
|
||||||
{
|
{
|
||||||
struct protocol *pr = c->proto;
|
struct protocol *pr = c->protocol;
|
||||||
struct proto *p = mb_allocz(proto_pool, size);
|
struct proto *p = mb_allocz(proto_pool, size);
|
||||||
|
|
||||||
p->cf = c;
|
p->cf = c;
|
||||||
|
@ -90,6 +90,7 @@ proto_new(struct proto_config *c, unsigned size)
|
||||||
p->table = c->table->table;
|
p->table = c->table->table;
|
||||||
p->in_filter = c->in_filter;
|
p->in_filter = c->in_filter;
|
||||||
p->out_filter = c->out_filter;
|
p->out_filter = c->out_filter;
|
||||||
|
c->proto = p;
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,7 +137,7 @@ proto_config_new(struct protocol *pr, unsigned size)
|
||||||
|
|
||||||
add_tail(&new_config->protos, &c->n);
|
add_tail(&new_config->protos, &c->n);
|
||||||
c->global = new_config;
|
c->global = new_config;
|
||||||
c->proto = pr;
|
c->protocol = pr;
|
||||||
c->debug = pr->debug;
|
c->debug = pr->debug;
|
||||||
c->name = pr->name;
|
c->name = pr->name;
|
||||||
c->out_filter = FILTER_REJECT;
|
c->out_filter = FILTER_REJECT;
|
||||||
|
@ -174,7 +175,7 @@ protos_postconfig(struct config *c)
|
||||||
WALK_LIST(x, c->protos)
|
WALK_LIST(x, c->protos)
|
||||||
{
|
{
|
||||||
debug(" %s", x->name);
|
debug(" %s", x->name);
|
||||||
p = x->proto;
|
p = x->protocol;
|
||||||
if (p->postconfig)
|
if (p->postconfig)
|
||||||
p->postconfig(x);
|
p->postconfig(x);
|
||||||
}
|
}
|
||||||
|
@ -192,7 +193,7 @@ protos_commit(struct config *c)
|
||||||
WALK_LIST(x, c->protos)
|
WALK_LIST(x, c->protos)
|
||||||
{
|
{
|
||||||
debug(" %s", x->name);
|
debug(" %s", x->name);
|
||||||
p = x->proto;
|
p = x->protocol;
|
||||||
q = p->init(x);
|
q = p->init(x);
|
||||||
q->proto_state = PS_DOWN;
|
q->proto_state = PS_DOWN;
|
||||||
q->core_state = FS_HUNGRY;
|
q->core_state = FS_HUNGRY;
|
||||||
|
@ -458,12 +459,8 @@ proto_goal_name(struct proto *p)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
proto_do_show(list *l, int verbose)
|
proto_do_show(struct proto *p, int verbose)
|
||||||
{
|
{
|
||||||
struct proto *p;
|
|
||||||
|
|
||||||
WALK_LIST(p, *l)
|
|
||||||
{
|
|
||||||
cli_msg(-1002, "%-8s %-8s %-8s %s%s",
|
cli_msg(-1002, "%-8s %-8s %-8s %s%s",
|
||||||
p->name,
|
p->name,
|
||||||
p->proto->name,
|
p->proto->name,
|
||||||
|
@ -476,15 +473,33 @@ proto_do_show(list *l, int verbose)
|
||||||
cli_msg(-1006, "\tInput filter: %s", filter_name(p->in_filter));
|
cli_msg(-1006, "\tInput filter: %s", filter_name(p->in_filter));
|
||||||
cli_msg(-1006, "\tOutput filter: %s", filter_name(p->out_filter));
|
cli_msg(-1006, "\tOutput filter: %s", filter_name(p->out_filter));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
proto_do_show_list(list *l, int verbose)
|
||||||
|
{
|
||||||
|
struct proto *p;
|
||||||
|
|
||||||
|
WALK_LIST(p, *l)
|
||||||
|
proto_do_show(p, verbose);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
proto_show(struct symbol *s, int verbose)
|
proto_show(struct symbol *s, int verbose)
|
||||||
{
|
{
|
||||||
|
if (s && s->class != SYM_PROTO)
|
||||||
|
{
|
||||||
|
cli_msg(9002, "%s is not a protocol", s->name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
cli_msg(-2002, "name proto table state");
|
cli_msg(-2002, "name proto table state");
|
||||||
proto_do_show(&proto_list, verbose);
|
if (s)
|
||||||
proto_do_show(&flush_proto_list, verbose);
|
proto_do_show(((struct proto_config *)s->def)->proto, verbose);
|
||||||
proto_do_show(&inactive_proto_list, verbose);
|
else
|
||||||
|
{
|
||||||
|
proto_do_show_list(&proto_list, verbose);
|
||||||
|
proto_do_show_list(&flush_proto_list, verbose);
|
||||||
|
proto_do_show_list(&inactive_proto_list, verbose);
|
||||||
|
}
|
||||||
cli_msg(0, "");
|
cli_msg(0, "");
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,8 @@ extern struct protocol proto_pipe;
|
||||||
struct proto_config {
|
struct proto_config {
|
||||||
node n;
|
node n;
|
||||||
struct config *global; /* Global configuration data */
|
struct config *global; /* Global configuration data */
|
||||||
struct protocol *proto; /* Protocol */
|
struct protocol *protocol; /* Protocol */
|
||||||
|
struct proto *proto; /* Instance we've created */
|
||||||
char *name;
|
char *name;
|
||||||
unsigned debug, preference, disabled; /* Generic parameters */
|
unsigned debug, preference, disabled; /* Generic parameters */
|
||||||
struct rtable_config *table; /* Table we're attached to */
|
struct rtable_config *table; /* Table we're attached to */
|
||||||
|
|
Loading…
Reference in a new issue