summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cadet/cadet_api_drop_message.c59
-rw-r--r--src/cadet/gnunet-service-cadet_connection.c5
-rw-r--r--src/cadet/gnunet-service-cadet_connection.h4
-rw-r--r--src/cadet/gnunet-service-cadet_peer.c32
-rw-r--r--src/cadet/gnunet-service-cadet_peer.h22
5 files changed, 99 insertions, 23 deletions
diff --git a/src/cadet/cadet_api_drop_message.c b/src/cadet/cadet_api_drop_message.c
new file mode 100644
index 000000000..d9f7e003e
--- /dev/null
+++ b/src/cadet/cadet_api_drop_message.c
@@ -0,0 +1,59 @@
+/*
+ This file is part of GNUnet.
+ Copyright (C) 2011, 2017, 2019 GNUnet e.V.
+
+ GNUnet is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License,
+ or (at your option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ SPDX-License-Identifier: AGPL3.0-or-later
+*/
+/**
+ * @file cadet/cadet_api_drop_message.c
+ * @brief cadet api: client implementation of cadet service
+ * @author t3sserakt
+ */
+#include "platform.h"
+#include "cadet.h"
+
+
+/**
+ * Drop the next cadet message of a given type..
+ *
+ * @param mq message queue
+ * @param ccn client channel number.
+ * @param type of cadet message to be dropped.
+ */
+void
+GNUNET_CADET_drop_message (struct GNUNET_MQ_Handle *mq,
+ struct GNUNET_CADET_ClientChannelNumber ccn,
+ uint16_t type)
+{
+ struct GNUNET_CADET_RequestDropCadetMessage *message;
+ struct GNUNET_MQ_Envelope *env;
+
+ env = GNUNET_MQ_msg (message, GNUNET_MESSAGE_TYPE_CADET_DROP_CADET_MESSAGE);
+
+ message->ccn = ccn;
+ message->type = type;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Dropping message for channel of type %s (%d)\n", type == GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY ? "GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY" : "UNKNOWN", type);
+
+ GNUNET_MQ_send (mq, env);
+
+}
+
+
+
+
+/* end of cadet_api_drop_message.c */
diff --git a/src/cadet/gnunet-service-cadet_connection.c b/src/cadet/gnunet-service-cadet_connection.c
index 1dac9eb1e..a7c1d9fb0 100644
--- a/src/cadet/gnunet-service-cadet_connection.c
+++ b/src/cadet/gnunet-service-cadet_connection.c
@@ -595,6 +595,11 @@ GCC_handle_encrypted (struct CadetConnection *cc,
}
+/**
+ * Set the signature for a monotime value on a GNUNET_CADET_ConnectionCreateMessage.
+ *
+ * @param msg The GNUNET_CADET_ConnectionCreateMessage.
+ */
void
set_monotime_sig (struct GNUNET_CADET_ConnectionCreateMessage *msg)
{
diff --git a/src/cadet/gnunet-service-cadet_connection.h b/src/cadet/gnunet-service-cadet_connection.h
index a9ebef567..ed0e909fb 100644
--- a/src/cadet/gnunet-service-cadet_connection.h
+++ b/src/cadet/gnunet-service-cadet_connection.h
@@ -182,6 +182,10 @@ void
GCC_handle_kx_auth (struct CadetConnection *cc,
const struct
GNUNET_CADET_TunnelKeyExchangeAuthMessage *msg);
+
+/**
+ * Purpose for the signature of a monotime.
+ */
struct CadetConnectionCreatePS
{
diff --git a/src/cadet/gnunet-service-cadet_peer.c b/src/cadet/gnunet-service-cadet_peer.c
index 0ff4d1fb8..55800b88c 100644
--- a/src/cadet/gnunet-service-cadet_peer.c
+++ b/src/cadet/gnunet-service-cadet_peer.c
@@ -1552,17 +1552,12 @@ GCP_send_ooo (struct CadetPeer *cp,
env);
}
-/*
- * FIXME: comment
- */
-void
-GCP_update_monotime (struct CadetPeer *peer)
-{
- peer->last_connection_create = GNUNET_TIME_absolute_get_monotonic (cfg);
-}
-
-/*
- * FIXME: comment
+/**
+ * Checking if a monotime value is newer than the last monotime value received from a peer. If the time value is newer it will be stored at the peer.
+ *
+ * @param peer The peer we received a new time value from.
+ * @param monotime Time value we check against the last time value we received from a peer.
+ * @return GNUNET_YES if monotime is newer than the last received time value, GNUNET_NO if monotime is not newer.
*/
int
GCP_check_and_update_monotime (struct CadetPeer *peer,
@@ -1579,16 +1574,17 @@ GCP_check_and_update_monotime (struct CadetPeer *peer,
return GNUNET_NO;
}
-/*
- * FIXME: documentation here
+/**
+ * Checking the signature for a monotime of a GNUNET_CADET_ConnectionCreateMessage.
+ *
+ * @param peer The peer that signed the monotime value.
+ * @param msg The GNUNET_CADET_ConnectionCreateMessage with the monotime value.
+ * @return GNUNET_OK if the signature is good, GNUNET_SYSERR if not.
*/
int
-GCP_check_monotime_sig (struct CadetPeer *peer, const struct
- GNUNET_CADET_ConnectionCreateMessage *msg)
+GCP_check_monotime_sig (struct CadetPeer *peer,
+ const struct GNUNET_CADET_ConnectionCreateMessage *msg)
{
- // struct CadetPeer *peer;
- // const struct GNUNET_CADET_ConnectionCreateMessage *msg;
-
struct CadetConnectionCreatePS cp = { .purpose.purpose = htonl (
GNUNET_SIGNATURE_PURPOSE_CADET_CONNECTION_INITIATOR),
.purpose.size = htonl (sizeof(cp)),
diff --git a/src/cadet/gnunet-service-cadet_peer.h b/src/cadet/gnunet-service-cadet_peer.h
index 31bd23121..5782b8bff 100644
--- a/src/cadet/gnunet-service-cadet_peer.h
+++ b/src/cadet/gnunet-service-cadet_peer.h
@@ -402,13 +402,25 @@ void
GCP_set_mq (struct CadetPeer *cp,
struct GNUNET_MQ_Handle *mq);
+/**
+ * Checking the signature for a monotime of a GNUNET_CADET_ConnectionCreateMessage.
+ *
+ * @param peer The peer that signed the monotime value.
+ * @param msg The GNUNET_CADET_ConnectionCreateMessage with the monotime value.
+ * @return GNUNET_OK if the signature is good, GNUNET_SYSERR if not.
+ */
int
-GCP_check_monotime_sig (struct CadetPeer *peer, const struct GNUNET_CADET_ConnectionCreateMessage *msg);
-
-void
-GCP_update_monotime (struct CadetPeer *cp);
+GCP_check_monotime_sig (struct CadetPeer *peer, const struct
+ GNUNET_CADET_ConnectionCreateMessage *msg);
-int
+/**
+ * Checking if a monotime value is newer than the last monotime value received from a peer. If the time value is newer it will be stored at the peer.
+ *
+ * @param peer The peer we received a new time value from.
+ * @param monotime Time value we check against the last time value we received from a peer.
+ * @return GNUNET_YES if monotime is newer than the last received time value, GNUNET_NO if monotime is not newer.
+ */
+int
GCP_check_and_update_monotime (struct CadetPeer *peer,
struct GNUNET_TIME_AbsoluteNBO monotime);