summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/README37
-rw-r--r--noncore/net/wellenreiter/config.in4
-rw-r--r--noncore/net/wellenreiter/contrib/.cvsignore4
-rw-r--r--noncore/net/wellenreiter/contrib/orinoco_hopper/.cvsignore4
-rw-r--r--noncore/net/wellenreiter/contrib/orinoco_hopper/Makefile.in101
-rw-r--r--noncore/net/wellenreiter/contrib/orinoco_hopper/orinoco_hopper.c118
-rw-r--r--noncore/net/wellenreiter/contrib/orinoco_hopper/orinoco_hopper.obin0 -> 35856 bytes
-rw-r--r--noncore/net/wellenreiter/contrib/orinoco_hopper/orinoco_hopper.pro11
-rw-r--r--noncore/net/wellenreiter/gui/configbase.ui307
-rw-r--r--noncore/net/wellenreiter/gui/gui.pro2
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp24
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/source/sniff.cc3
-rw-r--r--noncore/net/wellenreiter/opie-wellenreiter.control2
13 files changed, 605 insertions, 12 deletions
diff --git a/noncore/net/wellenreiter/README b/noncore/net/wellenreiter/README
new file mode 100644
index 0000000..4ed5c28
--- a/dev/null
+++ b/noncore/net/wellenreiter/README
@@ -0,0 +1,37 @@
1/*************************************************************************/
2/* W e l l e n r e i t e r I I */
3/* =============================== */
4/* */
5/* Version: Opie-ALPHA */
6/*************************************************************************/
7
8Release Notes for Opie-ALPHA Version December 2002
9--------------------------------------------------
10
11= Supported Devices =
12
13* low-level orinoco_cs-based (including prism2 and spectrum_cs)
14
15= Build =
16
17To compile Wellenreiter within the Opie build environment, add the
18following directories to $OPIEDIR/Makefile, e.g. to 'NONAPPS='
19
20noncore/net/wellenreiter/libwellenreiter \
21noncore/net/wellenreiter/daemon \
22noncore/net/wellenreiter/contrib/orinoco_hopper \
23noncore/net/wellenreiter/gui
24
25./configure and rebuild.
26
27= Run =
28
291. Place card in monitor mode: iwpriv <interface> 2 1
302. Start $OPIEDIR/bin/orinoco_hopper <interface>
313. Start Wellenreiter
32
33= Credits =
34
35Sniffer: Max Moser <max@remote-exploit.org>
36Communication and Protocol: Martin J. Muench <mjm@remote-exploit.org>
37GUI: Michael Lauer <mickeyl@handhelds.org>
diff --git a/noncore/net/wellenreiter/config.in b/noncore/net/wellenreiter/config.in
index d6b48d8..3c33b68 100644
--- a/noncore/net/wellenreiter/config.in
+++ b/noncore/net/wellenreiter/config.in
@@ -1,4 +1,4 @@
1# config #WELLENREITER 1# config WELLENREITER
2# boolean "wellenreiter" 2# boolean "wellenreiter"
3# default "y" 3# default "y"
4# depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE 4# depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE && LIBPCAP
diff --git a/noncore/net/wellenreiter/contrib/.cvsignore b/noncore/net/wellenreiter/contrib/.cvsignore
new file mode 100644
index 0000000..0e45b67
--- a/dev/null
+++ b/noncore/net/wellenreiter/contrib/.cvsignore
@@ -0,0 +1,4 @@
1*.o
2*~
3moc_*
4Makefile.*
diff --git a/noncore/net/wellenreiter/contrib/orinoco_hopper/.cvsignore b/noncore/net/wellenreiter/contrib/orinoco_hopper/.cvsignore
new file mode 100644
index 0000000..0e45b67
--- a/dev/null
+++ b/noncore/net/wellenreiter/contrib/orinoco_hopper/.cvsignore
@@ -0,0 +1,4 @@
1*.o
2*~
3moc_*
4Makefile.*
diff --git a/noncore/net/wellenreiter/contrib/orinoco_hopper/Makefile.in b/noncore/net/wellenreiter/contrib/orinoco_hopper/Makefile.in
new file mode 100644
index 0000000..c542a59
--- a/dev/null
+++ b/noncore/net/wellenreiter/contrib/orinoco_hopper/Makefile.in
@@ -0,0 +1,101 @@
1#############################################################################
2
3####### Compiler, tools and options
4
5 CXX =$(SYSCONF_CXX) $(QT_CXX_MT)
6 CXXFLAGS=$(SYSCONF_CXXFLAGS)
7 CC =$(SYSCONF_CC) $(QT_C_MT)
8 CFLAGS =$(SYSCONF_CFLAGS)
9 INCPATH =
10 LFLAGS =$(SYSCONF_LFLAGS) $(QT_LFLAGS_MT)
11 LIBS =$(SUBLIBS) $(SYSCONF_LIBS) $(SYSCONF_LIBS_QTAPP)
12 MOC =$(SYSCONF_MOC)
13 UIC =$(SYSCONF_UIC)
14
15####### Target
16
17DESTDIR = $(OPIEDIR)/bin/
18VER_MAJ = 1
19VER_MIN = 0
20VER_PATCH = 0
21 TARGET= orinoco_hopper
22TARGET1 = lib$(TARGET).so.$(VER_MAJ)
23
24####### Files
25
26 HEADERS =
27 SOURCES =orinoco_hopper.c
28 OBJECTS =orinoco_hopper.o
29INTERFACES =
30UICDECLS =
31UICIMPLS =
32 SRCMOC =
33 OBJMOC =
34
35
36####### Implicit rules
37
38.SUFFIXES: .cpp .cxx .cc .C .c
39
40.cpp.o:
41 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
42
43.cxx.o:
44 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
45
46.cc.o:
47 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
48
49.C.o:
50 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
51
52.c.o:
53 $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<
54
55####### Build rules
56
57
58all: $(DESTDIR)$(TARGET)
59
60$(DESTDIR)$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS)
61 $(SYSCONF_LINK) $(LFLAGS) -o $(DESTDIR)$(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS)
62
63moc: $(SRCMOC)
64
65tmake:
66 tmake orinoco_hopper.pro
67
68clean:
69 -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS)
70 -rm -f *~ core
71 -rm -f allmoc.cpp
72
73####### Extension Modules
74
75listpromodules:
76 @echo
77
78listallmodules:
79 @echo
80
81listaddonpromodules:
82 @echo
83
84listaddonentmodules:
85 @echo
86
87
88REQUIRES=
89
90####### Sub-libraries
91
92
93###### Combined headers
94
95
96
97####### Compile
98
99orinoco_hopper.o: orinoco_hopper.c
100
101
diff --git a/noncore/net/wellenreiter/contrib/orinoco_hopper/orinoco_hopper.c b/noncore/net/wellenreiter/contrib/orinoco_hopper/orinoco_hopper.c
new file mode 100644
index 0000000..78f0299
--- a/dev/null
+++ b/noncore/net/wellenreiter/contrib/orinoco_hopper/orinoco_hopper.c
@@ -0,0 +1,118 @@
1/* orinoco_hopper.c
2 * orinoco wireless nic channel scanning utility
3 *
4 * By Snax <snax@shmoo.com>
5 * Copyright (c) 2002 Snax
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * For a copy of the GNU General Public License write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
20
21#include <stdio.h>
22#include <stdlib.h>
23#include <sys/time.h>
24#include <signal.h>
25#include <string.h>
26#include <sys/ioctl.h>
27#include <sys/socket.h>
28#include <linux/wireless.h>
29#include <unistd.h>
30#include <getopt.h>
31
32#ifndef SIOCIWFIRSTPRIV
33#define SIOCIWFIRSTPRIV SIOCDEVPRIVATE
34#endif
35
36void changeChannel(int);
37int setChannel( unsigned char channel );
38
39int max = 11;
40int mode = 2;
41char dev[32];
42
43void changeChannel(int x) {
44 static int chan = 0;
45 chan = (chan % max) + 1;
46 setChannel(chan);
47}
48
49int setChannel( unsigned char channel )
50{
51 int result = 0;
52 int fd;
53 struct iwreq ireq; //for Orinoco
54 int *ptr;
55
56 /* get a socket */
57 fd = socket(AF_INET, SOCK_STREAM, 0);
58
59 if ( fd == -1 ) {
60 return -1;
61 }
62 ptr = (int *) ireq.u.name;
63 ptr[0] = mode;
64 ptr[1] = channel;
65 strcpy(ireq.ifr_ifrn.ifrn_name, dev);
66 result = ioctl( fd, SIOCIWFIRSTPRIV + 0x8, &ireq);
67 close(fd);
68 return result;
69}
70
71void usage(char *cmd) {
72 fprintf(stderr,
73 "Usage: %s <iface> [-p] [-i <interval millisec>] [-n]\n -n = international channels\n -p = keep prism headers\n", cmd);
74 exit(1);
75}
76
77int main (int argc, char *argv[])
78{
79 struct itimerval tval;
80 int ms, r;
81
82 //this will be the channel scanning interval, currently 0.2 sec
83 struct timeval interval = {0, 200000};
84
85 if (argc < 2) usage(argv[0]);
86 strncpy(dev, argv[1], 32);
87 dev[31] = 0;
88
89 while (1) {
90 r = getopt(argc,argv,"i:np");
91 if (r < 0) break;
92 switch (r) {
93 case 'n':
94 max = 14;
95 break;
96 case 'p':
97 mode = 1;
98 break;
99 case 'i':
100 ms = atoi(optarg);
101 interval.tv_sec = ms / 1000;
102 interval.tv_usec = (ms % 1000) * 1000;
103 break;
104 default:
105 usage(argv[0]);
106 }
107 }
108
109 //this sets up the kchannel scanning stuff
110 signal(SIGALRM, changeChannel);
111 tval.it_interval = interval;
112 tval.it_value = interval;
113 setitimer(ITIMER_REAL, &tval, NULL);
114 while (1) pause();
115
116 return 0;
117}
118
diff --git a/noncore/net/wellenreiter/contrib/orinoco_hopper/orinoco_hopper.o b/noncore/net/wellenreiter/contrib/orinoco_hopper/orinoco_hopper.o
new file mode 100644
index 0000000..dd90c62
--- a/dev/null
+++ b/noncore/net/wellenreiter/contrib/orinoco_hopper/orinoco_hopper.o
Binary files differ
diff --git a/noncore/net/wellenreiter/contrib/orinoco_hopper/orinoco_hopper.pro b/noncore/net/wellenreiter/contrib/orinoco_hopper/orinoco_hopper.pro
new file mode 100644
index 0000000..a85520c
--- a/dev/null
+++ b/noncore/net/wellenreiter/contrib/orinoco_hopper/orinoco_hopper.pro
@@ -0,0 +1,11 @@
1DESTDIR = $(OPIEDIR)/bin
2TEMPLATE = app
3CONFIG = warn_on debug
4#CONFIG = warn_on release
5HEADERS =
6SOURCES = orinoco_hopper.c
7INCLUDEPATH +=
8DEPENDPATH +=
9LIBS +=
10INTERFACES =
11TARGET = orinoco_hopper
diff --git a/noncore/net/wellenreiter/gui/configbase.ui b/noncore/net/wellenreiter/gui/configbase.ui
new file mode 100644
index 0000000..8f38252
--- a/dev/null
+++ b/noncore/net/wellenreiter/gui/configbase.ui
@@ -0,0 +1,307 @@
1<!DOCTYPE UI><UI>
2<class>Form1</class>
3<widget>
4 <class>QWidget</class>
5 <property stdset="1">
6 <name>name</name>
7 <cstring>Form1</cstring>
8 </property>
9 <property stdset="1">
10 <name>geometry</name>
11 <rect>
12 <x>0</x>
13 <y>0</y>
14 <width>226</width>
15 <height>300</height>
16 </rect>
17 </property>
18 <property stdset="1">
19 <name>caption</name>
20 <string>Form1</string>
21 </property>
22 <vbox>
23 <property stdset="1">
24 <name>margin</name>
25 <number>11</number>
26 </property>
27 <property stdset="1">
28 <name>spacing</name>
29 <number>6</number>
30 </property>
31 <widget>
32 <class>QGroupBox</class>
33 <property stdset="1">
34 <name>name</name>
35 <cstring>GroupBox1</cstring>
36 </property>
37 <property stdset="1">
38 <name>title</name>
39 <string>Sniffer Options</string>
40 </property>
41 <grid>
42 <property stdset="1">
43 <name>margin</name>
44 <number>11</number>
45 </property>
46 <property stdset="1">
47 <name>spacing</name>
48 <number>6</number>
49 </property>
50 <widget row="0" column="0" >
51 <class>QLayoutWidget</class>
52 <property stdset="1">
53 <name>name</name>
54 <cstring>Layout1</cstring>
55 </property>
56 <grid>
57 <property stdset="1">
58 <name>margin</name>
59 <number>0</number>
60 </property>
61 <property stdset="1">
62 <name>spacing</name>
63 <number>6</number>
64 </property>
65 <widget row="2" column="0" >
66 <class>QSpinBox</class>
67 <property stdset="1">
68 <name>name</name>
69 <cstring>hopInterval</cstring>
70 </property>
71 <property stdset="1">
72 <name>suffix</name>
73 <string> ms</string>
74 </property>
75 <property stdset="1">
76 <name>maxValue</name>
77 <number>2000</number>
78 </property>
79 <property stdset="1">
80 <name>minValue</name>
81 <number>100</number>
82 </property>
83 <property stdset="1">
84 <name>lineStep</name>
85 <number>100</number>
86 </property>
87 </widget>
88 <widget row="2" column="1" >
89 <class>QLabel</class>
90 <property stdset="1">
91 <name>name</name>
92 <cstring>TextLabel3</cstring>
93 </property>
94 <property stdset="1">
95 <name>text</name>
96 <string>Hop Interval</string>
97 </property>
98 </widget>
99 <widget row="0" column="0" >
100 <class>QComboBox</class>
101 <item>
102 <property>
103 <name>text</name>
104 <string>&lt;select&gt;</string>
105 </property>
106 </item>
107 <item>
108 <property>
109 <name>text</name>
110 <string>eth0</string>
111 </property>
112 </item>
113 <item>
114 <property>
115 <name>text</name>
116 <string>eth1</string>
117 </property>
118 </item>
119 <item>
120 <property>
121 <name>text</name>
122 <string>wlan0</string>
123 </property>
124 </item>
125 <item>
126 <property>
127 <name>text</name>
128 <string>wlan1</string>
129 </property>
130 </item>
131 <item>
132 <property>
133 <name>text</name>
134 <string>wifi0</string>
135 </property>
136 </item>
137 <item>
138 <property>
139 <name>text</name>
140 <string>wifi1</string>
141 </property>
142 </item>
143 <property stdset="1">
144 <name>name</name>
145 <cstring>interfaceName</cstring>
146 </property>
147 </widget>
148 <widget row="0" column="1" >
149 <class>QLabel</class>
150 <property stdset="1">
151 <name>name</name>
152 <cstring>TextLabel1</cstring>
153 </property>
154 <property stdset="1">
155 <name>text</name>
156 <string>Interface Name</string>
157 </property>
158 </widget>
159 <widget row="1" column="0" >
160 <class>QComboBox</class>
161 <item>
162 <property>
163 <name>text</name>
164 <string>&lt;select&gt;</string>
165 </property>
166 </item>
167 <item>
168 <property>
169 <name>text</name>
170 <string>cisco</string>
171 </property>
172 </item>
173 <item>
174 <property>
175 <name>text</name>
176 <string>orinoco</string>
177 </property>
178 </item>
179 <item>
180 <property>
181 <name>text</name>
182 <string>prism</string>
183 </property>
184 </item>
185 <item>
186 <property>
187 <name>text</name>
188 <string>&lt;manual&gt;</string>
189 </property>
190 </item>
191 <property stdset="1">
192 <name>name</name>
193 <cstring>deviceType</cstring>
194 </property>
195 </widget>
196 <widget row="1" column="1" >
197 <class>QLabel</class>
198 <property stdset="1">
199 <name>name</name>
200 <cstring>TextLabel2</cstring>
201 </property>
202 <property stdset="1">
203 <name>text</name>
204 <string>Device Type</string>
205 </property>
206 </widget>
207 </grid>
208 </widget>
209 </grid>
210 </widget>
211 <widget>
212 <class>QGroupBox</class>
213 <property stdset="1">
214 <name>name</name>
215 <cstring>GroupBox8</cstring>
216 </property>
217 <property stdset="1">
218 <name>title</name>
219 <string>Advanced Options</string>
220 </property>
221 <widget>
222 <class>QCheckBox</class>
223 <property stdset="1">
224 <name>name</name>
225 <cstring>additionalInfo</cstring>
226 </property>
227 <property stdset="1">
228 <name>geometry</name>
229 <rect>
230 <x>11</x>
231 <y>19</y>
232 <width>147</width>
233 <height>19</height>
234 </rect>
235 </property>
236 <property stdset="1">
237 <name>text</name>
238 <string>Gather Additional Info</string>
239 </property>
240 </widget>
241 <widget>
242 <class>QCheckBox</class>
243 <property stdset="1">
244 <name>name</name>
245 <cstring>activeScanning</cstring>
246 </property>
247 <property stdset="1">
248 <name>geometry</name>
249 <rect>
250 <x>11</x>
251 <y>44</y>
252 <width>175</width>
253 <height>19</height>
254 </rect>
255 </property>
256 <property stdset="1">
257 <name>text</name>
258 <string>Active Scanning (caution!)</string>
259 </property>
260 </widget>
261 </widget>
262 <widget>
263 <class>QGroupBox</class>
264 <property stdset="1">
265 <name>name</name>
266 <cstring>GroupBox3</cstring>
267 </property>
268 <property stdset="1">
269 <name>title</name>
270 <string>GUI Options</string>
271 </property>
272 <vbox>
273 <property stdset="1">
274 <name>margin</name>
275 <number>11</number>
276 </property>
277 <property stdset="1">
278 <name>spacing</name>
279 <number>6</number>
280 </property>
281 <widget>
282 <class>QCheckBox</class>
283 <property stdset="1">
284 <name>name</name>
285 <cstring>groupNetworks</cstring>
286 </property>
287 <property stdset="1">
288 <name>text</name>
289 <string>Group Detected Networks</string>
290 </property>
291 </widget>
292 <widget>
293 <class>QCheckBox</class>
294 <property stdset="1">
295 <name>name</name>
296 <cstring>enableActivity</cstring>
297 </property>
298 <property stdset="1">
299 <name>text</name>
300 <string>Enable Activity Display</string>
301 </property>
302 </widget>
303 </vbox>
304 </widget>
305 </vbox>
306</widget>
307</UI>
diff --git a/noncore/net/wellenreiter/gui/gui.pro b/noncore/net/wellenreiter/gui/gui.pro
index 8f14bc1..a047433 100644
--- a/noncore/net/wellenreiter/gui/gui.pro
+++ b/noncore/net/wellenreiter/gui/gui.pro
@@ -1,11 +1,11 @@
1DESTDIR = $(OPIEDIR)/bin 1DESTDIR = $(OPIEDIR)/bin
2TEMPLATE = app 2TEMPLATE = app
3CONFIG = qt warn_on debug 3CONFIG = qt warn_on debug
4#CONFIG = qt warn_on release 4#CONFIG = qt warn_on release
5HEADERS = wellenreiterbase.h wellenreiter.h scanlistitem.h scanlist.h logwindow.h hexwindow.h 5HEADERS = wellenreiterbase.h wellenreiter.h scanlistitem.h scanlist.h logwindow.h hexwindow.h
6SOURCES = main.cpp wellenreiterbase.cpp wellenreiter.cpp scanlistitem.cpp scanlist.cpp logwindow.cpp hexwindow.cpp 6SOURCES = main.cpp wellenreiterbase.cpp wellenreiter.cpp scanlistitem.cpp scanlist.cpp logwindow.cpp hexwindow.cpp
7INCLUDEPATH += $(OPIEDIR)/include ../daemon 7INCLUDEPATH += $(OPIEDIR)/include ../daemon
8DEPENDPATH += $(OPIEDIR)/include ../daemon 8DEPENDPATH += $(OPIEDIR)/include ../daemon
9LIBS += -lqpe -lopie -lwellenreiter 9LIBS += -lqpe -lopie -lwellenreiter
10INTERFACES = wellenreitertemplate.ui 10INTERFACES = configbase.ui
11TARGET = wellenreiter 11TARGET = wellenreiter
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index 6d62fa8..3453d18 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -1,247 +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 <unistd.h> 24#include <unistd.h>
25#include <string.h>
24#include <sys/types.h> 26#include <sys/types.h>
25 27
26// Local 28// Local
27 29
28#include "wellenreiter.h" 30#include "wellenreiter.h"
29#include "scanlistitem.h" 31#include "scanlistitem.h"
30#include "logwindow.h" 32#include "logwindow.h"
31#include "hexwindow.h" 33#include "hexwindow.h"
32 34
33#include "../libwellenreiter/source/sock.hh" // <--- ugly path, FIX THIS! 35#include "../libwellenreiter/source/sock.hh" // <--- ugly path, FIX THIS!
34#include "../libwellenreiter/source/proto.hh" // <--- ugly path, FIX THIS! 36#include "../libwellenreiter/source/proto.hh" // <--- ugly path, FIX THIS!
35#include "../daemon/source/config.hh" // <--- ugly path, FIX THIS! 37#include "../daemon/source/config.hh" // <--- ugly path, FIX THIS!
36 38
37Wellenreiter::Wellenreiter( QWidget* parent, const char* name, WFlags fl ) 39Wellenreiter::Wellenreiter( QWidget* parent, const char* name, WFlags fl )
38 : WellenreiterBase( parent, name, fl ) 40 : WellenreiterBase( parent, name, fl )
39{ 41{
40 42
41 logwindow->log( "(i) Wellenreiter has been started." ); 43 logwindow->log( "(i) Wellenreiter has been started." );
42 44
43 connect( button, SIGNAL( clicked() ), this, SLOT( buttonClicked() ) ); 45 connect( button, SIGNAL( clicked() ), this, SLOT( buttonClicked() ) );
44 netview->setColumnWidthMode( 1, QListView::Manual ); 46 netview->setColumnWidthMode( 1, QListView::Manual );
45 47
46 // 48 //
47 // setup socket for daemon communication and start poller 49 // setup socket for daemon communication and start poller
48 // 50 //
49 51
50 daemon_fd = commsock( GUIADDR, GUIPORT ); 52 daemon_fd = commsock( GUIADDR, GUIPORT );
51 if ( daemon_fd == -1 ) 53 if ( daemon_fd == -1 )
52 { 54 {
53 logwindow->log( "(E) Couldn't get file descriptor for commsocket." ); 55 logwindow->log( "(E) Couldn't get file descriptor for commsocket." );
54 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." );
55 } 57 }
56 else 58 else
57 startTimer( 700 ); 59 startTimer( 700 );
58 60
59} 61}
60 62
61Wellenreiter::~Wellenreiter() 63Wellenreiter::~Wellenreiter()
62{ 64{
63 // 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
64} 66}
65 67
66void Wellenreiter::handleMessage() 68void Wellenreiter::handleMessage()
67{ 69{
68 // FIXME: receive message and handle it 70 // FIXME: receive message and handle it
69 71
70 qDebug( "received message from daemon." ); 72 qDebug( "received message from daemon." );
71 73
72 char buffer[128]; 74 char buffer[128];
73 75
74 int result = recvcomm( &daemon_fd, (char*) &buffer, sizeof(buffer) ); 76 int result = recvcomm( &daemon_fd, (char*) &buffer, sizeof(buffer) );
75 qDebug( "received %d from recvcomm", result ); 77 qDebug( "received %d from recvcomm", result );
76 78
77/* 79/*
78typedef struct { 80typedef struct {
79 int net_type; 1 = Accesspoint ; 2 = Ad-Hoc 81 int net_type; 1 = Accesspoint ; 2 = Ad-Hoc
80 int ssid_len; Length of SSID 82 int ssid_len; Length of SSID
81 int channel; Channel 83 int channel; Channel
82 int wep; 1 = WEP enabled ; 0 = disabled 84 int wep; 1 = WEP enabled ; 0 = disabled
83 char mac[64]; MAC address of Accesspoint 85 char mac[64]; MAC address of Accesspoint
84 char bssid[128]; BSSID of Accesspoint 86 char bssid[128]; BSSID of Accesspoint
85} wl_network_t; 87} wl_network_t;
86*/ 88*/
87 89
88 // qDebug( "Sniffer sent: '%s'", (const char*) buffer ); 90 // qDebug( "Sniffer sent: '%s'", (const char*) buffer );
89 hexwindow->log( (const char*) &buffer ); 91 hexwindow->log( (const char*) &buffer );
90 92
91 if ( result == NETFOUND ) /* new network found */ 93 if ( result == NETFOUND ) /* new network found */
92 { 94 {
93 qDebug( "Sniffer said: new network found." ); 95 qDebug( "Sniffer said: new network found." );
94 wl_network_t n; 96 wl_network_t n;
95 get_network_found( &n, (char*) &buffer ); 97 get_network_found( &n, (char*) &buffer );
96 98
97 qDebug( "Sniffer said: net_type is %d.", n.net_type ); 99 qDebug( "Sniffer said: net_type is %d.", n.net_type );
98 qDebug( "Sniffer said: MAC is %s", (const char*) &n.mac ); 100 qDebug( "Sniffer said: MAC is %s", (const char*) &n.mac );
99 101
100 //n.bssid[n.ssid_len] = "\0"; 102 //n.bssid[n.ssid_len] = "\0";
101 103
102 QString type; 104 QString type;
103 105
104 if ( n.net_type == 1 ) 106 if ( n.net_type == 1 )
105 type = "managed"; 107 type = "managed";
106 else 108 else
107 type = "adhoc"; 109 type = "adhoc";
108 110
109 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 );
110 112
111 } 113 }
112 114
113 else 115 else
114 116
115 { 117 {
116 qDebug( "unknown sniffer command." ); 118 qDebug( "unknown sniffer command." );
117 } 119 }
118 120
119} 121}
120 122
121 123
122bool Wellenreiter::hasMessage() 124bool Wellenreiter::hasMessage()
123{ 125{
124 126
125 // FIXME: do this in libwellenreiter, not here!!! 127 // FIXME: do this in libwellenreiter, not here!!!
126 128
127 fd_set rfds; 129 fd_set rfds;
128 FD_ZERO( &rfds ); 130 FD_ZERO( &rfds );
129 FD_SET( daemon_fd, &rfds ); 131 FD_SET( daemon_fd, &rfds );
130 struct timeval tv; 132 struct timeval tv;
131 tv.tv_sec = 0; 133 tv.tv_sec = 0;
132 tv.tv_usec = 10; 134 tv.tv_usec = 10;
133 int result = select( daemon_fd+1, &rfds, NULL, NULL, &tv ); 135 int result = select( daemon_fd+1, &rfds, NULL, NULL, &tv );
134 return FD_ISSET( daemon_fd, &rfds ); 136
137 if ( result == 0 )
138 {
139 return false;
140 }
141 else if ( result == -1 )
142 {
143 qDebug( "selected returned: %s", strerror( errno ) );
144 return false;
145 }
146 else
147 return true; //FD_ISSET( daemon_fd, &rfds ); gibbet 'eh nur einen Deskriptor
135} 148}
136 149
137void Wellenreiter::timerEvent( QTimerEvent* e ) 150void Wellenreiter::timerEvent( QTimerEvent* e )
138{ 151{
139 qDebug( "checking for message..." ); 152 qDebug( "checking for message..." );
140 153 if ( hasMessage() )
141 int result = hasMessage();
142 qDebug( "hasMessage() returned %d", result );
143
144 if ( result )
145 { 154 {
155 qDebug( "got message" );
146 handleMessage(); 156 handleMessage();
147 } 157 }
148 else 158 else
149 { 159 {
150 qDebug( "no message :(" ); 160 qDebug( "no message..." );
151 } 161 }
152} 162}
153 163
154void 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 )
155{ 165{
156 // FIXME: this code belongs in customized QListView, not into this class 166 // FIXME: this code belongs in customized QListView, not into this class
157 // 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(...)
158 168
159 qDebug( "Wellenreiter::addNewItem( %s / %s / %s [%d]", 169 qDebug( "Wellenreiter::addNewItem( %s / %s / %s [%d]",
160 (const char*) type, 170 (const char*) type,
161 (const char*) essid, 171 (const char*) essid,
162 (const char*) macaddr, 172 (const char*) macaddr,
163 channel ); 173 channel );
164 174
165 // search, if we already have seen this net 175 // search, if we already have seen this net
166 176
167 QString s; 177 QString s;
168 MScanListItem* network; 178 MScanListItem* network;
169 MScanListItem* item = (MScanListItem*) netview->firstChild(); 179 MScanListItem* item = (MScanListItem*) netview->firstChild();
170 180
171 while ( item && ( item->text( 0 ) != essid ) ) 181 while ( item && ( item->text( 0 ) != essid ) )
172 { 182 {
173 qDebug( "itemtext: %s", (const char*) item->text( 0 ) ); 183 qDebug( "itemtext: %s", (const char*) item->text( 0 ) );
174 item = item->itemBelow(); 184 item = item->itemBelow();
175 } 185 }
176 if ( item ) 186 if ( item )
177 { 187 {
178 // 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
179 189
180 network = item; 190 network = item;
181 191
182 item = item->firstChild(); 192 item = item->firstChild();
183 assert( item ); // this shouldn't fail 193 assert( item ); // this shouldn't fail
184 194
185 while ( item && ( item->text( 2 ) != macaddr ) ) 195 while ( item && ( item->text( 2 ) != macaddr ) )
186 { 196 {
187 qDebug( "subitemtext: %s", (const char*) item->text( 2 ) ); 197 qDebug( "subitemtext: %s", (const char*) item->text( 2 ) );
188 item = item->itemBelow(); 198 item = item->itemBelow();
189 } 199 }
190 200
191 if ( item ) 201 if ( item )
192 { 202 {
193 // we have already seen this item, it's a dupe 203 // we have already seen this item, it's a dupe
194 qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); 204 qDebug( "%s is a dupe - ignoring...", (const char*) macaddr );
195 return; 205 return;
196 } 206 }
197 } 207 }
198 else 208 else
199 { 209 {
200 s.sprintf( "(i) new network: '%s'", (const char*) essid ); 210 s.sprintf( "(i) new network: '%s'", (const char*) essid );
201 logwindow->log( s ); 211 logwindow->log( s );
202 212
203 network = new MScanListItem( netview, "networks", essid, QString::null, 0, 0, 0 ); 213 network = new MScanListItem( netview, "networks", essid, QString::null, 0, 0, 0 );
204 } 214 }
205 215
206 216
207 // insert new station as child from network 217 // insert new station as child from network
208 218
209 // 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!?
210 220
211 qDebug( "inserting new station %s", (const char*) macaddr ); 221 qDebug( "inserting new station %s", (const char*) macaddr );
212 222
213 new MScanListItem( network, type, "", macaddr, wep, channel, signal ); 223 new MScanListItem( network, type, "", macaddr, wep, channel, signal );
214 224
215 if ( type == "managed" ) 225 if ( type == "managed" )
216 { 226 {
217 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 );
218 } 228 }
219 else 229 else
220 { 230 {
221 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 );
222 } 232 }
223 233
224 logwindow->log( s ); 234 logwindow->log( s );
225 235
226} 236}
227 237
228void Wellenreiter::buttonClicked() 238void Wellenreiter::buttonClicked()
229{ 239{
230 240
231 // FIXME: communicate with daemon and set button text according to state 241 // FIXME: communicate with daemon and set button text according to state
232 242
233 button->setText( "Stop Scanning" ); 243 button->setText( "Stop Scanning" );
234 244
235 // 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
236 246
237 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 );
238 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 );
239 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 );
240 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 );
241 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 );
242 252
243 QString command ("98"); 253 QString command ("98");
244 254
245 //sendcomm( DAEMONADDR, DAEMONPORT, (const char*) command ); 255 //sendcomm( DAEMONADDR, DAEMONPORT, (const char*) command );
246 256
247} 257}
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/sniff.cc b/noncore/net/wellenreiter/libwellenreiter/source/sniff.cc
index 6b0fffb..84caf12 100644
--- a/noncore/net/wellenreiter/libwellenreiter/source/sniff.cc
+++ b/noncore/net/wellenreiter/libwellenreiter/source/sniff.cc
@@ -1,335 +1,336 @@
1/* 1/*
2 * rfmon mode sniffer 2 * rfmon mode sniffer
3 * 3 *
4 * $Id$ 4 * $Id$
5 */ 5 */
6 6
7#include "sniff.hh" 7#include "sniff.hh"
8#include "ieee802_11.hh" 8#include "ieee802_11.hh"
9#include "extract.hh" 9#include "extract.hh"
10#include "log.hh" 10#include "log.hh"
11#include "proto.hh" 11#include "proto.hh"
12 12
13/* Main function, checks packets */ 13/* Main function, checks packets */
14void process_packets(const struct pcap_pkthdr *pkthdr, const unsigned char *packet, char *guihost, int guiport) 14void process_packets(const struct pcap_pkthdr *pkthdr, const unsigned char *packet, char *guihost, int guiport)
15{ 15{
16 unsigned int caplen = pkthdr->caplen; 16 unsigned int caplen = pkthdr->caplen;
17 unsigned int length = pkthdr->len; 17 unsigned int length = pkthdr->len;
18 u_int16_t fc; 18 u_int16_t fc;
19 unsigned int HEADER_LENGTH; 19 unsigned int HEADER_LENGTH;
20 20
21 /* pinfo holds all interresting information for us */ 21 /* pinfo holds all interresting information for us */
22 struct packetinfo pinfo; 22 struct packetinfo pinfo;
23 struct packetinfo *pinfoptr; 23 struct packetinfo *pinfoptr;
24 24
25 /* wl_network_t will finally be set and send to the ui */ 25 /* wl_network_t will finally be set and send to the ui */
26 wl_network_t wl_net; 26 wl_network_t wl_net;
27 27
28 pinfoptr=&pinfo; 28 pinfoptr=&pinfo;
29 29
30 pinfoptr->isvalid = 0; 30 pinfoptr->isvalid = 0;
31 pinfoptr->pktlen = pkthdr->len; 31 pinfoptr->pktlen = pkthdr->len;
32 32
33 if (caplen < IEEE802_11_FC_LEN) 33 if (caplen < IEEE802_11_FC_LEN)
34 { 34 {
35 /* This is a garbage packet, because is does not long enough 35 /* This is a garbage packet, because is does not long enough
36 to hold a 802.11b header */ 36 to hold a 802.11b header */
37 pinfoptr->isvalid = 0; 37 pinfoptr->isvalid = 0;
38 return; 38 return;
39 } 39 }
40 40
41 /* Gets the framecontrol bits (2bytes long) */ 41 /* Gets the framecontrol bits (2bytes long) */
42 fc = EXTRACT_LE_16BITS(packet); 42 fc = EXTRACT_LE_16BITS(packet);
43 43
44 HEADER_LENGTH = GetHeaderLength(fc); 44 HEADER_LENGTH = GetHeaderLength(fc);
45 45
46 if (caplen < HEADER_LENGTH) 46 if (caplen < HEADER_LENGTH)
47 { 47 {
48 /* This is a garbage packet, because it is not long enough 48 /* This is a garbage packet, because it is not long enough
49 to hold a correct header of its type */ 49 to hold a correct header of its type */
50 pinfoptr->isvalid = 0; 50 pinfoptr->isvalid = 0;
51 return; 51 return;
52 } 52 }
53 53
54 /* Decode 802.11b header out of the packet */ 54 /* Decode 802.11b header out of the packet */
55 if (decode_80211b_hdr(packet,pinfoptr) == 0) 55 if (decode_80211b_hdr(packet,pinfoptr) == 0)
56 { 56 {
57 /* Justification of the ofset to further process the packet */ 57 /* Justification of the ofset to further process the packet */
58 length -= HEADER_LENGTH; 58 length -= HEADER_LENGTH;
59 caplen -= HEADER_LENGTH; 59 caplen -= HEADER_LENGTH;
60 packet += HEADER_LENGTH; 60 packet += HEADER_LENGTH;
61 } 61 }
62 else /* Something is wrong,could not be a correct packet */ 62 else /* Something is wrong,could not be a correct packet */
63 return; 63 return;
64 64
65 switch (FC_TYPE(fc)) 65 switch (FC_TYPE(fc))
66 { 66 {
67 /* Is it a managemnet frame? */ 67 /* Is it a managemnet frame? */
68 case T_MGMT: 68 case T_MGMT:
69 switch (FC_SUBTYPE(fc)) 69 switch (FC_SUBTYPE(fc))
70 { 70 {
71 case ST_BEACON: 71 case ST_BEACON:
72 if (handle_beacon(fc, packet,pinfoptr) ==0) 72 if (handle_beacon(fc, packet,pinfoptr) ==0)
73 { 73 {
74 if (!strcmp(pinfoptr->desthwaddr,"ff:ff:ff:ff:ff:ff") == 0) 74 if (!strcmp(pinfoptr->desthwaddr,"ff:ff:ff:ff:ff:ff") == 0)
75 { 75 {
76 /* Every beacon must have the broadcast as destination 76 /* Every beacon must have the broadcast as destination
77 so it must be a shitti packet */ 77 so it must be a shitti packet */
78 pinfoptr->isvalid = 0; 78 pinfoptr->isvalid = 0;
79 return; 79 return;
80 } 80 }
81 81
82 if (pinfoptr->cap_ESS == pinfoptr->cap_IBSS) 82 if (pinfoptr->cap_ESS == pinfoptr->cap_IBSS)
83 { 83 {
84 /* Only one of both are possible, so must be 84 /* Only one of both are possible, so must be
85 a noise packet, if this comes up */ 85 a noise packet, if this comes up */
86 pinfoptr->isvalid = 0; 86 pinfoptr->isvalid = 0;
87 return; 87 return;
88 } 88 }
89 if (pinfoptr->channel < 1 || pinfoptr->channel > 14) 89 if (pinfoptr->channel < 1 || pinfoptr->channel > 14)
90 { 90 {
91 /* Only channels between 1 and 14 are possible 91 /* Only channels between 1 and 14 are possible
92 others must be noise packets */ 92 others must be noise packets */
93 pinfoptr->isvalid = 0; 93 pinfoptr->isvalid = 0;
94 return; 94 return;
95 } 95 }
96 96
97 97 printf( "cap_ESS is %d, cap_IBSS is %d\n", pinfoptr->cap_ESS, pinfoptr->cap_IBSS );
98
98 /* Here should be the infos to the gui issued */ 99 /* Here should be the infos to the gui issued */
99 if (pinfoptr->cap_ESS == 1 &&pinfoptr->cap_IBSS ==0) 100 if (pinfoptr->cap_ESS == 1 &&pinfoptr->cap_IBSS ==0)
100 { 101 {
101 wl_loginfo("Found an access point"); 102 wl_loginfo("Found an access point");
102 wl_net.net_type=1; 103 wl_net.net_type=1;
103 } 104 }
104 else if(pinfoptr->cap_ESS == 0 && pinfoptr->cap_IBSS == 2) 105 else if(pinfoptr->cap_ESS == 0 && pinfoptr->cap_IBSS == 2)
105 { 106 {
106 wl_loginfo("Found an ad-hoc network"); 107 wl_loginfo("Found an ad-hoc network");
107 wl_net.net_type=2; 108 wl_net.net_type=2;
108 } 109 }
109 if (strcmp (pinfoptr->ssid,NONBROADCASTING) ==0) 110 if (strcmp (pinfoptr->ssid,NONBROADCASTING) ==0)
110 { 111 {
111 wl_loginfo("Net is a non-broadcasting network"); 112 wl_loginfo("Net is a non-broadcasting network");
112 } 113 }
113 else 114 else
114 { 115 {
115 wl_loginfo("SSID is: %s", pinfoptr->ssid); 116 wl_loginfo("SSID is: %s", pinfoptr->ssid);
116 // wl_net.bssid=pinfoptr->ssid; 117 // wl_net.bssid=pinfoptr->ssid;
117 } 118 }
118 119
119 wl_loginfo("SSID length is: %d", pinfoptr->ssid_len); 120 wl_loginfo("SSID length is: %d", pinfoptr->ssid_len);
120 wl_net.ssid_len=pinfoptr->ssid_len; 121 wl_net.ssid_len=pinfoptr->ssid_len;
121 122
122 wl_loginfo("Channel is: %d", pinfoptr->channel); 123 wl_loginfo("Channel is: %d", pinfoptr->channel);
123 wl_net.channel=pinfoptr->channel; 124 wl_net.channel=pinfoptr->channel;
124 wl_net.wep=pinfoptr->cap_WEP; 125 wl_net.wep=pinfoptr->cap_WEP;
125 126
126 wl_loginfo("Mac is: %s", pinfoptr->sndhwaddr); 127 wl_loginfo("Mac is: %s", pinfoptr->sndhwaddr);
127 memcpy(wl_net.mac, pinfoptr->sndhwaddr, sizeof(wl_net.mac)-1);; 128 memcpy(wl_net.mac, pinfoptr->sndhwaddr, sizeof(wl_net.mac)-1);;
128 wl_loginfo("SSID is: %s", pinfoptr->ssid); 129 wl_loginfo("SSID is: %s", pinfoptr->ssid);
129 memcpy(wl_net.bssid, pinfoptr->ssid, sizeof(wl_net.bssid)-1); 130 memcpy(wl_net.bssid, pinfoptr->ssid, sizeof(wl_net.bssid)-1);
130 131
131 // printf ("\n\tDest : %s\n",pinfoptr->desthwaddr); 132 // printf ("\n\tDest : %s\n",pinfoptr->desthwaddr);
132 send_network_found((char *)guihost, guiport, &wl_net); 133 send_network_found((char *)guihost, guiport, &wl_net);
133 wl_loginfo("Sent network to GUI '%s:%d'", guihost, guiport); 134 wl_loginfo("Sent network to GUI '%s:%d'", guihost, guiport);
134 } 135 }
135 break; 136 break;
136 default: 137 default:
137 wl_logerr("Unknown IEEE802.11 frame subtype (%d)", FC_SUBTYPE(fc)); 138 wl_logerr("Unknown IEEE802.11 frame subtype (%d)", FC_SUBTYPE(fc));
138 break; 139 break;
139 } /* End of switch over different mgt frame types */ 140 } /* End of switch over different mgt frame types */
140 141
141 break; 142 break;
142 143
143 case T_CTRL: 144 case T_CTRL:
144 wl_loginfo("Received control frame, not implemented yet"); 145 wl_loginfo("Received control frame, not implemented yet");
145 break; 146 break;
146 147
147 case T_DATA: 148 case T_DATA:
148 wl_loginfo("Received date frame, not implemented yet"); 149 wl_loginfo("Received date frame, not implemented yet");
149 break; 150 break;
150 151
151 default: 152 default:
152 wl_logerr("Unknown IEEE802.11 frame type (%d)", FC_TYPE(fc)); 153 wl_logerr("Unknown IEEE802.11 frame type (%d)", FC_TYPE(fc));
153 break; 154 break;
154 } 155 }
155} 156}
156 157
157/* This decodes the 802.11b frame header out of the 802.11b packet 158/* This decodes the 802.11b frame header out of the 802.11b packet
158 all the infos is placed into the packetinfo structure */ 159 all the infos is placed into the packetinfo structure */
159int decode_80211b_hdr(const u_char *p,struct packetinfo *ppinfo) 160int decode_80211b_hdr(const u_char *p,struct packetinfo *ppinfo)
160{ 161{
161 const struct mgmt_header_t *mgthdr = (const struct mgmt_header_t *) p; 162 const struct mgmt_header_t *mgthdr = (const struct mgmt_header_t *) p;
162 ppinfo->fcsubtype = FC_SUBTYPE(mgthdr->fc); 163 ppinfo->fcsubtype = FC_SUBTYPE(mgthdr->fc);
163 164
164 /* Get the sender, bssid and dest mac address */ 165 /* Get the sender, bssid and dest mac address */
165 etheraddr_string(mgthdr->bssid,ppinfo->bssid); 166 etheraddr_string(mgthdr->bssid,ppinfo->bssid);
166 etheraddr_string(mgthdr->da,ppinfo->desthwaddr); 167 etheraddr_string(mgthdr->da,ppinfo->desthwaddr);
167 etheraddr_string(mgthdr->sa,ppinfo->sndhwaddr); 168 etheraddr_string(mgthdr->sa,ppinfo->sndhwaddr);
168 ppinfo->fc_wep = FC_WEP(mgthdr->fc); 169 ppinfo->fc_wep = FC_WEP(mgthdr->fc);
169 return 0; 170 return 0;
170} 171}
171 172
172 173
173void etheraddr_string(register const u_char *ep, char *text) 174void etheraddr_string(register const u_char *ep, char *text)
174{ 175{
175 static char hex[] = "0123456789abcdef"; 176 static char hex[] = "0123456789abcdef";
176 register unsigned int i, j; 177 register unsigned int i, j;
177 register char *cp; 178 register char *cp;
178 char buf[sizeof("00:00:00:00:00:00\0")]; 179 char buf[sizeof("00:00:00:00:00:00\0")];
179 cp = buf; 180 cp = buf;
180 if ((j = *ep >> 4) != 0) 181 if ((j = *ep >> 4) != 0)
181 { 182 {
182 *cp++ = hex[j]; 183 *cp++ = hex[j];
183 } 184 }
184 else 185 else
185 { 186 {
186 *cp++ = '0'; 187 *cp++ = '0';
187 } 188 }
188 *cp++ = hex[*ep++ & 0xf]; 189 *cp++ = hex[*ep++ & 0xf];
189 190
190 for (i = 5; (int)--i >= 0;) 191 for (i = 5; (int)--i >= 0;)
191 { 192 {
192 *cp++ = ':'; 193 *cp++ = ':';
193 if ((j = *ep >> 4) != 0) 194 if ((j = *ep >> 4) != 0)
194 { 195 {
195 *cp++ = hex[j]; 196 *cp++ = hex[j];
196 } 197 }
197 else 198 else
198 { 199 {
199 *cp++ = '0'; 200 *cp++ = '0';
200 } 201 }
201 202
202 *cp++ = hex[*ep++ & 0xf]; 203 *cp++ = hex[*ep++ & 0xf];
203 } 204 }
204 *cp = '\0'; 205 *cp = '\0';
205 strcpy(text,buf); 206 strcpy(text,buf);
206} 207}
207 208
208/* beacon handler */ 209/* beacon handler */
209int handle_beacon(u_int16_t fc, const u_char *p,struct packetinfo *ppinfo) 210int handle_beacon(u_int16_t fc, const u_char *p,struct packetinfo *ppinfo)
210{ 211{
211 struct mgmt_body_t pbody; 212 struct mgmt_body_t pbody;
212 int offset = 0; 213 int offset = 0;
213 214
214 /* Get the static informations out of the packet */ 215 /* Get the static informations out of the packet */
215 memset(&pbody, 0, sizeof(pbody)); 216 memset(&pbody, 0, sizeof(pbody));
216 memcpy(&pbody.timestamp, p, 8); 217 memcpy(&pbody.timestamp, p, 8);
217 offset += 8; 218 offset += 8;
218 pbody.beacon_interval = EXTRACT_LE_16BITS(p+offset); 219 pbody.beacon_interval = EXTRACT_LE_16BITS(p+offset);
219 offset += 2; 220 offset += 2;
220 pbody.capability_info = EXTRACT_LE_16BITS(p+offset); 221 pbody.capability_info = EXTRACT_LE_16BITS(p+offset);
221 offset += 2; 222 offset += 2;
222 223
223 /* Gets the different flags out of the capabilities */ 224 /* Gets the different flags out of the capabilities */
224 ppinfo->cap_ESS = CAPABILITY_ESS(pbody.capability_info); 225 ppinfo->cap_ESS = CAPABILITY_ESS(pbody.capability_info);
225 ppinfo->cap_IBSS = CAPABILITY_IBSS(pbody.capability_info); 226 ppinfo->cap_IBSS = CAPABILITY_IBSS(pbody.capability_info);
226 ppinfo->cap_WEP = CAPABILITY_PRIVACY(pbody.capability_info); 227 ppinfo->cap_WEP = CAPABILITY_PRIVACY(pbody.capability_info);
227 228
228 /* Gets the tagged elements out of the packets */ 229 /* Gets the tagged elements out of the packets */
229 while (offset + 1 < ppinfo->pktlen) 230 while (offset + 1 < ppinfo->pktlen)
230 { 231 {
231 switch (*(p + offset)) 232 switch (*(p + offset))
232 { 233 {
233 case E_SSID: 234 case E_SSID:
234 memcpy(&(pbody.ssid),p+offset,2); offset += 2; 235 memcpy(&(pbody.ssid),p+offset,2); offset += 2;
235 if (pbody.ssid.length > 0) 236 if (pbody.ssid.length > 0)
236 { 237 {
237 memcpy(&(pbody.ssid.ssid),p+offset,pbody.ssid.length); offset += pbody.ssid.length; 238 memcpy(&(pbody.ssid.ssid),p+offset,pbody.ssid.length); offset += pbody.ssid.length;
238 pbody.ssid.ssid[pbody.ssid.length]='\0'; 239 pbody.ssid.ssid[pbody.ssid.length]='\0';
239 if (strcmp((char *)pbody.ssid.ssid,"")==0) 240 if (strcmp((char *)pbody.ssid.ssid,"")==0)
240 memcpy(ppinfo->ssid, NONBROADCASTING, sizeof(ppinfo->ssid)); 241 memcpy(ppinfo->ssid, NONBROADCASTING, sizeof(ppinfo->ssid));
241 else 242 else
242 memcpy(ppinfo->ssid, pbody.ssid.ssid, sizeof(ppinfo->ssid)); 243 memcpy(ppinfo->ssid, pbody.ssid.ssid, sizeof(ppinfo->ssid));
243 ppinfo->ssid_len = pbody.ssid.length; 244 ppinfo->ssid_len = pbody.ssid.length;
244 } 245 }
245 break; 246 break;
246 247
247 case E_CHALLENGE: 248 case E_CHALLENGE:
248 memcpy(&(pbody.challenge),p+offset,2); offset += 2; 249 memcpy(&(pbody.challenge),p+offset,2); offset += 2;
249 if (pbody.challenge.length > 0) 250 if (pbody.challenge.length > 0)
250 { 251 {
251 memcpy(&(pbody.challenge.text),p+offset,pbody.challenge.length); offset += pbody.challenge.length; 252 memcpy(&(pbody.challenge.text),p+offset,pbody.challenge.length); offset += pbody.challenge.length;
252 pbody.challenge.text[pbody.challenge.length]='\0'; 253 pbody.challenge.text[pbody.challenge.length]='\0';
253 } 254 }
254 break; 255 break;
255 case E_RATES: 256 case E_RATES:
256 memcpy(&(pbody.rates),p+offset,2); offset += 2; 257 memcpy(&(pbody.rates),p+offset,2); offset += 2;
257 if (pbody.rates.length > 0) 258 if (pbody.rates.length > 0)
258 { 259 {
259 memcpy(&(pbody.rates.rate),p+offset,pbody.rates.length); offset += pbody.rates.length; 260 memcpy(&(pbody.rates.rate),p+offset,pbody.rates.length); offset += pbody.rates.length;
260 } 261 }
261 break; 262 break;
262 case E_DS: 263 case E_DS:
263 memcpy(&(pbody.ds),p+offset,3); offset +=3; 264 memcpy(&(pbody.ds),p+offset,3); offset +=3;
264 ppinfo->channel = pbody.ds.channel; 265 ppinfo->channel = pbody.ds.channel;
265 break; 266 break;
266 case E_CF: 267 case E_CF:
267 memcpy(&(pbody.cf),p+offset,8); offset +=8; 268 memcpy(&(pbody.cf),p+offset,8); offset +=8;
268 break; 269 break;
269 case E_TIM: 270 case E_TIM:
270 memcpy(&(pbody.tim),p+offset,2); offset +=2; 271 memcpy(&(pbody.tim),p+offset,2); offset +=2;
271 memcpy(&(pbody.tim.count),p+offset,3); offset +=3; 272 memcpy(&(pbody.tim.count),p+offset,3); offset +=3;
272 if ((pbody.tim.length -3) > 0) 273 if ((pbody.tim.length -3) > 0)
273 { 274 {
274 memcpy((pbody.tim.bitmap),p+(pbody.tim.length -3),(pbody.tim.length -3)); 275 memcpy((pbody.tim.bitmap),p+(pbody.tim.length -3),(pbody.tim.length -3));
275 offset += pbody.tim.length -3; 276 offset += pbody.tim.length -3;
276 } 277 }
277 break; 278 break;
278 default: 279 default:
279 280
280 offset+= *(p+offset+1) + 2; 281 offset+= *(p+offset+1) + 2;
281 break; 282 break;
282 } /* end of switch*/ 283 } /* end of switch*/
283 } /* end of for loop */ 284 } /* end of for loop */
284 return 0; 285 return 0;
285 286
286} /* End of handle_beacon */ 287} /* End of handle_beacon */
287 288
288 289
289int GetHeaderLength(u_int16_t fc) 290int GetHeaderLength(u_int16_t fc)
290{ 291{
291 int iLength=0; 292 int iLength=0;
292 293
293 switch (FC_TYPE(fc)) 294 switch (FC_TYPE(fc))
294 { 295 {
295 case T_MGMT: 296 case T_MGMT:
296 iLength = MGMT_HEADER_LEN; 297 iLength = MGMT_HEADER_LEN;
297 break; 298 break;
298 case T_CTRL: 299 case T_CTRL:
299 switch (FC_SUBTYPE(fc)) 300 switch (FC_SUBTYPE(fc))
300 { 301 {
301 case CTRL_PS_POLL: 302 case CTRL_PS_POLL:
302 iLength = CTRL_PS_POLL_LEN; 303 iLength = CTRL_PS_POLL_LEN;
303 break; 304 break;
304 case CTRL_RTS: 305 case CTRL_RTS:
305 iLength = CTRL_RTS_LEN; 306 iLength = CTRL_RTS_LEN;
306 break; 307 break;
307 case CTRL_CTS: 308 case CTRL_CTS:
308 iLength = CTRL_CTS_LEN; 309 iLength = CTRL_CTS_LEN;
309 break; 310 break;
310 case CTRL_ACK: 311 case CTRL_ACK:
311 iLength = CTRL_ACK_LEN; 312 iLength = CTRL_ACK_LEN;
312 break; 313 break;
313 case CTRL_CF_END: 314 case CTRL_CF_END:
314 iLength = CTRL_END_LEN; 315 iLength = CTRL_END_LEN;
315 break; 316 break;
316 case CTRL_END_ACK: 317 case CTRL_END_ACK:
317 iLength = CTRL_END_ACK_LEN; 318 iLength = CTRL_END_ACK_LEN;
318 break; 319 break;
319 default: 320 default:
320 iLength = 0; 321 iLength = 0;
321 break; 322 break;
322 } 323 }
323 break; 324 break;
324 case T_DATA: 325 case T_DATA:
325 if (FC_TO_DS(fc) && FC_FROM_DS(fc)) 326 if (FC_TO_DS(fc) && FC_FROM_DS(fc))
326 iLength = 30; 327 iLength = 30;
327 else 328 else
328 iLength = 24; 329 iLength = 24;
329 break; 330 break;
330 default: 331 default:
331 wl_logerr("unknown IEEE802.11 frame type (%d)", FC_TYPE(fc)); 332 wl_logerr("unknown IEEE802.11 frame type (%d)", FC_TYPE(fc));
332 break; 333 break;
333 } 334 }
334 return iLength; 335 return iLength;
335} 336}
diff --git a/noncore/net/wellenreiter/opie-wellenreiter.control b/noncore/net/wellenreiter/opie-wellenreiter.control
index da83359..83bfd0e 100644
--- a/noncore/net/wellenreiter/opie-wellenreiter.control
+++ b/noncore/net/wellenreiter/opie-wellenreiter.control
@@ -1,9 +1,9 @@
1Files: bin/wellenreiter bin/wellenreiterd 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)
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.