[Simh] Question on telnet mantra in simh
Richard Cornwell
skyvis at sky-visions.com
Wed Nov 10 23:08:18 EST 2010
Hi,
Here is a patch I sent Bob back in a couple of years ago to fix
telnet support to handle correct negotiations. I am busy right now
trying to get CTSS running on my 7090 sim, or I would move it
forward to current release. Have at it, it works with Ckermit.
Rich
diff -cr sim372/sim_tmxr.c sim372f/sim_tmxr.c
*** sim372/sim_tmxr.c Fri Aug 26 22:46:50 2005
--- sim372f/sim_tmxr.c Sun Aug 12 16:13:13 2007
***************
*** 96,101 ****
--- 96,103 ----
#define TNS_WILL 002 /* WILL seen */
#define TNS_WONT 003 /* WONT seen */
#define TNS_SKIP 004 /* skip next */
+ #define TNS_DO 005 /* DO seen */
+ #define TNS_DONT 006 /* DONT seen */
void tmxr_rmvrc (TMLN *lp, int32 p);
int32 tmxr_send_buffered_data (TMLN *lp);
***************
*** 123,135 ****
int32 i;
uint32 ipaddr;
static char mantra[] = {
! TN_IAC, TN_WILL, TN_LINE,
TN_IAC, TN_WILL, TN_SGA,
TN_IAC, TN_WILL, TN_ECHO,
TN_IAC, TN_WILL, TN_BIN,
TN_IAC, TN_DO, TN_BIN
};
newsock = sim_accept_conn (mp->master, &ipaddr); /* poll connect */
if (newsock != INVALID_SOCKET) { /* got a live one? */
for (i = 0; i < mp->lines; i++) { /* find avail line */
--- 125,138 ----
int32 i;
uint32 ipaddr;
static char mantra[] = {
! TN_IAC, TN_WONT, TN_LINE,
TN_IAC, TN_WILL, TN_SGA,
TN_IAC, TN_WILL, TN_ECHO,
TN_IAC, TN_WILL, TN_BIN,
TN_IAC, TN_DO, TN_BIN
};
+
newsock = sim_accept_conn (mp->master, &ipaddr); /* poll connect */
if (newsock != INVALID_SOCKET) { /* got a live one? */
for (i = 0; i < mp->lines; i++) { /* find avail line */
***************
*** 215,220 ****
--- 218,224 ----
{
int32 i, nbytes, j;
TMLN *lp;
+ char buff[3];
for (i = 0; i < mp->lines; i++) { /* loop thru lines */
lp = mp->ldsc + i; /* get line desc */
***************
*** 270,284 ****
lp->tsta = TNS_WILL;
else if (tmp == TN_WONT) /* IAC + WONT? */
lp->tsta = TNS_WONT;
else lp->tsta = TNS_SKIP; /* IAC + other */
tmxr_rmvrc (lp, j); /* remove char */
break;
case TNS_WILL: case TNS_WONT: /* IAC+WILL/WONT prev */
! if (tmp == TN_BIN) { /* BIN? */
! if (lp->tsta == TNS_WILL) lp->dstb = 0;
else lp->dstb = 1;
! }
case TNS_SKIP: default: /* skip char */
lp->tsta = TNS_NORM; /* next normal */
--- 274,338 ----
lp->tsta = TNS_WILL;
else if (tmp == TN_WONT) /* IAC + WONT? */
lp->tsta = TNS_WONT;
+ else if (tmp == TN_DO)
+ lp->tsta = TNS_DO;
+ else if (tmp == TN_DONT)
+ lp->tsta = TNS_DONT;
else lp->tsta = TNS_SKIP; /* IAC + other */
tmxr_rmvrc (lp, j); /* remove char */
break;
+ case TNS_DO: /* Handle do */
+ buff[0] = TN_IAC;
+ buff[1] = TN_WONT;
+ buff[2] = tmp;
+ if (tmp == TN_BIN) {
+ if (!lp->dstb) {
+ lp->tsta = TNS_NORM; /* next normal */
+ tmxr_rmvrc (lp, j); /* remove char */
+ break;
+ }
+ buff[1] = TN_WILL;
+ lp->dstb = 0;
+ } else if (tmp == TN_ECHO || tmp == TN_SGA) {
+ buff[1] = TN_WILL;
+ }
+ sim_write_sock (lp->conn, buff, 3);
+ lp->tsta = TNS_NORM; /* next normal */
+ tmxr_rmvrc (lp, j); /* remove char */
+ break;
+
+ case TNS_DONT: /* Handle don't */
+ buff[0] = TN_IAC;
+ buff[1] = TN_WONT;
+ buff[2] = tmp;
+ if (tmp == TN_BIN) {
+ if (lp->dstb) {
+ lp->tsta = TNS_NORM; /* next normal */
+ tmxr_rmvrc (lp, j); /* remove char */
+ break;
+ }
+ lp->dstb = 1;
+ }
+ sim_write_sock (lp->conn, buff, 3);
+ lp->tsta = TNS_NORM; /* next normal */
+ tmxr_rmvrc (lp, j); /* remove char */
+ break;
+
case TNS_WILL: case TNS_WONT: /* IAC+WILL/WONT prev */
! buff[0] = TN_IAC;
! buff[1] = TN_DONT;
! buff[2] = tmp;
! if (tmp == TN_BIN) { /* BIN? */
! if (lp->tsta == TNS_WILL) {
! buff[1] = TN_DO;
! lp->dstb = 0;
! }
else lp->dstb = 1;
! } else if (tmp == TN_ECHO || tmp == TN_SGA) {
! buff[1] = TN_DO;
! }
! sim_write_sock (lp->conn, buff, 3);
case TNS_SKIP: default: /* skip char */
lp->tsta = TNS_NORM; /* next normal */
--
==========================================================================
Richard Cornwell
skyvis at sky-visions.com
http://sky-visions.com
==========================================================================
More information about the Simh
mailing list