#include "buffer.h"
#include "poll-loop.h"
#include "ofp-print.h"
+#include "sat-math.h"
#include "timeval.h"
#include "util.h"
#include "vconn.h"
int probe_interval; /* Secs of inactivity before sending probe. */
};
-static unsigned int sat_add(unsigned int x, unsigned int y);
-static unsigned int sat_sub(unsigned int x, unsigned int y);
-static unsigned int sat_mul(unsigned int x, unsigned int y);
static unsigned int elapsed_in_this_state(const struct rconn *);
static unsigned int timeout(const struct rconn *);
static bool timed_out(const struct rconn *);
/* Sends 'b' on 'rc'. Increments '*n_queued' while the packet is in flight; it
* will be decremented when it has been sent (or discarded due to
* disconnection). Returns 0 if successful, EAGAIN if '*n_queued' is already
- * at least as large of 'queue_limit', or ENOTCONN if 'rc' is not currently
+ * at least as large as 'queue_limit', or ENOTCONN if 'rc' is not currently
* connected. Regardless of return value, 'b' is destroyed.
*
* Because 'b' may be sent (or discarded) before this function returns, the
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. */
rc->state_entered = time_now();
}
-static unsigned int
-sat_add(unsigned int x, unsigned int y)
-{
- return x + y >= x ? x + y : UINT_MAX;
-}
-
-static unsigned int
-sat_sub(unsigned int x, unsigned int y)
-{
- return x >= y ? x - y : 0;
-}
-
-static unsigned int
-sat_mul(unsigned int x, unsigned int y)
-{
- assert(y);
- return x <= UINT_MAX / y ? x * y : UINT_MAX;
-}
-
static void
question_connectivity(struct rconn *rc)
{