GNUnet 0.22.2
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. More...
 
#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. More...
 
#define INSANE_STATISTICS   GNUNET_NO
 Collect an instance number of statistics? May cause excessive IPC. More...
 

Functions

static void * client_connect_cb (void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq)
 Creates a fresh local client handle. More...
 
static void client_request_destroy (void *cls)
 Free the given client request. More...
 
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. More...
 
static void client_disconnect_cb (void *cls, struct GNUNET_SERVICE_Client *client, void *app_ctx)
 A client disconnected from us. More...
 
static void age_cover_counters (void *cls)
 Task that periodically ages our cover traffic statistics. More...
 
void GSF_update_datastore_delay_ (struct GNUNET_TIME_Absolute start)
 We've just now completed a datastore request. More...
 
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. More...
 
static int check_p2p_put (void *cls, const struct PutMessage *put)
 Check P2P "PUT" message. More...
 
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. More...
 
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. More...
 
static int check_p2p_get (void *cls, const struct GetMessage *gm)
 Check P2P "GET" request. More...
 
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). More...
 
static int check_client_start_search (void *cls, const struct SearchMessage *sm)
 Check GNUNET_MESSAGE_TYPE_FS_START_SEARCH-message (search request from client). More...
 
static void handle_client_start_search (void *cls, const struct SearchMessage *sm)
 Handle GNUNET_MESSAGE_TYPE_FS_START_SEARCH-message (search request from client). More...
 
static void handle_client_loc_sign (void *cls, const struct RequestLocSignatureMessage *msg)
 Handle request to sign a LOC URI (from client). More...
 
static int check_client_index_start (void *cls, const struct IndexStartMessage *ism)
 Check INDEX_START-message. More...
 
static void signal_index_ok (struct IndexStartContext *isc)
 We've validated the hash of the file we're about to index. More...
 
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. More...
 
static void handle_client_index_start (void *cls, const struct IndexStartMessage *ism)
 Handle INDEX_START-message. More...
 
static void handle_client_index_list_get (void *cls, const struct GNUNET_MessageHeader *message)
 Handle INDEX_LIST_GET-message. More...
 
static void handle_client_unindex (void *cls, const struct UnindexMessage *um)
 Handle UNINDEX-message. More...
 
static void shutdown_task (void *cls)
 Task run during shutdown. More...
 
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). More...
 
static int main_init (const struct GNUNET_CONFIGURATION_Handle *c)
 Process fs requests. More...
 
static void run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_SERVICE_Handle *service)
 Process fs requests. More...
 
 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. More...
 

Variables

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

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 51 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 59 of file gnunet-service-fs.c.

◆ INSANE_STATISTICS

#define INSANE_STATISTICS   GNUNET_NO

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

Definition at line 65 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 332 of file gnunet-service-fs.c.

335{
336 struct GSF_LocalClient *pos;
337
338 pos = GNUNET_new (struct GSF_LocalClient);
339 pos->client = client;
340 pos->mq = mq;
341 return pos;
342}
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
#define GNUNET_new(type)
Allocate a struct or union of the given type.
A local client.
struct GNUNET_MQ_Handle * mq
Queue for sending replies.
struct GNUNET_SERVICE_Client * client
ID of the client.

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 351 of file gnunet-service-fs.c.

352{
353 struct ClientRequest *cr = cls;
354 struct GSF_LocalClient *lc = cr->lc;
355
356 cr->kill_task = NULL;
358 lc->cr_tail,
359 cr);
361 GNUNET_YES);
363 gettext_noop ("# client searches active"),
364 -1,
365 GNUNET_NO);
366 GNUNET_free (cr);
367}
#define gettext_noop(String)
Definition: gettext.h:74
struct GNUNET_STATISTICS_Handle * GSF_stats
Handle for reporting statistics.
void GSF_pending_request_cancel_(struct GSF_PendingRequest *pr, int full_cleanup)
Explicitly cancel a pending request.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
@ GNUNET_YES
@ GNUNET_NO
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
Doubly-linked list of requests we are performing on behalf of the same client.
struct GNUNET_SCHEDULER_Task * kill_task
Task scheduled to destroy the request.
struct GSF_LocalClient * lc
Client list this request belongs to.
struct GSF_PendingRequest * pr
Request this entry represents.
struct ClientRequest * cr_head
Head of list of requests performed on behalf of this client right now.
struct ClientRequest * cr_tail
Tail of list of requests performed on behalf of this client right now.

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 389 of file gnunet-service-fs.c.

