Simplify basic protocol, rename announces to routes, begin implementing route request handling
This commit is contained in:
parent
45a3ff5a4f
commit
f29e37138a
11 changed files with 244 additions and 257 deletions
|
@ -1,9 +1,9 @@
|
||||||
include_directories(${GMRF_INCLUDE_DIR})
|
include_directories(${GMRF_INCLUDE_DIR})
|
||||||
|
|
||||||
add_library(mmss_proto_babel MODULE
|
add_library(mmss_proto_babel MODULE
|
||||||
announce.c
|
|
||||||
babel.c
|
babel.c
|
||||||
neigh.c
|
neigh.c
|
||||||
|
route.c
|
||||||
send.c
|
send.c
|
||||||
tlv.c
|
tlv.c
|
||||||
tlv_types.c
|
tlv_types.c
|
||||||
|
|
38
src/babel.c
38
src/babel.c
|
@ -48,7 +48,7 @@ static void send_updates(gmrf_context_t *ctx, void *arg) {
|
||||||
|
|
||||||
gmrf_iface_state_t *iface;
|
gmrf_iface_state_t *iface;
|
||||||
for (iface = ctx->interfaces; iface; iface = iface->next) {
|
for (iface = ctx->interfaces; iface; iface = iface->next) {
|
||||||
gp_babel_send_update(ctx, iface, NULL, NULL, false);
|
gp_babel_send_update(ctx, iface, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,28 +77,28 @@ static void maintain_neighbours(gmrf_context_t *ctx) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void maintain_announces(gmrf_context_t *ctx) {
|
static void maintain_routes(gmrf_context_t *ctx) {
|
||||||
gp_babel_announce_t **cur, **next;
|
gp_babel_route_t **cur, **next;
|
||||||
for (cur = &ctx->announces; *cur; cur = next) {
|
for (cur = &ctx->routes; *cur; cur = next) {
|
||||||
gp_babel_announce_t *announce = *cur;
|
gp_babel_route_t *route = *cur;
|
||||||
next = &announce->next;
|
next = &route->next;
|
||||||
|
|
||||||
gp_babel_announce_update(ctx, announce);
|
gp_babel_route_update(ctx, route);
|
||||||
|
|
||||||
if (!announce->nexthops) {
|
if (!route->nexthops) {
|
||||||
*cur = *next;
|
*cur = *next;
|
||||||
next = cur;
|
next = cur;
|
||||||
gp_babel_announce_free(ctx, announce);
|
gp_babel_route_free(ctx, route);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
gmrf_logf(ctx->gmrf, LOG_DEBUG, "node %04x%04x, type %04x, announce %04x (%u, seqno=%04x):",
|
gmrf_logf(ctx->gmrf, LOG_DEBUG, "node %04x%04x (%u, seqno=%04x):",
|
||||||
ntohl(*(uint32_t*)announce->node.id), ntohl(*(uint32_t*)(announce->node.id+4)),
|
ntohl(*(uint32_t*)route->node.id), ntohl(*(uint32_t*)(route->node.id+4)),
|
||||||
announce->type, announce->key, announce->metric.metric, announce->metric.seqno);
|
route->metric.metric, route->metric.seqno);
|
||||||
|
|
||||||
gp_babel_nexthop_t *nexthop;
|
gp_babel_nexthop_t *nexthop;
|
||||||
for (nexthop = announce->nexthops; nexthop; nexthop = nexthop->next) {
|
for (nexthop = route->nexthops; nexthop; nexthop = nexthop->next) {
|
||||||
gp_babel_neigh_t *neigh = nexthop->neigh;
|
gp_babel_neigh_t *neigh = nexthop->neigh;
|
||||||
|
|
||||||
if (!neigh) {
|
if (!neigh) {
|
||||||
|
@ -111,7 +111,7 @@ static void maintain_announces(gmrf_context_t *ctx) {
|
||||||
neigh->addr.d[4], neigh->addr.d[5], neigh->addr.d[6], neigh->addr.d[7],
|
neigh->addr.d[4], neigh->addr.d[5], neigh->addr.d[6], neigh->addr.d[7],
|
||||||
neigh->iface ? gmrf_iface_get_name(ctx->gmrf, neigh->iface->gmrf_iface) : NULL,
|
neigh->iface ? gmrf_iface_get_name(ctx->gmrf, neigh->iface->gmrf_iface) : NULL,
|
||||||
nexthop->metric_seqno.metric, nexthop->metric_seqno.seqno, gp_babel_neigh_get_cost(ctx, neigh),
|
nexthop->metric_seqno.metric, nexthop->metric_seqno.seqno, gp_babel_neigh_get_cost(ctx, neigh),
|
||||||
(nexthop == announce->selected) ? ", selected" : "");
|
(nexthop == route->selected) ? ", selected" : "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,7 @@ static void maintenance(gmrf_context_t *ctx, void *arg) {
|
||||||
gmrf_schedule(ctx->gmrf, maintenance, NULL, GP_BABEL_MAINTENANCE_INTERVAL*10);
|
gmrf_schedule(ctx->gmrf, maintenance, NULL, GP_BABEL_MAINTENANCE_INTERVAL*10);
|
||||||
|
|
||||||
maintain_neighbours(ctx);
|
maintain_neighbours(ctx);
|
||||||
maintain_announces(ctx);
|
maintain_routes(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
gmrf_context_t* gmrf_protocol_init(gmrf_t *gmrf) {
|
gmrf_context_t* gmrf_protocol_init(gmrf_t *gmrf) {
|
||||||
|
@ -135,12 +135,10 @@ gmrf_context_t* gmrf_protocol_init(gmrf_t *gmrf) {
|
||||||
ctx->gmrf = gmrf;
|
ctx->gmrf = gmrf;
|
||||||
gmrf_random_bytes(gmrf, &ctx->self, sizeof(gp_babel_node_id_t));
|
gmrf_random_bytes(gmrf, &ctx->self, sizeof(gp_babel_node_id_t));
|
||||||
|
|
||||||
gp_babel_announce_t *announce = gp_babel_announce_new(ctx);
|
gp_babel_route_t *route = gp_babel_route_new(ctx);
|
||||||
announce->node = ctx->self;
|
route->node = ctx->self;
|
||||||
announce->type = 1;
|
|
||||||
announce->key = 1337;
|
|
||||||
|
|
||||||
announce->nexthops = announce->selected = calloc(1, sizeof(gp_babel_nexthop_t));
|
route->nexthops = route->selected = calloc(1, sizeof(gp_babel_nexthop_t));
|
||||||
|
|
||||||
return ctx;
|
return ctx;
|
||||||
}
|
}
|
||||||
|
|
54
src/babel.h
54
src/babel.h
|
@ -50,10 +50,6 @@
|
||||||
#define GP_BABEL_SEQNO_REQ_HOP_LIMIT 127
|
#define GP_BABEL_SEQNO_REQ_HOP_LIMIT 127
|
||||||
|
|
||||||
|
|
||||||
#define GP_BABEL_UPDATE_FLAG_HAS_PAYLOAD 0x01
|
|
||||||
#define GP_BABEL_ANNOUCE_REQ_FLAG_WITH_PAYLOAD 0x01
|
|
||||||
|
|
||||||
|
|
||||||
struct gmrf_context {
|
struct gmrf_context {
|
||||||
gmrf_t *gmrf;
|
gmrf_t *gmrf;
|
||||||
|
|
||||||
|
@ -62,7 +58,7 @@ struct gmrf_context {
|
||||||
gmrf_iface_state_t *interfaces;
|
gmrf_iface_state_t *interfaces;
|
||||||
gp_babel_neigh_t *neighbours;
|
gp_babel_neigh_t *neighbours;
|
||||||
|
|
||||||
gp_babel_announce_t *announces;
|
gp_babel_route_t *routes;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct gmrf_iface_state {
|
struct gmrf_iface_state {
|
||||||
|
@ -94,12 +90,10 @@ struct gp_babel_neigh {
|
||||||
uint16_t txcost;
|
uint16_t txcost;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct gp_babel_announce {
|
struct gp_babel_route {
|
||||||
gp_babel_announce_t *next;
|
gp_babel_route_t *next;
|
||||||
|
|
||||||
gp_babel_node_id_t node;
|
gp_babel_node_id_t node;
|
||||||
uint16_t type;
|
|
||||||
uint16_t key;
|
|
||||||
|
|
||||||
gp_babel_metric_seqno_t metric;
|
gp_babel_metric_seqno_t metric;
|
||||||
uint16_t last_metric;
|
uint16_t last_metric;
|
||||||
|
@ -107,10 +101,6 @@ struct gp_babel_announce {
|
||||||
|
|
||||||
gp_babel_nexthop_t *selected;
|
gp_babel_nexthop_t *selected;
|
||||||
gp_babel_nexthop_t *nexthops;
|
gp_babel_nexthop_t *nexthops;
|
||||||
|
|
||||||
/* an incomplete announcement is specified by a len value of 0xff with NULL payload */
|
|
||||||
uint8_t len;
|
|
||||||
uint8_t *payload;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct gp_babel_nexthop {
|
struct gp_babel_nexthop {
|
||||||
|
@ -130,20 +120,22 @@ void gp_babel_handle_packet(gmrf_context_t *ctx, gmrf_iface_state_t *iface, cons
|
||||||
void gp_babel_send_ack(gmrf_context_t *ctx, gp_babel_neigh_t *neigh, uint16_t nonce);
|
void gp_babel_send_ack(gmrf_context_t *ctx, gp_babel_neigh_t *neigh, uint16_t nonce);
|
||||||
void gp_babel_send_hellos(gmrf_context_t *ctx);
|
void gp_babel_send_hellos(gmrf_context_t *ctx);
|
||||||
|
|
||||||
void gp_babel_send_update(gmrf_context_t *ctx, gmrf_iface_state_t *iface, gp_babel_neigh_t *neigh, gp_babel_announce_t *announce, bool with_payload);
|
void gp_babel_send_update(gmrf_context_t *ctx, gmrf_iface_state_t *iface, gp_babel_neigh_t *neigh);
|
||||||
|
void gp_babel_send_update_for_route(gmrf_context_t *ctx, gmrf_iface_state_t *iface, gp_babel_neigh_t *neigh, gp_babel_route_t *route);
|
||||||
|
void gp_babel_send_retract(gmrf_context_t *ctx, gmrf_iface_state_t *iface, gp_babel_neigh_t *neigh, const gp_babel_node_id_t *node);
|
||||||
|
|
||||||
void gp_babel_send_announce_request(gmrf_context_t *ctx, gmrf_iface_state_t *iface, gp_babel_neigh_t *neigh, const gp_babel_node_id_t *node, uint16_t type, uint16_t key, bool with_payload);
|
void gp_babel_send_route_request(gmrf_context_t *ctx, gmrf_iface_state_t *iface, gp_babel_neigh_t *neigh, const gp_babel_node_id_t *node);
|
||||||
void gp_babel_send_seqno_request(gmrf_context_t *ctx, gp_babel_neigh_t *neigh, gp_babel_announce_t *announce, uint16_t seqno, uint8_t hop_count);
|
void gp_babel_send_seqno_request(gmrf_context_t *ctx, gp_babel_neigh_t *neigh, gp_babel_route_t *route, uint16_t seqno, uint8_t hop_count);
|
||||||
|
|
||||||
gp_babel_announce_t* gp_babel_announce_new(gmrf_context_t *ctx);
|
gp_babel_route_t* gp_babel_route_new(gmrf_context_t *ctx);
|
||||||
gp_babel_announce_t* gp_babel_announce_find(gmrf_context_t *ctx, const gp_babel_node_id_t *node, uint16_t type, uint16_t key);
|
gp_babel_route_t* gp_babel_route_find(gmrf_context_t *ctx, const gp_babel_node_id_t *node);
|
||||||
gp_babel_announce_t* gp_babel_announce_get(gmrf_context_t *ctx, const gp_babel_node_id_t *node, uint16_t type, uint16_t key);
|
gp_babel_route_t* gp_babel_route_get(gmrf_context_t *ctx, const gp_babel_node_id_t *node);
|
||||||
void gp_babel_announce_update(gmrf_context_t *ctx, gp_babel_announce_t *announce);
|
void gp_babel_route_update(gmrf_context_t *ctx, gp_babel_route_t *route);
|
||||||
void gp_babel_announce_free(gmrf_context_t *ctx, gp_babel_announce_t *announce);
|
void gp_babel_route_free(gmrf_context_t *ctx, gp_babel_route_t *route);
|
||||||
|
|
||||||
gp_babel_nexthop_t* gp_babel_announce_nexthop_new(gp_babel_announce_t *announce, gp_babel_neigh_t *neigh);
|
gp_babel_nexthop_t* gp_babel_route_nexthop_new(gp_babel_route_t *route, gp_babel_neigh_t *neigh);
|
||||||
gp_babel_nexthop_t* gp_babel_announce_nexthop_find(const gp_babel_announce_t *announce, gp_babel_neigh_t *neigh);
|
gp_babel_nexthop_t* gp_babel_route_nexthop_find(const gp_babel_route_t *route, gp_babel_neigh_t *neigh);
|
||||||
void gp_babel_announce_update_nexthop(gmrf_context_t *ctx, gp_babel_announce_t *announce, gp_babel_nexthop_t *nexthop, gp_babel_metric_seqno_t ms, uint16_t interval);
|
void gp_babel_route_update_nexthop(gmrf_context_t *ctx, gp_babel_route_t *route, gp_babel_nexthop_t *nexthop, gp_babel_metric_seqno_t ms, uint16_t interval);
|
||||||
|
|
||||||
|
|
||||||
static inline bool gp_babel_node_id_equal(const gp_babel_node_id_t *id1, const gp_babel_node_id_t *id2) {
|
static inline bool gp_babel_node_id_equal(const gp_babel_node_id_t *id1, const gp_babel_node_id_t *id2) {
|
||||||
|
@ -177,18 +169,22 @@ static inline bool gp_babel_is_metric_better(gp_babel_metric_seqno_t ms1, gp_bab
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool gp_babel_is_feasible(const gp_babel_announce_t *announce, gp_babel_metric_seqno_t ms) {
|
static inline bool gp_babel_route_is_reachable(const gp_babel_route_t *route) {
|
||||||
|
return (route->metric.metric != GP_BABEL_INFINITY);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline bool gp_babel_is_feasible(const gp_babel_route_t *route, gp_babel_metric_seqno_t ms) {
|
||||||
if (ms.metric == GP_BABEL_INFINITY)
|
if (ms.metric == GP_BABEL_INFINITY)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return gp_babel_is_metric_better(ms, announce->feasibility_distance);
|
return gp_babel_is_metric_better(ms, route->feasibility_distance);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void gp_babel_send_seqno_request_for(gmrf_context_t *ctx, gp_babel_neigh_t *neigh, gp_babel_announce_t *announce) {
|
static inline void gp_babel_send_seqno_request_for(gmrf_context_t *ctx, gp_babel_neigh_t *neigh, gp_babel_route_t *route) {
|
||||||
if (announce->feasibility_distance.metric == GP_BABEL_INFINITY)
|
if (route->feasibility_distance.metric == GP_BABEL_INFINITY)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
gp_babel_send_seqno_request(ctx, neigh, announce, announce->feasibility_distance.seqno+1, GP_BABEL_SEQNO_REQ_HOP_LIMIT);
|
gp_babel_send_seqno_request(ctx, neigh, route, route->feasibility_distance.seqno+1, GP_BABEL_SEQNO_REQ_HOP_LIMIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* _GMRF_PROTO_BABEL_BABEL_H_ */
|
#endif /* _GMRF_PROTO_BABEL_BABEL_H_ */
|
||||||
|
|
|
@ -105,6 +105,6 @@ uint16_t gp_babel_neigh_get_cost(gmrf_context_t *ctx, const gp_babel_neigh_t *ne
|
||||||
return cost;
|
return cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gp_babel_neigh_reset(gmrf_iface_state_t *iface, gp_babel_neigh_t *neigh) {
|
void gp_babel_neigh_reset(gmrf_context_t *ctx, gmrf_iface_state_t *iface, gp_babel_neigh_t *neigh) {
|
||||||
//gp_babel_send_announce_request(iface, neigh, GMRF_PROTO_BABEL_NODE_ID_UNSPEC, 0, 0, true /* XXX change this later */);
|
gp_babel_send_route_request(ctx, iface, neigh, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,6 +52,6 @@ void gp_babel_neigh_unref_list(gp_babel_neigh_t *neigh);
|
||||||
uint16_t gp_babel_neigh_get_rxcost(gmrf_context_t *ctx, const gp_babel_neigh_t *neigh);
|
uint16_t gp_babel_neigh_get_rxcost(gmrf_context_t *ctx, const gp_babel_neigh_t *neigh);
|
||||||
uint16_t gp_babel_neigh_get_txcost(gmrf_context_t *ctx, const gp_babel_neigh_t *neigh);
|
uint16_t gp_babel_neigh_get_txcost(gmrf_context_t *ctx, const gp_babel_neigh_t *neigh);
|
||||||
uint16_t gp_babel_neigh_get_cost(gmrf_context_t *ctx, const gp_babel_neigh_t *neigh);
|
uint16_t gp_babel_neigh_get_cost(gmrf_context_t *ctx, const gp_babel_neigh_t *neigh);
|
||||||
void gp_babel_neigh_reset(gmrf_iface_state_t *iface, gp_babel_neigh_t *neigh);
|
void gp_babel_neigh_reset(gmrf_context_t *ctx, gmrf_iface_state_t *iface, gp_babel_neigh_t *neigh);
|
||||||
|
|
||||||
#endif /* _GMRF_PROTO_BABEL_NEIGH_H_ */
|
#endif /* _GMRF_PROTO_BABEL_NEIGH_H_ */
|
||||||
|
|
|
@ -30,49 +30,45 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
gp_babel_announce_t* gp_babel_announce_new(gmrf_context_t *ctx) {
|
gp_babel_route_t* gp_babel_route_new(gmrf_context_t *ctx) {
|
||||||
gp_babel_announce_t *a = calloc(1, sizeof(gp_babel_announce_t));
|
gp_babel_route_t *a = calloc(1, sizeof(gp_babel_route_t));
|
||||||
|
|
||||||
a->metric.metric = a->feasibility_distance.metric = a->last_metric = GP_BABEL_INFINITY;
|
a->metric.metric = a->feasibility_distance.metric = a->last_metric = GP_BABEL_INFINITY;
|
||||||
|
|
||||||
a->next = ctx->announces;
|
a->next = ctx->routes;
|
||||||
ctx->announces = a;
|
ctx->routes = a;
|
||||||
|
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
gp_babel_announce_t* gp_babel_announce_find(gmrf_context_t *ctx, const gp_babel_node_id_t *node, uint16_t type, uint16_t key) {
|
gp_babel_route_t* gp_babel_route_find(gmrf_context_t *ctx, const gp_babel_node_id_t *node) {
|
||||||
gp_babel_announce_t *announce;
|
gp_babel_route_t *route;
|
||||||
for (announce = ctx->announces; announce; announce = announce->next) {
|
for (route = ctx->routes; route; route = route->next) {
|
||||||
if (gp_babel_node_id_equal(&announce->node, node)
|
if (gp_babel_node_id_equal(&route->node, node))
|
||||||
&& announce->type == type
|
return route;
|
||||||
&& announce->key == key)
|
|
||||||
return announce;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
gp_babel_announce_t* gp_babel_announce_get(gmrf_context_t *ctx, const gp_babel_node_id_t *node, uint16_t type, uint16_t key) {
|
gp_babel_route_t* gp_babel_route_get(gmrf_context_t *ctx, const gp_babel_node_id_t *node) {
|
||||||
gp_babel_announce_t *announce = gp_babel_announce_find(ctx, node, type, key);
|
gp_babel_route_t *route = gp_babel_route_find(ctx, node);
|
||||||
|
|
||||||
if (!announce) {
|
if (!route) {
|
||||||
announce = gp_babel_announce_new(ctx);
|
route = gp_babel_route_new(ctx);
|
||||||
announce->node = *node;
|
route->node = *node;
|
||||||
announce->type = type;
|
|
||||||
announce->key = key;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return announce;
|
return route;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gp_babel_announce_free(gmrf_context_t *ctx, gp_babel_announce_t *announce) {
|
void gp_babel_route_free(gmrf_context_t *ctx, gp_babel_route_t *route) {
|
||||||
free(announce);
|
free(route);
|
||||||
}
|
}
|
||||||
|
|
||||||
gp_babel_nexthop_t* gp_babel_announce_nexthop_find(const gp_babel_announce_t *announce, gp_babel_neigh_t *neigh) {
|
gp_babel_nexthop_t* gp_babel_route_nexthop_find(const gp_babel_route_t *route, gp_babel_neigh_t *neigh) {
|
||||||
gp_babel_nexthop_t *nexthop;
|
gp_babel_nexthop_t *nexthop;
|
||||||
for (nexthop = announce->nexthops; nexthop; nexthop = nexthop->next) {
|
for (nexthop = route->nexthops; nexthop; nexthop = nexthop->next) {
|
||||||
if (nexthop->neigh == neigh)
|
if (nexthop->neigh == neigh)
|
||||||
return nexthop;
|
return nexthop;
|
||||||
}
|
}
|
||||||
|
@ -80,21 +76,21 @@ gp_babel_nexthop_t* gp_babel_announce_nexthop_find(const gp_babel_announce_t *an
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
gp_babel_nexthop_t* gp_babel_announce_nexthop_new(gp_babel_announce_t *announce, gp_babel_neigh_t *neigh) {
|
gp_babel_nexthop_t* gp_babel_route_nexthop_new(gp_babel_route_t *route, gp_babel_neigh_t *neigh) {
|
||||||
gp_babel_nexthop_t *nexthop = calloc(1, sizeof(gp_babel_nexthop_t));
|
gp_babel_nexthop_t *nexthop = calloc(1, sizeof(gp_babel_nexthop_t));
|
||||||
nexthop->neigh = neigh;
|
nexthop->neigh = neigh;
|
||||||
|
|
||||||
nexthop->next = announce->nexthops;
|
nexthop->next = route->nexthops;
|
||||||
announce->nexthops = nexthop;
|
route->nexthops = nexthop;
|
||||||
|
|
||||||
gp_babel_neigh_ref(neigh);
|
gp_babel_neigh_ref(neigh);
|
||||||
|
|
||||||
return nexthop;
|
return nexthop;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void maintain_nexthops(gmrf_context_t *ctx, gp_babel_announce_t *announce) {
|
static void maintain_nexthops(gmrf_context_t *ctx, gp_babel_route_t *route) {
|
||||||
gp_babel_nexthop_t **cur, **next;
|
gp_babel_nexthop_t **cur, **next;
|
||||||
for (cur = &announce->nexthops; *cur; cur = next) {
|
for (cur = &route->nexthops; *cur; cur = next) {
|
||||||
gp_babel_nexthop_t *nexthop = *cur;
|
gp_babel_nexthop_t *nexthop = *cur;
|
||||||
next = &nexthop->next;
|
next = &nexthop->next;
|
||||||
|
|
||||||
|
@ -116,8 +112,8 @@ static void maintain_nexthops(gmrf_context_t *ctx, gp_babel_announce_t *announce
|
||||||
*cur = *next;
|
*cur = *next;
|
||||||
next = cur;
|
next = cur;
|
||||||
|
|
||||||
if (announce->selected == nexthop)
|
if (route->selected == nexthop)
|
||||||
announce->selected = NULL;
|
route->selected = NULL;
|
||||||
|
|
||||||
gp_babel_neigh_unref(nexthop->neigh);
|
gp_babel_neigh_unref(nexthop->neigh);
|
||||||
|
|
||||||
|
@ -128,26 +124,26 @@ static void maintain_nexthops(gmrf_context_t *ctx, gp_babel_announce_t *announce
|
||||||
nexthop->last_update += GP_BABEL_UPDATE_TIMEOUT(nexthop->interval)*10;
|
nexthop->last_update += GP_BABEL_UPDATE_TIMEOUT(nexthop->interval)*10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (gmrf_now(ctx->gmrf) > nexthop->last_update+GP_BABEL_UPDATE_REQUEST_TIMEOUT(nexthop->interval)*10 && announce->selected == nexthop) {
|
else if (gmrf_now(ctx->gmrf) > nexthop->last_update+GP_BABEL_UPDATE_REQUEST_TIMEOUT(nexthop->interval)*10 && route->selected == nexthop) {
|
||||||
if (!nexthop->requested_update) {
|
if (!nexthop->requested_update) {
|
||||||
gmrf_logf(ctx->gmrf, LOG_INFO, "announce about to expire, requesting update");
|
gmrf_logf(ctx->gmrf, LOG_INFO, "route about to expire, requesting update");
|
||||||
gp_babel_send_announce_request(ctx, NULL, nexthop->neigh, &announce->node, announce->type, announce->key, false);
|
gp_babel_send_route_request(ctx, NULL, nexthop->neigh, &route->node);
|
||||||
nexthop->requested_update = true;
|
nexthop->requested_update = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static gp_babel_nexthop_t* select_nexthop(gmrf_context_t *ctx, const gp_babel_announce_t *announce) {
|
static gp_babel_nexthop_t* select_nexthop(gmrf_context_t *ctx, const gp_babel_route_t *route) {
|
||||||
uint16_t ret_metric = GP_BABEL_INFINITY;
|
uint16_t ret_metric = GP_BABEL_INFINITY;
|
||||||
gp_babel_nexthop_t *ret = NULL;
|
gp_babel_nexthop_t *ret = NULL;
|
||||||
|
|
||||||
gp_babel_nexthop_t *nexthop;
|
gp_babel_nexthop_t *nexthop;
|
||||||
for (nexthop = announce->nexthops; nexthop; nexthop = nexthop->next) {
|
for (nexthop = route->nexthops; nexthop; nexthop = nexthop->next) {
|
||||||
if (!nexthop->neigh) /* local */
|
if (!nexthop->neigh) /* local */
|
||||||
return nexthop;
|
return nexthop;
|
||||||
|
|
||||||
if (!gp_babel_is_feasible(announce, nexthop->metric_seqno))
|
if (!gp_babel_is_feasible(route, nexthop->metric_seqno))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
uint32_t metric = nexthop->metric_seqno.metric + gp_babel_neigh_get_cost(ctx, nexthop->neigh);
|
uint32_t metric = nexthop->metric_seqno.metric + gp_babel_neigh_get_cost(ctx, nexthop->neigh);
|
||||||
|
@ -161,37 +157,37 @@ static gp_babel_nexthop_t* select_nexthop(gmrf_context_t *ctx, const gp_babel_an
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
gp_babel_metric_seqno_t get_metric(gmrf_context_t *ctx, const gp_babel_announce_t *announce) {
|
gp_babel_metric_seqno_t get_metric(gmrf_context_t *ctx, const gp_babel_route_t *route) {
|
||||||
if (announce->selected) {
|
if (route->selected) {
|
||||||
uint32_t metric = announce->selected->metric_seqno.metric + gp_babel_neigh_get_cost(ctx, announce->selected->neigh);
|
uint32_t metric = route->selected->metric_seqno.metric + gp_babel_neigh_get_cost(ctx, route->selected->neigh);
|
||||||
|
|
||||||
if (metric < GP_BABEL_INFINITY)
|
if (metric < GP_BABEL_INFINITY)
|
||||||
return (gp_babel_metric_seqno_t){metric, announce->selected->metric_seqno.seqno};
|
return (gp_babel_metric_seqno_t){metric, route->selected->metric_seqno.seqno};
|
||||||
}
|
}
|
||||||
|
|
||||||
return (gp_babel_metric_seqno_t){GP_BABEL_INFINITY, 0};
|
return (gp_babel_metric_seqno_t){GP_BABEL_INFINITY, 0};
|
||||||
}
|
}
|
||||||
|
|
||||||
void gp_babel_announce_update(gmrf_context_t *ctx, gp_babel_announce_t *announce) {
|
void gp_babel_route_update(gmrf_context_t *ctx, gp_babel_route_t *route) {
|
||||||
maintain_nexthops(ctx, announce);
|
maintain_nexthops(ctx, route);
|
||||||
|
|
||||||
announce->selected = select_nexthop(ctx, announce);
|
route->selected = select_nexthop(ctx, route);
|
||||||
announce->metric = get_metric(ctx, announce);
|
route->metric = get_metric(ctx, route);
|
||||||
|
|
||||||
if (!announce->selected)
|
if (!route->selected)
|
||||||
gp_babel_send_seqno_request_for(ctx, NULL, announce);
|
gp_babel_send_seqno_request_for(ctx, NULL, route);
|
||||||
|
|
||||||
/* triggered updates */
|
/* triggered updates */
|
||||||
/*int diff = announce->metric.metric - announce->last_metric;
|
/*int diff = route->metric.metric - route->last_metric;
|
||||||
|
|
||||||
if (((announce->last_metric == GP_BABEL_INFINITY) != (announce->metric.metric == GP_BABEL_INFINITY))
|
if (((route->last_metric == GP_BABEL_INFINITY) != (route->metric.metric == GP_BABEL_INFINITY))
|
||||||
|| diff <= -1024 || diff >= 384) {
|
|| diff <= -1024 || diff >= 384) {
|
||||||
gmrf_logf(gmrf, LOG_INFO, "announce metric has changed significantly, sending updates");
|
gmrf_logf(gmrf, LOG_INFO, "route metric has changed significantly, sending updates");
|
||||||
gp_babel_update_enqueue(&announce->node, announce->type, announce->key, NULL, announce->metric.metric == GP_BABEL_INFINITY);
|
gp_babel_update_enqueue(&route->node, route->type, route->key, NULL, route->metric.metric == GP_BABEL_INFINITY);
|
||||||
} */
|
} */
|
||||||
}
|
}
|
||||||
|
|
||||||
void gp_babel_announce_update_nexthop(gmrf_context_t *ctx, gp_babel_announce_t *announce, gp_babel_nexthop_t *nexthop, gp_babel_metric_seqno_t ms, uint16_t interval) {
|
void gp_babel_route_update_nexthop(gmrf_context_t *ctx, gp_babel_route_t *route, gp_babel_nexthop_t *nexthop, gp_babel_metric_seqno_t ms, uint16_t interval) {
|
||||||
nexthop->metric_seqno = ms;
|
nexthop->metric_seqno = ms;
|
||||||
nexthop->interval = interval;
|
nexthop->interval = interval;
|
||||||
nexthop->requested_update = false;
|
nexthop->requested_update = false;
|
||||||
|
@ -199,5 +195,5 @@ void gp_babel_announce_update_nexthop(gmrf_context_t *ctx, gp_babel_announce_t *
|
||||||
if (ms.metric != GP_BABEL_INFINITY)
|
if (ms.metric != GP_BABEL_INFINITY)
|
||||||
nexthop->last_update = gmrf_now(ctx->gmrf);
|
nexthop->last_update = gmrf_now(ctx->gmrf);
|
||||||
|
|
||||||
gp_babel_announce_update(ctx, announce);
|
gp_babel_route_update(ctx, route);
|
||||||
}
|
}
|
141
src/send.c
141
src/send.c
|
@ -30,6 +30,8 @@
|
||||||
#include "tlv.h"
|
#include "tlv.h"
|
||||||
#include "tlv_types.h"
|
#include "tlv_types.h"
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
|
||||||
static inline bool send_neigh(gmrf_context_t *ctx, const gp_babel_neigh_t *neigh, const gp_babel_packet_t *packet) {
|
static inline bool send_neigh(gmrf_context_t *ctx, const gp_babel_neigh_t *neigh, const gp_babel_packet_t *packet) {
|
||||||
if (!neigh->iface)
|
if (!neigh->iface)
|
||||||
|
@ -111,7 +113,7 @@ void gp_babel_send_hellos(gmrf_context_t *ctx) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool add_node_id(gp_babel_packet_buf_t *buf, const gp_babel_node_id_t *node_id) {
|
/*static inline bool add_node_id_tlv(gp_babel_packet_buf_t *buf, const gp_babel_node_id_t *node_id) {
|
||||||
gp_babel_tlv_node_id_t *tlv = gp_babel_tlv_add(buf, TLV_NODE_ID, sizeof(gp_babel_tlv_node_id_t));
|
gp_babel_tlv_node_id_t *tlv = gp_babel_tlv_add(buf, TLV_NODE_ID, sizeof(gp_babel_tlv_node_id_t));
|
||||||
if (!tlv)
|
if (!tlv)
|
||||||
return false;
|
return false;
|
||||||
|
@ -119,81 +121,56 @@ static inline bool add_node_id(gp_babel_packet_buf_t *buf, const gp_babel_node_i
|
||||||
tlv->id = *node_id;
|
tlv->id = *node_id;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
static bool add_update(gp_babel_packet_buf_t *buf, gp_babel_node_id_t *node_id, gp_babel_announce_t *announce, bool with_payload, bool targetted) {
|
static gp_babel_tlv_update_t* add_update_tlv(gp_babel_packet_buf_t *buf, const gp_babel_node_id_t *node, gp_babel_metric_seqno_t ms) {
|
||||||
if (announce->len && !announce->payload) {
|
gp_babel_tlv_update_t *update = gp_babel_tlv_add(buf, TLV_UPDATE, sizeof(gp_babel_tlv_update_t));
|
||||||
/* incomplete announce, handle like non-existent announce */
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t len = buf->packet.len;
|
if (!update)
|
||||||
|
return NULL;
|
||||||
if (!node_id || !gp_babel_node_id_equal(node_id, &announce->node)) {
|
|
||||||
if (!add_node_id(buf, &announce->node))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (node_id)
|
|
||||||
*node_id = announce->node;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t payload_len = (with_payload && announce->metric.metric != GP_BABEL_INFINITY) ? announce->len : 0;
|
|
||||||
gp_babel_tlv_update_t *update = gp_babel_tlv_add(buf, TLV_UPDATE, sizeof(gp_babel_tlv_update_t)+payload_len);
|
|
||||||
if (!update) {
|
|
||||||
/* reset length to remove possibly added node ID record */
|
|
||||||
buf->packet.len = len;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
update->flags = 0;
|
update->flags = 0;
|
||||||
update->reserved = 0;
|
update->reserved = 0;
|
||||||
update->interval = htons(GP_BABEL_UPDATE_INTERVAL);
|
update->interval = htons(GP_BABEL_UPDATE_INTERVAL);
|
||||||
update->seqno = htons(announce->metric.seqno);
|
update->seqno = htons(ms.seqno);
|
||||||
update->metric = htons(announce->metric.metric);
|
update->metric = htons(ms.metric);
|
||||||
update->type = htons(announce->type);
|
update->node = *node;
|
||||||
update->key = htons(announce->key);
|
|
||||||
|
|
||||||
if (announce->metric.metric != GP_BABEL_INFINITY && announce->len) {
|
return update;
|
||||||
update->flags |= GP_BABEL_UPDATE_FLAG_HAS_PAYLOAD;
|
}
|
||||||
|
|
||||||
if (payload_len)
|
static gp_babel_tlv_update_t* add_retract_tlv(gp_babel_packet_buf_t *buf, const gp_babel_node_id_t *node) {
|
||||||
memcpy(update->payload, announce->payload, payload_len);
|
return add_update_tlv(buf, node, (gp_babel_metric_seqno_t){GP_BABEL_INFINITY, 0});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gp_babel_is_metric_better(announce->metric, announce->feasibility_distance))
|
static bool add_update(gp_babel_packet_buf_t *buf, gp_babel_route_t *route, bool targetted) {
|
||||||
announce->feasibility_distance = announce->metric;
|
gp_babel_tlv_update_t *update = add_update_tlv(buf, &route->node, route->metric);
|
||||||
|
if (!update)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (gp_babel_is_metric_better(route->metric, route->feasibility_distance))
|
||||||
|
route->feasibility_distance = route->metric;
|
||||||
|
|
||||||
if (!targetted)
|
if (!targetted)
|
||||||
announce->last_metric = announce->metric.metric;
|
route->last_metric = route->metric.metric;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gp_babel_send_update(gmrf_context_t *ctx, gmrf_iface_state_t *iface, gp_babel_neigh_t *neigh, gp_babel_announce_t *announce, bool with_payload) {
|
void gp_babel_send_update(gmrf_context_t *ctx, gmrf_iface_state_t *iface, gp_babel_neigh_t *neigh) {
|
||||||
gp_babel_packet_buf_t *buf = gp_babel_packet_alloca(GP_BABEL_PACKET_MAX);
|
gp_babel_packet_buf_t *buf = gp_babel_packet_alloca(GP_BABEL_PACKET_MAX);
|
||||||
|
|
||||||
if (announce) {
|
gp_babel_route_t *a;
|
||||||
add_update(buf, NULL, announce, with_payload, neigh);
|
for (a = ctx->routes; a; a = a->next) {
|
||||||
}
|
if (!add_update(buf, a, neigh)) {
|
||||||
else {
|
if (neigh)
|
||||||
gp_babel_node_id_t node_id = gp_babel_node_id_unspec;
|
send_neigh(ctx, neigh, &buf->packet);
|
||||||
|
else
|
||||||
|
send_iface(ctx, iface, &buf->packet);
|
||||||
|
|
||||||
gp_babel_announce_t *a;
|
buf->packet.len = 0;
|
||||||
for (a = ctx->announces; a; a = a->next) {
|
|
||||||
if (!add_update(buf, &node_id, a, with_payload, neigh)) {
|
|
||||||
if (neigh)
|
|
||||||
send_neigh(ctx, neigh, &buf->packet);
|
|
||||||
else
|
|
||||||
send_iface(ctx, iface, &buf->packet);
|
|
||||||
|
|
||||||
node_id = gp_babel_node_id_unspec;
|
assert(add_update(buf, a, neigh));
|
||||||
buf->packet.len = 0;
|
|
||||||
|
|
||||||
if (!add_update(buf, &node_id, a, with_payload, neigh)) {
|
|
||||||
gmrf_logf(ctx->gmrf, LOG_ERR, "add_update failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,21 +182,10 @@ void gp_babel_send_update(gmrf_context_t *ctx, gmrf_iface_state_t *iface, gp_bab
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gp_babel_send_announce_request(gmrf_context_t *ctx, gmrf_iface_state_t *iface, gp_babel_neigh_t *neigh, const gp_babel_node_id_t *node, uint16_t type, uint16_t key, bool with_payload) {
|
void gp_babel_send_update_for_route(gmrf_context_t *ctx, gmrf_iface_state_t *iface, gp_babel_neigh_t *neigh, gp_babel_route_t *route) {
|
||||||
gp_babel_packet_buf_t *buf = gp_babel_packet_alloca(GP_BABEL_PACKET_MAX);
|
gp_babel_packet_buf_t *buf = gp_babel_packet_alloca(GP_BABEL_PACKET_MAX);
|
||||||
|
|
||||||
gp_babel_tlv_announce_req_t *req = gp_babel_tlv_add(buf, TLV_ANNOUNCE_REQ, sizeof(gp_babel_tlv_announce_req_t));
|
assert(add_update(buf, route, neigh));
|
||||||
if (!req)
|
|
||||||
return;
|
|
||||||
|
|
||||||
req->node = *node;
|
|
||||||
req->flags = 0;
|
|
||||||
req->reserved = 0;
|
|
||||||
req->type = htons(type);
|
|
||||||
req->key = htons(key);
|
|
||||||
|
|
||||||
if (with_payload)
|
|
||||||
req->flags |= GP_BABEL_ANNOUCE_REQ_FLAG_WITH_PAYLOAD;
|
|
||||||
|
|
||||||
if (neigh)
|
if (neigh)
|
||||||
send_neigh(ctx, neigh, &buf->packet);
|
send_neigh(ctx, neigh, &buf->packet);
|
||||||
|
@ -227,7 +193,36 @@ void gp_babel_send_announce_request(gmrf_context_t *ctx, gmrf_iface_state_t *ifa
|
||||||
send_iface(ctx, iface, &buf->packet);
|
send_iface(ctx, iface, &buf->packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gp_babel_send_seqno_request(gmrf_context_t *ctx, gp_babel_neigh_t *neigh, gp_babel_announce_t *announce, uint16_t seqno, uint8_t hop_count) {
|
void gp_babel_send_retract(gmrf_context_t *ctx, gmrf_iface_state_t *iface, gp_babel_neigh_t *neigh, const gp_babel_node_id_t *node) {
|
||||||
|
gp_babel_packet_buf_t *buf = gp_babel_packet_alloca(GP_BABEL_PACKET_MAX);
|
||||||
|
|
||||||
|
assert(add_retract_tlv(buf, node));
|
||||||
|
|
||||||
|
if (neigh)
|
||||||
|
send_neigh(ctx, neigh, &buf->packet);
|
||||||
|
else
|
||||||
|
send_iface(ctx, iface, &buf->packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
void gp_babel_send_route_request(gmrf_context_t *ctx, gmrf_iface_state_t *iface, gp_babel_neigh_t *neigh, const gp_babel_node_id_t *node) {
|
||||||
|
gp_babel_packet_buf_t *buf = gp_babel_packet_alloca(GP_BABEL_PACKET_MAX);
|
||||||
|
|
||||||
|
gp_babel_tlv_route_req_t *req = gp_babel_tlv_add(buf, TLV_ROUTE_REQ, sizeof(gp_babel_tlv_route_req_t));
|
||||||
|
if (!req)
|
||||||
|
return;
|
||||||
|
|
||||||
|
req->node = node ? (*node) : (gp_babel_node_id_t){};
|
||||||
|
|
||||||
|
req->flags = 0;
|
||||||
|
req->reserved = 0;
|
||||||
|
|
||||||
|
if (neigh)
|
||||||
|
send_neigh(ctx, neigh, &buf->packet);
|
||||||
|
else
|
||||||
|
send_iface(ctx, iface, &buf->packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
void gp_babel_send_seqno_request(gmrf_context_t *ctx, gp_babel_neigh_t *neigh, gp_babel_route_t *route, uint16_t seqno, uint8_t hop_count) {
|
||||||
gp_babel_packet_buf_t *buf = gp_babel_packet_alloca(GP_BABEL_PACKET_MAX);
|
gp_babel_packet_buf_t *buf = gp_babel_packet_alloca(GP_BABEL_PACKET_MAX);
|
||||||
|
|
||||||
gp_babel_tlv_seqno_req_t *req = gp_babel_tlv_add(buf, TLV_SEQNO_REQ, sizeof(gp_babel_tlv_seqno_req_t));
|
gp_babel_tlv_seqno_req_t *req = gp_babel_tlv_add(buf, TLV_SEQNO_REQ, sizeof(gp_babel_tlv_seqno_req_t));
|
||||||
|
@ -237,9 +232,7 @@ void gp_babel_send_seqno_request(gmrf_context_t *ctx, gp_babel_neigh_t *neigh, g
|
||||||
req->seqno = htons(seqno);
|
req->seqno = htons(seqno);
|
||||||
req->hop_count = hop_count;
|
req->hop_count = hop_count;
|
||||||
req->reserved = 0;
|
req->reserved = 0;
|
||||||
req->node = announce->node;
|
req->node = route->node;
|
||||||
req->type = htons(announce->type);
|
|
||||||
req->key = htons(announce->key);
|
|
||||||
|
|
||||||
if (neigh)
|
if (neigh)
|
||||||
send_neigh(ctx, neigh, &buf->packet);
|
send_neigh(ctx, neigh, &buf->packet);
|
||||||
|
|
|
@ -40,7 +40,7 @@ typedef enum gp_babel_tlv_type {
|
||||||
TLV_NODE_ID,
|
TLV_NODE_ID,
|
||||||
TLV_RESERVED,
|
TLV_RESERVED,
|
||||||
TLV_UPDATE,
|
TLV_UPDATE,
|
||||||
TLV_ANNOUNCE_REQ,
|
TLV_ROUTE_REQ,
|
||||||
TLV_SEQNO_REQ,
|
TLV_SEQNO_REQ,
|
||||||
} gp_babel_tlv_type_t;
|
} gp_babel_tlv_type_t;
|
||||||
|
|
||||||
|
|
143
src/tlv_types.c
143
src/tlv_types.c
|
@ -43,25 +43,25 @@ static inline gp_babel_neigh_t* get_tlv_neigh(handle_tlv_arg_t *arg) {
|
||||||
return gp_babel_neigh_get(arg->iface, arg->source);
|
return gp_babel_neigh_get(arg->iface, arg->source);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_tlv_ack_req(gmrf_context_t *ctx, const gp_babel_tlv_ack_req_t *tlv_req, size_t len, handle_tlv_arg_t *arg) {
|
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) {
|
||||||
if (len < sizeof(gp_babel_tlv_ack_req_t)) {
|
if (len < sizeof(gp_babel_tlv_ack_req_t)) {
|
||||||
gmrf_logf(ctx->gmrf, LOG_WARNING, "received short acknowledement request TLV.");
|
gmrf_logf(ctx->gmrf, LOG_WARNING, "received short acknowledement request TLV.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gp_babel_send_ack(ctx, get_tlv_neigh(arg), ntohs(tlv_req->nonce));
|
gp_babel_send_ack(ctx, get_tlv_neigh(arg), ntohs(tlv->nonce));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_tlv_ack(gmrf_context_t *ctx, const gp_babel_tlv_ack_t *tlv_ack, size_t len, handle_tlv_arg_t *arg) {
|
static void handle_tlv_ack(gmrf_context_t *ctx, const gp_babel_tlv_ack_t *tlv, size_t len, handle_tlv_arg_t *arg) {
|
||||||
if (len < sizeof(gp_babel_tlv_ack_t)) {
|
if (len < sizeof(gp_babel_tlv_ack_t)) {
|
||||||
gmrf_logf(ctx->gmrf, LOG_WARNING, "received short acknowledement TLV.");
|
gmrf_logf(ctx->gmrf, LOG_WARNING, "received short acknowledement TLV.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//gp_babel_ack_handle(ntohs(tlv_ack->nonce));
|
//gp_babel_ack_handle(ntohs(tlv->nonce));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_tlv_hello(gmrf_context_t *ctx, const gp_babel_tlv_hello_t *tlv_hello, size_t len, handle_tlv_arg_t *arg) {
|
static void handle_tlv_hello(gmrf_context_t *ctx, const gp_babel_tlv_hello_t *tlv, size_t len, handle_tlv_arg_t *arg) {
|
||||||
if (len < sizeof(gp_babel_tlv_hello_t)) {
|
if (len < sizeof(gp_babel_tlv_hello_t)) {
|
||||||
gmrf_logf(ctx->gmrf, LOG_WARNING, "received short hello TLV.");
|
gmrf_logf(ctx->gmrf, LOG_WARNING, "received short hello TLV.");
|
||||||
return;
|
return;
|
||||||
|
@ -70,11 +70,11 @@ static void handle_tlv_hello(gmrf_context_t *ctx, const gp_babel_tlv_hello_t *tl
|
||||||
gmrf_logf(ctx->gmrf, LOG_DEBUG, "received hello from %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x[%s] with seqno %04x.",
|
gmrf_logf(ctx->gmrf, LOG_DEBUG, "received hello from %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x[%s] with seqno %04x.",
|
||||||
arg->source->d[0], arg->source->d[1], arg->source->d[2], arg->source->d[3],
|
arg->source->d[0], arg->source->d[1], arg->source->d[2], arg->source->d[3],
|
||||||
arg->source->d[4], arg->source->d[5], arg->source->d[6], arg->source->d[7],
|
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_hello->seqno));
|
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(arg);
|
||||||
|
|
||||||
uint16_t seqno = ntohs(tlv_hello->seqno);
|
uint16_t seqno = ntohs(tlv->seqno);
|
||||||
|
|
||||||
if (neigh->last_hello != gmrf_time_unspec) {
|
if (neigh->last_hello != gmrf_time_unspec) {
|
||||||
int timediff = (gmrf_now(ctx->gmrf) - neigh->last_hello)/10;
|
int timediff = (gmrf_now(ctx->gmrf) - neigh->last_hello)/10;
|
||||||
|
@ -101,112 +101,92 @@ static void handle_tlv_hello(gmrf_context_t *ctx, const gp_babel_tlv_hello_t *tl
|
||||||
}
|
}
|
||||||
|
|
||||||
neigh->hello_log |= 1;
|
neigh->hello_log |= 1;
|
||||||
neigh->hello_interval = ntohs(tlv_hello->interval);
|
neigh->hello_interval = ntohs(tlv->interval);
|
||||||
neigh->last_seqno = seqno;
|
neigh->last_seqno = seqno;
|
||||||
neigh->last_hello = gmrf_now(ctx->gmrf);
|
neigh->last_hello = gmrf_now(ctx->gmrf);
|
||||||
|
|
||||||
if (neigh->hello_log == 1) /* new or reset neighbour */
|
if (neigh->hello_log == 1) /* new or reset neighbour */
|
||||||
gp_babel_neigh_reset(arg->iface, neigh);
|
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_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));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_tlv_ihu(gmrf_context_t *ctx, const gp_babel_tlv_ihu_t *tlv_ihu, size_t len, handle_tlv_arg_t *arg) {
|
static void handle_tlv_ihu(gmrf_context_t *ctx, const gp_babel_tlv_ihu_t *tlv, size_t len, handle_tlv_arg_t *arg) {
|
||||||
if (len < sizeof(gp_babel_tlv_ihu_t)) {
|
if (len < sizeof(gp_babel_tlv_ihu_t)) {
|
||||||
gmrf_logf(ctx->gmrf, LOG_WARNING, "received short IHU TLV.");
|
gmrf_logf(ctx->gmrf, LOG_WARNING, "received short IHU TLV.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tlv_ihu->ae == ADDR_ENC_GMRF) {
|
if (tlv->ae == ADDR_ENC_GMRF) {
|
||||||
if (len < sizeof(gp_babel_tlv_ihu_t)+sizeof(gmrf_addr_t)) {
|
if (len < sizeof(gp_babel_tlv_ihu_t)+sizeof(gmrf_addr_t)) {
|
||||||
gmrf_logf(ctx->gmrf, LOG_WARNING, "received short IHU TLV.");
|
gmrf_logf(ctx->gmrf, LOG_WARNING, "received short IHU TLV.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gmrf_addr_t iface_addr = gmrf_iface_get_addr(ctx->gmrf, arg->iface->gmrf_iface);
|
gmrf_addr_t iface_addr = gmrf_iface_get_addr(ctx->gmrf, arg->iface->gmrf_iface);
|
||||||
if (memcmp(tlv_ihu->address, &iface_addr, sizeof(gmrf_addr_t)) != 0)
|
if (memcmp(tlv->address, &iface_addr, sizeof(gmrf_addr_t)) != 0)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (tlv_ihu->ae != ADDR_ENC_UNSPEC) {
|
else if (tlv->ae != ADDR_ENC_UNSPEC) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gp_babel_neigh_t *neigh = get_tlv_neigh(arg);
|
gp_babel_neigh_t *neigh = get_tlv_neigh(arg);
|
||||||
neigh->ihu_interval = ntohs(tlv_ihu->interval);
|
neigh->ihu_interval = ntohs(tlv->interval);
|
||||||
neigh->last_ihu = gmrf_now(ctx->gmrf);
|
neigh->last_ihu = gmrf_now(ctx->gmrf);
|
||||||
neigh->txcost = ntohs(tlv_ihu->rxcost);
|
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_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));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_tlv_node_id(gmrf_context_t *ctx, const gp_babel_tlv_node_id_t *tlv_node_id, size_t len, handle_tlv_arg_t *arg) {
|
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) {
|
||||||
if (len < sizeof(gp_babel_tlv_node_id_t)) {
|
if (len < sizeof(gp_babel_tlv_node_id_t)) {
|
||||||
gmrf_logf(ctx->gmrf, LOG_WARNING, "received short node id TLV.");
|
gmrf_logf(ctx->gmrf, LOG_WARNING, "received short node id TLV.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
arg->node_id = tlv_node_id->id;
|
arg->node_id = tlv->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_tlv_update(gmrf_context_t *ctx, const gp_babel_tlv_update_t *tlv_update, size_t len, handle_tlv_arg_t *arg) {
|
static void handle_tlv_update(gmrf_context_t *ctx, const gp_babel_tlv_update_t *tlv, size_t len, handle_tlv_arg_t *arg) {
|
||||||
if (len < sizeof(gp_babel_tlv_update_t)) {
|
if (len < sizeof(gp_babel_tlv_update_t)) {
|
||||||
gmrf_logf(ctx->gmrf, LOG_WARNING, "received short update TLV.");
|
gmrf_logf(ctx->gmrf, LOG_WARNING, "received short update TLV.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gp_babel_node_id_is_unspec(&arg->node_id)) {
|
if (gp_babel_node_id_equal(&tlv->node, &ctx->self)) {
|
||||||
gmrf_logf(ctx->gmrf, LOG_WARNING, "received update TLV without node id TLV.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gp_babel_node_id_equal(&arg->node_id, &ctx->self)) {
|
|
||||||
gmrf_logf(ctx->gmrf, LOG_DEBUG, "update source is myself.");
|
gmrf_logf(ctx->gmrf, LOG_DEBUG, "update source is myself.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gp_babel_announce_t *announce = gp_babel_announce_get(ctx, &arg->node_id, ntohs(tlv_update->type), ntohs(tlv_update->key));
|
gp_babel_route_t *route = gp_babel_route_get(ctx, &tlv->node);
|
||||||
gp_babel_metric_seqno_t ms = { ntohs(tlv_update->metric), ntohs(tlv_update->seqno) };
|
gp_babel_metric_seqno_t ms = { ntohs(tlv->metric), ntohs(tlv->seqno) };
|
||||||
bool feasible = gp_babel_is_feasible(announce, ms);
|
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(arg);
|
||||||
gp_babel_nexthop_t *nexthop = gp_babel_announce_nexthop_find(announce, neigh);
|
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.",
|
gmrf_logf(ctx->gmrf, LOG_DEBUG, "update received from %04x%04x, metric %u, seqno %04x.",
|
||||||
ntohl(*(uint32_t*)arg->node_id.id), ntohl(*(uint32_t*)(arg->node_id.id+4)),
|
ntohl(*(uint32_t*)tlv->node.id), ntohl(*(uint32_t*)(tlv->node.id+4)),
|
||||||
ms.metric, ms.seqno);
|
ms.metric, ms.seqno);
|
||||||
gmrf_logf(ctx->gmrf, LOG_DEBUG, "the update is %sfeasible and there is %s nexthop.", feasible ? "" : "not ", nexthop ? "a" : "no");
|
gmrf_logf(ctx->gmrf, LOG_DEBUG, "the update is %sfeasible and there is %s nexthop.", feasible ? "" : "not ", nexthop ? "a" : "no");
|
||||||
|
|
||||||
if (!nexthop) {
|
if (!nexthop) {
|
||||||
if (feasible && tlv_update->metric != GP_BABEL_INFINITY /* no need to ntohs */)
|
if (feasible && tlv->metric != GP_BABEL_INFINITY /* no need to ntohs */)
|
||||||
nexthop = gp_babel_announce_nexthop_new(announce, neigh);
|
nexthop = gp_babel_route_nexthop_new(route, neigh);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!feasible && nexthop == announce->selected) {
|
if (!feasible && nexthop == route->selected) {
|
||||||
gmrf_logf(ctx->gmrf, LOG_DEBUG, "requesting new seqno");
|
gmrf_logf(ctx->gmrf, LOG_DEBUG, "requesting new seqno");
|
||||||
gp_babel_send_seqno_request_for(ctx, neigh, announce);
|
gp_babel_send_seqno_request_for(ctx, neigh, route);
|
||||||
nexthop = NULL;
|
nexthop = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!feasible && nexthop && nexthop != announce->selected) {
|
if (!feasible && nexthop && nexthop != route->selected) {
|
||||||
if (ms.metric + gp_babel_neigh_get_cost(ctx, neigh) < announce->metric.metric) {
|
if (ms.metric + gp_babel_neigh_get_cost(ctx, neigh) < route->metric.metric) {
|
||||||
gmrf_logf(ctx->gmrf, LOG_DEBUG, "requesting new seqno");
|
gmrf_logf(ctx->gmrf, LOG_DEBUG, "requesting new seqno");
|
||||||
gp_babel_send_seqno_request_for(ctx, neigh, announce);
|
gp_babel_send_seqno_request_for(ctx, neigh, route);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((tlv_update->flags & GP_BABEL_UPDATE_FLAG_HAS_PAYLOAD) && !announce->payload) {
|
|
||||||
if (len > sizeof(gp_babel_tlv_update_t)) {
|
|
||||||
announce->len = len - sizeof(gp_babel_tlv_update_t);
|
|
||||||
announce->payload = malloc(announce->len);
|
|
||||||
memcpy(announce->payload, tlv_update->payload, announce->len);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
announce->len = 0xff;
|
|
||||||
|
|
||||||
/* request payload */
|
|
||||||
if (nexthop)
|
|
||||||
gp_babel_send_announce_request(ctx, NULL, neigh, &announce->node, announce->type, announce->key, true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,56 +195,81 @@ static void handle_tlv_update(gmrf_context_t *ctx, const gp_babel_tlv_update_t *
|
||||||
|
|
||||||
gmrf_logf(ctx->gmrf, LOG_DEBUG, "the update was accepted.");
|
gmrf_logf(ctx->gmrf, LOG_DEBUG, "the update was accepted.");
|
||||||
|
|
||||||
gp_babel_announce_update_nexthop(ctx, announce, nexthop, ms, ntohs(tlv_update->interval));
|
gp_babel_route_update_nexthop(ctx, route, nexthop, ms, ntohs(tlv->interval));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_tlv_seqno_req(gmrf_context_t *ctx, const gp_babel_tlv_seqno_req_t *tlv_seqno_req, size_t len, handle_tlv_arg_t *arg) {
|
static void handle_tlv_route_req(gmrf_context_t *ctx, const gp_babel_tlv_route_req_t *tlv, size_t len, handle_tlv_arg_t *arg) {
|
||||||
|
if (len < sizeof(gp_babel_tlv_route_req_t)) {
|
||||||
|
gmrf_logf(ctx->gmrf, LOG_WARNING, "received short route request TLV.");
|
||||||
|
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 (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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
||||||
if (len < sizeof(gp_babel_tlv_seqno_req_t)) {
|
if (len < sizeof(gp_babel_tlv_seqno_req_t)) {
|
||||||
gmrf_logf(ctx->gmrf, LOG_WARNING, "received short seqno request TLV.");
|
gmrf_logf(ctx->gmrf, LOG_WARNING, "received short seqno request TLV.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gp_babel_announce_t *announce = gp_babel_announce_get(ctx, &tlv_seqno_req->node, ntohs(tlv_seqno_req->type), ntohs(tlv_seqno_req->key));
|
gp_babel_route_t *route = gp_babel_route_find(ctx, &tlv->node);
|
||||||
if (!announce || !announce->selected) {
|
if (!route || !route->selected) {
|
||||||
gmrf_logf(ctx->gmrf, LOG_DEBUG, "received seqno request for unknown/unreachable announce.");
|
gmrf_logf(ctx->gmrf, LOG_DEBUG, "received seqno request for unknown/unreachable route.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gmrf_logf(ctx->gmrf, LOG_DEBUG, "seqno request received for %04x%04x, seqno %04x.",
|
gmrf_logf(ctx->gmrf, LOG_DEBUG, "seqno request received for %04x%04x, seqno %04x.",
|
||||||
ntohl(*(uint32_t*)tlv_seqno_req->node.id), ntohl(*(uint32_t*)(tlv_seqno_req->node.id+4)),
|
ntohl(*(uint32_t*)tlv->node.id), ntohl(*(uint32_t*)(tlv->node.id+4)),
|
||||||
ntohs(tlv_seqno_req->seqno));
|
ntohs(tlv->seqno));
|
||||||
|
|
||||||
gp_babel_neigh_t *neigh = get_tlv_neigh(arg);
|
gp_babel_neigh_t *neigh = get_tlv_neigh(arg);
|
||||||
|
|
||||||
if (!gp_babel_less(announce->metric.seqno, ntohs(tlv_seqno_req->seqno))) {
|
if (!gp_babel_less(route->metric.seqno, ntohs(tlv->seqno))) {
|
||||||
/* local seqno is high enough */
|
/* local seqno is high enough */
|
||||||
gmrf_logf(ctx->gmrf, LOG_DEBUG, "sending update.");
|
gmrf_logf(ctx->gmrf, LOG_DEBUG, "sending update.");
|
||||||
gp_babel_send_update(ctx, arg->iface, neigh, announce, false);
|
gp_babel_send_update_for_route(ctx, arg->iface, neigh, route);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!announce->selected->neigh) {
|
if (!route->selected->neigh) {
|
||||||
/* announce is local, increment seqno */
|
/* route is local, increment seqno */
|
||||||
gmrf_logf(ctx->gmrf, LOG_DEBUG, "incrementing seqno.");
|
gmrf_logf(ctx->gmrf, LOG_DEBUG, "incrementing seqno.");
|
||||||
announce->selected->metric_seqno.seqno++;
|
route->selected->metric_seqno.seqno++;
|
||||||
|
|
||||||
gp_babel_send_update(ctx, arg->iface, neigh, announce, false);
|
gp_babel_send_update_for_route(ctx, arg->iface, neigh, route);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tlv_seqno_req->hop_count < 2) {
|
if (tlv->hop_count < 2) {
|
||||||
gmrf_logf(ctx->gmrf, LOG_DEBUG, "hopcount too low, discarding.");
|
gmrf_logf(ctx->gmrf, LOG_DEBUG, "hopcount too low, discarding.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (announce->selected->neigh == neigh) {
|
if (route->selected->neigh == neigh) {
|
||||||
gmrf_logf(ctx->gmrf, LOG_DEBUG, "not forwarding backwards.");
|
gmrf_logf(ctx->gmrf, LOG_DEBUG, "not forwarding backwards.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* forward request */
|
/* forward request */
|
||||||
gmrf_logf(ctx->gmrf, LOG_DEBUG, "forwarding request.");
|
gmrf_logf(ctx->gmrf, LOG_DEBUG, "forwarding request.");
|
||||||
gp_babel_send_seqno_request(ctx, announce->selected->neigh, announce, ntohs(tlv_seqno_req->seqno), tlv_seqno_req->hop_count-1);
|
gp_babel_send_seqno_request(ctx, route->selected->neigh, route, ntohs(tlv->seqno), tlv->hop_count-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_tlv(gmrf_context_t *ctx, gp_babel_tlv_type_t type, const void *data, size_t len, void *arg) {
|
static void handle_tlv(gmrf_context_t *ctx, gp_babel_tlv_type_t type, const void *data, size_t len, void *arg) {
|
||||||
|
@ -295,6 +300,10 @@ static void handle_tlv(gmrf_context_t *ctx, gp_babel_tlv_type_t type, const void
|
||||||
handle_tlv_update(ctx, data, len, tlv_arg);
|
handle_tlv_update(ctx, data, len, tlv_arg);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
case TLV_ROUTE_REQ:
|
||||||
|
handle_tlv_route_req(ctx, data, len, tlv_arg);
|
||||||
|
return;
|
||||||
|
|
||||||
case TLV_SEQNO_REQ:
|
case TLV_SEQNO_REQ:
|
||||||
handle_tlv_seqno_req(ctx, data, len, tlv_arg);
|
handle_tlv_seqno_req(ctx, data, len, tlv_arg);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -64,26 +64,21 @@ typedef struct __attribute__((packed)) gp_babel_tlv_update {
|
||||||
uint16_t interval;
|
uint16_t interval;
|
||||||
uint16_t seqno;
|
uint16_t seqno;
|
||||||
uint16_t metric;
|
uint16_t metric;
|
||||||
uint16_t type;
|
uint16_t version;
|
||||||
uint16_t key;
|
gp_babel_node_id_t node;
|
||||||
uint8_t payload[];
|
|
||||||
} gp_babel_tlv_update_t;
|
} gp_babel_tlv_update_t;
|
||||||
|
|
||||||
typedef struct __attribute__((packed)) gp_babel_tlv_announce_req {
|
typedef struct __attribute__((packed)) gp_babel_tlv_route_req {
|
||||||
uint8_t flags;
|
uint8_t flags;
|
||||||
uint8_t reserved;
|
uint8_t reserved;
|
||||||
gp_babel_node_id_t node;
|
gp_babel_node_id_t node;
|
||||||
uint16_t type;
|
} gp_babel_tlv_route_req_t;
|
||||||
uint16_t key;
|
|
||||||
} gp_babel_tlv_announce_req_t;
|
|
||||||
|
|
||||||
typedef struct __attribute__((packed)) gp_babel_tlv_seqno_req {
|
typedef struct __attribute__((packed)) gp_babel_tlv_seqno_req {
|
||||||
uint16_t seqno;
|
uint16_t seqno;
|
||||||
uint8_t hop_count;
|
uint8_t hop_count;
|
||||||
uint8_t reserved;
|
uint8_t reserved;
|
||||||
gp_babel_node_id_t node;
|
gp_babel_node_id_t node;
|
||||||
uint16_t type;
|
|
||||||
uint16_t key;
|
|
||||||
} gp_babel_tlv_seqno_req_t;
|
} gp_babel_tlv_seqno_req_t;
|
||||||
|
|
||||||
#endif /* _GMRF_PROTO_BABEL_TLV_TYPES_H_ */
|
#endif /* _GMRF_PROTO_BABEL_TLV_TYPES_H_ */
|
||||||
|
|
|
@ -46,7 +46,7 @@ typedef struct gp_babel_metric_seqno {
|
||||||
|
|
||||||
|
|
||||||
typedef struct gp_babel_neigh gp_babel_neigh_t;
|
typedef struct gp_babel_neigh gp_babel_neigh_t;
|
||||||
typedef struct gp_babel_announce gp_babel_announce_t;
|
typedef struct gp_babel_route gp_babel_route_t;
|
||||||
typedef struct gp_babel_nexthop gp_babel_nexthop_t;
|
typedef struct gp_babel_nexthop gp_babel_nexthop_t;
|
||||||
|
|
||||||
typedef struct gp_babel_packet gp_babel_packet_t;
|
typedef struct gp_babel_packet gp_babel_packet_t;
|
||||||
|
|
Reference in a new issue