Commit 75084871 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Default values for interface flags from net->conf.

parent b6513124
......@@ -244,6 +244,10 @@ network_up(struct network *net, int up)
if(all_wireless) {
wired = 0;
} else if(NET_CONF(net, wired) == CONFIG_NO) {
wired = 0;
} else if(NET_CONF(net, wired) == CONFIG_YES) {
wired = 1;
} else {
rc = kernel_interface_wireless(net->ifname, net->ifindex);
if(rc < 0) {
......@@ -261,15 +265,30 @@ network_up(struct network *net, int up)
net->flags |= NET_WIRED;
net->cost = NET_CONF(net, cost);
if(net->cost <= 0) net->cost = 96;
if(split_horizon)
if(NET_CONF(net, split_horizon) == CONFIG_NO)
net->flags &= ~NET_SPLIT_HORIZON;
else if(NET_CONF(net, split_horizon) == CONFIG_YES)
net->flags |= NET_SPLIT_HORIZON;
else if(split_horizon)
net->flags |= NET_SPLIT_HORIZON;
net->flags &= ~NET_LQ;
else
net->flags &= ~NET_SPLIT_HORIZON;
if(NET_CONF(net, lq) == CONFIG_YES)
net->flags |= NET_LQ;
else
net->flags &= ~NET_LQ;
} else {
net->flags &= ~NET_WIRED;
net->cost = NET_CONF(net, cost);
if(net->cost <= 0) net->cost = 256;
net->flags &= ~NET_SPLIT_HORIZON;
net->flags |= NET_LQ;
if(NET_CONF(net, split_horizon) == CONFIG_YES)
net->flags |= NET_SPLIT_HORIZON;
else
net->flags &= ~NET_SPLIT_HORIZON;
if(NET_CONF(net, lq) == CONFIG_NO)
net->flags &= ~NET_LQ;
else
net->flags |= NET_LQ;
}
update_hello_interval(net);
......
......@@ -31,9 +31,16 @@ struct network_conf {
char *ifname;
unsigned short cost;
unsigned short hello_interval;
char wired;
char split_horizon;
char lq;
struct network_conf *next;
};
#define CONFIG_DEFAULT 0
#define CONFIG_NO 1
#define CONFIG_YES 2
#define NET_UP (1 << 0)
#define NET_WIRED (1<<1)
#define NET_SPLIT_HORIZON (1 << 2)
......
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