GNUnet  0.11.x
Data Structures | Macros | Typedefs | Enumerations | Functions
GNS Record library

Manipulate GNS record data. More...

Data Structures

struct  GNUNET_GNSRECORD_Data
 A GNS record. More...
 
struct  GNUNET_GNSRECORD_PlaceData
 Data stored in a PLACE record. More...
 
struct  GNUNET_GNSRECORD_EcdsaBlock
 Information we have in an encrypted block with record data (i.e. More...
 
struct  GNUNET_GNSRECORD_Block
 
struct  GNUNET_GNSRECORD_BoxRecord
 Record type used to box up SRV and TLSA records. More...
 
struct  GNUNET_GNSRECORD_ReverseRecord
 Record type used internally to keep track of reverse mappings into a namespace. More...
 

Macros

#define GNUNET_GNSRECORD_MAX_BLOCK_SIZE   (63 * 1024)
 Maximum size of a value that can be stored in a GNS block. More...
 
#define GNUNET_GNSRECORD_TYPE_ANY   0
 Record type indicating any record/'*'. More...
 
#define GNUNET_GNSRECORD_TYPE_PKEY   GNUNET_IDENTITY_TYPE_ECDSA
 Record type for GNS zone transfer ("PKEY"). More...
 
#define GNUNET_GNSRECORD_TYPE_NICK   65537
 Record type for GNS nick names ("NICK"). More...
 
#define GNUNET_GNSRECORD_TYPE_LEHO   65538
 Record type for GNS legacy hostnames ("LEHO"). More...
 
#define GNUNET_GNSRECORD_TYPE_VPN   65539
 Record type for VPN resolution. More...
 
#define GNUNET_GNSRECORD_TYPE_GNS2DNS   65540
 Record type for delegation to DNS. More...
 
#define GNUNET_GNSRECORD_TYPE_BOX   65541
 Record type for a boxed record (see TLSA/SRV handling in GNS). More...
 
#define GNUNET_GNSRECORD_TYPE_PLACE   65542
 Record type for a social place. More...
 
#define GNUNET_GNSRECORD_TYPE_PHONE   65543
 Record type for a phone (of CONVERSATION). More...
 
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE   65544
 Record type for identity attributes (of RECLAIM). More...
 
#define GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET   65545
 Record type for local ticket references. More...
 
#define GNUNET_GNSRECORD_TYPE_DELEGATE   65548
 65546 reserved More...
 
#define GNUNET_GNSRECORD_TYPE_ATTRIBUTE   65549
 Record type for reverse lookups. More...
 
#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF   65550
 Record type for reclaim records. More...
 
#define GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER   65551
 Record type for RECLAIM master. More...
 
#define GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT   65552
 Record type for reclaim OIDC clients. More...
 
#define GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT   65553
 Record type for reclaim OIDC redirect URIs. More...
 
#define GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL   65554
 Record type for an attribute attestation. More...
 
#define GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION   65555
 Record type for a presentation of a credential (used in a ticket record set) More...
 
#define GNUNET_GNSRECORD_TYPE_EDKEY   GNUNET_IDENTITY_TYPE_EDDSA
 Record type for EDKEY delegations. More...
 

Typedefs

typedef void(* GNUNET_GNSRECORD_RecordCallback) (void *cls, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
 Process a records that were decrypted from a block. More...
 

Enumerations

enum  GNUNET_GNSRECORD_Flags {
  GNUNET_GNSRECORD_RF_NONE = 0, GNUNET_GNSRECORD_RF_PRIVATE = 2, GNUNET_GNSRECORD_RF_SUPPLEMENTAL = 4, GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION = 8,
  GNUNET_GNSRECORD_RF_SHADOW_RECORD
}
 Flags that can be set for a record. More...
 

Functions

struct GNUNET_JSON_Specification GNUNET_GNSRECORD_JSON_spec_gnsrecord (struct GNUNET_GNSRECORD_Data **rd, unsigned int *rd_count, char **name)
 JSON Specification for GNS Records. More...
 
json_t * GNUNET_GNSRECORD_JSON_from_gnsrecord (const char *rname, const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count)
 Convert GNS record to JSON. More...
 
char * GNUNET_GNSRECORD_value_to_string (uint32_t type, const void *data, size_t data_size)
 Convert the binary value data of a record of type type to a human-readable string. More...
 
int GNUNET_GNSRECORD_string_to_value (uint32_t type, const char *s, void **data, size_t *data_size)
 Convert human-readable version of the value s of a record of type type to the respective binary representation. More...
 
uint32_t GNUNET_GNSRECORD_typename_to_number (const char *dns_typename)
 Convert a type name (i.e. More...
 
const char * GNUNET_GNSRECORD_number_to_typename (uint32_t type)
 Convert a type number (i.e. More...
 
ssize_t GNUNET_GNSRECORD_records_get_size (unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
 Calculate how many bytes we will need to serialize the given records. More...
 
ssize_t GNUNET_GNSRECORD_records_serialize (unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, size_t dest_size, char *dest)
 Serialize the given records to the given destination buffer. More...
 
int GNUNET_GNSRECORD_records_deserialize (size_t len, const char *src, unsigned int rd_count, struct GNUNET_GNSRECORD_Data *dest)
 Deserialize the given records to the given destination. More...
 
int GNUNET_GNSRECORD_is_expired (const struct GNUNET_GNSRECORD_Data *rd)
 Test if a given record is expired. More...
 
char * GNUNET_GNSRECORD_string_to_lowercase (const char *src)
 Convert a UTF-8 string to UTF-8 lowercase. More...
 
const char * GNUNET_GNSRECORD_z2s (const struct GNUNET_IDENTITY_PublicKey *z)
 Convert a zone to a string (for printing debug messages). More...
 
const char * GNUNET_GNSRECORD_pkey_to_zkey (const struct GNUNET_IDENTITY_PublicKey *pkey)
 Convert public key to the respective absolute domain name in the ".zkey" pTLD. More...
 
int GNUNET_GNSRECORD_zkey_to_pkey (const char *zkey, struct GNUNET_IDENTITY_PublicKey *pkey)
 Convert an absolute domain name to the respective public key. More...
 
void GNUNET_GNSRECORD_query_from_private_key (const struct GNUNET_IDENTITY_PrivateKey *zone, const char *label, struct GNUNET_HashCode *query)
 Calculate the DHT query for a given label in a given zone. More...
 
void GNUNET_GNSRECORD_query_from_public_key (const struct GNUNET_IDENTITY_PublicKey *pub, const char *label, struct GNUNET_HashCode *query)
 Calculate the DHT query for a given label in a given zone. More...
 
struct GNUNET_GNSRECORD_BlockGNUNET_GNSRECORD_block_create (const struct GNUNET_IDENTITY_PrivateKey *key, struct GNUNET_TIME_Absolute expire, const char *label, const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count)
 Sign name and records. More...
 
struct GNUNET_GNSRECORD_BlockGNUNET_GNSRECORD_block_create2 (const struct GNUNET_IDENTITY_PrivateKey *key, struct GNUNET_TIME_Absolute expire, const char *label, const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count)
 Sign name and records, cache derived public key (also keeps the private key in static memory, so do not use this function if keeping the private key in the process'es RAM is a major issue). More...
 
int GNUNET_GNSRECORD_block_verify (const struct GNUNET_GNSRECORD_Block *block)
 Check if a signature is valid. More...
 
int GNUNET_GNSRECORD_block_decrypt (const struct GNUNET_GNSRECORD_Block *block, const struct GNUNET_IDENTITY_PublicKey *zone_key, const char *label, GNUNET_GNSRECORD_RecordCallback proc, void *proc_cls)
 Decrypt block. More...
 
int GNUNET_GNSRECORD_records_cmp (const struct GNUNET_GNSRECORD_Data *a, const struct GNUNET_GNSRECORD_Data *b)
 Compares if two records are equal. More...
 
struct GNUNET_TIME_Absolute GNUNET_GNSRECORD_record_get_expiration_time (unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
 Returns the expiration time of the given block of records. More...
 
size_t GNUNET_GNSRECORD_block_get_size (const struct GNUNET_GNSRECORD_Block *block)
 Returns the length of this block in bytes. More...
 
struct GNUNET_TIME_Absolute GNUNET_GNSRECORD_block_get_expiration (const struct GNUNET_GNSRECORD_Block *block)
 Returns the expiration of a block. More...
 
enum GNUNET_GenericReturnValue GNUNET_GNSRECORD_query_from_block (const struct GNUNET_GNSRECORD_Block *block, struct GNUNET_HashCode *query)
 Builds the query hash from a block. More...
 
enum GNUNET_GenericReturnValue GNUNET_GNSRECORD_identity_from_data (const char *data, size_t data_size, uint32_t type, struct GNUNET_IDENTITY_PublicKey *key)
 Build a #GNUNET_GNSRECORD_PublicKey from zone delegation resource record data. More...
 
enum GNUNET_GenericReturnValue GNUNET_GNSRECORD_data_from_identity (const struct GNUNET_IDENTITY_PublicKey *key, char **data, size_t *data_size, uint32_t *type)
 Create record data and size from an identity key. More...
 
enum GNUNET_GenericReturnValue GNUNET_GNSRECORD_is_zonekey_type (uint32_t type)
 Check if this type is one of the supported GNS zone types. More...
 

Detailed Description

Manipulate GNS record data.

See also
Documentation

Macro Definition Documentation

◆ GNUNET_GNSRECORD_MAX_BLOCK_SIZE

#define GNUNET_GNSRECORD_MAX_BLOCK_SIZE   (63 * 1024)

Maximum size of a value that can be stored in a GNS block.

Definition at line 49 of file gnunet_gnsrecord_lib.h.

Referenced by block_create_ecdsa().

◆ GNUNET_GNSRECORD_TYPE_ANY

#define GNUNET_GNSRECORD_TYPE_ANY   0

◆ GNUNET_GNSRECORD_TYPE_PKEY

#define GNUNET_GNSRECORD_TYPE_PKEY   GNUNET_IDENTITY_TYPE_ECDSA

◆ GNUNET_GNSRECORD_TYPE_NICK

#define GNUNET_GNSRECORD_TYPE_NICK   65537

◆ GNUNET_GNSRECORD_TYPE_LEHO

#define GNUNET_GNSRECORD_TYPE_LEHO   65538

Record type for GNS legacy hostnames ("LEHO").

Definition at line 70 of file gnunet_gnsrecord_lib.h.

Referenced by dns_result_parser(), gns_string_to_value(), gns_value_to_string(), handle_gns_result(), and transmit_lookup_dns_result().

◆ GNUNET_GNSRECORD_TYPE_VPN

#define GNUNET_GNSRECORD_TYPE_VPN   65539

◆ GNUNET_GNSRECORD_TYPE_GNS2DNS

#define GNUNET_GNSRECORD_TYPE_GNS2DNS   65540

◆ GNUNET_GNSRECORD_TYPE_BOX

#define GNUNET_GNSRECORD_TYPE_BOX   65541

Record type for a boxed record (see TLSA/SRV handling in GNS).

Definition at line 85 of file gnunet_gnsrecord_lib.h.

Referenced by gns_string_to_value(), gns_value_to_string(), handle_gns_resolution_result(), and handle_gns_result().

◆ GNUNET_GNSRECORD_TYPE_PLACE

#define GNUNET_GNSRECORD_TYPE_PLACE   65542

Record type for a social place.

Definition at line 90 of file gnunet_gnsrecord_lib.h.

◆ GNUNET_GNSRECORD_TYPE_PHONE

#define GNUNET_GNSRECORD_TYPE_PHONE   65543

◆ GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE

#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE   65544

Record type for identity attributes (of RECLAIM).

Definition at line 100 of file gnunet_gnsrecord_lib.h.

Referenced by attr_iter_cb(), attr_store_task(), process_parallel_lookup_result(), rvk_move_attr_cb(), string_to_value(), and value_to_string().

◆ GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET

#define GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET   65545

Record type for local ticket references.

Definition at line 105 of file gnunet_gnsrecord_lib.h.

Referenced by collect_tickets_cb(), filter_tickets_cb(), issue_ticket(), string_to_value(), and value_to_string().

◆ GNUNET_GNSRECORD_TYPE_DELEGATE

#define GNUNET_GNSRECORD_TYPE_DELEGATE   65548

65546 reserved

65547 deleted, free to use Record type for policies

Definition at line 118 of file gnunet_gnsrecord_lib.h.

Referenced by abd_string_to_value(), abd_value_to_string(), delegation_chain_fw_resolution_start(), forward_resolution(), handle_delegate_collection_cb(), run(), and store_cb().

◆ GNUNET_GNSRECORD_TYPE_ATTRIBUTE

#define GNUNET_GNSRECORD_TYPE_ATTRIBUTE   65549

◆ GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF

#define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF   65550

◆ GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER

#define GNUNET_GNSRECORD_TYPE_RECLAIM_MASTER   65551

Record type for RECLAIM master.

Definition at line 133 of file gnunet_gnsrecord_lib.h.

Referenced by string_to_value(), and value_to_string().

◆ GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT

#define GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT   65552

Record type for reclaim OIDC clients.

Definition at line 138 of file gnunet_gnsrecord_lib.h.

Referenced by string_to_value(), and value_to_string().

◆ GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT

#define GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT   65553

Record type for reclaim OIDC redirect URIs.

Definition at line 143 of file gnunet_gnsrecord_lib.h.

Referenced by client_redirect(), lookup_redirect_uri_result(), string_to_value(), and value_to_string().

◆ GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL

#define GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL   65554

Record type for an attribute attestation.

Definition at line 148 of file gnunet_gnsrecord_lib.h.

Referenced by cred_add_cb(), cred_iter_cb(), filter_tickets_cb(), rvk_move_attr_cb(), string_to_value(), and value_to_string().

◆ GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION

#define GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION   65555

Record type for a presentation of a credential (used in a ticket record set)

Definition at line 154 of file gnunet_gnsrecord_lib.h.

Referenced by filter_tickets_cb(), issue_ticket(), lookup_authz_cb(), string_to_value(), and value_to_string().

◆ GNUNET_GNSRECORD_TYPE_EDKEY

#define GNUNET_GNSRECORD_TYPE_EDKEY   GNUNET_IDENTITY_TYPE_EDDSA

Typedef Documentation

◆ GNUNET_GNSRECORD_RecordCallback

typedef void(* GNUNET_GNSRECORD_RecordCallback) (void *cls, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)

Process a records that were decrypted from a block.

Parameters
clsclosure
rd_countnumber of entries in rd array
rdarray of records with data to store

Definition at line 375 of file gnunet_gnsrecord_lib.h.

Enumeration Type Documentation

◆ GNUNET_GNSRECORD_Flags

Flags that can be set for a record.

Enumerator
GNUNET_GNSRECORD_RF_NONE 

No special options.

GNUNET_GNSRECORD_RF_PRIVATE 

This is a private record of this peer and it should thus not be handed out to other peers.

GNUNET_GNSRECORD_RF_SUPPLEMENTAL 

This is a supplemental record.

GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION 

This expiration time of the record is a relative time (not an absolute time).

GNUNET_GNSRECORD_RF_SHADOW_RECORD 

This record should not be used unless all (other) records with an absolute expiration time have expired.

Definition at line 165 of file gnunet_gnsrecord_lib.h.

166 {
171 
177 
182 
188 
194 
206 #define GNUNET_GNSRECORD_RF_RCMP_FLAGS (GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION)
207 };
This record should not be used unless all (other) records with an absolute expiration time have expir...
This is a supplemental record.
This is a private record of this peer and it should thus not be handed out to other peers...
This expiration time of the record is a relative time (not an absolute time).

Function Documentation

◆ GNUNET_GNSRECORD_JSON_spec_gnsrecord()

struct GNUNET_JSON_Specification GNUNET_GNSRECORD_JSON_spec_gnsrecord ( struct GNUNET_GNSRECORD_Data **  rd,
unsigned int *  rd_count,
char **  name 
)

JSON Specification for GNS Records.

Parameters
gnsrecord_objectstruct of GNUNET_GNSRECORD_Data to fill
Returns
JSON Specification

Definition at line 262 of file json_gnsrecord.c.

References clean_gnsrecordobject(), GNUNET_new, GnsRecordInfo::name, parse_gnsrecordobject(), GNUNET_JSON_Specification::parser, GnsRecordInfo::rd, GnsRecordInfo::rd_count, and ret.

Referenced by namestore_add_or_update().

265 {
266  struct GnsRecordInfo *gnsrecord_info = GNUNET_new (struct GnsRecordInfo);
267 
268  gnsrecord_info->rd = rd;
269  gnsrecord_info->name = name;
270  gnsrecord_info->rd_count = rd_count;
272  .cleaner = &clean_gnsrecordobject,
273  .cls = NULL,
274  .field = NULL,
275  .ptr = (struct GnsRecordInfo *)
276  gnsrecord_info,
277  .ptr_size = 0,
278  .size_ptr = NULL };
279  return ret;
280 }
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
Entry in parser specification for GNUNET_JSON_parse().
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static int parse_gnsrecordobject(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
unsigned int * rd_count
const char * name
static void clean_gnsrecordobject(void *cls, struct GNUNET_JSON_Specification *spec)
Cleanup data left from parsing the record.
struct GNUNET_GNSRECORD_Data ** rd
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_GNSRECORD_JSON_from_gnsrecord()

json_t* GNUNET_GNSRECORD_JSON_from_gnsrecord ( const char *  rname,
const struct GNUNET_GNSRECORD_Data rd,
unsigned int  rd_count 
)

Convert GNS record to JSON.

Parameters
rnamename of record
rdrecord data
Returns
corresponding JSON encoding

Definition at line 291 of file json_gnsrecord.c.

References GNUNET_TIME_Absolute::abs_value_us, data, data_size, GNUNET_GNSRECORD_Data::expiration_time, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_GNSRECORD_number_to_typename(), GNUNET_GNSRECORD_RF_PRIVATE, GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION, GNUNET_GNSRECORD_RF_SHADOW_RECORD, GNUNET_GNSRECORD_RF_SUPPLEMENTAL, GNUNET_GNSRECORD_value_to_string(), GNUNET_log, GNUNET_NO, GNUNET_STRINGS_absolute_time_to_string(), GNUNET_STRINGS_relative_time_to_string(), GnsRecordInfo::rd_count, record(), records, and GNUNET_TIME_Relative::rel_value_us.

Referenced by handle_gns_response(), namestore_list_iteration(), and ns_get_lookup_cb().

294 {
295  struct GNUNET_TIME_Absolute abs_exp;
296  struct GNUNET_TIME_Relative rel_exp;
297  const char *expiration_time_str;
298  const char *record_type_str;
299  char *value_str;
300  json_t *data;
301  json_t *record;
302  json_t *records;
303 
304  data = json_object ();
305  if (NULL == data)
306  {
307  GNUNET_break (0);
308  return NULL;
309  }
310  if (0 !=
311  json_object_set_new (data,
312  "record_name",
313  json_string (rname)))
314  {
315  GNUNET_break (0);
316  json_decref (data);
317  return NULL;
318  }
319  records = json_array ();
320  if (NULL == records)
321  {
322  GNUNET_break (0);
323  json_decref (data);
324  return NULL;
325  }
326  for (int i = 0; i < rd_count; i++)
327  {
328  value_str = GNUNET_GNSRECORD_value_to_string (rd[i].record_type,
329  rd[i].data,
330  rd[i].data_size);
331  if (GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION & rd[i].flags)
332  {
333  rel_exp.rel_value_us = rd[i].expiration_time;
334  expiration_time_str = GNUNET_STRINGS_relative_time_to_string (rel_exp,
335  GNUNET_NO);
336  }
337  else
338  {
339  abs_exp.abs_value_us = rd[i].expiration_time;
340  expiration_time_str = GNUNET_STRINGS_absolute_time_to_string (abs_exp);
341  }
342  record_type_str = GNUNET_GNSRECORD_number_to_typename (rd[i].record_type);
344  "Packing %s %s %s %d\n",
345  value_str, record_type_str, expiration_time_str, rd[i].flags);
346  record = json_pack ("{s:s,s:s,s:s,s:b,s:b,s:b,s:b}",
347  "value",
348  value_str,
349  "record_type",
350  record_type_str,
351  "expiration_time",
352  expiration_time_str,
353  "private",
354  rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE,
355  "relative_expiration",
357  "supplemental",
358  rd[i].flags & GNUNET_GNSRECORD_RF_SUPPLEMENTAL,
359  "shadow",
360  rd[i].flags & GNUNET_GNSRECORD_RF_SHADOW_RECORD);
361  GNUNET_free (value_str);
362  if (NULL == record)
363  {
364  GNUNET_break (0);
365  json_decref (records);
366  json_decref (data);
367  return NULL;
368  }
369  if (0 !=
370  json_array_append_new (records,
371  record))
372  {
373  GNUNET_break (0);
374  json_decref (records);
375  json_decref (data);
376  return NULL;
377  }
378  }
379  if (0 !=
380  json_object_set_new (data,
381  "data",
382  records))
383  {
384  GNUNET_break (0);
385  json_decref (data);
386  return NULL;
387  }
388  return data;
389 }
This record should not be used unless all (other) records with an absolute expiration time have expir...
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
This is a supplemental record.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static unsigned int records
Number of records we found.
uint64_t expiration_time
Expiration time for the DNS record.
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:702
This is a private record of this peer and it should thus not be handed out to other peers...
#define GNUNET_log(kind,...)
static void record(void *cls, size_t data_size, const void *data)
Process recorded audio data.
Time for absolute times used by GNUnet, in microseconds.
This expiration time of the record is a relative time (not an absolute time).
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
Definition: strings.c:758
uint32_t data
The data value.
char * GNUNET_GNSRECORD_value_to_string(uint32_t type, const void *data, size_t data_size)
Convert the &#39;value&#39; of a record to a string.
Definition: gnsrecord.c:159
const char * GNUNET_GNSRECORD_number_to_typename(uint32_t type)
Convert a type number (i.e.
Definition: gnsrecord.c:247
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_GNSRECORD_value_to_string()

char* GNUNET_GNSRECORD_value_to_string ( uint32_t  type,
const void *  data,
size_t  data_size 
)

Convert the binary value data of a record of type type to a human-readable string.

Parameters
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

Convert the binary value data of a record of type type to a human-readable string.

Parameters
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 159 of file gnsrecord.c.

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

Referenced by check_pkey(), del_monitor(), display_record(), display_records_from_block(), gns_value_to_string(), GNUNET_GNSRECORD_JSON_from_gnsrecord(), GNUNET_GNSRECORD_records_deserialize(), GNUNET_GNSRECORD_records_get_size(), GNUNET_GNSRECORD_records_serialize(), iterate_cb(), process_lookup_result(), and start_phone().

162 {
163  struct Plugin *plugin;
164  char *ret;
165 
166  init ();
167  for (unsigned int i = 0; i < num_plugins; i++)
168  {
169  plugin = gns_plugins[i];
170  if (NULL != (ret = plugin->api->value_to_string (plugin->api->cls,
171  type,
172  data,
173  data_size)))
174  return ret;
175  }
176  return NULL;
177 }
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
static void init()
Loads all plugins (lazy initialization).
Definition: gnsrecord.c:100
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
static unsigned int num_plugins
Size of the &#39;plugins&#39; array.
Definition: gnsrecord.c:63
static char * plugin
Solver plugin name as string.
Handle for a plugin.
Definition: block.c:37
static struct Plugin ** gns_plugins
Array of our plugins.
Definition: gnsrecord.c:58
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
void * cls
Closure for all of the callbacks.
uint32_t data
The data value.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_GNSRECORD_string_to_value()

int GNUNET_GNSRECORD_string_to_value ( uint32_t  type,
const char *  s,
void **  data,
size_t *  data_size 
)

Convert human-readable version of the value s of a record of type type to the respective binary representation.

Parameters
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

Convert human-readable version of the value s of a record of type type to the respective binary representation.

Parameters
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 191 of file gnsrecord.c.

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

Referenced by gns_string_to_value(), multirecord_process(), parse_record(), run(), run_with_zone_pkey(), and store_cb().

195 {
196  struct Plugin *plugin;
197 
198  init ();
199  for (unsigned int i = 0; i < num_plugins; i++)
200  {
201  plugin = gns_plugins[i];
202  if (GNUNET_OK == plugin->api->string_to_value (plugin->api->cls,
203  type,
204  s,
205  data,
206  data_size))
207  return GNUNET_OK;
208  }
209  return GNUNET_SYSERR;
210 }
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
static void init()
Loads all plugins (lazy initialization).
Definition: gnsrecord.c:100
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
static unsigned int num_plugins
Size of the &#39;plugins&#39; array.
Definition: gnsrecord.c:63
static char * plugin
Solver plugin name as string.
Handle for a plugin.
Definition: block.c:37
static struct Plugin ** gns_plugins
Array of our plugins.
Definition: gnsrecord.c:58
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
void * cls
Closure for all of the callbacks.
uint32_t data
The data value.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_GNSRECORD_typename_to_number()

uint32_t GNUNET_GNSRECORD_typename_to_number ( const char *  dns_typename)

Convert a type name (i.e.

"AAAA") to the corresponding number.

Parameters
dns_typenamename to convert
Returns
corresponding number, UINT32_MAX on error

Definition at line 220 of file gnsrecord.c.

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

Referenced by del_monitor(), display_record(), get_gns_cont(), multirecord_process(), namestore_get(), parse_record(), run(), and run_with_zone_pkey().

221 {
222  struct Plugin *plugin;
223  uint32_t ret;
224 
225  if (0 == strcasecmp (dns_typename,
226  "ANY"))
228  init ();
229  for (unsigned int i = 0; i < num_plugins; i++)
230  {
231  plugin = gns_plugins[i];
232  if (UINT32_MAX != (ret = plugin->api->typename_to_number (plugin->api->cls,
233  dns_typename)))
234  return ret;
235  }
236  return UINT32_MAX;
237 }
#define GNUNET_GNSRECORD_TYPE_ANY
Record type indicating any record/&#39;*&#39;.
static void init()
Loads all plugins (lazy initialization).
Definition: gnsrecord.c:100
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
static unsigned int num_plugins
Size of the &#39;plugins&#39; array.
Definition: gnsrecord.c:63
static char * plugin
Solver plugin name as string.
Handle for a plugin.
Definition: block.c:37
static struct Plugin ** gns_plugins
Array of our plugins.
Definition: gnsrecord.c:58
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_GNSRECORD_number_to_typename()

const char* GNUNET_GNSRECORD_number_to_typename ( uint32_t  type)

Convert a type number (i.e.

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

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

Definition at line 247 of file gnsrecord.c.

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

Referenced by display_record(), display_records_from_block(), GNUNET_GNSRECORD_JSON_from_gnsrecord(), multirecord_process(), process_lookup_result(), and run_with_zone_pkey().

248 {
249  struct Plugin *plugin;
250  const char *ret;
251 
253  return "ANY";
254  init ();
255  for (unsigned int i = 0; i < num_plugins; i++)
256  {
257  plugin = gns_plugins[i];
258  if (NULL != (ret = plugin->api->number_to_typename (plugin->api->cls,
259  type)))
260  return ret;
261  }
262  return NULL;
263 }
#define GNUNET_GNSRECORD_TYPE_ANY
Record type indicating any record/&#39;*&#39;.
static void init()
Loads all plugins (lazy initialization).
Definition: gnsrecord.c:100
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
static unsigned int num_plugins
Size of the &#39;plugins&#39; array.
Definition: gnsrecord.c:63
static char * plugin
Solver plugin name as string.
Handle for a plugin.
Definition: block.c:37
static struct Plugin ** gns_plugins
Array of our plugins.
Definition: gnsrecord.c:58
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:

◆ GNUNET_GNSRECORD_records_get_size()

ssize_t GNUNET_GNSRECORD_records_get_size ( unsigned int  rd_count,
const struct GNUNET_GNSRECORD_Data rd 
)

Calculate how many bytes we will need to serialize the given records.

Parameters
rd_countnumber of records in the rd array
rdarray of GNUNET_GNSRECORD_Data with rd_count elements
Returns
the required size to serialize, -1 on error
Parameters
rd_countnumber of records in the rd array
rdarray of GNUNET_GNSRECORD_Data with rd_count elements
Returns
the required size to serialize, -1 on error

Efficiently round up to the next power of 2 for padding https://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2

Definition at line 88 of file gnsrecord_serialization.c.

References data, NetworkRecord::data_size, GNUNET_GNSRECORD_Data::data_size, GNUNET_break, GNUNET_break_op, GNUNET_free, GNUNET_GNSRECORD_TYPE_PKEY, GNUNET_GNSRECORD_value_to_string(), NetworkRecord::record_type, GNUNET_GNSRECORD_Data::record_type, and ret.

Referenced by block_create_ecdsa(), GNUNET_NAMESTORE_records_store(), handle_gns_resolution_result(), handle_zone_to_name_it(), lookup_it(), namestore_postgres_store_records(), namestore_sqlite_store_records(), run(), rvk_ticket_update(), send_lookup_response(), store_and_free_entries(), and ticket_iter().

90 {
91  size_t ret;
92 
93  if (0 == rd_count)
94  return 0;
95 
96  ret = sizeof(struct NetworkRecord) * rd_count;
97  for (unsigned int i = 0; i < rd_count; i++)
98  {
99  if ((ret + rd[i].data_size) < ret)
100  {
101  GNUNET_break (0);
102  return -1;
103  }
104  ret += rd[i].data_size;
105 #if DEBUG_GNSRECORDS
106  {
107  char *str;
108 
110  rd[i].data,
111  rd[i].data_size);
112  if (NULL == str)
113  {
114  GNUNET_break_op (0);
115  return -1;
116  }
117  GNUNET_free (str);
118  }
119 #endif
120  }
121  if (ret > SSIZE_MAX)
122  {
123  GNUNET_break (0);
124  return -1;
125  }
126  // Do not pad PKEY
128  return ret;ret--;
134  ret |= ret >> 1;
135  ret |= ret >> 2;
136  ret |= ret >> 4;
137  ret |= ret >> 8;
138  ret |= ret >> 16;
139  ret++;
140  return (ssize_t) ret;
141 }
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
size_t data_size
Number of bytes in data.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define GNUNET_GNSRECORD_TYPE_PKEY
Record type for GNS zone transfer ("PKEY").
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
uint32_t record_type
Type of the GNS/DNS record.
uint32_t record_type
Type of the GNS/DNS record, network byte order.
uint32_t data
The data value.
char * GNUNET_GNSRECORD_value_to_string(uint32_t type, const void *data, size_t data_size)
Convert the &#39;value&#39; of a record to a string.
Definition: gnsrecord.c:159
Internal format of a record in the serialized form.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_GNSRECORD_records_serialize()

ssize_t GNUNET_GNSRECORD_records_serialize ( unsigned int  rd_count,
const struct GNUNET_GNSRECORD_Data rd,
size_t  dest_size,
char *  dest 
)

Serialize the given records to the given destination buffer.

Parameters
rd_countnumber of records in the rd array
rdarray of GNUNET_GNSRECORD_Data with rd_count elements
dest_sizesize of the destination array dst
destwhere to write the result
Returns
the size of serialized records, -1 if records do not fit
Parameters
rd_countnumber of records in the rd array
rdarray of GNUNET_GNSRECORD_Data with rd_count elements
dest_sizesize of the destination array
destwhere to write the result
Returns
the size of serialized records, -1 if records do not fit

Definition at line 154 of file gnsrecord_serialization.c.

References data, NetworkRecord::data_size, GNUNET_GNSRECORD_Data::data_size, NetworkRecord::expiration_time, NetworkRecord::flags, GNUNET_break, GNUNET_break_op, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_GNSRECORD_value_to_string(), GNUNET_htonll(), GNUNET_memcpy, LOG, and NetworkRecord::record_type.

Referenced by block_create_ecdsa(), GNUNET_NAMESTORE_records_store(), handle_gns_resolution_result(), handle_zone_to_name_it(), lookup_it(), namestore_postgres_store_records(), namestore_sqlite_store_records(), run(), rvk_ticket_update(), send_lookup_response(), store_and_free_entries(), and ticket_iter().

158 {
159  struct NetworkRecord rec;
160  size_t off;
161 
162  off = 0;
163  for (unsigned int i = 0; i < rd_count; i++)
164  {
166  "Serializing record %u with flags %d and expiration time %llu\n",
167  i,
168  rd[i].flags,
169  (unsigned long long) rd[i].expiration_time);
170  rec.expiration_time = GNUNET_htonll (rd[i].expiration_time);
171  rec.data_size = htonl ((uint32_t) rd[i].data_size);
172  rec.record_type = htonl (rd[i].record_type);
173  rec.flags = htonl (rd[i].flags);
174  if ((off + sizeof(rec) > dest_size) ||
175  (off + sizeof(rec) < off))
176  {
177  GNUNET_break (0);
178  return -1;
179  }
180  GNUNET_memcpy (&dest[off],
181  &rec,
182  sizeof(rec));
183  off += sizeof(rec);
184  if ((off + rd[i].data_size > dest_size) ||
185  (off + rd[i].data_size < off))
186  {
187  GNUNET_break (0);
188  return -1;
189  }
190  GNUNET_memcpy (&dest[off],
191  rd[i].data,
192  rd[i].data_size);
193  off += rd[i].data_size;
194 #if DEBUG_GNSRECORDS
195  {
196  char *str;
197 
199  rd[i].data,
200  rd[i].data_size);
201  if (NULL == str)
202  {
203  GNUNET_break_op (0);
204  return -1;
205  }
206  GNUNET_free (str);
207  }
208 #endif
209  }
210  memset (&dest[off],
211  0,
212  dest_size - off);
213  return dest_size;
214 }
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
uint32_t flags
Flags for the record, network byte order.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
size_t data_size
Number of bytes in data.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define LOG(kind,...)
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
uint64_t expiration_time
Expiration time for the DNS record; relative or absolute depends on flags, network byte order...
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:36
uint32_t record_type
Type of the GNS/DNS record, network byte order.
uint32_t data
The data value.
char * GNUNET_GNSRECORD_value_to_string(uint32_t type, const void *data, size_t data_size)
Convert the &#39;value&#39; of a record to a string.
Definition: gnsrecord.c:159
Internal format of a record in the serialized form.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_GNSRECORD_records_deserialize()

int GNUNET_GNSRECORD_records_deserialize ( size_t  len,
const char *  src,
unsigned int  rd_count,
struct GNUNET_GNSRECORD_Data dest 
)

Deserialize the given records to the given destination.

Parameters
lensize of the serialized record data
srcthe serialized record data
rd_countnumber of records in the dest array
destwhere to put the data
Returns
GNUNET_OK on success, GNUNET_SYSERR on error
Parameters
lensize of the serialized record data
srcthe serialized record data
rd_countnumber of records in the rd array
destwhere to put the data
Returns
GNUNET_OK on success, GNUNET_SYSERR on error

Definition at line 227 of file gnsrecord_serialization.c.

References data, GNUNET_GNSRECORD_Data::data, NetworkRecord::data_size, GNUNET_GNSRECORD_Data::data_size, NetworkRecord::expiration_time, GNUNET_GNSRECORD_Data::expiration_time, NetworkRecord::flags, GNUNET_GNSRECORD_Data::flags, GNUNET_break_op, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_GNSRECORD_value_to_string(), GNUNET_memcpy, GNUNET_ntohll(), GNUNET_OK, GNUNET_SYSERR, LOG, NetworkRecord::record_type, and GNUNET_GNSRECORD_Data::record_type.

Referenced by block_decrypt_ecdsa(), check_rd(), check_result(), continue_store_activity(), database_setup(), get_records_and_call_iterator(), handle_lookup_result(), handle_record_result(), handle_record_store(), handle_result(), handle_zone_to_name_response(), parse_result_call_iterator(), process_tickets(), update_tickets(), and vpn_allocation_cb().

231 {
232  struct NetworkRecord rec;
233  size_t off;
234 
235  off = 0;
236  for (unsigned int i = 0; i < rd_count; i++)
237  {
238  if ((off + sizeof(rec) > len) ||
239  (off + sizeof(rec) < off))
240  {
241  GNUNET_break_op (0);
242  return GNUNET_SYSERR;
243  }
244  GNUNET_memcpy (&rec,
245  &src[off],
246  sizeof(rec));
247  dest[i].expiration_time = GNUNET_ntohll (rec.expiration_time);
248  dest[i].data_size = ntohl ((uint32_t) rec.data_size);
249  dest[i].record_type = ntohl (rec.record_type);
250  dest[i].flags = ntohl (rec.flags);
251  off += sizeof(rec);
252  if ((off + dest[i].data_size > len) ||
253  (off + dest[i].data_size < off))
254  {
255  GNUNET_break_op (0);
256  return GNUNET_SYSERR;
257  }
258  dest[i].data = &src[off];
259  off += dest[i].data_size;
260 #if GNUNET_EXTRA_LOGGING
261  {
262  char *str;
263 
265  dest[i].data,
266  dest[i].data_size);
267  if (NULL == str)
268  {
269  GNUNET_break_op (0);
270  return GNUNET_SYSERR;
271  }
272  GNUNET_free (str);
273  }
274 #endif
276  "Deserialized record %u with flags %d and expiration time %llu\n",
277  i,
278  dest[i].flags,
279  (unsigned long long) dest[i].expiration_time);
280  }
281  return GNUNET_OK;
282 }
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
uint32_t flags
Flags for the record, network byte order.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
size_t data_size
Number of bytes in data.
const void * data
Binary value stored in the DNS record.
#define LOG(kind,...)
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
uint64_t expiration_time
Expiration time for the DNS record.
uint64_t expiration_time
Expiration time for the DNS record; relative or absolute depends on flags, network byte order...
uint32_t record_type
Type of the GNS/DNS record.
uint32_t record_type
Type of the GNS/DNS record, network byte order.
enum GNUNET_GNSRECORD_Flags flags
Flags for the record.
uint32_t data
The data value.
char * GNUNET_GNSRECORD_value_to_string(uint32_t type, const void *data, size_t data_size)
Convert the &#39;value&#39; of a record to a string.
Definition: gnsrecord.c:159
Internal format of a record in the serialized form.
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:53
#define GNUNET_free(ptr)
Wrapper around free.
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_GNSRECORD_is_expired()

int GNUNET_GNSRECORD_is_expired ( const struct GNUNET_GNSRECORD_Data rd)

Test if a given record is expired.

Parameters
rdrecord to test
Returns
GNUNET_YES if the record is expired, GNUNET_NO if not
GNUNET_YES if the record is expired, GNUNET_NO if not

Definition at line 216 of file gnsrecord_misc.c.

References GNUNET_TIME_Absolute::abs_value_us, GNUNET_GNSRECORD_Data::expiration_time, GNUNET_GNSRECORD_Data::flags, GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION, GNUNET_NO, GNUNET_TIME_absolute_get_remaining(), and GNUNET_YES.

217 {
218  struct GNUNET_TIME_Absolute at;
219 
221  return GNUNET_NO;
222  at.abs_value_us = rd->expiration_time;
223  return (0 == GNUNET_TIME_absolute_get_remaining (at).rel_value_us) ?
225 }
uint64_t expiration_time
Expiration time for the DNS record.
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_remaining(struct GNUNET_TIME_Absolute future)
Given a timestamp in the future, how much time remains until then?
Definition: time.c:331
Time for absolute times used by GNUnet, in microseconds.
enum GNUNET_GNSRECORD_Flags flags
Flags for the record.
This expiration time of the record is a relative time (not an absolute time).
Here is the call graph for this function:

◆ GNUNET_GNSRECORD_string_to_lowercase()

char* GNUNET_GNSRECORD_string_to_lowercase ( const char *  src)

Convert a UTF-8 string to UTF-8 lowercase.

Parameters
srcsource string
Returns
converted result

Definition at line 46 of file gnsrecord_misc.c.

References GNUNET_strdup, GNUNET_STRINGS_utf8_tolower(), and res.

Referenced by handle_record_lookup(), and handle_record_store().

47 {
48  char *res;
49 
50  res = GNUNET_strdup (src);
51  GNUNET_STRINGS_utf8_tolower (src, res);
52  return res;
53 }
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
static int res
void GNUNET_STRINGS_utf8_tolower(const char *input, char *output)
Convert the utf-8 input string to lower case.
Definition: strings.c:568
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_GNSRECORD_z2s()

const char* GNUNET_GNSRECORD_z2s ( const struct GNUNET_IDENTITY_PublicKey z)

Convert a zone to a string (for printing debug messages).

This is one of the very few calls in the entire API that is NOT reentrant!

Parameters
zpublic key of a zone
Returns
string form; will be overwritten by next call to GNUNET_GNSRECORD_z2s.

Convert a zone to a string (for printing debug messages).

This is one of the very few calls in the entire API that is NOT reentrant!

Parameters
zthe zone key
Returns
string form; will be overwritten by next call to GNUNET_GNSRECORD_z2s

Definition at line 65 of file gnsrecord_misc.c.

References buf, end, GNUNET_break, and GNUNET_STRINGS_data_to_string().

Referenced by get_nick_record(), handle_gns_resolution_result(), handle_namecache_block_response(), handle_revocation_result(), namestore_flat_zone_to_name(), namestore_sqlite_zone_to_name(), recursive_gns_resolution_namecache(), recursive_gns_resolution_revocation(), and refresh_block().

66 {
67  static char buf[sizeof(struct GNUNET_IDENTITY_PublicKey) * 8];
68  char *end;
69 
70  end = GNUNET_STRINGS_data_to_string ((const unsigned char *) z,
71  sizeof(struct
73  buf, sizeof(buf));
74  if (NULL == end)
75  {
76  GNUNET_break (0);
77  return NULL;
78  }
79  *end = '\0';
80  return buf;
81 }
static int end
Set if we are to shutdown all services (including ARM).
Definition: gnunet-arm.c:34
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static char buf[2048]
An identity key as per LSD0001.
char * GNUNET_STRINGS_data_to_string(const void *data, size_t size, char *out, size_t out_size)
Convert binary data to ASCII encoding using CrockfordBase32.
Definition: strings.c:872
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_GNSRECORD_pkey_to_zkey()

const char* GNUNET_GNSRECORD_pkey_to_zkey ( const struct GNUNET_IDENTITY_PublicKey pkey)

Convert public key to the respective absolute domain name in the ".zkey" pTLD.

This is one of the very few calls in the entire API that is NOT reentrant!

Parameters
pkeya public key with a point on the eliptic curve
Returns
string "X.zkey" where X is the coordinates of the public key in an encoding suitable for DNS labels.

This is one of the very few calls in the entire API that is NOT reentrant!

Parameters
pkeya public key with a point on the eliptic curve
Returns
string "X.zkey" where X is the public key in an encoding suitable for DNS labels.

Definition at line 239 of file gnsrecord_misc.c.

References GNUNET_free, GNUNET_IDENTITY_public_key_to_string(), GNUNET_snprintf(), and ret.

Referenced by caller_event_handler(), do_accept(), do_call(), do_resume(), do_status(), handle_phone_hangup(), phone_event_handler(), and translate_dot_plus().

240 {
241  static char ret[128];
242  char *pkeys;
243 
245  GNUNET_snprintf (ret,
246  sizeof(ret),
247  "%s",
248  pkeys);
249  GNUNET_free (pkeys);
250  return ret;
251 }
char * GNUNET_IDENTITY_public_key_to_string(const struct GNUNET_IDENTITY_PublicKey *key)
Creates a (Base32) string representation of the public key.
Definition: identity_api.c:994
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
int GNUNET_snprintf(char *buf, size_t size, const char *format,...) __attribute__((format(printf
Like snprintf, just aborts if the buffer is of insufficient size.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_GNSRECORD_zkey_to_pkey()

int GNUNET_GNSRECORD_zkey_to_pkey ( const char *  zkey,
struct GNUNET_IDENTITY_PublicKey pkey 
)

Convert an absolute domain name to the respective public key.

Parameters
zkeystring "X" where X is the public key in an encoding suitable for DNS labels.
pkeyset to a public key on the eliptic curve
Returns
GNUNET_SYSERR if zkey has the wrong syntax
Parameters
zkeystring encoding the coordinates of the public key in an encoding suitable for DNS labels.
pkeyset to a public key on the eliptic curve
Returns
GNUNET_SYSERR if zkey has the wrong syntax

Definition at line 264 of file gnsrecord_misc.c.

References GNUNET_IDENTITY_public_key_from_string(), GNUNET_OK, and GNUNET_SYSERR.

Referenced by GNS_find_tld(), handle_gns_cname_result(), and recursive_gns2dns_resolution().

266 {
267  if (GNUNET_OK !=
269  pkey))
270  return GNUNET_SYSERR;
271  return GNUNET_OK;
272 }
enum GNUNET_GenericReturnValue GNUNET_IDENTITY_public_key_from_string(const char *str, struct GNUNET_IDENTITY_PublicKey *key)
Parses a (Base32) string representation of the public key.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_GNSRECORD_query_from_private_key()

void GNUNET_GNSRECORD_query_from_private_key ( const struct GNUNET_IDENTITY_PrivateKey zone,
const char *  label,
struct GNUNET_HashCode query 
)

Calculate the DHT query for a given label in a given zone.

Parameters
zoneprivate key of the zone
labellabel of the record
queryhash to use for the query

Definition at line 549 of file gnsrecord_crypto.c.

References GNUNET_assert, GNUNET_GNSRECORD_query_from_public_key(), GNUNET_GNSRECORD_TYPE_PKEY, GNUNET_IDENTITY_key_get_public(), and GNUNET_IDENTITY_PrivateKey::type.

Referenced by perform_dht_put().

553 {
555  switch (ntohl (zone->type))
556  {
558 
560  &pub);
562  label,
563  query);
564  break;
565  default:
566  GNUNET_assert (0);
567  }
568 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_GNSRECORD_TYPE_PKEY
Record type for GNS zone transfer ("PKEY").
enum GNUNET_GenericReturnValue GNUNET_IDENTITY_key_get_public(const struct GNUNET_IDENTITY_PrivateKey *privkey, struct GNUNET_IDENTITY_PublicKey *key)
Retrieves the public key representation of a private key.
Definition: identity_api.c:175
void GNUNET_GNSRECORD_query_from_public_key(const struct GNUNET_IDENTITY_PublicKey *pub, const char *label, struct GNUNET_HashCode *query)
Calculate the DHT query for a given label in a given zone.
uint32_t type
Type of public key.
An identity key as per LSD0001.
static struct GNUNET_CRYPTO_EddsaPublicKey pub
Definition: gnunet-scrypt.c:46
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_GNSRECORD_query_from_public_key()

void GNUNET_GNSRECORD_query_from_public_key ( const struct GNUNET_IDENTITY_PublicKey pub,
const char *  label,
struct GNUNET_HashCode query 
)

Calculate the DHT query for a given label in a given zone.

Parameters
pubpublic key of the zone
labellabel of the record
queryhash to use for the query

Definition at line 579 of file gnsrecord_crypto.c.

References GNUNET_IDENTITY_PublicKey::ecdsa_key, GNUNET_assert, GNUNET_CRYPTO_ecdsa_public_key_derive(), GNUNET_CRYPTO_hash(), GNUNET_GNSRECORD_TYPE_PKEY, and GNUNET_IDENTITY_PublicKey::type.

Referenced by GNUNET_GNSRECORD_query_from_private_key(), handle_namecache_block_response(), recursive_gns_resolution_namecache(), and run().

583 {
584  struct GNUNET_IDENTITY_PublicKey pd;
585 
586  switch (ntohl (pub->type))
587  {
589  pd.type = pub->type;
591  label,
592  "gns",
593  &pd.ecdsa_key);
594  GNUNET_CRYPTO_hash (&pd.ecdsa_key,
595  sizeof (pd.ecdsa_key),
596  query);
597  break;
598  default:
599  GNUNET_assert (0);
600  }
601 }
void GNUNET_CRYPTO_ecdsa_public_key_derive(const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, const char *label, const char *context, struct GNUNET_CRYPTO_EcdsaPublicKey *result)
Derive a public key from a given public key and a label.
Definition: crypto_ecc.c:963
uint32_t type
Type of public key.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_GNSRECORD_TYPE_PKEY
Record type for GNS zone transfer ("PKEY").
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:48
struct GNUNET_CRYPTO_EcdsaPublicKey ecdsa_key
An ECDSA identity key.
An identity key as per LSD0001.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_GNSRECORD_block_create()

struct GNUNET_GNSRECORD_Block* GNUNET_GNSRECORD_block_create ( const struct GNUNET_IDENTITY_PrivateKey key,
struct GNUNET_TIME_Absolute  expire,
const char *  label,
const struct GNUNET_GNSRECORD_Data rd,
unsigned int  rd_count 
)

Sign name and records.

Parameters
keythe private key
expireblock expiration
labelthe name for the records
rdrecord data
rd_countnumber of records in rd
keythe private key
expireblock expiration
labelthe name for the records
rdrecord data
rd_countnumber of records
Returns
NULL on error (block too large)

Definition at line 259 of file gnsrecord_crypto.c.

References block_create_ecdsa(), GNUNET_IDENTITY_PrivateKey::ecdsa_key, GNUNET_assert, GNUNET_CRYPTO_ecdsa_key_get_public(), GNUNET_GNSRECORD_TYPE_PKEY, and GNUNET_IDENTITY_PrivateKey::type.

Referenced by perform_dht_put(), refresh_block(), and run().

264 {
266 
267  switch (ntohl (key->type))
268  {
271  &pkey);
272  return block_create_ecdsa (&key->ecdsa_key,
273  &pkey,
274  expire,
275  label,
276  rd,
277  rd_count);
278  default:
279  GNUNET_assert (0);
280  }
281  return NULL;
282 }
static char * pkey
Public key of the zone to look in, in ASCII.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_CRYPTO_EcdsaPrivateKey ecdsa_key
An ECDSA identity key.
#define GNUNET_GNSRECORD_TYPE_PKEY
Record type for GNS zone transfer ("PKEY").
static struct GNUNET_GNSRECORD_Block * block_create_ecdsa(const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, const struct GNUNET_CRYPTO_EcdsaPublicKey *pkey, struct GNUNET_TIME_Absolute expire, const char *label, const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count)
Sign name and records.
void GNUNET_CRYPTO_ecdsa_key_get_public(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Extract the public key for the given private key.
Definition: crypto_ecc.c:176
uint32_t type
Type of public key.
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_GNSRECORD_block_create2()

struct GNUNET_GNSRECORD_Block* GNUNET_GNSRECORD_block_create2 ( const struct GNUNET_IDENTITY_PrivateKey pkey,
struct GNUNET_TIME_Absolute  expire,
const char *  label,
const struct GNUNET_GNSRECORD_Data rd,
unsigned int  rd_count 
)

Sign name and records, cache derived public key (also keeps the private key in static memory, so do not use this function if keeping the private key in the process'es RAM is a major issue).

Parameters
keythe private key
expireblock expiration
labelthe name for the records
rdrecord data
rd_countnumber of records in rd
keythe private key
expireblock expiration
labelthe name for the records
rdrecord data
rd_countnumber of records
Returns
NULL on error (block too large)

Definition at line 315 of file gnsrecord_crypto.c.

References block_create_ecdsa(), CSIZE, GNUNET_IDENTITY_PrivateKey::ecdsa_key, GNUNET_CRYPTO_ecdsa_key_get_public(), GNUNET_IDENTITY_TYPE_ECDSA, KeyCacheLine::key, line, KeyCacheLine::pkey, and GNUNET_IDENTITY_PrivateKey::type.

Referenced by perform_dht_put(), and refresh_block().

320 {
321  const struct GNUNET_CRYPTO_EcdsaPrivateKey *key;
322 
323  if (GNUNET_IDENTITY_TYPE_ECDSA != ntohl (pkey->type))
324  {
325  return NULL; // FIXME
326  }
327  key = &pkey->ecdsa_key;
328 #define CSIZE 64
329  static struct KeyCacheLine cache[CSIZE];
330  struct KeyCacheLine *line;
331 
332  line = &cache[(*(unsigned int *) key) % CSIZE];
333  if (0 != memcmp (&line->key,
334  key,
335  sizeof(*key)))
336  {
337  /* cache miss, recompute */
338  line->key = *key;
340  &line->pkey);
341  }
342 #undef CSIZE
343  return block_create_ecdsa (key,
344  &line->pkey,
345  expire,
346  label,
347  rd,
348  rd_count);
349 }
Private ECC key encoded for transmission.
struct GNUNET_CRYPTO_EcdsaPrivateKey ecdsa_key
An ECDSA identity key.
static char * line
Desired phone line (string to be converted to a hash).
#define CSIZE
static struct GNUNET_GNSRECORD_Block * block_create_ecdsa(const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, const struct GNUNET_CRYPTO_EcdsaPublicKey *pkey, struct GNUNET_TIME_Absolute expire, const char *label, const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count)
Sign name and records.
struct GNUNET_HashCode key
The key used in the DHT.
void GNUNET_CRYPTO_ecdsa_key_get_public(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Extract the public key for the given private key.
Definition: crypto_ecc.c:176
uint32_t type
Type of public key.
static struct GNUNET_CONTAINER_MultiHashMap32 * cache
Hashmap to maintain cache.
Line in cache mapping private keys to public keys.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_GNSRECORD_block_verify()

int GNUNET_GNSRECORD_block_verify ( const struct GNUNET_GNSRECORD_Block block)

Check if a signature is valid.

This API is used by the GNS Block to validate signatures received from the network.

Parameters
blockblock to verify
Returns
GNUNET_OK if the signature is valid

Definition at line 360 of file gnsrecord_crypto.c.

References GNUNET_GNSRECORD_EcdsaBlock::derived_key, GNUNET_GNSRECORD_Block::ecdsa_block, GNUNET_break, GNUNET_CRYPTO_ecdsa_verify_(), GNUNET_GNSRECORD_TYPE_PKEY, GNUNET_NO, GNUNET_SIGNATURE_PURPOSE_GNS_RECORD_SIGN, KeyCacheLine::key, GNUNET_GNSRECORD_EcdsaBlock::purpose, GNUNET_GNSRECORD_EcdsaBlock::signature, and GNUNET_GNSRECORD_Block::type.

Referenced by block_plugin_gns_evaluate(), and handle_lookup_block_response().

361 {
362  const struct GNUNET_CRYPTO_EcdsaPublicKey *key;
363  const struct GNUNET_GNSRECORD_EcdsaBlock *ecblock;
364 
365  if (GNUNET_GNSRECORD_TYPE_PKEY != ntohl (block->type))
366  {
367  GNUNET_break (0);
368  return GNUNET_NO;
369  }
370  ecblock = &block->ecdsa_block;
371  key = &ecblock->derived_key;
372 
374  &ecblock->purpose,
375  &ecblock->signature,
376  key);
377 }
Information we have in an encrypted block with record data (i.e.
struct GNUNET_CRYPTO_EcdsaSignature signature
Signature of the block.
struct GNUNET_GNSRECORD_EcdsaBlock ecdsa_block
struct GNUNET_CRYPTO_EcdsaPublicKey derived_key
Derived key used for signing; hash of this is the query.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_CRYPTO_EccSignaturePurpose purpose
Number of bytes signed; also specifies the number of bytes of encrypted data that follow...
#define GNUNET_GNSRECORD_TYPE_PKEY
Record type for GNS zone transfer ("PKEY").
struct GNUNET_HashCode key
The key used in the DHT.
int GNUNET_CRYPTO_ecdsa_verify_(uint32_t purpose, const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, const struct GNUNET_CRYPTO_EcdsaSignature *sig, const struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Verify ECDSA signature.
Definition: crypto_ecc.c:745
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
#define GNUNET_SIGNATURE_PURPOSE_GNS_RECORD_SIGN
Signature of a gnunet naming system record block.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_GNSRECORD_block_decrypt()

int GNUNET_GNSRECORD_block_decrypt ( const struct GNUNET_GNSRECORD_Block block,
const struct GNUNET_IDENTITY_PublicKey zone_key,
const char *  label,
GNUNET_GNSRECORD_RecordCallback  proc,
void *  proc_cls 
)

Decrypt block.

Parameters
blockblock to decrypt
zone_keypublic key of the zone
labelthe name for the records
procfunction to call with the result
proc_clsclosure for proc
Returns
GNUNET_OK on success, GNUNET_SYSERR if the block was not well-formed
Parameters
blockblock to decrypt
zone_keypublic key of the zone
labelthe name for the records
procfunction to call with the result
proc_clsclosure for proc
Returns
GNUNET_OK on success, GNUNET_SYSERR if the block was not well-formed

Definition at line 520 of file gnsrecord_crypto.c.

References block_decrypt_ecdsa(), GNUNET_GNSRECORD_Block::ecdsa_block, GNUNET_IDENTITY_PublicKey::ecdsa_key, GNUNET_IDENTITY_TYPE_ECDSA, GNUNET_NO, KeyCacheLine::key, and GNUNET_IDENTITY_PublicKey::type.

Referenced by handle_block(), handle_dht_response(), and handle_namecache_block_response().

526 {
527  const struct GNUNET_CRYPTO_EcdsaPublicKey *key;
528 
529  if (GNUNET_IDENTITY_TYPE_ECDSA != ntohl (zone_key->type))
530  {
531  return GNUNET_NO;
532  }
533  key = &zone_key->ecdsa_key;
534 
535  return block_decrypt_ecdsa (&block->ecdsa_block,
536  key, label, proc, proc_cls);
537 
538 }
uint32_t type
Type of public key.
struct GNUNET_GNSRECORD_EcdsaBlock ecdsa_block
struct GNUNET_CRYPTO_EcdsaPublicKey ecdsa_key
An ECDSA identity key.
struct GNUNET_HashCode key
The key used in the DHT.
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
enum GNUNET_GenericReturnValue block_decrypt_ecdsa(const struct GNUNET_GNSRECORD_EcdsaBlock *block, const struct GNUNET_CRYPTO_EcdsaPublicKey *zone_key, const char *label, GNUNET_GNSRECORD_RecordCallback proc, void *proc_cls)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_GNSRECORD_records_cmp()

int GNUNET_GNSRECORD_records_cmp ( const struct GNUNET_GNSRECORD_Data a,
const struct GNUNET_GNSRECORD_Data b 
)

Compares if two records are equal.

Parameters
aa record
banother record
Returns
GNUNET_YES if the records are equal, or GNUNET_NO if not.

Compares if two records are equal.

absolute expiration time).

Parameters
arecord
brecord
Returns
GNUNET_YES if the records are equal or GNUNET_NO if they are not

Definition at line 94 of file gnsrecord_misc.c.

References GNUNET_GNSRECORD_Data::data, GNUNET_GNSRECORD_Data::data_size, GNUNET_GNSRECORD_Data::expiration_time, GNUNET_GNSRECORD_Data::flags, GNUNET_ERROR_TYPE_DEBUG, GNUNET_GNSRECORD_RF_RCMP_FLAGS, GNUNET_NO, GNUNET_YES, LOG, and GNUNET_GNSRECORD_Data::record_type.

96 {
98  "Comparing records\n");
99  if (a->record_type != b->record_type)
100  {
102  "Record type %u != %u\n", a->record_type, b->record_type);
103  return GNUNET_NO;
104  }
105  if ((a->expiration_time != b->expiration_time) &&
106  ((a->expiration_time != 0) && (b->expiration_time != 0)))
107  {
109  "Expiration time %llu != %llu\n",
110  a->expiration_time,
111  b->expiration_time);
112  return GNUNET_NO;
113  }
116  {
118  "Flags %u (%u) != %u (%u)\n", a->flags,
121  return GNUNET_NO;
122  }
123  if (a->data_size != b->data_size)
124  {
126  "Data size %lu != %lu\n",
127  a->data_size,
128  b->data_size);
129  return GNUNET_NO;
130  }
131  if (0 != memcmp (a->data, b->data, a->data_size))
132  {
134  "Data contents do not match\n");
135  return GNUNET_NO;
136  }
138  "Records are equal\n");
139  return GNUNET_YES;
140 }
size_t data_size
Number of bytes in data.
const void * data
Binary value stored in the DNS record.
#define LOG(kind,...)
uint64_t expiration_time
Expiration time for the DNS record.
#define GNUNET_GNSRECORD_RF_RCMP_FLAGS
uint32_t record_type
Type of the GNS/DNS record.
enum GNUNET_GNSRECORD_Flags flags
Flags for the record.

