summaryrefslogtreecommitdiff
path: root/src/rps/rps_api.c
diff options
context:
space:
mode:
authorJulius Bünger <buenger@mytum.de>2015-08-02 14:48:28 +0000
committerJulius Bünger <buenger@mytum.de>2015-08-02 14:48:28 +0000
commitbae0066688e7571b4abdebfb914dba6df0578a6b (patch)
tree4ee2b2171170d169ff8cd55cfe5ad9adf640d5d2 /src/rps/rps_api.c
parent847e9575ed85eadb979bc416afec7cf898cf00d1 (diff)
cancellation of request and according test improvements
Diffstat (limited to 'src/rps/rps_api.c')
-rw-r--r--src/rps/rps_api.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/rps/rps_api.c b/src/rps/rps_api.c
index 854ea25cf..42cec9761 100644
--- a/src/rps/rps_api.c
+++ b/src/rps/rps_api.c
@@ -339,7 +339,8 @@ GNUNET_RPS_seed_ids (struct GNUNET_RPS_Handle *h,
GNUNET_RPS_act_malicious (struct GNUNET_RPS_Handle *h,
uint32_t type,
uint32_t num_peers,
- const struct GNUNET_PeerIdentity *peer_ids)
+ const struct GNUNET_PeerIdentity *peer_ids,
+ const struct GNUNET_PeerIdentity *target_peer)
{
size_t size_needed;
uint32_t num_peers_max;
@@ -379,8 +380,8 @@ GNUNET_RPS_act_malicious (struct GNUNET_RPS_Handle *h,
GNUNET_MESSAGE_TYPE_RPS_ACT_MALICIOUS);
msg->type = htonl (type);
msg->num_peers = htonl (num_peers_max);
- if (2 == type
- || 3 == type)
+ if ( (2 == type) ||
+ (3 == type) )
msg->attacked_peer = peer_ids[num_peers];
memcpy (&msg[1],
tmp_peer_pointer,
@@ -400,9 +401,9 @@ GNUNET_RPS_act_malicious (struct GNUNET_RPS_Handle *h,
GNUNET_MESSAGE_TYPE_RPS_ACT_MALICIOUS);
msg->type = htonl (type);
msg->num_peers = htonl (num_peers);
- if (2 == type
- || 3 == type)
- msg->attacked_peer = peer_ids[num_peers];
+ if ( (2 == type) ||
+ (3 == type) )
+ msg->attacked_peer = *target_peer;
memcpy (&msg[1], tmp_peer_pointer, num_peers * sizeof (struct GNUNET_PeerIdentity));
GNUNET_MQ_send (h->mq, ev);
@@ -418,7 +419,17 @@ GNUNET_RPS_act_malicious (struct GNUNET_RPS_Handle *h,
void
GNUNET_RPS_request_cancel (struct GNUNET_RPS_Request_Handle *rh)
{
- // TODO
+ struct GNUNET_MQ_Envelope *ev;
+ struct GNUNET_RPS_CS_RequestCancelMessage*msg;
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Cancelling request with id %" PRIu32 "\n",
+ rh->id);
+
+ GNUNET_array_append (req_handlers, req_handlers_size, *rh);
+ ev = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_RPS_CS_REQUEST_CANCEL);
+ msg->id = htonl (rh->id);
+ GNUNET_MQ_send (rh->rps_handle->mq, ev);
}