Commit 403f6cb4 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Split idle detection into its own function.

parent b771ae52
...@@ -702,10 +702,17 @@ add_network(char *ifname, int ifindex, int mtu, int wired, unsigned int cost) ...@@ -702,10 +702,17 @@ add_network(char *ifname, int ifindex, int mtu, int wired, unsigned int cost)
return &nets[numnets - 1]; return &nets[numnets - 1];
} }
int
network_idle(struct network *net)
{
return (idle_hello_interval > 0 &&
net->activity_time < now.tv_sec - idle_time);
}
void void
update_hello_interval(struct network *net) update_hello_interval(struct network *net)
{ {
if(idle_hello_interval >= 0 && net->activity_time < now.tv_sec - idle_time) if(network_idle(net))
net->hello_interval = idle_hello_interval; net->hello_interval = idle_hello_interval;
else if(net->wired) else if(net->wired)
net->hello_interval = wired_hello_interval; net->hello_interval = wired_hello_interval;
......
...@@ -98,4 +98,5 @@ extern int protocol_socket; ...@@ -98,4 +98,5 @@ extern int protocol_socket;
extern int kernel_socket; extern int kernel_socket;
extern int max_hopcount; extern int max_hopcount;
int network_idle(struct network *net);
void update_hello_interval(struct network *net); void update_hello_interval(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