diff options
Diffstat (limited to 'src/transport/plugin_transport_udp.c')
-rw-r--r-- | src/transport/plugin_transport_udp.c | 301 |
1 files changed, 167 insertions, 134 deletions
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index a0d5072b8..1ef0bca98 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c | |||
@@ -267,7 +267,7 @@ struct BroadcastAddress | |||
267 | struct BroadcastAddress *next; | 267 | struct BroadcastAddress *next; |
268 | struct BroadcastAddress *prev; | 268 | struct BroadcastAddress *prev; |
269 | 269 | ||
270 | void * addr; | 270 | void *addr; |
271 | socklen_t addrlen; | 271 | socklen_t addrlen; |
272 | }; | 272 | }; |
273 | 273 | ||
@@ -540,8 +540,11 @@ destroy_session (void *cls, const GNUNET_HashCode * key, void *value) | |||
540 | struct Session *peer_session = value; | 540 | struct Session *peer_session = value; |
541 | 541 | ||
542 | GNUNET_assert (GNUNET_YES == | 542 | GNUNET_assert (GNUNET_YES == |
543 | GNUNET_CONTAINER_multihashmap_remove (peer_session->plugin->sessions, | 543 | GNUNET_CONTAINER_multihashmap_remove (peer_session-> |
544 | &peer_session->target.hashPubKey, peer_session)); | 544 | plugin->sessions, |
545 | &peer_session-> | ||
546 | target.hashPubKey, | ||
547 | peer_session)); | ||
545 | if (peer_session->frag != NULL) | 548 | if (peer_session->frag != NULL) |
546 | GNUNET_FRAGMENT_context_destroy (peer_session->frag); | 549 | GNUNET_FRAGMENT_context_destroy (peer_session->frag); |
547 | if (GNUNET_SCHEDULER_NO_TASK != peer_session->delayed_cont_task) | 550 | if (GNUNET_SCHEDULER_NO_TASK != peer_session->delayed_cont_task) |
@@ -568,7 +571,8 @@ destroy_inbound_session (void *cls, const GNUNET_HashCode * key, void *value) | |||
568 | GNUNET_SCHEDULER_cancel (s->invalidation_task); | 571 | GNUNET_SCHEDULER_cancel (s->invalidation_task); |
569 | if (GNUNET_SCHEDULER_NO_TASK != s->delayed_cont_task) | 572 | if (GNUNET_SCHEDULER_NO_TASK != s->delayed_cont_task) |
570 | GNUNET_SCHEDULER_cancel (s->delayed_cont_task); | 573 | GNUNET_SCHEDULER_cancel (s->delayed_cont_task); |
571 | GNUNET_CONTAINER_multihashmap_remove (s->plugin->inbound_sessions, &s->target.hashPubKey, s); | 574 | GNUNET_CONTAINER_multihashmap_remove (s->plugin->inbound_sessions, |
575 | &s->target.hashPubKey, s); | ||
572 | GNUNET_free (s); | 576 | GNUNET_free (s); |
573 | return GNUNET_OK; | 577 | return GNUNET_OK; |
574 | } | 578 | } |
@@ -1300,42 +1304,46 @@ udp_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock) | |||
1300 | switch (ntohs (msg->type)) | 1304 | switch (ntohs (msg->type)) |
1301 | { | 1305 | { |
1302 | case GNUNET_MESSAGE_TYPE_TRANSPORT_BROADCAST_BEACON: | 1306 | case GNUNET_MESSAGE_TYPE_TRANSPORT_BROADCAST_BEACON: |
1307 | { | ||
1308 | if (fromlen == sizeof (struct sockaddr_in)) | ||
1303 | { | 1309 | { |
1304 | if (fromlen == sizeof (struct sockaddr_in)) | 1310 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1305 | { | 1311 | "Received IPv4 HELLO beacon broadcast with %i bytes from address %s\n", |
1306 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Received IPv4 HELLO beacon broadcast with %i bytes from address %s\n", | 1312 | ret, GNUNET_a2s ((const struct sockaddr *) &addr, fromlen)); |
1307 | ret, GNUNET_a2s((const struct sockaddr *) &addr, fromlen)); | 1313 | |
1308 | 1314 | struct Mstv4Context *mc; | |
1309 | struct Mstv4Context *mc; | 1315 | |
1310 | mc = GNUNET_malloc (sizeof (struct Mstv4Context)); | 1316 | mc = GNUNET_malloc (sizeof (struct Mstv4Context)); |
1311 | struct sockaddr_in *av4 = (struct sockaddr_in *) &addr; | 1317 | struct sockaddr_in *av4 = (struct sockaddr_in *) &addr; |
1312 | 1318 | ||
1313 | mc->addr.ipv4_addr = av4->sin_addr.s_addr; | 1319 | mc->addr.ipv4_addr = av4->sin_addr.s_addr; |
1314 | mc->addr.u4_port = av4->sin_port; | 1320 | mc->addr.u4_port = av4->sin_port; |
1315 | if (GNUNET_OK != | 1321 | if (GNUNET_OK != |
1316 | GNUNET_SERVER_mst_receive (plugin->broadcast_ipv4_mst, mc, buf, ret, GNUNET_NO, | 1322 | GNUNET_SERVER_mst_receive (plugin->broadcast_ipv4_mst, mc, buf, ret, |
1317 | GNUNET_NO)) | 1323 | GNUNET_NO, GNUNET_NO)) |
1318 | GNUNET_free (mc); | 1324 | GNUNET_free (mc); |
1319 | } | 1325 | } |
1320 | else if (fromlen == sizeof (struct sockaddr_in6)) | 1326 | else if (fromlen == sizeof (struct sockaddr_in6)) |
1321 | { | 1327 | { |
1322 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Received IPv6 HELLO beacon broadcast with %i bytes from address %s\n", | 1328 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1323 | ret, GNUNET_a2s((const struct sockaddr *) &addr, fromlen)); | 1329 | "Received IPv6 HELLO beacon broadcast with %i bytes from address %s\n", |
1330 | ret, GNUNET_a2s ((const struct sockaddr *) &addr, fromlen)); | ||
1324 | 1331 | ||
1325 | struct Mstv6Context *mc; | 1332 | struct Mstv6Context *mc; |
1326 | mc = GNUNET_malloc (sizeof (struct Mstv6Context)); | ||
1327 | struct sockaddr_in6 *av6 = (struct sockaddr_in6 *) &addr; | ||
1328 | 1333 | ||
1329 | mc->addr.ipv6_addr = av6->sin6_addr; | 1334 | mc = GNUNET_malloc (sizeof (struct Mstv6Context)); |
1330 | mc->addr.u6_port = av6->sin6_port; | 1335 | struct sockaddr_in6 *av6 = (struct sockaddr_in6 *) &addr; |
1331 | 1336 | ||
1332 | if (GNUNET_OK != | 1337 | mc->addr.ipv6_addr = av6->sin6_addr; |
1333 | GNUNET_SERVER_mst_receive (plugin->broadcast_ipv6_mst, mc, buf, ret, GNUNET_NO, | 1338 | mc->addr.u6_port = av6->sin6_port; |
1334 | GNUNET_NO)) | 1339 | |
1335 | GNUNET_free (mc); | 1340 | if (GNUNET_OK != |
1336 | } | 1341 | GNUNET_SERVER_mst_receive (plugin->broadcast_ipv6_mst, mc, buf, ret, |
1337 | return; | 1342 | GNUNET_NO, GNUNET_NO)) |
1343 | GNUNET_free (mc); | ||
1338 | } | 1344 | } |
1345 | return; | ||
1346 | } | ||
1339 | case GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_MESSAGE: | 1347 | case GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_MESSAGE: |
1340 | if (ntohs (msg->size) < sizeof (struct UDPMessage)) | 1348 | if (ntohs (msg->size) < sizeof (struct UDPMessage)) |
1341 | { | 1349 | { |
@@ -1489,7 +1497,7 @@ udp_plugin_select (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1489 | 1497 | ||
1490 | void | 1498 | void |
1491 | broadcast_ipv4_mst_cb (void *cls, void *client, | 1499 | broadcast_ipv4_mst_cb (void *cls, void *client, |
1492 | const struct GNUNET_MessageHeader *message) | 1500 | const struct GNUNET_MessageHeader *message) |
1493 | { | 1501 | { |
1494 | struct Plugin *plugin = cls; | 1502 | struct Plugin *plugin = cls; |
1495 | struct Mstv4Context *mc = client; | 1503 | struct Mstv4Context *mc = client; |
@@ -1517,15 +1525,16 @@ broadcast_ipv4_mst_cb (void *cls, void *client, | |||
1517 | (const char *) &mc->addr, sizeof (mc->addr)); | 1525 | (const char *) &mc->addr, sizeof (mc->addr)); |
1518 | 1526 | ||
1519 | GNUNET_STATISTICS_update (plugin->env->stats, | 1527 | GNUNET_STATISTICS_update (plugin->env->stats, |
1520 | _("# IPv4 broadcast HELLO beacons received via udp"), 1, | 1528 | _ |
1521 | GNUNET_NO); | 1529 | ("# IPv4 broadcast HELLO beacons received via udp"), |
1530 | 1, GNUNET_NO); | ||
1522 | GNUNET_free (mc); | 1531 | GNUNET_free (mc); |
1523 | } | 1532 | } |
1524 | 1533 | ||
1525 | 1534 | ||
1526 | void | 1535 | void |
1527 | broadcast_ipv6_mst_cb (void *cls, void *client, | 1536 | broadcast_ipv6_mst_cb (void *cls, void *client, |
1528 | const struct GNUNET_MessageHeader *message) | 1537 | const struct GNUNET_MessageHeader *message) |
1529 | { | 1538 | { |
1530 | 1539 | ||
1531 | struct Plugin *plugin = cls; | 1540 | struct Plugin *plugin = cls; |
@@ -1554,14 +1563,16 @@ broadcast_ipv6_mst_cb (void *cls, void *client, | |||
1554 | (const char *) &mc->addr, sizeof (mc->addr)); | 1563 | (const char *) &mc->addr, sizeof (mc->addr)); |
1555 | 1564 | ||
1556 | GNUNET_STATISTICS_update (plugin->env->stats, | 1565 | GNUNET_STATISTICS_update (plugin->env->stats, |
1557 | _("# IPv6 multicast HELLO beacons received via udp"), 1, | 1566 | _ |
1558 | GNUNET_NO); | 1567 | ("# IPv6 multicast HELLO beacons received via udp"), |
1568 | 1, GNUNET_NO); | ||
1559 | GNUNET_free (mc); | 1569 | GNUNET_free (mc); |
1560 | } | 1570 | } |
1561 | 1571 | ||
1562 | 1572 | ||
1563 | static void | 1573 | static void |
1564 | udp_ipv4_broadcast_send (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 1574 | udp_ipv4_broadcast_send (void *cls, |
1575 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
1565 | { | 1576 | { |
1566 | struct Plugin *plugin = cls; | 1577 | struct Plugin *plugin = cls; |
1567 | int sent; | 1578 | int sent; |
@@ -1571,7 +1582,7 @@ udp_ipv4_broadcast_send (void *cls, const struct GNUNET_SCHEDULER_TaskContext *t | |||
1571 | 1582 | ||
1572 | const struct GNUNET_MessageHeader *hello; | 1583 | const struct GNUNET_MessageHeader *hello; |
1573 | struct UDP_Beacon_Message *msg; | 1584 | struct UDP_Beacon_Message *msg; |
1574 | struct BroadcastAddress * baddr; | 1585 | struct BroadcastAddress *baddr; |
1575 | 1586 | ||
1576 | plugin->send_ipv4_broadcast_task = GNUNET_SCHEDULER_NO_TASK; | 1587 | plugin->send_ipv4_broadcast_task = GNUNET_SCHEDULER_NO_TASK; |
1577 | 1588 | ||
@@ -1594,18 +1605,21 @@ udp_ipv4_broadcast_send (void *cls, const struct GNUNET_SCHEDULER_TaskContext *t | |||
1594 | /* just IPv4 */ | 1605 | /* just IPv4 */ |
1595 | while ((baddr != NULL) && (baddr->addrlen == sizeof (struct sockaddr_in))) | 1606 | while ((baddr != NULL) && (baddr->addrlen == sizeof (struct sockaddr_in))) |
1596 | { | 1607 | { |
1597 | struct sockaddr_in * addr = (struct sockaddr_in * ) baddr->addr; | 1608 | struct sockaddr_in *addr = (struct sockaddr_in *) baddr->addr; |
1609 | |||
1598 | addr->sin_port = htons (plugin->port); | 1610 | addr->sin_port = htons (plugin->port); |
1599 | 1611 | ||
1600 | sent = GNUNET_NETWORK_socket_sendto (plugin->sockv4, msg, msg_size, | 1612 | sent = |
1601 | (const struct sockaddr *) addr, | 1613 | GNUNET_NETWORK_socket_sendto (plugin->sockv4, msg, msg_size, |
1602 | baddr->addrlen); | 1614 | (const struct sockaddr *) addr, |
1615 | baddr->addrlen); | ||
1603 | if (sent == GNUNET_SYSERR) | 1616 | if (sent == GNUNET_SYSERR) |
1604 | GNUNET_log_strerror(GNUNET_ERROR_TYPE_ERROR, "sendto"); | 1617 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sendto"); |
1605 | else | 1618 | else |
1606 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Sent HELLO beacon broadcast with %i bytes to address %s\n", | 1619 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1607 | sent, GNUNET_a2s(baddr->addr, baddr->addrlen)); | 1620 | "Sent HELLO beacon broadcast with %i bytes to address %s\n", sent, |
1608 | baddr = baddr->next; | 1621 | GNUNET_a2s (baddr->addr, baddr->addrlen)); |
1622 | baddr = baddr->next; | ||
1609 | } | 1623 | } |
1610 | 1624 | ||
1611 | plugin->send_ipv4_broadcast_task = | 1625 | plugin->send_ipv4_broadcast_task = |
@@ -1614,7 +1628,8 @@ udp_ipv4_broadcast_send (void *cls, const struct GNUNET_SCHEDULER_TaskContext *t | |||
1614 | } | 1628 | } |
1615 | 1629 | ||
1616 | static void | 1630 | static void |
1617 | udp_ipv6_broadcast_send (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 1631 | udp_ipv6_broadcast_send (void *cls, |
1632 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
1618 | { | 1633 | { |
1619 | struct Plugin *plugin = cls; | 1634 | struct Plugin *plugin = cls; |
1620 | int sent; | 1635 | int sent; |
@@ -1642,14 +1657,19 @@ udp_ipv6_broadcast_send (void *cls, const struct GNUNET_SCHEDULER_TaskContext *t | |||
1642 | memcpy (&msg[1], hello, hello_size); | 1657 | memcpy (&msg[1], hello, hello_size); |
1643 | sent = 0; | 1658 | sent = 0; |
1644 | 1659 | ||
1645 | sent = GNUNET_NETWORK_socket_sendto (plugin->sockv6, msg, msg_size, | 1660 | sent = |
1646 | (const struct sockaddr *) &plugin->ipv6_multicast_address, | 1661 | GNUNET_NETWORK_socket_sendto (plugin->sockv6, msg, msg_size, |
1647 | sizeof(struct sockaddr_in6)); | 1662 | (const struct sockaddr *) |
1663 | &plugin->ipv6_multicast_address, | ||
1664 | sizeof (struct sockaddr_in6)); | ||
1648 | if (sent == GNUNET_SYSERR) | 1665 | if (sent == GNUNET_SYSERR) |
1649 | GNUNET_log_strerror(GNUNET_ERROR_TYPE_ERROR, "sendto"); | 1666 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sendto"); |
1650 | else | 1667 | else |
1651 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending IPv6 HELLO beacon broadcast with %i bytes to address %s\n", | 1668 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1652 | sent, GNUNET_a2s((const struct sockaddr *) &plugin->ipv6_multicast_address, sizeof(struct sockaddr_in6))); | 1669 | "Sending IPv6 HELLO beacon broadcast with %i bytes to address %s\n", |
1670 | sent, | ||
1671 | GNUNET_a2s ((const struct sockaddr *) &plugin->ipv6_multicast_address, | ||
1672 | sizeof (struct sockaddr_in6))); | ||
1653 | 1673 | ||
1654 | 1674 | ||
1655 | 1675 | ||
@@ -1953,33 +1973,33 @@ udp_nat_port_map_callback (void *cls, int add_remove, | |||
1953 | 1973 | ||
1954 | 1974 | ||
1955 | static int | 1975 | static int |
1956 | iface_proc (void *cls, const char *name, | 1976 | iface_proc (void *cls, const char *name, int isDefault, |
1957 | int isDefault, | 1977 | const struct sockaddr *addr, const struct sockaddr *broadcast_addr, |
1958 | const struct sockaddr * addr, | 1978 | const struct sockaddr *netmask, socklen_t addrlen) |
1959 | const struct sockaddr * broadcast_addr, | ||
1960 | const struct sockaddr * netmask, | ||
1961 | socklen_t addrlen) | ||
1962 | { | 1979 | { |
1963 | struct Plugin *plugin = cls; | 1980 | struct Plugin *plugin = cls; |
1964 | 1981 | ||
1965 | if (addr != NULL) | 1982 | if (addr != NULL) |
1966 | { | 1983 | { |
1967 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "address %s for interface %s %p\n ", | 1984 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "address %s for interface %s %p\n ", |
1968 | GNUNET_a2s(addr,addrlen), name, addr); | 1985 | GNUNET_a2s (addr, addrlen), name, addr); |
1969 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "broadcast address %s for interface %s %p\n ", | 1986 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1970 | GNUNET_a2s(broadcast_addr,addrlen), name, broadcast_addr); | 1987 | "broadcast address %s for interface %s %p\n ", |
1988 | GNUNET_a2s (broadcast_addr, addrlen), name, broadcast_addr); | ||
1971 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "netmask %s for interface %s %p\n ", | 1989 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "netmask %s for interface %s %p\n ", |
1972 | GNUNET_a2s(netmask,addrlen), name, netmask); | 1990 | GNUNET_a2s (netmask, addrlen), name, netmask); |
1973 | 1991 | ||
1974 | 1992 | ||
1975 | /* Collecting broadcast addresses*/ | 1993 | /* Collecting broadcast addresses */ |
1976 | if (broadcast_addr != NULL) | 1994 | if (broadcast_addr != NULL) |
1977 | { | 1995 | { |
1978 | struct BroadcastAddress * ba = GNUNET_malloc(sizeof (struct BroadcastAddress)); | 1996 | struct BroadcastAddress *ba = |
1979 | ba->addr = GNUNET_malloc(addrlen); | 1997 | GNUNET_malloc (sizeof (struct BroadcastAddress)); |
1980 | memcpy(ba->addr, broadcast_addr, addrlen); | 1998 | ba->addr = GNUNET_malloc (addrlen); |
1999 | memcpy (ba->addr, broadcast_addr, addrlen); | ||
1981 | ba->addrlen = addrlen; | 2000 | ba->addrlen = addrlen; |
1982 | GNUNET_CONTAINER_DLL_insert(plugin->ipv4_broadcast_head, plugin->ipv4_broadcast_tail, ba); | 2001 | GNUNET_CONTAINER_DLL_insert (plugin->ipv4_broadcast_head, |
2002 | plugin->ipv4_broadcast_tail, ba); | ||
1983 | } | 2003 | } |
1984 | } | 2004 | } |
1985 | return GNUNET_OK; | 2005 | return GNUNET_OK; |
@@ -2225,73 +2245,80 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
2225 | { | 2245 | { |
2226 | /* create IPv4 broadcast socket */ | 2246 | /* create IPv4 broadcast socket */ |
2227 | plugin->broadcast_ipv4 = GNUNET_NO; | 2247 | plugin->broadcast_ipv4 = GNUNET_NO; |
2228 | if (plugin->sockv4 != NULL) | 2248 | if (plugin->sockv4 != NULL) |
2229 | { | 2249 | { |
2230 | int yes = 1; | 2250 | int yes = 1; |
2231 | 2251 | ||
2232 | if (GNUNET_NETWORK_socket_setsockopt | 2252 | if (GNUNET_NETWORK_socket_setsockopt |
2233 | (plugin->sockv4, SOL_SOCKET, SO_BROADCAST, &yes, sizeof (int)) != GNUNET_OK) | 2253 | (plugin->sockv4, SOL_SOCKET, SO_BROADCAST, &yes, |
2234 | { | 2254 | sizeof (int)) != GNUNET_OK) |
2235 | LOG (GNUNET_ERROR_TYPE_WARNING, | 2255 | { |
2236 | _ | 2256 | LOG (GNUNET_ERROR_TYPE_WARNING, |
2237 | ("Failed to set IPv4 broadcast option for broadcast socket on port %d\n"), | 2257 | _ |
2238 | ntohs (serverAddrv4.sin_port)); | 2258 | ("Failed to set IPv4 broadcast option for broadcast socket on port %d\n"), |
2239 | } | 2259 | ntohs (serverAddrv4.sin_port)); |
2240 | else | 2260 | } |
2241 | { | 2261 | else |
2242 | GNUNET_OS_network_interfaces_list(iface_proc, plugin); | 2262 | { |
2243 | plugin->send_ipv4_broadcast_task = | 2263 | GNUNET_OS_network_interfaces_list (iface_proc, plugin); |
2264 | plugin->send_ipv4_broadcast_task = | ||
2244 | GNUNET_SCHEDULER_add_now (&udp_ipv4_broadcast_send, plugin); | 2265 | GNUNET_SCHEDULER_add_now (&udp_ipv4_broadcast_send, plugin); |
2245 | 2266 | ||
2246 | plugin->broadcast_ipv4_mst = | 2267 | plugin->broadcast_ipv4_mst = |
2247 | GNUNET_SERVER_mst_create (broadcast_ipv4_mst_cb, plugin); | 2268 | GNUNET_SERVER_mst_create (broadcast_ipv4_mst_cb, plugin); |
2248 | 2269 | ||
2249 | LOG (GNUNET_ERROR_TYPE_DEBUG, "IPv4 Broadcasting running\n"); | 2270 | LOG (GNUNET_ERROR_TYPE_DEBUG, "IPv4 Broadcasting running\n"); |
2250 | plugin->broadcast_ipv4 = GNUNET_YES; | 2271 | plugin->broadcast_ipv4 = GNUNET_YES; |
2251 | } | ||
2252 | } | 2272 | } |
2273 | } | ||
2253 | 2274 | ||
2254 | plugin->broadcast_ipv6 = GNUNET_NO; | 2275 | plugin->broadcast_ipv6 = GNUNET_NO; |
2255 | if (plugin->sockv6 != NULL) | 2276 | if (plugin->sockv6 != NULL) |
2277 | { | ||
2278 | memset (&plugin->ipv6_multicast_address, 0, sizeof (struct sockaddr_in6)); | ||
2279 | GNUNET_assert (1 == | ||
2280 | inet_pton (AF_INET6, "FF05::13B", | ||
2281 | &plugin->ipv6_multicast_address.sin6_addr)); | ||
2282 | |||
2283 | plugin->ipv6_multicast_address.sin6_family = AF_INET6; | ||
2284 | plugin->ipv6_multicast_address.sin6_port = htons (plugin->port); | ||
2285 | |||
2286 | plugin->broadcast_ipv6_mst = | ||
2287 | GNUNET_SERVER_mst_create (broadcast_ipv6_mst_cb, plugin); | ||
2288 | |||
2289 | /* Create IPv6 multicast request */ | ||
2290 | struct ipv6_mreq multicastRequest; | ||
2291 | |||
2292 | multicastRequest.ipv6mr_multiaddr = | ||
2293 | plugin->ipv6_multicast_address.sin6_addr; | ||
2294 | /* TODO: 0 selects the "best" interface, tweak to use all interfaces | ||
2295 | * | ||
2296 | * http://tools.ietf.org/html/rfc2553#section-5.2: | ||
2297 | * | ||
2298 | * IPV6_JOIN_GROUP | ||
2299 | * | ||
2300 | * Join a multicast group on a specified local interface. If the | ||
2301 | * interface index is specified as 0, the kernel chooses the local | ||
2302 | * interface. For example, some kernels look up the multicast | ||
2303 | * group in the normal IPv6 routing table and using the resulting | ||
2304 | * interface. | ||
2305 | * */ | ||
2306 | multicastRequest.ipv6mr_interface = 0; | ||
2307 | |||
2308 | /* Join the multicast group */ | ||
2309 | if (GNUNET_NETWORK_socket_setsockopt | ||
2310 | (plugin->sockv6, IPPROTO_IPV6, IPV6_JOIN_GROUP, | ||
2311 | (char *) &multicastRequest, sizeof (multicastRequest)) == GNUNET_OK) | ||
2256 | { | 2312 | { |
2257 | memset (&plugin->ipv6_multicast_address, 0, sizeof (struct sockaddr_in6)); | 2313 | LOG (GNUNET_ERROR_TYPE_DEBUG, "IPv6 broadcasting running\n"); |
2258 | GNUNET_assert (1 == inet_pton(AF_INET6, "FF05::13B", &plugin->ipv6_multicast_address.sin6_addr)); | ||
2259 | |||
2260 | plugin->ipv6_multicast_address.sin6_family = AF_INET6; | ||
2261 | plugin->ipv6_multicast_address.sin6_port = htons(plugin->port); | ||
2262 | |||
2263 | plugin->broadcast_ipv6_mst = | ||
2264 | GNUNET_SERVER_mst_create (broadcast_ipv6_mst_cb, plugin); | ||
2265 | |||
2266 | /* Create IPv6 multicast request */ | ||
2267 | struct ipv6_mreq multicastRequest; | ||
2268 | multicastRequest.ipv6mr_multiaddr = plugin->ipv6_multicast_address.sin6_addr; | ||
2269 | /* TODO: 0 selects the "best" interface, tweak to use all interfaces | ||
2270 | * | ||
2271 | * http://tools.ietf.org/html/rfc2553#section-5.2: | ||
2272 | * | ||
2273 | * IPV6_JOIN_GROUP | ||
2274 | * | ||
2275 | * Join a multicast group on a specified local interface. If the | ||
2276 | * interface index is specified as 0, the kernel chooses the local | ||
2277 | * interface. For example, some kernels look up the multicast | ||
2278 | * group in the normal IPv6 routing table and using the resulting | ||
2279 | * interface. | ||
2280 | * */ | ||
2281 | multicastRequest.ipv6mr_interface = 0; | ||
2282 | |||
2283 | /* Join the multicast group */ | ||
2284 | if ( GNUNET_NETWORK_socket_setsockopt( plugin->sockv6, IPPROTO_IPV6, IPV6_JOIN_GROUP, (char*) &multicastRequest, sizeof(multicastRequest)) == GNUNET_OK ) | ||
2285 | { | ||
2286 | LOG (GNUNET_ERROR_TYPE_DEBUG, "IPv6 broadcasting running\n"); | ||
2287 | 2314 | ||
2288 | plugin->send_ipv6_broadcast_task = | 2315 | plugin->send_ipv6_broadcast_task = |
2289 | GNUNET_SCHEDULER_add_now (&udp_ipv6_broadcast_send, plugin); | 2316 | GNUNET_SCHEDULER_add_now (&udp_ipv6_broadcast_send, plugin); |
2290 | plugin->broadcast_ipv6 = GNUNET_YES; | 2317 | plugin->broadcast_ipv6 = GNUNET_YES; |
2291 | } | ||
2292 | else | ||
2293 | LOG (GNUNET_ERROR_TYPE_DEBUG, "IPv6 broadcasting not running\n"); | ||
2294 | } | 2318 | } |
2319 | else | ||
2320 | LOG (GNUNET_ERROR_TYPE_DEBUG, "IPv6 broadcasting not running\n"); | ||
2321 | } | ||
2295 | } | 2322 | } |
2296 | 2323 | ||
2297 | if (sockets_created == 0) | 2324 | if (sockets_created == 0) |
@@ -2351,8 +2378,10 @@ libgnunet_plugin_transport_udp_done (void *cls) | |||
2351 | 2378 | ||
2352 | while (plugin->ipv4_broadcast_head != NULL) | 2379 | while (plugin->ipv4_broadcast_head != NULL) |
2353 | { | 2380 | { |
2354 | struct BroadcastAddress * p= plugin->ipv4_broadcast_head; | 2381 | struct BroadcastAddress *p = plugin->ipv4_broadcast_head; |
2355 | GNUNET_CONTAINER_DLL_remove(plugin->ipv4_broadcast_head, plugin->ipv4_broadcast_tail, p); | 2382 | |
2383 | GNUNET_CONTAINER_DLL_remove (plugin->ipv4_broadcast_head, | ||
2384 | plugin->ipv4_broadcast_tail, p); | ||
2356 | GNUNET_free (p->addr); | 2385 | GNUNET_free (p->addr); |
2357 | GNUNET_free (p); | 2386 | GNUNET_free (p); |
2358 | } | 2387 | } |
@@ -2362,16 +2391,20 @@ libgnunet_plugin_transport_udp_done (void *cls) | |||
2362 | { | 2391 | { |
2363 | /* Create IPv6 multicast request */ | 2392 | /* Create IPv6 multicast request */ |
2364 | struct ipv6_mreq multicastRequest; | 2393 | struct ipv6_mreq multicastRequest; |
2365 | multicastRequest.ipv6mr_multiaddr = plugin->ipv6_multicast_address.sin6_addr; | 2394 | |
2395 | multicastRequest.ipv6mr_multiaddr = | ||
2396 | plugin->ipv6_multicast_address.sin6_addr; | ||
2366 | multicastRequest.ipv6mr_interface = 0; | 2397 | multicastRequest.ipv6mr_interface = 0; |
2367 | 2398 | ||
2368 | /* Join the multicast address */ | 2399 | /* Join the multicast address */ |
2369 | if ( GNUNET_NETWORK_socket_setsockopt( plugin->sockv6, IPPROTO_IPV6, IPV6_LEAVE_GROUP, (char*) &multicastRequest, sizeof(multicastRequest)) == 0 ) | 2400 | if (GNUNET_NETWORK_socket_setsockopt |
2401 | (plugin->sockv6, IPPROTO_IPV6, IPV6_LEAVE_GROUP, | ||
2402 | (char *) &multicastRequest, sizeof (multicastRequest)) == 0) | ||
2370 | { | 2403 | { |
2371 | LOG (GNUNET_ERROR_TYPE_DEBUG, "IPv6 Broadcasting stopped\n"); | 2404 | LOG (GNUNET_ERROR_TYPE_DEBUG, "IPv6 Broadcasting stopped\n"); |
2372 | } | 2405 | } |
2373 | else | 2406 | else |
2374 | GNUNET_log_strerror(GNUNET_ERROR_TYPE_ERROR, setsockopt); | 2407 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, setsockopt); |
2375 | 2408 | ||
2376 | if (plugin->send_ipv6_broadcast_task != GNUNET_SCHEDULER_NO_TASK) | 2409 | if (plugin->send_ipv6_broadcast_task != GNUNET_SCHEDULER_NO_TASK) |
2377 | { | 2410 | { |