author | mickeyl <mickeyl> | 2003-03-30 01:51:14 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-03-30 01:51:14 (UTC) |
commit | d11a0154e2d9732854c9a3d598857bc20f359849 (patch) (side-by-side diff) | |
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, 133 insertions, 3854 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 @@ -# Warning: Handcrafted! - -############################################################################# -# Makefile for building targets in sub directories. -# Project: wellenreiter -# Template: subdirs -############################################################################# - -MAKEFILE= Makefile -TMAKE = tmake - -SUBDIRS = libwellenreiter/source daemon/source gui cornucopia - -all: $(SUBDIRS) - -$(SUBDIRS): FORCE - cd $@; $(MAKE) - -tmake: - tmake wellenreiter.pro - -tmake_all: - 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 - -clean release debug: - for i in $(SUBDIRS); do ( if [ -d $$i ]; then cd $$i ; $(MAKE) $@; fi; ) ; done - -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 @@ -1,4 +1,6 @@ config WELLENREITER boolean "wellenreiter (wireless LAN monitor)" default "y" - depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE + depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE && LIBOPIE2CORE && LIBOPIE2NET && LIBOPIE2UI + comment "wellenreiter needs libqpe, libopie1 and libopie2 (core+net+ui)" + 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 @@ -*.o -*~ -moc_* -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 @@ -*.o -*~ -moc_* -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 @@ -*.o -*~ -Makefile* -moc_* -wellenreitertemplate.cpp -wellenreitertemplate.h -configbase.h -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 @@ -/******************************************************************** -/* This is an overview of the opielibs 1.2 project -/********************************************************************/ - - Origin: opielibs is about creating classes to - * optimize Qt classes for the embedded environment - * provide sophisticated abstractions for developers - * provide complete documentation and working examples - * provide end users with a common look and feel - * reduce memory footprint through sharing code - * reduce possible bugs through reusing tested code - --------------------------------------------------------- -1. General Overview --------------------------------------------------------- - -Separation into the following libraries: - - libopiecore - - libopieui - - libopiepim - - libopienet - -1.1 Contents of libopiecore [ opiecore ] --------------------------------------------------------- - - - oprocctrl - - oprocess - - odevice - - odevicebutton - - - oconfig - - oconfiggroupsaver - - ocompletionbase - - ocompletion - - ocomptreenodelist - - ocomptreenode - - ocompletionwrapper - - oglobal - - oglobalsettings - - osortableitem - - osortablevaluelist - -1.2 Contents of libopieui [ opieui ] --------------------------------------------------------- - - - oapplication - - - ofiledialog - - colordialog - - oclickablelabel - - ocolorbutton - - colorpopupmenu - - otabinfo - - otabbar - - otabwidget - - ofontmenu - - ofontselector - - ofileview - - oticker - - - olistview - - olistviewitem - - oversatileview - - oversatileviewitem - - ocompletionbox - - olineedit - - ocombobox - - ohistorycombo - - - omessagebox - - odialogbase - - - todayconfigwidget (rather into opiepim?) - - orecurrancewidget (rather into opiepim?) - - otimepicker (rather into opiepim?) - -1.3 Contents of libopiepim [ opiepim ] --------------------------------------------------------- - - - ocheckitem - - todoevent - - todoresource - - todayplugininterface - - todovcalresource - -1.4 Contents of libopiedb [ opiedb ] --------------------------------------------------------- - - - tododb - - xmltree - -1.5 Contents of libopienet [ opienet ] --------------------------------------------------------- - - <libmail stuff> - <libbend stuff> - <libftp stuff> - --------------------------------------------------------- -2.0 Feature Description --------------------------------------------------------- - -2.1 libopiecore - -... - -2.2 libopieui - -... - -2.2.x OListView, OListViewItem, OListViewFactory - -... - -2.3 libopiepim - -... - -2.4 libopiedb - -... - -2.5 libopienet - 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 @@ -DESTDIR = $(OPIEDIR)/lib -MOC_DIR = ./tmp -OBJECTS_DIR = ./tmp -TEMPLATE = lib -CONFIG = qt warn_on debug -VERSION = 0.1 -HEADERS = olistview.h -SOURCES = olistview.cpp -INCLUDEPATH = $(OPIEDIR)/include -DEPENDPATH = $(OPIEDIR)/include -TARGET = cornucopia - -!contains( platform, x11 ) { - include ( $(OPIEDIR)/include.pro ) -} - 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 @@ -/* - This file is part of the Opie Project - - Copyright (C) 2003 Michael 'Mickey' Lauer - <mickey@tm.informatik.uni-frankfurt.de> - =. - .=l. - .>+-= - _;:, .> :=|. This program is free software; you can -.> <`_, > . <= redistribute it and/or modify it under -:`=1 )Y*s>-.-- : the terms of the GNU Library General Public -.="- .-=="i, .._ License as published by the Free Software - - . .-<_> .<> Foundation; either version 2 of the License, - ._= =} : or (at your option) any later version. - .%`+i> _;_. - .i_,=:_. -<s. This program is distributed in the hope that - + . -:. = it will be useful, but WITHOUT ANY WARRANTY; - : .. .:, . . . without even the implied warranty of - =_ + =;=|` MERCHANTABILITY or FITNESS FOR A - _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU -..}^=.= = ; Library General Public License for more -++= -. .` .: details. - : = ...= . :.=- - -. .:....=;==+<; You should have received a copy of the GNU - -_. . . )=. = Library General Public License along with - -- :-=` this library; see the file COPYING.LIB. - If not, write to the Free Software Foundation, - Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - -*/ - -#include <qcolor.h> -#include <qheader.h> -#include <qpainter.h> -#include <qpixmap.h> - -#include "olistview.h" - -//****************************** OListView ************************************************************************** - -OListView::OListView( QWidget *parent, const char *name ) - :QListView( parent, name ) -{ - //FIXME: get from global settings and calculate ==> see oglobalsettings.* - - m_alternateBackground = QColor( 238, 246, 255 ); - m_columnSeparator = QPen( QColor( 150, 160, 170 ), 0, DotLine ); - m_fullWidth = true; -} - -OListView::~OListView() -{ -} - -void OListView::setFullWidth( bool fullWidth ) -{ - m_fullWidth = m_fullWidth; - #if QT_VERSION > 290 - header()->setStretchEnabled( fullWidth, columns()-1 ); - #endif -} - -bool OListView::fullWidth() const -{ - return m_fullWidth; -} - -int OListView::addColumn( const QString& label, int width ) -{ - int result = QListView::addColumn( label, width ); - #if QT_VERSION > 290 - if (m_fullWidth) { - header()->setStretchEnabled( false, columns()-2 ); - header()->setStretchEnabled( true, columns()-1 ); - } - #endif - return result; -} - -int OListView::addColumn( const QIconSet& iconset, const QString& label, int width ) -{ - int result = QListView::addColumn( iconset, label, width ); - #if QT_VERSION > 290 - if (m_fullWidth) { - header()->setStretchEnabled( false, columns()-2 ); - header()->setStretchEnabled( true, columns()-1 ); - } - #endif - return result; -} - -void OListView::removeColumn( int index ) -{ - QListView::removeColumn(index); - #if QT_VERSION > 290 - if ( m_fullWidth && index == columns() ) - { - header()->setStretchEnabled( true, columns()-1 ); - } - #endif -} - -const QColor& OListView::alternateBackground() const -{ - return m_alternateBackground; -} - -void OListView::setAlternateBackground( const QColor &c ) -{ - m_alternateBackground = c; - repaint(); -} - -const QPen& OListView::columnSeparator() const -{ - return m_columnSeparator; -} - -void OListView::setColumnSeparator( const QPen& p ) -{ - m_columnSeparator = p; - repaint(); -} - -OListViewItem* OListView::childFactory() -{ - return new OListViewItem( this ); -} - -#ifndef QT_NO_DATASTREAM -void OListView::serializeTo( QDataStream& s ) const -{ - #warning Caution... the binary format is still under construction... - qDebug( "storing OListView..." ); - - // store number of columns and the labels - s << columns(); - for ( int i = 0; i < columns(); ++i ) - s << columnText( i ); - - // calculate the number of top-level items to serialize - int items = 0; - QListViewItem* item = firstChild(); - while ( item ) - { - item = item->nextSibling(); - items++; - } - - // store number of items and the items itself - s << items; - item = firstChild(); - for ( int i = 0; i < items; ++i ) - { - s << *static_cast<OListViewItem*>( item ); - item = item->nextSibling(); - } - - qDebug( "OListview stored." ); -} - -void OListView::serializeFrom( QDataStream& s ) -{ - #warning Caution... the binary format is still under construction... - qDebug( "loading OListView..." ); - - int cols; - s >> cols; - qDebug( "read number of columns = %d", cols ); - - while ( columns() < cols ) addColumn( QString::null ); - - for ( int i = 0; i < cols; ++i ) - { - QString coltext; - s >> coltext; - qDebug( "read text '%s' for column %d", (const char*) coltext, i ); - setColumnText( i, coltext ); - } - - int items; - s >> items; - qDebug( "read number of items = %d", items ); - - for ( int i = 0; i < items; ++i ) - { - OListViewItem* item = childFactory(); - s >> *item; - } - - qDebug( "OListView loaded." ); - -} - -QDataStream& operator<<( QDataStream& s, const OListView& lv ) -{ - lv.serializeTo( s ); -} - -QDataStream& operator>>( QDataStream& s, OListView& lv ) -{ - lv.serializeFrom( s ); -} -#endif // QT_NO_DATASTREAM - -//****************************** OListViewItem *********************************************************************** - -OListViewItem::OListViewItem(QListView *parent) - : QListViewItem(parent) -{ - init(); -} - -OListViewItem::OListViewItem(QListViewItem *parent) - : QListViewItem(parent) -{ - init(); -} - -OListViewItem::OListViewItem(QListView *parent, QListViewItem *after) - : QListViewItem(parent, after) -{ - init(); -} - -OListViewItem::OListViewItem(QListViewItem *parent, QListViewItem *after) - : QListViewItem(parent, after) -{ - init(); -} - -OListViewItem::OListViewItem(QListView *parent, - QString label1, QString label2, QString label3, QString label4, - QString label5, QString label6, QString label7, QString label8) - : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) -{ - init(); -} - -OListViewItem::OListViewItem(QListViewItem *parent, - QString label1, QString label2, QString label3, QString label4, - QString label5, QString label6, QString label7, QString label8) - : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) -{ - init(); -} - -OListViewItem::OListViewItem(QListView *parent, QListViewItem *after, - QString label1, QString label2, QString label3, QString label4, - QString label5, QString label6, QString label7, QString label8) - : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) -{ - init(); -} - -OListViewItem::OListViewItem(QListViewItem *parent, QListViewItem *after, - QString label1, QString label2, QString label3, QString label4, - QString label5, QString label6, QString label7, QString label8) - : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) -{ - init(); -} - -OListViewItem::~OListViewItem() -{ -} - -void OListViewItem::init() -{ - m_known = false; -} - -const QColor &OListViewItem::backgroundColor() -{ - return isAlternate() ? static_cast<OListView*>(listView())->alternateBackground() : - listView()->viewport()->colorGroup().base(); -} - -bool OListViewItem::isAlternate() -{ - OListView *lv = static_cast<OListView*>( listView() ); - - // check if the item above is an OListViewItem - OListViewItem *above = static_cast<OListViewItem*>( itemAbove() ); - /*if (! itemAbove()->inherits( "OListViewItem" )) return false;*/ - - // check if we have a valid alternate background color - if (!(lv && lv->alternateBackground().isValid())) return false; - - m_known = above ? above->m_known : true; - if (m_known) - { - m_odd = above ? !above->m_odd : false; - } - else - { - OListViewItem *item; - bool previous = true; - if (parent()) - { - item = static_cast<OListViewItem *>(parent()); - if ( item /*&& item->inherits( "OListViewItem" )*/ ) previous = item->m_odd; - item = static_cast<OListViewItem *>(parent()->firstChild()); - /* if ( !item.inherits( "OListViewItem" ) item = 0; */ - } - else - { - item = static_cast<OListViewItem *>(lv->firstChild()); - } - - while(item) - { - item->m_odd = previous = !previous; - item->m_known = true; - item = static_cast<OListViewItem *>(item->nextSibling()); - /* if (!item.inherits( "OListViewItem" ) ) break; */ - } - } - return m_odd; -} - -void OListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) -{ - QColorGroup _cg = cg; - const QPixmap *pm = listView()->viewport()->backgroundPixmap(); - if (pm && !pm->isNull()) - { - _cg.setBrush( QColorGroup::Base, QBrush(backgroundColor(), *pm) ); - p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() ); - } - else if ( isAlternate() ) - { - _cg.setColor( QColorGroup::Base, static_cast<OListView*>( listView() )->alternateBackground() ); - } - QListViewItem::paintCell( p, _cg, column, width, alignment ); - - //FIXME: Use styling here! - - const QPen& pen = static_cast<OListView*>( listView() )->columnSeparator(); - p->setPen( pen ); - p->drawLine( width-1, 0, width-1, height() ); -} - -OListViewItem* OListViewItem::childFactory() -{ - return new OListViewItem( this ); -} - -#ifndef QT_NO_DATASTREAM -void OListViewItem::serializeTo( QDataStream& s ) const -{ - #warning Caution... the binary format is still under construction... - qDebug( "storing OListViewItem..." ); - - // store item text - for ( int i = 0; i < listView()->columns(); ++i ) - { - s << text( i ); - } - - // calculate the number of children to serialize - int items = 0; - QListViewItem* item = firstChild(); - while ( item ) - { - item = item->nextSibling(); - items++; - } - - // store number of items and the items itself - s << items; - item = firstChild(); - for ( int i = 0; i < items; ++i ) - { - s << *static_cast<OListViewItem*>( item ); - item = item->nextSibling(); - } - - qDebug( "OListviewItem stored." ); -} -void OListViewItem::serializeFrom( QDataStream& s ) -{ - #warning Caution... the binary format is still under construction... - qDebug( "loading OListViewItem..." ); - - for ( int i = 0; i < listView()->columns(); ++i ) - { - QString coltext; - s >> coltext; - qDebug( "read text '%s' for column %d", (const char*) coltext, i ); - setText( i, coltext ); - } - - int items; - s >> items; - qDebug( "read number of items = %d", items ); - - for ( int i = 0; i < items; ++i ) - { - OListViewItem* item = childFactory(); - s >> (*item); - } - - qDebug( "OListViewItem loaded." ); -} - -QDataStream& operator<<( QDataStream& s, const OListViewItem& lvi ) -{ - lvi.serializeTo( s ); -} - -QDataStream& operator>>( QDataStream& s, OListViewItem& lvi ) -{ - lvi.serializeFrom( s ); -} -#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 @@ -/* - This file is part of the Opie Project - - Copyright (C) 2003 Michael 'Mickey' Lauer - <mickey@tm.informatik.uni-frankfurt.de> - =. - .=l. - .>+-= - _;:, .> :=|. This program is free software; you can -.> <`_, > . <= redistribute it and/or modify it under -:`=1 )Y*s>-.-- : the terms of the GNU Library General Public -.="- .-=="i, .._ License as published by the Free Software - - . .-<_> .<> Foundation; either version 2 of the License, - ._= =} : or (at your option) any later version. - .%`+i> _;_. - .i_,=:_. -<s. This program is distributed in the hope that - + . -:. = it will be useful, but WITHOUT ANY WARRANTY; - : .. .:, . . . without even the implied warranty of - =_ + =;=|` MERCHANTABILITY or FITNESS FOR A - _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU -..}^=.= = ; Library General Public License for more -++= -. .` .: details. - : = ...= . :.=- - -. .:....=;==+<; You should have received a copy of the GNU - -_. . . )=. = Library General Public License along with - -- :-=` this library; see the file COPYING.LIB. - If not, write to the Free Software Foundation, - Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - -*/ - -#ifndef OLISTVIEW_H -#define OLISTVIEW_H - -#include <qcolor.h> -#include <qlistview.h> -#include <qpen.h> -#include <qdatastream.h> - -class OListViewItem; - -/** - * A @ref QListView variant featuring visual and functional enhancements - * like an alternate background for odd rows, an autostretch mode - * for the width of the widget ( >= Qt 3 only ) and persistence capabilities. - * - * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> - * @short OListView list/tree widget. - */ - class OListView: public QListView -{ - public: - /** - * Constructor. - * - * The parameters @p parent and @p name are handled by - * @ref QListView, as usual. - */ - OListView ( QWidget *parent = 0, const char *name = 0 ); - - /** - * Destructor. - */ - virtual ~OListView(); - - /** - * Let the last column fit exactly all the available width. - */ - void setFullWidth( bool fullWidth ); - - /** - * Returns whether the last column is set to fit the available width. - */ - bool fullWidth() const; - - /** - * Reimplemented for full width support - */ - virtual int addColumn( const QString& label, int width = -1 ); - - /** - * Reimplemented for full width support - */ - virtual int addColumn( const QIconSet& iconset, const QString& label, int width = -1 ); - - /** - * Reimplemented for full width support - */ - virtual void removeColumn(int index); - - /** - * sets the alternate background background color. - * This only has an effect if the items are OListViewItems - * - * @param c the color to use for every other item. Set to an invalid - * color to disable alternate colors. - */ - void setAlternateBackground( const QColor &c ); - - /** - * sets the column separator pen. - * - * @param p the pen used to draw the column separator. - */ - void setColumnSeparator( const QPen &p ); - - /** - * @return the alternate background color - */ - const QColor& alternateBackground() const; - - /** - * @return the column separator pen - */ - const QPen& columnSeparator() const; - - /** - * create a list view item as child of this object - * @return the new object - */ - virtual OListViewItem* childFactory(); - - #ifndef QT_NO_DATASTREAM - /** - * serialize this object to a @ref QDataStream - * @param s the stream used to serialize this object. - */ - virtual void serializeTo( QDataStream& s ) const; - - /** - * serialize this object from a @ref QDataStream - * @param s the stream used to serialize this object. - */ - virtual void serializeFrom( QDataStream& s ); - #endif - - private: - QColor m_alternateBackground; - bool m_fullWidth; - QPen m_columnSeparator; -}; - -#ifndef QT_NO_DATASTREAM -/** - * \relates QListView - * Writes a listview to the stream and returns a reference to the stream. - */ -QDataStream& operator<<( QDataStream& s, const OListView& lv ); -/** - * \relates QListView - * Reads a listview from the stream and returns a reference to the stream. - */ -QDataStream& operator>>( QDataStream& s, OListView& lv ); -#endif // QT_NO_DATASTREAM - -//****************************** OListViewItem ****************************************************************** - -class OListViewItem: public QListViewItem -{ - public: - OListViewItem( QListView * parent ); - OListViewItem( QListViewItem * parent ); - OListViewItem( QListView * parent, QListViewItem * after ); - OListViewItem( QListViewItem * parent, QListViewItem * after ); - - OListViewItem( QListView * parent, - QString, QString = QString::null, - QString = QString::null, QString = QString::null, - QString = QString::null, QString = QString::null, - QString = QString::null, QString = QString::null ); - - OListViewItem( QListViewItem * parent, - QString, QString = QString::null, - QString = QString::null, QString = QString::null, - QString = QString::null, QString = QString::null, - QString = QString::null, QString = QString::null ); - - OListViewItem( QListView * parent, QListViewItem * after, - QString, QString = QString::null, - QString = QString::null, QString = QString::null, - QString = QString::null, QString = QString::null, - QString = QString::null, QString = QString::null ); - - OListViewItem( QListViewItem * parent, QListViewItem * after, - QString, QString = QString::null, - QString = QString::null, QString = QString::null, - QString = QString::null, QString = QString::null, - QString = QString::null, QString = QString::null ); - - virtual ~OListViewItem(); - - const QColor& backgroundColor(); - bool isAlternate(); - void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment ); - void init(); - - /** - * create a list view item as child of this object - * @return the new object - */ - virtual OListViewItem* childFactory(); - - #ifndef QT_NO_DATASTREAM - /** - * serialize this object to or from a @ref QDataStream - * @param s the stream used to serialize this object. - */ - virtual void serializeTo( QDataStream& s ) const; - - /** - * serialize this object to or from a @ref QDataStream - * @param s the stream used to serialize this object. - */ - virtual void serializeFrom( QDataStream& s ); - #endif - - private: - bool m_known; - bool m_odd; -}; - -#ifndef QT_NO_DATASTREAM -/** - * \relates QListViewItem - * Writes a listview item and all subitems recursively to the stream - * and returns a reference to the stream. - */ -QDataStream& operator<<( QDataStream &s, const OListViewItem& lvi ); -/** - * \relates QListViewItem - * Reads a listview item from the stream and returns a reference to the stream. - */ -QDataStream& operator>>( QDataStream &s, OListViewItem& lvi ); -#endif // QT_NO_DATASTREAM - -#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 @@ -*.o -*~ -moc_* -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 @@ -DESTDIR = $(OPIEDIR)/bin -TEMPLATE = app -CONFIG = warn_on debug -#CONFIG = warn_on release -HEADERS = source/config.hh source/daemon.hh -SOURCES = source/daemon.cc -INCLUDEPATH += ../ -DEPENDPATH += $(OPIEDIR)/include -LIBS += -lpcap -lpthread -L$(OPIEDIR)/lib -lwellenreiter -INTERFACES = -TARGET = wellenreiterd -DEFINES += DEBUG - -!contains( platform, x11 ) { - include ( $(OPIEDIR)/include.pro ) -} 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 @@ -*.o -*~ -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 @@ -# $Id$ - -CPP = g++ -CPPFLAGS = -g -Wall -pedantic -DDEBUG -I ../../ -LIBS = -lpthread -lpcap ../../libwellenreiter/source/libwellenreiter.a -OBJ = daemon.o - -.SUFFIXES: -.PHONY: all wellenreiterd clean distclean realclean - -%.o : %.cc - $(CPP) $(CPPFLAGS) -c $< -o $@ - -all: wellenreiterd - -wellenreiterd: $(OBJ) - $(CPP) $(CPPFLAGS) $(OBJ) $(LIBS) -o $@ - @echo Build wellenreiterd - -clean distclean realclean: - @rm -f wellenreiterd *~ *.o - @echo All dependent files have been removed. - -daemon.o: config.hh - 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 @@ -/* - * - * Global configuration for wellenreiter - * - * $Id$ - * - * Written by Martin J. Muench <mjm@codito.de> - * - */ - -#ifndef CONFIG_HH -#define CONFIG_HH - -#define PROGNAME "wellenreiter" /* Name of program (for syslog et.al.) */ -#define VERSION "0.2" /* Version of wellenreiter */ - -#define DAEMONADDR "127.0.0.1" -#define DAEMONPORT 37772 /* Port of Daemon */ - -#define GUIADDR "127.0.0.1" /* Adress of GUI, later specified in configfile */ -#define GUIPORT 37773 /* Port of GUI, " " */ - -/* Temporary cardmode stuff, will hopefully removed soon */ -#define CARD_TYPE_CISCO 1 -#define CARD_TYPE_NG 2 -#define CARD_TYPE_HOSTAP 3 -#define CARD_TYPE_ORINOCCO 4 - -#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 @@ -/* - * Startup functions of wellenreiter - * - * $Id$ - */ - -#include "config.hh" -#include "daemon.hh" - -/* should be parsed from cfg-file */ -#define MAXCHANNEL 13 -#define CHANINTERVAL 500000 - - -/* Main function of wellenreiterd */ -int main(int argc, char **argv) -{ - int sock, maxfd, retval; - char buffer[WL_SOCKBUF]; - struct pcap_pkthdr header; - struct sockaddr_in saddr; -// pcap_t *handletopcap; - wl_cardtype_t cardtype; - pthread_t sub; - const unsigned char *packet; - - fd_set rset; - - fprintf(stderr, "wellenreiterd %s\n\n", VERSION); - fprintf(stderr, "(c) 2002 by M-M-M\n\n"); - - if(argc < 3) - usage(); - - /* Set sniffer device */ - memset(cardtype.iface, 0, sizeof(cardtype.iface)); - strncpy(cardtype.iface, (char *)argv[1], sizeof(cardtype.iface) - 1); - - /* Set card type */ - cardtype.type = atoi(argv[2]); - if(cardtype.type < 1 || cardtype.type > 4) - usage(); - - /* Until we do not act as a read daemon, it starts the sniffer - right after startup */ - if (!start_sniffer(cardtype.iface,cardtype.type)) - { - wl_logerr("daemon, start_sniff did not return proper, aborting"); - exit(EXIT_FAILURE); - } - wl_loginfo ("daemon, wireless card prepared for sniffing"); - - /* Setup socket for incoming commands */ - if((sock=wl_setupsock(DAEMONADDR, DAEMONPORT, saddr)) < 0) - { - wl_logerr("Cannot setup socket"); - exit(EXIT_FAILURE); - } - wl_loginfo("Set up socket '%d' for GUI communication", sock); - - /* Create channelswitching thread */ - if(pthread_create(&sub, NULL, channel_switcher, - (void *)&cardtype) != 0) - { - wl_logerr("Cannot create thread: %s", strerror(errno)); - close(sock); - exit(EXIT_FAILURE); - } - if(pthread_detach(sub)) - { - wl_logerr("Error detaching thread"); - close(sock); - pthread_exit((pthread_t *)sub); - exit(EXIT_FAILURE); - } - wl_loginfo("Created and detached channel switching thread"); - - FD_ZERO(&rset); - - /* Start main loop */ - wl_loginfo("Starting main loop"); - while(1) - { - - FD_SET(sock, &rset); - FD_SET(pcap_fileno(handletopcap), &rset); - - /* maxfd = biggest filefd */ - maxfd = (sock > pcap_fileno(handletopcap) ? - sock + 1 : pcap_fileno(handletopcap)) + 1; - - if(select(maxfd, &rset, NULL, NULL, NULL) < 0) - { - wl_logerr("Error calling select: %s", strerror(errno)); - break; - } - - /* Got data on local socket from GUI */ - if(FD_ISSET(sock, &rset)) - { - /* Receive data from socket */ - if((retval=wl_recv(&sock, saddr, buffer, sizeof(buffer))) < 0) - { - wl_logerr("Error trying to read: %s", strerror(errno)); - break; - } - else - { - /* check type of packet and start function according to it */ - switch(retval) - { - case STARTSNIFF: - wl_loginfo("Received STARTSNIFF command"); - if(!send_ok(GUIADDR, GUIPORT, STARTSNIFF)) - wl_logerr("Cannot set OK_CMD to GUI"); - break; - case STOPSNIFF: - wl_loginfo("Received STOPSNIFF command"); - if(!send_ok(GUIADDR, GUIPORT, STOPSNIFF)) - wl_logerr("Cannot set FAIL_CMD to GUI"); - break; - default: - wl_logerr("Received unknown command: %d", retval); - break; - } - } - } /* FD_ISSET */ - - /* Check pcap lib for packets */ - if(FD_ISSET(pcap_fileno(handletopcap), &rset)) - { - - /* Grab one single packet */ - packet = pcap_next(handletopcap, &header); - - /* process the packet */ - process_packets(&header,*&packet, GUIADDR, GUIPORT); - } - - } /* while(1) */ - - close(sock); - exit(EXIT_SUCCESS); -} - -void -usage(void) -{ - fprintf(stderr, "Usage: wellenreiter <device> <cardtype>\n" \ - "\t<device> = Wirelessdevice (e.g. wlan0)\n" \ - "\t<cardtype> = Cardtype:\tCisco\t= 1\n" \ - "\t\t\t\tNG\t= 2\n" \ - "\t\t\t\tHOSTAP\t= 3\n" \ - "\t\t\t\tLUCENT\t= 4\n"); - exit(EXIT_FAILURE); -} - -void * -channel_switcher(void *cardtypeptr) -{ - wl_cardtype_t *cardtype; - int maxchan=0; - int channel=1; - /* Get card info struct */ - cardtype = (wl_cardtype_t *)cardtypeptr; - /* Get from the wireless extension the amount of available channels - this prevents a fail in switching on us cards */ - maxchan = card_detect_channels(cardtype->iface); - - if (maxchan < MAXCHANNEL) - { - #undef MAXCHANNEL - #define MAXCHANNEL maxchan - } - - while(1) - { - - /* If channel bigger than maxchannel, set to 1 */ - if(channel > MAXCHANNEL) - channel=1; - - /* Set channel */ - if(!card_set_channel(cardtype->iface, channel, cardtype->type)) - { - wl_logerr("Cannot set channel, thread exiting"); - pthread_exit(NULL); - } - - /* sleep */ - usleep(CHANINTERVAL); - - channel++; - } /* while */ -} 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 @@ -/* $Id$ */ - -#ifndef DAEMON_HH -#define DAEMON_HH - -#include <stdio.h> -#include <string.h> -#include <sys/types.h> -#include <sys/time.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <pthread.h> -#include <unistd.h> -#include <errno.h> - -#include <libwellenreiter/source/wl_sock.hh> -#include <libwellenreiter/source/wl_log.hh> -#include <libwellenreiter/source/wl_types.hh> -#include <libwellenreiter/source/wl_proto.hh> -#include <libwellenreiter/source/cardmode.hh> -#include <libwellenreiter/source/sniff.hh> - -void usage(void); -void *channel_switcher(void *); - -#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 @@ - --[ Design of wellenreiter ]- - -written by: Martin J. Muench <mjm@codito.de> - --[ Introduction - -This is just a short overview of the new design of wellenreiter. -There will for sure be some changes and most parts will be specified -in more detail. - - --[ Program - -wellenreiter 1.7 -(will be named 2.0 after all the functions are implemented and the code -is cleaned up and audited) - - --[ Short description - -Wellenreiter is a wireless sniffing tool like netstumbler, kismet et al. -It discovers Access Points and Ad-Hoc networks and displays all available -information about them so that you can simply join unencrypted network -(without access restrictions) with the given informations. -For the latest version of wellenreiter look at: -http://wellenreiter.sourceforge.net. - - --[ Overview - -The software is divided into 2 sections, the daemon and the GUI. -The daemon does the active sniffing, analying stuff etc.pp. and -sends the informations to the GUI which displays the results. - - --[ Configuration - -The configuration is done by both, the GUI and the daemon so that the -GUI only provides the graphical interface to the configuration library -of the daemon. That means that the daemon loads the config file on -startup and sends the informations to the GUI. The GUI contains an option -"configure" where the settings can be changed. They will be sent to the -daemon which actually changes the configuration file. -The configuration file is placed in /usr/local/etc/wellenreiter.conf. -The whole content of this file cannot be specified yet. - -OPIE specific: Opie contains a bunch of high-level configuration classes, -which are used by most Opie applications. It should be discussed whether -to use this structure / API (preferred) or use a proprietary one. - - --[ Interaction GUI<->daemon - -The GUI and the daemon will talk actively with eachother, meaning that -everyside who has informations for the other part will send it and not -wait for the other part to poll. -For example the sniffing function of the daemon is startet when a -"start_sniff" from the GUI arrived. And when the daemon found a network -it will be directly send to the GUI to be able to sniff in realtime. - - --[ Communication GUI<->daemon - -The GUI and the daemon run as threads within one process, where the GUI -thread will be the main thread. Both the daemon and the GUI thread are -(mostly) "free-running". Once the GUI thread is started and has finished -its initializations, it jumps into the Qt event loop ( QApplication::exec() ). - -If the daemon thread is actively working and - -for instance - has acquired interesting data for the GUI thread to display, -it calls a special reentrant method of the GUI thread ( QApplication::postEvent ) -either transmitting the whole data structure or saying "Hey, there's interesting data -for you", which the GUI thread then retrieves. -To enable a free running daemon thread to actually receive messages from the -GUI thread, it's useful to to include a non-blocking check-for-messages-function -within the daemon main loop <since it is waiting for messages from a GUI thread, -this function has not be called very often>. If applicable, the daemon thread must -not call this function but only monitor some guarded variables from time to time -which the GUI thread can modify to alter the behaviour of the daemon thread. - -IMHO this is a much more leightweight design than to use a proprietary udp-socket protocol. - - --[ Setting card modes - -One of the most interesting parts is the switching of the wirelesscards to -different channels, to monitor mode and so on. In the older versions this -actions were done by the calling of external programs, that is now obsolete. -We will use the API of the wireless drivers to set it up. - - --[ Sniffing - -The sniffing will be done by capturing and analyzing all packets using the -pcap library. The sniffer itself will be a function of the daemon which will -probably be threaded so that this function is non-blocking. -If a packet is found the sniffer sends it to an analyzer function which -analyzes the packets, strips the results and sends it to the GUI. - - --[ Logging - -The GUI should not need to log that much so it logs to STDERR. The daemon -will be able to run in foreground and log to STDERR and syslog but normally -it will only log to syslog (INFO/ERR). -Logging of found networks, packets and so on will also be done by the daemon -but set up by the GUI. - - --[ GPS - -The gps daemon software will be used, hopefully by their API if they provide -that. If not, we have to use system() calls, hope we do not. - - --[ Security - -The programm and the daemon will have to run with SUID privileges for being -able to change card modes etc. so the code has to be audited several times. -Setuid 0 will only be called when really needing the privileges and dropped -directly after every single systemcall. -The daemon will implement an access control list where it specifies which -IPs or network interfaces will have access to it. -The configuration file will be chmod'ed 0400, for writing the configuration -library will change the mode. Of course the file will be locked during -writing so no race conditions can occur. - - --[ Documentation - -Wellenreiter will have it's own wellenreiter(8) manpage with most parts of -the README file in there. -Also we will provide general documentation about wireless scanning, security -risks with wireless devices and so on. -Most documentation will be intern like this one. The GUI and the daemon -should have a non-technical documentation and a developers version so we -can easily develope with other peoples code without having to read it -completely. - 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 @@ -/********************************************************************** -** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. -** -** This file is part of Opie Environment. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -**********************************************************************/ - -#include "cardconfig.h" - -#include <qstring.h> - -CardConfig::CardConfig( const QString& interface, Type type, int hopinterval ) - :_interface( interface ), _type( type ), _hopinterval( hopinterval ) -{ - -} - -CardConfig::~CardConfig() -{ -} - 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 @@ -/********************************************************************** -** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. -** -** This file is part of Opie Environment. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -**********************************************************************/ - -#ifndef CARDCONFIG_H -#define CARDCONFIG_H - -#include <qstring.h> - -#ifdef QWS -#include <opie/odevice.h> -using namespace Opie; -#endif - -class CardConfig -{ - public: - - typedef enum { Prism, Orinoco, HostAP, Manual } Type; - - public: - - CardConfig( const QString& interface, Type type = Manual, int hopinterval = 100 ); - virtual ~CardConfig(); - - const QString& interface() { return _interface; }; - int hopinterval() { return _hopinterval; }; - Type type() { return _type; }; - - #ifdef QWS - OSystem system() { return _system; }; - #endif - - private: - - QString _interface; - Type _type; - int _hopinterval; - - #ifdef QWS - OSystem _system; - #endif - -}; - -#endif - diff --git a/noncore/net/wellenreiter/gui/configbase.ui b/noncore/net/wellenreiter/gui/configbase.ui index 398118f..fa727f9 100644 --- a/noncore/net/wellenreiter/gui/configbase.ui +++ b/noncore/net/wellenreiter/gui/configbase.ui @@ -11,7 +11,7 @@ <rect> <x>0</x> <y>0</y> - <width>220</width> + <width>212</width> <height>267</height> </rect> </property> @@ -103,48 +103,6 @@ </property> <widget row="0" column="0" > <class>QComboBox</class> - <item> - <property> - <name>text</name> - <string><select></string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>eth0</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>eth1</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>wlan0</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>wlan1</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>wifi0</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>wifi1</string> - </property> - </item> <property stdset="1"> <name>name</name> <cstring>interfaceName</cstring> @@ -421,6 +379,10 @@ <cstring>beepOnFound</cstring> </property> <property stdset="1"> + <name>enabled</name> + <bool>false</bool> + </property> + <property stdset="1"> <name>text</name> <string>Beep on new network</string> </property> diff --git a/noncore/net/wellenreiter/gui/configwindow.cpp b/noncore/net/wellenreiter/gui/configwindow.cpp index f86b109..6dd862f 100644 --- a/noncore/net/wellenreiter/gui/configwindow.cpp +++ b/noncore/net/wellenreiter/gui/configwindow.cpp @@ -13,13 +13,19 @@ ** **********************************************************************/ +/* LOCAL */ #include "configwindow.h" + +/* QT */ #include <qmap.h> #include <qcombobox.h> #include <qpushbutton.h> #include <qspinbox.h> #include <qlayout.h> +/* OPIE */ +#include <opie2/onetwork.h> + WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f ) :WellenreiterConfigBase( parent, name, true, f ) { @@ -29,6 +35,16 @@ WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char _devicetype[ "orinoco" ] = 4; _devicetype[ "<manual>" ] = 5; + // gather possible interface names from ONetwork + ONetwork* net = ONetwork::instance(); + ONetwork::InterfaceIterator it = net->iterator(); + while ( it.current() ) + { + if ( it.current()->isWireless() ) + interfaceName->insertItem( it.current()->name() ); + ++it; + } + #ifdef Q_WS_X11 // We're on X11: adding an Ok-Button for the Dialog here QPushButton* okButton = new QPushButton( "ok", this ); okButton->show(); diff --git a/noncore/net/wellenreiter/gui/gui.pro b/noncore/net/wellenreiter/gui/gui.pro index 8861a50..200bfc1 100644 --- a/noncore/net/wellenreiter/gui/gui.pro +++ b/noncore/net/wellenreiter/gui/gui.pro @@ -11,8 +11,6 @@ HEADERS = wellenreiterbase.h \ logwindow.h \ hexwindow.h \ configwindow.h \ - wlan.h \ - cardconfig.h \ manufacturers.h SOURCES = main.cpp \ @@ -23,13 +21,11 @@ SOURCES = main.cpp \ logwindow.cpp \ hexwindow.cpp \ configwindow.cpp \ - wlan.cpp \ - cardconfig.cpp \ manufacturers.cpp -INCLUDEPATH += $(OPIEDIR)/include ../ -DEPENDPATH += $(OPIEDIR)/include ../ -LIBS += -L. -lwellenreiter -lcornucopia +INCLUDEPATH += $(OPIEDIR)/include +DEPENDPATH += $(OPIEDIR)/include +LIBS += -L. -lwellenreiter -lopiecore2 -lopieui2 -lopienet2 INTERFACES = configbase.ui TARGET = wellenreiter diff --git a/noncore/net/wellenreiter/gui/main.cpp b/noncore/net/wellenreiter/gui/main.cpp index 270ce06..96a8c1c 100644 --- a/noncore/net/wellenreiter/gui/main.cpp +++ b/noncore/net/wellenreiter/gui/main.cpp @@ -14,30 +14,14 @@ **********************************************************************/ #include "mainwindow.h" - -#ifdef QWS -#include <qpe/qpeapplication.h> -#else -#include <qapplication.h> -#endif +#include <opie2/oapplication.h> int main( int argc, char **argv ) { -#ifdef QWS - QPEApplication a( argc, argv ); -#else - QApplication a( argc, argv ); -#endif - - WellenreiterMainWindow w; - - w.setCaption( "Wellenreiter/Opie" ); -#ifdef QWS - a.showMainWidget(&w); -#else - a.setMainWidget(&w); - w.show(); -#endif - - return a.exec(); + OApplication a( argc, argv, "Wellenreiter II" ); + WellenreiterMainWindow* w = new WellenreiterMainWindow(); + a.showMainWidget( w ); + a.exec(); + delete w; + return 0; } diff --git a/noncore/net/wellenreiter/gui/scanlist.h b/noncore/net/wellenreiter/gui/scanlist.h index 222217c..da9369f 100644 --- a/noncore/net/wellenreiter/gui/scanlist.h +++ b/noncore/net/wellenreiter/gui/scanlist.h @@ -16,7 +16,7 @@ #ifndef SCANLIST_H #define SCANLIST_H -#include <cornucopia/olistview.h> +#include <opie2/olistview.h> #include <qtextstream.h> diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index 09a44e6..5bdc1b3 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp @@ -21,13 +21,6 @@ #include <qspinbox.h> #include <qsocketnotifier.h> -// Qtopia - -#ifdef QWS -#include <qpe/qpeapplication.h> -#include <qpe/global.h> -#endif - // Opie #ifdef QWS @@ -35,6 +28,10 @@ using namespace Opie; #endif +#include <opie2/oapplication.h> +#include <opie2/onetwork.h> +#include <opie2/opcap.h> + // Standard #include <assert.h> @@ -42,9 +39,7 @@ using namespace Opie; #include <unistd.h> #include <string.h> #include <sys/types.h> -#include <sys/socket.h> #include <stdlib.h> -#include <fcntl.h> // Local @@ -56,14 +51,9 @@ using namespace Opie; #include "manufacturers.h" -#include <daemon/source/config.hh> -#include <libwellenreiter/source/wl_types.hh> -#include <libwellenreiter/source/wl_sock.hh> -#include <libwellenreiter/source/wl_proto.hh> - Wellenreiter::Wellenreiter( QWidget* parent ) : WellenreiterBase( parent, 0, 0 ), - daemonRunning( false ), manufacturerdb( 0 ), configwindow( 0 ) + sniffing( false ), iface( 0 ), manufacturerdb( 0 ), configwindow( 0 ) { // @@ -91,31 +81,14 @@ Wellenreiter::Wellenreiter( QWidget* parent ) logwindow->log( sys ); #endif - // - // setup socket for daemon communication, register socket notifier - // - - // struct sockaddr_in sockaddr; - daemon_fd = wl_setupsock( GUIADDR, GUIPORT, sockaddr ); - if ( daemon_fd == -1 ) - { - logwindow->log( "(E) Couldn't get file descriptor for commsocket." ); - } - else - { - int flags; - flags = fcntl( daemon_fd, F_GETFL, 0 ); - fcntl( daemon_fd, F_SETFL, flags | O_NONBLOCK ); - QSocketNotifier *sn = new QSocketNotifier( daemon_fd, QSocketNotifier::Read, this ); - connect( sn, SIGNAL( activated( int ) ), this, SLOT( dataReceived() ) ); - } - // setup GUI netview->setColumnWidthMode( 1, QListView::Manual ); if ( manufacturerdb ) netview->setManufacturerDB( manufacturerdb ); + pcap = new OPacketCapturer(); + } Wellenreiter::~Wellenreiter() @@ -123,14 +96,7 @@ Wellenreiter::~Wellenreiter() // no need to delete child widgets, Qt does it all for us delete manufacturerdb; - - if ( daemon_fd != -1 ) - { - qDebug( "closing comm socket" ); - ::shutdown( daemon_fd, 0 ); - ::close( daemon_fd ); - qDebug( "comm socket closed." ); - } + delete pcap; } void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) @@ -138,145 +104,125 @@ void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) configwindow = cw; } -void Wellenreiter::handleMessage() +void Wellenreiter::receivePacket(OPacket* p) { - // FIXME: receive message and handle it - - qDebug( "received message from daemon." ); - - /*char buffer[10000]; - memset( &buffer, 0, sizeof( buffer ) );*/ - - char buffer[WL_SOCKBUF]; - - // int result = #wl_recv( &daemon_fd, (char*) &buffer, sizeof(buffer) ); - - /* - - struct sockaddr from; - socklen_t len; - - int result = recvfrom( daemon_fd, &buffer, 8192, MSG_WAITALL, &from, &len ); - qDebug( "received %d from recv [%d bytes]", result, len ); - - */ - - int result = wl_recv( &daemon_fd, sockaddr, (char*) &buffer, WL_SOCKBUF ); - - if ( result == -1 ) - { - qDebug( "Warning: %s", strerror( errno ) ); - return; - } - - int command = buffer[1] - 48; - -/* -typedef struct { - int net_type; 1 = Accesspoint ; 2 = Ad-Hoc - int ssid_len; Length of SSID - int channel; Channel - int wep; 1 = WEP enabled ; 0 = disabled - char mac[64]; MAC address of Accesspoint - char bssid[128]; BSSID of Accesspoint -} wl_network_t; -*/ - - qDebug( "Recv result: %d", ( result ) ); - qDebug( "Sniffer sent: '%s'", (const char*) buffer ); - hexwindow->log( (const char*) &buffer ); - - if ( command == NETFOUND ) /* new network found */ - { - qDebug( "Sniffer said: new network found." ); - wl_network_t n; - get_network_found( &n, (char*) &buffer ); - - qDebug( "Sniffer said: net_type is %d.", n.net_type ); - qDebug( "Sniffer said: MAC is %s", (const char*) &n.mac ); - - //n.bssid[n.ssid_len] = "\0"; - - QString type; - - if ( n.net_type == 1 ) - type = "managed"; - else - type = "adhoc"; + logwindow->log( "(d) Received data from daemon" ); + //TODO - netview->addNewItem( type, n.bssid, QString( (const char*) &n.mac ), n.wep, n.channel, 0 ); + // check if we received a beacon frame + // static_cast is justified here + OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) ); + if ( !beacon ) return; + QString type; - } + //FIXME: Can stations in ESS mode can be distinguished from APs? + //FIXME: Apparently yes, but not by listening to beacons, because + //FIXME: they simply don't send beacons in infrastructure mode. + //FIXME: so we also have to listen to data packets + if ( beacon->canIBSS() ) + type = "adhoc"; else + type = "managed"; - { - qDebug( "unknown sniffer command." ); - } + OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); + QString essid = ssid ? ssid->ID() : "<unknown>"; + OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); + int channel = ds ? ds->channel() : -1; -} - -void Wellenreiter::dataReceived() -{ - logwindow->log( "(d) Received data from daemon" ); - handleMessage(); + OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); + netView()->addNewItem( type, essid, header->macAddress2().toString(), header->usesWep(), channel, 0 ); } void Wellenreiter::startStopClicked() { - if ( daemonRunning ) + if ( sniffing ) { - daemonRunning = false; + disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); - logwindow->log( "(i) Daemon has been stopped." ); - setCaption( tr( "Wellenreiter/Opie" ) ); + iface->setChannelHopping(); // stop hopping channels + pcap->close(); + sniffing = false; + oApp->setTitle(); - // Stop daemon - ugly for now... later better + // get interface name from config window + const QString& interface = configwindow->interfaceName->currentText(); + ONetwork* net = ONetwork::instance(); + iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); - system( "killall wellenreiterd" ); + // switch off monitor mode + iface->setMonitorMode( false ); + // switch off promisc flag + iface->setPromiscuousMode( false ); - // get configuration from config window + //TODO: Display "please wait..." (use owait?) - const QString& interface = configwindow->interfaceName->currentText(); - - // reset the interface trying to get it into a usable state again + /* QString cmdline; - cmdline.sprintf( "iwpriv %s monitor 0; ifdown %s; ifup %s", (const char*) interface, (const char*) interface, (const char*) interface ); - system( cmdline ); + cmdline.sprintf( "ifdown %s; sleep 1; ifup %s", (const char*) interface, (const char*) interface, (const char*) interface ); + system( cmdline ); //FIXME: Use OProcess + + */ // message the user - QMessageBox::information( this, "Wellenreiter/Opie", "Your wireless card\nshould now be usable again." ); + //QMessageBox::information( this, "Wellenreiter II", "Your wireless card\nshould now be usable again." ); } else { - // get configuration from config window const QString& interface = configwindow->interfaceName->currentText(); const int cardtype = configwindow->daemonDeviceType(); const int interval = configwindow->daemonHopInterval(); - if ( ( interface == "<select>" ) || ( cardtype == 0 ) ) + if ( ( interface == "" ) || ( cardtype == 0 ) ) { - QMessageBox::information( this, "Wellenreiter/Opie", "Your device is not\nptoperly configured. Please reconfigure!" ); + QMessageBox::information( this, "Wellenreiter II", "Your device is not\nproperly configured. Please reconfigure!" ); return; } - // start wellenreiterd + // configure device - QString cmdline; - cmdline.sprintf( "wellenreiterd %s %d &", (const char*) interface, cardtype ); + ONetwork* net = ONetwork::instance(); + iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); + + // set monitor mode + + switch ( cardtype ) + { + case 1: iface->setMonitoring( new OCiscoMonitoringInterface( iface ) ); break; + case 2: iface->setMonitoring( new OWlanNGMonitoringInterface( iface ) ); break; + case 3: iface->setMonitoring( new OHostAPMonitoringInterface( iface ) ); break; + case 4: iface->setMonitoring( new OOrinocoMonitoringInterface( iface ) ); break; + default: assert( 0 ); // shouldn't happen + } + + iface->setMonitorMode( true ); + + // open pcap and start sniffing + pcap->open( interface ); + + if ( !pcap->isOpen() ) + { + QMessageBox::warning( this, "Wellenreiter II", "Can't open packet capturer:\n" + QString(strerror( errno ) )); + return; + } + + // set capturer to non-blocking mode + pcap->setBlocking( false ); + + // start channel hopper + iface->setChannelHopping( 1000 ); //use interval from config window - qDebug( "about to execute '%s' ...", (const char*) cmdline ); - system( cmdline ); - qDebug( "done!" ); + // connect + connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); logwindow->log( "(i) Daemon has been started." ); - daemonRunning = true; - setCaption( tr( "Scanning ..." ) ); + oApp->setTitle( "Scanning ..." ); + sniffing = true; } } diff --git a/noncore/net/wellenreiter/gui/wellenreiter.h b/noncore/net/wellenreiter/gui/wellenreiter.h index ee9dca9..3ec4021 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.h +++ b/noncore/net/wellenreiter/gui/wellenreiter.h @@ -23,23 +23,11 @@ using namespace Opie; #endif -// ugly... not here! - -#include <assert.h> -#include <errno.h> -#include <unistd.h> -#include <string.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <stdlib.h> -#include <fcntl.h> -#include <daemon/source/config.hh> -#include <libwellenreiter/source/wl_types.hh> -#include <libwellenreiter/source/wl_sock.hh> -#include <libwellenreiter/source/wl_proto.hh> - class QTimerEvent; class QPixmap; +class OPacket; +class OPacketCapturer; +class OWirelessNetworkInterface; class ManufacturerDB; class WellenreiterConfigWindow; @@ -53,25 +41,22 @@ class Wellenreiter : public WellenreiterBase { void setConfigWindow( WellenreiterConfigWindow* cw ); MScanListView* netView() const { return netview; }; MLogWindow* logWindow() const { return logwindow; }; - bool isDaemonRunning() const { return daemonRunning; }; - - protected: - bool daemonRunning; + bool isDaemonRunning() const { return sniffing; }; public slots: - void dataReceived(); + void receivePacket(OPacket*); void startStopClicked(); private: - int daemon_fd; // socket filedescriptor for udp communication socket #ifdef QWS OSystem _system; // Opie Operating System identifier #endif - void handleMessage(); + bool sniffing; + OWirelessNetworkInterface* iface; + OPacketCapturer* pcap; ManufacturerDB* manufacturerdb; WellenreiterConfigWindow* configwindow; - struct sockaddr_in sockaddr; //void readConfig(); //void writeConfig(); diff --git a/noncore/net/wellenreiter/gui/wlan.cpp b/noncore/net/wellenreiter/gui/wlan.cpp deleted file mode 100644 index b046cc8..0000000 --- a/noncore/net/wellenreiter/gui/wlan.cpp +++ b/dev/null @@ -1,57 +0,0 @@ -/********************************************************************** -** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. -** -** This file is part of Opie Environment. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -**********************************************************************/ - -#include "wlan.h" -#include "cardconfig.h" - -// Qt -#include <qstring.h> - -// Qtopia -#ifdef QWS -#include <opie/odevice.h> -using namespace Opie; -#endif - -WLAN::WLAN( const QString& interface ) -{ - _configuration = new CardConfig( interface ); -} - -WLAN::WLAN( const CardConfig* configuration ) -{ - _configuration = configuration; - -} - -WLAN::~WLAN() -{ - delete _configuration; - -} - -void WLAN::setMonitorMode( bool enabled ) -{ - - /* - - if ( _configuration->system() == System_OpenZaurus && _configuration->type() == CardConfig::Prism ) - { - } - - */ - -} - 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 @@ -/********************************************************************** -** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. -** -** This file is part of Opie Environment. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -**********************************************************************/ - -#ifndef WLAN_H -#define WLAN_H - -class QString; -class CardConfig; - -class WLAN -{ - public: - - WLAN( const QString& interface ); - WLAN( const CardConfig* ); - virtual ~WLAN(); - void setMonitorMode( bool enabled ); - - private: - - const CardConfig* _configuration; - -}; - -#endif - 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 @@ -*.o -*~ -moc_* -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 @@ - -Name: libwellenreiter -Author: Martin J. Muench - -NOTE: This is just a very short summary of the functions included -in libwellenreiter, written because a lack of time. The whole -library will be rewritten with extended documentation and -test programs. - --- -Wellenreiter types: -In proto.hh the following type (wl_network_t) is declared: - -typedef struct { - int net_type; /* 1 = Accesspoint ; 2 = Ad-Hoc */ - int ssid_len; /* Length of SSID */ - int channel; /* Channel */ - int wep; /* 1 = WEP enabled ; 0 = disabled */ - char mac[64]; /* MAC address of Accesspoint */ - char bssid[128]; /* BSSID of Accesspoint */ -} wl_network_t; - -When a network is found, the structure has to be set and -sent to the send_network_found() function. - -When the GUI receives a found network string it calls the -get_network_found() function to get its own structure set. - --- -Included functions: - --- -Protocol: - -Send a found network to GUI: -int send_network_found (const char *, int, void *); - -The first two arguments are the guihost and the guiport. -The third is the filled structure (wl_network_t), that will -be send to the GUI. - -Setup structure for found network: -int get_network_found (void *, const char *); - -When the GUI receives a new network found packet it calls -this function and passes a wl_network_t structure and the -received buffer. The function will strip the data from -the buffer and set it to the structure. - --- -Log to syslog/info: -void wl_loginfo(const char *, ...); - -Log to syslog/err: -void wl_logerr(const char *, ...); - -Use like printf() function with format strings and so on. - --- -Setup udp socket for incoming commands: -int commsock(const char *, int); - -Fist argument is the host where it should listen and second -is the port. Socket is returned, on failure -1 is returned. - - -Recvfrom socket: -int recv_commsock(int *, char *, int); - -First argument is the address of the socket, second is a buffer -that should be filled in and the third is the maxlength of the -buffer. On error, -1 is returned, on success the number of -packet type is returned. (return value should be used with switch -command, for types see proto.hh) - -Send command to udp socket: -int sendcomm(const char *, int, const char *, ...); - -First two arguments are the host and port where the command should -be send to, followed by buffer that should be send. On error, -1 -is returned. - - ---- - -Thats it for the moment. - -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 @@ -wl_conf - -#include <wellenreiter/wl_conf.hh> - -int wl_checkcfg(void); -int wl_cfgvalue(const char *token, char *out, int maxlen); - -wl_checkcfg checks whether the wellenreiter configfile exists. -wl_cfgvalue searches for the given token and copies maxlen -characters of its value to out. - -wl_ckeckcfg returns 1 if the file exists and is readable and -0 on error. - -wl_cfgvalue returns -1 on error, 0 if nothing was found and -1 on success. - 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 @@ -wl_log - -#include <wellenreiter/wl_log.hh> - -void wl_loginfo(const char *string, ...) -void wl_logerr(const char *string, ...) - -wl_loginfo() and wl_err() write string to syslog(), -either to INFO or to ERR. - -no return values - 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 @@ -sniff.cc - -#include <wellenreiter/sniff.hh> - -void process_packets(const struct pcap_pkthdr *pkthdr, - const unsigned char *packet, - char *guihost, - int guiport) - -The function process_packets() will use libpcap to get the -informations for a 802.11b packet. When it finds a valid -network it calls the wl_send function and sends a found -network packet to the guiport on the guihost. - - -Return value - -none - -NOTE: process_packets() is void at the moment because there -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 @@ -wl_sock - -#include <wellenreiter/wl_sock.hh> - -int wl_setupsock(const char *host, int port, struct sockaddr_in *) -int wl_send(const char *host, int port, const char *string, ...) -int wl_recv(int *socket, struct sockaddr_in *, char *out, int len) - - -wl_setupsock() returns the number of the activated udp socket. - -wl_send() sends string to the given host. - -wl_recv() checks for incoming data on a socket (created using -wl_setupsock()). It writes the incoming data to out with a -maxlen of len. - - -wl_setupsock() returns -1 on error and the number of socket on -success. -wl_send() returns 0 on error and 1 on success. -wl_recv() returns -1 on error and the type of the received packet -on success. - -Note: To use this function you have to set a sockaddr_in structure -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 @@ -wl_types.hh - -wl_types.hh contains the global buffers and type definitions. - -At the moment these are: - -/* Type definitions, to be continued */ -#define WL_NETFOUND 01 -#define WL_NETLOST 02 -#define WL_STARTSNIFF 98 -#define WL_STOPSNIFF 99 - -#define WL_SOCKBUF 512 /* Buffer for wl_send and wl_recv calls */ - -/* WL network structure */ -typedef struct { - int net_type; /* 1 = Accesspoint ; 2 = Ad-Hoc */ - int ssid_len; /* Length of SSID */ - int channel; /* Channel */ - int wep; /* 1 = WEP enabled ; 0 = disabled */ - char mac[64]; /* MAC address of Accesspoint */ - char bssid[128]; /* BSSID of Net */ -} wl_network_t; - -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 @@ -DESTDIR = $(OPIEDIR)/lib -TEMPLATE = lib -CONFIG = warn_on debug -VERSION = 0.2 -HEADERS = source/cardmode.hh source/wl_log.hh source/wl_proto.hh source/sniff.hh source/wl_sock.hh source/wl_types.hh -SOURCES = source/cardmode.cc source/wl_log.cc source/wl_proto.cc source/sniff.cc source/wl_sock.cc - -LIBS = -lpcap -TMAKE_CFLAGS += -D__UNIX__ -DEFINES += DEBUG -TARGET = wellenreiter - -!contains( platform, x11 ) { - include ( $(OPIEDIR)/include.pro ) -} - 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 @@ -*.o -*~ -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 @@ -# $Id$ - -OBJ = wl_proto.o wl_sock.o wl_log.o wl_conf.o cardmode.o sniff.o -CPP = g++ -CPPFLAGS = -Wall -pedantic -g -DDEBUG - -%.o : %.cc - $(CPP) $(CPPFLAGS) -c $< -o $@ - -static: libwellenreiter.a -libwellenreiter.a: $(OBJ) - ar -cr libwellenreiter.a $(OBJ) - -shared: libwellenreiter.so -libwellenreiter.so: $(OBJ) - $(CPP) $(CPPFLAGS) -shared -o libwellenreiter.so $(OBJ) - -clean: - rm -f *.o *.a *.so *~ - 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 @@ -/* - * Set card modes for sniffing - * - * $Id$ - */ - -#include "cardmode.hh" -#include "wl_log.hh" -pcap_t *handletopcap; -/* main card into monitor function */ -int card_into_monitormode (const char *device, int cardtype) -{ - char CiscoRFMON[35] = "/proc/driver/aironet/"; - FILE *CISCO_CONFIG_FILE; - - /* Checks if we have a device to sniff on */ - if(device == NULL) - { - wl_logerr("No device given"); - return 0; - } - - /* Setting the promiscous and up flag to the interface */ - if (!card_set_promisc_up(device)) - { - wl_logerr("Cannot set interface to promisc mode"); - return 0; - } - wl_loginfo("Interface set to promisc mode"); - - /* Check the cardtype and executes the commands to go into monitor mode */ - if (cardtype == CARD_TYPE_CISCO) - { - /* bring the sniffer into rfmon mode */ - snprintf(CiscoRFMON, sizeof(CiscoRFMON) - 1, DEFAULT_PATH, device); - if((CISCO_CONFIG_FILE = fopen(CiscoRFMON,"w")) == NULL) - { - wl_logerr("Cannot open config file: %s", strerror(errno)); - return 0; - } - fputs ("Mode: r",CISCO_CONFIG_FILE); - fputs ("Mode: y",CISCO_CONFIG_FILE); - fputs ("XmitPower: 1",CISCO_CONFIG_FILE); - fclose(CISCO_CONFIG_FILE); - } - else if (cardtype == CARD_TYPE_NG) - { - char wlanngcmd[80]; - snprintf(wlanngcmd, sizeof(wlanngcmd) - 1, "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=true", device, 1); - if (system(wlanngcmd) != 0) - { - wl_logerr("Could not set %s in raw mode, check cardtype", device); - return 0; - } - } - else if (cardtype == CARD_TYPE_HOSTAP) - { -#if WIRELESS_EXT > 14 - // IW_MODE_MONITOR was implemented in Wireless Extensions Version 15 - int skfd; - skfd = socket(AF_INET, SOCK_STREAM, 0); - struct iwreq wrq; - wrq.u.mode = IW_MODE_MONITOR; - - if(iw_set_ext(skfd,(char *) device,SIOCSIWMODE,&wrq)<0) - { - wl_logerr("Could not set hostap card %s to raw mode, check cardtype", device); - return 0; - } - else - { - wl_loginfo("Successfully set hostap card %s into raw mode",device); - return 1; - } - return 1; -#else - // Wireless Extensions < Version 15 need iwpriv commandos for monitoring - int fd; - //Wireless tools structure for the iocalls - struct iwreq ireq; - int *ptr; - /* Socket needed to use the iocall to */ - fd = socket(AF_INET, SOCK_STREAM, 0); - - if ( fd == -1 ) { - return -1; - } - - ptr = (int *) ireq.u.name; - // This is the monitor mode for 802.11 non-prism header - ptr[0] = 2; - strcpy(ireq.ifr_ifrn.ifrn_name, device); - if (ioctl( fd, SIOCDEVPRIVATE, &ireq)==0) - { - /* All was fine... */ - close(fd); - wl_loginfo("Set hostap card %s into monitormode",device); - return 1; - } - else - { - /* iocall does not work */ - close(fd); - wl_logerr("Could not set hostap card %s into monitormode, check cardtype",device); - return 0; - } -#endif - } - else if (cardtype == CARD_TYPE_ORINOCCO ) - { - if (!card_set_channel (device, 1, CARD_TYPE_ORINOCCO)) - { - wl_logerr("Could not set %s in raw mode, check cardtype", device); - return 0; - } - else - { - wl_loginfo("Successfully set %s into raw mode",device); - } - } - - /* Setting the promiscous and up flag to the interface */ - if (!card_check_rfmon_datalink(device)) - { - wl_logerr("Cannot set interface to rfmon mode"); - return 0; - } - else - { - wl_loginfo("Interface set to rfmon mode"); - } - return 1; -} - -/* Check card is in the rfmon mode */ -int card_check_rfmon_datalink (const char *device) -{ - int datalinktype=0; - pcap_t *phandle; - phandle = pcap_open_live((char *)device, 65,0,0,NULL); - datalinktype = pcap_datalink (phandle); - pcap_close(phandle); - - if (datalinktype != DLT_IEEE802_11) /* Rawmode is IEEE802_11 */ - { - return 0; - } - else - { - wl_loginfo("Your successfully listen on %s in 802.11 raw mode", device); - return 1; - } -} - -/* Ipaq running familiar does not have a loopback device, we need one */ -int check_loopback() -{ - /* Checking for a loopback interface with 127.0.0.1, otherwise the other stuff seems to fail on - familiar linux on ipaq's */ - int err; - /* First generate a socket to use with iocalls */ - int fd = socket(AF_INET, SOCK_DGRAM, 0); - if (fd < 0) - { - /* In case of an error */ - wl_logerr("check_loopback, generation of a socket failed, cannot continue"); - return 0; - } - /* Fill an empty an interface structure with the right flags (UP and Promsic) */ - struct ifreq ifr; - strncpy(ifr.ifr_name, "lo",3); - - /* Get the interface flags, loopback interfaces can be detected that way */ - err = ioctl(fd, SIOCGIFFLAGS, &ifr); - if (err < 0) - { - wl_logerr("check_loopback, could not get the flags of lo, check if you got a lo loopback interface, cannot continue"); - close(fd); - return 0; - } - /* Checking the flags for IFF_LOOPBACK flags */ - if(ifr.ifr_flags && IFF_LOOPBACK) - { - /* Yes, we do have a loopback interface....sup! */ - close(fd); - wl_loginfo ("check_loopback, check for loopback interface lo successful"); - return 1; - } - else - { - wl_logerr("check_loopback, did not found an interface lo with the IFF_LOOPBACK flag set, cannot continue"); - close(fd); - return 0; - } - /* Should never be reached */ - return 0; -} /*check_loopback */ - - -/* Set card into promisc mode */ -int card_set_promisc_up (const char *device) -{ - int err; - /* First generate a socket to use with iocalls */ - int fd = socket(AF_INET, SOCK_DGRAM, 0); - if (fd < 0) - { - /* In case of an error */ - perror("socket"); - return 0; - } - - /* Fill an empty an interface structure with the right flags (UP and Promsic) */ - struct ifreq ifr; - strncpy(ifr.ifr_name, device,10); - ifr.ifr_flags = IFF_UP + IFF_PROMISC; - err = ioctl(fd, SIOCSIFFLAGS, &ifr); - if (err < 0) - { - perror("Could not access the interface, "); - close(fd); - return 0; - } - - /* Get the informations back from the interface to check if the flags are correct */ - strncpy(ifr.ifr_name, device,10); - err = ioctl(fd, SIOCGIFFLAGS, &ifr); - if (err < 0) - { - perror("Could not access the interface, "); - close(fd); - return 0; - } - - if(ifr.ifr_flags && IFF_UP) - { - close(fd); - return 1; - } - else - { - wl_logerr("Could not set promisc flag on %d", device); - close(fd); - return 0; - } -} - -/* Remove card from promisc mode */ -int card_remove_promisc (const char *device) -{ - int err; - /* First generate a socket to use with iocalls */ - int fd = socket(AF_INET, SOCK_DGRAM, 0); - if (fd < 0) - { - /* In case of an error */ - perror("socket"); - return 0; - } - - /* Fill an empty an interface structure with the right flags (UP and Promsic) */ - struct ifreq ifr; - /* Get the flags from the interface*/ - strncpy(ifr.ifr_name, device,10); - err = ioctl(fd, SIOCGIFFLAGS, &ifr); - if (err < 0) - { - perror("Could not access the interface, "); - close(fd); - return 0; - } - /* Remove the IFF_PROMISC flag */ - ifr.ifr_flags = ifr.ifr_flags - IFF_PROMISC; - /*Set the new flags to the interface*/ - err = ioctl(fd, SIOCSIFFLAGS, &ifr); - if (err < 0) - { - perror("Could not access the interface, "); - close(fd); - return 0; - } - - /* Get the flags again to check if IFF_PROMISC is removed */ - err = ioctl(fd, SIOCGIFFLAGS, &ifr); - if (err < 0) - { - perror("Could not access the interface, "); - close(fd); - return 0; - } - if(ifr.ifr_flags && IFF_PROMISC) - { - wl_logerr("Could not remove the promisc flag on %d", device); - close(fd); - return 0; - } - else - { - /* Successfully removed the promisc flags */ - close(fd); - return 1; - } -} - - - - -/* Set channel (Wireless frequency) of the device */ -int card_set_channel (const char *device, int channel, int cardtype) -{ - if (cardtype == CARD_TYPE_CISCO || cardtype == CARD_TYPE_NG) - { - /* Cisco and wlan-ng drivers don't need channelswitching */ - return 1; - } - /* If it is a lucent orinocco card */ - else if (cardtype == CARD_TYPE_ORINOCCO) - { - int fd; - //Wireless tools structure for the iocalls - struct iwreq ireq; - int *ptr; - /* Socket needed to use the iocall to */ - fd = socket(AF_INET, SOCK_STREAM, 0); - - if ( fd == -1 ) { - return -1; - } - - ptr = (int *) ireq.u.name; - // This is the monitor mode for 802.11 non-prism header - ptr[0] = 2; - ptr[1] = channel; - strcpy(ireq.ifr_ifrn.ifrn_name, device); - if (ioctl( fd, SIOCIWFIRSTPRIV + 0x8, &ireq)==0) - { - /* All was fine... */ - close(fd); - wl_loginfo("Set channel %d on interface %s",channel, device); - return 1; - } - else - { - /* iocall does not work */ - close(fd); - wl_logerr("Could not set channel %d on %s, check cardtype",channel, device); - return 0; - } - } - /* when it is an hostap card you need another iocall for channel switching */ - else if (cardtype == CARD_TYPE_HOSTAP) - { - int skfd; - skfd = socket(AF_INET, SOCK_STREAM, 0); - struct iwreq wrq; - iw_float2freq((double) channel, &wrq.u.freq); - - if(iw_set_ext(skfd,(char *) device,SIOCSIWFREQ,&wrq)<0) - { - wl_logerr("Could not set hostap card %s to channel %d", device, channel); - return 0; - } - else - { - wl_loginfo("Successfully set hostap card %s to channel %d", device, channel); - return 1; - } - } - /* For undefined situations */ - return 0; -} - - -int card_detect_channels (char * device) -{ - int skfd; - skfd = socket(AF_INET, SOCK_STREAM, 0); - struct iw_range range; - /* Get list of frequencies / channels */ - printf ("\n hostap card get the frequencies"); - /* Get list of frequencies / channels */ - if(iw_get_range_info(skfd, device, &range) < 0) - { /* We are failsave if something went wrong, asume only 11 channels */ - return 11; - } - else - { - if(range.num_frequency > 0) - { - return range.num_frequency; - } - else - { /* We are failsave asume only 11 channels */ - return 11; - } - } - -} /* End of card_detect_channels */ - -int iw_get_range_info(int skfd, const char * ifname, iw_range * range) -{ - struct iwreq wrq2; - char buffer[sizeof(iw_range) * 2]; /* Large enough */ - - /* Cleanup */ - memset(buffer, 0, sizeof(buffer)); - wrq2.u.data.pointer = (caddr_t) buffer; - wrq2.u.data.length = sizeof(buffer); - wrq2.u.data.flags = 0; - - if(iw_get_ext(skfd, (char *)ifname, SIOCGIWRANGE, &wrq2) < 0) - { - wl_logerr("Could not get the range from the interface"); - return(-1); - } - else - { - /* Copy stuff at the right place, ignore extra */ - memcpy((char *) range, buffer, sizeof(iw_range)); - return 0; - } -} - -/*------------------------------------------------------------------*/ -/* - * Convert our internal representation of frequencies to a floating point. - */ -double iw_freq2float(iw_freq * in) -{ - int i; - double res = (double) in->m; - for(i = 0; i < in->e; i++) - res *= 10; - return(res); -} - - -void iw_float2freq(double in, iw_freq * out) -{ - /* Version without libm : slower */ - out->e = 0; - while(in > 1e9) - { - in /= 10; - out->e++; - } - out->m = (long) in; -} - - - 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 @@ -/* $Id$ */ - -#ifndef CARDMODE_HH -#define CARDMODE_HH - -#include <string.h> -#include <stdlib.h> -#include <errno.h> -#include <sys/types.h> -#include <sys/time.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <sys/ioctl.h> -#include <unistd.h> -#include <linux/if.h> - -/* Following typedefs are needed here, because linux/wireless.h - includes linux/ethertool.h which is using them */ -typedef signed char s8; -typedef unsigned char u8; -typedef signed short s16; -typedef unsigned short u16; -typedef signed int s32; -typedef unsigned int u32; -typedef signed long long s64; -typedef unsigned long long u64; - -#include <linux/wireless.h> - -#ifndef SIOCIWFIRSTPRIV -#define SIOCIWFIRSTPRIV SIOCDEVPRIVATE -#endif - -extern "C" -{ -#include <net/bpf.h> -#include <pcap.h> -} - -extern pcap_t *handletopcap; - -/* Defines, used for the card setup */ -#define DEFAULT_PATH "/proc/driver/aironet/%s/Config" -#define CISCO_STATUS "/proc/driver/aironet/%s/Status" -#define CARD_TYPE_CISCO 1 -#define CARD_TYPE_NG 2 -#define CARD_TYPE_HOSTAP 3 -#define CARD_TYPE_ORINOCCO 4 - -/* Some usefull constants for frequencies */ -#define KILO 1e3 -#define MEGA 1e6 -#define GIGA 1e9 - - -/* only for now, until we have the daemon running */ -/*the config file should provide these information */ -#define CARD_TYPE CARD_TYPE_HOSTAP - -/* Prototypes */ -int card_check_rfmon_datalink (const char *device); -int card_into_monitormode (const char *, int); -int check_loopback(); -int card_set_promisc_up (const char *device); -int card_remove_promisc (const char *device); -int card_set_channel (const char *device, int channel,int cardtype); -int iw_get_range_info(int skfd, const char * ifname, struct iw_range * range); -double iw_freq2float(iw_freq * in); -void iw_float2freq(double in, iw_freq * out); -int card_detect_channels (char * device); - -/*------------------------------------------------------------------*/ -/* - * Wrapper to push some Wireless Parameter in the driver - */ -static inline int -iw_set_ext(int skfd, /* Socket to the kernel */ - char * ifname, /* Device name */ - int request, /* WE ID */ - struct iwreq * pwrq) /* Fixed part of the request */ -{ - /* Set device name */ - strncpy(pwrq->ifr_name, ifname, IFNAMSIZ); - /* Do the request */ - return(ioctl(skfd, request, pwrq)); -} - -/*------------------------------------------------------------------*/ -/* - * Wrapper to extract some Wireless Parameter out of the driver - */ -static inline int -iw_get_ext(int skfd, /* Socket to the kernel */ - char * ifname, /* Device name */ - int request, /* WE ID */ - struct iwreq * pwrq) /* Fixed part of the request */ -{ - /* Set device name */ - strncpy(pwrq->ifr_name, ifname, IFNAMSIZ); - /* Do the request */ - return(ioctl(skfd, request, pwrq)); -} - - - -#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 @@ -/* $Id$ */ -/* - * Copyright (c) 1992, 1993, 1994, 1995, 1996 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that: (1) source code distributions - * retain the above copyright notice and this paragraph in its entirety, (2) - * distributions including binary code include the above copyright notice and - * this paragraph in its entirety in the documentation or other materials - * provided with the distribution, and (3) all advertising materials mentioning - * features or use of this software display the following acknowledgement: - * ``This product includes software developed by the University of California, - * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of - * the University nor the names of its contributors may be used to endorse - * or promote products derived from this software without specific prior - * written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ -/* Network to host order macros */ - -#ifndef EXTRACT_HH -#define EXTRACT_HH - -#ifdef LBL_ALIGN -#define EXTRACT_16BITS(p) \ - ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 0) << 8 | \ - (u_int16_t)*((const u_int8_t *)(p) + 1))) -#define EXTRACT_32BITS(p) \ - ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 24 | \ - (u_int32_t)*((const u_int8_t *)(p) + 1) << 16 | \ - (u_int32_t)*((const u_int8_t *)(p) + 2) << 8 | \ - (u_int32_t)*((const u_int8_t *)(p) + 3))) -#else -#define EXTRACT_16BITS(p) \ - ((u_int16_t)ntohs(*(const u_int16_t *)(p))) -#define EXTRACT_32BITS(p) \ - ((u_int32_t)ntohl(*(const u_int32_t *)(p))) -#endif - -#define EXTRACT_24BITS(p) \ - ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 16 | \ - (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \ - (u_int32_t)*((const u_int8_t *)(p) + 2))) - -/* Little endian protocol host order macros */ -#define EXTRACT_LE_8BITS(p) (*(p)) -#define EXTRACT_LE_16BITS(p) \ - ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 1) << 8 | \ - (u_int16_t)*((const u_int8_t *)(p) + 0))) -#define EXTRACT_LE_32BITS(p) \ - ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 3) << 24 | \ - (u_int32_t)*((const u_int8_t *)(p) + 2) << 16 | \ - (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \ - (u_int32_t)*((const u_int8_t *)(p) + 0))) - -#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 @@ -/* $Id$ */ -/* - * Copyright (c) 2001 - * Fortress Technologies - * Charlie Lenahan ( clenahan@fortresstech.com ) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that: (1) source code distributions - * retain the above copyright notice and this paragraph in its entirety, (2) - * distributions including binary code include the above copyright notice and - * this paragraph in its entirety in the documentation or other materials - * provided with the distribution, and (3) all advertising materials mentioning - * features or use of this software display the following acknowledgement: - * ``This product includes software developed by the University of California, - * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of - * the University nor the names of its contributors may be used to endorse - * or promote products derived from this software without specific prior - * written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - -#ifndef IEEE802_11_HH -#define IEEE802_11_HH - -#define IEEE802_11_FC_LEN 2 - -#define T_MGMT 0x0 /* management */ -#define T_CTRL 0x1 /* control */ -#define T_DATA 0x2 /* data */ -#define T_RESV 0x3 /* reserved */ - -#define ST_ASSOC_REQUEST 0x0 -#define ST_ASSOC_RESPONSE 0x1 -#define ST_REASSOC_REQUEST 0x2 -#define ST_REASSOC_RESPONSE 0x3 -#define ST_PROBE_REQUEST 0x4 -#define ST_PROBE_RESPONSE 0x5 -/* RESERVED 0x6 */ -/* RESERVED 0x7 */ -#define ST_BEACON 0x8 -#define ST_ATIM 0x9 -#define ST_DISASSOC 0xA -#define ST_AUTH 0xB -#define ST_DEAUTH 0xC -/* RESERVED 0xD */ -/* RESERVED 0xE */ -/* RESERVED 0xF */ - - -#define CTRL_PS_POLL 0xA -#define CTRL_RTS 0xB -#define CTRL_CTS 0xC -#define CTRL_ACK 0xD -#define CTRL_CF_END 0xE -#define CTRL_END_ACK 0xF - -/* - * Bits in the frame control field. - */ -#define FC_VERSION(fc) ((fc) & 0x3) -#define FC_TYPE(fc) (((fc) >> 2) & 0x3) -#define FC_SUBTYPE(fc) (((fc) >> 4) & 0xF) -#define FC_TO_DS(fc) ((fc) & 0x0100) -#define FC_FROM_DS(fc) ((fc) & 0x0200) -#define FC_MORE_FLAG(fc) ((fc) & 0x0400) -#define FC_RETRY(fc) ((fc) & 0x0800) -#define FC_POWER_MGMT(fc) ((fc) & 0x1000) -#define FC_MORE_DATA(fc) ((fc) & 0x2000) -#define FC_WEP(fc) ((fc) & 0x4000) -#define FC_ORDER(fc) ((fc) & 0x8000) - -struct mgmt_header_t { - u_int16_t fc; - u_int16_t duration; - u_int8_t da[6]; - u_int8_t sa[6]; - u_int8_t bssid[6]; - u_int16_t seq_ctrl; -}; - -#define MGMT_HEADER_LEN (2+2+6+6+6+2) - -#define CAPABILITY_ESS(cap) ((cap) & 0x0001) -#define CAPABILITY_IBSS(cap) ((cap) & 0x0002) -#define CAPABILITY_CFP(cap) ((cap) & 0x0004) -#define CAPABILITY_CFP_REQ(cap) ((cap) & 0x0008) -#define CAPABILITY_PRIVACY(cap) ((cap) & 0x0010) - -struct ssid_t { - u_int8_t element_id; - u_int8_t length; - u_char ssid[33]; /* 32 + 1 for null */ -} ; - -struct rates_t { - u_int8_t element_id; - u_int8_t length; - u_int8_t rate[8]; -}; - -struct challenge_t { - u_int8_t element_id; - u_int8_t length; - u_int8_t text[254]; /* 1-253 + 1 for null */ -}; -struct fh_t { - u_int8_t element_id; - u_int8_t length; - u_int16_t dwell_time; - u_int8_t hop_set; - u_int8_t hop_pattern; - u_int8_t hop_index; -}; - -struct ds_t { - u_int8_t element_id; - u_int8_t length; - u_int8_t channel; -}; - -struct cf_t { - u_int8_t element_id; - u_int8_t length; - u_int8_t count; - u_int8_t period; - u_int16_t max_duration; - u_int16_t dur_remaing; -}; - -struct tim_t { - u_int8_t element_id; - u_int8_t length; - u_int8_t count; - u_int8_t period; - u_int8_t bitmap_control; - u_int8_t bitmap[251]; -}; - -#define E_SSID 0 -#define E_RATES 1 -#define E_FH 2 -#define E_DS 3 -#define E_CF 4 -#define E_TIM 5 -#define E_IBSS 6 -#define E_CISCO 133 -/* reserved 7 */ -/* reserved 8 */ -/* reserved 9 */ -/* reserved 10 */ -/* reserved 11 */ -/* reserved 12 */ -/* reserved 13 */ -/* reserved 14 */ -/* reserved 15 */ -/* reserved 16 */ - -#define E_CHALLENGE 16 -/* reserved 17 */ -/* reserved 18 */ -/* reserved 19 */ -/* reserved 16 */ -/* reserved 16 */ - - -struct mgmt_body_t { - u_int8_t timestamp[8]; - u_int16_t beacon_interval; - u_int16_t listen_interval; - u_int16_t status_code; - u_int16_t aid; - u_char ap[6]; - u_int16_t reason_code; - u_int16_t auth_alg; - u_int16_t auth_trans_seq_num; - struct challenge_t challenge; - u_int16_t capability_info; - struct ssid_t ssid; - struct rates_t rates; - struct ds_t ds; - struct cf_t cf; - struct fh_t fh; - struct tim_t tim; -}; - -struct ctrl_rts_t { - u_int16_t fc; - u_int16_t duration; - u_int8_t ra[6]; - u_int8_t ta[6]; - u_int8_t fcs[4]; -}; - -#define CTRL_RTS_LEN (2+2+6+6+4) - -struct ctrl_cts_t { - u_int16_t fc; - u_int16_t duration; - u_int8_t ra[6]; - u_int8_t fcs[4]; -}; - -#define CTRL_CTS_LEN (2+2+6+4) - -struct ctrl_ack_t { - u_int16_t fc; - u_int16_t duration; - u_int8_t ra[6]; - u_int8_t fcs[4]; -}; - -#define CTRL_ACK_LEN (2+2+6+4) - -struct ctrl_ps_poll_t { - u_int16_t fc; - u_int16_t aid; - u_int8_t bssid[6]; - u_int8_t ta[6]; - u_int8_t fcs[4]; -}; - -#define CTRL_PS_POLL_LEN (2+2+6+6+4) - -struct ctrl_end_t { - u_int16_t fc; - u_int16_t duration; - u_int8_t ra[6]; - u_int8_t bssid[6]; - u_int8_t fcs[4]; -}; - -#define CTRL_END_LEN (2+2+6+6+4) - -struct ctrl_end_ack_t { - u_int16_t fc; - u_int16_t duration; - u_int8_t ra[6]; - u_int8_t bssid[6]; - u_int8_t fcs[4]; -}; - -#define CTRL_END_ACK_LEN (2+2+6+6+4) - -#define IV_IV(iv) ((iv) & 0xFFFFFF) -#define IV_PAD(iv) (((iv) >> 24) & 0x3F) -#define IV_KEYID(iv) (((iv) >> 30) & 0x03) - -#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 @@ -/* - * rfmon mode sniffer - * - * $Id$ - */ - -#include "sniff.hh" -#include "ieee802_11.hh" -#include "extract.hh" -#include "wl_log.hh" -#include "wl_types.hh" -#include "wl_proto.hh" -#include "cardmode.hh" - -int start_sniffer(const char *device, int cardtype ) -{ - - /* This function initialize the sniffing - 1. Check for lo interface - 2. bring it into promsicous mode and UP - 3. bring device into rfmon mode - start the pcap sniffing process. - */ - - /* Do we have the device name ? */ - if(device == NULL) - { - wl_logerr("start_sniffer, parameter \"device\" is empty, please check your config"); - return 0; - } - - /* Some Linux System does not have a loopback device lo with 127.0.0.1 so sockets could - not made correctly, let the proggie check that and proceed only if it exists. */ - if (!check_loopback()) - { - wl_logerr("start_sniffer, check_loopback failed, cannot continue without a loopback"); - return 0; - } - - /* Set the card into regulary promiscous mode first and set the UP flag, in case no ip - was given. It would work without the promisc flags but i dont like this */ - if (!card_set_promisc_up(device)) - { - wl_logerr("start_sniffer, card_set_promisc_up failed, cannot continue"); - return 0; - } - - /* Set card into the rfmon/monitoring mode */ - if (!card_into_monitormode(device,cardtype)) - { - wl_logerr("start_sniffer, cannot put wireless card into monitoring mode, aborting"); - return 0; - } - - /* setup pcap handle, used for the packet decoding etc. */ - if((handletopcap = pcap_open_live((char *) device, BUFSIZ, 1, 0, NULL)) == NULL) - { - wl_logerr("pcap_open_live() failed: %s", strerror(errno)); - return 0; - } - -#ifdef HAVE_PCAP_NONBLOCK - pcap_setnonblock(handletopcap, 1, NULL); -#endif - return 1; -} - - -int stop_sniffer(const char *device, int cardtype) -{ - /* This function terminates the sniffing - 1. get the device state - 2. remove the rfmon state - 3. Remove the promisc state - start the pcap sniffing process. - - */ - - /* Do we really have at least a lo interface with the 127.0.0.1 ? */ - return 0; - -} - - -/* Main function, checks packets */ -void process_packets(const struct pcap_pkthdr *pkthdr, - const unsigned char *packet, - char *guihost, - int guiport) -{ - unsigned int caplen = pkthdr->caplen; - unsigned int length = pkthdr->len; - u_int16_t fc; - unsigned int HEADER_LENGTH; - - /* pinfo holds all interresting information for us */ - struct packetinfo pinfo; - struct packetinfo *pinfoptr; - - /* wl_network_t will finally be set and send to the ui */ - wl_network_t wl_net; - - pinfoptr=&pinfo; - - pinfoptr->isvalid = 0; - pinfoptr->pktlen = pkthdr->len; - - if (caplen < IEEE802_11_FC_LEN) - { - /* This is a garbage packet, because is does not long enough - to hold a 802.11b header */ - pinfoptr->isvalid = 0; - return; - } - - /* Gets the framecontrol bits (2bytes long) */ - fc = EXTRACT_LE_16BITS(packet); - - HEADER_LENGTH = GetHeaderLength(fc); - - if (caplen < HEADER_LENGTH) - { - /* This is a garbage packet, because it is not long enough - to hold a correct header of its type */ - pinfoptr->isvalid = 0; - return; - } - - /* Decode 802.11b header out of the packet */ - if (decode_80211b_hdr(packet,pinfoptr) == 0) - { - /* Justification of the ofset to further process the packet */ - length -= HEADER_LENGTH; - caplen -= HEADER_LENGTH; - packet += HEADER_LENGTH; - } - else /* Something is wrong,could not be a correct packet */ - return; - - switch (FC_TYPE(fc)) - { - /* Is it a managemnet frame? */ - case T_MGMT: - switch (FC_SUBTYPE(fc)) - { - case ST_BEACON: - if (handle_beacon(fc, packet,pinfoptr) ==0) - { - if (!strcmp(pinfoptr->desthwaddr,"ff:ff:ff:ff:ff:ff") == 0) - { - /* Every beacon must have the broadcast as destination - so it must be a shitti packet */ - pinfoptr->isvalid = 0; - return; - } - - if (pinfoptr->cap_ESS == pinfoptr->cap_IBSS) - { - /* Only one of both are possible, so must be - a noise packet, if this comes up */ - pinfoptr->isvalid = 0; - return; - } - if (pinfoptr->channel < 1 || pinfoptr->channel > 14) - { - /* Only channels between 1 and 14 are possible - others must be noise packets */ - pinfoptr->isvalid = 0; - return; - } - - /* Here should be the infos to the gui issued */ - if (pinfoptr->cap_ESS == 1 && pinfoptr->cap_IBSS ==0) - { - wl_loginfo("Found an access point"); - wl_net.net_type=1; - } - else if(pinfoptr->cap_ESS == 0 && pinfoptr->cap_IBSS == 2) - { - wl_loginfo("Found an ad-hoc network"); - wl_net.net_type=2; - } - - if (strcmp (pinfoptr->ssid,NONBROADCASTING) ==0) - wl_loginfo("Net is a non-broadcasting network"); - else - wl_loginfo("SSID is: %s", pinfoptr->ssid); - - wl_loginfo("SSID is: %s", pinfoptr->ssid); - memset(wl_net.bssid, 0, sizeof(wl_net.bssid)); - memcpy(wl_net.bssid, pinfoptr->ssid, sizeof(wl_net.bssid)-1); - - wl_loginfo("SSID length is: %d", pinfoptr->ssid_len); - wl_net.ssid_len=pinfoptr->ssid_len; - - wl_loginfo("Channel is: %d", pinfoptr->channel); - wl_net.channel=pinfoptr->channel; - wl_net.wep=pinfoptr->cap_WEP; - - wl_loginfo("Mac is: %s", pinfoptr->sndhwaddr); - memset(wl_net.mac, 0, sizeof(wl_net.mac)); - memcpy(wl_net.mac, pinfoptr->sndhwaddr, sizeof(wl_net.mac)-1); - - if(!send_network_found((char *)guihost, guiport, &wl_net)) - { - wl_logerr("Error sending data to UI: %s", strerror(errno)); - break; - } - wl_loginfo("Sent network to GUI '%s:%d'", guihost, guiport); - } - break; - - default: - wl_logerr("Unknown IEEE802.11 frame subtype (%d)", FC_SUBTYPE(fc)); - break; - } /* End of switch over different mgt frame types */ - - break; - - case T_CTRL: - wl_loginfo("Received control frame, not implemented yet"); - break; - - case T_DATA: - wl_loginfo("Received date frame, not implemented yet"); - break; - - default: - wl_logerr("Unknown IEEE802.11 frame type (%d)", FC_TYPE(fc)); - break; - } -} - -/* This decodes the 802.11b frame header out of the 802.11b packet - all the infos is placed into the packetinfo structure */ -int decode_80211b_hdr(const u_char *p,struct packetinfo *ppinfo) -{ - const struct mgmt_header_t *mgthdr = (const struct mgmt_header_t *) p; - ppinfo->fcsubtype = FC_SUBTYPE(mgthdr->fc); - - /* Get the sender, bssid and dest mac address */ - etheraddr_string(mgthdr->bssid,ppinfo->bssid); - etheraddr_string(mgthdr->da,ppinfo->desthwaddr); - etheraddr_string(mgthdr->sa,ppinfo->sndhwaddr); - ppinfo->fc_wep = FC_WEP(mgthdr->fc); - return 0; -} - - -void etheraddr_string(register const u_char *ep, char *text) -{ - static char hex[] = "0123456789abcdef"; - register unsigned int i, j; - register char *cp; - char buf[sizeof("00:00:00:00:00:00\0")]; - cp = buf; - if ((j = *ep >> 4) != 0) - { - *cp++ = hex[j]; - } - else - { - *cp++ = '0'; - } - *cp++ = hex[*ep++ & 0xf]; - - for (i = 5; (int)--i >= 0;) - { - *cp++ = ':'; - if ((j = *ep >> 4) != 0) - { - *cp++ = hex[j]; - } - else - { - *cp++ = '0'; - } - - *cp++ = hex[*ep++ & 0xf]; - } - *cp = '\0'; - strcpy(text,buf); -} - -/* beacon handler */ -int handle_beacon(u_int16_t fc, const u_char *p,struct packetinfo *ppinfo) -{ - struct mgmt_body_t pbody; - int offset = 0; - - /* Get the static informations out of the packet */ - memset(&pbody, 0, sizeof(pbody)); - memcpy(&pbody.timestamp, p, 8); - offset += 8; - pbody.beacon_interval = EXTRACT_LE_16BITS(p+offset); - offset += 2; - pbody.capability_info = EXTRACT_LE_16BITS(p+offset); - offset += 2; - - /* Gets the different flags out of the capabilities */ - ppinfo->cap_ESS = CAPABILITY_ESS(pbody.capability_info); - ppinfo->cap_IBSS = CAPABILITY_IBSS(pbody.capability_info); - ppinfo->cap_WEP = CAPABILITY_PRIVACY(pbody.capability_info); - - /* Gets the tagged elements out of the packets */ - while (offset + 1 < ppinfo->pktlen) - { - switch (*(p + offset)) - { - case E_SSID: - memcpy(&(pbody.ssid),p+offset,2); offset += 2; - if (pbody.ssid.length > 0) - { - memcpy(&(pbody.ssid.ssid),p+offset,pbody.ssid.length); - offset += pbody.ssid.length; - pbody.ssid.ssid[pbody.ssid.length]='\0'; - if (strcmp((char *)pbody.ssid.ssid,"")==0) - memcpy(ppinfo->ssid, NONBROADCASTING, sizeof(ppinfo->ssid)); - else - memcpy(ppinfo->ssid, pbody.ssid.ssid, sizeof(ppinfo->ssid)); - ppinfo->ssid_len = pbody.ssid.length; - } - break; - - case E_CHALLENGE: - memcpy(&(pbody.challenge),p+offset,2); offset += 2; - if (pbody.challenge.length > 0) - { - memcpy(&(pbody.challenge.text),p+offset,pbody.challenge.length); - offset += pbody.challenge.length; - pbody.challenge.text[pbody.challenge.length]='\0'; - } - break; - case E_RATES: - memcpy(&(pbody.rates),p+offset,2); offset += 2; - if (pbody.rates.length > 0) - { - memcpy(&(pbody.rates.rate),p+offset,pbody.rates.length); - offset += pbody.rates.length; - } - break; - case E_DS: - memcpy(&(pbody.ds),p+offset,3); - offset +=3; - ppinfo->channel = pbody.ds.channel; - break; - case E_CF: - memcpy(&(pbody.cf),p+offset,8); - offset +=8; - break; - case E_TIM: - memcpy(&(pbody.tim),p+offset,2); - offset +=2; - memcpy(&(pbody.tim.count),p+offset,3); - offset +=3; - if ((pbody.tim.length -3) > 0) - { - memcpy((pbody.tim.bitmap),p+(pbody.tim.length -3),(pbody.tim.length -3)); - offset += pbody.tim.length -3; - } - break; - default: - - offset+= *(p+offset+1) + 2; - break; - } /* end of switch*/ - } /* end of for loop */ - return 0; - -} /* End of handle_beacon */ - - -int GetHeaderLength(u_int16_t fc) -{ - int iLength=0; - - switch (FC_TYPE(fc)) - { - case T_MGMT: - iLength = MGMT_HEADER_LEN; - break; - case T_CTRL: - switch (FC_SUBTYPE(fc)) - { - case CTRL_PS_POLL: - iLength = CTRL_PS_POLL_LEN; - break; - case CTRL_RTS: - iLength = CTRL_RTS_LEN; - break; - case CTRL_CTS: - iLength = CTRL_CTS_LEN; - break; - case CTRL_ACK: - iLength = CTRL_ACK_LEN; - break; - case CTRL_CF_END: - iLength = CTRL_END_LEN; - break; - case CTRL_END_ACK: - iLength = CTRL_END_ACK_LEN; - break; - default: - iLength = 0; - break; - } - break; - case T_DATA: - if (FC_TO_DS(fc) && FC_FROM_DS(fc)) - iLength = 30; - else - iLength = 24; - break; - default: - wl_logerr("unknown IEEE802.11 frame type (%d)", FC_TYPE(fc)); - break; - } - return iLength; -} 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 @@ -/* $Id$ */ - -#ifndef SNIFF_HH -#define SNIFF_HH - -#include <string.h> -#include <stdio.h> -#include <stdlib.h> -#include <errno.h> -#include <sys/types.h> -#include <sys/time.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> - -extern "C" -{ -#include <net/bpf.h> -#include <pcap.h> -} - -#define NONBROADCASTING "non-broadcasting" - -/* holds all the interresting data */ -struct packetinfo -{ - int isvalid; - int pktlen; - int fctype; - int fcsubtype; - int fc_wep; - int cap_WEP; - int cap_IBSS; - int cap_ESS; - int channel; - char bssid[sizeof("00:00:00:00:00:00") + 1]; - char desthwaddr[sizeof("00:00:00:00:00:00") + 1]; - char sndhwaddr[sizeof("00:00:00:00:00:00") + 1]; - char ssid[128]; - int ssid_len; -}; - -/* Function definitions */ -/* Used for stoping and starting the sniffer process */ -int start_sniffer(const char *device, int cardtype); -int stop_sniffer(const char *device, int cardtype); -void process_packets(const struct pcap_pkthdr* pkthdr,const u_char* packet, char *, int); -int decode_80211b_hdr(const u_char *p,struct packetinfo *ppinfo); -void etheraddr_string(register const u_char *ep,char * text); -int handle_beacon(u_int16_t fc, const u_char *p,struct packetinfo *ppinfo); -int GetHeaderLength(u_int16_t fc); - -/* - * True if "l" bytes of "var" were captured. - * - * The "snapend - (l) <= snapend" checks to make sure "l" isn't so large - * that "snapend - (l)" underflows. - * - * The check is for <= rather than < because "l" might be 0. - */ -#define TTEST2(var, l) (snapend - (l) <= snapend && \ - (const u_char *)&(var) <= snapend - (l)) - -/* True if "var" was captured */ -#define TTEST(var) TTEST2(var, sizeof(var)) - -/* Bail if "l" bytes of "var" were not captured */ -#define TCHECK2(var, l) if (!TTEST2(var, l)) goto trunc - -/* Bail if "var" was not captured */ -#define TCHECK(var) TCHECK2(var, sizeof(var)) - -#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 @@ -/* - * Configfile operations for wellenreiter - * - * $Id$ - */ - -#include "wl_conf.hh" -#include "wl_log.hh" -#include "wl_types.hh" - -/* Check whether configfile exists and is readable */ -int wl_checkcfg(void) -{ - FILE *wl_config; - - if((wl_config = fopen(WL_CONFFILE, "r")) == NULL) - { - wl_logerr("Cannot open configfile: %s", strerror(errno)); - return 0; - } - else - { - fclose(wl_config); - return 1; - } - -} - -/* Get value for given token from config file */ -int wl_cfgvalue(const char *token, char *out, int maxlen) -{ - FILE *wl_config; - char *ptr, *ptr2; - char confbuf[WL_CONFBUFF]; - - if(token == NULL) - return -1; - - if((wl_config = fopen(WL_CONFFILE, "r")) == NULL) - { - wl_logerr("Cannot open configfile: %s", strerror(errno)); - return -1; - } - - /* Clear buffers */ - memset(out, 0, maxlen); - memset(confbuf, 0, sizeof(confbuf)); - - while((fgets(confbuf, sizeof(confbuf) - 1, wl_config)) != NULL) - { - - /* Ignore comments */ - if(confbuf[0] == '#') continue; - - /* Search for token, if found check whether next character - * is a '=' or a ' ' - */ - if(strstr(confbuf, token) != NULL && - (confbuf[strlen(token)] == '=' || confbuf[strlen(token)] == ' ')) - { - - /* Get value between quotes */ - if((ptr = strstr(confbuf, "\"")) == NULL) - break; - ++ptr; - if((ptr2 = strstr(ptr, "\"")) == NULL) - break; - ptr2[0] = '\0'; - - memcpy(out, ptr, maxlen - 1); - break; - - } - memset(confbuf, 0, sizeof(confbuf)); - } - - fclose(wl_config); - - return (out[0] == '\0' ? 0 : 1); -} - 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 @@ -/* $Id$ */ - -#ifndef WLCONF_HH -#define WLCONF_HH - -#include <string.h> -#include <errno.h> - -int wl_checkcfg(void); -int wl_cfgvalue(const char *, char *, int); - -#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 @@ -/* - * Small functions to log to syslog - * - * $Id$ - */ - -#include "wl_log.hh" - -/* Log to syslog INFO */ -void wl_loginfo(const char *fmt,...) -{ - - char buffer[4096]; - va_list ap; - - memset(buffer, 0, sizeof(buffer)); - va_start(ap, fmt); - vsnprintf(buffer, sizeof(buffer)-1, fmt, ap); - va_end(ap); - - openlog("libwellenreiter", LOG_PID, LOG_SYSLOG); - syslog(LOG_INFO, "(info) %s", buffer); - closelog(); - -#ifdef DEBUG - fprintf(stderr, "(info) %s\n", buffer); -#endif - -} - -/* Log to syslog ERR */ -void wl_logerr(const char *fmt,...) -{ - - char buffer[4096]; - va_list ap; - - memset(buffer, 0, sizeof(buffer)); - va_start(ap, fmt); - vsnprintf(buffer, sizeof(buffer)-1, fmt, ap); - va_end(ap); - - openlog("libwellenreiter", LOG_PID, LOG_SYSLOG); - syslog(LOG_INFO, "(err) %s", buffer); - closelog(); - -#ifdef DEBUG - fprintf(stderr, "(err) %s\n", buffer); -#endif - -} 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 @@ -/* $Id$ */ - -#ifndef WLLOG_HH -#define WLLOG_HH - -#include <stdio.h> -#include <syslog.h> -#include <stdarg.h> -#include <string.h> - -void wl_loginfo(const char *, ...); -void wl_logerr(const char *, ...); - -#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 @@ -/* - * Communication protocol - * - * $Id$ - */ - -#include "wl_types.hh" -#include "wl_proto.hh" -#include "wl_log.hh" -#include "wl_sock.hh" - -/* Adds a field to the buffer */ -unsigned int add_field(char *buffer, const char *string, int len) -{ - char newlen[5]; - - /* 3 Byte = Length */ - memset(newlen, 0, sizeof(newlen)); - snprintf(newlen, sizeof(newlen) - 1, "%.3d", len); - memcpy(buffer, newlen, 3); - - /* Length bytes = Value */ - memcpy(buffer + 3, string, atoi(newlen)); - - /* Return length of attached field */ - return (atoi(newlen) + 3); -} - -unsigned int get_field(const char *buffer, char *out, int maxlen) -{ - char len[5]; - - /* Get length of value */ - memset(len, 0, sizeof(len)); - memcpy(len, buffer, 3); - - /* Copy buffer to out pointer */ - memset(out, 0, maxlen); - if(atoi(len) > maxlen -1) - memcpy(out, buffer + 3, maxlen - 1); - else - memcpy(out, buffer + 3, atoi(len)); - - /* Return length of whole field (including 3 byte length) */ - return (atoi(len) + 3); -} - -/* Send ok message */ -int send_ok(const char *guihost, int guiport, int code) -{ - unsigned int len = 0; - char buffer[128], temp[5]; - - memset(buffer, 0, sizeof(buffer)); - - memset(temp, 0, sizeof(temp)); - snprintf(temp, sizeof(temp) - 1, "%.2d", CMD_OK); - memcpy(buffer, temp, 2); - len += 2; - - memset(temp, 0, sizeof(temp)); - snprintf(temp, sizeof(temp) - 1, "%.2d", code); - len += add_field(buffer + len, temp, 2); - - /* Send prepared buffer to UI */ -#ifdef DEBUG - wl_loginfo("Sent ok to UI: '%s'", buffer); -#endif - - return ((!wl_send(guihost, guiport, buffer)) ? 0 : 1); -} - -/* Send fail message */ -int send_fail(const char *guihost, int guiport, - int code, const char *errstr) -{ - unsigned int len = 0; - char buffer[128], temp[5]; - - memset(buffer, 0, sizeof(buffer)); - - memset(temp, 0, sizeof(temp)); - snprintf(temp, sizeof(temp) - 1, "%.2d", CMD_FAIL); - memcpy(buffer, temp, 2); - len += 2; - - memset(temp, 0, sizeof(temp)); - snprintf(temp, sizeof(temp) - 1, "%.2d", code); - len += add_field(buffer + len, temp, 2); - - len += add_field(buffer + len, errstr, strlen(errstr)); - - /* Send prepared buffer to UI */ -#ifdef DEBUG - wl_loginfo("Send CMD_FAIL to UI: '%s'", buffer); -#endif - - return ((!wl_send(guihost, guiport, buffer)) ? 0 : 1); -} - -int get_ok(const char *buffer) -{ - char temp[5]; - unsigned int len = 0; - - /* packet type already determined, skip check */ - len += 2; - - /* what is ok for? */ - memset(temp, 0, sizeof(temp)); - len += get_field(buffer + len, temp, sizeof(temp)); - - return atoi(temp); -} - -/* put failmessage into buffer */ -int get_fail(char *out, const char *buffer, size_t bufflen) -{ - char temp[5]; - int error=0; - unsigned int len = 0; - - /* packet type already determined, skip check */ - len += 2; - - /* what is fail for? */ - memset(temp, 0, sizeof(temp)); - len += get_field(buffer + len, temp, sizeof(temp)); - error=atoi(temp); - - /* get errorstring and fill into buffer */ - memset(out, 0, bufflen); - len += get_field(buffer + len, out, bufflen - 1); - - return error; -} - - -/* Send found network to UI */ -int send_network_found (const char *guihost, int guiport, void *structure) -{ - wl_network_t *ptr; - char buffer[2048], temp[5]; - unsigned int len = 0; - - ptr = (wl_network_t *)structure; - - memset(buffer,0,sizeof(buffer)); - /* Type = Found new net (without length field) */ - memset(temp, 0, sizeof(temp)); - snprintf(temp, sizeof(temp) - 1, "%.2d", WL_NETFOUND); - memcpy(buffer, temp, 2); - len += 2; - - /* Set Net-type */ - memset(temp, 0, sizeof(temp)); - snprintf(temp, sizeof(temp) - 1, "%d", ptr->net_type); - len += add_field(buffer + len, temp, 1); - - /* Set channel */ - memset(temp, 0, sizeof(temp)); - snprintf(temp, sizeof(temp) - 1, "%.2d", ptr->channel); - len += add_field(buffer + len, temp, 2); - - /* Set WEP y/n */ - memset(temp, 0, sizeof(temp)); - snprintf(temp, sizeof(temp) - 1, "%d", ptr->wep); - len += add_field(buffer + len, temp, 1); - - /* Set Mac */ - len += add_field(buffer + len, ptr->mac, 17); - - /* Set ssid */ - if(len + ptr->ssid_len < sizeof(buffer) - 1) - len += add_field(buffer + len, ptr->bssid, ptr->ssid_len); - else - len += add_field(buffer + len, ptr->bssid, sizeof(buffer) - len - 1); - - /* Send prepared buffer to UI */ -#ifdef DEBUG - wl_loginfo("Sending network to UI: '%s'", buffer); -#endif - - return ((!wl_send(guihost, guiport, buffer)) ? 0 : 1); -} - -/* Fill buffer into structur */ -int get_network_found (void *structure, const char *buffer) -{ - wl_network_t *ptr; - char temp[5]; - unsigned int len = 0; - - ptr = (wl_network_t *)structure; - - /* packet type already determined, skip check */ - len += 2; - - /* Get net type (accesspoint || ad-hoc || ...) */ - memset(temp, 0, sizeof(temp)); - len += get_field(buffer + len, temp, sizeof(temp)); - ptr->net_type = atoi(temp); - - /* Get channel */ - memset(temp, 0, sizeof(temp)); - len += get_field(buffer + len, temp, sizeof(temp)); - ptr->channel = atoi(temp); - - /* Set WEP y/n */ - memset(temp, 0, sizeof(temp)); - len += get_field(buffer + len, temp, sizeof(temp)); - ptr->wep = atoi(temp); - - /* Set MAC address */ - len += get_field(buffer + len, ptr->mac, sizeof(ptr->mac)); - - /* Set BSSID */ - len += get_field(buffer + len, ptr->bssid, sizeof(ptr->bssid)); - - return 1; -} 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 @@ -/* $Id$ */ - -#ifndef WLPROTO_HH -#define WLPROTO_HH - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> - -/* Type definitions, to be continued */ -#define NETFOUND 01 -#define NETLOST 02 -#define CMD_FAIL 50 -#define CMD_OK 51 -#define STARTSNIFF 98 -#define STOPSNIFF 99 - -unsigned int add_field(char *, const char *, int); -unsigned int get_field(const char *, char *, int); -int send_ok(const char *, int, int); -int get_ok(const char *); -int send_fail(const char *, int, int, const char *); -int get_fail(char *, const char *, size_t); -int send_network_found (const char *, int, void *); -int get_network_found (void *, const char *); - -#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 @@ -/* - * Socket operations for wellenreiter - * - * $Id$ - */ - -#include "wl_sock.hh" -#include "wl_log.hh" - -/* Setup UDP Socket for incoming commands */ -int wl_setupsock(const char *host, int port, struct sockaddr_in saddr) -{ - int sock; - - if((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) - { - wl_logerr("Cannot set up socket: %s", strerror(errno)); - return -1; - } - - memset(&saddr, 0, sizeof(saddr)); - saddr.sin_family = PF_INET; - saddr.sin_port = htons(port); - saddr.sin_addr.s_addr = inet_addr(host); - - if(bind(sock,(struct sockaddr *)&saddr, sizeof(saddr)) < 0) - { - wl_logerr("Cannot bind socket: %s", strerror(errno)); - close(sock); - return -1; - } - - return sock; -} - -/* Send a string to commsock */ -int wl_send(const char *host, int port, const char *string, ...) -{ - int sock; - char buffer[4096]; - struct sockaddr_in saddr; - va_list ap; - - /* Generate string */ - memset(buffer, 0, sizeof(buffer)); - va_start(ap, string); - vsnprintf(buffer, sizeof(buffer)-1, string, ap); - va_end(ap); - - saddr.sin_family = AF_INET; - saddr.sin_port = htons(port); - saddr.sin_addr.s_addr = inet_addr(host); - - /* Setup socket */ - if((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) - { - wl_logerr("Cannot set up socket: %s", strerror(errno)); - return 0; - } - - if(sendto(sock, buffer, sizeof(buffer), 0, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) - { - wl_logerr("Cannot write to socket: %s", strerror(errno)); - close(sock); - return 0; - } - - if(close(sock) < 0) - wl_logerr("Cannot close socket: %s", strerror(errno)); - - return 1; -} - -/* Check for new messages on commsock */ -int wl_recv(int *sock, struct sockaddr_in cliaddr, char *out, int maxlen) -{ - socklen_t len = sizeof(struct sockaddr); - char retval[3]; - - memset(out, 0, maxlen); - if(recvfrom(*sock, out, maxlen - 1, 0, (struct sockaddr *)&cliaddr, &len) < 0) - { - wl_logerr("Cannot receive from socket: %s", strerror(errno)); - return -1; - } - - /* Get packet type and return it */ - memset(retval, 0, sizeof(retval)); - memcpy(retval, out, 2); - - return atoi(retval); -} 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 @@ -/* $Id */ - -#ifndef WLSOCK_HH -#define WLSOCK_HH - -#include <stdarg.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <signal.h> -#include <string.h> -#include <unistd.h> -#include <stdlib.h> -#include <errno.h> - -int wl_setupsock(const char *, int, struct sockaddr_in); -int wl_send(const char *, int, const char *, ...); -int wl_recv(int *, struct sockaddr_in, char *, int); - -#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 @@ -/* - * Global bufffer size and type definitions - * - * $Id$ - * - */ - -#ifndef WL_TYPES_HH -#define WL_TYPES_HH - -/* Type definitions, to be continued */ -#define WL_NETFOUND 01 -#define WL_NETLOST 02 -#define WL_STARTSNIFF 98 -#define WL_STOPSNIFF 99 - -/* Socket specific */ -#define WL_SOCKBUF 512 /* Buffer for wl_send and wl_recv calls */ - -/* Channelswitching */ -typedef struct { - int type; /* Type of card (chip) */ - char iface[6]; /* Interface of card */ -} wl_cardtype_t; - - -/* WL network structure */ -typedef struct { - int net_type; /* 1 = Accesspoint ; 2 = Ad-Hoc */ - int ssid_len; /* Length of SSID */ - int channel; /* Channel */ - int wep; /* 1 = WEP enabled ; 0 = disabled */ - char mac[64]; /* MAC address of Accesspoint */ - char bssid[128]; /* BSSID of Net */ -} wl_network_t; - -/* Config specific */ -#define WL_CONFFILE "sample.conf" -#define WL_CONFBUFF 128 - - -#endif /* WL_TYPES_HH */ - 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,9 +1,9 @@ -Files: bin/wellenreiter bin/wellenreiterd share/wellenreiter pics/wellenreiter apps/Applications/wellenreiter.desktop $OPIEDIR/lib/libwellenreiter.* $OPIEDIR/lib/libcornucopia.* +Files: bin/wellenreiter share/wellenreiter pics/wellenreiter apps/Applications/wellenreiter.desktop Priority: optional Section: opie/applications Maintainer: Michael 'Mickey' Lauer <mickeyl@handhelds.org> Architecture: arm Version: $QPE_VERSION-$SUB_VERSION -Depends: opie-base, libpcap0 +Depends: opie-base, libpcap0, libopie2 (1.8.1) Description: A WaveLAN Network Monitor A WaveLAN Network Monitor/Sniffer for the Opie Environment. 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,5 +1,5 @@ TEMPLATE = subdirs -unix:SUBDIRS = cornucopia libwellenreiter daemon gui +unix:SUBDIRS = gui !contains( platform, x11 ) { |