From f8d08db59ac05f5bf2f56e6ebf69c28dfbe8b13e Mon Sep 17 00:00:00 2001 From: mickeyl Date: Thu, 09 Oct 2003 00:03:06 +0000 Subject: - catch up with changed sniffing behaviour in newer wlan-ng *puke* drivers - new API: OPacketCapturer::next( int time ) --- (limited to 'libopie2/opienet/opcap.cpp') 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 @@ -32,15 +32,19 @@ */ /* OPIE */ - #include /* QT */ - #include // don't use oapplication here (will decrease reusability in other projects) #include #include +/* SYSTEM */ +#include +#include +#include + +/* LOCAL */ #include "udp_ports.h" /*====================================================================================== @@ -196,7 +200,7 @@ OEthernetPacket::OEthernetPacket( const unsigned char* end, const struct ether_h 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" ); } @@ -1130,6 +1134,23 @@ int OPacketCapturer::fileno() const } } + +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; -- cgit v0.9.0.2