summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-01-25 22:25:48 +0100
committerChristian Grothoff <christian@grothoff.org>2019-01-25 22:25:48 +0100
commit519cc35772b40b7966cc7c3bb03d5961f6f265d1 (patch)
tree0bc242a8760953bd28d12965892ec4542c285629 /src
parent392b3c355586179fdce6a565c467eeba96027bc5 (diff)
more on backchannel logic
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"
#define GNUNET_MESSAGE_TYPE_TRANSPORT_DV_BOX 1219
/**
- * Transport affirming receipt of an ephemeral key.
+ * Transport signalling incoming backchannel message to a communicator.
*/
-#define GNUNET_MESSAGE_TYPE_TRANSPORT_EPHEMERAL_CONFIRMATION 1220
+#define GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL_INCOMING 1220
+
/**
* 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 @@
*
* Implement:
* - manage defragmentation, retransmission, track RTT, loss, etc.
+ * - DV data structures, learning, forgetting, using them!
*
* Easy:
* - use ATS bandwidth allocation callback and schedule transmissions!
@@ -153,6 +154,9 @@ struct TransportBackchannelEncapsulationMessage
*/
struct GNUNET_CRYPTO_EcdhePublicKey ephemeral_key;
+ // FIXME: probably should add random IV here as well,
+ // especially if we re-use ephemeral keys!
+
/**
* HMAC over the ciphertext of the encrypted, variable-size
* body that follows. Verified via DH of @e target and
@@ -177,8 +181,7 @@ struct EphemeralConfirmation
struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
/**
- * How long is this signature over the ephemeral key
- * valid?
+ * How long is this signature over the ephemeral key valid?
*/
struct GNUNET_TIME_AbsoluteNBO ephemeral_validity;
@@ -192,37 +195,6 @@ struct EphemeralConfirmation
/**
- * Message by which a peqer confirms that it is using an ephemeral
- * key.
- */
-struct EphemeralConfirmationMessage
-{
-
- /**
- * Message header, type is #GNUNET_MESSAGE_TYPE_TRANSPORT_EPHEMERAL_CONFIRMATION
- */
- struct GNUNET_MessageHeader header;
-
- /**
- * Must be zero.
- */
- uint32_t reserved;
-
- /**
- * How long is this signature over the ephemeral key
- * valid?
- */
- struct GNUNET_TIME_AbsoluteNBO ephemeral_validity;
-
- /**
- * Ephemeral key setup by the sender for @e target, used
- * to encrypt the payload.
- */
- struct GNUNET_CRYPTO_EcdhePublicKey ephemeral_key;
-};
-
-
-/**
* Plaintext of the variable-size payload that is encrypted
* within a `struct TransportBackchannelEncapsulationMessage`
*/
@@ -546,6 +518,10 @@ enum ClientType
/**
* Entry in our cache of ephemeral keys we currently use.
+ * This way, we only sign an ephemeral once per @e target,
+ * and then can re-use it over multiple
+ * #GNUNET_MESSAGE_TYPE_TRANSPORT_BACKCHANNEL_ENCAPSULATION
+ * messages (as signing is expensive).
*/
struct EphemeralCacheEntry
{
@@ -2525,31 +2501,7 @@ handle_backchannel_encapsulation (void *cls,
// FIXME: check HMAC
// FIXME: decrypt payload
// FIXME: forward to specified communicator!
-
- finish_cmc_handling (cmc);
-}
-
-
-/**
- * Communicator gave us an ephemeral confirmation. Process the request.
- *
- * @param cls a `struct CommunicatorMessageContext` (must call #finish_cmc_handling() when done)
- * @param ec the message that was received
- */
-static void
-handle_ephemeral_confirmation (void *cls,
- const struct EphemeralConfirmationMessage *ec)
-{
- struct CommunicatorMessageContext *cmc = cls;
-
- // FIXME: notify communicator (?) about ephemeral confirmation!?
- // FIXME: or does this have something to do with the ephemeral_map?
- // where did I plan to use this message again!?
- // FIXME: communicator API has a very general notification API,
- // nothing specific for ephemeral keys;
- // why do we have a ephemeral key-specific message here?
- // => first revise where we get such messages from communicator
- // before processing further here!
+ // (using GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL_INCOMING)
finish_cmc_handling (cmc);
}
@@ -2726,10 +2678,6 @@ handle_incoming_msg (void *cls,
GNUNET_MESSAGE_TYPE_TRANSPORT_BACKCHANNEL_ENCAPSULATION,
struct TransportBackchannelEncapsulationMessage,
&cmc),
- GNUNET_MQ_hd_fixed_size (ephemeral_confirmation,
- GNUNET_MESSAGE_TYPE_TRANSPORT_EPHEMERAL_CONFIRMATION,
- struct EphemeralConfirmationMessage,
- &cmc),
GNUNET_MQ_hd_var_size (dv_learn,
GNUNET_MESSAGE_TYPE_TRANSPORT_DV_LEARN,
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
};
+/**
+ * Message from transport to communicator passing along a backchannel
+ * message from the given peer @e pid.
+ */
+struct GNUNET_TRANSPORT_CommunicatorBackchannelIncoming
+{
+ /**
+ * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL_INCOMING
+ */
+ struct GNUNET_MessageHeader header;
+
+ /**
+ * Always zero, for alignment.
+ */
+ uint32_t reserved;
+
+ /**
+ * Origin peer.
+ */
+ struct GNUNET_PeerIdentity pid;
+
+ /* Followed by a `struct GNUNET_MessageHeader` with the encapsulated
+ message to the communicator */
+
+};
+
+
/**
* 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 @@
* @file transport/transport_api2_communication.c
* @brief implementation of the gnunet_transport_communication_service.h API
* @author Christian Grothoff
+ *
+ * FIXME: handling of messages for "notify_cb" not implemented!
*/
#include "platform.h"
#include "gnunet_util_lib.h"
@@ -618,15 +620,8 @@ static int
check_send_msg (void *cls,
const struct GNUNET_TRANSPORT_SendMessageTo *smt)
{
- uint16_t len = ntohs (smt->header.size) - sizeof (*smt);
- const struct GNUNET_MessageHeader *mh = (const struct GNUNET_MessageHeader *) &smt[1];
-
(void) cls;
- if (ntohs (mh->size) != len)
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
+ GNUNET_MQ_check_boxed_message (smt);
return GNUNET_OK;
}
@@ -733,6 +728,40 @@ handle_send_msg (void *cls,
/**
+ * Transport service gives us backchannel message. Check if @a bi
+ * is well-formed.
+ *
+ * @param cls our `struct GNUNET_TRANSPORT_CommunicatorHandle *`
+ * @param bi the backchannel message
+ * @return #GNUNET_OK if @a smt is well-formed
+ */
+static int
+check_backchannel_incoming (void *cls,
+ const struct GNUNET_TRANSPORT_CommunicatorBackchannelIncoming *bi)
+{
+ (void) cls;
+ GNUNET_MQ_check_boxed_message (bi);
+ return GNUNET_OK;
+}
+
+
+/**
+ * Transport service gives us backchannel message. Handle it.
+ *
+ * @param cls our `struct GNUNET_TRANSPORT_CommunicatorHandle *`
+ * @param bi the backchannel message
+ */
+static void
+handle_backchannel_incoming (void *cls,
+ const struct GNUNET_TRANSPORT_CommunicatorBackchannelIncoming *bi)
+{
+ struct GNUNET_TRANSPORT_CommunicatorHandle *ch = cls;
+
+ // FIXME: handle bi!
+}
+
+
+/**
* (re)connect our communicator to the transport service
*
* @param ch handle to reconnect
@@ -753,7 +782,10 @@ reconnect (struct GNUNET_TRANSPORT_CommunicatorHandle *ch)
GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG,
struct GNUNET_TRANSPORT_SendMessageTo,
ch),
- // FIXME: handle backchannel notifications!
+ GNUNET_MQ_hd_var_size (backchannel_incoming,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL_INCOMING,
+ struct GNUNET_TRANSPORT_CommunicatorBackchannelIncoming,
+ ch),
GNUNET_MQ_handler_end()
};
struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *cam;