GNUnet  0.17.6
gnunet-service-zonemaster.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2012, 2013, 2014, 2017, 2018 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  GNUnet is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
20 
26 #include "platform.h"
27 #include "gnunet_util_lib.h"
28 #include "gnunet_dnsparser_lib.h"
29 #include "gnunet_dht_service.h"
33 
34 #define LOG_STRERROR_FILE(kind, syscall, \
35  filename) GNUNET_log_from_strerror_file (kind, "util", \
36  syscall, \
37  filename)
38 
39 
44 #define PUBLISH_OPS_PER_EXPIRATION 4
45 
51 #define DELTA_INTERVAL 100
52 
56 #define NS_BLOCK_SIZE 1000
57 
61 #define DHT_QUEUE_LIMIT 2000
62 
67 #define NAMESTORE_QUEUE_LIMIT 50
68 
73 #define INITIAL_ZONE_ITERATION_INTERVAL GNUNET_TIME_UNIT_MILLISECONDS
74 
79 #define MAXIMUM_ZONE_ITERATION_INTERVAL GNUNET_TIME_relative_multiply ( \
80  GNUNET_TIME_UNIT_MINUTES, 15)
81 
86 #define LATE_ITERATION_SPEEDUP_FACTOR 2
87 
91 #define DHT_GNS_REPLICATION_LEVEL 5
92 
96 struct DhtPutActivity
97 {
101  struct DhtPutActivity *next;
102 
106  struct DhtPutActivity *prev;
107 
111  struct GNUNET_DHT_PutHandle *ph;
112 
117 };
118 
122 struct CacheOperation
123 {
127  struct CacheOperation *prev;
128 
132  struct CacheOperation *next;
133 
138 
139 };
140 
141 
146 
151 
156 
161 
166 static int disable_namecache;
167 
172 
176 static struct DhtPutActivity *it_head;
177 
181 static struct DhtPutActivity *it_tail;
182 
186 static unsigned int dht_queue_length;
187 
191 static unsigned long long num_public_records;
192 
196 static unsigned long long last_num_public_records;
197 
202 static unsigned long long put_cnt;
203 
212 
218 
224 
229 
235 
240 static struct GNUNET_TIME_Absolute last_put_100;
241 
248 static struct GNUNET_TIME_Relative sub_delta;
249 
254 
259 static unsigned int ns_iteration_left;
260 
265 
270 static int cache_keys;
271 
275 static struct CacheOperation *cop_head;
276 
280 static struct CacheOperation *cop_tail;
281 
282 
289 static void
290 shutdown_task (void *cls)
291 {
292  struct DhtPutActivity *ma;
293  struct CacheOperation *cop;
294 
295  (void) cls;
297  "Shutting down!\n");
298  while (NULL != (cop = cop_head))
299  {
301  "Aborting incomplete namecache operation\n");
304  GNUNET_free (cop);
305  }
306 
307  while (NULL != (ma = it_head))
308  {
312  it_tail,
313  ma);
315  GNUNET_free (ma);
316  }
317  if (NULL != statistics)
318  {
320  GNUNET_NO);
321  statistics = NULL;
322  }
323  if (NULL != zone_publish_task)
324  {
326  zone_publish_task = NULL;
327  }
328  if (NULL != namestore_iter)
329  {
331  namestore_iter = NULL;
332  }
333  if (NULL != namestore_handle)
334  {
336  namestore_handle = NULL;
337  }
338  if (NULL != namecache)
339  {
341  namecache = NULL;
342  }
343 if (NULL != dht_handle)
344  {
346  dht_handle = NULL;
347  }
348 }
349 
357 static void
358 finish_cache_operation (void *cls, int32_t success, const char *emsg)
359 {
360  struct CacheOperation *cop = cls;
361 
362  if (NULL != emsg)
364  _ ("Failed to replicate block in namecache: %s\n"),
365  emsg);
366  else
367  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "CACHE operation completed\n");
369  GNUNET_free (cop);
370 }
371 
372 
381 static void
383 {
384  struct CacheOperation *cop;
385  struct GNUNET_TIME_Absolute exp_time;
386 
388  {
390  "Namecache updates skipped (NC disabled)",
391  1,
392  GNUNET_NO);
393  return;
394  }
395  GNUNET_assert (NULL != block);
396  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Caching block in namecache\n");
398  "Namecache updates pushed",
399  1,
400  GNUNET_NO);
401  cop = GNUNET_new (struct CacheOperation);
404  block,
406  cop);
407 }
408 
409 
410 
416 static void
418 {
419  (void) cls;
420  zone_publish_task = NULL;
421  GNUNET_assert (NULL != namestore_iter);
425  NS_BLOCK_SIZE);
426 }
427 
428 
434 static void
435 publish_zone_dht_start (void *cls);
436 
437 
441 static void
443 {
444  if (0 == num_public_records)
452  "No records in namestore database.\n");
453  }
454  else
455  {
467  }
472  "Minimum relative record expiration (in μs)",
474  GNUNET_NO);
476  "Zone publication time window (in μs)",
478  GNUNET_NO);
480  "Target zone iteration velocity (μs)",
482  GNUNET_NO);
483 }
484 
485 
493 static void
494 update_velocity (unsigned int cnt)
495 {
497  unsigned long long pct = 0;
498 
499  if (0 == cnt)
500  return;
501  /* How fast were we really? */
503  delta.rel_value_us /= cnt;
505 
506  /* calculate expected frequency */
509  {
511  "Last record count was lower than current record count. Reducing interval.\n");
515  }
517  "Desired global zone iteration interval is %s/record!\n",
520  GNUNET_YES));
521 
522  /* Tell statistics actual vs. desired speed */
524  "Current zone iteration velocity (μs/record)",
526  GNUNET_NO);
527  /* update "sub_delta" based on difference, taking
528  previous sub_delta into account! */
530  {
531  /* We were too fast, reduce sub_delta! */
532  struct GNUNET_TIME_Relative corr;
533 
535  delta);
537  {
538  /* Reduce sub_delta by corr */
540  corr);
541  }
542  else
543  {
544  /* We're doing fine with waiting the full time, this
545  should theoretically only happen if we run at
546  infinite speed. */
548  }
549  }
552  {
553  /* We were too slow, increase sub_delta! */
554  struct GNUNET_TIME_Relative corr;
555 
559  corr);
560  if (sub_delta.rel_value_us >
562  {
563  /* CPU overload detected, we cannot go at desired speed,
564  as this would mean using a negative delay. */
565  /* compute how much faster we would want to be for
566  the desired velocity */
568  pct = UINT64_MAX; /* desired speed is infinity ... */
569  else
570  pct = (sub_delta.rel_value_us
574  }
575  }
577  "# size of the DHT queue (it)",
579  GNUNET_NO);
581  "% speed increase needed for target velocity",
582  pct,
583  GNUNET_NO);
585  "# records processed in current iteration",
587  GNUNET_NO);
588 }
589 
590 
595 static void
597 {
599 
600  if (0 != ns_iteration_left)
601  return; /* current NAMESTORE iteration not yet done */
603  put_cnt = 0;
605  sub_delta);
606  /* We delay *once* per #NS_BLOCK_SIZE, so we need to multiply the
607  per-record delay calculated so far with the #NS_BLOCK_SIZE */
609  "Current artificial NAMESTORE delay (μs/record)",
611  GNUNET_NO);
613  NS_BLOCK_SIZE);
614  /* make sure we do not overshoot because of the #NS_BLOCK_SIZE factor */
616  delay);
617  /* no delays on first iteration */
623  NULL);
624 }
625 
626 
632 static void
634 {
635  struct DhtPutActivity *ma = cls;
636 
638  "PUT complete\n");
641  it_tail,
642  ma);
643  GNUNET_free (ma);
644 }
645 
646 
647 
658 static struct GNUNET_DHT_PutHandle *
660  const char *label,
661  const struct GNUNET_GNSRECORD_Data *rd,
662  unsigned int rd_count,
663  const struct GNUNET_TIME_Absolute expire,
664  struct DhtPutActivity *ma)
665 {
666  struct GNUNET_GNSRECORD_Data rd_public[rd_count];
667  struct GNUNET_GNSRECORD_Block *block;
668  struct GNUNET_GNSRECORD_Block *block_priv;
669  struct GNUNET_HashCode query;
670  struct GNUNET_TIME_Absolute expire_priv;
671  size_t block_size;
672  unsigned int rd_public_count = 0;
673  struct GNUNET_DHT_PutHandle *ret;
674  char *emsg;
675 
676  if (GNUNET_OK !=
678  rd,
679  rd_count,
680  rd_public,
681  &rd_public_count,
682  &expire_priv,
684  &emsg))
685  {
687  "%s\n", emsg);
688  GNUNET_free (emsg);
689  }
690 
691  if (cache_keys)
692  {
694  expire,
695  label,
696  rd_public,
697  rd_public_count,
698  &block));
699  }
700  else
701  {
703  expire,
704  label,
705  rd_public,
706  rd_public_count,
707  &block));
708  }
709  if (NULL == block)
710  {
711  GNUNET_break (0);
712  return NULL; /* whoops */
713  }
714  if (rd_count != rd_public_count)
716  expire_priv,
717  label,
718  rd,
719  rd_count,
720  &block_priv));
721  else
722  block_priv = block;
723  block_size = GNUNET_GNSRECORD_block_get_size (block);
725  label,
726  &query);
728  "DHT put operations initiated",
729  1,
730  GNUNET_NO);
732  "Storing %u record(s) for label `%s' in DHT with expiration `%s' under key %s\n",
733  rd_public_count,
734  label,
736  GNUNET_h2s (&query));
739  &query,
743  block_size,
744  block,
745  expire,
747  ma);
748  refresh_block (block_priv);
749  if (block != block_priv)
750  GNUNET_free (block_priv);
751  GNUNET_free (block);
752  return ret;
753 }
754 
755 
761 static void
763 {
764  (void) cls;
766  "Got disconnected from namestore database, retrying.\n");
767  namestore_iter = NULL;
768  /* We end up here on error/disconnect/shutdown, so potentially
769  while a zone publish task or a DHT put is still running; hence
770  we need to cancel those. */
771  if (NULL != zone_publish_task)
772  {
774  zone_publish_task = NULL;
775  }
777  NULL);
778 }
779 
780 
786 static void
788 {
789  (void) cls;
790  /* we're done with one iteration, calculate when to do the next one */
791  namestore_iter = NULL;
796  /* reset for next iteration */
800  "Zone iteration finished. Adjusted zone iteration interval to %s\n",
803  GNUNET_YES));
805  "Target zone iteration velocity (μs)",
807  GNUNET_NO);
809  "Number of public records in DHT",
811  GNUNET_NO);
813  if (0 == last_num_public_records)
814  {
818  NULL);
819  }
820  else
821  {
823  NULL);
824  }
825 }
826 
836 static void
837 put_gns_record (void *cls,
838  const struct GNUNET_IDENTITY_PrivateKey *key,
839  const char *label,
840  unsigned int rd_count,
841  const struct GNUNET_GNSRECORD_Data *rd,
843 {
844  struct DhtPutActivity *ma;
845 
846  (void) cls;
848  if (0 == rd_count)
849  {
851  "Record set empty, moving to next record set\n");
853  return;
854  }
855  for (unsigned int i = 0; i < rd_count; i++)
856  {
857  if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION))
858  {
859  /* GNUNET_GNSRECORD_block_create will convert to absolute time;
860  we just need to adjust our iteration frequency */
862  GNUNET_MIN (rd[i].expiration_time,
864  }
865  }
866 
867 
868  /* We got a set of records to publish */
870  "Starting DHT PUT\n");
871 
872  ma = GNUNET_new (struct DhtPutActivity);
874  ma->ph = perform_dht_put (key,
875  label,
876  rd,
877  rd_count,
878  expire,
879  ma);
880  put_cnt++;
881  if (0 == put_cnt % DELTA_INTERVAL)
884  if (NULL == ma->ph)
885  {
887  "Could not perform DHT PUT, is the DHT running?\n");
888  GNUNET_free (ma);
889  return;
890  }
893  it_tail,
894  ma);
896  {
897  ma = it_head;
899  it_tail,
900  ma);
904  "DHT PUT unconfirmed after %s, aborting PUT\n",
907  GNUNET_YES));
908  GNUNET_free (ma);
909  }
910 }
911 
917 static void
919 {
920  (void) cls;
921  zone_publish_task = NULL;
923  "Full zone iterations launched",
924  1,
925  GNUNET_NO);
927  "Starting DHT zone update!\n");
928  /* start counting again */
929  num_public_records = 0;
930  GNUNET_assert (NULL == namestore_iter);
931  ns_iteration_left = 1;
934  NULL, /* All zones */
936  NULL,
938  NULL,
940  NULL,
942  GNUNET_assert (NULL != namestore_iter);
943 }
944 
945 
953 static void
954 run (void *cls,
955  const struct GNUNET_CONFIGURATION_Handle *c,
957 {
958  unsigned long long max_parallel_bg_queries = 128;
959 
960  (void) cls;
961  (void) service;
962  last_put_100 = GNUNET_TIME_absolute_get (); /* first time! */
967  if (NULL == namestore_handle)
968  {
970  _ ("Failed to connect to the namestore!\n"));
972  return;
973  }
975  "namecache",
976  "DISABLE");
978  {
980  if (NULL == namecache)
981  {
983  _ ("Failed to connect to the namecache!\n"));
985  return;
986  }
987  }
989  "namestore",
990  "CACHE_KEYS");
992  if (GNUNET_OK ==
994  "zonemaster",
995  "ZONE_PUBLISH_TIME_WINDOW",
997  {
999  "Time window for zone iteration: %s\n",
1002  GNUNET_YES));
1003  }
1005  if (GNUNET_OK ==
1007  "zonemaster",
1008  "MAX_PARALLEL_BACKGROUND_QUERIES",
1009  &max_parallel_bg_queries))
1010  {
1012  "Number of allowed parallel background queries: %llu\n",
1013  max_parallel_bg_queries);
1014  }
1015  if (0 == max_parallel_bg_queries)
1016  max_parallel_bg_queries = 1;
1018  (unsigned int) max_parallel_bg_queries);
1019  if (NULL == dht_handle)
1020  {
1022  _ ("Could not connect to DHT!\n"));
1024  NULL);
1025  return;
1026  }
1027 
1028  /* Schedule periodic put for our records. */
1030  statistics = GNUNET_STATISTICS_create ("zonemaster",
1031  c);
1033  "Target zone iteration velocity (μs)",
1035  GNUNET_NO);
1037  NULL);
1039  NULL);
1040 }
1041 
1042 
1047  ("zonemaster",
1049  &run,
1050  NULL,
1051  NULL,
1052  NULL,
1054 
1055 
1056 /* end of gnunet-service-zonemaster.c */
@ GNUNET_BLOCK_TYPE_GNS_NAMERECORD
Block for storing GNS record data.
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
struct GNUNET_HashCode key
The key used in the DHT.
static char * expire
DID Document expiration Date Attribut String.
Definition: gnunet-did.c:101
static struct GNUNET_TIME_Relative delay
When should dkg communication start?
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
#define PUBLISH_OPS_PER_EXPIRATION
How often should we (re)publish each record before it expires?
static int disable_namecache
Use the namecache? Doing so creates additional cryptographic operations whenever we touch a record.
static struct CacheOperation * cop_head
Head of cop DLL.
static void zone_iteration_finished(void *cls)
Zone iteration is completed.
static unsigned int ns_iteration_left
How many more values are left for the current query before we need to explicitly ask the namestore fo...
static void refresh_block(const struct GNUNET_GNSRECORD_Block *block)
Refresh the (encrypted) block in the namecache.
static struct GNUNET_TIME_Relative target_iteration_velocity_per_record
What is the frequency at which we currently would like to perform DHT puts (per record)?...
static unsigned long long put_cnt
Number of successful put operations performed in the current measurement cycle (as measured in check_...
static struct GNUNET_NAMECACHE_Handle * namecache
Our handle to the namecache service.
static unsigned long long last_num_public_records
Last seen record count.
static struct DhtPutActivity * it_head
Head of iteration put activities; kept in a DLL.
static void check_zone_namestore_next()
Check if the current zone iteration needs to be continued by calling publish_zone_namestore_next(),...
static struct GNUNET_TIME_Relative sub_delta
By how much should we try to increase our per-record iteration speed (over the desired speed calculat...
static struct GNUNET_TIME_Relative zone_publish_time_window
Time window for zone iteration, adjusted based on relative record expiration times in our zone.
#define DHT_QUEUE_LIMIT
How many pending DHT operations do we allow at most?
#define DELTA_INTERVAL
How often do we measure the delta between desired zone iteration speed and actual speed,...
GNUNET_SERVICE_MAIN("zonemaster", GNUNET_SERVICE_OPTION_NONE, &run, NULL, NULL, NULL, GNUNET_MQ_handler_end())
Define "main" method using service macro.
static void calculate_put_interval()
Calculate target_iteration_velocity_per_record.
static void publish_zone_namestore_next(void *cls)
Method called periodically that triggers iteration over authoritative records.
static struct CacheOperation * cop_tail
Tail of cop DLL.
static void finish_cache_operation(void *cls, int32_t success, const char *emsg)
Cache operation complete, clean up.
static struct GNUNET_NAMESTORE_Handle * namestore_handle
Our handle to the namestore service.
static void shutdown_task(void *cls)
Task run during shutdown.
static unsigned int dht_queue_length
Number of entries in the DHT queue it_head.
#define NS_BLOCK_SIZE
How many records do we fetch in one shot from the namestore?
static struct GNUNET_TIME_Relative min_relative_record_time
Minimum relative expiration time of records seem during the current zone iteration.
static struct GNUNET_STATISTICS_Handle * statistics
Handle to the statistics service.
static struct GNUNET_DHT_Handle * dht_handle
Our handle to the DHT.
#define LATE_ITERATION_SPEEDUP_FACTOR
The factor the current zone iteration interval is divided by for each additional new record.
static void publish_zone_dht_start(void *cls)
Periodically iterate over our zone and store everything in dht.
static void run(void *cls, const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_SERVICE_Handle *service)
Perform zonemaster duties: watch namestore, publish records.
static unsigned long long num_public_records
Useful for zone update for DHT put.
#define INITIAL_ZONE_ITERATION_INTERVAL
The initial interval in milliseconds btween puts in a zone iteration.
static int first_zone_iteration
GNUNET_YES if zone has never been published before
static int cache_keys
Optimize block insertion by caching map of private keys to public keys in memory?
static struct GNUNET_TIME_Absolute last_put_100
When did we last start measuring the DELTA_INTERVAL successful DHT puts? Used for velocity calculatio...
static struct GNUNET_SCHEDULER_Task * zone_publish_task
zone publish task
static struct GNUNET_DHT_PutHandle * perform_dht_put(const struct GNUNET_IDENTITY_PrivateKey *key, const char *label, const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count, const struct GNUNET_TIME_Absolute expire, struct DhtPutActivity *ma)
Store GNS records in the DHT.
static struct GNUNET_NAMESTORE_ZoneIterator * namestore_iter
Handle to iterate over our authoritative zone in namestore.
static struct GNUNET_TIME_Relative zone_publish_time_window_default
Default time window for zone iteration.
#define DHT_GNS_REPLICATION_LEVEL
What replication level do we use for DHT PUT operations?
static void put_gns_record(void *cls, const struct GNUNET_IDENTITY_PrivateKey *key, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, struct GNUNET_TIME_Absolute expire)
Function used to put all records successively into the DHT.
static struct GNUNET_TIME_Relative last_min_relative_record_time
Minimum relative expiration time of records seem during the last zone iteration.
static void update_velocity(unsigned int cnt)
Re-calculate our velocity and the desired velocity.
static void dht_put_continuation(void *cls)
Continuation called from DHT once the PUT operation is done.
static struct DhtPutActivity * it_tail
Tail of iteration put activities; kept in a DLL.
#define MAXIMUM_ZONE_ITERATION_INTERVAL
The upper bound for the zone iteration interval (per record).
static void zone_iteration_error(void *cls)
We encountered an error in our zone iteration.
API to the DHT service.
API for helper library to parse DNS packets.
API that can be used to store naming information on a GNUnet node.
API that can be used to store naming information on a GNUnet node;.
API to create, modify and access statistics.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_yesno(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
Get a configuration value that should be in a set of "YES" or "NO".
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_time(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, struct GNUNET_TIME_Relative *time)
Get a configuration value that should be a relative time.
void GNUNET_DHT_put_cancel(struct GNUNET_DHT_PutHandle *ph)
Cancels a DHT PUT operation.
Definition: dht_api.c:1148
struct GNUNET_DHT_Handle * GNUNET_DHT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, unsigned int ht_len)
Initialize the connection with the DHT service.
Definition: dht_api.c:1039
#define GNUNET_DHT_DEFAULT_REPUBLISH_FREQUENCY
Default republication frequency for stored data in the DHT.
struct GNUNET_DHT_PutHandle * GNUNET_DHT_put(struct GNUNET_DHT_Handle *handle, const struct GNUNET_HashCode *key, uint32_t desired_replication_level, enum GNUNET_DHT_RouteOption options, enum GNUNET_BLOCK_Type type, size_t size, const void *data, struct GNUNET_TIME_Absolute exp, GNUNET_SCHEDULER_TaskCallback cont, void *cont_cls)
Perform a PUT operation storing data in the DHT.
Definition: dht_api.c:1090
void GNUNET_DHT_disconnect(struct GNUNET_DHT_Handle *handle)
Shutdown connection with the DHT service.
Definition: dht_api.c:1062
@ GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE
Each peer along the way should process the request (otherwise only peers locally closest to the key w...
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
void GNUNET_GNSRECORD_query_from_private_key(const struct GNUNET_IDENTITY_PrivateKey *zone, const char *label, struct GNUNET_HashCode *query)
Calculate the DHT query for a given label in a given zone.
enum GNUNET_GenericReturnValue GNUNET_GNSRECORD_block_create2(const struct GNUNET_IDENTITY_PrivateKey *pkey, struct GNUNET_TIME_Absolute expire, const char *label, const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count, struct GNUNET_GNSRECORD_Block **result)
Sign name and records, cache derived public key (also keeps the private key in static memory,...
enum GNUNET_GenericReturnValue GNUNET_GNSRECORD_block_create(const struct GNUNET_IDENTITY_PrivateKey *key, struct GNUNET_TIME_Absolute expire, const char *label, const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count, struct GNUNET_GNSRECORD_Block **result)
Sign name and records.
size_t GNUNET_GNSRECORD_block_get_size(const struct GNUNET_GNSRECORD_Block *block)
Returns the length of this block in bytes.
enum GNUNET_GenericReturnValue GNUNET_GNSRECORD_normalize_record_set(const char *label, const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count, struct GNUNET_GNSRECORD_Data *rd_public, unsigned int *rd_count_public, struct GNUNET_TIME_Absolute *expiry, enum GNUNET_GNSRECORD_Filter filter, char **emsg)
Normalize namestore records: Check for consistency and expirations.
@ GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION
This expiration time of the record is a relative time (not an absolute time).
@ GNUNET_GNSRECORD_FILTER_NONE
No filter flags set.
@ GNUNET_GNSRECORD_FILTER_OMIT_PRIVATE
Filter private records.
#define GNUNET_log(kind,...)
#define GNUNET_MIN(a, b)
@ GNUNET_OK
Definition: gnunet_common.h:99
@ GNUNET_YES
@ GNUNET_NO
Definition: gnunet_common.h:98
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_BULK
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
void GNUNET_NAMECACHE_disconnect(struct GNUNET_NAMECACHE_Handle *h)
Disconnect from the namecache service (and free associated resources).
void GNUNET_NAMECACHE_cancel(struct GNUNET_NAMECACHE_QueueEntry *qe)
Cancel a namecache operation.
struct GNUNET_NAMECACHE_Handle * GNUNET_NAMECACHE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the namecache service.
struct GNUNET_NAMECACHE_QueueEntry * GNUNET_NAMECACHE_block_cache(struct GNUNET_NAMECACHE_Handle *h, const struct GNUNET_GNSRECORD_Block *block, GNUNET_NAMECACHE_ContinuationWithStatus cont, void *cont_cls)
Store an item in the namecache.
void GNUNET_NAMESTORE_disconnect(struct GNUNET_NAMESTORE_Handle *h)
Disconnect from the namestore service (and free associated resources).
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.
struct GNUNET_NAMESTORE_ZoneIterator * GNUNET_NAMESTORE_zone_iteration_start2(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *zone, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordSetMonitor proc, void *proc_cls, GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls, enum GNUNET_GNSRECORD_Filter filter)
Starts a new zone iteration (used to periodically PUT all of our records into our DHT).
struct GNUNET_NAMESTORE_Handle * GNUNET_NAMESTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the namestore service.
void GNUNET_NAMESTORE_zone_iteration_stop(struct GNUNET_NAMESTORE_ZoneIterator *it)
Stops iteration and releases the namestore handle for further calls.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:533
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1281
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
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:957
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1254
@ GNUNET_SERVICE_OPTION_NONE
Use defaults.
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
void GNUNET_STATISTICS_set(struct GNUNET_STATISTICS_Handle *handle, const char *name, uint64_t value, int make_persistent)
Set statistic value for the peer.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
struct GNUNET_TIME_Relative GNUNET_TIME_relative_min(struct GNUNET_TIME_Relative t1, struct GNUNET_TIME_Relative t2)
Return the minimum of two relative time values.
Definition: time.c:342
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
Definition: time.c:435
struct GNUNET_TIME_Relative GNUNET_TIME_relative_subtract(struct GNUNET_TIME_Relative a1, struct GNUNET_TIME_Relative a2)
Subtract relative timestamp from the other.
Definition: time.c:602
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:110
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
Definition: strings.c:617
struct GNUNET_TIME_Relative GNUNET_TIME_relative_add(struct GNUNET_TIME_Relative a1, struct GNUNET_TIME_Relative a2)
Add relative times together.
Definition: time.c:584
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
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_divide(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Divide relative time by a given factor.
Definition: time.c:549
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
#define _(String)
GNU gettext support macro.
Definition: platform.h:177
static struct GNUNET_TIME_Relative delta
Definition: speedup.c:35
Pending operation on the namecache.
struct CacheOperation * next
Kept in a DLL.
struct CacheOperation * prev
Kept in a DLL.
struct GNUNET_NAMECACHE_QueueEntry * qe
Handle to namecache queue.
Handle for DHT PUT activity triggered from the namestore monitor.
struct DhtPutActivity * prev
Kept in a DLL.
struct DhtPutActivity * next
Kept in a DLL.
struct GNUNET_DHT_PutHandle * ph
Handle for the DHT PUT operation.
struct GNUNET_TIME_Absolute start_date
When was this PUT initiated?
Connection to the DHT service.
Definition: dht_api.c:237
Handle to a PUT request.
Definition: dht_api.c:45
A 512-bit hashcode.
A private key for an identity as per LSD0001.
Connection to the NAMECACHE service.
Definition: namecache_api.c:95
An QueueEntry used to store information for a pending NAMECACHE record operation.
Definition: namecache_api.c:48
Connection to the NAMESTORE service.
Handle for a zone iterator operation.
Entry in list of pending tasks.
Definition: scheduler.c:135
Handle to a service.
Definition: service.c:117
Handle for the service.
Time for absolute times used by GNUnet, in microseconds.
Time for relative time used by GNUnet, in microseconds.
uint64_t rel_value_us
The actual value.