diff options
author | Julius Bünger <buenger@mytum.de> | 2015-01-23 11:53:41 +0000 |
---|---|---|
committer | Julius Bünger <buenger@mytum.de> | 2015-01-23 11:53:41 +0000 |
commit | 1de46adfda8e188a2c8dcca5f2c519c4a98c55a7 (patch) | |
tree | 55e03afae45ec0c52d71e84fa4c59d5c0cd30754 /src/rps/rps_api.c | |
parent | 551d39765954e420daa93c87263a25802e8f9ef0 (diff) | |
download | gnunet-1de46adfda8e188a2c8dcca5f2c519c4a98c55a7.tar.gz gnunet-1de46adfda8e188a2c8dcca5f2c519c4a98c55a7.zip |
taking care of send msg size in the api
Diffstat (limited to 'src/rps/rps_api.c')
-rw-r--r-- | src/rps/rps_api.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/rps/rps_api.c b/src/rps/rps_api.c index 13f488351..d7e3fc4ed 100644 --- a/src/rps/rps_api.c +++ b/src/rps/rps_api.c | |||
@@ -228,10 +228,29 @@ GNUNET_RPS_request_peers (struct GNUNET_RPS_Handle *h, uint32_t n, | |||
228 | GNUNET_RPS_seed_ids (struct GNUNET_RPS_Handle *h, uint64_t n, | 228 | GNUNET_RPS_seed_ids (struct GNUNET_RPS_Handle *h, uint64_t n, |
229 | const struct GNUNET_PeerIdentity * ids) | 229 | const struct GNUNET_PeerIdentity * ids) |
230 | { | 230 | { |
231 | uint32_t size_needed; | ||
232 | uint32_t tmp_num_peers; | ||
231 | struct GNUNET_MQ_Envelope *ev; | 233 | struct GNUNET_MQ_Envelope *ev; |
232 | struct GNUNET_RPS_CS_SeedMessage *msg; | 234 | struct GNUNET_RPS_CS_SeedMessage *msg; |
233 | 235 | ||
234 | // FIXME was not able to find MAX size we are allowed to send | 236 | size_needed = sizeof (struct GNUNET_RPS_CS_SeedMessage) + |
237 | n * sizeof (struct GNUNET_PeerIdentity); | ||
238 | |||
239 | while (GNUNET_SERVER_MAX_MESSAGE_SIZE < size_needed) | ||
240 | { | ||
241 | tmp_num_peers = (GNUNET_SERVER_MAX_MESSAGE_SIZE - | ||
242 | sizeof (struct GNUNET_RPS_CS_SeedMessage)) / | ||
243 | sizeof (struct GNUNET_PeerIdentity); | ||
244 | n -= tmp_num_peers; | ||
245 | size_needed = sizeof (struct GNUNET_RPS_CS_SeedMessage) + | ||
246 | n * sizeof (struct GNUNET_PeerIdentity); | ||
247 | |||
248 | ev = GNUNET_MQ_msg_extra (msg, tmp_num_peers * sizeof (struct GNUNET_PeerIdentity), | ||
249 | GNUNET_MESSAGE_TYPE_RPS_CS_SEED); | ||
250 | msg->num_peers = GNUNET_htonll (tmp_num_peers); | ||
251 | memcpy (&msg[1], ids, tmp_num_peers * sizeof (struct GNUNET_PeerIdentity)); | ||
252 | GNUNET_MQ_send (h->mq, ev); | ||
253 | } | ||
235 | 254 | ||
236 | ev = GNUNET_MQ_msg_extra (msg, n * sizeof (struct GNUNET_PeerIdentity), | 255 | ev = GNUNET_MQ_msg_extra (msg, n * sizeof (struct GNUNET_PeerIdentity), |
237 | GNUNET_MESSAGE_TYPE_RPS_CS_SEED); | 256 | GNUNET_MESSAGE_TYPE_RPS_CS_SEED); |