GNUnet 0.25.1-6-gd4cc3597f
 
Loading...
Searching...
No Matches
gnunet-service-fs.c File Reference

gnunet anonymity protocol implementation More...

Include dependency graph for gnunet-service-fs.c:

Go to the source code of this file.

Data Structures

struct  ClientRequest
 Doubly-linked list of requests we are performing on behalf of the same client. More...
 
struct  ClientResponse
 Replies to be transmitted to the client. More...
 
struct  IndexStartContext
 Information we track while handling an index start request from a client. More...
 
struct  GSF_LocalClient
 A local client. More...
 

Macros

#define FS_DHT_HT_SIZE   1024
 Size for the hash map for DHT requests from the FS service.
 
#define COVER_AGE_FREQUENCY
 How quickly do we age cover traffic? At the given time interval, remaining cover traffic counters are decremented by 1/16th.
 
#define INSANE_STATISTICS   GNUNET_NO
 Collect an instance number of statistics? May cause excessive IPC.
 

Functions

static void * client_connect_cb (void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq)
 Creates a fresh local client handle.
 
static void client_request_destroy (void *cls)
 Free the given client request.
 
static void client_response_handler (void *cls, enum GNUNET_BLOCK_ReplyEvaluationResult 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.
 
static void client_disconnect_cb (void *cls, struct GNUNET_SERVICE_Client *client, void *app_ctx)
 A client disconnected from us.
 
static void age_cover_counters (void *cls)
 Task that periodically ages our cover traffic statistics.
 
void GSF_update_datastore_delay_ (struct GNUNET_TIME_Absolute start)
 We've just now completed a datastore request.
 
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.
 
static int check_p2p_put (void *cls, const struct PutMessage *put)
 Check P2P "PUT" message.
 
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.
 
void GSF_consider_forwarding (void *cls, struct GSF_PendingRequest *pr, enum GNUNET_BLOCK_ReplyEvaluationResult result)
 Function to be called after we're done processing replies from the local lookup.
 
static int check_p2p_get (void *cls, const struct GetMessage *gm)
 Check P2P "GET" request.
 
static void start_p2p_processing (void *cls, struct GSF_PendingRequest *pr, enum GNUNET_BLOCK_ReplyEvaluationResult result)
 We're done with the local lookup, now consider P2P processing (depending on request options and result status).
 
static int check_client_start_search (void *cls, const struct SearchMessage *sm)
 Check GNUNET_MESSAGE_TYPE_FS_START_SEARCH-message (search request from client).
 
static void handle_client_start_search (void *cls, const struct SearchMessage *sm)
 Handle GNUNET_MESSAGE_TYPE_FS_START_SEARCH-message (search request from client).
 
static void handle_client_loc_sign (void *cls, const struct RequestLocSignatureMessage *msg)
 Handle request to sign a LOC URI (from client).
 
static int check_client_index_start (void *cls, const struct IndexStartMessage *ism)
 Check INDEX_START-message.
 
static void signal_index_ok (struct IndexStartContext *isc)
 We've validated the hash of the file we're about to index.
 
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.
 
static void handle_client_index_start (void *cls, const struct IndexStartMessage *ism)
 Handle INDEX_START-message.
 
static void handle_client_index_list_get (void *cls, const struct GNUNET_MessageHeader *message)
 Handle INDEX_LIST_GET-message.
 
static void handle_client_unindex (void *cls, const struct UnindexMessage *um)
 Handle UNINDEX-message.
 
static void shutdown_task (void *cls)
 Task run during shutdown.
 
static void pils_pid_change_cb (void *cls, const struct GNUNET_HELLO_Parser *parser, const struct GNUNET_HashCode *hash)
 Function called after GNUNET_PILS_connect has succeeded (or failed for good).
 
static int main_init (const struct GNUNET_CONFIGURATION_Handle *c)
 Process fs requests.
 
static void run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_SERVICE_Handle *service)
 Process fs requests.
 
 GNUNET_SERVICE_MAIN (GNUNET_OS_project_data_gnunet(), "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.
 

Variables

struct GNUNET_DATASTORE_HandleGSF_dsh
 Our connection to the datastore.
 
const struct GNUNET_CONFIGURATION_HandleGSF_cfg
 Our configuration.
 
struct GNUNET_STATISTICS_HandleGSF_stats
 Handle for reporting statistics.
 
struct GNUNET_DHT_HandleGSF_dht
 Handle for DHT operations.
 
struct GNUNET_LOAD_ValueGSF_rt_entry_lifetime
 How long do requests typically stay in the routing table?
 
struct GNUNET_TIME_Relative GSF_avg_latency = { 500 }
 Running average of the observed latency to other peers (round trip).
 
double GSF_current_priorities
 Typical priorities we're seeing from other peers right now.
 
unsigned int GSF_datastore_queue_size
 Size of the datastore queue we assume for common requests.
 
unsigned int GSF_cover_query_count
 How many query messages have we received 'recently' that have not yet been claimed as cover traffic?
 
unsigned int GSF_cover_content_count
 How many content messages have we received 'recently' that have not yet been claimed as cover traffic?
 
struct GNUNET_BLOCK_ContextGSF_block_ctx
 Our block context.
 
struct GNUNET_CORE_HandleGSF_core
 Pointer to handle to the core service (points to NULL until we've connected to it).
 
struct GNUNET_PILS_HandleGSF_pils
 Pointer to handle to the pils service (points to NULL until we've connected to it).
 
int GSF_enable_randomized_delays
 Are we introducing randomized delays for better anonymity?
 
struct GNUNET_PeerIdentity GSF_my_id
 Identity of this peer.
 
static struct GNUNET_CONFIGURATION_Handleblock_cfg
 Configuration for block library.
 
static struct GNUNET_CRYPTO_EddsaPrivateKey pk
 Private key of this peer.
 
static struct GNUNET_SCHEDULER_Taskcover_age_task
 ID of our task that we use to age the cover counters.
 
static struct GNUNET_LOAD_Valuedatastore_get_load
 Datastore 'GET' load tracking.
 

Detailed Description

gnunet anonymity protocol implementation

Author
Christian Grothoff

Definition in file gnunet-service-fs.c.

Macro Definition Documentation

◆ FS_DHT_HT_SIZE

#define FS_DHT_HT_SIZE   1024

Size for the hash map for DHT requests from the FS service.

Should be about the number of concurrent DHT requests we plan to make.

Definition at line 52 of file gnunet-service-fs.c.

◆ COVER_AGE_FREQUENCY

#define COVER_AGE_FREQUENCY
Value:
#define GNUNET_TIME_UNIT_SECONDS
One second.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
Definition time.c:486

How quickly do we age cover traffic? At the given time interval, remaining cover traffic counters are decremented by 1/16th.

Definition at line 60 of file gnunet-service-fs.c.

73{
77 struct ClientRequest *next;
78
82 struct ClientRequest *prev;
83
87 struct GSF_PendingRequest *pr;
88
92 struct GSF_LocalClient *lc;
93
97 struct GNUNET_SCHEDULER_Task *kill_task;
98};
99
100
105struct ClientResponse
106{
110 struct ClientResponse *next;
111
115 struct ClientResponse *prev;
116
120 struct GSF_LocalClient *lc;
121
125 size_t msize;
126};
127
128
134{
138 struct IndexStartContext *next;
139
143 struct IndexStartContext *prev;
144
148 char *filename;
149
153 struct GSF_LocalClient *lc;
154
159
164};
165
166
170struct GSF_LocalClient
171{
176
180 struct GNUNET_MQ_Handle *mq;
181
186 struct ClientRequest *cr_head;
187
192 struct ClientRequest *cr_tail;
193
198
203
207 struct ClientResponse *res_head;
208
212 struct ClientResponse *res_tail;
213};
214
215
216/* ****************************** globals ****************************** */
217
222
227
232
237
242
248
249
261
265unsigned int GSF_datastore_queue_size;
266
271unsigned int GSF_cover_query_count;
272
277unsigned int GSF_cover_content_count;
278
283
289
295
300
305
306/* ***************************** locals ******************************* */
307
312
317
322
327
328
337static void *
338client_connect_cb (void *cls,
339 struct GNUNET_SERVICE_Client *client,
340 struct GNUNET_MQ_Handle *mq)
341{
342 struct GSF_LocalClient *pos;
343
344 pos = GNUNET_new (struct GSF_LocalClient);
345 pos->client = client;
346 pos->mq = mq;
347 return pos;
348}
349
350
356static void
357client_request_destroy (void *cls)
358{
359 struct ClientRequest *cr = cls;
360 struct GSF_LocalClient *lc = cr->lc;
361
362 cr->kill_task = NULL;
364 lc->cr_tail,
365 cr);
367 GNUNET_YES);
369 gettext_noop ("# client searches active"),
370 -1,
371 GNUNET_NO);
372 GNUNET_free (cr);
373}
374
375
394static void
395client_response_handler (void *cls,
397 struct GSF_PendingRequest *pr,
398 uint32_t reply_anonymity_level,
400 struct GNUNET_TIME_Absolute last_transmission,
402 const void *data,
403 size_t data_len)
404{
405 struct ClientRequest *cr = cls;
406 struct GSF_LocalClient *lc;
407 struct GNUNET_MQ_Envelope *env;
408 struct ClientPutMessage *pm;
409 const struct GSF_PendingRequestData *prd;
410
411 if (NULL == data)
412 {
413 /* local-only request, with no result, clean up. */
414 if (NULL == cr->kill_task)
416 cr);
417 return;
418 }
421 if ((prd->type != type) && (prd->type != GNUNET_BLOCK_TYPE_ANY))
422 {
423 GNUNET_break (0);
424 return;
425 }
428 ("# replies received for local clients"), 1,
429 GNUNET_NO);
430 GNUNET_assert (pr == cr->pr);
431 lc = cr->lc;
433 data_len,
435 pm->type = htonl (type);
437 pm->last_transmission = GNUNET_TIME_absolute_hton (last_transmission);
438 pm->num_transmissions = htonl (prd->num_transmissions);
439 pm->respect_offered = htonl (prd->respect_offered);
440 GNUNET_memcpy (&pm[1],
441 data,
442 data_len);
443 GNUNET_MQ_send (lc->mq,
444 env);
446 "Queued reply to query `%s' for local client\n",
447 GNUNET_h2s (&prd->query));
448 if (GNUNET_BLOCK_REPLY_OK_LAST != eval)
449 {
451 "Evaluation %d - keeping query alive\n",
452 (int) eval);
453 return;
454 }
455 if (NULL == cr->kill_task)
457 cr);
458}
459
460
469static void
470client_disconnect_cb (void *cls,
471 struct GNUNET_SERVICE_Client *client,
472 void *app_ctx)
473{
474 struct GSF_LocalClient *lc = app_ctx;
475 struct IndexStartContext *isc;
476 struct ClientRequest *cr;
477 struct ClientResponse *res;
478
479 while (NULL != (cr = lc->cr_head))
480 {
481 if (NULL != cr->kill_task)
484 }
485 while (NULL != (res = lc->res_head))
486 {
488 lc->res_tail,
489 res);
491 }
492 while (NULL != (isc = lc->isc_head))
493 {
495 lc->isc_tail,
496 isc);
498 GNUNET_free (isc);
499 }
500 GNUNET_free (lc);
501}
502
503
509static void
510age_cover_counters (void *cls)
511{
517 NULL);
518}
519
520
527void
529{
530 struct GNUNET_TIME_Relative delay;
531
533 GNUNET_LOAD_update (datastore_get_load, delay.rel_value_us);
534}
535
536
547int
548GSF_test_get_load_too_high_ (uint32_t priority)
549{
550 double ld;
551
553 if (ld < 1)
554 return GNUNET_SYSERR;
555 if (ld <= priority)
556 return GNUNET_NO;
557 return GNUNET_YES;
558}
559
560
569static int
570check_p2p_put (void *cls,
571 const struct PutMessage *put)
572{
574
575 type = ntohl (put->type);
577 {
578 GNUNET_break_op (0);
579 return GNUNET_SYSERR;
580 }
581 return GNUNET_OK;
582}
583
584
594static void
596 const struct GNUNET_PeerIdentity *peer,
597 struct GSF_ConnectedPeer *cp,
598 const struct GSF_PeerPerformanceData *ppd)
599{
600 struct GSF_PendingRequest *pr = cls;
601
602 if (GNUNET_YES !=
604 {
605#if INSANE_STATISTICS
607 gettext_noop ("# Loopback routes suppressed"), 1,
608 GNUNET_NO);
609#endif
610 return;
611 }
612 GSF_plan_add_ (cp,
613 pr);
614}
615
616
627void
628GSF_consider_forwarding (void *cls,
629 struct GSF_PendingRequest *pr,
631{
633 return; /* we're done... */
634 if (GNUNET_YES !=
636 return; /* request is not actually active, skip! */
638 pr);
639}
640
641
650static int
651check_p2p_get (void *cls,
652 const struct GetMessage *gm)
653{
654 size_t msize;
655 unsigned int bm;
656 unsigned int bits;
657 size_t bfsize;
658
659 msize = ntohs (gm->header.size);
660 bm = ntohl (gm->hash_bitmap);
661 bits = 0;
662 while (bm > 0)
663 {
664 if (1 == (bm & 1))
665 bits++;
666 bm >>= 1;
667 }
668 if (msize < sizeof(struct GetMessage) + bits * sizeof(struct
670 {
671 GNUNET_break_op (0);
672 return GNUNET_SYSERR;
673 }
674 bfsize = msize - sizeof(struct GetMessage) - bits * sizeof(struct
676 /* bfsize must be power of 2, check! */
677 if (0 != ((bfsize - 1) & bfsize))
678 {
679 GNUNET_break_op (0);
680 return GNUNET_SYSERR;
681 }
682 return GNUNET_OK;
683}
684
685
696static void
697start_p2p_processing (void *cls,
698 struct GSF_PendingRequest *pr,
700{
701 struct GSF_LocalClient *lc = cls;
702 struct GSF_PendingRequestData *prd;
703
706 return; /* we're done, 'pr' was already destroyed... */
709 "Finished database lookup for local request `%s' with result %d\n",
710 GNUNET_h2s (&prd->query),
711 result);
712 if (0 == prd->anonymity_level)
713 {
714 switch (prd->type)
715 {
718 /* the above block types MAY be available via 'cadet' */
720 "Considering cadet-based download for block\n");
722 break;
723
725 /* the above block types are in the DHT */
727 "Considering DHT-based search for block\n");
728 GSF_dht_lookup_ (pr);
729 break;
730
731 default:
732 GNUNET_break (0);
733 break;
734 }
735 }
737 pr,
738 result);
739}
740
741
750static int
752 const struct SearchMessage *sm)
753{
754 uint16_t msize;
755
756 msize = ntohs (sm->header.size) - sizeof(struct SearchMessage);
757 if (0 != msize % sizeof(struct GNUNET_HashCode))
758 {
759 GNUNET_break (0);
760 return GNUNET_SYSERR;
761 }
762 return GNUNET_OK;
763}
764
765
776static void
778 const struct SearchMessage *sm)
779{
780 static struct GNUNET_PeerIdentity all_zeros;
781 struct GSF_LocalClient *lc = cls;
782 struct ClientRequest *cr;
783 struct GSF_PendingRequestData *prd;
784 uint16_t msize;
785 unsigned int sc;
788
790 gettext_noop ("# client searches received"),
791 1,
792 GNUNET_NO);
793 msize = ntohs (sm->header.size) - sizeof(struct SearchMessage);
794 sc = msize / sizeof(struct GNUNET_HashCode);
795 type = ntohl (sm->type);
797 "Received request for `%s' of type %u from local client\n",
798 GNUNET_h2s (&sm->query),
799 (unsigned int) type);
800 cr = NULL;
801 /* detect duplicate UBLOCK requests */
804 {
805 cr = lc->cr_head;
806 while (NULL != cr)
807 {
809 /* only unify with queries that hae not yet started local processing
810 (SEARCH_MESSAGE_OPTION_CONTINUED was always set) and that have a
811 matching query and type */
812 if ((GNUNET_YES != prd->has_started) &&
813 (0 != memcmp (&prd->query,
814 &sm->query,
815 sizeof(struct GNUNET_HashCode))) &&
816 (prd->type == type))
817 break;
818 cr = cr->next;
819 }
820 }
821 if (NULL != cr)
822 {
824 "Have existing request, merging content-seen lists.\n");
826 (const struct GNUNET_HashCode *) &sm[1],
827 sc);
830 "# client searches updated (merged content seen list)"),
831 1,
832 GNUNET_NO);
833 }
834 else
835 {
837 gettext_noop ("# client searches active"),
838 1,
839 GNUNET_NO);
840 cr = GNUNET_new (struct ClientRequest);
841 cr->lc = lc;
843 lc->cr_tail,
844 cr);
846 if (0 != (SEARCH_MESSAGE_OPTION_LOOPBACK_ONLY & ntohl (sm->options)))
849 &sm->query,
850 (0 !=
851 memcmp (&sm->target,
852 &all_zeros,
853 sizeof(struct
855 ? &sm->target : NULL, NULL,
856 0 /* bf */,
857 ntohl (sm->anonymity_level),
858 0 /* priority */,
859 0 /* ttl */,
860 0 /* sender PID */,
861 0 /* origin PID */,
862 (const struct
863 GNUNET_HashCode *) &sm[1], sc,
865 cr);
866 }
867 if (0 != (SEARCH_MESSAGE_OPTION_CONTINUED & ntohl (sm->options)))
868 {
870 return;
871 }
875 lc);
876}
877
878
885static void
886handle_client_loc_sign (void *cls,
887 const struct RequestLocSignatureMessage *msg)
888{
889 struct GSF_LocalClient *lc = cls;
890 struct GNUNET_FS_Uri base;
891 struct GNUNET_FS_Uri *loc;
892 struct GNUNET_MQ_Envelope *env;
893 struct ResponseLocSignatureMessage *resp;
894
896 ntohl (msg->purpose));
897 base.type = GNUNET_FS_URI_CHK;
898 base.data.chk.chk = msg->chk;
899 base.data.chk.file_length = GNUNET_ntohll (msg->file_length);
900 loc = GNUNET_FS_uri_loc_create (&base,
901 &pk,
903 msg->expiration_time));
904 env = GNUNET_MQ_msg (resp,
908 loc->data.loc.expirationTime);
909 resp->signature = loc->data.loc.contentSignature;
910 resp->peer = loc->data.loc.peer;
912 GNUNET_MQ_send (lc->mq,
913 env);
915}
916
917
925static int
926check_client_index_start (void *cls,
927 const struct IndexStartMessage *ism)
928{
929 char *fn;
930
932 if (0 != ism->reserved)
933 {
934 GNUNET_break (0);
935 return GNUNET_SYSERR;
936 }
937 fn = GNUNET_STRINGS_filename_expand ((const char *) &ism[1]);
938 if (NULL == fn)
939 {
940 GNUNET_break (0);
941 return GNUNET_SYSERR;
942 }
943 GNUNET_free (fn);
944 return GNUNET_OK;
945}
946
947
954static void
956{
957 struct GSF_LocalClient *lc = isc->lc;
958 struct GNUNET_MQ_Envelope *env;
960
962 &isc->file_id);
965 GNUNET_MQ_send (lc->mq,
966 env);
967 GNUNET_free (isc->filename);
968 GNUNET_free (isc);
970}
971
972
980static void
981hash_for_index_val (void *cls,
982 const struct GNUNET_HashCode *res)
983{
984 struct IndexStartContext *isc = cls;
985 struct GSF_LocalClient *lc = isc->lc;
986 struct GNUNET_MQ_Envelope *env;
988
990 lc->isc_tail,
991 isc);
992 isc->fhc = NULL;
993 if ((NULL == res) ||
994 (0 != memcmp (res,
995 &isc->file_id,
996 sizeof(struct GNUNET_HashCode))))
997 {
999 _ (
1000 "Hash mismatch trying to index file `%s' which does not have hash `%s'\n"),
1001 isc->filename,
1002 GNUNET_h2s (&isc->file_id));
1003
1004 const char *emsg = "hash mismatch";
1005 const size_t msize = strlen (emsg) + 1;
1006
1008 msize,
1010 memcpy ((char*) &msg[1], emsg, msize);
1011 GNUNET_MQ_send (lc->mq,
1012 env);
1014 GNUNET_free (isc);
1015 return;
1016 }
1017 signal_index_ok (isc);
1018}
1019
1020
1027static void
1028handle_client_index_start (void *cls,
1029 const struct IndexStartMessage *ism)
1030{
1031 struct GSF_LocalClient *lc = cls;
1032 struct IndexStartContext *isc;
1033 char *fn;
1034 uint64_t dev;
1035 uint64_t ino;
1036 uint64_t mydev;
1037 uint64_t myino;
1038
1039 fn = GNUNET_STRINGS_filename_expand ((const char *) &ism[1]);
1040 GNUNET_assert (NULL != fn);
1041 dev = GNUNET_ntohll (ism->device);
1042 ino = GNUNET_ntohll (ism->inode);
1043 isc = GNUNET_new (struct IndexStartContext);
1044 isc->filename = fn;
1045 isc->file_id = ism->file_id;
1047 "Received START_INDEX message for file `%s'\n",
1048 isc->filename);
1049 isc->lc = lc;
1050 mydev = 0;
1051 myino = 0;
1052 if (((dev != 0) ||
1053 (ino != 0)) &&
1055 &mydev,
1056 &myino)) &&
1057 (dev == mydev) &&
1058 (ino == myino))
1059 {
1060 /* fast validation OK! */
1061 signal_index_ok (isc);
1062 return;
1063 }
1065 "Mismatch in file identifiers (%llu != %llu or %u != %u), need to hash.\n",
1066 (unsigned long long) ino,
1067 (unsigned long long) myino,
1068 (unsigned int) dev,
1069 (unsigned int) mydev);
1070 /* slow validation, need to hash full file (again) */
1072 lc->isc_tail,
1073 isc);
1075 isc->filename,
1078 isc);
1079 if (NULL == isc->fhc)
1080 hash_for_index_val (isc,
1081 NULL);
1082}
1083
1084
1091static void
1093 const struct GNUNET_MessageHeader *message)
1094{
1095 struct GSF_LocalClient *lc = cls;
1096
1099}
1100
1101
1108static void
1109handle_client_unindex (void *cls,
1110 const struct UnindexMessage *um)
1111{
1112 struct GSF_LocalClient *lc = cls;
1113 struct GNUNET_MQ_Envelope *env;
1114 struct GNUNET_MessageHeader *msg;
1115 int found;
1116
1117 GNUNET_break (0 == um->reserved);
1120 "Client requested unindexing of file `%s': %s\n",
1121 GNUNET_h2s (&um->file_id),
1122 found ? "found" : "not found");
1125 GNUNET_MQ_send (lc->mq,
1126 env);
1128}
1129
1130
1136static void
1137shutdown_task (void *cls)
1138{
1140 if (NULL != GSF_pils)
1141 {
1143 GSF_pils = NULL;
1144 }
1145 if (NULL != GSF_core)
1146 {
1148 GSF_core = NULL;
1149 }
1150 GSF_put_done_ ();
1151 GSF_push_done_ ();
1153 GSF_plan_done ();
1156 GNUNET_NO);
1157 GSF_dsh = NULL;
1159 GSF_dht = NULL;
1161 GSF_block_ctx = NULL;
1163 block_cfg = NULL;
1165 GSF_stats = NULL;
1166 if (NULL != cover_age_task)
1167 {
1169 cover_age_task = NULL;
1170 }
1173 datastore_get_load = NULL;
1175 GSF_rt_entry_lifetime = NULL;
1176}
1177
1178
1193static void
1194pils_pid_change_cb (void *cls,
1195 const struct GNUNET_HELLO_Parser *parser,
1196 const struct GNUNET_HashCode *hash)
1197{
1199 "My current identity is `%s'\n",
1203 "My new identity is `%s'\n",
1205}
1206
1207
1213static int
1214main_init (const struct GNUNET_CONFIGURATION_Handle *c)
1215{
1216 struct GNUNET_MQ_MessageHandler no_p2p_handlers[] = {
1218 };
1219 struct GNUNET_MQ_MessageHandler p2p_handlers[] = {
1220 GNUNET_MQ_hd_var_size (p2p_get,
1222 struct GetMessage,
1223 NULL),
1224 GNUNET_MQ_hd_var_size (p2p_put,
1226 struct PutMessage,
1227 NULL),
1228 GNUNET_MQ_hd_fixed_size (p2p_migration_stop,
1230 struct MigrationStopMessage,
1231 NULL),
1233 };
1234 int anon_p2p_off;
1235 char *keyfile;
1236 struct GNUNET_CORE_ServiceInfo service_info = {
1238 .version = { 1, 0 },
1239 .version_max = { 1, 0 },
1240 .version_min = { 1, 0 },
1241 };
1242
1243 /* this option is really only for testcases that need to disable
1244 _anonymous_ file-sharing for some reason */
1245 anon_p2p_off = (GNUNET_YES ==
1247 "fs",
1248 "DISABLE_ANON_TRANSFER")
1249 );
1250
1251 if (GNUNET_OK !=
1253 "PEER",
1254 "PRIVATE_KEY",
1255 &keyfile))
1256 {
1258 _ (
1259 "FS service is lacking HOSTKEY configuration setting. Exiting.\n"));
1261 return GNUNET_SYSERR;
1262 }
1263 if (GNUNET_SYSERR ==
1265 GNUNET_YES,
1266 &pk))
1267 {
1269 "Failed to setup peer's private key\n");
1271 GNUNET_free (keyfile);
1272 return GNUNET_SYSERR;
1273 }
1274 GNUNET_free (keyfile);
1277
1279 "I am peer %s\n",
1281 GSF_core
1283 NULL,
1284 NULL,
1287 (GNUNET_YES == anon_p2p_off)
1288 ? no_p2p_handlers
1289 : p2p_handlers,
1290 &service_info);
1291 if (NULL == GSF_core)
1292 {
1294 _ ("Failed to connect to `%s' service.\n"),
1295 "core");
1296 return GNUNET_SYSERR;
1297 }
1298 GSF_pils
1301 NULL);
1302 if (NULL == GSF_core)
1303 {
1305 _ ("Failed to connect to `%s' service.\n"),
1306 "core");
1307 return GNUNET_SYSERR;
1308 }
1312 NULL);
1316 NULL);
1317 return GNUNET_OK;
1318}
1319
1320
1328static void
1329run (void *cls,
1330 const struct GNUNET_CONFIGURATION_Handle *cfg,
1332{
1333 unsigned long long dqs;
1334
1335 GSF_cfg = cfg;
1336 if (GNUNET_OK !=
1338 "fs",
1339 "DATASTORE_QUEUE_SIZE",
1340 &dqs))
1341 {
1343 "fs",
1344 "DATASTORE_QUEUE_SIZE");
1345 dqs = 32;
1346 }
1347 GSF_datastore_queue_size = (unsigned int) dqs;
1351 if (NULL == GSF_dsh)
1352 {
1354 return;
1355 }
1360 GNUNET_assert (NULL != GSF_block_ctx);
1362 GSF_plan_init ();
1365
1366 GSF_push_init_ ();
1367 GSF_put_init_ ();
1369 GSF_dsh)) ||
1370 (GNUNET_OK != main_init (cfg)))
1371 {
1373 shutdown_task (NULL);
1374 return;
1375 }
1376}
1377
1378
1384 "fs",
1386 &run,
1389 NULL,
1390 GNUNET_MQ_hd_var_size (client_index_start,
1392 struct IndexStartMessage,
1393 NULL),
1394 GNUNET_MQ_hd_fixed_size (client_index_list_get,
1396 struct GNUNET_MessageHeader,
1397 NULL),
1398 GNUNET_MQ_hd_fixed_size (client_unindex,
1400 struct UnindexMessage,
1401 NULL),
1402 GNUNET_MQ_hd_var_size (client_start_search,
1404 struct SearchMessage,
1405 NULL),
1406 GNUNET_MQ_hd_fixed_size (client_loc_sign,
1409 NULL),
1411
1412
1413/* end of gnunet-service-fs.c */
struct GNUNET_GETOPT_CommandLineOption options[]
Definition 002.c:5
struct GNUNET_MessageHeader * msg
Definition 005.c:2
struct GNUNET_MQ_Envelope * env
Definition 005.c:1
#define HASHING_BLOCKSIZE
Blocksize to use when hashing files for indexing (blocksize for IO, not for the DBlocks).
Definition fs.h:48
#define SEARCH_MESSAGE_OPTION_LOOPBACK_ONLY
Only search the local datastore (no network)
Definition fs.h:254
#define SEARCH_MESSAGE_OPTION_CONTINUED
Request is too large to fit in 64k format.
Definition fs.h:262
@ GNUNET_FS_URI_CHK
Content-hash-key (simple file).
Definition fs_api.h:144
#define gettext_noop(String)
Definition gettext.h:74
static int start
Set if we are to start default services (including ARM).
Definition gnunet-arm.c:38
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition gnunet-arm.c:108
static unsigned int anonymity_level
Anonymity level option to use for publishing.
static char * data
The data to insert into the dht.
static struct GNUNET_TIME_Relative expiration
User supplied expiration value.
struct GNUNET_SCHEDULER_Task * shutdown_task
static char * res
Currently read line or NULL on EOF.
static uint32_t type
Type string converted to DNS type value.
static int result
Global testing status.
static struct GNUNET_FS_SearchContext * sc
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
static struct GNUNET_SCHEDULER_Task * cover_age_task
ID of our task that we use to age the cover counters.
static void handle_client_loc_sign(void *cls, const struct RequestLocSignatureMessage *msg)
Handle request to sign a LOC URI (from client).
#define COVER_AGE_FREQUENCY
How quickly do we age cover traffic? At the given time interval, remaining cover traffic counters are...
int GSF_enable_randomized_delays
Are we introducing randomized delays for better anonymity?
static struct GNUNET_LOAD_Value * datastore_get_load
Datastore 'GET' load tracking.
static int check_p2p_get(void *cls, const struct GetMessage *gm)
Check P2P "GET" request.
static void pils_pid_change_cb(void *cls, const struct GNUNET_HELLO_Parser *parser, const struct GNUNET_HashCode *hash)
Function called after GNUNET_PILS_connect has succeeded (or failed for good).
struct GNUNET_PILS_Handle * GSF_pils
Pointer to handle to the pils service (points to NULL until we've connected to it).
void GSF_update_datastore_delay_(struct GNUNET_TIME_Absolute start)
We've just now completed a datastore request.
struct GNUNET_BLOCK_Context * GSF_block_ctx
Our block context.
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.
static void start_p2p_processing(void *cls, struct GSF_PendingRequest *pr, enum GNUNET_BLOCK_ReplyEvaluationResult result)
We're done with the local lookup, now consider P2P processing (depending on request options and resul...
static void handle_client_start_search(void *cls, const struct SearchMessage *sm)
Handle GNUNET_MESSAGE_TYPE_FS_START_SEARCH-message (search request from client).
static void handle_client_unindex(void *cls, const struct UnindexMessage *um)
Handle UNINDEX-message.
static void handle_client_index_start(void *cls, const struct IndexStartMessage *ism)
Handle INDEX_START-message.
static int check_client_index_start(void *cls, const struct IndexStartMessage *ism)
Check INDEX_START-message.
static void handle_client_index_list_get(void *cls, const struct GNUNET_MessageHeader *message)
Handle INDEX_LIST_GET-message.
struct GNUNET_DHT_Handle * GSF_dht
Handle for DHT operations.
static struct GNUNET_CRYPTO_EddsaPrivateKey pk
Private key of this 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.
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...
static void * client_connect_cb(void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq)
Creates a fresh local client handle.
struct GNUNET_STATISTICS_Handle * GSF_stats
Handle for reporting statistics.
static void signal_index_ok(struct IndexStartContext *isc)
We've validated the hash of the file we're about to index.
double GSF_current_priorities
Typical priorities we're seeing from other peers right now.
unsigned int GSF_cover_query_count
How many query messages have we received 'recently' that have not yet been claimed as cover traffic?
const struct GNUNET_CONFIGURATION_Handle * GSF_cfg
Our configuration.
static int check_p2p_put(void *cls, const struct PutMessage *put)
Check P2P "PUT" message.
void GSF_consider_forwarding(void *cls, struct GSF_PendingRequest *pr, enum GNUNET_BLOCK_ReplyEvaluationResult result)
Function to be called after we're done processing replies from the local lookup.
static void age_cover_counters(void *cls)
Task that periodically ages our cover traffic statistics.
struct GNUNET_PeerIdentity GSF_my_id
Identity of this peer.
struct GNUNET_CORE_Handle * GSF_core
Pointer to handle to the core service (points to NULL until we've connected to it).
unsigned int GSF_cover_content_count
How many content messages have we received 'recently' that have not yet been claimed as cover traffic...
static void client_response_handler(void *cls, enum GNUNET_BLOCK_ReplyEvaluationResult 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.
static void client_disconnect_cb(void *cls, struct GNUNET_SERVICE_Client *client, void *app_ctx)
A client disconnected from us.
struct GNUNET_TIME_Relative GSF_avg_latency
Running average of the observed latency to other peers (round trip).
static int main_init(const struct GNUNET_CONFIGURATION_Handle *c)
Process fs requests.
struct GNUNET_LOAD_Value * GSF_rt_entry_lifetime
How long do requests typically stay in the routing table?
struct GNUNET_DATASTORE_Handle * GSF_dsh
Our connection to the datastore.
#define FS_DHT_HT_SIZE
Size for the hash map for DHT requests from the FS service.
static void client_request_destroy(void *cls)
Free the given client request.
unsigned int GSF_datastore_queue_size
Size of the datastore queue we assume for common requests.
static int check_client_start_search(void *cls, const struct SearchMessage *sm)
Check GNUNET_MESSAGE_TYPE_FS_START_SEARCH-message (search request from client).
static void run(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_SERVICE_Handle *service)
Process fs requests.
static struct GNUNET_CONFIGURATION_Handle * block_cfg
Configuration for block library.
#define DATASTORE_LOAD_AUTODECLINE
At what frequency should our datastore load decrease automatically (since if we don't use it,...
void GSF_cadet_stop_server(void)
Shutdown subsystem for non-anonymous file-sharing.
void GSF_cadet_start_server(void)
Initialize subsystem for non-anonymous file-sharing.
void GSF_connected_peer_done_()
Shutdown peer management subsystem.
void GSF_peer_disconnect_handler(void *cls, const struct GNUNET_PeerIdentity *peer, void *internal_cls)
A peer disconnected from us.
void GSF_iterate_connected_peers_(GSF_ConnectedPeerIterator it, void *it_cls)
Iterate over all connected peers.
void GSF_connected_peer_init_()
Initialize peer management subsystem.
void * GSF_peer_connect_handler(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq, enum GNUNET_CORE_PeerClass class)
A peer connected to us.
int GNUNET_FS_indexing_do_unindex(const struct GNUNET_HashCode *fid)
Remove a file from the index.
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.
int GNUNET_FS_indexing_init(const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_DATASTORE_Handle *d)
Initialize the indexing submodule.
void GNUNET_FS_indexing_send_list(struct GNUNET_MQ_Handle *mq)
Transmit information about indexed files to mq.
void GNUNET_FS_indexing_done()
Shutdown the module.
void GSF_plan_init()
Initialize plan subsystem.
void GSF_plan_add_(struct GSF_ConnectedPeer *cp, struct GSF_PendingRequest *pr)
Create a new query plan entry.
void GSF_plan_done()
Shutdown plan subsystem.
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?
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 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.
void GSF_cadet_lookup_(struct GSF_PendingRequest *pr)
Consider downloading via cadet (if possible)
void GSF_dht_lookup_(struct GSF_PendingRequest *pr)
Consider looking up the data in the DHT (anonymity-level permitting).
void GSF_local_lookup_(struct GSF_PendingRequest *pr, GSF_LocalLookupContinuation cont, void *cont_cls)
Look up the request in the local datastore.
void GSF_pending_request_init_()
Setup the subsystem.
struct GSF_PendingRequestData * GSF_pending_request_get_data_(struct GSF_PendingRequest *pr)
Obtain the public data associated with a pending request.
int GSF_pending_request_test_active_(struct GSF_PendingRequest *pr)
Check if the given request is still active.
void GSF_pending_request_done_()
Shutdown the subsystem.
void GSF_pending_request_cancel_(struct GSF_PendingRequest *pr, int full_cleanup)
Explicitly cancel a pending request.
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.
GSF_PendingRequestOptions
Options for pending requests (bits to be ORed).
@ GSF_PRO_LOCAL_REQUEST
Option mask for typical local requests.
@ GSF_PRO_LOCAL_ONLY
Request must only be processed locally.
void GSF_push_init_()
Setup the module.
void GSF_push_done_()
Shutdown the module.
void GSF_put_init_()
Setup the module.
void GSF_put_done_()
Shutdown the module.
static struct GNUNET_TRANSPORT_PluginMonitor * pm
Handle if we are monitoring plugin session activity.
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_DBLOCK
Data block (leaf) in the CHK tree.
@ GNUNET_BLOCK_TYPE_FS_ONDEMAND
Type of a block representing a block to be encoded on demand from disk.
@ GNUNET_BLOCK_TYPE_FS_IBLOCK
Inner block in the CHK tree.
@ GNUNET_BLOCK_TYPE_ANY
Identifier for any block.
@ GNUNET_BLOCK_TYPE_FS_UBLOCK
Type of a block representing any type of search result (universal).
struct GNUNET_PILS_Handle * GNUNET_PILS_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_PILS_PidChangeCallback pid_change_cb, void *cls)
Connect to the PILS service.
Definition pils_api.c:367
void GNUNET_PILS_disconnect(struct GNUNET_PILS_Handle *handle)
Disconnect from the PILS service.
Definition pils_api.c:390
#define GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT
Signature by which a peer affirms that it is providing a certain bit of content for use in LOCation U...
GNUNET_BLOCK_ReplyEvaluationResult
Possible ways for how a block may relate to a query.
void GNUNET_BLOCK_context_destroy(struct GNUNET_BLOCK_Context *ctx)
Destroy the block context.
Definition block.c:158
struct GNUNET_BLOCK_Context * GNUNET_BLOCK_context_create(const struct GNUNET_CONFIGURATION_Handle *cfg)
Create a block context.
Definition block.c:140
@ GNUNET_BLOCK_REPLY_OK_LAST
Last possible valid result.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create(const struct GNUNET_OS_ProjectData *pd)
Create a new configuration object.
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_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
enum GNUNET_GenericReturnValue 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.
enum GNUNET_GenericReturnValue 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".
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, struct GNUNET_CORE_ServiceInfo *service_info)
Connect to the core service.
Definition core_api.c:698
void GNUNET_CORE_disconnect(struct GNUNET_CORE_Handle *handle)
Disconnect from the core service.
Definition core_api.c:744
@ GNUNET_CORE_SERVICE_FS
Identifier for fs (file sharing) service.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_eddsa_key_from_file(const char *filename, int do_create, struct GNUNET_CRYPTO_EddsaPrivateKey *pkey)
Create a new private key by reading it from a file.
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:201
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.
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:1030
void GNUNET_DHT_disconnect(struct GNUNET_DHT_Handle *handle)
Shutdown connection with the DHT service.
Definition dht_api.c:1053
enum GNUNET_GenericReturnValue 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:254
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
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:869
void GNUNET_FS_uri_destroy(struct GNUNET_FS_Uri *uri)
Free URI.
Definition fs_uri.c:677
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.
const struct GNUNET_PeerIdentity * GNUNET_HELLO_parser_get_id(const struct GNUNET_HELLO_Parser *parser)
Get the PeerIdentity for this builder.
Definition hello-uri.c:353
#define GNUNET_log(kind,...)
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
void GNUNET_CRYPTO_hash_file_cancel(struct GNUNET_CRYPTO_FileHashContext *fhc)
Cancel a file hashing operation.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
@ GNUNET_SCHEDULER_PRIORITY_IDLE
Run when otherwise idle.
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_NO
@ GNUNET_SYSERR
struct GNUNET_LOAD_Value * GNUNET_LOAD_value_init(struct GNUNET_TIME_Relative autodecline)
Create a new load value.
Definition load.c:124
void GNUNET_LOAD_update(struct GNUNET_LOAD_Value *load, uint64_t data)
Update the current load.
Definition load.c:236
double GNUNET_LOAD_get_load(struct GNUNET_LOAD_Value *load)
Get the current load.
Definition load.c:200
#define GNUNET_LOAD_value_free(lv)
Free a load value.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
const char * GNUNET_i2s_full(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
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_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
@ GNUNET_ERROR_TYPE_INFO
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
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:305
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_check_zero_termination(m)
Insert code for a "check_" function that verifies that a given variable-length message received over ...
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_gnunet(void)
Return default project data used by 'libgnunetutil' for GNUnet.
#define GNUNET_MESSAGE_TYPE_FS_INDEX_LIST_GET
Request from client for list of indexed files.
#define GNUNET_MESSAGE_TYPE_FS_UNINDEX_OK
Reply to client indicating unindex receipt.
#define GNUNET_MESSAGE_TYPE_FS_START_SEARCH
Client asks FS service to start a (keyword) search.
#define GNUNET_MESSAGE_TYPE_FS_INDEX_START
Message sent by fs client to start indexing.
#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).
#define GNUNET_MESSAGE_TYPE_FS_MIGRATION_STOP
Peer asks us to stop migrating content towards it for a while.
#define GNUNET_MESSAGE_TYPE_FS_UNINDEX
Request from client to unindex a file.
#define GNUNET_MESSAGE_TYPE_FS_INDEX_START_FAILED
Response to a request for start indexing that refuses.
#define GNUNET_MESSAGE_TYPE_FS_REQUEST_LOC_SIGN
Message sent by fs client to request LOC signature.
#define GNUNET_MESSAGE_TYPE_FS_REQUEST_LOC_SIGNATURE
Reply sent by fs service with LOC signature.
#define GNUNET_MESSAGE_TYPE_FS_INDEX_START_OK
Affirmative response to a request for start indexing.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition scheduler.c:567
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,...
Definition scheduler.c:1339
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition scheduler.c:980
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:1304
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:1277
#define GNUNET_SERVICE_MAIN(pd, service_name, service_options, init_cb, connect_cb, disconnect_cb, cls,...)
Creates the "main" function for a GNUnet service.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition service.c:2433
@ GNUNET_SERVICE_OPTION_NONE
Use defaults.
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
char * GNUNET_STRINGS_filename_expand(const char *fil)
Complete filename (a la shell) from abbrevition.
Definition strings.c:520
#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:438
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
Definition time.c:741
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition time.c:640
#define _(String)
GNU gettext support macro.
Definition platform.h:179
static struct GNUNET_MQ_Handle * mq
Our connection to the resolver service, created on-demand, but then persists until error or shutdown.
Response from FS service with a result for a previous FS search.
Definition fs.h:356
Doubly-linked list of requests we are performing on behalf of the same client.
struct ClientRequest * prev
This is a doubly-linked list.
struct GNUNET_SCHEDULER_Task * kill_task
Task scheduled to destroy the request.
struct ClientRequest * next
This is a doubly-linked list.
struct GSF_LocalClient * lc
Client list this request belongs to.
struct GSF_PendingRequest * pr
Request this entry represents.
Replies to be transmitted to the client.
size_t msize
Number of bytes in the response.
struct ClientResponse * prev
This is a doubly-linked list.
struct GSF_LocalClient * lc
Client list entry this response belongs to.
struct ClientResponse * next
This is a doubly-linked list.
Handle to an initialized block library.
Definition block.c:55
Context for the core service connection.
Definition core_api.c:78
Gnunet service info - identifying compatibility with a range of version of a service communicating ov...
enum GNUNET_CORE_Service service
Identifier of the service on top of CORE.
Private ECC key encoded for transmission.
Context used when hashing a file.
Handle to the datastore service.
Connection to the DHT service.
Definition dht_api.c:235
A Universal Resource Identifier (URI), opaque.
Definition fs_api.h:167
union GNUNET_FS_Uri::@49 data
struct Location loc
Information needed to retrieve a file including signed location (identity of a peer) of the content.
Definition fs_api.h:218
Context for parsing HELLOs.
Definition hello-uri.c:232
A 512-bit hashcode.
Values we track for load calculations.
Definition load.c:36
Handle to a message queue.
Definition mq.c:87
Message handler for a specific message type.
Header for all communications.
A handle for the PILS service.
Definition pils_api.c:82
The identity of the host (wraps the signing key of the peer).
struct GNUNET_CRYPTO_EddsaPublicKey public_key
Entry in list of pending tasks.
Definition scheduler.c:136
Handle to a client that is connected to a service.
Definition service.c:249
Handle to a service.
Definition service.c:116
Handle for the service.
Time for absolute times used by GNUnet, in microseconds.
Time for relative time used by GNUnet, in microseconds.
A local client.
struct IndexStartContext * isc_head
This is a doubly linked list.
struct ClientRequest * cr_head
Head of list of requests performed on behalf of this client right now.
struct ClientResponse * res_tail
Tail of linked list of responses.
struct ClientRequest * cr_tail
Tail of list of requests performed on behalf of this client right now.
struct GNUNET_MQ_Handle * mq
Queue for sending replies.
struct IndexStartContext * isc_tail
This is a doubly linked list.
struct ClientResponse * res_head
Head of linked list of responses.
struct GNUNET_SERVICE_Client * client
ID of the client.
Performance data kept for a peer.
Public data (in the sense of not encapsulated within 'gnunet-service-fs_pr', not in the sense of netw...
int has_started
Has this request been started yet (local/p2p operations)? Or are we still constructing it?
uint32_t respect_offered
How much respect did we (in total) offer for this request so far (estimate, because we might have the...
enum GNUNET_BLOCK_Type type
Type of the requested block.
uint32_t num_transmissions
Counter for how often this request has been transmitted (estimate, because we might have the same req...
uint32_t anonymity_level
Desired anonymity level.
struct GNUNET_HashCode query
Primary query hash for this request.
An active request.
Message to the datastore service asking about specific content.
Definition datastore.h:141
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_DATASTORE_GET.
Definition datastore.h:145
uint32_t hash_bitmap
Which of the optional hash codes are present at the end of the message? See GET_MESSAGE_BIT_xx consta...
Information we track while handling an index start request from a client.
struct GNUNET_CRYPTO_FileHashContext * fhc
Context for hashing of the file.
struct GNUNET_HashCode file_id
Hash of the contents of the file.
struct IndexStartContext * next
This is a doubly linked list.
struct IndexStartContext * prev
This is a doubly linked list.
struct GSF_LocalClient * lc
Context for transmitting confirmation to client.
char * filename
Name of the indexed file.
Message sent from a GNUnet (fs) publishing activity to the gnunet-fs-service to initiate indexing of ...
Definition fs.h:153
uint64_t inode
Inode of the file on the given device, as seen by the client ("st_ino" field from "struct stat").
Definition fs.h:179
struct GNUNET_HashCode file_id
Hash of the file that we would like to index.
Definition fs.h:184
uint32_t reserved
For alignment.
Definition fs.h:162
uint64_t device
ID of device containing the file, as seen by the client.
Definition fs.h:171
struct GNUNET_TIME_Absolute expirationTime
Time when this location URI expires.
Definition fs_api.h:127
struct GNUNET_CRYPTO_EddsaSignature contentSignature
Signature over the GNUNET_EC_FileIdentifier, peer identity and expiration time.
Definition fs_api.h:133
struct GNUNET_PeerIdentity peer
Identity of the peer sharing the file.
Definition fs_api.h:122
Message send by a peer that wants to be excluded from migration for a while.
Response from FS service with a result for a previous FS search.
Definition fs.h:330
uint32_t type
Type of the block (in big endian).
Definition fs.h:339
Message sent from a GNUnet (fs) publishing activity to sign a LOC URI.
Definition fs.h:76
Message sent from the service with the signed LOC URI.
Definition fs.h:109
struct GNUNET_CRYPTO_EddsaSignature signature
The requested signature.
Definition fs.h:130
struct GNUNET_PeerIdentity peer
Identity of the peer sharing the file.
Definition fs.h:135
uint32_t purpose
Purpose of the generated signature.
Definition fs.h:120
struct GNUNET_TIME_AbsoluteNBO expiration_time
Expiration time that was actually used (rounded!).
Definition fs.h:125
Message sent from a GNUnet (fs) search activity to the gnunet-service-fs to start a search.
Definition fs.h:270
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:307
uint32_t type
Type of the content that we're looking for.
Definition fs.h:290
struct GNUNET_HashCode query
Hash of the public key for UBLOCKs; Hash of the CHK-encoded block for DBLOCKS and IBLOCKS.
Definition fs.h:313
struct GNUNET_MessageHeader header
Message type will be GNUNET_MESSAGE_TYPE_FS_START_SEARCH.
Definition fs.h:274
uint32_t options
Bitmask with options.
Definition fs.h:285
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

◆ INSANE_STATISTICS

#define INSANE_STATISTICS   GNUNET_NO

Collect an instance number of statistics? May cause excessive IPC.

Definition at line 66 of file gnunet-service-fs.c.

Function Documentation

◆ client_connect_cb()

static void * client_connect_cb ( void *  cls,
struct GNUNET_SERVICE_Client client,
struct GNUNET_MQ_Handle mq 
)
static

Creates a fresh local client handle.

Parameters
clsNULL
clienthandle of the client
mqmessage queue for client
Returns
handle to local client entry

Definition at line 339 of file gnunet-service-fs.c.

342{
343 struct GSF_LocalClient *pos;
344
345 pos = GNUNET_new (struct GSF_LocalClient);
346 pos->client = client;
347 pos->mq = mq;
348 return pos;
349}

References GSF_LocalClient::client, GNUNET_new, mq, and GSF_LocalClient::mq.

◆ client_request_destroy()

static void client_request_destroy ( void *  cls)
static

Free the given client request.

Parameters
clsthe client request to free

Definition at line 358 of file gnunet-service-fs.c.

359{
360 struct ClientRequest *cr = cls;
361 struct GSF_LocalClient *lc = cr->lc;
362
363 cr->kill_task = NULL;
365 lc->cr_tail,
366 cr);
368 GNUNET_YES);
370 gettext_noop ("# client searches active"),
371 -1,
372 GNUNET_NO);
373 GNUNET_free (cr);
374}

References GSF_LocalClient::cr_head, GSF_LocalClient::cr_tail, gettext_noop, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_YES, GSF_pending_request_cancel_(), GSF_stats, ClientRequest::kill_task, ClientRequest::lc, and ClientRequest::pr.

Referenced by client_disconnect_cb(), and client_response_handler().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ client_response_handler()

static void client_response_handler ( void *  cls,
enum GNUNET_BLOCK_ReplyEvaluationResult  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 
)
static

Handle a reply to a pending request.

Also called if a request expires (then with data == NULL). The handler may be called many times (depending on the request type), but will not be called during or after a call to #GSF_pending_request_cancel() and will also not be called anymore after a call signalling expiration.

Parameters
clsuser-specified closure
evalevaluation of the result
prhandle to the original pending request
reply_anonymity_levelanonymity level for the reply, UINT32_MAX for "unknown"
expirationwhen does data expire?
last_transmissionwhen was the last time we've tried to download this block? (FOREVER if unknown)
typetype of the block
dataresponse data, NULL on request expiration
data_lennumber of bytes in data

Definition at line 396 of file gnunet-service-fs.c.

405{
406 struct ClientRequest *cr = cls;
407 struct GSF_LocalClient *lc;
408 struct GNUNET_MQ_Envelope *env;
409 struct ClientPutMessage *pm;
410 const struct GSF_PendingRequestData *prd;
411
412 if (NULL == data)
413 {
414 /* local-only request, with no result, clean up. */
415 if (NULL == cr->kill_task)
417 cr);
418 return;
419 }
422 if ((prd->type != type) && (prd->type != GNUNET_BLOCK_TYPE_ANY))
423 {
424 GNUNET_break (0);
425 return;
426 }
429 ("# replies received for local clients"), 1,
430 GNUNET_NO);
431 GNUNET_assert (pr == cr->pr);
432 lc = cr->lc;
434 data_len,
436 pm->type = htonl (type);
438 pm->last_transmission = GNUNET_TIME_absolute_hton (last_transmission);
439 pm->num_transmissions = htonl (prd->num_transmissions);
440 pm->respect_offered = htonl (prd->respect_offered);
441 GNUNET_memcpy (&pm[1],
442 data,
443 data_len);
444 GNUNET_MQ_send (lc->mq,
445 env);
447 "Queued reply to query `%s' for local client\n",
448 GNUNET_h2s (&prd->query));
449 if (GNUNET_BLOCK_REPLY_OK_LAST != eval)
450 {
452 "Evaluation %d - keeping query alive\n",
453 (int) eval);
454 return;
455 }
456 if (NULL == cr->kill_task)
458 cr);
459}

