From ec21d1874e54cfb4ce2f0e91ba0310b378b60a4b Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Mon, 8 Oct 2012 03:24:05 +0200 Subject: Send triggered updates --- ffd/send.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'ffd/send.c') diff --git a/ffd/send.c b/ffd/send.c index 283b36e..9e36456 100644 --- a/ffd/send.c +++ b/ffd/send.c @@ -176,7 +176,7 @@ static bool add_node_id(ffd_packet_t *packet, size_t max_len, ffd_node_id_t node return true; } -static bool add_update(ffd_packet_t *packet, size_t max_len, ffd_node_id_t *node_id, ffd_announce_t *announce, bool with_data) { +static bool add_update(ffd_packet_t *packet, size_t max_len, ffd_node_id_t *node_id, ffd_announce_t *announce, bool with_data, bool targetted) { if (announce->len && !announce->data) { /* incomplete announce, handle like non-existant announce */ return true; @@ -217,6 +217,9 @@ static bool add_update(ffd_packet_t *packet, size_t max_len, ffd_node_id_t *node if (ffd_is_metric_better(announce->metric, announce->feasibility_distance)) announce->feasibility_distance = announce->metric; + if (!targetted) + announce->last_metric = announce->metric.metric; + return true; } @@ -227,20 +230,20 @@ void ffd_send_update(ffd_iface_t *iface, ffd_neigh_t *neigh, ffd_announce_t *ann packet->len = 0; if (announce) { - add_update(packet, FFD_PACKET_MAX, NULL, announce, with_data); + add_update(packet, FFD_PACKET_MAX, NULL, announce, with_data, iface || neigh); } else { ffd_node_id_t node_id = FFD_NODE_ID_UNSPEC; ffd_announce_t *a; for (a = announce_list; a; a = a->next) { - if (!add_update(packet, FFD_PACKET_MAX, &node_id, a, with_data)) { + if (!add_update(packet, FFD_PACKET_MAX, &node_id, a, with_data, iface || neigh)) { send_any(iface, neigh, packet); node_id = FFD_NODE_ID_UNSPEC; packet->len = 0; - if (!add_update(packet, FFD_PACKET_MAX, &node_id, a, with_data)) { + if (!add_update(packet, FFD_PACKET_MAX, &node_id, a, with_data, iface || neigh)) { fprintf(stderr, "error: add_update failed\n"); return; } -- cgit v1.2.3