-rw-r--r-- | libopie2/opienet/onetwork.cpp | 45 | ||||
-rw-r--r-- | libopie2/opienet/opienet.pro | 6 | ||||
-rw-r--r-- | libopie2/opienet/ostation.cpp | 49 | ||||
-rw-r--r-- | libopie2/opienet/ostation.h | 67 |
4 files changed, 164 insertions, 3 deletions
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp index 918ba07..a85a510 100644 --- a/libopie2/opienet/onetwork.cpp +++ b/libopie2/opienet/onetwork.cpp @@ -13,48 +13,49 @@ .="- .-=="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. */ /* OPIE */ #include <opie2/onetwork.h> +#include <opie2/ostation.h> /* QT */ #include <qfile.h> #include <qtextstream.h> /* UNIX */ #include <assert.h> #include <arpa/inet.h> #include <cerrno> #include <cstring> #include <cstdlib> #include <math.h> #include <sys/ioctl.h> #include <sys/socket.h> #include <sys/types.h> #include <unistd.h> #include <linux/sockios.h> #include <net/if_arp.h> #include <stdarg.h> using namespace std; @@ -860,53 +861,95 @@ int OWirelessNetworkInterface::scanNetwork() { results = true; continue; } else if ( errno == EAGAIN) { qDebug( "ONetworkInterface::scanNetwork() - scan in progress..." ); #if 0 if ( qApp ) { qApp->processEvents( 100 ); continue; } #endif tv.tv_sec = 0; tv.tv_usec = 100000; continue; } } qDebug( "ONetworkInterface::scanNetwork() - scan finished." ); if ( results ) { + qDebug( " - result length = %d", _iwr.u.data.length ); + if ( !_iwr.u.data.length ) + { + qDebug( " - no results (empty neighbourhood)" ); + return 0; + } + qDebug( " - results are in!" ); + dumpBytes( (const unsigned char*) &buffer[0], _iwr.u.data.length ); + + int stations = 0; + + // parse results + + int offset = 0; + struct iw_event* we = (struct iw_event*) &buffer[0]; + + while ( offset < _iwr.u.data.length ) + { + //const char* cmd = *(*_ioctlmap)[we->cmd]; + //if ( !cmd ) cmd = "<unknown>"; + qDebug( "reading next event... cmd=%d, len=%d", we->cmd, we->len ); + switch (we->cmd) + { + case SIOCGIWAP: qDebug( "SIOCGIWAP" ); stations++; break; + case SIOCGIWMODE: qDebug( "SIOCGIWMODE" ); break; + case SIOCGIWFREQ: qDebug( "SIOCGIWFREQ" ); break; + case SIOCGIWESSID: qDebug( "SIOCGIWESSID" ); break; + case SIOCGIWSENS: qDebug( "SIOCGIWSENS" ); break; + case SIOCGIWENCODE: qDebug( "SIOCGIWENCODE" ); break; + case IWEVTXDROP: qDebug( "IWEVTXDROP" ); break; /* Packet dropped to excessive retry */ + case IWEVQUAL: qDebug( "IWEVQUAL" ); break; /* Quality part of statistics (scan) */ + case IWEVCUSTOM: qDebug( "IWEVCUSTOM" ); break; /* Driver specific ascii string */ + case IWEVREGISTERED: qDebug( "IWEVREGISTERED" ); break; /* Discovered a new node (AP mode) */ + case IWEVEXPIRED: qDebug( "IWEVEXPIRED" ); break; /* Expired a node (AP mode) */ + default: qDebug( "unhandled event" ); + } + + offset += we->len; + we = (struct iw_event*) &buffer[offset]; + } + } else { - qDebug( " - no results :(" ); + qDebug( " - no results (timeout) :(" ); + return 0; } } bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const { #ifndef NODEBUG int result = ::ioctl( _sfd, call, &iwreq ); if ( result == -1 ) qDebug( "ONetworkInterface::wioctl (%s) call %s (0x%04X) - Status: Failed: %d (%s)", name(), (const char*) *(*_ioctlmap)[call], call, result, strerror( errno ) ); else qDebug( "ONetworkInterface::wioctl (%s) call %s (0x%04X) - Status: Ok.", name(), (const char*) *(*_ioctlmap)[call], call ); return ( result != -1 ); #else return ::ioctl( _sfd, call, &iwreq ) != -1; #endif } bool OWirelessNetworkInterface::wioctl( int call ) const { strcpy( _iwr.ifr_name, name() ); return wioctl( call, _iwr ); } diff --git a/libopie2/opienet/opienet.pro b/libopie2/opienet/opienet.pro index 304d968..d966462 100644 --- a/libopie2/opienet/opienet.pro +++ b/libopie2/opienet/opienet.pro @@ -1,32 +1,34 @@ TEMPLATE = lib CONFIG += qt warn_on debug DESTDIR = $(OPIEDIR)/lib HEADERS = 802_11_user.h \ dhcp.h \ udp_ports.h \ wireless.h \ oioctlmap.h \ omanufacturerdb.h \ onetutils.h \ onetwork.h \ - opcap.h + opcap.h \ + ostation.h SOURCES = oioctlmap.cpp \ omanufacturerdb.cpp \ onetutils.cpp \ onetwork.cpp \ - opcap.cpp + opcap.cpp \ + ostation.cpp INTERFACES = TARGET = opienet2 VERSION = 1.8.1 INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lpcap !contains( platform, x11 ) { include ( $(OPIEDIR)/include.pro ) } contains( platform, x11 ) { LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib } diff --git a/libopie2/opienet/ostation.cpp b/libopie2/opienet/ostation.cpp new file mode 100644 index 0000000..3817b31 --- a/dev/null +++ b/libopie2/opienet/ostation.cpp @@ -0,0 +1,49 @@ +/* + This file is part of the Opie Project + + (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 <opie2/ostation.h> + +/*====================================================================================== + * OStation + *======================================================================================*/ + +OStation::OStation() +{ + qDebug( "OStation::OStation()" ); +} + + +OStation::~OStation() +{ + qDebug( "OStation::~OStation()" ); +} + + diff --git a/libopie2/opienet/ostation.h b/libopie2/opienet/ostation.h new file mode 100644 index 0000000..f61570b --- a/dev/null +++ b/libopie2/opienet/ostation.h @@ -0,0 +1,67 @@ +/* + This file is part of the Opie Project + + (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 OSTATION_H +#define OSTATION_H + +#include <opie2/onetutils.h> + +#include <qdict.h> +#include <qmap.h> +#include <qstring.h> +#include <qhostaddress.h> +#include <qobject.h> + +#include <sys/types.h> + +class OStation; + +typedef QDict<OStation> OStationDict; + +/*====================================================================================== + * OStation + *======================================================================================*/ + +class OStation +{ + public: + OStation(); + ~OStation(); + + private: + OMacAddress macAddress; + QHostAddress ipAddress; + QString ssid; + QString type; +}; + +#endif // OSTATION_H + |