Diffstat (limited to 'libopie2/opienet/onetwork.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opienet/onetwork.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp index e5b091f..ab3e77f 100644 --- a/libopie2/opienet/onetwork.cpp +++ b/libopie2/opienet/onetwork.cpp | |||
@@ -12,103 +12,109 @@ | |||
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
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 | 32 | ||
33 | #include <opie2/onetwork.h> | 33 | #include <opie2/onetwork.h> |
34 | #include <opie2/ostation.h> | 34 | #include <opie2/ostation.h> |
35 | #include <opie2/odebug.h> | 35 | #include <opie2/odebug.h> |
36 | 36 | ||
37 | /* QT */ | 37 | /* QT */ |
38 | 38 | ||
39 | #include <qfile.h> | 39 | #include <qfile.h> |
40 | #include <qtextstream.h> | 40 | #include <qtextstream.h> |
41 | 41 | ||
42 | /* UNIX */ | 42 | /* UNIX */ |
43 | 43 | ||
44 | #include <assert.h> | 44 | #include <assert.h> |
45 | #include <arpa/inet.h> | 45 | #include <arpa/inet.h> |
46 | #include <errno.h> | 46 | #include <errno.h> |
47 | #include <string.h> | 47 | #include <string.h> |
48 | #include <stdlib.h> | 48 | #include <stdlib.h> |
49 | #include <math.h> | 49 | #include <math.h> |
50 | #include <sys/ioctl.h> | 50 | #include <sys/ioctl.h> |
51 | #include <sys/socket.h> | 51 | #include <sys/socket.h> |
52 | #include <sys/types.h> | 52 | #include <sys/types.h> |
53 | #include <unistd.h> | 53 | #include <unistd.h> |
54 | #include <linux/sockios.h> | 54 | #include <linux/sockios.h> |
55 | #include <net/if_arp.h> | 55 | #include <net/if_arp.h> |
56 | #include <stdarg.h> | 56 | #include <stdarg.h> |
57 | 57 | ||
58 | #ifndef NODEBUG | 58 | #ifndef NODEBUG |
59 | #include <opie2/odebugmapper.h> | 59 | #include <opie2/odebugmapper.h> |
60 | |||
61 | |||
62 | using namespace Opie::Core; | ||
63 | using namespace Opie::Net::Private; | ||
60 | DebugMapper* debugmapper = new DebugMapper(); | 64 | DebugMapper* debugmapper = new DebugMapper(); |
61 | #endif | 65 | #endif |
62 | 66 | ||
63 | /*====================================================================================== | 67 | /*====================================================================================== |
64 | * ONetwork | 68 | * ONetwork |
65 | *======================================================================================*/ | 69 | *======================================================================================*/ |
66 | 70 | ||
71 | namespace Opie { | ||
72 | namespace Net { | ||
67 | ONetwork* ONetwork::_instance = 0; | 73 | ONetwork* ONetwork::_instance = 0; |
68 | 74 | ||
69 | ONetwork::ONetwork() | 75 | ONetwork::ONetwork() |
70 | { | 76 | { |
71 | odebug << "ONetwork::ONetwork()" << oendl; | 77 | odebug << "ONetwork::ONetwork()" << oendl; |
72 | odebug << "ONetwork: This code has been compiled against Wireless Extensions V" << WIRELESS_EXT << oendl; | 78 | odebug << "ONetwork: This code has been compiled against Wireless Extensions V" << WIRELESS_EXT << oendl; |
73 | synchronize(); | 79 | synchronize(); |
74 | } | 80 | } |
75 | 81 | ||
76 | void ONetwork::synchronize() | 82 | void ONetwork::synchronize() |
77 | { | 83 | { |
78 | // gather available interfaces by inspecting /proc/net/dev | 84 | // gather available interfaces by inspecting /proc/net/dev |
79 | //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices | 85 | //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices |
80 | //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices | 86 | //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices |
81 | //FIXME: Best is use SIOCGIFCONF and if this doesn't work (result=-1), then fallback to parsing /proc/net/dev | 87 | //FIXME: Best is use SIOCGIFCONF and if this doesn't work (result=-1), then fallback to parsing /proc/net/dev |
82 | 88 | ||
83 | _interfaces.clear(); | 89 | _interfaces.clear(); |
84 | QString str; | 90 | QString str; |
85 | QFile f( "/proc/net/dev" ); | 91 | QFile f( "/proc/net/dev" ); |
86 | bool hasFile = f.open( IO_ReadOnly ); | 92 | bool hasFile = f.open( IO_ReadOnly ); |
87 | if ( !hasFile ) | 93 | if ( !hasFile ) |
88 | { | 94 | { |
89 | odebug << "ONetwork: /proc/net/dev not existing. No network devices available" << oendl; | 95 | odebug << "ONetwork: /proc/net/dev not existing. No network devices available" << oendl; |
90 | return; | 96 | return; |
91 | } | 97 | } |
92 | QTextStream s( &f ); | 98 | QTextStream s( &f ); |
93 | s.readLine(); | 99 | s.readLine(); |
94 | s.readLine(); | 100 | s.readLine(); |
95 | while ( !s.atEnd() ) | 101 | while ( !s.atEnd() ) |
96 | { | 102 | { |
97 | s >> str; | 103 | s >> str; |
98 | str.truncate( str.find( ':' ) ); | 104 | str.truncate( str.find( ':' ) ); |
99 | odebug << "ONetwork: found interface '" << str << "'" << oendl; | 105 | odebug << "ONetwork: found interface '" << str << "'" << oendl; |
100 | ONetworkInterface* iface; | 106 | ONetworkInterface* iface; |
101 | if ( isWirelessInterface( str ) ) | 107 | if ( isWirelessInterface( str ) ) |
102 | { | 108 | { |
103 | iface = new OWirelessNetworkInterface( this, (const char*) str ); | 109 | iface = new OWirelessNetworkInterface( this, (const char*) str ); |
104 | odebug << "ONetwork: interface '" << str << "' has Wireless Extensions" << oendl; | 110 | odebug << "ONetwork: interface '" << str << "' has Wireless Extensions" << oendl; |
105 | } | 111 | } |
106 | else | 112 | else |
107 | { | 113 | { |
108 | iface = new ONetworkInterface( this, (const char*) str ); | 114 | iface = new ONetworkInterface( this, (const char*) str ); |
109 | } | 115 | } |
110 | _interfaces.insert( str, iface ); | 116 | _interfaces.insert( str, iface ); |
111 | s.readLine(); | 117 | s.readLine(); |
112 | } | 118 | } |
113 | } | 119 | } |
114 | 120 | ||
@@ -1192,48 +1198,51 @@ QString OHostAPMonitoringInterface::name() const | |||
1192 | 1198 | ||
1193 | /*====================================================================================== | 1199 | /*====================================================================================== |
1194 | * OOrinocoNetworkInterface | 1200 | * OOrinocoNetworkInterface |
1195 | *======================================================================================*/ | 1201 | *======================================================================================*/ |
1196 | 1202 | ||
1197 | OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) | 1203 | OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) |
1198 | :OMonitoringInterface( iface, prismHeader ) | 1204 | :OMonitoringInterface( iface, prismHeader ) |
1199 | { | 1205 | { |
1200 | iface->setMonitoring( this ); | 1206 | iface->setMonitoring( this ); |
1201 | } | 1207 | } |
1202 | 1208 | ||
1203 | 1209 | ||
1204 | OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface() | 1210 | OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface() |
1205 | { | 1211 | { |
1206 | } | 1212 | } |
1207 | 1213 | ||
1208 | 1214 | ||
1209 | void OOrinocoMonitoringInterface::setChannel( int c ) | 1215 | void OOrinocoMonitoringInterface::setChannel( int c ) |
1210 | { | 1216 | { |
1211 | if ( !_if->hasPrivate( "monitor" ) ) | 1217 | if ( !_if->hasPrivate( "monitor" ) ) |
1212 | { | 1218 | { |
1213 | this->OMonitoringInterface::setChannel( c ); | 1219 | this->OMonitoringInterface::setChannel( c ); |
1214 | } | 1220 | } |
1215 | else | 1221 | else |
1216 | { | 1222 | { |
1217 | int monitorCode = _prismHeader ? 1 : 2; | 1223 | int monitorCode = _prismHeader ? 1 : 2; |
1218 | _if->setPrivate( "monitor", 2, monitorCode, c ); | 1224 | _if->setPrivate( "monitor", 2, monitorCode, c ); |
1219 | } | 1225 | } |
1220 | } | 1226 | } |
1221 | 1227 | ||
1222 | 1228 | ||
1223 | void OOrinocoMonitoringInterface::setEnabled( bool b ) | 1229 | void OOrinocoMonitoringInterface::setEnabled( bool b ) |
1224 | { | 1230 | { |
1225 | if ( b ) | 1231 | if ( b ) |
1226 | { | 1232 | { |
1227 | setChannel( 1 ); | 1233 | setChannel( 1 ); |
1228 | } | 1234 | } |
1229 | else | 1235 | else |
1230 | { | 1236 | { |
1231 | _if->setPrivate( "monitor", 2, 0, 0 ); | 1237 | _if->setPrivate( "monitor", 2, 0, 0 ); |
1232 | } | 1238 | } |
1233 | } | 1239 | } |
1234 | 1240 | ||
1235 | 1241 | ||
1236 | QString OOrinocoMonitoringInterface::name() const | 1242 | QString OOrinocoMonitoringInterface::name() const |
1237 | { | 1243 | { |
1238 | return "orinoco"; | 1244 | return "orinoco"; |
1239 | } | 1245 | } |
1246 | |||
1247 | } | ||
1248 | } | ||