diff options
author | Gabor X Toth <*@tg-x.net> | 2014-07-10 17:49:53 +0000 |
---|---|---|
committer | Gabor X Toth <*@tg-x.net> | 2014-07-10 17:49:53 +0000 |
commit | a8133f3ff80aaaccc904e4bbaf69bc53dee499cb (patch) | |
tree | c10edd7a8156280c61357ccf9e0f1f27c7a0d6db /src/psyc | |
parent | 6c75526e936fcc74ee79b13831b2b6dda57f293d (diff) | |
download | gnunet-a8133f3ff80aaaccc904e4bbaf69bc53dee499cb.tar.gz gnunet-a8133f3ff80aaaccc904e4bbaf69bc53dee499cb.zip |
PSYC(store), Multicast: use ECDSA slave/member keys; PSYC: add GNUNET_PSYC_message_create()
Diffstat (limited to 'src/psyc')
-rw-r--r-- | src/psyc/gnunet-service-psyc.c | 89 | ||||
-rw-r--r-- | src/psyc/psyc.h | 57 | ||||
-rw-r--r-- | src/psyc/psyc_api.c | 33 | ||||
-rw-r--r-- | src/psyc/psyc_util_lib.c | 113 | ||||
-rw-r--r-- | src/psyc/test_psyc.c | 18 |
5 files changed, 174 insertions, 136 deletions
diff --git a/src/psyc/gnunet-service-psyc.c b/src/psyc/gnunet-service-psyc.c index 9dcf40e0f..866275a79 100644 --- a/src/psyc/gnunet-service-psyc.c +++ b/src/psyc/gnunet-service-psyc.c | |||
@@ -93,7 +93,7 @@ struct TransmitMessage | |||
93 | uint64_t id; | 93 | uint64_t id; |
94 | 94 | ||
95 | /** | 95 | /** |
96 | * Size of @a buf | 96 | * Size of message. |
97 | */ | 97 | */ |
98 | uint16_t size; | 98 | uint16_t size; |
99 | 99 | ||
@@ -211,11 +211,6 @@ struct Channel | |||
211 | struct GNUNET_CONTAINER_Heap *recv_msgs; | 211 | struct GNUNET_CONTAINER_Heap *recv_msgs; |
212 | 212 | ||
213 | /** | 213 | /** |
214 | * FIXME: needed? | ||
215 | */ | ||
216 | GNUNET_SCHEDULER_TaskIdentifier tmit_task; | ||
217 | |||
218 | /** | ||
219 | * Public key of the channel. | 214 | * Public key of the channel. |
220 | */ | 215 | */ |
221 | struct GNUNET_CRYPTO_EddsaPublicKey pub_key; | 216 | struct GNUNET_CRYPTO_EddsaPublicKey pub_key; |
@@ -264,14 +259,16 @@ struct Channel | |||
264 | uint8_t is_master; | 259 | uint8_t is_master; |
265 | 260 | ||
266 | /** | 261 | /** |
267 | * Ready to receive messages from client? #GNUNET_YES or #GNUNET_NO | 262 | * Is this channel ready to receive messages from client? |
263 | * #GNUNET_YES or #GNUNET_NO | ||
268 | */ | 264 | */ |
269 | uint8_t ready; | 265 | uint8_t is_ready; |
270 | 266 | ||
271 | /** | 267 | /** |
272 | * Is the client disconnected? #GNUNET_YES or #GNUNET_NO | 268 | * Is the client disconnected? |
269 | * #GNUNET_YES or #GNUNET_NO | ||
273 | */ | 270 | */ |
274 | uint8_t disconnected; | 271 | uint8_t is_disconnected; |
275 | }; | 272 | }; |
276 | 273 | ||
277 | 274 | ||
@@ -345,12 +342,12 @@ struct Slave | |||
345 | /** | 342 | /** |
346 | * Private key of the slave. | 343 | * Private key of the slave. |
347 | */ | 344 | */ |
348 | struct GNUNET_CRYPTO_EddsaPrivateKey priv_key; | 345 | struct GNUNET_CRYPTO_EcdsaPrivateKey priv_key; |
349 | 346 | ||
350 | /** | 347 | /** |
351 | * Public key of the slave. | 348 | * Public key of the slave. |
352 | */ | 349 | */ |
353 | struct GNUNET_CRYPTO_EddsaPublicKey pub_key; | 350 | struct GNUNET_CRYPTO_EcdsaPublicKey pub_key; |
354 | 351 | ||
355 | /** | 352 | /** |
356 | * Hash of @a pub_key. | 353 | * Hash of @a pub_key. |
@@ -390,7 +387,7 @@ struct Slave | |||
390 | /** | 387 | /** |
391 | * Join decision received from multicast. | 388 | * Join decision received from multicast. |
392 | */ | 389 | */ |
393 | struct SlaveJoinDecision *join_dcsn; | 390 | struct GNUNET_PSYC_JoinDecisionMessage *join_dcsn; |
394 | 391 | ||
395 | /** | 392 | /** |
396 | * Maximum request ID for this channel. | 393 | * Maximum request ID for this channel. |
@@ -514,6 +511,7 @@ client_disconnect (void *cls, struct GNUNET_SERVER_Client *client) | |||
514 | { | 511 | { |
515 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 512 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
516 | "%p User context is NULL in client_disconnect()\n", chn); | 513 | "%p User context is NULL in client_disconnect()\n", chn); |
514 | GNUNET_break (0); | ||
517 | return; | 515 | return; |
518 | } | 516 | } |
519 | 517 | ||
@@ -573,7 +571,7 @@ client_send_msg (const struct Channel *chn, | |||
573 | */ | 571 | */ |
574 | struct JoinMemTestClosure | 572 | struct JoinMemTestClosure |
575 | { | 573 | { |
576 | struct GNUNET_CRYPTO_EddsaPublicKey slave_key; | 574 | struct GNUNET_CRYPTO_EcdsaPublicKey slave_key; |
577 | struct Channel *chn; | 575 | struct Channel *chn; |
578 | struct GNUNET_MULTICAST_JoinHandle *jh; | 576 | struct GNUNET_MULTICAST_JoinHandle *jh; |
579 | struct MasterJoinRequest *master_join_req; | 577 | struct MasterJoinRequest *master_join_req; |
@@ -613,7 +611,7 @@ join_mem_test_cb (void *cls, int64_t result, const char *err_msg) | |||
613 | */ | 611 | */ |
614 | static void | 612 | static void |
615 | mcast_recv_join_request (void *cls, | 613 | mcast_recv_join_request (void *cls, |
616 | const struct GNUNET_CRYPTO_EddsaPublicKey *slave_key, | 614 | const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key, |
617 | const struct GNUNET_MessageHeader *join_msg, | 615 | const struct GNUNET_MessageHeader *join_msg, |
618 | struct GNUNET_MULTICAST_JoinHandle *jh) | 616 | struct GNUNET_MULTICAST_JoinHandle *jh) |
619 | { | 617 | { |
@@ -670,7 +668,7 @@ mcast_recv_join_decision (void *cls, int is_admitted, | |||
670 | "%p Got join decision: %d\n", slv, is_admitted); | 668 | "%p Got join decision: %d\n", slv, is_admitted); |
671 | 669 | ||
672 | uint16_t join_resp_size = (NULL != join_resp) ? ntohs (join_resp->size) : 0; | 670 | uint16_t join_resp_size = (NULL != join_resp) ? ntohs (join_resp->size) : 0; |
673 | struct SlaveJoinDecision * | 671 | struct GNUNET_PSYC_JoinDecisionMessage * |
674 | dcsn = slv->join_dcsn = GNUNET_malloc (sizeof (*dcsn) + join_resp_size); | 672 | dcsn = slv->join_dcsn = GNUNET_malloc (sizeof (*dcsn) + join_resp_size); |
675 | dcsn->header.size = htons (sizeof (*dcsn) + join_resp_size); | 673 | dcsn->header.size = htons (sizeof (*dcsn) + join_resp_size); |
676 | dcsn->header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_JOIN_DECISION); | 674 | dcsn->header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_JOIN_DECISION); |
@@ -682,7 +680,7 @@ mcast_recv_join_decision (void *cls, int is_admitted, | |||
682 | 680 | ||
683 | if (GNUNET_YES == is_admitted) | 681 | if (GNUNET_YES == is_admitted) |
684 | { | 682 | { |
685 | chn->ready = GNUNET_YES; | 683 | chn->is_ready = GNUNET_YES; |
686 | } | 684 | } |
687 | else | 685 | else |
688 | { | 686 | { |
@@ -693,7 +691,7 @@ mcast_recv_join_decision (void *cls, int is_admitted, | |||
693 | 691 | ||
694 | static void | 692 | static void |
695 | mcast_recv_membership_test (void *cls, | 693 | mcast_recv_membership_test (void *cls, |
696 | const struct GNUNET_CRYPTO_EddsaPublicKey *slave_key, | 694 | const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key, |
697 | uint64_t message_id, uint64_t group_generation, | 695 | uint64_t message_id, uint64_t group_generation, |
698 | struct GNUNET_MULTICAST_MembershipTestHandle *mth) | 696 | struct GNUNET_MULTICAST_MembershipTestHandle *mth) |
699 | { | 697 | { |
@@ -703,7 +701,7 @@ mcast_recv_membership_test (void *cls, | |||
703 | 701 | ||
704 | static void | 702 | static void |
705 | mcast_recv_replay_fragment (void *cls, | 703 | mcast_recv_replay_fragment (void *cls, |
706 | const struct GNUNET_CRYPTO_EddsaPublicKey *slave_key, | 704 | const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key, |
707 | uint64_t fragment_id, uint64_t flags, | 705 | uint64_t fragment_id, uint64_t flags, |
708 | struct GNUNET_MULTICAST_ReplayHandle *rh) | 706 | struct GNUNET_MULTICAST_ReplayHandle *rh) |
709 | 707 | ||
@@ -714,7 +712,7 @@ mcast_recv_replay_fragment (void *cls, | |||
714 | 712 | ||
715 | static void | 713 | static void |
716 | mcast_recv_replay_message (void *cls, | 714 | mcast_recv_replay_message (void *cls, |
717 | const struct GNUNET_CRYPTO_EddsaPublicKey *slave_key, | 715 | const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key, |
718 | uint64_t message_id, | 716 | uint64_t message_id, |
719 | uint64_t fragment_offset, | 717 | uint64_t fragment_offset, |
720 | uint64_t flags, | 718 | uint64_t flags, |
@@ -737,7 +735,7 @@ hash_key_from_nll (struct GNUNET_HashCode *key, uint64_t n) | |||
737 | n = ((n << 8) & 0xFF00FF00FF00FF00ULL) | ((n >> 8) & 0x00FF00FF00FF00FFULL); | 735 | n = ((n << 8) & 0xFF00FF00FF00FF00ULL) | ((n >> 8) & 0x00FF00FF00FF00FFULL); |
738 | n = ((n << 16) & 0xFFFF0000FFFF0000ULL) | ((n >> 16) & 0x0000FFFF0000FFFFULL); | 736 | n = ((n << 16) & 0xFFFF0000FFFF0000ULL) | ((n >> 16) & 0x0000FFFF0000FFFFULL); |
739 | 737 | ||
740 | *key = (struct GNUNET_HashCode) {{ 0 }}; | 738 | *key = (struct GNUNET_HashCode) {}; |
741 | *((uint64_t *) key) | 739 | *((uint64_t *) key) |
742 | = (n << 32) | (n >> 32); | 740 | = (n << 32) | (n >> 32); |
743 | } | 741 | } |
@@ -753,7 +751,7 @@ hash_key_from_hll (struct GNUNET_HashCode *key, uint64_t n) | |||
753 | #if __BYTE_ORDER == __BIG_ENDIAN | 751 | #if __BYTE_ORDER == __BIG_ENDIAN |
754 | hash_key_from_nll (key, n); | 752 | hash_key_from_nll (key, n); |
755 | #elif __BYTE_ORDER == __LITTLE_ENDIAN | 753 | #elif __BYTE_ORDER == __LITTLE_ENDIAN |
756 | *key = (struct GNUNET_HashCode) {{ 0 }}; | 754 | *key = (struct GNUNET_HashCode) {}; |
757 | *((uint64_t *) key) = n; | 755 | *((uint64_t *) key) = n; |
758 | #else | 756 | #else |
759 | #error byteorder undefined | 757 | #error byteorder undefined |
@@ -1225,10 +1223,8 @@ mcast_recv_message (void *cls, const struct GNUNET_MULTICAST_MessageHeader *mmsg | |||
1225 | /** | 1223 | /** |
1226 | * Incoming request fragment from multicast for a master. | 1224 | * Incoming request fragment from multicast for a master. |
1227 | * | 1225 | * |
1228 | * @param cls Master. | 1226 | * @param cls Master. |
1229 | * @param slave_key Sending slave's public key. | 1227 | * @param req The request. |
1230 | * @param msg The message. | ||
1231 | * @param flags Request flags. | ||
1232 | */ | 1228 | */ |
1233 | static void | 1229 | static void |
1234 | mcast_recv_request (void *cls, | 1230 | mcast_recv_request (void *cls, |
@@ -1295,7 +1291,7 @@ store_recv_master_counters (void *cls, int result, uint64_t max_fragment_id, | |||
1295 | &mcast_recv_replay_message, | 1291 | &mcast_recv_replay_message, |
1296 | &mcast_recv_request, | 1292 | &mcast_recv_request, |
1297 | &mcast_recv_message, chn); | 1293 | &mcast_recv_message, chn); |
1298 | chn->ready = GNUNET_YES; | 1294 | chn->is_ready = GNUNET_YES; |
1299 | } | 1295 | } |
1300 | else | 1296 | else |
1301 | { | 1297 | { |
@@ -1400,7 +1396,7 @@ client_recv_master_start (void *cls, struct GNUNET_SERVER_Client *client, | |||
1400 | GNUNET_CONTAINER_multihashmap_put (masters, &chn->pub_key_hash, chn, | 1396 | GNUNET_CONTAINER_multihashmap_put (masters, &chn->pub_key_hash, chn, |
1401 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 1397 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
1402 | chn->store_op = GNUNET_PSYCSTORE_counters_get (store, &chn->pub_key, | 1398 | chn->store_op = GNUNET_PSYCSTORE_counters_get (store, &chn->pub_key, |
1403 | store_recv_master_counters, mst); | 1399 | store_recv_master_counters, mst); |
1404 | } | 1400 | } |
1405 | else | 1401 | else |
1406 | { | 1402 | { |
@@ -1440,10 +1436,10 @@ client_recv_slave_join (void *cls, struct GNUNET_SERVER_Client *client, | |||
1440 | const struct SlaveJoinRequest *req | 1436 | const struct SlaveJoinRequest *req |
1441 | = (const struct SlaveJoinRequest *) msg; | 1437 | = (const struct SlaveJoinRequest *) msg; |
1442 | 1438 | ||
1443 | struct GNUNET_CRYPTO_EddsaPublicKey slv_pub_key; | 1439 | struct GNUNET_CRYPTO_EcdsaPublicKey slv_pub_key; |
1444 | struct GNUNET_HashCode pub_key_hash, slv_pub_key_hash; | 1440 | struct GNUNET_HashCode pub_key_hash, slv_pub_key_hash; |
1445 | 1441 | ||
1446 | GNUNET_CRYPTO_eddsa_key_get_public (&req->slave_key, &slv_pub_key); | 1442 | GNUNET_CRYPTO_ecdsa_key_get_public (&req->slave_key, &slv_pub_key); |
1447 | GNUNET_CRYPTO_hash (&slv_pub_key, sizeof (slv_pub_key), &slv_pub_key_hash); | 1443 | GNUNET_CRYPTO_hash (&slv_pub_key, sizeof (slv_pub_key), &slv_pub_key_hash); |
1448 | GNUNET_CRYPTO_hash (&req->channel_key, sizeof (req->channel_key), &pub_key_hash); | 1444 | GNUNET_CRYPTO_hash (&req->channel_key, sizeof (req->channel_key), &pub_key_hash); |
1449 | 1445 | ||
@@ -1540,7 +1536,7 @@ client_recv_slave_join (void *cls, struct GNUNET_SERVER_Client *client, | |||
1540 | cli->client = client; | 1536 | cli->client = client; |
1541 | GNUNET_CONTAINER_DLL_insert (chn->clients_head, chn->clients_tail, cli); | 1537 | GNUNET_CONTAINER_DLL_insert (chn->clients_head, chn->clients_tail, cli); |
1542 | 1538 | ||
1543 | GNUNET_SERVER_client_set_user_context (client, &slv->chn); | 1539 | GNUNET_SERVER_client_set_user_context (client, chn); |
1544 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 1540 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
1545 | } | 1541 | } |
1546 | 1542 | ||
@@ -1578,7 +1574,8 @@ client_recv_join_decision (void *cls, struct GNUNET_SERVER_Client *client, | |||
1578 | GNUNET_assert (GNUNET_YES == chn->is_master); | 1574 | GNUNET_assert (GNUNET_YES == chn->is_master); |
1579 | struct Master *mst = (struct Master *) chn; | 1575 | struct Master *mst = (struct Master *) chn; |
1580 | 1576 | ||
1581 | struct MasterJoinDecision *dcsn = (struct MasterJoinDecision *) msg; | 1577 | struct GNUNET_PSYC_JoinDecisionMessage * |
1578 | dcsn = (struct GNUNET_PSYC_JoinDecisionMessage *) msg; | ||
1582 | struct JoinDecisionClosure jcls; | 1579 | struct JoinDecisionClosure jcls; |
1583 | jcls.is_admitted = ntohl (dcsn->is_admitted); | 1580 | jcls.is_admitted = ntohl (dcsn->is_admitted); |
1584 | jcls.msg | 1581 | jcls.msg |
@@ -1655,19 +1652,15 @@ transmit_notify (void *cls, size_t *data_size, void *data) | |||
1655 | GNUNET_CONTAINER_DLL_remove (chn->tmit_head, chn->tmit_tail, tmit_msg); | 1652 | GNUNET_CONTAINER_DLL_remove (chn->tmit_head, chn->tmit_tail, tmit_msg); |
1656 | GNUNET_free (tmit_msg); | 1653 | GNUNET_free (tmit_msg); |
1657 | 1654 | ||
1658 | if (0 == chn->tmit_task) | 1655 | if (NULL != chn->tmit_head) |
1659 | { | 1656 | { |
1660 | if (NULL != chn->tmit_head) | 1657 | transmit_message (chn); |
1661 | { | 1658 | } |
1662 | transmit_message (chn); | 1659 | else if (GNUNET_YES == chn->is_disconnected) |
1663 | } | 1660 | { |
1664 | else if (chn->disconnected) | 1661 | /* FIXME: handle partial message (when still in_transmit) */ |
1665 | { | 1662 | cleanup_channel (chn); |
1666 | /* FIXME: handle partial message (when still in_transmit) */ | ||
1667 | cleanup_channel (chn); | ||
1668 | } | ||
1669 | } | 1663 | } |
1670 | |||
1671 | return ret; | 1664 | return ret; |
1672 | } | 1665 | } |
1673 | 1666 | ||
@@ -1712,8 +1705,6 @@ slave_transmit_notify (void *cls, size_t *data_size, void *data) | |||
1712 | static void | 1705 | static void |
1713 | master_transmit_message (struct Master *mst) | 1706 | master_transmit_message (struct Master *mst) |
1714 | { | 1707 | { |
1715 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%p master_transmit_message()\n", mst); | ||
1716 | mst->chn.tmit_task = 0; | ||
1717 | if (NULL == mst->tmit_handle) | 1708 | if (NULL == mst->tmit_handle) |
1718 | { | 1709 | { |
1719 | mst->tmit_handle | 1710 | mst->tmit_handle |
@@ -1734,7 +1725,6 @@ master_transmit_message (struct Master *mst) | |||
1734 | static void | 1725 | static void |
1735 | slave_transmit_message (struct Slave *slv) | 1726 | slave_transmit_message (struct Slave *slv) |
1736 | { | 1727 | { |
1737 | slv->chn.tmit_task = 0; | ||
1738 | if (NULL == slv->tmit_handle) | 1728 | if (NULL == slv->tmit_handle) |
1739 | { | 1729 | { |
1740 | slv->tmit_handle | 1730 | slv->tmit_handle |
@@ -1830,6 +1820,8 @@ queue_message (struct Channel *chn, | |||
1830 | tmit_msg->size = data_size; | 1820 | tmit_msg->size = data_size; |
1831 | tmit_msg->state = chn->tmit_state; | 1821 | tmit_msg->state = chn->tmit_state; |
1832 | 1822 | ||
1823 | /* FIXME: separate queue per message ID */ | ||
1824 | |||
1833 | GNUNET_CONTAINER_DLL_insert_tail (chn->tmit_head, chn->tmit_tail, tmit_msg); | 1825 | GNUNET_CONTAINER_DLL_insert_tail (chn->tmit_head, chn->tmit_tail, tmit_msg); |
1834 | 1826 | ||
1835 | chn->is_master | 1827 | chn->is_master |
@@ -1877,10 +1869,11 @@ client_recv_psyc_message (void *cls, struct GNUNET_SERVER_Client *client, | |||
1877 | "%p Received message from client.\n", chn); | 1869 | "%p Received message from client.\n", chn); |
1878 | GNUNET_PSYC_log_message (GNUNET_ERROR_TYPE_DEBUG, msg); | 1870 | GNUNET_PSYC_log_message (GNUNET_ERROR_TYPE_DEBUG, msg); |
1879 | 1871 | ||
1880 | if (GNUNET_YES != chn->ready) | 1872 | if (GNUNET_YES != chn->is_ready) |
1881 | { | 1873 | { |
1882 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1874 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1883 | "%p Channel is not ready, dropping message from client.\n", chn); | 1875 | "%p Channel is not ready yet, disconnecting client.\n", chn); |
1876 | GNUNET_break (0); | ||
1884 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 1877 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
1885 | return; | 1878 | return; |
1886 | } | 1879 | } |
diff --git a/src/psyc/psyc.h b/src/psyc/psyc.h index 66c8de898..995fb1fa4 100644 --- a/src/psyc/psyc.h +++ b/src/psyc/psyc.h | |||
@@ -78,9 +78,9 @@ struct MasterStartRequest | |||
78 | */ | 78 | */ |
79 | struct GNUNET_MessageHeader header; | 79 | struct GNUNET_MessageHeader header; |
80 | 80 | ||
81 | struct GNUNET_CRYPTO_EddsaPrivateKey channel_key; | ||
82 | |||
83 | uint32_t policy GNUNET_PACKED; | 81 | uint32_t policy GNUNET_PACKED; |
82 | |||
83 | struct GNUNET_CRYPTO_EddsaPrivateKey channel_key; | ||
84 | }; | 84 | }; |
85 | 85 | ||
86 | 86 | ||
@@ -95,15 +95,17 @@ struct SlaveJoinRequest | |||
95 | 95 | ||
96 | struct GNUNET_CRYPTO_EddsaPublicKey channel_key; | 96 | struct GNUNET_CRYPTO_EddsaPublicKey channel_key; |
97 | 97 | ||
98 | struct GNUNET_CRYPTO_EddsaPrivateKey slave_key; | 98 | struct GNUNET_CRYPTO_EcdsaPrivateKey slave_key; |
99 | 99 | ||
100 | struct GNUNET_PeerIdentity origin; | 100 | struct GNUNET_PeerIdentity origin; |
101 | 101 | ||
102 | /* Followed by struct GNUNET_PeerIdentity relays[relay_count] */ | 102 | /* Followed by struct GNUNET_PeerIdentity relays[relay_count] */ |
103 | |||
104 | /* Followed by struct GNUNET_MessageHeader join_msg */ | ||
103 | }; | 105 | }; |
104 | 106 | ||
105 | 107 | ||
106 | struct ChannelSlaveAdd | 108 | struct ChannelSlaveAddRequest |
107 | { | 109 | { |
108 | /** | 110 | /** |
109 | * Type: GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_SLAVE_ADD | 111 | * Type: GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_SLAVE_ADD |
@@ -112,7 +114,7 @@ struct ChannelSlaveAdd | |||
112 | 114 | ||
113 | uint32_t reserved; | 115 | uint32_t reserved; |
114 | 116 | ||
115 | struct GNUNET_CRYPTO_EddsaPublicKey *slave_key; | 117 | struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key; |
116 | 118 | ||
117 | uint64_t announced_at; | 119 | uint64_t announced_at; |
118 | 120 | ||
@@ -120,7 +122,7 @@ struct ChannelSlaveAdd | |||
120 | }; | 122 | }; |
121 | 123 | ||
122 | 124 | ||
123 | struct ChannelSlaveRemove | 125 | struct ChannelSlaveRemoveRequest |
124 | { | 126 | { |
125 | /** | 127 | /** |
126 | * Type: GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_SLAVE_RM | 128 | * Type: GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_SLAVE_RM |
@@ -129,7 +131,7 @@ struct ChannelSlaveRemove | |||
129 | 131 | ||
130 | uint32_t reserved; | 132 | uint32_t reserved; |
131 | 133 | ||
132 | struct GNUNET_CRYPTO_EddsaPublicKey *slave_key; | 134 | struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key; |
133 | 135 | ||
134 | uint64_t announced_at; | 136 | uint64_t announced_at; |
135 | }; | 137 | }; |
@@ -189,6 +191,7 @@ struct CountersResult | |||
189 | uint64_t max_message_id; | 191 | uint64_t max_message_id; |
190 | }; | 192 | }; |
191 | 193 | ||
194 | |||
192 | /** | 195 | /** |
193 | * Answer from service to client about last operation. | 196 | * Answer from service to client about last operation. |
194 | */ | 197 | */ |
@@ -236,50 +239,12 @@ struct MasterJoinRequest | |||
236 | /** | 239 | /** |
237 | * Public key of the joining slave. | 240 | * Public key of the joining slave. |
238 | */ | 241 | */ |
239 | struct GNUNET_CRYPTO_EddsaPublicKey slave_key; | 242 | struct GNUNET_CRYPTO_EcdsaPublicKey slave_key; |
240 | 243 | ||
241 | /* Followed by struct GNUNET_MessageHeader join_request */ | 244 | /* Followed by struct GNUNET_MessageHeader join_request */ |
242 | }; | 245 | }; |
243 | 246 | ||
244 | 247 | ||
245 | struct MasterJoinDecision | ||
246 | { | ||
247 | /** | ||
248 | * Type: GNUNET_MESSAGE_TYPE_PSYC_JOIN_DECISION | ||
249 | */ | ||
250 | struct GNUNET_MessageHeader header; | ||
251 | |||
252 | /** | ||
253 | * #GNUNET_YES if the slave was admitted. | ||
254 | */ | ||
255 | int32_t is_admitted; | ||
256 | |||
257 | /** | ||
258 | * Public key of the joining slave. | ||
259 | */ | ||
260 | struct GNUNET_CRYPTO_EddsaPublicKey slave_key; | ||
261 | |||
262 | /* Followed by struct GNUNET_MessageHeader join_response */ | ||
263 | }; | ||
264 | |||
265 | |||
266 | struct SlaveJoinDecision | ||
267 | { | ||
268 | /** | ||
269 | * Type: GNUNET_MESSAGE_TYPE_PSYC_JOIN_DECISION | ||
270 | */ | ||
271 | struct GNUNET_MessageHeader header; | ||
272 | |||
273 | /** | ||
274 | * #GNUNET_YES if the slave was admitted. | ||
275 | */ | ||
276 | int32_t is_admitted; | ||
277 | |||
278 | /* Followed by struct GNUNET_MessageHeader join_response */ | ||
279 | }; | ||
280 | |||
281 | |||
282 | |||
283 | GNUNET_NETWORK_STRUCT_END | 248 | GNUNET_NETWORK_STRUCT_END |
284 | 249 | ||
285 | #endif | 250 | #endif |
diff --git a/src/psyc/psyc_api.c b/src/psyc/psyc_api.c index bfb6f43fb..88b007a0f 100644 --- a/src/psyc/psyc_api.c +++ b/src/psyc/psyc_api.c | |||
@@ -133,7 +133,7 @@ struct GNUNET_PSYC_Slave | |||
133 | struct GNUNET_PSYC_JoinHandle | 133 | struct GNUNET_PSYC_JoinHandle |
134 | { | 134 | { |
135 | struct GNUNET_PSYC_Master *mst; | 135 | struct GNUNET_PSYC_Master *mst; |
136 | struct GNUNET_CRYPTO_EddsaPublicKey slave_key; | 136 | struct GNUNET_CRYPTO_EcdsaPublicKey slave_key; |
137 | }; | 137 | }; |
138 | 138 | ||
139 | 139 | ||
@@ -270,8 +270,8 @@ slave_recv_join_decision (void *cls, | |||
270 | struct GNUNET_PSYC_Slave * | 270 | struct GNUNET_PSYC_Slave * |
271 | slv = GNUNET_CLIENT_MANAGER_get_user_context_ (client, | 271 | slv = GNUNET_CLIENT_MANAGER_get_user_context_ (client, |
272 | sizeof (struct GNUNET_PSYC_Channel)); | 272 | sizeof (struct GNUNET_PSYC_Channel)); |
273 | const struct SlaveJoinDecision * | 273 | const struct GNUNET_PSYC_JoinDecisionMessage * |
274 | dcsn = (const struct SlaveJoinDecision *) msg; | 274 | dcsn = (const struct GNUNET_PSYC_JoinDecisionMessage *) msg; |
275 | 275 | ||
276 | struct GNUNET_PSYC_MessageHeader *pmsg = NULL; | 276 | struct GNUNET_PSYC_MessageHeader *pmsg = NULL; |
277 | if (ntohs (dcsn->header.size) <= sizeof (*dcsn) + sizeof (*pmsg)) | 277 | if (ntohs (dcsn->header.size) <= sizeof (*dcsn) + sizeof (*pmsg)) |
@@ -285,8 +285,6 @@ slave_recv_join_decision (void *cls, | |||
285 | 285 | ||
286 | static struct GNUNET_CLIENT_MANAGER_MessageHandler master_handlers[] = | 286 | static struct GNUNET_CLIENT_MANAGER_MessageHandler master_handlers[] = |
287 | { | 287 | { |
288 | { &channel_recv_disconnect, NULL, 0, 0, GNUNET_NO }, | ||
289 | |||
290 | { &channel_recv_message, NULL, | 288 | { &channel_recv_message, NULL, |
291 | GNUNET_MESSAGE_TYPE_PSYC_MESSAGE, | 289 | GNUNET_MESSAGE_TYPE_PSYC_MESSAGE, |
292 | sizeof (struct GNUNET_PSYC_MessageHeader), GNUNET_YES }, | 290 | sizeof (struct GNUNET_PSYC_MessageHeader), GNUNET_YES }, |
@@ -303,14 +301,14 @@ static struct GNUNET_CLIENT_MANAGER_MessageHandler master_handlers[] = | |||
303 | GNUNET_MESSAGE_TYPE_PSYC_JOIN_REQUEST, | 301 | GNUNET_MESSAGE_TYPE_PSYC_JOIN_REQUEST, |
304 | sizeof (struct MasterJoinRequest), GNUNET_YES }, | 302 | sizeof (struct MasterJoinRequest), GNUNET_YES }, |
305 | 303 | ||
304 | { &channel_recv_disconnect, NULL, 0, 0, GNUNET_NO }, | ||
305 | |||
306 | { NULL, NULL, 0, 0, GNUNET_NO } | 306 | { NULL, NULL, 0, 0, GNUNET_NO } |
307 | }; | 307 | }; |
308 | 308 | ||
309 | 309 | ||
310 | static struct GNUNET_CLIENT_MANAGER_MessageHandler slave_handlers[] = | 310 | static struct GNUNET_CLIENT_MANAGER_MessageHandler slave_handlers[] = |
311 | { | 311 | { |
312 | { &channel_recv_disconnect, NULL, 0, 0, GNUNET_NO }, | ||
313 | |||
314 | { &channel_recv_message, NULL, | 312 | { &channel_recv_message, NULL, |
315 | GNUNET_MESSAGE_TYPE_PSYC_MESSAGE, | 313 | GNUNET_MESSAGE_TYPE_PSYC_MESSAGE, |
316 | sizeof (struct GNUNET_PSYC_MessageHeader), GNUNET_YES }, | 314 | sizeof (struct GNUNET_PSYC_MessageHeader), GNUNET_YES }, |
@@ -325,7 +323,9 @@ static struct GNUNET_CLIENT_MANAGER_MessageHandler slave_handlers[] = | |||
325 | 323 | ||
326 | { &slave_recv_join_decision, NULL, | 324 | { &slave_recv_join_decision, NULL, |
327 | GNUNET_MESSAGE_TYPE_PSYC_JOIN_DECISION, | 325 | GNUNET_MESSAGE_TYPE_PSYC_JOIN_DECISION, |
328 | sizeof (struct SlaveJoinDecision), GNUNET_YES }, | 326 | sizeof (struct GNUNET_PSYC_JoinDecisionMessage), GNUNET_YES }, |
327 | |||
328 | { &channel_recv_disconnect, NULL, 0, 0, GNUNET_NO }, | ||
329 | 329 | ||
330 | { NULL, NULL, 0, 0, GNUNET_NO } | 330 | { NULL, NULL, 0, 0, GNUNET_NO } |
331 | }; | 331 | }; |
@@ -442,7 +442,7 @@ GNUNET_PSYC_join_decision (struct GNUNET_PSYC_JoinHandle *jh, | |||
442 | const struct GNUNET_PSYC_MessageHeader *join_resp) | 442 | const struct GNUNET_PSYC_MessageHeader *join_resp) |
443 | { | 443 | { |
444 | struct GNUNET_PSYC_Channel *chn = &jh->mst->chn; | 444 | struct GNUNET_PSYC_Channel *chn = &jh->mst->chn; |
445 | struct MasterJoinDecision *dcsn; | 445 | struct GNUNET_PSYC_JoinDecisionMessage *dcsn; |
446 | uint16_t join_resp_size | 446 | uint16_t join_resp_size |
447 | = (NULL != join_resp) ? ntohs (join_resp->header.size) : 0; | 447 | = (NULL != join_resp) ? ntohs (join_resp->header.size) : 0; |
448 | uint16_t relay_size = relay_count * sizeof (*relays); | 448 | uint16_t relay_size = relay_count * sizeof (*relays); |
@@ -571,7 +571,7 @@ GNUNET_PSYC_master_get_channel (struct GNUNET_PSYC_Master *master) | |||
571 | struct GNUNET_PSYC_Slave * | 571 | struct GNUNET_PSYC_Slave * |
572 | GNUNET_PSYC_slave_join (const struct GNUNET_CONFIGURATION_Handle *cfg, | 572 | GNUNET_PSYC_slave_join (const struct GNUNET_CONFIGURATION_Handle *cfg, |
573 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, | 573 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, |
574 | const struct GNUNET_CRYPTO_EddsaPrivateKey *slave_key, | 574 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *slave_key, |
575 | const struct GNUNET_PeerIdentity *origin, | 575 | const struct GNUNET_PeerIdentity *origin, |
576 | uint32_t relay_count, | 576 | uint32_t relay_count, |
577 | const struct GNUNET_PeerIdentity *relays, | 577 | const struct GNUNET_PeerIdentity *relays, |
@@ -579,10 +579,7 @@ GNUNET_PSYC_slave_join (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
579 | GNUNET_PSYC_SlaveConnectCallback connect_cb, | 579 | GNUNET_PSYC_SlaveConnectCallback connect_cb, |
580 | GNUNET_PSYC_JoinDecisionCallback join_decision_cb, | 580 | GNUNET_PSYC_JoinDecisionCallback join_decision_cb, |
581 | void *cls, | 581 | void *cls, |
582 | const char *method_name, | 582 | const struct GNUNET_MessageHeader *join_msg) |
583 | const struct GNUNET_ENV_Environment *env, | ||
584 | const void *data, | ||
585 | uint16_t data_size) | ||
586 | { | 583 | { |
587 | struct GNUNET_PSYC_Slave *slv = GNUNET_malloc (sizeof (*slv)); | 584 | struct GNUNET_PSYC_Slave *slv = GNUNET_malloc (sizeof (*slv)); |
588 | struct GNUNET_PSYC_Channel *chn = &slv->chn; | 585 | struct GNUNET_PSYC_Channel *chn = &slv->chn; |
@@ -725,11 +722,11 @@ GNUNET_PSYC_slave_get_channel (struct GNUNET_PSYC_Slave *slv) | |||
725 | */ | 722 | */ |
726 | void | 723 | void |
727 | GNUNET_PSYC_channel_slave_add (struct GNUNET_PSYC_Channel *chn, | 724 | GNUNET_PSYC_channel_slave_add (struct GNUNET_PSYC_Channel *chn, |
728 | const struct GNUNET_CRYPTO_EddsaPublicKey *slave_key, | 725 | const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key, |
729 | uint64_t announced_at, | 726 | uint64_t announced_at, |
730 | uint64_t effective_since) | 727 | uint64_t effective_since) |
731 | { | 728 | { |
732 | struct ChannelSlaveAdd *add = GNUNET_malloc (sizeof (*add)); | 729 | struct ChannelSlaveAddRequest *add = GNUNET_malloc (sizeof (*add)); |
733 | add->header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_SLAVE_ADD); | 730 | add->header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_SLAVE_ADD); |
734 | add->header.size = htons (sizeof (*add)); | 731 | add->header.size = htons (sizeof (*add)); |
735 | add->announced_at = GNUNET_htonll (announced_at); | 732 | add->announced_at = GNUNET_htonll (announced_at); |
@@ -761,10 +758,10 @@ GNUNET_PSYC_channel_slave_add (struct GNUNET_PSYC_Channel *chn, | |||
761 | */ | 758 | */ |
762 | void | 759 | void |
763 | GNUNET_PSYC_channel_slave_remove (struct GNUNET_PSYC_Channel *chn, | 760 | GNUNET_PSYC_channel_slave_remove (struct GNUNET_PSYC_Channel *chn, |
764 | const struct GNUNET_CRYPTO_EddsaPublicKey *slave_key, | 761 | const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key, |
765 | uint64_t announced_at) | 762 | uint64_t announced_at) |
766 | { | 763 | { |
767 | struct ChannelSlaveRemove *rm = GNUNET_malloc (sizeof (*rm)); | 764 | struct ChannelSlaveRemoveRequest *rm = GNUNET_malloc (sizeof (*rm)); |
768 | rm->header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_SLAVE_RM); | 765 | rm->header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_SLAVE_RM); |
769 | rm->header.size = htons (sizeof (*rm)); | 766 | rm->header.size = htons (sizeof (*rm)); |
770 | rm->announced_at = GNUNET_htonll (announced_at); | 767 | rm->announced_at = GNUNET_htonll (announced_at); |
diff --git a/src/psyc/psyc_util_lib.c b/src/psyc/psyc_util_lib.c index a50d99bec..8ab0bdad2 100644 --- a/src/psyc/psyc_util_lib.c +++ b/src/psyc/psyc_util_lib.c | |||
@@ -34,22 +34,6 @@ | |||
34 | 34 | ||
35 | #define LOG(kind,...) GNUNET_log_from (kind, "psyc-util",__VA_ARGS__) | 35 | #define LOG(kind,...) GNUNET_log_from (kind, "psyc-util",__VA_ARGS__) |
36 | 36 | ||
37 | /** | ||
38 | * Message receive states. | ||
39 | */ | ||
40 | enum GNUNET_PSYC_MessageState | ||
41 | { | ||
42 | GNUNET_PSYC_MESSAGE_STATE_START = 0, | ||
43 | GNUNET_PSYC_MESSAGE_STATE_HEADER = 1, | ||
44 | GNUNET_PSYC_MESSAGE_STATE_METHOD = 2, | ||
45 | GNUNET_PSYC_MESSAGE_STATE_MODIFIER = 3, | ||
46 | GNUNET_PSYC_MESSAGE_STATE_MOD_CONT = 4, | ||
47 | GNUNET_PSYC_MESSAGE_STATE_DATA = 5, | ||
48 | GNUNET_PSYC_MESSAGE_STATE_END = 6, | ||
49 | GNUNET_PSYC_MESSAGE_STATE_CANCEL = 7, | ||
50 | GNUNET_PSYC_MESSAGE_STATE_ERROR = 8, | ||
51 | }; | ||
52 | |||
53 | 37 | ||
54 | struct GNUNET_PSYC_TransmitHandle | 38 | struct GNUNET_PSYC_TransmitHandle |
55 | { | 39 | { |
@@ -142,7 +126,7 @@ struct GNUNET_PSYC_ReceiveHandle | |||
142 | /** | 126 | /** |
143 | * Public key of the slave from which a message is being received. | 127 | * Public key of the slave from which a message is being received. |
144 | */ | 128 | */ |
145 | struct GNUNET_CRYPTO_EddsaPublicKey slave_key; | 129 | struct GNUNET_CRYPTO_EcdsaPublicKey slave_key; |
146 | 130 | ||
147 | /** | 131 | /** |
148 | * State of the currently being received message from the PSYC service. | 132 | * State of the currently being received message from the PSYC service. |
@@ -165,6 +149,101 @@ struct GNUNET_PSYC_ReceiveHandle | |||
165 | uint32_t mod_value_size; | 149 | uint32_t mod_value_size; |
166 | }; | 150 | }; |
167 | 151 | ||
152 | /**** Messages ****/ | ||
153 | |||
154 | |||
155 | /** | ||
156 | * Create a PSYC message. | ||
157 | * | ||
158 | * @param method_name | ||
159 | * PSYC method for the message. | ||
160 | * @param env | ||
161 | * Environment for the message. | ||
162 | * @param data | ||
163 | * Data payload for the message. | ||
164 | * @param data_size | ||
165 | * Size of @a data. | ||
166 | * | ||
167 | * @return Message header with size information, | ||
168 | * followed by the message parts. | ||
169 | */ | ||
170 | struct GNUNET_MessageHeader * | ||
171 | GNUNET_PSYC_message_create (const char *method_name, | ||
172 | const struct GNUNET_ENV_Environment *env, | ||
173 | const void *data, | ||
174 | size_t data_size) | ||
175 | { | ||
176 | struct GNUNET_ENV_Modifier *mod = NULL; | ||
177 | struct GNUNET_PSYC_MessageMethod *pmeth = NULL; | ||
178 | struct GNUNET_PSYC_MessageModifier *pmod = NULL; | ||
179 | struct GNUNET_MessageHeader *pmsg = NULL; | ||
180 | uint16_t env_size = 0; | ||
181 | if (NULL != env) | ||
182 | { | ||
183 | mod = GNUNET_ENV_environment_head (env); | ||
184 | while (NULL != mod) | ||
185 | { | ||
186 | env_size += sizeof (*pmod) + strlen (mod->name) + 1 + mod->value_size; | ||
187 | mod = mod->next; | ||
188 | } | ||
189 | } | ||
190 | |||
191 | struct GNUNET_MessageHeader *msg; | ||
192 | uint16_t method_name_size = strlen (method_name) + 1; | ||
193 | if (method_name_size == 1) | ||
194 | return NULL; | ||
195 | |||
196 | uint16_t msg_size = sizeof (*msg) /* header */ | ||
197 | + sizeof (*pmeth) + method_name_size /* method */ | ||
198 | + env_size /* modifiers */ | ||
199 | + ((0 < data_size) ? sizeof (*pmsg) + data_size : 0)/* data */ | ||
200 | + sizeof (*pmsg); /* end of message */ | ||
201 | msg = GNUNET_malloc (msg_size); | ||
202 | msg->size = htons (msg_size); | ||
203 | msg->type = htons (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE); | ||
204 | |||
205 | pmeth = (struct GNUNET_PSYC_MessageMethod *) &msg[1]; | ||
206 | pmeth->header.size = htons (sizeof (*pmeth) + method_name_size); | ||
207 | memcpy (pmeth, method_name, method_name_size); | ||
208 | |||
209 | uint16_t p = sizeof (*msg) + sizeof (*pmeth) + method_name_size; | ||
210 | if (NULL != env) | ||
211 | { | ||
212 | mod = GNUNET_ENV_environment_head (env); | ||
213 | while (NULL != mod) | ||
214 | { | ||
215 | uint16_t mod_name_size = strlen (mod->name) + 1; | ||
216 | pmod = (struct GNUNET_PSYC_MessageModifier *) ((char *) msg + p); | ||
217 | pmod->header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MODIFIER); | ||
218 | pmod->header.size = sizeof (*pmod) + mod_name_size + 1 + mod->value_size; | ||
219 | p += pmod->header.size; | ||
220 | pmod->header.size = htons (pmod->header.size); | ||
221 | |||
222 | memcpy (&pmod[1], mod->name, mod_name_size); | ||
223 | if (0 < mod->value_size) | ||
224 | memcpy ((char *) &pmod[1] + mod_name_size, mod->value, mod->value_size); | ||
225 | |||
226 | mod = mod->next; | ||
227 | } | ||
228 | } | ||
229 | |||
230 | if (0 < data_size) | ||
231 | { | ||
232 | pmsg = (struct GNUNET_MessageHeader *) ((char *) msg + p); | ||
233 | pmsg->size = sizeof (*pmsg) + data_size; | ||
234 | p += pmsg->size; | ||
235 | pmsg->size = htons (pmsg->size); | ||
236 | pmsg->type = htons (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_DATA); | ||
237 | memcpy (&pmsg[1], data, data_size); | ||
238 | } | ||
239 | |||
240 | pmsg = (struct GNUNET_MessageHeader *) ((char *) msg + p); | ||
241 | pmsg->size = htons (sizeof (*pmsg)); | ||
242 | pmsg->type = htons (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END); | ||
243 | |||
244 | return msg; | ||
245 | } | ||
246 | |||
168 | 247 | ||
169 | void | 248 | void |
170 | GNUNET_PSYC_log_message (enum GNUNET_ErrorType kind, | 249 | GNUNET_PSYC_log_message (enum GNUNET_ErrorType kind, |
diff --git a/src/psyc/test_psyc.c b/src/psyc/test_psyc.c index 6468b8a2b..0077bc9b7 100644 --- a/src/psyc/test_psyc.c +++ b/src/psyc/test_psyc.c | |||
@@ -33,11 +33,12 @@ | |||
33 | #include "gnunet_util_lib.h" | 33 | #include "gnunet_util_lib.h" |
34 | #include "gnunet_testing_lib.h" | 34 | #include "gnunet_testing_lib.h" |
35 | #include "gnunet_env_lib.h" | 35 | #include "gnunet_env_lib.h" |
36 | #include "gnunet_psyc_util_lib.h" | ||
36 | #include "gnunet_psyc_service.h" | 37 | #include "gnunet_psyc_service.h" |
37 | 38 | ||
38 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) | 39 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) |
39 | 40 | ||
40 | #define DEBUG_SERVICE 1 | 41 | #define DEBUG_SERVICE 0 |
41 | 42 | ||
42 | 43 | ||
43 | /** | 44 | /** |
@@ -56,10 +57,10 @@ static struct GNUNET_PSYC_Master *mst; | |||
56 | static struct GNUNET_PSYC_Slave *slv; | 57 | static struct GNUNET_PSYC_Slave *slv; |
57 | 58 | ||
58 | static struct GNUNET_CRYPTO_EddsaPrivateKey *channel_key; | 59 | static struct GNUNET_CRYPTO_EddsaPrivateKey *channel_key; |
59 | static struct GNUNET_CRYPTO_EddsaPrivateKey *slave_key; | 60 | static struct GNUNET_CRYPTO_EcdsaPrivateKey *slave_key; |
60 | 61 | ||
61 | static struct GNUNET_CRYPTO_EddsaPublicKey channel_pub_key; | 62 | static struct GNUNET_CRYPTO_EddsaPublicKey channel_pub_key; |
62 | static struct GNUNET_CRYPTO_EddsaPublicKey slave_pub_key; | 63 | static struct GNUNET_CRYPTO_EcdsaPublicKey slave_pub_key; |
63 | 64 | ||
64 | struct GNUNET_PSYC_MasterTransmitHandle *mth; | 65 | struct GNUNET_PSYC_MasterTransmitHandle *mth; |
65 | 66 | ||
@@ -414,7 +415,7 @@ join_decision_cb (void *cls, int is_admitted, | |||
414 | 415 | ||
415 | 416 | ||
416 | static void | 417 | static void |
417 | join_request_cb (void *cls, const struct GNUNET_CRYPTO_EddsaPublicKey *slave_key, | 418 | join_request_cb (void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key, |
418 | const struct GNUNET_PSYC_MessageHeader *msg, | 419 | const struct GNUNET_PSYC_MessageHeader *msg, |
419 | struct GNUNET_PSYC_JoinHandle *jh) | 420 | struct GNUNET_PSYC_JoinHandle *jh) |
420 | { | 421 | { |
@@ -449,10 +450,13 @@ slave_join () | |||
449 | "_foo", "bar baz", 7); | 450 | "_foo", "bar baz", 7); |
450 | GNUNET_ENV_environment_add (env, GNUNET_ENV_OP_ASSIGN, | 451 | GNUNET_ENV_environment_add (env, GNUNET_ENV_OP_ASSIGN, |
451 | "_foo_bar", "foo bar baz", 11); | 452 | "_foo_bar", "foo bar baz", 11); |
453 | struct GNUNET_MessageHeader * | ||
454 | join_msg = GNUNET_PSYC_message_create ("_request_join", env, "some data", 9); | ||
455 | |||
452 | slv = GNUNET_PSYC_slave_join (cfg, &channel_pub_key, slave_key, &origin, | 456 | slv = GNUNET_PSYC_slave_join (cfg, &channel_pub_key, slave_key, &origin, |
453 | 0, NULL, &slave_message_cb, | 457 | 0, NULL, &slave_message_cb, |
454 | &slave_connect_cb, &join_decision_cb, NULL, | 458 | &slave_connect_cb, &join_decision_cb, NULL, |
455 | "_request_join", env, "some data", 9); | 459 | join_msg); |
456 | GNUNET_ENV_environment_destroy (env); | 460 | GNUNET_ENV_environment_destroy (env); |
457 | } | 461 | } |
458 | 462 | ||
@@ -539,10 +543,10 @@ run (void *cls, | |||
539 | end_badly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); | 543 | end_badly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); |
540 | 544 | ||
541 | channel_key = GNUNET_CRYPTO_eddsa_key_create (); | 545 | channel_key = GNUNET_CRYPTO_eddsa_key_create (); |
542 | slave_key = GNUNET_CRYPTO_eddsa_key_create (); | 546 | slave_key = GNUNET_CRYPTO_ecdsa_key_create (); |
543 | 547 | ||
544 | GNUNET_CRYPTO_eddsa_key_get_public (channel_key, &channel_pub_key); | 548 | GNUNET_CRYPTO_eddsa_key_get_public (channel_key, &channel_pub_key); |
545 | GNUNET_CRYPTO_eddsa_key_get_public (slave_key, &slave_pub_key); | 549 | GNUNET_CRYPTO_ecdsa_key_get_public (slave_key, &slave_pub_key); |
546 | 550 | ||
547 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Starting master.\n"); | 551 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Starting master.\n"); |
548 | mst = GNUNET_PSYC_master_start (cfg, channel_key, GNUNET_PSYC_CHANNEL_PRIVATE, | 552 | mst = GNUNET_PSYC_master_start (cfg, channel_key, GNUNET_PSYC_CHANNEL_PRIVATE, |