GNUnet 0.21.1
plugin_gnsrecord_reclaim.c File Reference

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

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 (e.g. More...
 
static const char * number_to_typename (void *cls, uint32_t type)
 Convert a type number to the corresponding type string (e.g. 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.

44{
45 switch (type)
46 {
56
57 default:
58 return NULL;
59 }
60}
static char * data
The data to insert into the dht.
static uint32_t type
Type string converted to DNS type value.
static size_t data_size
Number of bytes in data.
#define GNUNET_strndup(a, length)
Wrapper around GNUNET_xstrndup_.
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:764
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE
identity attribute
#define GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION
Record type for a presentation of a credential.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF
for reclaim records
#define GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT
For reclaim OIDC client names.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL
Record type for an attribute attestation (e.g.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT
Used reclaimID OIDC client redirect URIs.
#define GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET
local ticket reference

References data, data_size, GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE, GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF, GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL, GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT, GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT, GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION, GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET, GNUNET_STRINGS_data_to_string_alloc(), GNUNET_strndup, and type.

Referenced by libgnunet_plugin_gnsrecord_reclaim_init().

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 75 of file plugin_gnsrecord_reclaim.c.

77{
78 if (NULL == s)
79 return GNUNET_SYSERR;
80 switch (type)
81 {
84 *data = GNUNET_strdup (s);
85 *data_size = strlen (s);
86 return GNUNET_OK;
92 return GNUNET_STRINGS_string_to_data (s, strlen (s), *data, *data_size);
93
94 default:
95 return GNUNET_SYSERR;
96 }
97}
@ GNUNET_OK
@ GNUNET_SYSERR
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
enum GNUNET_GenericReturnValue 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:789

References data, data_size, GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE, GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF, GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL, GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT, GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT, GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION, GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET, GNUNET_OK, GNUNET_strdup, GNUNET_STRINGS_string_to_data(), GNUNET_SYSERR, and type.

Referenced by libgnunet_plugin_gnsrecord_reclaim_init().

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 (e.g.

"AAAA") to the corresponding number.

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

Definition at line 128 of file plugin_gnsrecord_reclaim.c.

129{
130 unsigned int i;
131
132 i = 0;
133 while ((NULL != name_map[i].name) &&
134 (0 != strcasecmp (dns_typename, name_map[i].name)))
135 i++;
136 return name_map[i].number;
137}
static struct @40 name_map[]
Mapping of record type numbers to human-readable record type names.
const char * name

References name, and name_map.

Referenced by libgnunet_plugin_gnsrecord_reclaim_init().

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 to the corresponding type string (e.g.

1 to "A")

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

Definition at line 148 of file plugin_gnsrecord_reclaim.c.

149{
150 unsigned int i;
151
152 i = 0;
153 while ((NULL != name_map[i].name) && (type != name_map[i].number))
154 i++;
155 return name_map[i].name;
156}
uint32_t number

References name, name_map, number, and type.

Referenced by libgnunet_plugin_gnsrecord_reclaim_init().

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 166 of file plugin_gnsrecord_reclaim.c.

167{
169
175 return api;
176}
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static uint32_t typename_to_number(void *cls, const char *dns_typename)
Convert a type name (e.g.
static const char * number_to_typename(void *cls, uint32_t type)
Convert a type number to the corresponding type string (e.g.
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 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.
Each plugin is required to return a pointer to a struct of this type as the return value from its ent...
GNUNET_GNSRECORD_TypenameToNumberFunction typename_to_number
Typename to number.
GNUNET_GNSRECORD_NumberToTypenameFunction number_to_typename
Number to typename.
GNUNET_GNSRECORD_ValueToStringFunction value_to_string
Conversion to string.
GNUNET_GNSRECORD_StringToValueFunction string_to_value
Conversion to binary.

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

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 186 of file plugin_gnsrecord_reclaim.c.

187{
189
190 GNUNET_free (api);
191 return NULL;
192}
#define GNUNET_free(ptr)
Wrapper around free.
void * cls
Closure for all of the callbacks.

References GNUNET_GNSRECORD_PluginFunctions::cls, and GNUNET_free.

Variable Documentation

◆ name

const char* name

Definition at line 106 of file plugin_gnsrecord_reclaim.c.

Referenced by number_to_typename(), and typename_to_number().

◆ number

uint32_t number

Definition at line 107 of file plugin_gnsrecord_reclaim.c.

Referenced by number_to_typename().

◆ 

struct { ... } name_map[]
Initial value:
= {
{ "RECLAIM_ATTRIBUTE", GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE },
{ "RECLAIM_ATTRIBUTE_REF", GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF },
{ "RECLAIM_CREDENTIAL", GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL },
{ "RECLAIM_PRESENTATION", GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION },
{ "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 }
}

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

Referenced by number_to_typename(), and typename_to_number().