aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2021-02-21 11:46:16 +0100
committerMartin Schanzenbach <mschanzenbach@posteo.de>2021-02-21 11:46:16 +0100
commitf5439c2297f8c9db0af779df701a7974f8d94490 (patch)
treedc4d7f079f1b8f199a782dac7cb3ee24606daf88
parenta3971a93c2ca633389ebf04b003cb49854ae6e0c (diff)
downloadgnunet-f5439c2297f8c9db0af779df701a7974f8d94490.tar.gz
gnunet-f5439c2297f8c9db0af779df701a7974f8d94490.zip
TNG: Add queue update handling
-rw-r--r--src/transport/gnunet-service-tng.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c
index 2f6e17f3b..bd9acd0cf 100644
--- a/src/transport/gnunet-service-tng.c
+++ b/src/transport/gnunet-service-tng.c
@@ -1787,6 +1787,11 @@ struct Queue
1787 unsigned int queue_length; 1787 unsigned int queue_length;
1788 1788
1789 /** 1789 /**
1790 * Queue priority
1791 */
1792 uint32_t priority;
1793
1794 /**
1790 * Network type offered by this queue. 1795 * Network type offered by this queue.
1791 */ 1796 */
1792 enum GNUNET_NetworkType nt; 1797 enum GNUNET_NetworkType nt;
@@ -9575,6 +9580,50 @@ handle_add_queue_message (void *cls,
9575 9580
9576 9581
9577/** 9582/**
9583 * @brief Handle updates to queues.
9584 *
9585 * @param cls the transport client.
9586 * @param msg Message struct.
9587 */
9588static void
9589handle_update_queue_message (void *cls,
9590 const struct
9591 GNUNET_TRANSPORT_UpdateQueueMessage *msg)
9592{
9593 struct TransportClient *tc = cls;
9594 struct Queue *target_queue = NULL;
9595
9596 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
9597 "Received queue update message for %u with q_len %llu\n",
9598 msg->qid, (unsigned long long) GNUNET_ntohll (msg->q_len));
9599 for (target_queue = tc->details.communicator.queue_head;
9600 NULL != target_queue;
9601 target_queue = target_queue->next_client)
9602 {
9603 if (msg->qid == target_queue->qid)
9604 break;
9605 }
9606 if (NULL == target_queue)
9607 {
9608 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
9609 "Queue to update no longer exists! Discarding update.\n");
9610 return;
9611 }
9612
9613 target_queue->nt = msg->nt;
9614 target_queue->mtu = ntohl (msg->mtu);
9615 target_queue->cs = msg->cs;
9616 target_queue->priority = ntohl (msg->priority);
9617 /* The update message indicates how many _additional_
9618 * messages the queue should be able to handle
9619 */
9620 target_queue->queue_length += GNUNET_ntohll (msg->q_len);
9621 GNUNET_SERVICE_client_continue (tc->client);
9622}
9623
9624
9625
9626/**
9578 * Communicator tells us that our request to create a queue "worked", that 9627 * Communicator tells us that our request to create a queue "worked", that
9579 * is setting up the queue is now in process. 9628 * is setting up the queue is now in process.
9580 * 9629 *
@@ -10101,6 +10150,10 @@ GNUNET_SERVICE_MAIN (
10101 GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_SETUP, 10150 GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_SETUP,
10102 struct GNUNET_TRANSPORT_AddQueueMessage, 10151 struct GNUNET_TRANSPORT_AddQueueMessage,
10103 NULL), 10152 NULL),
10153 GNUNET_MQ_hd_fixed_size (update_queue_message,
10154 GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_UPDATE,
10155 struct GNUNET_TRANSPORT_UpdateQueueMessage,
10156 NULL),
10104 GNUNET_MQ_hd_fixed_size (del_queue_message, 10157 GNUNET_MQ_hd_fixed_size (del_queue_message,
10105 GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_TEARDOWN, 10158 GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_TEARDOWN,
10106 struct GNUNET_TRANSPORT_DelQueueMessage, 10159 struct GNUNET_TRANSPORT_DelQueueMessage,