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

235 {
236  struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr;
237  char *write_ptr;
238  char *attr_name_tmp = GNUNET_strdup (attr_name);
239 
240  GNUNET_STRINGS_utf8_tolower (attr_name, attr_name_tmp);
241 
242  attr = GNUNET_malloc (sizeof (struct GNUNET_RECLAIM_ATTRIBUTE_Claim) +
243  strlen (attr_name_tmp) + 1 + data_size);
244  attr->type = type;
245  attr->data_size = data_size;
246  attr->version = 0;
247  write_ptr = (char *) &attr[1];
248  GNUNET_memcpy (write_ptr, attr_name_tmp, strlen (attr_name_tmp) + 1);
249  attr->name = write_ptr;
250  write_ptr += strlen (attr->name) + 1;
251  GNUNET_memcpy (write_ptr, data, data_size);
252  attr->data = write_ptr;
253  GNUNET_free (attr_name_tmp);
254  return attr;
255 }
const char * name
The name of the attribute.
size_t data_size
Number of bytes in data.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
const void * data
Binary value stored as attribute value.
#define GNUNET_memcpy(dst, src, n)
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:558
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  for (le = attrs->list_head; NULL != le; le = le->next)
298  return len;
299 }
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(), OIDC_parse_authz_code(), 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 267 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.

273 {
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 310 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().

313 {
315  size_t len;
316  size_t total_len;
317  char *write_ptr;
318 
319  write_ptr = result;
320  total_len = 0;
321  for (le = attrs->list_head; NULL != le; le = le->next)
322  {
323  len = GNUNET_RECLAIM_ATTRIBUTE_serialize (le->claim, write_ptr);
324  total_len += len;
325  write_ptr += len;
326  }
327  return total_len;
328 }
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 339 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().

340 {
343  size_t attr_len;
344  const char *read_ptr;
345 
346  if (data_size < sizeof (struct Attribute))
347  return NULL;
348 
350  read_ptr = data;
351  while (((data + data_size) - read_ptr) >= sizeof (struct Attribute))
352  {
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.
Serialized claim.
const void * data
Binary value stored as attribute value.
#define GNUNET_memcpy(dst, src, n)
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.
Serialized claim.
const void * data
Binary value stored as attribute value.
#define GNUNET_memcpy(dst, src, n)
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 113 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().

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 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:47
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 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(), and parse_attr().

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 void init()
Load plugins.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
static struct GNUNET_ATS_SolverFunctions * plugin
Our solver.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
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 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 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:47
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 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 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:47
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: