mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-22 01:31:55 +00:00
show interfaces' and
show protocols' works.
This commit is contained in:
parent
10b5baaef3
commit
0d3e6bceee
@ -1,8 +1,8 @@
|
||||
Reply codes of BIRD command-line interface
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
0xxx Action suceessfully completed
|
||||
1xxx Table heading
|
||||
2xxx Table entry
|
||||
1xxx Table entry
|
||||
2xxx Table heading
|
||||
8xxx Run-time error
|
||||
9xxx Parse-time error
|
||||
<space> Continuation
|
||||
@ -11,14 +11,13 @@ Reply codes of BIRD command-line interface
|
||||
0000 OK
|
||||
0001 Welcome
|
||||
|
||||
1000 BIRD version
|
||||
1001 Interface list
|
||||
1002 Protocol list
|
||||
|
||||
2000 BIRD version
|
||||
2001 Interface list
|
||||
2002 Protocol list
|
||||
2003 Interface address
|
||||
2004 Interface flags
|
||||
2005 Interface summary
|
||||
1003 Interface address
|
||||
1004 Interface flags
|
||||
1005 Interface summary
|
||||
1006 Protocol details
|
||||
|
||||
8000 Reply too long
|
||||
|
||||
|
@ -191,12 +191,15 @@ password_list:
|
||||
CF_CLI_HELP(SHOW,,[[Show status information]])
|
||||
|
||||
CF_CLI(SHOW STATUS,,, [[Show router status]]) {
|
||||
cli_msg(2000, "BIRD " BIRD_VERSION);
|
||||
cli_msg(1000, "BIRD " BIRD_VERSION);
|
||||
/* FIXME: Should include uptime, shutdown flag et cetera */
|
||||
} ;
|
||||
|
||||
CF_CLI(SHOW PROTOCOLS, optsym, [<name>], [[Show routing protocols]])
|
||||
{ proto_show($3); } ;
|
||||
{ proto_show($3, 0); } ;
|
||||
|
||||
CF_CLI(SHOW PROTOCOLS VERBOSE, optsym, [<name>], [[Show routing protocol details]])
|
||||
{ proto_show($4, 1); } ;
|
||||
|
||||
CF_CLI(SHOW INTERFACES,,, [[Show network interfaces]])
|
||||
{ if_show(); } ;
|
||||
|
@ -646,7 +646,7 @@ if_show_addr(struct ifa *a)
|
||||
bsprintf(opp, ", opposite %I", a->opposite);
|
||||
else
|
||||
opp[0] = 0;
|
||||
cli_msg(-2003, "\t%I/%d (%s%s%s, scope %s)",
|
||||
cli_msg(-1003, "\t%I/%d (%s%s%s, scope %s)",
|
||||
a->ip, a->pxlen,
|
||||
(a->flags & IA_PRIMARY) ? "Primary" : (a->flags & IA_SECONDARY) ? "Secondary" : "???",
|
||||
broad, opp,
|
||||
@ -662,14 +662,14 @@ if_show(void)
|
||||
|
||||
WALK_LIST(i, iface_list)
|
||||
{
|
||||
cli_msg(-2001, "%s %s (index=%d)", i->name, (i->flags & IF_UP) ? "up" : "DOWN", i->index);
|
||||
cli_msg(-1001, "%s %s (index=%d)", i->name, (i->flags & IF_UP) ? "up" : "DOWN", i->index);
|
||||
if (i->flags & IF_UNNUMBERED)
|
||||
type = "UnNum-PtP";
|
||||
else if (!(i->flags & IF_MULTIACCESS))
|
||||
type = "PtP";
|
||||
else
|
||||
type = "MultiAccess";
|
||||
cli_msg(-2004, "\t%s%s%s Admin%s Link%s%s%s MTU=%d",
|
||||
cli_msg(-1004, "\t%s%s%s Admin%s Link%s%s%s MTU=%d",
|
||||
type,
|
||||
(i->flags & IF_BROADCAST) ? " Broadcast" : "",
|
||||
(i->flags & IF_MULTICAST) ? " Multicast" : "",
|
||||
@ -693,13 +693,14 @@ if_show_summary(void)
|
||||
struct iface *i;
|
||||
byte addr[STD_ADDRESS_P_LENGTH + 16];
|
||||
|
||||
cli_msg(-2005, "interface state address");
|
||||
WALK_LIST(i, iface_list)
|
||||
{
|
||||
if (i->addr)
|
||||
bsprintf(addr, "%I/%d", i->addr->ip, i->addr->pxlen);
|
||||
else
|
||||
addr[0] = 0;
|
||||
cli_msg(-2005, "%s\t%s\t%s", i->name, (i->flags & IF_UP) ? "up" : "DOWN", addr);
|
||||
cli_msg(-1005, "%-9s %-5s %s", i->name, (i->flags & IF_UP) ? "up" : "DOWN", addr);
|
||||
}
|
||||
cli_msg(0, "");
|
||||
}
|
||||
|
67
nest/proto.c
67
nest/proto.c
@ -422,10 +422,69 @@ proto_flush_all(void *unused)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
proto_show(struct symbol *s)
|
||||
/*
|
||||
* CLI Commands
|
||||
*/
|
||||
|
||||
static char *
|
||||
proto_state_name(struct proto *p)
|
||||
{
|
||||
cli_msg(-1002, "");
|
||||
cli_msg(-2002, "");
|
||||
#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 " <disabled>";
|
||||
if (p->core_goal == p->core_state)
|
||||
return "";
|
||||
if (p->core_goal == FS_HAPPY)
|
||||
return " <starting>";
|
||||
return " <shutting down>";
|
||||
}
|
||||
|
||||
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, int verbose)
|
||||
{
|
||||
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, "");
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ struct proto {
|
||||
void proto_build(struct proto_config *);
|
||||
void *proto_new(struct proto_config *, unsigned size);
|
||||
void *proto_config_new(struct protocol *, unsigned size);
|
||||
void proto_show(struct symbol *);
|
||||
void proto_show(struct symbol *, int);
|
||||
|
||||
extern list proto_list;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user