GNUnet  0.10.x
Data Structures | Functions | Variables
gnunet-namestore.c File Reference

command line tool to manipulate the local zone More...

#include "platform.h"
#include <gnunet_util_lib.h>
#include <gnunet_dnsparser_lib.h>
#include <gnunet_identity_service.h>
#include <gnunet_gnsrecord_lib.h>
#include <gnunet_gns_service.h>
#include <gnunet_namestore_service.h>
Include dependency graph for gnunet-namestore.c:

Go to the source code of this file.

Data Structures

struct  RecordSetEntry
 Entry in record set for bulk processing. More...
 

Functions

static void do_shutdown (void *cls)
 Task run on shutdown. More...
 
static void test_finished ()
 Check if we are finished, and if so, perform shutdown. More...
 
static void add_continuation (void *cls, int32_t success, const char *emsg)
 Continuation called to notify client about result of the operation. More...
 
static void del_continuation (void *cls, int32_t success, const char *emsg)
 Continuation called to notify client about result of the operation. More...
 
static void zone_iteration_finished (void *cls)
 Function called when we are done with a zone iteration. More...
 
static void zone_iteration_error_cb (void *cls)
 Function called when we encountered an error in a zone iteration. More...
 
static void display_record (const char *rname, unsigned int rd_len, const struct GNUNET_GNSRECORD_Data *rd)
 Process a record that was stored in the namestore. More...
 
static void display_record_iterator (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, const char *rname, unsigned int rd_len, const struct GNUNET_GNSRECORD_Data *rd)
 Process a record that was stored in the namestore. More...
 
static void display_record_monitor (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, const char *rname, unsigned int rd_len, const struct GNUNET_GNSRECORD_Data *rd)
 Process a record that was stored in the namestore. More...
 
static void display_record_lookup (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, const char *rname, unsigned int rd_len, const struct GNUNET_GNSRECORD_Data *rd)
 Process a record that was stored in the namestore. More...
 
static void sync_cb (void *cls)
 Function called once we are in sync in monitor mode. More...
 
static void monitor_error_cb (void *cls)
 Function called on errors while monitoring. More...
 
static void lookup_error_cb (void *cls)
 Function called on errors while monitoring. More...
 
static void add_error_cb (void *cls)
 Function called if lookup fails. More...
 
static void get_existing_record (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, const char *rec_name, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
 We're storing a record; this function is given the existing record so that we can merge the information. More...
 
static void reverse_error_cb (void *cls)
 Function called if we encountered an error in zone-to-name. More...
 
static void handle_reverse_lookup (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
 Function called with the result of our attempt to obtain a name for a given public key. More...
 
static void del_lookup_error_cb (void *cls)
 Function called if lookup for deletion fails. More...
 
static void del_monitor (void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
 We were asked to delete something; this function is called with the existing records. More...
 
static int parse_expiration (const char *expirationstring, int *etime_is_rel, uint64_t *etime)
 Parse expiration time. More...
 
static void replace_cont (void *cls, int success, const char *emsg)
 Function called when namestore is done with the replace operation. More...
 
static void run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg)
 We have obtained the zone's private key, so now process the main commands using it. More...
 
static void identity_cb (void *cls, const struct GNUNET_IDENTITY_Ego *ego)
 Callback invoked from identity service with ego information. More...
 
static void default_ego_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, const char *name)
 Function called with the default ego to be used for GNS operations. More...
 
static void id_connect_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, const char *name)
 Function called with ALL of the egos known to the identity service, used on startup if the user did not specify a zone on the command-line. More...
 
static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
 Main function that will be run. More...
 
static int multirecord_process (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, void *scls, const char *option, const char *value)
 Command-line option parser function that allows the user to specify a complete record as one argument for adding/removing. More...
 
struct GNUNET_GETOPT_CommandLineOption multirecord_option (char shortName, const char *name, const char *argumentHelp, const char *description, struct RecordSetEntry **rs)
 Allow user to specify keywords. More...
 
int main (int argc, char *const *argv)
 The main function for gnunet-namestore. More...
 

Variables

static struct GNUNET_NAMESTORE_Handlens
 Handle to the namestore. More...
 
static struct GNUNET_CRYPTO_EcdsaPrivateKey zone_pkey
 Private key for the our zone. More...
 
static struct GNUNET_IDENTITY_EgoLookupel
 Handle to identity lookup. More...
 
static struct GNUNET_IDENTITY_Handleidh
 Identity service handle. More...
 
struct GNUNET_IDENTITY_Operationget_default
 Obtain default ego. More...
 
static char * ego_name
 Name of the ego controlling the zone. More...
 
static int add
 Desired action is to add a record. More...
 
static struct GNUNET_NAMESTORE_QueueEntryadd_qe_uri
 Queue entry for the 'add-uri' operation. More...
 
static struct GNUNET_NAMESTORE_QueueEntryadd_qe
 Queue entry for the 'add' operation. More...
 
static struct GNUNET_NAMESTORE_QueueEntryget_qe
 Queue entry for the 'lookup' operation. More...
 
static struct GNUNET_NAMESTORE_QueueEntryreverse_qe
 Queue entry for the 'reverse lookup' operation (in combination with a name). More...
 
static int list
 Desired action is to list records. More...
 
static struct GNUNET_NAMESTORE_ZoneIteratorlist_it
 List iterator for the 'list' operation. More...
 
static int del
 Desired action is to remove a record. More...
 
static int is_public
 Is record public (opposite of GNUNET_GNSRECORD_RF_PRIVATE) More...
 
static int is_shadow
 Is record a shadow record (GNUNET_GNSRECORD_RF_SHADOW_RECORD) More...
 
static struct GNUNET_NAMESTORE_QueueEntrydel_qe
 Queue entry for the 'del' operation. More...
 
static struct GNUNET_NAMESTORE_QueueEntryset_qe
 Queue entry for the 'set/replace' operation. More...
 
static char * name
 Name of the records to add/list/remove. More...
 
static char * value
 Value of the record to add/remove. More...
 
static char * uri
 URI to import. More...
 
static char * reverse_pkey
 Reverse lookup to perform. More...
 
static char * typestring
 Type of the record to add/remove, NULL to remove all. More...
 
static char * expirationstring
 Desired expiration time. More...
 
static char * nickstring
 Desired nick name. More...
 
static int ret
 Global return value. More...
 
static uint32_t type
 Type string converted to DNS type value. More...
 
static void * data
 Value in binary format. More...
 
static size_t data_size
 Number of bytes in data. More...
 
static uint64_t etime
 Expiration string converted to numeric value. More...
 
static int etime_is_rel = GNUNET_SYSERR
 Is expiration time relative or absolute time? More...
 
static struct GNUNET_NAMESTORE_ZoneMonitorzm
 Monitor handle. More...
 
static int monitor
 Enables monitor mode. More...
 
static struct RecordSetEntryrecordset
 Entry in record set for processing records in bulk. More...
 

Detailed Description

command line tool to manipulate the local zone

Author
Christian Grothoff

TODO:

Definition in file gnunet-namestore.c.

Function Documentation

◆ do_shutdown()

static void do_shutdown ( void *  cls)
static

Task run on shutdown.

Cleans up everything.

Parameters
clsunused

Definition at line 231 of file gnunet-namestore.c.

References data, GNUNET_free, GNUNET_IDENTITY_cancel(), GNUNET_IDENTITY_disconnect(), GNUNET_IDENTITY_ego_lookup_cancel(), GNUNET_NAMESTORE_cancel(), GNUNET_NAMESTORE_disconnect(), GNUNET_NAMESTORE_zone_iteration_stop(), GNUNET_NAMESTORE_zone_monitor_stop(), uri, and zone_pkey.

Referenced by run().

232 {
233  (void) cls;
234  if (NULL != get_default)
235  {
237  get_default = NULL;
238  }
239  if (NULL != idh)
240  {
242  idh = NULL;
243  }
244  if (NULL != el)
245  {
247  el = NULL;
248  }
249  if (NULL != list_it)
250  {
252  list_it = NULL;
253  }
254  if (NULL != add_qe)
255  {
257  add_qe = NULL;
258  }
259  if (NULL != set_qe)
260  {
262  set_qe = NULL;
263  }
264  if (NULL != add_qe_uri)
265  {
267  add_qe_uri = NULL;
268  }
269  if (NULL != get_qe)
270  {
272  get_qe = NULL;
273  }
274  if (NULL != del_qe)
275  {
277  del_qe = NULL;
278  }
279  if (NULL != ns)
280  {
282  ns = NULL;
283  }
284  memset (&zone_pkey, 0, sizeof (zone_pkey));
285  if (NULL != uri)
286  {
287  GNUNET_free (uri);
288  uri = NULL;
289  }
290  if (NULL != zm)
291  {
293  zm = NULL;
294  }
295  if (NULL != data)
296  {
297  GNUNET_free (data);
298  data = NULL;
299  }
300 }
void GNUNET_IDENTITY_cancel(struct GNUNET_IDENTITY_Operation *op)
Cancel an identity operation.
Definition: identity_api.c:819
void GNUNET_IDENTITY_ego_lookup_cancel(struct GNUNET_IDENTITY_EgoLookup *el)
Abort ego lookup attempt.
static struct GNUNET_NAMESTORE_QueueEntry * add_qe
Queue entry for the &#39;add&#39; operation.
static struct GNUNET_NAMESTORE_QueueEntry * add_qe_uri
Queue entry for the &#39;add-uri&#39; operation.
static struct GNUNET_IDENTITY_EgoLookup * el
Handle to identity lookup.
static void * data
Value in binary format.
void GNUNET_NAMESTORE_zone_monitor_stop(struct GNUNET_NAMESTORE_ZoneMonitor *zm)
Stop monitoring a zone for changes.
static struct GNUNET_NAMESTORE_ZoneMonitor * zm
Monitor handle.
void GNUNET_NAMESTORE_cancel(struct GNUNET_NAMESTORE_QueueEntry *qe)
Cancel a namestore operation.
static struct GNUNET_IDENTITY_Handle * idh
Identity service handle.
void GNUNET_NAMESTORE_disconnect(struct GNUNET_NAMESTORE_Handle *h)
Disconnect from the namestore service (and free associated resources).
static struct GNUNET_NAMESTORE_QueueEntry * set_qe
Queue entry for the &#39;set/replace&#39; operation.
void GNUNET_IDENTITY_disconnect(struct GNUNET_IDENTITY_Handle *h)
Disconnect from identity service.
Definition: identity_api.c:838
void GNUNET_NAMESTORE_zone_iteration_stop(struct GNUNET_NAMESTORE_ZoneIterator *it)
Stops iteration and releases the namestore handle for further calls.
static char * uri
URI to import.
struct GNUNET_IDENTITY_Operation * get_default
Obtain default ego.
static struct GNUNET_CRYPTO_EcdsaPrivateKey zone_pkey
Private key for the our zone.
static struct GNUNET_NAMESTORE_ZoneIterator * list_it
List iterator for the &#39;list&#39; operation.
static struct GNUNET_NAMESTORE_QueueEntry * get_qe
Queue entry for the &#39;lookup&#39; operation.
static struct GNUNET_NAMESTORE_QueueEntry * del_qe
Queue entry for the &#39;del&#39; operation.
static struct GNUNET_NAMESTORE_Handle * ns
Handle to the namestore.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_finished()

static void test_finished ( )
static

Check if we are finished, and if so, perform shutdown.

Definition at line 307 of file gnunet-namestore.c.

References GNUNET_SCHEDULER_shutdown().

Referenced by add_continuation(), add_error_cb(), del_continuation(), del_lookup_error_cb(), del_monitor(), display_record_lookup(), get_existing_record(), handle_reverse_lookup(), lookup_error_cb(), zone_iteration_error_cb(), and zone_iteration_finished().

