Commit 050c0366 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Split link-quality flag from wired/wireless flag.

parent ff4cc024
......@@ -273,17 +273,7 @@ neighbour_rxcost(struct neighbour *neigh)
if((reach & 0xFFF0) == 0 || delay >= 180000) {
return INFINITY;
} else if((neigh->network->flags & NET_WIRED)) {
/* To lose one hello is a misfortune, to lose two is carelessness. */
if((reach & 0xC000) == 0xC000)
return neigh->network->cost;
else if((reach & 0xC000) == 0)
return INFINITY;
else if((reach & 0x2000))
return neigh->network->cost;
else
return INFINITY;
} else {
} else if((neigh->network->flags & NET_LQ)) {
int sreach =
((reach & 0x8000) >> 2) +
((reach & 0x4000) >> 1) +
......@@ -293,8 +283,17 @@ neighbour_rxcost(struct neighbour *neigh)
/* cost >= network->cost */
if(delay >= 40000)
cost = (cost * (delay - 20000) + 10000) / 20000;
return MIN(cost, INFINITY);
} else {
/* To lose one hello is a misfortune, to lose two is carelessness. */
if((reach & 0xC000) == 0xC000)
return neigh->network->cost;
else if((reach & 0xC000) == 0)
return INFINITY;
else if((reach & 0x2000))
return neigh->network->cost;
else
return INFINITY;
}
}
......@@ -315,7 +314,7 @@ neighbour_cost(struct neighbour *neigh)
if(b >= INFINITY)
return INFINITY;
if((neigh->network->flags & NET_WIRED) || (a <= 256 && b <= 256)) {
if(!(neigh->network->flags & NET_LQ) || (a <= 256 && b <= 256)) {
return a;
} else {
/* a = 256/alpha, b = 256/beta, where alpha and beta are the expected
......
......@@ -263,11 +263,13 @@ network_up(struct network *net, int up)
if(net->cost <= 0) net->cost = 96;
if(split_horizon)
net->flags |= NET_SPLIT_HORIZON;
net->flags &= ~NET_LQ;
} else {
net->flags &= ~NET_WIRED;
net->cost = NET_CONF(net, cost, 0);
if(net->cost <= 0) net->cost = 256;
net->flags &= ~NET_SPLIT_HORIZON;
net->flags |= NET_LQ;
}
update_hello_interval(net);
......
......@@ -37,6 +37,7 @@ struct network_conf {
#define NET_UP (1 << 0)
#define NET_WIRED (1<<1)
#define NET_SPLIT_HORIZON (1 << 2)
#define NET_LQ (1 << 3)
struct network {
struct network *next;
......
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