summaryrefslogtreecommitdiff
path: root/libopie2/opienet/opcap.cpp
Side-by-side diff
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
@@ -29,21 +29,25 @@
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/* OPIE */
-
#include <opie2/opcap.h>
/* QT */
-
#include <qapplication.h> // don't use oapplication here (will decrease reusability in other projects)
#include <qsocketnotifier.h>
#include <qobjectlist.h>
+/* SYSTEM */
+#include <sys/time.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+/* LOCAL */
#include "udp_ports.h"
/*======================================================================================
* OPacket
*======================================================================================*/
@@ -193,13 +197,13 @@ OEthernetPacket::OEthernetPacket( const unsigned char* end, const struct ether_h
if ( destinationAddress() == OMacAddress::broadcast )
qDebug( "Destination is broadcast address" );
switch ( type() )
{
case ETHERTYPE_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break;
- case ETHERTYPE_ARP: { qDebug( "OPacket::OPacket(): Received Ethernet Packet : Type = ARP" ); break; }
+ case ETHERTYPE_ARP: new OARPPacket( end, (const struct myarphdr*) (data+1), this ); break;
case ETHERTYPE_REVARP: { qDebug( "OPacket::OPacket(): Received Ethernet Packet : Type = RARP" ); break; }
default: qDebug( "OPacket::OPacket(): Received Ethernet Packet : Type = UNKNOWN" );
}
}
@@ -1127,12 +1131,29 @@ int OPacketCapturer::fileno() const
else
{
return -1;
}
}
+
+OPacket* OPacketCapturer::next( int time )
+{
+ fd_set fds;
+ struct timeval tv;
+ FD_ZERO( &fds );
+ FD_SET( pcap_fileno( _pch ), &fds );
+ tv.tv_sec = time / 1000;
+ tv.tv_usec = time % 1000;
+ int retval = select( 1, &fds, NULL, NULL, &tv);
+ if ( retval > 0 ) // clear to read!
+ return next();
+ else
+ return 0;
+}
+
+
OPacket* OPacketCapturer::next()
{
packetheaderstruct header;
qDebug( "==> OPacketCapturer::next()" );
const unsigned char* pdata = pcap_next( _pch, &header );
qDebug( "<== OPacketCapturer::next()" );