]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
`show protocols' now shows time of last state change and protocol-dependent
authorMartin Mares <mj@ucw.cz>
Wed, 1 Dec 1999 12:00:15 +0000 (12:00 +0000)
committerMartin Mares <mj@ucw.cz>
Wed, 1 Dec 1999 12:00:15 +0000 (12:00 +0000)
status information (obtained via newly introduced hook protocol->get_status).

nest/proto.c
nest/protocol.h

index 0766608a2676a99b74c9cc8452888b345b03d6d4..94bbbfd8349f7a71465b02c0cc4912477d0ee588 100644 (file)
@@ -53,6 +53,7 @@ proto_enqueue(list *l, struct proto *p)
        q = (struct proto *) q->n.next;
       insert_node(&p->n, q->n.prev);
     }
+  p->last_state_change = now;
 }
 
 static void
@@ -446,27 +447,22 @@ proto_state_name(struct proto *p)
 #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);
@@ -492,7 +488,7 @@ proto_show(struct symbol *s, int verbose)
       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
index 8958d0766122afb61c3a56882503ee07b33eeea7..c77a9358507a81ceb827765de5a2c2a41d61b0a0 100644 (file)
@@ -11,6 +11,7 @@
 
 #include "lib/lists.h"
 #include "lib/resource.h"
+#include "lib/timer.h"
 
 struct iface;
 struct ifa;
@@ -45,6 +46,7 @@ struct protocol {
   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);
@@ -98,6 +100,7 @@ struct proto {
   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: