GNUnet  0.17.6
Data Structures | Macros | 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...
 

Macros

#define WARN_RELATIVE_EXPIRATION_LIMIT
 The upper bound for the zone iteration interval (per record). 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.

Macro Definition Documentation

◆ WARN_RELATIVE_EXPIRATION_LIMIT

#define WARN_RELATIVE_EXPIRATION_LIMIT
Value:
#define GNUNET_TIME_UNIT_MINUTES
One minute.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
Definition: time.c:483

The upper bound for the zone iteration interval (per record).

Definition at line 40 of 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 237 of file gnunet-namestore.c.

238 {
239  (void) cls;
240  if (NULL != get_default)
241  {
243  get_default = NULL;
244  }
245  if (NULL != idh)
246  {
248  idh = NULL;
249  }
250  if (NULL != el)
251  {
253  el = NULL;
254  }
255  if (NULL != list_it)
256  {
258  list_it = NULL;
259  }
260  if (NULL != add_qe)
261  {
263  add_qe = NULL;
264  }
265  if (NULL != set_qe)
266  {
268  set_qe = NULL;
269  }
270  if (NULL != add_qe_uri)
271  {
273  add_qe_uri = NULL;
274  }
275  if (NULL != get_qe)
276  {
278  get_qe = NULL;
279  }
280  if (NULL != del_qe)
281  {
283  del_qe = NULL;
284  }
285  if (NULL != ns)
286  {
288  ns = NULL;
289  }
290  memset (&zone_pkey, 0, sizeof(zone_pkey));
291  if (NULL != uri)
292  {
293  GNUNET_free (uri);
294  uri = NULL;
295  }
296  if (NULL != zm)
297  {
299  zm = NULL;
300  }
301  if (NULL != data)
302  {
303  GNUNET_free (data);
304  data = NULL;
305  }
306 }
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 313 of file gnunet-namestore.c.

314 {
315  if ((NULL == add_qe) && (NULL == add_qe_uri) && (NULL == get_qe) &&
316  (NULL == del_qe) && (NULL == reverse_qe) && (NULL == list_it))
318 }
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:533

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

333 {
334  struct GNUNET_NAMESTORE_QueueEntry **qe = cls;
335 
336  *qe = NULL;
337  if (GNUNET_YES != success)
338  {
339  fprintf (stderr,
340  _ ("Adding record failed: %s\n"),
341  (GNUNET_NO == success) ? "record exists" : emsg);
342  if (GNUNET_NO != success)
343  ret = 1;
344  }
345  ret = 0;
346  test_finished ();
347 }
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
@ GNUNET_NO
Definition: gnunet_common.h:98
#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 361 of file gnunet-namestore.c.

362 {
363  (void) cls;
364  del_qe = NULL;
365  if (GNUNET_NO == success)
366  {
367  fprintf (stderr,
368  _ ("Deleting record failed, record does not exist%s%s\n"),
369  (NULL != emsg) ? ": " : "",
370  (NULL != emsg) ? emsg : "");
371  }
372  if (GNUNET_SYSERR == success)
373  {
374  fprintf (stderr,
375  _ ("Deleting record failed%s%s\n"),
376  (NULL != emsg) ? ": " : "",
377  (NULL != emsg) ? emsg : "");
378  }
379  test_finished ();
380 }
@ GNUNET_SYSERR
Definition: gnunet_common.h:97

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

388 {
389  (void) cls;
390  list_it = NULL;
391  test_finished ();
392 }

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

400 {
401  (void) cls;
402  list_it = NULL;
403  fprintf (stderr, "Error iterating over zone\n");
404  ret = 1;
405  test_finished ();
406 }

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

