GNUnet  0.11.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_IDENTITY_PrivateKey *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_IDENTITY_PrivateKey *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_IDENTITY_PrivateKey *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_IDENTITY_PrivateKey *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_IDENTITY_PrivateKey *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_IDENTITY_PrivateKey *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, 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_IDENTITY_PrivateKey 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.

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 }
static struct GNUNET_NAMESTORE_QueueEntry * get_qe
Queue entry for the 'lookup' operation.
static struct GNUNET_NAMESTORE_ZoneMonitor * zm
Monitor handle.
static struct GNUNET_IDENTITY_PrivateKey zone_pkey
Private key for the our zone.
static struct GNUNET_NAMESTORE_QueueEntry * add_qe
Queue entry for the 'add' operation.
static struct GNUNET_NAMESTORE_QueueEntry * del_qe
Queue entry for the 'del' operation.
static struct GNUNET_NAMESTORE_QueueEntry * set_qe
Queue entry for the 'set/replace' operation.
static void * data
Value in binary format.
static struct GNUNET_IDENTITY_EgoLookup * el
Handle to identity lookup.
static struct GNUNET_IDENTITY_Handle * idh
Identity service handle.
static struct GNUNET_NAMESTORE_Handle * ns
Handle to the namestore.
static struct GNUNET_NAMESTORE_ZoneIterator * list_it
List iterator for the 'list' operation.
static struct GNUNET_NAMESTORE_QueueEntry * add_qe_uri
Queue entry for the 'add-uri' operation.
struct GNUNET_IDENTITY_Operation * get_default
Obtain default ego.
static char * uri
URI to import.
void GNUNET_IDENTITY_cancel(struct GNUNET_IDENTITY_Operation *op)
Cancel an identity operation.
Definition: identity_api.c:904
void GNUNET_IDENTITY_ego_lookup_cancel(struct GNUNET_IDENTITY_EgoLookup *el)
Abort ego lookup attempt.
void GNUNET_IDENTITY_disconnect(struct GNUNET_IDENTITY_Handle *h)
Disconnect from identity service.
Definition: identity_api.c:921
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_NAMESTORE_disconnect(struct GNUNET_NAMESTORE_Handle *h)
Disconnect from the namestore service (and free associated resources).
void GNUNET_NAMESTORE_cancel(struct GNUNET_NAMESTORE_QueueEntry *qe)
Cancel a namestore operation.
void GNUNET_NAMESTORE_zone_monitor_stop(struct GNUNET_NAMESTORE_ZoneMonitor *zm)
Stop monitoring a zone for changes.
void GNUNET_NAMESTORE_zone_iteration_stop(struct GNUNET_NAMESTORE_ZoneIterator *it)
Stops iteration and releases the namestore handle for further calls.

References add_qe, add_qe_uri, data, del_qe, el, get_default, get_qe, 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(), idh, list_it, ns, set_qe, uri, zm, and zone_pkey.

Referenced by run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_finished()

static void test_finished ( void  )
static

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

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

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 * reverse_qe
Queue entry for the 'reverse lookup' operation (in combination with a name).
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:531

References add_qe, add_qe_uri, del_qe, get_qe, GNUNET_SCHEDULER_shutdown(), list_it, and reverse_qe.

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().

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.

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.
static int ret
Global return value.
static void test_finished()
Check if we are finished, and if so, perform shutdown.
@ GNUNET_YES
Definition: gnunet_common.h:97
@ GNUNET_NO
Definition: gnunet_common.h:94
#define _(String)
GNU gettext support macro.
Definition: platform.h:177
An QueueEntry used to store information for a pending NAMESTORE record operation.
Definition: namestore_api.c:54

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

Referenced by get_existing_record(), and run_with_zone_pkey().

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.

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 }
@ GNUNET_SYSERR
Definition: gnunet_common.h:93

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

Referenced by del_monitor().

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.

382 {
383  (void) cls;
384  list_it = NULL;
385  test_finished ();
386 }

References list_it, and test_finished().

Referenced by run_with_zone_pkey().

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.

394 {
395  (void) cls;
396  list_it = NULL;
397  fprintf (stderr, "Error iterating over zone\n");
398  ret = 1;
399  test_finished ();
400 }

References list_it, ret, and test_finished().

Referenced by run_with_zone_pkey().

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.

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 }
#define GNUNET_GNSRECORD_TYPE_NICK
GNS nick names.
static char * name
Name of the records to add/list/remove.
static uint32_t type
Type string converted to DNS type value.
static size_t data_size
Number of bytes in data.
static char * typestring
Type of the record to add/remove, NULL to remove all.
#define GNUNET_GNS_EMPTY_LABEL_AT
String we use to indicate an empty label (top-level entry in the zone).
const char * GNUNET_GNSRECORD_number_to_typename(uint32_t type)
Convert a type number to the corresponding type string (e.g.
Definition: gnsrecord.c:244
char * GNUNET_GNSRECORD_value_to_string(uint32_t type, const void *data, size_t data_size)
Convert the 'value' of a record to a string.
Definition: gnsrecord.c:156
uint32_t GNUNET_GNSRECORD_typename_to_number(const char *dns_typename)
Convert a type name (e.g "AAAA") to the corresponding number.
Definition: gnsrecord.c:217
#define GNUNET_GNSRECORD_TYPE_ANY
Record type indicating any record/'*'.
@ GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION
This expiration time of the record is a relative time (not an absolute time).
@ GNUNET_GNSRECORD_RF_SHADOW_RECORD
This record should not be used unless all (other) records with an absolute expiration time have expir...
@ GNUNET_GNSRECORD_RF_PRIVATE
This is a private record of this peer and it should thus not be handed out to other peers.
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.
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
Definition: strings.c:604
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:557
uint64_t expiration_time
Expiration time for the DNS record.
Time for absolute times used by GNUnet, in microseconds.
Time for relative time used by GNUnet, in microseconds.

References _, GNUNET_TIME_Absolute::abs_value_us, data, data_size, GNUNET_GNSRECORD_Data::expiration_time, 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, list_it, name, GNUNET_TIME_Relative::rel_value_us, type, and typestring.

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

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_IDENTITY_PrivateKey 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.

503 {
504  (void) cls;
505  (void) zone_key;
506  display_record (rname, rd_len, rd);
508 }
static const struct GNUNET_IDENTITY_PrivateKey * zone_key
Private key of the zone.
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.

References display_record(), GNUNET_NAMESTORE_zone_iterator_next(), list_it, and zone_key.

Referenced by run_with_zone_pkey().

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_IDENTITY_PrivateKey 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.

526 {
527  (void) cls;
528  (void) zone_key;
529  display_record (rname, rd_len, rd);
531 }
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).