308 {
309  if ((NULL == add_qe) && (NULL == add_qe_uri) && (NULL == get_qe) &&
310  (NULL == del_qe) && (NULL == reverse_qe) && (NULL == list_it))
312 }
static struct GNUNET_NAMESTORE_QueueEntry * add_qe
Queue entry for the &#39;add&#39; operation.
static struct GNUNET_NAMESTORE_QueueEntry * add_qe_uri
Queue entry for the &#39;add-uri&#39; operation.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:524
static struct GNUNET_NAMESTORE_QueueEntry * reverse_qe
Queue entry for the &#39;reverse lookup&#39; operation (in combination with a name).
static struct GNUNET_NAMESTORE_ZoneIterator * list_it
List iterator for the &#39;list&#39; operation.
static struct GNUNET_NAMESTORE_QueueEntry * get_qe
Queue entry for the &#39;lookup&#39; operation.
static struct GNUNET_NAMESTORE_QueueEntry * del_qe
Queue entry for the &#39;del&#39; operation.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_continuation()

static void add_continuation ( void *  cls,
int32_t  success,
const char *  emsg 
)
static

Continuation called to notify client about result of the operation.

Parameters
clsclosure, location of the QueueEntry pointer to NULL out
successGNUNET_SYSERR on failure (including timeout/queue drop/failure to validate) GNUNET_NO if content was already there GNUNET_YES (or other positive value) on success
emsgNULL on success, otherwise an error message

Definition at line 326 of file gnunet-namestore.c.

References _, GNUNET_NO, GNUNET_YES, qe, ret, and test_finished().

Referenced by get_existing_record(), and run_with_zone_pkey().

327 {
328  struct GNUNET_NAMESTORE_QueueEntry **qe = cls;
329 
330  *qe = NULL;
331  if (GNUNET_YES != success)
332  {
333  fprintf (stderr,
334  _ ("Adding record failed: %s\n"),
335  (GNUNET_NO == success) ? "record exists" : emsg);
336  if (GNUNET_NO != success)
337  ret = 1;
338  }
339  ret = 0;
340  test_finished ();
341 }
static struct GNUNET_DATASTORE_QueueEntry * qe
Current operation.
#define GNUNET_NO
Definition: gnunet_common.h:81
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
static int ret
Global return value.
An QueueEntry used to store information for a pending NAMESTORE record operation. ...
Definition: namestore_api.c:53
static void test_finished()
Check if we are finished, and if so, perform shutdown.
#define GNUNET_YES
Definition: gnunet_common.h:80
Here is the call graph for this function:
Here is the caller graph for this function:

◆ del_continuation()

static void del_continuation ( void *  cls,
int32_t  success,
const char *  emsg 
)
static

Continuation called to notify client about result of the operation.

Parameters
clsclosure, unused
successGNUNET_SYSERR on failure (including timeout/queue drop/failure to validate) GNUNET_NO if content was already there GNUNET_YES (or other positive value) on success
emsgNULL on success, otherwise an error message

Definition at line 355 of file gnunet-namestore.c.

References _, GNUNET_NO, GNUNET_SYSERR, and test_finished().

Referenced by del_monitor().

356 {
357  (void) cls;
358  del_qe = NULL;
359  if (GNUNET_NO == success)
360  {
361  fprintf (stderr,
362  _ ("Deleting record failed, record does not exist%s%s\n"),
363  (NULL != emsg) ? ": " : "",
364  (NULL != emsg) ? emsg : "");
365  }
366  if (GNUNET_SYSERR == success)
367  {
368  fprintf (stderr,
369  _ ("Deleting record failed%s%s\n"),
370  (NULL != emsg) ? ": " : "",
371  (NULL != emsg) ? emsg : "");
372  }
373  test_finished ();
374 }
#define GNUNET_NO
Definition: gnunet_common.h:81
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
static void test_finished()
Check if we are finished, and if so, perform shutdown.
static struct GNUNET_NAMESTORE_QueueEntry * del_qe
Queue entry for the &#39;del&#39; operation.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ zone_iteration_finished()

static void zone_iteration_finished ( void *  cls)
static

Function called when we are done with a zone iteration.

Definition at line 381 of file gnunet-namestore.c.

References test_finished().

Referenced by run_with_zone_pkey().

382 {
383  (void) cls;
384  list_it = NULL;
385  test_finished ();
386 }
static void test_finished()
Check if we are finished, and if so, perform shutdown.
static struct GNUNET_NAMESTORE_ZoneIterator * list_it
List iterator for the &#39;list&#39; operation.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ zone_iteration_error_cb()

static void zone_iteration_error_cb ( void *  cls)
static

Function called when we encountered an error in a zone iteration.

Definition at line 393 of file gnunet-namestore.c.

References ret, and test_finished().

Referenced by run_with_zone_pkey().

394 {
395  (void) cls;
396  list_it = NULL;
397  fprintf (stderr, "Error iterating over zone\n");
398  ret = 1;
399  test_finished ();
400 }
static int ret
Global return value.
static void test_finished()
Check if we are finished, and if so, perform shutdown.
static struct GNUNET_NAMESTORE_ZoneIterator * list_it
List iterator for the &#39;list&#39; operation.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ display_record()

static void display_record ( const char *  rname,
unsigned int  rd_len,
const struct GNUNET_GNSRECORD_Data rd 
)
static

Process a record that was stored in the namestore.

Parameters
rnamename that is being mapped (at most 255 characters long)
rd_lennumber of entries in rd array
rdarray of records with data to store

Definition at line 411 of file gnunet-namestore.c.

