-rw-r--r-- | libopie2/opienet/oioctlmap.cpp | 366 | ||||
-rw-r--r-- | libopie2/opienet/oioctlmap.h | 17 | ||||
-rw-r--r-- | libopie2/opienet/onetwork.cpp | 21 | ||||
-rw-r--r-- | libopie2/opienet/opienet.pro | 11 | ||||
-rwxr-xr-x | libopie2/tools/regen.py | 64 |
5 files changed, 470 insertions, 9 deletions
diff --git a/libopie2/opienet/oioctlmap.cpp b/libopie2/opienet/oioctlmap.cpp new file mode 100644 index 0000000..4a67eb6 --- a/dev/null +++ b/libopie2/opienet/oioctlmap.cpp | |||
@@ -0,0 +1,366 @@ | |||
1 | |||
2 | /* | ||
3 | * ioctl table - generated by regen.py - (C) Michael 'Mickey' Lauer <mickey@vanille.de> | ||
4 | */ | ||
5 | |||
6 | #include "oioctlmap.h" | ||
7 | |||
8 | IntStringMap* constructIoctlMap() | ||
9 | { | ||
10 | IntStringMap* map = new IntStringMap(); | ||
11 | |||
12 | |||
13 | qDebug( "adding 0x8902 = SIOCSPGRP" ); | ||
14 | map->insert( 0x8902, new QString("SIOCSPGRP") ); | ||
15 | qDebug( "adding 0x8904 = SIOCGPGRP" ); | ||
16 | map->insert( 0x8904, new QString("SIOCGPGRP") ); | ||
17 | qDebug( "adding 0x8905 = SIOCATMARK" ); | ||
18 | map->insert( 0x8905, new QString("SIOCATMARK") ); | ||
19 | qDebug( "adding 0x8906 = SIOCGSTAMP" ); | ||
20 | map->insert( 0x8906, new QString("SIOCGSTAMP") ); | ||
21 | qDebug( "adding 0x890B = SIOCADDRT" ); | ||
22 | map->insert( 0x890B, new QString("SIOCADDRT") ); | ||
23 | qDebug( "adding 0x890C = SIOCDELRT" ); | ||
24 | map->insert( 0x890C, new QString("SIOCDELRT") ); | ||
25 | qDebug( "adding 0x890D = SIOCRTMSG" ); | ||
26 | map->insert( 0x890D, new QString("SIOCRTMSG") ); | ||
27 | qDebug( "adding 0x8910 = SIOCGIFNAME" ); | ||
28 | map->insert( 0x8910, new QString("SIOCGIFNAME") ); | ||
29 | qDebug( "adding 0x8911 = SIOCSIFLINK" ); | ||
30 | map->insert( 0x8911, new QString("SIOCSIFLINK") ); | ||
31 | qDebug( "adding 0x8912 = SIOCGIFCONF" ); | ||
32 | map->insert( 0x8912, new QString("SIOCGIFCONF") ); | ||
33 | qDebug( "adding 0x8913 = SIOCGIFFLAGS" ); | ||
34 | map->insert( 0x8913, new QString("SIOCGIFFLAGS") ); | ||
35 | qDebug( "adding 0x8914 = SIOCSIFFLAGS" ); | ||
36 | map->insert( 0x8914, new QString("SIOCSIFFLAGS") ); | ||
37 | qDebug( "adding 0x8915 = SIOCGIFADDR" ); | ||
38 | map->insert( 0x8915, new QString("SIOCGIFADDR") ); | ||
39 | qDebug( "adding 0x8916 = SIOCSIFADDR" ); | ||
40 | map->insert( 0x8916, new QString("SIOCSIFADDR") ); | ||
41 | qDebug( "adding 0x8917 = SIOCGIFDSTADDR" ); | ||
42 | map->insert( 0x8917, new QString("SIOCGIFDSTADDR") ); | ||
43 | qDebug( "adding 0x8918 = SIOCSIFDSTADDR" ); | ||
44 | map->insert( 0x8918, new QString("SIOCSIFDSTADDR") ); | ||
45 | qDebug( "adding 0x8919 = SIOCGIFBRDADDR" ); | ||
46 | map->insert( 0x8919, new QString("SIOCGIFBRDADDR") ); | ||
47 | qDebug( "adding 0x891a = SIOCSIFBRDADDR" ); | ||
48 | map->insert( 0x891a, new QString("SIOCSIFBRDADDR") ); | ||
49 | qDebug( "adding 0x891b = SIOCGIFNETMASK" ); | ||
50 | map->insert( 0x891b, new QString("SIOCGIFNETMASK") ); | ||
51 | qDebug( "adding 0x891c = SIOCSIFNETMASK" ); | ||
52 | map->insert( 0x891c, new QString("SIOCSIFNETMASK") ); | ||
53 | qDebug( "adding 0x891d = SIOCGIFMETRIC" ); | ||
54 | map->insert( 0x891d, new QString("SIOCGIFMETRIC") ); | ||
55 | qDebug( "adding 0x891e = SIOCSIFMETRIC" ); | ||
56 | map->insert( 0x891e, new QString("SIOCSIFMETRIC") ); | ||
57 | qDebug( "adding 0x891f = SIOCGIFMEM" ); | ||
58 | map->insert( 0x891f, new QString("SIOCGIFMEM") ); | ||
59 | qDebug( "adding 0x8920 = SIOCSIFMEM" ); | ||
60 | map->insert( 0x8920, new QString("SIOCSIFMEM") ); | ||
61 | qDebug( "adding 0x8921 = SIOCGIFMTU" ); | ||
62 | map->insert( 0x8921, new QString("SIOCGIFMTU") ); | ||
63 | qDebug( "adding 0x8922 = SIOCSIFMTU" ); | ||
64 | map->insert( 0x8922, new QString("SIOCSIFMTU") ); | ||
65 | qDebug( "adding 0x8923 = SIOCSIFNAME" ); | ||
66 | map->insert( 0x8923, new QString("SIOCSIFNAME") ); | ||
67 | qDebug( "adding 0x8924 = SIOCSIFHWADDR" ); | ||
68 | map->insert( 0x8924, new QString("SIOCSIFHWADDR") ); | ||
69 | qDebug( "adding 0x8925 = SIOCGIFENCAP" ); | ||
70 | map->insert( 0x8925, new QString("SIOCGIFENCAP") ); | ||
71 | qDebug( "adding 0x8926 = SIOCSIFENCAP" ); | ||
72 | map->insert( 0x8926, new QString("SIOCSIFENCAP") ); | ||
73 | qDebug( "adding 0x8927 = SIOCGIFHWADDR" ); | ||
74 | map->insert( 0x8927, new QString("SIOCGIFHWADDR") ); | ||
75 | qDebug( "adding 0x8929 = SIOCGIFSLAVE" ); | ||
76 | map->insert( 0x8929, new QString("SIOCGIFSLAVE") ); | ||
77 | qDebug( "adding 0x8930 = SIOCSIFSLAVE" ); | ||
78 | map->insert( 0x8930, new QString("SIOCSIFSLAVE") ); | ||
79 | qDebug( "adding 0x8931 = SIOCADDMULTI" ); | ||
80 | map->insert( 0x8931, new QString("SIOCADDMULTI") ); | ||
81 | qDebug( "adding 0x8932 = SIOCDELMULTI" ); | ||
82 | map->insert( 0x8932, new QString("SIOCDELMULTI") ); | ||
83 | qDebug( "adding 0x8933 = SIOCGIFINDEX" ); | ||
84 | map->insert( 0x8933, new QString("SIOCGIFINDEX") ); | ||
85 | qDebug( "adding 0x8934 = SIOCSIFPFLAGS" ); | ||
86 | map->insert( 0x8934, new QString("SIOCSIFPFLAGS") ); | ||
87 | qDebug( "adding 0x8935 = SIOCGIFPFLAGS" ); | ||
88 | map->insert( 0x8935, new QString("SIOCGIFPFLAGS") ); | ||
89 | qDebug( "adding 0x8936 = SIOCDIFADDR" ); | ||
90 | map->insert( 0x8936, new QString("SIOCDIFADDR") ); | ||
91 | qDebug( "adding 0x8937 = SIOCSIFHWBROADCAST" ); | ||
92 | map->insert( 0x8937, new QString("SIOCSIFHWBROADCAST") ); | ||
93 | qDebug( "adding 0x8938 = SIOCGIFCOUNT" ); | ||
94 | map->insert( 0x8938, new QString("SIOCGIFCOUNT") ); | ||
95 | qDebug( "adding 0x8940 = SIOCGIFBR" ); | ||
96 | map->insert( 0x8940, new QString("SIOCGIFBR") ); | ||
97 | qDebug( "adding 0x8941 = SIOCSIFBR" ); | ||
98 | map->insert( 0x8941, new QString("SIOCSIFBR") ); | ||
99 | qDebug( "adding 0x8942 = SIOCGIFTXQLEN" ); | ||
100 | map->insert( 0x8942, new QString("SIOCGIFTXQLEN") ); | ||
101 | qDebug( "adding 0x8943 = SIOCSIFTXQLEN" ); | ||
102 | map->insert( 0x8943, new QString("SIOCSIFTXQLEN") ); | ||
103 | qDebug( "adding 0x8953 = SIOCDARP" ); | ||
104 | map->insert( 0x8953, new QString("SIOCDARP") ); | ||
105 | qDebug( "adding 0x8954 = SIOCGARP" ); | ||
106 | map->insert( 0x8954, new QString("SIOCGARP") ); | ||
107 | qDebug( "adding 0x8955 = SIOCSARP" ); | ||
108 | map->insert( 0x8955, new QString("SIOCSARP") ); | ||
109 | qDebug( "adding 0x8960 = SIOCDRARP" ); | ||
110 | map->insert( 0x8960, new QString("SIOCDRARP") ); | ||
111 | qDebug( "adding 0x8961 = SIOCGRARP" ); | ||
112 | map->insert( 0x8961, new QString("SIOCGRARP") ); | ||
113 | qDebug( "adding 0x8962 = SIOCSRARP" ); | ||
114 | map->insert( 0x8962, new QString("SIOCSRARP") ); | ||
115 | qDebug( "adding 0x8970 = SIOCGIFMAP" ); | ||
116 | map->insert( 0x8970, new QString("SIOCGIFMAP") ); | ||
117 | qDebug( "adding 0x8971 = SIOCSIFMAP" ); | ||
118 | map->insert( 0x8971, new QString("SIOCSIFMAP") ); | ||
119 | qDebug( "adding 0x8980 = SIOCADDDLCI" ); | ||
120 | map->insert( 0x8980, new QString("SIOCADDDLCI") ); | ||
121 | qDebug( "adding 0x8981 = SIOCDELDLCI" ); | ||
122 | map->insert( 0x8981, new QString("SIOCDELDLCI") ); | ||
123 | qDebug( "adding 0x89F0 = SIOCDEVPRIVATE" ); | ||
124 | map->insert( 0x89F0, new QString("SIOCDEVPRIVATE") ); | ||
125 | qDebug( "adding 0x89E0 = SIOCPROTOPRIVATE" ); | ||
126 | map->insert( 0x89E0, new QString("SIOCPROTOPRIVATE") ); | ||
127 | qDebug( "adding 0x1fff = SIOCPARM_MASK" ); | ||
128 | map->insert( 0x1fff, new QString("SIOCPARM_MASK") ); | ||
129 | qDebug( "adding 0x00000000 = SIOC_VOID" ); | ||
130 | map->insert( 0x00000000, new QString("SIOC_VOID") ); | ||
131 | qDebug( "adding 0x20000000 = SIOC_OUT" ); | ||
132 | map->insert( 0x20000000, new QString("SIOC_OUT") ); | ||
133 | qDebug( "adding 0x40000000 = SIOC_IN" ); | ||
134 | map->insert( 0x40000000, new QString("SIOC_IN") ); | ||
135 | qDebug( "adding 0x8B00 = SIOCSIWCOMMIT" ); | ||
136 | map->insert( 0x8B00, new QString("SIOCSIWCOMMIT") ); | ||
137 | qDebug( "adding 0x8B01 = SIOCGIWNAME" ); | ||
138 | map->insert( 0x8B01, new QString("SIOCGIWNAME") ); | ||
139 | qDebug( "adding 0x8B02 = SIOCSIWNWID" ); | ||
140 | map->insert( 0x8B02, new QString("SIOCSIWNWID") ); | ||
141 | qDebug( "adding 0x8B03 = SIOCGIWNWID" ); | ||
142 | map->insert( 0x8B03, new QString("SIOCGIWNWID") ); | ||
143 | qDebug( "adding 0x8B04 = SIOCSIWFREQ" ); | ||
144 | map->insert( 0x8B04, new QString("SIOCSIWFREQ") ); | ||
145 | qDebug( "adding 0x8B05 = SIOCGIWFREQ" ); | ||
146 | map->insert( 0x8B05, new QString("SIOCGIWFREQ") ); | ||
147 | qDebug( "adding 0x8B06 = SIOCSIWMODE" ); | ||
148 | map->insert( 0x8B06, new QString("SIOCSIWMODE") ); | ||
149 | qDebug( "adding 0x8B07 = SIOCGIWMODE" ); | ||
150 | map->insert( 0x8B07, new QString("SIOCGIWMODE") ); | ||
151 | qDebug( "adding 0x8B08 = SIOCSIWSENS" ); | ||
152 | map->insert( 0x8B08, new QString("SIOCSIWSENS") ); | ||
153 | qDebug( "adding 0x8B09 = SIOCGIWSENS" ); | ||
154 | map->insert( 0x8B09, new QString("SIOCGIWSENS") ); | ||
155 | qDebug( "adding 0x8B0A = SIOCSIWRANGE" ); | ||
156 | map->insert( 0x8B0A, new QString("SIOCSIWRANGE") ); | ||
157 | qDebug( "adding 0x8B0B = SIOCGIWRANGE" ); | ||
158 | map->insert( 0x8B0B, new QString("SIOCGIWRANGE") ); | ||
159 | qDebug( "adding 0x8B0C = SIOCSIWPRIV" ); | ||
160 | map->insert( 0x8B0C, new QString("SIOCSIWPRIV") ); | ||
161 | qDebug( "adding 0x8B0D = SIOCGIWPRIV" ); | ||
162 | map->insert( 0x8B0D, new QString("SIOCGIWPRIV") ); | ||
163 | qDebug( "adding 0x8B0E = SIOCSIWSTATS" ); | ||
164 | map->insert( 0x8B0E, new QString("SIOCSIWSTATS") ); | ||
165 | qDebug( "adding 0x8B0F = SIOCGIWSTATS" ); | ||
166 | map->insert( 0x8B0F, new QString("SIOCGIWSTATS") ); | ||
167 | qDebug( "adding 0x8B10 = SIOCSIWSPY" ); | ||
168 | map->insert( 0x8B10, new QString("SIOCSIWSPY") ); | ||
169 | qDebug( "adding 0x8B11 = SIOCGIWSPY" ); | ||
170 | map->insert( 0x8B11, new QString("SIOCGIWSPY") ); | ||
171 | qDebug( "adding 0x8B14 = SIOCSIWAP" ); | ||
172 | map->insert( 0x8B14, new QString("SIOCSIWAP") ); | ||
173 | qDebug( "adding 0x8B15 = SIOCGIWAP" ); | ||
174 | map->insert( 0x8B15, new QString("SIOCGIWAP") ); | ||
175 | qDebug( "adding 0x8B17 = SIOCGIWAPLIST" ); | ||
176 | map->insert( 0x8B17, new QString("SIOCGIWAPLIST") ); | ||
177 | qDebug( "adding 0x8B18 = SIOCSIWSCAN" ); | ||
178 | map->insert( 0x8B18, new QString("SIOCSIWSCAN") ); | ||
179 | qDebug( "adding 0x8B19 = SIOCGIWSCAN" ); | ||
180 | map->insert( 0x8B19, new QString("SIOCGIWSCAN") ); | ||
181 | qDebug( "adding 0x8B1A = SIOCSIWESSID" ); | ||
182 | map->insert( 0x8B1A, new QString("SIOCSIWESSID") ); | ||
183 | qDebug( "adding 0x8B1B = SIOCGIWESSID" ); | ||
184 | map->insert( 0x8B1B, new QString("SIOCGIWESSID") ); | ||
185 | qDebug( "adding 0x8B1C = SIOCSIWNICKN" ); | ||
186 | map->insert( 0x8B1C, new QString("SIOCSIWNICKN") ); | ||
187 | qDebug( "adding 0x8B1D = SIOCGIWNICKN" ); | ||
188 | map->insert( 0x8B1D, new QString("SIOCGIWNICKN") ); | ||
189 | qDebug( "adding 0x8B20 = SIOCSIWRATE" ); | ||
190 | map->insert( 0x8B20, new QString("SIOCSIWRATE") ); | ||
191 | qDebug( "adding 0x8B21 = SIOCGIWRATE" ); | ||
192 | map->insert( 0x8B21, new QString("SIOCGIWRATE") ); | ||
193 | qDebug( "adding 0x8B22 = SIOCSIWRTS" ); | ||
194 | map->insert( 0x8B22, new QString("SIOCSIWRTS") ); | ||
195 | qDebug( "adding 0x8B23 = SIOCGIWRTS" ); | ||
196 | map->insert( 0x8B23, new QString("SIOCGIWRTS") ); | ||
197 | qDebug( "adding 0x8B24 = SIOCSIWFRAG" ); | ||
198 | map->insert( 0x8B24, new QString("SIOCSIWFRAG") ); | ||
199 | qDebug( "adding 0x8B25 = SIOCGIWFRAG" ); | ||
200 | map->insert( 0x8B25, new QString("SIOCGIWFRAG") ); | ||
201 | qDebug( "adding 0x8B26 = SIOCSIWTXPOW" ); | ||
202 | map->insert( 0x8B26, new QString("SIOCSIWTXPOW") ); | ||
203 | qDebug( "adding 0x8B27 = SIOCGIWTXPOW" ); | ||
204 | map->insert( 0x8B27, new QString("SIOCGIWTXPOW") ); | ||
205 | qDebug( "adding 0x8B28 = SIOCSIWRETRY" ); | ||
206 | map->insert( 0x8B28, new QString("SIOCSIWRETRY") ); | ||
207 | qDebug( "adding 0x8B29 = SIOCGIWRETRY" ); | ||
208 | map->insert( 0x8B29, new QString("SIOCGIWRETRY") ); | ||
209 | qDebug( "adding 0x8B2A = SIOCSIWENCODE" ); | ||
210 | map->insert( 0x8B2A, new QString("SIOCSIWENCODE") ); | ||
211 | qDebug( "adding 0x8B2B = SIOCGIWENCODE" ); | ||
212 | map->insert( 0x8B2B, new QString("SIOCGIWENCODE") ); | ||
213 | qDebug( "adding 0x8B2C = SIOCSIWPOWER" ); | ||
214 | map->insert( 0x8B2C, new QString("SIOCSIWPOWER") ); | ||
215 | qDebug( "adding 0x8B2D = SIOCGIWPOWER" ); | ||
216 | map->insert( 0x8B2D, new QString("SIOCGIWPOWER") ); | ||
217 | qDebug( "adding 0x8BE0 = SIOCIWFIRSTPRIV" ); | ||
218 | map->insert( 0x8BE0, new QString("SIOCIWFIRSTPRIV") ); | ||
219 | qDebug( "adding 0x8BFF = SIOCIWLASTPRIV" ); | ||
220 | map->insert( 0x8BFF, new QString("SIOCIWLASTPRIV") ); | ||
221 | qDebug( "adding 0x8B00 = SIOCIWFIRST" ); | ||
222 | map->insert( 0x8B00, new QString("SIOCIWFIRST") ); | ||
223 | qDebug( "adding 0x5000 = SIOCGBPQETHPARAM" ); | ||
224 | map->insert( 0x5000, new QString("SIOCGBPQETHPARAM") ); | ||
225 | qDebug( "adding 0x5001 = SIOCSBPQETHPARAM" ); | ||
226 | map->insert( 0x5001, new QString("SIOCSBPQETHPARAM") ); | ||
227 | qDebug( "adding 0x890B = SIOCADDRT" ); | ||
228 | map->insert( 0x890B, new QString("SIOCADDRT") ); | ||
229 | qDebug( "adding 0x890C = SIOCDELRT" ); | ||
230 | map->insert( 0x890C, new QString("SIOCDELRT") ); | ||
231 | qDebug( "adding 0x890D = SIOCRTMSG" ); | ||
232 | map->insert( 0x890D, new QString("SIOCRTMSG") ); | ||
233 | qDebug( "adding 0x8910 = SIOCGIFNAME" ); | ||
234 | map->insert( 0x8910, new QString("SIOCGIFNAME") ); | ||
235 | qDebug( "adding 0x8911 = SIOCSIFLINK" ); | ||
236 | map->insert( 0x8911, new QString("SIOCSIFLINK") ); | ||
237 | qDebug( "adding 0x8912 = SIOCGIFCONF" ); | ||
238 | map->insert( 0x8912, new QString("SIOCGIFCONF") ); | ||
239 | qDebug( "adding 0x8913 = SIOCGIFFLAGS" ); | ||
240 | map->insert( 0x8913, new QString("SIOCGIFFLAGS") ); | ||
241 | qDebug( "adding 0x8914 = SIOCSIFFLAGS" ); | ||
242 | map->insert( 0x8914, new QString("SIOCSIFFLAGS") ); | ||
243 | qDebug( "adding 0x8915 = SIOCGIFADDR" ); | ||
244 | map->insert( 0x8915, new QString("SIOCGIFADDR") ); | ||
245 | qDebug( "adding 0x8916 = SIOCSIFADDR" ); | ||
246 | map->insert( 0x8916, new QString("SIOCSIFADDR") ); | ||
247 | qDebug( "adding 0x8917 = SIOCGIFDSTADDR" ); | ||
248 | map->insert( 0x8917, new QString("SIOCGIFDSTADDR") ); | ||
249 | qDebug( "adding 0x8918 = SIOCSIFDSTADDR" ); | ||
250 | map->insert( 0x8918, new QString("SIOCSIFDSTADDR") ); | ||
251 | qDebug( "adding 0x8919 = SIOCGIFBRDADDR" ); | ||
252 | map->insert( 0x8919, new QString("SIOCGIFBRDADDR") ); | ||
253 | qDebug( "adding 0x891a = SIOCSIFBRDADDR" ); | ||
254 | map->insert( 0x891a, new QString("SIOCSIFBRDADDR") ); | ||
255 | qDebug( "adding 0x891b = SIOCGIFNETMASK" ); | ||
256 | map->insert( 0x891b, new QString("SIOCGIFNETMASK") ); | ||
257 | qDebug( "adding 0x891c = SIOCSIFNETMASK" ); | ||
258 | map->insert( 0x891c, new QString("SIOCSIFNETMASK") ); | ||
259 | qDebug( "adding 0x891d = SIOCGIFMETRIC" ); | ||
260 | map->insert( 0x891d, new QString("SIOCGIFMETRIC") ); | ||
261 | qDebug( "adding 0x891e = SIOCSIFMETRIC" ); | ||
262 | map->insert( 0x891e, new QString("SIOCSIFMETRIC") ); | ||
263 | qDebug( "adding 0x891f = SIOCGIFMEM" ); | ||
264 | map->insert( 0x891f, new QString("SIOCGIFMEM") ); | ||
265 | qDebug( "adding 0x8920 = SIOCSIFMEM" ); | ||
266 | map->insert( 0x8920, new QString("SIOCSIFMEM") ); | ||
267 | qDebug( "adding 0x8921 = SIOCGIFMTU" ); | ||
268 | map->insert( 0x8921, new QString("SIOCGIFMTU") ); | ||
269 | qDebug( "adding 0x8922 = SIOCSIFMTU" ); | ||
270 | map->insert( 0x8922, new QString("SIOCSIFMTU") ); | ||
271 | qDebug( "adding 0x8923 = SIOCSIFNAME" ); | ||
272 | map->insert( 0x8923, new QString("SIOCSIFNAME") ); | ||
273 | qDebug( "adding 0x8924 = SIOCSIFHWADDR" ); | ||
274 | map->insert( 0x8924, new QString("SIOCSIFHWADDR") ); | ||
275 | qDebug( "adding 0x8925 = SIOCGIFENCAP" ); | ||
276 | map->insert( 0x8925, new QString("SIOCGIFENCAP") ); | ||
277 | qDebug( "adding 0x8926 = SIOCSIFENCAP" ); | ||
278 | map->insert( 0x8926, new QString("SIOCSIFENCAP") ); | ||
279 | qDebug( "adding 0x8927 = SIOCGIFHWADDR" ); | ||
280 | map->insert( 0x8927, new QString("SIOCGIFHWADDR") ); | ||
281 | qDebug( "adding 0x8929 = SIOCGIFSLAVE" ); | ||
282 | map->insert( 0x8929, new QString("SIOCGIFSLAVE") ); | ||
283 | qDebug( "adding 0x8930 = SIOCSIFSLAVE" ); | ||
284 | map->insert( 0x8930, new QString("SIOCSIFSLAVE") ); | ||
285 | qDebug( "adding 0x8931 = SIOCADDMULTI" ); | ||
286 | map->insert( 0x8931, new QString("SIOCADDMULTI") ); | ||
287 | qDebug( "adding 0x8932 = SIOCDELMULTI" ); | ||
288 | map->insert( 0x8932, new QString("SIOCDELMULTI") ); | ||
289 | qDebug( "adding 0x8933 = SIOCGIFINDEX" ); | ||
290 | map->insert( 0x8933, new QString("SIOCGIFINDEX") ); | ||
291 | qDebug( "adding 0x8934 = SIOCSIFPFLAGS" ); | ||
292 | map->insert( 0x8934, new QString("SIOCSIFPFLAGS") ); | ||
293 | qDebug( "adding 0x8935 = SIOCGIFPFLAGS" ); | ||
294 | map->insert( 0x8935, new QString("SIOCGIFPFLAGS") ); | ||
295 | qDebug( "adding 0x8936 = SIOCDIFADDR" ); | ||
296 | map->insert( 0x8936, new QString("SIOCDIFADDR") ); | ||
297 | qDebug( "adding 0x8937 = SIOCSIFHWBROADCAST" ); | ||
298 | map->insert( 0x8937, new QString("SIOCSIFHWBROADCAST") ); | ||
299 | qDebug( "adding 0x8938 = SIOCGIFCOUNT" ); | ||
300 | map->insert( 0x8938, new QString("SIOCGIFCOUNT") ); | ||
301 | qDebug( "adding 0x8940 = SIOCGIFBR" ); | ||
302 | map->insert( 0x8940, new QString("SIOCGIFBR") ); | ||
303 | qDebug( "adding 0x8941 = SIOCSIFBR" ); | ||
304 | map->insert( 0x8941, new QString("SIOCSIFBR") ); | ||
305 | qDebug( "adding 0x8942 = SIOCGIFTXQLEN" ); | ||
306 | map->insert( 0x8942, new QString("SIOCGIFTXQLEN") ); | ||
307 | qDebug( "adding 0x8943 = SIOCSIFTXQLEN" ); | ||
308 | map->insert( 0x8943, new QString("SIOCSIFTXQLEN") ); | ||
309 | qDebug( "adding 0x8944 = SIOCGIFDIVERT" ); | ||
310 | map->insert( 0x8944, new QString("SIOCGIFDIVERT") ); | ||
311 | qDebug( "adding 0x8945 = SIOCSIFDIVERT" ); | ||
312 | map->insert( 0x8945, new QString("SIOCSIFDIVERT") ); | ||
313 | qDebug( "adding 0x8946 = SIOCETHTOOL" ); | ||
314 | map->insert( 0x8946, new QString("SIOCETHTOOL") ); | ||
315 | qDebug( "adding 0x8947 = SIOCGMIIPHY" ); | ||
316 | map->insert( 0x8947, new QString("SIOCGMIIPHY") ); | ||
317 | qDebug( "adding 0x8948 = SIOCGMIIREG" ); | ||
318 | map->insert( 0x8948, new QString("SIOCGMIIREG") ); | ||
319 | qDebug( "adding 0x8949 = SIOCSMIIREG" ); | ||
320 | map->insert( 0x8949, new QString("SIOCSMIIREG") ); | ||
321 | qDebug( "adding 0x894A = SIOCWANDEV" ); | ||
322 | map->insert( 0x894A, new QString("SIOCWANDEV") ); | ||
323 | qDebug( "adding 0x8953 = SIOCDARP" ); | ||
324 | map->insert( 0x8953, new QString("SIOCDARP") ); | ||
325 | qDebug( "adding 0x8954 = SIOCGARP" ); | ||
326 | map->insert( 0x8954, new QString("SIOCGARP") ); | ||
327 | qDebug( "adding 0x8955 = SIOCSARP" ); | ||
328 | map->insert( 0x8955, new QString("SIOCSARP") ); | ||
329 | qDebug( "adding 0x8960 = SIOCDRARP" ); | ||
330 | map->insert( 0x8960, new QString("SIOCDRARP") ); | ||
331 | qDebug( "adding 0x8961 = SIOCGRARP" ); | ||
332 | map->insert( 0x8961, new QString("SIOCGRARP") ); | ||
333 | qDebug( "adding 0x8962 = SIOCSRARP" ); | ||
334 | map->insert( 0x8962, new QString("SIOCSRARP") ); | ||
335 | qDebug( "adding 0x8970 = SIOCGIFMAP" ); | ||
336 | map->insert( 0x8970, new QString("SIOCGIFMAP") ); | ||
337 | qDebug( "adding 0x8971 = SIOCSIFMAP" ); | ||
338 | map->insert( 0x8971, new QString("SIOCSIFMAP") ); | ||
339 | qDebug( "adding 0x8980 = SIOCADDDLCI" ); | ||
340 | map->insert( 0x8980, new QString("SIOCADDDLCI") ); | ||
341 | qDebug( "adding 0x8981 = SIOCDELDLCI" ); | ||
342 | map->insert( 0x8981, new QString("SIOCDELDLCI") ); | ||
343 | qDebug( "adding 0x8982 = SIOCGIFVLAN" ); | ||
344 | map->insert( 0x8982, new QString("SIOCGIFVLAN") ); | ||
345 | qDebug( "adding 0x8983 = SIOCSIFVLAN" ); | ||
346 | map->insert( 0x8983, new QString("SIOCSIFVLAN") ); | ||
347 | qDebug( "adding 0x8990 = SIOCBONDENSLAVE" ); | ||
348 | map->insert( 0x8990, new QString("SIOCBONDENSLAVE") ); | ||
349 | qDebug( "adding 0x8991 = SIOCBONDRELEASE" ); | ||
350 | map->insert( 0x8991, new QString("SIOCBONDRELEASE") ); | ||
351 | qDebug( "adding 0x8992 = SIOCBONDSETHWADDR" ); | ||
352 | map->insert( 0x8992, new QString("SIOCBONDSETHWADDR") ); | ||
353 | qDebug( "adding 0x8993 = SIOCBONDSLAVEINFOQUERY" ); | ||
354 | map->insert( 0x8993, new QString("SIOCBONDSLAVEINFOQUERY") ); | ||
355 | qDebug( "adding 0x8994 = SIOCBONDINFOQUERY" ); | ||
356 | map->insert( 0x8994, new QString("SIOCBONDINFOQUERY") ); | ||
357 | qDebug( "adding 0x8995 = SIOCBONDCHANGEACTIVE" ); | ||
358 | map->insert( 0x8995, new QString("SIOCBONDCHANGEACTIVE") ); | ||
359 | qDebug( "adding 0x89F0 = SIOCDEVPRIVATE" ); | ||
360 | map->insert( 0x89F0, new QString("SIOCDEVPRIVATE") ); | ||
361 | qDebug( "adding 0x89E0 = SIOCPROTOPRIVATE" ); | ||
362 | map->insert( 0x89E0, new QString("SIOCPROTOPRIVATE") ); | ||
363 | |||
364 | return map; | ||
365 | }; | ||
366 | |||
diff --git a/libopie2/opienet/oioctlmap.h b/libopie2/opienet/oioctlmap.h new file mode 100644 index 0000000..1cd89a3 --- a/dev/null +++ b/libopie2/opienet/oioctlmap.h | |||
@@ -0,0 +1,17 @@ | |||
1 | |||
2 | /* | ||
3 | * ioctl table - generated by regen.py - (C) Michael 'Mickey' Lauer <mickey@vanille.de> | ||
4 | */ | ||
5 | |||
6 | #ifndef IOCTLMAP_H | ||
7 | #define IOCTLMAP_H | ||
8 | |||
9 | #include <qstring.h> | ||
10 | #include <qintdict.h> | ||
11 | |||
12 | typedef QIntDict<QString> IntStringMap; | ||
13 | |||
14 | IntStringMap* constructIoctlMap(); | ||
15 | |||
16 | #endif | ||
17 | |||
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp index be45924..918ba07 100644 --- a/libopie2/opienet/onetwork.cpp +++ b/libopie2/opienet/onetwork.cpp | |||
@@ -1,1129 +1,1142 @@ | |||
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 | /* OPIE */ | 34 | /* OPIE */ |
35 | 35 | ||
36 | #include <opie2/onetwork.h> | 36 | #include <opie2/onetwork.h> |
37 | 37 | ||
38 | /* QT */ | 38 | /* QT */ |
39 | 39 | ||
40 | #include <qfile.h> | 40 | #include <qfile.h> |
41 | #include <qtextstream.h> | 41 | #include <qtextstream.h> |
42 | 42 | ||
43 | /* UNIX */ | 43 | /* UNIX */ |
44 | 44 | ||
45 | #include <assert.h> | 45 | #include <assert.h> |
46 | #include <arpa/inet.h> | 46 | #include <arpa/inet.h> |
47 | #include <cerrno> | 47 | #include <cerrno> |
48 | #include <cstring> | 48 | #include <cstring> |
49 | #include <cstdlib> | 49 | #include <cstdlib> |
50 | #include <math.h> | 50 | #include <math.h> |
51 | #include <sys/ioctl.h> | 51 | #include <sys/ioctl.h> |
52 | #include <sys/socket.h> | 52 | #include <sys/socket.h> |
53 | #include <sys/types.h> | 53 | #include <sys/types.h> |
54 | #include <unistd.h> | 54 | #include <unistd.h> |
55 | #include <linux/sockios.h> | 55 | #include <linux/sockios.h> |
56 | #include <net/if_arp.h> | 56 | #include <net/if_arp.h> |
57 | #include <stdarg.h> | 57 | #include <stdarg.h> |
58 | 58 | ||
59 | using namespace std; | 59 | using namespace std; |
60 | 60 | ||
61 | #ifndef NODEBUG | ||
62 | #include <opie2/oioctlmap.h> | ||
63 | IntStringMap* _ioctlmap = constructIoctlMap(); | ||
64 | #endif | ||
65 | |||
61 | /*====================================================================================== | 66 | /*====================================================================================== |
62 | * ONetwork | 67 | * ONetwork |
63 | *======================================================================================*/ | 68 | *======================================================================================*/ |
64 | 69 | ||
65 | ONetwork* ONetwork::_instance = 0; | 70 | ONetwork* ONetwork::_instance = 0; |
66 | 71 | ||
67 | ONetwork::ONetwork() | 72 | ONetwork::ONetwork() |
68 | { | 73 | { |
69 | qDebug( "ONetwork::ONetwork()" ); | 74 | qDebug( "ONetwork::ONetwork()" ); |
70 | qDebug( "ONetwork: This code has been compiled against Wireless Extensions V%d", WIRELESS_EXT ); | 75 | qDebug( "ONetwork: This code has been compiled against Wireless Extensions V%d", WIRELESS_EXT ); |
71 | synchronize(); | 76 | synchronize(); |
72 | } | 77 | } |
73 | 78 | ||
74 | void ONetwork::synchronize() | 79 | void ONetwork::synchronize() |
75 | { | 80 | { |
76 | // gather available interfaces by inspecting /proc/net/dev | 81 | // gather available interfaces by inspecting /proc/net/dev |
77 | //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices | 82 | //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices |
78 | //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices | 83 | //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices |
79 | //FIXME: Best is use SIOCGIFCONF and if this doesn't work (result=-1), then fallback to parsing /proc/net/dev | 84 | //FIXME: Best is use SIOCGIFCONF and if this doesn't work (result=-1), then fallback to parsing /proc/net/dev |
80 | 85 | ||
81 | _interfaces.clear(); | 86 | _interfaces.clear(); |
82 | QString str; | 87 | QString str; |
83 | QFile f( "/proc/net/dev" ); | 88 | QFile f( "/proc/net/dev" ); |
84 | bool hasFile = f.open( IO_ReadOnly ); | 89 | bool hasFile = f.open( IO_ReadOnly ); |
85 | if ( !hasFile ) | 90 | if ( !hasFile ) |
86 | { | 91 | { |
87 | qDebug( "ONetwork: /proc/net/dev not existing. No network devices available" ); | 92 | qDebug( "ONetwork: /proc/net/dev not existing. No network devices available" ); |
88 | return; | 93 | return; |
89 | } | 94 | } |
90 | QTextStream s( &f ); | 95 | QTextStream s( &f ); |
91 | s.readLine(); | 96 | s.readLine(); |
92 | s.readLine(); | 97 | s.readLine(); |
93 | while ( !s.atEnd() ) | 98 | while ( !s.atEnd() ) |
94 | { | 99 | { |
95 | s >> str; | 100 | s >> str; |
96 | str.truncate( str.find( ':' ) ); | 101 | str.truncate( str.find( ':' ) ); |
97 | qDebug( "ONetwork: found interface '%s'", (const char*) str ); | 102 | qDebug( "ONetwork: found interface '%s'", (const char*) str ); |
98 | ONetworkInterface* iface; | 103 | ONetworkInterface* iface; |
99 | if ( isWirelessInterface( str ) ) | 104 | if ( isWirelessInterface( str ) ) |
100 | { | 105 | { |
101 | iface = new OWirelessNetworkInterface( this, (const char*) str ); | 106 | iface = new OWirelessNetworkInterface( this, (const char*) str ); |
102 | qDebug( "ONetwork: interface '%s' has Wireless Extensions", (const char*) str ); | 107 | qDebug( "ONetwork: interface '%s' has Wireless Extensions", (const char*) str ); |
103 | } | 108 | } |
104 | else | 109 | else |
105 | { | 110 | { |
106 | iface = new ONetworkInterface( this, (const char*) str ); | 111 | iface = new ONetworkInterface( this, (const char*) str ); |
107 | } | 112 | } |
108 | _interfaces.insert( str, iface ); | 113 | _interfaces.insert( str, iface ); |
109 | s.readLine(); | 114 | s.readLine(); |
110 | } | 115 | } |
111 | } | 116 | } |
112 | 117 | ||
113 | 118 | ||
114 | short ONetwork::wirelessExtensionVersion() | 119 | short ONetwork::wirelessExtensionVersion() |
115 | { | 120 | { |
116 | return WIRELESS_EXT; | 121 | return WIRELESS_EXT; |
117 | } | 122 | } |
118 | 123 | ||
119 | 124 | ||
120 | int ONetwork::count() const | 125 | int ONetwork::count() const |
121 | { | 126 | { |
122 | return _interfaces.count(); | 127 | return _interfaces.count(); |
123 | } | 128 | } |
124 | 129 | ||
125 | 130 | ||
126 | ONetworkInterface* ONetwork::interface( const QString& iface ) const | 131 | ONetworkInterface* ONetwork::interface( const QString& iface ) const |
127 | { | 132 | { |
128 | return _interfaces[iface]; | 133 | return _interfaces[iface]; |
129 | } | 134 | } |
130 | 135 | ||
131 | 136 | ||
132 | ONetwork* ONetwork::instance() | 137 | ONetwork* ONetwork::instance() |
133 | { | 138 | { |
134 | if ( !_instance ) _instance = new ONetwork(); | 139 | if ( !_instance ) _instance = new ONetwork(); |
135 | return _instance; | 140 | return _instance; |
136 | } | 141 | } |
137 | 142 | ||
138 | 143 | ||
139 | ONetwork::InterfaceIterator ONetwork::iterator() const | 144 | ONetwork::InterfaceIterator ONetwork::iterator() const |
140 | { | 145 | { |
141 | return ONetwork::InterfaceIterator( _interfaces ); | 146 | return ONetwork::InterfaceIterator( _interfaces ); |
142 | } | 147 | } |
143 | 148 | ||
144 | 149 | ||
145 | bool ONetwork::isWirelessInterface( const char* name ) const | 150 | bool ONetwork::isWirelessInterface( const char* name ) const |
146 | { | 151 | { |
147 | int sfd = socket( AF_INET, SOCK_STREAM, 0 ); | 152 | int sfd = socket( AF_INET, SOCK_STREAM, 0 ); |
148 | struct iwreq iwr; | 153 | struct iwreq iwr; |
149 | memset( &iwr, 0, sizeof( struct iwreq ) ); | 154 | memset( &iwr, 0, sizeof( struct iwreq ) ); |
150 | strcpy( (char*) &iwr.ifr_name, name ); | 155 | strcpy( (char*) &iwr.ifr_name, name ); |
151 | int result = ::ioctl( sfd, SIOCGIWNAME, &iwr ); | 156 | int result = ::ioctl( sfd, SIOCGIWNAME, &iwr ); |
152 | return result != -1; | 157 | return result != -1; |
153 | } | 158 | } |
154 | 159 | ||
155 | /*====================================================================================== | 160 | /*====================================================================================== |
156 | * ONetworkInterface | 161 | * ONetworkInterface |
157 | *======================================================================================*/ | 162 | *======================================================================================*/ |
158 | 163 | ||
159 | ONetworkInterface::ONetworkInterface( QObject* parent, const char* name ) | 164 | ONetworkInterface::ONetworkInterface( QObject* parent, const char* name ) |
160 | :QObject( parent, name ), | 165 | :QObject( parent, name ), |
161 | _sfd( socket( AF_INET, SOCK_DGRAM, 0 ) ), _mon( 0 ) | 166 | _sfd( socket( AF_INET, SOCK_DGRAM, 0 ) ), _mon( 0 ) |
162 | { | 167 | { |
163 | qDebug( "ONetworkInterface::ONetworkInterface()" ); | 168 | qDebug( "ONetworkInterface::ONetworkInterface()" ); |
164 | init(); | 169 | init(); |
165 | } | 170 | } |
166 | 171 | ||
167 | 172 | ||
168 | struct ifreq& ONetworkInterface::ifr() const | 173 | struct ifreq& ONetworkInterface::ifr() const |
169 | { | 174 | { |
170 | return _ifr; | 175 | return _ifr; |
171 | } | 176 | } |
172 | 177 | ||
173 | 178 | ||
174 | void ONetworkInterface::init() | 179 | void ONetworkInterface::init() |
175 | { | 180 | { |
176 | qDebug( "ONetworkInterface::init()" ); | 181 | qDebug( "ONetworkInterface::init()" ); |
177 | 182 | ||
178 | memset( &_ifr, 0, sizeof( struct ifreq ) ); | 183 | memset( &_ifr, 0, sizeof( struct ifreq ) ); |
179 | 184 | ||
180 | if ( _sfd == -1 ) | 185 | if ( _sfd == -1 ) |
181 | { | 186 | { |
182 | qDebug( "ONetworkInterface::init(): Warning - can't get socket for device '%s'", name() ); | 187 | qDebug( "ONetworkInterface::init(): Warning - can't get socket for device '%s'", name() ); |
183 | return; | 188 | return; |
184 | } | 189 | } |
185 | } | 190 | } |
186 | 191 | ||
187 | 192 | ||
188 | bool ONetworkInterface::ioctl( int call, struct ifreq& ifreq ) const | 193 | bool ONetworkInterface::ioctl( int call, struct ifreq& ifreq ) const |
189 | { | 194 | { |
195 | #ifndef NODEBUG | ||
190 | int result = ::ioctl( _sfd, call, &ifreq ); | 196 | int result = ::ioctl( _sfd, call, &ifreq ); |
191 | if ( result == -1 ) | 197 | if ( result == -1 ) |
192 | qDebug( "ONetworkInterface::ioctl (%s) call %d (0x%04X) - Status: Failed: %d (%s)", name(), call, call, result, strerror( errno ) ); | 198 | qDebug( "ONetworkInterface::ioctl (%s) call %s (0x%04X) - Status: Failed: %d (%s)", name(), (const char*) *(*_ioctlmap)[call], call, result, strerror( errno ) ); |
193 | else | 199 | else |
194 | qDebug( "ONetworkInterface::ioctl (%s) call %d (0x%04X) - Status: Ok.", name(), call, call ); | 200 | qDebug( "ONetworkInterface::ioctl (%s) call %s (0x%04X) - Status: Ok.", name(), (const char*) *(*_ioctlmap)[call], call ); |
195 | return ( result != -1 ); | 201 | return ( result != -1 ); |
202 | #else | ||
203 | return ::ioctl( _sfd, call, &ifreq ) != -1; | ||
204 | #endif | ||
196 | } | 205 | } |
197 | 206 | ||
198 | 207 | ||
199 | bool ONetworkInterface::ioctl( int call ) const | 208 | bool ONetworkInterface::ioctl( int call ) const |
200 | { | 209 | { |
201 | strcpy( _ifr.ifr_name, name() ); | 210 | strcpy( _ifr.ifr_name, name() ); |
202 | return ioctl( call, _ifr ); | 211 | return ioctl( call, _ifr ); |
203 | } | 212 | } |
204 | 213 | ||
205 | 214 | ||
206 | bool ONetworkInterface::isLoopback() const | 215 | bool ONetworkInterface::isLoopback() const |
207 | { | 216 | { |
208 | ioctl( SIOCGIFFLAGS ); | 217 | ioctl( SIOCGIFFLAGS ); |
209 | return _ifr.ifr_flags & IFF_LOOPBACK; | 218 | return _ifr.ifr_flags & IFF_LOOPBACK; |
210 | } | 219 | } |
211 | 220 | ||
212 | 221 | ||
213 | bool ONetworkInterface::setUp( bool b ) | 222 | bool ONetworkInterface::setUp( bool b ) |
214 | { | 223 | { |
215 | ioctl( SIOCGIFFLAGS ); | 224 | ioctl( SIOCGIFFLAGS ); |
216 | if ( b ) _ifr.ifr_flags |= IFF_UP; | 225 | if ( b ) _ifr.ifr_flags |= IFF_UP; |
217 | else _ifr.ifr_flags &= (~IFF_UP); | 226 | else _ifr.ifr_flags &= (~IFF_UP); |
218 | return ioctl( SIOCSIFFLAGS ); | 227 | return ioctl( SIOCSIFFLAGS ); |
219 | } | 228 | } |
220 | 229 | ||
221 | 230 | ||
222 | bool ONetworkInterface::isUp() const | 231 | bool ONetworkInterface::isUp() const |
223 | { | 232 | { |
224 | ioctl( SIOCGIFFLAGS ); | 233 | ioctl( SIOCGIFFLAGS ); |
225 | return _ifr.ifr_flags & IFF_UP; | 234 | return _ifr.ifr_flags & IFF_UP; |
226 | } | 235 | } |
227 | 236 | ||
228 | 237 | ||
229 | void ONetworkInterface::setIPV4Address( const QHostAddress& addr ) | 238 | void ONetworkInterface::setIPV4Address( const QHostAddress& addr ) |
230 | { | 239 | { |
231 | struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr; | 240 | struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr; |
232 | sa->sin_family = AF_INET; | 241 | sa->sin_family = AF_INET; |
233 | sa->sin_port = 0; | 242 | sa->sin_port = 0; |
234 | sa->sin_addr.s_addr = htonl( addr.ip4Addr() ); | 243 | sa->sin_addr.s_addr = htonl( addr.ip4Addr() ); |
235 | ioctl( SIOCSIFADDR ); | 244 | ioctl( SIOCSIFADDR ); |
236 | } | 245 | } |
237 | 246 | ||
238 | 247 | ||
239 | QString ONetworkInterface::ipV4Address() const | 248 | QString ONetworkInterface::ipV4Address() const |
240 | { | 249 | { |
241 | if ( ioctl( SIOCGIFADDR ) ) | 250 | if ( ioctl( SIOCGIFADDR ) ) |
242 | { | 251 | { |
243 | struct sockaddr_in* sa = (struct sockaddr_in *) &_ifr.ifr_addr; | 252 | struct sockaddr_in* sa = (struct sockaddr_in *) &_ifr.ifr_addr; |
244 | //FIXME: Use QHostAddress here | 253 | //FIXME: Use QHostAddress here |
245 | return QString( inet_ntoa( sa->sin_addr ) ); | 254 | return QString( inet_ntoa( sa->sin_addr ) ); |
246 | } | 255 | } |
247 | else | 256 | else |
248 | return "<unknown>"; | 257 | return "<unknown>"; |
249 | } | 258 | } |
250 | 259 | ||
251 | 260 | ||
252 | void ONetworkInterface::setMacAddress( const OMacAddress& addr ) | 261 | void ONetworkInterface::setMacAddress( const OMacAddress& addr ) |
253 | { | 262 | { |
254 | _ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER; | 263 | _ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER; |
255 | memcpy( &_ifr.ifr_hwaddr.sa_data, addr.native(), 6 ); | 264 | memcpy( &_ifr.ifr_hwaddr.sa_data, addr.native(), 6 ); |
256 | ioctl( SIOCSIFHWADDR ); | 265 | ioctl( SIOCSIFHWADDR ); |
257 | } | 266 | } |
258 | 267 | ||
259 | 268 | ||
260 | OMacAddress ONetworkInterface::macAddress() const | 269 | OMacAddress ONetworkInterface::macAddress() const |
261 | { | 270 | { |
262 | if ( ioctl( SIOCGIFHWADDR ) ) | 271 | if ( ioctl( SIOCGIFHWADDR ) ) |
263 | { | 272 | { |
264 | return OMacAddress( _ifr ); | 273 | return OMacAddress( _ifr ); |
265 | } | 274 | } |
266 | else | 275 | else |
267 | { | 276 | { |
268 | return OMacAddress::unknown; | 277 | return OMacAddress::unknown; |
269 | } | 278 | } |
270 | } | 279 | } |
271 | 280 | ||
272 | 281 | ||
273 | void ONetworkInterface::setIPV4Netmask( const QHostAddress& addr ) | 282 | void ONetworkInterface::setIPV4Netmask( const QHostAddress& addr ) |
274 | { | 283 | { |
275 | struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr; | 284 | struct sockaddr_in *sa = (struct sockaddr_in *) &_ifr.ifr_addr; |
276 | sa->sin_family = AF_INET; | 285 | sa->sin_family = AF_INET; |
277 | sa->sin_port = 0; | 286 | sa->sin_port = 0; |
278 | sa->sin_addr.s_addr = htonl( addr.ip4Addr() ); | 287 | sa->sin_addr.s_addr = htonl( addr.ip4Addr() ); |
279 | ioctl( SIOCSIFNETMASK ); | 288 | ioctl( SIOCSIFNETMASK ); |
280 | } | 289 | } |
281 | 290 | ||
282 | 291 | ||
283 | QString ONetworkInterface::ipV4Netmask() const | 292 | QString ONetworkInterface::ipV4Netmask() const |
284 | { | 293 | { |
285 | if ( ioctl( SIOCGIFNETMASK ) ) | 294 | if ( ioctl( SIOCGIFNETMASK ) ) |
286 | { | 295 | { |
287 | struct sockaddr_in* sa = (struct sockaddr_in *) &_ifr.ifr_addr; | 296 | struct sockaddr_in* sa = (struct sockaddr_in *) &_ifr.ifr_addr; |
288 | //FIXME: Use QHostAddress here | 297 | //FIXME: Use QHostAddress here |
289 | return QString( inet_ntoa( sa->sin_addr ) ); | 298 | return QString( inet_ntoa( sa->sin_addr ) ); |
290 | } | 299 | } |
291 | else | 300 | else |
292 | return "<unknown>"; | 301 | return "<unknown>"; |
293 | } | 302 | } |
294 | 303 | ||
295 | 304 | ||
296 | int ONetworkInterface::dataLinkType() const | 305 | int ONetworkInterface::dataLinkType() const |
297 | { | 306 | { |
298 | if ( ioctl( SIOCGIFHWADDR ) ) | 307 | if ( ioctl( SIOCGIFHWADDR ) ) |
299 | { | 308 | { |
300 | return _ifr.ifr_hwaddr.sa_family; | 309 | return _ifr.ifr_hwaddr.sa_family; |
301 | } | 310 | } |
302 | else | 311 | else |
303 | { | 312 | { |
304 | return -1; | 313 | return -1; |
305 | } | 314 | } |
306 | } | 315 | } |
307 | 316 | ||
308 | 317 | ||
309 | void ONetworkInterface::setMonitoring( OMonitoringInterface* m ) | 318 | void ONetworkInterface::setMonitoring( OMonitoringInterface* m ) |
310 | { | 319 | { |
311 | _mon = m; | 320 | _mon = m; |
312 | qDebug( "ONetwork::setMonitoring(): Installed monitoring driver '%s' on interface '%s'", (const char*) m->name(), name() ); | 321 | qDebug( "ONetwork::setMonitoring(): Installed monitoring driver '%s' on interface '%s'", (const char*) m->name(), name() ); |
313 | } | 322 | } |
314 | 323 | ||
315 | 324 | ||
316 | OMonitoringInterface* ONetworkInterface::monitoring() const | 325 | OMonitoringInterface* ONetworkInterface::monitoring() const |
317 | { | 326 | { |
318 | return _mon; | 327 | return _mon; |
319 | } | 328 | } |
320 | 329 | ||
321 | 330 | ||
322 | ONetworkInterface::~ONetworkInterface() | 331 | ONetworkInterface::~ONetworkInterface() |
323 | { | 332 | { |
324 | qDebug( "ONetworkInterface::~ONetworkInterface()" ); | 333 | qDebug( "ONetworkInterface::~ONetworkInterface()" ); |
325 | if ( _sfd != -1 ) ::close( _sfd ); | 334 | if ( _sfd != -1 ) ::close( _sfd ); |
326 | } | 335 | } |
327 | 336 | ||
328 | 337 | ||
329 | bool ONetworkInterface::setPromiscuousMode( bool b ) | 338 | bool ONetworkInterface::setPromiscuousMode( bool b ) |
330 | { | 339 | { |
331 | ioctl( SIOCGIFFLAGS ); | 340 | ioctl( SIOCGIFFLAGS ); |
332 | if ( b ) _ifr.ifr_flags |= IFF_PROMISC; | 341 | if ( b ) _ifr.ifr_flags |= IFF_PROMISC; |
333 | else _ifr.ifr_flags &= (~IFF_PROMISC); | 342 | else _ifr.ifr_flags &= (~IFF_PROMISC); |
334 | return ioctl( SIOCSIFFLAGS ); | 343 | return ioctl( SIOCSIFFLAGS ); |
335 | } | 344 | } |
336 | 345 | ||
337 | 346 | ||
338 | bool ONetworkInterface::promiscuousMode() const | 347 | bool ONetworkInterface::promiscuousMode() const |
339 | { | 348 | { |
340 | ioctl( SIOCGIFFLAGS ); | 349 | ioctl( SIOCGIFFLAGS ); |
341 | return _ifr.ifr_flags & IFF_PROMISC; | 350 | return _ifr.ifr_flags & IFF_PROMISC; |
342 | } | 351 | } |
343 | 352 | ||
344 | 353 | ||
345 | bool ONetworkInterface::isWireless() const | 354 | bool ONetworkInterface::isWireless() const |
346 | { | 355 | { |
347 | return ioctl( SIOCGIWNAME ); | 356 | return ioctl( SIOCGIWNAME ); |
348 | } | 357 | } |
349 | 358 | ||
350 | 359 | ||
351 | /*====================================================================================== | 360 | /*====================================================================================== |
352 | * OChannelHopper | 361 | * OChannelHopper |
353 | *======================================================================================*/ | 362 | *======================================================================================*/ |
354 | 363 | ||
355 | OChannelHopper::OChannelHopper( OWirelessNetworkInterface* iface ) | 364 | OChannelHopper::OChannelHopper( OWirelessNetworkInterface* iface ) |
356 | :QObject( 0, "Mickey's funky hopper" ), | 365 | :QObject( 0, "Mickey's funky hopper" ), |
357 | _iface( iface ), _interval( 0 ), _tid( 0 ) | 366 | _iface( iface ), _interval( 0 ), _tid( 0 ) |
358 | { | 367 | { |
359 | int _maxChannel = iface->channels()+1; | 368 | int _maxChannel = iface->channels()+1; |
360 | // generate fancy hopping sequence honoring the device capabilities | 369 | // generate fancy hopping sequence honoring the device capabilities |
361 | if ( _maxChannel >= 1 ) _channels.append( 1 ); | 370 | if ( _maxChannel >= 1 ) _channels.append( 1 ); |
362 | if ( _maxChannel >= 7 ) _channels.append( 7 ); | 371 | if ( _maxChannel >= 7 ) _channels.append( 7 ); |
363 | if ( _maxChannel >= 13 ) _channels.append( 13 ); | 372 | if ( _maxChannel >= 13 ) _channels.append( 13 ); |
364 | if ( _maxChannel >= 2 ) _channels.append( 2 ); | 373 | if ( _maxChannel >= 2 ) _channels.append( 2 ); |
365 | if ( _maxChannel >= 8 ) _channels.append( 8 ); | 374 | if ( _maxChannel >= 8 ) _channels.append( 8 ); |
366 | if ( _maxChannel >= 3 ) _channels.append( 3 ); | 375 | if ( _maxChannel >= 3 ) _channels.append( 3 ); |
367 | if ( _maxChannel >= 14 ) _channels.append( 14 ); | 376 | if ( _maxChannel >= 14 ) _channels.append( 14 ); |
368 | if ( _maxChannel >= 9 ) _channels.append( 9 ); | 377 | if ( _maxChannel >= 9 ) _channels.append( 9 ); |
369 | if ( _maxChannel >= 4 ) _channels.append( 4 ); | 378 | if ( _maxChannel >= 4 ) _channels.append( 4 ); |
370 | if ( _maxChannel >= 10 ) _channels.append( 10 ); | 379 | if ( _maxChannel >= 10 ) _channels.append( 10 ); |
371 | if ( _maxChannel >= 5 ) _channels.append( 5 ); | 380 | if ( _maxChannel >= 5 ) _channels.append( 5 ); |
372 | if ( _maxChannel >= 11 ) _channels.append( 11 ); | 381 | if ( _maxChannel >= 11 ) _channels.append( 11 ); |
373 | if ( _maxChannel >= 6 ) _channels.append( 6 ); | 382 | if ( _maxChannel >= 6 ) _channels.append( 6 ); |
374 | if ( _maxChannel >= 12 ) _channels.append( 12 ); | 383 | if ( _maxChannel >= 12 ) _channels.append( 12 ); |
375 | _channel = _channels.begin(); | 384 | _channel = _channels.begin(); |
376 | 385 | ||
377 | } | 386 | } |
378 | 387 | ||
379 | 388 | ||
380 | OChannelHopper::~OChannelHopper() | 389 | OChannelHopper::~OChannelHopper() |
381 | { | 390 | { |
382 | } | 391 | } |
383 | 392 | ||
384 | 393 | ||
385 | bool OChannelHopper::isActive() const | 394 | bool OChannelHopper::isActive() const |
386 | { | 395 | { |
387 | return _tid; | 396 | return _tid; |
388 | } | 397 | } |
389 | 398 | ||
390 | 399 | ||
391 | int OChannelHopper::channel() const | 400 | int OChannelHopper::channel() const |
392 | { | 401 | { |
393 | return *_channel; | 402 | return *_channel; |
394 | } | 403 | } |
395 | 404 | ||
396 | 405 | ||
397 | void OChannelHopper::timerEvent( QTimerEvent* ) | 406 | void OChannelHopper::timerEvent( QTimerEvent* ) |
398 | { | 407 | { |
399 | _iface->setChannel( *_channel ); | 408 | _iface->setChannel( *_channel ); |
400 | emit( hopped( *_channel ) ); | 409 | emit( hopped( *_channel ) ); |
401 | qDebug( "OChannelHopper::timerEvent(): set channel %d on interface '%s'", | 410 | qDebug( "OChannelHopper::timerEvent(): set channel %d on interface '%s'", |
402 | *_channel, (const char*) _iface->name() ); | 411 | *_channel, (const char*) _iface->name() ); |
403 | if ( ++_channel == _channels.end() ) _channel = _channels.begin(); | 412 | if ( ++_channel == _channels.end() ) _channel = _channels.begin(); |
404 | } | 413 | } |
405 | 414 | ||
406 | 415 | ||
407 | void OChannelHopper::setInterval( int interval ) | 416 | void OChannelHopper::setInterval( int interval ) |
408 | { | 417 | { |
409 | if ( interval == _interval ) | 418 | if ( interval == _interval ) |
410 | return; | 419 | return; |
411 | 420 | ||
412 | if ( _interval ) | 421 | if ( _interval ) |
413 | killTimer( _tid ); | 422 | killTimer( _tid ); |
414 | 423 | ||
415 | _tid = 0; | 424 | _tid = 0; |
416 | _interval = interval; | 425 | _interval = interval; |
417 | 426 | ||
418 | if ( _interval ) | 427 | if ( _interval ) |
419 | { | 428 | { |
420 | _tid = startTimer( interval ); | 429 | _tid = startTimer( interval ); |
421 | } | 430 | } |
422 | } | 431 | } |
423 | 432 | ||
424 | 433 | ||
425 | int OChannelHopper::interval() const | 434 | int OChannelHopper::interval() const |
426 | { | 435 | { |
427 | return _interval; | 436 | return _interval; |
428 | } | 437 | } |
429 | 438 | ||
430 | 439 | ||
431 | /*====================================================================================== | 440 | /*====================================================================================== |
432 | * OWirelessNetworkInterface | 441 | * OWirelessNetworkInterface |
433 | *======================================================================================*/ | 442 | *======================================================================================*/ |
434 | 443 | ||
435 | OWirelessNetworkInterface::OWirelessNetworkInterface( QObject* parent, const char* name ) | 444 | OWirelessNetworkInterface::OWirelessNetworkInterface( QObject* parent, const char* name ) |
436 | :ONetworkInterface( parent, name ), _hopper( 0 ) | 445 | :ONetworkInterface( parent, name ), _hopper( 0 ) |
437 | { | 446 | { |
438 | qDebug( "OWirelessNetworkInterface::OWirelessNetworkInterface()" ); | 447 | qDebug( "OWirelessNetworkInterface::OWirelessNetworkInterface()" ); |
439 | init(); | 448 | init(); |
440 | } | 449 | } |
441 | 450 | ||
442 | 451 | ||
443 | OWirelessNetworkInterface::~OWirelessNetworkInterface() | 452 | OWirelessNetworkInterface::~OWirelessNetworkInterface() |
444 | { | 453 | { |
445 | } | 454 | } |
446 | 455 | ||
447 | 456 | ||
448 | struct iwreq& OWirelessNetworkInterface::iwr() const | 457 | struct iwreq& OWirelessNetworkInterface::iwr() const |
449 | { | 458 | { |
450 | return _iwr; | 459 | return _iwr; |
451 | } | 460 | } |
452 | 461 | ||
453 | 462 | ||
454 | void OWirelessNetworkInterface::init() | 463 | void OWirelessNetworkInterface::init() |
455 | { | 464 | { |
456 | qDebug( "OWirelessNetworkInterface::init()" ); | 465 | qDebug( "OWirelessNetworkInterface::init()" ); |
457 | memset( &_iwr, 0, sizeof( struct iwreq ) ); | 466 | memset( &_iwr, 0, sizeof( struct iwreq ) ); |
458 | buildInformation(); | 467 | buildInformation(); |
459 | buildPrivateList(); | 468 | buildPrivateList(); |
460 | dumpInformation(); | 469 | dumpInformation(); |
461 | } | 470 | } |
462 | 471 | ||
463 | 472 | ||
464 | bool OWirelessNetworkInterface::isAssociated() const | 473 | bool OWirelessNetworkInterface::isAssociated() const |
465 | { | 474 | { |
466 | //FIXME: handle different modes | 475 | //FIXME: handle different modes |
467 | return associatedAP() != "44:44:44:44:44:44"; | 476 | return associatedAP() != "44:44:44:44:44:44"; |
468 | } | 477 | } |
469 | 478 | ||
470 | 479 | ||
471 | QString OWirelessNetworkInterface::associatedAP() const | 480 | QString OWirelessNetworkInterface::associatedAP() const |
472 | { | 481 | { |
473 | //FIXME: use OMacAddress | 482 | //FIXME: use OMacAddress |
474 | QString mac; | 483 | QString mac; |
475 | 484 | ||
476 | if ( ioctl( SIOCGIWAP ) ) | 485 | if ( ioctl( SIOCGIWAP ) ) |
477 | { | 486 | { |
478 | mac.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", | 487 | mac.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", |
479 | _ifr.ifr_hwaddr.sa_data[0]&0xff, | 488 | _ifr.ifr_hwaddr.sa_data[0]&0xff, |
480 | _ifr.ifr_hwaddr.sa_data[1]&0xff, | 489 | _ifr.ifr_hwaddr.sa_data[1]&0xff, |
481 | _ifr.ifr_hwaddr.sa_data[2]&0xff, | 490 | _ifr.ifr_hwaddr.sa_data[2]&0xff, |
482 | _ifr.ifr_hwaddr.sa_data[3]&0xff, | 491 | _ifr.ifr_hwaddr.sa_data[3]&0xff, |
483 | _ifr.ifr_hwaddr.sa_data[4]&0xff, | 492 | _ifr.ifr_hwaddr.sa_data[4]&0xff, |
484 | _ifr.ifr_hwaddr.sa_data[5]&0xff ); | 493 | _ifr.ifr_hwaddr.sa_data[5]&0xff ); |
485 | } | 494 | } |
486 | else | 495 | else |
487 | { | 496 | { |
488 | mac = "<Unknown>"; | 497 | mac = "<Unknown>"; |
489 | } | 498 | } |
490 | return mac; | 499 | return mac; |
491 | } | 500 | } |
492 | 501 | ||
493 | 502 | ||
494 | void OWirelessNetworkInterface::buildInformation() | 503 | void OWirelessNetworkInterface::buildInformation() |
495 | { | 504 | { |
496 | //ML: If you listen carefully enough, you can hear lots of WLAN drivers suck | 505 | //ML: If you listen carefully enough, you can hear lots of WLAN drivers suck |
497 | //ML: The HostAP drivers need more than sizeof struct_iw range to complete | 506 | //ML: The HostAP drivers need more than sizeof struct_iw range to complete |
498 | //ML: SIOCGIWRANGE otherwise they fail with "Invalid Argument Length". | 507 | //ML: SIOCGIWRANGE otherwise they fail with "Invalid Argument Length". |
499 | //ML: The Wlan-NG drivers on the otherside fail (segfault!) if you allocate | 508 | //ML: The Wlan-NG drivers on the otherside fail (segfault!) if you allocate |
500 | //ML: _too much_ space. This is damn shitty crap *sigh* | 509 | //ML: _too much_ space. This is damn shitty crap *sigh* |
501 | //ML: We allocate a large memory region in RAM and check whether the | 510 | //ML: We allocate a large memory region in RAM and check whether the |
502 | //ML: driver pollutes this extra space. The complaint will be made on stdout, | 511 | //ML: driver pollutes this extra space. The complaint will be made on stdout, |
503 | //ML: so please forward this... | 512 | //ML: so please forward this... |
504 | 513 | ||
505 | struct iwreq wrq; | 514 | struct iwreq wrq; |
506 | int len = sizeof( struct iw_range )*2; | 515 | int len = sizeof( struct iw_range )*2; |
507 | char *buffer = (char*) malloc( len ); | 516 | char *buffer = (char*) malloc( len ); |
508 | //FIXME: Validate if we actually got the memory block | 517 | //FIXME: Validate if we actually got the memory block |
509 | memset( buffer, 0, len ); | 518 | memset( buffer, 0, len ); |
510 | memcpy( wrq.ifr_name, name(), IFNAMSIZ); | 519 | memcpy( wrq.ifr_name, name(), IFNAMSIZ); |
511 | wrq.u.data.pointer = (caddr_t) buffer; | 520 | wrq.u.data.pointer = (caddr_t) buffer; |
512 | wrq.u.data.length = sizeof( struct iw_range ); | 521 | wrq.u.data.length = sizeof( struct iw_range ); |
513 | wrq.u.data.flags = 0; | 522 | wrq.u.data.flags = 0; |
514 | 523 | ||
515 | if ( ::ioctl( _sfd, SIOCGIWRANGE, &wrq ) == -1 ) | 524 | if ( ::ioctl( _sfd, SIOCGIWRANGE, &wrq ) == -1 ) |
516 | { | 525 | { |
517 | qDebug( "OWirelessNetworkInterface::buildInformation(): SIOCGIWRANGE failed (%s) - using default values.", strerror( errno ) ); | 526 | qDebug( "OWirelessNetworkInterface::buildInformation(): SIOCGIWRANGE failed (%s) - using default values.", strerror( errno ) ); |
518 | _channels.insert( 2412, 1 ); // 2.412 GHz | 527 | _channels.insert( 2412, 1 ); // 2.412 GHz |
519 | _channels.insert( 2417, 2 ); // 2.417 GHz | 528 | _channels.insert( 2417, 2 ); // 2.417 GHz |
520 | _channels.insert( 2422, 3 ); // 2.422 GHz | 529 | _channels.insert( 2422, 3 ); // 2.422 GHz |
521 | _channels.insert( 2427, 4 ); // 2.427 GHz | 530 | _channels.insert( 2427, 4 ); // 2.427 GHz |
522 | _channels.insert( 2432, 5 ); // 2.432 GHz | 531 | _channels.insert( 2432, 5 ); // 2.432 GHz |
523 | _channels.insert( 2437, 6 ); // 2.437 GHz | 532 | _channels.insert( 2437, 6 ); // 2.437 GHz |
524 | _channels.insert( 2442, 7 ); // 2.442 GHz | 533 | _channels.insert( 2442, 7 ); // 2.442 GHz |
525 | _channels.insert( 2447, 8 ); // 2.447 GHz | 534 | _channels.insert( 2447, 8 ); // 2.447 GHz |
526 | _channels.insert( 2452, 9 ); // 2.452 GHz | 535 | _channels.insert( 2452, 9 ); // 2.452 GHz |
527 | _channels.insert( 2457, 10 ); // 2.457 GHz | 536 | _channels.insert( 2457, 10 ); // 2.457 GHz |
528 | _channels.insert( 2462, 11 ); // 2.462 GHz | 537 | _channels.insert( 2462, 11 ); // 2.462 GHz |
529 | 538 | ||
530 | memset( &_range, 0, sizeof( struct iw_range ) ); | 539 | memset( &_range, 0, sizeof( struct iw_range ) ); |
531 | } | 540 | } |
532 | else | 541 | else |
533 | { | 542 | { |
534 | // <check if the driver overwrites stuff> | 543 | // <check if the driver overwrites stuff> |
535 | int max = 0; | 544 | int max = 0; |
536 | for ( int r = sizeof( struct iw_range ); r < len; r++ ) | 545 | for ( int r = sizeof( struct iw_range ); r < len; r++ ) |
537 | if (buffer[r] != 0) | 546 | if (buffer[r] != 0) |
538 | max = r; | 547 | max = r; |
539 | if (max > 0) | 548 | if (max > 0) |
540 | { | 549 | { |
541 | qWarning( "OWirelessNetworkInterface::buildInformation(): Driver for wireless interface '%s' sucks!\n" | 550 | qWarning( "OWirelessNetworkInterface::buildInformation(): Driver for wireless interface '%s' sucks!\n" |
542 | "It overwrote the buffer end with at least %i bytes!\n", name(), max - sizeof( struct iw_range ) ); | 551 | "It overwrote the buffer end with at least %i bytes!\n", name(), max - sizeof( struct iw_range ) ); |
543 | } | 552 | } |
544 | // </check if the driver overwrites stuff> | 553 | // </check if the driver overwrites stuff> |
545 | 554 | ||
546 | struct iw_range range; | 555 | struct iw_range range; |
547 | memcpy( &range, buffer, sizeof range ); | 556 | memcpy( &range, buffer, sizeof range ); |
548 | 557 | ||
549 | qDebug( "OWirelessNetworkInterface::buildInformation(): Interface %s reported to have %d channels.", name(), range.num_frequency ); | 558 | qDebug( "OWirelessNetworkInterface::buildInformation(): Interface %s reported to have %d channels.", name(), range.num_frequency ); |
550 | for ( int i = 0; i < range.num_frequency; ++i ) | 559 | for ( int i = 0; i < range.num_frequency; ++i ) |
551 | { | 560 | { |
552 | int freq = (int) ( double( range.freq[i].m ) * pow( 10.0, range.freq[i].e ) / 1000000.0 ); | 561 | int freq = (int) ( double( range.freq[i].m ) * pow( 10.0, range.freq[i].e ) / 1000000.0 ); |
553 | _channels.insert( freq, i+1 ); | 562 | _channels.insert( freq, i+1 ); |
554 | } | 563 | } |
555 | } | 564 | } |
556 | 565 | ||
557 | memcpy( &_range, buffer, sizeof( struct iw_range ) ); | 566 | memcpy( &_range, buffer, sizeof( struct iw_range ) ); |
558 | qDebug( "OWirelessNetworkInterface::buildInformation(): Information block constructed." ); | 567 | qDebug( "OWirelessNetworkInterface::buildInformation(): Information block constructed." ); |
559 | free(buffer); | 568 | free(buffer); |
560 | } | 569 | } |
561 | 570 | ||
562 | 571 | ||
563 | void OWirelessNetworkInterface::buildPrivateList() | 572 | void OWirelessNetworkInterface::buildPrivateList() |
564 | { | 573 | { |
565 | qDebug( "OWirelessNetworkInterface::buildPrivateList()" ); | 574 | qDebug( "OWirelessNetworkInterface::buildPrivateList()" ); |
566 | 575 | ||
567 | struct iw_priv_args priv[IW_MAX_PRIV_DEF]; | 576 | struct iw_priv_args priv[IW_MAX_PRIV_DEF]; |
568 | 577 | ||
569 | _iwr.u.data.pointer = (char*) &priv; | 578 | _iwr.u.data.pointer = (char*) &priv; |
570 | _iwr.u.data.length = IW_MAX_PRIV_DEF; // length in terms of number of (sizeof iw_priv_args), not (sizeof iw_priv_args) itself | 579 | _iwr.u.data.length = IW_MAX_PRIV_DEF; // length in terms of number of (sizeof iw_priv_args), not (sizeof iw_priv_args) itself |
571 | _iwr.u.data.flags = 0; | 580 | _iwr.u.data.flags = 0; |
572 | 581 | ||
573 | if ( !wioctl( SIOCGIWPRIV ) ) | 582 | if ( !wioctl( SIOCGIWPRIV ) ) |
574 | { | 583 | { |
575 | qDebug( "OWirelessNetworkInterface::buildPrivateList(): SIOCGIWPRIV failed (%s) - can't get private ioctl information.", strerror( errno ) ); | 584 | qDebug( "OWirelessNetworkInterface::buildPrivateList(): SIOCGIWPRIV failed (%s) - can't get private ioctl information.", strerror( errno ) ); |
576 | return; | 585 | return; |
577 | } | 586 | } |
578 | 587 | ||
579 | for ( int i = 0; i < _iwr.u.data.length; ++i ) | 588 | for ( int i = 0; i < _iwr.u.data.length; ++i ) |
580 | { | 589 | { |
581 | new OPrivateIOCTL( this, priv[i].name, priv[i].cmd, priv[i].get_args, priv[i].set_args ); | 590 | new OPrivateIOCTL( this, priv[i].name, priv[i].cmd, priv[i].get_args, priv[i].set_args ); |
582 | } | 591 | } |
583 | qDebug( "OWirelessNetworkInterface::buildPrivateList(): Private IOCTL list constructed." ); | 592 | qDebug( "OWirelessNetworkInterface::buildPrivateList(): Private IOCTL list constructed." ); |
584 | } | 593 | } |
585 | 594 | ||
586 | 595 | ||
587 | void OWirelessNetworkInterface::dumpInformation() const | 596 | void OWirelessNetworkInterface::dumpInformation() const |
588 | { | 597 | { |
589 | qDebug( "OWirelessNetworkInterface::() -------------- dumping information block ----------------" ); | 598 | qDebug( "OWirelessNetworkInterface::() -------------- dumping information block ----------------" ); |
590 | 599 | ||
591 | qDebug( " - driver's idea of maximum throughput is %d bps = %d byte/s = %d Kb/s = %f.2 Mb/s", _range.throughput, _range.throughput / 8, _range.throughput / 8 / 1024, float( _range.throughput ) / 8.0 / 1024.0 / 1024.0 ); | 600 | qDebug( " - driver's idea of maximum throughput is %d bps = %d byte/s = %d Kb/s = %f.2 Mb/s", _range.throughput, _range.throughput / 8, _range.throughput / 8 / 1024, float( _range.throughput ) / 8.0 / 1024.0 / 1024.0 ); |
592 | qDebug( " - driver for '%s' has been compiled against WE V%d (source=V%d)", name(), _range.we_version_compiled, _range.we_version_source ); | 601 | qDebug( " - driver for '%s' has been compiled against WE V%d (source=V%d)", name(), _range.we_version_compiled, _range.we_version_source ); |
593 | 602 | ||
594 | qDebug( "OWirelessNetworkInterface::() ---------------------------------------------------------" ); | 603 | qDebug( "OWirelessNetworkInterface::() ---------------------------------------------------------" ); |
595 | } | 604 | } |
596 | 605 | ||
597 | 606 | ||
598 | int OWirelessNetworkInterface::channel() const | 607 | int OWirelessNetworkInterface::channel() const |
599 | { | 608 | { |
600 | //FIXME: When monitoring enabled, then use it | 609 | //FIXME: When monitoring enabled, then use it |
601 | //FIXME: to gather the current RF channel | 610 | //FIXME: to gather the current RF channel |
602 | //FIXME: Until then, get active channel from hopper. | 611 | //FIXME: Until then, get active channel from hopper. |
603 | if ( _hopper && _hopper->isActive() ) | 612 | if ( _hopper && _hopper->isActive() ) |
604 | return _hopper->channel(); | 613 | return _hopper->channel(); |
605 | 614 | ||
606 | if ( !wioctl( SIOCGIWFREQ ) ) | 615 | if ( !wioctl( SIOCGIWFREQ ) ) |
607 | { | 616 | { |
608 | return -1; | 617 | return -1; |
609 | } | 618 | } |
610 | else | 619 | else |
611 | { | 620 | { |
612 | return _channels[ static_cast<int>(double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000) ]; | 621 | return _channels[ static_cast<int>(double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000) ]; |
613 | } | 622 | } |
614 | } | 623 | } |
615 | 624 | ||
616 | 625 | ||
617 | void OWirelessNetworkInterface::setChannel( int c ) const | 626 | void OWirelessNetworkInterface::setChannel( int c ) const |
618 | { | 627 | { |
619 | if ( !c ) | 628 | if ( !c ) |
620 | { | 629 | { |
621 | qWarning( "OWirelessNetworkInterface::setChannel( 0 ) called - fix your application!" ); | 630 | qWarning( "OWirelessNetworkInterface::setChannel( 0 ) called - fix your application!" ); |
622 | return; | 631 | return; |
623 | } | 632 | } |
624 | 633 | ||
625 | if ( !_mon ) | 634 | if ( !_mon ) |
626 | { | 635 | { |
627 | memset( &_iwr, 0, sizeof( struct iwreq ) ); | 636 | memset( &_iwr, 0, sizeof( struct iwreq ) ); |
628 | _iwr.u.freq.m = c; | 637 | _iwr.u.freq.m = c; |
629 | _iwr.u.freq.e = 0; | 638 | _iwr.u.freq.e = 0; |
630 | wioctl( SIOCSIWFREQ ); | 639 | wioctl( SIOCSIWFREQ ); |
631 | } | 640 | } |
632 | else | 641 | else |
633 | { | 642 | { |
634 | _mon->setChannel( c ); | 643 | _mon->setChannel( c ); |
635 | } | 644 | } |
636 | } | 645 | } |
637 | 646 | ||
638 | 647 | ||
639 | double OWirelessNetworkInterface::frequency() const | 648 | double OWirelessNetworkInterface::frequency() const |
640 | { | 649 | { |
641 | if ( !wioctl( SIOCGIWFREQ ) ) | 650 | if ( !wioctl( SIOCGIWFREQ ) ) |
642 | { | 651 | { |
643 | return -1.0; | 652 | return -1.0; |
644 | } | 653 | } |
645 | else | 654 | else |
646 | { | 655 | { |
647 | return double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000000.0; | 656 | return double( _iwr.u.freq.m ) * pow( 10.0, _iwr.u.freq.e ) / 1000000000.0; |
648 | } | 657 | } |
649 | } | 658 | } |
650 | 659 | ||
651 | 660 | ||
652 | int OWirelessNetworkInterface::channels() const | 661 | int OWirelessNetworkInterface::channels() const |
653 | { | 662 | { |
654 | return _channels.count(); | 663 | return _channels.count(); |
655 | } | 664 | } |
656 | 665 | ||
657 | 666 | ||
658 | void OWirelessNetworkInterface::setChannelHopping( int interval ) | 667 | void OWirelessNetworkInterface::setChannelHopping( int interval ) |
659 | { | 668 | { |
660 | if ( !_hopper ) _hopper = new OChannelHopper( this ); | 669 | if ( !_hopper ) _hopper = new OChannelHopper( this ); |
661 | _hopper->setInterval( interval ); | 670 | _hopper->setInterval( interval ); |
662 | //FIXME: When and by whom will the channel hopper be deleted? | 671 | //FIXME: When and by whom will the channel hopper be deleted? |
663 | //TODO: rely on QObject hierarchy | 672 | //TODO: rely on QObject hierarchy |
664 | } | 673 | } |
665 | 674 | ||
666 | 675 | ||
667 | int OWirelessNetworkInterface::channelHopping() const | 676 | int OWirelessNetworkInterface::channelHopping() const |
668 | { | 677 | { |
669 | return _hopper->interval(); | 678 | return _hopper->interval(); |
670 | } | 679 | } |
671 | 680 | ||
672 | 681 | ||
673 | OChannelHopper* OWirelessNetworkInterface::channelHopper() const | 682 | OChannelHopper* OWirelessNetworkInterface::channelHopper() const |
674 | { | 683 | { |
675 | return _hopper; | 684 | return _hopper; |
676 | } | 685 | } |
677 | 686 | ||
678 | 687 | ||
679 | void OWirelessNetworkInterface::setMode( const QString& mode ) | 688 | void OWirelessNetworkInterface::setMode( const QString& mode ) |
680 | { | 689 | { |
681 | if ( mode == "auto" ) _iwr.u.mode = IW_MODE_AUTO; | 690 | if ( mode == "auto" ) _iwr.u.mode = IW_MODE_AUTO; |
682 | else if ( mode == "adhoc" ) _iwr.u.mode = IW_MODE_ADHOC; | 691 | else if ( mode == "adhoc" ) _iwr.u.mode = IW_MODE_ADHOC; |
683 | else if ( mode == "managed" ) _iwr.u.mode = IW_MODE_INFRA; | 692 | else if ( mode == "managed" ) _iwr.u.mode = IW_MODE_INFRA; |
684 | else if ( mode == "master" ) _iwr.u.mode = IW_MODE_MASTER; | 693 | else if ( mode == "master" ) _iwr.u.mode = IW_MODE_MASTER; |
685 | else if ( mode == "repeater" ) _iwr.u.mode = IW_MODE_REPEAT; | 694 | else if ( mode == "repeater" ) _iwr.u.mode = IW_MODE_REPEAT; |
686 | else if ( mode == "secondary" ) _iwr.u.mode = IW_MODE_SECOND; | 695 | else if ( mode == "secondary" ) _iwr.u.mode = IW_MODE_SECOND; |
687 | else if ( mode == "monitor" ) _iwr.u.mode = IW_MODE_MONITOR; | 696 | else if ( mode == "monitor" ) _iwr.u.mode = IW_MODE_MONITOR; |
688 | else | 697 | else |
689 | { | 698 | { |
690 | qDebug( "ONetwork: Warning! Invalid IEEE 802.11 mode '%s' specified.", (const char*) mode ); | 699 | qDebug( "ONetwork: Warning! Invalid IEEE 802.11 mode '%s' specified.", (const char*) mode ); |
691 | return; | 700 | return; |
692 | } | 701 | } |
693 | wioctl( SIOCSIWMODE ); | 702 | wioctl( SIOCSIWMODE ); |
694 | } | 703 | } |
695 | 704 | ||
696 | 705 | ||
697 | QString OWirelessNetworkInterface::mode() const | 706 | QString OWirelessNetworkInterface::mode() const |
698 | { | 707 | { |
699 | if ( !wioctl( SIOCGIWMODE ) ) | 708 | if ( !wioctl( SIOCGIWMODE ) ) |
700 | { | 709 | { |
701 | return "<unknown>"; | 710 | return "<unknown>"; |
702 | } | 711 | } |
703 | switch ( _iwr.u.mode ) | 712 | switch ( _iwr.u.mode ) |
704 | { | 713 | { |
705 | case IW_MODE_AUTO: return "auto"; | 714 | case IW_MODE_AUTO: return "auto"; |
706 | case IW_MODE_ADHOC: return "adhoc"; | 715 | case IW_MODE_ADHOC: return "adhoc"; |
707 | case IW_MODE_INFRA: return "managed"; | 716 | case IW_MODE_INFRA: return "managed"; |
708 | case IW_MODE_MASTER: return "master"; | 717 | case IW_MODE_MASTER: return "master"; |
709 | case IW_MODE_REPEAT: return "repeater"; | 718 | case IW_MODE_REPEAT: return "repeater"; |
710 | case IW_MODE_SECOND: return "secondary"; | 719 | case IW_MODE_SECOND: return "secondary"; |
711 | case IW_MODE_MONITOR: return "monitor"; | 720 | case IW_MODE_MONITOR: return "monitor"; |
712 | default: assert( 0 ); // shouldn't happen | 721 | default: assert( 0 ); // shouldn't happen |
713 | } | 722 | } |
714 | } | 723 | } |
715 | 724 | ||
716 | 725 | ||
717 | void OWirelessNetworkInterface::setMonitorMode( bool b ) | 726 | void OWirelessNetworkInterface::setMonitorMode( bool b ) |
718 | { | 727 | { |
719 | if ( _mon ) | 728 | if ( _mon ) |
720 | _mon->setEnabled( b ); | 729 | _mon->setEnabled( b ); |
721 | else | 730 | else |
722 | qDebug( "ONetwork(): can't switch monitor mode without installed monitoring interface" ); | 731 | qDebug( "ONetwork(): can't switch monitor mode without installed monitoring interface" ); |
723 | } | 732 | } |
724 | 733 | ||
725 | 734 | ||
726 | bool OWirelessNetworkInterface::monitorMode() const | 735 | bool OWirelessNetworkInterface::monitorMode() const |
727 | { | 736 | { |
728 | qDebug( "dataLinkType = %d", dataLinkType() ); | 737 | qDebug( "dataLinkType = %d", dataLinkType() ); |
729 | return ( dataLinkType() == ARPHRD_IEEE80211 || dataLinkType() == 802 ); | 738 | return ( dataLinkType() == ARPHRD_IEEE80211 || dataLinkType() == 802 ); |
730 | //FIXME: 802 is the header type for PRISM - Linux support for this is pending... | 739 | //FIXME: 802 is the header type for PRISM - Linux support for this is pending... |
731 | //FIXME: What is 119, by the way? | 740 | //FIXME: What is 119, by the way? |
732 | } | 741 | } |
733 | 742 | ||
734 | 743 | ||
735 | void OWirelessNetworkInterface::setNickName( const QString& nickname ) | 744 | void OWirelessNetworkInterface::setNickName( const QString& nickname ) |
736 | { | 745 | { |
737 | _iwr.u.essid.pointer = const_cast<char*>( (const char*) nickname ); | 746 | _iwr.u.essid.pointer = const_cast<char*>( (const char*) nickname ); |
738 | _iwr.u.essid.length = nickname.length(); | 747 | _iwr.u.essid.length = nickname.length(); |
739 | wioctl( SIOCSIWNICKN ); | 748 | wioctl( SIOCSIWNICKN ); |
740 | } | 749 | } |
741 | 750 | ||
742 | 751 | ||
743 | QString OWirelessNetworkInterface::nickName() const | 752 | QString OWirelessNetworkInterface::nickName() const |
744 | { | 753 | { |
745 | char str[IW_ESSID_MAX_SIZE]; | 754 | char str[IW_ESSID_MAX_SIZE]; |
746 | _iwr.u.data.pointer = &str[0]; | 755 | _iwr.u.data.pointer = &str[0]; |
747 | _iwr.u.data.length = IW_ESSID_MAX_SIZE; | 756 | _iwr.u.data.length = IW_ESSID_MAX_SIZE; |
748 | if ( !wioctl( SIOCGIWNICKN ) ) | 757 | if ( !wioctl( SIOCGIWNICKN ) ) |
749 | { | 758 | { |
750 | return "<unknown>"; | 759 | return "<unknown>"; |
751 | } | 760 | } |
752 | else | 761 | else |
753 | { | 762 | { |
754 | str[_iwr.u.data.length] = 0x0; // some drivers (e.g. wlan-ng) don't zero-terminate the string | 763 | str[_iwr.u.data.length] = 0x0; // some drivers (e.g. wlan-ng) don't zero-terminate the string |
755 | return str; | 764 | return str; |
756 | } | 765 | } |
757 | } | 766 | } |
758 | 767 | ||
759 | 768 | ||
760 | void OWirelessNetworkInterface::setPrivate( const QString& call, int numargs, ... ) | 769 | void OWirelessNetworkInterface::setPrivate( const QString& call, int numargs, ... ) |
761 | { | 770 | { |
762 | OPrivateIOCTL* priv = static_cast<OPrivateIOCTL*>( child( (const char*) call ) ); | 771 | OPrivateIOCTL* priv = static_cast<OPrivateIOCTL*>( child( (const char*) call ) ); |
763 | if ( !priv ) | 772 | if ( !priv ) |
764 | { | 773 | { |
765 | qDebug( "OWirelessNetworkInterface::setPrivate(): interface '%s' does not support private ioctl '%s'", name(), (const char*) call ); | 774 | qDebug( "OWirelessNetworkInterface::setPrivate(): interface '%s' does not support private ioctl '%s'", name(), (const char*) call ); |
766 | return; | 775 | return; |
767 | } | 776 | } |
768 | if ( priv->numberSetArgs() != numargs ) | 777 | if ( priv->numberSetArgs() != numargs ) |
769 | { | 778 | { |
770 | qDebug( "OWirelessNetworkInterface::setPrivate(): parameter count not matching. '%s' expects %d arguments, but got %d", (const char*) call, priv->numberSetArgs(), numargs ); | 779 | qDebug( "OWirelessNetworkInterface::setPrivate(): parameter count not matching. '%s' expects %d arguments, but got %d", (const char*) call, priv->numberSetArgs(), numargs ); |
771 | return; | 780 | return; |
772 | } | 781 | } |
773 | 782 | ||
774 | qDebug( "OWirelessNetworkInterface::setPrivate(): about to call '%s' on interface '%s'", (const char*) call, name() ); | 783 | qDebug( "OWirelessNetworkInterface::setPrivate(): about to call '%s' on interface '%s'", (const char*) call, name() ); |
775 | memset( &_iwr, 0, sizeof _iwr ); | 784 | memset( &_iwr, 0, sizeof _iwr ); |
776 | va_list argp; | 785 | va_list argp; |
777 | va_start( argp, numargs ); | 786 | va_start( argp, numargs ); |
778 | for ( int i = 0; i < numargs; ++i ) | 787 | for ( int i = 0; i < numargs; ++i ) |
779 | { | 788 | { |
780 | priv->setParameter( i, va_arg( argp, int ) ); | 789 | priv->setParameter( i, va_arg( argp, int ) ); |
781 | } | 790 | } |
782 | va_end( argp ); | 791 | va_end( argp ); |
783 | priv->invoke(); | 792 | priv->invoke(); |
784 | } | 793 | } |
785 | 794 | ||
786 | 795 | ||
787 | void OWirelessNetworkInterface::getPrivate( const QString& call ) | 796 | void OWirelessNetworkInterface::getPrivate( const QString& call ) |
788 | { | 797 | { |
789 | qWarning( "OWirelessNetworkInterface::getPrivate() is not implemented yet." ); | 798 | qWarning( "OWirelessNetworkInterface::getPrivate() is not implemented yet." ); |
790 | } | 799 | } |
791 | 800 | ||
792 | 801 | ||
793 | bool OWirelessNetworkInterface::hasPrivate( const QString& call ) | 802 | bool OWirelessNetworkInterface::hasPrivate( const QString& call ) |
794 | { | 803 | { |
795 | return child( (const char*) call ); | 804 | return child( (const char*) call ); |
796 | } | 805 | } |
797 | 806 | ||
798 | 807 | ||
799 | QString OWirelessNetworkInterface::SSID() const | 808 | QString OWirelessNetworkInterface::SSID() const |
800 | { | 809 | { |
801 | char str[IW_ESSID_MAX_SIZE]; | 810 | char str[IW_ESSID_MAX_SIZE]; |
802 | _iwr.u.essid.pointer = &str[0]; | 811 | _iwr.u.essid.pointer = &str[0]; |
803 | _iwr.u.essid.length = IW_ESSID_MAX_SIZE; | 812 | _iwr.u.essid.length = IW_ESSID_MAX_SIZE; |
804 | if ( !wioctl( SIOCGIWESSID ) ) | 813 | if ( !wioctl( SIOCGIWESSID ) ) |
805 | { | 814 | { |
806 | return "<unknown>"; | 815 | return "<unknown>"; |
807 | } | 816 | } |
808 | else | 817 | else |
809 | { | 818 | { |
810 | return str; | 819 | return str; |
811 | } | 820 | } |
812 | } | 821 | } |
813 | 822 | ||
814 | 823 | ||
815 | void OWirelessNetworkInterface::setSSID( const QString& ssid ) | 824 | void OWirelessNetworkInterface::setSSID( const QString& ssid ) |
816 | { | 825 | { |
817 | _iwr.u.essid.pointer = const_cast<char*>( (const char*) ssid ); | 826 | _iwr.u.essid.pointer = const_cast<char*>( (const char*) ssid ); |
818 | _iwr.u.essid.length = ssid.length(); | 827 | _iwr.u.essid.length = ssid.length(); |
819 | wioctl( SIOCSIWESSID ); | 828 | wioctl( SIOCSIWESSID ); |
820 | } | 829 | } |
821 | 830 | ||
822 | 831 | ||
823 | int OWirelessNetworkInterface::scanNetwork() | 832 | int OWirelessNetworkInterface::scanNetwork() |
824 | { | 833 | { |
825 | _iwr.u.param.flags = IW_SCAN_DEFAULT; | 834 | _iwr.u.param.flags = IW_SCAN_DEFAULT; |
826 | _iwr.u.param.value = 0; | 835 | _iwr.u.param.value = 0; |
827 | if ( !wioctl( SIOCSIWSCAN ) ) | 836 | if ( !wioctl( SIOCSIWSCAN ) ) |
828 | { | 837 | { |
829 | return -1; | 838 | return -1; |
830 | } | 839 | } |
831 | 840 | ||
832 | int timeout = 1000000; | 841 | int timeout = 1000000; |
833 | 842 | ||
834 | qDebug( "ONetworkInterface::scanNetwork() - scan started." ); | 843 | qDebug( "ONetworkInterface::scanNetwork() - scan started." ); |
835 | 844 | ||
836 | bool results = false; | 845 | bool results = false; |
837 | struct timeval tv; | 846 | struct timeval tv; |
838 | tv.tv_sec = 0; | 847 | tv.tv_sec = 0; |
839 | tv.tv_usec = 250000; // initial timeout ~ 250ms | 848 | tv.tv_usec = 250000; // initial timeout ~ 250ms |
840 | char buffer[IW_SCAN_MAX_DATA]; | 849 | char buffer[IW_SCAN_MAX_DATA]; |
841 | 850 | ||
842 | while ( !results && timeout > 0 ) | 851 | while ( !results && timeout > 0 ) |
843 | { | 852 | { |
844 | timeout -= tv.tv_usec; | 853 | timeout -= tv.tv_usec; |
845 | select( 0, 0, 0, 0, &tv ); | 854 | select( 0, 0, 0, 0, &tv ); |
846 | 855 | ||
847 | _iwr.u.data.pointer = &buffer[0]; | 856 | _iwr.u.data.pointer = &buffer[0]; |
848 | _iwr.u.data.flags = 0; | 857 | _iwr.u.data.flags = 0; |
849 | _iwr.u.data.length = sizeof buffer; | 858 | _iwr.u.data.length = sizeof buffer; |
850 | if ( wioctl( SIOCGIWSCAN ) ) | 859 | if ( wioctl( SIOCGIWSCAN ) ) |
851 | { | 860 | { |
852 | results = true; | 861 | results = true; |
853 | continue; | 862 | continue; |
854 | } | 863 | } |
855 | else if ( errno == EAGAIN) | 864 | else if ( errno == EAGAIN) |
856 | { | 865 | { |
857 | qDebug( "ONetworkInterface::scanNetwork() - scan in progress..." ); | 866 | qDebug( "ONetworkInterface::scanNetwork() - scan in progress..." ); |
858 | #if 0 | 867 | #if 0 |
859 | if ( qApp ) | 868 | if ( qApp ) |
860 | { | 869 | { |
861 | qApp->processEvents( 100 ); | 870 | qApp->processEvents( 100 ); |
862 | continue; | 871 | continue; |
863 | } | 872 | } |
864 | #endif | 873 | #endif |
865 | tv.tv_sec = 0; | 874 | tv.tv_sec = 0; |
866 | tv.tv_usec = 100000; | 875 | tv.tv_usec = 100000; |
867 | continue; | 876 | continue; |
868 | } | 877 | } |
869 | } | 878 | } |
870 | 879 | ||
871 | qDebug( "ONetworkInterface::scanNetwork() - scan finished." ); | 880 | qDebug( "ONetworkInterface::scanNetwork() - scan finished." ); |
872 | 881 | ||
873 | if ( results ) | 882 | if ( results ) |
874 | { | 883 | { |
875 | qDebug( " - results are in!" ); | 884 | qDebug( " - results are in!" ); |
876 | } | 885 | } |
877 | else | 886 | else |
878 | { | 887 | { |
879 | qDebug( " - no results :(" ); | 888 | qDebug( " - no results :(" ); |
880 | } | 889 | } |
881 | } | 890 | } |
882 | 891 | ||
883 | 892 | ||
884 | bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const | 893 | bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const |
885 | { | 894 | { |
895 | #ifndef NODEBUG | ||
886 | int result = ::ioctl( _sfd, call, &iwreq ); | 896 | int result = ::ioctl( _sfd, call, &iwreq ); |
887 | if ( result == -1 ) | 897 | if ( result == -1 ) |
888 | qDebug( "ONetworkInterface::wioctl (%s) call %d (0x%04X) - Status: Failed: %d (%s)", name(), call, call, result, strerror( errno ) ); | 898 | qDebug( "ONetworkInterface::wioctl (%s) call %s (0x%04X) - Status: Failed: %d (%s)", name(), (const char*) *(*_ioctlmap)[call], call, result, strerror( errno ) ); |
889 | else | 899 | else |
890 | qDebug( "ONetworkInterface::wioctl (%s) call %d (0x%04X) - Status: Ok.", name(), call, call ); | 900 | qDebug( "ONetworkInterface::wioctl (%s) call %s (0x%04X) - Status: Ok.", name(), (const char*) *(*_ioctlmap)[call], call ); |
891 | return ( result != -1 ); | 901 | return ( result != -1 ); |
902 | #else | ||
903 | return ::ioctl( _sfd, call, &iwreq ) != -1; | ||
904 | #endif | ||
892 | } | 905 | } |
893 | 906 | ||
894 | 907 | ||
895 | bool OWirelessNetworkInterface::wioctl( int call ) const | 908 | bool OWirelessNetworkInterface::wioctl( int call ) const |
896 | { | 909 | { |
897 | strcpy( _iwr.ifr_name, name() ); | 910 | strcpy( _iwr.ifr_name, name() ); |
898 | return wioctl( call, _iwr ); | 911 | return wioctl( call, _iwr ); |
899 | } | 912 | } |
900 | 913 | ||
901 | 914 | ||
902 | /*====================================================================================== | 915 | /*====================================================================================== |
903 | * OMonitoringInterface | 916 | * OMonitoringInterface |
904 | *======================================================================================*/ | 917 | *======================================================================================*/ |
905 | 918 | ||
906 | OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) | 919 | OMonitoringInterface::OMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) |
907 | :_if( static_cast<OWirelessNetworkInterface*>( iface ) ), _prismHeader( prismHeader ) | 920 | :_if( static_cast<OWirelessNetworkInterface*>( iface ) ), _prismHeader( prismHeader ) |
908 | { | 921 | { |
909 | } | 922 | } |
910 | 923 | ||
911 | 924 | ||
912 | OMonitoringInterface::~OMonitoringInterface() | 925 | OMonitoringInterface::~OMonitoringInterface() |
913 | { | 926 | { |
914 | } | 927 | } |
915 | 928 | ||
916 | 929 | ||
917 | void OMonitoringInterface::setChannel( int c ) | 930 | void OMonitoringInterface::setChannel( int c ) |
918 | { | 931 | { |
919 | // use standard WE channel switching protocol | 932 | // use standard WE channel switching protocol |
920 | memset( &_if->_iwr, 0, sizeof( struct iwreq ) ); | 933 | memset( &_if->_iwr, 0, sizeof( struct iwreq ) ); |
921 | _if->_iwr.u.freq.m = c; | 934 | _if->_iwr.u.freq.m = c; |
922 | _if->_iwr.u.freq.e = 0; | 935 | _if->_iwr.u.freq.e = 0; |
923 | _if->wioctl( SIOCSIWFREQ ); | 936 | _if->wioctl( SIOCSIWFREQ ); |
924 | } | 937 | } |
925 | 938 | ||
926 | 939 | ||
927 | bool OMonitoringInterface::enabled() const | 940 | bool OMonitoringInterface::enabled() const |
928 | { | 941 | { |
929 | return _if->monitorMode(); | 942 | return _if->monitorMode(); |
930 | } | 943 | } |
931 | 944 | ||
932 | 945 | ||
933 | void OMonitoringInterface::setEnabled( bool b ) | 946 | void OMonitoringInterface::setEnabled( bool b ) |
934 | { | 947 | { |
935 | } | 948 | } |
936 | 949 | ||
937 | 950 | ||
938 | /*====================================================================================== | 951 | /*====================================================================================== |
939 | * OCiscoMonitoringInterface | 952 | * OCiscoMonitoringInterface |
940 | *======================================================================================*/ | 953 | *======================================================================================*/ |
941 | 954 | ||
942 | OCiscoMonitoringInterface::OCiscoMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) | 955 | OCiscoMonitoringInterface::OCiscoMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) |
943 | :OMonitoringInterface( iface, prismHeader ) | 956 | :OMonitoringInterface( iface, prismHeader ) |
944 | { | 957 | { |
945 | iface->setMonitoring( this ); | 958 | iface->setMonitoring( this ); |
946 | } | 959 | } |
947 | 960 | ||
948 | 961 | ||
949 | OCiscoMonitoringInterface::~OCiscoMonitoringInterface() | 962 | OCiscoMonitoringInterface::~OCiscoMonitoringInterface() |
950 | { | 963 | { |
951 | } | 964 | } |
952 | 965 | ||
953 | 966 | ||
954 | void OCiscoMonitoringInterface::setEnabled( bool b ) | 967 | void OCiscoMonitoringInterface::setEnabled( bool b ) |
955 | { | 968 | { |
956 | QString fname; | 969 | QString fname; |
957 | fname.sprintf( "/proc/driver/aironet/%s", (const char*) _if->name() ); | 970 | fname.sprintf( "/proc/driver/aironet/%s", (const char*) _if->name() ); |
958 | QFile f( fname ); | 971 | QFile f( fname ); |
959 | if ( !f.exists() ) return; | 972 | if ( !f.exists() ) return; |
960 | 973 | ||
961 | if ( f.open( IO_WriteOnly ) ) | 974 | if ( f.open( IO_WriteOnly ) ) |
962 | { | 975 | { |
963 | QTextStream s( &f ); | 976 | QTextStream s( &f ); |
964 | s << "Mode: r"; | 977 | s << "Mode: r"; |
965 | s << "Mode: y"; | 978 | s << "Mode: y"; |
966 | s << "XmitPower: 1"; | 979 | s << "XmitPower: 1"; |
967 | } | 980 | } |
968 | 981 | ||
969 | // flushing and closing will be done automatically when f goes out of scope | 982 | // flushing and closing will be done automatically when f goes out of scope |
970 | } | 983 | } |
971 | 984 | ||
972 | 985 | ||
973 | QString OCiscoMonitoringInterface::name() const | 986 | QString OCiscoMonitoringInterface::name() const |
974 | { | 987 | { |
975 | return "cisco"; | 988 | return "cisco"; |
976 | } | 989 | } |
977 | 990 | ||
978 | 991 | ||
979 | void OCiscoMonitoringInterface::setChannel( int ) | 992 | void OCiscoMonitoringInterface::setChannel( int ) |
980 | { | 993 | { |
981 | // cisco devices automatically switch channels when in monitor mode | 994 | // cisco devices automatically switch channels when in monitor mode |
982 | } | 995 | } |
983 | 996 | ||
984 | 997 | ||
985 | /*====================================================================================== | 998 | /*====================================================================================== |
986 | * OWlanNGMonitoringInterface | 999 | * OWlanNGMonitoringInterface |
987 | *======================================================================================*/ | 1000 | *======================================================================================*/ |
988 | 1001 | ||
989 | 1002 | ||
990 | OWlanNGMonitoringInterface::OWlanNGMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) | 1003 | OWlanNGMonitoringInterface::OWlanNGMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) |
991 | :OMonitoringInterface( iface, prismHeader ) | 1004 | :OMonitoringInterface( iface, prismHeader ) |
992 | { | 1005 | { |
993 | iface->setMonitoring( this ); | 1006 | iface->setMonitoring( this ); |
994 | } | 1007 | } |
995 | 1008 | ||
996 | 1009 | ||
997 | OWlanNGMonitoringInterface::~OWlanNGMonitoringInterface() | 1010 | OWlanNGMonitoringInterface::~OWlanNGMonitoringInterface() |
998 | { | 1011 | { |
999 | } | 1012 | } |
1000 | 1013 | ||
1001 | 1014 | ||
1002 | void OWlanNGMonitoringInterface::setEnabled( bool b ) | 1015 | void OWlanNGMonitoringInterface::setEnabled( bool b ) |
1003 | { | 1016 | { |
1004 | //FIXME: do nothing if its already in the same mode | 1017 | //FIXME: do nothing if its already in the same mode |
1005 | 1018 | ||
1006 | QString enable = b ? "true" : "false"; | 1019 | QString enable = b ? "true" : "false"; |
1007 | QString prism = _prismHeader ? "true" : "false"; | 1020 | QString prism = _prismHeader ? "true" : "false"; |
1008 | QString cmd; | 1021 | QString cmd; |
1009 | cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s prismheader=%s", | 1022 | cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s prismheader=%s", |
1010 | (const char*) _if->name(), 1, (const char*) enable, (const char*) prism ); | 1023 | (const char*) _if->name(), 1, (const char*) enable, (const char*) prism ); |
1011 | system( cmd ); | 1024 | system( cmd ); |
1012 | } | 1025 | } |
1013 | 1026 | ||
1014 | 1027 | ||
1015 | QString OWlanNGMonitoringInterface::name() const | 1028 | QString OWlanNGMonitoringInterface::name() const |
1016 | { | 1029 | { |
1017 | return "wlan-ng"; | 1030 | return "wlan-ng"; |
1018 | } | 1031 | } |
1019 | 1032 | ||
1020 | 1033 | ||
1021 | void OWlanNGMonitoringInterface::setChannel( int c ) | 1034 | void OWlanNGMonitoringInterface::setChannel( int c ) |
1022 | { | 1035 | { |
1023 | //NOTE: Older wlan-ng drivers automatically hopped channels while lnxreq_wlansniff=true. Newer ones don't. | 1036 | //NOTE: Older wlan-ng drivers automatically hopped channels while lnxreq_wlansniff=true. Newer ones don't. |
1024 | 1037 | ||
1025 | QString enable = "true"; //_if->monitorMode() ? "true" : "false"; | 1038 | QString enable = "true"; //_if->monitorMode() ? "true" : "false"; |
1026 | QString prism = _prismHeader ? "true" : "false"; | 1039 | QString prism = _prismHeader ? "true" : "false"; |
1027 | QString cmd; | 1040 | QString cmd; |
1028 | cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s prismheader=%s", | 1041 | cmd.sprintf( "$(which wlanctl-ng) %s lnxreq_wlansniff channel=%d enable=%s prismheader=%s", |
1029 | (const char*) _if->name(), c, (const char*) enable, (const char*) prism ); | 1042 | (const char*) _if->name(), c, (const char*) enable, (const char*) prism ); |
1030 | system( cmd ); | 1043 | system( cmd ); |
1031 | } | 1044 | } |
1032 | 1045 | ||
1033 | 1046 | ||
1034 | /*====================================================================================== | 1047 | /*====================================================================================== |
1035 | * OHostAPMonitoringInterface | 1048 | * OHostAPMonitoringInterface |
1036 | *======================================================================================*/ | 1049 | *======================================================================================*/ |
1037 | 1050 | ||
1038 | OHostAPMonitoringInterface::OHostAPMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) | 1051 | OHostAPMonitoringInterface::OHostAPMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) |
1039 | :OMonitoringInterface( iface, prismHeader ) | 1052 | :OMonitoringInterface( iface, prismHeader ) |
1040 | { | 1053 | { |
1041 | iface->setMonitoring( this ); | 1054 | iface->setMonitoring( this ); |
1042 | } | 1055 | } |
1043 | 1056 | ||
1044 | OHostAPMonitoringInterface::~OHostAPMonitoringInterface() | 1057 | OHostAPMonitoringInterface::~OHostAPMonitoringInterface() |
1045 | { | 1058 | { |
1046 | } | 1059 | } |
1047 | 1060 | ||
1048 | void OHostAPMonitoringInterface::setEnabled( bool b ) | 1061 | void OHostAPMonitoringInterface::setEnabled( bool b ) |
1049 | { | 1062 | { |
1050 | // IW_MODE_MONITOR was introduced in Wireless Extensions Version 15 | 1063 | // IW_MODE_MONITOR was introduced in Wireless Extensions Version 15 |
1051 | // Wireless Extensions < Version 15 need iwpriv commandos for monitoring | 1064 | // Wireless Extensions < Version 15 need iwpriv commandos for monitoring |
1052 | 1065 | ||
1053 | #if WIRELESS_EXT > 14 | 1066 | #if WIRELESS_EXT > 14 |
1054 | if ( b ) | 1067 | if ( b ) |
1055 | _if->setMode( "monitor" ); // IW_MODE_MONITOR doesn't support prism header | 1068 | _if->setMode( "monitor" ); // IW_MODE_MONITOR doesn't support prism header |
1056 | else | 1069 | else |
1057 | _if->setMode( "managed" ); | 1070 | _if->setMode( "managed" ); |
1058 | #else | 1071 | #else |
1059 | int monitorCode = _prismHeader ? 1 : 2; | 1072 | int monitorCode = _prismHeader ? 1 : 2; |
1060 | if ( b ) | 1073 | if ( b ) |
1061 | { | 1074 | { |
1062 | _if->setPrivate( "monitor", 1, monitorCode ); | 1075 | _if->setPrivate( "monitor", 1, monitorCode ); |
1063 | } | 1076 | } |
1064 | else | 1077 | else |
1065 | { | 1078 | { |
1066 | _if->setPrivate( "monitor", 1, 0 ); | 1079 | _if->setPrivate( "monitor", 1, 0 ); |
1067 | } | 1080 | } |
1068 | #endif | 1081 | #endif |
1069 | } | 1082 | } |
1070 | 1083 | ||
1071 | 1084 | ||
1072 | QString OHostAPMonitoringInterface::name() const | 1085 | QString OHostAPMonitoringInterface::name() const |
1073 | { | 1086 | { |
1074 | return "hostap"; | 1087 | return "hostap"; |
1075 | } | 1088 | } |
1076 | 1089 | ||
1077 | 1090 | ||
1078 | /*====================================================================================== | 1091 | /*====================================================================================== |
1079 | * OOrinocoNetworkInterface | 1092 | * OOrinocoNetworkInterface |
1080 | *======================================================================================*/ | 1093 | *======================================================================================*/ |
1081 | 1094 | ||
1082 | OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) | 1095 | OOrinocoMonitoringInterface::OOrinocoMonitoringInterface( ONetworkInterface* iface, bool prismHeader ) |
1083 | :OMonitoringInterface( iface, prismHeader ) | 1096 | :OMonitoringInterface( iface, prismHeader ) |
1084 | { | 1097 | { |
1085 | iface->setMonitoring( this ); | 1098 | iface->setMonitoring( this ); |
1086 | } | 1099 | } |
1087 | 1100 | ||
1088 | 1101 | ||
1089 | OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface() | 1102 | OOrinocoMonitoringInterface::~OOrinocoMonitoringInterface() |
1090 | { | 1103 | { |
1091 | } | 1104 | } |
1092 | 1105 | ||
1093 | 1106 | ||
1094 | void OOrinocoMonitoringInterface::setChannel( int c ) | 1107 | void OOrinocoMonitoringInterface::setChannel( int c ) |
1095 | { | 1108 | { |
1096 | int monitorCode = _prismHeader ? 1 : 2; | 1109 | int monitorCode = _prismHeader ? 1 : 2; |
1097 | _if->setPrivate( "monitor", 2, monitorCode, c ); | 1110 | _if->setPrivate( "monitor", 2, monitorCode, c ); |
1098 | } | 1111 | } |
1099 | 1112 | ||
1100 | 1113 | ||
1101 | void OOrinocoMonitoringInterface::setEnabled( bool b ) | 1114 | void OOrinocoMonitoringInterface::setEnabled( bool b ) |
1102 | { | 1115 | { |
1103 | // IW_MODE_MONITOR was introduced in Wireless Extensions Version 15 | 1116 | // IW_MODE_MONITOR was introduced in Wireless Extensions Version 15 |
1104 | // Wireless Extensions < Version 15 need iwpriv commandos for monitoring | 1117 | // Wireless Extensions < Version 15 need iwpriv commandos for monitoring |
1105 | // However, as of recent orinoco drivers, IW_MODE_MONITOR is still not supported | 1118 | // However, as of recent orinoco drivers, IW_MODE_MONITOR is still not supported |
1106 | 1119 | ||
1107 | #if 0 | 1120 | #if 0 |
1108 | //#if WIRELESS_EXT > 14 | 1121 | //#if WIRELESS_EXT > 14 |
1109 | if ( b ) | 1122 | if ( b ) |
1110 | _if->setMode( "monitor" ); // IW_MODE_MONITOR doesn't support prism header | 1123 | _if->setMode( "monitor" ); // IW_MODE_MONITOR doesn't support prism header |
1111 | else | 1124 | else |
1112 | _if->setMode( "managed" ); | 1125 | _if->setMode( "managed" ); |
1113 | #else | 1126 | #else |
1114 | if ( b ) | 1127 | if ( b ) |
1115 | { | 1128 | { |
1116 | setChannel( 1 ); | 1129 | setChannel( 1 ); |
1117 | } | 1130 | } |
1118 | else | 1131 | else |
1119 | { | 1132 | { |
1120 | _if->setPrivate( "monitor", 2, 0, 0 ); | 1133 | _if->setPrivate( "monitor", 2, 0, 0 ); |
1121 | } | 1134 | } |
1122 | #endif | 1135 | #endif |
1123 | } | 1136 | } |
1124 | 1137 | ||
1125 | 1138 | ||
1126 | QString OOrinocoMonitoringInterface::name() const | 1139 | QString OOrinocoMonitoringInterface::name() const |
1127 | { | 1140 | { |
1128 | return "orinoco"; | 1141 | return "orinoco"; |
1129 | } | 1142 | } |
diff --git a/libopie2/opienet/opienet.pro b/libopie2/opienet/opienet.pro index 6fcc1ec..304d968 100644 --- a/libopie2/opienet/opienet.pro +++ b/libopie2/opienet/opienet.pro | |||
@@ -1,31 +1,32 @@ | |||
1 | TEMPLATE = lib | 1 | TEMPLATE = lib |
2 | CONFIG += qt warn_on debug | 2 | CONFIG += qt warn_on debug |
3 | DESTDIR = $(OPIEDIR)/lib | 3 | DESTDIR = $(OPIEDIR)/lib |
4 | HEADERS = 802_11_user.h \ | 4 | HEADERS = 802_11_user.h \ |
5 | dhcp.h \ | 5 | dhcp.h \ |
6 | udp_ports.h \ | ||
6 | wireless.h \ | 7 | wireless.h \ |
7 | omanufacturerdb.cpp \ | 8 | oioctlmap.h \ |
8 | onetutils.cpp \ | 9 | omanufacturerdb.h \ |
10 | onetutils.h \ | ||
9 | onetwork.h \ | 11 | onetwork.h \ |
10 | opcap.h | 12 | opcap.h |
11 | SOURCES = omanufacturerdb.cpp \ | 13 | SOURCES = oioctlmap.cpp \ |
14 | omanufacturerdb.cpp \ | ||
12 | onetutils.cpp \ | 15 | onetutils.cpp \ |
13 | onetwork.cpp \ | 16 | onetwork.cpp \ |
14 | opcap.cpp | 17 | opcap.cpp |
15 | INTERFACES = | 18 | INTERFACES = |
16 | TARGET = opienet2 | 19 | TARGET = opienet2 |
17 | VERSION = 1.8.1 | 20 | VERSION = 1.8.1 |
18 | INCLUDEPATH += $(OPIEDIR)/include | 21 | INCLUDEPATH += $(OPIEDIR)/include |
19 | DEPENDPATH += $(OPIEDIR)/include | 22 | DEPENDPATH += $(OPIEDIR)/include |
20 | LIBS += -lpcap | 23 | LIBS += -lpcap |
21 | MOC_DIR = moc | ||
22 | OBJECTS_DIR = obj | ||
23 | 24 | ||
24 | 25 | ||
25 | !contains( platform, x11 ) { | 26 | !contains( platform, x11 ) { |
26 | include ( $(OPIEDIR)/include.pro ) | 27 | include ( $(OPIEDIR)/include.pro ) |
27 | } | 28 | } |
28 | 29 | ||
29 | contains( platform, x11 ) { | 30 | contains( platform, x11 ) { |
30 | LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib | 31 | LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib |
31 | } | 32 | } |
diff --git a/libopie2/tools/regen.py b/libopie2/tools/regen.py new file mode 100755 index 0000000..2f7f418 --- a/dev/null +++ b/libopie2/tools/regen.py | |||
@@ -0,0 +1,64 @@ | |||
1 | #!/usr/bin/env python | ||
2 | |||
3 | # | ||
4 | # regenerate ioctl_table.h | ||
5 | # | ||
6 | |||
7 | import sys | ||
8 | import os | ||
9 | result = os.popen( 'find /usr/include -name "*.h" |xargs grep -h SIOC|grep 0x' ).readlines() | ||
10 | |||
11 | try: | ||
12 | tablehfile = file( sys.argv[1]+".h", "w" ) | ||
13 | except: | ||
14 | tablehfile = sys.stdout | ||
15 | |||
16 | try: | ||
17 | tablecfile = file( sys.argv[1]+".cpp", "w" ) | ||
18 | except: | ||
19 | tablecfile = sys.stdout | ||
20 | |||
21 | print >>tablehfile,""" | ||
22 | /* | ||
23 | * ioctl table - generated by regen.py - (C) Michael 'Mickey' Lauer <mickey@vanille.de> | ||
24 | */ | ||
25 | |||
26 | #ifndef IOCTLMAP_H | ||
27 | #define IOCTLMAP_H | ||
28 | |||
29 | #include <qstring.h> | ||
30 | #include <qintdict.h> | ||
31 | |||
32 | typedef QIntDict<QString> IntStringMap; | ||
33 | |||
34 | IntStringMap* constructIoctlMap(); | ||
35 | |||
36 | #endif | ||
37 | """ | ||
38 | |||
39 | print >>tablecfile,""" | ||
40 | /* | ||
41 | * ioctl table - generated by regen.py - (C) Michael 'Mickey' Lauer <mickey@vanille.de> | ||
42 | */ | ||
43 | |||
44 | #include "%s" | ||
45 | |||
46 | IntStringMap* constructIoctlMap() | ||
47 | { | ||
48 | \tIntStringMap* map = new IntStringMap(); | ||
49 | |||
50 | """ % (tablehfile.name) | ||
51 | |||
52 | for line in result: | ||
53 | l = line.split() | ||
54 | if not l[0].startswith( "#define" ) or not l[2].startswith( "0x" ): | ||
55 | print >>sys.stderr, "can't parse line: %s" % l | ||
56 | continue | ||
57 | #print >>tablecfile, "\tqDebug( \"adding %s = %s\" );" % ( l[2], l[1] ) | ||
58 | print >>tablecfile, "\tmap->insert( %s, new QString(\"%s\") );" % ( l[2], l[1] ) | ||
59 | |||
60 | |||
61 | print >>tablecfile,""" | ||
62 | \treturn map; | ||
63 | }; | ||
64 | """ \ No newline at end of file | ||