References display_record(), GNUNET_NAMESTORE_zone_monitor_next(), zm, and zone_key.

Referenced by run_with_zone_pkey().

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_IDENTITY_PrivateKey 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.

549 {
550  (void) cls;
551  (void) zone_key;
552  get_qe = NULL;
553  display_record (rname, rd_len, rd);
554  test_finished ();
555 }

References display_record(), get_qe, test_finished(), and zone_key.

Referenced by run_with_zone_pkey().

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.

565 {
566  (void) cls;
567  fprintf (stdout, "%s", "Monitor is now in sync.\n");
568 }

Referenced by GNUNET_NAMESTORE_zone_monitor_start(), and run_with_zone_pkey().

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.

578 {
579  (void) cls;
580  fprintf (stderr, "%s", "Monitor disconnected and out of sync.\n");
581 }

Referenced by run_with_zone_pkey().

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.

591 {
592  (void) cls;
593  get_qe = NULL;
594  fprintf (stderr, "%s", "Failed to lookup record.\n");
595  test_finished ();
596 }

References get_qe, and test_finished().

Referenced by run_with_zone_pkey().

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.

604 {
605  (void) cls;
606  add_qe = NULL;
607  GNUNET_break (0);
608  ret = 1;
609  test_finished ();
610 }
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.

References add_qe, GNUNET_break, ret, and test_finished().

Referenced by run_with_zone_pkey().

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_IDENTITY_PrivateKey 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.

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;
662 
665  fprintf (
666  stderr,
667  _ (
668  "A zone key record exists already under `%s', no other records can be added.\n"),
669  rec_name);
670  ret = 1;
671  test_finished ();
672  return;
673 
676  {
677  fprintf (
678  stderr,
679  _ (
680  "A SOA record exists already under `%s', cannot add a second SOA to the same zone.\n"),
681  rec_name);
682  ret = 1;
683  test_finished ();
684  return;
685  }
686  break;
687  }
688  }
689  switch (type)
690  {
692  if (0 != rd_count)
693  {
694  fprintf (stderr,
695  _ (
696  "Records already exist under `%s', cannot add `%s' record.\n"),
697  rec_name,
698  "CNAME");
699  ret = 1;
700  test_finished ();
701  return;
702  }
703  break;
704 
707  if (0 != rd_count)
708  {
709  fprintf (stderr,
710  _ (
711  "Records already exist under `%s', cannot add record.\n"),
712  rec_name);
713  ret = 1;
714  test_finished ();
715  return;
716  }
717  break;
718 
720  for (unsigned int i = 0; i < rd_count; i++)
722  {
723  fprintf (
724  stderr,
725  _ (
726  "Non-GNS2DNS records already exist under `%s', cannot add GNS2DNS record.\n"),
727  rec_name);
728  ret = 1;
729  test_finished ();
730  return;
731  }
732  break;
733  }
734  memset (rdn, 0, sizeof(struct GNUNET_GNSRECORD_Data));
735  GNUNET_memcpy (&rdn[1], rd, rd_count * sizeof(struct GNUNET_GNSRECORD_Data));
736  rde = &rdn[0];
737  rde->data = data;
738  rde->data_size = data_size;
739  rde->record_type = type;
740  if (1 == is_shadow)
742  if (1 != is_public)
744  rde->expiration_time = etime;
745  if (GNUNET_YES == etime_is_rel)
747  else if (GNUNET_NO != etime_is_rel)
748  rde->expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
749  GNUNET_assert (NULL != name);
751  &zone_pkey,
752  name,
753  rd_count + 1,
754  rde,
756  &add_qe);
757 }
#define GNUNET_GNSRECORD_TYPE_GNS2DNS
Delegation to DNS.
#define GNUNET_GNSRECORD_TYPE_PKEY
WARNING: This header is generated! In order to add GNS record types, you must register them in GANA,...
#define GNUNET_GNSRECORD_TYPE_EDKEY
Record type for EDKEY zone delegations.
static int is_shadow
Is record a shadow record (GNUNET_GNSRECORD_RF_SHADOW_RECORD)
static int etime_is_rel
Is expiration time relative or absolute time?
static void add_continuation(void *cls, int32_t success, const char *emsg)
Continuation called to notify client about result of the operation.
static uint64_t etime
Expiration string converted to numeric value.
static int is_public
Is record public (opposite of GNUNET_GNSRECORD_RF_PRIVATE)
#define GNUNET_log(kind,...)
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_DNSPARSER_TYPE_SOA
#define GNUNET_DNSPARSER_TYPE_CNAME
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
@ GNUNET_ERROR_TYPE_DEBUG
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_store(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *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.
#define GNUNET_TIME_UNIT_FOREVER_ABS
Constant used to specify "forever".
uint32_t record_type
Type of the GNS/DNS record.
const void * data
Binary value stored in the DNS record.
size_t data_size
Number of bytes in data.
enum GNUNET_GNSRECORD_Flags flags
Flags for the record.

References _, add_continuation(), add_qe, GNUNET_GNSRECORD_Data::data, data, GNUNET_GNSRECORD_Data::data_size, 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_EDKEY, 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, ns, GNUNET_GNSRECORD_Data::record_type, ret, test_finished(), type, zone_key, and zone_pkey.

Referenced by run_with_zone_pkey().

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 764 of file gnunet-namestore.c.

765 {
766  (void) cls;
767  reverse_qe = NULL;
768  fprintf (stdout, "%s.zkey\n", reverse_pkey);
769 }
static char * reverse_pkey
Reverse lookup to perform.

References reverse_pkey, and reverse_qe.

Referenced by run_with_zone_pkey().

Here is the caller graph for this function:

◆ handle_reverse_lookup()

static void handle_reverse_lookup ( void *  cls,
const struct GNUNET_IDENTITY_PrivateKey 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 783 of file gnunet-namestore.c.

788 {
789  (void) cls;
790  (void) zone;
791  (void) rd_count;
792  (void) rd;
793  reverse_qe = NULL;
794  if (NULL == label)
795  fprintf (stdout, "%s\n", reverse_pkey);
796  else
797  fprintf (stdout, "%s.%s\n", label, ego_name);
798  test_finished ();
799 }
static char * zone
Name of the zone being managed.
static char * ego_name
Name of the ego controlling the zone.

References ego_name, reverse_pkey, reverse_qe, test_finished(), and zone.

Referenced by run_with_zone_pkey().

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 806 of file gnunet-namestore.c.

807 {
808  (void) cls;
809  del_qe = NULL;
810  GNUNET_break (0);
811  ret = 1;
812  test_finished ();
813 }

References del_qe, GNUNET_break, ret, and test_finished().

Referenced by run_with_zone_pkey().

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_IDENTITY_PrivateKey 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 828 of file gnunet-namestore.c.

833 {
834  struct GNUNET_GNSRECORD_Data rdx[rd_count];
835  unsigned int rd_left;
836  uint32_t type;
837  char *vs;
838 
839  (void) cls;
840  (void) zone;
841  del_qe = NULL;
842  if (0 == rd_count)
843  {
844  fprintf (stderr,
845  _ (
846  "There are no records under label `%s' that could be deleted.\n"),
847  label);
848  ret = 1;
849  test_finished ();
850  return;
851  }
852  if ((NULL == value) && (NULL == typestring))
853  {
854  /* delete everything */
856  &zone_pkey,
857  name,
858  0,
859  NULL,
861  NULL);
862  return;
863  }
864  rd_left = 0;
865  if (NULL != typestring)
867  else
869  for (unsigned int i = 0; i < rd_count; i++)
870  {
871  vs = NULL;
872  if (! (((GNUNET_GNSRECORD_TYPE_ANY == type) ||
873  (rd[i].record_type == type)) &&
874  ((NULL == value) ||
875  (NULL ==
877  rd[i].data,
878  rd[i].data_size)))) ||
879  (0 == strcmp (vs, value)))))
880  rdx[rd_left++] = rd[i];
881  GNUNET_free (vs);
882  }
883  if (rd_count == rd_left)
884  {
885  /* nothing got deleted */
886  fprintf (
887  stderr,
888  _ (
889  "There are no records under label `%s' that match the request for deletion.\n"),
890  label);
891  test_finished ();
892  return;
893  }
894  /* delete everything but what we copied to 'rdx' */
896  &zone_pkey,
897  name,
898  rd_left,
899  rdx,
901  NULL);
902 }
static void del_continuation(void *cls, int32_t success, const char *emsg)
Continuation called to notify client about result of the operation.
static char * value
Value of the record to add/remove.

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

