Package: netkit-telnet
Version: 0.17
Severity: wishlist
Tags: patch


This patch is actually just a stepping stone to getting the desired 
functionality
into ssh, but I'm starting here in case peoploe still use telnet.

On high latency, congested networks, it's advantageous to do as much character
processing as possible on the local client, and only send complete lines of 
input
to the remote server. Up till now the Linux kernel has lacked the features 
needed
for full support of the RFC1184 Telnet LineMode option, but I've posted a patch
to implement the missing kernel features.

http://marc.info/?l=linux-kernel&m=127625158418585&w=2

The patches here are needed to make telnet and telnetd compile and run properly
when building with -DLINEMODE instead of -DKLUDGELINEMODE.


-- System Information:
Debian Release: squeeze/sid
  APT prefers lucid-updates
  APT policy: (500, 'lucid-updates'), (500, 'lucid-security'), (500, 'lucid')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.34-rc7 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

--
  -- Howard Chu
  CTO, Symas Corp.           http://www.symas.com
  Director, Highland Sun     http://highlandsun.com/hyc/
  Chief Architect, OpenLDAP  http://www.openldap.org/project/
diff -wur netkit-telnet-0.17/telnet/Makefile 
netkit-telnet-0.17.N/telnet/Makefile
--- netkit-telnet-0.17/telnet/Makefile  2010-06-11 04:27:14.000000000 -0700
+++ netkit-telnet-0.17.N/telnet/Makefile        2010-06-10 20:49:45.000000000 
-0700
@@ -6,7 +6,7 @@
 #CXXFLAGS:=$(patsubst -O2, -g, $(CXXFLAGS))
 
 # -DAUTHENTICATE
-CXXFLAGS += -DUSE_TERMIO -DKLUDGELINEMODE
+CXXFLAGS += -DUSE_TERMIO -DLINEMODE
 LIBS = $(LIBTERMCAP)
 
 SRCS = commands.cc main.cc network.cc ring.cc sys_bsd.cc telnet.cc \
diff -wur netkit-telnet-0.17/telnet/telnet.cc 
netkit-telnet-0.17.N/telnet/telnet.cc
--- netkit-telnet-0.17/telnet/telnet.cc 2010-06-11 04:27:14.000000000 -0700
+++ netkit-telnet-0.17.N/telnet/telnet.cc       2010-06-11 03:48:33.000000000 
-0700
@@ -895,6 +895,9 @@
   
   initfunc(SLC_EC, 0);
   initfunc(SLC_EL, 0);
+  initfunc(SLC_EW, 0);
+  initfunc(SLC_RP, 0);
+  initfunc(SLC_LNEXT, 0);
   
   initfunc(SLC_XON, 0);
   initfunc(SLC_XOFF, 0);
diff -wur netkit-telnet-0.17/telnetd/Makefile 
netkit-telnet-0.17.N/telnetd/Makefile
--- netkit-telnet-0.17/telnetd/Makefile 2010-06-11 04:27:14.000000000 -0700
+++ netkit-telnet-0.17.N/telnetd/Makefile       2010-06-11 03:20:16.000000000 
-0700
@@ -9,7 +9,7 @@
 # take out -DPARANOID_TTYS.
 
 CFLAGS += '-DISSUE_FILE="/etc/issue.net"' -DPARANOID_TTYS \
-          -DNO_REVOKE -DKLUDGELINEMODE -DDIAGNOSTICS \
+          -DNO_REVOKE -DLINEMODE -DDIAGNOSTICS \
           -DLOGIN_WRAPPER=\"/usr/lib/telnetlogin\"
 # LIBS += $(LIBTERMCAP)
 
diff -wur netkit-telnet-0.17/telnetd/slc.c netkit-telnet-0.17.N/telnetd/slc.c
--- netkit-telnet-0.17/telnetd/slc.c    1999-12-12 06:59:44.000000000 -0800
+++ netkit-telnet-0.17.N/telnetd/slc.c  2010-06-11 03:19:58.000000000 -0700
@@ -129,7 +129,7 @@
  *
  * Add an slc triplet to the slc buffer.
  */
