diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-02-09 14:28:45 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-02-09 14:28:45 +0000 |
commit | 72a2c1b9542d68eab32f483a1c53eeec19bc12b3 (patch) | |
tree | 36fe4082af27fba371e51bb838d8a0435e032432 /src/transport | |
parent | 6806f421c1164921cfa265ddc7009c08986bc915 (diff) | |
download | gnunet-72a2c1b9542d68eab32f483a1c53eeec19bc12b3.tar.gz gnunet-72a2c1b9542d68eab32f483a1c53eeec19bc12b3.zip |
-do only send HELLO to clients once on startup, do only send fully initialized HELLO to clients if we can help it, even the first one; do not perform blacklist check twice for try_connect
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/gnunet-service-transport.c | 26 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_clients.c | 79 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_hello.c | 80 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_neighbours.c | 4 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_plugins.c | 29 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_validation.c | 10 | ||||
-rw-r--r-- | src/transport/plugin_transport_tcp.c | 18 | ||||
-rw-r--r-- | src/transport/plugin_transport_udp_broadcasting.c | 7 | ||||
-rw-r--r-- | src/transport/plugin_transport_wlan.c | 10 | ||||
-rw-r--r-- | src/transport/transport_api.c | 14 |
10 files changed, 162 insertions, 115 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index 336925f4f..65519914a 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c | |||
@@ -215,6 +215,11 @@ transmit_our_hello (void *cls, | |||
215 | { | 215 | { |
216 | const struct GNUNET_MessageHeader *hello = cls; | 216 | const struct GNUNET_MessageHeader *hello = cls; |
217 | 217 | ||
218 | if (0 == | ||
219 | memcmp (peer, | ||
220 | &GST_my_identity, | ||
221 | sizeof (struct GNUNET_PeerIdentity))) | ||
222 | return; /* not to ourselves */ | ||
218 | if (GNUNET_NO == GST_neighbours_test_connected (peer)) | 223 | if (GNUNET_NO == GST_neighbours_test_connected (peer)) |
219 | return; | 224 | return; |
220 | 225 | ||
@@ -236,8 +241,13 @@ static void | |||
236 | process_hello_update (void *cls, | 241 | process_hello_update (void *cls, |
237 | const struct GNUNET_MessageHeader *hello) | 242 | const struct GNUNET_MessageHeader *hello) |
238 | { | 243 | { |
244 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
245 | "Broadcasting HELLO to clients\n"); | ||
239 | GST_clients_broadcast (hello, GNUNET_NO); | 246 | GST_clients_broadcast (hello, GNUNET_NO); |
240 | GST_neighbours_iterate (&transmit_our_hello, (void *) hello); | 247 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
248 | "Broadcasting HELLO to neighbours\n"); | ||
249 | GST_neighbours_iterate (&transmit_our_hello, | ||
250 | (void *) hello); | ||
241 | } | 251 | } |
242 | 252 | ||
243 | 253 | ||
@@ -1051,14 +1061,18 @@ run (void *cls, | |||
1051 | "Limiting number of sockets to %u: validation %u, neighbors: %u\n", | 1061 | "Limiting number of sockets to %u: validation %u, neighbors: %u\n", |
1052 | max_fd, (max_fd / 3), (max_fd / 3) * 2); | 1062 | max_fd, (max_fd / 3), (max_fd / 3) * 2); |
1053 | 1063 | ||
1054 | friend_only = GNUNET_CONFIGURATION_get_value_yesno (GST_cfg, "topology", | 1064 | friend_only = GNUNET_CONFIGURATION_get_value_yesno (GST_cfg, |
1055 | "FRIENDS-ONLY"); | 1065 | "topology", |
1066 | "FRIENDS-ONLY"); | ||
1056 | if (GNUNET_SYSERR == friend_only) | 1067 | if (GNUNET_SYSERR == friend_only) |
1057 | friend_only = GNUNET_NO; /* According to topology defaults */ | 1068 | friend_only = GNUNET_NO; /* According to topology defaults */ |
1058 | /* start subsystems */ | 1069 | /* start subsystems */ |
1059 | GST_hello_start (friend_only, &process_hello_update, NULL ); | 1070 | GST_hello_start (friend_only, |
1060 | GNUNET_assert(NULL != GST_hello_get()); | 1071 | &process_hello_update, |
1061 | GST_blacklist_start (GST_server, GST_cfg, &GST_my_identity); | 1072 | NULL); |
1073 | GST_blacklist_start (GST_server, | ||
1074 | GST_cfg, | ||
1075 | &GST_my_identity); | ||
1062 | is = GNUNET_ATS_scanner_init (); | 1076 | is = GNUNET_ATS_scanner_init (); |
1063 | GST_ats_connect = GNUNET_ATS_connectivity_init (GST_cfg); | 1077 | GST_ats_connect = GNUNET_ATS_connectivity_init (GST_cfg); |
1064 | GST_ats = GNUNET_ATS_scheduling_init (GST_cfg, | 1078 | GST_ats = GNUNET_ATS_scheduling_init (GST_cfg, |
diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c index 8e0b3fe68..cea1dc14e 100644 --- a/src/transport/gnunet-service-transport_clients.c +++ b/src/transport/gnunet-service-transport_clients.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2010-2014 Christian Grothoff (and other contributing authors) | 3 | Copyright (C) 2010-2015 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -613,38 +613,57 @@ clients_handle_start (void *cls, | |||
613 | const struct GNUNET_MessageHeader *message) | 613 | const struct GNUNET_MessageHeader *message) |
614 | { | 614 | { |
615 | const struct StartMessage *start; | 615 | const struct StartMessage *start; |
616 | const struct GNUNET_MessageHeader *hello; | ||
616 | struct TransportClient *tc; | 617 | struct TransportClient *tc; |
617 | uint32_t options; | 618 | uint32_t options; |
618 | 619 | ||
619 | tc = lookup_client (client); | 620 | tc = lookup_client (client); |
620 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
621 | "Client %p sent START\n", tc); | ||
622 | if (NULL != tc) | 621 | if (NULL != tc) |
623 | { | 622 | { |
624 | /* got 'start' twice from the same client, not allowed */ | 623 | /* got 'start' twice from the same client, not allowed */ |
625 | GNUNET_break (0); | 624 | GNUNET_break (0); |
626 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 625 | GNUNET_SERVER_receive_done (client, |
626 | GNUNET_SYSERR); | ||
627 | return; | 627 | return; |
628 | } | 628 | } |
629 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
630 | "Client %p sent START\n", | ||
631 | client); | ||
629 | start = (const struct StartMessage *) message; | 632 | start = (const struct StartMessage *) message; |
630 | options = ntohl (start->options); | 633 | options = ntohl (start->options); |
631 | if ((0 != (1 & options)) && | 634 | if ((0 != (1 & options)) && |
632 | (0 != | 635 | (0 != |
633 | memcmp (&start->self, &GST_my_identity, | 636 | memcmp (&start->self, |
637 | &GST_my_identity, | ||
634 | sizeof (struct GNUNET_PeerIdentity)))) | 638 | sizeof (struct GNUNET_PeerIdentity)))) |
635 | { | 639 | { |
636 | /* client thinks this is a different peer, reject */ | 640 | /* client thinks this is a different peer, reject */ |
637 | GNUNET_break (0); | 641 | GNUNET_break (0); |
638 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 642 | GNUNET_SERVER_receive_done (client, |
643 | GNUNET_SYSERR); | ||
639 | return; | 644 | return; |
640 | } | 645 | } |
641 | tc = setup_client (client); | 646 | tc = setup_client (client); |
642 | tc->send_payload = (0 != (2 & options)); | 647 | tc->send_payload = (0 != (2 & options)); |
643 | unicast (tc, | 648 | hello = GST_hello_get (); |
644 | GST_hello_get (), | 649 | if (NULL == hello) |
645 | GNUNET_NO); | 650 | { |
646 | GST_neighbours_iterate (¬ify_client_about_neighbour, tc); | 651 | /* We are during startup and should have no neighbours, hence |
647 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 652 | iteration with NULL must work. The HELLO will be sent to |
653 | all clients once it has been created, so this should happen | ||
654 | next anyway, and certainly before we get neighbours. */ | ||
655 | GST_neighbours_iterate (NULL, NULL); | ||
656 | } | ||
657 | else | ||
658 | { | ||
659 | unicast (tc, | ||
660 | hello, | ||
661 | GNUNET_NO); | ||
662 | GST_neighbours_iterate (¬ify_client_about_neighbour, | ||
663 | tc); | ||
664 | } | ||
665 | GNUNET_SERVER_receive_done (client, | ||
666 | GNUNET_OK); | ||
648 | } | 667 | } |
649 | 668 | ||
650 | 669 | ||
@@ -791,35 +810,6 @@ clients_handle_send (void *cls, | |||
791 | 810 | ||
792 | 811 | ||
793 | /** | 812 | /** |
794 | * Try to initiate a connection to the given peer if the blacklist | ||
795 | * allowed it. | ||
796 | * | ||
797 | * @param cls closure (unused, NULL) | ||
798 | * @param peer identity of peer that was tested | ||
799 | * @param result #GNUNET_OK if the connection is allowed, | ||
800 | * #GNUNET_NO if not | ||
801 | */ | ||
802 | static void | ||
803 | try_connect_if_allowed (void *cls, | ||
804 | const struct GNUNET_PeerIdentity *peer, | ||
805 | int result) | ||
806 | { | ||
807 | if (GNUNET_OK != result) | ||
808 | { | ||
809 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
810 | _("Blacklist refuses connection attempt to peer `%s'\n"), | ||
811 | GNUNET_i2s (peer)); | ||
812 | return; /* not allowed */ | ||
813 | } | ||
814 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
815 | "Blacklist allows connection attempt to peer `%s'\n", | ||
816 | GNUNET_i2s (peer)); | ||
817 | |||
818 | GST_neighbours_try_connect (peer); | ||
819 | } | ||
820 | |||
821 | |||
822 | /** | ||
823 | * Handle request connect message | 813 | * Handle request connect message |
824 | * | 814 | * |
825 | * @param cls closure (always NULL) | 815 | * @param cls closure (always NULL) |
@@ -850,10 +840,7 @@ clients_handle_request_connect (void *cls, | |||
850 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 840 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
851 | "Received a request connect message for peer `%s'\n", | 841 | "Received a request connect message for peer `%s'\n", |
852 | GNUNET_i2s (&trcm->peer)); | 842 | GNUNET_i2s (&trcm->peer)); |
853 | (void) GST_blacklist_test_allowed (&trcm->peer, | 843 | GST_neighbours_try_connect (&trcm->peer); |
854 | NULL, | ||
855 | &try_connect_if_allowed, | ||
856 | NULL); | ||
857 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 844 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
858 | } | 845 | } |
859 | 846 | ||
@@ -1590,6 +1577,10 @@ GST_clients_broadcast (const struct GNUNET_MessageHeader *msg, | |||
1590 | { | 1577 | { |
1591 | struct TransportClient *tc; | 1578 | struct TransportClient *tc; |
1592 | 1579 | ||
1580 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1581 | "Asked to broadcast message of type %u with %u bytes\n", | ||
1582 | (unsigned int) ntohs (msg->type), | ||
1583 | (unsigned int) ntohs (msg->size)); | ||
1593 | for (tc = clients_head; NULL != tc; tc = tc->next) | 1584 | for (tc = clients_head; NULL != tc; tc = tc->next) |
1594 | { | 1585 | { |
1595 | if ( (GNUNET_YES == may_drop) && | 1586 | if ( (GNUNET_YES == may_drop) && |
diff --git a/src/transport/gnunet-service-transport_hello.c b/src/transport/gnunet-service-transport_hello.c index d59b0f1b4..7b5f79a4a 100644 --- a/src/transport/gnunet-service-transport_hello.c +++ b/src/transport/gnunet-service-transport_hello.c | |||
@@ -90,28 +90,33 @@ static struct GNUNET_HELLO_Message *our_hello; | |||
90 | static GST_HelloCallback hello_cb; | 90 | static GST_HelloCallback hello_cb; |
91 | 91 | ||
92 | /** | 92 | /** |
93 | * Closure for 'hello_cb'. | 93 | * Closure for #hello_cb. |
94 | */ | 94 | */ |
95 | static void *hello_cb_cls; | 95 | static void *hello_cb_cls; |
96 | 96 | ||
97 | /** | 97 | /** |
98 | * Head of my addresses. | 98 | * Head of my addresses. |
99 | */ | 99 | */ |
100 | struct OwnAddressList *oal_head; | 100 | static struct OwnAddressList *oal_head; |
101 | 101 | ||
102 | /** | 102 | /** |
103 | * Tail of my addresses. | 103 | * Tail of my addresses. |
104 | */ | 104 | */ |
105 | struct OwnAddressList *oal_tail; | 105 | static struct OwnAddressList *oal_tail; |
106 | 106 | ||
107 | /** | 107 | /** |
108 | * Identifier of 'refresh_hello' task. | 108 | * Should we use a friend-only HELLO? |
109 | */ | ||
110 | static int friend_option; | ||
111 | |||
112 | /** | ||
113 | * Identifier of #refresh_hello_task(). | ||
109 | */ | 114 | */ |
110 | static struct GNUNET_SCHEDULER_Task * hello_task; | 115 | static struct GNUNET_SCHEDULER_Task * hello_task; |
111 | 116 | ||
112 | 117 | ||
113 | /** | 118 | /** |
114 | * Closure for 'address_generator'. | 119 | * Closure for #address_generator(). |
115 | */ | 120 | */ |
116 | struct GeneratorContext | 121 | struct GeneratorContext |
117 | { | 122 | { |
@@ -130,14 +135,16 @@ struct GeneratorContext | |||
130 | /** | 135 | /** |
131 | * Add an address from the 'OwnAddressList' to the buffer. | 136 | * Add an address from the 'OwnAddressList' to the buffer. |
132 | * | 137 | * |
133 | * @param cls the 'struct GeneratorContext' | 138 | * @param cls the `struct GeneratorContext` |
134 | * @param max maximum number of bytes left | 139 | * @param max maximum number of bytes left |
135 | * @param buf where to write the address | 140 | * @param buf where to write the address |
136 | * @return bytes written or GNUNET_SYSERR to signal the | 141 | * @return bytes written or #GNUNET_SYSERR to signal the |
137 | * end of the iteration. | 142 | * end of the iteration. |
138 | */ | 143 | */ |
139 | static ssize_t | 144 | static ssize_t |
140 | address_generator (void *cls, size_t max, void *buf) | 145 | address_generator (void *cls, |
146 | size_t max, | ||
147 | void *buf) | ||
141 | { | 148 | { |
142 | struct GeneratorContext *gc = cls; | 149 | struct GeneratorContext *gc = cls; |
143 | ssize_t ret; | 150 | ssize_t ret; |
@@ -159,35 +166,40 @@ address_generator (void *cls, size_t max, void *buf) | |||
159 | * @param tc scheduler context | 166 | * @param tc scheduler context |
160 | */ | 167 | */ |
161 | static void | 168 | static void |
162 | refresh_hello_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 169 | refresh_hello_task (void *cls, |
170 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
163 | { | 171 | { |
164 | struct GeneratorContext gc; | 172 | struct GeneratorContext gc; |
165 | int friend_only; | ||
166 | 173 | ||
167 | hello_task = NULL; | 174 | hello_task = NULL; |
168 | gc.addr_pos = oal_head; | 175 | gc.addr_pos = oal_head; |
169 | gc.expiration = GNUNET_TIME_relative_to_absolute (hello_expiration); | 176 | gc.expiration = GNUNET_TIME_relative_to_absolute (hello_expiration); |
170 | 177 | ||
171 | 178 | GNUNET_free_non_null (our_hello); | |
172 | friend_only = GNUNET_HELLO_is_friend_only (our_hello); | ||
173 | GNUNET_free (our_hello); | ||
174 | our_hello = GNUNET_HELLO_create (&GST_my_identity.public_key, | 179 | our_hello = GNUNET_HELLO_create (&GST_my_identity.public_key, |
175 | &address_generator, | 180 | &address_generator, |
176 | &gc, friend_only); | 181 | &gc, |
182 | friend_option); | ||
177 | GNUNET_assert (NULL != our_hello); | 183 | GNUNET_assert (NULL != our_hello); |
178 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 184 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
179 | "Refreshed my %s `%s', new size is %d\n", | 185 | "Refreshed my %s HELLO, new size is %d\n", |
180 | (GNUNET_YES == GNUNET_HELLO_is_friend_only (our_hello)) ? "friend-only" : "public", | 186 | (GNUNET_YES == friend_option) ? "friend-only" : "public", |
181 | "HELLO", GNUNET_HELLO_size (our_hello)); | 187 | GNUNET_HELLO_size (our_hello)); |
182 | GNUNET_STATISTICS_update (GST_stats, gettext_noop ("# refreshed my HELLO"), 1, | 188 | GNUNET_STATISTICS_update (GST_stats, |
189 | gettext_noop ("# refreshed my HELLO"), | ||
190 | 1, | ||
183 | GNUNET_NO); | 191 | GNUNET_NO); |
184 | if (NULL != hello_cb) | 192 | if (NULL != hello_cb) |
185 | hello_cb (hello_cb_cls, GST_hello_get ()); | 193 | hello_cb (hello_cb_cls, |
186 | GNUNET_PEERINFO_add_peer (GST_peerinfo, our_hello, NULL, NULL); | 194 | GST_hello_get ()); |
195 | GNUNET_PEERINFO_add_peer (GST_peerinfo, | ||
196 | our_hello, | ||
197 | NULL, | ||
198 | NULL); | ||
187 | hello_task = | 199 | hello_task = |
188 | GNUNET_SCHEDULER_add_delayed (HELLO_REFRESH_PERIOD, &refresh_hello_task, | 200 | GNUNET_SCHEDULER_add_delayed (HELLO_REFRESH_PERIOD, |
201 | &refresh_hello_task, | ||
189 | NULL); | 202 | NULL); |
190 | |||
191 | } | 203 | } |
192 | 204 | ||
193 | 205 | ||
@@ -198,9 +210,10 @@ refresh_hello_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
198 | static void | 210 | static void |
199 | refresh_hello () | 211 | refresh_hello () |
200 | { | 212 | { |
201 | if (hello_task != NULL) | 213 | if (NULL != hello_task) |
202 | GNUNET_SCHEDULER_cancel (hello_task); | 214 | GNUNET_SCHEDULER_cancel (hello_task); |
203 | hello_task = GNUNET_SCHEDULER_add_now (&refresh_hello_task, NULL); | 215 | hello_task = GNUNET_SCHEDULER_add_now (&refresh_hello_task, |
216 | NULL); | ||
204 | } | 217 | } |
205 | 218 | ||
206 | 219 | ||
@@ -209,16 +222,16 @@ refresh_hello () | |||
209 | * | 222 | * |
210 | * @param friend_only use a friend only hello | 223 | * @param friend_only use a friend only hello |
211 | * @param cb function to call whenever our HELLO changes | 224 | * @param cb function to call whenever our HELLO changes |
212 | * @param cb_cls closure for cb | 225 | * @param cb_cls closure for @a cb |
213 | */ | 226 | */ |
214 | void | 227 | void |
215 | GST_hello_start (int friend_only, GST_HelloCallback cb, void *cb_cls) | 228 | GST_hello_start (int friend_only, |
229 | GST_HelloCallback cb, | ||
230 | void *cb_cls) | ||
216 | { | 231 | { |
217 | hello_cb = cb; | 232 | hello_cb = cb; |
218 | hello_cb_cls = cb_cls; | 233 | hello_cb_cls = cb_cls; |
219 | our_hello = GNUNET_HELLO_create (&GST_my_identity.public_key, | 234 | friend_option = friend_only; |
220 | NULL, NULL, friend_only); | ||
221 | GNUNET_assert (NULL != our_hello); | ||
222 | refresh_hello (); | 235 | refresh_hello (); |
223 | } | 236 | } |
224 | 237 | ||
@@ -259,7 +272,7 @@ GST_hello_get () | |||
259 | /** | 272 | /** |
260 | * Add or remove an address from this peer's HELLO message. | 273 | * Add or remove an address from this peer's HELLO message. |
261 | * | 274 | * |
262 | * @param addremove GNUNET_YES to add, GNUNET_NO to remove | 275 | * @param addremove #GNUNET_YES to add, #GNUNET_NO to remove |
263 | * @param address address to add or remove | 276 | * @param address address to add or remove |
264 | */ | 277 | */ |
265 | void | 278 | void |
@@ -303,8 +316,8 @@ GST_hello_modify_addresses (int addremove, | |||
303 | * @param sig location where to cache PONG signatures for this address [set] | 316 | * @param sig location where to cache PONG signatures for this address [set] |
304 | * @param sig_expiration how long until the current 'sig' expires? | 317 | * @param sig_expiration how long until the current 'sig' expires? |
305 | * (ZERO if sig was never created) [set] | 318 | * (ZERO if sig was never created) [set] |
306 | * @return GNUNET_YES if this is one of our addresses, | 319 | * @return #GNUNET_YES if this is one of our addresses, |
307 | * GNUNET_NO if not | 320 | * #GNUNET_NO if not |
308 | */ | 321 | */ |
309 | int | 322 | int |
310 | GST_hello_test_address (const struct GNUNET_HELLO_Address *address, | 323 | GST_hello_test_address (const struct GNUNET_HELLO_Address *address, |
@@ -314,7 +327,8 @@ GST_hello_test_address (const struct GNUNET_HELLO_Address *address, | |||
314 | struct OwnAddressList *al; | 327 | struct OwnAddressList *al; |
315 | 328 | ||
316 | for (al = oal_head; al != NULL; al = al->next) | 329 | for (al = oal_head; al != NULL; al = al->next) |
317 | if (0 == GNUNET_HELLO_address_cmp (address, al->address)) | 330 | if (0 == GNUNET_HELLO_address_cmp (address, |
331 | al->address)) | ||
318 | { | 332 | { |
319 | *sig = &al->pong_signature; | 333 | *sig = &al->pong_signature; |
320 | *sig_expiration = &al->pong_sig_expires; | 334 | *sig_expiration = &al->pong_sig_expires; |
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index 15bb0bdab..315d32131 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c | |||
@@ -3711,7 +3711,9 @@ GST_neighbours_iterate (GST_NeighbourIterator cb, void *cb_cls) | |||
3711 | return; /* can happen during shutdown */ | 3711 | return; /* can happen during shutdown */ |
3712 | ic.cb = cb; | 3712 | ic.cb = cb; |
3713 | ic.cb_cls = cb_cls; | 3713 | ic.cb_cls = cb_cls; |
3714 | GNUNET_CONTAINER_multipeermap_iterate (neighbours, &neighbours_iterate, &ic); | 3714 | GNUNET_CONTAINER_multipeermap_iterate (neighbours, |
3715 | &neighbours_iterate, | ||
3716 | &ic); | ||
3715 | } | 3717 | } |
3716 | 3718 | ||
3717 | 3719 | ||
diff --git a/src/transport/gnunet-service-transport_plugins.c b/src/transport/gnunet-service-transport_plugins.c index 3e0e6601d..79f7f4ddd 100644 --- a/src/transport/gnunet-service-transport_plugins.c +++ b/src/transport/gnunet-service-transport_plugins.c | |||
@@ -108,15 +108,19 @@ GST_plugins_load (GNUNET_TRANSPORT_PluginReceiveCallback recv_cb, | |||
108 | int fail; | 108 | int fail; |
109 | 109 | ||
110 | if (GNUNET_OK != | 110 | if (GNUNET_OK != |
111 | GNUNET_CONFIGURATION_get_value_number (GST_cfg, "TRANSPORT", | 111 | GNUNET_CONFIGURATION_get_value_number (GST_cfg, |
112 | "NEIGHBOUR_LIMIT", &tneigh)) | 112 | "TRANSPORT", |
113 | "NEIGHBOUR_LIMIT", | ||
114 | &tneigh)) | ||
113 | { | 115 | { |
114 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 116 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
115 | _("Transport service is lacking NEIGHBOUR_LIMIT option.\n")); | 117 | _("Transport service is lacking NEIGHBOUR_LIMIT option.\n")); |
116 | return; | 118 | return; |
117 | } | 119 | } |
118 | if (GNUNET_OK != | 120 | if (GNUNET_OK != |
119 | GNUNET_CONFIGURATION_get_value_string (GST_cfg, "TRANSPORT", "PLUGINS", | 121 | GNUNET_CONFIGURATION_get_value_string (GST_cfg, |
122 | "TRANSPORT", | ||
123 | "PLUGINS", | ||
120 | &plugs)) | 124 | &plugs)) |
121 | return; | 125 | return; |
122 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 126 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
@@ -127,7 +131,9 @@ GST_plugins_load (GNUNET_TRANSPORT_PluginReceiveCallback recv_cb, | |||
127 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 131 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
128 | _("Loading `%s' transport plugin\n"), | 132 | _("Loading `%s' transport plugin\n"), |
129 | pos); | 133 | pos); |
130 | GNUNET_asprintf (&libname, "libgnunet_plugin_transport_%s", pos); | 134 | GNUNET_asprintf (&libname, |
135 | "libgnunet_plugin_transport_%s", | ||
136 | pos); | ||
131 | plug = GNUNET_new (struct TransportPlugin); | 137 | plug = GNUNET_new (struct TransportPlugin); |
132 | plug->short_name = GNUNET_strdup (pos); | 138 | plug->short_name = GNUNET_strdup (pos); |
133 | plug->lib_name = libname; | 139 | plug->lib_name = libname; |
@@ -143,7 +149,9 @@ GST_plugins_load (GNUNET_TRANSPORT_PluginReceiveCallback recv_cb, | |||
143 | plug->env.update_address_metrics = metric_update_cb; | 149 | plug->env.update_address_metrics = metric_update_cb; |
144 | plug->env.max_connections = tneigh; | 150 | plug->env.max_connections = tneigh; |
145 | plug->env.stats = GST_stats; | 151 | plug->env.stats = GST_stats; |
146 | GNUNET_CONTAINER_DLL_insert (plugins_head, plugins_tail, plug); | 152 | GNUNET_CONTAINER_DLL_insert (plugins_head, |
153 | plugins_tail, | ||
154 | plug); | ||
147 | } | 155 | } |
148 | GNUNET_free (plugs); | 156 | GNUNET_free (plugs); |
149 | next = plugins_head; | 157 | next = plugins_head; |
@@ -151,13 +159,16 @@ GST_plugins_load (GNUNET_TRANSPORT_PluginReceiveCallback recv_cb, | |||
151 | { | 159 | { |
152 | plug = next; | 160 | plug = next; |
153 | next = plug->next; | 161 | next = plug->next; |
154 | plug->api = GNUNET_PLUGIN_load (plug->lib_name, &plug->env); | 162 | plug->api = GNUNET_PLUGIN_load (plug->lib_name, |
163 | &plug->env); | ||
155 | if (NULL == plug->api) | 164 | if (NULL == plug->api) |
156 | { | 165 | { |
157 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 166 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
158 | _("Failed to load transport plugin for `%s'\n"), | 167 | _("Failed to load transport plugin for `%s'\n"), |
159 | plug->lib_name); | 168 | plug->lib_name); |
160 | GNUNET_CONTAINER_DLL_remove (plugins_head, plugins_tail, plug); | 169 | GNUNET_CONTAINER_DLL_remove (plugins_head, |
170 | plugins_tail, | ||
171 | plug); | ||
161 | GNUNET_free (plug->short_name); | 172 | GNUNET_free (plug->short_name); |
162 | GNUNET_free (plug->lib_name); | 173 | GNUNET_free (plug->lib_name); |
163 | GNUNET_free (plug); | 174 | GNUNET_free (plug); |
@@ -258,7 +269,9 @@ GST_plugins_load (GNUNET_TRANSPORT_PluginReceiveCallback recv_cb, | |||
258 | _("Did not load plugin `%s' due to missing functions\n"), | 269 | _("Did not load plugin `%s' due to missing functions\n"), |
259 | plug->lib_name); | 270 | plug->lib_name); |
260 | GNUNET_break (NULL == GNUNET_PLUGIN_unload (plug->lib_name, plug->api)); | 271 | GNUNET_break (NULL == GNUNET_PLUGIN_unload (plug->lib_name, plug->api)); |
261 | GNUNET_CONTAINER_DLL_remove (plugins_head, plugins_tail, plug); | 272 | GNUNET_CONTAINER_DLL_remove (plugins_head, |
273 | plugins_tail, | ||
274 | plug); | ||
262 | GNUNET_free (plug->short_name); | 275 | GNUNET_free (plug->short_name); |
263 | GNUNET_free (plug->lib_name); | 276 | GNUNET_free (plug->lib_name); |
264 | GNUNET_free (plug); | 277 | GNUNET_free (plug); |
diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c index abf15debf..a2fb3c853 100644 --- a/src/transport/gnunet-service-transport_validation.c +++ b/src/transport/gnunet-service-transport_validation.c | |||
@@ -526,7 +526,12 @@ transmit_ping_if_allowed (void *cls, | |||
526 | cleanup_validation_entry (NULL, pid, ve); | 526 | cleanup_validation_entry (NULL, pid, ve); |
527 | return; | 527 | return; |
528 | } | 528 | } |
529 | 529 | hello = GST_hello_get (); | |
530 | if (NULL == hello) | ||
531 | { | ||
532 | GNUNET_break (0); | ||
533 | return; | ||
534 | } | ||
530 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 535 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
531 | "Transmitting plain PING to `%s' `%s' `%s'\n", | 536 | "Transmitting plain PING to `%s' `%s' `%s'\n", |
532 | GNUNET_i2s (pid), | 537 | GNUNET_i2s (pid), |
@@ -534,7 +539,6 @@ transmit_ping_if_allowed (void *cls, | |||
534 | ve->address->transport_name); | 539 | ve->address->transport_name); |
535 | 540 | ||
536 | slen = strlen (ve->address->transport_name) + 1; | 541 | slen = strlen (ve->address->transport_name) + 1; |
537 | hello = GST_hello_get (); | ||
538 | hsize = ntohs (hello->size); | 542 | hsize = ntohs (hello->size); |
539 | tsize = | 543 | tsize = |
540 | sizeof (struct TransportPingMessage) + ve->address->address_length + | 544 | sizeof (struct TransportPingMessage) + ve->address->address_length + |
@@ -900,7 +904,7 @@ GST_validation_start (unsigned int max_fds) | |||
900 | validations_running, | 904 | validations_running, |
901 | GNUNET_NO); | 905 | GNUNET_NO); |
902 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 906 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
903 | "Validation uses a fast start threshold of %u connections and a delay between of %s\n ", | 907 | "Validation uses a fast start threshold of %u connections and a delay of %s\n", |
904 | validations_fast_start_threshold, | 908 | validations_fast_start_threshold, |
905 | GNUNET_STRINGS_relative_time_to_string (validation_delay, | 909 | GNUNET_STRINGS_relative_time_to_string (validation_delay, |
906 | GNUNET_YES)); | 910 | GNUNET_YES)); |
diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c index 0087cfee3..3f20d30a5 100644 --- a/src/transport/plugin_transport_tcp.c +++ b/src/transport/plugin_transport_tcp.c | |||
@@ -559,7 +559,8 @@ tcp_nat_port_map_callback (void *cls, | |||
559 | void *arg; | 559 | void *arg; |
560 | size_t args; | 560 | size_t args; |
561 | 561 | ||
562 | LOG(GNUNET_ERROR_TYPE_INFO, "NAT notification to %s address `%s'\n", | 562 | LOG(GNUNET_ERROR_TYPE_INFO, |
563 | "NAT notification to %s address `%s'\n", | ||
563 | (GNUNET_YES == add_remove) ? "add" : "remove", | 564 | (GNUNET_YES == add_remove) ? "add" : "remove", |
564 | GNUNET_a2s (addr, addrlen)); | 565 | GNUNET_a2s (addr, addrlen)); |
565 | /* convert 'addr' to our internal format */ | 566 | /* convert 'addr' to our internal format */ |
@@ -2133,7 +2134,8 @@ handle_tcp_nat_probe (void *cls, | |||
2133 | const struct sockaddr_in *s4; | 2134 | const struct sockaddr_in *s4; |
2134 | const struct sockaddr_in6 *s6; | 2135 | const struct sockaddr_in6 *s6; |
2135 | 2136 | ||
2136 | LOG(GNUNET_ERROR_TYPE_DEBUG, "Received NAT probe\n"); | 2137 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2138 | "Received NAT probe\n"); | ||
2137 | /* We have received a TCP NAT probe, meaning we (hopefully) initiated | 2139 | /* We have received a TCP NAT probe, meaning we (hopefully) initiated |
2138 | * a connection to this peer by running gnunet-nat-client. This peer | 2140 | * a connection to this peer by running gnunet-nat-client. This peer |
2139 | * received the punch message and now wants us to use the new connection | 2141 | * received the punch message and now wants us to use the new connection |
@@ -2157,7 +2159,7 @@ handle_tcp_nat_probe (void *cls, | |||
2157 | } | 2159 | } |
2158 | 2160 | ||
2159 | session = GNUNET_CONTAINER_multipeermap_get (plugin->nat_wait_conns, | 2161 | session = GNUNET_CONTAINER_multipeermap_get (plugin->nat_wait_conns, |
2160 | &tcp_nat_probe->clientIdentity); | 2162 | &tcp_nat_probe->clientIdentity); |
2161 | if (session == NULL) | 2163 | if (session == NULL) |
2162 | { | 2164 | { |
2163 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2165 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -2877,8 +2879,14 @@ libgnunet_plugin_transport_tcp_init (void *cls) | |||
2877 | else | 2879 | else |
2878 | { | 2880 | { |
2879 | plugin->nat = GNUNET_NAT_register (plugin->env->cfg, | 2881 | plugin->nat = GNUNET_NAT_register (plugin->env->cfg, |
2880 | GNUNET_YES, 0, 0, NULL, NULL, NULL, | 2882 | GNUNET_YES, |
2881 | &try_connection_reversal, plugin); | 2883 | 0, |
2884 | 0, | ||
2885 | NULL, | ||
2886 | NULL, | ||
2887 | NULL, | ||
2888 | &try_connection_reversal, | ||
2889 | plugin); | ||
2882 | } | 2890 | } |
2883 | api = GNUNET_new (struct GNUNET_TRANSPORT_PluginFunctions); | 2891 | api = GNUNET_new (struct GNUNET_TRANSPORT_PluginFunctions); |
2884 | api->cls = plugin; | 2892 | api->cls = plugin; |
diff --git a/src/transport/plugin_transport_udp_broadcasting.c b/src/transport/plugin_transport_udp_broadcasting.c index d9596c0a6..413c79564 100644 --- a/src/transport/plugin_transport_udp_broadcasting.c +++ b/src/transport/plugin_transport_udp_broadcasting.c | |||
@@ -545,11 +545,10 @@ setup_broadcast (struct Plugin *plugin, | |||
545 | struct sockaddr_in6 *server_addrv6, | 545 | struct sockaddr_in6 *server_addrv6, |
546 | struct sockaddr_in *server_addrv4) | 546 | struct sockaddr_in *server_addrv4) |
547 | { | 547 | { |
548 | const struct GNUNET_MessageHeader *hello; | ||
549 | |||
550 | hello = plugin->env->get_our_hello (); | ||
551 | if (GNUNET_YES == | 548 | if (GNUNET_YES == |
552 | GNUNET_HELLO_is_friend_only ((const struct GNUNET_HELLO_Message *) hello)) | 549 | GNUNET_CONFIGURATION_get_value_yesno (plugin->env->cfg, |
550 | "topology", | ||
551 | "FRIENDS-ONLY")) | ||
553 | { | 552 | { |
554 | LOG (GNUNET_ERROR_TYPE_WARNING, | 553 | LOG (GNUNET_ERROR_TYPE_WARNING, |
555 | _("Disabling HELLO broadcasting due to friend-to-friend only configuration!\n")); | 554 | _("Disabling HELLO broadcasting due to friend-to-friend only configuration!\n")); |
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c index a5a72e8cc..42b7d8669 100644 --- a/src/transport/plugin_transport_wlan.c +++ b/src/transport/plugin_transport_wlan.c | |||
@@ -1681,9 +1681,11 @@ send_hello_beacon (void *cls, | |||
1681 | const struct GNUNET_MessageHeader *hello; | 1681 | const struct GNUNET_MessageHeader *hello; |
1682 | 1682 | ||
1683 | hello = plugin->env->get_our_hello (); | 1683 | hello = plugin->env->get_our_hello (); |
1684 | hello_size = GNUNET_HELLO_size ((struct GNUNET_HELLO_Message *) hello); | 1684 | if (NULL != hello) |
1685 | GNUNET_assert (sizeof (struct WlanHeader) + hello_size <= WLAN_MTU); | 1685 | { |
1686 | size = sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) + hello_size; | 1686 | hello_size = GNUNET_HELLO_size ((struct GNUNET_HELLO_Message *) hello); |
1687 | GNUNET_assert (sizeof (struct WlanHeader) + hello_size <= WLAN_MTU); | ||
1688 | size = sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) + hello_size; | ||
1687 | { | 1689 | { |
1688 | char buf[size] GNUNET_ALIGN; | 1690 | char buf[size] GNUNET_ALIGN; |
1689 | 1691 | ||
@@ -1706,7 +1708,7 @@ send_hello_beacon (void *cls, | |||
1706 | GNUNET_STATISTICS_update (plugin->env->stats, | 1708 | GNUNET_STATISTICS_update (plugin->env->stats, |
1707 | _("# HELLO beacons sent"), | 1709 | _("# HELLO beacons sent"), |
1708 | 1, GNUNET_NO); | 1710 | 1, GNUNET_NO); |
1709 | } | 1711 | } } |
1710 | plugin->beacon_task = | 1712 | plugin->beacon_task = |
1711 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 1713 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
1712 | (HELLO_BEACON_SCALING_FACTOR, | 1714 | (HELLO_BEACON_SCALING_FACTOR, |
diff --git a/src/transport/transport_api.c b/src/transport/transport_api.c index 2da1a90d6..2da6e9a54 100644 --- a/src/transport/transport_api.c +++ b/src/transport/transport_api.c | |||
@@ -355,7 +355,7 @@ struct GNUNET_TRANSPORT_Handle | |||
355 | * The current HELLO message for this peer. Updated | 355 | * The current HELLO message for this peer. Updated |
356 | * whenever transports change their addresses. | 356 | * whenever transports change their addresses. |
357 | */ | 357 | */ |
358 | struct GNUNET_HELLO_Message *my_hello; | 358 | struct GNUNET_MessageHeader *my_hello; |
359 | 359 | ||
360 | /** | 360 | /** |
361 | * My client connection to the transport service. | 361 | * My client connection to the transport service. |
@@ -655,7 +655,8 @@ demultiplexer (void *cls, | |||
655 | break; | 655 | break; |
656 | } | 656 | } |
657 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 657 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
658 | "Receiving (my own) `%s' message, I am `%4s'.\n", "HELLO", | 658 | "Receiving (my own) HELLO message (%u bytes), I am `%4s'.\n", |
659 | (unsigned int) size, | ||
659 | GNUNET_i2s (&me)); | 660 | GNUNET_i2s (&me)); |
660 | GNUNET_free_non_null (h->my_hello); | 661 | GNUNET_free_non_null (h->my_hello); |
661 | h->my_hello = NULL; | 662 | h->my_hello = NULL; |
@@ -664,14 +665,13 @@ demultiplexer (void *cls, | |||
664 | GNUNET_break (0); | 665 | GNUNET_break (0); |
665 | break; | 666 | break; |
666 | } | 667 | } |
667 | h->my_hello = GNUNET_malloc (size); | 668 | h->my_hello = GNUNET_copy_message (msg); |
668 | memcpy (h->my_hello, msg, size); | ||
669 | hwl = h->hwl_head; | 669 | hwl = h->hwl_head; |
670 | while (NULL != hwl) | 670 | while (NULL != hwl) |
671 | { | 671 | { |
672 | next_hwl = hwl->next; | 672 | next_hwl = hwl->next; |
673 | hwl->rec (hwl->rec_cls, | 673 | hwl->rec (hwl->rec_cls, |
674 | (const struct GNUNET_MessageHeader *) h->my_hello); | 674 | h->my_hello); |
675 | hwl = next_hwl; | 675 | hwl = next_hwl; |
676 | } | 676 | } |
677 | break; | 677 | break; |
@@ -1668,7 +1668,7 @@ call_hello_update_cb_async (void *cls, | |||
1668 | GNUNET_assert (NULL != ghh->notify_task); | 1668 | GNUNET_assert (NULL != ghh->notify_task); |
1669 | ghh->notify_task = NULL; | 1669 | ghh->notify_task = NULL; |
1670 | ghh->rec (ghh->rec_cls, | 1670 | ghh->rec (ghh->rec_cls, |
1671 | (const struct GNUNET_MessageHeader *) ghh->handle->my_hello); | 1671 | ghh->handle->my_hello); |
1672 | } | 1672 | } |
1673 | 1673 | ||
1674 | 1674 | ||
@@ -1696,7 +1696,7 @@ GNUNET_TRANSPORT_get_hello (struct GNUNET_TRANSPORT_Handle *handle, | |||
1696 | hwl->rec_cls = rec_cls; | 1696 | hwl->rec_cls = rec_cls; |
1697 | hwl->handle = handle; | 1697 | hwl->handle = handle; |
1698 | GNUNET_CONTAINER_DLL_insert (handle->hwl_head, handle->hwl_tail, hwl); | 1698 | GNUNET_CONTAINER_DLL_insert (handle->hwl_head, handle->hwl_tail, hwl); |
1699 | if (handle->my_hello != NULL) | 1699 | if (NULL != handle->my_hello) |
1700 | hwl->notify_task = GNUNET_SCHEDULER_add_now (&call_hello_update_cb_async, | 1700 | hwl->notify_task = GNUNET_SCHEDULER_add_now (&call_hello_update_cb_async, |
1701 | hwl); | 1701 | hwl); |
1702 | return hwl; | 1702 | return hwl; |