Referenced by run_with_zone_pkey().

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 914 of file gnunet-namestore.c.

917 {
918  struct GNUNET_TIME_Relative etime_rel;
919  struct GNUNET_TIME_Absolute etime_abs;
920 
921  if (0 == strcmp (expirationstring, "never"))
922  {
923  *etime = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
925  return GNUNET_OK;
926  }
927  if (GNUNET_OK ==
929  {
931  *etime = etime_rel.rel_value_us;
933  "Storing record with relative expiration time of %s\n",
935  return GNUNET_OK;
936  }
937  if (GNUNET_OK ==
939  {
941  *etime = etime_abs.abs_value_us;
943  "Storing record with absolute expiration time of %s\n",
945  return GNUNET_OK;
946  }
947  return GNUNET_SYSERR;
948 }
static char * expirationstring
Desired expiration time.
@ GNUNET_OK
Definition: gnunet_common.h:95
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:284
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:326

References GNUNET_TIME_Absolute::abs_value_us, etime, etime_is_rel, expirationstring, 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_option(), and run_with_zone_pkey().

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 962 of file gnunet-namestore.c.

963 {
964  (void) cls;
965 
966  set_qe = NULL;
967  if (GNUNET_OK != success)
968  {
970  _ ("Failed to replace records: %s\n"),
971  emsg);
972  ret = 1; /* fail from 'main' */
973  }
975 }
@ GNUNET_ERROR_TYPE_MESSAGE

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

Referenced by run_with_zone_pkey().

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 985 of file gnunet-namestore.c.

986 {
987  struct GNUNET_GNSRECORD_Data rd;
988 
989  if (! (add | del | list | (NULL != nickstring) | (NULL != uri)
990  | (NULL != reverse_pkey) | (NULL != recordset)))
991  {
992  /* nothing more to be done */
993  fprintf (stderr, _ ("No options given\n"));
995  return;
996  }
998  if (NULL == ns)
999  {
1001  _ ("Failed to connect to namestore\n"));
1002  return;
1003  }
1004 
1005  if (NULL != recordset)
1006  {
1007  /* replace entire record set */
1008  unsigned int rd_count;
1009  struct GNUNET_GNSRECORD_Data *rd;
1010 
1011  if (NULL == name)
1012  {
1013  fprintf (stderr,
1014  _ ("Missing option `%s' for operation `%s'\n"),
1015  "-R",
1016  _ ("replace"));
1018  ret = 1;
1019  return;
1020  }
1021  rd_count = 0;
1022  for (struct RecordSetEntry *e = recordset; NULL != e; e = e->next)
1023  rd_count++;
1024  rd = GNUNET_new_array (rd_count, struct GNUNET_GNSRECORD_Data);
1025  rd_count = 0;
1026  for (struct RecordSetEntry *e = recordset; NULL != e; e = e->next)
1027  {
1028  rd[rd_count] = e->record;
1029  rd_count++;
1030  }
1032  &zone_pkey,
1033  name,
1034  rd_count,
1035  rd,
1036  &replace_cont,
1037  NULL);
1038  GNUNET_free (rd);
1039  return;
1040  }
1041  if (NULL != nickstring)
1042  {
1043  if (0 == strlen (nickstring))
1044  {
1045  fprintf (stderr, _ ("Invalid nick `%s'\n"), nickstring);
1047  ret = 1;
1048  return;
1049  }
1050  add = 1;
1055  is_public = 0;
1056  expirationstring = GNUNET_strdup ("never");
1058  nickstring = NULL;
1059  }
1060 
1061  if (add)
1062  {
1063  if (NULL == name)
1064  {
1065  fprintf (stderr,
1066  _ ("Missing option `%s' for operation `%s'\n"),
1067  "-n",
1068  _ ("add"));
1070  ret = 1;
1071  return;
1072  }
1073  if (NULL == typestring)
1074  {
1075  fprintf (stderr,
1076  _ ("Missing option `%s' for operation `%s'\n"),
1077  "-t",
1078  _ ("add"));
1080  ret = 1;
1081  return;
1082  }
1084  if (UINT32_MAX == type)
1085  {
1086  fprintf (stderr, _ ("Unsupported type `%s'\n"), typestring);
1088  ret = 1;
1089  return;
1090  }
1091  if ((GNUNET_DNSPARSER_TYPE_SRV == type) ||
1094  {
1095  fprintf (stderr,
1096  _ ("For DNS record types `SRV', `TLSA' and `OPENPGPKEY'"));
1097  fprintf (stderr, ", please use a `BOX' record instead\n");
1099  ret = 1;
1100  return;
1101  }
1102  if (NULL == value)
1103  {
1104  fprintf (stderr,
1105  _ ("Missing option `%s' for operation `%s'\n"),
1106  "-V",
1107  _ ("add"));
1108  ret = 1;
1110  return;
1111  }
1112  if (GNUNET_OK !=
1114  {
1115  fprintf (stderr,
1116  _ ("Value `%s' invalid for record type `%s'\n"),
1117  value,
1118  typestring);
1120  ret = 1;
1121  return;
1122  }
1123  if (NULL == expirationstring)
1124  {
1125  fprintf (stderr,
1126  _ ("Missing option `%s' for operation `%s'\n"),
1127  "-e",
1128  _ ("add"));
1130  ret = 1;
1131  return;
1132  }
1134  {
1135  fprintf (stderr, _ ("Invalid time format `%s'\n"), expirationstring);
1137  ret = 1;
1138  return;
1139  }
1141  &zone_pkey,
1142  name,
1143  &add_error_cb,
1144  NULL,
1146  NULL);
1147  }
1148  if (del)
1149  {
1150  if (NULL == name)
1151  {
1152  fprintf (stderr,
1153  _ ("Missing option `%s' for operation `%s'\n"),
1154  "-n",
1155  _ ("del"));
1157  ret = 1;
1158  return;
1159  }
1161  &zone_pkey,
1162  name,
1164  NULL,
1165  &del_monitor,
1166  NULL);
1167  }
1168  if (list)
1169  {
1170  if (NULL != name)
1172  &zone_pkey,
1173  name,
1174  &lookup_error_cb,
1175  NULL,
1177  NULL);
1178  else
1180  &zone_pkey,
1182  NULL,
1184  NULL,
1186  NULL);
1187  }
1188  if (NULL != reverse_pkey)
1189  {
1191 
1192  if (GNUNET_OK !=
1194  &pubkey))
1195  {
1196  fprintf (stderr,
1197  _ ("Invalid public key for reverse lookup `%s'\n"),
1198  reverse_pkey);
1200  }
1202  &zone_pkey,
1203  &pubkey,
1205  NULL,
1207  NULL);
1208  }
1209  if (NULL != uri)
1210  {
1211  char sh[105];
1212  char sname[64];
1214 
1216  if ((2 != (sscanf (uri, "gnunet://gns/%52s/%63s", sh, sname))) ||
1217  (GNUNET_OK !=
1219  {
1220  fprintf (stderr, _ ("Invalid URI `%s'\n"), uri);
1222  ret = 1;
1223  return;
1224  }
1225  if (NULL == expirationstring)
1226  {
1227  fprintf (stderr,
1228  _ ("Missing option `%s' for operation `%s'\n"),
1229  "-e",
1230  _ ("add"));
1232  ret = 1;
1233  return;
1234  }
1236  {
1237  fprintf (stderr, _ ("Invalid time format `%s'\n"), expirationstring);
1239  ret = 1;
1240  return;
1241  }
1242  memset (&rd, 0, sizeof(rd));
1243  rd.data = &pkey;
1245  rd.record_type = ntohl (pkey.type);
1246  rd.expiration_time = etime;
1247  if (GNUNET_YES == etime_is_rel)
1249  if (1 == is_shadow)
1252  &zone_pkey,
1253  sname,
1254  1,
1255  &rd,
1257  &add_qe_uri);
1258  }
1259  if (monitor)
1260  {
1262  &zone_pkey,
1263  GNUNET_YES,
1265  NULL,
1267  NULL,
1268  &sync_cb,
1269  NULL);
1270  }
1271 }
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
static struct Experiment * e
static struct SolverHandle * sh
static char * pkey
Public key of the zone to look in, in ASCII.
static struct GNUNET_IDENTITY_PublicKey pubkey
Public key of the zone to look in.
static void zone_iteration_finished(void *cls)
Function called when we are done with a zone iteration.
static void sync_cb(void *cls)
Function called once we are in sync in monitor mode.
static void del_lookup_error_cb(void *cls)
Function called if lookup for deletion fails.
static void display_record_monitor(void *cls, const struct GNUNET_IDENTITY_PrivateKey *zone_key, const char *rname, unsigned int rd_len, const struct GNUNET_GNSRECORD_Data *rd)
Process a record that was stored in the namestore.
static char * nickstring
Desired nick name.
static int monitor
Enables monitor mode.
static void replace_cont(void *cls, int success, const char *emsg)
Function called when namestore is done with the replace operation.
static int list
Desired action is to list records.
static void lookup_error_cb(void *cls)
Function called on errors while monitoring.
static struct RecordSetEntry * recordset
Entry in record set for processing records in bulk.
static void reverse_error_cb(void *cls)
Function called if we encountered an error in zone-to-name.
static void handle_reverse_lookup(void *cls, const struct GNUNET_IDENTITY_PrivateKey *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 get_existing_record(void *cls, const struct GNUNET_IDENTITY_PrivateKey *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 informati...
static int del
Desired action is to remove a record.
static void add_error_cb(void *cls)
Function called if lookup fails.
static int parse_expiration(const char *expirationstring, int *etime_is_rel, uint64_t *etime)
Parse expiration time.
static void monitor_error_cb(void *cls)
Function called on errors while monitoring.
static void display_record_iterator(void *cls, const struct GNUNET_IDENTITY_PrivateKey *zone_key, const char *rname, unsigned int rd_len, const struct GNUNET_GNSRECORD_Data *rd)
Process a record that was stored in the namestore.
static void del_monitor(void *cls, const struct GNUNET_IDENTITY_PrivateKey *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.
static void display_record_lookup(void *cls, const struct GNUNET_IDENTITY_PrivateKey *zone_key, const char *rname, unsigned int rd_len, const struct GNUNET_GNSRECORD_Data *rd)
Process a record that was stored in the namestore.
static int add
Desired action is to add a record.
static void zone_iteration_error_cb(void *cls)
Function called when we encountered an error in a zone iteration.
#define GNUNET_DNSPARSER_TYPE_OPENPGPKEY
#define GNUNET_DNSPARSER_TYPE_TLSA
#define GNUNET_DNSPARSER_TYPE_SRV
int GNUNET_GNSRECORD_string_to_value(uint32_t type, const char *s, void **data, size_t *data_size)
Convert human-readable version of a 'value' of a record to the binary representation.
Definition: gnsrecord.c:188
enum GNUNET_GenericReturnValue GNUNET_IDENTITY_public_key_from_string(const char *str, struct GNUNET_IDENTITY_PublicKey *key)
Parses a (Base32) string representation of the public key.
ssize_t GNUNET_IDENTITY_key_get_length(const struct GNUNET_IDENTITY_PublicKey *key)
Get the compacted length of a GNUNET_IDENTITY_PublicKey.
Definition: identity_api.c:976
@ GNUNET_ERROR_TYPE_ERROR
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
struct GNUNET_NAMESTORE_ZoneIterator * GNUNET_NAMESTORE_zone_iteration_start(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *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).
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_lookup(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *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.
struct GNUNET_NAMESTORE_Handle * GNUNET_NAMESTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the namestore service.
struct GNUNET_NAMESTORE_ZoneMonitor * GNUNET_NAMESTORE_zone_monitor_start(const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_IDENTITY_PrivateKey *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_zone_to_name(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *zone, const struct GNUNET_IDENTITY_PublicKey *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.
void GNUNET_STRINGS_utf8_tolower(const char *input, char *output)
Convert the utf-8 input string to lower case.
Definition: strings.c:444
An identity key as per LSD0001.
Entry in record set for bulk processing.

References _, add, add_continuation(), add_error_cb(), add_qe, add_qe_uri, cfg, GNUNET_GNSRECORD_Data::data, data, GNUNET_GNSRECORD_Data::data_size, data_size, del, del_lookup_error_cb(), del_monitor(), del_qe, 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(), get_qe, GNUNET_DNSPARSER_TYPE_OPENPGPKEY, GNUNET_DNSPARSER_TYPE_SRV, GNUNET_DNSPARSER_TYPE_TLSA, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_GNS_EMPTY_LABEL_AT, GNUNET_GNSRECORD_number_to_typename(), GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION, GNUNET_GNSRECORD_RF_SHADOW_RECORD, GNUNET_GNSRECORD_string_to_value(), GNUNET_GNSRECORD_TYPE_NICK, GNUNET_GNSRECORD_typename_to_number(), GNUNET_IDENTITY_key_get_length(), GNUNET_IDENTITY_public_key_from_string(), GNUNET_log, GNUNET_NAMESTORE_connect(), GNUNET_NAMESTORE_records_lookup(), GNUNET_NAMESTORE_records_store(), GNUNET_NAMESTORE_zone_iteration_start(), GNUNET_NAMESTORE_zone_monitor_start(), GNUNET_NAMESTORE_zone_to_name(), GNUNET_new_array, GNUNET_OK, GNUNET_SCHEDULER_shutdown(), GNUNET_strdup, GNUNET_STRINGS_utf8_tolower(), GNUNET_YES, handle_reverse_lookup(), is_public, is_shadow, list, list_it, lookup_error_cb(), monitor, monitor_error_cb(), name, nickstring, ns, parse_expiration(), pkey, pubkey, GNUNET_GNSRECORD_Data::record_type, recordset, replace_cont(), ret, reverse_error_cb(), reverse_pkey, reverse_qe, set_qe, sh, sync_cb(), type, typestring, uri, value, zm, zone_iteration_error_cb(), zone_iteration_finished(), and zone_pkey.

Referenced by identity_cb(), and run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ identity_cb()

static void identity_cb ( void *  cls,
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 1282 of file gnunet-namestore.c.

1283 {
1284  const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
1285 
1286  el = NULL;
1287  if ((NULL != name) && (0 != strchr (name, '.')))
1288  {
1289  fprintf (stderr,
1290  _ ("Label `%s' contains `.' which is not allowed\n"),
1291  name);
1293  ret = -1;
1294  return;
1295  }
1296 
1297  if (NULL == ego)
1298  {
1299  if (NULL != ego_name)
1300  {
1301  fprintf (stderr,
1302  _ ("Ego `%s' not known to identity service\n"),
1303  ego_name);
1304  }
1306  ret = -1;
1307  return;
1308  }
1311  ego_name = NULL;
1313 }
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.
const struct GNUNET_IDENTITY_PrivateKey * GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
Obtain the ECC key associated with a ego.
Definition: identity_api.c:639

References _, cfg, ego_name, el, GNUNET_free, 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().

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 1327 of file gnunet-namestore.c.

1331 {
1332  const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
1333 
1334  (void) ctx;
1335  (void) name;
1336  get_default = NULL;
1337  if (NULL == ego)
1338  {
1339  fprintf (stderr,
1340  _ ("No default identity configured for `namestore' subsystem\n"
1341  "Run gnunet-identity -s namestore -e $NAME to set the default to $NAME\n"
1342  "Run gnunet-identity -d to get a list of choices for $NAME\n"));
1344  ret = -1;
1345  return;
1346  }
1347  else
1348  {
1349  identity_cb ((void *) cfg, ego);
1350  }
1351 }
static void identity_cb(void *cls, struct GNUNET_IDENTITY_Ego *ego)
Callback invoked from identity service with ego information.
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.

References _, cfg, ctx, get_default, GNUNET_SCHEDULER_shutdown(), identity_cb(), name, and ret.

Referenced by id_connect_cb().

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 1367 of file gnunet-namestore.c.

1371 {
1372  const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
1373 
1374  (void) ctx;
1375  (void) name;
1376  if (NULL != ego)
1377  return;
1378  get_default =
1379  GNUNET_IDENTITY_get (idh, "namestore", &default_ego_cb, (void *) cfg);
1380 }
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 * 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:675

References cfg, ctx, default_ego_cb(), get_default, GNUNET_IDENTITY_get(), idh, and name.

Referenced by run().

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 1392 of file gnunet-namestore.c.

1396 {
1397  const char *pkey_str;
1398 
1399  (void) cls;
1400  (void) args;
1401  (void) cfgfile;
1402  if (NULL != args[0])
1403  GNUNET_log (
1405  _ ("Superfluous command line arguments (starting with `%s') ignored\n"),
1406  args[0]);
1407  if ((NULL != args[0]) && (NULL == uri))
1408  uri = GNUNET_strdup (args[0]);
1409 
1411  pkey_str = getenv ("GNUNET_NAMESTORE_EGO_PRIVATE_KEY");
1412  if (NULL != pkey_str)
1413  {
1414  if (GNUNET_OK != GNUNET_STRINGS_string_to_data (pkey_str,
1415  strlen (pkey_str),
1416  &zone_pkey,
1417  sizeof(zone_pkey)))
1418  {
1419  fprintf (stderr,
1420  "Malformed private key `%s' in $%s\n",
1421  pkey_str,
1422  "GNUNET_NAMESTORE_EGO_PRIVATE_KEY");
1423  ret = 1;
1425  return;
1426  }
1428  return;
1429  }
1430  if (NULL == ego_name)
1431  {
1433  if (NULL == idh)
1434  fprintf (stderr, _ ("Cannot connect to identity service\n"));
1435  ret = -1;
1436  return;
1437  }
1439 }
char * getenv()
static void do_shutdown(void *cls)
Task run on shutdown.
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...
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:610
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.
@ GNUNET_ERROR_TYPE_WARNING
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,...
Definition: scheduler.c:1331
enum GNUNET_GenericReturnValue GNUNET_STRINGS_string_to_data(const char *enc, size_t enclen, void *out, size_t out_size)
Convert CrockfordBase32 encoding back to data.
Definition: strings.c:775

References _, consensus-simulation::args, cfg, do_shutdown(), ego_name, el, 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(), idh, ret, run_with_zone_pkey(), uri, and zone_pkey.

Referenced by main().

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 1460 of file gnunet-namestore.c.

1464 {
1465  struct RecordSetEntry **head = scls;
1466  struct RecordSetEntry *r;
1468  char *cp;
1469  char *tok;
1470  char *saveptr;
1471  int etime_is_rel;
1472  void *raw_data;
1473 
1474  (void) ctx;
1475  (void) option;
1476  cp = GNUNET_strdup (value);
1477  tok = strtok_r (cp, " ", &saveptr);
1478  if (NULL == tok)
1479  {
1481  _ ("Empty record line argument is not allowed.\n"));
1482  GNUNET_free (cp);
1483  return GNUNET_SYSERR;
1484  }
1485  {
1486  char *etime_in_s;
1487 
1488  GNUNET_asprintf (&etime_in_s, "%s s", tok);
1489  if (GNUNET_OK !=
1490  parse_expiration (etime_in_s, &etime_is_rel, &record.expiration_time))
1491  {
1493  _ ("Invalid expiration time `%s' (must be without unit)\n"),
1494  tok);
1495  GNUNET_free (cp);
1496  GNUNET_free (etime_in_s);
1497  return GNUNET_SYSERR;
1498  }
1499  GNUNET_free (etime_in_s);
1500  }
1501  tok = strtok_r (NULL, " ", &saveptr);
1502  if (NULL == tok)
1503  {
1505  _ ("Missing entries in record line `%s'.\n"),
1506  value);
1507  GNUNET_free (cp);
1508  return GNUNET_SYSERR;
1509  }
1510  record.record_type = GNUNET_GNSRECORD_typename_to_number (tok);
1511  if (UINT32_MAX == record.record_type)
1512  {
1513  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _ ("Unknown record type `%s'\n"), tok);
1514  GNUNET_free (cp);
1515  return GNUNET_SYSERR;
1516  }
1517  tok = strtok_r (NULL, " ", &saveptr);
1518  if (NULL == tok)
1519  {
1521  _ ("Missing entries in record line `%s'.\n"),
1522  value);
1523  GNUNET_free (cp);
1524  return GNUNET_SYSERR;
1525  }
1527  if (etime_is_rel)
1529  if (NULL == strchr (tok, (unsigned char) 'p')) /* p = public */
1531  if (NULL != strchr (tok, (unsigned char) 's'))
1533  /* find beginning of record value */
1534  tok = strchr (&value[tok - cp], (unsigned char) ' ');
1535  if (NULL == tok)
1536  {
1538  _ ("Missing entries in record line `%s'.\n"),
1539  value);
1540  GNUNET_free (cp);
1541  return GNUNET_SYSERR;
1542  }
1543  GNUNET_free (cp);
1544  tok++; /* skip space */
1546  tok,
1547  &raw_data,
1548  &record.data_size))
1549  {
1551  _ ("Invalid record data for type %s: `%s'.\n"),
1553  tok);
1554  return GNUNET_SYSERR;
1555  }
1556 
1557  r = GNUNET_malloc (sizeof(struct RecordSetEntry) + record.data_size);
1558  r->next = *head;
1559  record.data = &r[1];
1560  memcpy (&r[1], raw_data, record.data_size);
1561  GNUNET_free (raw_data);
1562  r->record = record;
1563  *head = r;
1564  return GNUNET_OK;
1565 }
static struct PendingResolutions * head
Head of list of pending resolution requests.
Definition: gnunet-ats.c:230
static void record(void *cls, size_t data_size, const void *data)
Process recorded audio data.
@ GNUNET_GNSRECORD_RF_NONE
No special options.
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_malloc(size)
Wrapper around malloc.
struct GNUNET_GNSRECORD_Data record
The record to add/remove.
struct RecordSetEntry * next
Kept in a linked list.

