diff options
author | Ondrej Zajicek <santiago@crfreenet.org> | 2013-11-23 11:50:34 +0100 |
---|---|---|
committer | Ondrej Zajicek <santiago@crfreenet.org> | 2013-11-23 11:50:34 +0100 |
commit | 736e143fa50607fcd88132291e96089b899af979 (patch) | |
tree | c0fcd5fb3174bae8a39b3a32dfe582b2ccb6df17 /proto/bfd/io.h | |
parent | 094d2bdb79e1ffa0a02761fd651aa0f0b6b0c585 (diff) | |
parent | 2b3d52aa421ae1c31e30107beefd82fddbb42854 (diff) |
Merge branch 'master' into add-path
Conflicts:
filter/filter.c
nest/proto.c
nest/rt-table.c
proto/bgp/bgp.h
proto/bgp/config.Y
Diffstat (limited to 'proto/bfd/io.h')
-rw-r--r-- | proto/bfd/io.h | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/proto/bfd/io.h b/proto/bfd/io.h new file mode 100644 index 00000000..641ee054 --- /dev/null +++ b/proto/bfd/io.h @@ -0,0 +1,99 @@ +/* + * BIRD -- I/O and event loop + * + * Can be freely distributed and used under the terms of the GNU GPL. + */ + +#ifndef _BIRD_BFD_IO_H_ +#define _BIRD_BFD_IO_H_ + +#include "nest/bird.h" +#include "lib/lists.h" +#include "lib/resource.h" +#include "lib/event.h" +#include "lib/socket.h" +// #include "lib/timer.h" + + +typedef struct timer2 +{ + resource r; + void (*hook)(struct timer2 *); + void *data; + + btime expires; /* 0=inactive */ + uint randomize; /* Amount of randomization */ + uint recurrent; /* Timer recurrence */ + + int index; +} timer2; + + +btime current_time(void); + +void ev2_schedule(event *e); + + +timer2 *tm2_new(pool *p); +void tm2_set(timer2 *t, btime when); +void tm2_start(timer2 *t, btime after); +void tm2_stop(timer2 *t); + +static inline int +tm2_active(timer2 *t) +{ + return t->expires != 0; +} + +static inline btime +tm2_remains(timer2 *t) +{ + btime now = current_time(); + return (t->expires > now) ? (t->expires - now) : 0; +} + +static inline timer2 * +tm2_new_init(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; +} + +static inline void +tm2_set_max(timer2 *t, btime when) +{ + if (when > t->expires) + tm2_set(t, when); +} + +/* +static inline void +tm2_start_max(timer2 *t, btime after) +{ + btime rem = tm2_remains(t); + tm2_start(t, MAX_(rem, after)); +} +*/ + + +void sk_start(sock *s); +void sk_stop(sock *s); + + + +struct birdloop *birdloop_new(void); +void birdloop_start(struct birdloop *loop); +void birdloop_stop(struct birdloop *loop); +void birdloop_free(struct birdloop *loop); + +void birdloop_enter(struct birdloop *loop); +void birdloop_leave(struct birdloop *loop); +void birdloop_mask_wakeups(struct birdloop *loop); +void birdloop_unmask_wakeups(struct birdloop *loop); + + +#endif /* _BIRD_BFD_IO_H_ */ |