More binkp/1.1 fixes
This commit is contained in:
parent
a325fc5c29
commit
d9e74ae4d0
@ -212,6 +212,8 @@ int binkp(int role)
|
|||||||
|
|
||||||
most_debug = TRUE;
|
most_debug = TRUE;
|
||||||
|
|
||||||
|
Syslog('+', "Binkp: start session");
|
||||||
|
|
||||||
memset(&bp, 0, sizeof(bp));
|
memset(&bp, 0, sizeof(bp));
|
||||||
bp.Role = role;
|
bp.Role = role;
|
||||||
bp.CRAMflag = FALSE;
|
bp.CRAMflag = FALSE;
|
||||||
@ -238,20 +240,20 @@ int binkp(int role)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (rc) {
|
||||||
|
Syslog('!', "Binkp: session handshake failed");
|
||||||
|
goto binkpend;
|
||||||
|
}
|
||||||
|
|
||||||
if (Loaded && nodes.NoBinkp11 && (bp.Major == 1) && (bp.Minor != 0)) {
|
if (Loaded && nodes.NoBinkp11 && (bp.Major == 1) && (bp.Minor != 0)) {
|
||||||
Syslog('+', "Binkp: forcing downgrade to binkp/1.0 protocol");
|
Syslog('+', "Binkp: forcing downgrade to binkp/1.0 protocol");
|
||||||
bp.Major = 1;
|
bp.Major = 1;
|
||||||
bp.Minor = 0;
|
bp.Minor = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bp.FtState = InitTransfer;
|
bp.FtState = InitTransfer;
|
||||||
rc = file_transfer();
|
rc = file_transfer();
|
||||||
|
|
||||||
if (rc) {
|
|
||||||
Syslog('!', "Binkp: session failed");
|
|
||||||
goto binkpend;
|
|
||||||
}
|
|
||||||
|
|
||||||
binkpend:
|
binkpend:
|
||||||
/*
|
/*
|
||||||
* Deinit
|
* Deinit
|
||||||
@ -265,7 +267,8 @@ binkpend:
|
|||||||
if (bp.txbuf)
|
if (bp.txbuf)
|
||||||
free(bp.txbuf);
|
free(bp.txbuf);
|
||||||
rc = abs(rc);
|
rc = abs(rc);
|
||||||
Syslog('b', "Binkp: rc=%d", rc);
|
|
||||||
|
Syslog('+', "Binkp: session finished, rc=%d", rc);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -317,11 +320,7 @@ SM_STATE(WaitConn)
|
|||||||
* Build options we want (Add PLZ etc).
|
* Build options we want (Add PLZ etc).
|
||||||
*/
|
*/
|
||||||
p = xstrcpy((char *)"OPT");
|
p = xstrcpy((char *)"OPT");
|
||||||
// if ((noderecord(remote->addr)) && nodes.CRC32 && (bp.CRCflag == WeCan)) {
|
|
||||||
// p = xstrcat(p, (char *)" CRC");
|
|
||||||
// bp.CRCflag = WeWant;
|
|
||||||
// Syslog('b', "CRCflag WeCan => WeWant");
|
|
||||||
// }
|
|
||||||
if (strcmp(p, (char *)"OPT"))
|
if (strcmp(p, (char *)"OPT"))
|
||||||
rc = binkp_send_command(MM_NUL, p);
|
rc = binkp_send_command(MM_NUL, p);
|
||||||
free(p);
|
free(p);
|
||||||
@ -825,7 +824,7 @@ int file_transfer(void)
|
|||||||
TrType Trc = Ok;
|
TrType Trc = Ok;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
Syslog('B', "Binkp: FileTransfer state %s", ftstate[bp.FtState]);
|
// Syslog('B', "Binkp: FileTransfer state %s", ftstate[bp.FtState]);
|
||||||
switch (bp.FtState) {
|
switch (bp.FtState) {
|
||||||
case InitTransfer: binkp_settimer(BINKP_TIMEOUT);
|
case InitTransfer: binkp_settimer(BINKP_TIMEOUT);
|
||||||
bp.RxState = RxWaitF;
|
bp.RxState = RxWaitF;
|
||||||
@ -836,7 +835,6 @@ int file_transfer(void)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case Switch: if ((bp.RxState == RxDone) && (bp.TxState == TxDone)) {
|
case Switch: if ((bp.RxState == RxDone) && (bp.TxState == TxDone)) {
|
||||||
Syslog('+', "Binkp: file transfer complete rc=%d", bp.rc);
|
|
||||||
bp.FtState = DeinitTransfer;
|
bp.FtState = DeinitTransfer;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1117,19 +1115,20 @@ TrType binkp_receiver(void)
|
|||||||
}
|
}
|
||||||
} else if (bp.RxState == RxWriteD) {
|
} else if (bp.RxState == RxWriteD) {
|
||||||
written = fwrite(bp.rxbuf, 1, bp.blklen, bp.rxfp);
|
written = fwrite(bp.rxbuf, 1, bp.blklen, bp.rxfp);
|
||||||
Syslog('b', "Binkp: write %d bytes of %d bytes", written, bp.blklen);
|
|
||||||
|
|
||||||
bp.GotFrame = FALSE;
|
bp.GotFrame = FALSE;
|
||||||
bp.rxlen = 0;
|
bp.rxlen = 0;
|
||||||
bp.header = 0;
|
bp.header = 0;
|
||||||
bp.blklen = 0;
|
|
||||||
|
|
||||||
if (!written && bp.blklen) {
|
if (bp.blklen && (bp.blklen != written)) {
|
||||||
Syslog('+', "Binkp: file write error");
|
Syslog('+', "Binkp: file write error");
|
||||||
bp.RxState = RxDone;
|
bp.RxState = RxDone;
|
||||||
|
bp.blklen = 0;
|
||||||
return Failure;
|
return Failure;
|
||||||
}
|
}
|
||||||
|
bp.blklen = 0;
|
||||||
bp.rxpos += written;
|
bp.rxpos += written;
|
||||||
|
|
||||||
if (bp.rxpos == bp.rsize) {
|
if (bp.rxpos == bp.rsize) {
|
||||||
rc = binkp_send_command(MM_GOT, "%s %ld %ld", bp.rname, bp.rsize, bp.rtime);
|
rc = binkp_send_command(MM_GOT, "%s %ld %ld", bp.rname, bp.rsize, bp.rtime);
|
||||||
closefile();
|
closefile();
|
||||||
@ -1641,7 +1640,6 @@ void parse_m_nul(char *msg)
|
|||||||
if ((p = strstr(msg+4, PRTCLNAME "/")) && (q = strstr(p, "."))) {
|
if ((p = strstr(msg+4, PRTCLNAME "/")) && (q = strstr(p, "."))) {
|
||||||
bp.Major = atoi(p + 6);
|
bp.Major = atoi(p + 6);
|
||||||
bp.Minor = atoi(q + 1);
|
bp.Minor = atoi(q + 1);
|
||||||
Syslog('b', "Remote protocol version %d.%d", bp.Major, bp.Minor);
|
|
||||||
}
|
}
|
||||||
} else if (strncmp(msg, "PHN ", 4) == 0) {
|
} else if (strncmp(msg, "PHN ", 4) == 0) {
|
||||||
Syslog('+', "Phone : %s", msg+4);
|
Syslog('+', "Phone : %s", msg+4);
|
||||||
@ -1829,7 +1827,7 @@ int binkp_process_messages(void)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!Found) {
|
if (!Found) {
|
||||||
Syslog('!', "Binkp: unexpected M_GET \"%s\"", tmpq->data); /* Ignore frame */
|
Syslog('+', "Binkp: unexpected M_GET \"%s\"", tmpq->data); /* Ignore frame */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (tmpq->cmd == MM_GOT) {
|
} else if (tmpq->cmd == MM_GOT) {
|
||||||
@ -1861,7 +1859,7 @@ int binkp_process_messages(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!Found) {
|
if (!Found) {
|
||||||
Syslog('!', "Binkp: unexpected M_GOT \"%s\"", tmpq->data); /* Ignore frame */
|
Syslog('+', "Binkp: unexpected M_GOT \"%s\"", tmpq->data); /* Ignore frame */
|
||||||
}
|
}
|
||||||
} else if (tmpq->cmd == MM_SKIP) {
|
} else if (tmpq->cmd == MM_SKIP) {
|
||||||
sscanf(tmpq->data, "%s %ld %ld", lname, &lsize, <ime);
|
sscanf(tmpq->data, "%s %ld %ld", lname, &lsize, <ime);
|
||||||
@ -1883,7 +1881,7 @@ int binkp_process_messages(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!Found) {
|
if (!Found) {
|
||||||
Syslog('!', "Binkp: unexpected M_SKIP \"%s\"", tmpq->data); /* Ignore frame */
|
Syslog('+', "Binkp: unexpected M_SKIP \"%s\"", tmpq->data); /* Ignore frame */
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Illegal message on the queue */
|
/* Illegal message on the queue */
|
||||||
@ -1923,7 +1921,8 @@ int binkp_pendingfiles(void)
|
|||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
Syslog('b', "Binkp: %d pending files on queue", count);
|
if (count)
|
||||||
|
Syslog('b', "Binkp: %d pending files on queue", count);
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2044,7 +2043,7 @@ void fill_binkp_list(binkp_list **bkll, file_list *fal, off_t offs)
|
|||||||
struct stat tstat;
|
struct stat tstat;
|
||||||
|
|
||||||
if (stat(fal->local, &tstat) != 0) {
|
if (stat(fal->local, &tstat) != 0) {
|
||||||
Syslog('!', "$Can't add %s to sendlist", fal->local);
|
Syslog('+', "$Binkp: can't add %s to sendlist", fal->local);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (strstr(fal->remote, (char *)".pkt"))
|
if (strstr(fal->remote, (char *)".pkt"))
|
||||||
@ -2088,7 +2087,7 @@ void binkp_clear_filelist(void)
|
|||||||
binkp_list *tmp;
|
binkp_list *tmp;
|
||||||
|
|
||||||
if (tosend != NULL) {
|
if (tosend != NULL) {
|
||||||
Syslog('b', "Clear current filelist");
|
Syslog('b', "Binkp: clear current filelist");
|
||||||
|
|
||||||
for (tmp = bll; bll; bll = tmp) {
|
for (tmp = bll; bll; bll = tmp) {
|
||||||
tmp = bll->next;
|
tmp = bll->next;
|
||||||
|
Reference in New Issue
Block a user