diff options
Diffstat (limited to 'ffd/send.c')
-rw-r--r-- | ffd/send.c | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -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; } |