summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2004-05-03 13:50:22 (UTC)
committer mickeyl <mickeyl>2004-05-03 13:50:22 (UTC)
commitaad04cffe30ef133edcd5051ce7e486f27599d83 (patch) (unidiff)
tree830ccec1732ae743073511268c7bb67764c4fb6b
parent9efa98c49988a41de7613f56818f2e31bb24e22b (diff)
downloadopie-aad04cffe30ef133edcd5051ce7e486f27599d83.zip
opie-aad04cffe30ef133edcd5051ce7e486f27599d83.tar.gz
opie-aad04cffe30ef133edcd5051ce7e486f27599d83.tar.bz2
don't always write a capture file
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/mainwindow.cpp30
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp12
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.h2
3 files changed, 22 insertions, 22 deletions
diff --git a/noncore/net/wellenreiter/gui/mainwindow.cpp b/noncore/net/wellenreiter/gui/mainwindow.cpp
index 8525109..ef7ffcf 100644
--- a/noncore/net/wellenreiter/gui/mainwindow.cpp
+++ b/noncore/net/wellenreiter/gui/mainwindow.cpp
@@ -1,582 +1,582 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Wellenreiter II. 4** This file is part of Wellenreiter II.
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#include "configwindow.h" 16#include "configwindow.h"
17#include "gps.h" 17#include "gps.h"
18#include "logwindow.h" 18#include "logwindow.h"
19#include "packetview.h" 19#include "packetview.h"
20#include "mainwindow.h" 20#include "mainwindow.h"
21#include "wellenreiter.h" 21#include "wellenreiter.h"
22#include "scanlist.h" 22#include "scanlist.h"
23 23
24/* OPIE */ 24/* OPIE */
25#ifdef QWS 25#ifdef QWS
26#include <qpe/resource.h> 26#include <qpe/resource.h>
27#include <opie2/odebug.h> 27#include <opie2/odebug.h>
28#include <opie2/ofiledialog.h> 28#include <opie2/ofiledialog.h>
29#else 29#else
30#include "resource.h" 30#include "resource.h"
31#include <qapplication.h> 31#include <qapplication.h>
32#include <qfiledialog.h> 32#include <qfiledialog.h>
33#endif 33#endif
34using namespace Opie::Core; 34using namespace Opie::Core;
35using namespace Opie::Net; 35using namespace Opie::Net;
36using namespace Opie::Ui; 36using namespace Opie::Ui;
37 37
38/* QT */ 38/* QT */
39#include <qcombobox.h> 39#include <qcombobox.h>
40#include <qdatastream.h> 40#include <qdatastream.h>
41#include <qfile.h> 41#include <qfile.h>
42#include <qfileinfo.h> 42#include <qfileinfo.h>
43#include <qlabel.h> 43#include <qlabel.h>
44#include <qlayout.h> 44#include <qlayout.h>
45#include <qlineedit.h> 45#include <qlineedit.h>
46#include <qiconset.h> 46#include <qiconset.h>
47#include <qmenubar.h> 47#include <qmenubar.h>
48#include <qmessagebox.h> 48#include <qmessagebox.h>
49#include <qpopupmenu.h> 49#include <qpopupmenu.h>
50#include <qpushbutton.h> 50#include <qpushbutton.h>
51#include <qstatusbar.h> 51#include <qstatusbar.h>
52#include <qspinbox.h> 52#include <qspinbox.h>
53#include <qtextstream.h> 53#include <qtextstream.h>
54#include <qtoolbutton.h> 54#include <qtoolbutton.h>
55#include <qwhatsthis.h> 55#include <qwhatsthis.h>
56 56
57/* STD */ 57/* STD */
58#include <unistd.h> 58#include <unistd.h>
59 59
60WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * name, WFlags f ) 60WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * name, WFlags f )
61 :QMainWindow( parent, name, f ) 61 :QMainWindow( parent, name, f )
62{ 62{
63 cw = new WellenreiterConfigWindow( this ); 63 cw = new WellenreiterConfigWindow( this );
64 mw = new Wellenreiter( this ); 64 mw = new Wellenreiter( this );
65 mw->setConfigWindow( cw ); 65 mw->setConfigWindow( cw );
66 setCentralWidget( mw ); 66 setCentralWidget( mw );
67 67
68 // setup application icon 68 // setup application icon
69 69
70 setIcon( Resource::loadPixmap( "wellenreiter/appicon-trans" ) ); 70 setIcon( Resource::loadPixmap( "wellenreiter/appicon-trans" ) );
71 #ifndef QWS 71 #ifndef QWS
72 setIconText( "Wellenreiter/X11" ); 72 setIconText( "Wellenreiter/X11" );
73 #endif 73 #endif
74 74
75 // setup tool buttons 75 // setup tool buttons
76 76
77 startButton = new QToolButton( 0 ); 77 startButton = new QToolButton( 0 );
78 QWhatsThis::add( startButton, tr( "Click here to start scanning." ) ); 78 QWhatsThis::add( startButton, tr( "Click here to start scanning." ) );
79 #ifdef QWS 79 #ifdef QWS
80 startButton->setAutoRaise( true ); 80 startButton->setAutoRaise( true );
81 #endif 81 #endif
82 startButton->setIconSet( Resource::loadIconSet( "wellenreiter/SearchIcon" ) ); 82 startButton->setIconSet( Resource::loadIconSet( "wellenreiter/SearchIcon" ) );
83 startButton->setEnabled( false ); 83 startButton->setEnabled( false );
84 connect( startButton, SIGNAL( clicked() ), mw, SLOT( startClicked() ) ); 84 connect( startButton, SIGNAL( clicked() ), mw, SLOT( startClicked() ) );
85 85
86 stopButton = new QToolButton( 0 ); 86 stopButton = new QToolButton( 0 );
87 QWhatsThis::add( stopButton, tr( "Click here to stop scanning." ) ); 87 QWhatsThis::add( stopButton, tr( "Click here to stop scanning." ) );
88 #ifdef QWS 88 #ifdef QWS
89 stopButton->setAutoRaise( true ); 89 stopButton->setAutoRaise( true );
90 #endif 90 #endif
91 stopButton->setIconSet( Resource::loadIconSet( "wellenreiter/CancelIcon" ) ); 91 stopButton->setIconSet( Resource::loadIconSet( "wellenreiter/CancelIcon" ) );
92 stopButton->setEnabled( false ); 92 stopButton->setEnabled( false );
93 connect( stopButton, SIGNAL( clicked() ), mw, SLOT( stopClicked() ) ); 93 connect( stopButton, SIGNAL( clicked() ), mw, SLOT( stopClicked() ) );
94 94
95 QToolButton* d = new QToolButton( 0 ); 95 QToolButton* d = new QToolButton( 0 );
96 QWhatsThis::add( d, tr( "Click here to open the configure dialog." ) ), 96 QWhatsThis::add( d, tr( "Click here to open the configure dialog." ) ),
97 #ifdef QWS 97 #ifdef QWS
98 d->setAutoRaise( true ); 98 d->setAutoRaise( true );
99 #endif 99 #endif
100 d->setIconSet( Resource::loadIconSet( "wellenreiter/SettingsIcon" ) ); 100 d->setIconSet( Resource::loadIconSet( "wellenreiter/SettingsIcon" ) );
101 connect( d, SIGNAL( clicked() ), this, SLOT( showConfigure() ) ); 101 connect( d, SIGNAL( clicked() ), this, SLOT( showConfigure() ) );
102 102
103 uploadButton = new QToolButton( 0 ); 103 uploadButton = new QToolButton( 0 );
104 QWhatsThis::add( uploadButton, tr( "Click here to upload a capture session." ) ); 104 QWhatsThis::add( uploadButton, tr( "Click here to upload a capture session." ) );
105 #ifdef QWS 105 #ifdef QWS
106 uploadButton->setAutoRaise( true ); 106 uploadButton->setAutoRaise( true );
107 #endif 107 #endif
108 uploadButton->setIconSet( Resource::loadIconSet( "up" ) ); 108 uploadButton->setIconSet( Resource::loadIconSet( "up" ) );
109 uploadButton->setEnabled( false ); 109 uploadButton->setEnabled( false );
110 //uploadButton->setEnabled( true ); // DEBUGGING 110 //uploadButton->setEnabled( true ); // DEBUGGING
111 connect( uploadButton, SIGNAL( clicked() ), this, SLOT( uploadSession() ) ); 111 connect( uploadButton, SIGNAL( clicked() ), this, SLOT( uploadSession() ) );
112 112
113 // setup menu bar 113 // setup menu bar
114 114
115 int id; 115 int id;
116 116
117 QMenuBar* mb = menuBar(); 117 QMenuBar* mb = menuBar();
118 118
119 QPopupMenu* fileSave = new QPopupMenu( mb ); 119 QPopupMenu* fileSave = new QPopupMenu( mb );
120 fileSave->insertItem( tr( "&Session..." ), this, SLOT( fileSaveSession() ) ); 120 fileSave->insertItem( tr( "&Session..." ), this, SLOT( fileSaveSession() ) );
121 fileSave->insertItem( tr( "&Text Log..." ), this, SLOT( fileSaveLog() ) ); 121 fileSave->insertItem( tr( "&Text Log..." ), this, SLOT( fileSaveLog() ) );
122 fileSave->insertItem( tr( "&Hex Log..." ), this, SLOT( fileSaveHex() ) ); 122 fileSave->insertItem( tr( "&Hex Log..." ), this, SLOT( fileSaveHex() ) );
123 123
124 QPopupMenu* fileLoad = new QPopupMenu( mb ); 124 QPopupMenu* fileLoad = new QPopupMenu( mb );
125 fileLoad->insertItem( tr( "&Session..." ), this, SLOT( fileLoadSession() ) ); 125 fileLoad->insertItem( tr( "&Session..." ), this, SLOT( fileLoadSession() ) );
126 //fileLoad->insertItem( "&Log", this, SLOT( fileLoadLog() ) ); 126 //fileLoad->insertItem( "&Log", this, SLOT( fileLoadLog() ) );
127 127
128 QPopupMenu* file = new QPopupMenu( mb ); 128 QPopupMenu* file = new QPopupMenu( mb );
129 file->insertItem( tr( "&New" ), this, SLOT( fileNew() ) ); 129 file->insertItem( tr( "&New" ), this, SLOT( fileNew() ) );
130 id = file->insertItem( tr( "&Load" ), fileLoad ); 130 id = file->insertItem( tr( "&Load" ), fileLoad );
131 file->insertItem( tr( "&Save" ), fileSave ); 131 file->insertItem( tr( "&Save" ), fileSave );
132 file->insertSeparator(); 132 file->insertSeparator();
133 uploadID = file->insertItem( tr( "&Upload Session" ), this, SLOT( uploadSession() ) ); 133 uploadID = file->insertItem( tr( "&Upload Session" ), this, SLOT( uploadSession() ) );
134 file->insertSeparator(); 134 file->insertSeparator();
135 file->insertItem( tr( "&Exit" ), qApp, SLOT( quit() ) ); 135 file->insertItem( tr( "&Exit" ), qApp, SLOT( quit() ) );
136 136
137 QPopupMenu* sniffer = new QPopupMenu( mb ); 137 QPopupMenu* sniffer = new QPopupMenu( mb );
138 sniffer->insertItem( tr( "&Configure..." ), this, SLOT( showConfigure() ) ); 138 sniffer->insertItem( tr( "&Configure..." ), this, SLOT( showConfigure() ) );
139 sniffer->insertSeparator(); 139 sniffer->insertSeparator();
140 startID = sniffer->insertItem( tr( "&Start" ), mw, SLOT( startClicked() ) ); 140 startID = sniffer->insertItem( tr( "&Start" ), mw, SLOT( startClicked() ) );
141 sniffer->setItemEnabled( startID, false ); 141 sniffer->setItemEnabled( startID, false );
142 stopID = sniffer->insertItem( tr( "Sto&p" ), mw, SLOT( stopClicked() ) ); 142 stopID = sniffer->insertItem( tr( "Sto&p" ), mw, SLOT( stopClicked() ) );
143 sniffer->setItemEnabled( stopID, false ); 143 sniffer->setItemEnabled( stopID, false );
144 144
145 QPopupMenu* view = new QPopupMenu( mb ); 145 QPopupMenu* view = new QPopupMenu( mb );
146 view->insertItem( tr( "&Expand All" ), this, SLOT( viewExpandAll() ) ); 146 view->insertItem( tr( "&Expand All" ), this, SLOT( viewExpandAll() ) );
147 view->insertItem( tr( "&Collapse All" ), this, SLOT( viewCollapseAll() ) ); 147 view->insertItem( tr( "&Collapse All" ), this, SLOT( viewCollapseAll() ) );
148 148
149 QPopupMenu* demo = new QPopupMenu( mb ); 149 QPopupMenu* demo = new QPopupMenu( mb );
150 demo->insertItem( tr( "&Add something" ), this, SLOT( demoAddStations() ) ); 150 demo->insertItem( tr( "&Add something" ), this, SLOT( demoAddStations() ) );
151 //demo->insertItem( tr( "&Read from GPSd" ), this, SLOT( demoReadFromGps() ) ); 151 //demo->insertItem( tr( "&Read from GPSd" ), this, SLOT( demoReadFromGps() ) );
152 152
153 id = mb->insertItem( tr( "&File" ), file ); 153 id = mb->insertItem( tr( "&File" ), file );
154 154
155 id = mb->insertItem( tr( "&View" ), view ); 155 id = mb->insertItem( tr( "&View" ), view );
156 //mb->setItemEnabled( id, false ); 156 //mb->setItemEnabled( id, false );
157 157
158 id = mb->insertItem( tr( "&Sniffer" ), sniffer ); 158 id = mb->insertItem( tr( "&Sniffer" ), sniffer );
159 159
160 id = mb->insertItem( tr( "&Demo" ), demo ); 160 id = mb->insertItem( tr( "&Demo" ), demo );
161 mb->setItemEnabled( id, true ); 161 mb->setItemEnabled( id, true );
162 mb->setItemEnabled( uploadID, false ); 162 mb->setItemEnabled( uploadID, false );
163 163
164 #ifdef QWS 164 #ifdef QWS
165 mb->insertItem( startButton ); 165 mb->insertItem( startButton );
166 mb->insertItem( stopButton ); 166 mb->insertItem( stopButton );
167 mb->insertItem( uploadButton ); 167 mb->insertItem( uploadButton );
168 mb->insertItem( d ); 168 mb->insertItem( d );
169 #else // Qt3 changed the insertion order. It's now totally random :( 169 #else // Qt3 changed the insertion order. It's now totally random :(
170 mb->insertItem( d ); 170 mb->insertItem( d );
171 mb->insertItem( uploadButton ); 171 mb->insertItem( uploadButton );
172 mb->insertItem( stopButton ); 172 mb->insertItem( stopButton );
173 mb->insertItem( startButton ); 173 mb->insertItem( startButton );
174 #endif 174 #endif
175 175
176 updateToolButtonState(); 176 updateToolButtonState();
177 177
178 // setup status bar (for now only on X11) 178 // setup status bar (for now only on X11)
179 179
180 #ifndef QWS 180 #ifndef QWS
181 statusBar()->message( tr( "Ready." ) ); 181 statusBar()->message( tr( "Ready." ) );
182 #endif 182 #endif
183 183
184 connect( mw, SIGNAL( startedSniffing() ), this, SLOT( changedSniffingState() ) ); 184 connect( mw, SIGNAL( startedSniffing() ), this, SLOT( changedSniffingState() ) );
185 connect( mw, SIGNAL( stoppedSniffing() ), this, SLOT( changedSniffingState() ) ); 185 connect( mw, SIGNAL( stoppedSniffing() ), this, SLOT( changedSniffingState() ) );
186}; 186};
187 187
188 188
189 189
190void WellenreiterMainWindow::showConfigure() 190void WellenreiterMainWindow::showConfigure()
191{ 191{
192 odebug << "show configure..." << oendl; 192 odebug << "show configure..." << oendl;
193 cw->setCaption( tr( "Configure" ) ); 193 cw->setCaption( tr( "Configure" ) );
194 int result = QPEApplication::execDialog( cw ); 194 int result = QPEApplication::execDialog( cw );
195 195
196 if ( result ) updateToolButtonState(); 196 if ( result ) updateToolButtonState();
197} 197}
198 198
199 199
200void WellenreiterMainWindow::updateToolButtonState() 200void WellenreiterMainWindow::updateToolButtonState()
201{ 201{
202 const QString& interface = cw->interfaceName->currentText(); 202 const QString& interface = cw->interfaceName->currentText();
203 const int cardtype = cw->driverType(); 203 const int cardtype = cw->driverType();
204 204
205 if ( ( interface != "<select>" ) && ( cardtype != 0 ) ) 205 if ( ( interface != "<select>" ) && ( cardtype != 0 ) )
206 { 206 {
207 startButton->setEnabled( true ); 207 startButton->setEnabled( true );
208 menuBar()->setItemEnabled( startID, true ); 208 menuBar()->setItemEnabled( startID, true );
209 } 209 }
210 else 210 else
211 { 211 {
212 startButton->setEnabled( false ); 212 startButton->setEnabled( false );
213 menuBar()->setItemEnabled( startID, false ); 213 menuBar()->setItemEnabled( startID, false );
214 } 214 }
215} 215}
216 216
217 217
218void WellenreiterMainWindow::changedSniffingState() 218void WellenreiterMainWindow::changedSniffingState()
219{ 219{
220 startButton->setEnabled( !mw->sniffing ); 220 startButton->setEnabled( !mw->sniffing );
221 menuBar()->setItemEnabled( startID, !mw->sniffing ); 221 menuBar()->setItemEnabled( startID, !mw->sniffing );
222 stopButton->setEnabled( mw->sniffing ); 222 stopButton->setEnabled( mw->sniffing );
223 menuBar()->setItemEnabled( stopID, mw->sniffing ); 223 menuBar()->setItemEnabled( stopID, mw->sniffing );
224 224
225 if ( !mw->sniffing ) 225 if ( !mw->sniffing && QFile::exists( mw->dumpname ) )
226 { 226 {
227 menuBar()->setItemEnabled( uploadID, true ); 227 menuBar()->setItemEnabled( uploadID, true );
228 uploadButton->setEnabled( true ); 228 uploadButton->setEnabled( true );
229 } 229 }
230} 230}
231 231
232 232
233WellenreiterMainWindow::~WellenreiterMainWindow() 233WellenreiterMainWindow::~WellenreiterMainWindow()
234{ 234{
235 odebug << "Wellenreiter: bye." << oendl; 235 odebug << "Wellenreiter: bye." << oendl;
236}; 236};
237 237
238 238
239void WellenreiterMainWindow::demoAddStations() 239void WellenreiterMainWindow::demoAddStations()
240{ 240{
241 //mw = 0; // test SIGSEGV handling 241 //mw = 0; // test SIGSEGV handling
242 242
243 mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:00:20:EF:A6:43"), true, 6, 80, GpsLocation( 39.8794, -94.0936) ); 243 mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:00:20:EF:A6:43"), true, 6, 80, GpsLocation( 39.8794, -94.0936) );
244 mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:30:6D:EF:A6:23"), true, 11, 10, GpsLocation( 0.0, 0.0 ) ); 244 mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:30:6D:EF:A6:23"), true, 11, 10, GpsLocation( 0.0, 0.0 ) );
245 mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:03:F8:E7:16:22"), false, 3, 10, GpsLocation( 5.5, 2.3 ) ); 245 mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:03:F8:E7:16:22"), false, 3, 10, GpsLocation( 5.5, 2.3 ) );
246 mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:04:01:E7:56:62"), false, 3, 15, GpsLocation( 2.3, 5.5 ) ); 246 mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:04:01:E7:56:62"), false, 3, 15, GpsLocation( 2.3, 5.5 ) );
247 mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:05:8E:E7:56:E2"), false, 3, 20, GpsLocation( -10.0, -20.5 ) ); 247 mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:05:8E:E7:56:E2"), false, 3, 20, GpsLocation( -10.0, -20.5 ) );
248} 248}
249 249
250 250
251void WellenreiterMainWindow::demoReadFromGps() 251void WellenreiterMainWindow::demoReadFromGps()
252{ 252{
253 WellenreiterConfigWindow* configwindow = WellenreiterConfigWindow::instance(); 253 WellenreiterConfigWindow* configwindow = WellenreiterConfigWindow::instance();
254 GPS* gps = new GPS( this ); 254 GPS* gps = new GPS( this );
255 odebug << "Wellenreiter::demoReadFromGps(): url=gps://" << configwindow->gpsdHost->currentText() << ":" << configwindow->gpsdPort->value() << "/" << oendl; 255 odebug << "Wellenreiter::demoReadFromGps(): url=gps://" << configwindow->gpsdHost->currentText() << ":" << configwindow->gpsdPort->value() << "/" << oendl;
256 gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); 256 gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() );
257 GpsLocation loc = gps->position(); 257 GpsLocation loc = gps->position();
258 QMessageBox::information( this, "Wellenreiter/Opie", tr( "GPS said:\n%1" ).arg( loc.dmsPosition() ) ); 258 QMessageBox::information( this, "Wellenreiter/Opie", tr( "GPS said:\n%1" ).arg( loc.dmsPosition() ) );
259 delete gps; 259 delete gps;
260} 260}
261 261
262 262
263QString WellenreiterMainWindow::getFileName( bool save ) 263QString WellenreiterMainWindow::getFileName( bool save )
264{ 264{
265 QMap<QString, QStringList> map; 265 QMap<QString, QStringList> map;
266 map.insert( tr("All"), QStringList() ); 266 map.insert( tr("All"), QStringList() );
267 QStringList text; 267 QStringList text;
268 text << "text/*"; 268 text << "text/*";
269 map.insert( tr("Text"), text ); 269 map.insert( tr("Text"), text );
270 text << "*"; 270 text << "*";
271 map.insert( tr("All"), text ); 271 map.insert( tr("All"), text );
272 272
273 QString str; 273 QString str;
274 if ( save ) 274 if ( save )
275 { 275 {
276 #ifdef QWS 276 #ifdef QWS
277 str = OFileDialog::getSaveFileName( 2, "/", QString::null, map ); 277 str = OFileDialog::getSaveFileName( 2, "/", QString::null, map );
278 #else 278 #else
279 str = QFileDialog::getSaveFileName(); 279 str = QFileDialog::getSaveFileName();
280 #endif 280 #endif
281 if ( str.isEmpty() /*|| QFileInfo(str).isDir()*/ ) 281 if ( str.isEmpty() /*|| QFileInfo(str).isDir()*/ )
282 return ""; 282 return "";
283 } 283 }
284 else 284 else
285 { 285 {
286 #ifdef QWS 286 #ifdef QWS
287 str = OFileDialog::getOpenFileName( 2, "/", QString::null, map ); 287 str = OFileDialog::getOpenFileName( 2, "/", QString::null, map );
288 #else 288 #else
289 str = QFileDialog::getOpenFileName(); 289 str = QFileDialog::getOpenFileName();
290 #endif 290 #endif
291 if ( str.isEmpty() || !QFile(str).exists() || QFileInfo(str).isDir() ) 291 if ( str.isEmpty() || !QFile(str).exists() || QFileInfo(str).isDir() )
292 return ""; 292 return "";
293 } 293 }
294 return str; 294 return str;
295} 295}
296 296
297 297
298void WellenreiterMainWindow::fileSaveLog() 298void WellenreiterMainWindow::fileSaveLog()
299{ 299{
300 QString fname = getFileName( true ); 300 QString fname = getFileName( true );
301 if ( !fname.isEmpty() ) 301 if ( !fname.isEmpty() )
302 { 302 {
303 QFile f( fname ); 303 QFile f( fname );
304 if ( f.open(IO_WriteOnly) ) 304 if ( f.open(IO_WriteOnly) )
305 { 305 {
306 QTextStream t( &f ); 306 QTextStream t( &f );
307 t << mw->logWindow()->getLog(); 307 t << mw->logWindow()->getLog();
308 f.close(); 308 f.close();
309 odebug << "Saved log to file '" << fname << "'" << oendl; 309 odebug << "Saved log to file '" << fname << "'" << oendl;
310 } 310 }
311 else 311 else
312 { 312 {
313 odebug << "Problem saving log to file '" << fname << "'" << oendl; 313 odebug << "Problem saving log to file '" << fname << "'" << oendl;
314 } 314 }
315 } 315 }
316} 316}
317 317
318void WellenreiterMainWindow::fileSaveSession() 318void WellenreiterMainWindow::fileSaveSession()
319{ 319{
320 QString fname = getFileName( true ); 320 QString fname = getFileName( true );
321 if ( !fname.isEmpty() ) 321 if ( !fname.isEmpty() )
322 { 322 {
323 323
324 QFile f( fname ); 324 QFile f( fname );
325 if ( f.open(IO_WriteOnly) ) 325 if ( f.open(IO_WriteOnly) )
326 { 326 {
327 QDataStream t( &f ); 327 QDataStream t( &f );
328 t << *mw->netView(); 328 t << *mw->netView();
329 f.close(); 329 f.close();
330 odebug << "Saved session to file '" << fname << "'" << oendl; 330 odebug << "Saved session to file '" << fname << "'" << oendl;
331 } 331 }
332 else 332 else
333 { 333 {
334 odebug << "Problem saving session to file '" << fname << "'" << oendl; 334 odebug << "Problem saving session to file '" << fname << "'" << oendl;
335 } 335 }
336 } 336 }
337} 337}
338 338
339void WellenreiterMainWindow::fileSaveHex() 339void WellenreiterMainWindow::fileSaveHex()
340{ 340{
341 #warning DOES NOT WORK AT THE MOMENT 341 #warning DOES NOT WORK AT THE MOMENT
342 /* 342 /*
343 QString fname = getFileName( true ); 343 QString fname = getFileName( true );
344 if ( !fname.isEmpty() ) 344 if ( !fname.isEmpty() )
345 { 345 {
346 QFile f( fname ); 346 QFile f( fname );
347 if ( f.open(IO_WriteOnly) ) 347 if ( f.open(IO_WriteOnly) )
348 { 348 {
349 QTextStream t( &f ); 349 QTextStream t( &f );
350 t << mw->hexWindow()->getLog(); 350 t << mw->hexWindow()->getLog();
351 f.close(); 351 f.close();
352 odebug << "Saved hex log to file '" << fname << "'" << oendl; 352 odebug << "Saved hex log to file '" << fname << "'" << oendl;
353 } 353 }
354 else 354 else
355 { 355 {
356 odebug << "Problem saving hex log to file '" << fname << "'" << oendl; 356 odebug << "Problem saving hex log to file '" << fname << "'" << oendl;
357 } 357 }
358 } 358 }
359 */ 359 */
360} 360}
361 361
362void WellenreiterMainWindow::fileLoadSession() 362void WellenreiterMainWindow::fileLoadSession()
363{ 363{
364 QString fname = getFileName( false ); 364 QString fname = getFileName( false );
365 if ( !fname.isEmpty() ) 365 if ( !fname.isEmpty() )
366 { 366 {
367 QFile f( fname ); 367 QFile f( fname );
368 if ( f.open(IO_ReadOnly) ) 368 if ( f.open(IO_ReadOnly) )
369 { 369 {
370 QDataStream t( &f ); 370 QDataStream t( &f );
371 t >> *mw->netView(); 371 t >> *mw->netView();
372 f.close(); 372 f.close();
373 odebug << "Loaded session from file '" << fname << "'" << oendl; 373 odebug << "Loaded session from file '" << fname << "'" << oendl;
374 } 374 }
375 else 375 else
376 { 376 {
377 odebug << "Problem loading session from file '" << fname << "'" << oendl; 377 odebug << "Problem loading session from file '" << fname << "'" << oendl;
378 } 378 }
379 } 379 }
380} 380}
381 381
382 382
383void WellenreiterMainWindow::fileNew() 383void WellenreiterMainWindow::fileNew()
384{ 384{
385 mw->netView()->clear(); 385 mw->netView()->clear();
386 mw->logWindow()->clear(); 386 mw->logWindow()->clear();
387 mw->hexWindow()->clear(); 387 mw->hexWindow()->clear();
388} 388}
389 389
390 390
391void WellenreiterMainWindow::closeEvent( QCloseEvent* e ) 391void WellenreiterMainWindow::closeEvent( QCloseEvent* e )
392{ 392{
393 if ( mw->isDaemonRunning() ) 393 if ( mw->isDaemonRunning() )
394 { 394 {
395 QMessageBox::warning( this, "Wellenreiter/Opie", 395 QMessageBox::warning( this, "Wellenreiter/Opie",
396 tr( "Sniffing in progress!\nPlease stop sniffing before closing." ) ); 396 tr( "Sniffing in progress!\nPlease stop sniffing before closing." ) );
397 e->ignore(); 397 e->ignore();
398 } 398 }
399 else 399 else
400 { 400 {
401 QMainWindow::closeEvent( e ); 401 QMainWindow::closeEvent( e );
402 } 402 }
403} 403}
404 404
405static const char* CAP_hostname = "www.vanille.de"; 405static const char* CAP_hostname = "www.vanille.de";
406 406
407#include <netdb.h> 407#include <netdb.h>
408#include <unistd.h> 408#include <unistd.h>
409#include <sys/types.h> 409#include <sys/types.h>
410#include <sys/socket.h> 410#include <sys/socket.h>
411 411
412void WellenreiterMainWindow::uploadSession() 412void WellenreiterMainWindow::uploadSession()
413{ 413{
414 QLineEdit* from; 414 QLineEdit* from;
415 QLineEdit* location; 415 QLineEdit* location;
416 QLineEdit* comments; 416 QLineEdit* comments;
417 QPushButton* accept; 417 QPushButton* accept;
418 QPushButton* reject; 418 QPushButton* reject;
419 419
420 QDialog* d = new QDialog( 0, "session upload", true ); 420 QDialog* d = new QDialog( 0, "session upload", true );
421 d->setCaption( tr( "Upload Session" ) ); 421 d->setCaption( tr( "Upload Session" ) );
422 QGridLayout* g = new QGridLayout( d, 4, 2, 3 ); 422 QGridLayout* g = new QGridLayout( d, 4, 2, 3 );
423 g->addWidget( new QLabel( tr( "From: " ), d ), 0, 0 ); 423 g->addWidget( new QLabel( tr( "From: " ), d ), 0, 0 );
424 g->addWidget( from = new QLineEdit( d ), 0, 1 ); 424 g->addWidget( from = new QLineEdit( d ), 0, 1 );
425 g->addWidget( new QLabel( tr( "Location: " ), d ), 1, 0 ); 425 g->addWidget( new QLabel( tr( "Location: " ), d ), 1, 0 );
426 g->addWidget( location = new QLineEdit( d ), 1, 1 ); 426 g->addWidget( location = new QLineEdit( d ), 1, 1 );
427 g->addWidget( new QLabel( tr( "Comments: " ), d ), 2, 0 ); 427 g->addWidget( new QLabel( tr( "Comments: " ), d ), 2, 0 );
428 g->addWidget( comments = new QLineEdit( d ), 2, 1 ); 428 g->addWidget( comments = new QLineEdit( d ), 2, 1 );
429 g->addWidget( accept = new QPushButton( tr( "&Ok" ), d ), 3, 0 ); 429 g->addWidget( accept = new QPushButton( tr( "&Ok" ), d ), 3, 0 );
430 g->addWidget( reject = new QPushButton( tr( "&Cancel" ), d ), 3, 1 ); 430 g->addWidget( reject = new QPushButton( tr( "&Cancel" ), d ), 3, 1 );
431 accept->setDefault( true ); 431 accept->setDefault( true );
432 accept->setAutoDefault( true ); 432 accept->setAutoDefault( true );
433 from->setText( "WL II User" ); 433 from->setText( "WL II User" );
434 location->setText( "WL II Location" ); 434 location->setText( "WL II Location" );
435 comments->setText( "No Comments." ); 435 comments->setText( "No Comments." );
436 connect( accept, SIGNAL( clicked() ), d, SLOT( accept() ) ); 436 connect( accept, SIGNAL( clicked() ), d, SLOT( accept() ) );
437 connect( reject, SIGNAL( clicked() ), d, SLOT( reject() ) ); 437 connect( reject, SIGNAL( clicked() ), d, SLOT( reject() ) );
438 int result = d->exec(); 438 int result = d->exec();
439 439
440 if ( !result ) 440 if ( !result )
441 { 441 {
442 odebug << "Session upload cancelled :(" << oendl; 442 odebug << "Session upload cancelled :(" << oendl;
443 return; 443 return;
444 } 444 }
445 445
446 odebug << "Starting upload..." << oendl; 446 odebug << "Starting upload..." << oendl;
447 447
448 struct sockaddr_in raddr; 448 struct sockaddr_in raddr;
449 struct hostent *rhost_info; 449 struct hostent *rhost_info;
450 int sock = -1; 450 int sock = -1;
451 bool ok = false; 451 bool ok = false;
452 452
453 rhost_info = (struct hostent *) ::gethostbyname( CAP_hostname ); 453 rhost_info = (struct hostent *) ::gethostbyname( CAP_hostname );
454 if ( rhost_info ) 454 if ( rhost_info )
455 { 455 {
456 456
457 457
458 if ( !QFile::exists( mw->captureFileName() ) ) 458 if ( !QFile::exists( mw->captureFileName() ) )
459 { 459 {
460 QMessageBox::warning( 0, tr( "Error" ), tr( "<p>Logfile '%1' doesn't exist</p>").arg( mw->captureFileName() ) ); 460 QMessageBox::warning( 0, tr( "Error" ), tr( "<p>Logfile '%1' doesn't exist</p>").arg( mw->captureFileName() ) );
461 return; 461 return;
462 } 462 }
463 463
464 QFile f( mw->captureFileName() ); 464 QFile f( mw->captureFileName() );
465 if ( !f.open( IO_ReadOnly ) ) 465 if ( !f.open( IO_ReadOnly ) )
466 { 466 {
467 QMessageBox::warning( 0, tr( "Error" ), tr( "<p>Can't open Logfile '%1'</p>").arg( mw->captureFileName() ) ); 467 QMessageBox::warning( 0, tr( "Error" ), tr( "<p>Can't open Logfile '%1'</p>").arg( mw->captureFileName() ) );
468 return; 468 return;
469 } 469 }
470 470
471 int content_length = f.size(); 471 int content_length = f.size();
472 472
473 ::memset( &raddr, 0, sizeof (struct sockaddr_in) ); 473 ::memset( &raddr, 0, sizeof (struct sockaddr_in) );
474 ::memcpy( &raddr. sin_addr, rhost_info-> h_addr, rhost_info-> h_length ); 474 ::memcpy( &raddr. sin_addr, rhost_info-> h_addr, rhost_info-> h_length );
475 raddr.sin_family = rhost_info-> h_addrtype; 475 raddr.sin_family = rhost_info-> h_addrtype;
476 raddr.sin_port = htons ( 80 ); 476 raddr.sin_port = htons ( 80 );
477 477
478 sock = ::socket( AF_INET, SOCK_STREAM, 0 ); 478 sock = ::socket( AF_INET, SOCK_STREAM, 0 );
479 479
480 if ( sock >= 0 ) 480 if ( sock >= 0 )
481 { 481 {
482 if ( ::connect ( sock, (struct sockaddr *) & raddr, sizeof (struct sockaddr)) >= 0 ) 482 if ( ::connect ( sock, (struct sockaddr *) & raddr, sizeof (struct sockaddr)) >= 0 )
483 { 483 {
484 QString header; 484 QString header;
485 QString content; 485 QString content;
486 QString preambel; 486 QString preambel;
487 487
488 header = "" 488 header = ""
489 "POST /projects/capturedump.spy HTTP/1.1\r\n" 489 "POST /projects/capturedump.spy HTTP/1.1\r\n"
490 "Host: www.vanille.de\r\n" 490 "Host: www.vanille.de\r\n"
491 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031010 Galeon/1.3.10\r\n" 491 "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031010 Galeon/1.3.10\r\n"
492 "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,image/jpeg,image/gif;q=0.2,*/*;q=0.1\r\n" 492 "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,image/jpeg,image/gif;q=0.2,*/*;q=0.1\r\n"
493 "Accept-Language: en\r\n" 493 "Accept-Language: en\r\n"
494 "Accept-Encoding: gzip, deflate, compress;q=0.9\r\n" 494 "Accept-Encoding: gzip, deflate, compress;q=0.9\r\n"
495 "Accept-Charset: us-ascii,utf-8;q=0.7,*;q=0.7\r\n" 495 "Accept-Charset: us-ascii,utf-8;q=0.7,*;q=0.7\r\n"
496 "Keep-Alive: 300\r\n" 496 "Keep-Alive: 300\r\n"
497 "Connection: keep-alive\r\n" 497 "Connection: keep-alive\r\n"
498 "Referer: http://www.vanille.de/projects/capturedump.spy\r\n" 498 "Referer: http://www.vanille.de/projects/capturedump.spy\r\n"
499 "Content-Type: multipart/form-data; boundary=---------------------------97267758015830030481215568065\r\n" 499 "Content-Type: multipart/form-data; boundary=---------------------------97267758015830030481215568065\r\n"
500 "Content-Length: %1\r\n" 500 "Content-Length: %1\r\n"
501 "\r\n"; 501 "\r\n";
502 502
503 content = "" 503 content = ""
504 "-----------------------------97267758015830030481215568065\r\n" 504 "-----------------------------97267758015830030481215568065\r\n"
505 "Content-Disposition: form-data; name=\"Name\"\r\n" 505 "Content-Disposition: form-data; name=\"Name\"\r\n"
506 "\r\n" 506 "\r\n"
507 "%1\r\n" 507 "%1\r\n"
508 "-----------------------------97267758015830030481215568065\r\n" 508 "-----------------------------97267758015830030481215568065\r\n"
509 "Content-Disposition: form-data; name=\"Location\"\r\n" 509 "Content-Disposition: form-data; name=\"Location\"\r\n"
510 "\r\n" 510 "\r\n"
511 "%2\r\n" 511 "%2\r\n"
512 "-----------------------------97267758015830030481215568065\r\n" 512 "-----------------------------97267758015830030481215568065\r\n"
513 "Content-Disposition: form-data; name=\"Comments\"\r\n" 513 "Content-Disposition: form-data; name=\"Comments\"\r\n"
514 "\r\n" 514 "\r\n"
515 "%3\r\n" 515 "%3\r\n"
516 "-----------------------------97267758015830030481215568065\r\n" 516 "-----------------------------97267758015830030481215568065\r\n"
517 "Content-Disposition: form-data; name=\"upfile\"; filename=\"%4\"\r\n" 517 "Content-Disposition: form-data; name=\"upfile\"; filename=\"%4\"\r\n"
518 "Content-Type: application/octet-stream\r\n" 518 "Content-Type: application/octet-stream\r\n"
519 "\r\n"; 519 "\r\n";
520 520
521 preambel = "" 521 preambel = ""
522 "\r\n-----------------------------97267758015830030481215568065--\r\n"; 522 "\r\n-----------------------------97267758015830030481215568065--\r\n";
523 523
524 content = content.arg( from->text().isEmpty() ? QString( "Anonymous Wellenreiter II User" ) : from->text() ); 524 content = content.arg( from->text().isEmpty() ? QString( "Anonymous Wellenreiter II User" ) : from->text() );
525 content = content.arg( location->text().isEmpty() ? QString( "Anonymous Wellenreiter II Location" ) : location->text() ); 525 content = content.arg( location->text().isEmpty() ? QString( "Anonymous Wellenreiter II Location" ) : location->text() );
526 content = content.arg( comments->text().isEmpty() ? QString( "Anonymous Wellenreiter II Comments" ) : comments->text() ); 526 content = content.arg( comments->text().isEmpty() ? QString( "Anonymous Wellenreiter II Comments" ) : comments->text() );
527 content = content.arg( mw->captureFileName() ); 527 content = content.arg( mw->captureFileName() );
528 528
529 header = header.arg( QString::number( content.length() + f.size() + preambel.length() ) ); 529 header = header.arg( QString::number( content.length() + f.size() + preambel.length() ) );
530 530
531 // write header 531 // write header
532 532
533 const char* ascii = header.latin1(); 533 const char* ascii = header.latin1();
534 uint ascii_len = ::strlen( ascii ); 534 uint ascii_len = ::strlen( ascii );
535 ::write ( sock, ascii, ascii_len ); 535 ::write ( sock, ascii, ascii_len );
536 536
537 // write fixed content 537 // write fixed content
538 538
539 ascii = content.latin1(); 539 ascii = content.latin1();
540 ascii_len = ::strlen( ascii ); 540 ascii_len = ::strlen( ascii );
541 ::write ( sock, ascii, ascii_len ); 541 ::write ( sock, ascii, ascii_len );
542 542
543 // write variable content 543 // write variable content
544 544
545 char ch; 545 char ch;
546 while ( !f.atEnd() ) 546 while ( !f.atEnd() )
547 { 547 {
548 f.readBlock( &ch, 1 ); 548 f.readBlock( &ch, 1 );
549 ::write ( sock, &ch, 1 ); 549 ::write ( sock, &ch, 1 );
550 } 550 }
551 551
552 // write preambel 552 // write preambel
553 553
554 ascii = preambel.latin1(); 554 ascii = preambel.latin1();
555 ascii_len = ::strlen( ascii ); 555 ascii_len = ::strlen( ascii );
556 ::write ( sock, ascii, ascii_len ); 556 ::write ( sock, ascii, ascii_len );
557 557
558 // done! 558 // done!
559 559
560 ok = true; 560 ok = true;
561 } 561 }
562 } 562 }
563 ::close ( sock ); 563 ::close ( sock );
564 } 564 }
565 if ( ok ) 565 if ( ok )
566 QMessageBox::information( 0, tr( "Success" ), 566 QMessageBox::information( 0, tr( "Success" ),
567 QString ( "<p>%1</p>" ).arg( tr( "Capture Dump was uploaded to %1" ) ).arg( CAP_hostname ) ); 567 QString ( "<p>%1</p>" ).arg( tr( "Capture Dump was uploaded to %1" ) ).arg( CAP_hostname ) );
568 else 568 else
569 QMessageBox::warning( 0, tr( "Error" ), 569 QMessageBox::warning( 0, tr( "Error" ),
570 QString ( "<p>%1</p>" ).arg ( tr( "Connection to %1 failed" ) ).arg( CAP_hostname ) ); 570 QString ( "<p>%1</p>" ).arg ( tr( "Connection to %1 failed" ) ).arg( CAP_hostname ) );
571} 571}
572 572
573 573
574void WellenreiterMainWindow::viewExpandAll() 574void WellenreiterMainWindow::viewExpandAll()
575{ 575{
576 mw->netView()->expand(); 576 mw->netView()->expand();
577} 577}
578 578
579void WellenreiterMainWindow::viewCollapseAll() 579void WellenreiterMainWindow::viewCollapseAll()
580{ 580{
581 mw->netView()->collapse(); 581 mw->netView()->collapse();
582} 582}
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index fe8f22d..2f85790 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -1,769 +1,769 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file may be distributed and/or modified under the terms of the 4** This file may be distributed and/or modified under the terms of the
5** GNU General Public License version 2 as published by the Free Software 5** GNU General Public License version 2 as published by the Free Software
6** Foundation and appearing in the file LICENSE.GPL included in the 6** Foundation and appearing in the file LICENSE.GPL included in the
7** packaging of this file. 7** packaging of this file.
8** 8**
9** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 9** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
10** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 10** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
11** 11**
12***********************************************************************/ 12***********************************************************************/
13 13
14#include "gps.h" 14#include "gps.h"
15#include "wellenreiter.h" 15#include "wellenreiter.h"
16#include "scanlist.h" 16#include "scanlist.h"
17#include "logwindow.h" 17#include "logwindow.h"
18#include "packetview.h" 18#include "packetview.h"
19#include "configwindow.h" 19#include "configwindow.h"
20#include "statwindow.h" 20#include "statwindow.h"
21#include "graphwindow.h" 21#include "graphwindow.h"
22#include "protolistview.h" 22#include "protolistview.h"
23 23
24/* OPIE */ 24/* OPIE */
25#ifdef QWS 25#ifdef QWS
26#include <opie2/oapplication.h> 26#include <opie2/oapplication.h>
27#include <opie2/odebug.h> 27#include <opie2/odebug.h>
28#include <opie2/odevice.h> 28#include <opie2/odevice.h>
29#else 29#else
30#include <qapplication.h> 30#include <qapplication.h>
31#endif 31#endif
32#include <opie2/omanufacturerdb.h> 32#include <opie2/omanufacturerdb.h>
33#include <opie2/onetwork.h> 33#include <opie2/onetwork.h>
34#include <opie2/opcap.h> 34#include <opie2/opcap.h>
35#include <qpe/qcopenvelope_qws.h> 35#include <qpe/qcopenvelope_qws.h>
36using namespace Opie::Core; 36using namespace Opie::Core;
37using namespace Opie::Net; 37using namespace Opie::Net;
38using namespace Opie::Ui; 38using namespace Opie::Ui;
39 39
40/* QT */ 40/* QT */
41#include <qcheckbox.h> 41#include <qcheckbox.h>
42#include <qcombobox.h> 42#include <qcombobox.h>
43#include <qdatetime.h> 43#include <qdatetime.h>
44#include <qpushbutton.h> 44#include <qpushbutton.h>
45#include <qlineedit.h> 45#include <qlineedit.h>
46#include <qmessagebox.h> 46#include <qmessagebox.h>
47#include <qobjectlist.h> 47#include <qobjectlist.h>
48#include <qregexp.h> 48#include <qregexp.h>
49#include <qspinbox.h> 49#include <qspinbox.h>
50#include <qtimer.h> 50#include <qtimer.h>
51#include <qtoolbutton.h> 51#include <qtoolbutton.h>
52#include <qmainwindow.h> 52#include <qmainwindow.h>
53 53
54/* STD */ 54/* STD */
55#include <assert.h> 55#include <assert.h>
56#include <errno.h> 56#include <errno.h>
57#include <unistd.h> 57#include <unistd.h>
58#include <string.h> 58#include <string.h>
59#include <sys/types.h> 59#include <sys/types.h>
60#include <stdlib.h> 60#include <stdlib.h>
61#include <signal.h> 61#include <signal.h>
62 62
63Wellenreiter* Wellenreiter::instance = 0; 63Wellenreiter* Wellenreiter::instance = 0;
64 64
65Wellenreiter::Wellenreiter( QWidget* parent ) 65Wellenreiter::Wellenreiter( QWidget* parent )
66 : WellenreiterBase( parent, 0, 0 ), 66 : WellenreiterBase( parent, 0, 0 ),
67 sniffing( false ), iface( 0 ), configwindow( 0 ) 67 sniffing( false ), iface( 0 ), configwindow( 0 )
68{ 68{
69 69
70 logwindow->log( "(i) Wellenreiter has been started." ); 70 logwindow->log( "(i) Wellenreiter has been started." );
71 71
72 // 72 //
73 // detect operating system 73 // detect operating system
74 // 74 //
75 75
76 #ifdef QWS 76 #ifdef QWS
77 QString sys; 77 QString sys;
78 sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); 78 sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() );
79 _system = ODevice::inst()->system(); 79 _system = ODevice::inst()->system();
80 logwindow->log( sys ); 80 logwindow->log( sys );
81 #endif 81 #endif
82 82
83 netview->setColumnWidthMode( 1, QListView::Manual ); 83 netview->setColumnWidthMode( 1, QListView::Manual );
84 connect( netview, SIGNAL( joinNetwork(const QString&,const QString&,int,const QString&) ), 84 connect( netview, SIGNAL( joinNetwork(const QString&,const QString&,int,const QString&) ),
85 this, SLOT( joinNetwork(const QString&,const QString&,int,const QString&) ) ); 85 this, SLOT( joinNetwork(const QString&,const QString&,int,const QString&) ) );
86 pcap = new OPacketCapturer(); 86 pcap = new OPacketCapturer();
87 pcap->setAutoDelete( false ); 87 pcap->setAutoDelete( false );
88 88
89 gps = new GPS( this ); 89 gps = new GPS( this );
90 90
91 QTimer::singleShot( 1000, this, SLOT( initialTimer() ) ); 91 QTimer::singleShot( 1000, this, SLOT( initialTimer() ) );
92 92
93 registerSignalHandler(); 93 registerSignalHandler();
94} 94}
95 95
96 96
97Wellenreiter::~Wellenreiter() 97Wellenreiter::~Wellenreiter()
98{ 98{
99 delete pcap; 99 delete pcap;
100 //unregisterSignalHandler(); 100 //unregisterSignalHandler();
101} 101}
102 102
103 103
104void Wellenreiter::initialTimer() 104void Wellenreiter::initialTimer()
105{ 105{
106 odebug << "preloading manufacturer database..." << oendl; 106 odebug << "preloading manufacturer database..." << oendl;
107 OManufacturerDB::instance(); 107 OManufacturerDB::instance();
108} 108}
109 109
110 110
111void Wellenreiter::signalHandler( int sig ) 111void Wellenreiter::signalHandler( int sig )
112{ 112{
113 oerr << "Aye! Received SIGSEGV or SIGBUS! Trying to exit gracefully..." << oendl; 113 oerr << "Aye! Received SIGSEGV or SIGBUS! Trying to exit gracefully..." << oendl;
114 if ( Wellenreiter::instance->sniffing ) 114 if ( Wellenreiter::instance->sniffing )
115 { 115 {
116 Wellenreiter::instance->pcap->closeDumpFile();
116 Wellenreiter::instance->pcap->close(); 117 Wellenreiter::instance->pcap->close();
117 Wellenreiter::instance->stopClicked(); 118 Wellenreiter::instance->stopClicked();
118 } 119 }
119 oerr << "Phew. Seemed to work." << oendl; 120 oerr << "Phew. Seemed to work." << oendl;
120 ::exit( -1 ); 121 ::exit( -1 );
121} 122}
122 123
123 124
124void Wellenreiter::registerSignalHandler() 125void Wellenreiter::registerSignalHandler()
125{ 126{
126 Wellenreiter::instance = this; 127 Wellenreiter::instance = this;
127 struct sigaction action; 128 struct sigaction action;
128 129
129 action.sa_handler = Wellenreiter::signalHandler; 130 action.sa_handler = Wellenreiter::signalHandler;
130 if (sigemptyset(&action.sa_mask)) 131 if (sigemptyset(&action.sa_mask))
131 oerr << "sigemptyset() failure:" << strerror( errno ) << oendl; 132 oerr << "sigemptyset() failure:" << strerror( errno ) << oendl;
132 if (sigaction(SIGSEGV, &action, NULL)) 133 if (sigaction(SIGSEGV, &action, NULL))
133 oerr << "can't set up a signal handler for SIGSEGV:" << strerror( errno ) << oendl; 134 oerr << "can't set up a signal handler for SIGSEGV:" << strerror( errno ) << oendl;
134 if (sigaction(SIGBUS, &action, NULL)) 135 if (sigaction(SIGBUS, &action, NULL))
135 oerr << "can't set up a signal handler for SIGBUS:" << strerror( errno ) << oendl; 136 oerr << "can't set up a signal handler for SIGBUS:" << strerror( errno ) << oendl;
136 odebug << "signal handlers setup." << oendl; 137 odebug << "signal handlers setup." << oendl;
137} 138}
138 139
139 140
140void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) 141void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw )
141{ 142{
142 configwindow = cw; 143 configwindow = cw;
143} 144}
144 145
145 146
146void Wellenreiter::channelHopped(int c) 147void Wellenreiter::channelHopped(int c)
147{ 148{
148 QString title = "Wellenreiter II -scan- ["; 149 QString title = "Wellenreiter II -scan- [";
149 QString left; 150 QString left;
150 if ( c > 1 ) left.fill( '.', c-1 ); 151 if ( c > 1 ) left.fill( '.', c-1 );
151 title.append( left ); 152 title.append( left );
152 title.append( '|' ); 153 title.append( '|' );
153 if ( c < iface->channels() ) 154 if ( c < iface->channels() )
154 { 155 {
155 QString right; 156 QString right;
156 right.fill( '.', iface->channels()-c ); 157 right.fill( '.', iface->channels()-c );
157 title.append( right ); 158 title.append( right );
158 } 159 }
159 title.append( "]" ); 160 title.append( "]" );
160 //title.append( QString().sprintf( " %02d", c ) ); 161 //title.append( QString().sprintf( " %02d", c ) );
161 assert( parent() ); 162 assert( parent() );
162 ( (QMainWindow*) parent() )->setCaption( title ); 163 ( (QMainWindow*) parent() )->setCaption( title );
163} 164}
164 165
165 166
166void Wellenreiter::handleNotification( OPacket* p ) 167void Wellenreiter::handleNotification( OPacket* p )
167{ 168{
168 QObjectList* l = p->queryList(); 169 QObjectList* l = p->queryList();
169 QObjectListIt it( *l ); 170 QObjectListIt it( *l );
170 QObject* o; 171 QObject* o;
171 172
172 while ( (o = it.current()) != 0 ) 173 while ( (o = it.current()) != 0 )
173 { 174 {
174 QString name = it.current()->name(); 175 QString name = it.current()->name();
175 if ( configwindow->parsePackets->isProtocolChecked( name ) ) 176 if ( configwindow->parsePackets->isProtocolChecked( name ) )
176 { 177 {
177 QString action = configwindow->parsePackets->protocolAction( name ); 178 QString action = configwindow->parsePackets->protocolAction( name );
178 odebug << "parsePacket-action for '" << (const char*) name << "' seems to be '" << action << "'" << oendl; 179 odebug << "parsePacket-action for '" << (const char*) name << "' seems to be '" << action << "'" << oendl;
179 doAction( action, name, p ); 180 doAction( action, name, p );
180 } 181 }
181 else 182 else
182 { 183 {
183 odebug << "protocol '" << name << "' not checked in parsePackets." << oendl; 184 odebug << "protocol '" << name << "' not checked in parsePackets." << oendl;
184 } 185 }
185 ++it; 186 ++it;
186 } 187 }
187} 188}
188 189
189 190
190void Wellenreiter::handleManagementFrame( OPacket* p, OWaveLanManagementPacket* manage ) 191void Wellenreiter::handleManagementFrame( OPacket* p, OWaveLanManagementPacket* manage )
191{ 192{
192 if ( manage->managementType() == "Beacon" ) handleManagementFrameBeacon( p, manage ); 193 if ( manage->managementType() == "Beacon" ) handleManagementFrameBeacon( p, manage );
193 else if ( manage->managementType() == "ProbeRequest" ) handleManagementFrameProbeRequest( p, manage ); 194 else if ( manage->managementType() == "ProbeRequest" ) handleManagementFrameProbeRequest( p, manage );
194 else if ( manage->managementType() == "ProbeResponse" ) handleManagementFrameProbeResponse( p, manage ); 195 else if ( manage->managementType() == "ProbeResponse" ) handleManagementFrameProbeResponse( p, manage );
195 else owarn << "Wellenreiter::handleManagementFrame(): '" << manage->managementType() << "' - please handle me!" << oendl; 196 else owarn << "Wellenreiter::handleManagementFrame(): '" << manage->managementType() << "' - please handle me!" << oendl;
196} 197}
197 198
198 199
199void Wellenreiter::handleManagementFrameProbeRequest( OPacket* p, OWaveLanManagementPacket* request ) 200void Wellenreiter::handleManagementFrameProbeRequest( OPacket* p, OWaveLanManagementPacket* request )
200{ 201{
201 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); 202 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) );
202 QString essid = ssid ? ssid->ID( true /* decloak */ ) : QString("<unknown>"); 203 QString essid = ssid ? ssid->ID( true /* decloak */ ) : QString("<unknown>");
203 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); 204 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) );
204 int channel = ds ? ds->channel() : -1; 205 int channel = ds ? ds->channel() : -1;
205 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); 206 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) );
206 207
207 GpsLocation loc( -111, -111 ); 208 GpsLocation loc( -111, -111 );
208 if ( configwindow->enableGPS->isChecked() ) 209 if ( configwindow->enableGPS->isChecked() )
209 { 210 {
210 // TODO: add check if GPS is working!? 211 // TODO: add check if GPS is working!?
211 odebug << "Wellenreiter::gathering GPS data..." << oendl; 212 odebug << "Wellenreiter::gathering GPS data..." << oendl;
212 loc = gps->position(); 213 loc = gps->position();
213 odebug << "Wellenreiter::GPS data received is ( " << loc.latitude() << " , " << loc.longitude() << " ) - dms string = '" << loc.dmsPosition().latin1() << "'" << oendl; 214 odebug << "Wellenreiter::GPS data received is ( " << loc.latitude() << " , " << loc.longitude() << " ) - dms string = '" << loc.dmsPosition().latin1() << "'" << oendl;
214 } 215 }
215 216
216 if ( essid.length() ) 217 if ( essid.length() )
217 netView()->addNewItem( "adhoc", essid, header->macAddress2(), false /* should check FrameControl field */, -1, 0, loc, true /* only probed */ ); 218 netView()->addNewItem( "adhoc", essid, header->macAddress2(), false /* should check FrameControl field */, -1, 0, loc, true /* only probed */ );
218 odebug << "Wellenreiter::invalid frame [possibly noise] detected!" << oendl; 219 odebug << "Wellenreiter::invalid frame [possibly noise] detected!" << oendl;
219} 220}
220 221
221 222
222void Wellenreiter::handleManagementFrameProbeResponse( OPacket* p, OWaveLanManagementPacket* response ) 223void Wellenreiter::handleManagementFrameProbeResponse( OPacket* p, OWaveLanManagementPacket* response )
223{ 224{
224} 225}
225 226
226 227
227void Wellenreiter::handleManagementFrameBeacon( OPacket* p, OWaveLanManagementPacket* beacon ) 228void Wellenreiter::handleManagementFrameBeacon( OPacket* p, OWaveLanManagementPacket* beacon )
228{ 229{
229 QString type; 230 QString type;
230 if ( beacon->canIBSS() ) 231 if ( beacon->canIBSS() )
231 { 232 {
232 type = "adhoc"; 233 type = "adhoc";
233 } 234 }
234 else if ( beacon->canESS() ) 235 else if ( beacon->canESS() )
235 { 236 {
236 type = "managed"; 237 type = "managed";
237 } 238 }
238 else 239 else
239 { 240 {
240 owarn << "Wellenreiter::invalid frame [possibly noise] detected!" << oendl; 241 owarn << "Wellenreiter::invalid frame [possibly noise] detected!" << oendl;
241 return; 242 return;
242 } 243 }
243 244
244 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); 245 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) );
245 QString essid = ssid ? ssid->ID( true /* decloak */ ) : QString("<unknown>"); 246 QString essid = ssid ? ssid->ID( true /* decloak */ ) : QString("<unknown>");
246 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); 247 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) );
247 int channel = ds ? ds->channel() : -1; 248 int channel = ds ? ds->channel() : -1;
248 249
249 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); 250 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) );
250 251
251 GpsLocation loc( -111, -111 ); 252 GpsLocation loc( -111, -111 );
252 if ( configwindow->enableGPS->isChecked() ) 253 if ( configwindow->enableGPS->isChecked() )
253 { 254 {
254 // TODO: add check if GPS is working!? 255 // TODO: add check if GPS is working!?
255 odebug << "Wellenreiter::gathering GPS data..." << oendl; 256 odebug << "Wellenreiter::gathering GPS data..." << oendl;
256 loc = gps->position(); 257 loc = gps->position();
257 odebug << "Wellenreiter::GPS data received is ( " << loc.latitude() << " , " << loc.longitude() << " ) - dms string = '" << loc.dmsPosition().latin1() << "'" << oendl; 258 odebug << "Wellenreiter::GPS data received is ( " << loc.latitude() << " , " << loc.longitude() << " ) - dms string = '" << loc.dmsPosition().latin1() << "'" << oendl;
258 } 259 }
259 260
260 netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0, loc ); 261 netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0, loc );
261 262
262 // update graph window 263 // update graph window
263 if ( ds ) 264 if ( ds )
264 { 265 {
265 OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) ); 266 OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) );
266 if ( prism ) 267 if ( prism )
267 graphwindow->traffic( ds->channel(), prism->signalStrength() ); 268 graphwindow->traffic( ds->channel(), prism->signalStrength() );
268 else 269 else
269 graphwindow->traffic( ds->channel(), 95 ); 270 graphwindow->traffic( ds->channel(), 95 );
270 } 271 }
271} 272}
272 273
273 274
274void Wellenreiter::handleControlFrame( OPacket* p, OWaveLanControlPacket* control ) 275void Wellenreiter::handleControlFrame( OPacket* p, OWaveLanControlPacket* control )
275{ 276{
276 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); 277 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) );
277 278
278 if ( control->controlType() == "Acknowledge" ) 279 if ( control->controlType() == "Acknowledge" )
279 { 280 {
280 netView()->addNewItem( "adhoc", "<unknown>", header->macAddress1(), false, -1, 0, GpsLocation( -111, -111 ) ); 281 netView()->addNewItem( "adhoc", "<unknown>", header->macAddress1(), false, -1, 0, GpsLocation( -111, -111 ) );
281 } 282 }
282 else 283 else
283 { 284 {
284 odebug << "Wellenreiter::handleControlFrame - please handle " << control->controlType() << " in a future version! :D" << oendl; 285 odebug << "Wellenreiter::handleControlFrame - please handle " << control->controlType() << " in a future version! :D" << oendl;
285 } 286 }
286} 287}
287 288
288 289
289void Wellenreiter::handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to ) 290void Wellenreiter::handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to )
290{ 291{
291 OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); 292 OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" );
292 if ( wlan->fromDS() && !wlan->toDS() ) 293 if ( wlan->fromDS() && !wlan->toDS() )
293 { 294 {
294 netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); 295 netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() );
295 from = wlan->macAddress3(); 296 from = wlan->macAddress3();
296 to = wlan->macAddress2(); 297 to = wlan->macAddress2();
297 } 298 }
298 else if ( !wlan->fromDS() && wlan->toDS() ) 299 else if ( !wlan->fromDS() && wlan->toDS() )
299 { 300 {
300 netView()->toDStraffic( wlan->macAddress2(), wlan->macAddress3(), wlan->macAddress1() ); 301 netView()->toDStraffic( wlan->macAddress2(), wlan->macAddress3(), wlan->macAddress1() );
301 from = wlan->macAddress2(); 302 from = wlan->macAddress2();
302 to = wlan->macAddress3(); 303 to = wlan->macAddress3();
303 } 304 }
304 else if ( wlan->fromDS() && wlan->toDS() ) 305 else if ( wlan->fromDS() && wlan->toDS() )
305 { 306 {
306 netView()->WDStraffic( wlan->macAddress4(), wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); 307 netView()->WDStraffic( wlan->macAddress4(), wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() );
307 from = wlan->macAddress4(); 308 from = wlan->macAddress4();
308 to = wlan->macAddress3(); 309 to = wlan->macAddress3();
309 } 310 }
310 else 311 else
311 { 312 {
312 netView()->IBSStraffic( wlan->macAddress2(), wlan->macAddress1(), wlan->macAddress3() ); 313 netView()->IBSStraffic( wlan->macAddress2(), wlan->macAddress1(), wlan->macAddress3() );
313 from = wlan->macAddress2(); 314 from = wlan->macAddress2();
314 to = wlan->macAddress1(); 315 to = wlan->macAddress1();
315 } 316 }
316} 317}
317 318
318 319
319void Wellenreiter::handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to ) 320void Wellenreiter::handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to )
320{ 321{
321 from = data->sourceAddress(); 322 from = data->sourceAddress();
322 to = data->destinationAddress(); 323 to = data->destinationAddress();
323 324
324 netView()->addNewItem( "station", "<wired>", from, false, -1, 0, GpsLocation( -111, -111 ) ); 325 netView()->addNewItem( "station", "<wired>", from, false, -1, 0, GpsLocation( -111, -111 ) );
325} 326}
326 327
327 328
328void Wellenreiter::handleARPData( OPacket* p, OARPPacket*, OMacAddress& source, OMacAddress& dest ) 329void Wellenreiter::handleARPData( OPacket* p, OARPPacket*, OMacAddress& source, OMacAddress& dest )
329{ 330{
330 OARPPacket* arp = (OARPPacket*) p->child( "ARP" ); 331 OARPPacket* arp = (OARPPacket*) p->child( "ARP" );
331 if ( arp ) 332 if ( arp )
332 { 333 {
333 odebug << "Received ARP traffic (type '" << arp->type() << "'): " << oendl; 334 odebug << "Received ARP traffic (type '" << arp->type() << "'): " << oendl;
334 if ( arp->type() == "REQUEST" ) 335 if ( arp->type() == "REQUEST" )
335 { 336 {
336 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); 337 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() );
337 } 338 }
338 else if ( arp->type() == "REPLY" ) 339 else if ( arp->type() == "REPLY" )
339 { 340 {
340 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); 341 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() );
341 netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() ); 342 netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() );
342 } 343 }
343 } 344 }
344} 345}
345 346
346 347
347void Wellenreiter::handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& source, OMacAddress& dest ) 348void Wellenreiter::handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& source, OMacAddress& dest )
348{ 349{
349 //TODO: Implement more IP based protocols 350 //TODO: Implement more IP based protocols
350 351
351 ODHCPPacket* dhcp = (ODHCPPacket*) p->child( "DHCP" ); 352 ODHCPPacket* dhcp = (ODHCPPacket*) p->child( "DHCP" );
352 if ( dhcp ) 353 if ( dhcp )
353 { 354 {
354 odebug << "Received DHCP '" << dhcp->type() << "' packet" << oendl; 355 odebug << "Received DHCP '" << dhcp->type() << "' packet" << oendl;
355 if ( dhcp->type() == "OFFER" ) 356 if ( dhcp->type() == "OFFER" )
356 { 357 {
357 odebug << "DHCP: '" << (const char*) source.toString() << "' ('" << dhcp->serverAddress().toString() << "') seems to be a DHCP server." << oendl; 358 odebug << "DHCP: '" << (const char*) source.toString() << "' ('" << dhcp->serverAddress().toString() << "') seems to be a DHCP server." << oendl;
358 netView()->identify( source, dhcp->serverAddress().toString() ); 359 netView()->identify( source, dhcp->serverAddress().toString() );
359 netView()->addService( "DHCP", source, dhcp->serverAddress().toString() ); 360 netView()->addService( "DHCP", source, dhcp->serverAddress().toString() );
360 } 361 }
361 else if ( dhcp->type() == "ACK" ) 362 else if ( dhcp->type() == "ACK" )
362 { 363 {
363 odebug << "DHCP: '" << (const char*) dhcp->clientMacAddress().toString() << "' ('" << dhcp->yourAddress().toString() << "') accepted the offered DHCP address." << oendl; 364 odebug << "DHCP: '" << (const char*) dhcp->clientMacAddress().toString() << "' ('" << dhcp->yourAddress().toString() << "') accepted the offered DHCP address." << oendl;
364 netView()->identify( dhcp->clientMacAddress(), dhcp->yourAddress().toString() ); 365 netView()->identify( dhcp->clientMacAddress(), dhcp->yourAddress().toString() );
365 } 366 }
366 } 367 }
367} 368}
368 369
369 370
370QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol ) 371QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol )
371{ 372{
372 if ( configwindow->parsePackets->isProtocolChecked( protocol ) ) 373 if ( configwindow->parsePackets->isProtocolChecked( protocol ) )
373 if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" ) 374 if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" )
374 return 0; 375 return 0;
375 376
376 return p->child( protocol ); 377 return p->child( protocol );
377} 378}
378 379
379 380
380bool Wellenreiter::checkDumpPacket( OPacket* p ) 381bool Wellenreiter::checkDumpPacket( OPacket* p )
381{ 382{
382 // go through all child packets and see if one is inside the child hierarchy for p 383 // go through all child packets and see if one is inside the child hierarchy for p
383 // if so, do what the user requested (protocolAction), e.g. pass or discard 384 // if so, do what the user requested (protocolAction), e.g. pass or discard
384 if ( !configwindow->writeCaptureFile->isChecked() ) 385 if ( !configwindow->writeCaptureFile->isChecked() )
385 return true; // semantic change - we're logging anyway now to /tmp/wellenreiter 386 return true; // semantic change - we're logging anyway now to /tmp/wellenreiter
386 387
387 QObjectList* l = p->queryList(); 388 QObjectList* l = p->queryList();
388 QObjectListIt it( *l ); 389 QObjectListIt it( *l );
389 QObject* o; 390 QObject* o;
390 391
391 while ( (o = it.current()) != 0 ) 392 while ( (o = it.current()) != 0 )
392 { 393 {
393 QString name = it.current()->name(); 394 QString name = it.current()->name();
394 if ( configwindow->capturePackets->isProtocolChecked( name ) ) 395 if ( configwindow->capturePackets->isProtocolChecked( name ) )
395 { 396 {
396 QString action = configwindow->capturePackets->protocolAction( name ); 397 QString action = configwindow->capturePackets->protocolAction( name );
397 odebug << "capturePackets-action for '" << (const char*) name << "' seems to be '" << action << "'" << oendl; 398 odebug << "capturePackets-action for '" << (const char*) name << "' seems to be '" << action << "'" << oendl;
398 if ( action == "Discard" ) 399 if ( action == "Discard" )
399 { 400 {
400 logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) ); 401 logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) );
401 return false; 402 return false;
402 } 403 }
403 } 404 }
404 else 405 else
405 { 406 {
406 odebug << "protocol '" << name << "' not checked in capturePackets." << oendl; 407 odebug << "protocol '" << name << "' not checked in capturePackets." << oendl;
407 } 408 }
408 ++it; 409 ++it;
409 } 410 }
410 return true; 411 return true;
411} 412}
412 413
413 414
414void Wellenreiter::receivePacket( OPacket* p ) 415void Wellenreiter::receivePacket( OPacket* p )
415{ 416{
416 hexWindow()->add( p, configwindow->hexViewBuffer() ); 417 hexWindow()->add( p, configwindow->hexViewBuffer() );
417 418
418 if ( checkDumpPacket( p ) ) 419 if ( checkDumpPacket( p ) )
419 { 420 {
420 pcap->dump( p ); 421 pcap->dump( p );
421 } 422 }
422 423
423 // check for a management frame 424 // check for a management frame
424 OWaveLanManagementPacket* manage = static_cast<OWaveLanManagementPacket*>( childIfToParse( p, "802.11 Management" ) ); 425 OWaveLanManagementPacket* manage = static_cast<OWaveLanManagementPacket*>( childIfToParse( p, "802.11 Management" ) );
425 if ( manage ) 426 if ( manage )
426 { 427 {
427 handleManagementFrame( p, manage ); 428 handleManagementFrame( p, manage );
428 return; 429 return;
429 } 430 }
430 431
431 // check for a control frame 432 // check for a control frame
432 OWaveLanControlPacket* control = static_cast<OWaveLanControlPacket*>( childIfToParse( p, "802.11 Control" ) ); 433 OWaveLanControlPacket* control = static_cast<OWaveLanControlPacket*>( childIfToParse( p, "802.11 Control" ) );
433 if ( control ) 434 if ( control )
434 { 435 {
435 handleControlFrame( p, control ); 436 handleControlFrame( p, control );
436 return; 437 return;
437 } 438 }
438 439
439 OMacAddress source; 440 OMacAddress source;
440 OMacAddress dest; 441 OMacAddress dest;
441 442
442 //TODO: WEP check here 443 //TODO: WEP check here
443 444
444 // check for a wireless data frame 445 // check for a wireless data frame
445 OWaveLanDataPacket* wlan = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) ); 446 OWaveLanDataPacket* wlan = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) );
446 if ( wlan ) 447 if ( wlan )
447 { 448 {
448 handleWlanData( p, wlan, source, dest ); 449 handleWlanData( p, wlan, source, dest );
449 } 450 }
450 451
451 // check for a wired data frame 452 // check for a wired data frame
452 OEthernetPacket* eth = static_cast<OEthernetPacket*>( childIfToParse( p, "Ethernet" ) ); 453 OEthernetPacket* eth = static_cast<OEthernetPacket*>( childIfToParse( p, "Ethernet" ) );
453 if ( eth ) 454 if ( eth )
454 { 455 {
455 handleEthernetData( p, eth, source, dest ); 456 handleEthernetData( p, eth, source, dest );
456 } 457 }
457 458
458 // check for an arp frame since arp frames come in two flavours: 459 // check for an arp frame since arp frames come in two flavours:
459 // 802.11 encapsulates ARP data within IP packets while wired ethernet doesn't. 460 // 802.11 encapsulates ARP data within IP packets while wired ethernet doesn't.
460 OARPPacket* arp = static_cast<OARPPacket*>( childIfToParse( p, "ARP" ) ); 461 OARPPacket* arp = static_cast<OARPPacket*>( childIfToParse( p, "ARP" ) );
461 if ( arp ) 462 if ( arp )
462 { 463 {
463 handleARPData( p, arp, source, dest ); 464 handleARPData( p, arp, source, dest );
464 } 465 }
465 466
466 // check for a ip frame 467 // check for a ip frame
467 OIPPacket* ip = static_cast<OIPPacket*>( childIfToParse( p, "IP" ) ); 468 OIPPacket* ip = static_cast<OIPPacket*>( childIfToParse( p, "IP" ) );
468 if ( ip ) 469 if ( ip )
469 { 470 {
470 handleIPData( p, ip, source, dest ); 471 handleIPData( p, ip, source, dest );
471 } 472 }
472 473
473 //handleNotification( p ); 474 //handleNotification( p );
474 475
475} 476}
476 477
477 478
478void Wellenreiter::stopClicked() 479void Wellenreiter::stopClicked()
479{ 480{
480 if ( iface ) 481 if ( iface )
481 { 482 {
482 disconnect( SIGNAL( receivedPacket(Opie::Net::OPacket*) ), this, SLOT( receivePacket(Opie::Net::OPacket*) ) ); 483 disconnect( SIGNAL( receivedPacket(Opie::Net::OPacket*) ), this, SLOT( receivePacket(Opie::Net::OPacket*) ) );
483 disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); 484 disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) );
484 iface->setChannelHopping(); // stop hopping channels 485 iface->setChannelHopping(); // stop hopping channels
485 } 486 }
486 else 487 else
487 killTimers(); 488 killTimers();
488 489
489 pcap->close(); 490 pcap->close();
490 sniffing = false; 491 sniffing = false;
491 492
492 if ( iface ) 493 if ( iface )
493 { 494 {
494 // switch off monitor mode 495 // switch off monitor mode
495 iface->setMode( "managed" ); 496 iface->setMode( "managed" );
496 // switch off promisc flag 497 // switch off promisc flag
497 iface->setPromiscuousMode( false ); 498 iface->setPromiscuousMode( false );
498 499
499 system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess 500 system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess
500 } 501 }
501 502
502 logwindow->log( "(i) Stopped Scanning." ); 503 logwindow->log( "(i) Stopped Scanning." );
503 assert( parent() ); 504 assert( parent() );
504 ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" ); 505 ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" );
505 506
506 // message the user 507 // message the user
507 QMessageBox::information( this, "Wellenreiter II", 508 QMessageBox::information( this, "Wellenreiter II",
508 tr( "Your wireless card\nshould now be usable again." ) ); 509 tr( "Your wireless card\nshould now be usable again." ) );
509 510
510 sniffing = false; 511 sniffing = false;
511 emit( stoppedSniffing() ); 512 emit( stoppedSniffing() );
512 513
513 #ifdef QWS 514 #ifdef QWS
514 if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() ) 515 if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() )
515 { 516 {
516 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 517 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
517 } 518 }
518 #else 519 #else
519 #warning FIXME: setScreenSaverMode is not operational on the X11 build 520 #warning FIXME: setScreenSaverMode is not operational on the X11 build
520 #endif 521 #endif
521 522
522 // print out statistics 523 // print out statistics
523 for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it ) 524 for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it )
524 statwindow->updateCounter( it.key(), it.data() ); 525 statwindow->updateCounter( it.key(), it.data() );
525} 526}
526 527
527 528
528void Wellenreiter::startClicked() 529void Wellenreiter::startClicked()
529{ 530{
530 // get configuration from config window 531 // get configuration from config window
531 532
532 const QString& interface = configwindow->interfaceName->currentText(); 533 const QString& interface = configwindow->interfaceName->currentText();
533 const int cardtype = configwindow->driverType(); 534 const int cardtype = configwindow->driverType();
534 const int interval = configwindow->hoppingInterval(); 535 const int interval = configwindow->hoppingInterval();
535 536
536 if ( ( interface == "" ) || ( cardtype == 0 ) ) 537 if ( ( interface == "" ) || ( cardtype == 0 ) )
537 { 538 {
538 QMessageBox::information( this, "Wellenreiter II", 539 QMessageBox::information( this, "Wellenreiter II",
539 tr( "No device configured.\nPlease reconfigure!" ) ); 540 tr( "No device configured.\nPlease reconfigure!" ) );
540 return; 541 return;
541 } 542 }
542 543
543 // configure device 544 // configure device
544 ONetwork* net = ONetwork::instance(); 545 ONetwork* net = ONetwork::instance();
545 546
546 // TODO: check if interface is wireless and support sniffing for non-wireless interfaces 547 // TODO: check if interface is wireless and support sniffing for non-wireless interfaces
547 548
548 if ( cardtype != DEVTYPE_FILE ) 549 if ( cardtype != DEVTYPE_FILE )
549 { 550 {
550 551
551 if ( !net->isPresent( interface ) ) 552 if ( !net->isPresent( interface ) )
552 { 553 {
553 QMessageBox::information( this, "Wellenreiter II", 554 QMessageBox::information( this, "Wellenreiter II",
554 tr( "The configured device (%1)\nis not available on this system\n. Please reconfigure!" ).arg( interface ) ); 555 tr( "The configured device (%1)\nis not available on this system\n. Please reconfigure!" ).arg( interface ) );
555 return; 556 return;
556 } 557 }
557 558
558 iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); // fails if network is not wireless! 559 iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); // fails if network is not wireless!
559 assert( iface ); 560 assert( iface );
560 561
561 // bring device UP 562 // bring device UP
562 iface->setUp( true ); 563 iface->setUp( true );
563 if ( !iface->isUp() ) 564 if ( !iface->isUp() )
564 { 565 {
565 QMessageBox::warning( this, "Wellenreiter II", 566 QMessageBox::warning( this, "Wellenreiter II",
566 tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) ); 567 tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) );
567 return; 568 return;
568 } 569 }
569 570
570 // check if wireless extension version matches 571 // check if wireless extension version matches
571 if ( ONetwork::wirelessExtensionCompileVersion() != iface->wirelessExtensionDriverVersion() ) 572 if ( ONetwork::wirelessExtensionCompileVersion() != iface->wirelessExtensionDriverVersion() )
572 { 573 {
573 QMessageBox::critical( this, "Wellenreiter II", tr( "<p>The Wireless Extension Versions<br>are not matching!<p>" 574 QMessageBox::critical( this, "Wellenreiter II", tr( "<p>The Wireless Extension Versions<br>are not matching!<p>"
574 " Wellenreiter II : WE V%1<br>Interface driver: WE V%2" ) 575 " Wellenreiter II : WE V%1<br>Interface driver: WE V%2" )
575 .arg( QString::number( ONetwork::wirelessExtensionCompileVersion() ) ) 576 .arg( QString::number( ONetwork::wirelessExtensionCompileVersion() ) )
576 .arg( QString::number( iface->wirelessExtensionDriverVersion() ) ) ); 577 .arg( QString::number( iface->wirelessExtensionDriverVersion() ) ) );
577 return; 578 return;
578 } 579 }
579 } 580 }
580 // set monitor mode 581 // set monitor mode
581 bool usePrism = configwindow->usePrismHeader(); 582 bool usePrism = configwindow->usePrismHeader();
582 583
583 switch ( cardtype ) 584 switch ( cardtype )
584 { 585 {
585 case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break; 586 case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break;
586 case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break; 587 case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break;
587 case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break; 588 case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break;
588 case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break; 589 case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break;
589 case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break; 590 case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break;
590 case DEVTYPE_FILE: odebug << "Wellenreiter: Capturing from file '" << interface << "'" << oendl; break; 591 case DEVTYPE_FILE: odebug << "Wellenreiter: Capturing from file '" << interface << "'" << oendl; break;
591 default: assert( 0 ); // shouldn't reach this 592 default: assert( 0 ); // shouldn't reach this
592 } 593 }
593 594
594 // switch device into monitor mode 595 // switch device into monitor mode
595 if ( cardtype < DEVTYPE_FILE ) 596 if ( cardtype < DEVTYPE_FILE )
596 { 597 {
597 if ( cardtype != DEVTYPE_MANUAL ) 598 if ( cardtype != DEVTYPE_MANUAL )
598 iface->setMode( "monitor" ); 599 iface->setMode( "monitor" );
599 if ( iface->mode() != "monitor" ) 600 if ( iface->mode() != "monitor" )
600 { 601 {
601 if ( QMessageBox::warning( this, "Wellenreiter II", 602 if ( QMessageBox::warning( this, "Wellenreiter II",
602 tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) + 603 tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) +
603 tr( "\nContinue with limited functionality?" ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) 604 tr( "\nContinue with limited functionality?" ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No )
604 return; 605 return;
605 } 606 }
606 } 607 }
607 608
608 // open GPS device 609 // open GPS device
609 if ( configwindow->enableGPS->isChecked() ) 610 if ( configwindow->enableGPS->isChecked() )
610 { 611 {
611 odebug << "Wellenreiter:GPS enabled @ " << configwindow->gpsdHost->currentText() << ":" << configwindow->gpsdPort->value() << "" << oendl; 612 odebug << "Wellenreiter:GPS enabled @ " << configwindow->gpsdHost->currentText() << ":" << configwindow->gpsdPort->value() << "" << oendl;
612 gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); 613 gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() );
613 } 614 }
614 615
615 // open pcap and start sniffing 616 // open pcap and start sniffing
616 617
617 if ( configwindow->writeCaptureFile->isChecked() ) // write to a user specified capture file? 618 if ( configwindow->writeCaptureFile->isChecked() ) // write to a user specified capture file?
618 { 619 {
619 dumpname = configwindow->captureFileName->text(); 620 dumpname = configwindow->captureFileName->text();
620 if ( dumpname.isEmpty() ) dumpname = "captureFile"; 621 if ( dumpname.isEmpty() ) dumpname = "captureFile";
621 dumpname.append( '-' ); 622 dumpname.append( '-' );
622 dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) ); 623 dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) );
623 dumpname.append( ".wellenreiter" ); 624 dumpname.append( ".wellenreiter" );
624 } 625 }
625 else // write it anyway ;)
626 {
627 dumpname = "/var/log/dump.wellenreiter";
628 }
629 626
630 if ( cardtype != DEVTYPE_FILE ) 627 if ( cardtype != DEVTYPE_FILE )
631 pcap->open( interface ); 628 pcap->open( interface );
632 else 629 else
633 pcap->openCaptureFile( interface ); 630 pcap->openCaptureFile( interface );
634 631
635 odebug << "Wellenreiter:: dumping to " << dumpname << "" << oendl; 632 if ( configwindow->writeCaptureFile->isChecked() )
636 pcap->openDumpFile( dumpname ); 633 {
634 odebug << "Wellenreiter:: dumping to " << dumpname << oendl;
635 pcap->openDumpFile( dumpname );
636 }
637 637
638 if ( !pcap->isOpen() ) 638 if ( !pcap->isOpen() )
639 { 639 {
640 QMessageBox::warning( this, "Wellenreiter II", tr( "Can't open packet capturer for\n'%1':\n" ).arg( 640 QMessageBox::warning( this, "Wellenreiter II", tr( "Can't open packet capturer for\n'%1':\n" ).arg(
641 cardtype == DEVTYPE_FILE ? (const char*) interface : iface->name() ) + QString(strerror( errno ) )); 641 cardtype == DEVTYPE_FILE ? (const char*) interface : iface->name() ) + QString(strerror( errno ) ));
642 return; 642 return;
643 } 643 }
644 644
645 // set capturer to non-blocking mode 645 // set capturer to non-blocking mode
646 pcap->setBlocking( false ); 646 pcap->setBlocking( false );
647 647
648 // start channel hopper 648 // start channel hopper
649 if ( cardtype != DEVTYPE_FILE ) 649 if ( cardtype != DEVTYPE_FILE )
650 { 650 {
651 logwindow->log( QString().sprintf( "(i) Starting channel hopper (d=%d ms)", configwindow->hopInterval->value() ) ); 651 logwindow->log( QString().sprintf( "(i) Starting channel hopper (d=%d ms)", configwindow->hopInterval->value() ) );
652 iface->setChannelHopping( configwindow->hopInterval->value() ); //use interval from config window 652 iface->setChannelHopping( configwindow->hopInterval->value() ); //use interval from config window
653 } 653 }
654 654
655 if ( cardtype != DEVTYPE_FILE ) 655 if ( cardtype != DEVTYPE_FILE )
656 { 656 {
657 // connect socket notifier and start channel hopper 657 // connect socket notifier and start channel hopper
658 connect( pcap, SIGNAL( receivedPacket(Opie::Net::OPacket*) ), this, SLOT( receivePacket(Opie::Net::OPacket*) ) ); 658 connect( pcap, SIGNAL( receivedPacket(Opie::Net::OPacket*) ), this, SLOT( receivePacket(Opie::Net::OPacket*) ) );
659 connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); 659 connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) );
660 } 660 }
661 else 661 else
662 { 662 {
663 // start timer for reading packets 663 // start timer for reading packets
664 startTimer( 100 ); 664 startTimer( 100 );
665 } 665 }
666 666
667 logwindow->log( "(i) Started Scanning." ); 667 logwindow->log( "(i) Started Scanning." );
668 sniffing = true; 668 sniffing = true;
669 669
670 #ifdef QWS 670 #ifdef QWS
671 if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() ) 671 if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() )
672 { 672 {
673 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable; 673 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable;
674 } 674 }
675 #else 675 #else
676 #warning FIXME: setScreenSaverMode is not operational on the X11 build 676 #warning FIXME: setScreenSaverMode is not operational on the X11 build
677 #endif 677 #endif
678 678
679 emit( startedSniffing() ); 679 emit( startedSniffing() );
680 if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title 680 if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title
681 else 681 else
682 { 682 {
683 assert( parent() ); 683 assert( parent() );
684 ( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) ); 684 ( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) );
685 } 685 }
686} 686}
687 687
688 688
689void Wellenreiter::timerEvent( QTimerEvent* ) 689void Wellenreiter::timerEvent( QTimerEvent* )
690{ 690{
691 odebug << "Wellenreiter::timerEvent()" << oendl; 691 odebug << "Wellenreiter::timerEvent()" << oendl;
692 OPacket* p = pcap->next(); 692 OPacket* p = pcap->next();
693 if ( !p ) // no more packets available 693 if ( !p ) // no more packets available
694 { 694 {
695 stopClicked(); 695 stopClicked();
696 } 696 }
697 else 697 else
698 { 698 {
699 receivePacket( p ); 699 receivePacket( p );
700 // We no longer delete packets here. Ownership of the packets is 700 // We no longer delete packets here. Ownership of the packets is
701 // transferred to the PacketView. 701 // transferred to the PacketView.
702 //delete p; 702 //delete p;
703 } 703 }
704} 704}
705 705
706 706
707void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* p ) 707void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* p )
708{ 708{
709 #ifdef QWS 709 #ifdef QWS
710 if ( action == "TouchSound" ) 710 if ( action == "TouchSound" )
711 ODevice::inst()->playTouchSound(); 711 ODevice::inst()->playTouchSound();
712 else if ( action == "AlarmSound" ) 712 else if ( action == "AlarmSound" )
713 ODevice::inst()->playAlarmSound(); 713 ODevice::inst()->playAlarmSound();
714 else if ( action == "KeySound" ) 714 else if ( action == "KeySound" )
715 ODevice::inst()->playKeySound(); 715 ODevice::inst()->playKeySound();
716 else if ( action == "LedOn" ) 716 else if ( action == "LedOn" )
717 ODevice::inst()->setLedState( Led_Mail, Led_On ); 717 ODevice::inst()->setLedState( Led_Mail, Led_On );
718 else if ( action == "LedOff" ) 718 else if ( action == "LedOff" )
719 ODevice::inst()->setLedState( Led_Mail, Led_Off ); 719 ODevice::inst()->setLedState( Led_Mail, Led_Off );
720 else if ( action == "LogMessage" ) 720 else if ( action == "LogMessage" )
721 logwindow->log( QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); 721 logwindow->log( QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) );
722 else if ( action == "MessageBox" ) 722 else if ( action == "MessageBox" )
723 QMessageBox::information( this, "Notification!", 723 QMessageBox::information( this, "Notification!",
724 QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); 724 QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) );
725 #else 725 #else
726 #warning Actions do not work with Qt/X11 yet 726 #warning Actions do not work with Qt/X11 yet
727 #endif 727 #endif
728} 728}
729 729
730void Wellenreiter::joinNetwork(const QString& type, const QString& essid, int channel, const QString& macaddr) 730void Wellenreiter::joinNetwork(const QString& type, const QString& essid, int channel, const QString& macaddr)
731{ 731{
732 #ifdef QWS 732 #ifdef QWS
733 if ( !iface ) 733 if ( !iface )
734 { 734 {
735 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "No wireless\ninterface available." ) ); 735 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "No wireless\ninterface available." ) );
736 return; 736 return;
737 } 737 }
738 738
739 if ( sniffing ) 739 if ( sniffing )
740 { 740 {
741 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Stop sniffing before\njoining a net." ) ); 741 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Stop sniffing before\njoining a net." ) );
742 return; 742 return;
743 } 743 }
744 744
745 qDebug( "joinNetwork() with Interface %s: %s, %s, %d, %s", 745 qDebug( "joinNetwork() with Interface %s: %s, %s, %d, %s",
746 (const char*) iface->name(), 746 (const char*) iface->name(),
747 (const char*) type, 747 (const char*) type,
748 (const char*) essid, 748 (const char*) essid,
749 channel, 749 channel,
750 (const char*) macaddr ); 750 (const char*) macaddr );
751 751
752 QCopEnvelope msg( "QPE/Application/networksettings", "wlan(QString,QString,QString)" ); 752 QCopEnvelope msg( "QPE/Application/networksettings", "wlan(QString,QString,QString)" );
753 int count = 3; 753 int count = 3;
754 odebug << "sending " << count << " messages" << oendl; 754 odebug << "sending " << count << " messages" << oendl;
755 msg << QString("count") << QString::number(count); 755 msg << QString("count") << QString::number(count);
756 odebug << "msg >" << iface->name() << "< Mode >" << type.latin1() << "<" << oendl; 756 odebug << "msg >" << iface->name() << "< Mode >" << type.latin1() << "<" << oendl;
757 msg << QString(iface->name()) << QString("Mode") << type; 757 msg << QString(iface->name()) << QString("Mode") << type;
758 odebug << "msg >" << iface->name() << "< essid >" << essid.latin1() << "<" << oendl; 758 odebug << "msg >" << iface->name() << "< essid >" << essid.latin1() << "<" << oendl;
759 msg << QString(iface->name()) << QString("ESSID") << essid; 759 msg << QString(iface->name()) << QString("ESSID") << essid;
760 odebug << "msg >" << iface->name() << "< channel >" << channel << "<" << oendl; 760 odebug << "msg >" << iface->name() << "< channel >" << channel << "<" << oendl;
761 msg << QString(iface->name()) << QString("Channel") << channel; 761 msg << QString(iface->name()) << QString("Channel") << channel;
762// odebug << "msg >" << iface->name() << "< mac >" << macaddr << "<" << oendl; 762// odebug << "msg >" << iface->name() << "< mac >" << macaddr << "<" << oendl;
763// msg << QString(iface->name()) << QString("MacAddr") << macaddr; 763// msg << QString(iface->name()) << QString("MacAddr") << macaddr;
764 #else 764 #else
765 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Function only available on Embedded build" ) ); 765 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Function only available on Embedded build" ) );
766 #endif 766 #endif
767 767
768} 768}
769 769
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.h b/noncore/net/wellenreiter/gui/wellenreiter.h
index 32e5690..f582a5f 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.h
+++ b/noncore/net/wellenreiter/gui/wellenreiter.h
@@ -1,112 +1,112 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file may be distributed and/or modified under the terms of the 4** This file may be distributed and/or modified under the terms of the
5** GNU General Public License version 2 as published by the Free Software 5** GNU General Public License version 2 as published by the Free Software
6** Foundation and appearing in the file LICENSE.GPL included in the 6** Foundation and appearing in the file LICENSE.GPL included in the
7** packaging of this file. 7** packaging of this file.
8** 8**
9** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 9** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
10** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 10** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
11** 11**
12**********************************************************************/ 12**********************************************************************/
13 13
14#ifndef WELLENREITER_H 14#ifndef WELLENREITER_H
15#define WELLENREITER_H 15#define WELLENREITER_H
16 16
17#include "wellenreiterbase.h" 17#include "wellenreiterbase.h"
18 18
19#ifdef QWS 19#ifdef QWS
20#include <opie2/odevice.h> 20#include <opie2/odevice.h>
21#endif 21#endif
22 22
23#include <signal.h> 23#include <signal.h>
24 24
25class QTimerEvent; 25class QTimerEvent;
26class QPixmap; 26class QPixmap;
27namespace Opie {namespace Net {class OPacket;}} 27namespace Opie {namespace Net {class OPacket;}}
28namespace Opie {namespace Net {class OWaveLanManagementPacket;}} 28namespace Opie {namespace Net {class OWaveLanManagementPacket;}}
29namespace Opie {namespace Net {class OWaveLanControlPacket;}} 29namespace Opie {namespace Net {class OWaveLanControlPacket;}}
30namespace Opie {namespace Net {class OWaveLanDataPacket;}} 30namespace Opie {namespace Net {class OWaveLanDataPacket;}}
31namespace Opie {namespace Net {class OEthernetPacket;}} 31namespace Opie {namespace Net {class OEthernetPacket;}}
32namespace Opie {namespace Net {class OARPPacket;}} 32namespace Opie {namespace Net {class OARPPacket;}}
33namespace Opie {namespace Net {class OMacAddress;}} 33namespace Opie {namespace Net {class OMacAddress;}}
34namespace Opie {namespace Net {class OIPPacket;}} 34namespace Opie {namespace Net {class OIPPacket;}}
35namespace Opie {namespace Net {class OPacket;}} 35namespace Opie {namespace Net {class OPacket;}}
36namespace Opie {namespace Net {class OWirelessNetworkInterface;}} 36namespace Opie {namespace Net {class OWirelessNetworkInterface;}}
37namespace Opie {namespace Net {class OPacketCapturer;}} 37namespace Opie {namespace Net {class OPacketCapturer;}}
38class PacketView; 38class PacketView;
39class WellenreiterConfigWindow; 39class WellenreiterConfigWindow;
40class MLogWindow; 40class MLogWindow;
41class GPS; 41class GPS;
42 42
43class Wellenreiter : public WellenreiterBase { 43class Wellenreiter : public WellenreiterBase {
44 Q_OBJECT 44 Q_OBJECT
45 45
46 public: 46 public:
47 Wellenreiter( QWidget* parent = 0 ); 47 Wellenreiter( QWidget* parent = 0 );
48 ~Wellenreiter(); 48 ~Wellenreiter();
49 49
50 void setConfigWindow( WellenreiterConfigWindow* cw ); 50 void setConfigWindow( WellenreiterConfigWindow* cw );
51 MScanListView* netView() const { return netview; }; 51 MScanListView* netView() const { return netview; };
52 MLogWindow* logWindow() const { return logwindow; }; 52 MLogWindow* logWindow() const { return logwindow; };
53 PacketView* hexWindow() const { return hexwindow; }; 53 PacketView* hexWindow() const { return hexwindow; };
54 bool isDaemonRunning() const { return sniffing; }; 54 bool isDaemonRunning() const { return sniffing; };
55 QString captureFileName() const { return dumpname; }; 55 QString captureFileName() const { return dumpname; };
56 56
57 public: 57 public:
58 QString dumpname;
58 bool sniffing; 59 bool sniffing;
59 static Wellenreiter* instance; 60 static Wellenreiter* instance;
60 static void signalHandler( int sig ); 61 static void signalHandler( int sig );
61 62
62 protected: 63 protected:
63 virtual void timerEvent( QTimerEvent* ); 64 virtual void timerEvent( QTimerEvent* );
64 65
65 public slots: 66 public slots:
66 void initialTimer(); 67 void initialTimer();
67 68
68 void channelHopped(int); 69 void channelHopped(int);
69 void receivePacket(Opie::Net::OPacket*); 70 void receivePacket(Opie::Net::OPacket*);
70 void startClicked(); 71 void startClicked();
71 void stopClicked(); 72 void stopClicked();
72 73
73 void joinNetwork(const QString&,const QString&,int,const QString&); 74 void joinNetwork(const QString&,const QString&,int,const QString&);
74 75
75 signals: 76 signals:
76 void startedSniffing(); 77 void startedSniffing();
77 void stoppedSniffing(); 78 void stoppedSniffing();
78 79
79 private: 80 private:
80 void handleManagementFrame( Opie::Net::OPacket* p, Opie::Net::OWaveLanManagementPacket* ); 81 void handleManagementFrame( Opie::Net::OPacket* p, Opie::Net::OWaveLanManagementPacket* );
81 void handleManagementFrameBeacon( Opie::Net::OPacket* p, Opie::Net::OWaveLanManagementPacket* ); 82 void handleManagementFrameBeacon( Opie::Net::OPacket* p, Opie::Net::OWaveLanManagementPacket* );
82 void handleManagementFrameProbeRequest( Opie::Net::OPacket* p, Opie::Net::OWaveLanManagementPacket* ); 83 void handleManagementFrameProbeRequest( Opie::Net::OPacket* p, Opie::Net::OWaveLanManagementPacket* );
83 void handleManagementFrameProbeResponse( Opie::Net::OPacket* p, Opie::Net::OWaveLanManagementPacket* ); 84 void handleManagementFrameProbeResponse( Opie::Net::OPacket* p, Opie::Net::OWaveLanManagementPacket* );
84 void handleControlFrame( Opie::Net::OPacket* p, Opie::Net::OWaveLanControlPacket* control ); 85 void handleControlFrame( Opie::Net::OPacket* p, Opie::Net::OWaveLanControlPacket* control );
85 void handleWlanData( Opie::Net::OPacket* p, Opie::Net::OWaveLanDataPacket* data, Opie::Net::OMacAddress& from, Opie::Net::OMacAddress& to ); 86 void handleWlanData( Opie::Net::OPacket* p, Opie::Net::OWaveLanDataPacket* data, Opie::Net::OMacAddress& from, Opie::Net::OMacAddress& to );
86 void handleEthernetData( Opie::Net::OPacket* p, Opie::Net::OEthernetPacket* data, Opie::Net::OMacAddress& from, Opie::Net::OMacAddress& to ); 87 void handleEthernetData( Opie::Net::OPacket* p, Opie::Net::OEthernetPacket* data, Opie::Net::OMacAddress& from, Opie::Net::OMacAddress& to );
87 void handleARPData( Opie::Net::OPacket* p, Opie::Net::OARPPacket* arp, Opie::Net::OMacAddress& from, Opie::Net::OMacAddress& to ); 88 void handleARPData( Opie::Net::OPacket* p, Opie::Net::OARPPacket* arp, Opie::Net::OMacAddress& from, Opie::Net::OMacAddress& to );
88 void handleIPData( Opie::Net::OPacket* p, Opie::Net::OIPPacket* ip, Opie::Net::OMacAddress& from, Opie::Net::OMacAddress& to ); 89 void handleIPData( Opie::Net::OPacket* p, Opie::Net::OIPPacket* ip, Opie::Net::OMacAddress& from, Opie::Net::OMacAddress& to );
89 void handleNotification( Opie::Net::OPacket* p ); 90 void handleNotification( Opie::Net::OPacket* p );
90 void doAction( const QString& action, const QString& protocol, Opie::Net::OPacket* p ); 91 void doAction( const QString& action, const QString& protocol, Opie::Net::OPacket* p );
91 QObject* childIfToParse( Opie::Net::OPacket* p, const QString& protocol ); 92 QObject* childIfToParse( Opie::Net::OPacket* p, const QString& protocol );
92 bool checkDumpPacket( Opie::Net::OPacket* p ); 93 bool checkDumpPacket( Opie::Net::OPacket* p );
93 void registerSignalHandler(); 94 void registerSignalHandler();
94 95
95 private: 96 private:
96 #ifdef QWS 97 #ifdef QWS
97 Opie::Core::OSystem _system; // Opie Operating System identifier 98 Opie::Core::OSystem _system; // Opie Operating System identifier
98 #endif 99 #endif
99 100
100 QString dumpname;
101 Opie::Net::OWirelessNetworkInterface* iface; 101 Opie::Net::OWirelessNetworkInterface* iface;
102 Opie::Net::OPacketCapturer* pcap; 102 Opie::Net::OPacketCapturer* pcap;
103 WellenreiterConfigWindow* configwindow; 103 WellenreiterConfigWindow* configwindow;
104 GPS* gps; 104 GPS* gps;
105 105
106 //void readConfig(); 106 //void readConfig();
107 //void writeConfig(); 107 //void writeConfig();
108}; 108};
109 109
110 110
111 111
112#endif 112#endif