GNUnet  0.11.x
fs_namespace.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet
3  Copyright (C) 2003-2013 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 
27 #include "platform.h"
28 #include "gnunet_constants.h"
29 #include "gnunet_signatures.h"
30 #include "gnunet_util_lib.h"
31 #include "gnunet_fs_service.h"
32 #include "fs_api.h"
33 #include "fs_publish_ublock.h"
34 
35 
41 {
45  char *id;
46 
50  char *update;
51 
56 
60  struct GNUNET_FS_Uri *uri;
61 
66  unsigned int nug;
67 
71  unsigned int tree_id;
72 };
73 
74 
79 {
84 
89 
94 
100 
104  unsigned int update_node_count;
105 
109  unsigned int rc;
110 
114  unsigned int nug_gen;
115 };
116 
117 
126 static char *
128  struct GNUNET_FS_Handle *h,
129  const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns)
130 {
131  char *dn;
132  char *ret;
133  struct GNUNET_CRYPTO_EcdsaPublicKey pub;
134  struct GNUNET_HashCode hc;
136 
137  if (GNUNET_OK !=
138  GNUNET_CONFIGURATION_get_value_filename (h->cfg, "FS", "UPDATE_DIR", &dn))
139  {
141  return NULL;
142  }
144  GNUNET_CRYPTO_hash (&pub, sizeof(pub), &hc);
145  GNUNET_CRYPTO_hash_to_enc (&hc, &enc);
146  GNUNET_asprintf (&ret,
147  "%s%s%s",
148  dn,
150  (const char *) enc.encoding);
151  GNUNET_free (dn);
152  return ret;
153 }
154 
155 
161 static void
163 {
164  unsigned int i;
165  struct NamespaceUpdateNode *nsn;
166 
167  for (i = 0; i < uig->update_node_count; i++)
168  {
169  nsn = uig->update_nodes[i];
171  GNUNET_FS_uri_destroy (nsn->uri);
172  GNUNET_free (nsn->id);
173  GNUNET_free (nsn->update);
174  GNUNET_free (nsn);
175  }
177  if (NULL != uig->update_map)
179  GNUNET_free (uig);
180 }
181 
182 
188 static void
190 {
191  char *fn;
192  struct GNUNET_BIO_WriteHandle *wh;
193  unsigned int i;
194  struct NamespaceUpdateNode *n;
195  char *uris;
196 
197  fn = get_update_information_directory (uig->h, &uig->ns);
198  wh = GNUNET_BIO_write_open (fn);
199  if (NULL == wh)
200  {
202  _ ("Failed to open `%s' for writing: %s\n"),
203  fn,
204  strerror (errno));
205  GNUNET_free (fn);
206  return;
207  }
209  goto END;
210  for (i = 0; i < uig->update_node_count; i++)
211  {
212  n = uig->update_nodes[i];
213  uris = GNUNET_FS_uri_to_string (n->uri);
214  if ((GNUNET_OK != GNUNET_BIO_write_string (wh, n->id)) ||
215  (GNUNET_OK != GNUNET_BIO_write_meta_data (wh, n->md)) ||
216  (GNUNET_OK != GNUNET_BIO_write_string (wh, n->update)) ||
217  (GNUNET_OK != GNUNET_BIO_write_string (wh, uris)))
218  {
219  GNUNET_free (uris);
220  break;
221  }
222  GNUNET_free (uris);
223  }
224 END:
225  if (GNUNET_OK != GNUNET_BIO_write_close (wh))
227  _ ("Failed to write `%s': %s\n"),
228  fn,
229  strerror (errno));
230  GNUNET_free (fn);
231 }
232 
233 
241 static struct GNUNET_FS_UpdateInformationGraph *
243  const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns)
244 {
246  char *fn;
247  struct GNUNET_BIO_ReadHandle *rh;
248  unsigned int i;
249  struct NamespaceUpdateNode *n;
250  char *uris;
251  uint32_t count;
252  char *emsg;
253 
255  uig->h = h;
256  uig->ns = *ns;
258  if (GNUNET_YES != GNUNET_DISK_file_test (fn))
259  {
260  GNUNET_free (fn);
261  return uig;
262  }
263  rh = GNUNET_BIO_read_open (fn);
264  if (NULL == rh)
265  {
266  GNUNET_free (fn);
267  return uig;
268  }
269  if (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &count))
270  {
271  GNUNET_break (0);
272  goto END;
273  }
274  if (count > 1024 * 1024)
275  {
276  GNUNET_break (0);
277  goto END;
278  }
279  if (0 == count)
280  goto END;
281  uig->update_nodes =
282  GNUNET_malloc (count * sizeof(struct NamespaceUpdateNode *));
283 
284  for (i = 0; i < count; i++)
285  {
286  n = GNUNET_new (struct NamespaceUpdateNode);
287  if ((GNUNET_OK !=
288  GNUNET_BIO_read_string (rh, "identifier", &n->id, 1024)) ||
289  (GNUNET_OK != GNUNET_BIO_read_meta_data (rh, "meta", &n->md)) ||
290  (GNUNET_OK !=
291  GNUNET_BIO_read_string (rh, "update-id", &n->update, 1024)) ||
292  (GNUNET_OK != GNUNET_BIO_read_string (rh, "uri", &uris, 1024 * 2)))
293  {
294  GNUNET_break (0);
297  if (n->md != NULL)
299  GNUNET_free (n);
300  break;
301  }
302  n->uri = GNUNET_FS_uri_parse (uris, &emsg);
303  GNUNET_free (uris);
304  if (n->uri == NULL)
305  {
306  GNUNET_break (0);
307  GNUNET_free (emsg);
308  GNUNET_free (n->id);
311  GNUNET_free (n);
312  break;
313  }
314  uig->update_nodes[i] = n;
315  }
316  uig->update_node_count = i;
317 END:
318  if (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg))
319  {
321  _ ("Failed to read `%s': %s\n"),
322  fn,
323  emsg);
324  GNUNET_free (emsg);
325  }
326  GNUNET_free (fn);
327  return uig;
328 }
329 
330 
335 {
340 
346 
351 
356 
361 
366 
370  void *cont_cls;
371 
376 };
377 
378 
386 static void
387 sks_publish_cont (void *cls, const char *msg)
388 {
389  struct GNUNET_FS_PublishSksContext *psc = cls;
391 
392  psc->uc = NULL;
393  if (NULL != msg)
394  {
395  if (NULL != psc->cont)
396  psc->cont (psc->cont_cls, NULL, msg);
398  return;
399  }
400  if (NULL != psc->nsn)
401  {
402  /* FIXME: this can be done much more
403  * efficiently by simply appending to the
404  * file and overwriting the 4-byte header */
405  uig = read_update_information_graph (psc->h, &psc->ns);
407  psc->nsn = NULL;
410  }
411  if (NULL != psc->cont)
412  psc->cont (psc->cont_cls, psc->uri, NULL);
414 }
415 
416 
434  const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns,
435  const char *identifier,
436  const char *update,
437  const struct GNUNET_CONTAINER_MetaData *meta,
438  const struct GNUNET_FS_Uri *uri,
439  const struct GNUNET_FS_BlockOptions *bo,
442  void *cont_cls)
443 {
444  struct GNUNET_FS_PublishSksContext *psc;
445  struct GNUNET_FS_Uri *sks_uri;
446 
447  sks_uri = GNUNET_new (struct GNUNET_FS_Uri);
448  sks_uri->type = GNUNET_FS_URI_SKS;
449  sks_uri->data.sks.identifier = GNUNET_strdup (identifier);
450  GNUNET_CRYPTO_ecdsa_key_get_public (ns, &sks_uri->data.sks.ns);
451 
453  psc->h = h;
454  psc->uri = sks_uri;
455  psc->cont = cont;
456  psc->cont_cls = cont_cls;
457  psc->ns = *ns;
458  if (0 == (options & GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY))
459  {
460  psc->dsh = GNUNET_DATASTORE_connect (h->cfg);
461  if (NULL == psc->dsh)
462  {
463  sks_publish_cont (psc, _ ("Failed to connect to datastore."));
464  return NULL;
465  }
466  }
467  if (NULL != update)
468  {
469  psc->nsn = GNUNET_new (struct NamespaceUpdateNode);
470  psc->nsn->id = GNUNET_strdup (identifier);
471  psc->nsn->update = GNUNET_strdup (update);
473  psc->nsn->uri = GNUNET_FS_uri_dup (uri);
474  }
475  psc->uc = GNUNET_FS_publish_ublock_ (h,
476  psc->dsh,
477  identifier,
478  update,
479  ns,
480  meta,
481  uri,
482  bo,
483  options,
485  psc);
486  return psc;
487 }
488 
489 
495 void
497 {
498  if (NULL != psc->uc)
499  {
501  psc->uc = NULL;
502  }
503  if (NULL != psc->dsh)
504  {
506  psc->dsh = NULL;
507  }
508  GNUNET_FS_uri_destroy (psc->uri);
509  if (NULL != psc->nsn)
510  {
512  GNUNET_FS_uri_destroy (psc->nsn->uri);
513  GNUNET_free (psc->nsn->id);
514  GNUNET_free (psc->nsn->update);
515  GNUNET_free (psc->nsn);
516  }
517  GNUNET_free (psc);
518 }
519 
520 
525 {
530 
534  void *ip_cls;
535 };
536 
537 
548 static int
549 process_update_node (void *cls, const struct GNUNET_HashCode *key, void *value)
550 {
551  struct ProcessUpdateClosure *pc = cls;
552  struct NamespaceUpdateNode *nsn = value;
553 
554  pc->ip (pc->ip_cls, nsn->id, nsn->uri, nsn->md, nsn->update);
555  return GNUNET_YES;
556 }
557 
558 
563 {
568 
573 
577  unsigned int tree_array_size;
578 
582  unsigned int nug;
583 
587  unsigned int id;
588 };
589 
590 
611 static int
612 find_trees (void *cls, const struct GNUNET_HashCode *key, void *value)
613 {
614  struct FindTreeClosure *fc = cls;
615  struct NamespaceUpdateNode *nsn = value;
616  struct GNUNET_HashCode hc;
617 
618  if (nsn->nug == fc->nug)
619  {
620  if (UINT_MAX == nsn->tree_id)
621  return GNUNET_YES; /* circular */
623  if (fc->tree_array[nsn->tree_id] != nsn)
624  return GNUNET_YES; /* part of "another" (directed) TREE,
625  * and not root of it, end trace */
626  if (nsn->tree_id == fc->id)
627  return GNUNET_YES; /* that's our own root (can this be?) */
628  /* merge existing TREE, we have a root for both */
629  fc->tree_array[nsn->tree_id] = NULL;
630  if (UINT_MAX == fc->id)
631  fc->id = nsn->tree_id; /* take over ID */
632  }
633  else
634  {
635  nsn->nug = fc->nug;
636  nsn->tree_id = UINT_MAX; /* mark as undef */
637  /* trace */
638  GNUNET_CRYPTO_hash (nsn->update, strlen (nsn->update), &hc);
640  &hc,
641  &find_trees,
642  fc);
643  }
644  return GNUNET_YES;
645 }
646 
647 
671 void
673  struct GNUNET_FS_Handle *h,
674  const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns,
675  const char *next_id,
677  void *ip_cls)
678 {
679  unsigned int i;
680  unsigned int nug;
681  struct GNUNET_HashCode hc;
682  struct NamespaceUpdateNode *nsn;
683  struct ProcessUpdateClosure pc;
684  struct FindTreeClosure fc;
686 
687  uig = read_update_information_graph (h, ns);
688  if (NULL == uig->update_nodes)
689  {
691  "No updateable nodes found for ID `%s'\n",
692  next_id);
694  return; /* no nodes */
695  }
696  uig->update_map =
698  GNUNET_NO);
699  for (i = 0; i < uig->update_node_count; i++)
700  {
701  nsn = uig->update_nodes[i];
702  GNUNET_CRYPTO_hash (nsn->id, strlen (nsn->id), &hc);
704  uig->update_map,
705  &hc,
706  nsn,
708  }
709  if (NULL != next_id)
710  {
711  GNUNET_CRYPTO_hash (next_id, strlen (next_id), &hc);
712  pc.ip = ip;
713  pc.ip_cls = ip_cls;
715  &hc,
717  &pc);
719  return;
720  }
722  "Calculating TREEs to find roots of update trees\n");
723  /* Find heads of TREEs in update graph */
724  nug = ++uig->nug_gen;
725  fc.tree_array = NULL;
726  fc.tree_array_size = 0;
727 
728  for (i = 0; i < uig->update_node_count; i++)
729  {
730  nsn = uig->update_nodes[i];
731  if (nsn->nug == nug)
732  {
734  "TREE of node `%s' is %u\n",
735  nsn->id,
736  nsn->nug);
737  continue; /* already placed in TREE */
738  }
739  GNUNET_CRYPTO_hash (nsn->update, strlen (nsn->update), &hc);
740  nsn->nug = nug;
741  nsn->tree_id = UINT_MAX;
742  fc.id = UINT_MAX;
743  fc.nug = nug;
744  fc.uig = uig;
746  &hc,
747  &find_trees,
748  &fc);
749  if (UINT_MAX == fc.id)
750  {
751  /* start new TREE */
752  for (fc.id = 0; fc.id < fc.tree_array_size; fc.id++)
753  {
754  if (NULL == fc.tree_array[fc.id])
755  {
756  fc.tree_array[fc.id] = nsn;
757  nsn->tree_id = fc.id;
758  break;
759  }
760  }
761  if (fc.id == fc.tree_array_size)
762  {
764  nsn->tree_id = fc.id;
765  }
767  "Starting new TREE %u with node `%s'\n",
768  nsn->tree_id,
769  nsn->id);
770  /* put all nodes with same identifier into this TREE */
771  GNUNET_CRYPTO_hash (nsn->id, strlen (nsn->id), &hc);
772  fc.id = nsn->tree_id;
773  fc.nug = nug;
774  fc.uig = uig;
776  &hc,
777  &find_trees,
778  &fc);
779  }
780  else
781  {
782  /* make head of TREE "id" */
783  fc.tree_array[fc.id] = nsn;
784  nsn->tree_id = fc.id;
785  }
787  "TREE of node `%s' is %u\n",
788  nsn->id,
789  fc.id);
790  }
791  for (i = 0; i < fc.tree_array_size; i++)
792  {
793  nsn = fc.tree_array[i];
794  if (NULL != nsn)
795  {
797  "Root of TREE %u is node `%s'\n",
798  i,
799  nsn->id);
800  ip (ip_cls, nsn->id, nsn->uri, nsn->md, nsn->update);
801  }
802  }
804  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Done processing TREEs\n");
806 }
807 
808 
809 /* end of fs_namespace.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:544
int GNUNET_BIO_write_meta_data(struct GNUNET_BIO_WriteHandle *h, const struct GNUNET_CONTAINER_MetaData *m)
Write metadata container to a file.
Definition: bio.c:544
GNUNET_FS_PublishContinuation cont
Function to call once we&#39;re done.
Definition: fs_namespace.c:365
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
struct GNUNET_FS_Uri * uri
URI of the new entry in the namespace.
Definition: fs_namespace.c:339
struct GNUNET_FS_Uri::@13::@15 sks
Context for the SKS publication.
Definition: fs_namespace.c:334
struct GNUNET_FS_Uri * uri
URI of this entry in the namespace.
Definition: fs_namespace.c:60
static void write_update_information_graph(struct GNUNET_FS_UpdateInformationGraph *uig)
Write a namespace&#39;s update node graph to a file.
Definition: fs_namespace.c:189
struct GNUNET_FS_Uri * GNUNET_FS_uri_parse(const char *uri, char **emsg)
Convert a UTF-8 String to a URI.
Definition: fs_uri.c:644
Master context for most FS operations.
Definition: fs_api.h:1068
int GNUNET_BIO_write_string(struct GNUNET_BIO_WriteHandle *h, const char *s)
Write a string to a file.
Definition: bio.c:523
struct GNUNET_FS_Handle * h
Handle to the FS service context.
Definition: fs_namespace.c:83
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
unsigned int nug
Namespace update generation ID.
Definition: fs_namespace.c:66
struct GNUNET_FS_Handle * h
Handle to FS.
Definition: fs_namespace.c:360
struct GNUNET_FS_PublishSksContext * GNUNET_FS_publish_sks(struct GNUNET_FS_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns, const char *identifier, const char *update, const struct GNUNET_CONTAINER_MetaData *meta, const struct GNUNET_FS_Uri *uri, const struct GNUNET_FS_BlockOptions *bo, enum GNUNET_FS_PublishOptions options, GNUNET_FS_PublishContinuation cont, void *cont_cls)
Publish an SBlock on GNUnet.
Definition: fs_namespace.c:433
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
We&#39;re done processing.
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Private ECC key encoded for transmission.
void GNUNET_FS_namespace_list_updateable(struct GNUNET_FS_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns, const char *next_id, GNUNET_FS_IdentifierProcessor ip, void *ip_cls)
List all of the identifiers in the namespace for which we could produce an update.
Definition: fs_namespace.c:672
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
static void sks_publish_cont(void *cls, const char *msg)
Function called by the UBlock construction with the result from the PUT (UBlock) request.
Definition: fs_namespace.c:387
struct GNUNET_FS_Uri * GNUNET_FS_uri_dup(const struct GNUNET_FS_Uri *uri)
Duplicate URI.
Definition: fs_uri.c:998
Internal representation of the hash map.
int GNUNET_BIO_read_close(struct GNUNET_BIO_ReadHandle *h, char **emsg)
Close an open file.
Definition: bio.c:119
#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:99
static int find_trees(void *cls, const struct GNUNET_HashCode *key, void *value)
Find all nodes reachable from the current node (including the current node itself).
Definition: fs_namespace.c:612
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
GNUNET_FS_IdentifierProcessor ip
Function to call for each node.
Definition: fs_namespace.c:529
char * GNUNET_FS_uri_to_string(const struct GNUNET_FS_Uri *uri)
Convert a URI to a UTF-8 String.
Definition: fs_uri.c:2028
unsigned int rc
Reference counter.
Definition: fs_namespace.c:109
struct GNUNET_BIO_ReadHandle * GNUNET_BIO_read_open(const char *fn)
Open a file for reading.
Definition: bio.c:94
static void free_update_information_graph(struct GNUNET_FS_UpdateInformationGraph *uig)
Release memory occupied by UIG datastructure.
Definition: fs_namespace.c:162
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
Meta data to associate with a file, directory or namespace.
char * id
Identifier for this node.
Definition: fs_namespace.c:45
#define GNUNET_array_grow(arr, size, tsize)
Grow a well-typed (!) array.
Closure for &#39;find_trees&#39;.
Definition: fs_namespace.c:562
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.
unsigned int update_node_count
Size of the update nodes array.
Definition: fs_namespace.c:104
unsigned int tree_array_size
Size of &#39;tree_array&#39;.
Definition: fs_namespace.c:577
struct GNUNET_CRYPTO_EcdsaPrivateKey ns
Private key for the namespace.
Definition: fs_namespace.c:93
static char * fn
Filename of the unique file.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:48
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
struct GNUNET_CRYPTO_EcdsaPrivateKey ns
Namespace we&#39;re publishing to.
Definition: fs_namespace.c:350
#define DIR_SEPARATOR_STR
Definition: platform.h:168
static int process_update_node(void *cls, const struct GNUNET_HashCode *key, void *value)
Call the iterator in the closure for each node.
Definition: fs_namespace.c:549
void(* GNUNET_FS_IdentifierProcessor)(void *cls, const char *last_id, const struct GNUNET_FS_Uri *last_uri, const struct GNUNET_CONTAINER_MetaData *last_meta, const char *next_id)
Function called on updateable identifiers.
void GNUNET_FS_publish_sks_cancel(struct GNUNET_FS_PublishSksContext *psc)
Abort the SKS publishing operation.
Definition: fs_namespace.c:496
static struct GNUNET_NAMESTORE_Handle * ns
Handle to the namestore.
Definition: gnunet-abd.c:41
void(* GNUNET_FS_PublishContinuation)(void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg)
Signature of a function called as the continuation of a KBlock or SBlock publication.
void GNUNET_CONTAINER_meta_data_destroy(struct GNUNET_CONTAINER_MetaData *md)
Free meta data.
GNUNET_FS_PublishOptions
Options for publishing.
char * update
Identifier of children of this node.
Definition: fs_namespace.c:50
Handle for buffered writing.
Definition: bio.c:379
unsigned int tree_id
TREE this entry belongs to (if nug is current).
Definition: fs_namespace.c:71
void GNUNET_FS_uri_destroy(struct GNUNET_FS_Uri *uri)
Free URI.
Definition: fs_uri.c:678
A 512-bit hashcode.
int GNUNET_BIO_read_string(struct GNUNET_BIO_ReadHandle *h, const char *what, char **result, size_t max_length)
Read 0-terminated string from a file.
Definition: bio.c:233
void GNUNET_FS_publish_ublock_cancel_(struct GNUNET_FS_PublishUblockContext *uc)
Abort UBlock publishing operation.
struct GNUNET_CONTAINER_MultiHashMap * update_map
Hash map mapping identifiers of update nodes to the update nodes (initialized on-demand).
Definition: fs_namespace.c:99
struct GNUNET_HashCode key
The key used in the DHT.
void GNUNET_CRYPTO_hash_to_enc(const struct GNUNET_HashCode *block, struct GNUNET_CRYPTO_HashAsciiEncoded *result)
Convert hash to ASCII encoding.
Definition: crypto_hash.c:73
void GNUNET_CRYPTO_ecdsa_key_get_public(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Extract the public key for the given private key.
Definition: crypto_ecc.c:239
#define GNUNET_BIO_read_int32(h, i)
Read an (u)int32_t.
Closure for &#39;process_update_node&#39;.
Definition: fs_namespace.c:524
struct GNUNET_FS_PublishUblockContext * GNUNET_FS_publish_ublock_(struct GNUNET_FS_Handle *h, struct GNUNET_DATASTORE_Handle *dsh, const char *label, const char *ulabel, const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns, const struct GNUNET_CONTAINER_MetaData *meta, const struct GNUNET_FS_Uri *uri, const struct GNUNET_FS_BlockOptions *bo, enum GNUNET_FS_PublishOptions options, GNUNET_FS_UBlockContinuation cont, void *cont_cls)
Publish a UBlock.
Settings for publishing a block (which may of course also apply to an entire directory or file)...
Information about an (updateable) node in the namespace.
Definition: fs_namespace.c:40
static struct GNUNET_TESTBED_BarrierWaitHandle * wh
Our barrier wait handle.
enum GNUNET_FS_UriType type
Type of the URI.
Definition: fs_api.h:170
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.
struct NamespaceUpdateNode ** update_nodes
Array with information about nodes in the namespace.
Definition: fs_namespace.c:88
int GNUNET_BIO_write_close(struct GNUNET_BIO_WriteHandle *h)
Close an open file for writing.
Definition: bio.c:438
unsigned int nug
Current generational ID used.
Definition: fs_namespace.c:582
union GNUNET_FS_Uri::@13 data
0-terminated ASCII encoding of a struct GNUNET_HashCode.
Allow multiple values with the same key.
unsigned int id
Identifier for the current TREE, or UINT_MAX for none yet.
Definition: fs_namespace.c:587
Signed key space (file in namespace).
Definition: fs_api.h:148
#define GNUNET_array_append(arr, size, element)
Append an element to a list (growing the list by one).
void * ip_cls
Closure for &#39;ip&#39;.
Definition: fs_namespace.c:534
static struct GNUNET_FS_PublishContext * pc
Handle to FS-publishing operation.
int GNUNET_CONTAINER_multihashmap_get_multiple(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map that match a particular key.
static char * next_id
Command-line option for namespace publishing: identifier for updates to this publication.
static char * get_update_information_directory(struct GNUNET_FS_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns)
Return the name of the directory in which we store the update information graph for the given local n...
Definition: fs_namespace.c:127
struct GNUNET_FS_UpdateInformationGraph * uig
UIG we are operating on.
Definition: fs_namespace.c:567
struct GNUNET_CONTAINER_MetaData * md
Metadata for this entry.
Definition: fs_namespace.c:55
shared definitions for the FS library
void GNUNET_DATASTORE_disconnect(struct GNUNET_DATASTORE_Handle *h, int drop)
Disconnect from the datastore service (and free associated resources).
struct GNUNET_BIO_WriteHandle * GNUNET_BIO_write_open(const char *fn)
Open a file for writing.
Definition: bio.c:410
Context for &#39;ublock_put_cont&#39;.
A Universal Resource Identifier (URI), opaque.
Definition: fs_api.h:165
Handle to the datastore service.
static struct GNUNET_CONTAINER_MetaData * meta
Meta-data provided via command-line option.
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
#define GNUNET_log(kind,...)
unsigned int nug_gen
Generator for unique nug numbers.
Definition: fs_namespace.c:114
struct NamespaceUpdateNode * nsn
Namespace update node to add to namespace on success (or to be deleted if publishing failed)...
Definition: fs_namespace.c:345
struct GNUNET_DATASTORE_Handle * dsh
Handle to the datastore.
Definition: fs_namespace.c:355
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.
struct NamespaceUpdateNode ** tree_array
Array with &#39;head&#39;s of TREEs.
Definition: fs_namespace.c:572
int GNUNET_BIO_write_int32(struct GNUNET_BIO_WriteHandle *h, int32_t i)
Write an (u)int32_t.
Definition: bio.c:582
void * cont_cls
Closure for cont.
Definition: fs_namespace.c:370
int GNUNET_BIO_read_meta_data(struct GNUNET_BIO_ReadHandle *h, const char *what, struct GNUNET_CONTAINER_MetaData **result)
Read metadata container from a file.
Definition: bio.c:285
#define GNUNET_YES
Definition: gnunet_common.h:77
static struct GNUNET_FS_UpdateInformationGraph * read_update_information_graph(struct GNUNET_FS_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns)
Read the namespace update node graph from a file.
Definition: fs_namespace.c:242
struct GNUNET_FS_PublishUblockContext * uc
Handle for our UBlock operation request.
Definition: fs_namespace.c:375
struct GNUNET_DATASTORE_Handle * GNUNET_DATASTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the datastore service.
Handle to update information for a namespace.
Definition: fs_namespace.c:78
#define GNUNET_malloc(size)
Wrapper around malloc.
Handle for buffered reading.
Definition: bio.c:53
static struct GNUNET_FS_BlockOptions bo
Options we set for published blocks.
#define GNUNET_free(ptr)
Wrapper around free.
publish a UBLOCK in GNUnet
struct GNUNET_CONTAINER_MetaData * GNUNET_CONTAINER_meta_data_duplicate(const struct GNUNET_CONTAINER_MetaData *md)
Duplicate a MetaData token.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Definition: fs_api.h:1073