GNUnet  0.11.x
Data Structures | Macros | Functions
reclaim attributes

Data Structures

struct  GNUNET_RECLAIM_ATTRIBUTE_Claim
 An attribute. More...
 
struct  GNUNET_RECLAIM_ATTESTATION_Claim
 An attestation. More...
 
struct  GNUNET_RECLAIM_ATTESTATION_REFERENCE
 A reference to an Attestatiom. More...
 
struct  GNUNET_RECLAIM_ATTRIBUTE_ClaimList
 A list of GNUNET_RECLAIM_ATTRIBUTE_Claim structures. More...
 
struct  GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry
 
struct  GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType
 

Macros

#define GNUNET_RECLAIM_ATTRIBUTE_TYPE_NONE   0
 No value attribute. More...
 
#define GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING   1
 String attribute. More...
 
#define GNUNET_RECLAIM_ATTESTATION_TYPE_NONE   10
 No value attestation. More...
 
#define GNUNET_RECLAIM_ATTESTATION_TYPE_JWT   11
 A JSON Web Token attestation. More...
 

Functions

struct GNUNET_RECLAIM_ATTRIBUTE_ClaimGNUNET_RECLAIM_ATTRIBUTE_claim_new (const char *attr_name, uint32_t type, const void *data, size_t data_size)
 Create a new attribute claim. More...
 
size_t GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size (const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs)
 Get required size for serialization buffer. More...
 
void GNUNET_RECLAIM_ATTRIBUTE_list_destroy (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs)
 Destroy claim list. More...
 
void GNUNET_RECLAIM_ATTRIBUTE_list_add (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, const char *attr_name, uint32_t type, const void *data, size_t data_size)
 Add a new attribute to a claim list. More...
 
size_t GNUNET_RECLAIM_ATTRIBUTE_list_serialize (const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, char *result)
 Serialize an attribute list. More...
 
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListGNUNET_RECLAIM_ATTRIBUTE_list_deserialize (const char *data, size_t data_size)
 Deserialize an attribute list. More...
 
int GNUNET_RECLAIM_ATTRIBUTE_list_count_attest (const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs)
 Count attestations in claim list. More...
 
size_t GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr)
 Get required size for serialization buffer. More...
 
size_t GNUNET_RECLAIM_ATTRIBUTE_serialize (const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, char *result)
 Serialize an attribute. More...
 
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimGNUNET_RECLAIM_ATTRIBUTE_deserialize (const char *data, size_t data_size)
 Deserialize an attribute. More...
 
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListGNUNET_RECLAIM_ATTRIBUTE_list_dup (const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs)
 Make a (deep) copy of a claim list. More...
 
uint32_t GNUNET_RECLAIM_ATTRIBUTE_typename_to_number (const char *typename)
 Convert a type name to the corresponding number. More...
 
int GNUNET_RECLAIM_ATTRIBUTE_string_to_value (uint32_t type, const char *s, void **data, size_t *data_size)
 Convert human-readable version of a 'claim' of an attribute to the binary representation. More...
 
char * GNUNET_RECLAIM_ATTRIBUTE_value_to_string (uint32_t type, const void *data, size_t data_size)
 Convert the 'claim' of an attribute to a string. More...
 
const char * GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (uint32_t type)
 Convert a type number to the corresponding type string. More...
 
size_t GNUNET_RECLAIM_ATTESTATION_serialize_get_size (const struct GNUNET_RECLAIM_ATTESTATION_Claim *attr)
 Get required size for serialization buffer FIXME: More...
 
size_t GNUNET_RECLAIM_ATTESTATION_serialize (const struct GNUNET_RECLAIM_ATTESTATION_Claim *attr, char *result)
 Serialize an attestation. More...
 
struct GNUNET_RECLAIM_ATTESTATION_ClaimGNUNET_RECLAIM_ATTESTATION_deserialize (const char *data, size_t data_size)
 Deserialize an attestation. More...
 
struct GNUNET_RECLAIM_ATTESTATION_ClaimGNUNET_RECLAIM_ATTESTATION_claim_new (const char *attr_name, uint32_t type, const void *data, size_t data_size)
 Create a new attestation. More...
 
char * GNUNET_RECLAIM_ATTESTATION_value_to_string (uint32_t type, const void *data, size_t data_size)
 Convert the 'claim' of an attestation to a string. More...
 
int GNUNET_RECLAIM_ATTESTATION_string_to_value (uint32_t type, const char *s, void **data, size_t *data_size)
 Convert human-readable version of a 'claim' of an attestation to the binary representation. More...
 
const char * GNUNET_RECLAIM_ATTESTATION_number_to_typename (uint32_t type)
 Convert an attestation type number to the corresponding attestation type string. More...
 
uint32_t GNUNET_RECLAIM_ATTESTATION_typename_to_number (const char *typename)
 Convert an attestation type name to the corresponding number. More...
 
struct GNUNET_RECLAIM_ATTESTATION_REFERENCEGNUNET_RECLAIM_ATTESTATION_reference_new (const char *attr_name, const char *ref_value)
 Create a new attestation reference. More...
 
size_t GNUNET_RECLAIM_ATTESTATION_REF_serialize_get_size (const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr)
 Get required size for serialization buffer. More...
 
size_t GNUNET_RECLAIM_ATTESTATION_REF_serialize (const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr, char *result)
 Serialize a reference. More...
 
struct GNUNET_RECLAIM_ATTESTATION_REFERENCEGNUNET_RECLAIM_ATTESTATION_REF_deserialize (const char *data, size_t data_size)
 Deserialize a reference. More...
 

Detailed Description

Macro Definition Documentation

◆ GNUNET_RECLAIM_ATTRIBUTE_TYPE_NONE

#define GNUNET_RECLAIM_ATTRIBUTE_TYPE_NONE   0

No value attribute.

Definition at line 46 of file gnunet_reclaim_attribute_lib.h.

◆ GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING

#define GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING   1

String attribute.

Definition at line 51 of file gnunet_reclaim_attribute_lib.h.

Referenced by gnuid_string_to_value(), gnuid_value_to_string(), and iter_finished().

◆ GNUNET_RECLAIM_ATTESTATION_TYPE_NONE

#define GNUNET_RECLAIM_ATTESTATION_TYPE_NONE   10

No value attestation.

Definition at line 56 of file gnunet_reclaim_attribute_lib.h.

◆ GNUNET_RECLAIM_ATTESTATION_TYPE_JWT

#define GNUNET_RECLAIM_ATTESTATION_TYPE_JWT   11

A JSON Web Token attestation.

Definition at line 61 of file gnunet_reclaim_attribute_lib.h.

Referenced by gnuid_string_to_value_attest(), and gnuid_value_to_string_attest().

Function Documentation

◆ GNUNET_RECLAIM_ATTRIBUTE_claim_new()

struct GNUNET_RECLAIM_ATTRIBUTE_Claim* GNUNET_RECLAIM_ATTRIBUTE_claim_new ( const char *  attr_name,
uint32_t  type,
const void *  data,
size_t  data_size 
)

Create a new attribute claim.

Parameters
attr_namethe attribute name
typethe attribute type
datathe attribute value
data_sizethe attribute value size
Returns
the new attribute

Create a new attribute claim.

Parameters
attr_namethe attribute name
typethe attribute type
datathe attribute value
data_sizethe attribute value size
Returns
the new attribute

Definition at line 341 of file reclaim_attribute.c.

References GNUNET_RECLAIM_ATTRIBUTE_Claim::data, GNUNET_RECLAIM_ATTRIBUTE_Claim::data_size, data_size, GNUNET_RECLAIM_ATTRIBUTE_Claim::flag, GNUNET_free, GNUNET_malloc, GNUNET_memcpy, GNUNET_strdup, GNUNET_STRINGS_utf8_tolower(), GNUNET_RECLAIM_ATTRIBUTE_Claim::name, GNUNET_RECLAIM_ATTRIBUTE_Claim::type, and type.

