summaryrefslogtreecommitdiffstats
path: root/src/babel.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-08-01 21:07:59 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-08-01 21:07:59 +0200
commitf29e37138a190c5cb43747433d687c944b7d2efe (patch)
tree4f959cc0557150591e993bcc344b316d39272752 /src/babel.c
parent45a3ff5a4f41ca861a57fc9e14d4ac8a4905af95 (diff)
downloadbabel-f29e37138a190c5cb43747433d687c944b7d2efe.tar
babel-f29e37138a190c5cb43747433d687c944b7d2efe.zip
Simplify basic protocol, rename announces to routes, begin implementing route request handling
Diffstat (limited to 'src/babel.c')
-rw-r--r--src/babel.c38
1 files changed, 18 insertions, 20 deletions
diff --git a/src/babel.c b/src/babel.c
index 7cf52b6..06c972f 100644
--- a/src/babel.c
+++ b/src/babel.c
@@ -48,7 +48,7 @@ static void send_updates(gmrf_context_t *ctx, void *arg) {
gmrf_iface_state_t *iface;
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) {
- gp_babel_announce_t **cur, **next;
- for (cur = &ctx->announces; *cur; cur = next) {
- gp_babel_announce_t *announce = *cur;
- next = &announce->next;
+static void maintain_routes(gmrf_context_t *ctx) {
+ gp_babel_route_t **cur, **next;
+ for (cur = &ctx->routes; *cur; cur = next) {
+ gp_babel_route_t *route = *cur;
+ next = &route->next;
- gp_babel_announce_update(ctx, announce);
+ gp_babel_route_update(ctx, route);
- if (!announce->nexthops) {
+ if (!route->nexthops) {
*cur = *next;
next = cur;
- gp_babel_announce_free(ctx, announce);
+ gp_babel_route_free(ctx, route);
continue;
}
- gmrf_logf(ctx->gmrf, LOG_DEBUG, "node %04x%04x, type %04x, announce %04x (%u, seqno=%04x):",
- ntohl(*(uint32_t*)announce->node.id), ntohl(*(uint32_t*)(announce->node.id+4)),
- announce->type, announce->key, announce->metric.metric, announce->metric.seqno);
+ gmrf_logf(ctx->gmrf, LOG_DEBUG, "node %04x%04x (%u, seqno=%04x):",
+ ntohl(*(uint32_t*)route->node.id), ntohl(*(uint32_t*)(route->node.id+4)),
+ route->metric.metric, route->metric.seqno);
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;
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->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 == 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);
maintain_neighbours(ctx);
- maintain_announces(ctx);
+ maintain_routes(ctx);
}
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;
gmrf_random_bytes(gmrf, &ctx->self, sizeof(gp_babel_node_id_t));
- gp_babel_announce_t *announce = gp_babel_announce_new(ctx);
- announce->node = ctx->self;
- announce->type = 1;
- announce->key = 1337;
+ gp_babel_route_t *route = gp_babel_route_new(ctx);
+ route->node = ctx->self;
- announce->nexthops = announce->selected = calloc(1, sizeof(gp_babel_nexthop_t));
+ route->nexthops = route->selected = calloc(1, sizeof(gp_babel_nexthop_t));
return ctx;
}