Patch from James Zhu, telnetd window resizing support.
This commit is contained in:
parent
689e4b9531
commit
90ed9a0eb6
@ -1,4 +1,4 @@
|
|||||||
/* $Id: telnetd.c,v 1.9 2003/12/19 11:30:13 andersen Exp $
|
/* $Id: telnetd.c,v 1.10 2004/02/22 09:45:57 bug1 Exp $
|
||||||
*
|
*
|
||||||
* Simple telnet server
|
* Simple telnet server
|
||||||
* Bjorn Wesen, Axis Communications AB (bjornw@axis.com)
|
* Bjorn Wesen, Axis Communications AB (bjornw@axis.com)
|
||||||
@ -27,6 +27,7 @@
|
|||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -140,20 +141,36 @@ remove_iacs(struct tsession *ts, int *pnum_totty) {
|
|||||||
ptr++;
|
ptr++;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ((ptr+2) < end) {
|
/*
|
||||||
/* the entire IAC is contained in the buffer
|
* TELOPT_NAWS support!
|
||||||
we were asked to process. */
|
*/
|
||||||
#ifdef DEBUG
|
if ((ptr+2) >= end) {
|
||||||
fprintf(stderr, "Ignoring IAC %s,%s\n",
|
|
||||||
*ptr, TELCMD(*(ptr+1)), TELOPT(*(ptr+2)));
|
|
||||||
#endif
|
|
||||||
ptr += 3;
|
|
||||||
} else {
|
|
||||||
/* only the beginning of the IAC is in the
|
/* only the beginning of the IAC is in the
|
||||||
buffer we were asked to process, we can't
|
buffer we were asked to process, we can't
|
||||||
process this char. */
|
process this char. */
|
||||||
break;
|
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 @@ make_new_session(int sockfd)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
send_iac(ts, DO, TELOPT_ECHO);
|
send_iac(ts, DO, TELOPT_ECHO);
|
||||||
|
send_iac(ts, DO, TELOPT_NAWS);
|
||||||
send_iac(ts, DO, TELOPT_LFLOW);
|
send_iac(ts, DO, TELOPT_LFLOW);
|
||||||
send_iac(ts, WILL, TELOPT_ECHO);
|
send_iac(ts, WILL, TELOPT_ECHO);
|
||||||
send_iac(ts, WILL, TELOPT_SGA);
|
send_iac(ts, WILL, TELOPT_SGA);
|
||||||
|
Loading…
Reference in New Issue
Block a user