420 {
421  const char *typestr;
422  char *s;
423  const char *ets;
424  struct GNUNET_TIME_Absolute at;
425  struct GNUNET_TIME_Relative rt;
426  int have_record;
427 
428  if ((NULL != name) && (0 != strcmp (name, rname)))
429  {
431  return;
432  }
433  have_record = GNUNET_NO;
434  for (unsigned int i = 0; i < rd_len; i++)
435  {
436  if ((GNUNET_GNSRECORD_TYPE_NICK == rd[i].record_type) &&
437  (0 != strcmp (rname, GNUNET_GNS_EMPTY_LABEL_AT)))
438  continue;
439  if (GNUNET_GNSRECORD_TYPE_TOMBSTONE == rd[i].record_type)
440  continue;
441  if ((type != rd[i].record_type) && (GNUNET_GNSRECORD_TYPE_ANY != type))
442  continue;
443  have_record = GNUNET_YES;
444  break;
445  }
446  if (GNUNET_NO == have_record)
447  return;
448  fprintf (stdout, "%s:\n", rname);
449  if (NULL != typestring)
451  else
453  for (unsigned int i = 0; i < rd_len; i++)
454  {
455  if ((GNUNET_GNSRECORD_TYPE_NICK == rd[i].record_type) &&
456  (0 != strcmp (rname, GNUNET_GNS_EMPTY_LABEL_AT)))
457  continue;
458  if (GNUNET_GNSRECORD_TYPE_TOMBSTONE == rd[i].record_type)
459  continue;
460  if ((type != rd[i].record_type) && (GNUNET_GNSRECORD_TYPE_ANY != type))
461  continue;
462  typestr = GNUNET_GNSRECORD_number_to_typename (rd[i].record_type);
463  s = GNUNET_GNSRECORD_value_to_string (rd[i].record_type,
464  rd[i].data,
465  rd[i].data_size);
466  if (NULL == s)
467  {
468  fprintf (stdout,
469  _ ("\tCorrupt or unsupported record of type %u\n"),
470  (unsigned int) rd[i].record_type);
471  continue;
472  }
473  if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION))
474  {
475  rt.rel_value_us = rd[i].expiration_time;
477  }
478  else
479  {
480  at.abs_value_us = rd[i].expiration_time;
482  }
483  fprintf (stdout,
484  "\t%s: %s (%s)\t%s\t%s\n",
485  typestr,
486  s,
487  ets,
488  (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE)) ? "PRIVATE"
489  : "PUBLIC",
490  (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_SHADOW_RECORD)) ? "SHADOW"
491  : "");
492  GNUNET_free (s);
493  }
494  fprintf (stdout, "%s", "\n");
495 }
#define GNUNET_GNSRECORD_TYPE_NICK
GNS nick names.
#define GNUNET_GNSRECORD_TYPE_TOMBSTONE
Record type to indicate a previously delete record (PRIVATE only)
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.
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_GNS_EMPTY_LABEL_AT
String we use to indicate an empty label (top-level entry in the zone).
#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:617
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:570
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_TYPE_TOMBSTONE, 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 508 of file gnunet-namestore.c.

513 {
514  (void) cls;
515  (void) zone_key;
516  display_record (rname, rd_len, rd);
518 }
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 531 of file gnunet-namestore.c.

536 {
537  (void) cls;
538  (void) zone_key;
539  display_record (rname, rd_len, rd);
541 }
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 554 of file gnunet-namestore.c.

559 {
560  (void) cls;
561  (void) zone_key;
562  get_qe = NULL;
563  display_record (rname, rd_len, rd);
564  test_finished ();
565 }

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

575 {
576  (void) cls;
577  fprintf (stdout, "%s", "Monitor is now in sync.\n");
578 }

Referenced by GNUNET_NAMESTORE_zone_monitor_start(), GNUNET_NAMESTORE_zone_monitor_start2(), 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 587 of file gnunet-namestore.c.

588 {
589  (void) cls;
590  fprintf (stderr, "%s", "Monitor disconnected and out of sync.\n");
591 }

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

601 {
602  (void) cls;
603  get_qe = NULL;
604  fprintf (stderr, "%s", "Failed to lookup record.\n");
605  test_finished ();
606 }

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

614 {
615  (void) cls;
616  add_qe = NULL;
617  GNUNET_break (0);
618  ret = 1;
619  test_finished ();
620 }
#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 634 of file gnunet-namestore.c.

