diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-10-05 15:28:21 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-10-05 15:28:21 +0000 |
commit | ef76e090bf279f25038c03eec4eac96bbfbe952e (patch) | |
tree | 9e70dd991daefef65cd85dbcdc4bc4d19b7fedb0 /src/transport | |
parent | 8c85bda93a8ece52f02af7f20fb797ad6ac79337 (diff) | |
download | gnunet-ef76e090bf279f25038c03eec4eac96bbfbe952e.tar.gz gnunet-ef76e090bf279f25038c03eec4eac96bbfbe952e.zip |
fix #3986
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/gnunet-service-transport.c | 16 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_hello.c | 65 | ||||
-rw-r--r-- | src/transport/plugin_transport_udp.c | 10 |
3 files changed, 62 insertions, 29 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index f545b29f9..9cf4bdcac 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c | |||
@@ -515,23 +515,31 @@ plugin_env_address_change_notification (void *cls, | |||
515 | if (GNUNET_YES == add_remove) | 515 | if (GNUNET_YES == add_remove) |
516 | { | 516 | { |
517 | addresses ++; | 517 | addresses ++; |
518 | GNUNET_STATISTICS_update (cfg, "# transport addresses", 1, GNUNET_NO); | 518 | GNUNET_STATISTICS_update (cfg, |
519 | "# transport addresses", | ||
520 | 1, | ||
521 | GNUNET_NO); | ||
519 | } | 522 | } |
520 | else if (GNUNET_NO == add_remove) | 523 | else if (GNUNET_NO == add_remove) |
521 | { | 524 | { |
522 | if (0 == addresses) | 525 | if (0 == addresses) |
526 | { | ||
523 | GNUNET_break (0); | 527 | GNUNET_break (0); |
528 | } | ||
524 | else | 529 | else |
525 | { | 530 | { |
526 | addresses --; | 531 | addresses --; |
527 | GNUNET_STATISTICS_update (cfg, "# transport addresses", -1, GNUNET_NO); | 532 | GNUNET_STATISTICS_update (cfg, |
533 | "# transport addresses", | ||
534 | -1, | ||
535 | GNUNET_NO); | ||
528 | } | 536 | } |
529 | } | 537 | } |
530 | |||
531 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 538 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
532 | "Transport now has %u addresses to communicate\n", | 539 | "Transport now has %u addresses to communicate\n", |
533 | addresses); | 540 | addresses); |
534 | GST_hello_modify_addresses (add_remove, address); | 541 | GST_hello_modify_addresses (add_remove, |
542 | address); | ||
535 | } | 543 | } |
536 | 544 | ||
537 | 545 | ||
diff --git a/src/transport/gnunet-service-transport_hello.c b/src/transport/gnunet-service-transport_hello.c index 4607902a2..f1a16f112 100644 --- a/src/transport/gnunet-service-transport_hello.c +++ b/src/transport/gnunet-service-transport_hello.c | |||
@@ -76,6 +76,13 @@ struct OwnAddressList | |||
76 | */ | 76 | */ |
77 | struct GNUNET_CRYPTO_EddsaSignature pong_signature; | 77 | struct GNUNET_CRYPTO_EddsaSignature pong_signature; |
78 | 78 | ||
79 | /** | ||
80 | * How often has this address been added/removed? Used as | ||
81 | * some plugins may learn the same external address from | ||
82 | * multiple origins. | ||
83 | */ | ||
84 | unsigned int rc; | ||
85 | |||
79 | }; | 86 | }; |
80 | 87 | ||
81 | 88 | ||
@@ -133,7 +140,7 @@ struct GeneratorContext | |||
133 | 140 | ||
134 | 141 | ||
135 | /** | 142 | /** |
136 | * Add an address from the 'OwnAddressList' to the buffer. | 143 | * Add an address from the `struct OwnAddressList` to the buffer. |
137 | * | 144 | * |
138 | * @param cls the `struct GeneratorContext` | 145 | * @param cls the `struct GeneratorContext` |
139 | * @param max maximum number of bytes left | 146 | * @param max maximum number of bytes left |
@@ -151,8 +158,10 @@ address_generator (void *cls, | |||
151 | 158 | ||
152 | if (NULL == gc->addr_pos) | 159 | if (NULL == gc->addr_pos) |
153 | return GNUNET_SYSERR; /* Done */ | 160 | return GNUNET_SYSERR; /* Done */ |
154 | ret = GNUNET_HELLO_add_address (gc->addr_pos->address, gc->expiration, buf, | 161 | ret = GNUNET_HELLO_add_address (gc->addr_pos->address, |
155 | max); | 162 | gc->expiration, |
163 | buf, | ||
164 | max); | ||
156 | gc->addr_pos = gc->addr_pos->next; | 165 | gc->addr_pos = gc->addr_pos->next; |
157 | return ret; | 166 | return ret; |
158 | } | 167 | } |
@@ -267,7 +276,7 @@ GST_hello_stop () | |||
267 | const struct GNUNET_MessageHeader * | 276 | const struct GNUNET_MessageHeader * |
268 | GST_hello_get () | 277 | GST_hello_get () |
269 | { | 278 | { |
270 | return (struct GNUNET_MessageHeader *) our_hello; | 279 | return (const struct GNUNET_MessageHeader *) our_hello; |
271 | } | 280 | } |
272 | 281 | ||
273 | 282 | ||
@@ -284,28 +293,44 @@ GST_hello_modify_addresses (int addremove, | |||
284 | struct OwnAddressList *al; | 293 | struct OwnAddressList *al; |
285 | 294 | ||
286 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 295 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
287 | (addremove == | 296 | (GNUNET_YES == addremove) |
288 | GNUNET_YES) ? "Adding `%s' to the set of our addresses\n" : | 297 | ? "Adding `%s' to the set of our addresses\n" |
289 | "Removing `%s' from the set of our addresses\n", | 298 | : "Removing `%s' from the set of our addresses\n", |
290 | GST_plugins_a2s (address)); | 299 | GST_plugins_a2s (address)); |
291 | GNUNET_assert (address != NULL); | 300 | GNUNET_assert (NULL != address); |
301 | for (al = oal_head; al != NULL; al = al->next) | ||
302 | if (0 == GNUNET_HELLO_address_cmp (address, al->address)) | ||
303 | break; | ||
292 | if (GNUNET_NO == addremove) | 304 | if (GNUNET_NO == addremove) |
293 | { | 305 | { |
294 | for (al = oal_head; al != NULL; al = al->next) | 306 | if (NULL == al) |
295 | if (0 == GNUNET_HELLO_address_cmp (address, al->address)) | 307 | { |
296 | { | 308 | /* address to be removed not found!? */ |
297 | GNUNET_CONTAINER_DLL_remove (oal_head, oal_tail, al); | 309 | GNUNET_break (0); |
298 | GNUNET_HELLO_address_free (al->address); | 310 | return; |
299 | GNUNET_free (al); | 311 | } |
300 | refresh_hello (); | 312 | al->rc--; |
301 | return; | 313 | if (0 != al->rc) |
302 | } | 314 | return; /* RC not yet zero */ |
303 | /* address to be removed not found!? */ | 315 | GNUNET_CONTAINER_DLL_remove (oal_head, |
304 | GNUNET_break (0); | 316 | oal_tail, |
317 | al); | ||
318 | GNUNET_HELLO_address_free (al->address); | ||
319 | GNUNET_free (al); | ||
320 | refresh_hello (); | ||
321 | return; | ||
322 | } | ||
323 | if (NULL != al) | ||
324 | { | ||
325 | /* address added twice or more */ | ||
326 | al->rc++; | ||
305 | return; | 327 | return; |
306 | } | 328 | } |
307 | al = GNUNET_new (struct OwnAddressList); | 329 | al = GNUNET_new (struct OwnAddressList); |
308 | GNUNET_CONTAINER_DLL_insert (oal_head, oal_tail, al); | 330 | al->rc = 1; |
331 | GNUNET_CONTAINER_DLL_insert (oal_head, | ||
332 | oal_tail, | ||
333 | al); | ||
309 | al->address = GNUNET_HELLO_address_copy (address); | 334 | al->address = GNUNET_HELLO_address_copy (address); |
310 | refresh_hello (); | 335 | refresh_hello (); |
311 | } | 336 | } |
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index 5836f28bc..c7ee5b6e5 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c | |||
@@ -2855,11 +2855,11 @@ udp_select_read (struct Plugin *plugin, | |||
2855 | return; | 2855 | return; |
2856 | } | 2856 | } |
2857 | 2857 | ||
2858 | 2858 | /* Check if this is a STUN packet */ | |
2859 | /* PROCESS STUN PACKET */ | 2859 | if (GNUNET_NAT_is_valid_stun_packet (plugin->nat, |
2860 | if(GNUNET_NAT_is_valid_stun_packet(plugin->nat,(uint8_t *)buf, size )) | 2860 | (uint8_t *)buf, |
2861 | return; | 2861 | size)) |
2862 | 2862 | return; /* was STUN, do not process further */ | |
2863 | 2863 | ||
2864 | if (size < sizeof(struct GNUNET_MessageHeader)) | 2864 | if (size < sizeof(struct GNUNET_MessageHeader)) |
2865 | { | 2865 | { |