398{
399 struct ClientRequest *cr = cls;
400 struct GSF_LocalClient *lc;
401 struct GNUNET_MQ_Envelope *env;
402 struct ClientPutMessage *pm;
403 const struct GSF_PendingRequestData *prd;
404
405 if (NULL == data)
406 {
407 /* local-only request, with no result, clean up. */
408 if (NULL == cr->kill_task)
410 cr);
411 return;
412 }
415 if ((prd->type != type) && (prd->type != GNUNET_BLOCK_TYPE_ANY))
416 {
417 GNUNET_break (0);
418 return;
419 }
422 ("# replies received for local clients"), 1,
423 GNUNET_NO);
424 GNUNET_assert (pr == cr->pr);
425 lc = cr->lc;
427 data_len,
429 pm->type = htonl (type);
431 pm->last_transmission = GNUNET_TIME_absolute_hton (last_transmission);
432 pm->num_transmissions = htonl (prd->num_transmissions);
433 pm->respect_offered = htonl (prd->respect_offered);
434 GNUNET_memcpy (&pm[1],
435 data,
436 data_len);
437 GNUNET_MQ_send (lc->mq,
438 env);
440 "Queued reply to query `%s' for local client\n",
441 GNUNET_h2s (&prd->query));
442 if (GNUNET_BLOCK_REPLY_OK_LAST != eval)
443 {
445 "Evaluation %d - keeping query alive\n",
446 (int) eval);
447 return;
448 }
449 if (NULL == cr->kill_task)
451 cr);
452}
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static char * data
The data to insert into the dht.
static struct GNUNET_TIME_Relative expiration
User supplied expiration value.
static uint32_t type
Type string converted to DNS type value.
static void client_request_destroy(void *cls)
Free the given client request.
struct GSF_PendingRequestData * GSF_pending_request_get_data_(struct GSF_PendingRequest *pr)
Obtain the public data associated with a pending request.
static struct GNUNET_TRANSPORT_PluginMonitor * pm
Handle if we are monitoring plugin session activity.
@ GNUNET_BLOCK_TYPE_ANY
Identifier for any block.
@ GNUNET_BLOCK_REPLY_OK_LAST
Last possible valid result.
#define GNUNET_log(kind,...)
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_DEBUG
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_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:61
#define GNUNET_MESSAGE_TYPE_FS_PUT
P2P response with content or active migration of content.
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_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition: time.c:640
Response from FS service with a result for a previous FS search.
Definition: fs.h:356
Public data (in the sense of not encapsulated within 'gnunet-service-fs_pr', not in the sense of netw...
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...
struct GNUNET_HashCode query
Primary query hash for this request.

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 464 of file gnunet-service-fs.c.

467{
468 struct GSF_LocalClient *lc = app_ctx;
469 struct IndexStartContext *isc;
470 struct ClientRequest *cr;
471 struct ClientResponse *res;
472
473 while (NULL != (cr = lc->cr_head))
474 {
475 if (NULL != cr->kill_task)
478 }
479 while (NULL != (res = lc->res_head))
480 {
482 lc->res_tail,
483 res);
485 }
486 while (NULL != (isc = lc->isc_head))
487 {
489 lc->isc_tail,
490 isc);
492 GNUNET_free (isc);
493 }
494 GNUNET_free (lc);
495}
static char * res
Currently read line or NULL on EOF.
void GNUNET_CRYPTO_hash_file_cancel(struct GNUNET_CRYPTO_FileHashContext *fhc)
Cancel a file hashing operation.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:980
Replies to be transmitted to the client.
struct GSF_LocalClient * lc
Client list entry this response belongs to.
struct IndexStartContext * isc_head
This is a doubly linked list.
struct ClientResponse * res_tail
Tail of linked list of responses.
struct IndexStartContext * isc_tail
This is a doubly linked list.
struct ClientResponse * res_head
Head of linked list of responses.
Information we track while handling an index start request from a client.
struct GNUNET_CRYPTO_FileHashContext * fhc
Context for hashing of the file.

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 504 of file gnunet-service-fs.c.