-void add_slc(char func, char flag, cc_t val) {
+void add_slc(int func, int flag, int val) {
     add_slcbuf_char(func);
     add_slcbuf_char(flag);
     add_slcbuf_char(val);
@@ -259,7 +259,7 @@
  * Process a request to change one of our special characters.
  * Compare client's request with what we are capable of supporting.
  */
-void change_slc(char func, char flag, cc_t val) {
+void change_slc(int func, int flag, int val) {
     register int hislevel, mylevel;
     
     hislevel = flag & SLC_LEVELBITS;
diff -wur netkit-telnet-0.17/telnetd/state.c 
netkit-telnet-0.17.N/telnetd/state.c
--- netkit-telnet-0.17/telnetd/state.c  2010-06-11 04:27:14.000000000 -0700
+++ netkit-telnet-0.17.N/telnetd/state.c        2010-06-11 03:19:58.000000000 
-0700
@@ -129,8 +129,8 @@
                  * If we are operating in linemode,
                  * convert to local end-of-line.
                  */
-                if (linemode && (ncc > 0) && (('\n' == nc) ||
-                                              ((0 == nc) && tty_iscrnl())) ) {
+                if (linemode && (ncc > 0) && (('\n' == c) ||
+                                              ((0 == c) && tty_iscrnl())) ) {
                     netip++; ncc--;
                     c = '\n';
                 } 
diff -wur netkit-telnet-0.17/telnetd/sys_term.c 
netkit-telnet-0.17.N/telnetd/sys_term.c
--- netkit-telnet-0.17/telnetd/sys_term.c       2010-06-11 04:27:14.000000000 
-0700
+++ netkit-telnet-0.17.N/telnetd/sys_term.c     2010-06-11 03:19:58.000000000 
-0700
@@ -250,13 +250,13 @@
 
 void tty_setlinemode(int on) {
 #ifdef TIOCEXT
-    set_termbuf();
     ioctl(pty, TIOCEXT, (char *)&on);
-    init_termbuf();
 #else  /* !TIOCEXT */
 # ifdef        EXTPROC
+    init_termbuf();
     if (on) termbuf.c_lflag |= EXTPROC;
     else termbuf.c_lflag &= ~EXTPROC;
+    set_termbuf();
 # endif
 #endif /* TIOCEXT */
 }
@@ -413,25 +413,6 @@
 #if 0
     register int t = -1;
 
-# ifdef        LINEMODE
-    int waslm;
-# endif
-# ifdef        TIOCGWINSZ
-    struct winsize ws;
-# endif
-    /*
-     * Opening the slave side may cause initilization of the
-     * kernel tty structure.  We need remember the state of
-     *         if linemode was turned on
-     * terminal window size
-     * terminal speed
-     * so that we can re-set them if we need to.
-     */
-# ifdef        LINEMODE
-    waslm = tty_linemode();
-# endif
-
-
     /*
      * Make sure that we don't have a controlling tty, and
      * that we are the session (process group) leader.
@@ -448,11 +429,25 @@
 
     struct winsize ws;
     int t = ptyslavefd;
+# ifdef        LINEMODE
+    int waslm;
+# endif
 
     /*
      * set up the tty modes as we like them to be.
      */
     init_termbuf();
+    /*
+     * Opening the slave side may cause initilization of the
+     * kernel tty structure.  We need remember the state of
+     *         if linemode was turned on
+     * terminal window size
+     * terminal speed
+     * so that we can re-set them if we need to.
+     */
+# ifdef        LINEMODE
+    waslm = tty_linemode();
+# endif
 # ifdef        TIOCGWINSZ
     if (def_row || def_col) {
        bzero((char *)&ws, sizeof(ws));
diff -wur netkit-telnet-0.17/telnetd/termstat.c 
netkit-telnet-0.17.N/telnetd/termstat.c
--- netkit-telnet-0.17/telnetd/termstat.c       1999-12-12 06:59:45.000000000 
-0800
+++ netkit-telnet-0.17.N/telnetd/termstat.c     2010-06-11 03:19:58.000000000 
-0700
@@ -128,7 +128,6 @@
        void
 localstat()
 {
-       void netflush();
        int need_will_echo = 0;
 
        /*
diff -wur netkit-telnet-0.17/telnetd/utility.c 
netkit-telnet-0.17.N/telnetd/utility.c
--- netkit-telnet-0.17/telnetd/utility.c        2010-06-11 04:27:14.000000000 
-0700
+++ netkit-telnet-0.17.N/telnetd/utility.c      2010-06-11 03:19:58.000000000 
-0700
@@ -39,6 +39,9 @@
 
 #define PRINTOPTIONS
 
+#define _GNU_SOURCE
+#include <stdio.h>
+
 #include <stdarg.h>
 #include <sys/utsname.h>
 #include <sys/time.h>

Reply via email to