diff options
author | Gabor X Toth <*@tg-x.net> | 2015-08-28 13:33:43 +0000 |
---|---|---|
committer | Gabor X Toth <*@tg-x.net> | 2015-08-28 13:33:43 +0000 |
commit | 38963d1e81332032e0ac774f4f2c6b804c38802a (patch) | |
tree | ce33b979e47fe332c7c744744d60077a7e1fefee /src/social | |
parent | b4fa14499c64140273850569247abda687803053 (diff) | |
download | gnunet-38963d1e81332032e0ac774f4f2c6b804c38802a.tar.gz gnunet-38963d1e81332032e0ac774f4f2c6b804c38802a.zip |
psyc/social: get state from psycstore
Diffstat (limited to 'src/social')
-rw-r--r-- | src/social/gnunet-service-social.c | 133 | ||||
-rw-r--r-- | src/social/social_api.c | 68 | ||||
-rw-r--r-- | src/social/test_social.c | 125 |
3 files changed, 281 insertions, 45 deletions
diff --git a/src/social/gnunet-service-social.c b/src/social/gnunet-service-social.c index 4211772f1..56612b488 100644 --- a/src/social/gnunet-service-social.c +++ b/src/social/gnunet-service-social.c | |||
@@ -350,7 +350,7 @@ cleanup_guest (struct Guest *gst) | |||
350 | struct GNUNET_CONTAINER_MultiHashMap * | 350 | struct GNUNET_CONTAINER_MultiHashMap * |
351 | plc_gst = GNUNET_CONTAINER_multihashmap_get (place_guests, | 351 | plc_gst = GNUNET_CONTAINER_multihashmap_get (place_guests, |
352 | &plc->pub_key_hash); | 352 | &plc->pub_key_hash); |
353 | GNUNET_assert (NULL != plc_gst); | 353 | GNUNET_assert (NULL != plc_gst); // FIXME |
354 | GNUNET_CONTAINER_multihashmap_remove (plc_gst, &gst->pub_key_hash, gst); | 354 | GNUNET_CONTAINER_multihashmap_remove (plc_gst, &gst->pub_key_hash, gst); |
355 | 355 | ||
356 | if (0 == GNUNET_CONTAINER_multihashmap_size (plc_gst)) | 356 | if (0 == GNUNET_CONTAINER_multihashmap_size (plc_gst)) |
@@ -1302,7 +1302,7 @@ psyc_transmit_queue_next_method (struct Place *plc, | |||
1302 | { | 1302 | { |
1303 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1303 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1304 | "%p psyc_transmit_queue_next_method: unexpected message part of type %u.\n", | 1304 | "%p psyc_transmit_queue_next_method: unexpected message part of type %u.\n", |
1305 | plc, ntohs (pmsg->type)); | 1305 | plc, NULL != pmsg ? ntohs (pmsg->type) : 0); |
1306 | GNUNET_break (0); | 1306 | GNUNET_break (0); |
1307 | return GNUNET_SYSERR; | 1307 | return GNUNET_SYSERR; |
1308 | } | 1308 | } |
@@ -1536,12 +1536,10 @@ client_recv_psyc_message (void *cls, struct GNUNET_SERVER_Client *client, | |||
1536 | 1536 | ||
1537 | 1537 | ||
1538 | /** | 1538 | /** |
1539 | * A historic message result arrived from PSYC. | 1539 | * A historic message arrived from PSYC. |
1540 | */ | 1540 | */ |
1541 | static void | 1541 | static void |
1542 | psyc_recv_history_message (void *cls, | 1542 | psyc_recv_history_message (void *cls, uint64_t message_id, uint32_t flags, |
1543 | uint64_t message_id, | ||
1544 | uint32_t flags, | ||
1545 | const struct GNUNET_PSYC_MessageHeader *msg) | 1543 | const struct GNUNET_PSYC_MessageHeader *msg) |
1546 | { | 1544 | { |
1547 | struct OperationClosure *opcls = cls; | 1545 | struct OperationClosure *opcls = cls; |
@@ -1567,6 +1565,9 @@ psyc_recv_history_message (void *cls, | |||
1567 | } | 1565 | } |
1568 | 1566 | ||
1569 | 1567 | ||
1568 | /** | ||
1569 | * Result of message history replay from PSYC. | ||
1570 | */ | ||
1570 | static void | 1571 | static void |
1571 | psyc_recv_history_result (void *cls, int64_t result, | 1572 | psyc_recv_history_result (void *cls, int64_t result, |
1572 | const void *err_msg, uint16_t err_msg_size) | 1573 | const void *err_msg, uint16_t err_msg_size) |
@@ -1574,7 +1575,7 @@ psyc_recv_history_result (void *cls, int64_t result, | |||
1574 | struct OperationClosure *opcls = cls; | 1575 | struct OperationClosure *opcls = cls; |
1575 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1576 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1576 | "%p History replay #%" PRIu64 ": " | 1577 | "%p History replay #%" PRIu64 ": " |
1577 | "PSYCSTORE returned %" PRId64 " (%.*s)\n", | 1578 | "PSYCstore returned %" PRId64 " (%.*s)\n", |
1578 | opcls->plc, GNUNET_ntohll (opcls->op_id), result, err_msg_size, err_msg); | 1579 | opcls->plc, GNUNET_ntohll (opcls->op_id), result, err_msg_size, err_msg); |
1579 | 1580 | ||
1580 | // FIXME: place might have been destroyed | 1581 | // FIXME: place might have been destroyed |
@@ -1635,6 +1636,118 @@ client_recv_history_replay (void *cls, struct GNUNET_SERVER_Client *client, | |||
1635 | } | 1636 | } |
1636 | 1637 | ||
1637 | 1638 | ||
1639 | /** | ||
1640 | * A state variable part arrived from PSYC. | ||
1641 | */ | ||
1642 | void | ||
1643 | psyc_recv_state_var (void *cls, | ||
1644 | const struct GNUNET_MessageHeader *mod, | ||
1645 | const char *name, | ||
1646 | const void *value, | ||
1647 | uint32_t value_size, | ||
1648 | uint32_t full_value_size) | ||
1649 | { | ||
1650 | struct OperationClosure *opcls = cls; | ||
1651 | struct Place *plc = opcls->plc; | ||
1652 | |||
1653 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1654 | "%p Received state variable %s from PSYC\n", | ||
1655 | plc, name); | ||
1656 | |||
1657 | uint16_t size = ntohs (mod->size); | ||
1658 | |||
1659 | struct GNUNET_OperationResultMessage * | ||
1660 | res = GNUNET_malloc (sizeof (*res) + size); | ||
1661 | res->header.size = htons (sizeof (*res) + size); | ||
1662 | res->header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_STATE_RESULT); | ||
1663 | res->op_id = opcls->op_id; | ||
1664 | res->result_code = GNUNET_htonll (GNUNET_OK); | ||
1665 | |||
1666 | memcpy (&res[1], mod, size); | ||
1667 | |||
1668 | /** @todo FIXME: send only to requesting client */ | ||
1669 | client_send_msg (plc, &res->header); | ||
1670 | } | ||
1671 | |||
1672 | |||
1673 | /** | ||
1674 | * Result of retrieving state variable from PSYC. | ||
1675 | */ | ||
1676 | static void | ||
1677 | psyc_recv_state_result (void *cls, int64_t result, | ||
1678 | const void *err_msg, uint16_t err_msg_size) | ||
1679 | { | ||
1680 | struct OperationClosure *opcls = cls; | ||
1681 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1682 | "%p State get #%" PRIu64 ": " | ||
1683 | "PSYCstore returned %" PRId64 " (%.*s)\n", | ||
1684 | opcls->plc, GNUNET_ntohll (opcls->op_id), result, err_msg_size, err_msg); | ||
1685 | |||
1686 | // FIXME: place might have been destroyed | ||
1687 | client_send_result (opcls->client, opcls->op_id, result, err_msg, err_msg_size); | ||
1688 | } | ||
1689 | |||
1690 | |||
1691 | /** | ||
1692 | * Client requests channel history. | ||
1693 | */ | ||
1694 | static void | ||
1695 | client_recv_state_get (void *cls, struct GNUNET_SERVER_Client *client, | ||
1696 | const struct GNUNET_MessageHeader *msg) | ||
1697 | { | ||
1698 | struct Client * | ||
1699 | ctx = GNUNET_SERVER_client_get_user_context (client, struct Client); | ||
1700 | GNUNET_assert (NULL != ctx); | ||
1701 | struct Place *plc = ctx->plc; | ||
1702 | |||
1703 | const struct GNUNET_PSYC_StateRequestMessage * | ||
1704 | req = (const struct GNUNET_PSYC_StateRequestMessage *) msg; | ||
1705 | uint16_t size = ntohs (msg->size); | ||
1706 | const char *name = (const char *) &req[1]; | ||
1707 | |||
1708 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
1709 | "%p State get #%" PRIu64 ": %s\n", | ||
1710 | plc, GNUNET_ntohll (req->op_id), name); | ||
1711 | |||
1712 | if (size < sizeof (*req) + 1 | ||
1713 | || '\0' != name[size - sizeof (*req) - 1]) | ||
1714 | { | ||
1715 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1716 | "%p State get #%" PRIu64 ": " | ||
1717 | "invalid name. size: %u < %u?\n", | ||
1718 | plc, GNUNET_ntohll (req->op_id), size, sizeof (*req) + 1); | ||
1719 | GNUNET_break (0); | ||
1720 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | ||
1721 | return; | ||
1722 | } | ||
1723 | |||
1724 | struct OperationClosure *opcls = GNUNET_malloc (sizeof (*opcls)); | ||
1725 | opcls->client = client; | ||
1726 | opcls->plc = plc; | ||
1727 | opcls->op_id = req->op_id; | ||
1728 | |||
1729 | switch (ntohs (msg->type)) | ||
1730 | { | ||
1731 | case GNUNET_MESSAGE_TYPE_PSYC_STATE_GET: | ||
1732 | GNUNET_PSYC_channel_state_get (plc->channel, name, | ||
1733 | psyc_recv_state_var, | ||
1734 | psyc_recv_state_result, opcls); | ||
1735 | break; | ||
1736 | |||
1737 | case GNUNET_MESSAGE_TYPE_PSYC_STATE_GET_PREFIX: | ||
1738 | GNUNET_PSYC_channel_state_get_prefix (plc->channel, name, | ||
1739 | psyc_recv_state_var, | ||
1740 | psyc_recv_state_result, opcls); | ||
1741 | break; | ||
1742 | |||
1743 | default: | ||
1744 | GNUNET_assert (0); | ||
1745 | } | ||
1746 | |||
1747 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | ||
1748 | } | ||
1749 | |||
1750 | |||
1638 | static const struct GNUNET_SERVER_MessageHandler handlers[] = { | 1751 | static const struct GNUNET_SERVER_MessageHandler handlers[] = { |
1639 | { &client_recv_host_enter, NULL, | 1752 | { &client_recv_host_enter, NULL, |
1640 | GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER, 0 }, | 1753 | GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER, 0 }, |
@@ -1650,13 +1763,13 @@ static const struct GNUNET_SERVER_MessageHandler handlers[] = { | |||
1650 | 1763 | ||
1651 | { &client_recv_history_replay, NULL, | 1764 | { &client_recv_history_replay, NULL, |
1652 | GNUNET_MESSAGE_TYPE_PSYC_HISTORY_REPLAY, 0 }, | 1765 | GNUNET_MESSAGE_TYPE_PSYC_HISTORY_REPLAY, 0 }, |
1653 | #if FIXME | 1766 | |
1654 | { &client_recv_state_get, NULL, | 1767 | { &client_recv_state_get, NULL, |
1655 | GNUNET_MESSAGE_TYPE_PSYC_STATE_GET, 0 }, | 1768 | GNUNET_MESSAGE_TYPE_PSYC_STATE_GET, 0 }, |
1656 | 1769 | ||
1657 | { &client_recv_state_get_prefix, NULL, | 1770 | { &client_recv_state_get, NULL, |
1658 | GNUNET_MESSAGE_TYPE_PSYC_STATE_GET_PREFIX, 0 }, | 1771 | GNUNET_MESSAGE_TYPE_PSYC_STATE_GET_PREFIX, 0 }, |
1659 | #endif | 1772 | |
1660 | { NULL, NULL, 0, 0 } | 1773 | { NULL, NULL, 0, 0 } |
1661 | }; | 1774 | }; |
1662 | 1775 | ||
diff --git a/src/social/social_api.c b/src/social/social_api.c index 74a13cc35..20d0dc8b8 100644 --- a/src/social/social_api.c +++ b/src/social/social_api.c | |||
@@ -310,6 +310,21 @@ struct GNUNET_SOCIAL_LookHandle | |||
310 | GNUNET_ResultCallback result_cb; | 310 | GNUNET_ResultCallback result_cb; |
311 | 311 | ||
312 | /** | 312 | /** |
313 | * Name of current modifier being received. | ||
314 | */ | ||
315 | char *mod_name; | ||
316 | |||
317 | /** | ||
318 | * Size of current modifier value being received. | ||
319 | */ | ||
320 | size_t mod_value_size; | ||
321 | |||
322 | /** | ||
323 | * Remaining size of current modifier value still to be received. | ||
324 | */ | ||
325 | size_t mod_value_remaining; | ||
326 | |||
327 | /** | ||
313 | * Closure for @a result_cb. | 328 | * Closure for @a result_cb. |
314 | */ | 329 | */ |
315 | void *cls; | 330 | void *cls; |
@@ -753,49 +768,66 @@ place_recv_state_result (void *cls, | |||
753 | const struct GNUNET_OperationResultMessage * | 768 | const struct GNUNET_OperationResultMessage * |
754 | res = (const struct GNUNET_OperationResultMessage *) msg; | 769 | res = (const struct GNUNET_OperationResultMessage *) msg; |
755 | 770 | ||
756 | #if FIXME | ||
757 | GNUNET_ResultCallback result_cb = NULL; | 771 | GNUNET_ResultCallback result_cb = NULL; |
758 | struct GNUNET_PSYC_StateRequest *sr = NULL; | 772 | struct GNUNET_SOCIAL_LookHandle *look = NULL; |
759 | 773 | ||
760 | if (GNUNET_YES != GNUNET_CLIENT_MANAGER_op_find (plc->client, | 774 | if (GNUNET_YES != GNUNET_CLIENT_MANAGER_op_find (plc->client, |
761 | GNUNET_ntohll (res->op_id), | 775 | GNUNET_ntohll (res->op_id), |
762 | &result_cb, (void *) &sr)) | 776 | &result_cb, (void *) &look)) |
763 | { /* Operation not found. */ | 777 | { /* Operation not found. */ |
764 | return; | 778 | return; |
765 | } | 779 | } |
766 | 780 | ||
767 | const struct GNUNET_MessageHeader * | 781 | const struct GNUNET_MessageHeader * |
768 | modc = (struct GNUNET_MessageHeader *) &res[1]; | 782 | mod = (struct GNUNET_MessageHeader *) &res[1]; |
769 | uint16_t modc_size = ntohs (modc->size); | 783 | uint16_t mod_size = ntohs (mod->size); |
770 | if (ntohs (msg->size) - sizeof (*msg) != modc_size) | 784 | if (ntohs (msg->size) - sizeof (*res) != mod_size) |
771 | { | 785 | { |
772 | GNUNET_break (0); | 786 | GNUNET_break_op (0); |
787 | LOG (GNUNET_ERROR_TYPE_WARNING, | ||
788 | "Invalid modifier size in state result: %u - %u != %u\n", | ||
789 | ntohs (msg->size), sizeof (*res), mod_size); | ||
773 | return; | 790 | return; |
774 | } | 791 | } |
775 | switch (ntohs (modc->type)) | 792 | switch (ntohs (mod->type)) |
776 | { | 793 | { |
777 | case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MODIFIER: | 794 | case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MODIFIER: |
778 | { | 795 | { |
779 | const struct GNUNET_PSYC_MessageModifier * | 796 | const struct GNUNET_PSYC_MessageModifier * |
780 | mod = (const struct GNUNET_PSYC_MessageModifier *) modc; | 797 | pmod = (const struct GNUNET_PSYC_MessageModifier *) mod; |
781 | 798 | ||
782 | const char *name = (const char *) &mod[1]; | 799 | const char *name = (const char *) &pmod[1]; |
783 | uint16_t name_size = ntohs (mod->name_size); | 800 | uint16_t name_size = ntohs (pmod->name_size); |
784 | if ('\0' != name[name_size - 1]) | 801 | if ('\0' != name[name_size - 1]) |
785 | { | 802 | { |
786 | GNUNET_break (0); | 803 | GNUNET_break_op (0); |
804 | LOG (GNUNET_ERROR_TYPE_WARNING, | ||
805 | "Invalid modifier name in state result\n"); | ||
787 | return; | 806 | return; |
788 | } | 807 | } |
789 | sr->var_cb (sr->cls, name, name + name_size, ntohs (mod->value_size)); | 808 | look->mod_value_size = ntohs (pmod->value_size); |
809 | look->var_cb (look->cls, mod, name, name + name_size, | ||
810 | mod_size - sizeof (*mod) - name_size, | ||
811 | look->mod_value_size); | ||
812 | if (look->mod_value_size > mod_size - sizeof (*mod) - name_size) | ||
813 | { | ||
814 | look->mod_value_remaining = look->mod_value_size; | ||
815 | look->mod_name = GNUNET_malloc (name_size); | ||
816 | memcpy (look->mod_name, name, name_size); | ||
817 | } | ||
790 | break; | 818 | break; |
791 | } | 819 | } |
792 | 820 | ||
793 | case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MOD_CONT: | 821 | case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MOD_CONT: |
794 | sr->var_cb (sr->cls, NULL, (const char *) &modc[1], | 822 | look->var_cb (look->cls, mod, look->mod_name, (const char *) &mod[1], |
795 | modc_size - sizeof (*modc)); | 823 | mod_size - sizeof (*mod), look->mod_value_size); |
824 | look->mod_value_remaining -= mod_size - sizeof (*mod); | ||
825 | if (0 == look->mod_value_remaining) | ||
826 | { | ||
827 | GNUNET_free (look->mod_name); | ||
828 | } | ||
796 | break; | 829 | break; |
797 | } | 830 | } |
798 | #endif | ||
799 | } | 831 | } |
800 | 832 | ||
801 | 833 | ||
@@ -1980,7 +2012,7 @@ place_state_get (struct GNUNET_SOCIAL_Place *plc, | |||
1980 | * what was requested). | 2012 | * what was requested). |
1981 | * | 2013 | * |
1982 | * @param place | 2014 | * @param place |
1983 | * The place to look the object at. | 2015 | * The place where to look. |
1984 | * @param full_name | 2016 | * @param full_name |
1985 | * Full name of the object. | 2017 | * Full name of the object. |
1986 | * @param value_size | 2018 | * @param value_size |
@@ -2004,7 +2036,7 @@ GNUNET_SOCIAL_place_look_at (struct GNUNET_SOCIAL_Place *plc, | |||
2004 | * Look for objects in the place with a matching name prefix. | 2036 | * Look for objects in the place with a matching name prefix. |
2005 | * | 2037 | * |
2006 | * @param place | 2038 | * @param place |
2007 | * The place to look its objects at. | 2039 | * The place where to look. |
2008 | * @param name_prefix | 2040 | * @param name_prefix |
2009 | * Look at objects with names beginning with this value. | 2041 | * Look at objects with names beginning with this value. |
2010 | * @param var_cb | 2042 | * @param var_cb |
diff --git a/src/social/test_social.c b/src/social/test_social.c index 19a81f43d..dbcf822f8 100644 --- a/src/social/test_social.c +++ b/src/social/test_social.c | |||
@@ -36,7 +36,7 @@ | |||
36 | #include "gnunet_core_service.h" | 36 | #include "gnunet_core_service.h" |
37 | #include "gnunet_identity_service.h" | 37 | #include "gnunet_identity_service.h" |
38 | 38 | ||
39 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) | 39 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 300) |
40 | 40 | ||
41 | #define DATA2ARG(data) data, sizeof (data) | 41 | #define DATA2ARG(data) data, sizeof (data) |
42 | 42 | ||
@@ -99,6 +99,10 @@ struct TransmitClosure | |||
99 | uint8_t n; | 99 | uint8_t n; |
100 | } tmit; | 100 | } tmit; |
101 | 101 | ||
102 | struct ResultClosure { | ||
103 | uint32_t n; | ||
104 | }; | ||
105 | |||
102 | uint8_t join_req_count; | 106 | uint8_t join_req_count; |
103 | struct GNUNET_PSYC_Message *join_resp; | 107 | struct GNUNET_PSYC_Message *join_resp; |
104 | 108 | ||
@@ -107,19 +111,21 @@ uint32_t counter; | |||
107 | enum | 111 | enum |
108 | { | 112 | { |
109 | TEST_NONE = 0, | 113 | TEST_NONE = 0, |
110 | TEST_HOST_ANSWER_DOOR_REFUSE = 1, | 114 | TEST_HOST_ANSWER_DOOR_REFUSE = 1, |
111 | TEST_GUEST_RECV_ENTRY_DCSN_REFUSE = 2, | 115 | TEST_GUEST_RECV_ENTRY_DCSN_REFUSE = 2, |
112 | TEST_HOST_ANSWER_DOOR_ADMIT = 3, | 116 | TEST_HOST_ANSWER_DOOR_ADMIT = 3, |
113 | TEST_GUEST_RECV_ENTRY_DCSN_ADMIT = 4, | 117 | TEST_GUEST_RECV_ENTRY_DCSN_ADMIT = 4, |
114 | TEST_HOST_ANNOUNCE = 5, | 118 | TEST_HOST_ANNOUNCE = 5, |
115 | TEST_HOST_ANNOUNCE_END = 6, | 119 | TEST_HOST_ANNOUNCE_END = 6, |
116 | TEST_HOST_ANNOUNCE2 = 7, | 120 | TEST_HOST_ANNOUNCE2 = 7, |
117 | TEST_HOST_ANNOUNCE2_END = 8, | 121 | TEST_HOST_ANNOUNCE2_END = 8, |
118 | TEST_GUEST_TALK = 9, | 122 | TEST_GUEST_TALK = 9, |
119 | TEST_GUEST_HISTORY_REPLAY = 10, | 123 | TEST_GUEST_HISTORY_REPLAY = 10, |
120 | TEST_GUEST_HISTORY_REPLAY_LATEST = 11, | 124 | TEST_GUEST_HISTORY_REPLAY_LATEST = 11, |
121 | TEST_GUEST_LEAVE = 12, | 125 | TEST_GUEST_LOOK_AT = 12, |
122 | TEST_HOST_LEAVE = 13, | 126 | TEST_GUEST_LOOK_FOR = 13, |
127 | TEST_GUEST_LEAVE = 14, | ||
128 | TEST_HOST_LEAVE = 15, | ||
123 | } test; | 129 | } test; |
124 | 130 | ||
125 | 131 | ||
@@ -351,6 +357,86 @@ schedule_guest_leave (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
351 | 357 | ||
352 | 358 | ||
353 | static void | 359 | static void |
360 | guest_look_for_result (void *cls, int64_t result_code, | ||
361 | const void *data, uint16_t data_size) | ||
362 | { | ||
363 | struct ResultClosure *rcls = cls; | ||
364 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
365 | "guest_look_for_result: %d\n", result_code); | ||
366 | GNUNET_assert (GNUNET_OK == result_code); | ||
367 | GNUNET_assert (3 == rcls->n); | ||
368 | GNUNET_free (rcls); | ||
369 | GNUNET_SCHEDULER_add_now (&schedule_guest_leave, NULL); | ||
370 | } | ||
371 | |||
372 | |||
373 | static void | ||
374 | guest_look_for_var (void *cls, | ||
375 | const struct GNUNET_MessageHeader *mod, | ||
376 | const char *name, | ||
377 | const void *value, | ||
378 | uint32_t value_size, | ||
379 | uint32_t full_value_size) | ||
380 | { | ||
381 | struct ResultClosure *rcls = cls; | ||
382 | rcls->n++; | ||
383 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
384 | "guest_look_for_var: %s\n%.*s\n", | ||
385 | name, value_size, value); | ||
386 | } | ||
387 | |||
388 | |||
389 | static void | ||
390 | guest_look_for () | ||
391 | { | ||
392 | test = TEST_GUEST_LOOK_FOR; | ||
393 | struct ResultClosure *rcls = GNUNET_malloc (sizeof (*rcls)); | ||
394 | GNUNET_SOCIAL_place_look_for (gst_plc, "_foo", guest_look_for_var, guest_look_for_result, rcls); | ||
395 | } | ||
396 | |||
397 | |||
398 | static void | ||
399 | guest_look_at_result (void *cls, int64_t result_code, | ||
400 | const void *data, uint16_t data_size) | ||
401 | { | ||
402 | struct ResultClosure *rcls = cls; | ||
403 | |||
404 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
405 | "guest_look_at_result: %d\n", result_code); | ||
406 | GNUNET_assert (GNUNET_OK == result_code); | ||
407 | GNUNET_assert (1 == rcls->n); | ||
408 | GNUNET_free (rcls); | ||
409 | guest_look_for (); | ||
410 | } | ||
411 | |||
412 | |||
413 | static void | ||
414 | guest_look_at_var (void *cls, | ||
415 | const struct GNUNET_MessageHeader *mod, | ||
416 | const char *name, | ||
417 | const void *value, | ||
418 | uint32_t value_size, | ||
419 | uint32_t full_value_size) | ||
420 | { | ||
421 | struct ResultClosure *rcls = cls; | ||
422 | rcls->n++; | ||
423 | |||
424 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
425 | "guest_look_at_var: %s\n%.*s\n", | ||
426 | name, value_size, value); | ||
427 | } | ||
428 | |||
429 | |||
430 | static void | ||
431 | guest_look_at () | ||
432 | { | ||
433 | test = TEST_GUEST_LOOK_AT; | ||
434 | struct ResultClosure *rcls = GNUNET_malloc (sizeof (*rcls)); | ||
435 | GNUNET_SOCIAL_place_look_at (gst_plc, "_foo_bar", guest_look_at_var, guest_look_at_result, rcls); | ||
436 | } | ||
437 | |||
438 | |||
439 | static void | ||
354 | guest_recv_history_replay_latest_result (void *cls, int64_t result, | 440 | guest_recv_history_replay_latest_result (void *cls, int64_t result, |
355 | const void *data, uint16_t data_size) | 441 | const void *data, uint16_t data_size) |
356 | { | 442 | { |
@@ -361,7 +447,7 @@ guest_recv_history_replay_latest_result (void *cls, int64_t result, | |||
361 | GNUNET_assert (2 == counter); /* message count */ | 447 | GNUNET_assert (2 == counter); /* message count */ |
362 | GNUNET_assert (7 == result); /* fragment count */ | 448 | GNUNET_assert (7 == result); /* fragment count */ |
363 | 449 | ||
364 | GNUNET_SCHEDULER_add_now (&schedule_guest_leave, NULL); | 450 | guest_look_at (); |
365 | } | 451 | } |
366 | 452 | ||
367 | 453 | ||
@@ -488,6 +574,7 @@ guest_recv_eom (void *cls, | |||
488 | break; | 574 | break; |
489 | 575 | ||
490 | default: | 576 | default: |
577 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "invalid test: %d\n", test); | ||
491 | GNUNET_assert (0); | 578 | GNUNET_assert (0); |
492 | } | 579 | } |
493 | } | 580 | } |
@@ -570,10 +657,11 @@ host_recv_eom (void *cls, | |||
570 | break; | 657 | break; |
571 | 658 | ||
572 | case TEST_GUEST_TALK: | 659 | case TEST_GUEST_TALK: |
573 | guest_history_replay (); | 660 | guest_history_replay (); |
574 | break; | 661 | break; |
575 | 662 | ||
576 | default: | 663 | default: |
664 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "invalid test: %d\n", test); | ||
577 | GNUNET_assert (0); | 665 | GNUNET_assert (0); |
578 | } | 666 | } |
579 | } | 667 | } |
@@ -624,7 +712,8 @@ host_announce () | |||
624 | tmit.host_ann | 712 | tmit.host_ann |
625 | = GNUNET_SOCIAL_host_announce (hst, "_message_host", tmit.env, | 713 | = GNUNET_SOCIAL_host_announce (hst, "_message_host", tmit.env, |
626 | ¬ify_data, &tmit, | 714 | ¬ify_data, &tmit, |
627 | GNUNET_SOCIAL_ANNOUNCE_NONE); | 715 | GNUNET_SOCIAL_ANNOUNCE_NONE |
716 | | GNUNET_PSYC_MASTER_TRANSMIT_STATE_MODIFY); | ||
628 | } | 717 | } |
629 | 718 | ||
630 | 719 | ||
@@ -689,6 +778,7 @@ guest_recv_entry_decision (void *cls, | |||
689 | break; | 778 | break; |
690 | 779 | ||
691 | default: | 780 | default: |
781 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "invalid test: %d\n", test); | ||
692 | GNUNET_assert (0); | 782 | GNUNET_assert (0); |
693 | } | 783 | } |
694 | } | 784 | } |
@@ -728,6 +818,7 @@ host_answer_door (void *cls, | |||
728 | break; | 818 | break; |
729 | 819 | ||
730 | default: | 820 | default: |
821 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "invalid test: %d\n", test); | ||
731 | GNUNET_assert (0); | 822 | GNUNET_assert (0); |
732 | } | 823 | } |
733 | } | 824 | } |