aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJulius Bünger <buenger@mytum.de>2015-03-26 11:44:56 +0000
committerJulius Bünger <buenger@mytum.de>2015-03-26 11:44:56 +0000
commit759216e0aac8de4949e34f056d4b304acc6877ed (patch)
tree676c7711282e612f144dca5d5527110c0200ff98 /src
parent5e11eb124cc16bc65d42a47076e13d3b0147b838 (diff)
downloadgnunet-759216e0aac8de4949e34f056d4b304acc6877ed.tar.gz
gnunet-759216e0aac8de4949e34f056d4b304acc6877ed.zip
-mal peer pull reply handling
Diffstat (limited to 'src')
-rw-r--r--src/rps/gnunet-service-rps.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index 9e3a1a6c8..45c6d8ec9 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -1445,6 +1445,9 @@ handle_peer_pull_reply (void *cls,
1445 struct PeerContext *sender_ctx; 1445 struct PeerContext *sender_ctx;
1446 struct PeerOutstandingOp out_op; 1446 struct PeerOutstandingOp out_op;
1447 uint32_t i; 1447 uint32_t i;
1448#ifdef ENABLE_MALICIOUS
1449 struct AttackedPeer *tmp_att_peer;
1450#endif /* ENABLE_MALICIOUS */
1448 1451
1449 /* Check for protocol violation */ 1452 /* Check for protocol violation */
1450 if (sizeof (struct GNUNET_RPS_P2P_PullReplyMessage) > ntohs (msg->size)) 1453 if (sizeof (struct GNUNET_RPS_P2P_PullReplyMessage) > ntohs (msg->size))
@@ -1478,11 +1481,36 @@ handle_peer_pull_reply (void *cls,
1478 return GNUNET_OK; 1481 return GNUNET_OK;
1479 } 1482 }
1480 1483
1484#ifdef ENABLE_MALICIOUS
1485 // We shouldn't even receive pull replies as we're not sending
1486 if (2 == mal_type)
1487 return GNUNET_OK;
1488#endif /* ENABLE_MALICIOUS */
1481 1489
1482 /* Do actual logic */ 1490 /* Do actual logic */
1483 peers = (struct GNUNET_PeerIdentity *) &msg[1]; 1491 peers = (struct GNUNET_PeerIdentity *) &msg[1];
1492
1484 for (i = 0 ; i < ntohl (in_msg->num_peers) ; i++) 1493 for (i = 0 ; i < ntohl (in_msg->num_peers) ; i++)
1485 { 1494 {
1495 #ifdef ENABLE_MALICIOUS
1496 if (1 == mal_type)
1497 {
1498 // TODO check if we sent a request and this was the first reply
1499 if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (att_peer_set,
1500 &peers[i])
1501 && GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (mal_peer_set,
1502 &peers[i]))
1503 {
1504 tmp_att_peer = GNUNET_new (struct AttackedPeer);
1505 tmp_att_peer->peer_id = peers[i];
1506 GNUNET_CONTAINER_DLL_insert (att_peers_head,
1507 att_peers_tail,
1508 tmp_att_peer);
1509 add_peer_array_to_set (&peers[i], 1, att_peer_set);
1510 }
1511 continue;
1512 }
1513 #endif /* ENABLE_MALICIOUS */
1486 peer_ctx = get_peer_ctx (peer_map, &peers[i]); 1514 peer_ctx = get_peer_ctx (peer_map, &peers[i]);
1487 if (GNUNET_YES == get_peer_flag (peer_ctx, VALID) 1515 if (GNUNET_YES == get_peer_flag (peer_ctx, VALID)
1488 || NULL != peer_ctx->send_channel 1516 || NULL != peer_ctx->send_channel