*/
#define GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_DELETE 1500
+#define GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_RESULT 1501
+
/**
* Type used to match 'all' message types.
uint32_t type;
/**
- * Version
+ * Flags
*/
- uint32_t version;
+ uint32_t flag;
/**
* The name of the attribute. Note "name" must never be individually
* free'd
typedef void (*GNUNET_RECLAIM_AttributeResult) (
void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr,
- const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest);
+ const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest,
+ const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference);
/**
+ strlen (attr_name_tmp) + 1 + data_size);
attr->type = type;
attr->data_size = data_size;
- attr->version = 0;
+ attr->flag = 0;
write_ptr = (char *) &attr[1];
GNUNET_memcpy (write_ptr, attr_name_tmp, strlen (attr_name_tmp) + 1);
attr->name = write_ptr;
le->claim->type,
le->claim->data,
le->claim->data_size);
- result_le->claim->version = le->claim->version;
result_le->claim->id = le->claim->id;
+ result_le->claim->flag = le->claim->flag;
GNUNET_CONTAINER_DLL_insert (result->list_head,
result->list_tail,
result_le);
attr_ser = (struct Attribute *) result;
attr_ser->attribute_type = htons (attr->type);
- attr_ser->attribute_version = htonl (attr->version);
+ attr_ser->attribute_version = htonl (attr->flag);
attr_ser->attribute_id = GNUNET_htonll (attr->id);
name_len = strlen (attr->name);
attr_ser->name_len = htons (name_len);
attr = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_Claim)
+ data_len + name_len + 1);
attr->type = ntohs (attr_ser->attribute_type);
- attr->version = ntohl (attr_ser->attribute_version);
+ attr->flag = ntohl (attr_ser->attribute_version);
attr->id = GNUNET_ntohll (attr_ser->attribute_id);
attr->data_size = data_len;
process_attrs (void *cls,
const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr,
- const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest)
+ const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest,
+ const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference)
{
char *value_str;
char *id;
attr->name,
value_str,
attr_type,
- attr->version,
+ attr->flag,
id);
GNUNET_free (id);
}
iter_cb (void *cls,
const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr,
- const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest)
+ const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest,
+ const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference)
{
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le;
char *attrs_tmp;
attr->type,
attr->data,
attr->data_size);
- le->claim->version = attr->version;
+ le->claim->flag = attr->flag;
le->claim->id = attr->id;
GNUNET_CONTAINER_DLL_insert (attr_list->list_head,
attr_list->list_tail,
attr->name,
attr_str,
attr_type,
- attr->version,
+ attr->flag,
id);
GNUNET_free (id);
}
int has_changed = GNUNET_NO;
for (int i = 0; i < rd_count; i++)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Next Zone Iteration %u and record type is %u\n", rd_count,
- rd[i].record_type);
if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF != rd[i].record_type) &&
(GNUNET_GNSRECORD_TYPE_RECLAIM_REFERENCE_REF != rd[i].record_type) &&
(GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_REF != rd[i].record_type))
continue;
if (&adh->claim != NULL)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Claim is existend: %u \n", adh->claim->id);
if (0 != memcmp (rd[i].data, &adh->claim->id, sizeof(uint64_t)))
continue;
- }
if (&adh->attest != NULL)
if (0 != memcmp (rd[i].data, &adh->attest->id, sizeof(uint64_t)))
continue;
if (&adh->reference != NULL)
if (0 != memcmp (rd[i].data, &adh->reference->id, sizeof(uint64_t)))
continue;
-
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Attribute or Attestation/Reference to delete found (%s)\n",
adh->label);
adh->tickets_to_update_tail,
le);
}
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Next Zone Iteration \n");
GNUNET_NAMESTORE_zone_iterator_next (adh->ns_it, 1);
}
/**
- * Got record. Return if it is an attribute or attestation.
+ * Got record. Return if it is an attribute or attestation/reference.
*
* @param cls our attribute iterator
* @param zone zone we are iterating
struct GNUNET_MQ_Envelope *env;
char *data_tmp;
- if (rd_count != 1)
+ if (rd_count == 0)
{
GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, 1);
return;
}
-
- if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR != rd->record_type) &&
- (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR != rd->record_type) )
+ if (rd_count > 1)
{
- GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, 1);
- return;
+ if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR != rd[0].record_type)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Non-Attestation record with multiple entries found\n");
+ GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, 1);
+ return;
+ }
}
- if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR == rd->record_type )
+ for (int i = 0; i<rd_count; i++)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attestation under: %s\n",
- label);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Sending ATTESTATION_RESULT message\n");
- env = GNUNET_MQ_msg_extra (arm,
- rd->data_size,
- GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT);
- arm->id = htonl (ai->request_id);
- arm->attr_len = htons (rd->data_size);
- GNUNET_CRYPTO_ecdsa_key_get_public (zone, &arm->identity);
- data_tmp = (char *) &arm[1];
- GNUNET_memcpy (data_tmp, rd->data, rd->data_size);
- GNUNET_MQ_send (ai->client->mq, env);
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attribute under: %s\n", label);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending ATTRIBUTE_RESULT message\n");
- env = GNUNET_MQ_msg_extra (arm,
- rd->data_size,
- GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT);
- arm->id = htonl (ai->request_id);
- arm->attr_len = htons (rd->data_size);
- GNUNET_CRYPTO_ecdsa_key_get_public (zone, &arm->identity);
- data_tmp = (char *) &arm[1];
- GNUNET_memcpy (data_tmp, rd->data, rd->data_size);
- GNUNET_MQ_send (ai->client->mq, env);
+ if ((GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR != rd[i].record_type) &&
+ (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR != rd[i].record_type) &&
+ (GNUNET_GNSRECORD_TYPE_RECLAIM_REFERENCE != rd[i].record_type))
+ {
+ GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, 1);
+ return;
+ }
+
+ if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR == rd[i].record_type )
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attribute under: %s\n",
+ label);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Sending ATTRIBUTE_RESULT message\n");
+ env = GNUNET_MQ_msg_extra (arm,
+ rd[i].data_size,
+ GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT);
+ arm->id = htonl (ai->request_id);
+ arm->attr_len = htons (rd[i].data_size);
+ GNUNET_CRYPTO_ecdsa_key_get_public (zone, &arm->identity);
+ data_tmp = (char *) &arm[1];
+ GNUNET_memcpy (data_tmp, rd[i].data, rd[i].data_size);
+ GNUNET_MQ_send (ai->client->mq, env);
+ }
+ else
+ {
+ if (GNUNET_GNSRECORD_TYPE_RECLAIM_ATTEST_ATTR == rd[i].record_type )
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found attestation under: %s\n",
+ label);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Sending ATTESTATION_RESULT message\n");
+ env = GNUNET_MQ_msg_extra (arm,
+ rd[i].data_size,
+ GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT);
+ arm->id = htonl (ai->request_id);
+ arm->attr_len = htons (rd[i].data_size);
+ GNUNET_CRYPTO_ecdsa_key_get_public (zone, &arm->identity);
+ data_tmp = (char *) &arm[1];
+ GNUNET_memcpy (data_tmp, rd[i].data, rd[i].data_size);
+ GNUNET_MQ_send (ai->client->mq, env);
+ }
+ else
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found reference under: %s\n",
+ label);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Sending REFERENCE_RESULT message\n");
+ env = GNUNET_MQ_msg_extra (arm,
+ rd[i].data_size,
+ GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_RESULT);
+ arm->id = htonl (ai->request_id);
+ arm->attr_len = htons (rd[i].data_size);
+ GNUNET_CRYPTO_ecdsa_key_get_public (zone, &arm->identity);
+ data_tmp = (char *) &arm[1];
+ GNUNET_memcpy (data_tmp, rd[i].data, rd[i].data_size);
+ GNUNET_MQ_send (ai->client->mq, env);
+ }
+ }
}
}
oidc_attr_collect (void *cls,
const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr,
- const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest)
+ const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest,
+ const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference)
{
struct RequestHandle *handle = cls;
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le;
attr->data,
attr->data_size);
le->claim->id = attr->id;
- le->claim->version = attr->version;
+ le->claim->flag = attr->flag;
GNUNET_CONTAINER_DLL_insert (handle->attr_list->list_head,
handle->attr_list->list_tail,
le);
consume_ticket (void *cls,
const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr,
- const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest)
+ const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest,
+ const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference)
{
struct RequestHandle *handle = cls;
char *tmp_value;
attest_collect (void *cls,
const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr,
- const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest)
+ const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest,
+ const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference)
{
struct RequestHandle *handle = cls;
json_t *attr_obj;
attr_collect (void *cls,
const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr,
- const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest)
+ const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest,
+ const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference)
{
struct RequestHandle *handle = cls;
json_t *attr_obj;
consume_cont (void *cls,
const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr,
- const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest)
+ const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest,
+ const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference)
{
struct RequestHandle *handle = cls;
char *val_str;
{
if (NULL == attrs)
{
- op->ar_cb (op->cls, &msg->identity, NULL, NULL);
+ op->ar_cb (op->cls, &msg->identity, NULL, NULL, NULL);
}
else
{
for (le = attrs->list_head; NULL != le; le = le->next)
- op->ar_cb (op->cls, &msg->identity, le->claim, NULL);
+ op->ar_cb (op->cls, &msg->identity, le->claim, NULL, NULL);
GNUNET_RECLAIM_ATTRIBUTE_list_destroy (attrs);
attrs = NULL;
}
- op->ar_cb (op->cls, NULL, NULL, NULL);
+ op->ar_cb (op->cls, NULL, NULL, NULL, NULL);
}
GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
free_op (op);
if (NULL != op)
{
if (NULL != op->ar_cb)
- op->ar_cb (op->cls, NULL, NULL, NULL);
+ op->ar_cb (op->cls, NULL, NULL, NULL, NULL);
GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
free_op (op);
}
if (NULL != it)
{
if (NULL != it->proc)
- it->proc (it->proc_cls, &msg->identity, attr, NULL);
+ it->proc (it->proc_cls, &msg->identity, attr, NULL, NULL);
}
else if (NULL != op)
{
if (NULL != op->ar_cb)
- op->ar_cb (op->cls, &msg->identity, attr, NULL);
+ op->ar_cb (op->cls, &msg->identity, attr, NULL, NULL);
}
GNUNET_free (attr);
return;
if (NULL != op)
{
if (NULL != op->ar_cb)
- op->ar_cb (op->cls, NULL, NULL, NULL);
+ op->ar_cb (op->cls, NULL, NULL, NULL, NULL);
GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
free_op (op);
}
if (NULL != it)
{
if (NULL != it->proc)
- it->proc (it->proc_cls, &msg->identity, NULL, attr);
+ it->proc (it->proc_cls, &msg->identity, NULL, attr, NULL);
}
else if (NULL != op)
{
if (NULL != op->ar_cb)
- op->ar_cb (op->cls, &msg->identity, NULL, attr);
+ op->ar_cb (op->cls, &msg->identity, NULL, attr, NULL);
+ }
+ GNUNET_free (attr);
+ return;
+ }
+ GNUNET_assert (0);
+}
+
+/**
+ * Handle an incoming message of type
+ * #GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_RESULT
+ *
+ * @param cls
+ * @param msg the message we received
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
+ */
+static int
+check_reference_result (void *cls, const struct AttributeResultMessage *msg)
+{
+ size_t msg_len;
+ size_t attr_len;
+
+ msg_len = ntohs (msg->header.size);
+ attr_len = ntohs (msg->attr_len);
+ if (msg_len != sizeof(struct AttributeResultMessage) + attr_len)
+ {
+ GNUNET_break (0);
+ return GNUNET_SYSERR;
+ }
+ return GNUNET_OK;
+}
+
+/**
+* Handle an incoming message of type
+* #GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_RESULT
+*
+* @param cls
+* @param msg the message we received
+*/
+static void
+handle_reference_result (void *cls, const struct AttributeResultMessage *msg)
+{
+ static struct GNUNET_CRYPTO_EcdsaPrivateKey identity_dummy;
+ struct GNUNET_RECLAIM_Handle *h = cls;
+ struct GNUNET_RECLAIM_AttributeIterator *it;
+ struct GNUNET_RECLAIM_Operation *op;
+ size_t attr_len;
+ uint32_t r_id = ntohl (msg->id);
+
+ attr_len = ntohs (msg->attr_len);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Processing reference result.\n");
+
+
+ for (it = h->it_head; NULL != it; it = it->next)
+ if (it->r_id == r_id)
+ break;
+ for (op = h->op_head; NULL != op; op = op->next)
+ if (op->r_id == r_id)
+ break;
+ if ((NULL == it) && (NULL == op))
+ return;
+
+ if ((0 ==
+ (memcmp (&msg->identity, &identity_dummy, sizeof(identity_dummy)))))
+ {
+ if ((NULL == it) && (NULL == op))
+ {
+ GNUNET_break (0);
+ force_reconnect (h);
+ return;
+ }
+ if (NULL != it)
+ {
+ if (NULL != it->finish_cb)
+ it->finish_cb (it->finish_cb_cls);
+ free_it (it);
+ }
+ if (NULL != op)
+ {
+ if (NULL != op->ar_cb)
+ op->ar_cb (op->cls, NULL, NULL, NULL, NULL);
+ GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, op);
+ free_op (op);
+ }
+ return;
+ }
+
+ {
+ struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr;
+ attr = GNUNET_RECLAIM_ATTESTATION_REF_deserialize ((char *) &msg[1],
+ attr_len);
+ if (NULL != it)
+ {
+ if (NULL != it->proc)
+ it->proc (it->proc_cls, &msg->identity, NULL, NULL, attr);
+ }
+ else if (NULL != op)
+ {
+ if (NULL != op->ar_cb)
+ op->ar_cb (op->cls, &msg->identity, NULL, NULL, attr);
}
GNUNET_free (attr);
return;
GNUNET_MESSAGE_TYPE_RECLAIM_ATTESTATION_RESULT,
struct AttributeResultMessage,
h),
+ GNUNET_MQ_hd_var_size (reference_result,
+ GNUNET_MESSAGE_TYPE_RECLAIM_REFERENCE_RESULT,
+ struct AttributeResultMessage,
+ h),
GNUNET_MQ_hd_fixed_size (ticket_result,
GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT,
struct TicketResultMessage,