summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index d1dd73a..e294eb8 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -67,162 +67,162 @@ Wellenreiter::Wellenreiter( QWidget* parent )
67 QString manufile; 67 QString manufile;
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
98Wellenreiter::~Wellenreiter() 98Wellenreiter::~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
106void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) 106void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw )
107{ 107{
108 configwindow = cw; 108 configwindow = cw;
109} 109}
110 110
111void Wellenreiter::receivePacket(OPacket* p) 111void Wellenreiter::receivePacket(OPacket* p)
112{ 112{
113 // check if we received a beacon frame 113 // check if we received a beacon frame
114 // static_cast is justified here 114 // static_cast is justified here
115 OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) ); 115 OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) );
116 if ( !beacon ) return; 116 if ( !beacon ) return;
117 QString type; 117 QString type;
118 118
119 //FIXME: Can stations in ESS mode can be distinguished from APs? 119 //FIXME: Can stations in ESS mode can be distinguished from APs?
120 //FIXME: Apparently yes, but not by listening to beacons, because 120 //FIXME: Apparently yes, but not by listening to beacons, because
121 //FIXME: they simply don't send beacons in infrastructure mode. 121 //FIXME: they simply don't send beacons in infrastructure mode.
122 //FIXME: so we also have to listen to data packets 122 //FIXME: so we also have to listen to data packets
123 123
124 if ( beacon->canIBSS() ) 124 if ( beacon->canIBSS() )
125 type = "adhoc"; 125 type = "adhoc";
126 else 126 else
127 type = "managed"; 127 type = "managed";
128 128
129 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); 129 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) );
130 QString essid = ssid ? ssid->ID() : QString("<unknown>"); 130 QString essid = ssid ? ssid->ID() : QString("<unknown>");
131 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); 131 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) );
132 int channel = ds ? ds->channel() : -1; 132 int channel = ds ? ds->channel() : -1;
133 133
134 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); 134 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) );
135 netView()->addNewItem( type, essid, header->macAddress2().toString(), header->usesWep(), channel, 0 ); 135 netView()->addNewItem( type, essid, header->macAddress2().toString(), header->usesWep(), channel, 0 );
136} 136}
137 137
138void Wellenreiter::startStopClicked() 138void Wellenreiter::startStopClicked()
139{ 139{
140 if ( sniffing ) 140 if ( sniffing )
141 { 141 {
142 disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); 142 disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) );
143 143
144 iface->setChannelHopping(); // stop hopping channels 144 iface->setChannelHopping(); // stop hopping channels
145 pcap->close(); 145 pcap->close();
146 sniffing = false; 146 sniffing = false;
147 #ifdef QWS 147 #ifdef QWS
148 oApp->setTitle(); 148 oApp->setTitle();
149 #else 149 #else
150 qApp->mainWidget()->setCaption( "Wellenreiter II" ); 150 qApp->mainWidget()->setCaption( "Wellenreiter II" );
151 #endif 151 #endif
152 152
153 // get interface name from config window 153 // get interface name from config window
154 const QString& interface = configwindow->interfaceName->currentText(); 154 const QString& interface = configwindow->interfaceName->currentText();
155 ONetwork* net = ONetwork::instance(); 155 ONetwork* net = ONetwork::instance();
156 iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); 156 iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface ));
157 157
158 // switch off monitor mode 158 // switch off monitor mode
159 iface->setMonitorMode( false ); 159 iface->setMonitorMode( false );
160 // switch off promisc flag 160 // switch off promisc flag
161 iface->setPromiscuousMode( false ); 161 iface->setPromiscuousMode( false );
162 162
163 system( "cardctl reset; sleep 1; dhclient; udhcpc" ); //FIXME: Use OProcess 163 system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess
164 164
165 // message the user 165 // message the user
166 QMessageBox::information( this, "Wellenreiter II", "Your wireless card\nshould now be usable again." ); 166 QMessageBox::information( this, "Wellenreiter II", "Your wireless card\nshould now be usable again." );
167 } 167 }
168 168
169 else 169 else
170 { 170 {
171 // get configuration from config window 171 // get configuration from config window
172 172
173 const QString& interface = configwindow->interfaceName->currentText(); 173 const QString& interface = configwindow->interfaceName->currentText();
174 const int cardtype = configwindow->daemonDeviceType(); 174 const int cardtype = configwindow->daemonDeviceType();
175 const int interval = configwindow->daemonHopInterval(); 175 const int interval = configwindow->daemonHopInterval();
176 176
177 if ( ( interface == "" ) || ( cardtype == 0 ) ) 177 if ( ( interface == "" ) || ( cardtype == 0 ) )
178 { 178 {
179 QMessageBox::information( this, "Wellenreiter II", "Your device is not\nproperly configured. Please reconfigure!" ); 179 QMessageBox::information( this, "Wellenreiter II", "Your device is not\nproperly configured. Please reconfigure!" );
180 return; 180 return;
181 } 181 }
182 182
183 // configure device 183 // configure device
184 184
185 ONetwork* net = ONetwork::instance(); 185 ONetwork* net = ONetwork::instance();
186 iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); 186 iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface ));
187 187
188 // set monitor mode 188 // set monitor mode
189 189
190 switch ( cardtype ) 190 switch ( cardtype )
191 { 191 {
192 case 1: iface->setMonitoring( new OCiscoMonitoringInterface( iface ) ); break; 192 case 1: iface->setMonitoring( new OCiscoMonitoringInterface( iface ) ); break;
193 case 2: iface->setMonitoring( new OWlanNGMonitoringInterface( iface ) ); break; 193 case 2: iface->setMonitoring( new OWlanNGMonitoringInterface( iface ) ); break;
194 case 3: iface->setMonitoring( new OHostAPMonitoringInterface( iface ) ); break; 194 case 3: iface->setMonitoring( new OHostAPMonitoringInterface( iface ) ); break;
195 case 4: iface->setMonitoring( new OOrinocoMonitoringInterface( iface ) ); break; 195 case 4: iface->setMonitoring( new OOrinocoMonitoringInterface( iface ) ); break;
196 default: assert( 0 ); // shouldn't happen 196 default: assert( 0 ); // shouldn't happen
197 } 197 }
198 198
199 iface->setMonitorMode( true ); 199 iface->setMonitorMode( true );
200 200
201 // open pcap and start sniffing 201 // open pcap and start sniffing
202 pcap->open( interface ); 202 pcap->open( interface );
203 203
204 if ( !pcap->isOpen() ) 204 if ( !pcap->isOpen() )
205 { 205 {
206 QMessageBox::warning( this, "Wellenreiter II", "Can't open packet capturer:\n" + QString(strerror( errno ) )); 206 QMessageBox::warning( this, "Wellenreiter II", "Can't open packet capturer:\n" + QString(strerror( errno ) ));
207 return; 207 return;
208 } 208 }
209 209
210 // set capturer to non-blocking mode 210 // set capturer to non-blocking mode
211 pcap->setBlocking( false ); 211 pcap->setBlocking( false );
212 212
213 // start channel hopper 213 // start channel hopper
214 iface->setChannelHopping( 1000 ); //use interval from config window 214 iface->setChannelHopping( 1000 ); //use interval from config window
215 215
216 // connect 216 // connect
217 connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); 217 connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) );
218 218
219 logwindow->log( "(i) Daemon has been started." ); 219 logwindow->log( "(i) Daemon has been started." );
220 #ifdef QWS 220 #ifdef QWS
221 oApp->setTitle( "Scanning ..." ); 221 oApp->setTitle( "Scanning ..." );
222 #else 222 #else
223 qApp->mainWidget()->setCaption( "Wellenreiter II / Scanning ..." ); 223 qApp->mainWidget()->setCaption( "Wellenreiter II / Scanning ..." );
224 #endif 224 #endif
225 sniffing = true; 225 sniffing = true;
226 226
227 } 227 }
228} 228}