639 {
640  struct GNUNET_GNSRECORD_Data rdn[rd_count + 1];
641  struct GNUNET_GNSRECORD_Data *rde;
642 
643  (void) cls;
644  (void) zone_key;
645  add_qe = NULL;
646  if (0 != strcmp (rec_name, name))
647  {
648  GNUNET_break (0);
649  ret = 1;
650  test_finished ();
651  return;
652  }
653 
655  "Received %u records for name `%s'\n",
656  rd_count,
657  rec_name);
658  for (unsigned int i = 0; i < rd_count; i++)
659  {
660  switch (rd[i].record_type)
661  {
664  {
665  fprintf (
666  stderr,
667  _ (
668  "A SOA record exists already under `%s', cannot add a second SOA to the same zone.\n"),
669  rec_name);
670  ret = 1;
671  test_finished ();
672  return;
673  }
674  break;
675  }
676  }
677  memset (rdn, 0, sizeof(struct GNUNET_GNSRECORD_Data));
678  GNUNET_memcpy (&rdn[1], rd, rd_count * sizeof(struct GNUNET_GNSRECORD_Data));
679  rde = &rdn[0];
680  rde->data = data;
681  rde->data_size = data_size;
682  rde->record_type = type;
683  if (1 == is_shadow)
685  if (1 != is_public)
687  rde->expiration_time = etime;
688  if (GNUNET_YES == etime_is_rel)
690  else if (GNUNET_NO != etime_is_rel)
691  rde->expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
692  GNUNET_assert (NULL != name);
694  &zone_pkey,
695  name,
696  rd_count + 1,
697  rde,
699  &add_qe);
700 }
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_DNSPARSER_TYPE_SOA
#define GNUNET_log(kind,...)
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#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_SOA, GNUNET_ERROR_TYPE_DEBUG, GNUNET_GNSRECORD_RF_PRIVATE, GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION, GNUNET_GNSRECORD_RF_SHADOW_RECORD, 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 707 of file gnunet-namestore.c.

708 {
709  (void) cls;
710  reverse_qe = NULL;
711  fprintf (stdout, "%s.zkey\n", reverse_pkey);
712 }
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 726 of file gnunet-namestore.c.

731 {
732  (void) cls;
733  (void) zone;
734  (void) rd_count;
735  (void) rd;
736  reverse_qe = NULL;
737  if (NULL == label)
738  fprintf (stdout, "%s\n", reverse_pkey);
739  else
740  fprintf (stdout, "%s.%s\n", label, ego_name);
741  test_finished ();
742 }
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 749 of file gnunet-namestore.c.

750 {
751  (void) cls;
752  del_qe = NULL;
753  GNUNET_break (0);
754  ret = 1;
755  test_finished ();
756 }

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

776 {
777  struct GNUNET_GNSRECORD_Data rdx[rd_count];
778  unsigned int rd_left;
779  uint32_t type;
780  char *vs;
781 
782  (void) cls;
783  (void) zone;
784  del_qe = NULL;
785  if (0 == rd_count)
786  {
787  fprintf (stderr,
788  _ (
789  "There are no records under label `%s' that could be deleted.\n"),
790  label);
791  ret = 1;
792  test_finished ();
793  return;
794  }
795  if ((NULL == value) && (NULL == typestring))
796  {
797  /* delete everything */
799  &zone_pkey,
800  name,
801  0,
802  NULL,
804  NULL);
805  return;
806  }
807  rd_left = 0;
808  if (NULL != typestring)
810  else
812  for (unsigned int i = 0; i < rd_count; i++)
813  {
814  vs = NULL;
815  if (! (((GNUNET_GNSRECORD_TYPE_ANY == type) ||
816  (rd[i].record_type == type)) &&
817  ((NULL == value) ||
818  (NULL ==
820  rd[i].data,
821  rd[i].data_size)))) ||
822  (0 == strcmp (vs, value)))))
823  rdx[rd_left++] = rd[i];
824  GNUNET_free (vs);
825  }
826  if (rd_count == rd_left)
827  {
828  /* nothing got deleted */
829  fprintf (
830  stderr,
831  _ (
832  "There are no records under label `%s' that match the request for deletion.\n"),
833  label);
834  test_finished ();
835  return;
836  }
837  /* delete everything but what we copied to 'rdx' */
839  &zone_pkey,
840  name,
841  rd_left,
842  rdx,
844  NULL);
845 }
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 857 of file gnunet-namestore.c.