References _, GNUNET_TIME_Absolute::abs_value_us, data, data_size, GNUNET_GNSRECORD_Data::expiration_time, FPRINTF, GNUNET_free, GNUNET_GNS_EMPTY_LABEL_AT, GNUNET_GNSRECORD_number_to_typename(), GNUNET_GNSRECORD_RF_PRIVATE, GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION, GNUNET_GNSRECORD_RF_SHADOW_RECORD, GNUNET_GNSRECORD_TYPE_ANY, GNUNET_GNSRECORD_TYPE_NICK, GNUNET_GNSRECORD_typename_to_number(), GNUNET_GNSRECORD_value_to_string(), GNUNET_NAMESTORE_zone_iterator_next(), GNUNET_NO, GNUNET_STRINGS_absolute_time_to_string(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_YES, name, GNUNET_TIME_Relative::rel_value_us, type, and typestring.

Referenced by display_record_iterator(), display_record_lookup(), and display_record_monitor().

414 {
415  const char *typestr;
416  char *s;
417  const char *ets;
418  struct GNUNET_TIME_Absolute at;
419  struct GNUNET_TIME_Relative rt;
420  int have_record;
421 
422  if ((NULL != name) && (0 != strcmp (name, rname)))
423  {
425  return;
426  }
427  have_record = GNUNET_NO;
428  for (unsigned int i = 0; i < rd_len; i++)
429  {
430  if ((GNUNET_GNSRECORD_TYPE_NICK == rd[i].record_type) &&
431  (0 != strcmp (rname, GNUNET_GNS_EMPTY_LABEL_AT)))
432  continue;
433  if ((type != rd[i].record_type) && (GNUNET_GNSRECORD_TYPE_ANY != type))
434  continue;
435  have_record = GNUNET_YES;
436  break;
437  }
438  if (GNUNET_NO == have_record)
439  return;
440  FPRINTF (stdout, "%s:\n", rname);
441  if (NULL != typestring)
443  else
445  for (unsigned int i = 0; i < rd_len; i++)
446  {
447  if ((GNUNET_GNSRECORD_TYPE_NICK == rd[i].record_type) &&
448  (0 != strcmp (rname, GNUNET_GNS_EMPTY_LABEL_AT)))
449  continue;
450  if ((type != rd[i].record_type) && (GNUNET_GNSRECORD_TYPE_ANY != type))
451  continue;
452  typestr = GNUNET_GNSRECORD_number_to_typename (rd[i].record_type);
453  s = GNUNET_GNSRECORD_value_to_string (rd[i].record_type,
454  rd[i].data,
455  rd[i].data_size);
456  if (NULL == s)
457  {
458  FPRINTF (stdout,
459  _ ("\tCorrupt or unsupported record of type %u\n"),
460  (unsigned int) rd[i].record_type);
461  continue;
462  }
463  if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION))
464  {
465  rt.rel_value_us = rd[i].expiration_time;
467  }
468  else
469  {
470  at.abs_value_us = rd[i].expiration_time;
472  }
473  FPRINTF (stdout,
474  "\t%s: %s (%s)\t%s\t%s\n",
475  typestr,
476  s,
477  ets,
478  (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE)) ? "PRIVATE"
479  : "PUBLIC",
480  (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_SHADOW_RECORD)) ? "SHADOW"
481  : "");
482  GNUNET_free (s);
483  }
484  FPRINTF (stdout, "%s", "\n");
485 }
This record should not be used unless all (other) records with an absolute expiration time have expir...
#define GNUNET_GNS_EMPTY_LABEL_AT
String we use to indicate an empty label (top-level entry in the zone).
#define FPRINTF
Definition: plibc.h:683
uint32_t GNUNET_GNSRECORD_typename_to_number(const char *dns_typename)
Convert a type name (i.e.
Definition: gnsrecord.c:204
#define GNUNET_GNSRECORD_TYPE_ANY
Record type indicating any record/&#39;*&#39;.
static void * data
Value in binary format.
#define GNUNET_NO
Definition: gnunet_common.h:81
void GNUNET_NAMESTORE_zone_iterator_next(struct GNUNET_NAMESTORE_ZoneIterator *it, uint64_t limit)
Calls the record processor specified in GNUNET_NAMESTORE_zone_iteration_start for the next record...
static char * name
Name of the records to add/list/remove.
#define GNUNET_GNSRECORD_TYPE_NICK
Record type for GNS nick names ("NICK").
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
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:727
This is a private record of this peer and it should thus not be handed out to other peers...
static uint32_t type
Type string converted to DNS type value.
static struct GNUNET_NAMESTORE_ZoneIterator * list_it
List iterator for the &#39;list&#39; operation.
Time for absolute times used by GNUnet, in microseconds.
#define GNUNET_YES
Definition: gnunet_common.h:80
static char * typestring
Type of the record to add/remove, NULL to remove all.
This flag is currently unused; former RF_PENDING flag.
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
Definition: strings.c:792
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:143
static size_t data_size
Number of bytes in data.
const char * GNUNET_GNSRECORD_number_to_typename(uint32_t type)
Convert a type number (i.e.
Definition: gnsrecord.c:231
#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:

◆ display_record_iterator()

static void display_record_iterator ( void *  cls,
const struct GNUNET_CRYPTO_EcdsaPrivateKey zone_key,
const char *  rname,
unsigned int  rd_len,
const struct GNUNET_GNSRECORD_Data rd 
)
static

Process a record that was stored in the namestore.

Parameters
clsclosure
zone_keyprivate key of the zone
rnamename that is being mapped (at most 255 characters long)
rd_lennumber of entries in rd array
rdarray of records with data to store

Definition at line 498 of file gnunet-namestore.c.

References display_record(), and GNUNET_NAMESTORE_zone_iterator_next().

Referenced by run_with_zone_pkey().

503 {
504  (void) cls;
505  (void) zone_key;
506  display_record (rname, rd_len, rd);
508 }
void GNUNET_NAMESTORE_zone_iterator_next(struct GNUNET_NAMESTORE_ZoneIterator *it, uint64_t limit)
Calls the record processor specified in GNUNET_NAMESTORE_zone_iteration_start for the next record...
static struct GNUNET_NAMESTORE_ZoneIterator * list_it
List iterator for the &#39;list&#39; operation.
static void display_record(const char *rname, unsigned int rd_len, const struct GNUNET_GNSRECORD_Data *rd)
Process a record that was stored in the namestore.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ display_record_monitor()

static void display_record_monitor ( void *  cls,
const struct GNUNET_CRYPTO_EcdsaPrivateKey zone_key,
const char *  rname,
unsigned int  rd_len,
const struct GNUNET_GNSRECORD_Data rd 
)
static

Process a record that was stored in the namestore.

Parameters
clsclosure
zone_keyprivate key of the zone
rnamename that is being mapped (at most 255 characters long)
rd_lennumber of entries in rd array
rdarray of records with data to store

Definition at line 521 of file gnunet-namestore.c.

References display_record(), and GNUNET_NAMESTORE_zone_monitor_next().

Referenced by run_with_zone_pkey().

526 {
527  (void) cls;
528  (void) zone_key;
529  display_record (rname, rd_len, rd);
531 }
static struct GNUNET_NAMESTORE_ZoneMonitor * zm
Monitor handle.
static void display_record(const char *rname, unsigned int rd_len, const struct GNUNET_GNSRECORD_Data *rd)
Process a record that was stored in the namestore.
void GNUNET_NAMESTORE_zone_monitor_next(struct GNUNET_NAMESTORE_ZoneMonitor *zm, uint64_t limit)
Calls the monitor processor specified in GNUNET_NAMESTORE_zone_monitor_start for the next record(s)...
Here is the call graph for this function:
Here is the caller graph for this function:

◆ display_record_lookup()

static void display_record_lookup ( void *  cls,
const struct GNUNET_CRYPTO_EcdsaPrivateKey zone_key,
const char *  rname,
unsigned int  rd_len,
const struct GNUNET_GNSRECORD_Data rd 
)
static

Process a record that was stored in the namestore.

Parameters
clsclosure
zone_keyprivate key of the zone
rnamename that is being mapped (at most 255 characters long)
rd_lennumber of entries in rd array
rdarray of records with data to store

Definition at line 544 of file gnunet-namestore.c.

References display_record(), and test_finished().

Referenced by run_with_zone_pkey().

549 {
550  (void) cls;
551  (void) zone_key;
552  get_qe = NULL;
553  display_record (rname, rd_len, rd);
554  test_finished ();
555 }
static void test_finished()
Check if we are finished, and if so, perform shutdown.
static struct GNUNET_NAMESTORE_QueueEntry * get_qe
Queue entry for the &#39;lookup&#39; operation.
static void display_record(const char *rname, unsigned int rd_len, const struct GNUNET_GNSRECORD_Data *rd)
Process a record that was stored in the namestore.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sync_cb()

static void sync_cb ( void *  cls)
static

Function called once we are in sync in monitor mode.

Parameters
clsNULL

Definition at line 564 of file gnunet-namestore.c.

References FPRINTF.

Referenced by run_with_zone_pkey().

565 {
566  (void) cls;
567  FPRINTF (stdout, "%s", "Monitor is now in sync.\n");
568 }
#define FPRINTF
Definition: plibc.h:683
Here is the caller graph for this function:

◆ monitor_error_cb()

static void monitor_error_cb ( void *  cls)
static

Function called on errors while monitoring.

Parameters
clsNULL

Definition at line 577 of file gnunet-namestore.c.

References FPRINTF.

Referenced by run_with_zone_pkey().

578 {
579  (void) cls;
580  FPRINTF (stderr, "%s", "Monitor disconnected and out of sync.\n");
581 }
#define FPRINTF
Definition: plibc.h:683
Here is the caller graph for this function:

◆ lookup_error_cb()

static void lookup_error_cb ( void *  cls)
static

Function called on errors while monitoring.

Parameters
clsNULL

Definition at line 590 of file gnunet-namestore.c.

References FPRINTF, and test_finished().

Referenced by run_with_zone_pkey().

591 {
592  (void) cls;
593  get_qe = NULL;
594  FPRINTF (stderr, "%s", "Failed to lookup record.\n");
595  test_finished ();
596 }
#define FPRINTF
Definition: plibc.h:683
static void test_finished()
Check if we are finished, and if so, perform shutdown.
static struct GNUNET_NAMESTORE_QueueEntry * get_qe
Queue entry for the &#39;lookup&#39; operation.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_error_cb()

static void add_error_cb ( void *  cls)
static

Function called if lookup fails.

Definition at line 603 of file gnunet-namestore.c.

References GNUNET_break, ret, and test_finished().

Referenced by run_with_zone_pkey().

604 {
605  (void) cls;
606  add_qe = NULL;
607  GNUNET_break (0);
608  ret = 1;
609  test_finished ();
610 }
static struct GNUNET_NAMESTORE_QueueEntry * add_qe
Queue entry for the &#39;add&#39; operation.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static int ret
Global return value.
static void test_finished()
Check if we are finished, and if so, perform shutdown.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_existing_record()

static void get_existing_record ( void *  cls,
const struct GNUNET_CRYPTO_EcdsaPrivateKey zone_key,
const char *  rec_name,
unsigned int  rd_count,
const struct GNUNET_GNSRECORD_Data rd 
)
static

We're storing a record; this function is given the existing record so that we can merge the information.

Parameters
clsclosure, unused
zone_keyprivate key of the zone
rec_namename that is being mapped (at most 255 characters long)
rd_countnumber of entries in rd array
rdarray of records with data to store

Definition at line 624 of file gnunet-namestore.c.

References _, add_continuation(), data, GNUNET_GNSRECORD_Data::data, data_size, GNUNET_GNSRECORD_Data::data_size, etime, etime_is_rel, GNUNET_GNSRECORD_Data::expiration_time, GNUNET_GNSRECORD_Data::flags, GNUNET_assert, GNUNET_break, GNUNET_DNSPARSER_TYPE_CNAME, GNUNET_DNSPARSER_TYPE_SOA, GNUNET_ERROR_TYPE_DEBUG, GNUNET_GNSRECORD_RF_PRIVATE, GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION, GNUNET_GNSRECORD_RF_SHADOW_RECORD, GNUNET_GNSRECORD_TYPE_GNS2DNS, GNUNET_GNSRECORD_TYPE_PKEY, GNUNET_log, GNUNET_memcpy, GNUNET_NAMESTORE_records_store(), GNUNET_NO, GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_YES, is_public, is_shadow, name, GNUNET_GNSRECORD_Data::record_type, ret, test_finished(), type, and zone_pkey.

Referenced by run_with_zone_pkey().

629 {
630  struct GNUNET_GNSRECORD_Data rdn[rd_count + 1];
631  struct GNUNET_GNSRECORD_Data *rde;
632 
633  (void) cls;
634  (void) zone_key;
635  add_qe = NULL;
636  if (0 != strcmp (rec_name, name))
637  {
638  GNUNET_break (0);
639  ret = 1;
640  test_finished ();
641  return;
642  }
643 
645  "Received %u records for name `%s'\n",
646  rd_count,
647  rec_name);
648  for (unsigned int i = 0; i < rd_count; i++)
649  {
650  switch (rd[i].record_type)
651  {
653  fprintf (
654  stderr,
655  _ (
656  "A %s record exists already under `%s', no other records can be added.\n"),
657  "CNAME",
658  rec_name);
659  ret = 1;
660  test_finished ();
661  return;
663  fprintf (
664  stderr,
665  _ (
666  "A %s record exists already under `%s', no other records can be added.\n"),
667  "PKEY",
668  rec_name);
669  ret = 1;
670  test_finished ();
671  return;
674  {
675  fprintf (
676  stderr,
677  _ (
678  "A SOA record exists already under `%s', cannot add a second SOA to the same zone.\n"),
679  rec_name);
680  ret = 1;
681  test_finished ();
682  return;
683  }
684  break;
685  }
686  }
687  switch (type)
688  {
690  if (0 != rd_count)
691  {
692  fprintf (stderr,
693  _ (
694  "Records already exist under `%s', cannot add `%s' record.\n"),
695  rec_name,
696  "CNAME");
697  ret = 1;
698  test_finished ();
699  return;
700  }
701  break;
703  if (0 != rd_count)
704  {
705  fprintf (stderr,
706  _ (
707  "Records already exist under `%s', cannot add `%s' record.\n"),
708  rec_name,
709  "PKEY");
710  ret = 1;
711  test_finished ();
712  return;
713  }
714  break;
716  for (unsigned int i = 0; i < rd_count; i++)
717  if (GNUNET_GNSRECORD_TYPE_GNS2DNS != rd[i].record_type)
718  {
719  fprintf (
720  stderr,
721  _ (
722  "Non-GNS2DNS records already exist under `%s', cannot add GNS2DNS record.\n"),
723  rec_name);
724  ret = 1;
725  test_finished ();
726  return;
727  }
728  break;
729  }
730  memset (rdn, 0, sizeof (struct GNUNET_GNSRECORD_Data));
731  GNUNET_memcpy (&rdn[1], rd, rd_count * sizeof (struct GNUNET_GNSRECORD_Data));
732  rde = &rdn[0];
733  rde->data = data;
734  rde->data_size = data_size;
735  rde->record_type = type;
736  if (1 == is_shadow)
738  if (1 != is_public)
740  rde->expiration_time = etime;
741  if (GNUNET_YES == etime_is_rel)
743  else if (GNUNET_NO != etime_is_rel)
744  rde->expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
745  GNUNET_assert (NULL != name);
747  &zone_pkey,
748  name,
749  rd_count + 1,
750  rde,
752  &add_qe);
753 }
This record should not be used unless all (other) records with an absolute expiration time have expir...
static struct GNUNET_NAMESTORE_QueueEntry * add_qe
Queue entry for the &#39;add&#39; operation.
#define GNUNET_DNSPARSER_TYPE_CNAME
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static void * data
Value in binary format.
#define GNUNET_NO
Definition: gnunet_common.h:81
size_t data_size
Number of bytes in data.
static char * name
Name of the records to add/list/remove.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static int etime_is_rel
Is expiration time relative or absolute time?
#define GNUNET_TIME_UNIT_FOREVER_ABS
Constant used to specify "forever".
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_store(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls)
Store an item in the namestore.
static void add_continuation(void *cls, int32_t success, const char *emsg)
Continuation called to notify client about result of the operation.
static int is_shadow
Is record a shadow record (GNUNET_GNSRECORD_RF_SHADOW_RECORD)
#define GNUNET_DNSPARSER_TYPE_SOA
#define GNUNET_memcpy(dst, src, n)
const void * data
Binary value stored in the DNS record.
#define GNUNET_GNSRECORD_TYPE_PKEY
Record type for GNS zone transfer ("PKEY").
uint64_t expiration_time
Expiration time for the DNS record.
static int ret
Global return value.
#define GNUNET_GNSRECORD_TYPE_GNS2DNS
Record type for delegation to DNS.
This is a private record of this peer and it should thus not be handed out to other peers...
static uint64_t etime
Expiration string converted to numeric value.
static void test_finished()
Check if we are finished, and if so, perform shutdown.
static int is_public
Is record public (opposite of GNUNET_GNSRECORD_RF_PRIVATE)
static uint32_t type
Type string converted to DNS type value.
uint32_t record_type
Type of the GNS/DNS record.
static struct GNUNET_CRYPTO_EcdsaPrivateKey zone_pkey
Private key for the our zone.
#define GNUNET_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:80
enum GNUNET_GNSRECORD_Flags flags
Flags for the record.
This flag is currently unused; former RF_PENDING flag.
static size_t data_size
Number of bytes in data.
static struct GNUNET_NAMESTORE_Handle * ns
Handle to the namestore.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ reverse_error_cb()

