t4.ipv4_addr = ((struct sockaddr_in *) addr)->sin_addr.s_addr;
t4.t4_port = ((struct sockaddr_in *) addr)->sin_port;
arg = &t4;
- args = sizeof(t4);
+ args = sizeof (t4);
break;
case AF_INET6:
GNUNET_assert(addrlen == sizeof(struct sockaddr_in6));
t6.options = htonl (myoptions);
t6.t6_port = ((struct sockaddr_in6 *) addr)->sin6_port;
arg = &t6;
- args = sizeof(t6);
+ args = sizeof (t6);
break;
default:
GNUNET_break(0);
return;
}
/* modify our published address list */
+ GNUNET_assert ((args == sizeof (struct IPv4TcpAddress)) ||
+ (args == sizeof (struct IPv6TcpAddress)));
address = GNUNET_HELLO_address_allocate (plugin->env->my_identity,
PLUGIN_NAME, arg, args, GNUNET_HELLO_ADDRESS_INFO_NONE);
plugin->env->notify_address (plugin->env->cls, add_remove, address);
memcpy (&a4, &t4->ipv4_addr, sizeof(a4));
sb = &a4;
break;
- case 0:
- {
- GNUNET_snprintf (rbuf, sizeof(rbuf), "%s",
- TRANSPORT_SESSION_INBOUND_STRING);
- return rbuf;
- }
default:
LOG(GNUNET_ERROR_TYPE_WARNING, _("Unexpected address length: %u bytes\n"),
(unsigned int ) addrlen);
plugin->env->unregister_quota_notification (plugin->env->cls,
&session->target, PLUGIN_NAME, session);
session->plugin->env->session_end (session->plugin->env->cls,
- &session->target, session);
+ session->address, session);
if (GNUNET_SCHEDULER_NO_TASK != session->nat_connection_timeout)
{
sb = &a4;
sbs = sizeof(a4);
}
- else if (0 == addrlen)
- {
- asc (asc_cls, TRANSPORT_SESSION_INBOUND_STRING);
- asc (asc_cls, NULL );
- return;
- }
else
{
/* invalid address */
- GNUNET_break_op(0);
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ "Trying to print invalid `%s' address with size %u\n", type, addrlen);
asc (asc_cls, NULL );
return;
}
case AF_INET:
s4 = vaddr;
t4 = GNUNET_new (struct IPv4TcpAddress);
- t4->options = 0;
+ t4->options = htonl(0);
t4->t4_port = s4->sin_port;
t4->ipv4_addr = s4->sin_addr.s_addr;
session->address = GNUNET_HELLO_address_allocate (
&tcp_nat_probe->clientIdentity, PLUGIN_NAME, &t4,
- sizeof(struct IPv4TcpAddress), GNUNET_HELLO_ADDRESS_INFO_NONE);
+ sizeof(struct IPv4TcpAddress),
+ GNUNET_HELLO_ADDRESS_INFO_NONE);
break;
case AF_INET6:
s6 = vaddr;
t6 = GNUNET_new (struct IPv6TcpAddress);
- t6->options = 0;
+ t6->options = htonl(0);
t6->t6_port = s6->sin6_port;
memcpy (&t6->ipv6_addr, &s6->sin6_addr, sizeof(struct in6_addr));
session->address = GNUNET_HELLO_address_allocate (
- &tcp_nat_probe->clientIdentity, PLUGIN_NAME, &t6,
- sizeof(struct IPv6TcpAddress), GNUNET_HELLO_ADDRESS_INFO_NONE);
+ &tcp_nat_probe->clientIdentity,
+ PLUGIN_NAME, &t6, sizeof(struct IPv6TcpAddress),
+ GNUNET_HELLO_ADDRESS_INFO_NONE);
break;
default:
GNUNET_break_op(0);
const struct sockaddr_in6 *s6;
struct GNUNET_ATS_Information ats;
+
if (0 == memcmp (&wm->clientIdentity, plugin->env->my_identity,
sizeof(struct GNUNET_PeerIdentity)))
{
GNUNET_break_op(0);
return;
}
+
LOG(GNUNET_ERROR_TYPE_DEBUG, "Received %s message from `%4s' %p\n", "WELCOME",
GNUNET_i2s (&wm->clientIdentity), client);
GNUNET_STATISTICS_update (plugin->env->stats,
PLUGIN_NAME, &t6, sizeof (t6),
GNUNET_HELLO_ADDRESS_INFO_INBOUND);
}
+ else
+ {
+ GNUNET_break (0);
+ GNUNET_free_non_null (vaddr);
+ return;
+ }
session = create_session (plugin, address, client, GNUNET_NO);
GNUNET_HELLO_address_free (address);
ats = plugin->env->get_address_type (plugin->env->cls, vaddr, alen);
session->ats_address_network_type = (enum GNUNET_ATS_Network_Type) ntohl (
ats.value);
- LOG(GNUNET_ERROR_TYPE_DEBUG, "Creating new%s session %p for peer `%s'\n",
- GNUNET_HELLO_address_check_option (session->address, GNUNET_HELLO_ADDRESS_INFO_INBOUND) ? " inbound" : "",
- session,
- tcp_address_to_string(NULL, (void *) session->address->address,session->address->address_length));
+ LOG(GNUNET_ERROR_TYPE_DEBUG, "Creating new%s session %p for peer `%s' client %p \n",
+ GNUNET_HELLO_address_check_option (session->address,
+ GNUNET_HELLO_ADDRESS_INFO_INBOUND) ? " inbound" : "", session,
+ tcp_address_to_string(NULL, (void *) session->address->address,
+ session->address->address_length),
+ client);
GNUNET_free(vaddr);
GNUNET_SERVER_client_set_user_context(session->client, session);
GNUNET_CONTAINER_multipeermap_put (plugin->sessionmap, &session->target,
session, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
+
+ /* Notify transport and ATS about new session */
+ plugin->env->session_start (NULL, session->address, session, &ats, 1);
}
else
{
LOG(GNUNET_ERROR_TYPE_DEBUG,
"Did not obtain TCP socket address for incoming connection\n");
GNUNET_break(0);
+ return;
}
}
session->last_activity = GNUNET_TIME_absolute_get ();
session->expecting_welcome = GNUNET_NO;
- /* Notify transport and ATS about new session */
- plugin->env->session_start (NULL, session->address, session, &ats, 1);
-
process_pending_messages (session);
GNUNET_SERVER_client_set_timeout (client,
GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
static enum GNUNET_ATS_Network_Type
tcp_get_network (void *cls, struct Session *session)
{
- GNUNET_assert(NULL != session);
+ struct Plugin * plugin = cls;
+ GNUNET_assert (NULL != plugin);
+ GNUNET_assert (NULL != session);
+ if (GNUNET_SYSERR == find_session (plugin,session))
+ return GNUNET_ATS_NET_UNSPECIFIED;
return session->ats_address_network_type;
}