out_ttyfd:
void io_start() {	int n, nb, hdr_len;	fd_set readfds;	unsigned char buf[MAX_FRAME];	struct timeval wait;	struct iphdr *ipptr;	time_t now;	for (;;) {		if ((bc_interval > 0) && digi) {			now = time(NULL);			if (last_bc_time + bc_interval < now) {				last_bc_time = now;				LOGL4("iostart: BEACON\n");				do_beacon();			}		}		wait.tv_sec = 10;	/* lets us keep the beacon going */		wait.tv_usec = 0;		FD_ZERO(&readfds);		FD_SET(ttyfd, &readfds);		if (ip_mode) {			FD_SET(sock, &readfds);#ifdef USE_ICMP			FD_SET(icmpsock, &readfds);#endif		}		if (udp_mode) {			FD_SET(udpsock, &readfds);		}		nb = select(FD_SETSIZE, &readfds, (fd_set *) 0, (fd_set *) 0, &wait);		if (nb < 0) {			if (errno == EINTR)				continue;	/* Ignore */			perror("select");			exit(1);		}		if (nb == 0) {			fflush(stdout);			fflush(stderr);			/* just so we go back to the top of the loop! */			continue;		}		if (FD_ISSET(ttyfd, &readfds)) {			do {				n = read(ttyfd, buf, MAX_FRAME);			}			while (io_error(n, buf, n, READ_MSG, TTY_MODE));			LOGL4("ttydata l=%d\n", n);			if (n > 0)				assemble_kiss(buf, n);/* * If we are in "beacon after" mode, reset the "last_bc_time" each time * we hear something on the channel. */			if (!bc_every)				last_bc_time = time(NULL);		}		if (udp_mode) {			if (FD_ISSET(udpsock, &readfds)) {				do {					fromlen = sizeof from;					n = recvfrom(udpsock, buf, MAX_FRAME, 0, (struct sockaddr *) &from, &fromlen);				}				while (io_error(n, buf, n, READ_MSG, UDP_MODE));				LOGL4("udpdata from=%s port=%d l=%d\n", (char *) inet_ntoa(from.  sin_addr), ntohs(from.  sin_port), n);				stats.udp_in++;				if (n > 0)					from_ip(buf, n);			}		}		/* if udp_mode */		if (ip_mode) {			if (FD_ISSET(sock, &readfds)) {				do {					fromlen = sizeof from;					n = recvfrom(sock, buf, MAX_FRAME, 0, (struct sockaddr *) &from, &fromlen);				}				while (io_error(n, buf, n, READ_MSG, IP_MODE));				ipptr = (struct iphdr *) buf;				hdr_len = 4 * ipptr-> ihl;				LOGL4("ipdata from=%s l=%d, hl=%d\n", (char *) inet_ntoa(from.  sin_addr), n, hdr_len);				stats.ip_in++;				if (n > hdr_len)					from_ip(buf + hdr_len, n - hdr_len);			}#ifdef USE_ICMP			if (FD_ISSET(icmpsock, &readfds)) {				do {					fromlen = sizeof from;					n = recvfrom(icmpsock, buf, MAX_FRAME, 0, (struct sockaddr *) &from, &fromlen);				}				while (io_error(n, buf, n, READ_MSG, ICMP_MODE));				ipptr = (struct iphdr *) buf;				hdr_len = 4 * ipptr-> ihl;				LOGL4("icmpdata from=%s l=%d, hl=%d\n", (char *) inet_ntoa(from.  sin_addr), n, hdr_len);			}#endif		}		/* if ip_mode */	}	/* for forever */}