505{
511 NULL);
512}
static struct GNUNET_SCHEDULER_Task * cover_age_task
ID of our task that we use to age the cover counters.
#define COVER_AGE_FREQUENCY
How quickly do we age cover traffic? At the given time interval, remaining cover traffic counters are...
unsigned int GSF_cover_query_count
How many query messages have we received 'recently' that have not yet been claimed as cover traffic?
static void age_cover_counters(void *cls)
Task that periodically ages our cover traffic statistics.
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_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

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 522 of file gnunet-service-fs.c.

523{
524 struct GNUNET_TIME_Relative delay;
525
527 GNUNET_LOAD_update (datastore_get_load, delay.rel_value_us);
528}
static int start
Set if we are to start default services (including ARM).
Definition: gnunet-arm.c:38
static struct GNUNET_LOAD_Value * datastore_get_load
Datastore 'GET' load tracking.
void GNUNET_LOAD_update(struct GNUNET_LOAD_Value *load, uint64_t data)
Update the current load.
Definition: load.c:236
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
Time for relative time used by GNUnet, in microseconds.

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 542 of file gnunet-service-fs.c.

543{
544 double ld;
545
547 if (ld < 1)
548 return GNUNET_SYSERR;
549 if (ld <= priority)
550 return GNUNET_NO;
551 return GNUNET_YES;
552}
@ GNUNET_SYSERR
double GNUNET_LOAD_get_load(struct GNUNET_LOAD_Value *load)
Get the current load.
Definition: load.c:200

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 564 of file gnunet-service-fs.c.

566{
568
569 type = ntohl (put->type);
571 {
572 GNUNET_break_op (0);
573 return GNUNET_SYSERR;
574 }
575 return GNUNET_OK;
576}
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_ONDEMAND
Type of a block representing a block to be encoded on demand from disk.
@ GNUNET_OK
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
uint32_t type
Type of the block (in big endian).
Definition: fs.h:339

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 589 of file gnunet-service-fs.c.

593{
594 struct GSF_PendingRequest *pr = cls;
595
596 if (GNUNET_YES !=
598 {
599#if INSANE_STATISTICS
601 gettext_noop ("# Loopback routes suppressed"), 1,
602 GNUNET_NO);
603#endif
604 return;
605 }
606 GSF_plan_add_ (cp,
607 pr);
608}
void GSF_plan_add_(struct GSF_ConnectedPeer *cp, struct GSF_PendingRequest *pr)
Create a new query plan entry.
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?
An active request.

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 622 of file gnunet-service-fs.c.

625{
627 return; /* we're done... */
628 if (GNUNET_YES !=
630 return; /* request is not actually active, skip! */
632 pr);
633}
static int result
Global testing status.
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_iterate_connected_peers_(GSF_ConnectedPeerIterator it, void *it_cls)
Iterate over all connected peers.
int GSF_pending_request_test_active_(struct GSF_PendingRequest *pr)
Check if the given request is still active.

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 645 of file gnunet-service-fs.c.

647{
648 size_t msize;
649 unsigned int bm;
650 unsigned int bits;
651 size_t bfsize;
652
653 msize = ntohs (gm->header.size);
654 bm = ntohl (gm->hash_bitmap);
655 bits = 0;
656 while (bm > 0)
657 {
658 if (1 == (bm & 1))
659 bits++;
660 bm >>= 1;
661 }
662 if (msize < sizeof(struct GetMessage) + bits * sizeof(struct
664 {
665 GNUNET_break_op (0);
666 return GNUNET_SYSERR;
667 }
668 bfsize = msize - sizeof(struct GetMessage) - bits * sizeof(struct
670 /* bfsize must be power of 2, check! */
671 if (0 != ((bfsize - 1) & bfsize))
672 {
673 GNUNET_break_op (0);
674 return GNUNET_SYSERR;
675 }
676 return GNUNET_OK;
677}
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
The identity of the host (wraps the signing key of the peer).
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...

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 691 of file gnunet-service-fs.c.

694{
695 struct GSF_LocalClient *lc = cls;
696 struct GSF_PendingRequestData *prd;
697
700 return; /* we're done, 'pr' was already destroyed... */
703 "Finished database lookup for local request `%s' with result %d\n",
704 GNUNET_h2s (&prd->query),
705 result);
706 if (0 == prd->anonymity_level)
707 {
708 switch (prd->type)
709 {
712 /* the above block types MAY be available via 'cadet' */
714 "Considering cadet-based download for block\n");
716 break;
717
719 /* the above block types are in the DHT */
721 "Considering DHT-based search for block\n");
722 GSF_dht_lookup_ (pr);
723 break;
724
725 default:
726 GNUNET_break (0);
727 break;
728 }
729 }
731 pr,
732 result);
733}
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.
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).
@ GNUNET_BLOCK_TYPE_FS_DBLOCK
Data block (leaf) in the CHK tree.
@ GNUNET_BLOCK_TYPE_FS_IBLOCK
Inner block in the CHK tree.
@ GNUNET_BLOCK_TYPE_FS_UBLOCK
Type of a block representing any type of search result (universal).
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2389
uint32_t anonymity_level
Desired anonymity level.

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 745 of file gnunet-service-fs.c.

