diff options
Diffstat (limited to 'src/service/reclaim/gnunet-service-reclaim.c')
-rw-r--r-- | src/service/reclaim/gnunet-service-reclaim.c | 137 |
1 files changed, 69 insertions, 68 deletions
diff --git a/src/service/reclaim/gnunet-service-reclaim.c b/src/service/reclaim/gnunet-service-reclaim.c index 47a86a3e8..2e45324c0 100644 --- a/src/service/reclaim/gnunet-service-reclaim.c +++ b/src/service/reclaim/gnunet-service-reclaim.c | |||
@@ -23,15 +23,12 @@ | |||
23 | * @brief reclaim Service | 23 | * @brief reclaim Service |
24 | * | 24 | * |
25 | */ | 25 | */ |
26 | #include "platform.h" | ||
27 | #include "gnunet_util_lib.h" | 26 | #include "gnunet_util_lib.h" |
28 | #include "gnunet-service-reclaim_tickets.h" | 27 | #include "gnunet-service-reclaim_tickets.h" |
29 | #include "gnunet_constants.h" | ||
30 | #include "gnunet_gnsrecord_lib.h" | 28 | #include "gnunet_gnsrecord_lib.h" |
31 | #include "gnunet_protocols.h" | 29 | #include "gnunet_protocols.h" |
32 | #include "gnunet_reclaim_lib.h" | 30 | #include "gnunet_reclaim_lib.h" |
33 | #include "gnunet_reclaim_service.h" | 31 | #include "gnunet_reclaim_service.h" |
34 | #include "gnunet_signatures.h" | ||
35 | #include "reclaim.h" | 32 | #include "reclaim.h" |
36 | 33 | ||
37 | 34 | ||
@@ -784,7 +781,7 @@ handle_issue_ticket_message (void *cls, const struct IssueTicketMessage *im) | |||
784 | buf = (char *) &im[1]; | 781 | buf = (char *) &im[1]; |
785 | if ((GNUNET_SYSERR == | 782 | if ((GNUNET_SYSERR == |
786 | GNUNET_CRYPTO_read_private_key_from_buffer (buf, key_len, | 783 | GNUNET_CRYPTO_read_private_key_from_buffer (buf, key_len, |
787 | &identity, &read)) || | 784 | &identity, &read)) || |
788 | (read != key_len)) | 785 | (read != key_len)) |
789 | { | 786 | { |
790 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 787 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -796,7 +793,7 @@ handle_issue_ticket_message (void *cls, const struct IssueTicketMessage *im) | |||
796 | pkey_len = ntohs (im->pkey_len); | 793 | pkey_len = ntohs (im->pkey_len); |
797 | if ((GNUNET_SYSERR == | 794 | if ((GNUNET_SYSERR == |
798 | GNUNET_CRYPTO_read_public_key_from_buffer (buf, pkey_len, | 795 | GNUNET_CRYPTO_read_public_key_from_buffer (buf, pkey_len, |
799 | &rp, &read)) || | 796 | &rp, &read)) || |
800 | (read != pkey_len)) | 797 | (read != pkey_len)) |
801 | { | 798 | { |
802 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 799 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -902,7 +899,7 @@ handle_revoke_ticket_message (void *cls, const struct RevokeTicketMessage *rm) | |||
902 | buf = (char *) &rm[1]; | 899 | buf = (char *) &rm[1]; |
903 | if ((GNUNET_SYSERR == | 900 | if ((GNUNET_SYSERR == |
904 | GNUNET_CRYPTO_read_private_key_from_buffer (buf, key_len, | 901 | GNUNET_CRYPTO_read_private_key_from_buffer (buf, key_len, |
905 | &identity, &read)) || | 902 | &identity, &read)) || |
906 | (read != key_len)) | 903 | (read != key_len)) |
907 | { | 904 | { |
908 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 905 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -978,8 +975,8 @@ consume_result_cb (void *cls, | |||
978 | crm->result = htons (success); | 975 | crm->result = htons (success); |
979 | data_tmp = (char *) &crm[1]; | 976 | data_tmp = (char *) &crm[1]; |
980 | written = GNUNET_CRYPTO_write_public_key_to_buffer (identity, | 977 | written = GNUNET_CRYPTO_write_public_key_to_buffer (identity, |
981 | data_tmp, | 978 | data_tmp, |
982 | key_len); | 979 | key_len); |
983 | GNUNET_assert (0 <= written); | 980 | GNUNET_assert (0 <= written); |
984 | data_tmp += written; | 981 | data_tmp += written; |
985 | GNUNET_RECLAIM_attribute_list_serialize (attrs, data_tmp); | 982 | GNUNET_RECLAIM_attribute_list_serialize (attrs, data_tmp); |
@@ -1037,7 +1034,7 @@ handle_consume_ticket_message (void *cls, const struct ConsumeTicketMessage *cm) | |||
1037 | buf = (char *) &cm[1]; | 1034 | buf = (char *) &cm[1]; |
1038 | if ((GNUNET_SYSERR == | 1035 | if ((GNUNET_SYSERR == |
1039 | GNUNET_CRYPTO_read_private_key_from_buffer (buf, key_len, | 1036 | GNUNET_CRYPTO_read_private_key_from_buffer (buf, key_len, |
1040 | &identity, &read)) || | 1037 | &identity, &read)) || |
1041 | (read != key_len)) | 1038 | (read != key_len)) |
1042 | { | 1039 | { |
1043 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1040 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -1142,13 +1139,13 @@ attr_store_task (void *cls) | |||
1142 | rd[0].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE; | 1139 | rd[0].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE; |
1143 | rd[0].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; | 1140 | rd[0].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; |
1144 | rd[0].expiration_time = ash->exp.rel_value_us; | 1141 | rd[0].expiration_time = ash->exp.rel_value_us; |
1145 | ash->ns_qe = GNUNET_NAMESTORE_records_store (nsh, | 1142 | ash->ns_qe = GNUNET_NAMESTORE_record_set_store (nsh, |
1146 | &ash->identity, | 1143 | &ash->identity, |
1147 | label, | 1144 | label, |
1148 | 1, | 1145 | 1, |
1149 | rd, | 1146 | rd, |
1150 | &attr_store_cont, | 1147 | &attr_store_cont, |
1151 | ash); | 1148 | ash); |
1152 | GNUNET_free (buf); | 1149 | GNUNET_free (buf); |
1153 | GNUNET_free (label); | 1150 | GNUNET_free (label); |
1154 | } | 1151 | } |
@@ -1201,7 +1198,7 @@ handle_attribute_store_message (void *cls, | |||
1201 | buf = (char *) &sam[1]; | 1198 | buf = (char *) &sam[1]; |
1202 | if ((GNUNET_SYSERR == | 1199 | if ((GNUNET_SYSERR == |
1203 | GNUNET_CRYPTO_read_private_key_from_buffer (buf, key_len, | 1200 | GNUNET_CRYPTO_read_private_key_from_buffer (buf, key_len, |
1204 | &identity, &read)) || | 1201 | &identity, &read)) || |
1205 | (read != key_len)) | 1202 | (read != key_len)) |
1206 | { | 1203 | { |
1207 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1204 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -1314,13 +1311,13 @@ cred_add_cb (void *cls, | |||
1314 | rd_new[0].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL; | 1311 | rd_new[0].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL; |
1315 | rd_new[0].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; | 1312 | rd_new[0].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; |
1316 | rd_new[0].expiration_time = ash->exp.rel_value_us; | 1313 | rd_new[0].expiration_time = ash->exp.rel_value_us; |
1317 | ash->ns_qe = GNUNET_NAMESTORE_records_store (nsh, | 1314 | ash->ns_qe = GNUNET_NAMESTORE_record_set_store (nsh, |
1318 | &ash->identity, | 1315 | &ash->identity, |
1319 | label, | 1316 | label, |
1320 | 1, | 1317 | 1, |
1321 | rd_new, | 1318 | rd_new, |
1322 | &cred_store_cont, | 1319 | &cred_store_cont, |
1323 | ash); | 1320 | ash); |
1324 | GNUNET_free (buf); | 1321 | GNUNET_free (buf); |
1325 | return; | 1322 | return; |
1326 | } | 1323 | } |
@@ -1402,7 +1399,7 @@ handle_credential_store_message (void *cls, | |||
1402 | buf = (char *) &sam[1]; | 1399 | buf = (char *) &sam[1]; |
1403 | if ((GNUNET_SYSERR == | 1400 | if ((GNUNET_SYSERR == |
1404 | GNUNET_CRYPTO_read_private_key_from_buffer (buf, key_len, | 1401 | GNUNET_CRYPTO_read_private_key_from_buffer (buf, key_len, |
1405 | &identity, &read)) || | 1402 | &identity, &read)) || |
1406 | (read != key_len)) | 1403 | (read != key_len)) |
1407 | { | 1404 | { |
1408 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1405 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -1641,13 +1638,13 @@ update_tickets (void *cls) | |||
1641 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1638 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1642 | "Updating ticket with %d entries (%d before)...\n", | 1639 | "Updating ticket with %d entries (%d before)...\n", |
1643 | j, i); | 1640 | j, i); |
1644 | adh->ns_qe = GNUNET_NAMESTORE_records_store (nsh, | 1641 | adh->ns_qe = GNUNET_NAMESTORE_record_set_store (nsh, |
1645 | &adh->identity, | 1642 | &adh->identity, |
1646 | le->label, | 1643 | le->label, |
1647 | j, | 1644 | j, |
1648 | rd_new, | 1645 | rd_new, |
1649 | &ticket_updated, | 1646 | &ticket_updated, |
1650 | adh); | 1647 | adh); |
1651 | GNUNET_free (le->label); | 1648 | GNUNET_free (le->label); |
1652 | GNUNET_free (le->data); | 1649 | GNUNET_free (le->data); |
1653 | GNUNET_free (le); | 1650 | GNUNET_free (le); |
@@ -1727,13 +1724,13 @@ purge_attributes (void *cls) | |||
1727 | = GNUNET_STRINGS_data_to_string_alloc (&ale->attribute->id, | 1724 | = GNUNET_STRINGS_data_to_string_alloc (&ale->attribute->id, |
1728 | sizeof(ale->attribute->id)); | 1725 | sizeof(ale->attribute->id)); |
1729 | 1726 | ||
1730 | adh->ns_qe = GNUNET_NAMESTORE_records_store (nsh, | 1727 | adh->ns_qe = GNUNET_NAMESTORE_record_set_store (nsh, |
1731 | &adh->identity, | 1728 | &adh->identity, |
1732 | label, | 1729 | label, |
1733 | 0, | 1730 | 0, |
1734 | NULL, | 1731 | NULL, |
1735 | &offending_attr_delete_cont, | 1732 | &offending_attr_delete_cont, |
1736 | adh); | 1733 | adh); |
1737 | GNUNET_CONTAINER_DLL_remove (adh->existing_attributes->list_head, | 1734 | GNUNET_CONTAINER_DLL_remove (adh->existing_attributes->list_head, |
1738 | adh->existing_attributes->list_tail, | 1735 | adh->existing_attributes->list_tail, |
1739 | ale); | 1736 | ale); |
@@ -1873,7 +1870,7 @@ handle_attribute_delete_message (void *cls, | |||
1873 | buf = (char *) &dam[1]; | 1870 | buf = (char *) &dam[1]; |
1874 | if ((GNUNET_SYSERR == | 1871 | if ((GNUNET_SYSERR == |
1875 | GNUNET_CRYPTO_read_private_key_from_buffer (buf, key_len, | 1872 | GNUNET_CRYPTO_read_private_key_from_buffer (buf, key_len, |
1876 | &identity, &read)) || | 1873 | &identity, &read)) || |
1877 | (read != key_len)) | 1874 | (read != key_len)) |
1878 | { | 1875 | { |
1879 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1876 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -1896,13 +1893,13 @@ handle_attribute_delete_message (void *cls, | |||
1896 | GNUNET_SERVICE_client_continue (idp->client); | 1893 | GNUNET_SERVICE_client_continue (idp->client); |
1897 | adh->client = idp; | 1894 | adh->client = idp; |
1898 | GNUNET_CONTAINER_DLL_insert (idp->delete_op_head, idp->delete_op_tail, adh); | 1895 | GNUNET_CONTAINER_DLL_insert (idp->delete_op_head, idp->delete_op_tail, adh); |
1899 | adh->ns_qe = GNUNET_NAMESTORE_records_store (nsh, | 1896 | adh->ns_qe = GNUNET_NAMESTORE_record_set_store (nsh, |
1900 | &adh->identity, | 1897 | &adh->identity, |
1901 | adh->label, | 1898 | adh->label, |
1902 | 0, | 1899 | 0, |
1903 | NULL, | 1900 | NULL, |
1904 | &attr_delete_cont, | 1901 | &attr_delete_cont, |
1905 | adh); | 1902 | adh); |
1906 | } | 1903 | } |
1907 | 1904 | ||
1908 | 1905 | ||
@@ -1980,7 +1977,7 @@ handle_credential_delete_message (void *cls, | |||
1980 | buf = (char *) &dam[1]; | 1977 | buf = (char *) &dam[1]; |
1981 | if ((GNUNET_SYSERR == | 1978 | if ((GNUNET_SYSERR == |
1982 | GNUNET_CRYPTO_read_private_key_from_buffer (buf, key_len, | 1979 | GNUNET_CRYPTO_read_private_key_from_buffer (buf, key_len, |
1983 | &identity, &read)) || | 1980 | &identity, &read)) || |
1984 | (read != key_len)) | 1981 | (read != key_len)) |
1985 | { | 1982 | { |
1986 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1983 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -2002,13 +1999,13 @@ handle_credential_delete_message (void *cls, | |||
2002 | GNUNET_SERVICE_client_continue (idp->client); | 1999 | GNUNET_SERVICE_client_continue (idp->client); |
2003 | adh->client = idp; | 2000 | adh->client = idp; |
2004 | GNUNET_CONTAINER_DLL_insert (idp->delete_op_head, idp->delete_op_tail, adh); | 2001 | GNUNET_CONTAINER_DLL_insert (idp->delete_op_head, idp->delete_op_tail, adh); |
2005 | adh->ns_qe = GNUNET_NAMESTORE_records_store (nsh, | 2002 | adh->ns_qe = GNUNET_NAMESTORE_record_set_store (nsh, |
2006 | &adh->identity, | 2003 | &adh->identity, |
2007 | adh->label, | 2004 | adh->label, |
2008 | 0, | 2005 | 0, |
2009 | NULL, | 2006 | NULL, |
2010 | &cred_delete_cont, | 2007 | &cred_delete_cont, |
2011 | adh); | 2008 | adh); |
2012 | } | 2009 | } |
2013 | 2010 | ||
2014 | 2011 | ||
@@ -2101,8 +2098,8 @@ attr_iter_cb (void *cls, | |||
2101 | data_tmp = (char *) &arm[1]; | 2098 | data_tmp = (char *) &arm[1]; |
2102 | arm->pkey_len = htons (key_len); | 2099 | arm->pkey_len = htons (key_len); |
2103 | written = GNUNET_CRYPTO_write_public_key_to_buffer (&identity, | 2100 | written = GNUNET_CRYPTO_write_public_key_to_buffer (&identity, |
2104 | data_tmp, | 2101 | data_tmp, |
2105 | key_len); | 2102 | key_len); |
2106 | GNUNET_assert (0 <= written); | 2103 | GNUNET_assert (0 <= written); |
2107 | data_tmp += written; | 2104 | data_tmp += written; |
2108 | GNUNET_memcpy (data_tmp, rd->data, rd->data_size); | 2105 | GNUNET_memcpy (data_tmp, rd->data, rd->data_size); |
@@ -2129,6 +2126,7 @@ check_iteration_start ( | |||
2129 | return GNUNET_OK; | 2126 | return GNUNET_OK; |
2130 | } | 2127 | } |
2131 | 2128 | ||
2129 | |||
2132 | /** | 2130 | /** |
2133 | * Iterate over zone to get attributes | 2131 | * Iterate over zone to get attributes |
2134 | * | 2132 | * |
@@ -2150,9 +2148,9 @@ handle_iteration_start (void *cls, | |||
2150 | key_len = ntohs (ais_msg->key_len); | 2148 | key_len = ntohs (ais_msg->key_len); |
2151 | if ((GNUNET_SYSERR == | 2149 | if ((GNUNET_SYSERR == |
2152 | GNUNET_CRYPTO_read_private_key_from_buffer (&ais_msg[1], | 2150 | GNUNET_CRYPTO_read_private_key_from_buffer (&ais_msg[1], |
2153 | key_len, | 2151 | key_len, |
2154 | &identity, | 2152 | &identity, |
2155 | &read)) || | 2153 | &read)) || |
2156 | (read != key_len)) | 2154 | (read != key_len)) |
2157 | { | 2155 | { |
2158 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 2156 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -2331,14 +2329,15 @@ cred_iter_cb (void *cls, | |||
2331 | arm->key_len = htons (key_len); | 2329 | arm->key_len = htons (key_len); |
2332 | data_tmp = (char *) &arm[1]; | 2330 | data_tmp = (char *) &arm[1]; |
2333 | written = GNUNET_CRYPTO_write_public_key_to_buffer (&identity, | 2331 | written = GNUNET_CRYPTO_write_public_key_to_buffer (&identity, |
2334 | data_tmp, | 2332 | data_tmp, |
2335 | key_len); | 2333 | key_len); |
2336 | GNUNET_assert (written >= 0); | 2334 | GNUNET_assert (written >= 0); |
2337 | data_tmp += written; | 2335 | data_tmp += written; |
2338 | GNUNET_memcpy (data_tmp, rd->data, rd->data_size); | 2336 | GNUNET_memcpy (data_tmp, rd->data, rd->data_size); |
2339 | GNUNET_MQ_send (ai->client->mq, env); | 2337 | GNUNET_MQ_send (ai->client->mq, env); |
2340 | } | 2338 | } |
2341 | 2339 | ||
2340 | |||
2342 | static enum GNUNET_GenericReturnValue | 2341 | static enum GNUNET_GenericReturnValue |
2343 | check_credential_iteration_start ( | 2342 | check_credential_iteration_start ( |
2344 | void *cls, | 2343 | void *cls, |
@@ -2381,9 +2380,9 @@ handle_credential_iteration_start (void *cls, | |||
2381 | key_len = ntohs (ais_msg->key_len); | 2380 | key_len = ntohs (ais_msg->key_len); |
2382 | if ((GNUNET_SYSERR == | 2381 | if ((GNUNET_SYSERR == |
2383 | GNUNET_CRYPTO_read_private_key_from_buffer (&ais_msg[1], | 2382 | GNUNET_CRYPTO_read_private_key_from_buffer (&ais_msg[1], |
2384 | key_len, | 2383 | key_len, |
2385 | &identity, | 2384 | &identity, |
2386 | &read)) || | 2385 | &read)) || |
2387 | (read != key_len)) | 2386 | (read != key_len)) |
2388 | { | 2387 | { |
2389 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 2388 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -2524,6 +2523,7 @@ ticket_iter_cb (void *cls, struct GNUNET_RECLAIM_Ticket *ticket) | |||
2524 | GNUNET_free (ti); | 2523 | GNUNET_free (ti); |
2525 | } | 2524 | } |
2526 | 2525 | ||
2526 | |||
2527 | static enum GNUNET_GenericReturnValue | 2527 | static enum GNUNET_GenericReturnValue |
2528 | check_ticket_iteration_start ( | 2528 | check_ticket_iteration_start ( |
2529 | void *cls, | 2529 | void *cls, |
@@ -2543,6 +2543,7 @@ check_ticket_iteration_start ( | |||
2543 | return GNUNET_OK; | 2543 | return GNUNET_OK; |
2544 | } | 2544 | } |
2545 | 2545 | ||
2546 | |||
2546 | /** | 2547 | /** |
2547 | * Client requests a ticket iteration | 2548 | * Client requests a ticket iteration |
2548 | * | 2549 | * |
@@ -2565,9 +2566,9 @@ handle_ticket_iteration_start ( | |||
2565 | key_len = ntohs (tis_msg->key_len); | 2566 | key_len = ntohs (tis_msg->key_len); |
2566 | if ((GNUNET_SYSERR == | 2567 | if ((GNUNET_SYSERR == |
2567 | GNUNET_CRYPTO_read_private_key_from_buffer (&tis_msg[1], | 2568 | GNUNET_CRYPTO_read_private_key_from_buffer (&tis_msg[1], |
2568 | key_len, | 2569 | key_len, |
2569 | &identity, | 2570 | &identity, |
2570 | &read)) || | 2571 | &read)) || |
2571 | (read != key_len)) | 2572 | (read != key_len)) |
2572 | { | 2573 | { |
2573 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 2574 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |