More API function tests...
[oweals/gnunet.git] / src / dht / gnunet-service-wdht_clients.c
index 6d5c477adfc21f3b2ec26336f30b897b5dadad89..7ad0d2904959674746267fae7db5c0ac2de5f92e 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     Copyright (C) 2009, 2010, 2011 GNUnet e.V.
+     Copyright (C) 2009, 2010, 2011, 2016 GNUnet e.V.
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -31,7 +31,7 @@
 #include "gnunet_statistics_service.h"
 #include "gnunet-service-wdht.h"
 #include "gnunet-service-wdht_clients.h"
-#include "gnunet-service-wdht_datacache.h"
+#include "gnunet-service-dht_datacache.h"
 #include "gnunet-service-wdht_neighbours.h"
 #include "dht.h"
 
@@ -64,7 +64,7 @@ struct PendingMessage
   /**
    * Actual message to be sent, allocated at the end of the struct:
    * // msg = (cast) &pm[1];
-   * // memcpy (&pm[1], data, len);
+   * // GNUNET_memcpy (&pm[1], data, len);
    */
   const struct GNUNET_MessageHeader *msg;
 
@@ -316,7 +316,7 @@ send_reply_to_client (void *cls, size_t size, void *buf)
   {
     GNUNET_CONTAINER_DLL_remove (client->pending_head, client->pending_tail,
                                  reply);
-    memcpy (&cbuf[off], reply->msg, msize);
+    GNUNET_memcpy (&cbuf[off], reply->msg, msize);
     GNUNET_free (reply);
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Transmitting %u bytes to client %p\n",
@@ -580,7 +580,7 @@ forward_reply (void *cls,
     /* two clients waiting for same reply, must copy for queueing */
     pm = GNUNET_malloc (sizeof (struct PendingMessage) +
                         ntohs (frc->pm->msg->size));
-    memcpy (pm, frc->pm,
+    GNUNET_memcpy (pm, frc->pm,
             sizeof (struct PendingMessage) + ntohs (frc->pm->msg->size));
     pm->next = pm->prev = NULL;
     pm->msg = (struct GNUNET_MessageHeader *) &pm[1];
@@ -653,7 +653,8 @@ GDS_CLIENTS_handle_reply (struct GNUNET_TIME_Absolute expiration,
                 _("Could not pass reply to client, message too big!\n"));
     return;
   }
-  DEBUG("reply FOR DATA_SIZE = %lu\n",msize);
+  DEBUG ("reply FOR DATA_SIZE = %u\n",
+        (unsigned int) msize);
   pm = GNUNET_malloc (msize + sizeof (struct PendingMessage));
   reply = (struct GNUNET_DHT_ClientResultMessage *) &pm[1];
   pm->msg = &reply->header;
@@ -666,17 +667,23 @@ GDS_CLIENTS_handle_reply (struct GNUNET_TIME_Absolute expiration,
   reply->expiration = GNUNET_TIME_absolute_hton (expiration);
   reply->key = *key;
   paths = (struct GNUNET_PeerIdentity *) &reply[1];
-  memcpy (paths, put_path,
-          sizeof (struct GNUNET_PeerIdentity) * put_path_length);
-  memcpy (&paths[put_path_length], get_path,
-          sizeof (struct GNUNET_PeerIdentity) * get_path_length);
-  memcpy (&paths[get_path_length + put_path_length], data, data_size);
+  GNUNET_memcpy (paths,
+                put_path,
+                sizeof (struct GNUNET_PeerIdentity) * put_path_length);
+  GNUNET_memcpy (&paths[put_path_length],
+                get_path,
+                sizeof (struct GNUNET_PeerIdentity) * get_path_length);
+  GNUNET_memcpy (&paths[get_path_length + put_path_length],
+                data,
+                data_size);
   frc.do_copy = GNUNET_NO;
   frc.pm = pm;
   frc.data = data;
   frc.data_size = data_size;
   frc.type = type;
-  GNUNET_CONTAINER_multihashmap_get_multiple (forward_map, key, &forward_reply,
+  GNUNET_CONTAINER_multihashmap_get_multiple (forward_map,
+                                             key,
+                                             &forward_reply,
                                               &frc);
   if (GNUNET_NO == frc.do_copy)
   {
@@ -750,10 +757,10 @@ GDS_CLIENTS_process_get (uint32_t options,
       mmsg->hop_count = htonl(hop_count);
       mmsg->desired_replication_level = htonl(desired_replication_level);
       mmsg->get_path_length = htonl(path_length);
-      memcpy (&mmsg->key, key, sizeof (struct GNUNET_HashCode));
+      GNUNET_memcpy (&mmsg->key, key, sizeof (struct GNUNET_HashCode));
       msg_path = (struct GNUNET_PeerIdentity *) &mmsg[1];
       if (path_length > 0)
-        memcpy (msg_path, path,
+        GNUNET_memcpy (msg_path, path,
                 path_length * sizeof (struct GNUNET_PeerIdentity));
       add_pending_message (m->client, pm);
     }
@@ -832,13 +839,13 @@ GDS_CLIENTS_process_put (uint32_t options,
       msg_path = (struct GNUNET_PeerIdentity *) &mmsg[1];
       if (path_length > 0)
       {
-        memcpy (msg_path, path,
+        GNUNET_memcpy (msg_path, path,
                 path_length * sizeof (struct GNUNET_PeerIdentity));
       }
       mmsg->expiration_time = GNUNET_TIME_absolute_hton(exp);
-      memcpy (&mmsg->key, key, sizeof (struct GNUNET_HashCode));
+      GNUNET_memcpy (&mmsg->key, key, sizeof (struct GNUNET_HashCode));
       if (size > 0)
-        memcpy (&msg_path[path_length], data, size);
+        GNUNET_memcpy (&msg_path[path_length], data, size);
       add_pending_message (m->client, pm);
     }
   }
@@ -1015,7 +1022,7 @@ handle_dht_local_get (void *cls,
   cqr->key = get->key;
   cqr->client = find_active_client (client);
   cqr->xquery = (void *) &cqr[1];
-  memcpy (&cqr[1], xquery, xquery_size);
+  GNUNET_memcpy (&cqr[1], xquery, xquery_size);
   cqr->hnode = GNUNET_CONTAINER_heap_insert (retry_heap, cqr, 0);
   cqr->retry_frequency = GNUNET_TIME_UNIT_SECONDS;
   cqr->retry_time = GNUNET_TIME_absolute_get ();
@@ -1141,7 +1148,7 @@ handle_dht_local_get_result_seen (void *cls,
   GNUNET_array_grow (cqr->seen_replies,
                     cqr->seen_replies_count,
                     cqr->seen_replies_count + hash_count);
-  memcpy (&cqr->seen_replies[old_count],
+  GNUNET_memcpy (&cqr->seen_replies[old_count],
          hc,
          sizeof (struct GNUNET_HashCode) * hash_count);
 }
@@ -1253,7 +1260,7 @@ handle_dht_local_monitor (void *cls,
   else
   {
     r->key = GNUNET_new (struct GNUNET_HashCode);
-    memcpy (r->key, &msg->key, sizeof (struct GNUNET_HashCode));
+    GNUNET_memcpy (r->key, &msg->key, sizeof (struct GNUNET_HashCode));
   }
   GNUNET_CONTAINER_DLL_insert (monitor_head, monitor_tail, r);
   GNUNET_SERVER_receive_done (client, GNUNET_OK);