747{
748 uint16_t msize;
749
750 msize = ntohs (sm->header.size) - sizeof(struct SearchMessage);
751 if (0 != msize % sizeof(struct GNUNET_HashCode))
752 {
753 GNUNET_break (0);
754 return GNUNET_SYSERR;
755 }
756 return GNUNET_OK;
757}
A 512-bit hashcode.
Message sent from a GNUnet (fs) search activity to the gnunet-service-fs to start a search.
Definition: fs.h:270
struct GNUNET_MessageHeader header
Message type will be GNUNET_MESSAGE_TYPE_FS_START_SEARCH.
Definition: fs.h:274

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 771 of file gnunet-service-fs.c.

773{
774 static struct GNUNET_PeerIdentity all_zeros;
775 struct GSF_LocalClient *lc = cls;
776 struct ClientRequest *cr;
777 struct GSF_PendingRequestData *prd;
778 uint16_t msize;
779 unsigned int sc;
782
784 gettext_noop ("# client searches received"),
785 1,
786 GNUNET_NO);
787 msize = ntohs (sm->header.size) - sizeof(struct SearchMessage);
788 sc = msize / sizeof(struct GNUNET_HashCode);
789 type = ntohl (sm->type);
791 "Received request for `%s' of type %u from local client\n",
792 GNUNET_h2s (&sm->query),
793 (unsigned int) type);
794 cr = NULL;
795 /* detect duplicate UBLOCK requests */
798 {
799 cr = lc->cr_head;
800 while (NULL != cr)
801 {
803 /* only unify with queries that hae not yet started local processing
804 (SEARCH_MESSAGE_OPTION_CONTINUED was always set) and that have a
805 matching query and type */
806 if ((GNUNET_YES != prd->has_started) &&
807 (0 != memcmp (&prd->query,
808 &sm->query,
809 sizeof(struct GNUNET_HashCode))) &&
810 (prd->type == type))
811 break;
812 cr = cr->next;
813 }
814 }
815 if (NULL != cr)
816 {
818 "Have existing request, merging content-seen lists.\n");
820 (const struct GNUNET_HashCode *) &sm[1],
821 sc);
824 "# client searches updated (merged content seen list)"),
825 1,
826 GNUNET_NO);
827 }
828 else
829 {
831 gettext_noop ("# client searches active"),
832 1,
833 GNUNET_NO);
834 cr = GNUNET_new (struct ClientRequest);
835 cr->lc = lc;
837 lc->cr_tail,
838 cr);
840 if (0 != (SEARCH_MESSAGE_OPTION_LOOPBACK_ONLY & ntohl (sm->options)))
843 &sm->query,
844 (0 !=
845 memcmp (&sm->target,
846 &all_zeros,
847 sizeof(struct
849 ? &sm->target : NULL, NULL,
850 0 /* bf */,
851 ntohl (sm->anonymity_level),
852 0 /* priority */,
853 0 /* ttl */,
854 0 /* sender PID */,
855 0 /* origin PID */,
856 (const struct
857 GNUNET_HashCode *) &sm[1], sc,
859 cr);
860 }
861 if (0 != (SEARCH_MESSAGE_OPTION_CONTINUED & ntohl (sm->options)))
862 {
864 return;
865 }
869 lc);
870}
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
#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
static struct GNUNET_FS_SearchContext * sc
Definition: gnunet-search.c:87
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 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.
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_local_lookup_(struct GSF_PendingRequest *pr, GSF_LocalLookupContinuation cont, void *cont_cls)
Look up the request in the local datastore.
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.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
struct ClientRequest * next
This is a doubly-linked list.
int has_started
Has this request been started yet (local/p2p operations)? Or are we still constructing it?
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
uint32_t anonymity_level
Desired anonymity level, big-endian.
Definition: fs.h:295
uint32_t options
Bitmask with options.
Definition: fs.h:285

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 880 of file gnunet-service-fs.c.

