author | mickeyl <mickeyl> | 2002-12-29 17:28:26 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2002-12-29 17:28:26 (UTC) |
commit | e829097195e5c4b07c79ba22e168d3ae3ded4489 (patch) (unidiff) | |
tree | 166cf184a01806be74f9b3c61c94d9109daf2afc | |
parent | 8f6559d4be4e0b1857c4ae5cdbf1ad8b485b638b (diff) | |
download | opie-e829097195e5c4b07c79ba22e168d3ae3ded4489.zip opie-e829097195e5c4b07c79ba22e168d3ae3ded4489.tar.gz opie-e829097195e5c4b07c79ba22e168d3ae3ded4489.tar.bz2 |
added a manufacturer database class
-rw-r--r-- | noncore/net/wellenreiter/gui/gui-x11.pro | 4 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/gui.pro | 4 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/manufacturers.cpp | 58 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/manufacturers.h | 37 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlistitem.h | 22 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 16 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.h | 5 |
7 files changed, 141 insertions, 5 deletions
diff --git a/noncore/net/wellenreiter/gui/gui-x11.pro b/noncore/net/wellenreiter/gui/gui-x11.pro index 523bf15..c2a4394 100644 --- a/noncore/net/wellenreiter/gui/gui-x11.pro +++ b/noncore/net/wellenreiter/gui/gui-x11.pro | |||
@@ -1,11 +1,11 @@ | |||
1 | DESTDIR = . | 1 | DESTDIR = . |
2 | TEMPLATE = app | 2 | TEMPLATE = app |
3 | CONFIG = qt warn_on debug | 3 | CONFIG = qt warn_on debug |
4 | #CONFIG = qt warn_on release | 4 | #CONFIG = qt warn_on release |
5 | HEADERS = wellenreiterbase.h wellenreiter.h scanlistitem.h scanlist.h logwindow.h hexwindow.h configwindow.h resource.h wlan.h cardconfig.h | 5 | HEADERS = wellenreiterbase.h wellenreiter.h scanlistitem.h scanlist.h logwindow.h hexwindow.h configwindow.h resource.h wlan.h cardconfig.h manufacturers.h |
6 | SOURCES = main.cpp wellenreiterbase.cpp wellenreiter.cpp scanlistitem.cpp scanlist.cpp logwindow.cpp hexwindow.cpp configwindow.cpp resource.cpp wlan.cpp cardconfig.cpp | 6 | SOURCES = main.cpp wellenreiterbase.cpp wellenreiter.cpp scanlistitem.cpp scanlist.cpp logwindow.cpp hexwindow.cpp configwindow.cpp resource.cpp wlan.cpp cardconfig.cpp manufacturers.cpp |
7 | INCLUDEPATH += ../ | 7 | INCLUDEPATH += ../ |
8 | DEPENDPATH += ../ | 8 | DEPENDPATH += ../ |
9 | LIBS += -L. -lwellenreiter | 9 | LIBS += -L. -lwellenreiter |
10 | INTERFACES = configbase.ui | 10 | INTERFACES = configbase.ui |
11 | TARGET = wellenreiter | 11 | TARGET = wellenreiter |
diff --git a/noncore/net/wellenreiter/gui/gui.pro b/noncore/net/wellenreiter/gui/gui.pro index ce1c387..52ed8c6 100644 --- a/noncore/net/wellenreiter/gui/gui.pro +++ b/noncore/net/wellenreiter/gui/gui.pro | |||
@@ -1,11 +1,11 @@ | |||
1 | DESTDIR = $(OPIEDIR)/bin | 1 | DESTDIR = $(OPIEDIR)/bin |
2 | TEMPLATE = app | 2 | TEMPLATE = app |
3 | CONFIG = qt warn_on debug | 3 | CONFIG = qt warn_on debug |
4 | #CONFIG = qt warn_on release | 4 | #CONFIG = qt warn_on release |
5 | HEADERS = wellenreiterbase.h wellenreiter.h scanlistitem.h scanlist.h logwindow.h hexwindow.h configwindow.h wlan.h cardconfig.h | 5 | HEADERS = wellenreiterbase.h wellenreiter.h scanlistitem.h scanlist.h logwindow.h hexwindow.h configwindow.h wlan.h cardconfig.h manufacturers.h |
6 | SOURCES = main.cpp wellenreiterbase.cpp wellenreiter.cpp scanlistitem.cpp scanlist.cpp logwindow.cpp hexwindow.cpp configwindow.cpp wlan.cpp cardconfig.cpp | 6 | SOURCES = main.cpp wellenreiterbase.cpp wellenreiter.cpp scanlistitem.cpp scanlist.cpp logwindow.cpp hexwindow.cpp configwindow.cpp wlan.cpp cardconfig.cpp manufacturers.h |
7 | INCLUDEPATH += $(OPIEDIR)/include ../ | 7 | INCLUDEPATH += $(OPIEDIR)/include ../ |
8 | DEPENDPATH += $(OPIEDIR)/include ../ | 8 | DEPENDPATH += $(OPIEDIR)/include ../ |
9 | LIBS += -lqpe -lopie -L. -lwellenreiter | 9 | LIBS += -lqpe -lopie -L. -lwellenreiter |
10 | INTERFACES = configbase.ui | 10 | INTERFACES = configbase.ui |
11 | TARGET = wellenreiter | 11 | TARGET = wellenreiter |
diff --git a/noncore/net/wellenreiter/gui/manufacturers.cpp b/noncore/net/wellenreiter/gui/manufacturers.cpp new file mode 100644 index 0000000..d235989 --- a/dev/null +++ b/noncore/net/wellenreiter/gui/manufacturers.cpp | |||
@@ -0,0 +1,58 @@ | |||
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 "manufacturers.h" | ||
17 | |||
18 | // Qt | ||
19 | #include <qstring.h> | ||
20 | #include <qfile.h> | ||
21 | #include <qtextstream.h> | ||
22 | |||
23 | ManufacturerDB::ManufacturerDB( const QString& filename ) | ||
24 | { | ||
25 | QFile file( filename ); | ||
26 | bool hasFile = file.open( IO_ReadOnly ); | ||
27 | if (!hasFile) | ||
28 | { | ||
29 | qDebug( "ManufacturerDB: D'oh! Manufacturer list '%s' not found!", (const char*) filename ); | ||
30 | } | ||
31 | else | ||
32 | { | ||
33 | qDebug( "ManufacturerDB: reading manufacturer list from '%s'...", (const char*) filename ); | ||
34 | QTextStream s( &file ); | ||
35 | QString addr; | ||
36 | QString manu; | ||
37 | |||
38 | while (!s.atEnd()) | ||
39 | { | ||
40 | s >> addr; | ||
41 | s.skipWhiteSpace(); | ||
42 | manu = s.readLine(); | ||
43 | qDebug( "ManufacturerDB: read pair %s, %s", (const char*) addr, (const char*) manu ); | ||
44 | manufacturers.insert( addr, manu ); | ||
45 | |||
46 | } | ||
47 | } | ||
48 | |||
49 | } | ||
50 | |||
51 | ManufacturerDB::~ManufacturerDB() | ||
52 | { | ||
53 | } | ||
54 | |||
55 | QString ManufacturerDB::lookup( const QString& macaddr ) | ||
56 | { | ||
57 | return manufacturers[macaddr.upper().left(8)]; | ||
58 | } | ||
diff --git a/noncore/net/wellenreiter/gui/manufacturers.h b/noncore/net/wellenreiter/gui/manufacturers.h new file mode 100644 index 0000000..d69977a --- a/dev/null +++ b/noncore/net/wellenreiter/gui/manufacturers.h | |||
@@ -0,0 +1,37 @@ | |||
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 MANUFACTURERS_H | ||
17 | #define MANUFACTURERS_H | ||
18 | |||
19 | #include <qmap.h> | ||
20 | #include <string.h> | ||
21 | |||
22 | class ManufacturerDB | ||
23 | { | ||
24 | public: | ||
25 | |||
26 | ManufacturerDB( const QString& filename ); | ||
27 | virtual ~ManufacturerDB(); | ||
28 | QString lookup( const QString& macaddr ); | ||
29 | |||
30 | private: | ||
31 | |||
32 | QMap<QString, QString> manufacturers; | ||
33 | |||
34 | }; | ||
35 | |||
36 | #endif | ||
37 | |||
diff --git a/noncore/net/wellenreiter/gui/scanlistitem.h b/noncore/net/wellenreiter/gui/scanlistitem.h index cd9d883..47a5a4e 100644 --- a/noncore/net/wellenreiter/gui/scanlistitem.h +++ b/noncore/net/wellenreiter/gui/scanlistitem.h | |||
@@ -1,55 +1,77 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. | 2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Opie Environment. | 4 | ** This file is part of Opie Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 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 | 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 | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 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. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | **********************************************************************/ | 14 | **********************************************************************/ |
15 | 15 | ||
16 | #ifndef SCANLISTITEM_H | 16 | #ifndef SCANLISTITEM_H |
17 | #define SCANLISTITEM_H | 17 | #define SCANLISTITEM_H |
18 | 18 | ||
19 | #include <qlistview.h> | 19 | #include <qlistview.h> |
20 | 20 | ||
21 | class QString; | 21 | class QString; |
22 | 22 | ||
23 | class MScanListItem: public QListViewItem | 23 | class MScanListItem: public QListViewItem |
24 | { | 24 | { |
25 | public: | 25 | public: |
26 | 26 | ||
27 | MScanListItem::MScanListItem( QListView* parent, | 27 | MScanListItem::MScanListItem( QListView* parent, |
28 | QString type, | 28 | QString type, |
29 | QString essid, | 29 | QString essid, |
30 | QString macaddr, | 30 | QString macaddr, |
31 | bool wep, | 31 | bool wep, |
32 | int channel, | 32 | int channel, |
33 | int signal ); | 33 | int signal ); |
34 | 34 | ||
35 | MScanListItem::MScanListItem( QListViewItem* parent, | 35 | MScanListItem::MScanListItem( QListViewItem* parent, |
36 | QString type, | 36 | QString type, |
37 | QString essid, | 37 | QString essid, |
38 | QString macaddr, | 38 | QString macaddr, |
39 | bool wep, | 39 | bool wep, |
40 | int channel, | 40 | int channel, |
41 | int signal ); | 41 | int signal ); |
42 | 42 | ||
43 | 43 | ||
44 | protected: | 44 | protected: |
45 | 45 | ||
46 | virtual void decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ); | 46 | virtual void decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ); |
47 | 47 | ||
48 | public: | 48 | public: |
49 | 49 | ||
50 | QString type; | 50 | QString type; |
51 | 51 | ||
52 | public: | ||
53 | |||
54 | //const QString& type() { return _type; }; | ||
55 | const QString& essid() { return _essid; }; | ||
56 | const QString& macaddr() { return _macaddr; }; | ||
57 | bool wep() { return _wep; }; | ||
58 | int channel() { return _channel; }; | ||
59 | int signal() { return _signal; }; | ||
60 | int received() { return _received; }; | ||
61 | |||
62 | void setSignal( int signal ) { /* TODO */ }; | ||
63 | void incReceived() { _received++; }; | ||
64 | |||
65 | private: | ||
66 | QString _type; | ||
67 | QString _essid; | ||
68 | QString _macaddr; | ||
69 | bool _wep; | ||
70 | int _channel; | ||
71 | int _signal; | ||
72 | int _received; | ||
73 | |||
52 | }; | 74 | }; |
53 | 75 | ||
54 | #endif | 76 | #endif |
55 | 77 | ||
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index 2d9bbee..9068e3a 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp | |||
@@ -1,268 +1,284 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. | 2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Opie Environment. | 4 | ** This file is part of Opie Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 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 | 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 | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 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. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ***********************************************************************/ | 14 | ***********************************************************************/ |
15 | 15 | ||
16 | // Qt | 16 | // Qt |
17 | 17 | ||
18 | #include <qpushbutton.h> | 18 | #include <qpushbutton.h> |
19 | #include <qmessagebox.h> | 19 | #include <qmessagebox.h> |
20 | #include <qcombobox.h> | 20 | #include <qcombobox.h> |
21 | #include <qspinbox.h> | 21 | #include <qspinbox.h> |
22 | #include <qsocketnotifier.h> | 22 | #include <qsocketnotifier.h> |
23 | 23 | ||
24 | // Qtopia | 24 | // Qtopia |
25 | 25 | ||
26 | #ifdef QWS | 26 | #ifdef QWS |
27 | #include <qpe/global.h> | 27 | #include <qpe/global.h> |
28 | #endif | 28 | #endif |
29 | 29 | ||
30 | // Opie | 30 | // Opie |
31 | 31 | ||
32 | #ifdef QWS | 32 | #ifdef QWS |
33 | #include <opie/odevice.h> | 33 | #include <opie/odevice.h> |
34 | using namespace Opie; | 34 | using namespace Opie; |
35 | #endif | 35 | #endif |
36 | 36 | ||
37 | // Standard | 37 | // Standard |
38 | 38 | ||
39 | #include <assert.h> | 39 | #include <assert.h> |
40 | #include <errno.h> | 40 | #include <errno.h> |
41 | #include <unistd.h> | 41 | #include <unistd.h> |
42 | #include <string.h> | 42 | #include <string.h> |
43 | #include <sys/types.h> | 43 | #include <sys/types.h> |
44 | #include <sys/socket.h> | 44 | #include <sys/socket.h> |
45 | #include <stdlib.h> | 45 | #include <stdlib.h> |
46 | #include <fcntl.h> | 46 | #include <fcntl.h> |
47 | 47 | ||
48 | // Local | 48 | // Local |
49 | 49 | ||
50 | #include "wellenreiter.h" | 50 | #include "wellenreiter.h" |
51 | #include "scanlist.h" | 51 | #include "scanlist.h" |
52 | #include "logwindow.h" | 52 | #include "logwindow.h" |
53 | #include "hexwindow.h" | 53 | #include "hexwindow.h" |
54 | #include "configwindow.h" | 54 | #include "configwindow.h" |
55 | 55 | ||
56 | #include "manufacturers.h" | ||
57 | |||
56 | #include <libwellenreiter/source/wl_sock.hh> | 58 | #include <libwellenreiter/source/wl_sock.hh> |
57 | #include <libwellenreiter/source/wl_proto.hh> | 59 | #include <libwellenreiter/source/wl_proto.hh> |
58 | #include <daemon/source/config.hh> | 60 | #include <daemon/source/config.hh> |
59 | 61 | ||
60 | Wellenreiter::Wellenreiter( QWidget* parent, const char* name, WFlags fl ) | 62 | Wellenreiter::Wellenreiter( QWidget* parent, const char* name, WFlags fl ) |
61 | : WellenreiterBase( parent, name, fl ), daemonRunning( false ) | 63 | : WellenreiterBase( parent, name, fl ), daemonRunning( false ) |
62 | { | 64 | { |
63 | 65 | ||
66 | // | ||
67 | // construct manufacturer database | ||
68 | // | ||
69 | |||
70 | QString manufile; | ||
71 | #ifdef QWS | ||
72 | manufile.sprintf( "%s/share/wellenreiter/manufacturers.dat", (const char*) qApp.qpeDir() ); | ||
73 | #else | ||
74 | manufile.sprintf( "/home/mickey/work/opie/share/wellenreiter/manufacturers.dat" ); | ||
75 | #endif | ||
76 | manufacturerdb = new ManufacturerDB( manufile ); | ||
77 | |||
64 | logwindow->log( "(i) Wellenreiter has been started." ); | 78 | logwindow->log( "(i) Wellenreiter has been started." ); |
65 | 79 | ||
66 | // | 80 | // |
67 | // detect operating system | 81 | // detect operating system |
68 | // | 82 | // |
69 | 83 | ||
70 | #ifdef QWS | 84 | #ifdef QWS |
71 | QString sys; | 85 | QString sys; |
72 | sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); | 86 | sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); |
73 | _system = ODevice::inst()->system(); | 87 | _system = ODevice::inst()->system(); |
74 | logwindow->log( sys ); | 88 | logwindow->log( sys ); |
75 | #endif | 89 | #endif |
76 | 90 | ||
77 | // | 91 | // |
78 | // setup socket for daemon communication, register socket notifier | 92 | // setup socket for daemon communication, register socket notifier |
79 | // | 93 | // |
80 | 94 | ||
81 | daemon_fd = wl_setupsock( GUIADDR, GUIPORT ); | 95 | daemon_fd = wl_setupsock( GUIADDR, GUIPORT ); |
82 | if ( daemon_fd == -1 ) | 96 | if ( daemon_fd == -1 ) |
83 | { | 97 | { |
84 | logwindow->log( "(E) Couldn't get file descriptor for commsocket." ); | 98 | logwindow->log( "(E) Couldn't get file descriptor for commsocket." ); |
85 | } | 99 | } |
86 | else | 100 | else |
87 | { | 101 | { |
88 | int flags; | 102 | int flags; |
89 | flags = fcntl( daemon_fd, F_GETFL, 0 ); | 103 | flags = fcntl( daemon_fd, F_GETFL, 0 ); |
90 | fcntl( daemon_fd, F_SETFL, flags | O_NONBLOCK ); | 104 | fcntl( daemon_fd, F_SETFL, flags | O_NONBLOCK ); |
91 | QSocketNotifier *sn = new QSocketNotifier( daemon_fd, QSocketNotifier::Read, parent ); | 105 | QSocketNotifier *sn = new QSocketNotifier( daemon_fd, QSocketNotifier::Read, parent ); |
92 | connect( sn, SIGNAL( activated( int ) ), this, SLOT( dataReceived() ) ); | 106 | connect( sn, SIGNAL( activated( int ) ), this, SLOT( dataReceived() ) ); |
93 | } | 107 | } |
94 | 108 | ||
95 | // setup GUI | 109 | // setup GUI |
96 | 110 | ||
97 | connect( button, SIGNAL( clicked() ), this, SLOT( buttonClicked() ) ); | 111 | connect( button, SIGNAL( clicked() ), this, SLOT( buttonClicked() ) ); |
98 | button->setEnabled( false ); | 112 | button->setEnabled( false ); |
99 | netview->setColumnWidthMode( 1, QListView::Manual ); | 113 | netview->setColumnWidthMode( 1, QListView::Manual ); |
100 | 114 | ||
101 | } | 115 | } |
102 | 116 | ||
103 | Wellenreiter::~Wellenreiter() | 117 | Wellenreiter::~Wellenreiter() |
104 | { | 118 | { |
105 | // no need to delete child widgets, Qt does it all for us | 119 | // no need to delete child widgets, Qt does it all for us |
120 | |||
121 | delete manufacturerdb; | ||
106 | } | 122 | } |
107 | 123 | ||
108 | void Wellenreiter::handleMessage() | 124 | void Wellenreiter::handleMessage() |
109 | { | 125 | { |
110 | // FIXME: receive message and handle it | 126 | // FIXME: receive message and handle it |
111 | 127 | ||
112 | qDebug( "received message from daemon." ); | 128 | qDebug( "received message from daemon." ); |
113 | 129 | ||
114 | char buffer[10000]; | 130 | char buffer[10000]; |
115 | memset( &buffer, 0, sizeof( buffer ) ); | 131 | memset( &buffer, 0, sizeof( buffer ) ); |
116 | 132 | ||
117 | // int result = #wl_recv( &daemon_fd, (char*) &buffer, sizeof(buffer) ); | 133 | // int result = #wl_recv( &daemon_fd, (char*) &buffer, sizeof(buffer) ); |
118 | 134 | ||
119 | struct sockaddr from; | 135 | struct sockaddr from; |
120 | socklen_t len; | 136 | socklen_t len; |
121 | 137 | ||
122 | int result = recvfrom( daemon_fd, &buffer, 8192, MSG_WAITALL, &from, &len ); | 138 | int result = recvfrom( daemon_fd, &buffer, 8192, MSG_WAITALL, &from, &len ); |
123 | 139 | ||
124 | qDebug( "received %d from recv [%d bytes]", result, len ); | 140 | qDebug( "received %d from recv [%d bytes]", result, len ); |
125 | 141 | ||
126 | if ( result == -1 ) | 142 | if ( result == -1 ) |
127 | { | 143 | { |
128 | qDebug( "Warning: %s", strerror( errno ) ); | 144 | qDebug( "Warning: %s", strerror( errno ) ); |
129 | return; | 145 | return; |
130 | } | 146 | } |
131 | 147 | ||
132 | int command = buffer[1] - 48; | 148 | int command = buffer[1] - 48; |
133 | 149 | ||
134 | /* | 150 | /* |
135 | typedef struct { | 151 | typedef struct { |
136 | int net_type; 1 = Accesspoint ; 2 = Ad-Hoc | 152 | int net_type; 1 = Accesspoint ; 2 = Ad-Hoc |
137 | int ssid_len; Length of SSID | 153 | int ssid_len; Length of SSID |
138 | int channel; Channel | 154 | int channel; Channel |
139 | int wep; 1 = WEP enabled ; 0 = disabled | 155 | int wep; 1 = WEP enabled ; 0 = disabled |
140 | char mac[64]; MAC address of Accesspoint | 156 | char mac[64]; MAC address of Accesspoint |
141 | char bssid[128]; BSSID of Accesspoint | 157 | char bssid[128]; BSSID of Accesspoint |
142 | } wl_network_t; | 158 | } wl_network_t; |
143 | */ | 159 | */ |
144 | 160 | ||
145 | qDebug( "Recv result: %d", ( result ) ); | 161 | qDebug( "Recv result: %d", ( result ) ); |
146 | qDebug( "Sniffer sent: '%s'", (const char*) buffer ); | 162 | qDebug( "Sniffer sent: '%s'", (const char*) buffer ); |
147 | hexwindow->log( (const char*) &buffer ); | 163 | hexwindow->log( (const char*) &buffer ); |
148 | 164 | ||
149 | if ( command == NETFOUND ) /* new network found */ | 165 | if ( command == NETFOUND ) /* new network found */ |
150 | { | 166 | { |
151 | qDebug( "Sniffer said: new network found." ); | 167 | qDebug( "Sniffer said: new network found." ); |
152 | wl_network_t n; | 168 | wl_network_t n; |
153 | get_network_found( &n, (char*) &buffer ); | 169 | get_network_found( &n, (char*) &buffer ); |
154 | 170 | ||
155 | qDebug( "Sniffer said: net_type is %d.", n.net_type ); | 171 | qDebug( "Sniffer said: net_type is %d.", n.net_type ); |
156 | qDebug( "Sniffer said: MAC is %s", (const char*) &n.mac ); | 172 | qDebug( "Sniffer said: MAC is %s", (const char*) &n.mac ); |
157 | 173 | ||
158 | //n.bssid[n.ssid_len] = "\0"; | 174 | //n.bssid[n.ssid_len] = "\0"; |
159 | 175 | ||
160 | QString type; | 176 | QString type; |
161 | 177 | ||
162 | if ( n.net_type == 1 ) | 178 | if ( n.net_type == 1 ) |
163 | type = "managed"; | 179 | type = "managed"; |
164 | else | 180 | else |
165 | type = "adhoc"; | 181 | type = "adhoc"; |
166 | 182 | ||
167 | netview->addNewItem( type, n.bssid, QString( (const char*) &n.mac ), n.wep, n.channel, 0 ); | 183 | netview->addNewItem( type, n.bssid, QString( (const char*) &n.mac ), n.wep, n.channel, 0 ); |
168 | 184 | ||
169 | } | 185 | } |
170 | 186 | ||
171 | else | 187 | else |
172 | 188 | ||
173 | { | 189 | { |
174 | qDebug( "unknown sniffer command." ); | 190 | qDebug( "unknown sniffer command." ); |
175 | } | 191 | } |
176 | 192 | ||
177 | } | 193 | } |
178 | 194 | ||
179 | void Wellenreiter::dataReceived() | 195 | void Wellenreiter::dataReceived() |
180 | { | 196 | { |
181 | logwindow->log( "(d) Received data from daemon" ); | 197 | logwindow->log( "(d) Received data from daemon" ); |
182 | handleMessage(); | 198 | handleMessage(); |
183 | } | 199 | } |
184 | 200 | ||
185 | void Wellenreiter::buttonClicked() | 201 | void Wellenreiter::buttonClicked() |
186 | { | 202 | { |
187 | /* | 203 | /* |
188 | // add some test stations, so that we can see if the GUI part works | 204 | // add some test stations, so that we can see if the GUI part works |
189 | addNewItem( "managed", "Vanille", "04:00:20:EF:A6:43", true, 6, 80 ); | 205 | addNewItem( "managed", "Vanille", "04:00:20:EF:A6:43", true, 6, 80 ); |
190 | addNewItem( "managed", "Vanille", "04:00:20:EF:A6:23", true, 11, 10 ); | 206 | addNewItem( "managed", "Vanille", "04:00:20:EF:A6:23", true, 11, 10 ); |
191 | addNewItem( "adhoc", "ELAN", "40:03:43:E7:16:22", false, 3, 10 ); | 207 | addNewItem( "adhoc", "ELAN", "40:03:43:E7:16:22", false, 3, 10 ); |
192 | addNewItem( "adhoc", "ELAN", "40:03:53:E7:56:62", false, 3, 15 ); | 208 | addNewItem( "adhoc", "ELAN", "40:03:53:E7:56:62", false, 3, 15 ); |
193 | addNewItem( "adhoc", "ELAN", "40:03:63:E7:56:E2", false, 3, 20 ); | 209 | addNewItem( "adhoc", "ELAN", "40:03:63:E7:56:E2", false, 3, 20 ); |
194 | */ | 210 | */ |
195 | 211 | ||
196 | 212 | ||
197 | if ( daemonRunning ) | 213 | if ( daemonRunning ) |
198 | { | 214 | { |
199 | daemonRunning = false; | 215 | daemonRunning = false; |
200 | 216 | ||
201 | logwindow->log( "(i) Daemon has been stopped." ); | 217 | logwindow->log( "(i) Daemon has been stopped." ); |
202 | button->setText( "Start Scanning" ); | 218 | button->setText( "Start Scanning" ); |
203 | 219 | ||
204 | // Stop daemon - ugly for now... later better | 220 | // Stop daemon - ugly for now... later better |
205 | 221 | ||
206 | system( "killall orinoco_hopper" ); | 222 | system( "killall orinoco_hopper" ); |
207 | system( "killall wellenreiterd" ); | 223 | system( "killall wellenreiterd" ); |
208 | 224 | ||
209 | // FIXME: reset the card trying to get into a usable state again | 225 | // FIXME: reset the card trying to get into a usable state again |
210 | 226 | ||
211 | // for now, just message the user | 227 | // for now, just message the user |
212 | 228 | ||
213 | QMessageBox::information( this, "Wellenreiter/Opie", "You should reset your\ndevice before using it again." ); | 229 | QMessageBox::information( this, "Wellenreiter/Opie", "You should reset your\ndevice before using it again." ); |
214 | } | 230 | } |
215 | 231 | ||
216 | else | 232 | else |
217 | { | 233 | { |
218 | 234 | ||
219 | logwindow->log( "(i) Daemon has been started." ); | 235 | logwindow->log( "(i) Daemon has been started." ); |
220 | daemonRunning = true; | 236 | daemonRunning = true; |
221 | button->setText( "Stop Scanning" ); | 237 | button->setText( "Stop Scanning" ); |
222 | 238 | ||
223 | // get configuration from config window | 239 | // get configuration from config window |
224 | 240 | ||
225 | const QString& interface = configwindow->interfaceName->currentText(); | 241 | const QString& interface = configwindow->interfaceName->currentText(); |
226 | const QString& cardtype = configwindow->deviceType->currentText(); | 242 | const QString& cardtype = configwindow->deviceType->currentText(); |
227 | const QString& interval = configwindow->hopInterval->cleanText(); | 243 | const QString& interval = configwindow->hopInterval->cleanText(); |
228 | 244 | ||
229 | if ( ( interface == "<select>" ) || ( cardtype == "<select>" ) ) | 245 | if ( ( interface == "<select>" ) || ( cardtype == "<select>" ) ) |
230 | { | 246 | { |
231 | QMessageBox::information( this, "Wellenreiter/Opie", "You must configure your\ndevice before scanning." ); | 247 | QMessageBox::information( this, "Wellenreiter/Opie", "You must configure your\ndevice before scanning." ); |
232 | return; | 248 | return; |
233 | } | 249 | } |
234 | 250 | ||
235 | // set interface into monitor mode | 251 | // set interface into monitor mode |
236 | /* Global::Execute definitely does not work very well with non-gui stuff! :( */ | 252 | /* Global::Execute definitely does not work very well with non-gui stuff! :( */ |
237 | 253 | ||
238 | QString cmdline; | 254 | QString cmdline; |
239 | 255 | ||
240 | cmdline.sprintf( "iwpriv %s monitor 2", (const char*) interface ); | 256 | cmdline.sprintf( "iwpriv %s monitor 2", (const char*) interface ); |
241 | system( cmdline ); | 257 | system( cmdline ); |
242 | cmdline.sprintf( "iwpriv %s monitor 2 1", (const char*) interface ); | 258 | cmdline.sprintf( "iwpriv %s monitor 2 1", (const char*) interface ); |
243 | system( cmdline ); | 259 | system( cmdline ); |
244 | 260 | ||
245 | // start channel hopper | 261 | // start channel hopper |
246 | 262 | ||
247 | cmdline = "orinoco_hopper "; | 263 | cmdline = "orinoco_hopper "; |
248 | cmdline += interface; | 264 | cmdline += interface; |
249 | cmdline += " -i "; | 265 | cmdline += " -i "; |
250 | cmdline += interval; | 266 | cmdline += interval; |
251 | cmdline += " &"; | 267 | cmdline += " &"; |
252 | qDebug( "execute: %s", (const char*) cmdline ); | 268 | qDebug( "execute: %s", (const char*) cmdline ); |
253 | system( cmdline ); | 269 | system( cmdline ); |
254 | qDebug( "done" ); | 270 | qDebug( "done" ); |
255 | 271 | ||
256 | // start daemon | 272 | // start daemon |
257 | 273 | ||
258 | cmdline = "wellenreiterd "; | 274 | cmdline = "wellenreiterd "; |
259 | cmdline += interface; | 275 | cmdline += interface; |
260 | cmdline += " 3"; | 276 | cmdline += " 3"; |
261 | cmdline += " &"; | 277 | cmdline += " &"; |
262 | 278 | ||
263 | qDebug( "execute: %s", (const char*) cmdline ); | 279 | qDebug( "execute: %s", (const char*) cmdline ); |
264 | system( cmdline ); | 280 | system( cmdline ); |
265 | qDebug( "done" ); | 281 | qDebug( "done" ); |
266 | 282 | ||
267 | } | 283 | } |
268 | } | 284 | } |
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.h b/noncore/net/wellenreiter/gui/wellenreiter.h index 2296892..9715983 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.h +++ b/noncore/net/wellenreiter/gui/wellenreiter.h | |||
@@ -1,56 +1,59 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. | 2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Opie Environment. | 4 | ** This file is part of Opie Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 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 | 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 | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 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. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | **********************************************************************/ | 14 | **********************************************************************/ |
15 | 15 | ||
16 | #ifndef WELLENREITER_H | 16 | #ifndef WELLENREITER_H |
17 | #define WELLENREITER_H | 17 | #define WELLENREITER_H |
18 | 18 | ||
19 | #include "wellenreiterbase.h" | 19 | #include "wellenreiterbase.h" |
20 | 20 | ||
21 | #ifdef QWS | 21 | #ifdef QWS |
22 | #include <opie/odevice.h> | 22 | #include <opie/odevice.h> |
23 | using namespace Opie; | 23 | using namespace Opie; |
24 | #endif | 24 | #endif |
25 | 25 | ||
26 | class QTimerEvent; | 26 | class QTimerEvent; |
27 | class QPixmap; | 27 | class QPixmap; |
28 | class ManufacturerDB; | ||
28 | 29 | ||
29 | class Wellenreiter : public WellenreiterBase { | 30 | class Wellenreiter : public WellenreiterBase { |
30 | Q_OBJECT | 31 | Q_OBJECT |
31 | 32 | ||
32 | public: | 33 | public: |
33 | 34 | ||
34 | Wellenreiter( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 35 | Wellenreiter( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
35 | ~Wellenreiter(); | 36 | ~Wellenreiter(); |
36 | 37 | ||
37 | protected: | 38 | protected: |
38 | 39 | ||
39 | bool daemonRunning; | 40 | bool daemonRunning; |
40 | 41 | ||
41 | public slots: | 42 | public slots: |
42 | void buttonClicked(); | 43 | void buttonClicked(); |
43 | void dataReceived(); | 44 | void dataReceived(); |
44 | 45 | ||
45 | private: | 46 | private: |
46 | int daemon_fd; // socket filedescriptor for udp communication socket | 47 | int daemon_fd; // socket filedescriptor for udp communication socket |
47 | #ifdef QWS | 48 | #ifdef QWS |
48 | OSystem _system; // Opie Operating System identifier | 49 | OSystem _system; // Opie Operating System identifier |
49 | #endif | 50 | #endif |
50 | void handleMessage(); | 51 | void handleMessage(); |
51 | 52 | ||
53 | ManufacturerDB* manufacturerdb; | ||
54 | |||
52 | //void readConfig(); | 55 | //void readConfig(); |
53 | //void writeConfig(); | 56 | //void writeConfig(); |
54 | }; | 57 | }; |
55 | 58 | ||
56 | #endif | 59 | #endif |