q = (struct proto *) q->n.next;
insert_node(&p->n, q->n.prev);
}
+ p->last_state_change = now;
}
static void
#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(struct proto *p, int verbose)
{
- cli_msg(-1002, "%-8s %-8s %-8s %s%s",
+ byte buf[256], reltime[TM_RELTIME_BUFFER_SIZE];
+
+ buf[0] = 0;
+ if (p->proto->get_status)
+ p->proto->get_status(p, buf);
+ tm_format_reltime(reltime, p->last_state_change);
+ cli_msg(-1002, "%-8s %-8s %-8s %-5s %-5s %s",
p->name,
p->proto->name,
p->table->name,
proto_state_name(p),
- proto_goal_name(p));
+ reltime,
+ buf);
if (verbose)
{
cli_msg(-1006, "\tPreference: %d", p->preference);
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 since info");
if (s)
proto_do_show(((struct proto_config *)s->def)->proto, verbose);
else
#include "lib/lists.h"
#include "lib/resource.h"
+#include "lib/timer.h"
struct iface;
struct ifa;
void (*dump_attrs)(struct rte *); /* Dump protocol-dependent attributes */
int (*start)(struct proto *); /* Start the instance */
int (*shutdown)(struct proto *); /* Stop the instance */
+ void (*get_status)(struct proto *, byte *buf); /* Get instance status (for `show protocols' command) */
};
void protos_build(void);
unsigned proto_state; /* Protocol state machine (see below) */
unsigned core_state; /* Core state machine (see below) */
unsigned core_goal; /* State we want to reach (see below) */
+ bird_clock_t last_state_change; /* Time of last state transition */
/*
* General protocol hooks: