summaryrefslogtreecommitdiff
path: root/noncore/net/wellenreiter/gui/wellenreiter.cpp
Unidiff
Diffstat (limited to 'noncore/net/wellenreiter/gui/wellenreiter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp186
1 files changed, 110 insertions, 76 deletions
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index 62bda91..9e1010b 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -137,99 +137,133 @@ void Wellenreiter::channelHopped(int c)
137} 137}
138 138
139 139
140void Wellenreiter::receivePacket(OPacket* p) 140void Wellenreiter::handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon )
141{ 141{
142 hexWindow()->log( p->dump( 8 ) ); 142 QString type;
143 if ( beacon->canIBSS() )
144 {
145 type = "adhoc";
146 }
147 else if ( beacon->canESS() )
148 {
149 type = "managed";
150 }
151 else
152 {
153 qWarning( "Wellenreiter::invalid frame [possibly noise] detected!" );
154 return;
155 }
143 156
144 // check if we received a beacon frame 157 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) );
145 OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) ); 158 QString essid = ssid ? ssid->ID() : QString("<unknown>");
146 if ( beacon && beacon->managementType() == "Beacon" ) 159 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) );
160 int channel = ds ? ds->channel() : -1;
161
162 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) );
163 netView()->addNewItem( type, essid, header->macAddress2().toString(), beacon->canPrivacy(), channel, 0 );
164
165 // update graph window
166 if ( ds )
147 { 167 {
148 QString type; 168 OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) );
149 if ( beacon->canIBSS() ) 169 if ( prism )
150 { 170 graphwindow->traffic( ds->channel(), prism->signalStrength() );
151 type = "adhoc"; 171 else
152 } 172 graphwindow->traffic( ds->channel(), 95 );
153 else if ( beacon->canESS() ) 173 }
174}
175
176
177void Wellenreiter::handleData( OPacket* p, OWaveLanDataPacket* data )
178{
179 OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" );
180 if ( wlan->fromDS() && !wlan->toDS() )
181 {
182 qDebug( "FromDS traffic: '%s' -> '%s' via '%s'",
183 (const char*) wlan->macAddress3().toString(true),
184 (const char*) wlan->macAddress1().toString(true),
185 (const char*) wlan->macAddress2().toString(true) );
186 netView()->fromDStraffic( wlan->macAddress3().toString(),
187 wlan->macAddress1().toString(),
188 wlan->macAddress2().toString() );
189 }
190 else
191 if ( !wlan->fromDS() && wlan->toDS() )
192 {
193 qDebug( "ToDS traffic: '%s' -> '%s' via '%s'",
194 (const char*) wlan->macAddress2().toString(true),
195 (const char*) wlan->macAddress3().toString(true),
196 (const char*) wlan->macAddress1().toString(true) );
197 netView()->toDStraffic( wlan->macAddress2().toString(),
198 wlan->macAddress3().toString(),
199 wlan->macAddress1().toString() );
200 }
201 else
202 if ( wlan->fromDS() && wlan->toDS() )
203 {
204 qDebug( "WDS(bridge) traffic: '%s' -> '%s' via '%s' and '%s'",
205 (const char*) wlan->macAddress4().toString(true),
206 (const char*) wlan->macAddress3().toString(true),
207 (const char*) wlan->macAddress1().toString(true),
208 (const char*) wlan->macAddress2().toString(true) );
209 netView()->WDStraffic( wlan->macAddress4().toString(),
210 wlan->macAddress3().toString(),
211 wlan->macAddress1().toString(),
212 wlan->macAddress2().toString() );
213 }
214 else
215 {
216 qDebug( "IBSS(AdHoc) traffic: '%s' -> '%s' (Cell: '%s')'",
217 (const char*) wlan->macAddress2().toString(true),
218 (const char*) wlan->macAddress1().toString(true),
219 (const char*) wlan->macAddress3().toString(true) );
220 netView()->IBSStraffic( wlan->macAddress2().toString(),
221 wlan->macAddress1().toString(),
222 wlan->macAddress3().toString() );
223 }
224
225 OARPPacket* arp = (OARPPacket*) p->child( "ARP" );
226 if ( arp )
227 {
228 qDebug( "Received ARP traffic (type '%s'): ", (const char*) arp->type() );
229 if ( arp->type() == "REQUEST" )
154 { 230 {
155 type = "managed"; 231 netView()->identify( arp->senderMacAddress().toString(), arp->senderIPV4Address().toString() );
156 } 232 }
157 else 233 else if ( arp->type() == "REPLY" )
158 { 234 {
159 qDebug( "Wellenreiter::invalid frame detected: '%s'", (const char*) p->dump( 16 ) ); 235 netView()->identify( arp->senderMacAddress().toString(), arp->senderIPV4Address().toString() );
160 return; 236 netView()->identify( arp->targetMacAddress().toString(), arp->targetIPV4Address().toString() );
161 } 237 }
238 }
239
240 OIPPacket* ip = (OIPPacket*) p->child( "IP" );
241 if ( ip )
242 {
243 qDebug( "Received IP packet." );
244 }
245}
162 246
163 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) );
164 QString essid = ssid ? ssid->ID() : QString("<unknown>");
165 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) );
166 int channel = ds ? ds->channel() : -1;
167 247
168 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); 248void Wellenreiter::receivePacket( OPacket* p )
169 netView()->addNewItem( type, essid, header->macAddress2().toString(), beacon->canPrivacy(), channel, 0 ); 249{
250 hexWindow()->log( p->dump( 8 ) );
170 251
171 // update graph window 252 // check if we received a beacon frame
172 if ( ds ) 253 OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) );
173 { 254 if ( beacon && beacon->managementType() == "Beacon" )
174 OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) ); 255 {
175 if ( prism ) 256 handleBeacon( p, beacon );
176 graphwindow->traffic( ds->channel(), prism->signalStrength() );
177 else
178 graphwindow->traffic( ds->channel(), 95 );
179 }
180 return; 257 return;
181 } 258 }
182 259
260 //TODO: WEP check here
261
183 // check for a data frame 262 // check for a data frame
184 OWaveLanDataPacket* data = static_cast<OWaveLanDataPacket*>( p->child( "802.11 Data" ) ); 263 OWaveLanDataPacket* data = static_cast<OWaveLanDataPacket*>( p->child( "802.11 Data" ) );
185 if ( data ) 264 if ( data )
186 { 265 {
187 OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); 266 handleData( p, data );
188 if ( wlan->fromDS() && !wlan->toDS() )
189 {
190 qDebug( "FromDS traffic: '%s' -> '%s' via '%s'",
191 (const char*) wlan->macAddress3().toString(true),
192 (const char*) wlan->macAddress1().toString(true),
193 (const char*) wlan->macAddress2().toString(true) );
194 netView()->fromDStraffic( wlan->macAddress3().toString(),
195 wlan->macAddress1().toString(),
196 wlan->macAddress2().toString() );
197 }
198 else
199 if ( !wlan->fromDS() && wlan->toDS() )
200 {
201 qDebug( "ToDS traffic: '%s' -> '%s' via '%s'",
202 (const char*) wlan->macAddress2().toString(true),
203 (const char*) wlan->macAddress3().toString(true),
204 (const char*) wlan->macAddress1().toString(true) );
205 netView()->toDStraffic( wlan->macAddress2().toString(),
206 wlan->macAddress3().toString(),
207 wlan->macAddress1().toString() );
208 }
209 else
210 if ( wlan->fromDS() && wlan->toDS() )
211 {
212 qDebug( "WDS(bridge) traffic: '%s' -> '%s' via '%s' and '%s'",
213 (const char*) wlan->macAddress4().toString(true),
214 (const char*) wlan->macAddress3().toString(true),
215 (const char*) wlan->macAddress1().toString(true),
216 (const char*) wlan->macAddress2().toString(true) );
217 netView()->WDStraffic( wlan->macAddress4().toString(),
218 wlan->macAddress3().toString(),
219 wlan->macAddress1().toString(),
220 wlan->macAddress2().toString() );
221 }
222 else
223 {
224 qDebug( "IBSS(AdHoc) traffic: '%s' -> '%s' (Cell: '%s')'",
225 (const char*) wlan->macAddress2().toString(true),
226 (const char*) wlan->macAddress1().toString(true),
227 (const char*) wlan->macAddress3().toString(true) );
228 netView()->IBSStraffic( wlan->macAddress2().toString(),
229 wlan->macAddress1().toString(),
230 wlan->macAddress3().toString() );
231 }
232 return;
233 } 267 }
234} 268}
235 269