From 0d3e6bceeeec4ebf007e02374f799cd1fb21f20c Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Tue, 30 Nov 1999 12:57:14 +0000 Subject: `show interfaces' and `show protocols' works. --- nest/proto.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 62 insertions(+), 3 deletions(-) (limited to 'nest/proto.c') diff --git a/nest/proto.c b/nest/proto.c index 32e0b3be..29f961d4 100644 --- a/nest/proto.c +++ b/nest/proto.c @@ -422,10 +422,69 @@ proto_flush_all(void *unused) return 0; } +/* + * CLI Commands + */ + +static char * +proto_state_name(struct proto *p) +{ +#define P(x,y) ((x << 4) | y) + switch (P(p->proto_state, p->core_state)) + { + case P(PS_DOWN, FS_HUNGRY): return "down"; + case P(PS_START, FS_HUNGRY): return "start"; + case P(PS_UP, FS_HUNGRY): + case P(PS_UP, FS_FEEDING): return "feed"; + case P(PS_STOP, FS_HUNGRY): return "stop"; + case P(PS_UP, FS_HAPPY): return "up"; + case P(PS_STOP, FS_FLUSHING): + case P(PS_DOWN, FS_FLUSHING): return "flush"; + default: return "???"; + } +#undef P +} + +static char * +proto_goal_name(struct proto *p) +{ + if (p->disabled) + return " "; + if (p->core_goal == p->core_state) + return ""; + if (p->core_goal == FS_HAPPY) + return " "; + return " "; +} + +static void +proto_do_show(list *l, int verbose) +{ + struct proto *p; + + WALK_LIST(p, *l) + { + cli_msg(-1002, "%-8s %-8s %-8s %s%s", + p->name, + p->proto->name, + p->table->name, + proto_state_name(p), + proto_goal_name(p)); + if (verbose) + { + cli_msg(-1006, "\tPreference: %d", p->preference); + cli_msg(-1006, "\tInput filter: %s", filter_name(p->in_filter)); + cli_msg(-1006, "\tOutput filter: %s", filter_name(p->out_filter)); + } + } +} + void -proto_show(struct symbol *s) +proto_show(struct symbol *s, int verbose) { - cli_msg(-1002, ""); - cli_msg(-2002, ""); + cli_msg(-2002, "name proto table state"); + proto_do_show(&proto_list, verbose); + proto_do_show(&flush_proto_list, verbose); + proto_do_show(&inactive_proto_list, verbose); cli_msg(0, ""); } -- cgit v1.2.3