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

Data Structures

struct  GNUNET_RECLAIM_ATTRIBUTE_Claim
 An attribute. More...
 
struct  GNUNET_RECLAIM_ATTRIBUTE_ClaimList
 A list of GNUNET_RECLAIM_ATTRIBUTE_Claim structures. More...
 
struct  GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry
 

Macros

#define GNUNET_RECLAIM_ATTRIBUTE_TYPE_NONE   0
 No value attribute. More...
 
#define GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING   1
 String attribute. 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...
 
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...
 

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().

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 230 of file reclaim_attribute.c.

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

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

234 {
235  struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr;
236  char *write_ptr;
237  char *attr_name_tmp = GNUNET_strdup(attr_name);
238 
239  GNUNET_STRINGS_utf8_tolower(attr_name, attr_name_tmp);
240 
241  attr = GNUNET_malloc(sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_Claim) +
242  strlen(attr_name_tmp) + 1 + data_size);
243  attr->type = type;
244  attr->data_size = data_size;
245  attr->version = 0;
246  write_ptr = (char *)&attr[1];
247  GNUNET_memcpy(write_ptr, attr_name_tmp, strlen(attr_name_tmp) + 1);
248  attr->name = write_ptr;
249  write_ptr += strlen(attr->name) + 1;
250  GNUNET_memcpy(write_ptr, data, data_size);
251  attr->data = write_ptr;
252  GNUNET_free(attr_name_tmp);
253  return attr;
254 }
const char * name
The name of the attribute.
size_t data_size
Number of bytes in data.
#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.
static size_t data_size
Number of bytes in data.
#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:552
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 291 of file reclaim_attribute.c.

References GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry::claim, GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size(), len, GNUNET_RECLAIM_ATTRIBUTE_ClaimList::list_head, and GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry::next.

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

293 {
295  size_t len = 0;
296 
297  for (le = attrs->list_head; NULL != le; le = le->next)
299  return len;
300 }
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * claim
The attribute claim.
size_t GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size(const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *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 407 of file reclaim_attribute.c.

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

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

409 {
412 
413  for (le = attrs->list_head; NULL != le;)
414  {
415  GNUNET_free(le->claim);
416  tmp_le = le;
417  le = le->next;
418  GNUNET_free(tmp_le);
419  }
420  GNUNET_free(attrs);
421 }
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * claim
The attribute 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 266 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.

272 {
274 
276  le->claim =
279  claim_list->list_tail,
280  le);
281 }
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.
#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.
static size_t data_size
Number of bytes in data.
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 311 of file reclaim_attribute.c.

References GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry::claim, GNUNET_RECLAIM_ATTRIBUTE_serialize(), len, GNUNET_RECLAIM_ATTRIBUTE_ClaimList::list_head, GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry::next, and result.

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

314 {
316  size_t len;
317  size_t total_len;
318  char *write_ptr;
319 
320  write_ptr = result;
321  total_len = 0;
322  for (le = attrs->list_head; NULL != le; le = le->next)
323  {
324  len = GNUNET_RECLAIM_ATTRIBUTE_serialize(le->claim, write_ptr);
325  total_len += len;
326  write_ptr += len;
327  }
328  return total_len;
329 }
struct GNUNET_RECLAIM_ATTRIBUTE_Claim * claim
The attribute claim.
static int result
Global testing status.
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 340 of file reclaim_attribute.c.

References GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry::claim, data, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_new, GNUNET_RECLAIM_ATTRIBUTE_deserialize(), GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size(), GNUNET_RECLAIM_ATTRIBUTE_ClaimList::list_head, GNUNET_RECLAIM_ATTRIBUTE_ClaimList::list_tail, and GNUNET_RECLAIM_ATTRIBUTE_Claim::name.

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

341 {
344  size_t attr_len;
345  const char *read_ptr;
346 
347  if (data_size < sizeof(struct Attribute))
348  return NULL;
349 
351  read_ptr = data;
352  while (((data + data_size) - read_ptr) >= sizeof(struct Attribute))
353  {
355  le->claim =
357  data_size - (read_ptr - data));
359  "Deserialized attribute %s\n",
360  le->claim->name);
361  GNUNET_CONTAINER_DLL_insert(attrs->list_head, attrs->list_tail, le);
363  read_ptr += attr_len;
364  }
365  return attrs;
366 }
const char * name
The name of the attribute.
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.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Serialized claim.
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,...)
uint32_t data
The data value.
static size_t data_size
Number of bytes in data.
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_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 431 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().

