diff options
author | Christian Grothoff <christian@grothoff.org> | 2018-11-08 14:40:01 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2018-11-08 14:40:01 +0100 |
commit | 6dc4bacb0197e96d5d9c6e5f881a104ab054a1f0 (patch) | |
tree | 9050589ac3ba2731f3d8dd1d8456b2e78794aeef /src/transport/transport_api2_communication.c | |
parent | 304bfc5d18d5613a38b5d927925dbfa00adfc82a (diff) | |
download | gnunet-6dc4bacb0197e96d5d9c6e5f881a104ab054a1f0.tar.gz gnunet-6dc4bacb0197e96d5d9c6e5f881a104ab054a1f0.zip |
send NEW_COMMUNICATOR message on startup
Diffstat (limited to 'src/transport/transport_api2_communication.c')
-rw-r--r-- | src/transport/transport_api2_communication.c | 34 |
1 files changed, 27 insertions, 7 deletions
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 | |||
157 | const struct GNUNET_CONFIGURATION_Handle *cfg; | 157 | const struct GNUNET_CONFIGURATION_Handle *cfg; |
158 | 158 | ||
159 | /** | 159 | /** |
160 | * Name of the communicator. | 160 | * Config section to use. |
161 | */ | 161 | */ |
162 | const char *name; | 162 | const char *config_section; |
163 | |||
164 | /** | ||
165 | * Address prefix to use. | ||
166 | */ | ||
167 | const char *addr_prefix; | ||
163 | 168 | ||
164 | /** | 169 | /** |
165 | * Function to call when the transport service wants us to initiate | 170 | * Function to call when the transport service wants us to initiate |
@@ -723,13 +728,24 @@ reconnect (struct GNUNET_TRANSPORT_CommunicatorHandle *ch) | |||
723 | ch), | 728 | ch), |
724 | GNUNET_MQ_handler_end() | 729 | GNUNET_MQ_handler_end() |
725 | }; | 730 | }; |
731 | struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *cam; | ||
732 | struct GNUNET_MQ_Envelope *env; | ||
726 | 733 | ||
727 | ch->mq = GNUNET_CLIENT_connect (ch->cfg, | 734 | ch->mq = GNUNET_CLIENT_connect (ch->cfg, |
728 | "transport", | 735 | "transport", |
729 | handlers, | 736 | handlers, |
730 | &error_handler, | 737 | &error_handler, |
731 | ch); | 738 | ch); |
732 | // FIXME: must notify transport that we are responsible for 'ch->name' addresses!!! | 739 | if (NULL == ch->mq) |
740 | return; | ||
741 | env = GNUNET_MQ_msg_extra (cam, | ||
742 | strlen (ch->addr_prefix) + 1, | ||
743 | GNUNET_MESSAGE_TYPE_TRANSPORT_NEW_COMMUNICATOR); | ||
744 | memcpy (&cam[1], | ||
745 | ch->addr_prefix, | ||
746 | strlen (ch->addr_prefix) + 1); | ||
747 | GNUNET_MQ_send (ch->mq, | ||
748 | env); | ||
733 | for (struct GNUNET_TRANSPORT_AddressIdentifier *ai = ch->ai_head; | 749 | for (struct GNUNET_TRANSPORT_AddressIdentifier *ai = ch->ai_head; |
734 | NULL != ai; | 750 | NULL != ai; |
735 | ai = ai->next) | 751 | ai = ai->next) |
@@ -745,7 +761,9 @@ reconnect (struct GNUNET_TRANSPORT_CommunicatorHandle *ch) | |||
745 | * Connect to the transport service. | 761 | * Connect to the transport service. |
746 | * | 762 | * |
747 | * @param cfg configuration to use | 763 | * @param cfg configuration to use |
748 | * @param name name of the communicator that is connecting | 764 | * @param config_section section of the configuration to use for options |
765 | * @param addr_prefix address prefix for addresses supported by this | ||
766 | * communicator, could be NULL for incoming-only communicators | ||
749 | * @param mtu maximum message size supported by communicator, 0 if | 767 | * @param mtu maximum message size supported by communicator, 0 if |
750 | * sending is not supported, SIZE_MAX for no MTU | 768 | * sending is not supported, SIZE_MAX for no MTU |
751 | * @param mq_init function to call to initialize a message queue given | 769 | * @param mq_init function to call to initialize a message queue given |
@@ -756,7 +774,8 @@ reconnect (struct GNUNET_TRANSPORT_CommunicatorHandle *ch) | |||
756 | */ | 774 | */ |
757 | struct GNUNET_TRANSPORT_CommunicatorHandle * | 775 | struct GNUNET_TRANSPORT_CommunicatorHandle * |
758 | GNUNET_TRANSPORT_communicator_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | 776 | GNUNET_TRANSPORT_communicator_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, |
759 | const char *name, | 777 | const char *config_section, |
778 | const char *addr_prefix, | ||
760 | size_t mtu, | 779 | size_t mtu, |
761 | GNUNET_TRANSPORT_CommunicatorMqInit mq_init, | 780 | GNUNET_TRANSPORT_CommunicatorMqInit mq_init, |
762 | void *mq_init_cls) | 781 | void *mq_init_cls) |
@@ -765,14 +784,15 @@ GNUNET_TRANSPORT_communicator_connect (const struct GNUNET_CONFIGURATION_Handle | |||
765 | 784 | ||
766 | ch = GNUNET_new (struct GNUNET_TRANSPORT_CommunicatorHandle); | 785 | ch = GNUNET_new (struct GNUNET_TRANSPORT_CommunicatorHandle); |
767 | ch->cfg = cfg; | 786 | ch->cfg = cfg; |
768 | ch->name = name; | 787 | ch->config_section = config_section; |
788 | ch->addr_prefix = addr_prefix; | ||
769 | ch->mtu = mtu; | 789 | ch->mtu = mtu; |
770 | ch->mq_init = mq_init; | 790 | ch->mq_init = mq_init; |
771 | ch->mq_init_cls = mq_init_cls; | 791 | ch->mq_init_cls = mq_init_cls; |
772 | reconnect (ch); | 792 | reconnect (ch); |
773 | if (GNUNET_OK != | 793 | if (GNUNET_OK != |
774 | GNUNET_CONFIGURATION_get_value_number (cfg, | 794 | GNUNET_CONFIGURATION_get_value_number (cfg, |
775 | name, | 795 | config_section, |
776 | "MAX_QUEUE_LENGTH", | 796 | "MAX_QUEUE_LENGTH", |
777 | &ch->max_queue_length)) | 797 | &ch->max_queue_length)) |
778 | ch->max_queue_length = DEFAULT_MAX_QUEUE_LENGTH; | 798 | ch->max_queue_length = DEFAULT_MAX_QUEUE_LENGTH; |