gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r12986 - gnunet/src/transport


From: gnunet
Subject: [GNUnet-SVN] r12986 - gnunet/src/transport
Date: Tue, 14 Sep 2010 17:28:08 +0200

Author: nevans
Date: 2010-09-14 17:28:08 +0200 (Tue, 14 Sep 2010)
New Revision: 12986

Modified:
   gnunet/src/transport/gnunet-service-transport.c
   gnunet/src/transport/plugin_transport_tcp.c
Log:
don't ignore sessions marked as inbound when checking whether addresses match

Modified: gnunet/src/transport/gnunet-service-transport.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport.c     2010-09-14 13:35:28 UTC 
(rev 12985)
+++ gnunet/src/transport/gnunet-service-transport.c     2010-09-14 15:28:08 UTC 
(rev 12986)
@@ -3288,7 +3288,9 @@
   ping.challenge = htonl(va->challenge);
   memcpy(&ping.target, &neighbour->id, sizeof(struct GNUNET_PeerIdentity));
   if (peer_address->validated != GNUNET_YES)
-    memcpy(message_buf, our_hello, hello_size);
+    {
+      memcpy(message_buf, our_hello, hello_size);
+    }
 
   if (peer_address->addr != NULL)
     {
@@ -3325,9 +3327,14 @@
 #endif
   if (peer_address->validated != GNUNET_YES)
     GNUNET_STATISTICS_update (stats,
-                              gettext_noop ("# PING+HELLO messages sent"),
+                              gettext_noop ("# PING with HELLO messages sent"),
                               1,
                               GNUNET_NO);
+  else
+    GNUNET_STATISTICS_update (stats,
+                              gettext_noop ("# PING without HELLO messages 
sent"),
+                              1,
+                              GNUNET_NO);
 
 
   GNUNET_STATISTICS_update (stats,
@@ -4209,6 +4216,16 @@
                                   GNUNET_HELLO_size(hello)));
       chvc = chvc->next;
     }
+
+#if BREAK_TESTS
+  struct NeighbourList *temp_neighbor = find_neighbour(&target);
+  if ((NULL != temp_neighbor))
+    {
+      fprintf(stderr, "Already know peer, ignoring hello\n");
+      return GNUNET_OK;
+    }
+#endif
+
 #if DEBUG_TRANSPORT_HELLO > 2
   if (plugin != NULL)
     {

Modified: gnunet/src/transport/plugin_transport_tcp.c
===================================================================
--- gnunet/src/transport/plugin_transport_tcp.c 2010-09-14 13:35:28 UTC (rev 
12985)
+++ gnunet/src/transport/plugin_transport_tcp.c 2010-09-14 15:28:08 UTC (rev 
12986)
@@ -39,7 +39,7 @@
 
 #define DEBUG_TCP GNUNET_NO
 #define DEBUG_TCP_NAT GNUNET_NO
-
+#define MULTIPLE_PEER_SESSIONS GNUNET_YES
 /**
  * How long until we give up on transmitting the welcome message?
  */
@@ -564,7 +564,26 @@
   return ret;
 }
 
+#if !MULTIPLE_PEER_SESSIONS
 /**
+ * Find the session handle for the given client.
+ *
+ * @return NULL if no matching session exists
+ */
+static struct Session *
+find_session_by_id (struct Plugin *plugin,
+                    const struct GNUNET_PeerIdentity *peer)
+{
+  struct Session *ret;
+
+  ret = plugin->sessions;
+  while ((ret != NULL) && (0 != memcmp(peer, &ret->target, sizeof(struct 
GNUNET_PeerIdentity))))
+    ret = ret->next;
+  return ret;
+}
+#endif
+
+/**
  * Create a new session.  Also queues a welcome message.
  *
  * @param plugin us
@@ -1082,8 +1101,13 @@
              GNUNET_break (0);
              break;
            }
-         if (session->inbound == GNUNET_YES)
-           continue;
+#if IGNORE_INBOUND
+         if (session->inbound == GNUNET_YES) /* FIXME: why do we ignore 
inbound sessions? */
+           {
+              GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Ignoring inbound 
session\n");
+              continue;
+           }
+#endif
          if ((addrlen != session->connect_alen) && (session->is_nat == 
GNUNET_NO))
            continue;
          if ((0 != memcmp (session->connect_addr,
@@ -1218,7 +1242,7 @@
                                    GNUNET_NO);
          return -1;
        }
-#if DEBUG_TCP
+#if DEBUG_TCP_NAT
       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                        "Asked to transmit to `%4s', creating fresh session 
using address `%s'.\n",
                       GNUNET_i2s (target),
@@ -1586,7 +1610,7 @@
         {
 #if DEBUG_TCP_NAT
           GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                           "Found address `%s' for incoming connection %p\n",
+                           "handle_tcp_nat_probe Found address `%s' for 
incoming connection %p\n",
                            GNUNET_a2s (vaddr, alen),
                            client);
 #endif
@@ -1671,7 +1695,12 @@
                            gettext_noop ("# TCP WELCOME messages received"),
                            1,
                            GNUNET_NO);
+#if MULTIPLE_PEER_SESSIONS
   session = find_session_by_client (plugin, client);
+#else
+  session = find_session_by_id(plugin, &wm->clientIdentity);
+#endif
+
   if (session == NULL)
     {
       GNUNET_SERVER_client_keep (client);
@@ -1687,8 +1716,8 @@
       if (GNUNET_OK ==
          GNUNET_SERVER_client_get_address (client, &vaddr, &alen))
        {
-#if DEBUG_TCP
-         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+#if DEBUG_TCP_NAT
+         GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                           "Found address `%s' for incoming connection %p\n",
                           GNUNET_a2s (vaddr, alen),
                           client);
@@ -1713,6 +1742,7 @@
              session->connect_addr = t6;
              session->connect_alen = sizeof (struct IPv6TcpAddress);
            }
+
          GNUNET_free (vaddr);
        }
       else
@@ -1729,12 +1759,28 @@
 #endif
       process_pending_messages (session);
     }
+  else
+    {
+#if DEBUG_TCP_NAT
+    if (GNUNET_OK ==
+        GNUNET_SERVER_client_get_address (client, &vaddr, &alen))
+      {
+        GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                    "Found address `%s' (already have session) for incoming 
connection %p\n",
+                    GNUNET_a2s (vaddr, alen),
+                    client);
+      }
+#endif
+    }
+
+#if MULTIPLE_PEER_SESSIONS
   if (session->expecting_welcome != GNUNET_YES)
     {
       GNUNET_break_op (0);
       GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
       return;
     }
+#endif
   session->last_activity = GNUNET_TIME_absolute_get ();
   session->expecting_welcome = GNUNET_NO;
   GNUNET_SERVER_receive_done (client, GNUNET_OK);
@@ -1799,8 +1845,8 @@
       return;
     }
   session->last_activity = GNUNET_TIME_absolute_get ();
-#if DEBUG_TCP
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+#if DEBUG_TCP > 1
+  GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                   "Passing %u bytes of type %u from `%4s' to transport 
service.\n",
                    (unsigned int) ntohs (message->size),
                   (unsigned int) ntohs (message->type),




reply via email to

[Prev in Thread] Current Thread [Next in Thread]