-rw-r--r-- | libopie2/opienet/onetwork.h | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h index 4cadbeb..e249aee 100644 --- a/libopie2/opienet/onetwork.h +++ b/libopie2/opienet/onetwork.h | |||
@@ -42,52 +42,48 @@ | |||
42 | #include <qobject.h> | 42 | #include <qobject.h> |
43 | #include <qhostaddress.h> | 43 | #include <qhostaddress.h> |
44 | 44 | ||
45 | /* OPIE */ | 45 | /* OPIE */ |
46 | 46 | ||
47 | #include <opie2/onetutils.h> | 47 | #include <opie2/onetutils.h> |
48 | 48 | ||
49 | #ifndef IFNAMSIZ | 49 | #ifndef IFNAMSIZ |
50 | #define IFNAMSIZ 16 | 50 | #define IFNAMSIZ 16 |
51 | #endif | 51 | #endif |
52 | #ifndef IW_MAX_PRIV_DEF | 52 | #ifndef IW_MAX_PRIV_DEF |
53 | #define IW_MAX_PRIV_DEF 128 | 53 | #define IW_MAX_PRIV_DEF 128 |
54 | #endif | 54 | #endif |
55 | 55 | ||
56 | // ML: Yeah, I hate to include kernel headers, but it's necessary here | 56 | // ML: Yeah, I hate to include kernel headers, but it's necessary here |
57 | // ML: Here comes an ugly hack to prevent <linux/wireless.h> including <linux/if.h> | 57 | // ML: Here comes an ugly hack to prevent <linux/wireless.h> including <linux/if.h> |
58 | // ML: which conflicts with the user header <net/if.h> | 58 | // ML: which conflicts with the user header <net/if.h> |
59 | // ML: We really a user header for the Wireless Extensions, something like <net/wireless.h> | 59 | // ML: We really a user header for the Wireless Extensions, something like <net/wireless.h> |
60 | // ML: I will drop Jean an mail on that subject | 60 | // ML: I will drop Jean an mail on that subject |
61 | 61 | ||
62 | #include <net/if.h> | 62 | #include <net/if.h> |
63 | #define _LINUX_IF_H | 63 | #define _LINUX_IF_H |
64 | #include <linux/wireless.h> | 64 | #include <linux/wireless.h> |
65 | 65 | ||
66 | #ifndef SIOCIWFIRSTPRIV | ||
67 | #define SIOCIWFIRSTPRIV SIOCDEVPRIVATE | ||
68 | #endif | ||
69 | |||
70 | class ONetworkInterface; | 66 | class ONetworkInterface; |
71 | class OWirelessNetworkInterface; | 67 | class OWirelessNetworkInterface; |
72 | class OChannelHopper; | 68 | class OChannelHopper; |
73 | class OMonitoringInterface; | 69 | class OMonitoringInterface; |
74 | 70 | ||
75 | /*====================================================================================== | 71 | /*====================================================================================== |
76 | * ONetwork | 72 | * ONetwork |
77 | *======================================================================================*/ | 73 | *======================================================================================*/ |
78 | 74 | ||
79 | class ONetwork : public QObject | 75 | class ONetwork : public QObject |
80 | { | 76 | { |
81 | Q_OBJECT | 77 | Q_OBJECT |
82 | 78 | ||
83 | public: | 79 | public: |
84 | typedef QDict<ONetworkInterface> InterfaceMap; | 80 | typedef QDict<ONetworkInterface> InterfaceMap; |
85 | typedef QDictIterator<ONetworkInterface> InterfaceIterator; | 81 | typedef QDictIterator<ONetworkInterface> InterfaceIterator; |
86 | 82 | ||
87 | public: | 83 | public: |
88 | static ONetwork* instance(); | 84 | static ONetwork* instance(); |
89 | InterfaceIterator iterator() const; | 85 | InterfaceIterator iterator() const; |
90 | bool isWirelessInterface( const char* ) const; | 86 | bool isWirelessInterface( const char* ) const; |
91 | ONetworkInterface* interface( QString ) const; | 87 | ONetworkInterface* interface( QString ) const; |
92 | 88 | ||
93 | protected: | 89 | protected: |
@@ -104,48 +100,49 @@ class ONetwork : public QObject | |||
104 | * ONetworkInterface | 100 | * ONetworkInterface |
105 | *======================================================================================*/ | 101 | *======================================================================================*/ |
106 | 102 | ||
107 | class ONetworkInterface : public QObject | 103 | class ONetworkInterface : public QObject |
108 | { | 104 | { |
109 | friend class OMonitoringInterface; | 105 | friend class OMonitoringInterface; |
110 | friend class OCiscoMonitoringInterface; | 106 | friend class OCiscoMonitoringInterface; |
111 | friend class OWlanNGMonitoringInterface; | 107 | friend class OWlanNGMonitoringInterface; |
112 | friend class OHostAPMonitoringInterface; | 108 | friend class OHostAPMonitoringInterface; |
113 | friend class OOrinocoMonitoringInterface; | 109 | friend class OOrinocoMonitoringInterface; |
114 | 110 | ||
115 | public: | 111 | public: |
116 | ONetworkInterface( QObject* parent, const char* name ); | 112 | ONetworkInterface( QObject* parent, const char* name ); |
117 | virtual ~ONetworkInterface(); | 113 | virtual ~ONetworkInterface(); |
118 | 114 | ||
119 | void setMonitoring( OMonitoringInterface* ); | 115 | void setMonitoring( OMonitoringInterface* ); |
120 | OMonitoringInterface* monitoring() const; | 116 | OMonitoringInterface* monitoring() const; |
121 | bool setPromiscuousMode( bool ); | 117 | bool setPromiscuousMode( bool ); |
122 | bool promiscuousMode() const; | 118 | bool promiscuousMode() const; |
123 | bool setUp( bool ); | 119 | bool setUp( bool ); |
124 | bool isUp() const; | 120 | bool isUp() const; |
125 | bool isLoopback() const; | 121 | bool isLoopback() const; |
126 | bool isWireless() const; | 122 | bool isWireless() const; |
127 | QString ipV4Address() const; | 123 | QString ipV4Address() const; |
124 | void setMacAddress( const OMacAddress& ); | ||
128 | OMacAddress macAddress() const; | 125 | OMacAddress macAddress() const; |
129 | int dataLinkType() const; | 126 | int dataLinkType() const; |
130 | 127 | ||
131 | protected: | 128 | protected: |
132 | const int _sfd; | 129 | const int _sfd; |
133 | mutable ifreq _ifr; | 130 | mutable ifreq _ifr; |
134 | OMonitoringInterface* _mon; | 131 | OMonitoringInterface* _mon; |
135 | 132 | ||
136 | protected: | 133 | protected: |
137 | struct ifreq& ifr() const; | 134 | struct ifreq& ifr() const; |
138 | virtual void init(); | 135 | virtual void init(); |
139 | bool ioctl( int call ) const; | 136 | bool ioctl( int call ) const; |
140 | bool ioctl( int call, struct ifreq& ) const; | 137 | bool ioctl( int call, struct ifreq& ) const; |
141 | }; | 138 | }; |
142 | 139 | ||
143 | /*====================================================================================== | 140 | /*====================================================================================== |
144 | * OChannelHopper | 141 | * OChannelHopper |
145 | *======================================================================================*/ | 142 | *======================================================================================*/ |
146 | 143 | ||
147 | class OChannelHopper : public QObject | 144 | class OChannelHopper : public QObject |
148 | { | 145 | { |
149 | public: | 146 | public: |
150 | OChannelHopper( OWirelessNetworkInterface* ); | 147 | OChannelHopper( OWirelessNetworkInterface* ); |
151 | virtual ~OChannelHopper(); | 148 | virtual ~OChannelHopper(); |
@@ -183,94 +180,95 @@ class OWirelessNetworkInterface : public ONetworkInterface | |||
183 | enum Mode { AdHoc, Managed, Monitor }; | 180 | enum Mode { AdHoc, Managed, Monitor }; |
184 | 181 | ||
185 | OWirelessNetworkInterface( QObject* parent, const char* name ); | 182 | OWirelessNetworkInterface( QObject* parent, const char* name ); |
186 | virtual ~OWirelessNetworkInterface(); | 183 | virtual ~OWirelessNetworkInterface(); |
187 | 184 | ||
188 | virtual void setChannel( int ) const; | 185 | virtual void setChannel( int ) const; |
189 | virtual int channel() const; | 186 | virtual int channel() const; |
190 | virtual double frequency() const; | 187 | virtual double frequency() const; |
191 | virtual int channels() const; | 188 | virtual int channels() const; |
192 | //virtual double frequency(int) const; | 189 | //virtual double frequency(int) const; |
193 | 190 | ||
194 | virtual void setMode( Mode ) {}; | 191 | virtual void setMode( Mode ) {}; |
195 | virtual bool mode() const {}; | 192 | virtual bool mode() const {}; |
196 | 193 | ||
197 | virtual void setMonitorMode( bool ); | 194 | virtual void setMonitorMode( bool ); |
198 | virtual bool monitorMode() const; | 195 | virtual bool monitorMode() const; |
199 | 196 | ||
200 | virtual void setChannelHopping( int interval = 0 ); | 197 | virtual void setChannelHopping( int interval = 0 ); |
201 | virtual int channelHopping() const; | 198 | virtual int channelHopping() const; |
202 | 199 | ||
203 | virtual void setNickName( const QString& ) {}; | 200 | virtual void setNickName( const QString& ) {}; |
204 | virtual QString nickName() const; | 201 | virtual QString nickName() const; |
205 | 202 | ||
206 | virtual void setPrivate( const QString&, int, ... ); | 203 | virtual void setPrivate( const QString&, int, ... ); |
204 | virtual bool hasPrivate( const QString& ); | ||
207 | virtual void getPrivate( const QString& ); | 205 | virtual void getPrivate( const QString& ); |
208 | 206 | ||
209 | virtual bool isAssociated() const {}; | 207 | virtual bool isAssociated() const {}; |
210 | virtual QString associatedAP() const; | 208 | virtual QString associatedAP() const; |
211 | 209 | ||
212 | virtual void setSSID( const QString& ); | 210 | virtual void setSSID( const QString& ); |
213 | virtual QString SSID() const; | 211 | virtual QString SSID() const; |
214 | 212 | ||
215 | protected: | 213 | protected: |
216 | void buildChannelList(); | 214 | void buildChannelList(); |
217 | void buildPrivateList(); | 215 | void buildPrivateList(); |
218 | virtual void init(); | 216 | virtual void init(); |
219 | struct iwreq& iwr() const; | 217 | struct iwreq& iwr() const; |
220 | bool wioctl( int call ) const; | 218 | bool wioctl( int call ) const; |
221 | bool wioctl( int call, struct iwreq& ) const; | 219 | bool wioctl( int call, struct iwreq& ) const; |
222 | 220 | ||
223 | protected: | 221 | protected: |
224 | mutable struct iwreq _iwr; | 222 | mutable struct iwreq _iwr; |
225 | QMap<int,int> _channels; | 223 | QMap<int,int> _channels; |
226 | 224 | ||
227 | private: | 225 | private: |
228 | OChannelHopper* _hopper; | 226 | OChannelHopper* _hopper; |
229 | }; | 227 | }; |
230 | 228 | ||
231 | 229 | ||
232 | /*====================================================================================== | 230 | /*====================================================================================== |
233 | * OMonitoringInterface | 231 | * OMonitoringInterface |
234 | *======================================================================================*/ | 232 | *======================================================================================*/ |
235 | 233 | ||
236 | 234 | ||
237 | class OMonitoringInterface | 235 | class OMonitoringInterface |
238 | { | 236 | { |
239 | public: | 237 | public: |
240 | OMonitoringInterface(); | 238 | OMonitoringInterface(); |
241 | OMonitoringInterface( ONetworkInterface* ); | 239 | OMonitoringInterface( ONetworkInterface* ); |
242 | virtual ~OMonitoringInterface(); | 240 | virtual ~OMonitoringInterface(); |
243 | 241 | ||
244 | public: | 242 | public: |
245 | virtual void setEnabled( bool ); | 243 | virtual void setEnabled( bool ); |
246 | virtual bool enabled() const; | 244 | virtual bool enabled() const; |
247 | virtual void setChannel( int ); | 245 | virtual void setChannel( int ); |
248 | 246 | ||
249 | virtual QString name() const = 0; | 247 | virtual QString name() const = 0; |
250 | 248 | ||
251 | protected: | 249 | protected: |
252 | const OWirelessNetworkInterface* _if; | 250 | OWirelessNetworkInterface* _if; |
253 | 251 | ||
254 | }; | 252 | }; |
255 | 253 | ||
256 | 254 | ||
257 | /*====================================================================================== | 255 | /*====================================================================================== |
258 | * OCiscoMonitoring | 256 | * OCiscoMonitoring |
259 | *======================================================================================*/ | 257 | *======================================================================================*/ |
260 | 258 | ||
261 | 259 | ||
262 | class OCiscoMonitoringInterface : public OMonitoringInterface | 260 | class OCiscoMonitoringInterface : public OMonitoringInterface |
263 | { | 261 | { |
264 | public: | 262 | public: |
265 | OCiscoMonitoringInterface( ONetworkInterface* ); | 263 | OCiscoMonitoringInterface( ONetworkInterface* ); |
266 | virtual ~OCiscoMonitoringInterface(); | 264 | virtual ~OCiscoMonitoringInterface(); |
267 | 265 | ||
268 | virtual void setEnabled( bool ); | 266 | virtual void setEnabled( bool ); |
269 | virtual QString name() const; | 267 | virtual QString name() const; |
270 | virtual void setChannel( int ); | 268 | virtual void setChannel( int ); |
271 | 269 | ||
272 | }; | 270 | }; |
273 | 271 | ||
274 | /*====================================================================================== | 272 | /*====================================================================================== |
275 | * OWlanNGMonitoringInterface | 273 | * OWlanNGMonitoringInterface |
276 | *======================================================================================*/ | 274 | *======================================================================================*/ |