Fix up the code that deals with the
authorDave A. Borman <dab@ucbvax.Berkeley.EDU>
Wed, 20 Jan 1993 04:47:21 +0000 (20:47 -0800)
committerDave A. Borman <dab@ucbvax.Berkeley.EDU>
Wed, 20 Jan 1993 04:47:21 +0000 (20:47 -0800)
flowcontrol option to properly deal with the
RESTART_ANY and RESTART_XON suboptions.

SCCS-vsn: libexec/telnetd/telnetd.c 5.50
SCCS-vsn: libexec/telnetd/termstat.c 5.12
SCCS-vsn: libexec/telnetd/utility.c 5.10
SCCS-vsn: libexec/telnetd/state.c 5.12
SCCS-vsn: libexec/telnetd/sys_term.c 5.19

usr/src/libexec/telnetd/state.c
usr/src/libexec/telnetd/sys_term.c
usr/src/libexec/telnetd/telnetd.c
usr/src/libexec/telnetd/termstat.c
usr/src/libexec/telnetd/utility.c

index e8ede0e..1a34b4f 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)state.c    5.11 (Berkeley) %G%";
+static char sccsid[] = "@(#)state.c    5.12 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "telnetd.h"
 #endif /* not lint */
 
 #include "telnetd.h"
@@ -618,6 +618,9 @@ willoption(option)
                        func = encrypt_send_support;
                        break;
 #endif
                        func = encrypt_send_support;
                        break;
 #endif
+               case TELOPT_LFLOW:
+                       func = localstat;
+                       break;
                }
            }
        }
                }
            }
        }
index 9e502fb..e2cfa10 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)sys_term.c 5.18 (Berkeley) %G%";
+static char sccsid[] = "@(#)sys_term.c 5.19 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "telnetd.h"
 #endif /* not lint */
 
 #include "telnetd.h"
@@ -554,7 +554,7 @@ tty_flowmode()
 #ifndef USE_TERMIO
        return(((termbuf.tc.t_startc) > 0 && (termbuf.tc.t_stopc) > 0) ? 1 : 0);
 #else
 #ifndef USE_TERMIO
        return(((termbuf.tc.t_startc) > 0 && (termbuf.tc.t_stopc) > 0) ? 1 : 0);
 #else
-       return(termbuf.c_iflag & IXON ? 1 : 0);
+       return((termbuf.c_iflag & IXON) ? 1 : 0);
 #endif
 }
 
 #endif
 }
 
@@ -568,7 +568,7 @@ tty_restartany()
        return(-1);
 # endif
 #else
        return(-1);
 # endif
 #else
-       return(termbuf.c_iflag & IXANY ? 1 : 0);
+       return((termbuf.c_iflag & IXANY) ? 1 : 0);
 #endif
 }
 
 #endif
 }
 
index 89705e3..dedb529 100644 (file)
@@ -12,7 +12,7 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)telnetd.c  5.49 (Berkeley) %G%";
+static char sccsid[] = "@(#)telnetd.c  5.50 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "telnetd.h"
 #endif /* not lint */
 
 #include "telnetd.h"
@@ -826,7 +826,8 @@ telnet(f, p, host)
         */
        send_do(TELOPT_NAWS, 1);
        send_will(TELOPT_STATUS, 1);
         */
        send_do(TELOPT_NAWS, 1);
        send_will(TELOPT_STATUS, 1);
