diff options
-rw-r--r-- | src/transport/gnunet-transport-wlan-helper.c | 59 |
1 files changed, 46 insertions, 13 deletions
diff --git a/src/transport/gnunet-transport-wlan-helper.c b/src/transport/gnunet-transport-wlan-helper.c index 6f8e3d4d1..2cfe12087 100644 --- a/src/transport/gnunet-transport-wlan-helper.c +++ b/src/transport/gnunet-transport-wlan-helper.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include "gnunet_os_lib.h" | 34 | #include "gnunet_os_lib.h" |
35 | #include "gnunet_transport_plugin.h" | 35 | #include "gnunet_transport_plugin.h" |
36 | #include "transport.h" | 36 | #include "transport.h" |
37 | #include "gnunet_util_lib.h" | ||
37 | #include "plugin_transport_wlan.h" | 38 | #include "plugin_transport_wlan.h" |
38 | #include "gnunet_common.h" | 39 | #include "gnunet_common.h" |
39 | #include "gnunet-transport-wlan-helper.h" | 40 | #include "gnunet-transport-wlan-helper.h" |
@@ -394,7 +395,7 @@ int ieee80211_radiotap_iterator_next( | |||
394 | 395 | ||
395 | #define FIFO_FILE1 "/tmp/MYFIFOin" | 396 | #define FIFO_FILE1 "/tmp/MYFIFOin" |
396 | #define FIFO_FILE2 "/tmp/MYFIFOout" | 397 | #define FIFO_FILE2 "/tmp/MYFIFOout" |
397 | #define MAXLINE 5000 | 398 | #define MAXLINE 20 |
398 | 399 | ||
399 | int first; | 400 | int first; |
400 | int closeprog = 0; | 401 | int closeprog = 0; |
@@ -407,11 +408,10 @@ void sigfunc(int sig) | |||
407 | else | 408 | else |
408 | { | 409 | { |
409 | closeprog = 1; | 410 | closeprog = 1; |
410 | if (first == 1) | 411 | |
411 | { | 412 | unlink(FIFO_FILE1); |
412 | unlink(FIFO_FILE1); | 413 | unlink(FIFO_FILE2); |
413 | unlink(FIFO_FILE2); | 414 | |
414 | } | ||
415 | } | 415 | } |
416 | } | 416 | } |
417 | 417 | ||
@@ -504,31 +504,48 @@ testmode(int argc, char *argv[]) | |||
504 | int readc = 0; | 504 | int readc = 0; |
505 | int pos = 0; | 505 | int pos = 0; |
506 | char line[MAXLINE]; | 506 | char line[MAXLINE]; |
507 | int ret = 0; | ||
507 | 508 | ||
508 | while (closeprog == 0) | 509 | while (closeprog == 0) |
509 | { | 510 | { |
510 | readc = 0; | 511 | readc = 0; |
511 | 512 | ||
512 | while (readc < sizeof( struct RadiotapHeader) + sizeof(struct GNUNET_MessageHeader)){ | 513 | //while (readc < sizeof( struct RadiotapHeader) + sizeof(struct GNUNET_MessageHeader)){ |
513 | if ((rv = read(fd[0], line, MAXLINE)) < 0) | 514 | if ((rv = read(fd[0], line, MAXLINE)) < 0) |
514 | { | 515 | { |
515 | perror("READ ERROR FROM STDIN"); | 516 | perror("READ ERROR FROM STDIN"); |
516 | } | 517 | } |
517 | readc += rv; | 518 | readc += rv; |
519 | //} | ||
520 | |||
521 | if (closeprog == 1){ | ||
522 | break; | ||
518 | } | 523 | } |
519 | 524 | ||
520 | pos = 0; | 525 | pos = 0; |
521 | 526 | ||
522 | fwrite(&line[pos], 1, sizeof(struct GNUNET_MessageHeader), fpout); | ||
523 | 527 | ||
524 | pos += sizeof(struct GNUNET_MessageHeader); | 528 | perror("writing blub"); |
529 | //fwrite(&line[pos], 1, sizeof(struct GNUNET_MessageHeader), fpout); | ||
530 | |||
531 | //pos += sizeof(struct GNUNET_Mes#include "gnunet_util_lib.h"sageHeader); | ||
525 | 532 | ||
526 | //do not send radiotap header | 533 | //do not send radiotap header |
527 | pos += sizeof( struct RadiotapHeader); | 534 | //pos += sizeof( struct RadiotapHeader); |
528 | 535 | ||
529 | while (pos < readc) | 536 | while (pos < readc) |
530 | { | 537 | { |
531 | pos += fwrite(&line[pos], 1, readc - pos, fpout); | 538 | ret = fwrite(&line[pos], 1, readc - pos, fpout); |
539 | if (ret < 0) | ||
540 | { | ||
541 | closeprog = 1; | ||
542 | perror("Write ERROR FROM fpout"); | ||
543 | break; | ||
544 | } | ||
545 | else | ||
546 | { | ||
547 | pos += ret; | ||
548 | } | ||
532 | } | 549 | } |
533 | } | 550 | } |
534 | 551 | ||
@@ -542,6 +559,7 @@ testmode(int argc, char *argv[]) | |||
542 | signal(SIGTERM, sigfunc); | 559 | signal(SIGTERM, sigfunc); |
543 | signal(SIGKILL, sigfunc); | 560 | signal(SIGKILL, sigfunc); |
544 | int rv = 0; | 561 | int rv = 0; |
562 | int ret = 0; | ||
545 | ssize_t pos = 0; | 563 | ssize_t pos = 0; |
546 | char line[MAXLINE]; | 564 | char line[MAXLINE]; |
547 | struct Wlan_Helper_Control_Message macmsg; | 565 | struct Wlan_Helper_Control_Message macmsg; |
@@ -554,8 +572,10 @@ testmode(int argc, char *argv[]) | |||
554 | macmsg.mac.mac[4] = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 255); | 572 | macmsg.mac.mac[4] = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 255); |
555 | macmsg.mac.mac[5] = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 255); | 573 | macmsg.mac.mac[5] = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 255); |
556 | macmsg.hdr.size = sizeof(struct Wlan_Helper_Control_Message); | 574 | macmsg.hdr.size = sizeof(struct Wlan_Helper_Control_Message); |
575 | macmsg.hdr.type = GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL; | ||
557 | 576 | ||
558 | pos = 0; | 577 | pos = 0; |
578 | |||
559 | while (pos < sizeof(struct Wlan_Helper_Control_Message)) | 579 | while (pos < sizeof(struct Wlan_Helper_Control_Message)) |
560 | { | 580 | { |
561 | pos += write(fd[1], &macmsg + pos, sizeof(struct Wlan_Helper_Control_Message) - pos); | 581 | pos += write(fd[1], &macmsg + pos, sizeof(struct Wlan_Helper_Control_Message) - pos); |
@@ -567,11 +587,24 @@ testmode(int argc, char *argv[]) | |||
567 | { | 587 | { |
568 | perror("READ ERROR FROM fpin"); | 588 | perror("READ ERROR FROM fpin"); |
569 | } | 589 | } |
570 | 590 | if (closeprog == 1){ | |
591 | break; | ||
592 | } | ||
571 | pos = 0; | 593 | pos = 0; |
572 | while (pos < rv) | 594 | while (pos < rv) |
573 | { | 595 | { |
574 | pos += write(fd[1], &line[pos], rv - pos); | 596 | |
597 | ret= write(fd[1], &line[pos], rv - pos); | ||
598 | if (ret < 0) | ||
599 | { | ||
600 | closeprog = 1; | ||
601 | perror("Write ERROR FROM STDout"); | ||
602 | break; | ||
603 | } | ||
604 | else | ||
605 | { | ||
606 | pos += ret; | ||
607 | } | ||
575 | } | 608 | } |
576 | } | 609 | } |
577 | 610 | ||