◆ GNUNET_GNSRECORD_record_get_expiration_time()

struct GNUNET_TIME_Absolute GNUNET_GNSRECORD_record_get_expiration_time ( unsigned int  rd_count,
const struct GNUNET_GNSRECORD_Data rd 
)

Returns the expiration time of the given block of records.

The block expiration time is the expiration time of the record with smallest expiration time.

Parameters
rd_countnumber of records given in rd
rdarray of records
Returns
absolute expiration time

Definition at line 153 of file gnsrecord_misc.c.

References GNUNET_TIME_Absolute::abs_value_us, expire(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION, GNUNET_GNSRECORD_RF_SHADOW_RECORD, GNUNET_STRINGS_absolute_time_to_string(), GNUNET_TIME_absolute_max(), GNUNET_TIME_absolute_min(), GNUNET_TIME_relative_to_absolute(), GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_TIME_UNIT_ZERO_ABS, LOG, and GNUNET_TIME_Relative::rel_value_us.

Referenced by perform_dht_put(), and refresh_block().

156 {
158  struct GNUNET_TIME_Absolute at;
159  struct GNUNET_TIME_Relative rt;
160  struct GNUNET_TIME_Absolute at_shadow;
161  struct GNUNET_TIME_Relative rt_shadow;
162 
163  if (NULL == rd)
166  for (unsigned int c = 0; c < rd_count; c++)
167  {
168  if (0 != (rd[c].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION))
169  {
170  rt.rel_value_us = rd[c].expiration_time;
172  }
173  else
174  {
175  at.abs_value_us = rd[c].expiration_time;
176  }
177 
178  for (unsigned int c2 = 0; c2 < rd_count; c2++)
179  {
180  /* Check for shadow record */
181  if ((c == c2) ||
182  (rd[c].record_type != rd[c2].record_type) ||
183  (0 == (rd[c2].flags & GNUNET_GNSRECORD_RF_SHADOW_RECORD)))
184  continue;
185  /* We have a shadow record */
186  if (0 != (rd[c2].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION))
187  {
188  rt_shadow.rel_value_us = rd[c2].expiration_time;
189  at_shadow = GNUNET_TIME_relative_to_absolute (rt_shadow);
190  }
191  else
192  {
193  at_shadow.abs_value_us = rd[c2].expiration_time;
194  }
195  at = GNUNET_TIME_absolute_max (at,
196  at_shadow);
197  }
199  expire);
200  }
202  "Determined expiration time for block with %u records to be %s\n",
203  rd_count,
205  return expire;
206 }
This record should not be used unless all (other) records with an absolute expiration time have expir...
#define GNUNET_TIME_UNIT_ZERO_ABS
Absolute time zero.
static void expire(void *cls)
Expire a PooledConnection object.
struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute(struct GNUNET_TIME_Relative rel)
Convert relative time to an absolute time in the future.
Definition: time.c:246
#define GNUNET_TIME_UNIT_FOREVER_ABS
Constant used to specify "forever".
#define LOG(kind,...)
uint64_t expiration_time
Expiration time for the DNS record.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_max(struct GNUNET_TIME_Absolute t1, struct GNUNET_TIME_Absolute t2)
Return the maximum of two absolute time values.
Definition: time.c:317
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_min(struct GNUNET_TIME_Absolute t1, struct GNUNET_TIME_Absolute t2)
Return the minimum of two absolute time values.
Definition: time.c:302
Time for absolute times used by GNUnet, in microseconds.
This expiration time of the record is a relative time (not an absolute time).
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
Definition: strings.c:758
Time for relative time used by GNUnet, in microseconds.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_GNSRECORD_block_get_size()

