gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r10895 - gnunet/src/hostlist
Date: Tue, 13 Apr 2010 14:14:08 +0200

Author: wachs
Date: 2010-04-13 14:14:08 +0200 (Tue, 13 Apr 2010)
New Revision: 10895

Modified:
   gnunet/src/hostlist/gnunet-daemon-hostlist.c
   gnunet/src/hostlist/hostlist-client.c
   gnunet/src/hostlist/hostlist-server.c
   gnunet/src/hostlist/hostlist-server.h
   gnunet/src/hostlist/test_gnunet_daemon_hostlist_learning.c
Log:
Correct handling of daemon options to en/disable learning and advertising 

Modified: gnunet/src/hostlist/gnunet-daemon-hostlist.c
===================================================================
--- gnunet/src/hostlist/gnunet-daemon-hostlist.c        2010-04-13 11:06:23 UTC 
(rev 10894)
+++ gnunet/src/hostlist/gnunet-daemon-hostlist.c        2010-04-13 12:14:08 UTC 
(rev 10895)
@@ -168,8 +168,15 @@
                              struct GNUNET_TIME_Relative latency,
                              uint32_t distance)
 {
-  if (advertising && (NULL != client_adv_handler))
+  if ( !learning )
     {
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Recieved hostlist advertisement, but I am not learning!\n");
+    return GNUNET_NO;
+    }
+
+  if (learning && (NULL != client_adv_handler))
+    {
         (*client_adv_handler) (cls, peer, message, latency, distance);
         return GNUNET_YES;
     }
@@ -303,7 +310,7 @@
     }
   if (provide_hostlist)
     {      
-      GNUNET_HOSTLIST_server_start (cfg, sched, stats, core, &server_ch, 
&server_dh);
+      GNUNET_HOSTLIST_server_start (cfg, sched, stats, core, &server_ch, 
&server_dh, advertising );
     }
   if (learning)
     {

Modified: gnunet/src/hostlist/hostlist-client.c
===================================================================
--- gnunet/src/hostlist/hostlist-client.c       2010-04-13 11:06:23 UTC (rev 
10894)
+++ gnunet/src/hostlist/hostlist-client.c       2010-04-13 12:14:08 UTC (rev 
10895)
@@ -30,6 +30,7 @@
 #include "gnunet_hello_lib.h"
 #include "gnunet_statistics_service.h"
 #include "gnunet_transport_service.h"
+#include "gnunet-daemon-hostlist.h"
 #include <curl/curl.h>
 
 #define DEBUG_HOSTLIST_CLIENT GNUNET_YES
@@ -727,15 +728,27 @@
     struct GNUNET_TIME_Relative latency,
     uint32_t distance)
 {
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Hostlist client recieved advertisement, checking message: 
%s\n");
   int size = ntohs (message->size);
+  int uri_size = size - sizeof ( struct GNUNET_HOSTLIST_ADV_Message );
   int type = ntohs (message->type);
+  char * uri = GNUNET_malloc ( uri_size );
+
   if ( type != GNUNET_MESSAGE_TYPE_HOSTLIST_ADVERTISEMENT)
     return GNUNET_NO;
-#if DEBUG_HOSTLIST_CLIENT
+
+  const struct GNUNET_HOSTLIST_ADV_Message * incoming = (const struct 
GNUNET_HOSTLIST_ADV_Message *) message;
+  //struct GNUNET_HOSTLIST_ADV_Message * msg = message;
+  memcpy ( uri, &incoming[1], uri_size );
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Hostlist client recieved advertisement uri: %s\n", uri);
+  #if DEBUG_HOSTLIST_CLIENT
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                  "Hostlist client recieved advertisement message, size %u, 
type %u\n",size,type);
+                  "Hostlist client recieved advertisement message, type %u, 
message size %u, headersize %u, uri length %u, uri: %s\n",type,size,sizeof( 
struct GNUNET_HOSTLIST_ADV_Message ),uri_size,uri);
 #endif
 
+
      return GNUNET_YES;
 }
 

Modified: gnunet/src/hostlist/hostlist-server.c
===================================================================
--- gnunet/src/hostlist/hostlist-server.c       2010-04-13 11:06:23 UTC (rev 
10894)
+++ gnunet/src/hostlist/hostlist-server.c       2010-04-13 12:14:08 UTC (rev 
10895)
@@ -105,6 +105,11 @@
 };
 
 /**
+ * Set if we are allowed to advertise our hostlist to others.
+ */
+static int advertising;
+
+/**
  * Task that will produce a new response object.
  */
 static void
@@ -478,7 +483,9 @@
   uri = strcat(uri, ":");
   uri = strcat(uri, port_s);
   uri = strcat(uri, "/");
-  strcpy(hostlist_uri,uri);
+  if ( length < 255);
+    strcpy(hostlist_uri,uri);
+
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Address to obtain hostlist: %s\n", 
hostlist_uri);
 
   if ( ( size + sizeof( struct GNUNET_HOSTLIST_ADV_Message )) > 
GNUNET_SERVER_MAX_MESSAGE_SIZE)
@@ -513,6 +520,9 @@
                  struct GNUNET_TIME_Relative latency,
                  uint32_t distance)
 {
+  if ( !advertising )
+    return;
+
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "A new peer connected to the server, preparing to send hostlist 
advertisement\n");
   /* create a new advertisement message */
@@ -639,10 +649,18 @@
                              struct GNUNET_STATISTICS_Handle *st,
                              struct GNUNET_CORE_Handle *co,
                              GNUNET_CORE_ConnectEventHandler *server_ch,
-                              GNUNET_CORE_DisconnectEventHandler *server_dh)
+                              GNUNET_CORE_DisconnectEventHandler *server_dh,
+                              int advertise)
 {
   unsigned long long port;
 
+  advertising = advertise;
+  if  ( !advertising )
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Advertising not enabled on this hostlist server\n");
+  else
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Advertising enabled on this hostlist server\n");
   sched = s;
   cfg = c;
   stats = st;

Modified: gnunet/src/hostlist/hostlist-server.h
===================================================================
--- gnunet/src/hostlist/hostlist-server.h       2010-04-13 11:06:23 UTC (rev 
10894)
+++ gnunet/src/hostlist/hostlist-server.h       2010-04-13 12:14:08 UTC (rev 
10895)
@@ -44,7 +44,8 @@
                              struct GNUNET_STATISTICS_Handle *st,
                              struct GNUNET_CORE_Handle *core,
                               GNUNET_CORE_ConnectEventHandler *server_ch,
-                             GNUNET_CORE_DisconnectEventHandler *server_dh);
+                             GNUNET_CORE_DisconnectEventHandler *server_dh,
+                             int advertise);
 
 
 /**

Modified: gnunet/src/hostlist/test_gnunet_daemon_hostlist_learning.c
===================================================================
--- gnunet/src/hostlist/test_gnunet_daemon_hostlist_learning.c  2010-04-13 
11:06:23 UTC (rev 10894)
+++ gnunet/src/hostlist/test_gnunet_daemon_hostlist_learning.c  2010-04-13 
12:14:08 UTC (rev 10895)
@@ -30,9 +30,6 @@
 
 #define START_ARM GNUNET_YES
 
-#define VERBOSE GNUNET_YES
-#define DEBUG GNUNET_YES
-
 /**
  * How long until we give up on transmitting the message?
  */





reply via email to

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