diff options
Diffstat (limited to 'ncpd')
-rw-r--r-- | ncpd/link.cc | 6 | ||||
-rw-r--r-- | ncpd/linkchan.cc | 6 | ||||
-rw-r--r-- | ncpd/main.cc | 10 | ||||
-rw-r--r-- | ncpd/mp_serial.c | 2 | ||||
-rw-r--r-- | ncpd/ncp.cc | 2 | ||||
-rw-r--r-- | ncpd/packet.cc | 28 | ||||
-rw-r--r-- | ncpd/packet.h | 1 |
7 files changed, 39 insertions, 16 deletions
diff --git a/ncpd/link.cc b/ncpd/link.cc index c455324..d07b78b 100644 --- a/ncpd/link.cc +++ b/ncpd/link.cc @@ -90,7 +90,7 @@ send(const bufferStore & buff) if (buff.getLen() > 300) failed = true; else - sendQueue.pushBuffer(buff); + sendQueue += buff; } bufferArray link:: @@ -116,7 +116,7 @@ poll() // Send ack if (idLastGot != seq) { idLastGot = seq; - ret.pushBuffer(buff); + ret += buff; } else { if (verbose & LNK_DEBUG_LOG) cout << "link: DUP\n"; @@ -177,7 +177,7 @@ poll() } else { if (!sendQueue.empty()) { somethingToSend = true; - toSend = sendQueue.popBuffer(); + toSend = sendQueue.pop(); idSent++; if (idSent > 7) idSent = 0; diff --git a/ncpd/linkchan.cc b/ncpd/linkchan.cc index 4a2a4d4..f8e586f 100644 --- a/ncpd/linkchan.cc +++ b/ncpd/linkchan.cc @@ -60,7 +60,7 @@ ncpDataCallback(bufferStore & a) << srvName << "\"" << endl; while (!registerStack.empty()) { - se = registerStack.popBuffer(); + se = registerStack.pop(); if (se.getWord(0) == ser) { if (verbose & LINKCHAN_DEBUG_LOG) cout << "linkchan: found ser=0x" << hex << setw(4) << @@ -68,7 +68,7 @@ ncpDataCallback(bufferStore & a) " on stack -> callBack to waiting chan" << endl; ncpDoRegisterAck((int)se.getWord(2)); } else - newStack.pushBuffer(se); + newStack += se; } registerStack = newStack; return; @@ -111,7 +111,7 @@ Register(channel *ch) stack.addWord(registerSer); stack.addWord(ch->getNcpChannel()); - registerStack.pushBuffer(stack); + registerStack += stack; a.addByte(0); a.addWord(registerSer++); a.addString(ch->getNcpConnectName()); diff --git a/ncpd/main.cc b/ncpd/main.cc index 3a0ddb6..2c0fd3d 100644 --- a/ncpd/main.cc +++ b/ncpd/main.cc @@ -79,7 +79,7 @@ pollSocketConnections(int &numScp, socketChan ** scp) void usage() { - cerr << "Usage : ncpd [-V] [-v logclass] [-d] [-p <port>] [-s <device>] [-b <baudrate>]\n"; + cerr << "Usage : ncpd [-V] [-v logclass] [-d] [-e] [-p <port>] [-s <device>] [-b <baudrate>]\n"; exit(1); } @@ -90,6 +90,7 @@ main(int argc, char **argv) IOWatch iow; int pid; bool dofork = true; + bool autoexit = false; // Command line parameter processing int sockNum = DPORT; @@ -120,7 +121,7 @@ main(int argc, char **argv) if (!strcmp(argv[i], "pd")) pverbose |= PKT_DEBUG_DUMP; if (!strcmp(argv[i], "ph")) - lverbose |= PKT_DEBUG_HANDSHAKE; + pverbose |= PKT_DEBUG_HANDSHAKE; if (!strcmp(argv[i], "m")) verbose = true; if (!strcmp(argv[i], "all")) { @@ -133,6 +134,8 @@ main(int argc, char **argv) baudRate = atoi(argv[++i]); } else if (!strcmp(argv[i], "-d")) { dofork = 0; + } else if (!strcmp(argv[i], "-e")) { + autoexit = true; } else if (!strcmp(argv[i], "-V")) { cout << "ncpd version " << VERSION << endl; exit(0); @@ -180,6 +183,9 @@ main(int argc, char **argv) iow.watch(1, 0); if (a->hasFailed()) { + if (autoexit) + break; + iow.watch(5, 0); if (verbose) cout << "ncp: restarting\n"; diff --git a/ncpd/mp_serial.c b/ncpd/mp_serial.c index b153e77..05a014c 100644 --- a/ncpd/mp_serial.c +++ b/ncpd/mp_serial.c @@ -153,7 +153,7 @@ init_serial(const char *dev, int speed, int debug) #endif #if defined(sun) || defined(linux) || defined(__sgi) || defined(__NetBSD__) ti.c_cflag = CS8 | HUPCL | clocal | CRTSCTS | CREAD; - ti.c_iflag = IGNBRK | IGNPAR; + ti.c_iflag = IGNBRK | IGNPAR | IXON | IXOFF; ti.c_cc[VMIN] = 1; ti.c_cc[VTIME] = 0; #endif diff --git a/ncpd/ncp.cc b/ncpd/ncp.cc index e1bf96a..1a5c317 100644 --- a/ncpd/ncp.cc +++ b/ncpd/ncp.cc @@ -113,7 +113,7 @@ poll() bufferArray res(l->poll()); if (!res.empty()) { do { - bufferStore s = res.popBuffer(); + bufferStore s = res.pop(); if (s.getLen() > 1) { int channel = s.getByte(0); s.discardFirstBytes(1); diff --git a/ncpd/packet.cc b/ncpd/packet.cc index 26823c8..53774d6 100644 --- a/ncpd/packet.cc +++ b/ncpd/packet.cc @@ -54,6 +54,7 @@ iow(_iow) inPtr = inBuffer = new unsigned char[BUFFERLEN + 1]; outPtr = outBuffer = new unsigned char[BUFFERLEN + 1]; inLen = outLen = termLen = 0; + foundSync = 0; esc = false; crcIn = crcOut = 0; @@ -87,7 +88,7 @@ void packet:: send(unsigned char type, const bufferStore & b) { if (verbose & PKT_DEBUG_LOG) { - cout << "packet: >> "; + cout << "packet: type " << hex << (int) type << " >> "; if (verbose & PKT_DEBUG_DUMP) cout << b << endl; else @@ -185,7 +186,7 @@ get(unsigned char &type, bufferStore & ret) if (verbose & PKT_DEBUG_LOG) { cout << "packet: get "; if (verbose & PKT_DEBUG_DUMP) { - for (int i = 0; i < termLen; i++) + for (int i = foundSync - 3; i < termLen; i++) cout << hex << setw(2) << setfill('0') << (int) inBuffer[i] << " "; } else cout << "len=" << dec << termLen; @@ -193,6 +194,7 @@ get(unsigned char &type, bufferStore & ret) } inLen -= termLen; termLen = 0; + foundSync = 0; bool crcOk = (endPtr[0] == ((crcIn >> 8) & 0xff) && endPtr[1] == (crcIn & 0xff)); if (inLen > 0) memmove(inBuffer, &endPtr[2], inLen); @@ -218,15 +220,29 @@ terminated() if (inLen < 6) return false; p = inBuffer + termLen; - if (termLen == 0) { + if (!foundSync) { + while (!foundSync && (inLen - termLen >= 6)) + { + termLen++; if (*p++ != 0x16) - return false; + continue; + termLen++; if (*p++ != 0x10) - return false; + continue; + termLen++; if (*p++ != 0x02) + continue; + foundSync = termLen; + } + if (!foundSync) return false; + + if (verbose & PKT_DEBUG_LOG) { + if (foundSync != 3) + cout << "packet: terminated found sync at " << foundSync << endl; + } esc = false; - termLen = 3; + // termLen = 3; crcIn = 0; rcv.init(); } diff --git a/ncpd/packet.h b/ncpd/packet.h index 26d4282..5c4bb4f 100644 --- a/ncpd/packet.h +++ b/ncpd/packet.h @@ -63,6 +63,7 @@ class packet { int inLen; int outLen; int termLen; + int foundSync; int fd; short int verbose; bool esc; |