size_t GNUNET_GNSRECORD_block_get_size ( const struct GNUNET_GNSRECORD_Block block)

Returns the length of this block in bytes.

Block length strongly depends on the zone type.

Parameters
blockthe block.
Returns
the length of this block in bytes

Definition at line 321 of file gnsrecord_misc.c.

References GNUNET_GNSRECORD_Block::ecdsa_block, GNUNET_GNSRECORD_TYPE_PKEY, GNUNET_GNSRECORD_EcdsaBlock::purpose, GNUNET_CRYPTO_EccSignaturePurpose::size, and GNUNET_GNSRECORD_Block::type.

Referenced by block_plugin_gns_evaluate(), GNUNET_NAMECACHE_block_cache(), handle_dht_response(), handle_lookup_block_it(), namecache_cache_block(), namecache_postgres_cache_block(), namecache_sqlite_cache_block(), perform_dht_put(), and store_and_free_entries().

322 {
323  switch (ntohl (block->type))
324  {
326  return sizeof (uint32_t) /* zone type */
327  + sizeof (block->ecdsa_block) /* EcdsaBlock */
328  + ntohl (block->ecdsa_block.purpose.size) /* Length of signed data */
329  - sizeof (block->ecdsa_block.purpose); /* Purpose already in EcdsaBlock */
330  break;
331  default:
332  return 0;
333  }
334  return 0;
335 }
struct GNUNET_GNSRECORD_EcdsaBlock ecdsa_block
struct GNUNET_CRYPTO_EccSignaturePurpose purpose
Number of bytes signed; also specifies the number of bytes of encrypted data that follow...
#define GNUNET_GNSRECORD_TYPE_PKEY
Record type for GNS zone transfer ("PKEY").
uint32_t size
How many bytes does this signature sign? (including this purpose header); in network byte order (!)...
Here is the caller graph for this function:

