summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opienet/onetwork.cpp1
-rw-r--r--libopie2/opienet/onetwork.h13
2 files changed, 8 insertions, 6 deletions
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp
index 998b50e..21fa390 100644
--- a/libopie2/opienet/onetwork.cpp
+++ b/libopie2/opienet/onetwork.cpp
@@ -1,119 +1,118 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2003 by the Wellenreiter team: 3              Copyright (C) 2003 by the Wellenreiter team:
4 Martin J. Muench <mjm@remote-exploit.org> 4 Martin J. Muench <mjm@remote-exploit.org>
5 Max Moser <mmo@remote-exploit.org 5 Max Moser <mmo@remote-exploit.org
6 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 6 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34/* OPIE */ 34/* OPIE */
35 35
36#include <opie2/onetwork.h> 36#include <opie2/onetwork.h>
37 37
38/* QT */ 38/* QT */
39 39
40#include <qfile.h> 40#include <qfile.h>
41#include <qtextstream.h> 41#include <qtextstream.h>
42 42
43/* UNIX */ 43/* UNIX */
44 44
45#include <arpa/inet.h> 45#include <arpa/inet.h>
46#include <cerrno> 46#include <cerrno>
47#include <cstring> 47#include <cstring>
48#include <cstdlib> 48#include <cstdlib>
49#include <math.h> 49#include <math.h>
50#include <sys/ioctl.h> 50#include <sys/ioctl.h>
51#include <sys/socket.h> 51#include <sys/socket.h>
52#include <sys/types.h> 52#include <sys/types.h>
53#include <unistd.h> 53#include <unistd.h>
54#include <linux/sockios.h> 54#include <linux/sockios.h>
55#include <linux/wireless.h>
56 55
57using namespace std; 56using namespace std;
58 57
59/*====================================================================================== 58/*======================================================================================
60 * ONetwork 59 * ONetwork
61 *======================================================================================*/ 60 *======================================================================================*/
62 61
63ONetwork* ONetwork::_instance = 0; 62ONetwork* ONetwork::_instance = 0;
64 63
65ONetwork::ONetwork() 64ONetwork::ONetwork()
66{ 65{
67 qDebug( "ONetwork::ONetwork()" ); 66 qDebug( "ONetwork::ONetwork()" );
68 synchronize(); 67 synchronize();
69} 68}
70 69
71void ONetwork::synchronize() 70void ONetwork::synchronize()
72{ 71{
73 // gather available interfaces by inspecting /proc/net/dev 72 // gather available interfaces by inspecting /proc/net/dev
74 // we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices 73 // we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices
75 74
76 _interfaces.clear(); 75 _interfaces.clear();
77 QString str; 76 QString str;
78 QFile f( "/proc/net/dev" ); 77 QFile f( "/proc/net/dev" );
79 bool hasFile = f.open( IO_ReadOnly ); 78 bool hasFile = f.open( IO_ReadOnly );
80 if ( !hasFile ) 79 if ( !hasFile )
81 { 80 {
82 qDebug( "ONetwork: /proc/net/dev not existing. No network devices available" ); 81 qDebug( "ONetwork: /proc/net/dev not existing. No network devices available" );
83 return; 82 return;
84 } 83 }
85 QTextStream s( &f ); 84 QTextStream s( &f );
86 s.readLine(); 85 s.readLine();
87 s.readLine(); 86 s.readLine();
88 while ( !s.atEnd() ) 87 while ( !s.atEnd() )
89 { 88 {
90 s >> str; 89 s >> str;
91 str.truncate( str.find( ':' ) ); 90 str.truncate( str.find( ':' ) );
92 qDebug( "ONetwork: found interface '%s'", (const char*) str ); 91 qDebug( "ONetwork: found interface '%s'", (const char*) str );
93 ONetworkInterface* iface; 92 ONetworkInterface* iface;
94 if ( isWirelessInterface( str ) ) 93 if ( isWirelessInterface( str ) )
95 { 94 {
96 iface = new OWirelessNetworkInterface( str ); 95 iface = new OWirelessNetworkInterface( str );
97 qDebug( "ONetwork: interface '%s' has Wireless Extensions", (const char*) str ); 96 qDebug( "ONetwork: interface '%s' has Wireless Extensions", (const char*) str );
98 } 97 }
99 else 98 else
100 { 99 {
101 iface = new ONetworkInterface( str ); 100 iface = new ONetworkInterface( str );
102 } 101 }
103 _interfaces.insert( str, iface ); 102 _interfaces.insert( str, iface );
104 s.readLine(); 103 s.readLine();
105 } 104 }
106} 105}
107 106
108 107
109ONetworkInterface* ONetwork::interface( QString iface ) const 108ONetworkInterface* ONetwork::interface( QString iface ) const
110{ 109{
111 return _interfaces[iface]; 110 return _interfaces[iface];
112} 111}
113 112
114 113
115ONetwork* ONetwork::instance() 114ONetwork* ONetwork::instance()
116{ 115{
117 if ( !_instance ) _instance = new ONetwork(); 116 if ( !_instance ) _instance = new ONetwork();
118 return _instance; 117 return _instance;
119} 118}
diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h
index 56da5f4..c544454 100644
--- a/libopie2/opienet/onetwork.h
+++ b/libopie2/opienet/onetwork.h
@@ -1,121 +1,124 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2003 by the Wellenreiter team: 3              Copyright (C) 2003 by the Wellenreiter team:
4 Martin J. Muench <mjm@remote-exploit.org> 4 Martin J. Muench <mjm@remote-exploit.org>
5 Max Moser <mmo@remote-exploit.org 5 Max Moser <mmo@remote-exploit.org
6 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 6 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#ifndef ONETWORK_H 34#ifndef ONETWORK_H
35#define ONETWORK_H 35#define ONETWORK_H
36 36
37/* QT */ 37/* QT */
38 38
39#include <qdict.h> 39#include <qdict.h>
40#include <qmap.h> 40#include <qmap.h>
41#include <qobject.h> 41#include <qobject.h>
42#include <qhostaddress.h> 42#include <qhostaddress.h>
43 43
44/* OPIE */ 44/* OPIE */
45 45
46#include <opie2/onetutils.h> 46#include <opie2/onetutils.h>
47 47
48// ML: Yeah, I hate to include kernel headers, but it's necessary here
49// ML: Recent RedHat and MandrakePatches to the Kernel and WE broke something
50// ML: #include <net/if.h> e.g. conflicts with #include <linux/wireless.h>
51
52#ifndef IFNAMSIZ 48#ifndef IFNAMSIZ
53#define IFNAMSIZ 16 49#define IFNAMSIZ 16
54#endif 50#endif
55 51
56#include <linux/wireless.h> 52// ML: Yeah, I hate to include kernel headers, but it's necessary here
53// ML: Here comes an ugly hack to prevent <linux/wireless.h> including <linux/if.h>
54// ML: which conflicts with the user header <net/if.h>
55// ML: We really a user header for the Wireless Extensions, something like <net/wireless.h>
56// ML: I will drop Jean an mail on that subject
57
57#include <net/if.h> 58#include <net/if.h>
59#define _LINUX_IF_H
60#include <linux/wireless.h>
58 61
59#ifndef SIOCIWFIRSTPRIV 62#ifndef SIOCIWFIRSTPRIV
60#define SIOCIWFIRSTPRIV SIOCDEVPRIVATE 63#define SIOCIWFIRSTPRIV SIOCDEVPRIVATE
61#endif 64#endif
62 65
63class ONetworkInterface; 66class ONetworkInterface;
64class OWirelessNetworkInterface; 67class OWirelessNetworkInterface;
65class OChannelHopper; 68class OChannelHopper;
66class OMonitoringInterface; 69class OMonitoringInterface;
67 70
68typedef struct ifreq ifreqstruct; 71typedef struct ifreq ifreqstruct;
69typedef struct iwreq iwreqstruct; 72typedef struct iwreq iwreqstruct;
70typedef struct iw_event iweventstruct; 73typedef struct iw_event iweventstruct;
71typedef struct iw_freq iwfreqstruct; 74typedef struct iw_freq iwfreqstruct;
72typedef struct iw_priv_args iwprivargsstruct; 75typedef struct iw_priv_args iwprivargsstruct;
73typedef struct iw_range iwrangestruct; 76typedef struct iw_range iwrangestruct;
74 77
75/*====================================================================================== 78/*======================================================================================
76 * ONetwork 79 * ONetwork
77 *======================================================================================*/ 80 *======================================================================================*/
78 81
79class ONetwork : public QObject 82class ONetwork : public QObject
80{ 83{
81 Q_OBJECT 84 Q_OBJECT
82 85
83 public: 86 public:
84 typedef QDict<ONetworkInterface> InterfaceMap; 87 typedef QDict<ONetworkInterface> InterfaceMap;
85 typedef QDictIterator<ONetworkInterface> InterfaceIterator; 88 typedef QDictIterator<ONetworkInterface> InterfaceIterator;
86 89
87 public: 90 public:
88 static ONetwork* instance(); 91 static ONetwork* instance();
89 InterfaceIterator iterator() const; 92 InterfaceIterator iterator() const;
90 bool isWirelessInterface( const char* ) const; 93 bool isWirelessInterface( const char* ) const;
91 ONetworkInterface* interface( QString ) const; 94 ONetworkInterface* interface( QString ) const;
92 95
93 protected: 96 protected:
94 ONetwork(); 97 ONetwork();
95 void synchronize(); 98 void synchronize();
96 99
97 private: 100 private:
98 static ONetwork* _instance; 101 static ONetwork* _instance;
99 InterfaceMap _interfaces; 102 InterfaceMap _interfaces;
100}; 103};
101 104
102 105
103/*====================================================================================== 106/*======================================================================================
104 * ONetworkInterface 107 * ONetworkInterface
105 *======================================================================================*/ 108 *======================================================================================*/
106 109
107class ONetworkInterface 110class ONetworkInterface
108{ 111{
109 friend class OMonitoringInterface; 112 friend class OMonitoringInterface;
110 friend class OCiscoMonitoringInterface; 113 friend class OCiscoMonitoringInterface;
111 friend class OWlanNGMonitoringInterface; 114 friend class OWlanNGMonitoringInterface;
112 friend class OHostAPMonitoringInterface; 115 friend class OHostAPMonitoringInterface;
113 friend class OOrinocoMonitoringInterface; 116 friend class OOrinocoMonitoringInterface;
114 117
115 public: 118 public:
116 ONetworkInterface( const QString& name ); 119 ONetworkInterface( const QString& name );
117 virtual ~ONetworkInterface(); 120 virtual ~ONetworkInterface();
118 121
119 const QString& name() const; 122 const QString& name() const;
120 void setMonitoring( OMonitoringInterface* ); 123 void setMonitoring( OMonitoringInterface* );
121 OMonitoringInterface* monitoring() const; 124 OMonitoringInterface* monitoring() const;