diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2013-05-16 12:45:56 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2013-05-16 12:45:56 +0000 |
commit | 3a03bbb4b950948d18e0e6c263fad2dca4e1a7c5 (patch) | |
tree | fcd38eb2e5e60a161a1dfe6da7880f349b450b5e /src/transport | |
parent | 12b5faf3eeb5bd10b3ad6f74d6f74d90299dbb3c (diff) | |
download | gnunet-3a03bbb4b950948d18e0e6c263fad2dca4e1a7c5.tar.gz gnunet-3a03bbb4b950948d18e0e6c263fad2dca4e1a7c5.zip |
fixing memory leaks in udp
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/plugin_transport_udp.c | 177 | ||||
-rw-r--r-- | src/transport/plugin_transport_udp.h | 7 | ||||
-rw-r--r-- | src/transport/plugin_transport_udp_broadcasting.c | 4 |
3 files changed, 100 insertions, 88 deletions
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index b6d4b3f30..9a32515e7 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c | |||
@@ -442,7 +442,7 @@ schedule_select (struct Plugin *plugin) | |||
442 | struct GNUNET_TIME_Relative min_delay; | 442 | struct GNUNET_TIME_Relative min_delay; |
443 | struct UDP_MessageWrapper *udpw; | 443 | struct UDP_MessageWrapper *udpw; |
444 | 444 | ||
445 | if (NULL != plugin->sockv4) | 445 | if ((GNUNET_YES == plugin->enable_ipv4) && (NULL != plugin->sockv4)) |
446 | { | 446 | { |
447 | /* Find a message ready to send: | 447 | /* Find a message ready to send: |
448 | * Flow delay from other peer is expired or not set (0) */ | 448 | * Flow delay from other peer is expired or not set (0) */ |
@@ -464,7 +464,7 @@ schedule_select (struct Plugin *plugin) | |||
464 | (0 == min_delay.rel_value) ? plugin->ws_v4 : NULL, | 464 | (0 == min_delay.rel_value) ? plugin->ws_v4 : NULL, |
465 | &udp_plugin_select, plugin); | 465 | &udp_plugin_select, plugin); |
466 | } | 466 | } |
467 | if (NULL != plugin->sockv6) | 467 | if ((GNUNET_YES == plugin->enable_ipv6) && (NULL != plugin->sockv6)) |
468 | { | 468 | { |
469 | min_delay = GNUNET_TIME_UNIT_FOREVER_REL; | 469 | min_delay = GNUNET_TIME_UNIT_FOREVER_REL; |
470 | for (udpw = plugin->ipv6_queue_head; NULL != udpw; udpw = udpw->next) | 470 | for (udpw = plugin->ipv6_queue_head; NULL != udpw; udpw = udpw->next) |
@@ -2495,7 +2495,7 @@ udp_plugin_select_v6 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2495 | */ | 2495 | */ |
2496 | static int | 2496 | static int |
2497 | setup_sockets (struct Plugin *plugin, | 2497 | setup_sockets (struct Plugin *plugin, |
2498 | const struct sockaddr_in6 *bind_v6, | 2498 | const struct sockaddr_in6 *bind_v6, |
2499 | const struct sockaddr_in *bind_v4) | 2499 | const struct sockaddr_in *bind_v4) |
2500 | { | 2500 | { |
2501 | int tries; | 2501 | int tries; |
@@ -2530,38 +2530,36 @@ setup_sockets (struct Plugin *plugin, | |||
2530 | else | 2530 | else |
2531 | serverAddrv6.sin6_addr = in6addr_any; | 2531 | serverAddrv6.sin6_addr = in6addr_any; |
2532 | 2532 | ||
2533 | if (0 == plugin->port) | 2533 | if (0 == plugin->port) /* autodetect */ |
2534 | /* autodetect */ | 2534 | serverAddrv6.sin6_port = htons (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000); |
2535 | serverAddrv6.sin6_port = htons (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000); | ||
2536 | else | 2535 | else |
2537 | serverAddrv6.sin6_port = htons (plugin->port); | 2536 | serverAddrv6.sin6_port = htons (plugin->port); |
2538 | addrlen = sizeof (struct sockaddr_in6); | 2537 | addrlen = sizeof (struct sockaddr_in6); |
2539 | serverAddr = (struct sockaddr *) &serverAddrv6; | 2538 | serverAddr = (struct sockaddr *) &serverAddrv6; |
2540 | 2539 | ||
2541 | tries = 0; | 2540 | tries = 0; |
2542 | while (tries < 10) | 2541 | while (tries < 10) |
2543 | { | 2542 | { |
2544 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Binding to IPv6 `%s'\n", | 2543 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Binding to IPv6 `%s'\n", |
2545 | GNUNET_a2s (serverAddr, addrlen)); | 2544 | GNUNET_a2s (serverAddr, addrlen)); |
2546 | 2545 | /* binding */ | |
2547 | /* binding */ | 2546 | if (GNUNET_OK == GNUNET_NETWORK_socket_bind (plugin->sockv6, |
2548 | if (GNUNET_OK == GNUNET_NETWORK_socket_bind (plugin->sockv6, serverAddr, addrlen)) | 2547 | serverAddr, addrlen)) |
2549 | break; | 2548 | break; |
2550 | eno = errno; | 2549 | eno = errno; |
2551 | if (0 != plugin->port) | 2550 | if (0 != plugin->port) |
2552 | { | 2551 | { |
2553 | tries = 10; /* fail */ | 2552 | tries = 10; /* fail */ |
2554 | break; /* bind failed on specific port */ | 2553 | break; /* bind failed on specific port */ |
2555 | } | 2554 | } |
2556 | 2555 | /* autodetect */ | |
2557 | /* autodetect */ | 2556 | serverAddrv6.sin6_port = htons (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000); |
2558 | serverAddrv6.sin6_port = htons (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000); | 2557 | tries ++; |
2559 | tries ++; | ||
2560 | } | 2558 | } |
2561 | |||
2562 | if (tries >= 10) | 2559 | if (tries >= 10) |
2563 | { | 2560 | { |
2564 | GNUNET_NETWORK_socket_close (plugin->sockv6); | 2561 | GNUNET_NETWORK_socket_close (plugin->sockv6); |
2562 | plugin->enable_ipv6 = GNUNET_NO; | ||
2565 | plugin->sockv6 = NULL; | 2563 | plugin->sockv6 = NULL; |
2566 | } | 2564 | } |
2567 | 2565 | ||
@@ -2618,16 +2616,17 @@ setup_sockets (struct Plugin *plugin, | |||
2618 | while (tries < 10) | 2616 | while (tries < 10) |
2619 | { | 2617 | { |
2620 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Binding to IPv4 `%s'\n", | 2618 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Binding to IPv4 `%s'\n", |
2621 | GNUNET_a2s (serverAddr, addrlen)); | 2619 | GNUNET_a2s (serverAddr, addrlen)); |
2622 | 2620 | ||
2623 | /* binding */ | 2621 | /* binding */ |
2624 | if (GNUNET_OK == GNUNET_NETWORK_socket_bind (plugin->sockv4, serverAddr, addrlen)) | 2622 | if (GNUNET_OK == GNUNET_NETWORK_socket_bind (plugin->sockv4, |
2625 | break; | 2623 | serverAddr, addrlen)) |
2624 | break; | ||
2626 | eno = errno; | 2625 | eno = errno; |
2627 | if (0 != plugin->port) | 2626 | if (0 != plugin->port) |
2628 | { | 2627 | { |
2629 | tries = 10; /* fail */ | 2628 | tries = 10; /* fail */ |
2630 | break; /* bind failed on specific port */ | 2629 | break; /* bind failed on specific port */ |
2631 | } | 2630 | } |
2632 | 2631 | ||
2633 | /* autodetect */ | 2632 | /* autodetect */ |
@@ -2638,14 +2637,14 @@ setup_sockets (struct Plugin *plugin, | |||
2638 | if (tries >= 10) | 2637 | if (tries >= 10) |
2639 | { | 2638 | { |
2640 | GNUNET_NETWORK_socket_close (plugin->sockv4); | 2639 | GNUNET_NETWORK_socket_close (plugin->sockv4); |
2640 | plugin->enable_ipv4 = GNUNET_NO; | ||
2641 | plugin->sockv4 = NULL; | 2641 | plugin->sockv4 = NULL; |
2642 | } | 2642 | } |
2643 | 2643 | ||
2644 | if (plugin->sockv4 != NULL) | 2644 | if (plugin->sockv4 != NULL) |
2645 | { | 2645 | { |
2646 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2646 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2647 | "IPv4 socket created on port %s\n", | 2647 | "IPv4 socket created on port %s\n", GNUNET_a2s (serverAddr, addrlen)); |
2648 | GNUNET_a2s (serverAddr, addrlen)); | ||
2649 | addrs[sockets_created] = (struct sockaddr *) &serverAddrv4; | 2648 | addrs[sockets_created] = (struct sockaddr *) &serverAddrv4; |
2650 | addrlens[sockets_created] = sizeof (struct sockaddr_in); | 2649 | addrlens[sockets_created] = sizeof (struct sockaddr_in); |
2651 | sockets_created++; | 2650 | sockets_created++; |
@@ -2653,25 +2652,31 @@ setup_sockets (struct Plugin *plugin, | |||
2653 | else | 2652 | else |
2654 | { | 2653 | { |
2655 | LOG (GNUNET_ERROR_TYPE_ERROR, | 2654 | LOG (GNUNET_ERROR_TYPE_ERROR, |
2656 | "Failed to bind UDP socket to %s: %s\n", | 2655 | "Failed to bind UDP socket to %s: %s\n", |
2657 | GNUNET_a2s (serverAddr, addrlen), | 2656 | GNUNET_a2s (serverAddr, addrlen), STRERROR (eno)); |
2658 | STRERROR (eno)); | ||
2659 | } | 2657 | } |
2660 | } | 2658 | } |
2661 | 2659 | ||
2660 | if (0 == sockets_created) | ||
2661 | { | ||
2662 | LOG (GNUNET_ERROR_TYPE_WARNING, _("Failed to open UDP sockets\n")); | ||
2663 | return 0; /* No sockets created, return */ | ||
2664 | } | ||
2665 | |||
2662 | /* Create file descriptors */ | 2666 | /* Create file descriptors */ |
2663 | plugin->rs_v4 = GNUNET_NETWORK_fdset_create (); | 2667 | if (plugin->enable_ipv4 == GNUNET_YES) |
2664 | plugin->ws_v4 = GNUNET_NETWORK_fdset_create (); | ||
2665 | GNUNET_NETWORK_fdset_zero (plugin->rs_v4); | ||
2666 | GNUNET_NETWORK_fdset_zero (plugin->ws_v4); | ||
2667 | if (NULL != plugin->sockv4) | ||
2668 | { | 2668 | { |
2669 | GNUNET_NETWORK_fdset_set (plugin->rs_v4, plugin->sockv4); | 2669 | plugin->rs_v4 = GNUNET_NETWORK_fdset_create (); |
2670 | GNUNET_NETWORK_fdset_set (plugin->ws_v4, plugin->sockv4); | 2670 | plugin->ws_v4 = GNUNET_NETWORK_fdset_create (); |
2671 | GNUNET_NETWORK_fdset_zero (plugin->rs_v4); | ||
2672 | GNUNET_NETWORK_fdset_zero (plugin->ws_v4); | ||
2673 | if (NULL != plugin->sockv4) | ||
2674 | { | ||
2675 | GNUNET_NETWORK_fdset_set (plugin->rs_v4, plugin->sockv4); | ||
2676 | GNUNET_NETWORK_fdset_set (plugin->ws_v4, plugin->sockv4); | ||
2677 | } | ||
2671 | } | 2678 | } |
2672 | 2679 | ||
2673 | if (0 == sockets_created) | ||
2674 | LOG (GNUNET_ERROR_TYPE_WARNING, _("Failed to open UDP sockets\n")); | ||
2675 | if (plugin->enable_ipv6 == GNUNET_YES) | 2680 | if (plugin->enable_ipv6 == GNUNET_YES) |
2676 | { | 2681 | { |
2677 | plugin->rs_v6 = GNUNET_NETWORK_fdset_create (); | 2682 | plugin->rs_v6 = GNUNET_NETWORK_fdset_create (); |
@@ -2684,8 +2689,7 @@ setup_sockets (struct Plugin *plugin, | |||
2684 | GNUNET_NETWORK_fdset_set (plugin->ws_v6, plugin->sockv6); | 2689 | GNUNET_NETWORK_fdset_set (plugin->ws_v6, plugin->sockv6); |
2685 | } | 2690 | } |
2686 | } | 2691 | } |
2687 | if (0 == sockets_created) | 2692 | |
2688 | return 0; | ||
2689 | schedule_select (plugin); | 2693 | schedule_select (plugin); |
2690 | plugin->nat = GNUNET_NAT_register (plugin->env->cfg, | 2694 | plugin->nat = GNUNET_NAT_register (plugin->env->cfg, |
2691 | GNUNET_NO, plugin->port, | 2695 | GNUNET_NO, plugin->port, |
@@ -2737,7 +2741,7 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
2737 | return api; | 2741 | return api; |
2738 | } | 2742 | } |
2739 | 2743 | ||
2740 | GNUNET_assert( NULL != env->stats); | 2744 | GNUNET_assert (NULL != env->stats); |
2741 | 2745 | ||
2742 | /* Get port number: port == 0 : autodetect a port, | 2746 | /* Get port number: port == 0 : autodetect a port, |
2743 | * > 0 : use this port, | 2747 | * > 0 : use this port, |
@@ -2762,9 +2766,7 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
2762 | if ((GNUNET_YES == | 2766 | if ((GNUNET_YES == |
2763 | GNUNET_CONFIGURATION_get_value_yesno (env->cfg, "nat", | 2767 | GNUNET_CONFIGURATION_get_value_yesno (env->cfg, "nat", |
2764 | "DISABLEV6"))) | 2768 | "DISABLEV6"))) |
2765 | { | ||
2766 | enable_v6 = GNUNET_NO; | 2769 | enable_v6 = GNUNET_NO; |
2767 | } | ||
2768 | else | 2770 | else |
2769 | enable_v6 = GNUNET_YES; | 2771 | enable_v6 = GNUNET_YES; |
2770 | 2772 | ||
@@ -2785,6 +2787,7 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
2785 | } | 2787 | } |
2786 | have_bind4 = GNUNET_YES; | 2788 | have_bind4 = GNUNET_YES; |
2787 | } | 2789 | } |
2790 | GNUNET_free_non_null (bind4_address); | ||
2788 | have_bind6 = GNUNET_NO; | 2791 | have_bind6 = GNUNET_NO; |
2789 | memset (&serverAddrv6, 0, sizeof (serverAddrv6)); | 2792 | memset (&serverAddrv6, 0, sizeof (serverAddrv6)); |
2790 | if (GNUNET_YES == | 2793 | if (GNUNET_YES == |
@@ -2805,6 +2808,7 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
2805 | } | 2808 | } |
2806 | have_bind6 = GNUNET_YES; | 2809 | have_bind6 = GNUNET_YES; |
2807 | } | 2810 | } |
2811 | GNUNET_free_non_null (bind6_address); | ||
2808 | 2812 | ||
2809 | /* Enable neighbour discovery */ | 2813 | /* Enable neighbour discovery */ |
2810 | broadcast = GNUNET_CONFIGURATION_get_value_yesno (env->cfg, "transport-udp", | 2814 | broadcast = GNUNET_CONFIGURATION_get_value_yesno (env->cfg, "transport-udp", |
@@ -2834,51 +2838,49 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
2834 | } | 2838 | } |
2835 | 2839 | ||
2836 | p = GNUNET_malloc (sizeof (struct Plugin)); | 2840 | p = GNUNET_malloc (sizeof (struct Plugin)); |
2837 | |||
2838 | GNUNET_BANDWIDTH_tracker_init (&p->tracker, | ||
2839 | GNUNET_BANDWIDTH_value_init ((uint32_t)udp_max_bps), 30); | ||
2840 | p->sessions = GNUNET_CONTAINER_multihashmap_create (10, GNUNET_NO); | ||
2841 | p->defrag_ctxs = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); | ||
2842 | p->mst = GNUNET_SERVER_mst_create (&process_inbound_tokenized_messages, p); | ||
2843 | p->port = port; | 2841 | p->port = port; |
2844 | p->aport = aport; | 2842 | p->aport = aport; |
2845 | p->broadcast_interval = interval; | 2843 | p->broadcast_interval = interval; |
2846 | p->enable_ipv6 = enable_v6; | 2844 | p->enable_ipv6 = enable_v6; |
2845 | p->enable_ipv4 = GNUNET_YES; /* default */ | ||
2847 | p->env = env; | 2846 | p->env = env; |
2848 | 2847 | p->sessions = GNUNET_CONTAINER_multihashmap_create (10, GNUNET_NO); | |
2848 | p->defrag_ctxs = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); | ||
2849 | p->mst = GNUNET_SERVER_mst_create (&process_inbound_tokenized_messages, p); | ||
2850 | GNUNET_BANDWIDTH_tracker_init (&p->tracker, | ||
2851 | GNUNET_BANDWIDTH_value_init ((uint32_t)udp_max_bps), 30); | ||
2849 | plugin = p; | 2852 | plugin = p; |
2850 | api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions)); | ||
2851 | api->cls = p; | ||
2852 | api->send = NULL; | ||
2853 | api->disconnect = &udp_disconnect; | ||
2854 | api->address_pretty_printer = &udp_plugin_address_pretty_printer; | ||
2855 | api->address_to_string = &udp_address_to_string; | ||
2856 | api->string_to_address = &udp_string_to_address; | ||
2857 | api->check_address = &udp_plugin_check_address; | ||
2858 | api->get_session = &udp_plugin_get_session; | ||
2859 | api->send = &udp_plugin_send; | ||
2860 | 2853 | ||
2861 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Setting up sockets\n"); | 2854 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Setting up sockets\n"); |
2862 | res = setup_sockets (p, (GNUNET_YES == have_bind6) ? &serverAddrv6 : NULL, | 2855 | res = setup_sockets (p, (GNUNET_YES == have_bind6) ? &serverAddrv6 : NULL, |
2863 | (GNUNET_YES == have_bind4) ? &serverAddrv4 : NULL); | 2856 | (GNUNET_YES == have_bind4) ? &serverAddrv4 : NULL); |
2864 | if ((res == 0) || ((p->sockv4 == NULL) && (p->sockv6 == NULL))) | 2857 | if ((res == 0) || ((p->sockv4 == NULL) && (p->sockv6 == NULL))) |
2865 | { | 2858 | { |
2866 | /* FIXME: memory leaks here! (i.e. p->mst, sessions, defrag_ctxs, etc.) */ | ||
2867 | LOG (GNUNET_ERROR_TYPE_ERROR, | 2859 | LOG (GNUNET_ERROR_TYPE_ERROR, |
2868 | _("Failed to create network sockets, plugin failed\n")); | 2860 | _("Failed to create network sockets, plugin failed\n")); |
2861 | GNUNET_CONTAINER_multihashmap_destroy (p->sessions); | ||
2862 | GNUNET_CONTAINER_heap_destroy (p->defrag_ctxs); | ||
2863 | GNUNET_SERVER_mst_destroy (p->mst); | ||
2869 | GNUNET_free (p); | 2864 | GNUNET_free (p); |
2870 | GNUNET_free (api); | ||
2871 | return NULL; | 2865 | return NULL; |
2872 | } | 2866 | } |
2873 | 2867 | else if (broadcast == GNUNET_YES) | |
2874 | if (broadcast == GNUNET_YES) | ||
2875 | { | 2868 | { |
2876 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Starting broadcasting\n"); | 2869 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Starting broadcasting\n"); |
2877 | setup_broadcast (p, &serverAddrv6, &serverAddrv4); | 2870 | setup_broadcast (p, &serverAddrv6, &serverAddrv4); |
2878 | } | 2871 | } |
2879 | 2872 | ||
2880 | GNUNET_free_non_null (bind4_address); | 2873 | api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions)); |
2881 | GNUNET_free_non_null (bind6_address); | 2874 | api->cls = p; |
2875 | api->send = NULL; | ||
2876 | api->disconnect = &udp_disconnect; | ||
2877 | api->address_pretty_printer = &udp_plugin_address_pretty_printer; | ||
2878 | api->address_to_string = &udp_address_to_string; | ||
2879 | api->string_to_address = &udp_string_to_address; | ||
2880 | api->check_address = &udp_plugin_check_address; | ||
2881 | api->get_session = &udp_plugin_get_session; | ||
2882 | api->send = &udp_plugin_send; | ||
2883 | |||
2882 | return api; | 2884 | return api; |
2883 | } | 2885 | } |
2884 | 2886 | ||
@@ -2932,24 +2934,29 @@ libgnunet_plugin_transport_udp_done (void *cls) | |||
2932 | } | 2934 | } |
2933 | 2935 | ||
2934 | /* Closing sockets */ | 2936 | /* Closing sockets */ |
2935 | if (plugin->sockv4 != NULL) | 2937 | if (GNUNET_YES ==plugin->enable_ipv4) |
2936 | { | 2938 | { |
2937 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (plugin->sockv4)); | 2939 | if (plugin->sockv4 != NULL) |
2938 | plugin->sockv4 = NULL; | 2940 | { |
2941 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (plugin->sockv4)); | ||
2942 | plugin->sockv4 = NULL; | ||
2943 | } | ||
2944 | GNUNET_NETWORK_fdset_destroy (plugin->rs_v4); | ||
2945 | GNUNET_NETWORK_fdset_destroy (plugin->ws_v4); | ||
2939 | } | 2946 | } |
2940 | GNUNET_NETWORK_fdset_destroy (plugin->rs_v4); | 2947 | if (GNUNET_YES ==plugin->enable_ipv6) |
2941 | GNUNET_NETWORK_fdset_destroy (plugin->ws_v4); | ||
2942 | |||
2943 | if (plugin->sockv6 != NULL) | ||
2944 | { | 2948 | { |
2945 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (plugin->sockv6)); | 2949 | if (plugin->sockv6 != NULL) |
2946 | plugin->sockv6 = NULL; | 2950 | { |
2951 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (plugin->sockv6)); | ||
2952 | plugin->sockv6 = NULL; | ||
2947 | 2953 | ||
2948 | GNUNET_NETWORK_fdset_destroy (plugin->rs_v6); | 2954 | GNUNET_NETWORK_fdset_destroy (plugin->rs_v6); |
2949 | GNUNET_NETWORK_fdset_destroy (plugin->ws_v6); | 2955 | GNUNET_NETWORK_fdset_destroy (plugin->ws_v6); |
2956 | } | ||
2950 | } | 2957 | } |
2951 | 2958 | if (NULL != plugin->nat) | |
2952 | GNUNET_NAT_unregister (plugin->nat); | 2959 | GNUNET_NAT_unregister (plugin->nat); |
2953 | 2960 | ||
2954 | if (plugin->defrag_ctxs != NULL) | 2961 | if (plugin->defrag_ctxs != NULL) |
2955 | { | 2962 | { |
diff --git a/src/transport/plugin_transport_udp.h b/src/transport/plugin_transport_udp.h index bab8e6cf0..fe46bf85b 100644 --- a/src/transport/plugin_transport_udp.h +++ b/src/transport/plugin_transport_udp.h | |||
@@ -251,11 +251,16 @@ struct Plugin | |||
251 | struct BroadcastAddress *ipv4_broadcast_head; | 251 | struct BroadcastAddress *ipv4_broadcast_head; |
252 | 252 | ||
253 | /** | 253 | /** |
254 | * Enable IPv6 | 254 | * Is IPv6 enabled: GNUNET_YES or GNUNET_NO |
255 | */ | 255 | */ |
256 | int enable_ipv6; | 256 | int enable_ipv6; |
257 | 257 | ||
258 | /** | 258 | /** |
259 | * Is IPv4 enabled: GNUNET_YES or GNUNET_NO | ||
260 | */ | ||
261 | int enable_ipv4; | ||
262 | |||
263 | /** | ||
259 | * Port we broadcasting on. | 264 | * Port we broadcasting on. |
260 | */ | 265 | */ |
261 | uint16_t broadcast_port; | 266 | uint16_t broadcast_port; |
diff --git a/src/transport/plugin_transport_udp_broadcasting.c b/src/transport/plugin_transport_udp_broadcasting.c index a2278f293..1f8490d5e 100644 --- a/src/transport/plugin_transport_udp_broadcasting.c +++ b/src/transport/plugin_transport_udp_broadcasting.c | |||
@@ -407,7 +407,7 @@ setup_broadcast (struct Plugin *plugin, struct sockaddr_in6 *serverAddrv6, struc | |||
407 | 407 | ||
408 | /* create IPv4 broadcast socket */ | 408 | /* create IPv4 broadcast socket */ |
409 | plugin->broadcast_ipv4 = GNUNET_NO; | 409 | plugin->broadcast_ipv4 = GNUNET_NO; |
410 | if (plugin->sockv4 != NULL) | 410 | if ((GNUNET_YES == plugin->enable_ipv4) && (plugin->sockv4 != NULL)) |
411 | { | 411 | { |
412 | int yes = 1; | 412 | int yes = 1; |
413 | 413 | ||
@@ -435,7 +435,7 @@ setup_broadcast (struct Plugin *plugin, struct sockaddr_in6 *serverAddrv6, struc | |||
435 | } | 435 | } |
436 | 436 | ||
437 | plugin->broadcast_ipv6 = GNUNET_NO; | 437 | plugin->broadcast_ipv6 = GNUNET_NO; |
438 | if (plugin->sockv6 != NULL) | 438 | if ((GNUNET_YES == plugin->enable_ipv4) && (plugin->sockv6 != NULL)) |
439 | { | 439 | { |
440 | memset (&plugin->ipv6_multicast_address, 0, sizeof (struct sockaddr_in6)); | 440 | memset (&plugin->ipv6_multicast_address, 0, sizeof (struct sockaddr_in6)); |
441 | GNUNET_assert (1 == | 441 | GNUNET_assert (1 == |