Add support for DTR/CTS flow control, from Bill Studenmund.

This commit is contained in:
scottr 1997-10-20 08:07:47 +00:00
parent f0b7604760
commit 94cf433266
15 changed files with 107 additions and 45 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: key.c,v 1.12 1997/07/20 21:31:24 christos Exp $ */
/* $NetBSD: key.c,v 1.13 1997/10/20 08:08:01 scottr Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)key.c 8.4 (Berkeley) 2/20/95";
#else
__RCSID("$NetBSD: key.c,v 1.12 1997/07/20 21:31:24 christos Exp $");
__RCSID("$NetBSD: key.c,v 1.13 1997/10/20 08:08:01 scottr Exp $");
#endif
#endif /* not lint */
@ -271,7 +271,7 @@ f_sane(ip)
struct info *ip;
{
ip->t.c_cflag = TTYDEF_CFLAG | (ip->t.c_cflag & (CLOCAL|CRTSCTS));
ip->t.c_cflag = TTYDEF_CFLAG | (ip->t.c_cflag & (CLOCAL|CRTSCTS|CDTRCTS));
ip->t.c_iflag = TTYDEF_IFLAG;
ip->t.c_iflag |= ICRNL;
/* preserve user-preference flags in lflag */

View File

@ -1,4 +1,4 @@
/* $NetBSD: modes.c,v 1.11 1997/07/20 21:31:25 christos Exp $ */
/* $NetBSD: modes.c,v 1.12 1997/10/20 08:08:04 scottr Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)modes.c 8.3 (Berkeley) 4/2/94";
#else
__RCSID("$NetBSD: modes.c,v 1.11 1997/07/20 21:31:25 christos Exp $");
__RCSID("$NetBSD: modes.c,v 1.12 1997/10/20 08:08:04 scottr Exp $");
#endif
#endif /* not lint */
@ -89,6 +89,8 @@ const struct modes cmodes[] = {
{ "-crtscts", 0, CRTSCTS },
{ "mdmbuf", MDMBUF, 0 },
{ "-mdmbuf", 0, MDMBUF },
{ "cdtrcts", CDTRCTS, 0 },
{ "-cdtrcts", 0, CDTRCTS },
{ NULL },
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: print.c,v 1.13 1997/07/20 21:31:26 christos Exp $ */
/* $NetBSD: print.c,v 1.14 1997/10/20 08:08:07 scottr Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94";
#else
__RCSID("$NetBSD: print.c,v 1.13 1997/07/20 21:31:26 christos Exp $");
__RCSID("$NetBSD: print.c,v 1.14 1997/10/20 08:08:07 scottr Exp $");
#endif
#endif /* not lint */
@ -177,6 +177,7 @@ print(tp, wp, ldisc, fmt)
put("-cstopb", CSTOPB, 0);
put("-crtscts", CRTSCTS, 0);
put("-mdmbuf", MDMBUF, 0);
put("-cdtrcts", CDTRCTS, 0);
/* special control characters */
cc = tp->c_cc;

View File

@ -1,4 +1,4 @@
.\" $NetBSD: stty.1,v 1.14 1997/04/02 03:13:17 kleink Exp $
.\" $NetBSD: stty.1,v 1.15 1997/10/20 08:08:10 scottr Exp $
.\"
.\" Copyright (c) 1990, 1993, 1994
.\" The Regents of the University of California. All rights reserved.
@ -149,6 +149,8 @@ Assume a line without (with) modem
control.
.It Cm crtscts Pq Fl crtscts
Enable RTS/CTS flow control.
.It Cm cdtrcts Pq Fl cdtrcts
Enable DTR/CTS flow control (if supported).
.El
.Ss Input Modes:
This corresponds to the c_iflag in the termios structure.

View File

@ -1,4 +1,4 @@
.\" $NetBSD: getttyent.3,v 1.7 1996/03/17 19:36:53 christos Exp $
.\" $NetBSD: getttyent.3,v 1.8 1997/10/20 08:07:47 scottr Exp $
.\"
.\" Copyright (c) 1989, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@ -72,6 +72,7 @@ struct ttyent {
#define TTY_RTSCTS 0x08 /* set 'CRTSCTS' on open (dev. specific) */
#define TTY_SOFTCAR 0x10 /* ignore hardware carrier (dev. spec.) */
#define TTY_MDMBUF 0x20 /* set 'MDMBUF' on open (dev. specific) */
#define TTY_DTRCTS 0x40 /* set 'CDTRCTS' on open (dev. specific) */
int ty_status; /* flag values */
char *ty_window; /* command for window manager */
char *ty_comment; /* comment field */

View File

@ -1,4 +1,4 @@
/* $NetBSD: getttyent.c,v 1.11 1997/07/21 14:07:16 jtc Exp $ */
/* $NetBSD: getttyent.c,v 1.12 1997/10/20 08:07:51 scottr Exp $ */
/*
* Copyright (c) 1989, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)getttyent.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: getttyent.c,v 1.11 1997/07/21 14:07:16 jtc Exp $");
__RCSID("$NetBSD: getttyent.c,v 1.12 1997/10/20 08:07:51 scottr Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@ -128,6 +128,8 @@ getttyent()
tty.ty_status |= TTY_LOCAL;
else if (scmp(_TTYS_RTSCTS))
tty.ty_status |= TTY_RTSCTS;
else if (scmp(_TTYS_DTRCTS))
tty.ty_status |= TTY_DTRCTS;
else if (scmp(_TTYS_SOFTCAR))
tty.ty_status |= TTY_SOFTCAR;
else if (scmp(_TTYS_MDMBUF))

View File

@ -1,4 +1,4 @@
/* $NetBSD: tty.c,v 1.5 1997/10/09 19:16:04 christos Exp $ */
/* $NetBSD: tty.c,v 1.6 1997/10/20 08:07:56 scottr Exp $ */
/*-
* Copyright (c) 1992, 1993
@ -41,7 +41,7 @@
#if 0
static char sccsid[] = "@(#)tty.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: tty.c,v 1.5 1997/10/09 19:16:04 christos Exp $");
__RCSID("$NetBSD: tty.c,v 1.6 1997/10/20 08:07:56 scottr Exp $");
#endif
#endif /* not lint && not SCCSID */
@ -298,6 +298,9 @@ private ttymodes_t ttymodes[] = {
# ifdef CRTS_IFLOW
{ "crts_iflow",CRTS_IFLOW,M_CTL },
# endif /* CRTS_IFLOW */
# ifdef CDTRCTS
{ "cdtrcts",CDTRCTS,M_CTL },
# endif /* CDTRCTS */
# ifdef MDMBUF
{ "mdmbuf", MDMBUF, M_CTL },
# endif /* MDMBUF */

View File

@ -1,4 +1,4 @@
.\" $NetBSD: slattach.8,v 1.14 1997/09/15 11:20:04 lukem Exp $
.\" $NetBSD: slattach.8,v 1.15 1997/10/20 08:08:17 scottr Exp $
.\"
.\" Copyright (c) 1986, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@ -53,6 +53,8 @@ The following operands are supported by
.Bl -tag -width Ar
.It Fl h
Turn on RTS/CTS flow control. By default, no flow control is done.
.It Fl H
Turn on DTR/CTS flow control. By default, no flow control is done.
.It Fl m
Maintain modem control signals after closing the line. Specifically,
this disables HUPCL.

View File

@ -1,4 +1,4 @@
/* $NetBSD: slattach.c,v 1.18 1997/09/15 11:20:06 lukem Exp $ */
/* $NetBSD: slattach.c,v 1.19 1997/10/20 08:08:20 scottr Exp $ */
/*
* Copyright (c) 1988, 1993
@ -46,7 +46,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1993\n\
#if 0
static char sccsid[] = "@(#)slattach.c 8.2 (Berkeley) 1/7/94";
#else
__RCSID("$NetBSD: slattach.c,v 1.18 1997/09/15 11:20:06 lukem Exp $");
__RCSID("$NetBSD: slattach.c,v 1.19 1997/10/20 08:08:20 scottr Exp $");
#endif
#endif /* not lint */
@ -91,11 +91,14 @@ main(argc, argv)
int ch;
sigset_t sigset;
while ((ch = getopt(argc, argv, "hms:t:")) != -1) {
while ((ch = getopt(argc, argv, "hHms:t:")) != -1) {
switch (ch) {
case 'h':
cflag |= CRTSCTS;
break;
case 'H':
cflag |= CDTRCTS;
break;
case 'm':
cflag &= ~HUPCL;
break;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ttyflags.c,v 1.9 1997/09/15 11:24:41 lukem Exp $ */
/* $NetBSD: ttyflags.c,v 1.10 1997/10/20 08:08:24 scottr Exp $ */
/*
* Copyright (c) 1994 Christopher G. Demetriou
@ -37,7 +37,7 @@ __COPYRIGHT("@(#) Copyright (c) 1994 Christopher G. Demetriou\n\
#endif /* not lint */
#ifndef lint
__RCSID("$NetBSD: ttyflags.c,v 1.9 1997/09/15 11:24:41 lukem Exp $");
__RCSID("$NetBSD: ttyflags.c,v 1.10 1997/10/20 08:08:24 scottr Exp $");
#endif /* not lint */
#include <sys/types.h>
@ -185,6 +185,12 @@ change_ttyflags(tep)
(void)strcat(strflags, "|");
(void)strcat(strflags, "rtscts");
}
if (st & TTY_DTRCTS) {
flags |= TIOCFLAG_CDTRCTS;
if (sep++)
(void)strcat(strflags, "|");
(void)strcat(strflags, "dtrcts");
}
if (st & TTY_SOFTCAR) {
flags |= TIOCFLAG_SOFTCAR;
if (sep++)

View File

@ -1,4 +1,4 @@
/* $NetBSD: key.c,v 1.2 1997/07/17 05:46:51 mikel Exp $ */
/* $NetBSD: key.c,v 1.3 1997/10/20 08:08:28 scottr Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)key.c 8.3 (Berkeley) 4/2/94";
#else
__RCSID("$NetBSD: key.c,v 1.2 1997/07/17 05:46:51 mikel Exp $");
__RCSID("$NetBSD: key.c,v 1.3 1997/10/20 08:08:28 scottr Exp $");
#endif
#endif /* not lint */
@ -251,7 +251,7 @@ f_sane(ip)
struct info *ip;
{
ip->t.c_cflag = TTYDEF_CFLAG | (ip->t.c_cflag & (CLOCAL|CRTSCTS));
ip->t.c_cflag = TTYDEF_CFLAG | (ip->t.c_cflag & (CLOCAL|CRTSCTS|CDTRCTS));
ip->t.c_iflag = TTYDEF_IFLAG;
ip->t.c_iflag |= ICRNL;
/* preserve user-preference flags in lflag */

View File

@ -1,4 +1,4 @@
/* $NetBSD: modes.c,v 1.2 1997/07/17 05:44:33 mikel Exp $ */
/* $NetBSD: modes.c,v 1.3 1997/10/20 08:08:31 scottr Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)modes.c 8.3 (Berkeley) 4/2/94";
#else
__RCSID("$NetBSD: modes.c,v 1.2 1997/07/17 05:44:33 mikel Exp $");
__RCSID("$NetBSD: modes.c,v 1.3 1997/10/20 08:08:31 scottr Exp $");
#endif
#endif /* not lint */
@ -88,6 +88,8 @@ struct modes cmodes[] = {
{ "-clocal", 0, CLOCAL },
{ "crtscts", CRTSCTS, 0 },
{ "-crtscts", 0, CRTSCTS },
{ "cdtrcts", CDTRCTS, 0 },
{ "-cdtrcts", 0, CDTRCTS },
{ "mdmbuf", MDMBUF, 0 },
{ "-mdmbuf", 0, MDMBUF },
{ NULL },

View File

@ -1,4 +1,4 @@
/* $NetBSD: options.c,v 1.20 1997/09/29 03:53:40 christos Exp $ */
/* $NetBSD: options.c,v 1.21 1997/10/20 08:08:37 scottr Exp $ */
/*
* options.c - handles option processing for PPP.
@ -24,7 +24,7 @@
#if 0
static char rcsid[] = "Id: options.c,v 1.39 1997/07/14 03:53:34 paulus Exp ";
#else
__RCSID("$NetBSD: options.c,v 1.20 1997/09/29 03:53:40 christos Exp $");
__RCSID("$NetBSD: options.c,v 1.21 1997/10/20 08:08:37 scottr Exp $");
#endif
#endif
@ -178,6 +178,7 @@ static int setdomain __P((char **));
static int setnetmask __P((char **));
static int setcrtscts __P((char **));
static int setnocrtscts __P((char **));
static int setcdtrcts __P((char **));
static int setxonxoff __P((char **));
static int setnodetach __P((char **));
static int setmodem __P((char **));
@ -315,6 +316,9 @@ static struct cmd {
{"crtscts", 0, setcrtscts}, /* set h/w flow control */
{"nocrtscts", 0, setnocrtscts}, /* clear h/w flow control */
{"-crtscts", 0, setnocrtscts}, /* clear h/w flow control */
{"cdtrcts", 0, setcdtrcts}, /* set alternate h/w flow control */
{"nocdtrcts", 0, setnocrtscts}, /* clear h/w flow control */
{"-cdtrcts", 0, setnocrtscts}, /* clear h/w flow control */
{"xonxoff", 0, setxonxoff}, /* set s/w flow control */
{"debug", 0, setdebug}, /* Increase debugging level */
{"kdebug", 1, setkdebug}, /* Enable kernel-level debugging */
@ -438,6 +442,7 @@ Usage: %s [ options ], where options are:\n\
auth Require authentication from peer\n\
connect <p> Invoke shell command <p> to set up the serial line\n\
crtscts Use hardware RTS/CTS flow control\n\
cdtrcts Use hardware DTR/CTS flow control (if supported)\n\
defaultroute Add default route through interface\n\
file <f> Take options from file <f>\n\
modem Use modem control lines\n\
@ -1856,6 +1861,14 @@ setnocrtscts(argv)
return (1);
}
static int
setcdtrcts(argv)
char **argv;
{
crtscts = 2;
return (1);
}
static int
setxonxoff(argv)
char **argv;

View File

@ -1,6 +1,6 @@
.\" $NetBSD: pppd.8,v 1.19 1997/10/18 07:01:38 mikel Exp $
.\" $NetBSD: pppd.8,v 1.20 1997/10/20 08:08:41 scottr Exp $
.\" manual page [] for pppd 2.3
.\" $NetBSD: pppd.8,v 1.19 1997/10/18 07:01:38 mikel Exp $
.\" $NetBSD: pppd.8,v 1.20 1997/10/20 08:08:41 scottr Exp $
.\" SH section heading
.\" SS subsection heading
.\" LP paragraph
@ -93,10 +93,29 @@ program to dial the modem and start the remote ppp session. This
option is privileged if the \fInoauth\fR option is used.
.TP
.B crtscts
Use hardware flow control (i.e. RTS/CTS) to control the flow of data
on the serial port. If neither the \fIcrtscts\fR nor the
\fInocrtscts\fR option is given, the hardware flow control setting
for the serial port is left unchanged.
Use hardware flow control (i.e. RTS/CTS) to control the flow of
data on the serial port. If neither the \fIcrtscts\fR, the
\fInocrtscts\fR, the \fIcdtrcts\fR nor the \fInocdtrcts\fR option
is given, the hardware flow control setting for the serial port is
left unchanged.
Some serial ports (such as Macintosh serial ports) lack a true
RTS output. Such serial ports use this mode to impliment
unidirectional flow control. The serial port will
suspend transmission when requested by the modem (via CTS)
but will be unable to request the modem stop sending to the
computer. This mode retains the ability to use DTR as
a modem control line.
.TP
.B cdtrcts
Use a non-standard hardware flow control (i.e. DTR/CTS) to control
the flow of data on the serial port. If neither the \fIcrtscts\fR,
the \fInocrtscts\fR, the \fIcdtrcts\fR nor the \fInocdtrcts\fR
option is given, the hardware flow control setting for the serial
port is left unchanged.
Some serial ports (such as Macintosh serial ports) lack a true
RTS output. Such serial ports use this mode to impliment true
bi-directional flow control. The sacrafice is that this flow
control mode does not permit using DTR as a modem control line.
.TP
.B defaultroute
Add a default route to the system routing tables, using the peer as
@ -470,10 +489,14 @@ should only be required if the peer is buggy and gets confused by
requests from pppd for CCP negotiation.
.TP
.B nocrtscts
Disable hardware flow control (i.e. RTS/CTS) on the serial port. If
neither the \fIcrtscts\fR nor the \fInocrtscts\fR option is given,
the hardware flow control setting for the serial port is left
unchanged.
Disable hardware flow control (i.e. RTS/CTS) on the serial port.
If neither the \fIcrtscts\fR nor the \fInocrtscts\fR nor the
\fIcdtrcts\fR nor the \fInodtrcts\fR option is given, the hardware
flow control setting for the serial port is left unchanged.
.TP
.B nodtrcts
This option is a synonym for \fInocrtscts\fR. Either of these options will
disable both forms of hardware flow control.
.TP
.B nodefaultroute
Disable the \fIdefaultroute\fR option. The system administrator who

View File

@ -1,4 +1,4 @@
/* $NetBSD: sys-bsd.c,v 1.23 1997/09/30 16:45:16 christos Exp $ */
/* $NetBSD: sys-bsd.c,v 1.24 1997/10/20 08:08:47 scottr Exp $ */
/*
* sys-bsd.c - System-dependent procedures for setting up
@ -22,12 +22,11 @@
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char rcsid[] = "Id: sys-bsd.c,v 1.28 1997/04/30 05:57:46 paulus Exp ";
#else
__RCSID("$NetBSD: sys-bsd.c,v 1.23 1997/09/30 16:45:16 christos Exp $");
__RCSID("$NetBSD: sys-bsd.c,v 1.24 1997/10/20 08:08:47 scottr Exp $");
#endif
#endif
@ -66,8 +65,8 @@ __RCSID("$NetBSD: sys-bsd.c,v 1.23 1997/09/30 16:45:16 christos Exp $");
#include <sys/param.h>
#if defined(NetBSD) && (NetBSD >= 199703)
#include <netinet/if_inarp.h>
#else /* NetBSD 1.2D or later */
#include <net/if_ether.h>
#else /* NetBSD 1.2C or earlier */
#include <netinet/if_ether.h>
#endif
#endif
@ -391,10 +390,13 @@ set_up_tty(fd, local)
}
tios.c_cflag &= ~(CSIZE | CSTOPB | PARENB | CLOCAL);
if (crtscts > 0 && !local)
tios.c_cflag |= CRTSCTS;
else if (crtscts < 0)
tios.c_cflag &= ~CRTSCTS;
if (crtscts > 0 && !local) {
if (crtscts == 2)
tios.c_cflag |= CDTRCTS;
else
tios.c_cflag |= CRTSCTS;
} else if (crtscts < 0)
tios.c_cflag &= ~(CRTSCTS | CDTRCTS);
tios.c_cflag |= CS8 | CREAD | HUPCL;
if (local || !modem)