GNUnet  0.10.x
gnunet-service-fs.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2009-2014, 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 
26 #include "platform.h"
27 #include <float.h>
28 #include "gnunet_constants.h"
29 #include "gnunet_core_service.h"
30 #include "gnunet_dht_service.h"
32 #include "gnunet_load_lib.h"
33 #include "gnunet_peer_lib.h"
34 #include "gnunet_protocols.h"
35 #include "gnunet_signatures.h"
38 #include "gnunet_util_lib.h"
39 #include "gnunet-service-fs_cp.h"
41 #include "gnunet-service-fs_pe.h"
42 #include "gnunet-service-fs_pr.h"
43 #include "gnunet-service-fs_push.h"
44 #include "gnunet-service-fs_put.h"
46 #include "fs.h"
47 #include "fs_api.h"
48 
54 #define FS_DHT_HT_SIZE 1024
55 
56 
62 #define COVER_AGE_FREQUENCY GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5)
63 
67 #define INSANE_STATISTICS GNUNET_NO
68 
69 
70 
75 struct ClientRequest {
80 
85 
90 
95 
100 };
101 
102 
112 
117 
122 
126  size_t msize;
127 };
128 
129 
139 
144 
148  char *filename;
149 
154 
159 
163  struct GNUNET_HashCode file_id;
164 };
165 
166 
175 
180 
186 
192 
197 
202 
207 
212 };
213 
214 
215 /* ****************************** globals ****************************** */
216 
221 
226 
231 
236 
241 
247 
252 
253 
265 
270 
276 
282 
287 
293 
298 
303 
304 /* ***************************** locals ******************************* */
305 
310 
315 
320 
325 
326 
335 static void *
337  struct GNUNET_SERVICE_Client *client,
338  struct GNUNET_MQ_Handle *mq)
339 {
340  struct GSF_LocalClient *pos;
341 
342  pos = GNUNET_new(struct GSF_LocalClient);
343  pos->client = client;
344  pos->mq = mq;
345  return pos;
346 }
347 
348 
354 static void
356 {
357  struct ClientRequest *cr = cls;
358  struct GSF_LocalClient *lc = cr->lc;
359 
360  cr->kill_task = NULL;
362  lc->cr_tail,
363  cr);
365  GNUNET_YES);
366  GNUNET_STATISTICS_update(GSF_stats,
367  gettext_noop("# client searches active"),
368  -1,
369  GNUNET_NO);
370  GNUNET_free(cr);
371 }
372 
373 
392 static void
395  struct GSF_PendingRequest *pr,
396  uint32_t reply_anonymity_level,
399  enum GNUNET_BLOCK_Type type,
400  const void *data,
401  size_t data_len)
402 {
403  struct ClientRequest *cr = cls;
404  struct GSF_LocalClient *lc;
405  struct GNUNET_MQ_Envelope *env;
406  struct ClientPutMessage *pm;
407  const struct GSF_PendingRequestData *prd;
408 
409  if (NULL == data)
410  {
411  /* local-only request, with no result, clean up. */
412  if (NULL == cr->kill_task)
414  cr);
415  return;
416  }
419  if ((prd->type != type) && (prd->type != GNUNET_BLOCK_TYPE_ANY))
420  {
421  GNUNET_break(0);
422  return;
423  }
424  GNUNET_STATISTICS_update(GSF_stats,
426  ("# replies received for local clients"), 1,
427  GNUNET_NO);
428  GNUNET_assert(pr == cr->pr);
429  lc = cr->lc;
430  env = GNUNET_MQ_msg_extra(pm,
431  data_len,
433  pm->type = htonl(type);
434  pm->expiration = GNUNET_TIME_absolute_hton(expiration);
435  pm->last_transmission = GNUNET_TIME_absolute_hton(last_transmission);
436  pm->num_transmissions = htonl(prd->num_transmissions);
437  pm->respect_offered = htonl(prd->respect_offered);
438  GNUNET_memcpy(&pm[1],
439  data,
440  data_len);
441  GNUNET_MQ_send(lc->mq,
442  env);
444  "Queued reply to query `%s' for local client\n",
445  GNUNET_h2s(&prd->query));
447  {
449  "Evaluation %d - keeping query alive\n",
450  (int)eval);
451  return;
452  }
453  if (NULL == cr->kill_task)
455  cr);
456 }
457 
458 
467 static void
469  struct GNUNET_SERVICE_Client *client,
470  void *app_ctx)
471 {
472  struct GSF_LocalClient *lc = app_ctx;
473  struct IndexStartContext *isc;
474  struct ClientRequest *cr;
475  struct ClientResponse *res;
476 
477  while (NULL != (cr = lc->cr_head))
478  {
479  if (NULL != cr->kill_task)
482  }
483  while (NULL != (res = lc->res_head))
484  {
486  lc->res_tail,
487  res);
488  GNUNET_free(res);
489  }
490  while (NULL != (isc = lc->isc_head))
491  {
493  lc->isc_tail,
494  isc);
496  GNUNET_free(isc);
497  }
498  GNUNET_free(lc);
499 }
500 
501 
502 
503 
504 
510 static void
512 {
515  cover_age_task =
518  NULL);
519 }
520 
521 
528 void
530 {
531  struct GNUNET_TIME_Relative delay;
532 
533  delay = GNUNET_TIME_absolute_get_duration(start);
534  GNUNET_LOAD_update(datastore_get_load, delay.rel_value_us);
535 }
536 
537 
548 int
549 GSF_test_get_load_too_high_(uint32_t priority)
550 {
551  double ld;
552 
553  ld = GNUNET_LOAD_get_load(datastore_get_load);
554  if (ld < 1)
555  return GNUNET_SYSERR;
556  if (ld <= priority)
557  return GNUNET_NO;
558  return GNUNET_YES;
559 }
560 
561 
573 static void
575  const struct GNUNET_HELLO_Address *address,
576  int active,
577  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
578  struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
579  const struct GNUNET_ATS_Properties *prop)
580 {
581  if (NULL == address)
582  {
583  /* ATS service temporarily disconnected */
584  return;
585  }
586 
587  if (GNUNET_YES != active)
588  return;
589  GSF_update_peer_latency_(&address->peer,
590  prop->delay);
591  GSF_avg_latency.rel_value_us =
592  (GSF_avg_latency.rel_value_us * 31 +
593  GNUNET_MIN(5000, prop->delay.rel_value_us)) / 32;
594  GNUNET_STATISTICS_set(GSF_stats,
595  gettext_noop("# running average P2P latency (ms)"),
596  GSF_avg_latency.rel_value_us / 1000LL,
597  GNUNET_NO);
598 }
599 
600 
609 static int
610 check_p2p_put(void *cls,
611  const struct PutMessage *put)
612 {
613  enum GNUNET_BLOCK_Type type;
614 
615  type = ntohl(put->type);
616  if (GNUNET_BLOCK_TYPE_FS_ONDEMAND == type)
617  {
618  GNUNET_break_op(0);
619  return GNUNET_SYSERR;
620  }
621  return GNUNET_OK;
622 }
623 
624 
634 static void
636  const struct GNUNET_PeerIdentity *peer,
637  struct GSF_ConnectedPeer *cp,
638  const struct GSF_PeerPerformanceData *ppd)
639 {
640  struct GSF_PendingRequest *pr = cls;
641 
642  if (GNUNET_YES !=
644  {
645 #if INSANE_STATISTICS
646  GNUNET_STATISTICS_update(GSF_stats,
647  gettext_noop("# Loopback routes suppressed"), 1,
648  GNUNET_NO);
649 #endif
650  return;
651  }
652  GSF_plan_add_(cp,
653  pr);
654 }
655 
656 
667 void
669  struct GSF_PendingRequest *pr,
671 {
672  if (GNUNET_BLOCK_EVALUATION_OK_LAST == result)
673  return; /* we're done... */
674  if (GNUNET_YES !=
676  return; /* request is not actually active, skip! */
678  pr);
679 }
680 
681 
690 static int
691 check_p2p_get(void *cls,
692  const struct GetMessage *gm)
693 {
694  size_t msize;
695  unsigned int bm;
696  unsigned int bits;
697  size_t bfsize;
698 
699  msize = ntohs(gm->header.size);
700  bm = ntohl(gm->hash_bitmap);
701  bits = 0;
702  while (bm > 0)
703  {
704  if (1 == (bm & 1))
705  bits++;
706  bm >>= 1;
707  }
708  if (msize < sizeof(struct GetMessage) + bits * sizeof(struct GNUNET_PeerIdentity))
709  {
710  GNUNET_break_op(0);
711  return GNUNET_SYSERR;
712  }
713  bfsize = msize - sizeof(struct GetMessage) - bits * sizeof(struct GNUNET_PeerIdentity);
714  /* bfsize must be power of 2, check! */
715  if (0 != ((bfsize - 1) & bfsize))
716  {
717  GNUNET_break_op(0);
718  return GNUNET_SYSERR;
719  }
720  return GNUNET_OK;
721 }
722 
723 
734 static void
736  struct GSF_PendingRequest *pr,
738 {
739  struct GSF_LocalClient *lc = cls;
740  struct GSF_PendingRequestData *prd;
741 
743  if (GNUNET_BLOCK_EVALUATION_OK_LAST == result)
744  return; /* we're done, 'pr' was already destroyed... */
747  "Finished database lookup for local request `%s' with result %d\n",
748  GNUNET_h2s(&prd->query),
749  result);
750  if (0 == prd->anonymity_level)
751  {
752  switch (prd->type)
753  {
756  /* the above block types MAY be available via 'cadet' */
758  "Considering cadet-based download for block\n");
759  GSF_cadet_lookup_(pr);
760  break;
761 
763  /* the above block types are in the DHT */
765  "Considering DHT-based search for block\n");
766  GSF_dht_lookup_(pr);
767  break;
768 
769  default:
770  GNUNET_break(0);
771  break;
772  }
773  }
775  pr,
776  result);
777 }
778 
779 
788 static int
790  const struct SearchMessage *sm)
791 {
792  uint16_t msize;
793 
794  msize = ntohs(sm->header.size) - sizeof(struct SearchMessage);
795  if (0 != msize % sizeof(struct GNUNET_HashCode))
796  {
797  GNUNET_break(0);
798  return GNUNET_SYSERR;
799  }
800  return GNUNET_OK;
801 }
802 
803 
814 static void
816  const struct SearchMessage *sm)
817 {
818  static struct GNUNET_PeerIdentity all_zeros;
819  struct GSF_LocalClient *lc = cls;
820  struct ClientRequest *cr;
821  struct GSF_PendingRequestData *prd;
822  uint16_t msize;
823  unsigned int sc;
824  enum GNUNET_BLOCK_Type type;
826 
827  GNUNET_STATISTICS_update(GSF_stats,
828  gettext_noop("# client searches received"),
829  1,
830  GNUNET_NO);
831  msize = ntohs(sm->header.size) - sizeof(struct SearchMessage);
832  sc = msize / sizeof(struct GNUNET_HashCode);
833  type = ntohl(sm->type);
835  "Received request for `%s' of type %u from local client\n",
836  GNUNET_h2s(&sm->query),
837  (unsigned int)type);
838  cr = NULL;
839  /* detect duplicate UBLOCK requests */
840  if ((type == GNUNET_BLOCK_TYPE_FS_UBLOCK) ||
841  (type == GNUNET_BLOCK_TYPE_ANY))
842  {
843  cr = lc->cr_head;
844  while (NULL != cr)
845  {
847  /* only unify with queries that hae not yet started local processing
848  (SEARCH_MESSAGE_OPTION_CONTINUED was always set) and that have a
849  matching query and type */
850  if ((GNUNET_YES != prd->has_started) &&
851  (0 != memcmp(&prd->query,
852  &sm->query,
853  sizeof(struct GNUNET_HashCode))) &&
854  (prd->type == type))
855  break;
856  cr = cr->next;
857  }
858  }
859  if (NULL != cr)
860  {
862  "Have existing request, merging content-seen lists.\n");
864  (const struct GNUNET_HashCode *)&sm[1],
865  sc);
866  GNUNET_STATISTICS_update(GSF_stats,
867  gettext_noop("# client searches updated (merged content seen list)"),
868  1,
869  GNUNET_NO);
870  }
871  else
872  {
873  GNUNET_STATISTICS_update(GSF_stats,
874  gettext_noop("# client searches active"),
875  1,
876  GNUNET_NO);
877  cr = GNUNET_new(struct ClientRequest);
878  cr->lc = lc;
880  lc->cr_tail,
881  cr);
882  options = GSF_PRO_LOCAL_REQUEST;
883  if (0 != (SEARCH_MESSAGE_OPTION_LOOPBACK_ONLY & ntohl(sm->options)))
884  options |= GSF_PRO_LOCAL_ONLY;
885  cr->pr = GSF_pending_request_create_(options, type,
886  &sm->query,
887  (0 !=
888  memcmp(&sm->target,
889  &all_zeros,
890  sizeof(struct GNUNET_PeerIdentity)))
891  ? &sm->target : NULL, NULL, 0,
892  0 /* bf */,
893  ntohl(sm->anonymity_level),
894  0 /* priority */,
895  0 /* ttl */,
896  0 /* sender PID */,
897  0 /* origin PID */,
898  (const struct GNUNET_HashCode *)&sm[1], sc,
900  cr);
901  }
902  if (0 != (SEARCH_MESSAGE_OPTION_CONTINUED & ntohl(sm->options)))
903  {
905  return;
906  }
908  GSF_local_lookup_(cr->pr,
910  lc);
911 }
912 
913 
920 static void
922  const struct RequestLocSignatureMessage *msg)
923 {
924  struct GSF_LocalClient *lc = cls;
925  struct GNUNET_FS_Uri base;
926  struct GNUNET_FS_Uri *loc;
927  struct GNUNET_MQ_Envelope *env;
928  struct ResponseLocSignatureMessage *resp;
929 
931  ntohl(msg->purpose));
932  base.type = GNUNET_FS_URI_CHK;
933  base.data.chk.chk = msg->chk;
935  loc = GNUNET_FS_uri_loc_create(&base,
936  pk,
938  env = GNUNET_MQ_msg(resp,
942  resp->signature = loc->data.loc.contentSignature;
943  resp->peer = loc->data.loc.peer;
945  GNUNET_MQ_send(lc->mq,
946  env);
948 }
949 
950 
958 static int
960  const struct IndexStartMessage *ism)
961 {
962  char *fn;
963 
965  if (0 != ism->reserved)
966  {
967  GNUNET_break(0);
968  return GNUNET_SYSERR;
969  }
970  fn = GNUNET_STRINGS_filename_expand((const char *)&ism[1]);
971  if (NULL == fn)
972  {
973  GNUNET_break(0);
974  return GNUNET_SYSERR;
975  }
976  GNUNET_free(fn);
977  return GNUNET_OK;
978 }
979 
980 
987 static void
989 {
990  struct GSF_LocalClient *lc = isc->lc;
991  struct GNUNET_MQ_Envelope *env;
992  struct GNUNET_MessageHeader *msg;
993 
995  &isc->file_id);
996  env = GNUNET_MQ_msg(msg,
998  GNUNET_MQ_send(lc->mq,
999  env);
1000  GNUNET_free(isc->filename);
1001  GNUNET_free(isc);
1003 }
1004 
1005 
1013 static void
1015  const struct GNUNET_HashCode *res)
1016 {
1017  struct IndexStartContext *isc = cls;
1018  struct GSF_LocalClient *lc = isc->lc;
1019  struct GNUNET_MQ_Envelope *env;
1020  struct GNUNET_MessageHeader *msg;
1021 
1023  lc->isc_tail,
1024  isc);
1025  isc->fhc = NULL;
1026  if ((NULL == res) ||
1027  (0 != memcmp(res,
1028  &isc->file_id,
1029  sizeof(struct GNUNET_HashCode))))
1030  {
1032  _("Hash mismatch trying to index file `%s' which does not have hash `%s'\n"),
1033  isc->filename,
1034  GNUNET_h2s(&isc->file_id));
1035  env = GNUNET_MQ_msg(msg,
1037  GNUNET_MQ_send(lc->mq,
1038  env);
1040  GNUNET_free(isc);
1041  return;
1042  }
1043  signal_index_ok(isc);
1044 }
1045 
1046 
1053 static void
1055  const struct IndexStartMessage *ism)
1056 {
1057  struct GSF_LocalClient *lc = cls;
1058  struct IndexStartContext *isc;
1059  char *fn;
1060  uint64_t dev;
1061  uint64_t ino;
1062  uint64_t mydev;
1063  uint64_t myino;
1064 
1065  fn = GNUNET_STRINGS_filename_expand((const char *)&ism[1]);
1066  GNUNET_assert(NULL != fn);
1067  dev = GNUNET_ntohll(ism->device);
1068  ino = GNUNET_ntohll(ism->inode);
1069  isc = GNUNET_new(struct IndexStartContext);
1070  isc->filename = fn;
1071  isc->file_id = ism->file_id;
1073  "Received START_INDEX message for file `%s'\n",
1074  isc->filename);
1075  isc->lc = lc;
1076  mydev = 0;
1077  myino = 0;
1078  if (((dev != 0) ||
1079  (ino != 0)) &&
1081  &mydev,
1082  &myino)) &&
1083  (dev == mydev) &&
1084  (ino == myino))
1085  {
1086  /* fast validation OK! */
1087  signal_index_ok(isc);
1088  return;
1089  }
1091  "Mismatch in file identifiers (%llu != %llu or %u != %u), need to hash.\n",
1092  (unsigned long long)ino,
1093  (unsigned long long)myino,
1094  (unsigned int)dev,
1095  (unsigned int)mydev);
1096  /* slow validation, need to hash full file (again) */
1098  lc->isc_tail,
1099  isc);
1101  isc->filename,
1104  isc);
1105  if (NULL == isc->fhc)
1106  hash_for_index_val(isc,
1107  NULL);
1108 }
1109 
1110 
1117 static void
1119  const struct GNUNET_MessageHeader *message)
1120 {
1121  struct GSF_LocalClient *lc = cls;
1122 
1125 }
1126 
1127 
1134 static void
1136  const struct UnindexMessage *um)
1137 {
1138  struct GSF_LocalClient *lc = cls;
1139  struct GNUNET_MQ_Envelope *env;
1140  struct GNUNET_MessageHeader *msg;
1141  int found;
1142 
1143  GNUNET_break(0 == um->reserved);
1144  found = GNUNET_FS_indexing_do_unindex(&um->file_id);
1146  "Client requested unindexing of file `%s': %s\n",
1147  GNUNET_h2s(&um->file_id),
1148  found ? "found" : "not found");
1149  env = GNUNET_MQ_msg(msg,
1151  GNUNET_MQ_send(lc->mq,
1152  env);
1154 }
1155 
1156 
1162 static void
1163 shutdown_task(void *cls)
1164 {
1166  if (NULL != GSF_core)
1167  {
1168  GNUNET_CORE_disconnect(GSF_core);
1169  GSF_core = NULL;
1170  }
1171  if (NULL != GSF_ats)
1172  {
1173  GNUNET_ATS_performance_done(GSF_ats);
1174  GSF_ats = NULL;
1175  }
1176  GSF_put_done_();
1177  GSF_push_done_();
1179  GSF_plan_done();
1182  GNUNET_NO);
1183  GSF_dsh = NULL;
1184  GNUNET_DHT_disconnect(GSF_dht);
1185  GSF_dht = NULL;
1186  GNUNET_BLOCK_context_destroy(GSF_block_ctx);
1187  GSF_block_ctx = NULL;
1188  GNUNET_CONFIGURATION_destroy(block_cfg);
1189  block_cfg = NULL;
1191  GSF_stats = NULL;
1192  if (NULL != cover_age_task)
1193  {
1194  GNUNET_SCHEDULER_cancel(cover_age_task);
1195  cover_age_task = NULL;
1196  }
1198  GNUNET_LOAD_value_free(datastore_get_load);
1199  datastore_get_load = NULL;
1200  GNUNET_LOAD_value_free(GSF_rt_entry_lifetime);
1201  GSF_rt_entry_lifetime = NULL;
1202 }
1203 
1204 
1215 static void
1217  const struct GNUNET_PeerIdentity *my_identity)
1218 {
1219  if (0 != GNUNET_memcmp(&GSF_my_id,
1220  my_identity))
1221  {
1223  "Peer identity mismatch, refusing to start!\n");
1225  }
1226 }
1227 
1228 
1234 static int
1236 {
1237  struct GNUNET_MQ_MessageHandler no_p2p_handlers[] = {
1239  };
1240  struct GNUNET_MQ_MessageHandler p2p_handlers[] = {
1241  GNUNET_MQ_hd_var_size(p2p_get,
1243  struct GetMessage,
1244  NULL),
1245  GNUNET_MQ_hd_var_size(p2p_put,
1247  struct PutMessage,
1248  NULL),
1249  GNUNET_MQ_hd_fixed_size(p2p_migration_stop,
1251  struct MigrationStopMessage,
1252  NULL),
1254  };
1255  int anon_p2p_off;
1256  char *keyfile;
1257 
1258  /* this option is really only for testcases that need to disable
1259  _anonymous_ file-sharing for some reason */
1260  anon_p2p_off = (GNUNET_YES ==
1262  "fs",
1263  "DISABLE_ANON_TRANSFER"));
1264 
1265  if (GNUNET_OK !=
1267  "PEER",
1268  "PRIVATE_KEY",
1269  &keyfile))
1270  {
1272  _("FS service is lacking HOSTKEY configuration setting. Exiting.\n"));
1274  return GNUNET_SYSERR;
1275  }
1277  GNUNET_free(keyfile);
1278  GNUNET_assert(NULL != pk);
1281 
1283  "I am peer %s\n",
1284  GNUNET_i2s(&GSF_my_id));
1285  GSF_core
1286  = GNUNET_CORE_connect(GSF_cfg,
1287  NULL,
1291  (GNUNET_YES == anon_p2p_off)
1292  ? no_p2p_handlers
1293  : p2p_handlers);
1294  if (NULL == GSF_core)
1295  {
1297  _("Failed to connect to `%s' service.\n"),
1298  "core");
1299  return GNUNET_SYSERR;
1300  }
1301  cover_age_task =
1304  NULL);
1305  datastore_get_load = GNUNET_LOAD_value_init(DATASTORE_LOAD_AUTODECLINE);
1308  NULL);
1309  return GNUNET_OK;
1310 }
1311 
1312 
1320 static void
1321 run(void *cls,
1322  const struct GNUNET_CONFIGURATION_Handle *cfg,
1324 {
1325  unsigned long long dqs;
1326 
1327  GSF_cfg = cfg;
1328  if (GNUNET_OK !=
1330  "fs",
1331  "DATASTORE_QUEUE_SIZE",
1332  &dqs))
1333  {
1335  "fs",
1336  "DATASTORE_QUEUE_SIZE");
1337  dqs = 32;
1338  }
1339  GSF_datastore_queue_size = (unsigned int)dqs;
1341  GNUNET_CONFIGURATION_get_value_yesno(cfg, "fs", "DELAY");
1342  GSF_dsh = GNUNET_DATASTORE_connect(cfg);
1343  if (NULL == GSF_dsh)
1344  {
1346  return;
1347  }
1348  GSF_rt_entry_lifetime = GNUNET_LOAD_value_init(GNUNET_TIME_UNIT_FOREVER_REL);
1349  GSF_stats = GNUNET_STATISTICS_create("fs", cfg);
1350  block_cfg = GNUNET_CONFIGURATION_create();
1351  GSF_block_ctx = GNUNET_BLOCK_context_create(block_cfg);
1352  GNUNET_assert(NULL != GSF_block_ctx);
1353  GSF_dht = GNUNET_DHT_connect(cfg, FS_DHT_HT_SIZE);
1354  GSF_plan_init();
1357  GSF_ats = GNUNET_ATS_performance_init(GSF_cfg,
1359  NULL);
1360  GSF_push_init_();
1361  GSF_put_init_();
1362  if ((GNUNET_OK != GNUNET_FS_indexing_init(cfg,
1363  GSF_dsh)) ||
1364  (GNUNET_OK != main_init(cfg)))
1365  {
1367  shutdown_task(NULL);
1368  return;
1369  }
1370 }
1371 
1372 
1377  ("fs",
1379  &run,
1382  NULL,
1383  GNUNET_MQ_hd_var_size(client_index_start,
1385  struct IndexStartMessage,
1386  NULL),
1387  GNUNET_MQ_hd_fixed_size(client_index_list_get,
1389  struct GNUNET_MessageHeader,
1390  NULL),
1391  GNUNET_MQ_hd_fixed_size(client_unindex,
1393  struct UnindexMessage,
1394  NULL),
1395  GNUNET_MQ_hd_var_size(client_start_search,
1397  struct SearchMessage,
1398  NULL),
1399  GNUNET_MQ_hd_fixed_size(client_loc_sign,
1402  NULL),
1404 
1405 
1406 /* end of gnunet-service-fs.c */
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct GNUNET_BLOCK_Context * GNUNET_BLOCK_context_create(const struct GNUNET_CONFIGURATION_Handle *cfg)
Create a block context.
Definition: block.c:130
API to handle &#39;connected peers&#39;.
struct ClientRequest * prev
This is a doubly-linked list.
int GNUNET_FS_indexing_do_unindex(const struct GNUNET_HashCode *fid)
Remove a file from the index.
GNUNET_SERVICE_MAIN("fs", GNUNET_SERVICE_OPTION_NONE, &run, &client_connect_cb, &client_disconnect_cb, NULL, GNUNET_MQ_hd_var_size(client_index_start, GNUNET_MESSAGE_TYPE_FS_INDEX_START, struct IndexStartMessage, NULL), GNUNET_MQ_hd_fixed_size(client_index_list_get, GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_GET, struct GNUNET_MessageHeader, NULL), GNUNET_MQ_hd_fixed_size(client_unindex, GNUNET_MESSAGE_TYPE_FS_UNINDEX, struct UnindexMessage, NULL), GNUNET_MQ_hd_var_size(client_start_search, GNUNET_MESSAGE_TYPE_FS_START_SEARCH, struct SearchMessage, NULL), GNUNET_MQ_hd_fixed_size(client_loc_sign, GNUNET_MESSAGE_TYPE_FS_REQUEST_LOC_SIGN, struct RequestLocSignatureMessage, NULL), GNUNET_MQ_handler_end())
Define "main" method using service macro.
struct ContentHashKey chk
Query and key of the top GNUNET_EC_IBlock.
Definition: fs_api.h:102
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
Handle to an initialized block library.
Definition: block.c:53
static struct GNUNET_CRYPTO_EddsaPrivateKey * pk
Private key of this peer.
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
int GSF_enable_randomized_delays
Are we introducing randomized delays for better anonymity?
static char * expiration
Credential TTL.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
Definition: time.c:671
void GSF_plan_add_(struct GSF_ConnectedPeer *cp, struct GSF_PendingRequest *pr)
Create a new query plan entry.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_DATASTORE_GET.
Definition: datastore.h:140
struct FileIdentifier chk
Information needed to retrieve a file (content-hash-key plus file size).
Definition: fs_api.h:204
uint64_t rel_value_us
The actual value.
struct GNUNET_LOAD_Value * GNUNET_LOAD_value_init(struct GNUNET_TIME_Relative autodecline)
Create a new load value.
Definition: load.c:122
void GSF_plan_done()
Shutdown plan subsystem.
uint32_t reserved
Always zero.
Definition: fs.h:230
struct GNUNET_FS_Uri * GNUNET_FS_uri_loc_create(const struct GNUNET_FS_Uri *base_uri, const struct GNUNET_CRYPTO_EddsaPrivateKey *sign_key, struct GNUNET_TIME_Absolute expiration_time)
Construct a location URI (this peer will be used for the location).
Definition: fs_uri.c:876
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
static void handle_client_start_search(void *cls, const struct SearchMessage *sm)
Handle GNUNET_MESSAGE_TYPE_FS_START_SEARCH-message (search request from client).
void GSF_update_datastore_delay_(struct GNUNET_TIME_Absolute start)
We&#39;ve just now completed a datastore request.
Any type of block, used as a wildcard when searching.
static GNUNET_CronTime last_transmission
Context for the core service connection.
Definition: core_api.c:76
void GSF_connected_peer_init_()
Initialize peer management subsystem.
Response from FS service with a result for a previous FS search.
Definition: fs.h:321
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
uint32_t num_transmissions
Counter for how often this request has been transmitted (estimate, because we might have the same req...
Handle to a service.
Definition: service.c:114
GNUNET_BLOCK_Type
Blocks in the datastore and the datacache must have a unique type.
struct IndexStartContext * next
This is a doubly linked list.
uint32_t purpose
Requested signature purpose.
Definition: fs.h:83
double GSF_current_priorities
Typical priorities we&#39;re seeing from other peers right now.
void GNUNET_FS_indexing_done()
Shutdown the module.
Replies to be transmitted to the client.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received, or when GNUNET_SCHEDULER_shutdown() is being invoked.
Definition: scheduler.c:1284
void GSF_put_done_()
Shutdown the module.
struct IndexStartContext * isc_head
This is a doubly linked list.
#define GNUNET_MESSAGE_TYPE_FS_INDEX_START_FAILED
Response to a request for start indexing that refuses.
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
void GSF_peer_disconnect_handler(void *cls, const struct GNUNET_PeerIdentity *peer, void *internal_cls)
A peer disconnected from us.
static int start
Set if we are to start default services (including ARM).
Definition: gnunet-arm.c:39
static struct GNUNET_LOAD_Value * datastore_get_load
Datastore &#39;GET&#39; load tracking.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static void peer_init_handler(void *cls, const struct GNUNET_PeerIdentity *my_identity)
Function called after GNUNET_CORE_connect has succeeded (or failed for good).
static void client_disconnect_cb(void *cls, struct GNUNET_SERVICE_Client *client, void *app_ctx)
A client disconnected from us.
struct GSF_PendingRequest * pr
Request this entry represents.
uint32_t options
Bitmask with options.
Definition: fs.h:277
#define GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_GET
Request from client for list of indexed files.
struct GNUNET_MQ_Handle * mq
Queue for sending replies.
uint32_t anonymity_level
Desired anonymity level.
double GNUNET_LOAD_get_load(struct GNUNET_LOAD_Value *load)
Get the current load.
Definition: load.c:199
void GSF_cadet_stop_server(void)
Shutdown subsystem for non-anonymous file-sharing.
struct GNUNET_ATS_PerformanceHandle * GSF_ats
Handle to ATS service.
definitions for the entire fs module
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
void GNUNET_ATS_performance_done(struct GNUNET_ATS_PerformanceHandle *ph)
Client is done using the ATS performance subsystem, release resources.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#define COVER_AGE_FREQUENCY
How quickly do we age cover traffic? At the given time interval, remaining cover traffic counters are...
uint64_t file_length
Size of the shared file (to be signed).
Definition: fs.h:98
unsigned int GSF_cover_query_count
How many query messages have we received &#39;recently&#39; that have not yet been claimed as cover traffic...
struct GNUNET_DHT_Handle * GSF_dht
Handle for DHT operations.
struct GNUNET_STATISTICS_Handle * GSF_stats
Handle for reporting statistics.
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
char * filename
Name of the indexed file.
struct GNUNET_TIME_AbsoluteNBO last_transmission
When was the last time we&#39;ve tried to download this block? (FOREVER if unknown/not relevant) ...
Definition: fs.h:366
int GNUNET_DISK_file_get_identifiers(const char *filename, uint64_t *dev, uint64_t *ino)
Obtain some unique identifiers for the given file that can be used to identify it in the local system...
Definition: disk.c:288
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static int check_p2p_get(void *cls, const struct GetMessage *gm)
Check P2P "GET" request.
struct GNUNET_PeerIdentity peer
Identity of the peer sharing the file.
Definition: fs_api.h:119
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create(void)
Create a new configuration object.
static struct GNUNET_PeerIdentity my_identity
Identity of this peer.
static int main_init(const struct GNUNET_CONFIGURATION_Handle *c)
Process fs requests.
struct IndexStartContext * isc_tail
This is a doubly linked list.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
struct ClientRequest * next
This is a doubly-linked list.
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
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.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:517
Handle for the service.
#define GNUNET_MESSAGE_TYPE_FS_REQUEST_LOC_SIGNATURE
Reply sent by fs service with LOC signature.
struct GNUNET_PeerIdentity target
If the request is for a DBLOCK or IBLOCK, this is the identity of the peer that is known to have a re...
Definition: fs.h:299
struct GNUNET_SCHEDULER_Task * kill_task
Task scheduled to destroy the request.
Message sent from a GNUnet (fs) publishing activity to the gnunet-fs-service to initiate indexing of ...
Definition: fs.h:148
ATS performance characteristics for an address.
const struct GNUNET_CONFIGURATION_Handle * GSF_cfg
Our configuration.
void GSF_iterate_connected_peers_(GSF_ConnectedPeerIterator it, void *it_cls)
Iterate over all connected peers.
void GSF_pending_request_update_(struct GSF_PendingRequest *pr, const struct GNUNET_HashCode *replies_seen, unsigned int replies_seen_count)
Update a given pending request with additional replies that have been seen.
void GSF_pending_request_init_()
Setup the subsystem.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Type of a block representing a block to be encoded on demand from disk.
Connection to the DHT service.
Definition: dht_api.c:198
int GNUNET_FS_indexing_init(const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_DATASTORE_Handle *d)
Initialize the indexing submodule.
#define GNUNET_MESSAGE_TYPE_FS_INDEX_START_OK
Affirmative response to a request for start indexing.
void GNUNET_FS_indexing_send_list(struct GNUNET_MQ_Handle *mq)
Transmit information about indexed files to mq.
void GNUNET_LOAD_update(struct GNUNET_LOAD_Value *load, uint64_t data)
Update the current load.
Definition: load.c:235
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
struct GNUNET_HashCode query
Primary query hash for this request.
Information we track while handling an index start request from a client.
Handle to a client that is connected to a service.
Definition: service.c:246
struct GNUNET_HashCode query
Hash of the public key for UBLOCKs; Hash of the CHK-encoded block for DBLOCKS and IBLOCKS...
Definition: fs.h:305
A local client.
void GSF_push_init_()
Setup the module.
API to handle pending requests.
struct GNUNET_TIME_AbsoluteNBO expiration
When does this result expire?
Definition: fs.h:360
static void handle_client_unindex(void *cls, const struct UnindexMessage *um)
Handle UNINDEX-message.
Public data (in the sense of not encapsulated within &#39;gnunet-service-fs_pr&#39;, not in the sense of netw...
#define GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT
Signature by which a peer affirms that it is providing a certain bit of content (used in LOCation URI...
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1237
API to manage query plan.
void GSF_update_peer_latency_(const struct GNUNET_PeerIdentity *id, struct GNUNET_TIME_Relative latency)
Update the latency information kept for the given peer.
static void consider_request_for_forwarding(void *cls, const struct GNUNET_PeerIdentity *peer, struct GSF_ConnectedPeer *cp, const struct GSF_PeerPerformanceData *ppd)
We have a new request, consider forwarding it to the given peer.
#define GNUNET_MQ_check_zero_termination(m)
Insert code for a "check_" function that verifies that a given variable-length message received over ...
void * cls
Closure for mv and cb.
static void run(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_SERVICE_Handle *service)
Process fs requests.
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
int GSF_pending_request_test_active_(struct GSF_PendingRequest *pr)
Check if the given request is still active.
static void start_p2p_processing(void *cls, struct GSF_PendingRequest *pr, enum GNUNET_BLOCK_EvaluationResult result)
We&#39;re done with the local lookup, now consider P2P processing (depending on request options and resul...
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
static char * fn
Filename of the unique file.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
Message to the datastore service asking about specific content.
Definition: datastore.h:136
uint32_t hash_bitmap
Which of the optional hash codes are present at the end of the message? See GET_MESSAGE_BIT_xx consta...
void GSF_plan_init()
Initialize plan subsystem.
struct GSF_LocalClient * lc
Client list this request belongs to.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1264
unsigned int GSF_datastore_queue_size
Size of the datastore queue we assume for common requests.
struct GNUNET_BLOCK_Context * GSF_block_ctx
Our block context.
non-anonymous file-transfer
union GNUNET_FS_Uri::@16 data
static struct GNUNET_CONFIGURATION_Handle * block_cfg
Configuration for block library.
#define GNUNET_MIN(a, b)
Definition: gnunet_common.h:80
Inner block in the CHK tree.
Message sent from a GNUnet (fs) unindexing activity to the gnunet-service-fs to indicate that a file ...
Definition: fs.h:221
struct GNUNET_HashCode file_id
Hash of the file that we will unindex.
Definition: fs.h:235
static void handle_client_loc_sign(void *cls, const struct RequestLocSignatureMessage *msg)
Handle request to sign a LOC URI (from client).
struct GNUNET_TIME_AbsoluteNBO expiration_time
Expiration time that was actually used (rounded!).
Definition: fs.h:121
Last possible valid result.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
struct GSF_LocalClient * lc
Client list entry this response belongs to.
struct GNUNET_PeerIdentity GSF_my_id
Identity of this peer.
void GSF_local_lookup_(struct GSF_PendingRequest *pr, GSF_LocalLookupContinuation cont, void *cont_cls)
Look up the request in the local datastore.
uint32_t type
Type of the content that we&#39;re looking for.
Definition: fs.h:282
struct GNUNET_TIME_Relative delay
Delay.
static int result
Global testing status.
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
uint32_t respect_offered
How much respect did we (in total) offer for this request so far (estimate, because we might have the...
static void age_cover_counters(void *cls)
Task that periodically ages our cover traffic statistics.
enum GNUNET_BLOCK_Type type
Type of the requested block.
support for putting content into the DHT
uint32_t purpose
Purpose of the generated signature.
Definition: fs.h:116
struct IndexStartContext * prev
This is a doubly linked list.
Request must only be processed locally.
void GNUNET_CRYPTO_hash_file_cancel(struct GNUNET_CRYPTO_FileHashContext *fhc)
Cancel a file hashing operation.
void GNUNET_FS_uri_destroy(struct GNUNET_FS_Uri *uri)
Free URI.
Definition: fs_uri.c:675
void GNUNET_STATISTICS_set(struct GNUNET_STATISTICS_Handle *handle, const char *name, uint64_t value, int make_persistent)
Set statistic value for the peer.
Type of a block representing any type of search result (universal).
A 512-bit hashcode.
int GNUNET_CONFIGURATION_get_value_size(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *size)
Get a configuration value that should be a size in bytes.
struct GNUNET_CORE_Handle * GSF_core
Pointer to handle to the core service (points to NULL until we&#39;ve connected to it).
Message handler for a specific message type.
static int res
struct GNUNET_DATASTORE_Handle * GSF_dsh
Our connection to the datastore.
#define GNUNET_MESSAGE_TYPE_FS_UNINDEX_OK
Reply to client indicating unindex receipt.
void GNUNET_BLOCK_context_destroy(struct GNUNET_BLOCK_Context *ctx)
Destroy the block context.
Definition: block.c:150
Run when otherwise idle.
struct GNUNET_MessageHeader header
Message type will be GNUNET_MESSAGE_TYPE_FS_START_SEARCH.
Definition: fs.h:266
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
struct GNUNET_CRYPTO_FileHashContext * fhc
Context for hashing of the file.
Content-hash-key (simple file).
Definition: fs_api.h:140
void GSF_cadet_lookup_(struct GSF_PendingRequest *pr)
Consider downloading via cadet (if possible)
struct ClientResponse * res_tail
Tail of linked list of responses.
#define GNUNET_MESSAGE_TYPE_FS_INDEX_START
Message sent by fs client to start indexing.
static void handle_client_index_start(void *cls, const struct IndexStartMessage *ism)
Handle INDEX_START-message.
void GSF_pending_request_done_()
Shutdown the subsystem.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
struct GNUNET_PeerIdentity peer
Identity of the peer sharing the file.
Definition: fs.h:131
int GSF_test_get_load_too_high_(uint32_t priority)
Test if the DATABASE (GET) load on this peer is too high to even consider processing the query at all...
struct GNUNET_DHT_Handle * GNUNET_DHT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, unsigned int ht_len)
Initialize the connection with the DHT service.
Definition: dht_api.c:885
Values we track for load calculations.
Definition: load.c:35
struct GNUNET_CORE_Handle * GNUNET_CORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, void *cls, GNUNET_CORE_StartupCallback init, GNUNET_CORE_ConnectEventHandler connects, GNUNET_CORE_DisconnectEventHandler disconnects, const struct GNUNET_MQ_MessageHandler *handlers)
Connect to the core service.
Definition: core_api.c:690
static struct GNUNET_SCHEDULER_Task * cover_age_task
ID of our task that we use to age the cover counters.
void GNUNET_CORE_disconnect(struct GNUNET_CORE_Handle *handle)
Disconnect from the core service.
Definition: core_api.c:728
char * GNUNET_STRINGS_filename_expand(const char *fil)
Complete filename (a la shell) from abbrevition.
Definition: strings.c:602
GNUNET_BLOCK_EvaluationResult
Possible ways for how a block may relate to a query.
size_t msize
Number of bytes in the response.
void GNUNET_DHT_disconnect(struct GNUNET_DHT_Handle *handle)
Shutdown connection with the DHT service.
Definition: dht_api.c:913
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static struct GNUNET_FS_SearchContext * sc
Definition: gnunet-search.c:37
void GSF_consider_forwarding(void *cls, struct GSF_PendingRequest *pr, enum GNUNET_BLOCK_EvaluationResult result)
Function to be called after we&#39;re done processing replies from the local lookup.
indexing for the file-sharing service
#define GNUNET_MESSAGE_TYPE_FS_UNINDEX
Request from client to unindex a file.
Message send by a peer that wants to be excluded from migration for a while.
struct GNUNET_PeerIdentity peer
For which peer is this an address?
struct GNUNET_TIME_Absolute expirationTime
Time when this location URI expires.
Definition: fs_api.h:124
32-bit bandwidth used for network exchange by GNUnet, in bytes per second.
enum GNUNET_FS_UriType type
Type of the URI.
Definition: fs_api.h:166
Context used when hashing a file.
static int check_client_index_start(void *cls, const struct IndexStartMessage *ism)
Check INDEX_START-message.
uint32_t type
Type of the block (in big endian).
Definition: fs.h:330
uint32_t respect_offered
How much respect did we offer (in total) before getting an answer (estimate).
Definition: fs.h:378
struct ClientResponse * next
This is a doubly-linked list.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
void GNUNET_CRYPTO_eddsa_key_get_public(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Extract the public key for the given private key.
Definition: crypto_ecc.c:272
struct ContentHashKey chk
Information about the shared file (to be signed).
Definition: fs.h:93
ATS Handle to obtain and/or modify performance information.
#define GNUNET_MESSAGE_TYPE_FS_START_SEARCH
Client asks FS service to start a (keyword) search.
static int check_p2p_put(void *cls, const struct PutMessage *put)
Check P2P "PUT" message.
struct ClientResponse * prev
This is a doubly-linked list.
Message sent from the service with the signed LOC URI.
Definition: fs.h:105
Response from FS service with a result for a previous FS search.
Definition: fs.h:346
struct GNUNET_ATS_PerformanceHandle * GNUNET_ATS_performance_init(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_ATS_AddressInformationCallback addr_info_cb, void *addr_info_cb_cls)
Get handle to access performance API of the ATS subsystem.
Handle to a message queue.
Definition: mq.c:84
uint32_t type
Type of the block (in big endian).
Definition: fs.h:355
int GSF_pending_request_test_target_(struct GSF_PendingRequest *pr, const struct GNUNET_PeerIdentity *target)
Is the given target a legitimate peer for forwarding the given request?
Doubly-linked list of requests we are performing on behalf of the same client.
Private ECC key encoded for transmission.
The identity of the host (wraps the signing key of the peer).
struct GNUNET_LOAD_Value * GSF_rt_entry_lifetime
How long do requests typically stay in the routing table?
struct GSF_PendingRequestData * GSF_pending_request_get_data_(struct GSF_PendingRequest *pr)
Obtain the public data associated with a pending request.
void * GSF_peer_connect_handler(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
A peer connected to us.
Option mask for typical local requests.
Message sent from a GNUnet (fs) publishing activity to sign a LOC URI.
Definition: fs.h:73
Performance data kept for a peer.
static void client_response_handler(void *cls, enum GNUNET_BLOCK_EvaluationResult eval, struct GSF_PendingRequest *pr, uint32_t reply_anonymity_level, struct GNUNET_TIME_Absolute expiration, struct GNUNET_TIME_Absolute last_transmission, enum GNUNET_BLOCK_Type type, const void *data, size_t data_len)
Handle a reply to a pending request.
#define HASHING_BLOCKSIZE
Blocksize to use when hashing files for indexing (blocksize for IO, not for the DBlocks).
Definition: fs.h:47
configuration data
Definition: configuration.c:83
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 ClientResponse * res_head
Head of linked list of responses.
static int check_client_start_search(void *cls, const struct SearchMessage *sm)
Check GNUNET_MESSAGE_TYPE_FS_START_SEARCH-message (search request from client).
A Universal Resource Identifier (URI), opaque.
Definition: fs_api.h:162
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:373
Handle to the datastore service.
uint64_t file_length
Total size of the file in bytes.
Definition: fs_api.h:97
#define GNUNET_LOAD_value_free(lv)
Free a load value.
An address for communicating with a peer.
struct GNUNET_HashCode file_id
Hash of the contents of the file.
#define GNUNET_MESSAGE_TYPE_FS_MIGRATION_STOP
Peer asks us to stop migrating content towards it for a while.
static void shutdown_task(void *cls)
Task run during shutdown.
struct GNUNET_CRYPTO_EddsaSignature signature
The requested signature.
Definition: fs.h:126
struct GNUNET_CRYPTO_EddsaSignature contentSignature
Signature over the GNUNET_EC_FileIdentifier, peer identity and expiration time.
Definition: fs_api.h:130
void GSF_dht_lookup_(struct GSF_PendingRequest *pr)
Consider looking up the data in the DHT (anonymity-level permitting).
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
#define GNUNET_log(kind,...)
Entry in list of pending tasks.
Definition: scheduler.c:131
uint32_t reserved
For alignment.
Definition: fs.h:157
#define GNUNET_MESSAGE_TYPE_FS_REQUEST_LOC_SIGN
Message sent by fs client to request LOC signature.
struct GSF_LocalClient * lc
Context for transmitting confirmation to client.
A connected peer.
static void handle_client_index_list_get(void *cls, const struct GNUNET_MessageHeader *message)
Handle INDEX_LIST_GET-message.
#define FS_DHT_HT_SIZE
Size for the hash map for DHT requests from the FS service.
struct GNUNET_CRYPTO_EddsaPrivateKey * GNUNET_CRYPTO_eddsa_key_create_from_file(const char *filename)
Create a new private key by reading it from a file.
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.
Data block (leaf) in the CHK tree.
void GSF_push_done_()
Shutdown the module.
#define SEARCH_MESSAGE_OPTION_CONTINUED
Request is too large to fit in 64k format.
Definition: fs.h:255
static void update_latencies(void *cls, const struct GNUNET_HELLO_Address *address, int active, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, const struct GNUNET_ATS_Properties *prop)
We&#39;ve received peer performance information.
unsigned int GSF_cover_content_count
How many content messages have we received &#39;recently&#39; that have not yet been claimed as cover traffic...
struct GNUNET_TIME_Relative GSF_avg_latency
Running average of the observed latency to other peers (round trip).
struct ClientRequest * cr_head
Head of list of requests performed on behalf of this client right now.
struct GNUNET_TIME_AbsoluteNBO expiration_time
Requested expiration time.
Definition: fs.h:88
struct ClientRequest * cr_tail
Tail of list of requests performed on behalf of this client right now.
struct GSF_PendingRequest * GSF_pending_request_create_(enum GSF_PendingRequestOptions options, enum GNUNET_BLOCK_Type type, const struct GNUNET_HashCode *query, const struct GNUNET_PeerIdentity *target, const char *bf_data, size_t bf_size, uint32_t mingle, uint32_t anonymity_level, uint32_t priority, int32_t ttl, GNUNET_PEER_Id sender_pid, GNUNET_PEER_Id origin_pid, const struct GNUNET_HashCode *replies_seen, unsigned int replies_seen_count, GSF_PendingRequestReplyHandler rh, void *rh_cls)
Create a new pending request.
struct Location loc
Information needed to retrieve a file including signed location (identity of a peer) of the content...
Definition: fs_api.h:210
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
static void signal_index_ok(struct IndexStartContext *isc)
We&#39;ve validated the hash of the file we&#39;re about to index.
Header for all communications.
Time for absolute times used by GNUnet, in microseconds.
#define GNUNET_YES
Definition: gnunet_common.h:77
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:351
struct GNUNET_SERVICE_Client * client
ID of the client.
void GSF_cadet_start_server(void)
Initialize subsystem for non-anonymous file-sharing.
static void * client_connect_cb(void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq)
Creates a fresh local client handle.
void GSF_connected_peer_done_()
Shutdown peer management subsystem.
An active request.
support for pushing out content
#define SEARCH_MESSAGE_OPTION_LOOPBACK_ONLY
Only search the local datastore (no network)
Definition: fs.h:247
static void client_request_destroy(void *cls)
Free the given client request.
static void hash_for_index_val(void *cls, const struct GNUNET_HashCode *res)
Function called once the hash computation over an indexed file has completed.
void GSF_pending_request_cancel_(struct GSF_PendingRequest *pr, int full_cleanup)
Explicitly cancel a pending request.
int GNUNET_CONFIGURATION_get_value_yesno(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
Get a configuration value that should be in a set of "YES" or "NO".
Message sent from a GNUnet (fs) search activity to the gnunet-service-fs to start a search...
Definition: fs.h:262
uint32_t data
The data value.
struct GNUNET_DATASTORE_Handle * GNUNET_DATASTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the datastore service.
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition: time.c:655
static char * address
GNS address for this phone.
#define GNUNET_MESSAGE_TYPE_FS_PUT
P2P response with content or active migration of content.
#define GNUNET_MESSAGE_TYPE_FS_GET
P2P request for content (one FS to another).
uint32_t anonymity_level
Desired anonymity level, big-endian.
Definition: fs.h:287
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
int has_started
Has this request been started yet (local/p2p operations)? Or are we still constructing it...
GSF_PendingRequestOptions
Options for pending requests (bits to be ORed).
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2234
#define DATASTORE_LOAD_AUTODECLINE
At what frequency should our datastore load decrease automatically (since if we don&#39;t use it...
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
void GNUNET_FS_add_to_index(const char *filename, const struct GNUNET_HashCode *file_id)
Add the given file to the list of indexed files.
void GSF_put_init_()
Setup the module.
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:48
uint32_t num_transmissions
How often did we transmit this query before getting an answer (estimate).
Definition: fs.h:372
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.
struct GNUNET_CRYPTO_EddsaPublicKey public_key
static struct GNUNET_TRANSPORT_PluginMonitor * pm
Handle if we are monitoring plugin session activity.
#define gettext_noop(String)
Definition: gettext.h:69
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:956