static void reverse_error_cb ( void *  cls)
static

Function called if we encountered an error in zone-to-name.

Definition at line 760 of file gnunet-namestore.c.

References FPRINTF, and reverse_pkey.

Referenced by run_with_zone_pkey().

761 {
762  (void) cls;
763  reverse_qe = NULL;
764  FPRINTF (stdout, "%s.zkey\n", reverse_pkey);
765 }
#define FPRINTF
Definition: plibc.h:683
static struct GNUNET_NAMESTORE_QueueEntry * reverse_qe
Queue entry for the &#39;reverse lookup&#39; operation (in combination with a name).
static char * reverse_pkey
Reverse lookup to perform.
Here is the caller graph for this function:

◆ handle_reverse_lookup()

static void handle_reverse_lookup ( void *  cls,
const struct GNUNET_CRYPTO_EcdsaPrivateKey zone,
const char *  label,
unsigned int  rd_count,
const struct GNUNET_GNSRECORD_Data rd 
)
static

Function called with the result of our attempt to obtain a name for a given public key.

Parameters
clsNULL
zoneprivate key of the zone; NULL on disconnect
labellabel of the records; NULL on disconnect
rd_countnumber of entries in rd array, 0 if label was deleted
rdarray of records with data to store

Definition at line 779 of file gnunet-namestore.c.

References ego_name, FPRINTF, reverse_pkey, and test_finished().

Referenced by run_with_zone_pkey().

784 {
785  (void) cls;
786  (void) zone;
787  (void) rd_count;
788  (void) rd;
789  reverse_qe = NULL;
790  if (NULL == label)
791  FPRINTF (stdout, "%s\n", reverse_pkey);
792  else
793  FPRINTF (stdout, "%s.%s\n", label, ego_name);
794  test_finished ();
795 }
#define FPRINTF
Definition: plibc.h:683
static struct GNUNET_NAMESTORE_QueueEntry * reverse_qe
Queue entry for the &#39;reverse lookup&#39; operation (in combination with a name).
static char * reverse_pkey
Reverse lookup to perform.
static void test_finished()
Check if we are finished, and if so, perform shutdown.
static char * ego_name
Name of the ego controlling the zone.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ del_lookup_error_cb()

static void del_lookup_error_cb ( void *  cls)
static

Function called if lookup for deletion fails.

Definition at line 802 of file gnunet-namestore.c.

References GNUNET_break, ret, and test_finished().

Referenced by run_with_zone_pkey().

803 {
804  (void) cls;
805  del_qe = NULL;
806  GNUNET_break (0);
807  ret = 1;
808  test_finished ();
809 }
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static int ret
Global return value.
static void test_finished()
Check if we are finished, and if so, perform shutdown.
static struct GNUNET_NAMESTORE_QueueEntry * del_qe
Queue entry for the &#39;del&#39; operation.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ del_monitor()

static void del_monitor ( void *  cls,
const struct GNUNET_CRYPTO_EcdsaPrivateKey zone,
const char *  label,
unsigned int  rd_count,
const struct GNUNET_GNSRECORD_Data rd 
)
static

We were asked to delete something; this function is called with the existing records.

Now we should determine what should be deleted and then issue the deletion operation.

Parameters
clsNULL
zoneprivate key of the zone we are deleting from
labelname of the records we are editing
rd_countsize of the rd array
rdexisting records

Definition at line 824 of file gnunet-namestore.c.

References _, data, data_size, del_continuation(), FPRINTF, GNUNET_free_non_null, GNUNET_GNSRECORD_TYPE_ANY, GNUNET_GNSRECORD_typename_to_number(), GNUNET_GNSRECORD_value_to_string(), GNUNET_NAMESTORE_records_store(), name, GNUNET_GNSRECORD_Data::record_type, ret, test_finished(), type, typestring, value, and zone_pkey.

Referenced by run_with_zone_pkey().

