GNUnet  0.10.x
plugin_namestore_flat.c
Go to the documentation of this file.
1 /*
2  * This file is part of GNUnet
3  * Copyright (C) 2009-2015, 2018, 2019 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  */
27 #include "platform.h"
30 #include "gnunet_gnsrecord_lib.h"
31 #include "namestore.h"
32 
36 struct Plugin {
37  const struct GNUNET_CONFIGURATION_Handle *cfg;
38 
42  char *fn;
43 
48 };
49 
50 
51 struct FlatFileEntry {
55  struct GNUNET_CRYPTO_EcdsaPrivateKey private_key;
56 
60  uint32_t record_count;
61 
65  uint64_t rvalue;
66 
71 
75  char *label;
76 };
77 
78 
86 static void
88  const char *label,
89  struct GNUNET_HashCode *h)
90 {
91  char *key;
92  size_t label_len;
93  size_t key_len;
94 
95  label_len = strlen(label);
96  key_len = label_len + sizeof(struct GNUNET_CRYPTO_EcdsaPrivateKey);
97  key = GNUNET_malloc(key_len);
98  GNUNET_memcpy(key,
99  label,
100  label_len);
101  GNUNET_memcpy(key + label_len,
102  pkey,
103  sizeof(struct GNUNET_CRYPTO_EcdsaPrivateKey));
104  GNUNET_CRYPTO_hash(key,
105  key_len,
106  h);
107  GNUNET_free(key);
108 }
109 
110 
119 static int
121 {
122  char *flatdbfile;
123  char *record_data;
124  char *zone_private_key;
125  char *record_data_b64;
126  char *buffer;
127  char *line;
128  char *label;
129  char *rvalue;
130  char *record_count;
131  size_t record_data_size;
132  uint64_t size;
133  struct GNUNET_HashCode hkey;
134  struct GNUNET_DISK_FileHandle *fh;
135  struct FlatFileEntry *entry;
136  struct GNUNET_DISK_MapHandle *mh;
137 
138  if (GNUNET_OK !=
140  "namestore-flat",
141  "FILENAME",
142  &flatdbfile))
143  {
145  "namestore-flat",
146  "FILENAME");
147  return GNUNET_SYSERR;
148  }
149  if (GNUNET_OK !=
150  GNUNET_DISK_file_test(flatdbfile))
151  {
152  if (GNUNET_OK !=
154  {
155  GNUNET_break(0);
156  GNUNET_free(flatdbfile);
157  return GNUNET_SYSERR;
158  }
159  }
160  /* flatdbfile should be UTF-8-encoded. If it isn't, it's a bug */
161  plugin->fn = flatdbfile;
162 
163  /* Load data from file into hashmap */
165  GNUNET_NO);
166  fh = GNUNET_DISK_file_open(flatdbfile,
171  if (NULL == fh)
172  {
174  _("Unable to initialize file: %s.\n"),
175  flatdbfile);
176  return GNUNET_SYSERR;
177  }
178  if (GNUNET_SYSERR ==
179  GNUNET_DISK_file_size(flatdbfile,
180  &size,
181  GNUNET_YES,
182  GNUNET_YES))
183  {
185  _("Unable to get filesize: %s.\n"),
186  flatdbfile);
188  return GNUNET_SYSERR;
189  }
190  if (size > SIZE_MAX)
191  {
193  _("File too big to map: %llu bytes.\n"),
194  (unsigned long long)size);
196  return GNUNET_SYSERR;
197  }
198  if (0 == size)
199  {
201  return GNUNET_OK;
202  }
203  buffer = GNUNET_DISK_file_map(fh,
204  &mh,
206  size);
207  if (NULL == buffer)
208  {
210  "mmap");
212  return GNUNET_SYSERR;
213  }
214  if ('\0' != buffer[size - 1])
215  {
217  _("Namestore database file `%s' malformed\n"),
218  flatdbfile);
221  return GNUNET_SYSERR;
222  }
223 
224  line = strtok(buffer, "\n");
225  while (NULL != line)
226  {
227  zone_private_key = strtok(line, ",");
228  if (NULL == zone_private_key)
229  break;
230  rvalue = strtok(NULL, ",");
231  if (NULL == rvalue)
232  break;
233  record_count = strtok(NULL, ",");
234  if (NULL == record_count)
235  break;
236  record_data_b64 = strtok(NULL, ",");
237  if (NULL == record_data_b64)
238  break;
239  label = strtok(NULL, ",");
240  if (NULL == label)
241  break;
242  line = strtok(NULL, "\n");
243  entry = GNUNET_new(struct FlatFileEntry);
244  {
245  unsigned long long ll;
246 
247  if (1 != sscanf(rvalue,
248  "%llu",
249  &ll))
250  {
252  "Error parsing entry\n");
253  GNUNET_free(entry);
254  break;
255  }
256  entry->rvalue = (uint64_t)ll;
257  }
258  {
259  unsigned int ui;
260 
261  if (1 != sscanf(record_count,
262  "%u",
263  &ui))
264  {
266  "Error parsing entry\n");
267  GNUNET_free(entry);
268  break;
269  }
270  entry->record_count = (uint32_t)ui;
271  }
272  entry->label = GNUNET_strdup(label);
273  record_data_size
274  = GNUNET_STRINGS_base64_decode(record_data_b64,
275  strlen(record_data_b64),
276  (void **)&record_data);
277  entry->record_data =
279  struct GNUNET_GNSRECORD_Data);
280  if (GNUNET_OK !=
281  GNUNET_GNSRECORD_records_deserialize(record_data_size,
282  record_data,
283  entry->record_count,
284  entry->record_data))
285  {
287  "Unable to deserialize record %s\n",
288  label);
289  GNUNET_free(entry->label);
290  GNUNET_free(entry);
291  GNUNET_free(record_data);
292  break;
293  }
294  GNUNET_free(record_data);
295 
296  {
297  struct GNUNET_CRYPTO_EcdsaPrivateKey *private_key;
298 
299  GNUNET_STRINGS_base64_decode(zone_private_key,
300  strlen(zone_private_key),
301  (void**)&private_key);
302  entry->private_key = *private_key;
303  GNUNET_free(private_key);
304  }
305 
307  label,
308  &hkey);
309  if (GNUNET_OK !=
311  &hkey,
312  entry,
314  {
315  GNUNET_free(entry);
316  GNUNET_break(0);
317  }
318  }
321  return GNUNET_OK;
322 }
323 
324 
332 static int
334  const struct GNUNET_HashCode *key,
335  void *value)
336 {
337  struct GNUNET_DISK_FileHandle *fh = cls;
338  struct FlatFileEntry *entry = value;
339  char *line;
340  char *zone_private_key;
341  char *record_data_b64;
342  ssize_t data_size;
343 
344  (void)key;
346  sizeof(struct GNUNET_CRYPTO_EcdsaPrivateKey),
347  &zone_private_key);
349  entry->record_data);
350  if (data_size < 0)
351  {
352  GNUNET_break(0);
353  GNUNET_free(zone_private_key);
354  return GNUNET_SYSERR;
355  }
356  if (data_size >= UINT16_MAX)
357  {
358  GNUNET_break(0);
359  GNUNET_free(zone_private_key);
360  return GNUNET_SYSERR;
361  }
362  {
363  char data[data_size];
364  ssize_t ret;
365 
367  entry->record_data,
368  data_size,
369  data);
370  if ((ret < 0) ||
371  (data_size != ret))
372  {
373  GNUNET_break(0);
374  GNUNET_free(zone_private_key);
375  return GNUNET_SYSERR;
376  }
378  data_size,
379  &record_data_b64);
380  }
381  GNUNET_asprintf(&line,
382  "%s,%llu,%u,%s,%s\n",
383  zone_private_key,
384  (unsigned long long)entry->rvalue,
385  (unsigned int)entry->record_count,
386  record_data_b64,
387  entry->label);
388  GNUNET_free(record_data_b64);
389  GNUNET_free(zone_private_key);
390 
392  line,
393  strlen(line));
394 
395  GNUNET_free(line);
396  GNUNET_free(entry->label);
397  GNUNET_free(entry->record_data);
398  GNUNET_free(entry);
399  return GNUNET_YES;
400 }
401 
402 
408 static void
410 {
411  struct GNUNET_DISK_FileHandle *fh;
412 
413  fh = GNUNET_DISK_file_open(plugin->fn,
419  if (NULL == fh)
420  {
422  _("Unable to initialize file: %s.\n"),
423  plugin->fn);
424  return;
425  }
426 
429  fh);
431  /* append 0-terminator */
433  "",
434  1);
436 }
437 
438 
450 static int
452  const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key,
453  const char *label,
454  unsigned int rd_count,
455  const struct GNUNET_GNSRECORD_Data *rd)
456 {
457  struct Plugin *plugin = cls;
458  uint64_t rvalue;
459  struct GNUNET_HashCode hkey;
460  struct FlatFileEntry *entry;
461 
463  UINT64_MAX);
464  hash_pkey_and_label(zone_key,
465  label,
466  &hkey);
468  &hkey);
469  if (0 == rd_count)
470  {
472  "sqlite",
473  "Record deleted\n");
474  return GNUNET_OK;
475  }
476  entry = GNUNET_new(struct FlatFileEntry);
477  GNUNET_asprintf(&entry->label,
478  label,
479  strlen(label));
480  GNUNET_memcpy(&entry->private_key,
481  zone_key,
482  sizeof(struct GNUNET_CRYPTO_EcdsaPrivateKey));
483  entry->rvalue = rvalue;
484  entry->record_count = rd_count;
485  entry->record_data = GNUNET_new_array(rd_count,
486  struct GNUNET_GNSRECORD_Data);
487  for (unsigned int i = 0; i < rd_count; i++)
488  {
489  entry->record_data[i].expiration_time = rd[i].expiration_time;
490  entry->record_data[i].record_type = rd[i].record_type;
491  entry->record_data[i].flags = rd[i].flags;
492  entry->record_data[i].data_size = rd[i].data_size;
493  entry->record_data[i].data = GNUNET_malloc(rd[i].data_size);
494  GNUNET_memcpy((char*)entry->record_data[i].data,
495  rd[i].data,
496  rd[i].data_size);
497  }
498  return GNUNET_CONTAINER_multihashmap_put(plugin->hm,
499  &hkey,
500  entry,
502 }
503 
504 
515 static int
517  const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
518  const char *label,
520  void *iter_cls)
521 {
522  struct Plugin *plugin = cls;
523  struct FlatFileEntry *entry;
524  struct GNUNET_HashCode hkey;
525 
526  if (NULL == zone)
527  {
528  GNUNET_break(0);
529  return GNUNET_SYSERR;
530  }
531  hash_pkey_and_label(zone,
532  label,
533  &hkey);
534  entry = GNUNET_CONTAINER_multihashmap_get(plugin->hm,
535  &hkey);
536 
537  if (NULL == entry)
538  return GNUNET_NO;
539  if (NULL != iter)
540  iter(iter_cls,
541  1, /* zero is illegal */
542  &entry->private_key,
543  entry->label,
544  entry->record_count,
545  entry->record_data);
546  return GNUNET_YES;
547 }
548 
549 
557  uint64_t offset;
558 
562  uint64_t limit;
563 
568  uint64_t pos;
569 
574 
579 
583  void *iter_cls;
584 };
585 
586 
595 static int
596 iterate_zones(void *cls,
597  const struct GNUNET_HashCode *key,
598  void *value)
599 {
600  struct IterateContext *ic = cls;
601  struct FlatFileEntry *entry = value;
602 
603  (void)key;
604  if (0 == ic->limit)
605  return GNUNET_NO;
606  if ((NULL != ic->zone) &&
607  (0 != GNUNET_memcmp(&entry->private_key,
608  ic->zone)))
609  return GNUNET_YES;
610  ic->pos++;
611  if (ic->offset > 0)
612  {
613  ic->offset--;
614  return GNUNET_YES;
615  }
616  ic->iter(ic->iter_cls,
617  ic->pos,
618  (NULL == ic->zone)
619  ? &entry->private_key
620  : ic->zone,
621  entry->label,
622  entry->record_count,
623  entry->record_data);
624  ic->limit--;
625  if (0 == ic->limit)
626  return GNUNET_NO;
627  return GNUNET_YES;
628 }
629 
630 
643 static int
645  const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
646  uint64_t serial,
647  uint64_t limit,
649  void *iter_cls)
650 {
651  struct Plugin *plugin = cls;
652  struct IterateContext ic;
653 
654  ic.offset = serial;
655  ic.pos = 0;
656  ic.limit = limit;
657  ic.iter = iter;
658  ic.iter_cls = iter_cls;
659  ic.zone = zone;
661  &iterate_zones,
662  &ic);
663  return (0 == ic.limit) ? GNUNET_OK : GNUNET_NO;
664 }
665 
666 
674  void *iter_cls;
675 
677 };
678 
679 
680 static int
681 zone_to_name(void *cls,
682  const struct GNUNET_HashCode *key,
683  void *value)
684 {
685  struct ZoneToNameContext *ztn = cls;
686  struct FlatFileEntry *entry = value;
687 
688  (void)key;
689  if (0 != GNUNET_memcmp(&entry->private_key,
690  ztn->zone))
691  return GNUNET_YES;
692 
693  for (unsigned int i = 0; i < entry->record_count; i++)
694  {
696  continue;
697  if (0 == memcmp(ztn->value_zone,
698  entry->record_data[i].data,
699  sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)))
700  {
701  ztn->iter(ztn->iter_cls,
702  i + 1, /* zero is illegal! */
703  &entry->private_key,
704  entry->label,
705  entry->record_count,
706  entry->record_data);
707  ztn->result_found = GNUNET_YES;
708  }
709  }
710  return GNUNET_YES;
711 }
712 
713 
725 static int
727  const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
728  const struct GNUNET_CRYPTO_EcdsaPublicKey *value_zone,
730  void *iter_cls)
731 {
732  struct Plugin *plugin = cls;
733  struct ZoneToNameContext ztn = {
734  .iter = iter,
735  .iter_cls = iter_cls,
736  .zone = zone,
737  .value_zone = value_zone,
738  .result_found = GNUNET_NO
739  };
740 
742  "Performing reverse lookup for `%s'\n",
743  GNUNET_GNSRECORD_z2s(value_zone));
745  &zone_to_name,
746  &ztn);
747  return ztn.result_found;
748 }
749 
750 
757 void *
759 {
760  static struct Plugin plugin;
761  const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
763 
764  if (NULL != plugin.cfg)
765  return NULL; /* can only initialize once! */
766  memset(&plugin,
767  0,
768  sizeof(struct Plugin));
769  plugin.cfg = cfg;
770  if (GNUNET_OK != database_setup(&plugin))
771  {
772  database_shutdown(&plugin);
773  return NULL;
774  }
776  api->cls = &plugin;
782  _("Flat file database running\n"));
783  return api;
784 }
785 
786 
793 void *
795 {
797  struct Plugin *plugin = api->cls;
798 
799  database_shutdown(plugin);
800  plugin->cfg = NULL;
801  GNUNET_free(api);
803  "Flat file plugin is finished\n");
804  return NULL;
805 }
806 
807 /* end of plugin_namestore_flat.c */
int GNUNET_DISK_file_test(const char *fil)
Check that fil corresponds to a filename (of a file that exists and that is not a directory)...
Definition: disk.c:541
static void hash_pkey_and_label(const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const char *label, struct GNUNET_HashCode *h)
Hash contactenation of pkey and label into h.
Create file if it doesn&#39;t exist.
GNUNET_NETWORK_STRUCT_END ssize_t GNUNET_GNSRECORD_records_get_size(unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Calculate how many bytes we will need to serialize the given records.
int GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
Definition: disk.c:1339
static char * pkey
Public key of the zone to look in, in ASCII.
static int namestore_flat_lookup_records(void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label, GNUNET_NAMESTORE_RecordIterator iter, void *iter_cls)
Lookup records in the datastore for which we are the authority.
void * libgnunet_plugin_namestore_flat_init(void *cls)
Entry point for the plugin.
uint64_t GNUNET_CRYPTO_random_u64(enum GNUNET_CRYPTO_Quality mode, uint64_t max)
Random on unsigned 64-bit values.
ssize_t GNUNET_GNSRECORD_records_serialize(unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, size_t dest_size, char *dest)
Serialize the given records to the given destination buffer.
int(* zone_to_name)(void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const struct GNUNET_CRYPTO_EcdsaPublicKey *value_zone, GNUNET_NAMESTORE_RecordIterator iter, void *iter_cls)
Look for an existing PKEY delegation record for a given public key.
static int iterate_zones(void *cls, const struct GNUNET_HashCode *key, void *value)
Helper function for namestore_flat_iterate_records().
uint64_t offset
How many more records should we skip before returning results?
const struct GNUNET_CRYPTO_EcdsaPrivateKey * zone
Target zone.
static struct GNUNET_CADET_Handle * mh
Cadet handle.
Definition: gnunet-cadet.c:92
GNUNET_NAMESTORE_RecordIterator iter
char * key
TLS key.
void * GNUNET_DISK_file_map(const struct GNUNET_DISK_FileHandle *h, struct GNUNET_DISK_MapHandle **m, enum GNUNET_DISK_MapType access, size_t len)
Map a file into memory.
Definition: disk.c:1433
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
static int namestore_flat_iterate_records(void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, uint64_t serial, uint64_t limit, GNUNET_NAMESTORE_RecordIterator iter, void *iter_cls)
Iterate over the results for a particular key and zone in the datastore.
static void database_shutdown(struct Plugin *plugin)
Shutdown database connection and associate data structures.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
uint64_t rvalue
Rvalue.
int GNUNET_DISK_directory_create_for_file(const char *filename)
Create the directory structure for storing a file.
Definition: disk.c:681
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
size_t data_size
Number of bytes in data.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Private ECC key encoded for transmission.
int GNUNET_CONTAINER_multihashmap_remove_all(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Remove all entries for the given key from the map.
void(* GNUNET_NAMESTORE_RecordIterator)(void *cls, uint64_t serial, const struct GNUNET_CRYPTO_EcdsaPrivateKey *private_key, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Function called for each matching record.
int GNUNET_GNSRECORD_records_deserialize(size_t len, const char *src, unsigned int rd_count, struct GNUNET_GNSRECORD_Data *dest)
Deserialize the given records to the given destination.
static int ret
Final status code.
Definition: gnunet-arm.c:89
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define SIZE_MAX
Definition: platform.h:215
Internal representation of the hash map.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:94
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:46
void * GNUNET_CONTAINER_multihashmap_get(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Given a key find a value in the map matching the key.
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
Closure for iterate_zones.
static int namestore_flat_store_records(void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Store a record in the datastore.
uint64_t limit
How many more records should we return?
common internal definitions for namestore service
static char * zone
Name of the zone we manage.
const struct GNUNET_CRYPTO_EcdsaPublicKey * value_zone
void * cls
Closure to pass to all plugin functions.
static uint64_t record_count
Record count.
GNUNET_NAMESTORE_RecordIterator iter
Function to call on each record.
static struct GNUNET_ATS_SolverFunctions * plugin
Our solver.
#define GNUNET_log_strerror(level, cmd)
Log an error message at log-level &#39;level&#39; that indicates a failure of the command &#39;cmd&#39; with the mess...
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
const void * data
Binary value stored in the DNS record.
static char * line
Desired phone line (string to be converted to a hash).
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
static char * value
Value of the record to add/remove.
#define GNUNET_GNSRECORD_TYPE_PKEY
Record type for GNS zone transfer ("PKEY").
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:44
Truncate file if it exists.
ssize_t GNUNET_DISK_file_write(const struct GNUNET_DISK_FileHandle *h, const void *buffer, size_t n)
Write a buffer to a file.
Definition: disk.c:817
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
uint64_t expiration_time
Expiration time for the DNS record.
Read-only memory map.
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
char * label
Label.
Closure for zone_to_name.
static int fh
Handle to the unique file.
A 512-bit hashcode.
const char * GNUNET_GNSRECORD_z2s(const struct GNUNET_CRYPTO_EcdsaPublicKey *z)
Convert a zone key to a string (for printing debug messages).
size_t GNUNET_STRINGS_base64_decode(const char *data, size_t len, void **output)
Decode from Base64.
Definition: strings.c:1920
size_t GNUNET_STRINGS_base64_encode(const void *in, size_t len, char **output)
Encode into Base64.
Definition: strings.c:1856
There must only be one value per key; storing a value should fail if a value under the same key alrea...
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
int GNUNET_DISK_file_unmap(struct GNUNET_DISK_MapHandle *h)
Unmap a file.
Definition: disk.c:1469
struct GNUNET_CONTAINER_MultiHashMap * hm
HashMap.
void * iter_cls
Iterator cls.
uint32_t record_count
Record cound.
void * iter_cls
Closure for iter.
int GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
int GNUNET_DISK_file_size(const char *filename, uint64_t *size, int include_symbolic_links, int single_file_mode)
Get the size of the file (or directory) of the given file (in bytes).
Definition: disk.c:254
void * libgnunet_plugin_namestore_flat_done(void *cls)
Exit point from the plugin.
char * fn
Filename used for the DB.
const struct GNUNET_CRYPTO_EcdsaPrivateKey * zone
struct GNUNET_GNSRECORD_Data * record_data
Record data.
int(* lookup_records)(void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label, GNUNET_NAMESTORE_RecordIterator iter, void *iter_cls)
Lookup records in the datastore for which we are the authority.
uint32_t record_type
Type of the GNS/DNS record.
unsigned long long size
Size of all values we&#39;re storing.
configuration data
Definition: configuration.c:83
Handle for a plugin.
Definition: block.c:37
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
#define GNUNET_log(kind,...)
Open the file for both reading and writing.
static int database_setup(struct Plugin *plugin)
Initialize the database connections and associated data structures (create tables and indices as need...
static int namestore_flat_zone_to_name(void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const struct GNUNET_CRYPTO_EcdsaPublicKey *value_zone, GNUNET_NAMESTORE_RecordIterator iter, void *iter_cls)
Look for an existing PKEY delegation record for a given public key.
int GNUNET_CONFIGURATION_get_value_filename(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be the name of a file or directory.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
#define GNUNET_YES
Definition: gnunet_common.h:77
enum GNUNET_GNSRECORD_Flags flags
Flags for the record.
#define GNUNET_log_from(kind, comp,...)
sqlite3_stmt * zone_to_name
Precompiled SQL to for reverse lookup based on PKEY.
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
uint32_t data
The data value.
struct GNUNET_DISK_FileHandle * GNUNET_DISK_file_open(const char *fn, enum GNUNET_DISK_OpenFlags flags, enum GNUNET_DISK_AccessPermissions perm)
Open a file.
Definition: disk.c:1262
int(* store_records)(void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Store a record in the datastore for which we are the authority.
static size_t data_size
Number of bytes in data.
GNUNET_PEERSTORE_Processor iter
Iterator.
struct returned by the initialization function of the plugin
Handle used to access files (and pipes).
static int store_and_free_entries(void *cls, const struct GNUNET_HashCode *key, void *value)
Store values in hashmap in file and free data.
int(* iterate_records)(void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, uint64_t serial, uint64_t limit, GNUNET_NAMESTORE_RecordIterator iter, void *iter_cls)
Iterate over the results for a particular zone in the datastore.
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
#define GNUNET_malloc(size)
Wrapper around malloc.
Handle for a memory-mapping operation.
Definition: disk.c:1406
#define GNUNET_free(ptr)
Wrapper around free.
uint64_t pos
What is the position of the current entry, counting starts from 1.
struct GNUNET_CRYPTO_EcdsaPrivateKey private_key
Entry zone.