[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnunet] branch master updated: get new libgnunettransportc
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnunet] branch master updated: get new libgnunettransportcommunicator to build |
Date: |
Wed, 07 Nov 2018 19:25:41 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository gnunet.
The following commit(s) were added to refs/heads/master by this push:
new 59e432288 get new libgnunettransportcommunicator to build
59e432288 is described below
commit 59e432288a4d83a371a9a3efaba2376b44873473
Author: Christian Grothoff <address@hidden>
AuthorDate: Wed Nov 7 19:25:35 2018 +0100
get new libgnunettransportcommunicator to build
---
src/include/gnunet_protocols.h | 14 +-
.../gnunet_transport_communication_service.h | 1 +
src/transport/Makefile.am | 12 ++
src/transport/transport.h | 26 +++-
src/transport/transport_api2_communication.c | 161 +++++++++++++--------
5 files changed, 144 insertions(+), 70 deletions(-)
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h
index 898ad6258..16105d5a8 100644
--- a/src/include/gnunet_protocols.h
+++ b/src/include/gnunet_protocols.h
@@ -3051,14 +3051,24 @@ extern "C"
#define GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE 1206
/**
+ * Response from communicator: will try to create queue.
+ */
+#define GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_OK 1207
+
+/**
+ * Response from communicator: address bogus, will not try to create queue.
+ */
+#define GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_FAIL 1208
+
+/**
* @brief transport tells communicator it wants to transmit
*/
-#define GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG 1207
+#define GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG 1209
/**
* @brief communicator tells transports that message was sent
*/
-#define GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG_ACK 1208
+#define GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG_ACK 1210
/**
diff --git a/src/include/gnunet_transport_communication_service.h
b/src/include/gnunet_transport_communication_service.h
index d93d5134e..b1a248e51 100644
--- a/src/include/gnunet_transport_communication_service.h
+++ b/src/include/gnunet_transport_communication_service.h
@@ -42,6 +42,7 @@ extern "C"
#endif
#include "gnunet_util_lib.h"
+#include "gnunet_ats_service.h"
/**
* Version number of the transport communication API.
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am
index d0db6b141..c6c02c6ed 100644
--- a/src/transport/Makefile.am
+++ b/src/transport/Makefile.am
@@ -149,6 +149,7 @@ endif
lib_LTLIBRARIES = \
libgnunettransport.la \
+ libgnunettransportcommunicator.la \
$(TESTING_LIBS)
libgnunettransporttesting_la_SOURCES = \
@@ -187,6 +188,17 @@ libgnunettransport_la_LDFLAGS = \
$(GN_LIB_LDFLAGS) $(WINFLAGS) \
-version-info 4:0:2
+
+
+libgnunettransportcommunicator_la_SOURCES = \
+ transport_api2_communication.c
+libgnunettransportcommunicator_la_LIBADD = \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ $(GN_LIBINTL)
+libgnunettransportcommunicator_la_LDFLAGS = \
+ $(GN_LIB_LDFLAGS) $(WINFLAGS) \
+ -version-info 0:0:0
+
libexec_PROGRAMS = \
$(WLAN_BIN) \
$(WLAN_BIN_DUMMY) \
diff --git a/src/transport/transport.h b/src/transport/transport.h
index e68536bcc..5662d6c4d 100644
--- a/src/transport/transport.h
+++ b/src/transport/transport.h
@@ -769,7 +769,7 @@ struct GNUNET_TRANSPORT_AddQueueMessage
{
/**
- * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_ADD_QUEUE.
+ * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_SETUP.
*/
struct GNUNET_MessageHeader header;
@@ -799,7 +799,7 @@ struct GNUNET_TRANSPORT_DelQueueMessage
{
/**
- * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_DEL_QUEUE.
+ * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_TEARDOWN.
*/
struct GNUNET_MessageHeader header;
@@ -828,9 +828,9 @@ struct GNUNET_TRANSPORT_CreateQueue
struct GNUNET_MessageHeader header;
/**
- * Always zero.
+ * Unique ID for the request.
*/
- uint32_t reserved GNUNET_PACKED;
+ uint32_t request_id GNUNET_PACKED;
/**
* Receiver that can be addressed via the queue.
@@ -842,6 +842,24 @@ struct GNUNET_TRANSPORT_CreateQueue
/**
+ * Transport tells communicator that it wants a new queue.
+ */
+struct GNUNET_TRANSPORT_CreateQueueResponse
+{
+
+ /**
+ * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_OK or
#GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_FAIL.
+ */
+ struct GNUNET_MessageHeader header;
+
+ /**
+ * Unique ID for the request.
+ */
+ uint32_t request_id GNUNET_PACKED;
+};
+
+
+/**
* Inform communicator about transport's desire to send a message.
*/
struct GNUNET_TRANSPORT_SendMessageTo
diff --git a/src/transport/transport_api2_communication.c
b/src/transport/transport_api2_communication.c
index d446516bd..e5be53150 100644
--- a/src/transport/transport_api2_communication.c
+++ b/src/transport/transport_api2_communication.c
@@ -90,6 +90,11 @@ struct AckPending
struct AckPending *prev;
/**
+ * Communicator this entry belongs to.
+ */
+ struct GNUNET_TRANSPORT_CommunicatorHandle *ch;
+
+ /**
* Which peer is this about?
*/
struct GNUNET_PeerIdentity receiver;
@@ -134,17 +139,17 @@ struct GNUNET_TRANSPORT_CommunicatorHandle
/**
* DLL of messages awaiting transmission confirmation (ack).
*/
- struct AckPending *ac_tail;
+ struct AckPending *ap_tail;
/**
* DLL of queues we offer.
*/
- struct QueueHandle *queue_head;
+ struct GNUNET_TRANSPORT_QueueHandle *queue_head;
/**
* DLL of queues we offer.
*/
- struct QueueHandle *queue_tail;
+ struct GNUNET_TRANSPORT_QueueHandle *queue_tail;
/**
* Our configuration.
@@ -168,6 +173,11 @@ struct GNUNET_TRANSPORT_CommunicatorHandle
void *mq_init_cls;
/**
+ * Queue to talk to the transport service.
+ */
+ struct GNUNET_MQ_Handle *mq;
+
+ /**
* Maximum permissable queue length.
*/
unsigned long long max_queue_length;
@@ -202,6 +212,17 @@ struct GNUNET_TRANSPORT_CommunicatorHandle
*/
struct GNUNET_TRANSPORT_QueueHandle
{
+
+ /**
+ * Kept in a DLL.
+ */
+ struct GNUNET_TRANSPORT_QueueHandle *next;
+
+ /**
+ * Kept in a DLL.
+ */
+ struct GNUNET_TRANSPORT_QueueHandle *prev;
+
/**
* Handle this queue belongs to.
*/
@@ -308,7 +329,7 @@ send_add_address (struct GNUNET_TRANSPORT_AddressIdentifier
*ai)
env = GNUNET_MQ_msg_extra (aam,
strlen (ai->address) + 1,
GNUNET_MESSAGE_TYPE_TRANSPORT_ADD_ADDRESS);
- aam->expiration = GNUNET_TIME_relative_to_nbo (ai->expiration);
+ aam->expiration = GNUNET_TIME_relative_hton (ai->expiration);
aam->nt = htonl ((uint32_t) ai->nt);
memcpy (&aam[1],
ai->address,
@@ -334,7 +355,7 @@ send_del_address (struct GNUNET_TRANSPORT_AddressIdentifier
*ai)
return;
env = GNUNET_MQ_msg (dam,
GNUNET_MESSAGE_TYPE_TRANSPORT_DEL_ADDRESS);
- dam.aid = htonl (ai->aid);
+ dam->aid = htonl (ai->aid);
GNUNET_MQ_send (ai->ch->mq,
env);
}
@@ -352,18 +373,18 @@ send_add_queue (struct GNUNET_TRANSPORT_QueueHandle *qh)
struct GNUNET_MQ_Envelope *env;
struct GNUNET_TRANSPORT_AddQueueMessage *aqm;
- if (NULL == ai->ch->mq)
+ if (NULL == qh->ch->mq)
return;
env = GNUNET_MQ_msg_extra (aqm,
- strlen (ai->address) + 1,
- GNUNET_MESSAGE_TYPE_TRANSPORT_ADD_QUEUE);
- aqm.receiver = qh->peer;
- aqm.nt = htonl ((uint32_t) qh->nt);
- aqm.qid = htonl (qh->qid);
+ strlen (qh->address) + 1,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_SETUP);
+ aqm->receiver = qh->peer;
+ aqm->nt = htonl ((uint32_t) qh->nt);
+ aqm->qid = htonl (qh->queue_id);
memcpy (&aqm[1],
- ai->address,
- strlen (ai->address) + 1);
- GNUNET_MQ_send (ai->ch->mq,
+ qh->address,
+ strlen (qh->address) + 1);
+ GNUNET_MQ_send (qh->ch->mq,
env);
}
@@ -380,13 +401,13 @@ send_del_queue (struct GNUNET_TRANSPORT_QueueHandle *qh)
struct GNUNET_MQ_Envelope *env;
struct GNUNET_TRANSPORT_DelQueueMessage *dqm;
- if (NULL == ai->ch->mq)
+ if (NULL == qh->ch->mq)
return;
env = GNUNET_MQ_msg (dqm,
- GNUNET_MESSAGE_TYPE_TRANSPORT_DEL_QUEUE);
- dqm.qid = htonl (qh->qid);
- dqm.receiver = qh->peer;
- GNUNET_MQ_send (ai->ch->mq,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_TEARDOWN);
+ dqm->qid = htonl (qh->queue_id);
+ dqm->receiver = qh->peer;
+ GNUNET_MQ_send (qh->ch->mq,
env);
}
@@ -444,7 +465,8 @@ error_handler (void *cls,
struct GNUNET_TRANSPORT_CommunicatorHandle *ch = cls;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "MQ failure, reconnecting to transport service.\n");
+ "MQ failure %d, reconnecting to transport service.\n",
+ error);
disconnect (ch);
/* TODO: maybe do this with exponential backoff/delay */
reconnect (ch);
@@ -460,7 +482,7 @@ error_handler (void *cls,
*/
static void
handle_incoming_ack (void *cls,
- struct GNUNET_TRANSPORT_IncomingMessageAck *incoming_ack)
+ const struct GNUNET_TRANSPORT_IncomingMessageAck
*incoming_ack)
{
struct GNUNET_TRANSPORT_CommunicatorHandle *ch = cls;
@@ -470,7 +492,7 @@ handle_incoming_ack (void *cls,
{
if ( (fc->id == incoming_ack->fc_id) &&
(0 == memcmp (&fc->sender,
- incoming_ack->sender,
+ &incoming_ack->sender,
sizeof (struct GNUNET_PeerIdentity))) )
{
GNUNET_CONTAINER_DLL_remove (ch->fc_head,
@@ -499,11 +521,12 @@ handle_incoming_ack (void *cls,
*/
static int
check_create_queue (void *cls,
- struct GNUNET_TRANSPORT_CreateQueue *cq)
+ const struct GNUNET_TRANSPORT_CreateQueue *cq)
{
uint16_t len = ntohs (cq->header.size) - sizeof (*cq);
const char *addr = (const char *) &cq[1];
+ (void) cls;
if ( (0 == len) ||
('\0' != addr[len-1]) )
{
@@ -522,11 +545,13 @@ check_create_queue (void *cls,
*/
static void
handle_create_queue (void *cls,
- struct GNUNET_TRANSPORT_CreateQueue *cq)
+ const struct GNUNET_TRANSPORT_CreateQueue *cq)
{
struct GNUNET_TRANSPORT_CommunicatorHandle *ch = cls;
const char *addr = (const char *) &cq[1];
-
+ struct GNUNET_TRANSPORT_CreateQueueResponse *cqr;
+ struct GNUNET_MQ_Envelope *env;
+
if (GNUNET_OK !=
ch->mq_init (ch->mq_init_cls,
&cq->receiver,
@@ -535,8 +560,17 @@ handle_create_queue (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Address `%s' invalid for this communicator\n",
addr);
- // TODO: do we notify the transport!?
+ env = GNUNET_MQ_msg (cqr,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_FAIL);
}
+ else
+ {
+ env = GNUNET_MQ_msg (cqr,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_OK);
+ }
+ cqr->request_id = cq->request_id;
+ GNUNET_MQ_send (ch->mq,
+ env);
}
@@ -550,11 +584,12 @@ handle_create_queue (void *cls,
*/
static int
check_send_msg (void *cls,
- struct GNUNET_TRANSPORT_SendMessageTo *smt)
+ 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);
@@ -584,9 +619,9 @@ send_ack (struct GNUNET_TRANSPORT_CommunicatorHandle *ch,
env = GNUNET_MQ_msg (ack,
GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG_ACK);
- ack->status = htonl (GNUNET_OK);
- ack->mid = ap->mid;
- ack->receiver = ap->receiver;
+ ack->status = htonl (status);
+ ack->mid = mid;
+ ack->receiver = *receiver;
GNUNET_MQ_send (ch->mq,
env);
}
@@ -623,18 +658,18 @@ send_ack_cb (void *cls)
*/
static void
handle_send_msg (void *cls,
- struct GNUNET_TRANSPORT_SendMessageTo *smt)
+ const struct GNUNET_TRANSPORT_SendMessageTo *smt)
{
struct GNUNET_TRANSPORT_CommunicatorHandle *ch = cls;
const struct GNUNET_MessageHeader *mh;
struct GNUNET_MQ_Envelope *env;
struct AckPending *ap;
- struct QueueHandle *qh;
+ struct GNUNET_TRANSPORT_QueueHandle *qh;
for (qh = ch->queue_head;NULL != qh; qh = qh->next)
if ( (qh->queue_id == smt->qid) &&
(0 == memcmp (&qh->peer,
- &smt->target,
+ &smt->receiver,
sizeof (struct GNUNET_PeerIdentity))) )
break;
if (NULL == qh)
@@ -653,7 +688,7 @@ handle_send_msg (void *cls,
ap->receiver = smt->receiver;
ap->mid = smt->mid;
GNUNET_CONTAINER_DLL_insert (ch->ap_head,
- cp->ap_tail,
+ ch->ap_tail,
ap);
mh = (const struct GNUNET_MessageHeader *) &smt[1];
env = GNUNET_MQ_msg_copy (mh);
@@ -679,7 +714,7 @@ reconnect (struct GNUNET_TRANSPORT_CommunicatorHandle *ch)
struct GNUNET_TRANSPORT_IncomingMessageAck,
ch),
GNUNET_MQ_hd_var_size (create_queue,
- GNUNET_MESSAGE_TYPE_TRANSPORT_CREATE_QUEUE,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE,
struct GNUNET_TRANSPORT_CreateQueue,
ch),
GNUNET_MQ_hd_var_size (send_msg,
@@ -689,7 +724,7 @@ reconnect (struct GNUNET_TRANSPORT_CommunicatorHandle *ch)
GNUNET_MQ_handler_end()
};
- ch->mq = GNUNET_CLIENT_connect (cfg,
+ ch->mq = GNUNET_CLIENT_connect (ch->cfg,
"transport",
handlers,
&error_handler,
@@ -798,32 +833,15 @@ GNUNET_TRANSPORT_communicator_receive (struct
GNUNET_TRANSPORT_CommunicatorHandl
struct GNUNET_TRANSPORT_IncomingMessage *im;
uint16_t msize;
- if (NULL == ai->ch->mq)
+ if (NULL == ch->mq)
return GNUNET_SYSERR;
- if (NULL != cb)
- {
- struct FlowControl *fc;
-
- im->fc_on = htonl (GNUNET_YES);
- im->fc_id = ai->ch->fc_gen++;
- fc = GNUNET_new (struct FlowControl);
- fc->sender = *sender;
- fc->id = im->fc_id;
- fc->cb = cb;
- fc->cb_cls = cb_cls;
- GNUNET_CONTAINER_DLL_insert (ch->fc_head,
- ch->fc_tail,
- fc);
- }
- else
+ if ( (NULL == cb) &&
+ (GNUNET_MQ_get_length (ch->mq) >= ch->max_queue_length) )
{
- if (GNUNET_MQ_get_length (ch->mq) >= ch->max_queue_length)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Dropping message: transprot is too slow, queue length %u
exceeded\n",
- ch->max_queue_length);
- return GNUNET_NO;
- }
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Dropping message: transprot is too slow, queue length %llu
exceeded\n",
+ ch->max_queue_length);
+ return GNUNET_NO;
}
msize = ntohs (msg->size);
@@ -839,7 +857,22 @@ GNUNET_TRANSPORT_communicator_receive (struct
GNUNET_TRANSPORT_CommunicatorHandl
memcpy (&im[1],
msg,
msize);
- GNUNET_MQ_send (ai->ch->mq,
+ if (NULL != cb)
+ {
+ struct FlowControl *fc;
+
+ im->fc_on = htonl (GNUNET_YES);
+ im->fc_id = ch->fc_gen++;
+ fc = GNUNET_new (struct FlowControl);
+ fc->sender = *sender;
+ fc->id = im->fc_id;
+ fc->cb = cb;
+ fc->cb_cls = cb_cls;
+ GNUNET_CONTAINER_DLL_insert (ch->fc_head,
+ ch->fc_tail,
+ fc);
+ }
+ GNUNET_MQ_send (ch->mq,
env);
return GNUNET_OK;
}
@@ -927,9 +960,9 @@ GNUNET_TRANSPORT_communicator_address_add (struct
GNUNET_TRANSPORT_CommunicatorH
ai->address = GNUNET_strdup (address);
ai->nt = nt;
ai->expiration = expiration;
- ai->aid = handle->aid_gen++;
- GNUNET_CONTAINER_DLL_insert (handle->ai_head,
- handle->ai_tail,
+ ai->aid = ch->aid_gen++;
+ GNUNET_CONTAINER_DLL_insert (ch->ai_head,
+ ch->ai_tail,
ai);
send_add_address (ai);
return ai;
--
To stop receiving notification emails like this one, please contact
address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [gnunet] branch master updated: get new libgnunettransportcommunicator to build,
gnunet <=