Get ready for SO_OOBINLINE; Handle TELNET BREAK distinct from TELNET IP.
authorGregory Minshall <minshall@ucbvax.Berkeley.EDU>
Mon, 21 Apr 1986 12:30:53 +0000 (04:30 -0800)
committerGregory Minshall <minshall@ucbvax.Berkeley.EDU>
Mon, 21 Apr 1986 12:30:53 +0000 (04:30 -0800)
SCCS-vsn: libexec/telnetd/telnetd.c 5.12

usr/src/libexec/telnetd/telnetd.c

index 54b867e..67bb2c3 100644 (file)
@@ -11,7 +11,7 @@ char copyright[] =
 #endif not lint
 
 #ifndef lint
 #endif not lint
 
 #ifndef lint
-static char sccsid[] = "@(#)telnetd.c  5.11 (Berkeley) %G%";
+static char sccsid[] = "@(#)telnetd.c  5.12 (Berkeley) %G%";
 #endif not lint
 
 /*
 #endif not lint
 
 /*
@@ -274,6 +274,9 @@ telnet(f, p)
        net = f, pty = p;
        ioctl(f, FIONBIO, &on);
        ioctl(p, FIONBIO, &on);
        net = f, pty = p;
        ioctl(f, FIONBIO, &on);
        ioctl(p, FIONBIO, &on);
+#if    defined(xxxSO_OOBINLINE)
+       setsockopt(net, SOL_SOCKET, SO_OOBINLINE, on, sizeof on);
+#endif /* defined(xxxSO_OOBINLINE) */
        signal(SIGTSTP, SIG_IGN);
        signal(SIGCHLD, cleanup);
        setpgrp(0, 0);
        signal(SIGTSTP, SIG_IGN);
        signal(SIGCHLD, cleanup);
        setpgrp(0, 0);
@@ -338,7 +341,7 @@ telnet(f, p)
                 * Something to read from the network...
                 */
                if (FD_ISSET(net, &ibits)) {
                 * Something to read from the network...
                 */
                if (FD_ISSET(net, &ibits)) {
-#if    !defined(IOCTL_TO_DO_UNIX_OOB_IN_TCP_WAY)
+#if    !defined(xxxSO_OOBINLINE)
                        /*
                         * In 4.2 (and some early 4.3) systems, the
                         * OOB indication and data handling in the kernel
                        /*
                         * In 4.2 (and some early 4.3) systems, the
                         * OOB indication and data handling in the kernel
@@ -392,9 +395,9 @@ telnet(f, p)
                        ncc = read(net, netibuf, sizeof (netibuf));
                    }
                    settimer(didnetreceive);
                        ncc = read(net, netibuf, sizeof (netibuf));
                    }
                    settimer(didnetreceive);
-#else  /* !defined(IOCTL_TO_DO_UNIX_OOB_IN_TCP_WAY) */
+#else  /* !defined(xxxSO_OOBINLINE)) */
                    ncc = read(net, netibuf, sizeof (netibuf));
                    ncc = read(net, netibuf, sizeof (netibuf));
-#endif /* !defined(IOCTL_TO_DO_UNIX_OOB_IN_TCP_WAY) */
+#endif /* !defined(xxxSO_OOBINLINE)) */
                    if (ncc < 0 && errno == EWOULDBLOCK)
                        ncc = 0;
                    else {
                    if (ncc < 0 && errno == EWOULDBLOCK)
                        ncc = 0;
                    else {
@@ -508,11 +511,14 @@ telrcv()
                         * interrupt.  Do this with a NULL or
                         * interrupt char; depending on the tty mode.
                         */
                         * interrupt.  Do this with a NULL or
                         * interrupt char; depending on the tty mode.
                         */
-                       case BREAK:
                        case IP:
                                interrupt();
                                break;
 
                        case IP:
                                interrupt();
                                break;
 
+                       case BREAK:
+                               sendbrk();
+                               break;
+
                        /*
                         * Are You There?
                         */
                        /*
                         * Are You There?
                         */
@@ -767,6 +773,26 @@ interrupt()
                '\177' : tchars.t_intrc;
 }
 
                '\177' : tchars.t_intrc;
 }
 
+/*
+ * Send quit to process on other side of pty.
+ * If it is in raw mode, just write NULL;
+ * otherwise, write quit char.
+ */
+sendbrk()
+{
+       struct sgttyb b;
+       struct tchars tchars;
+
+       ptyflush();     /* half-hearted */
+       ioctl(pty, TIOCGETP, &b);
+       if (b.sg_flags & RAW) {
+               *pfrontp++ = '\0';
+               return;
+       }
+       *pfrontp++ = ioctl(pty, TIOCGETC, &tchars) < 0 ?
+               '\034' : tchars.t_quitc;
+}
+
 ptyflush()
 {
        int n;
 ptyflush()
 {
        int n;