summaryrefslogtreecommitdiffstats
path: root/ffd/ffd.c
diff options
context:
space:
mode:
Diffstat (limited to 'ffd/ffd.c')
-rw-r--r--ffd/ffd.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/ffd/ffd.c b/ffd/ffd.c
index 9351476..5ff5f1b 100644
--- a/ffd/ffd.c
+++ b/ffd/ffd.c
@@ -52,7 +52,7 @@ static char *mesh = "bat0";
int sockfd;
struct timespec now;
-static ffd_queue_head *tasks;
+static ffd_queue_t *tasks = NULL;
ffd_node_id_t self;
ffd_iface_t *iface_list = NULL;
@@ -397,14 +397,14 @@ static void handle_tlv_seqno_req(const ffd_tlv_seqno_req_t *tlv_req, size_t len,
if ((int16_t)(seqno-announce->selected->metric_seqno.seqno) <= 0) {
fprintf(stderr, "debug: received seqno request, seqno already ok\n");
- ffd_send_update(NULL, neigh, announce, false);
+ ffd_update_enqueue(&announce->node, announce->type, announce->key, neigh, false);
return;
}
if (!announce->selected->neigh) {
fprintf(stderr, "debug: received seqno request, incrementing seqno\n");
announce->selected->metric_seqno.seqno++;
- ffd_send_update(NULL, neigh, announce, false);
+ ffd_update_enqueue(&announce->node, announce->type, announce->key, neigh, false);
return;
}
@@ -533,8 +533,7 @@ static void maintenance(void) {
if (!announce->nexthop_list) {
*cur = *next;
next = cur;
- ffd_announce_seqno_request_free_list(announce);
- free(announce);
+ ffd_announce_free(announce);
continue;
}
@@ -591,6 +590,16 @@ static void register_periodic_tasks(void) {
}
+static inline int timeout_min(int a, int b) {
+ if (a < 0)
+ return b;
+ else if (b < 0)
+ return a;
+ else
+ return min(a, b);
+}
+
+
int main() {
if (!check_config())
return 1;
@@ -606,10 +615,11 @@ int main() {
while (true) {
ffd_queue_run(&tasks);
+ ffd_update_run();
struct pollfd fds[1];
- int timeout = 10*ffd_queue_timeout(&tasks);
+ int timeout = 10*timeout_min(ffd_queue_timeout(&tasks), ffd_update_timeout());
if (timeout < 0)
timeout = -1;