Commit f71ab703 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Implement link status detection.

parent 8d9a9383
......@@ -61,7 +61,7 @@ static int maxmtu;
int reboot_time;
int idle_time = 320;
int link_detect = 0;
int wireless_hello_interval = -1;
int wired_hello_interval = -1;
int idle_hello_interval = -1;
......@@ -188,6 +188,8 @@ main(int argc, char **argv)
debug = atoi(*arg);
} else if(strcmp(*arg, "-4") == 0) {
do_ipv4 = 1;
} else if(strcmp(*arg, "-l") == 0) {
link_detect = 1;
} else {
goto syntax;
}
......
......@@ -66,6 +66,7 @@ extern int reboot_time;
extern int do_ipv4;
extern int wireless_hello_interval, wired_hello_interval, idle_hello_interval;
extern int idle_time;
extern int link_detect;
extern unsigned char myid[16];
......
......@@ -545,6 +545,7 @@ kernel_interface_operational(const char *ifname, int ifindex)
{
struct ifreq req;
int rc;
int flags = link_detect ? (IFF_UP | IFF_RUNNING) : IFF_UP;
memset(&req, 0, sizeof(req));
memset(&req, 0, sizeof(req));
......@@ -552,7 +553,7 @@ kernel_interface_operational(const char *ifname, int ifindex)
rc = ioctl(dgram_socket, SIOCGIFFLAGS, &req);
if(rc < 0)
return -1;
return ((req.ifr_flags & IFF_UP) != 0);
return ((req.ifr_flags & flags) == flags);
}
int
......
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