Start implementation of some functions.
[oweals/gnunet.git] / src / dht / gnunet-service-dht_neighbours.c
index 4915302d4e68270945841afb3a623dcb2abb2886..caa226dad60d8c17a7340fa2f481d50527c96014 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2009-2013 Christian Grothoff (and other contributing authors)
+     Copyright (C) 2009-2013 Christian Grothoff (and other contributing authors)
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -24,7 +24,6 @@
  * @author Christian Grothoff
  * @author Nathan Evans
  */
-
 #include "platform.h"
 #include "gnunet_util_lib.h"
 #include "gnunet_block_lib.h"
@@ -335,7 +334,7 @@ struct PeerInfo
   /**
    * Task for scheduling preference updates
    */
-  GNUNET_SCHEDULER_TaskIdentifier preference_task;
+  struct GNUNET_SCHEDULER_Task * preference_task;
 
   /**
    * What is the identity of the peer?
@@ -423,7 +422,7 @@ static unsigned int bucket_size = DEFAULT_BUCKET_SIZE;
 /**
  * Task that sends FIND PEER requests.
  */
-static GNUNET_SCHEDULER_TaskIdentifier find_peer_task;
+static struct GNUNET_SCHEDULER_Task * find_peer_task;
 
 /**
  * Identity of this peer.
@@ -486,7 +485,7 @@ update_core_preference (void *cls,
   int bucket;
   struct GNUNET_HashCode phash;
 
-  peer->preference_task = GNUNET_SCHEDULER_NO_TASK;
+  peer->preference_task = NULL;
   if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
     return;
   GNUNET_CRYPTO_hash (&peer->id,
@@ -587,7 +586,7 @@ send_find_peer_message (void *cls,
   struct BloomConstructorContext bcc;
   struct GNUNET_CONTAINER_BloomFilter *peer_bf;
 
-  find_peer_task = GNUNET_SCHEDULER_NO_TASK;
+  find_peer_task = NULL;
   if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
     return;
   if (newly_found_peers > bucket_size)
@@ -730,10 +729,10 @@ handle_core_disconnect (void *cls,
                  GNUNET_CONTAINER_multipeermap_remove (all_known_peers,
                                                        peer,
                                                        to_remove));
-  if (GNUNET_SCHEDULER_NO_TASK != to_remove->preference_task)
+  if (NULL != to_remove->preference_task)
   {
     GNUNET_SCHEDULER_cancel (to_remove->preference_task);
-    to_remove->preference_task = GNUNET_SCHEDULER_NO_TASK;
+    to_remove->preference_task = NULL;
   }
   GNUNET_CRYPTO_hash (peer,
                      sizeof (struct GNUNET_PeerIdentity),
@@ -789,6 +788,11 @@ core_transmit_notify (void *cls, size_t size, void *buf)
   while ((NULL != (pending = peer->head)) &&
          (0 == GNUNET_TIME_absolute_get_remaining (pending->timeout).rel_value_us))
   {
+    GNUNET_STATISTICS_update (GDS_stats,
+                              gettext_noop
+                              ("# Messages dropped (CORE timeout)"),
+                              1,
+                              GNUNET_NO);
     peer->pending_count--;
     GNUNET_CONTAINER_DLL_remove (peer->head, peer->tail, pending);
     GNUNET_free (pending);
@@ -1302,12 +1306,12 @@ GDS_NEIGHBOURS_handle_put (enum GNUNET_BLOCK_Type type,
   msize =
       put_path_length * sizeof (struct GNUNET_PeerIdentity) + data_size +
       sizeof (struct PeerPutMessage);
-  if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
+  if (msize >= GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE)
   {
     put_path_length = 0;
     msize = data_size + sizeof (struct PeerPutMessage);
   }
-  if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
+  if (msize >= GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE)
   {
     GNUNET_break (0);
     GNUNET_free (targets);
@@ -1704,6 +1708,7 @@ handle_dht_p2p_put (void *cls, const struct GNUNET_PeerIdentity *peer,
   {
     switch (GNUNET_BLOCK_evaluate (GDS_block_context,
                                    ntohl (put->type),
+                                   GNUNET_BLOCK_EO_NONE,
                                    NULL,    /* query */
                                    NULL, 0, /* bloom filer */
                                    NULL, 0, /* xquery */
@@ -1949,8 +1954,16 @@ handle_dht_p2p_get (void *cls,
         GNUNET_CONTAINER_bloomfilter_init (&xquery[xquery_size], reply_bf_size,
                                            GNUNET_CONSTANTS_BLOOMFILTER_K);
   eval =
-      GNUNET_BLOCK_evaluate (GDS_block_context, type, &get->key, &reply_bf,
-                             get->bf_mutator, xquery, xquery_size, NULL, 0);
+      GNUNET_BLOCK_evaluate (GDS_block_context,
+                             type,
+                             GNUNET_BLOCK_EO_NONE,
+                             &get->key,
+                             &reply_bf,
+                             get->bf_mutator,
+                             xquery,
+                             xquery_size,
+                             NULL,
+                             0);
   if (eval != GNUNET_BLOCK_EVALUATION_REQUEST_VALID)
   {
     /* request invalid or block type not supported */
@@ -2236,10 +2249,10 @@ GDS_NEIGHBOURS_done ()
   GNUNET_assert (0 == GNUNET_CONTAINER_multipeermap_size (all_known_peers));
   GNUNET_CONTAINER_multipeermap_destroy (all_known_peers);
   all_known_peers = NULL;
-  if (GNUNET_SCHEDULER_NO_TASK != find_peer_task)
+  if (NULL != find_peer_task)
   {
     GNUNET_SCHEDULER_cancel (find_peer_task);
-    find_peer_task = GNUNET_SCHEDULER_NO_TASK;
+    find_peer_task = NULL;
   }
 }