-rw-r--r-- | libopie2/opienet/onetwork.h | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h index 7c70873..509c3db 100644 --- a/libopie2/opienet/onetwork.h +++ b/libopie2/opienet/onetwork.h | |||
@@ -51,55 +51,48 @@ | |||
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 | 66 | #ifndef SIOCIWFIRSTPRIV |
67 | #define SIOCIWFIRSTPRIV SIOCDEVPRIVATE | 67 | #define SIOCIWFIRSTPRIV SIOCDEVPRIVATE |
68 | #endif | 68 | #endif |
69 | 69 | ||
70 | class ONetworkInterface; | 70 | class ONetworkInterface; |
71 | class OWirelessNetworkInterface; | 71 | class OWirelessNetworkInterface; |
72 | class OChannelHopper; | 72 | class OChannelHopper; |
73 | class OMonitoringInterface; | 73 | class OMonitoringInterface; |
74 | 74 | ||
75 | typedef struct ifreq ifreqstruct; | ||
76 | typedef struct iwreq iwreqstruct; | ||
77 | typedef struct iw_event iweventstruct; | ||
78 | typedef struct iw_freq iwfreqstruct; | ||
79 | typedef struct iw_priv_args iwprivargsstruct; | ||
80 | typedef struct iw_range iwrangestruct; | ||
81 | |||
82 | /*====================================================================================== | 75 | /*====================================================================================== |
83 | * ONetwork | 76 | * ONetwork |
84 | *======================================================================================*/ | 77 | *======================================================================================*/ |
85 | 78 | ||
86 | class ONetwork : public QObject | 79 | class ONetwork : public QObject |
87 | { | 80 | { |
88 | Q_OBJECT | 81 | Q_OBJECT |
89 | 82 | ||
90 | public: | 83 | public: |
91 | typedef QDict<ONetworkInterface> InterfaceMap; | 84 | typedef QDict<ONetworkInterface> InterfaceMap; |
92 | typedef QDictIterator<ONetworkInterface> InterfaceIterator; | 85 | typedef QDictIterator<ONetworkInterface> InterfaceIterator; |
93 | 86 | ||
94 | public: | 87 | public: |
95 | static ONetwork* instance(); | 88 | static ONetwork* instance(); |
96 | InterfaceIterator iterator() const; | 89 | InterfaceIterator iterator() const; |
97 | bool isWirelessInterface( const char* ) const; | 90 | bool isWirelessInterface( const char* ) const; |
98 | ONetworkInterface* interface( QString ) const; | 91 | ONetworkInterface* interface( QString ) const; |
99 | 92 | ||
100 | protected: | 93 | protected: |
101 | ONetwork(); | 94 | ONetwork(); |
102 | void synchronize(); | 95 | void synchronize(); |
103 | 96 | ||
104 | private: | 97 | private: |
105 | static ONetwork* _instance; | 98 | static ONetwork* _instance; |
@@ -115,56 +108,56 @@ class ONetworkInterface : public QObject | |||
115 | { | 108 | { |
116 | friend class OMonitoringInterface; | 109 | friend class OMonitoringInterface; |
117 | friend class OCiscoMonitoringInterface; | 110 | friend class OCiscoMonitoringInterface; |
118 | friend class OWlanNGMonitoringInterface; | 111 | friend class OWlanNGMonitoringInterface; |
119 | friend class OHostAPMonitoringInterface; | 112 | friend class OHostAPMonitoringInterface; |
120 | friend class OOrinocoMonitoringInterface; | 113 | friend class OOrinocoMonitoringInterface; |
121 | 114 | ||
122 | public: | 115 | public: |
123 | ONetworkInterface( QObject* parent, const char* name ); | 116 | ONetworkInterface( QObject* parent, const char* name ); |
124 | virtual ~ONetworkInterface(); | 117 | virtual ~ONetworkInterface(); |
125 | 118 | ||
126 | void setMonitoring( OMonitoringInterface* ); | 119 | void setMonitoring( OMonitoringInterface* ); |
127 | OMonitoringInterface* monitoring() const; | 120 | OMonitoringInterface* monitoring() const; |
128 | bool setPromiscuousMode( bool ); | 121 | bool setPromiscuousMode( bool ); |
129 | bool promiscuousMode() const; | 122 | bool promiscuousMode() const; |
130 | bool setUp( bool ); | 123 | bool setUp( bool ); |
131 | bool isUp() const; | 124 | bool isUp() const; |
132 | bool isLoopback() const; | 125 | bool isLoopback() const; |
133 | bool isWireless() const; | 126 | bool isWireless() const; |
134 | QString ipV4Address() const; | 127 | QString ipV4Address() const; |
135 | OMacAddress macAddress() const; | 128 | OMacAddress macAddress() const; |
136 | 129 | ||
137 | protected: | 130 | protected: |
138 | const int _sfd; | 131 | const int _sfd; |
139 | mutable ifreqstruct _ifr; | 132 | mutable ifreq _ifr; |
140 | OMonitoringInterface* _mon; | 133 | OMonitoringInterface* _mon; |
141 | 134 | ||
142 | protected: | 135 | protected: |
143 | ifreqstruct& ifr() const; | 136 | struct ifreq& ifr() const; |
144 | virtual void init(); | 137 | virtual void init(); |
145 | bool ioctl( int call ) const; | 138 | bool ioctl( int call ) const; |
146 | bool ioctl( int call, ifreqstruct& ) const; | 139 | bool ioctl( int call, struct ifreq& ) const; |
147 | }; | 140 | }; |
148 | 141 | ||
149 | /*====================================================================================== | 142 | /*====================================================================================== |
150 | * OChannelHopper | 143 | * OChannelHopper |
151 | *======================================================================================*/ | 144 | *======================================================================================*/ |
152 | 145 | ||
153 | class OChannelHopper : public QObject | 146 | class OChannelHopper : public QObject |
154 | { | 147 | { |
155 | public: | 148 | public: |
156 | OChannelHopper( OWirelessNetworkInterface* ); | 149 | OChannelHopper( OWirelessNetworkInterface* ); |
157 | virtual ~OChannelHopper(); | 150 | virtual ~OChannelHopper(); |
158 | bool isActive() const; | 151 | bool isActive() const; |
159 | int channel() const; | 152 | int channel() const; |
160 | virtual void timerEvent( QTimerEvent* ); | 153 | virtual void timerEvent( QTimerEvent* ); |
161 | void setInterval( int ); | 154 | void setInterval( int ); |
162 | int interval() const; | 155 | int interval() const; |
163 | 156 | ||
164 | private: | 157 | private: |
165 | OWirelessNetworkInterface* _iface; | 158 | OWirelessNetworkInterface* _iface; |
166 | int _interval; | 159 | int _interval; |
167 | int _tid; | 160 | int _tid; |
168 | QValueList<int> _channels; | 161 | QValueList<int> _channels; |
169 | QValueList<int>::Iterator _channel; | 162 | QValueList<int>::Iterator _channel; |
170 | 163 | ||
@@ -201,54 +194,54 @@ class OWirelessNetworkInterface : public ONetworkInterface | |||
201 | virtual bool mode() const {}; | 194 | virtual bool mode() const {}; |
202 | 195 | ||
203 | virtual void setMonitorMode( bool ); | 196 | virtual void setMonitorMode( bool ); |
204 | virtual bool monitorMode() const; | 197 | virtual bool monitorMode() const; |
205 | 198 | ||
206 | virtual void setChannelHopping( int interval = 0 ); | 199 | virtual void setChannelHopping( int interval = 0 ); |
207 | virtual int channelHopping() const; | 200 | virtual int channelHopping() const; |
208 | 201 | ||
209 | virtual void setNickName( const QString& ) {}; | 202 | virtual void setNickName( const QString& ) {}; |
210 | virtual QString nickName() const; | 203 | virtual QString nickName() const; |
211 | 204 | ||
212 | virtual void setPrivate( const QString&, int, ... ); | 205 | virtual void setPrivate( const QString&, int, ... ); |
213 | virtual void getPrivate( const QString& ); | 206 | virtual void getPrivate( const QString& ); |
214 | 207 | ||
215 | virtual bool isAssociated() const {}; | 208 | virtual bool isAssociated() const {}; |
216 | virtual QString associatedAP() const; | 209 | virtual QString associatedAP() const; |
217 | 210 | ||
218 | virtual void setSSID( const QString& ); | 211 | virtual void setSSID( const QString& ); |
219 | virtual QString SSID() const; | 212 | virtual QString SSID() const; |
220 | 213 | ||
221 | protected: | 214 | protected: |
222 | void buildChannelList(); | 215 | void buildChannelList(); |
223 | void buildPrivateList(); | 216 | void buildPrivateList(); |
224 | virtual void init(); | 217 | virtual void init(); |
225 | iwreqstruct& iwr() const; | 218 | struct iwreq& iwr() const; |
226 | bool wioctl( int call ) const; | 219 | bool wioctl( int call ) const; |
227 | bool wioctl( int call, iwreqstruct& ) const; | 220 | bool wioctl( int call, struct iwreq& ) const; |
228 | 221 | ||
229 | protected: | 222 | protected: |
230 | mutable iwreqstruct _iwr; | 223 | mutable struct iwreq _iwr; |
231 | QMap<int,int> _channels; | 224 | QMap<int,int> _channels; |
232 | 225 | ||
233 | private: | 226 | private: |
234 | OChannelHopper* _hopper; | 227 | OChannelHopper* _hopper; |
235 | }; | 228 | }; |
236 | 229 | ||
237 | 230 | ||
238 | /*====================================================================================== | 231 | /*====================================================================================== |
239 | * OMonitoringInterface | 232 | * OMonitoringInterface |
240 | *======================================================================================*/ | 233 | *======================================================================================*/ |
241 | 234 | ||
242 | 235 | ||
243 | class OMonitoringInterface | 236 | class OMonitoringInterface |
244 | { | 237 | { |
245 | public: | 238 | public: |
246 | OMonitoringInterface(); | 239 | OMonitoringInterface(); |
247 | OMonitoringInterface( ONetworkInterface* ); | 240 | OMonitoringInterface( ONetworkInterface* ); |
248 | virtual ~OMonitoringInterface(); | 241 | virtual ~OMonitoringInterface(); |
249 | 242 | ||
250 | public: | 243 | public: |
251 | virtual void setEnabled( bool ); | 244 | virtual void setEnabled( bool ); |
252 | virtual bool enabled() const; | 245 | virtual bool enabled() const; |
253 | virtual void setChannel( int ); | 246 | virtual void setChannel( int ); |
254 | 247 | ||