Referenced by GNUNET_RECLAIM_ATTRIBUTE_list_add(), GNUNET_RECLAIM_ATTRIBUTE_list_dup(), iter_cb(), iter_finished(), oidc_attr_collect(), parse_attr(), and parse_jwt().

345 {
346  struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr;
347  char *write_ptr;
348  char *attr_name_tmp = GNUNET_strdup (attr_name);
349 
350  GNUNET_STRINGS_utf8_tolower (attr_name, attr_name_tmp);
351 
352  attr = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_Claim)
353  + strlen (attr_name_tmp) + 1 + data_size);
354  attr->type = type;
355  attr->data_size = data_size;
356  attr->flag = 0;
357  write_ptr = (char *) &attr[1];
358  GNUNET_memcpy (write_ptr, attr_name_tmp, strlen (attr_name_tmp) + 1);
359  attr->name = write_ptr;
360  write_ptr += strlen (attr->name) + 1;
361  GNUNET_memcpy (write_ptr, data, data_size);
362  attr->data = write_ptr;
363  GNUNET_free (attr_name_tmp);
364  return attr;
365 }
const char * name
The name of the attribute.
size_t data_size
Number of bytes in data.
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
const void * data
Binary value stored as attribute value.
static char * attr_name
The attribute.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
uint32_t data
The data value.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_STRINGS_utf8_tolower(const char *input, char *output)
Convert the utf-8 input string to lower case.
Definition: strings.c:553
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size()

size_t GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size ( const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList attrs)

Get required size for serialization buffer.

Parameters
attrsthe attribute list to serialize
Returns
the required buffer size

Definition at line 472 of file reclaim_attribute.c.

References GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry::attest, GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry::claim, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_RECLAIM_ATTESTATION_REF_serialize_get_size(), GNUNET_RECLAIM_ATTESTATION_serialize_get_size(), GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size(), len, GNUNET_RECLAIM_ATTRIBUTE_ClaimList::list_head, GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry::next, and GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry::reference.

Referenced by consume_result_cb(), GNUNET_RECLAIM_ticket_issue(), and OIDC_build_authz_code().

474 {
476  size_t len = 0;
477 
478  for (le = attrs->list_head; NULL != le; le = le->next)
479  {
480  if (NULL != le->claim)
481  {
482  len += sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType);
484  }
485  else if (NULL != le->attest )
486  {
487  len += sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType);
489  }
490  else if (NULL != le->reference)
491  {
492  len += sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType);
494  }
495  else
496  {
498  "Unserialized Claim List Entry Type for size not known.\n");
499  break;
500  }
501  len += sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry);
502  }
503  return len;
504 }
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * claim
The attribute claim.
size_t GNUNET_RECLAIM_ATTESTATION_serialize_get_size(const struct GNUNET_RECLAIM_ATTESTATION_Claim *attr)
Get required size for serialization buffer.
struct GNUNET_RECLAIM_ATTESTATION_REFERENCE * reference
The reference.
struct GNUNET_RECLAIM_ATTESTATION_Claim * attest
The attestation claim.
size_t GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size(const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr)
Get required size for serialization buffer.
#define GNUNET_log(kind,...)
size_t GNUNET_RECLAIM_ATTESTATION_REF_serialize_get_size(const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr)
Get required size for serialization buffer.
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry * next
DLL.
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry * list_head
List head.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_ATTRIBUTE_list_destroy()

void GNUNET_RECLAIM_ATTRIBUTE_list_destroy ( struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList attrs)

Destroy claim list.

Parameters
attrslist to destroy

Definition at line 728 of file reclaim_attribute.c.

References GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry::attest, GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry::claim, GNUNET_free, GNUNET_RECLAIM_ATTRIBUTE_ClaimList::list_head, GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry::next, and GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry::reference.

Referenced by cleanup_cth(), handle_consume_ticket_result(), handle_issue_ticket_message(), and token_endpoint().

730 {
733 
734  for (le = attrs->list_head; NULL != le; le = le->next)
735  {
736  if (NULL != le->claim)
737  GNUNET_free (le->claim);
738  if (NULL != le->attest)
739  GNUNET_free (le->attest);
740  if (NULL != le->reference)
741  GNUNET_free (le->reference);
742  tmp_le = le;
743  le = le->next;
744  GNUNET_free (tmp_le);
745  }
746  GNUNET_free (attrs);
747 }
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * claim
The attribute claim.
struct GNUNET_RECLAIM_ATTESTATION_REFERENCE * reference
The reference.
struct GNUNET_RECLAIM_ATTESTATION_Claim * attest
The attestation claim.
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry * next
DLL.
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry * list_head
List head.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_ATTRIBUTE_list_add()

void GNUNET_RECLAIM_ATTRIBUTE_list_add ( struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList claim_list,
const char *  attr_name,
uint32_t  type,
const void *  data,
size_t  data_size 
)

Add a new attribute to a claim list.

Parameters
attr_namethe name of the new attribute claim
typethe type of the claim
dataclaim payload
data_sizeclaim payload size

Definition at line 447 of file reclaim_attribute.c.

References GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry::claim, GNUNET_CONTAINER_DLL_insert, GNUNET_new, GNUNET_RECLAIM_ATTRIBUTE_claim_new(), GNUNET_RECLAIM_ATTRIBUTE_ClaimList::list_head, and GNUNET_RECLAIM_ATTRIBUTE_ClaimList::list_tail.

453 {
455 
457  le->claim =
460  claim_list->list_tail,
461  le);
462 }
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * claim
The attribute claim.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry * list_tail
List tail.
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static char * attr_name
The attribute.
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * GNUNET_RECLAIM_ATTRIBUTE_claim_new(const char *attr_name, uint32_t type, const void *data, size_t data_size)
Create a new attribute.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
uint32_t data
The data value.
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry * list_head
List head.
Here is the call graph for this function:

◆ GNUNET_RECLAIM_ATTRIBUTE_list_serialize()

size_t GNUNET_RECLAIM_ATTRIBUTE_list_serialize ( const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList attrs,
char *  result 
)

Serialize an attribute list.

Parameters
attrsthe attribute list to serialize
resultthe serialized attribute
Returns
length of serialized data

Definition at line 515 of file reclaim_attribute.c.

References GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry::attest, GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry::claim, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_RECLAIM_ATTESTATION_REF_serialize(), GNUNET_RECLAIM_ATTESTATION_serialize(), GNUNET_RECLAIM_ATTRIBUTE_serialize(), len, GNUNET_RECLAIM_ATTRIBUTE_ClaimList::list_head, GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry::next, GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry::reference, result, and GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType::type.

Referenced by consume_result_cb(), GNUNET_RECLAIM_ticket_issue(), and OIDC_build_authz_code().

