summaryrefslogtreecommitdiffstats
path: root/ffd/ffd.c
diff options
context:
space:
mode:
Diffstat (limited to 'ffd/ffd.c')
-rw-r--r--ffd/ffd.c36
1 files changed, 11 insertions, 25 deletions
diff --git a/ffd/ffd.c b/ffd/ffd.c
index f5b3271..f82932a 100644
--- a/ffd/ffd.c
+++ b/ffd/ffd.c
@@ -198,7 +198,7 @@ static void handle_tlv_ack_req(const ffd_tlv_ack_req_t *tlv_req, size_t len, han
ffd_neigh_t *neigh = get_tlv_neigh(arg);
- ffd_send_ack(arg->iface, neigh, ntohs(tlv_req->nonce));
+ ffd_send_ack(neigh, ntohs(tlv_req->nonce));
}
static void handle_tlv_hello(const ffd_tlv_hello_t *tlv_hello, size_t len, handle_tlv_arg_t *arg) {
@@ -284,24 +284,6 @@ static void handle_tlv_node_id(const ffd_tlv_node_id_t *tlv_node_id, size_t len,
arg->node_id = tlv_node_id->id;
}
-static ffd_announce_t* get_announce(const ffd_node_id_t *node, uint16_t type, uint16_t key) {
- ffd_announce_t *announce;
- for (announce = announce_list; announce; announce = announce->next) {
- if (ffd_are_node_ids_equal(&announce->node, node)
- && announce->type == type
- && announce->key == key)
- return announce;
- }
-
- /* not found */
- announce = ffd_announce_new();
- announce->node = *node;
- announce->type = type;
- announce->key = key;
-
- return announce;
-}
-
static ffd_nexthop_t* find_nexthop(const ffd_announce_t *announce, ffd_neigh_t *neigh) {
ffd_nexthop_t *nexthop;
for (nexthop = announce->nexthop_list; nexthop; nexthop = nexthop->next) {
@@ -342,7 +324,7 @@ static void handle_tlv_update(const ffd_tlv_update_t *tlv_update, size_t len, ha
fprintf(stderr, "debug: update received from %04x%04x.\n", ntohl(*(uint32_t*)arg->node_id.id), ntohl(*(uint32_t*)(arg->node_id.id+4)));
- ffd_announce_t *announce = get_announce(&arg->node_id, ntohs(tlv_update->type), ntohs(tlv_update->key));
+ ffd_announce_t *announce = ffd_announce_get(&arg->node_id, ntohs(tlv_update->type), ntohs(tlv_update->key));
ffd_metric_seqno_t ms = { ntohs(tlv_update->metric), ntohs(tlv_update->seqno) };
bool feasible = ffd_is_feasible(announce, ms);
@@ -387,13 +369,17 @@ static void handle_tlv_announce_req(const ffd_tlv_announce_req_t *tlv_req, size_
return;
}
- ffd_announce_t *announce = NULL;
-
- if (!ffd_is_node_id_unspec(&tlv_req->node)) {
- announce = NULL;
+ 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);
}
+ else {
+ ffd_announce_t *announce = ffd_announce_find(&tlv_req->node, ntohs(tlv_req->type), ntohs(tlv_req->key));
- ffd_send_update(arg->iface, get_tlv_neigh(arg), announce, tlv_req->flags & FFD_UPDATE_WITH_DATA);
+ if (announce)
+ ffd_send_update(NULL, get_tlv_neigh(arg), announce, 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));
+ }
}
static void handle_tlv(ffd_tlv_type_t type, const void *data, size_t len, void *arg) {