summaryrefslogtreecommitdiffstats
path: root/src/tlv_types.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/tlv_types.c')
-rw-r--r--src/tlv_types.c40
1 files changed, 27 insertions, 13 deletions
diff --git a/src/tlv_types.c b/src/tlv_types.c
index bd68642..ddf819f 100644
--- a/src/tlv_types.c
+++ b/src/tlv_types.c
@@ -159,8 +159,22 @@ static void handle_tlv_update(gmrf_context_t *ctx, const gp_babel_tlv_update_t *
return;
}
- gp_babel_route_t *route = gp_babel_route_get(ctx, &tlv->node);
gp_babel_metric_seqno_t ms = { ntohs(tlv->metric), ntohs(tlv->seqno) };
+
+ gp_babel_route_t *route;
+
+ if (ms.metric == GP_BABEL_INFINITY) {
+ route = gp_babel_route_find(ctx, &tlv->node);
+ if (!route) {
+ gmrf_logf(ctx->gmrf, LOG_DEBUG, "retract received for unknown node %04x%04x.",
+ ntohl(*(uint32_t*)tlv->node.id), ntohl(*(uint32_t*)(tlv->node.id+4)));
+ return;
+ }
+ }
+ else {
+ route = gp_babel_route_get(ctx, &tlv->node);
+ }
+
bool feasible = gp_babel_is_feasible(route, ms);
gp_babel_neigh_t *neigh = get_tlv_neigh(arg);
@@ -204,23 +218,23 @@ static void handle_tlv_route_req(gmrf_context_t *ctx, const gp_babel_tlv_route_r
return;
}
- const gp_babel_node_id_t *node = &tlv->node;
- gp_babel_route_t *route = NULL;
gp_babel_neigh_t *neigh = get_tlv_neigh(arg);
- if (gp_babel_node_id_is_unspec(node))
- node = NULL;
+ if (gp_babel_node_id_is_unspec(&tlv->node)) {
+ gmrf_logf(ctx->gmrf, LOG_DEBUG, "received wildcard route request, dumping table.");
+ gp_babel_send_update(ctx, arg->iface, neigh);
+ return;
+ }
- if (node) {
- route = gp_babel_route_find(ctx, &tlv->node);
- if (!route) {
- gmrf_logf(ctx->gmrf, LOG_DEBUG, "received route request for unknown route, retracting.");
- gp_babel_send_retract(ctx, arg->iface, neigh, node);
- return;
- }
+ gp_babel_route_t *route = gp_babel_route_find(ctx, &tlv->node);
+ if (!route) {
+ gmrf_logf(ctx->gmrf, LOG_DEBUG, "received route request for unknown route, retracting.");
+ gp_babel_send_retract(ctx, arg->iface, neigh, &tlv->node);
+ return;
}
- // TODO
+ gmrf_logf(ctx->gmrf, LOG_DEBUG, "received route request, responding.");
+ gp_babel_send_update_for_route(ctx, arg->iface, neigh, route);
}
static void handle_tlv_seqno_req(gmrf_context_t *ctx, const gp_babel_tlv_seqno_req_t *tlv, size_t len, handle_tlv_arg_t *arg) {