882{
883 struct GSF_LocalClient *lc = cls;
884 struct GNUNET_FS_Uri base;
885 struct GNUNET_FS_Uri *loc;
886 struct GNUNET_MQ_Envelope *env;
887 struct ResponseLocSignatureMessage *resp;
888
890 ntohl (msg->purpose));
891 base.type = GNUNET_FS_URI_CHK;
892 base.data.chk.chk = msg->chk;
893 base.data.chk.file_length = GNUNET_ntohll (msg->file_length);
894 loc = GNUNET_FS_uri_loc_create (&base,
895 &pk,
897 msg->expiration_time));
898 env = GNUNET_MQ_msg (resp,
902 loc->data.loc.expirationTime);
903 resp->signature = loc->data.loc.contentSignature;
904 resp->peer = loc->data.loc.peer;
906 GNUNET_MQ_send (lc->mq,
907 env);
909}
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
@ GNUNET_FS_URI_CHK
Content-hash-key (simple file).
Definition: fs_api.h:144
static struct GNUNET_CRYPTO_EddsaPrivateKey pk
Private key of this peer.
#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...
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
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:54
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:76
#define GNUNET_MESSAGE_TYPE_FS_REQUEST_LOC_SIGNATURE
Reply sent by fs service with LOC signature.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
Definition: time.c:741
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
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 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

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 920 of file gnunet-service-fs.c.

922{
923 char *fn;
924
926 if (0 != ism->reserved)
927 {
928 GNUNET_break (0);
929 return GNUNET_SYSERR;
930 }
931 fn = GNUNET_STRINGS_filename_expand ((const char *) &ism[1]);
932 if (NULL == fn)
933 {
934 GNUNET_break (0);
935 return GNUNET_SYSERR;
936 }
937 GNUNET_free (fn);
938 return GNUNET_OK;
939}
#define GNUNET_MQ_check_zero_termination(m)
Insert code for a "check_" function that verifies that a given variable-length message received over ...
char * GNUNET_STRINGS_filename_expand(const char *fil)
Complete filename (a la shell) from abbrevition.
Definition: strings.c:504
uint32_t reserved
For alignment.
Definition: fs.h:162

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 949 of file gnunet-service-fs.c.

950{
951 struct GSF_LocalClient *lc = isc->lc;
952 struct GNUNET_MQ_Envelope *env;
954
956 &isc->file_id);
959 GNUNET_MQ_send (lc->mq,
960 env);
961 GNUNET_free (isc->filename);
962 GNUNET_free (isc);
964}
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.
#define GNUNET_MESSAGE_TYPE_FS_INDEX_START_OK
Affirmative response to a request for start indexing.
Header for all communications.
struct GNUNET_HashCode file_id
Hash of the contents of the file.
struct GSF_LocalClient * lc
Context for transmitting confirmation to client.
char * filename
Name of the indexed file.

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 975 of file gnunet-service-fs.c.

