aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-05-14 20:49:50 +0200
committerChristian Grothoff <christian@grothoff.org>2019-05-14 20:51:24 +0200
commitbf59da41dd5042cc679ae0e39755d9fad9cb80f0 (patch)
treef2fbdd5291ec6a94c54f3795cdcb1d38f234e163
parent2449f7d921edefef8db82591c8438e57859cdfde (diff)
downloadgnunet-bf59da41dd5042cc679ae0e39755d9fad9cb80f0.tar.gz
gnunet-bf59da41dd5042cc679ae0e39755d9fad9cb80f0.zip
modify messages for t2t-fc
-rw-r--r--src/include/gnunet_protocols.h8
-rw-r--r--src/transport/gnunet-service-tng.c86
2 files changed, 86 insertions, 8 deletions
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h
index 73da40038..9a1ef32ee 100644
--- a/src/include/gnunet_protocols.h
+++ b/src/include/gnunet_protocols.h
@@ -3196,9 +3196,15 @@ extern "C" {
3196#define GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_CHALLENGE 1303 3196#define GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_CHALLENGE 1303
3197 3197
3198/** 3198/**
3199 * P2P message: transport proves that an address worked and provides
3200 * a new challenge for the other direction.
3201 */
3202#define GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_CHALLENGE_RESPONSE 1304
3203
3204/**
3199 * P2P message: transport proves that an address worked. 3205 * P2P message: transport proves that an address worked.
3200 */ 3206 */
3201#define GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_RESPONSE 1304 3207#define GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_RESPONSE 1305
3202 3208
3203 3209
3204/* ************** NEW (NG) ATS Messages ************* */ 3210/* ************** NEW (NG) ATS Messages ************* */
diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c
index 727ef7f9c..54e6a7a3e 100644
--- a/src/transport/gnunet-service-tng.c
+++ b/src/transport/gnunet-service-tng.c
@@ -794,9 +794,23 @@ struct TransportValidationChallengeMessage
794 struct GNUNET_MessageHeader header; 794 struct GNUNET_MessageHeader header;
795 795
796 /** 796 /**
797 * Zero. 797 * Maximum number of kilobytes of the flow control window of
798 * the previous challenge that the sender may consume.
799 * After sending this message (with a new challenge),
800 * the sender promises to never use more than this number
801 * of kilobytes of the flow control window of a previous
802 * handshake. Note that the number set here might be larger
803 * than the actual number the sender will use: to avoid
804 * a stall, the sender would estimate how long it would
805 * take to receive a validation response and reserve itself
806 * a buffer so it can keep sending while waiting for the
807 * response. Note that the consumption limit must still be
808 * below the maximum value permitted by the receiver so far.
809 *
810 * If this is the first challenge (initial connection
811 * establishment), this value must be zero.
798 */ 812 */
799 uint32_t reserved GNUNET_PACKED; 813 uint32_t last_window_consum_limit_kb GNUNET_PACKED;
800 814
801 /** 815 /**
802 * Challenge to be signed by the receiving peer. 816 * Challenge to be signed by the receiving peer.
@@ -812,6 +826,62 @@ struct TransportValidationChallengeMessage
812 826
813 827
814/** 828/**
829 * Message send to another peer to answer to a validation challenge
830 * and at the same time issue a challenge in the other direction.
831 */
832struct TransportValidationChallengeResponseMessage
833{
834
835 /**
836 * Type is #GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_CHALLENGE_RESPONSE
837 */
838 struct GNUNET_MessageHeader header;
839
840 /**
841 * Flow control window size in kilobytes (1024 b), in NBO.
842 * The receiver can now send this many kilobytes as per
843 * the @e received_challenge "account".
844 */
845 uint32_t fc_window_size_kb GNUNET_PACKED;
846
847 /**
848 * Challenge returned to the origin by the receiving peer.
849 */
850 struct ChallengeNonceP received_challenge;
851
852 /**
853 * The peer's signature matching the
854 * #GNUNET_SIGNATURE_PURPOSE_TRANSPORT_CHALLENGE purpose.
855 */
856 struct GNUNET_CRYPTO_EddsaSignature signature;
857
858 /**
859 * Fresh challenge created by the sender to be returned
860 * by the receiving peer.
861 */
862 struct ChallengeNonceP sender_challenge;
863
864 /**
865 * How long does the sender believe the address on
866 * which the challenge was received to remain valid?
867 */
868 struct GNUNET_TIME_RelativeNBO validity_duration;
869
870 /**
871 * Timestamp of the sender, to be copied into the reply
872 * to allow sender to calculate RTT.
873 */
874 struct GNUNET_TIME_AbsoluteNBO origin_time;
875
876 /**
877 * Timestamp of the sender, to be copied into the reply
878 * to allow sender to calculate RTT.
879 */
880 struct GNUNET_TIME_AbsoluteNBO sender_time;
881};
882
883
884/**
815 * Message signed by a peer to confirm that it can indeed 885 * Message signed by a peer to confirm that it can indeed
816 * receive messages at a particular address. 886 * receive messages at a particular address.
817 */ 887 */
@@ -837,7 +907,7 @@ struct TransportValidationPS
837 907
838 908
839/** 909/**
840 * Message send to a peer to respond to a 910 * Message send to a peer to respond to a
841 * #GNUNET_MESSAGE_TYPE_ADDRESS_VALIDATION_CHALLENGE 911 * #GNUNET_MESSAGE_TYPE_ADDRESS_VALIDATION_CHALLENGE
842 */ 912 */
843struct TransportValidationResponseMessage 913struct TransportValidationResponseMessage
@@ -849,9 +919,11 @@ struct TransportValidationResponseMessage
849 struct GNUNET_MessageHeader header; 919 struct GNUNET_MessageHeader header;
850 920
851 /** 921 /**
852 * Zero. 922 * Flow control window size in kilobytes (1024 b), in NBO.
923 * The receiver can now send this many kilobytes as per
924 * the @e challenge "account".
853 */ 925 */
854 uint32_t reserved GNUNET_PACKED; 926 uint32_t fc_window_size_kb GNUNET_PACKED;
855 927
856 /** 928 /**
857 * The peer's signature matching the 929 * The peer's signature matching the
@@ -6253,7 +6325,7 @@ handle_dv_learn (void *cls, const struct TransportDVLearnMessage *dvl)
6253 htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_HOP), 6325 htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_HOP),
6254 .purpose.size = htonl (sizeof (dhp)), 6326 .purpose.size = htonl (sizeof (dhp)),
6255 .pred = (0 == i) ? dvl->initiator : hops[i - 1].hop, 6327 .pred = (0 == i) ? dvl->initiator : hops[i - 1].hop,
6256 .succ = (nhops - 1 == i) ? GST_my_identity 6328 .succ = (nhops == i + 1) ? GST_my_identity
6257 : hops[i + 1].hop, 6329 : hops[i + 1].hop,
6258 .challenge = dvl->challenge}; 6330 .challenge = dvl->challenge};
6259 6331
@@ -8291,7 +8363,7 @@ validation_transmit_on_queue (struct Queue *q, struct ValidationState *vs)
8291 tvc.header.type = 8363 tvc.header.type =
8292 htons (GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_CHALLENGE); 8364 htons (GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_CHALLENGE);
8293 tvc.header.size = htons (sizeof (tvc)); 8365 tvc.header.size = htons (sizeof (tvc));
8294 tvc.reserved = htonl (0); 8366 tvc.last_window_consum_limit_kb = htonl (0); // FIXME!
8295 tvc.challenge = vs->challenge; 8367 tvc.challenge = vs->challenge;
8296 tvc.sender_time = GNUNET_TIME_absolute_hton (vs->last_challenge_use); 8368 tvc.sender_time = GNUNET_TIME_absolute_hton (vs->last_challenge_use);
8297 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 8369 GNUNET_log (GNUNET_ERROR_TYPE_INFO,