aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/include/gnunet_protocols.h90
-rw-r--r--src/include/gnunet_reclaim_plugin.h123
-rw-r--r--src/include/gnunet_reclaim_service.h19
-rw-r--r--src/reclaim/gnunet-reclaim.c61
-rw-r--r--src/reclaim/gnunet-service-reclaim.c356
-rw-r--r--src/reclaim/gnunet-service-reclaim_tickets.c126
-rw-r--r--src/reclaim/gnunet-service-reclaim_tickets.h37
-rw-r--r--src/reclaim/reclaim.h54
-rw-r--r--src/reclaim/reclaim_api.c58
9 files changed, 612 insertions, 312 deletions
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h
index f461249eb..e402460c0 100644
--- a/src/include/gnunet_protocols.h
+++ b/src/include/gnunet_protocols.h
@@ -43,9 +43,8 @@
43#define GNUNET_PROTOCOLS_H 43#define GNUNET_PROTOCOLS_H
44 44
45#ifdef __cplusplus 45#ifdef __cplusplus
46extern "C" 46extern "C" {
47{ 47#if 0 /* keep Emacsens' auto-indent happy */
48#if 0 /* keep Emacsens' auto-indent happy */
49} 48}
50#endif 49#endif
51#endif 50#endif
@@ -252,7 +251,8 @@ extern "C"
252#define GNUNET_MESSAGE_TYPE_DV_DISCONNECT 50 251#define GNUNET_MESSAGE_TYPE_DV_DISCONNECT 50
253 252
254/** 253/**
255 * P2P DV message telling plugin that a message transmission failed (negative ACK) 254 * P2P DV message telling plugin that a message transmission failed (negative
255 * ACK)
256 */ 256 */
257#define GNUNET_MESSAGE_TYPE_DV_SEND_NACK 51 257#define GNUNET_MESSAGE_TYPE_DV_SEND_NACK 51
258 258
@@ -622,37 +622,37 @@ extern "C"
622/** 622/**
623 * Receive information about transiting GETs 623 * Receive information about transiting GETs
624 */ 624 */
625#define GNUNET_MESSAGE_TYPE_DHT_MONITOR_GET 149 625#define GNUNET_MESSAGE_TYPE_DHT_MONITOR_GET 149
626 626
627/** 627/**
628 * Receive information about transiting GET responses 628 * Receive information about transiting GET responses
629 */ 629 */
630#define GNUNET_MESSAGE_TYPE_DHT_MONITOR_GET_RESP 150 630#define GNUNET_MESSAGE_TYPE_DHT_MONITOR_GET_RESP 150
631 631
632/** 632/**
633 * Receive information about transiting PUTs 633 * Receive information about transiting PUTs
634 */ 634 */
635#define GNUNET_MESSAGE_TYPE_DHT_MONITOR_PUT 151 635#define GNUNET_MESSAGE_TYPE_DHT_MONITOR_PUT 151
636 636
637/** 637/**
638 * Receive information about transiting PUT responses (TODO) 638 * Receive information about transiting PUT responses (TODO)
639 */ 639 */
640#define GNUNET_MESSAGE_TYPE_DHT_MONITOR_PUT_RESP 152 640#define GNUNET_MESSAGE_TYPE_DHT_MONITOR_PUT_RESP 152
641 641
642/** 642/**
643 * Request information about transiting messages 643 * Request information about transiting messages
644 */ 644 */
645#define GNUNET_MESSAGE_TYPE_DHT_MONITOR_START 153 645#define GNUNET_MESSAGE_TYPE_DHT_MONITOR_START 153
646 646
647/** 647/**
648 * Stop information about transiting messages 648 * Stop information about transiting messages
649 */ 649 */
650#define GNUNET_MESSAGE_TYPE_DHT_MONITOR_STOP 154 650#define GNUNET_MESSAGE_TYPE_DHT_MONITOR_STOP 154
651 651
652/** 652/**
653 * Certain results are already known to the client, filter those. 653 * Certain results are already known to the client, filter those.
654 */ 654 */
655#define GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET_RESULTS_KNOWN 156 655#define GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET_RESULTS_KNOWN 156
656 656
657/** 657/**
658 * Further X-VINE DHT messages continued from 880 658 * Further X-VINE DHT messages continued from 880
@@ -829,7 +829,6 @@ extern "C"
829#define GNUNET_MESSAGE_TYPE_DNS_HELPER 214 829#define GNUNET_MESSAGE_TYPE_DNS_HELPER 214
830 830
831 831
832
833/******************************************************************************* 832/*******************************************************************************
834 * CHAT message types START 833 * CHAT message types START
835 ******************************************************************************/ 834 ******************************************************************************/
@@ -1490,7 +1489,8 @@ extern "C"
1490#define GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_CONFIGURATION 480 1489#define GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_CONFIGURATION 480
1491 1490
1492/** 1491/**
1493 * Message to signal the result of #GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS request 1492 * Message to signal the result of #GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS
1493 * request
1494 */ 1494 */
1495#define GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT 481 1495#define GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT 481
1496 1496
@@ -1600,8 +1600,8 @@ extern "C"
1600#define GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_CONCLUDE 524 1600#define GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_CONCLUDE 524
1601 1601
1602/** 1602/**
1603 * Sent by service to client in order to signal a completed consensus conclusion. 1603 * Sent by service to client in order to signal a completed consensus
1604 * Last message sent in a consensus session. 1604 * conclusion. Last message sent in a consensus session.
1605 */ 1605 */
1606#define GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_CONCLUDE_DONE 525 1606#define GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_CONCLUDE_DONE 525
1607 1607
@@ -1646,7 +1646,8 @@ extern "C"
1646#define GNUNET_MESSAGE_TYPE_CONSENSUS_P2P_HELLO 546 1646#define GNUNET_MESSAGE_TYPE_CONSENSUS_P2P_HELLO 546
1647 1647
1648/** 1648/**
1649 * Report that the peer is synced with the partner after successfuly decoding the invertible bloom filter. 1649 * Report that the peer is synced with the partner after successfuly decoding
1650 * the invertible bloom filter.
1650 */ 1651 */
1651#define GNUNET_MESSAGE_TYPE_CONSENSUS_P2P_SYNCED 547 1652#define GNUNET_MESSAGE_TYPE_CONSENSUS_P2P_SYNCED 547
1652 1653
@@ -1871,7 +1872,6 @@ extern "C"
1871#define GNUNET_MESSAGE_TYPE_TESTBED_LOGGER_ACK 601 1872#define GNUNET_MESSAGE_TYPE_TESTBED_LOGGER_ACK 601
1872 1873
1873 1874
1874
1875/** 1875/**
1876 * Advertise regex capability. 1876 * Advertise regex capability.
1877 */ 1877 */
@@ -2023,9 +2023,6 @@ extern "C"
2023#define GNUNET_MESSAGE_TYPE_SCALARPRODUCT_ECC_BOB_CRYPTODATA 652 2023#define GNUNET_MESSAGE_TYPE_SCALARPRODUCT_ECC_BOB_CRYPTODATA 652
2024 2024
2025 2025
2026
2027
2028
2029/******************************************************************************* 2026/*******************************************************************************
2030 * PSYCSTORE message types 2027 * PSYCSTORE message types
2031 ******************************************************************************/ 2028 ******************************************************************************/
@@ -2122,8 +2119,10 @@ extern "C"
2122/** S<--C: PSYC message which contains one or more message parts. */ 2119/** S<--C: PSYC message which contains one or more message parts. */
2123#define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE 691 2120#define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE 691
2124 2121
2125/** M<->S<->C: PSYC message which contains a header and one or more message parts. */ 2122/** M<->S<->C: PSYC message which contains a header and one or more message
2126#define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_HEADER 692 // FIXME: start using this where appropriate 2123 * parts. */
2124#define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_HEADER \
2125 692 // FIXME: start using this where appropriate
2127 2126
2128/** Message part: method */ 2127/** Message part: method */
2129#define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD 693 2128#define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD 693
@@ -2333,7 +2332,6 @@ extern "C"
2333#define GNUNET_MESSAGE_TYPE_MULTICAST_REPLAY_RESPONSE_END 762 2332#define GNUNET_MESSAGE_TYPE_MULTICAST_REPLAY_RESPONSE_END 762
2334 2333
2335 2334
2336
2337/******************************************************************************* 2335/*******************************************************************************
2338 * SECRETSHARING message types 2336 * SECRETSHARING message types
2339 ******************************************************************************/ 2337 ******************************************************************************/
@@ -2544,7 +2542,7 @@ extern "C"
2544/** 2542/**
2545 * Acknowledge receiving ACT MALICIOUS request 2543 * Acknowledge receiving ACT MALICIOUS request
2546 */ 2544 */
2547#define GNUNET_MESSAGE_TYPE_DHT_CLIENT_ACT_MALICIOUS_OK 894 2545#define GNUNET_MESSAGE_TYPE_DHT_CLIENT_ACT_MALICIOUS_OK 894
2548 2546
2549#endif 2547#endif
2550 2548
@@ -2606,23 +2604,22 @@ extern "C"
2606/** 2604/**
2607 * RPS check liveliness message to check liveliness of other peer 2605 * RPS check liveliness message to check liveliness of other peer
2608 */ 2606 */
2609#define GNUNET_MESSAGE_TYPE_RPS_PP_CHECK_LIVE 950 2607#define GNUNET_MESSAGE_TYPE_RPS_PP_CHECK_LIVE 950
2610 2608
2611/** 2609/**
2612 * RPS PUSH message to push own ID to another peer 2610 * RPS PUSH message to push own ID to another peer
2613 */ 2611 */
2614#define GNUNET_MESSAGE_TYPE_RPS_PP_PUSH 951 2612#define GNUNET_MESSAGE_TYPE_RPS_PP_PUSH 951
2615 2613
2616/** 2614/**
2617 * RPS PULL REQUEST message to request the local view of another peer 2615 * RPS PULL REQUEST message to request the local view of another peer
2618 */ 2616 */
2619#define GNUNET_MESSAGE_TYPE_RPS_PP_PULL_REQUEST 952 2617#define GNUNET_MESSAGE_TYPE_RPS_PP_PULL_REQUEST 952
2620 2618
2621/** 2619/**
2622 * RPS PULL REPLY message which contains the view of the other peer 2620 * RPS PULL REPLY message which contains the view of the other peer
2623 */ 2621 */
2624#define GNUNET_MESSAGE_TYPE_RPS_PP_PULL_REPLY 953 2622#define GNUNET_MESSAGE_TYPE_RPS_PP_PULL_REPLY 953
2625
2626 2623
2627 2624
2628/* Client-Service Messages */ 2625/* Client-Service Messages */
@@ -2631,25 +2628,25 @@ extern "C"
2631/** 2628/**
2632 * RPS CS SEED Message for the Client to seed peers into rps 2629 * RPS CS SEED Message for the Client to seed peers into rps
2633 */ 2630 */
2634#define GNUNET_MESSAGE_TYPE_RPS_CS_SEED 954 2631#define GNUNET_MESSAGE_TYPE_RPS_CS_SEED 954
2635 2632
2636#if ENABLE_MALICIOUS 2633#if ENABLE_MALICIOUS
2637/** 2634/**
2638 * Turn RPS service malicious 2635 * Turn RPS service malicious
2639 */ 2636 */
2640#define GNUNET_MESSAGE_TYPE_RPS_ACT_MALICIOUS 955 2637#define GNUNET_MESSAGE_TYPE_RPS_ACT_MALICIOUS 955
2641 2638
2642#endif /* ENABLE_MALICIOUS */ 2639#endif /* ENABLE_MALICIOUS */
2643 2640
2644/** 2641/**
2645 * RPS client-service message to start a sub sampler 2642 * RPS client-service message to start a sub sampler
2646 */ 2643 */
2647#define GNUNET_MESSAGE_TYPE_RPS_CS_SUB_START 956 2644#define GNUNET_MESSAGE_TYPE_RPS_CS_SUB_START 956
2648 2645
2649/** 2646/**
2650 * RPS client-service message to stop a sub sampler 2647 * RPS client-service message to stop a sub sampler
2651 */ 2648 */
2652#define GNUNET_MESSAGE_TYPE_RPS_CS_SUB_STOP 957 2649#define GNUNET_MESSAGE_TYPE_RPS_CS_SUB_STOP 957
2653 2650
2654/* Debugging API continues at 1130 */ 2651/* Debugging API continues at 1130 */
2655 2652
@@ -2662,7 +2659,7 @@ extern "C"
2662 */ 2659 */
2663#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE 961 2660#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE 961
2664 2661
2665#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE_RESPONSE 962 2662#define GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE 962
2666 2663
2667#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START 963 2664#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START 963
2668 2665
@@ -2690,11 +2687,13 @@ extern "C"
2690 2687
2691#define GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_NEXT 975 2688#define GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_NEXT 975
2692 2689
2690#define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE 976
2691
2693/************************************************** 2692/**************************************************
2694 * 2693 *
2695 * CREDENTIAL MESSAGE TYPES 2694 * CREDENTIAL MESSAGE TYPES
2696 */ 2695 */
2697#define GNUNET_MESSAGE_TYPE_CREDENTIAL_VERIFY 981 2696#define GNUNET_MESSAGE_TYPE_CREDENTIAL_VERIFY 981
2698 2697
2699#define GNUNET_MESSAGE_TYPE_CREDENTIAL_VERIFY_RESULT 982 2698#define GNUNET_MESSAGE_TYPE_CREDENTIAL_VERIFY_RESULT 982
2700 2699
@@ -2776,7 +2775,6 @@ extern "C"
2776#define GNUNET_MESSAGE_TYPE_CADET_TUNNEL_KX_AUTH 1009 2775#define GNUNET_MESSAGE_TYPE_CADET_TUNNEL_KX_AUTH 1009
2777 2776
2778 2777
2779
2780/********************************** Channel *********************************/ 2778/********************************** Channel *********************************/
2781 2779
2782/** 2780/**
@@ -2964,7 +2962,8 @@ extern "C"
2964#define GNUNET_MESSAGE_TYPE_NAT_AUTO_CFG_RESULT 1068 2962#define GNUNET_MESSAGE_TYPE_NAT_AUTO_CFG_RESULT 1068
2965 2963
2966 2964
2967/* 1080-1109 reserved for TMCG (Heiko Stamer, see gnunet-developers, January 2017) */ 2965/* 1080-1109 reserved for TMCG (Heiko Stamer, see gnunet-developers, January
2966 * 2017) */
2968 2967
2969 2968
2970/******************************************************************************/ 2969/******************************************************************************/
@@ -2987,7 +2986,6 @@ extern "C"
2987#define GNUNET_MESSAGE_TYPE_AUCTION_CLIENT_OUTCOME 1112 2986#define GNUNET_MESSAGE_TYPE_AUCTION_CLIENT_OUTCOME 1112
2988 2987
2989 2988
2990
2991/******************************************************************************/ 2989/******************************************************************************/
2992/********************************* RPS DEBUG ********************************/ 2990/********************************* RPS DEBUG ********************************/
2993/******************************************************************************/ 2991/******************************************************************************/
@@ -3000,12 +2998,12 @@ extern "C"
3000/** 2998/**
3001 * @brief Send update of the view 2999 * @brief Send update of the view
3002 */ 3000 */
3003#define GNUNET_MESSAGE_TYPE_RPS_CS_DEBUG_VIEW_REPLY 1131 3001#define GNUNET_MESSAGE_TYPE_RPS_CS_DEBUG_VIEW_REPLY 1131
3004 3002
3005/** 3003/**
3006 * @brief Cancel getting updates of the view 3004 * @brief Cancel getting updates of the view
3007 */ 3005 */
3008#define GNUNET_MESSAGE_TYPE_RPS_CS_DEBUG_VIEW_CANCEL 1132 3006#define GNUNET_MESSAGE_TYPE_RPS_CS_DEBUG_VIEW_CANCEL 1132
3009 3007
3010 3008
3011/** 3009/**
@@ -3016,12 +3014,12 @@ extern "C"
3016/** 3014/**
3017 * @brief Send peer of biased stream 3015 * @brief Send peer of biased stream
3018 */ 3016 */
3019#define GNUNET_MESSAGE_TYPE_RPS_CS_DEBUG_STREAM_REPLY 1134 3017#define GNUNET_MESSAGE_TYPE_RPS_CS_DEBUG_STREAM_REPLY 1134
3020 3018
3021/** 3019/**
3022 * @brief Cancel getting biased strem 3020 * @brief Cancel getting biased strem
3023 */ 3021 */
3024#define GNUNET_MESSAGE_TYPE_RPS_CS_DEBUG_STREAM_CANCEL 1135 3022#define GNUNET_MESSAGE_TYPE_RPS_CS_DEBUG_STREAM_CANCEL 1135
3025 3023
3026 3024
3027/******************************************************* 3025/*******************************************************
@@ -3190,8 +3188,8 @@ extern "C"
3190#define GNUNET_MESSAGE_TYPE_TRANSPORT_SUGGEST_CANCEL 1301 3188#define GNUNET_MESSAGE_TYPE_TRANSPORT_SUGGEST_CANCEL 1301
3191 3189
3192/** 3190/**
3193 * Type of the 'struct RequestHelloValidationMessage' send by clients to TRANSPORT 3191 * Type of the 'struct RequestHelloValidationMessage' send by clients to
3194 * to trigger validation of addresses. 3192 * TRANSPORT to trigger validation of addresses.
3195 */ 3193 */
3196#define GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_HELLO_VALIDATION 1302 3194#define GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_HELLO_VALIDATION 1302
3197 3195
@@ -3207,7 +3205,6 @@ extern "C"
3207#define GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_RESPONSE 1304 3205#define GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_RESPONSE 1304
3208 3206
3209 3207
3210
3211/* ************** NEW (NG) ATS Messages ************* */ 3208/* ************** NEW (NG) ATS Messages ************* */
3212/* NOTE: it is not clear ATS will survive in TNG */ 3209/* NOTE: it is not clear ATS will survive in TNG */
3213 3210
@@ -3286,14 +3283,13 @@ extern "C"
3286 */ 3283 */
3287 3284
3288 3285
3289
3290/** 3286/**
3291 * Type used to match 'all' message types. 3287 * Type used to match 'all' message types.
3292 */ 3288 */
3293#define GNUNET_MESSAGE_TYPE_ALL 65535 3289#define GNUNET_MESSAGE_TYPE_ALL 65535
3294 3290
3295 3291
3296#if 0 /* keep Emacsens' auto-indent happy */ 3292#if 0 /* keep Emacsens' auto-indent happy */
3297{ 3293{
3298#endif 3294#endif
3299#ifdef __cplusplus 3295#ifdef __cplusplus
diff --git a/src/include/gnunet_reclaim_plugin.h b/src/include/gnunet_reclaim_plugin.h
deleted file mode 100644
index 72a4bc218..000000000
--- a/src/include/gnunet_reclaim_plugin.h
+++ /dev/null
@@ -1,123 +0,0 @@
1/*
2 This file is part of GNUnet
3 Copyright (C) 2012, 2013 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19*/
20
21/**
22 * @author Martin Schanzenbach
23 *
24 * @file
25 * Plugin API for the idp database backend
26 *
27 * @defgroup reclaim-plugin IdP service plugin API
28 * Plugin API for the idp database backend
29 * @{
30 */
31#ifndef GNUNET_RECLAIM_PLUGIN_H
32#define GNUNET_RECLAIM_PLUGIN_H
33
34#include "gnunet_util_lib.h"
35#include "gnunet_reclaim_service.h"
36
37#ifdef __cplusplus
38extern "C"
39{
40#if 0 /* keep Emacsens' auto-indent happy */
41}
42#endif
43#endif
44
45
46/**
47 * Function called by for each matching ticket.
48 *
49 * @param cls closure
50 * @param ticket the ticket
51 */
52typedef void (*GNUNET_RECLAIM_TicketIterator) (void *cls,
53 const struct GNUNET_RECLAIM_Ticket *ticket,
54 const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs);
55
56
57/**
58 * @brief struct returned by the initialization function of the plugin
59 */
60struct GNUNET_RECLAIM_PluginFunctions
61{
62
63 /**
64 * Closure to pass to all plugin functions.
65 */
66 void *cls;
67
68 /**
69 * Store a ticket in the database.
70 *
71 * @param cls closure (internal context for the plugin)
72 * @param ticket the ticket to store
73 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
74 */
75 int (*store_ticket) (void *cls,
76 const struct GNUNET_RECLAIM_Ticket *ticket,
77 const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs);
78
79 /**
80 * Delete a ticket from the database.
81 *
82 * @param cls closure (internal context for the plugin)
83 * @param ticket the ticket to store
84 * @return #GNUNET_OK on success, else #GNUNET_SYSERR
85 */
86 int (*delete_ticket) (void *cls,
87 const struct GNUNET_RECLAIM_Ticket *ticket);
88
89
90
91 /**
92 * Iterate over all tickets
93 *
94 * @param cls closure (internal context for the plugin)
95 * @param identity the identity
96 * @param audience GNUNET_YES if the identity is the audience of the ticket
97 * else it is considered the issuer
98 * @param iter function to call with the result
99 * @param iter_cls closure for @a iter
100 * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error
101 */
102 int (*iterate_tickets) (void *cls,
103 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
104 int audience,
105 uint64_t offset,
106 GNUNET_RECLAIM_TicketIterator iter, void *iter_cls);
107
108 int (*get_ticket_attributes) (void* cls,
109 const struct GNUNET_RECLAIM_Ticket *ticket,
110 GNUNET_RECLAIM_TicketIterator iter,
111 void *iter_cls);
112};
113
114#if 0 /* keep Emacsens' auto-indent happy */
115{
116#endif
117#ifdef __cplusplus
118}
119#endif
120
121#endif
122
123/** @} */ /* end of group */
diff --git a/src/include/gnunet_reclaim_service.h b/src/include/gnunet_reclaim_service.h
index d179485bb..fc3d0f920 100644
--- a/src/include/gnunet_reclaim_service.h
+++ b/src/include/gnunet_reclaim_service.h
@@ -151,6 +151,25 @@ GNUNET_RECLAIM_attribute_store (
151 151
152 152
153/** 153/**
154 * Delete an attribute. Tickets used to share this attribute are updated
155 * accordingly.
156 *
157 * @param h handle to the re:claimID service
158 * @param pkey Private key of the identity to add an attribute to
159 * @param attr The attribute
160 * @param cont Continuation to call when done
161 * @param cont_cls Closure for @a cont
162 * @return handle Used to to abort the request
163 */
164struct GNUNET_RECLAIM_Operation *
165GNUNET_RECLAIM_attribute_delete (
166 struct GNUNET_RECLAIM_Handle *h,
167 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
168 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr,
169 GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls);
170
171
172/**
154 * List all attributes for a local identity. 173 * List all attributes for a local identity.
155 * This MUST lock the `struct GNUNET_RECLAIM_Handle` 174 * This MUST lock the `struct GNUNET_RECLAIM_Handle`
156 * for any other calls than #GNUNET_RECLAIM_get_attributes_next() and 175 * for any other calls than #GNUNET_RECLAIM_get_attributes_next() and
diff --git a/src/reclaim/gnunet-reclaim.c b/src/reclaim/gnunet-reclaim.c
index 1c3b4174d..a9d6f67d2 100644
--- a/src/reclaim/gnunet-reclaim.c
+++ b/src/reclaim/gnunet-reclaim.c
@@ -157,6 +157,16 @@ static struct GNUNET_SCHEDULER_Task *cleanup_task;
157 */ 157 */
158struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim; 158struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim;
159 159
160/**
161 * Claim to delete
162 */
163static char *attr_delete;
164
165/**
166 * Claim object to delete
167 */
168static struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr_to_delete;
169
160static void 170static void
161do_cleanup (void *cls) 171do_cleanup (void *cls)
162{ 172{
@@ -177,6 +187,8 @@ do_cleanup (void *cls)
177 GNUNET_free (abe_key); 187 GNUNET_free (abe_key);
178 if (NULL != attr_list) 188 if (NULL != attr_list)
179 GNUNET_free (attr_list); 189 GNUNET_free (attr_list);
190 if (NULL != attr_to_delete)
191 GNUNET_free (attr_to_delete);
180} 192}
181 193
182static void 194static void
@@ -208,6 +220,7 @@ process_attrs (void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
208 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr) 220 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr)
209{ 221{
210 char *value_str; 222 char *value_str;
223 char *id;
211 const char *attr_type; 224 const char *attr_type;
212 225
213 if (NULL == identity) { 226 if (NULL == identity) {
@@ -222,8 +235,10 @@ process_attrs (void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
222 value_str = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type, attr->data, 235 value_str = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type, attr->data,
223 attr->data_size); 236 attr->data_size);
224 attr_type = GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (attr->type); 237 attr_type = GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (attr->type);
225 fprintf (stdout, "%s: %s [%s,v%u,id=%" PRIu64 "]\n", attr->name, value_str, 238 id = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof (uint64_t));
226 attr_type, attr->version, attr->id); 239 fprintf (stdout, "Name: %s; Value: %s (%s); Version %u; ID: %s\n", attr->name,
240 value_str, attr_type, attr->version, id);
241 GNUNET_free (id);
227} 242}
228 243
229static void 244static void
@@ -284,6 +299,19 @@ process_rvk (void *cls, int success, const char *msg)
284 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); 299 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
285} 300}
286 301
302
303static void
304process_delete (void *cls, int success, const char *msg)
305{
306 reclaim_op = NULL;
307 if (GNUNET_OK != success) {
308 fprintf (stderr, "Deletion failed.\n");
309 ret = 1;
310 }
311 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
312}
313
314
287static void 315static void
288iter_finished (void *cls) 316iter_finished (void *cls)
289{ 317{
@@ -315,6 +343,15 @@ iter_finished (void *cls)
315 &process_rvk, NULL); 343 &process_rvk, NULL);
316 return; 344 return;
317 } 345 }
346 if (attr_delete) {
347 if (NULL == attr_to_delete) {
348 fprintf (stdout, "No such attribute ``%s''\n", attr_delete);
349 return;
350 }
351 reclaim_op = GNUNET_RECLAIM_attribute_delete (
352 reclaim_handle, pkey, attr_to_delete, &process_delete, NULL);
353 return;
354 }
318 if (attr_name) { 355 if (attr_name) {
319 if (NULL == type_str) 356 if (NULL == type_str)
320 type = GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING; 357 type = GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING;
@@ -348,6 +385,8 @@ iter_cb (void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
348 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; 385 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le;
349 char *attrs_tmp; 386 char *attrs_tmp;
350 char *attr_str; 387 char *attr_str;
388 char *label;
389 char *id;
351 const char *attr_type; 390 const char *attr_type;
352 391
353 if ((NULL != attr_name) && (NULL != claim)) { 392 if ((NULL != attr_name) && (NULL != claim)) {
@@ -373,12 +412,22 @@ iter_cb (void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
373 break; 412 break;
374 } 413 }
375 GNUNET_free (attrs_tmp); 414 GNUNET_free (attrs_tmp);
415 } else if (attr_delete && (NULL == attr_to_delete)) {
416 label = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof (uint64_t));
417 if (0 == strcasecmp (attr_delete, label)) {
418 attr_to_delete = GNUNET_RECLAIM_ATTRIBUTE_claim_new (
419 attr->name, attr->type, attr->data, attr->data_size);
420 attr_to_delete->id = attr->id;
421 }
422 GNUNET_free (label);
376 } else if (list) { 423 } else if (list) {
377 attr_str = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type, attr->data, 424 attr_str = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type, attr->data,
378 attr->data_size); 425 attr->data_size);
379 attr_type = GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (attr->type); 426 attr_type = GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (attr->type);
380 fprintf (stdout, "%s: %s [%s,v%u,id=%" PRIu64 "]\n", attr->name, attr_str, 427 id = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof (uint64_t));
381 attr_type, attr->version, attr->id); 428 fprintf (stdout, "Name: %s; Value: %s (%s); Version %u; ID: %s\n",
429 attr->name, attr_str, attr_type, attr->version, id);
430 GNUNET_free (id);
382 } 431 }
383 GNUNET_RECLAIM_get_attributes_next (attr_iterator); 432 GNUNET_RECLAIM_get_attributes_next (attr_iterator);
384} 433}
@@ -474,7 +523,9 @@ main (int argc, char *const argv[])
474 GNUNET_GETOPT_option_string ('a', "add", "NAME", 523 GNUNET_GETOPT_option_string ('a', "add", "NAME",
475 gettext_noop ("Add an attribute NAME"), 524 gettext_noop ("Add an attribute NAME"),
476 &attr_name), 525 &attr_name),
477 526 GNUNET_GETOPT_option_string ('d', "delete", "ID",
527 gettext_noop ("Add an attribute with ID"),
528 &attr_delete),
478 GNUNET_GETOPT_option_string ('V', "value", "VALUE", 529 GNUNET_GETOPT_option_string ('V', "value", "VALUE",
479 gettext_noop ("The attribute VALUE"), 530 gettext_noop ("The attribute VALUE"),
480 &attr_value), 531 &attr_value),
diff --git a/src/reclaim/gnunet-service-reclaim.c b/src/reclaim/gnunet-service-reclaim.c
index 2bb4f5a74..5deb482e9 100644
--- a/src/reclaim/gnunet-service-reclaim.c
+++ b/src/reclaim/gnunet-service-reclaim.c
@@ -34,7 +34,7 @@
34#include "gnunet_namestore_service.h" 34#include "gnunet_namestore_service.h"
35#include "gnunet_protocols.h" 35#include "gnunet_protocols.h"
36#include "gnunet_reclaim_attribute_lib.h" 36#include "gnunet_reclaim_attribute_lib.h"
37#include "gnunet_reclaim_plugin.h" 37#include "gnunet_reclaim_service.h"
38#include "gnunet_signatures.h" 38#include "gnunet_signatures.h"
39#include "reclaim.h" 39#include "reclaim.h"
40 40
@@ -64,16 +64,6 @@
64static struct GNUNET_IDENTITY_Handle *identity_handle; 64static struct GNUNET_IDENTITY_Handle *identity_handle;
65 65
66/** 66/**
67 * Database handle
68 */
69static struct GNUNET_RECLAIM_PluginFunctions *TKT_database;
70
71/**
72 * Name of DB plugin
73 */
74static char *db_lib_name;
75
76/**
77 * Token expiration interval 67 * Token expiration interval
78 */ 68 */
79static struct GNUNET_TIME_Relative token_expiration_interval; 69static struct GNUNET_TIME_Relative token_expiration_interval;
@@ -106,7 +96,8 @@ struct IdpClient;
106/** 96/**
107 * A ticket iteration operation. 97 * A ticket iteration operation.
108 */ 98 */
109struct TicketIteration { 99struct TicketIteration
100{
110 /** 101 /**
111 * DLL 102 * DLL
112 */ 103 */
@@ -136,7 +127,8 @@ struct TicketIteration {
136/** 127/**
137 * An attribute iteration operation. 128 * An attribute iteration operation.
138 */ 129 */
139struct AttributeIterator { 130struct AttributeIterator
131{
140 /** 132 /**
141 * Next element in the DLL 133 * Next element in the DLL
142 */ 134 */
@@ -171,7 +163,8 @@ struct AttributeIterator {
171/** 163/**
172 * An idp client 164 * An idp client
173 */ 165 */
174struct IdpClient { 166struct IdpClient
167{
175 168
176 /** 169 /**
177 * The client 170 * The client
@@ -246,9 +239,80 @@ struct IdpClient {
246 * Tail of DLL of attribute store ops 239 * Tail of DLL of attribute store ops
247 */ 240 */
248 struct AttributeStoreHandle *store_op_tail; 241 struct AttributeStoreHandle *store_op_tail;
242 /**
243 * Head of DLL of attribute delete ops
244 */
245 struct AttributeDeleteHandle *delete_op_head;
246
247 /**
248 * Tail of DLL of attribute delete ops
249 */
250 struct AttributeDeleteHandle *delete_op_tail;
251};
252
253
254struct AttributeDeleteHandle
255{
256 /**
257 * DLL
258 */
259 struct AttributeDeleteHandle *next;
260
261 /**
262 * DLL
263 */
264 struct AttributeDeleteHandle *prev;
265
266 /**
267 * Client connection
268 */
269 struct IdpClient *client;
270
271 /**
272 * Identity
273 */
274 struct GNUNET_CRYPTO_EcdsaPrivateKey identity;
275
276
277 /**
278 * QueueEntry
279 */
280 struct GNUNET_NAMESTORE_QueueEntry *ns_qe;
281
282 /**
283 * Iterator
284 */
285 struct GNUNET_NAMESTORE_ZoneIterator *ns_it;
286
287 /**
288 * The attribute to delete
289 */
290 struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim;
291
292 /**
293 * Tickets to update
294 */
295 struct TicketRecordsEntry *tickets_to_update_head;
296
297 /**
298 * Tickets to update
299 */
300 struct TicketRecordsEntry *tickets_to_update_tail;
301
302 /**
303 * Attribute label
304 */
305 char *label;
306
307 /**
308 * request id
309 */
310 uint32_t r_id;
249}; 311};
250 312
251struct AttributeStoreHandle { 313
314struct AttributeStoreHandle
315{
252 /** 316 /**
253 * DLL 317 * DLL
254 */ 318 */
@@ -295,7 +359,8 @@ struct AttributeStoreHandle {
295 uint32_t r_id; 359 uint32_t r_id;
296}; 360};
297 361
298struct ConsumeTicketOperation { 362struct ConsumeTicketOperation
363{
299 /** 364 /**
300 * DLL 365 * DLL
301 */ 366 */
@@ -325,7 +390,8 @@ struct ConsumeTicketOperation {
325/** 390/**
326 * Updated attribute IDs 391 * Updated attribute IDs
327 */ 392 */
328struct TicketAttributeUpdateEntry { 393struct TicketAttributeUpdateEntry
394{
329 /** 395 /**
330 * DLL 396 * DLL
331 */ 397 */
@@ -350,7 +416,8 @@ struct TicketAttributeUpdateEntry {
350/** 416/**
351 * Ticket revocation request handle 417 * Ticket revocation request handle
352 */ 418 */
353struct TicketRevocationOperation { 419struct TicketRevocationOperation
420{
354 /** 421 /**
355 * DLL 422 * DLL
356 */ 423 */
@@ -380,7 +447,8 @@ struct TicketRevocationOperation {
380/** 447/**
381 * Ticket issue operation handle 448 * Ticket issue operation handle
382 */ 449 */
383struct TicketIssueOperation { 450struct TicketIssueOperation
451{
384 /** 452 /**
385 * DLL 453 * DLL
386 */ 454 */
@@ -407,7 +475,8 @@ struct TicketIssueOperation {
407 * map in json_t format 475 * map in json_t format
408 * 476 *
409 */ 477 */
410struct EgoEntry { 478struct EgoEntry
479{
411 /** 480 /**
412 * DLL 481 * DLL
413 */ 482 */
@@ -438,9 +507,6 @@ cleanup ()
438 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n"); 507 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n");
439 508
440 RECLAIM_TICKETS_deinit (); 509 RECLAIM_TICKETS_deinit ();
441 GNUNET_break (NULL == GNUNET_PLUGIN_unload (db_lib_name, TKT_database));
442 GNUNET_free (db_lib_name);
443 db_lib_name = NULL;
444 if (NULL != timeout_task) 510 if (NULL != timeout_task)
445 GNUNET_SCHEDULER_cancel (timeout_task); 511 GNUNET_SCHEDULER_cancel (timeout_task);
446 if (NULL != update_task) 512 if (NULL != update_task)
@@ -673,7 +739,7 @@ attr_store_cont (void *cls, int32_t success, const char *emsg)
673{ 739{
674 struct AttributeStoreHandle *ash = cls; 740 struct AttributeStoreHandle *ash = cls;
675 struct GNUNET_MQ_Envelope *env; 741 struct GNUNET_MQ_Envelope *env;
676 struct AttributeStoreResultMessage *acr_msg; 742 struct SuccessResultMessage *acr_msg;
677 743
678 ash->ns_qe = NULL; 744 ash->ns_qe = NULL;
679 GNUNET_CONTAINER_DLL_remove (ash->client->store_op_head, 745 GNUNET_CONTAINER_DLL_remove (ash->client->store_op_head,
@@ -687,10 +753,8 @@ attr_store_cont (void *cls, int32_t success, const char *emsg)
687 return; 753 return;
688 } 754 }
689 755
690 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 756 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending SUCCESS_RESPONSE message\n");
691 "Sending ATTRIBUTE_STORE_RESPONSE message\n"); 757 env = GNUNET_MQ_msg (acr_msg, GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE);
692 env = GNUNET_MQ_msg (acr_msg,
693 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE_RESPONSE);
694 acr_msg->id = htonl (ash->r_id); 758 acr_msg->id = htonl (ash->r_id);
695 acr_msg->op_result = htonl (GNUNET_OK); 759 acr_msg->op_result = htonl (GNUNET_OK);
696 GNUNET_MQ_send (ash->client->mq, env); 760 GNUNET_MQ_send (ash->client->mq, env);
@@ -771,6 +835,220 @@ handle_attribute_store_message (void *cls,
771 GNUNET_SCHEDULER_add_now (&attr_store_task, ash); 835 GNUNET_SCHEDULER_add_now (&attr_store_task, ash);
772} 836}
773 837
838
839static void
840cleanup_adh (struct AttributeDeleteHandle *adh)
841{
842 struct TicketRecordsEntry *le;
843 if (NULL != adh->ns_it)
844 GNUNET_NAMESTORE_zone_iteration_stop (adh->ns_it);
845 if (NULL != adh->ns_qe)
846 GNUNET_NAMESTORE_cancel (adh->ns_qe);
847 if (NULL != adh->label)
848 GNUNET_free (adh->label);
849 if (NULL != adh->claim)
850 GNUNET_free (adh->claim);
851 while (NULL != (le = adh->tickets_to_update_head)) {
852 GNUNET_CONTAINER_DLL_remove (adh->tickets_to_update_head,
853 adh->tickets_to_update_tail, le);
854 if (NULL != le->label)
855 GNUNET_free (le->label);
856 if (NULL != le->data)
857 GNUNET_free (le->data);
858 GNUNET_free (le);
859 }
860 GNUNET_free (adh);
861}
862
863
864static void
865send_delete_response (struct AttributeDeleteHandle *adh, int32_t success)
866{
867 struct GNUNET_MQ_Envelope *env;
868 struct SuccessResultMessage *acr_msg;
869
870 GNUNET_CONTAINER_DLL_remove (adh->client->delete_op_head,
871 adh->client->delete_op_tail, adh);
872
873 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending SUCCESS_RESPONSE message\n");
874 env = GNUNET_MQ_msg (acr_msg, GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE);
875 acr_msg->id = htonl (adh->r_id);
876 acr_msg->op_result = htonl (success);
877 GNUNET_MQ_send (adh->client->mq, env);
878}
879
880
881static void
882ticket_iter (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
883 const char *label, unsigned int rd_count,
884 const struct GNUNET_GNSRECORD_Data *rd)
885{
886 struct AttributeDeleteHandle *adh = cls;
887 struct TicketRecordsEntry *le;
888 int has_changed = GNUNET_NO;
889
890 for (int i = 0; i < rd_count; i++) {
891 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type)
892 continue;
893 if (0 != memcmp (rd[i].data, &adh->claim->id, sizeof (uint64_t)))
894 continue;
895 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Attribute to delete found (%s)\n",
896 adh->label);
897 has_changed = GNUNET_YES;
898 break;
899 }
900 if (GNUNET_YES == has_changed) {
901 le = GNUNET_new (struct TicketRecordsEntry);
902 le->data_size = GNUNET_GNSRECORD_records_get_size (rd_count, rd);
903 le->data = GNUNET_malloc (le->data_size);
904 le->rd_count = rd_count;
905 le->label = GNUNET_strdup (label);
906 GNUNET_GNSRECORD_records_serialize (rd_count, rd, le->data_size, le->data);
907 GNUNET_CONTAINER_DLL_insert (adh->tickets_to_update_head,
908 adh->tickets_to_update_tail, le);
909 }
910 GNUNET_NAMESTORE_zone_iterator_next (adh->ns_it, 1);
911}
912
913
914static void
915update_tickets (void *cls);
916
917
918static void
919ticket_updated (void *cls, int32_t success, const char *emsg)
920{
921 struct AttributeDeleteHandle *adh = cls;
922 adh->ns_qe = NULL;
923 GNUNET_SCHEDULER_add_now (&update_tickets, adh);
924}
925
926static void
927update_tickets (void *cls)
928{
929 struct AttributeDeleteHandle *adh = cls;
930 struct TicketRecordsEntry *le;
931 if (NULL == adh->tickets_to_update_head) {
932 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
933 "Finished updatding tickets, success\n");
934 send_delete_response (adh, GNUNET_OK);
935 cleanup_adh (adh);
936 return;
937 }
938 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Updating %s\n",
939 adh->tickets_to_update_head->label);
940 le = adh->tickets_to_update_head;
941 GNUNET_CONTAINER_DLL_remove (adh->tickets_to_update_head,
942 adh->tickets_to_update_tail, le);
943 struct GNUNET_GNSRECORD_Data rd[le->rd_count];
944 struct GNUNET_GNSRECORD_Data rd_new[le->rd_count - 1];
945 GNUNET_GNSRECORD_records_deserialize (le->data_size, le->data, le->rd_count,
946 rd);
947 int j = 0;
948 for (int i = 0; i < le->rd_count; i++) {
949 if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF == rd[i].record_type) &&
950 (0 == memcmp (rd[i].data, &adh->claim->id, sizeof (uint64_t))))
951 continue;
952 rd_new[j] = rd[i];
953 j++;
954 }
955 adh->ns_qe = GNUNET_NAMESTORE_records_store (nsh, &adh->identity, le->label,
956 j, rd_new, &ticket_updated, adh);
957 GNUNET_free (le->label);
958 GNUNET_free (le->data);
959 GNUNET_free (le);
960}
961
962
963static void
964ticket_iter_fin (void *cls)
965{
966 struct AttributeDeleteHandle *adh = cls;
967 adh->ns_it = NULL;
968 GNUNET_SCHEDULER_add_now (&update_tickets, adh);
969}
970
971
972static void
973ticket_iter_err (void *cls)
974{
975 struct AttributeDeleteHandle *adh = cls;
976 adh->ns_it = NULL;
977 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Namestore error on delete %s\n",
978 adh->label);
979 send_delete_response (adh, GNUNET_SYSERR);
980 cleanup_adh (adh);
981}
982
983
984static void
985start_ticket_update (void *cls)
986{
987 struct AttributeDeleteHandle *adh = cls;
988 adh->ns_it = GNUNET_NAMESTORE_zone_iteration_start (
989 nsh, &adh->identity, &ticket_iter_err, adh, &ticket_iter, adh,
990 &ticket_iter_fin, adh);
991}
992
993
994static void
995attr_delete_cont (void *cls, int32_t success, const char *emsg)
996{
997 struct AttributeDeleteHandle *adh = cls;
998 adh->ns_qe = NULL;
999 if (GNUNET_SYSERR == success) {
1000 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error deleting attribute %s (%s)\n",
1001 adh->claim->name, adh->label);
1002 send_delete_response (adh, GNUNET_SYSERR);
1003 cleanup_adh (adh);
1004 return;
1005 }
1006 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Updating tickets...\n");
1007 GNUNET_SCHEDULER_add_now (&start_ticket_update, adh);
1008}
1009
1010
1011static int
1012check_attribute_delete_message (void *cls,
1013 const struct AttributeDeleteMessage *dam)
1014{
1015 uint16_t size;
1016
1017 size = ntohs (dam->header.size);
1018 if (size <= sizeof (struct AttributeDeleteMessage)) {
1019 GNUNET_break (0);
1020 return GNUNET_SYSERR;
1021 }
1022 return GNUNET_OK;
1023}
1024
1025
1026static void
1027handle_attribute_delete_message (void *cls,
1028 const struct AttributeDeleteMessage *dam)
1029{
1030 struct AttributeDeleteHandle *adh;
1031 struct IdpClient *idp = cls;
1032 size_t data_len;
1033 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Received ATTRIBUTE_DELETE message\n");
1034
1035 data_len = ntohs (dam->attr_len);
1036
1037 adh = GNUNET_new (struct AttributeDeleteHandle);
1038 adh->claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize ((char *)&dam[1], data_len);
1039
1040 adh->r_id = ntohl (dam->id);
1041 adh->identity = dam->identity;
1042 adh->label =
1043 GNUNET_STRINGS_data_to_string_alloc (&adh->claim->id, sizeof (uint64_t));
1044 GNUNET_SERVICE_client_continue (idp->client);
1045 adh->client = idp;
1046 GNUNET_CONTAINER_DLL_insert (idp->delete_op_head, idp->delete_op_tail, adh);
1047 adh->ns_qe = GNUNET_NAMESTORE_records_store (nsh, &adh->identity, adh->label,
1048 0, NULL, &attr_delete_cont, adh);
1049}
1050
1051
774/************************************************* 1052/*************************************************
775 * Attrubute iteration 1053 * Attrubute iteration
776 *************************************************/ 1054 *************************************************/
@@ -1013,7 +1291,6 @@ static void
1013run (void *cls, const struct GNUNET_CONFIGURATION_Handle *c, 1291run (void *cls, const struct GNUNET_CONFIGURATION_Handle *c,
1014 struct GNUNET_SERVICE_Handle *server) 1292 struct GNUNET_SERVICE_Handle *server)
1015{ 1293{
1016 char *database;
1017 cfg = c; 1294 cfg = c;
1018 1295
1019 if (GNUNET_OK != RECLAIM_TICKETS_init (cfg)) { 1296 if (GNUNET_OK != RECLAIM_TICKETS_init (cfg)) {
@@ -1030,19 +1307,6 @@ run (void *cls, const struct GNUNET_CONFIGURATION_Handle *c,
1030 } 1307 }
1031 1308
1032 identity_handle = GNUNET_IDENTITY_connect (cfg, NULL, NULL); 1309 identity_handle = GNUNET_IDENTITY_connect (cfg, NULL, NULL);
1033 /* Loading DB plugin */
1034 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (
1035 cfg, "reclaim", "database", &database))
1036 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No database backend configured\n");
1037 GNUNET_asprintf (&db_lib_name, "libgnunet_plugin_reclaim_%s", database);
1038 TKT_database = GNUNET_PLUGIN_load (db_lib_name, (void *)cfg);
1039 GNUNET_free (database);
1040 if (NULL == TKT_database) {
1041 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1042 "Could not load database backend `%s'\n", db_lib_name);
1043 GNUNET_SCHEDULER_shutdown ();
1044 return;
1045 }
1046 1310
1047 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_time ( 1311 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_time (
1048 cfg, "reclaim", "TOKEN_EXPIRATION_INTERVAL", 1312 cfg, "reclaim", "TOKEN_EXPIRATION_INTERVAL",
@@ -1075,6 +1339,7 @@ client_disconnect_cb (void *cls, struct GNUNET_SERVICE_Client *client,
1075 struct TicketIssueOperation *iss; 1339 struct TicketIssueOperation *iss;
1076 struct ConsumeTicketOperation *ct; 1340 struct ConsumeTicketOperation *ct;
1077 struct AttributeStoreHandle *as; 1341 struct AttributeStoreHandle *as;
1342 struct AttributeDeleteHandle *adh;
1078 1343
1079 // TODO other operations 1344 // TODO other operations
1080 1345
@@ -1095,6 +1360,10 @@ client_disconnect_cb (void *cls, struct GNUNET_SERVICE_Client *client,
1095 GNUNET_CONTAINER_DLL_remove (idp->store_op_head, idp->store_op_tail, as); 1360 GNUNET_CONTAINER_DLL_remove (idp->store_op_head, idp->store_op_tail, as);
1096 cleanup_as_handle (as); 1361 cleanup_as_handle (as);
1097 } 1362 }
1363 while (NULL != (adh = idp->delete_op_head)) {
1364 GNUNET_CONTAINER_DLL_remove (idp->delete_op_head, idp->delete_op_tail, adh);
1365 cleanup_adh (adh);
1366 }
1098 1367
1099 while (NULL != (ai = idp->attr_iter_head)) { 1368 while (NULL != (ai = idp->attr_iter_head)) {
1100 GNUNET_CONTAINER_DLL_remove (idp->attr_iter_head, idp->attr_iter_tail, ai); 1369 GNUNET_CONTAINER_DLL_remove (idp->attr_iter_head, idp->attr_iter_tail, ai);
@@ -1143,6 +1412,9 @@ GNUNET_SERVICE_MAIN (
1143 GNUNET_MQ_hd_var_size (attribute_store_message, 1412 GNUNET_MQ_hd_var_size (attribute_store_message,
1144 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE, 1413 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE,
1145 struct AttributeStoreMessage, NULL), 1414 struct AttributeStoreMessage, NULL),
1415 GNUNET_MQ_hd_var_size (attribute_delete_message,
1416 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE,
1417 struct AttributeDeleteMessage, NULL),
1146 GNUNET_MQ_hd_fixed_size ( 1418 GNUNET_MQ_hd_fixed_size (
1147 iteration_start, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START, 1419 iteration_start, GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START,
1148 struct AttributeIterationStartMessage, NULL), 1420 struct AttributeIterationStartMessage, NULL),
diff --git a/src/reclaim/gnunet-service-reclaim_tickets.c b/src/reclaim/gnunet-service-reclaim_tickets.c
index 549ea8c34..1cdd4268d 100644
--- a/src/reclaim/gnunet-service-reclaim_tickets.c
+++ b/src/reclaim/gnunet-service-reclaim_tickets.c
@@ -30,6 +30,34 @@
30 30
31struct ParallelLookup; 31struct ParallelLookup;
32 32
33
34/**
35 * A reference to a ticket stored in GNS
36 */
37struct TicketReference
38{
39 /**
40 * DLL
41 */
42 struct TicketReference *next;
43
44 /**
45 * DLL
46 */
47 struct TicketReference *prev;
48
49 /**
50 * Attributes
51 */
52 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs;
53
54 /**
55 * Tickets
56 */
57 struct GNUNET_RECLAIM_Ticket ticket;
58};
59
60
33struct RECLAIM_TICKETS_ConsumeHandle 61struct RECLAIM_TICKETS_ConsumeHandle
34{ 62{
35 /** 63 /**
@@ -116,33 +144,6 @@ struct ParallelLookup
116 144
117 145
118/** 146/**
119 * A reference to a ticket stored in GNS
120 */
121struct TicketReference
122{
123 /**
124 * DLL
125 */
126 struct TicketReference *next;
127
128 /**
129 * DLL
130 */
131 struct TicketReference *prev;
132
133 /**
134 * Attributes
135 */
136 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs;
137
138 /**
139 * Tickets
140 */
141 struct GNUNET_RECLAIM_Ticket ticket;
142};
143
144
145/**
146 * Ticket issue request handle 147 * Ticket issue request handle
147 */ 148 */
148struct TicketIssueHandle 149struct TicketIssueHandle
@@ -224,39 +225,6 @@ struct RevokedAttributeEntry
224}; 225};
225 226
226 227
227struct TicketRecordsEntry
228{
229 /**
230 * DLL
231 */
232 struct TicketRecordsEntry *next;
233
234 /**
235 * DLL
236 */
237 struct TicketRecordsEntry *prev;
238
239 /**
240 * Record count
241 */
242 unsigned int rd_count;
243
244 /**
245 * Data
246 */
247 char *data;
248
249 /**
250 * Data size
251 */
252 size_t data_size;
253
254 /**
255 * Label
256 */
257 char *label;
258};
259
260/** 228/**
261 * Ticket revocation request handle 229 * Ticket revocation request handle
262 */ 230 */
@@ -414,8 +382,11 @@ rvk_move_attr_cb (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
414 const struct GNUNET_GNSRECORD_Data *rd) 382 const struct GNUNET_GNSRECORD_Data *rd)
415{ 383{
416 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls; 384 struct RECLAIM_TICKETS_RevokeHandle *rvk = cls;
385 struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim;
386 struct GNUNET_GNSRECORD_Data new_rd;
417 struct RevokedAttributeEntry *le; 387 struct RevokedAttributeEntry *le;
418 char *new_label; 388 char *new_label;
389 char *attr_data;
419 rvk->ns_qe = NULL; 390 rvk->ns_qe = NULL;
420 if (0 == rd_count) { 391 if (0 == rd_count) {
421 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 392 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -430,12 +401,24 @@ rvk_move_attr_cb (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
430 /** find a new place for this attribute **/ 401 /** find a new place for this attribute **/
431 rvk->move_attr->new_id = 402 rvk->move_attr->new_id =
432 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX); 403 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX);
404 new_rd = *rd;
405 claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize (rd->data, rd->data_size);
406 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
407 "Attribute to update: Name=%s, ID=%" PRIu64 "\n", claim->name,
408 claim->id);
409 claim->id = rvk->move_attr->new_id;
410 new_rd.data_size = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (claim);
411 attr_data = GNUNET_malloc (rd->data_size);
412 new_rd.data_size = GNUNET_RECLAIM_ATTRIBUTE_serialize (claim, attr_data);
413 new_rd.data = attr_data;
433 new_label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->new_id, 414 new_label = GNUNET_STRINGS_data_to_string_alloc (&rvk->move_attr->new_id,
434 sizeof (uint64_t)); 415 sizeof (uint64_t));
435 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute %s\n", new_label); 416 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute %s\n", new_label);
436 rvk->ns_qe = GNUNET_NAMESTORE_records_store (nsh, &rvk->identity, new_label, 417 rvk->ns_qe = GNUNET_NAMESTORE_records_store (
437 1, rd, &move_attr_finished, rvk); 418 nsh, &rvk->identity, new_label, 1, &new_rd, &move_attr_finished, rvk);
438 GNUNET_free (new_label); 419 GNUNET_free (new_label);
420 GNUNET_free (claim);
421 GNUNET_free (attr_data);
439} 422}
440 423
441 424
@@ -703,7 +686,7 @@ process_parallel_lookup_result (void *cls, uint32_t rd_count,
703 struct ParallelLookup *parallel_lookup = cls; 686 struct ParallelLookup *parallel_lookup = cls;
704 struct RECLAIM_TICKETS_ConsumeHandle *cth = parallel_lookup->handle; 687 struct RECLAIM_TICKETS_ConsumeHandle *cth = parallel_lookup->handle;
705 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *attr_le; 688 struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *attr_le;
706 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Parallel lookup finished (count=%u)\n", 689 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Parallel lookup finished (count=%u)\n",
707 rd_count); 690 rd_count);
708 691
709 GNUNET_CONTAINER_DLL_remove (cth->parallel_lookups_head, 692 GNUNET_CONTAINER_DLL_remove (cth->parallel_lookups_head,
@@ -777,8 +760,10 @@ lookup_authz_cb (void *cls, uint32_t rd_count,
777 GNUNET_YES); 760 GNUNET_YES);
778 761
779 for (int i = 0; i < rd_count; i++) { 762 for (int i = 0; i < rd_count; i++) {
763 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type)
764 continue;
780 lbl = GNUNET_STRINGS_data_to_string_alloc (rd[i].data, rd[i].data_size); 765 lbl = GNUNET_STRINGS_data_to_string_alloc (rd[i].data, rd[i].data_size);
781 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Attribute ref found %s\n", lbl); 766 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Attribute ref found %s\n", lbl);
782 parallel_lookup = GNUNET_new (struct ParallelLookup); 767 parallel_lookup = GNUNET_new (struct ParallelLookup);
783 parallel_lookup->handle = cth; 768 parallel_lookup->handle = cth;
784 parallel_lookup->label = lbl; 769 parallel_lookup->label = lbl;
@@ -790,9 +775,14 @@ lookup_authz_cb (void *cls, uint32_t rd_count,
790 GNUNET_CONTAINER_DLL_insert (cth->parallel_lookups_head, 775 GNUNET_CONTAINER_DLL_insert (cth->parallel_lookups_head,
791 cth->parallel_lookups_tail, parallel_lookup); 776 cth->parallel_lookups_tail, parallel_lookup);
792 } 777 }
793 cth->kill_task = GNUNET_SCHEDULER_add_delayed ( 778 if (NULL != cth->parallel_lookups_head) {
794 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 3), 779 cth->kill_task = GNUNET_SCHEDULER_add_delayed (
795 &abort_parallel_lookups, cth); 780 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 3),
781 &abort_parallel_lookups, cth);
782 return;
783 }
784 cth->cb (cth->cb_cls, &cth->ticket.identity, cth->attrs, GNUNET_OK, NULL);
785 cleanup_cth (cth);
796} 786}
797 787
798 788
@@ -813,7 +803,7 @@ RECLAIM_TICKETS_consume (const struct GNUNET_CRYPTO_EcdsaPrivateKey *id,
813 cth->cb_cls = cb_cls; 803 cth->cb_cls = cb_cls;
814 label = 804 label =
815 GNUNET_STRINGS_data_to_string_alloc (&cth->ticket.rnd, sizeof (uint64_t)); 805 GNUNET_STRINGS_data_to_string_alloc (&cth->ticket.rnd, sizeof (uint64_t));
816 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Looking for AuthZ info under %s\n", 806 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Looking for AuthZ info under %s\n",
817 label); 807 label);
818 cth->lookup_start_time = GNUNET_TIME_absolute_get (); 808 cth->lookup_start_time = GNUNET_TIME_absolute_get ();
819 cth->lookup_request = GNUNET_GNS_lookup ( 809 cth->lookup_request = GNUNET_GNS_lookup (
diff --git a/src/reclaim/gnunet-service-reclaim_tickets.h b/src/reclaim/gnunet-service-reclaim_tickets.h
index d2b614c46..6e704243d 100644
--- a/src/reclaim/gnunet-service-reclaim_tickets.h
+++ b/src/reclaim/gnunet-service-reclaim_tickets.h
@@ -38,7 +38,7 @@
38#include "gnunet_namestore_service.h" 38#include "gnunet_namestore_service.h"
39#include "gnunet_protocols.h" 39#include "gnunet_protocols.h"
40#include "gnunet_reclaim_attribute_lib.h" 40#include "gnunet_reclaim_attribute_lib.h"
41#include "gnunet_reclaim_plugin.h" 41#include "gnunet_reclaim_service.h"
42#include "gnunet_signatures.h" 42#include "gnunet_signatures.h"
43#include "gnunet_statistics_service.h" 43#include "gnunet_statistics_service.h"
44#include "reclaim.h" 44#include "reclaim.h"
@@ -47,6 +47,41 @@ struct RECLAIM_TICKETS_Iterator;
47struct RECLAIM_TICKETS_ConsumeHandle; 47struct RECLAIM_TICKETS_ConsumeHandle;
48struct RECLAIM_TICKETS_RevokeHandle; 48struct RECLAIM_TICKETS_RevokeHandle;
49 49
50
51struct TicketRecordsEntry
52{
53 /**
54 * DLL
55 */
56 struct TicketRecordsEntry *next;
57
58 /**
59 * DLL
60 */
61 struct TicketRecordsEntry *prev;
62
63 /**
64 * Record count
65 */
66 unsigned int rd_count;
67
68 /**
69 * Data
70 */
71 char *data;
72
73 /**
74 * Data size
75 */
76 size_t data_size;
77
78 /**
79 * Label
80 */
81 char *label;
82};
83
84
50/** 85/**
51 * Continuation called with ticket. 86 * Continuation called with ticket.
52 * 87 *
diff --git a/src/reclaim/reclaim.h b/src/reclaim/reclaim.h
index c29902ab1..982cd8ae4 100644
--- a/src/reclaim/reclaim.h
+++ b/src/reclaim/reclaim.h
@@ -33,6 +33,7 @@
33 33
34GNUNET_NETWORK_STRUCT_BEGIN 34GNUNET_NETWORK_STRUCT_BEGIN
35 35
36
36/** 37/**
37 * Use to store an identity attribute 38 * Use to store an identity attribute
38 */ 39 */
@@ -64,13 +65,42 @@ struct AttributeStoreMessage
64 struct GNUNET_CRYPTO_EcdsaPrivateKey identity; 65 struct GNUNET_CRYPTO_EcdsaPrivateKey identity;
65 66
66 /* followed by the serialized attribute */ 67 /* followed by the serialized attribute */
68};
69
70
71/**
72 * Use to delete an identity attribute
73 */
74struct AttributeDeleteMessage
75{
76 /**
77 * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT
78 */
79 struct GNUNET_MessageHeader header;
80
81 /**
82 * Unique identifier for this request (for key collisions).
83 */
84 uint32_t id GNUNET_PACKED;
85
86 /**
87 * The length of the attribute
88 */
89 uint32_t attr_len GNUNET_PACKED;
90
91 /**
92 * Identity
93 */
94 struct GNUNET_CRYPTO_EcdsaPrivateKey identity;
67 95
96 /* followed by the serialized attribute */
68}; 97};
69 98
99
70/** 100/**
71 * Attribute store response message 101 * Attribute store/delete response message
72 */ 102 */
73struct AttributeStoreResultMessage 103struct SuccessResultMessage
74{ 104{
75 /** 105 /**
76 * Message header 106 * Message header
@@ -86,7 +116,6 @@ struct AttributeStoreResultMessage
86 * #GNUNET_SYSERR on failure, #GNUNET_OK on success 116 * #GNUNET_SYSERR on failure, #GNUNET_OK on success
87 */ 117 */
88 int32_t op_result GNUNET_PACKED; 118 int32_t op_result GNUNET_PACKED;
89
90}; 119};
91 120
92/** 121/**
@@ -99,7 +128,7 @@ struct AttributeResultMessage
99 */ 128 */
100 struct GNUNET_MessageHeader header; 129 struct GNUNET_MessageHeader header;
101 130
102 /** 131 /**
103 * Unique identifier for this request (for key collisions). 132 * Unique identifier for this request (for key collisions).
104 */ 133 */
105 uint32_t id GNUNET_PACKED; 134 uint32_t id GNUNET_PACKED;
@@ -144,7 +173,6 @@ struct AttributeIterationStartMessage
144 * Identity. 173 * Identity.
145 */ 174 */
146 struct GNUNET_CRYPTO_EcdsaPrivateKey identity; 175 struct GNUNET_CRYPTO_EcdsaPrivateKey identity;
147
148}; 176};
149 177
150 178
@@ -162,7 +190,6 @@ struct AttributeIterationNextMessage
162 * Unique identifier for this request (for key collisions). 190 * Unique identifier for this request (for key collisions).
163 */ 191 */
164 uint32_t id GNUNET_PACKED; 192 uint32_t id GNUNET_PACKED;
165
166}; 193};
167 194
168 195
@@ -180,7 +207,6 @@ struct AttributeIterationStopMessage
180 * Unique identifier for this request (for key collisions). 207 * Unique identifier for this request (for key collisions).
181 */ 208 */
182 uint32_t id GNUNET_PACKED; 209 uint32_t id GNUNET_PACKED;
183
184}; 210};
185 211
186/** 212/**
@@ -202,7 +228,6 @@ struct TicketIterationStartMessage
202 * Identity. 228 * Identity.
203 */ 229 */
204 struct GNUNET_CRYPTO_EcdsaPrivateKey identity; 230 struct GNUNET_CRYPTO_EcdsaPrivateKey identity;
205
206}; 231};
207 232
208 233
@@ -220,7 +245,6 @@ struct TicketIterationNextMessage
220 * Unique identifier for this request (for key collisions). 245 * Unique identifier for this request (for key collisions).
221 */ 246 */
222 uint32_t id GNUNET_PACKED; 247 uint32_t id GNUNET_PACKED;
223
224}; 248};
225 249
226 250
@@ -238,11 +262,9 @@ struct TicketIterationStopMessage
238 * Unique identifier for this request (for key collisions). 262 * Unique identifier for this request (for key collisions).
239 */ 263 */
240 uint32_t id GNUNET_PACKED; 264 uint32_t id GNUNET_PACKED;
241
242}; 265};
243 266
244 267
245
246/** 268/**
247 * Ticket issue message 269 * Ticket issue message
248 */ 270 */
@@ -273,7 +295,7 @@ struct IssueTicketMessage
273 */ 295 */
274 uint32_t attr_len GNUNET_PACKED; 296 uint32_t attr_len GNUNET_PACKED;
275 297
276 //Followed by a serialized attribute list 298 // Followed by a serialized attribute list
277}; 299};
278 300
279/** 301/**
@@ -301,7 +323,7 @@ struct RevokeTicketMessage
301 */ 323 */
302 uint32_t attrs_len GNUNET_PACKED; 324 uint32_t attrs_len GNUNET_PACKED;
303 325
304 //Followed by a ticket and serialized attribute list 326 // Followed by a ticket and serialized attribute list
305}; 327};
306 328
307/** 329/**
@@ -340,7 +362,6 @@ struct TicketResultMessage
340 * Unique identifier for this request (for key collisions). 362 * Unique identifier for this request (for key collisions).
341 */ 363 */
342 uint32_t id GNUNET_PACKED; 364 uint32_t id GNUNET_PACKED;
343
344}; 365};
345 366
346/** 367/**
@@ -363,7 +384,7 @@ struct ConsumeTicketMessage
363 */ 384 */
364 struct GNUNET_CRYPTO_EcdsaPrivateKey identity; 385 struct GNUNET_CRYPTO_EcdsaPrivateKey identity;
365 386
366 //Followed by a serialized ticket 387 // Followed by a serialized ticket
367}; 388};
368 389
369/** 390/**
@@ -376,7 +397,7 @@ struct ConsumeTicketResultMessage
376 */ 397 */
377 struct GNUNET_MessageHeader header; 398 struct GNUNET_MessageHeader header;
378 399
379 /** 400 /**
380 * Unique identifier for this request (for key collisions). 401 * Unique identifier for this request (for key collisions).
381 */ 402 */
382 uint32_t id GNUNET_PACKED; 403 uint32_t id GNUNET_PACKED;
@@ -407,7 +428,6 @@ struct ConsumeTicketResultMessage
407}; 428};
408 429
409 430
410
411GNUNET_NETWORK_STRUCT_END 431GNUNET_NETWORK_STRUCT_END
412 432
413#endif 433#endif
diff --git a/src/reclaim/reclaim_api.c b/src/reclaim/reclaim_api.c
index 0edae76c2..e0ca9adf3 100644
--- a/src/reclaim/reclaim_api.c
+++ b/src/reclaim/reclaim_api.c
@@ -407,14 +407,13 @@ mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
407 407
408/** 408/**
409 * Handle an incoming message of type 409 * Handle an incoming message of type
410 * #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE_RESPONSE 410 * #GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE
411 * 411 *
412 * @param cls 412 * @param cls
413 * @param msg the message we received 413 * @param msg the message we received
414 */ 414 */
415static void 415static void
416handle_attribute_store_response (void *cls, 416handle_success_response (void *cls, const struct SuccessResultMessage *msg)
417 const struct AttributeStoreResultMessage *msg)
418{ 417{
419 struct GNUNET_RECLAIM_Handle *h = cls; 418 struct GNUNET_RECLAIM_Handle *h = cls;
420 struct GNUNET_RECLAIM_Operation *op; 419 struct GNUNET_RECLAIM_Operation *op;
@@ -429,8 +428,8 @@ handle_attribute_store_response (void *cls,
429 return; 428 return;
430 429
431 res = ntohl (msg->op_result); 430 res = ntohl (msg->op_result);
432 LOG (GNUNET_ERROR_TYPE_DEBUG, 431 LOG (GNUNET_ERROR_TYPE_DEBUG, "Received SUCCESS_RESPONSE with result %d\n",
433 "Received ATTRIBUTE_STORE_RESPONSE with result %d\n", res); 432 res);
434 433
435 /* TODO: add actual error message to response... */ 434 /* TODO: add actual error message to response... */
436 if (GNUNET_SYSERR == res) 435 if (GNUNET_SYSERR == res)
@@ -735,10 +734,9 @@ static void
735reconnect (struct GNUNET_RECLAIM_Handle *h) 734reconnect (struct GNUNET_RECLAIM_Handle *h)
736{ 735{
737 struct GNUNET_MQ_MessageHandler handlers[] = { 736 struct GNUNET_MQ_MessageHandler handlers[] = {
738 GNUNET_MQ_hd_fixed_size ( 737 GNUNET_MQ_hd_fixed_size (success_response,
739 attribute_store_response, 738 GNUNET_MESSAGE_TYPE_RECLAIM_SUCCESS_RESPONSE,
740 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE_RESPONSE, 739 struct SuccessResultMessage, h),
741 struct AttributeStoreResultMessage, h),
742 GNUNET_MQ_hd_var_size (attribute_result, 740 GNUNET_MQ_hd_var_size (attribute_result,
743 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT, 741 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT,
744 struct AttributeResultMessage, h), 742 struct AttributeResultMessage, h),
@@ -874,6 +872,48 @@ GNUNET_RECLAIM_attribute_store (
874 872
875 873
876/** 874/**
875 * Delete an attribute. Tickets used to share this attribute are updated
876 * accordingly.
877 *
878 * @param h handle to the re:claimID service
879 * @param pkey Private key of the identity to add an attribute to
880 * @param attr The attribute
881 * @param cont Continuation to call when done
882 * @param cont_cls Closure for @a cont
883 * @return handle Used to to abort the request
884 */
885struct GNUNET_RECLAIM_Operation *
886GNUNET_RECLAIM_attribute_delete (
887 struct GNUNET_RECLAIM_Handle *h,
888 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
889 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr,
890 GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
891{
892 struct GNUNET_RECLAIM_Operation *op;
893 struct AttributeDeleteMessage *dam;
894 size_t attr_len;
895
896 op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
897 op->h = h;
898 op->as_cb = cont;
899 op->cls = cont_cls;
900 op->r_id = h->r_id_gen++;
901 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
902 attr_len = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (attr);
903 op->env = GNUNET_MQ_msg_extra (dam, attr_len,
904 GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE);
905 dam->identity = *pkey;
906 dam->id = htonl (op->r_id);
907 GNUNET_RECLAIM_ATTRIBUTE_serialize (attr, (char *)&dam[1]);
908
909 dam->attr_len = htons (attr_len);
910 if (NULL != h->mq)
911 GNUNET_MQ_send_copy (h->mq, op->env);
912 return op;
913}
914
915
916/**
877 * List all attributes for a local identity. 917 * List all attributes for a local identity.
878 * This MUST lock the `struct GNUNET_RECLAIM_Handle` 918 * This MUST lock the `struct GNUNET_RECLAIM_Handle`
879 * for any other calls than #GNUNET_RECLAIM_get_attributes_next() and 919 * for any other calls than #GNUNET_RECLAIM_get_attributes_next() and