summaryrefslogtreecommitdiffstats
path: root/ffd/ffd.c
diff options
context:
space:
mode:
Diffstat (limited to 'ffd/ffd.c')
-rw-r--r--ffd/ffd.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/ffd/ffd.c b/ffd/ffd.c
index 9af9598..ee1e3ea 100644
--- a/ffd/ffd.c
+++ b/ffd/ffd.c
@@ -93,7 +93,7 @@ static bool init_self(void) {
self.id[6] = primary_addr.d[4];
self.id[7] = primary_addr.d[5];
- ffd_announce_t *announce = announce_list = calloc(1, sizeof(ffd_announce_t));
+ ffd_announce_t *announce = ffd_announce_new();
announce->node = self;
announce->type = 1;
@@ -222,6 +222,7 @@ static void handle_tlv_hello(const ffd_tlv_hello_t *tlv_hello, size_t len, handl
if (abs((int16_t)(seqno - seqexp)) > 16) {
fprintf(stderr, "info: neighbour was reset.\n");
neigh->hello_log = 0;
+ neigh->txcost = 0xffff;
}
else {
int16_t seqdiff = seqno - neigh->last_seqno;
@@ -376,7 +377,7 @@ static void handle_tlv_update(const ffd_tlv_update_t *tlv_update, size_t len, ha
fprintf(stderr, "debug: the update was accepted.\n");
- ffd_announce_update(announce, nexthop, ms, ntohs(tlv_update->interval));
+ ffd_announce_update_nexthop(announce, nexthop, ms, ntohs(tlv_update->interval));
}
static void handle_tlv_announce_req(const ffd_tlv_announce_req_t *tlv_req, size_t len, handle_tlv_arg_t *arg) {
@@ -482,6 +483,30 @@ static void maintenance(void) {
iface->name, ffd_neigh_get_cost(neigh), ffd_neigh_get_rxcost(neigh), ffd_neigh_get_txcost(neigh));
}
}
+
+ ffd_announce_t *announce;
+ for (announce = announce_list; announce; announce = announce->next) {
+ ffd_announce_update(announce);
+
+ fprintf(stderr, "debug: maintenance: node %04x%04x, type %04x, announce %04x: ", ntohl(*(uint32_t*)announce->node.id), ntohl(*(uint32_t*)(announce->node.id+4)), announce->type, announce->key);
+
+ if (!announce->selected) {
+ fprintf(stderr, "nexthop: none\n");
+ continue;
+ }
+
+ ffd_neigh_t *neigh = announce->selected->neigh;
+
+ if (!neigh) {
+ fprintf(stderr, "local\n");
+ continue;
+ }
+
+ fprintf(stderr, "nexthop: %02x:%02x:%02x:%02x:%02x:%02x (%u, seqno=%04x)\n",
+ neigh->addr.d[0], neigh->addr.d[1], neigh->addr.d[2],
+ neigh->addr.d[3], neigh->addr.d[4], neigh->addr.d[5],
+ announce->metric.metric, announce->metric.seqno);
+ }
}
int main() {