aboutsummaryrefslogtreecommitdiff
path: root/src/reclaim/gnunet-service-reclaim_tickets.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/reclaim/gnunet-service-reclaim_tickets.c')
-rw-r--r--src/reclaim/gnunet-service-reclaim_tickets.c45
1 files changed, 24 insertions, 21 deletions
diff --git a/src/reclaim/gnunet-service-reclaim_tickets.c b/src/reclaim/gnunet-service-reclaim_tickets.c
index 48b3fe214..5d3119c6f 100644
--- a/src/reclaim/gnunet-service-reclaim_tickets.c
+++ b/src/reclaim/gnunet-service-reclaim_tickets.c
@@ -29,7 +29,7 @@
29 29
30 30
31/** 31/**
32 * FIXME: the defaul ticket iteration interval should probably 32 * FIXME: the default ticket iteration interval should probably
33 * be the minimim attribute expiration. 33 * be the minimim attribute expiration.
34 */ 34 */
35#define DEFAULT_TICKET_REFRESH_INTERVAL GNUNET_TIME_UNIT_HOURS 35#define DEFAULT_TICKET_REFRESH_INTERVAL GNUNET_TIME_UNIT_HOURS
@@ -129,7 +129,7 @@ struct RECLAIM_TICKETS_ConsumeHandle
129 RECLAIM_TICKETS_ConsumeCallback cb; 129 RECLAIM_TICKETS_ConsumeCallback cb;
130 130
131 /** 131 /**
132 * Callbacl closure 132 * Callback closure
133 */ 133 */
134 void *cb_cls; 134 void *cb_cls;
135}; 135};
@@ -1319,31 +1319,32 @@ issue_ticket (struct TicketIssueHandle *ih)
1319 { 1319 {
1320 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1320 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1321 "Attribute is backed by credential. Adding...\n"); 1321 "Attribute is backed by credential. Adding...\n");
1322 struct GNUNET_RECLAIM_Presentation *pres = NULL; 1322 struct GNUNET_RECLAIM_Presentation *presentation = NULL;
1323 for (j = 0; j < i; j++) 1323 for (j = 0; j < i; j++)
1324 { 1324 {
1325 if (attrs_record[j].record_type 1325 if (attrs_record[j].record_type
1326 != GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION) 1326 != GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION)
1327 continue; 1327 continue;
1328 pres = GNUNET_RECLAIM_presentation_deserialize (attrs_record[j].data, 1328 presentation = GNUNET_RECLAIM_presentation_deserialize (
1329 attrs_record[j]. 1329 attrs_record[j].data,
1330 data_size); 1330 attrs_record[j].
1331 if (NULL == pres) 1331 data_size);
1332 if (NULL == presentation)
1332 { 1333 {
1333 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1334 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1334 "Failed to deserialize presentation\n"); 1335 "Failed to deserialize presentation\n");
1335 continue; 1336 continue;
1336 } 1337 }
1337 if (0 == memcmp (&pres->credential_id, 1338 if (0 == memcmp (&presentation->credential_id,
1338 &le->attribute->credential, 1339 &le->attribute->credential,
1339 sizeof (le->attribute->credential))) 1340 sizeof (le->attribute->credential)))
1340 break; 1341 break;
1341 GNUNET_free (pres); 1342 GNUNET_free (presentation);
1342 pres = NULL; 1343 presentation = NULL;
1343 } 1344 }
1344 if (NULL != pres) 1345 if (NULL != presentation)
1345 { 1346 {
1346 GNUNET_free (pres); 1347 GNUNET_free (presentation);
1347 continue; // Skip as we have already added this credential presentation. 1348 continue; // Skip as we have already added this credential presentation.
1348 } 1349 }
1349 for (ple = ih->presentations->list_head; NULL != ple; ple = ple->next) 1350 for (ple = ih->presentations->list_head; NULL != ple; ple = ple->next)
@@ -1361,6 +1362,7 @@ issue_ticket (struct TicketIssueHandle *ih)
1361 } 1362 }
1362 char *pres_buf; 1363 char *pres_buf;
1363 size_t pres_size; 1364 size_t pres_size;
1365
1364 pres_size = 1366 pres_size =
1365 GNUNET_RECLAIM_presentation_serialize_get_size (ple->presentation); 1367 GNUNET_RECLAIM_presentation_serialize_get_size (ple->presentation);
1366 pres_buf = GNUNET_malloc (pres_size); 1368 pres_buf = GNUNET_malloc (pres_size);
@@ -1457,7 +1459,7 @@ filter_tickets_cb (void *cls,
1457{ 1459{
1458 struct TicketIssueHandle *tih = cls; 1460 struct TicketIssueHandle *tih = cls;
1459 struct GNUNET_RECLAIM_Ticket *ticket = NULL; 1461 struct GNUNET_RECLAIM_Ticket *ticket = NULL;
1460 struct GNUNET_RECLAIM_Presentation *pres; 1462 struct GNUNET_RECLAIM_Presentation *presentation;
1461 struct GNUNET_RECLAIM_PresentationList *ticket_presentations; 1463 struct GNUNET_RECLAIM_PresentationList *ticket_presentations;
1462 struct GNUNET_RECLAIM_Credential *cred; 1464 struct GNUNET_RECLAIM_Credential *cred;
1463 struct GNUNET_RECLAIM_PresentationListEntry *ple; 1465 struct GNUNET_RECLAIM_PresentationListEntry *ple;
@@ -1526,7 +1528,7 @@ filter_tickets_cb (void *cls,
1526 if (GNUNET_OK != GNUNET_RECLAIM_credential_get_presentation ( 1528 if (GNUNET_OK != GNUNET_RECLAIM_credential_get_presentation (
1527 cred, 1529 cred,
1528 tih->attrs, 1530 tih->attrs,
1529 &pres)) 1531 &presentation))
1530 { 1532 {
1531 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1533 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1532 "Unable to retrieve presentation from credential\n"); 1534 "Unable to retrieve presentation from credential\n");
@@ -1534,7 +1536,7 @@ filter_tickets_cb (void *cls,
1534 continue; 1536 continue;
1535 } 1537 }
1536 ple = GNUNET_new (struct GNUNET_RECLAIM_PresentationListEntry); 1538 ple = GNUNET_new (struct GNUNET_RECLAIM_PresentationListEntry);
1537 ple->presentation = pres; 1539 ple->presentation = presentation;
1538 GNUNET_CONTAINER_DLL_insert (tih->presentations->list_head, 1540 GNUNET_CONTAINER_DLL_insert (tih->presentations->list_head,
1539 tih->presentations->list_tail, 1541 tih->presentations->list_tail,
1540 ple); 1542 ple);
@@ -1546,20 +1548,21 @@ filter_tickets_cb (void *cls,
1546 { 1548 {
1547 for (le = tih->attrs->list_head; NULL != le; le = le->next) 1549 for (le = tih->attrs->list_head; NULL != le; le = le->next)
1548 { 1550 {
1549 pres = GNUNET_RECLAIM_presentation_deserialize (rd[i].data, 1551 presentation = GNUNET_RECLAIM_presentation_deserialize (rd[i].data,
1550 rd[i].data_size); 1552 rd[i].data_size);
1551 if (NULL == pres) 1553 if (NULL == presentation)
1552 { 1554 {
1553 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1555 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1554 "Failed to deserialize presentation\n"); 1556 "Failed to deserialize presentation\n");
1555 continue; 1557 continue;
1556 } 1558 }
1557 if (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (&pres->credential_id, 1559 if (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (
1558 &le->attribute->credential)) 1560 &presentation->credential_id,
1561 &le->attribute->credential))
1559 { 1562 {
1560 found_pres_cnt++; 1563 found_pres_cnt++;
1561 ple = GNUNET_new (struct GNUNET_RECLAIM_PresentationListEntry); 1564 ple = GNUNET_new (struct GNUNET_RECLAIM_PresentationListEntry);
1562 ple->presentation = pres; 1565 ple->presentation = presentation;
1563 GNUNET_CONTAINER_DLL_insert (ticket_presentations->list_head, 1566 GNUNET_CONTAINER_DLL_insert (ticket_presentations->list_head,
1564 ticket_presentations->list_tail, 1567 ticket_presentations->list_tail,
1565 ple); 1568 ple);