From b63b1bef96a3a089c5a95b47161dc620a6f82545 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 3 Aug 2013 03:18:54 +0200 Subject: Add a neighbour packet timeout to prevent new neighbours to be purged right after a route request has been received --- src/tlv_types.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/tlv_types.c') diff --git a/src/tlv_types.c b/src/tlv_types.c index 12b7248..fd96e98 100644 --- a/src/tlv_types.c +++ b/src/tlv_types.c @@ -39,8 +39,10 @@ typedef struct handle_tlv_arg { gp_babel_node_id_t node_id; } handle_tlv_arg_t; -static inline gp_babel_neigh_t* get_tlv_neigh(handle_tlv_arg_t *arg) { - return gp_babel_neigh_get(arg->iface, arg->source); +static inline gp_babel_neigh_t* get_tlv_neigh(gmrf_context_t *ctx, handle_tlv_arg_t *arg) { + gp_babel_neigh_t *neigh = gp_babel_neigh_get(arg->iface, arg->source); + neigh->last_packet = gmrf_now(ctx->gmrf); + return neigh; } static void handle_tlv_ack_req(gmrf_context_t *ctx, const gp_babel_tlv_ack_req_t *tlv, size_t len, handle_tlv_arg_t *arg) { @@ -49,7 +51,7 @@ static void handle_tlv_ack_req(gmrf_context_t *ctx, const gp_babel_tlv_ack_req_t return; } - gp_babel_send_ack(ctx, get_tlv_neigh(arg), ntohs(tlv->nonce)); + gp_babel_send_ack(ctx, get_tlv_neigh(ctx, arg), ntohs(tlv->nonce)); } static void handle_tlv_ack(gmrf_context_t *ctx, const gp_babel_tlv_ack_t *tlv, size_t len, handle_tlv_arg_t *arg) { @@ -72,7 +74,7 @@ static void handle_tlv_hello(gmrf_context_t *ctx, const gp_babel_tlv_hello_t *tl arg->source->d[4], arg->source->d[5], arg->source->d[6], arg->source->d[7], gmrf_iface_get_name(ctx->gmrf, arg->iface->gmrf_iface), ntohs(tlv->seqno)); - gp_babel_neigh_t *neigh = get_tlv_neigh(arg); + gp_babel_neigh_t *neigh = get_tlv_neigh(ctx, arg); uint16_t seqno = ntohs(tlv->seqno); @@ -131,7 +133,7 @@ static void handle_tlv_ihu(gmrf_context_t *ctx, const gp_babel_tlv_ihu_t *tlv, s return; } - gp_babel_neigh_t *neigh = get_tlv_neigh(arg); + gp_babel_neigh_t *neigh = get_tlv_neigh(ctx, arg); neigh->ihu_interval = ntohs(tlv->interval); neigh->last_ihu = gmrf_now(ctx->gmrf); neigh->txcost = ntohs(tlv->rxcost); @@ -177,7 +179,7 @@ static void handle_tlv_update(gmrf_context_t *ctx, const gp_babel_tlv_update_t * bool feasible = gp_babel_is_feasible(route, ms); - gp_babel_neigh_t *neigh = get_tlv_neigh(arg); + gp_babel_neigh_t *neigh = get_tlv_neigh(ctx, arg); gp_babel_nexthop_t *nexthop = gp_babel_route_nexthop_find(route, neigh); gmrf_logf(ctx->gmrf, LOG_DEBUG, "update received from %04x%04x, metric %u, seqno %04x.", @@ -218,7 +220,7 @@ static void handle_tlv_route_req(gmrf_context_t *ctx, const gp_babel_tlv_route_r return; } - gp_babel_neigh_t *neigh = get_tlv_neigh(arg); + gp_babel_neigh_t *neigh = get_tlv_neigh(ctx, arg); if (gp_babel_node_id_is_unspec(&tlv->node)) { gmrf_logf(ctx->gmrf, LOG_DEBUG, "received wildcard route request, dumping table."); @@ -253,7 +255,7 @@ static void handle_tlv_seqno_req(gmrf_context_t *ctx, const gp_babel_tlv_seqno_r ntohl(*(uint32_t*)tlv->node.id), ntohl(*(uint32_t*)(tlv->node.id+4)), ntohs(tlv->seqno)); - gp_babel_neigh_t *neigh = get_tlv_neigh(arg); + gp_babel_neigh_t *neigh = get_tlv_neigh(ctx, arg); if (!gp_babel_less(route->metric.seqno, ntohs(tlv->seqno))) { /* local seqno is high enough */ -- cgit v1.2.3