aboutsummaryrefslogtreecommitdiff
path: root/src/transport/plugin_transport_tcp.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-07-11 09:37:13 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-07-11 09:37:13 +0000
commit296681524d3679be6e0945258b2fbaac0c4eb73e (patch)
tree867488d9063bbcdf04a864e47863afcd96911428 /src/transport/plugin_transport_tcp.c
parentf261d397b6a540d33531fc77060104429de06016 (diff)
downloadgnunet-296681524d3679be6e0945258b2fbaac0c4eb73e.tar.gz
gnunet-296681524d3679be6e0945258b2fbaac0c4eb73e.zip
fix:
return address length 0 for inbound session - return session only if inbound flag is set: issue because plugin sends TCP_WELCOME messages for incoming connections not only outbount
Diffstat (limited to 'src/transport/plugin_transport_tcp.c')
-rw-r--r--src/transport/plugin_transport_tcp.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c
index 18d033556..9b2ee482e 100644
--- a/src/transport/plugin_transport_tcp.c
+++ b/src/transport/plugin_transport_tcp.c
@@ -616,6 +616,12 @@ tcp_address_to_string (void *cls, const void *addr, size_t addrlen)
616 memcpy (&a4, &t4->ipv4_addr, sizeof (a4)); 616 memcpy (&a4, &t4->ipv4_addr, sizeof (a4));
617 sb = &a4; 617 sb = &a4;
618 break; 618 break;
619 case 0:
620 {
621 GNUNET_snprintf (rbuf, sizeof (rbuf), "%s",
622 "<inbound>");
623 return rbuf;
624 }
619 default: 625 default:
620 LOG (GNUNET_ERROR_TYPE_WARNING, 626 LOG (GNUNET_ERROR_TYPE_WARNING,
621 _("Unexpected address length: %u bytes\n"), 627 _("Unexpected address length: %u bytes\n"),
@@ -1355,7 +1361,7 @@ tcp_plugin_get_session (void *cls,
1355 if (si_ctx.result != NULL) 1361 if (si_ctx.result != NULL)
1356 { 1362 {
1357 session = si_ctx.result; 1363 session = si_ctx.result;
1358 LOG (GNUNET_ERROR_TYPE_DEBUG, 1364 LOG (GNUNET_ERROR_TYPE_DEBUG,
1359 "Found existing session for `%s' address `%s' session %p\n", 1365 "Found existing session for `%s' address `%s' session %p\n",
1360 GNUNET_i2s (&address->peer), 1366 GNUNET_i2s (&address->peer),
1361 tcp_address_to_string(NULL, address->address, address->address_length), 1367 tcp_address_to_string(NULL, address->address, address->address_length),
@@ -1676,7 +1682,7 @@ tcp_plugin_address_pretty_printer (void *cls, const char *type,
1676 } 1682 }
1677 else if (0 == addrlen) 1683 else if (0 == addrlen)
1678 { 1684 {
1679 asc (asc_cls, "<inbound connection>"); 1685 asc (asc_cls, "<inbound>");
1680 asc (asc_cls, NULL); 1686 asc (asc_cls, NULL);
1681 return; 1687 return;
1682 } 1688 }
@@ -2031,11 +2037,14 @@ handle_tcp_welcome (void *cls, struct GNUNET_SERVER_Client *client,
2031 session->last_activity = GNUNET_TIME_absolute_get (); 2037 session->last_activity = GNUNET_TIME_absolute_get ();
2032 session->expecting_welcome = GNUNET_NO; 2038 session->expecting_welcome = GNUNET_NO;
2033 2039
2034
2035 /* Notify transport and ATS about new session */ 2040 /* Notify transport and ATS about new session */
2036 plugin->env->session_start (NULL, &wm->clientIdentity, 2041 if (GNUNET_YES == session->inbound)
2037 PLUGIN_NAME, session->addr, session->addrlen, session, &ats, 1); 2042 {
2038 2043 plugin->env->session_start (NULL, &wm->clientIdentity, PLUGIN_NAME,
2044 (GNUNET_YES == session->inbound) ? NULL : session->addr,
2045 (GNUNET_YES == session->inbound) ? 0 : session->addrlen,
2046 session, &ats, 1);
2047 }
2039 2048
2040 process_pending_messages (session); 2049 process_pending_messages (session);
2041 2050
@@ -2154,10 +2163,8 @@ handle_tcp_data (void *cls, struct GNUNET_SERVER_Client *client,
2154 plugin->env->update_address_metrics (plugin->env->cls, 2163 plugin->env->update_address_metrics (plugin->env->cls,
2155 &session->target, 2164 &session->target,
2156 (GNUNET_YES == session->inbound) ? NULL : session->addr, 2165 (GNUNET_YES == session->inbound) ? NULL : session->addr,
2157 (GNUNET_YES == session->inbound) ? 0 : session->addrlen, 2166 (GNUNET_YES == session->inbound) ? 0 : session->addrlen,
2158 session, 2167 session, &distance, 1);
2159 &distance,
2160 1);
2161 2168
2162 reschedule_session_timeout (session); 2169 reschedule_session_timeout (session);
2163 2170