References client_request_destroy(), data, env, expiration, gettext_noop, GNUNET_assert, GNUNET_BLOCK_REPLY_OK_LAST, GNUNET_BLOCK_TYPE_ANY, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_FS_PUT, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_NO, GNUNET_SCHEDULER_add_now(), GNUNET_STATISTICS_update(), GNUNET_TIME_absolute_hton(), GSF_pending_request_get_data_(), GSF_stats, ClientRequest::kill_task, ClientRequest::lc, GSF_LocalClient::mq, GSF_PendingRequestData::num_transmissions, pm, ClientRequest::pr, GSF_PendingRequestData::query, GSF_PendingRequestData::respect_offered, type, and GSF_PendingRequestData::type.

Referenced by handle_client_start_search().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ client_disconnect_cb()

static void client_disconnect_cb ( void *  cls,
struct GNUNET_SERVICE_Client client,
void *  app_ctx 
)
static

A client disconnected from us.

Tear down the local client record.

Parameters
clsunused
clienthandle of the client
app_ctxthe struct GSF_LocalClient

Definition at line 471 of file gnunet-service-fs.c.

474{
475 struct GSF_LocalClient *lc = app_ctx;
476 struct IndexStartContext *isc;
477 struct ClientRequest *cr;
478 struct ClientResponse *res;
479
480 while (NULL != (cr = lc->cr_head))
481 {
482 if (NULL != cr->kill_task)
485 }
486 while (NULL != (res = lc->res_head))
487 {
489 lc->res_tail,
490 res);
492 }
493 while (NULL != (isc = lc->isc_head))
494 {
496 lc->isc_tail,
497 isc);
499 GNUNET_free (isc);
500 }
501 GNUNET_free (lc);
502}

