- update default values, eliminate obsolete ones
[oweals/gnunet.git] / src / dht / gnunet-service-xdht_clients.c
index 566e19ae431d4602b40a6e892f788632999ee220..59fbd6f17b43f74d7ad31e7dd2762bd41b5b1e9d 100644 (file)
 
 #define LOG(kind,...) GNUNET_log_from (kind, "dht-clients",__VA_ARGS__)
 
+#if ENABLE_MALICIOUS
+/**
+ * Should this peer act malicious?
+ */
+extern unsigned int malicious;
+#endif
+
 /**
  * Linked list of messages to send to clients.
  */
@@ -844,16 +851,8 @@ transmit_request (struct ClientQueryRecord *cqr)
        cqr->replication,
        cqr->seen_replies_count);
 
-  /* FIXME: Is it correct to pass your identity as default current_destination
-   * and current_source. also is it correct to copy your identity into a new
-   * address and then pass this address. address at which your identity is 
-   * stored should be const or else you may overwrite it and you lose your
-   * identity value.  */ 
-  
-  struct GNUNET_PeerIdentity my_identity;
-  my_identity = GDS_NEIGHBOURS_get_my_id ();
   GDS_NEIGHBOURS_send_get (&cqr->key, cqr->type, cqr->msg_options, 
-                           cqr->replication, my_identity, my_identity, NULL,
+                           cqr->replication, NULL, NULL , NULL,
                            0, 0, NULL);
   
   /* exponential back-off for retries.
@@ -951,13 +950,14 @@ handle_dht_local_put (void *cls, struct GNUNET_SERVER_Client *client,
                             &put_msg[1]);
  
   struct GNUNET_PeerIdentity my_identity =  GDS_NEIGHBOURS_get_my_id();
-  GDS_NEIGHBOURS_send_put (&put_msg->key, &put_msg[1],
-                           size - sizeof (struct GNUNET_DHT_ClientPutMessage),
+  GDS_NEIGHBOURS_send_put (&put_msg->key, 
                            ntohl (put_msg->type), ntohl (put_msg->options),
-                           ntohl (put_msg->desired_replication_level),
+                           ntohl (put_msg->desired_replication_level), NULL,
+                           NULL, NULL, 0, 0, NULL,
                            GNUNET_TIME_absolute_ntoh (put_msg->expiration),
-                           my_identity, my_identity, NULL, 0, 0, NULL);
-                           
+                           &put_msg[1],
+                           size - sizeof (struct GNUNET_DHT_ClientPutMessage));
+  
 
   GDS_CLIENTS_process_put (ntohl (put_msg->options),
                            ntohl (put_msg->type),
@@ -1052,12 +1052,6 @@ handle_dht_local_get (void *cls, struct GNUNET_SERVER_Client *client,
   if (GNUNET_SCHEDULER_NO_TASK != retry_task)
     GNUNET_SCHEDULER_cancel (retry_task);
   retry_task = GNUNET_SCHEDULER_add_now (&transmit_next_request_task, NULL);
-  /* perform local lookup 
-   * FIXME: Should we call it here or in neighbours file. And how to handle
-   * this case where we may get the data locally. You really need to rethink
-   * this design again. 
-  GDS_DATACACHE_handle_get (&get->key, cqr->type, cqr->xquery, xquery_size,
-                            NULL, 0); */
   GNUNET_SERVER_receive_done (client, GNUNET_OK);
 }
 
@@ -1316,6 +1310,25 @@ handle_dht_local_monitor_stop (void *cls, struct GNUNET_SERVER_Client *client,
 }
 
 
+#if ENABLE_MALICIOUS
+/**
+ * Handler for monitor stop messages
+ *
+ * @param cls closure for the service
+ * @param client the client we received this message from
+ * @param message the actual message received
+ *
+ */
+static void
+handle_dht_act_malicious (void *cls, struct GNUNET_SERVER_Client *client,
+                          const struct GNUNET_MessageHeader *message)
+{
+  /* FIXME: parse message and set malicious */
+  malicious = 1;
+}
+#endif
+
+
 /**
  * Functions with this signature are called whenever a client
  * is disconnected on the network level.
@@ -1391,6 +1404,11 @@ GDS_CLIENTS_init (struct GNUNET_SERVER_Handle *server)
      sizeof (struct GNUNET_DHT_MonitorStartStopMessage)},
     {&handle_dht_local_get_result_seen, NULL,
      GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET_RESULTS_KNOWN, 0},
+    #if ENABLE_MALICIOUS
+    {&handle_dht_act_malicious, NULL,
+     GNUNET_MESSAGE_TYPE_DHT_ACT_MALICIOUS,
+     sizeof (struct GNUNET_DHT_ActMaliciousMessage)},
+    #endif
     {NULL, NULL, 0, 0}
   };
   forward_map = GNUNET_CONTAINER_multihashmap_create (1024, GNUNET_NO);