gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r11109 - gnunet/src/dv


From: gnunet
Subject: [GNUnet-SVN] r11109 - gnunet/src/dv
Date: Wed, 28 Apr 2010 18:43:58 +0200

Author: nevans
Date: 2010-04-28 18:43:58 +0200 (Wed, 28 Apr 2010)
New Revision: 11109

Modified:
   gnunet/src/dv/dv.h
   gnunet/src/dv/dv_api.c
   gnunet/src/dv/gnunet-service-dv.c
   gnunet/src/dv/plugin_transport_dv.c
   gnunet/src/dv/test_transport_api_dv.c
   gnunet/src/dv/test_transport_api_dv_peer1.conf
   gnunet/src/dv/test_transport_api_dv_peer2.conf
   gnunet/src/dv/test_transport_api_dv_peer3.conf
Log:
in case of fire, or volcano. still not to be used by anyone for anything

Modified: gnunet/src/dv/dv.h
===================================================================
--- gnunet/src/dv/dv.h  2010-04-28 16:36:39 UTC (rev 11108)
+++ gnunet/src/dv/dv.h  2010-04-28 16:43:58 UTC (rev 11109)
@@ -30,14 +30,14 @@
 
 #define DEBUG_DV_GOSSIP GNUNET_NO
 #define DEBUG_DV_GOSSIP_RECEIPT GNUNET_YES
-#define DEBUG_DV GNUNET_YES
+#define DEBUG_DV GNUNET_NO
 #define DEBUG_DV_API GNUNET_YES
 
 typedef void (*GNUNET_DV_MessageReceivedHandler) (void *cls,
                                                   struct GNUNET_PeerIdentity 
*sender,
                                                   char *msg,
                                                   size_t msg_len,
-                                                  unsigned int distance,
+                                                  uint32_t distance,
                                                   char *sender_address,
                                                   size_t sender_address_len);
 

Modified: gnunet/src/dv/dv_api.c
===================================================================
--- gnunet/src/dv/dv_api.c      2010-04-28 16:36:39 UTC (rev 11108)
+++ gnunet/src/dv/dv_api.c      2010-04-28 16:43:58 UTC (rev 11109)
@@ -320,9 +320,11 @@
   memcpy(packed_msg, &packed_msg_start[sender_address_len], packed_msg_len);
 
 #if DEBUG_DV
-  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "packed message type: %d or %d\n", 
ntohs(((struct GNUNET_MessageHeader *)packed_msg)->type), ((struct 
GNUNET_MessageHeader *)packed_msg)->type);
-  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "message sender reported as %s\n", 
GNUNET_i2s(&received_msg->sender));
+  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "DV_API receive: packed message type: %d 
or %d\n", ntohs(((struct GNUNET_MessageHeader *)packed_msg)->type), ((struct 
GNUNET_MessageHeader *)packed_msg)->type);
+  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "DV_API receive: message sender reported 
as %s\n", GNUNET_i2s(&received_msg->sender));
+  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "DV_API receive: distance is %u\n", 
ntohl(received_msg->distance));
 #endif
