Implemented binkp CRC extension

This commit is contained in:
Michiel Broek 2002-06-16 19:55:30 +00:00
parent 8fe62076b5
commit 4526bfdee9
2 changed files with 25 additions and 21 deletions

View File

@ -4,8 +4,6 @@ $Id$
v0.35.01 05-Jun-2002 v0.35.01 05-Jun-2002
DO NOT USE THIS VERSION, IT WON'T WORK !!!!!!
general: general:
Added structures for netmail routing file. Added structures for netmail routing file.
Expanded nodes structures for FTP and Directory transfers. Expanded nodes structures for FTP and Directory transfers.
@ -22,11 +20,14 @@ DO NOT USE THIS VERSION, IT WON'T WORK !!!!!!
mbcico: mbcico:
Now uses the new session password field for session handshake. Now uses the new session password field for session handshake.
The binkd version string now includes the OS and CPU type. The binkp version string now includes the OS and CPU type.
If a transmitted file via binkp is skipped by the remote it If a transmitted file via binkp is skipped by the remote it
will stay in the queue for the next session. will stay in the queue for the next session.
The binkp receiver now supports the CRC option. The binkp protocol now supports the CRC option proposed by
The binkp transmitter doesn't right now, sessions will fail!!!!! Tobias Ernst. This unofficial extension is also supported by
Irex and patched BinkP versions.
Better error handling for error conditions during a binkp
session.
mbfile: mbfile:
Added -v commandline switch to supress virus checking for the Added -v commandline switch to supress virus checking for the

View File

