diff options
author | David Brodski <david@brodski.eu> | 2010-10-12 20:45:51 +0000 |
---|---|---|
committer | David Brodski <david@brodski.eu> | 2010-10-12 20:45:51 +0000 |
commit | c53502b0b956ffc953d459d6b46e6fa6b568c3e0 (patch) | |
tree | f04b3f41e047ecf1e07e2ba34a03cd95cc03cea4 | |
parent | 7bd385f7c57cfc27a3aeafedc8c9787774124ca3 (diff) | |
download | gnunet-c53502b0b956ffc953d459d6b46e6fa6b568c3e0.tar.gz gnunet-c53502b0b956ffc953d459d6b46e6fa6b568c3e0.zip |
Retransmit and timed retransmit added
cleanup at timeout added
disconnect added
wlan header changed to specs of ieee
-rw-r--r-- | src/transport/plugin_transport_wlan.c | 411 | ||||
-rw-r--r-- | src/transport/plugin_transport_wlan.h | 28 |
2 files changed, 295 insertions, 144 deletions
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c index d0d12d09d..a6affd4fd 100644 --- a/src/transport/plugin_transport_wlan.c +++ b/src/transport/plugin_transport_wlan.c | |||
@@ -85,9 +85,14 @@ struct Plugin | |||
85 | struct GNUNET_TRANSPORT_PluginEnvironment *env; | 85 | struct GNUNET_TRANSPORT_PluginEnvironment *env; |
86 | 86 | ||
87 | /** | 87 | /** |
88 | * List of open sessions. | 88 | * List of open sessions. head |
89 | */ | 89 | */ |
90 | struct Session *sessions; | 90 | struct Sessionqueue *sessions; |
91 | |||
92 | /** | ||
93 | * List of open sessions. tail | ||
94 | */ | ||
95 | struct Sessionqueue *sessions_tail; | ||
91 | 96 | ||
92 | /** | 97 | /** |
93 | * encapsulation to the local wlan server prog | 98 | * encapsulation to the local wlan server prog |
@@ -148,10 +153,15 @@ struct Plugin | |||
148 | struct Sessionqueue * pending_Sessions; | 153 | struct Sessionqueue * pending_Sessions; |
149 | 154 | ||
150 | /** | 155 | /** |
151 | * Sessions currently pending for transmission | 156 | * Sessions currently pending for transmission |
152 | * to this peer, if any. | 157 | * to this peer (tail), if any. |
158 | */ | ||
159 | struct Sessionqueue * pending_Sessions_tail; | ||
160 | |||
161 | /** | ||
162 | * number of pending sessions | ||
153 | */ | 163 | */ |
154 | struct Sessionqueue * all_Sessions; | 164 | uint pendingsessions; |
155 | 165 | ||
156 | }; | 166 | }; |
157 | 167 | ||
@@ -210,7 +220,7 @@ struct Session | |||
210 | /** | 220 | /** |
211 | * encapsulation of the data | 221 | * encapsulation of the data |
212 | */ | 222 | */ |
213 | struct GNUNET_SERVER_MessageStreamTokenizer * datatoken; | 223 | //struct GNUNET_SERVER_MessageStreamTokenizer * datatoken; |
214 | 224 | ||
215 | /** | 225 | /** |
216 | * peer mac address | 226 | * peer mac address |
@@ -395,7 +405,7 @@ uint16_t getcrc16 (const char *msgbuf, size_t msgbuf_size); | |||
395 | * get the next message number, at the moment just a random one | 405 | * get the next message number, at the moment just a random one |
396 | * | 406 | * |
397 | */ | 407 | */ |
398 | 408 | //TODO doxigen | |
399 | uint32_t | 409 | uint32_t |
400 | get_next_message_id() | 410 | get_next_message_id() |
401 | { | 411 | { |
@@ -410,7 +420,7 @@ get_next_message_id() | |||
410 | /** | 420 | /** |
411 | * start next message number generator | 421 | * start next message number generator |
412 | */ | 422 | */ |
413 | 423 | //TODO doxigen | |
414 | void | 424 | void |
415 | start_next_message_id() | 425 | start_next_message_id() |
416 | { | 426 | { |
@@ -429,7 +439,7 @@ static struct Session * | |||
429 | get_Session (struct Plugin *plugin, | 439 | get_Session (struct Plugin *plugin, |
430 | const char * addr) | 440 | const char * addr) |
431 | { | 441 | { |
432 | struct Sessionqueue * queue = plugin->all_Sessions; | 442 | struct Sessionqueue * queue = plugin->sessions; |
433 | struct Sessionqueue * lastitem = NULL; | 443 | struct Sessionqueue * lastitem = NULL; |
434 | 444 | ||
435 | 445 | ||
@@ -450,13 +460,7 @@ get_Session (struct Plugin *plugin, | |||
450 | // new session | 460 | // new session |
451 | queue = GNUNET_malloc (sizeof (struct Sessionqueue)); | 461 | queue = GNUNET_malloc (sizeof (struct Sessionqueue)); |
452 | 462 | ||
453 | if (plugin->all_Sessions == NULL){ | 463 | GNUNET_CONTAINER_DLL_insert(plugin->sessions, plugin->sessions_tail, queue); |
454 | //is first session | ||
455 | plugin->all_Sessions = queue; | ||
456 | } else { | ||
457 | lastitem->next = queue; | ||
458 | queue->prev = lastitem; | ||
459 | } | ||
460 | 464 | ||
461 | queue->content = GNUNET_malloc (sizeof (struct Session)); | 465 | queue->content = GNUNET_malloc (sizeof (struct Session)); |
462 | queue->content->plugin = plugin; | 466 | queue->content->plugin = plugin; |
@@ -477,7 +481,8 @@ get_Session (struct Plugin *plugin, | |||
477 | GNUNET_CONTAINER_DLL_insert ((queue->content)->pending_messages_head, | 481 | GNUNET_CONTAINER_DLL_insert ((queue->content)->pending_messages_head, |
478 | (queue->content)->pending_messages_tail, | 482 | (queue->content)->pending_messages_tail, |
479 | pm); | 483 | pm); |
480 | 484 | plugin->pendingsessions ++; | |
485 | GNUNET_CONTAINER_DLL_insert_after(plugin->pending_Sessions, plugin->pending_Sessions_tail, plugin->pending_Sessions_tail, queue); | ||
481 | return queue->content; | 486 | return queue->content; |
482 | 487 | ||
483 | } | 488 | } |
@@ -508,16 +513,25 @@ queue_Session (struct Plugin *plugin, | |||
508 | // Session is not in the queue | 513 | // Session is not in the queue |
509 | 514 | ||
510 | queue = GNUNET_malloc (sizeof (struct Sessionqueue)); | 515 | queue = GNUNET_malloc (sizeof (struct Sessionqueue)); |
511 | if (plugin->pending_Sessions == NULL){ | ||
512 | //is first session | ||
513 | plugin->pending_Sessions = queue; | ||
514 | } else { | ||
515 | lastitem->next = queue; | ||
516 | queue->prev = lastitem; | ||
517 | } | ||
518 | |||
519 | queue->content = session; | 516 | queue->content = session; |
520 | 517 | ||
518 | //insert at the tail | ||
519 | GNUNET_CONTAINER_DLL_insert_after (plugin->pending_Sessions, | ||
520 | plugin->pending_Sessions_tail, | ||
521 | plugin->pending_Sessions_tail, queue); | ||
522 | plugin->pendingsessions ++; | ||
523 | |||
524 | } | ||
525 | |||
526 | //TODO doxigen | ||
527 | static void | ||
528 | free_acks (struct PendingMessage * pm){ | ||
529 | struct FragmentQueue * fq; | ||
530 | while (pm->head != NULL){ | ||
531 | fq = pm->head; | ||
532 | GNUNET_CONTAINER_DLL_remove(pm->head, pm->tail, fq); | ||
533 | GNUNET_free(fq); | ||
534 | } | ||
521 | } | 535 | } |
522 | 536 | ||
523 | /** | 537 | /** |
@@ -550,9 +564,18 @@ do_transmit (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
550 | struct FragmentQueue * akt = NULL; | 564 | struct FragmentQueue * akt = NULL; |
551 | int exit = 0; | 565 | int exit = 0; |
552 | 566 | ||
567 | int i = 0; | ||
568 | |||
569 | struct GNUNET_TIME_Absolute nextsend; | ||
570 | struct GNUNET_TIME_Relative timeout; | ||
571 | struct Sessionqueue * nextsession = NULL; | ||
572 | |||
573 | timeout.value = FRAGMENT_TIMEOUT; | ||
574 | nextsend = GNUNET_TIME_absolute_get_forever(); | ||
575 | |||
553 | queue = plugin->pending_Sessions; | 576 | queue = plugin->pending_Sessions; |
554 | 577 | ||
555 | //check if the are some pending sessions/messages ... | 578 | // check if the are some pending sessions/messages ... |
556 | GNUNET_assert(queue != NULL); | 579 | GNUNET_assert(queue != NULL); |
557 | 580 | ||
558 | session = queue->content; | 581 | session = queue->content; |
@@ -561,133 +584,221 @@ do_transmit (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
561 | pm = session->pending_messages_head; | 584 | pm = session->pending_messages_head; |
562 | GNUNET_assert(pm != NULL); | 585 | GNUNET_assert(pm != NULL); |
563 | 586 | ||
564 | //check if msg is valid to send | 587 | // get next valid session |
565 | if (GNUNET_TIME_absolute_get_remaining(pm->timeout).value > 0){ | 588 | // check if this session is only waiting to receive the acks for an already send fragments to finish it |
566 | // split msg if to large | 589 | // timeout is not reached |
567 | 590 | for (i = 0; i < plugin->pendingsessions; i++){ | |
568 | if (pm->message_size > WLAN_MTU) { | 591 | |
569 | size += sizeof(struct FragmentationHeader); | 592 | // check if the are some pending sessions/messages ... |
570 | // check for retransmission | 593 | GNUNET_assert(queue != NULL); |
571 | if (GNUNET_TIME_absolute_get_duration(pm->last_ack).value > FRAGMENT_TIMEOUT) { | 594 | |
572 | // TODO retransmit | 595 | session = queue->content; |
573 | // be positive and try again later :-D | 596 | GNUNET_assert(session != NULL); |
574 | pm->last_ack = GNUNET_TIME_absolute_get(); | 597 | |
575 | // find first missing fragment | 598 | pm = session->pending_messages_head; |
576 | exit = 0; | 599 | GNUNET_assert(pm != NULL); |
577 | akt = pm->head; | 600 | |
578 | pm->message_pos = 0; | 601 | //save next session |
579 | 602 | nextsession = queue->next; | |
580 | //test if ack was already received | 603 | // test if message timed out |
581 | if (akt != NULL) { | 604 | while (GNUNET_TIME_absolute_get_remaining(pm->timeout).value == 0){ |
582 | while (exit == 0){ | 605 | //remove message |
583 | //if fragment is present, take next | 606 | //free the acks |
584 | if (akt->fragment_num == pm->message_pos) { | 607 | free_acks (pm); |
585 | pm->message_pos ++; | 608 | //call the cont func that it did not work |
586 | } | 609 | if (pm->transmit_cont != NULL) |
587 | //next ack is bigger then the fragment number | 610 | pm->transmit_cont (pm->transmit_cont_cls, |
588 | //in case there is something like this: (acks) 1, 2, 5, 6, ... | 611 | &(session->target), GNUNET_SYSERR); |
589 | //and we send 3 again, the next number should be 4 | 612 | //remove the message |
590 | if (akt->fragment_num > pm->message_pos) { | 613 | GNUNET_CONTAINER_DLL_remove (session->pending_messages_head, |
591 | exit = 1; | 614 | session->pending_messages_tail, |
592 | } | 615 | pm); |
593 | 616 | GNUNET_free(pm); | |
594 | akt = akt->next; | 617 | |
595 | //test if this was the last ack | 618 | //test if there are no more messages pending for this session |
596 | if (akt == NULL){ | 619 | if (session->pending_messages_head == NULL){ |
597 | exit = 1; | 620 | |
598 | } | 621 | //test if tail is null too |
599 | 622 | GNUNET_assert(session->pending_messages_tail == NULL); | |
600 | } | 623 | |
601 | } | 624 | plugin->pendingsessions --; |
625 | GNUNET_CONTAINER_DLL_remove (plugin->pending_Sessions, plugin->pending_Sessions_tail, queue); | ||
626 | GNUNET_free(queue); | ||
627 | queue = NULL; | ||
628 | break; | ||
629 | |||
630 | } else { | ||
631 | pm = session->pending_messages_head; | ||
632 | } | ||
633 | |||
634 | } | ||
635 | // restore next session if necessary | ||
636 | if (queue == NULL){ | ||
637 | queue = nextsession; | ||
638 | nextsession = NULL; | ||
639 | //there are no more messages in this session | ||
640 | continue; | ||
641 | } | ||
642 | nextsession = NULL; | ||
643 | |||
644 | // test if retransmit is needed | ||
645 | if (GNUNET_TIME_absolute_get_duration(pm->last_ack).value < FRAGMENT_TIMEOUT) { | ||
646 | // get last offset for this message | ||
647 | copyoffset = pm->message_size /(WLAN_MTU - sizeof(struct FragmentationHeader)); | ||
648 | // one more is the end | ||
649 | copyoffset ++; | ||
650 | // test if it is not the end | ||
651 | if (copyoffset > pm->message_pos){ | ||
652 | nextsession = queue; | ||
653 | break; | ||
654 | } | ||
655 | |||
656 | nextsend = GNUNET_TIME_absolute_min(GNUNET_TIME_absolute_add(pm->last_ack, timeout), nextsend); | ||
657 | |||
658 | GNUNET_CONTAINER_DLL_remove (plugin->pending_Sessions, plugin->pending_Sessions_tail, queue); | ||
659 | //insert at the tail | ||
660 | GNUNET_CONTAINER_DLL_insert_after (plugin->pending_Sessions, | ||
661 | plugin->pending_Sessions_tail, | ||
662 | plugin->pending_Sessions_tail, queue); | ||
663 | |||
664 | //get next pending session | ||
665 | queue = queue->next; | ||
666 | |||
667 | } else { | ||
668 | // retransmit | ||
669 | nextsession = queue; | ||
670 | break; | ||
671 | } | ||
672 | } | ||
602 | 673 | ||
603 | } | ||
604 | 674 | ||
605 | copyoffset = (WLAN_MTU - sizeof(struct FragmentationHeader)) * pm->message_pos; | 675 | //test if there is one session to send something |
606 | fragheader.fragment_off_or_num = pm->message_pos; | 676 | if (nextsession != NULL){ |
607 | fragheader.message_id = session->message_id_out; | 677 | queue = nextsession; |
608 | 678 | ||
609 | // start should be smaller then the packet size | 679 | // check if the are some pending sessions/messages ... |
610 | //TODO send some other data if everything was send but not all acks are present | 680 | GNUNET_assert(queue != NULL); |
611 | GNUNET_assert(copyoffset < pm->message_size); | ||
612 | copystart = pm->msg + copyoffset; | ||
613 | 681 | ||
614 | //size of the fragment is either the MTU - overhead | 682 | session = queue->content; |
615 | //or the missing part of the message in case this is the last fragment | 683 | GNUNET_assert(session != NULL); |
616 | copysize = GNUNET_MIN(pm->message_size - copyoffset, | ||
617 | WLAN_MTU - sizeof(struct FragmentationHeader)); | ||
618 | fragheader.header.size = copysize; | ||
619 | fragheader.header.type = GNUNET_MESSAGE_TYPE_WLAN_FRAGMENT; | ||
620 | 684 | ||
621 | //get the next missing fragment | 685 | pm = session->pending_messages_head; |
686 | GNUNET_assert(pm != NULL); | ||
687 | } else { | ||
688 | //nothing to send at the moment | ||
689 | plugin->server_read_task = | ||
690 | GNUNET_SCHEDULER_add_delayed (plugin->env->sched, | ||
691 | GNUNET_TIME_absolute_get_remaining(nextsend), | ||
692 | &do_transmit, plugin); | ||
693 | |||
694 | } | ||
695 | |||
696 | |||
697 | |||
698 | if (pm->message_size > WLAN_MTU) { | ||
699 | size += sizeof(struct FragmentationHeader); | ||
700 | // check for retransmission | ||
701 | if (GNUNET_TIME_absolute_get_duration(pm->last_ack).value > FRAGMENT_TIMEOUT) { | ||
702 | // TODO retransmit | ||
703 | // be positive and try again later :-D | ||
704 | pm->last_ack = GNUNET_TIME_absolute_get(); | ||
705 | // find first missing fragment | ||
622 | exit = 0; | 706 | exit = 0; |
623 | akt = pm->head; | 707 | akt = pm->head; |
624 | pm->message_pos ++; | 708 | pm->message_pos = 0; |
625 | |||
626 | //test if ack was already received | ||
627 | if (akt != NULL) { | ||
628 | while (exit == 0){ | ||
629 | //if fragment is present, take next | ||
630 | if (akt->fragment_num == pm->message_pos) { | ||
631 | pm->message_pos ++; | ||
632 | } | ||
633 | //next ack is bigger then the fragment number | ||
634 | //in case there is something like this: (acks) 1, 2, 5, 6, ... | ||
635 | //and we send 3 again, the next number should be 4 | ||
636 | if (akt->fragment_num > pm->message_pos) { | ||
637 | exit = 1; | ||
638 | } | ||
639 | |||
640 | akt = akt->next; | ||
641 | //test if this was the last ack | ||
642 | if (akt == NULL){ | ||
643 | exit = 1; | ||
644 | } | ||
645 | 709 | ||
710 | //test if ack 0 was already received | ||
711 | while (akt != NULL){ | ||
712 | //if fragment is present, take next | ||
713 | if (akt->fragment_num == pm->message_pos) { | ||
714 | pm->message_pos ++; | ||
646 | } | 715 | } |
716 | //next ack is bigger then the fragment number | ||
717 | //in case there is something like this: (acks) 1, 2, 5, 6, ... | ||
718 | //and we send 3 again, the next number should be 4 | ||
719 | if (akt->fragment_num > pm->message_pos) { | ||
720 | break; | ||
721 | } | ||
722 | |||
723 | akt = akt->next; | ||
724 | |||
647 | } | 725 | } |
648 | 726 | ||
649 | } else { | ||
650 | // there is no need to split | ||
651 | copystart = pm->msg; | ||
652 | copysize = pm->message_size; | ||
653 | } | ||
654 | size += copysize; | ||
655 | size += sizeof(struct RadiotapHeader) + sizeof(struct IeeeHeader) | ||
656 | + sizeof(struct GNUNET_MessageHeader); | ||
657 | msgheader = GNUNET_malloc(size); | ||
658 | msgheader->size = htons(size - sizeof(struct GNUNET_MessageHeader)); | ||
659 | msgheader->type = GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA; | ||
660 | 727 | ||
661 | radioHeader = (struct RadiotapHeader*) &msgheader[1]; | 728 | } |
662 | getRadiotapHeader(radioHeader); | ||
663 | 729 | ||
664 | wlanheader = (struct IeeeHeader *) &radioHeader[1]; | 730 | copyoffset = (WLAN_MTU - sizeof(struct FragmentationHeader)) * pm->message_pos; |
665 | getWlanHeader(wlanheader); | 731 | fragheader.fragment_off_or_num = pm->message_pos; |
732 | fragheader.message_id = session->message_id_out; | ||
733 | |||
734 | // start should be smaller then the packet size | ||
735 | //TODO send some other data if everything was send but not all acks are present | ||
736 | GNUNET_assert(copyoffset < pm->message_size); | ||
737 | copystart = pm->msg + copyoffset; | ||
738 | |||
739 | //size of the fragment is either the MTU - overhead | ||
740 | //or the missing part of the message in case this is the last fragment | ||
741 | copysize = GNUNET_MIN(pm->message_size - copyoffset, | ||
742 | WLAN_MTU - sizeof(struct FragmentationHeader)); | ||
743 | fragheader.header.size = copysize; | ||
744 | fragheader.header.type = GNUNET_MESSAGE_TYPE_WLAN_FRAGMENT; | ||
745 | |||
746 | //get the next missing fragment | ||
747 | exit = 0; | ||
748 | akt = pm->head; | ||
749 | pm->message_pos ++; | ||
750 | |||
751 | //test if ack was already received | ||
752 | while (akt != NULL){ | ||
753 | //if fragment is present, take next | ||
754 | if (akt->fragment_num == pm->message_pos) { | ||
755 | pm->message_pos ++; | ||
756 | } | ||
757 | //next ack is bigger then the fragment number | ||
758 | //in case there is something like this: (acks) 1, 2, 5, 6, ... | ||
759 | //and we send 3 again, the next number should be 4 | ||
760 | if (akt->fragment_num > pm->message_pos) { | ||
761 | break; | ||
762 | } | ||
763 | |||
764 | akt = akt->next; | ||
765 | } | ||
666 | 766 | ||
667 | 767 | ||
668 | //could be faster if content is just send and not copyed before | ||
669 | //fragmentheader is needed | ||
670 | if (pm->message_size > WLAN_MTU){ | ||
671 | fragheader.message_crc = getcrc16(copystart, copysize); | ||
672 | memcpy(&wlanheader[1],&fragheader, sizeof(struct FragmentationHeader)); | ||
673 | memcpy(&wlanheader[1] + sizeof(struct FragmentationHeader),copystart,copysize); | ||
674 | } else { | 768 | } else { |
675 | memcpy(&wlanheader[1],copystart,copysize); | 769 | // there is no need to split |
770 | copystart = pm->msg; | ||
771 | copysize = pm->message_size; | ||
676 | } | 772 | } |
773 | size += copysize; | ||
774 | size += sizeof(struct RadiotapHeader) + sizeof(struct IeeeHeader) | ||
775 | + sizeof(struct GNUNET_MessageHeader); | ||
776 | msgheader = GNUNET_malloc(size); | ||
777 | msgheader->size = htons(size - sizeof(struct GNUNET_MessageHeader)); | ||
778 | msgheader->type = GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA; | ||
677 | 779 | ||
678 | bytes = GNUNET_DISK_file_write(plugin->server_stdin_handle, msgheader, size); | 780 | radioHeader = (struct RadiotapHeader*) &msgheader[1]; |
781 | getRadiotapHeader(radioHeader); | ||
679 | 782 | ||
783 | wlanheader = (struct IeeeHeader *) &radioHeader[1]; | ||
784 | getWlanHeader(wlanheader); | ||
680 | 785 | ||
681 | } else { | ||
682 | //remove message | ||
683 | //TODO free the queues (acks) | ||
684 | GNUNET_CONTAINER_DLL_remove (session->pending_messages_head, | ||
685 | session->pending_messages_tail, | ||
686 | pm); | ||
687 | GNUNET_free(pm); | ||
688 | 786 | ||
787 | //could be faster if content is just send and not copyed before | ||
788 | //fragmentheader is needed | ||
789 | if (pm->message_size > WLAN_MTU){ | ||
790 | fragheader.message_crc = getcrc16(copystart, copysize); | ||
791 | memcpy(&wlanheader[1],&fragheader, sizeof(struct FragmentationHeader)); | ||
792 | memcpy(&wlanheader[1] + sizeof(struct FragmentationHeader),copystart,copysize); | ||
793 | } else { | ||
794 | memcpy(&wlanheader[1],copystart,copysize); | ||
689 | } | 795 | } |
690 | 796 | ||
797 | bytes = GNUNET_DISK_file_write(plugin->server_stdin_handle, msgheader, size); | ||
798 | |||
799 | |||
800 | |||
801 | |||
691 | 802 | ||
692 | 803 | ||
693 | 804 | ||
@@ -898,8 +1009,37 @@ static void | |||
898 | wlan_plugin_disconnect (void *cls, | 1009 | wlan_plugin_disconnect (void *cls, |
899 | const struct GNUNET_PeerIdentity *target) | 1010 | const struct GNUNET_PeerIdentity *target) |
900 | { | 1011 | { |
901 | // struct Plugin *plugin = cls; | 1012 | struct Plugin *plugin = cls; |
902 | // FIXME make something usefull :-D | 1013 | struct Sessionqueue * queue = plugin->sessions; |
1014 | struct Sessionqueue * lastitem = NULL; | ||
1015 | struct PendingMessage * pm; | ||
1016 | |||
1017 | // just look at all the session for the needed one | ||
1018 | while (queue != NULL){ | ||
1019 | // content is never NULL | ||
1020 | GNUNET_assert (queue->content == NULL); | ||
1021 | if (memcmp(target, &(queue->content->target), sizeof(struct GNUNET_PeerIdentity)) == 0) | ||
1022 | { | ||
1023 | // sesion found | ||
1024 | // remove PendingMessage | ||
1025 | while (queue->content->pending_messages_head != NULL){ | ||
1026 | pm = queue->content->pending_messages_head; | ||
1027 | free_acks(pm); | ||
1028 | GNUNET_CONTAINER_DLL_remove(queue->content->pending_messages_head,queue->content->pending_messages_tail, pm); | ||
1029 | GNUNET_free(pm); | ||
1030 | |||
1031 | } | ||
1032 | |||
1033 | GNUNET_free(queue->content); | ||
1034 | GNUNET_CONTAINER_DLL_remove(plugin->sessions, plugin->sessions_tail, queue); | ||
1035 | GNUNET_free(queue); | ||
1036 | |||
1037 | return; | ||
1038 | } | ||
1039 | // try next | ||
1040 | lastitem = queue; | ||
1041 | queue = queue->next; | ||
1042 | } | ||
903 | } | 1043 | } |
904 | 1044 | ||
905 | 1045 | ||
@@ -968,13 +1108,13 @@ wlan_plugin_address_suggested (void *cls, | |||
968 | const void *addr, | 1108 | const void *addr, |
969 | size_t addrlen) | 1109 | size_t addrlen) |
970 | { | 1110 | { |
971 | /* struct Plugin *plugin = cls; */ | 1111 | //struct Plugin *plugin = cls; |
972 | 1112 | ||
973 | /* check if the address is plausible; if so, | 1113 | /* check if the address is plausible; if so, |
974 | add it to our list! */ | 1114 | add it to our list! */ |
975 | 1115 | ||
976 | GNUNET_assert(cls !=NULL); | 1116 | GNUNET_assert(cls !=NULL); |
977 | 1117 | //FIXME mitm is not checked | |
978 | //Mac Adress has 6 bytes | 1118 | //Mac Adress has 6 bytes |
979 | if (addrlen == 6){ | 1119 | if (addrlen == 6){ |
980 | /* TODO check for bad addresses like milticast, broadcast, etc */ | 1120 | /* TODO check for bad addresses like milticast, broadcast, etc */ |
@@ -1163,11 +1303,12 @@ gnunet_plugin_transport_wlan_init (void *cls) | |||
1163 | 1303 | ||
1164 | plugin = GNUNET_malloc (sizeof (struct Plugin)); | 1304 | plugin = GNUNET_malloc (sizeof (struct Plugin)); |
1165 | plugin->env = env; | 1305 | plugin->env = env; |
1306 | plugin->pendingsessions = 0; | ||
1166 | 1307 | ||
1167 | wlan_transport_start_wlan_helper(plugin); | 1308 | wlan_transport_start_wlan_helper(plugin); |
1168 | plugin->consoltoken = GNUNET_SERVER_mst_create(&wlan_process_helper,plugin); | 1309 | plugin->consoltoken = GNUNET_SERVER_mst_create(&wlan_process_helper,plugin); |
1169 | 1310 | ||
1170 | //plugin->all_Sessions = GNUNET_malloc (sizeof (struct Sessionqueue)); | 1311 | //plugin->sessions = GNUNET_malloc (sizeof (struct Sessionqueue)); |
1171 | //plugin->pending_Sessions = GNUNET_malloc (sizeof (struct Sessionqueue)); | 1312 | //plugin->pending_Sessions = GNUNET_malloc (sizeof (struct Sessionqueue)); |
1172 | 1313 | ||
1173 | api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions)); | 1314 | api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions)); |
diff --git a/src/transport/plugin_transport_wlan.h b/src/transport/plugin_transport_wlan.h index dc30b5ff3..5ea8d3e20 100644 --- a/src/transport/plugin_transport_wlan.h +++ b/src/transport/plugin_transport_wlan.h | |||
@@ -30,13 +30,16 @@ typedef unsigned int uint32_t; | |||
30 | typedef unsigned short uint16_t; | 30 | typedef unsigned short uint16_t; |
31 | 31 | ||
32 | /* Wlan IEEE80211 header default */ | 32 | /* Wlan IEEE80211 header default */ |
33 | //Informations (in German) http://www.umtslink.at/content/WLAN_macheader-196.html | ||
33 | static const uint8_t u8aIeeeHeader[] = | 34 | static const uint8_t u8aIeeeHeader[] = |
34 | { | 35 | { |
35 | 0x08, 0x01, 0x00, 0x00, | 36 | 0x08, 0x01, // Frame Control 0x08= 00001000 -> | b1,2 = 0 -> Version 0; b3,4 = 10 -> Data; b5-8 = 0 -> Normal Data |
36 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, | 37 | // 0x01 = 00000001 -> | b1 = 1 to DS; b2 = 0 not from DS; |
37 | 0x13, 0x22, 0x33, 0x44, 0x55, 0x66, | 38 | 0x00, 0x00, // Duration/ID |
38 | 0x13, 0x22, 0x33, 0x44, 0x55, 0x66, | 39 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // mac1 |
39 | 0x10, 0x86, | 40 | 0x13, 0x22, 0x33, 0x44, 0x55, 0x66, // mac2 |
41 | 0x13, 0x22, 0x33, 0x44, 0x55, 0x66, // mac3 | ||
42 | 0x10, 0x86, //Sequence Control | ||
40 | }; | 43 | }; |
41 | 44 | ||
42 | /** | 45 | /** |
@@ -48,12 +51,19 @@ struct IeeeHeader | |||
48 | /** | 51 | /** |
49 | * Wlan flags | 52 | * Wlan flags |
50 | */ | 53 | */ |
51 | uint32_t flags; | 54 | uint16_t frame_control GNUNET_PACKED; |
55 | |||
56 | /** | ||
57 | * Duration / ID | ||
58 | */ | ||
59 | |||
60 | uint16_t duration_id GNUNET_PACKED; | ||
52 | 61 | ||
53 | /** | 62 | /** |
54 | * first mac | 63 | * first mac byte 1 |
55 | */ | 64 | */ |
56 | uint8_t mac1[6]; | 65 | uint8_t mac1[6]; |
66 | |||
57 | 67 | ||
58 | /** | 68 | /** |
59 | * second mac | 69 | * second mac |
@@ -66,9 +76,9 @@ struct IeeeHeader | |||
66 | uint8_t mac3[6]; | 76 | uint8_t mac3[6]; |
67 | 77 | ||
68 | /** | 78 | /** |
69 | * Wlan flags2 | 79 | * Wlan Sequence Control |
70 | */ | 80 | */ |
71 | uint16_t flags2; | 81 | uint16_t sequence_control GNUNET_PACKED; |
72 | }; | 82 | }; |
73 | 83 | ||
74 | /* this is the template radiotap header we send packets out with */ | 84 | /* this is the template radiotap header we send packets out with */ |