518 {
520  size_t len;
521  size_t total_len;
522  char *write_ptr;
523  write_ptr = result;
524  total_len = 0;
525  for (le = attrs->list_head; NULL != le; le = le->next)
526  {
528  if (NULL != le->claim)
529  {
530  list_type = (struct
532  list_type->type = htons (1);
533  total_len += sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType);
534  write_ptr += sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType);
535  len = GNUNET_RECLAIM_ATTRIBUTE_serialize (le->claim, write_ptr);
536  total_len += len;
537  write_ptr += len;
538  }
539  else if (NULL != le->attest )
540  {
541  list_type = (struct
543  list_type->type = htons (2);
544  total_len += sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType);
545  write_ptr += sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType);
546  len = GNUNET_RECLAIM_ATTESTATION_serialize (le->attest, write_ptr);
547  total_len += len;
548  write_ptr += len;
549  }
550  else if (NULL != le->reference)
551  {
552  list_type = (struct
554  list_type->type = htons (3);
555  total_len += sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType);
556  write_ptr += sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType);
558  total_len += len;
559  write_ptr += len;
560  }
561  else
562  {
564  "Unserialized Claim List Entry Type not known.\n");
565  continue;
566  }
567  }
568  return total_len;
569 }
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * claim
The attribute claim.
struct GNUNET_RECLAIM_ATTESTATION_REFERENCE * reference
The reference.
size_t GNUNET_RECLAIM_ATTESTATION_REF_serialize(const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr, char *result)
Serialize a reference.
struct GNUNET_RECLAIM_ATTESTATION_Claim * attest
The attestation claim.
static int result
Global testing status.
size_t GNUNET_RECLAIM_ATTESTATION_serialize(const struct GNUNET_RECLAIM_ATTESTATION_Claim *attr, char *result)
Serialize an attestation.
#define GNUNET_log(kind,...)
size_t GNUNET_RECLAIM_ATTRIBUTE_serialize(const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, char *result)
Serialize an attribute.
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry * next
DLL.
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry * list_head
List head.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_ATTRIBUTE_list_deserialize()

struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList* GNUNET_RECLAIM_ATTRIBUTE_list_deserialize ( const char *  data,
size_t  data_size 
)

Deserialize an attribute list.

Parameters
datathe serialized attribute list
data_sizethe length of the serialized data
Returns
a GNUNET_IDENTITY_PROVIDER_AttributeList, must be free'd by caller

Definition at line 580 of file reclaim_attribute.c.

References GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry::attest, GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry::claim, data, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_new, GNUNET_RECLAIM_ATTESTATION_deserialize(), GNUNET_RECLAIM_ATTESTATION_REF_deserialize(), GNUNET_RECLAIM_ATTESTATION_REF_serialize_get_size(), GNUNET_RECLAIM_ATTESTATION_serialize_get_size(), GNUNET_RECLAIM_ATTRIBUTE_deserialize(), GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size(), GNUNET_RECLAIM_ATTRIBUTE_ClaimList::list_head, GNUNET_RECLAIM_ATTRIBUTE_ClaimList::list_tail, GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry::reference, and GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType::type.

Referenced by handle_consume_ticket_result(), handle_issue_ticket_message(), and OIDC_parse_authz_code().

581 {
584  size_t attr_len;
585  const char *read_ptr;
586 
587  if ((data_size < sizeof(struct Attribute) + sizeof(struct
589  && (data_size < sizeof(struct
590  Attestation)
591  + sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry)) &&
592  (data_size < sizeof(struct Attestation_Reference) + sizeof(struct
594  return NULL;
595 
597  read_ptr = data;
598  while (((data + data_size) - read_ptr) >= sizeof(struct Attribute))
599  {
601  list_type = (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType *) read_ptr;
602  if (1 == ntohs (list_type->type))
603  {
605  read_ptr += sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType);
606  if (((data + data_size) - read_ptr) < sizeof(struct Attribute))
607  break;
608  le->attest = NULL;
609  le->reference = NULL;
610  le->claim =
612  data_size - (read_ptr - data));
613  GNUNET_CONTAINER_DLL_insert (attrs->list_head, attrs->list_tail, le);
615  read_ptr += attr_len;
616  }
617  else if (2 == ntohs (list_type->type))
618  {
620  read_ptr += sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType);
621  if (((data + data_size) - read_ptr) < sizeof(struct Attestation))
622  break;
623  le->claim = NULL;
624  le->reference = NULL;
625  le->attest =
627  data_size - (read_ptr - data));
628  GNUNET_CONTAINER_DLL_insert (attrs->list_head, attrs->list_tail, le);
630  read_ptr += attr_len;
631  }
632  else if (3 == ntohs (list_type->type))
633  {
635  read_ptr += sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntryType);
636  if (((data + data_size) - read_ptr) < sizeof(struct
638  break;
639  le->claim = NULL;
640  le->attest = NULL;
641  le->reference =
643  data_size - (read_ptr
644  - data));
645  GNUNET_CONTAINER_DLL_insert (attrs->list_head, attrs->list_tail, le);
647  le->reference);
648  read_ptr += attr_len;
649  }
650  else
651  {
653  "Serialized Claim List Entry Type not known.\n");
654  break;
655  }
656  }
657  return attrs;
658 }
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * claim
The attribute claim.
size_t GNUNET_RECLAIM_ATTESTATION_serialize_get_size(const struct GNUNET_RECLAIM_ATTESTATION_Claim *attr)
Get required size for serialization buffer.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry * list_tail
List tail.
struct GNUNET_RECLAIM_ATTESTATION_REFERENCE * reference
The reference.
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
struct GNUNET_RECLAIM_ATTESTATION_REFERENCE * GNUNET_RECLAIM_ATTESTATION_REF_deserialize(const char *data, size_t data_size)
Deserialize a reference.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Serialized claim.
struct GNUNET_RECLAIM_ATTESTATION_Claim * attest
The attestation claim.
Serialized attestation reference.
struct GNUNET_RECLAIM_ATTESTATION_Claim * GNUNET_RECLAIM_ATTESTATION_deserialize(const char *data, size_t data_size)
Deserialize an attestation.
size_t GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size(const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr)
Get required size for serialization buffer.
A list of GNUNET_RECLAIM_ATTRIBUTE_Claim structures.
#define GNUNET_log(kind,...)
size_t GNUNET_RECLAIM_ATTESTATION_REF_serialize_get_size(const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr)
Get required size for serialization buffer.
Serialized attestation claim.
uint32_t data
The data value.
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry * list_head
List head.
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * GNUNET_RECLAIM_ATTRIBUTE_deserialize(const char *data, size_t data_size)
Deserialize an attribute.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_ATTRIBUTE_list_count_attest()

int GNUNET_RECLAIM_ATTRIBUTE_list_count_attest ( const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList attrs)

Count attestations in claim list.

Parameters
attrslist

Definition at line 755 of file reclaim_attribute.c.

References GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry::attest, GNUNET_RECLAIM_ATTRIBUTE_ClaimList::list_head, and GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry::next.

Referenced by OIDC_id_token_new().

757 {
759  int i = 0;
760  for (le = attrs->list_head; NULL != le; le = le->next)
761  {
762  if (NULL != le->attest)
763  i++;
764  }
765  return i;
766 }
struct GNUNET_RECLAIM_ATTESTATION_Claim * attest
The attestation claim.
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry * next
DLL.
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry * list_head
List head.
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size()

size_t GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size ( const struct GNUNET_RECLAIM_ATTRIBUTE_Claim attr)

Get required size for serialization buffer.

Parameters
attrthe attribute to serialize
Returns
the required buffer size

Definition at line 774 of file reclaim_attribute.c.

Referenced by attr_store_task(), GNUNET_RECLAIM_attribute_delete(), GNUNET_RECLAIM_ATTRIBUTE_list_deserialize(), GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size(), GNUNET_RECLAIM_attribute_store(), and rvk_move_attr_cb().

776 {
777  return sizeof(struct Attribute) + strlen (attr->name) + attr->data_size;
778 }
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
Serialized claim.
const char * name
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_ATTRIBUTE_serialize()

size_t GNUNET_RECLAIM_ATTRIBUTE_serialize ( const struct GNUNET_RECLAIM_ATTRIBUTE_Claim attr,
char *  result 
)

Serialize an attribute.

Parameters
attrthe attribute to serialize
resultthe serialized attribute
Returns
length of serialized data

