GNUnet 0.21.0
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
32#include "gnunet_fs_service.h"
33#include "fs_api.h"
34#include "fs_publish_ublock.h"
35
36
42{
46 char *id;
47
51 char *update;
52
57
62
67 unsigned int nug;
68
72 unsigned int tree_id;
73};
74
75
80{
85
90
95
101
105 unsigned int update_node_count;
106
110 unsigned int rc;
111
115 unsigned int nug_gen;
116};
117
118
127static char *
129 struct GNUNET_FS_Handle *h,
130 const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns)
131{
132 char *dn;
133 char *ret;
135 struct GNUNET_HashCode hc;
137
138 if (GNUNET_OK !=
139 GNUNET_CONFIGURATION_get_value_filename (h->cfg, "FS", "UPDATE_DIR", &dn))
140 {
142 return NULL;
143 }
145 GNUNET_CRYPTO_hash (&pub, sizeof(pub), &hc);
148 "%s%s%s",
149 dn,
151 (const char *) enc.encoding);
152 GNUNET_free (dn);
153 return ret;
154}
155
156
162static void
164{
165 unsigned int i;
166 struct NamespaceUpdateNode *nsn;
167
168 for (i = 0; i < uig->update_node_count; i++)
169 {
170 nsn = uig->update_nodes[i];
173 GNUNET_free (nsn->id);
174 GNUNET_free (nsn->update);
175 GNUNET_free (nsn);
176 }
178 if (NULL != uig->update_map)
180 GNUNET_free (uig);
181}
182
183
189static void
191{
192 char *fn;
193 struct GNUNET_BIO_WriteHandle *wh;
194 unsigned int i;
195 struct NamespaceUpdateNode *n;
196 char *uris;
197
198 fn = get_update_information_directory (uig->h, &uig->ns);
200 if (NULL == wh)
201 {
203 _ ("Failed to open `%s' for writing: %s\n"),
204 fn,
205 strerror (errno));
206 GNUNET_free (fn);
207 return;
208 }
210 "fs-namespace-node-count",
211 uig->update_node_count))
212 goto END;
213 for (i = 0; i < uig->update_node_count; i++)
214 {
215 n = uig->update_nodes[i];
216 uris = GNUNET_FS_uri_to_string (n->uri);
217 struct GNUNET_BIO_WriteSpec ws[] = {
218 GNUNET_BIO_write_spec_string ("fs-namespace-node-id", n->id),
219 GNUNET_FS_write_spec_meta_data ("fs-namespace-node-meta", n->md),
220 GNUNET_BIO_write_spec_string ("fs-namespace-node-update", n->update),
221 GNUNET_BIO_write_spec_string ("fs-namespace-uris", uris),
223 };
225 {
226 GNUNET_free (uris);
227 break;
228 }
229 GNUNET_free (uris);
230 }
231 END:
232 if (GNUNET_OK != GNUNET_BIO_write_close (wh, NULL))
234 _ ("Failed to write `%s': %s\n"),
235 fn,
236 strerror (errno));
237 GNUNET_free (fn);
238}
239
240
250 const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns)
251{
253 char *fn;
254 struct GNUNET_BIO_ReadHandle *rh;
255 unsigned int i;
256 struct NamespaceUpdateNode *n;
257 char *uris;
258 uint32_t count;
259 char *emsg;
260
262 uig->h = h;
263 uig->ns = *ns;
266 {
267 GNUNET_free (fn);
268 return uig;
269 }
271 if (NULL == rh)
272 {
273 GNUNET_free (fn);
274 return uig;
275 }
276 if (GNUNET_OK != GNUNET_BIO_read_int32 (rh, "fs-namespace-count",
277 (int32_t *) &count))
278 {
279 GNUNET_break (0);
280 goto END;
281 }
282 if (count > 1024 * 1024)
283 {
284 GNUNET_break (0);
285 goto END;
286 }
287 if (0 == count)
288 goto END;
289 uig->update_nodes =
290 GNUNET_malloc (count * sizeof(struct NamespaceUpdateNode *));
291
292 for (i = 0; i < count; i++)
293 {
294 n = GNUNET_new (struct NamespaceUpdateNode);
295 struct GNUNET_BIO_ReadSpec rs[] = {
296 GNUNET_BIO_read_spec_string ("identifier", &n->id, 1024),
297 GNUNET_FS_read_spec_meta_data ("meta", &n->md),
298 GNUNET_BIO_read_spec_string ("update-id", &n->update, 1024),
299 GNUNET_BIO_read_spec_string ("uri", &uris, 1024 * 2),
301 };
303 {
304 GNUNET_break (0);
305 GNUNET_free (n->id);
306 GNUNET_free (n->update);
307 if (n->md != NULL)
309 GNUNET_free (n);
310 break;
311 }
312 n->uri = GNUNET_FS_uri_parse (uris, &emsg);
313 GNUNET_free (uris);
314 if (n->uri == NULL)
315 {
316 GNUNET_break (0);
317 GNUNET_free (emsg);
318 GNUNET_free (n->id);
319 GNUNET_free (n->update);
321 GNUNET_free (n);
322 break;
323 }
324 uig->update_nodes[i] = n;
325 }
326 uig->update_node_count = i;
327 END:
328 if (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg))
329 {
331 _ ("Failed to read `%s': %s\n"),
332 fn,
333 emsg);
334 GNUNET_free (emsg);
335 }
336 GNUNET_free (fn);
337 return uig;
338}
339
340
345{
350
356
361
366
371
376
380 void *cont_cls;
381
386};
387
388
396static void
397sks_publish_cont (void *cls, const char *msg)
398{
399 struct GNUNET_FS_PublishSksContext *psc = cls;
401
402 psc->uc = NULL;
403 if (NULL != msg)
404 {
405 if (NULL != psc->cont)
406 psc->cont (psc->cont_cls, NULL, msg);
408 return;
409 }
410 if (NULL != psc->nsn)
411 {
412 /* FIXME: this can be done much more
413 * efficiently by simply appending to the
414 * file and overwriting the 4-byte header */
415 uig = read_update_information_graph (psc->h, &psc->ns);
417 psc->nsn = NULL;
420 }
421 if (NULL != psc->cont)
422 psc->cont (psc->cont_cls, psc->uri, NULL);
424}
425
426
429 const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns,
430 const char *identifier,
431 const char *update,
432 const struct GNUNET_FS_MetaData *meta,
433 const struct GNUNET_FS_Uri *uri,
434 const struct GNUNET_FS_BlockOptions *bo,
437 void *cont_cls)
438{
439 struct GNUNET_FS_PublishSksContext *psc;
440 struct GNUNET_FS_Uri *sks_uri;
441
442 sks_uri = GNUNET_new (struct GNUNET_FS_Uri);
443 sks_uri->type = GNUNET_FS_URI_SKS;
446
448 psc->h = h;
449 psc->uri = sks_uri;
450 psc->cont = cont;
451 psc->cont_cls = cont_cls;
452 psc->ns = *ns;
454 {
456 if (NULL == psc->dsh)
457 {
458 sks_publish_cont (psc, _ ("Failed to connect to datastore."));
459 return NULL;
460 }
461 }
462 if (NULL != update)
463 {
464 psc->nsn = GNUNET_new (struct NamespaceUpdateNode);
465 psc->nsn->id = GNUNET_strdup (identifier);
466 psc->nsn->update = GNUNET_strdup (update);
468 psc->nsn->uri = GNUNET_FS_uri_dup (uri);
469 }
471 psc->dsh,
473 update,
474 ns,
475 meta,
476 uri,
477 bo,
478 options,
480 psc);
481 return psc;
482}
483
484
490void
492{
493 if (NULL != psc->uc)
494 {
496 psc->uc = NULL;
497 }
498 if (NULL != psc->dsh)
499 {
501 psc->dsh = NULL;
502 }
504 if (NULL != psc->nsn)
505 {
508 GNUNET_free (psc->nsn->id);
509 GNUNET_free (psc->nsn->update);
510 GNUNET_free (psc->nsn);
511 }
512 GNUNET_free (psc);
513}
514
515
520{
525
529 void *ip_cls;
530};
531
532
543static int
544process_update_node (void *cls, const struct GNUNET_HashCode *key, void *value)
545{
546 struct ProcessUpdateClosure *pc = cls;
547 struct NamespaceUpdateNode *nsn = value;
548
549 pc->ip (pc->ip_cls, nsn->id, nsn->uri, nsn->md, nsn->update);
550 return GNUNET_YES;
551}
552
553
558{
563
568
572 unsigned int tree_array_size;
573
577 unsigned int nug;
578
582 unsigned int id;
583};
584
585
606static int
607find_trees (void *cls, const struct GNUNET_HashCode *key, void *value)
608{
609 struct FindTreeClosure *fc = cls;
610 struct NamespaceUpdateNode *nsn = value;
611 struct GNUNET_HashCode hc;
612
613 if (nsn->nug == fc->nug)
614 {
615 if (UINT_MAX == nsn->tree_id)
616 return GNUNET_YES; /* circular */
618 if (fc->tree_array[nsn->tree_id] != nsn)
619 return GNUNET_YES; /* part of "another" (directed) TREE,
620 * and not root of it, end trace */
621 if (nsn->tree_id == fc->id)
622 return GNUNET_YES; /* that's our own root (can this be?) */
623 /* merge existing TREE, we have a root for both */
624 fc->tree_array[nsn->tree_id] = NULL;
625 if (UINT_MAX == fc->id)
626 fc->id = nsn->tree_id; /* take over ID */
627 }
628 else
629 {
630 nsn->nug = fc->nug;
631 nsn->tree_id = UINT_MAX; /* mark as undef */
632 /* trace */
633 GNUNET_CRYPTO_hash (nsn->update, strlen (nsn->update), &hc);
635 &hc,
636 &find_trees,
637 fc);
638 }
639 return GNUNET_YES;
640}
641
642
666void
668 struct GNUNET_FS_Handle *h,
669 const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns,
670 const char *next_id,
672 void *ip_cls)
673{
674 unsigned int i;
675 unsigned int nug;
676 struct GNUNET_HashCode hc;
677 struct NamespaceUpdateNode *nsn;
679 struct FindTreeClosure fc;
681
683 if (NULL == uig->update_nodes)
684 {
686 "No updateable nodes found for ID `%s'\n",
687 next_id);
689 return; /* no nodes */
690 }
691 uig->update_map =
693 GNUNET_NO);
694 for (i = 0; i < uig->update_node_count; i++)
695 {
696 nsn = uig->update_nodes[i];
697 GNUNET_CRYPTO_hash (nsn->id, strlen (nsn->id), &hc);
699 uig->update_map,
700 &hc,
701 nsn,
703 }
704 if (NULL != next_id)
705 {
706 GNUNET_CRYPTO_hash (next_id, strlen (next_id), &hc);
707 pc.ip = ip;
708 pc.ip_cls = ip_cls;
710 &hc,
712 &pc);
714 return;
715 }
717 "Calculating TREEs to find roots of update trees\n");
718 /* Find heads of TREEs in update graph */
719 nug = ++uig->nug_gen;
720 fc.tree_array = NULL;
721 fc.tree_array_size = 0;
722
723 for (i = 0; i < uig->update_node_count; i++)
724 {
725 nsn = uig->update_nodes[i];
726 if (nsn->nug == nug)
727 {
729 "TREE of node `%s' is %u\n",
730 nsn->id,
731 nsn->nug);
732 continue; /* already placed in TREE */
733 }
734 GNUNET_CRYPTO_hash (nsn->update, strlen (nsn->update), &hc);
735 nsn->nug = nug;
736 nsn->tree_id = UINT_MAX;
737 fc.id = UINT_MAX;
738 fc.nug = nug;
739 fc.uig = uig;
741 &hc,
742 &find_trees,
743 &fc);
744 if (UINT_MAX == fc.id)
745 {
746 /* start new TREE */
747 for (fc.id = 0; fc.id < fc.tree_array_size; fc.id++)
748 {
749 if (NULL == fc.tree_array[fc.id])
750 {
751 fc.tree_array[fc.id] = nsn;
752 nsn->tree_id = fc.id;
753 break;
754 }
755 }
756 if (fc.id == fc.tree_array_size)
757 {
759 nsn->tree_id = fc.id;
760 }
762 "Starting new TREE %u with node `%s'\n",
763 nsn->tree_id,
764 nsn->id);
765 /* put all nodes with same identifier into this TREE */
766 GNUNET_CRYPTO_hash (nsn->id, strlen (nsn->id), &hc);
767 fc.id = nsn->tree_id;
768 fc.nug = nug;
769 fc.uig = uig;
771 &hc,
772 &find_trees,
773 &fc);
774 }
775 else
776 {
777 /* make head of TREE "id" */
778 fc.tree_array[fc.id] = nsn;
779 nsn->tree_id = fc.id;
780 }
782 "TREE of node `%s' is %u\n",
783 nsn->id,
784 fc.id);
785 }
786 for (i = 0; i < fc.tree_array_size; i++)
787 {
788 nsn = fc.tree_array[i];
789 if (NULL != nsn)
790 {
792 "Root of TREE %u is node `%s'\n",
793 i,
794 nsn->id);
795 ip (ip_cls, nsn->id, nsn->uri, nsn->md, nsn->update);
796 }
797 }
799 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Done processing TREEs\n");
801}
802
803
804/* end of fs_namespace.c */
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
shared definitions for the FS library
@ GNUNET_FS_URI_SKS
Signed key space (file in namespace).
Definition: fs_api.h:149
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:544
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:397
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:128
static void free_update_information_graph(struct GNUNET_FS_UpdateInformationGraph *uig)
Release memory occupied by UIG datastructure.
Definition: fs_namespace.c:163
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:607
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:249
static void write_update_information_graph(struct GNUNET_FS_UpdateInformationGraph *uig)
Write a namespace's update node graph to a file.
Definition: fs_namespace.c:190
void GNUNET_FS_publish_ublock_cancel_(struct GNUNET_FS_PublishUblockContext *uc)
Abort UBlock publishing operation.
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_FS_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.
publish a UBLOCK in GNUnet
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
static int ret
Final status code.
Definition: gnunet-arm.c:94
@ END
We're done processing.
struct GNUNET_HashCode key
The key used in the DHT.
static OpusEncoder * enc
OPUS encoder.
static struct GNUNET_NAMECACHE_Handle * ns
Handle to the namecache.
static char * value
Value of the record to add/remove.
static struct GNUNET_FS_Uri * uri
Value of URI provided on command-line (when not publishing a file but just creating UBlocks to refer ...
static struct GNUNET_FS_MetaData * meta
Meta-data provided via command-line option.
static struct GNUNET_FS_BlockOptions bo
Options we set for published blocks.
static char * next_id
Command-line option for namespace publishing: identifier for updates to this publication.
static struct GNUNET_FS_PublishContext * pc
Handle to FS-publishing operation.
static struct GNUNET_CRYPTO_EddsaPublicKey pub
Definition: gnunet-scrypt.c:47
API for file sharing via GNUnet.
enum GNUNET_GenericReturnValue GNUNET_BIO_write_close(struct GNUNET_BIO_WriteHandle *h, char **emsg)
Close an IO handle.
Definition: bio.c:556
struct GNUNET_BIO_ReadSpec GNUNET_BIO_read_spec_string(const char *what, char **result, size_t max_length)
Create the specification to read a 0-terminated string.
Definition: bio.c:956
struct GNUNET_BIO_WriteHandle * GNUNET_BIO_write_open_file(const char *fn)
Open a file for writing.
Definition: bio.c:508
enum GNUNET_GenericReturnValue GNUNET_BIO_write_int32(struct GNUNET_BIO_WriteHandle *h, const char *what, int32_t i)
Write an (u)int32_t.
Definition: bio.c:847
enum GNUNET_GenericReturnValue GNUNET_BIO_read_spec_commit(struct GNUNET_BIO_ReadHandle *h, struct GNUNET_BIO_ReadSpec *rs)
Execute the read specifications in order.
Definition: bio.c:1108
struct GNUNET_BIO_WriteSpec GNUNET_BIO_write_spec_string(const char *what, const char *s)
Create the specification to write a 0-terminated string.
Definition: bio.c:1201
#define GNUNET_BIO_read_spec_end()
End of specifications marker.
#define GNUNET_BIO_write_spec_end()
End of specifications marker.
enum GNUNET_GenericReturnValue GNUNET_BIO_write_spec_commit(struct GNUNET_BIO_WriteHandle *h, struct GNUNET_BIO_WriteSpec *ws)
Execute the write specifications in order.
Definition: bio.c:1359
enum GNUNET_GenericReturnValue GNUNET_BIO_read_close(struct GNUNET_BIO_ReadHandle *h, char **emsg)
Close an open handle.
Definition: bio.c:162
enum GNUNET_GenericReturnValue GNUNET_BIO_read_int32(struct GNUNET_BIO_ReadHandle *h, const char *what, int32_t *i)
Read an (u)int32_t.
Definition: bio.c:427
struct GNUNET_BIO_ReadHandle * GNUNET_BIO_read_open_file(const char *fn)
Open a file for reading.
Definition: bio.c:114
enum GNUNET_GenericReturnValue 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.
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:187
void GNUNET_DATASTORE_disconnect(struct GNUNET_DATASTORE_Handle *h, int drop)
Disconnect from the datastore service (and free associated resources).
struct GNUNET_DATASTORE_Handle * GNUNET_DATASTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the datastore service.
enum GNUNET_GenericReturnValue 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:482
struct GNUNET_FS_Uri * GNUNET_FS_uri_dup(const struct GNUNET_FS_Uri *uri)
Duplicate URI.
Definition: fs_uri.c:987
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:667
GNUNET_FS_PublishOptions
Options for publishing.
char * GNUNET_FS_uri_to_string(const struct GNUNET_FS_Uri *uri)
Convert a URI to a UTF-8 String.
Definition: fs_uri.c:2017
void GNUNET_FS_uri_destroy(struct GNUNET_FS_Uri *uri)
Free URI.
Definition: fs_uri.c:677
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_FS_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:428
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_FS_IdentifierProcessor)(void *cls, const char *last_id, const struct GNUNET_FS_Uri *last_uri, const struct GNUNET_FS_MetaData *last_meta, const char *next_id)
Function called on updateable identifiers.
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:637
struct GNUNET_BIO_ReadSpec GNUNET_FS_read_spec_meta_data(const char *what, struct GNUNET_FS_MetaData **result)
Create the specification to read a metadata container.
Definition: meta_data.c:1185
struct GNUNET_BIO_WriteSpec GNUNET_FS_write_spec_meta_data(const char *what, const struct GNUNET_FS_MetaData *m)
Create the specification to write a metadata container.
Definition: meta_data.c:1223
void GNUNET_FS_publish_sks_cancel(struct GNUNET_FS_PublishSksContext *psc)
Abort the SKS publishing operation.
Definition: fs_namespace.c:491
@ GNUNET_FS_PUBLISH_OPTION_SIMULATE_ONLY
Simulate publishing.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:41
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:55
enum GNUNET_GenericReturnValue 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.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_get_multiple(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map that match a particular key.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE
Allow multiple values with the same key.
#define GNUNET_log(kind,...)
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_NO
#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.
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_array_grow(arr, size, tsize)
Grow a well-typed (!) array.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_array_append(arr, len, element)
Append an element to an array (growing the array by one).
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_FS_MetaData * GNUNET_FS_meta_data_duplicate(const struct GNUNET_FS_MetaData *md)
Duplicate a MetaData token.
Definition: meta_data.c:527
void GNUNET_FS_meta_data_destroy(struct GNUNET_FS_MetaData *md)
Free meta data.
Definition: meta_data.c:166
#define DIR_SEPARATOR_STR
Definition: platform.h:166
#define _(String)
GNU gettext support macro.
Definition: platform.h:178
Closure for 'find_trees'.
Definition: fs_namespace.c:558
unsigned int id
Identifier for the current TREE, or UINT_MAX for none yet.
Definition: fs_namespace.c:582
struct GNUNET_FS_UpdateInformationGraph * uig
UIG we are operating on.
Definition: fs_namespace.c:562
unsigned int tree_array_size
Size of 'tree_array'.
Definition: fs_namespace.c:572
struct NamespaceUpdateNode ** tree_array
Array with 'head's of TREEs.
Definition: fs_namespace.c:567
unsigned int nug
Current generational ID used.
Definition: fs_namespace.c:577
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration that we are using.
Definition: arm_api.c:112
Handle for buffered reading.
Definition: bio.c:69
Structure specifying a reading operation on an IO handle.
GNUNET_BIO_ReadHandler rh
Function performing data deserialization.
Handle for buffered writing.
Definition: bio.c:466
Structure specifying a writing operation on an IO handle.
GNUNET_BIO_WriteHandler wh
Function performing data serialization.
Internal representation of the hash map.
Private ECC key encoded for transmission.
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
0-terminated ASCII encoding of a struct GNUNET_HashCode.
Handle to the datastore service.
Settings for publishing a block (which may of course also apply to an entire directory or file).
Master context for most FS operations.
Definition: fs_api.h:1070
Meta data to associate with a file, directory or namespace.
Definition: meta_data.c:92
Context for the SKS publication.
Definition: fs_namespace.c:345
struct GNUNET_CRYPTO_EcdsaPrivateKey ns
Namespace we're publishing to.
Definition: fs_namespace.c:360
GNUNET_FS_PublishContinuation cont
Function to call once we're done.
Definition: fs_namespace.c:375
struct GNUNET_DATASTORE_Handle * dsh
Handle to the datastore.
Definition: fs_namespace.c:365
void * cont_cls
Closure for cont.
Definition: fs_namespace.c:380
struct NamespaceUpdateNode * nsn
Namespace update node to add to namespace on success (or to be deleted if publishing failed).
Definition: fs_namespace.c:355
struct GNUNET_FS_PublishUblockContext * uc
Handle for our UBlock operation request.
Definition: fs_namespace.c:385
struct GNUNET_FS_Handle * h
Handle to FS.
Definition: fs_namespace.c:370
struct GNUNET_FS_Uri * uri
URI of the new entry in the namespace.
Definition: fs_namespace.c:349
Context for 'ublock_put_cont'.
Handle to update information for a namespace.
Definition: fs_namespace.c:80
unsigned int rc
Reference counter.
Definition: fs_namespace.c:110
unsigned int nug_gen
Generator for unique nug numbers.
Definition: fs_namespace.c:115
struct GNUNET_FS_Handle * h
Handle to the FS service context.
Definition: fs_namespace.c:84
struct GNUNET_CRYPTO_EcdsaPrivateKey ns
Private key for the namespace.
Definition: fs_namespace.c:94
unsigned int update_node_count
Size of the update nodes array.
Definition: fs_namespace.c:105
struct GNUNET_CONTAINER_MultiHashMap * update_map
Hash map mapping identifiers of update nodes to the update nodes (initialized on-demand).
Definition: fs_namespace.c:100
struct NamespaceUpdateNode ** update_nodes
Array with information about nodes in the namespace.
Definition: fs_namespace.c:89
A Universal Resource Identifier (URI), opaque.
Definition: fs_api.h:167
union GNUNET_FS_Uri::@49 data
struct GNUNET_FS_Uri::@49::@51 sks
enum GNUNET_FS_UriType type
Type of the URI.
Definition: fs_api.h:171
struct GNUNET_CRYPTO_EcdsaPublicKey ns
Identifier of the namespace.
Definition: fs_api.h:199
char * identifier
Human-readable identifier chosen for this entry in the namespace.
Definition: fs_api.h:205
A 512-bit hashcode.
Information about an (updateable) node in the namespace.
Definition: fs_namespace.c:42
struct GNUNET_FS_MetaData * md
Metadata for this entry.
Definition: fs_namespace.c:56
struct GNUNET_FS_Uri * uri
URI of this entry in the namespace.
Definition: fs_namespace.c:61
char * update
Identifier of children of this node.
Definition: fs_namespace.c:51
unsigned int tree_id
TREE this entry belongs to (if nug is current).
Definition: fs_namespace.c:72
unsigned int nug
Namespace update generation ID.
Definition: fs_namespace.c:67
char * id
Identifier for this node.
Definition: fs_namespace.c:46
Closure for 'process_update_node'.
Definition: fs_namespace.c:520
void * ip_cls
Closure for 'ip'.
Definition: fs_namespace.c:529
GNUNET_FS_IdentifierProcessor ip
Function to call for each node.
Definition: fs_namespace.c:524