diff options
Diffstat (limited to 'src/transport/gnunet-service-tng.c')
-rw-r--r-- | src/transport/gnunet-service-tng.c | 349 |
1 files changed, 204 insertions, 145 deletions
diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c index d392b3a46..7d7d04375 100644 --- a/src/transport/gnunet-service-tng.c +++ b/src/transport/gnunet-service-tng.c | |||
@@ -46,16 +46,17 @@ | |||
46 | * #6 to ensure flow control and RTT are OK, we always do the | 46 | * #6 to ensure flow control and RTT are OK, we always do the |
47 | * 'validation', even if address comes from PEERSTORE | 47 | * 'validation', even if address comes from PEERSTORE |
48 | * #7 | 48 | * #7 |
49 | * - ACK handling / retransmission | 49 | * - ACK handling / retransmission |
50 | * - address verification | ||
50 | * - track RTT, distance, loss, etc. | 51 | * - track RTT, distance, loss, etc. |
51 | * - DV data structures: | 52 | * - DV data structures: |
52 | * + learning | 53 | * + learning |
53 | * + forgetting | 54 | * + forgetting |
54 | * + using them! | 55 | * + using them! |
55 | * - routing of messages (using DV data structures!) | 56 | * - routing of messages (using DV data structures!) |
56 | * - handling of DV-boxed messages that need to be forwarded | 57 | * - handling of DV-boxed messages that need to be forwarded |
57 | * - backchannel message encryption & decryption | 58 | * - backchannel message encryption & decryption |
58 | * - | 59 | * - |
59 | * | 60 | * |
60 | * Easy: | 61 | * Easy: |
61 | * - use ATS bandwidth allocation callback and schedule transmissions! | 62 | * - use ATS bandwidth allocation callback and schedule transmissions! |
@@ -72,7 +73,7 @@ | |||
72 | * (requires planning at receiver, and additional MST-style demultiplex | 73 | * (requires planning at receiver, and additional MST-style demultiplex |
73 | * at receiver!) | 74 | * at receiver!) |
74 | * - could avoid copying body of message into each fragment and keep | 75 | * - could avoid copying body of message into each fragment and keep |
75 | * fragments as just pointers into the original message and only | 76 | * fragments as just pointers into the original message and only |
76 | * fully build fragments just before transmission (optimization, should | 77 | * fully build fragments just before transmission (optimization, should |
77 | * reduce CPU and memory use) | 78 | * reduce CPU and memory use) |
78 | * | 79 | * |
@@ -141,7 +142,7 @@ | |||
141 | /** | 142 | /** |
142 | * How many messages can we have pending for a given communicator | 143 | * How many messages can we have pending for a given communicator |
143 | * process before we start to throttle that communicator? | 144 | * process before we start to throttle that communicator? |
144 | * | 145 | * |
145 | * Used if a communicator might be CPU-bound and cannot handle the traffic. | 146 | * Used if a communicator might be CPU-bound and cannot handle the traffic. |
146 | */ | 147 | */ |
147 | #define COMMUNICATOR_TOTAL_QUEUE_LIMIT 512 | 148 | #define COMMUNICATOR_TOTAL_QUEUE_LIMIT 512 |
@@ -150,7 +151,7 @@ | |||
150 | * How many messages can we have pending for a given session (queue to | 151 | * How many messages can we have pending for a given session (queue to |
151 | * a particular peer via a communicator) process before we start to | 152 | * a particular peer via a communicator) process before we start to |
152 | * throttle that queue? | 153 | * throttle that queue? |
153 | * | 154 | * |
154 | * Used if ATS assigns more bandwidth to a particular transmission | 155 | * Used if ATS assigns more bandwidth to a particular transmission |
155 | * method than that transmission method can right now handle. (Yes, | 156 | * method than that transmission method can right now handle. (Yes, |
156 | * ATS should eventually notice utilization below allocation and | 157 | * ATS should eventually notice utilization below allocation and |
@@ -195,7 +196,7 @@ struct TransportBackchannelEncapsulationMessage | |||
195 | 196 | ||
196 | // FIXME: probably should add random IV here as well, | 197 | // FIXME: probably should add random IV here as well, |
197 | // especially if we re-use ephemeral keys! | 198 | // especially if we re-use ephemeral keys! |
198 | 199 | ||
199 | /** | 200 | /** |
200 | * HMAC over the ciphertext of the encrypted, variable-size | 201 | * HMAC over the ciphertext of the encrypted, variable-size |
201 | * body that follows. Verified via DH of @e target and | 202 | * body that follows. Verified via DH of @e target and |
@@ -224,8 +225,8 @@ struct EphemeralConfirmation | |||
224 | * only interpret the value as a mononic time and reject | 225 | * only interpret the value as a mononic time and reject |
225 | * "older" values than the last one observed. Even with this, | 226 | * "older" values than the last one observed. Even with this, |
226 | * there is no real guarantee against replay achieved here, | 227 | * there is no real guarantee against replay achieved here, |
227 | * as the latest timestamp is not persisted. This is | 228 | * as the latest timestamp is not persisted. This is |
228 | * necessary as we do not want to require synchronized | 229 | * necessary as we do not want to require synchronized |
229 | * clocks and may not have a bidirectional communication | 230 | * clocks and may not have a bidirectional communication |
230 | * channel. Communicators must protect against replay | 231 | * channel. Communicators must protect against replay |
231 | * attacks when using backchannel communication! | 232 | * attacks when using backchannel communication! |
@@ -373,17 +374,17 @@ struct TransportFragmentBox | |||
373 | /** | 374 | /** |
374 | * Original message ID for of the message that all the1 | 375 | * Original message ID for of the message that all the1 |
375 | * fragments belong to. Must be the same for all fragments. | 376 | * fragments belong to. Must be the same for all fragments. |
376 | */ | 377 | */ |
377 | struct GNUNET_ShortHashCode msg_uuid; | 378 | struct GNUNET_ShortHashCode msg_uuid; |
378 | 379 | ||
379 | /** | 380 | /** |
380 | * Offset of this fragment in the overall message. | 381 | * Offset of this fragment in the overall message. |
381 | */ | 382 | */ |
382 | uint16_t frag_off GNUNET_PACKED; | 383 | uint16_t frag_off GNUNET_PACKED; |
383 | 384 | ||
384 | /** | 385 | /** |
385 | * Total size of the message that is being fragmented. | 386 | * Total size of the message that is being fragmented. |
386 | */ | 387 | */ |
387 | uint16_t msg_size GNUNET_PACKED; | 388 | uint16_t msg_size GNUNET_PACKED; |
388 | 389 | ||
389 | }; | 390 | }; |
@@ -412,13 +413,13 @@ struct TransportFragmentAckMessage | |||
412 | /** | 413 | /** |
413 | * Bitfield of up to 64 additional fragments following the | 414 | * Bitfield of up to 64 additional fragments following the |
414 | * @e msg_uuid being acknowledged by this message. | 415 | * @e msg_uuid being acknowledged by this message. |
415 | */ | 416 | */ |
416 | uint64_t extra_acks GNUNET_PACKED; | 417 | uint64_t extra_acks GNUNET_PACKED; |
417 | 418 | ||
418 | /** | 419 | /** |
419 | * Original message ID for of the message that all the | 420 | * Original message ID for of the message that all the |
420 | * fragments belong to. | 421 | * fragments belong to. |
421 | */ | 422 | */ |
422 | struct GNUNET_ShortHashCode msg_uuid; | 423 | struct GNUNET_ShortHashCode msg_uuid; |
423 | 424 | ||
424 | /** | 425 | /** |
@@ -444,7 +445,7 @@ struct TransportFragmentAckMessage | |||
444 | * to a subset of their neighbours to limit discoverability of the | 445 | * to a subset of their neighbours to limit discoverability of the |
445 | * network topology). To the extend that the @e bidirectional bits | 446 | * network topology). To the extend that the @e bidirectional bits |
446 | * are set, peers may learn the inverse paths even if they did not | 447 | * are set, peers may learn the inverse paths even if they did not |
447 | * initiate. | 448 | * initiate. |
448 | * | 449 | * |
449 | * Unless received on a bidirectional queue and @e num_hops just | 450 | * Unless received on a bidirectional queue and @e num_hops just |
450 | * zero, peers that can forward to the initator should always try to | 451 | * zero, peers that can forward to the initator should always try to |
@@ -469,13 +470,13 @@ struct TransportDVLearn | |||
469 | * to possibly instantly learn a path in both directions. Each peer | 470 | * to possibly instantly learn a path in both directions. Each peer |
470 | * should shift this value by one to the left, and then set the | 471 | * should shift this value by one to the left, and then set the |
471 | * lowest bit IF the current sender can be reached from it (without | 472 | * lowest bit IF the current sender can be reached from it (without |
472 | * DV routing). | 473 | * DV routing). |
473 | */ | 474 | */ |
474 | uint16_t bidirectional GNUNET_PACKED; | 475 | uint16_t bidirectional GNUNET_PACKED; |
475 | 476 | ||
476 | /** | 477 | /** |
477 | * Peers receiving this message and delaying forwarding to other | 478 | * Peers receiving this message and delaying forwarding to other |
478 | * peers for any reason should increment this value such as to | 479 | * peers for any reason should increment this value such as to |
479 | * enable the origin to determine the actual network-only delay | 480 | * enable the origin to determine the actual network-only delay |
480 | * in addition to the real-time delay (assuming the message loops | 481 | * in addition to the real-time delay (assuming the message loops |
481 | * back to the origin). | 482 | * back to the origin). |
@@ -486,11 +487,11 @@ struct TransportDVLearn | |||
486 | * Identity of the peer that started this learning activity. | 487 | * Identity of the peer that started this learning activity. |
487 | */ | 488 | */ |
488 | struct GNUNET_PeerIdentity initiator; | 489 | struct GNUNET_PeerIdentity initiator; |
489 | 490 | ||
490 | /* Followed by @e num_hops `struct GNUNET_PeerIdentity` values, | 491 | /* Followed by @e num_hops `struct GNUNET_PeerIdentity` values, |
491 | excluding the initiator of the DV trace; the last entry is the | 492 | excluding the initiator of the DV trace; the last entry is the |
492 | current sender; the current peer must not be included. */ | 493 | current sender; the current peer must not be included. */ |
493 | 494 | ||
494 | }; | 495 | }; |
495 | 496 | ||
496 | 497 | ||
@@ -527,7 +528,7 @@ struct TransportDVBox | |||
527 | * Number of hops this messages includes. In NBO. | 528 | * Number of hops this messages includes. In NBO. |
528 | */ | 529 | */ |
529 | uint16_t num_hops GNUNET_PACKED; | 530 | uint16_t num_hops GNUNET_PACKED; |
530 | 531 | ||
531 | /** | 532 | /** |
532 | * Identity of the peer that originated the message. | 533 | * Identity of the peer that originated the message. |
533 | */ | 534 | */ |
@@ -577,7 +578,7 @@ enum ClientType | |||
577 | /** | 578 | /** |
578 | * Entry in our cache of ephemeral keys we currently use. | 579 | * Entry in our cache of ephemeral keys we currently use. |
579 | * This way, we only sign an ephemeral once per @e target, | 580 | * This way, we only sign an ephemeral once per @e target, |
580 | * and then can re-use it over multiple | 581 | * and then can re-use it over multiple |
581 | * #GNUNET_MESSAGE_TYPE_TRANSPORT_BACKCHANNEL_ENCAPSULATION | 582 | * #GNUNET_MESSAGE_TYPE_TRANSPORT_BACKCHANNEL_ENCAPSULATION |
582 | * messages (as signing is expensive). | 583 | * messages (as signing is expensive). |
583 | */ | 584 | */ |
@@ -645,39 +646,39 @@ struct DistanceVectorHop | |||
645 | 646 | ||
646 | /** | 647 | /** |
647 | * Kept in a MDLL, sorted by @e timeout. | 648 | * Kept in a MDLL, sorted by @e timeout. |
648 | */ | 649 | */ |
649 | struct DistanceVectorHop *next_dv; | 650 | struct DistanceVectorHop *next_dv; |
650 | 651 | ||
651 | /** | 652 | /** |
652 | * Kept in a MDLL, sorted by @e timeout. | 653 | * Kept in a MDLL, sorted by @e timeout. |
653 | */ | 654 | */ |
654 | struct DistanceVectorHop *prev_dv; | 655 | struct DistanceVectorHop *prev_dv; |
655 | 656 | ||
656 | /** | 657 | /** |
657 | * Kept in a MDLL. | 658 | * Kept in a MDLL. |
658 | */ | 659 | */ |
659 | struct DistanceVectorHop *next_neighbour; | 660 | struct DistanceVectorHop *next_neighbour; |
660 | 661 | ||
661 | /** | 662 | /** |
662 | * Kept in a MDLL. | 663 | * Kept in a MDLL. |
663 | */ | 664 | */ |
664 | struct DistanceVectorHop *prev_neighbour; | 665 | struct DistanceVectorHop *prev_neighbour; |
665 | 666 | ||
666 | /** | 667 | /** |
667 | * What would be the next hop to @e target? | 668 | * What would be the next hop to @e target? |
668 | */ | 669 | */ |
669 | struct Neighbour *next_hop; | 670 | struct Neighbour *next_hop; |
670 | 671 | ||
671 | /** | 672 | /** |
672 | * Distance vector entry this hop belongs with. | 673 | * Distance vector entry this hop belongs with. |
673 | */ | 674 | */ |
674 | struct DistanceVector *dv; | 675 | struct DistanceVector *dv; |
675 | 676 | ||
676 | /** | 677 | /** |
677 | * Array of @e distance hops to the target, excluding @e next_hop. | 678 | * Array of @e distance hops to the target, excluding @e next_hop. |
678 | * NULL if the entire path is us to @e next_hop to `target`. Allocated | 679 | * NULL if the entire path is us to @e next_hop to `target`. Allocated |
679 | * at the end of this struct. | 680 | * at the end of this struct. |
680 | */ | 681 | */ |
681 | const struct GNUNET_PeerIdentity *path; | 682 | const struct GNUNET_PeerIdentity *path; |
682 | 683 | ||
683 | /** | 684 | /** |
@@ -685,11 +686,11 @@ struct DistanceVectorHop | |||
685 | * while learning? | 686 | * while learning? |
686 | */ | 687 | */ |
687 | struct GNUNET_TIME_Absolute timeout; | 688 | struct GNUNET_TIME_Absolute timeout; |
688 | 689 | ||
689 | /** | 690 | /** |
690 | * How many hops in total to the `target` (excluding @e next_hop and `target` itself), | 691 | * How many hops in total to the `target` (excluding @e next_hop and `target` itself), |
691 | * thus 0 still means a distance of 2 hops (to @e next_hop and then to `target`)? | 692 | * thus 0 still means a distance of 2 hops (to @e next_hop and then to `target`)? |
692 | */ | 693 | */ |
693 | unsigned int distance; | 694 | unsigned int distance; |
694 | }; | 695 | }; |
695 | 696 | ||
@@ -708,12 +709,12 @@ struct DistanceVector | |||
708 | 709 | ||
709 | /** | 710 | /** |
710 | * Known paths to @e target. | 711 | * Known paths to @e target. |
711 | */ | 712 | */ |
712 | struct DistanceVectorHop *dv_head; | 713 | struct DistanceVectorHop *dv_head; |
713 | 714 | ||
714 | /** | 715 | /** |
715 | * Known paths to @e target. | 716 | * Known paths to @e target. |
716 | */ | 717 | */ |
717 | struct DistanceVectorHop *dv_tail; | 718 | struct DistanceVectorHop *dv_tail; |
718 | 719 | ||
719 | /** | 720 | /** |
@@ -737,19 +738,19 @@ struct QueueEntry | |||
737 | 738 | ||
738 | /** | 739 | /** |
739 | * Kept as a DLL. | 740 | * Kept as a DLL. |
740 | */ | 741 | */ |
741 | struct QueueEntry *next; | 742 | struct QueueEntry *next; |
742 | 743 | ||
743 | /** | 744 | /** |
744 | * Kept as a DLL. | 745 | * Kept as a DLL. |
745 | */ | 746 | */ |
746 | struct QueueEntry *prev; | 747 | struct QueueEntry *prev; |
747 | 748 | ||
748 | /** | 749 | /** |
749 | * ATS session this entry is queued with. | 750 | * ATS session this entry is queued with. |
750 | */ | 751 | */ |
751 | struct GNUNET_ATS_Session *session; | 752 | struct GNUNET_ATS_Session *session; |
752 | 753 | ||
753 | /** | 754 | /** |
754 | * Message ID used for this message with the queue used for transmission. | 755 | * Message ID used for this message with the queue used for transmission. |
755 | */ | 756 | */ |
@@ -785,12 +786,12 @@ struct GNUNET_ATS_Session | |||
785 | 786 | ||
786 | /** | 787 | /** |
787 | * Head of DLL of unacked transmission requests. | 788 | * Head of DLL of unacked transmission requests. |
788 | */ | 789 | */ |
789 | struct QueueEntry *queue_head; | 790 | struct QueueEntry *queue_head; |
790 | 791 | ||
791 | /** | 792 | /** |
792 | * End of DLL of unacked transmission requests. | 793 | * End of DLL of unacked transmission requests. |
793 | */ | 794 | */ |
794 | struct QueueEntry *queue_tail; | 795 | struct QueueEntry *queue_tail; |
795 | 796 | ||
796 | /** | 797 | /** |
@@ -816,9 +817,9 @@ struct GNUNET_ATS_Session | |||
816 | /** | 817 | /** |
817 | * Task scheduled for the time when this queue can (likely) transmit the | 818 | * Task scheduled for the time when this queue can (likely) transmit the |
818 | * next message. Still needs to check with the @e tracker_out to be sure. | 819 | * next message. Still needs to check with the @e tracker_out to be sure. |
819 | */ | 820 | */ |
820 | struct GNUNET_SCHEDULER_Task *transmit_task; | 821 | struct GNUNET_SCHEDULER_Task *transmit_task; |
821 | 822 | ||
822 | /** | 823 | /** |
823 | * Our current RTT estimate for this ATS session. | 824 | * Our current RTT estimate for this ATS session. |
824 | */ | 825 | */ |
@@ -826,9 +827,9 @@ struct GNUNET_ATS_Session | |||
826 | 827 | ||
827 | /** | 828 | /** |
828 | * Message ID generator for transmissions on this queue. | 829 | * Message ID generator for transmissions on this queue. |
829 | */ | 830 | */ |
830 | uint64_t mid_gen; | 831 | uint64_t mid_gen; |
831 | 832 | ||
832 | /** | 833 | /** |
833 | * Unique identifier of this ATS session with the communicator. | 834 | * Unique identifier of this ATS session with the communicator. |
834 | */ | 835 | */ |
@@ -858,7 +859,7 @@ struct GNUNET_ATS_Session | |||
858 | * Length of the DLL starting at @e queue_head. | 859 | * Length of the DLL starting at @e queue_head. |
859 | */ | 860 | */ |
860 | unsigned int queue_length; | 861 | unsigned int queue_length; |
861 | 862 | ||
862 | /** | 863 | /** |
863 | * Network type offered by this ATS session. | 864 | * Network type offered by this ATS session. |
864 | */ | 865 | */ |
@@ -883,14 +884,14 @@ struct GNUNET_ATS_Session | |||
883 | 884 | ||
884 | /** | 885 | /** |
885 | * Information we keep for a message that we are reassembling. | 886 | * Information we keep for a message that we are reassembling. |
886 | */ | 887 | */ |
887 | struct ReassemblyContext | 888 | struct ReassemblyContext |
888 | { | 889 | { |
889 | 890 | ||
890 | /** | 891 | /** |
891 | * Original message ID for of the message that all the | 892 | * Original message ID for of the message that all the |
892 | * fragments belong to. | 893 | * fragments belong to. |
893 | */ | 894 | */ |
894 | struct GNUNET_ShortHashCode msg_uuid; | 895 | struct GNUNET_ShortHashCode msg_uuid; |
895 | 896 | ||
896 | /** | 897 | /** |
@@ -900,7 +901,7 @@ struct ReassemblyContext | |||
900 | 901 | ||
901 | /** | 902 | /** |
902 | * Entry in the reassembly heap (sorted by expiration). | 903 | * Entry in the reassembly heap (sorted by expiration). |
903 | */ | 904 | */ |
904 | struct GNUNET_CONTAINER_HeapNode *hn; | 905 | struct GNUNET_CONTAINER_HeapNode *hn; |
905 | 906 | ||
906 | /** | 907 | /** |
@@ -918,7 +919,7 @@ struct ReassemblyContext | |||
918 | * task is for the latter case. | 919 | * task is for the latter case. |
919 | */ | 920 | */ |
920 | struct GNUNET_SCHEDULER_Task *ack_task; | 921 | struct GNUNET_SCHEDULER_Task *ack_task; |
921 | 922 | ||
922 | /** | 923 | /** |
923 | * At what time will we give up reassembly of this message? | 924 | * At what time will we give up reassembly of this message? |
924 | */ | 925 | */ |
@@ -941,7 +942,7 @@ struct ReassemblyContext | |||
941 | * to be acknowledged in the next cummulative ACK. | 942 | * to be acknowledged in the next cummulative ACK. |
942 | */ | 943 | */ |
943 | uint64_t extra_acks; | 944 | uint64_t extra_acks; |
944 | 945 | ||
945 | /** | 946 | /** |
946 | * Unique ID of the lowest fragment UUID to be acknowledged in the | 947 | * Unique ID of the lowest fragment UUID to be acknowledged in the |
947 | * next cummulative ACK. Only valid if @e num_acks > 0. | 948 | * next cummulative ACK. Only valid if @e num_acks > 0. |
@@ -953,7 +954,7 @@ struct ReassemblyContext | |||
953 | * whenever we send a #GNUNET_MESSAGE_TYPE_TRANSPORT_FRAGMENT_ACK. | 954 | * whenever we send a #GNUNET_MESSAGE_TYPE_TRANSPORT_FRAGMENT_ACK. |
954 | */ | 955 | */ |
955 | unsigned int num_acks; | 956 | unsigned int num_acks; |
956 | 957 | ||
957 | /** | 958 | /** |
958 | * How big is the message we are reassembling in total? | 959 | * How big is the message we are reassembling in total? |
959 | */ | 960 | */ |
@@ -986,21 +987,21 @@ struct Neighbour | |||
986 | * Map with `struct ReassemblyContext` structs for fragments under | 987 | * Map with `struct ReassemblyContext` structs for fragments under |
987 | * reassembly. May be NULL if we currently have no fragments from | 988 | * reassembly. May be NULL if we currently have no fragments from |
988 | * this @e pid (lazy initialization). | 989 | * this @e pid (lazy initialization). |
989 | */ | 990 | */ |
990 | struct GNUNET_CONTAINER_MultiShortmap *reassembly_map; | 991 | struct GNUNET_CONTAINER_MultiShortmap *reassembly_map; |
991 | 992 | ||
992 | /** | 993 | /** |
993 | * Heap with `struct ReassemblyContext` structs for fragments under | 994 | * Heap with `struct ReassemblyContext` structs for fragments under |
994 | * reassembly. May be NULL if we currently have no fragments from | 995 | * reassembly. May be NULL if we currently have no fragments from |
995 | * this @e pid (lazy initialization). | 996 | * this @e pid (lazy initialization). |
996 | */ | 997 | */ |
997 | struct GNUNET_CONTAINER_Heap *reassembly_heap; | 998 | struct GNUNET_CONTAINER_Heap *reassembly_heap; |
998 | 999 | ||
999 | /** | 1000 | /** |
1000 | * Task to free old entries from the @e reassembly_heap and @e reassembly_map. | 1001 | * Task to free old entries from the @e reassembly_heap and @e reassembly_map. |
1001 | */ | 1002 | */ |
1002 | struct GNUNET_SCHEDULER_Task *reassembly_timeout_task; | 1003 | struct GNUNET_SCHEDULER_Task *reassembly_timeout_task; |
1003 | 1004 | ||
1004 | /** | 1005 | /** |
1005 | * Head of list of messages pending for this neighbour. | 1006 | * Head of list of messages pending for this neighbour. |
1006 | */ | 1007 | */ |
@@ -1014,13 +1015,13 @@ struct Neighbour | |||
1014 | /** | 1015 | /** |
1015 | * Head of MDLL of DV hops that have this neighbour as next hop. Must be | 1016 | * Head of MDLL of DV hops that have this neighbour as next hop. Must be |
1016 | * purged if this neighbour goes down. | 1017 | * purged if this neighbour goes down. |
1017 | */ | 1018 | */ |
1018 | struct DistanceVectorHop *dv_head; | 1019 | struct DistanceVectorHop *dv_head; |
1019 | 1020 | ||
1020 | /** | 1021 | /** |
1021 | * Tail of MDLL of DV hops that have this neighbour as next hop. Must be | 1022 | * Tail of MDLL of DV hops that have this neighbour as next hop. Must be |
1022 | * purged if this neighbour goes down. | 1023 | * purged if this neighbour goes down. |
1023 | */ | 1024 | */ |
1024 | struct DistanceVectorHop *dv_tail; | 1025 | struct DistanceVectorHop *dv_tail; |
1025 | 1026 | ||
1026 | /** | 1027 | /** |
@@ -1035,7 +1036,7 @@ struct Neighbour | |||
1035 | 1036 | ||
1036 | /** | 1037 | /** |
1037 | * Task run to cleanup pending messages that have exceeded their timeout. | 1038 | * Task run to cleanup pending messages that have exceeded their timeout. |
1038 | */ | 1039 | */ |
1039 | struct GNUNET_SCHEDULER_Task *timeout_task; | 1040 | struct GNUNET_SCHEDULER_Task *timeout_task; |
1040 | 1041 | ||
1041 | /** | 1042 | /** |
@@ -1052,15 +1053,15 @@ struct Neighbour | |||
1052 | 1053 | ||
1053 | /** | 1054 | /** |
1054 | * What is the earliest timeout of any message in @e pending_msg_tail? | 1055 | * What is the earliest timeout of any message in @e pending_msg_tail? |
1055 | */ | 1056 | */ |
1056 | struct GNUNET_TIME_Absolute earliest_timeout; | 1057 | struct GNUNET_TIME_Absolute earliest_timeout; |
1057 | 1058 | ||
1058 | }; | 1059 | }; |
1059 | 1060 | ||
1060 | 1061 | ||
1061 | /** | 1062 | /** |
1062 | * Types of different pending messages. | 1063 | * Types of different pending messages. |
1063 | */ | 1064 | */ |
1064 | enum PendingMessageType | 1065 | enum PendingMessageType |
1065 | { | 1066 | { |
1066 | 1067 | ||
@@ -1084,7 +1085,7 @@ enum PendingMessageType | |||
1084 | */ | 1085 | */ |
1085 | PMT_ACKNOWLEDGEMENT = 3 | 1086 | PMT_ACKNOWLEDGEMENT = 3 |
1086 | 1087 | ||
1087 | 1088 | ||
1088 | }; | 1089 | }; |
1089 | 1090 | ||
1090 | 1091 | ||
@@ -1101,13 +1102,13 @@ enum PendingMessageType | |||
1101 | * either calculate the next fragment (based on @e frag_off) from the | 1102 | * either calculate the next fragment (based on @e frag_off) from the |
1102 | * current node, or, if all fragments have already been created, | 1103 | * current node, or, if all fragments have already been created, |
1103 | * descend to the @e head_frag. Even though the node was already | 1104 | * descend to the @e head_frag. Even though the node was already |
1104 | * fragmented, the fragment may be too big if the fragment was | 1105 | * fragmented, the fragment may be too big if the fragment was |
1105 | * generated for a queue with a larger MTU. In this case, the node | 1106 | * generated for a queue with a larger MTU. In this case, the node |
1106 | * may be fragmented again, thus creating a tree. | 1107 | * may be fragmented again, thus creating a tree. |
1107 | * | 1108 | * |
1108 | * When acknowledgements for fragments are received, the tree | 1109 | * When acknowledgements for fragments are received, the tree |
1109 | * must be pruned, removing those parts that were already | 1110 | * must be pruned, removing those parts that were already |
1110 | * acknowledged. When fragments are sent over a reliable | 1111 | * acknowledged. When fragments are sent over a reliable |
1111 | * channel, they can be immediately removed. | 1112 | * channel, they can be immediately removed. |
1112 | * | 1113 | * |
1113 | * If a message is ever fragmented, then the original "full" message | 1114 | * If a message is ever fragmented, then the original "full" message |
@@ -1130,7 +1131,7 @@ struct PendingMessage | |||
1130 | * Kept in a MDLL of messages from this @a client (if @e pmt is #PMT_CORE) | 1131 | * Kept in a MDLL of messages from this @a client (if @e pmt is #PMT_CORE) |
1131 | */ | 1132 | */ |
1132 | struct PendingMessage *next_client; | 1133 | struct PendingMessage *next_client; |
1133 | 1134 | ||
1134 | /** | 1135 | /** |
1135 | * Kept in a MDLL of messages from this @a client (if @e pmt is #PMT_CORE) | 1136 | * Kept in a MDLL of messages from this @a client (if @e pmt is #PMT_CORE) |
1136 | */ | 1137 | */ |
@@ -1140,7 +1141,7 @@ struct PendingMessage | |||
1140 | * Kept in a MDLL of messages from this @a cpm (if @e pmt is #PMT_FRAGMENT_BOx) | 1141 | * Kept in a MDLL of messages from this @a cpm (if @e pmt is #PMT_FRAGMENT_BOx) |
1141 | */ | 1142 | */ |
1142 | struct PendingMessage *next_frag; | 1143 | struct PendingMessage *next_frag; |
1143 | 1144 | ||
1144 | /** | 1145 | /** |
1145 | * Kept in a MDLL of messages from this @a cpm (if @e pmt is #PMT_FRAGMENT_BOX) | 1146 | * Kept in a MDLL of messages from this @a cpm (if @e pmt is #PMT_FRAGMENT_BOX) |
1146 | */ | 1147 | */ |
@@ -1148,24 +1149,24 @@ struct PendingMessage | |||
1148 | 1149 | ||
1149 | /** | 1150 | /** |
1150 | * This message, reliability boxed. Only possibly available if @e pmt is #PMT_CORE. | 1151 | * This message, reliability boxed. Only possibly available if @e pmt is #PMT_CORE. |
1151 | */ | 1152 | */ |
1152 | struct PendingMessage *bpm; | 1153 | struct PendingMessage *bpm; |
1153 | 1154 | ||
1154 | /** | 1155 | /** |
1155 | * Target of the request. | 1156 | * Target of the request. |
1156 | */ | 1157 | */ |
1157 | struct Neighbour *target; | 1158 | struct Neighbour *target; |
1158 | 1159 | ||
1159 | /** | 1160 | /** |
1160 | * Client that issued the transmission request, if @e pmt is #PMT_CORE. | 1161 | * Client that issued the transmission request, if @e pmt is #PMT_CORE. |
1161 | */ | 1162 | */ |
1162 | struct TransportClient *client; | 1163 | struct TransportClient *client; |
1163 | 1164 | ||
1164 | /** | 1165 | /** |
1165 | * Head of a MDLL of fragments created for this core message. | 1166 | * Head of a MDLL of fragments created for this core message. |
1166 | */ | 1167 | */ |
1167 | struct PendingMessage *head_frag; | 1168 | struct PendingMessage *head_frag; |
1168 | 1169 | ||
1169 | /** | 1170 | /** |
1170 | * Tail of a MDLL of fragments created for this core message. | 1171 | * Tail of a MDLL of fragments created for this core message. |
1171 | */ | 1172 | */ |
@@ -1175,7 +1176,7 @@ struct PendingMessage | |||
1175 | * Our parent in the fragmentation tree. | 1176 | * Our parent in the fragmentation tree. |
1176 | */ | 1177 | */ |
1177 | struct PendingMessage *frag_parent; | 1178 | struct PendingMessage *frag_parent; |
1178 | 1179 | ||
1179 | /** | 1180 | /** |
1180 | * At what time should we give up on the transmission (and no longer retry)? | 1181 | * At what time should we give up on the transmission (and no longer retry)? |
1181 | */ | 1182 | */ |
@@ -1191,12 +1192,12 @@ struct PendingMessage | |||
1191 | * initialized if @e msg_uuid_set is #GNUNET_YES). | 1192 | * initialized if @e msg_uuid_set is #GNUNET_YES). |
1192 | */ | 1193 | */ |
1193 | struct GNUNET_ShortHashCode msg_uuid; | 1194 | struct GNUNET_ShortHashCode msg_uuid; |
1194 | 1195 | ||
1195 | /** | 1196 | /** |
1196 | * Counter incremented per generated fragment. | 1197 | * Counter incremented per generated fragment. |
1197 | */ | 1198 | */ |
1198 | uint32_t frag_uuidgen; | 1199 | uint32_t frag_uuidgen; |
1199 | 1200 | ||
1200 | /** | 1201 | /** |
1201 | * Type of the pending message. | 1202 | * Type of the pending message. |
1202 | */ | 1203 | */ |
@@ -1209,14 +1210,14 @@ struct PendingMessage | |||
1209 | 1210 | ||
1210 | /** | 1211 | /** |
1211 | * Offset at which we should generate the next fragment. | 1212 | * Offset at which we should generate the next fragment. |
1212 | */ | 1213 | */ |
1213 | uint16_t frag_off; | 1214 | uint16_t frag_off; |
1214 | 1215 | ||
1215 | /** | 1216 | /** |
1216 | * #GNUNET_YES once @e msg_uuid was initialized | 1217 | * #GNUNET_YES once @e msg_uuid was initialized |
1217 | */ | 1218 | */ |
1218 | int16_t msg_uuid_set; | 1219 | int16_t msg_uuid_set; |
1219 | 1220 | ||
1220 | /* Followed by @e bytes_msg to transmit */ | 1221 | /* Followed by @e bytes_msg to transmit */ |
1221 | }; | 1222 | }; |
1222 | 1223 | ||
@@ -1316,7 +1317,7 @@ struct TransportClient | |||
1316 | struct { | 1317 | struct { |
1317 | 1318 | ||
1318 | /** | 1319 | /** |
1319 | * Head of list of messages pending for this client, sorted by | 1320 | * Head of list of messages pending for this client, sorted by |
1320 | * transmission time ("next_attempt" + possibly internal prioritization). | 1321 | * transmission time ("next_attempt" + possibly internal prioritization). |
1321 | */ | 1322 | */ |
1322 | struct PendingMessage *pending_msg_head; | 1323 | struct PendingMessage *pending_msg_head; |
@@ -1384,7 +1385,7 @@ struct TransportClient | |||
1384 | * is globally unable to keep up. | 1385 | * is globally unable to keep up. |
1385 | */ | 1386 | */ |
1386 | unsigned int total_queue_length; | 1387 | unsigned int total_queue_length; |
1387 | 1388 | ||
1388 | /** | 1389 | /** |
1389 | * Characteristics of this communicator. | 1390 | * Characteristics of this communicator. |
1390 | */ | 1391 | */ |
@@ -1559,7 +1560,7 @@ free_distance_vector_hop (struct DistanceVectorHop *dvh) | |||
1559 | GNUNET_free (dvh); | 1560 | GNUNET_free (dvh); |
1560 | if (NULL == dv->dv_head) | 1561 | if (NULL == dv->dv_head) |
1561 | { | 1562 | { |
1562 | GNUNET_assert (GNUNET_YES == | 1563 | GNUNET_assert (GNUNET_YES == |
1563 | GNUNET_CONTAINER_multipeermap_remove (dv_routes, | 1564 | GNUNET_CONTAINER_multipeermap_remove (dv_routes, |
1564 | &dv->target, | 1565 | &dv->target, |
1565 | dv)); | 1566 | dv)); |
@@ -1764,7 +1765,7 @@ free_reassembly_cb (void *cls, | |||
1764 | struct ReassemblyContext *rc = value; | 1765 | struct ReassemblyContext *rc = value; |
1765 | (void) cls; | 1766 | (void) cls; |
1766 | (void) key; | 1767 | (void) key; |
1767 | 1768 | ||
1768 | free_reassembly_context (rc); | 1769 | free_reassembly_context (rc); |
1769 | return GNUNET_OK; | 1770 | return GNUNET_OK; |
1770 | } | 1771 | } |
@@ -1779,7 +1780,7 @@ static void | |||
1779 | free_neighbour (struct Neighbour *neighbour) | 1780 | free_neighbour (struct Neighbour *neighbour) |
1780 | { | 1781 | { |
1781 | struct DistanceVectorHop *dvh; | 1782 | struct DistanceVectorHop *dvh; |
1782 | 1783 | ||
1783 | GNUNET_assert (NULL == neighbour->session_head); | 1784 | GNUNET_assert (NULL == neighbour->session_head); |
1784 | GNUNET_assert (GNUNET_YES == | 1785 | GNUNET_assert (GNUNET_YES == |
1785 | GNUNET_CONTAINER_multipeermap_remove (neighbours, | 1786 | GNUNET_CONTAINER_multipeermap_remove (neighbours, |
@@ -1881,25 +1882,25 @@ cores_send_disconnect_info (const struct GNUNET_PeerIdentity *pid) | |||
1881 | 1882 | ||
1882 | /** | 1883 | /** |
1883 | * We believe we are ready to transmit a message on a queue. Double-checks | 1884 | * We believe we are ready to transmit a message on a queue. Double-checks |
1884 | * with the queue's "tracker_out" and then gives the message to the | 1885 | * with the queue's "tracker_out" and then gives the message to the |
1885 | * communicator for transmission (updating the tracker, and re-scheduling | 1886 | * communicator for transmission (updating the tracker, and re-scheduling |
1886 | * itself if applicable). | 1887 | * itself if applicable). |
1887 | * | 1888 | * |
1888 | * @param cls the `struct GNUNET_ATS_Session` to process transmissions for | 1889 | * @param cls the `struct GNUNET_ATS_Session` to process transmissions for |
1889 | */ | 1890 | */ |
1890 | static void | 1891 | static void |
1891 | transmit_on_queue (void *cls); | 1892 | transmit_on_queue (void *cls); |
1892 | 1893 | ||
1893 | 1894 | ||
1894 | /** | 1895 | /** |
1895 | * Schedule next run of #transmit_on_queue(). Does NOTHING if | 1896 | * Schedule next run of #transmit_on_queue(). Does NOTHING if |
1896 | * we should run immediately or if the message queue is empty. | 1897 | * we should run immediately or if the message queue is empty. |
1897 | * Test for no task being added AND queue not being empty to | 1898 | * Test for no task being added AND queue not being empty to |
1898 | * transmit immediately afterwards! This function must only | 1899 | * transmit immediately afterwards! This function must only |
1899 | * be called if the message queue is non-empty! | 1900 | * be called if the message queue is non-empty! |
1900 | * | 1901 | * |
1901 | * @param queue the queue to do scheduling for | 1902 | * @param queue the queue to do scheduling for |
1902 | */ | 1903 | */ |
1903 | static void | 1904 | static void |
1904 | schedule_transmit_on_queue (struct GNUNET_ATS_Session *queue) | 1905 | schedule_transmit_on_queue (struct GNUNET_ATS_Session *queue) |
1905 | { | 1906 | { |
@@ -1914,7 +1915,7 @@ schedule_transmit_on_queue (struct GNUNET_ATS_Session *queue) | |||
1914 | GNUNET_STATISTICS_update (GST_stats, | 1915 | GNUNET_STATISTICS_update (GST_stats, |
1915 | "# Transmission throttled due to communicator queue limit", | 1916 | "# Transmission throttled due to communicator queue limit", |
1916 | 1, | 1917 | 1, |
1917 | GNUNET_NO); | 1918 | GNUNET_NO); |
1918 | return; | 1919 | return; |
1919 | } | 1920 | } |
1920 | if (queue->queue_length >= SESSION_QUEUE_LIMIT) | 1921 | if (queue->queue_length >= SESSION_QUEUE_LIMIT) |
@@ -1922,10 +1923,10 @@ schedule_transmit_on_queue (struct GNUNET_ATS_Session *queue) | |||
1922 | GNUNET_STATISTICS_update (GST_stats, | 1923 | GNUNET_STATISTICS_update (GST_stats, |
1923 | "# Transmission throttled due to session queue limit", | 1924 | "# Transmission throttled due to session queue limit", |
1924 | 1, | 1925 | 1, |
1925 | GNUNET_NO); | 1926 | GNUNET_NO); |
1926 | return; | 1927 | return; |
1927 | } | 1928 | } |
1928 | 1929 | ||
1929 | wsize = (0 == queue->mtu) | 1930 | wsize = (0 == queue->mtu) |
1930 | ? pm->bytes_msg /* FIXME: add overheads? */ | 1931 | ? pm->bytes_msg /* FIXME: add overheads? */ |
1931 | : queue->mtu; | 1932 | : queue->mtu; |
@@ -2213,7 +2214,7 @@ check_client_send (void *cls, | |||
2213 | * Free fragment tree below @e root, excluding @e root itself. | 2214 | * Free fragment tree below @e root, excluding @e root itself. |
2214 | * | 2215 | * |
2215 | * @param root root of the tree to free | 2216 | * @param root root of the tree to free |
2216 | */ | 2217 | */ |
2217 | static void | 2218 | static void |
2218 | free_fragment_tree (struct PendingMessage *root) | 2219 | free_fragment_tree (struct PendingMessage *root) |
2219 | { | 2220 | { |
@@ -2328,7 +2329,7 @@ check_queue_timeouts (void *cls) | |||
2328 | GNUNET_NO); | 2329 | GNUNET_NO); |
2329 | client_send_response (pm, | 2330 | client_send_response (pm, |
2330 | GNUNET_NO, | 2331 | GNUNET_NO, |
2331 | 0); | 2332 | 0); |
2332 | continue; | 2333 | continue; |
2333 | } | 2334 | } |
2334 | earliest_timeout = GNUNET_TIME_absolute_min (earliest_timeout, | 2335 | earliest_timeout = GNUNET_TIME_absolute_min (earliest_timeout, |
@@ -2407,7 +2408,7 @@ handle_client_send (void *cls, | |||
2407 | target->earliest_timeout.abs_value_us = pm->timeout.abs_value_us; | 2408 | target->earliest_timeout.abs_value_us = pm->timeout.abs_value_us; |
2408 | if (NULL != target->timeout_task) | 2409 | if (NULL != target->timeout_task) |
2409 | GNUNET_SCHEDULER_cancel (target->timeout_task); | 2410 | GNUNET_SCHEDULER_cancel (target->timeout_task); |
2410 | target->timeout_task | 2411 | target->timeout_task |
2411 | = GNUNET_SCHEDULER_add_at (target->earliest_timeout, | 2412 | = GNUNET_SCHEDULER_add_at (target->earliest_timeout, |
2412 | &check_queue_timeouts, | 2413 | &check_queue_timeouts, |
2413 | target); | 2414 | target); |
@@ -2542,7 +2543,7 @@ expire_ephemerals (void *cls) | |||
2542 | * one, cache it and return it. | 2543 | * one, cache it and return it. |
2543 | * | 2544 | * |
2544 | * @param pid peer to look up ephemeral for | 2545 | * @param pid peer to look up ephemeral for |
2545 | * @param private_key[out] set to the private key | 2546 | * @param private_key[out] set to the private key |
2546 | * @param ephemeral_key[out] set to the key | 2547 | * @param ephemeral_key[out] set to the key |
2547 | * @param ephemeral_sender_sig[out] set to the signature | 2548 | * @param ephemeral_sender_sig[out] set to the signature |
2548 | * @param ephemeral_validity[out] set to the validity expiration time | 2549 | * @param ephemeral_validity[out] set to the validity expiration time |
@@ -2556,7 +2557,7 @@ lookup_ephemeral (const struct GNUNET_PeerIdentity *pid, | |||
2556 | { | 2557 | { |
2557 | struct EphemeralCacheEntry *ece; | 2558 | struct EphemeralCacheEntry *ece; |
2558 | struct EphemeralConfirmation ec; | 2559 | struct EphemeralConfirmation ec; |
2559 | 2560 | ||
2560 | ece = GNUNET_CONTAINER_multipeermap_get (ephemeral_map, | 2561 | ece = GNUNET_CONTAINER_multipeermap_get (ephemeral_map, |
2561 | pid); | 2562 | pid); |
2562 | if ( (NULL != ece) && | 2563 | if ( (NULL != ece) && |
@@ -2618,7 +2619,7 @@ route_message (const struct GNUNET_PeerIdentity *target, | |||
2618 | GNUNET_free (hdr); | 2619 | GNUNET_free (hdr); |
2619 | } | 2620 | } |
2620 | 2621 | ||
2621 | 2622 | ||
2622 | /** | 2623 | /** |
2623 | * Communicator requests backchannel transmission. Process the request. | 2624 | * Communicator requests backchannel transmission. Process the request. |
2624 | * | 2625 | * |
@@ -2636,7 +2637,7 @@ handle_communicator_backchannel (void *cls, | |||
2636 | struct TransportBackchannelRequestPayload ppay; | 2637 | struct TransportBackchannelRequestPayload ppay; |
2637 | char *mpos; | 2638 | char *mpos; |
2638 | uint16_t msize; | 2639 | uint16_t msize; |
2639 | 2640 | ||
2640 | /* encapsulate and encrypt message */ | 2641 | /* encapsulate and encrypt message */ |
2641 | msize = ntohs (cb->header.size) - sizeof (*cb) + sizeof (struct TransportBackchannelRequestPayload); | 2642 | msize = ntohs (cb->header.size) - sizeof (*cb) + sizeof (struct TransportBackchannelRequestPayload); |
2642 | enc = GNUNET_malloc (sizeof (*enc) + msize); | 2643 | enc = GNUNET_malloc (sizeof (*enc) + msize); |
@@ -2871,7 +2872,7 @@ struct CommunicatorMessageContext | |||
2871 | * | 2872 | * |
2872 | * @param cmc context for demultiplexing | 2873 | * @param cmc context for demultiplexing |
2873 | * @param msg message to demultiplex | 2874 | * @param msg message to demultiplex |
2874 | */ | 2875 | */ |
2875 | static void | 2876 | static void |
2876 | demultiplex_with_cmc (struct CommunicatorMessageContext *cmc, | 2877 | demultiplex_with_cmc (struct CommunicatorMessageContext *cmc, |
2877 | const struct GNUNET_MessageHeader *msg); | 2878 | const struct GNUNET_MessageHeader *msg); |
@@ -2949,7 +2950,7 @@ handle_raw_message (void *cls, | |||
2949 | env); | 2950 | env); |
2950 | } | 2951 | } |
2951 | /* FIXME: consider doing this _only_ once the message | 2952 | /* FIXME: consider doing this _only_ once the message |
2952 | was drained from the CORE MQs to extend flow control to CORE! | 2953 | was drained from the CORE MQs to extend flow control to CORE! |
2953 | (basically, increment counter in cmc, decrement on MQ send continuation! */ | 2954 | (basically, increment counter in cmc, decrement on MQ send continuation! */ |
2954 | finish_cmc_handling (cmc); | 2955 | finish_cmc_handling (cmc); |
2955 | } | 2956 | } |
@@ -2974,12 +2975,12 @@ check_fragment_box (void *cls, | |||
2974 | GNUNET_break_op (0); | 2975 | GNUNET_break_op (0); |
2975 | return GNUNET_SYSERR; | 2976 | return GNUNET_SYSERR; |
2976 | } | 2977 | } |
2977 | if (bsize + ntohs (fb->frag_off) > ntohs (fb->msg_size)) | 2978 | if (bsize + ntohs (fb->frag_off) > ntohs (fb->msg_size)) |
2978 | { | 2979 | { |
2979 | GNUNET_break_op (0); | 2980 | GNUNET_break_op (0); |
2980 | return GNUNET_SYSERR; | 2981 | return GNUNET_SYSERR; |
2981 | } | 2982 | } |
2982 | if (ntohs (fb->frag_off) >= ntohs (fb->msg_size)) | 2983 | if (ntohs (fb->frag_off) >= ntohs (fb->msg_size)) |
2983 | { | 2984 | { |
2984 | GNUNET_break_op (0); | 2985 | GNUNET_break_op (0); |
2985 | return GNUNET_SYSERR; | 2986 | return GNUNET_SYSERR; |
@@ -3046,7 +3047,7 @@ handle_fragment_box (void *cls, | |||
3046 | if (NULL == n) | 3047 | if (NULL == n) |
3047 | { | 3048 | { |
3048 | struct GNUNET_SERVICE_Client *client = cmc->tc->client; | 3049 | struct GNUNET_SERVICE_Client *client = cmc->tc->client; |
3049 | 3050 | ||
3050 | GNUNET_break (0); | 3051 | GNUNET_break (0); |
3051 | finish_cmc_handling (cmc); | 3052 | finish_cmc_handling (cmc); |
3052 | GNUNET_SERVICE_client_drop (client); | 3053 | GNUNET_SERVICE_client_drop (client); |
@@ -3096,7 +3097,7 @@ handle_fragment_box (void *cls, | |||
3096 | finish_cmc_handling (cmc); | 3097 | finish_cmc_handling (cmc); |
3097 | return; | 3098 | return; |
3098 | } | 3099 | } |
3099 | 3100 | ||
3100 | /* reassemble */ | 3101 | /* reassemble */ |
3101 | fsize = ntohs (fb->header.size) - sizeof (*fb); | 3102 | fsize = ntohs (fb->header.size) - sizeof (*fb); |
3102 | frag_off = ntohs (fb->frag_off); | 3103 | frag_off = ntohs (fb->frag_off); |
@@ -3112,7 +3113,7 @@ handle_fragment_box (void *cls, | |||
3112 | rc->msg_missing--; | 3113 | rc->msg_missing--; |
3113 | } | 3114 | } |
3114 | } | 3115 | } |
3115 | 3116 | ||
3116 | /* Compute cummulative ACK */ | 3117 | /* Compute cummulative ACK */ |
3117 | frag_uuid = ntohl (fb->frag_uuid); | 3118 | frag_uuid = ntohl (fb->frag_uuid); |
3118 | cdelay = GNUNET_TIME_absolute_get_duration (rc->last_frag); | 3119 | cdelay = GNUNET_TIME_absolute_get_duration (rc->last_frag); |
@@ -3151,7 +3152,7 @@ handle_fragment_box (void *cls, | |||
3151 | ( (rc->frag_uuid < frag_uuid + 64) && | 3152 | ( (rc->frag_uuid < frag_uuid + 64) && |
3152 | (rc->extra_acks == (rc->extra_acks & ~ ((1LLU << (64 - (rc->frag_uuid - frag_uuid))) - 1LLU))) ) ) ) | 3153 | (rc->extra_acks == (rc->extra_acks & ~ ((1LLU << (64 - (rc->frag_uuid - frag_uuid))) - 1LLU))) ) ) ) |
3153 | { | 3154 | { |
3154 | /* can fit ack by shifting extra acks and starting at | 3155 | /* can fit ack by shifting extra acks and starting at |
3155 | frag_uid, test above esured that the bits we will | 3156 | frag_uid, test above esured that the bits we will |
3156 | shift 'extra_acks' by are all zero. */ | 3157 | shift 'extra_acks' by are all zero. */ |
3157 | rc->extra_acks <<= (rc->frag_uuid - frag_uuid); | 3158 | rc->extra_acks <<= (rc->frag_uuid - frag_uuid); |
@@ -3162,8 +3163,8 @@ handle_fragment_box (void *cls, | |||
3162 | if (65 == rc->num_acks) /* FIXME: maybe use smaller threshold? This is very aggressive. */ | 3163 | if (65 == rc->num_acks) /* FIXME: maybe use smaller threshold? This is very aggressive. */ |
3163 | ack_now = GNUNET_YES; /* maximum acks received */ | 3164 | ack_now = GNUNET_YES; /* maximum acks received */ |
3164 | // FIXME: possibly also ACK based on RTT (but for that we'd need to | 3165 | // FIXME: possibly also ACK based on RTT (but for that we'd need to |
3165 | // determine the session used for the ACK first!) | 3166 | // determine the session used for the ACK first!) |
3166 | 3167 | ||
3167 | /* is reassembly complete? */ | 3168 | /* is reassembly complete? */ |
3168 | if (0 != rc->msg_missing) | 3169 | if (0 != rc->msg_missing) |
3169 | { | 3170 | { |
@@ -3187,7 +3188,7 @@ handle_fragment_box (void *cls, | |||
3187 | msg); | 3188 | msg); |
3188 | /* FIXME: really free here? Might be bad if fragments are still | 3189 | /* FIXME: really free here? Might be bad if fragments are still |
3189 | en-route and we forget that we finished this reassembly immediately! | 3190 | en-route and we forget that we finished this reassembly immediately! |
3190 | -> keep around until timeout? | 3191 | -> keep around until timeout? |
3191 | -> shorten timeout based on ACK? */ | 3192 | -> shorten timeout based on ACK? */ |
3192 | free_reassembly_context (rc); | 3193 | free_reassembly_context (rc); |
3193 | } | 3194 | } |
@@ -3204,7 +3205,7 @@ handle_fragment_ack (void *cls, | |||
3204 | const struct TransportFragmentAckMessage *fa) | 3205 | const struct TransportFragmentAckMessage *fa) |
3205 | { | 3206 | { |
3206 | struct CommunicatorMessageContext *cmc = cls; | 3207 | struct CommunicatorMessageContext *cmc = cls; |
3207 | 3208 | ||
3208 | // FIXME: do work: identify original message; then identify fragments being acked; | 3209 | // FIXME: do work: identify original message; then identify fragments being acked; |
3209 | // remove those from the tree to prevent retransmission; | 3210 | // remove those from the tree to prevent retransmission; |
3210 | // compute RTT | 3211 | // compute RTT |
@@ -3248,10 +3249,10 @@ handle_reliability_box (void *cls, | |||
3248 | 3249 | ||
3249 | /* FIXME: implement cummulative ACKs and ack_countdown, | 3250 | /* FIXME: implement cummulative ACKs and ack_countdown, |
3250 | then setting the avg_ack_delay field below: */ | 3251 | then setting the avg_ack_delay field below: */ |
3251 | ack = GNUNET_malloc (sizeof (*ack) + | 3252 | ack = GNUNET_malloc (sizeof (*ack) + |
3252 | sizeof (struct GNUNET_ShortHashCode)); | 3253 | sizeof (struct GNUNET_ShortHashCode)); |
3253 | ack->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_RELIABILITY_ACK); | 3254 | ack->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_RELIABILITY_ACK); |
3254 | ack->header.size = htons (sizeof (*ack) + | 3255 | ack->header.size = htons (sizeof (*ack) + |
3255 | sizeof (struct GNUNET_ShortHashCode)); | 3256 | sizeof (struct GNUNET_ShortHashCode)); |
3256 | memcpy (&ack[1], | 3257 | memcpy (&ack[1], |
3257 | &rb->msg_uuid, | 3258 | &rb->msg_uuid, |
@@ -3276,7 +3277,7 @@ handle_reliability_ack (void *cls, | |||
3276 | const struct TransportReliabilityAckMessage *ra) | 3277 | const struct TransportReliabilityAckMessage *ra) |
3277 | { | 3278 | { |
3278 | struct CommunicatorMessageContext *cmc = cls; | 3279 | struct CommunicatorMessageContext *cmc = cls; |
3279 | 3280 | ||
3280 | // FIXME: do work: find message that was acknowledged, and | 3281 | // FIXME: do work: find message that was acknowledged, and |
3281 | // remove from transmission queue; update RTT. | 3282 | // remove from transmission queue; update RTT. |
3282 | finish_cmc_handling (cmc); | 3283 | finish_cmc_handling (cmc); |
@@ -3331,7 +3332,7 @@ handle_backchannel_encapsulation (void *cls, | |||
3331 | // FIXME: check HMAC | 3332 | // FIXME: check HMAC |
3332 | // FIXME: decrypt payload | 3333 | // FIXME: decrypt payload |
3333 | // FIXME: forward to specified communicator! | 3334 | // FIXME: forward to specified communicator! |
3334 | // (using GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL_INCOMING) | 3335 | // (using GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL_INCOMING) |
3335 | finish_cmc_handling (cmc); | 3336 | finish_cmc_handling (cmc); |
3336 | } | 3337 | } |
3337 | 3338 | ||
@@ -3388,7 +3389,7 @@ handle_dv_learn (void *cls, | |||
3388 | const struct TransportDVLearn *dvl) | 3389 | const struct TransportDVLearn *dvl) |
3389 | { | 3390 | { |
3390 | struct CommunicatorMessageContext *cmc = cls; | 3391 | struct CommunicatorMessageContext *cmc = cls; |
3391 | 3392 | ||
3392 | // FIXME: learn path from DV message (if bi-directional flags are set) | 3393 | // FIXME: learn path from DV message (if bi-directional flags are set) |
3393 | // FIXME: expand DV message, forward on (unless path is getting too long) | 3394 | // FIXME: expand DV message, forward on (unless path is getting too long) |
3394 | finish_cmc_handling (cmc); | 3395 | finish_cmc_handling (cmc); |
@@ -3419,7 +3420,7 @@ check_dv_box (void *cls, | |||
3419 | return GNUNET_SYSERR; | 3420 | return GNUNET_SYSERR; |
3420 | } | 3421 | } |
3421 | isize = ntohs (inbox->size); | 3422 | isize = ntohs (inbox->size); |
3422 | if (size != sizeof (*dvb) + num_hops * sizeof (struct GNUNET_PeerIdentity) + isize) | 3423 | if (size != sizeof (*dvb) + num_hops * sizeof (struct GNUNET_PeerIdentity) + isize) |
3423 | { | 3424 | { |
3424 | GNUNET_break_op (0); | 3425 | GNUNET_break_op (0); |
3425 | return GNUNET_SYSERR; | 3426 | return GNUNET_SYSERR; |
@@ -3455,14 +3456,14 @@ handle_dv_box (void *cls, | |||
3455 | { | 3456 | { |
3456 | // FIXME: if we are not the target, shorten path and forward along. | 3457 | // FIXME: if we are not the target, shorten path and forward along. |
3457 | // Try from the _end_ of hops array if we know the given | 3458 | // Try from the _end_ of hops array if we know the given |
3458 | // neighbour (shortening the path!). | 3459 | // neighbour (shortening the path!). |
3459 | // NOTE: increment total_hops! | 3460 | // NOTE: increment total_hops! |
3460 | finish_cmc_handling (cmc); | 3461 | finish_cmc_handling (cmc); |
3461 | return; | 3462 | return; |
3462 | } | 3463 | } |
3463 | /* We are the target. Unbox and handle message. */ | 3464 | /* We are the target. Unbox and handle message. */ |
3464 | cmc->im.sender = dvb->origin; | 3465 | cmc->im.sender = dvb->origin; |
3465 | cmc->total_hops = ntohs (dvb->total_hops); | 3466 | cmc->total_hops = ntohs (dvb->total_hops); |
3466 | demultiplex_with_cmc (cmc, | 3467 | demultiplex_with_cmc (cmc, |
3467 | inbox); | 3468 | inbox); |
3468 | } | 3469 | } |
@@ -3516,7 +3517,7 @@ handle_incoming_msg (void *cls, | |||
3516 | * | 3517 | * |
3517 | * @param cmc context for demultiplexing | 3518 | * @param cmc context for demultiplexing |
3518 | * @param msg message to demultiplex | 3519 | * @param msg message to demultiplex |
3519 | */ | 3520 | */ |
3520 | static void | 3521 | static void |
3521 | demultiplex_with_cmc (struct CommunicatorMessageContext *cmc, | 3522 | demultiplex_with_cmc (struct CommunicatorMessageContext *cmc, |
3522 | const struct GNUNET_MessageHeader *msg) | 3523 | const struct GNUNET_MessageHeader *msg) |
@@ -3606,7 +3607,7 @@ tracker_update_in_cb (void *cls) | |||
3606 | struct GNUNET_ATS_Session *queue = cls; | 3607 | struct GNUNET_ATS_Session *queue = cls; |
3607 | struct GNUNET_TIME_Relative in_delay; | 3608 | struct GNUNET_TIME_Relative in_delay; |
3608 | unsigned int rsize; | 3609 | unsigned int rsize; |
3609 | 3610 | ||
3610 | rsize = (0 == queue->mtu) ? IN_PACKET_SIZE_WITHOUT_MTU : queue->mtu; | 3611 | rsize = (0 == queue->mtu) ? IN_PACKET_SIZE_WITHOUT_MTU : queue->mtu; |
3611 | in_delay = GNUNET_BANDWIDTH_tracker_get_delay (&queue->tracker_in, | 3612 | in_delay = GNUNET_BANDWIDTH_tracker_get_delay (&queue->tracker_in, |
3612 | rsize); | 3613 | rsize); |
@@ -3632,7 +3633,7 @@ set_pending_message_uuid (struct PendingMessage *pm) | |||
3632 | 3633 | ||
3633 | 3634 | ||
3634 | /** | 3635 | /** |
3635 | * Fragment the given @a pm to the given @a mtu. Adds | 3636 | * Fragment the given @a pm to the given @a mtu. Adds |
3636 | * additional fragments to the neighbour as well. If the | 3637 | * additional fragments to the neighbour as well. If the |
3637 | * @a mtu is too small, generates and error for the @a pm | 3638 | * @a mtu is too small, generates and error for the @a pm |
3638 | * and returns NULL. | 3639 | * and returns NULL. |
@@ -3648,7 +3649,7 @@ fragment_message (struct PendingMessage *pm, | |||
3648 | struct PendingMessage *ff; | 3649 | struct PendingMessage *ff; |
3649 | 3650 | ||
3650 | set_pending_message_uuid (pm); | 3651 | set_pending_message_uuid (pm); |
3651 | 3652 | ||
3652 | /* This invariant is established in #handle_add_queue_message() */ | 3653 | /* This invariant is established in #handle_add_queue_message() */ |
3653 | GNUNET_assert (mtu > sizeof (struct TransportFragmentBox)); | 3654 | GNUNET_assert (mtu > sizeof (struct TransportFragmentBox)); |
3654 | 3655 | ||
@@ -3756,7 +3757,7 @@ reliability_box_message (struct PendingMessage *pm) | |||
3756 | if (NULL != pm->bpm) | 3757 | if (NULL != pm->bpm) |
3757 | return pm->bpm; /* already computed earlier: do nothing */ | 3758 | return pm->bpm; /* already computed earlier: do nothing */ |
3758 | GNUNET_assert (NULL == pm->head_frag); | 3759 | GNUNET_assert (NULL == pm->head_frag); |
3759 | if (pm->bytes_msg + sizeof (rbox) > UINT16_MAX) | 3760 | if (pm->bytes_msg + sizeof (rbox) > UINT16_MAX) |
3760 | { | 3761 | { |
3761 | /* failed hard */ | 3762 | /* failed hard */ |
3762 | GNUNET_break (0); | 3763 | GNUNET_break (0); |
@@ -3766,7 +3767,7 @@ reliability_box_message (struct PendingMessage *pm) | |||
3766 | return NULL; | 3767 | return NULL; |
3767 | } | 3768 | } |
3768 | bpm = GNUNET_malloc (sizeof (struct PendingMessage) + | 3769 | bpm = GNUNET_malloc (sizeof (struct PendingMessage) + |
3769 | sizeof (rbox) + | 3770 | sizeof (rbox) + |
3770 | pm->bytes_msg); | 3771 | pm->bytes_msg); |
3771 | bpm->target = pm->target; | 3772 | bpm->target = pm->target; |
3772 | bpm->frag_parent = pm; | 3773 | bpm->frag_parent = pm; |
@@ -3796,12 +3797,12 @@ reliability_box_message (struct PendingMessage *pm) | |||
3796 | 3797 | ||
3797 | /** | 3798 | /** |
3798 | * We believe we are ready to transmit a message on a queue. Double-checks | 3799 | * We believe we are ready to transmit a message on a queue. Double-checks |
3799 | * with the queue's "tracker_out" and then gives the message to the | 3800 | * with the queue's "tracker_out" and then gives the message to the |
3800 | * communicator for transmission (updating the tracker, and re-scheduling | 3801 | * communicator for transmission (updating the tracker, and re-scheduling |
3801 | * itself if applicable). | 3802 | * itself if applicable). |
3802 | * | 3803 | * |
3803 | * @param cls the `struct GNUNET_ATS_Session` to process transmissions for | 3804 | * @param cls the `struct GNUNET_ATS_Session` to process transmissions for |
3804 | */ | 3805 | */ |
3805 | static void | 3806 | static void |
3806 | transmit_on_queue (void *cls) | 3807 | transmit_on_queue (void *cls) |
3807 | { | 3808 | { |
@@ -3818,7 +3819,7 @@ transmit_on_queue (void *cls) | |||
3818 | if (NULL == (pm = n->pending_msg_head)) | 3819 | if (NULL == (pm = n->pending_msg_head)) |
3819 | { | 3820 | { |
3820 | /* no message pending, nothing to do here! */ | 3821 | /* no message pending, nothing to do here! */ |
3821 | return; | 3822 | return; |
3822 | } | 3823 | } |
3823 | schedule_transmit_on_queue (queue); | 3824 | schedule_transmit_on_queue (queue); |
3824 | if (NULL != queue->transmit_task) | 3825 | if (NULL != queue->transmit_task) |
@@ -3874,7 +3875,7 @@ transmit_on_queue (void *cls) | |||
3874 | queue->tc->details.communicator.total_queue_length++; | 3875 | queue->tc->details.communicator.total_queue_length++; |
3875 | GNUNET_MQ_send (queue->tc->mq, | 3876 | GNUNET_MQ_send (queue->tc->mq, |
3876 | env); | 3877 | env); |
3877 | 3878 | ||
3878 | // FIXME: do something similar to the logic below | 3879 | // FIXME: do something similar to the logic below |
3879 | // in defragmentation / reliability ACK handling! | 3880 | // in defragmentation / reliability ACK handling! |
3880 | 3881 | ||
@@ -3892,7 +3893,7 @@ transmit_on_queue (void *cls) | |||
3892 | (PMT_FRAGMENT_BOX == s->pmt) ) | 3893 | (PMT_FRAGMENT_BOX == s->pmt) ) |
3893 | { | 3894 | { |
3894 | struct PendingMessage *pos; | 3895 | struct PendingMessage *pos; |
3895 | 3896 | ||
3896 | /* Fragment sent over reliabile channel */ | 3897 | /* Fragment sent over reliabile channel */ |
3897 | free_fragment_tree (s); | 3898 | free_fragment_tree (s); |
3898 | pos = s->frag_parent; | 3899 | pos = s->frag_parent; |
@@ -3912,9 +3913,9 @@ transmit_on_queue (void *cls) | |||
3912 | pos->head_frag, | 3913 | pos->head_frag, |
3913 | pos->tail_frag, | 3914 | pos->tail_frag, |
3914 | s); | 3915 | s); |
3915 | GNUNET_free (s); | 3916 | GNUNET_free (s); |
3916 | } | 3917 | } |
3917 | 3918 | ||
3918 | /* Was this the last applicable fragmment? */ | 3919 | /* Was this the last applicable fragmment? */ |
3919 | if ( (NULL == pm->head_frag) && | 3920 | if ( (NULL == pm->head_frag) && |
3920 | (pm->frag_off == pm->bytes_msg) ) | 3921 | (pm->frag_off == pm->bytes_msg) ) |
@@ -3981,7 +3982,7 @@ transmit_on_queue (void *cls) | |||
3981 | s); | 3982 | s); |
3982 | } | 3983 | } |
3983 | } | 3984 | } |
3984 | 3985 | ||
3985 | /* finally, re-schedule queue transmission task itself */ | 3986 | /* finally, re-schedule queue transmission task itself */ |
3986 | schedule_transmit_on_queue (queue); | 3987 | schedule_transmit_on_queue (queue); |
3987 | } | 3988 | } |
@@ -4023,13 +4024,13 @@ tracker_excess_out_cb (void *cls) | |||
4023 | { | 4024 | { |
4024 | /* FIXME: trigger excess bandwidth report to core? Right now, | 4025 | /* FIXME: trigger excess bandwidth report to core? Right now, |
4025 | this is done internally within transport_api2_core already, | 4026 | this is done internally within transport_api2_core already, |
4026 | but we probably want to change the logic and trigger it | 4027 | but we probably want to change the logic and trigger it |
4027 | from here via a message instead! */ | 4028 | from here via a message instead! */ |
4028 | /* TODO: maybe inform ATS at this point? */ | 4029 | /* TODO: maybe inform ATS at this point? */ |
4029 | GNUNET_STATISTICS_update (GST_stats, | 4030 | GNUNET_STATISTICS_update (GST_stats, |
4030 | "# Excess outbound bandwidth reported", | 4031 | "# Excess outbound bandwidth reported", |
4031 | 1, | 4032 | 1, |
4032 | GNUNET_NO); | 4033 | GNUNET_NO); |
4033 | } | 4034 | } |
4034 | 4035 | ||
4035 | 4036 | ||
@@ -4047,7 +4048,7 @@ tracker_excess_in_cb (void *cls) | |||
4047 | GNUNET_STATISTICS_update (GST_stats, | 4048 | GNUNET_STATISTICS_update (GST_stats, |
4048 | "# Excess inbound bandwidth reported", | 4049 | "# Excess inbound bandwidth reported", |
4049 | 1, | 4050 | 1, |
4050 | GNUNET_NO); | 4051 | GNUNET_NO); |
4051 | } | 4052 | } |
4052 | 4053 | ||
4053 | 4054 | ||
@@ -4126,7 +4127,7 @@ handle_add_queue_message (void *cls, | |||
4126 | .nt = queue->nt, | 4127 | .nt = queue->nt, |
4127 | .cc = tc->details.communicator.cc | 4128 | .cc = tc->details.communicator.cc |
4128 | }; | 4129 | }; |
4129 | 4130 | ||
4130 | queue->sr = GNUNET_ATS_session_add (ats, | 4131 | queue->sr = GNUNET_ATS_session_add (ats, |
4131 | &neighbour->pid, | 4132 | &neighbour->pid, |
4132 | queue->address, | 4133 | queue->address, |
@@ -4224,7 +4225,7 @@ handle_send_message_ack (void *cls, | |||
4224 | { | 4225 | { |
4225 | struct TransportClient *tc = cls; | 4226 | struct TransportClient *tc = cls; |
4226 | struct QueueEntry *queue; | 4227 | struct QueueEntry *queue; |
4227 | 4228 | ||
4228 | if (CT_COMMUNICATOR != tc->type) | 4229 | if (CT_COMMUNICATOR != tc->type) |
4229 | { | 4230 | { |
4230 | GNUNET_break (0); | 4231 | GNUNET_break (0); |
@@ -4251,12 +4252,12 @@ handle_send_message_ack (void *cls, | |||
4251 | queue = qe; | 4252 | queue = qe; |
4252 | break; | 4253 | break; |
4253 | } | 4254 | } |
4254 | break; | 4255 | break; |
4255 | } | 4256 | } |
4256 | if (NULL == queue) | 4257 | if (NULL == queue) |
4257 | { | 4258 | { |
4258 | /* this should never happen */ | 4259 | /* this should never happen */ |
4259 | GNUNET_break (0); | 4260 | GNUNET_break (0); |
4260 | GNUNET_SERVICE_client_drop (tc->client); | 4261 | GNUNET_SERVICE_client_drop (tc->client); |
4261 | return; | 4262 | return; |
4262 | } | 4263 | } |
@@ -4286,10 +4287,10 @@ handle_send_message_ack (void *cls, | |||
4286 | GNUNET_STATISTICS_update (GST_stats, | 4287 | GNUNET_STATISTICS_update (GST_stats, |
4287 | "# Transmission throttled due to session queue limit", | 4288 | "# Transmission throttled due to session queue limit", |
4288 | -1, | 4289 | -1, |
4289 | GNUNET_NO); | 4290 | GNUNET_NO); |
4290 | schedule_transmit_on_queue (queue->session); | 4291 | schedule_transmit_on_queue (queue->session); |
4291 | } | 4292 | } |
4292 | 4293 | ||
4293 | /* TODO: we also should react on the status! */ | 4294 | /* TODO: we also should react on the status! */ |
4294 | // FIXME: this probably requires queue->pm = s assignment! | 4295 | // FIXME: this probably requires queue->pm = s assignment! |
4295 | // FIXME: react to communicator status about transmission request. We got: | 4296 | // FIXME: react to communicator status about transmission request. We got: |
@@ -4452,7 +4453,7 @@ ats_suggestion_cb (void *cls, | |||
4452 | GNUNET_STATISTICS_update (GST_stats, | 4453 | GNUNET_STATISTICS_update (GST_stats, |
4453 | "# ATS suggestions ignored due to missing communicator", | 4454 | "# ATS suggestions ignored due to missing communicator", |
4454 | 1, | 4455 | 1, |
4455 | GNUNET_NO); | 4456 | GNUNET_NO); |
4456 | return; | 4457 | return; |
4457 | } | 4458 | } |
4458 | /* forward suggestion for queue creation to communicator */ | 4459 | /* forward suggestion for queue creation to communicator */ |
@@ -4481,7 +4482,7 @@ ats_suggestion_cb (void *cls, | |||
4481 | * | 4482 | * |
4482 | * @param cls the `struct TransportClient` | 4483 | * @param cls the `struct TransportClient` |
4483 | * @param cqr confirmation message | 4484 | * @param cqr confirmation message |
4484 | */ | 4485 | */ |
4485 | static void | 4486 | static void |
4486 | handle_queue_create_ok (void *cls, | 4487 | handle_queue_create_ok (void *cls, |
4487 | const struct GNUNET_TRANSPORT_CreateQueueResponse *cqr) | 4488 | const struct GNUNET_TRANSPORT_CreateQueueResponse *cqr) |
@@ -4501,7 +4502,7 @@ handle_queue_create_ok (void *cls, | |||
4501 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 4502 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
4502 | "Request #%u for communicator to create queue succeeded\n", | 4503 | "Request #%u for communicator to create queue succeeded\n", |
4503 | (unsigned int) ntohs (cqr->request_id)); | 4504 | (unsigned int) ntohs (cqr->request_id)); |
4504 | GNUNET_SERVICE_client_continue (tc->client); | 4505 | GNUNET_SERVICE_client_continue (tc->client); |
4505 | } | 4506 | } |
4506 | 4507 | ||
4507 | 4508 | ||
@@ -4512,7 +4513,7 @@ handle_queue_create_ok (void *cls, | |||
4512 | * | 4513 | * |
4513 | * @param cls the `struct TransportClient` | 4514 | * @param cls the `struct TransportClient` |
4514 | * @param cqr failure message | 4515 | * @param cqr failure message |
4515 | */ | 4516 | */ |
4516 | static void | 4517 | static void |
4517 | handle_queue_create_fail (void *cls, | 4518 | handle_queue_create_fail (void *cls, |
4518 | const struct GNUNET_TRANSPORT_CreateQueueResponse *cqr) | 4519 | const struct GNUNET_TRANSPORT_CreateQueueResponse *cqr) |
@@ -4532,7 +4533,61 @@ handle_queue_create_fail (void *cls, | |||
4532 | "# ATS suggestions failed in queue creation at communicator", | 4533 | "# ATS suggestions failed in queue creation at communicator", |
4533 | 1, | 4534 | 1, |
4534 | GNUNET_NO); | 4535 | GNUNET_NO); |
4535 | GNUNET_SERVICE_client_continue (tc->client); | 4536 | GNUNET_SERVICE_client_continue (tc->client); |
4537 | } | ||
4538 | |||
4539 | |||
4540 | /** | ||
4541 | * Check #GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_CONSIDER_VERIFY | ||
4542 | * messages. We do nothing here, real verification is done later. | ||
4543 | * | ||
4544 | * @param cls a `struct TransportClient *` | ||
4545 | * @param msg message to verify | ||
4546 | * @return #GNUNET_OK | ||
4547 | */ | ||
4548 | static int | ||
4549 | check_address_consider_verify (void *cls, | ||
4550 | const struct GNUNET_TRANSPORT_AddressToVerify *hdr) | ||
4551 | { | ||
4552 | (void) cls; | ||
4553 | (void) hdr; | ||
4554 | return GNUNET_OK; | ||
4555 | } | ||
4556 | |||
4557 | |||
4558 | /** | ||
4559 | * Given another peers address, consider checking it for validity | ||
4560 | * and then adding it to the Peerstore. | ||
4561 | * | ||
4562 | * @param cls a `struct TransportClient` | ||
4563 | * @param hdr message containing the raw address data and | ||
4564 | * signature in the body, see #GNUNET_HELLO_extract_address() | ||
4565 | */ | ||
4566 | static void | ||
4567 | handle_address_consider_verify (void *cls, | ||
4568 | const struct GNUNET_TRANSPORT_AddressToVerify *hdr) | ||
4569 | { | ||
4570 | char *address; | ||
4571 | enum GNUNET_NetworkType nt; | ||
4572 | struct GNUNET_TIME_Absolute expiration; | ||
4573 | |||
4574 | (void) cls; | ||
4575 | // FIXME: pre-check: do we know this address already? | ||
4576 | // FIXME: pre-check: rate-limit signature verification / validation! | ||
4577 | address = GNUNET_HELLO_extract_address (&hdr[1], | ||
4578 | ntohs (hdr->header.size) - sizeof (*hdr), | ||
4579 | &hdr->peer, | ||
4580 | &nt, | ||
4581 | &expiration); | ||
4582 | if (NULL == address) | ||
4583 | { | ||
4584 | GNUNET_break_op (0); | ||
4585 | return; | ||
4586 | } | ||
4587 | if (0 == GNUNET_TIME_absolute_get_remaining (expiration).rel_value_us) | ||
4588 | return; /* expired */ | ||
4589 | // FIXME: do begin actual verification here! | ||
4590 | GNUNET_free (address); | ||
4536 | } | 4591 | } |
4537 | 4592 | ||
4538 | 4593 | ||
@@ -4775,6 +4830,10 @@ GNUNET_SERVICE_MAIN | |||
4775 | GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_SETUP, | 4830 | GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_SETUP, |
4776 | struct GNUNET_TRANSPORT_AddQueueMessage, | 4831 | struct GNUNET_TRANSPORT_AddQueueMessage, |
4777 | NULL), | 4832 | NULL), |
4833 | GNUNET_MQ_hd_var_size (address_consider_verify, | ||
4834 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_CONSIDER_VERIFY, | ||
4835 | struct GNUNET_TRANSPORT_AddressToVerify, | ||
4836 | NULL), | ||
4778 | GNUNET_MQ_hd_fixed_size (del_queue_message, | 4837 | GNUNET_MQ_hd_fixed_size (del_queue_message, |
4779 | GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_TEARDOWN, | 4838 | GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_TEARDOWN, |
4780 | struct GNUNET_TRANSPORT_DelQueueMessage, | 4839 | struct GNUNET_TRANSPORT_DelQueueMessage, |