Changed timers for session setup

This commit is contained in:
Michiel Broek 2003-08-23 18:27:02 +00:00
parent f85535ff11
commit d90c04b69b
2 changed files with 291 additions and 278 deletions

View File

@ -118,7 +118,6 @@ int inbound_close(int success)
sprintf(source, "%s/%s", tempinbound, de->d_name); sprintf(source, "%s/%s", tempinbound, de->d_name);
sprintf(dest, "%s/%s", inbound, de->d_name); sprintf(dest, "%s/%s", inbound, de->d_name);
if ((lstat(source, &stb) == 0) && (S_ISREG(stb.st_mode))) { if ((lstat(source, &stb) == 0) && (S_ISREG(stb.st_mode))) {
Syslog('s', "Regular file");
if (file_exist(dest, F_OK) == 0) { if (file_exist(dest, F_OK) == 0) {
Syslog('!', "Cannot move %s to %s, file exists", de->d_name, inbound); Syslog('!', "Cannot move %s to %s, file exists", de->d_name, inbound);
} else { } else {
@ -129,8 +128,6 @@ int inbound_close(int success)
gotfiles = TRUE; gotfiles = TRUE;
} }
} }
} else {
Syslog('s', "Not a regular file");
} }
} }
@ -144,7 +141,10 @@ int inbound_close(int success)
*/ */
if ((rc = rmdir(tempinbound))) { if ((rc = rmdir(tempinbound))) {
WriteError("Can't remove %s: %s", tempinbound, strerror(rc)); WriteError("Can't remove %s: %s", tempinbound, strerror(rc));
} else {
Syslog('s', "Removed %s", tempinbound);
} }
free(tempinbound); free(tempinbound);
tempinbound = NULL; tempinbound = NULL;

View File

