diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/alarm.c | 19 | ||||
-rw-r--r-- | src/cache_timer.c | 4 | ||||
-rw-r--r-- | src/parse.c | 10 | ||||
-rw-r--r-- | src/sync-alarm.c | 8 | ||||
-rw-r--r-- | src/sync-ftfw.c | 6 |
5 files changed, 15 insertions, 32 deletions
diff --git a/src/alarm.c b/src/alarm.c index 2c65ef3..6edf68e 100644 --- a/src/alarm.c +++ b/src/alarm.c @@ -27,22 +27,13 @@ static LIST_HEAD(alarm_list); -void set_alarm_function(struct alarm_list *t, - void (*fcn)(struct alarm_list *a, void *data)) -{ - t->function = fcn; -} - -void set_alarm_data(struct alarm_list *t, void *data) -{ - t->data = data; -} - -void init_alarm(struct alarm_list *t) +void init_alarm(struct alarm_list *t, + void *data, + void (*fcn)(struct alarm_list *a, void *data)) { timerclear(&t->tv); - t->data = 0; - t->function = NULL; + t->data = data; + t->function = fcn; } void __add_alarm(struct alarm_list *alarm) diff --git a/src/cache_timer.c b/src/cache_timer.c index 2379f4b..8b4e4ea 100644 --- a/src/cache_timer.c +++ b/src/cache_timer.c @@ -35,10 +35,8 @@ static void timer_add(struct us_conntrack *u, void *data) { struct alarm_list *alarm = data; - init_alarm(alarm); + init_alarm(alarm, u, timeout); set_alarm_expiration(alarm, CONFIG(cache_timeout), 0); - set_alarm_data(alarm, u); - set_alarm_function(alarm, timeout); add_alarm(alarm); } diff --git a/src/parse.c b/src/parse.c index 0650995..c8a9704 100644 --- a/src/parse.c +++ b/src/parse.c @@ -20,27 +20,27 @@ #include <libnetfilter_conntrack/libnetfilter_conntrack.h> #include "network.h" -static int parse_u8(struct nf_conntrack *ct, int attr, void *data) +static void parse_u8(struct nf_conntrack *ct, int attr, void *data) { u_int8_t *value = (u_int8_t *) data; nfct_set_attr_u8(ct, attr, *value); } -static int parse_u16(struct nf_conntrack *ct, int attr, void *data) +static void parse_u16(struct nf_conntrack *ct, int attr, void *data) { u_int16_t *value = (u_int16_t *) data; nfct_set_attr_u16(ct, attr, ntohs(*value)); } -static int parse_u32(struct nf_conntrack *ct, int attr, void *data) +static void parse_u32(struct nf_conntrack *ct, int attr, void *data) { u_int32_t *value = (u_int32_t *) data; nfct_set_attr_u32(ct, attr, ntohl(*value)); } -typedef int (*parse)(struct nf_conntrack *ct, int attr, void *data); +typedef void (*parse)(struct nf_conntrack *ct, int attr, void *data); -parse h[ATTR_MAX] = { +static parse h[ATTR_MAX] = { [ATTR_IPV4_SRC] = parse_u32, [ATTR_IPV4_DST] = parse_u32, [ATTR_L3PROTO] = parse_u8, diff --git a/src/sync-alarm.c b/src/sync-alarm.c index 1dcfacd..d9a8267 100644 --- a/src/sync-alarm.c +++ b/src/sync-alarm.c @@ -30,13 +30,11 @@ static void refresher(struct alarm_list *a, void *data) debug_ct(u->ct, "persistence update"); - init_alarm(a); + init_alarm(a, u, refresher); set_alarm_expiration(a, random() % CONFIG(refresh) + 1, random() % 999999 + 1); - set_alarm_data(a, u); - set_alarm_function(a, refresher); add_alarm(a); net = BUILD_NETMSG(u->ct, NFCT_Q_UPDATE); @@ -48,12 +46,10 @@ static void cache_alarm_add(struct us_conntrack *u, void *data) { struct alarm_list *alarm = data; - init_alarm(alarm); + init_alarm(alarm, u, refresher); set_alarm_expiration(alarm, random() % CONFIG(refresh) + 1, random() % 999999 + 1); - set_alarm_data(alarm, u); - set_alarm_function(alarm, refresher); add_alarm(alarm); } diff --git a/src/sync-ftfw.c b/src/sync-ftfw.c index 0d57f36..63fd4b2 100644 --- a/src/sync-ftfw.c +++ b/src/sync-ftfw.c @@ -87,9 +87,8 @@ static void do_alive_alarm(struct alarm_list *a, void *data) { tx_queue_add_ctlmsg(NET_F_ALIVE, 0, 0); - init_alarm(&alive_alarm); + init_alarm(&alive_alarm, NULL, do_alive_alarm); set_alarm_expiration(&alive_alarm, 1, 0); - set_alarm_function(&alive_alarm, do_alive_alarm); add_alarm(&alive_alarm); } @@ -111,9 +110,8 @@ static int ftfw_init() INIT_LIST_HEAD(&rs_list); /* XXX: alive message expiration configurable */ - init_alarm(&alive_alarm); + init_alarm(&alive_alarm, NULL, do_alive_alarm); set_alarm_expiration(&alive_alarm, 1, 0); - set_alarm_function(&alive_alarm, do_alive_alarm); add_alarm(&alive_alarm); return 0; |