Finished PLZ binkp, bumped version

This commit is contained in:
Michiel Broek 2004-01-26 12:12:08 +00:00
parent bc7be1fb3b
commit c5a389968b
6 changed files with 52 additions and 22 deletions

View File

@ -1,6 +1,9 @@
$Id$ $Id$
v0.39.7 14-Jan-2004 v0.39.8 26-Jan-2004
v0.39.7 14-Jan-2004 - 26-Jan-2004
remark: remark:
Calling points is availbale now, but I know in the past that I Calling points is availbale now, but I know in the past that I
@ -17,7 +20,7 @@ v0.39.7 14-Jan-2004
and after running the external program to make sure diskbuffers and after running the external program to make sure diskbuffers
are committed. are committed.
Added a milliseconds timer. Added a milliseconds timer.
Before and after execute and execsh a 100 ms pause is inserted Before and after execute and execsh a 200 ms pause is inserted
to prevent (un)archiver and other errors. to prevent (un)archiver and other errors.
mbcico: mbcico:
@ -35,9 +38,7 @@ v0.39.7 14-Jan-2004
session close delay time. session close delay time.
During binkp handshake increased the timer of the receiver to During binkp handshake increased the timer of the receiver to
avoid handshake timeouts. avoid handshake timeouts.
Added PLZ compression option to binkp. Not yet 100% finished Added PLZ compression option to binkp.
but it seems to work. Not yet tested against latest Radius beta.
Be carefull!
mbfido: mbfido:
Removed sync calls that are now in execute. Removed sync calls that are now in execute.

4
TODO
View File

@ -1,6 +1,6 @@
$Id$ $Id$
MBSE BBS V0.39.7 TODO list. MBSE BBS V0.39.8 TODO list.
--------------------------- ---------------------------
These are a list of things that must be implemented one way or These are a list of things that must be implemented one way or
@ -123,8 +123,6 @@ mbcico:
L: Implement binkp option ND. L: Implement binkp option ND.
L: Implement binkp zlib compression.
mbfile: mbfile:
L: Add a check to see if the magic filenames are (still) valid. L: Add a check to see if the magic filenames are (still) valid.

2
configure vendored
View File

@ -1275,7 +1275,7 @@ SUBDIRS="lib mbcico mbfido mbmon mbsebbs mbtask mbsetup unix lang examples html
PACKAGE="mbsebbs" PACKAGE="mbsebbs"
MAJOR="0" MAJOR="0"
MINOR="39" MINOR="39"
REVISION="7" REVISION="8"
VERSION="$MAJOR.$MINOR.$REVISION" VERSION="$MAJOR.$MINOR.$REVISION"
COPYRIGHT="Copyright (C) 1997-2004 Michiel Broek, All Rights Reserved" COPYRIGHT="Copyright (C) 1997-2004 Michiel Broek, All Rights Reserved"
SHORTRIGHT="Copyright (C) 1997-2004 M. Broek" SHORTRIGHT="Copyright (C) 1997-2004 M. Broek"

View File

@ -13,7 +13,7 @@ dnl
PACKAGE="mbsebbs" PACKAGE="mbsebbs"
MAJOR="0" MAJOR="0"
MINOR="39" MINOR="39"
REVISION="7" REVISION="8"
VERSION="$MAJOR.$MINOR.$REVISION" VERSION="$MAJOR.$MINOR.$REVISION"
COPYRIGHT="Copyright (C) 1997-2004 Michiel Broek, All Rights Reserved" COPYRIGHT="Copyright (C) 1997-2004 Michiel Broek, All Rights Reserved"
SHORTRIGHT="Copyright (C) 1997-2004 M. Broek" SHORTRIGHT="Copyright (C) 1997-2004 M. Broek"

View File

