summaryrefslogtreecommitdiff
path: root/proto/bfd/io.h
diff options
context:
space:
mode:
authorOndrej Zajicek <santiago@crfreenet.org>2013-09-10 12:09:36 +0200
committerOndrej Zajicek <santiago@crfreenet.org>2013-09-10 12:09:36 +0200
commitbf139664aa2ae9956b520ba4813bb6e03bf1a3e8 (patch)
tree33381e1e2214b32fcb169def039a891b0db58509 /proto/bfd/io.h
parentbff9ce5130d16af2fd802d42bdb2bff00980c9ae (diff)
Initial BFD commit, work in progress.
Diffstat (limited to 'proto/bfd/io.h')
-rw-r--r--proto/bfd/io.h62
1 files changed, 62 insertions, 0 deletions
diff --git a/proto/bfd/io.h b/proto/bfd/io.h
new file mode 100644
index 00000000..7fc45194
--- /dev/null
+++ b/proto/bfd/io.h
@@ -0,0 +1,62 @@
+
+typedef s64 xxx_time;
+
+typedef struct timer
+{
+ resource r;
+ void (*hook)(struct timer2 *);
+ void *data;
+
+ xxx_time expires; /* 0=inactive */
+ unsigned randomize; /* Amount of randomization */
+ unsigned recurrent; /* Timer recurrence */
+
+ int index;
+} timer;
+
+
+
+void ev2_schedule(event *e);
+
+
+
+timer2 *tm2_new(pool *p);
+void tm2_start(timer2 *t, xxx_time after);
+void tm2_stop(timer2 *t);
+
+static inline xxx_time
+tm2_remains(timer2 *t)
+{
+ return (t->expires > xxxnow) ? t->expires - xxxnow : 0;
+}
+
+static inline void
+tm2_start_max(timer2 *t, xxx_time after)
+{
+ xxx_time rem = tm2_remains(t);
+ tm2_start(t, MAX(rem, after));
+}
+
+static inline timer2 *
+tm2_new_set(pool *p, void (*hook)(struct timer2 *), void *data, uint rec, uint rand)
+{
+ timer2 *t = tm2_new(p);
+ t->hook = hook;
+ t->data = data;
+ t->recurrent = rec;
+ t->randomize = rand;
+ return t;
+}
+
+
+
+void sk_start(sock *s);
+void sk_stop(sock *s);
+
+
+
+struct birdloop *birdloop_new(pool *p);
+void birdloop_enter(struct birdloop *loop);
+void birdloop_leave(struct birdloop *loop);
+void birdloop_main(struct birdloop *loop);
+