diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-02-13 19:42:57 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-02-13 19:42:57 +0100 |
commit | 94911c3e57d5f77ddf68032789244d0475955149 (patch) | |
tree | 3fe8afa2df331547e613b27926cd6dd2eeaa9b59 /src | |
parent | a4475afe1ad535c898bb0be7f30d2d3eff14dddf (diff) | |
download | gnunet-94911c3e57d5f77ddf68032789244d0475955149.tar.gz gnunet-94911c3e57d5f77ddf68032789244d0475955149.zip |
add handle_address_consider_verify skeleton
Diffstat (limited to 'src')
-rw-r--r-- | src/include/gnunet_hello_lib.h | 2 | ||||
-rw-r--r-- | src/include/gnunet_transport_address_service.h | 2 | ||||
-rw-r--r-- | src/transport/gnunet-service-tng.c | 349 | ||||
-rw-r--r-- | src/transport/transport.h | 26 | ||||
-rw-r--r-- | src/transport/transport_api2_address.c | 5 |
5 files changed, 237 insertions, 147 deletions
diff --git a/src/include/gnunet_hello_lib.h b/src/include/gnunet_hello_lib.h index c2256fd0a..fcd422701 100644 --- a/src/include/gnunet_hello_lib.h +++ b/src/include/gnunet_hello_lib.h | |||
@@ -526,7 +526,7 @@ GNUNET_HELLO_extract_address (const void *raw, | |||
526 | * | 526 | * |
527 | * @param address a peer's address | 527 | * @param address a peer's address |
528 | * @return NULL if the address is mal-formed, otherwise the prefix | 528 | * @return NULL if the address is mal-formed, otherwise the prefix |
529 | */ | 529 | */ |
530 | char * | 530 | char * |
531 | GNUNET_HELLO_address_to_prefix (const char *address); | 531 | GNUNET_HELLO_address_to_prefix (const char *address); |
532 | 532 | ||
diff --git a/src/include/gnunet_transport_address_service.h b/src/include/gnunet_transport_address_service.h index afd065d66..9f0717d00 100644 --- a/src/include/gnunet_transport_address_service.h +++ b/src/include/gnunet_transport_address_service.h | |||
@@ -90,11 +90,13 @@ GNUNET_TRANSPORT_address_disconnect (struct GNUNET_TRANSPORT_AddressHandle *ch); | |||
90 | * lost. | 90 | * lost. |
91 | * | 91 | * |
92 | * @param ch communicator handle | 92 | * @param ch communicator handle |
93 | * @param pid peer the address is for | ||
93 | * @param raw raw address data | 94 | * @param raw raw address data |
94 | * @param raw_size number of bytes in @a raw | 95 | * @param raw_size number of bytes in @a raw |
95 | */ | 96 | */ |
96 | void | 97 | void |
97 | GNUNET_TRANSPORT_address_try (struct GNUNET_TRANSPORT_AddressHandle *ch, | 98 | GNUNET_TRANSPORT_address_try (struct GNUNET_TRANSPORT_AddressHandle *ch, |
99 | const struct GNUNET_PeerIdentity *pid, | ||
98 | const void *raw, | 100 | const void *raw, |
99 | const size_t raw_size); | 101 | const size_t raw_size); |
100 | 102 | ||
diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c index a32d1872c..1d6329c21 100644 --- a/src/transport/gnunet-service-tng.c +++ b/src/transport/gnunet-service-tng.c | |||
@@ -33,16 +33,17 @@ | |||
33 | * transport-to-transport traffic) | 33 | * transport-to-transport traffic) |
34 | * | 34 | * |
35 | * Implement next: | 35 | * Implement next: |
36 | * - ACK handling / retransmission | 36 | * - ACK handling / retransmission |
37 | * - address verification | ||
37 | * - track RTT, distance, loss, etc. | 38 | * - track RTT, distance, loss, etc. |
38 | * - DV data structures: | 39 | * - DV data structures: |
39 | * + learning | 40 | * + learning |
40 | * + forgetting | 41 | * + forgetting |
41 | * + using them! | 42 | * + using them! |
42 | * - routing of messages (using DV data structures!) | 43 | * - routing of messages (using DV data structures!) |
43 | * - handling of DV-boxed messages that need to be forwarded | 44 | * - handling of DV-boxed messages that need to be forwarded |
44 | * - backchannel message encryption & decryption | 45 | * - backchannel message encryption & decryption |
45 | * - | 46 | * - |
46 | * | 47 | * |
47 | * Easy: | 48 | * Easy: |
48 | * - use ATS bandwidth allocation callback and schedule transmissions! | 49 | * - use ATS bandwidth allocation callback and schedule transmissions! |
@@ -59,7 +60,7 @@ | |||
59 | * (requires planning at receiver, and additional MST-style demultiplex | 60 | * (requires planning at receiver, and additional MST-style demultiplex |
60 | * at receiver!) | 61 | * at receiver!) |
61 | * - could avoid copying body of message into each fragment and keep | 62 | * - could avoid copying body of message into each fragment and keep |
62 | * fragments as just pointers into the original message and only | 63 | * fragments as just pointers into the original message and only |
63 | * fully build fragments just before transmission (optimization, should | 64 | * fully build fragments just before transmission (optimization, should |
64 | * reduce CPU and memory use) | 65 | * reduce CPU and memory use) |
65 | * | 66 | * |
@@ -128,7 +129,7 @@ | |||
128 | /** | 129 | /** |
129 | * How many messages can we have pending for a given communicator | 130 | * How many messages can we have pending for a given communicator |
130 | * process before we start to throttle that communicator? | 131 | * process before we start to throttle that communicator? |
131 | * | 132 | * |
132 | * Used if a communicator might be CPU-bound and cannot handle the traffic. | 133 | * Used if a communicator might be CPU-bound and cannot handle the traffic. |
133 | */ | 134 | */ |
134 | #define COMMUNICATOR_TOTAL_QUEUE_LIMIT 512 | 135 | #define COMMUNICATOR_TOTAL_QUEUE_LIMIT 512 |
@@ -137,7 +138,7 @@ | |||
137 | * How many messages can we have pending for a given session (queue to | 138 | * How many messages can we have pending for a given session (queue to |
138 | * a particular peer via a communicator) process before we start to | 139 | * a particular peer via a communicator) process before we start to |
139 | * throttle that queue? | 140 | * throttle that queue? |
140 | * | 141 | * |
141 | * Used if ATS assigns more bandwidth to a particular transmission | 142 | * Used if ATS assigns more bandwidth to a particular transmission |
142 | * method than that transmission method can right now handle. (Yes, | 143 | * method than that transmission method can right now handle. (Yes, |
143 | * ATS should eventually notice utilization below allocation and | 144 | * ATS should eventually notice utilization below allocation and |
@@ -182,7 +183,7 @@ struct TransportBackchannelEncapsulationMessage | |||
182 | 183 | ||
183 | // FIXME: probably should add random IV here as well, | 184 | // FIXME: probably should add random IV here as well, |
184 | // especially if we re-use ephemeral keys! | 185 | // especially if we re-use ephemeral keys! |
185 | 186 | ||
186 | /** | 187 | /** |
187 | * HMAC over the ciphertext of the encrypted, variable-size | 188 | * HMAC over the ciphertext of the encrypted, variable-size |
188 | * body that follows. Verified via DH of @e target and | 189 | * body that follows. Verified via DH of @e target and |
@@ -211,8 +212,8 @@ struct EphemeralConfirmation | |||
211 | * only interpret the value as a mononic time and reject | 212 | * only interpret the value as a mononic time and reject |
212 | * "older" values than the last one observed. Even with this, | 213 | * "older" values than the last one observed. Even with this, |
213 | * there is no real guarantee against replay achieved here, | 214 | * there is no real guarantee against replay achieved here, |
214 | * as the latest timestamp is not persisted. This is | 215 | * as the latest timestamp is not persisted. This is |
215 | * necessary as we do not want to require synchronized | 216 | * necessary as we do not want to require synchronized |
216 | * clocks and may not have a bidirectional communication | 217 | * clocks and may not have a bidirectional communication |
217 | * channel. Communicators must protect against replay | 218 | * channel. Communicators must protect against replay |
218 | * attacks when using backchannel communication! | 219 | * attacks when using backchannel communication! |
@@ -360,17 +361,17 @@ struct TransportFragmentBox | |||
360 | /** | 361 | /** |
361 | * Original message ID for of the message that all the1 | 362 | * Original message ID for of the message that all the1 |
362 | * fragments belong to. Must be the same for all fragments. | 363 | * fragments belong to. Must be the same for all fragments. |
363 | */ | 364 | */ |
364 | struct GNUNET_ShortHashCode msg_uuid; | 365 | struct GNUNET_ShortHashCode msg_uuid; |
365 | 366 | ||
366 | /** | 367 | /** |
367 | * Offset of this fragment in the overall message. | 368 | * Offset of this fragment in the overall message. |
368 | */ | 369 | */ |
369 | uint16_t frag_off GNUNET_PACKED; | 370 | uint16_t frag_off GNUNET_PACKED; |
370 | 371 | ||
371 | /** | 372 | /** |
372 | * Total size of the message that is being fragmented. | 373 | * Total size of the message that is being fragmented. |
373 | */ | 374 | */ |
374 | uint16_t msg_size GNUNET_PACKED; | 375 | uint16_t msg_size GNUNET_PACKED; |
375 | 376 | ||
376 | }; | 377 | }; |
@@ -399,13 +400,13 @@ struct TransportFragmentAckMessage | |||
399 | /** | 400 | /** |
400 | * Bitfield of up to 64 additional fragments following the | 401 | * Bitfield of up to 64 additional fragments following the |
401 | * @e msg_uuid being acknowledged by this message. | 402 | * @e msg_uuid being acknowledged by this message. |
402 | */ | 403 | */ |
403 | uint64_t extra_acks GNUNET_PACKED; | 404 | uint64_t extra_acks GNUNET_PACKED; |
404 | 405 | ||
405 | /** | 406 | /** |
406 | * Original message ID for of the message that all the | 407 | * Original message ID for of the message that all the |
407 | * fragments belong to. | 408 | * fragments belong to. |
408 | */ | 409 | */ |
409 | struct GNUNET_ShortHashCode msg_uuid; | 410 | struct GNUNET_ShortHashCode msg_uuid; |
410 | 411 | ||
411 | /** | 412 | /** |
@@ -431,7 +432,7 @@ struct TransportFragmentAckMessage | |||
431 | * to a subset of their neighbours to limit discoverability of the | 432 | * to a subset of their neighbours to limit discoverability of the |
432 | * network topology). To the extend that the @e bidirectional bits | 433 | * network topology). To the extend that the @e bidirectional bits |
433 | * are set, peers may learn the inverse paths even if they did not | 434 | * are set, peers may learn the inverse paths even if they did not |
434 | * initiate. | 435 | * initiate. |
435 | * | 436 | * |
436 | * Unless received on a bidirectional queue and @e num_hops just | 437 | * Unless received on a bidirectional queue and @e num_hops just |
437 | * zero, peers that can forward to the initator should always try to | 438 | * zero, peers that can forward to the initator should always try to |
@@ -456,13 +457,13 @@ struct TransportDVLearn | |||
456 | * to possibly instantly learn a path in both directions. Each peer | 457 | * to possibly instantly learn a path in both directions. Each peer |
457 | * should shift this value by one to the left, and then set the | 458 | * should shift this value by one to the left, and then set the |
458 | * lowest bit IF the current sender can be reached from it (without | 459 | * lowest bit IF the current sender can be reached from it (without |
459 | * DV routing). | 460 | * DV routing). |
460 | */ | 461 | */ |
461 | uint16_t bidirectional GNUNET_PACKED; | 462 | uint16_t bidirectional GNUNET_PACKED; |
462 | 463 | ||
463 | /** | 464 | /** |
464 | * Peers receiving this message and delaying forwarding to other | 465 | * Peers receiving this message and delaying forwarding to other |
465 | * peers for any reason should increment this value such as to | 466 | * peers for any reason should increment this value such as to |
466 | * enable the origin to determine the actual network-only delay | 467 | * enable the origin to determine the actual network-only delay |
467 | * in addition to the real-time delay (assuming the message loops | 468 | * in addition to the real-time delay (assuming the message loops |
468 | * back to the origin). | 469 | * back to the origin). |
@@ -473,11 +474,11 @@ struct TransportDVLearn | |||
473 | * Identity of the peer that started this learning activity. | 474 | * Identity of the peer that started this learning activity. |
474 | */ | 475 | */ |
475 | struct GNUNET_PeerIdentity initiator; | 476 | struct GNUNET_PeerIdentity initiator; |
476 | 477 | ||
477 | /* Followed by @e num_hops `struct GNUNET_PeerIdentity` values, | 478 | /* Followed by @e num_hops `struct GNUNET_PeerIdentity` values, |
478 | excluding the initiator of the DV trace; the last entry is the | 479 | excluding the initiator of the DV trace; the last entry is the |
479 | current sender; the current peer must not be included. */ | 480 | current sender; the current peer must not be included. */ |
480 | 481 | ||
481 | }; | 482 | }; |
482 | 483 | ||
483 | 484 | ||
@@ -514,7 +515,7 @@ struct TransportDVBox | |||
514 | * Number of hops this messages includes. In NBO. | 515 | * Number of hops this messages includes. In NBO. |
515 | */ | 516 | */ |
516 | uint16_t num_hops GNUNET_PACKED; | 517 | uint16_t num_hops GNUNET_PACKED; |
517 | 518 | ||
518 | /** | 519 | /** |
519 | * Identity of the peer that originated the message. | 520 | * Identity of the peer that originated the message. |
520 | */ | 521 | */ |
@@ -564,7 +565,7 @@ enum ClientType | |||
564 | /** | 565 | /** |
565 | * Entry in our cache of ephemeral keys we currently use. | 566 | * Entry in our cache of ephemeral keys we currently use. |
566 | * This way, we only sign an ephemeral once per @e target, | 567 | * This way, we only sign an ephemeral once per @e target, |
567 | * and then can re-use it over multiple | 568 | * and then can re-use it over multiple |
568 | * #GNUNET_MESSAGE_TYPE_TRANSPORT_BACKCHANNEL_ENCAPSULATION | 569 | * #GNUNET_MESSAGE_TYPE_TRANSPORT_BACKCHANNEL_ENCAPSULATION |
569 | * messages (as signing is expensive). | 570 | * messages (as signing is expensive). |
570 | */ | 571 | */ |
@@ -632,39 +633,39 @@ struct DistanceVectorHop | |||
632 | 633 | ||
633 | /** | 634 | /** |
634 | * Kept in a MDLL, sorted by @e timeout. | 635 | * Kept in a MDLL, sorted by @e timeout. |
635 | */ | 636 | */ |
636 | struct DistanceVectorHop *next_dv; | 637 | struct DistanceVectorHop *next_dv; |
637 | 638 | ||
638 | /** | 639 | /** |
639 | * Kept in a MDLL, sorted by @e timeout. | 640 | * Kept in a MDLL, sorted by @e timeout. |
640 | */ | 641 | */ |
641 | struct DistanceVectorHop *prev_dv; | 642 | struct DistanceVectorHop *prev_dv; |
642 | 643 | ||
643 | /** | 644 | /** |
644 | * Kept in a MDLL. | 645 | * Kept in a MDLL. |
645 | */ | 646 | */ |
646 | struct DistanceVectorHop *next_neighbour; | 647 | struct DistanceVectorHop *next_neighbour; |
647 | 648 | ||
648 | /** | 649 | /** |
649 | * Kept in a MDLL. | 650 | * Kept in a MDLL. |
650 | */ | 651 | */ |
651 | struct DistanceVectorHop *prev_neighbour; | 652 | struct DistanceVectorHop *prev_neighbour; |
652 | 653 | ||
653 | /** | 654 | /** |
654 | * What would be the next hop to @e target? | 655 | * What would be the next hop to @e target? |
655 | */ | 656 | */ |
656 | struct Neighbour *next_hop; | 657 | struct Neighbour *next_hop; |
657 | 658 | ||
658 | /** | 659 | /** |
659 | * Distance vector entry this hop belongs with. | 660 | * Distance vector entry this hop belongs with. |
660 | */ | 661 | */ |
661 | struct DistanceVector *dv; | 662 | struct DistanceVector *dv; |
662 | 663 | ||
663 | /** | 664 | /** |
664 | * Array of @e distance hops to the target, excluding @e next_hop. | 665 | * Array of @e distance hops to the target, excluding @e next_hop. |
665 | * NULL if the entire path is us to @e next_hop to `target`. Allocated | 666 | * NULL if the entire path is us to @e next_hop to `target`. Allocated |
666 | * at the end of this struct. | 667 | * at the end of this struct. |
667 | */ | 668 | */ |
668 | const struct GNUNET_PeerIdentity *path; | 669 | const struct GNUNET_PeerIdentity *path; |
669 | 670 | ||
670 | /** | 671 | /** |
@@ -672,11 +673,11 @@ struct DistanceVectorHop | |||
672 | * while learning? | 673 | * while learning? |
673 | */ | 674 | */ |
674 | struct GNUNET_TIME_Absolute timeout; | 675 | struct GNUNET_TIME_Absolute timeout; |
675 | 676 | ||
676 | /** | 677 | /** |
677 | * How many hops in total to the `target` (excluding @e next_hop and `target` itself), | 678 | * How many hops in total to the `target` (excluding @e next_hop and `target` itself), |
678 | * thus 0 still means a distance of 2 hops (to @e next_hop and then to `target`)? | 679 | * thus 0 still means a distance of 2 hops (to @e next_hop and then to `target`)? |
679 | */ | 680 | */ |
680 | unsigned int distance; | 681 | unsigned int distance; |
681 | }; | 682 | }; |
682 | 683 | ||
@@ -695,12 +696,12 @@ struct DistanceVector | |||
695 | 696 | ||
696 | /** | 697 | /** |
697 | * Known paths to @e target. | 698 | * Known paths to @e target. |
698 | */ | 699 | */ |
699 | struct DistanceVectorHop *dv_head; | 700 | struct DistanceVectorHop *dv_head; |
700 | 701 | ||
701 | /** | 702 | /** |
702 | * Known paths to @e target. | 703 | * Known paths to @e target. |
703 | */ | 704 | */ |
704 | struct DistanceVectorHop *dv_tail; | 705 | struct DistanceVectorHop *dv_tail; |
705 | 706 | ||
706 | /** | 707 | /** |
@@ -724,19 +725,19 @@ struct QueueEntry | |||
724 | 725 | ||
725 | /** | 726 | /** |
726 | * Kept as a DLL. | 727 | * Kept as a DLL. |
727 | */ | 728 | */ |
728 | struct QueueEntry *next; | 729 | struct QueueEntry *next; |
729 | 730 | ||
730 | /** | 731 | /** |
731 | * Kept as a DLL. | 732 | * Kept as a DLL. |
732 | */ | 733 | */ |
733 | struct QueueEntry *prev; | 734 | struct QueueEntry *prev; |
734 | 735 | ||
735 | /** | 736 | /** |
736 | * ATS session this entry is queued with. | 737 | * ATS session this entry is queued with. |
737 | */ | 738 | */ |
738 | struct GNUNET_ATS_Session *session; | 739 | struct GNUNET_ATS_Session *session; |
739 | 740 | ||
740 | /** | 741 | /** |
741 | * Message ID used for this message with the queue used for transmission. | 742 | * Message ID used for this message with the queue used for transmission. |
742 | */ | 743 | */ |
@@ -772,12 +773,12 @@ struct GNUNET_ATS_Session | |||
772 | 773 | ||
773 | /** | 774 | /** |
774 | * Head of DLL of unacked transmission requests. | 775 | * Head of DLL of unacked transmission requests. |
775 | */ | 776 | */ |
776 | struct QueueEntry *queue_head; | 777 | struct QueueEntry *queue_head; |
777 | 778 | ||
778 | /** | 779 | /** |
779 | * End of DLL of unacked transmission requests. | 780 | * End of DLL of unacked transmission requests. |
780 | */ | 781 | */ |
781 | struct QueueEntry *queue_tail; | 782 | struct QueueEntry *queue_tail; |
782 | 783 | ||
783 | /** | 784 | /** |
@@ -803,9 +804,9 @@ struct GNUNET_ATS_Session | |||
803 | /** | 804 | /** |
804 | * Task scheduled for the time when this queue can (likely) transmit the | 805 | * Task scheduled for the time when this queue can (likely) transmit the |
805 | * next message. Still needs to check with the @e tracker_out to be sure. | 806 | * next message. Still needs to check with the @e tracker_out to be sure. |
806 | */ | 807 | */ |
807 | struct GNUNET_SCHEDULER_Task *transmit_task; | 808 | struct GNUNET_SCHEDULER_Task *transmit_task; |
808 | 809 | ||
809 | /** | 810 | /** |
810 | * Our current RTT estimate for this ATS session. | 811 | * Our current RTT estimate for this ATS session. |
811 | */ | 812 | */ |
@@ -813,9 +814,9 @@ struct GNUNET_ATS_Session | |||
813 | 814 | ||
814 | /** | 815 | /** |
815 | * Message ID generator for transmissions on this queue. | 816 | * Message ID generator for transmissions on this queue. |
816 | */ | 817 | */ |
817 | uint64_t mid_gen; | 818 | uint64_t mid_gen; |
818 | 819 | ||
819 | /** | 820 | /** |
820 | * Unique identifier of this ATS session with the communicator. | 821 | * Unique identifier of this ATS session with the communicator. |
821 | */ | 822 | */ |
@@ -845,7 +846,7 @@ struct GNUNET_ATS_Session | |||
845 | * Length of the DLL starting at @e queue_head. | 846 | * Length of the DLL starting at @e queue_head. |
846 | */ | 847 | */ |
847 | unsigned int queue_length; | 848 | unsigned int queue_length; |
848 | 849 | ||
849 | /** | 850 | /** |
850 | * Network type offered by this ATS session. | 851 | * Network type offered by this ATS session. |
851 | */ | 852 | */ |
@@ -870,14 +871,14 @@ struct GNUNET_ATS_Session | |||
870 | 871 | ||
871 | /** | 872 | /** |
872 | * Information we keep for a message that we are reassembling. | 873 | * Information we keep for a message that we are reassembling. |
873 | */ | 874 | */ |
874 | struct ReassemblyContext | 875 | struct ReassemblyContext |
875 | { | 876 | { |
876 | 877 | ||
877 | /** | 878 | /** |
878 | * Original message ID for of the message that all the | 879 | * Original message ID for of the message that all the |
879 | * fragments belong to. | 880 | * fragments belong to. |
880 | */ | 881 | */ |
881 | struct GNUNET_ShortHashCode msg_uuid; | 882 | struct GNUNET_ShortHashCode msg_uuid; |
882 | 883 | ||
883 | /** | 884 | /** |
@@ -887,7 +888,7 @@ struct ReassemblyContext | |||
887 | 888 | ||
888 | /** | 889 | /** |
889 | * Entry in the reassembly heap (sorted by expiration). | 890 | * Entry in the reassembly heap (sorted by expiration). |
890 | */ | 891 | */ |
891 | struct GNUNET_CONTAINER_HeapNode *hn; | 892 | struct GNUNET_CONTAINER_HeapNode *hn; |
892 | 893 | ||
893 | /** | 894 | /** |
@@ -905,7 +906,7 @@ struct ReassemblyContext | |||
905 | * task is for the latter case. | 906 | * task is for the latter case. |
906 | */ | 907 | */ |
907 | struct GNUNET_SCHEDULER_Task *ack_task; | 908 | struct GNUNET_SCHEDULER_Task *ack_task; |
908 | 909 | ||
909 | /** | 910 | /** |
910 | * At what time will we give up reassembly of this message? | 911 | * At what time will we give up reassembly of this message? |
911 | */ | 912 | */ |
@@ -928,7 +929,7 @@ struct ReassemblyContext | |||
928 | * to be acknowledged in the next cummulative ACK. | 929 | * to be acknowledged in the next cummulative ACK. |
929 | */ | 930 | */ |
930 | uint64_t extra_acks; | 931 | uint64_t extra_acks; |
931 | 932 | ||
932 | /** | 933 | /** |
933 | * Unique ID of the lowest fragment UUID to be acknowledged in the | 934 | * Unique ID of the lowest fragment UUID to be acknowledged in the |
934 | * next cummulative ACK. Only valid if @e num_acks > 0. | 935 | * next cummulative ACK. Only valid if @e num_acks > 0. |
@@ -940,7 +941,7 @@ struct ReassemblyContext | |||
940 | * whenever we send a #GNUNET_MESSAGE_TYPE_TRANSPORT_FRAGMENT_ACK. | 941 | * whenever we send a #GNUNET_MESSAGE_TYPE_TRANSPORT_FRAGMENT_ACK. |
941 | */ | 942 | */ |
942 | unsigned int num_acks; | 943 | unsigned int num_acks; |
943 | 944 | ||
944 | /** | 945 | /** |
945 | * How big is the message we are reassembling in total? | 946 | * How big is the message we are reassembling in total? |
946 | */ | 947 | */ |
@@ -973,21 +974,21 @@ struct Neighbour | |||
973 | * Map with `struct ReassemblyContext` structs for fragments under | 974 | * Map with `struct ReassemblyContext` structs for fragments under |
974 | * reassembly. May be NULL if we currently have no fragments from | 975 | * reassembly. May be NULL if we currently have no fragments from |
975 | * this @e pid (lazy initialization). | 976 | * this @e pid (lazy initialization). |
976 | */ | 977 | */ |
977 | struct GNUNET_CONTAINER_MultiShortmap *reassembly_map; | 978 | struct GNUNET_CONTAINER_MultiShortmap *reassembly_map; |
978 | 979 | ||
979 | /** | 980 | /** |
980 | * Heap with `struct ReassemblyContext` structs for fragments under | 981 | * Heap with `struct ReassemblyContext` structs for fragments under |
981 | * reassembly. May be NULL if we currently have no fragments from | 982 | * reassembly. May be NULL if we currently have no fragments from |
982 | * this @e pid (lazy initialization). | 983 | * this @e pid (lazy initialization). |
983 | */ | 984 | */ |
984 | struct GNUNET_CONTAINER_Heap *reassembly_heap; | 985 | struct GNUNET_CONTAINER_Heap *reassembly_heap; |
985 | 986 | ||
986 | /** | 987 | /** |
987 | * Task to free old entries from the @e reassembly_heap and @e reassembly_map. | 988 | * Task to free old entries from the @e reassembly_heap and @e reassembly_map. |
988 | */ | 989 | */ |
989 | struct GNUNET_SCHEDULER_Task *reassembly_timeout_task; | 990 | struct GNUNET_SCHEDULER_Task *reassembly_timeout_task; |
990 | 991 | ||
991 | /** | 992 | /** |
992 | * Head of list of messages pending for this neighbour. | 993 | * Head of list of messages pending for this neighbour. |
993 | */ | 994 | */ |
@@ -1001,13 +1002,13 @@ struct Neighbour | |||
1001 | /** | 1002 | /** |
1002 | * Head of MDLL of DV hops that have this neighbour as next hop. Must be | 1003 | * Head of MDLL of DV hops that have this neighbour as next hop. Must be |
1003 | * purged if this neighbour goes down. | 1004 | * purged if this neighbour goes down. |
1004 | */ | 1005 | */ |
1005 | struct DistanceVectorHop *dv_head; | 1006 | struct DistanceVectorHop *dv_head; |
1006 | 1007 | ||
1007 | /** | 1008 | /** |
1008 | * Tail of MDLL of DV hops that have this neighbour as next hop. Must be | 1009 | * Tail of MDLL of DV hops that have this neighbour as next hop. Must be |
1009 | * purged if this neighbour goes down. | 1010 | * purged if this neighbour goes down. |
1010 | */ | 1011 | */ |
1011 | struct DistanceVectorHop *dv_tail; | 1012 | struct DistanceVectorHop *dv_tail; |
1012 | 1013 | ||
1013 | /** | 1014 | /** |
@@ -1022,7 +1023,7 @@ struct Neighbour | |||
1022 | 1023 | ||
1023 | /** | 1024 | /** |
1024 | * Task run to cleanup pending messages that have exceeded their timeout. | 1025 | * Task run to cleanup pending messages that have exceeded their timeout. |
1025 | */ | 1026 | */ |
1026 | struct GNUNET_SCHEDULER_Task *timeout_task; | 1027 | struct GNUNET_SCHEDULER_Task *timeout_task; |
1027 | 1028 | ||
1028 | /** | 1029 | /** |
@@ -1039,15 +1040,15 @@ struct Neighbour | |||
1039 | 1040 | ||
1040 | /** | 1041 | /** |
1041 | * What is the earliest timeout of any message in @e pending_msg_tail? | 1042 | * What is the earliest timeout of any message in @e pending_msg_tail? |
1042 | */ | 1043 | */ |
1043 | struct GNUNET_TIME_Absolute earliest_timeout; | 1044 | struct GNUNET_TIME_Absolute earliest_timeout; |
1044 | 1045 | ||
1045 | }; | 1046 | }; |
1046 | 1047 | ||
1047 | 1048 | ||
1048 | /** | 1049 | /** |
1049 | * Types of different pending messages. | 1050 | * Types of different pending messages. |
1050 | */ | 1051 | */ |
1051 | enum PendingMessageType | 1052 | enum PendingMessageType |
1052 | { | 1053 | { |
1053 | 1054 | ||
@@ -1071,7 +1072,7 @@ enum PendingMessageType | |||
1071 | */ | 1072 | */ |
1072 | PMT_ACKNOWLEDGEMENT = 3 | 1073 | PMT_ACKNOWLEDGEMENT = 3 |
1073 | 1074 | ||
1074 | 1075 | ||
1075 | }; | 1076 | }; |
1076 | 1077 | ||
1077 | 1078 | ||
@@ -1088,13 +1089,13 @@ enum PendingMessageType | |||
1088 | * either calculate the next fragment (based on @e frag_off) from the | 1089 | * either calculate the next fragment (based on @e frag_off) from the |
1089 | * current node, or, if all fragments have already been created, | 1090 | * current node, or, if all fragments have already been created, |
1090 | * descend to the @e head_frag. Even though the node was already | 1091 | * descend to the @e head_frag. Even though the node was already |
1091 | * fragmented, the fragment may be too big if the fragment was | 1092 | * fragmented, the fragment may be too big if the fragment was |
1092 | * generated for a queue with a larger MTU. In this case, the node | 1093 | * generated for a queue with a larger MTU. In this case, the node |
1093 | * may be fragmented again, thus creating a tree. | 1094 | * may be fragmented again, thus creating a tree. |
1094 | * | 1095 | * |
1095 | * When acknowledgements for fragments are received, the tree | 1096 | * When acknowledgements for fragments are received, the tree |
1096 | * must be pruned, removing those parts that were already | 1097 | * must be pruned, removing those parts that were already |
1097 | * acknowledged. When fragments are sent over a reliable | 1098 | * acknowledged. When fragments are sent over a reliable |
1098 | * channel, they can be immediately removed. | 1099 | * channel, they can be immediately removed. |
1099 | * | 1100 | * |
1100 | * If a message is ever fragmented, then the original "full" message | 1101 | * If a message is ever fragmented, then the original "full" message |
@@ -1117,7 +1118,7 @@ struct PendingMessage | |||
1117 | * Kept in a MDLL of messages from this @a client (if @e pmt is #PMT_CORE) | 1118 | * Kept in a MDLL of messages from this @a client (if @e pmt is #PMT_CORE) |
1118 | */ | 1119 | */ |
1119 | struct PendingMessage *next_client; | 1120 | struct PendingMessage *next_client; |
1120 | 1121 | ||
1121 | /** | 1122 | /** |
1122 | * Kept in a MDLL of messages from this @a client (if @e pmt is #PMT_CORE) | 1123 | * Kept in a MDLL of messages from this @a client (if @e pmt is #PMT_CORE) |
1123 | */ | 1124 | */ |
@@ -1127,7 +1128,7 @@ struct PendingMessage | |||
1127 | * Kept in a MDLL of messages from this @a cpm (if @e pmt is #PMT_FRAGMENT_BOx) | 1128 | * Kept in a MDLL of messages from this @a cpm (if @e pmt is #PMT_FRAGMENT_BOx) |
1128 | */ | 1129 | */ |
1129 | struct PendingMessage *next_frag; | 1130 | struct PendingMessage *next_frag; |
1130 | 1131 | ||
1131 | /** | 1132 | /** |
1132 | * Kept in a MDLL of messages from this @a cpm (if @e pmt is #PMT_FRAGMENT_BOX) | 1133 | * Kept in a MDLL of messages from this @a cpm (if @e pmt is #PMT_FRAGMENT_BOX) |
1133 | */ | 1134 | */ |
@@ -1135,24 +1136,24 @@ struct PendingMessage | |||
1135 | 1136 | ||
1136 | /** | 1137 | /** |
1137 | * This message, reliability boxed. Only possibly available if @e pmt is #PMT_CORE. | 1138 | * This message, reliability boxed. Only possibly available if @e pmt is #PMT_CORE. |
1138 | */ | 1139 | */ |
1139 | struct PendingMessage *bpm; | 1140 | struct PendingMessage *bpm; |
1140 | 1141 | ||
1141 | /** | 1142 | /** |
1142 | * Target of the request. | 1143 | * Target of the request. |
1143 | */ | 1144 | */ |
1144 | struct Neighbour *target; | 1145 | struct Neighbour *target; |
1145 | 1146 | ||
1146 | /** | 1147 | /** |
1147 | * Client that issued the transmission request, if @e pmt is #PMT_CORE. | 1148 | * Client that issued the transmission request, if @e pmt is #PMT_CORE. |
1148 | */ | 1149 | */ |
1149 | struct TransportClient *client; | 1150 | struct TransportClient *client; |
1150 | 1151 | ||
1151 | /** | 1152 | /** |
1152 | * Head of a MDLL of fragments created for this core message. | 1153 | * Head of a MDLL of fragments created for this core message. |
1153 | */ | 1154 | */ |
1154 | struct PendingMessage *head_frag; | 1155 | struct PendingMessage *head_frag; |
1155 | 1156 | ||
1156 | /** | 1157 | /** |
1157 | * Tail of a MDLL of fragments created for this core message. | 1158 | * Tail of a MDLL of fragments created for this core message. |
1158 | */ | 1159 | */ |
@@ -1162,7 +1163,7 @@ struct PendingMessage | |||
1162 | * Our parent in the fragmentation tree. | 1163 | * Our parent in the fragmentation tree. |
1163 | */ | 1164 | */ |
1164 | struct PendingMessage *frag_parent; | 1165 | struct PendingMessage *frag_parent; |
1165 | 1166 | ||
1166 | /** | 1167 | /** |
1167 | * At what time should we give up on the transmission (and no longer retry)? | 1168 | * At what time should we give up on the transmission (and no longer retry)? |
1168 | */ | 1169 | */ |
@@ -1178,12 +1179,12 @@ struct PendingMessage | |||
1178 | * initialized if @e msg_uuid_set is #GNUNET_YES). | 1179 | * initialized if @e msg_uuid_set is #GNUNET_YES). |
1179 | */ | 1180 | */ |
1180 | struct GNUNET_ShortHashCode msg_uuid; | 1181 | struct GNUNET_ShortHashCode msg_uuid; |
1181 | 1182 | ||
1182 | /** | 1183 | /** |
1183 | * Counter incremented per generated fragment. | 1184 | * Counter incremented per generated fragment. |
1184 | */ | 1185 | */ |
1185 | uint32_t frag_uuidgen; | 1186 | uint32_t frag_uuidgen; |
1186 | 1187 | ||
1187 | /** | 1188 | /** |
1188 | * Type of the pending message. | 1189 | * Type of the pending message. |
1189 | */ | 1190 | */ |
@@ -1196,14 +1197,14 @@ struct PendingMessage | |||
1196 | 1197 | ||
1197 | /** | 1198 | /** |
1198 | * Offset at which we should generate the next fragment. | 1199 | * Offset at which we should generate the next fragment. |
1199 | */ | 1200 | */ |
1200 | uint16_t frag_off; | 1201 | uint16_t frag_off; |
1201 | 1202 | ||
1202 | /** | 1203 | /** |
1203 | * #GNUNET_YES once @e msg_uuid was initialized | 1204 | * #GNUNET_YES once @e msg_uuid was initialized |
1204 | */ | 1205 | */ |
1205 | int16_t msg_uuid_set; | 1206 | int16_t msg_uuid_set; |
1206 | 1207 | ||
1207 | /* Followed by @e bytes_msg to transmit */ | 1208 | /* Followed by @e bytes_msg to transmit */ |
1208 | }; | 1209 | }; |
1209 | 1210 | ||
@@ -1303,7 +1304,7 @@ struct TransportClient | |||
1303 | struct { | 1304 | struct { |
1304 | 1305 | ||
1305 | /** | 1306 | /** |
1306 | * Head of list of messages pending for this client, sorted by | 1307 | * Head of list of messages pending for this client, sorted by |
1307 | * transmission time ("next_attempt" + possibly internal prioritization). | 1308 | * transmission time ("next_attempt" + possibly internal prioritization). |
1308 | */ | 1309 | */ |
1309 | struct PendingMessage *pending_msg_head; | 1310 | struct PendingMessage *pending_msg_head; |
@@ -1371,7 +1372,7 @@ struct TransportClient | |||
1371 | * is globally unable to keep up. | 1372 | * is globally unable to keep up. |
1372 | */ | 1373 | */ |
1373 | unsigned int total_queue_length; | 1374 | unsigned int total_queue_length; |
1374 | 1375 | ||
1375 | /** | 1376 | /** |
1376 | * Characteristics of this communicator. | 1377 | * Characteristics of this communicator. |
1377 | */ | 1378 | */ |
@@ -1546,7 +1547,7 @@ free_distance_vector_hop (struct DistanceVectorHop *dvh) | |||
1546 | GNUNET_free (dvh); | 1547 | GNUNET_free (dvh); |
1547 | if (NULL == dv->dv_head) | 1548 | if (NULL == dv->dv_head) |
1548 | { | 1549 | { |
1549 | GNUNET_assert (GNUNET_YES == | 1550 | GNUNET_assert (GNUNET_YES == |
1550 | GNUNET_CONTAINER_multipeermap_remove (dv_routes, | 1551 | GNUNET_CONTAINER_multipeermap_remove (dv_routes, |
1551 | &dv->target, | 1552 | &dv->target, |
1552 | dv)); | 1553 | dv)); |
@@ -1751,7 +1752,7 @@ free_reassembly_cb (void *cls, | |||
1751 | struct ReassemblyContext *rc = value; | 1752 | struct ReassemblyContext *rc = value; |
1752 | (void) cls; | 1753 | (void) cls; |
1753 | (void) key; | 1754 | (void) key; |
1754 | 1755 | ||
1755 | free_reassembly_context (rc); | 1756 | free_reassembly_context (rc); |
1756 | return GNUNET_OK; | 1757 | return GNUNET_OK; |
1757 | } | 1758 | } |
@@ -1766,7 +1767,7 @@ static void | |||
1766 | free_neighbour (struct Neighbour *neighbour) | 1767 | free_neighbour (struct Neighbour *neighbour) |
1767 | { | 1768 | { |
1768 | struct DistanceVectorHop *dvh; | 1769 | struct DistanceVectorHop *dvh; |
1769 | 1770 | ||
1770 | GNUNET_assert (NULL == neighbour->session_head); | 1771 | GNUNET_assert (NULL == neighbour->session_head); |
1771 | GNUNET_assert (GNUNET_YES == | 1772 | GNUNET_assert (GNUNET_YES == |
1772 | GNUNET_CONTAINER_multipeermap_remove (neighbours, | 1773 | GNUNET_CONTAINER_multipeermap_remove (neighbours, |
@@ -1868,25 +1869,25 @@ cores_send_disconnect_info (const struct GNUNET_PeerIdentity *pid) | |||
1868 | 1869 | ||
1869 | /** | 1870 | /** |
1870 | * We believe we are ready to transmit a message on a queue. Double-checks | 1871 | * We believe we are ready to transmit a message on a queue. Double-checks |
1871 | * with the queue's "tracker_out" and then gives the message to the | 1872 | * with the queue's "tracker_out" and then gives the message to the |
1872 | * communicator for transmission (updating the tracker, and re-scheduling | 1873 | * communicator for transmission (updating the tracker, and re-scheduling |
1873 | * itself if applicable). | 1874 | * itself if applicable). |
1874 | * | 1875 | * |
1875 | * @param cls the `struct GNUNET_ATS_Session` to process transmissions for | 1876 | * @param cls the `struct GNUNET_ATS_Session` to process transmissions for |
1876 | */ | 1877 | */ |
1877 | static void | 1878 | static void |
1878 | transmit_on_queue (void *cls); | 1879 | transmit_on_queue (void *cls); |
1879 | 1880 | ||
1880 | 1881 | ||
1881 | /** | 1882 | /** |
1882 | * Schedule next run of #transmit_on_queue(). Does NOTHING if | 1883 | * Schedule next run of #transmit_on_queue(). Does NOTHING if |
1883 | * we should run immediately or if the message queue is empty. | 1884 | * we should run immediately or if the message queue is empty. |
1884 | * Test for no task being added AND queue not being empty to | 1885 | * Test for no task being added AND queue not being empty to |
1885 | * transmit immediately afterwards! This function must only | 1886 | * transmit immediately afterwards! This function must only |
1886 | * be called if the message queue is non-empty! | 1887 | * be called if the message queue is non-empty! |
1887 | * | 1888 | * |
1888 | * @param queue the queue to do scheduling for | 1889 | * @param queue the queue to do scheduling for |
1889 | */ | 1890 | */ |
1890 | static void | 1891 | static void |
1891 | schedule_transmit_on_queue (struct GNUNET_ATS_Session *queue) | 1892 | schedule_transmit_on_queue (struct GNUNET_ATS_Session *queue) |
1892 | { | 1893 | { |
@@ -1901,7 +1902,7 @@ schedule_transmit_on_queue (struct GNUNET_ATS_Session *queue) | |||
1901 | GNUNET_STATISTICS_update (GST_stats, | 1902 | GNUNET_STATISTICS_update (GST_stats, |
1902 | "# Transmission throttled due to communicator queue limit", | 1903 | "# Transmission throttled due to communicator queue limit", |
1903 | 1, | 1904 | 1, |
1904 | GNUNET_NO); | 1905 | GNUNET_NO); |
1905 | return; | 1906 | return; |
1906 | } | 1907 | } |
1907 | if (queue->queue_length >= SESSION_QUEUE_LIMIT) | 1908 | if (queue->queue_length >= SESSION_QUEUE_LIMIT) |
@@ -1909,10 +1910,10 @@ schedule_transmit_on_queue (struct GNUNET_ATS_Session *queue) | |||
1909 | GNUNET_STATISTICS_update (GST_stats, | 1910 | GNUNET_STATISTICS_update (GST_stats, |
1910 | "# Transmission throttled due to session queue limit", | 1911 | "# Transmission throttled due to session queue limit", |
1911 | 1, | 1912 | 1, |
1912 | GNUNET_NO); | 1913 | GNUNET_NO); |
1913 | return; | 1914 | return; |
1914 | } | 1915 | } |
1915 | 1916 | ||
1916 | wsize = (0 == queue->mtu) | 1917 | wsize = (0 == queue->mtu) |
1917 | ? pm->bytes_msg /* FIXME: add overheads? */ | 1918 | ? pm->bytes_msg /* FIXME: add overheads? */ |
1918 | : queue->mtu; | 1919 | : queue->mtu; |
@@ -2200,7 +2201,7 @@ check_client_send (void *cls, | |||
2200 | * Free fragment tree below @e root, excluding @e root itself. | 2201 | * Free fragment tree below @e root, excluding @e root itself. |
2201 | * | 2202 | * |
2202 | * @param root root of the tree to free | 2203 | * @param root root of the tree to free |
2203 | */ | 2204 | */ |
2204 | static void | 2205 | static void |
2205 | free_fragment_tree (struct PendingMessage *root) | 2206 | free_fragment_tree (struct PendingMessage *root) |
2206 | { | 2207 | { |
@@ -2315,7 +2316,7 @@ check_queue_timeouts (void *cls) | |||
2315 | GNUNET_NO); | 2316 | GNUNET_NO); |
2316 | client_send_response (pm, | 2317 | client_send_response (pm, |
2317 | GNUNET_NO, | 2318 | GNUNET_NO, |
2318 | 0); | 2319 | 0); |
2319 | continue; | 2320 | continue; |
2320 | } | 2321 | } |
2321 | earliest_timeout = GNUNET_TIME_absolute_min (earliest_timeout, | 2322 | earliest_timeout = GNUNET_TIME_absolute_min (earliest_timeout, |
@@ -2394,7 +2395,7 @@ handle_client_send (void *cls, | |||
2394 | target->earliest_timeout.abs_value_us = pm->timeout.abs_value_us; | 2395 | target->earliest_timeout.abs_value_us = pm->timeout.abs_value_us; |
2395 | if (NULL != target->timeout_task) | 2396 | if (NULL != target->timeout_task) |
2396 | GNUNET_SCHEDULER_cancel (target->timeout_task); | 2397 | GNUNET_SCHEDULER_cancel (target->timeout_task); |
2397 | target->timeout_task | 2398 | target->timeout_task |
2398 | = GNUNET_SCHEDULER_add_at (target->earliest_timeout, | 2399 | = GNUNET_SCHEDULER_add_at (target->earliest_timeout, |
2399 | &check_queue_timeouts, | 2400 | &check_queue_timeouts, |
2400 | target); | 2401 | target); |
@@ -2529,7 +2530,7 @@ expire_ephemerals (void *cls) | |||
2529 | * one, cache it and return it. | 2530 | * one, cache it and return it. |
2530 | * | 2531 | * |
2531 | * @param pid peer to look up ephemeral for | 2532 | * @param pid peer to look up ephemeral for |
2532 | * @param private_key[out] set to the private key | 2533 | * @param private_key[out] set to the private key |
2533 | * @param ephemeral_key[out] set to the key | 2534 | * @param ephemeral_key[out] set to the key |
2534 | * @param ephemeral_sender_sig[out] set to the signature | 2535 | * @param ephemeral_sender_sig[out] set to the signature |
2535 | * @param ephemeral_validity[out] set to the validity expiration time | 2536 | * @param ephemeral_validity[out] set to the validity expiration time |
@@ -2543,7 +2544,7 @@ lookup_ephemeral (const struct GNUNET_PeerIdentity *pid, | |||
2543 | { | 2544 | { |
2544 | struct EphemeralCacheEntry *ece; | 2545 | struct EphemeralCacheEntry *ece; |
2545 | struct EphemeralConfirmation ec; | 2546 | struct EphemeralConfirmation ec; |
2546 | 2547 | ||
2547 | ece = GNUNET_CONTAINER_multipeermap_get (ephemeral_map, | 2548 | ece = GNUNET_CONTAINER_multipeermap_get (ephemeral_map, |
2548 | pid); | 2549 | pid); |
2549 | if ( (NULL != ece) && | 2550 | if ( (NULL != ece) && |
@@ -2605,7 +2606,7 @@ route_message (const struct GNUNET_PeerIdentity *target, | |||
2605 | GNUNET_free (hdr); | 2606 | GNUNET_free (hdr); |
2606 | } | 2607 | } |
2607 | 2608 | ||
2608 | 2609 | ||
2609 | /** | 2610 | /** |
2610 | * Communicator requests backchannel transmission. Process the request. | 2611 | * Communicator requests backchannel transmission. Process the request. |
2611 | * | 2612 | * |
@@ -2623,7 +2624,7 @@ handle_communicator_backchannel (void *cls, | |||
2623 | struct TransportBackchannelRequestPayload ppay; | 2624 | struct TransportBackchannelRequestPayload ppay; |
2624 | char *mpos; | 2625 | char *mpos; |
2625 | uint16_t msize; | 2626 | uint16_t msize; |
2626 | 2627 | ||
2627 | /* encapsulate and encrypt message */ | 2628 | /* encapsulate and encrypt message */ |
2628 | msize = ntohs (cb->header.size) - sizeof (*cb) + sizeof (struct TransportBackchannelRequestPayload); | 2629 | msize = ntohs (cb->header.size) - sizeof (*cb) + sizeof (struct TransportBackchannelRequestPayload); |
2629 | enc = GNUNET_malloc (sizeof (*enc) + msize); | 2630 | enc = GNUNET_malloc (sizeof (*enc) + msize); |
@@ -2858,7 +2859,7 @@ struct CommunicatorMessageContext | |||
2858 | * | 2859 | * |
2859 | * @param cmc context for demultiplexing | 2860 | * @param cmc context for demultiplexing |
2860 | * @param msg message to demultiplex | 2861 | * @param msg message to demultiplex |
2861 | */ | 2862 | */ |
2862 | static void | 2863 | static void |
2863 | demultiplex_with_cmc (struct CommunicatorMessageContext *cmc, | 2864 | demultiplex_with_cmc (struct CommunicatorMessageContext *cmc, |
2864 | const struct GNUNET_MessageHeader *msg); | 2865 | const struct GNUNET_MessageHeader *msg); |
@@ -2936,7 +2937,7 @@ handle_raw_message (void *cls, | |||
2936 | env); | 2937 | env); |
2937 | } | 2938 | } |
2938 | /* FIXME: consider doing this _only_ once the message | 2939 | /* FIXME: consider doing this _only_ once the message |
2939 | was drained from the CORE MQs to extend flow control to CORE! | 2940 | was drained from the CORE MQs to extend flow control to CORE! |
2940 | (basically, increment counter in cmc, decrement on MQ send continuation! */ | 2941 | (basically, increment counter in cmc, decrement on MQ send continuation! */ |
2941 | finish_cmc_handling (cmc); | 2942 | finish_cmc_handling (cmc); |
2942 | } | 2943 | } |
@@ -2961,12 +2962,12 @@ check_fragment_box (void *cls, | |||
2961 | GNUNET_break_op (0); | 2962 | GNUNET_break_op (0); |
2962 | return GNUNET_SYSERR; | 2963 | return GNUNET_SYSERR; |
2963 | } | 2964 | } |
2964 | if (bsize + ntohs (fb->frag_off) > ntohs (fb->msg_size)) | 2965 | if (bsize + ntohs (fb->frag_off) > ntohs (fb->msg_size)) |
2965 | { | 2966 | { |
2966 | GNUNET_break_op (0); | 2967 | GNUNET_break_op (0); |
2967 | return GNUNET_SYSERR; | 2968 | return GNUNET_SYSERR; |
2968 | } | 2969 | } |
2969 | if (ntohs (fb->frag_off) >= ntohs (fb->msg_size)) | 2970 | if (ntohs (fb->frag_off) >= ntohs (fb->msg_size)) |
2970 | { | 2971 | { |
2971 | GNUNET_break_op (0); | 2972 | GNUNET_break_op (0); |
2972 | return GNUNET_SYSERR; | 2973 | return GNUNET_SYSERR; |
@@ -3033,7 +3034,7 @@ handle_fragment_box (void *cls, | |||
3033 | if (NULL == n) | 3034 | if (NULL == n) |
3034 | { | 3035 | { |
3035 | struct GNUNET_SERVICE_Client *client = cmc->tc->client; | 3036 | struct GNUNET_SERVICE_Client *client = cmc->tc->client; |
3036 | 3037 | ||
3037 | GNUNET_break (0); | 3038 | GNUNET_break (0); |
3038 | finish_cmc_handling (cmc); | 3039 | finish_cmc_handling (cmc); |
3039 | GNUNET_SERVICE_client_drop (client); | 3040 | GNUNET_SERVICE_client_drop (client); |
@@ -3083,7 +3084,7 @@ handle_fragment_box (void *cls, | |||
3083 | finish_cmc_handling (cmc); | 3084 | finish_cmc_handling (cmc); |
3084 | return; | 3085 | return; |
3085 | } | 3086 | } |
3086 | 3087 | ||
3087 | /* reassemble */ | 3088 | /* reassemble */ |
3088 | fsize = ntohs (fb->header.size) - sizeof (*fb); | 3089 | fsize = ntohs (fb->header.size) - sizeof (*fb); |
3089 | frag_off = ntohs (fb->frag_off); | 3090 | frag_off = ntohs (fb->frag_off); |
@@ -3099,7 +3100,7 @@ handle_fragment_box (void *cls, | |||
3099 | rc->msg_missing--; | 3100 | rc->msg_missing--; |
3100 | } | 3101 | } |
3101 | } | 3102 | } |
3102 | 3103 | ||
3103 | /* Compute cummulative ACK */ | 3104 | /* Compute cummulative ACK */ |
3104 | frag_uuid = ntohl (fb->frag_uuid); | 3105 | frag_uuid = ntohl (fb->frag_uuid); |
3105 | cdelay = GNUNET_TIME_absolute_get_duration (rc->last_frag); | 3106 | cdelay = GNUNET_TIME_absolute_get_duration (rc->last_frag); |
@@ -3138,7 +3139,7 @@ handle_fragment_box (void *cls, | |||
3138 | ( (rc->frag_uuid < frag_uuid + 64) && | 3139 | ( (rc->frag_uuid < frag_uuid + 64) && |
3139 | (rc->extra_acks == (rc->extra_acks & ~ ((1LLU << (64 - (rc->frag_uuid - frag_uuid))) - 1LLU))) ) ) ) | 3140 | (rc->extra_acks == (rc->extra_acks & ~ ((1LLU << (64 - (rc->frag_uuid - frag_uuid))) - 1LLU))) ) ) ) |
3140 | { | 3141 | { |
3141 | /* can fit ack by shifting extra acks and starting at | 3142 | /* can fit ack by shifting extra acks and starting at |
3142 | frag_uid, test above esured that the bits we will | 3143 | frag_uid, test above esured that the bits we will |
3143 | shift 'extra_acks' by are all zero. */ | 3144 | shift 'extra_acks' by are all zero. */ |
3144 | rc->extra_acks <<= (rc->frag_uuid - frag_uuid); | 3145 | rc->extra_acks <<= (rc->frag_uuid - frag_uuid); |
@@ -3149,8 +3150,8 @@ handle_fragment_box (void *cls, | |||
3149 | if (65 == rc->num_acks) /* FIXME: maybe use smaller threshold? This is very aggressive. */ | 3150 | if (65 == rc->num_acks) /* FIXME: maybe use smaller threshold? This is very aggressive. */ |
3150 | ack_now = GNUNET_YES; /* maximum acks received */ | 3151 | ack_now = GNUNET_YES; /* maximum acks received */ |
3151 | // FIXME: possibly also ACK based on RTT (but for that we'd need to | 3152 | // FIXME: possibly also ACK based on RTT (but for that we'd need to |
3152 | // determine the session used for the ACK first!) | 3153 | // determine the session used for the ACK first!) |
3153 | 3154 | ||
3154 | /* is reassembly complete? */ | 3155 | /* is reassembly complete? */ |
3155 | if (0 != rc->msg_missing) | 3156 | if (0 != rc->msg_missing) |
3156 | { | 3157 | { |
@@ -3174,7 +3175,7 @@ handle_fragment_box (void *cls, | |||
3174 | msg); | 3175 | msg); |
3175 | /* FIXME: really free here? Might be bad if fragments are still | 3176 | /* FIXME: really free here? Might be bad if fragments are still |
3176 | en-route and we forget that we finished this reassembly immediately! | 3177 | en-route and we forget that we finished this reassembly immediately! |
3177 | -> keep around until timeout? | 3178 | -> keep around until timeout? |
3178 | -> shorten timeout based on ACK? */ | 3179 | -> shorten timeout based on ACK? */ |
3179 | free_reassembly_context (rc); | 3180 | free_reassembly_context (rc); |
3180 | } | 3181 | } |
@@ -3191,7 +3192,7 @@ handle_fragment_ack (void *cls, | |||
3191 | const struct TransportFragmentAckMessage *fa) | 3192 | const struct TransportFragmentAckMessage *fa) |
3192 | { | 3193 | { |
3193 | struct CommunicatorMessageContext *cmc = cls; | 3194 | struct CommunicatorMessageContext *cmc = cls; |
3194 | 3195 | ||
3195 | // FIXME: do work: identify original message; then identify fragments being acked; | 3196 | // FIXME: do work: identify original message; then identify fragments being acked; |
3196 | // remove those from the tree to prevent retransmission; | 3197 | // remove those from the tree to prevent retransmission; |
3197 | // compute RTT | 3198 | // compute RTT |
@@ -3235,10 +3236,10 @@ handle_reliability_box (void *cls, | |||
3235 | 3236 | ||
3236 | /* FIXME: implement cummulative ACKs and ack_countdown, | 3237 | /* FIXME: implement cummulative ACKs and ack_countdown, |
3237 | then setting the avg_ack_delay field below: */ | 3238 | then setting the avg_ack_delay field below: */ |
3238 | ack = GNUNET_malloc (sizeof (*ack) + | 3239 | ack = GNUNET_malloc (sizeof (*ack) + |
3239 | sizeof (struct GNUNET_ShortHashCode)); | 3240 | sizeof (struct GNUNET_ShortHashCode)); |
3240 | ack->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_RELIABILITY_ACK); | 3241 | ack->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_RELIABILITY_ACK); |
3241 | ack->header.size = htons (sizeof (*ack) + | 3242 | ack->header.size = htons (sizeof (*ack) + |
3242 | sizeof (struct GNUNET_ShortHashCode)); | 3243 | sizeof (struct GNUNET_ShortHashCode)); |
3243 | memcpy (&ack[1], | 3244 | memcpy (&ack[1], |
3244 | &rb->msg_uuid, | 3245 | &rb->msg_uuid, |
@@ -3263,7 +3264,7 @@ handle_reliability_ack (void *cls, | |||
3263 | const struct TransportReliabilityAckMessage *ra) | 3264 | const struct TransportReliabilityAckMessage *ra) |
3264 | { | 3265 | { |
3265 | struct CommunicatorMessageContext *cmc = cls; | 3266 | struct CommunicatorMessageContext *cmc = cls; |
3266 | 3267 | ||
3267 | // FIXME: do work: find message that was acknowledged, and | 3268 | // FIXME: do work: find message that was acknowledged, and |
3268 | // remove from transmission queue; update RTT. | 3269 | // remove from transmission queue; update RTT. |
3269 | finish_cmc_handling (cmc); | 3270 | finish_cmc_handling (cmc); |
@@ -3318,7 +3319,7 @@ handle_backchannel_encapsulation (void *cls, | |||
3318 | // FIXME: check HMAC | 3319 | // FIXME: check HMAC |
3319 | // FIXME: decrypt payload | 3320 | // FIXME: decrypt payload |
3320 | // FIXME: forward to specified communicator! | 3321 | // FIXME: forward to specified communicator! |
3321 | // (using GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL_INCOMING) | 3322 | // (using GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL_INCOMING) |
3322 | finish_cmc_handling (cmc); | 3323 | finish_cmc_handling (cmc); |
3323 | } | 3324 | } |
3324 | 3325 | ||
@@ -3375,7 +3376,7 @@ handle_dv_learn (void *cls, | |||
3375 | const struct TransportDVLearn *dvl) | 3376 | const struct TransportDVLearn *dvl) |
3376 | { | 3377 | { |
3377 | struct CommunicatorMessageContext *cmc = cls; | 3378 | struct CommunicatorMessageContext *cmc = cls; |
3378 | 3379 | ||
3379 | // FIXME: learn path from DV message (if bi-directional flags are set) | 3380 | // FIXME: learn path from DV message (if bi-directional flags are set) |
3380 | // FIXME: expand DV message, forward on (unless path is getting too long) | 3381 | // FIXME: expand DV message, forward on (unless path is getting too long) |
3381 | finish_cmc_handling (cmc); | 3382 | finish_cmc_handling (cmc); |
@@ -3406,7 +3407,7 @@ check_dv_box (void *cls, | |||
3406 | return GNUNET_SYSERR; | 3407 | return GNUNET_SYSERR; |
3407 | } | 3408 | } |
3408 | isize = ntohs (inbox->size); | 3409 | isize = ntohs (inbox->size); |
3409 | if (size != sizeof (*dvb) + num_hops * sizeof (struct GNUNET_PeerIdentity) + isize) | 3410 | if (size != sizeof (*dvb) + num_hops * sizeof (struct GNUNET_PeerIdentity) + isize) |
3410 | { | 3411 | { |
3411 | GNUNET_break_op (0); | 3412 | GNUNET_break_op (0); |
3412 | return GNUNET_SYSERR; | 3413 | return GNUNET_SYSERR; |
@@ -3442,14 +3443,14 @@ handle_dv_box (void *cls, | |||
3442 | { | 3443 | { |
3443 | // FIXME: if we are not the target, shorten path and forward along. | 3444 | // FIXME: if we are not the target, shorten path and forward along. |
3444 | // Try from the _end_ of hops array if we know the given | 3445 | // Try from the _end_ of hops array if we know the given |
3445 | // neighbour (shortening the path!). | 3446 | // neighbour (shortening the path!). |
3446 | // NOTE: increment total_hops! | 3447 | // NOTE: increment total_hops! |
3447 | finish_cmc_handling (cmc); | 3448 | finish_cmc_handling (cmc); |
3448 | return; | 3449 | return; |
3449 | } | 3450 | } |
3450 | /* We are the target. Unbox and handle message. */ | 3451 | /* We are the target. Unbox and handle message. */ |
3451 | cmc->im.sender = dvb->origin; | 3452 | cmc->im.sender = dvb->origin; |
3452 | cmc->total_hops = ntohs (dvb->total_hops); | 3453 | cmc->total_hops = ntohs (dvb->total_hops); |
3453 | demultiplex_with_cmc (cmc, | 3454 | demultiplex_with_cmc (cmc, |
3454 | inbox); | 3455 | inbox); |
3455 | } | 3456 | } |
@@ -3503,7 +3504,7 @@ handle_incoming_msg (void *cls, | |||
3503 | * | 3504 | * |
3504 | * @param cmc context for demultiplexing | 3505 | * @param cmc context for demultiplexing |
3505 | * @param msg message to demultiplex | 3506 | * @param msg message to demultiplex |
3506 | */ | 3507 | */ |
3507 | static void | 3508 | static void |
3508 | demultiplex_with_cmc (struct CommunicatorMessageContext *cmc, | 3509 | demultiplex_with_cmc (struct CommunicatorMessageContext *cmc, |
3509 | const struct GNUNET_MessageHeader *msg) | 3510 | const struct GNUNET_MessageHeader *msg) |
@@ -3593,7 +3594,7 @@ tracker_update_in_cb (void *cls) | |||
3593 | struct GNUNET_ATS_Session *queue = cls; | 3594 | struct GNUNET_ATS_Session *queue = cls; |
3594 | struct GNUNET_TIME_Relative in_delay; | 3595 | struct GNUNET_TIME_Relative in_delay; |
3595 | unsigned int rsize; | 3596 | unsigned int rsize; |
3596 | 3597 | ||
3597 | rsize = (0 == queue->mtu) ? IN_PACKET_SIZE_WITHOUT_MTU : queue->mtu; | 3598 | rsize = (0 == queue->mtu) ? IN_PACKET_SIZE_WITHOUT_MTU : queue->mtu; |
3598 | in_delay = GNUNET_BANDWIDTH_tracker_get_delay (&queue->tracker_in, | 3599 | in_delay = GNUNET_BANDWIDTH_tracker_get_delay (&queue->tracker_in, |
3599 | rsize); | 3600 | rsize); |
@@ -3619,7 +3620,7 @@ set_pending_message_uuid (struct PendingMessage *pm) | |||
3619 | 3620 | ||
3620 | 3621 | ||
3621 | /** | 3622 | /** |
3622 | * Fragment the given @a pm to the given @a mtu. Adds | 3623 | * Fragment the given @a pm to the given @a mtu. Adds |
3623 | * additional fragments to the neighbour as well. If the | 3624 | * additional fragments to the neighbour as well. If the |
3624 | * @a mtu is too small, generates and error for the @a pm | 3625 | * @a mtu is too small, generates and error for the @a pm |
3625 | * and returns NULL. | 3626 | * and returns NULL. |
@@ -3635,7 +3636,7 @@ fragment_message (struct PendingMessage *pm, | |||
3635 | struct PendingMessage *ff; | 3636 | struct PendingMessage *ff; |
3636 | 3637 | ||
3637 | set_pending_message_uuid (pm); | 3638 | set_pending_message_uuid (pm); |
3638 | 3639 | ||
3639 | /* This invariant is established in #handle_add_queue_message() */ | 3640 | /* This invariant is established in #handle_add_queue_message() */ |
3640 | GNUNET_assert (mtu > sizeof (struct TransportFragmentBox)); | 3641 | GNUNET_assert (mtu > sizeof (struct TransportFragmentBox)); |
3641 | 3642 | ||
@@ -3743,7 +3744,7 @@ reliability_box_message (struct PendingMessage *pm) | |||
3743 | if (NULL != pm->bpm) | 3744 | if (NULL != pm->bpm) |
3744 | return pm->bpm; /* already computed earlier: do nothing */ | 3745 | return pm->bpm; /* already computed earlier: do nothing */ |
3745 | GNUNET_assert (NULL == pm->head_frag); | 3746 | GNUNET_assert (NULL == pm->head_frag); |
3746 | if (pm->bytes_msg + sizeof (rbox) > UINT16_MAX) | 3747 | if (pm->bytes_msg + sizeof (rbox) > UINT16_MAX) |
3747 | { | 3748 | { |
3748 | /* failed hard */ | 3749 | /* failed hard */ |
3749 | GNUNET_break (0); | 3750 | GNUNET_break (0); |
@@ -3753,7 +3754,7 @@ reliability_box_message (struct PendingMessage *pm) | |||
3753 | return NULL; | 3754 | return NULL; |
3754 | } | 3755 | } |
3755 | bpm = GNUNET_malloc (sizeof (struct PendingMessage) + | 3756 | bpm = GNUNET_malloc (sizeof (struct PendingMessage) + |
3756 | sizeof (rbox) + | 3757 | sizeof (rbox) + |
3757 | pm->bytes_msg); | 3758 | pm->bytes_msg); |
3758 | bpm->target = pm->target; | 3759 | bpm->target = pm->target; |
3759 | bpm->frag_parent = pm; | 3760 | bpm->frag_parent = pm; |
@@ -3783,12 +3784,12 @@ reliability_box_message (struct PendingMessage *pm) | |||
3783 | 3784 | ||
3784 | /** | 3785 | /** |
3785 | * We believe we are ready to transmit a message on a queue. Double-checks | 3786 | * We believe we are ready to transmit a message on a queue. Double-checks |
3786 | * with the queue's "tracker_out" and then gives the message to the | 3787 | * with the queue's "tracker_out" and then gives the message to the |
3787 | * communicator for transmission (updating the tracker, and re-scheduling | 3788 | * communicator for transmission (updating the tracker, and re-scheduling |
3788 | * itself if applicable). | 3789 | * itself if applicable). |
3789 | * | 3790 | * |
3790 | * @param cls the `struct GNUNET_ATS_Session` to process transmissions for | 3791 | * @param cls the `struct GNUNET_ATS_Session` to process transmissions for |
3791 | */ | 3792 | */ |
3792 | static void | 3793 | static void |
3793 | transmit_on_queue (void *cls) | 3794 | transmit_on_queue (void *cls) |
3794 | { | 3795 | { |
@@ -3805,7 +3806,7 @@ transmit_on_queue (void *cls) | |||
3805 | if (NULL == (pm = n->pending_msg_head)) | 3806 | if (NULL == (pm = n->pending_msg_head)) |
3806 | { | 3807 | { |
3807 | /* no message pending, nothing to do here! */ | 3808 | /* no message pending, nothing to do here! */ |
3808 | return; | 3809 | return; |
3809 | } | 3810 | } |
3810 | schedule_transmit_on_queue (queue); | 3811 | schedule_transmit_on_queue (queue); |
3811 | if (NULL != queue->transmit_task) | 3812 | if (NULL != queue->transmit_task) |
@@ -3861,7 +3862,7 @@ transmit_on_queue (void *cls) | |||
3861 | queue->tc->details.communicator.total_queue_length++; | 3862 | queue->tc->details.communicator.total_queue_length++; |
3862 | GNUNET_MQ_send (queue->tc->mq, | 3863 | GNUNET_MQ_send (queue->tc->mq, |
3863 | env); | 3864 | env); |
3864 | 3865 | ||
3865 | // FIXME: do something similar to the logic below | 3866 | // FIXME: do something similar to the logic below |
3866 | // in defragmentation / reliability ACK handling! | 3867 | // in defragmentation / reliability ACK handling! |
3867 | 3868 | ||
@@ -3879,7 +3880,7 @@ transmit_on_queue (void *cls) | |||
3879 | (PMT_FRAGMENT_BOX == s->pmt) ) | 3880 | (PMT_FRAGMENT_BOX == s->pmt) ) |
3880 | { | 3881 | { |
3881 | struct PendingMessage *pos; | 3882 | struct PendingMessage *pos; |
3882 | 3883 | ||
3883 | /* Fragment sent over reliabile channel */ | 3884 | /* Fragment sent over reliabile channel */ |
3884 | free_fragment_tree (s); | 3885 | free_fragment_tree (s); |
3885 | pos = s->frag_parent; | 3886 | pos = s->frag_parent; |
@@ -3899,9 +3900,9 @@ transmit_on_queue (void *cls) | |||
3899 | pos->head_frag, | 3900 | pos->head_frag, |
3900 | pos->tail_frag, | 3901 | pos->tail_frag, |
3901 | s); | 3902 | s); |
3902 | GNUNET_free (s); | 3903 | GNUNET_free (s); |
3903 | } | 3904 | } |
3904 | 3905 | ||
3905 | /* Was this the last applicable fragmment? */ | 3906 | /* Was this the last applicable fragmment? */ |
3906 | if ( (NULL == pm->head_frag) && | 3907 | if ( (NULL == pm->head_frag) && |
3907 | (pm->frag_off == pm->bytes_msg) ) | 3908 | (pm->frag_off == pm->bytes_msg) ) |
@@ -3968,7 +3969,7 @@ transmit_on_queue (void *cls) | |||
3968 | s); | 3969 | s); |
3969 | } | 3970 | } |
3970 | } | 3971 | } |
3971 | 3972 | ||
3972 | /* finally, re-schedule queue transmission task itself */ | 3973 | /* finally, re-schedule queue transmission task itself */ |
3973 | schedule_transmit_on_queue (queue); | 3974 | schedule_transmit_on_queue (queue); |
3974 | } | 3975 | } |
@@ -4010,13 +4011,13 @@ tracker_excess_out_cb (void *cls) | |||
4010 | { | 4011 | { |
4011 | /* FIXME: trigger excess bandwidth report to core? Right now, | 4012 | /* FIXME: trigger excess bandwidth report to core? Right now, |
4012 | this is done internally within transport_api2_core already, | 4013 | this is done internally within transport_api2_core already, |
4013 | but we probably want to change the logic and trigger it | 4014 | but we probably want to change the logic and trigger it |
4014 | from here via a message instead! */ | 4015 | from here via a message instead! */ |
4015 | /* TODO: maybe inform ATS at this point? */ | 4016 | /* TODO: maybe inform ATS at this point? */ |
4016 | GNUNET_STATISTICS_update (GST_stats, | 4017 | GNUNET_STATISTICS_update (GST_stats, |
4017 | "# Excess outbound bandwidth reported", | 4018 | "# Excess outbound bandwidth reported", |
4018 | 1, | 4019 | 1, |
4019 | GNUNET_NO); | 4020 | GNUNET_NO); |
4020 | } | 4021 | } |
4021 | 4022 | ||
4022 | 4023 | ||
@@ -4034,7 +4035,7 @@ tracker_excess_in_cb (void *cls) | |||
4034 | GNUNET_STATISTICS_update (GST_stats, | 4035 | GNUNET_STATISTICS_update (GST_stats, |
4035 | "# Excess inbound bandwidth reported", | 4036 | "# Excess inbound bandwidth reported", |
4036 | 1, | 4037 | 1, |
4037 | GNUNET_NO); | 4038 | GNUNET_NO); |
4038 | } | 4039 | } |
4039 | 4040 | ||
4040 | 4041 | ||
@@ -4113,7 +4114,7 @@ handle_add_queue_message (void *cls, | |||
4113 | .nt = queue->nt, | 4114 | .nt = queue->nt, |
4114 | .cc = tc->details.communicator.cc | 4115 | .cc = tc->details.communicator.cc |
4115 | }; | 4116 | }; |
4116 | 4117 | ||
4117 | queue->sr = GNUNET_ATS_session_add (ats, | 4118 | queue->sr = GNUNET_ATS_session_add (ats, |
4118 | &neighbour->pid, | 4119 | &neighbour->pid, |
4119 | queue->address, | 4120 | queue->address, |
@@ -4211,7 +4212,7 @@ handle_send_message_ack (void *cls, | |||
4211 | { | 4212 | { |
4212 | struct TransportClient *tc = cls; | 4213 | struct TransportClient *tc = cls; |
4213 | struct QueueEntry *queue; | 4214 | struct QueueEntry *queue; |
4214 | 4215 | ||
4215 | if (CT_COMMUNICATOR != tc->type) | 4216 | if (CT_COMMUNICATOR != tc->type) |
4216 | { | 4217 | { |
4217 | GNUNET_break (0); | 4218 | GNUNET_break (0); |
@@ -4238,12 +4239,12 @@ handle_send_message_ack (void *cls, | |||
4238 | queue = qe; | 4239 | queue = qe; |
4239 | break; | 4240 | break; |
4240 | } | 4241 | } |
4241 | break; | 4242 | break; |
4242 | } | 4243 | } |
4243 | if (NULL == queue) | 4244 | if (NULL == queue) |
4244 | { | 4245 | { |
4245 | /* this should never happen */ | 4246 | /* this should never happen */ |
4246 | GNUNET_break (0); | 4247 | GNUNET_break (0); |
4247 | GNUNET_SERVICE_client_drop (tc->client); | 4248 | GNUNET_SERVICE_client_drop (tc->client); |
4248 | return; | 4249 | return; |
4249 | } | 4250 | } |
@@ -4273,10 +4274,10 @@ handle_send_message_ack (void *cls, | |||
4273 | GNUNET_STATISTICS_update (GST_stats, | 4274 | GNUNET_STATISTICS_update (GST_stats, |
4274 | "# Transmission throttled due to session queue limit", | 4275 | "# Transmission throttled due to session queue limit", |
4275 | -1, | 4276 | -1, |
4276 | GNUNET_NO); | 4277 | GNUNET_NO); |
4277 | schedule_transmit_on_queue (queue->session); | 4278 | schedule_transmit_on_queue (queue->session); |
4278 | } | 4279 | } |
4279 | 4280 | ||
4280 | /* TODO: we also should react on the status! */ | 4281 | /* TODO: we also should react on the status! */ |
4281 | // FIXME: this probably requires queue->pm = s assignment! | 4282 | // FIXME: this probably requires queue->pm = s assignment! |
4282 | // FIXME: react to communicator status about transmission request. We got: | 4283 | // FIXME: react to communicator status about transmission request. We got: |
@@ -4439,7 +4440,7 @@ ats_suggestion_cb (void *cls, | |||
4439 | GNUNET_STATISTICS_update (GST_stats, | 4440 | GNUNET_STATISTICS_update (GST_stats, |
4440 | "# ATS suggestions ignored due to missing communicator", | 4441 | "# ATS suggestions ignored due to missing communicator", |
4441 | 1, | 4442 | 1, |
4442 | GNUNET_NO); | 4443 | GNUNET_NO); |
4443 | return; | 4444 | return; |
4444 | } | 4445 | } |
4445 | /* forward suggestion for queue creation to communicator */ | 4446 | /* forward suggestion for queue creation to communicator */ |
@@ -4468,7 +4469,7 @@ ats_suggestion_cb (void *cls, | |||
4468 | * | 4469 | * |
4469 | * @param cls the `struct TransportClient` | 4470 | * @param cls the `struct TransportClient` |
4470 | * @param cqr confirmation message | 4471 | * @param cqr confirmation message |
4471 | */ | 4472 | */ |
4472 | static void | 4473 | static void |
4473 | handle_queue_create_ok (void *cls, | 4474 | handle_queue_create_ok (void *cls, |
4474 | const struct GNUNET_TRANSPORT_CreateQueueResponse *cqr) | 4475 | const struct GNUNET_TRANSPORT_CreateQueueResponse *cqr) |
@@ -4488,7 +4489,7 @@ handle_queue_create_ok (void *cls, | |||
4488 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 4489 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
4489 | "Request #%u for communicator to create queue succeeded\n", | 4490 | "Request #%u for communicator to create queue succeeded\n", |
4490 | (unsigned int) ntohs (cqr->request_id)); | 4491 | (unsigned int) ntohs (cqr->request_id)); |
4491 | GNUNET_SERVICE_client_continue (tc->client); | 4492 | GNUNET_SERVICE_client_continue (tc->client); |
4492 | } | 4493 | } |
4493 | 4494 | ||
4494 | 4495 | ||
@@ -4499,7 +4500,7 @@ handle_queue_create_ok (void *cls, | |||
4499 | * | 4500 | * |
4500 | * @param cls the `struct TransportClient` | 4501 | * @param cls the `struct TransportClient` |
4501 | * @param cqr failure message | 4502 | * @param cqr failure message |
4502 | */ | 4503 | */ |
4503 | static void | 4504 | static void |
4504 | handle_queue_create_fail (void *cls, | 4505 | handle_queue_create_fail (void *cls, |
4505 | const struct GNUNET_TRANSPORT_CreateQueueResponse *cqr) | 4506 | const struct GNUNET_TRANSPORT_CreateQueueResponse *cqr) |
@@ -4519,7 +4520,61 @@ handle_queue_create_fail (void *cls, | |||
4519 | "# ATS suggestions failed in queue creation at communicator", | 4520 | "# ATS suggestions failed in queue creation at communicator", |
4520 | 1, | 4521 | 1, |
4521 | GNUNET_NO); | 4522 | GNUNET_NO); |
4522 | GNUNET_SERVICE_client_continue (tc->client); | 4523 | GNUNET_SERVICE_client_continue (tc->client); |
4524 | } | ||
4525 | |||
4526 | |||
4527 | /** | ||
4528 | * Check #GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_CONSIDER_VERIFY | ||
4529 | * messages. We do nothing here, real verification is done later. | ||
4530 | * | ||
4531 | * @param cls a `struct TransportClient *` | ||
4532 | * @param msg message to verify | ||
4533 | * @return #GNUNET_OK | ||
4534 | */ | ||
4535 | static int | ||
4536 | check_address_consider_verify (void *cls, | ||
4537 | const struct GNUNET_TRANSPORT_AddressToVerify *hdr) | ||
4538 | { | ||
4539 | (void) cls; | ||
4540 | (void) hdr; | ||
4541 | return GNUNET_OK; | ||
4542 | } | ||
4543 | |||
4544 | |||
4545 | /** | ||
4546 | * Given another peers address, consider checking it for validity | ||
4547 | * and then adding it to the Peerstore. | ||
4548 | * | ||
4549 | * @param cls a `struct TransportClient` | ||
4550 | * @param hdr message containing the raw address data and | ||
4551 | * signature in the body, see #GNUNET_HELLO_extract_address() | ||
4552 | */ | ||
4553 | static void | ||
4554 | handle_address_consider_verify (void *cls, | ||
4555 | const struct GNUNET_TRANSPORT_AddressToVerify *hdr) | ||
4556 | { | ||
4557 | char *address; | ||
4558 | enum GNUNET_NetworkType nt; | ||
4559 | struct GNUNET_TIME_Absolute expiration; | ||
4560 | |||
4561 | (void) cls; | ||
4562 | // FIXME: pre-check: do we know this address already? | ||
4563 | // FIXME: pre-check: rate-limit signature verification / validation! | ||
4564 | address = GNUNET_HELLO_extract_address (&hdr[1], | ||
4565 | ntohs (hdr->header.size) - sizeof (*hdr), | ||
4566 | &hdr->peer, | ||
4567 | &nt, | ||
4568 | &expiration); | ||
4569 | if (NULL == address) | ||
4570 | { | ||
4571 | GNUNET_break_op (0); | ||
4572 | return; | ||
4573 | } | ||
4574 | if (0 == GNUNET_TIME_absolute_get_remaining (expiration).rel_value_us) | ||
4575 | return; /* expired */ | ||
4576 | // FIXME: do begin actual verification here! | ||
4577 | GNUNET_free (address); | ||
4523 | } | 4578 | } |
4524 | 4579 | ||
4525 | 4580 | ||
@@ -4762,6 +4817,10 @@ GNUNET_SERVICE_MAIN | |||
4762 | GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_SETUP, | 4817 | GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_SETUP, |
4763 | struct GNUNET_TRANSPORT_AddQueueMessage, | 4818 | struct GNUNET_TRANSPORT_AddQueueMessage, |
4764 | NULL), | 4819 | NULL), |
4820 | GNUNET_MQ_hd_var_size (address_consider_verify, | ||
4821 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_CONSIDER_VERIFY, | ||
4822 | struct GNUNET_TRANSPORT_AddressToVerify, | ||
4823 | NULL), | ||
4765 | GNUNET_MQ_hd_fixed_size (del_queue_message, | 4824 | GNUNET_MQ_hd_fixed_size (del_queue_message, |
4766 | GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_TEARDOWN, | 4825 | GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_TEARDOWN, |
4767 | struct GNUNET_TRANSPORT_DelQueueMessage, | 4826 | struct GNUNET_TRANSPORT_DelQueueMessage, |
diff --git a/src/transport/transport.h b/src/transport/transport.h index 931ba4810..c0e02c3d9 100644 --- a/src/transport/transport.h +++ b/src/transport/transport.h | |||
@@ -1081,6 +1081,32 @@ struct GNUNET_TRANSPORT_MonitorData | |||
1081 | 1081 | ||
1082 | }; | 1082 | }; |
1083 | 1083 | ||
1084 | |||
1085 | /** | ||
1086 | * Request to verify address. | ||
1087 | */ | ||
1088 | struct GNUNET_TRANSPORT_AddressToVerify | ||
1089 | { | ||
1090 | |||
1091 | /** | ||
1092 | * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_CONSIDER_VERIFY. | ||
1093 | */ | ||
1094 | struct GNUNET_MessageHeader header; | ||
1095 | |||
1096 | /** | ||
1097 | * Reserved. 0. | ||
1098 | */ | ||
1099 | uint32_t reserved; | ||
1100 | |||
1101 | /** | ||
1102 | * Peer the address is from. | ||
1103 | */ | ||
1104 | struct GNUNET_PeerIdentity peer; | ||
1105 | |||
1106 | /* followed by variable-size raw address */ | ||
1107 | }; | ||
1108 | |||
1109 | |||
1084 | #endif | 1110 | #endif |
1085 | 1111 | ||
1086 | GNUNET_NETWORK_STRUCT_END | 1112 | GNUNET_NETWORK_STRUCT_END |
diff --git a/src/transport/transport_api2_address.c b/src/transport/transport_api2_address.c index 0693a51ac..1ae1e5b1e 100644 --- a/src/transport/transport_api2_address.c +++ b/src/transport/transport_api2_address.c | |||
@@ -220,20 +220,23 @@ GNUNET_TRANSPORT_address_disconnect (struct GNUNET_TRANSPORT_AddressHandle *hand | |||
220 | * lost. | 220 | * lost. |
221 | * | 221 | * |
222 | * @param ch communicator handle | 222 | * @param ch communicator handle |
223 | * @param pid peer the address is for | ||
223 | * @param raw raw address data | 224 | * @param raw raw address data |
224 | * @param raw_size number of bytes in @a raw | 225 | * @param raw_size number of bytes in @a raw |
225 | */ | 226 | */ |
226 | void | 227 | void |
227 | GNUNET_TRANSPORT_address_try (struct GNUNET_TRANSPORT_AddressHandle *ch, | 228 | GNUNET_TRANSPORT_address_try (struct GNUNET_TRANSPORT_AddressHandle *ch, |
229 | const struct GNUNET_PeerIdentity *pid, | ||
228 | const void *raw, | 230 | const void *raw, |
229 | const size_t raw_size) | 231 | const size_t raw_size) |
230 | { | 232 | { |
231 | struct GNUNET_MQ_Envelope *env; | 233 | struct GNUNET_MQ_Envelope *env; |
232 | struct GNUNET_MessageHeader *hdr; | 234 | struct GNUNET_TRANSPORT_AddressToVerify *hdr; |
233 | 235 | ||
234 | env = GNUNET_MQ_msg_extra (hdr, | 236 | env = GNUNET_MQ_msg_extra (hdr, |
235 | raw_size, | 237 | raw_size, |
236 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_CONSIDER_VERIFY); | 238 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_CONSIDER_VERIFY); |
239 | hdr->peer = *pid; | ||
237 | memcpy (&hdr[1], | 240 | memcpy (&hdr[1], |
238 | raw, | 241 | raw, |
239 | raw_size); | 242 | raw_size); |