◆ GNUNET_GNSRECORD_block_get_expiration()

struct GNUNET_TIME_Absolute GNUNET_GNSRECORD_block_get_expiration ( const struct GNUNET_GNSRECORD_Block block)

Returns the expiration of a block.

Parameters
blockthe block.
Returns
the block expiration.

Definition at line 339 of file gnsrecord_misc.c.

References GNUNET_GNSRECORD_TYPE_PKEY, GNUNET_TIME_absolute_get_zero_(), and GNUNET_TIME_absolute_ntoh().

Referenced by expire_blocks(), handle_dht_response(), handle_lookup_block_it(), handle_namecache_block_response(), namecache_postgres_cache_block(), and namecache_sqlite_cache_block().

341 {
342 
343  switch (ntohl (block->type))
344  {
347  default:
349  }
351 
352 }
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
Definition: time.c:673
struct GNUNET_GNSRECORD_EcdsaBlock ecdsa_block
struct GNUNET_TIME_AbsoluteNBO expiration_time
Expiration time of the block.
#define GNUNET_GNSRECORD_TYPE_PKEY
Record type for GNS zone transfer ("PKEY").
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get_zero_(void)
Return absolute time of 0ms.
Definition: time.c:147
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_GNSRECORD_query_from_block()

enum GNUNET_GenericReturnValue GNUNET_GNSRECORD_query_from_block ( const struct GNUNET_GNSRECORD_Block block,
struct GNUNET_HashCode query 
)

