aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/transport/plugin_transport_udp.c53
-rw-r--r--src/transport/test_transport_api_udp_peer1.conf5
-rw-r--r--src/transport/transport.conf4
3 files changed, 49 insertions, 13 deletions
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c
index 84c7ce661..9ad97449c 100644
--- a/src/transport/plugin_transport_udp.c
+++ b/src/transport/plugin_transport_udp.c
@@ -2253,7 +2253,7 @@ libgnunet_plugin_transport_udp_init (void *cls)
2253 if (plugin->sockv6 != NULL) 2253 if (plugin->sockv6 != NULL)
2254 { 2254 {
2255 memset (&plugin->ipv6_multicast_address, 0, sizeof (struct sockaddr_in6)); 2255 memset (&plugin->ipv6_multicast_address, 0, sizeof (struct sockaddr_in6));
2256 GNUNET_assert (1 == inet_pton(AF_INET6, "ff02::1", &plugin->ipv6_multicast_address.sin6_addr)); 2256 GNUNET_assert (1 == inet_pton(AF_INET6, "FF05::13B", &plugin->ipv6_multicast_address.sin6_addr));
2257 2257
2258 plugin->ipv6_multicast_address.sin6_family = AF_INET6; 2258 plugin->ipv6_multicast_address.sin6_family = AF_INET6;
2259 plugin->ipv6_multicast_address.sin6_port = htons(plugin->port); 2259 plugin->ipv6_multicast_address.sin6_port = htons(plugin->port);
@@ -2261,12 +2261,34 @@ libgnunet_plugin_transport_udp_init (void *cls)
2261 plugin->broadcast_ipv6_mst = 2261 plugin->broadcast_ipv6_mst =
2262 GNUNET_SERVER_mst_create (broadcast_ipv6_mst_cb, plugin); 2262 GNUNET_SERVER_mst_create (broadcast_ipv6_mst_cb, plugin);
2263 2263
2264 LOG (GNUNET_ERROR_TYPE_DEBUG, "IPv6 Broadcasting running\n"); 2264 /* Create IPv6 multicast request */
2265 2265 struct ipv6_mreq multicastRequest;
2266 multicastRequest.ipv6mr_multiaddr = plugin->ipv6_multicast_address.sin6_addr;
2267 /* TODO: 0 selects the "best" interface, tweak to use all interfaces
2268 *
2269 * http://tools.ietf.org/html/rfc2553#section-5.2:
2270 *
2271 * IPV6_JOIN_GROUP
2272 *
2273 * Join a multicast group on a specified local interface. If the
2274 * interface index is specified as 0, the kernel chooses the local
2275 * interface. For example, some kernels look up the multicast
2276 * group in the normal IPv6 routing table and using the resulting
2277 * interface.
2278 * */
2279 multicastRequest.ipv6mr_interface = 0;
2280
2281 /* Join the multicast group */
2282 if ( GNUNET_NETWORK_socket_setsockopt( plugin->sockv6, IPPROTO_IPV6, IPV6_JOIN_GROUP, (char*) &multicastRequest, sizeof(multicastRequest)) == GNUNET_OK )
2283 {
2284 LOG (GNUNET_ERROR_TYPE_DEBUG, "IPv6 broadcasting running\n");
2266 2285
2267 plugin->send_ipv6_broadcast_task = 2286 plugin->send_ipv6_broadcast_task =
2268 GNUNET_SCHEDULER_add_now (&udp_ipv6_broadcast_send, plugin); 2287 GNUNET_SCHEDULER_add_now (&udp_ipv6_broadcast_send, plugin);
2269 plugin->broadcast_ipv6 = GNUNET_YES; 2288 plugin->broadcast_ipv6 = GNUNET_YES;
2289 }
2290 else
2291 LOG (GNUNET_ERROR_TYPE_DEBUG, "IPv6 broadcasting not running\n");
2270 } 2292 }
2271 } 2293 }
2272 2294
@@ -2277,7 +2299,6 @@ libgnunet_plugin_transport_udp_init (void *cls)
2277 (const struct sockaddr **) addrs, addrlens, 2299 (const struct sockaddr **) addrs, addrlens,
2278 &udp_nat_port_map_callback, NULL, plugin); 2300 &udp_nat_port_map_callback, NULL, plugin);
2279 return api; 2301 return api;
2280 udp_ipv6_broadcast_send(NULL, NULL);
2281} 2302}
2282 2303
2283/** 2304/**
@@ -2347,12 +2368,28 @@ libgnunet_plugin_transport_udp_done (void *cls)
2347 2368
2348 if (plugin->broadcast_ipv6) 2369 if (plugin->broadcast_ipv6)
2349 { 2370 {
2371 /* Create IPv6 multicast request */
2372 struct ipv6_mreq multicastRequest;
2373 multicastRequest.ipv6mr_multiaddr = plugin->ipv6_multicast_address.sin6_addr;
2374 multicastRequest.ipv6mr_interface = 0;
2375
2376 /* Join the multicast address */
2377 if ( GNUNET_NETWORK_socket_setsockopt( plugin->sockv6, IPPROTO_IPV6, IPV6_LEAVE_GROUP, (char*) &multicastRequest, sizeof(multicastRequest)) == 0 )
2378 {
2379 LOG (GNUNET_ERROR_TYPE_DEBUG, "IPv6 Broadcasting stopped\n");
2380
2381 plugin->send_ipv6_broadcast_task =
2382 GNUNET_SCHEDULER_add_now (&udp_ipv6_broadcast_send, plugin);
2383 plugin->broadcast_ipv6 = GNUNET_YES;
2384 }
2385 else
2386 GNUNET_log_strerror(GNUNET_ERROR_TYPE_ERROR, setsockopt);
2387
2350 if (plugin->send_ipv6_broadcast_task != GNUNET_SCHEDULER_NO_TASK) 2388 if (plugin->send_ipv6_broadcast_task != GNUNET_SCHEDULER_NO_TASK)
2351 { 2389 {
2352 GNUNET_SCHEDULER_cancel (plugin->send_ipv6_broadcast_task); 2390 GNUNET_SCHEDULER_cancel (plugin->send_ipv6_broadcast_task);
2353 plugin->send_ipv6_broadcast_task = GNUNET_SCHEDULER_NO_TASK; 2391 plugin->send_ipv6_broadcast_task = GNUNET_SCHEDULER_NO_TASK;
2354 } 2392 }
2355
2356 if (plugin->broadcast_ipv6_mst != NULL) 2393 if (plugin->broadcast_ipv6_mst != NULL)
2357 GNUNET_SERVER_mst_destroy (plugin->broadcast_ipv6_mst); 2394 GNUNET_SERVER_mst_destroy (plugin->broadcast_ipv6_mst);
2358 } 2395 }
diff --git a/src/transport/test_transport_api_udp_peer1.conf b/src/transport/test_transport_api_udp_peer1.conf
index a1413679f..f8b0ae47c 100644
--- a/src/transport/test_transport_api_udp_peer1.conf
+++ b/src/transport/test_transport_api_udp_peer1.conf
@@ -5,9 +5,8 @@ DEFAULTCONFIG = test_transport_api_udp_peer1.conf
5 5
6[transport-udp] 6[transport-udp]
7PORT = 12040 7PORT = 12040
8#BROADCAST = YES 8BROADCAST = YES
9BROADCAST_PORT = 20089 9BROADCAST_INTERVAL = 30000
10#BROADCAST_INTERVAL = 30000
11MAX_BPS = 50000000 10MAX_BPS = 50000000
12 11
13[arm] 12[arm]
diff --git a/src/transport/transport.conf b/src/transport/transport.conf
index ddcf83e55..7fe3d9532 100644
--- a/src/transport/transport.conf
+++ b/src/transport/transport.conf
@@ -42,8 +42,8 @@ MAX_CONNECTIONS = 128
42 42
43[transport-udp] 43[transport-udp]
44PORT = 2086 44PORT = 2086
45#BROADCAST = YES 45BROADCAST = YES
46#BROADCAST_INTERVAL = 30000 46BROADCAST_INTERVAL = 30000
47MAX_BPS = 1000000 47MAX_BPS = 1000000
48 48
49[transport-http] 49[transport-http]