36 files changed, 158 insertions, 111 deletions
diff --git a/libopie2/examples/opiecore/odebugdemo/odebugdemo.cpp b/libopie2/examples/opiecore/odebugdemo/odebugdemo.cpp index 74886fa..e8bf04f 100644 --- a/libopie2/examples/opiecore/odebugdemo/odebugdemo.cpp +++ b/libopie2/examples/opiecore/odebugdemo/odebugdemo.cpp @@ -1,138 +1,140 @@ /* QT */ #include <qvbox.h> #include <qhbox.h> #include <qvbuttongroup.h> #include <qhbuttongroup.h> #include <qlineedit.h> #include <qradiobutton.h> #include <qpushbutton.h> /* OPIE */ #include <qpe/config.h> #include <opie2/odebug.h> #include <opie2/oapplication.h> #include <opie2/oglobal.h> #include <opie2/oglobalsettings.h> class DemoApp : public OApplication { Q_OBJECT public: DemoApp( int argc, char** argv ) : OApplication( argc, argv, "libopie2 debug demo" ) { // you have access to your OApplication object via oApp qDebug( "Process-wide OApplication object @ %0x", oApp ); // you have access to global settings via OGlobalSettings int mode = OGlobalSettings::debugMode(); QVBox* vbox = new QVBox(); setMainWidget( vbox ); g = new QVButtonGroup( "Output Strategy", vbox ); QRadioButton* r0 = new QRadioButton( "file", g ); QRadioButton* r1 = new QRadioButton( "messagebox", g ); QRadioButton* r2 = new QRadioButton( "stderr", g ); QRadioButton* r3 = new QRadioButton( "syslog", g ); QRadioButton* r4 = new QRadioButton( "socket", g ); g->insert( r0, 0 ); g->insert( r1, 1 ); g->insert( r2, 2 ); g->insert( r3, 3 ); g->insert( r4, 4 ); g->setRadioButtonExclusive( true ); connect( g, SIGNAL( clicked(int) ), this, SLOT( chooseMethod(int) ) ); if ( mode != -1 ) g->setButton( mode ); QHButtonGroup* hbox = new QHButtonGroup( "Extra Output Information", vbox ); e = new QLineEdit( hbox ); QPushButton* pb = new QPushButton( hbox ); connect( e, SIGNAL( returnPressed() ), this, SLOT( updateDebugOutput() ) ); connect( pb, SIGNAL( clicked() ), this, SLOT( updateDebugOutput() ) ); // show the additional debug mode dependent output information e->setText( OGlobalSettings::debugOutput() ); // buttos QPushButton* info = new QPushButton( "Emit Debug(Info) Output!", vbox ); connect( info, SIGNAL( clicked() ), this, SLOT( emitInfoOutput() ) ); QPushButton* warn = new QPushButton( "Emit a Warning Output!", vbox ); connect( warn, SIGNAL( clicked() ), this, SLOT( emitWarningOutput() ) ); QPushButton* error = new QPushButton( "Emit an Error Output!", vbox ); connect( error, SIGNAL( clicked() ), this, SLOT( emitErrorOutput() ) ); QPushButton* fatal = new QPushButton( "Emit a Fatal Output!", vbox ); connect( fatal, SIGNAL( clicked() ), this, SLOT( emitFatalOutput() ) ); QPushButton* tb = new QPushButton( "Emit a Fatal Backtrace!", vbox ); connect( tb, SIGNAL( clicked() ), this, SLOT( emitTBOutput() ) ); info->show(); warn->show(); error->show(); fatal->show(); tb->show(); g->show(); hbox->show(); e->show(); vbox->show(); showMainWidget( vbox ); } public slots: void chooseMethod(int method) { m = method; qDebug( "choosing method: %d", method ); OConfig* g = OGlobal::config(); g->setGroup( "General" ); g->writeEntry( "debugMode", m ); e->setText( OGlobalSettings::debugOutput() ); + g->write(); } void updateDebugOutput() { OConfig* g = OGlobal::config(); g->setGroup( "General" ); g->writeEntry( "debugOutput"+QString::number(OGlobalSettings::debugMode()), e->text() ); + g->write(); } void emitInfoOutput() { odebug << "This is a debug message" << oendl; } void emitWarningOutput() { owarn << "This is a warning message" << oendl; } void emitErrorOutput() { oerr << "This is an errror message" << oendl; } void emitFatalOutput() { ofatal << "This is a fatal message" << oendl; } void emitTBOutput() { ofatal << "This is a fatal message + backtrace\n" + odBacktrace(); // odBacktrace includes \n } private: QButtonGroup* g; int m; QLineEdit* e; }; int main( int argc, char** argv ) { DemoApp* app = new DemoApp( argc, argv ); app->exec(); return 0; } #include "moc/odebugdemo.moc" diff --git a/libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.cpp b/libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.cpp index c49daa0..eb2e8e8 100644 --- a/libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.cpp +++ b/libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.cpp @@ -1,217 +1,232 @@ #include <qdict.h> #include <qsocketnotifier.h> #include <qstring.h> #include <opie2/onetwork.h> #include <qapplication.h> #include <opie2/opcap.h> #include <cerrno> #include <cstdio> #include <cstdlib> #include <cstring> //======================== Station help class =============================== class Station { public: Station( QString t, int c, bool w ) : type(t), channel(c), wep(w), beacons(1) {}; ~Station() {}; QString type; int channel; bool wep; int beacons; }; QDict<Station> stations; //======================== Application class =============================== class Wellenreiter : public QApplication { Q_OBJECT public: - Wellenreiter( int argc, char** argv ) : QApplication( argc, argv ) + Wellenreiter( int argc, char** argv ) : QApplication( argc, argv ), channel( 1 ) { ONetwork* net = ONetwork::instance(); if ( argc < 3 ) { printf( "Usage: ./%s <interface> <driver> <interval>\n", argv[0] ); printf( "\n" ); printf( "Valid wireless interfaces (detected) are:\n" ); ONetwork::InterfaceIterator it = net->iterator(); while ( it.current() ) { if ( it.current()->isWireless() ) { printf( " - '%s' (MAC=%s) (IPv4=%s)\n", (const char*) it.current()->name(), (const char*) it.current()->macAddress().toString(), (const char*) it.current()->ipV4Address() ); } ++it; } exit( -1 ); } - printf( "****************************************************\n" ); - printf( "* Wellenreiter mini edition 1.0 (C) 2003 M-M-M *\n" ); - printf( "****************************************************\n" ); + printf( "*******************************************************************\n" ); + printf( "* Wellenreiter mini edition 1.0.0 (C) 2003 Michael 'Mickey' Lauer *\n" ); + printf( "*******************************************************************\n" ); printf( "\n\n" ); QString interface( argv[1] ); QString driver( argv[2] ); printf( "Trying to use '%s' as %s-controlled device...\n", (const char*) interface, (const char*) driver ); // sanity checks before downcasting ONetworkInterface* iface = net->interface( interface ); if ( !iface ) { printf( "Interface '%s' doesn't exist. Exiting.\n", (const char*) interface ); exit( -1 ); } if ( !iface->isWireless() ) { printf( "Interface '%s' doesn't support wireless extensions. Exiting.\n", (const char*) interface ); exit( -1 ); } // downcast should be safe now wiface = (OWirelessNetworkInterface*) iface; printf( "Using wireless interface '%s' for scanning (current SSID is '%s')...\n", (const char*) interface, (const char*) wiface->SSID() ); // ifconfig +promisc the interface to receive all packets if ( !wiface->promiscuousMode() ) { printf( "Interface status is not promisc... switching to promisc... " ); wiface->setPromiscuousMode( true ); if ( !wiface->promiscuousMode() ) { printf( "failed (%s). Exiting.\n", strerror( errno ) ); exit( -1 ); } else { printf( "ok.\n" ); } } else printf( "Interface status is already promisc - good.\n" ); // connect a monitoring strategy to the interface if ( driver == "orinoco" ) new OOrinocoMonitoringInterface( wiface, false ); else + if ( driver == "hostap" ) + new OHostAPMonitoringInterface( wiface, false ); + else + if ( driver == "wlan-ng" ) + new OWlanNGMonitoringInterface( wiface, false ); + else { printf( "Unknown driver. Exiting\n" ); exit( -1 ); } // enable monitoring mode printf( "Enabling monitor mode...\n" ); - //wiface->setMonitorMode( true ); + wiface->setMode( "monitor" ); // open a packet capturer cap = new OPacketCapturer(); cap->open( interface ); if ( !cap->isOpen() ) { printf( "Unable to open libpcap (%s). Exiting.\n", strerror( errno ) ); exit( -1 ); } // set capturer to non-blocking mode cap->setBlocking( false ); // start channel hopper //wiface->setChannelHopping( 1000 ); // connect connect( cap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); + // timer + startTimer( 1000 ); } ~Wellenreiter() {}; public slots: + virtual void timerEvent(QTimerEvent* e) + { + wiface->setChannel( channel++ ); + if ( channel == 14 ) channel = 1; + } + void receivePacket(OPacket* p) { if (!p) { printf( "(empty packet received)\n" ); return; } OWaveLanManagementPacket* beacon = (OWaveLanManagementPacket*) p->child( "802.11 Management" ); if ( beacon ) { OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); QString essid = ssid ? ssid->ID() : "<unknown>"; if ( stations.find( essid ) ) stations[essid]->beacons++; else { printf( "found new network @ channel %d, SSID = '%s'\n", wiface->channel(), (const char*) essid ); stations.insert( essid, new Station( "unknown", wiface->channel(), ((OWaveLanPacket*) beacon->parent())->usesWep() ) ); } return; } OWaveLanDataPacket* data = (OWaveLanDataPacket*) p->child( "802.11 Data" ); if ( data ) { OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); if ( wlan->fromDS() && !wlan->toDS() ) { printf( "FromDS: '%s' -> '%s' via '%s'\n", (const char*) wlan->macAddress3().toString(true), (const char*) wlan->macAddress1().toString(true), (const char*) wlan->macAddress2().toString(true) ); } else if ( !wlan->fromDS() && wlan->toDS() ) { printf( "ToDS: '%s' -> '%s' via '%s'\n", (const char*) wlan->macAddress2().toString(true), (const char*) wlan->macAddress3().toString(true), (const char*) wlan->macAddress1().toString(true) ); } else if ( wlan->fromDS() && wlan->toDS() ) { printf( "WSD(bridge): '%s' -> '%s' via '%s' and '%s'\n", (const char*) wlan->macAddress4().toString(true), (const char*) wlan->macAddress3().toString(true), (const char*) wlan->macAddress1().toString(true), (const char*) wlan->macAddress2().toString(true) ); } else { printf( "IBSS(AdHoc): '%s' -> '%s' (Cell: '%s')'\n", (const char*) wlan->macAddress2().toString(true), (const char*) wlan->macAddress1().toString(true), (const char*) wlan->macAddress3().toString(true) ); } return; } } private: OPacketCapturer* cap; OWirelessNetworkInterface* wiface; + int channel; }; int main( int argc, char** argv ) { Wellenreiter w( argc, argv ); w.exec(); return 0; } #include "miniwellenreiter.moc" diff --git a/libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.pro b/libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.pro index 7ce535c..b2c5c14 100644 --- a/libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.pro +++ b/libopie2/examples/opienet/miniwellenreiter/miniwellenreiter.pro diff --git a/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp b/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp index 06b8b19..4763316 100644 --- a/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp +++ b/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp @@ -1,142 +1,143 @@ #include <opie2/onetwork.h> #include <opie2/ostation.h> #include <opie2/omanufacturerdb.h> #include <unistd.h> int main( int argc, char** argv ) { qDebug( "OPIE Network Demo" ); ONetwork* net = ONetwork::instance(); ONetwork::InterfaceIterator it = net->iterator(); while ( it.current() ) { qDebug( "DEMO: ONetwork contains Interface '%s'", (const char*) it.current()->name() ); qDebug( "DEMO: Datalink code is '%d'", it.current()->dataLinkType() ); qDebug( "DEMO: MAC Address is '%s'", (const char*) it.current()->macAddress().toString() ); qDebug( "DEMO: MAC Address is '%s'", (const char*) it.current()->macAddress().toString(true) ); qDebug( "DEMO: MAC Manufacturer seems to be '%s'", (const char*) it.current()->macAddress().manufacturer() ); qDebug( "DEMO: Manufacturertest1 = '%s'", (const char*) OManufacturerDB::instance()->lookupExt( "08:00:87" ) ); qDebug( "DEMO: Manufacturertest2 = '%s'", (const char*) OManufacturerDB::instance()->lookupExt( "E2:0C:0F" ) ); qDebug( "Demo: IPv4 Address is '%s'", (const char*) it.current()->ipV4Address() ); if ( it.current()->isWireless() ) { OWirelessNetworkInterface* iface = static_cast<OWirelessNetworkInterface*>( it.current() ); qDebug( "DEMO: '%s' seems to feature the wireless extensions.", (const char*) iface->name() ); qDebug( "DEMO: Current SSID is '%s'", (const char*) iface->SSID() ); qDebug( "DEMO: Antenna is tuned to '%f', that is channel %d", iface->frequency(), iface->channel() ); //if ( iface->mode() == OWirelessNetworkInterface::adhoc ) //{ //qDebug( "DEMO: Associated AP has MAC Address '%s'", (const char*) iface->associatedAP().toString() ); //} /* // nickname qDebug( "DEMO: Current NickName is '%s'", (const char*) iface->nickName() ); iface->setNickName( "MyNickName" ); if ( iface->nickName() != "MyNickName" ) qDebug( "DEMO: Warning! Can't change nickname" ); else qDebug( "DEMO: Nickname change successful." ); /* // operation mode qDebug( "DEMO: Current OperationMode is '%s'", (const char*) iface->mode() ); iface->setMode( "adhoc" ); if ( iface->mode() != "adhoc" ) qDebug( "DEMO: Warning! Can't change operation mode" ); else qDebug( "DEMO: Operation Mode change successful." ); // RF channel qDebug( "DEMO: Current Channel is '%d'", iface->channel() ); iface->setChannel( 1 ); if ( iface->channel() != 1 ) qDebug( "DEMO: Warning! Can't change RF channel" ); else qDebug( "DEMO: RF channel change successful." ); iface->setMode( "managed" ); */ /* // network scan OStationList* stations = iface->scanNetwork(); if ( stations ) { qDebug( "DEMO: # of stations around = %d", stations->count() ); OStation* station; for ( station = stations->first(); station != 0; station = stations->next() ) { qDebug( "DEMO: station dump following..." ); station->dump(); } } else { qDebug( "DEMO: Warning! Scan didn't work!" ); } /* // first some wrong calls to check if this is working iface->setPrivate( "seppel", 10 ); iface->setPrivate( "monitor", 0 ); // now the real deal iface->setPrivate( "monitor", 2, 2, 3 ); // trying to set hw address to 12:34:56:AB:CD:EF /* OMacAddress addr = OMacAddress::fromString( "12:34:56:AB:CD:EF" ); iface->setUp( false ); iface->setMacAddress( addr ); iface->setUp( true ); qDebug( "DEMO: MAC Address now is '%s'", (const char*) iface->macAddress().toString() ); */ // monitor test - /* + qDebug( "DEMO: current interface mode is '%s'", (const char*) iface->mode() ); iface->setMode( "monitor" ); qDebug( "DEMO: current interface mode is '%s'", (const char*) iface->mode() ); - sleep( 1 ); */ + sleep( 1 ); - iface->setMode( "master" ); + iface->setChannel( 1 ); + iface->setMode( "managed" ); //sleep( 1 ); qDebug( "DEMO: current interface mode is '%s'", (const char*) iface->mode() ); /*iface->setMode( "adhoc" ); sleep( 1 ); qDebug( "DEMO: current interface mode is '%s'", (const char*) iface->mode() ); iface->setMode( "managed" ); sleep( 1 ); qDebug( "DEMO: current interface mode is '%s'", (const char*) iface->mode() ); iface->setMode( "master" ); sleep( 1 ); qDebug( "DEMO: current interface mode is '%s'", (const char*) iface->mode() );*/ } ++it; } return 0; } diff --git a/libopie2/libopie2.control b/libopie2/libopie2.control index 6e11cbf..f54efd8 100644 --- a/libopie2/libopie2.control +++ b/libopie2/libopie2.control @@ -1,11 +1,11 @@ Package: libopie2 Files: Priority: optional Section: opie/system Maintainer: Opie Team <opie@handhelds.org> Architecture: arm -Version: 1.8.1-$SUB_VERSION.2 -Depends: libopiecore2 (1.8.1), libopiedb2 (1.8.1), libopiemm2 (1.8.1), libopienet2 (1.8.1), libopiepim2 (1.8.1), libopieui2 (1.8.1) +Version: 1.8.2-$SUB_VERSION.2 +Depends: libopiecore2 (1.8.2), libopiedb2 (1.8.2), libopiemm2 (1.8.2), libopienet2 (1.8.2), libopiepim2 (1.8.2), libopieui2 (1.8.2) Provides: libopie2 Description: Opie library 2.0 diff --git a/libopie2/opiecore/libopiecore2.control b/libopie2/opiecore/libopiecore2.control index 7dec1b9..956d24f 100644 --- a/libopie2/opiecore/libopiecore2.control +++ b/libopie2/opiecore/libopiecore2.control @@ -1,11 +1,11 @@ Package: libopiecore2 Files: $OPIEDIR/lib/libopiecore2.so.* Priority: optional Section: opie/system Maintainer: Opie Team <opie@handhelds.org> Architecture: arm -Version: 1.8.1-$SUB_VERSION.2 +Version: 1.8.2-$SUB_VERSION.2 Depends: libqpe1 Provides: libopiecore2 Description: Opie library 2.0 CORE diff --git a/libopie2/opiecore/oconfig.cpp b/libopie2/opiecore/oconfig.cpp index dc4d0b3..fb5eabb 100644 --- a/libopie2/opiecore/oconfig.cpp +++ b/libopie2/opiecore/oconfig.cpp @@ -1,201 +1,203 @@ /* This file is part of the Opie Project (C) 2003 Michael Lauer <mickey@tm.informatik.uni-frankfurt.de> Inspired by the config classes from the KDE Project which are =. (C) 1997 Matthias Kalle Dalheimer <kalle@kde.org> .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* QT */ #include <qfont.h> #include <qcolor.h> /* OPIE */ #include <opie2/oconfig.h> OConfig::OConfig( const QString &name, Domain domain ) - :OpieConfig( name, domain ) + :Config( name, domain ) { + qDebug( "OConfig::OConfig()" ); } OConfig::~OConfig() { + qDebug( "OConfig::~OConfig()" ); } QColor OConfig::readColorEntry( const QString& key, const QColor* pDefault ) const { QColor aRetColor; int nRed = 0, nGreen = 0, nBlue = 0; QString aValue = readEntry( key ); if( !aValue.isEmpty() ) { if ( aValue.at(0) == '#' ) { aRetColor.setNamedColor(aValue); } else { bool bOK; // find first part (red) int nIndex = aValue.find( ',' ); if( nIndex == -1 ) { // return a sensible default -- Bernd if( pDefault ) aRetColor = *pDefault; return aRetColor; } nRed = aValue.left( nIndex ).toInt( &bOK ); // find second part (green) int nOldIndex = nIndex; nIndex = aValue.find( ',', nOldIndex+1 ); if( nIndex == -1 ) { // return a sensible default -- Bernd if( pDefault ) aRetColor = *pDefault; return aRetColor; } nGreen = aValue.mid( nOldIndex+1, nIndex-nOldIndex-1 ).toInt( &bOK ); // find third part (blue) nBlue = aValue.right( aValue.length()-nIndex-1 ).toInt( &bOK ); aRetColor.setRgb( nRed, nGreen, nBlue ); } } else { if( pDefault ) aRetColor = *pDefault; } return aRetColor; } // FIXME: The whole font handling has to be revised for Opie QFont OConfig::readFontEntry( const QString& key, const QFont* pDefault ) const { /* QFont aRetFont; QString aValue = readEntry( key ); if( !aValue.isNull() ) { if ( aValue.contains( ',' ) > 5 ) { // KDE3 and upwards entry if ( !aRetFont.fromString( aValue ) && pDefault ) aRetFont = *pDefault; } else { // backward compatibility with older font formats // ### remove KDE 3.1 ? // find first part (font family) int nIndex = aValue.find( ',' ); if( nIndex == -1 ){ if( pDefault ) aRetFont = *pDefault; return aRetFont; } aRetFont.setFamily( aValue.left( nIndex ) ); // find second part (point size) int nOldIndex = nIndex; nIndex = aValue.find( ',', nOldIndex+1 ); if( nIndex == -1 ){ if( pDefault ) aRetFont = *pDefault; return aRetFont; } aRetFont.setPointSize( aValue.mid( nOldIndex+1, nIndex-nOldIndex-1 ).toInt() ); // find third part (style hint) nOldIndex = nIndex; nIndex = aValue.find( ',', nOldIndex+1 ); if( nIndex == -1 ){ if( pDefault ) aRetFont = *pDefault; return aRetFont; } aRetFont.setStyleHint( (QFont::StyleHint)aValue.mid( nOldIndex+1, nIndex-nOldIndex-1 ).toUInt() ); // find fourth part (char set) nOldIndex = nIndex; nIndex = aValue.find( ',', nOldIndex+1 ); if( nIndex == -1 ){ if( pDefault ) aRetFont = *pDefault; return aRetFont; } QString chStr=aValue.mid( nOldIndex+1, nIndex-nOldIndex-1 ); // find fifth part (weight) nOldIndex = nIndex; nIndex = aValue.find( ',', nOldIndex+1 ); if( nIndex == -1 ){ if( pDefault ) aRetFont = *pDefault; return aRetFont; } aRetFont.setWeight( aValue.mid( nOldIndex+1, nIndex-nOldIndex-1 ).toUInt() ); // find sixth part (font bits) uint nFontBits = aValue.right( aValue.length()-nIndex-1 ).toUInt(); aRetFont.setItalic( nFontBits & 0x01 ); aRetFont.setUnderline( nFontBits & 0x02 ); aRetFont.setStrikeOut( nFontBits & 0x04 ); aRetFont.setFixedPitch( nFontBits & 0x08 ); aRetFont.setRawMode( nFontBits & 0x20 ); } } else { if( pDefault ) aRetFont = *pDefault; } return aRetFont; */ return QFont("Helvetica",10); } diff --git a/libopie2/opiecore/oconfig.h b/libopie2/opiecore/oconfig.h index 75aa170..444d280 100644 --- a/libopie2/opiecore/oconfig.h +++ b/libopie2/opiecore/oconfig.h @@ -1,140 +1,140 @@ /* This file is part of the Opie Project (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> Inspired by the config classes from the KDE Project which are =. (C) 1997 Matthias Kalle Dalheimer <kalle@kde.org> .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef OCONFIG_H #define OCONFIG_H //FIXME: Implement for X11 or reuse libqpe/Config there also? //FIXME: Or rather use QSettings also for libqpe? -#include "opieconfig.h" +#include <qpe/config.h> class QColor; class QFont; /** * A Configuration class based on the Qtopia @ref Config class * featuring additional handling of color and font entries */ -class OConfig : public OpieConfig +class OConfig : public Config { public: /** * Constructs a OConfig object with a @a name. */ OConfig( const QString &name, Domain domain = User ); /** * Destructs the OConfig object. * * Writes back any dirty configuration entries, and destroys * dynamically created objects. */ virtual ~OConfig(); /** * @returns the name of the current group. * The current group is used for searching keys and accessing entries. */ - const QString& group() { return OpieConfig::group(); }; + const QString& group() { return git.key(); }; /** * @returns a @ref QColor entry or a @a default value if the key is not found. */ QColor readColorEntry( const QString& key, const QColor* pDefault ) const; /** * @returns a @ref QFont value or a @a default value if the key is not found. */ QFont readFontEntry( const QString& key, const QFont* pDefault ) const; }; /** * @brief Helper class for easier use of OConfig groups. * * Careful programmers always set the group of a * @ref OConfig object to the group they want to read from * and set it back to the old one of afterwards. This is usually * written as: * <pre> * * QString oldgroup config()->group(); * config()->setGroup( "TheGroupThatIWant" ); * ... * config()->writeEntry( "Blah", "Blubb" ); * * config()->setGroup( oldgroup ); * </pre> * * In order to facilitate this task, you can use * OConfigGroupSaver. Simply construct such an object ON THE STACK * when you want to switch to a new group. Then, when the object goes * out of scope, the group will automatically be restored. If you * want to use several different groups within a function or method, * you can still use OConfigGroupSaver: Simply enclose all work with * one group (including the creation of the OConfigGroupSaver object) * in one block. * * @author Matthias Kalle Dalheimer <Kalle@kde.org> * @version $Id$ * @see OConfig */ class OConfigGroupSaver { public: /** * Constructor. * Create the object giving a @config object and a @a group to become * the current group. */ OConfigGroupSaver( OConfig* config, QString group ) :_config(config), _oldgroup(config->group() ) { _config->setGroup( group ); } OConfigGroupSaver( OConfig* config, const char *group ) :_config(config), _oldgroup(config->group()) { _config->setGroup( group ); } OConfigGroupSaver( OConfig* config, const QCString &group ) : _config(config), _oldgroup(config->group()) { _config->setGroup( group ); } /** * Destructor. * Restores the last current group. */ ~OConfigGroupSaver() { _config->setGroup( _oldgroup ); } OConfig* config() { return _config; }; private: OConfig* _config; QString _oldgroup; OConfigGroupSaver( const OConfigGroupSaver& ); OConfigGroupSaver& operator=( const OConfigGroupSaver& ); }; #endif // OCONFIG_H diff --git a/libopie2/opiecore/odebug.cpp b/libopie2/opiecore/odebug.cpp index b2a37bc..4505ce7 100644 --- a/libopie2/opiecore/odebug.cpp +++ b/libopie2/opiecore/odebug.cpp @@ -1,632 +1,631 @@ /* This file is part of the Opie Project (C) 2003 Michael 'Mickey' Lauer (mickey@tm.informatik.uni-frankfurt.de) - Inspired by the KDE debug classes, which are - (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org) (C) 2002 Holger Freyther (freyther@kde.org) + (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org) =. .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Include this header without OPIE_NO_DEBUG defined to avoid having the oDebugInfo // functions inlined to noops (which would then conflict with their definition here). #include <opie2/odebug.h> #ifdef OPIE_NO_DEBUG #undef odDebug #undef odBacktrace #endif /* OPIE */ #include <opie2/oapplication.h> #include <opie2/oglobalsettings.h> #include <opie2/oconfig.h> /* QT */ #include <qbrush.h> #include <qdatetime.h> #include <qfile.h> #include <qhostaddress.h> #include <qmessagebox.h> #include <qintdict.h> #include <qpoint.h> #include <qrect.h> #include <qregion.h> #include <qsize.h> #include <qsocketdevice.h> #include <qstring.h> #include <qstringlist.h> #include <qtextstream.h> /* UNIX */ #include <stdlib.h> // abort #include <unistd.h> // getpid #include <stdarg.h> // vararg stuff #include <ctype.h> // isprint #include <syslog.h> #include <errno.h> #include <string.h> #ifndef OPIE_NO_BACKTRACE #include <execinfo.h> #endif /*====================================================================================== * debug levels *======================================================================================*/ enum DebugLevels { ODEBUG_INFO = 0, ODEBUG_WARN = 1, ODEBUG_ERROR = 2, ODEBUG_FATAL = 3 }; /*====================================================================================== * oDebug private data *======================================================================================*/ /*====================================================================================== * the main debug function *======================================================================================*/ static void oDebugBackend( unsigned short level, unsigned int area, const char *data) { //qDebug( "oDebugBackend: Level=%d, Area=%d, Data=%s", level, area, data ); // ML: OPIE doesn't use areacodes at the moment. See the KDE debug classes for an // ML: example use. I think it's not necessary to implement such a strategy here. // ML: Comments? int priority = 0; QString caption; QString lev; switch( level ) { case ODEBUG_INFO: lev = "(Info)"; caption = "Info"; priority = LOG_INFO; break; case ODEBUG_WARN: lev = "(Warn)"; caption = "Warning"; priority = LOG_WARNING; break; case ODEBUG_FATAL: lev = "(Fatal)"; caption = "Fatal Error"; priority = LOG_CRIT; break; default: qDebug( "oDebugBackend: Warning: Unknown debug level! - defaulting to ODEBUG_ERROR." ); case ODEBUG_ERROR: lev = "(Error)"; caption = "Error"; priority = LOG_ERR; break; } short output = OGlobalSettings::debugMode(); if (!oApp && (output == 1)) { qDebug( "oDebugBackend: Warning: no oapplication object - can't use MsgBox" ); output = 2; // need an application object to use MsgBox } // gcc 2.9x is dumb and sucks... can you hear it? //QString areaName = (oApp) ? oApp->appName() : "<unknown>"; QString areaName; if ( oApp ) areaName = oApp->appName(); else areaName = "<unknown>"; // Output switch( output ) { case -1: // ignore { return; } case 0: // File { QString outputFilename = OGlobalSettings::debugOutput(); const int BUFSIZE = 4096; char buf[BUFSIZE] = ""; buf[BUFSIZE-1] = '\0'; int nSize; nSize = snprintf( buf, BUFSIZE-1, "%s: %s", (const char*) areaName, data); QFile outputFile( outputFilename ); if ( outputFile.open( IO_WriteOnly | IO_Append ) ) { if ( ( nSize == -1 ) || ( nSize >= BUFSIZE ) ) { outputFile.writeBlock( buf, BUFSIZE-1 ); } else { outputFile.writeBlock( buf, nSize ); } } else { qDebug( "ODebug: can't write to file '%s' (%s)", (const char*) outputFilename, strerror(errno) ); } break; } // automatic close of file here case 1: // Message Box { // Since we are in opiecore here, we cannot use OMsgBox and use // QMessageBox instead caption += QString("(") + areaName + ")"; QMessageBox::warning( 0L, caption, data, ("&OK") ); // tr? break; } case 2: // Shell { FILE *output = stderr; fprintf( output, "%s: ", (const char*) areaName ); fputs( data, output); break; } case 3: // syslog { syslog( priority, "%s", data); break; } case 4: // socket { QString destination = OGlobalSettings::debugOutput(); if ( destination && destination.find(":") != -1 ) { QString host = destination.left( destination.find(":") ); QString port = destination.right( destination.length()-host.length()-1 ); QHostAddress addr; addr.setAddress( host ); // TODO: sanity check the address QString line; line.sprintf( "%s: %s", (const char*) areaName, (const char*) data ); QSocketDevice s( QSocketDevice::Datagram ); int result = s.writeBlock( (const char*) line, line.length(), addr, port.toInt() ); if ( result == -1 ) { qDebug( "ODebug: can't send to address '%s:%d' (%s)", (const char*) host, port.toInt(), strerror(errno) ); } } break; } } // check if we should abort /* if( ( nLevel == ODEBUG_FATAL ) && ( !oDebug_data->config || oDebug_data->config->readNumEntry( "AbortFatal", 1 ) ) ) abort(); */ } /*====================================================================================== * odbgstream *======================================================================================*/ odbgstream& perror( odbgstream &s) { return s << QString::fromLocal8Bit(strerror(errno)); } odbgstream odDebug(int area) { return odbgstream(area, ODEBUG_INFO); } odbgstream odDebug(bool cond, int area) { if (cond) return odbgstream(area, ODEBUG_INFO); else return odbgstream(0, 0, false); } odbgstream odError(int area) { return odbgstream("ERROR: ", area, ODEBUG_ERROR); } odbgstream odError(bool cond, int area) { if (cond) return odbgstream("ERROR: ", area, ODEBUG_ERROR); else return odbgstream(0,0,false); } odbgstream odWarning(int area) { return odbgstream("WARNING: ", area, ODEBUG_WARN); } odbgstream odWarning(bool cond, int area) { if (cond) return odbgstream("WARNING: ", area, ODEBUG_WARN); else return odbgstream(0,0,false); } odbgstream odFatal(int area) { return odbgstream("FATAL: ", area, ODEBUG_FATAL); } odbgstream odFatal(bool cond, int area) { if (cond) return odbgstream("FATAL: ", area, ODEBUG_FATAL); else return odbgstream(0,0,false); } odbgstream::odbgstream(unsigned int _area, unsigned int _level, bool _print) :area(_area), level(_level), print(_print) { } odbgstream::odbgstream(const char * initialString, unsigned int _area, unsigned int _level, bool _print) :output(QString::fromLatin1(initialString)), area(_area), level(_level), print(_print) { } odbgstream::odbgstream(odbgstream &str) :output(str.output), area(str.area), level(str.level), print(str.print) { str.output.truncate(0); } odbgstream::odbgstream(const odbgstream &str) :output(str.output), area(str.area), level(str.level), print(str.print) { } odbgstream& odbgstream::operator<<(bool i) { if (!print) return *this; output += QString::fromLatin1(i ? "true" : "false"); return *this; } odbgstream& odbgstream::operator<<(short i) { if (!print) return *this; QString tmp; tmp.setNum(i); output += tmp; return *this; } odbgstream& odbgstream::operator<<(unsigned short i) { if (!print) return *this; QString tmp; tmp.setNum(i); output += tmp; return *this; } odbgstream& odbgstream::operator<<(unsigned char i) { return operator<<( static_cast<char>( i ) ); } odbgstream& odbgstream::operator<<(int i) { if (!print) return *this; QString tmp; tmp.setNum(i); output += tmp; return *this; } odbgstream& odbgstream::operator<<(unsigned int i) { if (!print) return *this; QString tmp; tmp.setNum(i); output += tmp; return *this; } odbgstream& odbgstream::operator<<(long i) { if (!print) return *this; QString tmp; tmp.setNum(i); output += tmp; return *this; } odbgstream& odbgstream::operator<<(unsigned long i) { if (!print) return *this; QString tmp; tmp.setNum(i); output += tmp; return *this; } odbgstream& odbgstream::operator<<(const QString& string) { if (!print) return *this; output += string; if (output.at(output.length() -1 ) == '\n') flush(); return *this; } odbgstream& odbgstream::operator<<(const char *string) { if (!print) return *this; output += QString::fromUtf8(string); if (output.at(output.length() - 1) == '\n') flush(); return *this; } odbgstream& odbgstream::operator<<(const QCString& string) { *this << string.data(); return *this; } odbgstream& odbgstream::operator<<(const void * p) { form("%p", p); return *this; } odbgstream& odbgstream::operator<<(double d) { QString tmp; tmp.setNum(d); output += tmp; return *this; } /* odbgstream::odbgstream &form(const char *format, ...) #ifdef __GNUC__ __attribute__ ( ( format ( printf, 2, 3 ) ) ) #endif ; */ void odbgstream::flush() { if ( output.isEmpty() || !print ) { return; } else { oDebugBackend( level, area, output.local8Bit().data() ); output = QString::null; } } odbgstream& odbgstream::form(const char *format, ...) { char buf[4096]; va_list arguments; va_start( arguments, format ); buf[sizeof(buf)-1] = '\0'; vsnprintf( buf, sizeof(buf)-1, format, arguments ); va_end(arguments); *this << buf; return *this; } odbgstream::~odbgstream() { if (!output.isEmpty()) { fprintf(stderr, "ASSERT: debug output not ended with \\n\n"); *this << "\n"; } } odbgstream& odbgstream::operator<<(char ch) { if (!print) return *this; if (!isprint(ch)) { output += "\\x" + QString::number( static_cast<uint>( ch ) + 0x100, 16 ).right(2); } else { output += ch; if (ch == '\n') flush(); } return *this; } odbgstream& odbgstream::operator<<( QWidget* widget ) { QString string, temp; // ----- if(widget==0) { string=(QString)"[Null pointer]"; } else { temp.setNum((ulong)widget, 16); string=(QString)"["+widget->className()+" pointer " + "(0x" + temp + ")"; if(widget->name(0)==0) { string += " to unnamed widget, "; } else { string += (QString)" to widget " + widget->name() + ", "; } string += "geometry=" + QString().setNum(widget->width()) + "x"+QString().setNum(widget->height()) + "+"+QString().setNum(widget->x()) + "+"+QString().setNum(widget->y()) + "]"; } if (!print) return *this; output += string; if (output.at(output.length()-1) == '\n') { flush(); } return *this; } /* * either use 'output' directly and do the flush if needed * or use the QString operator which calls the char* operator * */ odbgstream& odbgstream::operator<<( const QDateTime& time) { *this << time.toString(); return *this; } odbgstream& odbgstream::operator<<( const QDate& date) { *this << date.toString(); return *this; } odbgstream& odbgstream::operator<<( const QTime& time ) { *this << time.toString(); return *this; } odbgstream& odbgstream::operator<<( const QPoint& p ) { *this << "(" << p.x() << ", " << p.y() << ")"; return *this; } odbgstream& odbgstream::operator<<( const QSize& s ) { *this << "[" << s.width() << "x" << s.height() << "]"; return *this; } odbgstream& odbgstream::operator<<( const QRect& r ) { *this << "[" << r.left() << ", " << r.top() << " - " << r.right() << ", " << r.bottom() << "]"; return *this; } odbgstream& odbgstream::operator<<( const QRegion& reg ) { /* Qt2 doesn't have a QMemArray... :( *this << "[ "; QMemArray<QRect>rs=reg.rects(); for (uint i=0;i<rs.size();++i) *this << QString("[%1, %2 - %3, %4] ").arg(rs[i].left()).arg(rs[i].top()).arg(rs[i].right()).arg(rs[i].bottom() ) ; *this <<"]"; */ return *this; } odbgstream& odbgstream::operator<<( const QStringList& l ) { *this << "("; *this << l.join(","); *this << ")"; return *this; } odbgstream& odbgstream::operator<<( const QColor& c ) { if ( c.isValid() ) *this << c.name(); else *this << "(invalid/default)"; return *this; } odbgstream& odbgstream::operator<<( const QBrush& b) { static const char* const s_brushStyles[] = { "NoBrush", "SolidPattern", "Dense1Pattern", "Dense2Pattern", "Dense3Pattern", "Dense4Pattern", "Dense5Pattern", "Dense6Pattern", "Dense7Pattern", "HorPattern", "VerPattern", "CrossPattern", "BDiagPattern", "FDiagPattern", "DiagCrossPattern" }; *this <<"[ style: "; *this <<s_brushStyles[ b.style() ]; *this <<" color: "; // can't use operator<<(str, b.color()) because that terminates a odbgstream (flushes) if ( b.color().isValid() ) *this <<b.color().name() ; else *this <<"(invalid/default)"; if ( b.pixmap() ) *this <<" has a pixmap"; *this <<" ]"; return *this; } QString odBacktrace( int levels ) { QString s; #ifndef OPIE_NO_BACKTRACE void* trace[256]; int n = backtrace(trace, 256); char** strings = backtrace_symbols (trace, n); if ( levels != -1 ) n = QMIN( n, levels ); s = "[\n"; for (int i = 0; i < n; ++i) s += QString::number(i) + QString::fromLatin1(": ") + QString::fromLatin1(strings[i]) + QString::fromLatin1("\n"); s += "]\n"; free (strings); #endif return s; } void odClearDebugConfig() { /* delete oDebug_data->config; oDebug_data->config = 0; */ } #ifdef OPIE_NO_DEBUG #define odDebug ondDebug #define odBacktrace ondBacktrace #endif diff --git a/libopie2/opiecore/oglobal.cpp b/libopie2/opiecore/oglobal.cpp index f6071be..ae2fcb6 100644 --- a/libopie2/opiecore/oglobal.cpp +++ b/libopie2/opiecore/oglobal.cpp @@ -1,36 +1,43 @@ /* This file is part of the Opie Project Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> =. .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <opie2/oglobal.h> +OConfig* OGlobal::_config = 0; + OConfig* OGlobal::config() { - return globalconfig; + if ( !OGlobal::_config ) + { + qDebug( "OGlobal::creating global configuration instance." ); + OGlobal::_config = new OConfig( "global" ); + } + return OGlobal::_config; } diff --git a/libopie2/opiecore/oglobal.h b/libopie2/opiecore/oglobal.h index 23cedde..2dc4f9e 100644 --- a/libopie2/opiecore/oglobal.h +++ b/libopie2/opiecore/oglobal.h @@ -1,49 +1,49 @@ /* This file is part of the Opie Project - - Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> + Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de> =. .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef OGLOBAL_H #define OGLOBAL_H -#include <qpe/global.h> #include <opie2/oconfig.h> -static OConfig *globalconfig = new OConfig( "global" ); - -//FIXME: Is it wise or even necessary to inherit OGlobal from Global? +//FIXME Is it wise or even necessary to inherit OGlobal from Global? // once we totally skip libqpe it should ideally swallow Global -zecke +// You're right. I deleted global as the base class. -mickeyl -class OGlobal : public Global +class OGlobal { public: - // do we want to put that into OApplication as in KApplication -zecke + //FIXME Do we want to put that into OApplication as in KApplication? -zecke + // We already have a per-application config in OApplication + // ( accessed through oApp->config() ), but this one is the global one! -mickeyl static OConfig* config(); + static OConfig* _config; }; #endif // OGLOBAL_H diff --git a/libopie2/opiecore/oglobalsettings.cpp b/libopie2/opiecore/oglobalsettings.cpp index 1799529..66adbd0 100644 --- a/libopie2/opiecore/oglobalsettings.cpp +++ b/libopie2/opiecore/oglobalsettings.cpp @@ -1,547 +1,548 @@ /* This file is part of the Opie Project Copyright (C) 2003 Michael Lauer <mickey@tm.informatik.uni-frankfurt.de> Inspired by the KDE globalsettings which are Copyright (C) 2000 David Faure <faure@kde.org> =. .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* OPIE */ #include <opie2/oglobalsettings.h> #include <opie2/oconfig.h> #include <opie2/oglobal.h> /* QT */ +#include <qobject.h> #include <qdir.h> #include <qpixmap.h> #include <qfontinfo.h> /* UNIX */ #include <stdlib.h> QString* OGlobalSettings::s_desktopPath = 0; QString* OGlobalSettings::s_autostartPath = 0; QString* OGlobalSettings::s_trashPath = 0; QString* OGlobalSettings::s_documentPath = 0; QFont *OGlobalSettings::_generalFont = 0; QFont *OGlobalSettings::_fixedFont = 0; QFont *OGlobalSettings::_toolBarFont = 0; QFont *OGlobalSettings::_menuFont = 0; QFont *OGlobalSettings::_windowTitleFont = 0; QFont *OGlobalSettings::_taskbarFont = 0; QColor *OGlobalSettings::OpieGray = 0; QColor *OGlobalSettings::OpieHighlight = 0; QColor *OGlobalSettings::OpieAlternate = 0; OGlobalSettings::OMouseSettings *OGlobalSettings::s_mouseSettings = 0; //FIXME: Add manipulators to the accessors int OGlobalSettings::dndEventDelay() { OConfig *c = OGlobal::config(); OConfigGroupSaver cgs( c, "General" ); return c->readNumEntry("DndDelay", 2); } bool OGlobalSettings::singleClick() { OConfig *c = OGlobal::config(); OConfigGroupSaver cgs( c, "OPIE" ); return c->readBoolEntry("SingleClick", OPIE_DEFAULT_SINGLECLICK); } bool OGlobalSettings::insertTearOffHandle() { OConfig *c = OGlobal::config(); OConfigGroupSaver cgs( c, "OPIE" ); return c->readBoolEntry("InsertTearOffHandle", OPIE_DEFAULT_INSERTTEAROFFHANDLES); } bool OGlobalSettings::changeCursorOverIcon() { OConfig *c = OGlobal::config(); OConfigGroupSaver cgs( c, "OPIE" ); return c->readBoolEntry("ChangeCursor", OPIE_DEFAULT_CHANGECURSOR); } bool OGlobalSettings::visualActivate() { OConfig *c = OGlobal::config(); OConfigGroupSaver cgs( c, "OPIE" ); return c->readBoolEntry("VisualActivate", OPIE_DEFAULT_VISUAL_ACTIVATE); } unsigned int OGlobalSettings::visualActivateSpeed() { OConfig *c = OGlobal::config(); OConfigGroupSaver cgs( c, "OPIE" ); return c->readNumEntry( "VisualActivateSpeed", OPIE_DEFAULT_VISUAL_ACTIVATE_SPEED ); } int OGlobalSettings::autoSelectDelay() { OConfig *c = OGlobal::config(); OConfigGroupSaver cgs( c, "OPIE" ); return c->readNumEntry("AutoSelectDelay", OPIE_DEFAULT_AUTOSELECTDELAY); } OGlobalSettings::Completion OGlobalSettings::completionMode() { int completion; OConfig *c = OGlobal::config(); OConfigGroupSaver cgs( c, "General" ); completion = c->readNumEntry("completionMode", -1); if ((completion < (int) CompletionNone) || (completion > (int) CompletionPopupAuto)) { completion = (int) CompletionPopup; // Default } return (Completion) completion; } bool OGlobalSettings::showContextMenusOnPress () { OConfig *c = OGlobal::config(); OConfigGroupSaver cgs (c, "ContextMenus"); return cgs.config()->readBoolEntry("ShowOnPress", true); } int OGlobalSettings::contextMenuKey () { OConfig *c = OGlobal::config(); OConfigGroupSaver cgs (c, "Shortcuts"); //OShortcut cut (cgs.config()->readEntry ("PopupMenuContext", "Menu")); //return cut.keyCodeQt(); return 0; // FIXME } OGlobalSettings::Debug OGlobalSettings::debugMode() { OConfig *c = OGlobal::config(); OConfigGroupSaver cgs( c, "General" ); int debug = c->readNumEntry( "debugMode", -1 ); if ( (debug < (int) DebugNone) || (debug > (int) DebugSocket) ) { debug = (int) DebugStdErr; // Default } return (Debug) debug; } QString OGlobalSettings::debugOutput() { OConfig *c = OGlobal::config(); OConfigGroupSaver cgs( c, "General" ); QString deflt = QString::null; switch( debugMode() ) { case DebugNone: break; // no additional information needed case DebugFiles: deflt = "/var/log/opiedebug.log"; break; // file to save output in case DebugMsgBox: break; // no additional information needed case DebugStdErr: break; // no additional information needed case DebugSysLog: break; // no additional information needed case DebugSocket: deflt = "127.0.0.1:8913"; break; // address to send packets to } return c->readEntry( "debugOutput"+ QString::number(debugMode()), deflt ); } QColor OGlobalSettings::toolBarHighlightColor() { initColors(); OConfig *c = OGlobal::config(); OConfigGroupSaver cgs( c, QString::fromLatin1("Toolbar style") ); return c->readColorEntry("HighlightColor", OpieHighlight); } QColor OGlobalSettings::inactiveTitleColor() { if (!OpieGray) OpieGray = new QColor(220, 220, 220); OConfig *c = OGlobal::config(); OConfigGroupSaver cgs( c, QString::fromLatin1("WM") ); return c->readColorEntry( "inactiveBackground", OpieGray ); } QColor OGlobalSettings::inactiveTextColor() { OConfig *c = OGlobal::config(); OConfigGroupSaver cgs( c, QString::fromLatin1("WM") ); return c->readColorEntry( "inactiveForeground", &Qt::darkGray ); } QColor OGlobalSettings::activeTitleColor() { initColors(); OConfig *c = OGlobal::config(); OConfigGroupSaver cgs( c, QString::fromLatin1("WM") ); return c->readColorEntry( "activeBackground", OpieHighlight); } QColor OGlobalSettings::activeTextColor() { OConfig *c = OGlobal::config(); OConfigGroupSaver cgs( c, QString::fromLatin1("WM") ); return c->readColorEntry( "activeForeground", &Qt::white ); } int OGlobalSettings::contrast() { OConfig *c = OGlobal::config(); OConfigGroupSaver cgs( c, QString::fromLatin1("OPIE") ); return c->readNumEntry( "contrast", 7 ); } // following functions should work in OPIE - how to sync with appearance changes? QColor OGlobalSettings::baseColor() { OConfig *c = OGlobal::config(); OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") ); return c->readColorEntry( "Base", &Qt::white ); } QColor OGlobalSettings::textColor() { OConfig *c = OGlobal::config(); OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") ); return c->readColorEntry( "Text", &Qt::black ); } QColor OGlobalSettings::highlightedTextColor() { OConfig *c = OGlobal::config(); OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") ); return c->readColorEntry( "HighlightedText", &Qt::white ); } QColor OGlobalSettings::highlightColor() { initColors(); OConfig *c = OGlobal::config(); OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") ); return c->readColorEntry( "Highlight", OpieHighlight ); } QColor OGlobalSettings::alternateBackgroundColor() { initColors(); OConfig *c = OGlobal::config(); OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") ); *OpieAlternate = calculateAlternateBackgroundColor( baseColor() ); return c->readColorEntry( "alternateBackground", OpieAlternate ); } QColor OGlobalSettings::calculateAlternateBackgroundColor(const QColor& base) { if (base == Qt::white) return QColor(238,246,255); else { int h, s, v; base.hsv( &h, &s, &v ); if (v > 128) return base.dark(106); else if (base != Qt::black) return base.light(110); return QColor(32,32,32); } } QColor OGlobalSettings::linkColor() { initColors(); OConfig *c = OGlobal::config(); OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") ); return c->readColorEntry( "linkColor", OpieGray ); } QColor OGlobalSettings::visitedLinkColor() { OConfig *c = OGlobal::config(); OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") ); return c->readColorEntry( "visitedLinkColor", &Qt::magenta ); } // FIXME: font stuff currently uses a different format in OPIE, so the // functions below are not yet applicable. The whole font stuff for OPIE // has to be revised anyway QFont OGlobalSettings::generalFont() { if (_generalFont) return *_generalFont; _generalFont = new QFont("helvetica", 10); _generalFont->setPixelSize(10); _generalFont->setStyleHint(QFont::SansSerif); OConfig *c = OGlobal::config(); OConfigGroupSaver cgs( c, QString::fromLatin1("Appearance") ); *_generalFont = c->readFontEntry("font", _generalFont); return *_generalFont; } QFont OGlobalSettings::fixedFont() { if (_fixedFont) return *_fixedFont; _fixedFont = new QFont("courier", 12); _fixedFont->setPixelSize(12); _fixedFont->setStyleHint(QFont::TypeWriter); OConfig *c = OGlobal::config(); OConfigGroupSaver cgs( c, QString::fromLatin1("General") ); *_fixedFont = c->readFontEntry("fixed", _fixedFont); return *_fixedFont; } QFont OGlobalSettings::toolBarFont() { if(_toolBarFont) return *_toolBarFont; _toolBarFont = new QFont("helvetica", 10); _toolBarFont->setPixelSize(10); _toolBarFont->setStyleHint(QFont::SansSerif); OConfig *c = OGlobal::config(); OConfigGroupSaver cgs( c, QString::fromLatin1("General") ); *_toolBarFont = c->readFontEntry("toolBarFont", _toolBarFont); return *_toolBarFont; } QFont OGlobalSettings::menuFont() { if(_menuFont) return *_menuFont; _menuFont = new QFont("helvetica", 12); _menuFont->setPixelSize(12); _menuFont->setStyleHint(QFont::SansSerif); OConfig *c = OGlobal::config(); OConfigGroupSaver cgs( c, QString::fromLatin1("General") ); *_menuFont = c->readFontEntry("menuFont", _menuFont); return *_menuFont; } QFont OGlobalSettings::windowTitleFont() { if(_windowTitleFont) return *_windowTitleFont; _windowTitleFont = new QFont("helvetica", 12, QFont::Bold); _windowTitleFont->setPixelSize(12); _windowTitleFont->setStyleHint(QFont::SansSerif); OConfig *c = OGlobal::config(); OConfigGroupSaver cgs( c, QString::fromLatin1("WM") ); *_windowTitleFont = c->readFontEntry("activeFont", _windowTitleFont); // inconsistency return *_windowTitleFont; } QFont OGlobalSettings::taskbarFont() { if(_taskbarFont) return *_taskbarFont; _taskbarFont = new QFont("helvetica", 8); _taskbarFont->setPixelSize(8); _taskbarFont->setStyleHint(QFont::SansSerif); OConfig *c = OGlobal::config(); OConfigGroupSaver cgs( c, QString::fromLatin1("General") ); *_taskbarFont = c->readFontEntry("taskbarFont", _taskbarFont); return *_taskbarFont; } // FIXME: the whole path stuff has to be revised for OPIE void OGlobalSettings::initStatic() // should be called initPaths(). Don't put anything else here. { if ( s_desktopPath != 0 ) return; s_desktopPath = new QString(); s_autostartPath = new QString(); s_trashPath = new QString(); s_documentPath = new QString(); OConfig *config = OGlobal::config(); //bool dollarExpansion = config->isDollarExpansion(); //config->setDollarExpansion(true); OConfigGroupSaver cgs( config, "Paths" ); // Desktop Path *s_desktopPath = QDir::homeDirPath() + "/" + "Desktop" + "/"; *s_desktopPath = config->readEntry( "Desktop", *s_desktopPath); if ( (*s_desktopPath)[0] != '/' ) s_desktopPath->prepend( QDir::homeDirPath() + "/" ); *s_desktopPath = QDir::cleanDirPath( *s_desktopPath ); if ( s_desktopPath->right(1) != "/") *s_desktopPath += "/"; // Trash Path *s_trashPath = *s_desktopPath + QObject::tr("Trash") + "/"; *s_trashPath = config->readEntry( "Trash" , *s_trashPath); if ( (*s_trashPath)[0] != '/' ) s_trashPath->prepend( QDir::homeDirPath() + "/" ); *s_trashPath = QDir::cleanDirPath( *s_trashPath ); if ( s_trashPath->right(1) != "/") *s_trashPath += "/"; // We need to save it in any case, in case the language changes later on, if ( !config->hasKey( "Trash" ) ) { //config->writePathEntry( "Trash", *s_trashPath, true, true ); config->writeEntry( "Trash", *s_trashPath ); //config->sync(); } /* // Autostart Path *s_autostartPath = OGlobal::dirs()->localkdedir() + "Autostart" + "/"; *s_autostartPath = config->readEntry( "Autostart" , *s_autostartPath); if ( (*s_autostartPath)[0] != '/' ) s_autostartPath->prepend( QDir::homeDirPath() + "/" ); *s_autostartPath = QDir::cleanDirPath( *s_autostartPath ); if ( s_autostartPath->right(1) != "/") *s_autostartPath += "/"; */ // Document Path *s_documentPath = QString::null; *s_documentPath = config->readEntry( "Documents" , *s_documentPath); if ( (*s_documentPath)[0] != '/' ) s_documentPath->prepend( QDir::homeDirPath() + "/" ); *s_documentPath = QDir::cleanDirPath( *s_documentPath ); if ( s_documentPath->right(1) != "/") *s_documentPath += "/"; //config->setDollarExpansion(dollarExpansion); // Make sure this app gets the notifications about those paths //if (kapp) //kapp->addKipcEventMask(KIPC::SettingsChanged); } void OGlobalSettings::initColors() { if ( !OpieHighlight ) OpieHighlight = new QColor( 156, 118, 32 ); if ( !OpieAlternate ) OpieAlternate = new QColor( 238, 246, 255 ); if ( !OpieGray ) OpieGray = new QColor( 220, 210, 215 ); } void OGlobalSettings::rereadFontSettings() { delete _generalFont; _generalFont = 0L; delete _fixedFont; _fixedFont = 0L; delete _menuFont; _menuFont = 0L; delete _toolBarFont; _toolBarFont = 0L; delete _windowTitleFont; _windowTitleFont = 0L; delete _taskbarFont; _taskbarFont = 0L; } void OGlobalSettings::rereadPathSettings() { qDebug( "OGlobalSettings::rereadPathSettings" ); delete s_autostartPath; s_autostartPath = 0L; delete s_trashPath; s_trashPath = 0L; delete s_desktopPath; s_desktopPath = 0L; delete s_documentPath; s_documentPath = 0L; } OGlobalSettings::OMouseSettings & OGlobalSettings::mouseSettings() { if ( ! s_mouseSettings ) { s_mouseSettings = new OMouseSettings; OMouseSettings & s = *s_mouseSettings; // for convenience OConfigGroupSaver cgs( OGlobal::config(), "Mouse" ); QString setting = OGlobal::config()->readEntry("MouseButtonMapping"); if (setting == "RightHanded") s.handed = OMouseSettings::RightHanded; else if (setting == "LeftHanded") s.handed = OMouseSettings::LeftHanded; else { // FIXME: Implement for Opie / Qt Embedded } } return *s_mouseSettings; } void OGlobalSettings::rereadMouseSettings() { delete s_mouseSettings; s_mouseSettings = 0L; } // FIXME: This won't be necessary, or will it? :-D bool OGlobalSettings::isMultiHead() { QCString multiHead = getenv("OPIE_MULTIHEAD"); if (!multiHead.isEmpty()) { return (multiHead.lower() == "true"); } return false; } diff --git a/libopie2/opiecore/opiecore.pro b/libopie2/opiecore/opiecore.pro index fe5800e..5d630ea 100644 --- a/libopie2/opiecore/opiecore.pro +++ b/libopie2/opiecore/opiecore.pro @@ -1,43 +1,43 @@ TEMPLATE = lib CONFIG += qt warn_on debug DESTDIR = $(OPIEDIR)/lib HEADERS = oapplication.h \ opieapplication.h \ oconfig.h \ opieconfig.h \ ocompletionbase.h \ ocompletion.h \ odebug.h \ oglobal.h \ oglobalsettings.h \ osortablevaluelist.h SOURCES = oapplication.cpp \ opieapplication.cpp \ oconfig.cpp \ opieconfig.cpp \ ocompletionbase.cpp \ ocompletion.cpp \ odebug.cpp \ oglobal.cpp \ oglobalsettings.cpp INTERFACES = TARGET = opiecore2 -VERSION = 1.8.1 +VERSION = 1.8.2 INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include MOC_DIR = moc OBJECTS_DIR = obj !contains( platform, x11 ) { LIBS = -lqpe include ( $(OPIEDIR)/include.pro ) } contains( platform, x11 ) { LIBS = -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib } diff --git a/libopie2/opiedb/libopiedb2.control b/libopie2/opiedb/libopiedb2.control index 3fe3820..5500dc8 100644 --- a/libopie2/opiedb/libopiedb2.control +++ b/libopie2/opiedb/libopiedb2.control @@ -1,11 +1,11 @@ Package: libopiedb2 Files: $OPIEDIR/lib/libopiedb2.so* Priority: optional Section: opie/system Maintainer: Opie Team <opie@handhelds.org> Architecture: arm -Version: 1.8.1-$SUB_VERSION.2 -Depends: libqpe1, libopiecore2 (1.8.1) +Version: 1.8.2-$SUB_VERSION.2 +Depends: libqpe1, libopiecore2 (1.8.2) Provides: libopiedb2 Description: Opie library 2.0 DB diff --git a/libopie2/opiedb/opiedb.pro b/libopie2/opiedb/opiedb.pro index 6a4e8f1..d869e6f 100644 --- a/libopie2/opiedb/opiedb.pro +++ b/libopie2/opiedb/opiedb.pro @@ -1,41 +1,41 @@ TEMPLATE = lib #CONFIG += qt warn_on debug CONFIG += qt warn_on release DESTDIR = $(OPIEDIR)/lib HEADERS = osqlbackend.h \ osqldriver.h \ osqlerror.h \ osqlmanager.h \ osqlquery.h \ osqlresult.h \ osqltable.h \ osqlbackendmanager.h \ osqlitedriver.h SOURCES = osqlbackend.cpp \ osqldriver.cpp \ osqlerror.cpp \ osqlmanager.cpp \ osqlquery.cpp \ osqlresult.cpp \ osqltable.cpp \ osqlbackendmanager.cpp \ osqlitedriver.cpp INTERFACES = TARGET = opiedb2 -VERSION = 1.8.1 +VERSION = 1.8.2 INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include MOC_DIR = moc OBJECTS_DIR = obj LIBS += -lsqlite -lqpe !contains( platform, x11 ) { include ( $(OPIEDIR)/include.pro ) } contains( platform, x11 ) { LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib } diff --git a/libopie2/opiemm/libopiemm2.control b/libopie2/opiemm/libopiemm2.control index 7fbadef..f528969 100644 --- a/libopie2/opiemm/libopiemm2.control +++ b/libopie2/opiemm/libopiemm2.control @@ -1,11 +1,11 @@ Package: libopiemm2 Files: $OPIEDIR/lib/libopiemm2.so.* Priority: optional Section: opie/system Maintainer: Opie Team <opie@handhelds.org> Architecture: arm -Version: 1.8.1-$SUB_VERSION.2 -Depends: libqpe1, libopiecore2 (1.8.1) +Version: 1.8.2-$SUB_VERSION.2 +Depends: libqpe1, libopiecore2 (1.8.2) Provides: libopiemm2 Description: Opie library 2.0 MM diff --git a/libopie2/opiemm/opiemm.pro b/libopie2/opiemm/opiemm.pro index d3ce8f7..d5c8238 100644 --- a/libopie2/opiemm/opiemm.pro +++ b/libopie2/opiemm/opiemm.pro @@ -1,22 +1,22 @@ TEMPLATE = lib CONFIG += qt warn_on debug DESTDIR = $(OPIEDIR)/lib HEADERS = osoundsystem.h SOURCES = osoundsystem.cpp INTERFACES = TARGET = opiemm2 -VERSION = 1.8.1 +VERSION = 1.8.2 INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += MOC_DIR = moc OBJECTS_DIR = obj !contains( platform, x11 ) { include ( $(OPIEDIR)/include.pro ) } contains( platform, x11 ) { LIBS = -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib } diff --git a/libopie2/opienet/dhcp.h b/libopie2/opienet/dhcp.h index 3f2f775..368e375 100644 --- a/libopie2/opienet/dhcp.h +++ b/libopie2/opienet/dhcp.h @@ -1,200 +1,201 @@ /* dhcp.h Protocol structures... */ /* * Copyright (c) 1995-2001 The Internet Software Consortium. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of The Internet Software Consortium nor the names * of its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * This software has been written for the Internet Software Consortium * by Ted Lemon in cooperation with Vixie Enterprises. To learn more * about the Internet Software Consortium, see ``http://www.isc.org''. * To learn more about Vixie Enterprises, see ``http://www.vix.com''. */ #ifndef DHCP_H #define DHCP_H #define DHCP_UDP_OVERHEAD (14 + /* Ethernet header */ \ 20 + /* IP header */ \ 8) /* UDP header */ #define DHCP_SNAME_LEN 64 #define DHCP_FILE_LEN 128 #define DHCP_FIXED_NON_UDP 236 #define DHCP_FIXED_LEN (DHCP_FIXED_NON_UDP + DHCP_UDP_OVERHEAD) /* Everything but options. */ #define DHCP_MTU_MAX 1500 #define DHCP_OPTION_LEN (DHCP_MTU_MAX - DHCP_FIXED_LEN) #define BOOTP_MIN_LEN 300 #define DHCP_MIN_LEN 548 struct dhcp_packet { u_int8_t op; /* 0: Message opcode/type */ u_int8_t htype; /* 1: Hardware addr type (net/if_types.h) */ u_int8_t hlen; /* 2: Hardware addr length */ u_int8_t hops; /* 3: Number of relay agent hops from client */ u_int32_t xid; /* 4: Transaction ID */ u_int16_t secs; /* 8: Seconds since client started looking */ u_int16_t flags; /* 10: Flag bits */ struct in_addr ciaddr; /* 12: Client IP address (if already in use) */ struct in_addr yiaddr; /* 16: Client IP address */ struct in_addr siaddr; /* 18: IP address of next server to talk to */ struct in_addr giaddr; /* 20: DHCP relay agent IP address */ unsigned char chaddr [16]; /* 24: Client hardware address */ char sname [DHCP_SNAME_LEN]; /* 40: Server name */ char file [DHCP_FILE_LEN]; /* 104: Boot filename */ unsigned char options [DHCP_OPTION_LEN]; /* 212: Optional parameters (actual length dependent on MTU). */ }; /* BOOTP (rfc951) message types */ #define BOOTREQUEST 1 #define BOOTREPLY 2 /* Possible values for flags field... */ #define BOOTP_BROADCAST 32768L /* Possible values for hardware type (htype) field... */ #define HTYPE_ETHER 1 /* Ethernet 10Mbps */ #define HTYPE_IEEE802 6 /* IEEE 802.2 Token Ring... */ #define HTYPE_FDDI 8 /* FDDI... */ /* Magic cookie validating dhcp options field (and bootp vendor extensions field). */ #define DHCP_OPTIONS_COOKIE "\143\202\123\143" /* DHCP Option codes: */ #define DHO_PAD 0 #define DHO_SUBNET_MASK 1 #define DHO_TIME_OFFSET 2 #define DHO_ROUTERS 3 #define DHO_TIME_SERVERS 4 #define DHO_NAME_SERVERS 5 #define DHO_DOMAIN_NAME_SERVERS 6 #define DHO_LOG_SERVERS 7 #define DHO_COOKIE_SERVERS 8 #define DHO_LPR_SERVERS 9 #define DHO_IMPRESS_SERVERS 10 #define DHO_RESOURCE_LOCATION_SERVERS 11 #define DHO_HOST_NAME 12 #define DHO_BOOT_SIZE 13 #define DHO_MERIT_DUMP 14 #define DHO_DOMAIN_NAME 15 #define DHO_SWAP_SERVER 16 #define DHO_ROOT_PATH 17 #define DHO_EXTENSIONS_PATH 18 #define DHO_IP_FORWARDING 19 #define DHO_NON_LOCAL_SOURCE_ROUTING 20 #define DHO_POLICY_FILTER 21 #define DHO_MAX_DGRAM_REASSEMBLY 22 #define DHO_DEFAULT_IP_TTL 23 #define DHO_PATH_MTU_AGING_TIMEOUT 24 #define DHO_PATH_MTU_PLATEAU_TABLE 25 #define DHO_INTERFACE_MTU 26 #define DHO_ALL_SUBNETS_LOCAL 27 #define DHO_BROADCAST_ADDRESS 28 #define DHO_PERFORM_MASK_DISCOVERY 29 #define DHO_MASK_SUPPLIER 30 #define DHO_ROUTER_DISCOVERY 31 #define DHO_ROUTER_SOLICITATION_ADDRESS 32 #define DHO_STATIC_ROUTES 33 #define DHO_TRAILER_ENCAPSULATION 34 #define DHO_ARP_CACHE_TIMEOUT 35 #define DHO_IEEE802_3_ENCAPSULATION 36 #define DHO_DEFAULT_TCP_TTL 37 #define DHO_TCP_KEEPALIVE_INTERVAL 38 #define DHO_TCP_KEEPALIVE_GARBAGE 39 #define DHO_NIS_DOMAIN 40 #define DHO_NIS_SERVERS 41 #define DHO_NTP_SERVERS 42 #define DHO_VENDOR_ENCAPSULATED_OPTIONS 43 #define DHO_NETBIOS_NAME_SERVERS 44 #define DHO_NETBIOS_DD_SERVER 45 #define DHO_NETBIOS_NODE_TYPE 46 #define DHO_NETBIOS_SCOPE 47 #define DHO_FONT_SERVERS 48 #define DHO_X_DISPLAY_MANAGER 49 #define DHO_DHCP_REQUESTED_ADDRESS 50 #define DHO_DHCP_LEASE_TIME 51 #define DHO_DHCP_OPTION_OVERLOAD 52 #define DHO_DHCP_MESSAGE_TYPE 53 #define DHO_DHCP_SERVER_IDENTIFIER 54 #define DHO_DHCP_PARAMETER_REQUEST_LIST 55 #define DHO_DHCP_MESSAGE 56 #define DHO_DHCP_MAX_MESSAGE_SIZE 57 #define DHO_DHCP_RENEWAL_TIME 58 #define DHO_DHCP_REBINDING_TIME 59 #define DHO_VENDOR_CLASS_IDENTIFIER 60 #define DHO_DHCP_CLIENT_IDENTIFIER 61 #define DHO_NWIP_DOMAIN_NAME 62 #define DHO_NWIP_SUBOPTIONS 63 #define DHO_USER_CLASS 77 #define DHO_FQDN 81 #define DHO_DHCP_AGENT_OPTIONS 82 #define DHO_SUBNET_SELECTION 118 /* RFC3011! */ /* The DHO_AUTHENTICATE option is not a standard yet, so I've allocated an option out of the "local" option space for it on a temporary basis. Once an option code number is assigned, I will immediately and shamelessly break this, so don't count on it continuing to work. */ #define DHO_AUTHENTICATE 210 #define DHO_END 255 /* DHCP message types. */ #define DHCPDISCOVER 1 #define DHCPOFFER 2 #define DHCPREQUEST 3 #define DHCPDECLINE 4 #define DHCPACK 5 #define DHCPNAK 6 #define DHCPRELEASE 7 #define DHCPINFORM 8 /* Relay Agent Information option subtypes: */ #define RAI_CIRCUIT_ID 1 #define RAI_REMOTE_ID 2 #define RAI_AGENT_ID 3 /* FQDN suboptions: */ #define FQDN_NO_CLIENT_UPDATE 1 #define FQDN_SERVER_UPDATE 2 #define FQDN_ENCODED 3 #define FQDN_RCODE1 4 #define FQDN_RCODE2 5 #define FQDN_HOSTNAME 6 #define FQDN_DOMAINNAME 7 #define FQDN_FQDN 8 #define FQDN_SUBOPTION_COUNT 8 #endif
\ No newline at end of file + diff --git a/libopie2/opienet/libopienet2.control b/libopie2/opienet/libopienet2.control index 65d8464..8eb0704 100644 --- a/libopie2/opienet/libopienet2.control +++ b/libopie2/opienet/libopienet2.control @@ -1,11 +1,11 @@ Package: libopienet2 Files: $OPIEDIR/lib/libopienet2.so.* $OPIEDIR/etc/manufacturers Priority: optional Section: opie/system Maintainer: Opie Team <opie@handhelds.org> Architecture: arm -Version: 1.8.1-$SUB_VERSION.2 -Depends: libqpe1, libopiecore2 (1.8.1) +Version: 1.8.2-$SUB_VERSION.2 +Depends: libopiecore2 (1.8.2) Provides: libopienet2 Description: Opie library 2.0 NET diff --git a/libopie2/opienet/odebugmapper.cpp b/libopie2/opienet/odebugmapper.cpp index d62b3ba..7e4ab2b 100644 --- a/libopie2/opienet/odebugmapper.cpp +++ b/libopie2/opienet/odebugmapper.cpp @@ -1,213 +1,215 @@ /* * debug value mapper - generated by regen.py - (C) Michael 'Mickey' Lauer <mickey@vanille.de> */ +#include <opie2/odebug.h> + #include "odebugmapper.h" DebugMapper::DebugMapper() { - qDebug( "DebugMapper::DebugMapper()" ); + odebug << "DebugMapper::DebugMapper()" << oendl; _map.insert( 0x8902, new QString("SIOCSPGRP") ); _map.insert( 0x8904, new QString("SIOCGPGRP") ); _map.insert( 0x8905, new QString("SIOCATMARK") ); _map.insert( 0x8906, new QString("SIOCGSTAMP") ); _map.insert( 0x890B, new QString("SIOCADDRT") ); _map.insert( 0x890C, new QString("SIOCDELRT") ); _map.insert( 0x890D, new QString("SIOCRTMSG") ); _map.insert( 0x8910, new QString("SIOCGIFNAME") ); _map.insert( 0x8911, new QString("SIOCSIFLINK") ); _map.insert( 0x8912, new QString("SIOCGIFCONF") ); _map.insert( 0x8913, new QString("SIOCGIFFLAGS") ); _map.insert( 0x8914, new QString("SIOCSIFFLAGS") ); _map.insert( 0x8915, new QString("SIOCGIFADDR") ); _map.insert( 0x8916, new QString("SIOCSIFADDR") ); _map.insert( 0x8917, new QString("SIOCGIFDSTADDR") ); _map.insert( 0x8918, new QString("SIOCSIFDSTADDR") ); _map.insert( 0x8919, new QString("SIOCGIFBRDADDR") ); _map.insert( 0x891a, new QString("SIOCSIFBRDADDR") ); _map.insert( 0x891b, new QString("SIOCGIFNETMASK") ); _map.insert( 0x891c, new QString("SIOCSIFNETMASK") ); _map.insert( 0x891d, new QString("SIOCGIFMETRIC") ); _map.insert( 0x891e, new QString("SIOCSIFMETRIC") ); _map.insert( 0x891f, new QString("SIOCGIFMEM") ); _map.insert( 0x8920, new QString("SIOCSIFMEM") ); _map.insert( 0x8921, new QString("SIOCGIFMTU") ); _map.insert( 0x8922, new QString("SIOCSIFMTU") ); _map.insert( 0x8923, new QString("SIOCSIFNAME") ); _map.insert( 0x8924, new QString("SIOCSIFHWADDR") ); _map.insert( 0x8925, new QString("SIOCGIFENCAP") ); _map.insert( 0x8926, new QString("SIOCSIFENCAP") ); _map.insert( 0x8927, new QString("SIOCGIFHWADDR") ); _map.insert( 0x8929, new QString("SIOCGIFSLAVE") ); _map.insert( 0x8930, new QString("SIOCSIFSLAVE") ); _map.insert( 0x8931, new QString("SIOCADDMULTI") ); _map.insert( 0x8932, new QString("SIOCDELMULTI") ); _map.insert( 0x8933, new QString("SIOCGIFINDEX") ); _map.insert( 0x8934, new QString("SIOCSIFPFLAGS") ); _map.insert( 0x8935, new QString("SIOCGIFPFLAGS") ); _map.insert( 0x8936, new QString("SIOCDIFADDR") ); _map.insert( 0x8937, new QString("SIOCSIFHWBROADCAST") ); _map.insert( 0x8938, new QString("SIOCGIFCOUNT") ); _map.insert( 0x8940, new QString("SIOCGIFBR") ); _map.insert( 0x8941, new QString("SIOCSIFBR") ); _map.insert( 0x8942, new QString("SIOCGIFTXQLEN") ); _map.insert( 0x8943, new QString("SIOCSIFTXQLEN") ); _map.insert( 0x8953, new QString("SIOCDARP") ); _map.insert( 0x8954, new QString("SIOCGARP") ); _map.insert( 0x8955, new QString("SIOCSARP") ); _map.insert( 0x8960, new QString("SIOCDRARP") ); _map.insert( 0x8961, new QString("SIOCGRARP") ); _map.insert( 0x8962, new QString("SIOCSRARP") ); _map.insert( 0x8970, new QString("SIOCGIFMAP") ); _map.insert( 0x8971, new QString("SIOCSIFMAP") ); _map.insert( 0x8980, new QString("SIOCADDDLCI") ); _map.insert( 0x8981, new QString("SIOCDELDLCI") ); _map.insert( 0x89F0, new QString("SIOCDEVPRIVATE") ); _map.insert( 0x89E0, new QString("SIOCPROTOPRIVATE") ); _map.insert( 0x1fff, new QString("SIOCPARM_MASK") ); _map.insert( 0x00000000, new QString("SIOC_VOID") ); _map.insert( 0x20000000, new QString("SIOC_OUT") ); _map.insert( 0x40000000, new QString("SIOC_IN") ); _map.insert( 0x8B00, new QString("SIOCSIWCOMMIT") ); _map.insert( 0x8B01, new QString("SIOCGIWNAME") ); _map.insert( 0x8B02, new QString("SIOCSIWNWID") ); _map.insert( 0x8B03, new QString("SIOCGIWNWID") ); _map.insert( 0x8B04, new QString("SIOCSIWFREQ") ); _map.insert( 0x8B05, new QString("SIOCGIWFREQ") ); _map.insert( 0x8B06, new QString("SIOCSIWMODE") ); _map.insert( 0x8B07, new QString("SIOCGIWMODE") ); _map.insert( 0x8B08, new QString("SIOCSIWSENS") ); _map.insert( 0x8B09, new QString("SIOCGIWSENS") ); _map.insert( 0x8B0A, new QString("SIOCSIWRANGE") ); _map.insert( 0x8B0B, new QString("SIOCGIWRANGE") ); _map.insert( 0x8B0C, new QString("SIOCSIWPRIV") ); _map.insert( 0x8B0D, new QString("SIOCGIWPRIV") ); _map.insert( 0x8B0E, new QString("SIOCSIWSTATS") ); _map.insert( 0x8B0F, new QString("SIOCGIWSTATS") ); _map.insert( 0x8B10, new QString("SIOCSIWSPY") ); _map.insert( 0x8B11, new QString("SIOCGIWSPY") ); _map.insert( 0x8B14, new QString("SIOCSIWAP") ); _map.insert( 0x8B15, new QString("SIOCGIWAP") ); _map.insert( 0x8B17, new QString("SIOCGIWAPLIST") ); _map.insert( 0x8B18, new QString("SIOCSIWSCAN") ); _map.insert( 0x8B19, new QString("SIOCGIWSCAN") ); _map.insert( 0x8B1A, new QString("SIOCSIWESSID") ); _map.insert( 0x8B1B, new QString("SIOCGIWESSID") ); _map.insert( 0x8B1C, new QString("SIOCSIWNICKN") ); _map.insert( 0x8B1D, new QString("SIOCGIWNICKN") ); _map.insert( 0x8B20, new QString("SIOCSIWRATE") ); _map.insert( 0x8B21, new QString("SIOCGIWRATE") ); _map.insert( 0x8B22, new QString("SIOCSIWRTS") ); _map.insert( 0x8B23, new QString("SIOCGIWRTS") ); _map.insert( 0x8B24, new QString("SIOCSIWFRAG") ); _map.insert( 0x8B25, new QString("SIOCGIWFRAG") ); _map.insert( 0x8B26, new QString("SIOCSIWTXPOW") ); _map.insert( 0x8B27, new QString("SIOCGIWTXPOW") ); _map.insert( 0x8B28, new QString("SIOCSIWRETRY") ); _map.insert( 0x8B29, new QString("SIOCGIWRETRY") ); _map.insert( 0x8B2A, new QString("SIOCSIWENCODE") ); _map.insert( 0x8B2B, new QString("SIOCGIWENCODE") ); _map.insert( 0x8B2C, new QString("SIOCSIWPOWER") ); _map.insert( 0x8B2D, new QString("SIOCGIWPOWER") ); _map.insert( 0x8BE0, new QString("SIOCIWFIRSTPRIV") ); _map.insert( 0x8BFF, new QString("SIOCIWLASTPRIV") ); _map.insert( 0x8B00, new QString("SIOCIWFIRST") ); _map.insert( 0x5000, new QString("SIOCGBPQETHPARAM") ); _map.insert( 0x5001, new QString("SIOCSBPQETHPARAM") ); _map.insert( 0x890B, new QString("SIOCADDRT") ); _map.insert( 0x890C, new QString("SIOCDELRT") ); _map.insert( 0x890D, new QString("SIOCRTMSG") ); _map.insert( 0x8910, new QString("SIOCGIFNAME") ); _map.insert( 0x8911, new QString("SIOCSIFLINK") ); _map.insert( 0x8912, new QString("SIOCGIFCONF") ); _map.insert( 0x8913, new QString("SIOCGIFFLAGS") ); _map.insert( 0x8914, new QString("SIOCSIFFLAGS") ); _map.insert( 0x8915, new QString("SIOCGIFADDR") ); _map.insert( 0x8916, new QString("SIOCSIFADDR") ); _map.insert( 0x8917, new QString("SIOCGIFDSTADDR") ); _map.insert( 0x8918, new QString("SIOCSIFDSTADDR") ); _map.insert( 0x8919, new QString("SIOCGIFBRDADDR") ); _map.insert( 0x891a, new QString("SIOCSIFBRDADDR") ); _map.insert( 0x891b, new QString("SIOCGIFNETMASK") ); _map.insert( 0x891c, new QString("SIOCSIFNETMASK") ); _map.insert( 0x891d, new QString("SIOCGIFMETRIC") ); _map.insert( 0x891e, new QString("SIOCSIFMETRIC") ); _map.insert( 0x891f, new QString("SIOCGIFMEM") ); _map.insert( 0x8920, new QString("SIOCSIFMEM") ); _map.insert( 0x8921, new QString("SIOCGIFMTU") ); _map.insert( 0x8922, new QString("SIOCSIFMTU") ); _map.insert( 0x8923, new QString("SIOCSIFNAME") ); _map.insert( 0x8924, new QString("SIOCSIFHWADDR") ); _map.insert( 0x8925, new QString("SIOCGIFENCAP") ); _map.insert( 0x8926, new QString("SIOCSIFENCAP") ); _map.insert( 0x8927, new QString("SIOCGIFHWADDR") ); _map.insert( 0x8929, new QString("SIOCGIFSLAVE") ); _map.insert( 0x8930, new QString("SIOCSIFSLAVE") ); _map.insert( 0x8931, new QString("SIOCADDMULTI") ); _map.insert( 0x8932, new QString("SIOCDELMULTI") ); _map.insert( 0x8933, new QString("SIOCGIFINDEX") ); _map.insert( 0x8934, new QString("SIOCSIFPFLAGS") ); _map.insert( 0x8935, new QString("SIOCGIFPFLAGS") ); _map.insert( 0x8936, new QString("SIOCDIFADDR") ); _map.insert( 0x8937, new QString("SIOCSIFHWBROADCAST") ); _map.insert( 0x8938, new QString("SIOCGIFCOUNT") ); _map.insert( 0x8940, new QString("SIOCGIFBR") ); _map.insert( 0x8941, new QString("SIOCSIFBR") ); _map.insert( 0x8942, new QString("SIOCGIFTXQLEN") ); _map.insert( 0x8943, new QString("SIOCSIFTXQLEN") ); _map.insert( 0x8944, new QString("SIOCGIFDIVERT") ); _map.insert( 0x8945, new QString("SIOCSIFDIVERT") ); _map.insert( 0x8946, new QString("SIOCETHTOOL") ); _map.insert( 0x8947, new QString("SIOCGMIIPHY") ); _map.insert( 0x8948, new QString("SIOCGMIIREG") ); _map.insert( 0x8949, new QString("SIOCSMIIREG") ); _map.insert( 0x894A, new QString("SIOCWANDEV") ); _map.insert( 0x8953, new QString("SIOCDARP") ); _map.insert( 0x8954, new QString("SIOCGARP") ); _map.insert( 0x8955, new QString("SIOCSARP") ); _map.insert( 0x8960, new QString("SIOCDRARP") ); _map.insert( 0x8961, new QString("SIOCGRARP") ); _map.insert( 0x8962, new QString("SIOCSRARP") ); _map.insert( 0x8970, new QString("SIOCGIFMAP") ); _map.insert( 0x8971, new QString("SIOCSIFMAP") ); _map.insert( 0x8980, new QString("SIOCADDDLCI") ); _map.insert( 0x8981, new QString("SIOCDELDLCI") ); _map.insert( 0x8982, new QString("SIOCGIFVLAN") ); _map.insert( 0x8983, new QString("SIOCSIFVLAN") ); _map.insert( 0x8990, new QString("SIOCBONDENSLAVE") ); _map.insert( 0x8991, new QString("SIOCBONDRELEASE") ); _map.insert( 0x8992, new QString("SIOCBONDSETHWADDR") ); _map.insert( 0x8993, new QString("SIOCBONDSLAVEINFOQUERY") ); _map.insert( 0x8994, new QString("SIOCBONDINFOQUERY") ); _map.insert( 0x8995, new QString("SIOCBONDCHANGEACTIVE") ); _map.insert( 0x89F0, new QString("SIOCDEVPRIVATE") ); _map.insert( 0x89E0, new QString("SIOCPROTOPRIVATE") ); }; DebugMapper::~DebugMapper() { - qDebug( "DebugMapper::~DebugMapper()" ); + odebug << "DebugMapper::~DebugMapper()" << oendl; } const QString& DebugMapper::map( int value ) const { QString* result = _map[ value ]; if ( !result ) { - qDebug( "DebugMapper::map() - value not found." ); + owarn << "DebugMapper::map() - value " << value << " is not found." << oendl; return QString::null; } else { return *result; } } diff --git a/libopie2/opienet/omanufacturerdb.cpp b/libopie2/opienet/omanufacturerdb.cpp index c3c213c..bcce11f 100644 --- a/libopie2/opienet/omanufacturerdb.cpp +++ b/libopie2/opienet/omanufacturerdb.cpp @@ -1,118 +1,131 @@ -/********************************************************************** -** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. -** -** This file is part of Opie Environment. -** -** 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. -** -**********************************************************************/ +/* + This file is part of the Opie Project + (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de> + =. + .=l. + .>+-= + _;:, .> :=|. This program is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU Library General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This program is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU +..}^=.= = ; Library General Public License for more +++= -. .` .: details. + : = ...= . :.=- + -. .:....=;==+<; You should have received a copy of the GNU + -_. . . )=. = Library General Public License along with + -- :-=` this library; see the file COPYING.LIB. + If not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ #include "omanufacturerdb.h" +/* OPIE CORE */ +#include <opie2/odebug.h> + /* QT */ #include <qstring.h> #include <qfile.h> #include <qtextstream.h> OManufacturerDB* OManufacturerDB::_instance = 0; OManufacturerDB* OManufacturerDB::instance() { if ( !OManufacturerDB::_instance ) { - qDebug( "OManufacturerDB::instance(): creating OManufacturerDB..." ); + odebug << "OManufacturerDB::instance(): creating OManufacturerDB..." << oendl; _instance = new OManufacturerDB(); } return _instance; } OManufacturerDB::OManufacturerDB() { QString filename( "/etc/manufacturers" ); - qDebug( "OManufacturerDB: trying to read '%s'...", (const char*) filename ); + odebug << "OManufacturerDB: trying to read " << filename << oendl; if ( !QFile::exists( filename ) ) { filename = "/opt/QtPalmtop/etc/manufacturers"; - qDebug( "OManufacturerDB: trying to read '%s'...", (const char*) filename ); + odebug << "OManufacturerDB: trying to read " << filename << oendl; if ( !QFile::exists( filename ) ) { filename = "/usr/share/wellenreiter/manufacturers"; - qDebug( "OManufacturerDB: trying to read '%s'...", (const char*) filename ); + odebug << "OManufacturerDB: trying to read " << filename << oendl; } } QFile file( filename ); bool hasFile = file.open( IO_ReadOnly ); if (!hasFile) { - qWarning( "OManufacturerDB: no valid manufacturer list found.", (const char*) filename ); + owarn << "OManufacturerDB: no valid manufacturer list found." << oendl; } else { - qDebug( "OManufacturerDB: found manufacturer list in '%s'...", (const char*) filename ); + odebug << "OManufacturerDB: found manufacturer list in " << filename << oendl; QTextStream s( &file ); QString addr; QString manu; QString extManu; while (!s.atEnd()) { s >> addr; if ( !addr ) // read nothing!? { continue; } else if ( addr[0] == '#' ) { continue; } s.skipWhiteSpace(); s >> manu; s.skipWhiteSpace(); s >> extManu; if ( extManu[0] == '#' ) // we have an extended manufacturer { s.skipWhiteSpace(); extManu = s.readLine(); - #ifdef DEBUG - qDebug( "OManufacturerDB: read '%s' as extended manufacturer string", (const char*) extManu ); - #endif + odebug << "OManufacturerDB: read " << extManu << " as extended manufacturer string" << oendl; manufacturersExt.insert( addr, extManu ); } else s.readLine(); - #ifdef DEBUG - qDebug( "ManufacturerDB: read tuple %s, %s", (const char*) addr, (const char*) manu ); - #endif + odebug << "OManufacturerDB: read tuple " << addr << ", " << manu << oendl; manufacturers.insert( addr, manu ); - } } } OManufacturerDB::~OManufacturerDB() { } const QString& OManufacturerDB::lookup( const QString& macaddr ) const { return manufacturers[macaddr.upper().left(8)]; } const QString& OManufacturerDB::lookupExt( const QString& macaddr ) const { QMap<QString,QString>::ConstIterator it = manufacturersExt.find( macaddr.upper().left(8) ); return it == manufacturersExt.end() ? lookup( macaddr ) : *it; } diff --git a/libopie2/opienet/omanufacturerdb.h b/libopie2/opienet/omanufacturerdb.h index 651f624..c2712e5 100644 --- a/libopie2/opienet/omanufacturerdb.h +++ b/libopie2/opienet/omanufacturerdb.h @@ -1,54 +1,69 @@ -/********************************************************************** -** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. -** -** This file is part of Opie Environment. -** -** 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. -** -**********************************************************************/ +/* + This file is part of the Opie Project + (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de> + =. + .=l. + .>+-= + _;:, .> :=|. This program is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU Library General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This program is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU +..}^=.= = ; Library General Public License for more +++= -. .` .: details. + : = ...= . :.=- + -. .:....=;==+<; You should have received a copy of the GNU + -_. . . )=. = Library General Public License along with + -- :-=` this library; see the file COPYING.LIB. + If not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ #ifndef OMANUFACTURERDB_H #define OMANUFACTURERDB_H #include <qmap.h> /** * @brief A Ethernet card vendor database. * * This class encapsulates the lookup of Ethernet vendor given a * certain Mac Address. Only the first three bytes define the vendor. */ class OManufacturerDB { public: /** * @returns the one-and-only @ref OManufacturerDB instance. */ static OManufacturerDB* instance(); /** * @returns the short manufacturer string given a @a macaddr. */ const QString& lookup( const QString& macaddr ) const; /** * @returns the enhanced manufacturer string given a @a macaddr. */ const QString& lookupExt( const QString& macaddr ) const; protected: OManufacturerDB(); virtual ~OManufacturerDB(); private: QMap<QString, QString> manufacturers; QMap<QString, QString> manufacturersExt; static OManufacturerDB* _instance; }; #endif diff --git a/libopie2/opienet/onetutils.cpp b/libopie2/opienet/onetutils.cpp index e3eb327..48cfa43 100644 --- a/libopie2/opienet/onetutils.cpp +++ b/libopie2/opienet/onetutils.cpp @@ -1,232 +1,232 @@ /* This file is part of the Opie Project - (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> + (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de> =. .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <opie2/onetutils.h> #include <opie2/onetwork.h> #include <opie2/omanufacturerdb.h> #include <net/if.h> #include <assert.h> #include <stdio.h> /*====================================================================================== * OMacAddress *======================================================================================*/ // static initializer for broadcast and unknown MAC Adresses const unsigned char __broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; const OMacAddress& OMacAddress::broadcast = OMacAddress( __broadcast ); const unsigned char __unknown[6] = { 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 }; const OMacAddress& OMacAddress::unknown = OMacAddress( __unknown ); //TODO: Incorporate Ethernet Manufacturer database here! (inline or so) OMacAddress::OMacAddress() { memcpy( _bytes, __unknown, 6 ); } OMacAddress::OMacAddress( unsigned char* p ) { memcpy( _bytes, p, 6 ); } OMacAddress::OMacAddress( const unsigned char* p ) { memcpy( _bytes, p, 6 ); } OMacAddress::OMacAddress( struct ifreq& ifr ) { memcpy( _bytes, ifr.ifr_hwaddr.sa_data, 6 ); } OMacAddress::~OMacAddress() { } //#ifdef QT_NO_DEBUG //inline //#endif const unsigned char* OMacAddress::native() const { return (const unsigned char*) &_bytes; } OMacAddress OMacAddress::fromString( const QString& str ) { QString addr( str ); unsigned char buf[6]; bool ok = true; int index = 14; for ( int i = 5; i >= 0; --i ) { buf[i] = addr.right( 2 ).toUShort( &ok, 16 ); if ( !ok ) return OMacAddress::unknown; addr.truncate( index ); index -= 3; } return (const unsigned char*) &buf; } QString OMacAddress::toString( bool substitute ) const { QString manu; manu.sprintf( "%.2X:%.2X:%.2X", _bytes[0]&0xff, _bytes[1]&0xff, _bytes[2]&0xff ); QString serial; serial.sprintf( ":%.2X:%.2X:%.2X", _bytes[3]&0xff, _bytes[4]&0xff, _bytes[5]&0xff ); if ( !substitute ) return manu+serial; // fallback - if no vendor is found, just use the number QString textmanu = OManufacturerDB::instance()->lookup( manu ); return textmanu.isNull() ? manu+serial : textmanu+serial; } QString OMacAddress::manufacturer() const { return OManufacturerDB::instance()->lookupExt( toString() ); } bool operator==( const OMacAddress &m1, const OMacAddress &m2 ) { return memcmp( &m1._bytes, &m2._bytes, 6 ) == 0; } /*====================================================================================== * OHostAddress *======================================================================================*/ /*====================================================================================== * OPrivateIOCTL *======================================================================================*/ OPrivateIOCTL::OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs ) :QObject( parent, name ), _ioctl( cmd ), _getargs( getargs ), _setargs( setargs ) { } OPrivateIOCTL::~OPrivateIOCTL() { } int OPrivateIOCTL::numberGetArgs() const { return _getargs & IW_PRIV_SIZE_MASK; } int OPrivateIOCTL::typeGetArgs() const { return _getargs & IW_PRIV_TYPE_MASK >> 12; } int OPrivateIOCTL::numberSetArgs() const { return _setargs & IW_PRIV_SIZE_MASK; } int OPrivateIOCTL::typeSetArgs() const { return _setargs & IW_PRIV_TYPE_MASK >> 12; } void OPrivateIOCTL::invoke() const { ( (OWirelessNetworkInterface*) parent() )->wioctl( _ioctl ); } void OPrivateIOCTL::setParameter( int num, u_int32_t value ) { u_int32_t* arglist = (u_int32_t*) &( (OWirelessNetworkInterface*) parent() )->_iwr.u.name; arglist[num] = value; } /*====================================================================================== * assorted functions *======================================================================================*/ void dumpBytes( const unsigned char* data, int num ) { printf( "Dumping %d bytes @ %0x", num, data ); printf( "-------------------------------------------\n" ); for ( int i = 0; i < num; ++i ) { printf( "%02x ", data[i] ); if ( !((i+1) % 32) ) printf( "\n" ); } printf( "\n\n" ); } int stringToMode( const QString& mode ) { if ( mode == "auto" ) return IW_MODE_AUTO; else if ( mode == "adhoc" ) return IW_MODE_ADHOC; else if ( mode == "managed" ) return IW_MODE_INFRA; else if ( mode == "master" ) return IW_MODE_MASTER; else if ( mode == "repeater" ) return IW_MODE_REPEAT; else if ( mode == "secondary" ) return IW_MODE_SECOND; else if ( mode == "monitor" ) return IW_MODE_MONITOR; else assert( 0 ); } QString modeToString( int mode ) { switch ( mode ) { case IW_MODE_AUTO: return "auto"; case IW_MODE_ADHOC: return "adhoc"; case IW_MODE_INFRA: return "managed"; case IW_MODE_MASTER: return "master"; case IW_MODE_REPEAT: return "repeater"; case IW_MODE_SECOND: return "second"; case IW_MODE_MONITOR: return "monitor"; default: assert( 0 ); } } diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp index 95c813f..6a9280f 100644 --- a/libopie2/opienet/onetwork.cpp +++ b/libopie2/opienet/onetwork.cpp @@ -1,1190 +1,1188 @@ /* This file is part of the Opie Project - Copyright (C) 2003 by the Wellenreiter team: - Martin J. Muench <mjm@remote-exploit.org> - Max Moser <mmo@remote-exploit.org - Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> + Copyright (C) 2003 by Michael 'Mickey' Lauer <mickey@Vanille.de> =. .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* OPIE */ #include <opie2/onetwork.h> #include <opie2/ostation.h> /* QT */ #include <qfile.h> #include <qtextstream.h> /* UNIX */ #include <assert.h> #include <arpa/inet.h> #include <errno.h> #include <string.h> #include <stdlib.h> #include <math.h> #include <sys/ioctl.h> #include <sys/socket.h> #include <sys/types.h> #include <unistd.h> #include <linux/sockios.h> #include <net/if_arp.h> #include <stdarg.h> #ifndef NODEBUG #include <opie2/odebugmapper.h> DebugMapper* debugmapper = new DebugMapper(); #endif /*====================================================================================== * ONetwork *======================================================================================*/ ONetwork* ONetwork::_instance = 0; ONetwork::ONetwork() { qDebug( "ONetwork::ONetwork()" ); qDebug( "ONetwork: This code has been compiled against Wireless Extensions V%d", WIRELESS_EXT ); synchronize(); } void ONetwork::synchronize() { // gather available interfaces by inspecting /proc/net/dev //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices //FIXME: Best is use SIOCGIFCONF and if this doesn't work (result=-1), then fallback to parsing /proc/net/dev _interfaces.clear(); QString str; QFile f( "/proc/net/dev" ); bool hasFile = f.open( IO_ReadOnly ); if ( !hasFile ) { qDebug( "ONetwork: /proc/net/dev not existing. No network devices available" ); return; } QTextStream s( &f ); s.readLine(); s.readLine(); while ( !s.atEnd() ) { s >> str; str.truncate( str.find( ':' ) ); qDebug( "ONetwork: found interface '%s'", (const char*) str ); ONetworkInterface* iface; if ( isWirelessInterface( str ) ) { iface = new OWirelessNetworkInterface( this, (const char*) str ); qDebug( "ONetwork: interface '%s' has Wireless Extensions", (const char*) str ); } else { iface = new ONetworkInterface( this, (const char*) str ); } _interfaces.insert( str, iface ); s.readLine(); } } short ONetwork::wirelessExtensionVersion() { return WIRELESS_EXT; } int ONetwork::count() const { return _interfaces.count(); } ONetworkInterface* ONetwork::interface( const QString& iface ) const { return _interfaces[iface]; } ONetwork* ONetwork::instance() { if ( !_instance ) _instance = new ONetwork(); return _instance; } ONetwork::InterfaceIterator ONetwork::iterator() const { return ONetwork::InterfaceIterator( _interfaces ); } bool ONetwork::isWirelessInterface( const char* name ) const { int sfd = socket( AF_INET, SOCK_STREAM, 0 ); struct iwreq iwr; memset( &iwr, 0, sizeof( struct iwreq ) ); strcpy( (char*) &iwr.ifr_name, name ); int result = ::ioctl( sfd, SIOCGIWNAME, &iwr ); return result != -1; } /*====================================================================================== * ONetworkInterface *======================================================================================*/ ONetworkInterface::ONetworkInterface( QObject* parent, const char* name ) :QObject( parent, name ), _sfd( socket( AF_INET, SOCK_DGRAM, 0 ) ), _mon( 0 ) { qDebug( "ONetworkInterface::ONetworkInterface()" ); init(); } struct ifreq& ONetworkInterface::ifr() const { return _ifr; } void ONetworkInterface::init() { qDebug( "ONetworkInterface::init()" ); memset( &_ifr, 0, sizeof( struct ifreq ) ); if ( _sfd == -1 ) { qDebug( "ONetworkInterface::init(): Warning - can't get socket for device '%s'", name() ); return; } } bool ONetworkInterface::ioctl( int call, struct ifreq& ifreq ) const { #ifndef NODEBUG int result = ::ioctl( _sfd, call, &ifreq ); if ( result == -1 ) qDebug( "ONetworkInterface::ioctl (%s) call %s (0x%04X) - Status: Failed: %d (%s)", name(), (const char*) debugmapper->map( call ), call, result, strerror( errno ) ); else qDebug( "ONetworkInterface::ioctl (%s) call %s (0x%04X) - Status: Ok.", name(), (const char*) debugmapper->map( call ), call ); return ( result != -1 ); #else return ::ioctl( _sfd, call, &ifreq ) != -1; #endif } bool ONetworkInterface::ioctl( int call ) const { strcpy( _ifr.ifr_name, name() ); return ioctl( call, _ifr ); } bool ONetworkInterface::isLoopback() const { ioctl( SIOCGIFFLAGS ); return _ifr.ifr_flags & IFF_LOOPBACK; } bool ONetworkInterface::setUp( bool b ) { ioctl( SIOCGIFFLAGS ); if ( b ) _ifr.ifr_flags |= IFF_UP; else _ifr.ifr_flags &= (~IFF_UP); return ioctl( SIOCSIFFLAGS ); } bool ONetworkInterface::isUp() const { ioctl( SIOCGIFFLAGS ); return _ifr.ifr_flags & IFF_UP; } void ONetworkInterface::setIPV4Address( const QHostAddress& addr ) { struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr; sa->sin_family = AF_INET; sa->sin_port = 0; sa->sin_addr.s_addr = htonl( addr.ip4Addr() ); ioctl( SIOCSIFADDR ); } QString ONetworkInterface::ipV4Address() const { if ( ioctl( SIOCGIFADDR ) ) { struct sockaddr_in* sa = (struct sockaddr_in *) &_ifr.ifr_addr; //FIXME: Use QHostAddress here return QString( inet_ntoa( sa->sin_addr ) ); } else return "<unknown>"; } void ONetworkInterface::setMacAddress( const OMacAddress& addr ) { _ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER; memcpy( &_ifr.ifr_hwaddr.sa_data, addr.native(), 6 ); ioctl( SIOCSIFHWADDR ); } OMacAddress ONetworkInterface::macAddress() const { if ( ioctl( SIOCGIFHWADDR ) ) { return OMacAddress( _ifr ); } else { return OMacAddress::unknown; } } void ONetworkInterface::setIPV4Netmask( const QHostAddress& addr ) { struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr; sa->sin_family = AF_INET; sa->sin_port = 0; sa->sin_addr.s_addr = htonl( addr.ip4Addr() ); ioctl( SIOCSIFNETMASK ); } QString ONetworkInterface::ipV4Netmask() const { if ( ioctl( SIOCGIFNETMASK ) ) { struct sockaddr_in* sa = (struct sockaddr_in *) &_ifr.ifr_addr; //FIXME: Use QHostAddress here return QString( inet_ntoa( sa->sin_addr ) ); } else return "<unknown>"; } int ONetworkInterface::dataLinkType() const { if ( ioctl( SIOCGIFHWADDR ) ) { return _ifr.ifr_hwaddr.sa_family; } else { return -1; } } void ONetworkInterface::setMonitoring( OMonitoringInterface* m ) { _mon = m; qDebug( "ONetwork::setMonitoring(): Installed monitoring driver '%s' on interface '%s'", (const char*) m->name(), name() ); } OMonitoringInterface* ONetworkInterface::monitoring() const { return _mon; } ONetworkInterface::~ONetworkInterface() { qDebug( "ONetworkInterface::~ONetworkInterface()" ); if ( _sfd != -1 ) ::close( _sfd ); } bool ONetworkInterface::setPromiscuousMode( bool b ) { ioctl( SIOCGIFFLAGS ); if ( b ) _ifr.ifr_flags |= IFF_PROMISC; else _ifr.ifr_flags &= (~IFF_PROMISC); return ioctl( SIOCSIFFLAGS ); } bool ONetworkInterface::promiscuousMode() const { ioctl( SIOCGIFFLAGS ); return _ifr.ifr_flags & IFF_PROMISC; } bool ONetworkInterface::isWireless() const { return ioctl( SIOCGIWNAME ); } /*====================================================================================== * OChannelHopper *======================================================================================*/ OChannelHopper::OChannelHopper( OWirelessNetworkInterface* iface ) :QObject( 0, "Mickey's funky hopper" ), _iface( iface ), _interval( 0 ), _tid( 0 ) { int _maxChannel = iface->channels()+1; // generate fancy hopping sequence honoring the device capabilities if ( _maxChannel >= 1 ) _channels.append( 1 ); if ( _maxChannel >= 7 ) _channels.append( 7 ); if ( _maxChannel >= 13 ) _channels.append( 13 ); if ( _maxChannel >= 2 ) _channels.append( 2 ); if ( _maxChannel >= 8 ) _channels.append( 8 ); if ( _maxChannel >= 3 ) _channels.append( 3 ); if ( _maxChannel >= 14 ) _channels.append( 14 ); if ( _maxChannel >= 9 ) _channels.append( 9 ); if ( _maxChannel >= 4 ) _channels.append( 4 ); if ( _maxChannel >= 10 ) _channels.append( 10 ); if ( _maxChannel >= 5 ) _channels.append( 5 ); if ( _maxChannel >= 11 ) _channels.append( 11 ); if ( _maxChannel >= 6 ) _channels.append( 6 ); if ( _maxChannel >= 12 ) _channels.append( 12 ); _channel = _channels.begin(); } OChannelHopper::~OChannelHopper() { } bool OChannelHopper::isActive() const { return _tid; } int OChannelHopper::channel() const { return *_channel; } void OChannelHopper::timerEvent( QTimerEvent* ) { _iface->setChannel( *_channel ); emit( hopped( *_channel ) ); qDebug( "OChannelHopper::timerEvent(): set channel %d on interface '%s'", *_channel, (const char*) _iface->name() ); if ( ++_channel == _channels.end() ) _channel = _channels.begin(); } void OChannelHopper::setInterval( int interval ) { if ( interval == _interval ) return; if ( _interval ) killTimer( _tid ); _tid = 0; _interval = interval; if ( _interval ) { _tid = startTimer( interval ); } } int OChannelHopper::interval() const { return _interval; } /*====================================================================================== * OWirelessNetworkInterface *======================================================================================*/ OWirelessNetworkInterface::OWirelessNetworkInterface( QObject* parent, const char* name ) :ONetworkInterface( parent, name ), _hopper( 0 ) { qDebug( "OWirelessNetworkInterface::OWirelessNetworkInterface()" ); init(); } OWirelessNetworkInterface::~OWirelessNetworkInterface() { } struct iwreq& OWirelessNetworkInterface::iwr() const { return _iwr; } void OWirelessNetworkInterface::init() { qDebug( "OWirelessNetworkInterface::init()" ); memset( &_iwr, 0, sizeof( struct iwreq ) ); buildInformation(); buildPrivateList(); dumpInformation(); } bool OWirelessNetworkInterface::isAssociated() const { //FIXME: handle different modes return !(associatedAP() == OMacAddress::unknown); } OMacAddress OWirelessNetworkInterface::associatedAP() const { if ( ioctl( SIOCGIWAP ) ) return (const unsigned char*) &_ifr.ifr_hwaddr.sa_data[0]; else return OMacAddress::unknown; } void OWirelessNetworkInterface::buildInformation() { //ML: If you listen carefully enough, you can hear lots of WLAN drivers suck //ML: The HostAP drivers need more than sizeof struct_iw range to complete //ML: SIOCGIWRANGE otherwise they fail with "Invalid Argument Length". //ML: The Wlan-NG drivers on the otherside fail (segfault!) if you allocate //ML: _too much_ space. This is damn shitty crap *sigh* //ML: We allocate a large memory region in RAM and check whether the //ML: driver pollutes this extra space. The complaint will be made on stdout, //ML: so please forward this... struct iwreq wrq; int len = sizeof( struct iw_range )*2; char *buffer = (char*) malloc( len ); //FIXME: Validate if we actually got the memory block memset( buffer, 0, len ); memcpy( wrq.ifr_name, name(), IFNAMSIZ); wrq.u.data.pointer = (caddr_t) buffer; wrq.u.data.length = sizeof( struct iw_range ); wrq.u.data.flags = 0; if ( ::ioctl( _sfd, SIOCGIWRANGE, &wrq ) == -1 ) { qDebug( "OWirelessNetworkInterface::buildInformation(): SIOCGIWRANGE failed (%s) - using default values.", strerror( errno ) ); _channels.insert( 2412, 1 ); // 2.412 GHz _channels.insert( 2417, 2 ); // 2.417 GHz _channels.insert( 2422, 3 ); // 2.422 GHz _channels.insert( 2427, 4 ); // 2.427 GHz _channels.insert( 2432, 5 ); // 2.432 GHz _channels.insert( 2437, 6 ); // 2.437 GHz _channels.insert( 2442, 7 ); // 2.442 GHz _channels.insert( 2447, 8 ); // 2.447 GHz _channels.insert( 2452, 9 ); // 2.452 GHz _channels.insert( 2457, 10 ); // 2.457 GHz _channels.insert( 2462, 11 ); // 2.462 GHz memset( &_range, 0, sizeof( struct iw_range ) ); } else { // <check if the driver overwrites stuff> int max = 0; for ( int r = sizeof( struct iw_range ); r < len; r++ ) if (buffer[r] != 0) max = r; if (max > 0) { qWarning( "OWirelessNetworkInterface::buildInformation(): Driver for wireless interface '%s' sucks!\n" "It overwrote the buffer end with at least %i bytes!\n", name(), max - sizeof( struct iw_range ) ); } // </check if the driver overwrites stuff> struct iw_range range; memcpy( &range, buffer, sizeof range ); qDebug( "OWirelessNetworkInterface::buildInformation(): Interface %s reported to have %d channels.", name(), range.num_frequency ); for ( int i = 0; i < range.num_frequency; ++i ) { int freq = (int) ( double( range.freq[i].m ) * pow( 10.0, range.freq[i].e ) / 1000000.0 ); _channels.insert( freq, i+1 ); } } memcpy( &_range, buffer, sizeof( struct iw_range ) ); qDebug( "OWirelessNetworkInterface::buildInformation(): Information block constructed." ); free(buffer); } void OWirelessNetworkInterface::buildPrivateList() { qDebug( "OWirelessNetworkInterface::buildPrivateList()" ); struct iw_priv_args priv[IW_MAX_PRIV_DEF]; _iwr.u.data.pointer = (char*) &priv; _iwr.u.data.length = IW_MAX_PRIV_DEF; // length in terms of number of (sizeof iw_priv_args), not (sizeof iw_priv_args) itself _iwr.u.data.flags = 0; if ( !wioctl( SIOCGIWPRIV ) ) { qDebug( "OWirelessNetworkInterface::buildPrivateList(): SIOCGIWPRIV failed (%s) - can't get private ioctl information.", strerror( errno ) ); return; } for ( int i = 0; i < _iwr.u.data.length; ++i ) { new OPrivateIOCTL( this, priv[i].name, priv[i].cmd, priv[i].get_args, priv[i].set_args ); } qDebug( "OWirelessNetworkInterface::buildPrivateList(): Private IOCTL list constructed." ); } void OWirelessNetworkInterface::dumpInformation() const { qDebug( "OWirelessNetworkInterface::() -------------- dumping information block ----------------" ); qDebug( " - driver's idea of maximum throughput is %d bps = %d byte/s = %d Kb/s = %f.2 Mb/s", _range.throughput, _range.throughput / 8, _range.throughput / 8 / 1024, float( _range.throughput ) / 8.0 / 1024.0 / 1024.0 ); qDebug( " - driver for '%s' has been compiled against WE V%d (source=V%d)", name(), _range.we_version_compiled, _range.we_version_source ); qDebug( "OWirelessNetworkInterface::() ---------------------------------------------------------" ); } int OWirelessNetworkInterface::channel() const { //FIXME: When monitoring enabled, then use it //FIXME: to gather the current RF channel //FIXME: Until then, get active channel from hopper. if ( _hopper && _hopper->isActive() ) return _hopper->channel(); if ( !wioctl( SIOCGIWFREQ ) ) { return -1; } else { return _channels[ static_cast<int>(double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000) ]; } } void OWirelessNetworkInterface::setChannel( int c ) const { if ( !c ) { qWarning( "OWirelessNetworkInterface::setChannel( 0 ) called - fix your application!" ); return; } if ( !_mon ) { memset( &_iwr, 0, sizeof( struct iwreq ) ); _iwr.u.freq.m = c; _iwr.u.freq.e = 0; wioctl( SIOCSIWFREQ ); } else { _mon->setChannel( c ); } } double OWirelessNetworkInterface::frequency() const { if ( !wioctl( SIOCGIWFREQ ) ) { return -1.0; } else { return double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000000.0; } } int OWirelessNetworkInterface::channels() const { return _channels.count(); } void OWirelessNetworkInterface::setChannelHopping( int interval ) { if ( !_hopper ) _hopper = new OChannelHopper( this ); _hopper->setInterval( interval ); //FIXME: When and by whom will the channel hopper be deleted? //TODO: rely on QObject hierarchy } int OWirelessNetworkInterface::channelHopping() const { return _hopper->interval(); } OChannelHopper* OWirelessNetworkInterface::channelHopper() const { return _hopper; } void OWirelessNetworkInterface::commit() const { wioctl( SIOCSIWCOMMIT ); } void OWirelessNetworkInterface::setMode( const QString& newMode ) { #ifdef FINALIZE QString currentMode = mode(); if ( currentMode == newMode ) return; #endif qDebug( "OWirelessNetworkInterface::setMode(): trying to set mode '%s' (%d)", (const char*) newMode, stringToMode( newMode ) ); _iwr.u.mode = stringToMode( newMode ); if ( _iwr.u.mode != IW_MODE_MONITOR ) { // IWR.U.MODE WIRD DURCH ABFRAGE DES MODE HIER PLATTGEMACHT!!!!!!!!!!!!!!!!!!!!! DEPP! _iwr.u.mode = stringToMode( newMode ); wioctl( SIOCSIWMODE ); // special iwpriv fallback for monitor mode (check if we're really out of monitor mode now) if ( mode() == "monitor" ) { qDebug( "OWirelessNetworkInterface::setMode(): SIOCSIWMODE not sufficient - trying fallback to iwpriv..." ); if ( _mon ) _mon->setEnabled( false ); else qDebug( "ONetwork(): can't switch monitor mode without installed monitoring interface" ); } } else // special iwpriv fallback for monitor mode { if ( wioctl( SIOCSIWMODE ) ) { qDebug( "OWirelessNetworkInterface::setMode(): IW_MODE_MONITOR ok" ); } else { qDebug( "OWirelessNetworkInterface::setMode(): SIOCSIWMODE not working - trying fallback to iwpriv..." ); if ( _mon ) _mon->setEnabled( true ); else qDebug( "ONetwork(): can't switch monitor mode without installed monitoring interface" ); } } } QString OWirelessNetworkInterface::mode() const { memset( &_iwr, 0, sizeof( struct iwreq ) ); if ( !wioctl( SIOCGIWMODE ) ) { return "<unknown>"; } qDebug( "DEBUG: WE's idea of current mode seems to be '%s'", (const char*) modeToString( _iwr.u.mode ) ); // legacy compatible monitor mode check if ( dataLinkType() == ARPHRD_IEEE80211 || dataLinkType() == 802 ) { return "monitor"; } else { return modeToString( _iwr.u.mode ); } } void OWirelessNetworkInterface::setNickName( const QString& nickname ) { _iwr.u.essid.pointer = const_cast<char*>( (const char*) nickname ); _iwr.u.essid.length = nickname.length(); wioctl( SIOCSIWNICKN ); } QString OWirelessNetworkInterface::nickName() const { char str[IW_ESSID_MAX_SIZE]; _iwr.u.data.pointer = &str[0]; _iwr.u.data.length = IW_ESSID_MAX_SIZE; if ( !wioctl( SIOCGIWNICKN ) ) { return "<unknown>"; } else { str[_iwr.u.data.length] = 0x0; // some drivers (e.g. wlan-ng) don't zero-terminate the string return str; } } void OWirelessNetworkInterface::setPrivate( const QString& call, int numargs, ... ) { OPrivateIOCTL* priv = static_cast<OPrivateIOCTL*>( child( (const char*) call ) ); if ( !priv ) { qDebug( "OWirelessNetworkInterface::setPrivate(): interface '%s' does not support private ioctl '%s'", name(), (const char*) call ); return; } if ( priv->numberSetArgs() != numargs ) { qDebug( "OWirelessNetworkInterface::setPrivate(): parameter count not matching. '%s' expects %d arguments, but got %d", (const char*) call, priv->numberSetArgs(), numargs ); return; } qDebug( "OWirelessNetworkInterface::setPrivate(): about to call '%s' on interface '%s'", (const char*) call, name() ); memset( &_iwr, 0, sizeof _iwr ); va_list argp; va_start( argp, numargs ); for ( int i = 0; i < numargs; ++i ) { priv->setParameter( i, va_arg( argp, int ) ); } va_end( argp ); priv->invoke(); } void OWirelessNetworkInterface::getPrivate( const QString& call ) { qWarning( "OWirelessNetworkInterface::getPrivate() is not implemented yet." ); } bool OWirelessNetworkInterface::hasPrivate( const QString& call ) { return child( (const char*) call ); } QString OWirelessNetworkInterface::SSID() const { char str[IW_ESSID_MAX_SIZE]; _iwr.u.essid.pointer = &str[0]; _iwr.u.essid.length = IW_ESSID_MAX_SIZE; if ( !wioctl( SIOCGIWESSID ) ) { return "<unknown>"; } else { return str; } } void OWirelessNetworkInterface::setSSID( const QString& ssid ) { _iwr.u.essid.pointer = const_cast<char*>( (const char*) ssid ); _iwr.u.essid.length = ssid.length(); wioctl( SIOCSIWESSID ); } OStationList* OWirelessNetworkInterface::scanNetwork() { _iwr.u.param.flags = IW_SCAN_DEFAULT; _iwr.u.param.value = 0; if ( !wioctl( SIOCSIWSCAN ) ) { return 0; } OStationList* stations = new OStationList(); int timeout = 1000000; qDebug( "ONetworkInterface::scanNetwork() - scan started." ); bool results = false; struct timeval tv; tv.tv_sec = 0; tv.tv_usec = 250000; // initial timeout ~ 250ms char buffer[IW_SCAN_MAX_DATA]; while ( !results && timeout > 0 ) { timeout -= tv.tv_usec; select( 0, 0, 0, 0, &tv ); _iwr.u.data.pointer = &buffer[0]; _iwr.u.data.flags = 0; _iwr.u.data.length = sizeof buffer; if ( wioctl( SIOCGIWSCAN ) ) { results = true; continue; } else if ( errno == EAGAIN) { qDebug( "ONetworkInterface::scanNetwork() - scan in progress..." ); #if 0 if ( qApp ) { qApp->processEvents( 100 ); continue; } #endif tv.tv_sec = 0; tv.tv_usec = 100000; continue; } } qDebug( "ONetworkInterface::scanNetwork() - scan finished." ); if ( results ) { qDebug( " - result length = %d", _iwr.u.data.length ); if ( !_iwr.u.data.length ) { qDebug( " - no results (empty neighbourhood)" ); return stations; } qDebug( " - results are in!" ); dumpBytes( (const unsigned char*) &buffer[0], _iwr.u.data.length ); // parse results int offset = 0; struct iw_event* we = (struct iw_event*) &buffer[0]; while ( offset < _iwr.u.data.length ) { //const char* cmd = *(*_ioctlmap)[we->cmd]; //if ( !cmd ) cmd = "<unknown>"; qDebug( "reading next event... cmd=%d, len=%d", we->cmd, we->len ); switch (we->cmd) { case SIOCGIWAP: { qDebug( "SIOCGIWAP" ); stations->append( new OStation() ); stations->last()->macAddress = (const unsigned char*) &we->u.ap_addr.sa_data[0]; break; } case SIOCGIWMODE: { qDebug( "SIOCGIWMODE" ); stations->last()->type = modeToString( we->u.mode ); break; } case SIOCGIWFREQ: { qDebug( "SIOCGIWFREQ" ); stations->last()->channel = _channels[ static_cast<int>(double( we->u.freq.m ) * pow( 10.0, we->u.freq.e ) / 1000000) ]; break; } case SIOCGIWESSID: { qDebug( "SIOCGIWESSID" ); stations->last()->ssid = we->u.essid.pointer; break; } case SIOCGIWSENS: qDebug( "SIOCGIWSENS" ); break; case SIOCGIWENCODE: qDebug( "SIOCGIWENCODE" ); break; case IWEVTXDROP: qDebug( "IWEVTXDROP" ); break; /* Packet dropped to excessive retry */ case IWEVQUAL: qDebug( "IWEVQUAL" ); break; /* Quality part of statistics (scan) */ case IWEVCUSTOM: qDebug( "IWEVCUSTOM" ); break; /* Driver specific ascii string */ case IWEVREGISTERED: qDebug( "IWEVREGISTERED" ); break; /* Discovered a new node (AP mode) */ case IWEVEXPIRED: qDebug( "IWEVEXPIRED" ); break; /* Expired a node (AP mode) */ default: qDebug( "unhandled event" ); } offset += we->len; we = (struct iw_event*) &buffer[offset]; } + return stations; return stations; } else { qDebug( " - no results (timeout) :(" ); return stations; } } bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const { #ifndef NODEBUG int result = ::ioctl( _sfd, call, &iwreq ); if ( result == -1 ) qDebug( "ONetworkInterface::wioctl (%s) call %s (0x%04X) - Status: Failed: %d (%s)", name(), (const char*) debugmapper->map( call ), call, result, strerror( errno ) ); else qDebug( "ONetworkInterface::wioctl (%s) call %s (0x%04X) - Status: Ok.", name(), (const char*) debugmapper->map( call ), call ); return ( result != -1 ); #else return ::ioctl( _sfd, call, &iwreq ) != -1; #endif } bool OWirelessNetworkInterface::wioctl( int call ) const { strcpy( _iwr.ifr_name, name() ); return wioctl( call, _iwr ); } /*====================================================================================== * OMonitoringInterface *======================================================================================*/ OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) :_if( static_cast<OWirelessNetworkInterface*>( iface ) ), _prismHeader( prismHeader ) { } OMonitoringInterface::~OMonitoringInterface() { } void OMonitoringInterface::setChannel( int c ) { // use standard WE channel switching protocol memset( &_if->_iwr, 0, sizeof( struct iwreq ) ); _if->_iwr.u.freq.m = c; _if->_iwr.u.freq.e = 0; _if->wioctl( SIOCSIWFREQ ); } void OMonitoringInterface::setEnabled( bool b ) { } /*====================================================================================== * OCiscoMonitoringInterface *======================================================================================*/ OCiscoMonitoringInterface::OCiscoMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) :OMonitoringInterface( iface, prismHeader ) { iface->setMonitoring( this ); } OCiscoMonitoringInterface::~OCiscoMonitoringInterface() { } void OCiscoMonitoringInterface::setEnabled( bool b ) { QString fname; fname.sprintf( "/proc/driver/aironet/%s", (const char*) _if->name() ); QFile f( fname ); if ( !f.exists() ) return; if ( f.open( IO_WriteOnly ) ) { QTextStream s( &f ); s << "Mode: r"; s << "Mode: y"; s << "XmitPower: 1"; } // flushing and closing will be done automatically when f goes out of scope } QString OCiscoMonitoringInterface::name() const { return "cisco"; } void OCiscoMonitoringInterface::setChannel( int ) { // cisco devices automatically switch channels when in monitor mode } /*====================================================================================== * OWlanNGMonitoringInterface *======================================================================================*/ OWlanNGMonitoringInterface::OWlanNGMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) :OMonitoringInterface( iface, prismHeader ) { iface->setMonitoring( this ); } OWlanNGMonitoringInterface::~OWlanNGMonitoringInterface() { } void OWlanNGMonitoringInterface::setEnabled( bool b ) { //FIXME: do nothing if its already in the same mode QString enable = b ? "true" : "false"; QString prism = _prismHeader ? "true" : "false"; QString cmd; cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s prismheader=%s", (const char*) _if->name(), 1, (const char*) enable, (const char*) prism ); system( cmd ); } QString OWlanNGMonitoringInterface::name() const { return "wlan-ng"; } void OWlanNGMonitoringInterface::setChannel( int c ) { //NOTE: Older wlan-ng drivers automatically hopped channels while lnxreq_wlansniff=true. Newer ones don't. QString enable = "true"; //_if->monitorMode() ? "true" : "false"; QString prism = _prismHeader ? "true" : "false"; QString cmd; cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s prismheader=%s", (const char*) _if->name(), c, (const char*) enable, (const char*) prism ); system( cmd ); } /*====================================================================================== * OHostAPMonitoringInterface *======================================================================================*/ OHostAPMonitoringInterface::OHostAPMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) :OMonitoringInterface( iface, prismHeader ) { iface->setMonitoring( this ); } OHostAPMonitoringInterface::~OHostAPMonitoringInterface() { } void OHostAPMonitoringInterface::setEnabled( bool b ) { int monitorCode = _prismHeader ? 1 : 2; if ( b ) { _if->setPrivate( "monitor", 1, monitorCode ); } else { _if->setPrivate( "monitor", 1, 0 ); } } QString OHostAPMonitoringInterface::name() const { return "hostap"; } /*====================================================================================== * OOrinocoNetworkInterface *======================================================================================*/ OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) :OMonitoringInterface( iface, prismHeader ) { iface->setMonitoring( this ); } OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface() { } void OOrinocoMonitoringInterface::setChannel( int c ) { int monitorCode = _prismHeader ? 1 : 2; _if->setPrivate( "monitor", 2, monitorCode, c ); } void OOrinocoMonitoringInterface::setEnabled( bool b ) { // IW_MODE_MONITOR was introduced in Wireless Extensions Version 15 // Wireless Extensions < Version 15 need iwpriv commandos for monitoring // However, as of recent orinoco drivers, IW_MODE_MONITOR is still not supported if ( b ) { setChannel( 1 ); } else { _if->setPrivate( "monitor", 2, 0, 0 ); } } QString OOrinocoMonitoringInterface::name() const { return "orinoco"; } diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h index eb6c86e..bc9e299 100644 --- a/libopie2/opienet/onetwork.h +++ b/libopie2/opienet/onetwork.h @@ -1,542 +1,539 @@ /* This file is part of the Opie Project - Copyright (C) 2003 by the Wellenreiter team: - Martin J. Muench <mjm@remote-exploit.org> - Max Moser <mmo@remote-exploit.org - Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> + Copyright (C) 2003 by Michael 'Mickey' Lauer <mickey@Vanille.de> =. .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef ONETWORK_H #define ONETWORK_H #include "wireless.h" /* OPIE */ #include <opie2/onetutils.h> #include <opie2/ostation.h> /* QT */ #include <qvaluelist.h> #include <qdict.h> #include <qmap.h> #include <qobject.h> #include <qhostaddress.h> class ONetworkInterface; class OWirelessNetworkInterface; class OChannelHopper; class OMonitoringInterface; /*====================================================================================== * ONetwork *======================================================================================*/ /** * @brief A container class for all network interfaces * * This class provides access to all available network interfaces of your computer. * * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> */ class ONetwork : public QObject { Q_OBJECT public: typedef QDict<ONetworkInterface> InterfaceMap; typedef QDictIterator<ONetworkInterface> InterfaceIterator; public: /** * @returns the number of available interfaces */ int count() const; /** * @returns a pointer to the (one and only) @ref ONetwork instance. */ static ONetwork* instance(); /** * @returns an iterator usable for iterating through all network interfaces. */ InterfaceIterator iterator() const; /** * @returns true, if the @a interface supports the wireless extension protocol. */ bool isWirelessInterface( const char* interface ) const; /** * @returns a pointer to the @ref ONetworkInterface object for the specified @a interface or 0, if not found. * @see ONetworkInterface */ ONetworkInterface* interface( const QString& interface ) const; /** * @internal Rebuild the internal interface database * @note Sometimes it might be useful to call this from client code, * e.g. after issuing a cardctl insert */ void synchronize(); /** * @returns the wireless extension version used at compile time. **/ static short wirelessExtensionVersion(); protected: ONetwork(); private: static ONetwork* _instance; InterfaceMap _interfaces; }; /*====================================================================================== * ONetworkInterface *======================================================================================*/ /** * @brief A network interface wrapper. * * This class provides a wrapper for a network interface. All the cumbersume details of * Linux ioctls are hidden under a convenient high-level interface. * @warning Most of the setting methods contained in this class require the appropriate * process permissions to work. * * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> */ class ONetworkInterface : public QObject { friend class OMonitoringInterface; friend class OCiscoMonitoringInterface; friend class OWlanNGMonitoringInterface; friend class OHostAPMonitoringInterface; friend class OOrinocoMonitoringInterface; public: /** * Constructor. Normally you don't create @ref ONetworkInterface objects yourself, * but access them via @ref ONetwork::interface(). */ ONetworkInterface( QObject* parent, const char* name ); /** * Destructor. */ virtual ~ONetworkInterface(); /** * Associates a @a monitoring interface with this network interface. * @note This is currently only useful with @ref OWirelessNetworkInterface objects. */ void setMonitoring( OMonitoringInterface* monitoring ); /** * @returns the currently associated monitoring interface or 0, if no monitoring is associated. */ OMonitoringInterface* monitoring() const; /** * Setting an interface to promiscuous mode enables the device to receive * all packets on the shared medium - as opposed to packets which are addressed to this interface. */ bool setPromiscuousMode( bool ); /** * @returns true if the interface is set to promiscuous mode. */ bool promiscuousMode() const; /** * Setting an interface to up enables it to receive packets. */ bool setUp( bool ); /** * @returns true if the interface is up. */ bool isUp() const; /** * @returns true if the interface is a loopback interface. */ bool isLoopback() const; /** * @returns true if the interface is featuring supports the wireless extension protocol. */ bool isWireless() const; /** * Associate the IP address @ addr with the interface. */ void setIPV4Address( const QHostAddress& addr ); /** * @returns the IPv4 address associated with the interface. */ QString ipV4Address() const; //TODO: make this return an OHostAddress /** * Associate the MAC address @a addr with the interface. * @note It can be necessary to shut down the interface prior to calling this method. * @warning This is not supported by all drivers. */ void setMacAddress( const OMacAddress& addr ); /** * @returns the MAC address associated with the interface. */ OMacAddress macAddress() const; /** * Associate the IPv4 @a netmask with the interface. */ void setIPV4Netmask( const QHostAddress& netmask ); /** * @returns the IPv4 netmask associated with the interface. */ QString ipV4Netmask() const; //TODO: make this return an OHostAddress /** * @returns the data link type currently associated with the interface. * @see #include <net/if_arp.h> for possible values. */ int dataLinkType() const; protected: const int _sfd; mutable ifreq _ifr; OMonitoringInterface* _mon; protected: struct ifreq& ifr() const; virtual void init(); bool ioctl( int call ) const; bool ioctl( int call, struct ifreq& ) const; }; /*====================================================================================== * OChannelHopper *======================================================================================*/ /** * @brief A radio frequency channel hopper. * * This class provides a channel hopper for radio frequencies. A channel hopper frequently * changes the radio frequency channel of its associated @ref OWirelessNetworkInterface. * This is necessary when in monitoring mode and scanning for other devices, because * the radio frequency hardware can only detect packets sent on the same frequency. * * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> */ class OChannelHopper : public QObject { Q_OBJECT public: /** * Constructor. */ OChannelHopper( OWirelessNetworkInterface* ); /** * Destructor. */ virtual ~OChannelHopper(); /** * @returns true, if the channel hopper is hopping channels */ bool isActive() const; /** * @returns the last hopped channel */ int channel() const; /** * Set the channel hopping @a interval. * An interval of 0 deactivates the channel hopper. */ void setInterval( int interval ); /** * @returns the channel hopping interval */ int interval() const; signals: /** * This signal is emitted right after the channel hopper performed a hop */ void hopped( int ); protected: virtual void timerEvent( QTimerEvent* ); private: OWirelessNetworkInterface* _iface; int _interval; int _tid; QValueList<int> _channels; QValueList<int>::Iterator _channel; }; /*====================================================================================== * OWirelessNetworkInterface *======================================================================================*/ /** * @brief A network interface wrapper for interfaces supporting the wireless extensions protocol. * * This class provides a high-level encapsulation of the Linux wireless extension API. * * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> */ class OWirelessNetworkInterface : public ONetworkInterface { friend class OMonitoringInterface; friend class OCiscoMonitoringInterface; friend class OWlanNGMonitoringInterface; friend class OHostAPMonitoringInterface; friend class OOrinocoMonitoringInterface; friend class OPrivateIOCTL; public: /** * Constructor. */ OWirelessNetworkInterface( QObject* parent, const char* name ); /** * Destructor. */ virtual ~OWirelessNetworkInterface(); /** * Setting the @a channel of the interface changes the radio frequency (RF) * of the corresponding wireless network device. * @note Common channel range is within [1-14]. A value of 0 is not allowed. * @see channels() */ virtual void setChannel( int channel ) const; /** * @returns the channel index of the current radio frequency. */ virtual int channel() const; /** * @returns the current radio frequency (in MHz). */ virtual double frequency() const; /** * @returns the number of radio frequency channels for the * corresponding wireless network device. * @note European devices usually have 14 channels, while American typically feature 11 channels. */ virtual int channels() const; /** * Set the IEEE 802.11 operation @a mode. * Valid values are <ul><li>adhoc<li>managed<li>monitor<li>master * @warning Not all drivers support the all modes. * @note You might have to change the SSID to get the operation mode change into effect. */ virtual void setMode( const QString& mode ); /** * @returns the current IEEE 802.11 operation mode. * Possible values are <ul><li>adhoc<li>managed<li>monitor<li>master or <li>unknown * * @note: Important note concerning the 'monitor' mode: * Setting the monitor mode on a wireless network interface enables * listening to IEEE 802.11 data and management frames which normally * are handled by the device firmware. This can be used to detect * other wireless network devices, e.g. Access Points or Ad-hoc stations. * @warning Standard wireless network drives don't support the monitor mode. * @warning You need a patched driver for this to work. * @note Enabling the monitor mode is highly driver dependent and requires * the proper @ref OMonitoringInterface to be associated with the interface. * @see OMonitoringInterface */ virtual QString mode() const; /** * Set the channel hopping @a interval. An @a interval of 0 disables channel hopping. * @see OChannelHopper */ virtual void setChannelHopping( int interval = 0 ); /** * @returns the channel hopping interval or 0, if channel hopping is disabled. */ virtual int channelHopping() const; /** * @returns the @ref OChannelHopper of this interface or 0, if channel hopping has not been activated before */ virtual OChannelHopper* channelHopper() const; /** * Set the station @a nickname. */ virtual void setNickName( const QString& nickname ); /** * @returns the current station nickname. */ virtual QString nickName() const; /** * Invoke the private IOCTL @a command with a @number of parameters on the network interface. * @see OPrivateIOCTL */ virtual void setPrivate( const QString& command, int number, ... ); /** * @returns true if the interface is featuring the private IOCTL @command. */ virtual bool hasPrivate( const QString& command ); virtual void getPrivate( const QString& command ); //FIXME: Implement and document this /** * @returns true if the interface is associated to an access point * @note: This information is only valid if the interface is in managed mode. */ virtual bool isAssociated() const; /** * @returns the MAC address of the Access Point if the device is in infrastructure mode. * @returns a (more or less random) cell ID address if the device is in adhoc mode. */ virtual OMacAddress associatedAP() const; /** * Set the @a ssid (Service Set ID) string. This is used to decide * which network to associate with (use "any" to let the driver decide). */ virtual void setSSID( const QString& ssid ); /** * @returns the current SSID (Service Set ID). */ virtual QString SSID() const; /** * Perform scanning the wireless network neighbourhood. * @note: UNSTABLE API - UNDER CONSTRUCTION - DON'T USE! */ virtual OStationList* scanNetwork(); /** @internal commit pending changes to the driver * */ void commit() const; protected: void buildInformation(); void buildPrivateList(); void dumpInformation() const; virtual void init(); struct iwreq& iwr() const; bool wioctl( int call ) const; bool wioctl( int call, struct iwreq& ) const; protected: mutable struct iwreq _iwr; QMap<int,int> _channels; struct iw_range _range; private: OChannelHopper* _hopper; }; /*====================================================================================== * OMonitoringInterface *======================================================================================*/ class OMonitoringInterface { public: OMonitoringInterface(); OMonitoringInterface( ONetworkInterface*, bool _prismHeader ); virtual ~OMonitoringInterface(); public: virtual void setEnabled( bool ); virtual void setChannel( int ); virtual QString name() const = 0; protected: OWirelessNetworkInterface* _if; bool _prismHeader; }; /*====================================================================================== * OCiscoMonitoring *======================================================================================*/ class OCiscoMonitoringInterface : public OMonitoringInterface { public: OCiscoMonitoringInterface( ONetworkInterface*, bool _prismHeader ); virtual ~OCiscoMonitoringInterface(); virtual void setEnabled( bool ); virtual QString name() const; virtual void setChannel( int ); }; /*====================================================================================== * OWlanNGMonitoringInterface *======================================================================================*/ class OWlanNGMonitoringInterface : public OMonitoringInterface { public: OWlanNGMonitoringInterface( ONetworkInterface*, bool _prismHeader ); virtual ~OWlanNGMonitoringInterface(); public: virtual void setEnabled( bool ); virtual QString name() const; virtual void setChannel( int ); }; /*====================================================================================== * OHostAPMonitoringInterface *======================================================================================*/ class OHostAPMonitoringInterface : public OMonitoringInterface { public: OHostAPMonitoringInterface( ONetworkInterface*, bool _prismHeader ); virtual ~OHostAPMonitoringInterface(); public: virtual void setEnabled( bool ); virtual QString name() const; }; /*====================================================================================== * OOrinocoMonitoringInterface *======================================================================================*/ class OOrinocoMonitoringInterface : public OMonitoringInterface { public: OOrinocoMonitoringInterface( ONetworkInterface*, bool _prismHeader ); virtual ~OOrinocoMonitoringInterface(); public: virtual void setChannel( int ); virtual void setEnabled( bool ); virtual QString name() const; }; #endif // ONETWORK_H diff --git a/libopie2/opienet/opcap.cpp b/libopie2/opienet/opcap.cpp index 6331b2d..635224c 100644 --- a/libopie2/opienet/opcap.cpp +++ b/libopie2/opienet/opcap.cpp @@ -1,1323 +1,1320 @@ /* This file is part of the Opie Project - Copyright (C) 2003 by the Wellenreiter team: - Martin J. Muench <mjm@remote-exploit.org> - Max Moser <mmo@remote-exploit.org - Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> + Copyright (C) 2003 by Michael 'Mickey' Lauer <mickey@Vanille.de> =. .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* OPIE */ #include <opie2/opcap.h> /* QT */ #include <qapplication.h> // don't use oapplication here (will decrease reusability in other projects) #include <qsocketnotifier.h> #include <qobjectlist.h> /* SYSTEM */ #include <sys/time.h> #include <sys/types.h> #include <unistd.h> /* LOCAL */ #include "udp_ports.h" /*====================================================================================== * OPacket *======================================================================================*/ OPacket::OPacket( int datalink, packetheaderstruct header, const unsigned char* data, QObject* parent ) :QObject( parent, "Generic" ), _hdr( header ), _data( data ) { //qDebug( "OPacket::OPacket(): (Len %d, CapLen %d)" /*, ctime((const time_t*) header.ts.tv_sec)*/, header.len, header.caplen ); _end = (unsigned char*) data + header.len; //qDebug( "OPacket::data @ %0x, end @ %0x", data, _end ); switch ( datalink ) { case DLT_EN10MB: qDebug( "OPacket::OPacket(): Received Packet. Datalink = ETHERNET" ); new OEthernetPacket( _end, (const struct ether_header*) data, this ); break; case DLT_IEEE802_11: qDebug( "OPacket::OPacket(): Received Packet. Datalink = IEEE802.11" ); new OWaveLanPacket( _end, (const struct ieee_802_11_header*) data, this ); break; case DLT_PRISM_HEADER: qDebug( "OPacket::OPacket(): Received Packet. Datalink = PRISM_HEADER" ); new OPrismHeaderPacket( _end, (const struct prism_hdr*) (unsigned char*) data, this ); break; default: qWarning( "OPacket::OPacket(): Received Packet over unsupported datalink (type %d)!", datalink ); } } OPacket::~OPacket() { } timevalstruct OPacket::timeval() const { return _hdr.ts; } int OPacket::caplen() const { return _hdr.caplen; } void OPacket::updateStats( QMap<QString,int>& stats, QObjectList* l ) { if (!l) return; QObject* o = l->first(); while ( o ) { stats[o->name()]++; updateStats( stats, const_cast<QObjectList*>( o->children() ) ); o = l->next(); } } void OPacket::dumpStructure( QObjectList* l ) { QString packetString( "[ |" + _dumpStructure( l ) + " ]" ); qDebug( "OPacket::dumpStructure: %s", (const char*) packetString ); } QString OPacket::_dumpStructure( QObjectList* l ) { if (!l) return QString::null; QObject* o = l->first(); QString str(" "); while ( o ) { str.append( o->name() ); str.append( " |" ); str += _dumpStructure( const_cast<QObjectList*>( o->children() ) ); o = l->next(); } return str; } QString OPacket::dump( int bpl ) const { static int index = 0; index++; int len = _hdr.caplen; QString str; str.sprintf( "\n<----- Packet #%04d Len = 0x%X (%d) ----->\n\n", index, len, len ); str.append( "0000: " ); QString tmp; QString bytes; QString chars; for ( int i = 0; i < len; ++i ) { tmp.sprintf( "%02X ", _data[i] ); bytes.append( tmp ); if ( (_data[i] > 31) && (_data[i]<128) ) chars.append( _data[i] ); else chars.append( '.' ); if ( !((i+1) % bpl) ) { str.append( bytes ); str.append( ' ' ); str.append( chars ); str.append( '\n' ); tmp.sprintf( "%04X: ", i+1 ); str.append( tmp ); bytes = ""; chars = ""; } } if ( (len % bpl) ) { str.append( bytes.leftJustify( 1 + 3*bpl ) ); str.append( chars ); } str.append( '\n' ); return str; } int OPacket::len() const { return _hdr.len; } /*====================================================================================== * OEthernetPacket *======================================================================================*/ OEthernetPacket::OEthernetPacket( const unsigned char* end, const struct ether_header* data, QObject* parent ) :QObject( parent, "Ethernet" ), _ether( data ) { qDebug( "Source = %s", (const char*) sourceAddress().toString() ); qDebug( "Destination = %s", (const char*) destinationAddress().toString() ); if ( sourceAddress() == OMacAddress::broadcast ) qDebug( "Source is broadcast address" ); if ( destinationAddress() == OMacAddress::broadcast ) qDebug( "Destination is broadcast address" ); switch ( type() ) { case ETHERTYPE_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break; case ETHERTYPE_ARP: new OARPPacket( end, (const struct myarphdr*) (data+1), this ); break; case ETHERTYPE_REVARP: { qDebug( "OPacket::OPacket(): Received Ethernet Packet : Type = RARP" ); break; } default: qDebug( "OPacket::OPacket(): Received Ethernet Packet : Type = UNKNOWN" ); } } OEthernetPacket::~OEthernetPacket() { } OMacAddress OEthernetPacket::sourceAddress() const { return OMacAddress( _ether->ether_shost ); } OMacAddress OEthernetPacket::destinationAddress() const { return OMacAddress( _ether->ether_dhost ); } int OEthernetPacket::type() const { return ntohs( _ether->ether_type ); } /*====================================================================================== * OIPPacket *======================================================================================*/ OIPPacket::OIPPacket( const unsigned char* end, const struct iphdr* data, QObject* parent ) :QObject( parent, "IP" ), _iphdr( data ) { qDebug( "OIPPacket::OIPPacket(): decoding IP header..." ); //qDebug( "FromAddress: %s", (const char*) inet_ntoa( *src ) ); //qDebug( " ToAddress: %s", (const char*) inet_ntoa( *dst ) ); qDebug( "FromAddress: %s", (const char*) fromIPAddress().toString() ); qDebug( " toAddress: %s", (const char*) toIPAddress().toString() ); switch ( protocol() ) { case IPPROTO_UDP: new OUDPPacket( end, (const struct udphdr*) (data+1), this ); break; case IPPROTO_TCP: new OTCPPacket( end, (const struct tcphdr*) (data+1), this ); break; default: qDebug( "OIPPacket::OIPPacket(): unknown IP protocol type = %d", protocol() ); } } OIPPacket::~OIPPacket() { } QHostAddress OIPPacket::fromIPAddress() const { return EXTRACT_32BITS( &_iphdr->saddr ); } QHostAddress OIPPacket::toIPAddress() const { return EXTRACT_32BITS( &_iphdr->saddr ); } int OIPPacket::tos() const { return _iphdr->tos; } int OIPPacket::len() const { return EXTRACT_16BITS( &_iphdr->tot_len ); } int OIPPacket::id() const { return EXTRACT_16BITS( &_iphdr->id ); } int OIPPacket::offset() const { return EXTRACT_16BITS( &_iphdr->frag_off ); } int OIPPacket::ttl() const { return _iphdr->ttl; } int OIPPacket::protocol() const { return _iphdr->protocol; } int OIPPacket::checksum() const { return EXTRACT_16BITS( &_iphdr->check ); } /*====================================================================================== * OARPPacket *======================================================================================*/ OARPPacket::OARPPacket( const unsigned char* end, const struct myarphdr* data, QObject* parent ) :QObject( parent, "ARP" ), _arphdr( data ) { qDebug( "OARPPacket::OARPPacket(): decoding ARP header..." ); qDebug( "ARP type seems to be %02d - '%s'", EXTRACT_16BITS( &_arphdr->ar_op ), (const char*) type() ); qDebug( "Sender: MAC %s = IP %s", (const char*) senderMacAddress().toString(), (const char*) senderIPV4Address().toString() ); qDebug( "Target: MAC %s = IP %s", (const char*) targetMacAddress().toString(), (const char*) targetIPV4Address().toString() ); } OARPPacket::~OARPPacket() { } QString OARPPacket::type() const { switch ( EXTRACT_16BITS( &_arphdr->ar_op ) ) { case 1: return "REQUEST"; case 2: return "REPLY"; case 3: return "RREQUEST"; case 4: return "RREPLY"; case 8: return "InREQUEST"; case 9: return "InREPLY"; case 10: return "NAK"; default: qWarning( "OARPPacket::type(): invalid ARP type!" ); return "<unknown>"; } } QHostAddress OARPPacket::senderIPV4Address() const { return EXTRACT_32BITS( &_arphdr->ar_sip ); } QHostAddress OARPPacket::targetIPV4Address() const { return EXTRACT_32BITS( &_arphdr->ar_tip ); } OMacAddress OARPPacket::senderMacAddress() const { return OMacAddress( _arphdr->ar_sha ); } OMacAddress OARPPacket::targetMacAddress() const { return OMacAddress( _arphdr->ar_tha ); } /*====================================================================================== * OUDPPacket *======================================================================================*/ OUDPPacket::OUDPPacket( const unsigned char* end, const struct udphdr* data, QObject* parent ) :QObject( parent, "UDP" ), _udphdr( data ) { qDebug( "OUDPPacket::OUDPPacket(): decoding UDP header..." ); qDebug( "fromPort = %d", fromPort() ); qDebug( " toPort = %d", toPort() ); // TODO: Make this a case or a hash if we know more udp protocols if ( fromPort() == UDP_PORT_BOOTPS || fromPort() == UDP_PORT_BOOTPC || toPort() == UDP_PORT_BOOTPS || toPort() == UDP_PORT_BOOTPC ) { qDebug( "seems to be part of a DHCP conversation => creating DHCP packet." ); new ODHCPPacket( end, (const struct dhcp_packet*) (data+1), this ); } } OUDPPacket::~OUDPPacket() { } int OUDPPacket::fromPort() const { return EXTRACT_16BITS( &_udphdr->source ); } int OUDPPacket::toPort() const { return EXTRACT_16BITS( &_udphdr->dest ); } int OUDPPacket::length() const { return EXTRACT_16BITS( &_udphdr->len ); } int OUDPPacket::checksum() const { return EXTRACT_16BITS( &_udphdr->check ); } /*====================================================================================== * ODHCPPacket *======================================================================================*/ ODHCPPacket::ODHCPPacket( const unsigned char* end, const struct dhcp_packet* data, QObject* parent ) :QObject( parent, "DHCP" ), _dhcphdr( data ) { qDebug( "ODHCPPacket::ODHCPPacket(): decoding DHCP information..." ); qDebug( "DHCP opcode seems to be %02d - '%s'", _dhcphdr->op, isRequest() ? "REQUEST" : "REPLY" ); qDebug( "clientAddress: %s", (const char*) clientAddress().toString() ); qDebug( " yourAddress: %s", (const char*) yourAddress().toString() ); qDebug( "serverAddress: %s", (const char*) serverAddress().toString() ); qDebug( " relayAddress: %s", (const char*) relayAddress().toString() ); qDebug( "parsing DHCP options..." ); _type = 0; const unsigned char* option = &_dhcphdr->options[4]; char tag = -1; char len = -1; while ( ( tag = *option++ ) != -1 /* end of option field */ ) { len = *option++; qDebug( "recognized DHCP option #%d, length %d", tag, len ); if ( tag == DHO_DHCP_MESSAGE_TYPE ) _type = *option; option += len; if ( option >= end ) { qWarning( "DHCP parsing ERROR: sanity check says the packet is at its end!" ); break; } } qDebug( "DHCP type seems to be '%s'", (const char*) type() ); } ODHCPPacket::~ODHCPPacket() { } bool ODHCPPacket::isRequest() const { return ( _dhcphdr->op == 01 ); } bool ODHCPPacket::isReply() const { return ( _dhcphdr->op == 02 ); } QString ODHCPPacket::type() const { switch ( _type ) { case 1: return "DISCOVER"; case 2: return "OFFER"; case 3: return "REQUEST"; case 4: return "DECLINE"; case 5: return "ACK"; case 6: return "NAK"; case 7: return "RELEASE"; case 8: return "INFORM"; default: qWarning( "ODHCPPacket::type(): invalid DHCP type (%d) !", _dhcphdr->op ); return "<unknown>"; } } QHostAddress ODHCPPacket::clientAddress() const { return EXTRACT_32BITS( &_dhcphdr->ciaddr ); } QHostAddress ODHCPPacket::yourAddress() const { return EXTRACT_32BITS( &_dhcphdr->yiaddr ); } QHostAddress ODHCPPacket::serverAddress() const { return EXTRACT_32BITS( &_dhcphdr->siaddr ); } QHostAddress ODHCPPacket::relayAddress() const { return EXTRACT_32BITS( &_dhcphdr->giaddr ); } OMacAddress ODHCPPacket::clientMacAddress() const { return OMacAddress( _dhcphdr->chaddr ); } /*====================================================================================== * OTCPPacket *======================================================================================*/ OTCPPacket::OTCPPacket( const unsigned char* end, const struct tcphdr* data, QObject* parent ) :QObject( parent, "TCP" ), _tcphdr( data ) { qDebug( "OTCPPacket::OTCPPacket(): decoding TCP header..." ); } OTCPPacket::~OTCPPacket() { } int OTCPPacket::fromPort() const { return EXTRACT_16BITS( &_tcphdr->source ); } int OTCPPacket::toPort() const { return EXTRACT_16BITS( &_tcphdr->dest ); } int OTCPPacket::seq() const { return EXTRACT_16BITS( &_tcphdr->seq ); } int OTCPPacket::ack() const { return EXTRACT_16BITS( &_tcphdr->ack_seq ); } int OTCPPacket::window() const { return EXTRACT_16BITS( &_tcphdr->window ); } int OTCPPacket::checksum() const { return EXTRACT_16BITS( &_tcphdr->check ); } /*====================================================================================== * OPrismHeaderPacket *======================================================================================*/ OPrismHeaderPacket::OPrismHeaderPacket( const unsigned char* end, const struct prism_hdr* data, QObject* parent ) :QObject( parent, "Prism" ), _header( data ) { qDebug( "OPrismHeaderPacket::OPrismHeaderPacket(): decoding PRISM header..." ); qDebug( "Signal Strength = %d", data->signal.data ); new OWaveLanPacket( end, (const struct ieee_802_11_header*) (data+1), this ); } OPrismHeaderPacket::~OPrismHeaderPacket() { } unsigned int OPrismHeaderPacket::signalStrength() const { return _header->signal.data; } /*====================================================================================== * OWaveLanPacket *======================================================================================*/ OWaveLanPacket::OWaveLanPacket( const unsigned char* end, const struct ieee_802_11_header* data, QObject* parent ) :QObject( parent, "802.11" ), _wlanhdr( data ) { qDebug( "OWaveLanPacket::OWaveLanPacket(): decoding IEEE 802.11 header..." ); qDebug( "type: %0X", type() ); qDebug( "subType: %0X", subType() ); qDebug( "duration: %d", duration() ); qDebug( "powermanagement: %d", usesPowerManagement() ); qDebug( "payload is encrypted: %s", usesWep() ? "yes" : "no" ); qDebug( "MAC1: %s", (const char*) macAddress1().toString() ); qDebug( "MAC2: %s", (const char*) macAddress2().toString() ); qDebug( "MAC3: %s", (const char*) macAddress3().toString() ); qDebug( "MAC4: %s", (const char*) macAddress4().toString() ); switch ( type() ) { case T_MGMT: new OWaveLanManagementPacket( end, (const struct ieee_802_11_mgmt_header*) data, this ); break; case T_DATA: new OWaveLanDataPacket( end, (const struct ieee_802_11_data_header*) data, this ); break; case T_CTRL: new OWaveLanControlPacket( end, (const struct ieee_802_11_control_header*) data, this ); break; default: qDebug( "OWaveLanPacket::OWaveLanPacket(): Warning: Unknown major type '%d'!", type() ); } } OWaveLanPacket::~OWaveLanPacket() { } int OWaveLanPacket::duration() const { return _wlanhdr->duration; } OMacAddress OWaveLanPacket::macAddress1() const { return OMacAddress( _wlanhdr->mac1 ); } OMacAddress OWaveLanPacket::macAddress2() const { return OMacAddress( _wlanhdr->mac2 ); } OMacAddress OWaveLanPacket::macAddress3() const { return OMacAddress( _wlanhdr->mac3 ); } OMacAddress OWaveLanPacket::macAddress4() const { return OMacAddress( _wlanhdr->mac4 ); } int OWaveLanPacket::subType() const { return FC_SUBTYPE( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); } int OWaveLanPacket::type() const { return FC_TYPE( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); } int OWaveLanPacket::version() const { return FC_VERSION( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); } bool OWaveLanPacket::fromDS() const { return FC_FROM_DS( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); } bool OWaveLanPacket::toDS() const { return FC_TO_DS( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); } bool OWaveLanPacket::usesPowerManagement() const { return FC_POWER_MGMT( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); } bool OWaveLanPacket::usesWep() const { return FC_WEP( EXTRACT_LE_16BITS( &_wlanhdr->frame_control ) ); } /*====================================================================================== * OWaveLanManagementPacket *======================================================================================*/ OWaveLanManagementPacket::OWaveLanManagementPacket( const unsigned char* end, const struct ieee_802_11_mgmt_header* data, OWaveLanPacket* parent ) :QObject( parent, "802.11 Management" ), _header( data ), _body( (const struct ieee_802_11_mgmt_body*) (data+1) ) { qDebug( "OWaveLanManagementPacket::OWaveLanManagementPacket(): decoding frame..." ); qDebug( "Detected subtype is '%s'", (const char*) managementType() ); // grab tagged values const unsigned char* ptr = (const unsigned char*) (_body+1); while (ptr < end) { switch ( *ptr ) { case E_SSID: new OWaveLanManagementSSID( end, (struct ssid_t*) ptr, this ); break; case E_FH: new OWaveLanManagementFH( end, (struct fh_t*) ptr, this ); break; case E_DS: new OWaveLanManagementDS( end, (struct ds_t*) ptr, this ); break; case E_RATES: new OWaveLanManagementRates( end, (struct rates_t*) ptr, this ); break; case E_CF: new OWaveLanManagementCF( end, (struct cf_t*) ptr, this ); break; case E_TIM: new OWaveLanManagementTim( end, (struct tim_t*) ptr, this ); break; case E_IBSS: new OWaveLanManagementIBSS( end, (struct ibss_t*) ptr, this ); break; case E_CHALLENGE: new OWaveLanManagementChallenge( end, (struct challenge_t*) ptr, this ); break; } ptr+= ( ( struct ssid_t* ) ptr )->length; // skip length of tagged value ptr+= 2; // skip tag ID and length } } OWaveLanManagementPacket::~OWaveLanManagementPacket() { } QString OWaveLanManagementPacket::managementType() const { switch ( FC_SUBTYPE( EXTRACT_LE_16BITS( &_header->fc ) ) ) { case ST_ASSOC_REQUEST: return "AssociationRequest"; break; case ST_ASSOC_RESPONSE: return "AssociationResponse"; break; case ST_REASSOC_REQUEST: return "ReassociationRequest"; break; case ST_REASSOC_RESPONSE: return "ReassociationResponse"; break; case ST_PROBE_REQUEST: return "ProbeRequest"; break; case ST_PROBE_RESPONSE: return "ProbeResponse"; break; case ST_BEACON: return "Beacon"; break; case ST_ATIM: return "Atim"; break; case ST_DISASSOC: return "Disassociation"; break; case ST_AUTH: return "Authentication"; break; case ST_DEAUTH: return "Deathentication"; break; default: qWarning( "OWaveLanManagementPacket::managementType(): unhandled subtype %d", FC_SUBTYPE( EXTRACT_LE_16BITS( &_header->fc ) ) ); return "Unknown"; } } int OWaveLanManagementPacket::beaconInterval() const { return EXTRACT_LE_16BITS( &_body->beacon_interval ); } int OWaveLanManagementPacket::capabilities() const { return EXTRACT_LE_16BITS( &_body->capability_info ); } bool OWaveLanManagementPacket::canESS() const { return CAPABILITY_ESS( EXTRACT_LE_16BITS( &_body->capability_info ) ); } bool OWaveLanManagementPacket::canIBSS() const { return CAPABILITY_IBSS( EXTRACT_LE_16BITS( &_body->capability_info ) ); } bool OWaveLanManagementPacket::canCFP() const { return CAPABILITY_CFP( EXTRACT_LE_16BITS( &_body->capability_info ) ); } bool OWaveLanManagementPacket::canCFP_REQ() const { return CAPABILITY_CFP_REQ( EXTRACT_LE_16BITS( &_body->capability_info ) ); } bool OWaveLanManagementPacket::canPrivacy() const { return CAPABILITY_PRIVACY( EXTRACT_LE_16BITS( &_body->capability_info ) ); } /*====================================================================================== * OWaveLanManagementSSID *======================================================================================*/ OWaveLanManagementSSID::OWaveLanManagementSSID( const unsigned char* end, const struct ssid_t* data, QObject* parent ) :QObject( parent, "802.11 SSID" ), _data( data ) { qDebug( "OWaveLanManagementSSID()" ); } OWaveLanManagementSSID::~OWaveLanManagementSSID() { } QString OWaveLanManagementSSID::ID() const { int length = _data->length; if ( length > 32 ) length = 32; char essid[length+1]; memcpy( &essid, &_data->ssid, length ); essid[length] = 0x0; return essid; } /*====================================================================================== * OWaveLanManagementRates *======================================================================================*/ OWaveLanManagementRates::OWaveLanManagementRates( const unsigned char* end, const struct rates_t* data, QObject* parent ) :QObject( parent, "802.11 Rates" ), _data( data ) { qDebug( "OWaveLanManagementRates()" ); } OWaveLanManagementRates::~OWaveLanManagementRates() { } /*====================================================================================== * OWaveLanManagementCF *======================================================================================*/ OWaveLanManagementCF::OWaveLanManagementCF( const unsigned char* end, const struct cf_t* data, QObject* parent ) :QObject( parent, "802.11 CF" ), _data( data ) { qDebug( "OWaveLanManagementCF()" ); } OWaveLanManagementCF::~OWaveLanManagementCF() { } /*====================================================================================== * OWaveLanManagementFH *======================================================================================*/ OWaveLanManagementFH::OWaveLanManagementFH( const unsigned char* end, const struct fh_t* data, QObject* parent ) :QObject( parent, "802.11 FH" ), _data( data ) { qDebug( "OWaveLanManagementFH()" ); } OWaveLanManagementFH::~OWaveLanManagementFH() { } /*====================================================================================== * OWaveLanManagementDS *======================================================================================*/ OWaveLanManagementDS::OWaveLanManagementDS( const unsigned char* end, const struct ds_t* data, QObject* parent ) :QObject( parent, "802.11 DS" ), _data( data ) { qDebug( "OWaveLanManagementDS()" ); } OWaveLanManagementDS::~OWaveLanManagementDS() { } int OWaveLanManagementDS::channel() const { return _data->channel; } /*====================================================================================== * OWaveLanManagementTim *======================================================================================*/ OWaveLanManagementTim::OWaveLanManagementTim( const unsigned char* end, const struct tim_t* data, QObject* parent ) :QObject( parent, "802.11 Tim" ), _data( data ) { qDebug( "OWaveLanManagementTim()" ); } OWaveLanManagementTim::~OWaveLanManagementTim() { } /*====================================================================================== * OWaveLanManagementIBSS *======================================================================================*/ OWaveLanManagementIBSS::OWaveLanManagementIBSS( const unsigned char* end, const struct ibss_t* data, QObject* parent ) :QObject( parent, "802.11 IBSS" ), _data( data ) { qDebug( "OWaveLanManagementIBSS()" ); } OWaveLanManagementIBSS::~OWaveLanManagementIBSS() { } /*====================================================================================== * OWaveLanManagementChallenge *======================================================================================*/ OWaveLanManagementChallenge::OWaveLanManagementChallenge( const unsigned char* end, const struct challenge_t* data, QObject* parent ) :QObject( parent, "802.11 Challenge" ), _data( data ) { qDebug( "OWaveLanManagementChallenge()" ); } OWaveLanManagementChallenge::~OWaveLanManagementChallenge() { } /*====================================================================================== * OWaveLanDataPacket *======================================================================================*/ OWaveLanDataPacket::OWaveLanDataPacket( const unsigned char* end, const struct ieee_802_11_data_header* data, OWaveLanPacket* parent ) :QObject( parent, "802.11 Data" ), _header( data ) { qDebug( "OWaveLanDataPacket::OWaveLanDataPacket(): decoding frame..." ); const unsigned char* payload = (const unsigned char*) data + sizeof( struct ieee_802_11_data_header ); #warning The next line works for most cases, but can not be correct generally! if (!( ( (OWaveLanPacket*) this->parent())->duration() )) payload -= 6; // compensation for missing last address new OLLCPacket( end, (const struct ieee_802_11_802_2_header*) payload, this ); } OWaveLanDataPacket::~OWaveLanDataPacket() { } /*====================================================================================== * OLLCPacket *======================================================================================*/ OLLCPacket::OLLCPacket( const unsigned char* end, const struct ieee_802_11_802_2_header* data, QObject* parent ) :QObject( parent, "802.11 LLC" ), _header( data ) { qDebug( "OLLCPacket::OLLCPacket(): decoding frame..." ); if ( !(_header->oui[0] || _header->oui[1] || _header->oui[2]) ) { qDebug( "OLLCPacket::OLLCPacket(): contains an encapsulated Ethernet frame (type=%04X)", EXTRACT_16BITS( &_header->type ) ); switch ( EXTRACT_16BITS( &_header->type ) ) // defined in linux/if_ether.h { case ETH_P_IP: new OIPPacket( end, (const struct iphdr*) (data+1), this ); break; case ETH_P_ARP: new OARPPacket( end, (const struct myarphdr*) (data+1), this ); break; default: qWarning( "OLLCPacket::OLLCPacket(): Unknown Encapsulation (type=%04X)", EXTRACT_16BITS( &_header->type ) ); } } } OLLCPacket::~OLLCPacket() { } /*====================================================================================== * OWaveLanControlPacket *======================================================================================*/ OWaveLanControlPacket::OWaveLanControlPacket( const unsigned char* end, const struct ieee_802_11_control_header* data, OWaveLanPacket* parent ) :QObject( parent, "802.11 Control" ), _header( data ) { qDebug( "OWaveLanControlPacket::OWaveLanDataControl(): decoding frame..." ); //TODO: Implement this } OWaveLanControlPacket::~OWaveLanControlPacket() { } /*====================================================================================== * OPacketCapturer *======================================================================================*/ OPacketCapturer::OPacketCapturer( QObject* parent, const char* name ) :QObject( parent, name ), _name( QString::null ), _open( false ), _pch( 0 ), _pcd( 0 ), _sn( 0 ) { } OPacketCapturer::~OPacketCapturer() { if ( _open ) { qDebug( "OPacketCapturer::~OPacketCapturer(): pcap still open, autoclosing." ); close(); } } void OPacketCapturer::setBlocking( bool b ) { if ( pcap_setnonblock( _pch, 1-b, _errbuf ) != -1 ) { qDebug( "OPacketCapturer::setBlocking(): blocking mode changed successfully." ); } else { qDebug( "OPacketCapturer::setBlocking(): can't change blocking mode: %s", _errbuf ); } } bool OPacketCapturer::blocking() const { int b = pcap_getnonblock( _pch, _errbuf ); if ( b == -1 ) { qDebug( "OPacketCapturer::blocking(): can't get blocking mode: %s", _errbuf ); return -1; } return !b; } void OPacketCapturer::closeDumpFile() { if ( _pcd ) { pcap_dump_close( _pcd ); _pcd = 0; } pcap_close( _pch ); } void OPacketCapturer::close() { if ( _open ) { if ( _sn ) { _sn->disconnect( SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) ); delete _sn; } closeDumpFile(); _open = false; } qDebug( "OPacketCapturer::close() --- dumping capturing statistics..." ); qDebug( "--------------------------------------------------" ); for( QMap<QString,int>::Iterator it = _stats.begin(); it != _stats.end(); ++it ) qDebug( "%s : %d", (const char*) it.key(), it.data() ); qDebug( "--------------------------------------------------" ); } int OPacketCapturer::dataLink() const { return pcap_datalink( _pch ); } void OPacketCapturer::dump( OPacket* p ) { if ( !_pcd ) { qWarning( "OPacketCapturer::dump() - cannot dump without open capture file!" ); return; } pcap_dump( (u_char*) _pcd, &p->_hdr, p->_data ); } int OPacketCapturer::fileno() const { if ( _open ) { return pcap_fileno( _pch ); } else { return -1; } } OPacket* OPacketCapturer::next( int time ) { fd_set fds; struct timeval tv; FD_ZERO( &fds ); FD_SET( pcap_fileno( _pch ), &fds ); tv.tv_sec = time / 1000; tv.tv_usec = time % 1000; int retval = select( pcap_fileno( _pch )+1, &fds, NULL, NULL, &tv); if ( retval > 0 ) // clear to read! return next(); else return 0; } OPacket* OPacketCapturer::next() { packetheaderstruct header; qDebug( "==> OPacketCapturer::next()" ); const unsigned char* pdata = pcap_next( _pch, &header ); qDebug( "<== OPacketCapturer::next()" ); if ( pdata && header.len ) { OPacket* p = new OPacket( dataLink(), header, pdata, 0 ); // packets shouldn't be inserted in the QObject child-parent hierarchy, // because due to memory constraints they will be deleted as soon // as possible - that is right after they have been processed // by emit() [ see below ] //TODO: make gathering statistics optional, because it takes time p->updateStats( _stats, const_cast<QObjectList*>( p->children() ) ); #ifndef NODEBUG p->dumpStructure( const_cast<QObjectList*>( p->children() ) ); #endif return p; } else { qWarning( "OPacketCapturer::next() - no packet received!" ); return 0; } } bool OPacketCapturer::open( const QString& name ) { if ( _open ) { if ( name == _name ) // ignore opening an already openend device { return true; } else // close the last opened device { close(); } } _name = name; // open libpcap pcap_t* handle = pcap_open_live( const_cast<char*>( (const char*) name ), 1024, 0, 0, &_errbuf[0] ); if ( !handle ) { qWarning( "OPacketCapturer::open(): can't open libpcap with '%s': %s", (const char*) name, _errbuf ); return false; } qDebug( "OPacketCapturer::open(): libpcap [%s] opened successfully.", (const char*) name ); _pch = handle; _open = true; _stats.clear(); // in case we have an application object, create a socket notifier if ( qApp ) //TODO: I don't like this here... { _sn = new QSocketNotifier( fileno(), QSocketNotifier::Read ); connect( _sn, SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) ); } return true; } bool OPacketCapturer::openDumpFile( const QString& filename ) { pcap_dumper_t* dump = pcap_dump_open( _pch, const_cast<char*>( (const char*) filename ) ); if ( !dump ) { qWarning( "OPacketCapturer::open(): can't open dump with '%s': %s", (const char*) filename, _errbuf ); return false; } qDebug( "OPacketCapturer::open(): dump [%s] opened successfully.", (const char*) filename ); _pcd = dump; return true; } bool OPacketCapturer::open( const QFile& file ) { QString name = file.name(); if ( _open ) { close(); if ( name == _name ) // ignore opening an already openend device { return true; } else // close the last opened device { close(); } } _name = name; pcap_t* handle = pcap_open_offline( const_cast<char*>( (const char*) name ), &_errbuf[0] ); if ( handle ) { qDebug( "OPacketCapturer::open(): libpcap opened successfully." ); _pch = handle; _open = true; // in case we have an application object, create a socket notifier if ( qApp ) { _sn = new QSocketNotifier( fileno(), QSocketNotifier::Read ); connect( _sn, SIGNAL( activated(int) ), this, SLOT( readyToReceive() ) ); } return true; } else { qDebug( "OPacketCapturer::open(): can't open libpcap with '%s': %s", (const char*) name, _errbuf ); return false; } } bool OPacketCapturer::isOpen() const { return _open; } void OPacketCapturer::readyToReceive() { qDebug( "OPacketCapturer::readyToReceive(): about to emit 'receivePacket(p)'" ); OPacket* p = next(); emit receivedPacket( p ); // emit is synchronous - packet has been dealt with, now it's safe to delete delete p; } const QMap<QString,int>& OPacketCapturer::statistics() const { return _stats; } int OPacketCapturer::snapShot() const { return pcap_snapshot( _pch ); } bool OPacketCapturer::swapped() const { return pcap_is_swapped( _pch ); } QString OPacketCapturer::version() const { return QString().sprintf( "%s.%s", pcap_major_version( _pch ), pcap_minor_version( _pch ) ); } diff --git a/libopie2/opienet/opcap.h b/libopie2/opienet/opcap.h index 54b256b..497fd6b 100644 --- a/libopie2/opienet/opcap.h +++ b/libopie2/opienet/opcap.h @@ -1,667 +1,664 @@ /* This file is part of the Opie Project - Copyright (C) 2003 by the Wellenreiter team: - Martin J. Muench <mjm@remote-exploit.org> - Max Moser <mmo@remote-exploit.org - Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> + Copyright (C) 2003 by Michael 'Mickey' Lauer <mickey@Vanille.de> =. .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef OPCAP_H #define OPCAP_H /* LINUX */ extern "C" // work around a bpf/pcap conflict in recent headers { #include <pcap.h> } #include <netinet/ether.h> #include <netinet/ip.h> #include <netinet/udp.h> #include <netinet/tcp.h> #include <time.h> /* QT */ #include <qevent.h> #include <qfile.h> #include <qhostaddress.h> #include <qobject.h> #include <qstring.h> #include <qmap.h> /* OPIE */ #include <opie2/onetutils.h> /* Custom Network Includes */ #include "802_11_user.h" #include "dhcp.h" /* TYPEDEFS */ typedef struct timeval timevalstruct; typedef struct pcap_pkthdr packetheaderstruct; /* FORWARDS */ class OPacketCapturer; class QSocketNotifier; /*====================================================================================== * OPacket - A frame on the wire *======================================================================================*/ /** @brief A class representing a data frame on the wire. * * The whole family of the packet classes are used when capturing frames from a network. * Most standard network protocols in use share a common architecture, which mostly is * a packet header and then the packet payload. In layered architectures, each lower layer * encapsulates data from its upper layer - that is it * treats the data from its upper layer as payload and prepends an own header to the packet, * which - again - is treated as the payload for the layer below. The figure below is an * example for how such a data frame is composed out of packets, e.g. when sending a mail. * * <pre> * | User Data | == Mail Data * | SMTP Header | User Data | == SMTP * | TCP Header | SMTP Header | User Data | == TCP * | IP Header | TCP Header | SMTP Header | User Data | == IP * | MAC Header | IP Header | TCP Header | SMTP Header | User Data | == MAC * * </pre> * * The example is trimmed for simplicity, because the MAC (Medium Access Control) layer * also contains a few more levels of encapsulation. * Since the type of the payload is more or less independent from the encapsulating protocol, * the header must be inspected before attempting to decode the payload. Hence, the * encapsulation level varies and can't be deduced without actually looking into the packets. * * For actually working with captured frames, it's useful to identify the packets via names and * insert them into a parent/child - relationship based on the encapsulation. This is why * all packet classes derive from QObject. The amount of overhead caused by the QObject is * not a problem in this case, because we're talking about a theoratical maximum of about * 10 packets per captured frame. We need to stuff them into a searchable list anyway and the * QObject also cares about destroying the sub-, (child-) packets. * * This enables us to perform a simple look for packets of a certain type: * @code * OPacketCapturer* pcap = new OPacketCapturer(); * pcap->open( "eth0" ); * OPacket* p = pcap->next(); * OIPPacket* ip = (OIPPacket*) p->child( "IP" ); // returns 0, if no such child exists * odebug << "got ip packet from " << ip->fromIPAddress().toString() << " to " << ip->toIPAddress().toString() << oendl; * */ class OPacket : public QObject { Q_OBJECT friend class OPacketCapturer; public: OPacket( int datalink, packetheaderstruct, const unsigned char*, QObject* parent ); virtual ~OPacket(); timevalstruct timeval() const; int caplen() const; int len() const; QString dump( int = 32 ) const; void updateStats( QMap<QString,int>&, QObjectList* ); private: void dumpStructure( QObjectList* ); QString _dumpStructure( QObjectList* ); private: const packetheaderstruct _hdr; // pcap packet header const unsigned char* _data; // pcap packet data const unsigned char* _end; // end of pcap packet data }; /*====================================================================================== * OEthernetPacket - DLT_EN10MB frame *======================================================================================*/ class OEthernetPacket : public QObject { Q_OBJECT public: OEthernetPacket( const unsigned char*, const struct ether_header*, QObject* parent = 0 ); virtual ~OEthernetPacket(); OMacAddress sourceAddress() const; OMacAddress destinationAddress() const; int type() const; private: const struct ether_header* _ether; }; /*====================================================================================== * OPrismHeaderPacket - DLT_PRISM_HEADER frame *======================================================================================*/ class OPrismHeaderPacket : public QObject { Q_OBJECT public: OPrismHeaderPacket( const unsigned char*, const struct prism_hdr*, QObject* parent = 0 ); virtual ~OPrismHeaderPacket(); unsigned int signalStrength() const; private: const struct prism_hdr* _header; }; /*====================================================================================== * OWaveLanPacket - DLT_IEEE802_11 frame *======================================================================================*/ class OWaveLanPacket : public QObject { Q_OBJECT public: OWaveLanPacket( const unsigned char*, const struct ieee_802_11_header*, QObject* parent = 0 ); virtual ~OWaveLanPacket(); int duration() const; bool fromDS() const; bool toDS() const; virtual OMacAddress macAddress1() const; virtual OMacAddress macAddress2() const; virtual OMacAddress macAddress3() const; virtual OMacAddress macAddress4() const; bool usesPowerManagement() const; int type() const; int subType() const; int version() const; bool usesWep() const; private: const struct ieee_802_11_header* _wlanhdr; }; /*====================================================================================== * OWaveLanManagementPacket - type: management (T_MGMT) *======================================================================================*/ class OWaveLanManagementPacket : public QObject { Q_OBJECT public: OWaveLanManagementPacket( const unsigned char*, const struct ieee_802_11_mgmt_header*, OWaveLanPacket* parent = 0 ); virtual ~OWaveLanManagementPacket(); QString managementType() const; int beaconInterval() const; int capabilities() const; // generic bool canESS() const; bool canIBSS() const; bool canCFP() const; bool canCFP_REQ() const; bool canPrivacy() const; private: const struct ieee_802_11_mgmt_header* _header; const struct ieee_802_11_mgmt_body* _body; }; /*====================================================================================== * OWaveLanManagementSSID *======================================================================================*/ class OWaveLanManagementSSID : public QObject { Q_OBJECT public: OWaveLanManagementSSID( const unsigned char*, const struct ssid_t*, QObject* parent = 0 ); virtual ~OWaveLanManagementSSID(); QString ID() const; private: const struct ssid_t* _data; }; /*====================================================================================== * OWaveLanManagementRates *======================================================================================*/ class OWaveLanManagementRates : public QObject { Q_OBJECT public: OWaveLanManagementRates( const unsigned char*, const struct rates_t*, QObject* parent = 0 ); virtual ~OWaveLanManagementRates(); private: const struct rates_t* _data; }; /*====================================================================================== * OWaveLanManagementCF *======================================================================================*/ class OWaveLanManagementCF : public QObject { Q_OBJECT public: OWaveLanManagementCF( const unsigned char*, const struct cf_t*, QObject* parent = 0 ); virtual ~OWaveLanManagementCF(); private: const struct cf_t* _data; }; /*====================================================================================== * OWaveLanManagementFH *======================================================================================*/ class OWaveLanManagementFH : public QObject { Q_OBJECT public: OWaveLanManagementFH( const unsigned char*, const struct fh_t*, QObject* parent = 0 ); virtual ~OWaveLanManagementFH(); private: const struct fh_t* _data; }; /*====================================================================================== * OWaveLanManagementDS *======================================================================================*/ class OWaveLanManagementDS : public QObject { Q_OBJECT public: OWaveLanManagementDS( const unsigned char*, const struct ds_t*, QObject* parent = 0 ); virtual ~OWaveLanManagementDS(); int channel() const; private: const struct ds_t* _data; }; /*====================================================================================== * OWaveLanManagementTim *======================================================================================*/ class OWaveLanManagementTim : public QObject { Q_OBJECT public: OWaveLanManagementTim( const unsigned char*, const struct tim_t*, QObject* parent = 0 ); virtual ~OWaveLanManagementTim(); private: const struct tim_t* _data; }; /*====================================================================================== * OWaveLanManagementIBSS *======================================================================================*/ class OWaveLanManagementIBSS : public QObject { Q_OBJECT public: OWaveLanManagementIBSS( const unsigned char*, const struct ibss_t*, QObject* parent = 0 ); virtual ~OWaveLanManagementIBSS(); private: const struct ibss_t* _data; }; /*====================================================================================== * OWaveLanManagementChallenge *======================================================================================*/ class OWaveLanManagementChallenge : public QObject { Q_OBJECT public: OWaveLanManagementChallenge( const unsigned char*, const struct challenge_t*, QObject* parent = 0 ); virtual ~OWaveLanManagementChallenge(); private: const struct challenge_t* _data; }; /*====================================================================================== * OWaveLanDataPacket - type: data (T_DATA) *======================================================================================*/ class OWaveLanDataPacket : public QObject { Q_OBJECT public: OWaveLanDataPacket( const unsigned char*, const struct ieee_802_11_data_header*, OWaveLanPacket* parent = 0 ); virtual ~OWaveLanDataPacket(); private: const struct ieee_802_11_data_header* _header; }; /*====================================================================================== * OWaveLanControlPacket - type: control (T_CTRL) *======================================================================================*/ class OWaveLanControlPacket : public QObject { Q_OBJECT public: OWaveLanControlPacket( const unsigned char*, const struct ieee_802_11_control_header*, OWaveLanPacket* parent = 0 ); virtual ~OWaveLanControlPacket(); private: const struct ieee_802_11_control_header* _header; }; /*====================================================================================== * OLLCPacket - IEEE 802.2 Link Level Control *======================================================================================*/ class OLLCPacket : public QObject { Q_OBJECT public: OLLCPacket( const unsigned char*, const struct ieee_802_11_802_2_header* data, QObject* parent = 0 ); virtual ~OLLCPacket(); private: const struct ieee_802_11_802_2_header* _header; }; /*====================================================================================== * OIPPacket *======================================================================================*/ class OIPPacket : public QObject { Q_OBJECT public: OIPPacket( const unsigned char*, const struct iphdr*, QObject* parent = 0 ); virtual ~OIPPacket(); QHostAddress fromIPAddress() const; QHostAddress toIPAddress() const; int tos() const; int len() const; int id() const; int offset() const; int ttl() const; int protocol() const; int checksum() const; private: const struct iphdr* _iphdr; }; /*====================================================================================== * OARPPacket *======================================================================================*/ class OARPPacket : public QObject { Q_OBJECT public: OARPPacket( const unsigned char*, const struct myarphdr*, QObject* parent = 0 ); virtual ~OARPPacket(); QHostAddress senderIPV4Address() const; OMacAddress senderMacAddress() const; QHostAddress targetIPV4Address() const; OMacAddress targetMacAddress() const; //int type() const; QString type() const; private: const struct myarphdr* _arphdr; }; /*====================================================================================== * OUDPPacket *======================================================================================*/ class OUDPPacket : public QObject { Q_OBJECT public: OUDPPacket( const unsigned char*, const struct udphdr*, QObject* parent = 0 ); virtual ~OUDPPacket(); int fromPort() const; int toPort() const; int length() const; int checksum() const; private: const struct udphdr* _udphdr; }; /*====================================================================================== * ODHCPPacket *======================================================================================*/ class ODHCPPacket : public QObject { Q_OBJECT public: ODHCPPacket( const unsigned char*, const struct dhcp_packet*, QObject* parent = 0 ); virtual ~ODHCPPacket(); QHostAddress clientAddress() const; QHostAddress yourAddress() const; QHostAddress serverAddress() const; QHostAddress relayAddress() const; OMacAddress clientMacAddress() const; bool isRequest() const; bool isReply() const; QString type() const; private: const struct dhcp_packet* _dhcphdr; unsigned char _type; }; /*====================================================================================== * OTCPPacket *======================================================================================*/ class OTCPPacket : public QObject { Q_OBJECT public: OTCPPacket( const unsigned char*, const struct tcphdr*, QObject* parent = 0 ); virtual ~OTCPPacket(); int fromPort() const; int toPort() const; int seq() const; int ack() const; int window() const; int checksum() const; private: const struct tcphdr* _tcphdr; }; /*====================================================================================== * OPacketCapturer *======================================================================================*/ /** * @brief A class based wrapper for network packet capturing. * * This class is the base of a high-level interface to the well known packet capturing * library libpcap. * @see http://tcpdump.org */ class OPacketCapturer : public QObject { Q_OBJECT public: /** * Constructor. */ OPacketCapturer( QObject* parent = 0, const char* name = 0 ); /** * Destructor. */ ~OPacketCapturer(); /** * Set the packet capturer to use blocking or non-blocking IO. This can be useful when * not using the socket notifier, e.g. without an application object. */ void setBlocking( bool ); /** * @returns true if the packet capturer uses blocking IO calls. */ bool blocking() const; /** * Close the packet capturer. This is automatically done in the destructor. */ void close(); /** * Close the output capture file. */ void closeDumpFile(); /** * @returns the data link type. * @see <pcap.h> for possible values. */ int dataLink() const; /** * Dump a packet to the output capture file. */ void dump( OPacket* ); /** * @returns the file descriptor of the packet capturer. This is only useful, if * not using the socket notifier, e.g. without an application object. */ int fileno() const; /** * @returns the next @ref OPacket from the packet capturer. * @note If blocking mode is true then this call might block. */ OPacket* next(); /** * @returns the next @ref OPacket from the packet capturer, if * one arrives within @a time milliseconds. */ OPacket* next( int time ); /** * Open the packet capturer to capture packets in live-mode from @a interface. */ bool open( const QString& interface ); /** * Open the packet capturer to capture packets in offline-mode from @a file. */ bool open( const QFile& file ); /** * Open a prerecorded tcpdump compatible capture file for use with @ref dump() */ bool openDumpFile( const QString& filename ); /** * @returns true if the packet capturer is open */ bool isOpen() const; /** * @returns the snapshot length of this packet capturer */ int snapShot() const; /** * @returns true if the input capture file has a different byte-order * than the byte-order of the running system. */ bool swapped() const; /** * @returns the libpcap version string used to write the input capture file. */ QString version() const; /** * @returns the packet statistic database. * @see QMap */ const QMap<QString,int>& statistics() const; signals: /** * This signal is emitted, when a packet has been received. */ void receivedPacket( OPacket* ); protected slots: void readyToReceive(); protected: QString _name; // devicename bool _open; // check this before doing pcap calls pcap_t* _pch; // pcap library handle pcap_dumper_t* _pcd; // pcap dumper handle QSocketNotifier* _sn; // socket notifier for main loop mutable char _errbuf[PCAP_ERRBUF_SIZE]; // holds error strings from libpcap QMap<QString, int> _stats; // statistics; }; #endif // OPCAP_H diff --git a/libopie2/opienet/opienet.pro b/libopie2/opienet/opienet.pro index 386c2db..2027481 100644 --- a/libopie2/opienet/opienet.pro +++ b/libopie2/opienet/opienet.pro @@ -1,34 +1,34 @@ TEMPLATE = lib CONFIG += qt warn_on debug DESTDIR = $(OPIEDIR)/lib HEADERS = 802_11_user.h \ dhcp.h \ udp_ports.h \ wireless.h \ odebugmapper.h \ omanufacturerdb.h \ onetutils.h \ onetwork.h \ opcap.h \ ostation.h SOURCES = odebugmapper.cpp \ omanufacturerdb.cpp \ onetutils.cpp \ onetwork.cpp \ opcap.cpp \ ostation.cpp INTERFACES = TARGET = opienet2 -VERSION = 1.8.1 +VERSION = 1.8.2 INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lpcap !contains( platform, x11 ) { include ( $(OPIEDIR)/include.pro ) } contains( platform, x11 ) { LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib } diff --git a/libopie2/opienet/ostation.cpp b/libopie2/opienet/ostation.cpp index ba1e4f6..c363f0c 100644 --- a/libopie2/opienet/ostation.cpp +++ b/libopie2/opienet/ostation.cpp @@ -1,64 +1,63 @@ /* This file is part of the Opie Project - - (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> + Copyright (C) 2003 by Michael 'Mickey' Lauer <mickey@Vanille.de> =. .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <opie2/ostation.h> /*====================================================================================== * OStation *======================================================================================*/ OStation::OStation() { qDebug( "OStation::OStation()" ); type = "<unknown>"; macAddress = OMacAddress::unknown; ssid = "<unknown>"; channel = 0; apAddress = OMacAddress::unknown; } OStation::~OStation() { qDebug( "OStation::~OStation()" ); } void OStation::dump() { qDebug( "------- OStation::dump() ------------" ); qDebug( "type: %s", (const char*) type ); qDebug( "mac: %s", (const char*) macAddress.toString() ); qDebug( "ap: %s", (const char*) apAddress.toString() ); qDebug( "ip: %s", (const char*) ipAddress.toString() ); } diff --git a/libopie2/opienet/ostation.h b/libopie2/opienet/ostation.h index a6956c9..1e7366d 100644 --- a/libopie2/opienet/ostation.h +++ b/libopie2/opienet/ostation.h @@ -1,74 +1,73 @@ /* This file is part of the Opie Project - - (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> + Copyright (C) 2003 by Michael 'Mickey' Lauer <mickey@Vanille.de> =. .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef OSTATION_H #define OSTATION_H #include <opie2/onetutils.h> #include <qlist.h> #include <qstring.h> #include <qhostaddress.h> #include <qobject.h> #include <sys/types.h> class OStation; typedef QList<OStation> OStationList; /*====================================================================================== * OStation *======================================================================================*/ class OStation { public: OStation(); ~OStation(); void dump(); /* Ethernet */ QString type; OMacAddress macAddress; QHostAddress ipAddress; /* WaveLan */ QString ssid; OMacAddress apAddress; int channel; bool encrypted; }; #endif // OSTATION_H diff --git a/libopie2/opienet/udp_ports.h b/libopie2/opienet/udp_ports.h index 5e92497..3fb1c85 100644 --- a/libopie2/opienet/udp_ports.h +++ b/libopie2/opienet/udp_ports.h @@ -1,89 +1,89 @@ /* * This file has been generated by doing * find . -name "*"|xargs grep -h '#define UDP_PORT' > udp_ports.h * in the root directory of Ethereal 0.9.15. Cudos to the Ethereal Team. - * -- Michael 'Mickey' Lauer <mickeyl@handhelds.org> + * -- Michael 'Mickey' Lauer <mickey@Vanille.de> */ #define UDP_PORT_AODV 654 #define UDP_PORT_LENGTH 2 #define UDP_PORT_OFFSET PARAMETER_VALUE_OFFSET #define UDP_PORT_RAS1 1718 #define UDP_PORT_RAS2 1719 #define UDP_PORT_CPHA 8116 #define UDP_PORT_DDTP 1052 #define UDP_PORT_CUPS 631 #define UDP_PORT_DLSW 2067 #define UDP_PORT_ISAKMP 500 #define UDP_PORT_L2TP 1701 #define UDP_PORT_IAPP 2313 #define UDP_PORT_HSRP 1985 #define UDP_PORT_SSDP 1900 #define UDP_PORT_TACACS 49 #define UDP_PORT_CLDAP 389 #define UDP_PORT_VINES 573 #define UDP_PORT_NBNS 137 #define UDP_PORT_NBDGM 138 #define UDP_PORT_XYPLEX 173 #define UDP_PORT_PIM_RP_DISC 496 #define UDP_PORT_SLIMP3_V1 1069 #define UDP_PORT_SLIMP3_V2 3483 #define UDP_PORT_RMCP 623 #define UDP_PORT_RMCP_SECURE 664 #define UDP_PORT_SYSLOG 514 #define UDP_PORT_SNMP 161 #define UDP_PORT_SNMP_TRAP 162 #define UDP_PORT_TFTP 69 #define UDP_PORT_TIME 37 #define UDP_PORT_STUN 3478 #define UDP_PORT_SRVLOC 427 #define UDP_PORT_TZSP 0x9090 #define UDP_PORT_WCCP 2048 #define UDP_PORT_MSPROXY 1745 #define UDP_PORT_BOOTPS 67 #define UDP_PORT_BOOTPC 68 #define UDP_PORT_XDMCP 177 #define UDP_PORT_DHCPV6_DOWNSTREAM 546 #define UDP_PORT_DHCPV6_UPSTREAM 547 #define UDP_PORT_DNS 53 #define UDP_PORT_MDNS 5353 #define UDP_PORT_ICP 3130 #define UDP_PORT_ICQ 4000 #define UDP_PORT_IPX 213 /* RFC 1234 */ #define UDP_PORT_LDP 646 #define UDP_PORT_LLC1 12000 #define UDP_PORT_LLC2 12001 #define UDP_PORT_LLC3 12002 #define UDP_PORT_LLC4 12003 #define UDP_PORT_LLC5 12004 #define UDP_PORT_MIP 434 #define UDP_PORT_NCP 524 #define UDP_PORT_NTP 123 #define UDP_PORT_RIP 520 #define UDP_PORT_SAP 9875 #define UDP_PORT_SIP 5060 #define UDP_PORT_TIMED 525 #define UDP_PORT_RIPNG 521 #define UDP_PORT_WSP 9200 /* wap-wsp */ #define UDP_PORT_WTP_WSP 9201 /* wap-wsp-wtp */ #define UDP_PORT_WTLS_WSP 9202 /* wap-wsp-s */ #define UDP_PORT_WTLS_WTP_WSP 9203 /* wap-wsp-wtp-s */ #define UDP_PORT_WSP_PUSH 2948 /* wap-wsp */ #define UDP_PORT_WTLS_WSP_PUSH 2949 /* wap-wsp-s */ #define UDP_PORT_WHO 513 #define UDP_PORT_KERBEROS 88 #define UDP_PORT_SFLOW 6343 #define UDP_PORT_LAPLINK 1547 #define UDP_PORT_NETFLOW 2055 #define UDP_PORT_RX_LOW 7000 #define UDP_PORT_RX_HIGH 7009 #define UDP_PORT_RX_AFS_BACKUPS 7021 #define UDP_PORT_MGCP_GATEWAY 2427 #define UDP_PORT_MGCP_CALLAGENT 2727 #define UDP_PORT_PCLI 9000 #define UDP_PORT_ARTNET 0x1936 #define UDP_PORT_TERREDO 3544 #define UDP_PORT_RADIUS 1645 #define UDP_PORT_RADIUS_NEW 1812 #define UDP_PORT_RADACCT 1646 #define UDP_PORT_RADACCT_NEW 1813 diff --git a/libopie2/opiepim/libopiepim2.control b/libopie2/opiepim/libopiepim2.control index 5cfa453..ac8e13c 100644 --- a/libopie2/opiepim/libopiepim2.control +++ b/libopie2/opiepim/libopiepim2.control @@ -1,11 +1,11 @@ Package: libopiepim2 Files: $OPIEDIR/lib/libopiepim2.so.* Priority: optional Section: opie/system Maintainer: Opie Team <opie@handhelds.org> Architecture: arm -Version: 1.8.1-$SUB_VERSION.2 -Depends: libqpe1, libopiecore2 (1.8.1) +Version: 1.8.2-$SUB_VERSION.2 +Depends: libqpe1, libopiecore2 (1.8.2) Provides: libopiepim2 Description: Opie library 2.0 PIM diff --git a/libopie2/opiepim/opiepim.pro b/libopie2/opiepim/opiepim.pro index cc6ee90..3972c3f 100644 --- a/libopie2/opiepim/opiepim.pro +++ b/libopie2/opiepim/opiepim.pro @@ -1,24 +1,24 @@ TEMPLATE = lib CONFIG += qt warn_on debug DESTDIR = $(OPIEDIR)/lib HEADERS = SOURCES = INTERFACES = TARGET = opiepim2 -VERSION = 1.8.1 +VERSION = 1.8.2 INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include MOC_DIR = moc OBJECTS_DIR = obj !contains( platform, x11 ) { include ( $(OPIEDIR)/include.pro ) } contains( platform, x11 ) { LIBS = -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib } diff --git a/libopie2/opieui/libopieui2.control b/libopie2/opieui/libopieui2.control index 6900fd6..71e6358 100644 --- a/libopie2/opieui/libopieui2.control +++ b/libopie2/opieui/libopieui2.control @@ -1,11 +1,11 @@ Package: libopieui2 Files: $OPIEDIR/lib/libopieui2.so.* Priority: optional Section: opie/system Maintainer: Opie Team <opie@handhelds.org> Architecture: arm -Version: 1.8.1-$SUB_VERSION.2 -Depends: libqpe1, libopiecore2 (1.8.1) +Version: 1.8.2-$SUB_VERSION.2 +Depends: libqpe1, libopiecore2 (1.8.2) Provides: libopieui2 Description: Opie library 2.0 UI diff --git a/libopie2/opieui/opieui.pro b/libopie2/opieui/opieui.pro index 68a5c5f..4c15181 100644 --- a/libopie2/opieui/opieui.pro +++ b/libopie2/opieui/opieui.pro @@ -1,67 +1,67 @@ TEMPLATE = lib CONFIG += qt warn_on debug DESTDIR = $(OPIEDIR)/lib HEADERS = ocompletionbox.h \ ocombobox.h \ oeditlistbox.h \ olineedit.h \ olistview.h \ oimageeffect.h \ opixmapeffect.h \ opopupmenu.h \ opixmapprovider.h \ oselector.h \ oversatileview.h \ oversatileviewitem.h \ #ojanuswidget.h \ odialog.h \ omenubar.h \ opiemenubar.h \ omessagebox.h \ oresource.h \ otoolbar.h \ oseparator.h # otaskbarapplet.h SOURCES = ocompletionbox.cpp \ ocombobox.cpp \ oeditlistbox.cpp \ olineedit.cpp \ olistview.cpp \ oimageeffect.cpp \ opixmapeffect.cpp \ opopupmenu.cpp \ opixmapprovider.cpp \ oselector.cpp \ oversatileview.cpp \ oversatileviewitem.cpp \ #ojanuswidget.cpp \ odialog.cpp \ omenubar.cpp \ opiemenubar.cpp \ oresource.cpp \ otoolbar.cpp \ oseparator.cpp #\ # otaskbarapplet.cpp INTERFACES = TARGET = opieui2 -VERSION = 1.8.1 +VERSION = 1.8.2 INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lopiecore2 MOC_DIR = moc OBJECTS_DIR = obj !contains( platform, x11 ) { include ( $(OPIEDIR)/include.pro ) HEADERS += otaskbarapplet.h SOURCES += otaskbarapplet.cpp } contains( platform, x11 ) { LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib message( Warning: NO otaskbarapplet ATM ) } diff --git a/libopie2/tools/regen.py b/libopie2/tools/regen.py index 9ad5352..3779896 100755 --- a/libopie2/tools/regen.py +++ b/libopie2/tools/regen.py @@ -1,94 +1,96 @@ #!/usr/bin/env python # # regenerate ioctl_table.h # import sys import os result = os.popen( 'find /usr/include -name "*.h" |xargs grep -h SIOC|grep 0x' ).readlines() try: tablehfile = file( sys.argv[1]+".h", "w" ) except: tablehfile = sys.stdout try: tablecfile = file( sys.argv[1]+".cpp", "w" ) except: tablecfile = sys.stdout print >>tablehfile,""" /* * debug value mapper - generated by regen.py - (C) Michael 'Mickey' Lauer <mickey@vanille.de> */ #ifndef DEBUGMAPPER_H #define DEBUGMAPPER_H #include <qstring.h> #include <qintdict.h> typedef QIntDict<QString> IntStringMap; class DebugMapper { public: DebugMapper(); ~DebugMapper(); const QString& map( int value ) const; private: IntStringMap _map; }; #endif """ print >>tablecfile,""" /* * debug value mapper - generated by regen.py - (C) Michael 'Mickey' Lauer <mickey@vanille.de> */ +#include <opie2/odebug.h> + #include "%s" DebugMapper::DebugMapper() { - qDebug( "DebugMapper::DebugMapper()" ); + odebug << "DebugMapper::DebugMapper()" << oendl; """ % (tablehfile.name) for line in result: l = line.split() if not l[0].startswith( "#define" ) or not l[2].startswith( "0x" ): print >>sys.stderr, "can't parse line: %s" % l continue print >>tablecfile, " _map.insert( %s, new QString(\"%s\") );" % ( l[2], l[1] ) print >>tablecfile,""" }; DebugMapper::~DebugMapper() { - qDebug( "DebugMapper::~DebugMapper()" ); + odebug << "DebugMapper::~DebugMapper()" << oendl; } const QString& DebugMapper::map( int value ) const { QString* result = _map[ value ]; if ( !result ) { - qDebug( "DebugMapper::map() - value not found." ); + owarn << "DebugMapper::map() - value " << value << " is not found." << oendl; return QString::null; } else { return *result; } } """ |