Commit 95983aad authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Fix incorrect computation of new channel number.

parent c20ab5c5
...@@ -965,6 +965,7 @@ flushupdates(struct network *net) ...@@ -965,6 +965,7 @@ flushupdates(struct network *net)
} else if(route) { } else if(route) {
unsigned char channels[DIVERSITY_HOPS]; unsigned char channels[DIVERSITY_HOPS];
int chlen; int chlen;
struct network *route_net = route->neigh->network;
seqno = route->seqno; seqno = route->seqno;
metric = route_metric(route); metric = route_metric(route);
if(metric < INFINITY) if(metric < INFINITY)
...@@ -980,14 +981,15 @@ flushupdates(struct network *net) ...@@ -980,14 +981,15 @@ flushupdates(struct network *net)
(diversity_factor * route->cost / + 128) / 256 + (diversity_factor * route->cost / + 128) / 256 +
route->add_metric; route->add_metric;
} }
if(net->channel == NET_CHANNEL_NONINTERFERING) { if(route_net->channel == NET_CHANNEL_NONINTERFERING) {
memcpy(channels, route->channels, DIVERSITY_HOPS); memcpy(channels, route->channels, DIVERSITY_HOPS);
} else { } else {
if(net->channel == NET_CHANNEL_UNKNOWN) if(route_net->channel == NET_CHANNEL_UNKNOWN)
channels[0] = NET_CHANNEL_INTERFERING; channels[0] = NET_CHANNEL_INTERFERING;
else { else {
assert(net->channel > 0 && net->channel < 254); assert(route_net->channel > 0 &&
channels[0] = net->channel; route_net->channel < 254);
channels[0] = route_net->channel;
} }
memcpy(channels + 1, route->channels, DIVERSITY_HOPS - 1); memcpy(channels + 1, route->channels, DIVERSITY_HOPS - 1);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment