summaryrefslogtreecommitdiff
path: root/libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.cpp
Unidiff
Diffstat (limited to 'libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.cpp25
1 files changed, 20 insertions, 5 deletions
diff --git a/libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.cpp b/libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.cpp
index c49daa0..eb2e8e8 100644
--- a/libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.cpp
+++ b/libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.cpp
@@ -22,52 +22,52 @@ class Station
22 bool wep; 22 bool wep;
23 int beacons; 23 int beacons;
24}; 24};
25 25
26QDict<Station> stations; 26QDict<Station> stations;
27 27
28//======================== Application class =============================== 28//======================== Application class ===============================
29 29
30class Wellenreiter : public QApplication 30class Wellenreiter : public QApplication
31{ 31{
32Q_OBJECT 32Q_OBJECT
33public: 33public:
34 Wellenreiter( int argc, char** argv ) : QApplication( argc, argv ) 34 Wellenreiter( int argc, char** argv ) : QApplication( argc, argv ), channel( 1 )
35 { 35 {
36 36
37 ONetwork* net = ONetwork::instance(); 37 ONetwork* net = ONetwork::instance();
38 38
39 if ( argc < 3 ) 39 if ( argc < 3 )
40 { 40 {
41 printf( "Usage: ./%s <interface> <driver> <interval>\n", argv[0] ); 41 printf( "Usage: ./%s <interface> <driver> <interval>\n", argv[0] );
42 printf( "\n" ); 42 printf( "\n" );
43 printf( "Valid wireless interfaces (detected) are:\n" ); 43 printf( "Valid wireless interfaces (detected) are:\n" );
44 44
45 ONetwork::InterfaceIterator it = net->iterator(); 45 ONetwork::InterfaceIterator it = net->iterator();
46 while ( it.current() ) 46 while ( it.current() )
47 { 47 {
48 if ( it.current()->isWireless() ) 48 if ( it.current()->isWireless() )
49 { 49 {
50 printf( " - '%s' (MAC=%s) (IPv4=%s)\n", (const char*) it.current()->name(), 50 printf( " - '%s' (MAC=%s) (IPv4=%s)\n", (const char*) it.current()->name(),
51 (const char*) it.current()->macAddress().toString(), 51 (const char*) it.current()->macAddress().toString(),
52 (const char*) it.current()->ipV4Address() ); 52 (const char*) it.current()->ipV4Address() );
53 } 53 }
54 ++it; 54 ++it;
55 } 55 }
56 exit( -1 ); 56 exit( -1 );
57 } 57 }
58 58
59 printf( "****************************************************\n" ); 59 printf( "*******************************************************************\n" );
60 printf( "* Wellenreiter mini edition 1.0 (C) 2003 M-M-M *\n" ); 60 printf( "* Wellenreiter mini edition 1.0.0 (C) 2003 Michael 'Mickey' Lauer *\n" );
61 printf( "****************************************************\n" ); 61 printf( "*******************************************************************\n" );
62 printf( "\n\n" ); 62 printf( "\n\n" );
63 63
64 QString interface( argv[1] ); 64 QString interface( argv[1] );
65 QString driver( argv[2] ); 65 QString driver( argv[2] );
66 66
67 printf( "Trying to use '%s' as %s-controlled device...\n", (const char*) interface, (const char*) driver ); 67 printf( "Trying to use '%s' as %s-controlled device...\n", (const char*) interface, (const char*) driver );
68 68
69 // sanity checks before downcasting 69 // sanity checks before downcasting
70 ONetworkInterface* iface = net->interface( interface ); 70 ONetworkInterface* iface = net->interface( interface );
71 if ( !iface ) 71 if ( !iface )
72 { 72 {
73 printf( "Interface '%s' doesn't exist. Exiting.\n", (const char*) interface ); 73 printf( "Interface '%s' doesn't exist. Exiting.\n", (const char*) interface );
@@ -96,56 +96,70 @@ public:
96 else 96 else
97 { 97 {
98 printf( "ok.\n" ); 98 printf( "ok.\n" );
99 } 99 }
100 } 100 }
101 else 101 else
102 printf( "Interface status is already promisc - good.\n" ); 102 printf( "Interface status is already promisc - good.\n" );
103 103
104 // connect a monitoring strategy to the interface 104 // connect a monitoring strategy to the interface
105 if ( driver == "orinoco" ) 105 if ( driver == "orinoco" )
106 new OOrinocoMonitoringInterface( wiface, false ); 106 new OOrinocoMonitoringInterface( wiface, false );
107 else 107 else
108 if ( driver == "hostap" )
109 new OHostAPMonitoringInterface( wiface, false );
110 else
111 if ( driver == "wlan-ng" )
112 new OWlanNGMonitoringInterface( wiface, false );
113 else
108 { 114 {
109 printf( "Unknown driver. Exiting\n" ); 115 printf( "Unknown driver. Exiting\n" );
110 exit( -1 ); 116 exit( -1 );
111 } 117 }
112 118
113 // enable monitoring mode 119 // enable monitoring mode
114 printf( "Enabling monitor mode...\n" ); 120 printf( "Enabling monitor mode...\n" );
115 //wiface->setMonitorMode( true ); 121 wiface->setMode( "monitor" );
116 122
117 // open a packet capturer 123 // open a packet capturer
118 cap = new OPacketCapturer(); 124 cap = new OPacketCapturer();
119 cap->open( interface ); 125 cap->open( interface );
120 if ( !cap->isOpen() ) 126 if ( !cap->isOpen() )
121 { 127 {
122 printf( "Unable to open libpcap (%s). Exiting.\n", strerror( errno ) ); 128 printf( "Unable to open libpcap (%s). Exiting.\n", strerror( errno ) );
123 exit( -1 ); 129 exit( -1 );
124 } 130 }
125 131
126 // set capturer to non-blocking mode 132 // set capturer to non-blocking mode
127 cap->setBlocking( false ); 133 cap->setBlocking( false );
128 134
129 // start channel hopper 135 // start channel hopper
130 //wiface->setChannelHopping( 1000 ); 136 //wiface->setChannelHopping( 1000 );
131 137
132 // connect 138 // connect
133 connect( cap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); 139 connect( cap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) );
140 // timer
141 startTimer( 1000 );
134 142
135 } 143 }
136 144
137 ~Wellenreiter() {}; 145 ~Wellenreiter() {};
138 146
139public slots: 147public slots:
148 virtual void timerEvent(QTimerEvent* e)
149 {
150 wiface->setChannel( channel++ );
151 if ( channel == 14 ) channel = 1;
152 }
153
140 void receivePacket(OPacket* p) 154 void receivePacket(OPacket* p)
141 { 155 {
142 if (!p) 156 if (!p)
143 { 157 {
144 printf( "(empty packet received)\n" ); 158 printf( "(empty packet received)\n" );
145 return; 159 return;
146 } 160 }
147 161
148 OWaveLanManagementPacket* beacon = (OWaveLanManagementPacket*) p->child( "802.11 Management" ); 162 OWaveLanManagementPacket* beacon = (OWaveLanManagementPacket*) p->child( "802.11 Management" );
149 if ( beacon ) 163 if ( beacon )
150 { 164 {
151 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); 165 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) );
@@ -194,24 +208,25 @@ public slots:
194 { 208 {
195 printf( "IBSS(AdHoc): '%s' -> '%s' (Cell: '%s')'\n", 209 printf( "IBSS(AdHoc): '%s' -> '%s' (Cell: '%s')'\n",
196 (const char*) wlan->macAddress2().toString(true), 210 (const char*) wlan->macAddress2().toString(true),
197 (const char*) wlan->macAddress1().toString(true), 211 (const char*) wlan->macAddress1().toString(true),
198 (const char*) wlan->macAddress3().toString(true) ); 212 (const char*) wlan->macAddress3().toString(true) );
199 } 213 }
200 return; 214 return;
201 } 215 }
202 } 216 }
203private: 217private:
204 OPacketCapturer* cap; 218 OPacketCapturer* cap;
205 OWirelessNetworkInterface* wiface; 219 OWirelessNetworkInterface* wiface;
220 int channel;
206}; 221};
207 222
208 223
209int main( int argc, char** argv ) 224int main( int argc, char** argv )
210{ 225{
211 Wellenreiter w( argc, argv ); 226 Wellenreiter w( argc, argv );
212 w.exec(); 227 w.exec();
213 return 0; 228 return 0;
214} 229}
215 230
216#include "miniwellenreiter.moc" 231#include "miniwellenreiter.moc"
217 232