diff options
Diffstat (limited to 'src/rps/rps_api.c')
-rw-r--r-- | src/rps/rps_api.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/rps/rps_api.c b/src/rps/rps_api.c index 3afff58e6..c46851fe9 100644 --- a/src/rps/rps_api.c +++ b/src/rps/rps_api.c | |||
@@ -311,7 +311,7 @@ GNUNET_RPS_seed_ids (struct GNUNET_RPS_Handle *h, | |||
311 | GNUNET_RPS_act_malicious (struct GNUNET_RPS_Handle *h, | 311 | GNUNET_RPS_act_malicious (struct GNUNET_RPS_Handle *h, |
312 | uint32_t type, | 312 | uint32_t type, |
313 | uint32_t num_peers, | 313 | uint32_t num_peers, |
314 | const struct GNUNET_PeerIdentity *ids) | 314 | const struct GNUNET_PeerIdentity *peer_ids) |
315 | { | 315 | { |
316 | size_t size_needed; | 316 | size_t size_needed; |
317 | uint32_t num_peers_max; | 317 | uint32_t num_peers_max; |
@@ -329,9 +329,9 @@ GNUNET_RPS_act_malicious (struct GNUNET_RPS_Handle *h, | |||
329 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 329 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
330 | "%u. peer: %s\n", | 330 | "%u. peer: %s\n", |
331 | i, | 331 | i, |
332 | GNUNET_i2s (&ids[i])); | 332 | GNUNET_i2s (&peer_ids[i])); |
333 | 333 | ||
334 | /* The actual size the message occupies */ | 334 | /* The actual size the message would occupy */ |
335 | size_needed = sizeof (struct GNUNET_RPS_CS_SeedMessage) + | 335 | size_needed = sizeof (struct GNUNET_RPS_CS_SeedMessage) + |
336 | num_peers * sizeof (struct GNUNET_PeerIdentity); | 336 | num_peers * sizeof (struct GNUNET_PeerIdentity); |
337 | /* The number of peers that fit in one message together with | 337 | /* The number of peers that fit in one message together with |
@@ -339,7 +339,7 @@ GNUNET_RPS_act_malicious (struct GNUNET_RPS_Handle *h, | |||
339 | num_peers_max = (GNUNET_SERVER_MAX_MESSAGE_SIZE - | 339 | num_peers_max = (GNUNET_SERVER_MAX_MESSAGE_SIZE - |
340 | sizeof (struct GNUNET_RPS_CS_SeedMessage)) / | 340 | sizeof (struct GNUNET_RPS_CS_SeedMessage)) / |
341 | sizeof (struct GNUNET_PeerIdentity); | 341 | sizeof (struct GNUNET_PeerIdentity); |
342 | tmp_peer_pointer = ids; | 342 | tmp_peer_pointer = peer_ids; |
343 | 343 | ||
344 | while (GNUNET_SERVER_MAX_MESSAGE_SIZE < size_needed) | 344 | while (GNUNET_SERVER_MAX_MESSAGE_SIZE < size_needed) |
345 | { | 345 | { |
@@ -351,14 +351,19 @@ GNUNET_RPS_act_malicious (struct GNUNET_RPS_Handle *h, | |||
351 | GNUNET_MESSAGE_TYPE_RPS_ACT_MALICIOUS); | 351 | GNUNET_MESSAGE_TYPE_RPS_ACT_MALICIOUS); |
352 | msg->type = htonl (type); | 352 | msg->type = htonl (type); |
353 | msg->num_peers = htonl (num_peers_max); | 353 | msg->num_peers = htonl (num_peers_max); |
354 | memcpy (&msg[1], tmp_peer_pointer, num_peers_max * sizeof (struct GNUNET_PeerIdentity)); | 354 | if (2 == type) |
355 | msg->attacked_peer = peer_ids[num_peers]; | ||
356 | memcpy (&msg[1], | ||
357 | tmp_peer_pointer, | ||
358 | num_peers_max * sizeof (struct GNUNET_PeerIdentity)); | ||
359 | |||
355 | GNUNET_MQ_send (h->mq, ev); | 360 | GNUNET_MQ_send (h->mq, ev); |
356 | 361 | ||
357 | num_peers -= num_peers_max; | 362 | num_peers -= num_peers_max; |
358 | size_needed = sizeof (struct GNUNET_RPS_CS_SeedMessage) + | 363 | size_needed = sizeof (struct GNUNET_RPS_CS_SeedMessage) + |
359 | num_peers * sizeof (struct GNUNET_PeerIdentity); | 364 | num_peers * sizeof (struct GNUNET_PeerIdentity); |
360 | /* Set pointer to beginning of next block of num_peers_max peers */ | 365 | /* Set pointer to beginning of next block of num_peers_max peers */ |
361 | tmp_peer_pointer = &ids[num_peers_max]; | 366 | tmp_peer_pointer = &peer_ids[num_peers_max]; |
362 | } | 367 | } |
363 | 368 | ||
364 | ev = GNUNET_MQ_msg_extra (msg, | 369 | ev = GNUNET_MQ_msg_extra (msg, |
@@ -366,6 +371,8 @@ GNUNET_RPS_act_malicious (struct GNUNET_RPS_Handle *h, | |||
366 | GNUNET_MESSAGE_TYPE_RPS_ACT_MALICIOUS); | 371 | GNUNET_MESSAGE_TYPE_RPS_ACT_MALICIOUS); |
367 | msg->type = htonl (type); | 372 | msg->type = htonl (type); |
368 | msg->num_peers = htonl (num_peers); | 373 | msg->num_peers = htonl (num_peers); |
374 | if (2 == type) | ||
375 | msg->attacked_peer = peer_ids[num_peers]; | ||
369 | memcpy (&msg[1], tmp_peer_pointer, num_peers * sizeof (struct GNUNET_PeerIdentity)); | 376 | memcpy (&msg[1], tmp_peer_pointer, num_peers * sizeof (struct GNUNET_PeerIdentity)); |
370 | 377 | ||
371 | GNUNET_MQ_send (h->mq, ev); | 378 | GNUNET_MQ_send (h->mq, ev); |