◆ 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 1460 of file gnunet-namestore.c.

1583 {
1585  .name = name,
1586  .argumentHelp = argumentHelp,
1587  .description = description,
1588  .require_argument = 1,
1589  .processor =
1591  .scls = (void *) rs };
1592 
1593  return clo;
1594 }
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...
Definition of a command line option.
const char * description
Help text for the option (description)
const char * argumentHelp
Name of the argument for the user in help text.
const char shortName
Short name of the option.

References _, ctx, etime_is_rel, 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(), record(), RecordSetEntry::record, and value.

Referenced by main().

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 1605 of file gnunet-namestore.c.

1606 {
1608  { GNUNET_GETOPT_option_flag ('a', "add", gettext_noop ("add record"), &add),
1610  "delete",
1611  gettext_noop ("delete record"),
1612  &del),
1614  "display",
1615  gettext_noop ("display records"),
1616  &list),
1618  'e',
1619  "expiration",
1620  "TIME",
1621  gettext_noop (
1622  "expiration time for record to use (for adding only), \"never\" is possible"),
1623  &expirationstring),
1625  "nick",
1626  "NICKNAME",
1627  gettext_noop (
1628  "set the desired nick name for the zone"),
1629  &nickstring),
1631  "monitor",
1632  gettext_noop (
1633  "monitor changes in the namestore"),
1634  &monitor),
1636  "name",
1637  "NAME",
1638  gettext_noop (
1639  "name of the record to add/delete/display"),
1640  &name),
1642  "reverse",
1643  "PKEY",
1644  gettext_noop (
1645  "determine our name for the given PKEY"),
1646  &reverse_pkey),
1648  'R',
1649  "replace",
1650  "RECORDLINE",
1651  gettext_noop (
1652  "set record set to values given by (possibly multiple) RECORDLINES; can be specified multiple times"),
1653  &recordset),
1655  "type",
1656  "TYPE",
1657  gettext_noop (
1658  "type of the record to add/delete/display"),
1659  &typestring),
1661  "uri",
1662  "URI",
1663  gettext_noop ("URI to import into our zone"),
1664  &uri),
1666  "value",
1667  "VALUE",
1668  gettext_noop (
1669  "value of the record to add/delete"),
1670  &value),
1672  "public",
1673  gettext_noop ("create or list public record"),
1674  &is_public),
1676  's',
1677  "shadow",
1678  gettext_noop (
1679  "create shadow record (only valid if all other records of the same type have expired"),
1680  &is_shadow),
1682  "zone",
1683  "EGO",
1684  gettext_noop (
1685  "name of the ego controlling the zone"),
1686  &ego_name),
1688  int lret;
1689 
1690  if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
1691  return 2;
1692 
1693  is_public = -1;
1694  is_shadow = -1;
1695  GNUNET_log_setup ("gnunet-namestore", "WARNING", NULL);
1696  if (GNUNET_OK !=
1697  (lret = GNUNET_PROGRAM_run (argc,
1698  argv,
1699  "gnunet-namestore",
1700  _ ("GNUnet zone manipulation tool"),
1701  options,
1702  &run,
1703  NULL)))
1704  {
1705  GNUNET_free_nz ((void *) argv);
1706  //FIXME
1707  //GNUNET_CRYPTO_ecdsa_key_clear (&zone_pkey);
1708  return lret;
1709  }
1710  GNUNET_free_nz ((void *) argv);
1711  //FIXME
1712  //GNUNET_CRYPTO_ecdsa_key_clear (&zone_pkey);
1713  return ret;
1714 }
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
#define gettext_noop(String)
Definition: gettext.h:69
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.
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
Main function that will be run.
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.
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.
int GNUNET_log_setup(const char *comp, const char *loglevel, const char *logfile)
Setup logging.
#define GNUNET_free_nz(ptr)
Wrapper around free.
enum GNUNET_GenericReturnValue 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,...
Definition: program.c:364
enum GNUNET_GenericReturnValue GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
Definition: strings.c:1209

