-rw-r--r-- | libopie2/opienet/onetwork.h | 1 | ||||
-rw-r--r-- | noncore/settings/networksettings/wlan/wextensions.h | 2 |
2 files changed, 3 insertions, 0 deletions
diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h index b13c7a3..370ad59 100644 --- a/libopie2/opienet/onetwork.h +++ b/libopie2/opienet/onetwork.h | |||
@@ -1,239 +1,240 @@ | |||
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 | .=l. | 4 | .=l. |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This program is free software; you can | 6 | _;:, .> :=|. This program is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; version 2 of the License. | 10 | - . .-<_> .<> Foundation; version 2 of the License. |
11 | ._= =} : | 11 | ._= =} : |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This program is distributed in the hope that | 13 | .i_,=:_. -<s. This program is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
18 | ..}^=.= = ; Library General Public License for more | 18 | ..}^=.= = ; Library General Public License for more |
19 | ++= -. .` .: details. | 19 | ++= -. .` .: details. |
20 | : = ...= . :.=- | 20 | : = ...= . :.=- |
21 | -. .:....=;==+<; You should have received a copy of the GNU | 21 | -. .:....=;==+<; You should have received a copy of the GNU |
22 | -_. . . )=. = Library General Public License along with | 22 | -_. . . )=. = Library General Public License along with |
23 | -- :-=` this library; see the file COPYING.LIB. | 23 | -- :-=` this library; see the file COPYING.LIB. |
24 | If not, write to the Free Software Foundation, | 24 | If not, write to the Free Software Foundation, |
25 | Inc., 59 Temple Place - Suite 330, | 25 | Inc., 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #ifndef ONETWORK_H | 30 | #ifndef ONETWORK_H |
31 | #define ONETWORK_H | 31 | #define ONETWORK_H |
32 | 32 | ||
33 | /* OPIE */ | 33 | /* OPIE */ |
34 | #include <opie2/onetutils.h> | 34 | #include <opie2/onetutils.h> |
35 | #include <opie2/ostation.h> | 35 | #include <opie2/ostation.h> |
36 | 36 | ||
37 | /* QT */ | 37 | /* QT */ |
38 | #include <qvaluelist.h> | 38 | #include <qvaluelist.h> |
39 | #include <qdict.h> | 39 | #include <qdict.h> |
40 | #include <qmap.h> | 40 | #include <qmap.h> |
41 | #include <qobject.h> | 41 | #include <qobject.h> |
42 | #include <qhostaddress.h> | 42 | #include <qhostaddress.h> |
43 | 43 | ||
44 | /* STD */ | 44 | /* STD */ |
45 | // hacky workarounds until we have a true user space wireless.h | 45 | // hacky workarounds until we have a true user space wireless.h |
46 | #include <net/if.h> | 46 | #include <net/if.h> |
47 | #define _LINUX_IF_H | 47 | #define _LINUX_IF_H |
48 | #include <linux/types.h> | ||
48 | #include <linux/wireless.h> | 49 | #include <linux/wireless.h> |
49 | #ifndef IW_MAX_PRIV_DEF | 50 | #ifndef IW_MAX_PRIV_DEF |
50 | #define IW_MAX_PRIV_DEF 128 | 51 | #define IW_MAX_PRIV_DEF 128 |
51 | #endif | 52 | #endif |
52 | 53 | ||
53 | namespace Opie { | 54 | namespace Opie { |
54 | namespace Net { | 55 | namespace Net { |
55 | class ONetworkInterface; | 56 | class ONetworkInterface; |
56 | class OWirelessNetworkInterface; | 57 | class OWirelessNetworkInterface; |
57 | class OChannelHopper; | 58 | class OChannelHopper; |
58 | class OMonitoringInterface; | 59 | class OMonitoringInterface; |
59 | 60 | ||
60 | /*====================================================================================== | 61 | /*====================================================================================== |
61 | * ONetwork | 62 | * ONetwork |
62 | *======================================================================================*/ | 63 | *======================================================================================*/ |
63 | 64 | ||
64 | /** | 65 | /** |
65 | * @brief A container class for all network interfaces | 66 | * @brief A container class for all network interfaces |
66 | * | 67 | * |
67 | * 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. |
68 | * | 69 | * |
69 | * @author Michael 'Mickey' Lauer <mickey@vanille.de> | 70 | * @author Michael 'Mickey' Lauer <mickey@vanille.de> |
70 | */ | 71 | */ |
71 | class ONetwork : public QObject | 72 | class ONetwork : public QObject |
72 | { | 73 | { |
73 | Q_OBJECT | 74 | Q_OBJECT |
74 | 75 | ||
75 | public: | 76 | public: |
76 | typedef QDict<ONetworkInterface> InterfaceMap; | 77 | typedef QDict<ONetworkInterface> InterfaceMap; |
77 | typedef QDictIterator<ONetworkInterface> InterfaceIterator; | 78 | typedef QDictIterator<ONetworkInterface> InterfaceIterator; |
78 | 79 | ||
79 | public: | 80 | public: |
80 | /** | 81 | /** |
81 | * @returns the number of available interfaces | 82 | * @returns the number of available interfaces |
82 | */ | 83 | */ |
83 | int count() const; | 84 | int count() const; |
84 | /** | 85 | /** |
85 | * @returns a pointer to the (one and only) @ref ONetwork instance. | 86 | * @returns a pointer to the (one and only) @ref ONetwork instance. |
86 | */ | 87 | */ |
87 | static ONetwork* instance(); | 88 | static ONetwork* instance(); |
88 | /** | 89 | /** |
89 | * @returns an iterator usable for iterating through all network interfaces. | 90 | * @returns an iterator usable for iterating through all network interfaces. |
90 | */ | 91 | */ |
91 | InterfaceIterator iterator() const; | 92 | InterfaceIterator iterator() const; |
92 | /** | 93 | /** |
93 | * @returns true, if the @a interface is present. | 94 | * @returns true, if the @a interface is present. |
94 | */ | 95 | */ |
95 | bool isPresent( const char* interface ) const; | 96 | bool isPresent( const char* interface ) const; |
96 | /** | 97 | /** |
97 | * @returns true, if the @a interface supports the wireless extension protocol. | 98 | * @returns true, if the @a interface supports the wireless extension protocol. |
98 | */ | 99 | */ |
99 | bool isWirelessInterface( const char* interface ) const; | 100 | bool isWirelessInterface( const char* interface ) const; |
100 | /** | 101 | /** |
101 | * @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. |
102 | * @see ONetworkInterface | 103 | * @see ONetworkInterface |
103 | */ | 104 | */ |
104 | ONetworkInterface* interface( const QString& interface ) const; | 105 | ONetworkInterface* interface( const QString& interface ) const; |
105 | /** | 106 | /** |
106 | * @internal Rebuild the internal interface database | 107 | * @internal Rebuild the internal interface database |
107 | * @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, |
108 | * e.g. after issuing a cardctl insert | 109 | * e.g. after issuing a cardctl insert |
109 | */ | 110 | */ |
110 | void synchronize(); | 111 | void synchronize(); |
111 | /** | 112 | /** |
112 | * @returns the wireless extension version used at compile time. | 113 | * @returns the wireless extension version used at compile time. |
113 | **/ | 114 | **/ |
114 | static short wirelessExtensionCompileVersion(); | 115 | static short wirelessExtensionCompileVersion(); |
115 | 116 | ||
116 | protected: | 117 | protected: |
117 | ONetwork(); | 118 | ONetwork(); |
118 | 119 | ||
119 | private: | 120 | private: |
120 | static ONetwork* _instance; | 121 | static ONetwork* _instance; |
121 | InterfaceMap _interfaces; | 122 | InterfaceMap _interfaces; |
122 | class Private; | 123 | class Private; |
123 | Private *d; | 124 | Private *d; |
124 | }; | 125 | }; |
125 | 126 | ||
126 | 127 | ||
127 | /*====================================================================================== | 128 | /*====================================================================================== |
128 | * ONetworkInterface | 129 | * ONetworkInterface |
129 | *======================================================================================*/ | 130 | *======================================================================================*/ |
130 | 131 | ||
131 | /** | 132 | /** |
132 | * @brief A network interface wrapper. | 133 | * @brief A network interface wrapper. |
133 | * | 134 | * |
134 | * 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 |
135 | * Linux ioctls are hidden under a convenient high-level interface. | 136 | * Linux ioctls are hidden under a convenient high-level interface. |
136 | * @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 |
137 | * process permissions to work. | 138 | * process permissions to work. |
138 | * | 139 | * |
139 | * @author Michael 'Mickey' Lauer <mickey@vanille.de> | 140 | * @author Michael 'Mickey' Lauer <mickey@vanille.de> |
140 | */ | 141 | */ |
141 | class ONetworkInterface : public QObject | 142 | class ONetworkInterface : public QObject |
142 | { | 143 | { |
143 | friend class OMonitoringInterface; | 144 | friend class OMonitoringInterface; |
144 | friend class OCiscoMonitoringInterface; | 145 | friend class OCiscoMonitoringInterface; |
145 | friend class OWlanNGMonitoringInterface; | 146 | friend class OWlanNGMonitoringInterface; |
146 | friend class OHostAPMonitoringInterface; | 147 | friend class OHostAPMonitoringInterface; |
147 | friend class OOrinocoMonitoringInterface; | 148 | friend class OOrinocoMonitoringInterface; |
148 | 149 | ||
149 | public: | 150 | public: |
150 | /** | 151 | /** |
151 | * Constructor. Normally you don't create @ref ONetworkInterface objects yourself, | 152 | * Constructor. Normally you don't create @ref ONetworkInterface objects yourself, |
152 | * but access them via @ref ONetwork::interface(). | 153 | * but access them via @ref ONetwork::interface(). |
153 | */ | 154 | */ |
154 | ONetworkInterface( QObject* parent, const char* name ); | 155 | ONetworkInterface( QObject* parent, const char* name ); |
155 | /** | 156 | /** |
156 | * Destructor. | 157 | * Destructor. |
157 | */ | 158 | */ |
158 | virtual ~ONetworkInterface(); | 159 | virtual ~ONetworkInterface(); |
159 | /** | 160 | /** |
160 | * Associates a @a monitoring interface with this network interface. | 161 | * Associates a @a monitoring interface with this network interface. |
161 | * @note This is currently only useful with @ref OWirelessNetworkInterface objects. | 162 | * @note This is currently only useful with @ref OWirelessNetworkInterface objects. |
162 | */ | 163 | */ |
163 | void setMonitoring( OMonitoringInterface* monitoring ); | 164 | void setMonitoring( OMonitoringInterface* monitoring ); |
164 | /** | 165 | /** |
165 | * @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. |
166 | */ | 167 | */ |
167 | OMonitoringInterface* monitoring() const; | 168 | OMonitoringInterface* monitoring() const; |
168 | /** | 169 | /** |
169 | * Setting an interface to promiscuous mode enables the device to receive | 170 | * Setting an interface to promiscuous mode enables the device to receive |
170 | * 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. |
171 | */ | 172 | */ |
172 | bool setPromiscuousMode( bool ); | 173 | bool setPromiscuousMode( bool ); |
173 | /** | 174 | /** |
174 | * @returns true if the interface is set to promiscuous mode. | 175 | * @returns true if the interface is set to promiscuous mode. |
175 | */ | 176 | */ |
176 | bool promiscuousMode() const; | 177 | bool promiscuousMode() const; |
177 | /** | 178 | /** |
178 | * Setting an interface to up enables it to receive packets. | 179 | * Setting an interface to up enables it to receive packets. |
179 | */ | 180 | */ |
180 | bool setUp( bool ); | 181 | bool setUp( bool ); |
181 | /** | 182 | /** |
182 | * @returns true if the interface is up. | 183 | * @returns true if the interface is up. |
183 | */ | 184 | */ |
184 | bool isUp() const; | 185 | bool isUp() const; |
185 | /** | 186 | /** |
186 | * @returns true if the interface is a loopback interface. | 187 | * @returns true if the interface is a loopback interface. |
187 | */ | 188 | */ |
188 | bool isLoopback() const; | 189 | bool isLoopback() const; |
189 | /** | 190 | /** |
190 | * @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. |
191 | */ | 192 | */ |
192 | bool isWireless() const; | 193 | bool isWireless() const; |
193 | /** | 194 | /** |
194 | * Associate the IP address @ addr with the interface. | 195 | * Associate the IP address @ addr with the interface. |
195 | */ | 196 | */ |
196 | void setIPV4Address( const QHostAddress& addr ); | 197 | void setIPV4Address( const QHostAddress& addr ); |
197 | /** | 198 | /** |
198 | * @returns the IPv4 address associated with the interface. | 199 | * @returns the IPv4 address associated with the interface. |
199 | */ | 200 | */ |
200 | OHostAddress ipV4Address() const; | 201 | OHostAddress ipV4Address() const; |
201 | /** | 202 | /** |
202 | * Associate the MAC address @a addr with the interface. | 203 | * Associate the MAC address @a addr with the interface. |
203 | * @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. |
204 | * @note This operation needs root privileges | 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 | OHostAddress ipV4Netmask() const; | 220 | OHostAddress ipV4Netmask() const; |
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; |
225 | /** | 226 | /** |
226 | * @returns a ONetworkInterfaceDriverInfo driver information block | 227 | * @returns a ONetworkInterfaceDriverInfo driver information block |
227 | * @note This operation needs root privileges | 228 | * @note This operation needs root privileges |
228 | * @warning This is not supported by all drivers | 229 | * @warning This is not supported by all drivers |
229 | */ | 230 | */ |
230 | ONetworkInterfaceDriverInfo driverInfo() const; | 231 | ONetworkInterfaceDriverInfo driverInfo() const; |
231 | 232 | ||
232 | protected: | 233 | protected: |
233 | const int _sfd; | 234 | const int _sfd; |
234 | mutable ifreq _ifr; | 235 | mutable ifreq _ifr; |
235 | OMonitoringInterface* _mon; | 236 | OMonitoringInterface* _mon; |
236 | 237 | ||
237 | protected: | 238 | protected: |
238 | struct ifreq& ifr() const; | 239 | struct ifreq& ifr() const; |
239 | virtual void init(); | 240 | virtual void init(); |
diff --git a/noncore/settings/networksettings/wlan/wextensions.h b/noncore/settings/networksettings/wlan/wextensions.h index a89e33a..aceb672 100644 --- a/noncore/settings/networksettings/wlan/wextensions.h +++ b/noncore/settings/networksettings/wlan/wextensions.h | |||
@@ -1,34 +1,36 @@ | |||
1 | #ifndef WEXTENSIONS_H | 1 | #ifndef WEXTENSIONS_H |
2 | #define WEXTENSIONS_H | 2 | #define WEXTENSIONS_H |
3 | 3 | ||
4 | #include <qstring.h> | 4 | #include <qstring.h> |
5 | 5 | ||
6 | #include <net/if.h> | ||
6 | #include <netinet/ip.h> | 7 | #include <netinet/ip.h> |
8 | #include <linux/types.h> | ||
7 | #include <linux/wireless.h> | 9 | #include <linux/wireless.h> |
8 | 10 | ||
9 | class WExtensions { | 11 | class WExtensions { |
10 | 12 | ||
11 | public: | 13 | public: |
12 | WExtensions(QString interfaceName); | 14 | WExtensions(QString interfaceName); |
13 | QString getInterfaceName(){return interface;}; | 15 | QString getInterfaceName(){return interface;}; |
14 | bool doesHaveWirelessExtensions(){return hasWirelessExtensions;}; | 16 | bool doesHaveWirelessExtensions(){return hasWirelessExtensions;}; |
15 | QString station(); | 17 | QString station(); |
16 | QString essid(); | 18 | QString essid(); |
17 | QString mode(); | 19 | QString mode(); |
18 | double frequency(); | 20 | double frequency(); |
19 | int channel(); | 21 | int channel(); |
20 | double rate(); | 22 | double rate(); |
21 | QString ap(); | 23 | QString ap(); |
22 | bool stats( int &signal, int &noise, int &quality); | 24 | bool stats( int &signal, int &noise, int &quality); |
23 | 25 | ||
24 | private: | 26 | private: |
25 | bool hasWirelessExtensions; | 27 | bool hasWirelessExtensions; |
26 | QString interface; | 28 | QString interface; |
27 | 29 | ||
28 | // Used in we calls | 30 | // Used in we calls |
29 | struct iwreq iwr; | 31 | struct iwreq iwr; |
30 | int fd; | 32 | int fd; |
31 | 33 | ||
32 | }; | 34 | }; |
33 | 35 | ||
34 | #endif | 36 | #endif |