-rw-r--r-- | examples/opienet/onetworkdemo/onetworkdemo.cpp | 5 | ||||
-rw-r--r-- | libopie2/opienet/onetutils.h | 26 | ||||
-rw-r--r-- | libopie2/opienet/onetwork.cpp | 31 | ||||
-rw-r--r-- | libopie2/opienet/onetwork.h | 7 | ||||
-rw-r--r-- | libopie2/opienet/opienet.pro | 2 |
5 files changed, 60 insertions, 11 deletions
diff --git a/examples/opienet/onetworkdemo/onetworkdemo.cpp b/examples/opienet/onetworkdemo/onetworkdemo.cpp index e0c93a2..b3a1115 100644 --- a/examples/opienet/onetworkdemo/onetworkdemo.cpp +++ b/examples/opienet/onetworkdemo/onetworkdemo.cpp | |||
@@ -1,176 +1,181 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the Opie Project | 2 | =. This file is part of the Opie Project |
3 | .=l. Copyright (C) 2004 Opie Team <opie-devel@handhelds.org> | 3 | .=l. Copyright (C) 2004 Opie Team <opie-devel@handhelds.org> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This library is free software; you can | 5 | _;:, .> :=|. This library is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This library is distributed in the hope that | 12 | .i_,=:_. -<s. This library is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
17 | ..}^=.= = ; Library General Public License for more | 17 | ..}^=.= = ; Library General Public License for more |
18 | ++= -. .` .: details. | 18 | ++= -. .` .: details. |
19 | : = ...= . :.=- | 19 | : = ...= . :.=- |
20 | -. .:....=;==+<; You should have received a copy of the GNU | 20 | -. .:....=;==+<; You should have received a copy of the GNU |
21 | -_. . . )=. = Library General Public License along with | 21 | -_. . . )=. = Library General Public License along with |
22 | -- :-=` this library; see the file COPYING.LIB. | 22 | -- :-=` this library; see the file COPYING.LIB. |
23 | If not, write to the Free Software Foundation, | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | 24 | Inc., 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | /* OPIE */ | 29 | /* OPIE */ |
30 | #include <opie2/onetwork.h> | 30 | #include <opie2/onetwork.h> |
31 | #include <opie2/ostation.h> | 31 | #include <opie2/ostation.h> |
32 | #include <opie2/omanufacturerdb.h> | 32 | #include <opie2/omanufacturerdb.h> |
33 | #include <opie2/odebug.h> | 33 | #include <opie2/odebug.h> |
34 | 34 | ||
35 | /* STD */ | 35 | /* STD */ |
36 | #include <unistd.h> | 36 | #include <unistd.h> |
37 | 37 | ||
38 | using namespace Opie::Net; | 38 | using namespace Opie::Net; |
39 | 39 | ||
40 | int main( int argc, char** argv ) | 40 | int main( int argc, char** argv ) |
41 | { | 41 | { |
42 | odebug << "OPIE Network Demo" << oendl; | 42 | odebug << "OPIE Network Demo" << oendl; |
43 | 43 | ||
44 | ONetwork* net = ONetwork::instance(); | 44 | ONetwork* net = ONetwork::instance(); |
45 | 45 | ||
46 | ONetwork::InterfaceIterator it = net->iterator(); | 46 | ONetwork::InterfaceIterator it = net->iterator(); |
47 | 47 | ||
48 | while ( it.current() ) | 48 | while ( it.current() ) |
49 | { | 49 | { |
50 | odebug << "DEMO: ONetwork contains Interface '" << it.current()->name() << "'" << oendl; | 50 | odebug << "DEMO: ONetwork contains Interface '" << it.current()->name() << "'" << oendl; |
51 | ONetworkInterfaceDriverInfo info = it.current()->driverInfo(); | ||
52 | odebug << "DEMO: DriverName reported as '" << info.name() << "'" << oendl; | ||
53 | odebug << "DEMO: DriverVersion reported as '" << info.version() << "'" << oendl; | ||
54 | odebug << "DEMO: DriverFirmware reported as '" << info.firmware() << "'" << oendl; | ||
55 | odebug << "DEMO: DriverBus reported as '" << info.bus() << "'" << oendl; | ||
51 | odebug << "DEMO: Datalink code is '" << it.current()->dataLinkType() << "'" << oendl; | 56 | odebug << "DEMO: Datalink code is '" << it.current()->dataLinkType() << "'" << oendl; |
52 | odebug << "DEMO: MAC Address is '" << it.current()->macAddress().toString() << "'" << oendl; | 57 | odebug << "DEMO: MAC Address is '" << it.current()->macAddress().toString() << "'" << oendl; |
53 | odebug << "DEMO: MAC Address is '" << it.current()->macAddress().toString(true) << "'" << oendl; | 58 | odebug << "DEMO: MAC Address is '" << it.current()->macAddress().toString(true) << "'" << oendl; |
54 | odebug << "DEMO: MAC Manufacturer seems to be '" << it.current()->macAddress().manufacturer() << "'" << oendl; | 59 | odebug << "DEMO: MAC Manufacturer seems to be '" << it.current()->macAddress().manufacturer() << "'" << oendl; |
55 | odebug << "DEMO: Manufacturertest1 = '" << OManufacturerDB::instance()->lookupExt( "08:00:87" ) << "'" << oendl; | 60 | odebug << "DEMO: Manufacturertest1 = '" << OManufacturerDB::instance()->lookupExt( "08:00:87" ) << "'" << oendl; |
56 | odebug << "DEMO: Manufacturertest2 = '" << OManufacturerDB::instance()->lookupExt( "E2:0C:0F" ) << "'" << oendl; | 61 | odebug << "DEMO: Manufacturertest2 = '" << OManufacturerDB::instance()->lookupExt( "E2:0C:0F" ) << "'" << oendl; |
57 | odebug << "Demo: IPv4 Address is '" << it.current()->ipV4Address() << "'" << oendl; | 62 | odebug << "Demo: IPv4 Address is '" << it.current()->ipV4Address() << "'" << oendl; |
58 | if ( it.current()->isWireless() ) | 63 | if ( it.current()->isWireless() ) |
59 | { | 64 | { |
60 | OWirelessNetworkInterface* iface = static_cast<OWirelessNetworkInterface*>( it.current() ); | 65 | OWirelessNetworkInterface* iface = static_cast<OWirelessNetworkInterface*>( it.current() ); |
61 | odebug << "DEMO: '" << iface->name() << "' seems to feature the wireless extensions." << oendl; | 66 | odebug << "DEMO: '" << iface->name() << "' seems to feature the wireless extensions." << oendl; |
62 | odebug << "DEMO: Current SSID is '" << iface->SSID() << "'" << oendl; | 67 | odebug << "DEMO: Current SSID is '" << iface->SSID() << "'" << oendl; |
63 | odebug << "DEMO: Antenna is tuned to '" << iface->frequency() << "', that is channel " << iface->channel() << "" << oendl; | 68 | odebug << "DEMO: Antenna is tuned to '" << iface->frequency() << "', that is channel " << iface->channel() << "" << oendl; |
64 | 69 | ||
65 | //if ( iface->mode() == OWirelessNetworkInterface::adhoc ) | 70 | //if ( iface->mode() == OWirelessNetworkInterface::adhoc ) |
66 | //{ | 71 | //{ |
67 | //odebug << "DEMO: Associated AP has MAC Address '" << iface->associatedAP().toString() << "'" << oendl; | 72 | //odebug << "DEMO: Associated AP has MAC Address '" << iface->associatedAP().toString() << "'" << oendl; |
68 | //} | 73 | //} |
69 | 74 | ||
70 | /* | 75 | /* |
71 | 76 | ||
72 | // nickname | 77 | // nickname |
73 | odebug << "DEMO: Current NickName is '" << iface->nickName() << "'" << oendl; | 78 | odebug << "DEMO: Current NickName is '" << iface->nickName() << "'" << oendl; |
74 | iface->setNickName( "MyNickName" ); | 79 | iface->setNickName( "MyNickName" ); |
75 | if ( iface->nickName() != "MyNickName" ) | 80 | if ( iface->nickName() != "MyNickName" ) |
76 | odebug << "DEMO: Warning! Can't change nickname" << oendl; | 81 | odebug << "DEMO: Warning! Can't change nickname" << oendl; |
77 | else | 82 | else |
78 | odebug << "DEMO: Nickname change successful." << oendl; | 83 | odebug << "DEMO: Nickname change successful." << oendl; |
79 | 84 | ||
80 | /* | 85 | /* |
81 | 86 | ||
82 | // operation mode | 87 | // operation mode |
83 | odebug << "DEMO: Current OperationMode is '" << iface->mode() << "'" << oendl; | 88 | odebug << "DEMO: Current OperationMode is '" << iface->mode() << "'" << oendl; |
84 | iface->setMode( "adhoc" ); | 89 | iface->setMode( "adhoc" ); |
85 | if ( iface->mode() != "adhoc" ) | 90 | if ( iface->mode() != "adhoc" ) |
86 | odebug << "DEMO: Warning! Can't change operation mode" << oendl; | 91 | odebug << "DEMO: Warning! Can't change operation mode" << oendl; |
87 | else | 92 | else |
88 | odebug << "DEMO: Operation Mode change successful." << oendl; | 93 | odebug << "DEMO: Operation Mode change successful." << oendl; |
89 | 94 | ||
90 | // RF channel | 95 | // RF channel |
91 | odebug << "DEMO: Current Channel is '" << iface->channel() << "'" << oendl; | 96 | odebug << "DEMO: Current Channel is '" << iface->channel() << "'" << oendl; |
92 | iface->setChannel( 1 ); | 97 | iface->setChannel( 1 ); |
93 | if ( iface->channel() != 1 ) | 98 | if ( iface->channel() != 1 ) |
94 | odebug << "DEMO: Warning! Can't change RF channel" << oendl; | 99 | odebug << "DEMO: Warning! Can't change RF channel" << oendl; |
95 | else | 100 | else |
96 | odebug << "DEMO: RF channel change successful." << oendl; | 101 | odebug << "DEMO: RF channel change successful." << oendl; |
97 | 102 | ||
98 | iface->setMode( "managed" ); | 103 | iface->setMode( "managed" ); |
99 | 104 | ||
100 | */ | 105 | */ |
101 | 106 | ||
102 | /* | 107 | /* |
103 | 108 | ||
104 | // network scan | 109 | // network scan |
105 | 110 | ||
106 | OStationList* stations = iface->scanNetwork(); | 111 | OStationList* stations = iface->scanNetwork(); |
107 | if ( stations ) | 112 | if ( stations ) |
108 | { | 113 | { |
109 | odebug << "DEMO: # of stations around = " << stations->count() << "" << oendl; | 114 | odebug << "DEMO: # of stations around = " << stations->count() << "" << oendl; |
110 | OStation* station; | 115 | OStation* station; |
111 | for ( station = stations->first(); station != 0; station = stations->next() ) | 116 | for ( station = stations->first(); station != 0; station = stations->next() ) |
112 | { | 117 | { |
113 | odebug << "DEMO: station dump following..." << oendl; | 118 | odebug << "DEMO: station dump following..." << oendl; |
114 | station->dump(); | 119 | station->dump(); |
115 | } | 120 | } |
116 | } | 121 | } |
117 | 122 | ||
118 | else | 123 | else |
119 | { | 124 | { |
120 | odebug << "DEMO: Warning! Scan didn't work!" << oendl; | 125 | odebug << "DEMO: Warning! Scan didn't work!" << oendl; |
121 | } | 126 | } |
122 | 127 | ||
123 | /* | 128 | /* |
124 | 129 | ||
125 | // first some wrong calls to check if this is working | 130 | // first some wrong calls to check if this is working |
126 | iface->setPrivate( "seppel", 10 ); | 131 | iface->setPrivate( "seppel", 10 ); |
127 | iface->setPrivate( "monitor", 0 ); | 132 | iface->setPrivate( "monitor", 0 ); |
128 | 133 | ||
129 | // now the real deal | 134 | // now the real deal |
130 | iface->setPrivate( "monitor", 2, 2, 3 ); | 135 | iface->setPrivate( "monitor", 2, 2, 3 ); |
131 | 136 | ||
132 | // trying to set hw address to 12:34:56:AB:CD:EF | 137 | // trying to set hw address to 12:34:56:AB:CD:EF |
133 | 138 | ||
134 | /* | 139 | /* |
135 | 140 | ||
136 | OMacAddress addr = OMacAddress::fromString( "12:34:56:AB:CD:EF" ); | 141 | OMacAddress addr = OMacAddress::fromString( "12:34:56:AB:CD:EF" ); |
137 | iface->setUp( false ); | 142 | iface->setUp( false ); |
138 | iface->setMacAddress( addr ); | 143 | iface->setMacAddress( addr ); |
139 | iface->setUp( true ); | 144 | iface->setUp( true ); |
140 | odebug << "DEMO: MAC Address now is '" << iface->macAddress().toString() << "'" << oendl; | 145 | odebug << "DEMO: MAC Address now is '" << iface->macAddress().toString() << "'" << oendl; |
141 | 146 | ||
142 | */ | 147 | */ |
143 | 148 | ||
144 | // monitor test | 149 | // monitor test |
145 | 150 | ||
146 | 151 | ||
147 | 152 | ||
148 | odebug << "DEMO: current interface mode is '" << iface->mode() << "'" << oendl; | 153 | odebug << "DEMO: current interface mode is '" << iface->mode() << "'" << oendl; |
149 | iface->setMode( "monitor" ); | 154 | iface->setMode( "monitor" ); |
150 | odebug << "DEMO: current interface mode is '" << iface->mode() << "'" << oendl; | 155 | odebug << "DEMO: current interface mode is '" << iface->mode() << "'" << oendl; |
151 | 156 | ||
152 | sleep( 1 ); | 157 | sleep( 1 ); |
153 | 158 | ||
154 | iface->setChannel( 1 ); | 159 | iface->setChannel( 1 ); |
155 | iface->setMode( "managed" ); | 160 | iface->setMode( "managed" ); |
156 | 161 | ||
157 | //sleep( 1 ); | 162 | //sleep( 1 ); |
158 | odebug << "DEMO: current interface mode is '" << iface->mode() << "'" << oendl; | 163 | odebug << "DEMO: current interface mode is '" << iface->mode() << "'" << oendl; |
159 | 164 | ||
160 | /*iface->setMode( "adhoc" ); | 165 | /*iface->setMode( "adhoc" ); |
161 | sleep( 1 ); | 166 | sleep( 1 ); |
162 | odebug << "DEMO: current interface mode is '" << iface->mode() << "'" << oendl; | 167 | odebug << "DEMO: current interface mode is '" << iface->mode() << "'" << oendl; |
163 | iface->setMode( "managed" ); | 168 | iface->setMode( "managed" ); |
164 | sleep( 1 ); | 169 | sleep( 1 ); |
165 | odebug << "DEMO: current interface mode is '" << iface->mode() << "'" << oendl; | 170 | odebug << "DEMO: current interface mode is '" << iface->mode() << "'" << oendl; |
166 | iface->setMode( "master" ); | 171 | iface->setMode( "master" ); |
167 | sleep( 1 ); | 172 | sleep( 1 ); |
168 | odebug << "DEMO: current interface mode is '" << iface->mode() << "'" << oendl; */ | 173 | odebug << "DEMO: current interface mode is '" << iface->mode() << "'" << oendl; */ |
169 | 174 | ||
170 | } | 175 | } |
171 | ++it; | 176 | ++it; |
172 | } | 177 | } |
173 | 178 | ||
174 | return 0; | 179 | return 0; |
175 | 180 | ||
176 | } | 181 | } |
diff --git a/libopie2/opienet/onetutils.h b/libopie2/opienet/onetutils.h index 32f5355..25c9238 100644 --- a/libopie2/opienet/onetutils.h +++ b/libopie2/opienet/onetutils.h | |||
@@ -1,215 +1,241 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de> | 3 | (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de> |
4 | =. | 4 | =. |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; version 2 of the License. | 11 | - . .-<_> .<> Foundation; version 2 of the License. |
12 | ._= =} : | 12 | ._= =} : |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | 28 | ||
29 | */ | 29 | */ |
30 | 30 | ||
31 | #ifndef ONETUTILS_H | 31 | #ifndef ONETUTILS_H |
32 | #define ONETUTILS_H | 32 | #define ONETUTILS_H |
33 | 33 | ||
34 | #include <qdict.h> | 34 | #include <qdict.h> |
35 | #include <qmap.h> | 35 | #include <qmap.h> |
36 | #include <qstring.h> | 36 | #include <qstring.h> |
37 | #include <qhostaddress.h> | 37 | #include <qhostaddress.h> |
38 | #include <qobject.h> | 38 | #include <qobject.h> |
39 | 39 | ||
40 | #include <sys/types.h> | 40 | #include <sys/types.h> |
41 | 41 | ||
42 | struct ifreq; | 42 | struct ifreq; |
43 | 43 | ||
44 | namespace Opie { | 44 | namespace Opie { |
45 | namespace Net { | 45 | namespace Net { |
46 | 46 | ||
47 | class OWirelessNetworkInterface; | 47 | class OWirelessNetworkInterface; |
48 | 48 | ||
49 | /*====================================================================================== | 49 | /*====================================================================================== |
50 | * OMacAddress | 50 | * OMacAddress |
51 | *======================================================================================*/ | 51 | *======================================================================================*/ |
52 | 52 | ||
53 | class OMacAddress | 53 | class OMacAddress |
54 | { | 54 | { |
55 | public: | 55 | public: |
56 | // QString c'tor? -zecke | 56 | // QString c'tor? -zecke |
57 | OMacAddress(); | 57 | OMacAddress(); |
58 | OMacAddress( unsigned char* ); | 58 | OMacAddress( unsigned char* ); |
59 | OMacAddress( const unsigned char* ); | 59 | OMacAddress( const unsigned char* ); |
60 | OMacAddress( struct ifreq& ); | 60 | OMacAddress( struct ifreq& ); |
61 | ~OMacAddress(); | 61 | ~OMacAddress(); |
62 | 62 | ||
63 | QString manufacturer() const; | 63 | QString manufacturer() const; |
64 | QString toString( bool substitute = false ) const; | 64 | QString toString( bool substitute = false ) const; |
65 | const unsigned char* native() const; | 65 | const unsigned char* native() const; |
66 | 66 | ||
67 | // no c'tor but this one why not make it a c'tor. it could also replace the others or is this the problem? | 67 | // no c'tor but this one why not make it a c'tor. it could also replace the others or is this the problem? |
68 | static OMacAddress fromString( const QString& ); | 68 | static OMacAddress fromString( const QString& ); |
69 | 69 | ||
70 | public: | 70 | public: |
71 | static const OMacAddress& broadcast; // ff:ff:ff:ff:ff:ff | 71 | static const OMacAddress& broadcast; // ff:ff:ff:ff:ff:ff |
72 | static const OMacAddress& unknown; // 44:44:44:44:44:44 | 72 | static const OMacAddress& unknown; // 44:44:44:44:44:44 |
73 | 73 | ||
74 | private: | 74 | private: |
75 | unsigned char _bytes[6]; | 75 | unsigned char _bytes[6]; |
76 | 76 | ||
77 | friend bool operator==( const OMacAddress &m1, const OMacAddress &m2 ); | 77 | friend bool operator==( const OMacAddress &m1, const OMacAddress &m2 ); |
78 | class Private; | 78 | class Private; |
79 | Private *d; | 79 | Private *d; |
80 | 80 | ||
81 | }; | 81 | }; |
82 | 82 | ||
83 | bool operator==( const OMacAddress &m1, const OMacAddress &m2 ); | 83 | bool operator==( const OMacAddress &m1, const OMacAddress &m2 ); |
84 | 84 | ||
85 | 85 | ||
86 | /*====================================================================================== | 86 | /*====================================================================================== |
87 | * OHostAddress | 87 | * OHostAddress |
88 | *======================================================================================*/ | 88 | *======================================================================================*/ |
89 | 89 | ||
90 | class OHostAddress : public QHostAddress | 90 | class OHostAddress : public QHostAddress |
91 | { | 91 | { |
92 | /*public: | 92 | /*public: |
93 | OHostAddress(); | 93 | OHostAddress(); |
94 | ~OHostAddress(); | 94 | ~OHostAddress(); |
95 | */ | 95 | */ |
96 | private: | 96 | private: |
97 | class Private; | 97 | class Private; |
98 | Private *d; | 98 | Private *d; |
99 | }; | 99 | }; |
100 | 100 | ||
101 | 101 | ||
102 | /*====================================================================================== | 102 | /*====================================================================================== |
103 | * ONetworkInterfaceDriverInfo | ||
104 | *======================================================================================*/ | ||
105 | |||
106 | class ONetworkInterfaceDriverInfo | ||
107 | { | ||
108 | public: | ||
109 | ONetworkInterfaceDriverInfo( const QString& name = "<unknown>", | ||
110 | const QString& version = "<unknown>", | ||
111 | const QString& firmware = "<unknown>", | ||
112 | const QString& bus = "<unknown>" ) : | ||
113 | _name( name ), _version( version ), _firmware( firmware ), _bus( bus ) { }; | ||
114 | ~ONetworkInterfaceDriverInfo() { }; | ||
115 | |||
116 | QString name() const { return _name; }; | ||
117 | QString version() const { return _version; }; | ||
118 | QString firmware() const { return _firmware; }; | ||
119 | QString bus() const { return _bus; }; | ||
120 | |||
121 | private: | ||
122 | const QString _name; | ||
123 | const QString _version; | ||
124 | const QString _firmware; | ||
125 | const QString _bus; | ||
126 | }; | ||
127 | |||
128 | /*====================================================================================== | ||
103 | * OPrivateIOCTL | 129 | * OPrivateIOCTL |
104 | *======================================================================================*/ | 130 | *======================================================================================*/ |
105 | 131 | ||
106 | class OPrivateIOCTL : public QObject | 132 | class OPrivateIOCTL : public QObject |
107 | { | 133 | { |
108 | public: | 134 | public: |
109 | OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs ); | 135 | OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs ); |
110 | ~OPrivateIOCTL(); | 136 | ~OPrivateIOCTL(); |
111 | 137 | ||
112 | int numberGetArgs() const; | 138 | int numberGetArgs() const; |
113 | int typeGetArgs() const; | 139 | int typeGetArgs() const; |
114 | int numberSetArgs() const; | 140 | int numberSetArgs() const; |
115 | int typeSetArgs() const; | 141 | int typeSetArgs() const; |
116 | 142 | ||
117 | // FIXME return int? as ::ioctl does? -zecke | 143 | // FIXME return int? as ::ioctl does? -zecke |
118 | void invoke() const; | 144 | void invoke() const; |
119 | void setParameter( int, u_int32_t ); | 145 | void setParameter( int, u_int32_t ); |
120 | 146 | ||
121 | private: | 147 | private: |
122 | u_int32_t _ioctl; | 148 | u_int32_t _ioctl; |
123 | u_int16_t _getargs; | 149 | u_int16_t _getargs; |
124 | u_int16_t _setargs; | 150 | u_int16_t _setargs; |
125 | 151 | ||
126 | class Private; | 152 | class Private; |
127 | Private *d; | 153 | Private *d; |
128 | }; | 154 | }; |
129 | 155 | ||
130 | /*====================================================================================== | 156 | /*====================================================================================== |
131 | * Miscellaneous | 157 | * Miscellaneous |
132 | *======================================================================================*/ | 158 | *======================================================================================*/ |
133 | 159 | ||
134 | namespace Internal { | 160 | namespace Internal { |
135 | void dumpBytes( const unsigned char* data, int num ); | 161 | void dumpBytes( const unsigned char* data, int num ); |
136 | QString modeToString( int ); | 162 | QString modeToString( int ); |
137 | int stringToMode( const QString& ); | 163 | int stringToMode( const QString& ); |
138 | } | 164 | } |
139 | } | 165 | } |
140 | } | 166 | } |
141 | 167 | ||
142 | #define IW_PRIV_TYPE_MASK 0x7000 | 168 | #define IW_PRIV_TYPE_MASK 0x7000 |
143 | #define IW_PRIV_TYPE_NONE 0x0000 | 169 | #define IW_PRIV_TYPE_NONE 0x0000 |
144 | #define IW_PRIV_TYPE_BYTE 0x1000 | 170 | #define IW_PRIV_TYPE_BYTE 0x1000 |
145 | #define IW_PRIV_TYPE_CHAR 0x2000 | 171 | #define IW_PRIV_TYPE_CHAR 0x2000 |
146 | #define IW_PRIV_TYPE_INT 0x4000 | 172 | #define IW_PRIV_TYPE_INT 0x4000 |
147 | #define IW_PRIV_TYPE_FLOAT 0x5000 | 173 | #define IW_PRIV_TYPE_FLOAT 0x5000 |
148 | #define IW_PRIV_TYPE_ADDR 0x6000 | 174 | #define IW_PRIV_TYPE_ADDR 0x6000 |
149 | #define IW_PRIV_SIZE_FIXED 0x0800 | 175 | #define IW_PRIV_SIZE_FIXED 0x0800 |
150 | #define IW_PRIV_SIZE_MASK 0x07FF | 176 | #define IW_PRIV_SIZE_MASK 0x07FF |
151 | 177 | ||
152 | #define IW_HEADER_TYPE_NULL 0 /* Not available */ | 178 | #define IW_HEADER_TYPE_NULL 0 /* Not available */ |
153 | #define IW_HEADER_TYPE_CHAR 2 /* char [IFNAMSIZ] */ | 179 | #define IW_HEADER_TYPE_CHAR 2 /* char [IFNAMSIZ] */ |
154 | #define IW_HEADER_TYPE_UINT 4 /* __u32 */ | 180 | #define IW_HEADER_TYPE_UINT 4 /* __u32 */ |
155 | #define IW_HEADER_TYPE_FREQ 5 /* struct iw_freq */ | 181 | #define IW_HEADER_TYPE_FREQ 5 /* struct iw_freq */ |
156 | #define IW_HEADER_TYPE_ADDR 6 /* struct sockaddr */ | 182 | #define IW_HEADER_TYPE_ADDR 6 /* struct sockaddr */ |
157 | #define IW_HEADER_TYPE_POINT 8 /* struct iw_point */ | 183 | #define IW_HEADER_TYPE_POINT 8 /* struct iw_point */ |
158 | #define IW_HEADER_TYPE_PARAM 9 /* struct iw_param */ | 184 | #define IW_HEADER_TYPE_PARAM 9 /* struct iw_param */ |
159 | #define IW_HEADER_TYPE_QUAL 10 /* struct iw_quality */ | 185 | #define IW_HEADER_TYPE_QUAL 10 /* struct iw_quality */ |
160 | 186 | ||
161 | #define IW_EV_POINT_OFF (((char *) &(((struct iw_point *) NULL)->length)) - \ | 187 | #define IW_EV_POINT_OFF (((char *) &(((struct iw_point *) NULL)->length)) - \ |
162 | (char *) NULL) | 188 | (char *) NULL) |
163 | 189 | ||
164 | #ifndef ARPHRD_IEEE80211 | 190 | #ifndef ARPHRD_IEEE80211 |
165 | #define ARPHRD_IEEE80211 801 | 191 | #define ARPHRD_IEEE80211 801 |
166 | #endif | 192 | #endif |
167 | #ifndef ARPHRD_IEEE80211_PRISM | 193 | #ifndef ARPHRD_IEEE80211_PRISM |
168 | #define ARPHRD_IEEE80211_PRISM 802 | 194 | #define ARPHRD_IEEE80211_PRISM 802 |
169 | #endif | 195 | #endif |
170 | 196 | ||
171 | /* Wireless Extension Scanning Stuff */ | 197 | /* Wireless Extension Scanning Stuff */ |
172 | struct iw_stream_descr | 198 | struct iw_stream_descr |
173 | { | 199 | { |
174 | char * end; /* End of the stream */ | 200 | char * end; /* End of the stream */ |
175 | char * current; /* Current event in stream of events */ | 201 | char * current; /* Current event in stream of events */ |
176 | char * value; /* Current value in event */ | 202 | char * value; /* Current value in event */ |
177 | }; | 203 | }; |
178 | 204 | ||
179 | 205 | ||
180 | /* Network to host order macros */ | 206 | /* Network to host order macros */ |
181 | 207 | ||
182 | #ifdef LBL_ALIGN | 208 | #ifdef LBL_ALIGN |
183 | #define EXTRACT_16BITS(p) \ | 209 | #define EXTRACT_16BITS(p) \ |
184 | ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 0) << 8 | \ | 210 | ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 0) << 8 | \ |
185 | (u_int16_t)*((const u_int8_t *)(p) + 1))) | 211 | (u_int16_t)*((const u_int8_t *)(p) + 1))) |
186 | #define EXTRACT_32BITS(p) \ | 212 | #define EXTRACT_32BITS(p) \ |
187 | ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 24 | \ | 213 | ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 24 | \ |
188 | (u_int32_t)*((const u_int8_t *)(p) + 1) << 16 | \ | 214 | (u_int32_t)*((const u_int8_t *)(p) + 1) << 16 | \ |
189 | (u_int32_t)*((const u_int8_t *)(p) + 2) << 8 | \ | 215 | (u_int32_t)*((const u_int8_t *)(p) + 2) << 8 | \ |
190 | (u_int32_t)*((const u_int8_t *)(p) + 3))) | 216 | (u_int32_t)*((const u_int8_t *)(p) + 3))) |
191 | #else | 217 | #else |
192 | #define EXTRACT_16BITS(p) \ | 218 | #define EXTRACT_16BITS(p) \ |
193 | ((u_int16_t)ntohs(*(const u_int16_t *)(p))) | 219 | ((u_int16_t)ntohs(*(const u_int16_t *)(p))) |
194 | #define EXTRACT_32BITS(p) \ | 220 | #define EXTRACT_32BITS(p) \ |
195 | ((u_int32_t)ntohl(*(const u_int32_t *)(p))) | 221 | ((u_int32_t)ntohl(*(const u_int32_t *)(p))) |
196 | #endif | 222 | #endif |
197 | 223 | ||
198 | #define EXTRACT_24BITS(p) \ | 224 | #define EXTRACT_24BITS(p) \ |
199 | ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 16 | \ | 225 | ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 16 | \ |
200 | (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \ | 226 | (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \ |
201 | (u_int32_t)*((const u_int8_t *)(p) + 2))) | 227 | (u_int32_t)*((const u_int8_t *)(p) + 2))) |
202 | 228 | ||
203 | /* Little endian protocol host order macros */ | 229 | /* Little endian protocol host order macros */ |
204 | #define EXTRACT_LE_8BITS(p) (*(p)) | 230 | #define EXTRACT_LE_8BITS(p) (*(p)) |
205 | #define EXTRACT_LE_16BITS(p) \ | 231 | #define EXTRACT_LE_16BITS(p) \ |
206 | ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 1) << 8 | \ | 232 | ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 1) << 8 | \ |
207 | (u_int16_t)*((const u_int8_t *)(p) + 0))) | 233 | (u_int16_t)*((const u_int8_t *)(p) + 0))) |
208 | #define EXTRACT_LE_32BITS(p) \ | 234 | #define EXTRACT_LE_32BITS(p) \ |
209 | ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 3) << 24 | \ | 235 | ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 3) << 24 | \ |
210 | (u_int32_t)*((const u_int8_t *)(p) + 2) << 16 | \ | 236 | (u_int32_t)*((const u_int8_t *)(p) + 2) << 16 | \ |
211 | (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \ | 237 | (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \ |
212 | (u_int32_t)*((const u_int8_t *)(p) + 0))) | 238 | (u_int32_t)*((const u_int8_t *)(p) + 0))) |
213 | 239 | ||
214 | #endif // ONETUTILS_H | 240 | #endif // ONETUTILS_H |
215 | 241 | ||
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp index 05513f8..1deb051 100644 --- a/libopie2/opienet/onetwork.cpp +++ b/libopie2/opienet/onetwork.cpp | |||
@@ -1,1452 +1,1463 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) 2003-2005 by Michael 'Mickey' Lauer <mickey@Vanille.de> | 3 | Copyright (C) 2003-2005 by Michael 'Mickey' Lauer <mickey@Vanille.de> |
4 | =. | 4 | =. |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; version 2 of the License. | 11 | - . .-<_> .<> Foundation; version 2 of the License. |
12 | ._= =} : | 12 | ._= =} : |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | 28 | ||
29 | */ | 29 | */ |
30 | 30 | ||
31 | /* OPIE */ | 31 | /* OPIE */ |
32 | |||
33 | #include <opie2/onetwork.h> | 32 | #include <opie2/onetwork.h> |
34 | #include <opie2/ostation.h> | 33 | #include <opie2/ostation.h> |
35 | #include <opie2/odebug.h> | 34 | #include <opie2/odebug.h> |
35 | using namespace Opie::Core; | ||
36 | 36 | ||
37 | /* QT */ | 37 | /* QT */ |
38 | |||
39 | #include <qfile.h> | 38 | #include <qfile.h> |
40 | #include <qtextstream.h> | 39 | #include <qtextstream.h> |
41 | #include <qapplication.h> | 40 | #include <qapplication.h> |
42 | 41 | ||
43 | /* UNIX */ | 42 | /* STD */ |
44 | |||
45 | #include <assert.h> | 43 | #include <assert.h> |
46 | #include <arpa/inet.h> | 44 | #include <arpa/inet.h> |
47 | #include <errno.h> | 45 | #include <errno.h> |
46 | #include <stdarg.h> | ||
48 | #include <string.h> | 47 | #include <string.h> |
49 | #include <stdlib.h> | 48 | #include <stdlib.h> |
50 | #include <math.h> | 49 | #include <math.h> |
50 | #include <unistd.h> | ||
51 | #include <net/if_arp.h> | ||
52 | #include <net/ethernet.h> | ||
51 | #include <sys/ioctl.h> | 53 | #include <sys/ioctl.h> |
52 | #include <sys/socket.h> | 54 | #include <sys/socket.h> |
53 | #include <sys/types.h> | 55 | #include <sys/types.h> |
54 | #include <unistd.h> | 56 | #include <linux/types.h> |
55 | #include <linux/sockios.h> | 57 | #include <linux/sockios.h> |
56 | #include <net/if_arp.h> | 58 | #define u64 __u64 |
57 | #include <net/ethernet.h> | 59 | #define u32 __u32 |
58 | #include <stdarg.h> | 60 | #define u16 __u16 |
61 | #define u8 __u8 | ||
62 | #include <linux/ethtool.h> | ||
59 | 63 | ||
60 | #ifndef NODEBUG | 64 | #ifndef NODEBUG |
61 | #include <opie2/odebugmapper.h> | 65 | #include <opie2/odebugmapper.h> |
62 | |||
63 | using namespace Opie::Core; | ||
64 | using namespace Opie::Net::Internal; | 66 | using namespace Opie::Net::Internal; |
65 | DebugMapper* debugmapper = new DebugMapper(); | 67 | DebugMapper* debugmapper = new DebugMapper(); |
66 | #endif | 68 | #endif |
67 | 69 | ||
68 | /*====================================================================================== | 70 | /*====================================================================================== |
69 | * ONetwork | 71 | * ONetwork |
70 | *======================================================================================*/ | 72 | *======================================================================================*/ |
71 | 73 | ||
72 | namespace Opie { | 74 | namespace Opie { |
73 | namespace Net { | 75 | namespace Net { |
74 | ONetwork* ONetwork::_instance = 0; | 76 | ONetwork* ONetwork::_instance = 0; |
75 | 77 | ||
76 | ONetwork::ONetwork() | 78 | ONetwork::ONetwork() |
77 | { | 79 | { |
78 | odebug << "ONetwork::ONetwork()" << oendl; | 80 | odebug << "ONetwork::ONetwork()" << oendl; |
79 | odebug << "ONetwork: This code has been compiled against Wireless Extensions V" << WIRELESS_EXT << oendl; | 81 | odebug << "ONetwork: This code has been compiled against Wireless Extensions V" << WIRELESS_EXT << oendl; |
80 | synchronize(); | 82 | synchronize(); |
81 | } | 83 | } |
82 | 84 | ||
83 | void ONetwork::synchronize() | 85 | void ONetwork::synchronize() |
84 | { | 86 | { |
85 | // gather available interfaces by inspecting /proc/net/dev | 87 | // gather available interfaces by inspecting /proc/net/dev |
86 | //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices | 88 | //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices |
87 | //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices | 89 | //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices |
88 | //FIXME: Best is use SIOCGIFCONF and if this doesn't work (result=-1), then fallback to parsing /proc/net/dev | 90 | //FIXME: Best is use SIOCGIFCONF and if this doesn't work (result=-1), then fallback to parsing /proc/net/dev |
89 | 91 | ||
90 | _interfaces.clear(); | 92 | _interfaces.clear(); |
91 | QString str; | 93 | QString str; |
92 | QFile f( "/proc/net/dev" ); | 94 | QFile f( "/proc/net/dev" ); |
93 | bool hasFile = f.open( IO_ReadOnly ); | 95 | bool hasFile = f.open( IO_ReadOnly ); |
94 | if ( !hasFile ) | 96 | if ( !hasFile ) |
95 | { | 97 | { |
96 | odebug << "ONetwork: /proc/net/dev not existing. No network devices available" << oendl; | 98 | odebug << "ONetwork: /proc/net/dev not existing. No network devices available" << oendl; |
97 | return; | 99 | return; |
98 | } | 100 | } |
99 | QTextStream s( &f ); | 101 | QTextStream s( &f ); |
100 | s.readLine(); | 102 | s.readLine(); |
101 | s.readLine(); | 103 | s.readLine(); |
102 | while ( !s.atEnd() ) | 104 | while ( !s.atEnd() ) |
103 | { | 105 | { |
104 | s >> str; | 106 | s >> str; |
105 | str.truncate( str.find( ':' ) ); | 107 | str.truncate( str.find( ':' ) ); |
106 | odebug << "ONetwork: found interface '" << str << "'" << oendl; | 108 | odebug << "ONetwork: found interface '" << str << "'" << oendl; |
107 | if ( str.startsWith( "wifi" ) ) | 109 | if ( str.startsWith( "wifi" ) ) |
108 | { | 110 | { |
109 | odebug << "ONetwork: ignoring hostap control interface" << oendl; | 111 | odebug << "ONetwork: ignoring hostap control interface" << oendl; |
110 | s.readLine(); | 112 | s.readLine(); |
111 | continue; | 113 | continue; |
112 | } | 114 | } |
113 | ONetworkInterface* iface = 0; | 115 | ONetworkInterface* iface = 0; |
114 | if ( isWirelessInterface( str ) ) | 116 | if ( isWirelessInterface( str ) ) |
115 | { | 117 | { |
116 | iface = new OWirelessNetworkInterface( this, (const char*) str ); | 118 | iface = new OWirelessNetworkInterface( this, (const char*) str ); |
117 | odebug << "ONetwork: interface '" << str << "' has Wireless Extensions" << oendl; | 119 | odebug << "ONetwork: interface '" << str << "' has Wireless Extensions" << oendl; |
118 | } | 120 | } |
119 | else | 121 | else |
120 | { | 122 | { |
121 | iface = new ONetworkInterface( this, (const char*) str ); | 123 | iface = new ONetworkInterface( this, (const char*) str ); |
122 | } | 124 | } |
123 | _interfaces.insert( str, iface ); | 125 | _interfaces.insert( str, iface ); |
124 | s.readLine(); | 126 | s.readLine(); |
125 | } | 127 | } |
126 | } | 128 | } |
127 | 129 | ||
128 | 130 | ||
129 | short ONetwork::wirelessExtensionCompileVersion() | 131 | short ONetwork::wirelessExtensionCompileVersion() |
130 | { | 132 | { |
131 | return WIRELESS_EXT; | 133 | return WIRELESS_EXT; |
132 | } | 134 | } |
133 | 135 | ||
134 | 136 | ||
135 | int ONetwork::count() const | 137 | int ONetwork::count() const |
136 | { | 138 | { |
137 | return _interfaces.count(); | 139 | return _interfaces.count(); |
138 | } | 140 | } |
139 | 141 | ||
140 | 142 | ||
141 | ONetworkInterface* ONetwork::interface( const QString& iface ) const | 143 | ONetworkInterface* ONetwork::interface( const QString& iface ) const |
142 | { | 144 | { |
143 | return _interfaces[iface]; | 145 | return _interfaces[iface]; |
144 | } | 146 | } |
145 | 147 | ||
146 | 148 | ||
147 | ONetwork* ONetwork::instance() | 149 | ONetwork* ONetwork::instance() |
148 | { | 150 | { |
149 | if ( !_instance ) _instance = new ONetwork(); | 151 | if ( !_instance ) _instance = new ONetwork(); |
150 | return _instance; | 152 | return _instance; |
151 | } | 153 | } |
152 | 154 | ||
153 | 155 | ||
154 | ONetwork::InterfaceIterator ONetwork::iterator() const | 156 | ONetwork::InterfaceIterator ONetwork::iterator() const |
155 | { | 157 | { |
156 | return ONetwork::InterfaceIterator( _interfaces ); | 158 | return ONetwork::InterfaceIterator( _interfaces ); |
157 | } | 159 | } |
158 | 160 | ||
159 | 161 | ||
160 | bool ONetwork::isPresent( const char* name ) const | 162 | bool ONetwork::isPresent( const char* name ) const |
161 | { | 163 | { |
162 | int sfd = socket( AF_INET, SOCK_STREAM, 0 ); | 164 | int sfd = socket( AF_INET, SOCK_STREAM, 0 ); |
163 | struct ifreq ifr; | 165 | struct ifreq ifr; |
164 | memset( &ifr, 0, sizeof( struct ifreq ) ); | 166 | memset( &ifr, 0, sizeof( struct ifreq ) ); |
165 | strcpy( (char*) &ifr.ifr_name, name ); | 167 | strcpy( (char*) &ifr.ifr_name, name ); |
166 | int result = ::ioctl( sfd, SIOCGIFFLAGS, &ifr ); | 168 | int result = ::ioctl( sfd, SIOCGIFFLAGS, &ifr ); |
167 | return result != -1; | 169 | return result != -1; |
168 | } | 170 | } |
169 | 171 | ||
170 | 172 | ||
171 | bool ONetwork::isWirelessInterface( const char* name ) const | 173 | bool ONetwork::isWirelessInterface( const char* name ) const |
172 | { | 174 | { |
173 | int sfd = socket( AF_INET, SOCK_STREAM, 0 ); | 175 | int sfd = socket( AF_INET, SOCK_STREAM, 0 ); |
174 | struct iwreq iwr; | 176 | struct iwreq iwr; |
175 | memset( &iwr, 0, sizeof( struct iwreq ) ); | 177 | memset( &iwr, 0, sizeof( struct iwreq ) ); |
176 | strcpy( (char*) &iwr.ifr_name, name ); | 178 | strcpy( (char*) &iwr.ifr_name, name ); |
177 | int result = ::ioctl( sfd, SIOCGIWNAME, &iwr ); | 179 | int result = ::ioctl( sfd, SIOCGIWNAME, &iwr ); |
178 | return result != -1; | 180 | return result != -1; |
179 | } | 181 | } |
180 | 182 | ||
181 | /*====================================================================================== | 183 | /*====================================================================================== |
182 | * ONetworkInterface | 184 | * ONetworkInterface |
183 | *======================================================================================*/ | 185 | *======================================================================================*/ |
184 | 186 | ||
185 | ONetworkInterface::ONetworkInterface( QObject* parent, const char* name ) | 187 | ONetworkInterface::ONetworkInterface( QObject* parent, const char* name ) |
186 | :QObject( parent, name ), | 188 | :QObject( parent, name ), |
187 | _sfd( socket( AF_INET, SOCK_DGRAM, 0 ) ), _mon( 0 ) | 189 | _sfd( socket( AF_INET, SOCK_DGRAM, 0 ) ), _mon( 0 ) |
188 | { | 190 | { |
189 | odebug << "ONetworkInterface::ONetworkInterface()" << oendl; | 191 | odebug << "ONetworkInterface::ONetworkInterface()" << oendl; |
190 | init(); | 192 | init(); |
191 | } | 193 | } |
192 | 194 | ||
193 | 195 | ||
194 | struct ifreq& ONetworkInterface::ifr() const | 196 | struct ifreq& ONetworkInterface::ifr() const |
195 | { | 197 | { |
196 | return _ifr; | 198 | return _ifr; |
197 | } | 199 | } |
198 | 200 | ||
199 | 201 | ||
200 | void ONetworkInterface::init() | 202 | void ONetworkInterface::init() |
201 | { | 203 | { |
202 | odebug << "ONetworkInterface::init()" << oendl; | 204 | odebug << "ONetworkInterface::init()" << oendl; |
203 | 205 | ||
204 | memset( &_ifr, 0, sizeof( struct ifreq ) ); | 206 | memset( &_ifr, 0, sizeof( struct ifreq ) ); |
205 | 207 | ||
206 | if ( _sfd == -1 ) | 208 | if ( _sfd == -1 ) |
207 | { | 209 | { |
208 | odebug << "ONetworkInterface::init(): Warning - can't get socket for device '" << name() << "'" << oendl; | 210 | odebug << "ONetworkInterface::init(): Warning - can't get socket for device '" << name() << "'" << oendl; |
209 | return; | 211 | return; |
210 | } | 212 | } |
211 | } | 213 | } |
212 | 214 | ||
213 | 215 | ||
214 | bool ONetworkInterface::ioctl( int call, struct ifreq& ifreq ) const | 216 | bool ONetworkInterface::ioctl( int call, struct ifreq& ifreq ) const |
215 | { | 217 | { |
216 | #ifndef NODEBUG | 218 | #ifndef NODEBUG |
217 | int result = ::ioctl( _sfd, call, &ifreq ); | 219 | int result = ::ioctl( _sfd, call, &ifreq ); |
218 | if ( result == -1 ) | 220 | if ( result == -1 ) |
219 | odebug << "ONetworkInterface::ioctl (" << name() << ") call '" << debugmapper->map( call ) | 221 | odebug << "ONetworkInterface::ioctl (" << name() << ") call '" << debugmapper->map( call ) |
220 | << "' FAILED! " << result << " (" << strerror( errno ) << ")" << oendl; | 222 | << "' FAILED! " << result << " (" << strerror( errno ) << ")" << oendl; |
221 | else | 223 | else |
222 | odebug << "ONetworkInterface::ioctl (" << name() << ") call '" << debugmapper->map( call ) | 224 | odebug << "ONetworkInterface::ioctl (" << name() << ") call '" << debugmapper->map( call ) |
223 | << "' - Status: Ok." << oendl; | 225 | << "' - Status: Ok." << oendl; |
224 | return ( result != -1 ); | 226 | return ( result != -1 ); |
225 | #else | 227 | #else |
226 | return ::ioctl( _sfd, call, &ifreq ) != -1; | 228 | return ::ioctl( _sfd, call, &ifreq ) != -1; |
227 | #endif | 229 | #endif |
228 | } | 230 | } |
229 | 231 | ||
230 | 232 | ||
231 | bool ONetworkInterface::ioctl( int call ) const | 233 | bool ONetworkInterface::ioctl( int call ) const |
232 | { | 234 | { |
233 | strcpy( _ifr.ifr_name, name() ); | 235 | strcpy( _ifr.ifr_name, name() ); |
234 | return ioctl( call, _ifr ); | 236 | return ioctl( call, _ifr ); |
235 | } | 237 | } |
236 | 238 | ||
237 | 239 | ||
238 | bool ONetworkInterface::isLoopback() const | 240 | bool ONetworkInterface::isLoopback() const |
239 | { | 241 | { |
240 | ioctl( SIOCGIFFLAGS ); | 242 | ioctl( SIOCGIFFLAGS ); |
241 | return _ifr.ifr_flags & IFF_LOOPBACK; | 243 | return _ifr.ifr_flags & IFF_LOOPBACK; |
242 | } | 244 | } |
243 | 245 | ||
244 | 246 | ||
245 | bool ONetworkInterface::setUp( bool b ) | 247 | bool ONetworkInterface::setUp( bool b ) |
246 | { | 248 | { |
247 | ioctl( SIOCGIFFLAGS ); | 249 | ioctl( SIOCGIFFLAGS ); |
248 | if ( b ) _ifr.ifr_flags |= IFF_UP; | 250 | if ( b ) _ifr.ifr_flags |= IFF_UP; |
249 | else _ifr.ifr_flags &= (~IFF_UP); | 251 | else _ifr.ifr_flags &= (~IFF_UP); |
250 | return ioctl( SIOCSIFFLAGS ); | 252 | return ioctl( SIOCSIFFLAGS ); |
251 | } | 253 | } |
252 | 254 | ||
253 | 255 | ||
254 | bool ONetworkInterface::isUp() const | 256 | bool ONetworkInterface::isUp() const |
255 | { | 257 | { |
256 | ioctl( SIOCGIFFLAGS ); | 258 | ioctl( SIOCGIFFLAGS ); |
257 | return _ifr.ifr_flags & IFF_UP; | 259 | return _ifr.ifr_flags & IFF_UP; |
258 | } | 260 | } |
259 | 261 | ||
260 | 262 | ||
261 | void ONetworkInterface::setIPV4Address( const QHostAddress& addr ) | 263 | void ONetworkInterface::setIPV4Address( const QHostAddress& addr ) |
262 | { | 264 | { |
263 | struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr; | 265 | struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr; |
264 | sa->sin_family = AF_INET; | 266 | sa->sin_family = AF_INET; |
265 | sa->sin_port = 0; | 267 | sa->sin_port = 0; |
266 | sa->sin_addr.s_addr = htonl( addr.ip4Addr() ); | 268 | sa->sin_addr.s_addr = htonl( addr.ip4Addr() ); |
267 | ioctl( SIOCSIFADDR ); | 269 | ioctl( SIOCSIFADDR ); |
268 | } | 270 | } |
269 | 271 | ||
270 | 272 | ||
271 | QString ONetworkInterface::ipV4Address() const | 273 | QString ONetworkInterface::ipV4Address() const |
272 | { | 274 | { |
273 | if ( ioctl( SIOCGIFADDR ) ) | 275 | if ( ioctl( SIOCGIFADDR ) ) |
274 | { | 276 | { |
275 | struct sockaddr_in* sa = (struct sockaddr_in *) &_ifr.ifr_addr; | 277 | struct sockaddr_in* sa = (struct sockaddr_in *) &_ifr.ifr_addr; |
276 | //FIXME: Use QHostAddress here | 278 | //FIXME: Use QHostAddress here |
277 | return QString( inet_ntoa( sa->sin_addr ) ); | 279 | return QString( inet_ntoa( sa->sin_addr ) ); |
278 | } | 280 | } |
279 | else | 281 | else |
280 | return "<unknown>"; | 282 | return "<unknown>"; |
281 | 283 | ||
282 | } | 284 | } |
283 | 285 | ||
284 | 286 | ||
285 | void ONetworkInterface::setMacAddress( const OMacAddress& addr ) | 287 | void ONetworkInterface::setMacAddress( const OMacAddress& addr ) |
286 | { | 288 | { |
287 | _ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER; | 289 | _ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER; |
288 | memcpy( &_ifr.ifr_hwaddr.sa_data, addr.native(), 6 ); | 290 | memcpy( &_ifr.ifr_hwaddr.sa_data, addr.native(), 6 ); |
289 | ioctl( SIOCSIFHWADDR ); | 291 | ioctl( SIOCSIFHWADDR ); |
290 | } | 292 | } |
291 | 293 | ||
292 | 294 | ||
293 | OMacAddress ONetworkInterface::macAddress() const | 295 | OMacAddress ONetworkInterface::macAddress() const |
294 | { | 296 | { |
295 | if ( ioctl( SIOCGIFHWADDR ) ) | 297 | if ( ioctl( SIOCGIFHWADDR ) ) |
296 | { | 298 | { |
297 | return OMacAddress( _ifr ); | 299 | return OMacAddress( _ifr ); |
298 | } | 300 | } |
299 | else | 301 | else |
300 | { | 302 | { |
301 | return OMacAddress::unknown; | 303 | return OMacAddress::unknown; |
302 | } | 304 | } |
303 | } | 305 | } |
304 | 306 | ||
305 | 307 | ||
306 | void ONetworkInterface::setIPV4Netmask( const QHostAddress& addr ) | 308 | void ONetworkInterface::setIPV4Netmask( const QHostAddress& addr ) |
307 | { | 309 | { |
308 | struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr; | 310 | struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr; |
309 | sa->sin_family = AF_INET; | 311 | sa->sin_family = AF_INET; |
310 | sa->sin_port = 0; | 312 | sa->sin_port = 0; |
311 | sa->sin_addr.s_addr = htonl( addr.ip4Addr() ); | 313 | sa->sin_addr.s_addr = htonl( addr.ip4Addr() ); |
312 | ioctl( SIOCSIFNETMASK ); | 314 | ioctl( SIOCSIFNETMASK ); |
313 | } | 315 | } |
314 | 316 | ||
315 | 317 | ||
316 | QString ONetworkInterface::ipV4Netmask() const | 318 | QString ONetworkInterface::ipV4Netmask() const |
317 | { | 319 | { |
318 | if ( ioctl( SIOCGIFNETMASK ) ) | 320 | if ( ioctl( SIOCGIFNETMASK ) ) |
319 | { | 321 | { |
320 | struct sockaddr_in* sa = (struct sockaddr_in *) &_ifr.ifr_addr; | 322 | struct sockaddr_in* sa = (struct sockaddr_in *) &_ifr.ifr_addr; |
321 | //FIXME: Use QHostAddress here | 323 | //FIXME: Use QHostAddress here |
322 | return QString( inet_ntoa( sa->sin_addr ) ); | 324 | return QString( inet_ntoa( sa->sin_addr ) ); |
323 | } | 325 | } |
324 | else | 326 | else |
325 | return "<unknown>"; | 327 | return "<unknown>"; |
326 | } | 328 | } |
327 | 329 | ||
328 | 330 | ||
329 | int ONetworkInterface::dataLinkType() const | 331 | int ONetworkInterface::dataLinkType() const |
330 | { | 332 | { |
331 | if ( ioctl( SIOCGIFHWADDR ) ) | 333 | if ( ioctl( SIOCGIFHWADDR ) ) |
332 | { | 334 | { |
333 | return _ifr.ifr_hwaddr.sa_family; | 335 | return _ifr.ifr_hwaddr.sa_family; |
334 | } | 336 | } |
335 | else | 337 | else |
336 | { | 338 | { |
337 | return -1; | 339 | return -1; |
338 | } | 340 | } |
339 | } | 341 | } |
340 | 342 | ||
341 | 343 | ||
342 | void ONetworkInterface::setMonitoring( OMonitoringInterface* m ) | 344 | void ONetworkInterface::setMonitoring( OMonitoringInterface* m ) |
343 | { | 345 | { |
344 | _mon = m; | 346 | _mon = m; |
345 | odebug << "ONetwork::setMonitoring(): Installed monitoring driver '" << m->name() << "' on interface '" << name() << "'" << oendl; | 347 | odebug << "ONetwork::setMonitoring(): Installed monitoring driver '" << m->name() << "' on interface '" << name() << "'" << oendl; |
346 | } | 348 | } |
347 | 349 | ||
348 | 350 | ||
349 | OMonitoringInterface* ONetworkInterface::monitoring() const | 351 | OMonitoringInterface* ONetworkInterface::monitoring() const |
350 | { | 352 | { |
351 | return _mon; | 353 | return _mon; |
352 | } | 354 | } |
353 | 355 | ||
354 | 356 | ||
355 | ONetworkInterface::~ONetworkInterface() | 357 | ONetworkInterface::~ONetworkInterface() |
356 | { | 358 | { |
357 | odebug << "ONetworkInterface::~ONetworkInterface()" << oendl; | 359 | odebug << "ONetworkInterface::~ONetworkInterface()" << oendl; |
358 | if ( _sfd != -1 ) ::close( _sfd ); | 360 | if ( _sfd != -1 ) ::close( _sfd ); |
359 | } | 361 | } |
360 | 362 | ||
361 | 363 | ||
362 | bool ONetworkInterface::setPromiscuousMode( bool b ) | 364 | bool ONetworkInterface::setPromiscuousMode( bool b ) |
363 | { | 365 | { |
364 | ioctl( SIOCGIFFLAGS ); | 366 | ioctl( SIOCGIFFLAGS ); |
365 | if ( b ) _ifr.ifr_flags |= IFF_PROMISC; | 367 | if ( b ) _ifr.ifr_flags |= IFF_PROMISC; |
366 | else _ifr.ifr_flags &= (~IFF_PROMISC); | 368 | else _ifr.ifr_flags &= (~IFF_PROMISC); |
367 | return ioctl( SIOCSIFFLAGS ); | 369 | return ioctl( SIOCSIFFLAGS ); |
368 | } | 370 | } |
369 | 371 | ||
370 | 372 | ||
371 | bool ONetworkInterface::promiscuousMode() const | 373 | bool ONetworkInterface::promiscuousMode() const |
372 | { | 374 | { |
373 | ioctl( SIOCGIFFLAGS ); | 375 | ioctl( SIOCGIFFLAGS ); |
374 | return _ifr.ifr_flags & IFF_PROMISC; | 376 | return _ifr.ifr_flags & IFF_PROMISC; |
375 | } | 377 | } |
376 | 378 | ||
377 | 379 | ||
378 | bool ONetworkInterface::isWireless() const | 380 | bool ONetworkInterface::isWireless() const |
379 | { | 381 | { |
380 | return ioctl( SIOCGIWNAME ); | 382 | return ioctl( SIOCGIWNAME ); |
381 | } | 383 | } |
382 | 384 | ||
383 | 385 | ||
386 | ONetworkInterfaceDriverInfo ONetworkInterface::driverInfo() const | ||
387 | { | ||
388 | struct ethtool_drvinfo info; | ||
389 | info.cmd = ETHTOOL_GDRVINFO; | ||
390 | _ifr.ifr_data = (caddr_t) &info; | ||
391 | return ioctl( SIOCETHTOOL ) ? ONetworkInterfaceDriverInfo( info.driver, info.version, info.fw_version, info.bus_info) : ONetworkInterfaceDriverInfo(); | ||
392 | } | ||
393 | |||
384 | /*====================================================================================== | 394 | /*====================================================================================== |
385 | * OChannelHopper | 395 | * OChannelHopper |
386 | *======================================================================================*/ | 396 | *======================================================================================*/ |
387 | 397 | ||
388 | OChannelHopper::OChannelHopper( OWirelessNetworkInterface* iface ) | 398 | OChannelHopper::OChannelHopper( OWirelessNetworkInterface* iface ) |
389 | :QObject( 0, "Mickey's funky hopper" ), | 399 | :QObject( 0, "Mickey's funky hopper" ), |
390 | _iface( iface ), _interval( 0 ), _tid( 0 ) | 400 | _iface( iface ), _interval( 0 ), _tid( 0 ) |
391 | { | 401 | { |
392 | int _maxChannel = iface->channels(); | 402 | int _maxChannel = iface->channels(); |
393 | // generate fancy hopping sequence honoring the device capabilities | 403 | // generate fancy hopping sequence honoring the device capabilities |
394 | if ( _maxChannel >= 1 ) _channels.append( 1 ); | 404 | if ( _maxChannel >= 1 ) _channels.append( 1 ); |
395 | if ( _maxChannel >= 7 ) _channels.append( 7 ); | 405 | if ( _maxChannel >= 7 ) _channels.append( 7 ); |
396 | if ( _maxChannel >= 13 ) _channels.append( 13 ); | 406 | if ( _maxChannel >= 13 ) _channels.append( 13 ); |
397 | if ( _maxChannel >= 2 ) _channels.append( 2 ); | 407 | if ( _maxChannel >= 2 ) _channels.append( 2 ); |
398 | if ( _maxChannel >= 8 ) _channels.append( 8 ); | 408 | if ( _maxChannel >= 8 ) _channels.append( 8 ); |
399 | if ( _maxChannel >= 3 ) _channels.append( 3 ); | 409 | if ( _maxChannel >= 3 ) _channels.append( 3 ); |
400 | if ( _maxChannel >= 14 ) _channels.append( 14 ); | 410 | if ( _maxChannel >= 14 ) _channels.append( 14 ); |
401 | if ( _maxChannel >= 9 ) _channels.append( 9 ); | 411 | if ( _maxChannel >= 9 ) _channels.append( 9 ); |
402 | if ( _maxChannel >= 4 ) _channels.append( 4 ); | 412 | if ( _maxChannel >= 4 ) _channels.append( 4 ); |
403 | if ( _maxChannel >= 10 ) _channels.append( 10 ); | 413 | if ( _maxChannel >= 10 ) _channels.append( 10 ); |
404 | if ( _maxChannel >= 5 ) _channels.append( 5 ); | 414 | if ( _maxChannel >= 5 ) _channels.append( 5 ); |
405 | if ( _maxChannel >= 11 ) _channels.append( 11 ); | 415 | if ( _maxChannel >= 11 ) _channels.append( 11 ); |
406 | if ( _maxChannel >= 6 ) _channels.append( 6 ); | 416 | if ( _maxChannel >= 6 ) _channels.append( 6 ); |
407 | if ( _maxChannel >= 12 ) _channels.append( 12 ); | 417 | if ( _maxChannel >= 12 ) _channels.append( 12 ); |
418 | //FIXME: Add 802.11a/g channels | ||
408 | _channel = _channels.begin(); | 419 | _channel = _channels.begin(); |
409 | } | 420 | } |
410 | 421 | ||
411 | 422 | ||
412 | OChannelHopper::~OChannelHopper() | 423 | OChannelHopper::~OChannelHopper() |
413 | { | 424 | { |
414 | } | 425 | } |
415 | 426 | ||
416 | 427 | ||
417 | bool OChannelHopper::isActive() const | 428 | bool OChannelHopper::isActive() const |
418 | { | 429 | { |
419 | return _tid; | 430 | return _tid; |
420 | } | 431 | } |
421 | 432 | ||
422 | 433 | ||
423 | int OChannelHopper::channel() const | 434 | int OChannelHopper::channel() const |
424 | { | 435 | { |
425 | return *_channel; | 436 | return *_channel; |
426 | } | 437 | } |
427 | 438 | ||
428 | 439 | ||
429 | void OChannelHopper::timerEvent( QTimerEvent* ) | 440 | void OChannelHopper::timerEvent( QTimerEvent* ) |
430 | { | 441 | { |
431 | _iface->setChannel( *_channel ); | 442 | _iface->setChannel( *_channel ); |
432 | emit( hopped( *_channel ) ); | 443 | emit( hopped( *_channel ) ); |
433 | odebug << "OChannelHopper::timerEvent(): set channel " << *_channel << " on interface '" << _iface->name() << "'" << oendl; | 444 | odebug << "OChannelHopper::timerEvent(): set channel " << *_channel << " on interface '" << _iface->name() << "'" << oendl; |
434 | if ( ++_channel == _channels.end() ) _channel = _channels.begin(); | 445 | if ( ++_channel == _channels.end() ) _channel = _channels.begin(); |
435 | } | 446 | } |
436 | 447 | ||
437 | 448 | ||
438 | void OChannelHopper::setInterval( int interval ) | 449 | void OChannelHopper::setInterval( int interval ) |
439 | { | 450 | { |
440 | if ( interval == _interval ) | 451 | if ( interval == _interval ) |
441 | return; | 452 | return; |
442 | 453 | ||
443 | if ( _interval ) | 454 | if ( _interval ) |
444 | killTimer( _tid ); | 455 | killTimer( _tid ); |
445 | 456 | ||
446 | _tid = 0; | 457 | _tid = 0; |
447 | _interval = interval; | 458 | _interval = interval; |
448 | 459 | ||
449 | if ( _interval ) | 460 | if ( _interval ) |
450 | { | 461 | { |
451 | _tid = startTimer( interval ); | 462 | _tid = startTimer( interval ); |
452 | } | 463 | } |
453 | } | 464 | } |
454 | 465 | ||
455 | 466 | ||
456 | int OChannelHopper::interval() const | 467 | int OChannelHopper::interval() const |
457 | { | 468 | { |
458 | return _interval; | 469 | return _interval; |
459 | } | 470 | } |
460 | 471 | ||
461 | 472 | ||
462 | /*====================================================================================== | 473 | /*====================================================================================== |
463 | * OWirelessNetworkInterface | 474 | * OWirelessNetworkInterface |
464 | *======================================================================================*/ | 475 | *======================================================================================*/ |
465 | 476 | ||
466 | OWirelessNetworkInterface::OWirelessNetworkInterface( QObject* parent, const char* name ) | 477 | OWirelessNetworkInterface::OWirelessNetworkInterface( QObject* parent, const char* name ) |
467 | :ONetworkInterface( parent, name ), _hopper( 0 ) | 478 | :ONetworkInterface( parent, name ), _hopper( 0 ) |
468 | { | 479 | { |
469 | odebug << "OWirelessNetworkInterface::OWirelessNetworkInterface()" << oendl; | 480 | odebug << "OWirelessNetworkInterface::OWirelessNetworkInterface()" << oendl; |
470 | init(); | 481 | init(); |
471 | } | 482 | } |
472 | 483 | ||
473 | 484 | ||
474 | OWirelessNetworkInterface::~OWirelessNetworkInterface() | 485 | OWirelessNetworkInterface::~OWirelessNetworkInterface() |
475 | { | 486 | { |
476 | } | 487 | } |
477 | 488 | ||
478 | 489 | ||
479 | struct iwreq& OWirelessNetworkInterface::iwr() const | 490 | struct iwreq& OWirelessNetworkInterface::iwr() const |
480 | { | 491 | { |
481 | return _iwr; | 492 | return _iwr; |
482 | } | 493 | } |
483 | 494 | ||
484 | 495 | ||
485 | void OWirelessNetworkInterface::init() | 496 | void OWirelessNetworkInterface::init() |
486 | { | 497 | { |
487 | odebug << "OWirelessNetworkInterface::init()" << oendl; | 498 | odebug << "OWirelessNetworkInterface::init()" << oendl; |
488 | memset( &_iwr, 0, sizeof( struct iwreq ) ); | 499 | memset( &_iwr, 0, sizeof( struct iwreq ) ); |
489 | buildInformation(); | 500 | buildInformation(); |
490 | buildPrivateList(); | 501 | buildPrivateList(); |
491 | dumpInformation(); | 502 | dumpInformation(); |
492 | } | 503 | } |
493 | 504 | ||
494 | 505 | ||
495 | bool OWirelessNetworkInterface::isAssociated() const | 506 | bool OWirelessNetworkInterface::isAssociated() const |
496 | { | 507 | { |
497 | //FIXME: handle different modes | 508 | //FIXME: handle different modes |
498 | return !(associatedAP() == OMacAddress::unknown); | 509 | return !(associatedAP() == OMacAddress::unknown); |
499 | } | 510 | } |
500 | 511 | ||
501 | 512 | ||
502 | void OWirelessNetworkInterface::setAssociatedAP( const OMacAddress& mac ) const | 513 | void OWirelessNetworkInterface::setAssociatedAP( const OMacAddress& mac ) const |
503 | { | 514 | { |
504 | _iwr.u.ap_addr.sa_family = ARPHRD_ETHER; | 515 | _iwr.u.ap_addr.sa_family = ARPHRD_ETHER; |
505 | ::memcpy(_iwr.u.ap_addr.sa_data, mac.native(), ETH_ALEN); | 516 | ::memcpy(_iwr.u.ap_addr.sa_data, mac.native(), ETH_ALEN); |
506 | wioctl( SIOCSIWAP ); | 517 | wioctl( SIOCSIWAP ); |
507 | } | 518 | } |
508 | 519 | ||
509 | 520 | ||
510 | OMacAddress OWirelessNetworkInterface::associatedAP() const | 521 | OMacAddress OWirelessNetworkInterface::associatedAP() const |
511 | { | 522 | { |
512 | if ( ioctl( SIOCGIWAP ) ) | 523 | if ( ioctl( SIOCGIWAP ) ) |
513 | return (const unsigned char*) &_ifr.ifr_hwaddr.sa_data[0]; | 524 | return (const unsigned char*) &_ifr.ifr_hwaddr.sa_data[0]; |
514 | else | 525 | else |
515 | return OMacAddress::unknown; | 526 | return OMacAddress::unknown; |
516 | } | 527 | } |
517 | 528 | ||
518 | 529 | ||
519 | void OWirelessNetworkInterface::buildInformation() | 530 | void OWirelessNetworkInterface::buildInformation() |
520 | { | 531 | { |
521 | //ML: If you listen carefully enough, you can hear lots of WLAN drivers suck | 532 | //ML: If you listen carefully enough, you can hear lots of WLAN drivers suck |
522 | //ML: The HostAP drivers need more than sizeof struct_iw range to complete | 533 | //ML: The HostAP drivers need more than sizeof struct_iw range to complete |
523 | //ML: SIOCGIWRANGE otherwise they fail with "Invalid Argument Length". | 534 | //ML: SIOCGIWRANGE otherwise they fail with "Invalid Argument Length". |
524 | //ML: The Wlan-NG drivers on the otherside fail (segfault!) if you allocate | 535 | //ML: The Wlan-NG drivers on the otherside fail (segfault!) if you allocate |
525 | //ML: _too much_ space. This is damn shitty crap *sigh* | 536 | //ML: _too much_ space. This is damn shitty crap *sigh* |
526 | //ML: We allocate a large memory region in RAM and check whether the | 537 | //ML: We allocate a large memory region in RAM and check whether the |
527 | //ML: driver pollutes this extra space. The complaint will be made on stdout, | 538 | //ML: driver pollutes this extra space. The complaint will be made on stdout, |
528 | //ML: so please forward this... | 539 | //ML: so please forward this... |
529 | 540 | ||
530 | struct iwreq wrq; | 541 | struct iwreq wrq; |
531 | int len = sizeof( struct iw_range )*2; | 542 | int len = sizeof( struct iw_range )*2; |
532 | char buffer[len]; | 543 | char buffer[len]; |
533 | memset( buffer, 0, len ); | 544 | memset( buffer, 0, len ); |
534 | memcpy( wrq.ifr_name, name(), IFNAMSIZ); | 545 | memcpy( wrq.ifr_name, name(), IFNAMSIZ); |
535 | wrq.u.data.pointer = (caddr_t) buffer; | 546 | wrq.u.data.pointer = (caddr_t) buffer; |
536 | wrq.u.data.length = sizeof buffer; | 547 | wrq.u.data.length = sizeof buffer; |
537 | wrq.u.data.flags = 0; | 548 | wrq.u.data.flags = 0; |
538 | 549 | ||
539 | if ( ::ioctl( _sfd, SIOCGIWRANGE, &wrq ) == -1 ) | 550 | if ( ::ioctl( _sfd, SIOCGIWRANGE, &wrq ) == -1 ) |
540 | { | 551 | { |
541 | owarn << "OWirelessNetworkInterface::buildInformation(): Can't get driver information (" << strerror( errno ) << ") - using default values." << oendl; | 552 | owarn << "OWirelessNetworkInterface::buildInformation(): Can't get driver information (" << strerror( errno ) << ") - using default values." << oendl; |
542 | _channels.insert( 2412, 1 ); // 2.412 GHz | 553 | _channels.insert( 2412, 1 ); // 2.412 GHz |
543 | _channels.insert( 2417, 2 ); // 2.417 GHz | 554 | _channels.insert( 2417, 2 ); // 2.417 GHz |
544 | _channels.insert( 2422, 3 ); // 2.422 GHz | 555 | _channels.insert( 2422, 3 ); // 2.422 GHz |
545 | _channels.insert( 2427, 4 ); // 2.427 GHz | 556 | _channels.insert( 2427, 4 ); // 2.427 GHz |
546 | _channels.insert( 2432, 5 ); // 2.432 GHz | 557 | _channels.insert( 2432, 5 ); // 2.432 GHz |
547 | _channels.insert( 2437, 6 ); // 2.437 GHz | 558 | _channels.insert( 2437, 6 ); // 2.437 GHz |
548 | _channels.insert( 2442, 7 ); // 2.442 GHz | 559 | _channels.insert( 2442, 7 ); // 2.442 GHz |
549 | _channels.insert( 2447, 8 ); // 2.447 GHz | 560 | _channels.insert( 2447, 8 ); // 2.447 GHz |
550 | _channels.insert( 2452, 9 ); // 2.452 GHz | 561 | _channels.insert( 2452, 9 ); // 2.452 GHz |
551 | _channels.insert( 2457, 10 ); // 2.457 GHz | 562 | _channels.insert( 2457, 10 ); // 2.457 GHz |
552 | _channels.insert( 2462, 11 ); // 2.462 GHz | 563 | _channels.insert( 2462, 11 ); // 2.462 GHz |
553 | 564 | ||
554 | memset( &_range, 0, sizeof( struct iw_range ) ); | 565 | memset( &_range, 0, sizeof( struct iw_range ) ); |
555 | } | 566 | } |
556 | else | 567 | else |
557 | { | 568 | { |
558 | // <check if the driver overwrites stuff> | 569 | // <check if the driver overwrites stuff> |
559 | int max = 0; | 570 | int max = 0; |
560 | for ( int r = sizeof( struct iw_range ); r < len; r++ ) | 571 | for ( int r = sizeof( struct iw_range ); r < len; r++ ) |
561 | if (buffer[r] != 0) | 572 | if (buffer[r] != 0) |
562 | max = r; | 573 | max = r; |
563 | if (max > 0) | 574 | if (max > 0) |
564 | { | 575 | { |
565 | owarn << "OWirelessNetworkInterface::buildInformation(): Driver for wireless interface '" << name() | 576 | owarn << "OWirelessNetworkInterface::buildInformation(): Driver for wireless interface '" << name() |
566 | << "' sucks! It overwrote the buffer end with at least " << max - sizeof( struct iw_range ) << " bytes!" << oendl; | 577 | << "' sucks! It overwrote the buffer end with at least " << max - sizeof( struct iw_range ) << " bytes!" << oendl; |
567 | } | 578 | } |
568 | // </check if the driver overwrites stuff> | 579 | // </check if the driver overwrites stuff> |
569 | 580 | ||
570 | struct iw_range range; | 581 | struct iw_range range; |
571 | memcpy( &range, buffer, sizeof range ); | 582 | memcpy( &range, buffer, sizeof range ); |
572 | 583 | ||
573 | odebug << "OWirelessNetworkInterface::buildInformation(): Interface reported to have " << (int) range.num_frequency << " channels." << oendl; | 584 | odebug << "OWirelessNetworkInterface::buildInformation(): Interface reported to have " << (int) range.num_frequency << " channels." << oendl; |
574 | for ( int i = 0; i < range.num_frequency; ++i ) | 585 | for ( int i = 0; i < range.num_frequency; ++i ) |
575 | { | 586 | { |
576 | int freq = (int) ( double( range.freq[i].m ) * pow( 10.0, range.freq[i].e ) / 1000000.0 ); | 587 | int freq = (int) ( double( range.freq[i].m ) * pow( 10.0, range.freq[i].e ) / 1000000.0 ); |
577 | odebug << "OWirelessNetworkInterface::buildInformation: Adding frequency " << freq << " as channel " << i+1 << oendl; | 588 | odebug << "OWirelessNetworkInterface::buildInformation: Adding frequency " << freq << " as channel " << i+1 << oendl; |
578 | _channels.insert( freq, i+1 ); | 589 | _channels.insert( freq, i+1 ); |
579 | } | 590 | } |
580 | } | 591 | } |
581 | 592 | ||
582 | memcpy( &_range, buffer, sizeof( struct iw_range ) ); | 593 | memcpy( &_range, buffer, sizeof( struct iw_range ) ); |
583 | odebug << "OWirelessNetworkInterface::buildInformation(): Information block constructed." << oendl; | 594 | odebug << "OWirelessNetworkInterface::buildInformation(): Information block constructed." << oendl; |
584 | } | 595 | } |
585 | 596 | ||
586 | 597 | ||
587 | short OWirelessNetworkInterface::wirelessExtensionDriverVersion() const | 598 | short OWirelessNetworkInterface::wirelessExtensionDriverVersion() const |
588 | { | 599 | { |
589 | return _range.we_version_compiled; | 600 | return _range.we_version_compiled; |
590 | } | 601 | } |
591 | 602 | ||
592 | 603 | ||
593 | void OWirelessNetworkInterface::buildPrivateList() | 604 | void OWirelessNetworkInterface::buildPrivateList() |
594 | { | 605 | { |
595 | odebug << "OWirelessNetworkInterface::buildPrivateList()" << oendl; | 606 | odebug << "OWirelessNetworkInterface::buildPrivateList()" << oendl; |
596 | 607 | ||
597 | struct iw_priv_args priv[IW_MAX_PRIV_DEF]; | 608 | struct iw_priv_args priv[IW_MAX_PRIV_DEF]; |
598 | 609 | ||
599 | _iwr.u.data.pointer = (char*) &priv; | 610 | _iwr.u.data.pointer = (char*) &priv; |
600 | _iwr.u.data.length = IW_MAX_PRIV_DEF; // length in terms of number of (sizeof iw_priv_args), not (sizeof iw_priv_args) itself | 611 | _iwr.u.data.length = IW_MAX_PRIV_DEF; // length in terms of number of (sizeof iw_priv_args), not (sizeof iw_priv_args) itself |
601 | _iwr.u.data.flags = 0; | 612 | _iwr.u.data.flags = 0; |
602 | 613 | ||
603 | if ( !wioctl( SIOCGIWPRIV ) ) | 614 | if ( !wioctl( SIOCGIWPRIV ) ) |
604 | { | 615 | { |
605 | owarn << "OWirelessNetworkInterface::buildPrivateList(): Can't get private ioctl information (" << strerror( errno ) << ")." << oendl; | 616 | owarn << "OWirelessNetworkInterface::buildPrivateList(): Can't get private ioctl information (" << strerror( errno ) << ")." << oendl; |
606 | return; | 617 | return; |
607 | } | 618 | } |
608 | 619 | ||
609 | for ( int i = 0; i < _iwr.u.data.length; ++i ) | 620 | for ( int i = 0; i < _iwr.u.data.length; ++i ) |
610 | { | 621 | { |
611 | new OPrivateIOCTL( this, priv[i].name, priv[i].cmd, priv[i].get_args, priv[i].set_args ); | 622 | new OPrivateIOCTL( this, priv[i].name, priv[i].cmd, priv[i].get_args, priv[i].set_args ); |
612 | } | 623 | } |
613 | odebug << "OWirelessNetworkInterface::buildPrivateList(): Private ioctl list constructed." << oendl; | 624 | odebug << "OWirelessNetworkInterface::buildPrivateList(): Private ioctl list constructed." << oendl; |
614 | } | 625 | } |
615 | 626 | ||
616 | 627 | ||
617 | void OWirelessNetworkInterface::dumpInformation() const | 628 | void OWirelessNetworkInterface::dumpInformation() const |
618 | { | 629 | { |
619 | odebug << "OWirelessNetworkInterface::() -------------- dumping information block ----------------" << oendl; | 630 | odebug << "OWirelessNetworkInterface::() -------------- dumping information block ----------------" << oendl; |
620 | 631 | ||
621 | odebug << " - driver's idea of maximum throughput is " << _range.throughput | 632 | odebug << " - driver's idea of maximum throughput is " << _range.throughput |
622 | << " bps = " << ( _range.throughput / 8 ) << " byte/s = " << ( _range.throughput / 8 / 1024 ) | 633 | << " bps = " << ( _range.throughput / 8 ) << " byte/s = " << ( _range.throughput / 8 / 1024 ) |
623 | << " Kb/s = " << QString().sprintf("%f.2", float( _range.throughput ) / 8.0 / 1024.0 / 1024.0 ) | 634 | << " Kb/s = " << QString().sprintf("%f.2", float( _range.throughput ) / 8.0 / 1024.0 / 1024.0 ) |
624 | << " Mb/s" << oendl; | 635 | << " Mb/s" << oendl; |
625 | 636 | ||
626 | odebug << " - driver for '" << name() << "' (V" << _range.we_version_source | 637 | odebug << " - driver for '" << name() << "' (V" << _range.we_version_source |
627 | << ") has been compiled against WE V" << _range.we_version_compiled << oendl; | 638 | << ") has been compiled against WE V" << _range.we_version_compiled << oendl; |
628 | 639 | ||
629 | if ( _range.we_version_compiled != WIRELESS_EXT ) | 640 | if ( _range.we_version_compiled != WIRELESS_EXT ) |
630 | { | 641 | { |
631 | owarn << "Version mismatch! WE_DRIVER = " << _range.we_version_compiled << " and WE_OPIENET = " << WIRELESS_EXT << oendl; | 642 | owarn << "Version mismatch! WE_DRIVER = " << _range.we_version_compiled << " and WE_OPIENET = " << WIRELESS_EXT << oendl; |
632 | } | 643 | } |
633 | 644 | ||
634 | odebug << "OWirelessNetworkInterface::() ---------------------------------------------------------" << oendl; | 645 | odebug << "OWirelessNetworkInterface::() ---------------------------------------------------------" << oendl; |
635 | } | 646 | } |
636 | 647 | ||
637 | 648 | ||
638 | int OWirelessNetworkInterface::channel() const | 649 | int OWirelessNetworkInterface::channel() const |
639 | { | 650 | { |
640 | //FIXME: When monitoring enabled, then use it | 651 | //FIXME: When monitoring enabled, then use it |
641 | //FIXME: to gather the current RF channel | 652 | //FIXME: to gather the current RF channel |
642 | //FIXME: Until then, get active channel from hopper. | 653 | //FIXME: Until then, get active channel from hopper. |
643 | if ( _hopper && _hopper->isActive() ) | 654 | if ( _hopper && _hopper->isActive() ) |
644 | return _hopper->channel(); | 655 | return _hopper->channel(); |
645 | 656 | ||
646 | if ( !wioctl( SIOCGIWFREQ ) ) | 657 | if ( !wioctl( SIOCGIWFREQ ) ) |
647 | { | 658 | { |
648 | return -1; | 659 | return -1; |
649 | } | 660 | } |
650 | else | 661 | else |
651 | { | 662 | { |
652 | return _channels[ static_cast<int>(double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000) ]; | 663 | return _channels[ static_cast<int>(double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000) ]; |
653 | } | 664 | } |
654 | } | 665 | } |
655 | 666 | ||
656 | 667 | ||
657 | void OWirelessNetworkInterface::setChannel( int c ) const | 668 | void OWirelessNetworkInterface::setChannel( int c ) const |
658 | { | 669 | { |
659 | if ( !c ) | 670 | if ( !c ) |
660 | { | 671 | { |
661 | oerr << "OWirelessNetworkInterface::setChannel( 0 ) called - fix your application!" << oendl; | 672 | oerr << "OWirelessNetworkInterface::setChannel( 0 ) called - fix your application!" << oendl; |
662 | return; | 673 | return; |
663 | } | 674 | } |
664 | 675 | ||
665 | if ( !_mon ) | 676 | if ( !_mon ) |
666 | { | 677 | { |
667 | memset( &_iwr, 0, sizeof( struct iwreq ) ); | 678 | memset( &_iwr, 0, sizeof( struct iwreq ) ); |
668 | _iwr.u.freq.m = c; | 679 | _iwr.u.freq.m = c; |
669 | _iwr.u.freq.e = 0; | 680 | _iwr.u.freq.e = 0; |
670 | wioctl( SIOCSIWFREQ ); | 681 | wioctl( SIOCSIWFREQ ); |
671 | } | 682 | } |
672 | else | 683 | else |
673 | { | 684 | { |
674 | _mon->setChannel( c ); | 685 | _mon->setChannel( c ); |
675 | } | 686 | } |
676 | } | 687 | } |
677 | 688 | ||
678 | 689 | ||
679 | double OWirelessNetworkInterface::frequency() const | 690 | double OWirelessNetworkInterface::frequency() const |
680 | { | 691 | { |
681 | if ( !wioctl( SIOCGIWFREQ ) ) | 692 | if ( !wioctl( SIOCGIWFREQ ) ) |
682 | { | 693 | { |
683 | return -1.0; | 694 | return -1.0; |
684 | } | 695 | } |
685 | else | 696 | else |
686 | { | 697 | { |
687 | return double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000000.0; | 698 | return double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000000.0; |
688 | } | 699 | } |
689 | } | 700 | } |
690 | 701 | ||
691 | 702 | ||
692 | int OWirelessNetworkInterface::channels() const | 703 | int OWirelessNetworkInterface::channels() const |
693 | { | 704 | { |
694 | return _channels.count(); | 705 | return _channels.count(); |
695 | } | 706 | } |
696 | 707 | ||
697 | 708 | ||
698 | void OWirelessNetworkInterface::setChannelHopping( int interval ) | 709 | void OWirelessNetworkInterface::setChannelHopping( int interval ) |
699 | { | 710 | { |
700 | if ( !_hopper ) _hopper = new OChannelHopper( this ); | 711 | if ( !_hopper ) _hopper = new OChannelHopper( this ); |
701 | _hopper->setInterval( interval ); | 712 | _hopper->setInterval( interval ); |
702 | //FIXME: When and by whom will the channel hopper be deleted? | 713 | //FIXME: When and by whom will the channel hopper be deleted? |
703 | //TODO: rely on QObject hierarchy | 714 | //TODO: rely on QObject hierarchy |
704 | } | 715 | } |
705 | 716 | ||
706 | 717 | ||
707 | int OWirelessNetworkInterface::channelHopping() const | 718 | int OWirelessNetworkInterface::channelHopping() const |
708 | { | 719 | { |
709 | return _hopper->interval(); | 720 | return _hopper->interval(); |
710 | } | 721 | } |
711 | 722 | ||
712 | 723 | ||
713 | OChannelHopper* OWirelessNetworkInterface::channelHopper() const | 724 | OChannelHopper* OWirelessNetworkInterface::channelHopper() const |
714 | { | 725 | { |
715 | return _hopper; | 726 | return _hopper; |
716 | } | 727 | } |
717 | 728 | ||
718 | 729 | ||
719 | void OWirelessNetworkInterface::commit() const | 730 | void OWirelessNetworkInterface::commit() const |
720 | { | 731 | { |
721 | wioctl( SIOCSIWCOMMIT ); | 732 | wioctl( SIOCSIWCOMMIT ); |
722 | } | 733 | } |
723 | 734 | ||
724 | 735 | ||
725 | void OWirelessNetworkInterface::setMode( const QString& newMode ) | 736 | void OWirelessNetworkInterface::setMode( const QString& newMode ) |
726 | { | 737 | { |
727 | #ifdef FINALIZE | 738 | #ifdef FINALIZE |
728 | QString currentMode = mode(); | 739 | QString currentMode = mode(); |
729 | if ( currentMode == newMode ) return; | 740 | if ( currentMode == newMode ) return; |
730 | #endif | 741 | #endif |
731 | 742 | ||
732 | odebug << "OWirelessNetworkInterface::setMode(): trying to set mode " << newMode << oendl; | 743 | odebug << "OWirelessNetworkInterface::setMode(): trying to set mode " << newMode << oendl; |
733 | 744 | ||
734 | _iwr.u.mode = stringToMode( newMode ); | 745 | _iwr.u.mode = stringToMode( newMode ); |
735 | 746 | ||
736 | if ( _iwr.u.mode != IW_MODE_MONITOR ) | 747 | if ( _iwr.u.mode != IW_MODE_MONITOR ) |
737 | { | 748 | { |
738 | // IWR.U.MODE WIRD DURCH ABFRAGE DES MODE HIER PLATTGEMACHT!!!!!!!!!!!!!!!!!!!!! DEPP! | 749 | // IWR.U.MODE WIRD DURCH ABFRAGE DES MODE HIER PLATTGEMACHT!!!!!!!!!!!!!!!!!!!!! DEPP! |
739 | _iwr.u.mode = stringToMode( newMode ); | 750 | _iwr.u.mode = stringToMode( newMode ); |
740 | wioctl( SIOCSIWMODE ); | 751 | wioctl( SIOCSIWMODE ); |
741 | 752 | ||
742 | // special iwpriv fallback for monitor mode (check if we're really out of monitor mode now) | 753 | // special iwpriv fallback for monitor mode (check if we're really out of monitor mode now) |
743 | 754 | ||
744 | if ( mode() == "monitor" ) | 755 | if ( mode() == "monitor" ) |
745 | { | 756 | { |
746 | odebug << "OWirelessNetworkInterface::setMode(): SIOCSIWMODE not sufficient - trying fallback to iwpriv..." << oendl; | 757 | odebug << "OWirelessNetworkInterface::setMode(): SIOCSIWMODE not sufficient - trying fallback to iwpriv..." << oendl; |
747 | if ( _mon ) | 758 | if ( _mon ) |
748 | _mon->setEnabled( false ); | 759 | _mon->setEnabled( false ); |
749 | else | 760 | else |
750 | odebug << "ONetwork(): can't switch monitor mode without installed monitoring interface" << oendl; | 761 | odebug << "ONetwork(): can't switch monitor mode without installed monitoring interface" << oendl; |
751 | } | 762 | } |
752 | 763 | ||
753 | } | 764 | } |
754 | else // special iwpriv fallback for monitor mode | 765 | else // special iwpriv fallback for monitor mode |
755 | { | 766 | { |
756 | if ( wioctl( SIOCSIWMODE ) ) | 767 | if ( wioctl( SIOCSIWMODE ) ) |
757 | { | 768 | { |
758 | odebug << "OWirelessNetworkInterface::setMode(): IW_MODE_MONITOR ok" << oendl; | 769 | odebug << "OWirelessNetworkInterface::setMode(): IW_MODE_MONITOR ok" << oendl; |
759 | } | 770 | } |
760 | else | 771 | else |
761 | { | 772 | { |
762 | odebug << "OWirelessNetworkInterface::setMode(): SIOCSIWMODE not working - trying fallback to iwpriv..." << oendl; | 773 | odebug << "OWirelessNetworkInterface::setMode(): SIOCSIWMODE not working - trying fallback to iwpriv..." << oendl; |
763 | 774 | ||
764 | if ( _mon ) | 775 | if ( _mon ) |
765 | _mon->setEnabled( true ); | 776 | _mon->setEnabled( true ); |
766 | else | 777 | else |
767 | odebug << "ONetwork(): can't switch monitor mode without installed monitoring interface" << oendl; | 778 | odebug << "ONetwork(): can't switch monitor mode without installed monitoring interface" << oendl; |
768 | } | 779 | } |
769 | } | 780 | } |
770 | } | 781 | } |
771 | 782 | ||
772 | 783 | ||
773 | QString OWirelessNetworkInterface::mode() const | 784 | QString OWirelessNetworkInterface::mode() const |
774 | { | 785 | { |
775 | memset( &_iwr, 0, sizeof( struct iwreq ) ); | 786 | memset( &_iwr, 0, sizeof( struct iwreq ) ); |
776 | 787 | ||
777 | if ( !wioctl( SIOCGIWMODE ) ) | 788 | if ( !wioctl( SIOCGIWMODE ) ) |
778 | { | 789 | { |
779 | return "<unknown>"; | 790 | return "<unknown>"; |
780 | } | 791 | } |
781 | 792 | ||
782 | odebug << "OWirelessNetworkInterface::setMode(): WE's idea of current mode seems to be " << modeToString( _iwr.u.mode ) << oendl; | 793 | odebug << "OWirelessNetworkInterface::setMode(): WE's idea of current mode seems to be " << modeToString( _iwr.u.mode ) << oendl; |
783 | 794 | ||
784 | // legacy compatible monitor mode check | 795 | // legacy compatible monitor mode check |
785 | 796 | ||
786 | if ( dataLinkType() == ARPHRD_IEEE80211 || dataLinkType() == 802 ) | 797 | if ( dataLinkType() == ARPHRD_IEEE80211 || dataLinkType() == 802 ) |
787 | { | 798 | { |
788 | return "monitor"; | 799 | return "monitor"; |
789 | } | 800 | } |
790 | else | 801 | else |
791 | { | 802 | { |
792 | return modeToString( _iwr.u.mode ); | 803 | return modeToString( _iwr.u.mode ); |
793 | } | 804 | } |
794 | } | 805 | } |
795 | 806 | ||
796 | void OWirelessNetworkInterface::setNickName( const QString& nickname ) | 807 | void OWirelessNetworkInterface::setNickName( const QString& nickname ) |
797 | { | 808 | { |
798 | _iwr.u.essid.pointer = const_cast<char*>( (const char*) nickname ); | 809 | _iwr.u.essid.pointer = const_cast<char*>( (const char*) nickname ); |
799 | _iwr.u.essid.length = nickname.length(); | 810 | _iwr.u.essid.length = nickname.length(); |
800 | wioctl( SIOCSIWNICKN ); | 811 | wioctl( SIOCSIWNICKN ); |
801 | } | 812 | } |
802 | 813 | ||
803 | 814 | ||
804 | QString OWirelessNetworkInterface::nickName() const | 815 | QString OWirelessNetworkInterface::nickName() const |
805 | { | 816 | { |
806 | char str[IW_ESSID_MAX_SIZE]; | 817 | char str[IW_ESSID_MAX_SIZE]; |
807 | _iwr.u.data.pointer = &str[0]; | 818 | _iwr.u.data.pointer = &str[0]; |
808 | _iwr.u.data.length = IW_ESSID_MAX_SIZE; | 819 | _iwr.u.data.length = IW_ESSID_MAX_SIZE; |
809 | if ( !wioctl( SIOCGIWNICKN ) ) | 820 | if ( !wioctl( SIOCGIWNICKN ) ) |
810 | { | 821 | { |
811 | return "<unknown>"; | 822 | return "<unknown>"; |
812 | } | 823 | } |
813 | else | 824 | else |
814 | { | 825 | { |
815 | str[_iwr.u.data.length] = '\0'; // some drivers don't zero-terminate the string | 826 | str[_iwr.u.data.length] = '\0'; // some drivers don't zero-terminate the string |
816 | return str; | 827 | return str; |
817 | } | 828 | } |
818 | } | 829 | } |
819 | 830 | ||
820 | 831 | ||
821 | void OWirelessNetworkInterface::setPrivate( const QString& call, int numargs, ... ) | 832 | void OWirelessNetworkInterface::setPrivate( const QString& call, int numargs, ... ) |
822 | { | 833 | { |
823 | OPrivateIOCTL* priv = static_cast<OPrivateIOCTL*>( child( (const char*) call ) ); | 834 | OPrivateIOCTL* priv = static_cast<OPrivateIOCTL*>( child( (const char*) call ) ); |
824 | if ( !priv ) | 835 | if ( !priv ) |
825 | { | 836 | { |
826 | owarn << "OWirelessNetworkInterface::setPrivate(): interface '" << name() | 837 | owarn << "OWirelessNetworkInterface::setPrivate(): interface '" << name() |
827 | << "' does not support private ioctl '" << call << "'" << oendl; | 838 | << "' does not support private ioctl '" << call << "'" << oendl; |
828 | return; | 839 | return; |
829 | } | 840 | } |
830 | if ( priv->numberSetArgs() != numargs ) | 841 | if ( priv->numberSetArgs() != numargs ) |
831 | { | 842 | { |
832 | owarn << "OWirelessNetworkInterface::setPrivate(): parameter count not matching. '" | 843 | owarn << "OWirelessNetworkInterface::setPrivate(): parameter count not matching. '" |
833 | << call << "' expects " << priv->numberSetArgs() << ", but got " << numargs << oendl; | 844 | << call << "' expects " << priv->numberSetArgs() << ", but got " << numargs << oendl; |
834 | return; | 845 | return; |
835 | } | 846 | } |
836 | 847 | ||
837 | odebug << "OWirelessNetworkInterface::setPrivate(): about to call '" << call << "' on interface '" << name() << "'" << oendl; | 848 | odebug << "OWirelessNetworkInterface::setPrivate(): about to call '" << call << "' on interface '" << name() << "'" << oendl; |
838 | memset( &_iwr, 0, sizeof _iwr ); | 849 | memset( &_iwr, 0, sizeof _iwr ); |
839 | va_list argp; | 850 | va_list argp; |
840 | va_start( argp, numargs ); | 851 | va_start( argp, numargs ); |
841 | for ( int i = 0; i < numargs; ++i ) | 852 | for ( int i = 0; i < numargs; ++i ) |
842 | { | 853 | { |
843 | priv->setParameter( i, va_arg( argp, int ) ); | 854 | priv->setParameter( i, va_arg( argp, int ) ); |
844 | } | 855 | } |
845 | va_end( argp ); | 856 | va_end( argp ); |
846 | priv->invoke(); | 857 | priv->invoke(); |
847 | } | 858 | } |
848 | 859 | ||
849 | 860 | ||
850 | void OWirelessNetworkInterface::getPrivate( const QString& ) | 861 | void OWirelessNetworkInterface::getPrivate( const QString& ) |
851 | { | 862 | { |
852 | oerr << "OWirelessNetworkInterface::getPrivate() is not implemented yet." << oendl; | 863 | oerr << "OWirelessNetworkInterface::getPrivate() is not implemented yet." << oendl; |
853 | } | 864 | } |
854 | 865 | ||
855 | 866 | ||
856 | bool OWirelessNetworkInterface::hasPrivate( const QString& call ) | 867 | bool OWirelessNetworkInterface::hasPrivate( const QString& call ) |
857 | { | 868 | { |
858 | return child( call.local8Bit() ); | 869 | return child( call.local8Bit() ); |
859 | } | 870 | } |
860 | 871 | ||
861 | 872 | ||
862 | QString OWirelessNetworkInterface::SSID() const | 873 | QString OWirelessNetworkInterface::SSID() const |
863 | { | 874 | { |
864 | char str[IW_ESSID_MAX_SIZE]; | 875 | char str[IW_ESSID_MAX_SIZE]; |
865 | _iwr.u.essid.pointer = &str[0]; | 876 | _iwr.u.essid.pointer = &str[0]; |
866 | _iwr.u.essid.length = IW_ESSID_MAX_SIZE; | 877 | _iwr.u.essid.length = IW_ESSID_MAX_SIZE; |
867 | if ( !wioctl( SIOCGIWESSID ) ) | 878 | if ( !wioctl( SIOCGIWESSID ) ) |
868 | { | 879 | { |
869 | return "<unknown>"; | 880 | return "<unknown>"; |
870 | } | 881 | } |
871 | else | 882 | else |
872 | { | 883 | { |
873 | str[_iwr.u.essid.length] = '\0'; // some drivers don't zero-terminate the string | 884 | str[_iwr.u.essid.length] = '\0'; // some drivers don't zero-terminate the string |
874 | return str; | 885 | return str; |
875 | } | 886 | } |
876 | } | 887 | } |
877 | 888 | ||
878 | 889 | ||
879 | void OWirelessNetworkInterface::setSSID( const QString& ssid ) | 890 | void OWirelessNetworkInterface::setSSID( const QString& ssid ) |
880 | { | 891 | { |
881 | _iwr.u.essid.pointer = const_cast<char*>( (const char*) ssid ); | 892 | _iwr.u.essid.pointer = const_cast<char*>( (const char*) ssid ); |
882 | _iwr.u.essid.length = ssid.length()+1; // zero byte | 893 | _iwr.u.essid.length = ssid.length()+1; // zero byte |
883 | wioctl( SIOCSIWESSID ); | 894 | wioctl( SIOCSIWESSID ); |
884 | } | 895 | } |
885 | 896 | ||
886 | 897 | ||
887 | OStationList* OWirelessNetworkInterface::scanNetwork() | 898 | OStationList* OWirelessNetworkInterface::scanNetwork() |
888 | { | 899 | { |
889 | _iwr.u.param.flags = IW_SCAN_DEFAULT; | 900 | _iwr.u.param.flags = IW_SCAN_DEFAULT; |
890 | _iwr.u.param.value = 0; | 901 | _iwr.u.param.value = 0; |
891 | if ( !wioctl( SIOCSIWSCAN ) ) | 902 | if ( !wioctl( SIOCSIWSCAN ) ) |
892 | { | 903 | { |
893 | return 0; | 904 | return 0; |
894 | } | 905 | } |
895 | 906 | ||
896 | OStationList* stations = new OStationList(); | 907 | OStationList* stations = new OStationList(); |
897 | 908 | ||
898 | int timeout = 10000000; | 909 | int timeout = 10000000; |
899 | 910 | ||
900 | odebug << "ONetworkInterface::scanNetwork() - scan started." << oendl; | 911 | odebug << "ONetworkInterface::scanNetwork() - scan started." << oendl; |
901 | 912 | ||
902 | bool results = false; | 913 | bool results = false; |
903 | struct timeval tv; | 914 | struct timeval tv; |
904 | tv.tv_sec = 0; | 915 | tv.tv_sec = 0; |
905 | tv.tv_usec = 250000; // initial timeout ~ 250ms | 916 | tv.tv_usec = 250000; // initial timeout ~ 250ms |
906 | char buffer[IW_SCAN_MAX_DATA]; | 917 | char buffer[IW_SCAN_MAX_DATA]; |
907 | 918 | ||
908 | while ( !results && timeout > 0 ) | 919 | while ( !results && timeout > 0 ) |
909 | { | 920 | { |
910 | timeout -= tv.tv_usec; | 921 | timeout -= tv.tv_usec; |
911 | select( 0, 0, 0, 0, &tv ); | 922 | select( 0, 0, 0, 0, &tv ); |
912 | 923 | ||
913 | _iwr.u.data.pointer = &buffer[0]; | 924 | _iwr.u.data.pointer = &buffer[0]; |
914 | _iwr.u.data.flags = 0; | 925 | _iwr.u.data.flags = 0; |
915 | _iwr.u.data.length = sizeof buffer; | 926 | _iwr.u.data.length = sizeof buffer; |
916 | if ( wioctl( SIOCGIWSCAN ) ) | 927 | if ( wioctl( SIOCGIWSCAN ) ) |
917 | { | 928 | { |
918 | results = true; | 929 | results = true; |
919 | continue; | 930 | continue; |
920 | } | 931 | } |
921 | else if ( errno == EAGAIN) | 932 | else if ( errno == EAGAIN) |
922 | { | 933 | { |
923 | odebug << "ONetworkInterface::scanNetwork() - scan in progress..." << oendl; | 934 | odebug << "ONetworkInterface::scanNetwork() - scan in progress..." << oendl; |
924 | if ( qApp ) | 935 | if ( qApp ) |
925 | { | 936 | { |
926 | qApp->processEvents( 100 ); | 937 | qApp->processEvents( 100 ); |
927 | continue; | 938 | continue; |
928 | } | 939 | } |
929 | tv.tv_sec = 0; | 940 | tv.tv_sec = 0; |
930 | tv.tv_usec = 100000; | 941 | tv.tv_usec = 100000; |
931 | continue; | 942 | continue; |
932 | } | 943 | } |
933 | } | 944 | } |
934 | 945 | ||
935 | odebug << "ONetworkInterface::scanNetwork() - scan finished." << oendl; | 946 | odebug << "ONetworkInterface::scanNetwork() - scan finished." << oendl; |
936 | 947 | ||
937 | if ( results ) | 948 | if ( results ) |
938 | { | 949 | { |
939 | odebug << " - result length = " << _iwr.u.data.length << oendl; | 950 | odebug << " - result length = " << _iwr.u.data.length << oendl; |
940 | if ( !_iwr.u.data.length ) | 951 | if ( !_iwr.u.data.length ) |
941 | { | 952 | { |
942 | odebug << " - no results (empty neighbourhood)" << oendl; | 953 | odebug << " - no results (empty neighbourhood)" << oendl; |
943 | return stations; | 954 | return stations; |
944 | } | 955 | } |
945 | 956 | ||
946 | odebug << " - results are in!" << oendl; | 957 | odebug << " - results are in!" << oendl; |
947 | dumpBytes( (const unsigned char*) &buffer[0], _iwr.u.data.length ); | 958 | dumpBytes( (const unsigned char*) &buffer[0], _iwr.u.data.length ); |
948 | 959 | ||
949 | // parse results | 960 | // parse results |
950 | struct iw_event iwe; | 961 | struct iw_event iwe; |
951 | struct iw_stream_descr stream; | 962 | struct iw_stream_descr stream; |
952 | unsigned int cmd_index, event_type, event_len; | 963 | unsigned int cmd_index, event_type, event_len; |
953 | char *pointer; | 964 | char *pointer; |
954 | 965 | ||
955 | const char standard_ioctl_hdr[] = { | 966 | const char standard_ioctl_hdr[] = { |
956 | IW_HEADER_TYPE_NULL, /* SIOCSIWCOMMIT */ | 967 | IW_HEADER_TYPE_NULL, /* SIOCSIWCOMMIT */ |
957 | IW_HEADER_TYPE_CHAR, /* SIOCGIWNAME */ | 968 | IW_HEADER_TYPE_CHAR, /* SIOCGIWNAME */ |
958 | IW_HEADER_TYPE_PARAM, /* SIOCSIWNWID */ | 969 | IW_HEADER_TYPE_PARAM, /* SIOCSIWNWID */ |
959 | IW_HEADER_TYPE_PARAM, /* SIOCGIWNWID */ | 970 | IW_HEADER_TYPE_PARAM, /* SIOCGIWNWID */ |
960 | IW_HEADER_TYPE_FREQ, /* SIOCSIWFREQ */ | 971 | IW_HEADER_TYPE_FREQ, /* SIOCSIWFREQ */ |
961 | IW_HEADER_TYPE_FREQ, /* SIOCGIWFREQ */ | 972 | IW_HEADER_TYPE_FREQ, /* SIOCGIWFREQ */ |
962 | IW_HEADER_TYPE_UINT, /* SIOCSIWMODE */ | 973 | IW_HEADER_TYPE_UINT, /* SIOCSIWMODE */ |
963 | IW_HEADER_TYPE_UINT, /* SIOCGIWMODE */ | 974 | IW_HEADER_TYPE_UINT, /* SIOCGIWMODE */ |
964 | IW_HEADER_TYPE_PARAM, /* SIOCSIWSENS */ | 975 | IW_HEADER_TYPE_PARAM, /* SIOCSIWSENS */ |
965 | IW_HEADER_TYPE_PARAM, /* SIOCGIWSENS */ | 976 | IW_HEADER_TYPE_PARAM, /* SIOCGIWSENS */ |
966 | IW_HEADER_TYPE_NULL, /* SIOCSIWRANGE */ | 977 | IW_HEADER_TYPE_NULL, /* SIOCSIWRANGE */ |
967 | IW_HEADER_TYPE_POINT, /* SIOCGIWRANGE */ | 978 | IW_HEADER_TYPE_POINT, /* SIOCGIWRANGE */ |
968 | IW_HEADER_TYPE_NULL, /* SIOCSIWPRIV */ | 979 | IW_HEADER_TYPE_NULL, /* SIOCSIWPRIV */ |
969 | IW_HEADER_TYPE_POINT, /* SIOCGIWPRIV */ | 980 | IW_HEADER_TYPE_POINT, /* SIOCGIWPRIV */ |
970 | IW_HEADER_TYPE_NULL, /* SIOCSIWSTATS */ | 981 | IW_HEADER_TYPE_NULL, /* SIOCSIWSTATS */ |
971 | IW_HEADER_TYPE_POINT, /* SIOCGIWSTATS */ | 982 | IW_HEADER_TYPE_POINT, /* SIOCGIWSTATS */ |
972 | IW_HEADER_TYPE_POINT, /* SIOCSIWSPY */ | 983 | IW_HEADER_TYPE_POINT, /* SIOCSIWSPY */ |
973 | IW_HEADER_TYPE_POINT, /* SIOCGIWSPY */ | 984 | IW_HEADER_TYPE_POINT, /* SIOCGIWSPY */ |
974 | IW_HEADER_TYPE_POINT, /* SIOCSIWTHRSPY */ | 985 | IW_HEADER_TYPE_POINT, /* SIOCSIWTHRSPY */ |
975 | IW_HEADER_TYPE_POINT, /* SIOCGIWTHRSPY */ | 986 | IW_HEADER_TYPE_POINT, /* SIOCGIWTHRSPY */ |
976 | IW_HEADER_TYPE_ADDR, /* SIOCSIWAP */ | 987 | IW_HEADER_TYPE_ADDR, /* SIOCSIWAP */ |
977 | IW_HEADER_TYPE_ADDR, /* SIOCGIWAP */ | 988 | IW_HEADER_TYPE_ADDR, /* SIOCGIWAP */ |
978 | IW_HEADER_TYPE_NULL, /* -- hole -- */ | 989 | IW_HEADER_TYPE_NULL, /* -- hole -- */ |
979 | IW_HEADER_TYPE_POINT, /* SIOCGIWAPLIST */ | 990 | IW_HEADER_TYPE_POINT, /* SIOCGIWAPLIST */ |
980 | IW_HEADER_TYPE_PARAM, /* SIOCSIWSCAN */ | 991 | IW_HEADER_TYPE_PARAM, /* SIOCSIWSCAN */ |
981 | IW_HEADER_TYPE_POINT, /* SIOCGIWSCAN */ | 992 | IW_HEADER_TYPE_POINT, /* SIOCGIWSCAN */ |
982 | IW_HEADER_TYPE_POINT, /* SIOCSIWESSID */ | 993 | IW_HEADER_TYPE_POINT, /* SIOCSIWESSID */ |
983 | IW_HEADER_TYPE_POINT, /* SIOCGIWESSID */ | 994 | IW_HEADER_TYPE_POINT, /* SIOCGIWESSID */ |
984 | IW_HEADER_TYPE_POINT, /* SIOCSIWNICKN */ | 995 | IW_HEADER_TYPE_POINT, /* SIOCSIWNICKN */ |
985 | IW_HEADER_TYPE_POINT, /* SIOCGIWNICKN */ | 996 | IW_HEADER_TYPE_POINT, /* SIOCGIWNICKN */ |
986 | IW_HEADER_TYPE_NULL, /* -- hole -- */ | 997 | IW_HEADER_TYPE_NULL, /* -- hole -- */ |
987 | IW_HEADER_TYPE_NULL, /* -- hole -- */ | 998 | IW_HEADER_TYPE_NULL, /* -- hole -- */ |
988 | IW_HEADER_TYPE_PARAM, /* SIOCSIWRATE */ | 999 | IW_HEADER_TYPE_PARAM, /* SIOCSIWRATE */ |
989 | IW_HEADER_TYPE_PARAM, /* SIOCGIWRATE */ | 1000 | IW_HEADER_TYPE_PARAM, /* SIOCGIWRATE */ |
990 | IW_HEADER_TYPE_PARAM, /* SIOCSIWRTS */ | 1001 | IW_HEADER_TYPE_PARAM, /* SIOCSIWRTS */ |
991 | IW_HEADER_TYPE_PARAM, /* SIOCGIWRTS */ | 1002 | IW_HEADER_TYPE_PARAM, /* SIOCGIWRTS */ |
992 | IW_HEADER_TYPE_PARAM, /* SIOCSIWFRAG */ | 1003 | IW_HEADER_TYPE_PARAM, /* SIOCSIWFRAG */ |
993 | IW_HEADER_TYPE_PARAM, /* SIOCGIWFRAG */ | 1004 | IW_HEADER_TYPE_PARAM, /* SIOCGIWFRAG */ |
994 | IW_HEADER_TYPE_PARAM, /* SIOCSIWTXPOW */ | 1005 | IW_HEADER_TYPE_PARAM, /* SIOCSIWTXPOW */ |
995 | IW_HEADER_TYPE_PARAM, /* SIOCGIWTXPOW */ | 1006 | IW_HEADER_TYPE_PARAM, /* SIOCGIWTXPOW */ |
996 | IW_HEADER_TYPE_PARAM, /* SIOCSIWRETRY */ | 1007 | IW_HEADER_TYPE_PARAM, /* SIOCSIWRETRY */ |
997 | IW_HEADER_TYPE_PARAM, /* SIOCGIWRETRY */ | 1008 | IW_HEADER_TYPE_PARAM, /* SIOCGIWRETRY */ |
998 | IW_HEADER_TYPE_POINT, /* SIOCSIWENCODE */ | 1009 | IW_HEADER_TYPE_POINT, /* SIOCSIWENCODE */ |
999 | IW_HEADER_TYPE_POINT, /* SIOCGIWENCODE */ | 1010 | IW_HEADER_TYPE_POINT, /* SIOCGIWENCODE */ |
1000 | IW_HEADER_TYPE_PARAM, /* SIOCSIWPOWER */ | 1011 | IW_HEADER_TYPE_PARAM, /* SIOCSIWPOWER */ |
1001 | IW_HEADER_TYPE_PARAM, /* SIOCGIWPOWER */ | 1012 | IW_HEADER_TYPE_PARAM, /* SIOCGIWPOWER */ |
1002 | }; | 1013 | }; |
1003 | 1014 | ||
1004 | const char standard_event_hdr[] = { | 1015 | const char standard_event_hdr[] = { |
1005 | IW_HEADER_TYPE_ADDR, /* IWEVTXDROP */ | 1016 | IW_HEADER_TYPE_ADDR, /* IWEVTXDROP */ |
1006 | IW_HEADER_TYPE_QUAL, /* IWEVQUAL */ | 1017 | IW_HEADER_TYPE_QUAL, /* IWEVQUAL */ |
1007 | IW_HEADER_TYPE_POINT, /* IWEVCUSTOM */ | 1018 | IW_HEADER_TYPE_POINT, /* IWEVCUSTOM */ |
1008 | IW_HEADER_TYPE_ADDR, /* IWEVREGISTERED */ | 1019 | IW_HEADER_TYPE_ADDR, /* IWEVREGISTERED */ |
1009 | IW_HEADER_TYPE_ADDR, /* IWEVEXPIRED */ | 1020 | IW_HEADER_TYPE_ADDR, /* IWEVEXPIRED */ |
1010 | IW_HEADER_TYPE_POINT, /* IWEVGENIE */ | 1021 | IW_HEADER_TYPE_POINT, /* IWEVGENIE */ |
1011 | IW_HEADER_TYPE_POINT, /* IWEVMICHAELMICFAILURE */ | 1022 | IW_HEADER_TYPE_POINT, /* IWEVMICHAELMICFAILURE */ |
1012 | IW_HEADER_TYPE_POINT, /* IWEVASSOCREQIE */ | 1023 | IW_HEADER_TYPE_POINT, /* IWEVASSOCREQIE */ |
1013 | IW_HEADER_TYPE_POINT, /* IWEVASSOCRESPIE */ | 1024 | IW_HEADER_TYPE_POINT, /* IWEVASSOCRESPIE */ |
1014 | IW_HEADER_TYPE_POINT, /* IWEVPMKIDCAND */ | 1025 | IW_HEADER_TYPE_POINT, /* IWEVPMKIDCAND */ |
1015 | }; | 1026 | }; |
1016 | 1027 | ||
1017 | 1028 | ||
1018 | const int event_type_size[] = { | 1029 | const int event_type_size[] = { |
1019 | IW_EV_LCP_LEN, /* IW_HEADER_TYPE_NULL */ | 1030 | IW_EV_LCP_LEN, /* IW_HEADER_TYPE_NULL */ |
1020 | 0, | 1031 | 0, |
1021 | IW_EV_CHAR_LEN, /* IW_HEADER_TYPE_CHAR */ | 1032 | IW_EV_CHAR_LEN, /* IW_HEADER_TYPE_CHAR */ |
1022 | 0, | 1033 | 0, |
1023 | IW_EV_UINT_LEN, /* IW_HEADER_TYPE_UINT */ | 1034 | IW_EV_UINT_LEN, /* IW_HEADER_TYPE_UINT */ |
1024 | IW_EV_FREQ_LEN, /* IW_HEADER_TYPE_FREQ */ | 1035 | IW_EV_FREQ_LEN, /* IW_HEADER_TYPE_FREQ */ |
1025 | IW_EV_ADDR_LEN, /* IW_HEADER_TYPE_ADDR */ | 1036 | IW_EV_ADDR_LEN, /* IW_HEADER_TYPE_ADDR */ |
1026 | 0, | 1037 | 0, |
1027 | IW_EV_POINT_LEN, /* Without variable payload */ | 1038 | IW_EV_POINT_LEN, /* Without variable payload */ |
1028 | IW_EV_PARAM_LEN, /* IW_HEADER_TYPE_PARAM */ | 1039 | IW_EV_PARAM_LEN, /* IW_HEADER_TYPE_PARAM */ |
1029 | IW_EV_QUAL_LEN, /* IW_HEADER_TYPE_QUAL */ | 1040 | IW_EV_QUAL_LEN, /* IW_HEADER_TYPE_QUAL */ |
1030 | }; | 1041 | }; |
1031 | 1042 | ||
1032 | 1043 | ||
1033 | //Initialize the stream | 1044 | //Initialize the stream |
1034 | memset( &stream, 0, sizeof(struct iw_stream_descr) ); | 1045 | memset( &stream, 0, sizeof(struct iw_stream_descr) ); |
1035 | stream.current = buffer; | 1046 | stream.current = buffer; |
1036 | stream.end = buffer + _iwr.u.data.length; | 1047 | stream.end = buffer + _iwr.u.data.length; |
1037 | 1048 | ||
1038 | do | 1049 | do |
1039 | { | 1050 | { |
1040 | if ((stream.current + IW_EV_LCP_LEN) > stream.end) | 1051 | if ((stream.current + IW_EV_LCP_LEN) > stream.end) |
1041 | break; | 1052 | break; |
1042 | memcpy((char *) &iwe, stream.current, IW_EV_LCP_LEN); | 1053 | memcpy((char *) &iwe, stream.current, IW_EV_LCP_LEN); |
1043 | 1054 | ||
1044 | if (iwe.len <= IW_EV_LCP_LEN) //If yes, it is an invalid event | 1055 | if (iwe.len <= IW_EV_LCP_LEN) //If yes, it is an invalid event |
1045 | break; | 1056 | break; |
1046 | if (iwe.cmd <= SIOCIWLAST) { | 1057 | if (iwe.cmd <= SIOCIWLAST) { |
1047 | cmd_index = iwe.cmd - SIOCIWFIRST; | 1058 | cmd_index = iwe.cmd - SIOCIWFIRST; |
1048 | 1059 | ||
1049 | if(cmd_index < sizeof(standard_ioctl_hdr)) | 1060 | if(cmd_index < sizeof(standard_ioctl_hdr)) |
1050 | event_type = standard_ioctl_hdr[cmd_index]; | 1061 | event_type = standard_ioctl_hdr[cmd_index]; |
1051 | } | 1062 | } |
1052 | else { | 1063 | else { |
1053 | cmd_index = iwe.cmd - IWEVFIRST; | 1064 | cmd_index = iwe.cmd - IWEVFIRST; |
1054 | 1065 | ||
1055 | if(cmd_index < sizeof(standard_event_hdr)) | 1066 | if(cmd_index < sizeof(standard_event_hdr)) |
1056 | event_type = standard_event_hdr[cmd_index]; | 1067 | event_type = standard_event_hdr[cmd_index]; |
1057 | } | 1068 | } |
1058 | 1069 | ||
1059 | /* Unknown events -> event_type=0 => IW_EV_LCP_LEN */ | 1070 | /* Unknown events -> event_type=0 => IW_EV_LCP_LEN */ |
1060 | event_len = event_type_size[event_type]; | 1071 | event_len = event_type_size[event_type]; |
1061 | 1072 | ||
1062 | /* Fixup for later version of WE */ | 1073 | /* Fixup for later version of WE */ |
1063 | if((_range.we_version_compiled > 18) && (event_type == IW_HEADER_TYPE_POINT)) | 1074 | if((_range.we_version_compiled > 18) && (event_type == IW_HEADER_TYPE_POINT)) |
1064 | event_len -= IW_EV_POINT_OFF; | 1075 | event_len -= IW_EV_POINT_OFF; |
1065 | 1076 | ||
1066 | /* Check if we know about this event */ | 1077 | /* Check if we know about this event */ |
1067 | if(event_len <= IW_EV_LCP_LEN) { | 1078 | if(event_len <= IW_EV_LCP_LEN) { |
1068 | /* Skip to next event */ | 1079 | /* Skip to next event */ |
1069 | stream.current += iwe.len; | 1080 | stream.current += iwe.len; |
1070 | continue; | 1081 | continue; |
1071 | } | 1082 | } |
1072 | 1083 | ||
1073 | event_len -= IW_EV_LCP_LEN; | 1084 | event_len -= IW_EV_LCP_LEN; |
1074 | 1085 | ||
1075 | /* Set pointer on data */ | 1086 | /* Set pointer on data */ |
1076 | if(stream.value != NULL) | 1087 | if(stream.value != NULL) |
1077 | pointer = stream.value; /* Next value in event */ | 1088 | pointer = stream.value; /* Next value in event */ |
1078 | else | 1089 | else |
1079 | pointer = stream.current + IW_EV_LCP_LEN; /* First value in event */ | 1090 | pointer = stream.current + IW_EV_LCP_LEN; /* First value in event */ |
1080 | 1091 | ||
1081 | if((pointer + event_len) > stream.end) { | 1092 | if((pointer + event_len) > stream.end) { |
1082 | /* Go to next event */ | 1093 | /* Go to next event */ |
1083 | stream.current += iwe.len; | 1094 | stream.current += iwe.len; |
1084 | break; | 1095 | break; |
1085 | } | 1096 | } |
1086 | 1097 | ||
1087 | /* Fixup for later version of WE */ | 1098 | /* Fixup for later version of WE */ |
1088 | if((_range.we_version_compiled > 18) && (event_type == IW_HEADER_TYPE_POINT)) | 1099 | if((_range.we_version_compiled > 18) && (event_type == IW_HEADER_TYPE_POINT)) |
1089 | memcpy((char *) &iwe + IW_EV_LCP_LEN + IW_EV_POINT_OFF, pointer, event_len); | 1100 | memcpy((char *) &iwe + IW_EV_LCP_LEN + IW_EV_POINT_OFF, pointer, event_len); |
1090 | else | 1101 | else |
1091 | memcpy((char *) &iwe + IW_EV_LCP_LEN, pointer, event_len); | 1102 | memcpy((char *) &iwe + IW_EV_LCP_LEN, pointer, event_len); |
1092 | 1103 | ||
1093 | /* Skip event in the stream */ | 1104 | /* Skip event in the stream */ |
1094 | pointer += event_len; | 1105 | pointer += event_len; |
1095 | 1106 | ||
1096 | /* Special processing for iw_point events */ | 1107 | /* Special processing for iw_point events */ |
1097 | if(event_type == IW_HEADER_TYPE_POINT) { | 1108 | if(event_type == IW_HEADER_TYPE_POINT) { |
1098 | /* Check the length of the payload */ | 1109 | /* Check the length of the payload */ |
1099 | 1110 | ||
1100 | if((iwe.len - (event_len + IW_EV_LCP_LEN)) > 0) | 1111 | if((iwe.len - (event_len + IW_EV_LCP_LEN)) > 0) |
1101 | /* Set pointer on variable part (warning : non aligned) */ | 1112 | /* Set pointer on variable part (warning : non aligned) */ |
1102 | iwe.u.data.pointer = pointer; | 1113 | iwe.u.data.pointer = pointer; |
1103 | else | 1114 | else |
1104 | /* No data */ | 1115 | /* No data */ |
1105 | iwe.u.data.pointer = NULL; | 1116 | iwe.u.data.pointer = NULL; |
1106 | /* Go to next event */ | 1117 | /* Go to next event */ |
1107 | stream.current += iwe.len; | 1118 | stream.current += iwe.len; |
1108 | } | 1119 | } |
1109 | 1120 | ||
1110 | else { | 1121 | else { |
1111 | /* Is there more value in the event ? */ | 1122 | /* Is there more value in the event ? */ |
1112 | if((pointer + event_len) <= (stream.current + iwe.len)) | 1123 | if((pointer + event_len) <= (stream.current + iwe.len)) |
1113 | /* Go to next value */ | 1124 | /* Go to next value */ |
1114 | stream.value = pointer; | 1125 | stream.value = pointer; |
1115 | else { | 1126 | else { |
1116 | /* Go to next event */ | 1127 | /* Go to next event */ |
1117 | stream.value = NULL; | 1128 | stream.value = NULL; |
1118 | stream.current += iwe.len; | 1129 | stream.current += iwe.len; |
1119 | } | 1130 | } |
1120 | } | 1131 | } |
1121 | 1132 | ||
1122 | struct iw_event *we = &iwe; | 1133 | struct iw_event *we = &iwe; |
1123 | //------ | 1134 | //------ |
1124 | odebug << " - reading next event... cmd=" << we->cmd << ", len=" << we->len << oendl; | 1135 | odebug << " - reading next event... cmd=" << we->cmd << ", len=" << we->len << oendl; |
1125 | switch (we->cmd) | 1136 | switch (we->cmd) |
1126 | { | 1137 | { |
1127 | case SIOCGIWAP: | 1138 | case SIOCGIWAP: |
1128 | { | 1139 | { |
1129 | odebug << "SIOCGIWAP" << oendl; | 1140 | odebug << "SIOCGIWAP" << oendl; |
1130 | stations->append( new OStation() ); | 1141 | stations->append( new OStation() ); |
1131 | stations->last()->macAddress = (const unsigned char*) &we->u.ap_addr.sa_data[0]; | 1142 | stations->last()->macAddress = (const unsigned char*) &we->u.ap_addr.sa_data[0]; |
1132 | break; | 1143 | break; |
1133 | } | 1144 | } |
1134 | case SIOCGIWMODE: | 1145 | case SIOCGIWMODE: |
1135 | { | 1146 | { |
1136 | odebug << "SIOCGIWMODE" << oendl; | 1147 | odebug << "SIOCGIWMODE" << oendl; |
1137 | stations->last()->type = modeToString( we->u.mode ); | 1148 | stations->last()->type = modeToString( we->u.mode ); |
1138 | break; | 1149 | break; |
1139 | } | 1150 | } |
1140 | case SIOCGIWFREQ: | 1151 | case SIOCGIWFREQ: |
1141 | { | 1152 | { |
1142 | odebug << "SIOCGIWFREQ" << oendl; | 1153 | odebug << "SIOCGIWFREQ" << oendl; |
1143 | if ( we->u.freq.m > 1000 ) | 1154 | if ( we->u.freq.m > 1000 ) |
1144 | stations->last()->channel = _channels[ static_cast<int>(double( we->u.freq.m ) * pow( 10.0, we->u.freq.e ) / 1000000) ]; | 1155 | stations->last()->channel = _channels[ static_cast<int>(double( we->u.freq.m ) * pow( 10.0, we->u.freq.e ) / 1000000) ]; |
1145 | else | 1156 | else |
1146 | stations->last()->channel = static_cast<int>(((double) we->u.freq.m) * pow( 10.0, we->u.freq.e )); | 1157 | stations->last()->channel = static_cast<int>(((double) we->u.freq.m) * pow( 10.0, we->u.freq.e )); |
1147 | break; | 1158 | break; |
1148 | } | 1159 | } |
1149 | case SIOCGIWESSID: | 1160 | case SIOCGIWESSID: |
1150 | { | 1161 | { |
1151 | odebug << "SIOCGIWESSID" << oendl; | 1162 | odebug << "SIOCGIWESSID" << oendl; |
1152 | we->u.essid.length = '\0'; // make sure it is zero terminated | 1163 | we->u.essid.length = '\0'; // make sure it is zero terminated |
1153 | stations->last()->ssid = static_cast<const char*> (we->u.essid.pointer); | 1164 | stations->last()->ssid = static_cast<const char*> (we->u.essid.pointer); |
1154 | odebug << "ESSID: " << stations->last()->ssid << oendl; | 1165 | odebug << "ESSID: " << stations->last()->ssid << oendl; |
1155 | break; | 1166 | break; |
1156 | } | 1167 | } |
1157 | case IWEVQUAL: | 1168 | case IWEVQUAL: |
1158 | { | 1169 | { |
1159 | odebug << "IWEVQUAL" << oendl; | 1170 | odebug << "IWEVQUAL" << oendl; |
1160 | stations->last()->level = static_cast<int>(we->u.qual.level); | 1171 | stations->last()->level = static_cast<int>(we->u.qual.level); |
1161 | break; /* Quality part of statistics (scan) */ | 1172 | break; /* Quality part of statistics (scan) */ |
1162 | } | 1173 | } |
1163 | case SIOCGIWENCODE: | 1174 | case SIOCGIWENCODE: |
1164 | { | 1175 | { |
1165 | odebug << "SIOCGIWENCODE" << oendl; | 1176 | odebug << "SIOCGIWENCODE" << oendl; |
1166 | stations->last()->encrypted = !(we->u.data.flags & IW_ENCODE_DISABLED); | 1177 | stations->last()->encrypted = !(we->u.data.flags & IW_ENCODE_DISABLED); |
1167 | break; | 1178 | break; |
1168 | } | 1179 | } |
1169 | 1180 | ||
1170 | case SIOCGIWRATE: | 1181 | case SIOCGIWRATE: |
1171 | { | 1182 | { |
1172 | odebug << "SIOCGIWRATE" << oendl; | 1183 | odebug << "SIOCGIWRATE" << oendl; |
1173 | stations->last()->rates.append(we->u.bitrate.value); | 1184 | stations->last()->rates.append(we->u.bitrate.value); |
1174 | break; | 1185 | break; |
1175 | } | 1186 | } |
1176 | case SIOCGIWSENS: odebug << "SIOCGIWSENS" << oendl; break; | 1187 | case SIOCGIWSENS: odebug << "SIOCGIWSENS" << oendl; break; |
1177 | case IWEVTXDROP: odebug << "IWEVTXDROP" << oendl; break; /* Packet dropped to excessive retry */ | 1188 | case IWEVTXDROP: odebug << "IWEVTXDROP" << oendl; break; /* Packet dropped to excessive retry */ |
1178 | case IWEVCUSTOM: odebug << "IWEVCUSTOM" << oendl; break; /* Driver specific ascii string */ | 1189 | case IWEVCUSTOM: odebug << "IWEVCUSTOM" << oendl; break; /* Driver specific ascii string */ |
1179 | case IWEVREGISTERED: odebug << "IWEVREGISTERED" << oendl; break; /* Discovered a new node (AP mode) */ | 1190 | case IWEVREGISTERED: odebug << "IWEVREGISTERED" << oendl; break; /* Discovered a new node (AP mode) */ |
1180 | case IWEVEXPIRED: odebug << "IWEVEXPIRED" << oendl; break; /* Expired a node (AP mode) */ | 1191 | case IWEVEXPIRED: odebug << "IWEVEXPIRED" << oendl; break; /* Expired a node (AP mode) */ |
1181 | default: odebug << "unhandled event" << oendl; | 1192 | default: odebug << "unhandled event" << oendl; |
1182 | } | 1193 | } |
1183 | 1194 | ||
1184 | } while (true); | 1195 | } while (true); |
1185 | } | 1196 | } |
1186 | else | 1197 | else |
1187 | { | 1198 | { |
1188 | odebug << " - no results (timeout) :(" << oendl; | 1199 | odebug << " - no results (timeout) :(" << oendl; |
1189 | } | 1200 | } |
1190 | return stations; | 1201 | return stations; |
1191 | } | 1202 | } |
1192 | 1203 | ||
1193 | 1204 | ||
1194 | int OWirelessNetworkInterface::signalStrength() const | 1205 | int OWirelessNetworkInterface::signalStrength() const |
1195 | { | 1206 | { |
1196 | iw_statistics stat; | 1207 | iw_statistics stat; |
1197 | ::memset( &stat, 0, sizeof stat ); | 1208 | ::memset( &stat, 0, sizeof stat ); |
1198 | _iwr.u.data.pointer = (char*) &stat; | 1209 | _iwr.u.data.pointer = (char*) &stat; |
1199 | _iwr.u.data.flags = 0; | 1210 | _iwr.u.data.flags = 0; |
1200 | _iwr.u.data.length = sizeof stat; | 1211 | _iwr.u.data.length = sizeof stat; |
1201 | 1212 | ||
1202 | if ( !wioctl( SIOCGIWSTATS ) ) | 1213 | if ( !wioctl( SIOCGIWSTATS ) ) |
1203 | { | 1214 | { |
1204 | return -1; | 1215 | return -1; |
1205 | } | 1216 | } |
1206 | 1217 | ||
1207 | int max = _range.max_qual.qual; | 1218 | int max = _range.max_qual.qual; |
1208 | int cur = stat.qual.qual; | 1219 | int cur = stat.qual.qual; |
1209 | // int lev = stat.qual.level; //FIXME: Do something with them? | 1220 | // int lev = stat.qual.level; //FIXME: Do something with them? |
1210 | // int noi = stat.qual.noise; //FIXME: Do something with them? | 1221 | // int noi = stat.qual.noise; //FIXME: Do something with them? |
1211 | 1222 | ||
1212 | 1223 | ||
1213 | return max != 0 ? cur*100/max: -1; | 1224 | return max != 0 ? cur*100/max: -1; |
1214 | } | 1225 | } |
1215 | 1226 | ||
1216 | 1227 | ||
1217 | bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const | 1228 | bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const |
1218 | { | 1229 | { |
1219 | #ifndef NODEBUG | 1230 | #ifndef NODEBUG |
1220 | int result = ::ioctl( _sfd, call, &iwreq ); | 1231 | int result = ::ioctl( _sfd, call, &iwreq ); |
1221 | 1232 | ||
1222 | if ( result == -1 ) | 1233 | if ( result == -1 ) |
1223 | odebug << "ONetworkInterface::wioctl (" << name() << ") call '" | 1234 | odebug << "ONetworkInterface::wioctl (" << name() << ") call '" |
1224 | << debugmapper->map( call ) << "' FAILED! " << result << " (" << strerror( errno ) << ")" << oendl; | 1235 | << debugmapper->map( call ) << "' FAILED! " << result << " (" << strerror( errno ) << ")" << oendl; |
1225 | else | 1236 | else |
1226 | odebug << "ONetworkInterface::wioctl (" << name() << ") call '" | 1237 | odebug << "ONetworkInterface::wioctl (" << name() << ") call '" |
1227 | << debugmapper->map( call ) << "' - Status: Ok." << oendl; | 1238 | << debugmapper->map( call ) << "' - Status: Ok." << oendl; |
1228 | 1239 | ||
1229 | return ( result != -1 ); | 1240 | return ( result != -1 ); |
1230 | #else | 1241 | #else |
1231 | return ::ioctl( _sfd, call, &iwreq ) != -1; | 1242 | return ::ioctl( _sfd, call, &iwreq ) != -1; |
1232 | #endif | 1243 | #endif |
1233 | } | 1244 | } |
1234 | 1245 | ||
1235 | 1246 | ||
1236 | bool OWirelessNetworkInterface::wioctl( int call ) const | 1247 | bool OWirelessNetworkInterface::wioctl( int call ) const |
1237 | { | 1248 | { |
1238 | strcpy( _iwr.ifr_name, name() ); | 1249 | strcpy( _iwr.ifr_name, name() ); |
1239 | return wioctl( call, _iwr ); | 1250 | return wioctl( call, _iwr ); |
1240 | } | 1251 | } |
1241 | 1252 | ||
1242 | 1253 | ||
1243 | /*====================================================================================== | 1254 | /*====================================================================================== |
1244 | * OMonitoringInterface | 1255 | * OMonitoringInterface |
1245 | *======================================================================================*/ | 1256 | *======================================================================================*/ |
1246 | 1257 | ||
1247 | OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) | 1258 | OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) |
1248 | :_if( static_cast<OWirelessNetworkInterface*>( iface ) ), _prismHeader( prismHeader ) | 1259 | :_if( static_cast<OWirelessNetworkInterface*>( iface ) ), _prismHeader( prismHeader ) |
1249 | { | 1260 | { |
1250 | } | 1261 | } |
1251 | 1262 | ||
1252 | 1263 | ||
1253 | OMonitoringInterface::~OMonitoringInterface() | 1264 | OMonitoringInterface::~OMonitoringInterface() |
1254 | { | 1265 | { |
1255 | } | 1266 | } |
1256 | 1267 | ||
1257 | 1268 | ||
1258 | void OMonitoringInterface::setChannel( int c ) | 1269 | void OMonitoringInterface::setChannel( int c ) |
1259 | { | 1270 | { |
1260 | // use standard WE channel switching protocol | 1271 | // use standard WE channel switching protocol |
1261 | memset( &_if->_iwr, 0, sizeof( struct iwreq ) ); | 1272 | memset( &_if->_iwr, 0, sizeof( struct iwreq ) ); |
1262 | _if->_iwr.u.freq.m = c; | 1273 | _if->_iwr.u.freq.m = c; |
1263 | _if->_iwr.u.freq.e = 0; | 1274 | _if->_iwr.u.freq.e = 0; |
1264 | _if->wioctl( SIOCSIWFREQ ); | 1275 | _if->wioctl( SIOCSIWFREQ ); |
1265 | } | 1276 | } |
1266 | 1277 | ||
1267 | 1278 | ||
1268 | void OMonitoringInterface::setEnabled( bool ) | 1279 | void OMonitoringInterface::setEnabled( bool ) |
1269 | { | 1280 | { |
1270 | } | 1281 | } |
1271 | 1282 | ||
1272 | 1283 | ||
1273 | /*====================================================================================== | 1284 | /*====================================================================================== |
1274 | * OCiscoMonitoringInterface | 1285 | * OCiscoMonitoringInterface |
1275 | *======================================================================================*/ | 1286 | *======================================================================================*/ |
1276 | 1287 | ||
1277 | OCiscoMonitoringInterface::OCiscoMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) | 1288 | OCiscoMonitoringInterface::OCiscoMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) |
1278 | :OMonitoringInterface( iface, prismHeader ) | 1289 | :OMonitoringInterface( iface, prismHeader ) |
1279 | { | 1290 | { |
1280 | iface->setMonitoring( this ); | 1291 | iface->setMonitoring( this ); |
1281 | } | 1292 | } |
1282 | 1293 | ||
1283 | 1294 | ||
1284 | OCiscoMonitoringInterface::~OCiscoMonitoringInterface() | 1295 | OCiscoMonitoringInterface::~OCiscoMonitoringInterface() |
1285 | { | 1296 | { |
1286 | } | 1297 | } |
1287 | 1298 | ||
1288 | 1299 | ||
1289 | void OCiscoMonitoringInterface::setEnabled( bool /*b*/ ) | 1300 | void OCiscoMonitoringInterface::setEnabled( bool /*b*/ ) |
1290 | { | 1301 | { |
1291 | QString fname; | 1302 | QString fname; |
1292 | fname.sprintf( "/proc/driver/aironet/%s", (const char*) _if->name() ); | 1303 | fname.sprintf( "/proc/driver/aironet/%s", (const char*) _if->name() ); |
1293 | QFile f( fname ); | 1304 | QFile f( fname ); |
1294 | if ( !f.exists() ) return; | 1305 | if ( !f.exists() ) return; |
1295 | 1306 | ||
1296 | if ( f.open( IO_WriteOnly ) ) | 1307 | if ( f.open( IO_WriteOnly ) ) |
1297 | { | 1308 | { |
1298 | QTextStream s( &f ); | 1309 | QTextStream s( &f ); |
1299 | s << "Mode: r"; | 1310 | s << "Mode: r"; |
1300 | s << "Mode: y"; | 1311 | s << "Mode: y"; |
1301 | s << "XmitPower: 1"; | 1312 | s << "XmitPower: 1"; |
1302 | } | 1313 | } |
1303 | 1314 | ||
1304 | // flushing and closing will be done automatically when f goes out of scope | 1315 | // flushing and closing will be done automatically when f goes out of scope |
1305 | } | 1316 | } |
1306 | 1317 | ||
1307 | 1318 | ||
1308 | QString OCiscoMonitoringInterface::name() const | 1319 | QString OCiscoMonitoringInterface::name() const |
1309 | { | 1320 | { |
1310 | return "cisco"; | 1321 | return "cisco"; |
1311 | } | 1322 | } |
1312 | 1323 | ||
1313 | 1324 | ||
1314 | void OCiscoMonitoringInterface::setChannel( int ) | 1325 | void OCiscoMonitoringInterface::setChannel( int ) |
1315 | { | 1326 | { |
1316 | // cisco devices automatically switch channels when in monitor mode | 1327 | // cisco devices automatically switch channels when in monitor mode |
1317 | } | 1328 | } |
1318 | 1329 | ||
1319 | 1330 | ||
1320 | /*====================================================================================== | 1331 | /*====================================================================================== |
1321 | * OWlanNGMonitoringInterface | 1332 | * OWlanNGMonitoringInterface |
1322 | *======================================================================================*/ | 1333 | *======================================================================================*/ |
1323 | 1334 | ||
1324 | 1335 | ||
1325 | OWlanNGMonitoringInterface::OWlanNGMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) | 1336 | OWlanNGMonitoringInterface::OWlanNGMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) |
1326 | :OMonitoringInterface( iface, prismHeader ) | 1337 | :OMonitoringInterface( iface, prismHeader ) |
1327 | { | 1338 | { |
1328 | iface->setMonitoring( this ); | 1339 | iface->setMonitoring( this ); |
1329 | } | 1340 | } |
1330 | 1341 | ||
1331 | 1342 | ||
1332 | OWlanNGMonitoringInterface::~OWlanNGMonitoringInterface() | 1343 | OWlanNGMonitoringInterface::~OWlanNGMonitoringInterface() |
1333 | { | 1344 | { |
1334 | } | 1345 | } |
1335 | 1346 | ||
1336 | 1347 | ||
1337 | void OWlanNGMonitoringInterface::setEnabled( bool b ) | 1348 | void OWlanNGMonitoringInterface::setEnabled( bool b ) |
1338 | { | 1349 | { |
1339 | //FIXME: do nothing if its already in the same mode | 1350 | //FIXME: do nothing if its already in the same mode |
1340 | 1351 | ||
1341 | QString enable = b ? "true" : "false"; | 1352 | QString enable = b ? "true" : "false"; |
1342 | QString prism = _prismHeader ? "true" : "false"; | 1353 | QString prism = _prismHeader ? "true" : "false"; |
1343 | QString cmd; | 1354 | QString cmd; |
1344 | cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s prismheader=%s", | 1355 | cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s prismheader=%s", |
1345 | (const char*) _if->name(), 1, (const char*) enable, (const char*) prism ); | 1356 | (const char*) _if->name(), 1, (const char*) enable, (const char*) prism ); |
1346 | system( cmd ); | 1357 | system( cmd ); |
1347 | } | 1358 | } |
1348 | 1359 | ||
1349 | 1360 | ||
1350 | QString OWlanNGMonitoringInterface::name() const | 1361 | QString OWlanNGMonitoringInterface::name() const |
1351 | { | 1362 | { |
1352 | return "wlan-ng"; | 1363 | return "wlan-ng"; |
1353 | } | 1364 | } |
1354 | 1365 | ||
1355 | 1366 | ||
1356 | void OWlanNGMonitoringInterface::setChannel( int c ) | 1367 | void OWlanNGMonitoringInterface::setChannel( int c ) |
1357 | { | 1368 | { |
1358 | //NOTE: Older wlan-ng drivers automatically hopped channels while lnxreq_wlansniff=true. Newer ones don't. | 1369 | //NOTE: Older wlan-ng drivers automatically hopped channels while lnxreq_wlansniff=true. Newer ones don't. |
1359 | 1370 | ||
1360 | QString enable = "true"; //_if->monitorMode() ? "true" : "false"; | 1371 | QString enable = "true"; //_if->monitorMode() ? "true" : "false"; |
1361 | QString prism = _prismHeader ? "true" : "false"; | 1372 | QString prism = _prismHeader ? "true" : "false"; |
1362 | QString cmd; | 1373 | QString cmd; |
1363 | cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s prismheader=%s", | 1374 | cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s prismheader=%s", |
1364 | (const char*) _if->name(), c, (const char*) enable, (const char*) prism ); | 1375 | (const char*) _if->name(), c, (const char*) enable, (const char*) prism ); |
1365 | system( cmd ); | 1376 | system( cmd ); |
1366 | } | 1377 | } |
1367 | 1378 | ||
1368 | 1379 | ||
1369 | /*====================================================================================== | 1380 | /*====================================================================================== |
1370 | * OHostAPMonitoringInterface | 1381 | * OHostAPMonitoringInterface |
1371 | *======================================================================================*/ | 1382 | *======================================================================================*/ |
1372 | 1383 | ||
1373 | OHostAPMonitoringInterface::OHostAPMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) | 1384 | OHostAPMonitoringInterface::OHostAPMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) |
1374 | :OMonitoringInterface( iface, prismHeader ) | 1385 | :OMonitoringInterface( iface, prismHeader ) |
1375 | { | 1386 | { |
1376 | iface->setMonitoring( this ); | 1387 | iface->setMonitoring( this ); |
1377 | } | 1388 | } |
1378 | 1389 | ||
1379 | OHostAPMonitoringInterface::~OHostAPMonitoringInterface() | 1390 | OHostAPMonitoringInterface::~OHostAPMonitoringInterface() |
1380 | { | 1391 | { |
1381 | } | 1392 | } |
1382 | 1393 | ||
1383 | void OHostAPMonitoringInterface::setEnabled( bool b ) | 1394 | void OHostAPMonitoringInterface::setEnabled( bool b ) |
1384 | { | 1395 | { |
1385 | int monitorCode = _prismHeader ? 1 : 2; | 1396 | int monitorCode = _prismHeader ? 1 : 2; |
1386 | if ( b ) | 1397 | if ( b ) |
1387 | { | 1398 | { |
1388 | _if->setPrivate( "monitor", 1, monitorCode ); | 1399 | _if->setPrivate( "monitor", 1, monitorCode ); |
1389 | } | 1400 | } |
1390 | else | 1401 | else |
1391 | { | 1402 | { |
1392 | _if->setPrivate( "monitor", 1, 0 ); | 1403 | _if->setPrivate( "monitor", 1, 0 ); |
1393 | } | 1404 | } |
1394 | } | 1405 | } |
1395 | 1406 | ||
1396 | 1407 | ||
1397 | QString OHostAPMonitoringInterface::name() const | 1408 | QString OHostAPMonitoringInterface::name() const |
1398 | { | 1409 | { |
1399 | return "hostap"; | 1410 | return "hostap"; |
1400 | } | 1411 | } |
1401 | 1412 | ||
1402 | 1413 | ||
1403 | /*====================================================================================== | 1414 | /*====================================================================================== |
1404 | * OOrinocoNetworkInterface | 1415 | * OOrinocoNetworkInterface |
1405 | *======================================================================================*/ | 1416 | *======================================================================================*/ |
1406 | 1417 | ||
1407 | OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) | 1418 | OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) |
1408 | :OMonitoringInterface( iface, prismHeader ) | 1419 | :OMonitoringInterface( iface, prismHeader ) |
1409 | { | 1420 | { |
1410 | iface->setMonitoring( this ); | 1421 | iface->setMonitoring( this ); |
1411 | } | 1422 | } |
1412 | 1423 | ||
1413 | 1424 | ||
1414 | OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface() | 1425 | OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface() |
1415 | { | 1426 | { |
1416 | } | 1427 | } |
1417 | 1428 | ||
1418 | 1429 | ||
1419 | void OOrinocoMonitoringInterface::setChannel( int c ) | 1430 | void OOrinocoMonitoringInterface::setChannel( int c ) |
1420 | { | 1431 | { |
1421 | if ( !_if->hasPrivate( "monitor" ) ) | 1432 | if ( !_if->hasPrivate( "monitor" ) ) |
1422 | { | 1433 | { |
1423 | this->OMonitoringInterface::setChannel( c ); | 1434 | this->OMonitoringInterface::setChannel( c ); |
1424 | } | 1435 | } |
1425 | else | 1436 | else |
1426 | { | 1437 | { |
1427 | int monitorCode = _prismHeader ? 1 : 2; | 1438 | int monitorCode = _prismHeader ? 1 : 2; |
1428 | _if->setPrivate( "monitor", 2, monitorCode, c ); | 1439 | _if->setPrivate( "monitor", 2, monitorCode, c ); |
1429 | } | 1440 | } |
1430 | } | 1441 | } |
1431 | 1442 | ||
1432 | 1443 | ||
1433 | void OOrinocoMonitoringInterface::setEnabled( bool b ) | 1444 | void OOrinocoMonitoringInterface::setEnabled( bool b ) |
1434 | { | 1445 | { |
1435 | if ( b ) | 1446 | if ( b ) |
1436 | { | 1447 | { |
1437 | setChannel( 1 ); | 1448 | setChannel( 1 ); |
1438 | } | 1449 | } |
1439 | else | 1450 | else |
1440 | { | 1451 | { |
1441 | _if->setPrivate( "monitor", 2, 0, 0 ); | 1452 | _if->setPrivate( "monitor", 2, 0, 0 ); |
1442 | } | 1453 | } |
1443 | } | 1454 | } |
1444 | 1455 | ||
1445 | 1456 | ||
1446 | QString OOrinocoMonitoringInterface::name() const | 1457 | QString OOrinocoMonitoringInterface::name() const |
1447 | { | 1458 | { |
1448 | return "orinoco"; | 1459 | return "orinoco"; |
1449 | } | 1460 | } |
1450 | 1461 | ||
1451 | } | 1462 | } |
1452 | } | 1463 | } |
diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h index fa9f39f..f0c4450 100644 --- a/libopie2/opienet/onetwork.h +++ b/libopie2/opienet/onetwork.h | |||
@@ -1,591 +1,598 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) 2003-2005 by Michael 'Mickey' Lauer <mickey@Vanille.de> | 3 | Copyright (C) 2003-2005 by Michael 'Mickey' Lauer <mickey@Vanille.de> |
4 | =. | 4 | =. |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; version 2 of the License. | 11 | - . .-<_> .<> Foundation; version 2 of the License. |
12 | ._= =} : | 12 | ._= =} : |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | 28 | ||
29 | */ | 29 | */ |
30 | 30 | ||
31 | #ifndef ONETWORK_H | 31 | #ifndef ONETWORK_H |
32 | #define ONETWORK_H | 32 | #define ONETWORK_H |
33 | 33 | ||
34 | /* OPIE */ | 34 | /* OPIE */ |
35 | #include <opie2/onetutils.h> | 35 | #include <opie2/onetutils.h> |
36 | #include <opie2/ostation.h> | 36 | #include <opie2/ostation.h> |
37 | 37 | ||
38 | /* QT */ | 38 | /* QT */ |
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 | /* STD */ | 45 | /* STD */ |
46 | // hacky workarounds until we have a true user space wireless.h | 46 | // hacky workarounds until we have a true user space wireless.h |
47 | #include <net/if.h> | 47 | #include <net/if.h> |
48 | #define _LINUX_IF_H | 48 | #define _LINUX_IF_H |
49 | #include <linux/wireless.h> | 49 | #include <linux/wireless.h> |
50 | #ifndef IW_MAX_PRIV_DEF | 50 | #ifndef IW_MAX_PRIV_DEF |
51 | #define IW_MAX_PRIV_DEF 128 | 51 | #define IW_MAX_PRIV_DEF 128 |
52 | #endif | 52 | #endif |
53 | 53 | ||
54 | namespace Opie { | 54 | namespace Opie { |
55 | namespace Net { | 55 | namespace Net { |
56 | class ONetworkInterface; | 56 | class ONetworkInterface; |
57 | class OWirelessNetworkInterface; | 57 | class OWirelessNetworkInterface; |
58 | class OChannelHopper; | 58 | class OChannelHopper; |
59 | class OMonitoringInterface; | 59 | class OMonitoringInterface; |
60 | 60 | ||
61 | /*====================================================================================== | 61 | /*====================================================================================== |
62 | * ONetwork | 62 | * ONetwork |
63 | *======================================================================================*/ | 63 | *======================================================================================*/ |
64 | 64 | ||
65 | /** | 65 | /** |
66 | * @brief A container class for all network interfaces | 66 | * @brief A container class for all network interfaces |
67 | * | 67 | * |
68 | * This class provides access to all available network interfaces of your computer. | 68 | * This class provides access to all available network interfaces of your computer. |
69 | * | 69 | * |
70 | * @author Michael 'Mickey' Lauer <mickey@vanille.de> | 70 | * @author Michael 'Mickey' Lauer <mickey@vanille.de> |
71 | */ | 71 | */ |
72 | class ONetwork : public QObject | 72 | class ONetwork : public QObject |
73 | { | 73 | { |
74 | Q_OBJECT | 74 | Q_OBJECT |
75 | 75 | ||
76 | public: | 76 | public: |
77 | typedef QDict<ONetworkInterface> InterfaceMap; | 77 | typedef QDict<ONetworkInterface> InterfaceMap; |
78 | typedef QDictIterator<ONetworkInterface> InterfaceIterator; | 78 | typedef QDictIterator<ONetworkInterface> InterfaceIterator; |
79 | 79 | ||
80 | public: | 80 | public: |
81 | /** | 81 | /** |
82 | * @returns the number of available interfaces | 82 | * @returns the number of available interfaces |
83 | */ | 83 | */ |
84 | int count() const; | 84 | int count() const; |
85 | /** | 85 | /** |
86 | * @returns a pointer to the (one and only) @ref ONetwork instance. | 86 | * @returns a pointer to the (one and only) @ref ONetwork instance. |
87 | */ | 87 | */ |
88 | static ONetwork* instance(); | 88 | static ONetwork* instance(); |
89 | /** | 89 | /** |
90 | * @returns an iterator usable for iterating through all network interfaces. | 90 | * @returns an iterator usable for iterating through all network interfaces. |
91 | */ | 91 | */ |
92 | InterfaceIterator iterator() const; | 92 | InterfaceIterator iterator() const; |
93 | /** | 93 | /** |
94 | * @returns true, if the @a interface is present. | 94 | * @returns true, if the @a interface is present. |
95 | */ | 95 | */ |
96 | bool isPresent( const char* interface ) const; | 96 | bool isPresent( const char* interface ) const; |
97 | /** | 97 | /** |
98 | * @returns true, if the @a interface supports the wireless extension protocol. | 98 | * @returns true, if the @a interface supports the wireless extension protocol. |
99 | */ | 99 | */ |
100 | bool isWirelessInterface( const char* interface ) const; | 100 | bool isWirelessInterface( const char* interface ) const; |
101 | /** | 101 | /** |
102 | * @returns a pointer to the @ref ONetworkInterface object for the specified @a interface or 0, if not found. | 102 | * @returns a pointer to the @ref ONetworkInterface object for the specified @a interface or 0, if not found. |
103 | * @see ONetworkInterface | 103 | * @see ONetworkInterface |
104 | */ | 104 | */ |
105 | ONetworkInterface* interface( const QString& interface ) const; | 105 | ONetworkInterface* interface( const QString& interface ) const; |
106 | /** | 106 | /** |
107 | * @internal Rebuild the internal interface database | 107 | * @internal Rebuild the internal interface database |
108 | * @note Sometimes it might be useful to call this from client code, | 108 | * @note Sometimes it might be useful to call this from client code, |
109 | * e.g. after issuing a cardctl insert | 109 | * e.g. after issuing a cardctl insert |
110 | */ | 110 | */ |
111 | void synchronize(); | 111 | void synchronize(); |
112 | /** | 112 | /** |
113 | * @returns the wireless extension version used at compile time. | 113 | * @returns the wireless extension version used at compile time. |
114 | **/ | 114 | **/ |
115 | static short wirelessExtensionCompileVersion(); | 115 | static short wirelessExtensionCompileVersion(); |
116 | 116 | ||
117 | protected: | 117 | protected: |
118 | ONetwork(); | 118 | ONetwork(); |
119 | 119 | ||
120 | private: | 120 | private: |
121 | static ONetwork* _instance; | 121 | static ONetwork* _instance; |
122 | InterfaceMap _interfaces; | 122 | InterfaceMap _interfaces; |
123 | class Private; | 123 | class Private; |
124 | Private *d; | 124 | Private *d; |
125 | }; | 125 | }; |
126 | 126 | ||
127 | 127 | ||
128 | /*====================================================================================== | 128 | /*====================================================================================== |
129 | * ONetworkInterface | 129 | * ONetworkInterface |
130 | *======================================================================================*/ | 130 | *======================================================================================*/ |
131 | 131 | ||
132 | /** | 132 | /** |
133 | * @brief A network interface wrapper. | 133 | * @brief A network interface wrapper. |
134 | * | 134 | * |
135 | * This class provides a wrapper for a network interface. All the cumbersume details of | 135 | * This class provides a wrapper for a network interface. All the cumbersume details of |
136 | * Linux ioctls are hidden under a convenient high-level interface. | 136 | * Linux ioctls are hidden under a convenient high-level interface. |
137 | * @warning Most of the setting methods contained in this class require the appropriate | 137 | * @warning Most of the setting methods contained in this class require the appropriate |
138 | * process permissions to work. | 138 | * process permissions to work. |
139 | * | 139 | * |
140 | * @author Michael 'Mickey' Lauer <mickey@vanille.de> | 140 | * @author Michael 'Mickey' Lauer <mickey@vanille.de> |
141 | */ | 141 | */ |
142 | class ONetworkInterface : public QObject | 142 | class ONetworkInterface : public QObject |
143 | { | 143 | { |
144 | friend class OMonitoringInterface; | 144 | friend class OMonitoringInterface; |
145 | friend class OCiscoMonitoringInterface; | 145 | friend class OCiscoMonitoringInterface; |
146 | friend class OWlanNGMonitoringInterface; | 146 | friend class OWlanNGMonitoringInterface; |
147 | friend class OHostAPMonitoringInterface; | 147 | friend class OHostAPMonitoringInterface; |
148 | friend class OOrinocoMonitoringInterface; | 148 | friend class OOrinocoMonitoringInterface; |
149 | 149 | ||
150 | public: | 150 | public: |
151 | /** | 151 | /** |
152 | * Constructor. Normally you don't create @ref ONetworkInterface objects yourself, | 152 | * Constructor. Normally you don't create @ref ONetworkInterface objects yourself, |
153 | * but access them via @ref ONetwork::interface(). | 153 | * but access them via @ref ONetwork::interface(). |
154 | */ | 154 | */ |
155 | ONetworkInterface( QObject* parent, const char* name ); | 155 | ONetworkInterface( QObject* parent, const char* name ); |
156 | /** | 156 | /** |
157 | * Destructor. | 157 | * Destructor. |
158 | */ | 158 | */ |
159 | virtual ~ONetworkInterface(); | 159 | virtual ~ONetworkInterface(); |
160 | /** | 160 | /** |
161 | * Associates a @a monitoring interface with this network interface. | 161 | * Associates a @a monitoring interface with this network interface. |
162 | * @note This is currently only useful with @ref OWirelessNetworkInterface objects. | 162 | * @note This is currently only useful with @ref OWirelessNetworkInterface objects. |
163 | */ | 163 | */ |
164 | void setMonitoring( OMonitoringInterface* monitoring ); | 164 | void setMonitoring( OMonitoringInterface* monitoring ); |
165 | /** | 165 | /** |
166 | * @returns the currently associated monitoring interface or 0, if no monitoring is associated. | 166 | * @returns the currently associated monitoring interface or 0, if no monitoring is associated. |
167 | */ | 167 | */ |
168 | OMonitoringInterface* monitoring() const; | 168 | OMonitoringInterface* monitoring() const; |
169 | /** | 169 | /** |
170 | * Setting an interface to promiscuous mode enables the device to receive | 170 | * Setting an interface to promiscuous mode enables the device to receive |
171 | * all packets on the shared medium - as opposed to packets which are addressed to this interface. | 171 | * all packets on the shared medium - as opposed to packets which are addressed to this interface. |
172 | */ | 172 | */ |
173 | bool setPromiscuousMode( bool ); | 173 | bool setPromiscuousMode( bool ); |
174 | /** | 174 | /** |
175 | * @returns true if the interface is set to promiscuous mode. | 175 | * @returns true if the interface is set to promiscuous mode. |
176 | */ | 176 | */ |
177 | bool promiscuousMode() const; | 177 | bool promiscuousMode() const; |
178 | /** | 178 | /** |
179 | * Setting an interface to up enables it to receive packets. | 179 | * Setting an interface to up enables it to receive packets. |
180 | */ | 180 | */ |
181 | bool setUp( bool ); | 181 | bool setUp( bool ); |
182 | /** | 182 | /** |
183 | * @returns true if the interface is up. | 183 | * @returns true if the interface is up. |
184 | */ | 184 | */ |
185 | bool isUp() const; | 185 | bool isUp() const; |
186 | /** | 186 | /** |
187 | * @returns true if the interface is a loopback interface. | 187 | * @returns true if the interface is a loopback interface. |
188 | */ | 188 | */ |
189 | bool isLoopback() const; | 189 | bool isLoopback() const; |
190 | /** | 190 | /** |
191 | * @returns true if the interface is featuring supports the wireless extension protocol. | 191 | * @returns true if the interface is featuring supports the wireless extension protocol. |
192 | */ | 192 | */ |
193 | bool isWireless() const; | 193 | bool isWireless() const; |
194 | /** | 194 | /** |
195 | * Associate the IP address @ addr with the interface. | 195 | * Associate the IP address @ addr with the interface. |
196 | */ | 196 | */ |
197 | void setIPV4Address( const QHostAddress& addr ); | 197 | void setIPV4Address( const QHostAddress& addr ); |
198 | /** | 198 | /** |
199 | * @returns the IPv4 address associated with the interface. | 199 | * @returns the IPv4 address associated with the interface. |
200 | */ | 200 | */ |
201 | QString ipV4Address() const; //TODO: make this return an OHostAddress | 201 | QString ipV4Address() const; //TODO: make this return an OHostAddress |
202 | /** | 202 | /** |
203 | * Associate the MAC address @a addr with the interface. | 203 | * Associate the MAC address @a addr with the interface. |
204 | * @note It can be necessary to shut down the interface prior to calling this method. | 204 | * @note It can be necessary to shut down the interface prior to calling this method. |
205 | * @note This operation needs root privileges | ||
205 | * @warning This is not supported by all drivers. | 206 | * @warning This is not supported by all drivers. |
206 | */ | 207 | */ |
207 | void setMacAddress( const OMacAddress& addr ); | 208 | void setMacAddress( const OMacAddress& addr ); |
208 | /** | 209 | /** |
209 | * @returns the MAC address associated with the interface. | 210 | * @returns the MAC address associated with the interface. |
210 | */ | 211 | */ |
211 | OMacAddress macAddress() const; | 212 | OMacAddress macAddress() const; |
212 | /** | 213 | /** |
213 | * Associate the IPv4 @a netmask with the interface. | 214 | * Associate the IPv4 @a netmask with the interface. |
214 | */ | 215 | */ |
215 | void setIPV4Netmask( const QHostAddress& netmask ); | 216 | void setIPV4Netmask( const QHostAddress& netmask ); |
216 | /** | 217 | /** |
217 | * @returns the IPv4 netmask associated with the interface. | 218 | * @returns the IPv4 netmask associated with the interface. |
218 | */ | 219 | */ |
219 | QString ipV4Netmask() const; //TODO: make this return an OHostAddress | 220 | QString ipV4Netmask() const; //TODO: make this return an OHostAddress |
220 | /** | 221 | /** |
221 | * @returns the data link type currently associated with the interface. | 222 | * @returns the data link type currently associated with the interface. |
222 | * @see #include <net/if_arp.h> for possible values. | 223 | * @see #include <net/if_arp.h> for possible values. |
223 | */ | 224 | */ |
224 | int dataLinkType() const; | 225 | int dataLinkType() const; |
226 | /** | ||
227 | * @returns a ONetworkInterfaceDriverInfo driver information block | ||
228 | * @note This operation needs root privileges | ||
229 | * @warning This is not supported by all drivers | ||
230 | */ | ||
231 | ONetworkInterfaceDriverInfo driverInfo() const; | ||
225 | 232 | ||
226 | protected: | 233 | protected: |
227 | const int _sfd; | 234 | const int _sfd; |
228 | mutable ifreq _ifr; | 235 | mutable ifreq _ifr; |
229 | OMonitoringInterface* _mon; | 236 | OMonitoringInterface* _mon; |
230 | 237 | ||
231 | protected: | 238 | protected: |
232 | struct ifreq& ifr() const; | 239 | struct ifreq& ifr() const; |
233 | virtual void init(); | 240 | virtual void init(); |
234 | bool ioctl( int call ) const; | 241 | bool ioctl( int call ) const; |
235 | bool ioctl( int call, struct ifreq& ) const; | 242 | bool ioctl( int call, struct ifreq& ) const; |
236 | private: | 243 | private: |
237 | class Private; | 244 | class Private; |
238 | Private *d; | 245 | Private *d; |
239 | }; | 246 | }; |
240 | 247 | ||
241 | /*====================================================================================== | 248 | /*====================================================================================== |
242 | * OChannelHopper | 249 | * OChannelHopper |
243 | *======================================================================================*/ | 250 | *======================================================================================*/ |
244 | 251 | ||
245 | /** | 252 | /** |
246 | * @brief A radio frequency channel hopper. | 253 | * @brief A radio frequency channel hopper. |
247 | * | 254 | * |
248 | * This class provides a channel hopper for radio frequencies. A channel hopper frequently | 255 | * This class provides a channel hopper for radio frequencies. A channel hopper frequently |
249 | * changes the radio frequency channel of its associated @ref OWirelessNetworkInterface. | 256 | * changes the radio frequency channel of its associated @ref OWirelessNetworkInterface. |
250 | * This is necessary when in monitoring mode and scanning for other devices, because | 257 | * This is necessary when in monitoring mode and scanning for other devices, because |
251 | * the radio frequency hardware can only detect packets sent on the same frequency. | 258 | * the radio frequency hardware can only detect packets sent on the same frequency. |
252 | * | 259 | * |
253 | * @author Michael 'Mickey' Lauer <mickey@vanille.de> | 260 | * @author Michael 'Mickey' Lauer <mickey@vanille.de> |
254 | */ | 261 | */ |
255 | class OChannelHopper : public QObject | 262 | class OChannelHopper : public QObject |
256 | { | 263 | { |
257 | Q_OBJECT | 264 | Q_OBJECT |
258 | 265 | ||
259 | public: | 266 | public: |
260 | /** | 267 | /** |
261 | * Constructor. | 268 | * Constructor. |
262 | */ | 269 | */ |
263 | OChannelHopper( OWirelessNetworkInterface* ); | 270 | OChannelHopper( OWirelessNetworkInterface* ); |
264 | /** | 271 | /** |
265 | * Destructor. | 272 | * Destructor. |
266 | */ | 273 | */ |
267 | virtual ~OChannelHopper(); | 274 | virtual ~OChannelHopper(); |
268 | /** | 275 | /** |
269 | * @returns true, if the channel hopper is hopping channels | 276 | * @returns true, if the channel hopper is hopping channels |
270 | */ | 277 | */ |
271 | bool isActive() const; | 278 | bool isActive() const; |
272 | /** | 279 | /** |
273 | * @returns the last hopped channel | 280 | * @returns the last hopped channel |
274 | */ | 281 | */ |
275 | int channel() const; | 282 | int channel() const; |
276 | /** | 283 | /** |
277 | * Set the channel hopping @a interval. | 284 | * Set the channel hopping @a interval. |
278 | * An interval of 0 deactivates the channel hopper. | 285 | * An interval of 0 deactivates the channel hopper. |
279 | */ | 286 | */ |
280 | void setInterval( int interval ); | 287 | void setInterval( int interval ); |
281 | /** | 288 | /** |
282 | * @returns the channel hopping interval | 289 | * @returns the channel hopping interval |
283 | */ | 290 | */ |
284 | int interval() const; | 291 | int interval() const; |
285 | 292 | ||
286 | signals: | 293 | signals: |
287 | /** | 294 | /** |
288 | * This signal is emitted right after the channel hopper performed a hop | 295 | * This signal is emitted right after the channel hopper performed a hop |
289 | */ | 296 | */ |
290 | void hopped( int ); | 297 | void hopped( int ); |
291 | 298 | ||
292 | protected: | 299 | protected: |
293 | virtual void timerEvent( QTimerEvent* ); | 300 | virtual void timerEvent( QTimerEvent* ); |
294 | 301 | ||
295 | private: | 302 | private: |
296 | OWirelessNetworkInterface* _iface; | 303 | OWirelessNetworkInterface* _iface; |
297 | int _interval; | 304 | int _interval; |
298 | int _tid; | 305 | int _tid; |
299 | QValueList<int> _channels; | 306 | QValueList<int> _channels; |
300 | QValueList<int>::Iterator _channel; | 307 | QValueList<int>::Iterator _channel; |
301 | class Private; | 308 | class Private; |
302 | Private *d; | 309 | Private *d; |
303 | }; | 310 | }; |
304 | 311 | ||
305 | 312 | ||
306 | /*====================================================================================== | 313 | /*====================================================================================== |
307 | * OWirelessNetworkInterface | 314 | * OWirelessNetworkInterface |
308 | *======================================================================================*/ | 315 | *======================================================================================*/ |
309 | 316 | ||
310 | /** | 317 | /** |
311 | * @brief A network interface wrapper for interfaces supporting the wireless extensions protocol. | 318 | * @brief A network interface wrapper for interfaces supporting the wireless extensions protocol. |
312 | * | 319 | * |
313 | * This class provides a high-level encapsulation of the Linux wireless extension API. | 320 | * This class provides a high-level encapsulation of the Linux wireless extension API. |
314 | * | 321 | * |
315 | * @author Michael 'Mickey' Lauer <mickey@vanille.de> | 322 | * @author Michael 'Mickey' Lauer <mickey@vanille.de> |
316 | */ | 323 | */ |
317 | class OWirelessNetworkInterface : public ONetworkInterface | 324 | class OWirelessNetworkInterface : public ONetworkInterface |
318 | { | 325 | { |
319 | friend class OMonitoringInterface; | 326 | friend class OMonitoringInterface; |
320 | friend class OCiscoMonitoringInterface; | 327 | friend class OCiscoMonitoringInterface; |
321 | friend class OWlanNGMonitoringInterface; | 328 | friend class OWlanNGMonitoringInterface; |
322 | friend class OHostAPMonitoringInterface; | 329 | friend class OHostAPMonitoringInterface; |
323 | friend class OOrinocoMonitoringInterface; | 330 | friend class OOrinocoMonitoringInterface; |
324 | 331 | ||
325 | friend class OPrivateIOCTL; | 332 | friend class OPrivateIOCTL; |
326 | 333 | ||
327 | public: | 334 | public: |
328 | /** | 335 | /** |
329 | * Constructor. | 336 | * Constructor. |
330 | */ | 337 | */ |
331 | OWirelessNetworkInterface( QObject* parent, const char* name ); | 338 | OWirelessNetworkInterface( QObject* parent, const char* name ); |
332 | /** | 339 | /** |
333 | * Destructor. | 340 | * Destructor. |
334 | */ | 341 | */ |
335 | virtual ~OWirelessNetworkInterface(); | 342 | virtual ~OWirelessNetworkInterface(); |
336 | /** | 343 | /** |
337 | * Setting the @a channel of the interface changes the radio frequency (RF) | 344 | * Setting the @a channel of the interface changes the radio frequency (RF) |
338 | * of the corresponding wireless network device. | 345 | * of the corresponding wireless network device. |
339 | * @note Common channel range is within [1-14]. A value of 0 is not allowed. | 346 | * @note Common channel range is within [1-14]. A value of 0 is not allowed. |
340 | * @see channels() | 347 | * @see channels() |
341 | */ | 348 | */ |
342 | virtual void setChannel( int channel ) const; | 349 | virtual void setChannel( int channel ) const; |
343 | /** | 350 | /** |
344 | * @returns the channel index of the current radio frequency. | 351 | * @returns the channel index of the current radio frequency. |
345 | */ | 352 | */ |
346 | virtual int channel() const; | 353 | virtual int channel() const; |
347 | /** | 354 | /** |
348 | * @returns the current radio frequency (in MHz). | 355 | * @returns the current radio frequency (in MHz). |
349 | */ | 356 | */ |
350 | virtual double frequency() const; | 357 | virtual double frequency() const; |
351 | /** | 358 | /** |
352 | * @returns the number of radio frequency channels for the | 359 | * @returns the number of radio frequency channels for the |
353 | * corresponding wireless network device. | 360 | * corresponding wireless network device. |
354 | * @note European devices usually have 14 channels, while American typically feature 11 channels. | 361 | * @note European devices usually have 14 channels, while American typically feature 11 channels. |
355 | */ | 362 | */ |
356 | virtual int channels() const; | 363 | virtual int channels() const; |
357 | /** | 364 | /** |
358 | * Set the IEEE 802.11 operation @a mode. | 365 | * Set the IEEE 802.11 operation @a mode. |
359 | * Valid values are <ul><li>adhoc<li>managed<li>monitor<li>master | 366 | * Valid values are <ul><li>adhoc<li>managed<li>monitor<li>master |
360 | * @warning Not all drivers support the all modes. | 367 | * @warning Not all drivers support the all modes. |
361 | * @note You might have to change the SSID to get the operation mode change into effect. | 368 | * @note You might have to change the SSID to get the operation mode change into effect. |
362 | */ | 369 | */ |
363 | virtual void setMode( const QString& mode ); | 370 | virtual void setMode( const QString& mode ); |
364 | /** | 371 | /** |
365 | * @returns the current IEEE 802.11 operation mode. | 372 | * @returns the current IEEE 802.11 operation mode. |
366 | * Possible values are <ul><li>adhoc<li>managed<li>monitor<li>master or <li>unknown | 373 | * Possible values are <ul><li>adhoc<li>managed<li>monitor<li>master or <li>unknown |
367 | * | 374 | * |
368 | * @note: Important note concerning the 'monitor' mode: | 375 | * @note: Important note concerning the 'monitor' mode: |
369 | * Setting the monitor mode on a wireless network interface enables | 376 | * Setting the monitor mode on a wireless network interface enables |
370 | * listening to IEEE 802.11 data and management frames which normally | 377 | * listening to IEEE 802.11 data and management frames which normally |
371 | * are handled by the device firmware. This can be used to detect | 378 | * are handled by the device firmware. This can be used to detect |
372 | * other wireless network devices, e.g. Access Points or Ad-hoc stations. | 379 | * other wireless network devices, e.g. Access Points or Ad-hoc stations. |
373 | * @warning Standard wireless network drives don't support the monitor mode. | 380 | * @warning Standard wireless network drives don't support the monitor mode. |
374 | * @warning You need a patched driver for this to work. | 381 | * @warning You need a patched driver for this to work. |
375 | * @note Enabling the monitor mode is highly driver dependent and requires | 382 | * @note Enabling the monitor mode is highly driver dependent and requires |
376 | * the proper @ref OMonitoringInterface to be associated with the interface. | 383 | * the proper @ref OMonitoringInterface to be associated with the interface. |
377 | * @see OMonitoringInterface | 384 | * @see OMonitoringInterface |
378 | */ | 385 | */ |
379 | virtual QString mode() const; | 386 | virtual QString mode() const; |
380 | /** | 387 | /** |
381 | * Set the channel hopping @a interval. An @a interval of 0 disables channel hopping. | 388 | * Set the channel hopping @a interval. An @a interval of 0 disables channel hopping. |
382 | * @see OChannelHopper | 389 | * @see OChannelHopper |
383 | */ | 390 | */ |
384 | virtual void setChannelHopping( int interval = 0 ); | 391 | virtual void setChannelHopping( int interval = 0 ); |
385 | /** | 392 | /** |
386 | * @returns the channel hopping interval or 0, if channel hopping is disabled. | 393 | * @returns the channel hopping interval or 0, if channel hopping is disabled. |
387 | */ | 394 | */ |
388 | virtual int channelHopping() const; | 395 | virtual int channelHopping() const; |
389 | /** | 396 | /** |
390 | * @returns the @ref OChannelHopper of this interface or 0, if channel hopping has not been activated before | 397 | * @returns the @ref OChannelHopper of this interface or 0, if channel hopping has not been activated before |
391 | */ | 398 | */ |
392 | virtual OChannelHopper* channelHopper() const; | 399 | virtual OChannelHopper* channelHopper() const; |
393 | /** | 400 | /** |
394 | * Set the station @a nickname. | 401 | * Set the station @a nickname. |
395 | */ | 402 | */ |
396 | virtual void setNickName( const QString& nickname ); | 403 | virtual void setNickName( const QString& nickname ); |
397 | /** | 404 | /** |
398 | * @returns the current station nickname. | 405 | * @returns the current station nickname. |
399 | */ | 406 | */ |
400 | virtual QString nickName() const; | 407 | virtual QString nickName() const; |
401 | /** | 408 | /** |
402 | * Invoke the private IOCTL @a command with a @number of parameters on the network interface. | 409 | * Invoke the private IOCTL @a command with a @number of parameters on the network interface. |
403 | * @see OPrivateIOCTL | 410 | * @see OPrivateIOCTL |
404 | */ | 411 | */ |
405 | virtual void setPrivate( const QString& command, int number, ... ); | 412 | virtual void setPrivate( const QString& command, int number, ... ); |
406 | /** | 413 | /** |
407 | * @returns true if the interface is featuring the private IOCTL @command. | 414 | * @returns true if the interface is featuring the private IOCTL @command. |
408 | */ | 415 | */ |
409 | virtual bool hasPrivate( const QString& command ); | 416 | virtual bool hasPrivate( const QString& command ); |
410 | virtual void getPrivate( const QString& command ); //FIXME: Implement and document this | 417 | virtual void getPrivate( const QString& command ); //FIXME: Implement and document this |
411 | /** | 418 | /** |
412 | * @returns true if the interface is associated to an access point | 419 | * @returns true if the interface is associated to an access point |
413 | * @note: This information is only valid if the interface is in managed mode. | 420 | * @note: This information is only valid if the interface is in managed mode. |
414 | */ | 421 | */ |
415 | virtual bool isAssociated() const; | 422 | virtual bool isAssociated() const; |
416 | /** Set the @a mac associated AP address. | 423 | /** Set the @a mac associated AP address. |
417 | */ | 424 | */ |
418 | virtual void setAssociatedAP( const OMacAddress& mac ) const; | 425 | virtual void setAssociatedAP( const OMacAddress& mac ) const; |
419 | /** | 426 | /** |
420 | * @returns the MAC address of the Access Point if the device is in infrastructure mode. | 427 | * @returns the MAC address of the Access Point if the device is in infrastructure mode. |
421 | * @returns a (more or less random) cell ID address if the device is in adhoc mode. | 428 | * @returns a (more or less random) cell ID address if the device is in adhoc mode. |
422 | */ | 429 | */ |
423 | virtual OMacAddress associatedAP() const; | 430 | virtual OMacAddress associatedAP() const; |
424 | /** | 431 | /** |
425 | * Set the @a ssid (Service Set ID) string. This is used to decide | 432 | * Set the @a ssid (Service Set ID) string. This is used to decide |
426 | * which network to associate with (use "any" to let the driver decide). | 433 | * which network to associate with (use "any" to let the driver decide). |
427 | */ | 434 | */ |
428 | virtual void setSSID( const QString& ssid ); | 435 | virtual void setSSID( const QString& ssid ); |
429 | /** | 436 | /** |
430 | * @returns the current SSID (Service Set ID). | 437 | * @returns the current SSID (Service Set ID). |
431 | */ | 438 | */ |
432 | virtual QString SSID() const; | 439 | virtual QString SSID() const; |
433 | /** | 440 | /** |
434 | * Perform scanning the wireless network neighbourhood. | 441 | * Perform scanning the wireless network neighbourhood. |
435 | * @note: UNSTABLE API - UNDER CONSTRUCTION - DON'T USE! | 442 | * @note: UNSTABLE API - UNDER CONSTRUCTION - DON'T USE! |
436 | */ | 443 | */ |
437 | virtual OStationList* scanNetwork(); | 444 | virtual OStationList* scanNetwork(); |
438 | /** | 445 | /** |
439 | * @return signal strength to associated neighbour (in percent). | 446 | * @return signal strength to associated neighbour (in percent). |
440 | * In infrastructure mode, this is the signal strength of the Access Point. | 447 | * In infrastructure mode, this is the signal strength of the Access Point. |
441 | * In other modes the result is driver dependent. | 448 | * In other modes the result is driver dependent. |
442 | */ | 449 | */ |
443 | virtual int signalStrength() const; | 450 | virtual int signalStrength() const; |
444 | /** | 451 | /** |
445 | * @returns the wireless extension version used by the interface driver. | 452 | * @returns the wireless extension version used by the interface driver. |
446 | **/ | 453 | **/ |
447 | short wirelessExtensionDriverVersion() const; | 454 | short wirelessExtensionDriverVersion() const; |
448 | /** | 455 | /** |
449 | * @internal commit pending changes to the driver | 456 | * @internal commit pending changes to the driver |
450 | */ | 457 | */ |
451 | void commit() const; | 458 | void commit() const; |
452 | 459 | ||
453 | protected: | 460 | protected: |
454 | void buildInformation(); | 461 | void buildInformation(); |
455 | void buildPrivateList(); | 462 | void buildPrivateList(); |
456 | void dumpInformation() const; | 463 | void dumpInformation() const; |
457 | virtual void init(); | 464 | virtual void init(); |
458 | struct iwreq& iwr() const; | 465 | struct iwreq& iwr() const; |
459 | bool wioctl( int call ) const; | 466 | bool wioctl( int call ) const; |
460 | bool wioctl( int call, struct iwreq& ) const; | 467 | bool wioctl( int call, struct iwreq& ) const; |
461 | 468 | ||
462 | protected: | 469 | protected: |
463 | mutable struct iwreq _iwr; | 470 | mutable struct iwreq _iwr; |
464 | QMap<int,int> _channels; | 471 | QMap<int,int> _channels; |
465 | struct iw_range _range; | 472 | struct iw_range _range; |
466 | 473 | ||
467 | private: | 474 | private: |
468 | OChannelHopper* _hopper; | 475 | OChannelHopper* _hopper; |
469 | class Private; | 476 | class Private; |
470 | Private *d; | 477 | Private *d; |
471 | }; | 478 | }; |
472 | 479 | ||
473 | 480 | ||
474 | /*====================================================================================== | 481 | /*====================================================================================== |
475 | * OMonitoringInterface | 482 | * OMonitoringInterface |
476 | *======================================================================================*/ | 483 | *======================================================================================*/ |
477 | 484 | ||
478 | 485 | ||
479 | class OMonitoringInterface | 486 | class OMonitoringInterface |
480 | { | 487 | { |
481 | public: | 488 | public: |
482 | OMonitoringInterface(); | 489 | OMonitoringInterface(); |
483 | OMonitoringInterface( ONetworkInterface*, bool _prismHeader ); | 490 | OMonitoringInterface( ONetworkInterface*, bool _prismHeader ); |
484 | virtual ~OMonitoringInterface(); | 491 | virtual ~OMonitoringInterface(); |
485 | 492 | ||
486 | public: | 493 | public: |
487 | virtual void setEnabled( bool ); | 494 | virtual void setEnabled( bool ); |
488 | virtual void setChannel( int ); | 495 | virtual void setChannel( int ); |
489 | 496 | ||
490 | virtual QString name() const = 0; | 497 | virtual QString name() const = 0; |
491 | 498 | ||
492 | protected: | 499 | protected: |
493 | OWirelessNetworkInterface* _if; | 500 | OWirelessNetworkInterface* _if; |
494 | bool _prismHeader; | 501 | bool _prismHeader; |
495 | private: | 502 | private: |
496 | class Private; | 503 | class Private; |
497 | Private *d; | 504 | Private *d; |
498 | 505 | ||
499 | }; | 506 | }; |
500 | 507 | ||
501 | 508 | ||
502 | /*====================================================================================== | 509 | /*====================================================================================== |
503 | * OCiscoMonitoring | 510 | * OCiscoMonitoring |
504 | *======================================================================================*/ | 511 | *======================================================================================*/ |
505 | 512 | ||
506 | 513 | ||
507 | class OCiscoMonitoringInterface : public OMonitoringInterface | 514 | class OCiscoMonitoringInterface : public OMonitoringInterface |
508 | { | 515 | { |
509 | public: | 516 | public: |
510 | OCiscoMonitoringInterface( ONetworkInterface*, bool _prismHeader ); | 517 | OCiscoMonitoringInterface( ONetworkInterface*, bool _prismHeader ); |
511 | virtual ~OCiscoMonitoringInterface(); | 518 | virtual ~OCiscoMonitoringInterface(); |
512 | 519 | ||
513 | virtual void setEnabled( bool ); | 520 | virtual void setEnabled( bool ); |
514 | virtual QString name() const; | 521 | virtual QString name() const; |
515 | virtual void setChannel( int ); | 522 | virtual void setChannel( int ); |
516 | private: | 523 | private: |
517 | class Private; | 524 | class Private; |
518 | Private *d; | 525 | Private *d; |
519 | 526 | ||
520 | }; | 527 | }; |
521 | 528 | ||
522 | 529 | ||
523 | /*====================================================================================== | 530 | /*====================================================================================== |
524 | * OWlanNGMonitoringInterface | 531 | * OWlanNGMonitoringInterface |
525 | *======================================================================================*/ | 532 | *======================================================================================*/ |
526 | 533 | ||
527 | 534 | ||
528 | class OWlanNGMonitoringInterface : public OMonitoringInterface | 535 | class OWlanNGMonitoringInterface : public OMonitoringInterface |
529 | { | 536 | { |
530 | public: | 537 | public: |
531 | OWlanNGMonitoringInterface( ONetworkInterface*, bool _prismHeader ); | 538 | OWlanNGMonitoringInterface( ONetworkInterface*, bool _prismHeader ); |
532 | virtual ~OWlanNGMonitoringInterface(); | 539 | virtual ~OWlanNGMonitoringInterface(); |
533 | 540 | ||
534 | public: | 541 | public: |
535 | virtual void setEnabled( bool ); | 542 | virtual void setEnabled( bool ); |
536 | virtual QString name() const; | 543 | virtual QString name() const; |
537 | virtual void setChannel( int ); | 544 | virtual void setChannel( int ); |
538 | private: | 545 | private: |
539 | class Private; | 546 | class Private; |
540 | Private *d; | 547 | Private *d; |
541 | 548 | ||
542 | }; | 549 | }; |
543 | 550 | ||
544 | 551 | ||
545 | /*====================================================================================== | 552 | /*====================================================================================== |
546 | * OHostAPMonitoringInterface | 553 | * OHostAPMonitoringInterface |
547 | *======================================================================================*/ | 554 | *======================================================================================*/ |
548 | 555 | ||
549 | 556 | ||
550 | class OHostAPMonitoringInterface : public OMonitoringInterface | 557 | class OHostAPMonitoringInterface : public OMonitoringInterface |
551 | { | 558 | { |
552 | public: | 559 | public: |
553 | OHostAPMonitoringInterface( ONetworkInterface*, bool _prismHeader ); | 560 | OHostAPMonitoringInterface( ONetworkInterface*, bool _prismHeader ); |
554 | virtual ~OHostAPMonitoringInterface(); | 561 | virtual ~OHostAPMonitoringInterface(); |
555 | 562 | ||
556 | public: | 563 | public: |
557 | virtual void setEnabled( bool ); | 564 | virtual void setEnabled( bool ); |
558 | virtual QString name() const; | 565 | virtual QString name() const; |
559 | 566 | ||
560 | private: | 567 | private: |
561 | class Private; | 568 | class Private; |
562 | Private *d; | 569 | Private *d; |
563 | }; | 570 | }; |
564 | 571 | ||
565 | 572 | ||
566 | /*====================================================================================== | 573 | /*====================================================================================== |
567 | * OOrinocoMonitoringInterface | 574 | * OOrinocoMonitoringInterface |
568 | *======================================================================================*/ | 575 | *======================================================================================*/ |
569 | 576 | ||
570 | 577 | ||
571 | class OOrinocoMonitoringInterface : public OMonitoringInterface | 578 | class OOrinocoMonitoringInterface : public OMonitoringInterface |
572 | { | 579 | { |
573 | public: | 580 | public: |
574 | OOrinocoMonitoringInterface( ONetworkInterface*, bool _prismHeader ); | 581 | OOrinocoMonitoringInterface( ONetworkInterface*, bool _prismHeader ); |
575 | virtual ~OOrinocoMonitoringInterface(); | 582 | virtual ~OOrinocoMonitoringInterface(); |
576 | 583 | ||
577 | public: | 584 | public: |
578 | virtual void setChannel( int ); | 585 | virtual void setChannel( int ); |
579 | virtual void setEnabled( bool ); | 586 | virtual void setEnabled( bool ); |
580 | virtual QString name() const; | 587 | virtual QString name() const; |
581 | 588 | ||
582 | private: | 589 | private: |
583 | class Private; | 590 | class Private; |
584 | Private *d; | 591 | Private *d; |
585 | }; | 592 | }; |
586 | 593 | ||
587 | } | 594 | } |
588 | } | 595 | } |
589 | 596 | ||
590 | #endif // ONETWORK_H | 597 | #endif // ONETWORK_H |
591 | 598 | ||
diff --git a/libopie2/opienet/opienet.pro b/libopie2/opienet/opienet.pro index 460de0a..854e5ff 100644 --- a/libopie2/opienet/opienet.pro +++ b/libopie2/opienet/opienet.pro | |||
@@ -1,40 +1,40 @@ | |||
1 | TEMPLATE = lib | 1 | TEMPLATE = lib |
2 | CONFIG += qt warn_on | 2 | CONFIG += qt warn_on |
3 | DESTDIR = $(OPIEDIR)/lib | 3 | DESTDIR = $(OPIEDIR)/lib |
4 | HEADERS = 802_11_user.h \ | 4 | HEADERS = 802_11_user.h \ |
5 | dhcp.h \ | 5 | dhcp.h \ |
6 | udp_ports.h \ | 6 | udp_ports.h \ |
7 | odebugmapper.h \ | 7 | odebugmapper.h \ |
8 | omanufacturerdb.h \ | 8 | omanufacturerdb.h \ |
9 | onetutils.h \ | 9 | onetutils.h \ |
10 | onetwork.h \ | 10 | onetwork.h \ |
11 | opcap.h \ | 11 | opcap.h \ |
12 | ostation.h | 12 | ostation.h |
13 | SOURCES = odebugmapper.cpp \ | 13 | SOURCES = odebugmapper.cpp \ |
14 | omanufacturerdb.cpp \ | 14 | omanufacturerdb.cpp \ |
15 | onetutils.cpp \ | 15 | onetutils.cpp \ |
16 | onetwork.cpp \ | 16 | onetwork.cpp \ |
17 | opcap.cpp \ | 17 | opcap.cpp \ |
18 | ostation.cpp | 18 | ostation.cpp |
19 | INTERFACES = | 19 | INTERFACES = |
20 | TARGET = opienet2 | 20 | TARGET = opienet2 |
21 | VERSION = 1.8.6 | 21 | VERSION = 1.8.7 |
22 | INCLUDEPATH += $(OPIEDIR)/include | 22 | INCLUDEPATH += $(OPIEDIR)/include |
23 | DEPENDPATH += $(OPIEDIR)/include | 23 | DEPENDPATH += $(OPIEDIR)/include |
24 | LIBS += -lpcap | 24 | LIBS += -lpcap |
25 | 25 | ||
26 | 26 | ||
27 | !contains( platform, x11 ) { | 27 | !contains( platform, x11 ) { |
28 | include( $(OPIEDIR)/include.pro ) | 28 | include( $(OPIEDIR)/include.pro ) |
29 | } | 29 | } |
30 | 30 | ||
31 | contains( platform, x11 ) { | 31 | contains( platform, x11 ) { |
32 | LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib | 32 | LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib |
33 | } | 33 | } |
34 | 34 | ||
35 | !isEmpty( LIBPCAP_INC_DIR ) { | 35 | !isEmpty( LIBPCAP_INC_DIR ) { |
36 | INCLUDEPATH = $$LIBPCAP_INC_DIR $$INCLUDEPATH | 36 | INCLUDEPATH = $$LIBPCAP_INC_DIR $$INCLUDEPATH |
37 | } | 37 | } |
38 | !isEmpty( LIBPCAP_LIB_DIR ) { | 38 | !isEmpty( LIBPCAP_LIB_DIR ) { |
39 | LIBS = -L$$LIBPCAP_LIB_DIR $$LIBS | 39 | LIBS = -L$$LIBPCAP_LIB_DIR $$LIBS |
40 | } | 40 | } |