Builds the query hash from a block.

Parameters
blockthe block.
querywhere to write the query hash.
Returns
GNUNET_SYSERR on error.

Definition at line 356 of file gnsrecord_misc.c.

References GNUNET_GNSRECORD_EcdsaBlock::derived_key, GNUNET_GNSRECORD_Block::ecdsa_block, GNUNET_CRYPTO_hash(), GNUNET_GNSRECORD_TYPE_PKEY, GNUNET_OK, GNUNET_SYSERR, and GNUNET_GNSRECORD_Block::type.

Referenced by block_plugin_gns_evaluate(), block_plugin_gns_get_key(), namecache_cache_block(), namecache_postgres_cache_block(), and namecache_sqlite_cache_block().

358 {
359  switch (ntohl (block->type))
360  {
363  sizeof (block->ecdsa_block.derived_key),
364  query);
365  return GNUNET_OK;
366  default:
367  return GNUNET_SYSERR;
368  }
369  return GNUNET_SYSERR;
370 
371 }
struct GNUNET_GNSRECORD_EcdsaBlock ecdsa_block
struct GNUNET_CRYPTO_EcdsaPublicKey derived_key
Derived key used for signing; hash of this is the query.
#define GNUNET_GNSRECORD_TYPE_PKEY
Record type for GNS zone transfer ("PKEY").
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:48
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_GNSRECORD_identity_from_data()