433 {
434  return sizeof(struct Attribute) + strlen(attr->name) + attr->data_size;
435 }
Serialized claim.
const char * name
static size_t data_size
Number of bytes in data.
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 446 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_htonll(), GNUNET_memcpy, GNUNET_RECLAIM_ATTRIBUTE_Claim::id, GNUNET_RECLAIM_ATTRIBUTE_Claim::name, Attribute::name_len, GNUNET_RECLAIM_ATTRIBUTE_Claim::type, and GNUNET_RECLAIM_ATTRIBUTE_Claim::version.

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

449 {
450  size_t data_len_ser;
451  size_t name_len;
452  struct Attribute *attr_ser;
453  char *write_ptr;
454 
455  attr_ser = (struct Attribute *)result;
456  attr_ser->attribute_type = htons(attr->type);
457  attr_ser->attribute_version = htonl(attr->version);
458  attr_ser->attribute_id = GNUNET_htonll(attr->id);
459  name_len = strlen(attr->name);
460  attr_ser->name_len = htons(name_len);
461  write_ptr = (char *)&attr_ser[1];
462  GNUNET_memcpy(write_ptr, attr->name, name_len);
463  write_ptr += name_len;
464  // TODO plugin-ize
465  // data_len_ser = plugin->serialize_attribute_value (attr,
466  // &attr_ser[1]);
467  data_len_ser = attr->data_size;
468  GNUNET_memcpy(write_ptr, attr->data, attr->data_size);
469  attr_ser->data_size = htons(data_len_ser);
470 
471  return sizeof(struct Attribute) + strlen(attr->name) + attr->data_size;
472 }
const char * name
The name of the attribute.
size_t data_size
Number of bytes in data.
#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:35
uint64_t attribute_id
Attribute ID.
const char * name
uint32_t name_len
Name length.
static size_t data_size
Number of bytes in data.
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 484 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_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_malloc, GNUNET_memcpy, GNUNET_ntohll(), GNUNET_RECLAIM_ATTRIBUTE_Claim::id, GNUNET_RECLAIM_ATTRIBUTE_Claim::name, Attribute::name_len, GNUNET_RECLAIM_ATTRIBUTE_Claim::type, and GNUNET_RECLAIM_ATTRIBUTE_Claim::version.

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().

485 {
486  struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr;
487  struct Attribute *attr_ser;
488  size_t data_len;
489  size_t name_len;
490  char *write_ptr;
491 
492  if (data_size < sizeof(struct Attribute))
493  return NULL;
494 
495  attr_ser = (struct Attribute *)data;
496  data_len = ntohs(attr_ser->data_size);
497  name_len = ntohs(attr_ser->name_len);
498  if (data_size < sizeof(struct Attribute) + data_len + name_len)
499  {
501  "Buffer too small to deserialize\n");
502  return NULL;
503  }
504  attr = GNUNET_malloc(sizeof(struct GNUNET_RECLAIM_ATTRIBUTE_Claim) +
505  data_len + name_len + 1);
506  attr->type = ntohs(attr_ser->attribute_type);
507  attr->version = ntohl(attr_ser->attribute_version);
508  attr->id = GNUNET_ntohll(attr_ser->attribute_id);
509  attr->data_size = data_len;
510 
511  write_ptr = (char *)&attr[1];
512  GNUNET_memcpy(write_ptr, &attr_ser[1], name_len);
513  write_ptr[name_len] = '\0';
514  attr->name = write_ptr;
515 
516  write_ptr += name_len + 1;
517  GNUNET_memcpy(write_ptr, (char *)&attr_ser[1] + name_len, attr->data_size);
518  attr->data = write_ptr;
519  return attr;
520 }
const char * name
The name of the attribute.
size_t data_size
Number of bytes in data.
#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.
static size_t data_size
Number of bytes in data.
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:48
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 375 of file reclaim_attribute.c.

References GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry::claim, GNUNET_RECLAIM_ATTRIBUTE_Claim::data, GNUNET_RECLAIM_ATTRIBUTE_Claim::data_size, GNUNET_CONTAINER_DLL_insert, GNUNET_new, GNUNET_RECLAIM_ATTRIBUTE_claim_new(), GNUNET_RECLAIM_ATTRIBUTE_Claim::id, GNUNET_RECLAIM_ATTRIBUTE_ClaimList::list_head, GNUNET_RECLAIM_ATTRIBUTE_ClaimList::list_tail, GNUNET_RECLAIM_ATTRIBUTE_Claim::name, GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry::next, result, GNUNET_RECLAIM_ATTRIBUTE_Claim::type, and GNUNET_RECLAIM_ATTRIBUTE_Claim::version.

Referenced by RECLAIM_TICKETS_issue().

377 {
379  struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *result_le;
381 
383  for (le = attrs->list_head; NULL != le; le = le->next)
384  {
386  result_le->claim =
388  le->claim->type,
389  le->claim->data,
390  le->claim->data_size);
391  result_le->claim->version = le->claim->version;
392  result_le->claim->id = le->claim->id;
394  result->list_tail,
395  result_le);
396  }
397  return result;
398 }
const char * name
The name of the attribute.
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.
size_t data_size
Number of bytes in data.
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry * list_tail
List tail.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
const void * data
Binary value stored as attribute value.
static int result
Global testing status.
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.
A list of GNUNET_RECLAIM_ATTRIBUTE_Claim structures.
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry * next
DLL.
struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry * list_head
List head.
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 112 of file reclaim_attribute.c.

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

Referenced by iter_finished(), and parse_attr().

113 {
114  unsigned int i;
115  struct Plugin *plugin;
116  uint32_t ret;
117 
118  init();
119  for (i = 0; i < num_plugins; i++)
120  {
121  plugin = attr_plugins[i];
122  if (UINT32_MAX !=
123  (ret = plugin->api->typename_to_number(plugin->api->cls, typename)))
124  return ret;
125  }
126  return UINT32_MAX;
127 }
static unsigned int num_plugins
Number of plugins.
static void init()
Load plugins.
static int ret
Final status code.
Definition: gnunet-arm.c:89
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:46
static struct GNUNET_ATS_SolverFunctions * plugin
Our solver.
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 166 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(), and parse_attr().

170 {
171  unsigned int i;
172  struct Plugin *plugin;
173 
174  init();
175  for (i = 0; i < num_plugins; i++)
176  {
177  plugin = attr_plugins[i];
178  if (GNUNET_OK == plugin->api->string_to_value(plugin->api->cls,
179  type,
180  s,
181  data,
182  data_size))
183  return GNUNET_OK;
184  }
185  return GNUNET_SYSERR;
186 }
static unsigned int num_plugins
Number of plugins.
static void init()
Load plugins.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:46
static struct GNUNET_ATS_SolverFunctions * plugin
Our solver.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
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.
static size_t data_size
Number of bytes in data.
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 198 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().

201 {
202  unsigned int i;
203  struct Plugin *plugin;
204  char *ret;
205 
206  init();
207  for (i = 0; i < num_plugins; i++)
208  {
209  plugin = attr_plugins[i];
210  if (NULL != (ret = plugin->api->value_to_string(plugin->api->cls,
211  type,
212  data,
213  data_size)))
214  return ret;
215  }
216  return NULL;
217 }
static unsigned int num_plugins
Number of plugins.
static void init()
Load plugins.
static int ret
Final status code.
Definition: gnunet-arm.c:89
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:46
static struct GNUNET_ATS_SolverFunctions * plugin
Our solver.
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.
static size_t data_size
Number of bytes in data.
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 137 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().

138 {
139  unsigned int i;
140  struct Plugin *plugin;
141  const char *ret;
142 
143  init();
144  for (i = 0; i < num_plugins; i++)
145  {
146  plugin = attr_plugins[i];
147  if (NULL !=
148  (ret = plugin->api->number_to_typename(plugin->api->cls, type)))
149  return ret;
150  }
151  return NULL;
152 }
static unsigned int num_plugins
Number of plugins.
static void init()
Load plugins.
static int ret
Final status code.
Definition: gnunet-arm.c:89
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:46
static struct GNUNET_ATS_SolverFunctions * plugin
Our solver.
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: