diff options
author | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2016-12-29 15:48:43 +0100 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2016-12-29 15:48:43 +0100 |
commit | baf9b5d76c4b40d6bd2869525656ad298ead7726 (patch) | |
tree | 257015b1c0463399fd70fb689666a00a6fb90341 /src/credential/gnunet-service-credential.c | |
parent | 897dd85d9feb5cd962db3bf2156a2a2b4d2841d4 (diff) | |
download | gnunet-baf9b5d76c4b40d6bd2869525656ad298ead7726.tar.gz gnunet-baf9b5d76c4b40d6bd2869525656ad298ead7726.zip |
-add tokens for credentials
Diffstat (limited to 'src/credential/gnunet-service-credential.c')
-rw-r--r-- | src/credential/gnunet-service-credential.c | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/src/credential/gnunet-service-credential.c b/src/credential/gnunet-service-credential.c index ec89da323..75ed6d5da 100644 --- a/src/credential/gnunet-service-credential.c +++ b/src/credential/gnunet-service-credential.c | |||
@@ -92,7 +92,11 @@ struct CredentialRecordEntry | |||
92 | * DLL | 92 | * DLL |
93 | */ | 93 | */ |
94 | struct CredentialRecordEntry *prev; | 94 | struct CredentialRecordEntry *prev; |
95 | 95 | ||
96 | /** | ||
97 | * Number of references in delegation chains | ||
98 | */ | ||
99 | uint32_t refcount; | ||
96 | 100 | ||
97 | /** | 101 | /** |
98 | * Payload | 102 | * Payload |
@@ -485,6 +489,7 @@ send_lookup_response (struct VerifyRequestHandle *vrh) | |||
485 | struct GNUNET_CREDENTIAL_Delegation dd[vrh->delegation_chain_size]; | 489 | struct GNUNET_CREDENTIAL_Delegation dd[vrh->delegation_chain_size]; |
486 | struct GNUNET_CREDENTIAL_Credential cred[vrh->cred_chain_size]; | 490 | struct GNUNET_CREDENTIAL_Credential cred[vrh->cred_chain_size]; |
487 | struct CredentialRecordEntry *cd; | 491 | struct CredentialRecordEntry *cd; |
492 | struct CredentialRecordEntry *tmp; | ||
488 | size_t size; | 493 | size_t size; |
489 | int i; | 494 | int i; |
490 | 495 | ||
@@ -508,6 +513,26 @@ send_lookup_response (struct VerifyRequestHandle *vrh) | |||
508 | } | 513 | } |
509 | 514 | ||
510 | /** | 515 | /** |
516 | * Remove all credentials not needed | ||
517 | */ | ||
518 | for (cd = vrh->cred_chain_head; NULL != cd;) | ||
519 | { | ||
520 | if (cd->refcount > 0) | ||
521 | { | ||
522 | cd = cd->next; | ||
523 | continue; | ||
524 | } | ||
525 | tmp = cd; | ||
526 | cd = cd->next; | ||
527 | GNUNET_CONTAINER_DLL_remove (vrh->cred_chain_head, | ||
528 | vrh->cred_chain_tail, | ||
529 | tmp); | ||
530 | GNUNET_free (tmp->credential); | ||
531 | GNUNET_free (tmp); | ||
532 | vrh->cred_chain_size--; | ||
533 | } | ||
534 | |||
535 | /** | ||
511 | * Get serialized record data | 536 | * Get serialized record data |
512 | * Append at the end of rmsg | 537 | * Append at the end of rmsg |
513 | */ | 538 | */ |
@@ -681,7 +706,7 @@ backward_resolution (void* cls, | |||
681 | 706 | ||
682 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 707 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
683 | "Found issuer\n"); | 708 | "Found issuer\n"); |
684 | 709 | cred_pointer->refcount++; | |
685 | //Backtrack | 710 | //Backtrack |
686 | for (tmp_set = ds_entry; | 711 | for (tmp_set = ds_entry; |
687 | NULL != tmp_set->parent_queue_entry; | 712 | NULL != tmp_set->parent_queue_entry; |
@@ -796,6 +821,7 @@ delegation_chain_resolution_start (void* cls) | |||
796 | continue; | 821 | continue; |
797 | if (0 != strcmp (cr_entry->credential->issuer_attribute, vrh->issuer_attribute)) | 822 | if (0 != strcmp (cr_entry->credential->issuer_attribute, vrh->issuer_attribute)) |
798 | continue; | 823 | continue; |
824 | cr_entry->refcount++; | ||
799 | //Found match prematurely | 825 | //Found match prematurely |
800 | send_lookup_response (vrh); | 826 | send_lookup_response (vrh); |
801 | return; | 827 | return; |