@ -920,7 +920,6 @@ int binkp_batch(file_list *to_send)
tcrc = file_crc(tmp->local, FALSE); tcrc = file_crc(tmp->local, FALSE);
else else
tcrc = 0; tcrc = 0;
Syslog('b', "File CRC is %lx %ld", tcrc, tcrc);
txfp = fopen(tmp->local, "r"); txfp = fopen(tmp->local, "r");
if (txfp == NULL) { if (txfp == NULL) {
@ -1055,18 +1054,19 @@ int binkp_batch(file_list *to_send)
case MM_ERR: Syslog('+', "Binkp: got ERR: %s", rxbuf+1); case MM_ERR: Syslog('+', "Binkp: got ERR: %s", rxbuf+1);
RxState = RxDone; RxState = RxDone;
TxState = TxDone; TxState = TxDone;
rc = -10;
break; break;
case MM_BSY: Syslog('+', "Binkp: got BSY: %s", rxbuf+1); case MM_BSY: Syslog('+', "Binkp: got BSY: %s", rxbuf+1);
RxState = RxDone; RxState = RxDone;
TxState = TxDone; TxState = TxDone;
rc = -11;
break; break;
case MM_SKIP: Syslog('+', "Got SKIP frame"); case MM_SKIP: Syslog('+', "Binkp: got SKIP: %s", rxbuf+1);
Syslogp('+', printable(rxbuf+1, 0));
break; break;
case MM_GET: Syslog('+', "Got GET frame"); case MM_GET: Syslog('+', "Binkp: got GET: %s", rxbuf+1);
sscanf(rxbuf+1, "%s %ld %ld %ld", gname, &gsize, &gtime, &goffset); sscanf(rxbuf+1, "%s %ld %ld %ld", gname, &gsize, &gtime, &goffset);
for (tmpg = bll; tmpg; tmpg = tmpg->next) { for (tmpg = bll; tmpg; tmpg = tmpg->next) {
if (strcasecmp(tmpg->remote, gname) == 0) { if (strcasecmp(tmpg->remote, gname) == 0) {
@ -1078,7 +1078,8 @@ int binkp_batch(file_list *to_send)
} }
break; break;
case MM_GOT: sscanf(rxbuf+1, "%s %ld %ld", lname, &lsize, &ltime); case MM_GOT: Syslog('+', "Binkp: got GOT: %s", rxbuf+1);
sscanf(rxbuf+1, "%s %ld %ld", lname, &lsize, &ltime);
Found = FALSE; Found = FALSE;
for (tmp = bll; tmp; tmp = tmp->next) for (tmp = bll; tmp; tmp = tmp->next)
if ((strcmp(lname, tmp->remote) == 0) && (lsize == tmp->size) && (ltime == tmp->date)) { if ((strcmp(lname, tmp->remote) == 0) && (lsize == tmp->size) && (ltime == tmp->date)) {
@ -1094,13 +1095,13 @@ int binkp_batch(file_list *to_send)
case MM_NUL: b_nul(rxbuf+1); case MM_NUL: b_nul(rxbuf+1);
break; break;
case MM_EOB: Syslog('+', "Binkp: received EOB"); case MM_EOB: Syslog('+', "Binkp: got EOB");
RxState = RxEndOfBatch; RxState = RxEndOfBatch;
break; break;
case MM_FILE: if ((RxState == RxWaitFile) || (RxState == RxEndOfBatch)) { case MM_FILE: Syslog('b', "Binkp: got FILE: %s", rxbuf+1);
if ((RxState == RxWaitFile) || (RxState == RxEndOfBatch)) {
RxState = RxAcceptFile; RxState = RxAcceptFile;
Syslog('b', "MM_FILE %s", rxbuf+1);
if (strlen(rxbuf) < 512) { if (strlen(rxbuf) < 512) {
/* /*
* Check against buffer overflow * Check against buffer overflow
@ -1111,7 +1112,6 @@ int binkp_batch(file_list *to_send)
} else { } else {
sscanf(rxbuf+1, "%s %ld %ld %ld", rname, &rsize, &rtime, &roffs); sscanf(rxbuf+1, "%s %ld %ld %ld", rname, &rsize, &rtime, &roffs);
} }
Syslog('b', "Expecting CRC %lx", rcrc);
} else { } else {
Syslog('+', "Got corrupted FILE frame, size %d bytes", strlen(rxbuf)); Syslog('+', "Got corrupted FILE frame, size %d bytes", strlen(rxbuf));
} }
@ -1134,30 +1134,32 @@ int binkp_batch(file_list *to_send)
} }
rxpos += written; rxpos += written;
if (rxpos == rsize) { if (rxpos == rsize) {
RxState = RxWaitFile;
if (CRCflag && rcrc) { if (CRCflag && rcrc) {
rxcrc = rxcrc ^ 0xffffffff; rxcrc = rxcrc ^ 0xffffffff;
Syslog('b', "File received crc %lx, expected %lx", rxcrc, rcrc);
if (rcrc == rxcrc) { if (rcrc == rxcrc) {
binkp_send_control(MM_GOT, "%s %ld %ld %lx", rname, rsize, rtime, rcrc); binkp_send_control(MM_GOT, "%s %ld %ld %lx", rname, rsize, rtime, rcrc);
closefile(TRUE);
} else { } else {
rxerror = TRUE; rxerror = TRUE;
crc_errors++; crc_errors++;
if (crc_errors < 3) {
binkp_send_control(MM_SKIP, "%s %ld %ld %lx", rname, rsize, rtime, rcrc); binkp_send_control(MM_SKIP, "%s %ld %ld %lx", rname, rsize, rtime, rcrc);
WriteError("File CRC error nr %d, sending SKIP frame", crc_errors); Syslog('+', "File CRC error nr %d, sending SKIP frame", crc_errors);
} else { if (crc_errors >= 3) {
WriteError("File CRC error nr %d, aborting session", crc_errors); WriteError("File CRC error nr %d, aborting session", crc_errors);
binkp_send_control(MM_ERR, "Too much CRC errors, aborting session"); binkp_send_control(MM_ERR, "Too much CRC errors, aborting session");
RxState = RxDone; RxState = RxDone;
rc = -12;
} }
closefile(FALSE);
} }
} else { } else {
/* /*
* ACK without CRC check * ACK without CRC check
*/ */
binkp_send_control(MM_GOT, "%s %ld %ld", rname, rsize, rtime); binkp_send_control(MM_GOT, "%s %ld %ld", rname, rsize, rtime);
}
closefile(TRUE); closefile(TRUE);
}
rxpos = rxpos - rxbytes; rxpos = rxpos - rxbytes;
gettimeofday(&rxtvend, &tz); gettimeofday(&rxtvend, &tz);
Syslog('+', "Binkp: %s %s", rxerror?"ERROR":"OK", transfertime(rxtvstart, rxtvend, rxpos, FALSE)); Syslog('+', "Binkp: %s %s", rxerror?"ERROR":"OK", transfertime(rxtvstart, rxtvend, rxpos, FALSE));
@ -1201,6 +1203,7 @@ int binkp_batch(file_list *to_send)
binkp_send_control(MM_BSY, "Low diskspace, try again later"); binkp_send_control(MM_BSY, "Low diskspace, try again later");
RxState = RxDone; RxState = RxDone;
TxState = TxDone; TxState = TxDone;
rc = -13;
break; break;
} }
@ -1210,7 +1213,7 @@ int binkp_batch(file_list *to_send)
* be deleted at the remote. * be deleted at the remote.
*/ */
Syslog('+', "Binkp: already got %s, sending GOT", rname); Syslog('+', "Binkp: already got %s, sending GOT", rname);
if (CRCflag &rcrc) if (CRCflag && rcrc)
binkp_send_control(MM_GOT, "%s %ld %ld %lx", rname, rsize, rtime, rcrc); binkp_send_control(MM_GOT, "%s %ld %ld %lx", rname, rsize, rtime, rcrc);
else else
binkp_send_control(MM_GOT, "%s %ld %ld", rname, rsize, rtime); binkp_send_control(MM_GOT, "%s %ld %ld", rname, rsize, rtime);