aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--src/rps/gnunet-service-rps.c22
-rw-r--r--src/rps/rps.h16
-rw-r--r--src/rps/rps_api.c8
-rw-r--r--src/rps/test_rps.conf3
-rw-r--r--src/rps/test_rps_malicious_1.c5
6 files changed, 32 insertions, 23 deletions
diff --git a/.gitignore b/.gitignore
index 9755bb9a7..1f0941569 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1004,6 +1004,7 @@
1004# /src/rps/ 1004# /src/rps/
1005/src/rps/rps.conf 1005/src/rps/rps.conf
1006/src/rps/test_rps_multipeer 1006/src/rps/test_rps_multipeer
1007/src/rps/test_rps_malicious*
1007/src/rps/Makefile.in 1008/src/rps/Makefile.in
1008/src/rps/Makefile 1009/src/rps/Makefile
1009/src/rps/.deps 1010/src/rps/.deps
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index 923540db0..4e9f795c3 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -379,7 +379,7 @@ static uint32_t num_mal_peers;
379/** 379/**
380 * If type is 2 this is the attacked peer 380 * If type is 2 this is the attacked peer
381 */ 381 */
382struct struct GNUNET_PeerIdentity attacked_peer; 382static struct GNUNET_PeerIdentity attacked_peer;
383#endif /* ENABLE_MALICIOUS */ 383#endif /* ENABLE_MALICIOUS */
384 384
385 385
@@ -1057,7 +1057,7 @@ handle_client_request (void *cls,
1057 msg = (struct GNUNET_RPS_CS_RequestMessage *) message; 1057 msg = (struct GNUNET_RPS_CS_RequestMessage *) message;
1058 1058
1059 num_peers = ntohl (msg->num_peers); 1059 num_peers = ntohl (msg->num_peers);
1060 size_needed = sizeof (struct GNUNET_RPS_CS_ReplyMessage) + 1060 size_needed = sizeof (struct GNUNET_RPS_CS_RequestMessage) +
1061 num_peers * sizeof (struct GNUNET_PeerIdentity); 1061 num_peers * sizeof (struct GNUNET_PeerIdentity);
1062 1062
1063 if (GNUNET_SERVER_MAX_MESSAGE_SIZE < size_needed) 1063 if (GNUNET_SERVER_MAX_MESSAGE_SIZE < size_needed)
@@ -1303,7 +1303,7 @@ handle_peer_pull_reply (void *cls,
1303 || NULL != peer_ctx->recv_channel) 1303 || NULL != peer_ctx->recv_channel)
1304 { 1304 {
1305 if (GNUNET_NO == in_arr (pull_list, pull_list_size, &peers[i]) 1305 if (GNUNET_NO == in_arr (pull_list, pull_list_size, &peers[i])
1306 && GNUNET_CRYPTO_cmp_peer_identity (&own_identity, &peers[i])) 1306 && 0 != GNUNET_CRYPTO_cmp_peer_identity (&own_identity, &peers[i]))
1307 GNUNET_array_append (pull_list, pull_list_size, peers[i]); 1307 GNUNET_array_append (pull_list, pull_list_size, peers[i]);
1308 } 1308 }
1309 else if (GNUNET_NO == insert_in_pull_list_scheduled (peer_ctx)) 1309 else if (GNUNET_NO == insert_in_pull_list_scheduled (peer_ctx))
@@ -1339,12 +1339,13 @@ handle_peer_act_malicious (void *cls,
1339 void **channel_ctx, 1339 void **channel_ctx,
1340 const struct GNUNET_MessageHeader *msg) 1340 const struct GNUNET_MessageHeader *msg)
1341{ 1341{
1342 struct GNUNET_RPS_CS_ActMaliciousMessage *in_msg;
1343 struct GNUNET_PeerIdentity *sender;
1344 struct PeerContext *sender_ctx;
1342 struct GNUNET_PeerIdentity *peers; 1345 struct GNUNET_PeerIdentity *peers;
1343 1346
1344 LOG (GNUNET_ERROR_TYPE_DEBUG, "PULL REPLY received\n");
1345
1346 /* Check for protocol violation */ 1347 /* Check for protocol violation */
1347 if (sizeof (struct GNUNET_RPS_P2P_PullReplyMessage) > ntohs (msg->size)) 1348 if (sizeof (struct GNUNET_RPS_CS_ActMaliciousMessage) > ntohs (msg->size))
1348 { 1349 {
1349 GNUNET_break_op (0); 1350 GNUNET_break_op (0);
1350 return GNUNET_SYSERR; 1351 return GNUNET_SYSERR;
@@ -1375,11 +1376,16 @@ handle_peer_act_malicious (void *cls,
1375 return GNUNET_OK; 1376 return GNUNET_OK;
1376 } 1377 }
1377 1378
1379
1378 /* Do actual logic */ 1380 /* Do actual logic */
1379 peers = (struct GNUNET_PeerIdentity *) &msg[1]; 1381 peers = (struct GNUNET_PeerIdentity *) &msg[1];
1380 num_peers = ntohl (in_msg->num_peers); 1382 num_mal_peers = ntohl (in_msg->num_peers);
1381 mal_type = ntohl (in_msg->type); 1383 mal_type = ntohl (in_msg->type);
1382 1384
1385 LOG (GNUNET_ERROR_TYPE_DEBUG,
1386 "Now acting malicious type %" PRIX32 "\n",
1387 mal_type);
1388
1383 if (1 == mal_type) 1389 if (1 == mal_type)
1384 { /* Try to maximise representation */ 1390 { /* Try to maximise representation */
1385 num_mal_peers = ntohl (in_msg->num_peers); 1391 num_mal_peers = ntohl (in_msg->num_peers);
@@ -1395,6 +1401,8 @@ handle_peer_act_malicious (void *cls,
1395 memcpy (mal_peers, peers, num_mal_peers); 1401 memcpy (mal_peers, peers, num_mal_peers);
1396 attacked_peer = peers[num_mal_peers]; 1402 attacked_peer = peers[num_mal_peers];
1397 } 1403 }
1404
1405 return GNUNET_OK;
1398} 1406}
1399#endif /* ENABLE_MALICIOUS */ 1407#endif /* ENABLE_MALICIOUS */
1400 1408
diff --git a/src/rps/rps.h b/src/rps/rps.h
index eace8d5f1..0fbd2fb60 100644
--- a/src/rps/rps.h
+++ b/src/rps/rps.h
@@ -24,6 +24,7 @@
24 */ 24 */
25 25
26#include "gnunet_rps_service.h" 26#include "gnunet_rps_service.h"
27//#define ENABLE_MALICIOUS 1
27 28
28/** 29/**
29 * Mesh port used by RPS. 30 * Mesh port used by RPS.
@@ -72,15 +73,14 @@ struct GNUNET_RPS_CS_RequestMessage
72 struct GNUNET_MessageHeader header; 73 struct GNUNET_MessageHeader header;
73 74
74 /** 75 /**
75 * Number of random peer requested
76 */
77 uint32_t num_peers GNUNET_PACKED;
78
79 /**
80 * Identifyer of the message. 76 * Identifyer of the message.
81 */ 77 */
82 uint64_t n GNUNET_PACKED; 78 uint64_t n GNUNET_PACKED;
83 79
80 /**
81 * Number of random peer requested
82 */
83 uint32_t num_peers GNUNET_PACKED;
84}; 84};
85 85
86/** 86/**
@@ -101,7 +101,7 @@ struct GNUNET_RPS_CS_ReplyMessage
101 /** 101 /**
102 * Number of random peer replied 102 * Number of random peer replied
103 */ 103 */
104 uint64_t num_peers GNUNET_PACKED; 104 uint32_t num_peers GNUNET_PACKED;
105 105
106 /* Followed by num_peers * GNUNET_PeerIdentity */ 106 /* Followed by num_peers * GNUNET_PeerIdentity */
107}; 107};
@@ -119,7 +119,7 @@ struct GNUNET_RPS_CS_SeedMessage
119 /** 119 /**
120 * Number of peers 120 * Number of peers
121 */ 121 */
122 uint64_t num_peers GNUNET_PACKED; 122 uint32_t num_peers GNUNET_PACKED;
123 123
124 /* Followed by num_peers * GNUNET_PeerIdentity */ 124 /* Followed by num_peers * GNUNET_PeerIdentity */
125}; 125};
@@ -147,7 +147,7 @@ struct GNUNET_RPS_CS_ActMaliciousMessage
147 /** 147 /**
148 * Number of peers 148 * Number of peers
149 */ 149 */
150 uint64_t num_peers GNUNET_PACKED; 150 uint32_t num_peers GNUNET_PACKED;
151 151
152 /* Followed by num_peers * GNUNET_PeerIdentity */ 152 /* Followed by num_peers * GNUNET_PeerIdentity */
153}; 153};
diff --git a/src/rps/rps_api.c b/src/rps/rps_api.c
index 30f0a75c5..91612c2f7 100644
--- a/src/rps/rps_api.c
+++ b/src/rps/rps_api.c
@@ -128,18 +128,14 @@ handle_reply (void *cls,
128 const struct GNUNET_MessageHeader *message) 128 const struct GNUNET_MessageHeader *message)
129{ 129{
130 struct GNUNET_RPS_CS_ReplyMessage *msg; 130 struct GNUNET_RPS_CS_ReplyMessage *msg;
131 //struct cb_cls_pack *pack;
132 //struct GNUNET_RPS_Handle *h;
133 struct GNUNET_PeerIdentity *peers; 131 struct GNUNET_PeerIdentity *peers;
134 struct GNUNET_RPS_Request_Handle *rh; 132 struct GNUNET_RPS_Request_Handle *rh;
135 133
136 /* Give the peers back */ 134 /* Give the peers back */
137 msg = (struct GNUNET_RPS_CS_ReplyMessage *) message; 135 msg = (struct GNUNET_RPS_CS_ReplyMessage *) message;
138 //pack = (struct cb_cls_pack *) cls;
139 //h = (struct GNUNET_RPS_Handle *) cls;
140 peers = (struct GNUNET_PeerIdentity *) &msg[1]; 136 peers = (struct GNUNET_PeerIdentity *) &msg[1];
141 rh = &req_handlers[msg->n]; 137 rh = &req_handlers[msg->n];
142 rh->ready_cb((rh)->ready_cb_cls, msg->num_peers, peers); 138 rh->ready_cb((rh)->ready_cb_cls, msg->num_peers, peers); // FIXME? ntohl ()
143 139
144 /* Disconnect */ 140 /* Disconnect */
145 //GNUNET_CLIENT_disconnect(pack->service_conn); 141 //GNUNET_CLIENT_disconnect(pack->service_conn);
@@ -270,7 +266,7 @@ GNUNET_RPS_seed_ids (struct GNUNET_RPS_Handle *h,
270 { 266 {
271 ev = GNUNET_MQ_msg_extra (msg, num_peers_max * sizeof (struct GNUNET_PeerIdentity), 267 ev = GNUNET_MQ_msg_extra (msg, num_peers_max * sizeof (struct GNUNET_PeerIdentity),
272 GNUNET_MESSAGE_TYPE_RPS_CS_SEED); 268 GNUNET_MESSAGE_TYPE_RPS_CS_SEED);
273 msg->num_peers = ntohl (num_peers_max); 269 msg->num_peers = htonl (num_peers_max);
274 memcpy (&msg[1], tmp_peer_pointer, num_peers_max * sizeof (struct GNUNET_PeerIdentity)); 270 memcpy (&msg[1], tmp_peer_pointer, num_peers_max * sizeof (struct GNUNET_PeerIdentity));
275 GNUNET_MQ_send (h->mq, ev); 271 GNUNET_MQ_send (h->mq, ev);
276 272
diff --git a/src/rps/test_rps.conf b/src/rps/test_rps.conf
index 9db6711ea..45f62133a 100644
--- a/src/rps/test_rps.conf
+++ b/src/rps/test_rps.conf
@@ -23,7 +23,8 @@ HOSTNAME = localhost
23OPERATION_TIMEOUT = 60 s 23OPERATION_TIMEOUT = 60 s
24 24
25MAX_PARALLEL_TOPOLOGY_CONFIG_OPERATIONS = 1 25MAX_PARALLEL_TOPOLOGY_CONFIG_OPERATIONS = 1
26OVERLAY_TOPOLOGY = CLIQUE 26#OVERLAY_TOPOLOGY = CLIQUE
27OVERLAY_TOPOLOGY = SMALL_WORLD
27SCALE_FREE_TOPOLOGY_CAP = 28SCALE_FREE_TOPOLOGY_CAP =
28 29
29OVERLAY_RANDOM_LINKS = 5 30OVERLAY_RANDOM_LINKS = 5
diff --git a/src/rps/test_rps_malicious_1.c b/src/rps/test_rps_malicious_1.c
index 304e46973..a30607d87 100644
--- a/src/rps/test_rps_malicious_1.c
+++ b/src/rps/test_rps_malicious_1.c
@@ -242,8 +242,11 @@ rps_connect_adapter (void *cls,
242 h = GNUNET_RPS_connect (cfg); 242 h = GNUNET_RPS_connect (cfg);
243 243
244 #if ENABLE_MALICIOUS 244 #if ENABLE_MALICIOUS
245 GNUNET_assert (1 >= portion
246 && 0 < portion);
247
245 num_mal_peers = round (portion * NUM_PEERS); 248 num_mal_peers = round (portion * NUM_PEERS);
246 GNUNET_RPS_act_malicious (h, htonl (1), htonl (num_mal_peers), rps_peer_ids); 249 GNUNET_RPS_act_malicious (h, htonl (1), num_mal_peers, rps_peer_ids);
247 #endif /* ENABLE_MALICIOUS */ 250 #endif /* ENABLE_MALICIOUS */
248 251
249 return h; 252 return h;