aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/include/gnunet_protocols.h5
-rw-r--r--src/transport/gnunet-service-tng.c72
-rw-r--r--src/transport/transport.h27
-rw-r--r--src/transport/transport_api2_communication.c50
4 files changed, 81 insertions, 73 deletions
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h
index a8d716b3f..7ef8dca8e 100644
--- a/src/include/gnunet_protocols.h
+++ b/src/include/gnunet_protocols.h
@@ -3125,9 +3125,10 @@ extern "C"
3125#define GNUNET_MESSAGE_TYPE_TRANSPORT_DV_BOX 1219 3125#define GNUNET_MESSAGE_TYPE_TRANSPORT_DV_BOX 1219
3126 3126
3127/** 3127/**
3128 * Transport affirming receipt of an ephemeral key. 3128 * Transport signalling incoming backchannel message to a communicator.
3129 */ 3129 */
3130#define GNUNET_MESSAGE_TYPE_TRANSPORT_EPHEMERAL_CONFIRMATION 1220 3130#define GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL_INCOMING 1220
3131
3131 3132
3132/** 3133/**
3133 * Message sent to indicate to the transport that a monitor 3134 * Message sent to indicate to the transport that a monitor
diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c
index b55cd2485..cb6fcebdc 100644
--- a/src/transport/gnunet-service-tng.c
+++ b/src/transport/gnunet-service-tng.c
@@ -34,6 +34,7 @@
34 * 34 *
35 * Implement: 35 * Implement:
36 * - manage defragmentation, retransmission, track RTT, loss, etc. 36 * - manage defragmentation, retransmission, track RTT, loss, etc.
37 * - DV data structures, learning, forgetting, using them!
37 * 38 *
38 * Easy: 39 * Easy:
39 * - use ATS bandwidth allocation callback and schedule transmissions! 40 * - use ATS bandwidth allocation callback and schedule transmissions!
@@ -153,6 +154,9 @@ struct TransportBackchannelEncapsulationMessage
153 */ 154 */
154 struct GNUNET_CRYPTO_EcdhePublicKey ephemeral_key; 155 struct GNUNET_CRYPTO_EcdhePublicKey ephemeral_key;
155 156
157 // FIXME: probably should add random IV here as well,
158 // especially if we re-use ephemeral keys!
159
156 /** 160 /**
157 * HMAC over the ciphertext of the encrypted, variable-size 161 * HMAC over the ciphertext of the encrypted, variable-size
158 * body that follows. Verified via DH of @e target and 162 * body that follows. Verified via DH of @e target and
@@ -177,8 +181,7 @@ struct EphemeralConfirmation
177 struct GNUNET_CRYPTO_EccSignaturePurpose purpose; 181 struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
178 182
179 /** 183 /**
180 * How long is this signature over the ephemeral key 184 * How long is this signature over the ephemeral key valid?
181 * valid?
182 */ 185 */
183 struct GNUNET_TIME_AbsoluteNBO ephemeral_validity; 186 struct GNUNET_TIME_AbsoluteNBO ephemeral_validity;
184 187
@@ -192,37 +195,6 @@ struct EphemeralConfirmation
192 195
193 196
194/** 197/**
195 * Message by which a peqer confirms that it is using an ephemeral
196 * key.
197 */
198struct EphemeralConfirmationMessage
199{
200
201 /**
202 * Message header, type is #GNUNET_MESSAGE_TYPE_TRANSPORT_EPHEMERAL_CONFIRMATION
203 */
204 struct GNUNET_MessageHeader header;
205
206 /**
207 * Must be zero.
208 */
209 uint32_t reserved;
210
211 /**
212 * How long is this signature over the ephemeral key
213 * valid?
214 */
215 struct GNUNET_TIME_AbsoluteNBO ephemeral_validity;
216
217 /**
218 * Ephemeral key setup by the sender for @e target, used
219 * to encrypt the payload.
220 */
221 struct GNUNET_CRYPTO_EcdhePublicKey ephemeral_key;
222};
223
224
225/**
226 * Plaintext of the variable-size payload that is encrypted 198 * Plaintext of the variable-size payload that is encrypted
227 * within a `struct TransportBackchannelEncapsulationMessage` 199 * within a `struct TransportBackchannelEncapsulationMessage`
228 */ 200 */
@@ -546,6 +518,10 @@ enum ClientType
546 518
547/** 519/**
548 * Entry in our cache of ephemeral keys we currently use. 520 * Entry in our cache of ephemeral keys we currently use.
521 * This way, we only sign an ephemeral once per @e target,
522 * and then can re-use it over multiple
523 * #GNUNET_MESSAGE_TYPE_TRANSPORT_BACKCHANNEL_ENCAPSULATION
524 * messages (as signing is expensive).
549 */ 525 */
550struct EphemeralCacheEntry 526struct EphemeralCacheEntry
551{ 527{
@@ -2525,31 +2501,7 @@ handle_backchannel_encapsulation (void *cls,
2525 // FIXME: check HMAC 2501 // FIXME: check HMAC
2526 // FIXME: decrypt payload 2502 // FIXME: decrypt payload
2527 // FIXME: forward to specified communicator! 2503 // FIXME: forward to specified communicator!
2528 2504 // (using GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL_INCOMING)
2529 finish_cmc_handling (cmc);
2530}
2531
2532
2533/**
2534 * Communicator gave us an ephemeral confirmation. Process the request.
2535 *
2536 * @param cls a `struct CommunicatorMessageContext` (must call #finish_cmc_handling() when done)
2537 * @param ec the message that was received
2538 */
2539static void
2540handle_ephemeral_confirmation (void *cls,
2541 const struct EphemeralConfirmationMessage *ec)
2542{
2543 struct CommunicatorMessageContext *cmc = cls;
2544
2545 // FIXME: notify communicator (?) about ephemeral confirmation!?
2546 // FIXME: or does this have something to do with the ephemeral_map?
2547 // where did I plan to use this message again!?
2548 // FIXME: communicator API has a very general notification API,
2549 // nothing specific for ephemeral keys;
2550 // why do we have a ephemeral key-specific message here?
2551 // => first revise where we get such messages from communicator
2552 // before processing further here!
2553 finish_cmc_handling (cmc); 2505 finish_cmc_handling (cmc);
2554} 2506}
2555 2507
@@ -2726,10 +2678,6 @@ handle_incoming_msg (void *cls,
2726 GNUNET_MESSAGE_TYPE_TRANSPORT_BACKCHANNEL_ENCAPSULATION, 2678 GNUNET_MESSAGE_TYPE_TRANSPORT_BACKCHANNEL_ENCAPSULATION,
2727 struct TransportBackchannelEncapsulationMessage, 2679 struct TransportBackchannelEncapsulationMessage,
2728 &cmc), 2680 &cmc),
2729 GNUNET_MQ_hd_fixed_size (ephemeral_confirmation,
2730 GNUNET_MESSAGE_TYPE_TRANSPORT_EPHEMERAL_CONFIRMATION,
2731 struct EphemeralConfirmationMessage,
2732 &cmc),
2733 GNUNET_MQ_hd_var_size (dv_learn, 2681 GNUNET_MQ_hd_var_size (dv_learn,
2734 GNUNET_MESSAGE_TYPE_TRANSPORT_DV_LEARN, 2682 GNUNET_MESSAGE_TYPE_TRANSPORT_DV_LEARN,
2735 struct TransportDVLearn, 2683 struct TransportDVLearn,
diff --git a/src/transport/transport.h b/src/transport/transport.h
index 24479e4c6..931ba4810 100644
--- a/src/transport/transport.h
+++ b/src/transport/transport.h
@@ -977,6 +977,33 @@ struct GNUNET_TRANSPORT_CommunicatorBackchannel
977}; 977};
978 978
979 979
980/**
981 * Message from transport to communicator passing along a backchannel
982 * message from the given peer @e pid.
983 */
984struct GNUNET_TRANSPORT_CommunicatorBackchannelIncoming
985{
986 /**
987 * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL_INCOMING
988 */
989 struct GNUNET_MessageHeader header;
990
991 /**
992 * Always zero, for alignment.
993 */
994 uint32_t reserved;
995
996 /**
997 * Origin peer.
998 */
999 struct GNUNET_PeerIdentity pid;
1000
1001 /* Followed by a `struct GNUNET_MessageHeader` with the encapsulated
1002 message to the communicator */
1003
1004};
1005
1006
980 1007
981/** 1008/**
982 * Request to start monitoring. 1009 * Request to start monitoring.
diff --git a/src/transport/transport_api2_communication.c b/src/transport/transport_api2_communication.c
index a816ecb67..ee1c788e5 100644
--- a/src/transport/transport_api2_communication.c
+++ b/src/transport/transport_api2_communication.c
@@ -22,6 +22,8 @@
22 * @file transport/transport_api2_communication.c 22 * @file transport/transport_api2_communication.c
23 * @brief implementation of the gnunet_transport_communication_service.h API 23 * @brief implementation of the gnunet_transport_communication_service.h API
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 *
26 * FIXME: handling of messages for "notify_cb" not implemented!
25 */ 27 */
26#include "platform.h" 28#include "platform.h"
27#include "gnunet_util_lib.h" 29#include "gnunet_util_lib.h"
@@ -618,15 +620,8 @@ static int
618check_send_msg (void *cls, 620check_send_msg (void *cls,
619 const struct GNUNET_TRANSPORT_SendMessageTo *smt) 621 const struct GNUNET_TRANSPORT_SendMessageTo *smt)
620{ 622{
621 uint16_t len = ntohs (smt->header.size) - sizeof (*smt);
622 const struct GNUNET_MessageHeader *mh = (const struct GNUNET_MessageHeader *) &smt[1];
623
624 (void) cls; 623 (void) cls;
625 if (ntohs (mh->size) != len) 624 GNUNET_MQ_check_boxed_message (smt);
626 {
627 GNUNET_break (0);
628 return GNUNET_SYSERR;
629 }
630 return GNUNET_OK; 625 return GNUNET_OK;
631} 626}
632 627
@@ -733,6 +728,40 @@ handle_send_msg (void *cls,
733 728
734 729
735/** 730/**
731 * Transport service gives us backchannel message. Check if @a bi
732 * is well-formed.
733 *
734 * @param cls our `struct GNUNET_TRANSPORT_CommunicatorHandle *`
735 * @param bi the backchannel message
736 * @return #GNUNET_OK if @a smt is well-formed
737 */
738static int
739check_backchannel_incoming (void *cls,
740 const struct GNUNET_TRANSPORT_CommunicatorBackchannelIncoming *bi)
741{
742 (void) cls;
743 GNUNET_MQ_check_boxed_message (bi);
744 return GNUNET_OK;
745}
746
747
748/**
749 * Transport service gives us backchannel message. Handle it.
750 *
751 * @param cls our `struct GNUNET_TRANSPORT_CommunicatorHandle *`
752 * @param bi the backchannel message
753 */
754static void
755handle_backchannel_incoming (void *cls,
756 const struct GNUNET_TRANSPORT_CommunicatorBackchannelIncoming *bi)
757{
758 struct GNUNET_TRANSPORT_CommunicatorHandle *ch = cls;
759
760 // FIXME: handle bi!
761}
762
763
764/**
736 * (re)connect our communicator to the transport service 765 * (re)connect our communicator to the transport service
737 * 766 *
738 * @param ch handle to reconnect 767 * @param ch handle to reconnect
@@ -753,7 +782,10 @@ reconnect (struct GNUNET_TRANSPORT_CommunicatorHandle *ch)
753 GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG, 782 GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG,
754 struct GNUNET_TRANSPORT_SendMessageTo, 783 struct GNUNET_TRANSPORT_SendMessageTo,
755 ch), 784 ch),
756 // FIXME: handle backchannel notifications! 785 GNUNET_MQ_hd_var_size (backchannel_incoming,
786 GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL_INCOMING,
787 struct GNUNET_TRANSPORT_CommunicatorBackchannelIncoming,
788 ch),
757 GNUNET_MQ_handler_end() 789 GNUNET_MQ_handler_end()
758 }; 790 };
759 struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *cam; 791 struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *cam;