author | mickeyl <mickeyl> | 2005-05-17 16:57:08 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2005-05-17 16:57:08 (UTC) |
commit | d2ae68c413873e234b34f733818427902e738948 (patch) (unidiff) | |
tree | f5748014d7b1785302c167c6f43fbd0622bf1019 | |
parent | cce15d6b9a27880df72ea2638f9295900ea6c21e (diff) | |
download | opie-d2ae68c413873e234b34f733818427902e738948.zip opie-d2ae68c413873e234b34f733818427902e738948.tar.gz opie-d2ae68c413873e234b34f733818427902e738948.tar.bz2 |
libopienet API cleanups
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | examples/opienet/miniwellenreiter/miniwellenreiter.cpp | 2 | ||||
-rw-r--r-- | examples/opienet/onetworkdemo/onetworkdemo.cpp | 2 | ||||
-rw-r--r-- | libopie2/opienet/onetutils.cpp | 19 | ||||
-rw-r--r-- | libopie2/opienet/onetutils.h | 8 | ||||
-rw-r--r-- | libopie2/opienet/onetwork.cpp | 43 | ||||
-rw-r--r-- | libopie2/opienet/onetwork.h | 7 | ||||
-rw-r--r-- | noncore/applets/networkapplet/networkapplet.cpp | 6 | ||||
-rw-r--r-- | noncore/net/opiestumbler/opiestumbler.cpp | 2 |
9 files changed, 47 insertions, 44 deletions
@@ -1,287 +1,289 @@ | |||
1 | 2005-??-??Opie 1.2.1 | 1 | 2005-??-??Opie 1.2.1 |
2 | 2 | ||
3 | 3 | ||
4 | New Features | 4 | New Features |
5 | ------------ | 5 | ------------ |
6 | * OpieStumbler: Scans WiFi networks using the wireless extension scanning (skyhusker) | 6 | * OpieStumbler: Scans WiFi networks using the wireless extension scanning (skyhusker) |
7 | * Opie-Reader: Support for document formats ArriereGo and Reb, add flite output (tim,pohly) | 7 | * Opie-Reader: Support for document formats ArriereGo and Reb, add flite output (tim,pohly) |
8 | * Opie-Networksettings: Add support for wlan-ng devices and improve WEP handling (Dirk Opfer) | 8 | * Opie-Networksettings: Add support for wlan-ng devices and improve WEP handling (Dirk Opfer) |
9 | * Wellenreiter: Remove Joining networks - use OpieStumbler for that (mickeyl) | 9 | * Wellenreiter: Remove Joining networks - use OpieStumbler for that (mickeyl) |
10 | 10 | ||
11 | Fixed Bugs | 11 | Fixed Bugs |
12 | ---------- | 12 | ---------- |
13 | * #1476 - Wrong order of application entries in the O-menu (skyhusker) | 13 | * #1476 - Wrong order of application entries in the O-menu (skyhusker) |
14 | * #1535- Missing line break and unnecessary location shown with Today-Calendar plugin (deller) | 14 | * #1535- Missing line break and unnecessary location shown with Today-Calendar plugin (deller) |
15 | * #1565 - crash-fix in odevice.cpp while scanning the distribution table (deller) | 15 | * #1565 - crash-fix in odevice.cpp while scanning the distribution table (deller) |
16 | * #1614 - Make Opie-console start in $HOME instead of / (skyhusker) | 16 | * #1614 - Make Opie-console start in $HOME instead of / (skyhusker) |
17 | * n.a.- always show volume and wireless applet popups inside visible screen (deller) | 17 | * n.a.- always show volume and wireless applet popups inside visible screen (deller) |
18 | * n.a. - scale O-Menu-Applets appropriately (mickeyl) | 18 | * n.a. - scale O-Menu-Applets appropriately (mickeyl) |
19 | * n.a.- libopienet: fix bugs in wireless scanning and setting SSID (skyhusker) | 19 | * n.a.- libopienet: fix bugs in wireless scanning and setting SSID (skyhusker) |
20 | * n.a.- Wellenreiter: relax WE version matching test a bit (mickeyl) | 20 | * n.a.- Wellenreiter: relax WE version matching test a bit (mickeyl) |
21 | * n.a.- scale BluezApplet appropriately and use larger icons (mickeyl) | 21 | * n.a.- scale BluezApplet appropriately and use larger icons (mickeyl) |
22 | * n.a.- memoryapplet: fix crash in memoryapplet on kernels without swap support (seneca cunningham) | 22 | * n.a.- memoryapplet: fix crash in memoryapplet on kernels without swap support (seneca cunningham) |
23 | * n.a. - networksettings: ignore hostap control interfaces wifi* (mickeyl) | 23 | * n.a. - networksettings: ignore hostap control interfaces wifi* (mickeyl) |
24 | 24 | ||
25 | Internal | 25 | Internal |
26 | -------- | 26 | -------- |
27 | * Make BluezApplet use OTaskbarApplet (mickeyl) | 27 | * Make BluezApplet use OTaskbarApplet (mickeyl) |
28 | * Rewrite OFileNotification to use the upcoming inotify interface instead of the deprecated dnotify (mickeyl) | 28 | * Rewrite OFileNotification to use the upcoming inotify interface instead of the deprecated dnotify (mickeyl) |
29 | * libopienet: Skip hostap control interfaces 'wifi' and improve robustness in ONetworkInterface (mickeyl) | 29 | * libopienet: Skip hostap control interfaces 'wifi' and improve robustness in ONetworkInterface (mickeyl) |
30 | * libopieui: Remove OVersatileView and OVersatileViewItem (mickeyl) | ||
31 | * libopienet: Miscellaneous API cleanups (mickeyl) | ||
30 | 32 | ||
31 | 2005-03-25Opie 1.2.0 | 33 | 2005-03-25Opie 1.2.0 |
32 | 34 | ||
33 | Fixed Bugs | 35 | Fixed Bugs |
34 | ---------- | 36 | ---------- |
35 | * #1613 - AdvancedFM - scale toolbar icons appropriately (drw) | 37 | * #1613 - AdvancedFM - scale toolbar icons appropriately (drw) |
36 | * #1620 - OFileSelector - show the button on press and not on press on hold (alwin) | 38 | * #1620 - OFileSelector - show the button on press and not on press on hold (alwin) |
37 | * #1473 - Opie-Eye - Same as #1620 but we lack a common FileSystem Button class (zecke) | 39 | * #1473 - Opie-Eye - Same as #1620 but we lack a common FileSystem Button class (zecke) |
38 | * n.a. - PackageManager - fix bug where messages show up multiple times in install dialog (drw) | 40 | * n.a. - PackageManager - fix bug where messages show up multiple times in install dialog (drw) |
39 | * n.a.- make qpeglobal.h include qglobal.h (zecke) | 41 | * n.a.- make qpeglobal.h include qglobal.h (zecke) |
40 | 42 | ||
41 | 2005-03-20Opie 1.2.0-rc1 | 43 | 2005-03-20Opie 1.2.0-rc1 |
42 | 44 | ||
43 | 45 | ||
44 | New Features | 46 | New Features |
45 | ------------ | 47 | ------------ |
46 | * Launcher: Support a static background pixmap (mickeyl) | 48 | * Launcher: Support a static background pixmap (mickeyl) |
47 | * LauncherSettings: Choose whether to have a static background pixmap (mickeyl) | 49 | * LauncherSettings: Choose whether to have a static background pixmap (mickeyl) |
48 | * PackageManager supports the 'lists_dir' ipkg configuration option (drw) | 50 | * PackageManager supports the 'lists_dir' ipkg configuration option (drw) |
49 | * Added hi-res inline images for large resolution devices (drw) | 51 | * Added hi-res inline images for large resolution devices (drw) |
50 | * Improved launcher icons for consistency (ar) | 52 | * Improved launcher icons for consistency (ar) |
51 | * Datebook: Added plugin system to datebook so holidays and birthdays from contacts may displayed in datebook (alwin) | 53 | * Datebook: Added plugin system to datebook so holidays and birthdays from contacts may displayed in datebook (alwin) |
52 | 54 | ||
53 | Fixed Bugs | 55 | Fixed Bugs |
54 | ---------- | 56 | ---------- |
55 | * #1236 - VCards contained empty home and work address entries causing Palms to crash (eilers) | 57 | * #1236 - VCards contained empty home and work address entries causing Palms to crash (eilers) |
56 | * #1412 - Launcher Settings - fixed default settings for background in Edit tab dialog (drw) | 58 | * #1412 - Launcher Settings - fixed default settings for background in Edit tab dialog (drw) |
57 | * #1472 - Opie textedit now check for unsaved changes on ESC key (ljp) | 59 | * #1472 - Opie textedit now check for unsaved changes on ESC key (ljp) |
58 | * #1474 - Implement GUI for Scrollbars on the Left in Appearance (zecke) | 60 | * #1474 - Implement GUI for Scrollbars on the Left in Appearance (zecke) |
59 | * #1482 - Fix double '/' in paths (zecke) | 61 | * #1482 - Fix double '/' in paths (zecke) |
60 | * #1536 - Autosave of custom locations in opie backup (ar) | 62 | * #1536 - Autosave of custom locations in opie backup (ar) |
61 | * #1539 - Fixed displaying too long path in the delete dialog in opie-eye (zecke) | 63 | * #1539 - Fixed displaying too long path in the delete dialog in opie-eye (zecke) |
62 | * #1540 - Implemented deletion of DocLnks in opie-eye (zecke) | 64 | * #1540 - Implemented deletion of DocLnks in opie-eye (zecke) |
63 | * #1542 - Fixed Todo crash when priority < 1 or > 5 (drw) | 65 | * #1542 - Fixed Todo crash when priority < 1 or > 5 (drw) |
64 | * #1550 - Browse for alarm sound start in QPEDIR/sounds/ (zecke) | 66 | * #1550 - Browse for alarm sound start in QPEDIR/sounds/ (zecke) |
65 | * #1554 - Fixed Opie-Console name in .desktop file (mickeyl) | 67 | * #1554 - Fixed Opie-Console name in .desktop file (mickeyl) |
66 | * #1556 - Start to look for sound files in /opt/QtPalmtop/sounds (zecke) | 68 | * #1556 - Start to look for sound files in /opt/QtPalmtop/sounds (zecke) |
67 | * #1558 - Fixed opie-login breaking opie startup (mickeyl) | 69 | * #1558 - Fixed opie-login breaking opie startup (mickeyl) |
68 | * #1560 - Fixed Opie-Console picking up the wrong shell (bluelightning) | 70 | * #1560 - Fixed Opie-Console picking up the wrong shell (bluelightning) |
69 | * #1570 - Confirmation needed befor Restore a backup and overwrite local data (ar) | 71 | * #1570 - Confirmation needed befor Restore a backup and overwrite local data (ar) |
70 | * #1591 - Addressbook sortorder changed by clicking on column 0 (eilers) | 72 | * #1591 - Addressbook sortorder changed by clicking on column 0 (eilers) |
71 | * #1599 - Security - change recommendation for opie-multiauth to opie-securityplugin (gints) | 73 | * #1599 - Security - change recommendation for opie-multiauth to opie-securityplugin (gints) |
72 | * #1604 - Checkbook crashed on startup (drw) | 74 | * #1604 - Checkbook crashed on startup (drw) |
73 | * #1608 - Addressbook crashed after search, which may caused by not initialzed member variable (eilers) | 75 | * #1608 - Addressbook crashed after search, which may caused by not initialzed member variable (eilers) |
74 | * #1608 - QueryByExampe-Datediff on SQL database did not worked properly (eilers) | 76 | * #1608 - QueryByExampe-Datediff on SQL database did not worked properly (eilers) |
75 | * n.a. - Netsystemtime - fixed UI to prevent error dialog from displaying when it shouldn't, get rid of some compiler warnings (drw) | 77 | * n.a. - Netsystemtime - fixed UI to prevent error dialog from displaying when it shouldn't, get rid of some compiler warnings (drw) |
76 | * n.a. - PackageManager - fixed where last package in status file was not shown as installed when it should be (drw) | 78 | * n.a. - PackageManager - fixed where last package in status file was not shown as installed when it should be (drw) |
77 | * n.a. - PackageManager - fixed bug where lists_dir was not being honored at startup (drw) | 79 | * n.a. - PackageManager - fixed bug where lists_dir was not being honored at startup (drw) |
78 | * n.a. - PackageManager - provided default value for lists_dir when none is entered in configuration dialog (drw) | 80 | * n.a. - PackageManager - provided default value for lists_dir when none is entered in configuration dialog (drw) |
79 | * n.a. - OTabWidget - fixed scroll buttons, fix display position of tabs (drw) | 81 | * n.a. - OTabWidget - fixed scroll buttons, fix display position of tabs (drw) |
80 | * n.a. - AddressBook - fixed sorting by 'File As' name (drw) | 82 | * n.a. - AddressBook - fixed sorting by 'File As' name (drw) |
81 | * n.a. - AddressBook - fixed category handling for 'All' and 'Unfiled' (eilers) | 83 | * n.a. - AddressBook - fixed category handling for 'All' and 'Unfiled' (eilers) |
82 | * n.a. - AddressBook - fixed letter picker record selection and sort records afterwards (drw) | 84 | * n.a. - AddressBook - fixed letter picker record selection and sort records afterwards (drw) |
83 | 85 | ||
84 | Internal | 86 | Internal |
85 | -------- | 87 | -------- |
86 | * Worked around bug in Qt/Embedded 2.3.10: qt_version() returns 231 (mickeyl) | 88 | * Worked around bug in Qt/Embedded 2.3.10: qt_version() returns 231 (mickeyl) |
87 | * Killed the need for weak symbols in QtE (zecke) | 89 | * Killed the need for weak symbols in QtE (zecke) |
88 | * Added optional building libqpe without inline images (mickeyl) | 90 | * Added optional building libqpe without inline images (mickeyl) |
89 | * OColorButton - fixed so does not emit a colorSelected signal inside of resizeEvent (drw) | 91 | * OColorButton - fixed so does not emit a colorSelected signal inside of resizeEvent (drw) |
90 | 92 | ||
91 | 2005-02-03Opie 1.1.9 | 93 | 2005-02-03Opie 1.1.9 |
92 | 94 | ||
93 | New Features | 95 | New Features |
94 | ------------ | 96 | ------------ |
95 | * Number of icon columns in Launcher is customizable through Launcher.conf (hrw,zecke,mickeyl) | 97 | * Number of icon columns in Launcher is customizable through Launcher.conf (hrw,zecke,mickeyl) |
96 | * Number of icon columns in Launcher is customizable through LauncherSettings (mickeyl) | 98 | * Number of icon columns in Launcher is customizable through LauncherSettings (mickeyl) |
97 | * Usability enhancements in OpieIRC (skyhusker) | 99 | * Usability enhancements in OpieIRC (skyhusker) |
98 | 100 | ||
99 | Fixed Bugs | 101 | Fixed Bugs |
100 | ---------- | 102 | ---------- |
101 | * #1501 - Fixed bug in todo sql backend (eilers) | 103 | * #1501 - Fixed bug in todo sql backend (eilers) |
102 | * #1505 - Added more Swap sizes in memoryapplet (mickeyl) | 104 | * #1505 - Added more Swap sizes in memoryapplet (mickeyl) |
103 | * #1525 - Hopefully fixed double alarms and not removing alarms set with the Clock application (zecke) | 105 | * #1525 - Hopefully fixed double alarms and not removing alarms set with the Clock application (zecke) |
104 | * #1533 - Security Owner Dialog (shown in case of unsuccessfull authentiacation) wasn't able to display information in non latin1 encoding (zecke) | 106 | * #1533 - Security Owner Dialog (shown in case of unsuccessfull authentiacation) wasn't able to display information in non latin1 encoding (zecke) |
105 | * n.a. - Removed hard coded font sizes in a couple of inputmethods (mickeyl) | 107 | * n.a. - Removed hard coded font sizes in a couple of inputmethods (mickeyl) |
106 | * n.a. - Removed MediumDlg appearing prior to FirstUsage wizard (i.e. calibration) (mickeyl) | 108 | * n.a. - Removed MediumDlg appearing prior to FirstUsage wizard (i.e. calibration) (mickeyl) |
107 | * n.a. - Fixed numerous buglets in OpieIRC (skyhusker) | 109 | * n.a. - Fixed numerous buglets in OpieIRC (skyhusker) |
108 | 110 | ||
109 | Internal | 111 | Internal |
110 | -------- | 112 | -------- |
111 | * Added the Qtopia 1.7 SDK macros for quick-apps to easa compilation of 3rd party apps against our headers (mickeyl) | 113 | * Added the Qtopia 1.7 SDK macros for quick-apps to easa compilation of 3rd party apps against our headers (mickeyl) |
112 | * You can now use the Opie build system in combination with a OpenEmbedded staging area which makes a nice cross development environment (mickeyl) | 114 | * You can now use the Opie build system in combination with a OpenEmbedded staging area which makes a nice cross development environment (mickeyl) |
113 | * Made Opie compilable with Qt/Embedded 2.3.10 (ar) | 115 | * Made Opie compilable with Qt/Embedded 2.3.10 (ar) |
114 | * Changed Launcher to get default orientation from ODevice w/ QWS_DISPLAY overriding (mickeyl) | 116 | * Changed Launcher to get default orientation from ODevice w/ QWS_DISPLAY overriding (mickeyl) |
115 | * Build tree cleanups (mickeyl) | 117 | * Build tree cleanups (mickeyl) |
116 | 118 | ||
117 | 2004-11-26Opie 1.1.8 | 119 | 2004-11-26Opie 1.1.8 |
118 | 120 | ||
119 | New Features | 121 | New Features |
120 | ------------ | 122 | ------------ |
121 | * PackageManager supports installation of local ipkg files (drw) | 123 | * PackageManager supports installation of local ipkg files (drw) |
122 | * PackageManager supports linking of applications to root (drw) | 124 | * PackageManager supports linking of applications to root (drw) |
123 | * PackageManager supports src/gz feeds (drw,wimpie) | 125 | * PackageManager supports src/gz feeds (drw,wimpie) |
124 | * Added a syslog information tab to sysinfo (mickeyl) | 126 | * Added a syslog information tab to sysinfo (mickeyl) |
125 | * Added new, more consistent, PIM icons + a GIMP teplate (ar) | 127 | * Added new, more consistent, PIM icons + a GIMP teplate (ar) |
126 | 128 | ||
127 | Fixed Bugs | 129 | Fixed Bugs |
128 | ---------- | 130 | ---------- |
129 | * #1017 - Tetrix doesn't display correctly for high resolution screens (drw) | 131 | * #1017 - Tetrix doesn't display correctly for high resolution screens (drw) |
130 | * #1269 - VCards were imported into personal area if it was activated (eilers) | 132 | * #1269 - VCards were imported into personal area if it was activated (eilers) |
131 | * #1464 - Packagemanager dont set active filter after install a package (drw) | 133 | * #1464 - Packagemanager dont set active filter after install a package (drw) |
132 | * #1479 - Improved VCard-Parser to import VCards created by Evolution 2 and Apple Addressbook (eilers) | 134 | * #1479 - Improved VCard-Parser to import VCards created by Evolution 2 and Apple Addressbook (eilers) |
133 | * #1493 - Fixed one column layout bug of the launcher (hrw) | 135 | * #1493 - Fixed one column layout bug of the launcher (hrw) |
134 | * n.a. - PackageManager - (Minor UI tweak) in filter dialog, when option is enabled, set focus to widget that corresponds to that option (drw) | 136 | * n.a. - PackageManager - (Minor UI tweak) in filter dialog, when option is enabled, set focus to widget that corresponds to that option (drw) |
135 | * n.a. - PackageManager - (Minor UI tweak) fix double entry in source feed configuration when adding a new feed (drw) | 137 | * n.a. - PackageManager - (Minor UI tweak) fix double entry in source feed configuration when adding a new feed (drw) |
136 | * n.a. - Battery Applet - fix sizing of battery info popup (drw,mickeyl) | 138 | * n.a. - Battery Applet - fix sizing of battery info popup (drw,mickeyl) |
137 | 139 | ||
138 | Internal | 140 | Internal |
139 | -------- | 141 | -------- |
140 | * Moved libopie1 to unsupported (mickeyl) | 142 | * Moved libopie1 to unsupported (mickeyl) |
141 | * Implemented generic queryByExample() with incremental searching. A lot of internal changes of the Pim2-library (eilers) | 143 | * Implemented generic queryByExample() with incremental searching. A lot of internal changes of the Pim2-library (eilers) |
142 | * Added fast and full featured and incremental sorted() for SQL addressbook backend (eilers) | 144 | * Added fast and full featured and incremental sorted() for SQL addressbook backend (eilers) |
143 | 145 | ||
144 | 2004-11-14Opie 1.1.7 | 146 | 2004-11-14Opie 1.1.7 |
145 | 147 | ||
146 | New Features | 148 | New Features |
147 | ------------ | 149 | ------------ |
148 | * libOpieDB now uses SQLite V3 instead V2. Remember to upgrade your database files! (eilers) | 150 | * libOpieDB now uses SQLite V3 instead V2. Remember to upgrade your database files! (eilers) |
149 | * Backup now uses the busy indicator when backing up and restore (ar) | 151 | * Backup now uses the busy indicator when backing up and restore (ar) |
150 | * OpiePlayer2 gained adding of Directories to the playlist (zecke) | 152 | * OpiePlayer2 gained adding of Directories to the playlist (zecke) |
151 | * OpiePlayer2 better error handling (zecke) | 153 | * OpiePlayer2 better error handling (zecke) |
152 | * OpiePlayer2 progress indication while streaming (zecke) | 154 | * OpiePlayer2 progress indication while streaming (zecke) |
153 | * OpiePlayer2 ported to use libxine 1.0.0-rc6a (brad,zecke) | 155 | * OpiePlayer2 ported to use libxine 1.0.0-rc6a (brad,zecke) |
154 | * Ported brightnessapplet from Qtopia 1.7 (mickeyl) | 156 | * Ported brightnessapplet from Qtopia 1.7 (mickeyl) |
155 | * Opie-Eye got a Digital Camera File Backend (alwin,zecke) | 157 | * Opie-Eye got a Digital Camera File Backend (alwin,zecke) |
156 | * Support for Tuxpad1 of Tradesquare.NL (mickeyl,zecke) | 158 | * Support for Tuxpad1 of Tradesquare.NL (mickeyl,zecke) |
157 | * Opie-Console use Custom Font and Size in a Profile (harlekin) | 159 | * Opie-Console use Custom Font and Size in a Profile (harlekin) |
158 | * Opie-Console transparently log the Output and Input to a file (harlekin) | 160 | * Opie-Console transparently log the Output and Input to a file (harlekin) |
159 | * Added new O-menu icon to lock the PDA immediately: opie-lockapplet (clem) | 161 | * Added new O-menu icon to lock the PDA immediately: opie-lockapplet (clem) |
160 | * Opie-Security now hides the plugin-based authentication tabs if no auth. plugin package is installed (clem) | 162 | * Opie-Security now hides the plugin-based authentication tabs if no auth. plugin package is installed (clem) |
161 | * Opie-Security gained a 'test authentication' button (clem) | 163 | * Opie-Security gained a 'test authentication' button (clem) |
162 | * Opie-Eye got a more unique layout (menubar), a slideshow, user can setup some defaults | 164 | * Opie-Eye got a more unique layout (menubar), a slideshow, user can setup some defaults |
163 | * Opie-Mail improve the handling of POP mail boxes (alwin) | 165 | * Opie-Mail improve the handling of POP mail boxes (alwin) |
164 | * Both Opie-Eye and Opie-Mail were greatly improved due the hard work of Rajko Albrecht(alwin) | 166 | * Both Opie-Eye and Opie-Mail were greatly improved due the hard work of Rajko Albrecht(alwin) |
165 | * Opie IRC - backports of the 'NeIRC fork' (zecke) | 167 | * Opie IRC - backports of the 'NeIRC fork' (zecke) |
166 | 168 | ||
167 | Fixed Bugs | 169 | Fixed Bugs |
168 | ---------- | 170 | ---------- |
169 | * #501 - Pickboard is able to show 'Umlaute' (TT,zecke) | 171 | * #501 - Pickboard is able to show 'Umlaute' (TT,zecke) |
170 | * #608 - Make Opie usable for left handed users (zecke) | 172 | * #608 - Make Opie usable for left handed users (zecke) |
171 | * #957 - Import of VCards/VTodos/VEvents with BASE64 encoding (ljp,zecke) | 173 | * #957 - Import of VCards/VTodos/VEvents with BASE64 encoding (ljp,zecke) |
172 | * #1245 - Opie-Go 'paused' (zecke) | 174 | * #1245 - Opie-Go 'paused' (zecke) |
173 | * #1358 - DocTab didn't show any MimeTypes (was fixed earlier) (zecke) | 175 | * #1358 - DocTab didn't show any MimeTypes (was fixed earlier) (zecke) |
174 | * #1380 - QDateBookAccess::remove() doesn't remove entries (eilers, zecke) | 176 | * #1380 - QDateBookAccess::remove() doesn't remove entries (eilers, zecke) |
175 | * #1395 - Build VNC Backend with gcc3.4 | 177 | * #1395 - Build VNC Backend with gcc3.4 |
176 | * #1440 - The icon of opie-mobilemsg is missing (CoreDump) | 178 | * #1440 - The icon of opie-mobilemsg is missing (CoreDump) |
177 | * #1426 - Add missing opie-bartender Icon (CoreDump) | 179 | * #1426 - Add missing opie-bartender Icon (CoreDump) |
178 | * #1445 - Opie-Sheet Has No Icon (CoreDump) | 180 | * #1445 - Opie-Sheet Has No Icon (CoreDump) |
179 | * #1448 - Brightness Applet added (mickeyl) | 181 | * #1448 - Brightness Applet added (mickeyl) |
180 | * #1450 - ZSame didn't clear the bonus item after winning a game (zecke) | 182 | * #1450 - ZSame didn't clear the bonus item after winning a game (zecke) |
181 | * #1482 - Fix OFileSelector to be able to sort by size (zecke) | 183 | * #1482 - Fix OFileSelector to be able to sort by size (zecke) |
182 | * n.a. - Opie-mail: fixed some crasher, some layout-problems | 184 | * n.a. - Opie-mail: fixed some crasher, some layout-problems |
183 | * n.a. - Converted applications to not hardcode /opt/QtPalmtop but to use QPEApplication::qpeDir (zecke) | 185 | * n.a. - Converted applications to not hardcode /opt/QtPalmtop but to use QPEApplication::qpeDir (zecke) |
184 | * n.a. - Converted usage of qpeDir() not to include a '/' as first charachter of the string (zecke) | 186 | * n.a. - Converted usage of qpeDir() not to include a '/' as first charachter of the string (zecke) |
185 | * n.a. - Build system: Enable distcc and ccache when crosscompiling too, and use them everywhere we can (clem) | 187 | * n.a. - Build system: Enable distcc and ccache when crosscompiling too, and use them everywhere we can (clem) |
186 | * 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) | 188 | * 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) |
187 | * n.a. - Removed hardcoded icon size in a couple of applets (mickeyl) | 189 | * n.a. - Removed hardcoded icon size in a couple of applets (mickeyl) |
188 | 190 | ||
189 | Internal | 191 | Internal |
190 | -------- | 192 | -------- |
191 | * Opie-Qashmoney has been moved to unsupported (mickeyl) | 193 | * Opie-Qashmoney has been moved to unsupported (mickeyl) |
192 | * Opie-Ubrowser has been moved to unsupported (mickeyl) | 194 | * Opie-Ubrowser has been moved to unsupported (mickeyl) |
193 | 195 | ||
194 | 2004-09-17Opie 1.1.6 | 196 | 2004-09-17Opie 1.1.6 |
195 | 197 | ||
196 | New Features | 198 | New Features |
197 | ------------ | 199 | ------------ |
198 | * Fifteen gained configurable number of items (zecke) | 200 | * Fifteen gained configurable number of items (zecke) |
199 | * Fifteen can have custom background images (zecke) | 201 | * Fifteen can have custom background images (zecke) |
200 | * Added daemonizing capabilities to QWS Server [via Qt/Embedded] (mickeyl) | 202 | * Added daemonizing capabilities to QWS Server [via Qt/Embedded] (mickeyl) |
201 | * Integrated the new security framework into libopie2 (zecke,clem) | 203 | * Integrated the new security framework into libopie2 (zecke,clem) |
202 | * Converted the launcher to use the new security framework (zecke) | 204 | * Converted the launcher to use the new security framework (zecke) |
203 | * Backup can now handle custom locations for backup and restore (ar) | 205 | * Backup can now handle custom locations for backup and restore (ar) |
204 | * Implemented right-on-hold feedback (wimpie,zecke) | 206 | * Implemented right-on-hold feedback (wimpie,zecke) |
205 | * Lots of new features in opie-reader (tim,pohly) | 207 | * Lots of new features in opie-reader (tim,pohly) |
206 | * Build system cleanups (schurig) | 208 | * Build system cleanups (schurig) |
207 | 209 | ||
208 | Fixed Bugs | 210 | Fixed Bugs |
209 | -------- | 211 | -------- |
210 | * #1005 - Fixed backup to CompactFlash (ar) | 212 | * #1005 - Fixed backup to CompactFlash (ar) |
211 | * #1167 - Fixed Opie write crashing on more text than one page (ar) | 213 | * #1167 - Fixed Opie write crashing on more text than one page (ar) |
212 | * #1225 - Fixed repeated light flashing on Zaurus with keyz (mickeyl) | 214 | * #1225 - Fixed repeated light flashing on Zaurus with keyz (mickeyl) |
213 | * #1359 - Fixed bookmarks in Gutenbrowser (ljp) | 215 | * #1359 - Fixed bookmarks in Gutenbrowser (ljp) |
214 | * #1361 - Fixed auto upercase in Opie-Addressbook (eilers) | 216 | * #1361 - Fixed auto upercase in Opie-Addressbook (eilers) |
215 | * #1370 - Pimconverter now reacts on cancel key (eilers) | 217 | * #1370 - Pimconverter now reacts on cancel key (eilers) |
216 | * #1376 - Bring back the capslock/numlock display (zecke) | 218 | * #1376 - Bring back the capslock/numlock display (zecke) |
217 | * #1383 - Language settings now warns about losing open apps (Markus Litz) | 219 | * #1383 - Language settings now warns about losing open apps (Markus Litz) |
218 | * #1393 - Fixed line wrap issues in opie-console for the default profile (mickeyl) | 220 | * #1393 - Fixed line wrap issues in opie-console for the default profile (mickeyl) |
219 | * #1394 - Fixed oversized headline in opie-login (coredump) | 221 | * #1394 - Fixed oversized headline in opie-login (coredump) |
220 | * #1396 - Opie-console captures the escape key and vim is working (zecke) | 222 | * #1396 - Opie-console captures the escape key and vim is working (zecke) |
221 | * #1401 - Scrollbar is now only visible if necessary in DocTab (mickeyl) | 223 | * #1401 - Scrollbar is now only visible if necessary in DocTab (mickeyl) |
222 | 224 | ||
223 | 2004-07-06Opie 1.1.4 | 225 | 2004-07-06Opie 1.1.4 |
224 | 226 | ||
225 | New Features | 227 | New Features |
226 | ------------ | 228 | ------------ |
227 | * Added four themes courtesy Robert Griebl (http://www.softforge.de/zstyle) | 229 | * Added four themes courtesy Robert Griebl (http://www.softforge.de/zstyle) |
228 | * Added Conversion tool for pim-data (eilers) | 230 | * Added Conversion tool for pim-data (eilers) |
229 | * Introduced new OPimAccessFactory and OBackendFactory which simplyfies database access (eilers) | 231 | * Introduced new OPimAccessFactory and OBackendFactory which simplyfies database access (eilers) |
230 | * Modified the PIM API for providing generic use of OPimRecords (eilers) | 232 | * Modified the PIM API for providing generic use of OPimRecords (eilers) |
231 | * Clicking on the application symbol now iterates over the application's top level widgets if already raised (zecke) | 233 | * Clicking on the application symbol now iterates over the application's top level widgets if already raised (zecke) |
232 | 234 | ||
233 | Fixed Bugs | 235 | Fixed Bugs |
234 | -------- | 236 | -------- |
235 | * #1068 - Country Drop Down Box Off Screen | 237 | * #1068 - Country Drop Down Box Off Screen |
236 | * #1291 - Opie tinykate does not open .desktop files (ar) | 238 | * #1291 - Opie tinykate does not open .desktop files (ar) |
237 | * #1291 - Opie sheet not saving correctly (ar) | 239 | * #1291 - Opie sheet not saving correctly (ar) |
238 | * #1294 - Opie does not know about British Summer Time | 240 | * #1294 - Opie does not know about British Summer Time |
239 | * #1314 - Drawpad initialization (mickeyl) | 241 | * #1314 - Drawpad initialization (mickeyl) |
240 | * #1317 - Packagemanager crashes on hold-down or install (chicken) | 242 | * #1317 - Packagemanager crashes on hold-down or install (chicken) |
241 | * #1321 - Batteryapplet graphic glitch (harlekin) | 243 | * #1321 - Batteryapplet graphic glitch (harlekin) |
242 | * #1324 - ZSafe not starting up (mickeyl) | 244 | * #1324 - ZSafe not starting up (mickeyl) |
243 | * #1328 - Personal Home Address fields is trimmed to 1char (eilers) | 245 | * #1328 - Personal Home Address fields is trimmed to 1char (eilers) |
244 | * #1327 - Opie-mail ipk does not depend on libopiedb2 (chicken) | 246 | * #1327 - Opie-mail ipk does not depend on libopiedb2 (chicken) |
245 | * #1345 - Networksettingsplugin wlan plugin dependency on libpcap0 (mickeyl) | 247 | * #1345 - Networksettingsplugin wlan plugin dependency on libpcap0 (mickeyl) |
246 | * #1348 - Datebook dependency on libopiedb2 (chicken) | 248 | * #1348 - Datebook dependency on libopiedb2 (chicken) |
247 | * #1328 - Switched SQLDatabase and VCards char encoding from latin1 to unicode (eilers) | 249 | * #1328 - Switched SQLDatabase and VCards char encoding from latin1 to unicode (eilers) |
248 | 250 | ||
249 | 2004-04-25Opie 1.1.3 | 251 | 2004-04-25Opie 1.1.3 |
250 | 252 | ||
251 | * Introduced first implementation of SQL-Support using SQLite (eilers) | 253 | * Introduced first implementation of SQL-Support using SQLite (eilers) |
252 | * Added a new Gutenberg Project reader app - opie-gutenbrowser (ljp) | 254 | * Added a new Gutenberg Project reader app - opie-gutenbrowser (ljp) |
253 | * Added a real system graffiti character set (brad) | 255 | * Added a real system graffiti character set (brad) |
254 | * Added Generic Keyconfig Widget (zecke) | 256 | * Added Generic Keyconfig Widget (zecke) |
255 | * Improved Screenshotapplet and Drawpad integration. You can now open a screenshot in drawpad and take notes (zecke) | 257 | * Improved Screenshotapplet and Drawpad integration. You can now open a screenshot in drawpad and take notes (zecke) |
256 | * Added new Bible reader app - opie-dagger (drw) | 258 | * Added new Bible reader app - opie-dagger (drw) |
257 | * Added a new Image Viewer. Work is ongoing (zecke,alwin) | 259 | * Added a new Image Viewer. Work is ongoing (zecke,alwin) |
258 | * Added namespace usage in libopie2 and everywhere (zecke,alwin) | 260 | * Added namespace usage in libopie2 and everywhere (zecke,alwin) |
259 | * Enabled the possibility to pass command line arguments to applications (mickeyl) | 261 | * Enabled the possibility to pass command line arguments to applications (mickeyl) |
260 | * Added an about applet showing some credits and information about Opie (mickeyl) | 262 | * Added an about applet showing some credits and information about Opie (mickeyl) |
261 | * Added benchmarking functionality to sysinfo (mickeyl) | 263 | * Added benchmarking functionality to sysinfo (mickeyl) |
262 | * Added applet and configuration application for switching hardware keyboard layouts (alwin) | 264 | * Added applet and configuration application for switching hardware keyboard layouts (alwin) |
263 | * Ported applications from libopie1 to libopie2* (drw,ar,alwin) | 265 | * Ported applications from libopie1 to libopie2* (drw,ar,alwin) |
264 | * Imported fullscreen and font improvements from the Qkonsole fork to embeddedkonsole (waspe) | 266 | * Imported fullscreen and font improvements from the Qkonsole fork to embeddedkonsole (waspe) |
265 | * Clean-up of package information in control files (drw) | 267 | * Clean-up of package information in control files (drw) |
266 | * Repaired mediummount which was broken since integrating the quicklauncher (alwin) | 268 | * Repaired mediummount which was broken since integrating the quicklauncher (alwin) |
267 | * Improved big-screen support (zecke,ar) | 269 | * Improved big-screen support (zecke,ar) |
268 | * Improved multikeyboard support, added keyboard layout switching applet (mouse) | 270 | * Improved multikeyboard support, added keyboard layout switching applet (mouse) |
269 | * Added a new mail client based on libetpan (harlekin,alwin,jgf) | 271 | * Added a new mail client based on libetpan (harlekin,alwin,jgf) |
270 | * Added new package manager - opie-packagemanager (drw) | 272 | * Added new package manager - opie-packagemanager (drw) |
271 | * Improved light-n-power for C7x0 (mickeyl) | 273 | * Improved light-n-power for C7x0 (mickeyl) |
272 | * Added automatic rotation support for C7x0 (treke) | 274 | * Added automatic rotation support for C7x0 (treke) |
273 | * Split libopie1 up into a set of smaller - functionally grouped - libraries (mickeyl) | 275 | * Split libopie1 up into a set of smaller - functionally grouped - libraries (mickeyl) |
274 | * Added scanning the wireless network neighbourhood to networksettings (mickeyl) | 276 | * Added scanning the wireless network neighbourhood to networksettings (mickeyl) |
275 | 277 | ||
276 | 2003-11-29Opie 1.0.3 | 278 | 2003-11-29Opie 1.0.3 |
277 | 279 | ||
278 | * Released as Version 1.0.3 | 280 | * Released as Version 1.0.3 |
279 | * Improved i18n (various contributors) | 281 | * Improved i18n (various contributors) |
280 | * Reduced application startup time by integrating the TT quicklauncher (zecke,harlekin) | 282 | * Reduced application startup time by integrating the TT quicklauncher (zecke,harlekin) |
281 | * Made the Documents Tab optional (mickeyl) | 283 | * Made the Documents Tab optional (mickeyl) |
282 | * Integrated basic support for HP iPAQ 54xx and the Jornada 5xx (chicken) | 284 | * Integrated basic support for HP iPAQ 54xx and the Jornada 5xx (chicken) |
283 | 285 | ||
284 | 2003-08-04Opie 1.0.0 | 286 | 2003-08-04Opie 1.0.0 |
285 | 287 | ||
286 | * Released as Version 1.0.0 | 288 | * Released as Version 1.0.0 |
287 | * Including a PPP module for easy dial up (tille,harlekin,zecke) | 289 | * Including a PPP module for easy dial up (tille,harlekin,zecke) |
diff --git a/examples/opienet/miniwellenreiter/miniwellenreiter.cpp b/examples/opienet/miniwellenreiter/miniwellenreiter.cpp index ebd3b5f..ba9d2ca 100644 --- a/examples/opienet/miniwellenreiter/miniwellenreiter.cpp +++ b/examples/opienet/miniwellenreiter/miniwellenreiter.cpp | |||
@@ -1,234 +1,234 @@ | |||
1 | #include <qdict.h> | 1 | #include <qdict.h> |
2 | #include <qsocketnotifier.h> | 2 | #include <qsocketnotifier.h> |
3 | #include <qstring.h> | 3 | #include <qstring.h> |
4 | #include <opie2/onetwork.h> | 4 | #include <opie2/onetwork.h> |
5 | #include <qapplication.h> | 5 | #include <qapplication.h> |
6 | #include <opie2/opcap.h> | 6 | #include <opie2/opcap.h> |
7 | #include <cerrno> | 7 | #include <cerrno> |
8 | #include <cstdio> | 8 | #include <cstdio> |
9 | #include <cstdlib> | 9 | #include <cstdlib> |
10 | #include <cstring> | 10 | #include <cstring> |
11 | 11 | ||
12 | 12 | ||
13 | using namespace Opie::Net; | 13 | using namespace Opie::Net; |
14 | //======================== Station help class =============================== | 14 | //======================== Station help class =============================== |
15 | 15 | ||
16 | class Station | 16 | class Station |
17 | { | 17 | { |
18 | public: | 18 | public: |
19 | Station( QString t, int c, bool w ) : type(t), channel(c), wep(w), beacons(1) {}; | 19 | Station( QString t, int c, bool w ) : type(t), channel(c), wep(w), beacons(1) {}; |
20 | ~Station() {}; | 20 | ~Station() {}; |
21 | 21 | ||
22 | QString type; | 22 | QString type; |
23 | int channel; | 23 | int channel; |
24 | bool wep; | 24 | bool wep; |
25 | int beacons; | 25 | int beacons; |
26 | }; | 26 | }; |
27 | 27 | ||
28 | QDict<Station> stations; | 28 | QDict<Station> stations; |
29 | 29 | ||
30 | //======================== Application class =============================== | 30 | //======================== Application class =============================== |
31 | 31 | ||
32 | class Wellenreiter : public QApplication | 32 | class Wellenreiter : public QApplication |
33 | { | 33 | { |
34 | Q_OBJECT | 34 | Q_OBJECT |
35 | public: | 35 | public: |
36 | Wellenreiter( int argc, char** argv ) : QApplication( argc, argv ), channel( 1 ) | 36 | Wellenreiter( int argc, char** argv ) : QApplication( argc, argv ), channel( 1 ) |
37 | { | 37 | { |
38 | 38 | ||
39 | ONetwork* net = ONetwork::instance(); | 39 | ONetwork* net = ONetwork::instance(); |
40 | 40 | ||
41 | if ( argc < 3 ) | 41 | if ( argc < 3 ) |
42 | { | 42 | { |
43 | printf( "Usage: ./%s <interface> <driver> <interval>\n", argv[0] ); | 43 | printf( "Usage: ./%s <interface> <driver> <interval>\n", argv[0] ); |
44 | printf( "\n" ); | 44 | printf( "\n" ); |
45 | printf( "Valid wireless interfaces (detected) are:\n" ); | 45 | printf( "Valid wireless interfaces (detected) are:\n" ); |
46 | 46 | ||
47 | ONetwork::InterfaceIterator it = net->iterator(); | 47 | ONetwork::InterfaceIterator it = net->iterator(); |
48 | while ( it.current() ) | 48 | while ( it.current() ) |
49 | { | 49 | { |
50 | if ( it.current()->isWireless() ) | 50 | if ( it.current()->isWireless() ) |
51 | { | 51 | { |
52 | printf( " - '%s' (MAC=%s) (IPv4=%s)\n", (const char*) it.current()->name(), | 52 | printf( " - '%s' (MAC=%s) (IPv4=%s)\n", (const char*) it.current()->name(), |
53 | (const char*) it.current()->macAddress().toString(), | 53 | (const char*) it.current()->macAddress().toString(), |
54 | (const char*) it.current()->ipV4Address() ); | 54 | (const char*) it.current()->ipV4Address().toString() ); |
55 | } | 55 | } |
56 | ++it; | 56 | ++it; |
57 | } | 57 | } |
58 | exit( -1 ); | 58 | exit( -1 ); |
59 | } | 59 | } |
60 | 60 | ||
61 | printf( "*******************************************************************\n" ); | 61 | printf( "*******************************************************************\n" ); |
62 | printf( "* Wellenreiter mini edition 1.0.0 (C) 2003 Michael 'Mickey' Lauer *\n" ); | 62 | printf( "* Wellenreiter mini edition 1.0.0 (C) 2003 Michael 'Mickey' Lauer *\n" ); |
63 | printf( "*******************************************************************\n" ); | 63 | printf( "*******************************************************************\n" ); |
64 | printf( "\n\n" ); | 64 | printf( "\n\n" ); |
65 | 65 | ||
66 | QString interface( argv[1] ); | 66 | QString interface( argv[1] ); |
67 | QString driver( argv[2] ); | 67 | QString driver( argv[2] ); |
68 | 68 | ||
69 | printf( "Trying to use '%s' as %s-controlled device...\n", (const char*) interface, (const char*) driver ); | 69 | printf( "Trying to use '%s' as %s-controlled device...\n", (const char*) interface, (const char*) driver ); |
70 | 70 | ||
71 | // sanity checks before downcasting | 71 | // sanity checks before downcasting |
72 | ONetworkInterface* iface = net->interface( interface ); | 72 | ONetworkInterface* iface = net->interface( interface ); |
73 | if ( !iface ) | 73 | if ( !iface ) |
74 | { | 74 | { |
75 | printf( "Interface '%s' doesn't exist. Exiting.\n", (const char*) interface ); | 75 | printf( "Interface '%s' doesn't exist. Exiting.\n", (const char*) interface ); |
76 | exit( -1 ); | 76 | exit( -1 ); |
77 | } | 77 | } |
78 | if ( !iface->isWireless() ) | 78 | if ( !iface->isWireless() ) |
79 | { | 79 | { |
80 | printf( "Interface '%s' doesn't support wireless extensions. Exiting.\n", (const char*) interface ); | 80 | printf( "Interface '%s' doesn't support wireless extensions. Exiting.\n", (const char*) interface ); |
81 | exit( -1 ); | 81 | exit( -1 ); |
82 | } | 82 | } |
83 | 83 | ||
84 | // downcast should be safe now | 84 | // downcast should be safe now |
85 | wiface = (OWirelessNetworkInterface*) iface; | 85 | wiface = (OWirelessNetworkInterface*) iface; |
86 | printf( "Using wireless interface '%s' for scanning (current SSID is '%s')...\n", (const char*) interface, (const char*) wiface->SSID() ); | 86 | printf( "Using wireless interface '%s' for scanning (current SSID is '%s')...\n", (const char*) interface, (const char*) wiface->SSID() ); |
87 | 87 | ||
88 | // ifconfig +promisc the interface to receive all packets | 88 | // ifconfig +promisc the interface to receive all packets |
89 | if ( !wiface->promiscuousMode() ) | 89 | if ( !wiface->promiscuousMode() ) |
90 | { | 90 | { |
91 | printf( "Interface status is not promisc... switching to promisc... " ); | 91 | printf( "Interface status is not promisc... switching to promisc... " ); |
92 | wiface->setPromiscuousMode( true ); | 92 | wiface->setPromiscuousMode( true ); |
93 | if ( !wiface->promiscuousMode() ) | 93 | if ( !wiface->promiscuousMode() ) |
94 | { | 94 | { |
95 | printf( "failed (%s). Exiting.\n", strerror( errno ) ); | 95 | printf( "failed (%s). Exiting.\n", strerror( errno ) ); |
96 | exit( -1 ); | 96 | exit( -1 ); |
97 | } | 97 | } |
98 | else | 98 | else |
99 | { | 99 | { |
100 | printf( "ok.\n" ); | 100 | printf( "ok.\n" ); |
101 | } | 101 | } |
102 | } | 102 | } |
103 | else | 103 | else |
104 | printf( "Interface status is already promisc - good.\n" ); | 104 | printf( "Interface status is already promisc - good.\n" ); |
105 | 105 | ||
106 | // connect a monitoring strategy to the interface | 106 | // connect a monitoring strategy to the interface |
107 | if ( driver == "orinoco" ) | 107 | if ( driver == "orinoco" ) |
108 | new OOrinocoMonitoringInterface( wiface, false ); | 108 | new OOrinocoMonitoringInterface( wiface, false ); |
109 | else | 109 | else |
110 | if ( driver == "hostap" ) | 110 | if ( driver == "hostap" ) |
111 | new OHostAPMonitoringInterface( wiface, false ); | 111 | new OHostAPMonitoringInterface( wiface, false ); |
112 | else | 112 | else |
113 | if ( driver == "wlan-ng" ) | 113 | if ( driver == "wlan-ng" ) |
114 | new OWlanNGMonitoringInterface( wiface, false ); | 114 | new OWlanNGMonitoringInterface( wiface, false ); |
115 | else | 115 | else |
116 | { | 116 | { |
117 | printf( "Unknown driver. Exiting\n" ); | 117 | printf( "Unknown driver. Exiting\n" ); |
118 | exit( -1 ); | 118 | exit( -1 ); |
119 | } | 119 | } |
120 | 120 | ||
121 | // enable monitoring mode | 121 | // enable monitoring mode |
122 | printf( "Enabling monitor mode...\n" ); | 122 | printf( "Enabling monitor mode...\n" ); |
123 | wiface->setMode( "monitor" ); | 123 | wiface->setMode( "monitor" ); |
124 | 124 | ||
125 | // open a packet capturer | 125 | // open a packet capturer |
126 | cap = new OPacketCapturer(); | 126 | cap = new OPacketCapturer(); |
127 | cap->open( interface ); | 127 | cap->open( interface ); |
128 | if ( !cap->isOpen() ) | 128 | if ( !cap->isOpen() ) |
129 | { | 129 | { |
130 | printf( "Unable to open libpcap (%s). Exiting.\n", strerror( errno ) ); | 130 | printf( "Unable to open libpcap (%s). Exiting.\n", strerror( errno ) ); |
131 | exit( -1 ); | 131 | exit( -1 ); |
132 | } | 132 | } |
133 | 133 | ||
134 | // set capturer to non-blocking mode | 134 | // set capturer to non-blocking mode |
135 | cap->setBlocking( false ); | 135 | cap->setBlocking( false ); |
136 | 136 | ||
137 | // start channel hopper | 137 | // start channel hopper |
138 | //wiface->setChannelHopping( 1000 ); | 138 | //wiface->setChannelHopping( 1000 ); |
139 | 139 | ||
140 | // connect | 140 | // connect |
141 | connect( cap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); | 141 | connect( cap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); |
142 | // timer | 142 | // timer |
143 | startTimer( 1000 ); | 143 | startTimer( 1000 ); |
144 | 144 | ||
145 | } | 145 | } |
146 | 146 | ||
147 | ~Wellenreiter() {}; | 147 | ~Wellenreiter() {}; |
148 | 148 | ||
149 | public slots: | 149 | public slots: |
150 | virtual void timerEvent(QTimerEvent* e) | 150 | virtual void timerEvent(QTimerEvent* e) |
151 | { | 151 | { |
152 | wiface->setChannel( channel++ ); | 152 | wiface->setChannel( channel++ ); |
153 | if ( channel == 14 ) channel = 1; | 153 | if ( channel == 14 ) channel = 1; |
154 | } | 154 | } |
155 | 155 | ||
156 | void receivePacket(OPacket* p) | 156 | void receivePacket(OPacket* p) |
157 | { | 157 | { |
158 | if (!p) | 158 | if (!p) |
159 | { | 159 | { |
160 | printf( "(empty packet received)\n" ); | 160 | printf( "(empty packet received)\n" ); |
161 | return; | 161 | return; |
162 | } | 162 | } |
163 | 163 | ||
164 | OWaveLanManagementPacket* beacon = (OWaveLanManagementPacket*) p->child( "802.11 Management" ); | 164 | OWaveLanManagementPacket* beacon = (OWaveLanManagementPacket*) p->child( "802.11 Management" ); |
165 | if ( beacon ) | 165 | if ( beacon ) |
166 | { | 166 | { |
167 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); | 167 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); |
168 | QString essid = ssid ? ssid->ID() : QString::fromLatin1( "<unknown>" ); | 168 | QString essid = ssid ? ssid->ID() : QString::fromLatin1( "<unknown>" ); |
169 | 169 | ||
170 | if ( stations.find( essid ) ) | 170 | if ( stations.find( essid ) ) |
171 | stations[essid]->beacons++; | 171 | stations[essid]->beacons++; |
172 | else | 172 | else |
173 | { | 173 | { |
174 | printf( "found new network @ channel %d, SSID = '%s'\n", wiface->channel(), (const char*) essid ); | 174 | printf( "found new network @ channel %d, SSID = '%s'\n", wiface->channel(), (const char*) essid ); |
175 | stations.insert( essid, new Station( "unknown", wiface->channel(), | 175 | stations.insert( essid, new Station( "unknown", wiface->channel(), |
176 | ((OWaveLanPacket*) beacon->parent())->usesWep() ) ); | 176 | ((OWaveLanPacket*) beacon->parent())->usesWep() ) ); |
177 | } | 177 | } |
178 | return; | 178 | return; |
179 | } | 179 | } |
180 | 180 | ||
181 | OWaveLanDataPacket* data = (OWaveLanDataPacket*) p->child( "802.11 Data" ); | 181 | OWaveLanDataPacket* data = (OWaveLanDataPacket*) p->child( "802.11 Data" ); |
182 | if ( data ) | 182 | if ( data ) |
183 | { | 183 | { |
184 | OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); | 184 | OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); |
185 | if ( wlan->fromDS() && !wlan->toDS() ) | 185 | if ( wlan->fromDS() && !wlan->toDS() ) |
186 | { | 186 | { |
187 | printf( "FromDS: '%s' -> '%s' via '%s'\n", | 187 | printf( "FromDS: '%s' -> '%s' via '%s'\n", |
188 | (const char*) wlan->macAddress3().toString(true), | 188 | (const char*) wlan->macAddress3().toString(true), |
189 | (const char*) wlan->macAddress1().toString(true), | 189 | (const char*) wlan->macAddress1().toString(true), |
190 | (const char*) wlan->macAddress2().toString(true) ); | 190 | (const char*) wlan->macAddress2().toString(true) ); |
191 | } | 191 | } |
192 | else | 192 | else |
193 | if ( !wlan->fromDS() && wlan->toDS() ) | 193 | if ( !wlan->fromDS() && wlan->toDS() ) |
194 | { | 194 | { |
195 | printf( "ToDS: '%s' -> '%s' via '%s'\n", | 195 | printf( "ToDS: '%s' -> '%s' via '%s'\n", |
196 | (const char*) wlan->macAddress2().toString(true), | 196 | (const char*) wlan->macAddress2().toString(true), |
197 | (const char*) wlan->macAddress3().toString(true), | 197 | (const char*) wlan->macAddress3().toString(true), |
198 | (const char*) wlan->macAddress1().toString(true) ); | 198 | (const char*) wlan->macAddress1().toString(true) ); |
199 | } | 199 | } |
200 | else | 200 | else |
201 | if ( wlan->fromDS() && wlan->toDS() ) | 201 | if ( wlan->fromDS() && wlan->toDS() ) |
202 | { | 202 | { |
203 | printf( "WSD(bridge): '%s' -> '%s' via '%s' and '%s'\n", | 203 | printf( "WSD(bridge): '%s' -> '%s' via '%s' and '%s'\n", |
204 | (const char*) wlan->macAddress4().toString(true), | 204 | (const char*) wlan->macAddress4().toString(true), |
205 | (const char*) wlan->macAddress3().toString(true), | 205 | (const char*) wlan->macAddress3().toString(true), |
206 | (const char*) wlan->macAddress1().toString(true), | 206 | (const char*) wlan->macAddress1().toString(true), |
207 | (const char*) wlan->macAddress2().toString(true) ); | 207 | (const char*) wlan->macAddress2().toString(true) ); |
208 | } | 208 | } |
209 | else | 209 | else |
210 | { | 210 | { |
211 | printf( "IBSS(AdHoc): '%s' -> '%s' (Cell: '%s')'\n", | 211 | printf( "IBSS(AdHoc): '%s' -> '%s' (Cell: '%s')'\n", |
212 | (const char*) wlan->macAddress2().toString(true), | 212 | (const char*) wlan->macAddress2().toString(true), |
213 | (const char*) wlan->macAddress1().toString(true), | 213 | (const char*) wlan->macAddress1().toString(true), |
214 | (const char*) wlan->macAddress3().toString(true) ); | 214 | (const char*) wlan->macAddress3().toString(true) ); |
215 | } | 215 | } |
216 | return; | 216 | return; |
217 | } | 217 | } |
218 | } | 218 | } |
219 | private: | 219 | private: |
220 | OPacketCapturer* cap; | 220 | OPacketCapturer* cap; |
221 | OWirelessNetworkInterface* wiface; | 221 | OWirelessNetworkInterface* wiface; |
222 | int channel; | 222 | int channel; |
223 | }; | 223 | }; |
224 | 224 | ||
225 | 225 | ||
226 | int main( int argc, char** argv ) | 226 | int main( int argc, char** argv ) |
227 | { | 227 | { |
228 | Wellenreiter w( argc, argv ); | 228 | Wellenreiter w( argc, argv ); |
229 | w.exec(); | 229 | w.exec(); |
230 | return 0; | 230 | return 0; |
231 | } | 231 | } |
232 | 232 | ||
233 | #include "miniwellenreiter.moc" | 233 | #include "miniwellenreiter.moc" |
234 | 234 | ||
diff --git a/examples/opienet/onetworkdemo/onetworkdemo.cpp b/examples/opienet/onetworkdemo/onetworkdemo.cpp index b3a1115..e8958dc 100644 --- a/examples/opienet/onetworkdemo/onetworkdemo.cpp +++ b/examples/opienet/onetworkdemo/onetworkdemo.cpp | |||
@@ -1,181 +1,181 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the Opie Project | 2 | =. This file is part of the Opie Project |
3 | .=l. Copyright (C) 2004 Opie Team <opie-devel@handhelds.org> | 3 | .=l. Copyright (C) 2004 Opie Team <opie-devel@handhelds.org> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This library is free software; you can | 5 | _;:, .> :=|. This library is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This library is distributed in the hope that | 12 | .i_,=:_. -<s. This library is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
17 | ..}^=.= = ; Library General Public License for more | 17 | ..}^=.= = ; Library General Public License for more |
18 | ++= -. .` .: details. | 18 | ++= -. .` .: details. |
19 | : = ...= . :.=- | 19 | : = ...= . :.=- |
20 | -. .:....=;==+<; You should have received a copy of the GNU | 20 | -. .:....=;==+<; You should have received a copy of the GNU |
21 | -_. . . )=. = Library General Public License along with | 21 | -_. . . )=. = Library General Public License along with |
22 | -- :-=` this library; see the file COPYING.LIB. | 22 | -- :-=` this library; see the file COPYING.LIB. |
23 | If not, write to the Free Software Foundation, | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | 24 | Inc., 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | /* OPIE */ | 29 | /* OPIE */ |
30 | #include <opie2/onetwork.h> | 30 | #include <opie2/onetwork.h> |
31 | #include <opie2/ostation.h> | 31 | #include <opie2/ostation.h> |
32 | #include <opie2/omanufacturerdb.h> | 32 | #include <opie2/omanufacturerdb.h> |
33 | #include <opie2/odebug.h> | 33 | #include <opie2/odebug.h> |
34 | 34 | ||
35 | /* STD */ | 35 | /* STD */ |
36 | #include <unistd.h> | 36 | #include <unistd.h> |
37 | 37 | ||
38 | using namespace Opie::Net; | 38 | using namespace Opie::Net; |
39 | 39 | ||
40 | int main( int argc, char** argv ) | 40 | int main( int argc, char** argv ) |
41 | { | 41 | { |
42 | odebug << "OPIE Network Demo" << oendl; | 42 | odebug << "OPIE Network Demo" << oendl; |
43 | 43 | ||
44 | ONetwork* net = ONetwork::instance(); | 44 | ONetwork* net = ONetwork::instance(); |
45 | 45 | ||
46 | ONetwork::InterfaceIterator it = net->iterator(); | 46 | ONetwork::InterfaceIterator it = net->iterator(); |
47 | 47 | ||
48 | while ( it.current() ) | 48 | while ( it.current() ) |
49 | { | 49 | { |
50 | odebug << "DEMO: ONetwork contains Interface '" << it.current()->name() << "'" << oendl; | 50 | odebug << "DEMO: ONetwork contains Interface '" << it.current()->name() << "'" << oendl; |
51 | ONetworkInterfaceDriverInfo info = it.current()->driverInfo(); | 51 | ONetworkInterfaceDriverInfo info = it.current()->driverInfo(); |
52 | odebug << "DEMO: DriverName reported as '" << info.name() << "'" << oendl; | 52 | odebug << "DEMO: DriverName reported as '" << info.name() << "'" << oendl; |
53 | odebug << "DEMO: DriverVersion reported as '" << info.version() << "'" << oendl; | 53 | odebug << "DEMO: DriverVersion reported as '" << info.version() << "'" << oendl; |
54 | odebug << "DEMO: DriverFirmware reported as '" << info.firmware() << "'" << oendl; | 54 | odebug << "DEMO: DriverFirmware reported as '" << info.firmware() << "'" << oendl; |
55 | odebug << "DEMO: DriverBus reported as '" << info.bus() << "'" << oendl; | 55 | odebug << "DEMO: DriverBus reported as '" << info.bus() << "'" << oendl; |
56 | odebug << "DEMO: Datalink code is '" << it.current()->dataLinkType() << "'" << oendl; | 56 | odebug << "DEMO: Datalink code is '" << it.current()->dataLinkType() << "'" << oendl; |
57 | odebug << "DEMO: MAC Address is '" << it.current()->macAddress().toString() << "'" << oendl; | 57 | odebug << "DEMO: MAC Address is '" << it.current()->macAddress().toString() << "'" << oendl; |
58 | odebug << "DEMO: MAC Address is '" << it.current()->macAddress().toString(true) << "'" << oendl; | 58 | odebug << "DEMO: MAC Address is '" << it.current()->macAddress().toString(true) << "'" << oendl; |
59 | odebug << "DEMO: MAC Manufacturer seems to be '" << it.current()->macAddress().manufacturer() << "'" << oendl; | 59 | odebug << "DEMO: MAC Manufacturer seems to be '" << it.current()->macAddress().manufacturer() << "'" << oendl; |
60 | odebug << "DEMO: Manufacturertest1 = '" << OManufacturerDB::instance()->lookupExt( "08:00:87" ) << "'" << oendl; | 60 | odebug << "DEMO: Manufacturertest1 = '" << OManufacturerDB::instance()->lookupExt( "08:00:87" ) << "'" << oendl; |
61 | odebug << "DEMO: Manufacturertest2 = '" << OManufacturerDB::instance()->lookupExt( "E2:0C:0F" ) << "'" << oendl; | 61 | odebug << "DEMO: Manufacturertest2 = '" << OManufacturerDB::instance()->lookupExt( "E2:0C:0F" ) << "'" << oendl; |
62 | odebug << "Demo: IPv4 Address is '" << it.current()->ipV4Address() << "'" << oendl; | 62 | odebug << "Demo: IPv4 Address is '" << it.current()->ipV4Address().toString() << "'" << oendl; |
63 | if ( it.current()->isWireless() ) | 63 | if ( it.current()->isWireless() ) |
64 | { | 64 | { |
65 | OWirelessNetworkInterface* iface = static_cast<OWirelessNetworkInterface*>( it.current() ); | 65 | OWirelessNetworkInterface* iface = static_cast<OWirelessNetworkInterface*>( it.current() ); |
66 | odebug << "DEMO: '" << iface->name() << "' seems to feature the wireless extensions." << oendl; | 66 | odebug << "DEMO: '" << iface->name() << "' seems to feature the wireless extensions." << oendl; |
67 | odebug << "DEMO: Current SSID is '" << iface->SSID() << "'" << oendl; | 67 | odebug << "DEMO: Current SSID is '" << iface->SSID() << "'" << oendl; |
68 | odebug << "DEMO: Antenna is tuned to '" << iface->frequency() << "', that is channel " << iface->channel() << "" << oendl; | 68 | odebug << "DEMO: Antenna is tuned to '" << iface->frequency() << "', that is channel " << iface->channel() << "" << oendl; |
69 | 69 | ||
70 | //if ( iface->mode() == OWirelessNetworkInterface::adhoc ) | 70 | //if ( iface->mode() == OWirelessNetworkInterface::adhoc ) |
71 | //{ | 71 | //{ |
72 | //odebug << "DEMO: Associated AP has MAC Address '" << iface->associatedAP().toString() << "'" << oendl; | 72 | //odebug << "DEMO: Associated AP has MAC Address '" << iface->associatedAP().toString() << "'" << oendl; |
73 | //} | 73 | //} |
74 | 74 | ||
75 | /* | 75 | /* |
76 | 76 | ||
77 | // nickname | 77 | // nickname |
78 | odebug << "DEMO: Current NickName is '" << iface->nickName() << "'" << oendl; | 78 | odebug << "DEMO: Current NickName is '" << iface->nickName() << "'" << oendl; |
79 | iface->setNickName( "MyNickName" ); | 79 | iface->setNickName( "MyNickName" ); |
80 | if ( iface->nickName() != "MyNickName" ) | 80 | if ( iface->nickName() != "MyNickName" ) |
81 | odebug << "DEMO: Warning! Can't change nickname" << oendl; | 81 | odebug << "DEMO: Warning! Can't change nickname" << oendl; |
82 | else | 82 | else |
83 | odebug << "DEMO: Nickname change successful." << oendl; | 83 | odebug << "DEMO: Nickname change successful." << oendl; |
84 | 84 | ||
85 | /* | 85 | /* |
86 | 86 | ||
87 | // operation mode | 87 | // operation mode |
88 | odebug << "DEMO: Current OperationMode is '" << iface->mode() << "'" << oendl; | 88 | odebug << "DEMO: Current OperationMode is '" << iface->mode() << "'" << oendl; |
89 | iface->setMode( "adhoc" ); | 89 | iface->setMode( "adhoc" ); |
90 | if ( iface->mode() != "adhoc" ) | 90 | if ( iface->mode() != "adhoc" ) |
91 | odebug << "DEMO: Warning! Can't change operation mode" << oendl; | 91 | odebug << "DEMO: Warning! Can't change operation mode" << oendl; |
92 | else | 92 | else |
93 | odebug << "DEMO: Operation Mode change successful." << oendl; | 93 | odebug << "DEMO: Operation Mode change successful." << oendl; |
94 | 94 | ||
95 | // RF channel | 95 | // RF channel |
96 | odebug << "DEMO: Current Channel is '" << iface->channel() << "'" << oendl; | 96 | odebug << "DEMO: Current Channel is '" << iface->channel() << "'" << oendl; |
97 | iface->setChannel( 1 ); | 97 | iface->setChannel( 1 ); |
98 | if ( iface->channel() != 1 ) | 98 | if ( iface->channel() != 1 ) |
99 | odebug << "DEMO: Warning! Can't change RF channel" << oendl; | 99 | odebug << "DEMO: Warning! Can't change RF channel" << oendl; |
100 | else | 100 | else |
101 | odebug << "DEMO: RF channel change successful." << oendl; | 101 | odebug << "DEMO: RF channel change successful." << oendl; |
102 | 102 | ||
103 | iface->setMode( "managed" ); | 103 | iface->setMode( "managed" ); |
104 | 104 | ||
105 | */ | 105 | */ |
106 | 106 | ||
107 | /* | 107 | /* |
108 | 108 | ||
109 | // network scan | 109 | // network scan |
110 | 110 | ||
111 | OStationList* stations = iface->scanNetwork(); | 111 | OStationList* stations = iface->scanNetwork(); |
112 | if ( stations ) | 112 | if ( stations ) |
113 | { | 113 | { |
114 | odebug << "DEMO: # of stations around = " << stations->count() << "" << oendl; | 114 | odebug << "DEMO: # of stations around = " << stations->count() << "" << oendl; |
115 | OStation* station; | 115 | OStation* station; |
116 | for ( station = stations->first(); station != 0; station = stations->next() ) | 116 | for ( station = stations->first(); station != 0; station = stations->next() ) |
117 | { | 117 | { |
118 | odebug << "DEMO: station dump following..." << oendl; | 118 | odebug << "DEMO: station dump following..." << oendl; |
119 | station->dump(); | 119 | station->dump(); |
120 | } | 120 | } |
121 | } | 121 | } |
122 | 122 | ||
123 | else | 123 | else |
124 | { | 124 | { |
125 | odebug << "DEMO: Warning! Scan didn't work!" << oendl; | 125 | odebug << "DEMO: Warning! Scan didn't work!" << oendl; |
126 | } | 126 | } |
127 | 127 | ||
128 | /* | 128 | /* |
129 | 129 | ||
130 | // first some wrong calls to check if this is working | 130 | // first some wrong calls to check if this is working |
131 | iface->setPrivate( "seppel", 10 ); | 131 | iface->setPrivate( "seppel", 10 ); |
132 | iface->setPrivate( "monitor", 0 ); | 132 | iface->setPrivate( "monitor", 0 ); |
133 | 133 | ||
134 | // now the real deal | 134 | // now the real deal |
135 | iface->setPrivate( "monitor", 2, 2, 3 ); | 135 | iface->setPrivate( "monitor", 2, 2, 3 ); |
136 | 136 | ||
137 | // trying to set hw address to 12:34:56:AB:CD:EF | 137 | // trying to set hw address to 12:34:56:AB:CD:EF |
138 | 138 | ||
139 | /* | 139 | /* |
140 | 140 | ||
141 | OMacAddress addr = OMacAddress::fromString( "12:34:56:AB:CD:EF" ); | 141 | OMacAddress addr = OMacAddress::fromString( "12:34:56:AB:CD:EF" ); |
142 | iface->setUp( false ); | 142 | iface->setUp( false ); |
143 | iface->setMacAddress( addr ); | 143 | iface->setMacAddress( addr ); |
144 | iface->setUp( true ); | 144 | iface->setUp( true ); |
145 | odebug << "DEMO: MAC Address now is '" << iface->macAddress().toString() << "'" << oendl; | 145 | odebug << "DEMO: MAC Address now is '" << iface->macAddress().toString() << "'" << oendl; |
146 | 146 | ||
147 | */ | 147 | */ |
148 | 148 | ||
149 | // monitor test | 149 | // monitor test |
150 | 150 | ||
151 | 151 | ||
152 | 152 | ||
153 | odebug << "DEMO: current interface mode is '" << iface->mode() << "'" << oendl; | 153 | odebug << "DEMO: current interface mode is '" << iface->mode() << "'" << oendl; |
154 | iface->setMode( "monitor" ); | 154 | iface->setMode( "monitor" ); |
155 | odebug << "DEMO: current interface mode is '" << iface->mode() << "'" << oendl; | 155 | odebug << "DEMO: current interface mode is '" << iface->mode() << "'" << oendl; |
156 | 156 | ||
157 | sleep( 1 ); | 157 | sleep( 1 ); |
158 | 158 | ||
159 | iface->setChannel( 1 ); | 159 | iface->setChannel( 1 ); |
160 | iface->setMode( "managed" ); | 160 | iface->setMode( "managed" ); |
161 | 161 | ||
162 | //sleep( 1 ); | 162 | //sleep( 1 ); |
163 | odebug << "DEMO: current interface mode is '" << iface->mode() << "'" << oendl; | 163 | odebug << "DEMO: current interface mode is '" << iface->mode() << "'" << oendl; |
164 | 164 | ||
165 | /*iface->setMode( "adhoc" ); | 165 | /*iface->setMode( "adhoc" ); |
166 | sleep( 1 ); | 166 | sleep( 1 ); |
167 | odebug << "DEMO: current interface mode is '" << iface->mode() << "'" << oendl; | 167 | odebug << "DEMO: current interface mode is '" << iface->mode() << "'" << oendl; |
168 | iface->setMode( "managed" ); | 168 | iface->setMode( "managed" ); |
169 | sleep( 1 ); | 169 | sleep( 1 ); |
170 | odebug << "DEMO: current interface mode is '" << iface->mode() << "'" << oendl; | 170 | odebug << "DEMO: current interface mode is '" << iface->mode() << "'" << oendl; |
171 | iface->setMode( "master" ); | 171 | iface->setMode( "master" ); |
172 | sleep( 1 ); | 172 | sleep( 1 ); |
173 | odebug << "DEMO: current interface mode is '" << iface->mode() << "'" << oendl; */ | 173 | odebug << "DEMO: current interface mode is '" << iface->mode() << "'" << oendl; */ |
174 | 174 | ||
175 | } | 175 | } |
176 | ++it; | 176 | ++it; |
177 | } | 177 | } |
178 | 178 | ||
179 | return 0; | 179 | return 0; |
180 | 180 | ||
181 | } | 181 | } |
diff --git a/libopie2/opienet/onetutils.cpp b/libopie2/opienet/onetutils.cpp index c8c494a..9c3e650 100644 --- a/libopie2/opienet/onetutils.cpp +++ b/libopie2/opienet/onetutils.cpp | |||
@@ -1,241 +1,254 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | =. (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de> | |
4 | (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de> | ||
5 | =. | ||
6 | .=l. | 4 | .=l. |
7 | .>+-= | 5 | .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 6 | _;:, .> :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; version 2 of the License. | 10 | - . .-<_> .<> Foundation; version 2 of the License. |
13 | ._= =} : | 11 | ._= =} : |
14 | .%`+i> _;_. | 12 | .%`+i> _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 13 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 18 | ..}^=.= = ; Library General Public License for more |
21 | ++= -. .` .: details. | 19 | ++= -. .` .: details. |
22 | : = ...= . :.=- | 20 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 21 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 22 | -_. . . )=. = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 23 | -- :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 24 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 25 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
29 | 27 | ||
30 | */ | 28 | */ |
31 | 29 | ||
32 | #include <opie2/onetutils.h> | 30 | #include <opie2/onetutils.h> |
33 | #include <opie2/onetwork.h> | 31 | #include <opie2/onetwork.h> |
34 | #include <opie2/omanufacturerdb.h> | 32 | #include <opie2/omanufacturerdb.h> |
35 | 33 | ||
36 | #include <net/if.h> | 34 | #include <net/if.h> |
37 | #include <assert.h> | 35 | #include <assert.h> |
38 | #include <stdio.h> | 36 | #include <stdio.h> |
39 | 37 | ||
40 | namespace Opie { | 38 | namespace Opie { |
41 | namespace Net { | 39 | namespace Net { |
42 | 40 | ||
43 | /*====================================================================================== | 41 | /*====================================================================================== |
44 | * OMacAddress | 42 | * OMacAddress |
45 | *======================================================================================*/ | 43 | *======================================================================================*/ |
46 | 44 | ||
47 | // static initializer for broadcast and unknown MAC Adresses | 45 | // static initializer for broadcast and unknown MAC Adresses |
48 | const unsigned char __broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; | 46 | const unsigned char __broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; |
49 | const OMacAddress& OMacAddress::broadcast = OMacAddress( __broadcast ); | 47 | const OMacAddress& OMacAddress::broadcast = OMacAddress( __broadcast ); |
50 | const unsigned char __unknown[6] = { 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 }; | 48 | const unsigned char __unknown[6] = { 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 }; |
51 | const OMacAddress& OMacAddress::unknown = OMacAddress( __unknown ); | 49 | const OMacAddress& OMacAddress::unknown = OMacAddress( __unknown ); |
52 | 50 | ||
53 | //TODO: Incorporate Ethernet Manufacturer database here! (inline or so) | 51 | //TODO: Incorporate Ethernet Manufacturer database here! (inline or so) |
54 | 52 | ||
55 | OMacAddress::OMacAddress() | 53 | OMacAddress::OMacAddress() |
56 | { | 54 | { |
57 | memcpy( _bytes, __unknown, 6 ); | 55 | memcpy( _bytes, __unknown, 6 ); |
58 | } | 56 | } |
59 | 57 | ||
60 | 58 | ||
61 | OMacAddress::OMacAddress( unsigned char* p ) | 59 | OMacAddress::OMacAddress( unsigned char* p ) |
62 | { | 60 | { |
63 | memcpy( _bytes, p, 6 ); | 61 | memcpy( _bytes, p, 6 ); |
64 | } | 62 | } |
65 | 63 | ||
66 | 64 | ||
67 | OMacAddress::OMacAddress( const unsigned char* p ) | 65 | OMacAddress::OMacAddress( const unsigned char* p ) |
68 | { | 66 | { |
69 | memcpy( _bytes, p, 6 ); | 67 | memcpy( _bytes, p, 6 ); |
70 | } | 68 | } |
71 | 69 | ||
72 | 70 | ||
73 | OMacAddress::OMacAddress( struct ifreq& ifr ) | 71 | OMacAddress::OMacAddress( struct ifreq& ifr ) |
74 | { | 72 | { |
75 | memcpy( _bytes, ifr.ifr_hwaddr.sa_data, 6 ); | 73 | memcpy( _bytes, ifr.ifr_hwaddr.sa_data, 6 ); |
76 | } | 74 | } |
77 | 75 | ||
78 | 76 | ||
79 | OMacAddress::~OMacAddress() | 77 | OMacAddress::~OMacAddress() |
80 | { | 78 | { |
81 | } | 79 | } |
82 | 80 | ||
83 | 81 | ||
84 | //#ifdef QT_NO_DEBUG | 82 | //#ifdef QT_NO_DEBUG |
85 | //inline | 83 | //inline |
86 | //#endif | 84 | //#endif |
87 | const unsigned char* OMacAddress::native() const | 85 | const unsigned char* OMacAddress::native() const |
88 | { | 86 | { |
89 | return (const unsigned char*) &_bytes; | 87 | return (const unsigned char*) &_bytes; |
90 | } | 88 | } |
91 | 89 | ||
92 | 90 | ||
93 | OMacAddress OMacAddress::fromString( const QString& str ) | 91 | OMacAddress OMacAddress::fromString( const QString& str ) |
94 | { | 92 | { |
95 | QString addr( str ); | 93 | QString addr( str ); |
96 | unsigned char buf[6]; | 94 | unsigned char buf[6]; |
97 | bool ok = true; | 95 | bool ok = true; |
98 | int index = 14; | 96 | int index = 14; |
99 | for ( int i = 5; i >= 0; --i ) | 97 | for ( int i = 5; i >= 0; --i ) |
100 | { | 98 | { |
101 | buf[i] = addr.right( 2 ).toUShort( &ok, 16 ); | 99 | buf[i] = addr.right( 2 ).toUShort( &ok, 16 ); |
102 | if ( !ok ) return OMacAddress::unknown; | 100 | if ( !ok ) return OMacAddress::unknown; |
103 | addr.truncate( index ); | 101 | addr.truncate( index ); |
104 | index -= 3; | 102 | index -= 3; |
105 | } | 103 | } |
106 | return (const unsigned char*) &buf; | 104 | return (const unsigned char*) &buf; |
107 | } | 105 | } |
108 | 106 | ||
109 | 107 | ||
110 | QString OMacAddress::toString( bool substitute ) const | 108 | QString OMacAddress::toString( bool substitute ) const |
111 | { | 109 | { |
112 | QString manu; | 110 | QString manu; |
113 | manu.sprintf( "%.2X:%.2X:%.2X", _bytes[0]&0xff, _bytes[1]&0xff, _bytes[2]&0xff ); | 111 | manu.sprintf( "%.2X:%.2X:%.2X", _bytes[0]&0xff, _bytes[1]&0xff, _bytes[2]&0xff ); |
114 | QString serial; | 112 | QString serial; |
115 | serial.sprintf( ":%.2X:%.2X:%.2X", _bytes[3]&0xff, _bytes[4]&0xff, _bytes[5]&0xff ); | 113 | serial.sprintf( ":%.2X:%.2X:%.2X", _bytes[3]&0xff, _bytes[4]&0xff, _bytes[5]&0xff ); |
116 | if ( !substitute ) return manu+serial; | 114 | if ( !substitute ) return manu+serial; |
117 | // fallback - if no vendor is found, just use the number | 115 | // fallback - if no vendor is found, just use the number |
118 | QString textmanu = OManufacturerDB::instance()->lookup( manu ); | 116 | QString textmanu = OManufacturerDB::instance()->lookup( manu ); |
119 | return textmanu.isNull() ? manu+serial : textmanu+serial; | 117 | return textmanu.isNull() ? manu+serial : textmanu+serial; |
120 | } | 118 | } |
121 | 119 | ||
122 | 120 | ||
123 | QString OMacAddress::manufacturer() const | 121 | QString OMacAddress::manufacturer() const |
124 | { | 122 | { |
125 | return OManufacturerDB::instance()->lookupExt( toString() ); | 123 | return OManufacturerDB::instance()->lookupExt( toString() ); |
126 | } | 124 | } |
127 | 125 | ||
128 | 126 | ||
129 | bool operator==( const OMacAddress &m1, const OMacAddress &m2 ) | 127 | bool operator==( const OMacAddress &m1, const OMacAddress &m2 ) |
130 | { | 128 | { |
131 | return memcmp( &m1._bytes, &m2._bytes, 6 ) == 0; | 129 | return memcmp( &m1._bytes, &m2._bytes, 6 ) == 0; |
132 | } | 130 | } |
133 | 131 | ||
134 | 132 | ||
135 | /*====================================================================================== | 133 | /*====================================================================================== |
136 | * OHostAddress | 134 | * OHostAddress |
137 | *======================================================================================*/ | 135 | *======================================================================================*/ |
138 | 136 | ||
137 | OHostAddress::OHostAddress() | ||
138 | :QHostAddress() | ||
139 | { | ||
140 | } | ||
141 | |||
142 | |||
143 | OHostAddress::OHostAddress( Q_UINT32 ip4Addr ) | ||
144 | :QHostAddress( ip4Addr ) | ||
145 | { | ||
146 | } | ||
147 | |||
148 | |||
149 | OHostAddress::~OHostAddress() | ||
150 | { | ||
151 | } | ||
139 | 152 | ||
140 | /*====================================================================================== | 153 | /*====================================================================================== |
141 | * OPrivateIOCTL | 154 | * OPrivateIOCTL |
142 | *======================================================================================*/ | 155 | *======================================================================================*/ |
143 | 156 | ||
144 | OPrivateIOCTL::OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs ) | 157 | OPrivateIOCTL::OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs ) |
145 | :QObject( parent, name ), _ioctl( cmd ), _getargs( getargs ), _setargs( setargs ) | 158 | :QObject( parent, name ), _ioctl( cmd ), _getargs( getargs ), _setargs( setargs ) |
146 | { | 159 | { |
147 | } | 160 | } |
148 | 161 | ||
149 | 162 | ||
150 | OPrivateIOCTL::~OPrivateIOCTL() | 163 | OPrivateIOCTL::~OPrivateIOCTL() |
151 | { | 164 | { |
152 | } | 165 | } |
153 | 166 | ||
154 | 167 | ||
155 | int OPrivateIOCTL::numberGetArgs() const | 168 | int OPrivateIOCTL::numberGetArgs() const |
156 | { | 169 | { |
157 | return _getargs & IW_PRIV_SIZE_MASK; | 170 | return _getargs & IW_PRIV_SIZE_MASK; |
158 | } | 171 | } |
159 | 172 | ||
160 | 173 | ||
161 | int OPrivateIOCTL::typeGetArgs() const | 174 | int OPrivateIOCTL::typeGetArgs() const |
162 | { | 175 | { |
163 | return _getargs & IW_PRIV_TYPE_MASK >> 12; | 176 | return _getargs & IW_PRIV_TYPE_MASK >> 12; |
164 | } | 177 | } |
165 | 178 | ||
166 | 179 | ||
167 | int OPrivateIOCTL::numberSetArgs() const | 180 | int OPrivateIOCTL::numberSetArgs() const |
168 | { | 181 | { |
169 | return _setargs & IW_PRIV_SIZE_MASK; | 182 | return _setargs & IW_PRIV_SIZE_MASK; |
170 | } | 183 | } |
171 | 184 | ||
172 | 185 | ||
173 | int OPrivateIOCTL::typeSetArgs() const | 186 | int OPrivateIOCTL::typeSetArgs() const |
174 | { | 187 | { |
175 | return _setargs & IW_PRIV_TYPE_MASK >> 12; | 188 | return _setargs & IW_PRIV_TYPE_MASK >> 12; |
176 | } | 189 | } |
177 | 190 | ||
178 | 191 | ||
179 | void OPrivateIOCTL::invoke() const | 192 | void OPrivateIOCTL::invoke() const |
180 | { | 193 | { |
181 | ( (OWirelessNetworkInterface*) parent() )->wioctl( _ioctl ); | 194 | ( (OWirelessNetworkInterface*) parent() )->wioctl( _ioctl ); |
182 | } | 195 | } |
183 | 196 | ||
184 | 197 | ||
185 | void OPrivateIOCTL::setParameter( int num, u_int32_t value ) | 198 | void OPrivateIOCTL::setParameter( int num, u_int32_t value ) |
186 | { | 199 | { |
187 | u_int32_t* arglist = (u_int32_t*) &( (OWirelessNetworkInterface*) parent() )->_iwr.u.name; | 200 | u_int32_t* arglist = (u_int32_t*) &( (OWirelessNetworkInterface*) parent() )->_iwr.u.name; |
188 | arglist[num] = value; | 201 | arglist[num] = value; |
189 | } | 202 | } |
190 | 203 | ||
191 | 204 | ||
192 | 205 | ||
193 | namespace Internal { | 206 | namespace Internal { |
194 | /*====================================================================================== | 207 | /*====================================================================================== |
195 | * assorted functions | 208 | * assorted functions |
196 | *======================================================================================*/ | 209 | *======================================================================================*/ |
197 | 210 | ||
198 | void dumpBytes( const unsigned char* data, int num ) | 211 | void dumpBytes( const unsigned char* data, int num ) |
199 | { | 212 | { |
200 | printf( "Dumping %d bytes @ 0x%p", num, data ); | 213 | printf( "Dumping %d bytes @ 0x%p", num, data ); |
201 | printf( "-------------------------------------------\n" ); | 214 | printf( "-------------------------------------------\n" ); |
202 | 215 | ||
203 | for ( int i = 0; i < num; ++i ) | 216 | for ( int i = 0; i < num; ++i ) |
204 | { | 217 | { |
205 | printf( "%02x ", data[i] ); | 218 | printf( "%02x ", data[i] ); |
206 | if ( !((i+1) % 32) ) printf( "\n" ); | 219 | if ( !((i+1) % 32) ) printf( "\n" ); |
207 | } | 220 | } |
208 | printf( "\n\n" ); | 221 | printf( "\n\n" ); |
209 | } | 222 | } |
210 | 223 | ||
211 | 224 | ||
212 | int stringToMode( const QString& mode ) | 225 | int stringToMode( const QString& mode ) |
213 | { | 226 | { |
214 | if ( mode == "auto" ) return IW_MODE_AUTO; | 227 | if ( mode == "auto" ) return IW_MODE_AUTO; |
215 | else if ( mode == "adhoc" ) return IW_MODE_ADHOC; | 228 | else if ( mode == "adhoc" ) return IW_MODE_ADHOC; |
216 | else if ( mode == "managed" ) return IW_MODE_INFRA; | 229 | else if ( mode == "managed" ) return IW_MODE_INFRA; |
217 | else if ( mode == "master" ) return IW_MODE_MASTER; | 230 | else if ( mode == "master" ) return IW_MODE_MASTER; |
218 | else if ( mode == "repeater" ) return IW_MODE_REPEAT; | 231 | else if ( mode == "repeater" ) return IW_MODE_REPEAT; |
219 | else if ( mode == "secondary" ) return IW_MODE_SECOND; | 232 | else if ( mode == "secondary" ) return IW_MODE_SECOND; |
220 | else if ( mode == "monitor" ) return IW_MODE_MONITOR; | 233 | else if ( mode == "monitor" ) return IW_MODE_MONITOR; |
221 | else assert( 0 ); | 234 | else assert( 0 ); |
222 | } | 235 | } |
223 | 236 | ||
224 | 237 | ||
225 | QString modeToString( int mode ) | 238 | QString modeToString( int mode ) |
226 | { | 239 | { |
227 | switch ( mode ) | 240 | switch ( mode ) |
228 | { | 241 | { |
229 | case IW_MODE_AUTO: return "auto"; | 242 | case IW_MODE_AUTO: return "auto"; |
230 | case IW_MODE_ADHOC: return "adhoc"; | 243 | case IW_MODE_ADHOC: return "adhoc"; |
231 | case IW_MODE_INFRA: return "managed"; | 244 | case IW_MODE_INFRA: return "managed"; |
232 | case IW_MODE_MASTER: return "master"; | 245 | case IW_MODE_MASTER: return "master"; |
233 | case IW_MODE_REPEAT: return "repeater"; | 246 | case IW_MODE_REPEAT: return "repeater"; |
234 | case IW_MODE_SECOND: return "second"; | 247 | case IW_MODE_SECOND: return "second"; |
235 | case IW_MODE_MONITOR: return "monitor"; | 248 | case IW_MODE_MONITOR: return "monitor"; |
236 | default: assert( 0 ); | 249 | default: assert( 0 ); |
237 | } | 250 | } |
238 | } | 251 | } |
239 | } | 252 | } |
240 | } | 253 | } |
241 | } | 254 | } |
diff --git a/libopie2/opienet/onetutils.h b/libopie2/opienet/onetutils.h index 25c9238..f08738c 100644 --- a/libopie2/opienet/onetutils.h +++ b/libopie2/opienet/onetutils.h | |||
@@ -1,241 +1,241 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de> | 3 | =. (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de> |
4 | =. | ||
5 | .=l. | 4 | .=l. |
6 | .>+-= | 5 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 6 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; version 2 of the License. | 10 | - . .-<_> .<> Foundation; version 2 of the License. |
12 | ._= =} : | 11 | ._= =} : |
13 | .%`+i> _;_. | 12 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 13 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 18 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 19 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 20 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 21 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 22 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 23 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 24 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 25 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
28 | 27 | ||
29 | */ | 28 | */ |
30 | 29 | ||
31 | #ifndef ONETUTILS_H | 30 | #ifndef ONETUTILS_H |
32 | #define ONETUTILS_H | 31 | #define ONETUTILS_H |
33 | 32 | ||
34 | #include <qdict.h> | 33 | #include <qdict.h> |
35 | #include <qmap.h> | 34 | #include <qmap.h> |
36 | #include <qstring.h> | 35 | #include <qstring.h> |
37 | #include <qhostaddress.h> | 36 | #include <qhostaddress.h> |
38 | #include <qobject.h> | 37 | #include <qobject.h> |
39 | 38 | ||
40 | #include <sys/types.h> | 39 | #include <sys/types.h> |
41 | 40 | ||
42 | struct ifreq; | 41 | struct ifreq; |
43 | 42 | ||
44 | namespace Opie { | 43 | namespace Opie { |
45 | namespace Net { | 44 | namespace Net { |
46 | 45 | ||
47 | class OWirelessNetworkInterface; | 46 | class OWirelessNetworkInterface; |
48 | 47 | ||
49 | /*====================================================================================== | 48 | /*====================================================================================== |
50 | * OMacAddress | 49 | * OMacAddress |
51 | *======================================================================================*/ | 50 | *======================================================================================*/ |
52 | 51 | ||
53 | class OMacAddress | 52 | class OMacAddress |
54 | { | 53 | { |
55 | public: | 54 | public: |
56 | // QString c'tor? -zecke | 55 | // QString c'tor? -zecke |
57 | OMacAddress(); | 56 | OMacAddress(); |
58 | OMacAddress( unsigned char* ); | 57 | OMacAddress( unsigned char* ); |
59 | OMacAddress( const unsigned char* ); | 58 | OMacAddress( const unsigned char* ); |
60 | OMacAddress( struct ifreq& ); | 59 | OMacAddress( struct ifreq& ); |
61 | ~OMacAddress(); | 60 | ~OMacAddress(); |
62 | 61 | ||
63 | QString manufacturer() const; | 62 | QString manufacturer() const; |
64 | QString toString( bool substitute = false ) const; | 63 | QString toString( bool substitute = false ) const; |
65 | const unsigned char* native() const; | 64 | const unsigned char* native() const; |
66 | 65 | ||
67 | // no c'tor but this one why not make it a c'tor. it could also replace the others or is this the problem? | 66 | // no c'tor but this one why not make it a c'tor. it could also replace the others or is this the problem? |
68 | static OMacAddress fromString( const QString& ); | 67 | static OMacAddress fromString( const QString& ); |
69 | 68 | ||
70 | public: | 69 | public: |
71 | static const OMacAddress& broadcast; // ff:ff:ff:ff:ff:ff | 70 | static const OMacAddress& broadcast; // ff:ff:ff:ff:ff:ff |
72 | static const OMacAddress& unknown; // 44:44:44:44:44:44 | 71 | static const OMacAddress& unknown; // 44:44:44:44:44:44 |
73 | 72 | ||
74 | private: | 73 | private: |
75 | unsigned char _bytes[6]; | 74 | unsigned char _bytes[6]; |
76 | 75 | ||
77 | friend bool operator==( const OMacAddress &m1, const OMacAddress &m2 ); | 76 | friend bool operator==( const OMacAddress &m1, const OMacAddress &m2 ); |
78 | class Private; | 77 | class Private; |
79 | Private *d; | 78 | Private *d; |
80 | 79 | ||
81 | }; | 80 | }; |
82 | 81 | ||
83 | bool operator==( const OMacAddress &m1, const OMacAddress &m2 ); | 82 | bool operator==( const OMacAddress &m1, const OMacAddress &m2 ); |
84 | 83 | ||
85 | 84 | ||
86 | /*====================================================================================== | 85 | /*====================================================================================== |
87 | * OHostAddress | 86 | * OHostAddress |
88 | *======================================================================================*/ | 87 | *======================================================================================*/ |
89 | 88 | ||
90 | class OHostAddress : public QHostAddress | 89 | class OHostAddress : public QHostAddress |
91 | { | 90 | { |
92 | /*public: | 91 | public: |
93 | OHostAddress(); | 92 | OHostAddress(); |
93 | OHostAddress( Q_UINT32 ip4Addr ); | ||
94 | ~OHostAddress(); | 94 | ~OHostAddress(); |
95 | */ | 95 | |
96 | private: | 96 | private: |
97 | class Private; | 97 | class Private; |
98 | Private *d; | 98 | Private *d; |
99 | }; | 99 | }; |
100 | 100 | ||
101 | 101 | ||
102 | /*====================================================================================== | 102 | /*====================================================================================== |
103 | * ONetworkInterfaceDriverInfo | 103 | * ONetworkInterfaceDriverInfo |
104 | *======================================================================================*/ | 104 | *======================================================================================*/ |
105 | 105 | ||
106 | class ONetworkInterfaceDriverInfo | 106 | class ONetworkInterfaceDriverInfo |
107 | { | 107 | { |
108 | public: | 108 | public: |
109 | ONetworkInterfaceDriverInfo( const QString& name = "<unknown>", | 109 | ONetworkInterfaceDriverInfo( const QString& name = "<unknown>", |
110 | const QString& version = "<unknown>", | 110 | const QString& version = "<unknown>", |
111 | const QString& firmware = "<unknown>", | 111 | const QString& firmware = "<unknown>", |
112 | const QString& bus = "<unknown>" ) : | 112 | const QString& bus = "<unknown>" ) : |
113 | _name( name ), _version( version ), _firmware( firmware ), _bus( bus ) { }; | 113 | _name( name ), _version( version ), _firmware( firmware ), _bus( bus ) { }; |
114 | ~ONetworkInterfaceDriverInfo() { }; | 114 | ~ONetworkInterfaceDriverInfo() { }; |
115 | 115 | ||
116 | QString name() const { return _name; }; | 116 | QString name() const { return _name; }; |
117 | QString version() const { return _version; }; | 117 | QString version() const { return _version; }; |
118 | QString firmware() const { return _firmware; }; | 118 | QString firmware() const { return _firmware; }; |
119 | QString bus() const { return _bus; }; | 119 | QString bus() const { return _bus; }; |
120 | 120 | ||
121 | private: | 121 | private: |
122 | const QString _name; | 122 | const QString _name; |
123 | const QString _version; | 123 | const QString _version; |
124 | const QString _firmware; | 124 | const QString _firmware; |
125 | const QString _bus; | 125 | const QString _bus; |
126 | }; | 126 | }; |
127 | 127 | ||
128 | /*====================================================================================== | 128 | /*====================================================================================== |
129 | * OPrivateIOCTL | 129 | * OPrivateIOCTL |
130 | *======================================================================================*/ | 130 | *======================================================================================*/ |
131 | 131 | ||
132 | class OPrivateIOCTL : public QObject | 132 | class OPrivateIOCTL : public QObject |
133 | { | 133 | { |
134 | public: | 134 | public: |
135 | OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs ); | 135 | OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs ); |
136 | ~OPrivateIOCTL(); | 136 | ~OPrivateIOCTL(); |
137 | 137 | ||
138 | int numberGetArgs() const; | 138 | int numberGetArgs() const; |
139 | int typeGetArgs() const; | 139 | int typeGetArgs() const; |
140 | int numberSetArgs() const; | 140 | int numberSetArgs() const; |
141 | int typeSetArgs() const; | 141 | int typeSetArgs() const; |
142 | 142 | ||
143 | // FIXME return int? as ::ioctl does? -zecke | 143 | // FIXME return int? as ::ioctl does? -zecke |
144 | void invoke() const; | 144 | void invoke() const; |
145 | void setParameter( int, u_int32_t ); | 145 | void setParameter( int, u_int32_t ); |
146 | 146 | ||
147 | private: | 147 | private: |
148 | u_int32_t _ioctl; | 148 | u_int32_t _ioctl; |
149 | u_int16_t _getargs; | 149 | u_int16_t _getargs; |
150 | u_int16_t _setargs; | 150 | u_int16_t _setargs; |
151 | 151 | ||
152 | class Private; | 152 | class Private; |
153 | Private *d; | 153 | Private *d; |
154 | }; | 154 | }; |
155 | 155 | ||
156 | /*====================================================================================== | 156 | /*====================================================================================== |
157 | * Miscellaneous | 157 | * Miscellaneous |
158 | *======================================================================================*/ | 158 | *======================================================================================*/ |
159 | 159 | ||
160 | namespace Internal { | 160 | namespace Internal { |
161 | void dumpBytes( const unsigned char* data, int num ); | 161 | void dumpBytes( const unsigned char* data, int num ); |
162 | QString modeToString( int ); | 162 | QString modeToString( int ); |
163 | int stringToMode( const QString& ); | 163 | int stringToMode( const QString& ); |
164 | } | 164 | } |
165 | } | 165 | } |
166 | } | 166 | } |
167 | 167 | ||
168 | #define IW_PRIV_TYPE_MASK 0x7000 | 168 | #define IW_PRIV_TYPE_MASK 0x7000 |
169 | #define IW_PRIV_TYPE_NONE 0x0000 | 169 | #define IW_PRIV_TYPE_NONE 0x0000 |
170 | #define IW_PRIV_TYPE_BYTE 0x1000 | 170 | #define IW_PRIV_TYPE_BYTE 0x1000 |
171 | #define IW_PRIV_TYPE_CHAR 0x2000 | 171 | #define IW_PRIV_TYPE_CHAR 0x2000 |
172 | #define IW_PRIV_TYPE_INT 0x4000 | 172 | #define IW_PRIV_TYPE_INT 0x4000 |
173 | #define IW_PRIV_TYPE_FLOAT 0x5000 | 173 | #define IW_PRIV_TYPE_FLOAT 0x5000 |
174 | #define IW_PRIV_TYPE_ADDR 0x6000 | 174 | #define IW_PRIV_TYPE_ADDR 0x6000 |
175 | #define IW_PRIV_SIZE_FIXED 0x0800 | 175 | #define IW_PRIV_SIZE_FIXED 0x0800 |
176 | #define IW_PRIV_SIZE_MASK 0x07FF | 176 | #define IW_PRIV_SIZE_MASK 0x07FF |
177 | 177 | ||
178 | #define IW_HEADER_TYPE_NULL 0 /* Not available */ | 178 | #define IW_HEADER_TYPE_NULL 0 /* Not available */ |
179 | #define IW_HEADER_TYPE_CHAR 2 /* char [IFNAMSIZ] */ | 179 | #define IW_HEADER_TYPE_CHAR 2 /* char [IFNAMSIZ] */ |
180 | #define IW_HEADER_TYPE_UINT 4 /* __u32 */ | 180 | #define IW_HEADER_TYPE_UINT 4 /* __u32 */ |
181 | #define IW_HEADER_TYPE_FREQ 5 /* struct iw_freq */ | 181 | #define IW_HEADER_TYPE_FREQ 5 /* struct iw_freq */ |
182 | #define IW_HEADER_TYPE_ADDR 6 /* struct sockaddr */ | 182 | #define IW_HEADER_TYPE_ADDR 6 /* struct sockaddr */ |
183 | #define IW_HEADER_TYPE_POINT 8 /* struct iw_point */ | 183 | #define IW_HEADER_TYPE_POINT 8 /* struct iw_point */ |
184 | #define IW_HEADER_TYPE_PARAM 9 /* struct iw_param */ | 184 | #define IW_HEADER_TYPE_PARAM 9 /* struct iw_param */ |
185 | #define IW_HEADER_TYPE_QUAL 10 /* struct iw_quality */ | 185 | #define IW_HEADER_TYPE_QUAL 10 /* struct iw_quality */ |
186 | 186 | ||
187 | #define IW_EV_POINT_OFF (((char *) &(((struct iw_point *) NULL)->length)) - \ | 187 | #define IW_EV_POINT_OFF (((char *) &(((struct iw_point *) NULL)->length)) - \ |
188 | (char *) NULL) | 188 | (char *) NULL) |
189 | 189 | ||
190 | #ifndef ARPHRD_IEEE80211 | 190 | #ifndef ARPHRD_IEEE80211 |
191 | #define ARPHRD_IEEE80211 801 | 191 | #define ARPHRD_IEEE80211 801 |
192 | #endif | 192 | #endif |
193 | #ifndef ARPHRD_IEEE80211_PRISM | 193 | #ifndef ARPHRD_IEEE80211_PRISM |
194 | #define ARPHRD_IEEE80211_PRISM 802 | 194 | #define ARPHRD_IEEE80211_PRISM 802 |
195 | #endif | 195 | #endif |
196 | 196 | ||
197 | /* Wireless Extension Scanning Stuff */ | 197 | /* Wireless Extension Scanning Stuff */ |
198 | struct iw_stream_descr | 198 | struct iw_stream_descr |
199 | { | 199 | { |
200 | char * end; /* End of the stream */ | 200 | char * end; /* End of the stream */ |
201 | char * current; /* Current event in stream of events */ | 201 | char * current; /* Current event in stream of events */ |
202 | char * value; /* Current value in event */ | 202 | char * value; /* Current value in event */ |
203 | }; | 203 | }; |
204 | 204 | ||
205 | 205 | ||
206 | /* Network to host order macros */ | 206 | /* Network to host order macros */ |
207 | 207 | ||
208 | #ifdef LBL_ALIGN | 208 | #ifdef LBL_ALIGN |
209 | #define EXTRACT_16BITS(p) \ | 209 | #define EXTRACT_16BITS(p) \ |
210 | ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 0) << 8 | \ | 210 | ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 0) << 8 | \ |
211 | (u_int16_t)*((const u_int8_t *)(p) + 1))) | 211 | (u_int16_t)*((const u_int8_t *)(p) + 1))) |
212 | #define EXTRACT_32BITS(p) \ | 212 | #define EXTRACT_32BITS(p) \ |
213 | ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 24 | \ | 213 | ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 24 | \ |
214 | (u_int32_t)*((const u_int8_t *)(p) + 1) << 16 | \ | 214 | (u_int32_t)*((const u_int8_t *)(p) + 1) << 16 | \ |
215 | (u_int32_t)*((const u_int8_t *)(p) + 2) << 8 | \ | 215 | (u_int32_t)*((const u_int8_t *)(p) + 2) << 8 | \ |
216 | (u_int32_t)*((const u_int8_t *)(p) + 3))) | 216 | (u_int32_t)*((const u_int8_t *)(p) + 3))) |
217 | #else | 217 | #else |
218 | #define EXTRACT_16BITS(p) \ | 218 | #define EXTRACT_16BITS(p) \ |
219 | ((u_int16_t)ntohs(*(const u_int16_t *)(p))) | 219 | ((u_int16_t)ntohs(*(const u_int16_t *)(p))) |
220 | #define EXTRACT_32BITS(p) \ | 220 | #define EXTRACT_32BITS(p) \ |
221 | ((u_int32_t)ntohl(*(const u_int32_t *)(p))) | 221 | ((u_int32_t)ntohl(*(const u_int32_t *)(p))) |
222 | #endif | 222 | #endif |
223 | 223 | ||
224 | #define EXTRACT_24BITS(p) \ | 224 | #define EXTRACT_24BITS(p) \ |
225 | ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 16 | \ | 225 | ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 16 | \ |
226 | (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \ | 226 | (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \ |
227 | (u_int32_t)*((const u_int8_t *)(p) + 2))) | 227 | (u_int32_t)*((const u_int8_t *)(p) + 2))) |
228 | 228 | ||
229 | /* Little endian protocol host order macros */ | 229 | /* Little endian protocol host order macros */ |
230 | #define EXTRACT_LE_8BITS(p) (*(p)) | 230 | #define EXTRACT_LE_8BITS(p) (*(p)) |
231 | #define EXTRACT_LE_16BITS(p) \ | 231 | #define EXTRACT_LE_16BITS(p) \ |
232 | ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 1) << 8 | \ | 232 | ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 1) << 8 | \ |
233 | (u_int16_t)*((const u_int8_t *)(p) + 0))) | 233 | (u_int16_t)*((const u_int8_t *)(p) + 0))) |
234 | #define EXTRACT_LE_32BITS(p) \ | 234 | #define EXTRACT_LE_32BITS(p) \ |
235 | ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 3) << 24 | \ | 235 | ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 3) << 24 | \ |
236 | (u_int32_t)*((const u_int8_t *)(p) + 2) << 16 | \ | 236 | (u_int32_t)*((const u_int8_t *)(p) + 2) << 16 | \ |
237 | (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \ | 237 | (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \ |
238 | (u_int32_t)*((const u_int8_t *)(p) + 0))) | 238 | (u_int32_t)*((const u_int8_t *)(p) + 0))) |
239 | 239 | ||
240 | #endif // ONETUTILS_H | 240 | #endif // ONETUTILS_H |
241 | 241 | ||
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp index 1deb051..0649ca2 100644 --- a/libopie2/opienet/onetwork.cpp +++ b/libopie2/opienet/onetwork.cpp | |||
@@ -1,1463 +1,1452 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) 2003-2005 by Michael 'Mickey' Lauer <mickey@Vanille.de> | 3 | =. Copyright (C) 2003-2005 by Michael 'Mickey' Lauer <mickey@Vanille.de> |
4 | =. | ||
5 | .=l. | 4 | .=l. |
6 | .>+-= | 5 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 6 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; version 2 of the License. | 10 | - . .-<_> .<> Foundation; version 2 of the License. |
12 | ._= =} : | 11 | ._= =} : |
13 | .%`+i> _;_. | 12 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 13 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 18 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 19 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 20 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 21 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 22 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 23 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 24 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 25 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
28 | 27 | ||
29 | */ | 28 | */ |
30 | 29 | ||
31 | /* OPIE */ | 30 | /* OPIE */ |
32 | #include <opie2/onetwork.h> | 31 | #include <opie2/onetwork.h> |
33 | #include <opie2/ostation.h> | 32 | #include <opie2/ostation.h> |
34 | #include <opie2/odebug.h> | 33 | #include <opie2/odebug.h> |
35 | using namespace Opie::Core; | 34 | using namespace Opie::Core; |
36 | 35 | ||
37 | /* QT */ | 36 | /* QT */ |
38 | #include <qfile.h> | 37 | #include <qfile.h> |
39 | #include <qtextstream.h> | 38 | #include <qtextstream.h> |
40 | #include <qapplication.h> | 39 | #include <qapplication.h> |
41 | 40 | ||
42 | /* STD */ | 41 | /* STD */ |
43 | #include <assert.h> | 42 | #include <assert.h> |
44 | #include <arpa/inet.h> | 43 | #include <arpa/inet.h> |
45 | #include <errno.h> | 44 | #include <errno.h> |
46 | #include <stdarg.h> | 45 | #include <stdarg.h> |
47 | #include <string.h> | 46 | #include <string.h> |
48 | #include <stdlib.h> | 47 | #include <stdlib.h> |
49 | #include <math.h> | 48 | #include <math.h> |
50 | #include <unistd.h> | 49 | #include <unistd.h> |
51 | #include <net/if_arp.h> | 50 | #include <net/if_arp.h> |
52 | #include <net/ethernet.h> | 51 | #include <net/ethernet.h> |
53 | #include <sys/ioctl.h> | 52 | #include <sys/ioctl.h> |
54 | #include <sys/socket.h> | 53 | #include <sys/socket.h> |
55 | #include <sys/types.h> | 54 | #include <sys/types.h> |
56 | #include <linux/types.h> | 55 | #include <linux/types.h> |
57 | #include <linux/sockios.h> | 56 | #include <linux/sockios.h> |
58 | #define u64 __u64 | 57 | #define u64 __u64 |
59 | #define u32 __u32 | 58 | #define u32 __u32 |
60 | #define u16 __u16 | 59 | #define u16 __u16 |
61 | #define u8 __u8 | 60 | #define u8 __u8 |
62 | #include <linux/ethtool.h> | 61 | #include <linux/ethtool.h> |
63 | 62 | ||
64 | #ifndef NODEBUG | 63 | #ifndef NODEBUG |
65 | #include <opie2/odebugmapper.h> | 64 | #include <opie2/odebugmapper.h> |
66 | using namespace Opie::Net::Internal; | 65 | using namespace Opie::Net::Internal; |
67 | DebugMapper* debugmapper = new DebugMapper(); | 66 | DebugMapper* debugmapper = new DebugMapper(); |
68 | #endif | 67 | #endif |
69 | 68 | ||
70 | /*====================================================================================== | 69 | /*====================================================================================== |
71 | * ONetwork | 70 | * ONetwork |
72 | *======================================================================================*/ | 71 | *======================================================================================*/ |
73 | 72 | ||
74 | namespace Opie { | 73 | namespace Opie { |
75 | namespace Net { | 74 | namespace Net { |
76 | ONetwork* ONetwork::_instance = 0; | 75 | ONetwork* ONetwork::_instance = 0; |
77 | 76 | ||
78 | ONetwork::ONetwork() | 77 | ONetwork::ONetwork() |
79 | { | 78 | { |
80 | odebug << "ONetwork::ONetwork()" << oendl; | 79 | odebug << "ONetwork::ONetwork()" << oendl; |
81 | odebug << "ONetwork: This code has been compiled against Wireless Extensions V" << WIRELESS_EXT << oendl; | 80 | odebug << "ONetwork: This code has been compiled against Wireless Extensions V" << WIRELESS_EXT << oendl; |
82 | synchronize(); | 81 | synchronize(); |
83 | } | 82 | } |
84 | 83 | ||
85 | void ONetwork::synchronize() | 84 | void ONetwork::synchronize() |
86 | { | 85 | { |
87 | // gather available interfaces by inspecting /proc/net/dev | 86 | // gather available interfaces by inspecting /proc/net/dev |
88 | //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices | ||
89 | //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices | ||
90 | //FIXME: Best is use SIOCGIFCONF and if this doesn't work (result=-1), then fallback to parsing /proc/net/dev | ||
91 | |||
92 | _interfaces.clear(); | 87 | _interfaces.clear(); |
93 | QString str; | 88 | QString str; |
94 | QFile f( "/proc/net/dev" ); | 89 | QFile f( "/proc/net/dev" ); |
95 | bool hasFile = f.open( IO_ReadOnly ); | 90 | bool hasFile = f.open( IO_ReadOnly ); |
96 | if ( !hasFile ) | 91 | if ( !hasFile ) |
97 | { | 92 | { |
98 | odebug << "ONetwork: /proc/net/dev not existing. No network devices available" << oendl; | 93 | odebug << "ONetwork: /proc/net/dev not existing. No network devices available" << oendl; |
99 | return; | 94 | return; |
100 | } | 95 | } |
101 | QTextStream s( &f ); | 96 | QTextStream s( &f ); |
102 | s.readLine(); | 97 | s.readLine(); |
103 | s.readLine(); | 98 | s.readLine(); |
104 | while ( !s.atEnd() ) | 99 | while ( !s.atEnd() ) |
105 | { | 100 | { |
106 | s >> str; | 101 | s >> str; |
107 | str.truncate( str.find( ':' ) ); | 102 | str.truncate( str.find( ':' ) ); |
108 | odebug << "ONetwork: found interface '" << str << "'" << oendl; | 103 | odebug << "ONetwork: found interface '" << str << "'" << oendl; |
109 | if ( str.startsWith( "wifi" ) ) | 104 | if ( str.startsWith( "wifi" ) ) |
110 | { | 105 | { |
111 | odebug << "ONetwork: ignoring hostap control interface" << oendl; | 106 | odebug << "ONetwork: ignoring hostap control interface" << oendl; |
112 | s.readLine(); | 107 | s.readLine(); |
113 | continue; | 108 | continue; |
114 | } | 109 | } |
115 | ONetworkInterface* iface = 0; | 110 | ONetworkInterface* iface = 0; |
116 | if ( isWirelessInterface( str ) ) | 111 | if ( isWirelessInterface( str ) ) |
117 | { | 112 | { |
118 | iface = new OWirelessNetworkInterface( this, (const char*) str ); | 113 | iface = new OWirelessNetworkInterface( this, (const char*) str ); |
119 | odebug << "ONetwork: interface '" << str << "' has Wireless Extensions" << oendl; | 114 | odebug << "ONetwork: interface '" << str << "' has Wireless Extensions" << oendl; |
120 | } | 115 | } |
121 | else | 116 | else |
122 | { | 117 | { |
123 | iface = new ONetworkInterface( this, (const char*) str ); | 118 | iface = new ONetworkInterface( this, (const char*) str ); |
124 | } | 119 | } |
125 | _interfaces.insert( str, iface ); | 120 | _interfaces.insert( str, iface ); |
126 | s.readLine(); | 121 | s.readLine(); |
127 | } | 122 | } |
128 | } | 123 | } |
129 | 124 | ||
130 | 125 | ||
131 | short ONetwork::wirelessExtensionCompileVersion() | 126 | short ONetwork::wirelessExtensionCompileVersion() |
132 | { | 127 | { |
133 | return WIRELESS_EXT; | 128 | return WIRELESS_EXT; |
134 | } | 129 | } |
135 | 130 | ||
136 | 131 | ||
137 | int ONetwork::count() const | 132 | int ONetwork::count() const |
138 | { | 133 | { |
139 | return _interfaces.count(); | 134 | return _interfaces.count(); |
140 | } | 135 | } |
141 | 136 | ||
142 | 137 | ||
143 | ONetworkInterface* ONetwork::interface( const QString& iface ) const | 138 | ONetworkInterface* ONetwork::interface( const QString& iface ) const |
144 | { | 139 | { |
145 | return _interfaces[iface]; | 140 | return _interfaces[iface]; |
146 | } | 141 | } |
147 | 142 | ||
148 | 143 | ||
149 | ONetwork* ONetwork::instance() | 144 | ONetwork* ONetwork::instance() |
150 | { | 145 | { |
151 | if ( !_instance ) _instance = new ONetwork(); | 146 | if ( !_instance ) _instance = new ONetwork(); |
152 | return _instance; | 147 | return _instance; |
153 | } | 148 | } |
154 | 149 | ||
155 | 150 | ||
156 | ONetwork::InterfaceIterator ONetwork::iterator() const | 151 | ONetwork::InterfaceIterator ONetwork::iterator() const |
157 | { | 152 | { |
158 | return ONetwork::InterfaceIterator( _interfaces ); | 153 | return ONetwork::InterfaceIterator( _interfaces ); |
159 | } | 154 | } |
160 | 155 | ||
161 | 156 | ||
162 | bool ONetwork::isPresent( const char* name ) const | 157 | bool ONetwork::isPresent( const char* name ) const |
163 | { | 158 | { |
164 | int sfd = socket( AF_INET, SOCK_STREAM, 0 ); | 159 | int sfd = socket( AF_INET, SOCK_STREAM, 0 ); |
165 | struct ifreq ifr; | 160 | struct ifreq ifr; |
166 | memset( &ifr, 0, sizeof( struct ifreq ) ); | 161 | memset( &ifr, 0, sizeof( struct ifreq ) ); |
167 | strcpy( (char*) &ifr.ifr_name, name ); | 162 | strcpy( (char*) &ifr.ifr_name, name ); |
168 | int result = ::ioctl( sfd, SIOCGIFFLAGS, &ifr ); | 163 | int result = ::ioctl( sfd, SIOCGIFFLAGS, &ifr ); |
169 | return result != -1; | 164 | return result != -1; |
170 | } | 165 | } |
171 | 166 | ||
172 | 167 | ||
173 | bool ONetwork::isWirelessInterface( const char* name ) const | 168 | bool ONetwork::isWirelessInterface( const char* name ) const |
174 | { | 169 | { |
175 | int sfd = socket( AF_INET, SOCK_STREAM, 0 ); | 170 | int sfd = socket( AF_INET, SOCK_STREAM, 0 ); |
176 | struct iwreq iwr; | 171 | struct iwreq iwr; |
177 | memset( &iwr, 0, sizeof( struct iwreq ) ); | 172 | memset( &iwr, 0, sizeof( struct iwreq ) ); |
178 | strcpy( (char*) &iwr.ifr_name, name ); | 173 | strcpy( (char*) &iwr.ifr_name, name ); |
179 | int result = ::ioctl( sfd, SIOCGIWNAME, &iwr ); | 174 | int result = ::ioctl( sfd, SIOCGIWNAME, &iwr ); |
180 | return result != -1; | 175 | return result != -1; |
181 | } | 176 | } |
182 | 177 | ||
183 | /*====================================================================================== | 178 | /*====================================================================================== |
184 | * ONetworkInterface | 179 | * ONetworkInterface |
185 | *======================================================================================*/ | 180 | *======================================================================================*/ |
186 | 181 | ||
187 | ONetworkInterface::ONetworkInterface( QObject* parent, const char* name ) | 182 | ONetworkInterface::ONetworkInterface( QObject* parent, const char* name ) |
188 | :QObject( parent, name ), | 183 | :QObject( parent, name ), |
189 | _sfd( socket( AF_INET, SOCK_DGRAM, 0 ) ), _mon( 0 ) | 184 | _sfd( socket( AF_INET, SOCK_DGRAM, 0 ) ), _mon( 0 ) |
190 | { | 185 | { |
191 | odebug << "ONetworkInterface::ONetworkInterface()" << oendl; | 186 | odebug << "ONetworkInterface::ONetworkInterface()" << oendl; |
192 | init(); | 187 | init(); |
193 | } | 188 | } |
194 | 189 | ||
195 | 190 | ||
196 | struct ifreq& ONetworkInterface::ifr() const | 191 | struct ifreq& ONetworkInterface::ifr() const |
197 | { | 192 | { |
198 | return _ifr; | 193 | return _ifr; |
199 | } | 194 | } |
200 | 195 | ||
201 | 196 | ||
202 | void ONetworkInterface::init() | 197 | void ONetworkInterface::init() |
203 | { | 198 | { |
204 | odebug << "ONetworkInterface::init()" << oendl; | 199 | odebug << "ONetworkInterface::init()" << oendl; |
205 | |||
206 | memset( &_ifr, 0, sizeof( struct ifreq ) ); | 200 | memset( &_ifr, 0, sizeof( struct ifreq ) ); |
207 | 201 | ||
208 | if ( _sfd == -1 ) | 202 | if ( _sfd == -1 ) |
209 | { | 203 | { |
210 | odebug << "ONetworkInterface::init(): Warning - can't get socket for device '" << name() << "'" << oendl; | 204 | odebug << "ONetworkInterface::init(): Warning - can't get socket for device '" << name() << "'" << oendl; |
211 | return; | 205 | return; |
212 | } | 206 | } |
213 | } | 207 | } |
214 | 208 | ||
215 | 209 | ||
216 | bool ONetworkInterface::ioctl( int call, struct ifreq& ifreq ) const | 210 | bool ONetworkInterface::ioctl( int call, struct ifreq& ifreq ) const |
217 | { | 211 | { |
218 | #ifndef NODEBUG | 212 | #ifndef NODEBUG |
219 | int result = ::ioctl( _sfd, call, &ifreq ); | 213 | int result = ::ioctl( _sfd, call, &ifreq ); |
220 | if ( result == -1 ) | 214 | if ( result == -1 ) |
221 | odebug << "ONetworkInterface::ioctl (" << name() << ") call '" << debugmapper->map( call ) | 215 | odebug << "ONetworkInterface::ioctl (" << name() << ") call '" << debugmapper->map( call ) |
222 | << "' FAILED! " << result << " (" << strerror( errno ) << ")" << oendl; | 216 | << "' FAILED! " << result << " (" << strerror( errno ) << ")" << oendl; |
223 | else | 217 | else |
224 | odebug << "ONetworkInterface::ioctl (" << name() << ") call '" << debugmapper->map( call ) | 218 | odebug << "ONetworkInterface::ioctl (" << name() << ") call '" << debugmapper->map( call ) |
225 | << "' - Status: Ok." << oendl; | 219 | << "' - Status: Ok." << oendl; |
226 | return ( result != -1 ); | 220 | return ( result != -1 ); |
227 | #else | 221 | #else |
228 | return ::ioctl( _sfd, call, &ifreq ) != -1; | 222 | return ::ioctl( _sfd, call, &ifreq ) != -1; |
229 | #endif | 223 | #endif |
230 | } | 224 | } |
231 | 225 | ||
232 | 226 | ||
233 | bool ONetworkInterface::ioctl( int call ) const | 227 | bool ONetworkInterface::ioctl( int call ) const |
234 | { | 228 | { |
235 | strcpy( _ifr.ifr_name, name() ); | 229 | strcpy( _ifr.ifr_name, name() ); |
236 | return ioctl( call, _ifr ); | 230 | return ioctl( call, _ifr ); |
237 | } | 231 | } |
238 | 232 | ||
239 | 233 | ||
240 | bool ONetworkInterface::isLoopback() const | 234 | bool ONetworkInterface::isLoopback() const |
241 | { | 235 | { |
242 | ioctl( SIOCGIFFLAGS ); | 236 | ioctl( SIOCGIFFLAGS ); |
243 | return _ifr.ifr_flags & IFF_LOOPBACK; | 237 | return _ifr.ifr_flags & IFF_LOOPBACK; |
244 | } | 238 | } |
245 | 239 | ||
246 | 240 | ||
247 | bool ONetworkInterface::setUp( bool b ) | 241 | bool ONetworkInterface::setUp( bool b ) |
248 | { | 242 | { |
249 | ioctl( SIOCGIFFLAGS ); | 243 | ioctl( SIOCGIFFLAGS ); |
250 | if ( b ) _ifr.ifr_flags |= IFF_UP; | 244 | if ( b ) _ifr.ifr_flags |= IFF_UP; |
251 | else _ifr.ifr_flags &= (~IFF_UP); | 245 | else _ifr.ifr_flags &= (~IFF_UP); |
252 | return ioctl( SIOCSIFFLAGS ); | 246 | return ioctl( SIOCSIFFLAGS ); |
253 | } | 247 | } |
254 | 248 | ||
255 | 249 | ||
256 | bool ONetworkInterface::isUp() const | 250 | bool ONetworkInterface::isUp() const |
257 | { | 251 | { |
258 | ioctl( SIOCGIFFLAGS ); | 252 | ioctl( SIOCGIFFLAGS ); |
259 | return _ifr.ifr_flags & IFF_UP; | 253 | return _ifr.ifr_flags & IFF_UP; |
260 | } | 254 | } |
261 | 255 | ||
262 | 256 | ||
263 | void ONetworkInterface::setIPV4Address( const QHostAddress& addr ) | 257 | void ONetworkInterface::setIPV4Address( const QHostAddress& addr ) |
264 | { | 258 | { |
265 | struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr; | 259 | struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr; |
266 | sa->sin_family = AF_INET; | 260 | sa->sin_family = AF_INET; |
267 | sa->sin_port = 0; | 261 | sa->sin_port = 0; |
268 | sa->sin_addr.s_addr = htonl( addr.ip4Addr() ); | 262 | sa->sin_addr.s_addr = htonl( addr.ip4Addr() ); |
269 | ioctl( SIOCSIFADDR ); | 263 | ioctl( SIOCSIFADDR ); |
270 | } | 264 | } |
271 | 265 | ||
272 | 266 | ||
273 | QString ONetworkInterface::ipV4Address() const | 267 | OHostAddress ONetworkInterface::ipV4Address() const |
274 | { | 268 | { |
275 | if ( ioctl( SIOCGIFADDR ) ) | 269 | struct sockaddr_in* sa = (struct sockaddr_in *) &_ifr.ifr_addr; |
276 | { | 270 | return ioctl( SIOCGIFADDR ) ? OHostAddress( ntohl( sa->sin_addr.s_addr ) ) : OHostAddress(); |
277 | struct sockaddr_in* sa = (struct sockaddr_in *) &_ifr.ifr_addr; | ||
278 | //FIXME: Use QHostAddress here | ||
279 | return QString( inet_ntoa( sa->sin_addr ) ); | ||
280 | } | ||
281 | else | ||
282 | return "<unknown>"; | ||
283 | |||
284 | } | 271 | } |
285 | 272 | ||
286 | 273 | ||
287 | void ONetworkInterface::setMacAddress( const OMacAddress& addr ) | 274 | void ONetworkInterface::setMacAddress( const OMacAddress& addr ) |
288 | { | 275 | { |
289 | _ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER; | 276 | _ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER; |
290 | memcpy( &_ifr.ifr_hwaddr.sa_data, addr.native(), 6 ); | 277 | memcpy( &_ifr.ifr_hwaddr.sa_data, addr.native(), 6 ); |
291 | ioctl( SIOCSIFHWADDR ); | 278 | ioctl( SIOCSIFHWADDR ); |
292 | } | 279 | } |
293 | 280 | ||
294 | 281 | ||
295 | OMacAddress ONetworkInterface::macAddress() const | 282 | OMacAddress ONetworkInterface::macAddress() const |
296 | { | 283 | { |
297 | if ( ioctl( SIOCGIFHWADDR ) ) | 284 | if ( ioctl( SIOCGIFHWADDR ) ) |
298 | { | 285 | { |
299 | return OMacAddress( _ifr ); | 286 | return OMacAddress( _ifr ); |
300 | } | 287 | } |
301 | else | 288 | else |
302 | { | 289 | { |
303 | return OMacAddress::unknown; | 290 | return OMacAddress::unknown; |
304 | } | 291 | } |
305 | } | 292 | } |
306 | 293 | ||
307 | 294 | ||
308 | void ONetworkInterface::setIPV4Netmask( const QHostAddress& addr ) | 295 | void ONetworkInterface::setIPV4Netmask( const QHostAddress& addr ) |
309 | { | 296 | { |
310 | struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr; | 297 | struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr; |
311 | sa->sin_family = AF_INET; | 298 | sa->sin_family = AF_INET; |
312 | sa->sin_port = 0; | 299 | sa->sin_port = 0; |
313 | sa->sin_addr.s_addr = htonl( addr.ip4Addr() ); | 300 | sa->sin_addr.s_addr = htonl( addr.ip4Addr() ); |
314 | ioctl( SIOCSIFNETMASK ); | 301 | ioctl( SIOCSIFNETMASK ); |
315 | } | 302 | } |
316 | 303 | ||
317 | 304 | ||
318 | QString ONetworkInterface::ipV4Netmask() const | 305 | OHostAddress ONetworkInterface::ipV4Netmask() const |
319 | { | 306 | { |
320 | if ( ioctl( SIOCGIFNETMASK ) ) | 307 | struct sockaddr_in* sa = (struct sockaddr_in *) &_ifr.ifr_addr; |
321 | { | 308 | return ioctl( SIOCGIFNETMASK ) ? OHostAddress( ntohl( sa->sin_addr.s_addr ) ) : OHostAddress(); |
322 | struct sockaddr_in* sa = (struct sockaddr_in *) &_ifr.ifr_addr; | ||
323 | //FIXME: Use QHostAddress here | ||
324 | return QString( inet_ntoa( sa->sin_addr ) ); | ||
325 | } | ||
326 | else | ||
327 | return "<unknown>"; | ||
328 | } | 309 | } |
329 | 310 | ||
330 | 311 | ||
331 | int ONetworkInterface::dataLinkType() const | 312 | int ONetworkInterface::dataLinkType() const |
332 | { | 313 | { |
333 | if ( ioctl( SIOCGIFHWADDR ) ) | 314 | if ( ioctl( SIOCGIFHWADDR ) ) |
334 | { | 315 | { |
335 | return _ifr.ifr_hwaddr.sa_family; | 316 | return _ifr.ifr_hwaddr.sa_family; |
336 | } | 317 | } |
337 | else | 318 | else |
338 | { | 319 | { |
339 | return -1; | 320 | return -1; |
340 | } | 321 | } |
341 | } | 322 | } |
342 | 323 | ||
343 | 324 | ||
344 | void ONetworkInterface::setMonitoring( OMonitoringInterface* m ) | 325 | void ONetworkInterface::setMonitoring( OMonitoringInterface* m ) |
345 | { | 326 | { |
346 | _mon = m; | 327 | _mon = m; |
347 | odebug << "ONetwork::setMonitoring(): Installed monitoring driver '" << m->name() << "' on interface '" << name() << "'" << oendl; | 328 | odebug << "ONetwork::setMonitoring(): Installed monitoring driver '" << m->name() << "' on interface '" << name() << "'" << oendl; |
348 | } | 329 | } |
349 | 330 | ||
350 | 331 | ||
351 | OMonitoringInterface* ONetworkInterface::monitoring() const | 332 | OMonitoringInterface* ONetworkInterface::monitoring() const |
352 | { | 333 | { |
353 | return _mon; | 334 | return _mon; |
354 | } | 335 | } |
355 | 336 | ||
356 | 337 | ||
357 | ONetworkInterface::~ONetworkInterface() | 338 | ONetworkInterface::~ONetworkInterface() |
358 | { | 339 | { |
359 | odebug << "ONetworkInterface::~ONetworkInterface()" << oendl; | 340 | odebug << "ONetworkInterface::~ONetworkInterface()" << oendl; |
360 | if ( _sfd != -1 ) ::close( _sfd ); | 341 | if ( _sfd != -1 ) ::close( _sfd ); |
361 | } | 342 | } |
362 | 343 | ||
363 | 344 | ||
364 | bool ONetworkInterface::setPromiscuousMode( bool b ) | 345 | bool ONetworkInterface::setPromiscuousMode( bool b ) |
365 | { | 346 | { |
366 | ioctl( SIOCGIFFLAGS ); | 347 | ioctl( SIOCGIFFLAGS ); |
367 | if ( b ) _ifr.ifr_flags |= IFF_PROMISC; | 348 | if ( b ) _ifr.ifr_flags |= IFF_PROMISC; |
368 | else _ifr.ifr_flags &= (~IFF_PROMISC); | 349 | else _ifr.ifr_flags &= (~IFF_PROMISC); |
369 | return ioctl( SIOCSIFFLAGS ); | 350 | return ioctl( SIOCSIFFLAGS ); |
370 | } | 351 | } |
371 | 352 | ||
372 | 353 | ||
373 | bool ONetworkInterface::promiscuousMode() const | 354 | bool ONetworkInterface::promiscuousMode() const |
374 | { | 355 | { |
375 | ioctl( SIOCGIFFLAGS ); | 356 | ioctl( SIOCGIFFLAGS ); |
376 | return _ifr.ifr_flags & IFF_PROMISC; | 357 | return _ifr.ifr_flags & IFF_PROMISC; |
377 | } | 358 | } |
378 | 359 | ||
379 | 360 | ||
380 | bool ONetworkInterface::isWireless() const | 361 | bool ONetworkInterface::isWireless() const |
381 | { | 362 | { |
382 | return ioctl( SIOCGIWNAME ); | 363 | return ioctl( SIOCGIWNAME ); |
383 | } | 364 | } |
384 | 365 | ||
385 | 366 | ||
386 | ONetworkInterfaceDriverInfo ONetworkInterface::driverInfo() const | 367 | ONetworkInterfaceDriverInfo ONetworkInterface::driverInfo() const |
387 | { | 368 | { |
388 | struct ethtool_drvinfo info; | 369 | struct ethtool_drvinfo info; |
389 | info.cmd = ETHTOOL_GDRVINFO; | 370 | info.cmd = ETHTOOL_GDRVINFO; |
390 | _ifr.ifr_data = (caddr_t) &info; | 371 | _ifr.ifr_data = (caddr_t) &info; |
391 | return ioctl( SIOCETHTOOL ) ? ONetworkInterfaceDriverInfo( info.driver, info.version, info.fw_version, info.bus_info) : ONetworkInterfaceDriverInfo(); | 372 | return ioctl( SIOCETHTOOL ) ? ONetworkInterfaceDriverInfo( info.driver, info.version, info.fw_version, info.bus_info) : ONetworkInterfaceDriverInfo(); |
392 | } | 373 | } |
393 | 374 | ||
394 | /*====================================================================================== | 375 | /*====================================================================================== |
395 | * OChannelHopper | 376 | * OChannelHopper |
396 | *======================================================================================*/ | 377 | *======================================================================================*/ |
397 | 378 | ||
398 | OChannelHopper::OChannelHopper( OWirelessNetworkInterface* iface ) | 379 | OChannelHopper::OChannelHopper( OWirelessNetworkInterface* iface ) |
399 | :QObject( 0, "Mickey's funky hopper" ), | 380 | :QObject( 0, "Mickey's funky hopper" ), |
400 | _iface( iface ), _interval( 0 ), _tid( 0 ) | 381 | _iface( iface ), _interval( 0 ), _tid( 0 ) |
401 | { | 382 | { |
402 | int _maxChannel = iface->channels(); | 383 | int _maxChannel = iface->channels(); |
403 | // generate fancy hopping sequence honoring the device capabilities | 384 | // generate fancy hopping sequence honoring the device capabilities |
404 | if ( _maxChannel >= 1 ) _channels.append( 1 ); | 385 | if ( _maxChannel >= 1 ) _channels.append( 1 ); |
405 | if ( _maxChannel >= 7 ) _channels.append( 7 ); | 386 | if ( _maxChannel >= 7 ) _channels.append( 7 ); |
406 | if ( _maxChannel >= 13 ) _channels.append( 13 ); | 387 | if ( _maxChannel >= 13 ) _channels.append( 13 ); |
407 | if ( _maxChannel >= 2 ) _channels.append( 2 ); | 388 | if ( _maxChannel >= 2 ) _channels.append( 2 ); |
408 | if ( _maxChannel >= 8 ) _channels.append( 8 ); | 389 | if ( _maxChannel >= 8 ) _channels.append( 8 ); |
409 | if ( _maxChannel >= 3 ) _channels.append( 3 ); | 390 | if ( _maxChannel >= 3 ) _channels.append( 3 ); |
410 | if ( _maxChannel >= 14 ) _channels.append( 14 ); | 391 | if ( _maxChannel >= 14 ) _channels.append( 14 ); |
411 | if ( _maxChannel >= 9 ) _channels.append( 9 ); | 392 | if ( _maxChannel >= 9 ) _channels.append( 9 ); |
412 | if ( _maxChannel >= 4 ) _channels.append( 4 ); | 393 | if ( _maxChannel >= 4 ) _channels.append( 4 ); |
413 | if ( _maxChannel >= 10 ) _channels.append( 10 ); | 394 | if ( _maxChannel >= 10 ) _channels.append( 10 ); |
414 | if ( _maxChannel >= 5 ) _channels.append( 5 ); | 395 | if ( _maxChannel >= 5 ) _channels.append( 5 ); |
415 | if ( _maxChannel >= 11 ) _channels.append( 11 ); | 396 | if ( _maxChannel >= 11 ) _channels.append( 11 ); |
416 | if ( _maxChannel >= 6 ) _channels.append( 6 ); | 397 | if ( _maxChannel >= 6 ) _channels.append( 6 ); |
417 | if ( _maxChannel >= 12 ) _channels.append( 12 ); | 398 | if ( _maxChannel >= 12 ) _channels.append( 12 ); |
418 | //FIXME: Add 802.11a/g channels | 399 | //FIXME: Add 802.11a/g channels |
419 | _channel = _channels.begin(); | 400 | _channel = _channels.begin(); |
420 | } | 401 | } |
421 | 402 | ||
422 | 403 | ||
423 | OChannelHopper::~OChannelHopper() | 404 | OChannelHopper::~OChannelHopper() |
424 | { | 405 | { |
425 | } | 406 | } |
426 | 407 | ||
427 | 408 | ||
428 | bool OChannelHopper::isActive() const | 409 | bool OChannelHopper::isActive() const |
429 | { | 410 | { |
430 | return _tid; | 411 | return _tid; |
431 | } | 412 | } |
432 | 413 | ||
433 | 414 | ||
434 | int OChannelHopper::channel() const | 415 | int OChannelHopper::channel() const |
435 | { | 416 | { |
436 | return *_channel; | 417 | return *_channel; |
437 | } | 418 | } |
438 | 419 | ||
439 | 420 | ||
440 | void OChannelHopper::timerEvent( QTimerEvent* ) | 421 | void OChannelHopper::timerEvent( QTimerEvent* ) |
441 | { | 422 | { |
442 | _iface->setChannel( *_channel ); | 423 | _iface->setChannel( *_channel ); |
443 | emit( hopped( *_channel ) ); | 424 | emit( hopped( *_channel ) ); |
444 | odebug << "OChannelHopper::timerEvent(): set channel " << *_channel << " on interface '" << _iface->name() << "'" << oendl; | 425 | odebug << "OChannelHopper::timerEvent(): set channel " << *_channel << " on interface '" << _iface->name() << "'" << oendl; |
445 | if ( ++_channel == _channels.end() ) _channel = _channels.begin(); | 426 | if ( ++_channel == _channels.end() ) _channel = _channels.begin(); |
446 | } | 427 | } |
447 | 428 | ||
448 | 429 | ||
449 | void OChannelHopper::setInterval( int interval ) | 430 | void OChannelHopper::setInterval( int interval ) |
450 | { | 431 | { |
451 | if ( interval == _interval ) | 432 | if ( interval == _interval ) |
452 | return; | 433 | return; |
453 | 434 | ||
454 | if ( _interval ) | 435 | if ( _interval ) |
455 | killTimer( _tid ); | 436 | killTimer( _tid ); |
456 | 437 | ||
457 | _tid = 0; | 438 | _tid = 0; |
458 | _interval = interval; | 439 | _interval = interval; |
459 | 440 | ||
460 | if ( _interval ) | 441 | if ( _interval ) |
461 | { | 442 | { |
462 | _tid = startTimer( interval ); | 443 | _tid = startTimer( interval ); |
463 | } | 444 | } |
464 | } | 445 | } |
465 | 446 | ||
466 | 447 | ||
467 | int OChannelHopper::interval() const | 448 | int OChannelHopper::interval() const |
468 | { | 449 | { |
469 | return _interval; | 450 | return _interval; |
470 | } | 451 | } |
471 | 452 | ||
472 | 453 | ||
473 | /*====================================================================================== | 454 | /*====================================================================================== |
474 | * OWirelessNetworkInterface | 455 | * OWirelessNetworkInterface |
475 | *======================================================================================*/ | 456 | *======================================================================================*/ |
476 | 457 | ||
477 | OWirelessNetworkInterface::OWirelessNetworkInterface( QObject* parent, const char* name ) | 458 | OWirelessNetworkInterface::OWirelessNetworkInterface( QObject* parent, const char* name ) |
478 | :ONetworkInterface( parent, name ), _hopper( 0 ) | 459 | :ONetworkInterface( parent, name ), _hopper( 0 ) |
479 | { | 460 | { |
480 | odebug << "OWirelessNetworkInterface::OWirelessNetworkInterface()" << oendl; | 461 | odebug << "OWirelessNetworkInterface::OWirelessNetworkInterface()" << oendl; |
481 | init(); | 462 | init(); |
482 | } | 463 | } |
483 | 464 | ||
484 | 465 | ||
485 | OWirelessNetworkInterface::~OWirelessNetworkInterface() | 466 | OWirelessNetworkInterface::~OWirelessNetworkInterface() |
486 | { | 467 | { |
487 | } | 468 | } |
488 | 469 | ||
489 | 470 | ||
490 | struct iwreq& OWirelessNetworkInterface::iwr() const | 471 | struct iwreq& OWirelessNetworkInterface::iwr() const |
491 | { | 472 | { |
492 | return _iwr; | 473 | return _iwr; |
493 | } | 474 | } |
494 | 475 | ||
495 | 476 | ||
496 | void OWirelessNetworkInterface::init() | 477 | void OWirelessNetworkInterface::init() |
497 | { | 478 | { |
498 | odebug << "OWirelessNetworkInterface::init()" << oendl; | 479 | odebug << "OWirelessNetworkInterface::init()" << oendl; |
499 | memset( &_iwr, 0, sizeof( struct iwreq ) ); | 480 | memset( &_iwr, 0, sizeof( struct iwreq ) ); |
500 | buildInformation(); | 481 | buildInformation(); |
501 | buildPrivateList(); | 482 | buildPrivateList(); |
502 | dumpInformation(); | 483 | dumpInformation(); |
503 | } | 484 | } |
504 | 485 | ||
505 | 486 | ||
506 | bool OWirelessNetworkInterface::isAssociated() const | 487 | bool OWirelessNetworkInterface::isAssociated() const |
507 | { | 488 | { |
508 | //FIXME: handle different modes | 489 | //FIXME: handle different modes |
509 | return !(associatedAP() == OMacAddress::unknown); | 490 | return !(associatedAP() == OMacAddress::unknown); |
510 | } | 491 | } |
511 | 492 | ||
512 | 493 | ||
513 | void OWirelessNetworkInterface::setAssociatedAP( const OMacAddress& mac ) const | 494 | void OWirelessNetworkInterface::setAssociatedAP( const OMacAddress& mac ) const |
514 | { | 495 | { |
515 | _iwr.u.ap_addr.sa_family = ARPHRD_ETHER; | 496 | _iwr.u.ap_addr.sa_family = ARPHRD_ETHER; |
516 | ::memcpy(_iwr.u.ap_addr.sa_data, mac.native(), ETH_ALEN); | 497 | ::memcpy(_iwr.u.ap_addr.sa_data, mac.native(), ETH_ALEN); |
517 | wioctl( SIOCSIWAP ); | 498 | wioctl( SIOCSIWAP ); |
518 | } | 499 | } |
519 | 500 | ||
520 | 501 | ||
521 | OMacAddress OWirelessNetworkInterface::associatedAP() const | 502 | OMacAddress OWirelessNetworkInterface::associatedAP() const |
522 | { | 503 | { |
523 | if ( ioctl( SIOCGIWAP ) ) | 504 | if ( ioctl( SIOCGIWAP ) ) |
524 | return (const unsigned char*) &_ifr.ifr_hwaddr.sa_data[0]; | 505 | return (const unsigned char*) &_ifr.ifr_hwaddr.sa_data[0]; |
525 | else | 506 | else |
526 | return OMacAddress::unknown; | 507 | return OMacAddress::unknown; |
527 | } | 508 | } |
528 | 509 | ||
529 | 510 | ||
530 | void OWirelessNetworkInterface::buildInformation() | 511 | void OWirelessNetworkInterface::buildInformation() |
531 | { | 512 | { |
532 | //ML: If you listen carefully enough, you can hear lots of WLAN drivers suck | 513 | //ML: If you listen carefully enough, you can hear lots of WLAN drivers suck |
533 | //ML: The HostAP drivers need more than sizeof struct_iw range to complete | 514 | //ML: The HostAP drivers need more than sizeof struct_iw range to complete |
534 | //ML: SIOCGIWRANGE otherwise they fail with "Invalid Argument Length". | 515 | //ML: SIOCGIWRANGE otherwise they fail with "Invalid Argument Length". |
535 | //ML: The Wlan-NG drivers on the otherside fail (segfault!) if you allocate | 516 | //ML: The Wlan-NG drivers on the otherside fail (segfault!) if you allocate |
536 | //ML: _too much_ space. This is damn shitty crap *sigh* | 517 | //ML: _too much_ space. This is damn shitty crap *sigh* |
537 | //ML: We allocate a large memory region in RAM and check whether the | 518 | //ML: We allocate a large memory region in RAM and check whether the |
538 | //ML: driver pollutes this extra space. The complaint will be made on stdout, | 519 | //ML: driver pollutes this extra space. The complaint will be made on stdout, |
539 | //ML: so please forward this... | 520 | //ML: so please forward this... |
540 | 521 | ||
541 | struct iwreq wrq; | 522 | struct iwreq wrq; |
542 | int len = sizeof( struct iw_range )*2; | 523 | int len = sizeof( struct iw_range )*2; |
543 | char buffer[len]; | 524 | char buffer[len]; |
544 | memset( buffer, 0, len ); | 525 | memset( buffer, 0, len ); |
545 | memcpy( wrq.ifr_name, name(), IFNAMSIZ); | 526 | memcpy( wrq.ifr_name, name(), IFNAMSIZ); |
546 | wrq.u.data.pointer = (caddr_t) buffer; | 527 | wrq.u.data.pointer = (caddr_t) buffer; |
547 | wrq.u.data.length = sizeof buffer; | 528 | wrq.u.data.length = sizeof buffer; |
548 | wrq.u.data.flags = 0; | 529 | wrq.u.data.flags = 0; |
549 | 530 | ||
550 | if ( ::ioctl( _sfd, SIOCGIWRANGE, &wrq ) == -1 ) | 531 | int result = ::ioctl( _sfd, SIOCGIWRANGE, &wrq ); |
532 | if ( result == -1 ) | ||
533 | { | ||
534 | owarn << "OWirelessNetworkInterface::buildInformation(): SIOCGIWRANGE failed (" << strerror( errno ) << ") - retrying with smaller buffer..." << oendl; | ||
535 | wrq.u.data.length = sizeof( struct iw_range ); | ||
536 | result = ::ioctl( _sfd, SIOCGIWRANGE, &wrq ); | ||
537 | } | ||
538 | |||
539 | if ( result == -1 ) | ||
551 | { | 540 | { |
552 | owarn << "OWirelessNetworkInterface::buildInformation(): Can't get driver information (" << strerror( errno ) << ") - using default values." << oendl; | 541 | owarn << "OWirelessNetworkInterface::buildInformation(): Can't get driver information (" << strerror( errno ) << ") - using default values." << oendl; |
553 | _channels.insert( 2412, 1 ); // 2.412 GHz | 542 | _channels.insert( 2412, 1 ); // 2.412 GHz |
554 | _channels.insert( 2417, 2 ); // 2.417 GHz | 543 | _channels.insert( 2417, 2 ); // 2.417 GHz |
555 | _channels.insert( 2422, 3 ); // 2.422 GHz | 544 | _channels.insert( 2422, 3 ); // 2.422 GHz |
556 | _channels.insert( 2427, 4 ); // 2.427 GHz | 545 | _channels.insert( 2427, 4 ); // 2.427 GHz |
557 | _channels.insert( 2432, 5 ); // 2.432 GHz | 546 | _channels.insert( 2432, 5 ); // 2.432 GHz |
558 | _channels.insert( 2437, 6 ); // 2.437 GHz | 547 | _channels.insert( 2437, 6 ); // 2.437 GHz |
559 | _channels.insert( 2442, 7 ); // 2.442 GHz | 548 | _channels.insert( 2442, 7 ); // 2.442 GHz |
560 | _channels.insert( 2447, 8 ); // 2.447 GHz | 549 | _channels.insert( 2447, 8 ); // 2.447 GHz |
561 | _channels.insert( 2452, 9 ); // 2.452 GHz | 550 | _channels.insert( 2452, 9 ); // 2.452 GHz |
562 | _channels.insert( 2457, 10 ); // 2.457 GHz | 551 | _channels.insert( 2457, 10 ); // 2.457 GHz |
563 | _channels.insert( 2462, 11 ); // 2.462 GHz | 552 | _channels.insert( 2462, 11 ); // 2.462 GHz |
564 | 553 | ||
565 | memset( &_range, 0, sizeof( struct iw_range ) ); | 554 | memset( &_range, 0, sizeof( struct iw_range ) ); |
566 | } | 555 | } |
567 | else | 556 | else |
568 | { | 557 | { |
569 | // <check if the driver overwrites stuff> | 558 | // <check if the driver overwrites stuff> |
570 | int max = 0; | 559 | int max = 0; |
571 | for ( int r = sizeof( struct iw_range ); r < len; r++ ) | 560 | for ( int r = sizeof( struct iw_range ); r < len; r++ ) |
572 | if (buffer[r] != 0) | 561 | if (buffer[r] != 0) |
573 | max = r; | 562 | max = r; |
574 | if (max > 0) | 563 | if (max > 0) |
575 | { | 564 | { |
576 | owarn << "OWirelessNetworkInterface::buildInformation(): Driver for wireless interface '" << name() | 565 | owarn << "OWirelessNetworkInterface::buildInformation(): Driver for wireless interface '" << name() |
577 | << "' sucks! It overwrote the buffer end with at least " << max - sizeof( struct iw_range ) << " bytes!" << oendl; | 566 | << "' sucks! It overwrote the buffer end with at least " << max - sizeof( struct iw_range ) << " bytes!" << oendl; |
578 | } | 567 | } |
579 | // </check if the driver overwrites stuff> | 568 | // </check if the driver overwrites stuff> |
580 | 569 | ||
581 | struct iw_range range; | 570 | struct iw_range range; |
582 | memcpy( &range, buffer, sizeof range ); | 571 | memcpy( &range, buffer, sizeof range ); |
583 | 572 | ||
584 | odebug << "OWirelessNetworkInterface::buildInformation(): Interface reported to have " << (int) range.num_frequency << " channels." << oendl; | 573 | odebug << "OWirelessNetworkInterface::buildInformation(): Interface reported to have " << (int) range.num_frequency << " channels." << oendl; |
585 | for ( int i = 0; i < range.num_frequency; ++i ) | 574 | for ( int i = 0; i < range.num_frequency; ++i ) |
586 | { | 575 | { |
587 | int freq = (int) ( double( range.freq[i].m ) * pow( 10.0, range.freq[i].e ) / 1000000.0 ); | 576 | int freq = (int) ( double( range.freq[i].m ) * pow( 10.0, range.freq[i].e ) / 1000000.0 ); |
588 | odebug << "OWirelessNetworkInterface::buildInformation: Adding frequency " << freq << " as channel " << i+1 << oendl; | 577 | odebug << "OWirelessNetworkInterface::buildInformation: Adding frequency " << freq << " as channel " << i+1 << oendl; |
589 | _channels.insert( freq, i+1 ); | 578 | _channels.insert( freq, i+1 ); |
590 | } | 579 | } |
591 | } | 580 | } |
592 | 581 | ||
593 | memcpy( &_range, buffer, sizeof( struct iw_range ) ); | 582 | memcpy( &_range, buffer, sizeof( struct iw_range ) ); |
594 | odebug << "OWirelessNetworkInterface::buildInformation(): Information block constructed." << oendl; | 583 | odebug << "OWirelessNetworkInterface::buildInformation(): Information block constructed." << oendl; |
595 | } | 584 | } |
596 | 585 | ||
597 | 586 | ||
598 | short OWirelessNetworkInterface::wirelessExtensionDriverVersion() const | 587 | short OWirelessNetworkInterface::wirelessExtensionDriverVersion() const |
599 | { | 588 | { |
600 | return _range.we_version_compiled; | 589 | return _range.we_version_compiled; |
601 | } | 590 | } |
602 | 591 | ||
603 | 592 | ||
604 | void OWirelessNetworkInterface::buildPrivateList() | 593 | void OWirelessNetworkInterface::buildPrivateList() |
605 | { | 594 | { |
606 | odebug << "OWirelessNetworkInterface::buildPrivateList()" << oendl; | 595 | odebug << "OWirelessNetworkInterface::buildPrivateList()" << oendl; |
607 | 596 | ||
608 | struct iw_priv_args priv[IW_MAX_PRIV_DEF]; | 597 | struct iw_priv_args priv[IW_MAX_PRIV_DEF]; |
609 | 598 | ||
610 | _iwr.u.data.pointer = (char*) &priv; | 599 | _iwr.u.data.pointer = (char*) &priv; |
611 | _iwr.u.data.length = IW_MAX_PRIV_DEF; // length in terms of number of (sizeof iw_priv_args), not (sizeof iw_priv_args) itself | 600 | _iwr.u.data.length = IW_MAX_PRIV_DEF; // length in terms of number of (sizeof iw_priv_args), not (sizeof iw_priv_args) itself |
612 | _iwr.u.data.flags = 0; | 601 | _iwr.u.data.flags = 0; |
613 | 602 | ||
614 | if ( !wioctl( SIOCGIWPRIV ) ) | 603 | if ( !wioctl( SIOCGIWPRIV ) ) |
615 | { | 604 | { |
616 | owarn << "OWirelessNetworkInterface::buildPrivateList(): Can't get private ioctl information (" << strerror( errno ) << ")." << oendl; | 605 | owarn << "OWirelessNetworkInterface::buildPrivateList(): Can't get private ioctl information (" << strerror( errno ) << ")." << oendl; |
617 | return; | 606 | return; |
618 | } | 607 | } |
619 | 608 | ||
620 | for ( int i = 0; i < _iwr.u.data.length; ++i ) | 609 | for ( int i = 0; i < _iwr.u.data.length; ++i ) |
621 | { | 610 | { |
622 | new OPrivateIOCTL( this, priv[i].name, priv[i].cmd, priv[i].get_args, priv[i].set_args ); | 611 | new OPrivateIOCTL( this, priv[i].name, priv[i].cmd, priv[i].get_args, priv[i].set_args ); |
623 | } | 612 | } |
624 | odebug << "OWirelessNetworkInterface::buildPrivateList(): Private ioctl list constructed." << oendl; | 613 | odebug << "OWirelessNetworkInterface::buildPrivateList(): Private ioctl list constructed." << oendl; |
625 | } | 614 | } |
626 | 615 | ||
627 | 616 | ||
628 | void OWirelessNetworkInterface::dumpInformation() const | 617 | void OWirelessNetworkInterface::dumpInformation() const |
629 | { | 618 | { |
630 | odebug << "OWirelessNetworkInterface::() -------------- dumping information block ----------------" << oendl; | 619 | odebug << "OWirelessNetworkInterface::() -------------- dumping information block ----------------" << oendl; |
631 | 620 | ||
632 | odebug << " - driver's idea of maximum throughput is " << _range.throughput | 621 | odebug << " - driver's idea of maximum throughput is " << _range.throughput |
633 | << " bps = " << ( _range.throughput / 8 ) << " byte/s = " << ( _range.throughput / 8 / 1024 ) | 622 | << " bps = " << ( _range.throughput / 8 ) << " byte/s = " << ( _range.throughput / 8 / 1024 ) |
634 | << " Kb/s = " << QString().sprintf("%f.2", float( _range.throughput ) / 8.0 / 1024.0 / 1024.0 ) | 623 | << " Kb/s = " << QString().sprintf("%f.2", float( _range.throughput ) / 8.0 / 1024.0 / 1024.0 ) |
635 | << " Mb/s" << oendl; | 624 | << " Mb/s" << oendl; |
636 | 625 | ||
637 | odebug << " - driver for '" << name() << "' (V" << _range.we_version_source | 626 | odebug << " - driver for '" << name() << "' (V" << _range.we_version_source |
638 | << ") has been compiled against WE V" << _range.we_version_compiled << oendl; | 627 | << ") has been compiled against WE V" << _range.we_version_compiled << oendl; |
639 | 628 | ||
640 | if ( _range.we_version_compiled != WIRELESS_EXT ) | 629 | if ( _range.we_version_compiled != WIRELESS_EXT ) |
641 | { | 630 | { |
642 | owarn << "Version mismatch! WE_DRIVER = " << _range.we_version_compiled << " and WE_OPIENET = " << WIRELESS_EXT << oendl; | 631 | owarn << "Version mismatch! WE_DRIVER = " << _range.we_version_compiled << " and WE_OPIENET = " << WIRELESS_EXT << oendl; |
643 | } | 632 | } |
644 | 633 | ||
645 | odebug << "OWirelessNetworkInterface::() ---------------------------------------------------------" << oendl; | 634 | odebug << "OWirelessNetworkInterface::() ---------------------------------------------------------" << oendl; |
646 | } | 635 | } |
647 | 636 | ||
648 | 637 | ||
649 | int OWirelessNetworkInterface::channel() const | 638 | int OWirelessNetworkInterface::channel() const |
650 | { | 639 | { |
651 | //FIXME: When monitoring enabled, then use it | 640 | //FIXME: When monitoring enabled, then use it |
652 | //FIXME: to gather the current RF channel | 641 | //FIXME: to gather the current RF channel |
653 | //FIXME: Until then, get active channel from hopper. | 642 | //FIXME: Until then, get active channel from hopper. |
654 | if ( _hopper && _hopper->isActive() ) | 643 | if ( _hopper && _hopper->isActive() ) |
655 | return _hopper->channel(); | 644 | return _hopper->channel(); |
656 | 645 | ||
657 | if ( !wioctl( SIOCGIWFREQ ) ) | 646 | if ( !wioctl( SIOCGIWFREQ ) ) |
658 | { | 647 | { |
659 | return -1; | 648 | return -1; |
660 | } | 649 | } |
661 | else | 650 | else |
662 | { | 651 | { |
663 | return _channels[ static_cast<int>(double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000) ]; | 652 | return _channels[ static_cast<int>(double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000) ]; |
664 | } | 653 | } |
665 | } | 654 | } |
666 | 655 | ||
667 | 656 | ||
668 | void OWirelessNetworkInterface::setChannel( int c ) const | 657 | void OWirelessNetworkInterface::setChannel( int c ) const |
669 | { | 658 | { |
670 | if ( !c ) | 659 | if ( !c ) |
671 | { | 660 | { |
672 | oerr << "OWirelessNetworkInterface::setChannel( 0 ) called - fix your application!" << oendl; | 661 | oerr << "OWirelessNetworkInterface::setChannel( 0 ) called - fix your application!" << oendl; |
673 | return; | 662 | return; |
674 | } | 663 | } |
675 | 664 | ||
676 | if ( !_mon ) | 665 | if ( !_mon ) |
677 | { | 666 | { |
678 | memset( &_iwr, 0, sizeof( struct iwreq ) ); | 667 | memset( &_iwr, 0, sizeof( struct iwreq ) ); |
679 | _iwr.u.freq.m = c; | 668 | _iwr.u.freq.m = c; |
680 | _iwr.u.freq.e = 0; | 669 | _iwr.u.freq.e = 0; |
681 | wioctl( SIOCSIWFREQ ); | 670 | wioctl( SIOCSIWFREQ ); |
682 | } | 671 | } |
683 | else | 672 | else |
684 | { | 673 | { |
685 | _mon->setChannel( c ); | 674 | _mon->setChannel( c ); |
686 | } | 675 | } |
687 | } | 676 | } |
688 | 677 | ||
689 | 678 | ||
690 | double OWirelessNetworkInterface::frequency() const | 679 | double OWirelessNetworkInterface::frequency() const |
691 | { | 680 | { |
692 | if ( !wioctl( SIOCGIWFREQ ) ) | 681 | if ( !wioctl( SIOCGIWFREQ ) ) |
693 | { | 682 | { |
694 | return -1.0; | 683 | return -1.0; |
695 | } | 684 | } |
696 | else | 685 | else |
697 | { | 686 | { |
698 | return double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000000.0; | 687 | return double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000000.0; |
699 | } | 688 | } |
700 | } | 689 | } |
701 | 690 | ||
702 | 691 | ||
703 | int OWirelessNetworkInterface::channels() const | 692 | int OWirelessNetworkInterface::channels() const |
704 | { | 693 | { |
705 | return _channels.count(); | 694 | return _channels.count(); |
706 | } | 695 | } |
707 | 696 | ||
708 | 697 | ||
709 | void OWirelessNetworkInterface::setChannelHopping( int interval ) | 698 | void OWirelessNetworkInterface::setChannelHopping( int interval ) |
710 | { | 699 | { |
711 | if ( !_hopper ) _hopper = new OChannelHopper( this ); | 700 | if ( !_hopper ) _hopper = new OChannelHopper( this ); |
712 | _hopper->setInterval( interval ); | 701 | _hopper->setInterval( interval ); |
713 | //FIXME: When and by whom will the channel hopper be deleted? | 702 | //FIXME: When and by whom will the channel hopper be deleted? |
714 | //TODO: rely on QObject hierarchy | 703 | //TODO: rely on QObject hierarchy |
715 | } | 704 | } |
716 | 705 | ||
717 | 706 | ||
718 | int OWirelessNetworkInterface::channelHopping() const | 707 | int OWirelessNetworkInterface::channelHopping() const |
719 | { | 708 | { |
720 | return _hopper->interval(); | 709 | return _hopper->interval(); |
721 | } | 710 | } |
722 | 711 | ||
723 | 712 | ||
724 | OChannelHopper* OWirelessNetworkInterface::channelHopper() const | 713 | OChannelHopper* OWirelessNetworkInterface::channelHopper() const |
725 | { | 714 | { |
726 | return _hopper; | 715 | return _hopper; |
727 | } | 716 | } |
728 | 717 | ||
729 | 718 | ||
730 | void OWirelessNetworkInterface::commit() const | 719 | void OWirelessNetworkInterface::commit() const |
731 | { | 720 | { |
732 | wioctl( SIOCSIWCOMMIT ); | 721 | wioctl( SIOCSIWCOMMIT ); |
733 | } | 722 | } |
734 | 723 | ||
735 | 724 | ||
736 | void OWirelessNetworkInterface::setMode( const QString& newMode ) | 725 | void OWirelessNetworkInterface::setMode( const QString& newMode ) |
737 | { | 726 | { |
738 | #ifdef FINALIZE | 727 | #ifdef FINALIZE |
739 | QString currentMode = mode(); | 728 | QString currentMode = mode(); |
740 | if ( currentMode == newMode ) return; | 729 | if ( currentMode == newMode ) return; |
741 | #endif | 730 | #endif |
742 | 731 | ||
743 | odebug << "OWirelessNetworkInterface::setMode(): trying to set mode " << newMode << oendl; | 732 | odebug << "OWirelessNetworkInterface::setMode(): trying to set mode " << newMode << oendl; |
744 | 733 | ||
745 | _iwr.u.mode = stringToMode( newMode ); | 734 | _iwr.u.mode = stringToMode( newMode ); |
746 | 735 | ||
747 | if ( _iwr.u.mode != IW_MODE_MONITOR ) | 736 | if ( _iwr.u.mode != IW_MODE_MONITOR ) |
748 | { | 737 | { |
749 | // IWR.U.MODE WIRD DURCH ABFRAGE DES MODE HIER PLATTGEMACHT!!!!!!!!!!!!!!!!!!!!! DEPP! | 738 | // IWR.U.MODE WIRD DURCH ABFRAGE DES MODE HIER PLATTGEMACHT!!!!!!!!!!!!!!!!!!!!! DEPP! |
750 | _iwr.u.mode = stringToMode( newMode ); | 739 | _iwr.u.mode = stringToMode( newMode ); |
751 | wioctl( SIOCSIWMODE ); | 740 | wioctl( SIOCSIWMODE ); |
752 | 741 | ||
753 | // special iwpriv fallback for monitor mode (check if we're really out of monitor mode now) | 742 | // special iwpriv fallback for monitor mode (check if we're really out of monitor mode now) |
754 | 743 | ||
755 | if ( mode() == "monitor" ) | 744 | if ( mode() == "monitor" ) |
756 | { | 745 | { |
757 | odebug << "OWirelessNetworkInterface::setMode(): SIOCSIWMODE not sufficient - trying fallback to iwpriv..." << oendl; | 746 | odebug << "OWirelessNetworkInterface::setMode(): SIOCSIWMODE not sufficient - trying fallback to iwpriv..." << oendl; |
758 | if ( _mon ) | 747 | if ( _mon ) |
759 | _mon->setEnabled( false ); | 748 | _mon->setEnabled( false ); |
760 | else | 749 | else |
761 | odebug << "ONetwork(): can't switch monitor mode without installed monitoring interface" << oendl; | 750 | odebug << "ONetwork(): can't switch monitor mode without installed monitoring interface" << oendl; |
762 | } | 751 | } |
763 | 752 | ||
764 | } | 753 | } |
765 | else // special iwpriv fallback for monitor mode | 754 | else // special iwpriv fallback for monitor mode |
766 | { | 755 | { |
767 | if ( wioctl( SIOCSIWMODE ) ) | 756 | if ( wioctl( SIOCSIWMODE ) ) |
768 | { | 757 | { |
769 | odebug << "OWirelessNetworkInterface::setMode(): IW_MODE_MONITOR ok" << oendl; | 758 | odebug << "OWirelessNetworkInterface::setMode(): IW_MODE_MONITOR ok" << oendl; |
770 | } | 759 | } |
771 | else | 760 | else |
772 | { | 761 | { |
773 | odebug << "OWirelessNetworkInterface::setMode(): SIOCSIWMODE not working - trying fallback to iwpriv..." << oendl; | 762 | odebug << "OWirelessNetworkInterface::setMode(): SIOCSIWMODE not working - trying fallback to iwpriv..." << oendl; |
774 | 763 | ||
775 | if ( _mon ) | 764 | if ( _mon ) |
776 | _mon->setEnabled( true ); | 765 | _mon->setEnabled( true ); |
777 | else | 766 | else |
778 | odebug << "ONetwork(): can't switch monitor mode without installed monitoring interface" << oendl; | 767 | odebug << "ONetwork(): can't switch monitor mode without installed monitoring interface" << oendl; |
779 | } | 768 | } |
780 | } | 769 | } |
781 | } | 770 | } |
782 | 771 | ||
783 | 772 | ||
784 | QString OWirelessNetworkInterface::mode() const | 773 | QString OWirelessNetworkInterface::mode() const |
785 | { | 774 | { |
786 | memset( &_iwr, 0, sizeof( struct iwreq ) ); | 775 | memset( &_iwr, 0, sizeof( struct iwreq ) ); |
787 | 776 | ||
788 | if ( !wioctl( SIOCGIWMODE ) ) | 777 | if ( !wioctl( SIOCGIWMODE ) ) |
789 | { | 778 | { |
790 | return "<unknown>"; | 779 | return "<unknown>"; |
791 | } | 780 | } |
792 | 781 | ||
793 | odebug << "OWirelessNetworkInterface::setMode(): WE's idea of current mode seems to be " << modeToString( _iwr.u.mode ) << oendl; | 782 | odebug << "OWirelessNetworkInterface::setMode(): WE's idea of current mode seems to be " << modeToString( _iwr.u.mode ) << oendl; |
794 | 783 | ||
795 | // legacy compatible monitor mode check | 784 | // legacy compatible monitor mode check |
796 | 785 | ||
797 | if ( dataLinkType() == ARPHRD_IEEE80211 || dataLinkType() == 802 ) | 786 | if ( dataLinkType() == ARPHRD_IEEE80211 || dataLinkType() == 802 ) |
798 | { | 787 | { |
799 | return "monitor"; | 788 | return "monitor"; |
800 | } | 789 | } |
801 | else | 790 | else |
802 | { | 791 | { |
803 | return modeToString( _iwr.u.mode ); | 792 | return modeToString( _iwr.u.mode ); |
804 | } | 793 | } |
805 | } | 794 | } |
806 | 795 | ||
807 | void OWirelessNetworkInterface::setNickName( const QString& nickname ) | 796 | void OWirelessNetworkInterface::setNickName( const QString& nickname ) |
808 | { | 797 | { |
809 | _iwr.u.essid.pointer = const_cast<char*>( (const char*) nickname ); | 798 | _iwr.u.essid.pointer = const_cast<char*>( (const char*) nickname ); |
810 | _iwr.u.essid.length = nickname.length(); | 799 | _iwr.u.essid.length = nickname.length(); |
811 | wioctl( SIOCSIWNICKN ); | 800 | wioctl( SIOCSIWNICKN ); |
812 | } | 801 | } |
813 | 802 | ||
814 | 803 | ||
815 | QString OWirelessNetworkInterface::nickName() const | 804 | QString OWirelessNetworkInterface::nickName() const |
816 | { | 805 | { |
817 | char str[IW_ESSID_MAX_SIZE]; | 806 | char str[IW_ESSID_MAX_SIZE]; |
818 | _iwr.u.data.pointer = &str[0]; | 807 | _iwr.u.data.pointer = &str[0]; |
819 | _iwr.u.data.length = IW_ESSID_MAX_SIZE; | 808 | _iwr.u.data.length = IW_ESSID_MAX_SIZE; |
820 | if ( !wioctl( SIOCGIWNICKN ) ) | 809 | if ( !wioctl( SIOCGIWNICKN ) ) |
821 | { | 810 | { |
822 | return "<unknown>"; | 811 | return "<unknown>"; |
823 | } | 812 | } |
824 | else | 813 | else |
825 | { | 814 | { |
826 | str[_iwr.u.data.length] = '\0'; // some drivers don't zero-terminate the string | 815 | str[_iwr.u.data.length] = '\0'; // some drivers don't zero-terminate the string |
827 | return str; | 816 | return str; |
828 | } | 817 | } |
829 | } | 818 | } |
830 | 819 | ||
831 | 820 | ||
832 | void OWirelessNetworkInterface::setPrivate( const QString& call, int numargs, ... ) | 821 | void OWirelessNetworkInterface::setPrivate( const QString& call, int numargs, ... ) |
833 | { | 822 | { |
834 | OPrivateIOCTL* priv = static_cast<OPrivateIOCTL*>( child( (const char*) call ) ); | 823 | OPrivateIOCTL* priv = static_cast<OPrivateIOCTL*>( child( (const char*) call ) ); |
835 | if ( !priv ) | 824 | if ( !priv ) |
836 | { | 825 | { |
837 | owarn << "OWirelessNetworkInterface::setPrivate(): interface '" << name() | 826 | owarn << "OWirelessNetworkInterface::setPrivate(): interface '" << name() |
838 | << "' does not support private ioctl '" << call << "'" << oendl; | 827 | << "' does not support private ioctl '" << call << "'" << oendl; |
839 | return; | 828 | return; |
840 | } | 829 | } |
841 | if ( priv->numberSetArgs() != numargs ) | 830 | if ( priv->numberSetArgs() != numargs ) |
842 | { | 831 | { |
843 | owarn << "OWirelessNetworkInterface::setPrivate(): parameter count not matching. '" | 832 | owarn << "OWirelessNetworkInterface::setPrivate(): parameter count not matching. '" |
844 | << call << "' expects " << priv->numberSetArgs() << ", but got " << numargs << oendl; | 833 | << call << "' expects " << priv->numberSetArgs() << ", but got " << numargs << oendl; |
845 | return; | 834 | return; |
846 | } | 835 | } |
847 | 836 | ||
848 | odebug << "OWirelessNetworkInterface::setPrivate(): about to call '" << call << "' on interface '" << name() << "'" << oendl; | 837 | odebug << "OWirelessNetworkInterface::setPrivate(): about to call '" << call << "' on interface '" << name() << "'" << oendl; |
849 | memset( &_iwr, 0, sizeof _iwr ); | 838 | memset( &_iwr, 0, sizeof _iwr ); |
850 | va_list argp; | 839 | va_list argp; |
851 | va_start( argp, numargs ); | 840 | va_start( argp, numargs ); |
852 | for ( int i = 0; i < numargs; ++i ) | 841 | for ( int i = 0; i < numargs; ++i ) |
853 | { | 842 | { |
854 | priv->setParameter( i, va_arg( argp, int ) ); | 843 | priv->setParameter( i, va_arg( argp, int ) ); |
855 | } | 844 | } |
856 | va_end( argp ); | 845 | va_end( argp ); |
857 | priv->invoke(); | 846 | priv->invoke(); |
858 | } | 847 | } |
859 | 848 | ||
860 | 849 | ||
861 | void OWirelessNetworkInterface::getPrivate( const QString& ) | 850 | void OWirelessNetworkInterface::getPrivate( const QString& ) |
862 | { | 851 | { |
863 | oerr << "OWirelessNetworkInterface::getPrivate() is not implemented yet." << oendl; | 852 | oerr << "OWirelessNetworkInterface::getPrivate() is not implemented yet." << oendl; |
864 | } | 853 | } |
865 | 854 | ||
866 | 855 | ||
867 | bool OWirelessNetworkInterface::hasPrivate( const QString& call ) | 856 | bool OWirelessNetworkInterface::hasPrivate( const QString& call ) |
868 | { | 857 | { |
869 | return child( call.local8Bit() ); | 858 | return child( call.local8Bit() ); |
870 | } | 859 | } |
871 | 860 | ||
872 | 861 | ||
873 | QString OWirelessNetworkInterface::SSID() const | 862 | QString OWirelessNetworkInterface::SSID() const |
874 | { | 863 | { |
875 | char str[IW_ESSID_MAX_SIZE]; | 864 | char str[IW_ESSID_MAX_SIZE]; |
876 | _iwr.u.essid.pointer = &str[0]; | 865 | _iwr.u.essid.pointer = &str[0]; |
877 | _iwr.u.essid.length = IW_ESSID_MAX_SIZE; | 866 | _iwr.u.essid.length = IW_ESSID_MAX_SIZE; |
878 | if ( !wioctl( SIOCGIWESSID ) ) | 867 | if ( !wioctl( SIOCGIWESSID ) ) |
879 | { | 868 | { |
880 | return "<unknown>"; | 869 | return "<unknown>"; |
881 | } | 870 | } |
882 | else | 871 | else |
883 | { | 872 | { |
884 | str[_iwr.u.essid.length] = '\0'; // some drivers don't zero-terminate the string | 873 | str[_iwr.u.essid.length] = '\0'; // some drivers don't zero-terminate the string |
885 | return str; | 874 | return str; |
886 | } | 875 | } |
887 | } | 876 | } |
888 | 877 | ||
889 | 878 | ||
890 | void OWirelessNetworkInterface::setSSID( const QString& ssid ) | 879 | void OWirelessNetworkInterface::setSSID( const QString& ssid ) |
891 | { | 880 | { |
892 | _iwr.u.essid.pointer = const_cast<char*>( (const char*) ssid ); | 881 | _iwr.u.essid.pointer = const_cast<char*>( (const char*) ssid ); |
893 | _iwr.u.essid.length = ssid.length()+1; // zero byte | 882 | _iwr.u.essid.length = ssid.length()+1; // zero byte |
894 | wioctl( SIOCSIWESSID ); | 883 | wioctl( SIOCSIWESSID ); |
895 | } | 884 | } |
896 | 885 | ||
897 | 886 | ||
898 | OStationList* OWirelessNetworkInterface::scanNetwork() | 887 | OStationList* OWirelessNetworkInterface::scanNetwork() |
899 | { | 888 | { |
900 | _iwr.u.param.flags = IW_SCAN_DEFAULT; | 889 | _iwr.u.param.flags = IW_SCAN_DEFAULT; |
901 | _iwr.u.param.value = 0; | 890 | _iwr.u.param.value = 0; |
902 | if ( !wioctl( SIOCSIWSCAN ) ) | 891 | if ( !wioctl( SIOCSIWSCAN ) ) |
903 | { | 892 | { |
904 | return 0; | 893 | return 0; |
905 | } | 894 | } |
906 | 895 | ||
907 | OStationList* stations = new OStationList(); | 896 | OStationList* stations = new OStationList(); |
908 | 897 | ||
909 | int timeout = 10000000; | 898 | int timeout = 10000000; |
910 | 899 | ||
911 | odebug << "ONetworkInterface::scanNetwork() - scan started." << oendl; | 900 | odebug << "ONetworkInterface::scanNetwork() - scan started." << oendl; |
912 | 901 | ||
913 | bool results = false; | 902 | bool results = false; |
914 | struct timeval tv; | 903 | struct timeval tv; |
915 | tv.tv_sec = 0; | 904 | tv.tv_sec = 0; |
916 | tv.tv_usec = 250000; // initial timeout ~ 250ms | 905 | tv.tv_usec = 250000; // initial timeout ~ 250ms |
917 | char buffer[IW_SCAN_MAX_DATA]; | 906 | char buffer[IW_SCAN_MAX_DATA]; |
918 | 907 | ||
919 | while ( !results && timeout > 0 ) | 908 | while ( !results && timeout > 0 ) |
920 | { | 909 | { |
921 | timeout -= tv.tv_usec; | 910 | timeout -= tv.tv_usec; |
922 | select( 0, 0, 0, 0, &tv ); | 911 | select( 0, 0, 0, 0, &tv ); |
923 | 912 | ||
924 | _iwr.u.data.pointer = &buffer[0]; | 913 | _iwr.u.data.pointer = &buffer[0]; |
925 | _iwr.u.data.flags = 0; | 914 | _iwr.u.data.flags = 0; |
926 | _iwr.u.data.length = sizeof buffer; | 915 | _iwr.u.data.length = sizeof buffer; |
927 | if ( wioctl( SIOCGIWSCAN ) ) | 916 | if ( wioctl( SIOCGIWSCAN ) ) |
928 | { | 917 | { |
929 | results = true; | 918 | results = true; |
930 | continue; | 919 | continue; |
931 | } | 920 | } |
932 | else if ( errno == EAGAIN) | 921 | else if ( errno == EAGAIN) |
933 | { | 922 | { |
934 | odebug << "ONetworkInterface::scanNetwork() - scan in progress..." << oendl; | 923 | odebug << "ONetworkInterface::scanNetwork() - scan in progress..." << oendl; |
935 | if ( qApp ) | 924 | if ( qApp ) |
936 | { | 925 | { |
937 | qApp->processEvents( 100 ); | 926 | qApp->processEvents( 100 ); |
938 | continue; | 927 | continue; |
939 | } | 928 | } |
940 | tv.tv_sec = 0; | 929 | tv.tv_sec = 0; |
941 | tv.tv_usec = 100000; | 930 | tv.tv_usec = 100000; |
942 | continue; | 931 | continue; |
943 | } | 932 | } |
944 | } | 933 | } |
945 | 934 | ||
946 | odebug << "ONetworkInterface::scanNetwork() - scan finished." << oendl; | 935 | odebug << "ONetworkInterface::scanNetwork() - scan finished." << oendl; |
947 | 936 | ||
948 | if ( results ) | 937 | if ( results ) |
949 | { | 938 | { |
950 | odebug << " - result length = " << _iwr.u.data.length << oendl; | 939 | odebug << " - result length = " << _iwr.u.data.length << oendl; |
951 | if ( !_iwr.u.data.length ) | 940 | if ( !_iwr.u.data.length ) |
952 | { | 941 | { |
953 | odebug << " - no results (empty neighbourhood)" << oendl; | 942 | odebug << " - no results (empty neighbourhood)" << oendl; |
954 | return stations; | 943 | return stations; |
955 | } | 944 | } |
956 | 945 | ||
957 | odebug << " - results are in!" << oendl; | 946 | odebug << " - results are in!" << oendl; |
958 | dumpBytes( (const unsigned char*) &buffer[0], _iwr.u.data.length ); | 947 | dumpBytes( (const unsigned char*) &buffer[0], _iwr.u.data.length ); |
959 | 948 | ||
960 | // parse results | 949 | // parse results |
961 | struct iw_event iwe; | 950 | struct iw_event iwe; |
962 | struct iw_stream_descr stream; | 951 | struct iw_stream_descr stream; |
963 | unsigned int cmd_index, event_type, event_len; | 952 | unsigned int cmd_index, event_type, event_len; |
964 | char *pointer; | 953 | char *pointer; |
965 | 954 | ||
966 | const char standard_ioctl_hdr[] = { | 955 | const char standard_ioctl_hdr[] = { |
967 | IW_HEADER_TYPE_NULL, /* SIOCSIWCOMMIT */ | 956 | IW_HEADER_TYPE_NULL, /* SIOCSIWCOMMIT */ |
968 | IW_HEADER_TYPE_CHAR, /* SIOCGIWNAME */ | 957 | IW_HEADER_TYPE_CHAR, /* SIOCGIWNAME */ |
969 | IW_HEADER_TYPE_PARAM, /* SIOCSIWNWID */ | 958 | IW_HEADER_TYPE_PARAM, /* SIOCSIWNWID */ |
970 | IW_HEADER_TYPE_PARAM, /* SIOCGIWNWID */ | 959 | IW_HEADER_TYPE_PARAM, /* SIOCGIWNWID */ |
971 | IW_HEADER_TYPE_FREQ, /* SIOCSIWFREQ */ | 960 | IW_HEADER_TYPE_FREQ, /* SIOCSIWFREQ */ |
972 | IW_HEADER_TYPE_FREQ, /* SIOCGIWFREQ */ | 961 | IW_HEADER_TYPE_FREQ, /* SIOCGIWFREQ */ |
973 | IW_HEADER_TYPE_UINT, /* SIOCSIWMODE */ | 962 | IW_HEADER_TYPE_UINT, /* SIOCSIWMODE */ |
974 | IW_HEADER_TYPE_UINT, /* SIOCGIWMODE */ | 963 | IW_HEADER_TYPE_UINT, /* SIOCGIWMODE */ |
975 | IW_HEADER_TYPE_PARAM, /* SIOCSIWSENS */ | 964 | IW_HEADER_TYPE_PARAM, /* SIOCSIWSENS */ |
976 | IW_HEADER_TYPE_PARAM, /* SIOCGIWSENS */ | 965 | IW_HEADER_TYPE_PARAM, /* SIOCGIWSENS */ |
977 | IW_HEADER_TYPE_NULL, /* SIOCSIWRANGE */ | 966 | IW_HEADER_TYPE_NULL, /* SIOCSIWRANGE */ |
978 | IW_HEADER_TYPE_POINT, /* SIOCGIWRANGE */ | 967 | IW_HEADER_TYPE_POINT, /* SIOCGIWRANGE */ |
979 | IW_HEADER_TYPE_NULL, /* SIOCSIWPRIV */ | 968 | IW_HEADER_TYPE_NULL, /* SIOCSIWPRIV */ |
980 | IW_HEADER_TYPE_POINT, /* SIOCGIWPRIV */ | 969 | IW_HEADER_TYPE_POINT, /* SIOCGIWPRIV */ |
981 | IW_HEADER_TYPE_NULL, /* SIOCSIWSTATS */ | 970 | IW_HEADER_TYPE_NULL, /* SIOCSIWSTATS */ |
982 | IW_HEADER_TYPE_POINT, /* SIOCGIWSTATS */ | 971 | IW_HEADER_TYPE_POINT, /* SIOCGIWSTATS */ |
983 | IW_HEADER_TYPE_POINT, /* SIOCSIWSPY */ | 972 | IW_HEADER_TYPE_POINT, /* SIOCSIWSPY */ |
984 | IW_HEADER_TYPE_POINT, /* SIOCGIWSPY */ | 973 | IW_HEADER_TYPE_POINT, /* SIOCGIWSPY */ |
985 | IW_HEADER_TYPE_POINT, /* SIOCSIWTHRSPY */ | 974 | IW_HEADER_TYPE_POINT, /* SIOCSIWTHRSPY */ |
986 | IW_HEADER_TYPE_POINT, /* SIOCGIWTHRSPY */ | 975 | IW_HEADER_TYPE_POINT, /* SIOCGIWTHRSPY */ |
987 | IW_HEADER_TYPE_ADDR, /* SIOCSIWAP */ | 976 | IW_HEADER_TYPE_ADDR, /* SIOCSIWAP */ |
988 | IW_HEADER_TYPE_ADDR, /* SIOCGIWAP */ | 977 | IW_HEADER_TYPE_ADDR, /* SIOCGIWAP */ |
989 | IW_HEADER_TYPE_NULL, /* -- hole -- */ | 978 | IW_HEADER_TYPE_NULL, /* -- hole -- */ |
990 | IW_HEADER_TYPE_POINT, /* SIOCGIWAPLIST */ | 979 | IW_HEADER_TYPE_POINT, /* SIOCGIWAPLIST */ |
991 | IW_HEADER_TYPE_PARAM, /* SIOCSIWSCAN */ | 980 | IW_HEADER_TYPE_PARAM, /* SIOCSIWSCAN */ |
992 | IW_HEADER_TYPE_POINT, /* SIOCGIWSCAN */ | 981 | IW_HEADER_TYPE_POINT, /* SIOCGIWSCAN */ |
993 | IW_HEADER_TYPE_POINT, /* SIOCSIWESSID */ | 982 | IW_HEADER_TYPE_POINT, /* SIOCSIWESSID */ |
994 | IW_HEADER_TYPE_POINT, /* SIOCGIWESSID */ | 983 | IW_HEADER_TYPE_POINT, /* SIOCGIWESSID */ |
995 | IW_HEADER_TYPE_POINT, /* SIOCSIWNICKN */ | 984 | IW_HEADER_TYPE_POINT, /* SIOCSIWNICKN */ |
996 | IW_HEADER_TYPE_POINT, /* SIOCGIWNICKN */ | 985 | IW_HEADER_TYPE_POINT, /* SIOCGIWNICKN */ |
997 | IW_HEADER_TYPE_NULL, /* -- hole -- */ | 986 | IW_HEADER_TYPE_NULL, /* -- hole -- */ |
998 | IW_HEADER_TYPE_NULL, /* -- hole -- */ | 987 | IW_HEADER_TYPE_NULL, /* -- hole -- */ |
999 | IW_HEADER_TYPE_PARAM, /* SIOCSIWRATE */ | 988 | IW_HEADER_TYPE_PARAM, /* SIOCSIWRATE */ |
1000 | IW_HEADER_TYPE_PARAM, /* SIOCGIWRATE */ | 989 | IW_HEADER_TYPE_PARAM, /* SIOCGIWRATE */ |
1001 | IW_HEADER_TYPE_PARAM, /* SIOCSIWRTS */ | 990 | IW_HEADER_TYPE_PARAM, /* SIOCSIWRTS */ |
1002 | IW_HEADER_TYPE_PARAM, /* SIOCGIWRTS */ | 991 | IW_HEADER_TYPE_PARAM, /* SIOCGIWRTS */ |
1003 | IW_HEADER_TYPE_PARAM, /* SIOCSIWFRAG */ | 992 | IW_HEADER_TYPE_PARAM, /* SIOCSIWFRAG */ |
1004 | IW_HEADER_TYPE_PARAM, /* SIOCGIWFRAG */ | 993 | IW_HEADER_TYPE_PARAM, /* SIOCGIWFRAG */ |
1005 | IW_HEADER_TYPE_PARAM, /* SIOCSIWTXPOW */ | 994 | IW_HEADER_TYPE_PARAM, /* SIOCSIWTXPOW */ |
1006 | IW_HEADER_TYPE_PARAM, /* SIOCGIWTXPOW */ | 995 | IW_HEADER_TYPE_PARAM, /* SIOCGIWTXPOW */ |
1007 | IW_HEADER_TYPE_PARAM, /* SIOCSIWRETRY */ | 996 | IW_HEADER_TYPE_PARAM, /* SIOCSIWRETRY */ |
1008 | IW_HEADER_TYPE_PARAM, /* SIOCGIWRETRY */ | 997 | IW_HEADER_TYPE_PARAM, /* SIOCGIWRETRY */ |
1009 | IW_HEADER_TYPE_POINT, /* SIOCSIWENCODE */ | 998 | IW_HEADER_TYPE_POINT, /* SIOCSIWENCODE */ |
1010 | IW_HEADER_TYPE_POINT, /* SIOCGIWENCODE */ | 999 | IW_HEADER_TYPE_POINT, /* SIOCGIWENCODE */ |
1011 | IW_HEADER_TYPE_PARAM, /* SIOCSIWPOWER */ | 1000 | IW_HEADER_TYPE_PARAM, /* SIOCSIWPOWER */ |
1012 | IW_HEADER_TYPE_PARAM, /* SIOCGIWPOWER */ | 1001 | IW_HEADER_TYPE_PARAM, /* SIOCGIWPOWER */ |
1013 | }; | 1002 | }; |
1014 | 1003 | ||
1015 | const char standard_event_hdr[] = { | 1004 | const char standard_event_hdr[] = { |
1016 | IW_HEADER_TYPE_ADDR, /* IWEVTXDROP */ | 1005 | IW_HEADER_TYPE_ADDR, /* IWEVTXDROP */ |
1017 | IW_HEADER_TYPE_QUAL, /* IWEVQUAL */ | 1006 | IW_HEADER_TYPE_QUAL, /* IWEVQUAL */ |
1018 | IW_HEADER_TYPE_POINT, /* IWEVCUSTOM */ | 1007 | IW_HEADER_TYPE_POINT, /* IWEVCUSTOM */ |
1019 | IW_HEADER_TYPE_ADDR, /* IWEVREGISTERED */ | 1008 | IW_HEADER_TYPE_ADDR, /* IWEVREGISTERED */ |
1020 | IW_HEADER_TYPE_ADDR, /* IWEVEXPIRED */ | 1009 | IW_HEADER_TYPE_ADDR, /* IWEVEXPIRED */ |
1021 | IW_HEADER_TYPE_POINT, /* IWEVGENIE */ | 1010 | IW_HEADER_TYPE_POINT, /* IWEVGENIE */ |
1022 | IW_HEADER_TYPE_POINT, /* IWEVMICHAELMICFAILURE */ | 1011 | IW_HEADER_TYPE_POINT, /* IWEVMICHAELMICFAILURE */ |
1023 | IW_HEADER_TYPE_POINT, /* IWEVASSOCREQIE */ | 1012 | IW_HEADER_TYPE_POINT, /* IWEVASSOCREQIE */ |
1024 | IW_HEADER_TYPE_POINT, /* IWEVASSOCRESPIE */ | 1013 | IW_HEADER_TYPE_POINT, /* IWEVASSOCRESPIE */ |
1025 | IW_HEADER_TYPE_POINT, /* IWEVPMKIDCAND */ | 1014 | IW_HEADER_TYPE_POINT, /* IWEVPMKIDCAND */ |
1026 | }; | 1015 | }; |
1027 | 1016 | ||
1028 | 1017 | ||
1029 | const int event_type_size[] = { | 1018 | const int event_type_size[] = { |
1030 | IW_EV_LCP_LEN, /* IW_HEADER_TYPE_NULL */ | 1019 | IW_EV_LCP_LEN, /* IW_HEADER_TYPE_NULL */ |
1031 | 0, | 1020 | 0, |
1032 | IW_EV_CHAR_LEN, /* IW_HEADER_TYPE_CHAR */ | 1021 | IW_EV_CHAR_LEN, /* IW_HEADER_TYPE_CHAR */ |
1033 | 0, | 1022 | 0, |
1034 | IW_EV_UINT_LEN, /* IW_HEADER_TYPE_UINT */ | 1023 | IW_EV_UINT_LEN, /* IW_HEADER_TYPE_UINT */ |
1035 | IW_EV_FREQ_LEN, /* IW_HEADER_TYPE_FREQ */ | 1024 | IW_EV_FREQ_LEN, /* IW_HEADER_TYPE_FREQ */ |
1036 | IW_EV_ADDR_LEN, /* IW_HEADER_TYPE_ADDR */ | 1025 | IW_EV_ADDR_LEN, /* IW_HEADER_TYPE_ADDR */ |
1037 | 0, | 1026 | 0, |
1038 | IW_EV_POINT_LEN, /* Without variable payload */ | 1027 | IW_EV_POINT_LEN, /* Without variable payload */ |
1039 | IW_EV_PARAM_LEN, /* IW_HEADER_TYPE_PARAM */ | 1028 | IW_EV_PARAM_LEN, /* IW_HEADER_TYPE_PARAM */ |
1040 | IW_EV_QUAL_LEN, /* IW_HEADER_TYPE_QUAL */ | 1029 | IW_EV_QUAL_LEN, /* IW_HEADER_TYPE_QUAL */ |
1041 | }; | 1030 | }; |
1042 | 1031 | ||
1043 | 1032 | ||
1044 | //Initialize the stream | 1033 | //Initialize the stream |
1045 | memset( &stream, 0, sizeof(struct iw_stream_descr) ); | 1034 | memset( &stream, 0, sizeof(struct iw_stream_descr) ); |
1046 | stream.current = buffer; | 1035 | stream.current = buffer; |
1047 | stream.end = buffer + _iwr.u.data.length; | 1036 | stream.end = buffer + _iwr.u.data.length; |
1048 | 1037 | ||
1049 | do | 1038 | do |
1050 | { | 1039 | { |
1051 | if ((stream.current + IW_EV_LCP_LEN) > stream.end) | 1040 | if ((stream.current + IW_EV_LCP_LEN) > stream.end) |
1052 | break; | 1041 | break; |
1053 | memcpy((char *) &iwe, stream.current, IW_EV_LCP_LEN); | 1042 | memcpy((char *) &iwe, stream.current, IW_EV_LCP_LEN); |
1054 | 1043 | ||
1055 | if (iwe.len <= IW_EV_LCP_LEN) //If yes, it is an invalid event | 1044 | if (iwe.len <= IW_EV_LCP_LEN) //If yes, it is an invalid event |
1056 | break; | 1045 | break; |
1057 | if (iwe.cmd <= SIOCIWLAST) { | 1046 | if (iwe.cmd <= SIOCIWLAST) { |
1058 | cmd_index = iwe.cmd - SIOCIWFIRST; | 1047 | cmd_index = iwe.cmd - SIOCIWFIRST; |
1059 | 1048 | ||
1060 | if(cmd_index < sizeof(standard_ioctl_hdr)) | 1049 | if(cmd_index < sizeof(standard_ioctl_hdr)) |
1061 | event_type = standard_ioctl_hdr[cmd_index]; | 1050 | event_type = standard_ioctl_hdr[cmd_index]; |
1062 | } | 1051 | } |
1063 | else { | 1052 | else { |
1064 | cmd_index = iwe.cmd - IWEVFIRST; | 1053 | cmd_index = iwe.cmd - IWEVFIRST; |
1065 | 1054 | ||
1066 | if(cmd_index < sizeof(standard_event_hdr)) | 1055 | if(cmd_index < sizeof(standard_event_hdr)) |
1067 | event_type = standard_event_hdr[cmd_index]; | 1056 | event_type = standard_event_hdr[cmd_index]; |
1068 | } | 1057 | } |
1069 | 1058 | ||
1070 | /* Unknown events -> event_type=0 => IW_EV_LCP_LEN */ | 1059 | /* Unknown events -> event_type=0 => IW_EV_LCP_LEN */ |
1071 | event_len = event_type_size[event_type]; | 1060 | event_len = event_type_size[event_type]; |
1072 | 1061 | ||
1073 | /* Fixup for later version of WE */ | 1062 | /* Fixup for later version of WE */ |
1074 | if((_range.we_version_compiled > 18) && (event_type == IW_HEADER_TYPE_POINT)) | 1063 | if((_range.we_version_compiled > 18) && (event_type == IW_HEADER_TYPE_POINT)) |
1075 | event_len -= IW_EV_POINT_OFF; | 1064 | event_len -= IW_EV_POINT_OFF; |
1076 | 1065 | ||
1077 | /* Check if we know about this event */ | 1066 | /* Check if we know about this event */ |
1078 | if(event_len <= IW_EV_LCP_LEN) { | 1067 | if(event_len <= IW_EV_LCP_LEN) { |
1079 | /* Skip to next event */ | 1068 | /* Skip to next event */ |
1080 | stream.current += iwe.len; | 1069 | stream.current += iwe.len; |
1081 | continue; | 1070 | continue; |
1082 | } | 1071 | } |
1083 | 1072 | ||
1084 | event_len -= IW_EV_LCP_LEN; | 1073 | event_len -= IW_EV_LCP_LEN; |
1085 | 1074 | ||
1086 | /* Set pointer on data */ | 1075 | /* Set pointer on data */ |
1087 | if(stream.value != NULL) | 1076 | if(stream.value != NULL) |
1088 | pointer = stream.value; /* Next value in event */ | 1077 | pointer = stream.value; /* Next value in event */ |
1089 | else | 1078 | else |
1090 | pointer = stream.current + IW_EV_LCP_LEN; /* First value in event */ | 1079 | pointer = stream.current + IW_EV_LCP_LEN; /* First value in event */ |
1091 | 1080 | ||
1092 | if((pointer + event_len) > stream.end) { | 1081 | if((pointer + event_len) > stream.end) { |
1093 | /* Go to next event */ | 1082 | /* Go to next event */ |
1094 | stream.current += iwe.len; | 1083 | stream.current += iwe.len; |
1095 | break; | 1084 | break; |
1096 | } | 1085 | } |
1097 | 1086 | ||
1098 | /* Fixup for later version of WE */ | 1087 | /* Fixup for later version of WE */ |
1099 | if((_range.we_version_compiled > 18) && (event_type == IW_HEADER_TYPE_POINT)) | 1088 | if((_range.we_version_compiled > 18) && (event_type == IW_HEADER_TYPE_POINT)) |
1100 | memcpy((char *) &iwe + IW_EV_LCP_LEN + IW_EV_POINT_OFF, pointer, event_len); | 1089 | memcpy((char *) &iwe + IW_EV_LCP_LEN + IW_EV_POINT_OFF, pointer, event_len); |
1101 | else | 1090 | else |
1102 | memcpy((char *) &iwe + IW_EV_LCP_LEN, pointer, event_len); | 1091 | memcpy((char *) &iwe + IW_EV_LCP_LEN, pointer, event_len); |
1103 | 1092 | ||
1104 | /* Skip event in the stream */ | 1093 | /* Skip event in the stream */ |
1105 | pointer += event_len; | 1094 | pointer += event_len; |
1106 | 1095 | ||
1107 | /* Special processing for iw_point events */ | 1096 | /* Special processing for iw_point events */ |
1108 | if(event_type == IW_HEADER_TYPE_POINT) { | 1097 | if(event_type == IW_HEADER_TYPE_POINT) { |
1109 | /* Check the length of the payload */ | 1098 | /* Check the length of the payload */ |
1110 | 1099 | ||
1111 | if((iwe.len - (event_len + IW_EV_LCP_LEN)) > 0) | 1100 | if((iwe.len - (event_len + IW_EV_LCP_LEN)) > 0) |
1112 | /* Set pointer on variable part (warning : non aligned) */ | 1101 | /* Set pointer on variable part (warning : non aligned) */ |
1113 | iwe.u.data.pointer = pointer; | 1102 | iwe.u.data.pointer = pointer; |
1114 | else | 1103 | else |
1115 | /* No data */ | 1104 | /* No data */ |
1116 | iwe.u.data.pointer = NULL; | 1105 | iwe.u.data.pointer = NULL; |
1117 | /* Go to next event */ | 1106 | /* Go to next event */ |
1118 | stream.current += iwe.len; | 1107 | stream.current += iwe.len; |
1119 | } | 1108 | } |
1120 | 1109 | ||
1121 | else { | 1110 | else { |
1122 | /* Is there more value in the event ? */ | 1111 | /* Is there more value in the event ? */ |
1123 | if((pointer + event_len) <= (stream.current + iwe.len)) | 1112 | if((pointer + event_len) <= (stream.current + iwe.len)) |
1124 | /* Go to next value */ | 1113 | /* Go to next value */ |
1125 | stream.value = pointer; | 1114 | stream.value = pointer; |
1126 | else { | 1115 | else { |
1127 | /* Go to next event */ | 1116 | /* Go to next event */ |
1128 | stream.value = NULL; | 1117 | stream.value = NULL; |
1129 | stream.current += iwe.len; | 1118 | stream.current += iwe.len; |
1130 | } | 1119 | } |
1131 | } | 1120 | } |
1132 | 1121 | ||
1133 | struct iw_event *we = &iwe; | 1122 | struct iw_event *we = &iwe; |
1134 | //------ | 1123 | //------ |
1135 | odebug << " - reading next event... cmd=" << we->cmd << ", len=" << we->len << oendl; | 1124 | odebug << " - reading next event... cmd=" << we->cmd << ", len=" << we->len << oendl; |
1136 | switch (we->cmd) | 1125 | switch (we->cmd) |
1137 | { | 1126 | { |
1138 | case SIOCGIWAP: | 1127 | case SIOCGIWAP: |
1139 | { | 1128 | { |
1140 | odebug << "SIOCGIWAP" << oendl; | 1129 | odebug << "SIOCGIWAP" << oendl; |
1141 | stations->append( new OStation() ); | 1130 | stations->append( new OStation() ); |
1142 | stations->last()->macAddress = (const unsigned char*) &we->u.ap_addr.sa_data[0]; | 1131 | stations->last()->macAddress = (const unsigned char*) &we->u.ap_addr.sa_data[0]; |
1143 | break; | 1132 | break; |
1144 | } | 1133 | } |
1145 | case SIOCGIWMODE: | 1134 | case SIOCGIWMODE: |
1146 | { | 1135 | { |
1147 | odebug << "SIOCGIWMODE" << oendl; | 1136 | odebug << "SIOCGIWMODE" << oendl; |
1148 | stations->last()->type = modeToString( we->u.mode ); | 1137 | stations->last()->type = modeToString( we->u.mode ); |
1149 | break; | 1138 | break; |
1150 | } | 1139 | } |
1151 | case SIOCGIWFREQ: | 1140 | case SIOCGIWFREQ: |
1152 | { | 1141 | { |
1153 | odebug << "SIOCGIWFREQ" << oendl; | 1142 | odebug << "SIOCGIWFREQ" << oendl; |
1154 | if ( we->u.freq.m > 1000 ) | 1143 | if ( we->u.freq.m > 1000 ) |
1155 | stations->last()->channel = _channels[ static_cast<int>(double( we->u.freq.m ) * pow( 10.0, we->u.freq.e ) / 1000000) ]; | 1144 | stations->last()->channel = _channels[ static_cast<int>(double( we->u.freq.m ) * pow( 10.0, we->u.freq.e ) / 1000000) ]; |
1156 | else | 1145 | else |
1157 | stations->last()->channel = static_cast<int>(((double) we->u.freq.m) * pow( 10.0, we->u.freq.e )); | 1146 | stations->last()->channel = static_cast<int>(((double) we->u.freq.m) * pow( 10.0, we->u.freq.e )); |
1158 | break; | 1147 | break; |
1159 | } | 1148 | } |
1160 | case SIOCGIWESSID: | 1149 | case SIOCGIWESSID: |
1161 | { | 1150 | { |
1162 | odebug << "SIOCGIWESSID" << oendl; | 1151 | odebug << "SIOCGIWESSID" << oendl; |
1163 | we->u.essid.length = '\0'; // make sure it is zero terminated | 1152 | we->u.essid.length = '\0'; // make sure it is zero terminated |
1164 | stations->last()->ssid = static_cast<const char*> (we->u.essid.pointer); | 1153 | stations->last()->ssid = static_cast<const char*> (we->u.essid.pointer); |
1165 | odebug << "ESSID: " << stations->last()->ssid << oendl; | 1154 | odebug << "ESSID: " << stations->last()->ssid << oendl; |
1166 | break; | 1155 | break; |
1167 | } | 1156 | } |
1168 | case IWEVQUAL: | 1157 | case IWEVQUAL: |
1169 | { | 1158 | { |
1170 | odebug << "IWEVQUAL" << oendl; | 1159 | odebug << "IWEVQUAL" << oendl; |
1171 | stations->last()->level = static_cast<int>(we->u.qual.level); | 1160 | stations->last()->level = static_cast<int>(we->u.qual.level); |
1172 | break; /* Quality part of statistics (scan) */ | 1161 | break; /* Quality part of statistics (scan) */ |
1173 | } | 1162 | } |
1174 | case SIOCGIWENCODE: | 1163 | case SIOCGIWENCODE: |
1175 | { | 1164 | { |
1176 | odebug << "SIOCGIWENCODE" << oendl; | 1165 | odebug << "SIOCGIWENCODE" << oendl; |
1177 | stations->last()->encrypted = !(we->u.data.flags & IW_ENCODE_DISABLED); | 1166 | stations->last()->encrypted = !(we->u.data.flags & IW_ENCODE_DISABLED); |
1178 | break; | 1167 | break; |
1179 | } | 1168 | } |
1180 | 1169 | ||
1181 | case SIOCGIWRATE: | 1170 | case SIOCGIWRATE: |
1182 | { | 1171 | { |
1183 | odebug << "SIOCGIWRATE" << oendl; | 1172 | odebug << "SIOCGIWRATE" << oendl; |
1184 | stations->last()->rates.append(we->u.bitrate.value); | 1173 | stations->last()->rates.append(we->u.bitrate.value); |
1185 | break; | 1174 | break; |
1186 | } | 1175 | } |
1187 | case SIOCGIWSENS: odebug << "SIOCGIWSENS" << oendl; break; | 1176 | case SIOCGIWSENS: odebug << "SIOCGIWSENS" << oendl; break; |
1188 | case IWEVTXDROP: odebug << "IWEVTXDROP" << oendl; break; /* Packet dropped to excessive retry */ | 1177 | case IWEVTXDROP: odebug << "IWEVTXDROP" << oendl; break; /* Packet dropped to excessive retry */ |
1189 | case IWEVCUSTOM: odebug << "IWEVCUSTOM" << oendl; break; /* Driver specific ascii string */ | 1178 | case IWEVCUSTOM: odebug << "IWEVCUSTOM" << oendl; break; /* Driver specific ascii string */ |
1190 | case IWEVREGISTERED: odebug << "IWEVREGISTERED" << oendl; break; /* Discovered a new node (AP mode) */ | 1179 | case IWEVREGISTERED: odebug << "IWEVREGISTERED" << oendl; break; /* Discovered a new node (AP mode) */ |
1191 | case IWEVEXPIRED: odebug << "IWEVEXPIRED" << oendl; break; /* Expired a node (AP mode) */ | 1180 | case IWEVEXPIRED: odebug << "IWEVEXPIRED" << oendl; break; /* Expired a node (AP mode) */ |
1192 | default: odebug << "unhandled event" << oendl; | 1181 | default: odebug << "unhandled event" << oendl; |
1193 | } | 1182 | } |
1194 | 1183 | ||
1195 | } while (true); | 1184 | } while (true); |
1196 | } | 1185 | } |
1197 | else | 1186 | else |
1198 | { | 1187 | { |
1199 | odebug << " - no results (timeout) :(" << oendl; | 1188 | odebug << " - no results (timeout) :(" << oendl; |
1200 | } | 1189 | } |
1201 | return stations; | 1190 | return stations; |
1202 | } | 1191 | } |
1203 | 1192 | ||
1204 | 1193 | ||
1205 | int OWirelessNetworkInterface::signalStrength() const | 1194 | int OWirelessNetworkInterface::signalStrength() const |
1206 | { | 1195 | { |
1207 | iw_statistics stat; | 1196 | iw_statistics stat; |
1208 | ::memset( &stat, 0, sizeof stat ); | 1197 | ::memset( &stat, 0, sizeof stat ); |
1209 | _iwr.u.data.pointer = (char*) &stat; | 1198 | _iwr.u.data.pointer = (char*) &stat; |
1210 | _iwr.u.data.flags = 0; | 1199 | _iwr.u.data.flags = 0; |
1211 | _iwr.u.data.length = sizeof stat; | 1200 | _iwr.u.data.length = sizeof stat; |
1212 | 1201 | ||
1213 | if ( !wioctl( SIOCGIWSTATS ) ) | 1202 | if ( !wioctl( SIOCGIWSTATS ) ) |
1214 | { | 1203 | { |
1215 | return -1; | 1204 | return -1; |
1216 | } | 1205 | } |
1217 | 1206 | ||
1218 | int max = _range.max_qual.qual; | 1207 | int max = _range.max_qual.qual; |
1219 | int cur = stat.qual.qual; | 1208 | int cur = stat.qual.qual; |
1220 | // int lev = stat.qual.level; //FIXME: Do something with them? | 1209 | // int lev = stat.qual.level; //FIXME: Do something with them? |
1221 | // int noi = stat.qual.noise; //FIXME: Do something with them? | 1210 | // int noi = stat.qual.noise; //FIXME: Do something with them? |
1222 | 1211 | ||
1223 | 1212 | ||
1224 | return max != 0 ? cur*100/max: -1; | 1213 | return max != 0 ? cur*100/max: -1; |
1225 | } | 1214 | } |
1226 | 1215 | ||
1227 | 1216 | ||
1228 | bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const | 1217 | bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const |
1229 | { | 1218 | { |
1230 | #ifndef NODEBUG | 1219 | #ifndef NODEBUG |
1231 | int result = ::ioctl( _sfd, call, &iwreq ); | 1220 | int result = ::ioctl( _sfd, call, &iwreq ); |
1232 | 1221 | ||
1233 | if ( result == -1 ) | 1222 | if ( result == -1 ) |
1234 | odebug << "ONetworkInterface::wioctl (" << name() << ") call '" | 1223 | odebug << "ONetworkInterface::wioctl (" << name() << ") call '" |
1235 | << debugmapper->map( call ) << "' FAILED! " << result << " (" << strerror( errno ) << ")" << oendl; | 1224 | << debugmapper->map( call ) << "' FAILED! " << result << " (" << strerror( errno ) << ")" << oendl; |
1236 | else | 1225 | else |
1237 | odebug << "ONetworkInterface::wioctl (" << name() << ") call '" | 1226 | odebug << "ONetworkInterface::wioctl (" << name() << ") call '" |
1238 | << debugmapper->map( call ) << "' - Status: Ok." << oendl; | 1227 | << debugmapper->map( call ) << "' - Status: Ok." << oendl; |
1239 | 1228 | ||
1240 | return ( result != -1 ); | 1229 | return ( result != -1 ); |
1241 | #else | 1230 | #else |
1242 | return ::ioctl( _sfd, call, &iwreq ) != -1; | 1231 | return ::ioctl( _sfd, call, &iwreq ) != -1; |
1243 | #endif | 1232 | #endif |
1244 | } | 1233 | } |
1245 | 1234 | ||
1246 | 1235 | ||
1247 | bool OWirelessNetworkInterface::wioctl( int call ) const | 1236 | bool OWirelessNetworkInterface::wioctl( int call ) const |
1248 | { | 1237 | { |
1249 | strcpy( _iwr.ifr_name, name() ); | 1238 | strcpy( _iwr.ifr_name, name() ); |
1250 | return wioctl( call, _iwr ); | 1239 | return wioctl( call, _iwr ); |
1251 | } | 1240 | } |
1252 | 1241 | ||
1253 | 1242 | ||
1254 | /*====================================================================================== | 1243 | /*====================================================================================== |
1255 | * OMonitoringInterface | 1244 | * OMonitoringInterface |
1256 | *======================================================================================*/ | 1245 | *======================================================================================*/ |
1257 | 1246 | ||
1258 | OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) | 1247 | OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) |
1259 | :_if( static_cast<OWirelessNetworkInterface*>( iface ) ), _prismHeader( prismHeader ) | 1248 | :_if( static_cast<OWirelessNetworkInterface*>( iface ) ), _prismHeader( prismHeader ) |
1260 | { | 1249 | { |
1261 | } | 1250 | } |
1262 | 1251 | ||
1263 | 1252 | ||
1264 | OMonitoringInterface::~OMonitoringInterface() | 1253 | OMonitoringInterface::~OMonitoringInterface() |
1265 | { | 1254 | { |
1266 | } | 1255 | } |
1267 | 1256 | ||
1268 | 1257 | ||
1269 | void OMonitoringInterface::setChannel( int c ) | 1258 | void OMonitoringInterface::setChannel( int c ) |
1270 | { | 1259 | { |
1271 | // use standard WE channel switching protocol | 1260 | // use standard WE channel switching protocol |
1272 | memset( &_if->_iwr, 0, sizeof( struct iwreq ) ); | 1261 | memset( &_if->_iwr, 0, sizeof( struct iwreq ) ); |
1273 | _if->_iwr.u.freq.m = c; | 1262 | _if->_iwr.u.freq.m = c; |
1274 | _if->_iwr.u.freq.e = 0; | 1263 | _if->_iwr.u.freq.e = 0; |
1275 | _if->wioctl( SIOCSIWFREQ ); | 1264 | _if->wioctl( SIOCSIWFREQ ); |
1276 | } | 1265 | } |
1277 | 1266 | ||
1278 | 1267 | ||
1279 | void OMonitoringInterface::setEnabled( bool ) | 1268 | void OMonitoringInterface::setEnabled( bool ) |
1280 | { | 1269 | { |
1281 | } | 1270 | } |
1282 | 1271 | ||
1283 | 1272 | ||
1284 | /*====================================================================================== | 1273 | /*====================================================================================== |
1285 | * OCiscoMonitoringInterface | 1274 | * OCiscoMonitoringInterface |
1286 | *======================================================================================*/ | 1275 | *======================================================================================*/ |
1287 | 1276 | ||
1288 | OCiscoMonitoringInterface::OCiscoMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) | 1277 | OCiscoMonitoringInterface::OCiscoMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) |
1289 | :OMonitoringInterface( iface, prismHeader ) | 1278 | :OMonitoringInterface( iface, prismHeader ) |
1290 | { | 1279 | { |
1291 | iface->setMonitoring( this ); | 1280 | iface->setMonitoring( this ); |
1292 | } | 1281 | } |
1293 | 1282 | ||
1294 | 1283 | ||
1295 | OCiscoMonitoringInterface::~OCiscoMonitoringInterface() | 1284 | OCiscoMonitoringInterface::~OCiscoMonitoringInterface() |
1296 | { | 1285 | { |
1297 | } | 1286 | } |
1298 | 1287 | ||
1299 | 1288 | ||
1300 | void OCiscoMonitoringInterface::setEnabled( bool /*b*/ ) | 1289 | void OCiscoMonitoringInterface::setEnabled( bool /*b*/ ) |
1301 | { | 1290 | { |
1302 | QString fname; | 1291 | QString fname; |
1303 | fname.sprintf( "/proc/driver/aironet/%s", (const char*) _if->name() ); | 1292 | fname.sprintf( "/proc/driver/aironet/%s", (const char*) _if->name() ); |
1304 | QFile f( fname ); | 1293 | QFile f( fname ); |
1305 | if ( !f.exists() ) return; | 1294 | if ( !f.exists() ) return; |
1306 | 1295 | ||
1307 | if ( f.open( IO_WriteOnly ) ) | 1296 | if ( f.open( IO_WriteOnly ) ) |
1308 | { | 1297 | { |
1309 | QTextStream s( &f ); | 1298 | QTextStream s( &f ); |
1310 | s << "Mode: r"; | 1299 | s << "Mode: r"; |
1311 | s << "Mode: y"; | 1300 | s << "Mode: y"; |
1312 | s << "XmitPower: 1"; | 1301 | s << "XmitPower: 1"; |
1313 | } | 1302 | } |
1314 | 1303 | ||
1315 | // flushing and closing will be done automatically when f goes out of scope | 1304 | // flushing and closing will be done automatically when f goes out of scope |
1316 | } | 1305 | } |
1317 | 1306 | ||
1318 | 1307 | ||
1319 | QString OCiscoMonitoringInterface::name() const | 1308 | QString OCiscoMonitoringInterface::name() const |
1320 | { | 1309 | { |
1321 | return "cisco"; | 1310 | return "cisco"; |
1322 | } | 1311 | } |
1323 | 1312 | ||
1324 | 1313 | ||
1325 | void OCiscoMonitoringInterface::setChannel( int ) | 1314 | void OCiscoMonitoringInterface::setChannel( int ) |
1326 | { | 1315 | { |
1327 | // cisco devices automatically switch channels when in monitor mode | 1316 | // cisco devices automatically switch channels when in monitor mode |
1328 | } | 1317 | } |
1329 | 1318 | ||
1330 | 1319 | ||
1331 | /*====================================================================================== | 1320 | /*====================================================================================== |
1332 | * OWlanNGMonitoringInterface | 1321 | * OWlanNGMonitoringInterface |
1333 | *======================================================================================*/ | 1322 | *======================================================================================*/ |
1334 | 1323 | ||
1335 | 1324 | ||
1336 | OWlanNGMonitoringInterface::OWlanNGMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) | 1325 | OWlanNGMonitoringInterface::OWlanNGMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) |
1337 | :OMonitoringInterface( iface, prismHeader ) | 1326 | :OMonitoringInterface( iface, prismHeader ) |
1338 | { | 1327 | { |
1339 | iface->setMonitoring( this ); | 1328 | iface->setMonitoring( this ); |
1340 | } | 1329 | } |
1341 | 1330 | ||
1342 | 1331 | ||
1343 | OWlanNGMonitoringInterface::~OWlanNGMonitoringInterface() | 1332 | OWlanNGMonitoringInterface::~OWlanNGMonitoringInterface() |
1344 | { | 1333 | { |
1345 | } | 1334 | } |
1346 | 1335 | ||
1347 | 1336 | ||
1348 | void OWlanNGMonitoringInterface::setEnabled( bool b ) | 1337 | void OWlanNGMonitoringInterface::setEnabled( bool b ) |
1349 | { | 1338 | { |
1350 | //FIXME: do nothing if its already in the same mode | 1339 | //FIXME: do nothing if its already in the same mode |
1351 | 1340 | ||
1352 | QString enable = b ? "true" : "false"; | 1341 | QString enable = b ? "true" : "false"; |
1353 | QString prism = _prismHeader ? "true" : "false"; | 1342 | QString prism = _prismHeader ? "true" : "false"; |
1354 | QString cmd; | 1343 | QString cmd; |
1355 | cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s prismheader=%s", | 1344 | cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s prismheader=%s", |
1356 | (const char*) _if->name(), 1, (const char*) enable, (const char*) prism ); | 1345 | (const char*) _if->name(), 1, (const char*) enable, (const char*) prism ); |
1357 | system( cmd ); | 1346 | system( cmd ); |
1358 | } | 1347 | } |
1359 | 1348 | ||
1360 | 1349 | ||
1361 | QString OWlanNGMonitoringInterface::name() const | 1350 | QString OWlanNGMonitoringInterface::name() const |
1362 | { | 1351 | { |
1363 | return "wlan-ng"; | 1352 | return "wlan-ng"; |
1364 | } | 1353 | } |
1365 | 1354 | ||
1366 | 1355 | ||
1367 | void OWlanNGMonitoringInterface::setChannel( int c ) | 1356 | void OWlanNGMonitoringInterface::setChannel( int c ) |
1368 | { | 1357 | { |
1369 | //NOTE: Older wlan-ng drivers automatically hopped channels while lnxreq_wlansniff=true. Newer ones don't. | 1358 | //NOTE: Older wlan-ng drivers automatically hopped channels while lnxreq_wlansniff=true. Newer ones don't. |
1370 | 1359 | ||
1371 | QString enable = "true"; //_if->monitorMode() ? "true" : "false"; | 1360 | QString enable = "true"; //_if->monitorMode() ? "true" : "false"; |
1372 | QString prism = _prismHeader ? "true" : "false"; | 1361 | QString prism = _prismHeader ? "true" : "false"; |
1373 | QString cmd; | 1362 | QString cmd; |
1374 | cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s prismheader=%s", | 1363 | cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s prismheader=%s", |
1375 | (const char*) _if->name(), c, (const char*) enable, (const char*) prism ); | 1364 | (const char*) _if->name(), c, (const char*) enable, (const char*) prism ); |
1376 | system( cmd ); | 1365 | system( cmd ); |
1377 | } | 1366 | } |
1378 | 1367 | ||
1379 | 1368 | ||
1380 | /*====================================================================================== | 1369 | /*====================================================================================== |
1381 | * OHostAPMonitoringInterface | 1370 | * OHostAPMonitoringInterface |
1382 | *======================================================================================*/ | 1371 | *======================================================================================*/ |
1383 | 1372 | ||
1384 | OHostAPMonitoringInterface::OHostAPMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) | 1373 | OHostAPMonitoringInterface::OHostAPMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) |
1385 | :OMonitoringInterface( iface, prismHeader ) | 1374 | :OMonitoringInterface( iface, prismHeader ) |
1386 | { | 1375 | { |
1387 | iface->setMonitoring( this ); | 1376 | iface->setMonitoring( this ); |
1388 | } | 1377 | } |
1389 | 1378 | ||
1390 | OHostAPMonitoringInterface::~OHostAPMonitoringInterface() | 1379 | OHostAPMonitoringInterface::~OHostAPMonitoringInterface() |
1391 | { | 1380 | { |
1392 | } | 1381 | } |
1393 | 1382 | ||
1394 | void OHostAPMonitoringInterface::setEnabled( bool b ) | 1383 | void OHostAPMonitoringInterface::setEnabled( bool b ) |
1395 | { | 1384 | { |
1396 | int monitorCode = _prismHeader ? 1 : 2; | 1385 | int monitorCode = _prismHeader ? 1 : 2; |
1397 | if ( b ) | 1386 | if ( b ) |
1398 | { | 1387 | { |
1399 | _if->setPrivate( "monitor", 1, monitorCode ); | 1388 | _if->setPrivate( "monitor", 1, monitorCode ); |
1400 | } | 1389 | } |
1401 | else | 1390 | else |
1402 | { | 1391 | { |
1403 | _if->setPrivate( "monitor", 1, 0 ); | 1392 | _if->setPrivate( "monitor", 1, 0 ); |
1404 | } | 1393 | } |
1405 | } | 1394 | } |
1406 | 1395 | ||
1407 | 1396 | ||
1408 | QString OHostAPMonitoringInterface::name() const | 1397 | QString OHostAPMonitoringInterface::name() const |
1409 | { | 1398 | { |
1410 | return "hostap"; | 1399 | return "hostap"; |
1411 | } | 1400 | } |
1412 | 1401 | ||
1413 | 1402 | ||
1414 | /*====================================================================================== | 1403 | /*====================================================================================== |
1415 | * OOrinocoNetworkInterface | 1404 | * OOrinocoNetworkInterface |
1416 | *======================================================================================*/ | 1405 | *======================================================================================*/ |
1417 | 1406 | ||
1418 | OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) | 1407 | OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) |
1419 | :OMonitoringInterface( iface, prismHeader ) | 1408 | :OMonitoringInterface( iface, prismHeader ) |
1420 | { | 1409 | { |
1421 | iface->setMonitoring( this ); | 1410 | iface->setMonitoring( this ); |
1422 | } | 1411 | } |
1423 | 1412 | ||
1424 | 1413 | ||
1425 | OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface() | 1414 | OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface() |
1426 | { | 1415 | { |
1427 | } | 1416 | } |
1428 | 1417 | ||
1429 | 1418 | ||
1430 | void OOrinocoMonitoringInterface::setChannel( int c ) | 1419 | void OOrinocoMonitoringInterface::setChannel( int c ) |
1431 | { | 1420 | { |
1432 | if ( !_if->hasPrivate( "monitor" ) ) | 1421 | if ( !_if->hasPrivate( "monitor" ) ) |
1433 | { | 1422 | { |
1434 | this->OMonitoringInterface::setChannel( c ); | 1423 | this->OMonitoringInterface::setChannel( c ); |
1435 | } | 1424 | } |
1436 | else | 1425 | else |
1437 | { | 1426 | { |
1438 | int monitorCode = _prismHeader ? 1 : 2; | 1427 | int monitorCode = _prismHeader ? 1 : 2; |
1439 | _if->setPrivate( "monitor", 2, monitorCode, c ); | 1428 | _if->setPrivate( "monitor", 2, monitorCode, c ); |
1440 | } | 1429 | } |
1441 | } | 1430 | } |
1442 | 1431 | ||
1443 | 1432 | ||
1444 | void OOrinocoMonitoringInterface::setEnabled( bool b ) | 1433 | void OOrinocoMonitoringInterface::setEnabled( bool b ) |
1445 | { | 1434 | { |
1446 | if ( b ) | 1435 | if ( b ) |
1447 | { | 1436 | { |
1448 | setChannel( 1 ); | 1437 | setChannel( 1 ); |
1449 | } | 1438 | } |
1450 | else | 1439 | else |
1451 | { | 1440 | { |
1452 | _if->setPrivate( "monitor", 2, 0, 0 ); | 1441 | _if->setPrivate( "monitor", 2, 0, 0 ); |
1453 | } | 1442 | } |
1454 | } | 1443 | } |
1455 | 1444 | ||
1456 | 1445 | ||
1457 | QString OOrinocoMonitoringInterface::name() const | 1446 | QString OOrinocoMonitoringInterface::name() const |
1458 | { | 1447 | { |
1459 | return "orinoco"; | 1448 | return "orinoco"; |
1460 | } | 1449 | } |
1461 | 1450 | ||
1462 | } | 1451 | } |
1463 | } | 1452 | } |
diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h index f0c4450..b13c7a3 100644 --- a/libopie2/opienet/onetwork.h +++ b/libopie2/opienet/onetwork.h | |||
@@ -1,598 +1,597 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) 2003-2005 by Michael 'Mickey' Lauer <mickey@Vanille.de> | 3 | =. Copyright (C) 2003-2005 by Michael 'Mickey' Lauer <mickey@Vanille.de> |
4 | =. | ||
5 | .=l. | 4 | .=l. |
6 | .>+-= | 5 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 6 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; version 2 of the License. | 10 | - . .-<_> .<> Foundation; version 2 of the License. |
12 | ._= =} : | 11 | ._= =} : |
13 | .%`+i> _;_. | 12 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 13 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 18 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 19 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 20 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 21 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 22 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 23 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 24 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 25 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
28 | 27 | ||
29 | */ | 28 | */ |
30 | 29 | ||
31 | #ifndef ONETWORK_H | 30 | #ifndef ONETWORK_H |
32 | #define ONETWORK_H | 31 | #define ONETWORK_H |
33 | 32 | ||
34 | /* OPIE */ | 33 | /* OPIE */ |
35 | #include <opie2/onetutils.h> | 34 | #include <opie2/onetutils.h> |
36 | #include <opie2/ostation.h> | 35 | #include <opie2/ostation.h> |
37 | 36 | ||
38 | /* QT */ | 37 | /* QT */ |
39 | #include <qvaluelist.h> | 38 | #include <qvaluelist.h> |
40 | #include <qdict.h> | 39 | #include <qdict.h> |
41 | #include <qmap.h> | 40 | #include <qmap.h> |
42 | #include <qobject.h> | 41 | #include <qobject.h> |
43 | #include <qhostaddress.h> | 42 | #include <qhostaddress.h> |
44 | 43 | ||
45 | /* STD */ | 44 | /* STD */ |
46 | // hacky workarounds until we have a true user space wireless.h | 45 | // hacky workarounds until we have a true user space wireless.h |
47 | #include <net/if.h> | 46 | #include <net/if.h> |
48 | #define _LINUX_IF_H | 47 | #define _LINUX_IF_H |
49 | #include <linux/wireless.h> | 48 | #include <linux/wireless.h> |
50 | #ifndef IW_MAX_PRIV_DEF | 49 | #ifndef IW_MAX_PRIV_DEF |
51 | #define IW_MAX_PRIV_DEF 128 | 50 | #define IW_MAX_PRIV_DEF 128 |
52 | #endif | 51 | #endif |
53 | 52 | ||
54 | namespace Opie { | 53 | namespace Opie { |
55 | namespace Net { | 54 | namespace Net { |
56 | class ONetworkInterface; | 55 | class ONetworkInterface; |
57 | class OWirelessNetworkInterface; | 56 | class OWirelessNetworkInterface; |
58 | class OChannelHopper; | 57 | class OChannelHopper; |
59 | class OMonitoringInterface; | 58 | class OMonitoringInterface; |
60 | 59 | ||
61 | /*====================================================================================== | 60 | /*====================================================================================== |
62 | * ONetwork | 61 | * ONetwork |
63 | *======================================================================================*/ | 62 | *======================================================================================*/ |
64 | 63 | ||
65 | /** | 64 | /** |
66 | * @brief A container class for all network interfaces | 65 | * @brief A container class for all network interfaces |
67 | * | 66 | * |
68 | * This class provides access to all available network interfaces of your computer. | 67 | * This class provides access to all available network interfaces of your computer. |
69 | * | 68 | * |
70 | * @author Michael 'Mickey' Lauer <mickey@vanille.de> | 69 | * @author Michael 'Mickey' Lauer <mickey@vanille.de> |
71 | */ | 70 | */ |
72 | class ONetwork : public QObject | 71 | class ONetwork : public QObject |
73 | { | 72 | { |
74 | Q_OBJECT | 73 | Q_OBJECT |
75 | 74 | ||
76 | public: | 75 | public: |
77 | typedef QDict<ONetworkInterface> InterfaceMap; | 76 | typedef QDict<ONetworkInterface> InterfaceMap; |
78 | typedef QDictIterator<ONetworkInterface> InterfaceIterator; | 77 | typedef QDictIterator<ONetworkInterface> InterfaceIterator; |
79 | 78 | ||
80 | public: | 79 | public: |
81 | /** | 80 | /** |
82 | * @returns the number of available interfaces | 81 | * @returns the number of available interfaces |
83 | */ | 82 | */ |
84 | int count() const; | 83 | int count() const; |
85 | /** | 84 | /** |
86 | * @returns a pointer to the (one and only) @ref ONetwork instance. | 85 | * @returns a pointer to the (one and only) @ref ONetwork instance. |
87 | */ | 86 | */ |
88 | static ONetwork* instance(); | 87 | static ONetwork* instance(); |
89 | /** | 88 | /** |
90 | * @returns an iterator usable for iterating through all network interfaces. | 89 | * @returns an iterator usable for iterating through all network interfaces. |
91 | */ | 90 | */ |
92 | InterfaceIterator iterator() const; | 91 | InterfaceIterator iterator() const; |
93 | /** | 92 | /** |
94 | * @returns true, if the @a interface is present. | 93 | * @returns true, if the @a interface is present. |
95 | */ | 94 | */ |
96 | bool isPresent( const char* interface ) const; | 95 | bool isPresent( const char* interface ) const; |
97 | /** | 96 | /** |
98 | * @returns true, if the @a interface supports the wireless extension protocol. | 97 | * @returns true, if the @a interface supports the wireless extension protocol. |
99 | */ | 98 | */ |
100 | bool isWirelessInterface( const char* interface ) const; | 99 | bool isWirelessInterface( const char* interface ) const; |
101 | /** | 100 | /** |
102 | * @returns a pointer to the @ref ONetworkInterface object for the specified @a interface or 0, if not found. | 101 | * @returns a pointer to the @ref ONetworkInterface object for the specified @a interface or 0, if not found. |
103 | * @see ONetworkInterface | 102 | * @see ONetworkInterface |
104 | */ | 103 | */ |
105 | ONetworkInterface* interface( const QString& interface ) const; | 104 | ONetworkInterface* interface( const QString& interface ) const; |
106 | /** | 105 | /** |
107 | * @internal Rebuild the internal interface database | 106 | * @internal Rebuild the internal interface database |
108 | * @note Sometimes it might be useful to call this from client code, | 107 | * @note Sometimes it might be useful to call this from client code, |
109 | * e.g. after issuing a cardctl insert | 108 | * e.g. after issuing a cardctl insert |
110 | */ | 109 | */ |
111 | void synchronize(); | 110 | void synchronize(); |
112 | /** | 111 | /** |
113 | * @returns the wireless extension version used at compile time. | 112 | * @returns the wireless extension version used at compile time. |
114 | **/ | 113 | **/ |
115 | static short wirelessExtensionCompileVersion(); | 114 | static short wirelessExtensionCompileVersion(); |
116 | 115 | ||
117 | protected: | 116 | protected: |
118 | ONetwork(); | 117 | ONetwork(); |
119 | 118 | ||
120 | private: | 119 | private: |
121 | static ONetwork* _instance; | 120 | static ONetwork* _instance; |
122 | InterfaceMap _interfaces; | 121 | InterfaceMap _interfaces; |
123 | class Private; | 122 | class Private; |
124 | Private *d; | 123 | Private *d; |
125 | }; | 124 | }; |
126 | 125 | ||
127 | 126 | ||
128 | /*====================================================================================== | 127 | /*====================================================================================== |
129 | * ONetworkInterface | 128 | * ONetworkInterface |
130 | *======================================================================================*/ | 129 | *======================================================================================*/ |
131 | 130 | ||
132 | /** | 131 | /** |
133 | * @brief A network interface wrapper. | 132 | * @brief A network interface wrapper. |
134 | * | 133 | * |
135 | * This class provides a wrapper for a network interface. All the cumbersume details of | 134 | * This class provides a wrapper for a network interface. All the cumbersume details of |
136 | * Linux ioctls are hidden under a convenient high-level interface. | 135 | * Linux ioctls are hidden under a convenient high-level interface. |
137 | * @warning Most of the setting methods contained in this class require the appropriate | 136 | * @warning Most of the setting methods contained in this class require the appropriate |
138 | * process permissions to work. | 137 | * process permissions to work. |
139 | * | 138 | * |
140 | * @author Michael 'Mickey' Lauer <mickey@vanille.de> | 139 | * @author Michael 'Mickey' Lauer <mickey@vanille.de> |
141 | */ | 140 | */ |
142 | class ONetworkInterface : public QObject | 141 | class ONetworkInterface : public QObject |
143 | { | 142 | { |
144 | friend class OMonitoringInterface; | 143 | friend class OMonitoringInterface; |
145 | friend class OCiscoMonitoringInterface; | 144 | friend class OCiscoMonitoringInterface; |
146 | friend class OWlanNGMonitoringInterface; | 145 | friend class OWlanNGMonitoringInterface; |
147 | friend class OHostAPMonitoringInterface; | 146 | friend class OHostAPMonitoringInterface; |
148 | friend class OOrinocoMonitoringInterface; | 147 | friend class OOrinocoMonitoringInterface; |
149 | 148 | ||
150 | public: | 149 | public: |
151 | /** | 150 | /** |
152 | * Constructor. Normally you don't create @ref ONetworkInterface objects yourself, | 151 | * Constructor. Normally you don't create @ref ONetworkInterface objects yourself, |
153 | * but access them via @ref ONetwork::interface(). | 152 | * but access them via @ref ONetwork::interface(). |
154 | */ | 153 | */ |
155 | ONetworkInterface( QObject* parent, const char* name ); | 154 | ONetworkInterface( QObject* parent, const char* name ); |
156 | /** | 155 | /** |
157 | * Destructor. | 156 | * Destructor. |
158 | */ | 157 | */ |
159 | virtual ~ONetworkInterface(); | 158 | virtual ~ONetworkInterface(); |
160 | /** | 159 | /** |
161 | * Associates a @a monitoring interface with this network interface. | 160 | * Associates a @a monitoring interface with this network interface. |
162 | * @note This is currently only useful with @ref OWirelessNetworkInterface objects. | 161 | * @note This is currently only useful with @ref OWirelessNetworkInterface objects. |
163 | */ | 162 | */ |
164 | void setMonitoring( OMonitoringInterface* monitoring ); | 163 | void setMonitoring( OMonitoringInterface* monitoring ); |
165 | /** | 164 | /** |
166 | * @returns the currently associated monitoring interface or 0, if no monitoring is associated. | 165 | * @returns the currently associated monitoring interface or 0, if no monitoring is associated. |
167 | */ | 166 | */ |
168 | OMonitoringInterface* monitoring() const; | 167 | OMonitoringInterface* monitoring() const; |
169 | /** | 168 | /** |
170 | * Setting an interface to promiscuous mode enables the device to receive | 169 | * Setting an interface to promiscuous mode enables the device to receive |
171 | * all packets on the shared medium - as opposed to packets which are addressed to this interface. | 170 | * all packets on the shared medium - as opposed to packets which are addressed to this interface. |
172 | */ | 171 | */ |
173 | bool setPromiscuousMode( bool ); | 172 | bool setPromiscuousMode( bool ); |
174 | /** | 173 | /** |
175 | * @returns true if the interface is set to promiscuous mode. | 174 | * @returns true if the interface is set to promiscuous mode. |
176 | */ | 175 | */ |
177 | bool promiscuousMode() const; | 176 | bool promiscuousMode() const; |
178 | /** | 177 | /** |
179 | * Setting an interface to up enables it to receive packets. | 178 | * Setting an interface to up enables it to receive packets. |
180 | */ | 179 | */ |
181 | bool setUp( bool ); | 180 | bool setUp( bool ); |
182 | /** | 181 | /** |
183 | * @returns true if the interface is up. | 182 | * @returns true if the interface is up. |
184 | */ | 183 | */ |
185 | bool isUp() const; | 184 | bool isUp() const; |
186 | /** | 185 | /** |
187 | * @returns true if the interface is a loopback interface. | 186 | * @returns true if the interface is a loopback interface. |
188 | */ | 187 | */ |
189 | bool isLoopback() const; | 188 | bool isLoopback() const; |
190 | /** | 189 | /** |
191 | * @returns true if the interface is featuring supports the wireless extension protocol. | 190 | * @returns true if the interface is featuring supports the wireless extension protocol. |
192 | */ | 191 | */ |
193 | bool isWireless() const; | 192 | bool isWireless() const; |
194 | /** | 193 | /** |
195 | * Associate the IP address @ addr with the interface. | 194 | * Associate the IP address @ addr with the interface. |
196 | */ | 195 | */ |
197 | void setIPV4Address( const QHostAddress& addr ); | 196 | void setIPV4Address( const QHostAddress& addr ); |
198 | /** | 197 | /** |
199 | * @returns the IPv4 address associated with the interface. | 198 | * @returns the IPv4 address associated with the interface. |
200 | */ | 199 | */ |
201 | QString ipV4Address() const; //TODO: make this return an OHostAddress | 200 | OHostAddress ipV4Address() const; |
202 | /** | 201 | /** |
203 | * Associate the MAC address @a addr with the interface. | 202 | * Associate the MAC address @a addr with the interface. |
204 | * @note It can be necessary to shut down the interface prior to calling this method. | 203 | * @note It can be necessary to shut down the interface prior to calling this method. |
205 | * @note This operation needs root privileges | 204 | * @note This operation needs root privileges |
206 | * @warning This is not supported by all drivers. | 205 | * @warning This is not supported by all drivers. |
207 | */ | 206 | */ |
208 | void setMacAddress( const OMacAddress& addr ); | 207 | void setMacAddress( const OMacAddress& addr ); |
209 | /** | 208 | /** |
210 | * @returns the MAC address associated with the interface. | 209 | * @returns the MAC address associated with the interface. |
211 | */ | 210 | */ |
212 | OMacAddress macAddress() const; | 211 | OMacAddress macAddress() const; |
213 | /** | 212 | /** |
214 | * Associate the IPv4 @a netmask with the interface. | 213 | * Associate the IPv4 @a netmask with the interface. |
215 | */ | 214 | */ |
216 | void setIPV4Netmask( const QHostAddress& netmask ); | 215 | void setIPV4Netmask( const QHostAddress& netmask ); |
217 | /** | 216 | /** |
218 | * @returns the IPv4 netmask associated with the interface. | 217 | * @returns the IPv4 netmask associated with the interface. |
219 | */ | 218 | */ |
220 | QString ipV4Netmask() const; //TODO: make this return an OHostAddress | 219 | OHostAddress ipV4Netmask() const; |
221 | /** | 220 | /** |
222 | * @returns the data link type currently associated with the interface. | 221 | * @returns the data link type currently associated with the interface. |
223 | * @see #include <net/if_arp.h> for possible values. | 222 | * @see #include <net/if_arp.h> for possible values. |
224 | */ | 223 | */ |
225 | int dataLinkType() const; | 224 | int dataLinkType() const; |
226 | /** | 225 | /** |
227 | * @returns a ONetworkInterfaceDriverInfo driver information block | 226 | * @returns a ONetworkInterfaceDriverInfo driver information block |
228 | * @note This operation needs root privileges | 227 | * @note This operation needs root privileges |
229 | * @warning This is not supported by all drivers | 228 | * @warning This is not supported by all drivers |
230 | */ | 229 | */ |
231 | ONetworkInterfaceDriverInfo driverInfo() const; | 230 | ONetworkInterfaceDriverInfo driverInfo() const; |
232 | 231 | ||
233 | protected: | 232 | protected: |
234 | const int _sfd; | 233 | const int _sfd; |
235 | mutable ifreq _ifr; | 234 | mutable ifreq _ifr; |
236 | OMonitoringInterface* _mon; | 235 | OMonitoringInterface* _mon; |
237 | 236 | ||
238 | protected: | 237 | protected: |
239 | struct ifreq& ifr() const; | 238 | struct ifreq& ifr() const; |
240 | virtual void init(); | 239 | virtual void init(); |
241 | bool ioctl( int call ) const; | 240 | bool ioctl( int call ) const; |
242 | bool ioctl( int call, struct ifreq& ) const; | 241 | bool ioctl( int call, struct ifreq& ) const; |
243 | private: | 242 | private: |
244 | class Private; | 243 | class Private; |
245 | Private *d; | 244 | Private *d; |
246 | }; | 245 | }; |
247 | 246 | ||
248 | /*====================================================================================== | 247 | /*====================================================================================== |
249 | * OChannelHopper | 248 | * OChannelHopper |
250 | *======================================================================================*/ | 249 | *======================================================================================*/ |
251 | 250 | ||
252 | /** | 251 | /** |
253 | * @brief A radio frequency channel hopper. | 252 | * @brief A radio frequency channel hopper. |
254 | * | 253 | * |
255 | * This class provides a channel hopper for radio frequencies. A channel hopper frequently | 254 | * This class provides a channel hopper for radio frequencies. A channel hopper frequently |
256 | * changes the radio frequency channel of its associated @ref OWirelessNetworkInterface. | 255 | * changes the radio frequency channel of its associated @ref OWirelessNetworkInterface. |
257 | * This is necessary when in monitoring mode and scanning for other devices, because | 256 | * This is necessary when in monitoring mode and scanning for other devices, because |
258 | * the radio frequency hardware can only detect packets sent on the same frequency. | 257 | * the radio frequency hardware can only detect packets sent on the same frequency. |
259 | * | 258 | * |
260 | * @author Michael 'Mickey' Lauer <mickey@vanille.de> | 259 | * @author Michael 'Mickey' Lauer <mickey@vanille.de> |
261 | */ | 260 | */ |
262 | class OChannelHopper : public QObject | 261 | class OChannelHopper : public QObject |
263 | { | 262 | { |
264 | Q_OBJECT | 263 | Q_OBJECT |
265 | 264 | ||
266 | public: | 265 | public: |
267 | /** | 266 | /** |
268 | * Constructor. | 267 | * Constructor. |
269 | */ | 268 | */ |
270 | OChannelHopper( OWirelessNetworkInterface* ); | 269 | OChannelHopper( OWirelessNetworkInterface* ); |
271 | /** | 270 | /** |
272 | * Destructor. | 271 | * Destructor. |
273 | */ | 272 | */ |
274 | virtual ~OChannelHopper(); | 273 | virtual ~OChannelHopper(); |
275 | /** | 274 | /** |
276 | * @returns true, if the channel hopper is hopping channels | 275 | * @returns true, if the channel hopper is hopping channels |
277 | */ | 276 | */ |
278 | bool isActive() const; | 277 | bool isActive() const; |
279 | /** | 278 | /** |
280 | * @returns the last hopped channel | 279 | * @returns the last hopped channel |
281 | */ | 280 | */ |
282 | int channel() const; | 281 | int channel() const; |
283 | /** | 282 | /** |
284 | * Set the channel hopping @a interval. | 283 | * Set the channel hopping @a interval. |
285 | * An interval of 0 deactivates the channel hopper. | 284 | * An interval of 0 deactivates the channel hopper. |
286 | */ | 285 | */ |
287 | void setInterval( int interval ); | 286 | void setInterval( int interval ); |
288 | /** | 287 | /** |
289 | * @returns the channel hopping interval | 288 | * @returns the channel hopping interval |
290 | */ | 289 | */ |
291 | int interval() const; | 290 | int interval() const; |
292 | 291 | ||
293 | signals: | 292 | signals: |
294 | /** | 293 | /** |
295 | * This signal is emitted right after the channel hopper performed a hop | 294 | * This signal is emitted right after the channel hopper performed a hop |
296 | */ | 295 | */ |
297 | void hopped( int ); | 296 | void hopped( int ); |
298 | 297 | ||
299 | protected: | 298 | protected: |
300 | virtual void timerEvent( QTimerEvent* ); | 299 | virtual void timerEvent( QTimerEvent* ); |
301 | 300 | ||
302 | private: | 301 | private: |
303 | OWirelessNetworkInterface* _iface; | 302 | OWirelessNetworkInterface* _iface; |
304 | int _interval; | 303 | int _interval; |
305 | int _tid; | 304 | int _tid; |
306 | QValueList<int> _channels; | 305 | QValueList<int> _channels; |
307 | QValueList<int>::Iterator _channel; | 306 | QValueList<int>::Iterator _channel; |
308 | class Private; | 307 | class Private; |
309 | Private *d; | 308 | Private *d; |
310 | }; | 309 | }; |
311 | 310 | ||
312 | 311 | ||
313 | /*====================================================================================== | 312 | /*====================================================================================== |
314 | * OWirelessNetworkInterface | 313 | * OWirelessNetworkInterface |
315 | *======================================================================================*/ | 314 | *======================================================================================*/ |
316 | 315 | ||
317 | /** | 316 | /** |
318 | * @brief A network interface wrapper for interfaces supporting the wireless extensions protocol. | 317 | * @brief A network interface wrapper for interfaces supporting the wireless extensions protocol. |
319 | * | 318 | * |
320 | * This class provides a high-level encapsulation of the Linux wireless extension API. | 319 | * This class provides a high-level encapsulation of the Linux wireless extension API. |
321 | * | 320 | * |
322 | * @author Michael 'Mickey' Lauer <mickey@vanille.de> | 321 | * @author Michael 'Mickey' Lauer <mickey@vanille.de> |
323 | */ | 322 | */ |
324 | class OWirelessNetworkInterface : public ONetworkInterface | 323 | class OWirelessNetworkInterface : public ONetworkInterface |
325 | { | 324 | { |
326 | friend class OMonitoringInterface; | 325 | friend class OMonitoringInterface; |
327 | friend class OCiscoMonitoringInterface; | 326 | friend class OCiscoMonitoringInterface; |
328 | friend class OWlanNGMonitoringInterface; | 327 | friend class OWlanNGMonitoringInterface; |
329 | friend class OHostAPMonitoringInterface; | 328 | friend class OHostAPMonitoringInterface; |
330 | friend class OOrinocoMonitoringInterface; | 329 | friend class OOrinocoMonitoringInterface; |
331 | 330 | ||
332 | friend class OPrivateIOCTL; | 331 | friend class OPrivateIOCTL; |
333 | 332 | ||
334 | public: | 333 | public: |
335 | /** | 334 | /** |
336 | * Constructor. | 335 | * Constructor. |
337 | */ | 336 | */ |
338 | OWirelessNetworkInterface( QObject* parent, const char* name ); | 337 | OWirelessNetworkInterface( QObject* parent, const char* name ); |
339 | /** | 338 | /** |
340 | * Destructor. | 339 | * Destructor. |
341 | */ | 340 | */ |
342 | virtual ~OWirelessNetworkInterface(); | 341 | virtual ~OWirelessNetworkInterface(); |
343 | /** | 342 | /** |
344 | * Setting the @a channel of the interface changes the radio frequency (RF) | 343 | * Setting the @a channel of the interface changes the radio frequency (RF) |
345 | * of the corresponding wireless network device. | 344 | * of the corresponding wireless network device. |
346 | * @note Common channel range is within [1-14]. A value of 0 is not allowed. | 345 | * @note Common channel range is within [1-14]. A value of 0 is not allowed. |
347 | * @see channels() | 346 | * @see channels() |
348 | */ | 347 | */ |
349 | virtual void setChannel( int channel ) const; | 348 | virtual void setChannel( int channel ) const; |
350 | /** | 349 | /** |
351 | * @returns the channel index of the current radio frequency. | 350 | * @returns the channel index of the current radio frequency. |
352 | */ | 351 | */ |
353 | virtual int channel() const; | 352 | virtual int channel() const; |
354 | /** | 353 | /** |
355 | * @returns the current radio frequency (in MHz). | 354 | * @returns the current radio frequency (in MHz). |
356 | */ | 355 | */ |
357 | virtual double frequency() const; | 356 | virtual double frequency() const; |
358 | /** | 357 | /** |
359 | * @returns the number of radio frequency channels for the | 358 | * @returns the number of radio frequency channels for the |
360 | * corresponding wireless network device. | 359 | * corresponding wireless network device. |
361 | * @note European devices usually have 14 channels, while American typically feature 11 channels. | 360 | * @note European devices usually have 14 channels, while American typically feature 11 channels. |
362 | */ | 361 | */ |
363 | virtual int channels() const; | 362 | virtual int channels() const; |
364 | /** | 363 | /** |
365 | * Set the IEEE 802.11 operation @a mode. | 364 | * Set the IEEE 802.11 operation @a mode. |
366 | * Valid values are <ul><li>adhoc<li>managed<li>monitor<li>master | 365 | * Valid values are <ul><li>adhoc<li>managed<li>monitor<li>master |
367 | * @warning Not all drivers support the all modes. | 366 | * @warning Not all drivers support the all modes. |
368 | * @note You might have to change the SSID to get the operation mode change into effect. | 367 | * @note You might have to change the SSID to get the operation mode change into effect. |
369 | */ | 368 | */ |
370 | virtual void setMode( const QString& mode ); | 369 | virtual void setMode( const QString& mode ); |
371 | /** | 370 | /** |
372 | * @returns the current IEEE 802.11 operation mode. | 371 | * @returns the current IEEE 802.11 operation mode. |
373 | * Possible values are <ul><li>adhoc<li>managed<li>monitor<li>master or <li>unknown | 372 | * Possible values are <ul><li>adhoc<li>managed<li>monitor<li>master or <li>unknown |
374 | * | 373 | * |
375 | * @note: Important note concerning the 'monitor' mode: | 374 | * @note: Important note concerning the 'monitor' mode: |
376 | * Setting the monitor mode on a wireless network interface enables | 375 | * Setting the monitor mode on a wireless network interface enables |
377 | * listening to IEEE 802.11 data and management frames which normally | 376 | * listening to IEEE 802.11 data and management frames which normally |
378 | * are handled by the device firmware. This can be used to detect | 377 | * are handled by the device firmware. This can be used to detect |
379 | * other wireless network devices, e.g. Access Points or Ad-hoc stations. | 378 | * other wireless network devices, e.g. Access Points or Ad-hoc stations. |
380 | * @warning Standard wireless network drives don't support the monitor mode. | 379 | * @warning Standard wireless network drives don't support the monitor mode. |
381 | * @warning You need a patched driver for this to work. | 380 | * @warning You need a patched driver for this to work. |
382 | * @note Enabling the monitor mode is highly driver dependent and requires | 381 | * @note Enabling the monitor mode is highly driver dependent and requires |
383 | * the proper @ref OMonitoringInterface to be associated with the interface. | 382 | * the proper @ref OMonitoringInterface to be associated with the interface. |
384 | * @see OMonitoringInterface | 383 | * @see OMonitoringInterface |
385 | */ | 384 | */ |
386 | virtual QString mode() const; | 385 | virtual QString mode() const; |
387 | /** | 386 | /** |
388 | * Set the channel hopping @a interval. An @a interval of 0 disables channel hopping. | 387 | * Set the channel hopping @a interval. An @a interval of 0 disables channel hopping. |
389 | * @see OChannelHopper | 388 | * @see OChannelHopper |
390 | */ | 389 | */ |
391 | virtual void setChannelHopping( int interval = 0 ); | 390 | virtual void setChannelHopping( int interval = 0 ); |
392 | /** | 391 | /** |
393 | * @returns the channel hopping interval or 0, if channel hopping is disabled. | 392 | * @returns the channel hopping interval or 0, if channel hopping is disabled. |
394 | */ | 393 | */ |
395 | virtual int channelHopping() const; | 394 | virtual int channelHopping() const; |
396 | /** | 395 | /** |
397 | * @returns the @ref OChannelHopper of this interface or 0, if channel hopping has not been activated before | 396 | * @returns the @ref OChannelHopper of this interface or 0, if channel hopping has not been activated before |
398 | */ | 397 | */ |
399 | virtual OChannelHopper* channelHopper() const; | 398 | virtual OChannelHopper* channelHopper() const; |
400 | /** | 399 | /** |
401 | * Set the station @a nickname. | 400 | * Set the station @a nickname. |
402 | */ | 401 | */ |
403 | virtual void setNickName( const QString& nickname ); | 402 | virtual void setNickName( const QString& nickname ); |
404 | /** | 403 | /** |
405 | * @returns the current station nickname. | 404 | * @returns the current station nickname. |
406 | */ | 405 | */ |
407 | virtual QString nickName() const; | 406 | virtual QString nickName() const; |
408 | /** | 407 | /** |
409 | * Invoke the private IOCTL @a command with a @number of parameters on the network interface. | 408 | * Invoke the private IOCTL @a command with a @number of parameters on the network interface. |
410 | * @see OPrivateIOCTL | 409 | * @see OPrivateIOCTL |
411 | */ | 410 | */ |
412 | virtual void setPrivate( const QString& command, int number, ... ); | 411 | virtual void setPrivate( const QString& command, int number, ... ); |
413 | /** | 412 | /** |
414 | * @returns true if the interface is featuring the private IOCTL @command. | 413 | * @returns true if the interface is featuring the private IOCTL @command. |
415 | */ | 414 | */ |
416 | virtual bool hasPrivate( const QString& command ); | 415 | virtual bool hasPrivate( const QString& command ); |
417 | virtual void getPrivate( const QString& command ); //FIXME: Implement and document this | 416 | virtual void getPrivate( const QString& command ); //FIXME: Implement and document this |
418 | /** | 417 | /** |
419 | * @returns true if the interface is associated to an access point | 418 | * @returns true if the interface is associated to an access point |
420 | * @note: This information is only valid if the interface is in managed mode. | 419 | * @note: This information is only valid if the interface is in managed mode. |
421 | */ | 420 | */ |
422 | virtual bool isAssociated() const; | 421 | virtual bool isAssociated() const; |
423 | /** Set the @a mac associated AP address. | 422 | /** Set the @a mac associated AP address. |
424 | */ | 423 | */ |
425 | virtual void setAssociatedAP( const OMacAddress& mac ) const; | 424 | virtual void setAssociatedAP( const OMacAddress& mac ) const; |
426 | /** | 425 | /** |
427 | * @returns the MAC address of the Access Point if the device is in infrastructure mode. | 426 | * @returns the MAC address of the Access Point if the device is in infrastructure mode. |
428 | * @returns a (more or less random) cell ID address if the device is in adhoc mode. | 427 | * @returns a (more or less random) cell ID address if the device is in adhoc mode. |
429 | */ | 428 | */ |
430 | virtual OMacAddress associatedAP() const; | 429 | virtual OMacAddress associatedAP() const; |
431 | /** | 430 | /** |
432 | * Set the @a ssid (Service Set ID) string. This is used to decide | 431 | * Set the @a ssid (Service Set ID) string. This is used to decide |
433 | * which network to associate with (use "any" to let the driver decide). | 432 | * which network to associate with (use "any" to let the driver decide). |
434 | */ | 433 | */ |
435 | virtual void setSSID( const QString& ssid ); | 434 | virtual void setSSID( const QString& ssid ); |
436 | /** | 435 | /** |
437 | * @returns the current SSID (Service Set ID). | 436 | * @returns the current SSID (Service Set ID). |
438 | */ | 437 | */ |
439 | virtual QString SSID() const; | 438 | virtual QString SSID() const; |
440 | /** | 439 | /** |
441 | * Perform scanning the wireless network neighbourhood. | 440 | * Perform scanning the wireless network neighbourhood. |
442 | * @note: UNSTABLE API - UNDER CONSTRUCTION - DON'T USE! | 441 | * @note: UNSTABLE API - UNDER CONSTRUCTION - DON'T USE! |
443 | */ | 442 | */ |
444 | virtual OStationList* scanNetwork(); | 443 | virtual OStationList* scanNetwork(); |
445 | /** | 444 | /** |
446 | * @return signal strength to associated neighbour (in percent). | 445 | * @return signal strength to associated neighbour (in percent). |
447 | * In infrastructure mode, this is the signal strength of the Access Point. | 446 | * In infrastructure mode, this is the signal strength of the Access Point. |
448 | * In other modes the result is driver dependent. | 447 | * In other modes the result is driver dependent. |
449 | */ | 448 | */ |
450 | virtual int signalStrength() const; | 449 | virtual int signalStrength() const; |
451 | /** | 450 | /** |
452 | * @returns the wireless extension version used by the interface driver. | 451 | * @returns the wireless extension version used by the interface driver. |
453 | **/ | 452 | **/ |
454 | short wirelessExtensionDriverVersion() const; | 453 | short wirelessExtensionDriverVersion() const; |
455 | /** | 454 | /** |
456 | * @internal commit pending changes to the driver | 455 | * @internal commit pending changes to the driver |
457 | */ | 456 | */ |
458 | void commit() const; | 457 | void commit() const; |
459 | 458 | ||
460 | protected: | 459 | protected: |
461 | void buildInformation(); | 460 | void buildInformation(); |
462 | void buildPrivateList(); | 461 | void buildPrivateList(); |
463 | void dumpInformation() const; | 462 | void dumpInformation() const; |
464 | virtual void init(); | 463 | virtual void init(); |
465 | struct iwreq& iwr() const; | 464 | struct iwreq& iwr() const; |
466 | bool wioctl( int call ) const; | 465 | bool wioctl( int call ) const; |
467 | bool wioctl( int call, struct iwreq& ) const; | 466 | bool wioctl( int call, struct iwreq& ) const; |
468 | 467 | ||
469 | protected: | 468 | protected: |
470 | mutable struct iwreq _iwr; | 469 | mutable struct iwreq _iwr; |
471 | QMap<int,int> _channels; | 470 | QMap<int,int> _channels; |
472 | struct iw_range _range; | 471 | struct iw_range _range; |
473 | 472 | ||
474 | private: | 473 | private: |
475 | OChannelHopper* _hopper; | 474 | OChannelHopper* _hopper; |
476 | class Private; | 475 | class Private; |
477 | Private *d; | 476 | Private *d; |
478 | }; | 477 | }; |
479 | 478 | ||
480 | 479 | ||
481 | /*====================================================================================== | 480 | /*====================================================================================== |
482 | * OMonitoringInterface | 481 | * OMonitoringInterface |
483 | *======================================================================================*/ | 482 | *======================================================================================*/ |
484 | 483 | ||
485 | 484 | ||
486 | class OMonitoringInterface | 485 | class OMonitoringInterface |
487 | { | 486 | { |
488 | public: | 487 | public: |
489 | OMonitoringInterface(); | 488 | OMonitoringInterface(); |
490 | OMonitoringInterface( ONetworkInterface*, bool _prismHeader ); | 489 | OMonitoringInterface( ONetworkInterface*, bool _prismHeader ); |
491 | virtual ~OMonitoringInterface(); | 490 | virtual ~OMonitoringInterface(); |
492 | 491 | ||
493 | public: | 492 | public: |
494 | virtual void setEnabled( bool ); | 493 | virtual void setEnabled( bool ); |
495 | virtual void setChannel( int ); | 494 | virtual void setChannel( int ); |
496 | 495 | ||
497 | virtual QString name() const = 0; | 496 | virtual QString name() const = 0; |
498 | 497 | ||
499 | protected: | 498 | protected: |
500 | OWirelessNetworkInterface* _if; | 499 | OWirelessNetworkInterface* _if; |
501 | bool _prismHeader; | 500 | bool _prismHeader; |
502 | private: | 501 | private: |
503 | class Private; | 502 | class Private; |
504 | Private *d; | 503 | Private *d; |
505 | 504 | ||
506 | }; | 505 | }; |
507 | 506 | ||
508 | 507 | ||
509 | /*====================================================================================== | 508 | /*====================================================================================== |
510 | * OCiscoMonitoring | 509 | * OCiscoMonitoring |
511 | *======================================================================================*/ | 510 | *======================================================================================*/ |
512 | 511 | ||
513 | 512 | ||
514 | class OCiscoMonitoringInterface : public OMonitoringInterface | 513 | class OCiscoMonitoringInterface : public OMonitoringInterface |
515 | { | 514 | { |
516 | public: | 515 | public: |
517 | OCiscoMonitoringInterface( ONetworkInterface*, bool _prismHeader ); | 516 | OCiscoMonitoringInterface( ONetworkInterface*, bool _prismHeader ); |
518 | virtual ~OCiscoMonitoringInterface(); | 517 | virtual ~OCiscoMonitoringInterface(); |
519 | 518 | ||
520 | virtual void setEnabled( bool ); | 519 | virtual void setEnabled( bool ); |
521 | virtual QString name() const; | 520 | virtual QString name() const; |
522 | virtual void setChannel( int ); | 521 | virtual void setChannel( int ); |
523 | private: | 522 | private: |
524 | class Private; | 523 | class Private; |
525 | Private *d; | 524 | Private *d; |
526 | 525 | ||
527 | }; | 526 | }; |
528 | 527 | ||
529 | 528 | ||
530 | /*====================================================================================== | 529 | /*====================================================================================== |
531 | * OWlanNGMonitoringInterface | 530 | * OWlanNGMonitoringInterface |
532 | *======================================================================================*/ | 531 | *======================================================================================*/ |
533 | 532 | ||
534 | 533 | ||
535 | class OWlanNGMonitoringInterface : public OMonitoringInterface | 534 | class OWlanNGMonitoringInterface : public OMonitoringInterface |
536 | { | 535 | { |
537 | public: | 536 | public: |
538 | OWlanNGMonitoringInterface( ONetworkInterface*, bool _prismHeader ); | 537 | OWlanNGMonitoringInterface( ONetworkInterface*, bool _prismHeader ); |
539 | virtual ~OWlanNGMonitoringInterface(); | 538 | virtual ~OWlanNGMonitoringInterface(); |
540 | 539 | ||
541 | public: | 540 | public: |
542 | virtual void setEnabled( bool ); | 541 | virtual void setEnabled( bool ); |
543 | virtual QString name() const; | 542 | virtual QString name() const; |
544 | virtual void setChannel( int ); | 543 | virtual void setChannel( int ); |
545 | private: | 544 | private: |
546 | class Private; | 545 | class Private; |
547 | Private *d; | 546 | Private *d; |
548 | 547 | ||
549 | }; | 548 | }; |
550 | 549 | ||
551 | 550 | ||
552 | /*====================================================================================== | 551 | /*====================================================================================== |
553 | * OHostAPMonitoringInterface | 552 | * OHostAPMonitoringInterface |
554 | *======================================================================================*/ | 553 | *======================================================================================*/ |
555 | 554 | ||
556 | 555 | ||
557 | class OHostAPMonitoringInterface : public OMonitoringInterface | 556 | class OHostAPMonitoringInterface : public OMonitoringInterface |
558 | { | 557 | { |
559 | public: | 558 | public: |
560 | OHostAPMonitoringInterface( ONetworkInterface*, bool _prismHeader ); | 559 | OHostAPMonitoringInterface( ONetworkInterface*, bool _prismHeader ); |
561 | virtual ~OHostAPMonitoringInterface(); | 560 | virtual ~OHostAPMonitoringInterface(); |
562 | 561 | ||
563 | public: | 562 | public: |
564 | virtual void setEnabled( bool ); | 563 | virtual void setEnabled( bool ); |
565 | virtual QString name() const; | 564 | virtual QString name() const; |
566 | 565 | ||
567 | private: | 566 | private: |
568 | class Private; | 567 | class Private; |
569 | Private *d; | 568 | Private *d; |
570 | }; | 569 | }; |
571 | 570 | ||
572 | 571 | ||
573 | /*====================================================================================== | 572 | /*====================================================================================== |
574 | * OOrinocoMonitoringInterface | 573 | * OOrinocoMonitoringInterface |
575 | *======================================================================================*/ | 574 | *======================================================================================*/ |
576 | 575 | ||
577 | 576 | ||
578 | class OOrinocoMonitoringInterface : public OMonitoringInterface | 577 | class OOrinocoMonitoringInterface : public OMonitoringInterface |
579 | { | 578 | { |
580 | public: | 579 | public: |
581 | OOrinocoMonitoringInterface( ONetworkInterface*, bool _prismHeader ); | 580 | OOrinocoMonitoringInterface( ONetworkInterface*, bool _prismHeader ); |
582 | virtual ~OOrinocoMonitoringInterface(); | 581 | virtual ~OOrinocoMonitoringInterface(); |
583 | 582 | ||
584 | public: | 583 | public: |
585 | virtual void setChannel( int ); | 584 | virtual void setChannel( int ); |
586 | virtual void setEnabled( bool ); | 585 | virtual void setEnabled( bool ); |
587 | virtual QString name() const; | 586 | virtual QString name() const; |
588 | 587 | ||
589 | private: | 588 | private: |
590 | class Private; | 589 | class Private; |
591 | Private *d; | 590 | Private *d; |
592 | }; | 591 | }; |
593 | 592 | ||
594 | } | 593 | } |
595 | } | 594 | } |
596 | 595 | ||
597 | #endif // ONETWORK_H | 596 | #endif // ONETWORK_H |
598 | 597 | ||
diff --git a/noncore/applets/networkapplet/networkapplet.cpp b/noncore/applets/networkapplet/networkapplet.cpp index 534a8d0..bd6ca66 100644 --- a/noncore/applets/networkapplet/networkapplet.cpp +++ b/noncore/applets/networkapplet/networkapplet.cpp | |||
@@ -1,255 +1,255 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | =. (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | 4 | =. (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | 28 | ||
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include "networkapplet.h" | 31 | #include "networkapplet.h" |
32 | 32 | ||
33 | /* OPIE */ | 33 | /* OPIE */ |
34 | #include <opie2/odebug.h> | 34 | #include <opie2/odebug.h> |
35 | #include <opie2/onetwork.h> | 35 | #include <opie2/onetwork.h> |
36 | #include <opie2/otaskbarapplet.h> | 36 | #include <opie2/otaskbarapplet.h> |
37 | #include <qpe/applnk.h> | 37 | #include <qpe/applnk.h> |
38 | #include <qpe/resource.h> | 38 | #include <qpe/resource.h> |
39 | using namespace Opie::Core; | 39 | using namespace Opie::Core; |
40 | using namespace Opie::Ui; | 40 | using namespace Opie::Ui; |
41 | using namespace Opie::Net; | 41 | using namespace Opie::Net; |
42 | 42 | ||
43 | /* QT */ | 43 | /* QT */ |
44 | #include <qpainter.h> | 44 | #include <qpainter.h> |
45 | #include <qlabel.h> | 45 | #include <qlabel.h> |
46 | #include <qlayout.h> | 46 | #include <qlayout.h> |
47 | #include <qobjectlist.h> | 47 | #include <qobjectlist.h> |
48 | 48 | ||
49 | /* STD */ | 49 | /* STD */ |
50 | #include <assert.h> | 50 | #include <assert.h> |
51 | 51 | ||
52 | IfaceUpDownButton::IfaceUpDownButton( QWidget* parent, const char* name ) | 52 | IfaceUpDownButton::IfaceUpDownButton( QWidget* parent, const char* name ) |
53 | :QToolButton( parent, name ) | 53 | :QToolButton( parent, name ) |
54 | { | 54 | { |
55 | _iface = ONetwork::instance()->interface( name ); | 55 | _iface = ONetwork::instance()->interface( name ); |
56 | assert( _iface ); | 56 | assert( _iface ); |
57 | setToggleButton( true ); | 57 | setToggleButton( true ); |
58 | //setAutoRaise( true ); | 58 | //setAutoRaise( true ); |
59 | setOnIconSet( QIconSet( Resource::loadPixmap( "up" ) ) ); | 59 | setOnIconSet( QIconSet( Resource::loadPixmap( "up" ) ) ); |
60 | setOffIconSet( QIconSet( Resource::loadPixmap( "down" ) ) ); | 60 | setOffIconSet( QIconSet( Resource::loadPixmap( "down" ) ) ); |
61 | setOn( _iface->isUp() ); | 61 | setOn( _iface->isUp() ); |
62 | //setFixedWidth( 16 ); | 62 | //setFixedWidth( 16 ); |
63 | connect( this, SIGNAL( clicked() ), this, SLOT( clicked() ) ); | 63 | connect( this, SIGNAL( clicked() ), this, SLOT( clicked() ) ); |
64 | } | 64 | } |
65 | 65 | ||
66 | 66 | ||
67 | IfaceUpDownButton::~IfaceUpDownButton() | 67 | IfaceUpDownButton::~IfaceUpDownButton() |
68 | { | 68 | { |
69 | } | 69 | } |
70 | 70 | ||
71 | 71 | ||
72 | void IfaceUpDownButton::clicked() | 72 | void IfaceUpDownButton::clicked() |
73 | { | 73 | { |
74 | _iface->setUp( isOn() ); | 74 | _iface->setUp( isOn() ); |
75 | setOn( _iface->isUp() ); // it might not have worked... | 75 | setOn( _iface->isUp() ); // it might not have worked... |
76 | repaint(); | 76 | repaint(); |
77 | } | 77 | } |
78 | 78 | ||
79 | 79 | ||
80 | IfaceIPAddress::IfaceIPAddress( QWidget* parent, const char* name ) | 80 | IfaceIPAddress::IfaceIPAddress( QWidget* parent, const char* name ) |
81 | :QLineEdit( parent, name ) | 81 | :QLineEdit( parent, name ) |
82 | { | 82 | { |
83 | setFont( QFont( "fixed" ) ); | 83 | setFont( QFont( "fixed" ) ); |
84 | _iface = ONetwork::instance()->interface( name ); | 84 | _iface = ONetwork::instance()->interface( name ); |
85 | setFixedWidth( 105 ); | 85 | setFixedWidth( 105 ); |
86 | setText( _iface->ipV4Address() ); | 86 | setText( _iface->ipV4Address().toString() ); |
87 | connect( this, SIGNAL( returnPressed() ), this, SLOT( returnPressed() ) ); | 87 | connect( this, SIGNAL( returnPressed() ), this, SLOT( returnPressed() ) ); |
88 | } | 88 | } |
89 | 89 | ||
90 | 90 | ||
91 | IfaceIPAddress::~IfaceIPAddress() | 91 | IfaceIPAddress::~IfaceIPAddress() |
92 | { | 92 | { |
93 | } | 93 | } |
94 | 94 | ||
95 | 95 | ||
96 | void IfaceIPAddress::returnPressed() | 96 | void IfaceIPAddress::returnPressed() |
97 | { | 97 | { |
98 | QHostAddress a; | 98 | QHostAddress a; |
99 | a.setAddress( text() ); | 99 | a.setAddress( text() ); |
100 | QHostAddress mask; | 100 | QHostAddress mask; |
101 | mask.setAddress( _iface->ipV4Netmask() ); // setIPV4Address destroys the netmask... | 101 | mask.setAddress( _iface->ipV4Netmask().toString() ); // setIPV4Address destroys the netmask... |
102 | _iface->setIPV4Address( a ); | 102 | _iface->setIPV4Address( a ); |
103 | _iface->setIPV4Netmask( mask ); // recover the old netmask | 103 | _iface->setIPV4Netmask( mask ); // recover the old netmask |
104 | setText( _iface->ipV4Address() ); | 104 | setText( _iface->ipV4Address().toString() ); |
105 | repaint(); | 105 | repaint(); |
106 | } | 106 | } |
107 | 107 | ||
108 | 108 | ||
109 | NetworkAppletControl::NetworkAppletControl( OTaskbarApplet* parent, const char* name ) | 109 | NetworkAppletControl::NetworkAppletControl( OTaskbarApplet* parent, const char* name ) |
110 | :QFrame( parent, name, WStyle_StaysOnTop | WType_Popup ), l(0) | 110 | :QFrame( parent, name, WStyle_StaysOnTop | WType_Popup ), l(0) |
111 | { | 111 | { |
112 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); | 112 | setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); |
113 | l = new QVBoxLayout( this, 4, 2 ); | 113 | l = new QVBoxLayout( this, 4, 2 ); |
114 | } | 114 | } |
115 | 115 | ||
116 | 116 | ||
117 | void NetworkAppletControl::build() | 117 | void NetworkAppletControl::build() |
118 | { | 118 | { |
119 | ONetwork::InterfaceIterator it = ONetwork::instance()->iterator(); | 119 | ONetwork::InterfaceIterator it = ONetwork::instance()->iterator(); |
120 | while ( it.current() ) | 120 | while ( it.current() ) |
121 | { | 121 | { |
122 | QHBoxLayout* h = new QHBoxLayout( l ); | 122 | QHBoxLayout* h = new QHBoxLayout( l ); |
123 | QLabel* symbol = new QLabel( this ); | 123 | QLabel* symbol = new QLabel( this ); |
124 | symbol->setPixmap( Resource::loadPixmap( guessDevice( it.current() ) ) ); | 124 | symbol->setPixmap( Resource::loadPixmap( guessDevice( it.current() ) ) ); |
125 | h->addWidget( symbol ); | 125 | h->addWidget( symbol ); |
126 | symbol->show(); | 126 | symbol->show(); |
127 | 127 | ||
128 | QLabel* name = new QLabel( it.current()->name(), this ); | 128 | QLabel* name = new QLabel( it.current()->name(), this ); |
129 | name->setFixedWidth( 35 ); | 129 | name->setFixedWidth( 35 ); |
130 | h->addWidget( name ); | 130 | h->addWidget( name ); |
131 | name->show(); | 131 | name->show(); |
132 | 132 | ||
133 | IfaceIPAddress* ip = new IfaceIPAddress( this, it.current()->name() ); | 133 | IfaceIPAddress* ip = new IfaceIPAddress( this, it.current()->name() ); |
134 | h->addWidget( ip ); | 134 | h->addWidget( ip ); |
135 | ip->show(); | 135 | ip->show(); |
136 | 136 | ||
137 | IfaceUpDownButton* tb = new IfaceUpDownButton( this, it.current()->name() ); | 137 | IfaceUpDownButton* tb = new IfaceUpDownButton( this, it.current()->name() ); |
138 | tb->show(); | 138 | tb->show(); |
139 | 139 | ||
140 | h->addWidget( tb ); | 140 | h->addWidget( tb ); |
141 | 141 | ||
142 | ++it; | 142 | ++it; |
143 | } | 143 | } |
144 | } | 144 | } |
145 | 145 | ||
146 | 146 | ||
147 | NetworkAppletControl::~NetworkAppletControl() | 147 | NetworkAppletControl::~NetworkAppletControl() |
148 | { | 148 | { |
149 | } | 149 | } |
150 | 150 | ||
151 | 151 | ||
152 | QString NetworkAppletControl::guessDevice( ONetworkInterface* iface ) | 152 | QString NetworkAppletControl::guessDevice( ONetworkInterface* iface ) |
153 | { | 153 | { |
154 | if ( iface->isWireless() ) | 154 | if ( iface->isWireless() ) |
155 | return "networksettings/wlan"; | 155 | return "networksettings/wlan"; |
156 | if ( iface->isLoopback() ) | 156 | if ( iface->isLoopback() ) |
157 | return "networksettings/lo"; | 157 | return "networksettings/lo"; |
158 | if ( QString( iface->name() ).contains( "usb" ) ) | 158 | if ( QString( iface->name() ).contains( "usb" ) ) |
159 | return "networksettings/usb"; | 159 | return "networksettings/usb"; |
160 | if ( QString( iface->name() ).contains( "ir" ) ) | 160 | if ( QString( iface->name() ).contains( "ir" ) ) |
161 | return "networksettings/irda"; | 161 | return "networksettings/irda"; |
162 | 162 | ||
163 | //TODO: Insert neat symbol and check for tunnel devices | 163 | //TODO: Insert neat symbol and check for tunnel devices |
164 | 164 | ||
165 | return "networksettings/lan"; | 165 | return "networksettings/lan"; |
166 | 166 | ||
167 | } | 167 | } |
168 | 168 | ||
169 | 169 | ||
170 | void NetworkAppletControl::showEvent( QShowEvent* e ) | 170 | void NetworkAppletControl::showEvent( QShowEvent* e ) |
171 | { | 171 | { |
172 | odebug << "showEvent" << oendl; | 172 | odebug << "showEvent" << oendl; |
173 | build(); | 173 | build(); |
174 | QWidget::showEvent( e ); | 174 | QWidget::showEvent( e ); |
175 | } | 175 | } |
176 | 176 | ||
177 | 177 | ||
178 | void NetworkAppletControl::hideEvent( QHideEvent* e ) | 178 | void NetworkAppletControl::hideEvent( QHideEvent* e ) |
179 | { | 179 | { |
180 | odebug << "hideEvent" << oendl; | 180 | odebug << "hideEvent" << oendl; |
181 | QWidget::hideEvent( e ); | 181 | QWidget::hideEvent( e ); |
182 | 182 | ||
183 | delete l; | 183 | delete l; |
184 | 184 | ||
185 | // delete all child widgets from this frame | 185 | // delete all child widgets from this frame |
186 | QObjectList* list = const_cast<QObjectList*>( children() ); | 186 | QObjectList* list = const_cast<QObjectList*>( children() ); |
187 | QObjectListIt it(*list); | 187 | QObjectListIt it(*list); |
188 | QObject* obj; | 188 | QObject* obj; |
189 | while ( (obj=it.current()) ) | 189 | while ( (obj=it.current()) ) |
190 | { | 190 | { |
191 | ++it; | 191 | ++it; |
192 | delete obj; | 192 | delete obj; |
193 | } | 193 | } |
194 | 194 | ||
195 | list = const_cast<QObjectList*>( children() ); | 195 | list = const_cast<QObjectList*>( children() ); |
196 | if ( list ) | 196 | if ( list ) |
197 | owarn << "D'oh! We still have " << list->count() << " children..." << oendl; | 197 | owarn << "D'oh! We still have " << list->count() << " children..." << oendl; |
198 | 198 | ||
199 | // renew layout | 199 | // renew layout |
200 | l = new QVBoxLayout( this, 4, 2 ); | 200 | l = new QVBoxLayout( this, 4, 2 ); |
201 | resize( 0, 0 ); | 201 | resize( 0, 0 ); |
202 | } | 202 | } |
203 | 203 | ||
204 | 204 | ||
205 | QSize NetworkAppletControl::sizeHint() const | 205 | QSize NetworkAppletControl::sizeHint() const |
206 | { | 206 | { |
207 | ONetwork::instance()->synchronize(); // rebuild interface database | 207 | ONetwork::instance()->synchronize(); // rebuild interface database |
208 | odebug << "sizeHint (#ifaces=" << ONetwork::instance()->count() << ")" << oendl; | 208 | odebug << "sizeHint (#ifaces=" << ONetwork::instance()->count() << ")" << oendl; |
209 | return QSize( 14+35+105+14 + 8, ONetwork::instance()->count() * 26 ); | 209 | return QSize( 14+35+105+14 + 8, ONetwork::instance()->count() * 26 ); |
210 | } | 210 | } |
211 | 211 | ||
212 | 212 | ||
213 | NetworkApplet::NetworkApplet( QWidget *parent, const char *name ) | 213 | NetworkApplet::NetworkApplet( QWidget *parent, const char *name ) |
214 | :OTaskbarApplet( parent, name ) | 214 | :OTaskbarApplet( parent, name ) |
215 | { | 215 | { |
216 | setFixedHeight( AppLnk::smallIconSize() ); | 216 | setFixedHeight( AppLnk::smallIconSize() ); |
217 | setFixedWidth( AppLnk::smallIconSize() ); | 217 | setFixedWidth( AppLnk::smallIconSize() ); |
218 | _pixmap.convertFromImage( Resource::loadImage( "networkapplet/network" ).smoothScale( height(), width() ) ); | 218 | _pixmap.convertFromImage( Resource::loadImage( "networkapplet/network" ).smoothScale( height(), width() ) ); |
219 | _control = new NetworkAppletControl( this, "control" ); | 219 | _control = new NetworkAppletControl( this, "control" ); |
220 | } | 220 | } |
221 | 221 | ||
222 | 222 | ||
223 | NetworkApplet::~NetworkApplet() | 223 | NetworkApplet::~NetworkApplet() |
224 | { | 224 | { |
225 | } | 225 | } |
226 | 226 | ||
227 | 227 | ||
228 | int NetworkApplet::position() | 228 | int NetworkApplet::position() |
229 | { | 229 | { |
230 | return 4; | 230 | return 4; |
231 | } | 231 | } |
232 | 232 | ||
233 | 233 | ||
234 | void NetworkApplet::paintEvent( QPaintEvent* ) | 234 | void NetworkApplet::paintEvent( QPaintEvent* ) |
235 | { | 235 | { |
236 | QPainter p(this); | 236 | QPainter p(this); |
237 | p.drawPixmap(0, 2, _pixmap ); | 237 | p.drawPixmap(0, 2, _pixmap ); |
238 | } | 238 | } |
239 | 239 | ||
240 | 240 | ||
241 | void NetworkApplet::mousePressEvent( QMouseEvent* ) | 241 | void NetworkApplet::mousePressEvent( QMouseEvent* ) |
242 | { | 242 | { |
243 | if ( !_control->isVisible() ) | 243 | if ( !_control->isVisible() ) |
244 | { | 244 | { |
245 | popup( _control ); | 245 | popup( _control ); |
246 | } | 246 | } |
247 | else | 247 | else |
248 | { | 248 | { |
249 | _control->hide(); | 249 | _control->hide(); |
250 | } | 250 | } |
251 | } | 251 | } |
252 | 252 | ||
253 | EXPORT_OPIE_APPLET_v1( NetworkApplet ) | 253 | EXPORT_OPIE_APPLET_v1( NetworkApplet ) |
254 | 254 | ||
255 | 255 | ||
diff --git a/noncore/net/opiestumbler/opiestumbler.cpp b/noncore/net/opiestumbler/opiestumbler.cpp index 8dedd67..f231fca 100644 --- a/noncore/net/opiestumbler/opiestumbler.cpp +++ b/noncore/net/opiestumbler/opiestumbler.cpp | |||
@@ -1,348 +1,348 @@ | |||
1 | #include <cstdlib> | 1 | #include <cstdlib> |
2 | 2 | ||
3 | #include <qmenubar.h> | 3 | #include <qmenubar.h> |
4 | #include <qaction.h> | 4 | #include <qaction.h> |
5 | #include <qlistview.h> | 5 | #include <qlistview.h> |
6 | #include <qstring.h> | 6 | #include <qstring.h> |
7 | //#include <qapplication.h> | 7 | //#include <qapplication.h> |
8 | #include <qdatetime.h> | 8 | #include <qdatetime.h> |
9 | #include <qpopupmenu.h> | 9 | #include <qpopupmenu.h> |
10 | #include <qstatusbar.h> | 10 | #include <qstatusbar.h> |
11 | #include <qlayout.h> | 11 | #include <qlayout.h> |
12 | #include <qwhatsthis.h> | 12 | #include <qwhatsthis.h> |
13 | #include <qtimer.h> | 13 | #include <qtimer.h> |
14 | 14 | ||
15 | #include <qpe/resource.h> | 15 | #include <qpe/resource.h> |
16 | #include <qpe/config.h> | 16 | #include <qpe/config.h> |
17 | //#include <qpe/global.h> | 17 | //#include <qpe/global.h> |
18 | #include <qpe/qcopenvelope_qws.h> | 18 | #include <qpe/qcopenvelope_qws.h> |
19 | #include <qpe/qpeapplication.h> | 19 | #include <qpe/qpeapplication.h> |
20 | 20 | ||
21 | #include <opie2/odebug.h> | 21 | #include <opie2/odebug.h> |
22 | #include <opie2/ostation.h> | 22 | #include <opie2/ostation.h> |
23 | #include <opie2/omanufacturerdb.h> | 23 | #include <opie2/omanufacturerdb.h> |
24 | #include <opie2/onetwork.h> | 24 | #include <opie2/onetwork.h> |
25 | #include <opie2/oprocess.h> | 25 | #include <opie2/oprocess.h> |
26 | 26 | ||
27 | #include "stumbler.h" | 27 | #include "stumbler.h" |
28 | #include "opiestumbler.h" | 28 | #include "opiestumbler.h" |
29 | #include "stumblersettings.h" | 29 | #include "stumblersettings.h" |
30 | #include "stationviewitem.h" | 30 | #include "stationviewitem.h" |
31 | #include "stumblerstation.h" | 31 | #include "stumblerstation.h" |
32 | #include "stationinfo.h" | 32 | #include "stationinfo.h" |
33 | 33 | ||
34 | 34 | ||
35 | using Opie::Net::OWirelessNetworkInterface; | 35 | using Opie::Net::OWirelessNetworkInterface; |
36 | using Opie::Net::ONetwork; | 36 | using Opie::Net::ONetwork; |
37 | 37 | ||
38 | 38 | ||
39 | QString OpieStumbler::appCaption() { | 39 | QString OpieStumbler::appCaption() { |
40 | return QObject::tr("OpieStumbler"); | 40 | return QObject::tr("OpieStumbler"); |
41 | } | 41 | } |
42 | 42 | ||
43 | OpieStumbler::OpieStumbler(QWidget *parent, const char *name, WFlags) | 43 | OpieStumbler::OpieStumbler(QWidget *parent, const char *name, WFlags) |
44 | :QMainWindow(parent, name, WStyle_ContextHelp), | 44 | :QMainWindow(parent, name, WStyle_ContextHelp), |
45 | m_listCurrent(new QListView(this)), m_listHistory(new QListView(this)), | 45 | m_listCurrent(new QListView(this)), m_listHistory(new QListView(this)), |
46 | m_stationsCurrent(new QList<Opie::Net::OStation>), | 46 | m_stationsCurrent(new QList<Opie::Net::OStation>), |
47 | m_popupCurrent(new QPopupMenu(this)), | 47 | m_popupCurrent(new QPopupMenu(this)), |
48 | m_popupHistory(new QPopupMenu(this)), | 48 | m_popupHistory(new QPopupMenu(this)), |
49 | m_db(NULL), m_proc(NULL) | 49 | m_db(NULL), m_proc(NULL) |
50 | { | 50 | { |
51 | 51 | ||
52 | if ( QCopChannel::isRegistered("QPE/OpieStumbler") ) { | 52 | if ( QCopChannel::isRegistered("QPE/OpieStumbler") ) { |
53 | QCopEnvelope e("QPE/OpieStumbler", "show()"); | 53 | QCopEnvelope e("QPE/OpieStumbler", "show()"); |
54 | exit(EXIT_SUCCESS); | 54 | exit(EXIT_SUCCESS); |
55 | } | 55 | } |
56 | 56 | ||
57 | QGridLayout *grid = new QGridLayout( this, 1, 1, 3, 0, "grid"); | 57 | QGridLayout *grid = new QGridLayout( this, 1, 1, 3, 0, "grid"); |
58 | QVBoxLayout *lay = new QVBoxLayout( NULL, 0, 5, "lay" ); | 58 | QVBoxLayout *lay = new QVBoxLayout( NULL, 0, 5, "lay" ); |
59 | QSpacerItem *spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Fixed ); | 59 | QSpacerItem *spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Fixed ); |
60 | lay->addItem(spacer); | 60 | lay->addItem(spacer); |
61 | lay->addWidget(m_listCurrent); | 61 | lay->addWidget(m_listCurrent); |
62 | lay->addWidget(m_listHistory); | 62 | lay->addWidget(m_listHistory); |
63 | grid->addLayout(lay, 0, 0); | 63 | grid->addLayout(lay, 0, 0); |
64 | 64 | ||
65 | m_stationsCurrent->setAutoDelete(TRUE); | 65 | m_stationsCurrent->setAutoDelete(TRUE); |
66 | 66 | ||
67 | m_channel = new QCopChannel( "QPE/OpieStumbler", this ); | 67 | m_channel = new QCopChannel( "QPE/OpieStumbler", this ); |
68 | connect(m_channel, SIGNAL(received(const QCString &, const QByteArray &)), | 68 | connect(m_channel, SIGNAL(received(const QCString &, const QByteArray &)), |
69 | this, SLOT(slotMessageReceived( const QCString &, const QByteArray &)) ); | 69 | this, SLOT(slotMessageReceived( const QCString &, const QByteArray &)) ); |
70 | 70 | ||
71 | //setCaption(appCaption()); | 71 | //setCaption(appCaption()); |
72 | //setCentralWidget(grid); | 72 | //setCentralWidget(grid); |
73 | setToolBarsMovable(FALSE); | 73 | setToolBarsMovable(FALSE); |
74 | 74 | ||
75 | 75 | ||
76 | QPopupMenu *fileMenu = new QPopupMenu(this); | 76 | QPopupMenu *fileMenu = new QPopupMenu(this); |
77 | QPopupMenu *configMenu = new QPopupMenu(this); | 77 | QPopupMenu *configMenu = new QPopupMenu(this); |
78 | QPopupMenu *scanMenu = new QPopupMenu(this); | 78 | QPopupMenu *scanMenu = new QPopupMenu(this); |
79 | 79 | ||
80 | fileMenu->insertItem( tr("Exit"), this, SLOT(close()) ); | 80 | fileMenu->insertItem( tr("Exit"), this, SLOT(close()) ); |
81 | configMenu->insertItem( tr("Configure"), this, SLOT(slotConfigure()) ); | 81 | configMenu->insertItem( tr("Configure"), this, SLOT(slotConfigure()) ); |
82 | scanMenu->insertItem( tr("Start"), this, SLOT(slotStartScanning()) ); | 82 | scanMenu->insertItem( tr("Start"), this, SLOT(slotStartScanning()) ); |
83 | scanMenu->insertItem( tr("Stop"), this, SLOT(slotStopScanning()) ); | 83 | scanMenu->insertItem( tr("Stop"), this, SLOT(slotStopScanning()) ); |
84 | 84 | ||
85 | m_popupCurrent->insertItem( tr("Show details"), this, SLOT(slotShowDetails()) ); | 85 | m_popupCurrent->insertItem( tr("Show details"), this, SLOT(slotShowDetails()) ); |
86 | m_popupCurrent->insertItem( tr("Join Network"), this, SLOT(slotJoinNetwork()) ); | 86 | m_popupCurrent->insertItem( tr("Join Network"), this, SLOT(slotJoinNetwork()) ); |
87 | 87 | ||
88 | menuBar()->insertItem(tr("File"), fileMenu); | 88 | menuBar()->insertItem(tr("File"), fileMenu); |
89 | menuBar()->insertItem(tr("Settings"), configMenu); | 89 | menuBar()->insertItem(tr("Settings"), configMenu); |
90 | menuBar()->insertItem(tr("Scanning"), scanMenu); | 90 | menuBar()->insertItem(tr("Scanning"), scanMenu); |
91 | 91 | ||
92 | QPEApplication::setStylusOperation(m_listCurrent->viewport(), QPEApplication::RightOnHold); | 92 | QPEApplication::setStylusOperation(m_listCurrent->viewport(), QPEApplication::RightOnHold); |
93 | QPEApplication::setStylusOperation(m_listHistory->viewport(), QPEApplication::RightOnHold); | 93 | QPEApplication::setStylusOperation(m_listHistory->viewport(), QPEApplication::RightOnHold); |
94 | 94 | ||
95 | m_listCurrent->addColumn(tr("SSID")); | 95 | m_listCurrent->addColumn(tr("SSID")); |
96 | m_listCurrent->addColumn(tr("Chan")); | 96 | m_listCurrent->addColumn(tr("Chan")); |
97 | m_listCurrent->addColumn(tr("Signal")); | 97 | m_listCurrent->addColumn(tr("Signal")); |
98 | m_listCurrent->addColumn(tr("Enc")); | 98 | m_listCurrent->addColumn(tr("Enc")); |
99 | m_listCurrent->setSelectionMode( QListView::Extended ); | 99 | m_listCurrent->setSelectionMode( QListView::Extended ); |
100 | 100 | ||
101 | m_listHistory->addColumn(tr("SSID")); | 101 | m_listHistory->addColumn(tr("SSID")); |
102 | m_listHistory->addColumn(tr("Chan")); | 102 | m_listHistory->addColumn(tr("Chan")); |
103 | m_listHistory->addColumn(tr("Max Sig")); | 103 | m_listHistory->addColumn(tr("Max Sig")); |
104 | m_listHistory->addColumn(tr("Enc")); | 104 | m_listHistory->addColumn(tr("Enc")); |
105 | m_listHistory->addColumn(tr("Vendor")); | 105 | m_listHistory->addColumn(tr("Vendor")); |
106 | 106 | ||
107 | connect(m_listCurrent, SIGNAL(mouseButtonPressed (int, QListViewItem*, const QPoint&, int)), | 107 | connect(m_listCurrent, SIGNAL(mouseButtonPressed (int, QListViewItem*, const QPoint&, int)), |
108 | this, SLOT(slotCurrentMousePressed (int, QListViewItem*, const QPoint&, int))); | 108 | this, SLOT(slotCurrentMousePressed (int, QListViewItem*, const QPoint&, int))); |
109 | 109 | ||
110 | connect(m_listHistory, SIGNAL(mouseButtonPressed (int, QListViewItem*, const QPoint&, int)), | 110 | connect(m_listHistory, SIGNAL(mouseButtonPressed (int, QListViewItem*, const QPoint&, int)), |
111 | this, SLOT(slotHistoryMousePressed (int, QListViewItem*, const QPoint&, int))); | 111 | this, SLOT(slotHistoryMousePressed (int, QListViewItem*, const QPoint&, int))); |
112 | 112 | ||
113 | for(int i = CURCHAN; i <= CURENC; ++i) { | 113 | for(int i = CURCHAN; i <= CURENC; ++i) { |
114 | m_listCurrent->setColumnAlignment( i, Qt::AlignHCenter ); | 114 | m_listCurrent->setColumnAlignment( i, Qt::AlignHCenter ); |
115 | m_listHistory->setColumnAlignment( i, Qt::AlignHCenter ); | 115 | m_listHistory->setColumnAlignment( i, Qt::AlignHCenter ); |
116 | } | 116 | } |
117 | 117 | ||
118 | loadConfig(); | 118 | loadConfig(); |
119 | m_stumbler = new Stumbler(m_interface, this); | 119 | m_stumbler = new Stumbler(m_interface, this); |
120 | connect(m_stumbler, SIGNAL(newdata()), this, SLOT(slotUpdateStations())); | 120 | connect(m_stumbler, SIGNAL(newdata()), this, SLOT(slotUpdateStations())); |
121 | 121 | ||
122 | QTimer::singleShot(1000, this, SLOT(slotLoadManufacturers()) ); | 122 | QTimer::singleShot(1000, this, SLOT(slotLoadManufacturers()) ); |
123 | 123 | ||
124 | slotStartScanning(); | 124 | slotStartScanning(); |
125 | } | 125 | } |
126 | 126 | ||
127 | void OpieStumbler::slotConfigure() | 127 | void OpieStumbler::slotConfigure() |
128 | { | 128 | { |
129 | StumblerSettings settings(this, "Settings", TRUE); | 129 | StumblerSettings settings(this, "Settings", TRUE); |
130 | if (settings.exec() == QDialog::Accepted) | 130 | if (settings.exec() == QDialog::Accepted) |
131 | loadConfig(); | 131 | loadConfig(); |
132 | } | 132 | } |
133 | 133 | ||
134 | void OpieStumbler::loadConfig() | 134 | void OpieStumbler::loadConfig() |
135 | { | 135 | { |
136 | Config cfg("OpieStumbler", Config::User); | 136 | Config cfg("OpieStumbler", Config::User); |
137 | cfg.setGroup("General"); | 137 | cfg.setGroup("General"); |
138 | m_interface = cfg.readEntry("interface", "wlan0"); | 138 | m_interface = cfg.readEntry("interface", "wlan0"); |
139 | } | 139 | } |
140 | 140 | ||
141 | void OpieStumbler::slotStartScanning() | 141 | void OpieStumbler::slotStartScanning() |
142 | { | 142 | { |
143 | setCaption(appCaption() + " (" + tr("Scanning") + ")"); | 143 | setCaption(appCaption() + " (" + tr("Scanning") + ")"); |
144 | m_stumbler->start(); | 144 | m_stumbler->start(); |
145 | } | 145 | } |
146 | 146 | ||
147 | void OpieStumbler::slotStopScanning() | 147 | void OpieStumbler::slotStopScanning() |
148 | { | 148 | { |
149 | setCaption(appCaption()); | 149 | setCaption(appCaption()); |
150 | m_stumbler->stop(); | 150 | m_stumbler->stop(); |
151 | } | 151 | } |
152 | 152 | ||
153 | void OpieStumbler::slotUpdateStations() | 153 | void OpieStumbler::slotUpdateStations() |
154 | { | 154 | { |
155 | m_stationsCurrent->clear(); | 155 | m_stationsCurrent->clear(); |
156 | 156 | ||
157 | m_stationsCurrent = m_stumbler->stations(); | 157 | m_stationsCurrent = m_stumbler->stations(); |
158 | if (m_stationsCurrent) { | 158 | if (m_stationsCurrent) { |
159 | QListIterator<Opie::Net::OStation> it(*m_stationsCurrent); | 159 | QListIterator<Opie::Net::OStation> it(*m_stationsCurrent); |
160 | for(; it.current(); ++it) { | 160 | for(; it.current(); ++it) { |
161 | Opie::Net::OStation *station = it.current(); | 161 | Opie::Net::OStation *station = it.current(); |
162 | QListIterator<StumblerStation> itr(m_stationsHistory); | 162 | QListIterator<StumblerStation> itr(m_stationsHistory); |
163 | for( ; itr.current(); ++itr) { | 163 | for( ; itr.current(); ++itr) { |
164 | if (itr.current()->st->macAddress.toString() == station->macAddress.toString()) { | 164 | if (itr.current()->st->macAddress.toString() == station->macAddress.toString()) { |
165 | break; | 165 | break; |
166 | } | 166 | } |
167 | } | 167 | } |
168 | if (!itr.current()) { | 168 | if (!itr.current()) { |
169 | //We need to copy the date because m_statiosCurrent has autodelete enabled | 169 | //We need to copy the date because m_statiosCurrent has autodelete enabled |
170 | m_stationsHistory.append(new StumblerStation(new Opie::Net::OStation, QDateTime::currentDateTime())); | 170 | m_stationsHistory.append(new StumblerStation(new Opie::Net::OStation, QDateTime::currentDateTime())); |
171 | *(m_stationsHistory.last()->st) = (*station); | 171 | *(m_stationsHistory.last()->st) = (*station); |
172 | } | 172 | } |
173 | else { | 173 | else { |
174 | if ( itr.current()->st->level < station->level ) | 174 | if ( itr.current()->st->level < station->level ) |
175 | itr.current()->st->level = station->level; | 175 | itr.current()->st->level = station->level; |
176 | 176 | ||
177 | itr.current()->lastTimeSeen = QDateTime::currentDateTime(); | 177 | itr.current()->lastTimeSeen = QDateTime::currentDateTime(); |
178 | } | 178 | } |
179 | } | 179 | } |
180 | } | 180 | } |
181 | displayStations(); | 181 | displayStations(); |
182 | } | 182 | } |
183 | 183 | ||
184 | void OpieStumbler::displayStations() | 184 | void OpieStumbler::displayStations() |
185 | { | 185 | { |
186 | m_listCurrent->clear(); | 186 | m_listCurrent->clear(); |
187 | for(QListIterator<Opie::Net::OStation> it(*m_stationsCurrent); it.current(); ++it) | 187 | for(QListIterator<Opie::Net::OStation> it(*m_stationsCurrent); it.current(); ++it) |
188 | new StationViewItem( m_listCurrent, it.current()->ssid, QString::number(it.current()->channel), | 188 | new StationViewItem( m_listCurrent, it.current()->ssid, QString::number(it.current()->channel), |
189 | QString::number(it.current()->level), it.current()->encrypted ? "Y": "N", it.current()->macAddress.toString() ); | 189 | QString::number(it.current()->level), it.current()->encrypted ? "Y": "N", it.current()->macAddress.toString() ); |
190 | 190 | ||
191 | m_listHistory->clear(); | 191 | m_listHistory->clear(); |
192 | for(QListIterator<StumblerStation> it(m_stationsHistory); it.current(); ++it) | 192 | for(QListIterator<StumblerStation> it(m_stationsHistory); it.current(); ++it) |
193 | new StationViewItem( m_listHistory, it.current()->st->ssid, QString::number(it.current()->st->channel), | 193 | new StationViewItem( m_listHistory, it.current()->st->ssid, QString::number(it.current()->st->channel), |
194 | QString::number(it.current()->st->level), it.current()->st->encrypted ? "Y": "N", | 194 | QString::number(it.current()->st->level), it.current()->st->encrypted ? "Y": "N", |
195 | manufacturer(it.current()->st->macAddress.toString()), it.current()->st->macAddress.toString() ); | 195 | manufacturer(it.current()->st->macAddress.toString()), it.current()->st->macAddress.toString() ); |
196 | } | 196 | } |
197 | 197 | ||
198 | void OpieStumbler::slotMessageReceived( const QCString &message, const QByteArray ¶meters) | 198 | void OpieStumbler::slotMessageReceived( const QCString &message, const QByteArray ¶meters) |
199 | { | 199 | { |
200 | Q_UNUSED(const_cast<QByteArray &>(parameters)) | 200 | Q_UNUSED(const_cast<QByteArray &>(parameters)) |
201 | 201 | ||
202 | if ( message == "show()" ) | 202 | if ( message == "show()" ) |
203 | show(); | 203 | show(); |
204 | } | 204 | } |
205 | 205 | ||
206 | void OpieStumbler::slotCurrentMousePressed(int button, QListViewItem * item, const QPoint &point, int c) | 206 | void OpieStumbler::slotCurrentMousePressed(int button, QListViewItem * item, const QPoint &point, int c) |
207 | { | 207 | { |
208 | Q_UNUSED(c) | 208 | Q_UNUSED(c) |
209 | 209 | ||
210 | if ( 2 == button ) { | 210 | if ( 2 == button ) { |
211 | m_mac = item->text(CURENC + 1); | 211 | m_mac = item->text(CURENC + 1); |
212 | m_popupCurrent->popup(point); | 212 | m_popupCurrent->popup(point); |
213 | } | 213 | } |
214 | } | 214 | } |
215 | 215 | ||
216 | 216 | ||
217 | void OpieStumbler::slotHistoryMousePressed(int button, QListViewItem * item, const QPoint &point, int c) | 217 | void OpieStumbler::slotHistoryMousePressed(int button, QListViewItem * item, const QPoint &point, int c) |
218 | { | 218 | { |
219 | Q_UNUSED(c) | 219 | Q_UNUSED(c) |
220 | 220 | ||
221 | if ( 2 == button ) { | 221 | if ( 2 == button ) { |
222 | m_mac = item->text(HISVENDOR + 1); | 222 | m_mac = item->text(HISVENDOR + 1); |
223 | m_popupHistory->popup(point); | 223 | m_popupHistory->popup(point); |
224 | } | 224 | } |
225 | } | 225 | } |
226 | 226 | ||
227 | void OpieStumbler::slotShowDetails() | 227 | void OpieStumbler::slotShowDetails() |
228 | { | 228 | { |
229 | QListIterator<StumblerStation> it(m_stationsHistory); | 229 | QListIterator<StumblerStation> it(m_stationsHistory); |
230 | for(; it.current() && it.current()->st->macAddress.toString() != m_mac; ++it ); | 230 | for(; it.current() && it.current()->st->macAddress.toString() != m_mac; ++it ); |
231 | 231 | ||
232 | if( it.current() ) { | 232 | if( it.current() ) { |
233 | StationInfo info(it.current()->st->ssid, it.current()->st->type, QString::number(it.current()->st->channel), | 233 | StationInfo info(it.current()->st->ssid, it.current()->st->type, QString::number(it.current()->st->channel), |
234 | QString::number(it.current()->st->rates.last()/1000000), QString::number(it.current()->st->level), | 234 | QString::number(it.current()->st->rates.last()/1000000), QString::number(it.current()->st->level), |
235 | it.current()->st->encrypted ? "WEP": "No", | 235 | it.current()->st->encrypted ? "WEP": "No", |
236 | it.current()->st->macAddress.toString(), manufacturer(it.current()->st->macAddress.toString(), TRUE), | 236 | it.current()->st->macAddress.toString(), manufacturer(it.current()->st->macAddress.toString(), TRUE), |
237 | it.current()->lastTimeSeen.toString() ,this, "", TRUE); | 237 | it.current()->lastTimeSeen.toString() ,this, "", TRUE); |
238 | info.exec(); | 238 | info.exec(); |
239 | } | 239 | } |
240 | 240 | ||
241 | } | 241 | } |
242 | 242 | ||
243 | void OpieStumbler::slotLoadManufacturers() | 243 | void OpieStumbler::slotLoadManufacturers() |
244 | { | 244 | { |
245 | m_db = Opie::Net::OManufacturerDB::instance(); | 245 | m_db = Opie::Net::OManufacturerDB::instance(); |
246 | } | 246 | } |
247 | 247 | ||
248 | QString OpieStumbler::manufacturer( const QString &mac, bool extended ) | 248 | QString OpieStumbler::manufacturer( const QString &mac, bool extended ) |
249 | { | 249 | { |
250 | QString retval; | 250 | QString retval; |
251 | if ( m_db ) | 251 | if ( m_db ) |
252 | if ( extended ) | 252 | if ( extended ) |
253 | retval = m_db->lookupExt(mac); | 253 | retval = m_db->lookupExt(mac); |
254 | else | 254 | else |
255 | retval = m_db->lookup(mac); | 255 | retval = m_db->lookup(mac); |
256 | 256 | ||
257 | if ( retval.isEmpty() ) | 257 | if ( retval.isEmpty() ) |
258 | retval = tr("Unknown"); | 258 | retval = tr("Unknown"); |
259 | 259 | ||
260 | return retval; | 260 | return retval; |
261 | } | 261 | } |
262 | 262 | ||
263 | void OpieStumbler::slotJoinNetwork() | 263 | void OpieStumbler::slotJoinNetwork() |
264 | { | 264 | { |
265 | slotStopScanning(); | 265 | slotStopScanning(); |
266 | 266 | ||
267 | OWirelessNetworkInterface *wiface = static_cast<OWirelessNetworkInterface*>(ONetwork::instance()->interface(m_interface)); | 267 | OWirelessNetworkInterface *wiface = static_cast<OWirelessNetworkInterface*>(ONetwork::instance()->interface(m_interface)); |
268 | 268 | ||
269 | if( !wiface ) | 269 | if( !wiface ) |
270 | return; | 270 | return; |
271 | 271 | ||
272 | QListIterator<StumblerStation> it(m_stationsHistory); | 272 | QListIterator<StumblerStation> it(m_stationsHistory); |
273 | 273 | ||
274 | for(; it.current() && it.current()->st->macAddress.toString() != m_mac; ++it ); | 274 | for(; it.current() && it.current()->st->macAddress.toString() != m_mac; ++it ); |
275 | 275 | ||
276 | if( !it.current() ) | 276 | if( !it.current() ) |
277 | return; | 277 | return; |
278 | 278 | ||
279 | Opie::Net::OStation *station = it.current()->st; | 279 | Opie::Net::OStation *station = it.current()->st; |
280 | 280 | ||
281 | odebug << "Bringing interface down" << oendl; | 281 | odebug << "Bringing interface down" << oendl; |
282 | wiface->setUp(FALSE); | 282 | wiface->setUp(FALSE); |
283 | 283 | ||
284 | odebug << "Setting mode to " << (station->type == "adhoc" ? "adhoc" : "managed") << oendl; | 284 | odebug << "Setting mode to " << (station->type == "adhoc" ? "adhoc" : "managed") << oendl; |
285 | wiface->setMode(station->type == "adhoc" ? "adhoc" : "managed" ); | 285 | wiface->setMode(station->type == "adhoc" ? "adhoc" : "managed" ); |
286 | 286 | ||
287 | odebug << "Setting channel to " << station->channel << oendl; | 287 | odebug << "Setting channel to " << station->channel << oendl; |
288 | wiface->setChannel(station->channel); | 288 | wiface->setChannel(station->channel); |
289 | 289 | ||
290 | odebug << "Setting SSID to " << station->ssid << oendl; | 290 | odebug << "Setting SSID to " << station->ssid << oendl; |
291 | wiface->setSSID(station->ssid); | 291 | wiface->setSSID(station->ssid); |
292 | 292 | ||
293 | wiface->commit(); | 293 | wiface->commit(); |
294 | 294 | ||
295 | odebug << "Bringing interface up" << oendl; | 295 | odebug << "Bringing interface up" << oendl; |
296 | wiface->setUp(TRUE); | 296 | wiface->setUp(TRUE); |
297 | //Wait 5 sec for association | 297 | //Wait 5 sec for association |
298 | QTimer::singleShot(5000, this, SLOT(slotAssociated())); | 298 | QTimer::singleShot(5000, this, SLOT(slotAssociated())); |
299 | } | 299 | } |
300 | 300 | ||
301 | void OpieStumbler::slotAssociated() | 301 | void OpieStumbler::slotAssociated() |
302 | { | 302 | { |
303 | OWirelessNetworkInterface *wiface = static_cast<OWirelessNetworkInterface*>(ONetwork::instance()->interface(m_interface)); | 303 | OWirelessNetworkInterface *wiface = static_cast<OWirelessNetworkInterface*>(ONetwork::instance()->interface(m_interface)); |
304 | 304 | ||
305 | if( !wiface ) | 305 | if( !wiface ) |
306 | return; | 306 | return; |
307 | 307 | ||
308 | if (!wiface->isAssociated()) { | 308 | if (!wiface->isAssociated()) { |
309 | Global::statusMessage(tr("Could not Join")); | 309 | Global::statusMessage(tr("Could not Join")); |
310 | return; | 310 | return; |
311 | } | 311 | } |
312 | 312 | ||
313 | Global::statusMessage(tr("Joined")); | 313 | Global::statusMessage(tr("Joined")); |
314 | 314 | ||
315 | if(m_proc) { | 315 | if(m_proc) { |
316 | m_proc->kill(); | 316 | m_proc->kill(); |
317 | delete m_proc; | 317 | delete m_proc; |
318 | } | 318 | } |
319 | 319 | ||
320 | m_proc = new Opie::Core::OProcess(this); | 320 | m_proc = new Opie::Core::OProcess(this); |
321 | 321 | ||
322 | *m_proc << "udhcpc" << "-f" << "-n" << "-i" << m_interface; | 322 | *m_proc << "udhcpc" << "-f" << "-n" << "-i" << m_interface; |
323 | m_proc->start(Opie::Core::OProcess::DontCare); | 323 | m_proc->start(Opie::Core::OProcess::DontCare); |
324 | QTimer::singleShot(5000, this, SLOT(slotCheckDHCP())); | 324 | QTimer::singleShot(5000, this, SLOT(slotCheckDHCP())); |
325 | } | 325 | } |
326 | 326 | ||
327 | void OpieStumbler::slotCheckDHCP() | 327 | void OpieStumbler::slotCheckDHCP() |
328 | { | 328 | { |
329 | if(!m_proc->isRunning()) { | 329 | if(!m_proc->isRunning()) { |
330 | Global::statusMessage(tr("Could not Obtain an Address")); | 330 | Global::statusMessage(tr("Could not Obtain an Address")); |
331 | delete m_proc; | 331 | delete m_proc; |
332 | m_proc = NULL; | 332 | m_proc = NULL; |
333 | return; | 333 | return; |
334 | } | 334 | } |
335 | m_listCurrent->show(); | 335 | m_listCurrent->show(); |
336 | 336 | ||
337 | 337 | ||
338 | OWirelessNetworkInterface *wiface = static_cast<OWirelessNetworkInterface*>(ONetwork::instance()->interface(m_interface)); | 338 | OWirelessNetworkInterface *wiface = static_cast<OWirelessNetworkInterface*>(ONetwork::instance()->interface(m_interface)); |
339 | Global::statusMessage(tr("Obtained IP ") + wiface->ipV4Address()); | 339 | Global::statusMessage(tr("Obtained IP ") + wiface->ipV4Address().toString()); |
340 | } | 340 | } |
341 | 341 | ||
342 | 342 | ||
343 | 343 | ||
344 | 344 | ||
345 | 345 | ||
346 | 346 | ||
347 | 347 | ||
348 | 348 | ||