GNUnet  0.19.4
fs_unindex.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2003--2013, 2016 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 
30 #include "gnunet_fs_service.h"
31 #include "gnunet_protocols.h"
32 #include "fs_api.h"
33 #include "fs_tree.h"
34 #include "block_fs.h"
35 #include "fs_publish_ublock.h"
36 
37 
51 static size_t
52 unindex_reader (void *cls,
53  uint64_t offset,
54  size_t max,
55  void *buf,
56  char **emsg)
57 {
58  struct GNUNET_FS_UnindexContext *uc = cls;
59  size_t pt_size;
60 
61  pt_size = GNUNET_MIN (max, uc->file_size - offset);
62  if (offset != GNUNET_DISK_file_seek (uc->fh, offset, GNUNET_DISK_SEEK_SET))
63  {
64  *emsg = GNUNET_strdup (_ ("Failed to find given position in file"));
65  return 0;
66  }
67  if (pt_size != GNUNET_DISK_file_read (uc->fh, buf, pt_size))
68  {
69  *emsg = GNUNET_strdup (_ ("Failed to read file"));
70  return 0;
71  }
72  return pt_size;
73 }
74 
75 
84 void
87  uint64_t offset)
88 {
89  pi->value.unindex.uc = uc;
90  pi->value.unindex.cctx = uc->client_info;
91  pi->value.unindex.filename = uc->filename;
92  pi->value.unindex.size = uc->file_size;
93  pi->value.unindex.eta =
95  pi->value.unindex.duration =
97  pi->value.unindex.completed = offset;
98  pi->fsh = uc->h;
99  uc->client_info = uc->h->upcb (uc->h->upcb_cls, pi);
100 }
101 
102 
113 static void
114 unindex_progress (void *cls,
115  uint64_t offset,
116  const void *pt_block,
117  size_t pt_size,
118  unsigned int depth)
119 {
120  struct GNUNET_FS_UnindexContext *uc = cls;
121  struct GNUNET_FS_ProgressInfo pi;
122 
124  pi.value.unindex.specifics.progress.data = pt_block;
125  pi.value.unindex.specifics.progress.offset = offset;
126  pi.value.unindex.specifics.progress.data_len = pt_size;
127  pi.value.unindex.specifics.progress.depth = depth;
129 }
130 
131 
138 static void
140 {
141  struct GNUNET_FS_ProgressInfo pi;
142 
144  pi.value.unindex.eta = GNUNET_TIME_UNIT_FOREVER_REL;
145  pi.value.unindex.specifics.error.message = uc->emsg;
147 }
148 
149 
159 static void
160 process_cont (void *cls,
161  int success,
163  const char *msg)
164 {
165  struct GNUNET_FS_UnindexContext *uc = cls;
166 
167  if (success == GNUNET_SYSERR)
168  {
169  uc->emsg = GNUNET_strdup (msg);
171  return;
172  }
174  "Datastore REMOVE operation succeeded\n");
176 }
177 
178 
193 static void
194 unindex_process (void *cls,
195  const struct ContentHashKey *chk,
196  uint64_t offset,
197  unsigned int depth,
198  enum GNUNET_BLOCK_Type type,
199  const void *block,
200  uint16_t block_size)
201 {
202  struct GNUNET_FS_UnindexContext *uc = cls;
203  uint32_t size;
204  const void *data;
205  struct OnDemandBlock odb;
206 
208  {
209  size = block_size;
210  data = block;
211  }
212  else /* on-demand encoded DBLOCK */
213  {
214  size = sizeof(struct OnDemandBlock);
215  odb.offset = GNUNET_htonll (offset);
216  odb.file_id = uc->file_id;
217  data = &odb;
218  }
220  "Sending REMOVE request to DATASTORE service\n");
221  GNUNET_DATASTORE_remove (uc->dsh, &chk->query, size, data, -2, 1,
222  &process_cont, uc);
223  uc->chk = *chk;
224 }
225 
226 
234 static void
236  const struct GNUNET_MessageHeader *msg)
237 {
238  struct GNUNET_FS_UnindexContext *uc = cls;
239  struct GNUNET_FS_ProgressInfo pi;
240 
241  if (NULL != uc->mq)
242  {
244  uc->mq = NULL;
245  }
248  pi.value.unindex.eta = GNUNET_TIME_UNIT_ZERO;
251  uc,
252  uc->file_size);
253 }
254 
255 
264 static void
266  enum GNUNET_MQ_Error error)
267 {
268  struct GNUNET_FS_UnindexContext *uc = cls;
269 
270  if (NULL != uc->mq)
271  {
273  uc->mq = NULL;
274  }
276  uc->emsg = GNUNET_strdup (_ ("Error communicating with `fs' service."));
279 }
280 
281 
289 static void
291 {
293  GNUNET_MQ_hd_fixed_size (unindex_response,
295  struct GNUNET_MessageHeader,
296  uc),
298  };
299  char *emsg;
300  struct GNUNET_MQ_Envelope *env;
301  struct UnindexMessage *req;
302 
303  /* generate final progress message */
305  uc->file_size,
306  NULL,
307  0,
308  0);
310  &emsg);
311  uc->tc = NULL;
313  uc->fh = NULL;
315  uc->dsh = NULL;
319  "fs",
320  handlers,
322  uc);
323  if (NULL == uc->mq)
324  {
326  uc->emsg =
327  GNUNET_strdup (_ ("Failed to connect to FS service for unindexing."));
330  return;
331  }
333  "Sending UNINDEX message to FS service\n");
334  env = GNUNET_MQ_msg (req,
336  req->reserved = 0;
337  req->file_id = uc->file_id;
338  GNUNET_MQ_send (uc->mq,
339  env);
340 }
341 
342 
354 static void
356  const char *filename,
357  int is_directory,
359 {
360  struct GNUNET_FS_UnindexContext *uc = cls;
361  static struct GNUNET_FS_ShareTreeItem *directory_scan_result;
362 
363  switch (reason)
364  {
366  directory_scan_result = GNUNET_FS_directory_scan_get_result (uc->dscan);
367  uc->dscan = NULL;
368  if (NULL != directory_scan_result->ksk_uri)
369  {
370  uc->ksk_uri = GNUNET_FS_uri_dup (directory_scan_result->ksk_uri);
374  }
375  else
376  {
377  uc->emsg = GNUNET_strdup (_ ("Failed to get KSKs from directory scan."));
379  unindex_finish (uc);
380  }
381  GNUNET_FS_share_tree_free (directory_scan_result);
382  break;
383 
386  _ ("Internal error scanning `%s'.\n"),
387  uc->filename);
389  uc->dscan = NULL;
390  uc->emsg = GNUNET_strdup (_ ("Failed to get KSKs from directory scan."));
392  unindex_finish (uc);
393  break;
394 
395  default:
396  break;
397  }
398 }
399 
400 
406 void
408 {
409  char *ex;
410 
411  if (GNUNET_OK !=
412  GNUNET_CONFIGURATION_get_value_string (uc->h->cfg, "FS", "EXTRACTORS",
413  &ex))
414  ex = NULL;
416  GNUNET_NO, ex,
418  uc);
419  GNUNET_free (ex);
420 }
421 
422 
436 static void
438  int32_t success,
440  const char *msg)
441 {
442  struct GNUNET_FS_UnindexContext *uc = cls;
443 
444  uc->dqe = NULL;
445  if (success != GNUNET_YES)
447  _ ("Failed to remove UBlock: %s\n"),
448  msg);
449  uc->ksk_offset++;
451 }
452 
453 
476 static void
478  const struct GNUNET_HashCode *key,
479  size_t size,
480  const void *data,
481  enum GNUNET_BLOCK_Type type,
482  uint32_t priority,
483  uint32_t anonymity,
484  uint32_t replication,
486  uint64_t uid)
487 {
488  struct GNUNET_FS_UnindexContext *uc = cls;
489  const struct UBlock *ub;
490  struct GNUNET_FS_Uri *chk_uri;
491  struct GNUNET_HashCode query;
492 
493  uc->dqe = NULL;
494  if (NULL == data)
495  {
496  /* no result */
497  uc->ksk_offset++;
499  return;
500  }
502  if (size < sizeof(struct UBlock))
503  {
504  GNUNET_break (0);
505  goto get_next;
506  }
507  ub = data;
509  sizeof(ub->verification_key),
510  &query);
511  if (0 != memcmp (&query,
512  key,
513  sizeof(struct GNUNET_HashCode)))
514  {
515  /* result does not match our keyword, skip */
516  goto get_next;
517  }
518  {
519  char pt[size - sizeof(struct UBlock)];
520  struct GNUNET_CRYPTO_EcdsaPublicKey anon_pub;
521  const char *keyword;
522 
525  &anon_pub);
526  keyword = &uc->ksk_uri->data.ksk.keywords[uc->ksk_offset][1];
527  GNUNET_FS_ublock_decrypt_ (&ub[1], size - sizeof(struct UBlock),
528  &anon_pub,
529  keyword,
530  pt);
531  if (NULL == memchr (&pt[1], 0, sizeof(pt) - 1))
532  {
533  GNUNET_break_op (0); /* malformed UBlock */
534  goto get_next;
535  }
536  chk_uri = GNUNET_FS_uri_parse (&pt[1], NULL);
537  if (NULL == chk_uri)
538  {
539  GNUNET_break_op (0); /* malformed UBlock */
540  goto get_next;
541  }
542  }
543  if (0 != memcmp (&uc->chk,
544  &chk_uri->data.chk.chk,
545  sizeof(struct ContentHashKey)))
546  {
547  /* different CHK, ignore */
548  GNUNET_FS_uri_destroy (chk_uri);
549  goto get_next;
550  }
551  GNUNET_FS_uri_destroy (chk_uri);
552  /* matches! */
554  key,
555  size,
556  data,
557  0 /* priority */,
558  1 /* queue size */,
560  uc);
561  return;
562 get_next:
564  uid + 1 /* next_uid */,
565  false /* random */,
566  &uc->uquery,
568  0 /* priority */,
569  1 /* queue size */,
571  uc);
572 }
573 
574 
580 void
582 {
583  const char *keyword;
584  const struct GNUNET_CRYPTO_EcdsaPrivateKey *anon;
585  struct GNUNET_CRYPTO_EcdsaPublicKey anon_pub;
586  struct GNUNET_CRYPTO_EcdsaPublicKey dpub;
587 
588  if (NULL == uc->dsh)
590  if (NULL == uc->dsh)
591  {
593  uc->emsg = GNUNET_strdup (_ ("Failed to connect to `datastore' service."));
596  return;
597  }
598  if ((NULL == uc->ksk_uri) ||
599  (uc->ksk_offset >= uc->ksk_uri->data.ksk.keywordCount))
600  {
601  unindex_finish (uc);
602  return;
603  }
606  &anon_pub);
607  keyword = &uc->ksk_uri->data.ksk.keywords[uc->ksk_offset][1];
609  keyword,
610  "fs-ublock",
611  &dpub);
612  GNUNET_CRYPTO_hash (&dpub,
613  sizeof(dpub),
614  &uc->uquery);
616  0 /* next_uid */,
617  false /* random */,
618  &uc->uquery,
620  0 /* priority */,
621  1 /* queue size */,
623  uc);
624 }
625 
626 
633 static void
635 {
636  struct GNUNET_FS_UnindexContext *uc = cls;
637 
641 }
642 
643 
649 void
651 {
652  if (NULL == uc->dsh)
654  if (NULL == uc->dsh)
655  {
657  uc->emsg = GNUNET_strdup (_ ("Failed to connect to `datastore' service."));
660  return;
661  }
662  uc->fh =
665  if (NULL == uc->fh)
666  {
668  uc->dsh = NULL;
670  uc->emsg = GNUNET_strdup (_ ("Failed to open file for unindexing."));
673  return;
674  }
675  uc->tc =
677  uc->file_size,
678  uc,
684 }
685 
686 
694 void
696  const struct GNUNET_HashCode *file_id)
697 {
698  struct GNUNET_FS_UnindexContext *uc = cls;
699 
700  uc->fhc = NULL;
702  {
704  return;
705  }
706  if (file_id == NULL)
707  {
709  uc->emsg = GNUNET_strdup (_ ("Failed to compute hash of file."));
712  return;
713  }
714  uc->file_id = *file_id;
718 }
719 
720 
727 void
729 {
730  struct GNUNET_FS_UnindexContext *uc = cls;
731  struct GNUNET_FS_ProgressInfo pi;
732 
733  /* FIXME: lots of duplication with unindex_stop here! */
734  if (uc->dscan != NULL)
735  {
737  uc->dscan = NULL;
738  }
739  if (NULL != uc->dqe)
740  {
742  uc->dqe = NULL;
743  }
744  if (uc->fhc != NULL)
745  {
747  uc->fhc = NULL;
748  }
749  if (NULL != uc->ksk_uri)
750  {
752  uc->ksk_uri = NULL;
753  }
754  if (NULL != uc->mq)
755  {
757  uc->mq = NULL;
758  }
759  if (NULL != uc->dsh)
760  {
762  uc->dsh = NULL;
763  }
764  if (NULL != uc->tc)
765  {
767  uc->tc = NULL;
768  }
769  if (uc->fh != NULL)
770  {
772  uc->fh = NULL;
773  }
774  GNUNET_FS_end_top (uc->h, uc->top);
777  (uc->state ==
779  GNUNET_break (NULL == uc->client_info);
782  GNUNET_free (uc->emsg);
783  GNUNET_free (uc);
784 }
785 
786 
797  const char *filename,
798  void *cctx)
799 {
801  struct GNUNET_FS_ProgressInfo pi;
802  uint64_t size;
803 
804  if (GNUNET_OK !=
806  &size,
807  GNUNET_YES,
808  GNUNET_YES))
809  return NULL;
811  uc->h = h;
814  uc->file_size = size;
815  uc->client_info = cctx;
818  pi.value.unindex.eta = GNUNET_TIME_UNIT_FOREVER_REL;
820  uc->fhc =
822  filename,
827  uc);
828  return uc;
829 }
830 
831 
837 void
839 {
840  struct GNUNET_FS_ProgressInfo pi;
841 
842  if (NULL != uc->dscan)
843  {
845  uc->dscan = NULL;
846  }
847  if (NULL != uc->dqe)
848  {
850  uc->dqe = NULL;
851  }
852  if (NULL != uc->fhc)
853  {
855  uc->fhc = NULL;
856  }
857  if (NULL != uc->mq)
858  {
860  uc->mq = NULL;
861  }
862  if (NULL != uc->dsh)
863  {
865  uc->dsh = NULL;
866  }
867  if (NULL != uc->ksk_uri)
868  {
870  uc->ksk_uri = NULL;
871  }
872  if (NULL != uc->tc)
873  {
875  uc->tc = NULL;
876  }
877  if (uc->fh != NULL)
878  {
880  uc->fh = NULL;
881  }
882  GNUNET_FS_end_top (uc->h, uc->top);
883  if (uc->serialization != NULL)
884  {
886  uc->serialization);
888  uc->serialization = NULL;
889  }
891  pi.value.unindex.eta = GNUNET_TIME_UNIT_ZERO;
893  (uc->state ==
895  GNUNET_break (NULL == uc->client_info);
896  GNUNET_free (uc->emsg);
898  GNUNET_free (uc);
899 }
900 
901 
902 /* end of fs_unindex.c */
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
FS block formats (shared between FS and Block)
GNUNET_BLOCK_Type
WARNING: This header is generated! In order to add DHT block types, you must register them in GANA,...
@ GNUNET_BLOCK_TYPE_FS_UBLOCK
Type of a block representing any type of search result (universal).
@ GNUNET_BLOCK_TYPE_FS_DBLOCK
Data block (leaf) in the CHK tree.
#define HASHING_BLOCKSIZE
Blocksize to use when hashing files for indexing (blocksize for IO, not for the DBlocks).
Definition: fs.h:48
void GNUNET_FS_unindex_sync_(struct GNUNET_FS_UnindexContext *uc)
Synchronize this unindex struct with its mirror on disk.
Definition: fs_api.c:1823
struct TopLevelActivity * GNUNET_FS_make_top(struct GNUNET_FS_Handle *h, SuspendSignalFunction ssf, void *ssf_cls)
Create a top-level activity entry.
Definition: fs_api.c:381
void GNUNET_FS_remove_sync_file_(struct GNUNET_FS_Handle *h, const char *ext, const char *ent)
Remove serialization/deserialization file from disk.
Definition: fs_api.c:728
void GNUNET_FS_end_top(struct GNUNET_FS_Handle *h, struct TopLevelActivity *top)
Destroy a top-level activity entry.
Definition: fs_api.c:402
shared definitions for the FS library
@ UNINDEX_STATE_EXTRACT_KEYWORDS
Find out which keywords apply.
Definition: fs_api.h:1322
@ UNINDEX_STATE_COMPLETE
We're done.
Definition: fs_api.h:1338
@ UNINDEX_STATE_DS_REMOVE
We're telling the datastore to delete the respective DBlocks and IBlocks.
Definition: fs_api.h:1317
@ UNINDEX_STATE_HASHING
We're currently hashing the file.
Definition: fs_api.h:1311
@ UNINDEX_STATE_ERROR
We've encountered a fatal error.
Definition: fs_api.h:1343
@ UNINDEX_STATE_FS_NOTIFY
We're notifying the FS service about the unindexing.
Definition: fs_api.h:1333
@ UNINDEX_STATE_DS_REMOVE_KBLOCKS
We're telling the datastore to remove KBlocks.
Definition: fs_api.h:1327
#define GNUNET_FS_SYNC_PATH_MASTER_UNINDEX
Name of the directory with unindex operations.
Definition: fs_api.h:87
void GNUNET_FS_ublock_decrypt_(const void *input, size_t input_len, const struct GNUNET_CRYPTO_EcdsaPublicKey *ns, const char *label, void *output)
Decrypt the given UBlock, storing the result in output.
publish a UBLOCK in GNUnet
void GNUNET_FS_tree_encoder_next(struct GNUNET_FS_TreeEncoder *te)
Encrypt the next block of the file (and call proc and progress accordingly; or of course "cont" if we...
Definition: fs_tree.c:320
void GNUNET_FS_tree_encoder_finish(struct GNUNET_FS_TreeEncoder *te, char **emsg)
Clean up a tree encoder and return information about possible errors.
Definition: fs_tree.c:432
struct GNUNET_FS_TreeEncoder * GNUNET_FS_tree_encoder_create(struct GNUNET_FS_Handle *h, uint64_t size, void *cls, GNUNET_FS_DataReader reader, GNUNET_FS_TreeBlockProcessor proc, GNUNET_FS_TreeProgressCallback progress, GNUNET_SCHEDULER_TaskCallback cont)
Initialize a tree encoder.
Definition: fs_tree.c:258
Merkle-tree-ish-CHK file encoding for GNUnet.
static void unindex_progress(void *cls, uint64_t offset, const void *pt_block, size_t pt_size, unsigned int depth)
Function called with information about our progress in computing the tree encoding.
Definition: fs_unindex.c:114
static size_t unindex_reader(void *cls, uint64_t offset, size_t max, void *buf, char **emsg)
Function called by the tree encoder to obtain a block of plaintext data (for the lowest level of the ...
Definition: fs_unindex.c:52
static void unindex_mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
Generic error handler, called with the appropriate error code and the same closure specified at the c...
Definition: fs_unindex.c:265
void GNUNET_FS_unindex_do_remove_kblocks_(struct GNUNET_FS_UnindexContext *uc)
If necessary, connect to the datastore and remove the KBlocks.
Definition: fs_unindex.c:581
static void unindex_finish(struct GNUNET_FS_UnindexContext *uc)
Function called when we are done with removing UBlocks.
Definition: fs_unindex.c:290
void GNUNET_FS_unindex_make_status_(struct GNUNET_FS_ProgressInfo *pi, struct GNUNET_FS_UnindexContext *uc, uint64_t offset)
Fill in all of the generic fields for an unindex event and call the callback.
Definition: fs_unindex.c:85
void GNUNET_FS_unindex_do_extract_keywords_(struct GNUNET_FS_UnindexContext *uc)
If necessary, connect to the datastore and remove the UBlocks.
Definition: fs_unindex.c:407
void GNUNET_FS_unindex_do_remove_(struct GNUNET_FS_UnindexContext *uc)
Connect to the datastore and remove the blocks.
Definition: fs_unindex.c:650
static void unindex_process(void *cls, const struct ContentHashKey *chk, uint64_t offset, unsigned int depth, enum GNUNET_BLOCK_Type type, const void *block, uint16_t block_size)
Function called asking for the current (encoded) block to be processed.
Definition: fs_unindex.c:194
static void handle_unindex_response(void *cls, const struct GNUNET_MessageHeader *msg)
Function called with the response from the FS service to our unindexing request.
Definition: fs_unindex.c:235
static void unindex_extract_keywords(void *cls)
Function called when the tree encoder has processed all blocks.
Definition: fs_unindex.c:634
static void process_cont(void *cls, int success, struct GNUNET_TIME_Absolute min_expiration, const char *msg)
Continuation called to notify client about result of the datastore removal operation.
Definition: fs_unindex.c:160
static void continue_after_remove(void *cls, int32_t success, struct GNUNET_TIME_Absolute min_expiration, const char *msg)
Continuation called to notify client about result of the remove operation for the UBlock.
Definition: fs_unindex.c:437
void GNUNET_FS_unindex_signal_suspend_(void *cls)
Create SUSPEND event for the given unindex operation and then clean up our state (without stop signal...
Definition: fs_unindex.c:728
void GNUNET_FS_unindex_process_hash_(void *cls, const struct GNUNET_HashCode *file_id)
Function called once the hash of the file that is being unindexed has been computed.
Definition: fs_unindex.c:695
static void signal_unindex_error(struct GNUNET_FS_UnindexContext *uc)
We've encountered an error during unindexing.
Definition: fs_unindex.c:139
static void process_kblock_for_unindex(void *cls, const struct GNUNET_HashCode *key, size_t size, const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority, uint32_t anonymity, uint32_t replication, struct GNUNET_TIME_Absolute expiration, uint64_t uid)
Function called from datastore with result from us looking for a UBlock.
Definition: fs_unindex.c:477
static void unindex_directory_scan_cb(void *cls, const char *filename, int is_directory, enum GNUNET_FS_DirScannerProgressUpdateReason reason)
Function called by the directory scanner as we extract keywords that we will need to remove UBlocks.
Definition: fs_unindex.c:355
static char * expiration
Credential TTL.
Definition: gnunet-abd.c:96
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
static unsigned int replication
static struct GNUNET_PEERINFO_Handle * pi
Handle to peerinfo service.
struct GNUNET_HashCode key
The key used in the DHT.
static unsigned int anonymity
static char * filename
uint32_t data
The data value.
static struct GNUNET_TIME_Absolute min_expiration
Minimum time that content should have to not be discarded instantly (time stamp of any content that w...
static char buf[2048]
static struct GNUNET_FS_UnindexContext * uc
API for file sharing via GNUnet.
Constants for network protocols.
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
Definition: client.c:1057
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
void GNUNET_CRYPTO_ecdsa_public_key_derive(const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, const char *label, const char *context, struct GNUNET_CRYPTO_EcdsaPublicKey *result)
Derive a public key from a given public key and a label.
const struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_CRYPTO_ecdsa_key_get_anonymous(void)
Get the shared private key we use for anonymous users.
Definition: crypto_ecc.c:481
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:186
struct GNUNET_DATASTORE_Handle * GNUNET_DATASTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the datastore service.
void GNUNET_DATASTORE_disconnect(struct GNUNET_DATASTORE_Handle *h, int drop)
Disconnect from the datastore service (and free associated resources).
struct GNUNET_DATASTORE_QueueEntry * GNUNET_DATASTORE_get_key(struct GNUNET_DATASTORE_Handle *h, uint64_t next_uid, bool random, const struct GNUNET_HashCode *key, enum GNUNET_BLOCK_Type type, unsigned int queue_priority, unsigned int max_queue_size, GNUNET_DATASTORE_DatumProcessor proc, void *proc_cls)
Get a result for a particular key from the datastore.
struct GNUNET_DATASTORE_QueueEntry * GNUNET_DATASTORE_remove(struct GNUNET_DATASTORE_Handle *h, const struct GNUNET_HashCode *key, size_t size, const void *data, unsigned int queue_priority, unsigned int max_queue_size, GNUNET_DATASTORE_ContinuationWithStatus cont, void *cont_cls)
Explicitly remove some content from the database.
void GNUNET_DATASTORE_cancel(struct GNUNET_DATASTORE_QueueEntry *qe)
Cancel a datastore operation.
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:1237
off_t GNUNET_DISK_file_seek(const struct GNUNET_DISK_FileHandle *h, off_t offset, enum GNUNET_DISK_Seek whence)
Move the read/write pointer in a file.
Definition: disk.c:205
enum GNUNET_GenericReturnValue 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:221
enum GNUNET_GenericReturnValue GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
Definition: disk.c:1308
ssize_t GNUNET_DISK_file_read(const struct GNUNET_DISK_FileHandle *h, void *result, size_t len)
Read the contents of a binary file into a buffer.
Definition: disk.c:622
@ GNUNET_DISK_OPEN_READ
Open the file for reading.
@ GNUNET_DISK_PERM_NONE
Nobody is allowed to do anything to the file.
@ GNUNET_DISK_SEEK_SET
Seek an absolute position (from the start of the file).
void GNUNET_FS_share_tree_free(struct GNUNET_FS_ShareTreeItem *toplevel)
Release memory of a share item tree.
Definition: fs_sharetree.c:437
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
void GNUNET_FS_unindex_stop(struct GNUNET_FS_UnindexContext *uc)
Clean up after completion of an unindex operation.
Definition: fs_unindex.c:838
void GNUNET_FS_uri_destroy(struct GNUNET_FS_Uri *uri)
Free URI.
Definition: fs_uri.c:677
struct GNUNET_FS_Uri * GNUNET_FS_uri_dup(const struct GNUNET_FS_Uri *uri)
Duplicate URI.
Definition: fs_uri.c:987
GNUNET_FS_DirScannerProgressUpdateReason
Progress reasons of the directory scanner.
struct GNUNET_FS_UnindexContext * GNUNET_FS_unindex_start(struct GNUNET_FS_Handle *h, const char *filename, void *cctx)
Unindex a file.
Definition: fs_unindex.c:796
void GNUNET_FS_directory_scan_abort(struct GNUNET_FS_DirScanner *ds)
Abort the scan.
struct GNUNET_FS_ShareTreeItem * GNUNET_FS_directory_scan_get_result(struct GNUNET_FS_DirScanner *ds)
Obtain the result of the scan after the scan has signalled completion.
struct GNUNET_FS_DirScanner * GNUNET_FS_directory_scan_start(const char *filename, int disable_extractor, const char *ex, GNUNET_FS_DirScannerProgressCallback cb, void *cb_cls)
Start a directory scanner thread.
@ GNUNET_FS_STATUS_UNINDEX_PROGRESS
Notification that we made progress unindexing a file.
@ GNUNET_FS_STATUS_UNINDEX_START
Notification that we started to unindex a file.
@ GNUNET_FS_STATUS_UNINDEX_STOPPED
Notification that the unindexing of this file was stopped (final event for this action).
@ GNUNET_FS_STATUS_UNINDEX_COMPLETED
Notification that the unindexing of this file was completed.
@ GNUNET_FS_STATUS_UNINDEX_SUSPEND
Notification that we suspended unindexing a file.
@ GNUNET_FS_STATUS_UNINDEX_ERROR
Notification that we encountered an error unindexing a file.
@ GNUNET_FS_DIRSCANNER_INTERNAL_ERROR
There was an internal error.
@ GNUNET_FS_DIRSCANNER_FINISHED
Last call to the progress function: we have finished scanning the directory.
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
struct GNUNET_CRYPTO_FileHashContext * GNUNET_CRYPTO_hash_file(enum GNUNET_SCHEDULER_Priority priority, const char *filename, size_t blocksize, GNUNET_CRYPTO_HashCompletedCallback callback, void *callback_cls)
Compute the hash of an entire file.
#define GNUNET_log(kind,...)
void GNUNET_CRYPTO_hash_file_cancel(struct GNUNET_CRYPTO_FileHashContext *fhc)
Cancel a file hashing operation.
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:37
#define GNUNET_MIN(a, b)
@ GNUNET_SCHEDULER_PRIORITY_IDLE
Run when otherwise idle.
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_NO
@ GNUNET_SYSERR
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
#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.
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
GNUNET_MQ_Error
Error codes for the queue.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:304
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:77
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:683
#define GNUNET_MESSAGE_TYPE_FS_UNINDEX_OK
Reply to client indicating unindex receipt.
#define GNUNET_MESSAGE_TYPE_FS_UNINDEX
Request from client to unindex a file.
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
Definition: time.c:436
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:111
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
struct GNUNET_TIME_Relative GNUNET_TIME_calculate_eta(struct GNUNET_TIME_Absolute start, uint64_t finished, uint64_t total)
Calculate the estimate time of arrival/completion for an operation.
Definition: time.c:564
#define max(x, y)
static unsigned int size
Size of the "table".
Definition: peer.c:68
#define _(String)
GNU gettext support macro.
Definition: platform.h:178
content hash key
Definition: fs.h:55
struct GNUNET_HashCode query
Hash of the encrypted content, used for querying.
Definition: fs.h:64
struct ContentHashKey chk
Query and key of the top GNUNET_EC_IBlock.
Definition: fs_api.h:104
Private ECC key encoded for transmission.
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
Master context for most FS operations.
Definition: fs_api.h:1070
void * upcb_cls
Closure for upcb.
Definition: fs_api.h:1089
GNUNET_FS_ProgressCallback upcb
Function to call with updates on our progress.
Definition: fs_api.h:1084
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Definition: fs_api.h:1074
Argument given to the progress callback with information about what is going on.
void * cctx
Client context pointer (set the last time by the client for this operation; initially NULL on START/R...
unsigned int depth
Depth of the given block in the tree; 0 would be the lowest level (DBLOCKs).
uint64_t offset
At what offset in the file is "data"?
struct GNUNET_FS_ProgressInfo::@25::GNUNET_FS_PublishStatusEvent::@26::GNUNET_FS_PublishErrorEvent error
A node of a directory tree (produced by dirscanner)
struct GNUNET_FS_Uri * ksk_uri
Keywords for this file or directory (derived from metadata).
Handle for controlling an unindexing operation.
Definition: fs_api.h:1351
struct GNUNET_FS_TreeEncoder * tc
Merkle-ish tree encoder context.
Definition: fs_api.h:1413
struct GNUNET_FS_DirScanner * dscan
Directory scanner to find keywords (KBlock removal).
Definition: fs_api.h:1371
enum UnindexState state
Current operatinonal phase.
Definition: fs_api.h:1464
void * client_info
Pointer kept for the client.
Definition: fs_api.h:1408
char * emsg
Error message, NULL on success.
Definition: fs_api.h:1439
struct GNUNET_DISK_FileHandle * fh
Handle used to read the file.
Definition: fs_api.h:1418
struct GNUNET_TIME_Absolute start_time
When did we start?
Definition: fs_api.h:1454
struct ContentHashKey chk
The content hash key of the last block we processed, will in the end be set to the CHK from the URI.
Definition: fs_api.h:1356
struct GNUNET_DATASTORE_QueueEntry * dqe
Handle to datastore 'get_key' operation issued for obtaining KBlocks.
Definition: fs_api.h:1424
struct GNUNET_CRYPTO_FileHashContext * fhc
Context for hashing of the file.
Definition: fs_api.h:1444
struct TopLevelActivity * top
Our top-level activity entry.
Definition: fs_api.h:1366
char * filename
Name of the file that we are unindexing.
Definition: fs_api.h:1386
struct GNUNET_DATASTORE_Handle * dsh
Connection to the datastore service, only valid during the UNINDEX_STATE_DS_NOTIFY phase.
Definition: fs_api.h:1403
struct GNUNET_FS_Handle * h
Global FS context.
Definition: fs_api.h:1361
uint32_t ksk_offset
Current offset in KSK removal.
Definition: fs_api.h:1381
char * serialization
Short name under which we are serializing the state of this operation.
Definition: fs_api.h:1391
struct GNUNET_HashCode uquery
Current query of 'get_key' operation.
Definition: fs_api.h:1434
struct GNUNET_FS_Uri * ksk_uri
Keywords found (telling us which KBlocks to remove).
Definition: fs_api.h:1376
struct GNUNET_HashCode file_id
Hash of the file's contents (once computed).
Definition: fs_api.h:1459
uint64_t file_size
Overall size of the file.
Definition: fs_api.h:1449
struct GNUNET_MQ_Handle * mq
Connection to the FS service, only valid during the UNINDEX_STATE_FS_NOTIFY phase.
Definition: fs_api.h:1397
A Universal Resource Identifier (URI), opaque.
Definition: fs_api.h:167
struct GNUNET_FS_Uri::@13::@14 ksk
union GNUNET_FS_Uri::@13 data
struct FileIdentifier chk
Information needed to retrieve a file (content-hash-key plus file size).
Definition: fs_api.h:212
A 512-bit hashcode.
Message handler for a specific message type.
Header for all communications.
Time for absolute times used by GNUnet, in microseconds.
index block (indexing a DBlock that can be obtained directly from reading the plaintext file)
Definition: block_fs.h:86
uint64_t offset
At which offset should we be able to find this on-demand encoded block? (in NBO)
Definition: block_fs.h:98
struct GNUNET_HashCode file_id
Hash code of the entire content of the file that was indexed (used to uniquely identify the plaintext...
Definition: block_fs.h:92
universal block for keyword and namespace search results
Definition: block_fs.h:54
struct GNUNET_CRYPTO_EcdsaPublicKey verification_key
Public key used to sign this block.
Definition: block_fs.h:68
Message sent from a GNUnet (fs) unindexing activity to the gnunet-service-fs to indicate that a file ...
Definition: fs.h:228
struct GNUNET_HashCode file_id
Hash of the file that we will unindex.
Definition: fs.h:242
uint32_t reserved
Always zero.
Definition: fs.h:237
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model