enum GNUNET_GenericReturnValue GNUNET_GNSRECORD_identity_from_data ( const char *  data,
size_t  data_size,
uint32_t  type,
struct GNUNET_IDENTITY_PublicKey key 
)

Build a #GNUNET_GNSRECORD_PublicKey from zone delegation resource record data.

Parameters
datathe record data-
data_sizethe data size.
typethe record type
keythe identity key to store the data in (must be allocated).
Returns
GNUNET_OK if successful.

Definition at line 276 of file gnsrecord_misc.c.

References GNUNET_GNSRECORD_is_zonekey_type(), GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, type, and GNUNET_IDENTITY_PublicKey::type.

Referenced by check_pkey(), gns_value_to_string(), handle_gns_resolution_result(), namestore_postgres_store_records(), namestore_sqlite_store_records(), and recursive_pkey_resolution().

280 {
282  return GNUNET_SYSERR;
283  if (data_size > sizeof (struct GNUNET_IDENTITY_PublicKey))
284  return GNUNET_SYSERR;
285  key->type = type;
286  memcpy (key, data, data_size);
287  return GNUNET_OK;
288 }
uint32_t type
Type of public key.
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
enum GNUNET_GenericReturnValue GNUNET_GNSRECORD_is_zonekey_type(uint32_t type)
Check if this type is one of the supported GNS zone types.
An identity key as per LSD0001.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
uint32_t data
The data value.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_GNSRECORD_data_from_identity()