@ -89,11 +89,6 @@ int session(faddr *a, node *nl, int role, int tp, char *dt)
type = tp; type = tp;
nlent = nl; nlent = nl;
if (role)
Syslog('+', "Start outbound %s session with %s", typestr(type), ascfnode(a,0x1f));
else
Syslog('+', "Start inbound %s session", typestr(type));
if (getpeername(0,(struct sockaddr*)&peeraddr,&addrlen) == 0) { if (getpeername(0,(struct sockaddr*)&peeraddr,&addrlen) == 0) {
Syslog('s', "TCP connection: len=%d, family=%hd, port=%hu, addr=%s", Syslog('s', "TCP connection: len=%d, family=%hd, port=%hu, addr=%s",
addrlen,peeraddr.sin_family, peeraddr.sin_port, inet_ntoa(peeraddr.sin_addr)); addrlen,peeraddr.sin_family, peeraddr.sin_port, inet_ntoa(peeraddr.sin_addr));
@ -147,6 +142,7 @@ int session(faddr *a, node *nl, int role, int tp, char *dt)
if (role) { if (role) {
if (type == SESSION_UNKNOWN) if (type == SESSION_UNKNOWN)
(void)tx_define_type(); (void)tx_define_type();
Syslog('+', "Start outbound %s session with %s", typestr(type), ascfnode(a,0x1f));
switch(type) { switch(type) {
case SESSION_UNKNOWN: rc = MBERR_UNKNOWN_SESSION; break; case SESSION_UNKNOWN: rc = MBERR_UNKNOWN_SESSION; break;
case SESSION_FTSC: rc = tx_ftsc(); break; case SESSION_FTSC: rc = tx_ftsc(); break;
@ -159,6 +155,7 @@ int session(faddr *a, node *nl, int role, int tp, char *dt)
session_flags |= FTSC_XMODEM_CRC; session_flags |= FTSC_XMODEM_CRC;
if (type == SESSION_UNKNOWN) if (type == SESSION_UNKNOWN)
(void)rx_define_type(); (void)rx_define_type();
Syslog('+', "Start inbound %s session", typestr(type));
switch(type) { switch(type) {
case SESSION_UNKNOWN: rc = MBERR_UNKNOWN_SESSION; break; case SESSION_UNKNOWN: rc = MBERR_UNKNOWN_SESSION; break;
case SESSION_FTSC: rc = rx_ftsc(); break; case SESSION_FTSC: rc = rx_ftsc(); break;
@ -215,7 +212,6 @@ SM_NAMES
(char *)"sendinq" (char *)"sendinq"
SM_EDECL SM_EDECL
int c = 0; int c = 0;
int count=0;
char buf[256], *p; char buf[256], *p;
char ebuf[13], *ep; char ebuf[13], *ep;
int standby = 0; int standby = 0;
@ -233,9 +229,11 @@ SM_START(skipjunk)
SM_STATE(skipjunk) SM_STATE(skipjunk)
Syslog('S', "tx_define_type SKIPJUNK"); Syslog('s', "tx_define_type SKIPJUNK");
while ((c = GETCHAR(1)) >= 0) /*nothing*/ ; while ((c = GETCHAR(1)) >= 0) /*nothing*/ ;
if (c == TIMEOUT) { if (c == TIMEOUT) {
RESETTIMERS();
SETTIMER(0, 60); /* 60 second master timer */
SM_PROCEED(wake); SM_PROCEED(wake);
} else { } else {
SM_ERROR; SM_ERROR;
@ -243,8 +241,8 @@ SM_STATE(skipjunk)
SM_STATE(wake) SM_STATE(wake)
Syslog('S', "tx_define_type WAKE"); Syslog('s', "tx_define_type WAKE");
if (count++ > 20) { if (EXPIRED(0)) {
Syslog('+', "Remote did not respond"); Syslog('+', "Remote did not respond");
SM_ERROR; SM_ERROR;
} }
@ -257,19 +255,19 @@ SM_STATE(wake)
WriteError("Error while waking remote"); WriteError("Error while waking remote");
SM_ERROR; SM_ERROR;
} else { } else {
count = 0; SETTIMER(0, 60);
Syslog('S', "Got %c wakeup", c); Syslog('S', "Got %c wakeup", c);
SM_PROCEED(nextchar); SM_PROCEED(nextchar);
} }
SM_STATE(waitchar) SM_STATE(waitchar)
Syslog('S', "tx_define_type WAITCHAR"); Syslog('s', "tx_define_type WAITCHAR");
if ((c = GETCHAR(2)) == TIMEOUT) { /* Was 4 seconds */ if ((c = GETCHAR(2)) == TIMEOUT) {
standby = 0; standby = 0;
ep = ebuf; ep = ebuf;
ebuf[0] = '\0'; ebuf[0] = '\0';
if (count++ > 30) { /* Was 8 loops */ if (EXPIRED(0)) {
Syslog('+', "Too many tries waking remote"); Syslog('+', "Too many tries waking remote");
SM_ERROR; SM_ERROR;
} }
@ -283,7 +281,6 @@ SM_STATE(waitchar)
SM_STATE(nextchar) SM_STATE(nextchar)
Syslog('S', "tx_define_type NEXTCHAR");
if (c == 'C') { if (c == 'C') {
session_flags |= FTSC_XMODEM_CRC; session_flags |= FTSC_XMODEM_CRC;
maybeftsc++; maybeftsc++;
@ -329,7 +326,8 @@ SM_STATE(nextchar)
SM_PROCEED(checkintro); SM_PROCEED(checkintro);
} }
} }
} else switch (c) { } else {
switch (c) {
case DC1: break; case DC1: break;
case '\r': case '\r':
case '\n': standby = 0; case '\n': standby = 0;
@ -346,12 +344,12 @@ SM_STATE(nextchar)
Syslog('i', "Got '%s' reading intro", printablec(c)); Syslog('i', "Got '%s' reading intro", printablec(c));
break; break;
} }
}
SM_PROCEED(waitchar); SM_PROCEED(waitchar);
SM_STATE(checkintro) SM_STATE(checkintro)
Syslog('S', "tx_define_type CHECKINTRO"); Syslog('s', "tx_define_type CHECKINTRO");
Syslog('i', "Check \"%s\" for being EMSI request",ebuf); Syslog('i', "Check \"%s\" for being EMSI request",ebuf);
if (((localoptions & NOEMSI) == 0) && (strncasecmp(ebuf,"EMSI_REQA77E",12) == 0)) { if (((localoptions & NOEMSI) == 0) && (strncasecmp(ebuf,"EMSI_REQA77E",12) == 0)) {
@ -368,11 +366,11 @@ SM_STATE(checkintro)
SM_STATE(sendinq) SM_STATE(sendinq)
Syslog('S', "tx_define_type SENDINQ"); Syslog('s', "tx_define_type SENDINQ");
PUTCHAR(DC1); PUTCHAR(DC1);
if ((localoptions & NOEMSI) == 0) { if ((localoptions & NOEMSI) == 0) {
Syslog('S', "send **EMSI_INQC816 (2 times)"); Syslog('S', "send **EMSI_INQC816 (2 times)");
PUTSTR((char *)"\r**EMSI_INQC816**EMSI_INQC816"); PUTSTR((char *)"\r**EMSI_INQC816\r**EMSI_INQC816");
} }
if ((localoptions & NOWAZOO) == 0) { if ((localoptions & NOWAZOO) == 0) {
Syslog('S', "send YOOHOO char"); Syslog('S', "send YOOHOO char");
@ -415,14 +413,16 @@ SM_EDECL
session_flags|=FTSC_XMODEM_CRC; session_flags|=FTSC_XMODEM_CRC;
ebuf[0]='\0'; ebuf[0]='\0';
ep=ebuf; ep=ebuf;
Syslog('S', "rxdefine_type INIT"); RESETTIMERS();
SETTIMER(0, 60);
Syslog('s', "rxdefine_type INIT");
SM_START(sendintro) SM_START(sendintro)
SM_STATE(sendintro) SM_STATE(sendintro)
Syslog('S', "rxdefine_type SENDINTRO"); Syslog('s', "rxdefine_type SENDINTRO");
if (count++ > 6) { /* Was 16, is 6 according to the EMSI spec */ 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;
} }
@ -455,8 +455,14 @@ SM_STATE(sendintro)
SM_STATE(waitchar) SM_STATE(waitchar)
Syslog('S', "rxdefine_type WAITCHAR"); Syslog('s', "rxdefine_type WAITCHAR");
if ((c=GETCHAR(20)) == TIMEOUT) { /* Timeout was 8, must be 20. */
if (EXPIRED(0)) {
Syslog('+', "Timeout session handshake with the caller");
SM_ERROR;
}
if ((c = GETCHAR(20)) == TIMEOUT) {
SM_PROCEED(sendintro); SM_PROCEED(sendintro);
} else if (c < 0) { } else if (c < 0) {
Syslog('+', "EMSI error while getting from caller"); Syslog('+', "EMSI error while getting from caller");
@ -467,7 +473,7 @@ SM_STATE(waitchar)
SM_STATE(nextchar) SM_STATE(nextchar)
Syslog('S', "rxdefine_type NEXTCHAR"); Syslog('s', "rxdefine_type NEXTCHAR");
if ((c >= ' ') && (c <= 'z')) { if ((c >= ' ') && (c <= 'z')) {
if (c == '*') { if (c == '*') {
standby = 1; standby = 1;
@ -484,7 +490,8 @@ SM_STATE(nextchar)
} }
} }
SM_PROCEED(waitchar); SM_PROCEED(waitchar);
} else switch (c) { } else {
switch (c) {
case DC1: SM_PROCEED(waitchar); case DC1: SM_PROCEED(waitchar);
break; break;
case TSYNC: standby = 0; case TSYNC: standby = 0;
@ -524,10 +531,11 @@ SM_STATE(nextchar)
SM_PROCEED(waitchar); SM_PROCEED(waitchar);
break; break;
} }
}
SM_STATE(checkemsi) SM_STATE(checkemsi)
Syslog('S', "rxdefine_type CHECKEMSI"); Syslog('s', "rxdefine_type 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) {
@ -538,6 +546,11 @@ SM_STATE(checkemsi)
type = SESSION_EMSI; type = SESSION_EMSI;
data = xstrcpy((char *)"**EMSI_INQC816"); data = xstrcpy((char *)"**EMSI_INQC816");
SM_SUCCESS; SM_SUCCESS;
} else if (strncasecmp(ebuf, "EMSI_HBT", 8) == 0) {
standby = 0;
ep = ebuf;
ebuf[0] = '\0';
SM_PROCEED(waitchar);
} else if (strncasecmp(ebuf, "EMSI_DAT", 8) == 0) { } else if (strncasecmp(ebuf, "EMSI_DAT", 8) == 0) {
SM_PROCEED(getdat); SM_PROCEED(getdat);
} else { } else {
@ -546,7 +559,7 @@ SM_STATE(checkemsi)
SM_STATE(getdat) SM_STATE(getdat)
Syslog('S', "rxdefine_type GETDAT"); Syslog('s', "rxdefine_type GETDAT");
Syslog('i', "Try get emsi_dat packet starting with \"%s\"",ebuf); Syslog('i', "Try get emsi_dat packet starting with \"%s\"",ebuf);
if (sscanf(ebuf+8, "%04x", &datasize) != 1) { if (sscanf(ebuf+8, "%04x", &datasize) != 1) {