author | mickeyl <mickeyl> | 2003-03-30 01:51:14 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-03-30 01:51:14 (UTC) |
commit | d11a0154e2d9732854c9a3d598857bc20f359849 (patch) (unidiff) | |
tree | af0e0273d01f4f6c64c9f230f22bb91a7a8a21d8 | |
parent | 99899abc80a8aa05044eeecd8a061b0a8efaa713 (diff) | |
download | opie-d11a0154e2d9732854c9a3d598857bc20f359849.zip opie-d11a0154e2d9732854c9a3d598857bc20f359849.tar.gz opie-d11a0154e2d9732854c9a3d598857bc20f359849.tar.bz2 |
- the network work for libopie2 pays off...
- good bye to wellenreiterd, t'was fun but always too unstable and too hard to maintain
- good bye to libwellenreiter
55 files changed, 132 insertions, 3853 deletions
diff --git a/noncore/net/wellenreiter/Makefile.static b/noncore/net/wellenreiter/Makefile.static deleted file mode 100644 index d5cdf44..0000000 --- a/noncore/net/wellenreiter/Makefile.static +++ b/dev/null | |||
@@ -1,28 +0,0 @@ | |||
1 | # Warning: Handcrafted! | ||
2 | |||
3 | ############################################################################# | ||
4 | # Makefile for building targets in sub directories. | ||
5 | # Project: wellenreiter | ||
6 | # Template: subdirs | ||
7 | ############################################################################# | ||
8 | |||
9 | MAKEFILE=Makefile | ||
10 | TMAKE =tmake | ||
11 | |||
12 | SUBDIRS =libwellenreiter/source daemon/source gui cornucopia | ||
13 | |||
14 | all: $(SUBDIRS) | ||
15 | |||
16 | $(SUBDIRS): FORCE | ||
17 | cd $@; $(MAKE) | ||
18 | |||
19 | tmake: | ||
20 | tmake wellenreiter.pro | ||
21 | |||
22 | tmake_all: | ||
23 | for i in $(SUBDIRS); do ( if [ -d $$i ]; then cd $$i ; pro=`basename $$i`.pro ; $(TMAKE) $$pro -o $(MAKEFILE); grep "TEMPLATE.*subdirs" $$pro 2>/dev/null >/dev/null && $(MAKE) -f $(MAKEFILE) tmake_all || true; fi; ) ; done | ||
24 | |||
25 | clean release debug: | ||
26 | for i in $(SUBDIRS); do ( if [ -d $$i ]; then cd $$i ; $(MAKE) $@; fi; ) ; done | ||
27 | |||
28 | FORCE: | ||
diff --git a/noncore/net/wellenreiter/config.in b/noncore/net/wellenreiter/config.in index 19f85e2..e835d1f 100644 --- a/noncore/net/wellenreiter/config.in +++ b/noncore/net/wellenreiter/config.in | |||
@@ -3,2 +3,4 @@ | |||
3 | default "y" | 3 | default "y" |
4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE | 4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE && LIBOPIE2CORE && LIBOPIE2NET && LIBOPIE2UI |
5 | comment "wellenreiter needs libqpe, libopie1 and libopie2 (core+net+ui)" | ||
6 | depends !(( LIBQPE || LIBQPE-X11 ) && LIBOPIE && LIBOPIE2CORE && LIBOPIE2NET && LIBOPIE2UI) | ||
diff --git a/noncore/net/wellenreiter/contrib/.cvsignore b/noncore/net/wellenreiter/contrib/.cvsignore deleted file mode 100644 index 0e45b67..0000000 --- a/noncore/net/wellenreiter/contrib/.cvsignore +++ b/dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | *.o | ||
2 | *~ | ||
3 | moc_* | ||
4 | Makefile.* | ||
diff --git a/noncore/net/wellenreiter/contrib/orinoco_hopper/.cvsignore b/noncore/net/wellenreiter/contrib/orinoco_hopper/.cvsignore deleted file mode 100644 index 4299fd9..0000000 --- a/noncore/net/wellenreiter/contrib/orinoco_hopper/.cvsignore +++ b/dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | *.o | ||
2 | *~ | ||
3 | moc_* | ||
4 | Makefile* | ||
diff --git a/noncore/net/wellenreiter/cornucopia/.cvsignore b/noncore/net/wellenreiter/cornucopia/.cvsignore deleted file mode 100644 index 724d599..0000000 --- a/noncore/net/wellenreiter/cornucopia/.cvsignore +++ b/dev/null | |||
@@ -1,8 +0,0 @@ | |||
1 | *.o | ||
2 | *~ | ||
3 | Makefile* | ||
4 | moc_* | ||
5 | wellenreitertemplate.cpp | ||
6 | wellenreitertemplate.h | ||
7 | configbase.h | ||
8 | configbase.cpp | ||
diff --git a/noncore/net/wellenreiter/cornucopia/README b/noncore/net/wellenreiter/cornucopia/README deleted file mode 100644 index 486dc67..0000000 --- a/noncore/net/wellenreiter/cornucopia/README +++ b/dev/null | |||
@@ -1,124 +0,0 @@ | |||
1 | /******************************************************************** | ||
2 | /* This is an overview of the opielibs 1.2 project | ||
3 | /********************************************************************/ | ||
4 | |||
5 | Origin: opielibs is about creating classes to | ||
6 | * optimize Qt classes for the embedded environment | ||
7 | * provide sophisticated abstractions for developers | ||
8 | * provide complete documentation and working examples | ||
9 | * provide end users with a common look and feel | ||
10 | * reduce memory footprint through sharing code | ||
11 | * reduce possible bugs through reusing tested code | ||
12 | |||
13 | -------------------------------------------------------- | ||
14 | 1. General Overview | ||
15 | -------------------------------------------------------- | ||
16 | |||
17 | Separation into the following libraries: | ||
18 | - libopiecore | ||
19 | - libopieui | ||
20 | - libopiepim | ||
21 | - libopienet | ||
22 | |||
23 | 1.1 Contents of libopiecore [ opiecore ] | ||
24 | -------------------------------------------------------- | ||
25 | |||
26 | - oprocctrl | ||
27 | - oprocess | ||
28 | - odevice | ||
29 | - odevicebutton | ||
30 | |||
31 | - oconfig | ||
32 | - oconfiggroupsaver | ||
33 | - ocompletionbase | ||
34 | - ocompletion | ||
35 | - ocomptreenodelist | ||
36 | - ocomptreenode | ||
37 | - ocompletionwrapper | ||
38 | - oglobal | ||
39 | - oglobalsettings | ||
40 | - osortableitem | ||
41 | - osortablevaluelist | ||
42 | |||
43 | 1.2 Contents of libopieui [ opieui ] | ||
44 | -------------------------------------------------------- | ||
45 | |||
46 | - oapplication | ||
47 | |||
48 | - ofiledialog | ||
49 | - colordialog | ||
50 | - oclickablelabel | ||
51 | - ocolorbutton | ||
52 | - colorpopupmenu | ||
53 | - otabinfo | ||
54 | - otabbar | ||
55 | - otabwidget | ||
56 | - ofontmenu | ||
57 | - ofontselector | ||
58 | - ofileview | ||
59 | - oticker | ||
60 | |||
61 | - olistview | ||
62 | - olistviewitem | ||
63 | - oversatileview | ||
64 | - oversatileviewitem | ||
65 | - ocompletionbox | ||
66 | - olineedit | ||
67 | - ocombobox | ||
68 | - ohistorycombo | ||
69 | |||
70 | - omessagebox | ||
71 | - odialogbase | ||
72 | |||
73 | - todayconfigwidget (rather into opiepim?) | ||
74 | - orecurrancewidget (rather into opiepim?) | ||
75 | - otimepicker (rather into opiepim?) | ||
76 | |||
77 | 1.3 Contents of libopiepim [ opiepim ] | ||
78 | -------------------------------------------------------- | ||
79 | |||
80 | - ocheckitem | ||
81 | - todoevent | ||
82 | - todoresource | ||
83 | - todayplugininterface | ||
84 | - todovcalresource | ||
85 | |||
86 | 1.4 Contents of libopiedb [ opiedb ] | ||
87 | -------------------------------------------------------- | ||
88 | |||
89 | - tododb | ||
90 | - xmltree | ||
91 | |||
92 | 1.5 Contents of libopienet [ opienet ] | ||
93 | -------------------------------------------------------- | ||
94 | |||
95 | <libmail stuff> | ||
96 | <libbend stuff> | ||
97 | <libftp stuff> | ||
98 | |||
99 | -------------------------------------------------------- | ||
100 | 2.0 Feature Description | ||
101 | -------------------------------------------------------- | ||
102 | |||
103 | 2.1 libopiecore | ||
104 | |||
105 | ... | ||
106 | |||
107 | 2.2 libopieui | ||
108 | |||
109 | ... | ||
110 | |||
111 | 2.2.x OListView, OListViewItem, OListViewFactory | ||
112 | |||
113 | ... | ||
114 | |||
115 | 2.3 libopiepim | ||
116 | |||
117 | ... | ||
118 | |||
119 | 2.4 libopiedb | ||
120 | |||
121 | ... | ||
122 | |||
123 | 2.5 libopienet | ||
124 | |||
diff --git a/noncore/net/wellenreiter/cornucopia/cornucopia.pro b/noncore/net/wellenreiter/cornucopia/cornucopia.pro deleted file mode 100644 index 7ffa202..0000000 --- a/noncore/net/wellenreiter/cornucopia/cornucopia.pro +++ b/dev/null | |||
@@ -1,16 +0,0 @@ | |||
1 | DESTDIR = $(OPIEDIR)/lib | ||
2 | MOC_DIR = ./tmp | ||
3 | OBJECTS_DIR = ./tmp | ||
4 | TEMPLATE = lib | ||
5 | CONFIG = qt warn_on debug | ||
6 | VERSION = 0.1 | ||
7 | HEADERS = olistview.h | ||
8 | SOURCES = olistview.cpp | ||
9 | INCLUDEPATH = $(OPIEDIR)/include | ||
10 | DEPENDPATH = $(OPIEDIR)/include | ||
11 | TARGET = cornucopia | ||
12 | |||
13 | !contains( platform, x11 ) { | ||
14 | include ( $(OPIEDIR)/include.pro ) | ||
15 | } | ||
16 | |||
diff --git a/noncore/net/wellenreiter/cornucopia/olistview.cpp b/noncore/net/wellenreiter/cornucopia/olistview.cpp deleted file mode 100644 index c292eb9..0000000 --- a/noncore/net/wellenreiter/cornucopia/olistview.cpp +++ b/dev/null | |||
@@ -1,417 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | |||
4 | Copyright (C) 2003 Michael 'Mickey' Lauer | ||
5 | <mickey@tm.informatik.uni-frankfurt.de> | ||
6 | =. | ||
7 | .=l. | ||
8 | .>+-= | ||
9 | _;:, .> :=|. This program is free software; you can | ||
10 | .> <`_, > . <= redistribute it and/or modify it under | ||
11 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
12 | .="- .-=="i, .._ License as published by the Free Software | ||
13 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
14 | ._= =} : or (at your option) any later version. | ||
15 | .%`+i> _;_. | ||
16 | .i_,=:_. -<s. This program is distributed in the hope that | ||
17 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
18 | : .. .:, . . . without even the implied warranty of | ||
19 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
20 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
21 | ..}^=.= = ; Library General Public License for more | ||
22 | ++= -. .` .: details. | ||
23 | : = ...= . :.=- | ||
24 | -. .:....=;==+<; You should have received a copy of the GNU | ||
25 | -_. . . )=. = Library General Public License along with | ||
26 | -- :-=` this library; see the file COPYING.LIB. | ||
27 | If not, write to the Free Software Foundation, | ||
28 | Inc., 59 Temple Place - Suite 330, | ||
29 | Boston, MA 02111-1307, USA. | ||
30 | |||
31 | */ | ||
32 | |||
33 | #include <qcolor.h> | ||
34 | #include <qheader.h> | ||
35 | #include <qpainter.h> | ||
36 | #include <qpixmap.h> | ||
37 | |||
38 | #include "olistview.h" | ||
39 | |||
40 | //****************************** OListView ************************************************************************** | ||
41 | |||
42 | OListView::OListView( QWidget *parent, const char *name ) | ||
43 | :QListView( parent, name ) | ||
44 | { | ||
45 | //FIXME: get from global settings and calculate ==> see oglobalsettings.* | ||
46 | |||
47 | m_alternateBackground = QColor( 238, 246, 255 ); | ||
48 | m_columnSeparator = QPen( QColor( 150, 160, 170 ), 0, DotLine ); | ||
49 | m_fullWidth = true; | ||
50 | } | ||
51 | |||
52 | OListView::~OListView() | ||
53 | { | ||
54 | } | ||
55 | |||
56 | void OListView::setFullWidth( bool fullWidth ) | ||
57 | { | ||
58 | m_fullWidth = m_fullWidth; | ||
59 | #if QT_VERSION > 290 | ||
60 | header()->setStretchEnabled( fullWidth, columns()-1 ); | ||
61 | #endif | ||
62 | } | ||
63 | |||
64 | bool OListView::fullWidth() const | ||
65 | { | ||
66 | return m_fullWidth; | ||
67 | } | ||
68 | |||
69 | int OListView::addColumn( const QString& label, int width ) | ||
70 | { | ||
71 | int result = QListView::addColumn( label, width ); | ||
72 | #if QT_VERSION > 290 | ||
73 | if (m_fullWidth) { | ||
74 | header()->setStretchEnabled( false, columns()-2 ); | ||
75 | header()->setStretchEnabled( true, columns()-1 ); | ||
76 | } | ||
77 | #endif | ||
78 | return result; | ||
79 | } | ||
80 | |||
81 | int OListView::addColumn( const QIconSet& iconset, const QString& label, int width ) | ||
82 | { | ||
83 | int result = QListView::addColumn( iconset, label, width ); | ||
84 | #if QT_VERSION > 290 | ||
85 | if (m_fullWidth) { | ||
86 | header()->setStretchEnabled( false, columns()-2 ); | ||
87 | header()->setStretchEnabled( true, columns()-1 ); | ||
88 | } | ||
89 | #endif | ||
90 | return result; | ||
91 | } | ||
92 | |||
93 | void OListView::removeColumn( int index ) | ||
94 | { | ||
95 | QListView::removeColumn(index); | ||
96 | #if QT_VERSION > 290 | ||
97 | if ( m_fullWidth && index == columns() ) | ||
98 | { | ||
99 | header()->setStretchEnabled( true, columns()-1 ); | ||
100 | } | ||
101 | #endif | ||
102 | } | ||
103 | |||
104 | const QColor& OListView::alternateBackground() const | ||
105 | { | ||
106 | return m_alternateBackground; | ||
107 | } | ||
108 | |||
109 | void OListView::setAlternateBackground( const QColor &c ) | ||
110 | { | ||
111 | m_alternateBackground = c; | ||
112 | repaint(); | ||
113 | } | ||
114 | |||
115 | const QPen& OListView::columnSeparator() const | ||
116 | { | ||
117 | return m_columnSeparator; | ||
118 | } | ||
119 | |||
120 | void OListView::setColumnSeparator( const QPen& p ) | ||
121 | { | ||
122 | m_columnSeparator = p; | ||
123 | repaint(); | ||
124 | } | ||
125 | |||
126 | OListViewItem* OListView::childFactory() | ||
127 | { | ||
128 | return new OListViewItem( this ); | ||
129 | } | ||
130 | |||
131 | #ifndef QT_NO_DATASTREAM | ||
132 | void OListView::serializeTo( QDataStream& s ) const | ||
133 | { | ||
134 | #warning Caution... the binary format is still under construction... | ||
135 | qDebug( "storing OListView..." ); | ||
136 | |||
137 | // store number of columns and the labels | ||
138 | s << columns(); | ||
139 | for ( int i = 0; i < columns(); ++i ) | ||
140 | s << columnText( i ); | ||
141 | |||
142 | // calculate the number of top-level items to serialize | ||
143 | int items = 0; | ||
144 | QListViewItem* item = firstChild(); | ||
145 | while ( item ) | ||
146 | { | ||
147 | item = item->nextSibling(); | ||
148 | items++; | ||
149 | } | ||
150 | |||
151 | // store number of items and the items itself | ||
152 | s << items; | ||
153 | item = firstChild(); | ||
154 | for ( int i = 0; i < items; ++i ) | ||
155 | { | ||
156 | s << *static_cast<OListViewItem*>( item ); | ||
157 | item = item->nextSibling(); | ||
158 | } | ||
159 | |||
160 | qDebug( "OListview stored." ); | ||
161 | } | ||
162 | |||
163 | void OListView::serializeFrom( QDataStream& s ) | ||
164 | { | ||
165 | #warning Caution... the binary format is still under construction... | ||
166 | qDebug( "loading OListView..." ); | ||
167 | |||
168 | int cols; | ||
169 | s >> cols; | ||
170 | qDebug( "read number of columns = %d", cols ); | ||
171 | |||
172 | while ( columns() < cols ) addColumn( QString::null ); | ||
173 | |||
174 | for ( int i = 0; i < cols; ++i ) | ||
175 | { | ||
176 | QString coltext; | ||
177 | s >> coltext; | ||
178 | qDebug( "read text '%s' for column %d", (const char*) coltext, i ); | ||
179 | setColumnText( i, coltext ); | ||
180 | } | ||
181 | |||
182 | int items; | ||
183 | s >> items; | ||
184 | qDebug( "read number of items = %d", items ); | ||
185 | |||
186 | for ( int i = 0; i < items; ++i ) | ||
187 | { | ||
188 | OListViewItem* item = childFactory(); | ||
189 | s >> *item; | ||
190 | } | ||
191 | |||
192 | qDebug( "OListView loaded." ); | ||
193 | |||
194 | } | ||
195 | |||
196 | QDataStream& operator<<( QDataStream& s, const OListView& lv ) | ||
197 | { | ||
198 | lv.serializeTo( s ); | ||
199 | } | ||
200 | |||
201 | QDataStream& operator>>( QDataStream& s, OListView& lv ) | ||
202 | { | ||
203 | lv.serializeFrom( s ); | ||
204 | } | ||
205 | #endif // QT_NO_DATASTREAM | ||
206 | |||
207 | //****************************** OListViewItem *********************************************************************** | ||
208 | |||
209 | OListViewItem::OListViewItem(QListView *parent) | ||
210 | : QListViewItem(parent) | ||
211 | { | ||
212 | init(); | ||
213 | } | ||
214 | |||
215 | OListViewItem::OListViewItem(QListViewItem *parent) | ||
216 | : QListViewItem(parent) | ||
217 | { | ||
218 | init(); | ||
219 | } | ||
220 | |||
221 | OListViewItem::OListViewItem(QListView *parent, QListViewItem *after) | ||
222 | : QListViewItem(parent, after) | ||
223 | { | ||
224 | init(); | ||
225 | } | ||
226 | |||
227 | OListViewItem::OListViewItem(QListViewItem *parent, QListViewItem *after) | ||
228 | : QListViewItem(parent, after) | ||
229 | { | ||
230 | init(); | ||
231 | } | ||
232 | |||
233 | OListViewItem::OListViewItem(QListView *parent, | ||
234 | QString label1, QString label2, QString label3, QString label4, | ||
235 | QString label5, QString label6, QString label7, QString label8) | ||
236 | : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) | ||
237 | { | ||
238 | init(); | ||
239 | } | ||
240 | |||
241 | OListViewItem::OListViewItem(QListViewItem *parent, | ||
242 | QString label1, QString label2, QString label3, QString label4, | ||
243 | QString label5, QString label6, QString label7, QString label8) | ||
244 | : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) | ||
245 | { | ||
246 | init(); | ||
247 | } | ||
248 | |||
249 | OListViewItem::OListViewItem(QListView *parent, QListViewItem *after, | ||
250 | QString label1, QString label2, QString label3, QString label4, | ||
251 | QString label5, QString label6, QString label7, QString label8) | ||
252 | : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) | ||
253 | { | ||
254 | init(); | ||
255 | } | ||
256 | |||
257 | OListViewItem::OListViewItem(QListViewItem *parent, QListViewItem *after, | ||
258 | QString label1, QString label2, QString label3, QString label4, | ||
259 | QString label5, QString label6, QString label7, QString label8) | ||
260 | : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) | ||
261 | { | ||
262 | init(); | ||
263 | } | ||
264 | |||
265 | OListViewItem::~OListViewItem() | ||
266 | { | ||
267 | } | ||
268 | |||
269 | void OListViewItem::init() | ||
270 | { | ||
271 | m_known = false; | ||
272 | } | ||
273 | |||
274 | const QColor &OListViewItem::backgroundColor() | ||
275 | { | ||
276 | return isAlternate() ? static_cast<OListView*>(listView())->alternateBackground() : | ||
277 | listView()->viewport()->colorGroup().base(); | ||
278 | } | ||
279 | |||
280 | bool OListViewItem::isAlternate() | ||
281 | { | ||
282 | OListView *lv = static_cast<OListView*>( listView() ); | ||
283 | |||
284 | // check if the item above is an OListViewItem | ||
285 | OListViewItem *above = static_cast<OListViewItem*>( itemAbove() ); | ||
286 | /*if (! itemAbove()->inherits( "OListViewItem" )) return false;*/ | ||
287 | |||
288 | // check if we have a valid alternate background color | ||
289 | if (!(lv && lv->alternateBackground().isValid())) return false; | ||
290 | |||
291 | m_known = above ? above->m_known : true; | ||
292 | if (m_known) | ||
293 | { | ||
294 | m_odd = above ? !above->m_odd : false; | ||
295 | } | ||
296 | else | ||
297 | { | ||
298 | OListViewItem *item; | ||
299 | bool previous = true; | ||
300 | if (parent()) | ||
301 | { | ||
302 | item = static_cast<OListViewItem *>(parent()); | ||
303 | if ( item /*&& item->inherits( "OListViewItem" )*/ ) previous = item->m_odd; | ||
304 | item = static_cast<OListViewItem *>(parent()->firstChild()); | ||
305 | /* if ( !item.inherits( "OListViewItem" ) item = 0; */ | ||
306 | } | ||
307 | else | ||
308 | { | ||
309 | item = static_cast<OListViewItem *>(lv->firstChild()); | ||
310 | } | ||
311 | |||
312 | while(item) | ||
313 | { | ||
314 | item->m_odd = previous = !previous; | ||
315 | item->m_known = true; | ||
316 | item = static_cast<OListViewItem *>(item->nextSibling()); | ||
317 | /* if (!item.inherits( "OListViewItem" ) ) break; */ | ||
318 | } | ||
319 | } | ||
320 | return m_odd; | ||
321 | } | ||
322 | |||
323 | void OListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) | ||
324 | { | ||
325 | QColorGroup _cg = cg; | ||
326 | const QPixmap *pm = listView()->viewport()->backgroundPixmap(); | ||
327 | if (pm && !pm->isNull()) | ||
328 | { | ||
329 | _cg.setBrush( QColorGroup::Base, QBrush(backgroundColor(), *pm) ); | ||
330 | p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() ); | ||
331 | } | ||
332 | else if ( isAlternate() ) | ||
333 | { | ||
334 | _cg.setColor( QColorGroup::Base, static_cast<OListView*>( listView() )->alternateBackground() ); | ||
335 | } | ||
336 | QListViewItem::paintCell( p, _cg, column, width, alignment ); | ||
337 | |||
338 | //FIXME: Use styling here! | ||
339 | |||
340 | const QPen& pen = static_cast<OListView*>( listView() )->columnSeparator(); | ||
341 | p->setPen( pen ); | ||
342 | p->drawLine( width-1, 0, width-1, height() ); | ||
343 | } | ||
344 | |||
345 | OListViewItem* OListViewItem::childFactory() | ||
346 | { | ||
347 | return new OListViewItem( this ); | ||
348 | } | ||
349 | |||
350 | #ifndef QT_NO_DATASTREAM | ||
351 | void OListViewItem::serializeTo( QDataStream& s ) const | ||
352 | { | ||
353 | #warning Caution... the binary format is still under construction... | ||
354 | qDebug( "storing OListViewItem..." ); | ||
355 | |||
356 | // store item text | ||
357 | for ( int i = 0; i < listView()->columns(); ++i ) | ||
358 | { | ||
359 | s << text( i ); | ||
360 | } | ||
361 | |||
362 | // calculate the number of children to serialize | ||
363 | int items = 0; | ||
364 | QListViewItem* item = firstChild(); | ||
365 | while ( item ) | ||
366 | { | ||
367 | item = item->nextSibling(); | ||
368 | items++; | ||
369 | } | ||
370 | |||
371 | // store number of items and the items itself | ||
372 | s << items; | ||
373 | item = firstChild(); | ||
374 | for ( int i = 0; i < items; ++i ) | ||
375 | { | ||
376 | s << *static_cast<OListViewItem*>( item ); | ||
377 | item = item->nextSibling(); | ||
378 | } | ||
379 | |||
380 | qDebug( "OListviewItem stored." ); | ||
381 | } | ||
382 | void OListViewItem::serializeFrom( QDataStream& s ) | ||
383 | { | ||
384 | #warning Caution... the binary format is still under construction... | ||
385 | qDebug( "loading OListViewItem..." ); | ||
386 | |||
387 | for ( int i = 0; i < listView()->columns(); ++i ) | ||
388 | { | ||
389 | QString coltext; | ||
390 | s >> coltext; | ||
391 | qDebug( "read text '%s' for column %d", (const char*) coltext, i ); | ||
392 | setText( i, coltext ); | ||
393 | } | ||
394 | |||
395 | int items; | ||
396 | s >> items; | ||
397 | qDebug( "read number of items = %d", items ); | ||
398 | |||
399 | for ( int i = 0; i < items; ++i ) | ||
400 | { | ||
401 | OListViewItem* item = childFactory(); | ||
402 | s >> (*item); | ||
403 | } | ||
404 | |||
405 | qDebug( "OListViewItem loaded." ); | ||
406 | } | ||
407 | |||
408 | QDataStream& operator<<( QDataStream& s, const OListViewItem& lvi ) | ||
409 | { | ||
410 | lvi.serializeTo( s ); | ||
411 | } | ||
412 | |||
413 | QDataStream& operator>>( QDataStream& s, OListViewItem& lvi ) | ||
414 | { | ||
415 | lvi.serializeFrom( s ); | ||
416 | } | ||
417 | #endif // QT_NO_DATASTREAM | ||
diff --git a/noncore/net/wellenreiter/cornucopia/olistview.h b/noncore/net/wellenreiter/cornucopia/olistview.h deleted file mode 100644 index 8911e22..0000000 --- a/noncore/net/wellenreiter/cornucopia/olistview.h +++ b/dev/null | |||
@@ -1,237 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | |||
4 | Copyright (C) 2003 Michael 'Mickey' Lauer | ||
5 | <mickey@tm.informatik.uni-frankfurt.de> | ||
6 | =. | ||
7 | .=l. | ||
8 | .>+-= | ||
9 | _;:, .> :=|. This program is free software; you can | ||
10 | .> <`_, > . <= redistribute it and/or modify it under | ||
11 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
12 | .="- .-=="i, .._ License as published by the Free Software | ||
13 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
14 | ._= =} : or (at your option) any later version. | ||
15 | .%`+i> _;_. | ||
16 | .i_,=:_. -<s. This program is distributed in the hope that | ||
17 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
18 | : .. .:, . . . without even the implied warranty of | ||
19 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
20 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
21 | ..}^=.= = ; Library General Public License for more | ||
22 | ++= -. .` .: details. | ||
23 | : = ...= . :.=- | ||
24 | -. .:....=;==+<; You should have received a copy of the GNU | ||
25 | -_. . . )=. = Library General Public License along with | ||
26 | -- :-=` this library; see the file COPYING.LIB. | ||
27 | If not, write to the Free Software Foundation, | ||
28 | Inc., 59 Temple Place - Suite 330, | ||
29 | Boston, MA 02111-1307, USA. | ||
30 | |||
31 | */ | ||
32 | |||
33 | #ifndef OLISTVIEW_H | ||
34 | #define OLISTVIEW_H | ||
35 | |||
36 | #include <qcolor.h> | ||
37 | #include <qlistview.h> | ||
38 | #include <qpen.h> | ||
39 | #include <qdatastream.h> | ||
40 | |||
41 | class OListViewItem; | ||
42 | |||
43 | /** | ||
44 | * A @ref QListView variant featuring visual and functional enhancements | ||
45 | * like an alternate background for odd rows, an autostretch mode | ||
46 | * for the width of the widget ( >= Qt 3 only ) and persistence capabilities. | ||
47 | * | ||
48 | * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | ||
49 | * @short OListView list/tree widget. | ||
50 | */ | ||
51 | class OListView: public QListView | ||
52 | { | ||
53 | public: | ||
54 | /** | ||
55 | * Constructor. | ||
56 | * | ||
57 | * The parameters @p parent and @p name are handled by | ||
58 | * @ref QListView, as usual. | ||
59 | */ | ||
60 | OListView ( QWidget *parent = 0, const char *name = 0 ); | ||
61 | |||
62 | /** | ||
63 | * Destructor. | ||
64 | */ | ||
65 | virtual ~OListView(); | ||
66 | |||
67 | /** | ||
68 | * Let the last column fit exactly all the available width. | ||
69 | */ | ||
70 | void setFullWidth( bool fullWidth ); | ||
71 | |||
72 | /** | ||
73 | * Returns whether the last column is set to fit the available width. | ||
74 | */ | ||
75 | bool fullWidth() const; | ||
76 | |||
77 | /** | ||
78 | * Reimplemented for full width support | ||
79 | */ | ||
80 | virtual int addColumn( const QString& label, int width = -1 ); | ||
81 | |||
82 | /** | ||
83 | * Reimplemented for full width support | ||
84 | */ | ||
85 | virtual int addColumn( const QIconSet& iconset, const QString& label, int width = -1 ); | ||
86 | |||
87 | /** | ||
88 | * Reimplemented for full width support | ||
89 | */ | ||
90 | virtual void removeColumn(int index); | ||
91 | |||
92 | /** | ||
93 | * sets the alternate background background color. | ||
94 | * This only has an effect if the items are OListViewItems | ||
95 | * | ||
96 | * @param c the color to use for every other item. Set to an invalid | ||
97 | * color to disable alternate colors. | ||
98 | */ | ||
99 | void setAlternateBackground( const QColor &c ); | ||
100 | |||
101 | /** | ||
102 | * sets the column separator pen. | ||
103 | * | ||
104 | * @param p the pen used to draw the column separator. | ||
105 | */ | ||
106 | void setColumnSeparator( const QPen &p ); | ||
107 | |||
108 | /** | ||
109 | * @return the alternate background color | ||
110 | */ | ||
111 | const QColor& alternateBackground() const; | ||
112 | |||
113 | /** | ||
114 | * @return the column separator pen | ||
115 | */ | ||
116 | const QPen& columnSeparator() const; | ||
117 | |||
118 | /** | ||
119 | * create a list view item as child of this object | ||
120 | * @return the new object | ||
121 | */ | ||
122 | virtual OListViewItem* childFactory(); | ||
123 | |||
124 | #ifndef QT_NO_DATASTREAM | ||
125 | /** | ||
126 | * serialize this object to a @ref QDataStream | ||
127 | * @param s the stream used to serialize this object. | ||
128 | */ | ||
129 | virtual void serializeTo( QDataStream& s ) const; | ||
130 | |||
131 | /** | ||
132 | * serialize this object from a @ref QDataStream | ||
133 | * @param s the stream used to serialize this object. | ||
134 | */ | ||
135 | virtual void serializeFrom( QDataStream& s ); | ||
136 | #endif | ||
137 | |||
138 | private: | ||
139 | QColor m_alternateBackground; | ||
140 | bool m_fullWidth; | ||
141 | QPen m_columnSeparator; | ||
142 | }; | ||
143 | |||
144 | #ifndef QT_NO_DATASTREAM | ||
145 | /** | ||
146 | * \relates QListView | ||
147 | * Writes a listview to the stream and returns a reference to the stream. | ||
148 | */ | ||
149 | QDataStream& operator<<( QDataStream& s, const OListView& lv ); | ||
150 | /** | ||
151 | * \relates QListView | ||
152 | * Reads a listview from the stream and returns a reference to the stream. | ||
153 | */ | ||
154 | QDataStream& operator>>( QDataStream& s, OListView& lv ); | ||
155 | #endif // QT_NO_DATASTREAM | ||
156 | |||
157 | //****************************** OListViewItem ****************************************************************** | ||
158 | |||
159 | class OListViewItem: public QListViewItem | ||
160 | { | ||
161 | public: | ||
162 | OListViewItem( QListView * parent ); | ||
163 | OListViewItem( QListViewItem * parent ); | ||
164 | OListViewItem( QListView * parent, QListViewItem * after ); | ||
165 | OListViewItem( QListViewItem * parent, QListViewItem * after ); | ||
166 | |||
167 | OListViewItem( QListView * parent, | ||
168 | QString, QString = QString::null, | ||
169 | QString = QString::null, QString = QString::null, | ||
170 | QString = QString::null, QString = QString::null, | ||
171 | QString = QString::null, QString = QString::null ); | ||
172 | |||
173 | OListViewItem( QListViewItem * parent, | ||
174 | QString, QString = QString::null, | ||
175 | QString = QString::null, QString = QString::null, | ||
176 | QString = QString::null, QString = QString::null, | ||
177 | QString = QString::null, QString = QString::null ); | ||
178 | |||
179 | OListViewItem( QListView * parent, QListViewItem * after, | ||
180 | QString, QString = QString::null, | ||
181 | QString = QString::null, QString = QString::null, | ||
182 | QString = QString::null, QString = QString::null, | ||
183 | QString = QString::null, QString = QString::null ); | ||
184 | |||
185 | OListViewItem( QListViewItem * parent, QListViewItem * after, | ||
186 | QString, QString = QString::null, | ||
187 | QString = QString::null, QString = QString::null, | ||
188 | QString = QString::null, QString = QString::null, | ||
189 | QString = QString::null, QString = QString::null ); | ||
190 | |||
191 | virtual ~OListViewItem(); | ||
192 | |||
193 | const QColor& backgroundColor(); | ||
194 | bool isAlternate(); | ||
195 | void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment ); | ||
196 | void init(); | ||
197 | |||
198 | /** | ||
199 | * create a list view item as child of this object | ||
200 | * @return the new object | ||
201 | */ | ||
202 | virtual OListViewItem* childFactory(); | ||
203 | |||
204 | #ifndef QT_NO_DATASTREAM | ||
205 | /** | ||
206 | * serialize this object to or from a @ref QDataStream | ||
207 | * @param s the stream used to serialize this object. | ||
208 | */ | ||
209 | virtual void serializeTo( QDataStream& s ) const; | ||
210 | |||
211 | /** | ||
212 | * serialize this object to or from a @ref QDataStream | ||
213 | * @param s the stream used to serialize this object. | ||
214 | */ | ||
215 | virtual void serializeFrom( QDataStream& s ); | ||
216 | #endif | ||
217 | |||
218 | private: | ||
219 | bool m_known; | ||
220 | bool m_odd; | ||
221 | }; | ||
222 | |||
223 | #ifndef QT_NO_DATASTREAM | ||
224 | /** | ||
225 | * \relates QListViewItem | ||
226 | * Writes a listview item and all subitems recursively to the stream | ||
227 | * and returns a reference to the stream. | ||
228 | */ | ||
229 | QDataStream& operator<<( QDataStream &s, const OListViewItem& lvi ); | ||
230 | /** | ||
231 | * \relates QListViewItem | ||
232 | * Reads a listview item from the stream and returns a reference to the stream. | ||
233 | */ | ||
234 | QDataStream& operator>>( QDataStream &s, OListViewItem& lvi ); | ||
235 | #endif // QT_NO_DATASTREAM | ||
236 | |||
237 | #endif // OLISTVIEW_H | ||
diff --git a/noncore/net/wellenreiter/daemon/.cvsignore b/noncore/net/wellenreiter/daemon/.cvsignore deleted file mode 100644 index 4299fd9..0000000 --- a/noncore/net/wellenreiter/daemon/.cvsignore +++ b/dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | *.o | ||
2 | *~ | ||
3 | moc_* | ||
4 | Makefile* | ||
diff --git a/noncore/net/wellenreiter/daemon/daemon.pro b/noncore/net/wellenreiter/daemon/daemon.pro deleted file mode 100644 index 33a6bb9..0000000 --- a/noncore/net/wellenreiter/daemon/daemon.pro +++ b/dev/null | |||
@@ -1,16 +0,0 @@ | |||
1 | DESTDIR = $(OPIEDIR)/bin | ||
2 | TEMPLATE = app | ||
3 | CONFIG = warn_on debug | ||
4 | #CONFIG = warn_on release | ||
5 | HEADERS = source/config.hh source/daemon.hh | ||
6 | SOURCES = source/daemon.cc | ||
7 | INCLUDEPATH += ../ | ||
8 | DEPENDPATH += $(OPIEDIR)/include | ||
9 | LIBS += -lpcap -lpthread -L$(OPIEDIR)/lib -lwellenreiter | ||
10 | INTERFACES = | ||
11 | TARGET = wellenreiterd | ||
12 | DEFINES += DEBUG | ||
13 | |||
14 | !contains( platform, x11 ) { | ||
15 | include ( $(OPIEDIR)/include.pro ) | ||
16 | } | ||
diff --git a/noncore/net/wellenreiter/daemon/source/.cvsignore b/noncore/net/wellenreiter/daemon/source/.cvsignore deleted file mode 100644 index ed65c71..0000000 --- a/noncore/net/wellenreiter/daemon/source/.cvsignore +++ b/dev/null | |||
@@ -1,3 +0,0 @@ | |||
1 | *.o | ||
2 | *~ | ||
3 | moc_* | ||
diff --git a/noncore/net/wellenreiter/daemon/source/Makefile b/noncore/net/wellenreiter/daemon/source/Makefile deleted file mode 100644 index 38d61f1..0000000 --- a/noncore/net/wellenreiter/daemon/source/Makefile +++ b/dev/null | |||
@@ -1,25 +0,0 @@ | |||
1 | # $Id$ | ||
2 | |||
3 | CPP = g++ | ||
4 | CPPFLAGS= -g -Wall -pedantic -DDEBUG -I ../../ | ||
5 | LIBS = -lpthread -lpcap ../../libwellenreiter/source/libwellenreiter.a | ||
6 | OBJ = daemon.o | ||
7 | |||
8 | .SUFFIXES: | ||
9 | .PHONY: all wellenreiterd clean distclean realclean | ||
10 | |||
11 | %.o : %.cc | ||
12 | $(CPP) $(CPPFLAGS) -c $< -o $@ | ||
13 | |||
14 | all:wellenreiterd | ||
15 | |||
16 | wellenreiterd:$(OBJ) | ||
17 | $(CPP) $(CPPFLAGS) $(OBJ) $(LIBS) -o $@ | ||
18 | @echo Build wellenreiterd | ||
19 | |||
20 | clean distclean realclean: | ||
21 | @rm -f wellenreiterd *~ *.o | ||
22 | @echo All dependent files have been removed. | ||
23 | |||
24 | daemon.o:config.hh | ||
25 | |||
diff --git a/noncore/net/wellenreiter/daemon/source/config.hh b/noncore/net/wellenreiter/daemon/source/config.hh deleted file mode 100644 index 0ac7eb9..0000000 --- a/noncore/net/wellenreiter/daemon/source/config.hh +++ b/dev/null | |||
@@ -1,29 +0,0 @@ | |||
1 | /* | ||
2 | * | ||
3 | * Global configuration for wellenreiter | ||
4 | * | ||
5 | * $Id$ | ||
6 | * | ||
7 | * Written by Martin J. Muench <mjm@codito.de> | ||
8 | * | ||
9 | */ | ||
10 | |||
11 | #ifndef CONFIG_HH | ||
12 | #define CONFIG_HH | ||
13 | |||
14 | #define PROGNAME "wellenreiter" /* Name of program (for syslog et.al.) */ | ||
15 | #define VERSION "0.2" /* Version of wellenreiter */ | ||
16 | |||
17 | #define DAEMONADDR "127.0.0.1" | ||
18 | #define DAEMONPORT 37772 /* Port of Daemon */ | ||
19 | |||
20 | #define GUIADDR "127.0.0.1" /* Adress of GUI, later specified in configfile */ | ||
21 | #define GUIPORT 37773 /* Port of GUI, " " */ | ||
22 | |||
23 | /* Temporary cardmode stuff, will hopefully removed soon */ | ||
24 | #define CARD_TYPE_CISCO 1 | ||
25 | #define CARD_TYPE_NG 2 | ||
26 | #define CARD_TYPE_HOSTAP 3 | ||
27 | #define CARD_TYPE_ORINOCCO 4 | ||
28 | |||
29 | #endif /* CONFIG_HH */ | ||
diff --git a/noncore/net/wellenreiter/daemon/source/daemon.cc b/noncore/net/wellenreiter/daemon/source/daemon.cc deleted file mode 100644 index b840f17..0000000 --- a/noncore/net/wellenreiter/daemon/source/daemon.cc +++ b/dev/null | |||
@@ -1,195 +0,0 @@ | |||
1 | /* | ||
2 | * Startup functions of wellenreiter | ||
3 | * | ||
4 | * $Id$ | ||
5 | */ | ||
6 | |||
7 | #include "config.hh" | ||
8 | #include "daemon.hh" | ||
9 | |||
10 | /* should be parsed from cfg-file */ | ||
11 | #define MAXCHANNEL 13 | ||
12 | #define CHANINTERVAL 500000 | ||
13 | |||
14 | |||
15 | /* Main function of wellenreiterd */ | ||
16 | int main(int argc, char **argv) | ||
17 | { | ||
18 | int sock, maxfd, retval; | ||
19 | char buffer[WL_SOCKBUF]; | ||
20 | struct pcap_pkthdr header; | ||
21 | struct sockaddr_in saddr; | ||
22 | // pcap_t *handletopcap; | ||
23 | wl_cardtype_t cardtype; | ||
24 | pthread_t sub; | ||
25 | const unsigned char *packet; | ||
26 | |||
27 | fd_set rset; | ||
28 | |||
29 | fprintf(stderr, "wellenreiterd %s\n\n", VERSION); | ||
30 | fprintf(stderr, "(c) 2002 by M-M-M\n\n"); | ||
31 | |||
32 | if(argc < 3) | ||
33 | usage(); | ||
34 | |||
35 | /* Set sniffer device */ | ||
36 | memset(cardtype.iface, 0, sizeof(cardtype.iface)); | ||
37 | strncpy(cardtype.iface, (char *)argv[1], sizeof(cardtype.iface) - 1); | ||
38 | |||
39 | /* Set card type */ | ||
40 | cardtype.type = atoi(argv[2]); | ||
41 | if(cardtype.type < 1 || cardtype.type > 4) | ||
42 | usage(); | ||
43 | |||
44 | /* Until we do not act as a read daemon, it starts the sniffer | ||
45 | right after startup */ | ||
46 | if (!start_sniffer(cardtype.iface,cardtype.type)) | ||
47 | { | ||
48 | wl_logerr("daemon, start_sniff did not return proper, aborting"); | ||
49 | exit(EXIT_FAILURE); | ||
50 | } | ||
51 | wl_loginfo ("daemon, wireless card prepared for sniffing"); | ||
52 | |||
53 | /* Setup socket for incoming commands */ | ||
54 | if((sock=wl_setupsock(DAEMONADDR, DAEMONPORT, saddr)) < 0) | ||
55 | { | ||
56 | wl_logerr("Cannot setup socket"); | ||
57 | exit(EXIT_FAILURE); | ||
58 | } | ||
59 | wl_loginfo("Set up socket '%d' for GUI communication", sock); | ||
60 | |||
61 | /* Create channelswitching thread */ | ||
62 | if(pthread_create(&sub, NULL, channel_switcher, | ||
63 | (void *)&cardtype) != 0) | ||
64 | { | ||
65 | wl_logerr("Cannot create thread: %s", strerror(errno)); | ||
66 | close(sock); | ||
67 | exit(EXIT_FAILURE); | ||
68 | } | ||
69 | if(pthread_detach(sub)) | ||
70 | { | ||
71 | wl_logerr("Error detaching thread"); | ||
72 | close(sock); | ||
73 | pthread_exit((pthread_t *)sub); | ||
74 | exit(EXIT_FAILURE); | ||
75 | } | ||
76 | wl_loginfo("Created and detached channel switching thread"); | ||
77 | |||
78 | FD_ZERO(&rset); | ||
79 | |||
80 | /* Start main loop */ | ||
81 | wl_loginfo("Starting main loop"); | ||
82 | while(1) | ||
83 | { | ||
84 | |||
85 | FD_SET(sock, &rset); | ||
86 | FD_SET(pcap_fileno(handletopcap), &rset); | ||
87 | |||
88 | /* maxfd = biggest filefd */ | ||
89 | maxfd = (sock > pcap_fileno(handletopcap) ? | ||
90 | sock + 1 : pcap_fileno(handletopcap)) + 1; | ||
91 | |||
92 | if(select(maxfd, &rset, NULL, NULL, NULL) < 0) | ||
93 | { | ||
94 | wl_logerr("Error calling select: %s", strerror(errno)); | ||
95 | break; | ||
96 | } | ||
97 | |||
98 | /* Got data on local socket from GUI */ | ||
99 | if(FD_ISSET(sock, &rset)) | ||
100 | { | ||
101 | /* Receive data from socket */ | ||
102 | if((retval=wl_recv(&sock, saddr, buffer, sizeof(buffer))) < 0) | ||
103 | { | ||
104 | wl_logerr("Error trying to read: %s", strerror(errno)); | ||
105 | break; | ||
106 | } | ||
107 | else | ||
108 | { | ||
109 | /* check type of packet and start function according to it */ | ||
110 | switch(retval) | ||
111 | { | ||
112 | case STARTSNIFF: | ||
113 | wl_loginfo("Received STARTSNIFF command"); | ||
114 | if(!send_ok(GUIADDR, GUIPORT, STARTSNIFF)) | ||
115 | wl_logerr("Cannot set OK_CMD to GUI"); | ||
116 | break; | ||
117 | case STOPSNIFF: | ||
118 | wl_loginfo("Received STOPSNIFF command"); | ||
119 | if(!send_ok(GUIADDR, GUIPORT, STOPSNIFF)) | ||
120 | wl_logerr("Cannot set FAIL_CMD to GUI"); | ||
121 | break; | ||
122 | default: | ||
123 | wl_logerr("Received unknown command: %d", retval); | ||
124 | break; | ||
125 | } | ||
126 | } | ||
127 | } /* FD_ISSET */ | ||
128 | |||
129 | /* Check pcap lib for packets */ | ||
130 | if(FD_ISSET(pcap_fileno(handletopcap), &rset)) | ||
131 | { | ||
132 | |||
133 | /* Grab one single packet */ | ||
134 | packet = pcap_next(handletopcap, &header); | ||
135 | |||
136 | /* process the packet */ | ||
137 | process_packets(&header,*&packet, GUIADDR, GUIPORT); | ||
138 | } | ||
139 | |||
140 | } /* while(1) */ | ||
141 | |||
142 | close(sock); | ||
143 | exit(EXIT_SUCCESS); | ||
144 | } | ||
145 | |||
146 | void | ||
147 | usage(void) | ||
148 | { | ||
149 | fprintf(stderr, "Usage: wellenreiter <device> <cardtype>\n" \ | ||
150 | "\t<device> = Wirelessdevice (e.g. wlan0)\n" \ | ||
151 | "\t<cardtype> = Cardtype:\tCisco\t= 1\n" \ | ||
152 | "\t\t\t\tNG\t= 2\n" \ | ||
153 | "\t\t\t\tHOSTAP\t= 3\n" \ | ||
154 | "\t\t\t\tLUCENT\t= 4\n"); | ||
155 | exit(EXIT_FAILURE); | ||
156 | } | ||
157 | |||
158 | void * | ||
159 | channel_switcher(void *cardtypeptr) | ||
160 | { | ||
161 | wl_cardtype_t *cardtype; | ||
162 | int maxchan=0; | ||
163 | int channel=1; | ||
164 | /* Get card info struct */ | ||
165 | cardtype = (wl_cardtype_t *)cardtypeptr; | ||
166 | /* Get from the wireless extension the amount of available channels | ||
167 | this prevents a fail in switching on us cards */ | ||
168 | maxchan = card_detect_channels(cardtype->iface); | ||
169 | |||
170 | if (maxchan < MAXCHANNEL) | ||
171 | { | ||
172 | #undef MAXCHANNEL | ||
173 | #define MAXCHANNEL maxchan | ||
174 | } | ||
175 | |||
176 | while(1) | ||
177 | { | ||
178 | |||
179 | /* If channel bigger than maxchannel, set to 1 */ | ||
180 | if(channel > MAXCHANNEL) | ||
181 | channel=1; | ||
182 | |||
183 | /* Set channel */ | ||
184 | if(!card_set_channel(cardtype->iface, channel, cardtype->type)) | ||
185 | { | ||
186 | wl_logerr("Cannot set channel, thread exiting"); | ||
187 | pthread_exit(NULL); | ||
188 | } | ||
189 | |||
190 | /* sleep */ | ||
191 | usleep(CHANINTERVAL); | ||
192 | |||
193 | channel++; | ||
194 | } /* while */ | ||
195 | } | ||
diff --git a/noncore/net/wellenreiter/daemon/source/daemon.hh b/noncore/net/wellenreiter/daemon/source/daemon.hh deleted file mode 100644 index f9ac45e..0000000 --- a/noncore/net/wellenreiter/daemon/source/daemon.hh +++ b/dev/null | |||
@@ -1,27 +0,0 @@ | |||
1 | /* $Id$ */ | ||
2 | |||
3 | #ifndef DAEMON_HH | ||
4 | #define DAEMON_HH | ||
5 | |||
6 | #include <stdio.h> | ||
7 | #include <string.h> | ||
8 | #include <sys/types.h> | ||
9 | #include <sys/time.h> | ||
10 | #include <sys/socket.h> | ||
11 | #include <netinet/in.h> | ||
12 | #include <arpa/inet.h> | ||
13 | #include <pthread.h> | ||
14 | #include <unistd.h> | ||
15 | #include <errno.h> | ||
16 | |||
17 | #include <libwellenreiter/source/wl_sock.hh> | ||
18 | #include <libwellenreiter/source/wl_log.hh> | ||
19 | #include <libwellenreiter/source/wl_types.hh> | ||
20 | #include <libwellenreiter/source/wl_proto.hh> | ||
21 | #include <libwellenreiter/source/cardmode.hh> | ||
22 | #include <libwellenreiter/source/sniff.hh> | ||
23 | |||
24 | void usage(void); | ||
25 | void *channel_switcher(void *); | ||
26 | |||
27 | #endif /* DAEMON_HH */ | ||
diff --git a/noncore/net/wellenreiter/docs/specification b/noncore/net/wellenreiter/docs/specification deleted file mode 100644 index 0766ef4..0000000 --- a/noncore/net/wellenreiter/docs/specification +++ b/dev/null | |||
@@ -1,140 +0,0 @@ | |||
1 | |||
2 | -[ Design of wellenreiter ]- | ||
3 | |||
4 | written by: Martin J. Muench <mjm@codito.de> | ||
5 | |||
6 | -[ Introduction | ||
7 | |||
8 | This is just a short overview of the new design of wellenreiter. | ||
9 | There will for sure be some changes and most parts will be specified | ||
10 | in more detail. | ||
11 | |||
12 | |||
13 | -[ Program | ||
14 | |||
15 | wellenreiter 1.7 | ||
16 | (will be named 2.0 after all the functions are implemented and the code | ||
17 | is cleaned up and audited) | ||
18 | |||
19 | |||
20 | -[ Short description | ||
21 | |||
22 | Wellenreiter is a wireless sniffing tool like netstumbler, kismet et al. | ||
23 | It discovers Access Points and Ad-Hoc networks and displays all available | ||
24 | information about them so that you can simply join unencrypted network | ||
25 | (without access restrictions) with the given informations. | ||
26 | For the latest version of wellenreiter look at: | ||
27 | http://wellenreiter.sourceforge.net. | ||
28 | |||
29 | |||
30 | -[ Overview | ||
31 | |||
32 | The software is divided into 2 sections, the daemon and the GUI. | ||
33 | The daemon does the active sniffing, analying stuff etc.pp. and | ||
34 | sends the informations to the GUI which displays the results. | ||
35 | |||
36 | |||
37 | -[ Configuration | ||
38 | |||
39 | The configuration is done by both, the GUI and the daemon so that the | ||
40 | GUI only provides the graphical interface to the configuration library | ||
41 | of the daemon. That means that the daemon loads the config file on | ||
42 | startup and sends the informations to the GUI. The GUI contains an option | ||
43 | "configure" where the settings can be changed. They will be sent to the | ||
44 | daemon which actually changes the configuration file. | ||
45 | The configuration file is placed in /usr/local/etc/wellenreiter.conf. | ||
46 | The whole content of this file cannot be specified yet. | ||
47 | |||
48 | OPIE specific: Opie contains a bunch of high-level configuration classes, | ||
49 | which are used by most Opie applications. It should be discussed whether | ||
50 | to use this structure / API (preferred) or use a proprietary one. | ||
51 | |||
52 | |||
53 | -[ Interaction GUI<->daemon | ||
54 | |||
55 | The GUI and the daemon will talk actively with eachother, meaning that | ||
56 | everyside who has informations for the other part will send it and not | ||
57 | wait for the other part to poll. | ||
58 | For example the sniffing function of the daemon is startet when a | ||
59 | "start_sniff" from the GUI arrived. And when the daemon found a network | ||
60 | it will be directly send to the GUI to be able to sniff in realtime. | ||
61 | |||
62 | |||
63 | -[ Communication GUI<->daemon | ||
64 | |||
65 | The GUI and the daemon run as threads within one process, where the GUI | ||
66 | thread will be the main thread. Both the daemon and the GUI thread are | ||
67 | (mostly) "free-running". Once the GUI thread is started and has finished | ||
68 | its initializations, it jumps into the Qt event loop ( QApplication::exec() ). | ||
69 | |||
70 | If the daemon thread is actively working and - | ||
71 | for instance - has acquired interesting data for the GUI thread to display, | ||
72 | it calls a special reentrant method of the GUI thread ( QApplication::postEvent ) | ||
73 | either transmitting the whole data structure or saying "Hey, there's interesting data | ||
74 | for you", which the GUI thread then retrieves. | ||
75 | To enable a free running daemon thread to actually receive messages from the | ||
76 | GUI thread, it's useful to to include a non-blocking check-for-messages-function | ||
77 | within the daemon main loop <since it is waiting for messages from a GUI thread, | ||
78 | this function has not be called very often>. If applicable, the daemon thread must | ||
79 | not call this function but only monitor some guarded variables from time to time | ||
80 | which the GUI thread can modify to alter the behaviour of the daemon thread. | ||
81 | |||
82 | IMHO this is a much more leightweight design than to use a proprietary udp-socket protocol. | ||
83 | |||
84 | |||
85 | -[ Setting card modes | ||
86 | |||
87 | One of the most interesting parts is the switching of the wirelesscards to | ||
88 | different channels, to monitor mode and so on. In the older versions this | ||
89 | actions were done by the calling of external programs, that is now obsolete. | ||
90 | We will use the API of the wireless drivers to set it up. | ||
91 | |||
92 | |||
93 | -[ Sniffing | ||
94 | |||
95 | The sniffing will be done by capturing and analyzing all packets using the | ||
96 | pcap library. The sniffer itself will be a function of the daemon which will | ||
97 | probably be threaded so that this function is non-blocking. | ||
98 | If a packet is found the sniffer sends it to an analyzer function which | ||
99 | analyzes the packets, strips the results and sends it to the GUI. | ||
100 | |||
101 | |||
102 | -[ Logging | ||
103 | |||
104 | The GUI should not need to log that much so it logs to STDERR. The daemon | ||
105 | will be able to run in foreground and log to STDERR and syslog but normally | ||
106 | it will only log to syslog (INFO/ERR). | ||
107 | Logging of found networks, packets and so on will also be done by the daemon | ||
108 | but set up by the GUI. | ||
109 | |||
110 | |||
111 | -[ GPS | ||
112 | |||
113 | The gps daemon software will be used, hopefully by their API if they provide | ||
114 | that. If not, we have to use system() calls, hope we do not. | ||
115 | |||
116 | |||
117 | -[ Security | ||
118 | |||
119 | The programm and the daemon will have to run with SUID privileges for being | ||
120 | able to change card modes etc. so the code has to be audited several times. | ||
121 | Setuid 0 will only be called when really needing the privileges and dropped | ||
122 | directly after every single systemcall. | ||
123 | The daemon will implement an access control list where it specifies which | ||
124 | IPs or network interfaces will have access to it. | ||
125 | The configuration file will be chmod'ed 0400, for writing the configuration | ||
126 | library will change the mode. Of course the file will be locked during | ||
127 | writing so no race conditions can occur. | ||
128 | |||
129 | |||
130 | -[ Documentation | ||
131 | |||
132 | Wellenreiter will have it's own wellenreiter(8) manpage with most parts of | ||
133 | the README file in there. | ||
134 | Also we will provide general documentation about wireless scanning, security | ||
135 | risks with wireless devices and so on. | ||
136 | Most documentation will be intern like this one. The GUI and the daemon | ||
137 | should have a non-technical documentation and a developers version so we | ||
138 | can easily develope with other peoples code without having to read it | ||
139 | completely. | ||
140 | |||
diff --git a/noncore/net/wellenreiter/gui/cardconfig.cpp b/noncore/net/wellenreiter/gui/cardconfig.cpp deleted file mode 100644 index 1ca1d27..0000000 --- a/noncore/net/wellenreiter/gui/cardconfig.cpp +++ b/dev/null | |||
@@ -1,29 +0,0 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Opie Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | **********************************************************************/ | ||
15 | |||
16 | #include "cardconfig.h" | ||
17 | |||
18 | #include <qstring.h> | ||
19 | |||
20 | CardConfig::CardConfig( const QString& interface, Type type, int hopinterval ) | ||
21 | :_interface( interface ), _type( type ), _hopinterval( hopinterval ) | ||
22 | { | ||
23 | |||
24 | } | ||
25 | |||
26 | CardConfig::~CardConfig() | ||
27 | { | ||
28 | } | ||
29 | |||
diff --git a/noncore/net/wellenreiter/gui/cardconfig.h b/noncore/net/wellenreiter/gui/cardconfig.h deleted file mode 100644 index f54ebac..0000000 --- a/noncore/net/wellenreiter/gui/cardconfig.h +++ b/dev/null | |||
@@ -1,58 +0,0 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Opie Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | **********************************************************************/ | ||
15 | |||
16 | #ifndef CARDCONFIG_H | ||
17 | #define CARDCONFIG_H | ||
18 | |||
19 | #include <qstring.h> | ||
20 | |||
21 | #ifdef QWS | ||
22 | #include <opie/odevice.h> | ||
23 | using namespace Opie; | ||
24 | #endif | ||
25 | |||
26 | class CardConfig | ||
27 | { | ||
28 | public: | ||
29 | |||
30 | typedef enum { Prism, Orinoco, HostAP, Manual } Type; | ||
31 | |||
32 | public: | ||
33 | |||
34 | CardConfig( const QString& interface, Type type = Manual, int hopinterval = 100 ); | ||
35 | virtual ~CardConfig(); | ||
36 | |||
37 | const QString& interface() { return _interface; }; | ||
38 | int hopinterval() { return _hopinterval; }; | ||
39 | Type type() { return _type; }; | ||
40 | |||
41 | #ifdef QWS | ||
42 | OSystem system() { return _system; }; | ||
43 | #endif | ||
44 | |||
45 | private: | ||
46 | |||
47 | QString _interface; | ||
48 | Type _type; | ||
49 | int _hopinterval; | ||
50 | |||
51 | #ifdef QWS | ||
52 | OSystem _system; | ||
53 | #endif | ||
54 | |||
55 | }; | ||
56 | |||
57 | #endif | ||
58 | |||
diff --git a/noncore/net/wellenreiter/gui/configbase.ui b/noncore/net/wellenreiter/gui/configbase.ui index 398118f..fa727f9 100644 --- a/noncore/net/wellenreiter/gui/configbase.ui +++ b/noncore/net/wellenreiter/gui/configbase.ui | |||
@@ -13,3 +13,3 @@ | |||
13 | <y>0</y> | 13 | <y>0</y> |
14 | <width>220</width> | 14 | <width>212</width> |
15 | <height>267</height> | 15 | <height>267</height> |
@@ -105,44 +105,2 @@ | |||
105 | <class>QComboBox</class> | 105 | <class>QComboBox</class> |
106 | <item> | ||
107 | <property> | ||
108 | <name>text</name> | ||
109 | <string><select></string> | ||
110 | </property> | ||
111 | </item> | ||
112 | <item> | ||
113 | <property> | ||
114 | <name>text</name> | ||
115 | <string>eth0</string> | ||
116 | </property> | ||
117 | </item> | ||
118 | <item> | ||
119 | <property> | ||
120 | <name>text</name> | ||
121 | <string>eth1</string> | ||
122 | </property> | ||
123 | </item> | ||
124 | <item> | ||
125 | <property> | ||
126 | <name>text</name> | ||
127 | <string>wlan0</string> | ||
128 | </property> | ||
129 | </item> | ||
130 | <item> | ||
131 | <property> | ||
132 | <name>text</name> | ||
133 | <string>wlan1</string> | ||
134 | </property> | ||
135 | </item> | ||
136 | <item> | ||
137 | <property> | ||
138 | <name>text</name> | ||
139 | <string>wifi0</string> | ||
140 | </property> | ||
141 | </item> | ||
142 | <item> | ||
143 | <property> | ||
144 | <name>text</name> | ||
145 | <string>wifi1</string> | ||
146 | </property> | ||
147 | </item> | ||
148 | <property stdset="1"> | 106 | <property stdset="1"> |
@@ -423,2 +381,6 @@ | |||
423 | <property stdset="1"> | 381 | <property stdset="1"> |
382 | <name>enabled</name> | ||
383 | <bool>false</bool> | ||
384 | </property> | ||
385 | <property stdset="1"> | ||
424 | <name>text</name> | 386 | <name>text</name> |
diff --git a/noncore/net/wellenreiter/gui/configwindow.cpp b/noncore/net/wellenreiter/gui/configwindow.cpp index f86b109..6dd862f 100644 --- a/noncore/net/wellenreiter/gui/configwindow.cpp +++ b/noncore/net/wellenreiter/gui/configwindow.cpp | |||
@@ -15,3 +15,6 @@ | |||
15 | 15 | ||
16 | /* LOCAL */ | ||
16 | #include "configwindow.h" | 17 | #include "configwindow.h" |
18 | |||
19 | /* QT */ | ||
17 | #include <qmap.h> | 20 | #include <qmap.h> |
@@ -22,2 +25,5 @@ | |||
22 | 25 | ||
26 | /* OPIE */ | ||
27 | #include <opie2/onetwork.h> | ||
28 | |||
23 | WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f ) | 29 | WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f ) |
@@ -31,2 +37,12 @@ WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char | |||
31 | 37 | ||
38 | // gather possible interface names from ONetwork | ||
39 | ONetwork* net = ONetwork::instance(); | ||
40 | ONetwork::InterfaceIterator it = net->iterator(); | ||
41 | while ( it.current() ) | ||
42 | { | ||
43 | if ( it.current()->isWireless() ) | ||
44 | interfaceName->insertItem( it.current()->name() ); | ||
45 | ++it; | ||
46 | } | ||
47 | |||
32 | #ifdef Q_WS_X11 // We're on X11: adding an Ok-Button for the Dialog here | 48 | #ifdef Q_WS_X11 // We're on X11: adding an Ok-Button for the Dialog here |
diff --git a/noncore/net/wellenreiter/gui/gui.pro b/noncore/net/wellenreiter/gui/gui.pro index 8861a50..200bfc1 100644 --- a/noncore/net/wellenreiter/gui/gui.pro +++ b/noncore/net/wellenreiter/gui/gui.pro | |||
@@ -13,4 +13,2 @@ HEADERS = wellenreiterbase.h \ | |||
13 | configwindow.h \ | 13 | configwindow.h \ |
14 | wlan.h \ | ||
15 | cardconfig.h \ | ||
16 | manufacturers.h | 14 | manufacturers.h |
@@ -25,9 +23,7 @@ SOURCES = main.cpp \ | |||
25 | configwindow.cpp \ | 23 | configwindow.cpp \ |
26 | wlan.cpp \ | ||
27 | cardconfig.cpp \ | ||
28 | manufacturers.cpp | 24 | manufacturers.cpp |
29 | 25 | ||
30 | INCLUDEPATH += $(OPIEDIR)/include ../ | 26 | INCLUDEPATH += $(OPIEDIR)/include |
31 | DEPENDPATH += $(OPIEDIR)/include ../ | 27 | DEPENDPATH += $(OPIEDIR)/include |
32 | LIBS += -L. -lwellenreiter -lcornucopia | 28 | LIBS += -L. -lwellenreiter -lopiecore2 -lopieui2 -lopienet2 |
33 | INTERFACES = configbase.ui | 29 | INTERFACES = configbase.ui |
diff --git a/noncore/net/wellenreiter/gui/main.cpp b/noncore/net/wellenreiter/gui/main.cpp index 270ce06..96a8c1c 100644 --- a/noncore/net/wellenreiter/gui/main.cpp +++ b/noncore/net/wellenreiter/gui/main.cpp | |||
@@ -16,8 +16,3 @@ | |||
16 | #include "mainwindow.h" | 16 | #include "mainwindow.h" |
17 | 17 | #include <opie2/oapplication.h> | |
18 | #ifdef QWS | ||
19 | #include <qpe/qpeapplication.h> | ||
20 | #else | ||
21 | #include <qapplication.h> | ||
22 | #endif | ||
23 | 18 | ||
@@ -25,19 +20,8 @@ int main( int argc, char **argv ) | |||
25 | { | 20 | { |
26 | #ifdef QWS | 21 | OApplication a( argc, argv, "Wellenreiter II" ); |
27 | QPEApplication a( argc, argv ); | 22 | WellenreiterMainWindow* w = new WellenreiterMainWindow(); |
28 | #else | 23 | a.showMainWidget( w ); |
29 | QApplication a( argc, argv ); | 24 | a.exec(); |
30 | #endif | 25 | delete w; |
31 | 26 | return 0; | |
32 | WellenreiterMainWindow w; | ||
33 | |||
34 | w.setCaption( "Wellenreiter/Opie" ); | ||
35 | #ifdef QWS | ||
36 | a.showMainWidget(&w); | ||
37 | #else | ||
38 | a.setMainWidget(&w); | ||
39 | w.show(); | ||
40 | #endif | ||
41 | |||
42 | return a.exec(); | ||
43 | } | 27 | } |
diff --git a/noncore/net/wellenreiter/gui/scanlist.h b/noncore/net/wellenreiter/gui/scanlist.h index 222217c..da9369f 100644 --- a/noncore/net/wellenreiter/gui/scanlist.h +++ b/noncore/net/wellenreiter/gui/scanlist.h | |||
@@ -18,3 +18,3 @@ | |||
18 | 18 | ||
19 | #include <cornucopia/olistview.h> | 19 | #include <opie2/olistview.h> |
20 | 20 | ||
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index 09a44e6..5bdc1b3 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp | |||
@@ -23,9 +23,2 @@ | |||
23 | 23 | ||
24 | // Qtopia | ||
25 | |||
26 | #ifdef QWS | ||
27 | #include <qpe/qpeapplication.h> | ||
28 | #include <qpe/global.h> | ||
29 | #endif | ||
30 | |||
31 | // Opie | 24 | // Opie |
@@ -37,2 +30,6 @@ using namespace Opie; | |||
37 | 30 | ||
31 | #include <opie2/oapplication.h> | ||
32 | #include <opie2/onetwork.h> | ||
33 | #include <opie2/opcap.h> | ||
34 | |||
38 | // Standard | 35 | // Standard |
@@ -44,5 +41,3 @@ using namespace Opie; | |||
44 | #include <sys/types.h> | 41 | #include <sys/types.h> |
45 | #include <sys/socket.h> | ||
46 | #include <stdlib.h> | 42 | #include <stdlib.h> |
47 | #include <fcntl.h> | ||
48 | 43 | ||
@@ -58,10 +53,5 @@ using namespace Opie; | |||
58 | 53 | ||
59 | #include <daemon/source/config.hh> | ||
60 | #include <libwellenreiter/source/wl_types.hh> | ||
61 | #include <libwellenreiter/source/wl_sock.hh> | ||
62 | #include <libwellenreiter/source/wl_proto.hh> | ||
63 | |||
64 | Wellenreiter::Wellenreiter( QWidget* parent ) | 54 | Wellenreiter::Wellenreiter( QWidget* parent ) |
65 | : WellenreiterBase( parent, 0, 0 ), | 55 | : WellenreiterBase( parent, 0, 0 ), |
66 | daemonRunning( false ), manufacturerdb( 0 ), configwindow( 0 ) | 56 | sniffing( false ), iface( 0 ), manufacturerdb( 0 ), configwindow( 0 ) |
67 | { | 57 | { |
@@ -93,21 +83,2 @@ Wellenreiter::Wellenreiter( QWidget* parent ) | |||
93 | 83 | ||
94 | // | ||
95 | // setup socket for daemon communication, register socket notifier | ||
96 | // | ||
97 | |||
98 | // struct sockaddr_in sockaddr; | ||
99 | daemon_fd = wl_setupsock( GUIADDR, GUIPORT, sockaddr ); | ||
100 | if ( daemon_fd == -1 ) | ||
101 | { | ||
102 | logwindow->log( "(E) Couldn't get file descriptor for commsocket." ); | ||
103 | } | ||
104 | else | ||
105 | { | ||
106 | int flags; | ||
107 | flags = fcntl( daemon_fd, F_GETFL, 0 ); | ||
108 | fcntl( daemon_fd, F_SETFL, flags | O_NONBLOCK ); | ||
109 | QSocketNotifier *sn = new QSocketNotifier( daemon_fd, QSocketNotifier::Read, this ); | ||
110 | connect( sn, SIGNAL( activated( int ) ), this, SLOT( dataReceived() ) ); | ||
111 | } | ||
112 | |||
113 | // setup GUI | 84 | // setup GUI |
@@ -118,2 +89,4 @@ Wellenreiter::Wellenreiter( QWidget* parent ) | |||
118 | 89 | ||
90 | pcap = new OPacketCapturer(); | ||
91 | |||
119 | } | 92 | } |
@@ -125,10 +98,3 @@ Wellenreiter::~Wellenreiter() | |||
125 | delete manufacturerdb; | 98 | delete manufacturerdb; |
126 | 99 | delete pcap; | |
127 | if ( daemon_fd != -1 ) | ||
128 | { | ||
129 | qDebug( "closing comm socket" ); | ||
130 | ::shutdown( daemon_fd, 0 ); | ||
131 | ::close( daemon_fd ); | ||
132 | qDebug( "comm socket closed." ); | ||
133 | } | ||
134 | } | 100 | } |
@@ -140,84 +106,30 @@ void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) | |||
140 | 106 | ||
141 | void Wellenreiter::handleMessage() | 107 | void Wellenreiter::receivePacket(OPacket* p) |
142 | { | ||
143 | // FIXME: receive message and handle it | ||
144 | |||
145 | qDebug( "received message from daemon." ); | ||
146 | |||
147 | /*char buffer[10000]; | ||
148 | memset( &buffer, 0, sizeof( buffer ) );*/ | ||
149 | |||
150 | char buffer[WL_SOCKBUF]; | ||
151 | |||
152 | // int result = #wl_recv( &daemon_fd, (char*) &buffer, sizeof(buffer) ); | ||
153 | |||
154 | /* | ||
155 | |||
156 | struct sockaddr from; | ||
157 | socklen_t len; | ||
158 | |||
159 | int result = recvfrom( daemon_fd, &buffer, 8192, MSG_WAITALL, &from, &len ); | ||
160 | qDebug( "received %d from recv [%d bytes]", result, len ); | ||
161 | |||
162 | */ | ||
163 | |||
164 | int result = wl_recv( &daemon_fd, sockaddr, (char*) &buffer, WL_SOCKBUF ); | ||
165 | |||
166 | if ( result == -1 ) | ||
167 | { | 108 | { |
168 | qDebug( "Warning: %s", strerror( errno ) ); | 109 | logwindow->log( "(d) Received data from daemon" ); |
169 | return; | 110 | //TODO |
170 | } | ||
171 | |||
172 | int command = buffer[1] - 48; | ||
173 | |||
174 | /* | ||
175 | typedef struct { | ||
176 | int net_type; 1 = Accesspoint ; 2 = Ad-Hoc | ||
177 | int ssid_len; Length of SSID | ||
178 | int channel; Channel | ||
179 | int wep; 1 = WEP enabled ; 0 = disabled | ||
180 | char mac[64]; MAC address of Accesspoint | ||
181 | char bssid[128]; BSSID of Accesspoint | ||
182 | } wl_network_t; | ||
183 | */ | ||
184 | |||
185 | qDebug( "Recv result: %d", ( result ) ); | ||
186 | qDebug( "Sniffer sent: '%s'", (const char*) buffer ); | ||
187 | hexwindow->log( (const char*) &buffer ); | ||
188 | |||
189 | if ( command == NETFOUND ) /* new network found */ | ||
190 | { | ||
191 | qDebug( "Sniffer said: new network found." ); | ||
192 | wl_network_t n; | ||
193 | get_network_found( &n, (char*) &buffer ); | ||
194 | |||
195 | qDebug( "Sniffer said: net_type is %d.", n.net_type ); | ||
196 | qDebug( "Sniffer said: MAC is %s", (const char*) &n.mac ); | ||
197 | |||
198 | //n.bssid[n.ssid_len] = "\0"; | ||
199 | 111 | ||
112 | // check if we received a beacon frame | ||
113 | // static_cast is justified here | ||
114 | OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) ); | ||
115 | if ( !beacon ) return; | ||
200 | QString type; | 116 | QString type; |
201 | 117 | ||
202 | if ( n.net_type == 1 ) | 118 | //FIXME: Can stations in ESS mode can be distinguished from APs? |
203 | type = "managed"; | 119 | //FIXME: Apparently yes, but not by listening to beacons, because |
204 | else | 120 | //FIXME: they simply don't send beacons in infrastructure mode. |
205 | type = "adhoc"; | 121 | //FIXME: so we also have to listen to data packets |
206 | |||
207 | netview->addNewItem( type, n.bssid, QString( (const char*) &n.mac ), n.wep, n.channel, 0 ); | ||
208 | |||
209 | } | ||
210 | 122 | ||
123 | if ( beacon->canIBSS() ) | ||
124 | type = "adhoc"; | ||
211 | else | 125 | else |
126 | type = "managed"; | ||
212 | 127 | ||
213 | { | 128 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); |
214 | qDebug( "unknown sniffer command." ); | 129 | QString essid = ssid ? ssid->ID() : "<unknown>"; |
215 | } | 130 | OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); |
216 | 131 | int channel = ds ? ds->channel() : -1; | |
217 | } | ||
218 | 132 | ||
219 | void Wellenreiter::dataReceived() | 133 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); |
220 | { | 134 | netView()->addNewItem( type, essid, header->macAddress2().toString(), header->usesWep(), channel, 0 ); |
221 | logwindow->log( "(d) Received data from daemon" ); | ||
222 | handleMessage(); | ||
223 | } | 135 | } |
@@ -226,22 +138,30 @@ void Wellenreiter::startStopClicked() | |||
226 | { | 138 | { |
227 | if ( daemonRunning ) | 139 | if ( sniffing ) |
228 | { | 140 | { |
229 | daemonRunning = false; | 141 | disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); |
230 | 142 | ||
231 | logwindow->log( "(i) Daemon has been stopped." ); | 143 | iface->setChannelHopping(); // stop hopping channels |
232 | setCaption( tr( "Wellenreiter/Opie" ) ); | 144 | pcap->close(); |
145 | sniffing = false; | ||
146 | oApp->setTitle(); | ||
233 | 147 | ||
234 | // Stop daemon - ugly for now... later better | 148 | // get interface name from config window |
149 | const QString& interface = configwindow->interfaceName->currentText(); | ||
150 | ONetwork* net = ONetwork::instance(); | ||
151 | iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); | ||
235 | 152 | ||
236 | system( "killall wellenreiterd" ); | 153 | // switch off monitor mode |
154 | iface->setMonitorMode( false ); | ||
155 | // switch off promisc flag | ||
156 | iface->setPromiscuousMode( false ); | ||
237 | 157 | ||
238 | // get configuration from config window | 158 | //TODO: Display "please wait..." (use owait?) |
239 | 159 | ||
240 | const QString& interface = configwindow->interfaceName->currentText(); | 160 | /* |
241 | |||
242 | // reset the interface trying to get it into a usable state again | ||
243 | 161 | ||
244 | QString cmdline; | 162 | QString cmdline; |
245 | cmdline.sprintf( "iwpriv %s monitor 0; ifdown %s; ifup %s", (const char*) interface, (const char*) interface, (const char*) interface ); | 163 | cmdline.sprintf( "ifdown %s; sleep 1; ifup %s", (const char*) interface, (const char*) interface, (const char*) interface ); |
246 | system( cmdline ); | 164 | system( cmdline ); //FIXME: Use OProcess |
165 | |||
166 | */ | ||
247 | 167 | ||
@@ -249,3 +169,3 @@ void Wellenreiter::startStopClicked() | |||
249 | 169 | ||
250 | QMessageBox::information( this, "Wellenreiter/Opie", "Your wireless card\nshould now be usable again." ); | 170 | //QMessageBox::information( this, "Wellenreiter II", "Your wireless card\nshould now be usable again." ); |
251 | } | 171 | } |
@@ -254,3 +174,2 @@ void Wellenreiter::startStopClicked() | |||
254 | { | 174 | { |
255 | |||
256 | // get configuration from config window | 175 | // get configuration from config window |
@@ -261,5 +180,5 @@ void Wellenreiter::startStopClicked() | |||
261 | 180 | ||
262 | if ( ( interface == "<select>" ) || ( cardtype == 0 ) ) | 181 | if ( ( interface == "" ) || ( cardtype == 0 ) ) |
263 | { | 182 | { |
264 | QMessageBox::information( this, "Wellenreiter/Opie", "Your device is not\nptoperly configured. Please reconfigure!" ); | 183 | QMessageBox::information( this, "Wellenreiter II", "Your device is not\nproperly configured. Please reconfigure!" ); |
265 | return; | 184 | return; |
@@ -267,14 +186,41 @@ void Wellenreiter::startStopClicked() | |||
267 | 186 | ||
268 | // start wellenreiterd | 187 | // configure device |
269 | 188 | ||
270 | QString cmdline; | 189 | ONetwork* net = ONetwork::instance(); |
271 | cmdline.sprintf( "wellenreiterd %s %d &", (const char*) interface, cardtype ); | 190 | iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); |
191 | |||
192 | // set monitor mode | ||
193 | |||
194 | switch ( cardtype ) | ||
195 | { | ||
196 | case 1: iface->setMonitoring( new OCiscoMonitoringInterface( iface ) ); break; | ||
197 | case 2: iface->setMonitoring( new OWlanNGMonitoringInterface( iface ) ); break; | ||
198 | case 3: iface->setMonitoring( new OHostAPMonitoringInterface( iface ) ); break; | ||
199 | case 4: iface->setMonitoring( new OOrinocoMonitoringInterface( iface ) ); break; | ||
200 | default: assert( 0 ); // shouldn't happen | ||
201 | } | ||
202 | |||
203 | iface->setMonitorMode( true ); | ||
204 | |||
205 | // open pcap and start sniffing | ||
206 | pcap->open( interface ); | ||
207 | |||
208 | if ( !pcap->isOpen() ) | ||
209 | { | ||
210 | QMessageBox::warning( this, "Wellenreiter II", "Can't open packet capturer:\n" + QString(strerror( errno ) )); | ||
211 | return; | ||
212 | } | ||
213 | |||
214 | // set capturer to non-blocking mode | ||
215 | pcap->setBlocking( false ); | ||
216 | |||
217 | // start channel hopper | ||
218 | iface->setChannelHopping( 1000 ); //use interval from config window | ||
272 | 219 | ||
273 | qDebug( "about to execute '%s' ...", (const char*) cmdline ); | 220 | // connect |
274 | system( cmdline ); | 221 | connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); |
275 | qDebug( "done!" ); | ||
276 | 222 | ||
277 | logwindow->log( "(i) Daemon has been started." ); | 223 | logwindow->log( "(i) Daemon has been started." ); |
278 | daemonRunning = true; | 224 | oApp->setTitle( "Scanning ..." ); |
279 | setCaption( tr( "Scanning ..." ) ); | 225 | sniffing = true; |
280 | 226 | ||
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.h b/noncore/net/wellenreiter/gui/wellenreiter.h index ee9dca9..3ec4021 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.h +++ b/noncore/net/wellenreiter/gui/wellenreiter.h | |||
@@ -25,19 +25,7 @@ using namespace Opie; | |||
25 | 25 | ||
26 | // ugly... not here! | ||
27 | |||
28 | #include <assert.h> | ||
29 | #include <errno.h> | ||
30 | #include <unistd.h> | ||
31 | #include <string.h> | ||
32 | #include <sys/types.h> | ||
33 | #include <sys/socket.h> | ||
34 | #include <stdlib.h> | ||
35 | #include <fcntl.h> | ||
36 | #include <daemon/source/config.hh> | ||
37 | #include <libwellenreiter/source/wl_types.hh> | ||
38 | #include <libwellenreiter/source/wl_sock.hh> | ||
39 | #include <libwellenreiter/source/wl_proto.hh> | ||
40 | |||
41 | class QTimerEvent; | 26 | class QTimerEvent; |
42 | class QPixmap; | 27 | class QPixmap; |
28 | class OPacket; | ||
29 | class OPacketCapturer; | ||
30 | class OWirelessNetworkInterface; | ||
43 | class ManufacturerDB; | 31 | class ManufacturerDB; |
@@ -55,9 +43,6 @@ class Wellenreiter : public WellenreiterBase { | |||
55 | MLogWindow* logWindow() const { return logwindow; }; | 43 | MLogWindow* logWindow() const { return logwindow; }; |
56 | bool isDaemonRunning() const { return daemonRunning; }; | 44 | bool isDaemonRunning() const { return sniffing; }; |
57 | |||
58 | protected: | ||
59 | bool daemonRunning; | ||
60 | 45 | ||
61 | public slots: | 46 | public slots: |
62 | void dataReceived(); | 47 | void receivePacket(OPacket*); |
63 | void startStopClicked(); | 48 | void startStopClicked(); |
@@ -65,3 +50,2 @@ class Wellenreiter : public WellenreiterBase { | |||
65 | private: | 50 | private: |
66 | int daemon_fd; // socket filedescriptor for udp communication socket | ||
67 | #ifdef QWS | 51 | #ifdef QWS |
@@ -69,7 +53,8 @@ class Wellenreiter : public WellenreiterBase { | |||
69 | #endif | 53 | #endif |
70 | void handleMessage(); | ||
71 | 54 | ||
55 | bool sniffing; | ||
56 | OWirelessNetworkInterface* iface; | ||
57 | OPacketCapturer* pcap; | ||
72 | ManufacturerDB* manufacturerdb; | 58 | ManufacturerDB* manufacturerdb; |
73 | WellenreiterConfigWindow* configwindow; | 59 | WellenreiterConfigWindow* configwindow; |
74 | struct sockaddr_in sockaddr; | ||
75 | 60 | ||
diff --git a/noncore/net/wellenreiter/gui/wlan.cpp b/noncore/net/wellenreiter/gui/wlan.cpp deleted file mode 100644 index b046cc8..0000000 --- a/noncore/net/wellenreiter/gui/wlan.cpp +++ b/dev/null | |||
@@ -1,57 +0,0 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Opie Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | **********************************************************************/ | ||
15 | |||
16 | #include "wlan.h" | ||
17 | #include "cardconfig.h" | ||
18 | |||
19 | // Qt | ||
20 | #include <qstring.h> | ||
21 | |||
22 | // Qtopia | ||
23 | #ifdef QWS | ||
24 | #include <opie/odevice.h> | ||
25 | using namespace Opie; | ||
26 | #endif | ||
27 | |||
28 | WLAN::WLAN( const QString& interface ) | ||
29 | { | ||
30 | _configuration = new CardConfig( interface ); | ||
31 | } | ||
32 | |||
33 | WLAN::WLAN( const CardConfig* configuration ) | ||
34 | { | ||
35 | _configuration = configuration; | ||
36 | |||
37 | } | ||
38 | |||
39 | WLAN::~WLAN() | ||
40 | { | ||
41 | delete _configuration; | ||
42 | |||
43 | } | ||
44 | |||
45 | void WLAN::setMonitorMode( bool enabled ) | ||
46 | { | ||
47 | |||
48 | /* | ||
49 | |||
50 | if ( _configuration->system() == System_OpenZaurus && _configuration->type() == CardConfig::Prism ) | ||
51 | { | ||
52 | } | ||
53 | |||
54 | */ | ||
55 | |||
56 | } | ||
57 | |||
diff --git a/noncore/net/wellenreiter/gui/wlan.h b/noncore/net/wellenreiter/gui/wlan.h deleted file mode 100644 index 139e218..0000000 --- a/noncore/net/wellenreiter/gui/wlan.h +++ b/dev/null | |||
@@ -1,38 +0,0 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Opie Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | **********************************************************************/ | ||
15 | |||
16 | #ifndef WLAN_H | ||
17 | #define WLAN_H | ||
18 | |||
19 | class QString; | ||
20 | class CardConfig; | ||
21 | |||
22 | class WLAN | ||
23 | { | ||
24 | public: | ||
25 | |||
26 | WLAN( const QString& interface ); | ||
27 | WLAN( const CardConfig* ); | ||
28 | virtual ~WLAN(); | ||
29 | void setMonitorMode( bool enabled ); | ||
30 | |||
31 | private: | ||
32 | |||
33 | const CardConfig* _configuration; | ||
34 | |||
35 | }; | ||
36 | |||
37 | #endif | ||
38 | |||
diff --git a/noncore/net/wellenreiter/libwellenreiter/.cvsignore b/noncore/net/wellenreiter/libwellenreiter/.cvsignore deleted file mode 100644 index 4299fd9..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/.cvsignore +++ b/dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | *.o | ||
2 | *~ | ||
3 | moc_* | ||
4 | Makefile* | ||
diff --git a/noncore/net/wellenreiter/libwellenreiter/docs/quickintro b/noncore/net/wellenreiter/libwellenreiter/docs/quickintro deleted file mode 100644 index 97458b7..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/docs/quickintro +++ b/dev/null | |||
@@ -1,88 +0,0 @@ | |||
1 | |||
2 | Name: libwellenreiter | ||
3 | Author: Martin J. Muench | ||
4 | |||
5 | NOTE: This is just a very short summary of the functions included | ||
6 | in libwellenreiter, written because a lack of time. The whole | ||
7 | library will be rewritten with extended documentation and | ||
8 | test programs. | ||
9 | |||
10 | -- | ||
11 | Wellenreiter types: | ||
12 | In proto.hh the following type (wl_network_t) is declared: | ||
13 | |||
14 | typedef struct { | ||
15 | int net_type; /* 1 = Accesspoint ; 2 = Ad-Hoc */ | ||
16 | int ssid_len; /* Length of SSID */ | ||
17 | int channel; /* Channel */ | ||
18 | int wep; /* 1 = WEP enabled ; 0 = disabled */ | ||
19 | char mac[64]; /* MAC address of Accesspoint */ | ||
20 | char bssid[128]; /* BSSID of Accesspoint */ | ||
21 | } wl_network_t; | ||
22 | |||
23 | When a network is found, the structure has to be set and | ||
24 | sent to the send_network_found() function. | ||
25 | |||
26 | When the GUI receives a found network string it calls the | ||
27 | get_network_found() function to get its own structure set. | ||
28 | |||
29 | -- | ||
30 | Included functions: | ||
31 | |||
32 | -- | ||
33 | Protocol: | ||
34 | |||
35 | Send a found network to GUI: | ||
36 | int send_network_found (const char *, int, void *); | ||
37 | |||
38 | The first two arguments are the guihost and the guiport. | ||
39 | The third is the filled structure (wl_network_t), that will | ||
40 | be send to the GUI. | ||
41 | |||
42 | Setup structure for found network: | ||
43 | int get_network_found (void *, const char *); | ||
44 | |||
45 | When the GUI receives a new network found packet it calls | ||
46 | this function and passes a wl_network_t structure and the | ||
47 | received buffer. The function will strip the data from | ||
48 | the buffer and set it to the structure. | ||
49 | |||
50 | -- | ||
51 | Log to syslog/info: | ||
52 | void wl_loginfo(const char *, ...); | ||
53 | |||
54 | Log to syslog/err: | ||
55 | void wl_logerr(const char *, ...); | ||
56 | |||
57 | Use like printf() function with format strings and so on. | ||
58 | |||
59 | -- | ||
60 | Setup udp socket for incoming commands: | ||
61 | int commsock(const char *, int); | ||
62 | |||
63 | Fist argument is the host where it should listen and second | ||
64 | is the port. Socket is returned, on failure -1 is returned. | ||
65 | |||
66 | |||
67 | Recvfrom socket: | ||
68 | int recv_commsock(int *, char *, int); | ||
69 | |||
70 | First argument is the address of the socket, second is a buffer | ||
71 | that should be filled in and the third is the maxlength of the | ||
72 | buffer. On error, -1 is returned, on success the number of | ||
73 | packet type is returned. (return value should be used with switch | ||
74 | command, for types see proto.hh) | ||
75 | |||
76 | Send command to udp socket: | ||
77 | int sendcomm(const char *, int, const char *, ...); | ||
78 | |||
79 | First two arguments are the host and port where the command should | ||
80 | be send to, followed by buffer that should be send. On error, -1 | ||
81 | is returned. | ||
82 | |||
83 | |||
84 | --- | ||
85 | |||
86 | Thats it for the moment. | ||
87 | |||
88 | mjm. | ||
diff --git a/noncore/net/wellenreiter/libwellenreiter/docs/wl_conf.8 b/noncore/net/wellenreiter/libwellenreiter/docs/wl_conf.8 deleted file mode 100644 index 8d2fe27..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/docs/wl_conf.8 +++ b/dev/null | |||
@@ -1,17 +0,0 @@ | |||
1 | wl_conf | ||
2 | |||
3 | #include <wellenreiter/wl_conf.hh> | ||
4 | |||
5 | int wl_checkcfg(void); | ||
6 | int wl_cfgvalue(const char *token, char *out, int maxlen); | ||
7 | |||
8 | wl_checkcfg checks whether the wellenreiter configfile exists. | ||
9 | wl_cfgvalue searches for the given token and copies maxlen | ||
10 | characters of its value to out. | ||
11 | |||
12 | wl_ckeckcfg returns 1 if the file exists and is readable and | ||
13 | 0 on error. | ||
14 | |||
15 | wl_cfgvalue returns -1 on error, 0 if nothing was found and | ||
16 | 1 on success. | ||
17 | |||
diff --git a/noncore/net/wellenreiter/libwellenreiter/docs/wl_log.8 b/noncore/net/wellenreiter/libwellenreiter/docs/wl_log.8 deleted file mode 100644 index 00262bd..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/docs/wl_log.8 +++ b/dev/null | |||
@@ -1,12 +0,0 @@ | |||
1 | wl_log | ||
2 | |||
3 | #include <wellenreiter/wl_log.hh> | ||
4 | |||
5 | void wl_loginfo(const char *string, ...) | ||
6 | void wl_logerr(const char *string, ...) | ||
7 | |||
8 | wl_loginfo() and wl_err() write string to syslog(), | ||
9 | either to INFO or to ERR. | ||
10 | |||
11 | no return values | ||
12 | |||
diff --git a/noncore/net/wellenreiter/libwellenreiter/docs/wl_sniff.8 b/noncore/net/wellenreiter/libwellenreiter/docs/wl_sniff.8 deleted file mode 100644 index 9a65223..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/docs/wl_sniff.8 +++ b/dev/null | |||
@@ -1,21 +0,0 @@ | |||
1 | sniff.cc | ||
2 | |||
3 | #include <wellenreiter/sniff.hh> | ||
4 | |||
5 | void process_packets(const struct pcap_pkthdr *pkthdr, | ||
6 | const unsigned char *packet, | ||
7 | char *guihost, | ||
8 | int guiport) | ||
9 | |||
10 | The function process_packets() will use libpcap to get the | ||
11 | informations for a 802.11b packet. When it finds a valid | ||
12 | network it calls the wl_send function and sends a found | ||
13 | network packet to the guiport on the guihost. | ||
14 | |||
15 | |||
16 | Return value | ||
17 | |||
18 | none | ||
19 | |||
20 | NOTE: process_packets() is void at the moment because there | ||
21 | will be alot of non-critical and annoying errors. | ||
diff --git a/noncore/net/wellenreiter/libwellenreiter/docs/wl_sock.8 b/noncore/net/wellenreiter/libwellenreiter/docs/wl_sock.8 deleted file mode 100644 index 62e935b..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/docs/wl_sock.8 +++ b/dev/null | |||
@@ -1,26 +0,0 @@ | |||
1 | wl_sock | ||
2 | |||
3 | #include <wellenreiter/wl_sock.hh> | ||
4 | |||
5 | int wl_setupsock(const char *host, int port, struct sockaddr_in *) | ||
6 | int wl_send(const char *host, int port, const char *string, ...) | ||
7 | int wl_recv(int *socket, struct sockaddr_in *, char *out, int len) | ||
8 | |||
9 | |||
10 | wl_setupsock() returns the number of the activated udp socket. | ||
11 | |||
12 | wl_send() sends string to the given host. | ||
13 | |||
14 | wl_recv() checks for incoming data on a socket (created using | ||
15 | wl_setupsock()). It writes the incoming data to out with a | ||
16 | maxlen of len. | ||
17 | |||
18 | |||
19 | wl_setupsock() returns -1 on error and the number of socket on | ||
20 | success. | ||
21 | wl_send() returns 0 on error and 1 on success. | ||
22 | wl_recv() returns -1 on error and the type of the received packet | ||
23 | on success. | ||
24 | |||
25 | Note: To use this function you have to set a sockaddr_in structure | ||
26 | and pass it to wl_setupsock and wl_receive. | ||
diff --git a/noncore/net/wellenreiter/libwellenreiter/docs/wl_types.8 b/noncore/net/wellenreiter/libwellenreiter/docs/wl_types.8 deleted file mode 100644 index d12f564..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/docs/wl_types.8 +++ b/dev/null | |||
@@ -1,25 +0,0 @@ | |||
1 | wl_types.hh | ||
2 | |||
3 | wl_types.hh contains the global buffers and type definitions. | ||
4 | |||
5 | At the moment these are: | ||
6 | |||
7 | /* Type definitions, to be continued */ | ||
8 | #define WL_NETFOUND 01 | ||
9 | #define WL_NETLOST 02 | ||
10 | #define WL_STARTSNIFF 98 | ||
11 | #define WL_STOPSNIFF 99 | ||
12 | |||
13 | #define WL_SOCKBUF 512 /* Buffer for wl_send and wl_recv calls */ | ||
14 | |||
15 | /* WL network structure */ | ||
16 | typedef struct { | ||
17 | int net_type; /* 1 = Accesspoint ; 2 = Ad-Hoc */ | ||
18 | int ssid_len; /* Length of SSID */ | ||
19 | int channel; /* Channel */ | ||
20 | int wep; /* 1 = WEP enabled ; 0 = disabled */ | ||
21 | char mac[64]; /* MAC address of Accesspoint */ | ||
22 | char bssid[128]; /* BSSID of Net */ | ||
23 | } wl_network_t; | ||
24 | |||
25 | Will be filled up with other structs and size definitions asap. | ||
diff --git a/noncore/net/wellenreiter/libwellenreiter/libwellenreiter.pro b/noncore/net/wellenreiter/libwellenreiter/libwellenreiter.pro deleted file mode 100644 index 5930c60..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/libwellenreiter.pro +++ b/dev/null | |||
@@ -1,16 +0,0 @@ | |||
1 | DESTDIR = $(OPIEDIR)/lib | ||
2 | TEMPLATE = lib | ||
3 | CONFIG = warn_on debug | ||
4 | VERSION = 0.2 | ||
5 | HEADERS = source/cardmode.hh source/wl_log.hh source/wl_proto.hh source/sniff.hh source/wl_sock.hh source/wl_types.hh | ||
6 | SOURCES = source/cardmode.cc source/wl_log.cc source/wl_proto.cc source/sniff.cc source/wl_sock.cc | ||
7 | |||
8 | LIBS = -lpcap | ||
9 | TMAKE_CFLAGS += -D__UNIX__ | ||
10 | DEFINES += DEBUG | ||
11 | TARGET = wellenreiter | ||
12 | |||
13 | !contains( platform, x11 ) { | ||
14 | include ( $(OPIEDIR)/include.pro ) | ||
15 | } | ||
16 | |||
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/.cvsignore b/noncore/net/wellenreiter/libwellenreiter/source/.cvsignore deleted file mode 100644 index ed65c71..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/source/.cvsignore +++ b/dev/null | |||
@@ -1,3 +0,0 @@ | |||
1 | *.o | ||
2 | *~ | ||
3 | moc_* | ||
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/Makefile b/noncore/net/wellenreiter/libwellenreiter/source/Makefile deleted file mode 100644 index 0017f05..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/source/Makefile +++ b/dev/null | |||
@@ -1,20 +0,0 @@ | |||
1 | # $Id$ | ||
2 | |||
3 | OBJ = wl_proto.o wl_sock.o wl_log.o wl_conf.o cardmode.o sniff.o | ||
4 | CPP = g++ | ||
5 | CPPFLAGS = -Wall -pedantic -g -DDEBUG | ||
6 | |||
7 | %.o : %.cc | ||
8 | $(CPP) $(CPPFLAGS) -c $< -o $@ | ||
9 | |||
10 | static:libwellenreiter.a | ||
11 | libwellenreiter.a: $(OBJ) | ||
12 | ar -cr libwellenreiter.a $(OBJ) | ||
13 | |||
14 | shared:libwellenreiter.so | ||
15 | libwellenreiter.so: $(OBJ) | ||
16 | $(CPP) $(CPPFLAGS) -shared -o libwellenreiter.so $(OBJ) | ||
17 | |||
18 | clean: | ||
19 | rm -f *.o *.a *.so *~ | ||
20 | |||
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc deleted file mode 100644 index 4f187c0..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.cc +++ b/dev/null | |||
@@ -1,451 +0,0 @@ | |||
1 | /* | ||
2 | * Set card modes for sniffing | ||
3 | * | ||
4 | * $Id$ | ||
5 | */ | ||
6 | |||
7 | #include "cardmode.hh" | ||
8 | #include "wl_log.hh" | ||
9 | pcap_t *handletopcap; | ||
10 | /* main card into monitor function */ | ||
11 | int card_into_monitormode (const char *device, int cardtype) | ||
12 | { | ||
13 | char CiscoRFMON[35] = "/proc/driver/aironet/"; | ||
14 | FILE *CISCO_CONFIG_FILE; | ||
15 | |||
16 | /* Checks if we have a device to sniff on */ | ||
17 | if(device == NULL) | ||
18 | { | ||
19 | wl_logerr("No device given"); | ||
20 | return 0; | ||
21 | } | ||
22 | |||
23 | /* Setting the promiscous and up flag to the interface */ | ||
24 | if (!card_set_promisc_up(device)) | ||
25 | { | ||
26 | wl_logerr("Cannot set interface to promisc mode"); | ||
27 | return 0; | ||
28 | } | ||
29 | wl_loginfo("Interface set to promisc mode"); | ||
30 | |||
31 | /* Check the cardtype and executes the commands to go into monitor mode */ | ||
32 | if (cardtype == CARD_TYPE_CISCO) | ||
33 | { | ||
34 | /* bring the sniffer into rfmon mode */ | ||
35 | snprintf(CiscoRFMON, sizeof(CiscoRFMON) - 1, DEFAULT_PATH, device); | ||
36 | if((CISCO_CONFIG_FILE = fopen(CiscoRFMON,"w")) == NULL) | ||
37 | { | ||
38 | wl_logerr("Cannot open config file: %s", strerror(errno)); | ||
39 | return 0; | ||
40 | } | ||
41 | fputs ("Mode: r",CISCO_CONFIG_FILE); | ||
42 | fputs ("Mode: y",CISCO_CONFIG_FILE); | ||
43 | fputs ("XmitPower: 1",CISCO_CONFIG_FILE); | ||
44 | fclose(CISCO_CONFIG_FILE); | ||
45 | } | ||
46 | else if (cardtype == CARD_TYPE_NG) | ||
47 | { | ||
48 | char wlanngcmd[80]; | ||
49 | snprintf(wlanngcmd, sizeof(wlanngcmd) - 1, "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=true", device, 1); | ||
50 | if (system(wlanngcmd) != 0) | ||
51 | { | ||
52 | wl_logerr("Could not set %s in raw mode, check cardtype", device); | ||
53 | return 0; | ||
54 | } | ||
55 | } | ||
56 | else if (cardtype == CARD_TYPE_HOSTAP) | ||
57 | { | ||
58 | #if WIRELESS_EXT > 14 | ||
59 | // IW_MODE_MONITOR was implemented in Wireless Extensions Version 15 | ||
60 | int skfd; | ||
61 | skfd = socket(AF_INET, SOCK_STREAM, 0); | ||
62 | struct iwreq wrq; | ||
63 | wrq.u.mode = IW_MODE_MONITOR; | ||
64 | |||
65 | if(iw_set_ext(skfd,(char *) device,SIOCSIWMODE,&wrq)<0) | ||
66 | { | ||
67 | wl_logerr("Could not set hostap card %s to raw mode, check cardtype", device); | ||
68 | return 0; | ||
69 | } | ||
70 | else | ||
71 | { | ||
72 | wl_loginfo("Successfully set hostap card %s into raw mode",device); | ||
73 | return 1; | ||
74 | } | ||
75 | return 1; | ||
76 | #else | ||
77 | // Wireless Extensions < Version 15 need iwpriv commandos for monitoring | ||
78 | int fd; | ||
79 | //Wireless tools structure for the iocalls | ||
80 | struct iwreq ireq; | ||
81 | int *ptr; | ||
82 | /* Socket needed to use the iocall to */ | ||
83 | fd = socket(AF_INET, SOCK_STREAM, 0); | ||
84 | |||
85 | if ( fd == -1 ) { | ||
86 | return -1; | ||
87 | } | ||
88 | |||
89 | ptr = (int *) ireq.u.name; | ||
90 | // This is the monitor mode for 802.11 non-prism header | ||
91 | ptr[0] = 2; | ||
92 | strcpy(ireq.ifr_ifrn.ifrn_name, device); | ||
93 | if (ioctl( fd, SIOCDEVPRIVATE, &ireq)==0) | ||
94 | { | ||
95 | /* All was fine... */ | ||
96 | close(fd); | ||
97 | wl_loginfo("Set hostap card %s into monitormode",device); | ||
98 | return 1; | ||
99 | } | ||
100 | else | ||
101 | { | ||
102 | /* iocall does not work */ | ||
103 | close(fd); | ||
104 | wl_logerr("Could not set hostap card %s into monitormode, check cardtype",device); | ||
105 | return 0; | ||
106 | } | ||
107 | #endif | ||
108 | } | ||
109 | else if (cardtype == CARD_TYPE_ORINOCCO ) | ||
110 | { | ||
111 | if (!card_set_channel (device, 1, CARD_TYPE_ORINOCCO)) | ||
112 | { | ||
113 | wl_logerr("Could not set %s in raw mode, check cardtype", device); | ||
114 | return 0; | ||
115 | } | ||
116 | else | ||
117 | { | ||
118 | wl_loginfo("Successfully set %s into raw mode",device); | ||
119 | } | ||
120 | } | ||
121 | |||
122 | /* Setting the promiscous and up flag to the interface */ | ||
123 | if (!card_check_rfmon_datalink(device)) | ||
124 | { | ||
125 | wl_logerr("Cannot set interface to rfmon mode"); | ||
126 | return 0; | ||
127 | } | ||
128 | else | ||
129 | { | ||
130 | wl_loginfo("Interface set to rfmon mode"); | ||
131 | } | ||
132 | return 1; | ||
133 | } | ||
134 | |||
135 | /* Check card is in the rfmon mode */ | ||
136 | int card_check_rfmon_datalink (const char *device) | ||
137 | { | ||
138 | int datalinktype=0; | ||
139 | pcap_t *phandle; | ||
140 | phandle = pcap_open_live((char *)device, 65,0,0,NULL); | ||
141 | datalinktype = pcap_datalink (phandle); | ||
142 | pcap_close(phandle); | ||
143 | |||
144 | if (datalinktype != DLT_IEEE802_11) /* Rawmode is IEEE802_11 */ | ||
145 | { | ||
146 | return 0; | ||
147 | } | ||
148 | else | ||
149 | { | ||
150 | wl_loginfo("Your successfully listen on %s in 802.11 raw mode", device); | ||
151 | return 1; | ||
152 | } | ||
153 | } | ||
154 | |||
155 | /* Ipaq running familiar does not have a loopback device, we need one */ | ||
156 | int check_loopback() | ||
157 | { | ||
158 | /* Checking for a loopback interface with 127.0.0.1, otherwise the other stuff seems to fail on | ||
159 | familiar linux on ipaq's */ | ||
160 | int err; | ||
161 | /* First generate a socket to use with iocalls */ | ||
162 | int fd = socket(AF_INET, SOCK_DGRAM, 0); | ||
163 | if (fd < 0) | ||
164 | { | ||
165 | /* In case of an error */ | ||
166 | wl_logerr("check_loopback, generation of a socket failed, cannot continue"); | ||
167 | return 0; | ||
168 | } | ||
169 | /* Fill an empty an interface structure with the right flags (UP and Promsic) */ | ||
170 | struct ifreq ifr; | ||
171 | strncpy(ifr.ifr_name, "lo",3); | ||
172 | |||
173 | /* Get the interface flags, loopback interfaces can be detected that way */ | ||
174 | err = ioctl(fd, SIOCGIFFLAGS, &ifr); | ||
175 | if (err < 0) | ||
176 | { | ||
177 | wl_logerr("check_loopback, could not get the flags of lo, check if you got a lo loopback interface, cannot continue"); | ||
178 | close(fd); | ||
179 | return 0; | ||
180 | } | ||
181 | /* Checking the flags for IFF_LOOPBACK flags */ | ||
182 | if(ifr.ifr_flags && IFF_LOOPBACK) | ||
183 | { | ||
184 | /* Yes, we do have a loopback interface....sup! */ | ||
185 | close(fd); | ||
186 | wl_loginfo ("check_loopback, check for loopback interface lo successful"); | ||
187 | return 1; | ||
188 | } | ||
189 | else | ||
190 | { | ||
191 | wl_logerr("check_loopback, did not found an interface lo with the IFF_LOOPBACK flag set, cannot continue"); | ||
192 | close(fd); | ||
193 | return 0; | ||
194 | } | ||
195 | /* Should never be reached */ | ||
196 | return 0; | ||
197 | } /*check_loopback */ | ||
198 | |||
199 | |||
200 | /* Set card into promisc mode */ | ||
201 | int card_set_promisc_up (const char *device) | ||
202 | { | ||
203 | int err; | ||
204 | /* First generate a socket to use with iocalls */ | ||
205 | int fd = socket(AF_INET, SOCK_DGRAM, 0); | ||
206 | if (fd < 0) | ||
207 | { | ||
208 | /* In case of an error */ | ||
209 | perror("socket"); | ||
210 | return 0; | ||
211 | } | ||
212 | |||
213 | /* Fill an empty an interface structure with the right flags (UP and Promsic) */ | ||
214 | struct ifreq ifr; | ||
215 | strncpy(ifr.ifr_name, device,10); | ||
216 | ifr.ifr_flags = IFF_UP + IFF_PROMISC; | ||
217 | err = ioctl(fd, SIOCSIFFLAGS, &ifr); | ||
218 | if (err < 0) | ||
219 | { | ||
220 | perror("Could not access the interface, "); | ||
221 | close(fd); | ||
222 | return 0; | ||
223 | } | ||
224 | |||
225 | /* Get the informations back from the interface to check if the flags are correct */ | ||
226 | strncpy(ifr.ifr_name, device,10); | ||
227 | err = ioctl(fd, SIOCGIFFLAGS, &ifr); | ||
228 | if (err < 0) | ||
229 | { | ||
230 | perror("Could not access the interface, "); | ||
231 | close(fd); | ||
232 | return 0; | ||
233 | } | ||
234 | |||
235 | if(ifr.ifr_flags && IFF_UP) | ||
236 | { | ||
237 | close(fd); | ||
238 | return 1; | ||
239 | } | ||
240 | else | ||
241 | { | ||
242 | wl_logerr("Could not set promisc flag on %d", device); | ||
243 | close(fd); | ||
244 | return 0; | ||
245 | } | ||
246 | } | ||
247 | |||
248 | /* Remove card from promisc mode */ | ||
249 | int card_remove_promisc (const char *device) | ||
250 | { | ||
251 | int err; | ||
252 | /* First generate a socket to use with iocalls */ | ||
253 | int fd = socket(AF_INET, SOCK_DGRAM, 0); | ||
254 | if (fd < 0) | ||
255 | { | ||
256 | /* In case of an error */ | ||
257 | perror("socket"); | ||
258 | return 0; | ||
259 | } | ||
260 | |||
261 | /* Fill an empty an interface structure with the right flags (UP and Promsic) */ | ||
262 | struct ifreq ifr; | ||
263 | /* Get the flags from the interface*/ | ||
264 | strncpy(ifr.ifr_name, device,10); | ||
265 | err = ioctl(fd, SIOCGIFFLAGS, &ifr); | ||
266 | if (err < 0) | ||
267 | { | ||
268 | perror("Could not access the interface, "); | ||
269 | close(fd); | ||
270 | return 0; | ||
271 | } | ||
272 | /* Remove the IFF_PROMISC flag */ | ||
273 | ifr.ifr_flags = ifr.ifr_flags - IFF_PROMISC; | ||
274 | /*Set the new flags to the interface*/ | ||
275 | err = ioctl(fd, SIOCSIFFLAGS, &ifr); | ||
276 | if (err < 0) | ||
277 | { | ||
278 | perror("Could not access the interface, "); | ||
279 | close(fd); | ||
280 | return 0; | ||
281 | } | ||
282 | |||
283 | /* Get the flags again to check if IFF_PROMISC is removed */ | ||
284 | err = ioctl(fd, SIOCGIFFLAGS, &ifr); | ||
285 | if (err < 0) | ||
286 | { | ||
287 | perror("Could not access the interface, "); | ||
288 | close(fd); | ||
289 | return 0; | ||
290 | } | ||
291 | if(ifr.ifr_flags && IFF_PROMISC) | ||
292 | { | ||
293 | wl_logerr("Could not remove the promisc flag on %d", device); | ||
294 | close(fd); | ||
295 | return 0; | ||
296 | } | ||
297 | else | ||
298 | { | ||
299 | /* Successfully removed the promisc flags */ | ||
300 | close(fd); | ||
301 | return 1; | ||
302 | } | ||
303 | } | ||
304 | |||
305 | |||
306 | |||
307 | |||
308 | /* Set channel (Wireless frequency) of the device */ | ||
309 | int card_set_channel (const char *device, int channel, int cardtype) | ||
310 | { | ||
311 | if (cardtype == CARD_TYPE_CISCO || cardtype == CARD_TYPE_NG) | ||
312 | { | ||
313 | /* Cisco and wlan-ng drivers don't need channelswitching */ | ||
314 | return 1; | ||
315 | } | ||
316 | /* If it is a lucent orinocco card */ | ||
317 | else if (cardtype == CARD_TYPE_ORINOCCO) | ||
318 | { | ||
319 | int fd; | ||
320 | //Wireless tools structure for the iocalls | ||
321 | struct iwreq ireq; | ||
322 | int *ptr; | ||
323 | /* Socket needed to use the iocall to */ | ||
324 | fd = socket(AF_INET, SOCK_STREAM, 0); | ||
325 | |||
326 | if ( fd == -1 ) { | ||
327 | return -1; | ||
328 | } | ||
329 | |||
330 | ptr = (int *) ireq.u.name; | ||
331 | // This is the monitor mode for 802.11 non-prism header | ||
332 | ptr[0] = 2; | ||
333 | ptr[1] = channel; | ||
334 | strcpy(ireq.ifr_ifrn.ifrn_name, device); | ||
335 | if (ioctl( fd, SIOCIWFIRSTPRIV + 0x8, &ireq)==0) | ||
336 | { | ||
337 | /* All was fine... */ | ||
338 | close(fd); | ||
339 | wl_loginfo("Set channel %d on interface %s",channel, device); | ||
340 | return 1; | ||
341 | } | ||
342 | else | ||
343 | { | ||
344 | /* iocall does not work */ | ||
345 | close(fd); | ||
346 | wl_logerr("Could not set channel %d on %s, check cardtype",channel, device); | ||
347 | return 0; | ||
348 | } | ||
349 | } | ||
350 | /* when it is an hostap card you need another iocall for channel switching */ | ||
351 | else if (cardtype == CARD_TYPE_HOSTAP) | ||
352 | { | ||
353 | int skfd; | ||
354 | skfd = socket(AF_INET, SOCK_STREAM, 0); | ||
355 | struct iwreq wrq; | ||
356 | iw_float2freq((double) channel, &wrq.u.freq); | ||
357 | |||
358 | if(iw_set_ext(skfd,(char *) device,SIOCSIWFREQ,&wrq)<0) | ||
359 | { | ||
360 | wl_logerr("Could not set hostap card %s to channel %d", device, channel); | ||
361 | return 0; | ||
362 | } | ||
363 | else | ||
364 | { | ||
365 | wl_loginfo("Successfully set hostap card %s to channel %d", device, channel); | ||
366 | return 1; | ||
367 | } | ||
368 | } | ||
369 | /* For undefined situations */ | ||
370 | return 0; | ||
371 | } | ||
372 | |||
373 | |||
374 | int card_detect_channels (char * device) | ||
375 | { | ||
376 | int skfd; | ||
377 | skfd = socket(AF_INET, SOCK_STREAM, 0); | ||
378 | struct iw_rangerange; | ||
379 | /* Get list of frequencies / channels */ | ||
380 | printf ("\n hostap card get the frequencies"); | ||
381 | /* Get list of frequencies / channels */ | ||
382 | if(iw_get_range_info(skfd, device, &range) < 0) | ||
383 | { /* We are failsave if something went wrong, asume only 11 channels */ | ||
384 | return 11; | ||
385 | } | ||
386 | else | ||
387 | { | ||
388 | if(range.num_frequency > 0) | ||
389 | { | ||
390 | return range.num_frequency; | ||
391 | } | ||
392 | else | ||
393 | { /* We are failsave asume only 11 channels */ | ||
394 | return 11; | ||
395 | } | ||
396 | } | ||
397 | |||
398 | } /* End of card_detect_channels */ | ||
399 | |||
400 | int iw_get_range_info(int skfd, const char * ifname, iw_range * range) | ||
401 | { | ||
402 | struct iwreq wrq2; | ||
403 | char buffer[sizeof(iw_range) * 2];/* Large enough */ | ||
404 | |||
405 | /* Cleanup */ | ||
406 | memset(buffer, 0, sizeof(buffer)); | ||
407 | wrq2.u.data.pointer = (caddr_t) buffer; | ||
408 | wrq2.u.data.length = sizeof(buffer); | ||
409 | wrq2.u.data.flags = 0; | ||
410 | |||
411 | if(iw_get_ext(skfd, (char *)ifname, SIOCGIWRANGE, &wrq2) < 0) | ||
412 | { | ||
413 | wl_logerr("Could not get the range from the interface"); | ||
414 | return(-1); | ||
415 | } | ||
416 | else | ||
417 | { | ||
418 | /* Copy stuff at the right place, ignore extra */ | ||
419 | memcpy((char *) range, buffer, sizeof(iw_range)); | ||
420 | return 0; | ||
421 | } | ||
422 | } | ||
423 | |||
424 | /*------------------------------------------------------------------*/ | ||
425 | /* | ||
426 | * Convert our internal representation of frequencies to a floating point. | ||
427 | */ | ||
428 | double iw_freq2float(iw_freq * in) | ||
429 | { | ||
430 | int i; | ||
431 | double res = (double) in->m; | ||
432 | for(i = 0; i < in->e; i++) | ||
433 | res *= 10; | ||
434 | return(res); | ||
435 | } | ||
436 | |||
437 | |||
438 | void iw_float2freq(double in, iw_freq *out) | ||
439 | { | ||
440 | /* Version without libm : slower */ | ||
441 | out->e = 0; | ||
442 | while(in > 1e9) | ||
443 | { | ||
444 | in /= 10; | ||
445 | out->e++; | ||
446 | } | ||
447 | out->m = (long) in; | ||
448 | } | ||
449 | |||
450 | |||
451 | |||
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh b/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh deleted file mode 100644 index 73e0ae1..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/source/cardmode.hh +++ b/dev/null | |||
@@ -1,107 +0,0 @@ | |||
1 | /* $Id$ */ | ||
2 | |||
3 | #ifndef CARDMODE_HH | ||
4 | #define CARDMODE_HH | ||
5 | |||
6 | #include <string.h> | ||
7 | #include <stdlib.h> | ||
8 | #include <errno.h> | ||
9 | #include <sys/types.h> | ||
10 | #include <sys/time.h> | ||
11 | #include <sys/socket.h> | ||
12 | #include <netinet/in.h> | ||
13 | #include <arpa/inet.h> | ||
14 | #include <sys/ioctl.h> | ||
15 | #include <unistd.h> | ||
16 | #include <linux/if.h> | ||
17 | |||
18 | /* Following typedefs are needed here, because linux/wireless.h | ||
19 | includes linux/ethertool.h which is using them */ | ||
20 | typedef signed char s8; | ||
21 | typedef unsigned char u8; | ||
22 | typedef signed short s16; | ||
23 | typedef unsigned short u16; | ||
24 | typedef signed int s32; | ||
25 | typedef unsigned int u32; | ||
26 | typedef signed long long s64; | ||
27 | typedef unsigned long long u64; | ||
28 | |||
29 | #include <linux/wireless.h> | ||
30 | |||
31 | #ifndef SIOCIWFIRSTPRIV | ||
32 | #define SIOCIWFIRSTPRIV SIOCDEVPRIVATE | ||
33 | #endif | ||
34 | |||
35 | extern "C" | ||
36 | { | ||
37 | #include <net/bpf.h> | ||
38 | #include <pcap.h> | ||
39 | } | ||
40 | |||
41 | extern pcap_t *handletopcap; | ||
42 | |||
43 | /* Defines, used for the card setup */ | ||
44 | #define DEFAULT_PATH "/proc/driver/aironet/%s/Config" | ||
45 | #define CISCO_STATUS "/proc/driver/aironet/%s/Status" | ||
46 | #define CARD_TYPE_CISCO 1 | ||
47 | #define CARD_TYPE_NG 2 | ||
48 | #define CARD_TYPE_HOSTAP 3 | ||
49 | #define CARD_TYPE_ORINOCCO 4 | ||
50 | |||
51 | /* Some usefull constants for frequencies */ | ||
52 | #define KILO 1e3 | ||
53 | #define MEGA 1e6 | ||
54 | #define GIGA 1e9 | ||
55 | |||
56 | |||
57 | /* only for now, until we have the daemon running */ | ||
58 | /*the config file should provide these information */ | ||
59 | #define CARD_TYPE CARD_TYPE_HOSTAP | ||
60 | |||
61 | /* Prototypes */ | ||
62 | int card_check_rfmon_datalink (const char *device); | ||
63 | int card_into_monitormode (const char *, int); | ||
64 | int check_loopback(); | ||
65 | int card_set_promisc_up (const char *device); | ||
66 | int card_remove_promisc (const char *device); | ||
67 | int card_set_channel (const char *device, int channel,int cardtype); | ||
68 | int iw_get_range_info(int skfd, const char * ifname, struct iw_range * range); | ||
69 | double iw_freq2float(iw_freq * in); | ||
70 | void iw_float2freq(double in, iw_freq *out); | ||
71 | int card_detect_channels (char * device); | ||
72 | |||
73 | /*------------------------------------------------------------------*/ | ||
74 | /* | ||
75 | * Wrapper to push some Wireless Parameter in the driver | ||
76 | */ | ||
77 | static inline int | ||
78 | iw_set_ext(int skfd, /* Socket to the kernel */ | ||
79 | char * ifname, /* Device name */ | ||
80 | int request,/* WE ID */ | ||
81 | struct iwreq * pwrq) /* Fixed part of the request */ | ||
82 | { | ||
83 | /* Set device name */ | ||
84 | strncpy(pwrq->ifr_name, ifname, IFNAMSIZ); | ||
85 | /* Do the request */ | ||
86 | return(ioctl(skfd, request, pwrq)); | ||
87 | } | ||
88 | |||
89 | /*------------------------------------------------------------------*/ | ||
90 | /* | ||
91 | * Wrapper to extract some Wireless Parameter out of the driver | ||
92 | */ | ||
93 | static inline int | ||
94 | iw_get_ext(int skfd, /* Socket to the kernel */ | ||
95 | char * ifname, /* Device name */ | ||
96 | int request,/* WE ID */ | ||
97 | struct iwreq * pwrq) /* Fixed part of the request */ | ||
98 | { | ||
99 | /* Set device name */ | ||
100 | strncpy(pwrq->ifr_name, ifname, IFNAMSIZ); | ||
101 | /* Do the request */ | ||
102 | return(ioctl(skfd, request, pwrq)); | ||
103 | } | ||
104 | |||
105 | |||
106 | |||
107 | #endif /* CARDMODE_HH */ | ||
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/extract.hh b/noncore/net/wellenreiter/libwellenreiter/source/extract.hh deleted file mode 100644 index f948bcb..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/source/extract.hh +++ b/dev/null | |||
@@ -1,59 +0,0 @@ | |||
1 | /* $Id$ */ | ||
2 | /* | ||
3 | * Copyright (c) 1992, 1993, 1994, 1995, 1996 | ||
4 | *The Regents of the University of California. All rights reserved. | ||
5 | * | ||
6 | * Redistribution and use in source and binary forms, with or without | ||
7 | * modification, are permitted provided that: (1) source code distributions | ||
8 | * retain the above copyright notice and this paragraph in its entirety, (2) | ||
9 | * distributions including binary code include the above copyright notice and | ||
10 | * this paragraph in its entirety in the documentation or other materials | ||
11 | * provided with the distribution, and (3) all advertising materials mentioning | ||
12 | * features or use of this software display the following acknowledgement: | ||
13 | * ``This product includes software developed by the University of California, | ||
14 | * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of | ||
15 | * the University nor the names of its contributors may be used to endorse | ||
16 | * or promote products derived from this software without specific prior | ||
17 | * written permission. | ||
18 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED | ||
19 | * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF | ||
20 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
21 | */ | ||
22 | /* Network to host order macros */ | ||
23 | |||
24 | #ifndef EXTRACT_HH | ||
25 | #define EXTRACT_HH | ||
26 | |||
27 | #ifdef LBL_ALIGN | ||
28 | #define EXTRACT_16BITS(p) \ | ||
29 | ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 0) << 8 | \ | ||
30 | (u_int16_t)*((const u_int8_t *)(p) + 1))) | ||
31 | #define EXTRACT_32BITS(p) \ | ||
32 | ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 24 | \ | ||
33 | (u_int32_t)*((const u_int8_t *)(p) + 1) << 16 | \ | ||
34 | (u_int32_t)*((const u_int8_t *)(p) + 2) << 8 | \ | ||
35 | (u_int32_t)*((const u_int8_t *)(p) + 3))) | ||
36 | #else | ||
37 | #define EXTRACT_16BITS(p) \ | ||
38 | ((u_int16_t)ntohs(*(const u_int16_t *)(p))) | ||
39 | #define EXTRACT_32BITS(p) \ | ||
40 | ((u_int32_t)ntohl(*(const u_int32_t *)(p))) | ||
41 | #endif | ||
42 | |||
43 | #define EXTRACT_24BITS(p) \ | ||
44 | ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 16 | \ | ||
45 | (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \ | ||
46 | (u_int32_t)*((const u_int8_t *)(p) + 2))) | ||
47 | |||
48 | /* Little endian protocol host order macros */ | ||
49 | #define EXTRACT_LE_8BITS(p) (*(p)) | ||
50 | #define EXTRACT_LE_16BITS(p) \ | ||
51 | ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 1) << 8 | \ | ||
52 | (u_int16_t)*((const u_int8_t *)(p) + 0))) | ||
53 | #define EXTRACT_LE_32BITS(p) \ | ||
54 | ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 3) << 24 | \ | ||
55 | (u_int32_t)*((const u_int8_t *)(p) + 2) << 16 | \ | ||
56 | (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \ | ||
57 | (u_int32_t)*((const u_int8_t *)(p) + 0))) | ||
58 | |||
59 | #endif /* EXTRACT_HH */ | ||
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/ieee802_11.hh b/noncore/net/wellenreiter/libwellenreiter/source/ieee802_11.hh deleted file mode 100644 index 872fd40..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/source/ieee802_11.hh +++ b/dev/null | |||
@@ -1,250 +0,0 @@ | |||
1 | /* $Id$ */ | ||
2 | /* | ||
3 | * Copyright (c) 2001 | ||
4 | *Fortress Technologies | ||
5 | * Charlie Lenahan ( clenahan@fortresstech.com ) | ||
6 | * | ||
7 | * Redistribution and use in source and binary forms, with or without | ||
8 | * modification, are permitted provided that: (1) source code distributions | ||
9 | * retain the above copyright notice and this paragraph in its entirety, (2) | ||
10 | * distributions including binary code include the above copyright notice and | ||
11 | * this paragraph in its entirety in the documentation or other materials | ||
12 | * provided with the distribution, and (3) all advertising materials mentioning | ||
13 | * features or use of this software display the following acknowledgement: | ||
14 | * ``This product includes software developed by the University of California, | ||
15 | * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of | ||
16 | * the University nor the names of its contributors may be used to endorse | ||
17 | * or promote products derived from this software without specific prior | ||
18 | * written permission. | ||
19 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED | ||
20 | * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF | ||
21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
22 | */ | ||
23 | |||
24 | #ifndef IEEE802_11_HH | ||
25 | #define IEEE802_11_HH | ||
26 | |||
27 | #define IEEE802_11_FC_LEN2 | ||
28 | |||
29 | #define T_MGMT 0x0 /* management */ | ||
30 | #define T_CTRL 0x1 /* control */ | ||
31 | #define T_DATA 0x2 /* data */ | ||
32 | #define T_RESV 0x3 /* reserved */ | ||
33 | |||
34 | #define ST_ASSOC_REQUEST 0x0 | ||
35 | #define ST_ASSOC_RESPONSE 0x1 | ||
36 | #define ST_REASSOC_REQUEST 0x2 | ||
37 | #define ST_REASSOC_RESPONSE 0x3 | ||
38 | #define ST_PROBE_REQUEST 0x4 | ||
39 | #define ST_PROBE_RESPONSE 0x5 | ||
40 | /* RESERVED 0x6 */ | ||
41 | /* RESERVED 0x7 */ | ||
42 | #define ST_BEACON 0x8 | ||
43 | #define ST_ATIM 0x9 | ||
44 | #define ST_DISASSOC 0xA | ||
45 | #define ST_AUTH 0xB | ||
46 | #define ST_DEAUTH 0xC | ||
47 | /* RESERVED 0xD */ | ||
48 | /* RESERVED 0xE */ | ||
49 | /* RESERVED 0xF */ | ||
50 | |||
51 | |||
52 | #define CTRL_PS_POLL0xA | ||
53 | #define CTRL_RTS0xB | ||
54 | #define CTRL_CTS0xC | ||
55 | #define CTRL_ACK0xD | ||
56 | #define CTRL_CF_END0xE | ||
57 | #define CTRL_END_ACK0xF | ||
58 | |||
59 | /* | ||
60 | * Bits in the frame control field. | ||
61 | */ | ||
62 | #define FC_VERSION(fc) ((fc) & 0x3) | ||
63 | #define FC_TYPE(fc) (((fc) >> 2) & 0x3) | ||
64 | #define FC_SUBTYPE(fc) (((fc) >> 4) & 0xF) | ||
65 | #define FC_TO_DS(fc) ((fc) & 0x0100) | ||
66 | #define FC_FROM_DS(fc) ((fc) & 0x0200) | ||
67 | #define FC_MORE_FLAG(fc)((fc) & 0x0400) | ||
68 | #define FC_RETRY(fc) ((fc) & 0x0800) | ||
69 | #define FC_POWER_MGMT(fc)((fc) & 0x1000) | ||
70 | #define FC_MORE_DATA(fc)((fc) & 0x2000) | ||
71 | #define FC_WEP(fc) ((fc) & 0x4000) | ||
72 | #define FC_ORDER(fc) ((fc) & 0x8000) | ||
73 | |||
74 | struct mgmt_header_t { | ||
75 | u_int16_tfc; | ||
76 | u_int16_t duration; | ||
77 | u_int8_tda[6]; | ||
78 | u_int8_tsa[6]; | ||
79 | u_int8_tbssid[6]; | ||
80 | u_int16_tseq_ctrl; | ||
81 | }; | ||
82 | |||
83 | #define MGMT_HEADER_LEN(2+2+6+6+6+2) | ||
84 | |||
85 | #define CAPABILITY_ESS(cap)((cap) & 0x0001) | ||
86 | #define CAPABILITY_IBSS(cap)((cap) & 0x0002) | ||
87 | #define CAPABILITY_CFP(cap)((cap) & 0x0004) | ||
88 | #define CAPABILITY_CFP_REQ(cap)((cap) & 0x0008) | ||
89 | #define CAPABILITY_PRIVACY(cap)((cap) & 0x0010) | ||
90 | |||
91 | struct ssid_t { | ||
92 | u_int8_telement_id; | ||
93 | u_int8_tlength; | ||
94 | u_char ssid[33]; /* 32 + 1 for null */ | ||
95 | } ; | ||
96 | |||
97 | struct rates_t { | ||
98 | u_int8_telement_id; | ||
99 | u_int8_tlength; | ||
100 | u_int8_trate[8]; | ||
101 | }; | ||
102 | |||
103 | struct challenge_t { | ||
104 | u_int8_telement_id; | ||
105 | u_int8_tlength; | ||
106 | u_int8_ttext[254]; /* 1-253 + 1 for null */ | ||
107 | }; | ||
108 | struct fh_t { | ||
109 | u_int8_telement_id; | ||
110 | u_int8_tlength; | ||
111 | u_int16_tdwell_time; | ||
112 | u_int8_thop_set; | ||
113 | u_int8_t hop_pattern; | ||
114 | u_int8_thop_index; | ||
115 | }; | ||
116 | |||
117 | struct ds_t { | ||
118 | u_int8_telement_id; | ||
119 | u_int8_tlength; | ||
120 | u_int8_tchannel; | ||
121 | }; | ||
122 | |||
123 | struct cf_t { | ||
124 | u_int8_telement_id; | ||
125 | u_int8_tlength; | ||
126 | u_int8_tcount; | ||
127 | u_int8_tperiod; | ||
128 | u_int16_tmax_duration; | ||
129 | u_int16_tdur_remaing; | ||
130 | }; | ||
131 | |||
132 | struct tim_t { | ||
133 | u_int8_telement_id; | ||
134 | u_int8_tlength; | ||
135 | u_int8_tcount; | ||
136 | u_int8_tperiod; | ||
137 | u_int8_tbitmap_control; | ||
138 | u_int8_tbitmap[251]; | ||
139 | }; | ||
140 | |||
141 | #define E_SSID 0 | ||
142 | #define E_RATES 1 | ||
143 | #define E_FH 2 | ||
144 | #define E_DS 3 | ||
145 | #define E_CF 4 | ||
146 | #define E_TIM 5 | ||
147 | #define E_IBSS 6 | ||
148 | #define E_CISCO 133 | ||
149 | /* reserved 7 */ | ||
150 | /* reserved 8 */ | ||
151 | /* reserved 9 */ | ||
152 | /* reserved 10 */ | ||
153 | /* reserved 11 */ | ||
154 | /* reserved 12 */ | ||
155 | /* reserved 13 */ | ||
156 | /* reserved 14 */ | ||
157 | /* reserved 15 */ | ||
158 | /* reserved 16 */ | ||
159 | |||
160 | #define E_CHALLENGE 16 | ||
161 | /* reserved 17 */ | ||
162 | /* reserved 18 */ | ||
163 | /* reserved 19 */ | ||
164 | /* reserved 16 */ | ||
165 | /* reserved 16 */ | ||
166 | |||
167 | |||
168 | struct mgmt_body_t { | ||
169 | u_int8_t timestamp[8]; | ||
170 | u_int16_t beacon_interval; | ||
171 | u_int16_t listen_interval; | ||
172 | u_int16_t status_code; | ||
173 | u_int16_t aid; | ||
174 | u_char ap[6]; | ||
175 | u_int16_treason_code; | ||
176 | u_int16_tauth_alg; | ||
177 | u_int16_tauth_trans_seq_num; | ||
178 | struct challenge_t challenge; | ||
179 | u_int16_tcapability_info; | ||
180 | struct ssid_tssid; | ||
181 | struct rates_t rates; | ||
182 | struct ds_tds; | ||
183 | struct cf_tcf; | ||
184 | struct fh_tfh; | ||
185 | struct tim_ttim; | ||
186 | }; | ||
187 | |||
188 | struct ctrl_rts_t { | ||
189 | u_int16_tfc; | ||
190 | u_int16_tduration; | ||
191 | u_int8_tra[6]; | ||
192 | u_int8_tta[6]; | ||
193 | u_int8_tfcs[4]; | ||
194 | }; | ||
195 | |||
196 | #define CTRL_RTS_LEN(2+2+6+6+4) | ||
197 | |||
198 | struct ctrl_cts_t { | ||
199 | u_int16_tfc; | ||
200 | u_int16_tduration; | ||
201 | u_int8_tra[6]; | ||
202 | u_int8_tfcs[4]; | ||
203 | }; | ||
204 | |||
205 | #define CTRL_CTS_LEN(2+2+6+4) | ||
206 | |||
207 | struct ctrl_ack_t { | ||
208 | u_int16_tfc; | ||
209 | u_int16_tduration; | ||
210 | u_int8_tra[6]; | ||
211 | u_int8_tfcs[4]; | ||
212 | }; | ||
213 | |||
214 | #define CTRL_ACK_LEN(2+2+6+4) | ||
215 | |||
216 | struct ctrl_ps_poll_t { | ||
217 | u_int16_tfc; | ||
218 | u_int16_taid; | ||
219 | u_int8_tbssid[6]; | ||
220 | u_int8_tta[6]; | ||
221 | u_int8_tfcs[4]; | ||
222 | }; | ||
223 | |||
224 | #define CTRL_PS_POLL_LEN(2+2+6+6+4) | ||
225 | |||
226 | struct ctrl_end_t { | ||
227 | u_int16_tfc; | ||
228 | u_int16_tduration; | ||
229 | u_int8_tra[6]; | ||
230 | u_int8_tbssid[6]; | ||
231 | u_int8_tfcs[4]; | ||
232 | }; | ||
233 | |||
234 | #define CTRL_END_LEN(2+2+6+6+4) | ||
235 | |||
236 | struct ctrl_end_ack_t { | ||
237 | u_int16_tfc; | ||
238 | u_int16_tduration; | ||
239 | u_int8_tra[6]; | ||
240 | u_int8_tbssid[6]; | ||
241 | u_int8_tfcs[4]; | ||
242 | }; | ||
243 | |||
244 | #define CTRL_END_ACK_LEN(2+2+6+6+4) | ||
245 | |||
246 | #define IV_IV(iv)((iv) & 0xFFFFFF) | ||
247 | #define IV_PAD(iv)(((iv) >> 24) & 0x3F) | ||
248 | #define IV_KEYID(iv)(((iv) >> 30) & 0x03) | ||
249 | |||
250 | #endif /* IEEE802_11_HH */ | ||
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/sniff.cc b/noncore/net/wellenreiter/libwellenreiter/source/sniff.cc deleted file mode 100644 index 0616a7e..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/source/sniff.cc +++ b/dev/null | |||
@@ -1,419 +0,0 @@ | |||
1 | /* | ||
2 | * rfmon mode sniffer | ||
3 | * | ||
4 | * $Id$ | ||
5 | */ | ||
6 | |||
7 | #include "sniff.hh" | ||
8 | #include "ieee802_11.hh" | ||
9 | #include "extract.hh" | ||
10 | #include "wl_log.hh" | ||
11 | #include "wl_types.hh" | ||
12 | #include "wl_proto.hh" | ||
13 | #include "cardmode.hh" | ||
14 | |||
15 | int start_sniffer(const char *device, int cardtype ) | ||
16 | { | ||
17 | |||
18 | /* This function initialize the sniffing | ||
19 | 1. Check for lo interface | ||
20 | 2. bring it into promsicous mode and UP | ||
21 | 3. bring device into rfmon mode | ||
22 | start the pcap sniffing process. | ||
23 | */ | ||
24 | |||
25 | /* Do we have the device name ? */ | ||
26 | if(device == NULL) | ||
27 | { | ||
28 | wl_logerr("start_sniffer, parameter \"device\" is empty, please check your config"); | ||
29 | return 0; | ||
30 | } | ||
31 | |||
32 | /* Some Linux System does not have a loopback device lo with 127.0.0.1 so sockets could | ||
33 | not made correctly, let the proggie check that and proceed only if it exists. */ | ||
34 | if (!check_loopback()) | ||
35 | { | ||
36 | wl_logerr("start_sniffer, check_loopback failed, cannot continue without a loopback"); | ||
37 | return 0; | ||
38 | } | ||
39 | |||
40 | /* Set the card into regulary promiscous mode first and set the UP flag, in case no ip | ||
41 | was given. It would work without the promisc flags but i dont like this */ | ||
42 | if (!card_set_promisc_up(device)) | ||
43 | { | ||
44 | wl_logerr("start_sniffer, card_set_promisc_up failed, cannot continue"); | ||
45 | return 0; | ||
46 | } | ||
47 | |||
48 | /* Set card into the rfmon/monitoring mode */ | ||
49 | if (!card_into_monitormode(device,cardtype)) | ||
50 | { | ||
51 | wl_logerr("start_sniffer, cannot put wireless card into monitoring mode, aborting"); | ||
52 | return 0; | ||
53 | } | ||
54 | |||
55 | /* setup pcap handle, used for the packet decoding etc. */ | ||
56 | if((handletopcap = pcap_open_live((char *) device, BUFSIZ, 1, 0, NULL)) == NULL) | ||
57 | { | ||
58 | wl_logerr("pcap_open_live() failed: %s", strerror(errno)); | ||
59 | return 0; | ||
60 | } | ||
61 | |||
62 | #ifdef HAVE_PCAP_NONBLOCK | ||
63 | pcap_setnonblock(handletopcap, 1, NULL); | ||
64 | #endif | ||
65 | return 1; | ||
66 | } | ||
67 | |||
68 | |||
69 | int stop_sniffer(const char *device, int cardtype) | ||
70 | { | ||
71 | /* This function terminates the sniffing | ||
72 | 1. get the device state | ||
73 | 2. remove the rfmon state | ||
74 | 3. Remove the promisc state | ||
75 | start the pcap sniffing process. | ||
76 | |||
77 | */ | ||
78 | |||
79 | /* Do we really have at least a lo interface with the 127.0.0.1 ? */ | ||
80 | return 0; | ||
81 | |||
82 | } | ||
83 | |||
84 | |||
85 | /* Main function, checks packets */ | ||
86 | void process_packets(const struct pcap_pkthdr *pkthdr, | ||
87 | const unsigned char *packet, | ||
88 | char *guihost, | ||
89 | int guiport) | ||
90 | { | ||
91 | unsigned int caplen = pkthdr->caplen; | ||
92 | unsigned int length = pkthdr->len; | ||
93 | u_int16_t fc; | ||
94 | unsigned int HEADER_LENGTH; | ||
95 | |||
96 | /* pinfo holds all interresting information for us */ | ||
97 | struct packetinfo pinfo; | ||
98 | struct packetinfo *pinfoptr; | ||
99 | |||
100 | /* wl_network_t will finally be set and send to the ui */ | ||
101 | wl_network_t wl_net; | ||
102 | |||
103 | pinfoptr=&pinfo; | ||
104 | |||
105 | pinfoptr->isvalid = 0; | ||
106 | pinfoptr->pktlen = pkthdr->len; | ||
107 | |||
108 | if (caplen < IEEE802_11_FC_LEN) | ||
109 | { | ||
110 | /* This is a garbage packet, because is does not long enough | ||
111 | to hold a 802.11b header */ | ||
112 | pinfoptr->isvalid = 0; | ||
113 | return; | ||
114 | } | ||
115 | |||
116 | /* Gets the framecontrol bits (2bytes long) */ | ||
117 | fc = EXTRACT_LE_16BITS(packet); | ||
118 | |||
119 | HEADER_LENGTH = GetHeaderLength(fc); | ||
120 | |||
121 | if (caplen < HEADER_LENGTH) | ||
122 | { | ||
123 | /* This is a garbage packet, because it is not long enough | ||
124 | to hold a correct header of its type */ | ||
125 | pinfoptr->isvalid = 0; | ||
126 | return; | ||
127 | } | ||
128 | |||
129 | /* Decode 802.11b header out of the packet */ | ||
130 | if (decode_80211b_hdr(packet,pinfoptr) == 0) | ||
131 | { | ||
132 | /* Justification of the ofset to further process the packet */ | ||
133 | length -= HEADER_LENGTH; | ||
134 | caplen -= HEADER_LENGTH; | ||
135 | packet += HEADER_LENGTH; | ||
136 | } | ||
137 | else /* Something is wrong,could not be a correct packet */ | ||
138 | return; | ||
139 | |||
140 | switch (FC_TYPE(fc)) | ||
141 | { | ||
142 | /* Is it a managemnet frame? */ | ||
143 | case T_MGMT: | ||
144 | switch (FC_SUBTYPE(fc)) | ||
145 | { | ||
146 | case ST_BEACON: | ||
147 | if (handle_beacon(fc, packet,pinfoptr) ==0) | ||
148 | { | ||
149 | if (!strcmp(pinfoptr->desthwaddr,"ff:ff:ff:ff:ff:ff") == 0) | ||
150 | { | ||
151 | /* Every beacon must have the broadcast as destination | ||
152 | so it must be a shitti packet */ | ||
153 | pinfoptr->isvalid = 0; | ||
154 | return; | ||
155 | } | ||
156 | |||
157 | if (pinfoptr->cap_ESS == pinfoptr->cap_IBSS) | ||
158 | { | ||
159 | /* Only one of both are possible, so must be | ||
160 | a noise packet, if this comes up */ | ||
161 | pinfoptr->isvalid = 0; | ||
162 | return; | ||
163 | } | ||
164 | if (pinfoptr->channel < 1 || pinfoptr->channel > 14) | ||
165 | { | ||
166 | /* Only channels between 1 and 14 are possible | ||
167 | others must be noise packets */ | ||
168 | pinfoptr->isvalid = 0; | ||
169 | return; | ||
170 | } | ||
171 | |||
172 | /* Here should be the infos to the gui issued */ | ||
173 | if (pinfoptr->cap_ESS == 1 && pinfoptr->cap_IBSS ==0) | ||
174 | { | ||
175 | wl_loginfo("Found an access point"); | ||
176 | wl_net.net_type=1; | ||
177 | } | ||
178 | else if(pinfoptr->cap_ESS == 0 && pinfoptr->cap_IBSS == 2) | ||
179 | { | ||
180 | wl_loginfo("Found an ad-hoc network"); | ||
181 | wl_net.net_type=2; | ||
182 | } | ||
183 | |||
184 | if (strcmp (pinfoptr->ssid,NONBROADCASTING) ==0) | ||
185 | wl_loginfo("Net is a non-broadcasting network"); | ||
186 | else | ||
187 | wl_loginfo("SSID is: %s", pinfoptr->ssid); | ||
188 | |||
189 | wl_loginfo("SSID is: %s", pinfoptr->ssid); | ||
190 | memset(wl_net.bssid, 0, sizeof(wl_net.bssid)); | ||
191 | memcpy(wl_net.bssid, pinfoptr->ssid, sizeof(wl_net.bssid)-1); | ||
192 | |||
193 | wl_loginfo("SSID length is: %d", pinfoptr->ssid_len); | ||
194 | wl_net.ssid_len=pinfoptr->ssid_len; | ||
195 | |||
196 | wl_loginfo("Channel is: %d", pinfoptr->channel); | ||
197 | wl_net.channel=pinfoptr->channel; | ||
198 | wl_net.wep=pinfoptr->cap_WEP; | ||
199 | |||
200 | wl_loginfo("Mac is: %s", pinfoptr->sndhwaddr); | ||
201 | memset(wl_net.mac, 0, sizeof(wl_net.mac)); | ||
202 | memcpy(wl_net.mac, pinfoptr->sndhwaddr, sizeof(wl_net.mac)-1); | ||
203 | |||
204 | if(!send_network_found((char *)guihost, guiport, &wl_net)) | ||
205 | { | ||
206 | wl_logerr("Error sending data to UI: %s", strerror(errno)); | ||
207 | break; | ||
208 | } | ||
209 | wl_loginfo("Sent network to GUI '%s:%d'", guihost, guiport); | ||
210 | } | ||
211 | break; | ||
212 | |||
213 | default: | ||
214 | wl_logerr("Unknown IEEE802.11 frame subtype (%d)", FC_SUBTYPE(fc)); | ||
215 | break; | ||
216 | } /* End of switch over different mgt frame types */ | ||
217 | |||
218 | break; | ||
219 | |||
220 | case T_CTRL: | ||
221 | wl_loginfo("Received control frame, not implemented yet"); | ||
222 | break; | ||
223 | |||
224 | case T_DATA: | ||
225 | wl_loginfo("Received date frame, not implemented yet"); | ||
226 | break; | ||
227 | |||
228 | default: | ||
229 | wl_logerr("Unknown IEEE802.11 frame type (%d)", FC_TYPE(fc)); | ||
230 | break; | ||
231 | } | ||
232 | } | ||
233 | |||
234 | /* This decodes the 802.11b frame header out of the 802.11b packet | ||
235 | all the infos is placed into the packetinfo structure */ | ||
236 | int decode_80211b_hdr(const u_char *p,struct packetinfo *ppinfo) | ||
237 | { | ||
238 | const struct mgmt_header_t *mgthdr = (const struct mgmt_header_t *) p; | ||
239 | ppinfo->fcsubtype = FC_SUBTYPE(mgthdr->fc); | ||
240 | |||
241 | /* Get the sender, bssid and dest mac address */ | ||
242 | etheraddr_string(mgthdr->bssid,ppinfo->bssid); | ||
243 | etheraddr_string(mgthdr->da,ppinfo->desthwaddr); | ||
244 | etheraddr_string(mgthdr->sa,ppinfo->sndhwaddr); | ||
245 | ppinfo->fc_wep = FC_WEP(mgthdr->fc); | ||
246 | return 0; | ||
247 | } | ||
248 | |||
249 | |||
250 | void etheraddr_string(register const u_char *ep, char *text) | ||
251 | { | ||
252 | static char hex[] = "0123456789abcdef"; | ||
253 | register unsigned int i, j; | ||
254 | register char *cp; | ||
255 | char buf[sizeof("00:00:00:00:00:00\0")]; | ||
256 | cp = buf; | ||
257 | if ((j = *ep >> 4) != 0) | ||
258 | { | ||
259 | *cp++ = hex[j]; | ||
260 | } | ||
261 | else | ||
262 | { | ||
263 | *cp++ = '0'; | ||
264 | } | ||
265 | *cp++ = hex[*ep++ & 0xf]; | ||
266 | |||
267 | for (i = 5; (int)--i >= 0;) | ||
268 | { | ||
269 | *cp++ = ':'; | ||
270 | if ((j = *ep >> 4) != 0) | ||
271 | { | ||
272 | *cp++ = hex[j]; | ||
273 | } | ||
274 | else | ||
275 | { | ||
276 | *cp++ = '0'; | ||
277 | } | ||
278 | |||
279 | *cp++ = hex[*ep++ & 0xf]; | ||
280 | } | ||
281 | *cp = '\0'; | ||
282 | strcpy(text,buf); | ||
283 | } | ||
284 | |||
285 | /* beacon handler */ | ||
286 | int handle_beacon(u_int16_t fc, const u_char *p,struct packetinfo *ppinfo) | ||
287 | { | ||
288 | struct mgmt_body_t pbody; | ||
289 | int offset = 0; | ||
290 | |||
291 | /* Get the static informations out of the packet */ | ||
292 | memset(&pbody, 0, sizeof(pbody)); | ||
293 | memcpy(&pbody.timestamp, p, 8); | ||
294 | offset += 8; | ||
295 | pbody.beacon_interval = EXTRACT_LE_16BITS(p+offset); | ||
296 | offset += 2; | ||
297 | pbody.capability_info = EXTRACT_LE_16BITS(p+offset); | ||
298 | offset += 2; | ||
299 | |||
300 | /* Gets the different flags out of the capabilities */ | ||
301 | ppinfo->cap_ESS = CAPABILITY_ESS(pbody.capability_info); | ||
302 | ppinfo->cap_IBSS = CAPABILITY_IBSS(pbody.capability_info); | ||
303 | ppinfo->cap_WEP = CAPABILITY_PRIVACY(pbody.capability_info); | ||
304 | |||
305 | /* Gets the tagged elements out of the packets */ | ||
306 | while (offset + 1 < ppinfo->pktlen) | ||
307 | { | ||
308 | switch (*(p + offset)) | ||
309 | { | ||
310 | case E_SSID: | ||
311 | memcpy(&(pbody.ssid),p+offset,2); offset += 2; | ||
312 | if (pbody.ssid.length > 0) | ||
313 | { | ||
314 | memcpy(&(pbody.ssid.ssid),p+offset,pbody.ssid.length); | ||
315 | offset += pbody.ssid.length; | ||
316 | pbody.ssid.ssid[pbody.ssid.length]='\0'; | ||
317 | if (strcmp((char *)pbody.ssid.ssid,"")==0) | ||
318 | memcpy(ppinfo->ssid, NONBROADCASTING, sizeof(ppinfo->ssid)); | ||
319 | else | ||
320 | memcpy(ppinfo->ssid, pbody.ssid.ssid, sizeof(ppinfo->ssid)); | ||
321 | ppinfo->ssid_len = pbody.ssid.length; | ||
322 | } | ||
323 | break; | ||
324 | |||
325 | case E_CHALLENGE: | ||
326 | memcpy(&(pbody.challenge),p+offset,2); offset += 2; | ||
327 | if (pbody.challenge.length > 0) | ||
328 | { | ||
329 | memcpy(&(pbody.challenge.text),p+offset,pbody.challenge.length); | ||
330 | offset += pbody.challenge.length; | ||
331 | pbody.challenge.text[pbody.challenge.length]='\0'; | ||
332 | } | ||
333 | break; | ||
334 | case E_RATES: | ||
335 | memcpy(&(pbody.rates),p+offset,2); offset += 2; | ||
336 | if (pbody.rates.length > 0) | ||
337 | { | ||
338 | memcpy(&(pbody.rates.rate),p+offset,pbody.rates.length); | ||
339 | offset += pbody.rates.length; | ||
340 | } | ||
341 | break; | ||
342 | case E_DS: | ||
343 | memcpy(&(pbody.ds),p+offset,3); | ||
344 | offset +=3; | ||
345 | ppinfo->channel = pbody.ds.channel; | ||
346 | break; | ||
347 | case E_CF: | ||
348 | memcpy(&(pbody.cf),p+offset,8); | ||
349 | offset +=8; | ||
350 | break; | ||
351 | case E_TIM: | ||
352 | memcpy(&(pbody.tim),p+offset,2); | ||
353 | offset +=2; | ||
354 | memcpy(&(pbody.tim.count),p+offset,3); | ||
355 | offset +=3; | ||
356 | if ((pbody.tim.length -3) > 0) | ||
357 | { | ||
358 | memcpy((pbody.tim.bitmap),p+(pbody.tim.length -3),(pbody.tim.length -3)); | ||
359 | offset += pbody.tim.length -3; | ||
360 | } | ||
361 | break; | ||
362 | default: | ||
363 | |||
364 | offset+= *(p+offset+1) + 2; | ||
365 | break; | ||
366 | } /* end of switch*/ | ||
367 | } /* end of for loop */ | ||
368 | return 0; | ||
369 | |||
370 | } /* End of handle_beacon */ | ||
371 | |||
372 | |||
373 | int GetHeaderLength(u_int16_t fc) | ||
374 | { | ||
375 | int iLength=0; | ||
376 | |||
377 | switch (FC_TYPE(fc)) | ||
378 | { | ||
379 | case T_MGMT: | ||
380 | iLength = MGMT_HEADER_LEN; | ||
381 | break; | ||
382 | case T_CTRL: | ||
383 | switch (FC_SUBTYPE(fc)) | ||
384 | { | ||
385 | case CTRL_PS_POLL: | ||
386 | iLength = CTRL_PS_POLL_LEN; | ||
387 | break; | ||
388 | case CTRL_RTS: | ||
389 | iLength = CTRL_RTS_LEN; | ||
390 | break; | ||
391 | case CTRL_CTS: | ||
392 | iLength = CTRL_CTS_LEN; | ||
393 | break; | ||
394 | case CTRL_ACK: | ||
395 | iLength = CTRL_ACK_LEN; | ||
396 | break; | ||
397 | case CTRL_CF_END: | ||
398 | iLength = CTRL_END_LEN; | ||
399 | break; | ||
400 | case CTRL_END_ACK: | ||
401 | iLength = CTRL_END_ACK_LEN; | ||
402 | break; | ||
403 | default: | ||
404 | iLength = 0; | ||
405 | break; | ||
406 | } | ||
407 | break; | ||
408 | case T_DATA: | ||
409 | if (FC_TO_DS(fc) && FC_FROM_DS(fc)) | ||
410 | iLength = 30; | ||
411 | else | ||
412 | iLength = 24; | ||
413 | break; | ||
414 | default: | ||
415 | wl_logerr("unknown IEEE802.11 frame type (%d)", FC_TYPE(fc)); | ||
416 | break; | ||
417 | } | ||
418 | return iLength; | ||
419 | } | ||
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/sniff.hh b/noncore/net/wellenreiter/libwellenreiter/source/sniff.hh deleted file mode 100644 index a4cf4b7..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/source/sniff.hh +++ b/dev/null | |||
@@ -1,73 +0,0 @@ | |||
1 | /* $Id$ */ | ||
2 | |||
3 | #ifndef SNIFF_HH | ||
4 | #define SNIFF_HH | ||
5 | |||
6 | #include <string.h> | ||
7 | #include <stdio.h> | ||
8 | #include <stdlib.h> | ||
9 | #include <errno.h> | ||
10 | #include <sys/types.h> | ||
11 | #include <sys/time.h> | ||
12 | #include <sys/socket.h> | ||
13 | #include <netinet/in.h> | ||
14 | #include <arpa/inet.h> | ||
15 | |||
16 | extern "C" | ||
17 | { | ||
18 | #include <net/bpf.h> | ||
19 | #include <pcap.h> | ||
20 | } | ||
21 | |||
22 | #define NONBROADCASTING "non-broadcasting" | ||
23 | |||
24 | /* holds all the interresting data */ | ||
25 | struct packetinfo | ||
26 | { | ||
27 | int isvalid; | ||
28 | int pktlen; | ||
29 | int fctype; | ||
30 | int fcsubtype; | ||
31 | int fc_wep; | ||
32 | int cap_WEP; | ||
33 | int cap_IBSS; | ||
34 | int cap_ESS; | ||
35 | int channel; | ||
36 | char bssid[sizeof("00:00:00:00:00:00") + 1]; | ||
37 | char desthwaddr[sizeof("00:00:00:00:00:00") + 1]; | ||
38 | char sndhwaddr[sizeof("00:00:00:00:00:00") + 1]; | ||
39 | char ssid[128]; | ||
40 | int ssid_len; | ||
41 | }; | ||
42 | |||
43 | /* Function definitions */ | ||
44 | /* Used for stoping and starting the sniffer process */ | ||
45 | int start_sniffer(const char *device, int cardtype); | ||
46 | int stop_sniffer(const char *device, int cardtype); | ||
47 | void process_packets(const struct pcap_pkthdr* pkthdr,const u_char* packet, char *, int); | ||
48 | int decode_80211b_hdr(const u_char *p,struct packetinfo *ppinfo); | ||
49 | void etheraddr_string(register const u_char *ep,char * text); | ||
50 | int handle_beacon(u_int16_t fc, const u_char *p,struct packetinfo *ppinfo); | ||
51 | int GetHeaderLength(u_int16_t fc); | ||
52 | |||
53 | /* | ||
54 | * True if "l" bytes of "var" were captured. | ||
55 | * | ||
56 | * The "snapend - (l) <= snapend" checks to make sure "l" isn't so large | ||
57 | * that "snapend - (l)" underflows. | ||
58 | * | ||
59 | * The check is for <= rather than < because "l" might be 0. | ||
60 | */ | ||
61 | #define TTEST2(var, l) (snapend - (l) <= snapend && \ | ||
62 | (const u_char *)&(var) <= snapend - (l)) | ||
63 | |||
64 | /* True if "var" was captured */ | ||
65 | #define TTEST(var) TTEST2(var, sizeof(var)) | ||
66 | |||
67 | /* Bail if "l" bytes of "var" were not captured */ | ||
68 | #define TCHECK2(var, l) if (!TTEST2(var, l)) goto trunc | ||
69 | |||
70 | /* Bail if "var" was not captured */ | ||
71 | #define TCHECK(var) TCHECK2(var, sizeof(var)) | ||
72 | |||
73 | #endif /* SNIFF_HH */ | ||
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/wl_conf.cc b/noncore/net/wellenreiter/libwellenreiter/source/wl_conf.cc deleted file mode 100644 index ba56754..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/source/wl_conf.cc +++ b/dev/null | |||
@@ -1,81 +0,0 @@ | |||
1 | /* | ||
2 | * Configfile operations for wellenreiter | ||
3 | * | ||
4 | * $Id$ | ||
5 | */ | ||
6 | |||
7 | #include "wl_conf.hh" | ||
8 | #include "wl_log.hh" | ||
9 | #include "wl_types.hh" | ||
10 | |||
11 | /* Check whether configfile exists and is readable */ | ||
12 | int wl_checkcfg(void) | ||
13 | { | ||
14 | FILE *wl_config; | ||
15 | |||
16 | if((wl_config = fopen(WL_CONFFILE, "r")) == NULL) | ||
17 | { | ||
18 | wl_logerr("Cannot open configfile: %s", strerror(errno)); | ||
19 | return 0; | ||
20 | } | ||
21 | else | ||
22 | { | ||
23 | fclose(wl_config); | ||
24 | return 1; | ||
25 | } | ||
26 | |||
27 | } | ||
28 | |||
29 | /* Get value for given token from config file */ | ||
30 | int wl_cfgvalue(const char *token, char *out, int maxlen) | ||
31 | { | ||
32 | FILE *wl_config; | ||
33 | char *ptr, *ptr2; | ||
34 | char confbuf[WL_CONFBUFF]; | ||
35 | |||
36 | if(token == NULL) | ||
37 | return -1; | ||
38 | |||
39 | if((wl_config = fopen(WL_CONFFILE, "r")) == NULL) | ||
40 | { | ||
41 | wl_logerr("Cannot open configfile: %s", strerror(errno)); | ||
42 | return -1; | ||
43 | } | ||
44 | |||
45 | /* Clear buffers */ | ||
46 | memset(out, 0, maxlen); | ||
47 | memset(confbuf, 0, sizeof(confbuf)); | ||
48 | |||
49 | while((fgets(confbuf, sizeof(confbuf) - 1, wl_config)) != NULL) | ||
50 | { | ||
51 | |||
52 | /* Ignore comments */ | ||
53 | if(confbuf[0] == '#') continue; | ||
54 | |||
55 | /* Search for token, if found check whether next character | ||
56 | * is a '=' or a ' ' | ||
57 | */ | ||
58 | if(strstr(confbuf, token) != NULL && | ||
59 | (confbuf[strlen(token)] == '=' || confbuf[strlen(token)] == ' ')) | ||
60 | { | ||
61 | |||
62 | /* Get value between quotes */ | ||
63 | if((ptr = strstr(confbuf, "\"")) == NULL) | ||
64 | break; | ||
65 | ++ptr; | ||
66 | if((ptr2 = strstr(ptr, "\"")) == NULL) | ||
67 | break; | ||
68 | ptr2[0] = '\0'; | ||
69 | |||
70 | memcpy(out, ptr, maxlen - 1); | ||
71 | break; | ||
72 | |||
73 | } | ||
74 | memset(confbuf, 0, sizeof(confbuf)); | ||
75 | } | ||
76 | |||
77 | fclose(wl_config); | ||
78 | |||
79 | return (out[0] == '\0' ? 0 : 1); | ||
80 | } | ||
81 | |||
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/wl_conf.hh b/noncore/net/wellenreiter/libwellenreiter/source/wl_conf.hh deleted file mode 100644 index 4061440..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/source/wl_conf.hh +++ b/dev/null | |||
@@ -1,12 +0,0 @@ | |||
1 | /* $Id$ */ | ||
2 | |||
3 | #ifndef WLCONF_HH | ||
4 | #define WLCONF_HH | ||
5 | |||
6 | #include <string.h> | ||
7 | #include <errno.h> | ||
8 | |||
9 | int wl_checkcfg(void); | ||
10 | int wl_cfgvalue(const char *, char *, int); | ||
11 | |||
12 | #endif /* WLCONF_HH */ | ||
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/wl_log.cc b/noncore/net/wellenreiter/libwellenreiter/source/wl_log.cc deleted file mode 100644 index 7adaba8..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/source/wl_log.cc +++ b/dev/null | |||
@@ -1,51 +0,0 @@ | |||
1 | /* | ||
2 | * Small functions to log to syslog | ||
3 | * | ||
4 | * $Id$ | ||
5 | */ | ||
6 | |||
7 | #include "wl_log.hh" | ||
8 | |||
9 | /* Log to syslog INFO */ | ||
10 | void wl_loginfo(const char *fmt,...) | ||
11 | { | ||
12 | |||
13 | char buffer[4096]; | ||
14 | va_list ap; | ||
15 | |||
16 | memset(buffer, 0, sizeof(buffer)); | ||
17 | va_start(ap, fmt); | ||
18 | vsnprintf(buffer, sizeof(buffer)-1, fmt, ap); | ||
19 | va_end(ap); | ||
20 | |||
21 | openlog("libwellenreiter", LOG_PID, LOG_SYSLOG); | ||
22 | syslog(LOG_INFO, "(info) %s", buffer); | ||
23 | closelog(); | ||
24 | |||
25 | #ifdef DEBUG | ||
26 | fprintf(stderr, "(info) %s\n", buffer); | ||
27 | #endif | ||
28 | |||
29 | } | ||
30 | |||
31 | /* Log to syslog ERR */ | ||
32 | void wl_logerr(const char *fmt,...) | ||
33 | { | ||
34 | |||
35 | char buffer[4096]; | ||
36 | va_list ap; | ||
37 | |||
38 | memset(buffer, 0, sizeof(buffer)); | ||
39 | va_start(ap, fmt); | ||
40 | vsnprintf(buffer, sizeof(buffer)-1, fmt, ap); | ||
41 | va_end(ap); | ||
42 | |||
43 | openlog("libwellenreiter", LOG_PID, LOG_SYSLOG); | ||
44 | syslog(LOG_INFO, "(err) %s", buffer); | ||
45 | closelog(); | ||
46 | |||
47 | #ifdef DEBUG | ||
48 | fprintf(stderr, "(err) %s\n", buffer); | ||
49 | #endif | ||
50 | |||
51 | } | ||
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/wl_log.hh b/noncore/net/wellenreiter/libwellenreiter/source/wl_log.hh deleted file mode 100644 index 8f6e543..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/source/wl_log.hh +++ b/dev/null | |||
@@ -1,14 +0,0 @@ | |||
1 | /* $Id$ */ | ||
2 | |||
3 | #ifndef WLLOG_HH | ||
4 | #define WLLOG_HH | ||
5 | |||
6 | #include <stdio.h> | ||
7 | #include <syslog.h> | ||
8 | #include <stdarg.h> | ||
9 | #include <string.h> | ||
10 | |||
11 | void wl_loginfo(const char *, ...); | ||
12 | void wl_logerr(const char *, ...); | ||
13 | |||
14 | #endif /* WLLOG_HH */ | ||
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/wl_proto.cc b/noncore/net/wellenreiter/libwellenreiter/source/wl_proto.cc deleted file mode 100644 index 6c3846f..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/source/wl_proto.cc +++ b/dev/null | |||
@@ -1,221 +0,0 @@ | |||
1 | /* | ||
2 | * Communication protocol | ||
3 | * | ||
4 | * $Id$ | ||
5 | */ | ||
6 | |||
7 | #include "wl_types.hh" | ||
8 | #include "wl_proto.hh" | ||
9 | #include "wl_log.hh" | ||
10 | #include "wl_sock.hh" | ||
11 | |||
12 | /* Adds a field to the buffer */ | ||
13 | unsigned int add_field(char *buffer, const char *string, int len) | ||
14 | { | ||
15 | char newlen[5]; | ||
16 | |||
17 | /* 3 Byte = Length */ | ||
18 | memset(newlen, 0, sizeof(newlen)); | ||
19 | snprintf(newlen, sizeof(newlen) - 1, "%.3d", len); | ||
20 | memcpy(buffer, newlen, 3); | ||
21 | |||
22 | /* Length bytes = Value */ | ||
23 | memcpy(buffer + 3, string, atoi(newlen)); | ||
24 | |||
25 | /* Return length of attached field */ | ||
26 | return (atoi(newlen) + 3); | ||
27 | } | ||
28 | |||
29 | unsigned int get_field(const char *buffer, char *out, int maxlen) | ||
30 | { | ||
31 | char len[5]; | ||
32 | |||
33 | /* Get length of value */ | ||
34 | memset(len, 0, sizeof(len)); | ||
35 | memcpy(len, buffer, 3); | ||
36 | |||
37 | /* Copy buffer to out pointer */ | ||
38 | memset(out, 0, maxlen); | ||
39 | if(atoi(len) > maxlen -1) | ||
40 | memcpy(out, buffer + 3, maxlen - 1); | ||
41 | else | ||
42 | memcpy(out, buffer + 3, atoi(len)); | ||
43 | |||
44 | /* Return length of whole field (including 3 byte length) */ | ||
45 | return (atoi(len) + 3); | ||
46 | } | ||
47 | |||
48 | /* Send ok message */ | ||
49 | int send_ok(const char *guihost, int guiport, int code) | ||
50 | { | ||
51 | unsigned int len = 0; | ||
52 | char buffer[128], temp[5]; | ||
53 | |||
54 | memset(buffer, 0, sizeof(buffer)); | ||
55 | |||
56 | memset(temp, 0, sizeof(temp)); | ||
57 | snprintf(temp, sizeof(temp) - 1, "%.2d", CMD_OK); | ||
58 | memcpy(buffer, temp, 2); | ||
59 | len += 2; | ||
60 | |||
61 | memset(temp, 0, sizeof(temp)); | ||
62 | snprintf(temp, sizeof(temp) - 1, "%.2d", code); | ||
63 | len += add_field(buffer + len, temp, 2); | ||
64 | |||
65 | /* Send prepared buffer to UI */ | ||
66 | #ifdef DEBUG | ||
67 | wl_loginfo("Sent ok to UI: '%s'", buffer); | ||
68 | #endif | ||
69 | |||
70 | return ((!wl_send(guihost, guiport, buffer)) ? 0 : 1); | ||
71 | } | ||
72 | |||
73 | /* Send fail message */ | ||
74 | int send_fail(const char *guihost, int guiport, | ||
75 | int code, const char *errstr) | ||
76 | { | ||
77 | unsigned int len = 0; | ||
78 | char buffer[128], temp[5]; | ||
79 | |||
80 | memset(buffer, 0, sizeof(buffer)); | ||
81 | |||
82 | memset(temp, 0, sizeof(temp)); | ||
83 | snprintf(temp, sizeof(temp) - 1, "%.2d", CMD_FAIL); | ||
84 | memcpy(buffer, temp, 2); | ||
85 | len += 2; | ||
86 | |||
87 | memset(temp, 0, sizeof(temp)); | ||
88 | snprintf(temp, sizeof(temp) - 1, "%.2d", code); | ||
89 | len += add_field(buffer + len, temp, 2); | ||
90 | |||
91 | len += add_field(buffer + len, errstr, strlen(errstr)); | ||
92 | |||
93 | /* Send prepared buffer to UI */ | ||
94 | #ifdef DEBUG | ||
95 | wl_loginfo("Send CMD_FAIL to UI: '%s'", buffer); | ||
96 | #endif | ||
97 | |||
98 | return ((!wl_send(guihost, guiport, buffer)) ? 0 : 1); | ||
99 | } | ||
100 | |||
101 | int get_ok(const char *buffer) | ||
102 | { | ||
103 | char temp[5]; | ||
104 | unsigned int len = 0; | ||
105 | |||
106 | /* packet type already determined, skip check */ | ||
107 | len += 2; | ||
108 | |||
109 | /* what is ok for? */ | ||
110 | memset(temp, 0, sizeof(temp)); | ||
111 | len += get_field(buffer + len, temp, sizeof(temp)); | ||
112 | |||
113 | return atoi(temp); | ||
114 | } | ||
115 | |||
116 | /* put failmessage into buffer */ | ||
117 | int get_fail(char *out, const char *buffer, size_t bufflen) | ||
118 | { | ||
119 | char temp[5]; | ||
120 | int error=0; | ||
121 | unsigned int len = 0; | ||
122 | |||
123 | /* packet type already determined, skip check */ | ||
124 | len += 2; | ||
125 | |||
126 | /* what is fail for? */ | ||
127 | memset(temp, 0, sizeof(temp)); | ||
128 | len += get_field(buffer + len, temp, sizeof(temp)); | ||
129 | error=atoi(temp); | ||
130 | |||
131 | /* get errorstring and fill into buffer */ | ||
132 | memset(out, 0, bufflen); | ||
133 | len += get_field(buffer + len, out, bufflen - 1); | ||
134 | |||
135 | return error; | ||
136 | } | ||
137 | |||
138 | |||
139 | /* Send found network to UI */ | ||
140 | int send_network_found (const char *guihost, int guiport, void *structure) | ||
141 | { | ||
142 | wl_network_t *ptr; | ||
143 | char buffer[2048], temp[5]; | ||
144 | unsigned int len = 0; | ||
145 | |||
146 | ptr = (wl_network_t *)structure; | ||
147 | |||
148 | memset(buffer,0,sizeof(buffer)); | ||
149 | /* Type = Found new net (without length field) */ | ||
150 | memset(temp, 0, sizeof(temp)); | ||
151 | snprintf(temp, sizeof(temp) - 1, "%.2d", WL_NETFOUND); | ||
152 | memcpy(buffer, temp, 2); | ||
153 | len += 2; | ||
154 | |||
155 | /* Set Net-type */ | ||
156 | memset(temp, 0, sizeof(temp)); | ||
157 | snprintf(temp, sizeof(temp) - 1, "%d", ptr->net_type); | ||
158 | len += add_field(buffer + len, temp, 1); | ||
159 | |||
160 | /* Set channel */ | ||
161 | memset(temp, 0, sizeof(temp)); | ||
162 | snprintf(temp, sizeof(temp) - 1, "%.2d", ptr->channel); | ||
163 | len += add_field(buffer + len, temp, 2); | ||
164 | |||
165 | /* Set WEP y/n */ | ||
166 | memset(temp, 0, sizeof(temp)); | ||
167 | snprintf(temp, sizeof(temp) - 1, "%d", ptr->wep); | ||
168 | len += add_field(buffer + len, temp, 1); | ||
169 | |||
170 | /* Set Mac */ | ||
171 | len += add_field(buffer + len, ptr->mac, 17); | ||
172 | |||
173 | /* Set ssid */ | ||
174 | if(len + ptr->ssid_len < sizeof(buffer) - 1) | ||
175 | len += add_field(buffer + len, ptr->bssid, ptr->ssid_len); | ||
176 | else | ||
177 | len += add_field(buffer + len, ptr->bssid, sizeof(buffer) - len - 1); | ||
178 | |||
179 | /* Send prepared buffer to UI */ | ||
180 | #ifdef DEBUG | ||
181 | wl_loginfo("Sending network to UI: '%s'", buffer); | ||
182 | #endif | ||
183 | |||
184 | return ((!wl_send(guihost, guiport, buffer)) ? 0 : 1); | ||
185 | } | ||
186 | |||
187 | /* Fill buffer into structur */ | ||
188 | int get_network_found (void *structure, const char *buffer) | ||
189 | { | ||
190 | wl_network_t *ptr; | ||
191 | char temp[5]; | ||
192 | unsigned int len = 0; | ||
193 | |||
194 | ptr = (wl_network_t *)structure; | ||
195 | |||
196 | /* packet type already determined, skip check */ | ||
197 | len += 2; | ||
198 | |||
199 | /* Get net type (accesspoint || ad-hoc || ...) */ | ||
200 | memset(temp, 0, sizeof(temp)); | ||
201 | len += get_field(buffer + len, temp, sizeof(temp)); | ||
202 | ptr->net_type = atoi(temp); | ||
203 | |||
204 | /* Get channel */ | ||
205 | memset(temp, 0, sizeof(temp)); | ||
206 | len += get_field(buffer + len, temp, sizeof(temp)); | ||
207 | ptr->channel = atoi(temp); | ||
208 | |||
209 | /* Set WEP y/n */ | ||
210 | memset(temp, 0, sizeof(temp)); | ||
211 | len += get_field(buffer + len, temp, sizeof(temp)); | ||
212 | ptr->wep = atoi(temp); | ||
213 | |||
214 | /* Set MAC address */ | ||
215 | len += get_field(buffer + len, ptr->mac, sizeof(ptr->mac)); | ||
216 | |||
217 | /* Set BSSID */ | ||
218 | len += get_field(buffer + len, ptr->bssid, sizeof(ptr->bssid)); | ||
219 | |||
220 | return 1; | ||
221 | } | ||
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/wl_proto.hh b/noncore/net/wellenreiter/libwellenreiter/source/wl_proto.hh deleted file mode 100644 index 63ac53b..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/source/wl_proto.hh +++ b/dev/null | |||
@@ -1,27 +0,0 @@ | |||
1 | /* $Id$ */ | ||
2 | |||
3 | #ifndef WLPROTO_HH | ||
4 | #define WLPROTO_HH | ||
5 | |||
6 | #include <stdio.h> | ||
7 | #include <string.h> | ||
8 | #include <stdlib.h> | ||
9 | |||
10 | /* Type definitions, to be continued */ | ||
11 | #define NETFOUND 01 | ||
12 | #define NETLOST 02 | ||
13 | #define CMD_FAIL 50 | ||
14 | #define CMD_OK 51 | ||
15 | #define STARTSNIFF 98 | ||
16 | #define STOPSNIFF 99 | ||
17 | |||
18 | unsigned int add_field(char *, const char *, int); | ||
19 | unsigned int get_field(const char *, char *, int); | ||
20 | int send_ok(const char *, int, int); | ||
21 | int get_ok(const char *); | ||
22 | int send_fail(const char *, int, int, const char *); | ||
23 | int get_fail(char *, const char *, size_t); | ||
24 | int send_network_found (const char *, int, void *); | ||
25 | int get_network_found (void *, const char *); | ||
26 | |||
27 | #endif /* WLPROTO_HH */ | ||
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/wl_sock.cc b/noncore/net/wellenreiter/libwellenreiter/source/wl_sock.cc deleted file mode 100644 index 6e26cb8..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/source/wl_sock.cc +++ b/dev/null | |||
@@ -1,92 +0,0 @@ | |||
1 | /* | ||
2 | * Socket operations for wellenreiter | ||
3 | * | ||
4 | * $Id$ | ||
5 | */ | ||
6 | |||
7 | #include "wl_sock.hh" | ||
8 | #include "wl_log.hh" | ||
9 | |||
10 | /* Setup UDP Socket for incoming commands */ | ||
11 | int wl_setupsock(const char *host, int port, struct sockaddr_in saddr) | ||
12 | { | ||
13 | int sock; | ||
14 | |||
15 | if((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) | ||
16 | { | ||
17 | wl_logerr("Cannot set up socket: %s", strerror(errno)); | ||
18 | return -1; | ||
19 | } | ||
20 | |||
21 | memset(&saddr, 0, sizeof(saddr)); | ||
22 | saddr.sin_family = PF_INET; | ||
23 | saddr.sin_port = htons(port); | ||
24 | saddr.sin_addr.s_addr = inet_addr(host); | ||
25 | |||
26 | if(bind(sock,(struct sockaddr *)&saddr, sizeof(saddr)) < 0) | ||
27 | { | ||
28 | wl_logerr("Cannot bind socket: %s", strerror(errno)); | ||
29 | close(sock); | ||
30 | return -1; | ||
31 | } | ||
32 | |||
33 | return sock; | ||
34 | } | ||
35 | |||
36 | /* Send a string to commsock */ | ||
37 | int wl_send(const char *host, int port, const char *string, ...) | ||
38 | { | ||
39 | int sock; | ||
40 | char buffer[4096]; | ||
41 | struct sockaddr_in saddr; | ||
42 | va_list ap; | ||
43 | |||
44 | /* Generate string */ | ||
45 | memset(buffer, 0, sizeof(buffer)); | ||
46 | va_start(ap, string); | ||
47 | vsnprintf(buffer, sizeof(buffer)-1, string, ap); | ||
48 | va_end(ap); | ||
49 | |||
50 | saddr.sin_family = AF_INET; | ||
51 | saddr.sin_port = htons(port); | ||
52 | saddr.sin_addr.s_addr = inet_addr(host); | ||
53 | |||
54 | /* Setup socket */ | ||
55 | if((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) | ||
56 | { | ||
57 | wl_logerr("Cannot set up socket: %s", strerror(errno)); | ||
58 | return 0; | ||
59 | } | ||
60 | |||
61 | if(sendto(sock, buffer, sizeof(buffer), 0, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) | ||
62 | { | ||
63 | wl_logerr("Cannot write to socket: %s", strerror(errno)); | ||
64 | close(sock); | ||
65 | return 0; | ||
66 | } | ||
67 | |||
68 | if(close(sock) < 0) | ||
69 | wl_logerr("Cannot close socket: %s", strerror(errno)); | ||
70 | |||
71 | return 1; | ||
72 | } | ||
73 | |||
74 | /* Check for new messages on commsock */ | ||
75 | int wl_recv(int *sock, struct sockaddr_in cliaddr, char *out, int maxlen) | ||
76 | { | ||
77 | socklen_t len = sizeof(struct sockaddr); | ||
78 | char retval[3]; | ||
79 | |||
80 | memset(out, 0, maxlen); | ||
81 | if(recvfrom(*sock, out, maxlen - 1, 0, (struct sockaddr *)&cliaddr, &len) < 0) | ||
82 | { | ||
83 | wl_logerr("Cannot receive from socket: %s", strerror(errno)); | ||
84 | return -1; | ||
85 | } | ||
86 | |||
87 | /* Get packet type and return it */ | ||
88 | memset(retval, 0, sizeof(retval)); | ||
89 | memcpy(retval, out, 2); | ||
90 | |||
91 | return atoi(retval); | ||
92 | } | ||
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/wl_sock.hh b/noncore/net/wellenreiter/libwellenreiter/source/wl_sock.hh deleted file mode 100644 index e7d9747..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/source/wl_sock.hh +++ b/dev/null | |||
@@ -1,21 +0,0 @@ | |||
1 | /* $Id */ | ||
2 | |||
3 | #ifndef WLSOCK_HH | ||
4 | #define WLSOCK_HH | ||
5 | |||
6 | #include <stdarg.h> | ||
7 | #include <sys/types.h> | ||
8 | #include <sys/socket.h> | ||
9 | #include <netinet/in.h> | ||
10 | #include <arpa/inet.h> | ||
11 | #include <signal.h> | ||
12 | #include <string.h> | ||
13 | #include <unistd.h> | ||
14 | #include <stdlib.h> | ||
15 | #include <errno.h> | ||
16 | |||
17 | int wl_setupsock(const char *, int, struct sockaddr_in); | ||
18 | int wl_send(const char *, int, const char *, ...); | ||
19 | int wl_recv(int *, struct sockaddr_in, char *, int); | ||
20 | |||
21 | #endif /* WLSOCK_HH */ | ||
diff --git a/noncore/net/wellenreiter/libwellenreiter/source/wl_types.hh b/noncore/net/wellenreiter/libwellenreiter/source/wl_types.hh deleted file mode 100644 index afc105c..0000000 --- a/noncore/net/wellenreiter/libwellenreiter/source/wl_types.hh +++ b/dev/null | |||
@@ -1,43 +0,0 @@ | |||
1 | /* | ||
2 | * Global bufffer size and type definitions | ||
3 | * | ||
4 | * $Id$ | ||
5 | * | ||
6 | */ | ||
7 | |||
8 | #ifndef WL_TYPES_HH | ||
9 | #define WL_TYPES_HH | ||
10 | |||
11 | /* Type definitions, to be continued */ | ||
12 | #define WL_NETFOUND 01 | ||
13 | #define WL_NETLOST 02 | ||
14 | #define WL_STARTSNIFF 98 | ||
15 | #define WL_STOPSNIFF 99 | ||
16 | |||
17 | /* Socket specific */ | ||
18 | #define WL_SOCKBUF 512 /* Buffer for wl_send and wl_recv calls */ | ||
19 | |||
20 | /* Channelswitching */ | ||
21 | typedef struct { | ||
22 | int type; /* Type of card (chip) */ | ||
23 | char iface[6]; /* Interface of card */ | ||
24 | } wl_cardtype_t; | ||
25 | |||
26 | |||
27 | /* WL network structure */ | ||
28 | typedef struct { | ||
29 | int net_type; /* 1 = Accesspoint ; 2 = Ad-Hoc */ | ||
30 | int ssid_len; /* Length of SSID */ | ||
31 | int channel; /* Channel */ | ||
32 | int wep; /* 1 = WEP enabled ; 0 = disabled */ | ||
33 | char mac[64]; /* MAC address of Accesspoint */ | ||
34 | char bssid[128]; /* BSSID of Net */ | ||
35 | } wl_network_t; | ||
36 | |||
37 | /* Config specific */ | ||
38 | #define WL_CONFFILE "sample.conf" | ||
39 | #define WL_CONFBUFF 128 | ||
40 | |||
41 | |||
42 | #endif /* WL_TYPES_HH */ | ||
43 | |||
diff --git a/noncore/net/wellenreiter/opie-wellenreiter.control b/noncore/net/wellenreiter/opie-wellenreiter.control index 4414341..ca50207 100644 --- a/noncore/net/wellenreiter/opie-wellenreiter.control +++ b/noncore/net/wellenreiter/opie-wellenreiter.control | |||
@@ -1,2 +1,2 @@ | |||
1 | Files: bin/wellenreiter bin/wellenreiterd share/wellenreiter pics/wellenreiter apps/Applications/wellenreiter.desktop $OPIEDIR/lib/libwellenreiter.* $OPIEDIR/lib/libcornucopia.* | 1 | Files: bin/wellenreiter share/wellenreiter pics/wellenreiter apps/Applications/wellenreiter.desktop |
2 | Priority: optional | 2 | Priority: optional |
@@ -6,3 +6,3 @@ Architecture: arm | |||
6 | Version: $QPE_VERSION-$SUB_VERSION | 6 | Version: $QPE_VERSION-$SUB_VERSION |
7 | Depends: opie-base, libpcap0 | 7 | Depends: opie-base, libpcap0, libopie2 (1.8.1) |
8 | Description: A WaveLAN Network Monitor | 8 | Description: A WaveLAN Network Monitor |
diff --git a/noncore/net/wellenreiter/wellenreiter.pro b/noncore/net/wellenreiter/wellenreiter.pro index 1d76564..d473695 100644 --- a/noncore/net/wellenreiter/wellenreiter.pro +++ b/noncore/net/wellenreiter/wellenreiter.pro | |||
@@ -1,3 +1,3 @@ | |||
1 | TEMPLATE = subdirs | 1 | TEMPLATE = subdirs |
2 | unix:SUBDIRS = cornucopia libwellenreiter daemon gui | 2 | unix:SUBDIRS = gui |
3 | 3 | ||