aboutsummaryrefslogtreecommitdiffstats
path: root/ncpd/packet.cc
diff options
context:
space:
mode:
authorFritz Elfert <felfert@to.com>1999-07-04 19:12:50 +0000
committerFritz Elfert <felfert@to.com>1999-07-04 19:12:50 +0000
commitccc2e6cfe3a5936b0c72fa57faca5fb7b46c0b1d (patch)
treea9b3d6d93022dd1e625133931e1e03c71ed7f67d /ncpd/packet.cc
parent8f953dfc4c3349e7a022ea48dbc22feae34fc0f6 (diff)
downloadplptools-ccc2e6cfe3a5936b0c72fa57faca5fb7b46c0b1d.tar.gz
plptools-ccc2e6cfe3a5936b0c72fa57faca5fb7b46c0b1d.tar.bz2
plptools-ccc2e6cfe3a5936b0c72fa57faca5fb7b46c0b1d.zip
Forking, syslog and better error handling
Diffstat (limited to 'ncpd/packet.cc')
-rw-r--r--ncpd/packet.cc25
1 files changed, 25 insertions, 0 deletions
diff --git a/ncpd/packet.cc b/ncpd/packet.cc
index 70006bc..9009f86 100644
--- a/ncpd/packet.cc
+++ b/ncpd/packet.cc
@@ -29,6 +29,7 @@
#include <fstream.h>
#include <iomanip.h>
#include <errno.h>
+#include <sys/ioctl.h>
extern "C" {
#include "mp_serial.h"
@@ -155,6 +156,8 @@ bool packet::
get(unsigned char &type, bufferStore & ret)
{
while (!terminated()) {
+ if (linkFailed())
+ return false;
int res = read(fd, inPtr, BUFFERLEN - inLen);
if (res > 0) {
if (verbose & PKT_DEBUG_LOG)
@@ -241,3 +244,25 @@ terminated()
termLen = l;
return false;
}
+
+bool packet::
+linkFailed()
+{
+ int arg;
+ bool failed = false;
+ int res = ioctl(fd, TIOCMGET, &arg);
+ if (res < 0)
+ failed = true;
+ if (verbose & PKT_DEBUG_DUMP)
+ cout << "packet: DTR:" << ((arg & TIOCM_DTR)?1:0)
+ << " RTS:" << ((arg & TIOCM_RTS)?1:0)
+ << " DCD:" << ((arg & TIOCM_CAR)?1:0)
+ << " DSR:" << ((arg & TIOCM_DSR)?1:0)
+ << " CTS:" << ((arg & TIOCM_CTS)?1:0) << endl;
+ if (((arg & TIOCM_DSR) == 0) || ((arg & TIOCM_CTS) == 0))
+ failed = true;
+ if ((verbose & PKT_DEBUG_LOG) && failed)
+ cout << "packet: linkFAILED\n";
+ return failed;
+}
+