diff options
author | bug1 <bug1@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2004-02-22 09:45:57 +0000 |
---|---|---|
committer | bug1 <bug1@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2004-02-22 09:45:57 +0000 |
commit | 70d2f1eaf8ccae2cd81b349e735c2a59d35af365 (patch) | |
tree | bba5dd64ebfc3788b7ab3901eaeec82a1c4236cc | |
parent | 8b2aa51ddd9c0df1f0b756f9fd1da1cfd68bb1a7 (diff) | |
download | busybox-w32-70d2f1eaf8ccae2cd81b349e735c2a59d35af365.tar.gz busybox-w32-70d2f1eaf8ccae2cd81b349e735c2a59d35af365.tar.bz2 busybox-w32-70d2f1eaf8ccae2cd81b349e735c2a59d35af365.zip |
Patch from James Zhu, telnetd window resizing support.
git-svn-id: svn://busybox.net/trunk/busybox@8543 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r-- | networking/telnetd.c | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/networking/telnetd.c b/networking/telnetd.c index 3d5e8d100..3051cfa1e 100644 --- a/networking/telnetd.c +++ b/networking/telnetd.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $Id: telnetd.c,v 1.9 2003/12/19 11:30:13 andersen Exp $ | 1 | /* $Id: telnetd.c,v 1.10 2004/02/22 09:45:57 bug1 Exp $ |
2 | * | 2 | * |
3 | * Simple telnet server | 3 | * Simple telnet server |
4 | * Bjorn Wesen, Axis Communications AB (bjornw@axis.com) | 4 | * Bjorn Wesen, Axis Communications AB (bjornw@axis.com) |
@@ -27,6 +27,7 @@ | |||
27 | #include <sys/time.h> | 27 | #include <sys/time.h> |
28 | #include <sys/socket.h> | 28 | #include <sys/socket.h> |
29 | #include <sys/wait.h> | 29 | #include <sys/wait.h> |
30 | #include <sys/ioctl.h> | ||
30 | #include <string.h> | 31 | #include <string.h> |
31 | #include <stdlib.h> | 32 | #include <stdlib.h> |
32 | #include <unistd.h> | 33 | #include <unistd.h> |
@@ -140,20 +141,36 @@ remove_iacs(struct tsession *ts, int *pnum_totty) { | |||
140 | ptr++; | 141 | ptr++; |
141 | } | 142 | } |
142 | else { | 143 | else { |
143 | if ((ptr+2) < end) { | 144 | /* |
144 | /* the entire IAC is contained in the buffer | 145 | * TELOPT_NAWS support! |
145 | we were asked to process. */ | 146 | */ |
146 | #ifdef DEBUG | 147 | if ((ptr+2) >= end) { |
147 | fprintf(stderr, "Ignoring IAC %s,%s\n", | ||
148 | *ptr, TELCMD(*(ptr+1)), TELOPT(*(ptr+2))); | ||
149 | #endif | ||
150 | ptr += 3; | ||
151 | } else { | ||
152 | /* only the beginning of the IAC is in the | 148 | /* only the beginning of the IAC is in the |
153 | buffer we were asked to process, we can't | 149 | buffer we were asked to process, we can't |
154 | process this char. */ | 150 | process this char. */ |
155 | break; | 151 | break; |
156 | } | 152 | } |
153 | |||
154 | /* | ||
155 | * IAC -> SB -> TELOPT_NAWS -> 4-byte -> IAC -> SE | ||
156 | */ | ||
157 | else if (ptr[1] == SB && ptr[2] == TELOPT_NAWS) { | ||
158 | struct winsize ws; | ||
159 | if ((ptr+8) >= end) | ||
160 | break; /* incomplete, can't process */ | ||
161 | ws.ws_col = (ptr[3] << 8) | ptr[4]; | ||
162 | ws.ws_row = (ptr[5] << 8) | ptr[6]; | ||
163 | (void) ioctl(ts->ptyfd, TIOCSWINSZ, (char *)&ws); | ||
164 | ptr += 9; | ||
165 | } | ||
166 | else { | ||
167 | /* skip 3-byte IAC non-SB cmd */ | ||
168 | #ifdef DEBUG | ||
169 | fprintf(stderr, "Ignoring IAC %s,%s\n", | ||
170 | TELCMD(*(ptr+1)), TELOPT(*(ptr+2))); | ||
171 | #endif | ||
172 | ptr += 3; | ||
173 | } | ||
157 | } | 174 | } |
158 | } | 175 | } |
159 | 176 | ||
@@ -268,6 +285,7 @@ make_new_session(int sockfd) | |||
268 | */ | 285 | */ |
269 | 286 | ||
270 | send_iac(ts, DO, TELOPT_ECHO); | 287 | send_iac(ts, DO, TELOPT_ECHO); |
288 | send_iac(ts, DO, TELOPT_NAWS); | ||
271 | send_iac(ts, DO, TELOPT_LFLOW); | 289 | send_iac(ts, DO, TELOPT_LFLOW); |
272 | send_iac(ts, WILL, TELOPT_ECHO); | 290 | send_iac(ts, WILL, TELOPT_ECHO); |
273 | send_iac(ts, WILL, TELOPT_SGA); | 291 | send_iac(ts, WILL, TELOPT_SGA); |