summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-04-10 15:49:08 (UTC)
committer mickeyl <mickeyl>2003-04-10 15:49:08 (UTC)
commit4e8e3741dca909782e15bb197e5b6a78750536c2 (patch) (unidiff)
tree37285f8d053b3995aee46487277b57248862848c
parent3733471135ea180709fcf4695607cce0c5fc7fb5 (diff)
downloadopie-4e8e3741dca909782e15bb197e5b6a78750536c2.zip
opie-4e8e3741dca909782e15bb197e5b6a78750536c2.tar.gz
opie-4e8e3741dca909782e15bb197e5b6a78750536c2.tar.bz2
Wellenreiter can now open and replay capture files as written by tcpdump, ethereal, etc.
Next task: writing capture files
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/configbase.ui6
-rw-r--r--noncore/net/wellenreiter/gui/configwindow.cpp46
-rw-r--r--noncore/net/wellenreiter/gui/configwindow.h14
-rw-r--r--noncore/net/wellenreiter/gui/mainwindow.cpp2
-rw-r--r--noncore/net/wellenreiter/gui/mainwindow.h4
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp94
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.h3
7 files changed, 121 insertions, 48 deletions
diff --git a/noncore/net/wellenreiter/gui/configbase.ui b/noncore/net/wellenreiter/gui/configbase.ui
index dda7ba0..3ece270 100644
--- a/noncore/net/wellenreiter/gui/configbase.ui
+++ b/noncore/net/wellenreiter/gui/configbase.ui
@@ -140,64 +140,70 @@
140 </property> 140 </property>
141 </item> 141 </item>
142 <item> 142 <item>
143 <property> 143 <property>
144 <name>text</name> 144 <name>text</name>
145 <string>cisco</string> 145 <string>cisco</string>
146 </property> 146 </property>
147 </item> 147 </item>
148 <item> 148 <item>
149 <property> 149 <property>
150 <name>text</name> 150 <name>text</name>
151 <string>wlan-ng</string> 151 <string>wlan-ng</string>
152 </property> 152 </property>
153 </item> 153 </item>
154 <item> 154 <item>
155 <property> 155 <property>
156 <name>text</name> 156 <name>text</name>
157 <string>hostap</string> 157 <string>hostap</string>
158 </property> 158 </property>
159 </item> 159 </item>
160 <item> 160 <item>
161 <property> 161 <property>
162 <name>text</name> 162 <name>text</name>
163 <string>orinoco</string> 163 <string>orinoco</string>
164 </property> 164 </property>
165 </item> 165 </item>
166 <item> 166 <item>
167 <property> 167 <property>
168 <name>text</name> 168 <name>text</name>
169 <string>&lt;manual&gt;</string> 169 <string>&lt;manual&gt;</string>
170 </property> 170 </property>
171 </item> 171 </item>
172 <item>
173 <property>
174 <name>text</name>
175 <string>&lt;file&gt;</string>
176 </property>
177 </item>
172 <property stdset="1"> 178 <property stdset="1">
173 <name>name</name> 179 <name>name</name>
174 <cstring>deviceType</cstring> 180 <cstring>deviceType</cstring>
175 </property> 181 </property>
176 <property stdset="1"> 182 <property stdset="1">
177 <name>enabled</name> 183 <name>enabled</name>
178 <bool>true</bool> 184 <bool>true</bool>
179 </property> 185 </property>
180 <property> 186 <property>
181 <name>whatsThis</name> 187 <name>whatsThis</name>
182 <string>Choose the type of driver used for sniffing.</string> 188 <string>Choose the type of driver used for sniffing.</string>
183 </property> 189 </property>
184 </widget> 190 </widget>
185 <widget row="3" column="0" rowspan="1" colspan="2" > 191 <widget row="3" column="0" rowspan="1" colspan="2" >
186 <class>QCheckBox</class> 192 <class>QCheckBox</class>
187 <property stdset="1"> 193 <property stdset="1">
188 <name>name</name> 194 <name>name</name>
189 <cstring>additionalInfo</cstring> 195 <cstring>additionalInfo</cstring>
190 </property> 196 </property>
191 <property stdset="1"> 197 <property stdset="1">
192 <name>enabled</name> 198 <name>enabled</name>
193 <bool>false</bool> 199 <bool>false</bool>
194 </property> 200 </property>
195 <property stdset="1"> 201 <property stdset="1">
196 <name>text</name> 202 <name>text</name>
197 <string>Gather Additional Info</string> 203 <string>Gather Additional Info</string>
198 </property> 204 </property>
199 </widget> 205 </widget>
200 <widget row="2" column="0" > 206 <widget row="2" column="0" >
201 <class>QSpinBox</class> 207 <class>QSpinBox</class>
202 <property stdset="1"> 208 <property stdset="1">
203 <name>name</name> 209 <name>name</name>
diff --git a/noncore/net/wellenreiter/gui/configwindow.cpp b/noncore/net/wellenreiter/gui/configwindow.cpp
index ba1119e..4aca526 100644
--- a/noncore/net/wellenreiter/gui/configwindow.cpp
+++ b/noncore/net/wellenreiter/gui/configwindow.cpp
@@ -1,100 +1,126 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Opie Environment. 4** This file is part of Opie Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14**********************************************************************/ 14**********************************************************************/
15 15
16/* LOCAL */ 16/* LOCAL */
17#include "configwindow.h" 17#include "configwindow.h"
18#include "mainwindow.h"
18 19
19/* QT */ 20/* QT */
21#include <qapplication.h>
20#include <qcombobox.h> 22#include <qcombobox.h>
21#include <qfile.h> 23#include <qfile.h>
22#include <qlayout.h> 24#include <qlayout.h>
23#include <qmap.h> 25#include <qmap.h>
24#include <qpushbutton.h> 26#include <qpushbutton.h>
25#include <qspinbox.h> 27#include <qspinbox.h>
26#include <qtextstream.h> 28#include <qtextstream.h>
27 29
28/* OPIE */ 30/* OPIE */
29#include <opie2/onetwork.h> 31#include <opie2/onetwork.h>
30 32
31WellenreiterConfigWindow* WellenreiterConfigWindow::_instance = 0; 33WellenreiterConfigWindow* WellenreiterConfigWindow::_instance = 0;
32 34
33WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f ) 35WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f )
34 :WellenreiterConfigBase( parent, name, true, f ) 36 :WellenreiterConfigBase( parent, name, true, f )
35{ 37{
36 _devicetype[ "cisco" ] = 1; 38 _devicetype[ "cisco" ] = DEVTYPE_CISCO;
37 _devicetype[ "wlan-ng" ] = 2; 39 _devicetype[ "wlan-ng" ] = DEVTYPE_WLAN_NG;
38 _devicetype[ "hostap" ] = 3; 40 _devicetype[ "hostap" ] = DEVTYPE_HOSTAP;
39 _devicetype[ "orinoco" ] = 4; 41 _devicetype[ "orinoco" ] = DEVTYPE_ORINOCO;
40 _devicetype[ "<manual>" ] = 5; 42 _devicetype[ "<manual>" ] = DEVTYPE_MANUAL;
43 _devicetype[ "<file>" ] = DEVTYPE_FILE;
41 44
42 // gather possible interface names from ONetwork 45 // gather possible interface names from ONetwork
43 ONetwork* net = ONetwork::instance(); 46 ONetwork* net = ONetwork::instance();
44 ONetwork::InterfaceIterator it = net->iterator(); 47 ONetwork::InterfaceIterator it = net->iterator();
45 while ( it.current() ) 48 while ( it.current() )
46 { 49 {
47 if ( it.current()->isWireless() ) 50 if ( it.current()->isWireless() )
48 interfaceName->insertItem( it.current()->name() ); 51 interfaceName->insertItem( it.current()->name() );
49 ++it; 52 ++it;
50 } 53 }
51 54
52 // try to guess device type 55 // try to guess device type
53 QFile m( "/proc/modules" ); 56 QFile m( "/proc/modules" );
54 if ( m.open( IO_ReadOnly ) ) 57 if ( m.open( IO_ReadOnly ) )
55 { 58 {
56 int devicetype(0); 59 int devicetype(0);
57 QString line; 60 QString line;
58 QTextStream modules( &m ); 61 QTextStream modules( &m );
59 while( !modules.atEnd() && !devicetype ) 62 while( !modules.atEnd() && !devicetype )
60 { 63 {
61 modules >> line; 64 modules >> line;
62 if ( line.contains( "cisco" ) ) devicetype = 1; 65 if ( line.contains( "cisco" ) ) devicetype = DEVTYPE_CISCO;
63 else if ( line.contains( "hostap" ) ) devicetype = 3; 66 else if ( line.contains( "hostap" ) ) devicetype = DEVTYPE_HOSTAP;
64 else if ( line.contains( "prism" ) ) devicetype = 2; 67 else if ( line.contains( "prism" ) ) devicetype = DEVTYPE_WLAN_NG;
65 else if ( line.contains( "orinoco" ) ) devicetype = 4; 68 else if ( line.contains( "orinoco" ) ) devicetype = DEVTYPE_ORINOCO;
66 } 69 }
67 if ( devicetype ) 70 if ( devicetype )
68 { 71 {
69 deviceType->setCurrentItem( devicetype ); 72 deviceType->setCurrentItem( devicetype );
70 qDebug( "Wellenreiter: guessed device type to be %d", devicetype ); 73 _guess = devicetype;
74 qDebug( "Wellenreiter: guessed device type to be #%d", devicetype );
71 } 75 }
72 } 76 }
73 77
74 #ifdef Q_WS_X11 // We're on X11: adding an Ok-Button for the Dialog here 78 #ifdef Q_WS_X11 // We're on X11: adding an Ok-Button for the Dialog here
75 QPushButton* okButton = new QPushButton( "ok", this ); 79 QPushButton* okButton = new QPushButton( "ok", this );
76 okButton->show(); 80 okButton->show();
77 Layout5_2->addWidget( okButton, 0, 3 ); //FIXME: rename this in configbase.ui 81 Layout5_2->addWidget( okButton, 0, 3 ); //FIXME: rename this in configbase.ui
78 connect( okButton, SIGNAL( clicked() ), this, SLOT( accept() ) ); 82 connect( okButton, SIGNAL( clicked() ), this, SLOT( accept() ) );
79 #endif 83 #endif
80 84
81 WellenreiterConfigWindow::_instance = this; 85 WellenreiterConfigWindow::_instance = this;
86
87 connect( deviceType, SIGNAL( activated(int) ), this, SLOT( changedDeviceType(int) ) );
82}; 88};
83 89
90
84int WellenreiterConfigWindow::daemonDeviceType() 91int WellenreiterConfigWindow::daemonDeviceType()
85{ 92{
86 QString name = deviceType->currentText(); 93 QString name = deviceType->currentText();
87 if ( _devicetype.contains( name ) ) 94 if ( _devicetype.contains( name ) )
88 { 95 {
89 return _devicetype[name]; 96 return _devicetype[name];
90 } 97 }
91 else 98 else
92 { 99 {
93 return 0; 100 return 0;
94 } 101 }
95}; 102};
96 103
104
97int WellenreiterConfigWindow::daemonHopInterval() 105int WellenreiterConfigWindow::daemonHopInterval()
98{ 106{
99 return hopInterval->cleanText().toInt(); 107 return hopInterval->cleanText().toInt();
100} 108}
109
110
111void WellenreiterConfigWindow::changedDeviceType(int t)
112{
113 if ( t != DEVTYPE_FILE ) return;
114 QString name = ( (WellenreiterMainWindow*) qApp->mainWidget() )->getFileName(false);
115 if ( !name.isNull() && QFile::exists( name ) )
116 {
117 interfaceName->insertItem( name );
118 interfaceName->setCurrentItem( interfaceName->count()-1 );
119 }
120 else
121 {
122 deviceType->setCurrentItem( _guess );
123 }
124
125}
126
diff --git a/noncore/net/wellenreiter/gui/configwindow.h b/noncore/net/wellenreiter/gui/configwindow.h
index 5fd0327..7df1a80 100644
--- a/noncore/net/wellenreiter/gui/configwindow.h
+++ b/noncore/net/wellenreiter/gui/configwindow.h
@@ -1,44 +1,56 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Opie Environment. 4** This file is part of Opie Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14**********************************************************************/ 14**********************************************************************/
15 15
16#ifndef WELLENREITERCONFIGWINDOW_H 16#ifndef WELLENREITERCONFIGWINDOW_H
17#define WELLENREITERCONFIGWINDOW_H 17#define WELLENREITERCONFIGWINDOW_H
18 18
19#include "configbase.h" 19#include "configbase.h"
20#include <qmap.h> 20#include <qmap.h>
21#include <qcombobox.h> 21#include <qcombobox.h>
22#include <qstring.h> 22#include <qstring.h>
23 23
24const int DEVTYPE_SELECT = 0;
25const int DEVTYPE_CISCO = 1;
26const int DEVTYPE_WLAN_NG = 2;
27const int DEVTYPE_HOSTAP = 3;
28const int DEVTYPE_ORINOCO = 4;
29const int DEVTYPE_MANUAL = 5;
30const int DEVTYPE_FILE = 6;
31
24class WellenreiterConfigWindow; 32class WellenreiterConfigWindow;
25 33
26class WellenreiterConfigWindow : public WellenreiterConfigBase 34class WellenreiterConfigWindow : public WellenreiterConfigBase
27{ 35{
36 Q_OBJECT
28 37
29 public: 38 public:
30 WellenreiterConfigWindow( QWidget * parent = 0, const char * name = "WellenreiterConfigWindow", WFlags f = 0 ); 39 WellenreiterConfigWindow( QWidget * parent = 0, const char * name = "WellenreiterConfigWindow", WFlags f = 0 );
31 int daemonDeviceType(); 40 int daemonDeviceType();
32 int daemonHopInterval(); 41 int daemonHopInterval();
33 const QString soundOnNetwork() const { return netSound->currentText(); }; 42 const QString soundOnNetwork() const { return netSound->currentText(); };
34 const QString soundOnBeacon() const { return beaconSound->currentText(); }; 43 const QString soundOnBeacon() const { return beaconSound->currentText(); };
35 static WellenreiterConfigWindow* instance() { return _instance; }; 44 static WellenreiterConfigWindow* instance() { return _instance; };
36 45
46 public slots:
47 void changedDeviceType(int);
48
37 protected: 49 protected:
38 QMap<QString, int> _devicetype; 50 QMap<QString, int> _devicetype;
39 static WellenreiterConfigWindow* _instance; 51 static WellenreiterConfigWindow* _instance;
52 int _guess;
40 53
41}; 54};
42 55
43#endif 56#endif
44
diff --git a/noncore/net/wellenreiter/gui/mainwindow.cpp b/noncore/net/wellenreiter/gui/mainwindow.cpp
index 94e3f28..6cd364c 100644
--- a/noncore/net/wellenreiter/gui/mainwindow.cpp
+++ b/noncore/net/wellenreiter/gui/mainwindow.cpp
@@ -194,98 +194,100 @@ void WellenreiterMainWindow::updateToolButtonState()
194 startButton->setEnabled( false ); 194 startButton->setEnabled( false );
195 menuBar()->setItemEnabled( startID, false ); 195 menuBar()->setItemEnabled( startID, false );
196 } 196 }
197} 197}
198 198
199 199
200void WellenreiterMainWindow::changedSniffingState() 200void WellenreiterMainWindow::changedSniffingState()
201{ 201{
202 startButton->setEnabled( !mw->sniffing ); 202 startButton->setEnabled( !mw->sniffing );
203 menuBar()->setItemEnabled( startID, !mw->sniffing ); 203 menuBar()->setItemEnabled( startID, !mw->sniffing );
204 stopButton->setEnabled( mw->sniffing ); 204 stopButton->setEnabled( mw->sniffing );
205 menuBar()->setItemEnabled( stopID, mw->sniffing ); 205 menuBar()->setItemEnabled( stopID, mw->sniffing );
206} 206}
207 207
208 208
209WellenreiterMainWindow::~WellenreiterMainWindow() 209WellenreiterMainWindow::~WellenreiterMainWindow()
210{ 210{
211 delete infoIconSet; 211 delete infoIconSet;
212 delete settingsIconSet; 212 delete settingsIconSet;
213 delete startIconSet; 213 delete startIconSet;
214 delete stopIconSet; 214 delete stopIconSet;
215}; 215};
216 216
217void WellenreiterMainWindow::demoAddStations() 217void WellenreiterMainWindow::demoAddStations()
218{ 218{
219 mw->netView()->addNewItem( "managed", "Vanille", "00:00:20:EF:A6:43", true, 6, 80 ); 219 mw->netView()->addNewItem( "managed", "Vanille", "00:00:20:EF:A6:43", true, 6, 80 );
220 mw->netView()->addNewItem( "managed", "Vanille", "00:30:6D:EF:A6:23", true, 11, 10 ); 220 mw->netView()->addNewItem( "managed", "Vanille", "00:30:6D:EF:A6:23", true, 11, 10 );
221 mw->netView()->addNewItem( "adhoc", "ELAN", "00:A0:F8:E7:16:22", false, 3, 10 ); 221 mw->netView()->addNewItem( "adhoc", "ELAN", "00:A0:F8:E7:16:22", false, 3, 10 );
222 mw->netView()->addNewItem( "adhoc", "ELAN", "00:AA:01:E7:56:62", false, 3, 15 ); 222 mw->netView()->addNewItem( "adhoc", "ELAN", "00:AA:01:E7:56:62", false, 3, 15 );
223 mw->netView()->addNewItem( "adhoc", "ELAN", "00:B0:8E:E7:56:E2", false, 3, 20 ); 223 mw->netView()->addNewItem( "adhoc", "ELAN", "00:B0:8E:E7:56:E2", false, 3, 20 );
224} 224}
225 225
226
226QString WellenreiterMainWindow::getFileName( bool save ) 227QString WellenreiterMainWindow::getFileName( bool save )
227{ 228{
228 QMap<QString, QStringList> map; 229 QMap<QString, QStringList> map;
229 map.insert( tr("All"), QStringList() ); 230 map.insert( tr("All"), QStringList() );
230 QStringList text; 231 QStringList text;
231 text << "text/*"; 232 text << "text/*";
232 map.insert(tr("Text"), text ); 233 map.insert(tr("Text"), text );
233 text << "*"; 234 text << "*";
234 map.insert(tr("All"), text ); 235 map.insert(tr("All"), text );
235 236
236 QString str; 237 QString str;
237 if ( save ) 238 if ( save )
238 { 239 {
239 #ifdef QWS 240 #ifdef QWS
240 str = OFileDialog::getSaveFileName( 2, "/", QString::null, map ); 241 str = OFileDialog::getSaveFileName( 2, "/", QString::null, map );
241 #else 242 #else
242 str = QFileDialog::getSaveFileName(); 243 str = QFileDialog::getSaveFileName();
243 #endif 244 #endif
244 if ( str.isEmpty() || QFileInfo(str).isDir() ) 245 if ( str.isEmpty() || QFileInfo(str).isDir() )
245 return ""; 246 return "";
246 } 247 }
247 else 248 else
248 { 249 {
249 #ifdef QWS 250 #ifdef QWS
250 str = OFileDialog::getOpenFileName( 2, "/", QString::null, map ); 251 str = OFileDialog::getOpenFileName( 2, "/", QString::null, map );
251 #else 252 #else
252 str = QFileDialog::getOpenFileName(); 253 str = QFileDialog::getOpenFileName();
253 #endif 254 #endif
254 if ( str.isEmpty() || !QFile(str).exists() || QFileInfo(str).isDir() ) 255 if ( str.isEmpty() || !QFile(str).exists() || QFileInfo(str).isDir() )
255 return ""; 256 return "";
256 } 257 }
257 return str; 258 return str;
258} 259}
259 260
261
260void WellenreiterMainWindow::fileSaveLog() 262void WellenreiterMainWindow::fileSaveLog()
261{ 263{
262 QString fname = getFileName( true ); 264 QString fname = getFileName( true );
263 if ( !fname.isEmpty() ) 265 if ( !fname.isEmpty() )
264 { 266 {
265 QFile f( fname ); 267 QFile f( fname );
266 if ( f.open(IO_WriteOnly) ) 268 if ( f.open(IO_WriteOnly) )
267 { 269 {
268 QTextStream t( &f ); 270 QTextStream t( &f );
269 t << mw->logWindow()->getLog(); 271 t << mw->logWindow()->getLog();
270 f.close(); 272 f.close();
271 qDebug( "Saved log to file '%s'", (const char*) fname ); 273 qDebug( "Saved log to file '%s'", (const char*) fname );
272 } 274 }
273 else 275 else
274 { 276 {
275 qDebug( "Problem saving log to file '%s'", (const char*) fname ); 277 qDebug( "Problem saving log to file '%s'", (const char*) fname );
276 } 278 }
277 } 279 }
278} 280}
279 281
280void WellenreiterMainWindow::fileSaveSession() 282void WellenreiterMainWindow::fileSaveSession()
281{ 283{
282 QString fname = getFileName( true ); 284 QString fname = getFileName( true );
283 if ( !fname.isEmpty() ) 285 if ( !fname.isEmpty() )
284 { 286 {
285 287
286 QFile f( fname ); 288 QFile f( fname );
287 if ( f.open(IO_WriteOnly) ) 289 if ( f.open(IO_WriteOnly) )
288 { 290 {
289 QDataStream t( &f ); 291 QDataStream t( &f );
290 t << *mw->netView(); 292 t << *mw->netView();
291 f.close(); 293 f.close();
diff --git a/noncore/net/wellenreiter/gui/mainwindow.h b/noncore/net/wellenreiter/gui/mainwindow.h
index 1e191e5..926bb0a 100644
--- a/noncore/net/wellenreiter/gui/mainwindow.h
+++ b/noncore/net/wellenreiter/gui/mainwindow.h
@@ -1,66 +1,64 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Opie Environment. 4** This file is part of Opie Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14**********************************************************************/ 14**********************************************************************/
15 15
16#ifndef MAINWINDOW_H 16#ifndef MAINWINDOW_H
17#define MAINWINDOW_H 17#define MAINWINDOW_H
18 18
19#include <qmainwindow.h> 19#include <qmainwindow.h>
20 20
21class Wellenreiter; 21class Wellenreiter;
22class WellenreiterConfigWindow; 22class WellenreiterConfigWindow;
23class QIconSet; 23class QIconSet;
24class QToolButton; 24class QToolButton;
25 25
26class WellenreiterMainWindow: public QMainWindow 26class WellenreiterMainWindow: public QMainWindow
27{ 27{
28 Q_OBJECT 28 Q_OBJECT
29 29
30 public: 30 public:
31 WellenreiterMainWindow( QWidget * parent = 0, const char * name = "mainwindow", WFlags f = 0 ); 31 WellenreiterMainWindow( QWidget * parent = 0, const char * name = "mainwindow", WFlags f = 0 );
32 ~WellenreiterMainWindow(); 32 ~WellenreiterMainWindow();
33 QString getFileName( bool save );
33 34
34 protected: 35 protected:
35 Wellenreiter* mw; 36 Wellenreiter* mw;
36 WellenreiterConfigWindow* cw; 37 WellenreiterConfigWindow* cw;
37 38
38 const QIconSet* startIconSet; 39 const QIconSet* startIconSet;
39 const QIconSet* stopIconSet; 40 const QIconSet* stopIconSet;
40 const QIconSet* infoIconSet; 41 const QIconSet* infoIconSet;
41 const QIconSet* settingsIconSet; 42 const QIconSet* settingsIconSet;
42 43
43 QToolButton* startButton; 44 QToolButton* startButton;
44 QToolButton* stopButton; 45 QToolButton* stopButton;
45 int startID; 46 int startID;
46 int stopID; 47 int stopID;
47 48
48 protected: 49 protected:
49 virtual void closeEvent( QCloseEvent* ); 50 virtual void closeEvent( QCloseEvent* );
50 void updateToolButtonState(); 51 void updateToolButtonState();
51 52
52 private:
53 QString getFileName( bool save );
54
55 public slots: 53 public slots:
56 void showConfigure(); 54 void showConfigure();
57 void demoAddStations(); 55 void demoAddStations();
58 void fileSaveLog(); 56 void fileSaveLog();
59 void fileSaveHex(); 57 void fileSaveHex();
60 void fileSaveSession(); 58 void fileSaveSession();
61 void fileLoadSession(); 59 void fileLoadSession();
62 void fileNew(); 60 void fileNew();
63 void changedSniffingState(); 61 void changedSniffingState();
64}; 62};
65 63
66#endif 64#endif
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index 3372883..5c10c3b 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -192,148 +192,174 @@ void Wellenreiter::receivePacket(OPacket* p)
192 wlan->macAddress1().toString() ); 192 wlan->macAddress1().toString() );
193 } 193 }
194 else 194 else
195 if ( wlan->fromDS() && wlan->toDS() ) 195 if ( wlan->fromDS() && wlan->toDS() )
196 { 196 {
197 qDebug( "WSD(bridge) traffic: '%s' -> '%s' via '%s' and '%s'", 197 qDebug( "WSD(bridge) traffic: '%s' -> '%s' via '%s' and '%s'",
198 (const char*) wlan->macAddress4().toString(true), 198 (const char*) wlan->macAddress4().toString(true),
199 (const char*) wlan->macAddress3().toString(true), 199 (const char*) wlan->macAddress3().toString(true),
200 (const char*) wlan->macAddress1().toString(true), 200 (const char*) wlan->macAddress1().toString(true),
201 (const char*) wlan->macAddress2().toString(true) ); 201 (const char*) wlan->macAddress2().toString(true) );
202 netView()->traffic( "WSD", wlan->macAddress4().toString(), 202 netView()->traffic( "WSD", wlan->macAddress4().toString(),
203 wlan->macAddress3().toString(), 203 wlan->macAddress3().toString(),
204 wlan->macAddress1().toString(), 204 wlan->macAddress1().toString(),
205 wlan->macAddress2().toString() ); 205 wlan->macAddress2().toString() );
206 } 206 }
207 else 207 else
208 { 208 {
209 qDebug( "IBSS(AdHoc) traffic: '%s' -> '%s' (Cell: '%s')'", 209 qDebug( "IBSS(AdHoc) traffic: '%s' -> '%s' (Cell: '%s')'",
210 (const char*) wlan->macAddress2().toString(true), 210 (const char*) wlan->macAddress2().toString(true),
211 (const char*) wlan->macAddress1().toString(true), 211 (const char*) wlan->macAddress1().toString(true),
212 (const char*) wlan->macAddress3().toString(true) ); 212 (const char*) wlan->macAddress3().toString(true) );
213 netView()->traffic( "IBSS", wlan->macAddress2().toString(), 213 netView()->traffic( "IBSS", wlan->macAddress2().toString(),
214 wlan->macAddress1().toString(), 214 wlan->macAddress1().toString(),
215 wlan->macAddress3().toString() ); 215 wlan->macAddress3().toString() );
216 } 216 }
217 return; 217 return;
218 } 218 }
219} 219}
220 220
221 221
222void Wellenreiter::stopClicked() 222void Wellenreiter::stopClicked()
223{ 223{
224 disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); 224 if ( iface )
225 disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); 225 {
226 iface->setChannelHopping(); // stop hopping channels 226 disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) );
227 disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) );
228 iface->setChannelHopping(); // stop hopping channels
229 }
230 else
231 killTimers();
232
227 pcap->close(); 233 pcap->close();
228 sniffing = false; 234 sniffing = false;
229 #ifdef QWS
230 oApp->setTitle();
231 #else
232 qApp->mainWidget()->setCaption( "Wellenreiter II" );
233 #endif
234 235
235 // get interface name from config window 236 if ( iface )
236 const QString& interface = configwindow->interfaceName->currentText(); 237 {
237 ONetwork* net = ONetwork::instance(); 238 // switch off monitor mode
238 iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); 239 iface->setMonitorMode( false );
240 // switch off promisc flag
241 iface->setPromiscuousMode( false );
239 242
240 // switch off monitor mode 243 system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess
241 iface->setMonitorMode( false ); 244 }
242 // switch off promisc flag
243 iface->setPromiscuousMode( false );
244 245
245 system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess
246 logwindow->log( "(i) Stopped Scanning." ); 246 logwindow->log( "(i) Stopped Scanning." );
247 assert( parent() ); 247 assert( parent() );
248 ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" ); 248 ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" );
249 249
250 // message the user 250 // message the user
251 QMessageBox::information( this, "Wellenreiter II", "Your wireless card\nshould now be usable again." ); 251 QMessageBox::information( this, "Wellenreiter II", "Your wireless card\nshould now be usable again." );
252 252
253 sniffing = false; 253 sniffing = false;
254 emit( stoppedSniffing() ); 254 emit( stoppedSniffing() );
255 255
256 // print out statistics 256 // print out statistics
257 statwindow->log( "-----------------------------------------" ); 257 statwindow->log( "-----------------------------------------" );
258 statwindow->log( "- Wellenreiter II Capturing Statistic -" ); 258 statwindow->log( "- Wellenreiter II Capturing Statistic -" );
259 statwindow->log( "-----------------------------------------" ); 259 statwindow->log( "-----------------------------------------" );
260 statwindow->log( "Packet Type | Receive Count" ); 260 statwindow->log( "Packet Type | Receive Count" );
261 261
262 for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it ) 262 for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it )
263 { 263 {
264 QString left; 264 QString left;
265 left.sprintf( "%s", (const char*) it.key() ); 265 left.sprintf( "%s", (const char*) it.key() );
266 left = left.leftJustify( 20 ); 266 left = left.leftJustify( 20 );
267 left.append( '|' ); 267 left.append( '|' );
268 QString right; 268 QString right;
269 right.sprintf( "%d", it.data() ); 269 right.sprintf( "%d", it.data() );
270 right = right.rightJustify( 7 ); 270 right = right.rightJustify( 7 );
271 statwindow->log( left + right ); 271 statwindow->log( left + right );
272 } 272 }
273 273
274} 274}
275 275
276 276
277void Wellenreiter::startClicked() 277void Wellenreiter::startClicked()
278{ 278{
279 // get configuration from config window 279 // get configuration from config window
280 280
281 const QString& interface = configwindow->interfaceName->currentText(); 281 const QString& interface = configwindow->interfaceName->currentText();
282 const int cardtype = configwindow->daemonDeviceType(); 282 const int cardtype = configwindow->daemonDeviceType();
283 const int interval = configwindow->daemonHopInterval(); 283 const int interval = configwindow->daemonHopInterval();
284 284
285 if ( ( interface == "" ) || ( cardtype == 0 ) ) 285 if ( ( interface == "" ) || ( cardtype == 0 ) )
286 { 286 {
287 QMessageBox::information( this, "Wellenreiter II", "Your device is not\nproperly configured. Please reconfigure!" ); 287 QMessageBox::information( this, "Wellenreiter II", "Your device is not\nproperly configured. Please reconfigure!" );
288 return; 288 return;
289 } 289 }
290 290
291 // configure device 291 // configure device
292 292
293 ONetwork* net = ONetwork::instance(); 293 ONetwork* net = ONetwork::instance();
294 iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); 294 iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface ));
295 295
296 // set monitor mode 296 // set monitor mode
297 297
298 switch ( cardtype ) 298 switch ( cardtype )
299 { 299 {
300 case 1: iface->setMonitoring( new OCiscoMonitoringInterface( iface ) ); break; 300 case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface ) ); break;
301 case 2: iface->setMonitoring( new OWlanNGMonitoringInterface( iface ) ); break; 301 case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface ) ); break;
302 case 3: iface->setMonitoring( new OHostAPMonitoringInterface( iface ) ); break; 302 case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface ) ); break;
303 case 4: iface->setMonitoring( new OOrinocoMonitoringInterface( iface ) ); break; 303 case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface ) ); break;
304 default: 304 case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", "Bring your device into\nmonitor mode now." ); break;
305 QMessageBox::information( this, "Wellenreiter II", "Bring your device into\nmonitor mode now." ); 305 case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break;
306 default: assert( 0 ); // shouldn't reach this
306 } 307 }
307 308
308 if ( cardtype > 0 && cardtype < 5 ) 309 // switch device into monitor mode
309 iface->setMonitorMode( true ); 310 if ( cardtype < DEVTYPE_FILE )
310
311 if ( !iface->monitorMode() )
312 { 311 {
313 QMessageBox::warning( this, "Wellenreiter II", "Can't set device into monitor mode." ); 312 if ( cardtype != DEVTYPE_MANUAL )
314 return; 313 iface->setMonitorMode( true );
314 if ( !iface->monitorMode() )
315 {
316 QMessageBox::warning( this, "Wellenreiter II", "Can't set device into monitor mode." );
317 return;
318 }
315 } 319 }
316 320
317 // open pcap and start sniffing 321 // open pcap and start sniffing
318 pcap->open( interface ); 322 if ( cardtype != DEVTYPE_FILE )
323 pcap->open( interface );
324 else
325 pcap->open( QFile( interface ) );
319 326
320 if ( !pcap->isOpen() ) 327 if ( !pcap->isOpen() )
321 { 328 {
322 QMessageBox::warning( this, "Wellenreiter II", "Can't open packet capturer:\n" + QString(strerror( errno ) )); 329 QMessageBox::warning( this, "Wellenreiter II", "Can't open packet capturer:\n" + QString(strerror( errno ) ));
323 return; 330 return;
324 } 331 }
325 332
326 // set capturer to non-blocking mode 333 // set capturer to non-blocking mode
327 pcap->setBlocking( false ); 334 pcap->setBlocking( false );
328 335
329 // start channel hopper 336 // start channel hopper
330 iface->setChannelHopping( 1000 ); //use interval from config window 337 if ( cardtype != DEVTYPE_FILE )
338 iface->setChannelHopping( 1000 ); //use interval from config window
331 339
332 // connect 340 if ( cardtype != DEVTYPE_FILE )
333 connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); 341 {
334 connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); 342 // connect socket notifier and start channel hopper
343 connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) );
344 connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) );
345 }
346 else
347 {
348 // start timer for reading packets
349 startTimer( 100 );
350 }
335 351
336 logwindow->log( "(i) Started Scanning." ); 352 logwindow->log( "(i) Started Scanning." );
337 sniffing = true; 353 sniffing = true;
338 emit( startedSniffing() ); 354 emit( startedSniffing() );
339} 355}
356
357
358void Wellenreiter::timerEvent( QTimerEvent* )
359{
360 qDebug( "Wellenreiter::timerEvent()" );
361 OPacket* p = pcap->next();
362 receivePacket( p );
363 delete p;
364}
365
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.h b/noncore/net/wellenreiter/gui/wellenreiter.h
index 839c77e..c37a9f2 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.h
+++ b/noncore/net/wellenreiter/gui/wellenreiter.h
@@ -20,59 +20,62 @@
20 20
21#ifdef QWS 21#ifdef QWS
22#include <opie/odevice.h> 22#include <opie/odevice.h>
23using namespace Opie; 23using namespace Opie;
24#endif 24#endif
25 25
26class QTimerEvent; 26class QTimerEvent;
27class QPixmap; 27class QPixmap;
28class OPacket; 28class OPacket;
29class OPacketCapturer; 29class OPacketCapturer;
30class OWirelessNetworkInterface; 30class OWirelessNetworkInterface;
31 31
32class ManufacturerDB; 32class ManufacturerDB;
33class WellenreiterConfigWindow; 33class WellenreiterConfigWindow;
34class MLogWindow; 34class MLogWindow;
35class MHexWindow; 35class MHexWindow;
36 36
37class Wellenreiter : public WellenreiterBase { 37class Wellenreiter : public WellenreiterBase {
38 Q_OBJECT 38 Q_OBJECT
39 39
40 public: 40 public:
41 Wellenreiter( QWidget* parent = 0 ); 41 Wellenreiter( QWidget* parent = 0 );
42 ~Wellenreiter(); 42 ~Wellenreiter();
43 43
44 void setConfigWindow( WellenreiterConfigWindow* cw ); 44 void setConfigWindow( WellenreiterConfigWindow* cw );
45 MScanListView* netView() const { return netview; }; 45 MScanListView* netView() const { return netview; };
46 MLogWindow* logWindow() const { return logwindow; }; 46 MLogWindow* logWindow() const { return logwindow; };
47 MHexWindow* hexWindow() const { return hexwindow; }; 47 MHexWindow* hexWindow() const { return hexwindow; };
48 bool isDaemonRunning() const { return sniffing; }; 48 bool isDaemonRunning() const { return sniffing; };
49 49
50 bool sniffing; 50 bool sniffing;
51 51
52 protected:
53 virtual void timerEvent( QTimerEvent* );
54
52 public slots: 55 public slots:
53 void channelHopped(int); 56 void channelHopped(int);
54 void receivePacket(OPacket*); 57 void receivePacket(OPacket*);
55 void startClicked(); 58 void startClicked();
56 void stopClicked(); 59 void stopClicked();
57 60
58 signals: 61 signals:
59 void startedSniffing(); 62 void startedSniffing();
60 void stoppedSniffing(); 63 void stoppedSniffing();
61 64
62 private: 65 private:
63 #ifdef QWS 66 #ifdef QWS
64 OSystem _system; // Opie Operating System identifier 67 OSystem _system; // Opie Operating System identifier
65 #endif 68 #endif
66 69
67 OWirelessNetworkInterface* iface; 70 OWirelessNetworkInterface* iface;
68 OPacketCapturer* pcap; 71 OPacketCapturer* pcap;
69 ManufacturerDB* manufacturerdb; 72 ManufacturerDB* manufacturerdb;
70 WellenreiterConfigWindow* configwindow; 73 WellenreiterConfigWindow* configwindow;
71 74
72 //void readConfig(); 75 //void readConfig();
73 //void writeConfig(); 76 //void writeConfig();
74}; 77};
75 78
76 79
77 80
78#endif 81#endif