860 {
861  struct GNUNET_TIME_Relative etime_rel;
862  struct GNUNET_TIME_Absolute etime_abs;
863 
864  if (0 == strcmp (expirationstring, "never"))
865  {
866  *etime = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
868  return GNUNET_OK;
869  }
870  if (GNUNET_OK ==
872  {
874  *etime = etime_rel.rel_value_us;
876  {
878  "Relative expiration times of less than %s are not recommended. To improve availability, consider increasing this value.\n",
881  }
883  "Storing record with relative expiration time of %s\n",
885  return GNUNET_OK;
886  }
887  if (GNUNET_OK ==
889  {
891  *etime = etime_abs.abs_value_us;
893  "Storing record with absolute expiration time of %s\n",
895  return GNUNET_OK;
896  }
897  return GNUNET_SYSERR;
898 }
#define WARN_RELATIVE_EXPIRATION_LIMIT
The upper bound for the zone iteration interval (per record).
static char * expirationstring
Desired expiration time.
@ GNUNET_OK
Definition: gnunet_common.h:99
@ GNUNET_ERROR_TYPE_WARNING
enum GNUNET_GenericReturnValue 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:261
#define GNUNET_TIME_relative_cmp(t1, op, t2)
Compare two relative times.
enum GNUNET_GenericReturnValue 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:303

References GNUNET_TIME_Absolute::abs_value_us, etime, etime_is_rel, expirationstring, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, 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_relative_cmp, GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_YES, GNUNET_TIME_Relative::rel_value_us, and WARN_RELATIVE_EXPIRATION_LIMIT.

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

913 {
914  (void) cls;
915 
916  set_qe = NULL;
917  if (GNUNET_OK != success)
918  {
920  _ ("Failed to replace records: %s\n"),
921  emsg);
922  ret = 1; /* fail from 'main' */
923  }
925 }
@ 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 935 of file gnunet-namestore.c.

936 {
937  struct GNUNET_GNSRECORD_Data rd;
938 
939  if (! (add | del | list | (NULL != nickstring) | (NULL != uri)
940  | (NULL != reverse_pkey) | (NULL != recordset)))
941  {
942  /* nothing more to be done */
943  fprintf (stderr, _ ("No options given\n"));
945  return;
946  }
948  if (NULL == ns)
949  {
951  _ ("Failed to connect to namestore\n"));
952  return;
953  }
954 
955  if (NULL != recordset)
956  {
957  /* replace entire record set */
958  unsigned int rd_count;
959  struct GNUNET_GNSRECORD_Data *rd;
960 
961  if (NULL == name)
962  {
963  fprintf (stderr,
964  _ ("Missing option `%s' for operation `%s'\n"),
965  "-R",
966  _ ("replace"));
968  ret = 1;
969  return;
970  }
971  rd_count = 0;
972  for (struct RecordSetEntry *e = recordset; NULL != e; e = e->next)
973  rd_count++;
974  rd = GNUNET_new_array (rd_count, struct GNUNET_GNSRECORD_Data);
975  rd_count = 0;
976  for (struct RecordSetEntry *e = recordset; NULL != e; e = e->next)
977  {
978  rd[rd_count] = e->record;
979  rd_count++;
980  }
982  &zone_pkey,
983  name,
984  rd_count,
985  rd,
986  &replace_cont,
987  NULL);
988  GNUNET_free (rd);
989  return;
990  }
991  if (NULL != nickstring)
992  {
993  if (0 == strlen (nickstring))
994  {
995  fprintf (stderr, _ ("Invalid nick `%s'\n"), nickstring);
997  ret = 1;
998  return;
999  }
1000  add = 1;
1005  is_public = 0;
1006  expirationstring = GNUNET_strdup ("never");
1008  nickstring = NULL;
1009  }
1010 
1011  if (add)
1012  {
1013  if (NULL == name)
1014  {
1015  fprintf (stderr,
1016  _ ("Missing option `%s' for operation `%s'\n"),
1017  "-n",
1018  _ ("add"));
1020  ret = 1;
1021  return;
1022  }
1023  if (NULL == typestring)
1024  {
1025  fprintf (stderr,
1026  _ ("Missing option `%s' for operation `%s'\n"),
1027  "-t",
1028  _ ("add"));
1030  ret = 1;
1031  return;
1032  }
1034  if (UINT32_MAX == type)
1035  {
1036  fprintf (stderr, _ ("Unsupported type `%s'\n"), typestring);
1038  ret = 1;
1039  return;
1040  }
1041  if ((GNUNET_DNSPARSER_TYPE_SRV == type) ||
1044  {
1045  fprintf (stderr,
1046  _ ("For DNS record types `SRV', `TLSA' and `OPENPGPKEY'"));
1047  fprintf (stderr, ", please use a `BOX' record instead\n");
1049  ret = 1;
1050  return;
1051  }
1052  if (NULL == value)
1053  {
1054  fprintf (stderr,
1055  _ ("Missing option `%s' for operation `%s'\n"),
1056  "-V",
1057  _ ("add"));
1058  ret = 1;
1060  return;
1061  }
1062  if (GNUNET_OK !=
1064  {
1065  fprintf (stderr,
1066  _ ("Value `%s' invalid for record type `%s'\n"),
1067  value,
1068  typestring);
1070  ret = 1;
1071  return;
1072  }
1073  if (NULL == expirationstring)
1074  {
1075  fprintf (stderr,
1076  _ ("Missing option `%s' for operation `%s'\n"),
1077  "-e",
1078  _ ("add"));
1080  ret = 1;
1081  return;
1082  }
1084  {
1085  fprintf (stderr, _ ("Invalid time format `%s'\n"), expirationstring);
1087  ret = 1;
1088  return;
1089  }
1091  &zone_pkey,
1092  name,
1093  &add_error_cb,
1094  NULL,
1096  NULL);
1097  }
1098  if (del)
1099  {
1100  if (NULL == name)
1101  {
1102  fprintf (stderr,
1103  _ ("Missing option `%s' for operation `%s'\n"),
1104  "-n",
1105  _ ("del"));
1107  ret = 1;
1108  return;
1109  }
1111  &zone_pkey,
1112  name,
1114  NULL,
1115  &del_monitor,
1116  NULL);
1117  }
1118  if (list)
1119  {
1120  if (NULL != name)
1122  &zone_pkey,
1123  name,
1124  &lookup_error_cb,
1125  NULL,
1127  NULL);
1128  else
1130  &zone_pkey,
1132  NULL,
1134  NULL,
1136  NULL);
1137  }
1138  if (NULL != reverse_pkey)
1139  {
1141 
1142  if (GNUNET_OK !=
1144  &pubkey))
1145  {
1146  fprintf (stderr,
1147  _ ("Invalid public key for reverse lookup `%s'\n"),
1148  reverse_pkey);
1150  }
1152  &zone_pkey,
1153  &pubkey,
1155  NULL,
1157  NULL);
1158  }
1159  if (NULL != uri)
1160  {
1161  char sh[105];
1162  char sname[64];
1164 
1165  memset (sh, 0, 105);
1166  memset (sname, 0, 64);
1167 
1168  if ((2 != (sscanf (uri, "gnunet://gns/%58s/%63s", sh, sname))) ||
1169  (GNUNET_OK !=
1171  {
1172  fprintf (stderr, _ ("Invalid URI `%s'\n"), uri);
1174  ret = 1;
1175  return;
1176  }
1177  if (NULL == expirationstring)
1178  {
1179  fprintf (stderr,
1180  _ ("Missing option `%s' for operation `%s'\n"),
1181  "-e",
1182  _ ("add"));
1184  ret = 1;
1185  return;
1186  }
1188  {
1189  fprintf (stderr, _ ("Invalid time format `%s'\n"), expirationstring);
1191  ret = 1;
1192  return;
1193  }
1194  memset (&rd, 0, sizeof(rd));
1195  rd.data = &pkey;
1197  rd.record_type = ntohl (pkey.type);
1198  rd.expiration_time = etime;
1199  if (GNUNET_YES == etime_is_rel)
1201  if (1 == is_shadow)
1204  &zone_pkey,
1205  sname,
1206  1,
1207  &rd,
1209  &add_qe_uri);
1210  }
1211  if (monitor)
1212  {
1214  &zone_pkey,
1215  GNUNET_YES,
1217  NULL,
1219  NULL,
1220  &sync_cb,
1221  NULL);
1222  }
1223 }
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:991
@ 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)
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)
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.
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_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 1234 of file gnunet-namestore.c.

