author | mickeyl <mickeyl> | 2003-04-03 23:46:04 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-04-03 23:46:04 (UTC) |
commit | 487971af0c1b70babcc39fd549dc0d8142cd4865 (patch) (unidiff) | |
tree | e317df1359a20686ba35b17309a8b82386108fb3 | |
parent | 934e4d81bc078c704a39f02663607a6c16a5b29f (diff) | |
download | opie-487971af0c1b70babcc39fd549dc0d8142cd4865.zip opie-487971af0c1b70babcc39fd549dc0d8142cd4865.tar.gz opie-487971af0c1b70babcc39fd549dc0d8142cd4865.tar.bz2 |
first part of private IOCTL API for OWirelessNetworkInterface implemented
-rw-r--r-- | libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp | 8 | ||||
-rw-r--r-- | libopie2/opienet/onetutils.cpp | 33 | ||||
-rw-r--r-- | libopie2/opienet/onetutils.h | 4 | ||||
-rw-r--r-- | libopie2/opienet/onetwork.cpp | 33 | ||||
-rw-r--r-- | libopie2/opienet/onetwork.h | 5 |
5 files changed, 79 insertions, 4 deletions
diff --git a/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp b/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp index 7703b4c..b010ac5 100644 --- a/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp +++ b/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp | |||
@@ -1,35 +1,43 @@ | |||
1 | #include <opie2/onetwork.h> | 1 | #include <opie2/onetwork.h> |
2 | 2 | ||
3 | int main( int argc, char** argv ) | 3 | int main( int argc, char** argv ) |
4 | { | 4 | { |
5 | qDebug( "OPIE Network Demo" ); | 5 | qDebug( "OPIE Network Demo" ); |
6 | 6 | ||
7 | ONetwork* net = ONetwork::instance(); | 7 | ONetwork* net = ONetwork::instance(); |
8 | 8 | ||
9 | ONetwork::InterfaceIterator it = net->iterator(); | 9 | ONetwork::InterfaceIterator it = net->iterator(); |
10 | 10 | ||
11 | while ( it.current() ) | 11 | while ( it.current() ) |
12 | { | 12 | { |
13 | qDebug( "DEMO: ONetwork contains Interface '%s'", (const char*) it.current()->name() ); | 13 | qDebug( "DEMO: ONetwork contains Interface '%s'", (const char*) it.current()->name() ); |
14 | qDebug( "DEMO: MAC Address is '%s'", (const char*) it.current()->macAddress().toString() ); | 14 | qDebug( "DEMO: MAC Address is '%s'", (const char*) it.current()->macAddress().toString() ); |
15 | qDebug( "Demo: IPv4 Address is '%s'", (const char*) it.current()->ipV4Address() ); | 15 | qDebug( "Demo: IPv4 Address is '%s'", (const char*) it.current()->ipV4Address() ); |
16 | if ( it.current()->isWireless() ) | 16 | if ( it.current()->isWireless() ) |
17 | { | 17 | { |
18 | OWirelessNetworkInterface* iface = static_cast<OWirelessNetworkInterface*>( it.current() ); | 18 | OWirelessNetworkInterface* iface = static_cast<OWirelessNetworkInterface*>( it.current() ); |
19 | qDebug( "DEMO: '%s' seems to feature the wireless extensions.", (const char*) iface->name() ); | 19 | qDebug( "DEMO: '%s' seems to feature the wireless extensions.", (const char*) iface->name() ); |
20 | qDebug( "DEMO: Current SSID is '%s'", (const char*) iface->SSID() ); | 20 | qDebug( "DEMO: Current SSID is '%s'", (const char*) iface->SSID() ); |
21 | qDebug( "DEMO: Current NickName is '%s'", (const char*) iface->nickName() ); | 21 | qDebug( "DEMO: Current NickName is '%s'", (const char*) iface->nickName() ); |
22 | qDebug( "DEMO: Antenna is tuned to '%f', that is channel %d", iface->frequency(), iface->channel() ); | 22 | qDebug( "DEMO: Antenna is tuned to '%f', that is channel %d", iface->frequency(), iface->channel() ); |
23 | 23 | ||
24 | //if ( iface->mode() == OWirelessNetworkInterface::adhoc ) | 24 | //if ( iface->mode() == OWirelessNetworkInterface::adhoc ) |
25 | //{ | 25 | //{ |
26 | qDebug( "DEMO: Associated AP has MAC Address '%s'", (const char*) iface->associatedAP() ); | 26 | qDebug( "DEMO: Associated AP has MAC Address '%s'", (const char*) iface->associatedAP() ); |
27 | //} | 27 | //} |
28 | 28 | ||
29 | // try to set monitor mode | ||
30 | |||
31 | // first some wrong calls to check if this is working | ||
32 | iface->setPrivate( "seppel", 10 ); | ||
33 | iface->setPrivate( "monitor", 0 ); | ||
34 | |||
35 | // now the real deal | ||
36 | iface->setPrivate( "monitor", 2, 2, 3 ); | ||
29 | } | 37 | } |
30 | ++it; | 38 | ++it; |
31 | } | 39 | } |
32 | 40 | ||
33 | return 0; | 41 | return 0; |
34 | 42 | ||
35 | } | 43 | } |
diff --git a/libopie2/opienet/onetutils.cpp b/libopie2/opienet/onetutils.cpp index 3e11b53..fd8f9e9 100644 --- a/libopie2/opienet/onetutils.cpp +++ b/libopie2/opienet/onetutils.cpp | |||
@@ -1,160 +1,185 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | 4 | (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | _;:, .> :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | .%`+i> _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= = ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= -. .` .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | -_. . . )=. = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | -- :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | 29 | ||
30 | */ | 30 | */ |
31 | 31 | ||
32 | #include <opie2/onetutils.h> | 32 | #include <opie2/onetutils.h> |
33 | #include <opie2/onetwork.h> | ||
33 | 34 | ||
34 | #include <net/if.h> | 35 | #include <net/if.h> |
35 | 36 | ||
36 | #include <cstdio> | 37 | #include <cstdio> |
37 | using namespace std; | 38 | using namespace std; |
38 | 39 | ||
39 | #define IW_PRIV_TYPE_MASK 0x7000 | 40 | #define IW_PRIV_TYPE_MASK 0x7000 |
40 | #define IW_PRIV_TYPE_NONE 0x0000 | 41 | #define IW_PRIV_TYPE_NONE 0x0000 |
41 | #define IW_PRIV_TYPE_BYTE 0x1000 | 42 | #define IW_PRIV_TYPE_BYTE 0x1000 |
42 | #define IW_PRIV_TYPE_CHAR 0x2000 | 43 | #define IW_PRIV_TYPE_CHAR 0x2000 |
43 | #define IW_PRIV_TYPE_INT 0x4000 | 44 | #define IW_PRIV_TYPE_INT 0x4000 |
44 | #define IW_PRIV_TYPE_FLOAT 0x5000 | 45 | #define IW_PRIV_TYPE_FLOAT 0x5000 |
45 | #define IW_PRIV_TYPE_ADDR 0x6000 | 46 | #define IW_PRIV_TYPE_ADDR 0x6000 |
46 | #define IW_PRIV_SIZE_FIXED 0x0800 | 47 | #define IW_PRIV_SIZE_FIXED 0x0800 |
47 | #define IW_PRIV_SIZE_MASK 0x07FF | 48 | #define IW_PRIV_SIZE_MASK 0x07FF |
48 | 49 | ||
49 | /*====================================================================================== | 50 | /*====================================================================================== |
50 | * OMacAddress | 51 | * OMacAddress |
51 | *======================================================================================*/ | 52 | *======================================================================================*/ |
52 | 53 | ||
53 | // static initializer for broadcast and unknown MAC Adresses | 54 | // static initializer for broadcast and unknown MAC Adresses |
54 | const unsigned char __broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; | 55 | const unsigned char __broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; |
55 | const OMacAddress& OMacAddress::broadcast = OMacAddress( __broadcast ); | 56 | const OMacAddress& OMacAddress::broadcast = OMacAddress( __broadcast ); |
56 | const unsigned char __unknown[6] = { 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 }; | 57 | const unsigned char __unknown[6] = { 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 }; |
57 | const OMacAddress& OMacAddress::unknown = OMacAddress( __unknown ); | 58 | const OMacAddress& OMacAddress::unknown = OMacAddress( __unknown ); |
58 | 59 | ||
59 | 60 | ||
60 | //TODO: Incorporate Ethernet Manufacturer database here! | 61 | //TODO: Incorporate Ethernet Manufacturer database here! |
61 | 62 | ||
62 | OMacAddress::OMacAddress( unsigned char* p ) | 63 | OMacAddress::OMacAddress( unsigned char* p ) |
63 | { | 64 | { |
64 | memcpy( _bytes, p, 6 ); // D'OH! memcpy in my sources... eeek... | 65 | memcpy( _bytes, p, 6 ); // D'OH! memcpy in my sources... eeek... |
65 | } | 66 | } |
66 | 67 | ||
67 | 68 | ||
68 | OMacAddress::OMacAddress( const unsigned char* p ) | 69 | OMacAddress::OMacAddress( const unsigned char* p ) |
69 | { | 70 | { |
70 | memcpy( _bytes, p, 6 ); | 71 | memcpy( _bytes, p, 6 ); |
71 | } | 72 | } |
72 | 73 | ||
73 | 74 | ||
74 | OMacAddress::OMacAddress( struct ifreq& ifr ) | 75 | OMacAddress::OMacAddress( struct ifreq& ifr ) |
75 | { | 76 | { |
76 | memcpy( _bytes, ifr.ifr_hwaddr.sa_data, 6 ); | 77 | memcpy( _bytes, ifr.ifr_hwaddr.sa_data, 6 ); |
77 | } | 78 | } |
78 | 79 | ||
79 | 80 | ||
80 | OMacAddress::~OMacAddress() | 81 | OMacAddress::~OMacAddress() |
81 | { | 82 | { |
82 | } | 83 | } |
83 | 84 | ||
84 | 85 | ||
85 | QString OMacAddress::toString() const | 86 | QString OMacAddress::toString() const |
86 | { | 87 | { |
87 | QString s; | 88 | QString s; |
88 | s.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", | 89 | s.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", |
89 | _bytes[0]&0xff, _bytes[1]&0xff, _bytes[2]&0xff, | 90 | _bytes[0]&0xff, _bytes[1]&0xff, _bytes[2]&0xff, |
90 | _bytes[3]&0xff, _bytes[4]&0xff, _bytes[5]&0xff ); | 91 | _bytes[3]&0xff, _bytes[4]&0xff, _bytes[5]&0xff ); |
91 | return s; | 92 | return s; |
92 | } | 93 | } |
93 | 94 | ||
94 | 95 | ||
95 | bool operator==( const OMacAddress &m1, const OMacAddress &m2 ) | 96 | bool operator==( const OMacAddress &m1, const OMacAddress &m2 ) |
96 | { | 97 | { |
97 | return memcmp( &m1._bytes, &m2._bytes, 6 ) == 0; | 98 | return memcmp( &m1._bytes, &m2._bytes, 6 ) == 0; |
98 | } | 99 | } |
99 | 100 | ||
100 | 101 | ||
101 | /*====================================================================================== | 102 | /*====================================================================================== |
102 | * OHostAddress | 103 | * OHostAddress |
103 | *======================================================================================*/ | 104 | *======================================================================================*/ |
104 | 105 | ||
105 | 106 | ||
106 | /*====================================================================================== | 107 | /*====================================================================================== |
107 | * OPrivateIOCTL | 108 | * OPrivateIOCTL |
108 | *======================================================================================*/ | 109 | *======================================================================================*/ |
109 | 110 | ||
110 | OPrivateIOCTL::OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs ) | 111 | OPrivateIOCTL::OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs ) |
111 | :QObject( parent, name ), _ioctl( cmd ), _getargs( getargs ), _setargs( setargs ) | 112 | :QObject( parent, name ), _ioctl( cmd ), _getargs( getargs ), _setargs( setargs ) |
112 | { | 113 | { |
113 | } | 114 | } |
114 | 115 | ||
115 | 116 | ||
116 | OPrivateIOCTL::~OPrivateIOCTL() | 117 | OPrivateIOCTL::~OPrivateIOCTL() |
117 | { | 118 | { |
118 | } | 119 | } |
119 | 120 | ||
120 | 121 | ||
121 | inline int OPrivateIOCTL::numberGetArgs() const | 122 | #ifdef QT_NO_DEBUG |
123 | inline | ||
124 | #endif | ||
125 | int OPrivateIOCTL::numberGetArgs() const | ||
122 | { | 126 | { |
123 | return _getargs & IW_PRIV_SIZE_MASK; | 127 | return _getargs & IW_PRIV_SIZE_MASK; |
124 | } | 128 | } |
125 | 129 | ||
126 | 130 | ||
127 | inline int OPrivateIOCTL::typeGetArgs() const | 131 | #ifdef QT_NO_DEBUG |
132 | inline | ||
133 | #endif | ||
134 | int OPrivateIOCTL::typeGetArgs() const | ||
128 | { | 135 | { |
129 | return _getargs & IW_PRIV_TYPE_MASK >> 12; | 136 | return _getargs & IW_PRIV_TYPE_MASK >> 12; |
130 | } | 137 | } |
131 | 138 | ||
132 | 139 | ||
133 | inline int OPrivateIOCTL::numberSetArgs() const | 140 | #ifdef QT_NO_DEBUG |
141 | inline | ||
142 | #endif | ||
143 | int OPrivateIOCTL::numberSetArgs() const | ||
134 | { | 144 | { |
135 | return _setargs & IW_PRIV_SIZE_MASK; | 145 | return _setargs & IW_PRIV_SIZE_MASK; |
136 | } | 146 | } |
137 | 147 | ||
138 | 148 | ||
139 | inline int OPrivateIOCTL::typeSetArgs() const | 149 | #ifdef QT_NO_DEBUG |
150 | inline | ||
151 | #endif | ||
152 | int OPrivateIOCTL::typeSetArgs() const | ||
140 | { | 153 | { |
141 | return _setargs & IW_PRIV_TYPE_MASK >> 12; | 154 | return _setargs & IW_PRIV_TYPE_MASK >> 12; |
142 | } | 155 | } |
143 | 156 | ||
144 | 157 | ||
158 | void OPrivateIOCTL::invoke() const | ||
159 | { | ||
160 | ( (OWirelessNetworkInterface*) parent() )->wioctl( _ioctl ); | ||
161 | } | ||
162 | |||
163 | |||
164 | void OPrivateIOCTL::setParameter( int num, u_int32_t value ) | ||
165 | { | ||
166 | u_int32_t* arglist = (u_int32_t*) &( (OWirelessNetworkInterface*) parent() )->_iwr.u.name; | ||
167 | arglist[num] = value; | ||
168 | } | ||
169 | |||
145 | /*====================================================================================== | 170 | /*====================================================================================== |
146 | * assorted functions | 171 | * assorted functions |
147 | *======================================================================================*/ | 172 | *======================================================================================*/ |
148 | 173 | ||
149 | void dumpBytes( const unsigned char* data, int num ) | 174 | void dumpBytes( const unsigned char* data, int num ) |
150 | { | 175 | { |
151 | printf( "Dumping %d bytes @ %0x", num, data ); | 176 | printf( "Dumping %d bytes @ %0x", num, data ); |
152 | printf( "-------------------------------------------\n" ); | 177 | printf( "-------------------------------------------\n" ); |
153 | 178 | ||
154 | for ( int i = 0; i < num; ++i ) | 179 | for ( int i = 0; i < num; ++i ) |
155 | { | 180 | { |
156 | printf( "%02x ", data[i] ); | 181 | printf( "%02x ", data[i] ); |
157 | if ( !((i+1) % 32) ) printf( "\n" ); | 182 | if ( !((i+1) % 32) ) printf( "\n" ); |
158 | } | 183 | } |
159 | printf( "\n\n" ); | 184 | printf( "\n\n" ); |
160 | } | 185 | } |
diff --git a/libopie2/opienet/onetutils.h b/libopie2/opienet/onetutils.h index 6640515..8be042b 100644 --- a/libopie2/opienet/onetutils.h +++ b/libopie2/opienet/onetutils.h | |||
@@ -1,150 +1,154 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | 4 | (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | _;:, .> :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | .%`+i> _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= = ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= -. .` .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | -_. . . )=. = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | -- :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | 29 | ||
30 | */ | 30 | */ |
31 | 31 | ||
32 | #ifndef ONETUTILS_H | 32 | #ifndef ONETUTILS_H |
33 | #define ONETUTILS_H | 33 | #define ONETUTILS_H |
34 | 34 | ||
35 | #include <qdict.h> | 35 | #include <qdict.h> |
36 | #include <qmap.h> | 36 | #include <qmap.h> |
37 | #include <qstring.h> | 37 | #include <qstring.h> |
38 | #include <qhostaddress.h> | 38 | #include <qhostaddress.h> |
39 | #include <qobject.h> | 39 | #include <qobject.h> |
40 | 40 | ||
41 | #include <sys/types.h> | 41 | #include <sys/types.h> |
42 | 42 | ||
43 | struct ifreq; | 43 | struct ifreq; |
44 | class OWirelessNetworkInterface; | 44 | class OWirelessNetworkInterface; |
45 | 45 | ||
46 | /*====================================================================================== | 46 | /*====================================================================================== |
47 | * OMacAddress | 47 | * OMacAddress |
48 | *======================================================================================*/ | 48 | *======================================================================================*/ |
49 | 49 | ||
50 | class OMacAddress | 50 | class OMacAddress |
51 | { | 51 | { |
52 | public: | 52 | public: |
53 | OMacAddress( unsigned char* ); | 53 | OMacAddress( unsigned char* ); |
54 | OMacAddress( const unsigned char* ); | 54 | OMacAddress( const unsigned char* ); |
55 | OMacAddress( struct ifreq& ); | 55 | OMacAddress( struct ifreq& ); |
56 | ~OMacAddress(); | 56 | ~OMacAddress(); |
57 | 57 | ||
58 | QString toString() const; | 58 | QString toString() const; |
59 | 59 | ||
60 | public: | 60 | public: |
61 | static const OMacAddress& broadcast; // ff:ff:ff:ff:ff:ff | 61 | static const OMacAddress& broadcast; // ff:ff:ff:ff:ff:ff |
62 | static const OMacAddress& unknown; // 44:44:44:44:44:44 | 62 | static const OMacAddress& unknown; // 44:44:44:44:44:44 |
63 | 63 | ||
64 | private: | 64 | private: |
65 | unsigned char _bytes[6]; | 65 | unsigned char _bytes[6]; |
66 | 66 | ||
67 | friend bool operator==( const OMacAddress &m1, const OMacAddress &m2 ); | 67 | friend bool operator==( const OMacAddress &m1, const OMacAddress &m2 ); |
68 | 68 | ||
69 | }; | 69 | }; |
70 | 70 | ||
71 | bool operator==( const OMacAddress &m1, const OMacAddress &m2 ); | 71 | bool operator==( const OMacAddress &m1, const OMacAddress &m2 ); |
72 | 72 | ||
73 | 73 | ||
74 | /*====================================================================================== | 74 | /*====================================================================================== |
75 | * OHostAddress | 75 | * OHostAddress |
76 | *======================================================================================*/ | 76 | *======================================================================================*/ |
77 | 77 | ||
78 | class OHostAddress : public QHostAddress | 78 | class OHostAddress : public QHostAddress |
79 | { | 79 | { |
80 | public: | 80 | public: |
81 | OHostAddress(); | 81 | OHostAddress(); |
82 | ~OHostAddress(); | 82 | ~OHostAddress(); |
83 | }; | 83 | }; |
84 | 84 | ||
85 | 85 | ||
86 | /*====================================================================================== | 86 | /*====================================================================================== |
87 | * OPrivateIOCTL | 87 | * OPrivateIOCTL |
88 | *======================================================================================*/ | 88 | *======================================================================================*/ |
89 | 89 | ||
90 | class OPrivateIOCTL : public QObject | 90 | class OPrivateIOCTL : public QObject |
91 | { | 91 | { |
92 | public: | 92 | public: |
93 | OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs ); | 93 | OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs ); |
94 | ~OPrivateIOCTL(); | 94 | ~OPrivateIOCTL(); |
95 | 95 | ||
96 | int numberGetArgs() const; | 96 | int numberGetArgs() const; |
97 | int typeGetArgs() const; | 97 | int typeGetArgs() const; |
98 | int numberSetArgs() const; | 98 | int numberSetArgs() const; |
99 | int typeSetArgs() const; | 99 | int typeSetArgs() const; |
100 | 100 | ||
101 | void invoke() const; | ||
102 | void setParameter( int, u_int32_t ); | ||
103 | |||
101 | private: | 104 | private: |
102 | u_int32_t _ioctl; | 105 | u_int32_t _ioctl; |
103 | u_int16_t _getargs; | 106 | u_int16_t _getargs; |
104 | u_int16_t _setargs; | 107 | u_int16_t _setargs; |
108 | |||
105 | }; | 109 | }; |
106 | 110 | ||
107 | /*====================================================================================== | 111 | /*====================================================================================== |
108 | * Miscellaneous | 112 | * Miscellaneous |
109 | *======================================================================================*/ | 113 | *======================================================================================*/ |
110 | 114 | ||
111 | /* dump bytes */ | 115 | /* dump bytes */ |
112 | 116 | ||
113 | void dumpBytes( const unsigned char* data, int num ); | 117 | void dumpBytes( const unsigned char* data, int num ); |
114 | 118 | ||
115 | /* Network to host order macros */ | 119 | /* Network to host order macros */ |
116 | 120 | ||
117 | #ifdef LBL_ALIGN | 121 | #ifdef LBL_ALIGN |
118 | #define EXTRACT_16BITS(p) \ | 122 | #define EXTRACT_16BITS(p) \ |
119 | ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 0) << 8 | \ | 123 | ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 0) << 8 | \ |
120 | (u_int16_t)*((const u_int8_t *)(p) + 1))) | 124 | (u_int16_t)*((const u_int8_t *)(p) + 1))) |
121 | #define EXTRACT_32BITS(p) \ | 125 | #define EXTRACT_32BITS(p) \ |
122 | ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 24 | \ | 126 | ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 24 | \ |
123 | (u_int32_t)*((const u_int8_t *)(p) + 1) << 16 | \ | 127 | (u_int32_t)*((const u_int8_t *)(p) + 1) << 16 | \ |
124 | (u_int32_t)*((const u_int8_t *)(p) + 2) << 8 | \ | 128 | (u_int32_t)*((const u_int8_t *)(p) + 2) << 8 | \ |
125 | (u_int32_t)*((const u_int8_t *)(p) + 3))) | 129 | (u_int32_t)*((const u_int8_t *)(p) + 3))) |
126 | #else | 130 | #else |
127 | #define EXTRACT_16BITS(p) \ | 131 | #define EXTRACT_16BITS(p) \ |
128 | ((u_int16_t)ntohs(*(const u_int16_t *)(p))) | 132 | ((u_int16_t)ntohs(*(const u_int16_t *)(p))) |
129 | #define EXTRACT_32BITS(p) \ | 133 | #define EXTRACT_32BITS(p) \ |
130 | ((u_int32_t)ntohl(*(const u_int32_t *)(p))) | 134 | ((u_int32_t)ntohl(*(const u_int32_t *)(p))) |
131 | #endif | 135 | #endif |
132 | 136 | ||
133 | #define EXTRACT_24BITS(p) \ | 137 | #define EXTRACT_24BITS(p) \ |
134 | ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 16 | \ | 138 | ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 16 | \ |
135 | (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \ | 139 | (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \ |
136 | (u_int32_t)*((const u_int8_t *)(p) + 2))) | 140 | (u_int32_t)*((const u_int8_t *)(p) + 2))) |
137 | 141 | ||
138 | /* Little endian protocol host order macros */ | 142 | /* Little endian protocol host order macros */ |
139 | #define EXTRACT_LE_8BITS(p) (*(p)) | 143 | #define EXTRACT_LE_8BITS(p) (*(p)) |
140 | #define EXTRACT_LE_16BITS(p) \ | 144 | #define EXTRACT_LE_16BITS(p) \ |
141 | ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 1) << 8 | \ | 145 | ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 1) << 8 | \ |
142 | (u_int16_t)*((const u_int8_t *)(p) + 0))) | 146 | (u_int16_t)*((const u_int8_t *)(p) + 0))) |
143 | #define EXTRACT_LE_32BITS(p) \ | 147 | #define EXTRACT_LE_32BITS(p) \ |
144 | ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 3) << 24 | \ | 148 | ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 3) << 24 | \ |
145 | (u_int32_t)*((const u_int8_t *)(p) + 2) << 16 | \ | 149 | (u_int32_t)*((const u_int8_t *)(p) + 2) << 16 | \ |
146 | (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \ | 150 | (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \ |
147 | (u_int32_t)*((const u_int8_t *)(p) + 0))) | 151 | (u_int32_t)*((const u_int8_t *)(p) + 0))) |
148 | 152 | ||
149 | #endif // ONETUTILS_H | 153 | #endif // ONETUTILS_H |
150 | 154 | ||
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp index 2548a04..66fa215 100644 --- a/libopie2/opienet/onetwork.cpp +++ b/libopie2/opienet/onetwork.cpp | |||
@@ -1,246 +1,247 @@ | |||
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 <stdarg.h> | ||
55 | 56 | ||
56 | using namespace std; | 57 | using namespace std; |
57 | 58 | ||
58 | /*====================================================================================== | 59 | /*====================================================================================== |
59 | * ONetwork | 60 | * ONetwork |
60 | *======================================================================================*/ | 61 | *======================================================================================*/ |
61 | 62 | ||
62 | ONetwork* ONetwork::_instance = 0; | 63 | ONetwork* ONetwork::_instance = 0; |
63 | 64 | ||
64 | ONetwork::ONetwork() | 65 | ONetwork::ONetwork() |
65 | { | 66 | { |
66 | qDebug( "ONetwork::ONetwork()" ); | 67 | qDebug( "ONetwork::ONetwork()" ); |
67 | synchronize(); | 68 | synchronize(); |
68 | } | 69 | } |
69 | 70 | ||
70 | void ONetwork::synchronize() | 71 | void ONetwork::synchronize() |
71 | { | 72 | { |
72 | // gather available interfaces by inspecting /proc/net/dev | 73 | // gather available interfaces by inspecting /proc/net/dev |
73 | // we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices | 74 | // we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices |
74 | 75 | ||
75 | _interfaces.clear(); | 76 | _interfaces.clear(); |
76 | QString str; | 77 | QString str; |
77 | QFile f( "/proc/net/dev" ); | 78 | QFile f( "/proc/net/dev" ); |
78 | bool hasFile = f.open( IO_ReadOnly ); | 79 | bool hasFile = f.open( IO_ReadOnly ); |
79 | if ( !hasFile ) | 80 | if ( !hasFile ) |
80 | { | 81 | { |
81 | qDebug( "ONetwork: /proc/net/dev not existing. No network devices available" ); | 82 | qDebug( "ONetwork: /proc/net/dev not existing. No network devices available" ); |
82 | return; | 83 | return; |
83 | } | 84 | } |
84 | QTextStream s( &f ); | 85 | QTextStream s( &f ); |
85 | s.readLine(); | 86 | s.readLine(); |
86 | s.readLine(); | 87 | s.readLine(); |
87 | while ( !s.atEnd() ) | 88 | while ( !s.atEnd() ) |
88 | { | 89 | { |
89 | s >> str; | 90 | s >> str; |
90 | str.truncate( str.find( ':' ) ); | 91 | str.truncate( str.find( ':' ) ); |
91 | qDebug( "ONetwork: found interface '%s'", (const char*) str ); | 92 | qDebug( "ONetwork: found interface '%s'", (const char*) str ); |
92 | ONetworkInterface* iface; | 93 | ONetworkInterface* iface; |
93 | if ( isWirelessInterface( str ) ) | 94 | if ( isWirelessInterface( str ) ) |
94 | { | 95 | { |
95 | iface = new OWirelessNetworkInterface( this, str ); | 96 | iface = new OWirelessNetworkInterface( this, str ); |
96 | qDebug( "ONetwork: interface '%s' has Wireless Extensions", (const char*) str ); | 97 | qDebug( "ONetwork: interface '%s' has Wireless Extensions", (const char*) str ); |
97 | } | 98 | } |
98 | else | 99 | else |
99 | { | 100 | { |
100 | iface = new ONetworkInterface( this, str ); | 101 | iface = new ONetworkInterface( this, str ); |
101 | } | 102 | } |
102 | _interfaces.insert( str, iface ); | 103 | _interfaces.insert( str, iface ); |
103 | s.readLine(); | 104 | s.readLine(); |
104 | } | 105 | } |
105 | } | 106 | } |
106 | 107 | ||
107 | 108 | ||
108 | ONetworkInterface* ONetwork::interface( QString iface ) const | 109 | ONetworkInterface* ONetwork::interface( QString iface ) const |
109 | { | 110 | { |
110 | return _interfaces[iface]; | 111 | return _interfaces[iface]; |
111 | } | 112 | } |
112 | 113 | ||
113 | 114 | ||
114 | ONetwork* ONetwork::instance() | 115 | ONetwork* ONetwork::instance() |
115 | { | 116 | { |
116 | if ( !_instance ) _instance = new ONetwork(); | 117 | if ( !_instance ) _instance = new ONetwork(); |
117 | return _instance; | 118 | return _instance; |
118 | } | 119 | } |
119 | 120 | ||
120 | 121 | ||
121 | ONetwork::InterfaceIterator ONetwork::iterator() const | 122 | ONetwork::InterfaceIterator ONetwork::iterator() const |
122 | { | 123 | { |
123 | return ONetwork::InterfaceIterator( _interfaces ); | 124 | return ONetwork::InterfaceIterator( _interfaces ); |
124 | } | 125 | } |
125 | 126 | ||
126 | 127 | ||
127 | bool ONetwork::isWirelessInterface( const char* name ) const | 128 | bool ONetwork::isWirelessInterface( const char* name ) const |
128 | { | 129 | { |
129 | int sfd = socket( AF_INET, SOCK_STREAM, 0 ); | 130 | int sfd = socket( AF_INET, SOCK_STREAM, 0 ); |
130 | iwreqstruct iwr; | 131 | iwreqstruct iwr; |
131 | memset( &iwr, 0, sizeof( iwreqstruct ) ); | 132 | memset( &iwr, 0, sizeof( iwreqstruct ) ); |
132 | strcpy( (char*) &iwr.ifr_name, name ); | 133 | strcpy( (char*) &iwr.ifr_name, name ); |
133 | int result = ::ioctl( sfd, SIOCGIWNAME, &iwr ); | 134 | int result = ::ioctl( sfd, SIOCGIWNAME, &iwr ); |
134 | if ( result == -1 ) | 135 | if ( result == -1 ) |
135 | qDebug( "ONetwork::ioctl(): SIOCGIWNAME failed: %d (%s)", result, strerror( errno ) ); | 136 | qDebug( "ONetwork::ioctl(): SIOCGIWNAME failed: %d (%s)", result, strerror( errno ) ); |
136 | else | 137 | else |
137 | qDebug( "ONetwork::ioctl(): SIOCGIWNAME ok." ); | 138 | qDebug( "ONetwork::ioctl(): SIOCGIWNAME ok." ); |
138 | return ( result != -1 ); | 139 | return ( result != -1 ); |
139 | } | 140 | } |
140 | 141 | ||
141 | /*====================================================================================== | 142 | /*====================================================================================== |
142 | * ONetworkInterface | 143 | * ONetworkInterface |
143 | *======================================================================================*/ | 144 | *======================================================================================*/ |
144 | 145 | ||
145 | ONetworkInterface::ONetworkInterface( QObject* parent, const char* name ) | 146 | ONetworkInterface::ONetworkInterface( QObject* parent, const char* name ) |
146 | :QObject( parent, name ), | 147 | :QObject( parent, name ), |
147 | _sfd( socket( AF_INET, SOCK_DGRAM, 0 ) ), _mon( 0 ) | 148 | _sfd( socket( AF_INET, SOCK_DGRAM, 0 ) ), _mon( 0 ) |
148 | { | 149 | { |
149 | qDebug( "ONetworkInterface::ONetworkInterface()" ); | 150 | qDebug( "ONetworkInterface::ONetworkInterface()" ); |
150 | init(); | 151 | init(); |
151 | } | 152 | } |
152 | 153 | ||
153 | 154 | ||
154 | ifreqstruct& ONetworkInterface::ifr() const | 155 | ifreqstruct& ONetworkInterface::ifr() const |
155 | { | 156 | { |
156 | return _ifr; | 157 | return _ifr; |
157 | } | 158 | } |
158 | 159 | ||
159 | 160 | ||
160 | void ONetworkInterface::init() | 161 | void ONetworkInterface::init() |
161 | { | 162 | { |
162 | qDebug( "ONetworkInterface::init()" ); | 163 | qDebug( "ONetworkInterface::init()" ); |
163 | 164 | ||
164 | memset( &_ifr, 0, sizeof( struct ifreq ) ); | 165 | memset( &_ifr, 0, sizeof( struct ifreq ) ); |
165 | 166 | ||
166 | if ( _sfd == -1 ) | 167 | if ( _sfd == -1 ) |
167 | { | 168 | { |
168 | qDebug( "ONetworkInterface::init(): Warning - can't get socket for device '%s'", name() ); | 169 | qDebug( "ONetworkInterface::init(): Warning - can't get socket for device '%s'", name() ); |
169 | return; | 170 | return; |
170 | } | 171 | } |
171 | } | 172 | } |
172 | 173 | ||
173 | 174 | ||
174 | bool ONetworkInterface::ioctl( int call, ifreqstruct& ifreq ) const | 175 | bool ONetworkInterface::ioctl( int call, ifreqstruct& ifreq ) const |
175 | { | 176 | { |
176 | int result = ::ioctl( _sfd, call, &ifreq ); | 177 | int result = ::ioctl( _sfd, call, &ifreq ); |
177 | if ( result == -1 ) | 178 | if ( result == -1 ) |
178 | qDebug( "ONetworkInterface::ioctl(): Call %d - Status: Failed: %d (%s)", call, result, strerror( errno ) ); | 179 | qDebug( "ONetworkInterface::ioctl(): Call %d - Status: Failed: %d (%s)", call, result, strerror( errno ) ); |
179 | else | 180 | else |
180 | qDebug( "ONetworkInterface::ioctl(): Call %d - Status: Ok.", call ); | 181 | qDebug( "ONetworkInterface::ioctl(): Call %d - Status: Ok.", call ); |
181 | return ( result != -1 ); | 182 | return ( result != -1 ); |
182 | } | 183 | } |
183 | 184 | ||
184 | 185 | ||
185 | bool ONetworkInterface::ioctl( int call ) const | 186 | bool ONetworkInterface::ioctl( int call ) const |
186 | { | 187 | { |
187 | strcpy( _ifr.ifr_name, name() ); | 188 | strcpy( _ifr.ifr_name, name() ); |
188 | return ioctl( call, _ifr ); | 189 | return ioctl( call, _ifr ); |
189 | } | 190 | } |
190 | 191 | ||
191 | 192 | ||
192 | bool ONetworkInterface::isLoopback() const | 193 | bool ONetworkInterface::isLoopback() const |
193 | { | 194 | { |
194 | ioctl( SIOCGIFFLAGS ); | 195 | ioctl( SIOCGIFFLAGS ); |
195 | return _ifr.ifr_flags & IFF_LOOPBACK; | 196 | return _ifr.ifr_flags & IFF_LOOPBACK; |
196 | } | 197 | } |
197 | 198 | ||
198 | 199 | ||
199 | bool ONetworkInterface::setUp( bool b ) | 200 | bool ONetworkInterface::setUp( bool b ) |
200 | { | 201 | { |
201 | ioctl( SIOCGIFFLAGS ); | 202 | ioctl( SIOCGIFFLAGS ); |
202 | if ( b ) _ifr.ifr_flags |= IFF_UP; | 203 | if ( b ) _ifr.ifr_flags |= IFF_UP; |
203 | else _ifr.ifr_flags &= (~IFF_UP); | 204 | else _ifr.ifr_flags &= (~IFF_UP); |
204 | return ioctl( SIOCSIFFLAGS ); | 205 | return ioctl( SIOCSIFFLAGS ); |
205 | } | 206 | } |
206 | 207 | ||
207 | 208 | ||
208 | bool ONetworkInterface::isUp() const | 209 | bool ONetworkInterface::isUp() const |
209 | { | 210 | { |
210 | ioctl( SIOCGIFFLAGS ); | 211 | ioctl( SIOCGIFFLAGS ); |
211 | return _ifr.ifr_flags & IFF_UP; | 212 | return _ifr.ifr_flags & IFF_UP; |
212 | } | 213 | } |
213 | 214 | ||
214 | 215 | ||
215 | QString ONetworkInterface::ipV4Address() const | 216 | QString ONetworkInterface::ipV4Address() const |
216 | { | 217 | { |
217 | if ( ioctl( SIOCGIFADDR ) ) | 218 | if ( ioctl( SIOCGIFADDR ) ) |
218 | { | 219 | { |
219 | struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr; | 220 | struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr; |
220 | //FIXME: Use QHostAddress here | 221 | //FIXME: Use QHostAddress here |
221 | return QString( inet_ntoa( sa->sin_addr ) ); | 222 | return QString( inet_ntoa( sa->sin_addr ) ); |
222 | } | 223 | } |
223 | else | 224 | else |
224 | return "<unknown>"; | 225 | return "<unknown>"; |
225 | } | 226 | } |
226 | 227 | ||
227 | 228 | ||
228 | OMacAddress ONetworkInterface::macAddress() const | 229 | OMacAddress ONetworkInterface::macAddress() const |
229 | { | 230 | { |
230 | if ( ioctl( SIOCGIFHWADDR ) ) | 231 | if ( ioctl( SIOCGIFHWADDR ) ) |
231 | { | 232 | { |
232 | return OMacAddress( _ifr ); | 233 | return OMacAddress( _ifr ); |
233 | } | 234 | } |
234 | else | 235 | else |
235 | { | 236 | { |
236 | return OMacAddress::unknown; | 237 | return OMacAddress::unknown; |
237 | } | 238 | } |
238 | } | 239 | } |
239 | 240 | ||
240 | 241 | ||
241 | void ONetworkInterface::setMonitoring( OMonitoringInterface* m ) | 242 | void ONetworkInterface::setMonitoring( OMonitoringInterface* m ) |
242 | { | 243 | { |
243 | _mon = m; | 244 | _mon = m; |
244 | qDebug( "ONetwork::setMonitoring(): Installed monitoring driver '%s' on interface '%s'", (const char*) m->name(), name() ); | 245 | qDebug( "ONetwork::setMonitoring(): Installed monitoring driver '%s' on interface '%s'", (const char*) m->name(), name() ); |
245 | } | 246 | } |
246 | 247 | ||
@@ -393,384 +394,416 @@ void OWirelessNetworkInterface::init() | |||
393 | 394 | ||
394 | QString OWirelessNetworkInterface::associatedAP() const | 395 | QString OWirelessNetworkInterface::associatedAP() const |
395 | { | 396 | { |
396 | //FIXME: use OMacAddress | 397 | //FIXME: use OMacAddress |
397 | QString mac; | 398 | QString mac; |
398 | 399 | ||
399 | if ( ioctl( SIOCGIWAP ) ) | 400 | if ( ioctl( SIOCGIWAP ) ) |
400 | { | 401 | { |
401 | mac.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", | 402 | mac.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", |
402 | _ifr.ifr_hwaddr.sa_data[0]&0xff, | 403 | _ifr.ifr_hwaddr.sa_data[0]&0xff, |
403 | _ifr.ifr_hwaddr.sa_data[1]&0xff, | 404 | _ifr.ifr_hwaddr.sa_data[1]&0xff, |
404 | _ifr.ifr_hwaddr.sa_data[2]&0xff, | 405 | _ifr.ifr_hwaddr.sa_data[2]&0xff, |
405 | _ifr.ifr_hwaddr.sa_data[3]&0xff, | 406 | _ifr.ifr_hwaddr.sa_data[3]&0xff, |
406 | _ifr.ifr_hwaddr.sa_data[4]&0xff, | 407 | _ifr.ifr_hwaddr.sa_data[4]&0xff, |
407 | _ifr.ifr_hwaddr.sa_data[5]&0xff ); | 408 | _ifr.ifr_hwaddr.sa_data[5]&0xff ); |
408 | } | 409 | } |
409 | else | 410 | else |
410 | { | 411 | { |
411 | mac = "<Unknown>"; | 412 | mac = "<Unknown>"; |
412 | } | 413 | } |
413 | return mac; | 414 | return mac; |
414 | } | 415 | } |
415 | 416 | ||
416 | 417 | ||
417 | void OWirelessNetworkInterface::buildChannelList() | 418 | void OWirelessNetworkInterface::buildChannelList() |
418 | { | 419 | { |
419 | // IEEE802.11(b) radio frequency channels | 420 | // IEEE802.11(b) radio frequency channels |
420 | struct iw_range range; | 421 | struct iw_range range; |
421 | 422 | ||
422 | //ML: If you listen carefully enough, you can hear lots of WLAN drivers suck | 423 | //ML: If you listen carefully enough, you can hear lots of WLAN drivers suck |
423 | //ML: The HostAP drivers need more than sizeof struct_iw range to complete | 424 | //ML: The HostAP drivers need more than sizeof struct_iw range to complete |
424 | //ML: SIOCGIWRANGE otherwise they fail with "Invalid Argument Length". | 425 | //ML: SIOCGIWRANGE otherwise they fail with "Invalid Argument Length". |
425 | //ML: The Wlan-NG drivers on the otherside fail (segfault!) if you allocate | 426 | //ML: The Wlan-NG drivers on the otherside fail (segfault!) if you allocate |
426 | //ML: _too much_ space. This is damn shitty crap *sigh* | 427 | //ML: _too much_ space. This is damn shitty crap *sigh* |
427 | 428 | ||
428 | _iwr.u.data.pointer = (char*) ⦥ | 429 | _iwr.u.data.pointer = (char*) ⦥ |
429 | _iwr.u.data.length = IW_MAX_FREQUENCIES; //sizeof range; | 430 | _iwr.u.data.length = IW_MAX_FREQUENCIES; //sizeof range; |
430 | _iwr.u.data.flags = 0; | 431 | _iwr.u.data.flags = 0; |
431 | 432 | ||
432 | if ( !wioctl( SIOCGIWRANGE ) ) | 433 | if ( !wioctl( SIOCGIWRANGE ) ) |
433 | { | 434 | { |
434 | qDebug( "OWirelessNetworkInterface::buildChannelList(): SIOCGIWRANGE failed (%s) - defaulting to 11 channels", strerror( errno ) ); | 435 | qDebug( "OWirelessNetworkInterface::buildChannelList(): SIOCGIWRANGE failed (%s) - defaulting to 11 channels", strerror( errno ) ); |
435 | _channels.insert( 2412, 1 ); // 2.412 GHz | 436 | _channels.insert( 2412, 1 ); // 2.412 GHz |
436 | _channels.insert( 2417, 2 ); // 2.417 GHz | 437 | _channels.insert( 2417, 2 ); // 2.417 GHz |
437 | _channels.insert( 2422, 3 ); // 2.422 GHz | 438 | _channels.insert( 2422, 3 ); // 2.422 GHz |
438 | _channels.insert( 2427, 4 ); // 2.427 GHz | 439 | _channels.insert( 2427, 4 ); // 2.427 GHz |
439 | _channels.insert( 2432, 5 ); // 2.432 GHz | 440 | _channels.insert( 2432, 5 ); // 2.432 GHz |
440 | _channels.insert( 2437, 6 ); // 2.437 GHz | 441 | _channels.insert( 2437, 6 ); // 2.437 GHz |
441 | _channels.insert( 2442, 7 ); // 2.442 GHz | 442 | _channels.insert( 2442, 7 ); // 2.442 GHz |
442 | _channels.insert( 2447, 8 ); // 2.447 GHz | 443 | _channels.insert( 2447, 8 ); // 2.447 GHz |
443 | _channels.insert( 2452, 9 ); // 2.452 GHz | 444 | _channels.insert( 2452, 9 ); // 2.452 GHz |
444 | _channels.insert( 2457, 10 ); // 2.457 GHz | 445 | _channels.insert( 2457, 10 ); // 2.457 GHz |
445 | _channels.insert( 2462, 11 ); // 2.462 GHz | 446 | _channels.insert( 2462, 11 ); // 2.462 GHz |
446 | } | 447 | } |
447 | else | 448 | else |
448 | { | 449 | { |
449 | qDebug( "OWirelessNetworkInterface::buildChannelList(): Interface %s reported to have %d channels.", name(), range.num_frequency ); | 450 | qDebug( "OWirelessNetworkInterface::buildChannelList(): Interface %s reported to have %d channels.", name(), range.num_frequency ); |
450 | for ( int i = 0; i < range.num_frequency; ++i ) | 451 | for ( int i = 0; i < range.num_frequency; ++i ) |
451 | { | 452 | { |
452 | int freq = (int) ( double( range.freq[i].m ) * pow( 10.0, range.freq[i].e ) / 1000000.0 ); | 453 | int freq = (int) ( double( range.freq[i].m ) * pow( 10.0, range.freq[i].e ) / 1000000.0 ); |
453 | _channels.insert( freq, i+1 ); | 454 | _channels.insert( freq, i+1 ); |
454 | } | 455 | } |
455 | } | 456 | } |
456 | qDebug( "OWirelessNetworkInterface::buildChannelList(): Channel list constructed." ); | 457 | qDebug( "OWirelessNetworkInterface::buildChannelList(): Channel list constructed." ); |
457 | } | 458 | } |
458 | 459 | ||
459 | 460 | ||
460 | void OWirelessNetworkInterface::buildPrivateList() | 461 | void OWirelessNetworkInterface::buildPrivateList() |
461 | { | 462 | { |
462 | qDebug( "OWirelessNetworkInterface::buildPrivateList()" ); | 463 | qDebug( "OWirelessNetworkInterface::buildPrivateList()" ); |
463 | 464 | ||
464 | struct iw_priv_args priv[IW_MAX_PRIV_DEF]; | 465 | struct iw_priv_args priv[IW_MAX_PRIV_DEF]; |
465 | 466 | ||
466 | _iwr.u.data.pointer = (char*) &priv; | 467 | _iwr.u.data.pointer = (char*) &priv; |
467 | _iwr.u.data.length = IW_MAX_PRIV_DEF; // length in terms of number of (sizeof iw_priv_args), not (sizeof iw_priv_args) itself | 468 | _iwr.u.data.length = IW_MAX_PRIV_DEF; // length in terms of number of (sizeof iw_priv_args), not (sizeof iw_priv_args) itself |
468 | _iwr.u.data.flags = 0; | 469 | _iwr.u.data.flags = 0; |
469 | 470 | ||
470 | if ( !wioctl( SIOCGIWPRIV ) ) | 471 | if ( !wioctl( SIOCGIWPRIV ) ) |
471 | { | 472 | { |
472 | qDebug( "OWirelessNetworkInterface::buildPrivateList(): SIOCGIWPRIV failed (%s) - can't get private ioctl information.", strerror( errno ) ); | 473 | qDebug( "OWirelessNetworkInterface::buildPrivateList(): SIOCGIWPRIV failed (%s) - can't get private ioctl information.", strerror( errno ) ); |
473 | return; | 474 | return; |
474 | } | 475 | } |
475 | 476 | ||
476 | for ( int i = 0; i < _iwr.u.data.length; ++i ) | 477 | for ( int i = 0; i < _iwr.u.data.length; ++i ) |
477 | { | 478 | { |
478 | new OPrivateIOCTL( this, priv[i].name, priv[i].cmd, priv[i].get_args, priv[i].set_args ); | 479 | new OPrivateIOCTL( this, priv[i].name, priv[i].cmd, priv[i].get_args, priv[i].set_args ); |
479 | } | 480 | } |
480 | qDebug( "OWirelessNetworkInterface::buildPrivateList(): Private IOCTL list constructed." ); | 481 | qDebug( "OWirelessNetworkInterface::buildPrivateList(): Private IOCTL list constructed." ); |
481 | } | 482 | } |
482 | 483 | ||
483 | 484 | ||
484 | int OWirelessNetworkInterface::channel() const | 485 | int OWirelessNetworkInterface::channel() const |
485 | { | 486 | { |
486 | //FIXME: When monitoring enabled, then use it | 487 | //FIXME: When monitoring enabled, then use it |
487 | //FIXME: to gather the current RF channel | 488 | //FIXME: to gather the current RF channel |
488 | //FIXME: Until then, get active channel from hopper. | 489 | //FIXME: Until then, get active channel from hopper. |
489 | if ( _hopper && _hopper->isActive() ) | 490 | if ( _hopper && _hopper->isActive() ) |
490 | return _hopper->channel(); | 491 | return _hopper->channel(); |
491 | 492 | ||
492 | if ( !wioctl( SIOCGIWFREQ ) ) | 493 | if ( !wioctl( SIOCGIWFREQ ) ) |
493 | { | 494 | { |
494 | return -1; | 495 | return -1; |
495 | } | 496 | } |
496 | else | 497 | else |
497 | { | 498 | { |
498 | return _channels[ static_cast<int>(double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000) ]; | 499 | return _channels[ static_cast<int>(double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000) ]; |
499 | } | 500 | } |
500 | } | 501 | } |
501 | 502 | ||
502 | 503 | ||
503 | void OWirelessNetworkInterface::setChannel( int c ) const | 504 | void OWirelessNetworkInterface::setChannel( int c ) const |
504 | { | 505 | { |
505 | if ( !_mon ) | 506 | if ( !_mon ) |
506 | { | 507 | { |
507 | memset( &_iwr, 0, sizeof( iwreqstruct ) ); | 508 | memset( &_iwr, 0, sizeof( iwreqstruct ) ); |
508 | _iwr.u.freq.m = c; | 509 | _iwr.u.freq.m = c; |
509 | _iwr.u.freq.e = 0; | 510 | _iwr.u.freq.e = 0; |
510 | wioctl( SIOCSIWFREQ ); | 511 | wioctl( SIOCSIWFREQ ); |
511 | } | 512 | } |
512 | else | 513 | else |
513 | { | 514 | { |
514 | _mon->setChannel( c ); | 515 | _mon->setChannel( c ); |
515 | } | 516 | } |
516 | } | 517 | } |
517 | 518 | ||
518 | 519 | ||
519 | double OWirelessNetworkInterface::frequency() const | 520 | double OWirelessNetworkInterface::frequency() const |
520 | { | 521 | { |
521 | if ( !wioctl( SIOCGIWFREQ ) ) | 522 | if ( !wioctl( SIOCGIWFREQ ) ) |
522 | { | 523 | { |
523 | return -1.0; | 524 | return -1.0; |
524 | } | 525 | } |
525 | else | 526 | else |
526 | { | 527 | { |
527 | return double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000000.0; | 528 | return double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000000.0; |
528 | } | 529 | } |
529 | } | 530 | } |
530 | 531 | ||
531 | 532 | ||
532 | int OWirelessNetworkInterface::channels() const | 533 | int OWirelessNetworkInterface::channels() const |
533 | { | 534 | { |
534 | return _channels.count(); | 535 | return _channels.count(); |
535 | } | 536 | } |
536 | 537 | ||
537 | 538 | ||
538 | void OWirelessNetworkInterface::setChannelHopping( int interval ) | 539 | void OWirelessNetworkInterface::setChannelHopping( int interval ) |
539 | { | 540 | { |
540 | if ( !_hopper ) _hopper = new OChannelHopper( this ); | 541 | if ( !_hopper ) _hopper = new OChannelHopper( this ); |
541 | _hopper->setInterval( interval ); | 542 | _hopper->setInterval( interval ); |
542 | //FIXME: When and by whom will the channel hopper be deleted? | 543 | //FIXME: When and by whom will the channel hopper be deleted? |
543 | //TODO: rely on QObject hierarchy | 544 | //TODO: rely on QObject hierarchy |
544 | } | 545 | } |
545 | 546 | ||
546 | 547 | ||
547 | int OWirelessNetworkInterface::channelHopping() const | 548 | int OWirelessNetworkInterface::channelHopping() const |
548 | { | 549 | { |
549 | return _hopper->interval(); | 550 | return _hopper->interval(); |
550 | } | 551 | } |
551 | 552 | ||
552 | 553 | ||
553 | void OWirelessNetworkInterface::setMonitorMode( bool b ) | 554 | void OWirelessNetworkInterface::setMonitorMode( bool b ) |
554 | { | 555 | { |
555 | if ( _mon ) | 556 | if ( _mon ) |
556 | _mon->setEnabled( b ); | 557 | _mon->setEnabled( b ); |
557 | else | 558 | else |
558 | qDebug( "ONetwork(): can't switch monitor mode without installed monitoring interface" ); | 559 | qDebug( "ONetwork(): can't switch monitor mode without installed monitoring interface" ); |
559 | } | 560 | } |
560 | 561 | ||
561 | 562 | ||
562 | bool OWirelessNetworkInterface::monitorMode() const | 563 | bool OWirelessNetworkInterface::monitorMode() const |
563 | { | 564 | { |
564 | return _mon ? _mon->enabled() : false; | 565 | return _mon ? _mon->enabled() : false; |
565 | } | 566 | } |
566 | 567 | ||
567 | 568 | ||
568 | QString OWirelessNetworkInterface::nickName() const | 569 | QString OWirelessNetworkInterface::nickName() const |
569 | { | 570 | { |
570 | char str[IW_ESSID_MAX_SIZE]; | 571 | char str[IW_ESSID_MAX_SIZE]; |
571 | _iwr.u.data.pointer = &str[0]; | 572 | _iwr.u.data.pointer = &str[0]; |
572 | _iwr.u.data.length = IW_ESSID_MAX_SIZE; | 573 | _iwr.u.data.length = IW_ESSID_MAX_SIZE; |
573 | if ( !wioctl( SIOCGIWNICKN ) ) | 574 | if ( !wioctl( SIOCGIWNICKN ) ) |
574 | { | 575 | { |
575 | return "<unknown>"; | 576 | return "<unknown>"; |
576 | } | 577 | } |
577 | else | 578 | else |
578 | { | 579 | { |
579 | str[_iwr.u.data.length] = 0x0; // some drivers (e.g. wlan-ng) don't zero-terminate the string | 580 | str[_iwr.u.data.length] = 0x0; // some drivers (e.g. wlan-ng) don't zero-terminate the string |
580 | return str; | 581 | return str; |
581 | } | 582 | } |
582 | } | 583 | } |
583 | 584 | ||
584 | 585 | ||
586 | void OWirelessNetworkInterface::setPrivate( const QString& call, int numargs, ... ) | ||
587 | { | ||
588 | OPrivateIOCTL* priv = static_cast<OPrivateIOCTL*>( child( (const char*) call ) ); | ||
589 | if ( !priv ) | ||
590 | { | ||
591 | qDebug( "OWirelessNetworkInterface::setPrivate(): interface '%s' does not support private ioctl '%s'", name(), (const char*) call ); | ||
592 | return; | ||
593 | } | ||
594 | if ( priv->numberSetArgs() != numargs ) | ||
595 | { | ||
596 | qDebug( "OWirelessNetworkInterface::setPrivate(): parameter count not matching. '%s' expects %d arguments, but got %d", (const char*) call, priv->numberSetArgs(), numargs ); | ||
597 | return; | ||
598 | } | ||
599 | |||
600 | qDebug( "OWirelessNetworkInterface::setPrivate(): about to call '%s' on interface '%s'", (const char*) call, name() ); | ||
601 | memset( &_iwr, 0, sizeof _iwr ); | ||
602 | va_list argp; | ||
603 | va_start( argp, numargs ); | ||
604 | for ( int i = 0; i < numargs; ++i ) | ||
605 | { | ||
606 | priv->setParameter( i, va_arg( argp, int ) ); | ||
607 | } | ||
608 | va_end( argp ); | ||
609 | priv->invoke(); | ||
610 | } | ||
611 | |||
612 | |||
613 | void OWirelessNetworkInterface::getPrivate( const QString& call ) | ||
614 | { | ||
615 | } | ||
616 | |||
617 | |||
585 | QString OWirelessNetworkInterface::SSID() const | 618 | QString OWirelessNetworkInterface::SSID() const |
586 | { | 619 | { |
587 | char str[IW_ESSID_MAX_SIZE]; | 620 | char str[IW_ESSID_MAX_SIZE]; |
588 | _iwr.u.essid.pointer = &str[0]; | 621 | _iwr.u.essid.pointer = &str[0]; |
589 | _iwr.u.essid.length = IW_ESSID_MAX_SIZE; | 622 | _iwr.u.essid.length = IW_ESSID_MAX_SIZE; |
590 | if ( !wioctl( SIOCGIWESSID ) ) | 623 | if ( !wioctl( SIOCGIWESSID ) ) |
591 | { | 624 | { |
592 | return "<unknown>"; | 625 | return "<unknown>"; |
593 | } | 626 | } |
594 | else | 627 | else |
595 | { | 628 | { |
596 | return str; | 629 | return str; |
597 | } | 630 | } |
598 | } | 631 | } |
599 | 632 | ||
600 | 633 | ||
601 | void OWirelessNetworkInterface::setSSID( const QString& ssid ) | 634 | void OWirelessNetworkInterface::setSSID( const QString& ssid ) |
602 | { | 635 | { |
603 | _iwr.u.essid.pointer = const_cast<char*>( (const char*) ssid ); | 636 | _iwr.u.essid.pointer = const_cast<char*>( (const char*) ssid ); |
604 | _iwr.u.essid.length = ssid.length(); | 637 | _iwr.u.essid.length = ssid.length(); |
605 | wioctl( SIOCSIWESSID ); | 638 | wioctl( SIOCSIWESSID ); |
606 | } | 639 | } |
607 | 640 | ||
608 | 641 | ||
609 | bool OWirelessNetworkInterface::wioctl( int call, iwreqstruct& iwreq ) const | 642 | bool OWirelessNetworkInterface::wioctl( int call, iwreqstruct& iwreq ) const |
610 | { | 643 | { |
611 | int result = ::ioctl( _sfd, call, &iwreq ); | 644 | int result = ::ioctl( _sfd, call, &iwreq ); |
612 | if ( result == -1 ) | 645 | if ( result == -1 ) |
613 | qDebug( "ONetworkInterface::wioctl(): Call %d - Status: Failed: %d (%s)", call, result, strerror( errno ) ); | 646 | qDebug( "ONetworkInterface::wioctl(): Call %d - Status: Failed: %d (%s)", call, result, strerror( errno ) ); |
614 | else | 647 | else |
615 | qDebug( "ONetworkInterface::wioctl(): Call %d - Status: Ok.", call ); | 648 | qDebug( "ONetworkInterface::wioctl(): Call %d - Status: Ok.", call ); |
616 | return ( result != -1 ); | 649 | return ( result != -1 ); |
617 | } | 650 | } |
618 | 651 | ||
619 | 652 | ||
620 | bool OWirelessNetworkInterface::wioctl( int call ) const | 653 | bool OWirelessNetworkInterface::wioctl( int call ) const |
621 | { | 654 | { |
622 | strcpy( _iwr.ifr_name, name() ); | 655 | strcpy( _iwr.ifr_name, name() ); |
623 | return wioctl( call, _iwr ); | 656 | return wioctl( call, _iwr ); |
624 | } | 657 | } |
625 | 658 | ||
626 | 659 | ||
627 | /*====================================================================================== | 660 | /*====================================================================================== |
628 | * OMonitoringInterface | 661 | * OMonitoringInterface |
629 | *======================================================================================*/ | 662 | *======================================================================================*/ |
630 | 663 | ||
631 | OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface ) | 664 | OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface ) |
632 | :_enabled( false ), _if( static_cast<OWirelessNetworkInterface*>( iface ) ) | 665 | :_enabled( false ), _if( static_cast<OWirelessNetworkInterface*>( iface ) ) |
633 | { | 666 | { |
634 | } | 667 | } |
635 | 668 | ||
636 | 669 | ||
637 | OMonitoringInterface::~OMonitoringInterface() | 670 | OMonitoringInterface::~OMonitoringInterface() |
638 | { | 671 | { |
639 | } | 672 | } |
640 | 673 | ||
641 | 674 | ||
642 | void OMonitoringInterface::setChannel( int c ) | 675 | void OMonitoringInterface::setChannel( int c ) |
643 | { | 676 | { |
644 | // use standard WE channel switching protocol | 677 | // use standard WE channel switching protocol |
645 | memset( &_if->_iwr, 0, sizeof( iwreqstruct ) ); | 678 | memset( &_if->_iwr, 0, sizeof( iwreqstruct ) ); |
646 | _if->_iwr.u.freq.m = c; | 679 | _if->_iwr.u.freq.m = c; |
647 | _if->_iwr.u.freq.e = 0; | 680 | _if->_iwr.u.freq.e = 0; |
648 | _if->wioctl( SIOCSIWFREQ ); | 681 | _if->wioctl( SIOCSIWFREQ ); |
649 | } | 682 | } |
650 | 683 | ||
651 | 684 | ||
652 | bool OMonitoringInterface::enabled() const | 685 | bool OMonitoringInterface::enabled() const |
653 | { | 686 | { |
654 | return _enabled; | 687 | return _enabled; |
655 | } | 688 | } |
656 | 689 | ||
657 | void OMonitoringInterface::setEnabled( bool b ) | 690 | void OMonitoringInterface::setEnabled( bool b ) |
658 | { | 691 | { |
659 | // open a packet capturer here or leave this to | 692 | // open a packet capturer here or leave this to |
660 | // the client code? | 693 | // the client code? |
661 | 694 | ||
662 | /* | 695 | /* |
663 | 696 | ||
664 | if ( b ) | 697 | if ( b ) |
665 | { | 698 | { |
666 | OPacketCapturer* opcap = new OPacketCapturer(); | 699 | OPacketCapturer* opcap = new OPacketCapturer(); |
667 | opcap->open( _if->name() ); | 700 | opcap->open( _if->name() ); |
668 | } | 701 | } |
669 | */ | 702 | */ |
670 | 703 | ||
671 | _enabled = b; | 704 | _enabled = b; |
672 | 705 | ||
673 | } | 706 | } |
674 | 707 | ||
675 | /*====================================================================================== | 708 | /*====================================================================================== |
676 | * OCiscoMonitoringInterface | 709 | * OCiscoMonitoringInterface |
677 | *======================================================================================*/ | 710 | *======================================================================================*/ |
678 | 711 | ||
679 | OCiscoMonitoringInterface::OCiscoMonitoringInterface( ONetworkInterface* iface ) | 712 | OCiscoMonitoringInterface::OCiscoMonitoringInterface( ONetworkInterface* iface ) |
680 | :OMonitoringInterface( iface ) | 713 | :OMonitoringInterface( iface ) |
681 | { | 714 | { |
682 | iface->setMonitoring( this ); | 715 | iface->setMonitoring( this ); |
683 | } | 716 | } |
684 | 717 | ||
685 | 718 | ||
686 | OCiscoMonitoringInterface::~OCiscoMonitoringInterface() | 719 | OCiscoMonitoringInterface::~OCiscoMonitoringInterface() |
687 | { | 720 | { |
688 | } | 721 | } |
689 | 722 | ||
690 | 723 | ||
691 | void OCiscoMonitoringInterface::setEnabled( bool b ) | 724 | void OCiscoMonitoringInterface::setEnabled( bool b ) |
692 | { | 725 | { |
693 | QString fname; | 726 | QString fname; |
694 | fname.sprintf( "/proc/driver/aironet/%s", (const char*) _if->name() ); | 727 | fname.sprintf( "/proc/driver/aironet/%s", (const char*) _if->name() ); |
695 | QFile f( fname ); | 728 | QFile f( fname ); |
696 | if ( !f.exists() ) return; | 729 | if ( !f.exists() ) return; |
697 | 730 | ||
698 | if ( f.open( IO_WriteOnly ) ) | 731 | if ( f.open( IO_WriteOnly ) ) |
699 | { | 732 | { |
700 | QTextStream s( &f ); | 733 | QTextStream s( &f ); |
701 | s << "Mode: r"; | 734 | s << "Mode: r"; |
702 | s << "Mode: y"; | 735 | s << "Mode: y"; |
703 | s << "XmitPower: 1"; | 736 | s << "XmitPower: 1"; |
704 | 737 | ||
705 | OMonitoringInterface::setEnabled( b ); | 738 | OMonitoringInterface::setEnabled( b ); |
706 | 739 | ||
707 | } | 740 | } |
708 | 741 | ||
709 | // flushing and closing will be done automatically when f goes out of scope | 742 | // flushing and closing will be done automatically when f goes out of scope |
710 | } | 743 | } |
711 | 744 | ||
712 | 745 | ||
713 | QString OCiscoMonitoringInterface::name() const | 746 | QString OCiscoMonitoringInterface::name() const |
714 | { | 747 | { |
715 | return "cisco"; | 748 | return "cisco"; |
716 | } | 749 | } |
717 | 750 | ||
718 | 751 | ||
719 | void OCiscoMonitoringInterface::setChannel( int ) | 752 | void OCiscoMonitoringInterface::setChannel( int ) |
720 | { | 753 | { |
721 | // cisco devices automatically switch channels when in monitor mode | 754 | // cisco devices automatically switch channels when in monitor mode |
722 | } | 755 | } |
723 | 756 | ||
724 | 757 | ||
725 | /*====================================================================================== | 758 | /*====================================================================================== |
726 | * OWlanNGMonitoringInterface | 759 | * OWlanNGMonitoringInterface |
727 | *======================================================================================*/ | 760 | *======================================================================================*/ |
728 | 761 | ||
729 | 762 | ||
730 | OWlanNGMonitoringInterface::OWlanNGMonitoringInterface( ONetworkInterface* iface ) | 763 | OWlanNGMonitoringInterface::OWlanNGMonitoringInterface( ONetworkInterface* iface ) |
731 | :OMonitoringInterface( iface ) | 764 | :OMonitoringInterface( iface ) |
732 | { | 765 | { |
733 | iface->setMonitoring( this ); | 766 | iface->setMonitoring( this ); |
734 | } | 767 | } |
735 | 768 | ||
736 | 769 | ||
737 | OWlanNGMonitoringInterface::~OWlanNGMonitoringInterface() | 770 | OWlanNGMonitoringInterface::~OWlanNGMonitoringInterface() |
738 | { | 771 | { |
739 | } | 772 | } |
740 | 773 | ||
741 | 774 | ||
742 | void OWlanNGMonitoringInterface::setEnabled( bool b ) | 775 | void OWlanNGMonitoringInterface::setEnabled( bool b ) |
743 | { | 776 | { |
744 | //FIXME: do nothing if its already in the same mode | 777 | //FIXME: do nothing if its already in the same mode |
745 | 778 | ||
746 | QString enable = b ? "true" : "false"; | 779 | QString enable = b ? "true" : "false"; |
747 | QString cmd; | 780 | QString cmd; |
748 | cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s", (const char*) _if->name(), 1, (const char*) enable ); | 781 | cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s", (const char*) _if->name(), 1, (const char*) enable ); |
749 | system( cmd ); | 782 | system( cmd ); |
750 | 783 | ||
751 | OMonitoringInterface::setEnabled( b ); | 784 | OMonitoringInterface::setEnabled( b ); |
752 | } | 785 | } |
753 | 786 | ||
754 | 787 | ||
755 | QString OWlanNGMonitoringInterface::name() const | 788 | QString OWlanNGMonitoringInterface::name() const |
756 | { | 789 | { |
757 | return "wlan-ng"; | 790 | return "wlan-ng"; |
758 | } | 791 | } |
759 | 792 | ||
760 | 793 | ||
761 | void OWlanNGMonitoringInterface::setChannel( int ) | 794 | void OWlanNGMonitoringInterface::setChannel( int ) |
762 | { | 795 | { |
763 | // wlan-ng devices automatically switch channels when in monitor mode | 796 | // wlan-ng devices automatically switch channels when in monitor mode |
764 | } | 797 | } |
765 | 798 | ||
766 | 799 | ||
767 | /*====================================================================================== | 800 | /*====================================================================================== |
768 | * OHostAPMonitoringInterface | 801 | * OHostAPMonitoringInterface |
769 | *======================================================================================*/ | 802 | *======================================================================================*/ |
770 | 803 | ||
771 | OHostAPMonitoringInterface::OHostAPMonitoringInterface( ONetworkInterface* iface ) | 804 | OHostAPMonitoringInterface::OHostAPMonitoringInterface( ONetworkInterface* iface ) |
772 | :OMonitoringInterface( iface ) | 805 | :OMonitoringInterface( iface ) |
773 | { | 806 | { |
774 | iface->setMonitoring( this ); | 807 | iface->setMonitoring( this ); |
775 | } | 808 | } |
776 | 809 | ||
diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h index acf2f69..7c70873 100644 --- a/libopie2/opienet/onetwork.h +++ b/libopie2/opienet/onetwork.h | |||
@@ -1,326 +1,331 @@ | |||
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 <qvaluelist.h> | 39 | #include <qvaluelist.h> |
40 | #include <qdict.h> | 40 | #include <qdict.h> |
41 | #include <qmap.h> | 41 | #include <qmap.h> |
42 | #include <qobject.h> | 42 | #include <qobject.h> |
43 | #include <qhostaddress.h> | 43 | #include <qhostaddress.h> |
44 | 44 | ||
45 | /* OPIE */ | 45 | /* OPIE */ |
46 | 46 | ||
47 | #include <opie2/onetutils.h> | 47 | #include <opie2/onetutils.h> |
48 | 48 | ||
49 | #ifndef IFNAMSIZ | 49 | #ifndef IFNAMSIZ |
50 | #define IFNAMSIZ 16 | 50 | #define IFNAMSIZ 16 |
51 | #endif | 51 | #endif |
52 | #ifndef IW_MAX_PRIV_DEF | 52 | #ifndef IW_MAX_PRIV_DEF |
53 | #define IW_MAX_PRIV_DEF 128 | 53 | #define IW_MAX_PRIV_DEF 128 |
54 | #endif | 54 | #endif |
55 | 55 | ||
56 | // ML: Yeah, I hate to include kernel headers, but it's necessary here | 56 | // ML: Yeah, I hate to include kernel headers, but it's necessary here |
57 | // ML: Here comes an ugly hack to prevent <linux/wireless.h> including <linux/if.h> | 57 | // ML: Here comes an ugly hack to prevent <linux/wireless.h> including <linux/if.h> |
58 | // ML: which conflicts with the user header <net/if.h> | 58 | // ML: which conflicts with the user header <net/if.h> |
59 | // ML: We really a user header for the Wireless Extensions, something like <net/wireless.h> | 59 | // ML: We really a user header for the Wireless Extensions, something like <net/wireless.h> |
60 | // ML: I will drop Jean an mail on that subject | 60 | // ML: I will drop Jean an mail on that subject |
61 | 61 | ||
62 | #include <net/if.h> | 62 | #include <net/if.h> |
63 | #define _LINUX_IF_H | 63 | #define _LINUX_IF_H |
64 | #include <linux/wireless.h> | 64 | #include <linux/wireless.h> |
65 | 65 | ||
66 | #ifndef SIOCIWFIRSTPRIV | 66 | #ifndef SIOCIWFIRSTPRIV |
67 | #define SIOCIWFIRSTPRIV SIOCDEVPRIVATE | 67 | #define SIOCIWFIRSTPRIV SIOCDEVPRIVATE |
68 | #endif | 68 | #endif |
69 | 69 | ||
70 | class ONetworkInterface; | 70 | class ONetworkInterface; |
71 | class OWirelessNetworkInterface; | 71 | class OWirelessNetworkInterface; |
72 | class OChannelHopper; | 72 | class OChannelHopper; |
73 | class OMonitoringInterface; | 73 | class OMonitoringInterface; |
74 | 74 | ||
75 | typedef struct ifreq ifreqstruct; | 75 | typedef struct ifreq ifreqstruct; |
76 | typedef struct iwreq iwreqstruct; | 76 | typedef struct iwreq iwreqstruct; |
77 | typedef struct iw_event iweventstruct; | 77 | typedef struct iw_event iweventstruct; |
78 | typedef struct iw_freq iwfreqstruct; | 78 | typedef struct iw_freq iwfreqstruct; |
79 | typedef struct iw_priv_args iwprivargsstruct; | 79 | typedef struct iw_priv_args iwprivargsstruct; |
80 | typedef struct iw_range iwrangestruct; | 80 | typedef struct iw_range iwrangestruct; |
81 | 81 | ||
82 | /*====================================================================================== | 82 | /*====================================================================================== |
83 | * ONetwork | 83 | * ONetwork |
84 | *======================================================================================*/ | 84 | *======================================================================================*/ |
85 | 85 | ||
86 | class ONetwork : public QObject | 86 | class ONetwork : public QObject |
87 | { | 87 | { |
88 | Q_OBJECT | 88 | Q_OBJECT |
89 | 89 | ||
90 | public: | 90 | public: |
91 | typedef QDict<ONetworkInterface> InterfaceMap; | 91 | typedef QDict<ONetworkInterface> InterfaceMap; |
92 | typedef QDictIterator<ONetworkInterface> InterfaceIterator; | 92 | typedef QDictIterator<ONetworkInterface> InterfaceIterator; |
93 | 93 | ||
94 | public: | 94 | public: |
95 | static ONetwork* instance(); | 95 | static ONetwork* instance(); |
96 | InterfaceIterator iterator() const; | 96 | InterfaceIterator iterator() const; |
97 | bool isWirelessInterface( const char* ) const; | 97 | bool isWirelessInterface( const char* ) const; |
98 | ONetworkInterface* interface( QString ) const; | 98 | ONetworkInterface* interface( QString ) const; |
99 | 99 | ||
100 | protected: | 100 | protected: |
101 | ONetwork(); | 101 | ONetwork(); |
102 | void synchronize(); | 102 | void synchronize(); |
103 | 103 | ||
104 | private: | 104 | private: |
105 | static ONetwork* _instance; | 105 | static ONetwork* _instance; |
106 | InterfaceMap _interfaces; | 106 | InterfaceMap _interfaces; |
107 | }; | 107 | }; |
108 | 108 | ||
109 | 109 | ||
110 | /*====================================================================================== | 110 | /*====================================================================================== |
111 | * ONetworkInterface | 111 | * ONetworkInterface |
112 | *======================================================================================*/ | 112 | *======================================================================================*/ |
113 | 113 | ||
114 | class ONetworkInterface : public QObject | 114 | class ONetworkInterface : public QObject |
115 | { | 115 | { |
116 | friend class OMonitoringInterface; | 116 | friend class OMonitoringInterface; |
117 | friend class OCiscoMonitoringInterface; | 117 | friend class OCiscoMonitoringInterface; |
118 | friend class OWlanNGMonitoringInterface; | 118 | friend class OWlanNGMonitoringInterface; |
119 | friend class OHostAPMonitoringInterface; | 119 | friend class OHostAPMonitoringInterface; |
120 | friend class OOrinocoMonitoringInterface; | 120 | friend class OOrinocoMonitoringInterface; |
121 | 121 | ||
122 | public: | 122 | public: |
123 | ONetworkInterface( QObject* parent, const char* name ); | 123 | ONetworkInterface( QObject* parent, const char* name ); |
124 | virtual ~ONetworkInterface(); | 124 | virtual ~ONetworkInterface(); |
125 | 125 | ||
126 | void setMonitoring( OMonitoringInterface* ); | 126 | void setMonitoring( OMonitoringInterface* ); |
127 | OMonitoringInterface* monitoring() const; | 127 | OMonitoringInterface* monitoring() const; |
128 | bool setPromiscuousMode( bool ); | 128 | bool setPromiscuousMode( bool ); |
129 | bool promiscuousMode() const; | 129 | bool promiscuousMode() const; |
130 | bool setUp( bool ); | 130 | bool setUp( bool ); |
131 | bool isUp() const; | 131 | bool isUp() const; |
132 | bool isLoopback() const; | 132 | bool isLoopback() const; |
133 | bool isWireless() const; | 133 | bool isWireless() const; |
134 | QString ipV4Address() const; | 134 | QString ipV4Address() const; |
135 | OMacAddress macAddress() const; | 135 | OMacAddress macAddress() const; |
136 | 136 | ||
137 | protected: | 137 | protected: |
138 | const int _sfd; | 138 | const int _sfd; |
139 | mutable ifreqstruct _ifr; | 139 | mutable ifreqstruct _ifr; |
140 | OMonitoringInterface* _mon; | 140 | OMonitoringInterface* _mon; |
141 | 141 | ||
142 | protected: | 142 | protected: |
143 | ifreqstruct& ifr() const; | 143 | ifreqstruct& ifr() const; |
144 | virtual void init(); | 144 | virtual void init(); |
145 | bool ioctl( int call ) const; | 145 | bool ioctl( int call ) const; |
146 | bool ioctl( int call, ifreqstruct& ) const; | 146 | bool ioctl( int call, ifreqstruct& ) const; |
147 | }; | 147 | }; |
148 | 148 | ||
149 | /*====================================================================================== | 149 | /*====================================================================================== |
150 | * OChannelHopper | 150 | * OChannelHopper |
151 | *======================================================================================*/ | 151 | *======================================================================================*/ |
152 | 152 | ||
153 | class OChannelHopper : public QObject | 153 | class OChannelHopper : public QObject |
154 | { | 154 | { |
155 | public: | 155 | public: |
156 | OChannelHopper( OWirelessNetworkInterface* ); | 156 | OChannelHopper( OWirelessNetworkInterface* ); |
157 | virtual ~OChannelHopper(); | 157 | virtual ~OChannelHopper(); |
158 | bool isActive() const; | 158 | bool isActive() const; |
159 | int channel() const; | 159 | int channel() const; |
160 | virtual void timerEvent( QTimerEvent* ); | 160 | virtual void timerEvent( QTimerEvent* ); |
161 | void setInterval( int ); | 161 | void setInterval( int ); |
162 | int interval() const; | 162 | int interval() const; |
163 | 163 | ||
164 | private: | 164 | private: |
165 | OWirelessNetworkInterface* _iface; | 165 | OWirelessNetworkInterface* _iface; |
166 | int _interval; | 166 | int _interval; |
167 | int _tid; | 167 | int _tid; |
168 | QValueList<int> _channels; | 168 | QValueList<int> _channels; |
169 | QValueList<int>::Iterator _channel; | 169 | QValueList<int>::Iterator _channel; |
170 | 170 | ||
171 | }; | 171 | }; |
172 | 172 | ||
173 | 173 | ||
174 | /*====================================================================================== | 174 | /*====================================================================================== |
175 | * OWirelessNetworkInterface | 175 | * OWirelessNetworkInterface |
176 | *======================================================================================*/ | 176 | *======================================================================================*/ |
177 | 177 | ||
178 | class OWirelessNetworkInterface : public ONetworkInterface | 178 | class OWirelessNetworkInterface : public ONetworkInterface |
179 | { | 179 | { |
180 | friend class OMonitoringInterface; | 180 | friend class OMonitoringInterface; |
181 | friend class OCiscoMonitoringInterface; | 181 | friend class OCiscoMonitoringInterface; |
182 | friend class OWlanNGMonitoringInterface; | 182 | friend class OWlanNGMonitoringInterface; |
183 | friend class OHostAPMonitoringInterface; | 183 | friend class OHostAPMonitoringInterface; |
184 | friend class OOrinocoMonitoringInterface; | 184 | friend class OOrinocoMonitoringInterface; |
185 | 185 | ||
186 | friend class OPrivateIOCTL; | ||
187 | |||
186 | public: | 188 | public: |
187 | enum Mode { AdHoc, Managed, Monitor }; | 189 | enum Mode { AdHoc, Managed, Monitor }; |
188 | 190 | ||
189 | OWirelessNetworkInterface( QObject* parent, const char* name ); | 191 | OWirelessNetworkInterface( QObject* parent, const char* name ); |
190 | virtual ~OWirelessNetworkInterface(); | 192 | virtual ~OWirelessNetworkInterface(); |
191 | 193 | ||
192 | virtual void setChannel( int ) const; | 194 | virtual void setChannel( int ) const; |
193 | virtual int channel() const; | 195 | virtual int channel() const; |
194 | virtual double frequency() const; | 196 | virtual double frequency() const; |
195 | virtual int channels() const; | 197 | virtual int channels() const; |
196 | //virtual double frequency(int) const; | 198 | //virtual double frequency(int) const; |
197 | 199 | ||
198 | virtual void setMode( Mode ) {}; | 200 | virtual void setMode( Mode ) {}; |
199 | virtual bool mode() const {}; | 201 | virtual bool mode() const {}; |
200 | 202 | ||
201 | virtual void setMonitorMode( bool ); | 203 | virtual void setMonitorMode( bool ); |
202 | virtual bool monitorMode() const; | 204 | virtual bool monitorMode() const; |
203 | 205 | ||
204 | virtual void setChannelHopping( int interval = 0 ); | 206 | virtual void setChannelHopping( int interval = 0 ); |
205 | virtual int channelHopping() const; | 207 | virtual int channelHopping() const; |
206 | 208 | ||
207 | virtual void setNickName( const QString& ) {}; | 209 | virtual void setNickName( const QString& ) {}; |
208 | virtual QString nickName() const; | 210 | virtual QString nickName() const; |
209 | 211 | ||
212 | virtual void setPrivate( const QString&, int, ... ); | ||
213 | virtual void getPrivate( const QString& ); | ||
214 | |||
210 | virtual bool isAssociated() const {}; | 215 | virtual bool isAssociated() const {}; |
211 | virtual QString associatedAP() const; | 216 | virtual QString associatedAP() const; |
212 | 217 | ||
213 | virtual void setSSID( const QString& ); | 218 | virtual void setSSID( const QString& ); |
214 | virtual QString SSID() const; | 219 | virtual QString SSID() const; |
215 | 220 | ||
216 | protected: | 221 | protected: |
217 | void buildChannelList(); | 222 | void buildChannelList(); |
218 | void buildPrivateList(); | 223 | void buildPrivateList(); |
219 | virtual void init(); | 224 | virtual void init(); |
220 | iwreqstruct& iwr() const; | 225 | iwreqstruct& iwr() const; |
221 | bool wioctl( int call ) const; | 226 | bool wioctl( int call ) const; |
222 | bool wioctl( int call, iwreqstruct& ) const; | 227 | bool wioctl( int call, iwreqstruct& ) const; |
223 | 228 | ||
224 | protected: | 229 | protected: |
225 | mutable iwreqstruct _iwr; | 230 | mutable iwreqstruct _iwr; |
226 | QMap<int,int> _channels; | 231 | QMap<int,int> _channels; |
227 | 232 | ||
228 | private: | 233 | private: |
229 | OChannelHopper* _hopper; | 234 | OChannelHopper* _hopper; |
230 | }; | 235 | }; |
231 | 236 | ||
232 | 237 | ||
233 | /*====================================================================================== | 238 | /*====================================================================================== |
234 | * OMonitoringInterface | 239 | * OMonitoringInterface |
235 | *======================================================================================*/ | 240 | *======================================================================================*/ |
236 | 241 | ||
237 | 242 | ||
238 | class OMonitoringInterface | 243 | class OMonitoringInterface |
239 | { | 244 | { |
240 | public: | 245 | public: |
241 | OMonitoringInterface(); | 246 | OMonitoringInterface(); |
242 | OMonitoringInterface( ONetworkInterface* ); | 247 | OMonitoringInterface( ONetworkInterface* ); |
243 | virtual ~OMonitoringInterface(); | 248 | virtual ~OMonitoringInterface(); |
244 | 249 | ||
245 | public: | 250 | public: |
246 | virtual void setEnabled( bool ); | 251 | virtual void setEnabled( bool ); |
247 | virtual bool enabled() const; | 252 | virtual bool enabled() const; |
248 | virtual void setChannel( int ); | 253 | virtual void setChannel( int ); |
249 | 254 | ||
250 | virtual QString name() const = 0; | 255 | virtual QString name() const = 0; |
251 | 256 | ||
252 | protected: | 257 | protected: |
253 | bool _enabled; | 258 | bool _enabled; |
254 | const OWirelessNetworkInterface* _if; | 259 | const OWirelessNetworkInterface* _if; |
255 | 260 | ||
256 | }; | 261 | }; |
257 | 262 | ||
258 | 263 | ||
259 | /*====================================================================================== | 264 | /*====================================================================================== |
260 | * OCiscoMonitoring | 265 | * OCiscoMonitoring |
261 | *======================================================================================*/ | 266 | *======================================================================================*/ |
262 | 267 | ||
263 | 268 | ||
264 | class OCiscoMonitoringInterface : public OMonitoringInterface | 269 | class OCiscoMonitoringInterface : public OMonitoringInterface |
265 | { | 270 | { |
266 | public: | 271 | public: |
267 | OCiscoMonitoringInterface( ONetworkInterface* ); | 272 | OCiscoMonitoringInterface( ONetworkInterface* ); |
268 | virtual ~OCiscoMonitoringInterface(); | 273 | virtual ~OCiscoMonitoringInterface(); |
269 | 274 | ||
270 | virtual void setEnabled( bool ); | 275 | virtual void setEnabled( bool ); |
271 | virtual QString name() const; | 276 | virtual QString name() const; |
272 | virtual void setChannel( int ); | 277 | virtual void setChannel( int ); |
273 | 278 | ||
274 | }; | 279 | }; |
275 | 280 | ||
276 | /*====================================================================================== | 281 | /*====================================================================================== |
277 | * OWlanNGMonitoringInterface | 282 | * OWlanNGMonitoringInterface |
278 | *======================================================================================*/ | 283 | *======================================================================================*/ |
279 | 284 | ||
280 | class OWlanNGMonitoringInterface : public OMonitoringInterface | 285 | class OWlanNGMonitoringInterface : public OMonitoringInterface |
281 | { | 286 | { |
282 | public: | 287 | public: |
283 | OWlanNGMonitoringInterface( ONetworkInterface* ); | 288 | OWlanNGMonitoringInterface( ONetworkInterface* ); |
284 | virtual ~OWlanNGMonitoringInterface(); | 289 | virtual ~OWlanNGMonitoringInterface(); |
285 | 290 | ||
286 | public: | 291 | public: |
287 | virtual void setEnabled( bool ); | 292 | virtual void setEnabled( bool ); |
288 | virtual QString name() const; | 293 | virtual QString name() const; |
289 | virtual void setChannel( int ); | 294 | virtual void setChannel( int ); |
290 | 295 | ||
291 | }; | 296 | }; |
292 | 297 | ||
293 | /*====================================================================================== | 298 | /*====================================================================================== |
294 | * OHostAPMonitoringInterface | 299 | * OHostAPMonitoringInterface |
295 | *======================================================================================*/ | 300 | *======================================================================================*/ |
296 | 301 | ||
297 | class OHostAPMonitoringInterface : public OMonitoringInterface | 302 | class OHostAPMonitoringInterface : public OMonitoringInterface |
298 | { | 303 | { |
299 | public: | 304 | public: |
300 | OHostAPMonitoringInterface( ONetworkInterface* ); | 305 | OHostAPMonitoringInterface( ONetworkInterface* ); |
301 | virtual ~OHostAPMonitoringInterface(); | 306 | virtual ~OHostAPMonitoringInterface(); |
302 | 307 | ||
303 | public: | 308 | public: |
304 | virtual void setEnabled( bool ); | 309 | virtual void setEnabled( bool ); |
305 | virtual QString name() const; | 310 | virtual QString name() const; |
306 | }; | 311 | }; |
307 | 312 | ||
308 | /*====================================================================================== | 313 | /*====================================================================================== |
309 | * OOrinocoMonitoringInterface | 314 | * OOrinocoMonitoringInterface |
310 | *======================================================================================*/ | 315 | *======================================================================================*/ |
311 | 316 | ||
312 | class OOrinocoMonitoringInterface : public OMonitoringInterface | 317 | class OOrinocoMonitoringInterface : public OMonitoringInterface |
313 | { | 318 | { |
314 | public: | 319 | public: |
315 | OOrinocoMonitoringInterface( ONetworkInterface* ); | 320 | OOrinocoMonitoringInterface( ONetworkInterface* ); |
316 | virtual ~OOrinocoMonitoringInterface(); | 321 | virtual ~OOrinocoMonitoringInterface(); |
317 | 322 | ||
318 | public: | 323 | public: |
319 | virtual void setChannel( int ); | 324 | virtual void setChannel( int ); |
320 | virtual void setEnabled( bool ); | 325 | virtual void setEnabled( bool ); |
321 | virtual QString name() const; | 326 | virtual QString name() const; |
322 | 327 | ||
323 | }; | 328 | }; |
324 | 329 | ||
325 | #endif // ONETWORK_H | 330 | #endif // ONETWORK_H |
326 | 331 | ||