From 4a40b6246a4862ac52fa4ef7f692f63784e72330 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 20 Oct 2012 05:04:19 +0200 Subject: Somewhat hacky implementation of update retransmits --- ffd/ffd.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'ffd/ffd.c') diff --git a/ffd/ffd.c b/ffd/ffd.c index 9351476..fd82d0c 100644 --- a/ffd/ffd.c +++ b/ffd/ffd.c @@ -52,7 +52,8 @@ static char *mesh = "bat0"; int sockfd; struct timespec now; -static ffd_queue_head *tasks; +ffd_queue_head *tasks = NULL; +ffd_queue_head *retransmits = NULL; ffd_node_id_t self; ffd_iface_t *iface_list = NULL; @@ -358,13 +359,13 @@ static void handle_tlv_announce_req(const ffd_tlv_announce_req_t *tlv_req, size_ fprintf(stderr, "debug: received announce request\n"); if (ffd_is_node_id_unspec(&tlv_req->node)) { - ffd_send_update(NULL, get_tlv_neigh(arg), NULL, tlv_req->flags & FFD_UPDATE_WITH_DATA); + ffd_send_update(NULL, get_tlv_neigh(arg), NULL, false, tlv_req->flags & FFD_UPDATE_WITH_DATA); } else { ffd_announce_t *announce = ffd_announce_find(&tlv_req->node, ntohs(tlv_req->type), ntohs(tlv_req->key)); if (announce) - ffd_send_update(NULL, get_tlv_neigh(arg), announce, tlv_req->flags & FFD_UPDATE_WITH_DATA); + ffd_send_update(NULL, get_tlv_neigh(arg), announce, false, tlv_req->flags & FFD_UPDATE_WITH_DATA); else ffd_send_retract(get_tlv_neigh(arg), tlv_req->node, ntohs(tlv_req->type), ntohs(tlv_req->key)); } @@ -397,14 +398,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_send_update(NULL, neigh, announce, true, 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_send_update(NULL, neigh, announce, true, false); return; } @@ -494,7 +495,7 @@ static void send_updates(void) { ffd_iface_t *iface; for (iface = iface_list; iface; iface = iface->next) { - ffd_send_update(iface, NULL, NULL, false); + ffd_send_update(iface, NULL, NULL, false, false); } } @@ -591,6 +592,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 +617,11 @@ int main() { while (true) { ffd_queue_run(&tasks); + ffd_queue_run(&retransmits); struct pollfd fds[1]; - int timeout = 10*ffd_queue_timeout(&tasks); + int timeout = 10*timeout_min(ffd_queue_timeout(&tasks), ffd_queue_timeout(&retransmits)); if (timeout < 0) timeout = -1; -- cgit v1.2.3