aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2014-06-06 12:01:32 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2014-06-06 12:01:32 +0000
commit62e273beeae391a44615e350e48f4ee40f2eab7a (patch)
tree9137da71304165f148468c3135d91a4da9bff967
parentbdfda4dd17faf721d82bfee411dcaf2777012a9f (diff)
downloadgnunet-62e273beeae391a44615e350e48f4ee40f2eab7a.tar.gz
gnunet-62e273beeae391a44615e350e48f4ee40f2eab7a.zip
Enable (X)DHT service to be compiled with malicious code.
-rw-r--r--configure.ac17
-rw-r--r--src/dht/dht.h18
-rw-r--r--src/dht/gnunet-service-xdht.c7
-rw-r--r--src/dht/gnunet-service-xdht_clients.c31
-rw-r--r--src/include/gnunet_dht_service.h13
-rw-r--r--src/include/gnunet_protocols.h110
6 files changed, 149 insertions, 47 deletions
diff --git a/configure.ac b/configure.ac
index 7a488dd6e..3c315afe6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1209,6 +1209,23 @@ AC_ARG_ENABLE([experimental],
1209AC_MSG_RESULT($enable_experimental) 1209AC_MSG_RESULT($enable_experimental)
1210AM_CONDITIONAL([HAVE_EXPERIMENTAL], [test "x$enable_experimental" = "xyes"]) 1210AM_CONDITIONAL([HAVE_EXPERIMENTAL], [test "x$enable_experimental" = "xyes"])
1211 1211
1212# should malicious code be compiled (should only be used for testing)?
1213AC_MSG_CHECKING(whether to compile malicious code)
1214AC_ARG_ENABLE([malicious],
1215 [AS_HELP_STRING([--enable-malicious], [enable compiling malicious code])],
1216 [if test "x$enableval" = "xno"
1217 then
1218 malicious=0
1219 else
1220 malicious=1
1221 fi],
1222 [malicious=0
1223 enable_malicious=no])
1224AC_MSG_RESULT($enable_malicious)
1225AM_CONDITIONAL([ENABLE_MALICIOUS], [$malicious])
1226AC_DEFINE_UNQUOTED([ENABLE_MALICIOUS], [$malicious],
1227 [enable compilation of malicious code])
1228
1212# should services be started by default when a peer starts? Some services may 1229# should services be started by default when a peer starts? Some services may
1213# choose to never start by default and it is upto the service/module developer to 1230# choose to never start by default and it is upto the service/module developer to
1214# decide it by having "AUTOSTART = NO" instead of "AUTOSTART = @AUTOSTART" in 1231# decide it by having "AUTOSTART = NO" instead of "AUTOSTART = @AUTOSTART" in
diff --git a/src/dht/dht.h b/src/dht/dht.h
index 86fbc16bb..f630e5a33 100644
--- a/src/dht/dht.h
+++ b/src/dht/dht.h
@@ -441,6 +441,24 @@ struct GNUNET_DHT_MonitorGetRespMessage
441 441
442}; 442};
443 443
444#if ENABLE_MALICIOUS
445/**
446 * Message to turn the service malicious
447 */
448struct GNUNET_DHT_ActMaliciousMessage
449{
450 /**
451 * Type: #GNUNET_MESSAGE_TYPE_ACT_MALICIOUS
452 */
453 struct GNUNET_MessageHeader header;
454
455 /**
456 * Type of malicious behaviour expected; 0 turning peer benign
457 */
458 uint32_t action;
459};
460#endif
461
444GNUNET_NETWORK_STRUCT_END 462GNUNET_NETWORK_STRUCT_END
445 463
446#endif 464#endif
diff --git a/src/dht/gnunet-service-xdht.c b/src/dht/gnunet-service-xdht.c
index 432fea354..40aa71a0f 100644
--- a/src/dht/gnunet-service-xdht.c
+++ b/src/dht/gnunet-service-xdht.c
@@ -77,6 +77,13 @@ static struct GNUNET_TRANSPORT_GetHelloHandle *ghh;
77 */ 77 */
78struct GNUNET_TIME_Relative hello_expiration; 78struct GNUNET_TIME_Relative hello_expiration;
79 79
80#if ENABLE_MALICIOUS
81/**
82 * Should this peer act malicious?
83 */
84unsigned int malicious;
85#endif
86
80 87
81/** 88/**
82 * Receive the HELLO from transport service, free current and replace 89 * Receive the HELLO from transport service, free current and replace
diff --git a/src/dht/gnunet-service-xdht_clients.c b/src/dht/gnunet-service-xdht_clients.c
index 0621f8ea8..59fbd6f17 100644
--- a/src/dht/gnunet-service-xdht_clients.c
+++ b/src/dht/gnunet-service-xdht_clients.c
@@ -43,6 +43,13 @@
43 43
44#define LOG(kind,...) GNUNET_log_from (kind, "dht-clients",__VA_ARGS__) 44#define LOG(kind,...) GNUNET_log_from (kind, "dht-clients",__VA_ARGS__)
45 45
46#if ENABLE_MALICIOUS
47/**
48 * Should this peer act malicious?
49 */
50extern unsigned int malicious;
51#endif
52
46/** 53/**
47 * Linked list of messages to send to clients. 54 * Linked list of messages to send to clients.
48 */ 55 */
@@ -1303,6 +1310,25 @@ handle_dht_local_monitor_stop (void *cls, struct GNUNET_SERVER_Client *client,
1303} 1310}
1304 1311
1305 1312
1313#if ENABLE_MALICIOUS
1314/**
1315 * Handler for monitor stop messages
1316 *
1317 * @param cls closure for the service
1318 * @param client the client we received this message from
1319 * @param message the actual message received
1320 *
1321 */
1322static void
1323handle_dht_act_malicious (void *cls, struct GNUNET_SERVER_Client *client,
1324 const struct GNUNET_MessageHeader *message)
1325{
1326 /* FIXME: parse message and set malicious */
1327 malicious = 1;
1328}
1329#endif
1330
1331
1306/** 1332/**
1307 * Functions with this signature are called whenever a client 1333 * Functions with this signature are called whenever a client
1308 * is disconnected on the network level. 1334 * is disconnected on the network level.
@@ -1378,6 +1404,11 @@ GDS_CLIENTS_init (struct GNUNET_SERVER_Handle *server)
1378 sizeof (struct GNUNET_DHT_MonitorStartStopMessage)}, 1404 sizeof (struct GNUNET_DHT_MonitorStartStopMessage)},
1379 {&handle_dht_local_get_result_seen, NULL, 1405 {&handle_dht_local_get_result_seen, NULL,
1380 GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET_RESULTS_KNOWN, 0}, 1406 GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET_RESULTS_KNOWN, 0},
1407 #if ENABLE_MALICIOUS
1408 {&handle_dht_act_malicious, NULL,
1409 GNUNET_MESSAGE_TYPE_DHT_ACT_MALICIOUS,
1410 sizeof (struct GNUNET_DHT_ActMaliciousMessage)},
1411 #endif
1381 {NULL, NULL, 0, 0} 1412 {NULL, NULL, 0, 0}
1382 }; 1413 };
1383 forward_map = GNUNET_CONTAINER_multihashmap_create (1024, GNUNET_NO); 1414 forward_map = GNUNET_CONTAINER_multihashmap_create (1024, GNUNET_NO);
diff --git a/src/include/gnunet_dht_service.h b/src/include/gnunet_dht_service.h
index 33c6551db..31d66ccf0 100644
--- a/src/include/gnunet_dht_service.h
+++ b/src/include/gnunet_dht_service.h
@@ -391,6 +391,19 @@ void
391GNUNET_DHT_monitor_stop (struct GNUNET_DHT_MonitorHandle *handle); 391GNUNET_DHT_monitor_stop (struct GNUNET_DHT_MonitorHandle *handle);
392 392
393 393
394#if ENABLE_MALICIOUS
395/**
396 * Turn the DHT service to act malicious depending on @a flag
397 *
398 * @param handle the DHT handle
399 * @param action 1 to make the service malicious; 0 to make it benign
400 FIXME: perhaps make this an enum of known malicious behaviors?
401 */
402void
403GNUNET_DHT_malicious (struct GNUNET_DHT_Handle *handle, unsigned int action);
404#endif
405
406
394#if 0 /* keep Emacsens' auto-indent happy */ 407#if 0 /* keep Emacsens' auto-indent happy */
395{ 408{
396#endif 409#endif
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h
index bd54062f1..d329c6da8 100644
--- a/src/include/gnunet_protocols.h
+++ b/src/include/gnunet_protocols.h
@@ -611,54 +611,9 @@ extern "C"
611#define GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET_RESULTS_KNOWN 156 611#define GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET_RESULTS_KNOWN 156
612 612
613/** 613/**
614 * Trail setup request is received by a peer. 614 * Further X-VINE DHT messages continued from 880
615 */
616#define GNUNET_MESSAGE_TYPE_DHT_P2P_TRAIL_SETUP 157
617
618/**
619 * Trail to a particular peer is returned to this peer.
620 */
621#define GNUNET_MESSAGE_TYPE_DHT_P2P_TRAIL_SETUP_RESULT 158
622
623/**
624 * Verify if your immediate successor is still your immediate successor.
625 */
626#define GNUNET_MESSAGE_TYPE_DHT_P2P_VERIFY_SUCCESSOR 159
627
628/**
629 * Notify your new immediate successor that you are its new predecessor.
630 */
631#define GNUNET_MESSAGE_TYPE_DHT_P2P_NOTIFY_NEW_SUCCESSOR 160
632
633/**
634 * Message which contains the immediate predecessor of requested successor
635 */
636#define GNUNET_MESSAGE_TYPE_DHT_P2P_VERIFY_SUCCESSOR_RESULT 161
637
638/**
639 * Message which contains the get result.
640 */ 615 */
641#define GNUNET_MESSAGE_TYPE_DHT_P2P_GET_RESULT 162
642 616
643/**
644 * Trail Rejection Message.
645 */
646#define GNUNET_MESSAGE_TYPE_DHT_P2P_TRAIL_REJECTION 163
647
648/**
649 * Trail Tear down Message.
650 */
651#define GNUNET_MESSAGE_TYPE_DHT_P2P_TRAIL_TEARDOWN 164
652
653/**
654 * Routing table add message.
655 */
656#define GNUNET_MESSAGE_TYPE_DHT_P2P_ADD_TRAIL 165
657
658/**
659 * Trail compression message.
660 */
661#define GNUNET_MESSAGE_TYPE_DHT_P2P_TRAIL_COMPRESSION 166
662/******************************************************************************* 617/*******************************************************************************
663 * HOSTLIST message types 618 * HOSTLIST message types
664 ******************************************************************************/ 619 ******************************************************************************/
@@ -2537,11 +2492,72 @@ extern "C"
2537/** C->S->P: decision about a join request */ 2492/** C->S->P: decision about a join request */
2538#define GNUNET_MESSAGE_TYPE_SOCIAL_JOIN_DECISION 848 2493#define GNUNET_MESSAGE_TYPE_SOCIAL_JOIN_DECISION 848
2539 2494
2495/*******************************************************************************
2496 * X-VINE DHT messages
2497 ******************************************************************************/
2498
2499/**
2500 * Trail setup request is received by a peer.
2501 */
2502#define GNUNET_MESSAGE_TYPE_DHT_P2P_TRAIL_SETUP 880
2503
2504/**
2505 * Trail to a particular peer is returned to this peer.
2506 */
2507#define GNUNET_MESSAGE_TYPE_DHT_P2P_TRAIL_SETUP_RESULT 881
2540 2508
2541/** 2509/**
2542 * Next available: 880 2510 * Verify if your immediate successor is still your immediate successor.
2543 */ 2511 */
2512#define GNUNET_MESSAGE_TYPE_DHT_P2P_VERIFY_SUCCESSOR 882
2544 2513
2514/**
2515 * Notify your new immediate successor that you are its new predecessor.
2516 */
2517#define GNUNET_MESSAGE_TYPE_DHT_P2P_NOTIFY_NEW_SUCCESSOR 883
2518
2519/**
2520 * Message which contains the immediate predecessor of requested successor
2521 */
2522#define GNUNET_MESSAGE_TYPE_DHT_P2P_VERIFY_SUCCESSOR_RESULT 884
2523
2524/**
2525 * Message which contains the get result.
2526 */
2527#define GNUNET_MESSAGE_TYPE_DHT_P2P_GET_RESULT 885
2528
2529/**
2530 * Trail Rejection Message.
2531 */
2532#define GNUNET_MESSAGE_TYPE_DHT_P2P_TRAIL_REJECTION 886
2533
2534/**
2535 * Trail Tear down Message.
2536 */
2537#define GNUNET_MESSAGE_TYPE_DHT_P2P_TRAIL_TEARDOWN 887
2538
2539/**
2540 * Routing table add message.
2541 */
2542#define GNUNET_MESSAGE_TYPE_DHT_P2P_ADD_TRAIL 888
2543
2544/**
2545 * Trail compression message.
2546 */
2547#define GNUNET_MESSAGE_TYPE_DHT_P2P_TRAIL_COMPRESSION 889
2548
2549#if ENABLE_MALICIOUS
2550/**
2551 * Turn X-VINE DHT service malicious
2552 */
2553#define GNUNET_MESSAGE_TYPE_DHT_ACT_MALICIOUS 890
2554#endif
2555
2556/*******************************************************************************/
2557
2558/**
2559 * Next available: 900
2560 */
2545 2561
2546/** 2562/**
2547 * Type used to match 'all' message types. 2563 * Type used to match 'all' message types.