+
   handle->receive_handler(handle->receive_cls,
                           &received_msg->sender,
                           packed_msg,

Modified: gnunet/src/dv/gnunet-service-dv.c
===================================================================
--- gnunet/src/dv/gnunet-service-dv.c   2010-04-28 16:36:39 UTC (rev 11108)
+++ gnunet/src/dv/gnunet-service-dv.c   2010-04-28 16:43:58 UTC (rev 11109)
@@ -27,13 +27,7 @@
  * @author Christian Grothoff
  * @author Nathan Evans
  *
- * TODO: Currently the final hop of a DV message assigns a 0 to the receiver
- * id field.  This probably can't work(!) even if we know that the peer is
- * a direct neighbor (unless we can trust that transport will choose that
- * address for the peer).  So the DV message will likely need to have the
- * peer identity of the recipient.
- *
- * Also the gossip rates need to be worked out.  Probably many other things
+ * TODO: The gossip rates need to be worked out.  Probably many other things
  * as well.
  *
  */
@@ -114,6 +108,11 @@
 #define DV_PRIORITY 0
 
 /**
+ * The cost to a direct neighbor.  We used to use 0, but 1 makes more sense.
+ */
+#define DIRECT_NEIGHBOR_COST 1
+
+/**
  * The client, should be the DV plugin connected to us.  Hopefully
  * this client will never change, although if the plugin dies
  * and returns for some reason it may happen.
@@ -179,6 +178,10 @@
  */
 struct PendingMessage *plugin_pending_tail;
 
+/**
+ * Handle to the peerinfo service
+ */
+struct GNUNET_PEERINFO_Handle *peerinfo_handle;
 
 /**
  * Transmit handle to core service.
@@ -196,8 +199,6 @@
 struct PendingMessage *core_pending_tail;
 
 
-
-
 /**
  * Context created whenever a direct peer connects to us,
  * used to gossip other peers to it.
@@ -674,7 +675,7 @@
           (size >= off + (msize = ntohs (reply->msg->size))))
     {
 #if DEBUG_DV
-    GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "`%s' : transmit_notify (core) 
called with size %d\n", "dv service", msize);
+    GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "`%s' : transmit_notify (core) called 
with size %d\n", "dv service", msize);
 #endif
       GNUNET_CONTAINER_DLL_remove (core_pending_head,
                                    core_pending_tail,
@@ -751,7 +752,7 @@
 #if DEBUG_DV
   memcpy(&shortname, GNUNET_i2s(&specific_neighbor->identity), 4);
   shortname[4] = '\0';
-  GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "%s: Notifying core of send to 
destination `%s' via `%s' size %u\n", "DV", &shortname, 
GNUNET_i2s(&specific_neighbor->referrer->identity), msg_size);
+  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s: Notifying core of send to 
destination `%s' via `%s' size %u\n", "DV", &shortname, 
GNUNET_i2s(&specific_neighbor->referrer->identity), msg_size);
 #endif
 
   GNUNET_CONTAINER_DLL_insert_after (core_pending_head,
@@ -761,7 +762,7 @@
   if (core_transmit_handle == NULL)
     core_transmit_handle = GNUNET_CORE_notify_transmit_ready(coreAPI, 
send_context->importance, send_context->timeout, 
&specific_neighbor->referrer->identity, msg_size, &core_transmit_notify, NULL);
   else
-    GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "`%s': Failed to schedule pending 
transmission (must be one in progress!)\n", "dv service");
+    GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "`%s': Failed to schedule pending 
transmission (must be one in progress!)\n", "dv service");
 
   return (int) cost;
 }
@@ -840,7 +841,7 @@
                                      core_pending_tail,
                                      pending_message);
 #if DEBUG_DV
-  GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "%s: Notifying core of send size %d to 
destination `%s'\n", "DV SEND MESSAGE", msg_size, GNUNET_i2s(recipient));
+  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s: Notifying core of send size %d to 
destination `%s'\n", "DV SEND MESSAGE", msg_size, GNUNET_i2s(recipient));
 #endif
   if (core_transmit_handle == NULL)
     core_transmit_handle = GNUNET_CORE_notify_transmit_ready(coreAPI, 
importance, timeout, &target->referrer->identity, msg_size, 
&core_transmit_notify, NULL);
@@ -913,7 +914,7 @@
   if (pos == NULL)
     {
 #if DEBUG_DV
-      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                   "%s: unknown sender (%d), size of extended_peers is %d!\n", 
"dv", ntohl(incoming->sender), GNUNET_CONTAINER_multihashmap_size 
(ctx.extended_neighbors));
 #endif
       /* unknown sender */
@@ -931,8 +932,8 @@
         {
           packed_message = (struct GNUNET_MessageHeader *)&cbuf[offset];
 #if DEBUG_DV
-          GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                      "%s: Receives %s message for me, size %d type %d!\n", 
"dv", "DV DATA", ntohs(packed_message->size), ntohs(packed_message->type));
+          GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                      "%s: Receives %s message for me, size %d type %d, cost 
%u!\n", "dv", "DV DATA", ntohs(packed_message->size), 
ntohs(packed_message->type), pos->cost);
 #endif
           GNUNET_break_op (ntohs (packed_message->type) != 
GNUNET_MESSAGE_TYPE_DV_GOSSIP);
           GNUNET_break_op (ntohs (packed_message->type) != 
GNUNET_MESSAGE_TYPE_DV_DATA);
@@ -1174,7 +1175,7 @@
   if (client_handle == NULL)
   {
     client_handle = client;
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "%s: Setting initial client handle, never received `%s' 
message?\n", "dv", "START");
   }
   else if (client_handle != client)
