diff options
author | Fritz Elfert <felfert@to.com> | 1999-07-01 20:44:20 +0000 |
---|---|---|
committer | Fritz Elfert <felfert@to.com> | 1999-07-01 20:44:20 +0000 |
commit | 80e566ea830ec9e6534f1a140af0bbc6b1765aa7 (patch) | |
tree | 86788a4b96d0b9ba70f787e4cd31777c4eb457bc /ncpd/main.cc | |
parent | 8c29602b21efacced9d7ff4cd1f3c4101dda5f65 (diff) | |
download | plptools-80e566ea830ec9e6534f1a140af0bbc6b1765aa7.tar.gz plptools-80e566ea830ec9e6534f1a140af0bbc6b1765aa7.tar.bz2 plptools-80e566ea830ec9e6534f1a140af0bbc6b1765aa7.zip |
modified logging for finer control.
proper reconnect on link failure.
Diffstat (limited to 'ncpd/main.cc')
-rw-r--r-- | ncpd/main.cc | 46 |
1 files changed, 36 insertions, 10 deletions
diff --git a/ncpd/main.cc b/ncpd/main.cc index dd32729..fca9efc 100644 --- a/ncpd/main.cc +++ b/ncpd/main.cc @@ -31,6 +31,8 @@ #include "socketchan.h" #include "iowatch.h" #include "linkchan.h" +#include "link.h" +#include "packet.h" void checkForNewSocketConnection(ppsocket & skt, int &numScp, socketChan ** scp, ncp * a, IOWatch & iow) @@ -44,6 +46,8 @@ checkForNewSocketConnection(ppsocket & skt, int &numScp, socketChan ** scp, ncp bufferStore a; a.addStringT("No psion ncp channel free"); next->sendBufferStore(a); + sleep(1); + next->closeSocket(); } else scp[numScp++] = new socketChan(next, a, iow); } @@ -90,8 +94,8 @@ resetSocketConnections(int &numScp, socketChan ** scp, ncp * a) void usage() { - cout << "Version : " << VERSION << endl; - cout << "Usage : ncp [-s <socket number>] [-d <device>] [-b <baud rate>]\n"; + cerr << "Usage : ncpd [-s <socket number>] [-d <device>] [-b <baud rate>]\n"; + exit(1); } int @@ -105,23 +109,40 @@ main(int argc, char **argv) int sockNum = DPORT; int baudRate = DSPEED; const char *serialDevice = DDEV; + short int nverbose = 0; + short int pverbose = 0; + short int lverbose = 0; for (int i = 1; i < argc; i++) { if (!strcmp(argv[i], "-s") && i + 1 < argc) { sockNum = atoi(argv[++i]); } else if (!strcmp(argv[i], "-d") && i + 1 < argc) { serialDevice = argv[++i]; + } else if (!strcmp(argv[i], "-v") && i + 1 < argc) { + i++; + if (!strcmp(argv[i], "nl")) + nverbose |= NCP_DEBUG_LOG; + if (!strcmp(argv[i], "nd")) + nverbose |= NCP_DEBUG_DUMP; + if (!strcmp(argv[i], "ll")) + lverbose |= LNK_DEBUG_LOG; + if (!strcmp(argv[i], "ld")) + lverbose |= LNK_DEBUG_DUMP; + if (!strcmp(argv[i], "pl")) + pverbose |= PKT_DEBUG_LOG; + if (!strcmp(argv[i], "pd")) + pverbose |= PKT_DEBUG_DUMP; } else if (!strcmp(argv[i], "-b") && i + 1 < argc) { baudRate = atoi(argv[++i]); - } else { + } else if (!strcmp(argv[i], "-V")) { + cout << "plpnfsd version " << VERSION << endl; + exit(0); + } else usage(); - exit(1); - } } if (!skt.listen("127.0.0.1", sockNum)) { cerr << "Could not initiate listen on socket " << sockNum << endl; - cerr << "NCP is now started by rfsv - you don't have to do it explicitly yourself" << endl; } else { ncp *a = NULL; int numScp; @@ -130,12 +151,15 @@ main(int argc, char **argv) while (true) { if (a == NULL) { a = new ncp(serialDevice, baudRate, iow); + a->setVerbose(nverbose); + a->setLinkVerbose(lverbose); + a->setPktVerbose(pverbose); numScp = 0; iow.addIO(skt.socket()); } // sockets - checkForNewSocketConnection(skt, numScp, scp, a, iow); pollSocketConnections(numScp, scp); + checkForNewSocketConnection(skt, numScp, scp, a, iow); // psion a->poll(); @@ -144,11 +168,13 @@ main(int argc, char **argv) iow.watch(0, 100000); else iow.watch(100000, 0); + if (a->hasFailed()) { cout << "ncp: restarting\n"; - resetSocketConnections(numScp, scp, a); - delete a; - a = NULL; + // resetSocketConnections(numScp, scp, a); + // delete a; + // a = NULL; + a->reset(); } } delete a; |