References _, add, del, ego_name, expirationstring, gettext_noop, GNUNET_free_nz, 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(), name, nickstring, options, recordset, ret, reverse_pkey, run(), typestring, uri, and value.

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.

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

◆ zone_pkey

struct GNUNET_IDENTITY_PrivateKey zone_pkey
static

Private key for the our zone.

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

Referenced by del_monitor(), do_shutdown(), get_existing_record(), identity_cb(), 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.

Referenced by do_shutdown(), identity_cb(), and run().

◆ idh

struct GNUNET_IDENTITY_Handle* idh
static

Identity service handle.

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

Referenced by do_shutdown(), id_connect_cb(), and run().

◆ get_default

struct GNUNET_IDENTITY_Operation* get_default

Obtain default ego.

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

Referenced by default_ego_cb(), do_shutdown(), and id_connect_cb().

◆ 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

◆ 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.

Referenced by do_shutdown(), run_with_zone_pkey(), and test_finished().

◆ add_qe

struct GNUNET_NAMESTORE_QueueEntry* add_qe
static

Queue entry for the 'add' operation.

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

Referenced by add_error_cb(), do_shutdown(), get_existing_record(), run_with_zone_pkey(), and test_finished().

◆ get_qe

struct GNUNET_NAMESTORE_QueueEntry* get_qe
static

