aboutsummaryrefslogtreecommitdiff
path: root/src/transport/transport_api2_communication.c
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2020-06-01 16:39:35 +0200
committerMartin Schanzenbach <mschanzenbach@posteo.de>2020-06-01 16:39:35 +0200
commit198c09654354d09a9b33f27cf095e0295f70826c (patch)
tree07aa088c8e9664dc76915cc6b664654da59359f4 /src/transport/transport_api2_communication.c
parenta325c3eaa8450d325fe57959eac29da5496cfd6d (diff)
downloadgnunet-198c09654354d09a9b33f27cf095e0295f70826c.tar.gz
gnunet-198c09654354d09a9b33f27cf095e0295f70826c.zip
tng: more UDP communicator backchannels
Added a new message for queue updates to indicate queue length. Queues now may also have a priority parameter.
Diffstat (limited to 'src/transport/transport_api2_communication.c')
-rw-r--r--src/transport/transport_api2_communication.c77
1 files changed, 77 insertions, 0 deletions
diff --git a/src/transport/transport_api2_communication.c b/src/transport/transport_api2_communication.c
index e80cd5c03..cfa144415 100644
--- a/src/transport/transport_api2_communication.c
+++ b/src/transport/transport_api2_communication.c
@@ -280,6 +280,15 @@ struct GNUNET_TRANSPORT_QueueHandle
280 * Maximum transmission unit for the queue. 280 * Maximum transmission unit for the queue.
281 */ 281 */
282 uint32_t mtu; 282 uint32_t mtu;
283
284 /**
285 * Queue length.
286 */
287 uint64_t q_len;
288 /**
289 * Queue priority.
290 */
291 uint32_t priority;
283}; 292};
284 293
285 294
@@ -395,6 +404,8 @@ send_add_queue (struct GNUNET_TRANSPORT_QueueHandle *qh)
395 404
396 if (NULL == qh->ch->mq) 405 if (NULL == qh->ch->mq)
397 return; 406 return;
407 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
408 "Sending `GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_SETUP` message\n");
398 env = GNUNET_MQ_msg_extra (aqm, 409 env = GNUNET_MQ_msg_extra (aqm,
399 strlen (qh->address) + 1, 410 strlen (qh->address) + 1,
400 GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_SETUP); 411 GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_SETUP);
@@ -402,11 +413,39 @@ send_add_queue (struct GNUNET_TRANSPORT_QueueHandle *qh)
402 aqm->receiver = qh->peer; 413 aqm->receiver = qh->peer;
403 aqm->nt = htonl ((uint32_t) qh->nt); 414 aqm->nt = htonl ((uint32_t) qh->nt);
404 aqm->mtu = htonl (qh->mtu); 415 aqm->mtu = htonl (qh->mtu);
416 aqm->q_len = GNUNET_htonll (qh->q_len);
417 aqm->priority = htonl (qh->priority);
405 aqm->cs = htonl ((uint32_t) qh->cs); 418 aqm->cs = htonl ((uint32_t) qh->cs);
406 memcpy (&aqm[1], qh->address, strlen (qh->address) + 1); 419 memcpy (&aqm[1], qh->address, strlen (qh->address) + 1);
407 GNUNET_MQ_send (qh->ch->mq, env); 420 GNUNET_MQ_send (qh->ch->mq, env);
408} 421}
409 422
423/**
424 * Send message to the transport service about queue @a qh
425 * updated.
426 *
427 * @param qh queue to add
428 */
429static void
430send_update_queue (struct GNUNET_TRANSPORT_QueueHandle *qh)
431{
432 struct GNUNET_MQ_Envelope *env;
433 struct GNUNET_TRANSPORT_UpdateQueueMessage *uqm;
434
435 if (NULL == qh->ch->mq)
436 return;
437 env = GNUNET_MQ_msg (uqm, GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_UPDATE);
438 uqm->qid = htonl (qh->queue_id);
439 uqm->receiver = qh->peer;
440 uqm->nt = htonl ((uint32_t) qh->nt);
441 uqm->mtu = htonl (qh->mtu);
442 uqm->q_len = GNUNET_htonll (qh->q_len);
443 uqm->priority = htonl (qh->priority);
444 uqm->cs = htonl ((uint32_t) qh->cs);
445 GNUNET_MQ_send (qh->ch->mq, env);
446}
447
448
410 449
411/** 450/**
412 * Send message to the transport service about queue @a qh 451 * Send message to the transport service about queue @a qh
@@ -924,6 +963,9 @@ GNUNET_TRANSPORT_communicator_receive (
924 * @param address address in human-readable format, 0-terminated, UTF-8 963 * @param address address in human-readable format, 0-terminated, UTF-8
925 * @param mtu maximum message size supported by queue, 0 if 964 * @param mtu maximum message size supported by queue, 0 if
926 * sending is not supported, SIZE_MAX for no MTU 965 * sending is not supported, SIZE_MAX for no MTU
966 * @param q_len number of messages that can be send through this queue
967 * @param priority queue priority. Queues with highest priority should be
968 * used
927 * @param nt which network type does the @a address belong to? 969 * @param nt which network type does the @a address belong to?
928 * @param cc what characteristics does the communicator have? 970 * @param cc what characteristics does the communicator have?
929 * @param cs what is the connection status of the queue? 971 * @param cs what is the connection status of the queue?
@@ -936,6 +978,8 @@ GNUNET_TRANSPORT_communicator_mq_add (
936 const struct GNUNET_PeerIdentity *peer, 978 const struct GNUNET_PeerIdentity *peer,
937 const char *address, 979 const char *address,
938 uint32_t mtu, 980 uint32_t mtu,
981 uint64_t q_len,
982 uint32_t priority,
939 enum GNUNET_NetworkType nt, 983 enum GNUNET_NetworkType nt,
940 enum GNUNET_TRANSPORT_ConnectionStatus cs, 984 enum GNUNET_TRANSPORT_ConnectionStatus cs,
941 struct GNUNET_MQ_Handle *mq) 985 struct GNUNET_MQ_Handle *mq)
@@ -948,6 +992,8 @@ GNUNET_TRANSPORT_communicator_mq_add (
948 qh->address = GNUNET_strdup (address); 992 qh->address = GNUNET_strdup (address);
949 qh->nt = nt; 993 qh->nt = nt;
950 qh->mtu = mtu; 994 qh->mtu = mtu;
995 qh->q_len = q_len;
996 qh->priority = priority;
951 qh->cs = cs; 997 qh->cs = cs;
952 qh->mq = mq; 998 qh->mq = mq;
953 qh->queue_id = ch->queue_gen++; 999 qh->queue_id = ch->queue_gen++;
@@ -958,6 +1004,37 @@ GNUNET_TRANSPORT_communicator_mq_add (
958 1004
959 1005
960/** 1006/**
1007 * Notify transport service that an MQ was updated
1008 *
1009 * @param ch connection to transport service
1010 * @param qh the queue to update
1011 * @param q_len number of messages that can be send through this queue
1012 * @param priority queue priority. Queues with highest priority should be
1013 * used
1014 */
1015void
1016GNUNET_TRANSPORT_communicator_mq_update (
1017 struct GNUNET_TRANSPORT_CommunicatorHandle *ch,
1018 const struct GNUNET_TRANSPORT_QueueHandle *u_qh,
1019 uint64_t q_len,
1020 uint32_t priority)
1021{
1022 struct GNUNET_TRANSPORT_QueueHandle *qh;
1023
1024 for (qh = ch->queue_head; NULL != qh; qh = qh->next)
1025 {
1026 if (u_qh == qh)
1027 break;
1028 }
1029 GNUNET_assert (NULL != qh);
1030 qh->q_len = q_len;
1031 qh->priority = priority;
1032 send_update_queue (qh);
1033}
1034
1035
1036
1037/**
961 * Notify transport service that an MQ became unavailable due to a 1038 * Notify transport service that an MQ became unavailable due to a
962 * disconnect or timeout. 1039 * disconnect or timeout.
963 * 1040 *