aboutsummaryrefslogtreecommitdiff
path: root/src/reclaim/reclaim_api.c
diff options
context:
space:
mode:
authorSchanzenbach, Martin <mschanzenbach@posteo.de>2019-04-14 15:23:44 +0200
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2019-04-14 15:23:44 +0200
commit494af3383d2a5d3402e1f03209cb574af86079a8 (patch)
tree6b457d61846e2f18c3f1b4ace0e3e58480e3e15c /src/reclaim/reclaim_api.c
parenta277e037fefe605c93d81869ac514f87cad25768 (diff)
downloadgnunet-494af3383d2a5d3402e1f03209cb574af86079a8.tar.gz
gnunet-494af3383d2a5d3402e1f03209cb574af86079a8.zip
RECLAIM: bugfixes; add delete attribute API
Diffstat (limited to 'src/reclaim/reclaim_api.c')
-rw-r--r--src/reclaim/reclaim_api.c58
1 files changed, 49 insertions, 9 deletions
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