Queue entry for the 'lookup' operation.

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

Referenced by display_record_lookup(), do_shutdown(), lookup_error_cb(), run_with_zone_pkey(), and test_finished().

◆ 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.

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

◆ 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

◆ del

int del
static

Desired action is to remove a record.

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

Referenced by forward_resolution(), GNUNET_ABD_delegate_issue(), handle_delegate_collection_cb(), main(), run_with_zone_pkey(), and send_lookup_response().

◆ 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(), main(), and run_with_zone_pkey().

◆ 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.

Referenced by del_continuation(), del_lookup_error_cb(), del_monitor(), do_shutdown(), run_with_zone_pkey(), and test_finished().

◆ 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.

Referenced by do_shutdown(), replace_cont(), and run_with_zone_pkey().

◆ name

char* name
static

Name of the records to add/list/remove.

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

Referenced by default_ego_cb(), del_monitor(), display_record(), get_existing_record(), id_connect_cb(), identity_cb(), main(), 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_known_to_bloom(), add_section_contents(), add_sections(), add_setter_action(), add_to_tc(), age_values(), attr_in_claims_request(), auto_conf_iter(), bandwidth_stats_iterator(), barrier_destroy_iterator(), bind_loose_channel(), blacklist_cfg_iter(), build_result_set(), cache_clear_iterator(), call_iterator(), cancel_pending_request(), cfg_copy_iterator(), change_peer_respect(), channel_destroy_iterator(), check_connection_quality(), check_known_address(), check_known_challenge(), check_validation_request_pending(), check_vectors(), clean_local_client(), clean_request(), cleanup_channel(), cleanup_destination(), cleanup_hashmap(), cleanup_iterator(), cleanup_url_map(), cleanup_validation_entry(), client_disconnect_it(), client_release_ports(), close_files_iter(), collector(), compare_entries(), compute_service_response(), compute_square_sum_mpi_elements(), con_val_iter(), consume_cont(), cookie_identity_interpretation(), copy_element_cb(), copy_entry(), create_randomized_element_iterator(), database_setup(), debug_channel(), decrementBit(), del_monitor(), delete_entries(), delete_value(), 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(), determinate_avg_element_size_iterator(), determinate_done_message_iterator(), disconnect_all_neighbours(), disconnect_and_free_it(), disconnect_and_free_peer_entry(), dns_string_to_value(), dns_value_to_string(), do_flood(), do_notify(), do_restart_typemap_message(), drop_client_entries(), dv_neighbour_selection(), dv_neighbour_transmission(), 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(), format_help(), 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_element_cb(), free_entry(), free_host_entry(), free_item(), free_iterate(), free_matching_requests(), free_neighbour_cb(), free_peer(), free_pending_ack_cb(), free_preference(), free_reassembly_cb(), free_request(), free_request_it(), free_result(), free_service_record(), free_sug_handle(), free_tmps(), free_tracker(), free_validation_state_cb(), free_value(), free_waiting_entry(), full_sync_plausibility_check(), get_active_address_it(), get_all_peers_iterator(), get_all_tunnels_iterator(), get_cb(), get_iterator(), get_lt_delete_it(), get_queue_delete_it(), get_rand_peer_iterator(), get_receiver_delete_it(), get_result_present(), get_sender_delete_it(), get_session_delete_it(), get_url_parameter_copy(), GNUNET_CONFIGURATION_append_value_filename(), GNUNET_CONFIGURATION_config_tool_run(), GNUNET_CONFIGURATION_set_value_string(), GNUNET_CONTAINER_multihashmap32_contains_value(), GNUNET_CONTAINER_multihashmap32_iterator_next(), GNUNET_CONTAINER_multihashmap32_put(), GNUNET_CONTAINER_multihashmap32_remove(), GNUNET_CONTAINER_multihashmap_contains_value(), GNUNET_CONTAINER_multihashmap_iterator_next(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_multihashmap_remove(), GNUNET_CONTAINER_multipeermap_contains_value(), GNUNET_CONTAINER_multipeermap_iterator_next(), GNUNET_CONTAINER_multipeermap_put(), GNUNET_CONTAINER_multipeermap_remove(), GNUNET_CONTAINER_multishortmap_contains_value(), GNUNET_CONTAINER_multishortmap_iterator_next(), GNUNET_CONTAINER_multishortmap_put(), GNUNET_CONTAINER_multishortmap_remove(), GNUNET_CONTAINER_multiuuidmap_contains_value(), GNUNET_CONTAINER_multiuuidmap_iterator_next(), GNUNET_CONTAINER_multiuuidmap_put(), GNUNET_CONTAINER_multiuuidmap_remove(), GNUNET_FS_GETOPT_KEYWORDS(), GNUNET_FS_GETOPT_METADATA(), GNUNET_GETOPT_option_absolute_time(), GNUNET_GETOPT_option_cfgfile(), GNUNET_GETOPT_option_flag(), GNUNET_GETOPT_option_increment_uint(), GNUNET_GETOPT_option_loglevel(), GNUNET_GETOPT_option_relative_time(), GNUNET_GETOPT_option_timetravel(), GNUNET_GETOPT_option_uint(), GNUNET_GETOPT_option_uint16(), GNUNET_GETOPT_option_ulong(), GNUNET_GETOPT_option_version(), GNUNET_JSON_getopt(), GNUNET_NETWORK_socket_disable_corking(), GNUNET_PEERSTORE_store(), GNUNET_STATISTICS_set(), GNUNET_TESTING_get_topo_from_file(), GSF_cadet_release_clients(), handle_ack(), handle_alice_client_message(), handle_bob_client_message(), handle_set(), hash_hosts(), header_iterator(), 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(), inspect_attrs(), iterate_addresses(), iterate_channels_cb(), iterate_close_room(), iterate_copy_history(), iterate_destroy_contacts(), iterate_destroy_egos(), iterate_destroy_entries(), iterate_destroy_links(), iterate_destroy_members(), iterate_destroy_message(), iterate_destroy_messages(), iterate_destroy_operations(), iterate_destroy_room(), iterate_destroy_rooms(), iterate_destroy_session(), iterate_destroy_tunnels(), iterate_entries(), iterate_find_member(), iterate_find_room(), iterate_free_member_ids(), iterate_load_next_member_sessions(), iterate_load_next_session(), iterate_local_members(), iterate_member_sessions_it(), iterate_reachables(), iterate_reset_room(), iterate_save_entries(), iterate_save_links(), iterate_save_member_session_history_hentries(), iterate_save_members(), iterate_save_messages(), iterate_save_operations(), iterate_save_rooms(), iterate_save_session(), iterate_search_session(), iterate_send_room_message(), iterate_store_members_it(), iterate_sync_member_contacts(), iterate_sync_session_contact(), iterate_zones(), iterator(), iterator_bf_create(), iterator_bf_reduce(), iterator_cb(), jwt_parse_attributes(), locate_by_id(), log_namespaces(), log_nodes(), lookup_queue_it(), lookup_session_it(), main(), make_json(), mark_match_down(), mark_peer_down(), migrate_and_drop_keywords(), migrate_and_drop_metadata(), move_to_pending(), move_to_queue(), mpi_to_sexp(), multirecord_option(), neighbour_delete(), neighbours_iterate(), nibble_to_regex(), node_connections(), normalize_address(), notify_change(), notify_client_about_session(), notify_client_connect_info(), notify_client_queues(), notify_tunnel_up_cb(), num_to_regex(), op_get_element_iterator(), opc_free_iterator(), opc_search_iterator(), open_port_cb(), parse_jwt(), parse_record(), parse_record_data(), peerinfo_it(), peermap_clear_iterator(), PEERSTORE_create_record_mq_envelope(), peerstore_flat_store_record(), peerstore_sqlite_store_record(), prepare_ibf_iterator(), print_option(), printer(), printer_watch(), process(), process_client_result(), process_reply(), process_result_with_request(), process_stat(), process_stat_in(), process_stats(), process_update_node(), put_cb(), rcop_cleanup_iterator(), reachability_iterator(), read_service_conf(), regex_cancel_dht_get(), regex_free_result(), regex_result_iterator(), reghost_free_iterator(), register_notify(), remove_all(), remove_by_unique_id(), remove_iterator(), reschedule_hellos(), rewatch_it(), rsa_sign_mpi(), 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_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_base32(), set_cont(), set_insert_iterator(), set_value(), signal_result_resume(), socket_set_nodelay(), stat_iterator(), statistics_cb(), statistics_result(), stats_iterator(), stop_peer_request(), store_and_free_entries(), store_peer_presistently_iterator(), stun_attr2str(), stun_msg2str(), sum_relative_preferences(), test_blacklisted(), test_exist_cb(), test_result_present(), ticket_collect(), tld_iter(), transmit_client_response(), transmit_suggestion(), try_add_peers(), try_combine_recent(), update_abs_sum(), update_config(), update_desire_strength(), update_flood_times(), update_iterator(), update_rel_sum(), update_sre_result_maps(), url_iterator(), valid_peer_iterator(), 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(), 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(), parse_expiration(), 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

Number of bytes in data.

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

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

◆ etime

uint64_t etime
static

Expiration string converted to numeric value.

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

Referenced by get_existing_record(), parse_expiration(), 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_option(), parse_expiration(), 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.

Referenced by main(), and run_with_zone_pkey().