author | mickeyl <mickeyl> | 2003-04-07 22:06:01 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-04-07 22:06:01 (UTC) |
commit | eee5531d24fdb17011debaa7acd42683330e55b6 (patch) (unidiff) | |
tree | 5e82bb5e7c39b1bdb1240eff47dbbe13adcf18cb /noncore/net/wellenreiter/gui/wellenreiter.cpp | |
parent | c32ffdaa4cac3cbe60d4bb6f72e0444a6f9e323f (diff) | |
download | opie-eee5531d24fdb17011debaa7acd42683330e55b6.zip opie-eee5531d24fdb17011debaa7acd42683330e55b6.tar.gz opie-eee5531d24fdb17011debaa7acd42683330e55b6.tar.bz2 |
New feature! Finally, non-AP stations in an infrastructure network show up.
Diffstat (limited to 'noncore/net/wellenreiter/gui/wellenreiter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 88 |
1 files changed, 68 insertions, 20 deletions
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index aa33158..8d18f73 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp | |||
@@ -68,118 +68,166 @@ Wellenreiter::Wellenreiter( QWidget* parent ) | |||
68 | #ifdef QWS | 68 | #ifdef QWS |
69 | manufile.sprintf( "%s/share/wellenreiter/manufacturers.dat", (const char*) QPEApplication::qpeDir() ); | 69 | manufile.sprintf( "%s/share/wellenreiter/manufacturers.dat", (const char*) QPEApplication::qpeDir() ); |
70 | #else | 70 | #else |
71 | manufile.sprintf( "/usr/local/share/wellenreiter/manufacturers.dat" ); | 71 | manufile.sprintf( "/usr/local/share/wellenreiter/manufacturers.dat" ); |
72 | #endif | 72 | #endif |
73 | manufacturerdb = new ManufacturerDB( manufile ); | 73 | manufacturerdb = new ManufacturerDB( manufile ); |
74 | 74 | ||
75 | logwindow->log( "(i) Wellenreiter has been started." ); | 75 | logwindow->log( "(i) Wellenreiter has been started." ); |
76 | 76 | ||
77 | // | 77 | // |
78 | // detect operating system | 78 | // detect operating system |
79 | // | 79 | // |
80 | 80 | ||
81 | #ifdef QWS | 81 | #ifdef QWS |
82 | QString sys; | 82 | QString sys; |
83 | sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); | 83 | sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); |
84 | _system = ODevice::inst()->system(); | 84 | _system = ODevice::inst()->system(); |
85 | logwindow->log( sys ); | 85 | logwindow->log( sys ); |
86 | #endif | 86 | #endif |
87 | 87 | ||
88 | // setup GUI | 88 | // setup GUI |
89 | netview->setColumnWidthMode( 1, QListView::Manual ); | 89 | netview->setColumnWidthMode( 1, QListView::Manual ); |
90 | 90 | ||
91 | if ( manufacturerdb ) | 91 | if ( manufacturerdb ) |
92 | netview->setManufacturerDB( manufacturerdb ); | 92 | netview->setManufacturerDB( manufacturerdb ); |
93 | 93 | ||
94 | pcap = new OPacketCapturer(); | 94 | pcap = new OPacketCapturer(); |
95 | 95 | ||
96 | } | 96 | } |
97 | 97 | ||
98 | Wellenreiter::~Wellenreiter() | 98 | Wellenreiter::~Wellenreiter() |
99 | { | 99 | { |
100 | // no need to delete child widgets, Qt does it all for us | 100 | // no need to delete child widgets, Qt does it all for us |
101 | 101 | ||
102 | delete manufacturerdb; | 102 | delete manufacturerdb; |
103 | delete pcap; | 103 | delete pcap; |
104 | } | 104 | } |
105 | 105 | ||
106 | void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) | 106 | void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) |
107 | { | 107 | { |
108 | configwindow = cw; | 108 | configwindow = cw; |
109 | } | 109 | } |
110 | 110 | ||
111 | void Wellenreiter::receivePacket(OPacket* p) | 111 | void Wellenreiter::receivePacket(OPacket* p) |
112 | { | 112 | { |
113 | hexWindow()->log( p->dump( 8 ) ); | 113 | hexWindow()->log( p->dump( 8 ) ); |
114 | 114 | ||
115 | // check if we received a beacon frame | 115 | // check if we received a beacon frame |
116 | // static_cast is justified here | ||
117 | OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) ); | 116 | OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) ); |
118 | if ( !beacon ) return; | 117 | if ( beacon ) |
119 | QString type; | 118 | { |
120 | 119 | QString type; | |
121 | //FIXME: Can stations in ESS mode can be distinguished from APs? | 120 | if ( beacon->canIBSS() ) |
122 | //FIXME: Apparently yes, but not by listening to beacons, because | 121 | type = "adhoc"; |
123 | //FIXME: they simply don't send beacons in infrastructure mode. | 122 | else |
124 | //FIXME: so we also have to listen to data packets | 123 | type = "managed"; |
125 | 124 | ||
126 | if ( beacon->canIBSS() ) | 125 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); |
127 | type = "adhoc"; | 126 | QString essid = ssid ? ssid->ID() : QString("<unknown>"); |
128 | else | 127 | OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); |
129 | type = "managed"; | 128 | int channel = ds ? ds->channel() : -1; |
130 | 129 | ||
131 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); | 130 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); |
132 | QString essid = ssid ? ssid->ID() : QString("<unknown>"); | 131 | netView()->addNewItem( type, essid, header->macAddress2().toString(), header->usesWep(), channel, 0 ); |
133 | OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); | 132 | return; |
134 | int channel = ds ? ds->channel() : -1; | 133 | } |
135 | 134 | ||
136 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); | 135 | // check for a data frame |
137 | netView()->addNewItem( type, essid, header->macAddress2().toString(), header->usesWep(), channel, 0 ); | 136 | OWaveLanDataPacket* data = static_cast<OWaveLanDataPacket*>( p->child( "802.11 Data" ) ); |
137 | if ( data ) | ||
138 | { | ||
139 | OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); | ||
140 | if ( wlan->fromDS() && !wlan->toDS() ) | ||
141 | { | ||
142 | qDebug( "FromDS traffic: '%s' -> '%s' via '%s'", | ||
143 | (const char*) wlan->macAddress3().toString(true), | ||
144 | (const char*) wlan->macAddress1().toString(true), | ||
145 | (const char*) wlan->macAddress2().toString(true) ); | ||
146 | netView()->traffic( "fromDS", wlan->macAddress3().toString(), | ||
147 | wlan->macAddress1().toString(), | ||
148 | wlan->macAddress2().toString() ); | ||
149 | } | ||
150 | else | ||
151 | if ( !wlan->fromDS() && wlan->toDS() ) | ||
152 | { | ||
153 | qDebug( "ToDS traffic: '%s' -> '%s' via '%s'", | ||
154 | (const char*) wlan->macAddress2().toString(true), | ||
155 | (const char*) wlan->macAddress3().toString(true), | ||
156 | (const char*) wlan->macAddress1().toString(true) ); | ||
157 | netView()->traffic( "toDS", wlan->macAddress2().toString(), | ||
158 | wlan->macAddress3().toString(), | ||
159 | wlan->macAddress1().toString() ); | ||
160 | } | ||
161 | else | ||
162 | if ( wlan->fromDS() && wlan->toDS() ) | ||
163 | { | ||
164 | qDebug( "WSD(bridge) traffic: '%s' -> '%s' via '%s' and '%s'", | ||
165 | (const char*) wlan->macAddress4().toString(true), | ||
166 | (const char*) wlan->macAddress3().toString(true), | ||
167 | (const char*) wlan->macAddress1().toString(true), | ||
168 | (const char*) wlan->macAddress2().toString(true) ); | ||
169 | netView()->traffic( "WSD", wlan->macAddress4().toString(), | ||
170 | wlan->macAddress3().toString(), | ||
171 | wlan->macAddress1().toString(), | ||
172 | wlan->macAddress2().toString() ); | ||
173 | } | ||
174 | else | ||
175 | { | ||
176 | qDebug( "IBSS(AdHoc) traffic: '%s' -> '%s' (Cell: '%s')'", | ||
177 | (const char*) wlan->macAddress2().toString(true), | ||
178 | (const char*) wlan->macAddress1().toString(true), | ||
179 | (const char*) wlan->macAddress3().toString(true) ); | ||
180 | netView()->traffic( "fromDS", wlan->macAddress2().toString(), | ||
181 | wlan->macAddress1().toString(), | ||
182 | wlan->macAddress3().toString() ); | ||
183 | } | ||
184 | return; | ||
185 | } | ||
138 | } | 186 | } |
139 | 187 | ||
140 | void Wellenreiter::startStopClicked() | 188 | void Wellenreiter::startStopClicked() |
141 | { | 189 | { |
142 | if ( sniffing ) | 190 | if ( sniffing ) |
143 | { | 191 | { |
144 | disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); | 192 | disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); |
145 | 193 | ||
146 | iface->setChannelHopping(); // stop hopping channels | 194 | iface->setChannelHopping(); // stop hopping channels |
147 | pcap->close(); | 195 | pcap->close(); |
148 | sniffing = false; | 196 | sniffing = false; |
149 | #ifdef QWS | 197 | #ifdef QWS |
150 | oApp->setTitle(); | 198 | oApp->setTitle(); |
151 | #else | 199 | #else |
152 | qApp->mainWidget()->setCaption( "Wellenreiter II" ); | 200 | qApp->mainWidget()->setCaption( "Wellenreiter II" ); |
153 | #endif | 201 | #endif |
154 | 202 | ||
155 | // get interface name from config window | 203 | // get interface name from config window |
156 | const QString& interface = configwindow->interfaceName->currentText(); | 204 | const QString& interface = configwindow->interfaceName->currentText(); |
157 | ONetwork* net = ONetwork::instance(); | 205 | ONetwork* net = ONetwork::instance(); |
158 | iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); | 206 | iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); |
159 | 207 | ||
160 | // switch off monitor mode | 208 | // switch off monitor mode |
161 | iface->setMonitorMode( false ); | 209 | iface->setMonitorMode( false ); |
162 | // switch off promisc flag | 210 | // switch off promisc flag |
163 | iface->setPromiscuousMode( false ); | 211 | iface->setPromiscuousMode( false ); |
164 | 212 | ||
165 | system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess | 213 | system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess |
166 | logwindow->log( "(i) Stopped Scanning." ); | 214 | logwindow->log( "(i) Stopped Scanning." ); |
167 | 215 | ||
168 | // message the user | 216 | // message the user |
169 | QMessageBox::information( this, "Wellenreiter II", "Your wireless card\nshould now be usable again." ); | 217 | QMessageBox::information( this, "Wellenreiter II", "Your wireless card\nshould now be usable again." ); |
170 | } | 218 | } |
171 | 219 | ||
172 | else | 220 | else |
173 | { | 221 | { |
174 | // get configuration from config window | 222 | // get configuration from config window |
175 | 223 | ||
176 | const QString& interface = configwindow->interfaceName->currentText(); | 224 | const QString& interface = configwindow->interfaceName->currentText(); |
177 | const int cardtype = configwindow->daemonDeviceType(); | 225 | const int cardtype = configwindow->daemonDeviceType(); |
178 | const int interval = configwindow->daemonHopInterval(); | 226 | const int interval = configwindow->daemonHopInterval(); |
179 | 227 | ||
180 | if ( ( interface == "" ) || ( cardtype == 0 ) ) | 228 | if ( ( interface == "" ) || ( cardtype == 0 ) ) |
181 | { | 229 | { |
182 | QMessageBox::information( this, "Wellenreiter II", "Your device is not\nproperly configured. Please reconfigure!" ); | 230 | QMessageBox::information( this, "Wellenreiter II", "Your device is not\nproperly configured. Please reconfigure!" ); |
183 | return; | 231 | return; |
184 | } | 232 | } |
185 | 233 | ||