summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2002-12-11 13:47:44 (UTC)
committer mickeyl <mickeyl>2002-12-11 13:47:44 (UTC)
commit16138f0cdf46994d20ade71b5621b82fb9386933 (patch) (unidiff)
tree124be86049cf95260105b03a80c21b5f87b48a11
parent2b3c450378c1da0a2175c91d652ce2eae5614ff8 (diff)
downloadopie-16138f0cdf46994d20ade71b5621b82fb9386933.zip
opie-16138f0cdf46994d20ade71b5621b82fb9386933.tar.gz
opie-16138f0cdf46994d20ade71b5621b82fb9386933.tar.bz2
- Reduce g++ warnings.
- Depend on libpcap
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp8
-rw-r--r--noncore/net/wellenreiter/opie-wellenreiter.control6
2 files changed, 7 insertions, 7 deletions
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index 3453d18..5808e9c 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -1,257 +1,257 @@
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 19
20// Standard 20// Standard
21 21
22#include <assert.h> 22#include <assert.h>
23#include <errno.h> 23#include <errno.h>
24#include <unistd.h> 24#include <unistd.h>
25#include <string.h> 25#include <string.h>
26#include <sys/types.h> 26#include <sys/types.h>
27 27
28// Local 28// Local
29 29
30#include "wellenreiter.h" 30#include "wellenreiter.h"
31#include "scanlistitem.h" 31#include "scanlistitem.h"
32#include "logwindow.h" 32#include "logwindow.h"
33#include "hexwindow.h" 33#include "hexwindow.h"
34 34
35#include "../libwellenreiter/source/sock.hh" // <--- ugly path, FIX THIS! 35#include "../libwellenreiter/source/sock.hh" // <--- ugly path, FIX THIS!
36#include "../libwellenreiter/source/proto.hh" // <--- ugly path, FIX THIS! 36#include "../libwellenreiter/source/proto.hh" // <--- ugly path, FIX THIS!
37#include "../daemon/source/config.hh" // <--- ugly path, FIX THIS! 37#include "../daemon/source/config.hh" // <--- ugly path, FIX THIS!
38 38
39Wellenreiter::Wellenreiter( QWidget* parent, const char* name, WFlags fl ) 39Wellenreiter::Wellenreiter( QWidget* parent, const char* name, WFlags fl )
40 : WellenreiterBase( parent, name, fl ) 40 : WellenreiterBase( parent, name, fl )
41{ 41{
42 42
43 logwindow->log( "(i) Wellenreiter has been started." ); 43 logwindow->log( "(i) Wellenreiter has been started." );
44 44
45 connect( button, SIGNAL( clicked() ), this, SLOT( buttonClicked() ) ); 45 connect( button, SIGNAL( clicked() ), this, SLOT( buttonClicked() ) );
46 netview->setColumnWidthMode( 1, QListView::Manual ); 46 netview->setColumnWidthMode( 1, QListView::Manual );
47 47
48 // 48 //
49 // setup socket for daemon communication and start poller 49 // setup socket for daemon communication and start poller
50 // 50 //
51 51
52 daemon_fd = commsock( GUIADDR, GUIPORT ); 52 daemon_fd = commsock( GUIADDR, GUIPORT );
53 if ( daemon_fd == -1 ) 53 if ( daemon_fd == -1 )
54 { 54 {
55 logwindow->log( "(E) Couldn't get file descriptor for commsocket." ); 55 logwindow->log( "(E) Couldn't get file descriptor for commsocket." );
56 qDebug( "D'oh! Could not get file descriptor for daemon-->gui communication socket." ); 56 qDebug( "D'oh! Could not get file descriptor for daemon-->gui communication socket." );
57 } 57 }
58 else 58 else
59 startTimer( 700 ); 59 startTimer( 700 );
60 60
61} 61}
62 62
63Wellenreiter::~Wellenreiter() 63Wellenreiter::~Wellenreiter()
64{ 64{
65 // no need to delete child widgets, Qt does it all for us 65 // no need to delete child widgets, Qt does it all for us
66} 66}
67 67
68void Wellenreiter::handleMessage() 68void Wellenreiter::handleMessage()
69{ 69{
70 // FIXME: receive message and handle it 70 // FIXME: receive message and handle it
71 71
72 qDebug( "received message from daemon." ); 72 qDebug( "received message from daemon." );
73 73
74 char buffer[128]; 74 char buffer[128];
75 75
76 int result = recvcomm( &daemon_fd, (char*) &buffer, sizeof(buffer) ); 76 int result = recvcomm( &daemon_fd, (char*) &buffer, sizeof(buffer) );
77 qDebug( "received %d from recvcomm", result ); 77 qDebug( "received %d from recvcomm", result );
78 78
79/* 79/*
80typedef struct { 80typedef struct {
81 int net_type; 1 = Accesspoint ; 2 = Ad-Hoc 81 int net_type; 1 = Accesspoint ; 2 = Ad-Hoc
82 int ssid_len; Length of SSID 82 int ssid_len; Length of SSID
83 int channel; Channel 83 int channel; Channel
84 int wep; 1 = WEP enabled ; 0 = disabled 84 int wep; 1 = WEP enabled ; 0 = disabled
85 char mac[64]; MAC address of Accesspoint 85 char mac[64]; MAC address of Accesspoint
86 char bssid[128]; BSSID of Accesspoint 86 char bssid[128]; BSSID of Accesspoint
87} wl_network_t; 87} wl_network_t;
88*/ 88*/
89 89
90 // qDebug( "Sniffer sent: '%s'", (const char*) buffer ); 90 // qDebug( "Sniffer sent: '%s'", (const char*) buffer );
91 hexwindow->log( (const char*) &buffer ); 91 hexwindow->log( (const char*) &buffer );
92 92
93 if ( result == NETFOUND ) /* new network found */ 93 if ( result == NETFOUND ) /* new network found */
94 { 94 {
95 qDebug( "Sniffer said: new network found." ); 95 qDebug( "Sniffer said: new network found." );
96 wl_network_t n; 96 wl_network_t n;
97 get_network_found( &n, (char*) &buffer ); 97 get_network_found( &n, (char*) &buffer );
98 98
99 qDebug( "Sniffer said: net_type is %d.", n.net_type ); 99 qDebug( "Sniffer said: net_type is %d.", n.net_type );
100 qDebug( "Sniffer said: MAC is %s", (const char*) &n.mac ); 100 qDebug( "Sniffer said: MAC is %s", (const char*) &n.mac );
101 101
102 //n.bssid[n.ssid_len] = "\0"; 102 //n.bssid[n.ssid_len] = "\0";
103 103
104 QString type; 104 QString type;
105 105
106 if ( n.net_type == 1 ) 106 if ( n.net_type == 1 )
107 type = "managed"; 107 type = "managed";
108 else 108 else
109 type = "adhoc"; 109 type = "adhoc";
110 110
111 addNewItem( type, n.bssid, QString( (const char*) &n.mac ), n.wep, n.channel, 0 ); 111 addNewItem( type, n.bssid, QString( (const char*) &n.mac ), n.wep, n.channel, 0 );
112 112
113 } 113 }
114 114
115 else 115 else
116 116
117 { 117 {
118 qDebug( "unknown sniffer command." ); 118 qDebug( "unknown sniffer command." );
119 } 119 }
120 120
121} 121}
122 122
123 123
124bool Wellenreiter::hasMessage() 124bool Wellenreiter::hasMessage()
125{ 125{
126 126
127 // FIXME: do this in libwellenreiter, not here!!! 127 // FIXME: do this in libwellenreiter, not here!!!
128 128
129 fd_set rfds; 129 fd_set rfds;
130 FD_ZERO( &rfds ); 130 FD_ZERO( &rfds );
131 FD_SET( daemon_fd, &rfds ); 131 FD_SET( daemon_fd, &rfds );
132 struct timeval tv; 132 struct timeval tv;
133 tv.tv_sec = 0; 133 tv.tv_sec = 0;
134 tv.tv_usec = 10; 134 tv.tv_usec = 10;
135 int result = select( daemon_fd+1, &rfds, NULL, NULL, &tv ); 135 int result = select( daemon_fd+1, &rfds, NULL, NULL, &tv );
136 136
137 if ( result == 0 ) 137 if ( result == 0 )
138 { 138 {
139 return false; 139 return false;
140 } 140 }
141 else if ( result == -1 ) 141 else if ( result == -1 )
142 { 142 {
143 qDebug( "selected returned: %s", strerror( errno ) ); 143 qDebug( "selected returned: %s", strerror( errno ) );
144 return false; 144 return false;
145 } 145 }
146 else 146 else
147 return true; //FD_ISSET( daemon_fd, &rfds ); gibbet 'eh nur einen Deskriptor 147 return true; //FD_ISSET( daemon_fd, &rfds ); gibbet 'eh nur einen Deskriptor
148} 148}
149 149
150void Wellenreiter::timerEvent( QTimerEvent* e ) 150void Wellenreiter::timerEvent( QTimerEvent* e )
151{ 151{
152 qDebug( "checking for message..." ); 152 qDebug( "checking for message..." );
153 if ( hasMessage() ) 153 if ( hasMessage() )
154 { 154 {
155 qDebug( "got message" ); 155 qDebug( "got message" );
156 handleMessage(); 156 handleMessage();
157 } 157 }
158 else 158 else
159 { 159 {
160 qDebug( "no message..." ); 160 qDebug( "no message..." );
161 } 161 }
162} 162}
163 163
164void Wellenreiter::addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) 164void Wellenreiter::addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal )
165{ 165{
166 // FIXME: this code belongs in customized QListView, not into this class 166 // FIXME: this code belongs in customized QListView, not into this class
167 // FIXME: scanlistitem needs a proper encapsulation and not such a damn dealing with text(...) 167 // FIXME: scanlistitem needs a proper encapsulation and not such a damn dealing with text(...)
168 168
169 qDebug( "Wellenreiter::addNewItem( %s / %s / %s [%d]", 169 qDebug( "Wellenreiter::addNewItem( %s / %s / %s [%d]",
170 (const char*) type, 170 (const char*) type,
171 (const char*) essid, 171 (const char*) essid,
172 (const char*) macaddr, 172 (const char*) macaddr,
173 channel ); 173 channel );
174 174
175 // search, if we already have seen this net 175 // search, if we already have seen this net
176 176
177 QString s; 177 QString s;
178 MScanListItem* network; 178 MScanListItem* network;
179 MScanListItem* item = (MScanListItem*) netview->firstChild(); 179 MScanListItem* item = static_cast<MScanListItem*> ( netview->firstChild() );
180 180
181 while ( item && ( item->text( 0 ) != essid ) ) 181 while ( item && ( item->text( 0 ) != essid ) )
182 { 182 {
183 qDebug( "itemtext: %s", (const char*) item->text( 0 ) ); 183 qDebug( "itemtext: %s", (const char*) item->text( 0 ) );
184 item = item->itemBelow(); 184 item = static_cast<MScanListItem*> ( item->itemBelow() );
185 } 185 }
186 if ( item ) 186 if ( item )
187 { 187 {
188 // we have already seen this net, check all childs if MAC exists 188 // we have already seen this net, check all childs if MAC exists
189 189
190 network = item; 190 network = item;
191 191
192 item = item->firstChild(); 192 item = static_cast<MScanListItem*> ( item->firstChild() );
193 assert( item ); // this shouldn't fail 193 assert( item ); // this shouldn't fail
194 194
195 while ( item && ( item->text( 2 ) != macaddr ) ) 195 while ( item && ( item->text( 2 ) != macaddr ) )
196 { 196 {
197 qDebug( "subitemtext: %s", (const char*) item->text( 2 ) ); 197 qDebug( "subitemtext: %s", (const char*) item->text( 2 ) );
198 item = item->itemBelow(); 198 item = static_cast<MScanListItem*> ( item->itemBelow() );
199 } 199 }
200 200
201 if ( item ) 201 if ( item )
202 { 202 {
203 // we have already seen this item, it's a dupe 203 // we have already seen this item, it's a dupe
204 qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); 204 qDebug( "%s is a dupe - ignoring...", (const char*) macaddr );
205 return; 205 return;
206 } 206 }
207 } 207 }
208 else 208 else
209 { 209 {
210 s.sprintf( "(i) new network: '%s'", (const char*) essid ); 210 s.sprintf( "(i) new network: '%s'", (const char*) essid );
211 logwindow->log( s ); 211 logwindow->log( s );
212 212
213 network = new MScanListItem( netview, "networks", essid, QString::null, 0, 0, 0 ); 213 network = new MScanListItem( netview, "networks", essid, QString::null, 0, 0, 0 );
214 } 214 }
215 215
216 216
217 // insert new station as child from network 217 // insert new station as child from network
218 218
219 // no essid to reduce clutter, maybe later we have a nick or stationname to display!? 219 // no essid to reduce clutter, maybe later we have a nick or stationname to display!?
220 220
221 qDebug( "inserting new station %s", (const char*) macaddr ); 221 qDebug( "inserting new station %s", (const char*) macaddr );
222 222
223 new MScanListItem( network, type, "", macaddr, wep, channel, signal ); 223 new MScanListItem( network, type, "", macaddr, wep, channel, signal );
224 224
225 if ( type == "managed" ) 225 if ( type == "managed" )
226 { 226 {
227 s.sprintf( "(i) new AP in '%s' [%d]", (const char*) essid, channel ); 227 s.sprintf( "(i) new AP in '%s' [%d]", (const char*) essid, channel );
228 } 228 }
229 else 229 else
230 { 230 {
231 s.sprintf( "(i) new adhoc station in '%s' [%d]", (const char*) essid, channel ); 231 s.sprintf( "(i) new adhoc station in '%s' [%d]", (const char*) essid, channel );
232 } 232 }
233 233
234 logwindow->log( s ); 234 logwindow->log( s );
235 235
236} 236}
237 237
238void Wellenreiter::buttonClicked() 238void Wellenreiter::buttonClicked()
239{ 239{
240 240
241 // FIXME: communicate with daemon and set button text according to state 241 // FIXME: communicate with daemon and set button text according to state
242 242
243 button->setText( "Stop Scanning" ); 243 button->setText( "Stop Scanning" );
244 244
245 // add some test stations, so that we can see if the GUI part works 245 // add some test stations, so that we can see if the GUI part works
246 246
247 addNewItem( "managed", "Vanille", "04:00:20:EF:A6:43", true, 6, 80 ); 247 addNewItem( "managed", "Vanille", "04:00:20:EF:A6:43", true, 6, 80 );
248 addNewItem( "managed", "Vanille", "04:00:20:EF:A6:23", true, 11, 10 ); 248 addNewItem( "managed", "Vanille", "04:00:20:EF:A6:23", true, 11, 10 );
249 addNewItem( "adhoc", "ELAN", "40:03:43:E7:16:22", false, 3, 10 ); 249 addNewItem( "adhoc", "ELAN", "40:03:43:E7:16:22", false, 3, 10 );
250 addNewItem( "adhoc", "ELAN", "40:03:53:E7:56:62", false, 3, 15 ); 250 addNewItem( "adhoc", "ELAN", "40:03:53:E7:56:62", false, 3, 15 );
251 addNewItem( "adhoc", "ELAN", "40:03:63:E7:56:E2", false, 3, 20 ); 251 addNewItem( "adhoc", "ELAN", "40:03:63:E7:56:E2", false, 3, 20 );
252 252
253 QString command ("98"); 253 QString command ("98");
254 254
255 //sendcomm( DAEMONADDR, DAEMONPORT, (const char*) command ); 255 //sendcomm( DAEMONADDR, DAEMONPORT, (const char*) command );
256 256
257} 257}
diff --git a/noncore/net/wellenreiter/opie-wellenreiter.control b/noncore/net/wellenreiter/opie-wellenreiter.control
index 83bfd0e..f34cc08 100644
--- a/noncore/net/wellenreiter/opie-wellenreiter.control
+++ b/noncore/net/wellenreiter/opie-wellenreiter.control
@@ -1,9 +1,9 @@
1Files: bin/wellenreiter bin/wellenreiterd bin/orinoco_hopper pics/wellenreiter $QTDIR/lib/libwellenreiter.* 1Files: bin/wellenreiter bin/wellenreiterd bin/orinoco_hopper pics/wellenreiter $QTDIR/lib/libwellenreiter.*
2Priority: optional 2Priority: optional
3Section: opie/applications 3Section: opie/applications
4Maintainer: Michael Lauer <mickeyl@handhelds.org> 4Maintainer: Michael Lauer <mickeyl@handhelds.org>
5Architecture: arm 5Architecture: arm
6Version: $QPE_VERSION-$SUB_VERSION 6Version: $QPE_VERSION-$SUB_VERSION
7Depends: opie-base ($QPE_VERSION) 7Depends: opie-base ($QPE_VERSION), libpcap
8Description: A wavelan network monitor 8Description: A WaveLAN Network Monitor
9 A wavelan network monitor/sniffer for the Opie environment. 9 A WaveLAN Network Monitor/Sniffer for the Opie Environment.