1235 {
1236  const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
1237 
1238  el = NULL;
1239 
1240  if (NULL == ego)
1241  {
1242  if (NULL != ego_name)
1243  {
1244  fprintf (stderr,
1245  _ ("Ego `%s' not known to identity service\n"),
1246  ego_name);
1247  }
1249  ret = -1;
1250  return;
1251  }
1254  ego_name = NULL;
1256 }
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(), 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 1270 of file gnunet-namestore.c.

1274 {
1275  const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
1276 
1277  (void) ctx;
1278  (void) name;
1279  get_default = NULL;
1280  if (NULL == ego)
1281  {
1282  fprintf (stderr,
1283  _ ("No default identity configured for `namestore' subsystem\n"
1284  "Run gnunet-identity -s namestore -e $NAME to set the default to $NAME\n"
1285  "Run gnunet-identity -d to get a list of choices for $NAME\n"));
1287  ret = -1;
1288  return;
1289  }
1290  else
1291  {
1292  identity_cb ((void *) cfg, ego);
1293  }
1294 }
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 1310 of file gnunet-namestore.c.

1314 {
1315  const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
1316 
1317  (void) ctx;
1318  (void) name;
1319  if (NULL != ego)
1320  return;
1321  get_default =
1322  GNUNET_IDENTITY_get (idh, "namestore", &default_ego_cb, (void *) cfg);
1323 }
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 1335 of file gnunet-namestore.c.

