diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/transport/ieee80211_radiotap.h | 10 | ||||
-rw-r--r-- | src/transport/plugin_transport_wlan.c | 155 |
2 files changed, 81 insertions, 84 deletions
diff --git a/src/transport/ieee80211_radiotap.h b/src/transport/ieee80211_radiotap.h index bfcc2180c..91d197995 100644 --- a/src/transport/ieee80211_radiotap.h +++ b/src/transport/ieee80211_radiotap.h | |||
@@ -37,7 +37,7 @@ | |||
37 | 37 | ||
38 | #include <linux/if_ether.h> | 38 | #include <linux/if_ether.h> |
39 | #include <linux/kernel.h> | 39 | #include <linux/kernel.h> |
40 | //#include <asm/unaligned.h> | 40 | // #include <asm/unaligned.h> |
41 | 41 | ||
42 | /* Base version of the radiotap packet header data */ | 42 | /* Base version of the radiotap packet header data */ |
43 | #define PKTHDR_RADIOTAP_VERSION 0 | 43 | #define PKTHDR_RADIOTAP_VERSION 0 |
@@ -254,12 +254,18 @@ enum ieee80211_radiotap_type { | |||
254 | ((x) + 1000) * 5) | 254 | ((x) + 1000) * 5) |
255 | 255 | ||
256 | /* helpers */ | 256 | /* helpers */ |
257 | static inline u16 get_unaligned_le16(const u8 *p) | ||
258 | { | ||
259 | return p[0] | p[1] << 8; | ||
260 | } | ||
261 | |||
262 | |||
257 | static inline int ieee80211_get_radiotap_len(unsigned char *data) | 263 | static inline int ieee80211_get_radiotap_len(unsigned char *data) |
258 | { | 264 | { |
259 | struct ieee80211_radiotap_header *hdr = | 265 | struct ieee80211_radiotap_header *hdr = |
260 | (struct ieee80211_radiotap_header *)data; | 266 | (struct ieee80211_radiotap_header *)data; |
261 | 267 | ||
262 | return get_unaligned_le16(&hdr->it_len); | 268 | return get_unaligned_le16( (const u8 *) &hdr->it_len); |
263 | } | 269 | } |
264 | 270 | ||
265 | #endif /* IEEE80211_RADIOTAP_H */ | 271 | #endif /* IEEE80211_RADIOTAP_H */ |
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c index 824ebf12c..a7d40982b 100644 --- a/src/transport/plugin_transport_wlan.c +++ b/src/transport/plugin_transport_wlan.c | |||
@@ -26,9 +26,7 @@ | |||
26 | 26 | ||
27 | #include "platform.h" | 27 | #include "platform.h" |
28 | #include "gnunet_protocols.h" | 28 | #include "gnunet_protocols.h" |
29 | #include "gnunet_connection_lib.h" | 29 | #include "gnunet_util_lib.h" |
30 | #include "gnunet_server_lib.h" | ||
31 | #include "gnunet_service_lib.h" | ||
32 | #include "gnunet_statistics_service.h" | 30 | #include "gnunet_statistics_service.h" |
33 | #include "gnunet_transport_service.h" | 31 | #include "gnunet_transport_service.h" |
34 | #include "plugin_transport.h" | 32 | #include "plugin_transport.h" |
@@ -37,9 +35,6 @@ | |||
37 | 35 | ||
38 | #define DEBUG_wlan GNUNET_NO | 36 | #define DEBUG_wlan GNUNET_NO |
39 | 37 | ||
40 | static void | ||
41 | wlan_plugin_helper_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | ||
42 | |||
43 | /** | 38 | /** |
44 | * After how long do we expire an address that we | 39 | * After how long do we expire an address that we |
45 | * learned from another peer if it is not reconfirmed | 40 | * learned from another peer if it is not reconfirmed |
@@ -265,34 +260,32 @@ wlan_plugin_disconnect (void *cls, | |||
265 | */ | 260 | */ |
266 | static void | 261 | static void |
267 | wlan_plugin_address_pretty_printer (void *cls, | 262 | wlan_plugin_address_pretty_printer (void *cls, |
268 | const char *type, | 263 | const char *type, |
269 | const void *addr, | 264 | const void *addr, |
270 | size_t addrlen, | 265 | size_t addrlen, |
271 | int numeric, | 266 | int numeric, |
272 | struct GNUNET_TIME_Relative timeout, | 267 | struct GNUNET_TIME_Relative timeout, |
273 | GNUNET_TRANSPORT_AddressStringCallback | 268 | GNUNET_TRANSPORT_AddressStringCallback |
274 | asc, void *asc_cls) | 269 | asc, void *asc_cls) |
275 | { | 270 | { |
276 | unsigned int res; | 271 | char ret[92]; |
277 | char * ret; | 272 | const unsigned char * input; |
278 | char * input; | 273 | |
279 | |||
280 | GNUNET_assert(cls !=NULL); | 274 | GNUNET_assert(cls !=NULL); |
281 | //Mac Adress has 6 bytes | 275 | if (addrlen != 6) |
282 | if (addrlen == 6){ | 276 | { |
283 | input = addr; | 277 | /* invalid address (MAC addresses have 6 bytes) */ |
284 | res = GNUNET_asprintf(&ret,"%s Mac-Adress %X:%X:%X:%X:%X:%X", PROTOCOL_PREFIX, input[0], input[1],input[2],input[3],input[4],input[5]); | 278 | GNUNET_break (0); |
285 | 279 | asc (asc_cls, NULL); | |
286 | GNUNET_assert(res != 0); | 280 | return; |
287 | asc (asc_cls, ret); | 281 | } |
288 | GNUNET_free_non_null (ret); | 282 | input = (const unsigned char*) addr; |
289 | 283 | GNUNET_snprintf (ret, | |
290 | } else { | 284 | sizeof (ret), |
291 | /* invalid address */ | 285 | "%s Mac-Adress %X:%X:%X:%X:%X:%X", |
292 | GNUNET_break_op (0); | 286 | PROTOCOL_PREFIX, |
293 | asc (asc_cls, NULL); | 287 | input[0], input[1], input[2], input[3], input[4], input[5]); |
294 | return; | 288 | asc (asc_cls, ret); |
295 | } | ||
296 | } | 289 | } |
297 | 290 | ||
298 | 291 | ||
@@ -345,30 +338,30 @@ wlan_plugin_address_suggested (void *cls, | |||
345 | */ | 338 | */ |
346 | static const char* | 339 | static const char* |
347 | wlan_plugin_address_to_string (void *cls, | 340 | wlan_plugin_address_to_string (void *cls, |
348 | const void *addr, | 341 | const void *addr, |
349 | size_t addrlen) | 342 | size_t addrlen) |
350 | { | 343 | { |
351 | unsigned int res; | 344 | char ret[92]; |
352 | char * ret; | 345 | const unsigned char * input; |
353 | char * input; | 346 | |
354 | |||
355 | GNUNET_assert(cls !=NULL); | 347 | GNUNET_assert(cls !=NULL); |
356 | //Mac Adress has 6 bytes | 348 | if (addrlen != 6) |
357 | if (addrlen == 6){ | 349 | { |
358 | input = addr; | 350 | /* invalid address (MAC addresses have 6 bytes) */ |
359 | res = GNUNET_asprintf(&ret,"%X:%X:%X:%X:%X:%X", input[0], input[1],input[2],input[3],input[4],input[5]); | 351 | GNUNET_break (0); |
360 | 352 | return NULL; | |
361 | GNUNET_assert(res != 0); | 353 | } |
362 | return ret; | 354 | input = (const unsigned char*) addr; |
363 | 355 | GNUNET_snprintf (ret, | |
364 | } else { | 356 | sizeof (ret), |
365 | /* invalid address */ | 357 | "%s Mac-Adress %X:%X:%X:%X:%X:%X", |
366 | GNUNET_break (0); | 358 | PROTOCOL_PREFIX, |
367 | return NULL; | 359 | input[0], input[1], input[2], input[3], input[4], input[5]); |
368 | } | 360 | return GNUNET_strdup (ret); |
369 | } | 361 | } |
370 | 362 | ||
371 | 363 | ||
364 | #if 0 | ||
372 | /** | 365 | /** |
373 | * Function for used to process the data from the suid process | 366 | * Function for used to process the data from the suid process |
374 | */ | 367 | */ |
@@ -399,6 +392,35 @@ wlan_process_helper (void *cls, | |||
399 | } | 392 | } |
400 | 393 | ||
401 | 394 | ||
395 | static void | ||
396 | wlan_plugin_helper_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
397 | { | ||
398 | struct Plugin *plugin = cls; | ||
399 | char mybuf[3000]; //max size of packet from helper | ||
400 | ssize_t bytes; | ||
401 | //memset(&mybuf, 0, sizeof(mybuf)); //? | ||
402 | |||
403 | if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN) | ||
404 | return; | ||
405 | |||
406 | bytes = GNUNET_DISK_file_read(plugin->server_stdout_handle, &mybuf, sizeof(mybuf)); | ||
407 | |||
408 | if (bytes < 1) | ||
409 | { | ||
410 | #if DEBUG_TCP_NAT | ||
411 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
412 | _("Finished reading from wlan-helper stdout with code: %d\n"), bytes); | ||
413 | #endif | ||
414 | return; | ||
415 | } | ||
416 | |||
417 | plugin->server_read_task = | ||
418 | GNUNET_SCHEDULER_add_read_file (plugin->env->sched, | ||
419 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
420 | plugin->server_stdout_handle, &wlan_plugin_helper_read, plugin); | ||
421 | |||
422 | } | ||
423 | |||
402 | 424 | ||
403 | /** | 425 | /** |
404 | * Start the gnunet-wlan-helper process for users behind NAT. | 426 | * Start the gnunet-wlan-helper process for users behind NAT. |
@@ -407,7 +429,6 @@ wlan_process_helper (void *cls, | |||
407 | * | 429 | * |
408 | * @return GNUNET_YES if process was started, GNUNET_SYSERR on error | 430 | * @return GNUNET_YES if process was started, GNUNET_SYSERR on error |
409 | */ | 431 | */ |
410 | |||
411 | static int | 432 | static int |
412 | wlan_transport_start_wlan_helper(struct Plugin *plugin) | 433 | wlan_transport_start_wlan_helper(struct Plugin *plugin) |
413 | { | 434 | { |
@@ -452,37 +473,7 @@ wlan_transport_start_wlan_helper(struct Plugin *plugin) | |||
452 | 473 | ||
453 | 474 | ||
454 | 475 | ||
455 | |||
456 | static void | ||
457 | wlan_plugin_helper_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
458 | { | ||
459 | struct Plugin *plugin = cls; | ||
460 | char mybuf[3000]; //max size of packet from helper | ||
461 | ssize_t bytes; | ||
462 | //memset(&mybuf, 0, sizeof(mybuf)); //? | ||
463 | int i; | ||
464 | |||
465 | |||
466 | if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN) | ||
467 | return; | ||
468 | |||
469 | bytes = GNUNET_DISK_file_read(plugin->server_stdout_handle, &mybuf, sizeof(mybuf)); | ||
470 | |||
471 | if (bytes < 1) | ||
472 | { | ||
473 | #if DEBUG_TCP_NAT | ||
474 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
475 | _("Finished reading from wlan-helper stdout with code: %d\n"), bytes); | ||
476 | #endif | 476 | #endif |
477 | return; | ||
478 | } | ||
479 | |||
480 | plugin->server_read_task = | ||
481 | GNUNET_SCHEDULER_add_read_file (plugin->env->sched, | ||
482 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
483 | plugin->server_stdout_handle, &wlan_plugin_helper_read, plugin); | ||
484 | |||
485 | } | ||
486 | 477 | ||
487 | 478 | ||
488 | /** | 479 | /** |