summaryrefslogtreecommitdiffstats
path: root/src/send.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/send.c')
-rw-r--r--src/send.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/send.c b/src/send.c
index 55adb21..e1c582f 100644
--- a/src/send.c
+++ b/src/send.c
@@ -132,7 +132,7 @@ static gp_babel_tlv_update_t* add_update_tlv(gp_babel_packet_buf_t *buf, const g
update->flags = 0;
update->reserved = 0;
update->interval = htons(GP_BABEL_UPDATE_INTERVAL);
- update->seqno = htons(ms.seqno);
+ update->seqno = (ms.metric != GP_BABEL_INFINITY) ? htons(ms.seqno) : 0;
update->metric = htons(ms.metric);
update->node = *node;
@@ -143,7 +143,7 @@ static gp_babel_tlv_update_t* add_retract_tlv(gp_babel_packet_buf_t *buf, const
return add_update_tlv(buf, node, (gp_babel_metric_seqno_t){GP_BABEL_INFINITY, 0});
}
-static bool add_update(gp_babel_packet_buf_t *buf, gp_babel_route_t *route, bool targetted) {
+static bool add_update(gp_babel_packet_buf_t *buf, gp_babel_route_t *route, bool targeted) {
gp_babel_tlv_update_t *update = add_update_tlv(buf, &route->node, route->metric);
if (!update)
return false;
@@ -151,7 +151,7 @@ static bool add_update(gp_babel_packet_buf_t *buf, gp_babel_route_t *route, bool
if (gp_babel_is_metric_better(route->metric, route->feasibility_distance))
route->feasibility_distance = route->metric;
- if (!targetted)
+ if (!targeted)
route->last_metric = route->metric.metric;
return true;
@@ -159,10 +159,15 @@ static bool add_update(gp_babel_packet_buf_t *buf, gp_babel_route_t *route, bool
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);
+ bool targeted = neigh;
- gp_babel_route_t *a;
- for (a = ctx->routes; a; a = a->next) {
- if (!add_update(buf, a, neigh)) {
+ gp_babel_route_t *route;
+ for (route = ctx->routes; route; route = route->next) {
+ if ((route->metric.metric == GP_BABEL_INFINITY) && targeted)
+ /* when targeted == true we are responding to a wildcard route request */
+ continue;
+
+ if (!add_update(buf, route, targeted)) {
if (neigh)
send_neigh(ctx, neigh, &buf->packet);
else
@@ -170,7 +175,7 @@ void gp_babel_send_update(gmrf_context_t *ctx, gmrf_iface_state_t *iface, gp_bab
buf->packet.len = 0;
- assert(add_update(buf, a, neigh));
+ assert(add_update(buf, route, targeted));
}
}