aboutsummaryrefslogtreecommitdiff
path: root/src/psyc
diff options
context:
space:
mode:
authorGabor X Toth <*@tg-x.net>2016-01-26 20:37:11 +0000
committerGabor X Toth <*@tg-x.net>2016-01-26 20:37:11 +0000
commit23f117ce9756b2fb898bba5cb3a1f638333c23d9 (patch)
treee15291bd36f696802fca5c379ad09e3ea3920d76 /src/psyc
parent0841876fb932574a6c9ebaf2adbb64f1ffc06899 (diff)
downloadgnunet-23f117ce9756b2fb898bba5cb3a1f638333c23d9.tar.gz
gnunet-23f117ce9756b2fb898bba5cb3a1f638333c23d9.zip
social: relay msgs; psyc: slicer api; multicast: reset fragment_offset
Diffstat (limited to 'src/psyc')
-rw-r--r--src/psyc/gnunet-service-psyc.c29
-rw-r--r--src/psyc/test_psyc.c54
2 files changed, 43 insertions, 40 deletions
diff --git a/src/psyc/gnunet-service-psyc.c b/src/psyc/gnunet-service-psyc.c
index 75a94bcb7..38ec10e4d 100644
--- a/src/psyc/gnunet-service-psyc.c
+++ b/src/psyc/gnunet-service-psyc.c
@@ -1030,9 +1030,12 @@ client_send_mcast_req (struct Master *mst,
1030 pmsg->fragment_offset = req->fragment_offset; 1030 pmsg->fragment_offset = req->fragment_offset;
1031 pmsg->flags = htonl (GNUNET_PSYC_MESSAGE_REQUEST); 1031 pmsg->flags = htonl (GNUNET_PSYC_MESSAGE_REQUEST);
1032 pmsg->slave_pub_key = req->member_pub_key; 1032 pmsg->slave_pub_key = req->member_pub_key;
1033
1034 memcpy (&pmsg[1], &req[1], size - sizeof (*req)); 1033 memcpy (&pmsg[1], &req[1], size - sizeof (*req));
1034
1035 client_send_msg (chn, &pmsg->header); 1035 client_send_msg (chn, &pmsg->header);
1036
1037 /* FIXME: save req to PSYCstore so that it can be resent later to clients */
1038
1036 GNUNET_free (pmsg); 1039 GNUNET_free (pmsg);
1037} 1040}
1038 1041
@@ -2057,12 +2060,14 @@ slave_transmit_notify (void *cls, size_t *data_size, void *data)
2057static void 2060static void
2058master_transmit_message (struct Master *mst) 2061master_transmit_message (struct Master *mst)
2059{ 2062{
2060 if (NULL == mst->chn.tmit_head) 2063 struct Channel *chn = &mst->chn;
2064 struct TransmitMessage *tmit_msg = chn->tmit_head;
2065 if (NULL == tmit_msg)
2061 return; 2066 return;
2062 if (NULL == mst->tmit_handle) 2067 if (NULL == mst->tmit_handle)
2063 { 2068 {
2064 mst->tmit_handle 2069 mst->tmit_handle
2065 = GNUNET_MULTICAST_origin_to_all (mst->origin, mst->chn.tmit_head->id, 2070 = GNUNET_MULTICAST_origin_to_all (mst->origin, tmit_msg->id,
2066 mst->max_group_generation, 2071 mst->max_group_generation,
2067 master_transmit_notify, mst); 2072 master_transmit_notify, mst);
2068 } 2073 }
@@ -2167,12 +2172,18 @@ slave_queue_message (struct Slave *slv, struct TransmitMessage *tmit_msg)
2167/** 2172/**
2168 * Queue PSYC message parts for sending to multicast. 2173 * Queue PSYC message parts for sending to multicast.
2169 * 2174 *
2170 * @param chn Channel to send to. 2175 * @param chn
2171 * @param client Client the message originates from. 2176 * Channel to send to.
2172 * @param data_size Size of @a data. 2177 * @param client
2173 * @param data Concatenated message parts. 2178 * Client the message originates from.
2174 * @param first_ptype First message part type in @a data. 2179 * @param data_size
2175 * @param last_ptype Last message part type in @a data. 2180 * Size of @a data.
2181 * @param data
2182 * Concatenated message parts.
2183 * @param first_ptype
2184 * First message part type in @a data.
2185 * @param last_ptype
2186 * Last message part type in @a data.
2176 */ 2187 */
2177static struct TransmitMessage * 2188static struct TransmitMessage *
2178queue_message (struct Channel *chn, 2189queue_message (struct Channel *chn,
diff --git a/src/psyc/test_psyc.c b/src/psyc/test_psyc.c
index d0380b21b..4aae5e122 100644
--- a/src/psyc/test_psyc.c
+++ b/src/psyc/test_psyc.c
@@ -203,34 +203,29 @@ end ()
203 203
204 204
205void 205void
206master_message_cb (void *cls, uint64_t message_id, uint32_t flags, 206master_message_cb (void *cls, const struct GNUNET_PSYC_MessageHeader *msg)
207 const struct GNUNET_PSYC_MessageHeader *msg)
208{ 207{
209 GNUNET_assert (NULL != msg); 208 GNUNET_assert (NULL != msg);
210 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 209 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
211 "Test #%d: Master got PSYC message fragment of size %u " 210 "Test #%d: Master got PSYC message fragment of size %u "
212 "belonging to message ID %" PRIu64 " with flags %x\n", 211 "belonging to message ID %" PRIu64 " with flags %x\n",
213 test, ntohs (msg->header.size), message_id, flags); 212 test, ntohs (msg->header.size),
213 GNUNET_ntohll (msg->message_id), ntohl (msg->flags));
214 // FIXME 214 // FIXME
215} 215}
216 216
217 217
218void 218void
219master_message_part_cb (void *cls, 219master_message_part_cb (void *cls, const struct GNUNET_PSYC_MessageHeader *msg,
220 const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key, 220 const struct GNUNET_MessageHeader *pmsg)
221 uint64_t message_id, uint32_t flags, uint64_t data_offset,
222 const struct GNUNET_MessageHeader *msg)
223{ 221{
224 if (NULL == msg) 222 GNUNET_assert (NULL != msg && NULL != pmsg);
225 {
226 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
227 "Test #%d: Error while master is receiving part of message #%" PRIu64 ".\n",
228 test, message_id);
229 return;
230 }
231 223
232 uint16_t type = ntohs (msg->type); 224 uint64_t message_id = GNUNET_ntohll (msg->message_id);
233 uint16_t size = ntohs (msg->size); 225 uint32_t flags = ntohl (msg->flags);
226
227 uint16_t type = ntohs (pmsg->type);
228 uint16_t size = ntohs (pmsg->size);
234 229
235 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 230 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
236 "Test #%d: Master got message part of type %u and size %u " 231 "Test #%d: Master got message part of type %u and size %u "
@@ -278,33 +273,30 @@ master_message_part_cb (void *cls,
278 273
279 274
280void 275void
281slave_message_cb (void *cls, uint64_t message_id, uint32_t flags, 276slave_message_cb (void *cls, const struct GNUNET_PSYC_MessageHeader *msg)
282 const struct GNUNET_PSYC_MessageHeader *msg)
283{ 277{
278 GNUNET_assert (NULL != msg);
284 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 279 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
285 "Test #%d: Slave got PSYC message fragment of size %u " 280 "Test #%d: Slave got PSYC message fragment of size %u "
286 "belonging to message ID %" PRIu64 " with flags %x\n", 281 "belonging to message ID %" PRIu64 " with flags %x\n",
287 test, ntohs (msg->header.size), message_id, flags); 282 test, ntohs (msg->header.size),
283 GNUNET_ntohll (msg->message_id), ntohl (msg->flags));
288 // FIXME 284 // FIXME
289} 285}
290 286
291 287
292void 288void
293slave_message_part_cb (void *cls, 289slave_message_part_cb (void *cls,
294 const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key, 290 const struct GNUNET_PSYC_MessageHeader *msg,
295 uint64_t message_id, uint32_t flags, uint64_t data_offset, 291 const struct GNUNET_MessageHeader *pmsg)
296 const struct GNUNET_MessageHeader *msg)
297{ 292{
298 if (NULL == msg) 293 GNUNET_assert (NULL != msg && NULL != pmsg);
299 { 294
300 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 295 uint64_t message_id = GNUNET_ntohll (msg->message_id);
301 "Test #%d: Error while slave is receiving part of message #%" PRIu64 ".\n", 296 uint32_t flags = ntohl (msg->flags);
302 test, message_id);
303 return;
304 }
305 297
306 uint16_t type = ntohs (msg->type); 298 uint16_t type = ntohs (pmsg->type);
307 uint16_t size = ntohs (msg->size); 299 uint16_t size = ntohs (pmsg->size);
308 300
309 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 301 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
310 "Test #%d: Slave got message part of type %u and size %u " 302 "Test #%d: Slave got message part of type %u and size %u "