2 net.c -- most of the network code
3 Copyright (C) 1998,1999,2000 Ivo Timmermans <itimmermans@bigfoot.com>,
4 2000 Guus Sliepen <guus@sliepen.warande.net>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 $Id: net.c,v 1.35.4.36 2000/10/15 00:59:34 guus Exp $
25 #include <arpa/inet.h>
29 #include <netinet/in.h>
33 #include <sys/signal.h>
34 #include <sys/socket.h>
36 #include <sys/types.h>
40 /* Next two includes are for tun/tap support */
42 #include "/usr/src/linux/include/linux/if_tun.h"
59 int total_tap_out = 0;
60 int total_socket_in = 0;
61 int total_socket_out = 0;
63 int upstreamindex = 0;
64 static int seconds_till_retry;
69 strip off the MAC adresses of an ethernet frame
71 void strip_mac_addresses(vpn_packet_t *p)
74 memmove(p->data, p->data + 12, p->len -= 12);
79 reassemble MAC addresses
81 void add_mac_addresses(vpn_packet_t *p)
84 memcpy(p->data + 12, p->data, p->len);
86 p->data[0] = p->data[6] = 0xfe;
87 p->data[1] = p->data[7] = 0xfd;
88 /* Really evil pointer stuff just below! */
89 *((ip_t*)(&p->data[2])) = (ip_t)(htonl(myself->address));
90 *((ip_t*)(&p->data[8])) = *((ip_t*)(&p->data[26]));
94 int xsend(conn_list_t *cl, vpn_packet_t *inpkt)
99 outpkt.len = inpkt->len;
100 EVP_EncryptInit(cl->cipher_pktctx, cl->cipher_pkttype, cl->cipher_pktkey, NULL);
101 EVP_EncryptUpdate(cl->cipher_pktctx, outpkt.data, &outlen, inpkt->data, inpkt->len);
102 EVP_EncryptFinal(cl->cipher_pktctx, outpkt.data + outlen, &outpad);
106 syslog(LOG_ERR, _("Sending packet of %d bytes to %s (%s)"),
107 outlen, cl->name, cl->hostname);
109 total_socket_out += outlen;
113 if((send(cl->socket, (char *) &(outpkt.len), outlen + 2, 0)) < 0)
115 syslog(LOG_ERR, _("Error sending packet to %s (%s): %m"),
116 cl->name, cl->hostname);
123 int xrecv(vpn_packet_t *inpkt)
129 syslog(LOG_ERR, _("Receiving packet of %d bytes"),
132 outpkt.len = inpkt->len;
133 EVP_DecryptInit(myself->cipher_pktctx, myself->cipher_pkttype, myself->cipher_pktkey, NULL);
134 EVP_DecryptUpdate(myself->cipher_pktctx, outpkt.data, &outlen, inpkt->data, inpkt->len);
135 /* FIXME: grok DecryptFinal
136 EVP_DecryptFinal(myself->cipher_pktctx, outpkt.data + outlen, &outpad);
139 add_mac_addresses(&outpkt);
141 if(write(tap_fd, outpkt.data, outpkt.len) < 0)
142 syslog(LOG_ERR, _("Can't write to tap device: %m"));
144 total_tap_out += outpkt.len;
150 add the given packet of size s to the
151 queue q, be it the send or receive queue
153 void add_queue(packet_queue_t **q, void *packet, size_t s)
157 e = xmalloc(sizeof(*e));
158 e->packet = xmalloc(s);
159 memcpy(e->packet, packet, s);
163 *q = xmalloc(sizeof(**q));
164 (*q)->head = (*q)->tail = NULL;
167 e->next = NULL; /* We insert at the tail */
169 if((*q)->tail) /* Do we have a tail? */
171 (*q)->tail->next = e;
172 e->prev = (*q)->tail;
174 else /* No tail -> no head too */
184 /* Remove a queue element */
185 void del_queue(packet_queue_t **q, queue_element_t *e)
190 if(e->next) /* There is a successor, so we are not tail */
192 if(e->prev) /* There is a predecessor, so we are not head */
194 e->next->prev = e->prev;
195 e->prev->next = e->next;
197 else /* We are head */
199 e->next->prev = NULL;
200 (*q)->head = e->next;
203 else /* We are tail (or all alone!) */
205 if(e->prev) /* We are not alone :) */
207 e->prev->next = NULL;
208 (*q)->tail = e->prev;
222 flush a queue by calling function for
223 each packet, and removing it when that
224 returned a zero exit code
226 void flush_queue(conn_list_t *cl, packet_queue_t **pq,
227 int (*function)(conn_list_t*,void*))
229 queue_element_t *p, *next = NULL;
231 for(p = (*pq)->head; p != NULL; )
235 if(!function(cl, p->packet))
242 syslog(LOG_DEBUG, _("Queue flushed"));
247 flush the send&recv queues
248 void because nothing goes wrong here, packets
249 remain in the queue if something goes wrong
251 void flush_queues(conn_list_t *cl)
257 syslog(LOG_DEBUG, _("Flushing send queue for %s (%s)"),
258 cl->name, cl->hostname);
259 flush_queue(cl, &(cl->sq), xsend);
265 syslog(LOG_DEBUG, _("Flushing receive queue for %s (%s)"),
266 cl->name, cl->hostname);
267 flush_queue(cl, &(cl->rq), xrecv);
273 send a packet to the given vpn ip.
275 int send_packet(ip_t to, vpn_packet_t *packet)
279 if((cl = lookup_conn_list_ipv4(to)) == NULL)
283 syslog(LOG_NOTICE, _("Trying to look up %d.%d.%d.%d in connection list failed!"),
290 /* If we ourselves have indirectdata flag set, we should send only to our uplink! */
292 /* FIXME - check for indirection and reprogram it The Right Way(tm) this time. */
294 if(!cl->status.dataopen)
295 if(setup_vpn_connection(cl) < 0)
297 syslog(LOG_ERR, _("Could not open UDP connection to %s (%s)"),
298 cl->name, cl->hostname);
302 if(!cl->status.validkey)
305 syslog(LOG_INFO, _("No valid key known yet for %s (%s), queueing packet"),
306 cl->name, cl->hostname);
307 add_queue(&(cl->sq), packet, packet->len + 2);
308 if(!cl->status.waitingforkey)
309 send_req_key(myself, cl); /* Keys should be sent to the host running the tincd */
313 if(!cl->status.active)
316 syslog(LOG_INFO, _("%s (%s) is not ready, queueing packet"),
317 cl->name, cl->hostname);
318 add_queue(&(cl->sq), packet, packet->len + 2);
319 return 0; /* We don't want to mess up, do we? */
322 /* can we send it? can we? can we? huh? */
324 return xsend(cl, packet);
328 open the local ethertap device
330 int setup_tap_fd(void)
333 const char *tapfname;
337 if((cfg = get_config_val(config, tapdevice)))
338 tapfname = cfg->data.ptr;
340 tapfname = "/dev/misc/net/tun";
342 if((nfd = open(tapfname, O_RDWR | O_NONBLOCK)) < 0)
344 syslog(LOG_ERR, _("Could not open %s: %m"), tapfname);
350 /* Ok now check if this is an old ethertap or a new tun/tap thingie */
352 memset(&ifr, 0, sizeof(ifr));
354 ifr.ifr_flags = IFF_TAP;
356 strncpy(ifr.ifr_name, netname, IFNAMSIZ);
358 if (!ioctl(tap_fd, TUNSETIFF, (void *) &ifr))
360 syslog(LOG_INFO, _("%s is a new style tun/tap device"), tapfname);
361 if((cfg = get_config_val(config, tapsubnet)) == NULL)
362 syslog(LOG_INFO, _("tun/tap device will be left unconfigured"));
364 /* Setup inetaddr/netmask etc */;
372 set up the socket that we listen on for incoming
375 int setup_listen_meta_socket(int port)
378 struct sockaddr_in a;
382 if((nfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
384 syslog(LOG_ERR, _("Creating metasocket failed: %m"));
388 if(setsockopt(nfd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)))
390 syslog(LOG_ERR, _("setsockopt: %m"));
394 if(setsockopt(nfd, SOL_SOCKET, SO_KEEPALIVE, &one, sizeof(one)))
396 syslog(LOG_ERR, _("setsockopt: %m"));
400 flags = fcntl(nfd, F_GETFL);
401 if(fcntl(nfd, F_SETFL, flags | O_NONBLOCK) < 0)
403 syslog(LOG_ERR, _("fcntl: %m"));
407 if((cfg = get_config_val(config, interface)))
409 if(setsockopt(nfd, SOL_SOCKET, SO_KEEPALIVE, cfg->data.ptr, strlen(cfg->data.ptr)))
411 syslog(LOG_ERR, _("Unable to bind listen socket to interface %s: %m"), cfg->data.ptr);
416 memset(&a, 0, sizeof(a));
417 a.sin_family = AF_INET;
418 a.sin_port = htons(port);
420 if((cfg = get_config_val(config, interfaceip)))
421 a.sin_addr.s_addr = htonl(cfg->data.ip->ip);
423 a.sin_addr.s_addr = htonl(INADDR_ANY);
425 if(bind(nfd, (struct sockaddr *)&a, sizeof(struct sockaddr)))
427 syslog(LOG_ERR, _("Can't bind to port %hd/tcp: %m"), port);
433 syslog(LOG_ERR, _("listen: %m"));
441 setup the socket for incoming encrypted
444 int setup_vpn_in_socket(int port)
447 struct sockaddr_in a;
450 if((nfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
452 syslog(LOG_ERR, _("Creating socket failed: %m"));
456 if(setsockopt(nfd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)))
458 syslog(LOG_ERR, _("setsockopt: %m"));
462 flags = fcntl(nfd, F_GETFL);
463 if(fcntl(nfd, F_SETFL, flags | O_NONBLOCK) < 0)
465 syslog(LOG_ERR, _("fcntl: %m"));
469 memset(&a, 0, sizeof(a));
470 a.sin_family = AF_INET;
471 a.sin_port = htons(port);
472 a.sin_addr.s_addr = htonl(INADDR_ANY);
474 if(bind(nfd, (struct sockaddr *)&a, sizeof(struct sockaddr)))
476 syslog(LOG_ERR, _("Can't bind to port %hd/udp: %m"), port);
484 setup an outgoing meta (tcp) socket
486 int setup_outgoing_meta_socket(conn_list_t *cl)
489 struct sockaddr_in a;
493 syslog(LOG_INFO, _("Trying to connect to %s"), cl->hostname);
495 if((cfg = get_config_val(cl->config, port)) == NULL)
498 cl->port = cfg->data.val;
500 cl->meta_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
501 if(cl->meta_socket == -1)
503 syslog(LOG_ERR, _("Creating socket for %s port %d failed: %m"),
504 cl->hostname, cl->port);
508 a.sin_family = AF_INET;
509 a.sin_port = htons(cl->port);
510 a.sin_addr.s_addr = htonl(cl->address);
512 if(connect(cl->meta_socket, (struct sockaddr *)&a, sizeof(a)) == -1)
514 syslog(LOG_ERR, _("%s port %hd: %m"), cl->hostname, cl->port);
518 flags = fcntl(cl->meta_socket, F_GETFL);
519 if(fcntl(cl->meta_socket, F_SETFL, flags | O_NONBLOCK) < 0)
521 syslog(LOG_ERR, _("fcntl for %s port %d: %m"),
522 cl->hostname, cl->port);
527 syslog(LOG_INFO, _("Connected to %s port %hd"),
528 cl->hostname, cl->port);
534 setup an outgoing connection. It's not
535 necessary to also open an udp socket as
536 well, because the other host will initiate
537 an authentication sequence during which
538 we will do just that.
540 int setup_outgoing_connection(char *hostname)
545 if(!(h = gethostbyname(hostname)))
547 syslog(LOG_ERR, _("Error looking up `%s': %m"), hostname);
551 ncn = new_conn_list();
552 ncn->address = ntohl(*((ip_t*)(h->h_addr_list[0])));
553 ncn->hostname = hostlookup(htonl(ncn->address));
555 if(setup_outgoing_meta_socket(ncn) < 0)
557 syslog(LOG_ERR, _("Could not set up a meta connection to %s"),
563 ncn->status.meta = 1;
564 ncn->status.outgoing = 1;
565 ncn->next = conn_list;
572 set up the local sockets (listen only)
574 int setup_myself(void)
578 myself = new_conn_list();
580 asprintf(&myself->hostname, "MYSELF"); /* FIXME? Do hostlookup on ourselves? */
582 myself->protocol_version = PROT_CURRENT;
584 if(!(cfg = get_config_val(config, tincname))) /* Not acceptable */
586 syslog(LOG_ERR, _("Name for tinc daemon required!"));
590 myself->name = (char*)cfg->data.val;
592 if(check_id(myself->name))
594 syslog(LOG_ERR, _("Invalid name for myself!"));
598 if(read_host_config(myself))
600 syslog(LOG_ERR, _("Cannot open host configuration file for myself!"));
604 if(!(cfg = get_config_val(myself->config, port)))
607 myself->port = cfg->data.val;
609 if((cfg = get_config_val(myself->config, indirectdata)))
610 if(cfg->data.val == stupid_true)
611 myself->flags |= EXPORTINDIRECTDATA;
613 if((cfg = get_config_val(myself->config, tcponly)))
614 if(cfg->data.val == stupid_true)
615 myself->flags |= TCPONLY;
617 if((myself->meta_socket = setup_listen_meta_socket(myself->port)) < 0)
619 syslog(LOG_ERR, _("Unable to set up a listening socket!"));
623 if((myself->socket = setup_vpn_in_socket(myself->port)) < 0)
625 syslog(LOG_ERR, _("Unable to set up an incoming vpn data socket!"));
626 close(myself->meta_socket);
630 myself->status.active = 1;
632 syslog(LOG_NOTICE, _("Ready: listening on port %hd"), myself->port);
638 sigalrm_handler(int a)
642 /* FIXME! Use name instead of upstreamip.
643 cfg = get_next_config_val(config, upstreamip, upstreamindex++);
647 if(!setup_outgoing_connection(cfg->data.ptr)) /* function returns 0 when there are no problems */
649 signal(SIGALRM, SIG_IGN);
652 // cfg = get_next_config_val(config, upstreamip, upstreamindex++); /* Or else we try the next ConnectTo line */
655 signal(SIGALRM, sigalrm_handler);
657 seconds_till_retry += 5;
658 if(seconds_till_retry > MAXTIMEOUT) /* Don't wait more than MAXTIMEOUT seconds. */
659 seconds_till_retry = MAXTIMEOUT;
660 syslog(LOG_ERR, _("Still failed to connect to other, will retry in %d seconds"),
662 alarm(seconds_till_retry);
667 setup all initial network connections
669 int setup_network_connections(void)
673 if((cfg = get_config_val(config, pingtimeout)) == NULL)
676 timeout = cfg->data.val;
678 if(setup_tap_fd() < 0)
681 if(setup_myself() < 0)
684 // if((cfg = get_next_config_val(config, upstreamip, upstreamindex++)) == NULL)
685 /* No upstream IP given, we're listen only. */
690 if(!setup_outgoing_connection(cfg->data.ptr)) /* function returns 0 when there are no problems */
692 // cfg = get_next_config_val(config, upstreamip, upstreamindex++); /* Or else we try the next ConnectTo line */
695 signal(SIGALRM, sigalrm_handler);
697 seconds_till_retry = MAXTIMEOUT;
698 syslog(LOG_NOTICE, _("Trying to re-establish outgoing connection in %d seconds"), seconds_till_retry);
699 alarm(seconds_till_retry);
705 close all open network connections
707 void close_network_connections(void)
711 for(p = conn_list; p != NULL; p = p->next)
713 if(p->status.dataopen)
715 shutdown(p->socket, 0); /* No more receptions */
721 shutdown(p->meta_socket, 0); /* No more receptions */
722 close(p->meta_socket);
727 if(myself->status.active)
729 close(myself->meta_socket);
730 close(myself->socket);
736 syslog(LOG_NOTICE, _("Terminating"));
742 create a data (udp) socket
744 int setup_vpn_connection(conn_list_t *cl)
747 struct sockaddr_in a;
750 syslog(LOG_DEBUG, _("Opening UDP socket to %s"), cl->hostname);
752 nfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
755 syslog(LOG_ERR, _("Creating UDP socket failed: %m"));
759 a.sin_family = AF_INET;
760 a.sin_port = htons(cl->port);
761 a.sin_addr.s_addr = htonl(cl->address);
763 if(connect(nfd, (struct sockaddr *)&a, sizeof(a)) == -1)
765 syslog(LOG_ERR, _("Connecting to %s port %d failed: %m"),
766 cl->hostname, cl->port);
770 flags = fcntl(nfd, F_GETFL);
771 if(fcntl(nfd, F_SETFL, flags | O_NONBLOCK) < 0)
773 syslog(LOG_ERR, _("This is a bug: %s:%d: %d:%m %s (%s)"), __FILE__, __LINE__, nfd,
774 cl->name, cl->hostname);
779 cl->status.dataopen = 1;
785 handle an incoming tcp connect call and open
788 conn_list_t *create_new_connection(int sfd)
791 struct sockaddr_in ci;
792 int len = sizeof(ci);
796 if(getpeername(sfd, &ci, &len) < 0)
798 syslog(LOG_ERR, _("Error: getpeername: %m"));
803 p->address = ntohl(ci.sin_addr.s_addr);
804 p->hostname = hostlookup(ci.sin_addr.s_addr);
805 p->meta_socket = sfd;
807 p->buffer = xmalloc(MAXBUFSIZE);
809 p->last_ping_time = time(NULL);
813 syslog(LOG_NOTICE, _("Connection from %s port %d"),
814 p->hostname, htons(ci.sin_port));
826 put all file descriptors in an fd_set array
828 void build_fdset(fd_set *fs)
834 for(p = conn_list; p != NULL; p = p->next)
837 FD_SET(p->meta_socket, fs);
838 if(p->status.dataopen)
839 FD_SET(p->socket, fs);
842 FD_SET(myself->meta_socket, fs);
843 FD_SET(myself->socket, fs);
849 receive incoming data from the listening
850 udp socket and write it to the ethertap
851 device after being decrypted
853 int handle_incoming_vpn_data()
857 int x, l = sizeof(x);
859 if(getsockopt(myself->socket, SOL_SOCKET, SO_ERROR, &x, &l) < 0)
861 syslog(LOG_ERR, _("This is a bug: %s:%d: %d:%m"),
862 __FILE__, __LINE__, myself->socket);
867 syslog(LOG_ERR, _("Incoming data socket error: %s"), strerror(x));
871 if(recvfrom(myself->socket, (char *) &(pkt.len), MTU, 0, NULL, NULL) <= 0)
873 syslog(LOG_ERR, _("Receiving packet failed: %m"));
882 terminate a connection and notify the other
883 end before closing the sockets
885 void terminate_connection(conn_list_t *cl)
890 if(cl->status.remove)
894 syslog(LOG_NOTICE, _("Closing connection with %s (%s)"),
895 cl->name, cl->hostname);
900 close(cl->meta_socket);
902 cl->status.remove = 1;
904 /* If this cl isn't active, don't send any DEL_HOSTs. */
906 /* FIXME: reprogram this.
907 if(cl->status.active)
908 notify_others(cl,NULL,send_del_host);
912 /* Find all connections that were lost because they were behind cl
913 (the connection that was dropped). */
915 for(p = conn_list; p != NULL; p = p->next)
917 if((p->nexthop == cl) && (p != cl))
919 if(cl->status.active && p->status.active)
920 /* FIXME: reprogram this
921 notify_others(p,cl,send_del_host);
925 p->status.active = 0;
926 p->status.remove = 1;
930 cl->status.active = 0;
932 if(cl->status.outgoing)
934 signal(SIGALRM, sigalrm_handler);
935 seconds_till_retry = 5;
936 alarm(seconds_till_retry);
937 syslog(LOG_NOTICE, _("Trying to re-establish outgoing connection in 5 seconds"));
943 Check if the other end is active.
944 If we have sent packets, but didn't receive any,
945 then possibly the other end is dead. We send a
946 PING request over the meta connection. If the other
947 end does not reply in time, we consider them dead
948 and close the connection.
950 int check_dead_connections(void)
956 for(p = conn_list; p != NULL; p = p->next)
960 if(p->status.active && p->status.meta)
962 if(p->last_ping_time + timeout < now)
964 if(p->status.pinged && !p->status.got_pong)
967 syslog(LOG_INFO, _("%s (%s) didn't respond to PING"),
968 p->name, p->hostname);
969 p->status.timeout = 1;
970 terminate_connection(p);
972 else if(p->want_ping)
975 p->last_ping_time = now;
976 p->status.pinged = 1;
977 p->status.got_pong = 0;
987 accept a new tcp connect and create a
990 int handle_new_meta_connection()
993 struct sockaddr client;
994 int nfd, len = sizeof(client);
996 if((nfd = accept(myself->meta_socket, &client, &len)) < 0)
998 syslog(LOG_ERR, _("Accepting a new connection failed: %m"));
1002 if(!(ncn = create_new_connection(nfd)))
1006 syslog(LOG_NOTICE, _("Closed attempted connection"));
1010 ncn->status.meta = 1;
1011 ncn->next = conn_list;
1018 check all connections to see if anything
1019 happened on their sockets
1021 void check_network_activity(fd_set *f)
1024 int x, l = sizeof(x);
1026 for(p = conn_list; p != NULL; p = p->next)
1028 if(p->status.remove)
1031 if(p->status.dataopen)
1032 if(FD_ISSET(p->socket, f))
1035 The only thing that can happen to get us here is apparently an
1036 error on this outgoing(!) UDP socket that isn't immediate (i.e.
1037 something that will not trigger an error directly on send()).
1038 I've once got here when it said `No route to host'.
1040 getsockopt(p->socket, SOL_SOCKET, SO_ERROR, &x, &l);
1041 syslog(LOG_ERR, _("Outgoing data socket error for %s (%s): %s"),
1042 p->name, p->hostname, strerror(x));
1043 terminate_connection(p);
1048 if(FD_ISSET(p->meta_socket, f))
1049 if(receive_meta(p) < 0)
1051 terminate_connection(p);
1056 if(FD_ISSET(myself->socket, f))
1057 handle_incoming_vpn_data();
1059 if(FD_ISSET(myself->meta_socket, f))
1060 handle_new_meta_connection();
1065 read, encrypt and send data that is
1066 available through the ethertap device
1068 void handle_tap_input(void)
1072 int ether_type, lenin;
1074 memset(&vp, 0, sizeof(vp));
1075 if((lenin = read(tap_fd, &vp, MTU)) <= 0)
1077 syslog(LOG_ERR, _("Error while reading from tapdevice: %m"));
1081 total_tap_in += lenin;
1083 ether_type = ntohs(*((unsigned short*)(&vp.data[12])));
1084 if(ether_type != 0x0800)
1087 syslog(LOG_INFO, _("Non-IP ethernet frame %04x from %02x:%02x:%02x:%02x:%02x:%02x"), ether_type, MAC_ADDR_V(vp.data[6]));
1094 syslog(LOG_INFO, _("Dropping short packet from %02x:%02x:%02x:%02x:%02x:%02x"), MAC_ADDR_V(vp.data[6]));
1098 from = ntohl(*((unsigned long*)(&vp.data[26])));
1099 to = ntohl(*((unsigned long*)(&vp.data[30])));
1101 vp.len = (length_t)lenin - 2;
1103 strip_mac_addresses(&vp);
1105 send_packet(to, &vp);
1110 this is where it all happens...
1112 void main_loop(void)
1117 time_t last_ping_check;
1119 last_ping_check = time(NULL);
1123 tv.tv_sec = timeout;
1129 if((r = select(FD_SETSIZE, &fset, NULL, NULL, &tv)) < 0)
1131 if(errno != EINTR) /* because of alarm */
1133 syslog(LOG_ERR, _("Error while waiting for input: %m"));
1141 /* FIXME: reprogram this.
1143 syslog(LOG_INFO, _("Rereading configuration file"));
1144 close_network_connections();
1146 if(read_config_file(&config, configfilename))
1148 syslog(LOG_ERR, _("Unable to reread configuration file, exiting"));
1152 setup_network_connections();
1157 if(last_ping_check + timeout < time(NULL))
1158 /* Let's check if everybody is still alive */
1160 check_dead_connections();
1161 last_ping_check = time(NULL);
1166 check_network_activity(&fset);
1168 /* local tap data */
1169 if(FD_ISSET(tap_fd, &fset))