summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-10-09 00:03:06 (UTC)
committer mickeyl <mickeyl>2003-10-09 00:03:06 (UTC)
commitf8d08db59ac05f5bf2f56e6ebf69c28dfbe8b13e (patch) (unidiff)
tree36059d71abfcdb73748c1941fb9458dc75e0d4a8
parent5517443d9ebe96ff9c30d91b2254418964d5c410 (diff)
downloadopie-f8d08db59ac05f5bf2f56e6ebf69c28dfbe8b13e.zip
opie-f8d08db59ac05f5bf2f56e6ebf69c28dfbe8b13e.tar.gz
opie-f8d08db59ac05f5bf2f56e6ebf69c28dfbe8b13e.tar.bz2
- catch up with changed sniffing behaviour in newer wlan-ng *puke* drivers
- new API: OPacketCapturer::next( int time )
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opienet/onetwork.cpp12
-rw-r--r--libopie2/opienet/opcap.cpp27
-rw-r--r--libopie2/opienet/opcap.h5
3 files changed, 38 insertions, 6 deletions
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp
index 1f529d2..45ee4c0 100644
--- a/libopie2/opienet/onetwork.cpp
+++ b/libopie2/opienet/onetwork.cpp
@@ -928,16 +928,22 @@ void OWlanNGMonitoringInterface::setEnabled( bool b )
928QString OWlanNGMonitoringInterface::name() const 928QString OWlanNGMonitoringInterface::name() const
929{ 929{
930 return "wlan-ng"; 930 return "wlan-ng";
931} 931}
932 932
933 933
934void OWlanNGMonitoringInterface::setChannel( int ) 934void OWlanNGMonitoringInterface::setChannel( int c )
935{ 935{
936 // wlan-ng devices automatically switch channels when in monitor mode 936 //NOTE: Older wlan-ng drivers automatically hopped channels while lnxreq_wlansniff=true. Newer ones don't.
937 // NOTE: The above note no longer seems to be true for recent driver versions! 937
938 QString enable = "true"; //_if->monitorMode() ? "true" : "false";
939 QString prism = _prismHeader ? "true" : "false";
940 QString cmd;
941 cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s prismheader=%s",
942 (const char*) _if->name(), c+1, (const char*) enable, (const char*) prism );
943 system( cmd );
938} 944}
939 945
940 946
941/*====================================================================================== 947/*======================================================================================
942 * OHostAPMonitoringInterface 948 * OHostAPMonitoringInterface
943 *======================================================================================*/ 949 *======================================================================================*/
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 @@
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34/* OPIE */ 34/* OPIE */
35
36#include <opie2/opcap.h> 35#include <opie2/opcap.h>
37 36
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)
41#include <qsocketnotifier.h> 39#include <qsocketnotifier.h>
42#include <qobjectlist.h> 40#include <qobjectlist.h>
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"
45 49
46/*====================================================================================== 50/*======================================================================================
47 * OPacket 51 * OPacket
48 *======================================================================================*/ 52 *======================================================================================*/
49 53
@@ -193,13 +197,13 @@ OEthernetPacket::OEthernetPacket( const unsigned char* end, const struct ether_h
193 if ( destinationAddress() == OMacAddress::broadcast ) 197 if ( destinationAddress() == OMacAddress::broadcast )
194 qDebug( "Destination is broadcast address" ); 198 qDebug( "Destination is broadcast address" );
195 199
196 switch ( type() ) 200 switch ( type() )
197 { 201 {
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; }
201 default: qDebug( "OPacket::OPacket(): Received Ethernet Packet : Type = UNKNOWN" ); 205 default: qDebug( "OPacket::OPacket(): Received Ethernet Packet : Type = UNKNOWN" );
202 } 206 }
203 207
204} 208}
205 209
@@ -1127,12 +1131,29 @@ int OPacketCapturer::fileno() const
1127 else 1131 else
1128 { 1132 {
1129 return -1; 1133 return -1;
1130 } 1134 }
1131} 1135}
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()
1134{ 1155{
1135 packetheaderstruct header; 1156 packetheaderstruct header;
1136 qDebug( "==> OPacketCapturer::next()" ); 1157 qDebug( "==> OPacketCapturer::next()" );
1137 const unsigned char* pdata = pcap_next( _pch, &header ); 1158 const unsigned char* pdata = pcap_next( _pch, &header );
1138 qDebug( "<== OPacketCapturer::next()" ); 1159 qDebug( "<== OPacketCapturer::next()" );
diff --git a/libopie2/opienet/opcap.h b/libopie2/opienet/opcap.h
index 51f067a..54b256b 100644
--- a/libopie2/opienet/opcap.h
+++ b/libopie2/opienet/opcap.h
@@ -602,12 +602,17 @@ class OPacketCapturer : public QObject
602 /** 602 /**
603 * @returns the next @ref OPacket from the packet capturer. 603 * @returns the next @ref OPacket from the packet capturer.
604 * @note If blocking mode is true then this call might block. 604 * @note If blocking mode is true then this call might block.
605 */ 605 */
606 OPacket* next(); 606 OPacket* next();
607 /** 607 /**
608 * @returns the next @ref OPacket from the packet capturer, if
609 * one arrives within @a time milliseconds.
610 */
611 OPacket* next( int time );
612 /**
608 * Open the packet capturer to capture packets in live-mode from @a interface. 613 * Open the packet capturer to capture packets in live-mode from @a interface.
609 */ 614 */
610 bool open( const QString& interface ); 615 bool open( const QString& interface );
611 /** 616 /**
612 * Open the packet capturer to capture packets in offline-mode from @a file. 617 * Open the packet capturer to capture packets in offline-mode from @a file.
613 */ 618 */