diff options
author | Nathan S. Evans <evans@in.tum.de> | 2010-09-14 15:28:08 +0000 |
---|---|---|
committer | Nathan S. Evans <evans@in.tum.de> | 2010-09-14 15:28:08 +0000 |
commit | 9c77c63d6b19db8f679eaf17c9760bcb1b8b06c1 (patch) | |
tree | cbb53b8b4a2f1b4c8ff4ed22c45c98107f1de6c3 /src | |
parent | 603fe52fab9b124be9320cf35c38511a3bcc0e8c (diff) | |
download | gnunet-9c77c63d6b19db8f679eaf17c9760bcb1b8b06c1.tar.gz gnunet-9c77c63d6b19db8f679eaf17c9760bcb1b8b06c1.zip |
don't ignore sessions marked as inbound when checking whether addresses match
Diffstat (limited to 'src')
-rw-r--r-- | src/transport/gnunet-service-transport.c | 21 | ||||
-rw-r--r-- | src/transport/plugin_transport_tcp.c | 64 |
2 files changed, 74 insertions, 11 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index 1d0e0cc15..c117b06da 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c | |||
@@ -3288,7 +3288,9 @@ send_periodic_ping (void *cls, | |||
3288 | ping.challenge = htonl(va->challenge); | 3288 | ping.challenge = htonl(va->challenge); |
3289 | memcpy(&ping.target, &neighbour->id, sizeof(struct GNUNET_PeerIdentity)); | 3289 | memcpy(&ping.target, &neighbour->id, sizeof(struct GNUNET_PeerIdentity)); |
3290 | if (peer_address->validated != GNUNET_YES) | 3290 | if (peer_address->validated != GNUNET_YES) |
3291 | memcpy(message_buf, our_hello, hello_size); | 3291 | { |
3292 | memcpy(message_buf, our_hello, hello_size); | ||
3293 | } | ||
3292 | 3294 | ||
3293 | if (peer_address->addr != NULL) | 3295 | if (peer_address->addr != NULL) |
3294 | { | 3296 | { |
@@ -3325,7 +3327,12 @@ send_periodic_ping (void *cls, | |||
3325 | #endif | 3327 | #endif |
3326 | if (peer_address->validated != GNUNET_YES) | 3328 | if (peer_address->validated != GNUNET_YES) |
3327 | GNUNET_STATISTICS_update (stats, | 3329 | GNUNET_STATISTICS_update (stats, |
3328 | gettext_noop ("# PING+HELLO messages sent"), | 3330 | gettext_noop ("# PING with HELLO messages sent"), |
3331 | 1, | ||
3332 | GNUNET_NO); | ||
3333 | else | ||
3334 | GNUNET_STATISTICS_update (stats, | ||
3335 | gettext_noop ("# PING without HELLO messages sent"), | ||
3329 | 1, | 3336 | 1, |
3330 | GNUNET_NO); | 3337 | GNUNET_NO); |
3331 | 3338 | ||
@@ -4209,6 +4216,16 @@ process_hello (struct TransportPlugin *plugin, | |||
4209 | GNUNET_HELLO_size(hello))); | 4216 | GNUNET_HELLO_size(hello))); |
4210 | chvc = chvc->next; | 4217 | chvc = chvc->next; |
4211 | } | 4218 | } |
4219 | |||
4220 | #if BREAK_TESTS | ||
4221 | struct NeighbourList *temp_neighbor = find_neighbour(&target); | ||
4222 | if ((NULL != temp_neighbor)) | ||
4223 | { | ||
4224 | fprintf(stderr, "Already know peer, ignoring hello\n"); | ||
4225 | return GNUNET_OK; | ||
4226 | } | ||
4227 | #endif | ||
4228 | |||
4212 | #if DEBUG_TRANSPORT_HELLO > 2 | 4229 | #if DEBUG_TRANSPORT_HELLO > 2 |
4213 | if (plugin != NULL) | 4230 | if (plugin != NULL) |
4214 | { | 4231 | { |
diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c index 8c1d3d333..208a113f4 100644 --- a/src/transport/plugin_transport_tcp.c +++ b/src/transport/plugin_transport_tcp.c | |||
@@ -39,7 +39,7 @@ | |||
39 | 39 | ||
40 | #define DEBUG_TCP GNUNET_NO | 40 | #define DEBUG_TCP GNUNET_NO |
41 | #define DEBUG_TCP_NAT GNUNET_NO | 41 | #define DEBUG_TCP_NAT GNUNET_NO |
42 | 42 | #define MULTIPLE_PEER_SESSIONS GNUNET_YES | |
43 | /** | 43 | /** |
44 | * How long until we give up on transmitting the welcome message? | 44 | * How long until we give up on transmitting the welcome message? |
45 | */ | 45 | */ |
@@ -564,6 +564,25 @@ find_session_by_client (struct Plugin *plugin, | |||
564 | return ret; | 564 | return ret; |
565 | } | 565 | } |
566 | 566 | ||
567 | #if !MULTIPLE_PEER_SESSIONS | ||
568 | /** | ||
569 | * Find the session handle for the given client. | ||
570 | * | ||
571 | * @return NULL if no matching session exists | ||
572 | */ | ||
573 | static struct Session * | ||
574 | find_session_by_id (struct Plugin *plugin, | ||
575 | const struct GNUNET_PeerIdentity *peer) | ||
576 | { | ||
577 | struct Session *ret; | ||
578 | |||
579 | ret = plugin->sessions; | ||
580 | while ((ret != NULL) && (0 != memcmp(peer, &ret->target, sizeof(struct GNUNET_PeerIdentity)))) | ||
581 | ret = ret->next; | ||
582 | return ret; | ||
583 | } | ||
584 | #endif | ||
585 | |||
567 | /** | 586 | /** |
568 | * Create a new session. Also queues a welcome message. | 587 | * Create a new session. Also queues a welcome message. |
569 | * | 588 | * |
@@ -1082,8 +1101,13 @@ tcp_plugin_send (void *cls, | |||
1082 | GNUNET_break (0); | 1101 | GNUNET_break (0); |
1083 | break; | 1102 | break; |
1084 | } | 1103 | } |
1085 | if (session->inbound == GNUNET_YES) | 1104 | #if IGNORE_INBOUND |
1086 | continue; | 1105 | if (session->inbound == GNUNET_YES) /* FIXME: why do we ignore inbound sessions? */ |
1106 | { | ||
1107 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Ignoring inbound session\n"); | ||
1108 | continue; | ||
1109 | } | ||
1110 | #endif | ||
1087 | if ((addrlen != session->connect_alen) && (session->is_nat == GNUNET_NO)) | 1111 | if ((addrlen != session->connect_alen) && (session->is_nat == GNUNET_NO)) |
1088 | continue; | 1112 | continue; |
1089 | if ((0 != memcmp (session->connect_addr, | 1113 | if ((0 != memcmp (session->connect_addr, |
@@ -1218,7 +1242,7 @@ tcp_plugin_send (void *cls, | |||
1218 | GNUNET_NO); | 1242 | GNUNET_NO); |
1219 | return -1; | 1243 | return -1; |
1220 | } | 1244 | } |
1221 | #if DEBUG_TCP | 1245 | #if DEBUG_TCP_NAT |
1222 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1246 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1223 | "Asked to transmit to `%4s', creating fresh session using address `%s'.\n", | 1247 | "Asked to transmit to `%4s', creating fresh session using address `%s'.\n", |
1224 | GNUNET_i2s (target), | 1248 | GNUNET_i2s (target), |
@@ -1586,7 +1610,7 @@ handle_tcp_nat_probe (void *cls, | |||
1586 | { | 1610 | { |
1587 | #if DEBUG_TCP_NAT | 1611 | #if DEBUG_TCP_NAT |
1588 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1612 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1589 | "Found address `%s' for incoming connection %p\n", | 1613 | "handle_tcp_nat_probe Found address `%s' for incoming connection %p\n", |
1590 | GNUNET_a2s (vaddr, alen), | 1614 | GNUNET_a2s (vaddr, alen), |
1591 | client); | 1615 | client); |
1592 | #endif | 1616 | #endif |
@@ -1671,7 +1695,12 @@ handle_tcp_welcome (void *cls, | |||
1671 | gettext_noop ("# TCP WELCOME messages received"), | 1695 | gettext_noop ("# TCP WELCOME messages received"), |
1672 | 1, | 1696 | 1, |
1673 | GNUNET_NO); | 1697 | GNUNET_NO); |
1698 | #if MULTIPLE_PEER_SESSIONS | ||
1674 | session = find_session_by_client (plugin, client); | 1699 | session = find_session_by_client (plugin, client); |
1700 | #else | ||
1701 | session = find_session_by_id(plugin, &wm->clientIdentity); | ||
1702 | #endif | ||
1703 | |||
1675 | if (session == NULL) | 1704 | if (session == NULL) |
1676 | { | 1705 | { |
1677 | GNUNET_SERVER_client_keep (client); | 1706 | GNUNET_SERVER_client_keep (client); |
@@ -1687,8 +1716,8 @@ handle_tcp_welcome (void *cls, | |||
1687 | if (GNUNET_OK == | 1716 | if (GNUNET_OK == |
1688 | GNUNET_SERVER_client_get_address (client, &vaddr, &alen)) | 1717 | GNUNET_SERVER_client_get_address (client, &vaddr, &alen)) |
1689 | { | 1718 | { |
1690 | #if DEBUG_TCP | 1719 | #if DEBUG_TCP_NAT |
1691 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1720 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1692 | "Found address `%s' for incoming connection %p\n", | 1721 | "Found address `%s' for incoming connection %p\n", |
1693 | GNUNET_a2s (vaddr, alen), | 1722 | GNUNET_a2s (vaddr, alen), |
1694 | client); | 1723 | client); |
@@ -1713,6 +1742,7 @@ handle_tcp_welcome (void *cls, | |||
1713 | session->connect_addr = t6; | 1742 | session->connect_addr = t6; |
1714 | session->connect_alen = sizeof (struct IPv6TcpAddress); | 1743 | session->connect_alen = sizeof (struct IPv6TcpAddress); |
1715 | } | 1744 | } |
1745 | |||
1716 | GNUNET_free (vaddr); | 1746 | GNUNET_free (vaddr); |
1717 | } | 1747 | } |
1718 | else | 1748 | else |
@@ -1729,12 +1759,28 @@ handle_tcp_welcome (void *cls, | |||
1729 | #endif | 1759 | #endif |
1730 | process_pending_messages (session); | 1760 | process_pending_messages (session); |
1731 | } | 1761 | } |
1762 | else | ||
1763 | { | ||
1764 | #if DEBUG_TCP_NAT | ||
1765 | if (GNUNET_OK == | ||
1766 | GNUNET_SERVER_client_get_address (client, &vaddr, &alen)) | ||
1767 | { | ||
1768 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
1769 | "Found address `%s' (already have session) for incoming connection %p\n", | ||
1770 | GNUNET_a2s (vaddr, alen), | ||
1771 | client); | ||
1772 | } | ||
1773 | #endif | ||
1774 | } | ||
1775 | |||
1776 | #if MULTIPLE_PEER_SESSIONS | ||
1732 | if (session->expecting_welcome != GNUNET_YES) | 1777 | if (session->expecting_welcome != GNUNET_YES) |
1733 | { | 1778 | { |
1734 | GNUNET_break_op (0); | 1779 | GNUNET_break_op (0); |
1735 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 1780 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
1736 | return; | 1781 | return; |
1737 | } | 1782 | } |
1783 | #endif | ||
1738 | session->last_activity = GNUNET_TIME_absolute_get (); | 1784 | session->last_activity = GNUNET_TIME_absolute_get (); |
1739 | session->expecting_welcome = GNUNET_NO; | 1785 | session->expecting_welcome = GNUNET_NO; |
1740 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 1786 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
@@ -1799,8 +1845,8 @@ handle_tcp_data (void *cls, | |||
1799 | return; | 1845 | return; |
1800 | } | 1846 | } |
1801 | session->last_activity = GNUNET_TIME_absolute_get (); | 1847 | session->last_activity = GNUNET_TIME_absolute_get (); |
1802 | #if DEBUG_TCP | 1848 | #if DEBUG_TCP > 1 |
1803 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1849 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1804 | "Passing %u bytes of type %u from `%4s' to transport service.\n", | 1850 | "Passing %u bytes of type %u from `%4s' to transport service.\n", |
1805 | (unsigned int) ntohs (message->size), | 1851 | (unsigned int) ntohs (message->size), |
1806 | (unsigned int) ntohs (message->type), | 1852 | (unsigned int) ntohs (message->type), |