-       flowmode = 1;  /* default flow control state */
+       flowmode = 1;           /* default flow control state */
+       restartany = -1;        /* uninitialized... */
        send_do(TELOPT_LFLOW, 1);
 
        /*
        send_do(TELOPT_LFLOW, 1);
 
        /*
@@ -1188,11 +1189,18 @@ telnet(f, p, host)
                                if (his_state_is_will(TELOPT_LFLOW) &&
                                    (ptyibuf[0] &
                                     (TIOCPKT_NOSTOP|TIOCPKT_DOSTOP))) {
                                if (his_state_is_will(TELOPT_LFLOW) &&
                                    (ptyibuf[0] &
                                     (TIOCPKT_NOSTOP|TIOCPKT_DOSTOP))) {
-                                       (void) sprintf(nfrontp, "%c%c%c%c%c%c",
-                                           IAC, SB, TELOPT_LFLOW,
-                                           ptyibuf[0] & TIOCPKT_DOSTOP ? 1 : 0,
-                                           IAC, SE);
-                                       nfrontp += 6;
+                                       int newflow =
+                                           ptyibuf[0] & TIOCPKT_DOSTOP ? 1 : 0;
+                                       if (newflow != flowmode) {
+                                               flowmode = newflow;
+                                               (void) sprintf(nfrontp,
+                                                       "%c%c%c%c%c%c",
+                                                       IAC, SB, TELOPT_LFLOW,
+                                                       flowmode ? LFLOW_ON
+                                                                : LFLOW_OFF,
+                                                       IAC, SE);
+                                               nfrontp += 6;
+                                       }
                                }
                                pcc--;
                                ptyip = ptyibuf+1;
                                }
                                pcc--;
                                ptyip = ptyibuf+1;
index 01a2cc6..f5be6ad 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)termstat.c 5.11 (Berkeley) %G%";
+static char sccsid[] = "@(#)termstat.c 5.12 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "telnetd.h"
 #endif /* not lint */
 
 #include "telnetd.h"
@@ -142,18 +142,19 @@ localstat()
        if (his_state_is_will(TELOPT_LFLOW)) {
                if (tty_flowmode() != flowmode) {
                        flowmode = tty_flowmode();
        if (his_state_is_will(TELOPT_LFLOW)) {
                if (tty_flowmode() != flowmode) {
                        flowmode = tty_flowmode();
-                       (void) sprintf(nfrontp, "%c%c%c%c%c%c", IAC, SB,
-                               TELOPT_LFLOW, flowmode ? LFLOW_ON : LFLOW_OFF,
-                               IAC, SE);
+                       (void) sprintf(nfrontp, "%c%c%c%c%c%c",
+                                       IAC, SB, TELOPT_LFLOW,
+                                       flowmode ? LFLOW_ON : LFLOW_OFF,
+                                       IAC, SE);
                        nfrontp += 6;
                        nfrontp += 6;
+               }
+               if (tty_restartany() != restartany) {
                        restartany = tty_restartany();
                        restartany = tty_restartany();
-                       if (restartany >= 0) {
-                               (void) sprintf(nfrontp, "%c%c%c%c%c%c",
+                       (void) sprintf(nfrontp, "%c%c%c%c%c%c",
                                        IAC, SB, TELOPT_LFLOW,
                                        restartany ? LFLOW_RESTART_ANY
                                                   : LFLOW_RESTART_XON,
                                        IAC, SE);
                                        IAC, SB, TELOPT_LFLOW,
                                        restartany ? LFLOW_RESTART_ANY
                                                   : LFLOW_RESTART_XON,
                                        IAC, SE);
-                       }
                        nfrontp += 6;
                }
        }
                        nfrontp += 6;
                }
        }
index 12807ec..a4d80e8 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)utility.c  5.9 (Berkeley) %G%";
+static char sccsid[] = "@(#)utility.c  5.10 (Berkeley) %G%";
 #endif /* not lint */
 
 #define PRINTOPTIONS
 #endif /* not lint */
 
 #define PRINTOPTIONS
@@ -587,10 +587,14 @@ printsub(direction, pointer, length)
                break;
            }
            switch (pointer[1]) {
                break;
            }
            switch (pointer[1]) {
-           case 0:
+           case LFLOW_OFF:
                sprintf(nfrontp, " OFF"); break;
                sprintf(nfrontp, " OFF"); break;
-           case 1:
+           case LFLOW_ON:
                sprintf(nfrontp, " ON"); break;
                sprintf(nfrontp, " ON"); break;
+           case LFLOW_RESTART_ANY:
+               sprintf(nfrontp, " RESTART-ANY"); break;
+           case LFLOW_RESTART_XON:
+               sprintf(nfrontp, " RESTART-XON"); break;
            default:
                sprintf(nfrontp, " %d (unknown)", pointer[1]);
            }
            default:
                sprintf(nfrontp, " %d (unknown)", pointer[1]);
            }