diff options
author | brian <brian@cvs.openbsd.org> | 1999-05-13 19:29:38 +0000 |
---|---|---|
committer | brian <brian@cvs.openbsd.org> | 1999-05-13 19:29:38 +0000 |
commit | 5fbe2342e22815eb50f7f82f396af752edfe8ad1 (patch) | |
tree | 531b18467faedd9c1dc81880ce4b33f547b755da /usr.sbin/ppp | |
parent | 2261a7eb1272fd0c818161ee20eb17e79cc1b65a (diff) |
Initialise the struct device part of struct ttydevice.
Diffstat (limited to 'usr.sbin/ppp')
-rw-r--r-- | usr.sbin/ppp/ppp/physical.c | 9 | ||||
-rw-r--r-- | usr.sbin/ppp/ppp/tty.c | 137 |
2 files changed, 73 insertions, 73 deletions
diff --git a/usr.sbin/ppp/ppp/physical.c b/usr.sbin/ppp/ppp/physical.c index 759ead8c504..d4c71cff1da 100644 --- a/usr.sbin/ppp/ppp/physical.c +++ b/usr.sbin/ppp/ppp/physical.c @@ -16,7 +16,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: physical.c,v 1.7 1999/05/12 10:03:52 brian Exp $ + * $Id: physical.c,v 1.8 1999/05/13 19:29:37 brian Exp $ * */ @@ -803,12 +803,11 @@ physical_Open(struct physical *p, struct bundle *bundle) for (h = 0; h < NDEVICES && p->handler == NULL && p->fd >= 0; h++) p->handler = (*devices[h].create)(p); if (p->fd >= 0) { - if (p->handler == NULL) + if (p->handler == NULL) { physical_SetupStack(p, PHYSICAL_NOFORCE); + log_Printf(LogDEBUG, "%s: stdin is unidentified\n", p->link.name); + } physical_Found(p); - if (p->handler == NULL) - log_Printf(LogDEBUG, "%s: stdin is unidentified\n", - p->link.name); } } else { dev = p->cfg.devlist; diff --git a/usr.sbin/ppp/ppp/tty.c b/usr.sbin/ppp/ppp/tty.c index 55e32fdb0b6..7f98c7f0622 100644 --- a/usr.sbin/ppp/ppp/tty.c +++ b/usr.sbin/ppp/ppp/tty.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: tty.c,v 1.3 1999/05/13 16:33:56 brian Exp $ + * $Id: tty.c,v 1.4 1999/05/13 19:29:37 brian Exp $ */ #include <sys/param.h> @@ -154,73 +154,6 @@ tty_Unlock(struct physical *p) log_Printf(LogALERT, "%s: Can't uu_unlock %s\n", p->link.name, fn); } -static struct device * -tty_SetupDevice(struct physical *p) -{ - struct ttydevice *dev; - struct termios ios; - int oldflag; - - if ((dev = malloc(sizeof *dev)) == NULL) - return NULL; - - tcgetattr(p->fd, &ios); - dev->ios = ios; - - log_Printf(LogDEBUG, "%s: tty_SetupDevice: physical (get): fd = %d," - " iflag = %lx, oflag = %lx, cflag = %lx\n", p->link.name, p->fd, - (u_long)ios.c_iflag, (u_long)ios.c_oflag, (u_long)ios.c_cflag); - - cfmakeraw(&ios); - if (p->cfg.rts_cts) - ios.c_cflag |= CLOCAL | CCTS_OFLOW | CRTS_IFLOW; - else { - ios.c_cflag |= CLOCAL; - ios.c_iflag |= IXOFF; - } - ios.c_iflag |= IXON; - if (p->type != PHYS_DEDICATED) - ios.c_cflag |= HUPCL; - - if (p->type != PHYS_DIRECT) { - /* Change tty speed when we're not in -direct mode */ - ios.c_cflag &= ~(CSIZE | PARODD | PARENB); - ios.c_cflag |= p->cfg.parity; - if (cfsetspeed(&ios, IntToSpeed(p->cfg.speed)) == -1) - log_Printf(LogWARN, "%s: %s: Unable to set speed to %d\n", - p->link.name, p->name.full, p->cfg.speed); - } - tcsetattr(p->fd, TCSADRAIN, &ios); - log_Printf(LogDEBUG, "%s: physical (put): iflag = %lx, oflag = %lx, " - "cflag = %lx\n", p->link.name, (u_long)ios.c_iflag, - (u_long)ios.c_oflag, (u_long)ios.c_cflag); - - if (ioctl(p->fd, TIOCMGET, &dev->mbits) == -1) { - if (p->type != PHYS_DIRECT) { - log_Printf(LogWARN, "%s: Open: Cannot get physical status: %s\n", - p->link.name, strerror(errno)); - physical_Close(p); - return NULL; - } else - dev->mbits = TIOCM_CD; - } - log_Printf(LogDEBUG, "%s: Open: physical control = %o\n", - p->link.name, dev->mbits); - - oldflag = fcntl(p->fd, F_GETFL, 0); - if (oldflag < 0) { - log_Printf(LogWARN, "%s: Open: Cannot get physical flags: %s\n", - p->link.name, strerror(errno)); - physical_Close(p); - return NULL; - } else - fcntl(p->fd, F_SETFL, oldflag & ~O_NONBLOCK); - - physical_SetupStack(p, PHYSICAL_NOFORCE); - - return &dev->dev; -} - /* * tty_Timeout() watches the DCD signal and mentions it if it's status * changes. @@ -443,6 +376,74 @@ static struct device basettydevice = { tty_OpenInfo }; +static struct device * +tty_SetupDevice(struct physical *p) +{ + struct ttydevice *dev; + struct termios ios; + int oldflag; + + if ((dev = malloc(sizeof *dev)) == NULL) + return NULL; + + memcpy(&dev->dev, &basettydevice, sizeof dev->dev); + tcgetattr(p->fd, &ios); + dev->ios = ios; + + log_Printf(LogDEBUG, "%s: tty_SetupDevice: physical (get): fd = %d," + " iflag = %lx, oflag = %lx, cflag = %lx\n", p->link.name, p->fd, + (u_long)ios.c_iflag, (u_long)ios.c_oflag, (u_long)ios.c_cflag); + + cfmakeraw(&ios); + if (p->cfg.rts_cts) + ios.c_cflag |= CLOCAL | CCTS_OFLOW | CRTS_IFLOW; + else { + ios.c_cflag |= CLOCAL; + ios.c_iflag |= IXOFF; + } + ios.c_iflag |= IXON; + if (p->type != PHYS_DEDICATED) + ios.c_cflag |= HUPCL; + + if (p->type != PHYS_DIRECT) { + /* Change tty speed when we're not in -direct mode */ + ios.c_cflag &= ~(CSIZE | PARODD | PARENB); + ios.c_cflag |= p->cfg.parity; + if (cfsetspeed(&ios, IntToSpeed(p->cfg.speed)) == -1) + log_Printf(LogWARN, "%s: %s: Unable to set speed to %d\n", + p->link.name, p->name.full, p->cfg.speed); + } + tcsetattr(p->fd, TCSADRAIN, &ios); + log_Printf(LogDEBUG, "%s: physical (put): iflag = %lx, oflag = %lx, " + "cflag = %lx\n", p->link.name, (u_long)ios.c_iflag, + (u_long)ios.c_oflag, (u_long)ios.c_cflag); + + if (ioctl(p->fd, TIOCMGET, &dev->mbits) == -1) { + if (p->type != PHYS_DIRECT) { + log_Printf(LogWARN, "%s: Open: Cannot get physical status: %s\n", + p->link.name, strerror(errno)); + physical_Close(p); + return NULL; + } else + dev->mbits = TIOCM_CD; + } + log_Printf(LogDEBUG, "%s: Open: physical control = %o\n", + p->link.name, dev->mbits); + + oldflag = fcntl(p->fd, F_GETFL, 0); + if (oldflag < 0) { + log_Printf(LogWARN, "%s: Open: Cannot get physical flags: %s\n", + p->link.name, strerror(errno)); + physical_Close(p); + return NULL; + } else + fcntl(p->fd, F_SETFL, oldflag & ~O_NONBLOCK); + + physical_SetupStack(p, PHYSICAL_NOFORCE); + + return &dev->dev; +} + struct device * tty_iov2device(int type, struct physical *p, struct iovec *iov, int *niov, int maxiov) |