References client_request_destroy(), GSF_LocalClient::cr_head, IndexStartContext::fhc, GNUNET_CONTAINER_DLL_remove, GNUNET_CRYPTO_hash_file_cancel(), GNUNET_free, GNUNET_SCHEDULER_cancel(), GSF_LocalClient::isc_head, GSF_LocalClient::isc_tail, ClientRequest::kill_task, ClientResponse::lc, res, GSF_LocalClient::res_head, and GSF_LocalClient::res_tail.

Here is the call graph for this function:

◆ age_cover_counters()

static void age_cover_counters ( void *  cls)
static

Task that periodically ages our cover traffic statistics.

Parameters
clsunused closure

Definition at line 511 of file gnunet-service-fs.c.

References age_cover_counters(), COVER_AGE_FREQUENCY, cover_age_task, GNUNET_SCHEDULER_add_delayed(), GSF_cover_content_count, and GSF_cover_query_count.

Referenced by age_cover_counters(), and main_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GSF_update_datastore_delay_()

void GSF_update_datastore_delay_ ( struct GNUNET_TIME_Absolute  start)

We've just now completed a datastore request.

Update our datastore load calculations.

Parameters
starttime when the datastore request was issued

Definition at line 529 of file gnunet-service-fs.c.

530{
531 struct GNUNET_TIME_Relative delay;
532
534 GNUNET_LOAD_update (datastore_get_load, delay.rel_value_us);
535}

