Fixed compression OPT commands

This commit is contained in:
Michiel Broek 2005-06-19 15:58:42 +00:00
parent a34a512a49
commit 96fe795e0a

View File

@ -379,25 +379,6 @@ SM_STATE(WaitConn)
Syslog('+', "Binkp: node %s", ascfnode(remote->addr, 0x1f)); Syslog('+', "Binkp: node %s", ascfnode(remote->addr, 0x1f));
IsDoing("Connect binkp %s", ascfnode(remote->addr, 0xf)); IsDoing("Connect binkp %s", ascfnode(remote->addr, 0xf));
/*
* Build options we want
*/
p = xstrcpy((char *)"OPT");
#ifdef HAVE_ZLIB_H
if (bp.PLZflag == WeCan) {
p = xstrcat(p, (char *)" PLZ");
bp.PLZflag = WeWant;
}
#endif
if (strcmp(p, (char *)"OPT"))
rc = binkp_send_command(MM_NUL, p);
free(p);
if (rc) {
SM_ERROR;
}
rc = binkp_banner(); rc = binkp_banner();
if (rc) { if (rc) {
SM_ERROR; SM_ERROR;
@ -636,6 +617,12 @@ SM_STATE(Opts)
} }
#endif #endif
} }
#endif
#ifdef HAVE_ZLIB_H
if (bp.PLZflag == TheyWant) {
bp.PLZflag = Active;
Syslog('b', "Binkp: PLZ compression active");
}
#endif #endif
SM_SUCCESS; SM_SUCCESS;
@ -695,12 +682,6 @@ SM_STATE(WaitConn)
*/ */
char s[MD5_DIGEST_LEN*2+15]; /* max. length of opt string */ char s[MD5_DIGEST_LEN*2+15]; /* max. length of opt string */
strcpy(s, "OPT "); strcpy(s, "OPT ");
#ifdef HAVE_ZLIB_H
if (bp.PLZflag == WeCan) {
strcpy(s + strlen(s), "PLZ ");
bp.PLZflag = WeWant;
}
#endif
MD_toString(s + strlen(s), bp.MD_Challenge[0], bp.MD_Challenge+1); MD_toString(s + strlen(s), bp.MD_Challenge[0], bp.MD_Challenge+1);
bp.CRAMflag = TRUE; bp.CRAMflag = TRUE;
if ((rc = binkp_send_command(MM_NUL, "%s", s))) { if ((rc = binkp_send_command(MM_NUL, "%s", s))) {
@ -940,6 +921,12 @@ SM_STATE(Opts)
bp.BZ2flag = No; bp.BZ2flag = No;
#endif #endif
} }
#endif
#ifdef HAVE_ZLIB_H
if (bp.PLZflag == TheyWant) {
bp.PLZflag = Active;
Syslog('+', "Binkp: PLZ compression active");
}
#endif #endif
SM_SUCCESS; SM_SUCCESS;
@ -1353,7 +1340,7 @@ TrType binkp_receiver(void)
bp.rxpos = bp.rxpos - bp.rxbytes; bp.rxpos = bp.rxpos - bp.rxbytes;
gettimeofday(&rxtvend, &bp.tz); gettimeofday(&rxtvend, &bp.tz);
#if defined(HAVE_ZLIB_H) || defined(HAVE_BZLIB_H) #if defined(HAVE_ZLIB_H) || defined(HAVE_BZLIB_H)
if (bp.rxcompressed && ((bp.PLZflag == Active) || bp.rmode)) if (bp.rxcompressed)
Syslog('+', "Binkp: %s", compress_stat(bp.rxpos, bp.rxcompressed)); Syslog('+', "Binkp: %s", compress_stat(bp.rxpos, bp.rxcompressed));
#endif #endif
Syslog('+', "Binkp: OK %s", transfertime(rxtvstart, rxtvend, bp.rxpos, FALSE)); Syslog('+', "Binkp: OK %s", transfertime(rxtvstart, rxtvend, bp.rxpos, FALSE));
@ -1987,16 +1974,25 @@ int binkp_banner(void)
#ifdef USE_BINKDZLIB #ifdef USE_BINKDZLIB
if (!rc /* && bp.Role */) { if (!rc /* && bp.Role */) {
p = xstrcpy((char *)"OPT EXTCMD"); p = xstrcpy((char *)"OPT EXTCMD");
#ifdef HAVE_BZLIB_H
p = xstrcat(p, (char *)" BZ2");
#endif
#ifdef HAVE_ZLIB_H #ifdef HAVE_ZLIB_H
p = xstrcat(p, (char *)" GZ"); p = xstrcat(p, (char *)" GZ");
#endif
#ifdef HAVE_BZLIB_H
p = xstrcat(p, (char *)" BZ2");
#endif #endif
rc = binkp_send_command(MM_NUL,"%s", p); rc = binkp_send_command(MM_NUL,"%s", p);
free(p); free(p);
} }
#endif #endif
#ifdef HAVE_ZLIB_H
if (!rc) {
p = xstrcpy((char *)"OPT PLZ");
rc = binkp_send_command(MM_NUL,"%s", p);
free(p);
}
#endif
return rc; return rc;
} }
@ -2120,10 +2116,6 @@ void parse_m_nul(char *msg)
if (bp.BZ2flag == WeCan) { if (bp.BZ2flag == WeCan) {
bp.BZ2flag = TheyWant; bp.BZ2flag = TheyWant;
Syslog('+', "Binkp: remote supports BZ2 mode"); Syslog('+', "Binkp: remote supports BZ2 mode");
#ifdef HAVE_ZLIB_H
bp.GZflag = No; /* Don't ack GZ */
bp.PLZflag = No; /* Don't ack PLZ */
#endif
} else { } else {
Syslog('b', "BZ2flag is %s and received BZ2 option", opstate[bp.BZ2flag]); Syslog('b', "BZ2flag is %s and received BZ2 option", opstate[bp.BZ2flag]);
} }
@ -2134,10 +2126,6 @@ void parse_m_nul(char *msg)
if (bp.GZflag == WeCan) { if (bp.GZflag == WeCan) {
bp.GZflag = TheyWant; bp.GZflag = TheyWant;
Syslog('+', "Binkp: remote supports GZ mode"); Syslog('+', "Binkp: remote supports GZ mode");
bp.PLZflag = No; /* Don't ack PLZ */
#ifdef HAVE_BZLIB_H
bp.BZ2flag = No;
#endif
} else { } else {
Syslog('b', "GZflag is %s and received GZ option", opstate[bp.GZflag]); Syslog('b', "GZflag is %s and received GZ option", opstate[bp.GZflag]);
} }
@ -2148,23 +2136,11 @@ void parse_m_nul(char *msg)
} else if (strncmp(q, (char *)"PLZ", 3) == 0) { } else if (strncmp(q, (char *)"PLZ", 3) == 0) {
if (bp.PLZflag == WeCan) { if (bp.PLZflag == WeCan) {
bp.PLZflag = TheyWant; bp.PLZflag = TheyWant;
binkp_send_command(MM_NUL,"OPT PLZ"); Syslog('+', "Binkp: remote supports PLZ mode");
bp.PLZflag = Active;
Syslog('+', " : zlib compression active");
#ifdef USE_BINDZLIB
#ifdef HAVE_BZLIB_H
bp.BZ2flag = No;
#endif
#endif
} else if (bp.PLZflag == WeWant) {
bp.PLZflag = Active;
Syslog('+', " : zlib compression active");
} else { } else {
Syslog('b', "PLZflag is %s and received PLZ option", opstate[bp.PLZflag]); Syslog('b', "PLZflag is %s and received PLZ option", opstate[bp.PLZflag]);
} }
#endif #endif
// } else {
// Syslog('b', "Binkp: opt not supported");
} }
} }