aboutsummaryrefslogtreecommitdiff
path: root/src/dht/gnunet-service-dht.c
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2010-08-10 16:24:53 +0000
committerNathan S. Evans <evans@in.tum.de>2010-08-10 16:24:53 +0000
commitcab00729856bdbe0c60f298a79b1f12aac2aee8b (patch)
tree14ea5bf0b19dca878e5f5aafcf69599e3e4726b7 /src/dht/gnunet-service-dht.c
parent0cd34604e5497edad8fa3a761ef626ad7168c90a (diff)
downloadgnunet-cab00729856bdbe0c60f298a79b1f12aac2aee8b.tar.gz
gnunet-cab00729856bdbe0c60f298a79b1f12aac2aee8b.zip
api change to allow client to set DHT malicious, still need to implement it on the dht driver side
Diffstat (limited to 'src/dht/gnunet-service-dht.c')
-rw-r--r--src/dht/gnunet-service-dht.c75
1 files changed, 75 insertions, 0 deletions
diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c
index 33c85c7d4..3f58088bd 100644
--- a/src/dht/gnunet-service-dht.c
+++ b/src/dht/gnunet-service-dht.c
@@ -2402,6 +2402,30 @@ find_active_client (struct GNUNET_SERVER_Client *client)
2402} 2402}
2403 2403
2404/** 2404/**
2405 * Task to send a malicious put message across the network.
2406 *
2407 * @param cls closure for this task
2408 * @param tc the context under which the task is running
2409 */
2410static void
2411malicious_put_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
2412{
2413 return;
2414}
2415
2416/**
2417 * Task to send a malicious put message across the network.
2418 *
2419 * @param cls closure for this task
2420 * @param tc the context under which the task is running
2421 */
2422static void
2423malicious_get_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
2424{
2425 return;
2426}
2427
2428/**
2405 * Task to send a find peer message for our own peer identifier 2429 * Task to send a find peer message for our own peer identifier
2406 * so that we can find the closest peers in the network to ourselves 2430 * so that we can find the closest peers in the network to ourselves
2407 * and attempt to connect to them. 2431 * and attempt to connect to them.
@@ -2500,6 +2524,56 @@ handle_dht_local_route_request (void *cls, struct GNUNET_SERVER_Client *client,
2500} 2524}
2501 2525
2502/** 2526/**
2527 * Handler for any locally received DHT control messages,
2528 * sets malicious flags mostly for now.
2529 *
2530 * @param cls closure for the service
2531 * @param client the client we received this message from
2532 * @param message the actual message received
2533 *
2534 */
2535static void
2536handle_dht_control_message (void *cls, struct GNUNET_SERVER_Client *client,
2537 const struct GNUNET_MessageHeader *message)
2538{
2539 const struct GNUNET_DHT_ControlMessage *dht_control_msg =
2540 (const struct GNUNET_DHT_ControlMessage *) message;
2541#if DEBUG_DHT
2542 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2543 "`%s:%s': Received `%s' request from client, command %d\n", my_short_id, "DHT",
2544 "CONTROL", ntohs(dht_control_msg->command));
2545#endif
2546
2547 switch (ntohs(dht_control_msg->command))
2548 {
2549 case GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_GET:
2550 if (ntohs(dht_control_msg->variable) > 0)
2551 malicious_get_frequency = ntohs(dht_control_msg->variable);
2552 if (malicious_getter != GNUNET_YES)
2553 GNUNET_SCHEDULER_add_now(sched, &malicious_get_task, NULL);
2554 malicious_getter = GNUNET_YES;
2555 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "%s:%s Initiating malicious GET behavior, frequency %d\n", my_short_id, "DHT", malicious_get_frequency);
2556 break;
2557 case GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_PUT:
2558 if (ntohs(dht_control_msg->variable) > 0)
2559 malicious_put_frequency = ntohs(dht_control_msg->variable);
2560 if (malicious_putter != GNUNET_YES)
2561 GNUNET_SCHEDULER_add_now(sched, &malicious_put_task, NULL);
2562 malicious_putter = GNUNET_YES;
2563 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "%s:%s Initiating malicious PUT behavior, frequency %d\n", my_short_id, "DHT", malicious_put_frequency);
2564 break;
2565 case GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_DROP:
2566 malicious_dropper = GNUNET_YES;
2567 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "%s:%s Initiating malicious DROP behavior\n", my_short_id, "DHT");
2568 break;
2569 default:
2570 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "%s:%s Unknown control command type `%d'!\n", ntohs(dht_control_msg->command));
2571 }
2572
2573 GNUNET_SERVER_receive_done (client, GNUNET_OK);
2574}
2575
2576/**
2503 * Handler for any generic DHT stop messages, calls the appropriate handler 2577 * Handler for any generic DHT stop messages, calls the appropriate handler
2504 * depending on message type (if processed locally) 2578 * depending on message type (if processed locally)
2505 * 2579 *
@@ -2759,6 +2833,7 @@ core_init (void *cls,
2759static struct GNUNET_SERVER_MessageHandler plugin_handlers[] = { 2833static struct GNUNET_SERVER_MessageHandler plugin_handlers[] = {
2760 {&handle_dht_local_route_request, NULL, GNUNET_MESSAGE_TYPE_DHT_LOCAL_ROUTE, 0}, 2834 {&handle_dht_local_route_request, NULL, GNUNET_MESSAGE_TYPE_DHT_LOCAL_ROUTE, 0},
2761 {&handle_dht_local_route_stop, NULL, GNUNET_MESSAGE_TYPE_DHT_LOCAL_ROUTE_STOP, 0}, 2835 {&handle_dht_local_route_stop, NULL, GNUNET_MESSAGE_TYPE_DHT_LOCAL_ROUTE_STOP, 0},
2836 {&handle_dht_control_message, NULL, GNUNET_MESSAGE_TYPE_DHT_CONTROL, 0},
2762 {NULL, NULL, 0, 0} 2837 {NULL, NULL, 0, 0}
2763}; 2838};
2764 2839