829 {
830  struct GNUNET_GNSRECORD_Data rdx[rd_count];
831  unsigned int rd_left;
832  uint32_t type;
833  char *vs;
834 
835  (void) cls;
836  (void) zone;
837  del_qe = NULL;
838  if (0 == rd_count)
839  {
840  FPRINTF (stderr,
841  _ (
842  "There are no records under label `%s' that could be deleted.\n"),
843  label);
844  ret = 1;
845  test_finished ();
846  return;
847  }
848  if ((NULL == value) && (NULL == typestring))
849  {
850  /* delete everything */
852  &zone_pkey,
853  name,
854  0,
855  NULL,
857  NULL);
858  return;
859  }
860  rd_left = 0;
861  if (NULL != typestring)
863  else
865  for (unsigned int i = 0; i < rd_count; i++)
866  {
867  vs = NULL;
868  if (! (((GNUNET_GNSRECORD_TYPE_ANY == type) ||
869  (rd[i].record_type == type)) &&
870  ((NULL == value) ||
871  (NULL ==
873  rd[i].data,
874  rd[i].data_size)))) ||
875  (0 == strcmp (vs, value)))))
876  rdx[rd_left++] = rd[i];
878  }
879  if (rd_count == rd_left)
880  {
881  /* nothing got deleted */
882  FPRINTF (
883  stderr,
884  _ (
885  "There are no records under label `%s' that match the request for deletion.\n"),
886  label);
887  test_finished ();
888  return;
889  }
890  /* delete everything but what we copied to 'rdx' */
892  &zone_pkey,
893  name,
894  rd_left,
895  rdx,
897  NULL);
898 }
#define FPRINTF
Definition: plibc.h:683
uint32_t GNUNET_GNSRECORD_typename_to_number(const char *dns_typename)
Convert a type name (i.e.
Definition: gnsrecord.c:204
#define GNUNET_GNSRECORD_TYPE_ANY
Record type indicating any record/&#39;*&#39;.
static void * data
Value in binary format.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
static char * name
Name of the records to add/list/remove.
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_store(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls)
Store an item in the namestore.
static char * value
Value of the record to add/remove.
static int ret
Global return value.
static void del_continuation(void *cls, int32_t success, const char *emsg)
Continuation called to notify client about result of the operation.
static void test_finished()
Check if we are finished, and if so, perform shutdown.
static uint32_t type
Type string converted to DNS type value.
uint32_t record_type
Type of the GNS/DNS record.
static struct GNUNET_CRYPTO_EcdsaPrivateKey zone_pkey
Private key for the our zone.
static struct GNUNET_NAMESTORE_QueueEntry * del_qe
Queue entry for the &#39;del&#39; operation.
static char * typestring
Type of the record to add/remove, NULL to remove all.
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:143
static size_t data_size
Number of bytes in data.
static struct GNUNET_NAMESTORE_Handle * ns
Handle to the namestore.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_expiration()

static int parse_expiration ( const char *  expirationstring,
int *  etime_is_rel,
uint64_t *  etime 
)
static

Parse expiration time.

Parameters
expirationstringtext to parse
etime_is_rel[out]set to GNUNET_YES if time is relative
etime[out]set to expiration time (abs or rel)
Returns
GNUNET_OK on success

Definition at line 910 of file gnunet-namestore.c.

References GNUNET_TIME_Absolute::abs_value_us, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_STRINGS_absolute_time_to_string(), GNUNET_STRINGS_fancy_time_to_absolute(), GNUNET_STRINGS_fancy_time_to_relative(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_SYSERR, GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_YES, and GNUNET_TIME_Relative::rel_value_us.

Referenced by multirecord_process(), and run_with_zone_pkey().

913 {
914  struct GNUNET_TIME_Relative etime_rel;
915  struct GNUNET_TIME_Absolute etime_abs;
916 
917  if (0 == strcmp (expirationstring, "never"))
918  {
919  *etime = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
921  return GNUNET_OK;
922  }
923  if (GNUNET_OK ==
925  {
927  *etime = etime_rel.rel_value_us;
929  "Storing record with relative expiration time of %s\n",
931  return GNUNET_OK;
932  }
933  if (GNUNET_OK ==
935  {
937  *etime = etime_abs.abs_value_us;
939  "Storing record with absolute expiration time of %s\n",
941  return GNUNET_OK;
942  }
943  return GNUNET_SYSERR;
944 }
int GNUNET_STRINGS_fancy_time_to_relative(const char *fancy_time, struct GNUNET_TIME_Relative *rtime)
Convert a given fancy human-readable time to our internal representation.
Definition: strings.c:353
int GNUNET_STRINGS_fancy_time_to_absolute(const char *fancy_time, struct GNUNET_TIME_Absolute *atime)
Convert a given fancy human-readable time to our internal representation.
Definition: strings.c:408
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
static int etime_is_rel
Is expiration time relative or absolute time?
#define GNUNET_TIME_UNIT_FOREVER_ABS
Constant used to specify "forever".
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:727
static uint64_t etime
Expiration string converted to numeric value.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
static char * expirationstring
Desired expiration time.
#define GNUNET_log(kind,...)
Time for absolute times used by GNUnet, in microseconds.
#define GNUNET_YES
Definition: gnunet_common.h:80
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
Definition: strings.c:792
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:

◆ replace_cont()

static void replace_cont ( void *  cls,
int  success,
const char *  emsg 
)
static

Function called when namestore is done with the replace operation.

Parameters
clsNULL
successGNUNET_SYSERR on failure (including timeout/queue drop/failure to validate) GNUNET_NO if content was already there or not found GNUNET_YES (or other positive value) on success
emsgNULL on success, otherwise an error message

Definition at line 958 of file gnunet-namestore.c.

References _, GNUNET_ERROR_TYPE_MESSAGE, GNUNET_log, GNUNET_OK, GNUNET_SCHEDULER_shutdown(), and ret.

Referenced by run_with_zone_pkey().

959 {
960  (void) cls;
961 
962  set_qe = NULL;
963  if (GNUNET_OK != success)
964  {
966  _ ("Failed to replace records: %s\n"),
967  emsg);
968  ret = 1; /* fail from 'main' */
969  }
971 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:524
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
static int ret
Global return value.
static struct GNUNET_NAMESTORE_QueueEntry * set_qe
Queue entry for the &#39;set/replace&#39; operation.
#define GNUNET_log(kind,...)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ run_with_zone_pkey()

static void run_with_zone_pkey ( const struct GNUNET_CONFIGURATION_Handle cfg)
static

We have obtained the zone's private key, so now process the main commands using it.

Parameters
cfgconfiguration to use

Definition at line 981 of file gnunet-namestore.c.

References _, add, add_continuation(), add_error_cb(), data, GNUNET_GNSRECORD_Data::data, data_size, GNUNET_GNSRECORD_Data::data_size, del, del_lookup_error_cb(), del_monitor(), display_record_iterator(), display_record_lookup(), display_record_monitor(), e, etime, etime_is_rel, GNUNET_GNSRECORD_Data::expiration_time, expirationstring, GNUNET_GNSRECORD_Data::flags, get_existing_record(), GNUNET_CRYPTO_ecdsa_public_key_from_string(), GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION, GNUNET_GNSRECORD_RF_SHADOW_RECORD, GNUNET_GNSRECORD_string_to_value(), GNUNET_GNSRECORD_TYPE_PKEY, GNUNET_GNSRECORD_typename_to_number(), GNUNET_log, GNUNET_NAMESTORE_connect(), GNUNET_NAMESTORE_records_lookup(), GNUNET_NAMESTORE_records_store(), GNUNET_NAMESTORE_set_nick(), GNUNET_NAMESTORE_zone_iteration_start(), GNUNET_NAMESTORE_zone_monitor_start(), GNUNET_NAMESTORE_zone_to_name(), GNUNET_new_array, GNUNET_OK, GNUNET_SCHEDULER_shutdown(), GNUNET_STRINGS_utf8_tolower(), GNUNET_YES, handle_reverse_lookup(), is_shadow, list, lookup_error_cb(), monitor, monitor_error_cb(), name, nickstring, parse_expiration(), pkey, GNUNET_GNSRECORD_Data::record_type, replace_cont(), ret, reverse_error_cb(), reverse_pkey, sh, sync_cb(), type, typestring, uri, value, zone_iteration_error_cb(), zone_iteration_finished(), and zone_pkey.

Referenced by identity_cb(), and run().

982 {
983  struct GNUNET_GNSRECORD_Data rd;
984 
985  if (! (add | del | list | (NULL != nickstring) | (NULL != uri) |
986  (NULL != reverse_pkey) | (NULL != recordset)))
987  {
988  /* nothing more to be done */
989  fprintf (stderr, _ ("No options given\n"));
991  return;
992  }
994  if (NULL == ns)
995  {
997  _ ("Failed to connect to namestore\n"));
998  return;
999  }
1000 
1001  if (NULL != recordset)
1002  {
1003  /* replace entire record set */
1004  unsigned int rd_count;
1005  struct GNUNET_GNSRECORD_Data *rd;
1006 
1007  if (NULL == name)
1008  {
1009  fprintf (stderr,
1010  _ ("Missing option `%s' for operation `%s'\n"),
1011  "-R",
1012  _ ("replace"));
1014  ret = 1;
1015  return;
1016  }
1017  rd_count = 0;
1018  for (struct RecordSetEntry *e = recordset; NULL != e; e = e->next)
1019  rd_count++;
1020  rd = GNUNET_new_array (rd_count, struct GNUNET_GNSRECORD_Data);
1021  rd_count = 0;
1022  for (struct RecordSetEntry *e = recordset; NULL != e; e = e->next)
1023  {
1024  rd[rd_count] = e->record;
1025  rd_count++;
1026  }
1028  &zone_pkey,
1029  name,
1030  rd_count,
1031  rd,
1032  &replace_cont,
1033  NULL);
1034  GNUNET_free (rd);
1035  return;
1036  }
1037 
1038  if (add)
1039  {
1040  if (NULL == name)
1041  {
1042  fprintf (stderr,
1043  _ ("Missing option `%s' for operation `%s'\n"),
1044  "-n",
1045  _ ("add"));
1047  ret = 1;
1048  return;
1049  }
1050  if (NULL == typestring)
1051  {
1052  fprintf (stderr,
1053  _ ("Missing option `%s' for operation `%s'\n"),
1054  "-t",
1055  _ ("add"));
1057  ret = 1;
1058  return;
1059  }
1061  if (UINT32_MAX == type)
1062  {
1063  fprintf (stderr, _ ("Unsupported type `%s'\n"), typestring);
1065  ret = 1;
1066  return;
1067  }
1068  if (NULL == value)
1069  {
1070  fprintf (stderr,
1071  _ ("Missing option `%s' for operation `%s'\n"),
1072  "-V",
1073  _ ("add"));
1074  ret = 1;
1076  return;
1077  }
1078  if (GNUNET_OK !=
1080  {
1081  fprintf (stderr,
1082  _ ("Value `%s' invalid for record type `%s'\n"),
1083  value,
1084  typestring);
1086  ret = 1;
1087  return;
1088  }
1089  if (NULL == expirationstring)
1090  {
1091  fprintf (stderr,
1092  _ ("Missing option `%s' for operation `%s'\n"),
1093  "-e",
1094  _ ("add"));
1096  ret = 1;
1097  return;
1098  }
1100  {
1101  fprintf (stderr, _ ("Invalid time format `%s'\n"), expirationstring);
1103  ret = 1;
1104  return;
1105  }
1107  &zone_pkey,
1108  name,
1109  &add_error_cb,
1110  NULL,
1112  NULL);
1113  }
1114  if (del)
1115  {
1116  if (NULL == name)
1117  {
1118  fprintf (stderr,
1119  _ ("Missing option `%s' for operation `%s'\n"),
1120  "-n",
1121  _ ("del"));
1123  ret = 1;
1124  return;
1125  }
1127  &zone_pkey,
1128  name,
1130  NULL,
1131  &del_monitor,
1132  NULL);
1133  }
1134  if (list)
1135  {
1136  if (NULL != name)
1138  &zone_pkey,
1139  name,
1140  &lookup_error_cb,
1141  NULL,
1143  NULL);
1144  else
1146  &zone_pkey,
1148  NULL,
1150  NULL,
1152  NULL);
1153  }
1154  if (NULL != reverse_pkey)
1155  {
1157 
1158  if (GNUNET_OK !=
1160  strlen (reverse_pkey),
1161  &pubkey))
1162  {
1163  fprintf (stderr,
1164  _ ("Invalid public key for reverse lookup `%s'\n"),
1165  reverse_pkey);
1167  }
1169  &zone_pkey,
1170  &pubkey,
1172  NULL,
1174  NULL);
1175  }
1176  if (NULL != uri)
1177  {
1178  char sh[105];
1179  char sname[64];
1181 
1183  if ((2 != (sscanf (uri, "gnunet://gns/%52s/%63s", sh, sname))) ||
1184  (GNUNET_OK !=
1185  GNUNET_CRYPTO_ecdsa_public_key_from_string (sh, strlen (sh), &pkey)))
1186  {
1187  fprintf (stderr, _ ("Invalid URI `%s'\n"), uri);
1189  ret = 1;
1190  return;
1191  }
1192  memset (&rd, 0, sizeof (rd));
1193  rd.data = &pkey;
1194  rd.data_size = sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey);
1196  rd.expiration_time = etime;
1197  if (GNUNET_YES == etime_is_rel)
1199  if (1 == is_shadow)
1202  &zone_pkey,
1203  sname,
1204  1,
1205  &rd,
1207  &add_qe_uri);
1208  }
1209  if (NULL != nickstring)
1210  {
1211  if (0 == strlen (nickstring))
1212  {
1213  fprintf (stderr, _ ("Invalid nick `%s'\n"), nickstring);
1215  ret = 1;
1216  return;
1217  }
1219  &zone_pkey,
1220  nickstring,
1222  &add_qe_uri);
1223  }
1224  if (monitor)
1225  {
1227  &zone_pkey,
1228  GNUNET_YES,
1230  NULL,
1232  NULL,
1233  &sync_cb,
1234  NULL);
1235  }
1236 }
static void add_error_cb(void *cls)
Function called if lookup fails.
This record should not be used unless all (other) records with an absolute expiration time have expir...
static struct GNUNET_CRYPTO_EcdsaPublicKey pubkey
Public key of the zone to look in.
static struct GNUNET_NAMESTORE_QueueEntry * add_qe
Queue entry for the &#39;add&#39; operation.
static void lookup_error_cb(void *cls)
Function called on errors while monitoring.
static char * pkey
Public key of the zone to look in, in ASCII.
static int parse_expiration(const char *expirationstring, int *etime_is_rel, uint64_t *etime)
Parse expiration time.
static struct GNUNET_NAMESTORE_QueueEntry * add_qe_uri
Queue entry for the &#39;add-uri&#39; operation.
struct GNUNET_NAMESTORE_ZoneMonitor * GNUNET_NAMESTORE_zone_monitor_start(const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, int iterate_first, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor monitor, void *monitor_cls, GNUNET_SCHEDULER_TaskCallback sync_cb, void *sync_cb_cls)
Begin monitoring a zone for changes.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_lookup(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const char *label, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor rm, void *rm_cls)
Lookup an item in the namestore.
static void sync_cb(void *cls)
Function called once we are in sync in monitor mode.
struct GNUNET_NAMESTORE_ZoneIterator * GNUNET_NAMESTORE_zone_iteration_start(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor proc, void *proc_cls, GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls)
Starts a new zone iteration (used to periodically PUT all of our records into our DHT)...
uint32_t GNUNET_GNSRECORD_typename_to_number(const char *dns_typename)
Convert a type name (i.e.
Definition: gnsrecord.c:204
static void handle_reverse_lookup(void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Function called with the result of our attempt to obtain a name for a given public key...
static void * data
Value in binary format.
static struct Experiment * e
static struct GNUNET_NAMESTORE_ZoneMonitor * zm
Monitor handle.
static void get_existing_record(void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, const char *rec_name, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
We&#39;re storing a record; this function is given the existing record so that we can merge the informati...
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
size_t data_size
Number of bytes in data.
static char * name
Name of the records to add/list/remove.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:524
static void zone_iteration_finished(void *cls)
Function called when we are done with a zone iteration.
static struct RecordSetEntry * recordset
Entry in record set for processing records in bulk.
static void zone_iteration_error_cb(void *cls)
Function called when we encountered an error in a zone iteration.
static int etime_is_rel
Is expiration time relative or absolute time?
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_store(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls)
Store an item in the namestore.
static void add_continuation(void *cls, int32_t success, const char *emsg)
Continuation called to notify client about result of the operation.
static void replace_cont(void *cls, int success, const char *emsg)
Function called when namestore is done with the replace operation.
static int is_shadow
Is record a shadow record (GNUNET_GNSRECORD_RF_SHADOW_RECORD)
const void * data
Binary value stored in the DNS record.
static char * value
Value of the record to add/remove.
static int monitor
Enables monitor mode.
static int del
Desired action is to remove a record.
#define GNUNET_GNSRECORD_TYPE_PKEY
Record type for GNS zone transfer ("PKEY").
uint64_t expiration_time
Expiration time for the DNS record.
static int ret
Global return value.
static struct SolverHandle * sh
static struct GNUNET_NAMESTORE_QueueEntry * set_qe
Queue entry for the &#39;set/replace&#39; operation.
static void display_record_lookup(void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, const char *rname, unsigned int rd_len, const struct GNUNET_GNSRECORD_Data *rd)
Process a record that was stored in the namestore.
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
static void del_monitor(void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
We were asked to delete something; this function is called with the existing records.
int GNUNET_GNSRECORD_string_to_value(uint32_t type, const char *s, void **data, size_t *data_size)
Convert human-readable version of a &#39;value&#39; of a record to the binary representation.
Definition: gnsrecord.c:175
static struct GNUNET_NAMESTORE_QueueEntry * reverse_qe
Queue entry for the &#39;reverse lookup&#39; operation (in combination with a name).
static uint64_t etime
Expiration string converted to numeric value.
static char * reverse_pkey
Reverse lookup to perform.
static char * expirationstring
Desired expiration time.
struct GNUNET_NAMESTORE_Handle * GNUNET_NAMESTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the namestore service.
static char * uri
URI to import.
static int add
Desired action is to add a record.
static int list
Desired action is to list records.
static void display_record_iterator(void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, const char *rname, unsigned int rd_len, const struct GNUNET_GNSRECORD_Data *rd)
Process a record that was stored in the namestore.
Entry in record set for bulk processing.
static void display_record_monitor(void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, const char *rname, unsigned int rd_len, const struct GNUNET_GNSRECORD_Data *rd)
Process a record that was stored in the namestore.
int GNUNET_CRYPTO_ecdsa_public_key_from_string(const char *enc, size_t enclen, struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Convert a string representing a public key to a public key.
Definition: crypto_ecc.c:468
static uint32_t type
Type string converted to DNS type value.
uint32_t record_type
Type of the GNS/DNS record.
static void del_lookup_error_cb(void *cls)
Function called if lookup for deletion fails.
static char * nickstring
Desired nick name.
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
static struct GNUNET_CRYPTO_EcdsaPrivateKey zone_pkey
Private key for the our zone.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_zone_to_name(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const struct GNUNET_CRYPTO_EcdsaPublicKey *value_zone, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor proc, void *proc_cls)
Look for an existing PKEY delegation record for a given public key.
#define GNUNET_log(kind,...)
static struct GNUNET_NAMESTORE_ZoneIterator * list_it
List iterator for the &#39;list&#39; operation.
static void monitor_error_cb(void *cls)
Function called on errors while monitoring.
static struct GNUNET_NAMESTORE_QueueEntry * get_qe
Queue entry for the &#39;lookup&#39; operation.
static struct GNUNET_NAMESTORE_QueueEntry * del_qe
Queue entry for the &#39;del&#39; operation.
#define GNUNET_YES
Definition: gnunet_common.h:80
static char * typestring
Type of the record to add/remove, NULL to remove all.
enum GNUNET_GNSRECORD_Flags flags
Flags for the record.
This flag is currently unused; former RF_PENDING flag.
static void reverse_error_cb(void *cls)
Function called if we encountered an error in zone-to-name.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_set_nick(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const char *nick, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls)
Set the desired nick name for a zone.
static size_t data_size
Number of bytes in data.
static struct GNUNET_NAMESTORE_Handle * ns
Handle to the namestore.
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_STRINGS_utf8_tolower(const char *input, char *output)
Convert the utf-8 input string to lower case.
Definition: strings.c:558
Here is the call graph for this function:
Here is the caller graph for this function:

◆ identity_cb()

static void identity_cb ( void *  cls,
const struct GNUNET_IDENTITY_Ego ego 
)
static

Callback invoked from identity service with ego information.

An ego of NULL means the ego was not found.

Parameters
clsclosure with the configuration
egoan ego known to identity service, or NULL

Definition at line 1247 of file gnunet-namestore.c.

References _, cfg, ego_name, GNUNET_free_non_null, GNUNET_IDENTITY_ego_get_private_key(), GNUNET_SCHEDULER_shutdown(), name, ret, run_with_zone_pkey(), and zone_pkey.

Referenced by default_ego_cb(), and run().

1248 {
1249  const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
1250 
1251  el = NULL;
1252  if ((NULL != name) && (0 != strchr (name, '.')))
1253  {
1254  fprintf (stderr,
1255  _ ("Label `%s' contains `.' which is not allowed\n"),
1256  name);
1258  ret = -1;
1259  return;
1260  }
1261 
1262  if (NULL == ego)
1263  {
1264  if (NULL != ego_name)
1265  {
1266  fprintf (stderr,
1267  _ ("Ego `%s' not known to identity service\n"),
1268  ego_name);
1269  }
1271  ret = -1;
1272  return;
1273  }
1276  ego_name = NULL;
1277  run_with_zone_pkey (cfg);
1278 }
static void run_with_zone_pkey(const struct GNUNET_CONFIGURATION_Handle *cfg)
We have obtained the zone&#39;s private key, so now process the main commands using it.
static struct GNUNET_IDENTITY_EgoLookup * el
Handle to identity lookup.
const struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
Obtain the ECC key associated with a ego.
Definition: identity_api.c:556
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
static char * name
Name of the records to add/list/remove.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:524
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
static int ret
Global return value.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
configuration data
Definition: configuration.c:85
static char * ego_name
Name of the ego controlling the zone.
static struct GNUNET_CRYPTO_EcdsaPrivateKey zone_pkey
Private key for the our zone.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ default_ego_cb()

static void default_ego_cb ( void *  cls,
struct GNUNET_IDENTITY_Ego ego,
void **  ctx,
const char *  name 
)
static

Function called with the default ego to be used for GNS operations.

Used if the user did not specify a zone via command-line or environment variables.

Parameters
clsNULL
egodefault ego, NULL for none
ctxNULL
nameunused

Definition at line 1292 of file gnunet-namestore.c.

References _, cfg, GNUNET_SCHEDULER_shutdown(), identity_cb(), and ret.

Referenced by id_connect_cb().

1296 {
1297  const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
1298 
1299  (void) ctx;
1300  (void) name;
1301  get_default = NULL;
1302  if (NULL == ego)
1303  {
1304  fprintf (stderr, _ ("No default ego configured in identity service\n"));
1306  ret = -1;
1307  return;
1308  }
1309  else
1310  {
1311  identity_cb ((void *) cfg, ego);
1312  }
1313 }
static char * name
Name of the records to add/list/remove.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:524
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
static void identity_cb(void *cls, const struct GNUNET_IDENTITY_Ego *ego)
Callback invoked from identity service with ego information.
static int ret
Global return value.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
struct GNUNET_IDENTITY_Operation * get_default
Obtain default ego.
configuration data
Definition: configuration.c:85
Here is the call graph for this function:
Here is the caller graph for this function:

◆ id_connect_cb()

static void id_connect_cb ( void *  cls,
struct GNUNET_IDENTITY_Ego ego,
void **  ctx,
const char *  name 
)
static

Function called with ALL of the egos known to the identity service, used on startup if the user did not specify a zone on the command-line.

Once the iteration is done (ego is NULL), we ask for the default ego for "namestore".

Parameters
clsa struct GNUNET_CONFIGURATION_Handle
egoan ego, NULL for end of iteration
ctxNULL
namename associated with ego

Definition at line 1329 of file gnunet-namestore.c.

References cfg, default_ego_cb(), and GNUNET_IDENTITY_get().

Referenced by run().

1333 {
1334  const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
1335 
1336  (void) ctx;
1337  (void) name;
1338  if (NULL != ego)
1339  return;
1340  get_default =
1341  GNUNET_IDENTITY_get (idh, "namestore", &default_ego_cb, (void *) cfg);
1342 }
struct GNUNET_IDENTITY_Operation * GNUNET_IDENTITY_get(struct GNUNET_IDENTITY_Handle *h, const char *service_name, GNUNET_IDENTITY_Callback cb, void *cb_cls)
Obtain the identity that is currently preferred/default for a service.
Definition: identity_api.c:587
static char * name
Name of the records to add/list/remove.
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
static struct GNUNET_IDENTITY_Handle * idh
Identity service handle.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
static void default_ego_cb(void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, const char *name)
Function called with the default ego to be used for GNS operations.
struct GNUNET_IDENTITY_Operation * get_default
Obtain default ego.
configuration data
Definition: configuration.c:85
Here is the call graph for this function:
Here is the caller graph for this function:

◆ run()

static void run ( void *  cls,
char *const *  args,
const char *  cfgfile,
const struct GNUNET_CONFIGURATION_Handle cfg 
)
static

Main function that will be run.

Parameters
clsclosure
argsremaining command-line arguments
cfgfilename of the configuration file used (for saving, can be NULL!)
cfgconfiguration

Definition at line 1354 of file gnunet-namestore.c.

References _, do_shutdown(), ego_name, getenv(), GNUNET_ERROR_TYPE_WARNING, GNUNET_IDENTITY_connect(), GNUNET_IDENTITY_ego_lookup(), GNUNET_log, GNUNET_OK, GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_shutdown(), GNUNET_strdup, GNUNET_STRINGS_string_to_data(), id_connect_cb(), identity_cb(), ret, run_with_zone_pkey(), uri, and zone_pkey.

Referenced by main().

1358 {
1359  const char *pkey_str;
1360 
1361  (void) cls;
1362  (void) args;
1363  (void) cfgfile;
1364  if (NULL != args[0])
1365  GNUNET_log (
1367  _ ("Superfluous command line arguments (starting with `%s') ignored\n"),
1368  args[0]);
1369  if ((NULL != args[0]) && (NULL == uri))
1370  uri = GNUNET_strdup (args[0]);
1371 
1372  GNUNET_SCHEDULER_add_shutdown (&do_shutdown, (void *) cfg);
1373  pkey_str = getenv ("GNUNET_NAMESTORE_EGO_PRIVATE_KEY");
1374  if (NULL != pkey_str)
1375  {
1376  if (GNUNET_OK != GNUNET_STRINGS_string_to_data (pkey_str,
1377  strlen (pkey_str),
1378  &zone_pkey,
1379  sizeof (zone_pkey)))
1380  {
1381  fprintf (stderr,
1382  "Malformed private key `%s' in $%s\n",
1383  pkey_str,
1384  "GNUNET_NAMESTORE_EGO_PRIVATE_KEY");
1385  ret = 1;
1387  return;
1388  }
1389  run_with_zone_pkey (cfg);
1390  return;
1391  }
1392  if (NULL == ego_name)
1393  {
1394  idh = GNUNET_IDENTITY_connect (cfg, &id_connect_cb, (void *) cfg);
1395  if (NULL == idh)
1396  fprintf (stderr, _ ("Cannot connect to identity service\n"));
1397  ret = -1;
1398  return;
1399  }
1400  el = GNUNET_IDENTITY_ego_lookup (cfg, ego_name, &identity_cb, (void *) cfg);
1401 }
struct GNUNET_IDENTITY_Handle * GNUNET_IDENTITY_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_IDENTITY_Callback cb, void *cb_cls)
Connect to the identity service.
Definition: identity_api.c:528
static void run_with_zone_pkey(const struct GNUNET_CONFIGURATION_Handle *cfg)
We have obtained the zone&#39;s private key, so now process the main commands using it.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received, or when GNUNET_SCHEDULER_shutdown() is being invoked.
Definition: scheduler.c:1293
static struct GNUNET_IDENTITY_EgoLookup * el
Handle to identity lookup.
static void do_shutdown(void *cls)
Task run on shutdown.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:524
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
static struct GNUNET_IDENTITY_Handle * idh
Identity service handle.
static void identity_cb(void *cls, const struct GNUNET_IDENTITY_Ego *ego)
Callback invoked from identity service with ego information.
static int ret
Global return value.
static void id_connect_cb(void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, const char *name)
Function called with ALL of the egos known to the identity service, used on startup if the user did n...
char * getenv()
static char * uri
URI to import.
struct GNUNET_IDENTITY_EgoLookup * GNUNET_IDENTITY_ego_lookup(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *name, GNUNET_IDENTITY_EgoCallback cb, void *cb_cls)
Lookup an ego by name.
static char * ego_name
Name of the ego controlling the zone.
static struct GNUNET_CRYPTO_EcdsaPrivateKey zone_pkey
Private key for the our zone.
#define GNUNET_log(kind,...)
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:1021
Here is the call graph for this function:
Here is the caller graph for this function:

◆ multirecord_process()

static int multirecord_process ( struct GNUNET_GETOPT_CommandLineProcessorContext ctx,
void *  scls,
const char *  option,
const char *  value 
)
static

Command-line option parser function that allows the user to specify a complete record as one argument for adding/removing.

A pointer to the head of the list of record sets must be passed as the "scls" argument.

Parameters
ctxcommand line processor context
sclsmust be of type "struct GNUNET_FS_Uri **"
optionname of the option (typically 'R')
valuecommand line argument given; format is "TTL TYPE FLAGS VALUE" where TTL is an expiration time (rel or abs), always given in seconds (without the unit), TYPE is a DNS/GNS record type, FLAGS is either "n" for no flags or a combination of 's' (shadow) and 'p' (public) and VALUE is the value (in human-readable format)
Returns
GNUNET_OK on success

Definition at line 1422 of file gnunet-namestore.c.

References _, GNUNET_GNSRECORD_Data::data, GNUNET_GNSRECORD_Data::data_size, etime_is_rel, GNUNET_GNSRECORD_Data::expiration_time, GNUNET_GNSRECORD_Data::flags, GNUNET_asprintf(), GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_GNSRECORD_number_to_typename(), GNUNET_GNSRECORD_RF_NONE, GNUNET_GNSRECORD_RF_PRIVATE, GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION, GNUNET_GNSRECORD_RF_SHADOW_RECORD, GNUNET_GNSRECORD_string_to_value(), GNUNET_GNSRECORD_typename_to_number(), GNUNET_log, GNUNET_malloc, GNUNET_OK, GNUNET_strdup, GNUNET_SYSERR, head, RecordSetEntry::next, parse_expiration(), RecordSetEntry::record, and GNUNET_GNSRECORD_Data::record_type.

Referenced by multirecord_option().

1426 {
1427  struct RecordSetEntry **head = scls;
1428  struct RecordSetEntry *r;
1430  char *cp;
1431  char *tok;
1432  char *saveptr;
1433  int etime_is_rel;
1434  void *raw_data;
1435 
1436  (void) ctx;
1437  (void) option;
1438  cp = GNUNET_strdup (value);
1439  tok = strtok_r (cp, " ", &saveptr);
1440  if (NULL == tok)
1441  {
1443  _ ("Empty record line argument is not allowed.\n"));
1444  GNUNET_free (cp);
1445  return GNUNET_SYSERR;
1446  }
1447  {
1448  char *etime_in_s;
1449 
1450  GNUNET_asprintf (&etime_in_s, "%s s", tok);
1451  if (GNUNET_OK !=
1452  parse_expiration (etime_in_s, &etime_is_rel, &record.expiration_time))
1453  {
1455  _ ("Invalid expiration time `%s' (must be without unit)\n"),
1456  tok);
1457  GNUNET_free (cp);
1458  GNUNET_free (etime_in_s);
1459  return GNUNET_SYSERR;
1460  }
1461  GNUNET_free (etime_in_s);
1462  }
1463  tok = strtok_r (NULL, " ", &saveptr);
1464  if (NULL == tok)
1465  {
1467  _ ("Missing entries in record line `%s'.\n"),
1468  value);
1469  GNUNET_free (cp);
1470  return GNUNET_SYSERR;
1471  }
1472  record.record_type = GNUNET_GNSRECORD_typename_to_number (tok);
1473  if (UINT32_MAX == record.record_type)
1474  {
1475  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _ ("Unknown record type `%s'\n"), tok);
1476  GNUNET_free (cp);
1477  return GNUNET_SYSERR;
1478  }
1479  tok = strtok_r (NULL, " ", &saveptr);
1480  if (NULL == tok)
1481  {
1483  _ ("Missing entries in record line `%s'.\n"),
1484  value);
1485  GNUNET_free (cp);
1486  return GNUNET_SYSERR;
1487  }
1489  if (etime_is_rel)
1491  if (NULL == strchr (tok, (unsigned char) 'p')) /* p = public */
1493  if (NULL != strchr (tok, (unsigned char) 's'))
1495  /* find beginning of record value */
1496  tok = strchr (&value[tok - cp], (unsigned char) ' ');
1497  if (NULL == tok)
1498  {
1500  _ ("Missing entries in record line `%s'.\n"),
1501  value);
1502  GNUNET_free (cp);
1503  return GNUNET_SYSERR;
1504  }
1505  GNUNET_free (cp);
1506  tok++; /* skip space */
1508  tok,
1509  &raw_data,
1510  &record.data_size))
1511  {
1513  _ ("Invalid record data for type %s: `%s'.\n"),
1515  tok);
1516  return GNUNET_SYSERR;
1517  }
1518 
1519  r = GNUNET_malloc (sizeof (struct RecordSetEntry) + record.data_size);
1520  r->next = *head;
1521  record.data = &r[1];
1522  memcpy (&r[1], raw_data, record.data_size);
1523  GNUNET_free (raw_data);
1524  r->record = record;
1525  *head = r;
1526  return GNUNET_OK;
1527 }
This record should not be used unless all (other) records with an absolute expiration time have expir...
struct RecordSetEntry * next
Kept in a linked list.
DWORD flags
Definition: w32nsp.c:86
static int parse_expiration(const char *expirationstring, int *etime_is_rel, uint64_t *etime)
Parse expiration time.
Definition: w32nsp.c:83
uint32_t GNUNET_GNSRECORD_typename_to_number(const char *dns_typename)
Convert a type name (i.e.
Definition: gnsrecord.c:204
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
static int etime_is_rel
Is expiration time relative or absolute time?
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
static char * value
Value of the record to add/remove.
static char * option
Name of the option.
Definition: gnunet-config.c:38
This is a private record of this peer and it should thus not be handed out to other peers...
int GNUNET_GNSRECORD_string_to_value(uint32_t type, const char *s, void **data, size_t *data_size)
Convert human-readable version of a &#39;value&#39; of a record to the binary representation.
Definition: gnsrecord.c:175
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
struct GNUNET_GNSRECORD_Data record
The record to add/remove.
Entry in record set for bulk processing.
static struct PendingResolutions * head
Head of list of pending resolution requests.
Definition: gnunet-ats.c:231
#define GNUNET_log(kind,...)
static void record(void *cls, size_t data_size, const void *data)
Process recorded audio data.
This flag is currently unused; former RF_PENDING flag.
const char * GNUNET_GNSRECORD_number_to_typename(uint32_t type)
Convert a type number (i.e.
Definition: gnsrecord.c:231
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ multirecord_option()

struct GNUNET_GETOPT_CommandLineOption multirecord_option ( char  shortName,
const char *  name,
const char *  argumentHelp,
const char *  description,
struct RecordSetEntry **  rs 
)

Allow user to specify keywords.

Parameters
shortNameshort name of the option
namelong name of the option
argumentHelphelp text for the option argument
descriptionlong help text for the option
[out]topKeywordsset to the desired value

Definition at line 1540 of file gnunet-namestore.c.

References GNUNET_GETOPT_CommandLineOption::argumentHelp, GNUNET_GETOPT_CommandLineOption::description, multirecord_process(), name, and GNUNET_GETOPT_CommandLineOption::shortName.

Referenced by main().

1545 {
1547  .name = name,
1548  .argumentHelp = argumentHelp,
1549  .description = description,
1550  .require_argument = 1,
1551  .processor =
1553  .scls = (void *) rs};
1554 
1555  return clo;
1556 }
const char * argumentHelp
Name of the argument for the user in help text.
const char * description
Help text for the option (description)
Definition of a command line option.
static char * name
Name of the records to add/list/remove.
const char shortName
Short name of the option.
static int multirecord_process(struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, void *scls, const char *option, const char *value)
Command-line option parser function that allows the user to specify a complete record as one argument...
Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char *const *  argv 
)

