summaryrefslogtreecommitdiff
path: root/tunDevice.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tunDevice.cpp')
-rw-r--r--tunDevice.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/tunDevice.cpp b/tunDevice.cpp
index bfac2a4..0f17fb7 100644
--- a/tunDevice.cpp
+++ b/tunDevice.cpp
@@ -29,6 +29,7 @@
*/
#include <stdexcept>
+#include <poll.h>
extern "C" {
#include "openvpn/config.h"
@@ -105,14 +106,17 @@ TunDevice::~TunDevice()
close_tun(dev_);
}
-int TunDevice::read(Buffer& buf)
+short TunDevice::read(Buffer& buf)
{
if(!dev_)
return -1;
- perf_push (PERF_READ_IN_TUN);
-
- return read_tun(dev_, buf, buf.getLength());
+ struct pollfd pfd[1];
+ pfd[0].fd = tun_event_handle(dev_);
+// pfd[0].events = POLLIN | POLLRDNORM | POLLRDBAND | POLLPRI | POLLOUT | POLLWRNORM | POLLWRBAND | POLLERR | POLLHUP | POLLNVAL;
+ pfd[0].events = POLLIN | POLLRDNORM | POLLRDBAND | POLLPRI;
+ poll(pfd, 1, -1);
+ return pfd[0].revents;//read_tun(dev_, buf, buf.getLength());
}
int TunDevice::write(Buffer& buf)