[BusyBox-cvs] busybox/networking telnetd.c,1.9,1.10
Glenn McGrath
bug1 at busybox.net
Sun Feb 22 09:46:00 UTC 2004
Update of /var/cvs/busybox/networking
In directory nail:/tmp/cvs-serv1507/networking
Modified Files:
telnetd.c
Log Message:
Patch from James Zhu, telnetd window resizing support.
Index: telnetd.c
===================================================================
RCS file: /var/cvs/busybox/networking/telnetd.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- a/telnetd.c 19 Dec 2003 11:30:13 -0000 1.9
+++ b/telnetd.c 22 Feb 2004 09:45:57 -0000 1.10
@@ -27,6 +27,7 @@
#include <sys/time.h>
#include <sys/socket.h>
#include <sys/wait.h>
+#include <sys/ioctl.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
@@ -140,20 +141,36 @@
ptr++;
}
else {
- if ((ptr+2) < end) {
- /* the entire IAC is contained in the buffer
- we were asked to process. */
-#ifdef DEBUG
- fprintf(stderr, "Ignoring IAC %s,%s\n",
- *ptr, TELCMD(*(ptr+1)), TELOPT(*(ptr+2)));
-#endif
- ptr += 3;
- } else {
+ /*
+ * TELOPT_NAWS support!
+ */
+ if ((ptr+2) >= end) {
/* only the beginning of the IAC is in the
buffer we were asked to process, we can't
process this char. */
break;
}
+
+ /*
+ * IAC -> SB -> TELOPT_NAWS -> 4-byte -> IAC -> SE
+ */
+ else if (ptr[1] == SB && ptr[2] == TELOPT_NAWS) {
+ struct winsize ws;
+ if ((ptr+8) >= end)
+ break; /* incomplete, can't process */
+ ws.ws_col = (ptr[3] << 8) | ptr[4];
+ ws.ws_row = (ptr[5] << 8) | ptr[6];
+ (void) ioctl(ts->ptyfd, TIOCSWINSZ, (char *)&ws);
+ ptr += 9;
+ }
+ else {
+ /* skip 3-byte IAC non-SB cmd */
+#ifdef DEBUG
+ fprintf(stderr, "Ignoring IAC %s,%s\n",
+ TELCMD(*(ptr+1)), TELOPT(*(ptr+2)));
+#endif
+ ptr += 3;
+ }
}
}
@@ -268,6 +285,7 @@
*/
send_iac(ts, DO, TELOPT_ECHO);
+ send_iac(ts, DO, TELOPT_NAWS);
send_iac(ts, DO, TELOPT_LFLOW);
send_iac(ts, WILL, TELOPT_ECHO);
send_iac(ts, WILL, TELOPT_SGA);
More information about the busybox-cvs
mailing list