977{
978 struct IndexStartContext *isc = cls;
979 struct GSF_LocalClient *lc = isc->lc;
980 struct GNUNET_MQ_Envelope *env;
982
984 lc->isc_tail,
985 isc);
986 isc->fhc = NULL;
987 if ((NULL == res) ||
988 (0 != memcmp (res,
989 &isc->file_id,
990 sizeof(struct GNUNET_HashCode))))
991 {
993 _ (
994 "Hash mismatch trying to index file `%s' which does not have hash `%s'\n"),
995 isc->filename,
996 GNUNET_h2s (&isc->file_id));
997
998 const char *emsg = "hash mismatch";
999 const size_t msize = strlen (emsg) + 1;
1000
1002 msize,
1004 memcpy ((char*) &msg[1], emsg, msize);
1005 GNUNET_MQ_send (lc->mq,
1006 env);
1008 GNUNET_free (isc);
1009 return;
1010 }
1011 signal_index_ok (isc);
1012}
static void signal_index_ok(struct IndexStartContext *isc)
We've validated the hash of the file we're about to index.
@ GNUNET_ERROR_TYPE_WARNING
#define GNUNET_MESSAGE_TYPE_FS_INDEX_START_FAILED
Response to a request for start indexing that refuses.
#define _(String)
GNU gettext support macro.
Definition: platform.h:179

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 1022 of file gnunet-service-fs.c.

1024{
1025 struct GSF_LocalClient *lc = cls;
1026 struct IndexStartContext *isc;
1027 char *fn;
1028 uint64_t dev;
1029 uint64_t ino;
1030 uint64_t mydev;
1031 uint64_t myino;
1032
1033 fn = GNUNET_STRINGS_filename_expand ((const char *) &ism[1]);
1034 GNUNET_assert (NULL != fn);
1035 dev = GNUNET_ntohll (ism->device);
1036 ino = GNUNET_ntohll (ism->inode);
1037 isc = GNUNET_new (struct IndexStartContext);
1038 isc->filename = fn;
1039 isc->file_id = ism->file_id;
1041 "Received START_INDEX message for file `%s'\n",
1042 isc->filename);
1043 isc->lc = lc;
1044 mydev = 0;
1045 myino = 0;
1046 if (((dev != 0) ||
1047 (ino != 0)) &&
1049 &mydev,
1050 &myino)) &&
1051 (dev == mydev) &&
1052 (ino == myino))
1053 {
1054 /* fast validation OK! */
1055 signal_index_ok (isc);
1056 return;
1057 }
1059 "Mismatch in file identifiers (%llu != %llu or %u != %u), need to hash.\n",
1060 (unsigned long long) ino,
1061 (unsigned long long) myino,
1062 (unsigned int) dev,
1063 (unsigned int) mydev);
1064 /* slow validation, need to hash full file (again) */
1066 lc->isc_tail,
1067 isc);
1069 isc->filename,
1072 isc);
1073 if (NULL == isc->fhc)
1074 hash_for_index_val (isc,
1075 NULL);
1076}
#define HASHING_BLOCKSIZE
Blocksize to use when hashing files for indexing (blocksize for IO, not for the DBlocks).
Definition: fs.h:48
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.
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:241
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.
@ GNUNET_SCHEDULER_PRIORITY_IDLE
Run when otherwise idle.
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
uint64_t device
ID of device containing the file, as seen by the client.
Definition: fs.h:171

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 1086 of file gnunet-service-fs.c.

1088{
1089 struct GSF_LocalClient *lc = cls;
1090
1093}
void GNUNET_FS_indexing_send_list(struct GNUNET_MQ_Handle *mq)
Transmit information about indexed files to mq.

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 1103 of file gnunet-service-fs.c.

1105{
1106 struct GSF_LocalClient *lc = cls;
1107 struct GNUNET_MQ_Envelope *env;
1108 struct GNUNET_MessageHeader *msg;
1109 int found;
1110
1111 GNUNET_break (0 == um->reserved);
1114 "Client requested unindexing of file `%s': %s\n",
1115 GNUNET_h2s (&um->file_id),
1116 found ? "found" : "not found");
1119 GNUNET_MQ_send (lc->mq,
1120 env);
1122}
int GNUNET_FS_indexing_do_unindex(const struct GNUNET_HashCode *fid)
Remove a file from the index.
#define GNUNET_MESSAGE_TYPE_FS_UNINDEX_OK
Reply to client indicating unindex receipt.
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

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 1131 of file gnunet-service-fs.c.