References datastore_get_load, GNUNET_LOAD_update(), GNUNET_TIME_absolute_get_duration(), GNUNET_TIME_Relative::rel_value_us, and start.

Referenced by process_local_reply().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GSF_test_get_load_too_high_()

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.

Parameters
prioritypriority of the request (used as a reference point to compare with the load)
Returns
GNUNET_YES if the load is too high to do anything (load high) GNUNET_NO to process normally (load normal) GNUNET_SYSERR to process for free (load low)

Definition at line 549 of file gnunet-service-fs.c.

550{
551 double ld;
552
554 if (ld < 1)
555 return GNUNET_SYSERR;
556 if (ld <= priority)
557 return GNUNET_NO;
558 return GNUNET_YES;
559}

References datastore_get_load, GNUNET_LOAD_get_load(), GNUNET_NO, GNUNET_SYSERR, and GNUNET_YES.

Referenced by bound_priority(), and process_local_reply().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_p2p_put()

static int check_p2p_put ( void *  cls,
const struct PutMessage put 
)
static

Check P2P "PUT" message.

Parameters
clsclosure with the struct GSF_ConnectedPeer
putthe actual message
Returns
GNUNET_OK to keep the connection open, GNUNET_SYSERR to close it (signal serious error)

Definition at line 571 of file gnunet-service-fs.c.

