aboutsummaryrefslogtreecommitdiff
path: root/src/dht/dht_api.c
diff options
context:
space:
mode:
authorSupriti Singh <supritisingh08@gmail.com>2014-08-13 13:58:41 +0000
committerSupriti Singh <supritisingh08@gmail.com>2014-08-13 13:58:41 +0000
commitc04d50e9c8c9375e2bba39c2de9fe864fdb17572 (patch)
treec6022596e8ac5e0969d5f937dc1ce96a733e341e /src/dht/dht_api.c
parent0f78836a920e83ff987d0a4f3490de892bfa0892 (diff)
downloadgnunet-c04d50e9c8c9375e2bba39c2de9fe864fdb17572.tar.gz
gnunet-c04d50e9c8c9375e2bba39c2de9fe864fdb17572.zip
Act Malicious service code
Diffstat (limited to 'src/dht/dht_api.c')
-rw-r--r--src/dht/dht_api.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/dht/dht_api.c b/src/dht/dht_api.c
index 0a35ba988..8aa7320f5 100644
--- a/src/dht/dht_api.c
+++ b/src/dht/dht_api.c
@@ -1496,4 +1496,44 @@ GNUNET_DHT_monitor_stop (struct GNUNET_DHT_MonitorHandle *handle)
1496 GNUNET_free (handle); 1496 GNUNET_free (handle);
1497} 1497}
1498 1498
1499
1500#if ENABLE_MALICIOUS
1501/**
1502 * Turn the DHT service to act malicious depending on @a flag
1503 *
1504 * @param handle the DHT handle
1505 * @param action 1 to make the service malicious; 0 to make it benign
1506 FIXME: perhaps make this an enum of known malicious behaviors?
1507 */
1508void
1509GNUNET_DHT_malicious (struct GNUNET_DHT_Handle *handle, unsigned int action)
1510{
1511 struct GNUNET_DHT_ActMaliciousMessage *amm;
1512 struct PendingMessage *pending;
1513 size_t msize;
1514
1515 msize = sizeof(struct GNUNET_DHT_ActMaliciousMessage);
1516 if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
1517 {
1518 GNUNET_break(0);
1519 return;
1520 }
1521
1522 pending = GNUNET_malloc (sizeof (struct PendingMessage) + msize);
1523 amm = (struct GNUNET_DHT_ActMaliciousMessage *)&pending[1];
1524 pending->msg = &amm->header;
1525 pending->handle = handle;
1526 pending->free_on_send = GNUNET_YES;
1527 amm->header.size = htons (msize);
1528 amm->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_ACT_MALICIOUS);
1529 amm->action = action;
1530
1531 GNUNET_CONTAINER_DLL_insert (handle->pending_head, handle->pending_tail,
1532 pending);
1533 pending->in_pending_queue = GNUNET_YES;
1534 process_pending_messages (handle);
1535}
1536#endif
1537
1538
1499/* end of dht_api.c */ 1539/* end of dht_api.c */