Changed handshake and EMSI timers

This commit is contained in:
Michiel Broek 2003-08-23 21:15:16 +00:00
parent c519afe9dc
commit 4bd3c7dcde
3 changed files with 322 additions and 240 deletions

View File

@ -3,7 +3,15 @@ $Id$
WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
Inbound file handling is changed, this version is under test and should NOT Inbound file handling is changed, this version is under test and should NOT
be used on production systems be used on production systems if you don't want to help debugging.
Handshake and EMSI is changed, please run this version with debugging on,
mbsetup 1.14.1 turn 5, 11 and 18 on at least. Report any problems and include
a piece of the logfile.
Before installing, make a copy of /opt/mbse/bin/mbcico so you can go back
if you experience any problems.
As far as I have tested, there should be no problems with this version.
WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !! WARNING !!
@ -29,6 +37,11 @@ v0.37.6 10-Aug-2003
systems. systems.
Fixed the binkp escape sequence which is wrong in the FSP. Fixed the binkp escape sequence which is wrong in the FSP.
A light improvement in session handshake setup timers. A light improvement in session handshake setup timers.
Added EMSI handshake timers, this gives a more relaxed EMSI
handshake.
Set the EMSI receive failure count to 20 instead of 6, we can
now even accept buggy maindoor sessions and still display a
banner.
v0.37.5 12-Jul-2003 - 10-Aug-2003 v0.37.5 12-Jul-2003 - 10-Aug-2003

View File