573{
575
576 type = ntohl (put->type);
578 {
579 GNUNET_break_op (0);
580 return GNUNET_SYSERR;
581 }
582 return GNUNET_OK;
583}

References GNUNET_BLOCK_TYPE_FS_ONDEMAND, GNUNET_break_op, GNUNET_OK, GNUNET_SYSERR, type, and PutMessage::type.

◆ consider_request_for_forwarding()

static void consider_request_for_forwarding ( void *  cls,
const struct GNUNET_PeerIdentity peer,
struct GSF_ConnectedPeer cp,
const struct GSF_PeerPerformanceData ppd 
)
static

We have a new request, consider forwarding it to the given peer.

Parameters
clsthe struct GSF_PendingRequest
peeridentity of the peer
cphandle to the connected peer record
ppdpeer performance data

Definition at line 596 of file gnunet-service-fs.c.

600{
601 struct GSF_PendingRequest *pr = cls;
602
603 if (GNUNET_YES !=
605 {
606#if INSANE_STATISTICS
608 gettext_noop ("# Loopback routes suppressed"), 1,
609 GNUNET_NO);
610#endif
611 return;
612 }
613 GSF_plan_add_ (cp,
614 pr);
615}

References gettext_noop, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_YES, GSF_pending_request_test_target_(), GSF_plan_add_(), and GSF_stats.

