From owner-freebsd-bugs Tue Jul 16 16:20:08 1996 Return-Path: owner-bugs Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id QAA10235 for bugs-outgoing; Tue, 16 Jul 1996 16:20:08 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id QAA10201; Tue, 16 Jul 1996 16:20:03 -0700 (PDT) Resent-Date: Tue, 16 Jul 1996 16:20:03 -0700 (PDT) Resent-Message-Id: <199607162320.QAA10201@freefall.freebsd.org> Resent-From: gnats (GNATS Management) Resent-To: freebsd-bugs Resent-Reply-To: FreeBSD-gnats@freefall.FreeBSD.org, mmcg@heraclitus.cs.monash.edu.au Received: from heraclitus.cs.monash.edu.au (heraclitus.cs.monash.edu.au [130.194.64.241]) by freefall.freebsd.org (8.7.5/8.7.3) with SMTP id QAA10009 for ; Tue, 16 Jul 1996 16:19:04 -0700 (PDT) Received: (from root@localhost) by heraclitus.cs.monash.edu.au (8.6.12/8.6.12) id CAA16974; Wed, 17 Jul 1996 02:00:35 +1000 Message-Id: <199607161600.CAA16974@heraclitus.cs.monash.edu.au> Date: Wed, 17 Jul 1996 02:00:35 +1000 From: Mike McGaughey Reply-To: mmcg@heraclitus.cs.monash.edu.au To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.2 Subject: bin/1392: PPP fix for direct lines with no CTS/RTS Sender: owner-bugs@freebsd.org X-Loop: FreeBSD.org Precedence: bulk >Number: 1392 >Category: bin >Synopsis: PPP silently fails to work when CTS/RTS isnt available (report + patch) >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Class: change-request >Submitter-Id: current-users >Arrival-Date: Tue Jul 16 16:20:01 PDT 1996 >Last-Modified: >Originator: Mike McGaughey >Organization: Computer Science, Monash University >Release: FreeBSD 2.1.5-STABLE i386 >Environment: >Description: PPP, as supplied in both 2.1.0-R and 2.1.5-R, is unusable if your setup does not provide hardware CTS/RTS signalling. PPP appears to be working, and (in my case) reads data from the serial port; however, data which is being queued for output will never be sent (for lack of a CTS signal). Thus, although PPP may have the right configuration, and does all of the right things, a connection is never established and the LCP times out and is eventually dropped. The consequences are particularly insidious for newbies trying to set it up for the first time. The only way for a naive user to work out what is going on is to notice that the (undocumented) modem `outq' count isn't decreasing. A more likely result is that such users spend endless frustrating hours tweaking their configuration files, then give up in disgust---and we never hear from them, because they can't connect to the net :) >How-To-Repeat: Connect your serial line to a poorly configured (and under-wired) Annex terminal server box (or connect to a properly wired one but disable bell flow control). >Fix: The obvious fix is to add a `set ctsrts [on|off]' command to PPP, with the default being `on', for compatibility; people with dedicated lines can add `set ctsrts off' to the appropriate parts of their ppp.conf. I have been using such a modified version of PPP from 2.1.0-RELEASE for some months now, with no problems. Here are diffs for the same modifications made (by hand) to a clean copy of PPP from the 2.1.5-RELEASE source; if you are reading this mail, it is probably working. Note that it has only had a few hours of testing, and (in fact) is being run on a 2.1.0-R installation; treat it with some suspicion. Cheers, Mike. diff -r -c ppp-2.1.5-R/command.c ppp-new/command.c *** ppp-2.1.5-R/command.c Tue Jul 16 23:33:08 1996 --- ppp-new/command.c Wed Jul 17 00:11:27 1996 *************** *** 850,855 **** --- 850,872 ---- return(1); } + static int SetCtsRts(list, argc, argv) + struct cmdtab *list; + int argc; + char **argv; + { + if (argc > 0) { + if (strcmp(*argv, "on") == 0) + VarCtsRts = TRUE; + else if (strcmp(*argv, "off") == 0) + VarCtsRts = FALSE; + else + printf("usage: set ctsrts [on|off].\n"); + } + return(1); + } + + static int SetOpenMode(list, argc, argv) struct cmdtab *list; int argc; *************** *** 880,885 **** --- 897,904 ---- "Set authentication key", "key", (void *)VAR_AUTHKEY}, { "authname", NULL, SetVariable, LOCAL_AUTH, "Set authentication name", "name", (void *)VAR_AUTHNAME}, + { "ctsrts", NULL, SetCtsRts, LOCAL_AUTH, + "Use CTS/RTS modem signalling", "[on|off]"}, { "debug", NULL, SetDebugLevel, LOCAL_AUTH, "Set debug level", StrValue}, { "device", "line", SetVariable, LOCAL_AUTH, diff -r -c ppp-2.1.5-R/defs.h ppp-new/defs.h *** ppp-2.1.5-R/defs.h Tue Jul 16 23:33:08 1996 --- ppp-new/defs.h Wed Jul 17 00:10:48 1996 *************** *** 45,50 **** --- 45,51 ---- #define MODEM_SPEED B38400 /* tty speed */ #define SERVER_PORT 3000 /* Base server port no. */ + #define MODEM_CTSRTS TRUE /* Default (true): use CTS/RTS signals */ #define REDIAL_PERIOD 30 /* Default Hold time to redial */ #define CONFFILE "ppp.conf" diff -r -c ppp-2.1.5-R/modem.c ppp-new/modem.c *** ppp-2.1.5-R/modem.c Tue Jul 16 23:33:09 1996 --- ppp-new/modem.c Wed Jul 17 00:33:34 1996 *************** *** 440,451 **** logprintf("modem (get): iflag = %x, oflag = %x, cflag = %x\n", rstio.c_iflag, rstio.c_oflag, rstio.c_cflag); #endif ! #define USE_CTSRTS ! #ifdef USE_CTSRTS ! rstio.c_cflag = (CS8 | CREAD | CLOCAL | CCTS_OFLOW|CRTS_IFLOW); ! #else rstio.c_cflag = (CS8 | CREAD | CLOCAL); ! #endif if ((mode & MODE_DIRECT) == 0) { /* * If we are working as direct mode, don't change tty speed. --- 440,450 ---- logprintf("modem (get): iflag = %x, oflag = %x, cflag = %x\n", rstio.c_iflag, rstio.c_oflag, rstio.c_cflag); #endif ! rstio.c_cflag = (CS8 | CREAD | CLOCAL); ! if (VarCtsRts) ! rstio.c_cflag |= (CCTS_OFLOW | CRTS_IFLOW); ! if ((mode & MODE_DIRECT) == 0) { /* * If we are working as direct mode, don't change tty speed. *************** *** 766,776 **** } if (VarParity & PARENB) { if (VarParity & PARODD) ! printf("odd parity\n"); else ! printf("even parity\n"); } else ! printf("none parity\n"); #ifdef DEBUG printf("fd = %d, modem control = %o\n", modem, mbits); #endif --- 765,778 ---- } if (VarParity & PARENB) { if (VarParity & PARODD) ! printf("odd parity, "); else ! printf("even parity, "); } else ! printf("no parity, "); ! ! printf("CTS/RTS %s.\n", (VarCtsRts? "on" : "off")); ! #ifdef DEBUG printf("fd = %d, modem control = %o\n", modem, mbits); #endif diff -r -c ppp-2.1.5-R/ppp.8 ppp-new/ppp.8 *** ppp-2.1.5-R/ppp.8 Tue Jul 16 23:33:10 1996 --- ppp-new/ppp.8 Wed Jul 17 00:58:16 1996 *************** *** 150,163 **** ppp ON tama> ! * You can specify the device name and speed for your modem using the ! following commands: * ppp ON tama> set line /dev/cuaa0 ppp ON tama> set speed 38400 ppp ON tama> set parity even ppp ON tama> show modem --- 150,175 ---- ppp ON tama> ! * You can now specify the device name, speed and parity ! for your modem, and whether ! CTS/RTS signalling should be used (CTS/RTS is used by default). ! If your hardware does not provide CTS/RTS lines (as ! may happen when you are connected directly to certain ppp-capable ! terminal servers), ! .Nm ! will never send any output through the port; it ! waits for a signal which never comes. ! Thus, if you have a direct line and can't seem to make ! a connection, try turning ctsrts off: * ! ppp ON tama> set line /dev/cuaa0 ppp ON tama> set speed 38400 ppp ON tama> set parity even + + ppp ON tama> set ctsrts on ppp ON tama> show modem diff -r -c ppp-2.1.5-R/vars.c ppp-new/vars.c *** ppp-2.1.5-R/vars.c Tue Jul 16 23:33:10 1996 --- ppp-new/vars.c Wed Jul 17 01:08:28 1996 *************** *** 47,53 **** }; struct pppvars pppVars = { ! DEF_MRU, 0, MODEM_SPEED, CS8, 180, 30, 3, REDIAL_PERIOD, 1, MODEM_DEV, OPEN_PASSIVE, LOCAL_NO_AUTH, }; --- 47,53 ---- }; struct pppvars pppVars = { ! DEF_MRU, 0, MODEM_SPEED, CS8, MODEM_CTSRTS, 180, 30, 3, REDIAL_PERIOD, 1, MODEM_DEV, OPEN_PASSIVE, LOCAL_NO_AUTH, }; diff -r -c ppp-2.1.5-R/vars.h ppp-new/vars.h *** ppp-2.1.5-R/vars.h Tue Jul 16 23:33:10 1996 --- ppp-new/vars.h Tue Jul 16 23:56:56 1996 *************** *** 56,61 **** --- 56,62 ---- int var_accmap; /* Initial ACCMAP value */ int modem_speed; /* Current modem speed */ int modem_parity; /* Parity setting */ + int modem_ctsrts; /* Use CTS/RTS on modem port? (boolean) */ int idle_timeout; /* Idle timeout value */ int lqr_timeout; /* LQR timeout value */ int retry_timeout; /* Retry timeout value */ *************** *** 81,86 **** --- 82,88 ---- #define VarDevice pppVars.modem_dev #define VarSpeed pppVars.modem_speed #define VarParity pppVars.modem_parity + #define VarCtsRts pppVars.modem_ctsrts #define VarOpenMode pppVars.open_mode #define VarLocalAuth pppVars.lauth #define VarDialScript pppVars.dial_script >Audit-Trail: >Unformatted: