diff options
Diffstat (limited to 'src/transport/plugin_transport_udp.c')
-rw-r--r-- | src/transport/plugin_transport_udp.c | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index 791272e19..f8c68244a 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c | |||
@@ -217,7 +217,7 @@ struct UDP_NAT_ProbeMessageConfirmation | |||
217 | */ | 217 | */ |
218 | struct LocalAddrList | 218 | struct LocalAddrList |
219 | { | 219 | { |
220 | 220 | ||
221 | /** | 221 | /** |
222 | * This is a doubly linked list. | 222 | * This is a doubly linked list. |
223 | */ | 223 | */ |
@@ -334,12 +334,12 @@ struct UDP_NAT_Probes | |||
334 | struct UDP_Sock_Info | 334 | struct UDP_Sock_Info |
335 | { | 335 | { |
336 | /** | 336 | /** |
337 | * The network handle | 337 | * The network handle |
338 | */ | 338 | */ |
339 | struct GNUNET_NETWORK_Handle *desc; | 339 | struct GNUNET_NETWORK_Handle *desc; |
340 | 340 | ||
341 | /** | 341 | /** |
342 | * The port we bound to | 342 | * The port we bound to |
343 | */ | 343 | */ |
344 | uint16_t port; | 344 | uint16_t port; |
345 | }; | 345 | }; |
@@ -410,10 +410,10 @@ struct Plugin | |||
410 | * List of our IP addresses. | 410 | * List of our IP addresses. |
411 | */ | 411 | */ |
412 | struct LocalAddrList *lal_head; | 412 | struct LocalAddrList *lal_head; |
413 | 413 | ||
414 | /** | 414 | /** |
415 | * Tail of our IP address list. | 415 | * Tail of our IP address list. |
416 | */ | 416 | */ |
417 | struct LocalAddrList *lal_tail; | 417 | struct LocalAddrList *lal_tail; |
418 | 418 | ||
419 | /** | 419 | /** |
@@ -537,7 +537,7 @@ udp_transport_server_stop (void *cls) | |||
537 | 537 | ||
538 | 538 | ||
539 | struct PeerSession * | 539 | struct PeerSession * |
540 | find_session (struct Plugin *plugin, | 540 | find_session (struct Plugin *plugin, |
541 | const struct GNUNET_PeerIdentity *peer) | 541 | const struct GNUNET_PeerIdentity *peer) |
542 | { | 542 | { |
543 | struct PeerSession *pos; | 543 | struct PeerSession *pos; |
@@ -669,7 +669,7 @@ udp_real_send (void *cls, | |||
669 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 669 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
670 | "UDP transmit %u-byte message to %s (%d: %s)\n", | 670 | "UDP transmit %u-byte message to %s (%d: %s)\n", |
671 | (unsigned int) ssize, | 671 | (unsigned int) ssize, |
672 | GNUNET_a2s (sb, sbs), | 672 | GNUNET_a2s (sb, sbs), |
673 | (int) sent, | 673 | (int) sent, |
674 | (sent < 0) ? STRERROR (errno) : "ok"); | 674 | (sent < 0) ? STRERROR (errno) : "ok"); |
675 | if (cont != NULL) | 675 | if (cont != NULL) |
@@ -833,7 +833,7 @@ udp_plugin_send (void *cls, | |||
833 | target, | 833 | target, |
834 | msgbuf, msgbuf_size, | 834 | msgbuf, msgbuf_size, |
835 | priority, timeout, | 835 | priority, timeout, |
836 | peer_session->connect_addr, peer_session->connect_alen, | 836 | peer_session->connect_addr, peer_session->connect_alen, |
837 | cont, cont_cls); | 837 | cont, cont_cls); |
838 | } | 838 | } |
839 | else /* Haven't gotten a response from this peer, queue message */ | 839 | else /* Haven't gotten a response from this peer, queue message */ |
@@ -852,11 +852,11 @@ udp_plugin_send (void *cls, | |||
852 | } | 852 | } |
853 | else if (other_peer_natd == GNUNET_NO) /* Other peer not behind a NAT, so we can just send the message as is */ | 853 | else if (other_peer_natd == GNUNET_NO) /* Other peer not behind a NAT, so we can just send the message as is */ |
854 | { | 854 | { |
855 | sent = udp_real_send(cls, | 855 | sent = udp_real_send(cls, |
856 | (addrlen == sizeof (struct IPv4UdpAddress)) ? plugin->udp_sockv4.desc : plugin->udp_sockv6.desc, | 856 | (addrlen == sizeof (struct IPv4UdpAddress)) ? plugin->udp_sockv4.desc : plugin->udp_sockv6.desc, |
857 | target, | 857 | target, |
858 | msgbuf, msgbuf_size, | 858 | msgbuf, msgbuf_size, |
859 | priority, timeout, addr, addrlen, | 859 | priority, timeout, addr, addrlen, |
860 | cont, cont_cls); | 860 | cont, cont_cls); |
861 | } | 861 | } |
862 | else /* Other peer is NAT'd, but we don't want to play with them (or can't!) */ | 862 | else /* Other peer is NAT'd, but we don't want to play with them (or can't!) */ |
@@ -1008,12 +1008,12 @@ process_interfaces (void *cls, | |||
1008 | GNUNET_break (0); | 1008 | GNUNET_break (0); |
1009 | return GNUNET_OK; | 1009 | return GNUNET_OK; |
1010 | } | 1010 | } |
1011 | 1011 | ||
1012 | GNUNET_log (GNUNET_ERROR_TYPE_INFO | | 1012 | GNUNET_log (GNUNET_ERROR_TYPE_INFO | |
1013 | GNUNET_ERROR_TYPE_BULK, | 1013 | GNUNET_ERROR_TYPE_BULK, |
1014 | _("Found address `%s' (%s)\n"), | 1014 | _("Found address `%s' (%s)\n"), |
1015 | GNUNET_a2s (addr, addrlen), name); | 1015 | GNUNET_a2s (addr, addrlen), name); |
1016 | 1016 | ||
1017 | if (addr_nat != NULL) | 1017 | if (addr_nat != NULL) |
1018 | { | 1018 | { |
1019 | plugin->env->notify_address (plugin->env->cls, | 1019 | plugin->env->notify_address (plugin->env->cls, |
@@ -1083,11 +1083,11 @@ send_udp_probe_message (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc | |||
1083 | _("Sending a probe to port %d\n"), ntohs(probe->addr.u_port)); | 1083 | _("Sending a probe to port %d\n"), ntohs(probe->addr.u_port)); |
1084 | #endif | 1084 | #endif |
1085 | probe->count++; | 1085 | probe->count++; |
1086 | udp_real_send(plugin, | 1086 | udp_real_send(plugin, |
1087 | plugin->udp_sockv4.desc, | 1087 | plugin->udp_sockv4.desc, |
1088 | NULL, | 1088 | NULL, |
1089 | (char *)&message, ntohs(message.header.size), 0, | 1089 | (char *)&message, ntohs(message.header.size), 0, |
1090 | GNUNET_TIME_relative_get_unit(), | 1090 | GNUNET_TIME_relative_get_unit(), |
1091 | &probe->addr, sizeof(struct IPv4UdpAddress), | 1091 | &probe->addr, sizeof(struct IPv4UdpAddress), |
1092 | &udp_probe_continuation, probe); | 1092 | &udp_probe_continuation, probe); |
1093 | } | 1093 | } |
@@ -1329,7 +1329,7 @@ udp_demultiplexer(struct Plugin *plugin, struct GNUNET_PeerIdentity *sender, | |||
1329 | if (fromlen == sizeof(struct IPv4UdpAddress)) | 1329 | if (fromlen == sizeof(struct IPv4UdpAddress)) |
1330 | { | 1330 | { |
1331 | memset(&addr_buf, 0, sizeof(addr_buf)); | 1331 | memset(&addr_buf, 0, sizeof(addr_buf)); |
1332 | if (NULL == inet_ntop (AF_INET, | 1332 | if (NULL == inet_ntop (AF_INET, |
1333 | &((struct IPv4UdpAddress *) sender_addr)->ipv4_addr, addr_buf, | 1333 | &((struct IPv4UdpAddress *) sender_addr)->ipv4_addr, addr_buf, |
1334 | INET_ADDRSTRLEN)) | 1334 | INET_ADDRSTRLEN)) |
1335 | { | 1335 | { |
@@ -1346,10 +1346,10 @@ udp_demultiplexer(struct Plugin *plugin, struct GNUNET_PeerIdentity *sender, | |||
1346 | outgoing_probe_confirmation = GNUNET_malloc(sizeof(struct UDP_NAT_ProbeMessageConfirmation)); | 1346 | outgoing_probe_confirmation = GNUNET_malloc(sizeof(struct UDP_NAT_ProbeMessageConfirmation)); |
1347 | outgoing_probe_confirmation->header.size = htons(sizeof(struct UDP_NAT_ProbeMessageConfirmation)); | 1347 | outgoing_probe_confirmation->header.size = htons(sizeof(struct UDP_NAT_ProbeMessageConfirmation)); |
1348 | outgoing_probe_confirmation->header.type = htons(GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_NAT_PROBE_CONFIRM); | 1348 | outgoing_probe_confirmation->header.type = htons(GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_NAT_PROBE_CONFIRM); |
1349 | udp_real_send(plugin, sockinfo->desc, NULL, | 1349 | udp_real_send(plugin, sockinfo->desc, NULL, |
1350 | (char *)outgoing_probe_confirmation, | 1350 | (char *)outgoing_probe_confirmation, |
1351 | ntohs(outgoing_probe_confirmation->header.size), 0, | 1351 | ntohs(outgoing_probe_confirmation->header.size), 0, |
1352 | GNUNET_TIME_relative_get_unit(), | 1352 | GNUNET_TIME_relative_get_unit(), |
1353 | sender_addr, fromlen, NULL, NULL); | 1353 | sender_addr, fromlen, NULL, NULL); |
1354 | 1354 | ||
1355 | if (outgoing_probe->task != GNUNET_SCHEDULER_NO_TASK) | 1355 | if (outgoing_probe->task != GNUNET_SCHEDULER_NO_TASK) |
@@ -1476,7 +1476,7 @@ udp_demultiplexer(struct Plugin *plugin, struct GNUNET_PeerIdentity *sender, | |||
1476 | "Sending message type %d to transport!\n", | 1476 | "Sending message type %d to transport!\n", |
1477 | ntohs(currhdr->type)); | 1477 | ntohs(currhdr->type)); |
1478 | #endif | 1478 | #endif |
1479 | plugin->env->receive (plugin->env->cls, sender, currhdr, UDP_DIRECT_DISTANCE, | 1479 | plugin->env->receive (plugin->env->cls, sender, currhdr, UDP_DIRECT_DISTANCE, |
1480 | NULL, sender_addr, fromlen); | 1480 | NULL, sender_addr, fromlen); |
1481 | } | 1481 | } |
1482 | 1482 | ||
@@ -1637,10 +1637,10 @@ udp_transport_server_start (void *cls) | |||
1637 | plugin->internal_address); | 1637 | plugin->internal_address); |
1638 | #endif | 1638 | #endif |
1639 | /* Start the server process */ | 1639 | /* Start the server process */ |
1640 | plugin->server_pid = GNUNET_OS_start_process(NULL, | 1640 | plugin->server_pid = GNUNET_OS_start_process(NULL, |
1641 | plugin->server_stdout, | 1641 | plugin->server_stdout, |
1642 | "gnunet-nat-server", | 1642 | "gnunet-nat-server", |
1643 | "gnunet-nat-server", | 1643 | "gnunet-nat-server", |
1644 | plugin->internal_address, NULL); | 1644 | plugin->internal_address, NULL); |
1645 | if (plugin->server_pid == GNUNET_SYSERR) | 1645 | if (plugin->server_pid == GNUNET_SYSERR) |
1646 | { | 1646 | { |
@@ -1652,7 +1652,7 @@ udp_transport_server_start (void *cls) | |||
1652 | } | 1652 | } |
1653 | /* Close the write end of the read pipe */ | 1653 | /* Close the write end of the read pipe */ |
1654 | GNUNET_DISK_pipe_close_end(plugin->server_stdout, GNUNET_DISK_PIPE_END_WRITE); | 1654 | GNUNET_DISK_pipe_close_end(plugin->server_stdout, GNUNET_DISK_PIPE_END_WRITE); |
1655 | 1655 | ||
1656 | plugin->server_stdout_handle = GNUNET_DISK_pipe_handle(plugin->server_stdout, GNUNET_DISK_PIPE_END_READ); | 1656 | plugin->server_stdout_handle = GNUNET_DISK_pipe_handle(plugin->server_stdout, GNUNET_DISK_PIPE_END_READ); |
1657 | plugin->server_read_task = | 1657 | plugin->server_read_task = |
1658 | GNUNET_SCHEDULER_add_read_file (plugin->env->sched, | 1658 | GNUNET_SCHEDULER_add_read_file (plugin->env->sched, |
@@ -1689,7 +1689,7 @@ udp_transport_server_start (void *cls) | |||
1689 | serverAddr = (struct sockaddr *) &serverAddrv6; | 1689 | serverAddr = (struct sockaddr *) &serverAddrv6; |
1690 | #if DEBUG_UDP | 1690 | #if DEBUG_UDP |
1691 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1691 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1692 | "Binding to IPv6 port %d\n", | 1692 | "Binding to IPv6 port %d\n", |
1693 | ntohs(serverAddrv6.sin6_port)); | 1693 | ntohs(serverAddrv6.sin6_port)); |
1694 | #endif | 1694 | #endif |
1695 | tries = 0; | 1695 | tries = 0; |
@@ -1699,7 +1699,7 @@ udp_transport_server_start (void *cls) | |||
1699 | serverAddrv6.sin6_port = htons (GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000); /* Find a good, non-root port */ | 1699 | serverAddrv6.sin6_port = htons (GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000); /* Find a good, non-root port */ |
1700 | #if DEBUG_UDP | 1700 | #if DEBUG_UDP |
1701 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1701 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1702 | "IPv6 Binding failed, trying new port %d\n", | 1702 | "IPv6 Binding failed, trying new port %d\n", |
1703 | ntohs(serverAddrv6.sin6_port)); | 1703 | ntohs(serverAddrv6.sin6_port)); |
1704 | #endif | 1704 | #endif |
1705 | tries++; | 1705 | tries++; |
@@ -1708,7 +1708,7 @@ udp_transport_server_start (void *cls) | |||
1708 | GNUNET_NETWORK_socket_close (plugin->udp_sockv6.desc); | 1708 | GNUNET_NETWORK_socket_close (plugin->udp_sockv6.desc); |
1709 | plugin->udp_sockv6.desc = NULL; | 1709 | plugin->udp_sockv6.desc = NULL; |
1710 | break; | 1710 | break; |
1711 | } | 1711 | } |
1712 | } | 1712 | } |
1713 | if (plugin->udp_sockv6.desc != NULL) | 1713 | if (plugin->udp_sockv6.desc != NULL) |
1714 | { | 1714 | { |
@@ -1741,7 +1741,7 @@ udp_transport_server_start (void *cls) | |||
1741 | serverAddr = (struct sockaddr *) &serverAddrv4; | 1741 | serverAddr = (struct sockaddr *) &serverAddrv4; |
1742 | #if DEBUG_UDP | 1742 | #if DEBUG_UDP |
1743 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1743 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1744 | "Binding to IPv4 port %d\n", | 1744 | "Binding to IPv4 port %d\n", |
1745 | ntohs(serverAddrv4.sin_port)); | 1745 | ntohs(serverAddrv4.sin_port)); |
1746 | #endif | 1746 | #endif |
1747 | tries = 0; | 1747 | tries = 0; |
@@ -1751,7 +1751,7 @@ udp_transport_server_start (void *cls) | |||
1751 | serverAddrv4.sin_port = htons (GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000); /* Find a good, non-root port */ | 1751 | serverAddrv4.sin_port = htons (GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000); /* Find a good, non-root port */ |
1752 | #if DEBUG_UDP | 1752 | #if DEBUG_UDP |
1753 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1753 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1754 | "IPv4 Binding failed, trying new port %d\n", | 1754 | "IPv4 Binding failed, trying new port %d\n", |
1755 | ntohs(serverAddrv4.sin_port)); | 1755 | ntohs(serverAddrv4.sin_port)); |
1756 | #endif | 1756 | #endif |
1757 | tries++; | 1757 | tries++; |
@@ -1760,7 +1760,7 @@ udp_transport_server_start (void *cls) | |||
1760 | GNUNET_NETWORK_socket_close (plugin->udp_sockv4.desc); | 1760 | GNUNET_NETWORK_socket_close (plugin->udp_sockv4.desc); |
1761 | plugin->udp_sockv4.desc = NULL; | 1761 | plugin->udp_sockv4.desc = NULL; |
1762 | break; | 1762 | break; |
1763 | } | 1763 | } |
1764 | } | 1764 | } |
1765 | if (plugin->udp_sockv4.desc != NULL) | 1765 | if (plugin->udp_sockv4.desc != NULL) |
1766 | { | 1766 | { |
@@ -1772,10 +1772,10 @@ udp_transport_server_start (void *cls) | |||
1772 | plugin->rs = GNUNET_NETWORK_fdset_create (); | 1772 | plugin->rs = GNUNET_NETWORK_fdset_create (); |
1773 | GNUNET_NETWORK_fdset_zero (plugin->rs); | 1773 | GNUNET_NETWORK_fdset_zero (plugin->rs); |
1774 | if (NULL != plugin->udp_sockv4.desc) | 1774 | if (NULL != plugin->udp_sockv4.desc) |
1775 | GNUNET_NETWORK_fdset_set (plugin->rs, | 1775 | GNUNET_NETWORK_fdset_set (plugin->rs, |
1776 | plugin->udp_sockv4.desc); | 1776 | plugin->udp_sockv4.desc); |
1777 | if (NULL != plugin->udp_sockv6.desc) | 1777 | if (NULL != plugin->udp_sockv6.desc) |
1778 | GNUNET_NETWORK_fdset_set (plugin->rs, | 1778 | GNUNET_NETWORK_fdset_set (plugin->rs, |
1779 | plugin->udp_sockv6.desc); | 1779 | plugin->udp_sockv6.desc); |
1780 | 1780 | ||
1781 | plugin->select_task = | 1781 | plugin->select_task = |
@@ -1806,7 +1806,7 @@ check_port (struct Plugin *plugin, uint16_t in_port) | |||
1806 | if ( (plugin->only_nat_addresses == GNUNET_YES) && | 1806 | if ( (plugin->only_nat_addresses == GNUNET_YES) && |
1807 | (plugin->behind_nat == GNUNET_YES) ) | 1807 | (plugin->behind_nat == GNUNET_YES) ) |
1808 | return GNUNET_SYSERR; /* odd case... */ | 1808 | return GNUNET_SYSERR; /* odd case... */ |
1809 | if (in_port == plugin->port) | 1809 | if (in_port == plugin->port) |
1810 | return GNUNET_OK; | 1810 | return GNUNET_OK; |
1811 | return GNUNET_SYSERR; | 1811 | return GNUNET_SYSERR; |
1812 | } | 1812 | } |
@@ -1829,8 +1829,8 @@ check_port (struct Plugin *plugin, uint16_t in_port) | |||
1829 | * | 1829 | * |
1830 | */ | 1830 | */ |
1831 | static int | 1831 | static int |
1832 | udp_check_address (void *cls, | 1832 | udp_check_address (void *cls, |
1833 | const void *addr, | 1833 | const void *addr, |
1834 | size_t addrlen) | 1834 | size_t addrlen) |
1835 | { | 1835 | { |
1836 | struct Plugin *plugin = cls; | 1836 | struct Plugin *plugin = cls; |
@@ -1873,7 +1873,7 @@ udp_check_address (void *cls, | |||
1873 | GNUNET_break_op (0); | 1873 | GNUNET_break_op (0); |
1874 | return GNUNET_SYSERR; | 1874 | return GNUNET_SYSERR; |
1875 | } | 1875 | } |
1876 | if (GNUNET_OK != | 1876 | if (GNUNET_OK != |
1877 | check_port (plugin, ntohs (v6->u6_port))) | 1877 | check_port (plugin, ntohs (v6->u6_port))) |
1878 | return GNUNET_SYSERR; | 1878 | return GNUNET_SYSERR; |
1879 | if (GNUNET_OK != | 1879 | if (GNUNET_OK != |
@@ -2226,7 +2226,7 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
2226 | GNUNET_SERVICE_stop (service); | 2226 | GNUNET_SERVICE_stop (service); |
2227 | GNUNET_free_non_null(external_address); | 2227 | GNUNET_free_non_null(external_address); |
2228 | GNUNET_free_non_null(internal_address); | 2228 | GNUNET_free_non_null(internal_address); |
2229 | return NULL; | 2229 | return NULL; |
2230 | } | 2230 | } |
2231 | 2231 | ||
2232 | mtu = 1240; | 2232 | mtu = 1240; |