*/
#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
* 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
*/
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);
#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
if ('\0' == un->sun_path[0])
GNUNET_asprintf (&foreign_addr,
"%s-@%s",
- 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,
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,
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;
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);
}
GNUNET_asprintf (&my_addr,
"%s-%s",
- COMMUNICATOR_NAME,
+ COMMUNICATOR_ADDRESS_PREFIX,
unix_socket_path);
ai = GNUNET_TRANSPORT_communicator_address_add (ch,
my_addr,
/* *********************** 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.
*/
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
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)
* 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
*/
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)
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;