aboutsummaryrefslogtreecommitdiff
path: root/src/reclaim
diff options
context:
space:
mode:
authorSchanzenbach, Martin <mschanzenbach@posteo.de>2020-02-07 15:36:43 +0100
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2020-02-09 20:38:11 +0100
commit141a279fb55bc9b11aaa765ca3ad54689003e291 (patch)
tree2519ee820288fae481ae972963dea24fd86ffb59 /src/reclaim
parentd06446f143610790d9a0530d524d8e9db2a03b8c (diff)
downloadgnunet-141a279fb55bc9b11aaa765ca3ad54689003e291.tar.gz
gnunet-141a279fb55bc9b11aaa765ca3ad54689003e291.zip
bugfixes; CLI improvements
Diffstat (limited to 'src/reclaim')
-rw-r--r--src/reclaim/gnunet-reclaim.c57
-rw-r--r--src/reclaim/gnunet-service-reclaim.c8
-rw-r--r--src/reclaim/gnunet-service-reclaim_tickets.c45
-rw-r--r--src/reclaim/gnunet-service-reclaim_tickets.h3
-rw-r--r--src/reclaim/reclaim_api.c7
5 files changed, 87 insertions, 33 deletions
diff --git a/src/reclaim/gnunet-reclaim.c b/src/reclaim/gnunet-reclaim.c
index 121f2b963..cb9a87e37 100644
--- a/src/reclaim/gnunet-reclaim.c
+++ b/src/reclaim/gnunet-reclaim.c
@@ -277,19 +277,43 @@ process_attrs (void *cls,
277 ret = 1; 277 ret = 1;
278 return; 278 return;
279 } 279 }
280 value_str = GNUNET_RECLAIM_attribute_value_to_string (attr->type,
281 attr->data,
282 attr->data_size);
283 attr_type = GNUNET_RECLAIM_attribute_number_to_typename (attr->type); 280 attr_type = GNUNET_RECLAIM_attribute_number_to_typename (attr->type);
284 id = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(attr->id)); 281 id = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(attr->id));
282 value_str = NULL;
283 if (NULL == attest)
284 {
285 value_str = GNUNET_RECLAIM_attribute_value_to_string (attr->type,
286 attr->data,
287 attr->data_size);
288 }
289 else
290 {
291 struct GNUNET_RECLAIM_AttributeListEntry *ale;
292 struct GNUNET_RECLAIM_AttributeList *al
293 = GNUNET_RECLAIM_attestation_get_attributes (attest);
294
295 for (ale = al->list_head; NULL != ale; ale = ale->next)
296 {
297 if (0 != strncmp (attr->data, ale->attribute->name, attr->data_size))
298 continue;
299 value_str
300 = GNUNET_RECLAIM_attribute_value_to_string (ale->attribute->type,
301 ale->attribute->
302 data,
303 ale->attribute->
304 data_size);
305 break;
306 }
307 }
285 fprintf (stdout, 308 fprintf (stdout,
286 "Name: %s; Value: %s (%s); Flag %u; ID: %s %s\n", 309 "Name: %s; Value: %s (%s); Flag %u; ID: %s %s\n",
287 attr->name, 310 attr->name,
288 value_str, 311 (NULL != value_str) ? value_str : "???",
289 attr_type, 312 attr_type,
290 attr->flag, 313 attr->flag,
291 id, 314 id,
292 (NULL == attest) ? "" : "ATTESTED"); 315 (NULL == attest) ? "" : "(ATTESTED)");
316 GNUNET_free_non_null (value_str);
293 GNUNET_free (id); 317 GNUNET_free (id);
294} 318}
295 319
@@ -556,22 +580,25 @@ iter_cb (void *cls,
556 if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&attr->attestation)) 580 if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&attr->attestation))
557 { 581 {
558 fprintf (stdout, 582 fprintf (stdout,
559 "Name: %s; Value: %s (%s); Flag %u; ID: %s\n", 583 "%s: ``%s'' (%s); ID: %s\n",
560 attr->name, 584 attr->name,
561 attr_str, 585 attr_str,
562 attr_type, 586 attr_type,
563 attr->flag,
564 id); 587 id);
565 } 588 }
566 else 589 else
567 { 590 {
591 char *attest_id =
592 GNUNET_STRINGS_data_to_string_alloc (&attr->attestation,
593 sizeof(attr->attestation));
568 fprintf (stdout, 594 fprintf (stdout,
569 "Name: %s; Value: %s (%s); Flag %u; ID: %s\n", 595 "%s: <``%s'' in attestation %s> (%s); ID: %s\n",
570 attr->name, 596 attr->name,
571 attr_str, 597 attr_str,
598 attest_id,
572 attr_type, 599 attr_type,
573 attr->flag,
574 id); 600 id);
601 GNUNET_free (attest_id);
575 602
576 } 603 }
577 GNUNET_free (id); 604 GNUNET_free (id);
@@ -643,11 +670,10 @@ attest_iter_cb (void *cls,
643 attest_type = GNUNET_RECLAIM_attestation_number_to_typename (attest->type); 670 attest_type = GNUNET_RECLAIM_attestation_number_to_typename (attest->type);
644 id = GNUNET_STRINGS_data_to_string_alloc (&attest->id, sizeof(attest->id)); 671 id = GNUNET_STRINGS_data_to_string_alloc (&attest->id, sizeof(attest->id));
645 fprintf (stdout, 672 fprintf (stdout,
646 "Name: %s; Value: %s (%s); Flag %u; ID: %s\n", 673 "%s: ``%s'' (%s); ID: %s\n",
647 attest->name, 674 attest->name,
648 attest_str, 675 attest_str,
649 attest_type, 676 attest_type,
650 attest->flag,
651 id); 677 id);
652 if (NULL != attrs) 678 if (NULL != attrs)
653 { 679 {
@@ -655,9 +681,12 @@ attest_iter_cb (void *cls,
655 "\t Attributes:\n"); 681 "\t Attributes:\n");
656 for (ale = attrs->list_head; NULL != ale; ale = ale->next) 682 for (ale = attrs->list_head; NULL != ale; ale = ale->next)
657 { 683 {
658 attr_str = GNUNET_RECLAIM_attribute_value_to_string (ale->attribute->type, 684 attr_str = GNUNET_RECLAIM_attribute_value_to_string (
659 ale->attribute->data, 685 ale->attribute->type,
660 ale->attribute->data_size); 686 ale->attribute->
687 data,
688 ale->attribute->
689 data_size);
661 690
662 fprintf (stdout, 691 fprintf (stdout,
663 "\t %s: %s\n", ale->attribute->name, attr_str); 692 "\t %s: %s\n", ale->attribute->name, attr_str);
diff --git a/src/reclaim/gnunet-service-reclaim.c b/src/reclaim/gnunet-service-reclaim.c
index eb8727f8f..4521e5c81 100644
--- a/src/reclaim/gnunet-service-reclaim.c
+++ b/src/reclaim/gnunet-service-reclaim.c
@@ -842,6 +842,7 @@ static void
842consume_result_cb (void *cls, 842consume_result_cb (void *cls,
843 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, 843 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
844 const struct GNUNET_RECLAIM_AttributeList *attrs, 844 const struct GNUNET_RECLAIM_AttributeList *attrs,
845 const struct GNUNET_RECLAIM_AttestationList *attests,
845 int32_t success, 846 int32_t success,
846 const char *emsg) 847 const char *emsg)
847{ 848{
@@ -850,23 +851,28 @@ consume_result_cb (void *cls,
850 struct GNUNET_MQ_Envelope *env; 851 struct GNUNET_MQ_Envelope *env;
851 char *data_tmp; 852 char *data_tmp;
852 size_t attrs_len; 853 size_t attrs_len;
854 size_t attests_len;
853 855
854 if (GNUNET_OK != success) 856 if (GNUNET_OK != success)
855 { 857 {
856 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error consuming ticket: %s\n", emsg); 858 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error consuming ticket: %s\n", emsg);
857 } 859 }
858 attrs_len = GNUNET_RECLAIM_attribute_list_serialize_get_size (attrs); 860 attrs_len = GNUNET_RECLAIM_attribute_list_serialize_get_size (attrs);
861 attests_len = GNUNET_RECLAIM_attestation_list_serialize_get_size (attests);
859 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 862 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
860 "Sending CONSUME_TICKET_RESULT message\n"); 863 "Sending CONSUME_TICKET_RESULT message\n");
861 env = GNUNET_MQ_msg_extra (crm, 864 env = GNUNET_MQ_msg_extra (crm,
862 attrs_len, 865 attrs_len + attests_len,
863 GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT); 866 GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT);
864 crm->id = htonl (cop->r_id); 867 crm->id = htonl (cop->r_id);
865 crm->attrs_len = htons (attrs_len); 868 crm->attrs_len = htons (attrs_len);
869 crm->attestations_len = htons (attests_len);
866 crm->identity = *identity; 870 crm->identity = *identity;
867 crm->result = htonl (success); 871 crm->result = htonl (success);
868 data_tmp = (char *) &crm[1]; 872 data_tmp = (char *) &crm[1];
869 GNUNET_RECLAIM_attribute_list_serialize (attrs, data_tmp); 873 GNUNET_RECLAIM_attribute_list_serialize (attrs, data_tmp);
874 data_tmp += attrs_len;
875 GNUNET_RECLAIM_attestation_list_serialize (attests, data_tmp);
870 GNUNET_MQ_send (cop->client->mq, env); 876 GNUNET_MQ_send (cop->client->mq, env);
871 GNUNET_CONTAINER_DLL_remove (cop->client->consume_op_head, 877 GNUNET_CONTAINER_DLL_remove (cop->client->consume_op_head,
872 cop->client->consume_op_tail, 878 cop->client->consume_op_tail,
diff --git a/src/reclaim/gnunet-service-reclaim_tickets.c b/src/reclaim/gnunet-service-reclaim_tickets.c
index 019ce51b0..205886c78 100644
--- a/src/reclaim/gnunet-service-reclaim_tickets.c
+++ b/src/reclaim/gnunet-service-reclaim_tickets.c
@@ -1058,7 +1058,8 @@ process_parallel_lookup_result (void *cls,
1058 if (NULL != cth->parallel_lookups_head) 1058 if (NULL != cth->parallel_lookups_head)
1059 return; // Wait for more 1059 return; // Wait for more
1060 /* Else we are done */ 1060 /* Else we are done */
1061 cth->cb (cth->cb_cls, &cth->ticket.identity, cth->attrs, GNUNET_OK, NULL); 1061 cth->cb (cth->cb_cls, &cth->ticket.identity,
1062 cth->attrs, cth->attests, GNUNET_OK, NULL);
1062 cleanup_cth (cth); 1063 cleanup_cth (cth);
1063} 1064}
1064 1065
@@ -1087,7 +1088,7 @@ abort_parallel_lookups (void *cls)
1087 GNUNET_free (lu); 1088 GNUNET_free (lu);
1088 lu = tmp; 1089 lu = tmp;
1089 } 1090 }
1090 cth->cb (cth->cb_cls, NULL, NULL, GNUNET_SYSERR, "Aborted"); 1091 cth->cb (cth->cb_cls, NULL, NULL, NULL, GNUNET_SYSERR, "Aborted");
1091} 1092}
1092 1093
1093 1094
@@ -1124,10 +1125,11 @@ lookup_authz_cb (void *cls,
1124 1125
1125 for (int i = 0; i < rd_count; i++) 1126 for (int i = 0; i < rd_count; i++)
1126 { 1127 {
1127 if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF != rd[i].record_type) 1128 if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF != rd[i].record_type) &&
1129 (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION_REF != rd[i].record_type))
1128 continue; 1130 continue;
1129 lbl = GNUNET_STRINGS_data_to_string_alloc (rd[i].data, rd[i].data_size); 1131 lbl = GNUNET_STRINGS_data_to_string_alloc (rd[i].data, rd[i].data_size);
1130 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Attribute ref found %s\n", lbl); 1132 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ticket reference found %s\n", lbl);
1131 parallel_lookup = GNUNET_new (struct ParallelLookup); 1133 parallel_lookup = GNUNET_new (struct ParallelLookup);
1132 parallel_lookup->handle = cth; 1134 parallel_lookup->handle = cth;
1133 parallel_lookup->label = lbl; 1135 parallel_lookup->label = lbl;
@@ -1159,7 +1161,8 @@ lookup_authz_cb (void *cls,
1159 /** 1161 /**
1160 * No references found, return empty attribute list 1162 * No references found, return empty attribute list
1161 */ 1163 */
1162 cth->cb (cth->cb_cls, &cth->ticket.identity, cth->attrs, GNUNET_OK, NULL); 1164 cth->cb (cth->cb_cls, &cth->ticket.identity,
1165 cth->attrs, cth->attests, GNUNET_OK, NULL);
1163 cleanup_cth (cth); 1166 cleanup_cth (cth);
1164} 1167}
1165 1168
@@ -1189,6 +1192,7 @@ RECLAIM_TICKETS_consume (const struct GNUNET_CRYPTO_EcdsaPrivateKey *id,
1189 cth->identity = *id; 1192 cth->identity = *id;
1190 GNUNET_CRYPTO_ecdsa_key_get_public (&cth->identity, &cth->identity_pub); 1193 GNUNET_CRYPTO_ecdsa_key_get_public (&cth->identity, &cth->identity_pub);
1191 cth->attrs = GNUNET_new (struct GNUNET_RECLAIM_AttributeList); 1194 cth->attrs = GNUNET_new (struct GNUNET_RECLAIM_AttributeList);
1195 cth->attests = GNUNET_new (struct GNUNET_RECLAIM_AttestationList);
1192 cth->ticket = *ticket; 1196 cth->ticket = *ticket;
1193 cth->cb = cb; 1197 cth->cb = cb;
1194 cth->cb_cls = cb_cls; 1198 cth->cb_cls = cb_cls;
@@ -1282,18 +1286,15 @@ issue_ticket (struct TicketIssueHandle *ih)
1282 struct GNUNET_RECLAIM_AttributeListEntry *le; 1286 struct GNUNET_RECLAIM_AttributeListEntry *le;
1283 struct GNUNET_GNSRECORD_Data *attrs_record; 1287 struct GNUNET_GNSRECORD_Data *attrs_record;
1284 char *label; 1288 char *label;
1285 size_t list_len = 1;
1286 int i; 1289 int i;
1290 int attrs_count = 0;
1287 1291
1288 for (le = ih->attrs->list_head; NULL != le; le = le->next) 1292 for (le = ih->attrs->list_head; NULL != le; le = le->next)
1289 { 1293 attrs_count++;
1290 list_len++;
1291 if (GNUNET_NO == GNUNET_RECLAIM_id_is_zero (&le->attribute->attestation))
1292 list_len++;
1293 }
1294 1294
1295 //Worst case we have one attestation per attribute
1295 attrs_record = 1296 attrs_record =
1296 GNUNET_malloc (list_len * sizeof(struct GNUNET_GNSRECORD_Data)); 1297 GNUNET_malloc (2 * attrs_count * sizeof(struct GNUNET_GNSRECORD_Data));
1297 i = 0; 1298 i = 0;
1298 for (le = ih->attrs->list_head; NULL != le; le = le->next) 1299 for (le = ih->attrs->list_head; NULL != le; le = le->next)
1299 { 1300 {
@@ -1302,17 +1303,30 @@ issue_ticket (struct TicketIssueHandle *ih)
1302 attrs_record[i].expiration_time = ticket_refresh_interval.rel_value_us; 1303 attrs_record[i].expiration_time = ticket_refresh_interval.rel_value_us;
1303 attrs_record[i].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF; 1304 attrs_record[i].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF;
1304 attrs_record[i].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; 1305 attrs_record[i].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
1306 i++;
1305 if (GNUNET_NO == GNUNET_RECLAIM_id_is_zero (&le->attribute->attestation)) 1307 if (GNUNET_NO == GNUNET_RECLAIM_id_is_zero (&le->attribute->attestation))
1306 { 1308 {
1307 i++; 1309 int j;
1310 for (j = 0; j < i; j++)
1311 {
1312 if (attrs_record[j].record_type
1313 != GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION_REF)
1314 continue;
1315 if (0 == memcmp (attrs_record[j].data,
1316 &le->attribute->attestation,
1317 sizeof (le->attribute->attestation)))
1318 break;
1319 }
1320 if (j < i)
1321 continue; // Skip as we have already added this attestation.
1308 attrs_record[i].data = &le->attribute->attestation; 1322 attrs_record[i].data = &le->attribute->attestation;
1309 attrs_record[i].data_size = sizeof(le->attribute->attestation); 1323 attrs_record[i].data_size = sizeof(le->attribute->attestation);
1310 attrs_record[i].expiration_time = ticket_refresh_interval.rel_value_us; 1324 attrs_record[i].expiration_time = ticket_refresh_interval.rel_value_us;
1311 attrs_record[i].record_type = 1325 attrs_record[i].record_type =
1312 GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION_REF; 1326 GNUNET_GNSRECORD_TYPE_RECLAIM_ATTESTATION_REF;
1313 attrs_record[i].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; 1327 attrs_record[i].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
1328 i++;
1314 } 1329 }
1315 i++;
1316 } 1330 }
1317 attrs_record[i].data = &ih->ticket; 1331 attrs_record[i].data = &ih->ticket;
1318 attrs_record[i].data_size = sizeof(struct GNUNET_RECLAIM_Ticket); 1332 attrs_record[i].data_size = sizeof(struct GNUNET_RECLAIM_Ticket);
@@ -1320,6 +1334,7 @@ issue_ticket (struct TicketIssueHandle *ih)
1320 attrs_record[i].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET; 1334 attrs_record[i].record_type = GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET;
1321 attrs_record[i].flags = 1335 attrs_record[i].flags =
1322 GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION | GNUNET_GNSRECORD_RF_PRIVATE; 1336 GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION | GNUNET_GNSRECORD_RF_PRIVATE;
1337 i++;
1323 1338
1324 label = 1339 label =
1325 GNUNET_STRINGS_data_to_string_alloc (&ih->ticket.rnd, 1340 GNUNET_STRINGS_data_to_string_alloc (&ih->ticket.rnd,
@@ -1328,7 +1343,7 @@ issue_ticket (struct TicketIssueHandle *ih)
1328 ih->ns_qe = GNUNET_NAMESTORE_records_store (nsh, 1343 ih->ns_qe = GNUNET_NAMESTORE_records_store (nsh,
1329 &ih->identity, 1344 &ih->identity,
1330 label, 1345 label,
1331 list_len, 1346 i,
1332 attrs_record, 1347 attrs_record,
1333 &store_ticket_issue_cont, 1348 &store_ticket_issue_cont,
1334 ih); 1349 ih);
diff --git a/src/reclaim/gnunet-service-reclaim_tickets.h b/src/reclaim/gnunet-service-reclaim_tickets.h
index e8299718c..d6bc4a70a 100644
--- a/src/reclaim/gnunet-service-reclaim_tickets.h
+++ b/src/reclaim/gnunet-service-reclaim_tickets.h
@@ -136,7 +136,8 @@ typedef void (*RECLAIM_TICKETS_TicketResult) (
136typedef void (*RECLAIM_TICKETS_ConsumeCallback) ( 136typedef void (*RECLAIM_TICKETS_ConsumeCallback) (
137 void *cls, 137 void *cls,
138 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, 138 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
139 const struct GNUNET_RECLAIM_AttributeList *l, 139 const struct GNUNET_RECLAIM_AttributeList *attributes,
140 const struct GNUNET_RECLAIM_AttestationList *attestations,
140 int32_t success, 141 int32_t success,
141 const char *emsg); 142 const char *emsg);
142 143
diff --git a/src/reclaim/reclaim_api.c b/src/reclaim/reclaim_api.c
index 5f52aa57b..54288866d 100644
--- a/src/reclaim/reclaim_api.c
+++ b/src/reclaim/reclaim_api.c
@@ -561,10 +561,13 @@ check_consume_ticket_result (void *cls,
561{ 561{
562 size_t msg_len; 562 size_t msg_len;
563 size_t attrs_len; 563 size_t attrs_len;
564 size_t attests_len;
564 565
565 msg_len = ntohs (msg->header.size); 566 msg_len = ntohs (msg->header.size);
566 attrs_len = ntohs (msg->attrs_len); 567 attrs_len = ntohs (msg->attrs_len);
567 if (msg_len != sizeof(struct ConsumeTicketResultMessage) + attrs_len) 568 attests_len = ntohs (msg->attestations_len);
569 if (msg_len !=
570 sizeof(struct ConsumeTicketResultMessage) + attrs_len + attests_len)
568 { 571 {
569 GNUNET_break (0); 572 GNUNET_break (0);
570 return GNUNET_SYSERR; 573 return GNUNET_SYSERR;
@@ -628,7 +631,7 @@ handle_consume_ticket_result (void *cls,
628 for (ale = attests->list_head; NULL != ale; ale = ale->next) 631 for (ale = attests->list_head; NULL != ale; ale = ale->next)
629 { 632 {
630 if (GNUNET_YES == 633 if (GNUNET_YES ==
631 GNUNET_RECLAIM_id_is_equal (&le->attribute->id, 634 GNUNET_RECLAIM_id_is_equal (&le->attribute->attestation,
632 &ale->attestation->id)) 635 &ale->attestation->id))
633 { 636 {
634 op->atr_cb (op->cls, &msg->identity, 637 op->atr_cb (op->cls, &msg->identity,