author | mickeyl <mickeyl> | 2003-03-28 15:11:52 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-03-28 15:11:52 (UTC) |
commit | 11304d02942e9fa493e4e80943a828f9c65f6772 (patch) (unidiff) | |
tree | a0223c10c067e1afc70d15c2b82be3f3c15e41ae /libopie2/opienet/onetwork.h | |
parent | b271d575fa05cf570a1a829136517761bd47e69b (diff) | |
download | opie-11304d02942e9fa493e4e80943a828f9c65f6772.zip opie-11304d02942e9fa493e4e80943a828f9c65f6772.tar.gz opie-11304d02942e9fa493e4e80943a828f9c65f6772.tar.bz2 |
skeleton and the start of libopie2, please read README, ROADMAP and STATUS and comment...
-rw-r--r-- | libopie2/opienet/onetwork.h | 307 |
1 files changed, 307 insertions, 0 deletions
diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h new file mode 100644 index 0000000..9a68a74 --- a/dev/null +++ b/libopie2/opienet/onetwork.h | |||
@@ -0,0 +1,307 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) 2003 by the Wellenreiter team: | ||
4 | Martin J. Muench <mjm@remote-exploit.org> | ||
5 | Max Moser <mmo@remote-exploit.org | ||
6 | Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | ||
7 | =. | ||
8 | .=l. | ||
9 | .>+-= | ||
10 | _;:, .> :=|. This program is free software; you can | ||
11 | .> <`_, > . <= redistribute it and/or modify it under | ||
12 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
13 | .="- .-=="i, .._ License as published by the Free Software | ||
14 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
15 | ._= =} : or (at your option) any later version. | ||
16 | .%`+i> _;_. | ||
17 | .i_,=:_. -<s. This program is distributed in the hope that | ||
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
19 | : .. .:, . . . without even the implied warranty of | ||
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
22 | ..}^=.= = ; Library General Public License for more | ||
23 | ++= -. .` .: details. | ||
24 | : = ...= . :.=- | ||
25 | -. .:....=;==+<; You should have received a copy of the GNU | ||
26 | -_. . . )=. = Library General Public License along with | ||
27 | -- :-=` this library; see the file COPYING.LIB. | ||
28 | If not, write to the Free Software Foundation, | ||
29 | Inc., 59 Temple Place - Suite 330, | ||
30 | Boston, MA 02111-1307, USA. | ||
31 | |||
32 | */ | ||
33 | |||
34 | #ifndef ONETWORK_H | ||
35 | #define ONETWORK_H | ||
36 | |||
37 | /* QT */ | ||
38 | |||
39 | #include <qdict.h> | ||
40 | #include <qmap.h> | ||
41 | #include <qobject.h> | ||
42 | #include <qhostaddress.h> | ||
43 | |||
44 | /* OPIE */ | ||
45 | |||
46 | #include <opie2/onetutils.h> | ||
47 | |||
48 | // ML: Yeah, I hate to include kernel headers, but it's necessary here | ||
49 | // ML: Recent RedHat and MandrakePatches to the Kernel and WE broke something | ||
50 | // ML: #include <net/if.h> e.g. conflicts with #include <linux/wireless.h> | ||
51 | #define IFNAMSIZ 16 | ||
52 | #include <linux/wireless.h> | ||
53 | #include <net/if.h> | ||
54 | |||
55 | class ONetworkInterface; | ||
56 | class OWirelessNetworkInterface; | ||
57 | class OChannelHopper; | ||
58 | class OMonitoringInterface; | ||
59 | |||
60 | typedef struct ifreq ifreqstruct; | ||
61 | typedef struct iwreq iwreqstruct; | ||
62 | typedef struct iw_event iweventstruct; | ||
63 | typedef struct iw_freq iwfreqstruct; | ||
64 | typedef struct iw_priv_args iwprivargsstruct; | ||
65 | typedef struct iw_range iwrangestruct; | ||
66 | |||
67 | /*====================================================================================== | ||
68 | * ONetwork | ||
69 | *======================================================================================*/ | ||
70 | |||
71 | class ONetwork : public QObject | ||
72 | { | ||
73 | Q_OBJECT | ||
74 | |||
75 | public: | ||
76 | typedef QDict<ONetworkInterface> InterfaceMap; | ||
77 | typedef QDictIterator<ONetworkInterface> InterfaceIterator; | ||
78 | |||
79 | public: | ||
80 | static ONetwork* instance(); | ||
81 | InterfaceIterator iterator() const; | ||
82 | bool isWirelessInterface( const char* ) const; | ||
83 | ONetworkInterface* interface( QString ) const; | ||
84 | |||
85 | protected: | ||
86 | ONetwork(); | ||
87 | void synchronize(); | ||
88 | |||
89 | private: | ||
90 | static ONetwork* _instance; | ||
91 | InterfaceMap _interfaces; | ||
92 | }; | ||
93 | |||
94 | |||
95 | /*====================================================================================== | ||
96 | * ONetworkInterface | ||
97 | *======================================================================================*/ | ||
98 | |||
99 | class ONetworkInterface | ||
100 | { | ||
101 | friend class OMonitoringInterface; | ||
102 | friend class OCiscoMonitoringInterface; | ||
103 | friend class OWlanNGMonitoringInterface; | ||
104 | friend class OHostAPMonitoringInterface; | ||
105 | friend class OOrinocoMonitoringInterface; | ||
106 | |||
107 | public: | ||
108 | ONetworkInterface( const QString& name ); | ||
109 | virtual ~ONetworkInterface(); | ||
110 | |||
111 | const QString& name() const; | ||
112 | void setMonitoring( OMonitoringInterface* ); | ||
113 | OMonitoringInterface* monitoring() const; | ||
114 | bool setPromiscuousMode( bool ); | ||
115 | bool promiscuousMode() const; | ||
116 | bool setUp( bool ); | ||
117 | bool isUp() const; | ||
118 | bool isLoopback() const; | ||
119 | bool isWireless() const; | ||
120 | QString ipV4Address() const; | ||
121 | OMacAddress macAddress() const; | ||
122 | |||
123 | protected: | ||
124 | const QString _name; | ||
125 | const int _sfd; | ||
126 | mutable ifreqstruct _ifr; | ||
127 | OMonitoringInterface* _mon; | ||
128 | |||
129 | protected: | ||
130 | ifreqstruct& ifr() const; | ||
131 | virtual void init(); | ||
132 | bool ioctl( int call ) const; | ||
133 | bool ioctl( int call, ifreqstruct& ) const; | ||
134 | }; | ||
135 | |||
136 | /*====================================================================================== | ||
137 | * OChannelHopper | ||
138 | *======================================================================================*/ | ||
139 | |||
140 | class OChannelHopper : public QObject | ||
141 | { | ||
142 | public: | ||
143 | OChannelHopper( OWirelessNetworkInterface* ); | ||
144 | virtual ~OChannelHopper(); | ||
145 | virtual void timerEvent( QTimerEvent* ); | ||
146 | void setInterval( int ); | ||
147 | int interval() const; | ||
148 | |||
149 | private: | ||
150 | OWirelessNetworkInterface* _iface; | ||
151 | int _interval; | ||
152 | int _channel; | ||
153 | int _tid; | ||
154 | }; | ||
155 | |||
156 | |||
157 | /*====================================================================================== | ||
158 | * OWirelessNetworkInterface | ||
159 | *======================================================================================*/ | ||
160 | |||
161 | class OWirelessNetworkInterface : public ONetworkInterface | ||
162 | { | ||
163 | friend class OMonitoringInterface; | ||
164 | friend class OCiscoMonitoringInterface; | ||
165 | friend class OWlanNGMonitoringInterface; | ||
166 | friend class OHostAPMonitoringInterface; | ||
167 | friend class OOrinocoMonitoringInterface; | ||
168 | |||
169 | public: | ||
170 | enum Mode { AdHoc, Managed, Monitor }; | ||
171 | |||
172 | OWirelessNetworkInterface( const QString& name ); | ||
173 | virtual ~OWirelessNetworkInterface(); | ||
174 | |||
175 | virtual void setChannel( int ) const; | ||
176 | virtual int channel() const; | ||
177 | virtual double frequency() const; | ||
178 | virtual int channels() const; | ||
179 | //virtual double frequency(int) const; | ||
180 | |||
181 | virtual void setMode( Mode ) {}; | ||
182 | virtual bool mode() const {}; | ||
183 | |||
184 | virtual void setMonitorMode( bool ); | ||
185 | virtual bool monitorMode() const; | ||
186 | |||
187 | virtual void setChannelHopping( int interval ); | ||
188 | virtual int channelHopping() const; | ||
189 | |||
190 | virtual void setNickName( const QString& ) {}; | ||
191 | virtual QString nickName() const; | ||
192 | |||
193 | virtual bool isAssociated() const {}; | ||
194 | virtual QString associatedAP() const; | ||
195 | |||
196 | virtual void setSSID( const QString& ); | ||
197 | virtual QString SSID() const; | ||
198 | |||
199 | protected: | ||
200 | mutable iwreqstruct _iwr; | ||
201 | QMap<int,int> _channels; | ||
202 | |||
203 | protected: | ||
204 | virtual void init(); | ||
205 | iwreqstruct& iwr() const; | ||
206 | bool wioctl( int call ) const; | ||
207 | bool wioctl( int call, iwreqstruct& ) const; | ||
208 | |||
209 | private: | ||
210 | OChannelHopper _hopper; | ||
211 | }; | ||
212 | |||
213 | |||
214 | /*====================================================================================== | ||
215 | * OMonitoringInterface | ||
216 | *======================================================================================*/ | ||
217 | |||
218 | |||
219 | class OMonitoringInterface | ||
220 | { | ||
221 | public: | ||
222 | OMonitoringInterface(); | ||
223 | OMonitoringInterface( ONetworkInterface* ); | ||
224 | virtual ~OMonitoringInterface(); | ||
225 | |||
226 | public: | ||
227 | virtual void setEnabled( bool ); | ||
228 | virtual bool enabled() const; | ||
229 | virtual void setChannel( int ); | ||
230 | |||
231 | virtual QString name() const = 0; | ||
232 | |||
233 | protected: | ||
234 | bool _enabled; | ||
235 | const OWirelessNetworkInterface* _if; | ||
236 | |||
237 | }; | ||
238 | |||
239 | |||
240 | /*====================================================================================== | ||
241 | * OCiscoMonitoring | ||
242 | *======================================================================================*/ | ||
243 | |||
244 | |||
245 | class OCiscoMonitoringInterface : public OMonitoringInterface | ||
246 | { | ||
247 | public: | ||
248 | OCiscoMonitoringInterface( ONetworkInterface* ); | ||
249 | virtual ~OCiscoMonitoringInterface(); | ||
250 | |||
251 | virtual void setEnabled( bool ); | ||
252 | virtual QString name() const; | ||
253 | virtual void setChannel( int ); | ||
254 | |||
255 | }; | ||
256 | |||
257 | /*====================================================================================== | ||
258 | * OWlanNGMonitoringInterface | ||
259 | *======================================================================================*/ | ||
260 | |||
261 | class OWlanNGMonitoringInterface : public OMonitoringInterface | ||
262 | { | ||
263 | public: | ||
264 | OWlanNGMonitoringInterface( ONetworkInterface* ); | ||
265 | virtual ~OWlanNGMonitoringInterface(); | ||
266 | |||
267 | public: | ||
268 | virtual void setEnabled( bool ); | ||
269 | virtual QString name() const; | ||
270 | virtual void setChannel( int ); | ||
271 | |||
272 | }; | ||
273 | |||
274 | /*====================================================================================== | ||
275 | * OHostAPMonitoringInterface | ||
276 | *======================================================================================*/ | ||
277 | |||
278 | class OHostAPMonitoringInterface : public OMonitoringInterface | ||
279 | { | ||
280 | public: | ||
281 | OHostAPMonitoringInterface( ONetworkInterface* ); | ||
282 | virtual ~OHostAPMonitoringInterface(); | ||
283 | |||
284 | public: | ||
285 | virtual void setEnabled( bool ); | ||
286 | virtual QString name() const; | ||
287 | }; | ||
288 | |||
289 | /*====================================================================================== | ||
290 | * OOrinocoMonitoringInterface | ||
291 | *======================================================================================*/ | ||
292 | |||
293 | class OOrinocoMonitoringInterface : public OMonitoringInterface | ||
294 | { | ||
295 | public: | ||
296 | OOrinocoMonitoringInterface( ONetworkInterface* ); | ||
297 | virtual ~OOrinocoMonitoringInterface(); | ||
298 | |||
299 | public: | ||
300 | virtual void setChannel( int ); | ||
301 | virtual void setEnabled( bool ); | ||
302 | virtual QString name() const; | ||
303 | |||
304 | }; | ||
305 | |||
306 | #endif // ONETWORK_H | ||
307 | |||