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