Definition at line 789 of file reclaim_attribute.c.

References Attribute::attribute_id, Attribute::attribute_type, Attribute::attribute_version, GNUNET_RECLAIM_ATTRIBUTE_Claim::data, Attribute::data_size, GNUNET_RECLAIM_ATTRIBUTE_Claim::data_size, GNUNET_RECLAIM_ATTRIBUTE_Claim::flag, GNUNET_htonll(), GNUNET_memcpy, GNUNET_RECLAIM_ATTRIBUTE_Claim::id, GNUNET_RECLAIM_ATTRIBUTE_Claim::name, Attribute::name_len, and GNUNET_RECLAIM_ATTRIBUTE_Claim::type.

Referenced by attr_store_task(), GNUNET_RECLAIM_attribute_delete(), GNUNET_RECLAIM_ATTRIBUTE_list_serialize(), GNUNET_RECLAIM_attribute_store(), and rvk_move_attr_cb().

792 {
793  size_t data_len_ser;
794  size_t name_len;
795  struct Attribute *attr_ser;
796  char *write_ptr;
797 
798  attr_ser = (struct Attribute *) result;
799  attr_ser->attribute_type = htons (attr->type);
800  attr_ser->attribute_version = htonl (attr->flag);
801  attr_ser->attribute_id = GNUNET_htonll (attr->id);
802  name_len = strlen (attr->name);
803  attr_ser->name_len = htons (name_len);
804  write_ptr = (char *) &attr_ser[1];
805  GNUNET_memcpy (write_ptr, attr->name, name_len);
806  write_ptr += name_len;
807  // TODO plugin-ize
808  // data_len_ser = plugin->serialize_attribute_value (attr,
809  // &attr_ser[1]);
810  data_len_ser = attr->data_size;
811  GNUNET_memcpy (write_ptr, attr->data, attr->data_size);
812  attr_ser->data_size = htons (data_len_ser);
813 
814  return sizeof(struct Attribute) + strlen (attr->name) + attr->data_size;
815 }
const char * name
The name of the attribute.
size_t data_size
Number of bytes in data.
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
Serialized claim.
const void * data
Binary value stored as attribute value.
uint32_t data_size
Data size.
static int result
Global testing status.
uint32_t attribute_version
Attribute version.
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:36
uint64_t attribute_id
Attribute ID.
const char * name
uint32_t name_len
Name length.
uint32_t attribute_type
Attribute type.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_ATTRIBUTE_deserialize()

struct GNUNET_RECLAIM_ATTRIBUTE_Claim* GNUNET_RECLAIM_ATTRIBUTE_deserialize ( const char *  data,
size_t  data_size 
)

Deserialize an attribute.

Parameters
datathe serialized attribute
data_sizethe length of the serialized data
Returns
a GNUNET_IDENTITY_PROVIDER_Attribute, must be free'd by caller

Definition at line 827 of file reclaim_attribute.c.

References Attribute::attribute_id, Attribute::attribute_type, Attribute::attribute_version, GNUNET_RECLAIM_ATTRIBUTE_Claim::data, Attribute::data_size, GNUNET_RECLAIM_ATTRIBUTE_Claim::data_size, GNUNET_RECLAIM_ATTRIBUTE_Claim::flag, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_malloc, GNUNET_memcpy, GNUNET_ntohll(), GNUNET_RECLAIM_ATTRIBUTE_Claim::id, GNUNET_RECLAIM_ATTRIBUTE_Claim::name, Attribute::name_len, and GNUNET_RECLAIM_ATTRIBUTE_Claim::type.

Referenced by GNUNET_RECLAIM_ATTRIBUTE_list_deserialize(), handle_attribute_delete_message(), handle_attribute_result(), handle_attribute_store_message(), process_parallel_lookup_result(), and rvk_move_attr_cb().

828 {
829  struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr;
830  struct Attribute *attr_ser;
831  size_t data_len;
832  size_t name_len;
833  char *write_ptr;
834 
835  if (data_size < sizeof(struct Attribute))
836  return NULL;
837 
838  attr_ser = (struct Attribute *) data;
839  data_len = ntohs (attr_ser->data_size);
840  name_len = ntohs (attr_ser->name_len);
841  if (data_size < sizeof(struct Attribute) + data_len + name_len)
842  {
844  "Buffer too small to deserialize\n");
845  return NULL;
846  }
847  attr = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_Claim)
848  + data_len + name_len + 1);
849  attr->type = ntohs (attr_ser->attribute_type);
850  attr->flag = ntohl (attr_ser->attribute_version);
851  attr->id = GNUNET_ntohll (attr_ser->attribute_id);
852  attr->data_size = data_len;
853 
854  write_ptr = (char *) &attr[1];
855  GNUNET_memcpy (write_ptr, &attr_ser[1], name_len);
856  write_ptr[name_len] = '\0';
857  attr->name = write_ptr;
858 
859  write_ptr += name_len + 1;
860  GNUNET_memcpy (write_ptr, (char *) &attr_ser[1] + name_len, attr->data_size);
861  attr->data = write_ptr;
862  return attr;
863 }
const char * name
The name of the attribute.
size_t data_size
Number of bytes in data.
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
Serialized claim.
const void * data
Binary value stored as attribute value.
uint32_t data_size
Data size.
uint32_t attribute_version
Attribute version.
uint64_t attribute_id
Attribute ID.
#define GNUNET_log(kind,...)
uint32_t name_len
Name length.
uint32_t data
The data value.
uint32_t attribute_type
Attribute type.
#define GNUNET_malloc(size)
Wrapper around malloc.
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:53
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_ATTRIBUTE_list_dup()

struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList* GNUNET_RECLAIM_ATTRIBUTE_list_dup ( const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList attrs)

Make a (deep) copy of a claim list.

Parameters
attrsclaim list to copy
Returns
copied claim list

Definition at line 667 of file reclaim_attribute.c.

References GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry::attest, GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry::claim, GNUNET_RECLAIM_ATTRIBUTE_Claim::data, GNUNET_RECLAIM_ATTESTATION_Claim::data, GNUNET_RECLAIM_ATTRIBUTE_Claim::data_size, data_size, GNUNET_RECLAIM_ATTRIBUTE_Claim::flag, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_new, GNUNET_RECLAIM_ATTESTATION_claim_new(), GNUNET_RECLAIM_ATTESTATION_reference_new(), GNUNET_RECLAIM_ATTRIBUTE_claim_new(), GNUNET_RECLAIM_ATTRIBUTE_Claim::id, GNUNET_RECLAIM_ATTESTATION_Claim::id, GNUNET_RECLAIM_ATTESTATION_REFERENCE::id, GNUNET_RECLAIM_ATTESTATION_REFERENCE::id_attest, GNUNET_RECLAIM_ATTRIBUTE_ClaimList::list_head, GNUNET_RECLAIM_ATTRIBUTE_ClaimList::list_tail, GNUNET_RECLAIM_ATTRIBUTE_Claim::name, GNUNET_RECLAIM_ATTESTATION_Claim::name, GNUNET_RECLAIM_ATTESTATION_REFERENCE::name, GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry::next, GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry::reference, GNUNET_RECLAIM_ATTESTATION_REFERENCE::reference_value, result, GNUNET_RECLAIM_ATTRIBUTE_Claim::type, and GNUNET_RECLAIM_ATTESTATION_Claim::type.

Referenced by RECLAIM_TICKETS_issue().

