Make the secchan report a few more switch-status items.
authorBen Pfaff <blp@nicira.com>
Wed, 27 Aug 2008 18:29:53 +0000 (11:29 -0700)
committerBen Pfaff <blp@nicira.com>
Thu, 28 Aug 2008 21:25:05 +0000 (14:25 -0700)
include/rconn.h
lib/rconn.c
secchan/secchan.c

index 036f030..df17a5c 100644 (file)
@@ -87,5 +87,7 @@ unsigned int rconn_get_successful_connections(const struct rconn *);
 time_t rconn_get_last_connection(const struct rconn *);
 time_t rconn_get_creation_time(const struct rconn *);
 unsigned long int rconn_get_total_time_connected(const struct rconn *);
+int rconn_get_backoff(const struct rconn *);
+unsigned int rconn_get_state_elapsed(const struct rconn *);
 
 #endif /* rconn.h */
index ee995e4..26e2e61 100644 (file)
@@ -623,6 +623,21 @@ rconn_get_total_time_connected(const struct rconn *rc)
     return (rc->total_time_connected
             + (rconn_is_connected(rc) ? elapsed_in_this_state(rc) : 0));
 }
+
+/* Returns the current amount of backoff, in seconds.  This is the amount of
+ * time after which the rconn will transition from BACKOFF to CONNECTING. */
+int
+rconn_get_backoff(const struct rconn *rc)
+{
+    return rc->backoff;
+}
+
+/* Returns the number of seconds spent in this state so far. */
+unsigned int
+rconn_get_state_elapsed(const struct rconn *rc)
+{
+    return elapsed_in_this_state(rc);
+}
 \f
 /* Tries to send a packet from 'rc''s send buffer.  Returns 0 if successful,
  * otherwise a positive errno value. */
index 92d5ed7..68e7df3 100644 (file)
@@ -1092,6 +1092,7 @@ rconn_status_cb(struct status_reply *sr, void *rconn_)
 
     status_reply_put(sr, "name=%s", rconn_get_name(rconn));
     status_reply_put(sr, "state=%s", rconn_get_state(rconn));
+    status_reply_put(sr, "backoff=%d", rconn_get_backoff(rconn));
     status_reply_put(sr, "is-connected=%s",
                      rconn_is_connected(rconn) ? "true" : "false");
     status_reply_put(sr, "sent-msgs=%u", rconn_packets_sent(rconn));
@@ -1104,6 +1105,7 @@ rconn_status_cb(struct status_reply *sr, void *rconn_)
                      (long int) (now - rconn_get_last_connection(rconn)));
     status_reply_put(sr, "time-connected=%lu",
                      rconn_get_total_time_connected(rconn));
+    status_reply_put(sr, "state-elapsed=%u", rconn_get_state_elapsed(rconn));
 }
 
 static void