diff options
author | Markus Voggenreiter <Markus.Voggenreiter@tum.de> | 2019-10-15 09:32:16 +0200 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2020-01-13 13:31:02 +0100 |
commit | 0def2d57eabbf00947ede47b0e968c0a395ace50 (patch) | |
tree | b93af20c076aa365df68356fa107d1689d918a8a /src/reclaim/gnunet-service-reclaim.c | |
parent | 2c65283b0bd97a8719f4c71aee8cc091a491129a (diff) | |
download | gnunet-0def2d57eabbf00947ede47b0e968c0a395ace50.tar.gz gnunet-0def2d57eabbf00947ede47b0e968c0a395ace50.zip |
Delete Attestation via Service
Diffstat (limited to 'src/reclaim/gnunet-service-reclaim.c')
-rw-r--r-- | src/reclaim/gnunet-service-reclaim.c | 114 |
1 files changed, 111 insertions, 3 deletions
diff --git a/src/reclaim/gnunet-service-reclaim.c b/src/reclaim/gnunet-service-reclaim.c index d6c93812f..7929d36d9 100644 --- a/src/reclaim/gnunet-service-reclaim.c +++ b/src/reclaim/gnunet-service-reclaim.c | |||
@@ -266,6 +266,11 @@ struct AttributeDeleteHandle | |||
266 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim; | 266 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim; |
267 | 267 | ||
268 | /** | 268 | /** |
269 | * The attestation to delete | ||
270 | */ | ||
271 | struct GNUNET_RECLAIM_ATTESTATION_Claim *attest; | ||
272 | |||
273 | /** | ||
269 | * Tickets to update | 274 | * Tickets to update |
270 | */ | 275 | */ |
271 | struct TicketRecordsEntry *tickets_to_update_head; | 276 | struct TicketRecordsEntry *tickets_to_update_head; |
@@ -464,6 +469,8 @@ cleanup_adh (struct AttributeDeleteHandle *adh) | |||
464 | GNUNET_free (adh->label); | 469 | GNUNET_free (adh->label); |
465 | if (NULL != adh->claim) | 470 | if (NULL != adh->claim) |
466 | GNUNET_free (adh->claim); | 471 | GNUNET_free (adh->claim); |
472 | if (NULL != adh->attest) | ||
473 | GNUNET_free (adh->attest); | ||
467 | while (NULL != (le = adh->tickets_to_update_head)) | 474 | while (NULL != (le = adh->tickets_to_update_head)) |
468 | { | 475 | { |
469 | GNUNET_CONTAINER_DLL_remove (adh->tickets_to_update_head, | 476 | GNUNET_CONTAINER_DLL_remove (adh->tickets_to_update_head, |
@@ -1209,12 +1216,15 @@ ticket_iter (void *cls, | |||
1209 | 1216 | ||
1210 | for (int i = 0; i < rd_count; i++) | 1217 | for (int i = 0; i < rd_count; i++) |
1211 | { | 1218 | { |
1212 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) | 1219 | if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) && |
1220 | (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR != rd[i].record_type)) | ||
1213 | continue; | 1221 | continue; |
1214 | if (0 != memcmp (rd[i].data, &adh->claim->id, sizeof(uint64_t))) | 1222 | if (0 != memcmp (rd[i].data, &adh->claim->id, sizeof(uint64_t))) |
1215 | continue; | 1223 | continue; |
1224 | if (0 != memcmp (rd[i].data, (&adh->attest->id), sizeof(uint64_t))) | ||
1225 | continue; | ||
1216 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1226 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1217 | "Attribute to delete found (%s)\n", | 1227 | "Attribute or Attestation to delete found (%s)\n", |
1218 | adh->label); | 1228 | adh->label); |
1219 | has_changed = GNUNET_YES; | 1229 | has_changed = GNUNET_YES; |
1220 | break; | 1230 | break; |
@@ -1276,7 +1286,7 @@ update_tickets (void *cls) | |||
1276 | if (NULL == adh->tickets_to_update_head) | 1286 | if (NULL == adh->tickets_to_update_head) |
1277 | { | 1287 | { |
1278 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1288 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1279 | "Finished updatding tickets, success\n"); | 1289 | "Finished updating tickets, success\n"); |
1280 | send_delete_response (adh, GNUNET_OK); | 1290 | send_delete_response (adh, GNUNET_OK); |
1281 | cleanup_adh (adh); | 1291 | cleanup_adh (adh); |
1282 | return; | 1292 | return; |
@@ -1307,6 +1317,9 @@ update_tickets (void *cls) | |||
1307 | if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF == rd[i].record_type) | 1317 | if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF == rd[i].record_type) |
1308 | && (0 == memcmp (rd[i].data, &adh->claim->id, sizeof(uint64_t)))) | 1318 | && (0 == memcmp (rd[i].data, &adh->claim->id, sizeof(uint64_t)))) |
1309 | continue; | 1319 | continue; |
1320 | if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR == rd[i].record_type) | ||
1321 | && (0 == memcmp (rd[i].data, &adh->attest->id, sizeof(uint64_t)))) | ||
1322 | continue; | ||
1310 | rd_new[j] = rd[i]; | 1323 | rd_new[j] = rd[i]; |
1311 | j++; | 1324 | j++; |
1312 | } | 1325 | } |
@@ -1466,6 +1479,97 @@ handle_attribute_delete_message (void *cls, | |||
1466 | adh); | 1479 | adh); |
1467 | } | 1480 | } |
1468 | 1481 | ||
1482 | /** | ||
1483 | * Attestation deleted callback | ||
1484 | * | ||
1485 | * @param cls our handle | ||
1486 | * @param success success status | ||
1487 | * @param emsg error message (NULL if success=GNUNET_OK) | ||
1488 | */ | ||
1489 | static void | ||
1490 | attest_delete_cont (void *cls, int32_t success, const char *emsg) | ||
1491 | { | ||
1492 | struct AttributeDeleteHandle *adh = cls; | ||
1493 | |||
1494 | adh->ns_qe = NULL; | ||
1495 | if (GNUNET_SYSERR == success) | ||
1496 | { | ||
1497 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1498 | "Error deleting attestation %s\n", | ||
1499 | adh->label); | ||
1500 | send_delete_response (adh, GNUNET_SYSERR); | ||
1501 | cleanup_adh (adh); | ||
1502 | return; | ||
1503 | } | ||
1504 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating tickets...\n"); | ||
1505 | GNUNET_SCHEDULER_add_now (&start_ticket_update, adh); | ||
1506 | } | ||
1507 | |||
1508 | /** | ||
1509 | * Check attestation delete message format | ||
1510 | * | ||
1511 | * @cls unused | ||
1512 | * @dam message to check | ||
1513 | */ | ||
1514 | static int | ||
1515 | check_attestation_delete_message (void *cls, | ||
1516 | const struct AttributeDeleteMessage *dam) | ||
1517 | { | ||
1518 | uint16_t size; | ||
1519 | |||
1520 | size = ntohs (dam->header.size); | ||
1521 | if (size <= sizeof(struct AttributeDeleteMessage)) | ||
1522 | { | ||
1523 | GNUNET_break (0); | ||
1524 | return GNUNET_SYSERR; | ||
1525 | } | ||
1526 | return GNUNET_OK; | ||
1527 | } | ||
1528 | |||
1529 | |||
1530 | /** | ||
1531 | * Handle attestation deletion | ||
1532 | * | ||
1533 | * @param cls our client | ||
1534 | * @param dam deletion message | ||
1535 | */ | ||
1536 | static void | ||
1537 | handle_attestation_delete_message (void *cls, | ||
1538 | const struct AttributeDeleteMessage *dam) | ||
1539 | { | ||
1540 | struct AttributeDeleteHandle *adh; | ||
1541 | struct IdpClient *idp = cls; | ||
1542 | size_t data_len; | ||
1543 | |||
1544 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ATTESTATION_DELETE message\n"); | ||
1545 | |||
1546 | data_len = ntohs (dam->attr_len); | ||
1547 | |||
1548 | adh = GNUNET_new (struct AttributeDeleteHandle); | ||
1549 | adh->attest = GNUNET_RECLAIM_ATTESTATION_deserialize ((char *) &dam[1], | ||
1550 | data_len); | ||
1551 | |||
1552 | adh->r_id = ntohl (dam->id); | ||
1553 | adh->identity = dam->identity; | ||
1554 | adh->label | ||
1555 | = GNUNET_STRINGS_data_to_string_alloc (&adh->attest->id, sizeof(uint64_t)); | ||
1556 | GNUNET_SERVICE_client_continue (idp->client); | ||
1557 | adh->client = idp; | ||
1558 | GNUNET_CONTAINER_DLL_insert (idp->delete_op_head, idp->delete_op_tail, adh); | ||
1559 | adh->ns_qe = GNUNET_NAMESTORE_records_store (nsh, | ||
1560 | &adh->identity, | ||
1561 | adh->label, | ||
1562 | 0, | ||
1563 | NULL, | ||
1564 | &attest_delete_cont, | ||
1565 | adh); | ||
1566 | } | ||
1567 | |||
1568 | |||
1569 | |||
1570 | |||
1571 | |||
1572 | |||
1469 | 1573 | ||
1470 | /************************************************* | 1574 | /************************************************* |
1471 | * Attrubute iteration | 1575 | * Attrubute iteration |
@@ -1890,6 +1994,10 @@ GNUNET_SERVICE_MAIN ( | |||
1890 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE, | 1994 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_DELETE, |
1891 | struct AttributeDeleteMessage, | 1995 | struct AttributeDeleteMessage, |
1892 | NULL), | 1996 | NULL), |
1997 | GNUNET_MQ_hd_var_size (attestation_delete_message, | ||
1998 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_DELETE, | ||
1999 | struct AttributeDeleteMessage, | ||
2000 | NULL), | ||
1893 | GNUNET_MQ_hd_fixed_size ( | 2001 | GNUNET_MQ_hd_fixed_size ( |
1894 | iteration_start, | 2002 | iteration_start, |
1895 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START, | 2003 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START, |