1339 {
1340  const char *pkey_str;
1341 
1342  (void) cls;
1343  (void) args;
1344  (void) cfgfile;
1345  if (NULL != args[0])
1346  GNUNET_log (
1348  _ ("Superfluous command line arguments (starting with `%s') ignored\n"),
1349  args[0]);
1350  if ((NULL != args[0]) && (NULL == uri))
1351  uri = GNUNET_strdup (args[0]);
1352 
1354  pkey_str = getenv ("GNUNET_NAMESTORE_EGO_PRIVATE_KEY");
1355  if (NULL != pkey_str)
1356  {
1357  if (GNUNET_OK != GNUNET_STRINGS_string_to_data (pkey_str,
1358  strlen (pkey_str),
1359  &zone_pkey,
1360  sizeof(zone_pkey)))
1361  {
1362  fprintf (stderr,
1363  "Malformed private key `%s' in $%s\n",
1364  pkey_str,
1365  "GNUNET_NAMESTORE_EGO_PRIVATE_KEY");
1366  ret = 1;
1368  return;
1369  }
1371  return;
1372  }
1373  if (NULL == ego_name)
1374  {
1376  if (NULL == idh)
1377  fprintf (stderr, _ ("Cannot connect to identity service\n"));
1378  ret = -1;
1379  return;
1380  }
1382 }
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.
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:1316
enum GNUNET_GenericReturnValue GNUNET_STRINGS_string_to_data(const char *enc, size_t enclen, void *out, size_t out_size)
Convert CrockfordBase32 encoding back to data.
Definition: strings.c:789

References _, 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 1403 of file gnunet-namestore.c.