The main function for gnunet-namestore.

Parameters
argcnumber of arguments from the command line
argvcommand line arguments
Returns
0 ok, 1 on error

Definition at line 1567 of file gnunet-namestore.c.

References _, add, del, ego_name, expirationstring, gettext_noop, GNUNET_CRYPTO_ecdsa_key_clear(), GNUNET_free, GNUNET_GETOPT_OPTION_END, GNUNET_GETOPT_option_flag(), GNUNET_GETOPT_option_string(), GNUNET_log_setup(), GNUNET_OK, GNUNET_PROGRAM_run(), GNUNET_STRINGS_get_utf8_args(), is_public, is_shadow, list, monitor, multirecord_option(), nickstring, ret, reverse_pkey, run(), typestring, uri, value, and zone_pkey.

1568 {
1570  {GNUNET_GETOPT_option_flag ('a', "add", gettext_noop ("add record"), &add),
1572  "delete",
1573  gettext_noop ("delete record"),
1574  &del),
1576  "display",
1577  gettext_noop ("display records"),
1578  &list),
1580  'e',
1581  "expiration",
1582  "TIME",
1583  gettext_noop (
1584  "expiration time for record to use (for adding only), \"never\" is possible"),
1585  &expirationstring),
1587  "nick",
1588  "NICKNAME",
1589  gettext_noop (
1590  "set the desired nick name for the zone"),
1591  &nickstring),
1593  "monitor",
1594  gettext_noop (
1595  "monitor changes in the namestore"),
1596  &monitor),
1598  "name",
1599  "NAME",
1600  gettext_noop (
1601  "name of the record to add/delete/display"),
1602  &name),
1604  "reverse",
1605  "PKEY",
1606  gettext_noop (
1607  "determine our name for the given PKEY"),
1608  &reverse_pkey),
1610  'R',
1611  "replace",
1612  "RECORDLINE",
1613  gettext_noop (
1614  "set record set to values given by (possibly multiple) RECORDLINES; can be specified multiple times"),
1615  &recordset),
1617  "type",
1618  "TYPE",
1619  gettext_noop (
1620  "type of the record to add/delete/display"),
1621  &typestring),
1623  "uri",
1624  "URI",
1625  gettext_noop ("URI to import into our zone"),
1626  &uri),
1628  "value",
1629  "VALUE",
1630  gettext_noop (
1631  "value of the record to add/delete"),
1632  &value),
1634  "public",
1635  gettext_noop ("create or list public record"),
1636  &is_public),
1638  's',
1639  "shadow",
1640  gettext_noop (
1641  "create shadow record (only valid if all other records of the same type have expired"),
1642  &is_shadow),
1644  "zone",
1645  "EGO",
1646  gettext_noop (
1647  "name of the ego controlling the zone"),
1648  &ego_name),
1650  int lret;
1651 
1652  if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
1653  return 2;
1654 
1655  is_public = -1;
1656  is_shadow = -1;
1657  GNUNET_log_setup ("gnunet-namestore", "WARNING", NULL);
1658  if (GNUNET_OK !=
1659  (lret = GNUNET_PROGRAM_run (argc,
1660  argv,
1661  "gnunet-namestore",
1662  _ ("GNUnet zone manipulation tool"),
1663  options,
1664  &run,
1665  NULL)))
1666  {
1667  GNUNET_free ((void *) argv);
1669  return lret;
1670  }
1671  GNUNET_free ((void *) argv);
1673  return ret;
1674 }
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
void GNUNET_CRYPTO_ecdsa_key_clear(struct GNUNET_CRYPTO_EcdsaPrivateKey *pk)
Clear memory that was used to store a private key.
Definition: crypto_ecc.c:585
int GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
Definition: strings.c:1521
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
Definition of a command line option.
static char * name
Name of the records to add/list/remove.
static struct RecordSetEntry * recordset
Entry in record set for processing records in bulk.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_string(char shortName, const char *name, const char *argumentHelp, const char *description, char **str)
Allow user to specify a string.
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
static int is_shadow
Is record a shadow record (GNUNET_GNSRECORD_RF_SHADOW_RECORD)
static char * value
Value of the record to add/remove.
static int monitor
Enables monitor mode.
static int del
Desired action is to remove a record.
static int ret
Global return value.
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
Main function that will be run.
static char * reverse_pkey
Reverse lookup to perform.
static char * expirationstring
Desired expiration time.
static char * uri
URI to import.
static int is_public
Is record public (opposite of GNUNET_GNSRECORD_RF_PRIVATE)
static int add
Desired action is to add a record.
static int list
Desired action is to list records.
static char * nickstring
Desired nick name.
static char * ego_name
Name of the ego controlling the zone.
static struct GNUNET_CRYPTO_EcdsaPrivateKey zone_pkey
Private key for the our zone.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_flag(char shortName, const char *name, const char *description, int *val)
Allow user to specify a flag (which internally means setting an integer to 1/GNUNET_YES/GNUNET_OK.
int GNUNET_PROGRAM_run(int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration, parse options).
Definition: program.c:361
static char * typestring
Type of the record to add/remove, NULL to remove all.
int GNUNET_log_setup(const char *comp, const char *loglevel, const char *logfile)
Setup logging.
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_GETOPT_CommandLineOption multirecord_option(char shortName, const char *name, const char *argumentHelp, const char *description, struct RecordSetEntry **rs)
Allow user to specify keywords.
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:

Variable Documentation

◆ ns

struct GNUNET_NAMESTORE_Handle* ns
static

Handle to the namestore.

Definition at line 57 of file gnunet-namestore.c.

◆ zone_pkey

struct GNUNET_CRYPTO_EcdsaPrivateKey zone_pkey
static

Private key for the our zone.

Definition at line 62 of file gnunet-namestore.c.

Referenced by del_monitor(), do_shutdown(), get_existing_record(), identity_cb(), main(), run(), and run_with_zone_pkey().

◆ el

struct GNUNET_IDENTITY_EgoLookup* el
static

Handle to identity lookup.

Definition at line 67 of file gnunet-namestore.c.

◆ idh

struct GNUNET_IDENTITY_Handle* idh
static

Identity service handle.

Definition at line 72 of file gnunet-namestore.c.

◆ get_default

struct GNUNET_IDENTITY_Operation* get_default

Obtain default ego.

Definition at line 77 of file gnunet-namestore.c.

◆ ego_name

char* ego_name
static

Name of the ego controlling the zone.

Definition at line 82 of file gnunet-namestore.c.

Referenced by handle_reverse_lookup(), identity_cb(), main(), and run().

◆ add

int add
static

Desired action is to add a record.

Definition at line 87 of file gnunet-namestore.c.

Referenced by main(), and run_with_zone_pkey().

◆ add_qe_uri

struct GNUNET_NAMESTORE_QueueEntry* add_qe_uri
static

Queue entry for the 'add-uri' operation.

Definition at line 92 of file gnunet-namestore.c.

◆ add_qe

struct GNUNET_NAMESTORE_QueueEntry* add_qe
static

Queue entry for the 'add' operation.

Definition at line 97 of file gnunet-namestore.c.

◆ get_qe

struct GNUNET_NAMESTORE_QueueEntry* get_qe
static

Queue entry for the 'lookup' operation.

Definition at line 102 of file gnunet-namestore.c.

◆ reverse_qe

struct GNUNET_NAMESTORE_QueueEntry* reverse_qe
static

Queue entry for the 'reverse lookup' operation (in combination with a name).

Definition at line 107 of file gnunet-namestore.c.

◆ list

int list
static

Desired action is to list records.

Definition at line 112 of file gnunet-namestore.c.

Referenced by main(), and run_with_zone_pkey().

◆ list_it

struct GNUNET_NAMESTORE_ZoneIterator* list_it
static

List iterator for the 'list' operation.

Definition at line 117 of file gnunet-namestore.c.

◆ del

int del
static

Desired action is to remove a record.

Definition at line 122 of file gnunet-namestore.c.

Referenced by main(), and run_with_zone_pkey().

◆ is_public

int is_public
static

Is record public (opposite of GNUNET_GNSRECORD_RF_PRIVATE)

Definition at line 127 of file gnunet-namestore.c.

Referenced by get_existing_record(), and main().

◆ is_shadow

int is_shadow
static

Is record a shadow record (GNUNET_GNSRECORD_RF_SHADOW_RECORD)

Definition at line 132 of file gnunet-namestore.c.

Referenced by get_existing_record(), main(), and run_with_zone_pkey().

◆ del_qe

struct GNUNET_NAMESTORE_QueueEntry* del_qe
static

Queue entry for the 'del' operation.

Definition at line 137 of file gnunet-namestore.c.

◆ set_qe

struct GNUNET_NAMESTORE_QueueEntry* set_qe
static

Queue entry for the 'set/replace' operation.

Definition at line 142 of file gnunet-namestore.c.

◆ name

char* name
static

Name of the records to add/list/remove.

Definition at line 147 of file gnunet-namestore.c.

Referenced by del_monitor(), display_record(), get_existing_record(), identity_cb(), multirecord_option(), and run_with_zone_pkey().

◆ value

char* value
static

Value of the record to add/remove.

Definition at line 152 of file gnunet-namestore.c.

Referenced by add_get_request_to_pending(), add_setter_action(), add_to_tc(), age_values(), bandwidth_stats_iterator(), barrier_destroy_iterator(), bind_loose_channel(), build_result_set(), cache_clear_iterator(), call_iterator(), cancel_pending_request(), change_peer_respect(), channel_destroy_iterator(), check_connection_quality(), check_known_address(), check_known_challenge(), check_validation_request_pending(), clean_local_client(), clean_request(), cleanup_channel(), cleanup_destination(), cleanup_iterator(), cleanup_validation_entry(), client_release_ports(), close_files_iter(), collector(), consume_cont(), consume_ticket(), cookie_identity_interpretation(), database_setup(), debug_channel(), decrementBit(), del_monitor(), delete_entries(), destroy_active_client_request(), destroy_ai_cb(), destroy_all_address_it(), destroy_channel_cb(), destroy_elements_iterator(), destroy_it(), destroy_iterator_cb(), destroy_key_to_element_iter(), destroy_paths_now(), destroy_port_cb(), destroy_remaining_channels(), destroy_session_cb(), destroy_session_shutdown_cb(), destroy_tunnels_now(), destroy_watch(), disconnect_all_neighbours(), disconnect_and_free_peer_entry(), dns_string_to_value(), dns_value_to_string(), do_flood(), do_restart_typemap_message(), drop_client_entries(), escape_name(), execute_get(), execute_select(), expire_blocks(), expire_entries(), filter_all(), filtered_map_initialization(), find_address_cb(), find_address_it(), find_advertisable_hello(), find_ai_cb(), find_ai_no_session_cb(), find_best_address_it(), find_by_message_uuid(), find_by_unique_id(), find_closest(), find_result_set(), find_sender_by_address(), find_trees(), flush_respect(), forward_reply(), free_ack_cummulator_cb(), free_addr_it(), free_all_it(), free_backtalker_cb(), free_blacklist_entry(), free_connect_info(), free_dv_routes_cb(), free_ego(), free_entry(), free_host_entry(), free_item(), free_matching_requests(), free_neighbour_cb(), free_peer(), free_pending_ack_cb(), free_preference(), free_reassembly_cb(), free_record(), free_request(), free_request_it(), free_result(), free_service_record(), free_session(), free_sug_handle(), free_tmps(), free_tracker(), free_validation_state_cb(), free_value(), free_waiting_entry(), get_active_address_it(), get_all_peers_iterator(), get_all_tunnels_iterator(), get_cb(), get_iterator(), get_queue_delete_it(), get_receiver_delete_it(), get_result_present(), get_sender_delete_it(), get_session_delete_it(), get_url_parameter_copy(), GNUNET_CONFIGURATION_deserialize(), GNUNET_NETWORK_socket_disable_corking(), GSF_cadet_release_clients(), handle_ack(), handle_set(), heap_plugin_get_expiration(), heap_plugin_get_replication(), heap_plugin_get_zero_anonymity(), heap_plugin_put(), incrementBit(), init_key_to_element_iterator(), initialize_map_unfiltered(), iterate_addresses(), iterate_channels_cb(), iterate_entries(), iterate_reachables(), iterate_zones(), iterator_bf_create(), iterator_bf_reduce(), libgnunet_plugin_rest_openid_connect_done(), locate_by_id(), lookup_queue_it(), lookup_session_it(), main(), mark_match_down(), mark_peer_down(), match_session_cb(), mlp_create_problem_add_address_information(), mlp_free_peers(), mlp_get_preferred_address_it(), mlp_propagate_results(), move_to_pending(), move_to_queue(), neighbour_delete(), neighbours_iterate(), normalize_address(), notify_change(), notify_client_about_session(), notify_client_queues(), notify_tunnel_up_cb(), op_get_element_iterator(), opc_free_iterator(), opc_search_iterator(), open_port_cb(), parse_record(), parse_record_data(), peerinfo_it(), prepare_ibf_iterator(), printer(), process(), process_client_result(), process_reply(), process_result_with_request(), process_stat_in(), process_update_node(), put_cb(), rcop_cleanup_iterator(), reachability_iterator(), regex_cancel_dht_get(), regex_result_iterator(), reghost_free_iterator(), reghost_match_iterator(), remove_by_unique_id(), remove_iterator(), reschedule_hellos(), reset_peers(), rewatch_it(), run(), run_with_zone_pkey(), schedule_current_round(), search_iterator(), search_result_free(), search_result_freeze_probes(), search_result_resume_probes(), search_result_stop(), search_result_suspend(), send_add_session_cb(), send_full_element_iterator(), send_missing_full_elements_iter(), send_offers_iterator(), send_session_info_iter(), send_utilization_data(), session_cmp_it(), session_disconnect_it(), session_lookup_client_by_address(), session_lookup_it(), session_tag_it(), set_insert_iterator(), signal_result_resume(), socket_set_nodelay(), stat_iterator(), stop_peer_request(), store_and_free_entries(), stun_attr2str(), stun_msg2str(), sum_relative_preferences(), template_plugin_update_session_timeout(), test_blacklisted(), test_exist_cb(), test_result_present(), ticket_collect(), transmit_suggestion(), try_add_peers(), try_combine_recent(), update_abs_sum(), update_allocation(), update_counters(), update_flood_times(), update_iterator(), update_rel_sum(), update_sre_result_maps(), validation_entry_match(), watch_notifier_it(), write_item(), and zone_to_name().

◆ uri

char* uri
static

URI to import.

Definition at line 157 of file gnunet-namestore.c.

Referenced by do_shutdown(), main(), run(), and run_with_zone_pkey().

◆ reverse_pkey

char* reverse_pkey
static

Reverse lookup to perform.

Definition at line 162 of file gnunet-namestore.c.

Referenced by handle_reverse_lookup(), main(), reverse_error_cb(), and run_with_zone_pkey().

◆ typestring

char* typestring
static

Type of the record to add/remove, NULL to remove all.

Definition at line 167 of file gnunet-namestore.c.

Referenced by del_monitor(), display_record(), display_records_from_block(), main(), and run_with_zone_pkey().

◆ expirationstring

char* expirationstring
static

Desired expiration time.

Definition at line 172 of file gnunet-namestore.c.

Referenced by main(), and run_with_zone_pkey().

◆ nickstring

char* nickstring
static

Desired nick name.

Definition at line 177 of file gnunet-namestore.c.

Referenced by main(), and run_with_zone_pkey().

◆ ret

int ret
static

◆ type

uint32_t type
static

Type string converted to DNS type value.

Definition at line 187 of file gnunet-namestore.c.

Referenced by del_monitor(), display_record(), get_existing_record(), and run_with_zone_pkey().

◆ data

void* data
static

Value in binary format.

Definition at line 192 of file gnunet-namestore.c.

Referenced by del_monitor(), display_record(), do_shutdown(), get_existing_record(), and run_with_zone_pkey().

◆ data_size

size_t data_size
static

◆ etime

uint64_t etime
static

Expiration string converted to numeric value.

Definition at line 202 of file gnunet-namestore.c.

Referenced by generate_gns_certificate(), get_existing_record(), and run_with_zone_pkey().

◆ etime_is_rel

int etime_is_rel = GNUNET_SYSERR
static

Is expiration time relative or absolute time?

Definition at line 207 of file gnunet-namestore.c.

Referenced by get_existing_record(), multirecord_process(), and run_with_zone_pkey().

◆ zm

struct GNUNET_NAMESTORE_ZoneMonitor* zm
static

◆ monitor

int monitor
static

Enables monitor mode.

Definition at line 217 of file gnunet-namestore.c.

Referenced by main(), and run_with_zone_pkey().

◆ recordset

struct RecordSetEntry* recordset
static

Entry in record set for processing records in bulk.

Definition at line 222 of file gnunet-namestore.c.