author | mickeyl <mickeyl> | 2004-03-09 17:59:55 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-03-09 17:59:55 (UTC) |
commit | dd34b866c0f3e5041696dd97cf356d86a8d6d212 (patch) (side-by-side diff) | |
tree | fb4c6e414b851a3000d91d34d38a666da1fbf95a | |
parent | 25434cbbcd2d2473c9cd3d486cec7a96a6a6323e (diff) | |
download | opie-dd34b866c0f3e5041696dd97cf356d86a8d6d212.zip opie-dd34b866c0f3e5041696dd97cf356d86a8d6d212.tar.gz opie-dd34b866c0f3e5041696dd97cf356d86a8d6d212.tar.bz2 |
on the way to a new hex window
-rw-r--r-- | noncore/net/wellenreiter/TODO | 7 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/main.cpp | 1 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/mainwindow.cpp | 5 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/packetview.cpp | 48 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/packetview.h | 19 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 4 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.h | 4 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiterbase.cpp | 14 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiterbase.h | 4 |
9 files changed, 75 insertions, 31 deletions
diff --git a/noncore/net/wellenreiter/TODO b/noncore/net/wellenreiter/TODO index f3fd205..5f37ddf 100644 --- a/noncore/net/wellenreiter/TODO +++ b/noncore/net/wellenreiter/TODO @@ -1,60 +1,67 @@ /************************************************************************ /* W e l l e n r e i t e r I I /* =============================== /* /* Version: 1.0.2 /************************************************************************ ---------------------------------------------------- Ideas as of Wellenreiter II / December 2003 ---------------------------------------------------- -------- ENGINE -------- - enable multiple packet sources - infrared - bluetooth - usb? - define packet structure in a metalanguage and generate the actual parsing code (hmmm) - pester the ethereal folks to settle for an application independant packet dissection framework... (unlikely) - adaptive hopping scheme ! - gather interface capabilities - enable sniffing in wired networks - fix autodetection (interface name) --------- UI --------- - display interface capabilities (or rewrite networksettings?) - distinguish wireless bridges (WDS traffic) - add configuration for scrollback buffer in hex window and log window - revamp hex window, make it more sophisticated than just a QMultiLineEdit - tree view - beep over headphone / customizable - count/display number of wireless networks / APs since last start/stop --------- FILES --------- - write kismet-like .network format and format to be importable into AutoRoute - implement beacon stripping (the first beacon is enough to detect a new network - further beacons just blow up the capture file) +- write wi-scan format like that: + # $Creator: Wellenreiter II Version 1.0.2 + # $Format: wi-scan + # Latitude Longitude ( SSID ) Type ( BSSID ) Time (GMT) [ SNR Sig Noise ] + # $DateGMT: 2004-02-07 + N 41.1008009 W 8.3893034 ( Porceven ) BBS ( 00:a0:f8:41:91:63 ) 22:32:39 (GMT) [ 21 177 156 ] + diff --git a/noncore/net/wellenreiter/gui/main.cpp b/noncore/net/wellenreiter/gui/main.cpp index be7a528..7dcc583 100644 --- a/noncore/net/wellenreiter/gui/main.cpp +++ b/noncore/net/wellenreiter/gui/main.cpp @@ -1,109 +1,110 @@ /********************************************************************** ** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved. ** ** This file is part of Wellenreiter II. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** **********************************************************************/ #include "mainwindow.h" #ifdef QWS #include <opie2/oapplication.h> #include <opie2/oprocess.h> #else #include <qapplication.h> #endif #include <qmessagebox.h> #include <qstringlist.h> #include <errno.h> #include <signal.h> #include <string.h> #include <unistd.h> int main( int argc, char **argv ) { #ifdef QWS OApplication a( argc, argv, "Wellenreiter II" ); #else QApplication a( argc, argv ); #endif WellenreiterMainWindow* w = new WellenreiterMainWindow(); #ifdef QWS a.showMainWidget( w ); #else a.setMainWidget( w ); w->setCaption( "Wellenreiter II" ); w->show(); #endif a.processEvents(); // show the window before doing the safety checks int result = -1; static int killed = false; bool check = true; for ( int i = 1; i < argc; ++i ) { + qDebug( "Wellenreiter::main() parsing argument %d = '%s'", i, argv[i] ); if ( !strcmp( "-nocheck", argv[i] ) ) { qDebug( "-nocheck found" ); check = false; break; } } if ( check ) { // root check if ( getuid() ) { qWarning( QObject::tr( "Wellenreiter: trying to run as non-root!" ) ); result = QMessageBox::warning( w, " - Wellenreiter II - (non-root)", QObject::tr( "You have started Wellenreiter II\n" "as non-root. You will have\nonly limited functionality.\nProceed anyway?" ), QMessageBox::Yes, QMessageBox::No ); if ( result == QMessageBox::No ) return -1; } int dhcpid = OProcess::processPID( "dhcpc" ); if ( dhcpid ) { result = QMessageBox::warning( w, " - Wellenreiter II - (dhcp)", QObject::tr( "You have a dhcp client running.\n" "(PID = %1)\nThis can severly limit scanning!\nShould I kill it for you?" ).arg( dhcpid ), QMessageBox::Yes, QMessageBox::No ); if ( result == QMessageBox::Yes ) { if ( -1 == ::kill( dhcpid, SIGTERM ) ) qWarning( "Wellenreiter: can't kill process #%d (%s)", result, strerror( errno ) ); else killed = true; } } } a.exec(); if ( check ) { if ( killed ) { result = QMessageBox::warning( w, " - Wellenreiter II - (dhcp)", QObject::tr( "Restart your dhcp client?" ), QMessageBox::Yes, QMessageBox::No ); if ( result == QMessageBox::Yes ) { ::system( QString().sprintf( "dhclient &; udhcpcd &; dhcpcd &" ) ); } } delete w; } return 0; } diff --git a/noncore/net/wellenreiter/gui/mainwindow.cpp b/noncore/net/wellenreiter/gui/mainwindow.cpp index 6f57a7f..5cc0daf 100644 --- a/noncore/net/wellenreiter/gui/mainwindow.cpp +++ b/noncore/net/wellenreiter/gui/mainwindow.cpp @@ -1,542 +1,545 @@ /********************************************************************** ** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved. ** ** This file is part of Wellenreiter II. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** **********************************************************************/ #include "configwindow.h" #include "gps.h" #include "logwindow.h" -#include "hexwindow.h" +#include "packetview.h" #include "mainwindow.h" #include "wellenreiter.h" #include "scanlist.h" #include <qcombobox.h> #include <qdatastream.h> #include <qfile.h> #include <qfileinfo.h> #include <qlabel.h> #include <qlayout.h> #include <qlineedit.h> #include <qiconset.h> #include <qmenubar.h> #include <qmessagebox.h> #include <qpopupmenu.h> #include <qpushbutton.h> #include <qstatusbar.h> #include <qspinbox.h> #include <qtextstream.h> #include <qtoolbutton.h> #include <qwhatsthis.h> #ifdef QWS #include <qpe/resource.h> #include <opie2/ofiledialog.h> using namespace Opie; #else #include "resource.h" #include <qapplication.h> #include <qfiledialog.h> #endif #include <unistd.h> WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * name, WFlags f ) :QMainWindow( parent, name, f ) { cw = new WellenreiterConfigWindow( this ); mw = new Wellenreiter( this ); mw->setConfigWindow( cw ); setCentralWidget( mw ); // setup application icon setIcon( Resource::loadPixmap( "wellenreiter/appicon-trans" ) ); #ifndef QWS setIconText( "Wellenreiter/X11" ); #endif // setup tool buttons startButton = new QToolButton( 0 ); QWhatsThis::add( startButton, tr( "Click here to start scanning." ) ); #ifdef QWS startButton->setAutoRaise( true ); #endif startButton->setIconSet( Resource::loadIconSet( "wellenreiter/SearchIcon" ) ); startButton->setEnabled( false ); connect( startButton, SIGNAL( clicked() ), mw, SLOT( startClicked() ) ); stopButton = new QToolButton( 0 ); QWhatsThis::add( stopButton, tr( "Click here to stop scanning." ) ); #ifdef QWS stopButton->setAutoRaise( true ); #endif stopButton->setIconSet( Resource::loadIconSet( "wellenreiter/CancelIcon" ) ); stopButton->setEnabled( false ); connect( stopButton, SIGNAL( clicked() ), mw, SLOT( stopClicked() ) ); QToolButton* d = new QToolButton( 0 ); QWhatsThis::add( d, tr( "Click here to open the configure dialog." ) ), #ifdef QWS d->setAutoRaise( true ); #endif d->setIconSet( Resource::loadIconSet( "wellenreiter/SettingsIcon" ) ); connect( d, SIGNAL( clicked() ), this, SLOT( showConfigure() ) ); uploadButton = new QToolButton( 0 ); QWhatsThis::add( uploadButton, tr( "Click here to upload a capture session." ) ); #ifdef QWS uploadButton->setAutoRaise( true ); #endif uploadButton->setIconSet( Resource::loadIconSet( "up" ) ); uploadButton->setEnabled( false ); //uploadButton->setEnabled( true ); // DEBUGGING connect( uploadButton, SIGNAL( clicked() ), this, SLOT( uploadSession() ) ); // setup menu bar int id; QMenuBar* mb = menuBar(); QPopupMenu* fileSave = new QPopupMenu( mb ); fileSave->insertItem( tr( "&Session..." ), this, SLOT( fileSaveSession() ) ); fileSave->insertItem( tr( "&Text Log..." ), this, SLOT( fileSaveLog() ) ); fileSave->insertItem( tr( "&Hex Log..." ), this, SLOT( fileSaveHex() ) ); QPopupMenu* fileLoad = new QPopupMenu( mb ); fileLoad->insertItem( tr( "&Session..." ), this, SLOT( fileLoadSession() ) ); //fileLoad->insertItem( "&Log", this, SLOT( fileLoadLog() ) ); QPopupMenu* file = new QPopupMenu( mb ); file->insertItem( tr( "&New" ), this, SLOT( fileNew() ) ); id = file->insertItem( tr( "&Load" ), fileLoad ); file->insertItem( tr( "&Save" ), fileSave ); file->insertSeparator(); uploadID = file->insertItem( tr( "&Upload Session" ), this, SLOT( uploadSession() ) ); file->insertSeparator(); file->insertItem( tr( "&Exit" ), qApp, SLOT( quit() ) ); QPopupMenu* sniffer = new QPopupMenu( mb ); sniffer->insertItem( tr( "&Configure..." ), this, SLOT( showConfigure() ) ); sniffer->insertSeparator(); startID = sniffer->insertItem( tr( "&Start" ), mw, SLOT( startClicked() ) ); sniffer->setItemEnabled( startID, false ); stopID = sniffer->insertItem( tr( "Sto&p" ), mw, SLOT( stopClicked() ) ); sniffer->setItemEnabled( stopID, false ); QPopupMenu* view = new QPopupMenu( mb ); view->insertItem( tr( "&Expand All" ), this, SLOT( viewExpandAll() ) ); view->insertItem( tr( "&Collapse All" ), this, SLOT( viewCollapseAll() ) ); QPopupMenu* demo = new QPopupMenu( mb ); demo->insertItem( tr( "&Add something" ), this, SLOT( demoAddStations() ) ); //demo->insertItem( tr( "&Read from GPSd" ), this, SLOT( demoReadFromGps() ) ); id = mb->insertItem( tr( "&File" ), file ); id = mb->insertItem( tr( "&View" ), view ); //mb->setItemEnabled( id, false ); id = mb->insertItem( tr( "&Sniffer" ), sniffer ); id = mb->insertItem( tr( "&Demo" ), demo ); mb->setItemEnabled( id, true ); mb->setItemEnabled( uploadID, false ); #ifdef QWS mb->insertItem( startButton ); mb->insertItem( stopButton ); mb->insertItem( uploadButton ); mb->insertItem( d ); #else // Qt3 changed the insertion order. It's now totally random :( mb->insertItem( d ); mb->insertItem( uploadButton ); mb->insertItem( stopButton ); mb->insertItem( startButton ); #endif updateToolButtonState(); // setup status bar (for now only on X11) #ifndef QWS statusBar()->message( tr( "Ready." ) ); #endif connect( mw, SIGNAL( startedSniffing() ), this, SLOT( changedSniffingState() ) ); connect( mw, SIGNAL( stoppedSniffing() ), this, SLOT( changedSniffingState() ) ); }; void WellenreiterMainWindow::showConfigure() { qDebug( "show configure..." ); cw->setCaption( tr( "Configure" ) ); int result = QPEApplication::execDialog( cw ); if ( result ) updateToolButtonState(); } void WellenreiterMainWindow::updateToolButtonState() { const QString& interface = cw->interfaceName->currentText(); const int cardtype = cw->driverType(); if ( ( interface != "<select>" ) && ( cardtype != 0 ) ) { startButton->setEnabled( true ); menuBar()->setItemEnabled( startID, true ); } else { startButton->setEnabled( false ); menuBar()->setItemEnabled( startID, false ); } } void WellenreiterMainWindow::changedSniffingState() { startButton->setEnabled( !mw->sniffing ); menuBar()->setItemEnabled( startID, !mw->sniffing ); stopButton->setEnabled( mw->sniffing ); menuBar()->setItemEnabled( stopID, mw->sniffing ); if ( !mw->sniffing ) { menuBar()->setItemEnabled( uploadID, true ); uploadButton->setEnabled( true ); } } WellenreiterMainWindow::~WellenreiterMainWindow() { qDebug( "Wellenreiter: bye." ); }; void WellenreiterMainWindow::demoAddStations() { //mw = 0; // test SIGSEGV handling mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:00:20:EF:A6:43"), true, 6, 80, GpsLocation( 39.8794, -94.0936) ); mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:30:6D:EF:A6:23"), true, 11, 10, GpsLocation( 0.0, 0.0 ) ); mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:03:F8:E7:16:22"), false, 3, 10, GpsLocation( 5.5, 2.3 ) ); mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:04:01:E7:56:62"), false, 3, 15, GpsLocation( 2.3, 5.5 ) ); mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:05:8E:E7:56:E2"), false, 3, 20, GpsLocation( -10.0, -20.5 ) ); } void WellenreiterMainWindow::demoReadFromGps() { WellenreiterConfigWindow* configwindow = WellenreiterConfigWindow::instance(); GPS* gps = new GPS( this ); qDebug( "Wellenreiter::demoReadFromGps(): url=gps://%s:%d/", (const char*) configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); GpsLocation loc = gps->position(); QMessageBox::information( this, "Wellenreiter/Opie", tr( "GPS said:\n%1" ).arg( loc.dmsPosition() ) ); delete gps; } QString WellenreiterMainWindow::getFileName( bool save ) { QMap<QString, QStringList> map; map.insert( tr("All"), QStringList() ); QStringList text; text << "text/*"; map.insert( tr("Text"), text ); text << "*"; map.insert( tr("All"), text ); QString str; if ( save ) { #ifdef QWS str = OFileDialog::getSaveFileName( 2, "/", QString::null, map ); #else str = QFileDialog::getSaveFileName(); #endif if ( str.isEmpty() /*|| QFileInfo(str).isDir()*/ ) return ""; } else { #ifdef QWS str = OFileDialog::getOpenFileName( 2, "/", QString::null, map ); #else str = QFileDialog::getOpenFileName(); #endif if ( str.isEmpty() || !QFile(str).exists() || QFileInfo(str).isDir() ) return ""; } return str; } void WellenreiterMainWindow::fileSaveLog() { QString fname = getFileName( true ); if ( !fname.isEmpty() ) { QFile f( fname ); if ( f.open(IO_WriteOnly) ) { QTextStream t( &f ); t << mw->logWindow()->getLog(); f.close(); qDebug( "Saved log to file '%s'", (const char*) fname ); } else { qDebug( "Problem saving log to file '%s'", (const char*) fname ); } } } void WellenreiterMainWindow::fileSaveSession() { QString fname = getFileName( true ); if ( !fname.isEmpty() ) { QFile f( fname ); if ( f.open(IO_WriteOnly) ) { QDataStream t( &f ); t << *mw->netView(); f.close(); qDebug( "Saved session to file '%s'", (const char*) fname ); } else { qDebug( "Problem saving session to file '%s'", (const char*) fname ); } } } void WellenreiterMainWindow::fileSaveHex() { + #warning DOES NOT WORK AT THE MOMENT + /* QString fname = getFileName( true ); if ( !fname.isEmpty() ) { QFile f( fname ); if ( f.open(IO_WriteOnly) ) { QTextStream t( &f ); t << mw->hexWindow()->getLog(); f.close(); qDebug( "Saved hex log to file '%s'", (const char*) fname ); } else { qDebug( "Problem saving hex log to file '%s'", (const char*) fname ); } } + */ } void WellenreiterMainWindow::fileLoadSession() { QString fname = getFileName( false ); if ( !fname.isEmpty() ) { QFile f( fname ); if ( f.open(IO_ReadOnly) ) { QDataStream t( &f ); t >> *mw->netView(); f.close(); qDebug( "Loaded session from file '%s'", (const char*) fname ); } else { qDebug( "Problem loading session from file '%s'", (const char*) fname ); } } } void WellenreiterMainWindow::fileNew() { mw->netView()->clear(); mw->logWindow()->clear(); mw->hexWindow()->clear(); } void WellenreiterMainWindow::closeEvent( QCloseEvent* e ) { if ( mw->isDaemonRunning() ) { QMessageBox::warning( this, "Wellenreiter/Opie", tr( "Sniffing in progress!\nPlease stop sniffing before closing." ) ); e->ignore(); } else { QMainWindow::closeEvent( e ); } } static const char* CAP_hostname = "www.vanille.de"; #include <netdb.h> #include <unistd.h> #include <sys/types.h> #include <sys/socket.h> void WellenreiterMainWindow::uploadSession() { QLineEdit* from; QLineEdit* location; QLineEdit* comments; QPushButton* accept; QPushButton* reject; QDialog* d = new QDialog( 0, "session upload", true ); d->setCaption( tr( "Upload Session" ) ); QGridLayout* g = new QGridLayout( d, 4, 2, 3 ); g->addWidget( new QLabel( tr( "From: " ), d ), 0, 0 ); g->addWidget( from = new QLineEdit( d ), 0, 1 ); g->addWidget( new QLabel( tr( "Location: " ), d ), 1, 0 ); g->addWidget( location = new QLineEdit( d ), 1, 1 ); g->addWidget( new QLabel( tr( "Comments: " ), d ), 2, 0 ); g->addWidget( comments = new QLineEdit( d ), 2, 1 ); g->addWidget( accept = new QPushButton( tr( "&Ok" ), d ), 3, 0 ); g->addWidget( reject = new QPushButton( tr( "&Cancel" ), d ), 3, 1 ); accept->setDefault( true ); accept->setAutoDefault( true ); from->setText( "WL II User" ); location->setText( "WL II Location" ); comments->setText( "No Comments." ); connect( accept, SIGNAL( clicked() ), d, SLOT( accept() ) ); connect( reject, SIGNAL( clicked() ), d, SLOT( reject() ) ); int result = d->exec(); if ( !result ) { qDebug( "Session upload cancelled :(" ); return; } qDebug( "Starting upload..." ); struct sockaddr_in raddr; struct hostent *rhost_info; int sock = -1; bool ok = false; rhost_info = (struct hostent *) ::gethostbyname( CAP_hostname ); if ( rhost_info ) { if ( !QFile::exists( mw->captureFileName() ) ) { QMessageBox::warning( 0, tr( "Error" ), tr( "<p>Logfile '%1' doesn't exist</p>").arg( mw->captureFileName() ) ); return; } QFile f( mw->captureFileName() ); if ( !f.open( IO_ReadOnly ) ) { QMessageBox::warning( 0, tr( "Error" ), tr( "<p>Can't open Logfile '%1'</p>").arg( mw->captureFileName() ) ); return; } int content_length = f.size(); ::memset( &raddr, 0, sizeof (struct sockaddr_in) ); ::memcpy( &raddr. sin_addr, rhost_info-> h_addr, rhost_info-> h_length ); raddr.sin_family = rhost_info-> h_addrtype; raddr.sin_port = htons ( 80 ); sock = ::socket( AF_INET, SOCK_STREAM, 0 ); if ( sock >= 0 ) { if ( ::connect ( sock, (struct sockaddr *) & raddr, sizeof (struct sockaddr)) >= 0 ) { QString header; QString content; QString preambel; header = "" "POST /projects/capturedump.spy HTTP/1.1\r\n" "Host: www.vanille.de\r\n" "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031010 Galeon/1.3.10\r\n" "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" "Accept-Language: en\r\n" "Accept-Encoding: gzip, deflate, compress;q=0.9\r\n" "Accept-Charset: us-ascii,utf-8;q=0.7,*;q=0.7\r\n" "Keep-Alive: 300\r\n" "Connection: keep-alive\r\n" "Referer: http://www.vanille.de/projects/capturedump.spy\r\n" "Content-Type: multipart/form-data; boundary=---------------------------97267758015830030481215568065\r\n" "Content-Length: %1\r\n" "\r\n"; content = "" "-----------------------------97267758015830030481215568065\r\n" "Content-Disposition: form-data; name=\"Name\"\r\n" "\r\n" "%1\r\n" "-----------------------------97267758015830030481215568065\r\n" "Content-Disposition: form-data; name=\"Location\"\r\n" "\r\n" "%2\r\n" "-----------------------------97267758015830030481215568065\r\n" "Content-Disposition: form-data; name=\"Comments\"\r\n" "\r\n" "%3\r\n" "-----------------------------97267758015830030481215568065\r\n" "Content-Disposition: form-data; name=\"upfile\"; filename=\"%4\"\r\n" "Content-Type: application/octet-stream\r\n" "\r\n"; preambel = "" "\r\n-----------------------------97267758015830030481215568065--\r\n"; content = content.arg( from->text().isEmpty() ? QString( "Anonymous Wellenreiter II User" ) : from->text() ); content = content.arg( location->text().isEmpty() ? QString( "Anonymous Wellenreiter II Location" ) : location->text() ); content = content.arg( comments->text().isEmpty() ? QString( "Anonymous Wellenreiter II Comments" ) : comments->text() ); content = content.arg( mw->captureFileName() ); header = header.arg( QString::number( content.length() + f.size() + preambel.length() ) ); // write header const char* ascii = header.latin1(); uint ascii_len = ::strlen( ascii ); ::write ( sock, ascii, ascii_len ); // write fixed content ascii = content.latin1(); ascii_len = ::strlen( ascii ); ::write ( sock, ascii, ascii_len ); // write variable content char ch; while ( !f.atEnd() ) { f.readBlock( &ch, 1 ); ::write ( sock, &ch, 1 ); } diff --git a/noncore/net/wellenreiter/gui/packetview.cpp b/noncore/net/wellenreiter/gui/packetview.cpp index e986b49..ef5d020 100644 --- a/noncore/net/wellenreiter/gui/packetview.cpp +++ b/noncore/net/wellenreiter/gui/packetview.cpp @@ -1,44 +1,68 @@ /********************************************************************** ** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved. ** ** This file is part of Wellenreiter II. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** **********************************************************************/ #include "packetview.h" -#include <qmultilineedit.h> + +/* OPIE */ +#include <opie2/opcap.h> + +/* QT */ +#include <qtextview.h> +#include <qspinbox.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qlist.h> PacketView::PacketView( QWidget * parent, const char * name, WFlags f ) - :QVBox( parent, name, f ) + :QFrame( parent, name, f ) { - ledit = new QMultiLineEdit( this ); - ledit->setFont( QFont( "fixed", 10 ) ); - ledit->setReadOnly( true ); + _number = new QSpinBox( this ); + _number->setPrefix( "Packet # " ); + _label = new QLabel( this ); + _label->setText( "eth0 2004/03/08 - 00:00:21" ); + _list = new QLabel( this ); + _hex = new QTextView( this ); + + QVBoxLayout* vb = new QVBoxLayout( this, 2, 2 ); + QHBoxLayout* hb = new QHBoxLayout( vb, 2 ); + hb->addWidget( _label ); + hb->addWidget( _number ); + vb->addWidget( _list ); + vb->addWidget( _hex ); + + _packets.setAutoDelete( true ); + + _list->setText( "<b>[ 802.11 [ LLC [ IP [ UDP [ DHCP ] ] ] ] ]</b>" ); }; -void PacketView::log( const QString& text ) +void PacketView::add( OPacket* p ) { - int col; - int row; - ledit->getCursorPosition( &col, &row ); - ledit->insertAt( text, col, row ); + _packets.append( p ); }; const QString PacketView::getLog() const { - return ledit->text(); } void PacketView::clear() { - ledit->clear(); + _packets.clear(); + _number->setMinValue( 0 ); + _number->setMaxValue( 0 ); + _label->setText( "---" ); + _list->setText( " <b>-- no Packet available --</b> " ); + _hex->setText( " <i>-- no Packet available --</i> " ); } diff --git a/noncore/net/wellenreiter/gui/packetview.h b/noncore/net/wellenreiter/gui/packetview.h index ee3cf3a..b5f2b26 100644 --- a/noncore/net/wellenreiter/gui/packetview.h +++ b/noncore/net/wellenreiter/gui/packetview.h @@ -1,40 +1,49 @@ /********************************************************************** ** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved. ** ** This file is part of Wellenreiter II. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** **********************************************************************/ #ifndef PACKETVIEW_H #define PACKETVIEW_H -#include <qvbox.h> +#include <qlist.h> +#include <qframe.h> class QString; -class QMultiLineEdit; +class QSpinBox; +class QLabel; +class QTextView; +class OPacket; -class PacketView: public QVBox +class PacketView: public QFrame { public: PacketView( QWidget * parent = 0, const char * name = "PacketView", WFlags f = 0 ); - void log( const QString& text ); + void add( OPacket* p ); const QString getLog() const; void clear(); protected: - QMultiLineEdit* ledit; + + QSpinBox* _number; + QLabel* _label; + QLabel* _list; + QTextView* _hex; + QList<OPacket> _packets; }; #endif diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index 67e3940..ce416e5 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp @@ -1,575 +1,575 @@ /********************************************************************** ** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ***********************************************************************/ // Local #include "gps.h" #include "wellenreiter.h" #include "scanlist.h" #include "logwindow.h" -#include "hexwindow.h" +#include "packetview.h" #include "configwindow.h" #include "statwindow.h" #include "graphwindow.h" #include "protolistview.h" // Opie #ifdef QWS #include <opie2/oapplication.h> #include <opie2/odevice.h> #else #include <qapplication.h> #endif #include <opie2/omanufacturerdb.h> #include <opie2/onetwork.h> #include <opie2/opcap.h> #include <qpe/qcopenvelope_qws.h> using namespace Opie; // Qt #include <qcheckbox.h> #include <qcombobox.h> #include <qdatetime.h> #include <qpushbutton.h> #include <qlineedit.h> #include <qmessagebox.h> #include <qobjectlist.h> #include <qregexp.h> #include <qspinbox.h> #include <qtimer.h> #include <qtoolbutton.h> #include <qmainwindow.h> // Standard #include <assert.h> #include <errno.h> #include <unistd.h> #include <string.h> #include <sys/types.h> #include <stdlib.h> Wellenreiter::Wellenreiter( QWidget* parent ) : WellenreiterBase( parent, 0, 0 ), sniffing( false ), iface( 0 ), configwindow( 0 ) { logwindow->log( "(i) Wellenreiter has been started." ); // // detect operating system // #ifdef QWS QString sys; sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); _system = ODevice::inst()->system(); logwindow->log( sys ); #endif netview->setColumnWidthMode( 1, QListView::Manual ); connect( netview, SIGNAL( joinNetwork(const QString&,const QString&,int,const QString&) ), this, SLOT( joinNetwork(const QString&,const QString&,int,const QString&) ) ); pcap = new OPacketCapturer(); gps = new GPS( this ); QTimer::singleShot( 1000, this, SLOT( initialTimer() ) ); } Wellenreiter::~Wellenreiter() { delete pcap; } void Wellenreiter::initialTimer() { qDebug( "Wellenreiter::preloading manufacturer database..." ); OManufacturerDB::instance(); } void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) { configwindow = cw; } void Wellenreiter::channelHopped(int c) { QString title = "Wellenreiter II -scan- ["; QString left; if ( c > 1 ) left.fill( '.', c-1 ); title.append( left ); title.append( '|' ); if ( c < iface->channels() ) { QString right; right.fill( '.', iface->channels()-c ); title.append( right ); } title.append( "]" ); //title.append( QString().sprintf( " %02d", c ) ); assert( parent() ); ( (QMainWindow*) parent() )->setCaption( title ); } void Wellenreiter::handleNotification( OPacket* p ) { QObjectList* l = p->queryList(); QObjectListIt it( *l ); QObject* o; while ( (o = it.current()) != 0 ) { QString name = it.current()->name(); if ( configwindow->parsePackets->isProtocolChecked( name ) ) { QString action = configwindow->parsePackets->protocolAction( name ); qDebug( "parsePacket-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); doAction( action, name, p ); } else { qDebug( "protocol '%s' not checked in parsePackets.", (const char*) name ); } ++it; } } void Wellenreiter::handleManagementFrame( OPacket* p, OWaveLanManagementPacket* manage ) { if ( manage->managementType() == "Beacon" ) handleManagementFrameBeacon( p, manage ); else if ( manage->managementType() == "ProbeRequest" ) handleManagementFrameProbeRequest( p, manage ); else if ( manage->managementType() == "ProbeResponse" ) handleManagementFrameProbeResponse( p, manage ); else qWarning( "Wellenreiter::handleManagementFrame(): '%s' - please handle me!", (const char*) manage->managementType() ); } void Wellenreiter::handleManagementFrameProbeRequest( OPacket* p, OWaveLanManagementPacket* request ) { OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); QString essid = ssid ? ssid->ID( true /* decloak */ ) : QString("<unknown>"); OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); int channel = ds ? ds->channel() : -1; OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); GpsLocation loc( -111, -111 ); if ( configwindow->enableGPS->isChecked() ) { // TODO: add check if GPS is working!? qDebug( "Wellenreiter::gathering GPS data..." ); loc = gps->position(); qDebug( "Wellenreiter::GPS data received is ( %f , %f ) - dms string = '%s'", loc.latitude(), loc.longitude(), loc.dmsPosition().latin1() ); } if ( essid.length() ) netView()->addNewItem( "adhoc", essid, header->macAddress2(), false /* should check FrameControl field */, -1, 0, loc, true /* only probed */ ); qDebug( "Wellenreiter::invalid frame [possibly noise] detected!" ); } void Wellenreiter::handleManagementFrameProbeResponse( OPacket* p, OWaveLanManagementPacket* response ) { } void Wellenreiter::handleManagementFrameBeacon( OPacket* p, OWaveLanManagementPacket* beacon ) { QString type; if ( beacon->canIBSS() ) { type = "adhoc"; } else if ( beacon->canESS() ) { type = "managed"; } else { qWarning( "Wellenreiter::invalid frame [possibly noise] detected!" ); return; } OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); QString essid = ssid ? ssid->ID( true /* decloak */ ) : QString("<unknown>"); OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); int channel = ds ? ds->channel() : -1; OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); GpsLocation loc( -111, -111 ); if ( configwindow->enableGPS->isChecked() ) { // TODO: add check if GPS is working!? qDebug( "Wellenreiter::gathering GPS data..." ); loc = gps->position(); qDebug( "Wellenreiter::GPS data received is ( %f , %f ) - dms string = '%s'", loc.latitude(), loc.longitude(), loc.dmsPosition().latin1() ); } netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0, loc ); // update graph window if ( ds ) { OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) ); if ( prism ) graphwindow->traffic( ds->channel(), prism->signalStrength() ); else graphwindow->traffic( ds->channel(), 95 ); } } void Wellenreiter::handleControlFrame( OPacket* p, OWaveLanControlPacket* control ) { OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); if ( control->controlType() == "Acknowledge" ) { netView()->addNewItem( "adhoc", "<unknown>", header->macAddress1(), false, -1, 0, GpsLocation( -111, -111 ) ); } else { qDebug( "Wellenreiter::handleControlFrame - please handle %s in a future version! :D", (const char*) control->controlType() ); } } void Wellenreiter::handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to ) { OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); if ( wlan->fromDS() && !wlan->toDS() ) { netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); from = wlan->macAddress3(); to = wlan->macAddress2(); } else if ( !wlan->fromDS() && wlan->toDS() ) { netView()->toDStraffic( wlan->macAddress2(), wlan->macAddress3(), wlan->macAddress1() ); from = wlan->macAddress2(); to = wlan->macAddress3(); } else if ( wlan->fromDS() && wlan->toDS() ) { netView()->WDStraffic( wlan->macAddress4(), wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); from = wlan->macAddress4(); to = wlan->macAddress3(); } else { netView()->IBSStraffic( wlan->macAddress2(), wlan->macAddress1(), wlan->macAddress3() ); from = wlan->macAddress2(); to = wlan->macAddress1(); } } void Wellenreiter::handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to ) { from = data->sourceAddress(); to = data->destinationAddress(); netView()->addNewItem( "station", "<wired>", from, false, -1, 0, GpsLocation( -111, -111 ) ); } void Wellenreiter::handleARPData( OPacket* p, OARPPacket*, OMacAddress& source, OMacAddress& dest ) { OARPPacket* arp = (OARPPacket*) p->child( "ARP" ); if ( arp ) { qDebug( "Received ARP traffic (type '%s'): ", (const char*) arp->type() ); if ( arp->type() == "REQUEST" ) { netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); } else if ( arp->type() == "REPLY" ) { netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() ); } } } void Wellenreiter::handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& source, OMacAddress& dest ) { //TODO: Implement more IP based protocols ODHCPPacket* dhcp = (ODHCPPacket*) p->child( "DHCP" ); if ( dhcp ) { qDebug( "Received DHCP '%s' packet", (const char*) dhcp->type() ); if ( dhcp->type() == "OFFER" ) { qDebug( "DHCP: '%s' ('%s') seems to be a DHCP server.", (const char*) source.toString(), (const char*) dhcp->serverAddress().toString() ); netView()->identify( source, dhcp->serverAddress().toString() ); netView()->addService( "DHCP", source, dhcp->serverAddress().toString() ); } else if ( dhcp->type() == "ACK" ) { qDebug( "DHCP: '%s' ('%s') accepted the offered DHCP address.", (const char*) dhcp->clientMacAddress().toString(), (const char*) dhcp->yourAddress().toString() ); netView()->identify( dhcp->clientMacAddress(), dhcp->yourAddress().toString() ); } } } QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol ) { if ( configwindow->parsePackets->isProtocolChecked( protocol ) ) if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" ) return 0; return p->child( protocol ); } bool Wellenreiter::checkDumpPacket( OPacket* p ) { // go through all child packets and see if one is inside the child hierarchy for p // if so, do what the user requested (protocolAction), e.g. pass or discard if ( !configwindow->writeCaptureFile->isChecked() ) return true; // semantic change - we're logging anyway now to /tmp/wellenreiter QObjectList* l = p->queryList(); QObjectListIt it( *l ); QObject* o; while ( (o = it.current()) != 0 ) { QString name = it.current()->name(); if ( configwindow->capturePackets->isProtocolChecked( name ) ) { QString action = configwindow->capturePackets->protocolAction( name ); qDebug( "capturePackets-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); if ( action == "Discard" ) { logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) ); return false; } } else { qDebug( "protocol '%s' not checked in capturePackets.", (const char*) name ); } ++it; } return true; } void Wellenreiter::receivePacket( OPacket* p ) { - hexWindow()->log( p->dump( 8 ) ); + hexWindow()->add( p ); if ( checkDumpPacket( p ) ) { pcap->dump( p ); } // check for a management frame OWaveLanManagementPacket* manage = static_cast<OWaveLanManagementPacket*>( childIfToParse( p, "802.11 Management" ) ); if ( manage ) { handleManagementFrame( p, manage ); return; } // check for a control frame OWaveLanControlPacket* control = static_cast<OWaveLanControlPacket*>( childIfToParse( p, "802.11 Control" ) ); if ( control ) { handleControlFrame( p, control ); return; } OMacAddress source; OMacAddress dest; //TODO: WEP check here // check for a wireless data frame OWaveLanDataPacket* wlan = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) ); if ( wlan ) { handleWlanData( p, wlan, source, dest ); } // check for a wired data frame OEthernetPacket* eth = static_cast<OEthernetPacket*>( childIfToParse( p, "Ethernet" ) ); if ( eth ) { handleEthernetData( p, eth, source, dest ); } // check for an arp frame since arp frames come in two flavours: // 802.11 encapsulates ARP data within IP packets while wired ethernet doesn't. OARPPacket* arp = static_cast<OARPPacket*>( childIfToParse( p, "ARP" ) ); if ( arp ) { handleARPData( p, arp, source, dest ); } // check for a ip frame OIPPacket* ip = static_cast<OIPPacket*>( childIfToParse( p, "IP" ) ); if ( ip ) { handleIPData( p, ip, source, dest ); } //handleNotification( p ); } void Wellenreiter::stopClicked() { if ( iface ) { disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); iface->setChannelHopping(); // stop hopping channels } else killTimers(); pcap->close(); sniffing = false; if ( iface ) { // switch off monitor mode iface->setMode( "managed" ); // switch off promisc flag iface->setPromiscuousMode( false ); system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess } logwindow->log( "(i) Stopped Scanning." ); assert( parent() ); ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" ); // message the user QMessageBox::information( this, "Wellenreiter II", tr( "Your wireless card\nshould now be usable again." ) ); sniffing = false; emit( stoppedSniffing() ); #ifdef QWS if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() ) { QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; } #else #warning FIXME: setScreenSaverMode is not operational on the X11 build #endif // print out statistics for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it ) statwindow->updateCounter( it.key(), it.data() ); } void Wellenreiter::startClicked() { // get configuration from config window const QString& interface = configwindow->interfaceName->currentText(); const int cardtype = configwindow->driverType(); const int interval = configwindow->hoppingInterval(); if ( ( interface == "" ) || ( cardtype == 0 ) ) { QMessageBox::information( this, "Wellenreiter II", tr( "Your device is not\nproperly configured. Please reconfigure!" ) ); return; } // configure device ONetwork* net = ONetwork::instance(); // TODO: check if interface is wireless and support sniffing for non-wireless interfaces if ( !net->isPresent( interface ) ) { QMessageBox::information( this, "Wellenreiter II", tr( "The configured device (%1)\nis not available on this system\n. Please reconfigure!" ).arg( interface ) ); return; } iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); // fails if network is not wireless! assert( iface ); // bring device UP if ( cardtype != DEVTYPE_FILE ) { iface->setUp( true ); if ( !iface->isUp() ) { QMessageBox::warning( this, "Wellenreiter II", tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) ); return; } } // set monitor mode bool usePrism = configwindow->usePrismHeader(); switch ( cardtype ) { case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break; case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break; case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break; case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break; case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break; case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break; default: assert( 0 ); // shouldn't reach this } // switch device into monitor mode if ( cardtype < DEVTYPE_FILE ) { if ( cardtype != DEVTYPE_MANUAL ) iface->setMode( "monitor" ); if ( iface->mode() != "monitor" ) { if ( QMessageBox::warning( this, "Wellenreiter II", tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) + tr( "\nContinue with limited functionality?" ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) return; } } // open GPS device if ( configwindow->enableGPS->isChecked() ) { qDebug( "Wellenreiter:GPS enabled @ %s:%d", (const char*) configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); } // open pcap and start sniffing if ( configwindow->writeCaptureFile->isChecked() ) // write to a user specified capture file? { dumpname = configwindow->captureFileName->text(); diff --git a/noncore/net/wellenreiter/gui/wellenreiter.h b/noncore/net/wellenreiter/gui/wellenreiter.h index 745486f..d02813b 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.h +++ b/noncore/net/wellenreiter/gui/wellenreiter.h @@ -1,107 +1,107 @@ /********************************************************************** ** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** **********************************************************************/ #ifndef WELLENREITER_H #define WELLENREITER_H #include "wellenreiterbase.h" #ifdef QWS #include <opie2/odevice.h> using namespace Opie; #endif class QTimerEvent; class QPixmap; class OPacket; class OWaveLanManagementPacket; class OWaveLanControlPacket; class OWaveLanDataPacket; class OEthernetPacket; class OARPPacket; class OMacAddress; class OIPPacket; class OPacketCapturer; class OWirelessNetworkInterface; +class PacketView; class WellenreiterConfigWindow; class MLogWindow; -class MHexWindow; class GPS; class Wellenreiter : public WellenreiterBase { Q_OBJECT public: Wellenreiter( QWidget* parent = 0 ); ~Wellenreiter(); void setConfigWindow( WellenreiterConfigWindow* cw ); MScanListView* netView() const { return netview; }; MLogWindow* logWindow() const { return logwindow; }; - MHexWindow* hexWindow() const { return hexwindow; }; + PacketView* hexWindow() const { return hexwindow; }; bool isDaemonRunning() const { return sniffing; }; QString captureFileName() const { return dumpname; }; public: bool sniffing; protected: virtual void timerEvent( QTimerEvent* ); public slots: void initialTimer(); void channelHopped(int); void receivePacket(OPacket*); void startClicked(); void stopClicked(); void joinNetwork(const QString&,const QString&,int,const QString&); signals: void startedSniffing(); void stoppedSniffing(); private: void handleManagementFrame( OPacket* p, OWaveLanManagementPacket* ); void handleManagementFrameBeacon( OPacket* p, OWaveLanManagementPacket* ); void handleManagementFrameProbeRequest( OPacket* p, OWaveLanManagementPacket* ); void handleManagementFrameProbeResponse( OPacket* p, OWaveLanManagementPacket* ); void handleControlFrame( OPacket* p, OWaveLanControlPacket* control ); void handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to ); void handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to ); void handleARPData( OPacket* p, OARPPacket* arp, OMacAddress& from, OMacAddress& to ); void handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& from, OMacAddress& to ); void handleNotification( OPacket* p ); void doAction( const QString& action, const QString& protocol, OPacket* p ); QObject* childIfToParse( OPacket* p, const QString& protocol ); bool checkDumpPacket( OPacket* p ); private: #ifdef QWS OSystem _system; // Opie Operating System identifier #endif QString dumpname; OWirelessNetworkInterface* iface; OPacketCapturer* pcap; WellenreiterConfigWindow* configwindow; GPS* gps; //void readConfig(); //void writeConfig(); }; #endif diff --git a/noncore/net/wellenreiter/gui/wellenreiterbase.cpp b/noncore/net/wellenreiter/gui/wellenreiterbase.cpp index f57dba2..3d0595d 100644 --- a/noncore/net/wellenreiter/gui/wellenreiterbase.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiterbase.cpp @@ -1,177 +1,177 @@ /********************************************************************** ** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved. ** ** This file is part of Wellenreiter II. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ***********************************************************************/ #include "wellenreiterbase.h" #include <qlabel.h> #include <qlayout.h> #include "logwindow.h" -#include "hexwindow.h" +#include "packetview.h" #include "scanlist.h" #include "statwindow.h" #include "graphwindow.h" #ifdef QWS #include <qpe/resource.h> #include <opie2/otabwidget.h> using namespace Opie; #else #include "resource.h" #include <qtabwidget.h> #endif /* * Constructs a WellenreiterBase which is a child of 'parent', with the - * name 'name' and widget flags set to 'f' + * name 'name' and widget flags set to 'f' */ WellenreiterBase::WellenreiterBase( QWidget* parent, const char* name, WFlags fl ) : QWidget( parent, name, fl ) { //ani1 = new QPixmap( Resource::loadPixmap( "wellenreiter/networks_rot0" ) ); //ani2 = new QPixmap( Resource::loadPixmap( "wellenreiter/networks_rot90" ) ); //ani3 = new QPixmap( Resource::loadPixmap( "wellenreiter/networks_rot180" ) ); //ani4 = new QPixmap( Resource::loadPixmap( "wellenreiter/networks_rot270" ) ); - + if ( !name ) setName( "WellenreiterBase" ); resize( 191, 294 ); #ifdef QWS setCaption( tr( "Wellenreiter/Opie" ) ); #else setCaption( tr( "Wellenreiter/X11" ) ); #endif WellenreiterBaseLayout = new QVBoxLayout( this ); WellenreiterBaseLayout->setSpacing( 2 ); WellenreiterBaseLayout->setMargin( 0 ); #ifdef QWS TabWidget = new OTabWidget( this, "TabWidget", OTabWidget::Global ); #else TabWidget = new QTabWidget( this, "TabWidget" ); #endif ap = new QWidget( TabWidget, "ap" ); apLayout = new QVBoxLayout( ap ); apLayout->setSpacing( 2 ); apLayout->setMargin( 2 ); //--------- NETVIEW TAB -------------- netview = new MScanListView( ap ); apLayout->addWidget( netview ); //--------- GRAPH TAB -------------- graphwindow = new MGraphWindow( TabWidget, "Graph" ); //--------- LOG TAB -------------- logwindow = new MLogWindow( TabWidget, "Log" ); //--------- HEX TAB -------------- - hexwindow = new MHexWindow( TabWidget, "Hex" ); + hexwindow = new PacketView( TabWidget, "Hex" ); //--------- STAT TAB -------------- statwindow = new MStatWindow( TabWidget, "Stat" ); //--------- ABOUT TAB -------------- about = new QWidget( TabWidget, "about" ); aboutLayout = new QGridLayout( about ); aboutLayout->setSpacing( 6 ); aboutLayout->setMargin( 11 ); PixmapLabel1_3_2 = new QLabel( about, "PixmapLabel1_3_2" ); PixmapLabel1_3_2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, PixmapLabel1_3_2->sizePolicy().hasHeightForWidth() ) ); PixmapLabel1_3_2->setFrameShape( QLabel::Panel ); PixmapLabel1_3_2->setFrameShadow( QLabel::Sunken ); PixmapLabel1_3_2->setLineWidth( 2 ); PixmapLabel1_3_2->setMargin( 0 ); PixmapLabel1_3_2->setMidLineWidth( 0 ); PixmapLabel1_3_2->setPixmap( Resource::loadPixmap( "wellenreiter/logo" ) ); PixmapLabel1_3_2->setScaledContents( TRUE ); PixmapLabel1_3_2->setAlignment( int( QLabel::AlignCenter ) ); aboutLayout->addWidget( PixmapLabel1_3_2, 0, 0 ); TextLabel1_4_2 = new QLabel( about, "TextLabel1_4_2" ); QFont TextLabel1_4_2_font( TextLabel1_4_2->font() ); TextLabel1_4_2_font.setFamily( "adobe-helvetica" ); TextLabel1_4_2_font.setPointSize( 10 ); TextLabel1_4_2->setFont( TextLabel1_4_2_font ); TextLabel1_4_2->setText( tr( "<p align=center>\n" "<hr>\n" "Michael 'Mickey' Lauer<br><hr>\n" "Max Moser<br>\n" "Martin J. Muench<br>\n" "<b>www.wellenreiter.net</b>\n" "</p>" ) ); TextLabel1_4_2->setAlignment( int( QLabel::AlignCenter ) ); aboutLayout->addWidget( TextLabel1_4_2, 1, 0 ); #ifdef QWS TabWidget->addTab( ap, "wellenreiter/networks", tr( "Nets" ) ); TabWidget->addTab( graphwindow, "wellenreiter/graph", tr( "Graph" ) ); TabWidget->addTab( logwindow, "wellenreiter/log", tr( "Log" ) ); TabWidget->addTab( hexwindow, "wellenreiter/hex", tr( "Hex" ) ); TabWidget->addTab( statwindow, "wellenreiter/stat", tr( "Stat" ) ); TabWidget->addTab( about, "wellenreiter/about", tr( "About" ) ); #else TabWidget->addTab( ap, /* "wellenreiter/networks", */ tr( "Networks" ) ); TabWidget->addTab( graphwindow, /* "wellenreiter/graph", */ tr( "Graph" ) ); TabWidget->addTab( logwindow, /* "wellenreiter/log", */ tr( "Log" ) ); TabWidget->addTab( hexwindow, /* "wellenreiter/hex", */ tr( "Hex" ) ); TabWidget->addTab( statwindow, /* "wellenreiter/hex", */ tr( "Stat" ) ); TabWidget->addTab( about, /* "wellenreiter/about", */ tr( "About" ) ); #endif WellenreiterBaseLayout->addWidget( TabWidget ); #ifdef QWS TabWidget->setCurrentTab( tr( "Nets" ) ); #endif } /* * Destroys the object and frees any allocated resources */ WellenreiterBase::~WellenreiterBase() { // no need to delete child widgets, Qt does it all for us } -/* +/* * Main event handler. Reimplemented to handle application * font changes */ bool WellenreiterBase::event( QEvent* ev ) { - bool ret = QWidget::event( ev ); + bool ret = QWidget::event( ev ); if ( ev->type() == QEvent::ApplicationFontChange ) { //QFont Log_2_font( Log_2->font() ); //Log_2_font.setFamily( "adobe-courier" ); //Log_2_font.setPointSize( 8 ); - //Log_2->setFont( Log_2_font ); + //Log_2->setFont( Log_2_font ); QFont TextLabel1_4_2_font( TextLabel1_4_2->font() ); TextLabel1_4_2_font.setFamily( "adobe-helvetica" ); TextLabel1_4_2_font.setPointSize( 10 ); TextLabel1_4_2->setFont( TextLabel1_4_2_font ); } return ret; } diff --git a/noncore/net/wellenreiter/gui/wellenreiterbase.h b/noncore/net/wellenreiter/gui/wellenreiterbase.h index 5e00ddc..126aad2 100644 --- a/noncore/net/wellenreiter/gui/wellenreiterbase.h +++ b/noncore/net/wellenreiter/gui/wellenreiterbase.h @@ -1,77 +1,77 @@ /********************************************************************** ** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved. ** ** This file is part of Wellenreiter II. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** **********************************************************************/ #ifndef WELLENREITERBASE_H #define WELLENREITERBASE_H #include <qvariant.h> #include <qwidget.h> class QVBoxLayout; class QHBoxLayout; class QGridLayout; class QLabel; class MScanListView; class MScanListItem; class QPushButton; class MLogWindow; -class MHexWindow; class MStatWindow; class MGraphWindow; +class PacketView; #ifdef QWS #include <opie2/otabwidget.h> using namespace Opie; #else class QTabWidget; #endif class WellenreiterBase : public QWidget { Q_OBJECT public: WellenreiterBase( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); ~WellenreiterBase(); #ifdef QWS OTabWidget* TabWidget; #else QTabWidget* TabWidget; #endif QWidget* ap; MScanListView* netview; MLogWindow* logwindow; - MHexWindow* hexwindow; + PacketView* hexwindow; MStatWindow* statwindow; MGraphWindow* graphwindow; QWidget* about; QLabel* PixmapLabel1_3_2; QLabel* TextLabel1_4_2; protected: QVBoxLayout* WellenreiterBaseLayout; QVBoxLayout* apLayout; QGridLayout* aboutLayout; bool event( QEvent* ); QPixmap* ani1; QPixmap* ani2; QPixmap* ani3; QPixmap* ani4; }; #endif // WELLENREITERBASE_H |