aboutsummaryrefslogtreecommitdiffstats
path: root/ncpd
diff options
context:
space:
mode:
authorFritz Elfert <felfert@to.com>2002-03-17 08:40:17 +0000
committerFritz Elfert <felfert@to.com>2002-03-17 08:40:17 +0000
commit38fc74f68c90aff4909660b89a9c233eac16f626 (patch)
treea4548dc2760015c13990def9418b35a966e46ad4 /ncpd
parentbf0e9c7d42c2078e29301123aae3593bab1a029b (diff)
downloadplptools-38fc74f68c90aff4909660b89a9c233eac16f626.tar.gz
plptools-38fc74f68c90aff4909660b89a9c233eac16f626.tar.bz2
plptools-38fc74f68c90aff4909660b89a9c233eac16f626.zip
- packet: Fixed bug where sync detection could overrun end of buffer
- socketchan: removed debugging output - link: Changed a debug output of unmatched ack's; removed wrong purge.
Diffstat (limited to 'ncpd')
-rw-r--r--ncpd/link.cc18
-rw-r--r--ncpd/packet.cc4
-rw-r--r--ncpd/socketchan.cc1
3 files changed, 13 insertions, 10 deletions
diff --git a/ncpd/link.cc b/ncpd/link.cc
index 19f7094..453211f 100644
--- a/ncpd/link.cc
+++ b/ncpd/link.cc
@@ -343,12 +343,6 @@ receive(bufferStore buff)
// Transmit waiting packets
transmitWaitQueue();
} else {
- if (verbose & LNK_DEBUG_LOG) {
- cout << "Link: << UNMATCHED ack seq=" << seq;
- if (verbose & LNK_DEBUG_DUMP)
- cout << " " << buff;
- cout << endl;
- }
// If packet with seq+1 is in ackWaitQueue, resend it immediately
// (Receiving an ack for a packet not on our wait queue is a
// hint by the Psion about which was the last packet it
@@ -356,8 +350,10 @@ receive(bufferStore buff)
pthread_mutex_lock(&queueMutex);
struct timeval now;
gettimeofday(&now, NULL);
+ bool nextFound = false;
for (i = ackWaitQueue.begin(); i != ackWaitQueue.end(); i++)
if (i->seq == seq+1) {
+ nextFound = true;
if (i->txcount-- == 0) {
// timeout, remove packet
if (verbose & LNK_DEBUG_LOG)
@@ -376,6 +372,12 @@ receive(bufferStore buff)
break;
}
pthread_mutex_unlock(&queueMutex);
+ if ((verbose & LNK_DEBUG_LOG) && (!nextFound)) {
+ cout << "Link: << UNMATCHED ack seq=" << seq;
+ if (verbose & LNK_DEBUG_DUMP)
+ cout << " " << buff;
+ cout << endl;
+ }
}
break;
@@ -386,7 +388,7 @@ receive(bufferStore buff)
// May be a link confirm packet (EPOC)
pthread_mutex_lock(&queueMutex);
for (i = ackWaitQueue.begin(); i != ackWaitQueue.end(); i++)
- if ((i->seq == 0) && (i->data.getByte(0) & 0xf0) == 0x20) {
+ if ((i->seq == 0) && (i->data.getByte(0) == 0x21)) {
ackWaitQueue.erase(i);
linkType = LINK_TYPE_EPOC;
if (verbose & LNK_DEBUG_LOG)
@@ -411,7 +413,6 @@ receive(bufferStore buff)
if (conFound) {
rxSequence = 0;
txSequence = 1;
- purgeAllQueues();
sendAck(rxSequence);
} else {
if (verbose & LNK_DEBUG_LOG) {
@@ -430,7 +431,6 @@ receive(bufferStore buff)
// EPOC can handle up to 8 unacknowledged packets
maxOutstanding = 8;
p->setEpoc(true);
- purgeAllQueues();
failed = false;
sendReqCon();
} else {
diff --git a/ncpd/packet.cc b/ncpd/packet.cc
index b08b745..afd82fb 100644
--- a/ncpd/packet.cc
+++ b/ncpd/packet.cc
@@ -372,9 +372,13 @@ findSync()
continue;
lastSYN = p - 1;
normalize(p);
+ if (p == inw)
+ break;
if (inBuffer[p++] != 0x10)
continue;
normalize(p);
+ if (p == inw)
+ break;
if (inBuffer[p++] != 0x02)
continue;
normalize(p);
diff --git a/ncpd/socketchan.cc b/ncpd/socketchan.cc
index fe2b683..407464a 100644
--- a/ncpd/socketchan.cc
+++ b/ncpd/socketchan.cc
@@ -113,7 +113,6 @@ ncpCommand(bufferStore & a)
ok = true;
} else if (!strncmp(str, "GSPD", 4)) {
// Get Speed of serial device
- cerr << "socketChan:: GETSPEED" << endl;
a.init();
a.addByte(rfsv::E_PSI_GEN_NONE);
a.addDWord(ncpGetSpeed());