1407 {
1408  struct RecordSetEntry **head = scls;
1409  struct RecordSetEntry *r;
1411  char *cp;
1412  char *tok;
1413  char *saveptr;
1414  int etime_is_rel;
1415  void *raw_data;
1416 
1417  (void) ctx;
1418  (void) option;
1419  cp = GNUNET_strdup (value);
1420  tok = strtok_r (cp, " ", &saveptr);
1421  if (NULL == tok)
1422  {
1424  _ ("Empty record line argument is not allowed.\n"));
1425  GNUNET_free (cp);
1426  return GNUNET_SYSERR;
1427  }
1428  {
1429  char *etime_in_s;
1430 
1431  GNUNET_asprintf (&etime_in_s, "%s s", tok);
1432  if (GNUNET_OK !=
1433  parse_expiration (etime_in_s, &etime_is_rel, &record.expiration_time))
1434  {
1436  _ ("Invalid expiration time `%s' (must be without unit)\n"),
1437  tok);
1438  GNUNET_free (cp);
1439  GNUNET_free (etime_in_s);
1440  return GNUNET_SYSERR;
1441  }
1442  GNUNET_free (etime_in_s);
1443  }
1444  tok = strtok_r (NULL, " ", &saveptr);
1445  if (NULL == tok)
1446  {
1448  _ ("Missing entries in record line `%s'.\n"),
1449  value);
1450  GNUNET_free (cp);
1451  return GNUNET_SYSERR;
1452  }
1453  record.record_type = GNUNET_GNSRECORD_typename_to_number (tok);
1454  if (UINT32_MAX == record.record_type)
1455  {
1456  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _ ("Unknown record type `%s'\n"), tok);
1457  GNUNET_free (cp);
1458  return GNUNET_SYSERR;
1459  }
1460  tok = strtok_r (NULL, " ", &saveptr);
1461  if (NULL == tok)
1462  {
1464  _ ("Missing entries in record line `%s'.\n"),
1465  value);
1466  GNUNET_free (cp);
1467  return GNUNET_SYSERR;
1468  }
1470  if (etime_is_rel)
1472  if (NULL == strchr (tok, (unsigned char) 'p')) /* p = public */
1474  if (NULL != strchr (tok, (unsigned char) 's'))
1476  /* find beginning of record value */
1477  tok = strchr (&value[tok - cp], (unsigned char) ' ');
1478  if (NULL == tok)
1479  {
1481  _ ("Missing entries in record line `%s'.\n"),
1482  value);
1483  GNUNET_free (cp);
1484  return GNUNET_SYSERR;
1485  }
1486  GNUNET_free (cp);
1487  tok++; /* skip space */
1489  tok,
1490  &raw_data,
1491  &record.data_size))
1492  {
1494  _ ("Invalid record data for type %s: `%s'.\n"),
1496  tok);
1497  return GNUNET_SYSERR;
1498  }
1499 
1500  r = GNUNET_malloc (sizeof(struct RecordSetEntry) + record.data_size);
1501  r->next = *head;
1502  record.data = &r[1];
1503  memcpy (&r[1], raw_data, record.data_size);
1504  GNUNET_free (raw_data);
1505  r->record = record;
1506  *head = r;
1507  return GNUNET_OK;
1508 }
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 1403 of file gnunet-namestore.c.

1526 {
1528  .name = name,
1529  .argumentHelp = argumentHelp,
1530  .description = description,
1531  .require_argument = 1,
1532  .processor =
1534  .scls = (void *) rs };
1535 
1536  return clo;
1537 }
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 1548 of file gnunet-namestore.c.

