Made new binkp driver more or less stable for test
This commit is contained in:
parent
1d0a5dd328
commit
f0fe1e3378
@ -5,8 +5,7 @@ v0.39.6 11-Jan-2004
|
|||||||
mbcico:
|
mbcico:
|
||||||
New binkp/1.1 driver fixes for Sun NetBSD.
|
New binkp/1.1 driver fixes for Sun NetBSD.
|
||||||
Removed TCP ignore check in EOB state.
|
Removed TCP ignore check in EOB state.
|
||||||
FIXME: transmitter on slow systems processes GOT while file
|
Transmiter file close now right after last block.
|
||||||
seems still in transmit state.
|
|
||||||
|
|
||||||
mbsetup:
|
mbsetup:
|
||||||
Reorganised menu 1.4 screen 1 and 2.
|
Reorganised menu 1.4 screen 1 and 2.
|
||||||
|
@ -255,7 +255,6 @@ int binkp(int role)
|
|||||||
session_flags &= ~SESSION_WAZOO;
|
session_flags &= ~SESSION_WAZOO;
|
||||||
else
|
else
|
||||||
session_flags |= SESSION_WAZOO;
|
session_flags |= SESSION_WAZOO;
|
||||||
Syslog('b', "Binkp: WAZOO requests: %s", (session_flags & SESSION_WAZOO) ? "True":"False");
|
|
||||||
|
|
||||||
bp.FtState = InitTransfer;
|
bp.FtState = InitTransfer;
|
||||||
rc = file_transfer();
|
rc = file_transfer();
|
||||||
@ -826,7 +825,7 @@ SM_RETURN
|
|||||||
*/
|
*/
|
||||||
int file_transfer(void)
|
int file_transfer(void)
|
||||||
{
|
{
|
||||||
int data;
|
int rc = 0;
|
||||||
TrType Trc = Ok;
|
TrType Trc = Ok;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@ -844,16 +843,13 @@ int file_transfer(void)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
rc = binkp_poll_frame();
|
||||||
* Get I/O status
|
if (rc == -1) {
|
||||||
*/
|
Syslog('b', "Binkp: receiver error detected");
|
||||||
data = WAITPUTGET(-1);
|
bp.rc = rc = MBERR_FTRANSFER;
|
||||||
// Syslog('B', "Binkp: waitputget rc=%d", data);
|
bp.FtState = DeinitTransfer;
|
||||||
|
break;
|
||||||
/*
|
} else if (rc == 1) {
|
||||||
* Data in input buffer
|
|
||||||
*/
|
|
||||||
if (data & 1) {
|
|
||||||
bp.FtState = Receive;
|
bp.FtState = Receive;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -861,7 +857,7 @@ int file_transfer(void)
|
|||||||
/*
|
/*
|
||||||
* Check if there is room in the output buffer
|
* Check if there is room in the output buffer
|
||||||
*/
|
*/
|
||||||
if (data & 2) {
|
if (WAITPUTGET(-1) & 2) {
|
||||||
bp.FtState = Transmit;
|
bp.FtState = Transmit;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -932,16 +928,13 @@ TrType binkp_receiver(void)
|
|||||||
long written;
|
long written;
|
||||||
off_t rxbytes;
|
off_t rxbytes;
|
||||||
|
|
||||||
|
Syslog('B', "Binkp: receiver state %s", rxstate[bp.RxState]);
|
||||||
|
|
||||||
if (bp.RxState == RxWaitF) {
|
if (bp.RxState == RxWaitF) {
|
||||||
|
|
||||||
rc = binkp_poll_frame();
|
if (! bp.GotFrame)
|
||||||
if (rc == -1) {
|
|
||||||
return Failure;
|
|
||||||
} else if (rc == 0) {
|
|
||||||
return Ok;
|
return Ok;
|
||||||
}
|
|
||||||
|
|
||||||
Syslog('B', "Binkp: receiver state %s", rxstate[bp.RxState]);
|
|
||||||
bp.GotFrame = FALSE;
|
bp.GotFrame = FALSE;
|
||||||
bp.rxlen = 0;
|
bp.rxlen = 0;
|
||||||
bp.header = 0;
|
bp.header = 0;
|
||||||
@ -965,7 +958,6 @@ TrType binkp_receiver(void)
|
|||||||
parse_m_nul(bp.rxbuf +1);
|
parse_m_nul(bp.rxbuf +1);
|
||||||
return Ok;
|
return Ok;
|
||||||
} else if (bcmd == MM_EOB) {
|
} else if (bcmd == MM_EOB) {
|
||||||
Syslog('+', "Binkp: rcvd M_EOB");
|
|
||||||
if ((bp.Major == 1) && (bp.Minor != 0)) {
|
if ((bp.Major == 1) && (bp.Minor != 0)) {
|
||||||
// Syslog('B', "Binkp: 1.1 check local_EOB=%s remote_EOB=%s messages=%d",
|
// Syslog('B', "Binkp: 1.1 check local_EOB=%s remote_EOB=%s messages=%d",
|
||||||
// bp.local_EOB?"True":"False", bp.remote_EOB?"True":"False", bp.messages);
|
// bp.local_EOB?"True":"False", bp.remote_EOB?"True":"False", bp.messages);
|
||||||
@ -997,7 +989,7 @@ TrType binkp_receiver(void)
|
|||||||
bp.RxState = RxAccF;
|
bp.RxState = RxAccF;
|
||||||
return Continue;
|
return Continue;
|
||||||
} else if (bcmd <= MM_MAX) {
|
} else if (bcmd <= MM_MAX) {
|
||||||
Syslog('+', "Binkp: got unexpected %s frame in %s state", bstate[bcmd], rxstate[bp.RxState]);
|
Syslog('+', "Binkp: ERROR got unexpected %s frame in %s state", bstate[bcmd], rxstate[bp.RxState]);
|
||||||
bp.RxState = RxDone;
|
bp.RxState = RxDone;
|
||||||
return Failure;
|
return Failure;
|
||||||
} else {
|
} else {
|
||||||
@ -1005,8 +997,6 @@ TrType binkp_receiver(void)
|
|||||||
return Ok;
|
return Ok;
|
||||||
}
|
}
|
||||||
} else if (bp.RxState == RxAccF) {
|
} else if (bp.RxState == RxAccF) {
|
||||||
Syslog('B', "Binkp: receiver state %s", rxstate[bp.RxState]);
|
|
||||||
// Syslog('b', "Binkp: got M_FILE \"%s\"", printable(bp.rxbuf +1, 0));
|
|
||||||
if (strlen(bp.rxbuf) < 512) {
|
if (strlen(bp.rxbuf) < 512) {
|
||||||
sprintf(bp.rname, "%s", strtok(bp.rxbuf+1, " \n\r"));
|
sprintf(bp.rname, "%s", strtok(bp.rxbuf+1, " \n\r"));
|
||||||
bp.rsize = atoi(strtok(NULL, " \n\r"));
|
bp.rsize = atoi(strtok(NULL, " \n\r"));
|
||||||
@ -1097,13 +1087,8 @@ TrType binkp_receiver(void)
|
|||||||
|
|
||||||
} else if (bp.RxState == RxReceD) {
|
} else if (bp.RxState == RxReceD) {
|
||||||
|
|
||||||
rc = binkp_poll_frame();
|
if (! bp.GotFrame)
|
||||||
if (rc == -1) {
|
|
||||||
return Failure;
|
|
||||||
} else if (rc == 0) {
|
|
||||||
return Ok;
|
return Ok;
|
||||||
}
|
|
||||||
Syslog('B', "Binkp: receiver state %s", rxstate[bp.RxState]);
|
|
||||||
|
|
||||||
if (! bp.cmd) {
|
if (! bp.cmd) {
|
||||||
bp.RxState = RxWriteD;
|
bp.RxState = RxWriteD;
|
||||||
@ -1133,7 +1118,7 @@ TrType binkp_receiver(void)
|
|||||||
bp.RxState = RxAccF;
|
bp.RxState = RxAccF;
|
||||||
return Continue;
|
return Continue;
|
||||||
} else if (bcmd <= MM_MAX) {
|
} else if (bcmd <= MM_MAX) {
|
||||||
Syslog('+', "Binkp: got unexpected %s frame in %s state", bstate[bcmd], rxstate[bp.RxState]);
|
Syslog('+', "Binkp: ERROR got unexpected %s frame in %s state", bstate[bcmd], rxstate[bp.RxState]);
|
||||||
bp.RxState = RxDone;
|
bp.RxState = RxDone;
|
||||||
return Failure;
|
return Failure;
|
||||||
} else {
|
} else {
|
||||||
@ -1141,7 +1126,6 @@ TrType binkp_receiver(void)
|
|||||||
return Ok;
|
return Ok;
|
||||||
}
|
}
|
||||||
} else if (bp.RxState == RxWriteD) {
|
} else if (bp.RxState == RxWriteD) {
|
||||||
Syslog('B', "Binkp: receiver state %s", rxstate[bp.RxState]);
|
|
||||||
written = fwrite(bp.rxbuf, 1, bp.blklen, bp.rxfp);
|
written = fwrite(bp.rxbuf, 1, bp.blklen, bp.rxfp);
|
||||||
|
|
||||||
bp.GotFrame = FALSE;
|
bp.GotFrame = FALSE;
|
||||||
@ -1149,7 +1133,7 @@ TrType binkp_receiver(void)
|
|||||||
bp.header = 0;
|
bp.header = 0;
|
||||||
|
|
||||||
if (bp.blklen && (bp.blklen != written)) {
|
if (bp.blklen && (bp.blklen != written)) {
|
||||||
Syslog('+', "Binkp: file write error");
|
Syslog('+', "Binkp: ERROR file write error");
|
||||||
bp.RxState = RxDone;
|
bp.RxState = RxDone;
|
||||||
bp.blklen = 0;
|
bp.blklen = 0;
|
||||||
return Failure;
|
return Failure;
|
||||||
@ -1174,13 +1158,8 @@ TrType binkp_receiver(void)
|
|||||||
return Ok;
|
return Ok;
|
||||||
} else if (bp.RxState == RxEOB) {
|
} else if (bp.RxState == RxEOB) {
|
||||||
|
|
||||||
rc = binkp_poll_frame();
|
if (! bp.GotFrame)
|
||||||
if (rc == -1) {
|
|
||||||
return Failure;
|
|
||||||
} else if (rc == 0) {
|
|
||||||
return Ok;
|
return Ok;
|
||||||
}
|
|
||||||
Syslog('B', "Binkp: receiver state %s", rxstate[bp.RxState]);
|
|
||||||
|
|
||||||
bp.GotFrame = FALSE;
|
bp.GotFrame = FALSE;
|
||||||
bp.rxlen = 0;
|
bp.rxlen = 0;
|
||||||
@ -1200,7 +1179,7 @@ TrType binkp_receiver(void)
|
|||||||
parse_m_nul(bp.rxbuf +1);
|
parse_m_nul(bp.rxbuf +1);
|
||||||
return Ok;
|
return Ok;
|
||||||
} else if (bcmd <= MM_MAX) {
|
} else if (bcmd <= MM_MAX) {
|
||||||
Syslog('+', "Binkp: got unexpected %s frame in %s state", bstate[bcmd], rxstate[bp.RxState]);
|
Syslog('+', "Binkp: ERROR got unexpected %s frame in %s state", bstate[bcmd], rxstate[bp.RxState]);
|
||||||
bp.RxState = RxDone;
|
bp.RxState = RxDone;
|
||||||
return Failure;
|
return Failure;
|
||||||
} else {
|
} else {
|
||||||
@ -1208,13 +1187,12 @@ TrType binkp_receiver(void)
|
|||||||
return Ok;
|
return Ok;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Syslog('+', "Binkp: got unexpected data frame in %s state", rxstate[bp.RxState]);
|
Syslog('+', "Binkp: ERROR got unexpected data frame in %s state", rxstate[bp.RxState]);
|
||||||
bp.RxState = RxDone;
|
bp.RxState = RxDone;
|
||||||
return Failure;
|
return Failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (bp.RxState == RxDone) {
|
} else if (bp.RxState == RxDone) {
|
||||||
Syslog('B', "Binkp: receiver state %s", rxstate[bp.RxState]);
|
|
||||||
return Ok;
|
return Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1233,15 +1211,15 @@ TrType binkp_receiver(void)
|
|||||||
|
|
||||||
TrType binkp_transmitter(void)
|
TrType binkp_transmitter(void)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0, eof = FALSE;
|
||||||
char *nonhold_mail;
|
char *nonhold_mail;
|
||||||
fa_list *eff_remote;
|
fa_list *eff_remote;
|
||||||
file_list *tsl;
|
file_list *tsl;
|
||||||
static binkp_list *tmp;
|
static binkp_list *tmp;
|
||||||
|
|
||||||
if (bp.TxState == TxGNF) {
|
Syslog('B', "Binkp: transmitter state %s", txstate[bp.TxState]);
|
||||||
|
|
||||||
Syslog('B', "Binkp: transmitter state %s", txstate[bp.TxState]);
|
if (bp.TxState == TxGNF) {
|
||||||
/*
|
/*
|
||||||
* If we do not have a filelist yet, create one.
|
* If we do not have a filelist yet, create one.
|
||||||
*/
|
*/
|
||||||
@ -1336,7 +1314,6 @@ TrType binkp_transmitter(void)
|
|||||||
/*
|
/*
|
||||||
* No more files
|
* No more files
|
||||||
*/
|
*/
|
||||||
Syslog('+', "Binkp: send M_EOB");
|
|
||||||
rc = binkp_send_command(MM_EOB, "");
|
rc = binkp_send_command(MM_EOB, "");
|
||||||
bp.TxState = TxWLA;
|
bp.TxState = TxWLA;
|
||||||
if (rc)
|
if (rc)
|
||||||
@ -1348,7 +1325,6 @@ TrType binkp_transmitter(void)
|
|||||||
|
|
||||||
} else if (bp.TxState == TxTryR) {
|
} else if (bp.TxState == TxTryR) {
|
||||||
|
|
||||||
Syslog('B', "Binkp: transmitter state %s", txstate[bp.TxState]);
|
|
||||||
if (bp.msgs_on_queue == 0) {
|
if (bp.msgs_on_queue == 0) {
|
||||||
bp.TxState = TxReadS;
|
bp.TxState = TxReadS;
|
||||||
return Continue;
|
return Continue;
|
||||||
@ -1361,12 +1337,14 @@ TrType binkp_transmitter(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else if (bp.TxState == TxReadS) {
|
} else if (bp.TxState == TxReadS) {
|
||||||
Syslog('B', "Binkp: transmitter state %s", txstate[bp.TxState]);
|
|
||||||
fseek(bp.txfp, bp.txpos, SEEK_SET);
|
fseek(bp.txfp, bp.txpos, SEEK_SET);
|
||||||
bp.txlen = fread(bp.txbuf, 1, SND_BLKSIZE, bp.txfp);
|
bp.txlen = fread(bp.txbuf, 1, SND_BLKSIZE, bp.txfp);
|
||||||
|
eof = feof(bp.txfp);
|
||||||
|
|
||||||
if (bp.txlen == 0) {
|
if ((bp.txlen == 0) || eof) {
|
||||||
|
/*
|
||||||
|
* Nothing read/error or we are at eof
|
||||||
|
*/
|
||||||
if (ferror(bp.txfp)) {
|
if (ferror(bp.txfp)) {
|
||||||
WriteError("$Binkp: error reading from file");
|
WriteError("$Binkp: error reading from file");
|
||||||
bp.TxState = TxDone;
|
bp.TxState = TxDone;
|
||||||
@ -1375,6 +1353,17 @@ TrType binkp_transmitter(void)
|
|||||||
return Failure;
|
return Failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We are at eof, send last datablock
|
||||||
|
*/
|
||||||
|
if (eof && bp.txlen) {
|
||||||
|
bp.txpos += bp.txlen;
|
||||||
|
sentbytes += bp.txlen;
|
||||||
|
rc = binkp_send_frame(FALSE, bp.txbuf, bp.txlen);
|
||||||
|
if (rc)
|
||||||
|
return Failure;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* calculate time needed and bytes transferred
|
* calculate time needed and bytes transferred
|
||||||
*/
|
*/
|
||||||
@ -1398,6 +1387,9 @@ TrType binkp_transmitter(void)
|
|||||||
bp.TxState = TxGNF;
|
bp.TxState = TxGNF;
|
||||||
return Ok;
|
return Ok;
|
||||||
} else {
|
} else {
|
||||||
|
/*
|
||||||
|
* regular datablock
|
||||||
|
*/
|
||||||
bp.txpos += bp.txlen;
|
bp.txpos += bp.txlen;
|
||||||
sentbytes += bp.txlen;
|
sentbytes += bp.txlen;
|
||||||
rc = binkp_send_frame(FALSE, bp.txbuf, bp.txlen);
|
rc = binkp_send_frame(FALSE, bp.txbuf, bp.txlen);
|
||||||
@ -1410,7 +1402,6 @@ TrType binkp_transmitter(void)
|
|||||||
|
|
||||||
} else if (bp.TxState == TxWLA) {
|
} else if (bp.TxState == TxWLA) {
|
||||||
|
|
||||||
Syslog('B', "Binkp: transmitter state %s", txstate[bp.TxState]);
|
|
||||||
if ((bp.msgs_on_queue == 0) && (binkp_pendingfiles() == 0)) {
|
if ((bp.msgs_on_queue == 0) && (binkp_pendingfiles() == 0)) {
|
||||||
|
|
||||||
if ((bp.RxState >= RxEOB) && (bp.Major == 1) && (bp.Minor == 0)) {
|
if ((bp.RxState >= RxEOB) && (bp.Major == 1) && (bp.Minor == 0)) {
|
||||||
@ -1475,7 +1466,6 @@ TrType binkp_transmitter(void)
|
|||||||
return Ok;
|
return Ok;
|
||||||
|
|
||||||
} else if (bp.TxState == TxDone) {
|
} else if (bp.TxState == TxDone) {
|
||||||
Syslog('B', "Binkp: transmitter state %s", txstate[bp.TxState]);
|
|
||||||
return Ok;
|
return Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1649,7 +1639,7 @@ int binkp_recv_command(char *buf, int *len, int *cmd)
|
|||||||
|
|
||||||
to:
|
to:
|
||||||
if (tty_status)
|
if (tty_status)
|
||||||
WriteError("Binkp: TCP receive error: %d %s", tty_status, ttystat[tty_status]);
|
WriteError("Binkp: TCP rcv error, tty status: %s", ttystat[tty_status]);
|
||||||
return tty_status;
|
return tty_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1767,7 +1757,7 @@ int binkp_poll_frame(void)
|
|||||||
bp.remote_EOB = TRUE;
|
bp.remote_EOB = TRUE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Syslog('b', "Binkp: rcvd data (%d)", bp.rxlen);
|
Syslog('b', "Binkp: rcvd data (%d)", bp.rxlen -1);
|
||||||
}
|
}
|
||||||
rc = 1;
|
rc = 1;
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user