1132{
1134 if (NULL != GSF_core)
1135 {
1137 GSF_core = NULL;
1138 }
1139 GSF_put_done_ ();
1140 GSF_push_done_ ();
1142 GSF_plan_done ();
1145 GNUNET_NO);
1146 GSF_dsh = NULL;
1148 GSF_dht = NULL;
1150 GSF_block_ctx = NULL;
1152 block_cfg = NULL;
1154 GSF_stats = NULL;
1155 if (NULL != cover_age_task)
1156 {
1158 cover_age_task = NULL;
1159 }
1162 datastore_get_load = NULL;
1164 GSF_rt_entry_lifetime = NULL;
1165}
struct GNUNET_BLOCK_Context * GSF_block_ctx
Our block context.
struct GNUNET_DHT_Handle * GSF_dht
Handle for DHT operations.
struct GNUNET_CORE_Handle * GSF_core
Pointer to handle to the core service (points to NULL until we've connected to it).
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.
static struct GNUNET_CONFIGURATION_Handle * block_cfg
Configuration for block library.
void GSF_cadet_stop_server(void)
Shutdown subsystem for non-anonymous file-sharing.
void GSF_connected_peer_done_()
Shutdown peer management subsystem.
void GNUNET_FS_indexing_done()
Shutdown the module.
void GSF_plan_done()
Shutdown plan subsystem.
void GSF_pending_request_done_()
Shutdown the subsystem.
void GSF_push_done_()
Shutdown the module.
void GSF_put_done_()
Shutdown the module.
void GNUNET_BLOCK_context_destroy(struct GNUNET_BLOCK_Context *ctx)
Destroy the block context.
Definition: block.c:158
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
void GNUNET_CORE_disconnect(struct GNUNET_CORE_Handle *handle)
Disconnect from the core service.
Definition: core_api.c:729
void GNUNET_DATASTORE_disconnect(struct GNUNET_DATASTORE_Handle *h, int drop)
Disconnect from the datastore service (and free associated resources).
void GNUNET_DHT_disconnect(struct GNUNET_DHT_Handle *handle)
Shutdown connection with the DHT service.
Definition: dht_api.c:1053
#define GNUNET_LOAD_value_free(lv)
Free a load value.
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).

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_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_plan_done(), GSF_push_done_(), GSF_put_done_(), GSF_rt_entry_lifetime, and GSF_stats.

Referenced by main_init(), and run().

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

◆ peer_init_handler()

static void peer_init_handler ( void *  cls,
const struct GNUNET_PeerIdentity my_identity 
)
static

Function called after GNUNET_CORE_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

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

1181{
1182 if (0 != GNUNET_memcmp (&GSF_my_id,
1183 my_identity))
1184 {
1186 "Peer identity mismatch, refusing to start!\n");
1188 }
1189}
struct GNUNET_PeerIdentity my_identity
Our peer identity.
struct GNUNET_PeerIdentity GSF_my_id
Identity of this peer.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
@ GNUNET_ERROR_TYPE_ERROR
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:567

References GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_memcmp, GNUNET_SCHEDULER_shutdown(), GSF_my_id, and my_identity.

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 1198 of file gnunet-service-fs.c.

