From 38fc74f68c90aff4909660b89a9c233eac16f626 Mon Sep 17 00:00:00 2001 From: Fritz Elfert Date: Sun, 17 Mar 2002 08:40:17 +0000 Subject: - 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. --- ncpd/link.cc | 18 +++++++++--------- ncpd/packet.cc | 4 ++++ ncpd/socketchan.cc | 1 - 3 files changed, 13 insertions(+), 10 deletions(-) (limited to 'ncpd') 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()); -- cgit v1.2.3