ttyfd = open(ttydevice, O_RDWR, 0);
ttyfd = ((ttyfd_bpq = (strchr(ttydevice, '/') ? 0 : 1)) ? open_ethertap(ttydevice) : open(ttydevice, O_RDWR, 0));
void io_open(){	int baudrate;	if (ip_mode) {		sock = socket(AF_INET, SOCK_RAW, IPPROTO_AX25);		if (sock < 0) {			perror("opening raw socket");			exit(1);		}		if (fcntl(sock, F_SETFL, FNDELAY) < 0) {			perror("setting non-blocking I/O on raw socket");			exit(1);		}#ifdef USE_ICMP		icmpsock = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);		if (icmpsock < 0) {			perror("opening raw ICMP socket");			exit(1);		}		if (fcntl(icmpsock, F_SETFL, FNDELAY) < 0) {			perror("setting non-blocking I/O on ICMP socket");			exit(1);		}#endif	}	if (udp_mode) {		udpsock = socket(AF_INET, SOCK_DGRAM, 0);		if (udpsock < 0) {			perror("opening udp socket");			exit(1);		}		if (fcntl(udpsock, F_SETFL, FNDELAY) < 0) {			perror("setting non-blocking I/O on UDP socket");			exit(1);		}/* * Ok, the udp socket is open.  Now express our interest in receiving * data destined for a particular socket. */		udpbind.sin_addr.s_addr = INADDR_ANY;		udpbind.sin_port = my_udp;		if (bind(udpsock, (struct sockaddr *) &udpbind, sizeof udpbind) < 0) {			perror("binding udp socket");			exit(1);		}	}	ttyfd = open(ttydevice, O_RDWR, 0);	if (ttyfd < 0) {		perror("opening tty device");		exit(1);	}	if (fcntl(ttyfd, F_SETFL, FNDELAY) < 0) {		perror("setting non-blocking I/O on tty device");		exit(1);	}#ifdef USE_TERMIOS	if (ioctl(ttyfd, TCGETS, &nterm) < 0) {#endif#ifdef USE_TERMIO	if (ioctl(ttyfd, TCGETA, &nterm) < 0) {#endif#ifdef USE_SGTTY	if (ioctl(ttyfd, TIOCGETP, &nterm) < 0) {#endif		perror("fetching tty device parameters");		exit(1);	}	if (ttyspeed == 50)		baudrate = B50;	else if (ttyspeed == 50)		baudrate = B50;	else if (ttyspeed == 75)		baudrate = B75;	else if (ttyspeed == 110)		baudrate = B110;	else if (ttyspeed == 134)		baudrate = B134;	else if (ttyspeed == 150)		baudrate = B150;	else if (ttyspeed == 200)		baudrate = B200;	else if (ttyspeed == 300)		baudrate = B300;	else if (ttyspeed == 600)		baudrate = B600;	else if (ttyspeed == 1200)		baudrate = B1200;	else if (ttyspeed == 1800)		baudrate = B1800;	else if (ttyspeed == 2400)		baudrate = B2400;	else if (ttyspeed == 4800)		baudrate = B4800;	else if (ttyspeed == 9600)		baudrate = B9600;#ifdef B19200	else if (ttyspeed == 19200)		baudrate = B19200;#else#ifdef EXTA	else if (ttyspeed == 19200)		baudrate = EXTA;#endif	/* EXTA */#endif	/* B19200 */#ifdef B38400	else if (ttyspeed == 38400)		baudrate = B38400;#else#ifdef EXTB	else if (ttyspeed == 38400)		baudrate = EXTB;#endif /* EXTB */#endif /* B38400 */	else		baudrate = B9600;#ifdef USE_SGTTY	nterm.sg_flags = (RAW | ANYP);	nterm.sg_ispeed = baudrate;	nterm.sg_ospeed = baudrate;#else	nterm.c_iflag = 0;	nterm.c_oflag = 0;	nterm.c_cflag = baudrate | CS8 | CREAD | CLOCAL;	nterm.c_lflag = 0;	nterm.c_cc[VMIN] = 0;	nterm.c_cc[VTIME] = 0;#endif /* USE_SGTTY */#ifdef USE_TERMIOS	if (ioctl(ttyfd, TCSETS, &nterm) < 0) {#endif /* USE_TERMIOS */#ifdef USE_TERMIO	if (ioctl(ttyfd, TCSETA, &nterm) < 0) {#endif /* USE_TERMIO */#ifdef USE_SGTTY	if (ioctl (ttyfd, TIOCSETP, &nterm) < 0) {#endif /* USE_SGTTY */		perror("setting tty device parameters");		exit(1);	}	if (digi)		send_params();	last_bc_time = 0;	/* force immediate id */}