aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJulius Bünger <buenger@mytum.de>2015-04-03 11:28:18 +0000
committerJulius Bünger <buenger@mytum.de>2015-04-03 11:28:18 +0000
commit4c8b28dea0b03bd08c2bbc787394f4a06e383e4d (patch)
treeca377d7a55b574275d651bf3282751bf5361d35b /src
parent758969dea417b0b8cd0a0fb2823bf23186617a52 (diff)
downloadgnunet-4c8b28dea0b03bd08c2bbc787394f4a06e383e4d.tar.gz
gnunet-4c8b28dea0b03bd08c2bbc787394f4a06e383e4d.zip
mal type 3 (combined 1 + 2)
Diffstat (limited to 'src')
-rw-r--r--src/rps/gnunet-service-rps.c52
1 files changed, 45 insertions, 7 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index 7dd496a5d..34d4b5095 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -379,6 +379,7 @@ struct ReplyCls
379 * 0 Don't act malicious at all - Default 379 * 0 Don't act malicious at all - Default
380 * 1 Try to maximise representation 380 * 1 Try to maximise representation
381 * 2 Try to partition the network 381 * 2 Try to partition the network
382 * 3 Combined attack
382 */ 383 */
383uint32_t mal_type = 0; 384uint32_t mal_type = 0;
384 385
@@ -1422,7 +1423,8 @@ handle_peer_push (void *cls,
1422 1423
1423 tmp_att_peer = GNUNET_new (struct AttackedPeer); 1424 tmp_att_peer = GNUNET_new (struct AttackedPeer);
1424 memcpy (&tmp_att_peer->peer_id, peer, sizeof (struct GNUNET_PeerIdentity)); 1425 memcpy (&tmp_att_peer->peer_id, peer, sizeof (struct GNUNET_PeerIdentity));
1425 if (1 == mal_type) 1426 if (1 == mal_type
1427 || 3 == mal_type)
1426 { /* Try to maximise representation */ 1428 { /* Try to maximise representation */
1427 if (NULL == att_peer_set) 1429 if (NULL == att_peer_set)
1428 att_peer_set = GNUNET_CONTAINER_multipeermap_create (1, GNUNET_NO); 1430 att_peer_set = GNUNET_CONTAINER_multipeermap_create (1, GNUNET_NO);
@@ -1477,7 +1479,8 @@ handle_peer_pull_request (void *cls,
1477 // FIXME wait for cadet to change this function 1479 // FIXME wait for cadet to change this function
1478 1480
1479 #ifdef ENABLE_MALICIOUS 1481 #ifdef ENABLE_MALICIOUS
1480 if (1 == mal_type) 1482 if (1 == mal_type
1483 || 3 == mal_type)
1481 { /* Try to maximise representation */ 1484 { /* Try to maximise representation */
1482 send_pull_reply (peer, mal_peers, num_mal_peers); 1485 send_pull_reply (peer, mal_peers, num_mal_peers);
1483 return GNUNET_OK; 1486 return GNUNET_OK;
@@ -1579,9 +1582,10 @@ handle_peer_pull_reply (void *cls,
1579 i, 1582 i,
1580 GNUNET_i2s (&peers[i])); 1583 GNUNET_i2s (&peers[i]));
1581 1584
1582 #ifdef ENABLE_MALICIOUS 1585 #ifdef ENABLE_MALICIOUS
1583 if (1 == mal_type) 1586 if (1 == mal_type
1584 { 1587 || 3 == mal_type)
1588 { /* Add attacked peer to local list */
1585 // TODO check if we sent a request and this was the first reply 1589 // TODO check if we sent a request and this was the first reply
1586 if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (att_peer_set, 1590 if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (att_peer_set,
1587 &peers[i]) 1591 &peers[i])
@@ -1599,7 +1603,7 @@ handle_peer_pull_reply (void *cls,
1599 } 1603 }
1600 continue; 1604 continue;
1601 } 1605 }
1602 #endif /* ENABLE_MALICIOUS */ 1606 #endif /* ENABLE_MALICIOUS */
1603 peer_ctx = get_peer_ctx (peer_map, &peers[i]); 1607 peer_ctx = get_peer_ctx (peer_map, &peers[i]);
1604 if (GNUNET_YES == get_peer_flag (peer_ctx, VALID) 1608 if (GNUNET_YES == get_peer_flag (peer_ctx, VALID)
1605 || NULL != peer_ctx->send_channel 1609 || NULL != peer_ctx->send_channel
@@ -1793,7 +1797,8 @@ handle_client_act_malicious (void *cls,
1793 do_round_task = GNUNET_SCHEDULER_add_now (&do_mal_round, NULL); 1797 do_round_task = GNUNET_SCHEDULER_add_now (&do_mal_round, NULL);
1794 } 1798 }
1795 1799
1796 else if (2 == mal_type) 1800 else if (2 == mal_type
1801 || 3 == mal_type)
1797 { /* Try to partition the network */ 1802 { /* Try to partition the network */
1798 /* Add other malicious peers to those we already know */ 1803 /* Add other malicious peers to those we already know */
1799 num_mal_peers_sent = ntohl (in_msg->num_peers) - 1; 1804 num_mal_peers_sent = ntohl (in_msg->num_peers) - 1;
@@ -1898,6 +1903,39 @@ do_mal_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1898 } 1903 }
1899 1904
1900 1905
1906 if (3 == mal_type)
1907 { /* Combined attack */
1908
1909 /* The maximum of pushes we're going to send this round */
1910 num_pushes = min (min (push_limit,
1911 num_attacked_peers),
1912 GNUNET_CONSTANTS_MAX_CADET_MESSAGE_SIZE) - 1;
1913
1914 /* Send PUSHes to attacked peers */
1915 send_push (&attacked_peer);
1916
1917 for (i = 0 ; i < num_pushes ; i++)
1918 {
1919 if (att_peers_tail == att_peer_index)
1920 att_peer_index = att_peers_head;
1921 else
1922 att_peer_index = att_peer_index->next;
1923
1924 send_push (&att_peer_index->peer_id);
1925 }
1926
1927 /* Send PULLs to some peers to learn about additional peers to attack */
1928 for (i = 0 ; i < num_pushes * alpha ; i++)
1929 {
1930 if (att_peers_tail == tmp_att_peer)
1931 tmp_att_peer = att_peers_head;
1932 else
1933 att_peer_index = tmp_att_peer->next;
1934
1935 send_pull_request (&tmp_att_peer->peer_id);
1936 }
1937 }
1938
1901 /* Schedule next round */ 1939 /* Schedule next round */
1902 time_next_round = compute_rand_delay (round_interval, 2); 1940 time_next_round = compute_rand_delay (round_interval, 2);
1903 1941