@ -140,12 +140,12 @@ int execute(char *cmd, char *file, char *pkt, char *in, char *out, char *err)
#ifdef __linux__ #ifdef __linux__
sync(); sync();
#endif #endif
msleep(100); msleep(200);
rc = _execute(cmd, file, pkt, in, out, err); rc = _execute(cmd, file, pkt, in, out, err);
msleep(100);
#ifdef __linux #ifdef __linux
sync(); sync();
#endif #endif
msleep(200);
return rc; return rc;
} }
@ -217,12 +217,12 @@ int execsh(char *cmd, char *in, char *out, char *err)
#ifdef __linux__ #ifdef __linux__
sync(); sync();
#endif #endif
msleep(100); msleep(200);
rc = _execsh(cmd, in, out, err); rc = _execsh(cmd, in, out, err);
msleep(100);
#ifdef __linux__ #ifdef __linux__
sync(); sync();
#endif #endif
msleep(200);
return rc; return rc;
} }

View File

@ -132,6 +132,7 @@ struct binkprec {
int Minor; /* Minor protocol version */ int Minor; /* Minor protocol version */
unsigned char *MD_Challenge; /* Received challenge data */ unsigned char *MD_Challenge; /* Received challenge data */
int PLZflag; /* Zlib packet compression */ int PLZflag; /* Zlib packet compression */
int cmpblksize; /* Ideal next blocksize */
/* Receiver buffer */ /* Receiver buffer */
char *rxbuf; /* Receiver buffer */ char *rxbuf; /* Receiver buffer */
@ -233,6 +234,7 @@ int binkp(int role)
bp.local_EOB = FALSE; bp.local_EOB = FALSE;
bp.remote_EOB = FALSE; bp.remote_EOB = FALSE;
bp.msgs_on_queue = 0; bp.msgs_on_queue = 0;
bp.cmpblksize = SND_BLKSIZE;
#ifdef HAVE_ZLIB_H #ifdef HAVE_ZLIB_H
bp.PLZflag = WeCan; bp.PLZflag = WeCan;
#else #else
@ -1077,6 +1079,7 @@ TrType binkp_receiver(void)
rxbytes = bp.rxbytes; rxbytes = bp.rxbytes;
bp.rxfp = openfile(binkp2unix(bp.rname), bp.rtime, bp.rsize, &rxbytes, binkp_resync); bp.rxfp = openfile(binkp2unix(bp.rname), bp.rtime, bp.rsize, &rxbytes, binkp_resync);
bp.rxbytes = rxbytes; bp.rxbytes = rxbytes;
bp.rxcompressed = 0;
if (bp.DidSendGET) { if (bp.DidSendGET) {
Syslog('b', "Binkp: DidSendGET is set"); Syslog('b', "Binkp: DidSendGET is set");
@ -1203,6 +1206,10 @@ TrType binkp_receiver(void)
closefile(); closefile();
bp.rxpos = bp.rxpos - bp.rxbytes; bp.rxpos = bp.rxpos - bp.rxbytes;
gettimeofday(&rxtvend, &bp.tz); gettimeofday(&rxtvend, &bp.tz);
#ifdef HAVE_ZLIB_H
if (bp.rxcompressed && (bp.PLZflag == Active))
Syslog('+', "Binkp: %s", compress_stat(bp.rxpos, bp.rxcompressed));
#endif
Syslog('+', "Binkp: OK %s", transfertime(rxtvstart, rxtvend, bp.rxpos, FALSE)); Syslog('+', "Binkp: OK %s", transfertime(rxtvstart, rxtvend, bp.rxpos, FALSE));
rcvdbytes += bp.rxpos; rcvdbytes += bp.rxpos;
bp.RxState = RxWaitF; bp.RxState = RxWaitF;
@ -1351,6 +1358,7 @@ TrType binkp_transmitter(void)
} }
bp.txpos = bp.stxpos = tmp->offset; bp.txpos = bp.stxpos = tmp->offset;
bp.txcompressed = 0;
Syslog('+', "Binkp: send \"%s\" as \"%s\"", MBSE_SS(tmp->local), MBSE_SS(tmp->remote)); Syslog('+', "Binkp: send \"%s\" as \"%s\"", MBSE_SS(tmp->local), MBSE_SS(tmp->remote));
Syslog('+', "Binkp: size %lu bytes, dated %s", (unsigned long)tmp->size, date(tmp->date)); Syslog('+', "Binkp: size %lu bytes, dated %s", (unsigned long)tmp->size, date(tmp->date));
rc = binkp_send_command(MM_FILE, "%s %lu %ld %ld", MBSE_SS(tmp->remote), rc = binkp_send_command(MM_FILE, "%s %lu %ld %ld", MBSE_SS(tmp->remote),
@ -1395,7 +1403,7 @@ TrType binkp_transmitter(void)
} else if (bp.TxState == TxReadS) { } else if (bp.TxState == TxReadS) {
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, bp.cmpblksize, bp.txfp);
eof = feof(bp.txfp); eof = feof(bp.txfp);
if ((bp.txlen == 0) || eof) { if ((bp.txlen == 0) || eof) {
@ -1434,6 +1442,10 @@ TrType binkp_transmitter(void)
if (bp.txpos >= 0) { if (bp.txpos >= 0) {
bp.stxpos = bp.txpos - bp.stxpos; bp.stxpos = bp.txpos - bp.stxpos;
#ifdef HAVE_ZLIB_H
if (bp.txcompressed && (bp.PLZflag == Active))
Syslog('+', "Binkp: %s", compress_stat(bp.stxpos, bp.txcompressed));
#endif
Syslog('+', "Binkp: OK %s", transfertime(txtvstart, txtvend, bp.stxpos, TRUE)); Syslog('+', "Binkp: OK %s", transfertime(txtvstart, txtvend, bp.stxpos, TRUE));
} else { } else {
Syslog('+', "Binkp: transmitter skipped file after %ld seconds", txtvend.tv_sec - txtvstart.tv_sec); Syslog('+', "Binkp: transmitter skipped file after %ld seconds", txtvend.tv_sec - txtvstart.tv_sec);
@ -1548,7 +1560,7 @@ int binkp_send_frame(int cmd, char *buf, int len)
unsigned short header = 0; unsigned short header = 0;
int rc, id; int rc, id;
#ifdef HAVE_ZLIB_H #ifdef HAVE_ZLIB_H
int rcz; int rcz, last;
unsigned long zlen; unsigned long zlen;
char *zbuf; char *zbuf;
#endif #endif
@ -1577,6 +1589,7 @@ int binkp_send_frame(int cmd, char *buf, int len)
} }
#ifdef HAVE_ZLIB_H #ifdef HAVE_ZLIB_H
last = bp.cmpblksize;
if ((bp.PLZflag == Active) && (len > 20)) { if ((bp.PLZflag == Active) && (len > 20)) {
zbuf = calloc(BINKP_ZIPBUFLEN, sizeof(char)); zbuf = calloc(BINKP_ZIPBUFLEN, sizeof(char));
rcz = compress2(zbuf, &zlen, buf, len, 9); rcz = compress2(zbuf, &zlen, buf, len, 9);
@ -1585,6 +1598,19 @@ int binkp_send_frame(int cmd, char *buf, int len)
len, zlen, (zlen < len) ?"yes":"no"); len, zlen, (zlen < len) ?"yes":"no");
if (zlen < len) { if (zlen < len) {
bp.txcompressed += (len - zlen); bp.txcompressed += (len - zlen);
/*
* Calculate the perfect blocksize for the next block
* using the current compression ratio. This gives
* a dynamic optimal blocksize. The average maximum
* blocksize on the line will be 4096 bytes.
*/
if (!cmd) {
bp.cmpblksize = ((len * 4) / zlen) * 512;
if (bp.cmpblksize < SND_BLKSIZE)
bp.cmpblksize = SND_BLKSIZE;
if (bp.cmpblksize > (BINKP_PLZ_BLOCK -1))
bp.cmpblksize = (BINKP_PLZ_BLOCK -1);
}
/* /*
* Rebuild header for compressed block * Rebuild header for compressed block
*/ */
@ -1604,6 +1630,8 @@ int binkp_send_frame(int cmd, char *buf, int len)
rc = PUTCHAR(header & 0x00ff); rc = PUTCHAR(header & 0x00ff);
if (len && !rc) if (len && !rc)
rc = PUT(buf, len); rc = PUT(buf, len);
if (!cmd)
bp.cmpblksize = SND_BLKSIZE;
} }
} else { } else {
rc = PUTCHAR((header >> 8) & 0x00ff); rc = PUTCHAR((header >> 8) & 0x00ff);
@ -1611,6 +1639,8 @@ int binkp_send_frame(int cmd, char *buf, int len)
rc = PUTCHAR(header & 0x00ff); rc = PUTCHAR(header & 0x00ff);
if (len && !rc) if (len && !rc)
rc = PUT(buf, len); rc = PUT(buf, len);
if (!cmd)
bp.cmpblksize = SND_BLKSIZE;
} }
free(zbuf); free(zbuf);
} else { } else {
@ -1619,13 +1649,18 @@ int binkp_send_frame(int cmd, char *buf, int len)
rc = PUTCHAR(header & 0x00ff); rc = PUTCHAR(header & 0x00ff);
if (len && !rc) if (len && !rc)
rc = PUT(buf, len); rc = PUT(buf, len);
if (!cmd)
bp.cmpblksize = SND_BLKSIZE;
} }
if (!cmd && (last != bp.cmpblksize))
Syslog('b', "Binkp: adjusting next blocksize to %d bytes", bp.cmpblksize);
#else #else
rc = PUTCHAR((header >> 8) & 0x00ff); rc = PUTCHAR((header >> 8) & 0x00ff);
if (!rc) if (!rc)
rc = PUTCHAR(header & 0x00ff); rc = PUTCHAR(header & 0x00ff);
if (len && !rc) if (len && !rc)
rc = PUT(buf, len); rc = PUT(buf, len);
bp.cmpblksize = SND_BLKSIZE;
#endif #endif
FLUSHOUT(); FLUSHOUT();
@ -1946,15 +1981,12 @@ int binkp_poll_frame(void)
} }
if ((bp.rxlen == (bp.blklen + 1) && (bp.rxlen >= 1))) { if ((bp.rxlen == (bp.blklen + 1) && (bp.rxlen >= 1))) {
bp.GotFrame = TRUE; bp.GotFrame = TRUE;
Syslog('b', "Binkp: got a complete %s frame, mode %scompressed", bp.cmd?"CMD":"DATA", plz?"":"un");
#ifdef HAVE_ZLIB_H #ifdef HAVE_ZLIB_H
if (plz) { if (plz) {
Syslog('b', "Binkp: rcvd compressed block %d bytes", bp.rxlen -1);
zbuf = calloc(BINKP_ZIPBUFLEN, sizeof(char)); zbuf = calloc(BINKP_ZIPBUFLEN, sizeof(char));
rc = uncompress(zbuf, &zlen, bp.rxbuf, bp.rxlen -1); rc = uncompress(zbuf, &zlen, bp.rxbuf, bp.rxlen -1);
Syslog('b', "Binkp: uncompress rc=%d %d => %d", rc, bp.rxlen -1, zlen);
if (rc == Z_OK) { if (rc == Z_OK) {
bp.rxcompressed = (zlen - (bp.rxlen -1)); bp.rxcompressed += (zlen - (bp.rxlen -1));
memmove(bp.rxbuf, zbuf, zlen); memmove(bp.rxbuf, zbuf, zlen);
bp.rxlen = zlen +1; bp.rxlen = zlen +1;
bp.blklen = zlen; bp.blklen = zlen;
@ -1966,7 +1998,6 @@ int binkp_poll_frame(void)
free(zbuf); free(zbuf);
} }
#endif #endif
Syslog('b', "Binkp: bp.rxlen=%d bp.blklen=%d", bp.rxlen, bp.blklen);
bp.rxbuf[bp.rxlen-1] = '\0'; bp.rxbuf[bp.rxlen-1] = '\0';
if (bp.cmd) { if (bp.cmd) {
bp.messages++; bp.messages++;