gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r10143 - gnunet/src/transport
Date: Mon, 25 Jan 2010 14:59:55 +0100

Author: nevans
Date: 2010-01-25 14:59:55 +0100 (Mon, 25 Jan 2010)
New Revision: 10143

Modified:
   gnunet/src/transport/gnunet-service-transport.c
   gnunet/src/transport/plugin_transport_udp.c
Log:
udp closer to working, still wrestling with how to do data structures properly 
in gnunet-service-transport.c (grr)

Modified: gnunet/src/transport/gnunet-service-transport.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport.c     2010-01-25 10:46:32 UTC 
(rev 10142)
+++ gnunet/src/transport/gnunet-service-transport.c     2010-01-25 13:59:55 UTC 
(rev 10143)
@@ -988,7 +988,12 @@
       rl->connected = GNUNET_NO;
     }
   if (!mq->internal_msg)
-    rl->transmit_ready = GNUNET_YES;
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "Setting transmit_ready on transport!\n");
+      rl->transmit_ready = GNUNET_YES;
+    }
+
   if (mq->client != NULL)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1025,6 +1030,16 @@
   struct MessageQueue *mq;
   struct GNUNET_TIME_Absolute now;
 
+  if (neighbor->addr != NULL)
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+          _("try_transmission_to_peer entry: at this point neighbor->addr is 
NOT NULL\n"));
+    }
+  else
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("try_transmission_to_peer entry: 
at this point neighbor->addr is NULL\n"));
+    }
+
   if (neighbor->messages == NULL)
     return;                     /* nothing to do */
   try_alternative_plugins (neighbor);
@@ -1045,6 +1060,13 @@
 #endif
           pos->connected = GNUNET_NO;
         }
+      if (GNUNET_YES == pos->transmit_ready)
+        {
+#if DEBUG_TRANSPORT
+          GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                      "Found transmit_ready flag...\n");
+#endif
+        }
       if (((GNUNET_YES == pos->transmit_ready) ||
            (mq->internal_msg)) &&
           (pos->connect_attempts < MAX_CONNECT_RETRY) &&
@@ -1084,6 +1106,10 @@
               GNUNET_i2s (&neighbor->id), rl->plugin->short_name);
 #endif
 
+  if (rl->neighbor->addr != NULL)
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("try_transmission_to_peer 
pre-send: at this point rl->neighbor->addr is NOT NULL, addrlen is %d\n"), 
rl->neighbor->addr_len);
+  else
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("try_transmission_to_peer pre-send: 
at this point rl->neighbor->addr is NULL\n"));
   rl->plugin->api->send (rl->plugin->api->cls,
                          &neighbor->id,
                          mq->message,
@@ -1119,6 +1145,8 @@
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               _("Sending message of type %u to peer `%4s'\n"),
               ntohs (msg->type), GNUNET_i2s (&neighbor->id));
+  if (neighbor->addr != NULL)
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("transmit_to_peer: at this point 
neighbor->addr is NOT NULL\n"));
 #endif
   if (client != NULL)
     {
@@ -1190,7 +1218,17 @@
       gc->addr_pos = (gc->plug_pos != NULL) ? gc->plug_pos->addresses : NULL;
     }
   if (NULL == gc->plug_pos)
-    return 0;
+    {
+#if DEBUG_TRANSPORT
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "In address_generator, gc->plug_pos is NULL!\n");
+#endif
+      return 0;
+    }
+#if DEBUG_TRANSPORT
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "Should be adding an address...\n");
+#endif
   ret = GNUNET_HELLO_add_address (gc->plug_pos->short_name,
                                   gc->expiration,
                                   gc->addr_pos->addr,
@@ -1220,6 +1258,10 @@
   gc.addr_pos = plugins != NULL ? plugins->addresses : NULL;
   gc.expiration = GNUNET_TIME_relative_to_absolute (HELLO_ADDRESS_EXPIRATION);
   hello = GNUNET_HELLO_create (&my_public_key, &address_generator, &gc);
+#if DEBUG_TRANSPORT
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
+              "Refreshed my `%s', new size is %d\n", "HELLO", 
GNUNET_HELLO_size(hello));
+#endif
   cpos = clients;
   while (cpos != NULL)
     {
@@ -1801,6 +1843,7 @@
   struct ValidationAddress *va;
   struct TransportPlugin *tp;
   int first_call;
+  int count;
   struct GNUNET_PeerIdentity apeer;
 
   first_call = GNUNET_NO;
@@ -1817,6 +1860,10 @@
       chvc->e->next = pending_validations;
       pending_validations = chvc->e;
     }
+  /* no existing HELLO, all addresses are new */
+  GNUNET_HELLO_iterate_addresses (chvc->hello,
+                                  GNUNET_NO, &run_validation, chvc->e);
+#if 0
   if (h != NULL)
     {
       GNUNET_HELLO_iterate_new_addresses (chvc->hello,
@@ -1830,6 +1877,7 @@
       GNUNET_HELLO_iterate_addresses (chvc->hello,
                                       GNUNET_NO, &run_validation, chvc->e);
     }
+#endif
   if (h != NULL)
     return;                     /* wait for next call */
   /* finally, transmit validation attempts */
@@ -1840,6 +1888,7 @@
               "HELLO", GNUNET_i2s (&apeer));
 #endif
   va = chvc->e->addresses;
+  count = 0;
   while (va != NULL)
     {
 #if DEBUG_TRANSPORT
@@ -1858,7 +1907,13 @@
                         &va[1], va->addr_len);
       /* va->ok = GNUNET_SYSERR; will be set by validate_address! */
       va = va->next;
+      count++;
     }
