summaryrefslogtreecommitdiff
authorschurig <schurig>2003-06-04 11:53:19 (UTC)
committer schurig <schurig>2003-06-04 11:53:19 (UTC)
commite23848abe917d689ee9d8f7b78ff5e5047a3ed43 (patch) (unidiff)
treec23bf1cbb116ad2f8e523746867cf0494aa4af89
parentdf76591a8ee920c6549bc55b026ab66926917667 (diff)
downloadopie-e23848abe917d689ee9d8f7b78ff5e5047a3ed43.zip
opie-e23848abe917d689ee9d8f7b78ff5e5047a3ed43.tar.gz
opie-e23848abe917d689ee9d8f7b78ff5e5047a3ed43.tar.bz2
enable compilation
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opienet/onetwork.h15
1 files changed, 8 insertions, 7 deletions
diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h
index eb9d506..cfb999d 100644
--- a/libopie2/opienet/onetwork.h
+++ b/libopie2/opienet/onetwork.h
@@ -1,318 +1,319 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2003 by the Wellenreiter team: 3              Copyright (C) 2003 by the Wellenreiter team:
4 Martin J. Muench <mjm@remote-exploit.org> 4 Martin J. Muench <mjm@remote-exploit.org>
5 Max Moser <mmo@remote-exploit.org 5 Max Moser <mmo@remote-exploit.org
6 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 6 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#ifndef ONETWORK_H 34#ifndef ONETWORK_H
35#define ONETWORK_H 35#define ONETWORK_H
36 36
37/* OPIE */ 37/* OPIE */
38 38
39#include <opie2/onetutils.h> 39#include <opie2/onetutils.h>
40 40
41/* QT */ 41/* QT */
42 42
43#include <qvaluelist.h> 43#include <qvaluelist.h>
44#include <qdict.h> 44#include <qdict.h>
45#include <qmap.h> 45#include <qmap.h>
46#include <qobject.h> 46#include <qobject.h>
47#include <qhostaddress.h> 47#include <qhostaddress.h>
48 48
49#ifndef IFNAMSIZ
50#define IFNAMSIZ 16
51#endif
52#ifndef IW_MAX_PRIV_DEF
53#define IW_MAX_PRIV_DEF 128
54#endif
55
56// ML: Yeah, I hate to include kernel headers, but it's necessary here 49// ML: Yeah, I hate to include kernel headers, but it's necessary here
57// ML: Here comes an ugly hack to prevent <linux/wireless.h> including <linux/if.h> 50// ML: Here comes an ugly hack to prevent <linux/wireless.h> including <linux/if.h>
58// ML: which conflicts with the user header <net/if.h> 51// ML: which conflicts with the user header <net/if.h>
59// ML: We really need a user header for the Wireless Extensions, something like <net/wireless.h> 52// ML: We really need a user header for the Wireless Extensions, something like <net/wireless.h>
60// ML: I will drop Jean a mail on that subject 53// ML: I will drop Jean a mail on that subject
61 54
62#include <net/if.h> 55#include <net/if.h>
56
57#ifndef IFNAMSIZ
58#define IFNAMSIZ 16
59#endif
60#ifndef IW_MAX_PRIV_DEF
61#define IW_MAX_PRIV_DEF 128
62#endif
63
63#define _LINUX_IF_H 64#define _LINUX_IF_H
64#include <linux/wireless.h> 65#include <linux/wireless.h>
65 66
66class ONetworkInterface; 67class ONetworkInterface;
67class OWirelessNetworkInterface; 68class OWirelessNetworkInterface;
68class OChannelHopper; 69class OChannelHopper;
69class OMonitoringInterface; 70class OMonitoringInterface;
70 71
71/*====================================================================================== 72/*======================================================================================
72 * ONetwork 73 * ONetwork
73 *======================================================================================*/ 74 *======================================================================================*/
74 75
75/** 76/**
76 * @brief A container class for all network interfaces 77 * @brief A container class for all network interfaces
77 * 78 *
78 * This class provides access to all available network interfaces of your computer. 79 * This class provides access to all available network interfaces of your computer.
79 * 80 *
80 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 81 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
81 */ 82 */
82class ONetwork : public QObject 83class ONetwork : public QObject
83{ 84{
84 Q_OBJECT 85 Q_OBJECT
85 86
86 public: 87 public:
87 typedef QDict<ONetworkInterface> InterfaceMap; 88 typedef QDict<ONetworkInterface> InterfaceMap;
88 typedef QDictIterator<ONetworkInterface> InterfaceIterator; 89 typedef QDictIterator<ONetworkInterface> InterfaceIterator;
89 90
90 public: 91 public:
91 /** 92 /**
92 * @returns the number of available interfaces 93 * @returns the number of available interfaces
93 */ 94 */
94 int count() const; 95 int count() const;
95 /** 96 /**
96 * @returns a pointer to the (one and only) @ref ONetwork instance. 97 * @returns a pointer to the (one and only) @ref ONetwork instance.
97 */ 98 */
98 static ONetwork* instance(); 99 static ONetwork* instance();
99 /** 100 /**
100 * @returns an iterator usable for iterating through all network interfaces. 101 * @returns an iterator usable for iterating through all network interfaces.
101 */ 102 */
102 InterfaceIterator iterator() const; 103 InterfaceIterator iterator() const;
103 /** 104 /**
104 * @returns true, if the @a interface supports the wireless extension protocol. 105 * @returns true, if the @a interface supports the wireless extension protocol.
105 */ 106 */
106 // FIXME QString? -zecke 107 // FIXME QString? -zecke
107 bool isWirelessInterface( const char* interface ) const; 108 bool isWirelessInterface( const char* interface ) const;
108 /** 109 /**
109 * @returns a pointer to the @ref ONetworkInterface object for the specified @a interface or 0, if not found 110 * @returns a pointer to the @ref ONetworkInterface object for the specified @a interface or 0, if not found
110 * @see ONetworkInterface 111 * @see ONetworkInterface
111 */ 112 */
112 // FIXME: const QString& is prefered over QString!!! -zecke 113 // FIXME: const QString& is prefered over QString!!! -zecke
113 ONetworkInterface* interface( const QString& interface ) const; 114 ONetworkInterface* interface( const QString& interface ) const;
114 /** 115 /**
115 * @internal Rebuild the internal interface database 116 * @internal Rebuild the internal interface database
116 * @note Sometimes it might be useful to call this from client code, 117 * @note Sometimes it might be useful to call this from client code,
117 * e.g. after issuing a cardctl insert 118 * e.g. after issuing a cardctl insert
118 */ 119 */
119 void synchronize(); 120 void synchronize();
120 121
121 protected: 122 protected:
122 ONetwork(); 123 ONetwork();
123 124
124 private: 125 private:
125 static ONetwork* _instance; 126 static ONetwork* _instance;
126 InterfaceMap _interfaces; 127 InterfaceMap _interfaces;
127}; 128};
128 129
129 130
130/*====================================================================================== 131/*======================================================================================
131 * ONetworkInterface 132 * ONetworkInterface
132 *======================================================================================*/ 133 *======================================================================================*/
133 134
134/** 135/**
135 * @brief A network interface wrapper. 136 * @brief A network interface wrapper.
136 * 137 *
137 * This class provides a wrapper for a network interface. All the cumbersume details of 138 * This class provides a wrapper for a network interface. All the cumbersume details of
138 * Linux ioctls are hidden under a convenient high-level interface. 139 * Linux ioctls are hidden under a convenient high-level interface.
139 * @warning Most of the setting methods contained in this class require the appropriate 140 * @warning Most of the setting methods contained in this class require the appropriate
140 * process permissions to work. 141 * process permissions to work.
141 * 142 *
142 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 143 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
143 */ 144 */
144class ONetworkInterface : public QObject 145class ONetworkInterface : public QObject
145{ 146{
146 friend class OMonitoringInterface; 147 friend class OMonitoringInterface;
147 friend class OCiscoMonitoringInterface; 148 friend class OCiscoMonitoringInterface;
148 friend class OWlanNGMonitoringInterface; 149 friend class OWlanNGMonitoringInterface;
149 friend class OHostAPMonitoringInterface; 150 friend class OHostAPMonitoringInterface;
150 friend class OOrinocoMonitoringInterface; 151 friend class OOrinocoMonitoringInterface;
151 152
152 public: 153 public:
153 /** 154 /**
154 * Constructor. Normally you don't create @ref ONetworkInterface objects yourself, 155 * Constructor. Normally you don't create @ref ONetworkInterface objects yourself,
155 * but access them via @ref ONetwork::interface(). 156 * but access them via @ref ONetwork::interface().
156 */ 157 */
157 ONetworkInterface( QObject* parent, const char* name ); 158 ONetworkInterface( QObject* parent, const char* name );
158 /** 159 /**
159 * Destructor. 160 * Destructor.
160 */ 161 */
161 virtual ~ONetworkInterface(); 162 virtual ~ONetworkInterface();
162 /** 163 /**
163 * Associates a @a monitoring interface with this network interface. 164 * Associates a @a monitoring interface with this network interface.
164 * @note This is currently only useful with @ref OWirelessNetworkInterface objects. 165 * @note This is currently only useful with @ref OWirelessNetworkInterface objects.
165 */ 166 */
166 void setMonitoring( OMonitoringInterface* monitoring ); 167 void setMonitoring( OMonitoringInterface* monitoring );
167 /** 168 /**
168 * @returns the currently associated monitoring interface or 0, if no monitoring is associated. 169 * @returns the currently associated monitoring interface or 0, if no monitoring is associated.
169 */ 170 */
170 OMonitoringInterface* monitoring() const; 171 OMonitoringInterface* monitoring() const;
171 /** 172 /**
172 * Setting an interface to promiscuous mode enables the device to receive 173 * Setting an interface to promiscuous mode enables the device to receive
173 * all packets on the shared medium - as opposed to packets which are addressed to this interface. 174 * all packets on the shared medium - as opposed to packets which are addressed to this interface.
174 */ 175 */
175 bool setPromiscuousMode( bool ); 176 bool setPromiscuousMode( bool );
176 /** 177 /**
177 * @returns true if the interface is set to promiscuous mode. 178 * @returns true if the interface is set to promiscuous mode.
178 */ 179 */
179 bool promiscuousMode() const; 180 bool promiscuousMode() const;
180 /** 181 /**
181 * Setting an interface to up enables it to receive packets. 182 * Setting an interface to up enables it to receive packets.
182 */ 183 */
183 bool setUp( bool ); 184 bool setUp( bool );
184 /** 185 /**
185 * @returns true if the interface is up. 186 * @returns true if the interface is up.
186 */ 187 */
187 bool isUp() const; 188 bool isUp() const;
188 /** 189 /**
189 * @returns true if the interface is a loopback interface. 190 * @returns true if the interface is a loopback interface.
190 */ 191 */
191 bool isLoopback() const; 192 bool isLoopback() const;
192 /** 193 /**
193 * @returns true if the interface is featuring supports the wireless extension protocol. 194 * @returns true if the interface is featuring supports the wireless extension protocol.
194 */ 195 */
195 bool isWireless() const; 196 bool isWireless() const;
196 /** 197 /**
197 * Associate the IP address @ addr with the interface. 198 * Associate the IP address @ addr with the interface.
198 */ 199 */
199 void setIPV4Address( const QHostAddress& addr ); 200 void setIPV4Address( const QHostAddress& addr );
200 /** 201 /**
201 * @returns the IPv4 address associated with the interface. 202 * @returns the IPv4 address associated with the interface.
202 */ 203 */
203 QString ipV4Address() const; //TODO: make this return an OHostAddress 204 QString ipV4Address() const; //TODO: make this return an OHostAddress
204 /** 205 /**
205 * Associate the MAC address @a addr with the interface. 206 * Associate the MAC address @a addr with the interface.
206 * @note It can be necessary to shut down the interface prior to calling this method. 207 * @note It can be necessary to shut down the interface prior to calling this method.
207 * @warning This is not supported by all drivers. 208 * @warning This is not supported by all drivers.
208 */ 209 */
209 void setMacAddress( const OMacAddress& addr ); 210 void setMacAddress( const OMacAddress& addr );
210 /** 211 /**
211 * @returns the MAC address associated with the interface. 212 * @returns the MAC address associated with the interface.
212 */ 213 */
213 OMacAddress macAddress() const; 214 OMacAddress macAddress() const;
214 /** 215 /**
215 * Associate the IPv4 @a netmask with the interface. 216 * Associate the IPv4 @a netmask with the interface.
216 */ 217 */
217 void setIPV4Netmask( const QHostAddress& netmask ); 218 void setIPV4Netmask( const QHostAddress& netmask );
218 /** 219 /**
219 * @returns the IPv4 netmask associated with the interface. 220 * @returns the IPv4 netmask associated with the interface.
220 */ 221 */
221 QString ipV4Netmask() const; //TODO: make this return an OHostAddress 222 QString ipV4Netmask() const; //TODO: make this return an OHostAddress
222 /** 223 /**
223 * @returns the data link type currently associated with the interface. 224 * @returns the data link type currently associated with the interface.
224 * @see #include <net/if_arp.h> for possible values. 225 * @see #include <net/if_arp.h> for possible values.
225 */ 226 */
226 int dataLinkType() const; 227 int dataLinkType() const;
227 228
228 protected: 229 protected:
229 const int _sfd; 230 const int _sfd;
230 mutable ifreq _ifr; 231 mutable ifreq _ifr;
231 OMonitoringInterface* _mon; 232 OMonitoringInterface* _mon;
232 233
233 protected: 234 protected:
234 struct ifreq& ifr() const; 235 struct ifreq& ifr() const;
235 virtual void init(); 236 virtual void init();
236 bool ioctl( int call ) const; 237 bool ioctl( int call ) const;
237 bool ioctl( int call, struct ifreq& ) const; 238 bool ioctl( int call, struct ifreq& ) const;
238}; 239};
239 240
240/*====================================================================================== 241/*======================================================================================
241 * OChannelHopper 242 * OChannelHopper
242 *======================================================================================*/ 243 *======================================================================================*/
243 244
244/** 245/**
245 * @brief A radio frequency channel hopper. 246 * @brief A radio frequency channel hopper.
246 * 247 *
247 * This class provides a channel hopper for radio frequencies. A channel hopper frequently 248 * This class provides a channel hopper for radio frequencies. A channel hopper frequently
248 * changes the radio frequency channel of its associated @ref OWirelessNetworkInterface. 249 * changes the radio frequency channel of its associated @ref OWirelessNetworkInterface.
249 * This is necessary when in monitoring mode and scanning for other devices, because 250 * This is necessary when in monitoring mode and scanning for other devices, because
250 * the radio frequency hardware can only detect packets sent on the same frequency. 251 * the radio frequency hardware can only detect packets sent on the same frequency.
251 * 252 *
252 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 253 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
253 */ 254 */
254class OChannelHopper : public QObject 255class OChannelHopper : public QObject
255{ 256{
256 Q_OBJECT 257 Q_OBJECT
257 258
258 public: 259 public:
259 /** 260 /**
260 * Constructor. 261 * Constructor.
261 */ 262 */
262 OChannelHopper( OWirelessNetworkInterface* ); 263 OChannelHopper( OWirelessNetworkInterface* );
263 /** 264 /**
264 * Destructor. 265 * Destructor.
265 */ 266 */
266 virtual ~OChannelHopper(); 267 virtual ~OChannelHopper();
267 /** 268 /**
268 * @returns true, if the channel hopper is hopping channels 269 * @returns true, if the channel hopper is hopping channels
269 */ 270 */
270 bool isActive() const; 271 bool isActive() const;
271 /** 272 /**
272 * @returns the last hopped channel 273 * @returns the last hopped channel
273 */ 274 */
274 int channel() const; 275 int channel() const;
275 /** 276 /**
276 * Set the channel hopping @a interval. 277 * Set the channel hopping @a interval.
277 * An interval of 0 deactivates the channel hopper. 278 * An interval of 0 deactivates the channel hopper.
278 */ 279 */
279 void setInterval( int interval ); 280 void setInterval( int interval );
280 /** 281 /**
281 * @returns the channel hopping interval 282 * @returns the channel hopping interval
282 */ 283 */
283 int interval() const; 284 int interval() const;
284 285
285 signals: 286 signals:
286 /** 287 /**
287 * This signal is emitted right after the channel hopper performed a hop 288 * This signal is emitted right after the channel hopper performed a hop
288 */ 289 */
289 void hopped( int ); 290 void hopped( int );
290 291
291 protected: 292 protected:
292 virtual void timerEvent( QTimerEvent* ); 293 virtual void timerEvent( QTimerEvent* );
293 294
294 private: 295 private:
295 OWirelessNetworkInterface* _iface; 296 OWirelessNetworkInterface* _iface;
296 int _interval; 297 int _interval;
297 int _tid; 298 int _tid;
298 QValueList<int> _channels; 299 QValueList<int> _channels;
299 QValueList<int>::Iterator _channel; 300 QValueList<int>::Iterator _channel;
300}; 301};
301 302
302 303
303/*====================================================================================== 304/*======================================================================================
304 * OWirelessNetworkInterface 305 * OWirelessNetworkInterface
305 *======================================================================================*/ 306 *======================================================================================*/
306 307
307/** 308/**
308 * @brief A network interface wrapper for interfaces supporting the wireless extensions protocol. 309 * @brief A network interface wrapper for interfaces supporting the wireless extensions protocol.
309 * 310 *
310 * This class provides a high-level encapsulation of the Linux wireless extension API. 311 * This class provides a high-level encapsulation of the Linux wireless extension API.
311 * 312 *
312 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 313 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
313 */ 314 */
314class OWirelessNetworkInterface : public ONetworkInterface 315class OWirelessNetworkInterface : public ONetworkInterface
315{ 316{
316 friend class OMonitoringInterface; 317 friend class OMonitoringInterface;
317 friend class OCiscoMonitoringInterface; 318 friend class OCiscoMonitoringInterface;
318 friend class OWlanNGMonitoringInterface; 319 friend class OWlanNGMonitoringInterface;