@ -271,6 +271,7 @@ int tx_emsi(char *data)
SM_DECL(rxemsi,(char *)"rxemsi") SM_DECL(rxemsi,(char *)"rxemsi")
SM_STATES SM_STATES
init,
waitpkt, waitpkt,
waitchar, waitchar,
checkemsi, checkemsi,
@ -280,6 +281,7 @@ SM_STATES
sendnak, sendnak,
sendack sendack
SM_NAMES SM_NAMES
(char *)"init",
(char *)"waitpkt", (char *)"waitpkt",
(char *)"waitchar", (char *)"waitchar",
(char *)"checkemsi", (char *)"checkemsi",
@ -300,24 +302,40 @@ SM_EDECL
p = buf; p = buf;
databuf = xstrcpy(intro); databuf = xstrcpy(intro);
SM_START(checkpkt) SM_START(init)
Syslog('i', "RXEMSI: start");
SM_STATE(init)
Syslog('i', "RXEMSI: init");
RESETTIMERS();
SETTIMER(0, 60);
SETTIMER(1, 20);
SM_PROCEED(checkpkt);
SM_STATE(waitpkt) SM_STATE(waitpkt)
Syslog('i', "RXEMSI: waitpkt");
standby = 0; standby = 0;
SETTIMER(1, 20);
SM_PROCEED(waitchar); SM_PROCEED(waitchar);
SM_STATE(waitchar) SM_STATE(waitchar)
c = GETCHAR(5); Syslog('i', "RXEMSI: waitchar, tries=%d", tries);
if (c == TIMEOUT) {
if (++tries > 9) { if (EXPIRED(0)) {
Syslog('+', "Too many tries waiting EMSI handshake"); Syslog('+', "EMSI receive 60 seconds timeout");
SM_ERROR; SM_ERROR;
} else { }
if (EXPIRED(1)) {
Syslog('s', "20 sec timeout");
SM_PROCEED(sendnak); SM_PROCEED(sendnak);
} }
c = GETCHAR(1);
if (c == TIMEOUT) {
SM_PROCEED(waitchar);
} else if (c < 0) { } else if (c < 0) {
SM_ERROR; SM_ERROR;
} else if ((c >= ' ') && (c <= '~')) { } else if ((c >= ' ') && (c <= '~')) {
@ -334,7 +352,8 @@ SM_STATE(waitchar)
SM_PROCEED(checkemsi); SM_PROCEED(checkemsi);
} }
} }
} else switch(c) { } else {
switch(c) {
case DC1: break; case DC1: break;
case '\n': case '\n':
case '\r': standby = 0; case '\r': standby = 0;
@ -342,7 +361,7 @@ SM_STATE(waitchar)
default: standby = 0; default: standby = 0;
break; break;
} }
}
SM_PROCEED(waitchar); SM_PROCEED(waitchar);
SM_STATE(checkemsi) SM_STATE(checkemsi)
@ -391,6 +410,8 @@ SM_STATE(getdat)
SM_STATE(checkpkt) SM_STATE(checkpkt)
Syslog('i', "RXEMSI: checkpkt");
if (strncasecmp(databuf,"EMSI_DAT",8) == 0) { if (strncasecmp(databuf,"EMSI_DAT",8) == 0) {
SM_PROCEED(checkdat); SM_PROCEED(checkdat);
} }
@ -435,7 +456,12 @@ SM_STATE(checkdat)
SM_STATE(sendnak) SM_STATE(sendnak)
if (++tries > 9) { /*
* The FSC-0059 says 6 attempts, but to accept maindoor sessions
* we seem to need about 11, we set it to 20 since we also have
* a global 60 seconds timer running.
*/
if (++tries > 19) {
Syslog('+', "Too many tries getting EMSI_DAT"); Syslog('+', "Too many tries getting EMSI_DAT");
SM_ERROR; SM_ERROR;
} if (caller) { } if (caller) {
@ -491,6 +517,9 @@ SM_EDECL
p = buf; p = buf;
memset(&buf, 0, sizeof(buf)); memset(&buf, 0, sizeof(buf));
strncpy(buf, intro, sizeof(buf) - 1); strncpy(buf, intro, sizeof(buf) - 1);
RESETTIMERS();
SETTIMER(0, 60);
Syslog('i', "TXEMSI: 60 seconds timer set");
SM_START(senddata) SM_START(senddata)
Syslog('i', "TXEMSI: start"); Syslog('i', "TXEMSI: start");
@ -505,6 +534,7 @@ SM_STATE(senddata)
PUTSTR(trailer); PUTSTR(trailer);
Syslog('i', "TXEMSI: send **%s%04X", p, crc16xmodem(p, strlen(p))); Syslog('i', "TXEMSI: send **%s%04X", p, crc16xmodem(p, strlen(p)));
free(p); free(p);
SETTIMER(1, 20);
SM_PROCEED(waitpkt); SM_PROCEED(waitpkt);
SM_STATE(waitpkt) SM_STATE(waitpkt)
@ -514,14 +544,24 @@ SM_STATE(waitpkt)
SM_STATE(waitchar) SM_STATE(waitchar)
c = GETCHAR(8); if (EXPIRED(0)) {
if (c == TIMEOUT) { Syslog('+', "EMSI transmit 60 seconds timeout");
if (++tries > 9) { SM_ERROR;
}
if (EXPIRED(1)) {
Syslog('i', "TXEMSI: 20 seconds timeout");
if (++tries > 19) {
Syslog('+', "too many tries sending EMSI"); Syslog('+', "too many tries sending EMSI");
SM_ERROR; SM_ERROR;
} else { } else {
SM_PROCEED(senddata); SM_PROCEED(senddata);
} }
}
c = GETCHAR(1);
if (c == TIMEOUT) {
SM_PROCEED(waitchar);
} else if (c < 0) { } else if (c < 0) {
SM_ERROR; SM_ERROR;
} else if ((c >= ' ') && (c <= '~')) { } else if ((c >= ' ') && (c <= '~')) {
@ -538,7 +578,8 @@ SM_STATE(waitchar)
SM_PROCEED(checkpkt); SM_PROCEED(checkpkt);
} }
} }
} else switch(c) { } else
switch(c) {
case DC1: SM_PROCEED(waitchar); case DC1: SM_PROCEED(waitchar);
break; break;
case '\n': case '\n':

View File

@ -388,12 +388,14 @@ SM_RETURN
SM_DECL(rx_define_type,(char *)"rx_define_type") SM_DECL(rx_define_type,(char *)"rx_define_type")
SM_STATES SM_STATES
sendintro, sendintro,
settimer,
waitchar, waitchar,
nextchar, nextchar,
checkemsi, checkemsi,
getdat getdat
SM_NAMES SM_NAMES
(char *)"sendintro", (char *)"sendintro",
(char *)"settimer",
(char *)"waitchar", (char *)"waitchar",
(char *)"nextchar", (char *)"nextchar",
(char *)"checkemsi", (char *)"checkemsi",
@ -413,17 +415,19 @@ SM_EDECL
ep=ebuf; ep=ebuf;
RESETTIMERS(); RESETTIMERS();
SETTIMER(0, 60); SETTIMER(0, 60);
SETTIMER(1, 20);
SM_START(sendintro) SM_START(sendintro)
SM_STATE(sendintro) SM_STATE(sendintro)
Syslog('s', "rxdefine_type SENDINTRO count=%d", count);
if (count++ > 6) { if (count++ > 6) {
Syslog('+', "Too many tries to get anything from the caller"); Syslog('+', "Too many tries to get anything from the caller");
SM_ERROR; SM_ERROR;
} }
Syslog('s', "rxdefine_type SENDINTRO count=%d", count);
standby = 0; standby = 0;
ep = ebuf; ep = ebuf;
ebuf[0] = '\0'; ebuf[0] = '\0';
@ -447,9 +451,15 @@ SM_STATE(sendintro)
if (STATUS) { if (STATUS) {
SM_ERROR; SM_ERROR;
} else { } else {
SM_PROCEED(waitchar); SM_PROCEED(settimer);
} }
SM_STATE(settimer)
Syslog('s', "Set 20 secs timer");
SETTIMER(1, 20);
SM_PROCEED(waitchar);
SM_STATE(waitchar) SM_STATE(waitchar)
if (EXPIRED(0)) { if (EXPIRED(0)) {
@ -457,8 +467,13 @@ SM_STATE(waitchar)
SM_ERROR; SM_ERROR;
} }
if ((c = GETCHAR(20)) == TIMEOUT) { if (EXPIRED(1)) {
Syslog('s', "20 sec timer timeout");
SM_PROCEED(sendintro); SM_PROCEED(sendintro);
}
if ((c = GETCHAR(1)) == TIMEOUT) {
SM_PROCEED(waitchar);
} else if (c < 0) { } else if (c < 0) {
Syslog('+', "Session setup error"); Syslog('+', "Session setup error");
SM_ERROR; SM_ERROR;
@ -515,7 +530,18 @@ SM_STATE(nextchar)
if (ebuf[0]) { if (ebuf[0]) {
SM_PROCEED(checkemsi); SM_PROCEED(checkemsi);
} else { } else {
/*
* If the 20 second timer is expired or after the
* first sendintro, send the intro again. After
* that take it easy.
*/
if (EXPIRED(1) || (count == 1)) {
Syslog('s', "sendintro after eol char");
SM_PROCEED(sendintro); SM_PROCEED(sendintro);
} else {
Syslog('s', "waitchar after eol char");
SM_PROCEED(waitchar);
}
} }
break; break;
default: standby = 0; default: standby = 0;
@ -532,6 +558,7 @@ SM_STATE(checkemsi)
Syslog('i', "check \"%s\" for being EMSI inquery or data",ebuf); Syslog('i', "check \"%s\" for being EMSI inquery or data",ebuf);
if (localoptions & NOEMSI) { if (localoptions & NOEMSI) {
Syslog('s', "Force sendintro");
SM_PROCEED(sendintro); SM_PROCEED(sendintro);
} }
@ -543,11 +570,11 @@ SM_STATE(checkemsi)
standby = 0; standby = 0;
ep = ebuf; ep = ebuf;
ebuf[0] = '\0'; ebuf[0] = '\0';
SM_PROCEED(waitchar); SM_PROCEED(settimer);
} else if (strncasecmp(ebuf, "EMSI_DAT", 8) == 0) { } else if (strncasecmp(ebuf, "EMSI_DAT", 8) == 0) {
SM_PROCEED(getdat); SM_PROCEED(getdat);
} else { } else {
SM_PROCEED(sendintro); SM_PROCEED(settimer);
} }
SM_STATE(getdat) SM_STATE(getdat)
@ -569,6 +596,7 @@ SM_STATE(getdat)
*p= '\0'; *p= '\0';
} }
if (c == TIMEOUT) { if (c == TIMEOUT) {
Syslog('s', "c = TIMEOUT -> sendintro");
SM_PROCEED(sendintro); SM_PROCEED(sendintro);
} else if (c < 0) { } else if (c < 0) {
Syslog('+', "Error while reading EMSI_DAT from the caller"); Syslog('+', "Error while reading EMSI_DAT from the caller");