1199{
1200 struct GNUNET_MQ_MessageHandler no_p2p_handlers[] = {
1202 };
1203 struct GNUNET_MQ_MessageHandler p2p_handlers[] = {
1204 GNUNET_MQ_hd_var_size (p2p_get,
1206 struct GetMessage,
1207 NULL),
1208 GNUNET_MQ_hd_var_size (p2p_put,
1210 struct PutMessage,
1211 NULL),
1212 GNUNET_MQ_hd_fixed_size (p2p_migration_stop,
1214 struct MigrationStopMessage,
1215 NULL),
1217 };
1218 int anon_p2p_off;
1219 char *keyfile;
1220
1221 /* this option is really only for testcases that need to disable
1222 _anonymous_ file-sharing for some reason */
1223 anon_p2p_off = (GNUNET_YES ==
1225 "fs",
1226 "DISABLE_ANON_TRANSFER")
1227 );
1228
1229 if (GNUNET_OK !=
1231 "PEER",
1232 "PRIVATE_KEY",
1233 &keyfile))
1234 {
1236 _ (
1237 "FS service is lacking HOSTKEY configuration setting. Exiting.\n"));
1239 return GNUNET_SYSERR;
1240 }
1241 if (GNUNET_SYSERR ==
1243 GNUNET_YES,
1244 &pk))
1245 {
1247 "Failed to setup peer's private key\n");
1249 GNUNET_free (keyfile);
1250 return GNUNET_SYSERR;
1251 }
1252 GNUNET_free (keyfile);
1255
1257 "I am peer %s\n",
1259 GSF_core
1261 NULL,
1265 (GNUNET_YES == anon_p2p_off)
1266 ? no_p2p_handlers
1267 : p2p_handlers);
1268 if (NULL == GSF_core)
1269 {
1271 _ ("Failed to connect to `%s' service.\n"),
1272 "core");
1273 return GNUNET_SYSERR;
1274 }
1278 NULL);
1282 NULL);
1283 return GNUNET_OK;
1284}
static void shutdown_task(void *cls)
Task run during shutdown.
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).
const struct GNUNET_CONFIGURATION_Handle * GSF_cfg
Our configuration.
#define DATASTORE_LOAD_AUTODECLINE
At what frequency should our datastore load decrease automatically (since if we don't use it,...
void GSF_cadet_start_server(void)
Initialize subsystem for non-anonymous file-sharing.
void GSF_peer_disconnect_handler(void *cls, const struct GNUNET_PeerIdentity *peer, void *internal_cls)
A peer disconnected from us.
void * GSF_peer_connect_handler(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
A peer connected to us.
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.
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)
Connect to the core service.
Definition: core_api.c:691
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
struct GNUNET_LOAD_Value * GNUNET_LOAD_value_init(struct GNUNET_TIME_Relative autodecline)
Create a new load value.
Definition: load.c:124
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
#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.
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
Message handler for a specific message type.
struct GNUNET_CRYPTO_EddsaPublicKey public_key
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

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_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_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(), peer_init_handler(), pk, GNUNET_PeerIdentity::public_key, 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 1295 of file gnunet-service-fs.c.

1298{
1299 unsigned long long dqs;
1300
1301 GSF_cfg = cfg;
1302 if (GNUNET_OK !=
1304 "fs",
1305 "DATASTORE_QUEUE_SIZE",
1306 &dqs))
1307 {
1309 "fs",
1310 "DATASTORE_QUEUE_SIZE");
1311 dqs = 32;
1312 }
1313 GSF_datastore_queue_size = (unsigned int) dqs;
1317 if (NULL == GSF_dsh)
1318 {
1320 return;
1321 }
1326 GNUNET_assert (NULL != GSF_block_ctx);
1328 GSF_plan_init ();
1331
1332 GSF_push_init_ ();
1333 GSF_put_init_ ();
1335 GSF_dsh)) ||
1336 (GNUNET_OK != main_init (cfg)))
1337 {
1339 shutdown_task (NULL);
1340 return;
1341 }
1342}
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:108
int GSF_enable_randomized_delays
Are we introducing randomized delays for better anonymity?
static int main_init(const struct GNUNET_CONFIGURATION_Handle *c)
Process fs requests.
#define FS_DHT_HT_SIZE
Size for the hash map for DHT requests from the FS service.
unsigned int GSF_datastore_queue_size
Size of the datastore queue we assume for common requests.
void GSF_connected_peer_init_()
Initialize peer management subsystem.
int GNUNET_FS_indexing_init(const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_DATASTORE_Handle *d)
Initialize the indexing submodule.
void GSF_plan_init()
Initialize plan subsystem.
void GSF_pending_request_init_()
Setup the subsystem.
void GSF_push_init_()
Setup the module.
void GSF_put_init_()
Setup the module.
struct GNUNET_BLOCK_Context * GNUNET_BLOCK_context_create(const struct GNUNET_CONFIGURATION_Handle *cfg)
Create a block context.
Definition: block.c:140
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_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_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_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
@ GNUNET_ERROR_TYPE_INFO
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_gnunet(void)
Return default project data used by 'libgnunetutil' for GNUnet.
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".

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, consensus-simulation::int, 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 236 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 241 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 247 of file gnunet-service-fs.c.

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 260 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 265 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 271 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 277 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 288 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 293 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 298 of file gnunet-service-fs.c.

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

◆ block_cfg

struct GNUNET_CONFIGURATION_Handle* block_cfg
static

Configuration for block library.

Definition at line 305 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 310 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 315 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 320 of file gnunet-service-fs.c.

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