Referenced by GSF_consider_forwarding().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GSF_consider_forwarding()

void GSF_consider_forwarding ( void *  cls,
struct GSF_PendingRequest pr,
enum GNUNET_BLOCK_ReplyEvaluationResult  result 
)

Function to be called after we're done processing replies from the local lookup.

If the result status code indicates that there may be more replies, plan forwarding the request.

Parameters
clsclosure (NULL)
prthe pending request we were processing
resultfinal datastore lookup result

Definition at line 629 of file gnunet-service-fs.c.

632{
634 return; /* we're done... */
635 if (GNUNET_YES !=
637 return; /* request is not actually active, skip! */
639 pr);
640}

References consider_request_for_forwarding(), GNUNET_BLOCK_REPLY_OK_LAST, GNUNET_YES, GSF_iterate_connected_peers_(), GSF_pending_request_test_active_(), and result.

Referenced by handle_p2p_get(), and start_p2p_processing().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_p2p_get()

static int check_p2p_get ( void *  cls,
const struct GetMessage gm 
)
static

Check P2P "GET" request.

Parameters
clsclosure
gmthe actual message
Returns
GNUNET_OK to keep the connection open, GNUNET_SYSERR to close it (signal serious error)

Definition at line 652 of file gnunet-service-fs.c.

654{
655 size_t msize;
656 unsigned int bm;
657 unsigned int bits;
658 size_t bfsize;
659
660 msize = ntohs (gm->header.size);
661 bm = ntohl (gm->hash_bitmap);
662 bits = 0;
663 while (bm > 0)
664 {
665 if (1 == (bm & 1))
666 bits++;
667 bm >>= 1;
668 }
669 if (msize < sizeof(struct GetMessage) + bits * sizeof(struct
671 {
672 GNUNET_break_op (0);
673 return GNUNET_SYSERR;
674 }
675 bfsize = msize - sizeof(struct GetMessage) - bits * sizeof(struct
677 /* bfsize must be power of 2, check! */
678 if (0 != ((bfsize - 1) & bfsize))
679 {
680 GNUNET_break_op (0);
681 return GNUNET_SYSERR;
682 }
683 return GNUNET_OK;
684}

References GNUNET_break_op, GNUNET_OK, GNUNET_SYSERR, GetMessage::hash_bitmap, GetMessage::header, and GNUNET_MessageHeader::size.

◆ start_p2p_processing()

static void start_p2p_processing ( void *  cls,
struct GSF_PendingRequest pr,
enum GNUNET_BLOCK_ReplyEvaluationResult  result 
)
static

We're done with the local lookup, now consider P2P processing (depending on request options and result status).

Also signal that we can now receive more request information from the client.

Parameters
clsthe client doing the request (struct GSF_LocalClient)
prthe pending request we were processing
resultfinal datastore lookup result

Definition at line 698 of file gnunet-service-fs.c.

701{
702 struct GSF_LocalClient *lc = cls;
703 struct GSF_PendingRequestData *prd;
704
707 return; /* we're done, 'pr' was already destroyed... */
710 "Finished database lookup for local request `%s' with result %d\n",
711 GNUNET_h2s (&prd->query),
712 result);
713 if (0 == prd->anonymity_level)
714 {
715 switch (prd->type)
716 {
719 /* the above block types MAY be available via 'cadet' */
721 "Considering cadet-based download for block\n");
723 break;
724
726 /* the above block types are in the DHT */
728 "Considering DHT-based search for block\n");
729 GSF_dht_lookup_ (pr);
730 break;
731
732 default:
733 GNUNET_break (0);
734 break;
735 }
736 }
738 pr,
739 result);
740}

References GSF_PendingRequestData::anonymity_level, GSF_LocalClient::client, GNUNET_BLOCK_REPLY_OK_LAST, GNUNET_BLOCK_TYPE_FS_DBLOCK, GNUNET_BLOCK_TYPE_FS_IBLOCK, GNUNET_BLOCK_TYPE_FS_UBLOCK, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_SERVICE_client_continue(), GSF_cadet_lookup_(), GSF_consider_forwarding(), GSF_dht_lookup_(), GSF_pending_request_get_data_(), GSF_PendingRequestData::query, result, and GSF_PendingRequestData::type.

Referenced by handle_client_start_search().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_client_start_search()

static int check_client_start_search ( void *  cls,
const struct SearchMessage sm 
)
static

Check GNUNET_MESSAGE_TYPE_FS_START_SEARCH-message (search request from client).

Parameters
clsidentification of the client
smthe actual message
Returns
GNUNET_OK if sm is well-formed

Definition at line 752 of file gnunet-service-fs.c.

754{
755 uint16_t msize;
756
757 msize = ntohs (sm->header.size) - sizeof(struct SearchMessage);
758 if (0 != msize % sizeof(struct GNUNET_HashCode))
759 {
760 GNUNET_break (0);
761 return GNUNET_SYSERR;
762 }
763 return GNUNET_OK;
764}

References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, SearchMessage::header, and GNUNET_MessageHeader::size.

◆ handle_client_start_search()

static void handle_client_start_search ( void *  cls,
const struct SearchMessage sm 
)
static

Handle GNUNET_MESSAGE_TYPE_FS_START_SEARCH-message (search request from client).

Responsible for creating the request entry itself and setting up reply callback and cancellation on client disconnect.

Parameters
clsidentification of the client
smthe actual message

Definition at line 778 of file gnunet-service-fs.c.

780{
781 static struct GNUNET_PeerIdentity all_zeros;
782 struct GSF_LocalClient *lc = cls;
783 struct ClientRequest *cr;
784 struct GSF_PendingRequestData *prd;
785 uint16_t msize;
786 unsigned int sc;
789
791 gettext_noop ("# client searches received"),
792 1,
793 GNUNET_NO);
794 msize = ntohs (sm->header.size) - sizeof(struct SearchMessage);
795 sc = msize / sizeof(struct GNUNET_HashCode);
796 type = ntohl (sm->type);
798 "Received request for `%s' of type %u from local client\n",
799 GNUNET_h2s (&sm->query),
800 (unsigned int) type);
801 cr = NULL;
802 /* detect duplicate UBLOCK requests */
805 {
806 cr = lc->cr_head;
807 while (NULL != cr)
808 {
810 /* only unify with queries that hae not yet started local processing
811 (SEARCH_MESSAGE_OPTION_CONTINUED was always set) and that have a
812 matching query and type */
813 if ((GNUNET_YES != prd->has_started) &&
814 (0 != memcmp (&prd->query,
815 &sm->query,
816 sizeof(struct GNUNET_HashCode))) &&
817 (prd->type == type))
818 break;
819 cr = cr->next;
820 }
821 }
822 if (NULL != cr)
823 {
825 "Have existing request, merging content-seen lists.\n");
827 (const struct GNUNET_HashCode *) &sm[1],
828 sc);
831 "# client searches updated (merged content seen list)"),
832 1,
833 GNUNET_NO);
834 }
835 else
836 {
838 gettext_noop ("# client searches active"),
839 1,
840 GNUNET_NO);
841 cr = GNUNET_new (struct ClientRequest);
842 cr->lc = lc;
844 lc->cr_tail,
845 cr);
847 if (0 != (SEARCH_MESSAGE_OPTION_LOOPBACK_ONLY & ntohl (sm->options)))
850 &sm->query,
851 (0 !=
852 memcmp (&sm->target,
853 &all_zeros,
854 sizeof(struct
856 ? &sm->target : NULL, NULL,
857 0 /* bf */,
858 ntohl (sm->anonymity_level),
859 0 /* priority */,
860 0 /* ttl */,
861 0 /* sender PID */,
862 0 /* origin PID */,
863 (const struct
864 GNUNET_HashCode *) &sm[1], sc,
866 cr);
867 }
868 if (0 != (SEARCH_MESSAGE_OPTION_CONTINUED & ntohl (sm->options)))
869 {
871 return;
872 }
876 lc);
877}

References SearchMessage::anonymity_level, GSF_LocalClient::client, client_response_handler(), GSF_LocalClient::cr_head, GSF_LocalClient::cr_tail, gettext_noop, GNUNET_BLOCK_TYPE_ANY, GNUNET_BLOCK_TYPE_FS_UBLOCK, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_new, GNUNET_NO, GNUNET_SERVICE_client_continue(), GNUNET_STATISTICS_update(), GNUNET_YES, GSF_local_lookup_(), GSF_pending_request_create_(), GSF_pending_request_get_data_(), GSF_pending_request_update_(), GSF_PRO_LOCAL_ONLY, GSF_PRO_LOCAL_REQUEST, GSF_stats, GSF_PendingRequestData::has_started, SearchMessage::header, ClientRequest::lc, ClientRequest::next, options, SearchMessage::options, ClientRequest::pr, SearchMessage::query, GSF_PendingRequestData::query, sc, SEARCH_MESSAGE_OPTION_CONTINUED, SEARCH_MESSAGE_OPTION_LOOPBACK_ONLY, GNUNET_MessageHeader::size, start_p2p_processing(), SearchMessage::target, type, SearchMessage::type, and GSF_PendingRequestData::type.