1549 {
1551  { GNUNET_GETOPT_option_flag ('a', "add", gettext_noop ("add record"), &add),
1553  "delete",
1554  gettext_noop ("delete record"),
1555  &del),
1557  "display",
1558  gettext_noop ("display records"),
1559  &list),
1561  'e',
1562  "expiration",
1563  "TIME",
1564  gettext_noop (
1565  "expiration time for record to use (for adding only), \"never\" is possible"),
1566  &expirationstring),
1568  "nick",
1569  "NICKNAME",
1570  gettext_noop (
1571  "set the desired nick name for the zone"),
1572  &nickstring),
1574  "monitor",
1575  gettext_noop (
1576  "monitor changes in the namestore"),
1577  &monitor),
1579  "name",
1580  "NAME",
1581  gettext_noop (
1582  "name of the record to add/delete/display"),
1583  &name),
1585  "reverse",
1586  "PKEY",
1587  gettext_noop (
1588  "determine our name for the given PKEY"),
1589  &reverse_pkey),
1591  'R',
1592  "replace",
1593  "RECORDLINE",
1594  gettext_noop (
1595  "set record set to values given by (possibly multiple) RECORDLINES; can be specified multiple times"),
1596  &recordset),
1598  "type",
1599  "TYPE",
1600  gettext_noop (
1601  "type of the record to add/delete/display"),
1602  &typestring),
1604  "uri",
1605  "URI",
1606  gettext_noop ("URI to import into our zone"),
1607  &uri),
1609  "value",
1610  "VALUE",
1611  gettext_noop (
1612  "value of the record to add/delete"),
1613  &value),
1615  "public",
1616  gettext_noop ("create or list public record"),
1617  &is_public),
1619  's',
1620  "shadow",
1621  gettext_noop (
1622  "create shadow record (only valid if all other records of the same type have expired"),
1623  &is_shadow),
1625  "zone",
1626  "EGO",
1627  gettext_noop (
1628  "name of the ego controlling the zone"),
1629  &ego_name),
1631  int lret;
1632 
1633  if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
1634  return 2;
1635 
1636  is_public = -1;
1637  is_shadow = -1;
1638  GNUNET_log_setup ("gnunet-namestore", "WARNING", NULL);
1639  if (GNUNET_OK !=
1640  (lret = GNUNET_PROGRAM_run (argc,
1641  argv,
1642  "gnunet-namestore",
1643  _ ("GNUnet zone manipulation tool"),
1644  options,
1645  &run,
1646  NULL)))
1647  {
1648  GNUNET_free_nz ((void *) argv);
1649  // FIXME
1650  // GNUNET_CRYPTO_ecdsa_key_clear (&zone_pkey);
1651  return lret;
1652  }
1653  GNUNET_free_nz ((void *) argv);
1654  // FIXME
1655  // GNUNET_CRYPTO_ecdsa_key_clear (&zone_pkey);
1656  return ret;
1657 }
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:399
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:1223

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 63 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 63 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 73 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 78 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 83 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 88 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 98 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 103 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 108 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 113 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 118 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 128 of file gnunet-namestore.c.

Referenced by forward_resolution(), GNUNET_ABD_delegate_issue(), 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 133 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 138 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 143 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 148 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 153 of file gnunet-namestore.c.

Referenced by default_ego_cb(), del_monitor(), display_record(), get_existing_record(), id_connect_cb(), main(), and run_with_zone_pkey().

◆ value

char* value
static

Value of the record to add/remove.

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

Referenced by 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(), create_response(), database_setup(), debug_channel(), 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_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_result_set(), find_sender_by_address(), find_trees(), flush_respect(), free_ack_cummulator_cb(), free_addr_it(), free_all_it(), free_backtalker_cb(), free_blacklist_entry(), free_dv_routes_cb(), free_ego(), free_element_cb(), free_entry(), free_host_entry(), free_item(), free_iterate(), free_matching_requests(), free_namespaces_cb(), free_neighbour_cb(), free_nodes_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_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_NETWORK_socket_disable_corking(), GNUNET_PEERSTORE_store(), GNUNET_STATISTICS_set(), GNUNET_TESTING_get_topo_from_string(), 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_create_ego(), 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(), 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_reply(), process_result_with_request(), process_stat(), process_stat_in(), process_stats(), process_update_node(), 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_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_simple_cb(), send_utilization_data(), session_cmp_it(), session_disconnect_it(), session_lookup_client_by_address(), session_lookup_it(), session_tag_it(), 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(), update_abs_sum(), update_config(), update_flood_times(), update_iterator(), update_rel_sum(), update_sre_result_maps(), url_iterator(), valid_peer_iterator(), validation_entry_match(), watch_notifier_it(), and write_item().

◆ uri

char* uri
static

URI to import.

Definition at line 163 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 168 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 173 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 178 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 183 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 193 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 198 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 203 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 208 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 213 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 223 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 228 of file gnunet-namestore.c.

Referenced by main(), and run_with_zone_pkey().