[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r35003 - gnunet/src/transport
From: |
gnunet |
Subject: |
[GNUnet-SVN] r35003 - gnunet/src/transport |
Date: |
Sun, 25 Jan 2015 23:59:22 +0100 |
Author: grothoff
Date: 2015-01-25 23:59:22 +0100 (Sun, 25 Jan 2015)
New Revision: 35003
Modified:
gnunet/src/transport/gnunet-service-transport_ats.c
gnunet/src/transport/plugin_transport_tcp.c
gnunet/src/transport/plugin_transport_udp.c
Log:
-correct a few overly optimistic assumptions about what can legitimately
happen...
Modified: gnunet/src/transport/gnunet-service-transport_ats.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_ats.c 2015-01-25 21:44:18 UTC
(rev 35002)
+++ gnunet/src/transport/gnunet-service-transport_ats.c 2015-01-25 22:59:22 UTC
(rev 35003)
@@ -140,6 +140,56 @@
/**
+ * Find matching address info, ignoring sessions.
+ *
+ * @param cls the `struct FindClosure`
+ * @param key which peer is this about
+ * @param value the `struct AddressInfo`
+ * @return #GNUNET_YES to continue to iterate, #GNUNET_NO if we found the value
+ */
+static int
+find_ai_no_session_cb (void *cls,
+ const struct GNUNET_PeerIdentity *key,
+ void *value)
+{
+ struct FindClosure *fc = cls;
+ struct AddressInfo *ai = value;
+
+ if (0 ==
+ GNUNET_HELLO_address_cmp (fc->address,
+ ai->address))
+ {
+ fc->ret = ai;
+ return GNUNET_NO;
+ }
+ return GNUNET_YES;
+}
+
+
+/**
+ * Find the address information struct for the
+ * given address (ignoring sessions)
+ *
+ * @param address address to look for
+ * @return NULL if this combination is unknown
+ */
+static struct AddressInfo *
+find_ai_no_session (const struct GNUNET_HELLO_Address *address)
+{
+ struct FindClosure fc;
+
+ fc.address = address;
+ fc.session = NULL;
+ fc.ret = NULL;
+ GNUNET_CONTAINER_multipeermap_get_multiple (p2a,
+ &address->peer,
+ &find_ai_no_session_cb,
+ &fc);
+ return fc.ret;
+}
+
+
+/**
* Test if ATS knows about this address.
*
* @param address the address
@@ -187,11 +237,22 @@
{
GNUNET_break (NULL != session);
}
- ai = find_ai (address, session);
+ ai = (NULL == session)
+ ? find_ai_no_session (address)
+ : find_ai (address, session);
if (NULL != ai)
+ return;
+ if (NULL != session)
{
- GNUNET_break (0);
- return;
+ /* in this case, we must not find an existing
+ session-less address, as the caller should
+ have checked for this case if it were possible. */
+ ai = find_ai (address, NULL);
+ if (NULL != ai)
+ {
+ GNUNET_assert (0);
+ return;
+ }
}
if (NULL == (papi = GST_plugins_find (address->transport_name)))
{
Modified: gnunet/src/transport/plugin_transport_tcp.c
===================================================================
--- gnunet/src/transport/plugin_transport_tcp.c 2015-01-25 21:44:18 UTC (rev
35002)
+++ gnunet/src/transport/plugin_transport_tcp.c 2015-01-25 22:59:22 UTC (rev
35003)
@@ -1529,20 +1529,22 @@
#endif
addrlen = address->address_length;
- LOG(GNUNET_ERROR_TYPE_DEBUG,
- "Trying to get session for `%s' address of peer `%s'\n",
- tcp_plugin_address_to_string(NULL, address->address,
address->address_length),
- GNUNET_i2s (&address->peer));
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Trying to get session for `%s' address of peer `%s'\n",
+ tcp_plugin_address_to_string(NULL, address->address,
address->address_length),
+ GNUNET_i2s (&address->peer));
- if (GNUNET_HELLO_address_check_option(address,
GNUNET_HELLO_ADDRESS_INFO_INBOUND))
+ if (GNUNET_HELLO_address_check_option (address,
+ GNUNET_HELLO_ADDRESS_INFO_INBOUND))
{
GNUNET_break (0);
return NULL;
}
/* look for existing session */
- if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (plugin->sessionmap,
- &address->peer))
+ if (GNUNET_YES ==
+ GNUNET_CONTAINER_multipeermap_contains (plugin->sessionmap,
+ &address->peer))
{
struct SessionItCtx si_ctx;
@@ -1550,15 +1552,18 @@
si_ctx.result = NULL;
GNUNET_CONTAINER_multipeermap_get_multiple (plugin->sessionmap,
- &address->peer, &session_lookup_it, &si_ctx);
- if (si_ctx.result != NULL)
+ &address->peer,
+ &session_lookup_it, &si_ctx);
+ if (NULL != si_ctx.result)
{
session = si_ctx.result;
- LOG(GNUNET_ERROR_TYPE_DEBUG,
- "Found existing session for `%s' address `%s' session %p\n",
- GNUNET_i2s (&address->peer),
- tcp_plugin_address_to_string(NULL, address->address,
address->address_length),
- session);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Found existing session for `%s' address `%s' session %p\n",
+ GNUNET_i2s (&address->peer),
+ tcp_plugin_address_to_string (NULL,
+ address->address,
+ address->address_length),
+ session);
return session;
}
LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -1637,8 +1642,9 @@
}
if ((is_natd == GNUNET_YES) && (NULL != plugin->nat) &&
- (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains
(plugin->nat_wait_conns,
- &address->peer)))
+ (GNUNET_NO ==
+ GNUNET_CONTAINER_multipeermap_contains (plugin->nat_wait_conns,
+ &address->peer)))
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Found valid IPv4 NAT address (creating session)!\n");
Modified: gnunet/src/transport/plugin_transport_udp.c
===================================================================
--- gnunet/src/transport/plugin_transport_udp.c 2015-01-25 21:44:18 UTC (rev
35002)
+++ gnunet/src/transport/plugin_transport_udp.c 2015-01-25 22:59:22 UTC (rev
35003)
@@ -1687,9 +1687,11 @@
"Looking for existing session for peer `%s' `%s' \n",
GNUNET_i2s (&address->peer),
udp_address_to_string(NULL, address->address, address->address_length));
- GNUNET_CONTAINER_multipeermap_get_multiple (plugin->sessions, &address->peer,
- session_cmp_it, &cctx);
- if (cctx.res != NULL )
+ GNUNET_CONTAINER_multipeermap_get_multiple (plugin->sessions,
+ &address->peer,
+ session_cmp_it,
+ &cctx);
+ if (NULL != cctx.res)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Found existing session %p\n",
@@ -1836,14 +1838,18 @@
if (NULL == s)
return NULL; /* protocol not supported or address invalid */
LOG(GNUNET_ERROR_TYPE_DEBUG,
- "Creating new %s session %p for peer `%s' address `%s'\n",
- GNUNET_HELLO_address_check_option (address,
GNUNET_HELLO_ADDRESS_INFO_INBOUND) ? "inbound" : "outbound",
+ "Creating new session %p for peer `%s' address `%s'\n",
s, GNUNET_i2s (&address->peer),
udp_address_to_string( NULL,address->address,address->address_length));
- GNUNET_assert(
- GNUNET_OK == GNUNET_CONTAINER_multipeermap_put (plugin->sessions,
&s->target, s, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE));
- GNUNET_STATISTICS_set (plugin->env->stats, "# UDP sessions active",
- GNUNET_CONTAINER_multipeermap_size (plugin->sessions), GNUNET_NO);
+ GNUNET_assert(GNUNET_OK ==
+ GNUNET_CONTAINER_multipeermap_put (plugin->sessions,
+ &s->target,
+ s,
+
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE));
+ GNUNET_STATISTICS_set (plugin->env->stats,
+ "# UDP sessions active",
+ GNUNET_CONTAINER_multipeermap_size (plugin->sessions),
+ GNUNET_NO);
return s;
}
@@ -2330,18 +2336,19 @@
GNUNET_break(0);
return;
}
- LOG(GNUNET_ERROR_TYPE_DEBUG,
- "Received message with %u bytes from peer `%s' at `%s'\n",
- (unsigned int ) ntohs (msg->header.size), GNUNET_i2s (&msg->sender),
- GNUNET_a2s (sender_addr, sender_addr_len));
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Received message with %u bytes from peer `%s' at `%s'\n",
+ (unsigned int ) ntohs (msg->header.size), GNUNET_i2s (&msg->sender),
+ GNUNET_a2s (sender_addr, sender_addr_len));
- address = GNUNET_HELLO_address_allocate ( &msg->sender, PLUGIN_NAME,
- arg, args,
- GNUNET_HELLO_ADDRESS_INFO_INBOUND);
+ address = GNUNET_HELLO_address_allocate (&msg->sender, PLUGIN_NAME,
+ arg, args,
+ GNUNET_HELLO_ADDRESS_INFO_NONE);
if (NULL == (s = udp_plugin_lookup_session (plugin, address)))
{
s = udp_plugin_create_session (plugin, address);
- plugin->env->session_start (NULL, address, s, NULL, 0);
+ plugin->env->session_start (plugin->env->cls,
+ address, s, NULL, 0);
notify_session_monitor (s->plugin,
s,
GNUNET_TRANSPORT_SS_INIT);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r35003 - gnunet/src/transport,
gnunet <=