669 {
671  struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *result_le;
673 
675  if (NULL == attrs->list_head)
676  {
677  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Duplicating empty List\n");
678  }
679  for (le = attrs->list_head; NULL != le; le = le->next)
680  {
682  result_le->claim = NULL;
683  result_le->attest = NULL;
684  result_le->reference = NULL;
685  if (NULL != le->claim)
686  {
687  result_le->claim =
689  le->claim->type,
690  le->claim->data,
691  le->claim->data_size);
692 
693  result_le->claim->id = le->claim->id;
694  result_le->claim->flag = le->claim->flag;
695  }
696  if ( NULL != le->attest)
697  {
699  le->attest->name,
700  le->attest->type,
701  le->attest->data,
702  le->attest->
703  data_size);
704  result_le->attest->id = le->attest->id;
705  }
706  if (NULL !=le->reference)
707  {
709  le->reference->name,
711  result_le->reference->id = le->reference->id;
712  result_le->reference->id_attest = le->reference->id_attest;
713  }
715  result->list_tail,
716  result_le);
717  }
718  return result;
719 }
const char * name
The name of the attribute.
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * claim
The attribute claim.
struct GNUNET_RECLAIM_ATTESTATION_Claim * GNUNET_RECLAIM_ATTESTATION_claim_new(const char *attr_name, uint32_t type, const void *data, size_t data_size)
Create a new attestation.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
size_t data_size
Number of bytes in data.
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry * list_tail
List tail.
struct GNUNET_RECLAIM_ATTESTATION_REFERENCE * reference
The reference.
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
const char * reference_value
The name of the attribute/attestation reference value.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
uint64_t id_attest
Referenced ID of Attestation.
struct GNUNET_RECLAIM_ATTESTATION_Claim * attest
The attestation claim.
const void * data
Binary value stored as attribute value.
struct GNUNET_RECLAIM_ATTESTATION_REFERENCE * GNUNET_RECLAIM_ATTESTATION_reference_new(const char *attr_name, const char *ref_value)
Create a new attestation reference.
static int result
Global testing status.
const char * name
The name of the attribute.
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * GNUNET_RECLAIM_ATTRIBUTE_claim_new(const char *attr_name, uint32_t type, const void *data, size_t data_size)
Create a new attribute.
const char * name
The name of the attribute/attestation reference value.
A list of GNUNET_RECLAIM_ATTRIBUTE_Claim structures.
#define GNUNET_log(kind,...)
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry * next
DLL.
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry * list_head
List head.
const void * data
Binary value stored as attribute value.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_ATTRIBUTE_typename_to_number()

uint32_t GNUNET_RECLAIM_ATTRIBUTE_typename_to_number ( const char *  typename)

Convert a type name to the corresponding number.

Parameters
typenamename to convert
Returns
corresponding number, UINT32_MAX on error

Definition at line 113 of file reclaim_attribute.c.

References Plugin::api, GNUNET_BLOCK_PluginFunctions::cls, init(), num_plugins, plugin, and ret.

Referenced by iter_finished(), parse_attr(), and parse_jwt().

114 {
115  unsigned int i;
116  struct Plugin *plugin;
117  uint32_t ret;
118 
119  init ();
120  for (i = 0; i < num_plugins; i++)
121  {
122  plugin = attr_plugins[i];
123  if (UINT32_MAX !=
124  (ret = plugin->api->typename_to_number (plugin->api->cls, typename)))
125  return ret;
126  }
127  return UINT32_MAX;
128 }
static unsigned int num_plugins
Number of plugins.
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
static void init()
Load plugins.
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
static char * plugin
Solver plugin name as string.
static struct Plugin ** attr_plugins
Plugins.
Handle for a plugin.
Definition: block.c:37
void * cls
Closure for all of the callbacks.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_ATTRIBUTE_string_to_value()

int GNUNET_RECLAIM_ATTRIBUTE_string_to_value ( uint32_t  type,
const char *  s,
void **  data,
size_t *  data_size 
)

Convert human-readable version of a 'claim' of an attribute to the binary representation.

Parameters
typetype of the claim
shuman-readable string
dataset to value in binary encoding (will be allocated)
data_sizeset to number of bytes in data
Returns
GNUNET_OK on success

Definition at line 167 of file reclaim_attribute.c.

References Plugin::api, GNUNET_BLOCK_PluginFunctions::cls, GNUNET_OK, GNUNET_SYSERR, init(), num_plugins, and plugin.

Referenced by iter_finished(), parse_attr(), and parse_jwt().

171 {
172  unsigned int i;
173  struct Plugin *plugin;
174 
175  init ();
176  for (i = 0; i < num_plugins; i++)
177  {
178  plugin = attr_plugins[i];
179  if (GNUNET_OK == plugin->api->string_to_value (plugin->api->cls,
180  type,
181  s,
182  data,
183  data_size))
184  return GNUNET_OK;
185  }
186  return GNUNET_SYSERR;
187 }
static unsigned int num_plugins
Number of plugins.
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
static void init()
Load plugins.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
static char * plugin
Solver plugin name as string.
#define GNUNET_SYSERR
Definition: gnunet_common.h:84
static struct Plugin ** attr_plugins
Plugins.
Handle for a plugin.
Definition: block.c:37
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
void * cls
Closure for all of the callbacks.
uint32_t data
The data value.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_ATTRIBUTE_value_to_string()

char* GNUNET_RECLAIM_ATTRIBUTE_value_to_string ( uint32_t  type,
const void *  data,
size_t  data_size 
)

Convert the 'claim' of an attribute to a string.

Parameters
typethe type of attribute
dataclaim in binary encoding
data_sizenumber of bytes in data
Returns
NULL on error, otherwise human-readable representation of the claim

Definition at line 199 of file reclaim_attribute.c.

References Plugin::api, GNUNET_BLOCK_PluginFunctions::cls, init(), num_plugins, plugin, and ret.

Referenced by attr_collect(), consume_cont(), consume_ticket(), iter_cb(), OIDC_id_token_new(), and process_attrs().

202 {
203  unsigned int i;
204  struct Plugin *plugin;
205  char *ret;
206 
207  init ();
208  for (i = 0; i < num_plugins; i++)
209  {
210  plugin = attr_plugins[i];
211  if (NULL != (ret = plugin->api->value_to_string (plugin->api->cls,
212  type,
213  data,
214  data_size)))
215  return ret;
216  }
217  return NULL;
218 }
static unsigned int num_plugins
Number of plugins.
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
static void init()
Load plugins.
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
static char * plugin
Solver plugin name as string.
static struct Plugin ** attr_plugins
Plugins.
Handle for a plugin.
Definition: block.c:37
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
void * cls
Closure for all of the callbacks.
uint32_t data
The data value.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_ATTRIBUTE_number_to_typename()

const char* GNUNET_RECLAIM_ATTRIBUTE_number_to_typename ( uint32_t  type)

Convert a type number to the corresponding type string.

Parameters
typenumber of a type
Returns
corresponding typestring, NULL on error

Definition at line 138 of file reclaim_attribute.c.

References Plugin::api, GNUNET_BLOCK_PluginFunctions::cls, init(), num_plugins, plugin, and ret.

Referenced by attr_collect(), iter_cb(), and process_attrs().

139 {
140  unsigned int i;
141  struct Plugin *plugin;
142  const char *ret;
143 
144  init ();
145  for (i = 0; i < num_plugins; i++)
146  {
147  plugin = attr_plugins[i];
148  if (NULL !=
149  (ret = plugin->api->number_to_typename (plugin->api->cls, type)))
150  return ret;
151  }
152  return NULL;
153 }
static unsigned int num_plugins
Number of plugins.
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
static void init()
Load plugins.
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
static char * plugin
Solver plugin name as string.
static struct Plugin ** attr_plugins
Plugins.
Handle for a plugin.
Definition: block.c:37
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
void * cls
Closure for all of the callbacks.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_ATTESTATION_serialize_get_size()

size_t GNUNET_RECLAIM_ATTESTATION_serialize_get_size ( const struct GNUNET_RECLAIM_ATTESTATION_Claim attr)

