TMXR fixes to support Virtual Null Modem Connections
sim_tmxr.c sim_defs.h - Fixed parsing issues with NOTELNET option. - Fixed line closing logic to drop buffered contents when line errors occur before closing link. - Fixed logic to allow bidirectional line connections (i.e. listen=1234;connect=ip:2345 on both sides of a a virtual null modem).
This commit is contained in:
parent
05707907a4
commit
fbb74de9b7
2 changed files with 29 additions and 21 deletions
|
@ -277,7 +277,7 @@ typedef uint32 t_addr;
|
||||||
|
|
||||||
/* String match - at least one character required */
|
/* String match - at least one character required */
|
||||||
|
|
||||||
#define MATCH_CMD(ptr,cmd) (*(ptr) && strncmp ((ptr), (cmd), strlen (ptr)))
|
#define MATCH_CMD(ptr,cmd) ((!*(ptr)) || strncmp ((ptr), (cmd), strlen (ptr)))
|
||||||
|
|
||||||
/* End of Linked List/Queue value */
|
/* End of Linked List/Queue value */
|
||||||
/* Chosen for 2 reasons: */
|
/* Chosen for 2 reasons: */
|
||||||
|
|
48
sim_tmxr.c
48
sim_tmxr.c
|
@ -708,11 +708,11 @@ static char mantra[] = {
|
||||||
TN_IAC, TN_DO, TN_BIN
|
TN_IAC, TN_DO, TN_BIN
|
||||||
};
|
};
|
||||||
|
|
||||||
tmxr_debug_trace (mp, "tmxr_poll_conn()");
|
|
||||||
|
|
||||||
if ((poll_time - mp->last_poll_time) < TMXR_CONNECT_POLL_INTERVAL)
|
if ((poll_time - mp->last_poll_time) < TMXR_CONNECT_POLL_INTERVAL)
|
||||||
return -1; /* */
|
return -1; /* */
|
||||||
|
|
||||||
|
tmxr_debug_trace (mp, "tmxr_poll_conn()");
|
||||||
|
|
||||||
mp->last_poll_time = poll_time;
|
mp->last_poll_time = poll_time;
|
||||||
|
|
||||||
/* Check for a pending Telnet connection */
|
/* Check for a pending Telnet connection */
|
||||||
|
@ -765,21 +765,18 @@ if (newsock != INVALID_SOCKET) { /* got a live one? */
|
||||||
for (i = 0; i < mp->lines; i++) { /* check each line in sequence */
|
for (i = 0; i < mp->lines; i++) { /* check each line in sequence */
|
||||||
lp = mp->ldsc + i; /* get pointer to line descriptor */
|
lp = mp->ldsc + i; /* get pointer to line descriptor */
|
||||||
|
|
||||||
if (0 == lp->master) { /* not listening? */
|
if (lp->connecting) { /* connecting? */
|
||||||
if (lp->connecting) { /* connecting? */
|
switch (sim_check_conn(lp->connecting, FALSE))
|
||||||
switch (sim_check_conn(lp->connecting, FALSE))
|
{
|
||||||
{
|
case 1: /* successful connection */
|
||||||
case 1: /* successful connection */
|
lp->conn = lp->connecting; /* it now looks normal */
|
||||||
lp->conn = lp->connecting; /* it now looks normal */
|
lp->connecting = 0;
|
||||||
lp->connecting = 0;
|
lp->cnms = sim_os_msec ();
|
||||||
lp->cnms = sim_os_msec ();
|
break;
|
||||||
break;
|
case -1: /* failed connection */
|
||||||
case -1: /* failed connection */
|
tmxr_reset_ln (lp); /* retry */
|
||||||
tmxr_reset_ln (lp); /* retry */
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
continue; /* skip this line */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check for a pending Telnet connection */
|
/* Check for a pending Telnet connection */
|
||||||
|
@ -803,6 +800,10 @@ for (i = 0; i < mp->lines; i++) { /* check each line in se
|
||||||
free (address);
|
free (address);
|
||||||
continue; /* Move on to next line */
|
continue; /* Move on to next line */
|
||||||
}
|
}
|
||||||
|
if (lp->connecting) {
|
||||||
|
sim_close_sock (lp->connecting, 0); /* abort our as yet unconnnected socket */
|
||||||
|
lp->connecting = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (lp->conn == 0) { /* is the line available? */
|
if (lp->conn == 0) { /* is the line available? */
|
||||||
tmxr_init_line (lp); /* init line */
|
tmxr_init_line (lp); /* init line */
|
||||||
|
@ -1089,8 +1090,10 @@ for (i = 0; i < mp->lines; i++) { /* loop thru lines */
|
||||||
nbytes = tmxr_read (lp, /* yes, read to end */
|
nbytes = tmxr_read (lp, /* yes, read to end */
|
||||||
TMXR_MAXBUF - lp->rxbpi);
|
TMXR_MAXBUF - lp->rxbpi);
|
||||||
|
|
||||||
if (nbytes < 0) /* line error? */
|
if (nbytes < 0) { /* line error? */
|
||||||
|
lp->txbpi = lp->txbpr = 0; /* Drop the data we already know we can't send */
|
||||||
tmxr_close_ln (lp); /* disconnect line */
|
tmxr_close_ln (lp); /* disconnect line */
|
||||||
|
}
|
||||||
|
|
||||||
else if (nbytes > 0) { /* if data rcvd */
|
else if (nbytes > 0) { /* if data rcvd */
|
||||||
|
|
||||||
|
@ -1316,6 +1319,7 @@ if (nbytes) { /* >0? write */
|
||||||
nbytes = nbytes - sbytes;
|
nbytes = nbytes - sbytes;
|
||||||
}
|
}
|
||||||
if (sbytes < 0) { /* I/O Error? */
|
if (sbytes < 0) { /* I/O Error? */
|
||||||
|
lp->txbpi = lp->txbpr = 0; /* Drop the data we already know we can't send */
|
||||||
tmxr_close_ln (lp); /* close line/port on error */
|
tmxr_close_ln (lp); /* close line/port on error */
|
||||||
return nbytes; /* done now. */
|
return nbytes; /* done now. */
|
||||||
}
|
}
|
||||||
|
@ -1445,7 +1449,9 @@ while (*tptr) {
|
||||||
sim_close_sock (sock, 0);
|
sim_close_sock (sock, 0);
|
||||||
else
|
else
|
||||||
return SCPE_ARG;
|
return SCPE_ARG;
|
||||||
if (cptr && (0 == MATCH_CMD (cptr, "NOTELNET")))
|
if (cptr)
|
||||||
|
get_glyph (cptr, cptr, 0); /* upcase this string */
|
||||||
|
if (0 == MATCH_CMD (cptr, "NOTELNET"))
|
||||||
notelnet = TRUE;
|
notelnet = TRUE;
|
||||||
cptr = hostport;
|
cptr = hostport;
|
||||||
}
|
}
|
||||||
|
@ -1455,7 +1461,9 @@ while (*tptr) {
|
||||||
cptr = get_glyph (gbuf, port, ';');
|
cptr = get_glyph (gbuf, port, ';');
|
||||||
if (SCPE_OK != sim_parse_addr (port, NULL, 0, NULL, NULL, 0, NULL))
|
if (SCPE_OK != sim_parse_addr (port, NULL, 0, NULL, NULL, 0, NULL))
|
||||||
return SCPE_ARG;
|
return SCPE_ARG;
|
||||||
if (cptr && (0 == MATCH_CMD (cptr, "NOTELNET")))
|
if (cptr)
|
||||||
|
get_glyph (cptr, cptr, 0); /* upcase this string */
|
||||||
|
if (0 == MATCH_CMD (cptr, "NOTELNET"))
|
||||||
listennotelnet = TRUE;
|
listennotelnet = TRUE;
|
||||||
cptr = init_cptr;
|
cptr = init_cptr;
|
||||||
}
|
}
|
||||||
|
@ -1468,7 +1476,7 @@ while (*tptr) {
|
||||||
sim_close_sock (sock, 1);
|
sim_close_sock (sock, 1);
|
||||||
strcpy(listen, port);
|
strcpy(listen, port);
|
||||||
cptr = get_glyph (cptr, option, ';');
|
cptr = get_glyph (cptr, option, ';');
|
||||||
if (option[0] && (0 == MATCH_CMD (option, "NOTELNET")))
|
if (0 == MATCH_CMD (option, "NOTELNET"))
|
||||||
listennotelnet = TRUE;
|
listennotelnet = TRUE;
|
||||||
}
|
}
|
||||||
if (line == -1) {
|
if (line == -1) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue