author | mickeyl <mickeyl> | 2005-05-06 09:27:12 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2005-05-06 09:27:12 (UTC) |
commit | 543d9d7c58c9601dba6f47b3a4011313d1d75499 (patch) (side-by-side diff) | |
tree | 6b9d259a91b220264c961d542e25b69fe070320f | |
parent | c199fa0b0ef971c3a121af6c31a9a9822561a1be (diff) | |
download | opie-543d9d7c58c9601dba6f47b3a4011313d1d75499.zip opie-543d9d7c58c9601dba6f47b3a4011313d1d75499.tar.gz opie-543d9d7c58c9601dba6f47b3a4011313d1d75499.tar.bz2 |
- OManufacturerDB: check if there is a QApplication before calling Global::statusMessage or qApp->processEvents()
- ONetwork: skip hostap control interfaces 'wifi*'
- OWirelessNetworkInterface: set \0 in SSID() and nickName() to work around (buggy) drivers not returning a
zero-terminated string
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | libopie2/opienet/omanufacturerdb.cpp | 17 | ||||
-rw-r--r-- | libopie2/opienet/onetwork.cpp | 9 | ||||
-rw-r--r-- | libopie2/opienet/opienet.pro | 2 |
4 files changed, 14 insertions, 15 deletions
@@ -1,283 +1,284 @@ 2005-??-?? Opie 1.2.1 New Features ------------ * OpieStumbler: Scans WiFi networks using the wireless extension scanning (skyhusker) * Opie-Reader: Support for document formats ArriereGo and Reb, add flite output (tim,pohly) Fixed Bugs ---------- * #1476 - Wrong order of application entries in the O-menu (skyhusker) * #1535 - Missing line break and unnecessary location shown with Today-Calendar plugin (deller) * #1565 - crash-fix in odevice.cpp while scanning the distribution table (deller) * #1614 - Make Opie-console start in $HOME instead of / (skyhusker) * n.a. - always show volume and wireless applet popups inside visible screen (deller) * n.a. - scale O-Menu-Applets appropriately (mickeyl) * n.a. - libopienet: fix bugs in wireless scanning and setting SSID (skyhusker) * n.a. - Wellenreiter: relax WE version matching test a bit (mickeyl) * n.a. - scale BluezApplet appropriately and use larger icons (mickeyl) * n.a. - memoryapplet: fix crash in memoryapplet on kernels without swap support (seneca cunningham) Internal -------- * Make BluezApplet use OTaskbarApplet (mickeyl) * Rewrite OFileNotification to use the upcoming inotify interface instead of the deprecated dnotify (mickeyl) + * libopienet: Skip hostap control interfaces 'wifi' and improve robustness in ONetworkInterface (mickeyl) 2005-03-25 Opie 1.2.0 Fixed Bugs ---------- * #1613 - AdvancedFM - scale toolbar icons appropriately (drw) * #1620 - OFileSelector - show the button on press and not on press on hold (alwin) * #1473 - Opie-Eye - Same as #1620 but we lack a common FileSystem Button class (zecke) * n.a. - PackageManager - fix bug where messages show up multiple times in install dialog (drw) * n.a. - make qpeglobal.h include qglobal.h (zecke) 2005-03-20 Opie 1.2.0-rc1 New Features ------------ * Launcher: Support a static background pixmap (mickeyl) * LauncherSettings: Choose whether to have a static background pixmap (mickeyl) * PackageManager supports the 'lists_dir' ipkg configuration option (drw) * Added hi-res inline images for large resolution devices (drw) * Improved launcher icons for consistency (ar) * Datebook: Added plugin system to datebook so holidays and birthdays from contacts may displayed in datebook (alwin) Fixed Bugs ---------- * #1236 - VCards contained empty home and work address entries causing Palms to crash (eilers) * #1412 - Launcher Settings - fixed default settings for background in Edit tab dialog (drw) * #1472 - Opie textedit now check for unsaved changes on ESC key (ljp) * #1474 - Implement GUI for Scrollbars on the Left in Appearance (zecke) * #1482 - Fix double '/' in paths (zecke) * #1536 - Autosave of custom locations in opie backup (ar) * #1539 - Fixed displaying too long path in the delete dialog in opie-eye (zecke) * #1540 - Implemented deletion of DocLnks in opie-eye (zecke) * #1542 - Fixed Todo crash when priority < 1 or > 5 (drw) * #1550 - Browse for alarm sound start in QPEDIR/sounds/ (zecke) * #1554 - Fixed Opie-Console name in .desktop file (mickeyl) * #1556 - Start to look for sound files in /opt/QtPalmtop/sounds (zecke) * #1558 - Fixed opie-login breaking opie startup (mickeyl) * #1560 - Fixed Opie-Console picking up the wrong shell (bluelightning) * #1570 - Confirmation needed befor Restore a backup and overwrite local data (ar) * #1591 - Addressbook sortorder changed by clicking on column 0 (eilers) * #1599 - Security - change recommendation for opie-multiauth to opie-securityplugin (gints) * #1604 - Checkbook crashed on startup (drw) * #1608 - Addressbook crashed after search, which may caused by not initialzed member variable (eilers) * #1608 - QueryByExampe-Datediff on SQL database did not worked properly (eilers) * n.a. - Netsystemtime - fixed UI to prevent error dialog from displaying when it shouldn't, get rid of some compiler warnings (drw) * n.a. - PackageManager - fixed where last package in status file was not shown as installed when it should be (drw) * n.a. - PackageManager - fixed bug where lists_dir was not being honored at startup (drw) * n.a. - PackageManager - provided default value for lists_dir when none is entered in configuration dialog (drw) * n.a. - OTabWidget - fixed scroll buttons, fix display position of tabs (drw) * n.a. - AddressBook - fixed sorting by 'File As' name (drw) * n.a. - AddressBook - fixed category handling for 'All' and 'Unfiled' (eilers) * n.a. - AddressBook - fixed letter picker record selection and sort records afterwards (drw) Internal -------- * Worked around bug in Qt/Embedded 2.3.10: qt_version() returns 231 (mickeyl) * Killed the need for weak symbols in QtE (zecke) * Added optional building libqpe without inline images (mickeyl) * OColorButton - fixed so does not emit a colorSelected signal inside of resizeEvent (drw) 2005-02-03 Opie 1.1.9 New Features ------------ * Number of icon columns in Launcher is customizable through Launcher.conf (hrw,zecke,mickeyl) * Number of icon columns in Launcher is customizable through LauncherSettings (mickeyl) * Usability enhancements in OpieIRC (skyhusker) Fixed Bugs ---------- * #1501 - Fixed bug in todo sql backend (eilers) * #1505 - Added more Swap sizes in memoryapplet (mickeyl) * #1525 - Hopefully fixed double alarms and not removing alarms set with the Clock application (zecke) * #1533 - Security Owner Dialog (shown in case of unsuccessfull authentiacation) wasn't able to display information in non latin1 encoding (zecke) * n.a. - Removed hard coded font sizes in a couple of inputmethods (mickeyl) * n.a. - Removed MediumDlg appearing prior to FirstUsage wizard (i.e. calibration) (mickeyl) * n.a. - Fixed numerous buglets in OpieIRC (skyhusker) Internal -------- * Added the Qtopia 1.7 SDK macros for quick-apps to easa compilation of 3rd party apps against our headers (mickeyl) * You can now use the Opie build system in combination with a OpenEmbedded staging area which makes a nice cross development environment (mickeyl) * Made Opie compilable with Qt/Embedded 2.3.10 (ar) * Changed Launcher to get default orientation from ODevice w/ QWS_DISPLAY overriding (mickeyl) * Build tree cleanups (mickeyl) 2004-11-26 Opie 1.1.8 New Features ------------ * PackageManager supports installation of local ipkg files (drw) * PackageManager supports linking of applications to root (drw) * PackageManager supports src/gz feeds (drw,wimpie) * Added a syslog information tab to sysinfo (mickeyl) * Added new, more consistent, PIM icons + a GIMP teplate (ar) Fixed Bugs ---------- * #1017 - Tetrix doesn't display correctly for high resolution screens (drw) * #1269 - VCards were imported into personal area if it was activated (eilers) * #1464 - Packagemanager dont set active filter after install a package (drw) * #1479 - Improved VCard-Parser to import VCards created by Evolution 2 and Apple Addressbook (eilers) * #1493 - Fixed one column layout bug of the launcher (hrw) * n.a. - PackageManager - (Minor UI tweak) in filter dialog, when option is enabled, set focus to widget that corresponds to that option (drw) * n.a. - PackageManager - (Minor UI tweak) fix double entry in source feed configuration when adding a new feed (drw) * n.a. - Battery Applet - fix sizing of battery info popup (drw,mickeyl) Internal -------- * Moved libopie1 to unsupported (mickeyl) * Implemented generic queryByExample() with incremental searching. A lot of internal changes of the Pim2-library (eilers) * Added fast and full featured and incremental sorted() for SQL addressbook backend (eilers) 2004-11-14 Opie 1.1.7 New Features ------------ * libOpieDB now uses SQLite V3 instead V2. Remember to upgrade your database files! (eilers) * Backup now uses the busy indicator when backing up and restore (ar) * OpiePlayer2 gained adding of Directories to the playlist (zecke) * OpiePlayer2 better error handling (zecke) * OpiePlayer2 progress indication while streaming (zecke) * OpiePlayer2 ported to use libxine 1.0.0-rc6a (brad,zecke) * Ported brightnessapplet from Qtopia 1.7 (mickeyl) * Opie-Eye got a Digital Camera File Backend (alwin,zecke) * Support for Tuxpad1 of Tradesquare.NL (mickeyl,zecke) * Opie-Console use Custom Font and Size in a Profile (harlekin) * Opie-Console transparently log the Output and Input to a file (harlekin) * Added new O-menu icon to lock the PDA immediately: opie-lockapplet (clem) * Opie-Security now hides the plugin-based authentication tabs if no auth. plugin package is installed (clem) * Opie-Security gained a 'test authentication' button (clem) * Opie-Eye got a more unique layout (menubar), a slideshow, user can setup some defaults * Opie-Mail improve the handling of POP mail boxes (alwin) * Both Opie-Eye and Opie-Mail were greatly improved due the hard work of Rajko Albrecht(alwin) * Opie IRC - backports of the 'NeIRC fork' (zecke) Fixed Bugs ---------- * #501 - Pickboard is able to show 'Umlaute' (TT,zecke) * #608 - Make Opie usable for left handed users (zecke) * #957 - Import of VCards/VTodos/VEvents with BASE64 encoding (ljp,zecke) * #1245 - Opie-Go 'paused' (zecke) * #1358 - DocTab didn't show any MimeTypes (was fixed earlier) (zecke) * #1380 - QDateBookAccess::remove() doesn't remove entries (eilers, zecke) * #1395 - Build VNC Backend with gcc3.4 * #1440 - The icon of opie-mobilemsg is missing (CoreDump) * #1426 - Add missing opie-bartender Icon (CoreDump) * #1445 - Opie-Sheet Has No Icon (CoreDump) * #1448 - Brightness Applet added (mickeyl) * #1450 - ZSame didn't clear the bonus item after winning a game (zecke) * #1482 - Fix OFileSelector to be able to sort by size (zecke) * n.a. - Opie-mail: fixed some crasher, some layout-problems * n.a. - Converted applications to not hardcode /opt/QtPalmtop but to use QPEApplication::qpeDir (zecke) * n.a. - Converted usage of qpeDir() not to include a '/' as first charachter of the string (zecke) * n.a. - Build system: Enable distcc and ccache when crosscompiling too, and use them everywhere we can (clem) * n.a. - Build system: Fix deps in several config.in (and fix scripts/deps.pl too) to stop breaking builds, especially with make -j highNumber (clem) * n.a. - Removed hardcoded icon size in a couple of applets (mickeyl) Internal -------- * Opie-Qashmoney has been moved to unsupported (mickeyl) * Opie-Ubrowser has been moved to unsupported (mickeyl) 2004-09-17 Opie 1.1.6 New Features ------------ * Fifteen gained configurable number of items (zecke) * Fifteen can have custom background images (zecke) * Added daemonizing capabilities to QWS Server [via Qt/Embedded] (mickeyl) * Integrated the new security framework into libopie2 (zecke,clem) * Converted the launcher to use the new security framework (zecke) * Backup can now handle custom locations for backup and restore (ar) * Implemented right-on-hold feedback (wimpie,zecke) * Lots of new features in opie-reader (tim,pohly) * Build system cleanups (schurig) Fixed Bugs -------- * #1005 - Fixed backup to CompactFlash (ar) * #1167 - Fixed Opie write crashing on more text than one page (ar) * #1225 - Fixed repeated light flashing on Zaurus with keyz (mickeyl) * #1359 - Fixed bookmarks in Gutenbrowser (ljp) * #1361 - Fixed auto upercase in Opie-Addressbook (eilers) * #1370 - Pimconverter now reacts on cancel key (eilers) * #1376 - Bring back the capslock/numlock display (zecke) * #1383 - Language settings now warns about losing open apps (Markus Litz) * #1393 - Fixed line wrap issues in opie-console for the default profile (mickeyl) * #1394 - Fixed oversized headline in opie-login (coredump) * #1396 - Opie-console captures the escape key and vim is working (zecke) * #1401 - Scrollbar is now only visible if necessary in DocTab (mickeyl) 2004-07-06 Opie 1.1.4 New Features ------------ * Added four themes courtesy Robert Griebl (http://www.softforge.de/zstyle) * Added Conversion tool for pim-data (eilers) * Introduced new OPimAccessFactory and OBackendFactory which simplyfies database access (eilers) * Modified the PIM API for providing generic use of OPimRecords (eilers) * Clicking on the application symbol now iterates over the application's top level widgets if already raised (zecke) Fixed Bugs -------- * #1068 - Country Drop Down Box Off Screen * #1291 - Opie tinykate does not open .desktop files (ar) * #1291 - Opie sheet not saving correctly (ar) * #1294 - Opie does not know about British Summer Time * #1314 - Drawpad initialization (mickeyl) * #1317 - Packagemanager crashes on hold-down or install (chicken) * #1321 - Batteryapplet graphic glitch (harlekin) * #1324 - ZSafe not starting up (mickeyl) * #1328 - Personal Home Address fields is trimmed to 1char (eilers) * #1327 - Opie-mail ipk does not depend on libopiedb2 (chicken) * #1345 - Networksettingsplugin wlan plugin dependency on libpcap0 (mickeyl) * #1348 - Datebook dependency on libopiedb2 (chicken) * #1328 - Switched SQLDatabase and VCards char encoding from latin1 to unicode (eilers) 2004-04-25 Opie 1.1.3 * Introduced first implementation of SQL-Support using SQLite (eilers) * Added a new Gutenberg Project reader app - opie-gutenbrowser (ljp) * Added a real system graffiti character set (brad) * Added Generic Keyconfig Widget (zecke) * Improved Screenshotapplet and Drawpad integration. You can now open a screenshot in drawpad and take notes (zecke) * Added new Bible reader app - opie-dagger (drw) * Added a new Image Viewer. Work is ongoing (zecke,alwin) * Added namespace usage in libopie2 and everywhere (zecke,alwin) * Enabled the possibility to pass command line arguments to applications (mickeyl) * Added an about applet showing some credits and information about Opie (mickeyl) * Added benchmarking functionality to sysinfo (mickeyl) * Added applet and configuration application for switching hardware keyboard layouts (alwin) * Ported applications from libopie1 to libopie2* (drw,ar,alwin) * Imported fullscreen and font improvements from the Qkonsole fork to embeddedkonsole (waspe) * Clean-up of package information in control files (drw) * Repaired mediummount which was broken since integrating the quicklauncher (alwin) * Improved big-screen support (zecke,ar) * Improved multikeyboard support, added keyboard layout switching applet (mouse) * Added a new mail client based on libetpan (harlekin,alwin,jgf) * Added new package manager - opie-packagemanager (drw) * Improved light-n-power for C7x0 (mickeyl) * Added automatic rotation support for C7x0 (treke) * Split libopie1 up into a set of smaller - functionally grouped - libraries (mickeyl) * Added scanning the wireless network neighbourhood to networksettings (mickeyl) 2003-11-29 Opie 1.0.3 * Released as Version 1.0.3 * Improved i18n (various contributors) * Reduced application startup time by integrating the TT quicklauncher (zecke,harlekin) * Made the Documents Tab optional (mickeyl) * Integrated basic support for HP iPAQ 54xx and the Jornada 5xx (chicken) 2003-08-04 Opie 1.0.0 * Released as Version 1.0.0 * Including a PPP module for easy dial up (tille,harlekin,zecke) diff --git a/libopie2/opienet/omanufacturerdb.cpp b/libopie2/opienet/omanufacturerdb.cpp index 123aee8..3af3d4c 100644 --- a/libopie2/opienet/omanufacturerdb.cpp +++ b/libopie2/opienet/omanufacturerdb.cpp @@ -1,143 +1,134 @@ /* This file is part of the Opie Project =. (C) 2003-2004 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; version 2 of the License. ._= =} : .%`+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" -#define OPIE_IMPROVE_GUI_LATENCY 1 - /* OPIE */ #include <opie2/odebug.h> #include <qpe/qpeapplication.h> #ifdef OPIE_IMPROVE_GUI_LATENCY #include <qpe/global.h> #endif /* QT */ #include <qapplication.h> #include <qfile.h> #include <qtextstream.h> using namespace Opie::Core; namespace Opie { namespace Net { OManufacturerDB* OManufacturerDB::_instance = 0; OManufacturerDB* OManufacturerDB::instance() { if ( !OManufacturerDB::_instance ) { odebug << "OManufacturerDB::instance(): creating OManufacturerDB..." << oendl; _instance = new OManufacturerDB(); } return _instance; } OManufacturerDB::OManufacturerDB() { - #ifdef OPIE_IMPROVE_GUI_LATENCY - Global::statusMessage( "Reading Manufacturers..." ); - #endif + if ( qApp ) Global::statusMessage( "Reading Manufacturers..." ); QString filename( "/etc/manufacturers" ); odebug << "OManufacturerDB: trying to read " << filename << oendl; if ( !QFile::exists( filename ) ) { filename = QPEApplication::qpeDir()+"etc/manufacturers"; odebug << "OManufacturerDB: trying to read " << filename << oendl; if ( !QFile::exists( filename ) ) { filename = "/usr/share/wellenreiter/manufacturers"; odebug << "OManufacturerDB: trying to read " << filename << oendl; } } QFile file( filename ); bool hasFile = file.open( IO_ReadOnly ); if (!hasFile) { owarn << "OManufacturerDB: no valid manufacturer list found." << oendl; } else { odebug << "OManufacturerDB: found manufacturer list in " << filename << oendl; QTextStream s( &file ); QString addr; QString manu; QString extManu; - #ifdef OPIE_IMPROVE_GUI_LATENCY int counter = 0; - #endif + while (!s.atEnd()) { s >> addr; s >> manu; s >> extManu; manufacturers.insert( addr, manu ); manufacturersExt.insert( addr, extManu ); // odebug << "OmanufacturerDB: parse '" << addr << "' as '" << manu << "' (" << extManu << ")" << oendl; - #ifdef OPIE_IMPROVE_GUI_LATENCY counter++; if ( counter == 50 ) { - qApp->processEvents(); + if ( qApp ) qApp->processEvents(); counter = 0; } - #endif } odebug << "OManufacturerDB: manufacturer list completed." << oendl; - #ifdef OPIE_IMPROVE_GUI_LATENCY - Global::statusMessage( "Manufacturers Complete..." ); - #endif + if ( qApp ) Global::statusMessage( "Manufacturers Complete..." ); } } 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/onetwork.cpp b/libopie2/opienet/onetwork.cpp index 0a74019..f4bdbe0 100644 --- a/libopie2/opienet/onetwork.cpp +++ b/libopie2/opienet/onetwork.cpp @@ -1,1252 +1,1259 @@ /* This file is part of the Opie Project Copyright (C) 2003-2005 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; version 2 of the License. ._= =} : .%`+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> #include <opie2/odebug.h> /* QT */ #include <qfile.h> #include <qtextstream.h> #include <qapplication.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 <net/ethernet.h> #include <stdarg.h> #ifndef NODEBUG #include <opie2/odebugmapper.h> using namespace Opie::Core; using namespace Opie::Net::Internal; DebugMapper* debugmapper = new DebugMapper(); #endif /*====================================================================================== * ONetwork *======================================================================================*/ namespace Opie { namespace Net { ONetwork* ONetwork::_instance = 0; ONetwork::ONetwork() { odebug << "ONetwork::ONetwork()" << oendl; odebug << "ONetwork: This code has been compiled against Wireless Extensions V" << WIRELESS_EXT << oendl; 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 ) { odebug << "ONetwork: /proc/net/dev not existing. No network devices available" << oendl; return; } QTextStream s( &f ); s.readLine(); s.readLine(); while ( !s.atEnd() ) { s >> str; str.truncate( str.find( ':' ) ); odebug << "ONetwork: found interface '" << str << "'" << oendl; + if ( str.startsWith( "wifi" ) ) + { + odebug << "ONetwork: ignoring hostap control interface" << oendl; + s.readLine(); + continue; + } ONetworkInterface* iface = 0; if ( isWirelessInterface( str ) ) { iface = new OWirelessNetworkInterface( this, (const char*) str ); odebug << "ONetwork: interface '" << str << "' has Wireless Extensions" << oendl; } else { iface = new ONetworkInterface( this, (const char*) str ); } _interfaces.insert( str, iface ); s.readLine(); } } short ONetwork::wirelessExtensionCompileVersion() { 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::isPresent( const char* name ) const { int sfd = socket( AF_INET, SOCK_STREAM, 0 ); struct ifreq ifr; memset( &ifr, 0, sizeof( struct ifreq ) ); strcpy( (char*) &ifr.ifr_name, name ); int result = ::ioctl( sfd, SIOCGIFFLAGS, &ifr ); return result != -1; } 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 ) { odebug << "ONetworkInterface::ONetworkInterface()" << oendl; init(); } struct ifreq& ONetworkInterface::ifr() const { return _ifr; } void ONetworkInterface::init() { odebug << "ONetworkInterface::init()" << oendl; memset( &_ifr, 0, sizeof( struct ifreq ) ); if ( _sfd == -1 ) { odebug << "ONetworkInterface::init(): Warning - can't get socket for device '" << name() << "'" << oendl; return; } } bool ONetworkInterface::ioctl( int call, struct ifreq& ifreq ) const { #ifndef NODEBUG int result = ::ioctl( _sfd, call, &ifreq ); if ( result == -1 ) odebug << "ONetworkInterface::ioctl (" << name() << ") call '" << debugmapper->map( call ) << "' FAILED! " << result << " (" << strerror( errno ) << ")" << oendl; else odebug << "ONetworkInterface::ioctl (" << name() << ") call '" << debugmapper->map( call ) << "' - Status: Ok." << oendl; 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; odebug << "ONetwork::setMonitoring(): Installed monitoring driver '" << m->name() << "' on interface '" << name() << "'" << oendl; } OMonitoringInterface* ONetworkInterface::monitoring() const { return _mon; } ONetworkInterface::~ONetworkInterface() { odebug << "ONetworkInterface::~ONetworkInterface()" << oendl; 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(); // 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 ) ); odebug << "OChannelHopper::timerEvent(): set channel " << *_channel << " on interface '" << _iface->name() << "'" << oendl; 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 ) { odebug << "OWirelessNetworkInterface::OWirelessNetworkInterface()" << oendl; init(); } OWirelessNetworkInterface::~OWirelessNetworkInterface() { } struct iwreq& OWirelessNetworkInterface::iwr() const { return _iwr; } void OWirelessNetworkInterface::init() { odebug << "OWirelessNetworkInterface::init()" << oendl; memset( &_iwr, 0, sizeof( struct iwreq ) ); buildInformation(); buildPrivateList(); dumpInformation(); } bool OWirelessNetworkInterface::isAssociated() const { //FIXME: handle different modes return !(associatedAP() == OMacAddress::unknown); } void OWirelessNetworkInterface::setAssociatedAP( const OMacAddress& mac ) const { _iwr.u.ap_addr.sa_family = ARPHRD_ETHER; ::memcpy(_iwr.u.ap_addr.sa_data, mac.native(), ETH_ALEN); wioctl( SIOCSIWAP ); } 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 ) { owarn << "OWirelessNetworkInterface::buildInformation(): Can't get channel information - using default values." << oendl; _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) { owarn << "OWirelessNetworkInterface::buildInformation(): Driver for wireless interface '" << name() << "' sucks! It overwrote the buffer end with at least " << max - sizeof( struct iw_range ) << " bytes!" << oendl; } // </check if the driver overwrites stuff> struct iw_range range; memcpy( &range, buffer, sizeof range ); odebug << "OWirelessNetworkInterface::buildInformation(): Interface reported to have " << (int) range.num_frequency << " channels." << oendl; 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 ); odebug << "OWirelessNetworkInterface::buildInformation: Adding frequency " << freq << " as channel " << i+1 << oendl; _channels.insert( freq, i+1 ); } } memcpy( &_range, buffer, sizeof( struct iw_range ) ); odebug << "OWirelessNetworkInterface::buildInformation(): Information block constructed." << oendl; free(buffer); } short OWirelessNetworkInterface::wirelessExtensionDriverVersion() const { return _range.we_version_compiled; } void OWirelessNetworkInterface::buildPrivateList() { odebug << "OWirelessNetworkInterface::buildPrivateList()" << oendl; 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 ) ) { owarn << "OWirelessNetworkInterface::buildPrivateList(): Can't get private ioctl information." << oendl; 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 ); } odebug << "OWirelessNetworkInterface::buildPrivateList(): Private ioctl list constructed." << oendl; } void OWirelessNetworkInterface::dumpInformation() const { odebug << "OWirelessNetworkInterface::() -------------- dumping information block ----------------" << oendl; odebug << " - driver's idea of maximum throughput is " << _range.throughput << " bps = " << ( _range.throughput / 8 ) << " byte/s = " << ( _range.throughput / 8 / 1024 ) << " Kb/s = " << QString().sprintf("%f.2", float( _range.throughput ) / 8.0 / 1024.0 / 1024.0 ) << " Mb/s" << oendl; odebug << " - driver for '" << name() << "' (V" << _range.we_version_source << ") has been compiled against WE V" << _range.we_version_compiled << oendl; if ( _range.we_version_compiled != WIRELESS_EXT ) { owarn << "Version mismatch! WE_DRIVER = " << _range.we_version_compiled << " and WE_OPIENET = " << WIRELESS_EXT << oendl; } odebug << "OWirelessNetworkInterface::() ---------------------------------------------------------" << oendl; } 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 ) { oerr << "OWirelessNetworkInterface::setChannel( 0 ) called - fix your application!" << oendl; 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 odebug << "OWirelessNetworkInterface::setMode(): trying to set mode " << newMode << oendl; _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" ) { odebug << "OWirelessNetworkInterface::setMode(): SIOCSIWMODE not sufficient - trying fallback to iwpriv..." << oendl; if ( _mon ) _mon->setEnabled( false ); else odebug << "ONetwork(): can't switch monitor mode without installed monitoring interface" << oendl; } } else // special iwpriv fallback for monitor mode { if ( wioctl( SIOCSIWMODE ) ) { odebug << "OWirelessNetworkInterface::setMode(): IW_MODE_MONITOR ok" << oendl; } else { odebug << "OWirelessNetworkInterface::setMode(): SIOCSIWMODE not working - trying fallback to iwpriv..." << oendl; if ( _mon ) _mon->setEnabled( true ); else odebug << "ONetwork(): can't switch monitor mode without installed monitoring interface" << oendl; } } } QString OWirelessNetworkInterface::mode() const { memset( &_iwr, 0, sizeof( struct iwreq ) ); if ( !wioctl( SIOCGIWMODE ) ) { return "<unknown>"; } odebug << "OWirelessNetworkInterface::setMode(): WE's idea of current mode seems to be " << modeToString( _iwr.u.mode ) << oendl; // 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 + str[_iwr.u.data.length] = '\0'; // some drivers 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 ) { owarn << "OWirelessNetworkInterface::setPrivate(): interface '" << name() << "' does not support private ioctl '" << call << "'" << oendl; return; } if ( priv->numberSetArgs() != numargs ) { owarn << "OWirelessNetworkInterface::setPrivate(): parameter count not matching. '" << call << "' expects " << priv->numberSetArgs() << ", but got " << numargs << oendl; return; } odebug << "OWirelessNetworkInterface::setPrivate(): about to call '" << call << "' on interface '" << name() << "'" << oendl; 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& ) { oerr << "OWirelessNetworkInterface::getPrivate() is not implemented yet." << oendl; } bool OWirelessNetworkInterface::hasPrivate( const QString& call ) { return child( call.local8Bit() ); } 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 { + str[_iwr.u.essid.length] = '\0'; // some drivers don't zero-terminate the string return str; } } void OWirelessNetworkInterface::setSSID( const QString& ssid ) { _iwr.u.essid.pointer = const_cast<char*>( (const char*) ssid ); _iwr.u.essid.length = ssid.length()+1; // zero byte 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 = 10000000; odebug << "ONetworkInterface::scanNetwork() - scan started." << oendl; 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) { odebug << "ONetworkInterface::scanNetwork() - scan in progress..." << oendl; if ( qApp ) { qApp->processEvents( 100 ); continue; } tv.tv_sec = 0; tv.tv_usec = 100000; continue; } } odebug << "ONetworkInterface::scanNetwork() - scan finished." << oendl; if ( results ) { odebug << " - result length = " << _iwr.u.data.length << oendl; if ( !_iwr.u.data.length ) { odebug << " - no results (empty neighbourhood)" << oendl; return stations; } odebug << " - results are in!" << oendl; dumpBytes( (const unsigned char*) &buffer[0], _iwr.u.data.length ); // parse results struct iw_event iwe; struct iw_stream_descr stream; unsigned int cmd_index, event_type, event_len; char *pointer; const char standard_ioctl_hdr[] = { IW_HEADER_TYPE_NULL, /* SIOCSIWCOMMIT */ IW_HEADER_TYPE_CHAR, /* SIOCGIWNAME */ IW_HEADER_TYPE_PARAM, /* SIOCSIWNWID */ IW_HEADER_TYPE_PARAM, /* SIOCGIWNWID */ IW_HEADER_TYPE_FREQ, /* SIOCSIWFREQ */ IW_HEADER_TYPE_FREQ, /* SIOCGIWFREQ */ IW_HEADER_TYPE_UINT, /* SIOCSIWMODE */ IW_HEADER_TYPE_UINT, /* SIOCGIWMODE */ IW_HEADER_TYPE_PARAM, /* SIOCSIWSENS */ IW_HEADER_TYPE_PARAM, /* SIOCGIWSENS */ IW_HEADER_TYPE_NULL, /* SIOCSIWRANGE */ IW_HEADER_TYPE_POINT, /* SIOCGIWRANGE */ IW_HEADER_TYPE_NULL, /* SIOCSIWPRIV */ IW_HEADER_TYPE_POINT, /* SIOCGIWPRIV */ IW_HEADER_TYPE_NULL, /* SIOCSIWSTATS */ IW_HEADER_TYPE_POINT, /* SIOCGIWSTATS */ IW_HEADER_TYPE_POINT, /* SIOCSIWSPY */ IW_HEADER_TYPE_POINT, /* SIOCGIWSPY */ IW_HEADER_TYPE_POINT, /* SIOCSIWTHRSPY */ IW_HEADER_TYPE_POINT, /* SIOCGIWTHRSPY */ IW_HEADER_TYPE_ADDR, /* SIOCSIWAP */ IW_HEADER_TYPE_ADDR, /* SIOCGIWAP */ IW_HEADER_TYPE_NULL, /* -- hole -- */ IW_HEADER_TYPE_POINT, /* SIOCGIWAPLIST */ IW_HEADER_TYPE_PARAM, /* SIOCSIWSCAN */ IW_HEADER_TYPE_POINT, /* SIOCGIWSCAN */ IW_HEADER_TYPE_POINT, /* SIOCSIWESSID */ IW_HEADER_TYPE_POINT, /* SIOCGIWESSID */ IW_HEADER_TYPE_POINT, /* SIOCSIWNICKN */ IW_HEADER_TYPE_POINT, /* SIOCGIWNICKN */ IW_HEADER_TYPE_NULL, /* -- hole -- */ IW_HEADER_TYPE_NULL, /* -- hole -- */ IW_HEADER_TYPE_PARAM, /* SIOCSIWRATE */ IW_HEADER_TYPE_PARAM, /* SIOCGIWRATE */ IW_HEADER_TYPE_PARAM, /* SIOCSIWRTS */ IW_HEADER_TYPE_PARAM, /* SIOCGIWRTS */ IW_HEADER_TYPE_PARAM, /* SIOCSIWFRAG */ IW_HEADER_TYPE_PARAM, /* SIOCGIWFRAG */ IW_HEADER_TYPE_PARAM, /* SIOCSIWTXPOW */ IW_HEADER_TYPE_PARAM, /* SIOCGIWTXPOW */ IW_HEADER_TYPE_PARAM, /* SIOCSIWRETRY */ IW_HEADER_TYPE_PARAM, /* SIOCGIWRETRY */ IW_HEADER_TYPE_POINT, /* SIOCSIWENCODE */ IW_HEADER_TYPE_POINT, /* SIOCGIWENCODE */ IW_HEADER_TYPE_PARAM, /* SIOCSIWPOWER */ IW_HEADER_TYPE_PARAM, /* SIOCGIWPOWER */ }; const char standard_event_hdr[] = { IW_HEADER_TYPE_ADDR, /* IWEVTXDROP */ IW_HEADER_TYPE_QUAL, /* IWEVQUAL */ IW_HEADER_TYPE_POINT, /* IWEVCUSTOM */ IW_HEADER_TYPE_ADDR, /* IWEVREGISTERED */ IW_HEADER_TYPE_ADDR, /* IWEVEXPIRED */ IW_HEADER_TYPE_POINT, /* IWEVGENIE */ IW_HEADER_TYPE_POINT, /* IWEVMICHAELMICFAILURE */ IW_HEADER_TYPE_POINT, /* IWEVASSOCREQIE */ IW_HEADER_TYPE_POINT, /* IWEVASSOCRESPIE */ IW_HEADER_TYPE_POINT, /* IWEVPMKIDCAND */ }; const int event_type_size[] = { IW_EV_LCP_LEN, /* IW_HEADER_TYPE_NULL */ 0, IW_EV_CHAR_LEN, /* IW_HEADER_TYPE_CHAR */ 0, IW_EV_UINT_LEN, /* IW_HEADER_TYPE_UINT */ IW_EV_FREQ_LEN, /* IW_HEADER_TYPE_FREQ */ IW_EV_ADDR_LEN, /* IW_HEADER_TYPE_ADDR */ 0, IW_EV_POINT_LEN, /* Without variable payload */ IW_EV_PARAM_LEN, /* IW_HEADER_TYPE_PARAM */ IW_EV_QUAL_LEN, /* IW_HEADER_TYPE_QUAL */ }; //Initialize the stream memset( &stream, 0, sizeof(struct iw_stream_descr) ); stream.current = buffer; stream.end = buffer + _iwr.u.data.length; do { if ((stream.current + IW_EV_LCP_LEN) > stream.end) break; memcpy((char *) &iwe, stream.current, IW_EV_LCP_LEN); if (iwe.len <= IW_EV_LCP_LEN) //If yes, it is an invalid event break; if (iwe.cmd <= SIOCIWLAST) { cmd_index = iwe.cmd - SIOCIWFIRST; if(cmd_index < sizeof(standard_ioctl_hdr)) event_type = standard_ioctl_hdr[cmd_index]; } else { cmd_index = iwe.cmd - IWEVFIRST; if(cmd_index < sizeof(standard_event_hdr)) event_type = standard_event_hdr[cmd_index]; } /* Unknown events -> event_type=0 => IW_EV_LCP_LEN */ event_len = event_type_size[event_type]; /* Fixup for later version of WE */ if((_range.we_version_compiled > 18) && (event_type == IW_HEADER_TYPE_POINT)) event_len -= IW_EV_POINT_OFF; /* Check if we know about this event */ if(event_len <= IW_EV_LCP_LEN) { /* Skip to next event */ stream.current += iwe.len; continue; } event_len -= IW_EV_LCP_LEN; /* Set pointer on data */ if(stream.value != NULL) pointer = stream.value; /* Next value in event */ else pointer = stream.current + IW_EV_LCP_LEN; /* First value in event */ if((pointer + event_len) > stream.end) { /* Go to next event */ stream.current += iwe.len; break; } /* Fixup for later version of WE */ if((_range.we_version_compiled > 18) && (event_type == IW_HEADER_TYPE_POINT)) memcpy((char *) &iwe + IW_EV_LCP_LEN + IW_EV_POINT_OFF, pointer, event_len); else memcpy((char *) &iwe + IW_EV_LCP_LEN, pointer, event_len); /* Skip event in the stream */ pointer += event_len; /* Special processing for iw_point events */ if(event_type == IW_HEADER_TYPE_POINT) { /* Check the length of the payload */ if((iwe.len - (event_len + IW_EV_LCP_LEN)) > 0) /* Set pointer on variable part (warning : non aligned) */ iwe.u.data.pointer = pointer; else /* No data */ iwe.u.data.pointer = NULL; /* Go to next event */ stream.current += iwe.len; } else { /* Is there more value in the event ? */ if((pointer + event_len) <= (stream.current + iwe.len)) /* Go to next value */ stream.value = pointer; else { /* Go to next event */ stream.value = NULL; stream.current += iwe.len; } } struct iw_event *we = &iwe; //------ odebug << " - reading next event... cmd=" << we->cmd << ", len=" << we->len << oendl; switch (we->cmd) { case SIOCGIWAP: { odebug << "SIOCGIWAP" << oendl; stations->append( new OStation() ); stations->last()->macAddress = (const unsigned char*) &we->u.ap_addr.sa_data[0]; break; } case SIOCGIWMODE: { odebug << "SIOCGIWMODE" << oendl; stations->last()->type = modeToString( we->u.mode ); break; } case SIOCGIWFREQ: { odebug << "SIOCGIWFREQ" << oendl; if ( we->u.freq.m > 1000 ) stations->last()->channel = _channels[ static_cast<int>(double( we->u.freq.m ) * pow( 10.0, we->u.freq.e ) / 1000000) ]; else stations->last()->channel = static_cast<int>(((double) we->u.freq.m) * pow( 10.0, we->u.freq.e )); break; } case SIOCGIWESSID: { odebug << "SIOCGIWESSID" << oendl; we->u.essid.length = '\0'; // make sure it is zero terminated stations->last()->ssid = static_cast<const char*> (we->u.essid.pointer); odebug << "ESSID: " << stations->last()->ssid << oendl; break; } case IWEVQUAL: { odebug << "IWEVQUAL" << oendl; stations->last()->level = static_cast<int>(we->u.qual.level); break; /* Quality part of statistics (scan) */ } case SIOCGIWENCODE: { odebug << "SIOCGIWENCODE" << oendl; stations->last()->encrypted = !(we->u.data.flags & IW_ENCODE_DISABLED); break; } case SIOCGIWRATE: { odebug << "SIOCGIWRATE" << oendl; stations->last()->rates.append(we->u.bitrate.value); break; } case SIOCGIWSENS: odebug << "SIOCGIWSENS" << oendl; break; case IWEVTXDROP: odebug << "IWEVTXDROP" << oendl; break; /* Packet dropped to excessive retry */ case IWEVCUSTOM: odebug << "IWEVCUSTOM" << oendl; break; /* Driver specific ascii string */ case IWEVREGISTERED: odebug << "IWEVREGISTERED" << oendl; break; /* Discovered a new node (AP mode) */ case IWEVEXPIRED: odebug << "IWEVEXPIRED" << oendl; break; /* Expired a node (AP mode) */ default: odebug << "unhandled event" << oendl; } } while (true); } else { odebug << " - no results (timeout) :(" << oendl; } return stations; } int OWirelessNetworkInterface::signalStrength() const { iw_statistics stat; ::memset( &stat, 0, sizeof stat ); _iwr.u.data.pointer = (char*) &stat; _iwr.u.data.flags = 0; _iwr.u.data.length = sizeof stat; if ( !wioctl( SIOCGIWSTATS ) ) { return -1; } int max = _range.max_qual.qual; int cur = stat.qual.qual; // int lev = stat.qual.level; //FIXME: Do something with them? // int noi = stat.qual.noise; //FIXME: Do something with them? return max != 0 ? cur*100/max: -1; } bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const { #ifndef NODEBUG int result = ::ioctl( _sfd, call, &iwreq ); if ( result == -1 ) odebug << "ONetworkInterface::wioctl (" << name() << ") call '" << debugmapper->map( call ) << "' FAILED! " << result << " (" << strerror( errno ) << ")" << oendl; else odebug << "ONetworkInterface::wioctl (" << name() << ") call '" << debugmapper->map( call ) << "' - Status: Ok." << oendl; 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() { } diff --git a/libopie2/opienet/opienet.pro b/libopie2/opienet/opienet.pro index a10a949..460de0a 100644 --- a/libopie2/opienet/opienet.pro +++ b/libopie2/opienet/opienet.pro @@ -1,40 +1,40 @@ TEMPLATE = lib CONFIG += qt warn_on DESTDIR = $(OPIEDIR)/lib HEADERS = 802_11_user.h \ dhcp.h \ udp_ports.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.5 +VERSION = 1.8.6 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 } !isEmpty( LIBPCAP_INC_DIR ) { INCLUDEPATH = $$LIBPCAP_INC_DIR $$INCLUDEPATH } !isEmpty( LIBPCAP_LIB_DIR ) { LIBS = -L$$LIBPCAP_LIB_DIR $$LIBS } |