Get required size for serialization buffer FIXME:

  1. The naming convention is violated here. It should GNUNET_RECLAIM_ATTRIBUTE_<lowercase from here>. It might make sense to refactor attestations into a separate folder.
  2. The struct should be called GNUNET_RECLAIM_ATTESTATION_Data or GNUNET_RECLAIM_ATTRIBUTE_Attestation depending on location in source.
Parameters
attrthe attestation to serialize
Returns
the required buffer size

Get required size for serialization buffer FIXME:

Parameters
attrthe attestation to serialize
Returns
the required buffer size

Definition at line 873 of file reclaim_attribute.c.

Referenced by attest_add_cb(), GNUNET_RECLAIM_attestation_delete(), GNUNET_RECLAIM_attestation_store(), GNUNET_RECLAIM_ATTRIBUTE_list_deserialize(), GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size(), and rvk_move_attr_cb().

875 {
876  return sizeof(struct Attestation) + strlen (attr->name) + attr->data_size;
877 }
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
const char * name
Serialized attestation claim.
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_ATTESTATION_serialize()

size_t GNUNET_RECLAIM_ATTESTATION_serialize ( const struct GNUNET_RECLAIM_ATTESTATION_Claim attr,
char *  result 
)

Serialize an attestation.

Parameters
attrthe attestation to serialize
resultthe serialized attestation
Returns
length of serialized data

Definition at line 887 of file reclaim_attribute.c.

References Attestation::attestation_id, Attestation::attestation_type, Attestation::attestation_version, GNUNET_RECLAIM_ATTESTATION_Claim::data, Attestation::data_size, GNUNET_RECLAIM_ATTESTATION_Claim::data_size, GNUNET_htonll(), GNUNET_memcpy, GNUNET_RECLAIM_ATTESTATION_Claim::id, GNUNET_RECLAIM_ATTESTATION_Claim::name, Attestation::name_len, GNUNET_RECLAIM_ATTESTATION_Claim::type, and GNUNET_RECLAIM_ATTESTATION_Claim::version.

Referenced by attest_add_cb(), GNUNET_RECLAIM_attestation_delete(), GNUNET_RECLAIM_attestation_store(), GNUNET_RECLAIM_ATTRIBUTE_list_serialize(), and rvk_move_attr_cb().

890 {
891  size_t data_len_ser;
892  size_t name_len;
893  struct Attestation *attr_ser;
894  char *write_ptr;
895 
896  attr_ser = (struct Attestation *) result;
897  attr_ser->attestation_type = htons (attr->type);
898  attr_ser->attestation_version = htonl (attr->version);
899  attr_ser->attestation_id = GNUNET_htonll (attr->id);
900  name_len = strlen (attr->name);
901  attr_ser->name_len = htons (name_len);
902  write_ptr = (char *) &attr_ser[1];
903  GNUNET_memcpy (write_ptr, attr->name, name_len);
904  write_ptr += name_len;
905  // TODO plugin-ize
906  // data_len_ser = plugin->serialize_attribute_value (attr,
907  // &attr_ser[1]);
908  data_len_ser = attr->data_size;
909  GNUNET_memcpy (write_ptr, attr->data, attr->data_size);
910  attr_ser->data_size = htons (data_len_ser);
911 
912  return sizeof(struct Attestation) + strlen (attr->name) + attr->data_size;
913 }
uint32_t attestation_version
Attestation version.
uint32_t attestation_type
Attestation type.
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
uint32_t name_len
Name length.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
uint64_t attestation_id
Attestation ID.
size_t data_size
Number of bytes in data.
static int result
Global testing status.
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:36
const char * name
The name of the attribute.
const char * name
Serialized attestation claim.
uint32_t data_size
Data size.
const void * data
Binary value stored as attribute value.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_ATTESTATION_deserialize()

struct GNUNET_RECLAIM_ATTESTATION_Claim* GNUNET_RECLAIM_ATTESTATION_deserialize ( const char *  data,
size_t  data_size 
)

Deserialize an attestation.

Parameters
datathe serialized attestation
data_sizethe length of the serialized data
Returns
a GNUNET_IDENTITY_PROVIDER_Attribute, must be free'd by caller

Definition at line 924 of file reclaim_attribute.c.

References Attestation::attestation_id, Attestation::attestation_type, Attestation::attestation_version, GNUNET_RECLAIM_ATTESTATION_Claim::data, Attestation::data_size, GNUNET_RECLAIM_ATTESTATION_Claim::data_size, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_malloc, GNUNET_memcpy, GNUNET_ntohll(), GNUNET_RECLAIM_ATTESTATION_Claim::id, GNUNET_RECLAIM_ATTESTATION_Claim::name, Attestation::name_len, GNUNET_RECLAIM_ATTESTATION_Claim::type, and GNUNET_RECLAIM_ATTESTATION_Claim::version.

Referenced by GNUNET_RECLAIM_ATTRIBUTE_list_deserialize(), handle_attestation_delete_message(), handle_attestation_result(), handle_attestation_store_message(), handle_reference_result(), process_parallel_lookup_result(), and rvk_move_attr_cb().

925 {
927  struct Attestation *attr_ser;
928  size_t data_len;
929  size_t name_len;
930  char *write_ptr;
931 
932  if (data_size < sizeof(struct Attestation))
933  return NULL;
934 
935  attr_ser = (struct Attestation *) data;
936  data_len = ntohs (attr_ser->data_size);
937  name_len = ntohs (attr_ser->name_len);
938  if (data_size < sizeof(struct Attestation) + data_len + name_len)
939  {
941  "Buffer too small to deserialize\n");
942  return NULL;
943  }
944  attr = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_ATTESTATION_Claim)
945  + data_len + name_len + 1);
946  attr->type = ntohs (attr_ser->attestation_type);
947  attr->version = ntohl (attr_ser->attestation_version);
948  attr->id = GNUNET_ntohll (attr_ser->attestation_id);
949  attr->data_size = data_len;
950 
951  write_ptr = (char *) &attr[1];
952  GNUNET_memcpy (write_ptr, &attr_ser[1], name_len);
953  write_ptr[name_len] = '\0';
954  attr->name = write_ptr;
955 
956  write_ptr += name_len + 1;
957  GNUNET_memcpy (write_ptr, (char *) &attr_ser[1] + name_len, attr->data_size);
958  attr->data = write_ptr;
959  return attr;
960 }
uint32_t attestation_version
Attestation version.
uint32_t attestation_type
Attestation type.
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
uint32_t name_len
Name length.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
uint64_t attestation_id
Attestation ID.
size_t data_size
Number of bytes in data.
const char * name
The name of the attribute.
#define GNUNET_log(kind,...)
Serialized attestation claim.
uint32_t data_size
Data size.
uint32_t data
The data value.
#define GNUNET_malloc(size)
Wrapper around malloc.
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:53
const void * data
Binary value stored as attribute value.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_ATTESTATION_claim_new()

struct GNUNET_RECLAIM_ATTESTATION_Claim* GNUNET_RECLAIM_ATTESTATION_claim_new ( const char *  attr_name,
uint32_t  type,
const void *  data,
size_t  data_size 
)

Create a new attestation.

Parameters
attr_namethe attestation name
typethe attestation type
datathe attestation value
data_sizethe attestation value size
Returns
the new attestation

Definition at line 377 of file reclaim_attribute.c.

References GNUNET_RECLAIM_ATTESTATION_Claim::data, GNUNET_RECLAIM_ATTESTATION_Claim::data_size, data_size, GNUNET_free, GNUNET_malloc, GNUNET_memcpy, GNUNET_strdup, GNUNET_STRINGS_utf8_tolower(), GNUNET_RECLAIM_ATTESTATION_Claim::name, GNUNET_RECLAIM_ATTESTATION_Claim::type, type, and GNUNET_RECLAIM_ATTESTATION_Claim::version.

