diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/event.h | 9 | ||||
-rw-r--r-- | lib/ip.h | 2 | ||||
-rw-r--r-- | lib/unaligned.h | 6 |
3 files changed, 17 insertions, 0 deletions
diff --git a/lib/event.h b/lib/event.h index d5975222..14a54730 100644 --- a/lib/event.h +++ b/lib/event.h @@ -36,5 +36,14 @@ ev_active(event *e) return e->n.next != NULL; } +static inline event* +ev_new_set(pool *p, void (*hook)(void *), void *data) +{ + event *e = ev_new(p); + e->hook = hook; + e->data = data; + return e; +} + #endif @@ -99,6 +99,7 @@ typedef ip6_addr ip_addr; #define ipa_to_u32(x) ip4_to_u32(ipa_to_ip4(x)) #define ipa_is_ip4(a) ip6_is_v4mapped(a) +#define ipa_is_ip6(a) (! ip6_is_v4mapped(a)) #else @@ -115,6 +116,7 @@ typedef ip4_addr ip_addr; #define ipa_to_u32(x) ip4_to_u32(ipa_to_ip4(x)) #define ipa_is_ip4(a) 1 +#define ipa_is_ip6(a) 0 #endif diff --git a/lib/unaligned.h b/lib/unaligned.h index dc777fbf..b02bc6fe 100644 --- a/lib/unaligned.h +++ b/lib/unaligned.h @@ -45,6 +45,12 @@ get_u64(const void *p) } static inline void +put_u8(void *p, u8 x) +{ + memcpy(p, &x, 1); +} + +static inline void put_u16(void *p, u16 x) { x = htons(x); |