@@ -1290,6 +1291,7 @@
   GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "calling CORE_DISCONNECT\n");
 #endif
   GNUNET_CORE_disconnect (coreAPI);
+  GNUNET_PEERINFO_disconnect(peerinfo_handle);
 #if DEBUG_DV
   GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "CORE_DISCONNECT completed\n");
 #endif
@@ -1487,7 +1489,7 @@
               GNUNET_free(neighbor_update);
               return;
             }
-          if (max->cost > 0)
+          if (max->cost > 1)
             {
               /* only free if this is not a direct connection;
                  we could theoretically have more direct
@@ -1518,7 +1520,7 @@
       neighbor->referrer_id = referrer_peer_id;
       neighbor->our_id = our_id;
       neighbor->hidden =
-        (cost == 0) ? (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 
4) ==
+        (cost == DIRECT_NEIGHBOR_COST) ? (GNUNET_CRYPTO_random_u32 
(GNUNET_CRYPTO_QUALITY_WEAK, 4) ==
                        0) : GNUNET_NO;
       GNUNET_CONTAINER_multihashmap_put (ctx.extended_neighbors, 
&peer->hashPubKey,
                                  neighbor,
@@ -1537,25 +1539,7 @@
     GNUNET_CONTAINER_multihashmap_iterate(ctx.extended_neighbors, 
&print_neighbors, NULL);
 #endif
   GNUNET_free(neighbor_update);
-  /* Old logic to remove entry and replace, not needed now as we only want to 
remove when full
-   * or when the referring peer disconnects from us.
-   *
-   * FIXME: add new functionality, or check if it already exists (i forget)
-   */
-  /*
-  GNUNET_DLL_remove (neighbor->referrer->referee_head,
-                     neighbor->referrer->referee_tail, neighbor);
-  neighbor->referrer = referrer;
-  GNUNET_DLL_insert (referrer->referee_head,
-                     referrer->referee_tail, neighbor);
-  GNUNET_CONTAINER_heap_update_cost (ctx.neighbor_max_heap,
-                                     neighbor->max_loc, cost);
-  GNUNET_CONTAINER_heap_update_cost (ctx.neighbor_min_heap,
-                                     neighbor->min_loc, cost);
-  neighbor->referrer_id = referrer_peer_id;
-  neighbor->last_activity = now;
-  neighbor->cost = cost;
-  */
+
 }
 
 
@@ -1658,8 +1642,8 @@
 
 static void
 process_peerinfo (void *cls,
-         const struct GNUNET_PeerIdentity *peer,
-         const struct GNUNET_HELLO_Message *hello, uint32_t trust)
+                  const struct GNUNET_PeerIdentity *peer,
+                  const struct GNUNET_HELLO_Message *hello, uint32_t trust)
 {
   struct PeerIteratorContext *peerinfo_iterator = cls;
   struct DirectNeighbor *neighbor = peerinfo_iterator->neighbor;
@@ -1704,7 +1688,7 @@
               "%s: Receives core connect message for peer %s distance %d!\n", 
"dv", GNUNET_i2s(peer), distance);
 #endif
 
