diff options
-rw-r--r-- | src/transport/gnunet-helper-transport-wlan.c | 1314 | ||||
-rw-r--r-- | src/transport/plugin_transport_wlan.c | 14 | ||||
-rw-r--r-- | src/transport/plugin_transport_wlan.h | 48 |
3 files changed, 857 insertions, 519 deletions
diff --git a/src/transport/gnunet-helper-transport-wlan.c b/src/transport/gnunet-helper-transport-wlan.c index 2ed81a24d..0169a2da1 100644 --- a/src/transport/gnunet-helper-transport-wlan.c +++ b/src/transport/gnunet-helper-transport-wlan.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | (C) 2010, 2011 Christian Grothoff (and other contributing authors) | 3 | (C) 2010, 2011, 2012 Christian Grothoff (and other contributing authors) |
4 | Copyright (c) 2007, 2008, Andy Green <andy@warmcat.com> | 4 | Copyright (c) 2007, 2008, Andy Green <andy@warmcat.com> |
5 | Copyright (C) 2009 Thomas d'Otreppe | 5 | Copyright (C) 2009 Thomas d'Otreppe |
6 | 6 | ||
@@ -21,12 +21,27 @@ | |||
21 | */ | 21 | */ |
22 | /** | 22 | /** |
23 | * @file src/transport/gnunet-helper-transport-wlan.c | 23 | * @file src/transport/gnunet-helper-transport-wlan.c |
24 | * @brief wlan layer two server; must run as root (SUID will do) | 24 | * @brief mediator between the wlan interface and gnunet; must run as root (SUID will do) |
25 | * This code will work under GNU/Linux only. | 25 | * This code will work under GNU/Linux only. |
26 | * @author David Brodski | 26 | * @author David Brodski |
27 | * @author Christian Grothoff | ||
27 | * | 28 | * |
28 | * This program serves as the mediator between the wlan interface and | 29 | * This program will allow receiving and sending traffic from the WLAN |
29 | * gnunet | 30 | * interface. It will force traffic to be in 'ad-hoc' mode, use the |
31 | * proper MAC address of the WLAN interface and use a GNUnet-specific | ||
32 | * SSID (and a GNUnet-specific SNAP header). It only takes a single | ||
33 | * argument, which is the name of the interface to use. Since it uses | ||
34 | * RAW sockets, it must be installed SUID or run as 'root'. In order | ||
35 | * to keep the security risk of the resulting SUID binary minimal, the | ||
36 | * program ONLY opens the RAW socket with root privileges, then drops | ||
37 | * them and only then starts to process command line arguments. The | ||
38 | * code also does not link against any shared libraries (except libc) | ||
39 | * and is strictly minimal (except for checking for errors). The | ||
40 | * following list of people have reviewed this code and considered it | ||
41 | * safe since the last modification (if you reviewed it, please have | ||
42 | * your name added to the list): | ||
43 | * | ||
44 | * - Christian Grothoff (Mar 16th 2012) | ||
30 | */ | 45 | */ |
31 | 46 | ||
32 | /*- | 47 | /*- |
@@ -102,179 +117,429 @@ | |||
102 | #include "gnunet_protocols.h" | 117 | #include "gnunet_protocols.h" |
103 | #include "plugin_transport_wlan.h" | 118 | #include "plugin_transport_wlan.h" |
104 | 119 | ||
120 | /** | ||
121 | * Packet format type for the messages we receive from | ||
122 | * the kernel. This is for plain messages (with no | ||
123 | * performance information included). | ||
124 | */ | ||
105 | #define ARPHRD_IEEE80211 801 | 125 | #define ARPHRD_IEEE80211 801 |
126 | |||
127 | /** | ||
128 | * Packet format type for the messages we receive from | ||
129 | * the kernel. This is for the PRISM format. | ||
130 | */ | ||
106 | #define ARPHRD_IEEE80211_PRISM 802 | 131 | #define ARPHRD_IEEE80211_PRISM 802 |
132 | |||
133 | /** | ||
134 | * Packet format type for the messages we receive from | ||
135 | * the kernel. This is for messages with a | ||
136 | * 'struct Ieee80211RadiotapHeader' (see below). | ||
137 | */ | ||
107 | #define ARPHRD_IEEE80211_FULL 803 | 138 | #define ARPHRD_IEEE80211_FULL 803 |
108 | 139 | ||
109 | 140 | ||
110 | /** | 141 | /** |
111 | * Maximum size of a message allowed in either direction. | 142 | * Maximum size of a message allowed in either direction |
143 | * (used for our receive and sent buffers). | ||
112 | */ | 144 | */ |
113 | #define MAXLINE 4096 | 145 | #define MAXLINE 4096 |
114 | 146 | ||
115 | 147 | ||
116 | #define IEEE80211_RADIOTAP_PRESENT_EXTEND_MASK 0x80000000 | ||
117 | 148 | ||
149 | /* ********* structure of messages of type ARPHRD_IEEE80211_PRISM *********** */ | ||
118 | 150 | ||
119 | /* Name Data type Units | 151 | /** |
120 | * ---- --------- ----- | 152 | * Device name length in PRISM frames. |
121 | * | 153 | * (In the kernel, this is "WLAN_DEVNAMELEN_MAX") |
122 | * IEEE80211_RADIOTAP_TSFT __le64 microseconds | 154 | */ |
123 | * | 155 | #define PRISM_DEVICE_NAME_LENGTH 16 |
124 | * Value in microseconds of the MAC's 64-bit 802.11 Time | 156 | |
125 | * Synchronization Function timer when the first bit of the | 157 | /** |
126 | * MPDU arrived at the MAC. For received frames, only. | 158 | * Monitor Frame (indicator that we have a 'struct PrismHeader'). |
127 | * | 159 | */ |
128 | * IEEE80211_RADIOTAP_CHANNEL 2 x __le16 MHz, bitmap | 160 | #define PRISM_MSGCODE_MONITOR 0x0041 |
129 | * | 161 | |
130 | * Tx/Rx frequency in MHz, followed by flags (see below). | 162 | /** |
131 | * | 163 | * Mac time element. In micro-seconds. |
132 | * IEEE80211_RADIOTAP_FHSS __le16 see below | 164 | * Drivers appear to use a 64bit counter to hold mactime internal |
133 | * | 165 | * the then fill the prism header with the lower 32 bits |
134 | * For frequency-hopping radios, the hop set (first byte) | 166 | */ |
135 | * and pattern (second byte). | 167 | #define PRISM_DID_MACTIME 0x2041 |
136 | * | 168 | |
137 | * IEEE80211_RADIOTAP_RATE uint8_t 500kb/s | 169 | /** |
138 | * | 170 | * Channel element |
139 | * Tx/Rx data rate | 171 | */ |
140 | * | 172 | #define PRISM_DID_CHANNEL 0x3041 |
141 | * IEEE80211_RADIOTAP_DBM_ANTSIGNAL s8 decibels from | 173 | |
142 | * one milliwatt (dBm) | 174 | /** |
143 | * | 175 | * Signal element. Should be the signal strength in dbm, some people |
144 | * RF signal power at the antenna, decibel difference from | 176 | * suggest that instead "100 - (strength in dbm)" is used (to make this |
145 | * one milliwatt. | 177 | * a positive integer). |
146 | * | 178 | */ |
147 | * IEEE80211_RADIOTAP_DBM_ANTNOISE s8 decibels from | 179 | #define PRISM_DID_SIGNAL 0x6041 |
148 | * one milliwatt (dBm) | 180 | |
149 | * | 181 | /** |
150 | * RF noise power at the antenna, decibel difference from one | 182 | * Noise element |
151 | * milliwatt. | 183 | */ |
152 | * | 184 | #define PRISM_DID_NOISE 0x7041 |
153 | * IEEE80211_RADIOTAP_DB_ANTSIGNAL uint8_t decibel (dB) | 185 | |
154 | * | 186 | /** |
155 | * RF signal power at the antenna, decibel difference from an | 187 | * Rate element, in units/multiples of 500Khz |
156 | * arbitrary, fixed reference. | 188 | */ |
157 | * | 189 | #define PRISM_DID_RATE 0x8041 |
158 | * IEEE80211_RADIOTAP_DB_ANTNOISE uint8_t decibel (dB) | 190 | |
159 | * | 191 | |
160 | * RF noise power at the antenna, decibel difference from an | 192 | /** |
161 | * arbitrary, fixed reference point. | 193 | * Value is set (supplied) |
162 | * | 194 | */ |
163 | * IEEE80211_RADIOTAP_LOCK_QUALITY __le16 unitless | 195 | #define PRISM_STATUS_OK 0 |
164 | * | 196 | |
165 | * Quality of Barker code lock. Unitless. Monotonically | 197 | /** |
166 | * nondecreasing with "better" lock strength. Called "Signal | 198 | * Value not supplied. |
167 | * Quality" in datasheets. (Is there a standard way to measure | 199 | */ |
168 | * this?) | 200 | #define PRISM_STATUS_NO_VALUE 1 |
169 | * | 201 | |
170 | * IEEE80211_RADIOTAP_TX_ATTENUATION __le16 unitless | 202 | |
171 | * | 203 | /** |
172 | * Transmit power expressed as unitless distance from max | 204 | * Values in the 'struct PrismHeader'. All in host byte order (!). |
173 | * power set at factory calibration. 0 is max power. | 205 | */ |
174 | * Monotonically nondecreasing with lower power levels. | 206 | struct PrismValue |
175 | * | 207 | { |
176 | * IEEE80211_RADIOTAP_DB_TX_ATTENUATION __le16 decibels (dB) | 208 | /** |
177 | * | 209 | * This has a different ID for each parameter, see |
178 | * Transmit power expressed as decibel distance from max power | 210 | * PRISM_DID_* constants. |
179 | * set at factory calibration. 0 is max power. Monotonically | 211 | */ |
180 | * nondecreasing with lower power levels. | 212 | uint32_t did; |
181 | * | 213 | |
182 | * IEEE80211_RADIOTAP_DBM_TX_POWER s8 decibels from | 214 | /** |
183 | * one milliwatt (dBm) | 215 | * See PRISM_STATUS_*-constants. Note that they are unusual: 0 = set; 1 = not set |
184 | * | 216 | */ |
185 | * Transmit power expressed as dBm (decibels from a 1 milliwatt | 217 | uint16_t status; |
186 | * reference). This is the absolute power level measured at | 218 | |
187 | * the antenna port. | 219 | /** |
188 | * | 220 | * length of data (which is always a uint32_t, but presumably this can be used |
189 | * IEEE80211_RADIOTAP_FLAGS uint8_t bitmap | 221 | * to specify that fewer bytes are used (with values in 'len' from 0-4). We |
190 | * | 222 | * ignore this field. |
191 | * Properties of transmitted and received frames. See flags | 223 | */ |
192 | * defined below. | 224 | uint16_t len; |
193 | * | 225 | |
194 | * IEEE80211_RADIOTAP_ANTENNA uint8_t antenna index | 226 | /** |
195 | * | 227 | * The data value |
196 | * Unitless indication of the Rx/Tx antenna for this packet. | 228 | */ |
197 | * The first antenna is antenna 0. | 229 | uint32_t data; |
198 | * | 230 | |
199 | * IEEE80211_RADIOTAP_RX_FLAGS __le16 bitmap | 231 | } __attribute__ ((packed)); |
200 | * | 232 | |
201 | * Properties of received frames. See flags defined below. | 233 | |
202 | * | 234 | /** |
203 | * IEEE80211_RADIOTAP_TX_FLAGS __le16 bitmap | 235 | * Prism header format ('struct p80211msg' in Linux). All in host byte order (!). |
204 | * | 236 | */ |
205 | * Properties of transmitted frames. See flags defined below. | 237 | struct PrismHeader |
206 | * | 238 | { |
207 | * IEEE80211_RADIOTAP_RTS_RETRIES uint8_t data | 239 | /** |
208 | * | 240 | * We expect this to be a PRISM_MSGCODE_*. |
209 | * Number of rts retries a transmitted frame used. | 241 | */ |
210 | * | 242 | uint32_t msgcode; |
211 | * IEEE80211_RADIOTAP_DATA_RETRIES uint8_t data | 243 | |
212 | * | 244 | /** |
213 | * Number of unicast retries a transmitted frame used. | 245 | * The length of the entire header. |
214 | * | 246 | */ |
247 | uint32_t msglen; | ||
248 | |||
249 | /** | ||
250 | * Name of the device that captured the packet. | ||
251 | */ | ||
252 | char devname[PRISM_DEVICE_NAME_LENGTH]; | ||
253 | |||
254 | /* followed by 'struct PrismValue's. Documentation suggests that these | ||
255 | are typically the hosttime, mactime, channel, rssi, sq, signal, noise, | ||
256 | rate, istx and frmlen values, but documentation is sparse. So we | ||
257 | will use the 'did' fields to find out what we actually got. */ | ||
258 | |||
259 | } __attribute__ ((packed)); | ||
260 | |||
261 | |||
262 | /* ****** end of structure of messages of type ARPHRD_IEEE80211_PRISM ******* */ | ||
263 | |||
264 | /* ********** structure of messages of type ARPHRD_IEEE80211_FULL *********** */ | ||
265 | |||
266 | /** | ||
267 | * Bits in the 'it_present' bitmask from the 'struct | ||
268 | * Ieee80211RadiotapHeader'. For each value, we give the name, data | ||
269 | * type, unit and then a description below. Note that the actual size | ||
270 | * of the extension can be bigger as arguments must be padded so that | ||
271 | * args of a given length must begin at a boundary of that length. | ||
272 | * However, note that compound args are allowed (eg, 2 x uint16_t for | ||
273 | * IEEE80211_RADIOTAP_CHANNEL) so total argument length is not a | ||
274 | * reliable indicator of alignment requirement. See also | ||
275 | * 'man 9 ieee80211_radiotap'. | ||
215 | */ | 276 | */ |
216 | enum RadiotapType | 277 | enum RadiotapType |
217 | { | 278 | { |
279 | |||
280 | /** | ||
281 | * IEEE80211_RADIOTAP_TSFT __le64 microseconds | ||
282 | * | ||
283 | * Value in microseconds of the MAC's 64-bit 802.11 Time | ||
284 | * Synchronization Function timer when the first bit of the | ||
285 | * MPDU arrived at the MAC. For received frames, only. | ||
286 | */ | ||
218 | IEEE80211_RADIOTAP_TSFT = 0, | 287 | IEEE80211_RADIOTAP_TSFT = 0, |
288 | |||
289 | /** | ||
290 | * IEEE80211_RADIOTAP_FLAGS uint8_t bitmap | ||
291 | * | ||
292 | * Properties of transmitted and received frames. See flags | ||
293 | * defined below. | ||
294 | */ | ||
219 | IEEE80211_RADIOTAP_FLAGS = 1, | 295 | IEEE80211_RADIOTAP_FLAGS = 1, |
296 | |||
297 | /** | ||
298 | * IEEE80211_RADIOTAP_RATE uint8_t 500kb/s | ||
299 | * | ||
300 | * Tx/Rx data rate | ||
301 | */ | ||
220 | IEEE80211_RADIOTAP_RATE = 2, | 302 | IEEE80211_RADIOTAP_RATE = 2, |
303 | |||
304 | /** | ||
305 | * IEEE80211_RADIOTAP_CHANNEL 2 x __le16 MHz, bitmap | ||
306 | * | ||
307 | * Tx/Rx frequency in MHz, followed by flags (see below). | ||
308 | */ | ||
221 | IEEE80211_RADIOTAP_CHANNEL = 3, | 309 | IEEE80211_RADIOTAP_CHANNEL = 3, |
310 | /** | ||
311 | * IEEE80211_RADIOTAP_FHSS __le16 see below | ||
312 | * | ||
313 | * For frequency-hopping radios, the hop set (first byte) | ||
314 | * and pattern (second byte). | ||
315 | */ | ||
222 | IEEE80211_RADIOTAP_FHSS = 4, | 316 | IEEE80211_RADIOTAP_FHSS = 4, |
317 | |||
318 | /** | ||
319 | * IEEE80211_RADIOTAP_DBM_ANTSIGNAL s8 decibels from | ||
320 | * one milliwatt (dBm) | ||
321 | * | ||
322 | * RF signal power at the antenna, decibel difference from | ||
323 | * one milliwatt. | ||
324 | */ | ||
223 | IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5, | 325 | IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5, |
326 | |||
327 | /** | ||
328 | * IEEE80211_RADIOTAP_DBM_ANTNOISE s8 decibels from | ||
329 | * one milliwatt (dBm) | ||
330 | * | ||
331 | * RF noise power at the antenna, decibel difference from one | ||
332 | * milliwatt. | ||
333 | */ | ||
224 | IEEE80211_RADIOTAP_DBM_ANTNOISE = 6, | 334 | IEEE80211_RADIOTAP_DBM_ANTNOISE = 6, |
335 | |||
336 | /** | ||
337 | * IEEE80211_RADIOTAP_LOCK_QUALITY __le16 unitless | ||
338 | * | ||
339 | * Quality of Barker code lock. Unitless. Monotonically | ||
340 | * nondecreasing with "better" lock strength. Called "Signal | ||
341 | * Quality" in datasheets. (Is there a standard way to measure | ||
342 | * this?) | ||
343 | */ | ||
225 | IEEE80211_RADIOTAP_LOCK_QUALITY = 7, | 344 | IEEE80211_RADIOTAP_LOCK_QUALITY = 7, |
345 | |||
346 | /** | ||
347 | * IEEE80211_RADIOTAP_TX_ATTENUATION __le16 unitless | ||
348 | * | ||
349 | * Transmit power expressed as unitless distance from max | ||
350 | * power set at factory calibration. 0 is max power. | ||
351 | * Monotonically nondecreasing with lower power levels. | ||
352 | */ | ||
226 | IEEE80211_RADIOTAP_TX_ATTENUATION = 8, | 353 | IEEE80211_RADIOTAP_TX_ATTENUATION = 8, |
354 | |||
355 | /** | ||
356 | * IEEE80211_RADIOTAP_DB_TX_ATTENUATION __le16 decibels (dB) | ||
357 | * | ||
358 | * Transmit power expressed as decibel distance from max power | ||
359 | * set at factory calibration. 0 is max power. Monotonically | ||
360 | * nondecreasing with lower power levels. | ||
361 | */ | ||
227 | IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9, | 362 | IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9, |
363 | |||
364 | /** | ||
365 | * IEEE80211_RADIOTAP_DBM_TX_POWER s8 decibels from | ||
366 | * one milliwatt (dBm) | ||
367 | * | ||
368 | * Transmit power expressed as dBm (decibels from a 1 milliwatt | ||
369 | * reference). This is the absolute power level measured at | ||
370 | * the antenna port. | ||
371 | */ | ||
228 | IEEE80211_RADIOTAP_DBM_TX_POWER = 10, | 372 | IEEE80211_RADIOTAP_DBM_TX_POWER = 10, |
373 | |||
374 | /** | ||
375 | * IEEE80211_RADIOTAP_ANTENNA uint8_t antenna index | ||
376 | * | ||
377 | * Unitless indication of the Rx/Tx antenna for this packet. | ||
378 | * The first antenna is antenna 0. | ||
379 | */ | ||
229 | IEEE80211_RADIOTAP_ANTENNA = 11, | 380 | IEEE80211_RADIOTAP_ANTENNA = 11, |
381 | |||
382 | /** | ||
383 | * IEEE80211_RADIOTAP_DB_ANTSIGNAL uint8_t decibel (dB) | ||
384 | * | ||
385 | * RF signal power at the antenna, decibel difference from an | ||
386 | * arbitrary, fixed reference. | ||
387 | */ | ||
230 | IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12, | 388 | IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12, |
389 | |||
390 | /** | ||
391 | * IEEE80211_RADIOTAP_DB_ANTNOISE uint8_t decibel (dB) | ||
392 | * | ||
393 | * RF noise power at the antenna, decibel difference from an | ||
394 | * arbitrary, fixed reference point. | ||
395 | */ | ||
231 | IEEE80211_RADIOTAP_DB_ANTNOISE = 13, | 396 | IEEE80211_RADIOTAP_DB_ANTNOISE = 13, |
397 | |||
398 | /** | ||
399 | * IEEE80211_RADIOTAP_RX_FLAGS __le16 bitmap | ||
400 | * | ||
401 | * Properties of received frames. See flags defined below. | ||
402 | */ | ||
232 | IEEE80211_RADIOTAP_RX_FLAGS = 14, | 403 | IEEE80211_RADIOTAP_RX_FLAGS = 14, |
404 | |||
405 | /** | ||
406 | * IEEE80211_RADIOTAP_TX_FLAGS __le16 bitmap | ||
407 | * | ||
408 | * Properties of transmitted frames. See flags defined below. | ||
409 | */ | ||
233 | IEEE80211_RADIOTAP_TX_FLAGS = 15, | 410 | IEEE80211_RADIOTAP_TX_FLAGS = 15, |
411 | |||
412 | /** | ||
413 | * IEEE80211_RADIOTAP_RTS_RETRIES uint8_t data | ||
414 | * | ||
415 | * Number of rts retries a transmitted frame used. | ||
416 | */ | ||
234 | IEEE80211_RADIOTAP_RTS_RETRIES = 16, | 417 | IEEE80211_RADIOTAP_RTS_RETRIES = 16, |
418 | |||
419 | /** | ||
420 | * IEEE80211_RADIOTAP_DATA_RETRIES uint8_t data | ||
421 | * | ||
422 | * Number of unicast retries a transmitted frame used. | ||
423 | */ | ||
235 | IEEE80211_RADIOTAP_DATA_RETRIES = 17, | 424 | IEEE80211_RADIOTAP_DATA_RETRIES = 17, |
425 | |||
426 | /** | ||
427 | * Extension bit, used to indicate that more bits are needed for | ||
428 | * the bitmask. | ||
429 | */ | ||
236 | IEEE80211_RADIOTAP_EXT = 31 | 430 | IEEE80211_RADIOTAP_EXT = 31 |
237 | }; | 431 | }; |
238 | 432 | ||
239 | /* For IEEE80211_RADIOTAP_FLAGS */ | 433 | /** |
240 | #define IEEE80211_RADIOTAP_F_CFP 0x01 /* sent/received | 434 | * Bitmask indicating an extension of the bitmask is used. |
241 | * during CFP | 435 | * (Mask corresponding to IEEE80211_RADIOTAP_EXT). |
242 | */ | 436 | */ |
243 | #define IEEE80211_RADIOTAP_F_SHORTPRE 0x02 /* sent/received | 437 | #define IEEE80211_RADIOTAP_PRESENT_EXTEND_MASK (1 << IEEE80211_RADIOTAP_EXT) |
244 | * with short | 438 | |
245 | * preamble | ||
246 | */ | ||
247 | #define IEEE80211_RADIOTAP_F_WEP 0x04 /* sent/received | ||
248 | * with WEP encryption | ||
249 | */ | ||
250 | #define IEEE80211_RADIOTAP_F_FRAG 0x08 /* sent/received | ||
251 | * with fragmentation | ||
252 | */ | ||
253 | #define IEEE80211_RADIOTAP_F_FCS 0x10 /* frame includes FCS */ | ||
254 | #define IEEE80211_RADIOTAP_F_DATAPAD 0x20 /* frame has padding between | ||
255 | * 802.11 header and payload | ||
256 | * (to 32-bit boundary) | ||
257 | */ | ||
258 | /* For IEEE80211_RADIOTAP_RX_FLAGS */ | ||
259 | #define IEEE80211_RADIOTAP_F_RX_BADFCS 0x0001 /* frame failed crc check */ | ||
260 | |||
261 | /* For IEEE80211_RADIOTAP_TX_FLAGS */ | ||
262 | #define IEEE80211_RADIOTAP_F_TX_FAIL 0x0001 /* failed due to excessive | ||
263 | * retries */ | ||
264 | #define IEEE80211_RADIOTAP_F_TX_CTS 0x0002 /* used cts 'protection' */ | ||
265 | #define IEEE80211_RADIOTAP_F_TX_RTS 0x0004 /* used rts/cts handshake */ | ||
266 | #define IEEE80211_RADIOTAP_F_TX_NOACK 0x0008 /* frame should not be ACKed */ | ||
267 | #define IEEE80211_RADIOTAP_F_TX_NOSEQ 0x0010 /* sequence number handled | ||
268 | * by userspace */ | ||
269 | 439 | ||
270 | 440 | ||
271 | /** | 441 | /** |
272 | * A generic radio capture format is desirable. There is one for | 442 | * Bit in IEEE80211_RADIOTAP_FLAGS (which we might get |
273 | * Linux, but it is neither rigidly defined (there were not even | 443 | * as part of a 'struct Ieee80211RadiotapHeader' extension |
274 | * units given for some fields) nor easily extensible. | 444 | * if the IEEE80211_RADIOTAP_FLAGS bit is set in |
445 | * 'it_present'). The radiotap flags are an 8-bit field. | ||
275 | * | 446 | * |
276 | * I suggest the following extensible radio capture format. It is | 447 | * Frame was sent/received during CFP (Contention Free Period) |
277 | * based on a bitmap indicating which fields are present. | 448 | */ |
449 | #define IEEE80211_RADIOTAP_F_CFP 0x01 | ||
450 | |||
451 | /** | ||
452 | * Bit in IEEE80211_RADIOTAP_FLAGS (which we might get | ||
453 | * as part of a 'struct Ieee80211RadiotapHeader' extension | ||
454 | * if the IEEE80211_RADIOTAP_FLAGS bit is set in | ||
455 | * 'it_present'). The radiotap flags are an 8-bit field. | ||
456 | * | ||
457 | * Frame was sent/received with short preamble | ||
458 | */ | ||
459 | #define IEEE80211_RADIOTAP_F_SHORTPRE 0x02 | ||
460 | |||
461 | /** | ||
462 | * Bit in IEEE80211_RADIOTAP_FLAGS (which we might get | ||
463 | * as part of a 'struct Ieee80211RadiotapHeader' extension | ||
464 | * if the IEEE80211_RADIOTAP_FLAGS bit is set in | ||
465 | * 'it_present'). The radiotap flags are an 8-bit field. | ||
466 | * | ||
467 | * Frame was sent/received with WEP encryption | ||
468 | */ | ||
469 | #define IEEE80211_RADIOTAP_F_WEP 0x04 | ||
470 | |||
471 | /** | ||
472 | * Bit in IEEE80211_RADIOTAP_FLAGS (which we might get | ||
473 | * as part of a 'struct Ieee80211RadiotapHeader' extension | ||
474 | * if the IEEE80211_RADIOTAP_FLAGS bit is set in | ||
475 | * 'it_present'). The radiotap flags are an 8-bit field. | ||
476 | * | ||
477 | * Frame was sent/received with fragmentation | ||
478 | */ | ||
479 | #define IEEE80211_RADIOTAP_F_FRAG 0x08 | ||
480 | |||
481 | /** | ||
482 | * Bit in IEEE80211_RADIOTAP_FLAGS (which we might get | ||
483 | * as part of a 'struct Ieee80211RadiotapHeader' extension | ||
484 | * if the IEEE80211_RADIOTAP_FLAGS bit is set in | ||
485 | * 'it_present'). The radiotap flags are an 8-bit field. | ||
486 | * | ||
487 | * Frame includes FCS (CRC at the end that needs to be removeD). | ||
488 | */ | ||
489 | #define IEEE80211_RADIOTAP_F_FCS 0x10 | ||
490 | |||
491 | /** | ||
492 | * Bit in IEEE80211_RADIOTAP_FLAGS (which we might get | ||
493 | * as part of a 'struct Ieee80211RadiotapHeader' extension | ||
494 | * if the IEEE80211_RADIOTAP_FLAGS bit is set in | ||
495 | * 'it_present'). The radiotap flags are an 8-bit field. | ||
496 | * | ||
497 | * Frame has padding between 802.11 header and payload | ||
498 | * (to 32-bit boundary) | ||
499 | */ | ||
500 | #define IEEE80211_RADIOTAP_F_DATAPAD 0x20 | ||
501 | |||
502 | |||
503 | /** | ||
504 | * For IEEE80211_RADIOTAP_RX_FLAGS: | ||
505 | * frame failed crc check | ||
506 | */ | ||
507 | #define IEEE80211_RADIOTAP_F_RX_BADFCS 0x0001 | ||
508 | |||
509 | /** | ||
510 | * For IEEE80211_RADIOTAP_TX_FLAGS ('txflags' in 'struct RadiotapTransmissionHeader'): | ||
511 | * failed due to excessive retries | ||
512 | */ | ||
513 | #define IEEE80211_RADIOTAP_F_TX_FAIL 0x0001 | ||
514 | |||
515 | /** | ||
516 | * For IEEE80211_RADIOTAP_TX_FLAGS ('txflags' in 'struct RadiotapTransmissionHeader'): | ||
517 | * used cts 'protection' | ||
518 | */ | ||
519 | #define IEEE80211_RADIOTAP_F_TX_CTS 0x0002 | ||
520 | |||
521 | /** | ||
522 | * For IEEE80211_RADIOTAP_TX_FLAGS ('txflags' in 'struct RadiotapTransmissionHeader'): | ||
523 | * used rts/cts handshake | ||
524 | */ | ||
525 | #define IEEE80211_RADIOTAP_F_TX_RTS 0x0004 | ||
526 | |||
527 | /** | ||
528 | * For IEEE80211_RADIOTAP_TX_FLAGS ('txflags' in 'struct RadiotapTransmissionHeader'): | ||
529 | * frame should not be ACKed | ||
530 | */ | ||
531 | #define IEEE80211_RADIOTAP_F_TX_NOACK 0x0008 | ||
532 | |||
533 | /** | ||
534 | * For IEEE80211_RADIOTAP_TX_FLAGS ('txflags' in 'struct RadiotapTransmissionHeader'): | ||
535 | * sequence number handled by userspace | ||
536 | */ | ||
537 | #define IEEE80211_RADIOTAP_F_TX_NOSEQ 0x0010 | ||
538 | |||
539 | |||
540 | /** | ||
541 | * Generic header for radiotap messages (receiving and sending). A | ||
542 | * bit mask (it_present) determines which specific records follow. | ||
278 | * | 543 | * |
279 | * I am trying to describe precisely what the application programmer | 544 | * I am trying to describe precisely what the application programmer |
280 | * should expect in the following, and for that reason I tell the | 545 | * should expect in the following, and for that reason I tell the |
@@ -286,7 +551,7 @@ enum RadiotapType | |||
286 | * The radio capture header precedes the 802.11 header. | 551 | * The radio capture header precedes the 802.11 header. |
287 | * All data in the header is little endian on all platforms. | 552 | * All data in the header is little endian on all platforms. |
288 | */ | 553 | */ |
289 | struct ieee80211_radiotap_header | 554 | struct Ieee80211RadiotapHeader |
290 | { | 555 | { |
291 | /** | 556 | /** |
292 | * Version 0. Only increases for drastic changes, introduction of | 557 | * Version 0. Only increases for drastic changes, introduction of |
@@ -295,7 +560,7 @@ struct ieee80211_radiotap_header | |||
295 | uint8_t it_version; | 560 | uint8_t it_version; |
296 | 561 | ||
297 | /** | 562 | /** |
298 | * | 563 | * Padding. Set to 0. |
299 | */ | 564 | */ |
300 | uint8_t it_pad; | 565 | uint8_t it_pad; |
301 | 566 | ||
@@ -313,60 +578,106 @@ struct ieee80211_radiotap_header | |||
313 | uint32_t it_present; | 578 | uint32_t it_present; |
314 | }; | 579 | }; |
315 | 580 | ||
581 | |||
316 | /** | 582 | /** |
317 | * | 583 | * Format of the header we need to prepend to messages to be sent to the |
584 | * Kernel. | ||
318 | */ | 585 | */ |
319 | struct RadioTapheader | 586 | struct RadiotapTransmissionHeader |
320 | { | 587 | { |
588 | |||
321 | /** | 589 | /** |
322 | * | 590 | * First we begin with the 'generic' header we also get when receiving |
591 | * messages. | ||
323 | */ | 592 | */ |
324 | struct ieee80211_radiotap_header header; | 593 | struct Ieee80211RadiotapHeader header; |
325 | 594 | ||
326 | /** | 595 | /** |
327 | * | 596 | * Transmission rate (we use 0, kernel makes up its mind anyway). |
328 | */ | 597 | */ |
329 | uint8_t rate; | 598 | uint8_t rate; |
330 | 599 | ||
331 | /** | 600 | /** |
332 | * | 601 | * Padding (we use 0). There is a requirement to pad args, so that |
602 | * args of a given length must begin at a boundary of that length. | ||
603 | * As our next argument is the 'it_len' with 2 bytes, we need 1 byte | ||
604 | * of padding. | ||
333 | */ | 605 | */ |
334 | uint8_t pad1; | 606 | uint8_t pad1; |
335 | 607 | ||
336 | /** | 608 | /** |
337 | * | 609 | * Transmission flags from on the IEEE80211_RADIOTAP_F_TX_* constant family. |
338 | */ | 610 | */ |
339 | uint16_t txflags; | 611 | uint16_t txflags; |
612 | |||
340 | }; | 613 | }; |
341 | 614 | ||
615 | /** | ||
616 | * The above 'struct RadiotapTransmissionHeader' should have the | ||
617 | * following value for 'header.it_present' based on the presence of | ||
618 | * the 'rate' and 'txflags' in the overall struct. | ||
619 | */ | ||
620 | #define IEEE80211_RADIOTAP_OUR_TRANSMISSION_HEADER_MASK ((1 << IEEE80211_RADIOTAP_RATE) | (1 << IEEE80211_RADIOTAP_TX_FLAGS)) | ||
621 | |||
622 | |||
342 | 623 | ||
343 | /** | 624 | /** |
344 | * IO buffer used for buffering data in transit (to wireless or to stdout). | 625 | * struct Ieee80211RadiotapHeaderIterator - tracks walk through present radiotap arguments |
626 | * in the radiotap header. Used when we parse radiotap packets received from the kernel. | ||
345 | */ | 627 | */ |
346 | struct SendBuffer | 628 | struct Ieee80211RadiotapHeaderIterator |
347 | { | 629 | { |
348 | /** | 630 | /** |
349 | * How many bytes of data are stored in 'buf' for transmission right now? | 631 | * pointer to the radiotap header we are walking through |
350 | * Data always starts at offset 0 and extends to 'size'. | ||
351 | */ | 632 | */ |
352 | size_t size; | 633 | const struct Ieee80211RadiotapHeader *rtheader; |
353 | 634 | ||
354 | /** | 635 | /** |
355 | * How many bytes that were stored in 'buf' did we already write to the | 636 | * pointer to current radiotap arg |
356 | * destination? Always smaller than 'size'. | ||
357 | */ | 637 | */ |
358 | size_t pos; | 638 | const uint8_t *this_arg; |
359 | 639 | ||
360 | /** | 640 | /** |
361 | * Buffered data; twice the maximum allowed message size as we add some | 641 | * internal next argument pointer |
362 | * headers. | ||
363 | */ | 642 | */ |
364 | char buf[MAXLINE * 2]; | 643 | const uint8_t *arg; |
644 | |||
645 | /** | ||
646 | * internal pointer to next present uint32_t (if IEEE80211_RADIOTAP_EXT is used). | ||
647 | */ | ||
648 | const uint32_t *next_bitmap; | ||
649 | |||
650 | /** | ||
651 | * length of radiotap header in host byte ordering | ||
652 | */ | ||
653 | size_t max_length; | ||
654 | |||
655 | /** | ||
656 | * internal shifter for current uint32_t bitmap, (it_present in host byte order), | ||
657 | * If bit 0 is set, the 'arg_index' argument is present. | ||
658 | */ | ||
659 | uint32_t bitmap_shifter; | ||
660 | |||
661 | /** | ||
662 | * IEEE80211_RADIOTAP_... index of current arg | ||
663 | */ | ||
664 | unsigned int this_arg_index; | ||
665 | |||
666 | /** | ||
667 | * internal next argument index | ||
668 | */ | ||
669 | unsigned int arg_index; | ||
670 | |||
365 | }; | 671 | }; |
366 | 672 | ||
367 | 673 | ||
674 | /* ************** end of structure of ARPHRD_IEEE80211_FULL ************** */ | ||
675 | |||
676 | /* ************************** our globals ******************************* */ | ||
677 | |||
368 | /** | 678 | /** |
369 | * struct for storing the information of the hardware | 679 | * struct for storing the information of the hardware. There is only |
680 | * one of these. | ||
370 | */ | 681 | */ |
371 | struct HardwareInfos | 682 | struct HardwareInfos |
372 | { | 683 | { |
@@ -395,50 +706,27 @@ struct HardwareInfos | |||
395 | 706 | ||
396 | 707 | ||
397 | /** | 708 | /** |
398 | * struct ieee80211_radiotap_iterator - tracks walk through present radiotap arguments | 709 | * IO buffer used for buffering data in transit (to wireless or to stdout). |
399 | * in the radiotap header. | ||
400 | */ | 710 | */ |
401 | struct ieee80211_radiotap_iterator | 711 | struct SendBuffer |
402 | { | 712 | { |
403 | /** | 713 | /** |
404 | * pointer to the radiotap header we are walking through | 714 | * How many bytes of data are stored in 'buf' for transmission right now? |
405 | */ | 715 | * Data always starts at offset 0 and extends to 'size'. |
406 | const struct ieee80211_radiotap_header *rtheader; | ||
407 | |||
408 | /** | ||
409 | * length of radiotap header in cpu byte ordering | ||
410 | */ | ||
411 | size_t max_length; | ||
412 | |||
413 | /** | ||
414 | * IEEE80211_RADIOTAP_... index of current arg | ||
415 | */ | ||
416 | unsigned int this_arg_index; | ||
417 | |||
418 | /** | ||
419 | * pointer to current radiotap arg | ||
420 | */ | ||
421 | uint8_t *this_arg; | ||
422 | |||
423 | /** | ||
424 | * internal next argument index | ||
425 | */ | ||
426 | unsigned int arg_index; | ||
427 | |||
428 | /** | ||
429 | * internal next argument pointer | ||
430 | */ | 716 | */ |
431 | uint8_t *arg; | 717 | size_t size; |
432 | 718 | ||
433 | /** | 719 | /** |
434 | * internal pointer to next present uint32_t | 720 | * How many bytes that were stored in 'buf' did we already write to the |
721 | * destination? Always smaller than 'size'. | ||
435 | */ | 722 | */ |
436 | uint32_t *next_bitmap; | 723 | size_t pos; |
437 | 724 | ||
438 | /** | 725 | /** |
439 | * internal shifter for curr uint32_t bitmap, b0 set == arg present | 726 | * Buffered data; twice the maximum allowed message size as we add some |
727 | * headers. | ||
440 | */ | 728 | */ |
441 | uint32_t bitmap_shifter; | 729 | char buf[MAXLINE * 2]; |
442 | }; | 730 | }; |
443 | 731 | ||
444 | 732 | ||
@@ -454,8 +742,12 @@ static struct SendBuffer write_std; | |||
454 | 742 | ||
455 | 743 | ||
456 | 744 | ||
457 | /* specialized version of server_mst.c begins here */ | 745 | /* *********** specialized version of server_mst.c begins here ********** */ |
458 | 746 | ||
747 | /** | ||
748 | * To what multiple do we align messages? 8 byte should suffice for everyone | ||
749 | * for now. | ||
750 | */ | ||
459 | #define ALIGN_FACTOR 8 | 751 | #define ALIGN_FACTOR 8 |
460 | 752 | ||
461 | /** | 753 | /** |
@@ -530,10 +822,16 @@ mst_create (MessageTokenizerCallback cb, | |||
530 | 822 | ||
531 | ret = malloc (sizeof (struct MessageStreamTokenizer)); | 823 | ret = malloc (sizeof (struct MessageStreamTokenizer)); |
532 | if (NULL == ret) | 824 | if (NULL == ret) |
825 | { | ||
826 | fprintf (stderr, "Failed to allocate buffer for tokenizer\n"); | ||
533 | exit (1); | 827 | exit (1); |
828 | } | ||
534 | ret->hdr = malloc (MIN_BUFFER_SIZE); | 829 | ret->hdr = malloc (MIN_BUFFER_SIZE); |
535 | if (NULL == ret->hdr) | 830 | if (NULL == ret->hdr) |
536 | exit (2); | 831 | { |
832 | fprintf (stderr, "Failed to allocate buffer for alignment\n"); | ||
833 | exit (1); | ||
834 | } | ||
537 | ret->curr_buf = MIN_BUFFER_SIZE; | 835 | ret->curr_buf = MIN_BUFFER_SIZE; |
538 | ret->cb = cb; | 836 | ret->cb = cb; |
539 | ret->cb_cls = cb_cls; | 837 | ret->cb_cls = cb_cls; |
@@ -594,8 +892,9 @@ do_align: | |||
594 | want = ntohs (hdr->size); | 892 | want = ntohs (hdr->size); |
595 | if (want < sizeof (struct GNUNET_MessageHeader)) | 893 | if (want < sizeof (struct GNUNET_MessageHeader)) |
596 | { | 894 | { |
597 | // GNUNET_break_op (0); | 895 | fprintf (stderr, |
598 | return GNUNET_SYSERR; | 896 | "Received invalid message from stdin\n"); |
897 | exit (1); | ||
599 | } | 898 | } |
600 | if (mst->curr_buf - mst->off < want) | 899 | if (mst->curr_buf - mst->off < want) |
601 | { | 900 | { |
@@ -608,7 +907,10 @@ do_align: | |||
608 | { | 907 | { |
609 | mst->hdr = realloc (mst->hdr, want); | 908 | mst->hdr = realloc (mst->hdr, want); |
610 | if (NULL == mst->hdr) | 909 | if (NULL == mst->hdr) |
611 | exit (3); | 910 | { |
911 | fprintf (stderr, "Failed to allocate buffer for alignment\n"); | ||
912 | exit (1); | ||
913 | } | ||
612 | ibuf = (char *) mst->hdr; | 914 | ibuf = (char *) mst->hdr; |
613 | mst->curr_buf = want; | 915 | mst->curr_buf = want; |
614 | } | 916 | } |
@@ -647,9 +949,9 @@ do_align: | |||
647 | want = ntohs (hdr->size); | 949 | want = ntohs (hdr->size); |
648 | if (want < sizeof (struct GNUNET_MessageHeader)) | 950 | if (want < sizeof (struct GNUNET_MessageHeader)) |
649 | { | 951 | { |
650 | // GNUNET_break_op (0); | 952 | fprintf (stderr, |
651 | mst->off = 0; | 953 | "Received invalid message from stdin\n"); |
652 | return GNUNET_SYSERR; | 954 | exit (1); |
653 | } | 955 | } |
654 | if (size < want) | 956 | if (size < want) |
655 | break; /* or not, buffer incomplete, so copy to private buffer... */ | 957 | break; /* or not, buffer incomplete, so copy to private buffer... */ |
@@ -670,11 +972,19 @@ do_align: | |||
670 | { | 972 | { |
671 | mst->hdr = realloc (mst->hdr, size + mst->pos); | 973 | mst->hdr = realloc (mst->hdr, size + mst->pos); |
672 | if (NULL == mst->hdr) | 974 | if (NULL == mst->hdr) |
673 | exit (4); | 975 | { |
976 | fprintf (stderr, "Failed to allocate buffer for alignment\n"); | ||
977 | exit (1); | ||
978 | } | ||
674 | ibuf = (char *) mst->hdr; | 979 | ibuf = (char *) mst->hdr; |
675 | mst->curr_buf = size + mst->pos; | 980 | mst->curr_buf = size + mst->pos; |
676 | } | 981 | } |
677 | // GNUNET_assert (mst->pos + size <= mst->curr_buf); | 982 | if (mst->pos + size > mst->curr_buf) |
983 | { | ||
984 | fprintf (stderr, | ||
985 | "Assertion failed\n"); | ||
986 | exit (1); | ||
987 | } | ||
678 | memcpy (&ibuf[mst->pos], buf, size); | 988 | memcpy (&ibuf[mst->pos], buf, size); |
679 | mst->pos += size; | 989 | mst->pos += size; |
680 | } | 990 | } |
@@ -694,16 +1004,16 @@ mst_destroy (struct MessageStreamTokenizer *mst) | |||
694 | free (mst); | 1004 | free (mst); |
695 | } | 1005 | } |
696 | 1006 | ||
697 | /* end of server_mst.c copy */ | 1007 | /* ***************** end of server_mst.c clone ***************** **/ |
698 | |||
699 | 1008 | ||
700 | 1009 | ||
1010 | /* ************** code for handling of ARPHRD_IEEE80211_FULL ************** */ | ||
701 | 1011 | ||
702 | /** | 1012 | /** |
703 | * Radiotap header iteration | 1013 | * Radiotap header iteration |
704 | * | 1014 | * |
705 | * call __ieee80211_radiotap_iterator_init() to init a semi-opaque iterator | 1015 | * call __ieee80211_radiotap_iterator_init() to init a semi-opaque iterator |
706 | * struct ieee80211_radiotap_iterator (no need to init the struct beforehand) | 1016 | * struct Ieee80211RadiotapHeaderIterator (no need to init the struct beforehand) |
707 | * then loop calling __ieee80211_radiotap_iterator_next()... it returns -1 | 1017 | * then loop calling __ieee80211_radiotap_iterator_next()... it returns -1 |
708 | * if there are no more args in the header, or the next argument type index | 1018 | * if there are no more args in the header, or the next argument type index |
709 | * that is present. The iterator's this_arg member points to the start of the | 1019 | * that is present. The iterator's this_arg member points to the start of the |
@@ -717,9 +1027,8 @@ mst_destroy (struct MessageStreamTokenizer *mst) | |||
717 | * @return 0 on success, -1 on error | 1027 | * @return 0 on success, -1 on error |
718 | */ | 1028 | */ |
719 | static int | 1029 | static int |
720 | ieee80211_radiotap_iterator_init (struct ieee80211_radiotap_iterator *iterator, | 1030 | ieee80211_radiotap_iterator_init (struct Ieee80211RadiotapHeaderIterator *iterator, |
721 | const struct ieee80211_radiotap_header | 1031 | const struct Ieee80211RadiotapHeader *radiotap_header, |
722 | *radiotap_header, | ||
723 | size_t max_length) | 1032 | size_t max_length) |
724 | { | 1033 | { |
725 | if ( (iterator == NULL) || | 1034 | if ( (iterator == NULL) || |
@@ -731,26 +1040,22 @@ ieee80211_radiotap_iterator_init (struct ieee80211_radiotap_iterator *iterator, | |||
731 | return -1; | 1040 | return -1; |
732 | 1041 | ||
733 | /* sanity check for allowed length and radiotap length field */ | 1042 | /* sanity check for allowed length and radiotap length field */ |
734 | if ( (max_length < sizeof (struct ieee80211_radiotap_header)) || | 1043 | if ( (max_length < sizeof (struct Ieee80211RadiotapHeader)) || |
735 | (max_length < (GNUNET_le16toh (radiotap_header->it_len))) ) | 1044 | (max_length < (GNUNET_le16toh (radiotap_header->it_len))) ) |
736 | return -1; | 1045 | return -1; |
737 | 1046 | ||
1047 | memset (iterator, 0, sizeof (struct Ieee80211RadiotapHeaderIterator)); | ||
738 | iterator->rtheader = radiotap_header; | 1048 | iterator->rtheader = radiotap_header; |
739 | iterator->max_length = GNUNET_le16toh (radiotap_header->it_len); | 1049 | iterator->max_length = GNUNET_le16toh (radiotap_header->it_len); |
740 | iterator->arg_index = 0; | ||
741 | iterator->bitmap_shifter = GNUNET_le32toh (radiotap_header->it_present); | 1050 | iterator->bitmap_shifter = GNUNET_le32toh (radiotap_header->it_present); |
742 | iterator->arg = | 1051 | iterator->arg = ((uint8_t *) radiotap_header) + sizeof (struct Ieee80211RadiotapHeader); |
743 | ((uint8_t *) radiotap_header) + sizeof (struct ieee80211_radiotap_header); | ||
744 | iterator->this_arg = 0; | ||
745 | 1052 | ||
746 | /* find payload start allowing for extended bitmap(s) */ | 1053 | /* find payload start allowing for extended bitmap(s) */ |
747 | if ((iterator->bitmap_shifter & IEEE80211_RADIOTAP_PRESENT_EXTEND_MASK)) | 1054 | if (0 != (iterator->bitmap_shifter & IEEE80211_RADIOTAP_PRESENT_EXTEND_MASK)) |
748 | { | 1055 | { |
749 | while (GNUNET_le32toh (*((uint32_t *) iterator->arg)) & | 1056 | while (GNUNET_le32toh (*((uint32_t *) iterator->arg)) & IEEE80211_RADIOTAP_PRESENT_EXTEND_MASK) |
750 | IEEE80211_RADIOTAP_PRESENT_EXTEND_MASK) | ||
751 | { | 1057 | { |
752 | iterator->arg += sizeof (uint32_t); | 1058 | iterator->arg += sizeof (uint32_t); |
753 | |||
754 | /* | 1059 | /* |
755 | * check for insanity where the present bitmaps | 1060 | * check for insanity where the present bitmaps |
756 | * keep claiming to extend up to or even beyond the | 1061 | * keep claiming to extend up to or even beyond the |
@@ -772,7 +1077,7 @@ ieee80211_radiotap_iterator_init (struct ieee80211_radiotap_iterator *iterator, | |||
772 | 1077 | ||
773 | 1078 | ||
774 | /** | 1079 | /** |
775 | * @brief ieee80211_radiotap_iterator_next - return next radiotap parser iterator arg | 1080 | * Returns the next radiotap parser iterator arg. |
776 | * | 1081 | * |
777 | * This function returns the next radiotap arg index (IEEE80211_RADIOTAP_...) | 1082 | * This function returns the next radiotap arg index (IEEE80211_RADIOTAP_...) |
778 | * and sets iterator->this_arg to point to the payload for the arg. It takes | 1083 | * and sets iterator->this_arg to point to the payload for the arg. It takes |
@@ -781,13 +1086,11 @@ ieee80211_radiotap_iterator_init (struct ieee80211_radiotap_iterator *iterator, | |||
781 | * format. | 1086 | * format. |
782 | * | 1087 | * |
783 | * @param iterator: radiotap_iterator to move to next arg (if any) | 1088 | * @param iterator: radiotap_iterator to move to next arg (if any) |
784 | * | ||
785 | * @return next present arg index on success or -1 if no more or error | 1089 | * @return next present arg index on success or -1 if no more or error |
786 | */ | 1090 | */ |
787 | static int | 1091 | static int |
788 | ieee80211_radiotap_iterator_next (struct ieee80211_radiotap_iterator *iterator) | 1092 | ieee80211_radiotap_iterator_next (struct Ieee80211RadiotapHeaderIterator *iterator) |
789 | { | 1093 | { |
790 | |||
791 | /* | 1094 | /* |
792 | * small length lookup table for all radiotap types we heard of | 1095 | * small length lookup table for all radiotap types we heard of |
793 | * starting from b0 in the bitmap, so we can walk the payload | 1096 | * starting from b0 in the bitmap, so we can walk the payload |
@@ -832,120 +1135,103 @@ ieee80211_radiotap_iterator_next (struct ieee80211_radiotap_iterator *iterator) | |||
832 | * for every radiotap entry we can at | 1135 | * for every radiotap entry we can at |
833 | * least skip (by knowing the length)... | 1136 | * least skip (by knowing the length)... |
834 | */ | 1137 | */ |
835 | |||
836 | while (iterator->arg_index < sizeof (rt_sizes)) | 1138 | while (iterator->arg_index < sizeof (rt_sizes)) |
837 | { | 1139 | { |
838 | int hit = 0; | 1140 | int hit = (0 != (iterator->bitmap_shifter & 1)); |
839 | |||
840 | if (!(iterator->bitmap_shifter & 1)) | ||
841 | goto next_entry; /* arg not present */ | ||
842 | 1141 | ||
843 | /* | 1142 | if (hit) |
844 | * arg is present, account for alignment padding | 1143 | { |
845 | * 8-bit args can be at any alignment | 1144 | unsigned int wanted_alignment; |
846 | * 16-bit args must start on 16-bit boundary | 1145 | unsigned int unalignment; |
847 | * 32-bit args must start on 32-bit boundary | 1146 | /* |
848 | * 64-bit args must start on 64-bit boundary | 1147 | * arg is present, account for alignment padding |
849 | * | 1148 | * 8-bit args can be at any alignment |
850 | * note that total arg size can differ from alignment of | 1149 | * 16-bit args must start on 16-bit boundary |
851 | * elements inside arg, so we use upper nybble of length | 1150 | * 32-bit args must start on 32-bit boundary |
852 | * table to base alignment on | 1151 | * 64-bit args must start on 64-bit boundary |
853 | * | 1152 | * |
854 | * also note: these alignments are ** relative to the | 1153 | * note that total arg size can differ from alignment of |
855 | * start of the radiotap header **. There is no guarantee | 1154 | * elements inside arg, so we use upper nybble of length table |
856 | * that the radiotap header itself is aligned on any | 1155 | * to base alignment on. First, 'wanted_alignment' is set to be |
857 | * kind of boundary. | 1156 | * 1 for 8-bit, 2 for 16-bit, 4 for 32-bit and 8 for 64-bit |
858 | */ | 1157 | * arguments. Then, we calculate the 'unalignment' (how many |
859 | 1158 | * bytes we are over by taking the difference of 'arg' and the | |
860 | if ((((void *) iterator->arg) - | 1159 | * overall starting point modulo the desired alignment. As |
861 | ((void *) iterator->rtheader)) & ((rt_sizes[iterator->arg_index] >> 4) | 1160 | * desired alignments are powers of two, we can do modulo with |
862 | - 1)) | 1161 | * binary "&" (and also avoid the possibility of a division by |
863 | iterator->arg_index += | 1162 | * zero if the 'rt_sizes' table contains bogus entries). |
864 | (rt_sizes[iterator->arg_index] >> 4) - | 1163 | * |
865 | ((((void *) iterator->arg) - | 1164 | * also note: these alignments are relative to the start of the |
866 | ((void *) iterator->rtheader)) & ((rt_sizes[iterator->arg_index] >> | 1165 | * radiotap header. There is no guarantee that the radiotap |
867 | 4) - 1)); | 1166 | * header itself is aligned on any kind of boundary, thus we |
868 | 1167 | * need to really look at the delta here. | |
869 | /* | 1168 | */ |
870 | * this is what we will return to user, but we need to | 1169 | wanted_alignment = rt_sizes[iterator->arg_index] >> 4; |
871 | * move on first so next call has something fresh to test | 1170 | unalignment = (((void *) iterator->arg) - ((void *) iterator->rtheader)) & (wanted_alignment - 1); |
872 | */ | 1171 | if (0 != unalignment) |
873 | 1172 | { | |
874 | iterator->this_arg_index = iterator->arg_index; | 1173 | /* need padding (by 'wanted_alignment - unalignment') */ |
875 | iterator->this_arg = iterator->arg; | 1174 | iterator->arg_index += wanted_alignment - unalignment; |
876 | hit = 1; | 1175 | } |
877 | 1176 | ||
878 | /* internally move on the size of this arg */ | 1177 | /* |
879 | 1178 | * this is what we will return to user, but we need to | |
880 | iterator->arg += rt_sizes[iterator->arg_index] & 0x0f; | 1179 | * move on first so next call has something fresh to test |
881 | 1180 | */ | |
882 | /* | 1181 | iterator->this_arg_index = iterator->arg_index; |
883 | * check for insanity where we are given a bitmap that | 1182 | iterator->this_arg = iterator->arg; |
884 | * claims to have more arg content than the length of the | 1183 | |
885 | * radiotap section. We will normally end up equalling this | 1184 | /* internally move on the size of this arg (using lower nybble from |
886 | * max_length on the last arg, never exceeding it. | 1185 | the table) */ |
887 | */ | 1186 | iterator->arg += rt_sizes[iterator->arg_index] & 0x0f; |
888 | 1187 | ||
889 | if ((((void *) iterator->arg) - ((void *) iterator->rtheader)) > | 1188 | /* |
890 | iterator->max_length) | 1189 | * check for insanity where we are given a bitmap that |
891 | return -1; | 1190 | * claims to have more arg content than the length of the |
892 | 1191 | * radiotap section. We will normally end up equalling this | |
893 | next_entry: | 1192 | * max_length on the last arg, never exceeding it. |
1193 | */ | ||
1194 | if ((((void *) iterator->arg) - ((void *) iterator->rtheader)) > iterator->max_length) | ||
1195 | return -1; | ||
1196 | } | ||
894 | 1197 | ||
1198 | /* Now, move on to next bit / next entry */ | ||
895 | iterator->arg_index++; | 1199 | iterator->arg_index++; |
896 | if (((iterator->arg_index & 31) == 0)) | 1200 | |
1201 | if (0 == (iterator->arg_index % 32)) | ||
897 | { | 1202 | { |
898 | /* completed current uint32_t bitmap */ | 1203 | /* completed current uint32_t bitmap */ |
899 | if (iterator->bitmap_shifter & 1) | 1204 | if (0 != (iterator->bitmap_shifter & 1)) |
900 | { | 1205 | { |
901 | /* b31 was set, there is more */ | 1206 | /* bit 31 was set, there is more; move to next uint32_t bitmap */ |
902 | /* move to next uint32_t bitmap */ | ||
903 | iterator->bitmap_shifter = GNUNET_le32toh (*iterator->next_bitmap); | 1207 | iterator->bitmap_shifter = GNUNET_le32toh (*iterator->next_bitmap); |
904 | iterator->next_bitmap++; | 1208 | iterator->next_bitmap++; |
905 | } | 1209 | } |
906 | else | 1210 | else |
907 | { | 1211 | { |
908 | /* no more bitmaps: end */ | 1212 | /* no more bitmaps: end (by setting arg_index to high, unsupported value) */ |
909 | iterator->arg_index = sizeof (rt_sizes); | 1213 | iterator->arg_index = sizeof (rt_sizes); |
910 | } | 1214 | } |
911 | } | 1215 | } |
912 | else | 1216 | else |
913 | { /* just try the next bit */ | 1217 | { |
1218 | /* just try the next bit (while loop will move on) */ | ||
914 | iterator->bitmap_shifter >>= 1; | 1219 | iterator->bitmap_shifter >>= 1; |
915 | } | 1220 | } |
916 | 1221 | ||
917 | /* if we found a valid arg earlier, return it now */ | 1222 | /* if we found a valid arg earlier, return it now */ |
918 | |||
919 | if (hit) | 1223 | if (hit) |
920 | return iterator->this_arg_index; | 1224 | return iterator->this_arg_index; |
921 | |||
922 | } | 1225 | } |
923 | 1226 | ||
924 | /* we don't know how to handle any more args, we're done */ | 1227 | /* we don't know how to handle any more args (or there are no more), |
925 | return -1; | 1228 | so we're done (this is not an error) */ |
926 | } | ||
927 | |||
928 | |||
929 | /** | ||
930 | * Return the channel from the frequency (in Mhz) | ||
931 | * @param frequency of the channel | ||
932 | * @return number of the channel | ||
933 | */ | ||
934 | static int | ||
935 | get_channel_from_frequency (int frequency) | ||
936 | { | ||
937 | if (frequency >= 2412 && frequency <= 2472) | ||
938 | return (frequency - 2407) / 5; | ||
939 | if (frequency == 2484) | ||
940 | return 14; | ||
941 | if (frequency >= 5000 && frequency <= 6100) | ||
942 | return (frequency - 5000) / 5; | ||
943 | return -1; | 1229 | return -1; |
944 | } | 1230 | } |
945 | 1231 | ||
946 | 1232 | ||
947 | /** | 1233 | /** |
948 | * function to calculate the crc, the start of the calculation | 1234 | * Calculate crc32, the start of the calculation |
949 | * | 1235 | * |
950 | * @param buf buffer to calc the crc | 1236 | * @param buf buffer to calc the crc |
951 | * @param len len of the buffer | 1237 | * @param len len of the buffer |
@@ -1030,7 +1316,7 @@ calc_crc_osdep (const unsigned char *buf, size_t len) | |||
1030 | 1316 | ||
1031 | 1317 | ||
1032 | /** | 1318 | /** |
1033 | * Function to calculate and check crc of the wlan packet | 1319 | * Calculate and check crc of the wlan packet |
1034 | * | 1320 | * |
1035 | * @param buf buffer of the packet, with len + 4 bytes of data, | 1321 | * @param buf buffer of the packet, with len + 4 bytes of data, |
1036 | * the last 4 bytes being the checksum | 1322 | * the last 4 bytes being the checksum |
@@ -1051,6 +1337,30 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len) | |||
1051 | } | 1337 | } |
1052 | 1338 | ||
1053 | 1339 | ||
1340 | /* ************end of code for handling of ARPHRD_IEEE80211_FULL ************** */ | ||
1341 | |||
1342 | |||
1343 | /* ************beginning of code for reading packets from kernel ************** */ | ||
1344 | |||
1345 | /** | ||
1346 | * Return the channel from the frequency (in Mhz) | ||
1347 | * | ||
1348 | * @param frequency of the channel | ||
1349 | * @return number of the channel | ||
1350 | */ | ||
1351 | static int | ||
1352 | get_channel_from_frequency (int32_t frequency) | ||
1353 | { | ||
1354 | if (frequency >= 2412 && frequency <= 2472) | ||
1355 | return (frequency - 2407) / 5; | ||
1356 | if (frequency == 2484) | ||
1357 | return 14; | ||
1358 | if (frequency >= 5000 && frequency <= 6100) | ||
1359 | return (frequency - 5000) / 5; | ||
1360 | return -1; | ||
1361 | } | ||
1362 | |||
1363 | |||
1054 | /** | 1364 | /** |
1055 | * Get the channel used by our WLAN interface. | 1365 | * Get the channel used by our WLAN interface. |
1056 | * | 1366 | * |
@@ -1061,36 +1371,33 @@ static int | |||
1061 | linux_get_channel (const struct HardwareInfos *dev) | 1371 | linux_get_channel (const struct HardwareInfos *dev) |
1062 | { | 1372 | { |
1063 | struct iwreq wrq; | 1373 | struct iwreq wrq; |
1064 | int fd; | 1374 | int32_t frequency; |
1065 | int frequency; | ||
1066 | int chan; | ||
1067 | 1375 | ||
1068 | memset (&wrq, 0, sizeof (struct iwreq)); | 1376 | memset (&wrq, 0, sizeof (struct iwreq)); |
1069 | strncpy (wrq.ifr_name, dev->iface, IFNAMSIZ); | 1377 | strncpy (wrq.ifr_name, dev->iface, IFNAMSIZ); |
1070 | fd = dev->fd_raw; | 1378 | if (0 > ioctl (dev->fd_raw, SIOCGIWFREQ, &wrq)) |
1071 | if (0 > ioctl (fd, SIOCGIWFREQ, &wrq)) | ||
1072 | return -1; | 1379 | return -1; |
1073 | 1380 | frequency = wrq.u.freq.m; /* 'iw_freq' defines 'm' as '__s32', so we keep it signed */ | |
1074 | frequency = wrq.u.freq.m; | ||
1075 | if (100000000 < frequency) | 1381 | if (100000000 < frequency) |
1076 | frequency /= 100000; | 1382 | frequency /= 100000; |
1077 | else if (1000000 < frequency) | 1383 | else if (1000000 < frequency) |
1078 | frequency /= 1000; | 1384 | frequency /= 1000; |
1079 | if (1000 < frequency) | 1385 | if (1000 < frequency) |
1080 | chan = get_channel_from_frequency (frequency); | 1386 | return get_channel_from_frequency (frequency); |
1081 | else | 1387 | return frequency; |
1082 | chan = frequency; | ||
1083 | return chan; | ||
1084 | } | 1388 | } |
1085 | 1389 | ||
1086 | 1390 | ||
1087 | /** | 1391 | /** |
1088 | * function to read from a wlan card | 1392 | * Read from the raw socket (the wlan card), parse the packet and |
1393 | * put the result into the buffer for transmission to 'stdout'. | ||
1394 | * | ||
1089 | * @param dev pointer to the struct of the wlan card | 1395 | * @param dev pointer to the struct of the wlan card |
1090 | * @param buf buffer to read to | 1396 | * @param buf buffer to read to; first bytes will be the 'struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame', |
1397 | * followed by the actual payload | ||
1091 | * @param buf_size size of the buffer | 1398 | * @param buf_size size of the buffer |
1092 | * @param ri where to write radiotap_rx info | 1399 | * @param ri where to write radiotap_rx info |
1093 | * @return size read from the buffer | 1400 | * @return number of bytes written to 'buf' |
1094 | */ | 1401 | */ |
1095 | static ssize_t | 1402 | static ssize_t |
1096 | linux_read (struct HardwareInfos *dev, | 1403 | linux_read (struct HardwareInfos *dev, |
@@ -1099,9 +1406,11 @@ linux_read (struct HardwareInfos *dev, | |||
1099 | { | 1406 | { |
1100 | unsigned char tmpbuf[buf_size]; | 1407 | unsigned char tmpbuf[buf_size]; |
1101 | ssize_t caplen; | 1408 | ssize_t caplen; |
1102 | int n, got_signal, got_noise, got_channel, fcs_removed; | 1409 | size_t n; |
1103 | 1410 | int got_signal = 0; | |
1104 | n = got_signal = got_noise = got_channel = fcs_removed = 0; | 1411 | int got_noise = 0; |
1412 | int got_channel = 0; | ||
1413 | int fcs_removed = 0; | ||
1105 | 1414 | ||
1106 | caplen = read (dev->fd_raw, tmpbuf, buf_size); | 1415 | caplen = read (dev->fd_raw, tmpbuf, buf_size); |
1107 | if (0 > caplen) | 1416 | if (0 > caplen) |
@@ -1112,172 +1421,181 @@ linux_read (struct HardwareInfos *dev, | |||
1112 | return -1; | 1421 | return -1; |
1113 | } | 1422 | } |
1114 | 1423 | ||
1115 | memset (buf, 0, buf_size); | 1424 | memset (ri, 0, sizeof (*ri)); |
1116 | memset (ri, 0, sizeof (*ri)); | ||
1117 | |||
1118 | switch (dev->arptype_in) | 1425 | switch (dev->arptype_in) |
1119 | { | 1426 | { |
1120 | case ARPHRD_IEEE80211_PRISM: | 1427 | case ARPHRD_IEEE80211_PRISM: |
1121 | { | ||
1122 | /* skip the prism header */ | ||
1123 | if (tmpbuf[7] == 0x40) | ||
1124 | { | 1428 | { |
1125 | /* prism54 uses a different format */ | 1429 | const struct PrismHeader *ph; |
1126 | ri->ri_power = tmpbuf[0x33]; | 1430 | |
1127 | ri->ri_noise = *(unsigned int *) (tmpbuf + 0x33 + 12); | 1431 | ph = (const struct PrismHeader*) tmpbuf; |
1128 | ri->ri_rate = (*(unsigned int *) (tmpbuf + 0x33 + 24)) * 500000; | 1432 | n = ph->msglen; |
1129 | got_signal = 1; | 1433 | if ( (n < 8) || (n >= caplen) ) |
1130 | got_noise = 1; | 1434 | return 0; /* invalid format */ |
1131 | n = 0x40; | 1435 | if ( (PRISM_MSGCODE_MONITOR == ph->msgcode) && |
1132 | } | 1436 | (n >= sizeof (struct PrismHeader)) ) |
1133 | else | 1437 | { |
1134 | { | 1438 | const char *pos; |
1135 | ri->ri_mactime = *(uint64_t *) (tmpbuf + 0x5C - 48); | 1439 | size_t left; |
1136 | ri->ri_channel = *(unsigned int *) (tmpbuf + 0x5C - 36); | 1440 | struct PrismValue pv; |
1137 | ri->ri_power = *(unsigned int *) (tmpbuf + 0x5C); | 1441 | |
1138 | ri->ri_noise = *(unsigned int *) (tmpbuf + 0x5C + 12); | 1442 | left = n - sizeof (struct PrismHeader); |
1139 | ri->ri_rate = (*(unsigned int *) (tmpbuf + 0x5C + 24)) * 500000; | 1443 | pos = (const char *) &ph[1]; |
1140 | got_channel = 1; | 1444 | while (left > sizeof (struct PrismValue)) |
1141 | got_signal = 1; | 1445 | { |
1142 | got_noise = 1; | 1446 | left -= sizeof (struct PrismValue); |
1143 | n = *(int *) (tmpbuf + 4); | 1447 | memcpy (&pv, pos, sizeof (struct PrismValue)); |
1448 | pos += sizeof (struct PrismValue); | ||
1449 | |||
1450 | switch (pv.did) | ||
1451 | { | ||
1452 | case PRISM_DID_NOISE: | ||
1453 | if (PRISM_STATUS_OK == pv.status) | ||
1454 | { | ||
1455 | ri->ri_noise = pv.data; | ||
1456 | got_noise = 1; | ||
1457 | } | ||
1458 | break; | ||
1459 | case PRISM_DID_RATE: | ||
1460 | if (PRISM_STATUS_OK == pv.status) | ||
1461 | ri->ri_rate = pv.data * 500000; | ||
1462 | break; | ||
1463 | case PRISM_DID_CHANNEL: | ||
1464 | if (PRISM_STATUS_OK == pv.status) | ||
1465 | { | ||
1466 | ri->ri_channel = pv.data; | ||
1467 | got_channel = 1; | ||
1468 | } | ||
1469 | break; | ||
1470 | case PRISM_DID_MACTIME: | ||
1471 | if (PRISM_STATUS_OK == pv.status) | ||
1472 | ri->ri_mactime = pv.data; | ||
1473 | break; | ||
1474 | case PRISM_DID_SIGNAL: | ||
1475 | if (PRISM_STATUS_OK == pv.status) | ||
1476 | { | ||
1477 | ri->ri_power = pv.data; | ||
1478 | got_signal = 1; | ||
1479 | } | ||
1480 | break; | ||
1481 | } | ||
1482 | } | ||
1483 | } | ||
1484 | if ( (n < 8) || (n >= caplen) ) | ||
1485 | return 0; /* invalid format */ | ||
1144 | } | 1486 | } |
1145 | |||
1146 | if ( (n < 8) || (n >= caplen) ) | ||
1147 | return 0; | ||
1148 | } | ||
1149 | break; | 1487 | break; |
1150 | |||
1151 | case ARPHRD_IEEE80211_FULL: | 1488 | case ARPHRD_IEEE80211_FULL: |
1152 | { | ||
1153 | struct ieee80211_radiotap_iterator iterator; | ||
1154 | struct ieee80211_radiotap_header *rthdr; | ||
1155 | |||
1156 | memset (&iterator, 0, sizeof (iterator)); | ||
1157 | rthdr = (struct ieee80211_radiotap_header *) tmpbuf; | ||
1158 | |||
1159 | if (0 != ieee80211_radiotap_iterator_init (&iterator, rthdr, caplen)) | ||
1160 | return 0; | ||
1161 | |||
1162 | /* go through the radiotap arguments we have been given | ||
1163 | * by the driver | ||
1164 | */ | ||
1165 | |||
1166 | while (ieee80211_radiotap_iterator_next (&iterator) >= 0) | ||
1167 | { | 1489 | { |
1168 | 1490 | struct Ieee80211RadiotapHeaderIterator iterator; | |
1169 | switch (iterator.this_arg_index) | 1491 | struct Ieee80211RadiotapHeader *rthdr; |
1492 | |||
1493 | memset (&iterator, 0, sizeof (iterator)); | ||
1494 | rthdr = (struct Ieee80211RadiotapHeader *) tmpbuf; | ||
1495 | n = GNUNET_le16toh (rthdr->it_len); | ||
1496 | if ( (n < sizeof (struct Ieee80211RadiotapHeader)) || (n >= caplen)) | ||
1497 | return 0; /* invalid 'it_len' */ | ||
1498 | if (0 != ieee80211_radiotap_iterator_init (&iterator, rthdr, caplen)) | ||
1499 | return 0; | ||
1500 | /* go through the radiotap arguments we have been given by the driver */ | ||
1501 | while (0 <= ieee80211_radiotap_iterator_next (&iterator)) | ||
1170 | { | 1502 | { |
1171 | 1503 | switch (iterator.this_arg_index) | |
1172 | case IEEE80211_RADIOTAP_TSFT: | 1504 | { |
1173 | ri->ri_mactime = GNUNET_le64toh (*((uint64_t *) iterator.this_arg)); | 1505 | case IEEE80211_RADIOTAP_TSFT: |
1174 | break; | 1506 | ri->ri_mactime = GNUNET_le64toh (*((uint64_t *) iterator.this_arg)); |
1175 | 1507 | break; | |
1176 | case IEEE80211_RADIOTAP_DBM_ANTSIGNAL: | 1508 | case IEEE80211_RADIOTAP_DBM_ANTSIGNAL: |
1177 | if (!got_signal) | 1509 | if (!got_signal) |
1178 | { | 1510 | { |
1179 | if (*iterator.this_arg < 127) | 1511 | ri->ri_power = * ((int8_t*) iterator.this_arg); |
1180 | ri->ri_power = *iterator.this_arg; | 1512 | got_signal = 1; |
1181 | else | 1513 | } |
1182 | ri->ri_power = *iterator.this_arg - 255; | 1514 | break; |
1183 | 1515 | case IEEE80211_RADIOTAP_DB_ANTSIGNAL: | |
1184 | got_signal = 1; | 1516 | if (!got_signal) |
1185 | } | 1517 | { |
1186 | break; | 1518 | ri->ri_power = * ((int8_t*) iterator.this_arg); |
1187 | 1519 | got_signal = 1; | |
1188 | case IEEE80211_RADIOTAP_DB_ANTSIGNAL: | 1520 | } |
1189 | if (!got_signal) | 1521 | break; |
1190 | { | 1522 | case IEEE80211_RADIOTAP_DBM_ANTNOISE: |
1191 | if (*iterator.this_arg < 127) | 1523 | if (!got_noise) |
1192 | ri->ri_power = *iterator.this_arg; | 1524 | { |
1193 | else | 1525 | ri->ri_noise = * ((int8_t*) iterator.this_arg); |
1194 | ri->ri_power = *iterator.this_arg - 255; | 1526 | got_noise = 1; |
1195 | 1527 | } | |
1196 | got_signal = 1; | 1528 | break; |
1197 | } | 1529 | case IEEE80211_RADIOTAP_DB_ANTNOISE: |
1198 | break; | 1530 | if (!got_noise) |
1199 | 1531 | { | |
1200 | case IEEE80211_RADIOTAP_DBM_ANTNOISE: | 1532 | ri->ri_noise = * ((int8_t*) iterator.this_arg); |
1201 | if (!got_noise) | 1533 | got_noise = 1; |
1202 | { | 1534 | } |
1203 | if (*iterator.this_arg < 127) | 1535 | break; |
1204 | ri->ri_noise = *iterator.this_arg; | 1536 | case IEEE80211_RADIOTAP_ANTENNA: |
1205 | else | 1537 | ri->ri_antenna = *iterator.this_arg; |
1206 | ri->ri_noise = *iterator.this_arg - 255; | 1538 | break; |
1207 | 1539 | case IEEE80211_RADIOTAP_CHANNEL: | |
1208 | got_noise = 1; | 1540 | ri->ri_channel = *iterator.this_arg; |
1209 | } | 1541 | got_channel = 1; |
1210 | break; | 1542 | break; |
1211 | 1543 | case IEEE80211_RADIOTAP_RATE: | |
1212 | case IEEE80211_RADIOTAP_DB_ANTNOISE: | 1544 | ri->ri_rate = (*iterator.this_arg) * 500000; |
1213 | if (!got_noise) | 1545 | break; |
1214 | { | 1546 | case IEEE80211_RADIOTAP_FLAGS: |
1215 | if (*iterator.this_arg < 127) | 1547 | { |
1216 | ri->ri_noise = *iterator.this_arg; | 1548 | uint8_t flags = *iterator.this_arg; |
1217 | else | 1549 | /* is the CRC visible at the end? if so, remove */ |
1218 | ri->ri_noise = *iterator.this_arg - 255; | 1550 | if (0 != (flags & IEEE80211_RADIOTAP_F_FCS)) |
1219 | 1551 | { | |
1220 | got_noise = 1; | 1552 | fcs_removed = 1; |
1221 | } | 1553 | caplen -= sizeof (uint32_t); |
1222 | break; | 1554 | } |
1223 | 1555 | break; | |
1224 | case IEEE80211_RADIOTAP_ANTENNA: | 1556 | } |
1225 | ri->ri_antenna = *iterator.this_arg; | 1557 | case IEEE80211_RADIOTAP_RX_FLAGS: |
1226 | break; | 1558 | { |
1227 | 1559 | uint16_t flags = ntohs (* ((uint16_t *) iterator.this_arg)); | |
1228 | case IEEE80211_RADIOTAP_CHANNEL: | 1560 | if (0 != (flags & IEEE80211_RADIOTAP_F_RX_BADFCS)) |
1229 | ri->ri_channel = *iterator.this_arg; | 1561 | return 0; |
1230 | got_channel = 1; | 1562 | } |
1231 | break; | 1563 | break; |
1232 | 1564 | } /* end of 'switch' */ | |
1233 | case IEEE80211_RADIOTAP_RATE: | 1565 | } /* end of the 'while' loop */ |
1234 | ri->ri_rate = (*iterator.this_arg) * 500000; | 1566 | } |
1235 | break; | ||
1236 | |||
1237 | case IEEE80211_RADIOTAP_FLAGS: | ||
1238 | /* is the CRC visible at the end? | ||
1239 | * remove | ||
1240 | */ | ||
1241 | if (*iterator.this_arg & IEEE80211_RADIOTAP_F_FCS) | ||
1242 | { | ||
1243 | fcs_removed = 1; | ||
1244 | caplen -= 4; | ||
1245 | } | ||
1246 | |||
1247 | if (*iterator.this_arg & IEEE80211_RADIOTAP_F_RX_BADFCS) | ||
1248 | return (0); | ||
1249 | |||
1250 | break; | ||
1251 | } | ||
1252 | } | ||
1253 | n = GNUNET_le16toh (rthdr->it_len); | ||
1254 | if (n <= 0 || n >= caplen) | ||
1255 | return 0; | ||
1256 | } | ||
1257 | break; | 1567 | break; |
1258 | case ARPHRD_IEEE80211: | 1568 | case ARPHRD_IEEE80211: |
1259 | /* do nothing? */ | 1569 | n = 0; /* no header */ |
1260 | break; | 1570 | break; |
1261 | default: | 1571 | default: |
1262 | errno = ENOTSUP; | 1572 | errno = ENOTSUP; /* unsupported format */ |
1263 | return -1; | 1573 | return -1; |
1264 | } | 1574 | } |
1265 | |||
1266 | caplen -= n; | 1575 | caplen -= n; |
1576 | if (! got_channel) | ||
1577 | ri->ri_channel = linux_get_channel (dev); | ||
1267 | 1578 | ||
1268 | //detect fcs at the end, even if the flag wasn't set and remove it | 1579 | /* detect CRC32 at the end, even if the flag wasn't set and remove it */ |
1269 | if ((0 == fcs_removed) && (0 == check_crc_buf_osdep (tmpbuf + n, caplen - 4))) | 1580 | if ( (0 == fcs_removed) && |
1581 | (0 == check_crc_buf_osdep (tmpbuf + n, caplen - sizeof (uint32_t))) ) | ||
1270 | { | 1582 | { |
1271 | caplen -= 4; | 1583 | /* NOTE: this heuristic can of course fail if there happens to |
1584 | be a matching checksum at the end. Would be good to have | ||
1585 | some data to see how often this heuristic actually works. */ | ||
1586 | caplen -= sizeof (uint32_t); | ||
1272 | } | 1587 | } |
1588 | /* copy payload to target buffer */ | ||
1273 | memcpy (buf, tmpbuf + n, caplen); | 1589 | memcpy (buf, tmpbuf + n, caplen); |
1274 | if (!got_channel) | ||
1275 | ri->ri_channel = linux_get_channel (dev); | ||
1276 | |||
1277 | return caplen; | 1590 | return caplen; |
1278 | } | 1591 | } |
1279 | 1592 | ||
1280 | 1593 | ||
1594 | /* ************end of code for reading packets from kernel ************** */ | ||
1595 | |||
1596 | /* ************other helper functions for main start here ************** */ | ||
1597 | |||
1598 | |||
1281 | /** | 1599 | /** |
1282 | * Open the wireless network interface for reading/writing. | 1600 | * Open the wireless network interface for reading/writing. |
1283 | * | 1601 | * |
@@ -1383,11 +1701,12 @@ open_device_raw (struct HardwareInfos *dev) | |||
1383 | setsockopt (dev->fd_raw, SOL_PACKET, PACKET_ADD_MEMBERSHIP, &mr, | 1701 | setsockopt (dev->fd_raw, SOL_PACKET, PACKET_ADD_MEMBERSHIP, &mr, |
1384 | sizeof (mr))) | 1702 | sizeof (mr))) |
1385 | { | 1703 | { |
1386 | fprintf (stderr, "Failed to enable promiscuous mode on interface `%.*s'\n", | 1704 | fprintf (stderr, |
1387 | IFNAMSIZ, dev->iface); | 1705 | "Failed to enable promiscuous mode on interface `%.*s'\n", |
1706 | IFNAMSIZ, | ||
1707 | dev->iface); | ||
1388 | return 1; | 1708 | return 1; |
1389 | } | 1709 | } |
1390 | |||
1391 | return 0; | 1710 | return 0; |
1392 | } | 1711 | } |
1393 | 1712 | ||
@@ -1406,21 +1725,22 @@ test_wlan_interface (const char *iface) | |||
1406 | struct stat sbuf; | 1725 | struct stat sbuf; |
1407 | int ret; | 1726 | int ret; |
1408 | 1727 | ||
1409 | /* mac80211 stack detection */ | 1728 | ret = snprintf (strbuf, sizeof (strbuf), |
1410 | ret = | 1729 | "/sys/class/net/%s/phy80211/subsystem", |
1411 | snprintf (strbuf, sizeof (strbuf), "/sys/class/net/%s/phy80211/subsystem", | 1730 | iface); |
1412 | iface); | ||
1413 | if ((ret < 0) || (ret >= sizeof (strbuf)) || (0 != stat (strbuf, &sbuf))) | 1731 | if ((ret < 0) || (ret >= sizeof (strbuf)) || (0 != stat (strbuf, &sbuf))) |
1414 | { | 1732 | { |
1415 | fprintf (stderr, "Did not find 802.11 interface `%s'. Exiting.\n", iface); | 1733 | fprintf (stderr, |
1416 | return 1; | 1734 | "Did not find 802.11 interface `%s'. Exiting.\n", |
1735 | iface); | ||
1736 | exit (1); | ||
1417 | } | 1737 | } |
1418 | return 0; | 1738 | return 0; |
1419 | } | 1739 | } |
1420 | 1740 | ||
1421 | 1741 | ||
1422 | /** | 1742 | /** |
1423 | * Function to test incoming packets mac for being our own. | 1743 | * Test incoming packets mac for being our own. |
1424 | * | 1744 | * |
1425 | * @param taIeeeHeader buffer of the packet | 1745 | * @param taIeeeHeader buffer of the packet |
1426 | * @param dev the Hardware_Infos struct | 1746 | * @param dev the Hardware_Infos struct |
@@ -1431,17 +1751,17 @@ mac_test (const struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *taIeeeHeader, | |||
1431 | const struct HardwareInfos *dev) | 1751 | const struct HardwareInfos *dev) |
1432 | { | 1752 | { |
1433 | if (0 != memcmp (&taIeeeHeader->addr3, &mac_bssid_gnunet, MAC_ADDR_SIZE)) | 1753 | if (0 != memcmp (&taIeeeHeader->addr3, &mac_bssid_gnunet, MAC_ADDR_SIZE)) |
1434 | return 1; | 1754 | return 1; /* not a GNUnet ad-hoc package */ |
1435 | if (0 == memcmp (&taIeeeHeader->addr1, &dev->pl_mac, MAC_ADDR_SIZE)) | 1755 | if ( (0 == memcmp (&taIeeeHeader->addr1, &dev->pl_mac, MAC_ADDR_SIZE)) || |
1436 | return 0; | 1756 | (0 == memcmp (&taIeeeHeader->addr1, &bc_all_mac, MAC_ADDR_SIZE)) ) |
1437 | if (0 == memcmp (&taIeeeHeader->addr1, &bc_all_mac, MAC_ADDR_SIZE)) | 1757 | return 0; /* for us, or broadcast */ |
1438 | return 0; | 1758 | return 1; /* not for us */ |
1439 | return 1; | ||
1440 | } | 1759 | } |
1441 | 1760 | ||
1442 | 1761 | ||
1443 | /** | 1762 | /** |
1444 | * function to set the wlan header to make attacks more difficult | 1763 | * Set the wlan header to sane values to make attacks more difficult |
1764 | * | ||
1445 | * @param taIeeeHeader pointer to the header of the packet | 1765 | * @param taIeeeHeader pointer to the header of the packet |
1446 | * @param dev pointer to the Hardware_Infos struct | 1766 | * @param dev pointer to the Hardware_Infos struct |
1447 | */ | 1767 | */ |
@@ -1449,15 +1769,18 @@ static void | |||
1449 | mac_set (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *taIeeeHeader, | 1769 | mac_set (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *taIeeeHeader, |
1450 | const struct HardwareInfos *dev) | 1770 | const struct HardwareInfos *dev) |
1451 | { | 1771 | { |
1452 | taIeeeHeader->frame_control = ntohs (0x08); // FIXME: need to shift by 8? | 1772 | taIeeeHeader->frame_control = htons (IEEE80211_FC0_TYPE_DATA); |
1453 | taIeeeHeader->addr2 = dev->pl_mac; | 1773 | taIeeeHeader->addr2 = dev->pl_mac; |
1454 | taIeeeHeader->addr3 = mac_bssid_gnunet; | 1774 | taIeeeHeader->addr3 = mac_bssid_gnunet; |
1455 | } | 1775 | } |
1456 | 1776 | ||
1457 | 1777 | ||
1458 | /** | 1778 | /** |
1459 | * function to process the data from the stdin | 1779 | * Process data from the stdin. Takes the message, prepends the |
1460 | * @param cls pointer to the device struct | 1780 | * radiotap transmission header, forces the sender MAC to be correct |
1781 | * and puts it into our buffer for transmission to the kernel. | ||
1782 | * | ||
1783 | * @param cls pointer to the device struct ('struct HardwareInfos*') | ||
1461 | * @param hdr pointer to the start of the packet | 1784 | * @param hdr pointer to the start of the packet |
1462 | */ | 1785 | */ |
1463 | static void | 1786 | static void |
@@ -1467,7 +1790,7 @@ stdin_send_hw (void *cls, const struct GNUNET_MessageHeader *hdr) | |||
1467 | const struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *header; | 1790 | const struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *header; |
1468 | struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *wlanheader; | 1791 | struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *wlanheader; |
1469 | size_t sendsize; | 1792 | size_t sendsize; |
1470 | struct RadioTapheader rtheader; | 1793 | struct RadiotapTransmissionHeader rtheader; |
1471 | 1794 | ||
1472 | sendsize = ntohs (hdr->size); | 1795 | sendsize = ntohs (hdr->size); |
1473 | if ( (sendsize < | 1796 | if ( (sendsize < |
@@ -1484,20 +1807,19 @@ stdin_send_hw (void *cls, const struct GNUNET_MessageHeader *hdr) | |||
1484 | exit (1); | 1807 | exit (1); |
1485 | } | 1808 | } |
1486 | header = (const struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *) hdr; | 1809 | header = (const struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *) hdr; |
1487 | rtheader.header.it_version = 0; /* radiotap version */ | 1810 | rtheader.header.it_version = 0; |
1488 | rtheader.header.it_len = GNUNET_htole16 (0x0c); /* radiotap header length */ | 1811 | rtheader.header.it_pad = 0; |
1489 | rtheader.header.it_present = GNUNET_htole16 (0x00008004); /* our bitmap */ | ||
1490 | rtheader.rate = 0x00; | ||
1491 | rtheader.pad1 = 0x00; | ||
1492 | rtheader.txflags = GNUNET_htole16 (IEEE80211_RADIOTAP_F_TX_NOACK | IEEE80211_RADIOTAP_F_TX_NOSEQ); | ||
1493 | rtheader.header.it_len = GNUNET_htole16 (sizeof (rtheader)); | 1812 | rtheader.header.it_len = GNUNET_htole16 (sizeof (rtheader)); |
1494 | rtheader.rate = header->rate; | 1813 | rtheader.header.it_present = GNUNET_htole16 (IEEE80211_RADIOTAP_OUR_TRANSMISSION_HEADER_MASK); |
1814 | rtheader.rate = header->rate; | ||
1815 | rtheader.pad1 = 0; | ||
1816 | rtheader.txflags = GNUNET_htole16 (IEEE80211_RADIOTAP_F_TX_NOACK | IEEE80211_RADIOTAP_F_TX_NOSEQ); | ||
1495 | memcpy (write_pout.buf, &rtheader, sizeof (rtheader)); | 1817 | memcpy (write_pout.buf, &rtheader, sizeof (rtheader)); |
1496 | memcpy (&write_pout.buf[sizeof (rtheader)], &header->frame, sendsize); | 1818 | memcpy (&write_pout.buf[sizeof (rtheader)], &header->frame, sendsize); |
1497 | wlanheader = (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *) &write_pout.buf[sizeof (rtheader)]; | 1819 | wlanheader = (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *) &write_pout.buf[sizeof (rtheader)]; |
1498 | 1820 | ||
1499 | /* payload contains MAC address, but we don't trust it, so we'll | 1821 | /* payload contains MAC address, but we don't trust it, so we'll |
1500 | * overwrite it with OUR MAC address again to prevent mischief */ | 1822 | * overwrite it with OUR MAC address to prevent mischief */ |
1501 | mac_set (wlanheader, dev); | 1823 | mac_set (wlanheader, dev); |
1502 | write_pout.size = sendsize + sizeof (rtheader); | 1824 | write_pout.size = sendsize + sizeof (rtheader); |
1503 | } | 1825 | } |
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c index 7b709ce9d..0c60bd68c 100644 --- a/src/transport/plugin_transport_wlan.c +++ b/src/transport/plugin_transport_wlan.c | |||
@@ -93,6 +93,7 @@ | |||
93 | * max messages in in queue | 93 | * max messages in in queue |
94 | */ | 94 | */ |
95 | #define MESSAGES_IN_QUEUE_SIZE 10 | 95 | #define MESSAGES_IN_QUEUE_SIZE 10 |
96 | |||
96 | /** | 97 | /** |
97 | * max messages in in queue per session/client | 98 | * max messages in in queue per session/client |
98 | */ | 99 | */ |
@@ -106,17 +107,6 @@ | |||
106 | #define WLAN_LLC_SSAP_FIELD 0x1f | 107 | #define WLAN_LLC_SSAP_FIELD 0x1f |
107 | 108 | ||
108 | 109 | ||
109 | #define IEEE80211_ADDR_LEN 6 /* size of 802.11 address */ | ||
110 | |||
111 | #define IEEE80211_FC0_VERSION_MASK 0x03 | ||
112 | #define IEEE80211_FC0_VERSION_SHIFT 0 | ||
113 | #define IEEE80211_FC0_VERSION_0 0x00 | ||
114 | #define IEEE80211_FC0_TYPE_MASK 0x0c | ||
115 | #define IEEE80211_FC0_TYPE_SHIFT 2 | ||
116 | #define IEEE80211_FC0_TYPE_MGT 0x00 | ||
117 | #define IEEE80211_FC0_TYPE_CTL 0x04 | ||
118 | #define IEEE80211_FC0_TYPE_DATA 0x08 | ||
119 | |||
120 | 110 | ||
121 | /** | 111 | /** |
122 | * Encapsulation of all of the state of the plugin. | 112 | * Encapsulation of all of the state of the plugin. |
@@ -1266,7 +1256,7 @@ getWlanHeader (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *Header, | |||
1266 | { | 1256 | { |
1267 | const int rate = 11000000; | 1257 | const int rate = 11000000; |
1268 | 1258 | ||
1269 | Header->frame_control = htons (IEEE80211_FC0_TYPE_DATA); // FIXME: check: might need to shift by 8? | 1259 | Header->frame_control = htons (IEEE80211_FC0_TYPE_DATA); |
1270 | Header->addr1 = *to_mac_addr; | 1260 | Header->addr1 = *to_mac_addr; |
1271 | Header->addr2 = plugin->mac_address; | 1261 | Header->addr2 = plugin->mac_address; |
1272 | Header->addr3 = mac_bssid_gnunet; | 1262 | Header->addr3 = mac_bssid_gnunet; |
diff --git a/src/transport/plugin_transport_wlan.h b/src/transport/plugin_transport_wlan.h index 3f8e82404..96aa434ee 100644 --- a/src/transport/plugin_transport_wlan.h +++ b/src/transport/plugin_transport_wlan.h | |||
@@ -34,6 +34,25 @@ | |||
34 | */ | 34 | */ |
35 | #define MAC_ADDR_SIZE 6 | 35 | #define MAC_ADDR_SIZE 6 |
36 | 36 | ||
37 | /** | ||
38 | * Value for "Management" in the 'frame_control' field of the | ||
39 | * struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame. | ||
40 | */ | ||
41 | #define IEEE80211_FC0_TYPE_MGT 0x00 | ||
42 | |||
43 | /** | ||
44 | * Value for "Control" in the 'frame_control' field of the | ||
45 | * struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame. | ||
46 | */ | ||
47 | #define IEEE80211_FC0_TYPE_CTL 0x04 | ||
48 | |||
49 | /** | ||
50 | * Value for DATA in the 'frame_control' field of the | ||
51 | * struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame. | ||
52 | */ | ||
53 | #define IEEE80211_FC0_TYPE_DATA 0x08 | ||
54 | |||
55 | |||
37 | GNUNET_NETWORK_STRUCT_BEGIN | 56 | GNUNET_NETWORK_STRUCT_BEGIN |
38 | 57 | ||
39 | /** | 58 | /** |
@@ -68,7 +87,13 @@ struct GNUNET_TRANSPORT_WLAN_HelperControlMessage | |||
68 | struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame | 87 | struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame |
69 | { | 88 | { |
70 | /** | 89 | /** |
71 | * 802.11 Frame Control field, | 90 | * 802.11 Frame Control field. A bitmask. The overall field is a |
91 | * 16-bit mask of the respecitve fields. The lowest two bits should | ||
92 | * be 0, then comes the "type" (2 bits, see IEEE80211_FC0_TYPE_* | ||
93 | * constants), followed by 4-bit subtype (all zeros for ad-hoc), | ||
94 | * followed by various flags (to DS, from DS, more frag, retry, | ||
95 | * power management, more data, WEP, strict), all of which we also | ||
96 | * keep at zero. | ||
72 | */ | 97 | */ |
73 | uint16_t frame_control GNUNET_PACKED; | 98 | uint16_t frame_control GNUNET_PACKED; |
74 | 99 | ||
@@ -93,7 +118,8 @@ struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame | |||
93 | struct GNUNET_TRANSPORT_WLAN_MacAddress addr3; | 118 | struct GNUNET_TRANSPORT_WLAN_MacAddress addr3; |
94 | 119 | ||
95 | /** | 120 | /** |
96 | * 802.11 sequence control field. | 121 | * 802.11 sequence control field; contains fragment number an sequence |
122 | * number (we set this to all zeros). | ||
97 | */ | 123 | */ |
98 | uint16_t sequence_control GNUNET_PACKED; | 124 | uint16_t sequence_control GNUNET_PACKED; |
99 | 125 | ||
@@ -162,46 +188,46 @@ struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage | |||
162 | struct GNUNET_MessageHeader header; | 188 | struct GNUNET_MessageHeader header; |
163 | 189 | ||
164 | /** | 190 | /** |
165 | * FIXME: not initialized properly so far. (supposed to contain | 191 | * Information about which of the fields below are actually valid. |
166 | * information about which of the fields below are actually valid). | 192 | * 0 for none. FIXME: not properly initialized so far (always zero). |
167 | */ | 193 | */ |
168 | uint32_t ri_present GNUNET_PACKED; | 194 | uint32_t ri_present GNUNET_PACKED; |
169 | 195 | ||
170 | /** | 196 | /** |
171 | * IEEE80211_RADIOTAP_TSFT | 197 | * IEEE80211_RADIOTAP_TSFT, 0 if unknown. |
172 | */ | 198 | */ |
173 | uint64_t ri_mactime GNUNET_PACKED; | 199 | uint64_t ri_mactime GNUNET_PACKED; |
174 | 200 | ||
175 | /** | 201 | /** |
176 | * from radiotap | 202 | * from radiotap |
177 | * either IEEE80211_RADIOTAP_DBM_ANTSIGNAL | 203 | * either IEEE80211_RADIOTAP_DBM_ANTSIGNAL |
178 | * or IEEE80211_RADIOTAP_DB_ANTSIGNAL | 204 | * or IEEE80211_RADIOTAP_DB_ANTSIGNAL, 0 if unknown. |
179 | */ | 205 | */ |
180 | int32_t ri_power GNUNET_PACKED; | 206 | int32_t ri_power GNUNET_PACKED; |
181 | 207 | ||
182 | /** | 208 | /** |
183 | * either IEEE80211_RADIOTAP_DBM_ANTNOISE | 209 | * either IEEE80211_RADIOTAP_DBM_ANTNOISE |
184 | * or IEEE80211_RADIOTAP_DB_ANTNOISE | 210 | * or IEEE80211_RADIOTAP_DB_ANTNOISE, 0 if unknown. |
185 | */ | 211 | */ |
186 | int32_t ri_noise GNUNET_PACKED; | 212 | int32_t ri_noise GNUNET_PACKED; |
187 | 213 | ||
188 | /** | 214 | /** |
189 | * IEEE80211_RADIOTAP_CHANNEL | 215 | * IEEE80211_RADIOTAP_CHANNEL, 0 if unknown. |
190 | */ | 216 | */ |
191 | uint32_t ri_channel GNUNET_PACKED; | 217 | uint32_t ri_channel GNUNET_PACKED; |
192 | 218 | ||
193 | /** | 219 | /** |
194 | * Frequency we use. FIXME: not properly initialized so far! | 220 | * Frequency we use. 0 if unknown. |
195 | */ | 221 | */ |
196 | uint32_t ri_freq GNUNET_PACKED; | 222 | uint32_t ri_freq GNUNET_PACKED; |
197 | 223 | ||
198 | /** | 224 | /** |
199 | * IEEE80211_RADIOTAP_RATE * 50000 | 225 | * IEEE80211_RADIOTAP_RATE * 50000, 0 if unknown. |
200 | */ | 226 | */ |
201 | uint32_t ri_rate GNUNET_PACKED; | 227 | uint32_t ri_rate GNUNET_PACKED; |
202 | 228 | ||
203 | /** | 229 | /** |
204 | * IEEE80211_RADIOTAP_ANTENNA | 230 | * IEEE80211_RADIOTAP_ANTENNA, 0 if unknown. |
205 | */ | 231 | */ |
206 | uint32_t ri_antenna GNUNET_PACKED; | 232 | uint32_t ri_antenna GNUNET_PACKED; |
207 | 233 | ||