gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r12846 - gnunet/src/transport
Date: Sun, 5 Sep 2010 12:04:49 +0200

Author: nevans
Date: 2010-09-05 12:04:49 +0200 (Sun, 05 Sep 2010)
New Revision: 12846

Modified:
   gnunet/src/transport/gnunet-nat-server.c
   gnunet/src/transport/gnunet-service-transport.c
   gnunet/src/transport/transport_api.c
Log:
allow transport api to send multiple request connect messages

Modified: gnunet/src/transport/gnunet-nat-server.c
===================================================================
--- gnunet/src/transport/gnunet-nat-server.c    2010-09-05 05:57:58 UTC (rev 
12845)
+++ gnunet/src/transport/gnunet-nat-server.c    2010-09-05 10:04:49 UTC (rev 
12846)
@@ -582,8 +582,8 @@
   if (1 != inet_pton (AF_INET, argv[1], &external))
     {
       fprintf (stderr,
-              "Error parsing IPv4 address: %s\n",
-              strerror (errno));
+              "Error parsing IPv4 address: %s\n",
+              strerror (errno));
       return 1;
     }
   if (1 != inet_pton (AF_INET, DUMMY_IP, &dummy))
@@ -634,7 +634,7 @@
       if (1 == getppid()) /* Check the parent process id, if 1 the parent has 
died, so we should die too */
         break;
       if (FD_ISSET (icmpsock, &rs))
-       process_icmp_response ();
+        process_icmp_response ();
       if (0 == (++alt % 2))
        send_icmp_echo (&external);
       else

Modified: gnunet/src/transport/gnunet-service-transport.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport.c     2010-09-05 05:57:58 UTC 
(rev 12845)
+++ gnunet/src/transport/gnunet-service-transport.c     2010-09-05 10:04:49 UTC 
(rev 12846)
@@ -2782,7 +2782,7 @@
   if (do_hello)
     {
       GNUNET_STATISTICS_update (stats,
-                                gettext_noop ("# peerinfo iterate requests"),
+                                gettext_noop ("# peerinfo new neighbor iterate 
requests"),
                                 1,
                                 GNUNET_NO);
       GNUNET_STATISTICS_update (stats,
@@ -4124,7 +4124,7 @@
   const struct GNUNET_HELLO_Message *hello;
   struct CheckHelloValidatedContext *chvc;
   struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded publicKey;
-#if DEBUG_TRANSPORT_HELLO
+#if DEBUG_TRANSPORT_HELLO > 2
   char *my_id;
 #endif
   hsize = ntohs (message->size);
@@ -4196,7 +4196,7 @@
                               chvc->hello,
                               GNUNET_TIME_absolute_get ()).value > 0)
        {
-#if DEBUG_TRANSPORT_HELLO
+#if DEBUG_TRANSPORT_HELLO > 2
          GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                      "Received duplicate `%s' message for `%4s'; ignored\n",
                      "HELLO",
@@ -4209,7 +4209,7 @@
                                   GNUNET_HELLO_size(hello)));
       chvc = chvc->next;
     }
-#if DEBUG_TRANSPORT_HELLO
+#if DEBUG_TRANSPORT_HELLO > 2
   if (plugin != NULL)
     {
       my_id = GNUNET_strdup(GNUNET_i2s(plugin->env.my_identity));
@@ -4233,7 +4233,7 @@
   /* finally, check if HELLO was previously validated
      (continuation will then schedule actual validation) */
   GNUNET_STATISTICS_update (stats,
-                            gettext_noop ("# peerinfo iterate requests"),
+                            gettext_noop ("# peerinfo process hello iterate 
requests"),
                             1,
                             GNUNET_NO);
   GNUNET_STATISTICS_update (stats,

Modified: gnunet/src/transport/transport_api.c
===================================================================
--- gnunet/src/transport/transport_api.c        2010-09-05 05:57:58 UTC (rev 
12845)
+++ gnunet/src/transport/transport_api.c        2010-09-05 10:04:49 UTC (rev 
12846)
@@ -1289,6 +1289,28 @@
 }
 
 /**
+ * Create and send a request connect message to
+ * the transport service for a particular peer.
+ *
+ * @param h handle to the transport service
+ * @param n the neighbor to send the request connect message about
+ *
+ */
+static void send_request_connect_message(struct GNUNET_TRANSPORT_Handle *h, 
struct NeighbourList *n)
+{
+  struct TransportRequestConnectMessage *trcm;
+
+  trcm = GNUNET_malloc(sizeof(struct TransportRequestConnectMessage));
+  trcm->header.type = htons(GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_CONNECT);
+  trcm->header.size = htons(sizeof(struct TransportRequestConnectMessage));
+  memcpy(&trcm->peer, &n->id, sizeof(struct GNUNET_PeerIdentity));
+  schedule_control_transmit (h,
+                             sizeof (struct TransportRequestConnectMessage),
+                             GNUNET_NO,
+                             GNUNET_TIME_UNIT_FOREVER_REL, 
&send_transport_request_connect, trcm);
+}
+
+/**
  * Add neighbour to our list
  *
  * @return NULL if this API is currently disconnecting from the service
@@ -1298,7 +1320,6 @@
                const struct GNUNET_PeerIdentity *pid)
 {
   struct NeighbourList *n;
-  struct TransportRequestConnectMessage *trcm;
 
   if (GNUNET_YES == h->in_disconnect)
     return NULL;
@@ -1322,14 +1343,7 @@
   n->h = h;
   h->neighbours = n;
 
-  trcm = GNUNET_malloc(sizeof(struct TransportRequestConnectMessage));
-  trcm->header.type = htons(GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_CONNECT);
-  trcm->header.size = htons(sizeof(struct TransportRequestConnectMessage));
-  memcpy(&trcm->peer, pid, sizeof(struct GNUNET_PeerIdentity));
-  schedule_control_transmit (h,
-                             sizeof (struct TransportRequestConnectMessage),
-                             GNUNET_NO,
-                             GNUNET_TIME_UNIT_FOREVER_REL, 
&send_transport_request_connect, trcm);
+
   return n;
 }
 
@@ -1796,6 +1810,17 @@
       n = neighbour_add (handle, target);
 
     }
+
+  /**
+   *  Send a request connect message if not connected,
+   *  otherwise we will never send anything to
+   *  transport service
+   */
+  if (n->is_connected == GNUNET_NO)
+    {
+      send_request_connect_message(handle, n);
+    }
+
   if (n == NULL)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1830,7 +1855,7 @@
   th->priority = priority;
   th->notify_delay_task
     = GNUNET_SCHEDULER_add_delayed (handle->sched, timeout,
-                                   &peer_transmit_timeout, th);
+                                    &peer_transmit_timeout, th);
   schedule_transmission (handle);
   return th;
 }




reply via email to

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