-  if ((distance == 0) && 
(GNUNET_CONTAINER_multihashmap_get(ctx.direct_neighbors, &peer->hashPubKey) == 
NULL))
+  if ((distance == DIRECT_NEIGHBOR_COST) && 
(GNUNET_CONTAINER_multihashmap_get(ctx.direct_neighbors, &peer->hashPubKey) == 
NULL))
   {
     peerinfo_iterator = GNUNET_malloc(sizeof(struct PeerIteratorContext));
     neighbor = GNUNET_malloc (sizeof (struct DirectNeighbor));
@@ -1716,15 +1700,14 @@
     GNUNET_CONTAINER_multihashmap_put (ctx.direct_neighbors,
                                &peer->hashPubKey,
                                neighbor, 
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
-    addUpdateNeighbor (peer, NULL, 0, neighbor, 0);
+    addUpdateNeighbor (peer, NULL, 0, neighbor, DIRECT_NEIGHBOR_COST);
     peerinfo_iterator->neighbor = neighbor;
-    peerinfo_iterator->ic = GNUNET_PEERINFO_iterate (cfg,
-                                            sched,
-                                            peer,
-                                            0,
-                                            GNUNET_TIME_relative_multiply
-                                            (GNUNET_TIME_UNIT_SECONDS, 15),
-                                            &process_peerinfo, 
peerinfo_iterator);
+    peerinfo_iterator->ic = GNUNET_PEERINFO_iterate (peerinfo_handle,
+                                                     peer,
+                                                     0,
+                                                     
GNUNET_TIME_UNIT_FOREVER_REL,
+                                                     &process_peerinfo,
+                                                     peerinfo_iterator);
     /* Only add once we get the publicKey of this guy
      *
      * neighbor->send_context->task = GNUNET_SCHEDULER_add_now(sched, 
&neighbor_send_task, neighbor->send_context);
@@ -1734,7 +1717,7 @@
   {
 #if DEBUG_DV
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "%s: Distance (%d) greater than 0 or already know about peer 
(%s), not re-adding!\n", "dv", distance, GNUNET_i2s(peer));
+                "%s: Distance (%d) greater than %d or already know about peer 
(%s), not re-adding!\n", "dv", distance, DIRECT_NEIGHBOR_COST, 
GNUNET_i2s(peer));
 #endif
     return;
   }
@@ -1810,8 +1793,6 @@
   client_transmit_timeout = GNUNET_TIME_relative_get_forever(); /* Only 
timeout on disconnect */
   default_dv_delay = GNUNET_TIME_relative_get_forever(); /* Only timeout on 
disconnect */
 
-  //client_transmit_timeout = 
GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5);
-  //default_dv_delay = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 
5);
   GNUNET_SERVER_add_handlers (server, plugin_handlers);
   coreAPI =
   GNUNET_CORE_connect (sched,
@@ -1829,8 +1810,15 @@
 
   if (coreAPI == NULL)
     return;
-  /* load (server); Huh? */
 
+   peerinfo_handle = GNUNET_PEERINFO_connect(sched, cfg);
+
+   if (peerinfo_handle == NULL)
+     {
+       GNUNET_CORE_disconnect(coreAPI);
+       return;
+     }
+
   /* Scheduled the task to clean up when shutdown is called */
   cleanup_task = GNUNET_SCHEDULER_add_delayed (sched,
                                 GNUNET_TIME_UNIT_FOREVER_REL,

Modified: gnunet/src/dv/plugin_transport_dv.c
===================================================================
--- gnunet/src/dv/plugin_transport_dv.c 2010-04-28 16:36:39 UTC (rev 11108)
+++ gnunet/src/dv/plugin_transport_dv.c 2010-04-28 16:43:58 UTC (rev 11109)
@@ -173,7 +173,7 @@
                                  struct GNUNET_PeerIdentity *sender,
                                  char *msg,
                                  size_t msg_len,
-                                 unsigned int distance,
+                                 uint32_t distance,
                                  char *sender_address,
                                  size_t sender_address_len)
 {
@@ -181,8 +181,9 @@
 
   GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
                    "plugin_transport_dv",
-                   _("Received message from %s of type %d!\n"),
-                   "DV SERVICE", ntohs(((struct GNUNET_MessageHeader 
*)msg)->type));
+                   _("PLUGIN Received message from %s of type %d, distance 
%u!\n"),
+                   "DV SERVICE", ntohs(((struct GNUNET_MessageHeader 
*)msg)->type), distance);
+
   plugin->env->receive(plugin->env->cls,
                        sender,
                        (struct GNUNET_MessageHeader *)msg,

Modified: gnunet/src/dv/test_transport_api_dv.c
===================================================================
--- gnunet/src/dv/test_transport_api_dv.c       2010-04-28 16:36:39 UTC (rev 
11108)
+++ gnunet/src/dv/test_transport_api_dv.c       2010-04-28 16:43:58 UTC (rev 
11109)
@@ -42,9 +42,9 @@
 #include "gnunet_transport_service.h"
 #include "../transport/transport.h"
 
-#define VERBOSE GNUNET_YES
+#define VERBOSE GNUNET_NO
 
-#define VERBOSE_ARM GNUNET_YES
+#define VERBOSE_ARM GNUNET_NO
 
 #define START_ARM GNUNET_YES
 
@@ -112,7 +112,7 @@
 #if VERBOSE
                                         "-L", "DEBUG",
 #endif
-                                        "-c", p->cfg_file, "-e", NULL);
+                                        "-c", p->cfg_file, "-e", "-q", NULL);
 
   GNUNET_OS_process_wait (p->arm_pid);
 #endif
@@ -129,9 +129,8 @@
 #if VERBOSE
                                         "-L", "DEBUG",
 #endif
-                                        "-c", p->cfg_file, "-k", "transport", 
NULL);
+                                        "-c", p->cfg_file, "-k", "transport", 
"-q", NULL);
 
-  fprintf(stderr, "stop arm command returned %d\n", p->arm_pid);
   GNUNET_OS_process_wait (p->arm_pid);
 #endif
 
@@ -141,7 +140,7 @@
 #if VERBOSE
                                         "-L", "DEBUG",
 #endif
-                                        "-c", p->cfg_file, "-i", "transport", 
NULL);
+                                        "-c", p->cfg_file, "-i", "transport", 
"-q", NULL);
 
   GNUNET_OS_process_wait (p->arm_pid);
 #endif
@@ -232,7 +231,7 @@
     {
 
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                 "Peer 1 notified about connection to peer 3, distance %d!\n", 
GNUNET_i2s (peer), cls, distance);
+                 "Peer 1 notified about connection to peer 3, distance %u!\n", 
GNUNET_i2s (peer), cls, distance);
 
       GNUNET_TRANSPORT_notify_transmit_ready (p1.th,
                                              &p3.id,
@@ -264,7 +263,7 @@
 #if VERBOSE_ARM
                                         "-L", "DEBUG",
 #endif
-                                        "-c", cfgname, "-s", NULL);
+                                        "-c", cfgname, "-s", "-q", NULL);
 #endif
   GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
 

Modified: gnunet/src/dv/test_transport_api_dv_peer1.conf
===================================================================
--- gnunet/src/dv/test_transport_api_dv_peer1.conf      2010-04-28 16:36:39 UTC 
(rev 11108)
+++ gnunet/src/dv/test_transport_api_dv_peer1.conf      2010-04-28 16:43:58 UTC 
(rev 11109)
@@ -49,7 +49,7 @@
 DEBUG = NO
 #PREFIX = xterm -T transport2 -e gdb --command=cmd --args
 #PREFIX = valgrind --leak-check=full
-#BINARY = 
/root/documents/research/gnunet/gnunet-ng/src/transport/.libs/gnunet-service-transport
+#BINARY = 
/home/mrwiggles/documents/research/gnunet/gnunet-ng/src/transport/.libs/gnunet-service-transport
 ALLOW_SHUTDOWN = YES
 ACCEPT_FROM6 = ::1;
 ACCEPT_FROM = 127.0.0.1;

Modified: gnunet/src/dv/test_transport_api_dv_peer2.conf
===================================================================
--- gnunet/src/dv/test_transport_api_dv_peer2.conf      2010-04-28 16:36:39 UTC 
(rev 11108)
+++ gnunet/src/dv/test_transport_api_dv_peer2.conf      2010-04-28 16:43:58 UTC 
(rev 11109)
@@ -64,7 +64,8 @@
 ACCEPT_FROM6 = ::1;
 ACCEPT_FROM = 127.0.0.1;
 NEIGHBOUR_LIMIT = 50
-BINARY = gnunet-service-transport
+#BINARY = gnunet-service-transport
+#BINARY = 
/home/mrwiggles/documents/research/gnunet/gnunet-ng/src/transport/.libs/gnunet-service-transport
 CONFIG = $DEFAULTCONFIG
 HOME = $SERVICEHOME
 HOSTNAME = localhost

Modified: gnunet/src/dv/test_transport_api_dv_peer3.conf
===================================================================
--- gnunet/src/dv/test_transport_api_dv_peer3.conf      2010-04-28 16:36:39 UTC 
(rev 11108)
+++ gnunet/src/dv/test_transport_api_dv_peer3.conf      2010-04-28 16:43:58 UTC 
(rev 11109)
@@ -46,7 +46,7 @@
 
 [transport]
 PLUGINS = tcp dv
-DEBUG = YES
+DEBUG = NO
 ALLOW_SHUTDOWN = YES
 ACCEPT_FROM6 = ::1;
 ACCEPT_FROM = 127.0.0.1;
@@ -106,7 +106,7 @@
 PORT = 32367
 
 [dv]
-DEBUG = YES
+DEBUG = NO
 ALLOW_SHUTDOWN = YES
 ACCEPT_FROM6 = ::1;
 ACCEPT_FROM = 127.0.0.1;





reply via email to

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