- syslog(LOG_ERR, "Unable to set up an incoming vpn data socket");
- close(myself->meta_socket);
- return -1;
- }
-
- myself->status.active = 1;
-
- syslog(LOG_NOTICE, "Ready: listening on port %d.", myself->port);
-cp
- return 0;
-}
-
-/*
- setup all initial network connections
-*/
-int setup_network_connections(void)
-{
- config_t const *cfg;
-cp
- if((cfg = get_config_val(pingtimeout)) == NULL)
- timeout = 10;
- else
- timeout = cfg->data.val;
-
- if(setup_tap_fd() < 0)
- return -1;
-
- if(setup_myself() < 0)
- return -1;
-
- if((cfg = get_config_val(upstreamip)) == NULL)
- /* No upstream IP given, we're listen only. */
- return 0;
-
- if(setup_outgoing_connection(cfg->data.ip->ip))
- return -1;
-cp
- return 0;
-}
-
-RETSIGTYPE
-sigalrm_handler(int a)
-{
- config_t const *cfg;
- static int seconds_till_retry;
-cp
- cfg = get_config_val(upstreamip);
-
- if(!setup_outgoing_connection(cfg->data.ip->ip))
- {
- signal(SIGALRM, SIG_IGN);
- seconds_till_retry = 5;
- }
- else
- {
- signal(SIGALRM, sigalrm_handler);
- seconds_till_retry += 5;
- alarm(seconds_till_retry);
- syslog(LOG_ERR, "Still failed to connect to other. Will retry in %d seconds.",
- seconds_till_retry);
- }
-cp
-}
-
-/*
- close all open network connections
-*/
-void close_network_connections(void)
-{
- conn_list_t *p;
-cp
- for(p = conn_list; p != NULL; p = p->next)
- {
- if(p->status.dataopen)
- {
- shutdown(p->socket, 0); /* No more receptions */
- close(p->socket);
- }
- if(p->status.meta)
- {
- send_termreq(p);
- shutdown(p->meta_socket, 0); /* No more receptions */
- close(p->meta_socket);
+ next = node->next;
+ c = (connection_t *)node->data;
+ if(c->last_ping_time + pingtimeout < now)
+ {
+ if(c->status.active)
+ {
+ if(c->status.pinged)
+ {
+ if(debug_lvl >= DEBUG_PROTOCOL)
+ syslog(LOG_INFO, _("%s (%s) didn't respond to PING"),
+ c->name, c->hostname);
+ c->status.timeout = 1;
+ terminate_connection(c, 1);
+ }
+ else
+ {
+ send_ping(c);
+ }
+ }
+ else
+ {
+ if(debug_lvl >= DEBUG_CONNECTIONS)
+ syslog(LOG_WARNING, _("Timeout from %s (%s) during authentication"),
+ c->name, c->hostname);
+ terminate_connection(c, 0);
+ }