mirror of
https://github.com/prirun/p50em.git
synced 2026-03-10 12:18:24 +00:00
Re-add Kermit telnet negotiation, but leave it disabled
This commit is contained in:
115
devamlc.h
115
devamlc.h
@@ -139,6 +139,22 @@ int devamlc (int class, int func, int device) {
|
||||
#define TS_SUBOPT 2 /* inside a suboption */
|
||||
#define TS_OPTION 3 /* inside an option */
|
||||
|
||||
/* telnet protocol special characters */
|
||||
|
||||
#define TN_IAC 255
|
||||
#define TN_WILL 251
|
||||
#define TN_WONT 252
|
||||
#define TN_DO 253
|
||||
#define TN_DONT 254
|
||||
|
||||
/* telnet options */
|
||||
|
||||
#define TN_BINARY 0
|
||||
#define TN_ECHO 1
|
||||
#define TN_SGA 3 /* means this is a full-duplex connection */
|
||||
#define TN_KERMIT 47
|
||||
#define TN_SUBOPT 250
|
||||
|
||||
static short inited = 0;
|
||||
static int pollspeedup = 1;
|
||||
static int baudtable[16] = {1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200};
|
||||
@@ -191,7 +207,7 @@ int devamlc (int class, int func, int device) {
|
||||
fd_set fds;
|
||||
struct timeval timeout;
|
||||
unsigned char ch;
|
||||
int state;
|
||||
int tstate, toper;
|
||||
int msgfd;
|
||||
int allbusy;
|
||||
unsigned short qtop, qbot, qtemp;
|
||||
@@ -805,15 +821,15 @@ endconnect:
|
||||
methods, this stuff might be better off in a very thin
|
||||
connection server */
|
||||
|
||||
buf[0] = 255; /* IAC */
|
||||
buf[1] = 251; /* will */
|
||||
buf[2] = 1; /* echo */
|
||||
buf[3] = 255; /* IAC */
|
||||
buf[4] = 251; /* will */
|
||||
buf[5] = 3; /* supress go ahead */
|
||||
buf[6] = 255; /* IAC */
|
||||
buf[7] = 253; /* do */
|
||||
buf[8] = 0; /* binary mode */
|
||||
buf[0] = TN_IAC;
|
||||
buf[1] = TN_WILL;
|
||||
buf[2] = TN_ECHO;
|
||||
buf[3] = TN_IAC;
|
||||
buf[4] = TN_WILL;
|
||||
buf[5] = TN_SGA;
|
||||
buf[6] = TN_IAC;
|
||||
buf[7] = TN_DO;
|
||||
buf[8] = TN_BINARY;
|
||||
write(fd, buf, 9);
|
||||
|
||||
/* send out the ttymsg greeting */
|
||||
@@ -1031,13 +1047,13 @@ endconnect:
|
||||
|
||||
if (n > 0) {
|
||||
//printf("devamlc: RECV dx=%d, lx=%d, b=%d, tried=%d, read=%d\n", dx, lx, dc[dx].bufnum, n2, n);
|
||||
state = dc[dx].tstate[lx];
|
||||
tstate = dc[dx].tstate[lx];
|
||||
for (i=0; i<n; i++) {
|
||||
ch = buf[i];
|
||||
switch (state) {
|
||||
switch (tstate) {
|
||||
case TS_DATA:
|
||||
if (ch == 255 && (dc[dx].ctype[lx] == CT_SOCKET || dc[dx].ctype[lx] == CT_DEDIP))
|
||||
state = TS_IAC;
|
||||
if (ch == TN_IAC && (dc[dx].ctype[lx] == CT_SOCKET || dc[dx].ctype[lx] == CT_DEDIP))
|
||||
tstate = TS_IAC;
|
||||
else {
|
||||
storech:
|
||||
utempa = lx<<12 | 0x0200 | ch;
|
||||
@@ -1049,32 +1065,75 @@ endconnect:
|
||||
break;
|
||||
case TS_IAC:
|
||||
switch (ch) {
|
||||
case 255:
|
||||
state = TS_DATA;
|
||||
case TN_IAC:
|
||||
tstate = TS_DATA;
|
||||
goto storech;
|
||||
case 251: /* will */
|
||||
case 252: /* won't */
|
||||
case 253: /* do */
|
||||
case 254: /* don't */
|
||||
state = TS_OPTION;
|
||||
case TN_WILL:
|
||||
case TN_WONT:
|
||||
case TN_DO:
|
||||
case TN_DONT:
|
||||
//printf("\nReceived command %d\n", ch);
|
||||
tstate = TS_OPTION;
|
||||
toper = ch;
|
||||
break;
|
||||
case 250: /* begin suboption */
|
||||
state = TS_SUBOPT;
|
||||
case TN_SUBOPT:
|
||||
//printf("\nReceived SUBOPT command\n");
|
||||
tstate = TS_SUBOPT;
|
||||
break;
|
||||
default: /* ignore other chars after IAC */
|
||||
state = TS_DATA;
|
||||
//printf("\nReceived unknown IAC command %d\n", ch);
|
||||
tstate = TS_DATA;
|
||||
}
|
||||
break;
|
||||
case TS_SUBOPT:
|
||||
if (ch == 255)
|
||||
state = TS_IAC;
|
||||
//printf("\nsubopt received %d\n", ch);
|
||||
if (ch == TN_IAC)
|
||||
tstate = TS_IAC;
|
||||
break;
|
||||
case TS_OPTION:
|
||||
#if 0
|
||||
//printf("\nReceived option %d\n", ch);
|
||||
if (toper == TN_WILL) {
|
||||
if (ch == TN_SGA || ch == TN_BINARY)
|
||||
;
|
||||
else if (ch == TN_KERMIT) {
|
||||
buf[0] = TN_IAC;
|
||||
buf[1] = TN_DO;
|
||||
buf[2] = ch;
|
||||
//printf("Sending DO %d\n", ch);
|
||||
write(fd, buf, 3);
|
||||
} else {
|
||||
buf[0] = TN_IAC;
|
||||
buf[1] = TN_DONT;
|
||||
buf[2] = ch;
|
||||
//printf("Sending DONT %d\n", ch);
|
||||
write(fd, buf, 3);
|
||||
}
|
||||
} else if (toper == TN_DO) {
|
||||
if (toper == TN_ECHO)
|
||||
;
|
||||
else if (0 && ch == TN_KERMIT) {
|
||||
buf[0] = TN_IAC;
|
||||
buf[1] = TN_WILL;
|
||||
buf[2] = ch;
|
||||
//printf("Sending WILL %d\n", ch);
|
||||
write(fd, buf, 3);
|
||||
} else {
|
||||
buf[0] = TN_IAC;
|
||||
buf[1] = TN_WONT;
|
||||
buf[2] = ch;
|
||||
//printf("Sending WONT %d\n", ch);
|
||||
write(fd, buf, 3);
|
||||
}
|
||||
}
|
||||
tstate = TS_DATA;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
state = TS_DATA;
|
||||
tstate = TS_DATA;
|
||||
}
|
||||
}
|
||||
dc[dx].tstate[lx] = state;
|
||||
dc[dx].tstate[lx] = tstate;
|
||||
}
|
||||
}
|
||||
lx = (lx+1) & 0xF;
|
||||
|
||||
Reference in New Issue
Block a user