diff options
author | brian <brian@FreeBSD.org> | 1999-05-13 19:29:40 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 1999-05-13 19:29:40 +0000 |
commit | bc576fdb28e703a8f2cca219067e976735d3815d (patch) | |
tree | a636b4a3f920f461b02bf8d2aae8cb6594e3a1b4 /usr.sbin/ppp | |
parent | 2ff48aab7d0e0a07f0f6d5b2f85fc3b8b0aaf5b6 (diff) | |
download | FreeBSD-src-bc576fdb28e703a8f2cca219067e976735d3815d.zip FreeBSD-src-bc576fdb28e703a8f2cca219067e976735d3815d.tar.gz |
Initialise the struct device part of struct ttydevice.
Diffstat (limited to 'usr.sbin/ppp')
-rw-r--r-- | usr.sbin/ppp/physical.c | 9 | ||||
-rw-r--r-- | usr.sbin/ppp/tty.c | 137 |
2 files changed, 73 insertions, 73 deletions
diff --git a/usr.sbin/ppp/physical.c b/usr.sbin/ppp/physical.c index b9b8d23..05ff19a 100644 --- a/usr.sbin/ppp/physical.c +++ b/usr.sbin/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.10 1999/05/09 20:13:51 brian Exp $ + * $Id: physical.c,v 1.11 1999/05/12 09:48:56 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/tty.c b/usr.sbin/ppp/tty.c index a825d70..eac49d4 100644 --- a/usr.sbin/ppp/tty.c +++ b/usr.sbin/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.2 1999/05/12 09:49:07 brian Exp $ + * $Id: tty.c,v 1.3 1999/05/13 16:35:13 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) |