enum GNUNET_GenericReturnValue GNUNET_GNSRECORD_data_from_identity ( const struct GNUNET_IDENTITY_PublicKey key,
char **  data,
size_t *  data_size,
uint32_t *  type 
)

Create record data and size from an identity key.

Parameters
keythe identity key to use.
datathe record data (will be allocated)
data_sizethe allocated data size.
typethe resulting record type
Returns
GNUNET_OK if successful.

Definition at line 291 of file gnsrecord_misc.c.

References GNUNET_IDENTITY_key_get_length(), GNUNET_malloc, GNUNET_OK, GNUNET_SYSERR, and GNUNET_IDENTITY_PublicKey::type.

Referenced by gns_string_to_value(), and zone_to_name_cb().

296 {
297  *type = key->type;
299  if (0 == *data_size)
300  return GNUNET_SYSERR;
302  memcpy (*data, key, *data_size);
303  return GNUNET_OK;
304 }
uint32_t type
Type of public key.
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
ssize_t GNUNET_IDENTITY_key_get_length(const struct GNUNET_IDENTITY_PublicKey *key)
Get the compacted length of a GNUNET_IDENTITY_PublicKey.
Definition: identity_api.c:976
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
uint32_t data
The data value.
#define GNUNET_malloc(size)
Wrapper around malloc.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_GNSRECORD_is_zonekey_type()

enum GNUNET_GenericReturnValue GNUNET_GNSRECORD_is_zonekey_type ( uint32_t  type)

Check if this type is one of the supported GNS zone types.

Parameters
typethe type to check
Returns
GNUNET_YES if it is one of the supported types.

Definition at line 308 of file gnsrecord_misc.c.

References GNUNET_GNSRECORD_TYPE_EDKEY, GNUNET_GNSRECORD_TYPE_PKEY, GNUNET_NO, and GNUNET_YES.

Referenced by GNUNET_GNSRECORD_identity_from_data(), namestore_postgres_store_records(), namestore_sqlite_store_records(), and zone_to_name().

309 {
310  switch (type)
311  {
314  return GNUNET_YES;
315  default:
316  return GNUNET_NO;
317  }
318 }
#define GNUNET_GNSRECORD_TYPE_EDKEY
Record type for EDKEY delegations.
#define GNUNET_GNSRECORD_TYPE_PKEY
Record type for GNS zone transfer ("PKEY").
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
Here is the caller graph for this function: