GNUnet 0.22.2
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 {
218 struct GNUNET_BIO_WriteSpec ws[] = {
219 GNUNET_BIO_write_spec_string ("fs-namespace-node-id", n->id),
220 GNUNET_FS_write_spec_meta_data ("fs-namespace-node-meta", n->md),
221 GNUNET_BIO_write_spec_string ("fs-namespace-node-update", n->update),
222 GNUNET_BIO_write_spec_string ("fs-namespace-uris", uris),
224 };
226 {
227 GNUNET_free (uris);
228 break;
229 }
230 }
231 GNUNET_free (uris);
232 }
233END:
234 if (GNUNET_OK != GNUNET_BIO_write_close (wh, NULL))
236 _ ("Failed to write `%s': %s\n"),
237 fn,
238 strerror (errno));
239 GNUNET_free (fn);
240}
241
242
252 const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns)
253{
255 char *fn;
256 struct GNUNET_BIO_ReadHandle *rh;
257 unsigned int i;
258 struct NamespaceUpdateNode *n;
259 char *uris;
260 uint32_t count;
261 char *emsg;
262
264 uig->h = h;
265 uig->ns = *ns;
268 {
269 GNUNET_free (fn);
270 return uig;
271 }
273 if (NULL == rh)
274 {
275 GNUNET_free (fn);
276 return uig;
277 }
278 if (GNUNET_OK != GNUNET_BIO_read_int32 (rh, "fs-namespace-count",
279 (int32_t *) &count))
280 {
281 GNUNET_break (0);
282 goto END;
283 }
284 if (count > 1024 * 1024)
285 {
286 GNUNET_break (0);
287 goto END;
288 }
289 if (0 == count)
290 goto END;
291 uig->update_nodes =
292 GNUNET_malloc (count * sizeof(struct NamespaceUpdateNode *));
293
294 for (i = 0; i < count; i++)
295 {
296 n = GNUNET_new (struct NamespaceUpdateNode);
297 {
298 struct GNUNET_BIO_ReadSpec rs[] = {
299 GNUNET_BIO_read_spec_string ("identifier", &n->id, 1024),
300 GNUNET_FS_read_spec_meta_data ("meta", &n->md),
301 GNUNET_BIO_read_spec_string ("update-id", &n->update, 1024),
302 GNUNET_BIO_read_spec_string ("uri", &uris, 1024 * 2),
304 };
306 {
307 GNUNET_break (0);
308 GNUNET_free (n->id);
309 GNUNET_free (n->update);
310 if (n->md != NULL)
312 GNUNET_free (n);
313 break;
314 }
315 }
316 n->uri = GNUNET_FS_uri_parse (uris, &emsg);
317 GNUNET_free (uris);
318 if (n->uri == NULL)
319 {
320 GNUNET_break (0);
321 GNUNET_free (emsg);
322 GNUNET_free (n->id);
323 GNUNET_free (n->update);
325 GNUNET_free (n);
326 break;
327 }
328 uig->update_nodes[i] = n;
329 }
330 uig->update_node_count = i;
331END:
332 if (GNUNET_OK != GNUNET_BIO_read_close (rh, &emsg))
333 {
335 _ ("Failed to read `%s': %s\n"),
336 fn,
337 emsg);
338 GNUNET_free (emsg);
339 }
340 GNUNET_free (fn);
341 return uig;
342}
343
344
349{
354
360
365
370
375
380
384 void *cont_cls;
385
390};
391
392
400static void
401sks_publish_cont (void *cls, const char *msg)
402{
403 struct GNUNET_FS_PublishSksContext *psc = cls;
405
406 psc->uc = NULL;
407 if (NULL != msg)
408 {
409 if (NULL != psc->cont)
410 psc->cont (psc->cont_cls, NULL, msg);
412 return;
413 }
414 if (NULL != psc->nsn)
415 {
416 /* FIXME: this can be done much more
417 * efficiently by simply appending to the
418 * file and overwriting the 4-byte header */
419 uig = read_update_information_graph (psc->h, &psc->ns);
421 psc->nsn = NULL;
424 }
425 if (NULL != psc->cont)
426 psc->cont (psc->cont_cls, psc->uri, NULL);
428}
429
430
433 const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns,
434 const char *identifier,
435 const char *update,
436 const struct GNUNET_FS_MetaData *meta,
437 const struct GNUNET_FS_Uri *uri,
438 const struct GNUNET_FS_BlockOptions *bo,
441 void *cont_cls)
442{
443 struct GNUNET_FS_PublishSksContext *psc;
444 struct GNUNET_FS_Uri *sks_uri;
445
446 sks_uri = GNUNET_new (struct GNUNET_FS_Uri);
447 sks_uri->type = GNUNET_FS_URI_SKS;
450
452 psc->h = h;
453 psc->uri = sks_uri;
454 psc->cont = cont;
455 psc->cont_cls = cont_cls;
456 psc->ns = *ns;
458 {
460 if (NULL == psc->dsh)
461 {
462 sks_publish_cont (psc, _ ("Failed to connect to datastore."));
463 return NULL;
464 }
465 }
466 if (NULL != update)
467 {
468 psc->nsn = GNUNET_new (struct NamespaceUpdateNode);
469 psc->nsn->id = GNUNET_strdup (identifier);
470 psc->nsn->update = GNUNET_strdup (update);
472 psc->nsn->uri = GNUNET_FS_uri_dup (uri);
473 }
475 psc->dsh,
477 update,
478 ns,
479 meta,
480 uri,
481 bo,
482 options,
484 psc);
485 return psc;
486}
487
488
494void
496{
497 if (NULL != psc->uc)
498 {
500 psc->uc = NULL;
501 }
502 if (NULL != psc->dsh)
503 {
505 psc->dsh = NULL;
506 }
508 if (NULL != psc->nsn)
509 {
512 GNUNET_free (psc->nsn->id);
513 GNUNET_free (psc->nsn->update);
514 GNUNET_free (psc->nsn);
515 }
516 GNUNET_free (psc);
517}
518
519
524{
529
533 void *ip_cls;
534};
535
536
547static int
548process_update_node (void *cls, const struct GNUNET_HashCode *key, void *value)
549{
550 struct ProcessUpdateClosure *pc = cls;
551 struct NamespaceUpdateNode *nsn = value;
552
553 pc->ip (pc->ip_cls, nsn->id, nsn->uri, nsn->md, nsn->update);
554 return GNUNET_YES;
555}
556
557
562{
567
572
576 unsigned int tree_array_size;
577
581 unsigned int nug;
582
586 unsigned int id;
587};
588
589
610static int
611find_trees (void *cls, const struct GNUNET_HashCode *key, void *value)
612{
613 struct FindTreeClosure *fc = cls;
614 struct NamespaceUpdateNode *nsn = value;
615 struct GNUNET_HashCode hc;
616
617 if (nsn->nug == fc->nug)
618 {
619 if (UINT_MAX == nsn->tree_id)
620 return GNUNET_YES; /* circular */
622 if (fc->tree_array[nsn->tree_id] != nsn)
623 return GNUNET_YES; /* part of "another" (directed) TREE,
624 * and not root of it, end trace */
625 if (nsn->tree_id == fc->id)
626 return GNUNET_YES; /* that's our own root (can this be?) */
627 /* merge existing TREE, we have a root for both */
628 fc->tree_array[nsn->tree_id] = NULL;
629 if (UINT_MAX == fc->id)
630 fc->id = nsn->tree_id; /* take over ID */
631 }
632 else
633 {
634 nsn->nug = fc->nug;
635 nsn->tree_id = UINT_MAX; /* mark as undef */
636 /* trace */
637 GNUNET_CRYPTO_hash (nsn->update, strlen (nsn->update), &hc);
639 &hc,
640 &find_trees,
641 fc);
642 }
643 return GNUNET_YES;
644}
645
646
670void
672 struct GNUNET_FS_Handle *h,
673 const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns,
674 const char *next_id,
676 void *ip_cls)
677{
678 unsigned int i;
679 unsigned int nug;
680 struct GNUNET_HashCode hc;
681 struct NamespaceUpdateNode *nsn;
683 struct FindTreeClosure fc;
685
687 if (NULL == uig->update_nodes)
688 {
690 "No updateable nodes found for ID `%s'\n",
691 next_id);
693 return; /* no nodes */
694 }
695 uig->update_map =
697 GNUNET_NO);
698 for (i = 0; i < uig->update_node_count; i++)
699 {
700 nsn = uig->update_nodes[i];
701 GNUNET_CRYPTO_hash (nsn->id, strlen (nsn->id), &hc);
703 uig->update_map,
704 &hc,
705 nsn,
707 }
708 if (NULL != next_id)
709 {
710 GNUNET_CRYPTO_hash (next_id, strlen (next_id), &hc);
711 pc.ip = ip;
712 pc.ip_cls = ip_cls;
714 &hc,
716 &pc);
718 return;
719 }
721 "Calculating TREEs to find roots of update trees\n");
722 /* Find heads of TREEs in update graph */
723 nug = ++uig->nug_gen;
724 fc.tree_array = NULL;
725 fc.tree_array_size = 0;
726
727 for (i = 0; i < uig->update_node_count; i++)
728 {
729 nsn = uig->update_nodes[i];
730 if (nsn->nug == nug)
731 {
733 "TREE of node `%s' is %u\n",
734 nsn->id,
735 nsn->nug);
736 continue; /* already placed in TREE */
737 }
738 GNUNET_CRYPTO_hash (nsn->update, strlen (nsn->update), &hc);
739 nsn->nug = nug;
740 nsn->tree_id = UINT_MAX;
741 fc.id = UINT_MAX;
742 fc.nug = nug;
743 fc.uig = uig;
745 &hc,
746 &find_trees,
747 &fc);
748 if (UINT_MAX == fc.id)
749 {
750 /* start new TREE */
751 for (fc.id = 0; fc.id < fc.tree_array_size; fc.id++)
752 {
753 if (NULL == fc.tree_array[fc.id])
754 {
755 fc.tree_array[fc.id] = nsn;
756 nsn->tree_id = fc.id;
757 break;
758 }
759 }
760 if (fc.id == fc.tree_array_size)
761 {
763 nsn->tree_id = fc.id;
764 }
766 "Starting new TREE %u with node `%s'\n",
767 nsn->tree_id,
768 nsn->id);
769 /* put all nodes with same identifier into this TREE */
770 GNUNET_CRYPTO_hash (nsn->id, strlen (nsn->id), &hc);
771 fc.id = nsn->tree_id;
772 fc.nug = nug;
773 fc.uig = uig;
775 &hc,
776 &find_trees,
777 &fc);
778 }
779 else
780 {
781 /* make head of TREE "id" */
782 fc.tree_array[fc.id] = nsn;
783 nsn->tree_id = fc.id;
784 }
786 "TREE of node `%s' is %u\n",
787 nsn->id,
788 fc.id);
789 }
790 for (i = 0; i < fc.tree_array_size; i++)
791 {
792 nsn = fc.tree_array[i];
793 if (NULL != nsn)
794 {
796 "Root of TREE %u is node `%s'\n",
797 i,
798 nsn->id);
799 ip (ip_cls, nsn->id, nsn->uri, nsn->md, nsn->update);
800 }
801 }
803 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Done processing TREEs\n");
805}
806
807
808/* 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:548
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:401
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:611
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:251
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:98
static int ret
Final status code.
Definition: gnunet-arm.c:93
@ 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:954
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:845
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:1106
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:1199
#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:1357
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:190
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:520
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:671
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:2034
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:432
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:495
@ 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:167
#define _(String)
GNU gettext support macro.
Definition: platform.h:179
Closure for 'find_trees'.
Definition: fs_namespace.c:562
unsigned int id
Identifier for the current TREE, or UINT_MAX for none yet.
Definition: fs_namespace.c:586
struct GNUNET_FS_UpdateInformationGraph * uig
UIG we are operating on.
Definition: fs_namespace.c:566
unsigned int tree_array_size
Size of 'tree_array'.
Definition: fs_namespace.c:576
struct NamespaceUpdateNode ** tree_array
Array with 'head's of TREEs.
Definition: fs_namespace.c:571
unsigned int nug
Current generational ID used.
Definition: fs_namespace.c:581
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:349
struct GNUNET_CRYPTO_EcdsaPrivateKey ns
Namespace we're publishing to.
Definition: fs_namespace.c:364
GNUNET_FS_PublishContinuation cont
Function to call once we're done.
Definition: fs_namespace.c:379
struct GNUNET_DATASTORE_Handle * dsh
Handle to the datastore.
Definition: fs_namespace.c:369
void * cont_cls
Closure for cont.
Definition: fs_namespace.c:384
struct NamespaceUpdateNode * nsn
Namespace update node to add to namespace on success (or to be deleted if publishing failed).
Definition: fs_namespace.c:359
struct GNUNET_FS_PublishUblockContext * uc
Handle for our UBlock operation request.
Definition: fs_namespace.c:389
struct GNUNET_FS_Handle * h
Handle to FS.
Definition: fs_namespace.c:374
struct GNUNET_FS_Uri * uri
URI of the new entry in the namespace.
Definition: fs_namespace.c:353
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:524
void * ip_cls
Closure for 'ip'.
Definition: fs_namespace.c:533
GNUNET_FS_IdentifierProcessor ip
Function to call for each node.
Definition: fs_namespace.c:528