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

gnsrecord plugin to provide the API for identity records More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_gnsrecord_lib.h"
#include "gnunet_gnsrecord_plugin.h"
Include dependency graph for plugin_gnsrecord_reclaim.c:

Go to the source code of this file.

Functions

static char * value_to_string (void *cls, uint32_t type, const void *data, size_t data_size)
 Convert the 'value' of a record to a string. More...
 
static int 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 a record to the binary representation. More...
 
static uint32_t typename_to_number (void *cls, const char *dns_typename)
 Convert a type name (i.e. More...
 
static const char * number_to_typename (void *cls, uint32_t type)
 Convert a type number (i.e. More...
 
void * libgnunet_plugin_gnsrecord_reclaim_init (void *cls)
 Entry point for the plugin. More...
 
void * libgnunet_plugin_gnsrecord_reclaim_done (void *cls)
 Exit point from the plugin. More...
 

Variables

struct {
   const char *   name
 
   uint32_t   number
 
name_map []
 Mapping of record type numbers to human-readable record type names. More...
 

Detailed Description

gnsrecord plugin to provide the API for identity records

Author
Martin Schanzenbach

Definition in file plugin_gnsrecord_reclaim.c.

Function Documentation

◆ value_to_string()

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

Convert the 'value' of a record to a string.

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

Definition at line 43 of file plugin_gnsrecord_reclaim.c.

References GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR, GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF, GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER, GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT, GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT, GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET, GNUNET_STRINGS_data_to_string_alloc(), and GNUNET_strndup.

Referenced by libgnunet_plugin_gnsrecord_reclaim_init().

44 {
45  switch (type)
46  {
49 
52  return GNUNET_strndup (data, data_size);
53 
58 
59  default:
60  return NULL;
61  }
62 }
#define GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER
Record type for RECLAIM master.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR
Record type for identity attributes (of RECLAIM).
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF
Record type for reclaim records.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT
Record type for reclaim OIDC clients.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT
Record type for reclaim OIDC redirect URIs.
#define GNUNET_strndup(a, length)
Wrapper around GNUNET_xstrndup_.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET
Record type for local ticket references.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:920
uint32_t data
The data value.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ string_to_value()

static int 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 a record to the binary representation.

Parameters
clsclosure, unused
typetype of the record
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 77 of file plugin_gnsrecord_reclaim.c.

References GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR, GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF, GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER, GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT, GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT, GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET, GNUNET_OK, GNUNET_strdup, GNUNET_STRINGS_string_to_data(), and GNUNET_SYSERR.

Referenced by libgnunet_plugin_gnsrecord_reclaim_init().

79 {
80  if (NULL == s)
81  return GNUNET_SYSERR;
82  switch (type)
83  {
85  return GNUNET_STRINGS_string_to_data (s, strlen (s), *data, *data_size);
86 
89  *data = GNUNET_strdup (s);
90  *data_size = strlen (s);
91  return GNUNET_OK;
92 
96  return GNUNET_STRINGS_string_to_data (s, strlen (s), *data, *data_size);
97 
98  default:
99  return GNUNET_SYSERR;
100  }
101 }
#define GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER
Record type for RECLAIM master.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR
Record type for identity attributes (of RECLAIM).
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF
Record type for reclaim records.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT
Record type for reclaim OIDC clients.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
#define GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT
Record type for reclaim OIDC redirect URIs.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET
Record type for local ticket references.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
uint32_t data
The data value.
int GNUNET_STRINGS_string_to_data(const char *enc, size_t enclen, void *out, size_t out_size)
Convert CrockfordBase32 encoding back to data.
Definition: strings.c:952
Here is the call graph for this function:
Here is the caller graph for this function:

◆ typename_to_number()

static uint32_t typename_to_number ( void *  cls,
const char *  dns_typename 
)
static

Convert a type name (i.e.

"AAAA") to the corresponding number.

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

Definition at line 131 of file plugin_gnsrecord_reclaim.c.

References name, and name_map.

Referenced by libgnunet_plugin_gnsrecord_reclaim_init().

132 {
133  unsigned int i;
134 
135  i = 0;
136  while ((NULL != name_map[i].name) &&
137  (0 != strcasecmp (dns_typename, name_map[i].name)))
138  i++;
139  return name_map[i].number;
140 }
static struct @64 name_map[]
Mapping of record type numbers to human-readable record type names.
const char * name
Here is the caller graph for this function:

◆ number_to_typename()

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

Convert a type number (i.e.

1) to the corresponding type string (i.e. "A")

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

Definition at line 151 of file plugin_gnsrecord_reclaim.c.

References name, name_map, and number.

Referenced by libgnunet_plugin_gnsrecord_reclaim_init().

152 {
153  unsigned int i;
154 
155  i = 0;
156  while ((NULL != name_map[i].name) && (type != name_map[i].number))
157  i++;
158  return name_map[i].name;
159 }
uint32_t number
static struct @64 name_map[]
Mapping of record type numbers to human-readable record type names.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
const char * name
Here is the caller graph for this function:

◆ libgnunet_plugin_gnsrecord_reclaim_init()

void* libgnunet_plugin_gnsrecord_reclaim_init ( void *  cls)

Entry point for the plugin.

Parameters
clsNULL
Returns
the exported block API

Definition at line 169 of file plugin_gnsrecord_reclaim.c.

References GNUNET_new, GNUNET_GNSRECORD_PluginFunctions::number_to_typename, number_to_typename(), string_to_value(), GNUNET_GNSRECORD_PluginFunctions::string_to_value, typename_to_number(), GNUNET_GNSRECORD_PluginFunctions::typename_to_number, value_to_string(), and GNUNET_GNSRECORD_PluginFunctions::value_to_string.

170 {
172 
178  return api;
179 }
GNUNET_GNSRECORD_TypenameToNumberFunction typename_to_number
Typename to number.
GNUNET_GNSRECORD_ValueToStringFunction value_to_string
Conversion to string.
GNUNET_GNSRECORD_NumberToTypenameFunction number_to_typename
Number to typename.
GNUNET_GNSRECORD_StringToValueFunction string_to_value
Conversion to binary.
static int 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 a record to the binary representation.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static const char * number_to_typename(void *cls, uint32_t type)
Convert a type number (i.e.
static char * value_to_string(void *cls, uint32_t type, const void *data, size_t data_size)
Convert the 'value' of a record to a string.
static uint32_t typename_to_number(void *cls, const char *dns_typename)
Convert a type name (i.e.
Each plugin is required to return a pointer to a struct of this type as the return value from its ent...
Here is the call graph for this function:

◆ libgnunet_plugin_gnsrecord_reclaim_done()

void* libgnunet_plugin_gnsrecord_reclaim_done ( void *  cls)

Exit point from the plugin.

Parameters
clsthe return value from libgnunet_plugin_block_test_init
Returns
NULL

Definition at line 189 of file plugin_gnsrecord_reclaim.c.

References GNUNET_GNSRECORD_PluginFunctions::cls, and GNUNET_free.

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

Variable Documentation

◆ name

const char* name

Definition at line 110 of file plugin_gnsrecord_reclaim.c.

Referenced by number_to_typename(), and typename_to_number().

◆ number

uint32_t number

Definition at line 111 of file plugin_gnsrecord_reclaim.c.

Referenced by number_to_typename().

◆ name_map

struct { ... } name_map[]
Initial value:
= {
{ "RECLAIM_ATTR_REF", GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF },
{ "RECLAIM_MASTER", GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER },
{ "RECLAIM_OIDC_CLIENT", GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT },
{ "RECLAIM_OIDC_REDIRECT", GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT },
{ "RECLAIM_TICKET", GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET },
{ NULL, UINT32_MAX }
}
#define GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER
Record type for RECLAIM master.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR
Record type for identity attributes (of RECLAIM).
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF
Record type for reclaim records.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT
Record type for reclaim OIDC clients.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT
Record type for reclaim OIDC redirect URIs.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET
Record type for local ticket references.

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

Referenced by number_to_typename(), and typename_to_number().