GNUnet  0.11.x
Functions | Variables
plugin_reclaim_attribute_gnuid.c File Reference

reclaim-attribute-plugin-gnuid attribute plugin to provide the API for fundamental attribute types. More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_reclaim_attribute_plugin.h"
#include <inttypes.h>
Include dependency graph for plugin_reclaim_attribute_gnuid.c:

Go to the source code of this file.

Functions

static char * gnuid_value_to_string (void *cls, uint32_t type, const void *data, size_t data_size)
 Convert the 'value' of an attribute to a string. More...
 
static int gnuid_string_to_value (void *cls, uint32_t type, const char *s, void **data, size_t *data_size)
 Convert human-readable version of a 'value' of an attribute to the binary representation. More...
 
static char * gnuid_value_to_string_attest (void *cls, uint32_t type, const void *data, size_t data_size)
 Convert the 'value' of an attestation to a string. More...
 
static int gnuid_string_to_value_attest (void *cls, uint32_t type, const char *s, void **data, size_t *data_size)
 Convert human-readable version of a 'value' of an attestation to the binary representation. More...
 
static uint32_t gnuid_typename_to_number (void *cls, const char *gnuid_typename)
 Convert a type name to the corresponding number. More...
 
static const char * gnuid_number_to_typename (void *cls, uint32_t type)
 Convert a type number (i.e. More...
 
static uint32_t gnuid_typename_to_number_attest (void *cls, const char *gnuid_typename)
 Convert a type name to the corresponding number. More...
 
static const char * gnuid_number_to_typename_attest (void *cls, uint32_t type)
 Convert a type number (i.e. More...
 
void * libgnunet_plugin_reclaim_attribute_gnuid_init (void *cls)
 Entry point for the plugin. More...
 
void * libgnunet_plugin_reclaim_attribute_gnuid_done (void *cls)
 Exit point from the plugin. More...
 

Variables

struct {
   const char *   name
 
   uint32_t   number
 
gnuid_name_map []
 Mapping of attribute type numbers to human-readable attribute type names. More...
 
struct {
   const char *   name
 
   uint32_t   number
 
gnuid_attest_name_map []
 Mapping of attestation type numbers to human-readable attestation type names. More...
 

Detailed Description

reclaim-attribute-plugin-gnuid attribute plugin to provide the API for fundamental attribute types.

Author
Martin Schanzenbach

Definition in file plugin_reclaim_attribute_gnuid.c.

Function Documentation

◆ gnuid_value_to_string()

static char* gnuid_value_to_string ( void *  cls,
uint32_t  type,
const void *  data,
size_t  data_size 
)
static

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

Parameters
clsclosure, unused
typetype of the attribute
datavalue in binary encoding
data_sizenumber of bytes in data
Returns
NULL on error, otherwise human-readable representation of the value

Definition at line 45 of file plugin_reclaim_attribute_gnuid.c.

References GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING, and GNUNET_strndup.

Referenced by libgnunet_plugin_reclaim_attribute_gnuid_init().

49 {
50  switch (type)
51  {
53  return GNUNET_strndup (data, data_size);
54 
55  default:
56  return NULL;
57  }
58 }
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
#define GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING
String attribute.
#define GNUNET_strndup(a, length)
Wrapper around GNUNET_xstrndup_.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
uint32_t data
The data value.
Here is the caller graph for this function:

◆ gnuid_string_to_value()

static int gnuid_string_to_value ( void *  cls,
uint32_t  type,
const char *  s,
void **  data,
size_t *  data_size 
)
static

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

Parameters
clsclosure, unused
typetype of the attribute
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 73 of file plugin_reclaim_attribute_gnuid.c.

References GNUNET_OK, GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING, GNUNET_strdup, and GNUNET_SYSERR.

Referenced by libgnunet_plugin_reclaim_attribute_gnuid_init().

78 {
79  if (NULL == s)
80  return GNUNET_SYSERR;
81  switch (type)
82  {
84  *data = GNUNET_strdup (s);
85  *data_size = strlen (s);
86  return GNUNET_OK;
87 
88  default:
89  return GNUNET_SYSERR;
90  }
91 }
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING
String attribute.
#define GNUNET_SYSERR
Definition: gnunet_common.h:84
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
uint32_t data
The data value.
Here is the caller graph for this function:

◆ gnuid_value_to_string_attest()

static char* gnuid_value_to_string_attest ( void *  cls,
uint32_t  type,
const void *  data,
size_t  data_size 
)
static

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

Parameters
clsclosure, unused
typetype of the attestation
datavalue in binary encoding
data_sizenumber of bytes in data
Returns
NULL on error, otherwise human-readable representation of the value

Definition at line 103 of file plugin_reclaim_attribute_gnuid.c.

References GNUNET_RECLAIM_ATTESTATION_TYPE_JWT, and GNUNET_strndup.

Referenced by libgnunet_plugin_reclaim_attribute_gnuid_init().

107 {
108  switch (type)
109  {
111  return GNUNET_strndup (data, data_size);
112 
113  default:
114  return NULL;
115  }
116 }
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
#define GNUNET_RECLAIM_ATTESTATION_TYPE_JWT
A JSON Web Token attestation.
#define GNUNET_strndup(a, length)
Wrapper around GNUNET_xstrndup_.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
uint32_t data
The data value.
Here is the caller graph for this function:

◆ gnuid_string_to_value_attest()

static int gnuid_string_to_value_attest ( void *  cls,
uint32_t  type,
const char *  s,
void **  data,
size_t *  data_size 
)
static

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

Parameters
clsclosure, unused
typetype of the attestation
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 131 of file plugin_reclaim_attribute_gnuid.c.

References GNUNET_OK, GNUNET_RECLAIM_ATTESTATION_TYPE_JWT, GNUNET_strdup, and GNUNET_SYSERR.

Referenced by libgnunet_plugin_reclaim_attribute_gnuid_init().

136 {
137  if (NULL == s)
138  return GNUNET_SYSERR;
139  switch (type)
140  {
142  *data = GNUNET_strdup (s);
143  *data_size = strlen (s);
144  return GNUNET_OK;
145 
146  default:
147  return GNUNET_SYSERR;
148  }
149 }
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_RECLAIM_ATTESTATION_TYPE_JWT
A JSON Web Token attestation.
#define GNUNET_SYSERR
Definition: gnunet_common.h:84
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
uint32_t data
The data value.
Here is the caller graph for this function:

◆ gnuid_typename_to_number()

static uint32_t gnuid_typename_to_number ( void *  cls,
const char *  gnuid_typename 
)
static

Convert a type name to the corresponding number.

Parameters
clsclosure, unused
gnuid_typenamename to convert
Returns
corresponding number, UINT32_MAX on error

Definition at line 181 of file plugin_reclaim_attribute_gnuid.c.

References gnuid_name_map, and name.

Referenced by libgnunet_plugin_reclaim_attribute_gnuid_init().

182 {
183  unsigned int i;
184 
185  i = 0;
186  while ((NULL != gnuid_name_map[i].name) &&
187  (0 != strcasecmp (gnuid_typename, gnuid_name_map[i].name)))
188  i++;
189  return gnuid_name_map[i].number;
190 }
static struct @65 gnuid_name_map[]
Mapping of attribute type numbers to human-readable attribute type names.
const char * name
Here is the caller graph for this function:

◆ gnuid_number_to_typename()

static const char* gnuid_number_to_typename ( void *  cls,
uint32_t  type 
)
static

Convert a type number (i.e.

1) to the corresponding type string

Parameters
clsclosure, unused
typenumber of a type to convert
Returns
corresponding typestring, NULL on error

Definition at line 201 of file plugin_reclaim_attribute_gnuid.c.

References gnuid_name_map, name, and number.

Referenced by libgnunet_plugin_reclaim_attribute_gnuid_init().

202 {
203  unsigned int i;
204 
205  i = 0;
206  while ((NULL != gnuid_name_map[i].name) && (type != gnuid_name_map[i].number))
207  i++;
208  return gnuid_name_map[i].name;
209 }
static struct @65 gnuid_name_map[]
Mapping of attribute type numbers to human-readable attribute type names.
const char * name
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
Here is the caller graph for this function:

◆ gnuid_typename_to_number_attest()

static uint32_t gnuid_typename_to_number_attest ( void *  cls,
const char *  gnuid_typename 
)
static

Convert a type name to the corresponding number.

Parameters
clsclosure, unused
gnuid_typenamename to convert
Returns
corresponding number, UINT32_MAX on error

Definition at line 219 of file plugin_reclaim_attribute_gnuid.c.

References gnuid_attest_name_map, and name.

Referenced by libgnunet_plugin_reclaim_attribute_gnuid_init().

220 {
221  unsigned int i;
222 
223  i = 0;
224  while ((NULL != gnuid_attest_name_map[i].name) &&
225  (0 != strcasecmp (gnuid_typename, gnuid_attest_name_map[i].name)))
226  i++;
227  return gnuid_attest_name_map[i].number;
228 }
static struct @66 gnuid_attest_name_map[]
Mapping of attestation type numbers to human-readable attestation type names.
const char * name
Here is the caller graph for this function:

◆ gnuid_number_to_typename_attest()

static const char* gnuid_number_to_typename_attest ( void *  cls,
uint32_t  type 
)
static

Convert a type number (i.e.

1) to the corresponding type string

Parameters
clsclosure, unused
typenumber of a type to convert
Returns
corresponding typestring, NULL on error

Definition at line 238 of file plugin_reclaim_attribute_gnuid.c.

References gnuid_attest_name_map, name, and number.

Referenced by libgnunet_plugin_reclaim_attribute_gnuid_init().

239 {
240  unsigned int i;
241 
242  i = 0;
243  while ((NULL != gnuid_attest_name_map[i].name) && (type !=
245  number))
246  i++;
247  return gnuid_attest_name_map[i].name;
248 }
static struct @66 gnuid_attest_name_map[]
Mapping of attestation type numbers to human-readable attestation type names.
const char * name
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
Here is the caller graph for this function:

◆ libgnunet_plugin_reclaim_attribute_gnuid_init()

void* libgnunet_plugin_reclaim_attribute_gnuid_init ( void *  cls)

Entry point for the plugin.

Parameters
clsNULL
Returns
the exported block API

Definition at line 257 of file plugin_reclaim_attribute_gnuid.c.

References gnuid_number_to_typename(), gnuid_number_to_typename_attest(), gnuid_string_to_value(), gnuid_string_to_value_attest(), gnuid_typename_to_number(), gnuid_typename_to_number_attest(), gnuid_value_to_string(), gnuid_value_to_string_attest(), GNUNET_new, GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions::number_to_typename, GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions::number_to_typename_attest, GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions::string_to_value, GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions::string_to_value_attest, GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions::typename_to_number, GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions::typename_to_number_attest, GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions::value_to_string, and GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions::value_to_string_attest.

258 {
260 
270  return api;
271 }
static const char * gnuid_number_to_typename_attest(void *cls, uint32_t type)
Convert a type number (i.e.
GNUNET_RECLAIM_ATTRIBUTE_NumberToTypenameFunction number_to_typename_attest
Attestation Number to typename.
static uint32_t gnuid_typename_to_number_attest(void *cls, const char *gnuid_typename)
Convert a type name to the corresponding number.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
GNUNET_RECLAIM_ATTRIBUTE_ValueToStringFunction value_to_string
Conversion to string.
static int gnuid_string_to_value(void *cls, uint32_t type, const char *s, void **data, size_t *data_size)
Convert human-readable version of a &#39;value&#39; of an attribute to the binary representation.
GNUNET_RECLAIM_ATTRIBUTE_TypenameToNumberFunction typename_to_number
Typename to number.
GNUNET_RECLAIM_ATTRIBUTE_ValueToStringFunction value_to_string_attest
FIXME: It is odd that attestation functions are withing the attribute plugin.
static uint32_t gnuid_typename_to_number(void *cls, const char *gnuid_typename)
Convert a type name to the corresponding number.
Each plugin is required to return a pointer to a struct of this type as the return value from its ent...
static int gnuid_string_to_value_attest(void *cls, uint32_t type, const char *s, void **data, size_t *data_size)
Convert human-readable version of a &#39;value&#39; of an attestation to the binary representation.
GNUNET_RECLAIM_ATTRIBUTE_TypenameToNumberFunction typename_to_number_attest
Attestation Typename to number.
GNUNET_RECLAIM_ATTRIBUTE_StringToValueFunction string_to_value_attest
Attestation Conversion to binary.
static char * gnuid_value_to_string(void *cls, uint32_t type, const void *data, size_t data_size)
Convert the &#39;value&#39; of an attribute to a string.
static char * gnuid_value_to_string_attest(void *cls, uint32_t type, const void *data, size_t data_size)
Convert the &#39;value&#39; of an attestation to a string.
static const char * gnuid_number_to_typename(void *cls, uint32_t type)
Convert a type number (i.e.
GNUNET_RECLAIM_ATTRIBUTE_NumberToTypenameFunction number_to_typename
Number to typename.
GNUNET_RECLAIM_ATTRIBUTE_StringToValueFunction string_to_value
Conversion to binary.
Here is the call graph for this function:

◆ libgnunet_plugin_reclaim_attribute_gnuid_done()

void* libgnunet_plugin_reclaim_attribute_gnuid_done ( void *  cls)

Exit point from the plugin.

Parameters
clsthe return value from libgnunet_plugin_block_test_init()
Returns
NULL

Definition at line 281 of file plugin_reclaim_attribute_gnuid.c.

References GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions::cls, and GNUNET_free.

282 {
284 
285  GNUNET_free (api);
286  return NULL;
287 }
Each plugin is required to return a pointer to a struct of this type as the return value from its ent...
void * cls
Closure for all of the callbacks.
#define GNUNET_free(ptr)
Wrapper around free.

Variable Documentation

◆ name

const char* name

◆ number

uint32_t number

◆ gnuid_name_map

struct { ... } gnuid_name_map[]
Initial value:
{ NULL, UINT32_MAX } }
#define GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING
String attribute.

Mapping of attribute type numbers to human-readable attribute type names.

Referenced by gnuid_number_to_typename(), and gnuid_typename_to_number().

◆ gnuid_attest_name_map

struct { ... } gnuid_attest_name_map[]
Initial value:
{ NULL, UINT32_MAX } }
#define GNUNET_RECLAIM_ATTESTATION_TYPE_JWT
A JSON Web Token attestation.

Mapping of attestation type numbers to human-readable attestation type names.

Referenced by gnuid_number_to_typename_attest(), and gnuid_typename_to_number_attest().