From fc704485589e2b1841d587e26f74794ac59c00d4 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Mon, 18 Jun 2007 01:37:58 +0000 Subject: readded not silly refernce removed really silly refernce some tests with poll() --- tunDevice.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'tunDevice.cpp') diff --git a/tunDevice.cpp b/tunDevice.cpp index bfac2a4..0f17fb7 100644 --- a/tunDevice.cpp +++ b/tunDevice.cpp @@ -29,6 +29,7 @@ */ #include +#include 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) -- cgit v1.2.3