Referenced by GNUNET_RECLAIM_ATTRIBUTE_list_dup(), oidc_attr_collect(), and parse_attest().

381 {
383  char *write_ptr;
384  char *attr_name_tmp = GNUNET_strdup (attr_name);
385 
386  GNUNET_STRINGS_utf8_tolower (attr_name, attr_name_tmp);
387 
388  attr = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_ATTESTATION_Claim)
389  + strlen (attr_name_tmp) + 1 + data_size);
390  attr->type = type;
391  attr->data_size = data_size;
392  attr->version = 0;
393  write_ptr = (char *) &attr[1];
394  GNUNET_memcpy (write_ptr, attr_name_tmp, strlen (attr_name_tmp) + 1);
395  attr->name = write_ptr;
396  write_ptr += strlen (attr->name) + 1;
397  GNUNET_memcpy (write_ptr, data, data_size);
398  attr->data = write_ptr;
399  GNUNET_free (attr_name_tmp);
400  return attr;
401 }
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
static char * attr_name
The attribute.
size_t data_size
Number of bytes in data.
const char * name
The name of the attribute.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
uint32_t data
The data value.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
const void * data
Binary value stored as attribute value.
void GNUNET_STRINGS_utf8_tolower(const char *input, char *output)
Convert the utf-8 input string to lower case.
Definition: strings.c:553
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_ATTESTATION_value_to_string()

char* GNUNET_RECLAIM_ATTESTATION_value_to_string ( uint32_t  type,
const void *  data,
size_t  data_size 
)

Convert the 'claim' of an attestation to a string.

Parameters
typethe type of attestation
dataclaim in binary encoding
data_sizenumber of bytes in data
Returns
NULL on error, otherwise human-readable representation of the claim

Definition at line 310 of file reclaim_attribute.c.

References Plugin::api, GNUNET_BLOCK_PluginFunctions::cls, init(), num_plugins, plugin, and ret.

Referenced by attest_collect(), consume_ticket(), OIDC_id_token_new(), and parse_jwt().

313 {
314  unsigned int i;
315  struct Plugin *plugin;
316  char *ret;
317 
318  init ();
319  for (i = 0; i < num_plugins; i++)
320  {
321  plugin = attr_plugins[i];
322  if (NULL != (ret = plugin->api->value_to_string_attest (plugin->api->cls,
323  type,
324  data,
325  data_size)))
326  return ret;
327  }
328  return NULL;
329 }
static unsigned int num_plugins
Number of plugins.
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
static void init()
Load plugins.
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
static char * plugin
Solver plugin name as string.
static struct Plugin ** attr_plugins
Plugins.
Handle for a plugin.
Definition: block.c:37
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
void * cls
Closure for all of the callbacks.
uint32_t data
The data value.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_ATTESTATION_string_to_value()

int GNUNET_RECLAIM_ATTESTATION_string_to_value ( uint32_t  type,
const char *  s,
void **  data,
size_t *  data_size 
)

Convert human-readable version of a 'claim' of an attestation to the binary representation.

Parameters
typetype of the claim
shuman-readable string
dataset to value in binary encoding (will be allocated)
data_sizeset to number of bytes in data
Returns
GNUNET_OK on success

Definition at line 278 of file reclaim_attribute.c.

References Plugin::api, GNUNET_BLOCK_PluginFunctions::cls, GNUNET_OK, GNUNET_SYSERR, init(), num_plugins, and plugin.

Referenced by parse_attest().

282 {
283  unsigned int i;
284  struct Plugin *plugin;
285 
286  init ();
287  for (i = 0; i < num_plugins; i++)
288  {
289  plugin = attr_plugins[i];
290  if (GNUNET_OK == plugin->api->string_to_value_attest (plugin->api->cls,
291  type,
292  s,
293  data,
294  data_size))
295  return GNUNET_OK;
296  }
297  return GNUNET_SYSERR;
298 }
static unsigned int num_plugins
Number of plugins.
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
static void init()
Load plugins.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
static char * plugin
Solver plugin name as string.
#define GNUNET_SYSERR
Definition: gnunet_common.h:84
static struct Plugin ** attr_plugins
Plugins.
Handle for a plugin.
Definition: block.c:37
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
void * cls
Closure for all of the callbacks.
uint32_t data
The data value.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_ATTESTATION_number_to_typename()

const char* GNUNET_RECLAIM_ATTESTATION_number_to_typename ( uint32_t  type)

Convert an attestation type number to the corresponding attestation type string.

Parameters
typenumber of a type
Returns
corresponding typestring, NULL on error

Definition at line 251 of file reclaim_attribute.c.

References Plugin::api, GNUNET_BLOCK_PluginFunctions::cls, init(), num_plugins, plugin, and ret.

Referenced by attest_collect().

252 {
253  unsigned int i;
254  struct Plugin *plugin;
255  const char *ret;
256 
257  init ();
258  for (i = 0; i < num_plugins; i++)
259  {
260  plugin = attr_plugins[i];
261  if (NULL !=
262  (ret = plugin->api->number_to_typename_attest (plugin->api->cls, type)))
263  return ret;
264  }
265  return NULL;
266 }
static unsigned int num_plugins
Number of plugins.
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
static void init()
Load plugins.
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
static char * plugin
Solver plugin name as string.
static struct Plugin ** attr_plugins
Plugins.
Handle for a plugin.
Definition: block.c:37
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
void * cls
Closure for all of the callbacks.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_ATTESTATION_typename_to_number()

uint32_t GNUNET_RECLAIM_ATTESTATION_typename_to_number ( const char *  typename)

Convert an attestation type name to the corresponding number.

Parameters
typenamename to convert
Returns
corresponding number, UINT32_MAX on error

Definition at line 227 of file reclaim_attribute.c.

References Plugin::api, GNUNET_BLOCK_PluginFunctions::cls, init(), num_plugins, plugin, and ret.

Referenced by parse_attest().

228 {
229  unsigned int i;
230  struct Plugin *plugin;
231  uint32_t ret;
232  init ();
233  for (i = 0; i < num_plugins; i++)
234  {
235  plugin = attr_plugins[i];
236  if (UINT32_MAX !=
237  (ret = plugin->api->typename_to_number_attest (plugin->api->cls,
238  typename)))
239  return ret;
240  }
241  return UINT32_MAX;
242 }
static unsigned int num_plugins
Number of plugins.
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
static void init()
Load plugins.
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
static char * plugin
Solver plugin name as string.
static struct Plugin ** attr_plugins
Plugins.
Handle for a plugin.
Definition: block.c:37
void * cls
Closure for all of the callbacks.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_ATTESTATION_reference_new()

struct GNUNET_RECLAIM_ATTESTATION_REFERENCE* GNUNET_RECLAIM_ATTESTATION_reference_new ( const char *  attr_name,
const char *  ref_value 
)

Create a new attestation reference.

Parameters
attr_namethe referenced claim name
ref_valuethe claim name in the attestation
Returns
the new reference

Definition at line 411 of file reclaim_attribute.c.

References GNUNET_free, GNUNET_malloc, GNUNET_memcpy, GNUNET_strdup, GNUNET_STRINGS_utf8_tolower(), GNUNET_RECLAIM_ATTESTATION_REFERENCE::name, and GNUNET_RECLAIM_ATTESTATION_REFERENCE::reference_value.

Referenced by GNUNET_RECLAIM_ATTRIBUTE_list_dup(), oidc_attr_collect(), and parse_attest_ref().

