summaryrefslogtreecommitdiff
path: root/libopie2/opienet/opcap.cpp
Unidiff
Diffstat (limited to 'libopie2/opienet/opcap.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opienet/opcap.cpp27
1 files changed, 24 insertions, 3 deletions
diff --git a/libopie2/opienet/opcap.cpp b/libopie2/opienet/opcap.cpp
index 9ed2b83..38ca1a1 100644
--- a/libopie2/opienet/opcap.cpp
+++ b/libopie2/opienet/opcap.cpp
@@ -34,3 +34,2 @@
34/* OPIE */ 34/* OPIE */
35
36#include <opie2/opcap.h> 35#include <opie2/opcap.h>
@@ -38,3 +37,2 @@
38/* QT */ 37/* QT */
39
40#include <qapplication.h> // don't use oapplication here (will decrease reusability in other projects) 38#include <qapplication.h> // don't use oapplication here (will decrease reusability in other projects)
@@ -43,2 +41,8 @@
43 41
42/* SYSTEM */
43#include <sys/time.h>
44#include <sys/types.h>
45#include <unistd.h>
46
47/* LOCAL */
44#include "udp_ports.h" 48#include "udp_ports.h"
@@ -198,3 +202,3 @@ OEthernetPacket::OEthernetPacket( const unsigned char* end, const struct ether_h
198 case ETHERTYPE_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break; 202 case ETHERTYPE_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break;
199 case ETHERTYPE_ARP: { qDebug( "OPacket::OPacket(): Received Ethernet Packet : Type = ARP" ); break; } 203 case ETHERTYPE_ARP: new OARPPacket( end, (const struct myarphdr*) (data+1), this ); break;
200 case ETHERTYPE_REVARP: { qDebug( "OPacket::OPacket(): Received Ethernet Packet : Type = RARP" ); break; } 204 case ETHERTYPE_REVARP: { qDebug( "OPacket::OPacket(): Received Ethernet Packet : Type = RARP" ); break; }
@@ -1132,2 +1136,19 @@ int OPacketCapturer::fileno() const
1132 1136
1137
1138OPacket* OPacketCapturer::next( int time )
1139{
1140 fd_set fds;
1141 struct timeval tv;
1142 FD_ZERO( &fds );
1143 FD_SET( pcap_fileno( _pch ), &fds );
1144 tv.tv_sec = time / 1000;
1145 tv.tv_usec = time % 1000;
1146 int retval = select( 1, &fds, NULL, NULL, &tv);
1147 if ( retval > 0 ) // clear to read!
1148 return next();
1149 else
1150 return 0;
1151}
1152
1153
1133OPacket* OPacketCapturer::next() 1154OPacket* OPacketCapturer::next()