Commit f311f9f6 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Move wireless detection to network_up.

parent dfe63a08
...@@ -392,21 +392,8 @@ main(int argc, char **argv) ...@@ -392,21 +392,8 @@ main(int argc, char **argv)
/* 40 for IPv6 header, 8 for UDP header, 12 for good luck. */ /* 40 for IPv6 header, 8 for UDP header, 12 for good luck. */
mtu -= 60; mtu -= 60;
if(all_wireless) { debugf("Adding network %s.\n", *arg);
rc = 1; vrc = add_network(*arg);
} else {
rc = kernel_interface_wireless(*arg, ifindex);
if(rc < 0) {
fprintf(stderr,
"Warning: couldn't determine whether %s "
"is a wireless interface.\n",
*arg);
rc = 1;
}
}
debugf("Adding %s network %s (%d).\n",
rc ? "wireless" : "wired", *arg, ifindex);
vrc = add_network(*arg, !rc, rc ? 256 : 128);
if(vrc == NULL) if(vrc == NULL)
goto fail; goto fail;
SHIFT(); SHIFT();
......
...@@ -37,7 +37,7 @@ struct network nets[MAXNETS]; ...@@ -37,7 +37,7 @@ struct network nets[MAXNETS];
int numnets = 0; int numnets = 0;
struct network * struct network *
add_network(char *ifname, int wired, unsigned int cost) add_network(char *ifname)
{ {
if(numnets >= MAXNETS) { if(numnets >= MAXNETS) {
fprintf(stderr, "Too many networks.\n"); fprintf(stderr, "Too many networks.\n");
...@@ -48,8 +48,6 @@ add_network(char *ifname, int wired, unsigned int cost) ...@@ -48,8 +48,6 @@ add_network(char *ifname, int wired, unsigned int cost)
nets[numnets].up = 0; nets[numnets].up = 0;
nets[numnets].ifindex = 0; nets[numnets].ifindex = 0;
nets[numnets].ipv4 = NULL; nets[numnets].ipv4 = NULL;
nets[numnets].wired = wired;
nets[numnets].cost = cost;
nets[numnets].activity_time = now.tv_sec; nets[numnets].activity_time = now.tv_sec;
nets[numnets].bufsize = 0; nets[numnets].bufsize = 0;
strncpy(nets[numnets].ifname, ifname, IF_NAMESIZE); strncpy(nets[numnets].ifname, ifname, IF_NAMESIZE);
...@@ -127,7 +125,7 @@ update_jitter(struct network *net, int urgent) ...@@ -127,7 +125,7 @@ update_jitter(struct network *net, int urgent)
static int static int
network_up(struct network *net, int up) network_up(struct network *net, int up)
{ {
int mtu; int mtu, rc, wired;
if(up == net->up) if(up == net->up)
return 0; return 0;
...@@ -153,6 +151,25 @@ network_up(struct network *net, int up) ...@@ -153,6 +151,25 @@ network_up(struct network *net, int up)
net->bufsize = 0; net->bufsize = 0;
return network_up(net, 0); return network_up(net, 0);
} }
if(all_wireless) {
wired = 1;
} else {
rc = kernel_interface_wireless(net->ifname, net->ifindex);
if(rc < 0) {
fprintf(stderr,
"Warning: couldn't determine whether %s (%d) "
"is a wireless interface.\n",
net->ifname, net->ifindex);
wired = 0;
} else {
wired = !rc;
}
}
net->wired = wired;
net->cost = wired ? 128 : 256;
update_hello_interval(net); update_hello_interval(net);
} else { } else {
net->buffered = 0; net->buffered = 0;
......
...@@ -47,7 +47,7 @@ struct network { ...@@ -47,7 +47,7 @@ struct network {
extern struct network nets[MAXNETS]; extern struct network nets[MAXNETS];
extern int numnets; extern int numnets;
struct network *add_network(char *ifname, int wired, unsigned int cost); struct network *add_network(char *ifname);
int network_idle(struct network *net); int network_idle(struct network *net);
int update_hello_interval(struct network *net); int update_hello_interval(struct network *net);
unsigned int jitter(struct network *net); unsigned int jitter(struct network *net);
......
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