413 {
415  char *write_ptr;
416  char *attr_name_tmp = GNUNET_strdup (attr_name);
417  char *ref_value_tmp = GNUNET_strdup (ref_value);
418 
419  GNUNET_STRINGS_utf8_tolower (attr_name, attr_name_tmp);
420  GNUNET_STRINGS_utf8_tolower (ref_value, ref_value_tmp);
421 
423  + strlen (attr_name_tmp) + strlen (ref_value_tmp) + 2);
424 
425  write_ptr = (char *) &attr[1];
426  GNUNET_memcpy (write_ptr, attr_name_tmp, strlen (attr_name_tmp) + 1);
427  attr->name = write_ptr;
428 
429  write_ptr += strlen (attr_name) + 1;
430  GNUNET_memcpy (write_ptr, ref_value_tmp, strlen (ref_value_tmp) + 1);
431  attr->reference_value = write_ptr;
432 
433  GNUNET_free (attr_name_tmp);
434  GNUNET_free (ref_value_tmp);
435  return attr;
436 }
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
const char * reference_value
The name of the attribute/attestation reference value.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
static char * attr_name
The attribute.
const char * name
The name of the attribute/attestation reference value.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_STRINGS_utf8_tolower(const char *input, char *output)
Convert the utf-8 input string to lower case.
Definition: strings.c:553
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_ATTESTATION_REF_serialize_get_size()

size_t GNUNET_RECLAIM_ATTESTATION_REF_serialize_get_size ( const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE attr)

Get required size for serialization buffer.

Parameters
attrthe reference to serialize
Returns
the required buffer size

Definition at line 969 of file reclaim_attribute.c.

Referenced by GNUNET_RECLAIM_attestation_reference_delete(), GNUNET_RECLAIM_attestation_reference_store(), GNUNET_RECLAIM_ATTRIBUTE_list_deserialize(), GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size(), ref_add_cb(), and rvk_move_attr_cb().

971 {
972  return sizeof(struct Attestation_Reference) + strlen (attr->name) + strlen (
973  attr->reference_value);
974 }
Serialized attestation reference.
const char * name
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_ATTESTATION_REF_serialize()

size_t GNUNET_RECLAIM_ATTESTATION_REF_serialize ( const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE attr,
char *  result 
)

Serialize a reference.

Parameters
attrthe reference to serialize
resultthe serialized reference
Returns
length of serialized data

Definition at line 985 of file reclaim_attribute.c.

References Attestation_Reference::attestation_id, GNUNET_htonll(), GNUNET_memcpy, GNUNET_RECLAIM_ATTESTATION_REFERENCE::id, GNUNET_RECLAIM_ATTESTATION_REFERENCE::id_attest, GNUNET_RECLAIM_ATTESTATION_REFERENCE::name, Attestation_Reference::name_len, Attestation_Reference::ref_value_len, Attestation_Reference::reference_id, and GNUNET_RECLAIM_ATTESTATION_REFERENCE::reference_value.

Referenced by GNUNET_RECLAIM_attestation_reference_delete(), GNUNET_RECLAIM_attestation_reference_store(), GNUNET_RECLAIM_ATTRIBUTE_list_serialize(), ref_add_cb(), and rvk_move_attr_cb().

988 {
989  size_t name_len;
990  size_t refval_len;
991  struct Attestation_Reference *attr_ser;
992  char *write_ptr;
993  attr_ser = (struct Attestation_Reference *) result;
994  attr_ser->reference_id = GNUNET_htonll (attr->id);
995  attr_ser->attestation_id = GNUNET_htonll (attr->id_attest);
996  name_len = strlen (attr->name);
997  refval_len = strlen (attr->reference_value);
998  attr_ser->name_len = htons (name_len);
999  attr_ser->ref_value_len = htons (refval_len);
1000  write_ptr = (char *) &attr_ser[1];
1001  GNUNET_memcpy (write_ptr, attr->name, name_len);
1002  write_ptr += name_len;
1003  GNUNET_memcpy (write_ptr, attr->reference_value, refval_len);
1004 
1005  return sizeof(struct Attestation_Reference) + strlen (attr->name) + strlen (
1006  attr->reference_value);
1007 }
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
const char * reference_value
The name of the attribute/attestation reference value.
uint32_t ref_value_len
Length of the referenced value.
uint64_t id_attest
Referenced ID of Attestation.
Serialized attestation reference.
static int result
Global testing status.
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:36
const char * name
uint32_t name_len
Claim Name length.
const char * name
The name of the attribute/attestation reference value.
uint64_t reference_id
Reference ID.
uint64_t attestation_id
The ID of the referenced attestation.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_RECLAIM_ATTESTATION_REF_deserialize()

struct GNUNET_RECLAIM_ATTESTATION_REFERENCE* GNUNET_RECLAIM_ATTESTATION_REF_deserialize ( const char *  data,
size_t  data_size 
)

Deserialize a reference.

Parameters
datathe serialized reference
data_sizethe length of the serialized data
Returns
a GNUNET_IDENTITY_PROVIDER_Attribute, must be free'd by caller

Definition at line 1019 of file reclaim_attribute.c.

References Attestation_Reference::attestation_id, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_malloc, GNUNET_memcpy, GNUNET_ntohll(), GNUNET_RECLAIM_ATTESTATION_REFERENCE::id, GNUNET_RECLAIM_ATTESTATION_REFERENCE::id_attest, GNUNET_RECLAIM_ATTESTATION_REFERENCE::name, Attestation_Reference::name_len, Attestation_Reference::ref_value_len, Attestation_Reference::reference_id, and GNUNET_RECLAIM_ATTESTATION_REFERENCE::reference_value.

Referenced by GNUNET_RECLAIM_ATTRIBUTE_list_deserialize(), handle_reference_delete_message(), handle_reference_result(), handle_reference_store_message(), process_parallel_lookup_result(), ref_add_cb(), ref_del_cb(), and rvk_move_attr_cb().

1020 {
1022  struct Attestation_Reference *attr_ser;
1023  size_t name_len;
1024  size_t refval_len;
1025  char *write_ptr;
1026 
1027  if (data_size < sizeof(struct Attestation_Reference))
1028  return NULL;
1029  attr_ser = (struct Attestation_Reference *) data;
1030  name_len = ntohs (attr_ser->name_len);
1031  refval_len = ntohs (attr_ser->ref_value_len);
1032  if (data_size < sizeof(struct Attestation_Reference) + refval_len + name_len)
1033  {
1035  "Buffer too small to deserialize\n");
1036  return NULL;
1037  }
1039  + refval_len + name_len + 2);
1040 
1041  attr->id = GNUNET_ntohll (attr_ser->reference_id);
1042  attr->id_attest = GNUNET_ntohll (attr_ser->attestation_id);
1043 
1044  write_ptr = (char *) &attr[1];
1045  GNUNET_memcpy (write_ptr, &attr_ser[1], name_len);
1046  write_ptr[name_len] = '\0';
1047  attr->name = write_ptr;
1048 
1049  write_ptr += name_len + 1;
1050  GNUNET_memcpy (write_ptr, (char *) &attr_ser[1] + name_len, refval_len);
1051  write_ptr[refval_len] = '\0';
1052  attr->reference_value = write_ptr;
1053  return attr;
1054 }
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
const char * reference_value
The name of the attribute/attestation reference value.
uint32_t ref_value_len
Length of the referenced value.
uint64_t id_attest
Referenced ID of Attestation.
Serialized attestation reference.
uint32_t name_len
Claim Name length.
const char * name
The name of the attribute/attestation reference value.
#define GNUNET_log(kind,...)
uint64_t reference_id
Reference ID.
uint64_t attestation_id
The ID of the referenced attestation.
uint32_t data
The data value.
#define GNUNET_malloc(size)
Wrapper around malloc.
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:53
Here is the call graph for this function:
Here is the caller graph for this function: