gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r10840 - gnunet/src/hostlist


From: gnunet
Subject: [GNUnet-SVN] r10840 - gnunet/src/hostlist
Date: Wed, 7 Apr 2010 17:40:12 +0200

Author: wachs
Date: 2010-04-07 17:40:12 +0200 (Wed, 07 Apr 2010)
New Revision: 10840

Modified:
   gnunet/src/hostlist/gnunet-daemon-hostlist.c
Log:
Initial changes to implement hostlist learning

Modified: gnunet/src/hostlist/gnunet-daemon-hostlist.c
===================================================================
--- gnunet/src/hostlist/gnunet-daemon-hostlist.c        2010-04-07 15:38:10 UTC 
(rev 10839)
+++ gnunet/src/hostlist/gnunet-daemon-hostlist.c        2010-04-07 15:40:12 UTC 
(rev 10840)
@@ -42,6 +42,8 @@
 #include "gnunet_time_lib.h"
 #include "gnunet_util_lib.h"
 
+#define DEBUG_HOSTLIST_LEARNING GNUNET_YES
+#define VERBOSE GNUNET_YES
 
 /**
  * Set if we are allowed to advertise our hostlist to others.
@@ -110,7 +112,23 @@
     }
 }
 
+/**
+ * Core handler for p2p hostlist advertisements
+ */
+static int handle_hostlist_advertisement (void *cls,
+                             const struct GNUNET_PeerIdentity * peer,
+                             const struct GNUNET_MessageHeader * message,
+                             struct GNUNET_TIME_Relative latency,
+                             uint32_t distance)
+{
+#if DEBUG_HOSTLIST_LEARNING
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  _("Recieved hostlist advertisement\n"));
+#endif
 
+      return GNUNET_OK;
+}
+
 /**
  * Last task run during shutdown.  Disconnects us from
  * the other services.
@@ -119,7 +137,7 @@
 cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Hostlist daemon is shutting down.\n");
+             "Hostlist daemon is shutting down\n");
   if (bootstrapping)
     {
       GNUNET_HOSTLIST_client_stop ();
@@ -141,6 +159,14 @@
     }
 }
 
+/**
+ * List of handlers for the messages understood by this
+ * service.
+ */
+static struct GNUNET_CORE_MessageHandler handlers[] = {
+    { &handle_hostlist_advertisement, 
GNUNET_MESSAGE_TYPE_HOSTLIST_ADVERTISEMENT, 0},
+    { NULL, 0, 0 }
+};
 
 /**
  * Main function that will be run.
@@ -160,11 +186,15 @@
 {
   GNUNET_CORE_ConnectEventHandler ch = NULL;
   GNUNET_CORE_DisconnectEventHandler dh = NULL;
-  struct GNUNET_CORE_MessageHandler handlers[] = 
-    {
+
+
+
+  struct GNUNET_CORE_MessageHandler null_handler[] = {
       { NULL, 0, 0 }
-    };
+  };
 
+  struct GNUNET_CORE_MessageHandler *used_handler = null_handler;
+
   if ( (! bootstrapping) &&
        (! learning) &&
        (! provide_hostlist) )
@@ -185,16 +215,18 @@
     }
   if (learning)
     {
-      /* FIXME (register handler with core for hostlist ads) */
+      used_handler = handlers;
     }
+
   core = GNUNET_CORE_connect (sched, cfg,
-                             GNUNET_TIME_UNIT_FOREVER_REL,
-                             NULL,
-                             &core_init,
-                             NULL, ch, dh,
-                             NULL, GNUNET_NO,
-                             NULL, GNUNET_NO,
-                             handlers);
+                            GNUNET_TIME_UNIT_FOREVER_REL,
+                            NULL,
+                            &core_init,
+                            NULL, ch, dh,
+                            NULL, GNUNET_NO,
+                            NULL, GNUNET_NO,
+                            used_handler);
+
   GNUNET_SCHEDULER_add_delayed (sched,
                                 GNUNET_TIME_UNIT_FOREVER_REL,
                                 &cleaning_task, NULL);
@@ -220,7 +252,15 @@
 main (int argc, char *const *argv)
 {
   int ret;
+  GNUNET_log_setup ("hostlist","DEBUG",NULL);
 
+  GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+              "ERROR\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "DEBUG\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+              "INFO\n");
+
   ret = (GNUNET_OK ==
          GNUNET_PROGRAM_run (argc,
                              argv,
@@ -228,6 +268,7 @@
                             _("GNUnet hostlist server and client"),
                             options,
                             &run, NULL)) ? 0 : 1;
+
   return ret;
 }
 





reply via email to

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