+
+#if DEBUG_TRANSPORT
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "Found %d addresses in hello of size %d\n", count, 
GNUNET_HELLO_size(chvc->hello));
+#endif
   GNUNET_SCHEDULER_add_delayed (sched,
                                 GNUNET_TIME_absolute_get_remaining (chvc->
                                                                     
e->timeout),
@@ -1909,8 +1964,8 @@
                       &target.hashPubKey);
 #if DEBUG_TRANSPORT
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Processing `%s' message for `%4s'\n",
-              "HELLO", GNUNET_i2s (&target));
+              "Processing `%s' message for `%4s' of size %d (hsize is %d)\n",
+              "HELLO", GNUNET_i2s (&target), GNUNET_HELLO_size(hello), hsize);
 #endif
   /* check if a HELLO for this peer is already on the validation list */
   e = pending_validations;
@@ -2125,7 +2180,7 @@
   struct TransportPingMessage *ping;
   struct TransportPongMessage *pong;
   uint16_t msize;
-
+  struct NeighborList *n;
   pong = GNUNET_malloc(sizeof(struct TransportPongMessage));
 
 #if DEBUG_TRANSPORT
@@ -2181,11 +2236,37 @@
   GNUNET_assert (GNUNET_OK ==
                  GNUNET_CRYPTO_rsa_sign (my_private_key,
                                          &pong->purpose, &pong->signature));
+  /* Will this nonsense work, even for UDP?
+   * The idea is that we need an address to send to for UDP, but we may not 
know
+   * this peer yet.  So in that case, we need to create a new neighbor with the
+   * current address, but is this address going to be correct, or will it have 
a
+   * random high port or something? Another question is, why didn't we get a 
WELCOME
+   * from this peer with its advertised addresses already?  We don't want to
+   * differentiate based on transport... */
+  n = find_neighbor(peer, NULL, 0);
+  if (n == NULL)
+    {
+#if DEBUG_TRANSPORT
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Didn't find peer in list, adding...\n");
+#endif
+      setup_new_neighbor(peer, sender_address, sender_address_len);
+      n = find_neighbor(peer, sender_address, sender_address_len);
+      GNUNET_assert(n != NULL);
+    }
+  else if (n->addr == NULL)
+    {
+#if DEBUG_TRANSPORT
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Found peer in list, but without address, adding!\n");
+#endif
+      n->addr = GNUNET_malloc(sender_address_len);
+      memcpy(n->addr, sender_address, sender_address_len);
+      n->addr_len = sender_address_len;
+    }
 
-  transmit_to_peer(NULL, TRANSPORT_DEFAULT_PRIORITY, &pong->header, GNUNET_NO, 
find_neighbor(peer, NULL, 0));
-  /* plugin->api->send(); */ /* We can't directly send back along received 
address, because
-                          the port we saw for the peer (for TCP especially) 
will not
-                          likely be the open port on the other side! */
+  transmit_to_peer(NULL, TRANSPORT_DEFAULT_PRIORITY, &pong->header, GNUNET_NO, 
n);
+
   GNUNET_free(pong);
   return GNUNET_OK;
 }

Modified: gnunet/src/transport/plugin_transport_udp.c
===================================================================
--- gnunet/src/transport/plugin_transport_udp.c 2010-01-25 10:46:32 UTC (rev 
10142)
+++ gnunet/src/transport/plugin_transport_udp.c 2010-01-25 13:59:55 UTC (rev 
10143)
@@ -40,7 +40,7 @@
 #include "plugin_transport.h"
 #include "transport.h"
 
-#define DEBUG_UDP GNUNET_NO
+#define DEBUG_UDP GNUNET_YES
 
 /*
  * Transport cost to peer, always 1 for UDP (direct connection)
@@ -216,8 +216,17 @@
   ssize_t sent;
 
   GNUNET_assert(udp_sock != NULL);
-  GNUNET_assert(addr != NULL);
 
+  if ((addr == NULL) || (addrlen == 0))
+    {
+#if DEBUG_UDP
+  GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "udp", _
+                   ("udp_plugin_send called without address, returning!\n"));
+#endif
+      cont (cont_cls, target, GNUNET_OK);
+      return 0; /* Can never send if we don't have an address!! */
+    }
+
   /* Build the message to be sent */
   message = GNUNET_malloc (sizeof (struct UDPMessage) + ntohs (msg->size));
   ssize = sizeof (struct UDPMessage) + ntohs (msg->size);
@@ -243,7 +252,13 @@
       if (sent == GNUNET_SYSERR)
         cont (cont_cls, target, GNUNET_SYSERR);
       else
-        cont (cont_cls, target, GNUNET_OK);
+        {
+#if DEBUG_UDP
+  GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "udp", _
+                   ("Sucessfully sent message, calling transmit 
continuation!\n"));
+#endif
+          cont (cont_cls, target, GNUNET_OK);
+        }
     }
   GNUNET_free (message);
   return sent;
@@ -405,7 +420,7 @@
                        ntohs (hdr->type));
 #endif
       plugin->env->receive (plugin->env->cls,
-          sender, &msg->header, UDP_DIRECT_DISTANCE, (char *)&addr, fromlen);
+          sender, hdr, UDP_DIRECT_DISTANCE, (char *)&addr, fromlen);
 
       GNUNET_free (sender);
       GNUNET_free (buf);
@@ -562,7 +577,7 @@
       v6 = (struct sockaddr_in6 *) buf;
       v6->sin6_port = htons (check_port (plugin, ntohs (v6->sin6_port)));
     }
-#if DEBUG_TCP
+#if DEBUG_UDP
   GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
                    "tcp",
                    "Informing transport service about my address `%s'.\n",





reply via email to

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