From 3af74a4b534186c966728785a05b0f72dc2b6048 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Tue, 18 Mar 2014 17:56:29 +0100 Subject: Add GMRF debug calls --- src/babel.c | 4 ++++ src/route.c | 10 +++++++++- src/tlv_types.c | 2 ++ 3 files changed, 15 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/babel.c b/src/babel.c index 4a2de19..c8781f8 100644 --- a/src/babel.c +++ b/src/babel.c @@ -68,6 +68,7 @@ static void maintain_neighbours(gmrf_context_t *ctx) { neigh->addr.d[0], neigh->addr.d[1], neigh->addr.d[2], neigh->addr.d[3], neigh->addr.d[4], neigh->addr.d[5], neigh->addr.d[6], neigh->addr.d[7], gmrf_iface_get_name(ctx->gmrf, iface->gmrf_iface), (int)gp_babel_since(ctx, neigh->last_packet)*10); + gmrf_debug_neigh_lost(ctx->gmrf, iface->gmrf_iface, &neigh->addr); *cur = *next; next = cur; @@ -81,6 +82,7 @@ static void maintain_neighbours(gmrf_context_t *ctx) { neigh->addr.d[4], neigh->addr.d[5], neigh->addr.d[6], neigh->addr.d[7], gmrf_iface_get_name(ctx->gmrf, iface->gmrf_iface), gp_babel_neigh_get_cost(ctx, neigh), gp_babel_neigh_get_rxcost(ctx, neigh), gp_babel_neigh_get_txcost(ctx, neigh)); + gmrf_debug_neigh(ctx->gmrf, iface->gmrf_iface, &neigh->addr, gp_babel_neigh_get_rxcost(ctx, neigh), gp_babel_neigh_get_txcost(ctx, neigh)); } } } @@ -147,6 +149,8 @@ gmrf_context_t* gmrf_protocol_init(gmrf_t *gmrf) { ctx->gmrf = gmrf; gmrf_random_bytes(gmrf, &ctx->self, sizeof(gp_babel_node_id_t)); + gmrf_debug_init(gmrf, ctx->self.id, sizeof(gp_babel_node_id_t)); + gp_babel_route_t *route = gp_babel_route_new(ctx); route->node = ctx->self; diff --git a/src/route.c b/src/route.c index f8a16d5..e0cd588 100644 --- a/src/route.c +++ b/src/route.c @@ -179,9 +179,17 @@ void gp_babel_route_update(gmrf_context_t *ctx, gp_babel_route_t *route) { route->selected = select_nexthop(ctx, route); route->metric = get_metric(ctx, route); - if (!route->selected) + if (route->selected) { + if (route->selected->neigh) + gmrf_debug_route(ctx->gmrf, route->node.id, sizeof(gp_babel_node_id_t), route->selected->neigh->iface->gmrf_iface, + &route->selected->neigh->addr, route->metric.metric); + } + else { gp_babel_send_seqno_request_for(ctx, NULL, route); + gmrf_debug_route_lost(ctx->gmrf, route->node.id, sizeof(gp_babel_node_id_t)); + } + /* triggered updates */ int diff = route->metric.metric - route->last_metric; diff --git a/src/tlv_types.c b/src/tlv_types.c index 850acfb..279aaab 100644 --- a/src/tlv_types.c +++ b/src/tlv_types.c @@ -111,6 +111,7 @@ static void handle_tlv_hello(gmrf_context_t *ctx, const gp_babel_tlv_hello_t *tl gp_babel_neigh_reset(ctx, arg->iface, neigh); gmrf_logf(ctx->gmrf, LOG_DEBUG, "accepted hello, log %04x, rxcost is %u, cost is %u now.", neigh->hello_log, gp_babel_neigh_get_rxcost(ctx, neigh), gp_babel_neigh_get_cost(ctx, neigh)); + gmrf_debug_neigh(ctx->gmrf, arg->iface->gmrf_iface, &neigh->addr, gp_babel_neigh_get_rxcost(ctx, neigh), gp_babel_neigh_get_txcost(ctx, neigh)); } static void handle_tlv_ihu(gmrf_context_t *ctx, const gp_babel_tlv_ihu_t *tlv, size_t len, handle_tlv_arg_t *arg) { @@ -139,6 +140,7 @@ static void handle_tlv_ihu(gmrf_context_t *ctx, const gp_babel_tlv_ihu_t *tlv, s neigh->txcost = ntohs(tlv->rxcost); gmrf_logf(ctx->gmrf, LOG_DEBUG, "accepted IHU, txcost is %u, cost is %u now.", gp_babel_neigh_get_txcost(ctx, neigh), gp_babel_neigh_get_cost(ctx, neigh)); + gmrf_debug_neigh(ctx->gmrf, arg->iface->gmrf_iface, &neigh->addr, gp_babel_neigh_get_rxcost(ctx, neigh), gp_babel_neigh_get_txcost(ctx, neigh)); } static void handle_tlv_node_id(gmrf_context_t *ctx, const gp_babel_tlv_node_id_t *tlv, size_t len, handle_tlv_arg_t *arg) { -- cgit v1.2.3