[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnunet] branch master updated: send NEW_COMMUNICATOR messa
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnunet] branch master updated: send NEW_COMMUNICATOR message on startup |
Date: |
Thu, 08 Nov 2018 14:40:03 +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 6dc4bacb0 send NEW_COMMUNICATOR message on startup
6dc4bacb0 is described below
commit 6dc4bacb0197e96d5d9c6e5f881a104ab054a1f0
Author: Christian Grothoff <address@hidden>
AuthorDate: Thu Nov 8 14:40:01 2018 +0100
send NEW_COMMUNICATOR message on startup
---
src/include/gnunet_protocols.h | 5 ++++
.../gnunet_transport_communication_service.h | 7 +++--
src/transport/gnunet-communicator-unix.c | 30 +++++++++++--------
src/transport/transport.h | 16 ++++++++++
src/transport/transport_api2_communication.c | 34 +++++++++++++++++-----
5 files changed, 71 insertions(+), 21 deletions(-)
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h
index 16105d5a8..fbdee5415 100644
--- a/src/include/gnunet_protocols.h
+++ b/src/include/gnunet_protocols.h
@@ -3070,6 +3070,11 @@ extern "C"
*/
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG_ACK 1210
+/**
+ * Message sent to indicate to the transport which address
+ * prefix is supported by a communicator.
+ */
+#define GNUNET_MESSAGE_TYPE_TRANSPORT_NEW_COMMUNICATOR 1211
/**
* Next available: 1300
diff --git a/src/include/gnunet_transport_communication_service.h
b/src/include/gnunet_transport_communication_service.h
index ab5d3742a..50f94bddf 100644
--- a/src/include/gnunet_transport_communication_service.h
+++ b/src/include/gnunet_transport_communication_service.h
@@ -83,7 +83,9 @@ struct GNUNET_TRANSPORT_CommunicatorHandle;
* Connect to the transport service.
*
* @param cfg configuration to use
- * @param name name of the communicator that is connecting
+ * @param config_section section of the configuration to use for options
+ * @param addr_prefix address prefix for addresses supported by this
+ * communicator, could be NULL for incoming-only communicators
* @param mtu maximum message size supported by communicator, 0 if
* sending is not supported, SIZE_MAX for no MTU
* @param mq_init function to call to initialize a message queue given
@@ -94,7 +96,8 @@ struct GNUNET_TRANSPORT_CommunicatorHandle;
*/
struct GNUNET_TRANSPORT_CommunicatorHandle *
GNUNET_TRANSPORT_communicator_connect (const struct
GNUNET_CONFIGURATION_Handle *cfg,
- const char *name,
+ const char *config_section_name,
+ const char *addr_prefix,
size_t mtu,
GNUNET_TRANSPORT_CommunicatorMqInit
mq_init,
void *mq_init_cls);
diff --git a/src/transport/gnunet-communicator-unix.c
b/src/transport/gnunet-communicator-unix.c
index 2879b1738..cd3ae5dce 100644
--- a/src/transport/gnunet-communicator-unix.c
+++ b/src/transport/gnunet-communicator-unix.c
@@ -41,9 +41,14 @@
#define DEFAULT_MAX_QUEUE_LENGTH 8
/**
- * Name of the communicator.
+ * Address prefix used by the communicator.
*/
-#define COMMUNICATOR_NAME "unix"
+#define COMMUNICATOR_ADDRESS_PREFIX "unix"
+
+/**
+ * Configuration section used by the communicator.
+ */
+#define COMMUNICATOR_CONFIG_SECTION "communicator-unix"
GNUNET_NETWORK_STRUCT_BEGIN
@@ -656,12 +661,12 @@ setup_queue (const struct GNUNET_PeerIdentity *target,
if ('\0' == un->sun_path[0])
GNUNET_asprintf (&foreign_addr,
"address@hidden",
- COMMUNICATOR_NAME,
+ COMMUNICATOR_ADDRESS_PREFIX,
&un->sun_path[1]);
else
GNUNET_asprintf (&foreign_addr,
"%s-%s",
- COMMUNICATOR_NAME,
+ COMMUNICATOR_ADDRESS_PREFIX,
un->sun_path);
queue->qh
= GNUNET_TRANSPORT_communicator_mq_add (ch,
@@ -855,13 +860,13 @@ mq_init (void *cls,
socklen_t un_len;
if (0 != strncmp (address,
- COMMUNICATOR_NAME "-",
- strlen (COMMUNICATOR_NAME "-")))
+ COMMUNICATOR_ADDRESS_PREFIX "-",
+ strlen (COMMUNICATOR_ADDRESS_PREFIX "-")))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
- path = &address[strlen (COMMUNICATOR_NAME "-")];
+ path = &address[strlen (COMMUNICATOR_ADDRESS_PREFIX "-")];
un = unix_address_to_sockaddr (path,
&un_len);
queue = lookup_queue (peer,
@@ -983,18 +988,18 @@ run (void *cls,
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_filename (cfg,
- "communicator-unix",
+ COMMUNICATOR_CONFIG_SECTION,
"UNIXPATH",
&unix_socket_path))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
- "communicator-unix",
+ COMMUNICATOR_CONFIG_SECTION,
"UNIXPATH");
return;
}
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_number (cfg,
- "communicator-unix",
+ COMMUNICATOR_CONFIG_SECTION,
"MAX_QUEUE_LENGTH",
&max_queue_length))
max_queue_length = DEFAULT_MAX_QUEUE_LENGTH;
@@ -1062,7 +1067,8 @@ run (void *cls,
queue_map = GNUNET_CONTAINER_multipeermap_create (10,
GNUNET_NO);
ch = GNUNET_TRANSPORT_communicator_connect (cfg,
- COMMUNICATOR_NAME,
+ COMMUNICATOR_CONFIG_SECTION,
+ COMMUNICATOR_ADDRESS_PREFIX,
65535,
&mq_init,
NULL);
@@ -1075,7 +1081,7 @@ run (void *cls,
}
GNUNET_asprintf (&my_addr,
"%s-%s",
- COMMUNICATOR_NAME,
+ COMMUNICATOR_ADDRESS_PREFIX,
unix_socket_path);
ai = GNUNET_TRANSPORT_communicator_address_add (ch,
my_addr,
diff --git a/src/transport/transport.h b/src/transport/transport.h
index 5662d6c4d..f21863aef 100644
--- a/src/transport/transport.h
+++ b/src/transport/transport.h
@@ -654,6 +654,22 @@ struct TransportPluginMonitorMessage
/* *********************** TNG messages ***************** */
/**
+ * Communicator goes online. Note which addresses it can
+ * work with.
+ */
+struct GNUNET_TRANSPORT_CommunicatorAvailableMessage
+{
+
+ /**
+ * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_NEW_COMMUNICATOR.
+ */
+ struct GNUNET_MessageHeader header;
+
+ /* Followed by the address prefix of the communicator */
+};
+
+
+/**
* Add address to the list.
*/
struct GNUNET_TRANSPORT_AddAddressMessage
diff --git a/src/transport/transport_api2_communication.c
b/src/transport/transport_api2_communication.c
index 434138e19..3a68c6eba 100644
--- a/src/transport/transport_api2_communication.c
+++ b/src/transport/transport_api2_communication.c
@@ -157,9 +157,14 @@ struct GNUNET_TRANSPORT_CommunicatorHandle
const struct GNUNET_CONFIGURATION_Handle *cfg;
/**
- * Name of the communicator.
+ * Config section to use.
*/
- const char *name;
+ const char *config_section;
+
+ /**
+ * Address prefix to use.
+ */
+ const char *addr_prefix;
/**
* Function to call when the transport service wants us to initiate
@@ -723,13 +728,24 @@ reconnect (struct GNUNET_TRANSPORT_CommunicatorHandle *ch)
ch),
GNUNET_MQ_handler_end()
};
+ struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *cam;
+ struct GNUNET_MQ_Envelope *env;
ch->mq = GNUNET_CLIENT_connect (ch->cfg,
"transport",
handlers,
&error_handler,
ch);
- // FIXME: must notify transport that we are responsible for 'ch->name'
addresses!!!
+ if (NULL == ch->mq)
+ return;
+ env = GNUNET_MQ_msg_extra (cam,
+ strlen (ch->addr_prefix) + 1,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_NEW_COMMUNICATOR);
+ memcpy (&cam[1],
+ ch->addr_prefix,
+ strlen (ch->addr_prefix) + 1);
+ GNUNET_MQ_send (ch->mq,
+ env);
for (struct GNUNET_TRANSPORT_AddressIdentifier *ai = ch->ai_head;
NULL != ai;
ai = ai->next)
@@ -745,7 +761,9 @@ reconnect (struct GNUNET_TRANSPORT_CommunicatorHandle *ch)
* Connect to the transport service.
*
* @param cfg configuration to use
- * @param name name of the communicator that is connecting
+ * @param config_section section of the configuration to use for options
+ * @param addr_prefix address prefix for addresses supported by this
+ * communicator, could be NULL for incoming-only communicators
* @param mtu maximum message size supported by communicator, 0 if
* sending is not supported, SIZE_MAX for no MTU
* @param mq_init function to call to initialize a message queue given
@@ -756,7 +774,8 @@ reconnect (struct GNUNET_TRANSPORT_CommunicatorHandle *ch)
*/
struct GNUNET_TRANSPORT_CommunicatorHandle *
GNUNET_TRANSPORT_communicator_connect (const struct
GNUNET_CONFIGURATION_Handle *cfg,
- const char *name,
+ const char *config_section,
+ const char *addr_prefix,
size_t mtu,
GNUNET_TRANSPORT_CommunicatorMqInit
mq_init,
void *mq_init_cls)
@@ -765,14 +784,15 @@ GNUNET_TRANSPORT_communicator_connect (const struct
GNUNET_CONFIGURATION_Handle
ch = GNUNET_new (struct GNUNET_TRANSPORT_CommunicatorHandle);
ch->cfg = cfg;
- ch->name = name;
+ ch->config_section = config_section;
+ ch->addr_prefix = addr_prefix;
ch->mtu = mtu;
ch->mq_init = mq_init;
ch->mq_init_cls = mq_init_cls;
reconnect (ch);
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_number (cfg,
- name,
+ config_section,
"MAX_QUEUE_LENGTH",
&ch->max_queue_length))
ch->max_queue_length = DEFAULT_MAX_QUEUE_LENGTH;
--
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: send NEW_COMMUNICATOR message on startup,
gnunet <=