diff options
author | Gabor X Toth <*@tg-x.net> | 2013-10-10 18:08:53 +0000 |
---|---|---|
committer | Gabor X Toth <*@tg-x.net> | 2013-10-10 18:08:53 +0000 |
commit | 1b5d4aba9d8bbcb62c93f96782e3567f6f79d0cb (patch) | |
tree | 3cd28bfee831af0417c2dcbb543c03481517ad00 /src/psyc/psyc_api.c | |
parent | 67a8e21eedb6d35fec76841d4a1a6b4b41b37879 (diff) | |
download | gnunet-1b5d4aba9d8bbcb62c93f96782e3567f6f79d0cb.tar.gz gnunet-1b5d4aba9d8bbcb62c93f96782e3567f6f79d0cb.zip |
PSYC: master msg transmission
Diffstat (limited to 'src/psyc/psyc_api.c')
-rw-r--r-- | src/psyc/psyc_api.c | 218 |
1 files changed, 166 insertions, 52 deletions
diff --git a/src/psyc/psyc_api.c b/src/psyc/psyc_api.c index abe7bb028..4178d920b 100644 --- a/src/psyc/psyc_api.c +++ b/src/psyc/psyc_api.c | |||
@@ -106,6 +106,28 @@ struct GNUNET_PSYC_Channel | |||
106 | * Are we currently transmitting a message? | 106 | * Are we currently transmitting a message? |
107 | */ | 107 | */ |
108 | int in_transmit; | 108 | int in_transmit; |
109 | |||
110 | /** | ||
111 | * Is this a master or slave channel? | ||
112 | */ | ||
113 | int is_master; | ||
114 | |||
115 | /** | ||
116 | * Buffer space available for transmitting the next data fragment. | ||
117 | */ | ||
118 | uint16_t tmit_buf_avail; | ||
119 | }; | ||
120 | |||
121 | |||
122 | /** | ||
123 | * Handle for a pending PSYC transmission operation. | ||
124 | */ | ||
125 | struct GNUNET_PSYC_MasterTransmitHandle | ||
126 | { | ||
127 | struct GNUNET_PSYC_Master *master; | ||
128 | GNUNET_PSYC_MasterTransmitNotify notify; | ||
129 | void *notify_cls; | ||
130 | enum GNUNET_PSYC_DataStatus status; | ||
109 | }; | 131 | }; |
110 | 132 | ||
111 | 133 | ||
@@ -116,6 +138,8 @@ struct GNUNET_PSYC_Master | |||
116 | { | 138 | { |
117 | struct GNUNET_PSYC_Channel ch; | 139 | struct GNUNET_PSYC_Channel ch; |
118 | 140 | ||
141 | struct GNUNET_PSYC_MasterTransmitHandle *tmit; | ||
142 | |||
119 | GNUNET_PSYC_MasterStartCallback start_cb; | 143 | GNUNET_PSYC_MasterStartCallback start_cb; |
120 | 144 | ||
121 | uint64_t max_message_id; | 145 | uint64_t max_message_id; |
@@ -146,19 +170,6 @@ struct GNUNET_PSYC_JoinHandle | |||
146 | /** | 170 | /** |
147 | * Handle for a pending PSYC transmission operation. | 171 | * Handle for a pending PSYC transmission operation. |
148 | */ | 172 | */ |
149 | struct GNUNET_PSYC_MasterTransmitHandle | ||
150 | { | ||
151 | struct GNUNET_PSYC_Master *master; | ||
152 | const struct GNUNET_ENV_Environment *env; | ||
153 | GNUNET_PSYC_MasterTransmitNotify notify; | ||
154 | void *notify_cls; | ||
155 | enum GNUNET_PSYC_MasterTransmitFlags flags; | ||
156 | }; | ||
157 | |||
158 | |||
159 | /** | ||
160 | * Handle for a pending PSYC transmission operation. | ||
161 | */ | ||
162 | struct GNUNET_PSYC_SlaveTransmitHandle | 173 | struct GNUNET_PSYC_SlaveTransmitHandle |
163 | { | 174 | { |
164 | 175 | ||
@@ -184,10 +195,10 @@ struct GNUNET_PSYC_StateQuery | |||
184 | 195 | ||
185 | 196 | ||
186 | /** | 197 | /** |
187 | * Try again to connect to the PSYCstore service. | 198 | * Try again to connect to the PSYC service. |
188 | * | 199 | * |
189 | * @param cls handle to the PSYCstore service. | 200 | * @param cls Handle to the PSYC service. |
190 | * @param tc scheduler context | 201 | * @param tc Scheduler context |
191 | */ | 202 | */ |
192 | static void | 203 | static void |
193 | reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | 204 | reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); |
@@ -215,7 +226,7 @@ reschedule_connect (struct GNUNET_PSYC_Channel *c) | |||
215 | } | 226 | } |
216 | c->in_receive = GNUNET_NO; | 227 | c->in_receive = GNUNET_NO; |
217 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 228 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
218 | "Scheduling task to reconnect to PSYCstore service in %s.\n", | 229 | "Scheduling task to reconnect to PSYC service in %s.\n", |
219 | GNUNET_STRINGS_relative_time_to_string (c->reconnect_delay, GNUNET_YES)); | 230 | GNUNET_STRINGS_relative_time_to_string (c->reconnect_delay, GNUNET_YES)); |
220 | c->reconnect_task = | 231 | c->reconnect_task = |
221 | GNUNET_SCHEDULER_add_delayed (c->reconnect_delay, &reconnect, c); | 232 | GNUNET_SCHEDULER_add_delayed (c->reconnect_delay, &reconnect, c); |
@@ -226,12 +237,56 @@ reschedule_connect (struct GNUNET_PSYC_Channel *c) | |||
226 | /** | 237 | /** |
227 | * Schedule transmission of the next message from our queue. | 238 | * Schedule transmission of the next message from our queue. |
228 | * | 239 | * |
229 | * @param h PSYCstore handle | 240 | * @param h PSYC handle |
230 | */ | 241 | */ |
231 | static void | 242 | static void |
232 | transmit_next (struct GNUNET_PSYC_Channel *c); | 243 | transmit_next (struct GNUNET_PSYC_Channel *c); |
233 | 244 | ||
234 | 245 | ||
246 | void | ||
247 | master_transmit_data (struct GNUNET_PSYC_Master *mst) | ||
248 | { | ||
249 | struct GNUNET_PSYC_Channel *ch = &mst->ch; | ||
250 | size_t data_size = ch->tmit_buf_avail; | ||
251 | struct GNUNET_PSYC_MessageData *pdata; | ||
252 | struct OperationHandle *op | ||
253 | = GNUNET_malloc (sizeof (*op) + sizeof (*pdata) + data_size); | ||
254 | pdata = (struct GNUNET_PSYC_MessageData *) &op[1]; | ||
255 | op->msg = (struct GNUNET_MessageHeader *) pdata; | ||
256 | pdata->header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_DATA); | ||
257 | |||
258 | switch (mst->tmit->notify (mst->tmit->notify_cls, &data_size, &pdata[1])) | ||
259 | { | ||
260 | case GNUNET_NO: | ||
261 | mst->tmit->status = GNUNET_PSYC_DATA_CONT; | ||
262 | break; | ||
263 | |||
264 | case GNUNET_YES: | ||
265 | mst->tmit->status = GNUNET_PSYC_DATA_END; | ||
266 | break; | ||
267 | |||
268 | default: | ||
269 | mst->tmit->status = GNUNET_PSYC_DATA_CANCEL; | ||
270 | data_size = 0; | ||
271 | LOG (GNUNET_ERROR_TYPE_ERROR, "MasterTransmitNotify returned error\n"); | ||
272 | } | ||
273 | |||
274 | if ((GNUNET_PSYC_DATA_CONT == mst->tmit->status && 0 == data_size)) | ||
275 | { | ||
276 | /* Transmission paused, nothing to send. */ | ||
277 | GNUNET_free (op); | ||
278 | } | ||
279 | else | ||
280 | { | ||
281 | GNUNET_assert (data_size <= ch->tmit_buf_avail); | ||
282 | pdata->header.size = htons (sizeof (*pdata) + data_size); | ||
283 | pdata->status = htons (mst->tmit->status); | ||
284 | GNUNET_CONTAINER_DLL_insert_tail (ch->transmit_head, ch->transmit_tail, op); | ||
285 | transmit_next (ch); | ||
286 | } | ||
287 | } | ||
288 | |||
289 | |||
235 | /** | 290 | /** |
236 | * Type of a function to call when we receive a message | 291 | * Type of a function to call when we receive a message |
237 | * from the service. | 292 | * from the service. |
@@ -253,8 +308,8 @@ message_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
253 | } | 308 | } |
254 | uint16_t size_eq = 0; | 309 | uint16_t size_eq = 0; |
255 | uint16_t size_min = 0; | 310 | uint16_t size_min = 0; |
256 | const uint16_t size = ntohs (msg->size); | 311 | uint16_t size = ntohs (msg->size); |
257 | const uint16_t type = ntohs (msg->type); | 312 | uint16_t type = ntohs (msg->type); |
258 | 313 | ||
259 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 314 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
260 | "Received message of type %d from PSYC service\n", type); | 315 | "Received message of type %d from PSYC service\n", type); |
@@ -265,6 +320,9 @@ message_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
265 | case GNUNET_MESSAGE_TYPE_PSYC_SLAVE_JOIN_ACK: | 320 | case GNUNET_MESSAGE_TYPE_PSYC_SLAVE_JOIN_ACK: |
266 | size_eq = sizeof (struct CountersResult); | 321 | size_eq = sizeof (struct CountersResult); |
267 | break; | 322 | break; |
323 | case GNUNET_MESSAGE_TYPE_PSYC_TRANSMIT_ACK: | ||
324 | size_eq = sizeof (struct TransmitAck); | ||
325 | break; | ||
268 | } | 326 | } |
269 | 327 | ||
270 | if (! ((0 < size_eq && size == size_eq) | 328 | if (! ((0 < size_eq && size == size_eq) |
@@ -276,6 +334,7 @@ message_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
276 | } | 334 | } |
277 | 335 | ||
278 | struct CountersResult *cres; | 336 | struct CountersResult *cres; |
337 | struct TransmitAck *tack; | ||
279 | 338 | ||
280 | switch (type) | 339 | switch (type) |
281 | { | 340 | { |
@@ -294,17 +353,39 @@ message_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
294 | mst->join_ack_cb (ch->cb_cls, mst->max_message_id); | 353 | mst->join_ack_cb (ch->cb_cls, mst->max_message_id); |
295 | #endif | 354 | #endif |
296 | break; | 355 | break; |
356 | |||
357 | case GNUNET_MESSAGE_TYPE_PSYC_TRANSMIT_ACK: | ||
358 | tack = (struct TransmitAck *) msg; | ||
359 | if (ch->is_master) | ||
360 | { | ||
361 | GNUNET_assert (NULL != mst->tmit); | ||
362 | if (GNUNET_PSYC_DATA_CONT != mst->tmit->status | ||
363 | || NULL == mst->tmit->notify) | ||
364 | { | ||
365 | GNUNET_free (mst->tmit); | ||
366 | mst->tmit = NULL; | ||
367 | } | ||
368 | else | ||
369 | { | ||
370 | ch->tmit_buf_avail = ntohs (tack->buf_avail); | ||
371 | master_transmit_data (mst); | ||
372 | } | ||
373 | } | ||
374 | else | ||
375 | { | ||
376 | /* TODO: slave */ | ||
377 | } | ||
378 | break; | ||
297 | } | 379 | } |
298 | 380 | ||
299 | GNUNET_CLIENT_receive (ch->client, &message_handler, ch, | 381 | GNUNET_CLIENT_receive (ch->client, &message_handler, ch, |
300 | GNUNET_TIME_UNIT_FOREVER_REL); | 382 | GNUNET_TIME_UNIT_FOREVER_REL); |
301 | } | 383 | } |
302 | 384 | ||
303 | |||
304 | /** | 385 | /** |
305 | * Transmit next message to service. | 386 | * Transmit next message to service. |
306 | * | 387 | * |
307 | * @param cls The 'struct GNUNET_PSYCSTORE_Handle'. | 388 | * @param cls The 'struct GNUNET_PSYC_Channel'. |
308 | * @param size Number of bytes available in buf. | 389 | * @param size Number of bytes available in buf. |
309 | * @param buf Where to copy the message. | 390 | * @param buf Where to copy the message. |
310 | * @return Number of bytes copied to buf. | 391 | * @return Number of bytes copied to buf. |
@@ -326,7 +407,7 @@ send_next_message (void *cls, size_t size, void *buf) | |||
326 | return 0; | 407 | return 0; |
327 | } | 408 | } |
328 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 409 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
329 | "Sending message of type %d to PSYCstore service\n", | 410 | "Sending message of type %d to PSYC service\n", |
330 | ntohs (op->msg->type)); | 411 | ntohs (op->msg->type)); |
331 | memcpy (buf, op->msg, ret); | 412 | memcpy (buf, op->msg, ret); |
332 | 413 | ||
@@ -349,7 +430,7 @@ send_next_message (void *cls, size_t size, void *buf) | |||
349 | /** | 430 | /** |
350 | * Schedule transmission of the next message from our queue. | 431 | * Schedule transmission of the next message from our queue. |
351 | * | 432 | * |
352 | * @param h PSYCstore handle. | 433 | * @param h PSYC handle. |
353 | */ | 434 | */ |
354 | static void | 435 | static void |
355 | transmit_next (struct GNUNET_PSYC_Channel *ch) | 436 | transmit_next (struct GNUNET_PSYC_Channel *ch) |
@@ -391,14 +472,12 @@ reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
391 | if (NULL == ch->transmit_head || | 472 | if (NULL == ch->transmit_head || |
392 | ch->transmit_head->msg->type != ch->reconnect_msg->type) | 473 | ch->transmit_head->msg->type != ch->reconnect_msg->type) |
393 | { | 474 | { |
394 | struct OperationHandle *op | 475 | uint16_t reconn_size = ntohs (ch->reconnect_msg->size); |
395 | = GNUNET_malloc (sizeof (struct OperationHandle) | 476 | struct OperationHandle *op = GNUNET_malloc (sizeof (*op) + reconn_size); |
396 | + ntohs (ch->reconnect_msg->size)); | 477 | memcpy (&op[1], ch->reconnect_msg, reconn_size); |
397 | memcpy (&op[1], ch->reconnect_msg, ntohs (ch->reconnect_msg->size)); | ||
398 | op->msg = (struct GNUNET_MessageHeader *) &op[1]; | 478 | op->msg = (struct GNUNET_MessageHeader *) &op[1]; |
399 | GNUNET_CONTAINER_DLL_insert (ch->transmit_head, ch->transmit_tail, op); | 479 | GNUNET_CONTAINER_DLL_insert (ch->transmit_head, ch->transmit_tail, op); |
400 | } | 480 | } |
401 | |||
402 | transmit_next (ch); | 481 | transmit_next (ch); |
403 | } | 482 | } |
404 | 483 | ||
@@ -414,7 +493,12 @@ disconnect (void *c) | |||
414 | { | 493 | { |
415 | struct GNUNET_PSYC_Channel *ch = c; | 494 | struct GNUNET_PSYC_Channel *ch = c; |
416 | GNUNET_assert (NULL != ch); | 495 | GNUNET_assert (NULL != ch); |
417 | GNUNET_assert (ch->transmit_head == ch->transmit_tail); | 496 | if (ch->transmit_head != ch->transmit_tail) |
497 | { | ||
498 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
499 | "Disconnecting while there are still outstanding messages!\n"); | ||
500 | GNUNET_break (0); | ||
501 | } | ||
418 | if (ch->reconnect_task != GNUNET_SCHEDULER_NO_TASK) | 502 | if (ch->reconnect_task != GNUNET_SCHEDULER_NO_TASK) |
419 | { | 503 | { |
420 | GNUNET_SCHEDULER_cancel (ch->reconnect_task); | 504 | GNUNET_SCHEDULER_cancel (ch->reconnect_task); |
@@ -431,7 +515,10 @@ disconnect (void *c) | |||
431 | ch->client = NULL; | 515 | ch->client = NULL; |
432 | } | 516 | } |
433 | if (NULL != ch->reconnect_msg) | 517 | if (NULL != ch->reconnect_msg) |
518 | { | ||
519 | GNUNET_free (ch->reconnect_msg); | ||
434 | ch->reconnect_msg = NULL; | 520 | ch->reconnect_msg = NULL; |
521 | } | ||
435 | } | 522 | } |
436 | 523 | ||
437 | 524 | ||
@@ -475,12 +562,13 @@ GNUNET_PSYC_master_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
475 | struct GNUNET_PSYC_Channel *ch = &mst->ch; | 562 | struct GNUNET_PSYC_Channel *ch = &mst->ch; |
476 | struct MasterStartRequest *req = GNUNET_malloc (sizeof (*req)); | 563 | struct MasterStartRequest *req = GNUNET_malloc (sizeof (*req)); |
477 | 564 | ||
478 | req->header.size = htons (sizeof (*req) + sizeof (*channel_key)); | 565 | req->header.size = htons (sizeof (*req)); |
479 | req->header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_MASTER_START); | 566 | req->header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_MASTER_START); |
480 | req->channel_key = *channel_key; | 567 | req->channel_key = *channel_key; |
481 | req->policy = policy; | 568 | req->policy = policy; |
482 | 569 | ||
483 | ch->cfg = cfg; | 570 | ch->cfg = cfg; |
571 | ch->is_master = GNUNET_YES; | ||
484 | ch->reconnect_msg = (struct GNUNET_MessageHeader *) req; | 572 | ch->reconnect_msg = (struct GNUNET_MessageHeader *) req; |
485 | ch->reconnect_delay = GNUNET_TIME_UNIT_ZERO; | 573 | ch->reconnect_delay = GNUNET_TIME_UNIT_ZERO; |
486 | ch->reconnect_task = GNUNET_SCHEDULER_add_now (&reconnect, mst); | 574 | ch->reconnect_task = GNUNET_SCHEDULER_add_now (&reconnect, mst); |
@@ -532,7 +620,7 @@ GNUNET_PSYC_master_stop (struct GNUNET_PSYC_Master *mst) | |||
532 | void | 620 | void |
533 | GNUNET_PSYC_join_decision (struct GNUNET_PSYC_JoinHandle *jh, | 621 | GNUNET_PSYC_join_decision (struct GNUNET_PSYC_JoinHandle *jh, |
534 | int is_admitted, | 622 | int is_admitted, |
535 | unsigned int relay_count, | 623 | uint32_t relay_count, |
536 | const struct GNUNET_PeerIdentity *relays, | 624 | const struct GNUNET_PeerIdentity *relays, |
537 | const char *method_name, | 625 | const char *method_name, |
538 | const struct GNUNET_ENV_Environment *env, | 626 | const struct GNUNET_ENV_Environment *env, |
@@ -556,13 +644,13 @@ send_modifier (void *cls, struct GNUNET_ENV_Modifier *mod) | |||
556 | pmod = (struct GNUNET_PSYC_MessageModifier *) &op[1]; | 644 | pmod = (struct GNUNET_PSYC_MessageModifier *) &op[1]; |
557 | op->msg = (struct GNUNET_MessageHeader *) pmod; | 645 | op->msg = (struct GNUNET_MessageHeader *) pmod; |
558 | 646 | ||
559 | pmod->header.type = GNUNET_MESSAGE_TYPE_PSYC_TRANSMIT_MODIFIER; | 647 | pmod->header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MODIFIER); |
560 | pmod->header.size = htons (sizeof (*pmod) + name_size + mod->value_size); | 648 | pmod->header.size = htons (sizeof (*pmod) + name_size + mod->value_size); |
561 | pmod->name_size = htons (name_size); | 649 | pmod->name_size = htons (name_size); |
562 | memcpy (&pmod[1], mod->name, name_size); | 650 | memcpy (&pmod[1], mod->name, name_size); |
563 | memcpy ((void *) &pmod[1] + name_size, mod->value, mod->value_size); | 651 | memcpy ((char *) &pmod[1] + name_size, mod->value, mod->value_size); |
564 | 652 | ||
565 | GNUNET_CONTAINER_DLL_insert (ch->transmit_head, ch->transmit_tail, op); | 653 | GNUNET_CONTAINER_DLL_insert_tail (ch->transmit_head, ch->transmit_tail, op); |
566 | return GNUNET_YES; | 654 | return GNUNET_YES; |
567 | } | 655 | } |
568 | 656 | ||
@@ -594,29 +682,41 @@ GNUNET_PSYC_master_transmit (struct GNUNET_PSYC_Master *mst, | |||
594 | return NULL; | 682 | return NULL; |
595 | ch->in_transmit = GNUNET_YES; | 683 | ch->in_transmit = GNUNET_YES; |
596 | 684 | ||
685 | size_t size = strlen (method_name) + 1; | ||
597 | struct GNUNET_PSYC_MessageMethod *pmeth; | 686 | struct GNUNET_PSYC_MessageMethod *pmeth; |
598 | struct OperationHandle *op = GNUNET_malloc (sizeof (*op) + sizeof (*pmeth)); | 687 | struct OperationHandle *op |
688 | = GNUNET_malloc (sizeof (*op) + sizeof (*pmeth) + size); | ||
599 | pmeth = (struct GNUNET_PSYC_MessageMethod *) &op[1]; | 689 | pmeth = (struct GNUNET_PSYC_MessageMethod *) &op[1]; |
600 | op->msg = (struct GNUNET_MessageHeader *) pmeth; | 690 | op->msg = (struct GNUNET_MessageHeader *) pmeth; |
601 | 691 | ||
602 | pmeth->header.type = GNUNET_MESSAGE_TYPE_PSYC_TRANSMIT_METHOD; | 692 | pmeth->header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD); |
603 | size_t size = strlen (method_name) + 1; | ||
604 | pmeth->header.size = htons (sizeof (*pmeth) + size); | 693 | pmeth->header.size = htons (sizeof (*pmeth) + size); |
605 | pmeth->flags = htonl (flags); | 694 | pmeth->flags = htonl (flags); |
606 | pmeth->mod_count | 695 | pmeth->mod_count = GNUNET_ntohll (GNUNET_ENV_environment_get_mod_count (env)); |
607 | = GNUNET_ntohll (GNUNET_ENV_environment_get_mod_count (env)); | ||
608 | memcpy (&pmeth[1], method_name, size); | 696 | memcpy (&pmeth[1], method_name, size); |
609 | 697 | ||
610 | GNUNET_CONTAINER_DLL_insert (ch->transmit_head, ch->transmit_tail, op); | 698 | GNUNET_CONTAINER_DLL_insert_tail (ch->transmit_head, ch->transmit_tail, op); |
611 | |||
612 | GNUNET_ENV_environment_iterate (env, send_modifier, mst); | 699 | GNUNET_ENV_environment_iterate (env, send_modifier, mst); |
700 | transmit_next (ch); | ||
701 | |||
702 | mst->tmit = GNUNET_malloc (sizeof (*mst->tmit)); | ||
703 | mst->tmit->master = mst; | ||
704 | mst->tmit->notify = notify; | ||
705 | mst->tmit->notify_cls = notify_cls; | ||
706 | mst->tmit->status = GNUNET_PSYC_DATA_CONT; | ||
707 | return mst->tmit; | ||
708 | } | ||
709 | |||
613 | 710 | ||
614 | struct GNUNET_PSYC_MasterTransmitHandle *th = GNUNET_malloc (sizeof (*th)); | 711 | /** |
615 | th->master = mst; | 712 | * Resume transmission to the channel. |
616 | th->env = env; | 713 | * |
617 | th->notify = notify; | 714 | * @param th Handle of the request that is being resumed. |
618 | th->notify_cls = notify_cls; | 715 | */ |
619 | return th; | 716 | void |
717 | GNUNET_PSYC_master_transmit_resume (struct GNUNET_PSYC_MasterTransmitHandle *th) | ||
718 | { | ||
719 | master_transmit_data (th->master); | ||
620 | } | 720 | } |
621 | 721 | ||
622 | 722 | ||
@@ -671,7 +771,7 @@ GNUNET_PSYC_slave_join (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
671 | const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key, | 771 | const struct GNUNET_CRYPTO_EccPublicSignKey *channel_key, |
672 | const struct GNUNET_CRYPTO_EccPrivateKey *slave_key, | 772 | const struct GNUNET_CRYPTO_EccPrivateKey *slave_key, |
673 | const struct GNUNET_PeerIdentity *origin, | 773 | const struct GNUNET_PeerIdentity *origin, |
674 | size_t relay_count, | 774 | uint32_t relay_count, |
675 | const struct GNUNET_PeerIdentity *relays, | 775 | const struct GNUNET_PeerIdentity *relays, |
676 | GNUNET_PSYC_Method method, | 776 | GNUNET_PSYC_Method method, |
677 | GNUNET_PSYC_JoinCallback join_cb, | 777 | GNUNET_PSYC_JoinCallback join_cb, |
@@ -680,7 +780,7 @@ GNUNET_PSYC_slave_join (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
680 | const char *method_name, | 780 | const char *method_name, |
681 | const struct GNUNET_ENV_Environment *env, | 781 | const struct GNUNET_ENV_Environment *env, |
682 | const void *data, | 782 | const void *data, |
683 | size_t data_size) | 783 | uint16_t data_size) |
684 | { | 784 | { |
685 | struct GNUNET_PSYC_Slave *slv = GNUNET_malloc (sizeof (*slv)); | 785 | struct GNUNET_PSYC_Slave *slv = GNUNET_malloc (sizeof (*slv)); |
686 | struct GNUNET_PSYC_Channel *ch = &slv->ch; | 786 | struct GNUNET_PSYC_Channel *ch = &slv->ch; |
@@ -692,10 +792,12 @@ GNUNET_PSYC_slave_join (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
692 | req->header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_SLAVE_JOIN); | 792 | req->header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_SLAVE_JOIN); |
693 | req->channel_key = *channel_key; | 793 | req->channel_key = *channel_key; |
694 | req->slave_key = *slave_key; | 794 | req->slave_key = *slave_key; |
795 | req->origin = *origin; | ||
695 | req->relay_count = relay_count; | 796 | req->relay_count = relay_count; |
696 | memcpy (&req[1], relays, relay_count * sizeof (*relays)); | 797 | memcpy (&req[1], relays, relay_count * sizeof (*relays)); |
697 | 798 | ||
698 | ch->cfg = cfg; | 799 | ch->cfg = cfg; |
800 | ch->is_master = GNUNET_NO; | ||
699 | ch->reconnect_msg = (struct GNUNET_MessageHeader *) req; | 801 | ch->reconnect_msg = (struct GNUNET_MessageHeader *) req; |
700 | ch->reconnect_delay = GNUNET_TIME_UNIT_ZERO; | 802 | ch->reconnect_delay = GNUNET_TIME_UNIT_ZERO; |
701 | ch->reconnect_task = GNUNET_SCHEDULER_add_now (&reconnect, slv); | 803 | ch->reconnect_task = GNUNET_SCHEDULER_add_now (&reconnect, slv); |
@@ -746,6 +848,18 @@ GNUNET_PSYC_slave_transmit (struct GNUNET_PSYC_Slave *slave, | |||
746 | 848 | ||
747 | 849 | ||
748 | /** | 850 | /** |
851 | * Resume transmission to the master. | ||
852 | * | ||
853 | * @param th Handle of the request that is being resumed. | ||
854 | */ | ||
855 | void | ||
856 | GNUNET_PSYC_slave_transmit_resume (struct GNUNET_PSYC_MasterTransmitHandle *th) | ||
857 | { | ||
858 | |||
859 | } | ||
860 | |||
861 | |||
862 | /** | ||
749 | * Abort transmission request to master. | 863 | * Abort transmission request to master. |
750 | * | 864 | * |
751 | * @param th Handle of the request that is being aborted. | 865 | * @param th Handle of the request that is being aborted. |
@@ -822,7 +936,7 @@ GNUNET_PSYC_channel_slave_add (struct GNUNET_PSYC_Channel *ch, | |||
822 | slvadd->announced_at = GNUNET_htonll (announced_at); | 936 | slvadd->announced_at = GNUNET_htonll (announced_at); |
823 | slvadd->effective_since = GNUNET_htonll (effective_since); | 937 | slvadd->effective_since = GNUNET_htonll (effective_since); |
824 | 938 | ||
825 | GNUNET_CONTAINER_DLL_insert (ch->transmit_head, ch->transmit_tail, op); | 939 | GNUNET_CONTAINER_DLL_insert_tail (ch->transmit_head, ch->transmit_tail, op); |
826 | transmit_next (ch); | 940 | transmit_next (ch); |
827 | } | 941 | } |
828 | 942 | ||
@@ -863,7 +977,7 @@ GNUNET_PSYC_channel_slave_remove (struct GNUNET_PSYC_Channel *ch, | |||
863 | slvrm->header.size = htons (sizeof (*slvrm)); | 977 | slvrm->header.size = htons (sizeof (*slvrm)); |
864 | slvrm->announced_at = GNUNET_htonll (announced_at); | 978 | slvrm->announced_at = GNUNET_htonll (announced_at); |
865 | 979 | ||
866 | GNUNET_CONTAINER_DLL_insert (ch->transmit_head, ch->transmit_tail, op); | 980 | GNUNET_CONTAINER_DLL_insert_tail (ch->transmit_head, ch->transmit_tail, op); |
867 | transmit_next (ch); | 981 | transmit_next (ch); |
868 | } | 982 | } |
869 | 983 | ||