Here is the call graph for this function:

◆ handle_client_loc_sign()

static void handle_client_loc_sign ( void *  cls,
const struct RequestLocSignatureMessage msg 
)
static

Handle request to sign a LOC URI (from client).

Parameters
clsidentification of the client
msgthe actual message

Definition at line 887 of file gnunet-service-fs.c.

889{
890 struct GSF_LocalClient *lc = cls;
891 struct GNUNET_FS_Uri base;
892 struct GNUNET_FS_Uri *loc;
893 struct GNUNET_MQ_Envelope *env;
894 struct ResponseLocSignatureMessage *resp;
895
897 ntohl (msg->purpose));
898 base.type = GNUNET_FS_URI_CHK;
899 base.data.chk.chk = msg->chk;
900 base.data.chk.file_length = GNUNET_ntohll (msg->file_length);
901 loc = GNUNET_FS_uri_loc_create (&base,
902 &pk,
904 msg->expiration_time));
905 env = GNUNET_MQ_msg (resp,
909 loc->data.loc.expirationTime);
910 resp->signature = loc->data.loc.contentSignature;
911 resp->peer = loc->data.loc.peer;
913 GNUNET_MQ_send (lc->mq,
914 env);
916}

References FileIdentifier::chk, GNUNET_FS_Uri::chk, GSF_LocalClient::client, Location::contentSignature, GNUNET_FS_Uri::data, env, ResponseLocSignatureMessage::expiration_time, Location::expirationTime, FileIdentifier::file_length, GNUNET_break, GNUNET_FS_URI_CHK, GNUNET_FS_uri_destroy(), GNUNET_FS_uri_loc_create(), GNUNET_MESSAGE_TYPE_FS_REQUEST_LOC_SIGNATURE, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_ntohll(), GNUNET_SERVICE_client_continue(), GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT, GNUNET_TIME_absolute_hton(), GNUNET_TIME_absolute_ntoh(), GNUNET_FS_Uri::loc, GSF_LocalClient::mq, msg, ResponseLocSignatureMessage::peer, Location::peer, pk, ResponseLocSignatureMessage::purpose, ResponseLocSignatureMessage::signature, and GNUNET_FS_Uri::type.

Here is the call graph for this function:

◆ check_client_index_start()

static int check_client_index_start ( void *  cls,
const struct IndexStartMessage ism 
)
static

Check INDEX_START-message.

Parameters
clsidentification of the client
ismthe actual message
Returns
GNUNET_OK if ism is well-formed

Definition at line 927 of file gnunet-service-fs.c.

929{
930 char *fn;
931
933 if (0 != ism->reserved)
934 {
935 GNUNET_break (0);
936 return GNUNET_SYSERR;
937 }
938 fn = GNUNET_STRINGS_filename_expand ((const char *) &ism[1]);
939 if (NULL == fn)
940 {
941 GNUNET_break (0);
942 return GNUNET_SYSERR;
943 }
944 GNUNET_free (fn);
945 return GNUNET_OK;
946}

References GNUNET_break, GNUNET_free, GNUNET_MQ_check_zero_termination, GNUNET_OK, GNUNET_STRINGS_filename_expand(), GNUNET_SYSERR, and IndexStartMessage::reserved.

Here is the call graph for this function:

◆ signal_index_ok()

static void signal_index_ok ( struct IndexStartContext isc)
static

We've validated the hash of the file we're about to index.

Signal success to the client and update our internal data structures.

Parameters
iscthe data about the index info entry for the request

Definition at line 956 of file gnunet-service-fs.c.

957{
958 struct GSF_LocalClient *lc = isc->lc;
959 struct GNUNET_MQ_Envelope *env;
961
963 &isc->file_id);
966 GNUNET_MQ_send (lc->mq,
967 env);
968 GNUNET_free (isc->filename);
969 GNUNET_free (isc);
971}

References GSF_LocalClient::client, env, IndexStartContext::file_id, IndexStartContext::filename, GNUNET_free, GNUNET_FS_add_to_index(), GNUNET_MESSAGE_TYPE_FS_INDEX_START_OK, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_SERVICE_client_continue(), IndexStartContext::lc, GSF_LocalClient::mq, and msg.

Referenced by handle_client_index_start(), and hash_for_index_val().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hash_for_index_val()

static void hash_for_index_val ( void *  cls,
const struct GNUNET_HashCode res 
)
static

Function called once the hash computation over an indexed file has completed.

Parameters
clsclosure, our publishing context
resresulting hash, NULL on error

Definition at line 982 of file gnunet-service-fs.c.

984{
985 struct IndexStartContext *isc = cls;
986 struct GSF_LocalClient *lc = isc->lc;
987 struct GNUNET_MQ_Envelope *env;
989
991 lc->isc_tail,
992 isc);
993 isc->fhc = NULL;
994 if ((NULL == res) ||
995 (0 != memcmp (res,
996 &isc->file_id,
997 sizeof(struct GNUNET_HashCode))))
998 {
1000 _ (
1001 "Hash mismatch trying to index file `%s' which does not have hash `%s'\n"),
1002 isc->filename,
1003 GNUNET_h2s (&isc->file_id));
1004
1005 const char *emsg = "hash mismatch";
1006 const size_t msize = strlen (emsg) + 1;
1007
1009 msize,
1011 memcpy ((char*) &msg[1], emsg, msize);
1012 GNUNET_MQ_send (lc->mq,
1013 env);
1015 GNUNET_free (isc);
1016 return;
1017 }
1018 signal_index_ok (isc);
1019}

References _, GSF_LocalClient::client, env, IndexStartContext::fhc, IndexStartContext::file_id, IndexStartContext::filename, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_h2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_FS_INDEX_START_FAILED, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_SERVICE_client_continue(), GSF_LocalClient::isc_head, GSF_LocalClient::isc_tail, IndexStartContext::lc, GSF_LocalClient::mq, msg, res, and signal_index_ok().

Referenced by handle_client_index_start().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_client_index_start()

static void handle_client_index_start ( void *  cls,
const struct IndexStartMessage ism 
)
static

Handle INDEX_START-message.

Parameters
clsidentification of the client
ismthe actual message

Definition at line 1029 of file gnunet-service-fs.c.

1031{
1032 struct GSF_LocalClient *lc = cls;
1033 struct IndexStartContext *isc;
1034 char *fn;
1035 uint64_t dev;
1036 uint64_t ino;
1037 uint64_t mydev;
1038 uint64_t myino;
1039
1040 fn = GNUNET_STRINGS_filename_expand ((const char *) &ism[1]);
1041 GNUNET_assert (NULL != fn);
1042 dev = GNUNET_ntohll (ism->device);
1043 ino = GNUNET_ntohll (ism->inode);
1044 isc = GNUNET_new (struct IndexStartContext);
1045 isc->filename = fn;
1046 isc->file_id = ism->file_id;
1048 "Received START_INDEX message for file `%s'\n",
1049 isc->filename);
1050 isc->lc = lc;
1051 mydev = 0;
1052 myino = 0;
1053 if (((dev != 0) ||
1054 (ino != 0)) &&
1056 &mydev,
1057 &myino)) &&
1058 (dev == mydev) &&
1059 (ino == myino))
1060 {
1061 /* fast validation OK! */
1062 signal_index_ok (isc);
1063 return;
1064 }
1066 "Mismatch in file identifiers (%llu != %llu or %u != %u), need to hash.\n",
1067 (unsigned long long) ino,
1068 (unsigned long long) myino,
1069 (unsigned int) dev,
1070 (unsigned int) mydev);
1071 /* slow validation, need to hash full file (again) */
1073 lc->isc_tail,
1074 isc);
1076 isc->filename,
1079 isc);
1080 if (NULL == isc->fhc)
1081 hash_for_index_val (isc,
1082 NULL);
1083}

References IndexStartMessage::device, IndexStartContext::fhc, IndexStartMessage::file_id, IndexStartContext::file_id, IndexStartContext::filename, GNUNET_assert, GNUNET_CONTAINER_DLL_insert, GNUNET_CRYPTO_hash_file(), GNUNET_DISK_file_get_identifiers(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_new, GNUNET_ntohll(), GNUNET_OK, GNUNET_SCHEDULER_PRIORITY_IDLE, GNUNET_STRINGS_filename_expand(), hash_for_index_val(), HASHING_BLOCKSIZE, IndexStartMessage::inode, GSF_LocalClient::isc_head, GSF_LocalClient::isc_tail, IndexStartContext::lc, and signal_index_ok().

Here is the call graph for this function:

◆ handle_client_index_list_get()

static void handle_client_index_list_get ( void *  cls,
const struct GNUNET_MessageHeader message 
)
static

Handle INDEX_LIST_GET-message.

Parameters
clsclosure
messagethe actual message

Definition at line 1093 of file gnunet-service-fs.c.

1095{
1096 struct GSF_LocalClient *lc = cls;
1097
1100}

References GSF_LocalClient::client, GNUNET_FS_indexing_send_list(), GNUNET_SERVICE_client_continue(), and GSF_LocalClient::mq.

Here is the call graph for this function:

◆ handle_client_unindex()

static void handle_client_unindex ( void *  cls,
const struct UnindexMessage um 
)
static

Handle UNINDEX-message.

Parameters
clsidentification of the client
umthe actual message

Definition at line 1110 of file gnunet-service-fs.c.

1112{
1113 struct GSF_LocalClient *lc = cls;
1114 struct GNUNET_MQ_Envelope *env;
1115 struct GNUNET_MessageHeader *msg;
1116 int found;
1117
1118 GNUNET_break (0 == um->reserved);
1121 "Client requested unindexing of file `%s': %s\n",
1122 GNUNET_h2s (&um->file_id),
1123 found ? "found" : "not found");
1126 GNUNET_MQ_send (lc->mq,
1127 env);
1129}

References GSF_LocalClient::client, env, UnindexMessage::file_id, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_FS_indexing_do_unindex(), GNUNET_h2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_FS_UNINDEX_OK, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_SERVICE_client_continue(), GSF_LocalClient::mq, msg, and UnindexMessage::reserved.

Here is the call graph for this function:

◆ shutdown_task()

static void shutdown_task ( void *  cls)
static

Task run during shutdown.

Parameters
clsunused

Definition at line 1138 of file gnunet-service-fs.c.

References block_cfg, cover_age_task, datastore_get_load, GNUNET_BLOCK_context_destroy(), GNUNET_CONFIGURATION_destroy(), GNUNET_CORE_disconnect(), GNUNET_DATASTORE_disconnect(), GNUNET_DHT_disconnect(), GNUNET_FS_indexing_done(), GNUNET_LOAD_value_free, GNUNET_NO, GNUNET_PILS_disconnect(), GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_destroy(), GSF_block_ctx, GSF_cadet_stop_server(), GSF_connected_peer_done_(), GSF_core, GSF_dht, GSF_dsh, GSF_pending_request_done_(), GSF_pils, GSF_plan_done(), GSF_push_done_(), GSF_put_done_(), GSF_rt_entry_lifetime, and GSF_stats.

Here is the call graph for this function:

◆ pils_pid_change_cb()

static void pils_pid_change_cb ( void *  cls,
const struct GNUNET_HELLO_Parser parser,
const struct GNUNET_HashCode hash 
)
static

Function called after GNUNET_PILS_connect has succeeded (or failed for good).

