summaryrefslogtreecommitdiff
path: root/noncore/net/wellenreiter/gui
authormickeyl <mickeyl>2003-03-30 01:51:14 (UTC)
committer mickeyl <mickeyl>2003-03-30 01:51:14 (UTC)
commitd11a0154e2d9732854c9a3d598857bc20f359849 (patch) (unidiff)
treeaf0e0273d01f4f6c64c9f230f22bb91a7a8a21d8 /noncore/net/wellenreiter/gui
parent99899abc80a8aa05044eeecd8a061b0a8efaa713 (diff)
downloadopie-d11a0154e2d9732854c9a3d598857bc20f359849.zip
opie-d11a0154e2d9732854c9a3d598857bc20f359849.tar.gz
opie-d11a0154e2d9732854c9a3d598857bc20f359849.tar.bz2
- the network work for libopie2 pays off...
- good bye to wellenreiterd, t'was fun but always too unstable and too hard to maintain - good bye to libwellenreiter
Diffstat (limited to 'noncore/net/wellenreiter/gui') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/cardconfig.cpp29
-rw-r--r--noncore/net/wellenreiter/gui/cardconfig.h58
-rw-r--r--noncore/net/wellenreiter/gui/configbase.ui48
-rw-r--r--noncore/net/wellenreiter/gui/configwindow.cpp16
-rw-r--r--noncore/net/wellenreiter/gui/gui.pro10
-rw-r--r--noncore/net/wellenreiter/gui/main.cpp30
-rw-r--r--noncore/net/wellenreiter/gui/scanlist.h2
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp228
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.h31
-rw-r--r--noncore/net/wellenreiter/gui/wlan.cpp57
-rw-r--r--noncore/net/wellenreiter/gui/wlan.h38
11 files changed, 127 insertions, 420 deletions
diff --git a/noncore/net/wellenreiter/gui/cardconfig.cpp b/noncore/net/wellenreiter/gui/cardconfig.cpp
deleted file mode 100644
index 1ca1d27..0000000
--- a/noncore/net/wellenreiter/gui/cardconfig.cpp
+++ b/dev/null
@@ -1,29 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
3**
4** This file is part of Opie Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14**********************************************************************/
15
16#include "cardconfig.h"
17
18#include <qstring.h>
19
20CardConfig::CardConfig( const QString& interface, Type type, int hopinterval )
21 :_interface( interface ), _type( type ), _hopinterval( hopinterval )
22{
23
24}
25
26CardConfig::~CardConfig()
27{
28}
29
diff --git a/noncore/net/wellenreiter/gui/cardconfig.h b/noncore/net/wellenreiter/gui/cardconfig.h
deleted file mode 100644
index f54ebac..0000000
--- a/noncore/net/wellenreiter/gui/cardconfig.h
+++ b/dev/null
@@ -1,58 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
3**
4** This file is part of Opie Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14**********************************************************************/
15
16#ifndef CARDCONFIG_H
17#define CARDCONFIG_H
18
19#include <qstring.h>
20
21#ifdef QWS
22#include <opie/odevice.h>
23using namespace Opie;
24#endif
25
26class CardConfig
27{
28 public:
29
30 typedef enum { Prism, Orinoco, HostAP, Manual } Type;
31
32 public:
33
34 CardConfig( const QString& interface, Type type = Manual, int hopinterval = 100 );
35 virtual ~CardConfig();
36
37 const QString& interface() { return _interface; };
38 int hopinterval() { return _hopinterval; };
39 Type type() { return _type; };
40
41 #ifdef QWS
42 OSystem system() { return _system; };
43 #endif
44
45 private:
46
47 QString _interface;
48 Type _type;
49 int _hopinterval;
50
51 #ifdef QWS
52 OSystem _system;
53 #endif
54
55};
56
57#endif
58
diff --git a/noncore/net/wellenreiter/gui/configbase.ui b/noncore/net/wellenreiter/gui/configbase.ui
index 398118f..fa727f9 100644
--- a/noncore/net/wellenreiter/gui/configbase.ui
+++ b/noncore/net/wellenreiter/gui/configbase.ui
@@ -11,7 +11,7 @@
11 <rect> 11 <rect>
12 <x>0</x> 12 <x>0</x>
13 <y>0</y> 13 <y>0</y>
14 <width>220</width> 14 <width>212</width>
15 <height>267</height> 15 <height>267</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
@@ -103,48 +103,6 @@
103 </property> 103 </property>
104 <widget row="0" column="0" > 104 <widget row="0" column="0" >
105 <class>QComboBox</class> 105 <class>QComboBox</class>
106 <item>
107 <property>
108 <name>text</name>
109 <string>&lt;select&gt;</string>
110 </property>
111 </item>
112 <item>
113 <property>
114 <name>text</name>
115 <string>eth0</string>
116 </property>
117 </item>
118 <item>
119 <property>
120 <name>text</name>
121 <string>eth1</string>
122 </property>
123 </item>
124 <item>
125 <property>
126 <name>text</name>
127 <string>wlan0</string>
128 </property>
129 </item>
130 <item>
131 <property>
132 <name>text</name>
133 <string>wlan1</string>
134 </property>
135 </item>
136 <item>
137 <property>
138 <name>text</name>
139 <string>wifi0</string>
140 </property>
141 </item>
142 <item>
143 <property>
144 <name>text</name>
145 <string>wifi1</string>
146 </property>
147 </item>
148 <property stdset="1"> 106 <property stdset="1">
149 <name>name</name> 107 <name>name</name>
150 <cstring>interfaceName</cstring> 108 <cstring>interfaceName</cstring>
@@ -421,6 +379,10 @@
421 <cstring>beepOnFound</cstring> 379 <cstring>beepOnFound</cstring>
422 </property> 380 </property>
423 <property stdset="1"> 381 <property stdset="1">
382 <name>enabled</name>
383 <bool>false</bool>
384 </property>
385 <property stdset="1">
424 <name>text</name> 386 <name>text</name>
425 <string>Beep on new network</string> 387 <string>Beep on new network</string>
426 </property> 388 </property>
diff --git a/noncore/net/wellenreiter/gui/configwindow.cpp b/noncore/net/wellenreiter/gui/configwindow.cpp
index f86b109..6dd862f 100644
--- a/noncore/net/wellenreiter/gui/configwindow.cpp
+++ b/noncore/net/wellenreiter/gui/configwindow.cpp
@@ -13,13 +13,19 @@
13** 13**
14**********************************************************************/ 14**********************************************************************/
15 15
16/* LOCAL */
16#include "configwindow.h" 17#include "configwindow.h"
18
19/* QT */
17#include <qmap.h> 20#include <qmap.h>
18#include <qcombobox.h> 21#include <qcombobox.h>
19#include <qpushbutton.h> 22#include <qpushbutton.h>
20#include <qspinbox.h> 23#include <qspinbox.h>
21#include <qlayout.h> 24#include <qlayout.h>
22 25
26/* OPIE */
27#include <opie2/onetwork.h>
28
23WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f ) 29WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f )
24 :WellenreiterConfigBase( parent, name, true, f ) 30 :WellenreiterConfigBase( parent, name, true, f )
25{ 31{
@@ -29,6 +35,16 @@ WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char
29 _devicetype[ "orinoco" ] = 4; 35 _devicetype[ "orinoco" ] = 4;
30 _devicetype[ "<manual>" ] = 5; 36 _devicetype[ "<manual>" ] = 5;
31 37
38 // gather possible interface names from ONetwork
39 ONetwork* net = ONetwork::instance();
40 ONetwork::InterfaceIterator it = net->iterator();
41 while ( it.current() )
42 {
43 if ( it.current()->isWireless() )
44 interfaceName->insertItem( it.current()->name() );
45 ++it;
46 }
47
32 #ifdef Q_WS_X11 // We're on X11: adding an Ok-Button for the Dialog here 48 #ifdef Q_WS_X11 // We're on X11: adding an Ok-Button for the Dialog here
33 QPushButton* okButton = new QPushButton( "ok", this ); 49 QPushButton* okButton = new QPushButton( "ok", this );
34 okButton->show(); 50 okButton->show();
diff --git a/noncore/net/wellenreiter/gui/gui.pro b/noncore/net/wellenreiter/gui/gui.pro
index 8861a50..200bfc1 100644
--- a/noncore/net/wellenreiter/gui/gui.pro
+++ b/noncore/net/wellenreiter/gui/gui.pro
@@ -11,8 +11,6 @@ HEADERS = wellenreiterbase.h \
11 logwindow.h \ 11 logwindow.h \
12 hexwindow.h \ 12 hexwindow.h \
13 configwindow.h \ 13 configwindow.h \
14 wlan.h \
15 cardconfig.h \
16 manufacturers.h 14 manufacturers.h
17 15
18SOURCES = main.cpp \ 16SOURCES = main.cpp \
@@ -23,13 +21,11 @@ SOURCES = main.cpp \
23 logwindow.cpp \ 21 logwindow.cpp \
24 hexwindow.cpp \ 22 hexwindow.cpp \
25 configwindow.cpp \ 23 configwindow.cpp \
26 wlan.cpp \
27 cardconfig.cpp \
28 manufacturers.cpp 24 manufacturers.cpp
29 25
30INCLUDEPATH += $(OPIEDIR)/include ../ 26INCLUDEPATH += $(OPIEDIR)/include
31DEPENDPATH += $(OPIEDIR)/include ../ 27DEPENDPATH += $(OPIEDIR)/include
32LIBS += -L. -lwellenreiter -lcornucopia 28LIBS += -L. -lwellenreiter -lopiecore2 -lopieui2 -lopienet2
33INTERFACES = configbase.ui 29INTERFACES = configbase.ui
34TARGET = wellenreiter 30TARGET = wellenreiter
35 31
diff --git a/noncore/net/wellenreiter/gui/main.cpp b/noncore/net/wellenreiter/gui/main.cpp
index 270ce06..96a8c1c 100644
--- a/noncore/net/wellenreiter/gui/main.cpp
+++ b/noncore/net/wellenreiter/gui/main.cpp
@@ -14,30 +14,14 @@
14**********************************************************************/ 14**********************************************************************/
15 15
16#include "mainwindow.h" 16#include "mainwindow.h"
17 17#include <opie2/oapplication.h>
18#ifdef QWS
19#include <qpe/qpeapplication.h>
20#else
21#include <qapplication.h>
22#endif
23 18
24int main( int argc, char **argv ) 19int main( int argc, char **argv )
25{ 20{
26#ifdef QWS 21 OApplication a( argc, argv, "Wellenreiter II" );
27 QPEApplication a( argc, argv ); 22 WellenreiterMainWindow* w = new WellenreiterMainWindow();
28#else 23 a.showMainWidget( w );
29 QApplication a( argc, argv ); 24 a.exec();
30#endif 25 delete w;
31 26 return 0;
32 WellenreiterMainWindow w;
33
34 w.setCaption( "Wellenreiter/Opie" );
35#ifdef QWS
36 a.showMainWidget(&w);
37#else
38 a.setMainWidget(&w);
39 w.show();
40#endif
41
42 return a.exec();
43} 27}
diff --git a/noncore/net/wellenreiter/gui/scanlist.h b/noncore/net/wellenreiter/gui/scanlist.h
index 222217c..da9369f 100644
--- a/noncore/net/wellenreiter/gui/scanlist.h
+++ b/noncore/net/wellenreiter/gui/scanlist.h
@@ -16,7 +16,7 @@
16#ifndef SCANLIST_H 16#ifndef SCANLIST_H
17#define SCANLIST_H 17#define SCANLIST_H
18 18
19#include <cornucopia/olistview.h> 19#include <opie2/olistview.h>
20 20
21#include <qtextstream.h> 21#include <qtextstream.h>
22 22
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index 09a44e6..5bdc1b3 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -21,13 +21,6 @@
21#include <qspinbox.h> 21#include <qspinbox.h>
22#include <qsocketnotifier.h> 22#include <qsocketnotifier.h>
23 23
24// Qtopia
25
26#ifdef QWS
27#include <qpe/qpeapplication.h>
28#include <qpe/global.h>
29#endif
30
31// Opie 24// Opie
32 25
33#ifdef QWS 26#ifdef QWS
@@ -35,6 +28,10 @@
35using namespace Opie; 28using namespace Opie;
36#endif 29#endif
37 30
31#include <opie2/oapplication.h>
32#include <opie2/onetwork.h>
33#include <opie2/opcap.h>
34
38// Standard 35// Standard
39 36
40#include <assert.h> 37#include <assert.h>
@@ -42,9 +39,7 @@ using namespace Opie;
42#include <unistd.h> 39#include <unistd.h>
43#include <string.h> 40#include <string.h>
44#include <sys/types.h> 41#include <sys/types.h>
45#include <sys/socket.h>
46#include <stdlib.h> 42#include <stdlib.h>
47#include <fcntl.h>
48 43
49// Local 44// Local
50 45
@@ -56,14 +51,9 @@ using namespace Opie;
56 51
57#include "manufacturers.h" 52#include "manufacturers.h"
58 53
59#include <daemon/source/config.hh>
60#include <libwellenreiter/source/wl_types.hh>
61#include <libwellenreiter/source/wl_sock.hh>
62#include <libwellenreiter/source/wl_proto.hh>
63
64Wellenreiter::Wellenreiter( QWidget* parent ) 54Wellenreiter::Wellenreiter( QWidget* parent )
65 : WellenreiterBase( parent, 0, 0 ), 55 : WellenreiterBase( parent, 0, 0 ),
66 daemonRunning( false ), manufacturerdb( 0 ), configwindow( 0 ) 56 sniffing( false ), iface( 0 ), manufacturerdb( 0 ), configwindow( 0 )
67{ 57{
68 58
69 // 59 //
@@ -91,31 +81,14 @@ Wellenreiter::Wellenreiter( QWidget* parent )
91 logwindow->log( sys ); 81 logwindow->log( sys );
92 #endif 82 #endif
93 83
94 //
95 // setup socket for daemon communication, register socket notifier
96 //
97
98 // struct sockaddr_in sockaddr;
99 daemon_fd = wl_setupsock( GUIADDR, GUIPORT, sockaddr );
100 if ( daemon_fd == -1 )
101 {
102 logwindow->log( "(E) Couldn't get file descriptor for commsocket." );
103 }
104 else
105 {
106 int flags;
107 flags = fcntl( daemon_fd, F_GETFL, 0 );
108 fcntl( daemon_fd, F_SETFL, flags | O_NONBLOCK );
109 QSocketNotifier *sn = new QSocketNotifier( daemon_fd, QSocketNotifier::Read, this );
110 connect( sn, SIGNAL( activated( int ) ), this, SLOT( dataReceived() ) );
111 }
112
113 // setup GUI 84 // setup GUI
114 netview->setColumnWidthMode( 1, QListView::Manual ); 85 netview->setColumnWidthMode( 1, QListView::Manual );
115 86
116 if ( manufacturerdb ) 87 if ( manufacturerdb )
117 netview->setManufacturerDB( manufacturerdb ); 88 netview->setManufacturerDB( manufacturerdb );
118 89
90 pcap = new OPacketCapturer();
91
119} 92}
120 93
121Wellenreiter::~Wellenreiter() 94Wellenreiter::~Wellenreiter()
@@ -123,14 +96,7 @@ Wellenreiter::~Wellenreiter()
123 // no need to delete child widgets, Qt does it all for us 96 // no need to delete child widgets, Qt does it all for us
124 97
125 delete manufacturerdb; 98 delete manufacturerdb;
126 99 delete pcap;
127 if ( daemon_fd != -1 )
128 {
129 qDebug( "closing comm socket" );
130 ::shutdown( daemon_fd, 0 );
131 ::close( daemon_fd );
132 qDebug( "comm socket closed." );
133 }
134} 100}
135 101
136void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) 102void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw )
@@ -138,145 +104,125 @@ void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw )
138 configwindow = cw; 104 configwindow = cw;
139} 105}
140 106
141void Wellenreiter::handleMessage() 107void Wellenreiter::receivePacket(OPacket* p)
142{ 108{
143 // FIXME: receive message and handle it 109 logwindow->log( "(d) Received data from daemon" );
144 110 //TODO
145 qDebug( "received message from daemon." );
146
147 /*char buffer[10000];
148 memset( &buffer, 0, sizeof( buffer ) );*/
149
150 char buffer[WL_SOCKBUF];
151
152 // int result = #wl_recv( &daemon_fd, (char*) &buffer, sizeof(buffer) );
153
154 /*
155
156 struct sockaddr from;
157 socklen_t len;
158
159 int result = recvfrom( daemon_fd, &buffer, 8192, MSG_WAITALL, &from, &len );
160 qDebug( "received %d from recv [%d bytes]", result, len );
161
162 */
163
164 int result = wl_recv( &daemon_fd, sockaddr, (char*) &buffer, WL_SOCKBUF );
165
166 if ( result == -1 )
167 {
168 qDebug( "Warning: %s", strerror( errno ) );
169 return;
170 }
171
172 int command = buffer[1] - 48;
173
174/*
175typedef struct {
176 int net_type; 1 = Accesspoint ; 2 = Ad-Hoc
177 int ssid_len; Length of SSID
178 int channel; Channel
179 int wep; 1 = WEP enabled ; 0 = disabled
180 char mac[64]; MAC address of Accesspoint
181 char bssid[128]; BSSID of Accesspoint
182} wl_network_t;
183*/
184
185 qDebug( "Recv result: %d", ( result ) );
186 qDebug( "Sniffer sent: '%s'", (const char*) buffer );
187 hexwindow->log( (const char*) &buffer );
188
189 if ( command == NETFOUND ) /* new network found */
190 {
191 qDebug( "Sniffer said: new network found." );
192 wl_network_t n;
193 get_network_found( &n, (char*) &buffer );
194
195 qDebug( "Sniffer said: net_type is %d.", n.net_type );
196 qDebug( "Sniffer said: MAC is %s", (const char*) &n.mac );
197
198 //n.bssid[n.ssid_len] = "\0";
199
200 QString type;
201
202 if ( n.net_type == 1 )
203 type = "managed";
204 else
205 type = "adhoc";
206 111
207 netview->addNewItem( type, n.bssid, QString( (const char*) &n.mac ), n.wep, n.channel, 0 ); 112 // check if we received a beacon frame
113 // static_cast is justified here
114 OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) );
115 if ( !beacon ) return;
116 QString type;
208 117
209 } 118 //FIXME: Can stations in ESS mode can be distinguished from APs?
119 //FIXME: Apparently yes, but not by listening to beacons, because
120 //FIXME: they simply don't send beacons in infrastructure mode.
121 //FIXME: so we also have to listen to data packets
210 122
123 if ( beacon->canIBSS() )
124 type = "adhoc";
211 else 125 else
126 type = "managed";
212 127
213 { 128 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) );
214 qDebug( "unknown sniffer command." ); 129 QString essid = ssid ? ssid->ID() : "<unknown>";
215 } 130 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) );
131 int channel = ds ? ds->channel() : -1;
216 132
217} 133 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) );
218 134 netView()->addNewItem( type, essid, header->macAddress2().toString(), header->usesWep(), channel, 0 );
219void Wellenreiter::dataReceived()
220{
221 logwindow->log( "(d) Received data from daemon" );
222 handleMessage();
223} 135}
224 136
225void Wellenreiter::startStopClicked() 137void Wellenreiter::startStopClicked()
226{ 138{
227 if ( daemonRunning ) 139 if ( sniffing )
228 { 140 {
229 daemonRunning = false; 141 disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) );
230 142
231 logwindow->log( "(i) Daemon has been stopped." ); 143 iface->setChannelHopping(); // stop hopping channels
232 setCaption( tr( "Wellenreiter/Opie" ) ); 144 pcap->close();
145 sniffing = false;
146 oApp->setTitle();
233 147
234 // Stop daemon - ugly for now... later better 148 // get interface name from config window
149 const QString& interface = configwindow->interfaceName->currentText();
150 ONetwork* net = ONetwork::instance();
151 iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface ));
235 152
236 system( "killall wellenreiterd" ); 153 // switch off monitor mode
154 iface->setMonitorMode( false );
155 // switch off promisc flag
156 iface->setPromiscuousMode( false );
237 157
238 // get configuration from config window 158 //TODO: Display "please wait..." (use owait?)
239 159
240 const QString& interface = configwindow->interfaceName->currentText(); 160 /*
241
242 // reset the interface trying to get it into a usable state again
243 161
244 QString cmdline; 162 QString cmdline;
245 cmdline.sprintf( "iwpriv %s monitor 0; ifdown %s; ifup %s", (const char*) interface, (const char*) interface, (const char*) interface ); 163 cmdline.sprintf( "ifdown %s; sleep 1; ifup %s", (const char*) interface, (const char*) interface, (const char*) interface );
246 system( cmdline ); 164 system( cmdline ); //FIXME: Use OProcess
165
166 */
247 167
248 // message the user 168 // message the user
249 169
250 QMessageBox::information( this, "Wellenreiter/Opie", "Your wireless card\nshould now be usable again." ); 170 //QMessageBox::information( this, "Wellenreiter II", "Your wireless card\nshould now be usable again." );
251 } 171 }
252 172
253 else 173 else
254 { 174 {
255
256 // get configuration from config window 175 // get configuration from config window
257 176
258 const QString& interface = configwindow->interfaceName->currentText(); 177 const QString& interface = configwindow->interfaceName->currentText();
259 const int cardtype = configwindow->daemonDeviceType(); 178 const int cardtype = configwindow->daemonDeviceType();
260 const int interval = configwindow->daemonHopInterval(); 179 const int interval = configwindow->daemonHopInterval();
261 180
262 if ( ( interface == "<select>" ) || ( cardtype == 0 ) ) 181 if ( ( interface == "" ) || ( cardtype == 0 ) )
263 { 182 {
264 QMessageBox::information( this, "Wellenreiter/Opie", "Your device is not\nptoperly configured. Please reconfigure!" ); 183 QMessageBox::information( this, "Wellenreiter II", "Your device is not\nproperly configured. Please reconfigure!" );
265 return; 184 return;
266 } 185 }
267 186
268 // start wellenreiterd 187 // configure device
269 188
270 QString cmdline; 189 ONetwork* net = ONetwork::instance();
271 cmdline.sprintf( "wellenreiterd %s %d &", (const char*) interface, cardtype ); 190 iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface ));
191
192 // set monitor mode
193
194 switch ( cardtype )
195 {
196 case 1: iface->setMonitoring( new OCiscoMonitoringInterface( iface ) ); break;
197 case 2: iface->setMonitoring( new OWlanNGMonitoringInterface( iface ) ); break;
198 case 3: iface->setMonitoring( new OHostAPMonitoringInterface( iface ) ); break;
199 case 4: iface->setMonitoring( new OOrinocoMonitoringInterface( iface ) ); break;
200 default: assert( 0 ); // shouldn't happen
201 }
202
203 iface->setMonitorMode( true );
204
205 // open pcap and start sniffing
206 pcap->open( interface );
207
208 if ( !pcap->isOpen() )
209 {
210 QMessageBox::warning( this, "Wellenreiter II", "Can't open packet capturer:\n" + QString(strerror( errno ) ));
211 return;
212 }
213
214 // set capturer to non-blocking mode
215 pcap->setBlocking( false );
216
217 // start channel hopper
218 iface->setChannelHopping( 1000 ); //use interval from config window
272 219
273 qDebug( "about to execute '%s' ...", (const char*) cmdline ); 220 // connect
274 system( cmdline ); 221 connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) );
275 qDebug( "done!" );
276 222
277 logwindow->log( "(i) Daemon has been started." ); 223 logwindow->log( "(i) Daemon has been started." );
278 daemonRunning = true; 224 oApp->setTitle( "Scanning ..." );
279 setCaption( tr( "Scanning ..." ) ); 225 sniffing = true;
280 226
281 } 227 }
282} 228}
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.h b/noncore/net/wellenreiter/gui/wellenreiter.h
index ee9dca9..3ec4021 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.h
+++ b/noncore/net/wellenreiter/gui/wellenreiter.h
@@ -23,23 +23,11 @@
23using namespace Opie; 23using namespace Opie;
24#endif 24#endif
25 25
26// ugly... not here!
27
28#include <assert.h>
29#include <errno.h>
30#include <unistd.h>
31#include <string.h>
32#include <sys/types.h>
33#include <sys/socket.h>
34#include <stdlib.h>
35#include <fcntl.h>
36#include <daemon/source/config.hh>
37#include <libwellenreiter/source/wl_types.hh>
38#include <libwellenreiter/source/wl_sock.hh>
39#include <libwellenreiter/source/wl_proto.hh>
40
41class QTimerEvent; 26class QTimerEvent;
42class QPixmap; 27class QPixmap;
28class OPacket;
29class OPacketCapturer;
30class OWirelessNetworkInterface;
43class ManufacturerDB; 31class ManufacturerDB;
44class WellenreiterConfigWindow; 32class WellenreiterConfigWindow;
45 33
@@ -53,25 +41,22 @@ class Wellenreiter : public WellenreiterBase {
53 void setConfigWindow( WellenreiterConfigWindow* cw ); 41 void setConfigWindow( WellenreiterConfigWindow* cw );
54 MScanListView* netView() const { return netview; }; 42 MScanListView* netView() const { return netview; };
55 MLogWindow* logWindow() const { return logwindow; }; 43 MLogWindow* logWindow() const { return logwindow; };
56 bool isDaemonRunning() const { return daemonRunning; }; 44 bool isDaemonRunning() const { return sniffing; };
57
58 protected:
59 bool daemonRunning;
60 45
61 public slots: 46 public slots:
62 void dataReceived(); 47 void receivePacket(OPacket*);
63 void startStopClicked(); 48 void startStopClicked();
64 49
65 private: 50 private:
66 int daemon_fd; // socket filedescriptor for udp communication socket
67 #ifdef QWS 51 #ifdef QWS
68 OSystem _system; // Opie Operating System identifier 52 OSystem _system; // Opie Operating System identifier
69 #endif 53 #endif
70 void handleMessage();
71 54
55 bool sniffing;
56 OWirelessNetworkInterface* iface;
57 OPacketCapturer* pcap;
72 ManufacturerDB* manufacturerdb; 58 ManufacturerDB* manufacturerdb;
73 WellenreiterConfigWindow* configwindow; 59 WellenreiterConfigWindow* configwindow;
74 struct sockaddr_in sockaddr;
75 60
76 //void readConfig(); 61 //void readConfig();
77 //void writeConfig(); 62 //void writeConfig();
diff --git a/noncore/net/wellenreiter/gui/wlan.cpp b/noncore/net/wellenreiter/gui/wlan.cpp
deleted file mode 100644
index b046cc8..0000000
--- a/noncore/net/wellenreiter/gui/wlan.cpp
+++ b/dev/null
@@ -1,57 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
3**
4** This file is part of Opie Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14**********************************************************************/
15
16#include "wlan.h"
17#include "cardconfig.h"
18
19// Qt
20#include <qstring.h>
21
22// Qtopia
23#ifdef QWS
24#include <opie/odevice.h>
25using namespace Opie;
26#endif
27
28WLAN::WLAN( const QString& interface )
29{
30 _configuration = new CardConfig( interface );
31}
32
33WLAN::WLAN( const CardConfig* configuration )
34{
35 _configuration = configuration;
36
37}
38
39WLAN::~WLAN()
40{
41 delete _configuration;
42
43}
44
45void WLAN::setMonitorMode( bool enabled )
46{
47
48 /*
49
50 if ( _configuration->system() == System_OpenZaurus && _configuration->type() == CardConfig::Prism )
51 {
52 }
53
54 */
55
56}
57
diff --git a/noncore/net/wellenreiter/gui/wlan.h b/noncore/net/wellenreiter/gui/wlan.h
deleted file mode 100644
index 139e218..0000000
--- a/noncore/net/wellenreiter/gui/wlan.h
+++ b/dev/null
@@ -1,38 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
3**
4** This file is part of Opie Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14**********************************************************************/
15
16#ifndef WLAN_H
17#define WLAN_H
18
19class QString;
20class CardConfig;
21
22class WLAN
23{
24 public:
25
26 WLAN( const QString& interface );
27 WLAN( const CardConfig* );
28 virtual ~WLAN();
29 void setMonitorMode( bool enabled );
30
31 private:
32
33 const CardConfig* _configuration;
34
35};
36
37#endif
38