Note that the private key of the peer is intentionally not exposed here; if you need it, your process should try to read the private key file directly (which should work if you are authorized...).

Parameters
clsclosure
my_identityID of this peer, NULL if we failed
clsclosure given to GNUNET_PILS_connect
parserthe new HELLO from which the PID can be extracted
hashThe hash of addresses the peer id is based on. This hash is also returned by #GNUNET_PILS_feed_address.

Definition at line 1195 of file gnunet-service-fs.c.

1198{
1200 "My current identity is `%s'\n",
1204 "My new identity is `%s'\n",
1206}

References GNUNET_ERROR_TYPE_INFO, GNUNET_HELLO_parser_get_id(), GNUNET_i2s_full(), GNUNET_log, and GSF_my_id.

Referenced by main_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ main_init()

static int main_init ( const struct GNUNET_CONFIGURATION_Handle c)
static

Process fs requests.

Parameters
cconfiguration to use

Definition at line 1215 of file gnunet-service-fs.c.

1216{
1217 struct GNUNET_MQ_MessageHandler no_p2p_handlers[] = {
1219 };
1220 struct GNUNET_MQ_MessageHandler p2p_handlers[] = {
1221 GNUNET_MQ_hd_var_size (p2p_get,
1223 struct GetMessage,
1224 NULL),
1225 GNUNET_MQ_hd_var_size (p2p_put,
1227 struct PutMessage,
1228 NULL),
1229 GNUNET_MQ_hd_fixed_size (p2p_migration_stop,
1231 struct MigrationStopMessage,
1232 NULL),
1234 };
1235 int anon_p2p_off;
1236 char *keyfile;
1237 struct GNUNET_CORE_ServiceInfo service_info = {
1239 .version = { 1, 0 },
1240 .version_max = { 1, 0 },
1241 .version_min = { 1, 0 },
1242 };
1243
1244 /* this option is really only for testcases that need to disable
1245 _anonymous_ file-sharing for some reason */
1246 anon_p2p_off = (GNUNET_YES ==
1248 "fs",
1249 "DISABLE_ANON_TRANSFER")
1250 );
1251
1252 if (GNUNET_OK !=
1254 "PEER",
1255 "PRIVATE_KEY",
1256 &keyfile))
1257 {
1259 _ (
1260 "FS service is lacking HOSTKEY configuration setting. Exiting.\n"));
1262 return GNUNET_SYSERR;
1263 }
1264 if (GNUNET_SYSERR ==
1266 GNUNET_YES,
1267 &pk))
1268 {
1270 "Failed to setup peer's private key\n");
1272 GNUNET_free (keyfile);
1273 return GNUNET_SYSERR;
1274 }
1275 GNUNET_free (keyfile);
1278
1280 "I am peer %s\n",
1282 GSF_core
1284 NULL,
1285 NULL,
1288 (GNUNET_YES == anon_p2p_off)
1289 ? no_p2p_handlers
1290 : p2p_handlers,
1291 &service_info);
1292 if (NULL == GSF_core)
1293 {
1295 _ ("Failed to connect to `%s' service.\n"),
1296 "core");
1297 return GNUNET_SYSERR;
1298 }
1299 GSF_pils
1302 NULL);
1303 if (NULL == GSF_core)
1304 {
1306 _ ("Failed to connect to `%s' service.\n"),
1307 "core");
1308 return GNUNET_SYSERR;
1309 }
1313 NULL);
1317 NULL);
1318 return GNUNET_OK;
1319}

References _, age_cover_counters(), COVER_AGE_FREQUENCY, cover_age_task, datastore_get_load, DATASTORE_LOAD_AUTODECLINE, GNUNET_CONFIGURATION_get_value_filename(), GNUNET_CONFIGURATION_get_value_yesno(), GNUNET_CORE_connect(), GNUNET_CORE_SERVICE_FS, GNUNET_CRYPTO_eddsa_key_from_file(), GNUNET_CRYPTO_eddsa_key_get_public(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_i2s(), GNUNET_LOAD_value_init(), GNUNET_log, GNUNET_MESSAGE_TYPE_FS_GET, GNUNET_MESSAGE_TYPE_FS_MIGRATION_STOP, GNUNET_MESSAGE_TYPE_FS_PUT, GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_MQ_hd_var_size, GNUNET_OK, GNUNET_PILS_connect(), GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_shutdown(), GNUNET_SYSERR, GNUNET_YES, GSF_cadet_start_server(), GSF_cfg, GSF_core, GSF_my_id, GSF_peer_connect_handler(), GSF_peer_disconnect_handler(), GSF_pils, pils_pid_change_cb(), pk, GNUNET_PeerIdentity::public_key, GNUNET_CORE_ServiceInfo::service, and shutdown_task.

Referenced by run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ run()

static void run ( void *  cls,
const struct GNUNET_CONFIGURATION_Handle cfg,
struct GNUNET_SERVICE_Handle service 
)
static

Process fs requests.

Parameters
clsclosure
cfgconfiguration to use
servicethe initialized service

Definition at line 1330 of file gnunet-service-fs.c.

1333{
1334 unsigned long long dqs;
1335
1336 GSF_cfg = cfg;
1337 if (GNUNET_OK !=
1339 "fs",
1340 "DATASTORE_QUEUE_SIZE",
1341 &dqs))
1342 {
1344 "fs",
1345 "DATASTORE_QUEUE_SIZE");
1346 dqs = 32;
1347 }
1348 GSF_datastore_queue_size = (unsigned int) dqs;
1352 if (NULL == GSF_dsh)
1353 {
1355 return;
1356 }
1361 GNUNET_assert (NULL != GSF_block_ctx);
1363 GSF_plan_init ();
1366
1367 GSF_push_init_ ();
1368 GSF_put_init_ ();
1370 GSF_dsh)) ||
1371 (GNUNET_OK != main_init (cfg)))
1372 {
1374 shutdown_task (NULL);
1375 return;
1376 }
1377}

References block_cfg, cfg, FS_DHT_HT_SIZE, GNUNET_assert, GNUNET_BLOCK_context_create(), GNUNET_CONFIGURATION_create(), GNUNET_CONFIGURATION_get_value_size(), GNUNET_CONFIGURATION_get_value_yesno(), GNUNET_DATASTORE_connect(), GNUNET_DHT_connect(), GNUNET_ERROR_TYPE_INFO, GNUNET_FS_indexing_init(), GNUNET_LOAD_value_init(), GNUNET_log_config_missing(), GNUNET_OK, GNUNET_OS_project_data_gnunet(), GNUNET_SCHEDULER_shutdown(), GNUNET_STATISTICS_create(), GNUNET_TIME_UNIT_FOREVER_REL, GSF_block_ctx, GSF_cfg, GSF_connected_peer_init_(), GSF_datastore_queue_size, GSF_dht, GSF_dsh, GSF_enable_randomized_delays, GSF_pending_request_init_(), GSF_plan_init(), GSF_push_init_(), GSF_put_init_(), GSF_rt_entry_lifetime, GSF_stats, main_init(), and shutdown_task.

Here is the call graph for this function:

◆ GNUNET_SERVICE_MAIN()

GNUNET_SERVICE_MAIN ( GNUNET_OS_project_data_gnunet()  ,
"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.

Variable Documentation

◆ GSF_dsh

◆ GSF_cfg

◆ GSF_stats

◆ GSF_dht

struct GNUNET_DHT_Handle* GSF_dht

Handle for DHT operations.

Definition at line 237 of file gnunet-service-fs.c.

Referenced by GSF_dht_lookup_(), process_dht_put_content(), run(), and shutdown_task().

◆ GSF_rt_entry_lifetime

struct GNUNET_LOAD_Value* GSF_rt_entry_lifetime

How long do requests typically stay in the routing table?

Definition at line 242 of file gnunet-service-fs.c.

Referenced by handle_p2p_get(), process_reply(), run(), and shutdown_task().

◆ GSF_avg_latency

struct GNUNET_TIME_Relative GSF_avg_latency = { 500 }

Running average of the observed latency to other peers (round trip).

Initialized to 5s as the initial default.

Definition at line 248 of file gnunet-service-fs.c.

248{ 500 };

Referenced by get_randomized_delay().

◆ GSF_current_priorities

double GSF_current_priorities

Typical priorities we're seeing from other peers right now.

Since most priorities will be zero, this value is the weighted average of non-zero priorities seen "recently". In order to ensure that new values do not dramatically change the ratio, values are first "capped" to a reasonable range (+N of the current value) and then averaged into the existing value by a ratio of 1:N. Hence receiving the largest possible priority can still only raise our "current_priorities" by at most 1.

Definition at line 261 of file gnunet-service-fs.c.

Referenced by bound_priority(), and plan().

◆ GSF_datastore_queue_size

unsigned int GSF_datastore_queue_size

Size of the datastore queue we assume for common requests.

Definition at line 266 of file gnunet-service-fs.c.

Referenced by handle_request(), run(), and start_local_query().

◆ GSF_cover_query_count

unsigned int GSF_cover_query_count

How many query messages have we received 'recently' that have not yet been claimed as cover traffic?

Definition at line 272 of file gnunet-service-fs.c.

Referenced by age_cover_counters(), and handle_p2p_get().

◆ GSF_cover_content_count

unsigned int GSF_cover_content_count

How many content messages have we received 'recently' that have not yet been claimed as cover traffic?

Definition at line 278 of file gnunet-service-fs.c.

Referenced by age_cover_counters(), handle_p2p_put(), and handle_p2p_reply().

◆ GSF_block_ctx

◆ GSF_core

struct GNUNET_CORE_Handle* GSF_core

Pointer to handle to the core service (points to NULL until we've connected to it).

Definition at line 289 of file gnunet-service-fs.c.

Referenced by main_init(), and shutdown_task().

◆ GSF_pils

struct GNUNET_PILS_Handle* GSF_pils

Pointer to handle to the pils service (points to NULL until we've connected to it).

Definition at line 295 of file gnunet-service-fs.c.

Referenced by main_init(), and shutdown_task().

◆ GSF_enable_randomized_delays

int GSF_enable_randomized_delays

Are we introducing randomized delays for better anonymity?

Definition at line 300 of file gnunet-service-fs.c.

Referenced by handle_p2p_reply(), and run().

◆ GSF_my_id

struct GNUNET_PeerIdentity GSF_my_id

Identity of this peer.

Definition at line 305 of file gnunet-service-fs.c.

Referenced by GSF_peer_connect_handler(), main_init(), and pils_pid_change_cb().

◆ block_cfg

struct GNUNET_CONFIGURATION_Handle* block_cfg
static

Configuration for block library.

Definition at line 312 of file gnunet-service-fs.c.

Referenced by run(), and shutdown_task().

◆ pk

Private key of this peer.

Used to sign LOC URI requests.

Definition at line 317 of file gnunet-service-fs.c.

Referenced by handle_client_loc_sign(), and main_init().

◆ cover_age_task

struct GNUNET_SCHEDULER_Task* cover_age_task
static

ID of our task that we use to age the cover counters.

Definition at line 322 of file gnunet-service-fs.c.

Referenced by age_cover_counters(), main_init(), and shutdown_task().

◆ datastore_get_load

struct GNUNET_LOAD_Value* datastore_get_load
static

Datastore 'GET' load tracking.

Definition at line 327 of file gnunet-service-fs.c.

Referenced by GSF_test_get_load_too_high_(), GSF_update_datastore_delay_(), main_init(), and shutdown_task().