GNUnet  0.11.x
Data Structures | Macros | Functions
fs_search.c File Reference

Helper functions for searching. More...

#include "platform.h"
#include "gnunet_constants.h"
#include "gnunet_fs_service.h"
#include "gnunet_protocols.h"
#include "fs_api.h"
#include "fs_publish_ublock.h"
Include dependency graph for fs_search.c:

Go to the source code of this file.

Data Structures

struct  GetResultContext
 Context for "get_result_present". More...
 
struct  MessageBuilderContext
 Closure for build_result_set(). More...
 

Macros

#define AVAILABILITY_TRIALS_MAX   8
 Number of availability trials we perform per search result. More...
 

Functions

void * GNUNET_FS_search_make_status_ (struct GNUNET_FS_ProgressInfo *pi, struct GNUNET_FS_Handle *h, struct GNUNET_FS_SearchContext *sc)
 Fill in all of the generic fields for a search event and call the callback. More...
 
static int test_result_present (void *cls, const struct GNUNET_HashCode *key, void *value)
 Check if the given result is identical to the given URI. More...
 
static void notify_client_chk_result (struct GNUNET_FS_SearchContext *sc, struct GNUNET_FS_SearchResult *sr)
 We've found a new CHK result. More...
 
static void notify_client_chk_update (struct GNUNET_FS_SearchContext *sc, struct GNUNET_FS_SearchResult *sr)
 We've found new information about an existing CHK result. More...
 
static int get_result_present (void *cls, const struct GNUNET_HashCode *key, void *value)
 Check if the given result is identical to the given URI and if so return it. More...
 
static void signal_probe_result (struct GNUNET_FS_SearchResult *sr)
 Signal result of last probe to client and then schedule next probe. More...
 
static void probe_failure_handler (void *cls)
 Handle the case where we have failed to receive a response for our probe. More...
 
static void probe_success_handler (void *cls)
 Handle the case where we have gotten a response for our probe. More...
 
void * GNUNET_FS_search_probe_progress_ (void *cls, const struct GNUNET_FS_ProgressInfo *info)
 Notification of FS that a search probe has made progress. More...
 
static void probe_ping_task_cb (void *cls)
 Task run periodically to remind clients that a probe is active. More...
 
static void start_probe_ping_task (struct GNUNET_FS_SearchResult *sr)
 Start the ping task for this search result. More...
 
void GNUNET_FS_stop_probe_ping_task_ (struct GNUNET_FS_SearchResult *sr)
 Stop the ping task for this search result. More...
 
void GNUNET_FS_search_start_probe_ (struct GNUNET_FS_SearchResult *sr)
 Start download probes for the given search result. More...
 
struct GNUNET_FS_SearchResultGNUNET_FS_probe (struct GNUNET_FS_Handle *h, const struct GNUNET_FS_Uri *uri, const struct GNUNET_CONTAINER_MetaData *meta, void *client_info, uint32_t anonymity)
 Start download probes for the given search result. More...
 
static void GNUNET_FS_search_stop_probe_ (struct GNUNET_FS_SearchResult *sr)
 Stop probing activity associated with a search result. More...
 
void * GNUNET_FS_probe_stop (struct GNUNET_FS_SearchResult *sr)
 Stop probe activity. More...
 
static void process_ksk_result (struct GNUNET_FS_SearchContext *sc, struct SearchRequestEntry *ent, const struct GNUNET_FS_Uri *uri, const struct GNUNET_CONTAINER_MetaData *meta)
 We have received a KSK result. More...
 
static struct GNUNET_FS_SearchContextsearch_start (struct GNUNET_FS_Handle *h, const struct GNUNET_FS_Uri *uri, uint32_t anonymity, enum GNUNET_FS_SearchOptions options, void *cctx, struct GNUNET_FS_SearchResult *psearch)
 Start search for content, internal API. More...
 
static void process_sks_result (struct GNUNET_FS_SearchContext *sc, const char *id_update, const struct GNUNET_FS_Uri *uri, const struct GNUNET_CONTAINER_MetaData *meta)
 We have received an SKS result. More...
 
static int decrypt_block_with_keyword (const struct GNUNET_FS_SearchContext *sc, const struct GNUNET_CRYPTO_EcdsaPublicKey *dpub, const void *edata, size_t edata_size, char *data)
 Decrypt a ublock using a 'keyword' as the passphrase. More...
 
static void process_kblock (struct GNUNET_FS_SearchContext *sc, const struct UBlock *ub, size_t size)
 Process a keyword search result. More...
 
static void process_sblock (struct GNUNET_FS_SearchContext *sc, const struct UBlock *ub, size_t size)
 Process a namespace-search result. More...
 
static void try_reconnect (struct GNUNET_FS_SearchContext *sc)
 Shutdown any existing connection to the FS service and try to establish a fresh one (and then re-transmit our search request). More...
 
static int check_result (void *cls, const struct ClientPutMessage *cm)
 We check a result message from the service. More...
 
static void handle_result (void *cls, const struct ClientPutMessage *cm)
 We process a search result from the service. More...
 
static void schedule_transmit_search_request (struct GNUNET_FS_SearchContext *sc)
 Schedule the transmission of the (next) search request to the service. More...
 
static int build_result_set (void *cls, const struct GNUNET_HashCode *key, void *value)
 Iterating over the known results, pick those matching the given result range and store their keys at 'xoff'. More...
 
static int find_result_set (void *cls, const struct GNUNET_HashCode *key, void *value)
 Iterating over the known results, count those matching the given result range and increment put count for each. More...
 
static void search_mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
 Generic error handler, called with the appropriate error code and the same closure specified at the creation of the message queue. More...
 
static void do_reconnect (void *cls)
 Reconnect to the FS service and transmit our queries NOW. More...
 
static int update_sre_result_maps (void *cls, const struct GNUNET_HashCode *key, void *value)
 Update the 'results' map for the individual keywords with the results from the 'global' result set. More...
 
int GNUNET_FS_search_start_searching_ (struct GNUNET_FS_SearchContext *sc)
 Build the request and actually initiate the search using the GNUnet FS service. More...
 
static int search_result_freeze_probes (void *cls, const struct GNUNET_HashCode *key, void *value)
 Freeze probes for the given search result. More...
 
static int search_result_resume_probes (void *cls, const struct GNUNET_HashCode *key, void *value)
 Resume probes for the given search result. More...
 
static int search_result_suspend (void *cls, const struct GNUNET_HashCode *key, void *value)
 Signal suspend and free the given search result. More...
 
void GNUNET_FS_search_signal_suspend_ (void *cls)
 Create SUSPEND event for the given search operation and then clean up our state (without stop signal). More...
 
struct GNUNET_FS_SearchContextGNUNET_FS_search_start (struct GNUNET_FS_Handle *h, const struct GNUNET_FS_Uri *uri, uint32_t anonymity, enum GNUNET_FS_SearchOptions options, void *cctx)
 Start search for content. More...
 
void GNUNET_FS_search_pause (struct GNUNET_FS_SearchContext *sc)
 Pause search. More...
 
void GNUNET_FS_search_continue (struct GNUNET_FS_SearchContext *sc)
 Continue paused search. More...
 
static int search_result_stop (void *cls, const struct GNUNET_HashCode *key, void *value)
 Signal stop for the given search result. More...
 
static int search_result_free (void *cls, const struct GNUNET_HashCode *key, void *value)
 Free the given search result. More...
 
void GNUNET_FS_search_stop (struct GNUNET_FS_SearchContext *sc)
 Stop search for content. More...
 

Detailed Description

Helper functions for searching.

Author
Christian Grothoff

Definition in file fs_search.c.

Macro Definition Documentation

◆ AVAILABILITY_TRIALS_MAX

#define AVAILABILITY_TRIALS_MAX   8

Number of availability trials we perform per search result.

Definition at line 36 of file fs_search.c.

Referenced by GNUNET_FS_search_start_probe_().

Function Documentation

◆ GNUNET_FS_search_make_status_()

void* GNUNET_FS_search_make_status_ ( struct GNUNET_FS_ProgressInfo pi,
struct GNUNET_FS_Handle h,
struct GNUNET_FS_SearchContext sc 
)

Fill in all of the generic fields for a search event and call the callback.

Parameters
pistructure to fill in
hfile-sharing handle
scoverall search context
Returns
value returned by the callback

Definition at line 48 of file fs_search.c.

References GNUNET_FS_SearchContext::anonymity, GNUNET_FS_SearchResult::client_info, GNUNET_FS_SearchContext::client_info, GNUNET_FS_ProgressInfo::fsh, GNUNET_TIME_absolute_get_duration(), GNUNET_TIME_UNIT_ZERO, GNUNET_FS_SearchContext::psearch_result, ret, sc, GNUNET_FS_ProgressInfo::search, GNUNET_FS_SearchContext::start_time, GNUNET_FS_Handle::upcb, GNUNET_FS_Handle::upcb_cls, GNUNET_FS_SearchContext::uri, and GNUNET_FS_ProgressInfo::value.

Referenced by GNUNET_FS_search_continue(), GNUNET_FS_search_pause(), GNUNET_FS_search_signal_suspend_(), GNUNET_FS_search_stop(), notify_client_chk_result(), notify_client_chk_update(), search_result_stop(), search_result_suspend(), search_start(), signal_probe_result(), signal_result_resume(), and signal_search_resume().

51 {
52  void *ret;
53 
54  pi->value.search.sc = sc;
55  pi->value.search.cctx = (NULL != sc) ? sc->client_info : NULL;
56  pi->value.search.pctx =
57  ((NULL == sc) || (NULL == sc->psearch_result))
58  ? NULL
60  pi->value.search.query = (NULL != sc) ? sc->uri : NULL;
61  pi->value.search.duration = (NULL != sc)
63  sc->start_time)
65  pi->value.search.anonymity = (NULL != sc) ? sc->anonymity : 0;
66  pi->fsh = h;
67  ret = h->upcb (h->upcb_cls, pi);
68  return ret;
69 }
void * client_info
Client info for this search result.
Definition: fs_api.h:533
struct GNUNET_FS_SearchResult * psearch_result
For update-searches, link to the search result that triggered the update search; otherwise NULL...
Definition: fs_api.h:1530
struct GNUNET_TIME_Absolute start_time
When did we start?
Definition: fs_api.h:1569
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
struct GNUNET_FS_Uri * uri
List of keywords that we're looking for.
Definition: fs_api.h:1524
uint32_t anonymity
Anonymity level for the search.
Definition: fs_api.h:1587
union GNUNET_FS_ProgressInfo::@25 value
Values that depend on the event type.
struct GNUNET_FS_ProgressInfo::@25::@28 search
Values for all "GNUNET_FS_STATUS_SEARCH_*" events.
static struct GNUNET_FS_SearchContext * sc
Definition: gnunet-search.c:37
#define GNUNET_TIME_UNIT_ZERO
Relative time zero.
struct GNUNET_FS_Handle * fsh
File-sharing handle that generated the event.
GNUNET_FS_ProgressCallback upcb
Function to call with updates on our progress.
Definition: fs_api.h:1083
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:375
void * upcb_cls
Closure for upcb.
Definition: fs_api.h:1088
void * client_info
Pointer we keep for the client.
Definition: fs_api.h:1540
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_result_present()

static int test_result_present ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Check if the given result is identical to the given URI.

Parameters
clspoints to the URI we check against
keynot used
valuea struct GNUNET_FS_SearchResult who's URI we should compare with
Returns
GNUNET_SYSERR if the result is present, GNUNET_OK otherwise

Definition at line 83 of file fs_search.c.

References GNUNET_FS_uri_test_equal(), GNUNET_OK, GNUNET_SYSERR, uri, GNUNET_FS_SearchResult::uri, and value.

Referenced by process_ksk_result(), and process_sks_result().

86 {
87  const struct GNUNET_FS_Uri *uri = cls;
88  struct GNUNET_FS_SearchResult *sr = value;
89 
90  if (GNUNET_FS_uri_test_equal (uri, sr->uri))
91  return GNUNET_SYSERR;
92  return GNUNET_OK;
93 }
struct GNUNET_FS_Uri * uri
URI to which this search result refers to.
Definition: fs_api.h:523
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
int GNUNET_FS_uri_test_equal(const struct GNUNET_FS_Uri *u1, const struct GNUNET_FS_Uri *u2)
Test if two URIs are equal.
Definition: fs_uri.c:1212
static struct GNUNET_FS_Uri * uri
Value of URI provided on command-line (when not publishing a file but just creating UBlocks to refer ...
static char * value
Value of the record to add/remove.
Information we store for each search result.
Definition: fs_api.h:497
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
A Universal Resource Identifier (URI), opaque.
Definition: fs_api.h:165
Here is the call graph for this function:
Here is the caller graph for this function:

◆ notify_client_chk_result()

static void notify_client_chk_result ( struct GNUNET_FS_SearchContext sc,
struct GNUNET_FS_SearchResult sr 
)
static

We've found a new CHK result.

Let the client know about it.

Parameters
scthe search context
srthe specific result

Definition at line 104 of file fs_search.c.

References GNUNET_FS_SearchResult::client_info, GNUNET_FS_search_make_status_(), GNUNET_FS_STATUS_SEARCH_RESULT, GNUNET_FS_SearchContext::h, GNUNET_FS_SearchResult::meta, GNUNET_FS_SearchResult::optional_support, GNUNET_FS_ProgressInfo::search, GNUNET_FS_ProgressInfo::status, GNUNET_FS_SearchResult::uri, and GNUNET_FS_ProgressInfo::value.

Referenced by process_ksk_result(), and process_sks_result().

106 {
107  struct GNUNET_FS_ProgressInfo pi;
108 
110  pi.value.search.specifics.result.meta = sr->meta;
111  pi.value.search.specifics.result.uri = sr->uri;
112  pi.value.search.specifics.result.result = sr;
113  pi.value.search.specifics.result.applicability_rank = sr->optional_support;
114  sr->client_info = GNUNET_FS_search_make_status_ (&pi, sc->h, sc);
115 }
void * client_info
Client info for this search result.
Definition: fs_api.h:533
uint32_t optional_support
Number of optional keywords under which this result was also found.
Definition: fs_api.h:601
This search has yielded a result.
struct GNUNET_FS_Uri * uri
URI to which this search result refers to.
Definition: fs_api.h:523
static struct GNUNET_PEERINFO_Handle * pi
Handle to peerinfo service.
struct GNUNET_CONTAINER_MetaData * meta
Metadata for the search result.
Definition: fs_api.h:528
struct GNUNET_FS_Handle * h
Handle to the global FS context.
Definition: fs_api.h:1514
void * GNUNET_FS_search_make_status_(struct GNUNET_FS_ProgressInfo *pi, struct GNUNET_FS_Handle *h, struct GNUNET_FS_SearchContext *sc)
Fill in all of the generic fields for a search event and call the callback.
Definition: fs_search.c:48
Argument given to the progress callback with information about what is going on.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ notify_client_chk_update()

static void notify_client_chk_update ( struct GNUNET_FS_SearchContext sc,
struct GNUNET_FS_SearchResult sr 
)
static

We've found new information about an existing CHK result.

Let the client know about it.

Parameters
scthe search context
srthe specific result

Definition at line 126 of file fs_search.c.

References GNUNET_FS_SearchResult::availability_success, GNUNET_FS_SearchResult::availability_trials, GNUNET_FS_SearchResult::client_info, GNUNET_FS_search_make_status_(), GNUNET_FS_STATUS_SEARCH_UPDATE, GNUNET_TIME_absolute_get_duration(), GNUNET_FS_SearchContext::h, GNUNET_FS_SearchResult::meta, GNUNET_FS_SearchResult::optional_support, GNUNET_FS_SearchResult::probe_active_time, GNUNET_FS_ProgressInfo::search, GNUNET_FS_ProgressInfo::status, GNUNET_FS_SearchResult::uri, and GNUNET_FS_ProgressInfo::value.

Referenced by process_ksk_result().

128 {
129  struct GNUNET_FS_ProgressInfo pi;
130 
132  pi.value.search.specifics.update.cctx = sr->client_info;
133  pi.value.search.specifics.update.meta = sr->meta;
134  pi.value.search.specifics.update.uri = sr->uri;
135  pi.value.search.specifics.update.availability_rank =
137  pi.value.search.specifics.update.availability_certainty =
139  pi.value.search.specifics.update.applicability_rank = sr->optional_support;
140  pi.value.search.specifics.update.current_probe_time
142  sr->client_info = GNUNET_FS_search_make_status_ (&pi, sc->h, sc);
143 }
void * client_info
Client info for this search result.
Definition: fs_api.h:533
uint32_t optional_support
Number of optional keywords under which this result was also found.
Definition: fs_api.h:601
struct GNUNET_FS_Uri * uri
URI to which this search result refers to.
Definition: fs_api.h:523
static struct GNUNET_PEERINFO_Handle * pi
Handle to peerinfo service.
uint32_t availability_trials
Number of availability trials that we have performed for this search result.
Definition: fs_api.h:612
uint32_t availability_success
Number of availability tests that have succeeded for this result.
Definition: fs_api.h:606
struct GNUNET_CONTAINER_MetaData * meta
Metadata for the search result.
Definition: fs_api.h:528
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:375
struct GNUNET_FS_Handle * h
Handle to the global FS context.
Definition: fs_api.h:1514
struct GNUNET_TIME_Absolute probe_active_time
When did the current probe become active?
Definition: fs_api.h:578
We have additional data about the quality or availability of a search result.
void * GNUNET_FS_search_make_status_(struct GNUNET_FS_ProgressInfo *pi, struct GNUNET_FS_Handle *h, struct GNUNET_FS_SearchContext *sc)
Fill in all of the generic fields for a search event and call the callback.
Definition: fs_search.c:48
Argument given to the progress callback with information about what is going on.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_result_present()

static int get_result_present ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Check if the given result is identical to the given URI and if so return it.

Parameters
clsa struct GetResultContext
keynot used
valuea struct GNUNET_FS_SearchResult who's URI we should compare with
Returns
GNUNET_OK

Definition at line 175 of file fs_search.c.

References GNUNET_FS_uri_test_equal(), GNUNET_OK, GetResultContext::sr, GetResultContext::uri, GNUNET_FS_SearchResult::uri, and value.

Referenced by process_ksk_result().

178 {
179  struct GetResultContext *grc = cls;
180  struct GNUNET_FS_SearchResult *sr = value;
181 
182  if (GNUNET_FS_uri_test_equal (grc->uri, sr->uri))
183  grc->sr = sr;
184  return GNUNET_OK;
185 }
struct GNUNET_FS_Uri * uri
URI to which this search result refers to.
Definition: fs_api.h:523
Context for "get_result_present".
Definition: fs_search.c:149
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
int GNUNET_FS_uri_test_equal(const struct GNUNET_FS_Uri *u1, const struct GNUNET_FS_Uri *u2)
Test if two URIs are equal.
Definition: fs_uri.c:1212
struct GNUNET_FS_SearchResult * sr
Where to store a pointer to the search result struct if we found a match.
Definition: fs_search.c:160
static char * value
Value of the record to add/remove.
Information we store for each search result.
Definition: fs_api.h:497
const struct GNUNET_FS_Uri * uri
The URI we're looking for.
Definition: fs_search.c:154
Here is the call graph for this function:
Here is the caller graph for this function:

◆ signal_probe_result()

static void signal_probe_result ( struct GNUNET_FS_SearchResult sr)
static

Signal result of last probe to client and then schedule next probe.

Parameters
srsearch result to signal for

Definition at line 195 of file fs_search.c.

References GNUNET_FS_SearchResult::availability_success, GNUNET_FS_SearchResult::availability_trials, GNUNET_FS_SearchResult::client_info, GNUNET_FS_search_make_status_(), GNUNET_FS_search_start_probe_(), GNUNET_FS_STATUS_SEARCH_UPDATE, GNUNET_TIME_absolute_get_duration(), GNUNET_FS_SearchResult::h, GNUNET_FS_SearchResult::meta, GNUNET_FS_SearchResult::optional_support, GNUNET_FS_SearchResult::probe_active_time, GNUNET_FS_SearchResult::sc, GNUNET_FS_ProgressInfo::search, GNUNET_FS_ProgressInfo::status, GNUNET_FS_SearchResult::uri, and GNUNET_FS_ProgressInfo::value.

Referenced by probe_failure_handler(), probe_ping_task_cb(), and probe_success_handler().

196 {
197  struct GNUNET_FS_ProgressInfo pi;
198 
200  pi.value.search.specifics.update.cctx = sr->client_info;
201  pi.value.search.specifics.update.meta = sr->meta;
202  pi.value.search.specifics.update.uri = sr->uri;
203  pi.value.search.specifics.update.availability_rank
205  pi.value.search.specifics.update.availability_certainty
206  = sr->availability_trials;
207  pi.value.search.specifics.update.applicability_rank = sr->optional_support;
208  pi.value.search.specifics.update.current_probe_time
210  sr->client_info = GNUNET_FS_search_make_status_ (&pi, sr->h, sr->sc);
212 }
void * client_info
Client info for this search result.
Definition: fs_api.h:533
uint32_t optional_support
Number of optional keywords under which this result was also found.
Definition: fs_api.h:601
struct GNUNET_FS_SearchContext * sc
Search context this result belongs to; can be NULL for probes that come from a directory result...
Definition: fs_api.h:518
struct GNUNET_FS_Uri * uri
URI to which this search result refers to.
Definition: fs_api.h:523
static struct GNUNET_PEERINFO_Handle * pi
Handle to peerinfo service.
uint32_t availability_trials
Number of availability trials that we have performed for this search result.
Definition: fs_api.h:612
struct GNUNET_FS_Handle * h
File-sharing context this result belongs to.
Definition: fs_api.h:502
uint32_t availability_success
Number of availability tests that have succeeded for this result.
Definition: fs_api.h:606
struct GNUNET_CONTAINER_MetaData * meta
Metadata for the search result.
Definition: fs_api.h:528
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:375
struct GNUNET_TIME_Absolute probe_active_time
When did the current probe become active?
Definition: fs_api.h:578
We have additional data about the quality or availability of a search result.
void * GNUNET_FS_search_make_status_(struct GNUNET_FS_ProgressInfo *pi, struct GNUNET_FS_Handle *h, struct GNUNET_FS_SearchContext *sc)
Fill in all of the generic fields for a search event and call the callback.
Definition: fs_search.c:48
void GNUNET_FS_search_start_probe_(struct GNUNET_FS_SearchResult *sr)
Start download probes for the given search result.
Definition: fs_search.c:430
Argument given to the progress callback with information about what is going on.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ probe_failure_handler()

static void probe_failure_handler ( void *  cls)
static

Handle the case where we have failed to receive a response for our probe.

Parameters
clsour struct GNUNET_FS_SearchResult *

Definition at line 221 of file fs_search.c.

References GNUNET_FS_SearchResult::availability_trials, GNUNET_ERROR_TYPE_DEBUG, GNUNET_FS_download_stop(), GNUNET_FS_search_result_sync_(), GNUNET_FS_stop_probe_ping_task_(), GNUNET_log, GNUNET_YES, GNUNET_FS_SearchResult::probe_cancel_task, GNUNET_FS_SearchResult::probe_ctx, signal_probe_result(), and GetResultContext::sr.

Referenced by GNUNET_FS_search_probe_progress_().

222 {
223  struct GNUNET_FS_SearchResult *sr = cls;
224 
225  sr->probe_cancel_task = NULL;
226  sr->availability_trials++;
228  sr->probe_ctx = NULL;
232  "Probe #%u for search result %p failed\n",
234  sr);
235  signal_probe_result (sr);
236 }
static void signal_probe_result(struct GNUNET_FS_SearchResult *sr)
Signal result of last probe to client and then schedule next probe.
Definition: fs_search.c:195
struct GNUNET_FS_DownloadContext * probe_ctx
ID of a job that is currently probing this results' availability (NULL if we are not currently probin...
Definition: fs_api.h:539
uint32_t availability_trials
Number of availability trials that we have performed for this search result.
Definition: fs_api.h:612
Information we store for each search result.
Definition: fs_api.h:497
void GNUNET_FS_stop_probe_ping_task_(struct GNUNET_FS_SearchResult *sr)
Stop the ping task for this search result.
Definition: fs_search.c:409
void GNUNET_FS_search_result_sync_(struct GNUNET_FS_SearchResult *sr)
Synchronize this search result with its mirror on disk.
Definition: fs_api.c:2076
void GNUNET_FS_download_stop(struct GNUNET_FS_DownloadContext *dc, int do_delete)
Stop a download (aborts if download is incomplete).
Definition: fs_download.c:2333
#define GNUNET_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:77
struct GNUNET_SCHEDULER_Task * probe_cancel_task
ID of the task that will clean up the probe_ctx should it not complete on time (and that will need to...
Definition: fs_api.h:573
Here is the call graph for this function:
Here is the caller graph for this function:

◆ probe_success_handler()

static void probe_success_handler ( void *  cls)
static

Handle the case where we have gotten a response for our probe.

Parameters
clsour struct GNUNET_FS_SearchResult *

Definition at line 245 of file fs_search.c.

References GNUNET_FS_SearchResult::availability_success, GNUNET_FS_SearchResult::availability_trials, GNUNET_ERROR_TYPE_DEBUG, GNUNET_FS_download_stop(), GNUNET_FS_search_result_sync_(), GNUNET_FS_stop_probe_ping_task_(), GNUNET_log, GNUNET_YES, GNUNET_FS_SearchResult::probe_cancel_task, GNUNET_FS_SearchResult::probe_ctx, signal_probe_result(), and GetResultContext::sr.

Referenced by GNUNET_FS_search_probe_progress_().

246 {
247  struct GNUNET_FS_SearchResult *sr = cls;
248 
249  sr->probe_cancel_task = NULL;
250  sr->availability_trials++;
251  sr->availability_success++;
253  sr->probe_ctx = NULL;
257  "Probe #%u for search result %p succeeded\n",
259  sr);
260  signal_probe_result (sr);
261 }
static void signal_probe_result(struct GNUNET_FS_SearchResult *sr)
Signal result of last probe to client and then schedule next probe.
Definition: fs_search.c:195
struct GNUNET_FS_DownloadContext * probe_ctx
ID of a job that is currently probing this results' availability (NULL if we are not currently probin...
Definition: fs_api.h:539
uint32_t availability_trials
Number of availability trials that we have performed for this search result.
Definition: fs_api.h:612
Information we store for each search result.
Definition: fs_api.h:497
uint32_t availability_success
Number of availability tests that have succeeded for this result.
Definition: fs_api.h:606
void GNUNET_FS_stop_probe_ping_task_(struct GNUNET_FS_SearchResult *sr)
Stop the ping task for this search result.
Definition: fs_search.c:409
void GNUNET_FS_search_result_sync_(struct GNUNET_FS_SearchResult *sr)
Synchronize this search result with its mirror on disk.
Definition: fs_api.c:2076
void GNUNET_FS_download_stop(struct GNUNET_FS_DownloadContext *dc, int do_delete)
Stop a download (aborts if download is incomplete).
Definition: fs_download.c:2333
#define GNUNET_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:77
struct GNUNET_SCHEDULER_Task * probe_cancel_task
ID of the task that will clean up the probe_ctx should it not complete on time (and that will need to...
Definition: fs_api.h:573
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_search_probe_progress_()

void* GNUNET_FS_search_probe_progress_ ( void *  cls,
const struct GNUNET_FS_ProgressInfo info 
)

Notification of FS that a search probe has made progress.

This function is used INSTEAD of the client's event handler for downloads where the GNUNET_FS_DOWNLOAD_IS_PROBE flag is set.

Parameters
clsclosure, always NULL (!), actual closure is in the client-context of the info struct
infodetails about the event, specifying the event type and various bits about the event
Returns
client-context (for the next progress call for this operation; should be set to NULL for SUSPEND and STOPPED events). The value returned will be passed to future callbacks in the respective field in the struct GNUNET_FS_ProgressInfo.

Definition at line 280 of file fs_search.c.

References GNUNET_FS_ProgressInfo::download, GNUNET_assert, GNUNET_break, GNUNET_FS_search_result_sync_(), GNUNET_FS_STATUS_DOWNLOAD_ACTIVE, GNUNET_FS_STATUS_DOWNLOAD_COMPLETED, GNUNET_FS_STATUS_DOWNLOAD_ERROR, GNUNET_FS_STATUS_DOWNLOAD_INACTIVE, GNUNET_FS_STATUS_DOWNLOAD_PROGRESS, GNUNET_FS_STATUS_DOWNLOAD_RESUME, GNUNET_FS_STATUS_DOWNLOAD_START, GNUNET_FS_STATUS_DOWNLOAD_STOPPED, GNUNET_FS_STATUS_DOWNLOAD_SUSPEND, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_get_duration(), GNUNET_TIME_relative_subtract(), GNUNET_FS_SearchResult::probe_active_time, GNUNET_FS_SearchResult::probe_cancel_task, probe_failure_handler(), probe_success_handler(), GNUNET_TIME_Relative::rel_value_us, GNUNET_FS_SearchResult::remaining_probe_time, GetResultContext::sr, GNUNET_FS_ProgressInfo::status, and GNUNET_FS_ProgressInfo::value.

Referenced by GNUNET_FS_download_make_status_().

282 {
283  struct GNUNET_FS_SearchResult *sr = info->value.download.cctx;
284  struct GNUNET_TIME_Relative dur;
285 
286  switch (info->status)
287  {
289  /* ignore */
290  break;
292  /* probes should never be resumed */
293  GNUNET_assert (0);
294  break;
296  /* probes should never be suspended */
297  GNUNET_break (0);
298  break;
300  /* ignore */
301  break;
303  if (NULL != sr->probe_cancel_task)
304  {
306  sr->probe_cancel_task = NULL;
307  }
308  sr->probe_cancel_task =
310  &probe_failure_handler, sr);
311  break;
313  if (NULL != sr->probe_cancel_task)
314  {
316  sr->probe_cancel_task = NULL;
317  }
318  sr->probe_cancel_task =
320  break;
322  if (NULL != sr->probe_cancel_task)
323  {
325  sr->probe_cancel_task = NULL;
326  }
327  sr = NULL;
328  break;
330  if (NULL == sr->probe_cancel_task)
331  {
333  sr->probe_cancel_task =
335  &probe_failure_handler, sr);
336  }
337  break;
339  if (NULL != sr->probe_cancel_task)
340  {
342  sr->probe_cancel_task = NULL;
343  }
347  if (0 == sr->remaining_probe_time.rel_value_us)
348  sr->probe_cancel_task =
351  break;
352 
353  default:
354  GNUNET_break (0);
355  return NULL;
356  }
357  return sr;
358 }
Notification that we have started this download.
uint64_t rel_value_us
The actual value.
struct GNUNET_FS_ProgressInfo::@25::@27 download
Values for all "GNUNET_FS_STATUS_DOWNLOAD_*" events.
Notification that this download was suspended.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static void probe_failure_handler(void *cls)
Handle the case where we have failed to receive a response for our probe.
Definition: fs_search.c:221
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Notification that this download completed.
union GNUNET_FS_ProgressInfo::@25 value
Values that depend on the event type.
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:1253
struct GNUNET_TIME_Relative remaining_probe_time
How much longer should we run the current probe before giving up?
Definition: fs_api.h:583
Information we store for each search result.
Definition: fs_api.h:497
static void probe_success_handler(void *cls)
Handle the case where we have gotten a response for our probe.
Definition: fs_search.c:245
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:1280
enum GNUNET_FS_Status status
Specific status code (determines the event type).
void GNUNET_FS_search_result_sync_(struct GNUNET_FS_SearchResult *sr)
Synchronize this search result with its mirror on disk.
Definition: fs_api.c:2076
struct GNUNET_TIME_Relative GNUNET_TIME_relative_subtract(struct GNUNET_TIME_Relative a1, struct GNUNET_TIME_Relative a2)
Subtract relative timestamp from the other.
Definition: time.c:604
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
Notification that this download is no longer actively being pursued (back in the queue).
Notification about progress with this download.
Notification that this download is now actively being pursued (as opposed to waiting in the queue)...
Notification that this download is being resumed.
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:375
struct GNUNET_TIME_Absolute probe_active_time
When did the current probe become active?
Definition: fs_api.h:578
Notification that this download was stopped (final event with respect to this action).
Notification that this download encountered an error.
Time for relative time used by GNUnet, in microseconds.
struct GNUNET_SCHEDULER_Task * probe_cancel_task
ID of the task that will clean up the probe_ctx should it not complete on time (and that will need to...
Definition: fs_api.h:573
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
Here is the call graph for this function:
Here is the caller graph for this function:

◆ probe_ping_task_cb()

static void probe_ping_task_cb ( void *  cls)
static

Task run periodically to remind clients that a probe is active.

Parameters
clsthe struct GNUNET_FS_SearchResult that we are probing for

Definition at line 367 of file fs_search.c.

References GNUNET_FS_PROBE_UPDATE_FREQUENCY, GNUNET_SCHEDULER_add_delayed(), h, GNUNET_FS_DownloadContext::mq, GNUNET_FS_SearchResult::next, GNUNET_FS_SearchResult::probe_ctx, GNUNET_FS_Handle::probe_ping_task, GNUNET_FS_Handle::probes_head, signal_probe_result(), and GetResultContext::sr.

Referenced by start_probe_ping_task().

368 {
369  struct GNUNET_FS_Handle *h = cls;
370 
371  for (struct GNUNET_FS_SearchResult *sr = h->probes_head;
372  NULL != sr;
373  sr = sr->next)
374  if (NULL != sr->probe_ctx->mq)
375  signal_probe_result (sr);
376  h->probe_ping_task
379  h);
380 }
static void signal_probe_result(struct GNUNET_FS_SearchResult *sr)
Signal result of last probe to client and then schedule next probe.
Definition: fs_search.c:195
Master context for most FS operations.
Definition: fs_api.h:1068
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
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:1253
Information we store for each search result.
Definition: fs_api.h:497
#define GNUNET_FS_PROBE_UPDATE_FREQUENCY
How often do we signal applications that a probe for a particular search result is running...
struct GNUNET_FS_SearchResult * next
Kept in a DLL while probing.
Definition: fs_api.h:507
struct GNUNET_SCHEDULER_Task * probe_ping_task
Task we use to report periodically to the application that certain search probes (from probes_head) a...
Definition: fs_api.h:1140
struct GNUNET_FS_SearchResult * probes_head
Head of active probes.
Definition: fs_api.h:1123
static void probe_ping_task_cb(void *cls)
Task run periodically to remind clients that a probe is active.
Definition: fs_search.c:367
Here is the call graph for this function:
Here is the caller graph for this function:

◆ start_probe_ping_task()

static void start_probe_ping_task ( struct GNUNET_FS_SearchResult sr)
static

Start the ping task for this search result.

Parameters
srresult to start pinging for.

Definition at line 389 of file fs_search.c.

References GNUNET_CONTAINER_DLL_insert, GNUNET_SCHEDULER_add_now(), h, GNUNET_FS_SearchResult::h, GNUNET_FS_Handle::probe_ping_task, probe_ping_task_cb(), GNUNET_FS_Handle::probes_head, and GNUNET_FS_Handle::probes_tail.

Referenced by GNUNET_FS_search_start_probe_().

390 {
391  struct GNUNET_FS_Handle *h = sr->h;
392 
394  h->probes_tail,
395  sr);
396  if (NULL == h->probe_ping_task)
397  h->probe_ping_task
399  h);
400 }
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
Master context for most FS operations.
Definition: fs_api.h:1068
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
struct GNUNET_FS_Handle * h
File-sharing context this result belongs to.
Definition: fs_api.h:502
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:1280
struct GNUNET_SCHEDULER_Task * probe_ping_task
Task we use to report periodically to the application that certain search probes (from probes_head) a...
Definition: fs_api.h:1140
struct GNUNET_FS_SearchResult * probes_head
Head of active probes.
Definition: fs_api.h:1123
struct GNUNET_FS_SearchResult * probes_tail
Tail of active probes.
Definition: fs_api.h:1128
static void probe_ping_task_cb(void *cls)
Task run periodically to remind clients that a probe is active.
Definition: fs_search.c:367
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_stop_probe_ping_task_()

void GNUNET_FS_stop_probe_ping_task_ ( struct GNUNET_FS_SearchResult sr)

Stop the ping task for this search result.

Parameters
srresult to start pinging for.

Definition at line 409 of file fs_search.c.

References GNUNET_CONTAINER_DLL_remove, GNUNET_SCHEDULER_cancel(), h, GNUNET_FS_SearchResult::h, GNUNET_FS_Handle::probe_ping_task, GNUNET_FS_Handle::probes_head, and GNUNET_FS_Handle::probes_tail.

Referenced by GNUNET_FS_download_start_from_search(), GNUNET_FS_search_stop_probe_(), probe_failure_handler(), probe_success_handler(), and search_result_freeze_probes().

410 {
411  struct GNUNET_FS_Handle *h = sr->h;
412 
414  h->probes_tail,
415  sr);
416  if (NULL == h->probes_head)
417  {
419  h->probe_ping_task = NULL;
420  }
421 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
Master context for most FS operations.
Definition: fs_api.h:1068
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
struct GNUNET_FS_Handle * h
File-sharing context this result belongs to.
Definition: fs_api.h:502
struct GNUNET_SCHEDULER_Task * probe_ping_task
Task we use to report periodically to the application that certain search probes (from probes_head) a...
Definition: fs_api.h:1140
struct GNUNET_FS_SearchResult * probes_head
Head of active probes.
Definition: fs_api.h:1123
struct GNUNET_FS_SearchResult * probes_tail
Tail of active probes.
Definition: fs_api.h:1128
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_search_start_probe_()

void GNUNET_FS_search_start_probe_ ( struct GNUNET_FS_SearchResult sr)

Start download probes for the given search result.

Parameters
srthe search result

Definition at line 430 of file fs_search.c.

References GNUNET_FS_SearchResult::anonymity, GNUNET_FS_SearchResult::availability_success, GNUNET_FS_SearchResult::availability_trials, AVAILABILITY_TRIALS_MAX, GNUNET_FS_Handle::avg_block_latency, DBLOCK_SIZE, GNUNET_FS_SearchResult::download, GNUNET_FS_Handle::flags, GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u32(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_FS_DOWNLOAD_IS_PROBE, GNUNET_FS_DOWNLOAD_NO_TEMPORARIES, GNUNET_FS_download_start(), GNUNET_FS_FLAGS_DO_PROBES, GNUNET_FS_URI_CHK, GNUNET_FS_uri_chk_get_file_size(), GNUNET_FS_URI_LOC, GNUNET_log, GNUNET_TIME_relative_saturating_multiply(), GNUNET_FS_SearchResult::h, len, GNUNET_FS_SearchResult::meta, GNUNET_FS_SearchResult::probe_ctx, GNUNET_FS_SearchResult::remaining_probe_time, start_probe_ping_task(), GNUNET_FS_Uri::type, and GNUNET_FS_SearchResult::uri.

Referenced by GNUNET_FS_probe(), process_ksk_result(), process_sks_result(), search_result_resume_probes(), signal_probe_result(), and signal_result_resume().

431 {
432  uint64_t off;
433  uint64_t len;
434 
435  if (NULL != sr->probe_ctx)
436  return;
437  if (NULL != sr->download)
438  return;
439  if (0 == (sr->h->flags & GNUNET_FS_FLAGS_DO_PROBES))
440  return;
442  return;
443  if ( (GNUNET_FS_URI_CHK != sr->uri->type) &&
444  (GNUNET_FS_URI_LOC != sr->uri->type) )
445  return;
447  if (0 == len)
448  return;
449  if ((len <= DBLOCK_SIZE) && (sr->availability_success > 0))
450  return;
451  off = len / DBLOCK_SIZE;
452  if (off > 0)
454  off *= DBLOCK_SIZE;
455  if (len - off < DBLOCK_SIZE)
456  len = len - off;
457  else
458  len = DBLOCK_SIZE;
460  "Starting probe #%u (at offset %llu) for search result %p\n",
461  sr->availability_trials + 1,
462  (unsigned long long) off,
463  sr);
466  2 * (1
467  + sr->availability_trials));
468  sr->probe_ctx =
469  GNUNET_FS_download_start (sr->h, sr->uri, sr->meta, NULL, NULL, off,
470  len, sr->anonymity,
472  | GNUNET_FS_DOWNLOAD_IS_PROBE, sr, NULL);
474 }
static void start_probe_ping_task(struct GNUNET_FS_SearchResult *sr)
Start the ping task for this search result.
Definition: fs_search.c:389
struct GNUNET_FS_DownloadContext * download
ID of an associated download based on this search result (or NULL for none).
Definition: fs_api.h:545
struct GNUNET_TIME_Relative avg_block_latency
Average time we take for a single request to be satisfied.
Definition: fs_api.h:1146
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
struct GNUNET_FS_Uri * uri
URI to which this search result refers to.
Definition: fs_api.h:523
struct GNUNET_FS_DownloadContext * probe_ctx
ID of a job that is currently probing this results&#39; availability (NULL if we are not currently probin...
Definition: fs_api.h:539
struct GNUNET_FS_DownloadContext * GNUNET_FS_download_start(struct GNUNET_FS_Handle *h, const struct GNUNET_FS_Uri *uri, const struct GNUNET_CONTAINER_MetaData *meta, const char *filename, const char *tempname, uint64_t offset, uint64_t length, uint32_t anonymity, enum GNUNET_FS_DownloadOptions options, void *cctx, struct GNUNET_FS_DownloadContext *parent)
Download parts of a file.
Definition: fs_download.c:2145
Do not append temporary data to the target file (for the IBlocks).
struct GNUNET_TIME_Relative remaining_probe_time
How much longer should we run the current probe before giving up?
Definition: fs_api.h:583
uint32_t availability_trials
Number of availability trials that we have performed for this search result.
Definition: fs_api.h:612
struct GNUNET_FS_Handle * h
File-sharing context this result belongs to.
Definition: fs_api.h:502
Should we automatically trigger probes for search results to determine availability? (will create GNUNET_FS_STATUS_SEARCH_UPDATE events).
uint32_t availability_success
Number of availability tests that have succeeded for this result.
Definition: fs_api.h:606
Internal option used to flag this download as a &#39;probe&#39; for a search result.
uint32_t anonymity
Anonymity level to use for probes using this search result.
Definition: fs_api.h:588
#define AVAILABILITY_TRIALS_MAX
Number of availability trials we perform per search result.
Definition: fs_search.c:36
#define DBLOCK_SIZE
Size of the individual blocks used for file-sharing.
Definition: fs.h:40
Content-hash-key (simple file).
Definition: fs_api.h:143
struct GNUNET_CONTAINER_MetaData * meta
Metadata for the search result.
Definition: fs_api.h:528
enum GNUNET_FS_UriType type
Type of the URI.
Definition: fs_api.h:170
uint64_t GNUNET_FS_uri_chk_get_file_size(const struct GNUNET_FS_Uri *uri)
What is the size of the file that this URI refers to?
Definition: fs_uri.c:1371
#define GNUNET_log(kind,...)
Location (chk with identity of hosting peer).
Definition: fs_api.h:158
struct GNUNET_TIME_Relative GNUNET_TIME_relative_saturating_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Saturating multiply relative time by a given factor.
Definition: time.c:501
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
enum GNUNET_FS_Flags flags
General flags.
Definition: fs_api.h:1161
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_search_stop_probe_()

static void GNUNET_FS_search_stop_probe_ ( struct GNUNET_FS_SearchResult sr)
static

Stop probing activity associated with a search result.

Parameters
srsearch result

Definition at line 515 of file fs_search.c.

References GNUNET_FS_download_stop(), GNUNET_FS_stop_probe_ping_task_(), GNUNET_SCHEDULER_cancel(), GNUNET_YES, GNUNET_FS_SearchResult::probe_cancel_task, and GNUNET_FS_SearchResult::probe_ctx.

Referenced by GNUNET_FS_probe_stop(), search_result_stop(), and search_result_suspend().

516 {
517  if (NULL != sr->probe_ctx)
518  {
520  sr->probe_ctx = NULL;
522  }
523  if (NULL != sr->probe_cancel_task)
524  {
526  sr->probe_cancel_task = NULL;
527  }
528 }
struct GNUNET_FS_DownloadContext * probe_ctx
ID of a job that is currently probing this results&#39; availability (NULL if we are not currently probin...
Definition: fs_api.h:539
void GNUNET_FS_stop_probe_ping_task_(struct GNUNET_FS_SearchResult *sr)
Stop the ping task for this search result.
Definition: fs_search.c:409
void GNUNET_FS_download_stop(struct GNUNET_FS_DownloadContext *dc, int do_delete)
Stop a download (aborts if download is incomplete).
Definition: fs_download.c:2333
#define GNUNET_YES
Definition: gnunet_common.h:77
struct GNUNET_SCHEDULER_Task * probe_cancel_task
ID of the task that will clean up the probe_ctx should it not complete on time (and that will need to...
Definition: fs_api.h:573
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_ksk_result()

static void process_ksk_result ( struct GNUNET_FS_SearchContext sc,
struct SearchRequestEntry ent,
const struct GNUNET_FS_Uri uri,
const struct GNUNET_CONTAINER_MetaData meta 
)
static

We have received a KSK result.

Check how it fits in with the overall query and notify the client accordingly.

Parameters
sccontext for the overall query
ententry for the specific keyword
urithe URI that was found
metametadata associated with the URI under the ent keyword

Definition at line 564 of file fs_search.c.

References anonymity, GNUNET_FS_SearchResult::anonymity, GNUNET_FS_SearchContext::anonymity, GNUNET_FS_SearchResult::client_info, GNUNET_FS_Uri::data, get_result_present(), GNUNET_assert, GNUNET_break, GNUNET_break_op, GNUNET_CONTAINER_meta_data_duplicate(), GNUNET_CONTAINER_meta_data_merge(), GNUNET_CONTAINER_multihashmap_get_multiple(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_multihashmap_size(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_FS_search_result_sync_(), GNUNET_FS_search_start_probe_(), GNUNET_FS_uri_dup(), GNUNET_FS_uri_to_key(), GNUNET_malloc, GNUNET_new, GNUNET_OK, GNUNET_SYSERR, h, GNUNET_FS_SearchResult::h, GNUNET_FS_SearchContext::h, key, GNUNET_FS_SearchResult::key, GNUNET_FS_SearchResult::keyword_bitmap, GNUNET_FS_Uri::ksk, SearchRequestEntry::mandatory, GNUNET_FS_SearchContext::mandatory_count, GNUNET_FS_SearchResult::mandatory_missing, GNUNET_FS_SearchContext::master_result_map, GNUNET_FS_SearchResult::meta, notify_client_chk_result(), notify_client_chk_update(), GNUNET_FS_SearchResult::optional_support, options, GNUNET_FS_SearchContext::requests, SearchRequestEntry::results, sc, GNUNET_FS_SearchResult::sc, search_start(), GetResultContext::sr, test_result_present(), GetResultContext::uri, GNUNET_FS_SearchResult::uri, and GNUNET_FS_SearchContext::uri.

Referenced by process_kblock().

568 {
569  struct GNUNET_HashCode key;
570  struct GNUNET_FS_SearchResult *sr;
571  struct GetResultContext grc;
572  int is_new;
573  unsigned int koff;
574 
575  /* check if new */
576  GNUNET_assert (NULL != sc);
577  if (GNUNET_OK !=
579  &key))
580  {
581  GNUNET_break_op (0);
582  return;
583  }
584  if (GNUNET_SYSERR ==
586  &key,
588  (void *) uri))
589  return; /* duplicate result */
590  /* try to find search result in master map */
591  grc.sr = NULL;
592  grc.uri = uri;
594  &key,
595  &get_result_present, &grc);
596  sr = grc.sr;
597  is_new = (NULL == sr) || (sr->mandatory_missing > 0);
598  if (NULL == sr)
599  {
600  sr = GNUNET_new (struct GNUNET_FS_SearchResult);
601  sr->h = sc->h;
602  sr->sc = sc;
603  sr->anonymity = sc->anonymity;
604  sr->uri = GNUNET_FS_uri_dup (uri);
607  sr->key = key;
608  sr->keyword_bitmap = GNUNET_malloc ((sc->uri->data.ksk.keywordCount + 7)
609  / 8); /* round up, count bits */
612  }
613  else
614  {
616  }
619  &sr->key,
620  sr,
622 
623  koff = ent - sc->requests;
624  GNUNET_assert ((ent >= sc->requests) &&
625  (koff < sc->uri->data.ksk.keywordCount));
626  sr->keyword_bitmap[koff / 8] |= (1 << (koff % 8));
627  /* check if mandatory satisfied */
629  {
630  if (ent->mandatory)
631  {
633  sr->mandatory_missing--;
634  }
635  else
636  {
637  sr->optional_support++;
638  }
639  }
640  if (0 != sr->mandatory_missing)
641  {
642  GNUNET_break (NULL == sr->client_info);
643  return;
644  }
645  if (is_new)
646  notify_client_chk_result (sc, sr);
647  else
648  notify_client_chk_update (sc, sr);
651 }
void * client_info
Client info for this search result.
Definition: fs_api.h:533
uint32_t optional_support
Number of optional keywords under which this result was also found.
Definition: fs_api.h:601
uint32_t mandatory_count
Number of mandatory keywords in this query.
Definition: fs_api.h:1592
unsigned int GNUNET_CONTAINER_multihashmap_size(const struct GNUNET_CONTAINER_MultiHashMap *map)
Get the number of key-value pairs in the map.
static void notify_client_chk_result(struct GNUNET_FS_SearchContext *sc, struct GNUNET_FS_SearchResult *sr)
We&#39;ve found a new CHK result.
Definition: fs_search.c:104
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_FS_SearchContext * sc
Search context this result belongs to; can be NULL for probes that come from a directory result...
Definition: fs_api.h:518
uint8_t * keyword_bitmap
Bitmap that specifies precisely which keywords have been matched already.
Definition: fs_api.h:561
int mandatory
Is this keyword a mandatory keyword (started with &#39;+&#39;)?
Definition: fs_api.h:1502
struct GNUNET_FS_Uri * uri
URI to which this search result refers to.
Definition: fs_api.h:523
static int test_result_present(void *cls, const struct GNUNET_HashCode *key, void *value)
Check if the given result is identical to the given URI.
Definition: fs_search.c:83
Context for "get_result_present".
Definition: fs_search.c:149
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
static int get_result_present(void *cls, const struct GNUNET_HashCode *key, void *value)
Check if the given result is identical to the given URI and if so return it.
Definition: fs_search.c:175
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_FS_Uri * GNUNET_FS_uri_dup(const struct GNUNET_FS_Uri *uri)
Duplicate URI.
Definition: fs_uri.c:998
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct SearchRequestEntry * requests
Per-keyword information for a keyword search.
Definition: fs_api.h:1564
struct GNUNET_FS_Uri * uri
List of keywords that we&#39;re looking for.
Definition: fs_api.h:1524
int GNUNET_FS_uri_to_key(const struct GNUNET_FS_Uri *uri, struct GNUNET_HashCode *key)
Get a unique key from a URI.
Definition: fs_uri.c:103
uint32_t anonymity
Anonymity level for the search.
Definition: fs_api.h:1587
static struct GNUNET_FS_Uri * uri
Value of URI provided on command-line (when not publishing a file but just creating UBlocks to refer ...
struct GNUNET_FS_SearchResult * sr
Where to store a pointer to the search result struct if we found a match.
Definition: fs_search.c:160
void GNUNET_CONTAINER_meta_data_merge(struct GNUNET_CONTAINER_MetaData *md, const struct GNUNET_CONTAINER_MetaData *in)
Extend metadata.
struct GNUNET_CONTAINER_MultiHashMap * master_result_map
Map that contains a struct GNUNET_FS_SearchResult for each result that was found in the search...
Definition: fs_api.h:1558
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
Information we store for each search result.
Definition: fs_api.h:497
struct GNUNET_FS_Handle * h
File-sharing context this result belongs to.
Definition: fs_api.h:502
void GNUNET_FS_search_result_sync_(struct GNUNET_FS_SearchResult *sr)
Synchronize this search result with its mirror on disk.
Definition: fs_api.c:2076
struct GNUNET_CONTAINER_MultiHashMap * results
Map that contains a "struct GNUNET_FS_SearchResult" for each result that was found under this keyword...
Definition: fs_api.h:1496
uint32_t anonymity
Anonymity level to use for probes using this search result.
Definition: fs_api.h:588
A 512-bit hashcode.
There must only be one value per key; storing a value should fail if a value under the same key alrea...
struct GNUNET_HashCode key
The key used in the DHT.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
static struct GNUNET_FS_SearchContext * sc
Definition: gnunet-search.c:37
struct GNUNET_CONTAINER_MetaData * meta
Metadata for the search result.
Definition: fs_api.h:528
int GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
struct GNUNET_HashCode key
Key for the search result based on the URI.
Definition: fs_api.h:566
union GNUNET_FS_Uri::@13 data
Allow multiple values with the same key.
uint32_t mandatory_missing
Number of mandatory keywords for which we have NOT yet found the search result; when this value hits ...
Definition: fs_api.h:595
int GNUNET_CONTAINER_multihashmap_get_multiple(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map that match a particular key.
struct GNUNET_FS_Uri::@13::@14 ksk
struct GNUNET_FS_Handle * h
Handle to the global FS context.
Definition: fs_api.h:1514
static void notify_client_chk_update(struct GNUNET_FS_SearchContext *sc, struct GNUNET_FS_SearchResult *sr)
We&#39;ve found new information about an existing CHK result.
Definition: fs_search.c:126
#define GNUNET_malloc(size)
Wrapper around malloc.
void GNUNET_FS_search_start_probe_(struct GNUNET_FS_SearchResult *sr)
Start download probes for the given search result.
Definition: fs_search.c:430
struct GNUNET_CONTAINER_MetaData * GNUNET_CONTAINER_meta_data_duplicate(const struct GNUNET_CONTAINER_MetaData *md)
Duplicate a MetaData token.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ search_start()

static struct GNUNET_FS_SearchContext * search_start ( struct GNUNET_FS_Handle h,
const struct GNUNET_FS_Uri uri,
uint32_t  anonymity,
enum GNUNET_FS_SearchOptions  options,
void *  cctx,
struct GNUNET_FS_SearchResult psearch 
)
static

Start search for content, internal API.

Parameters
hhandle to the file sharing subsystem
urispecifies the search parameters; can be a KSK URI or an SKS URI.
anonymitydesired level of anonymity
optionsoptions for the search
cctxclient context
psearchparent search result (for namespace update searches)
Returns
context that can be used to control the search
Parameters
hhandle to the file sharing subsystem
urispecifies the search parameters; can be a KSK URI or an SKS URI.
anonymitydesired level of anonymity
optionsoptions for the search
cctxinitial value for the client context
psearchparent search result (for namespace update searches)
Returns
context that can be used to control the search

Definition at line 1333 of file fs_search.c.

References anonymity, GNUNET_FS_ProgressInfo::cctx, GNUNET_CONTAINER_multihashmap_create(), GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_free, GNUNET_FS_search_make_status_(), GNUNET_FS_search_start_searching_(), GNUNET_FS_search_sync_(), GNUNET_FS_STATUS_SEARCH_START, GNUNET_FS_uri_destroy(), GNUNET_FS_uri_dup(), GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_TIME_absolute_get(), h, GNUNET_FS_SearchContext::master_result_map, options, sc, GNUNET_FS_ProgressInfo::status, and GNUNET_FS_SearchResult::update_search.

Referenced by GNUNET_FS_search_start(), and process_ksk_result().

1339 {
1340  struct GNUNET_FS_SearchContext *sc;
1341  struct GNUNET_FS_ProgressInfo pi;
1342 
1343  sc = GNUNET_new (struct GNUNET_FS_SearchContext);
1344  sc->h = h;
1345  sc->options = options;
1346  sc->uri = GNUNET_FS_uri_dup (uri);
1347  sc->anonymity = anonymity;
1348  sc->start_time = GNUNET_TIME_absolute_get ();
1349  if (NULL != psearch)
1350  {
1351  sc->psearch_result = psearch;
1352  psearch->update_search = sc;
1353  }
1355  sc->client_info = cctx;
1357  {
1358  GNUNET_FS_uri_destroy (sc->uri);
1359  GNUNET_CONTAINER_multihashmap_destroy (sc->master_result_map);
1360  GNUNET_free (sc);
1361  return NULL;
1362  }
1365  sc->client_info = GNUNET_FS_search_make_status_ (&pi, sc->h, sc);
1366  return sc;
1367 }
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
void GNUNET_FS_search_sync_(struct GNUNET_FS_SearchContext *sc)
Synchronize this search struct with its mirror on disk.
Definition: fs_api.c:2167
First event generated when a client requests a search to begin or when a namespace result automatical...
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static struct GNUNET_PEERINFO_Handle * pi
Handle to peerinfo service.
struct GNUNET_FS_Uri * GNUNET_FS_uri_dup(const struct GNUNET_FS_Uri *uri)
Duplicate URI.
Definition: fs_uri.c:998
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
struct GNUNET_FS_SearchContext * update_search
If this search result triggered an update search, this field links to the update search.
Definition: fs_api.h:551
struct GNUNET_CONTAINER_MultiHashMap * master_result_map
Map that contains a struct GNUNET_FS_SearchResult for each result that was found in the search...
Definition: fs_api.h:1558
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
void GNUNET_FS_uri_destroy(struct GNUNET_FS_Uri *uri)
Free URI.
Definition: fs_uri.c:678
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
int GNUNET_FS_search_start_searching_(struct GNUNET_FS_SearchContext *sc)
Build the request and actually initiate the search using the GNUnet FS service.
Definition: fs_search.c:1408
static struct GNUNET_FS_SearchContext * sc
Definition: gnunet-search.c:37
Handle for controlling a search.
Definition: fs_api.h:1509
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
static unsigned int anonymity
void * GNUNET_FS_search_make_status_(struct GNUNET_FS_ProgressInfo *pi, struct GNUNET_FS_Handle *h, struct GNUNET_FS_SearchContext *sc)
Fill in all of the generic fields for a search event and call the callback.
Definition: fs_search.c:48
#define GNUNET_free(ptr)
Wrapper around free.
Argument given to the progress callback with information about what is going on.
void * cctx
Client context pointer (set the last time by the client for this operation; initially NULL on START/R...
Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_sks_result()

static void process_sks_result ( struct GNUNET_FS_SearchContext sc,
const char *  id_update,
const struct GNUNET_FS_Uri uri,
const struct GNUNET_CONTAINER_MetaData meta 
)
static

We have received an SKS result.

Start searching for updates and notify the client if it is a new result.

Parameters
sccontext for the overall query
id_updateidentifier for updates, NULL for none
urithe URI that was found
metametadata associated with the URI

Definition at line 685 of file fs_search.c.

References GNUNET_FS_SearchResult::anonymity, GNUNET_FS_SearchContext::anonymity, GNUNET_FS_Uri::chk, FileIdentifier::chk, GNUNET_FS_SearchResult::client_info, GNUNET_FS_Uri::data, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_meta_data_duplicate(), GNUNET_CONTAINER_multihashmap_get_multiple(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CRYPTO_hash_xor(), GNUNET_free, GNUNET_FS_search_result_sync_(), GNUNET_FS_search_start_probe_(), GNUNET_FS_uri_dup(), GNUNET_FS_URI_SKS, GNUNET_FS_uri_to_key(), GNUNET_new, GNUNET_OK, GNUNET_strdup, GNUNET_SYSERR, GNUNET_FS_SearchResult::h, GNUNET_FS_SearchContext::h, key, ContentHashKey::key, GNUNET_FS_SearchResult::key, GNUNET_FS_SearchResult::mandatory_missing, GNUNET_FS_SearchContext::master_result_map, GNUNET_FS_SearchResult::meta, notify_client_chk_result(), GNUNET_FS_SearchContext::options, ContentHashKey::query, sc, GNUNET_FS_SearchResult::sc, GNUNET_FS_Uri::sks, GetResultContext::sr, test_result_present(), GNUNET_FS_Uri::type, GNUNET_FS_SearchResult::uri, and GNUNET_FS_SearchContext::uri.

Referenced by process_sblock().

689 {
690  struct GNUNET_FS_Uri uu;
691  struct GNUNET_HashCode key;
692  struct GNUNET_FS_SearchResult *sr;
693 
694  /* check if new */
695  GNUNET_assert (NULL != sc);
696  if (GNUNET_OK !=
698  &key))
699  {
700  GNUNET_break (0);
701  return;
702  }
704  &uri->data.chk.chk.query,
705  &key);
706  if (GNUNET_SYSERR ==
709  (void *) uri))
710  return; /* duplicate result */
711  sr = GNUNET_new (struct GNUNET_FS_SearchResult);
712  sr->h = sc->h;
713  sr->sc = sc;
714  sr->anonymity = sc->anonymity;
715  sr->uri = GNUNET_FS_uri_dup (uri);
717  sr->key = key;
722  /* notify client */
723  if (0 == sr->mandatory_missing)
724  notify_client_chk_result (sc, sr);
725  else
726  GNUNET_break (NULL == sr->client_info);
727  /* search for updates */
728  if (0 == strlen (id_update))
729  return; /* no updates */
730  uu.type = GNUNET_FS_URI_SKS;
731  uu.data.sks.ns = sc->uri->data.sks.ns;
732  uu.data.sks.identifier = GNUNET_strdup (id_update);
733  (void) search_start (sc->h, &uu, sc->anonymity, sc->options, NULL, sr);
734  GNUNET_free (uu.data.sks.identifier);
735 }
void * client_info
Client info for this search result.
Definition: fs_api.h:533
struct ContentHashKey chk
Query and key of the top GNUNET_EC_IBlock.
Definition: fs_api.h:103
struct FileIdentifier chk
Information needed to retrieve a file (content-hash-key plus file size).
Definition: fs_api.h:211
static void notify_client_chk_result(struct GNUNET_FS_SearchContext *sc, struct GNUNET_FS_SearchResult *sr)
We&#39;ve found a new CHK result.
Definition: fs_search.c:104
struct GNUNET_FS_Uri::@13::@15 sks
enum GNUNET_FS_SearchOptions options
Options for the search.
Definition: fs_api.h:1597
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_FS_SearchContext * sc
Search context this result belongs to; can be NULL for probes that come from a directory result...
Definition: fs_api.h:518
struct GNUNET_FS_Uri * uri
URI to which this search result refers to.
Definition: fs_api.h:523
static int test_result_present(void *cls, const struct GNUNET_HashCode *key, void *value)
Check if the given result is identical to the given URI.
Definition: fs_search.c:83
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
struct GNUNET_FS_Uri * GNUNET_FS_uri_dup(const struct GNUNET_FS_Uri *uri)
Duplicate URI.
Definition: fs_uri.c:998
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_FS_Uri * uri
List of keywords that we&#39;re looking for.
Definition: fs_api.h:1524
int GNUNET_FS_uri_to_key(const struct GNUNET_FS_Uri *uri, struct GNUNET_HashCode *key)
Get a unique key from a URI.
Definition: fs_uri.c:103
uint32_t anonymity
Anonymity level for the search.
Definition: fs_api.h:1587
struct GNUNET_CONTAINER_MultiHashMap * master_result_map
Map that contains a struct GNUNET_FS_SearchResult for each result that was found in the search...
Definition: fs_api.h:1558
Information we store for each search result.
Definition: fs_api.h:497
struct GNUNET_FS_Handle * h
File-sharing context this result belongs to.
Definition: fs_api.h:502
struct GNUNET_HashCode query
Hash of the encrypted content, used for querying.
Definition: fs.h:63
void GNUNET_FS_search_result_sync_(struct GNUNET_FS_SearchResult *sr)
Synchronize this search result with its mirror on disk.
Definition: fs_api.c:2076
uint32_t anonymity
Anonymity level to use for probes using this search result.
Definition: fs_api.h:588
A 512-bit hashcode.
struct GNUNET_HashCode key
The key used in the DHT.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
static struct GNUNET_FS_SearchContext * sc
Definition: gnunet-search.c:37
struct GNUNET_CONTAINER_MetaData * meta
Metadata for the search result.
Definition: fs_api.h:528
int GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
struct GNUNET_HashCode key
Key for the search result based on the URI.
Definition: fs_api.h:566
union GNUNET_FS_Uri::@13 data
Allow multiple values with the same key.
Signed key space (file in namespace).
Definition: fs_api.h:148
struct GNUNET_HashCode key
Hash of the original content, used for encryption.
Definition: fs.h:58
uint32_t mandatory_missing
Number of mandatory keywords for which we have NOT yet found the search result; when this value hits ...
Definition: fs_api.h:595
int GNUNET_CONTAINER_multihashmap_get_multiple(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map that match a particular key.
A Universal Resource Identifier (URI), opaque.
Definition: fs_api.h:165
struct GNUNET_FS_Handle * h
Handle to the global FS context.
Definition: fs_api.h:1514
void GNUNET_CRYPTO_hash_xor(const struct GNUNET_HashCode *a, const struct GNUNET_HashCode *b, struct GNUNET_HashCode *result)
compute result = a ^ b
Definition: crypto_hash.c:202
static struct GNUNET_FS_SearchContext * search_start(struct GNUNET_FS_Handle *h, const struct GNUNET_FS_Uri *uri, uint32_t anonymity, enum GNUNET_FS_SearchOptions options, void *cctx, struct GNUNET_FS_SearchResult *psearch)
Start search for content, internal API.
Definition: fs_search.c:1333
void GNUNET_FS_search_start_probe_(struct GNUNET_FS_SearchResult *sr)
Start download probes for the given search result.
Definition: fs_search.c:430
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_CONTAINER_MetaData * GNUNET_CONTAINER_meta_data_duplicate(const struct GNUNET_CONTAINER_MetaData *md)
Duplicate a MetaData token.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ decrypt_block_with_keyword()

static int decrypt_block_with_keyword ( const struct GNUNET_FS_SearchContext sc,
const struct GNUNET_CRYPTO_EcdsaPublicKey dpub,
const void *  edata,
size_t  edata_size,
char *  data 
)
static

Decrypt a ublock using a 'keyword' as the passphrase.

Given the KSK public key derived from the keyword, this function looks up the original keyword in the search context and decrypts the given ciphertext block.

Parameters
scsearch context with the keywords
dpubderived public key used for the search
edataencrypted data
edata_sizenumber of bytes in edata (and data)
datawhere to store the plaintext
Returns
keyword index on success, GNUNET_SYSERR on error (no such keyword, internal error)

Definition at line 753 of file fs_search.c.

References GNUNET_FS_Uri::data, SearchRequestEntry::dpub, GNUNET_break, GNUNET_CRYPTO_ecdsa_key_get_anonymous(), GNUNET_CRYPTO_ecdsa_key_get_public(), GNUNET_FS_ublock_decrypt_(), GNUNET_SYSERR, SearchRequestEntry::keyword, GNUNET_FS_Uri::ksk, GNUNET_FS_SearchContext::requests, and GNUNET_FS_SearchContext::uri.

Referenced by process_kblock().

758 {
759  const struct GNUNET_CRYPTO_EcdsaPrivateKey *anon;
760  struct GNUNET_CRYPTO_EcdsaPublicKey anon_pub;
761  unsigned int i;
762 
763  /* find key */
764  for (i = 0; i < sc->uri->data.ksk.keywordCount; i++)
765  if (0 == memcmp (dpub,
766  &sc->requests[i].dpub,
767  sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)))
768  break;
769  if (i == sc->uri->data.ksk.keywordCount)
770  {
771  /* oops, does not match any of our keywords!? */
772  GNUNET_break (0);
773  return GNUNET_SYSERR;
774  }
775  /* decrypt */
777  GNUNET_CRYPTO_ecdsa_key_get_public (anon, &anon_pub);
778  GNUNET_FS_ublock_decrypt_ (edata, edata_size,
779  &anon_pub,
780  sc->requests[i].keyword,
781  data);
782  return i;
783 }
const struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_CRYPTO_ecdsa_key_get_anonymous(void)
Get the shared private key we use for anonymous users.
Definition: crypto_ecc.c:812
struct GNUNET_CRYPTO_EcdsaPublicKey dpub
Derived public key, hashes to &#39;uquery&#39;.
Definition: fs_api.h:1480
void GNUNET_FS_ublock_decrypt_(const void *input, size_t input_len, const struct GNUNET_CRYPTO_EcdsaPublicKey *ns, const char *label, void *output)
Decrypt the given UBlock, storing the result in output.
Private ECC key encoded for transmission.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct SearchRequestEntry * requests
Per-keyword information for a keyword search.
Definition: fs_api.h:1564
struct GNUNET_FS_Uri * uri
List of keywords that we&#39;re looking for.
Definition: fs_api.h:1524
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
void GNUNET_CRYPTO_ecdsa_key_get_public(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Extract the public key for the given private key.
Definition: crypto_ecc.c:239
union GNUNET_FS_Uri::@13 data
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
struct GNUNET_FS_Uri::@13::@14 ksk
uint32_t data
The data value.
char * keyword
The original keyword, used to derive the key (for decrypting the UBlock).
Definition: fs_api.h:1486
Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_kblock()

static void process_kblock ( struct GNUNET_FS_SearchContext sc,
const struct UBlock ub,
size_t  size 
)
static

Process a keyword search result.

The actual type of block is a UBlock; we know it is a keyword search result because that's what we were searching for.

Parameters
scour search context
ubthe ublock with the keyword search result
sizesize of ub

Definition at line 796 of file fs_search.c.

References _, decrypt_block_with_keyword(), GNUNET_break_op, GNUNET_CONTAINER_meta_data_create(), GNUNET_CONTAINER_meta_data_deserialize(), GNUNET_CONTAINER_meta_data_destroy(), GNUNET_ERROR_TYPE_ERROR, GNUNET_free_non_null, GNUNET_FS_uri_destroy(), GNUNET_FS_uri_parse(), GNUNET_FS_VERSION, GNUNET_log, meta, process_ksk_result(), GNUNET_FS_SearchContext::requests, GetResultContext::uri, and UBlock::verification_key.

Referenced by handle_result().

799 {
800  size_t j;
801  char pt[size - sizeof(struct UBlock)];
802  const char *eos;
804  struct GNUNET_FS_Uri *uri;
805  char *emsg;
806  int i;
807 
808  if (-1 == (i = decrypt_block_with_keyword (sc,
809  &ub->verification_key,
810  &ub[1],
811  size - sizeof(struct UBlock),
812  pt)))
813  return;
814  /* parse; pt[0] is just '\0', so we skip over that */
815  eos = memchr (&pt[1], '\0', sizeof(pt) - 1);
816  if (NULL == eos)
817  {
818  GNUNET_break_op (0);
819  return;
820  }
821  if (NULL == (uri = GNUNET_FS_uri_parse (&pt[1], &emsg)))
822  {
823  if (GNUNET_FS_VERSION > 0x00090400)
824  {
825  /* we broke this in 0x00090300, so don't bitch
826  too loudly just one version up... */
827  GNUNET_break_op (0); /* ublock malformed */
829  _ ("Failed to parse URI `%s': %s\n"),
830  &pt[1],
831  emsg);
832  }
833  GNUNET_free_non_null (emsg);
834  return;
835  }
836  j = eos - pt + 1;
837  if (sizeof(pt) == j)
839  else
840  meta = GNUNET_CONTAINER_meta_data_deserialize (&pt[j], sizeof(pt) - j);
841  if (NULL == meta)
842  {
843  GNUNET_break_op (0); /* ublock malformed */
844  GNUNET_FS_uri_destroy (uri);
845  return;
846  }
847  process_ksk_result (sc,
848  &sc->requests[i],
849  uri,
850  meta);
851 
852  /* clean up */
854  GNUNET_FS_uri_destroy (uri);
855 }
#define GNUNET_FS_VERSION
Version number of the implementation.
struct GNUNET_FS_Uri * GNUNET_FS_uri_parse(const char *uri, char **emsg)
Convert a UTF-8 String to a URI.
Definition: fs_uri.c:644
struct GNUNET_CONTAINER_MetaData * GNUNET_CONTAINER_meta_data_deserialize(const char *input, size_t size)
Deserialize meta-data.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
static int decrypt_block_with_keyword(const struct GNUNET_FS_SearchContext *sc, const struct GNUNET_CRYPTO_EcdsaPublicKey *dpub, const void *edata, size_t edata_size, char *data)
Decrypt a ublock using a &#39;keyword&#39; as the passphrase.
Definition: fs_search.c:753
struct SearchRequestEntry * requests
Per-keyword information for a keyword search.
Definition: fs_api.h:1564
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
static struct GNUNET_FS_Uri * uri
Value of URI provided on command-line (when not publishing a file but just creating UBlocks to refer ...
Meta data to associate with a file, directory or namespace.
static void process_ksk_result(struct GNUNET_FS_SearchContext *sc, struct SearchRequestEntry *ent, const struct GNUNET_FS_Uri *uri, const struct GNUNET_CONTAINER_MetaData *meta)
We have received a KSK result.
Definition: fs_search.c:564
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
struct GNUNET_CONTAINER_MetaData * GNUNET_CONTAINER_meta_data_create(void)
Create a fresh meta data container.
void GNUNET_CONTAINER_meta_data_destroy(struct GNUNET_CONTAINER_MetaData *md)
Free meta data.
void GNUNET_FS_uri_destroy(struct GNUNET_FS_Uri *uri)
Free URI.
Definition: fs_uri.c:678
static unsigned int size
Size of the "table".
Definition: peer.c:67
A Universal Resource Identifier (URI), opaque.
Definition: fs_api.h:165
static struct GNUNET_CONTAINER_MetaData * meta
Meta-data provided via command-line option.
#define GNUNET_log(kind,...)
struct GNUNET_CRYPTO_EcdsaPublicKey verification_key
Public key used to sign this block.
Definition: block_fs.h:64
universal block for keyword and namespace search results
Definition: block_fs.h:49
Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_sblock()

static void process_sblock ( struct GNUNET_FS_SearchContext sc,
const struct UBlock ub,
size_t  size 
)
static

Process a namespace-search result.

The actual type of block is a UBlock; we know it is a namespace search result because that's what we were searching for.

Parameters
scour search context
ubthe ublock with a namespace result
sizesize of ub

Definition at line 868 of file fs_search.c.

References _, GNUNET_FS_Uri::data, GNUNET_break_op, GNUNET_CONTAINER_meta_data_deserialize(), GNUNET_CONTAINER_meta_data_destroy(), GNUNET_ERROR_TYPE_ERROR, GNUNET_free_non_null, GNUNET_FS_ublock_decrypt_(), GNUNET_FS_uri_destroy(), GNUNET_FS_uri_parse(), GNUNET_log, GNUNET_STRINGS_buffer_tokenize(), id, len, meta, process_sks_result(), sc, GNUNET_FS_Uri::sks, try_reconnect(), GetResultContext::uri, and GNUNET_FS_SearchContext::uri.

Referenced by handle_result().

871 {
872  size_t len = size - sizeof(struct UBlock);
873  char pt[len];
874  struct GNUNET_FS_Uri *uri;
876  const char *id;
877  const char *uris;
878  size_t off;
879  char *emsg;
880 
881  GNUNET_FS_ublock_decrypt_ (&ub[1], len,
882  &sc->uri->data.sks.ns,
883  sc->uri->data.sks.identifier,
884  pt);
885  /* parse */
886  if (0 == (off = GNUNET_STRINGS_buffer_tokenize (pt, len, 2, &id, &uris)))
887  {
888  GNUNET_break_op (0); /* ublock malformed */
889  return;
890  }
891  if (NULL == (meta = GNUNET_CONTAINER_meta_data_deserialize (&pt[off], len
892  - off)))
893  {
894  GNUNET_break_op (0); /* ublock malformed */
895  return;
896  }
897  if (NULL == (uri = GNUNET_FS_uri_parse (uris, &emsg)))
898  {
900  _ ("Failed to parse URI `%s': %s\n"),
901  uris, emsg);
902  GNUNET_break_op (0); /* ublock malformed */
903  GNUNET_free_non_null (emsg);
905  return;
906  }
907  /* process */
908  process_sks_result (sc, id, uri, meta);
909  /* clean up */
910  GNUNET_FS_uri_destroy (uri);
912 }
struct GNUNET_FS_Uri::@13::@15 sks
struct GNUNET_FS_Uri * GNUNET_FS_uri_parse(const char *uri, char **emsg)
Convert a UTF-8 String to a URI.
Definition: fs_uri.c:644
void GNUNET_FS_ublock_decrypt_(const void *input, size_t input_len, const struct GNUNET_CRYPTO_EcdsaPublicKey *ns, const char *label, void *output)
Decrypt the given UBlock, storing the result in output.
struct GNUNET_CONTAINER_MetaData * GNUNET_CONTAINER_meta_data_deserialize(const char *input, size_t size)
Deserialize meta-data.
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
struct GNUNET_FS_Uri * uri
List of keywords that we&#39;re looking for.
Definition: fs_api.h:1524
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
static struct GNUNET_FS_Uri * uri
Value of URI provided on command-line (when not publishing a file but just creating UBlocks to refer ...
unsigned int GNUNET_STRINGS_buffer_tokenize(const char *buffer, size_t size, unsigned int count,...)
Given a buffer of a given size, find "count" 0-terminated strings in the buffer and assign the count ...
Definition: strings.c:135
Meta data to associate with a file, directory or namespace.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
void GNUNET_CONTAINER_meta_data_destroy(struct GNUNET_CONTAINER_MetaData *md)
Free meta data.
void GNUNET_FS_uri_destroy(struct GNUNET_FS_Uri *uri)
Free URI.
Definition: fs_uri.c:678
static void process_sks_result(struct GNUNET_FS_SearchContext *sc, const char *id_update, const struct GNUNET_FS_Uri *uri, const struct GNUNET_CONTAINER_MetaData *meta)
We have received an SKS result.
Definition: fs_search.c:685
static unsigned int size
Size of the "table".
Definition: peer.c:67
union GNUNET_FS_Uri::@13 data
A Universal Resource Identifier (URI), opaque.
Definition: fs_api.h:165
static struct GNUNET_CONTAINER_MetaData * meta
Meta-data provided via command-line option.
#define GNUNET_log(kind,...)
universal block for keyword and namespace search results
Definition: block_fs.h:49
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
Here is the call graph for this function:
Here is the caller graph for this function:

◆ try_reconnect()

static void try_reconnect ( struct GNUNET_FS_SearchContext sc)
static

Shutdown any existing connection to the FS service and try to establish a fresh one (and then re-transmit our search request).

Parameters
scthe search to reconnec

Definition at line 1305 of file fs_search.c.

References do_reconnect(), GNUNET_MQ_destroy(), GNUNET_SCHEDULER_add_delayed(), GNUNET_TIME_STD_BACKOFF, GNUNET_FS_SearchContext::mq, GNUNET_FS_SearchContext::reconnect_backoff, and GNUNET_FS_SearchContext::task.

Referenced by do_reconnect(), process_sblock(), and search_mq_error_handler().

1306 {
1307  if (NULL != sc->mq)
1308  {
1309  GNUNET_MQ_destroy (sc->mq);
1310  sc->mq = NULL;
1311  }
1313  sc->task =
1315  &do_reconnect,
1316  sc);
1317 }
struct GNUNET_SCHEDULER_Task * task
ID of a task that is using this struct and that must be cancelled when the search is being stopped (i...
Definition: fs_api.h:1582
static void do_reconnect(void *cls)
Reconnect to the FS service and transmit our queries NOW.
Definition: fs_search.c:1271
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:1253
struct GNUNET_TIME_Relative reconnect_backoff
How long to wait before we try to reconnect to FS service?
Definition: fs_api.h:1574
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
struct GNUNET_MQ_Handle * mq
Connection to the FS service.
Definition: fs_api.h:1535
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_result()

static int check_result ( void *  cls,
const struct ClientPutMessage cm 
)
static

We check a result message from the service.

Parameters
clsclosure
msgresult message received

Definition at line 933 of file fs_search.c.

References GNUNET_OK.

935 {
936  /* payload of any variable size is OK */
937  return GNUNET_OK;
938 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75

◆ handle_result()

static void handle_result ( void *  cls,
const struct ClientPutMessage cm 
)
static

We process a search result from the service.

Parameters
clsclosure
msgresult message received

Definition at line 948 of file fs_search.c.

References _, ClientPutMessage::expiration, GNUNET_BLOCK_TYPE_ANY, GNUNET_BLOCK_TYPE_FS_DBLOCK, GNUNET_BLOCK_TYPE_FS_IBLOCK, GNUNET_BLOCK_TYPE_FS_ONDEMAND, GNUNET_BLOCK_TYPE_FS_UBLOCK, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_FS_URI_SKS, GNUNET_log, GNUNET_TIME_absolute_get_duration(), GNUNET_TIME_absolute_ntoh(), ClientPutMessage::header, process_kblock(), process_sblock(), GNUNET_TIME_Relative::rel_value_us, schedule_transmit_search_request(), GNUNET_MessageHeader::size, GNUNET_FS_Uri::type, type, ClientPutMessage::type, and GNUNET_FS_SearchContext::uri.

950 {
951  struct GNUNET_FS_SearchContext *sc = cls;
952  uint16_t msize = ntohs (cm->header.size) - sizeof(*cm);
953  enum GNUNET_BLOCK_Type type = ntohl (cm->type);
954 
956  cm->expiration)).rel_value_us > 0)
957  {
959  "Result received has already expired.\n");
960  return; /* result expired */
961  }
962  switch (type)
963  {
965  if (GNUNET_FS_URI_SKS == sc->uri->type)
966  process_sblock (sc,
967  (const struct UBlock *) &cm[1],
968  msize);
969  else
970  process_kblock (sc,
971  (const struct UBlock *) &cm[1],
972  msize);
973  break;
974 
976  GNUNET_break (0);
977  break;
978 
980  GNUNET_break (0);
981  break;
982 
984  GNUNET_break (0);
985  break;
986 
988  GNUNET_break (0);
989  break;
990 
991  default:
993  _ ("Got result with unknown block type `%d', ignoring"),
994  type);
995  break;
996  }
997 }
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
Definition: time.c:673
uint64_t rel_value_us
The actual value.
Any type of block, used as a wildcard when searching.
struct GNUNET_MessageHeader header
Message type will be GNUNET_MESSAGE_TYPE_FS_PUT.
Definition: fs.h:359
GNUNET_BLOCK_Type
Blocks in the datastore and the datacache must have a unique type.
static void process_sblock(struct GNUNET_FS_SearchContext *sc, const struct UBlock *ub, size_t size)
Process a namespace-search result.
Definition: fs_search.c:868
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
static void process_kblock(struct GNUNET_FS_SearchContext *sc, const struct UBlock *ub, size_t size)
Process a keyword search result.
Definition: fs_search.c:796
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Type of a block representing a block to be encoded on demand from disk.
struct GNUNET_FS_Uri * uri
List of keywords that we&#39;re looking for.
Definition: fs_api.h:1524
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
struct GNUNET_TIME_AbsoluteNBO expiration
When does this result expire?
Definition: fs.h:369
Inner block in the CHK tree.
Type of a block representing any type of search result (universal).
static struct GNUNET_FS_SearchContext * sc
Definition: gnunet-search.c:37
enum GNUNET_FS_UriType type
Type of the URI.
Definition: fs_api.h:170
uint32_t type
Type of the block (in big endian).
Definition: fs.h:364
Signed key space (file in namespace).
Definition: fs_api.h:148
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:375
Handle for controlling a search.
Definition: fs_api.h:1509
#define GNUNET_log(kind,...)
Data block (leaf) in the CHK tree.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
universal block for keyword and namespace search results
Definition: block_fs.h:49
Here is the call graph for this function:

◆ schedule_transmit_search_request()

static void schedule_transmit_search_request ( struct GNUNET_FS_SearchContext sc)
static

Schedule the transmission of the (next) search request to the service.

Parameters
sccontext for the search

Definition at line 1113 of file fs_search.c.

References GNUNET_FS_SearchContext::anonymity, SearchMessage::anonymity_level, build_result_set(), GNUNET_FS_Uri::data, env, find_result_set(), GNUNET_assert, GNUNET_BLOCK_TYPE_FS_UBLOCK, GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_CONTAINER_multihashmap_size(), GNUNET_CRYPTO_ecdsa_public_key_derive(), GNUNET_CRYPTO_hash(), GNUNET_FS_SEARCH_OPTION_LOOPBACK_ONLY, GNUNET_FS_uri_test_ksk(), GNUNET_FS_uri_test_sks(), GNUNET_MAX_MESSAGE_SIZE, GNUNET_MESSAGE_TYPE_FS_START_SEARCH, GNUNET_MIN, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_NO, GNUNET_YES, MessageBuilderContext::keyword_offset, GNUNET_FS_Uri::ksk, GNUNET_FS_SearchContext::master_result_map, GNUNET_FS_SearchContext::mq, options, SearchMessage::options, GNUNET_FS_SearchContext::options, MessageBuilderContext::put_cnt, SearchMessage::query, GNUNET_FS_SearchContext::requests, sc, MessageBuilderContext::sc, SEARCH_MESSAGE_OPTION_CONTINUED, SEARCH_MESSAGE_OPTION_LOOPBACK_ONLY, SEARCH_MESSAGE_OPTION_NONE, MessageBuilderContext::skip_cnt, GNUNET_FS_Uri::sks, SearchMessage::target, SearchMessage::type, SearchRequestEntry::uquery, GNUNET_FS_SearchContext::uri, and MessageBuilderContext::xoff.

Referenced by do_reconnect(), and handle_result().

1114 {
1115  struct MessageBuilderContext mbc;
1116  struct GNUNET_MQ_Envelope *env;
1117  struct SearchMessage *sm;
1118  struct GNUNET_CRYPTO_EcdsaPublicKey dpub;
1119  unsigned int total_seen_results; /* total number of result hashes to send */
1120  uint32_t options;
1121  unsigned int left;
1122  unsigned int todo;
1123  unsigned int fit;
1124  unsigned int search_request_map_offset;
1125  unsigned int keyword_offset;
1126  int first_call;
1127 
1128  memset (&mbc, 0, sizeof(mbc));
1129  mbc.sc = sc;
1130  if (GNUNET_FS_uri_test_ksk (sc->uri))
1131  {
1132  /* This will calculate the result set size ONLY for
1133  "keyword_offset == 0", so we will have to recalculate
1134  it for the other keywords later! */
1136  &find_result_set,
1137  &mbc);
1138  total_seen_results = mbc.put_cnt;
1139  }
1140  else
1141  {
1142  total_seen_results
1144  }
1145  search_request_map_offset = 0;
1146  keyword_offset = 0;
1147  first_call = GNUNET_YES;
1148  while ((0 != (left =
1149  (total_seen_results - search_request_map_offset))) ||
1150  (GNUNET_YES == first_call))
1151  {
1152  first_call = GNUNET_NO;
1153  options = SEARCH_MESSAGE_OPTION_NONE;
1156 
1157  fit = (GNUNET_MAX_MESSAGE_SIZE - 1 - sizeof(*sm)) / sizeof(struct
1158  GNUNET_HashCode);
1159  todo = GNUNET_MIN (fit,
1160  left);
1161  env = GNUNET_MQ_msg_extra (sm,
1162  sizeof(struct GNUNET_HashCode) * todo,
1164  mbc.skip_cnt = search_request_map_offset;
1165  mbc.xoff = (struct GNUNET_HashCode *) &sm[1];
1166  sm->type = htonl (GNUNET_BLOCK_TYPE_FS_UBLOCK);
1167  sm->anonymity_level = htonl (sc->anonymity);
1168  memset (&sm->target,
1169  0,
1170  sizeof(struct GNUNET_PeerIdentity));
1171 
1172  if (GNUNET_FS_uri_test_ksk (sc->uri))
1173  {
1174  mbc.keyword_offset = keyword_offset;
1175  /* calculate how many results we can send in this message */
1176  mbc.put_cnt = todo;
1177  /* now build message */
1178  sm->query = sc->requests[keyword_offset].uquery;
1181  &mbc);
1182  search_request_map_offset += todo;
1183  GNUNET_assert (0 == mbc.put_cnt);
1184  GNUNET_assert (total_seen_results >= search_request_map_offset);
1185  if (total_seen_results != search_request_map_offset)
1186  {
1187  /* more requesting to be done... */
1188  sm->options = htonl (options | SEARCH_MESSAGE_OPTION_CONTINUED);
1189  }
1190  else
1191  {
1192  sm->options = htonl (options);
1193  keyword_offset++;
1194  if (sc->uri->data.ksk.keywordCount != keyword_offset)
1195  {
1196  /* more keywords => more requesting to be done... */
1197  first_call = GNUNET_YES;
1198  search_request_map_offset = 0;
1199  mbc.put_cnt = 0;
1200  mbc.keyword_offset = keyword_offset;
1202  &find_result_set,
1203  &mbc);
1204  total_seen_results = mbc.put_cnt;
1205  }
1206  }
1207  }
1208  else
1209  {
1211 
1213  sc->uri->data.sks.identifier,
1214  "fs-ublock",
1215  &dpub);
1216  GNUNET_CRYPTO_hash (&dpub,
1217  sizeof(dpub),
1218  &sm->query);
1219  mbc.put_cnt = todo;
1220  mbc.keyword_offset = 0;
1223  &mbc);
1224  GNUNET_assert (total_seen_results >= search_request_map_offset);
1225  if (total_seen_results != search_request_map_offset)
1226  {
1227  /* more requesting to be done... */
1228  sm->options = htonl (options | SEARCH_MESSAGE_OPTION_CONTINUED);
1229  }
1230  else
1231  {
1232  sm->options = htonl (options);
1233  }
1234  }
1235  GNUNET_MQ_send (sc->mq,
1236  env);
1237  }
1238 }
int GNUNET_FS_uri_test_ksk(const struct GNUNET_FS_Uri *uri)
Is this a keyword URI?
Definition: fs_uri.c:1335
Closure for build_result_set().
Definition: fs_search.c:1013
void GNUNET_CRYPTO_ecdsa_public_key_derive(const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, const char *label, const char *context, struct GNUNET_CRYPTO_EcdsaPublicKey *result)
Derive a public key from a given public key and a label.
Definition: crypto_ecc.c:1337
unsigned int GNUNET_CONTAINER_multihashmap_size(const struct GNUNET_CONTAINER_MultiHashMap *map)
Get the number of key-value pairs in the map.
struct GNUNET_HashCode uquery
Hash of the public key, also known as the query.
Definition: fs_api.h:1475
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
struct GNUNET_FS_Uri::@13::@15 sks
enum GNUNET_FS_SearchOptions options
Options for the search.
Definition: fs_api.h:1597
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
uint32_t options
Bitmask with options.
Definition: fs.h:284
#define GNUNET_NO
Definition: gnunet_common.h:78
int GNUNET_FS_uri_test_sks(const struct GNUNET_FS_Uri *uri)
Is this a namespace URI?
Definition: fs_uri.c:1282
static int find_result_set(void *cls, const struct GNUNET_HashCode *key, void *value)
Iterating over the known results, count those matching the given result range and increment put count...
Definition: fs_search.c:1088
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:306
struct SearchRequestEntry * requests
Per-keyword information for a keyword search.
Definition: fs_api.h:1564
struct GNUNET_FS_Uri * uri
List of keywords that we&#39;re looking for.
Definition: fs_api.h:1524
uint32_t anonymity
Anonymity level for the search.
Definition: fs_api.h:1587
struct GNUNET_HashCode query
Hash of the public key for UBLOCKs; Hash of the CHK-encoded block for DBLOCKS and IBLOCKS...
Definition: fs.h:312
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
struct GNUNET_CONTAINER_MultiHashMap * master_result_map
Map that contains a struct GNUNET_FS_SearchResult for each result that was found in the search...
Definition: fs_api.h:1558
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:48
#define GNUNET_MIN(a, b)
Definition: gnunet_common.h:80
uint32_t type
Type of the content that we&#39;re looking for.
Definition: fs.h:289
Type of a block representing any type of search result (universal).
A 512-bit hashcode.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static struct GNUNET_FS_SearchContext * sc
Definition: gnunet-search.c:37
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message...
union GNUNET_FS_Uri::@13 data
#define GNUNET_MESSAGE_TYPE_FS_START_SEARCH
Client asks FS service to start a (keyword) search.
The identity of the host (wraps the signing key of the peer).
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
struct GNUNET_FS_Uri::@13::@14 ksk
struct GNUNET_MQ_Handle * mq
Connection to the FS service.
Definition: fs_api.h:1535
Only search the local host, do not search remote systems (no P2P)
#define SEARCH_MESSAGE_OPTION_CONTINUED
Request is too large to fit in 64k format.
Definition: fs.h:261
#define GNUNET_YES
Definition: gnunet_common.h:77
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
#define SEARCH_MESSAGE_OPTION_NONE
No options.
Definition: fs.h:248
#define SEARCH_MESSAGE_OPTION_LOOPBACK_ONLY
Only search the local datastore (no network)
Definition: fs.h:253
static int build_result_set(void *cls, const struct GNUNET_HashCode *key, void *value)
Iterating over the known results, pick those matching the given result range and store their keys at ...
Definition: fs_search.c:1052
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
Message sent from a GNUnet (fs) search activity to the gnunet-service-fs to start a search...
Definition: fs.h:268
uint32_t anonymity_level
Desired anonymity level, big-endian.
Definition: fs.h:294
Here is the call graph for this function:
Here is the caller graph for this function:

◆ build_result_set()

static int build_result_set ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Iterating over the known results, pick those matching the given result range and store their keys at 'xoff'.

Parameters
clsthe struct MessageBuilderContext
keykey for a result
valuethe search result
Returns
GNUNET_OK to continue iterating

Definition at line 1052 of file fs_search.c.

References GNUNET_OK, GNUNET_SYSERR, key, GNUNET_FS_SearchResult::keyword_bitmap, MessageBuilderContext::keyword_offset, MessageBuilderContext::put_cnt, MessageBuilderContext::skip_cnt, GetResultContext::sr, value, and MessageBuilderContext::xoff.

Referenced by schedule_transmit_search_request().

1055 {
1056  struct MessageBuilderContext *mbc = cls;
1057  struct GNUNET_FS_SearchResult *sr = value;
1058 
1059  if ((NULL != sr->keyword_bitmap) &&
1060  (0 == (sr->keyword_bitmap[mbc->keyword_offset / 8] & (1
1061  << (mbc->
1062  keyword_offset
1063  % 8)))))
1064  return GNUNET_OK; /* have no match for this keyword yet */
1065  if (mbc->skip_cnt > 0)
1066  {
1067  mbc->skip_cnt--;
1068  return GNUNET_OK;
1069  }
1070  if (0 == mbc->put_cnt)
1071  return GNUNET_SYSERR;
1072  mbc->xoff[--mbc->put_cnt] = *key;
1073 
1074  return GNUNET_OK;
1075 }
Closure for build_result_set().
Definition: fs_search.c:1013
uint8_t * keyword_bitmap
Bitmap that specifies precisely which keywords have been matched already.
Definition: fs_api.h:561
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
static char * value
Value of the record to add/remove.
Information we store for each search result.
Definition: fs_api.h:497
unsigned int keyword_offset
Keyword offset the search result must match (0 for SKS)
Definition: fs_search.c:1038
struct GNUNET_HashCode key
The key used in the DHT.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
unsigned int put_cnt
How many entries can we store to xoff.
Definition: fs_search.c:1018
struct GNUNET_HashCode * xoff
Where to store the keys.
Definition: fs_search.c:1028
unsigned int skip_cnt
How many entries should we skip.
Definition: fs_search.c:1023
Here is the caller graph for this function:

◆ find_result_set()

static int find_result_set ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Iterating over the known results, count those matching the given result range and increment put count for each.

Parameters
clsthe struct MessageBuilderContext
keykey for a result
valuethe search result
Returns
GNUNET_OK to continue iterating

Definition at line 1088 of file fs_search.c.

References GNUNET_OK, GNUNET_FS_SearchResult::keyword_bitmap, MessageBuilderContext::keyword_offset, MessageBuilderContext::put_cnt, GetResultContext::sr, and value.

Referenced by schedule_transmit_search_request().

1091 {
1092  struct MessageBuilderContext *mbc = cls;
1093  struct GNUNET_FS_SearchResult *sr = value;
1094 
1095  if ((NULL != sr->keyword_bitmap) &&
1096  (0 == (sr->keyword_bitmap[mbc->keyword_offset / 8] & (1
1097  << (mbc->
1098  keyword_offset
1099  % 8)))))
1100  return GNUNET_OK; /* have no match for this keyword yet */
1101  mbc->put_cnt++;
1102  return GNUNET_OK;
1103 }
Closure for build_result_set().
Definition: fs_search.c:1013
uint8_t * keyword_bitmap
Bitmap that specifies precisely which keywords have been matched already.
Definition: fs_api.h:561
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
static char * value
Value of the record to add/remove.
Information we store for each search result.
Definition: fs_api.h:497
unsigned int keyword_offset
Keyword offset the search result must match (0 for SKS)
Definition: fs_search.c:1038
unsigned int put_cnt
How many entries can we store to xoff.
Definition: fs_search.c:1018
Here is the caller graph for this function:

◆ search_mq_error_handler()

static void search_mq_error_handler ( void *  cls,
enum GNUNET_MQ_Error  error 
)
static

Generic error handler, called with the appropriate error code and the same closure specified at the creation of the message queue.

Not every message queue implementation supports an error handler.

Parameters
clsclosure with the struct GNUNET_FS_SearchContext *
errorerror code

Definition at line 1250 of file fs_search.c.

References GNUNET_MQ_destroy(), GNUNET_FS_SearchContext::mq, and try_reconnect().

Referenced by do_reconnect().

1252 {
1253  struct GNUNET_FS_SearchContext *sc = cls;
1254 
1255  if (NULL != sc->mq)
1256  {
1257  GNUNET_MQ_destroy (sc->mq);
1258  sc->mq = NULL;
1259  }
1260  try_reconnect (sc);
1261 }
static struct GNUNET_FS_SearchContext * sc
Definition: gnunet-search.c:37
Handle for controlling a search.
Definition: fs_api.h:1509
struct GNUNET_MQ_Handle * mq
Connection to the FS service.
Definition: fs_api.h:1535
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
static void try_reconnect(struct GNUNET_FS_SearchContext *sc)
Shutdown any existing connection to the FS service and try to establish a fresh one (and then re-tran...
Definition: fs_search.c:1305
Here is the call graph for this function:
Here is the caller graph for this function:

◆ do_reconnect()

static void do_reconnect ( void *  cls)
static

Reconnect to the FS service and transmit our queries NOW.

Parameters
clsour search context

Definition at line 1271 of file fs_search.c.

References GNUNET_FS_Handle::cfg, GNUNET_CLIENT_connect(), GNUNET_MESSAGE_TYPE_FS_PUT, GNUNET_MQ_handler_end, GNUNET_MQ_hd_var_size, GNUNET_FS_SearchContext::h, GNUNET_FS_SearchContext::mq, result, schedule_transmit_search_request(), search_mq_error_handler(), GNUNET_FS_SearchContext::task, and try_reconnect().

Referenced by GNUNET_FS_search_continue(), GNUNET_FS_search_start_searching_(), and try_reconnect().

1272 {
1273  struct GNUNET_FS_SearchContext *sc = cls;
1274  struct GNUNET_MQ_MessageHandler handlers[] = {
1277  struct ClientPutMessage,
1278  sc),
1280  };
1281 
1282  sc->task = NULL;
1283  sc->mq = GNUNET_CLIENT_connect (sc->h->cfg,
1284  "fs",
1285  handlers,
1287  sc);
1288  if (NULL == sc->mq)
1289  {
1290  try_reconnect (sc);
1291  return;
1292  }
1294 }
struct GNUNET_SCHEDULER_Task * task
ID of a task that is using this struct and that must be cancelled when the search is being stopped (i...
Definition: fs_api.h:1582
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
Definition: client.c:1057
static void schedule_transmit_search_request(struct GNUNET_FS_SearchContext *sc)
Schedule the transmission of the (next) search request to the service.
Definition: fs_search.c:1113
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
static int result
Global testing status.
Message handler for a specific message type.
static struct GNUNET_FS_SearchContext * sc
Definition: gnunet-search.c:37
Response from FS service with a result for a previous FS search.
Definition: fs.h:354
static void search_mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
Generic error handler, called with the appropriate error code and the same closure specified at the c...
Definition: fs_search.c:1250
Handle for controlling a search.
Definition: fs_api.h:1509
struct GNUNET_MQ_Handle * mq
Connection to the FS service.
Definition: fs_api.h:1535
struct GNUNET_FS_Handle * h
Handle to the global FS context.
Definition: fs_api.h:1514
static void try_reconnect(struct GNUNET_FS_SearchContext *sc)
Shutdown any existing connection to the FS service and try to establish a fresh one (and then re-tran...
Definition: fs_search.c:1305
#define GNUNET_MESSAGE_TYPE_FS_PUT
P2P response with content or active migration of content.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Definition: fs_api.h:1073
Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_sre_result_maps()

static int update_sre_result_maps ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Update the 'results' map for the individual keywords with the results from the 'global' result set.

Parameters
clsclosure, the struct GNUNET_FS_SearchContext *
keycurrent key code
valuevalue in the hash map, the struct GNUNET_FS_SearchResult *
Returns
GNUNET_YES (we should continue to iterate)

Definition at line 1380 of file fs_search.c.

References GNUNET_FS_Uri::data, GNUNET_break, GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_OK, GNUNET_YES, GNUNET_FS_SearchResult::key, GNUNET_FS_SearchResult::keyword_bitmap, GNUNET_FS_Uri::ksk, GNUNET_FS_SearchContext::requests, SearchRequestEntry::results, GetResultContext::sr, GNUNET_FS_SearchContext::uri, and value.

Referenced by GNUNET_FS_search_start_searching_().

1383 {
1384  struct GNUNET_FS_SearchContext *sc = cls;
1385  struct GNUNET_FS_SearchResult *sr = value;
1386 
1387  for (unsigned int i = 0; i < sc->uri->data.ksk.keywordCount; i++)
1388  {
1389  if (0 != (sr->keyword_bitmap[i / 8] & (1 << (i % 8))))
1392  &sr->key,
1393  sr,
1395  }
1396  return GNUNET_YES;
1397 }
uint8_t * keyword_bitmap
Bitmap that specifies precisely which keywords have been matched already.
Definition: fs_api.h:561
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct SearchRequestEntry * requests
Per-keyword information for a keyword search.
Definition: fs_api.h:1564
struct GNUNET_FS_Uri * uri
List of keywords that we&#39;re looking for.
Definition: fs_api.h:1524
static char * value
Value of the record to add/remove.
Information we store for each search result.
Definition: fs_api.h:497
struct GNUNET_CONTAINER_MultiHashMap * results
Map that contains a "struct GNUNET_FS_SearchResult" for each result that was found under this keyword...
Definition: fs_api.h:1496
There must only be one value per key; storing a value should fail if a value under the same key alrea...
static struct GNUNET_FS_SearchContext * sc
Definition: gnunet-search.c:37
int GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
struct GNUNET_HashCode key
Key for the search result based on the URI.
Definition: fs_api.h:566
union GNUNET_FS_Uri::@13 data
Handle for controlling a search.
Definition: fs_api.h:1509
struct GNUNET_FS_Uri::@13::@14 ksk
#define GNUNET_YES
Definition: gnunet_common.h:77
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_search_start_searching_()

int GNUNET_FS_search_start_searching_ ( struct GNUNET_FS_SearchContext sc)

Build the request and actually initiate the search using the GNUnet FS service.

Parameters
scsearch context
Returns
GNUNET_OK on success, GNUNET_SYSERR on error

Definition at line 1408 of file fs_search.c.

References GNUNET_FS_Uri::data, do_reconnect(), SearchRequestEntry::dpub, GNUNET_assert, GNUNET_CONTAINER_multihashmap_create(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_CRYPTO_ecdsa_key_get_anonymous(), GNUNET_CRYPTO_ecdsa_key_get_public(), GNUNET_CRYPTO_ecdsa_public_key_derive(), GNUNET_CRYPTO_hash(), GNUNET_FS_uri_test_ksk(), GNUNET_new_array, GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_cancel(), GNUNET_strdup, GNUNET_SYSERR, SearchRequestEntry::keyword, GNUNET_FS_Uri::ksk, SearchRequestEntry::mandatory, GNUNET_FS_SearchContext::mandatory_count, GNUNET_FS_SearchContext::master_result_map, GNUNET_FS_SearchContext::mq, GNUNET_FS_SearchContext::requests, SearchRequestEntry::results, GNUNET_FS_SearchContext::task, update_sre_result_maps(), SearchRequestEntry::uquery, and GNUNET_FS_SearchContext::uri.

Referenced by deserialize_search(), and search_start().

1409 {
1410  unsigned int i;
1411  const char *keyword;
1412  const struct GNUNET_CRYPTO_EcdsaPrivateKey *anon;
1413  struct GNUNET_CRYPTO_EcdsaPublicKey anon_pub;
1414  struct SearchRequestEntry *sre;
1415 
1416  GNUNET_assert (NULL == sc->mq);
1417  if (GNUNET_FS_uri_test_ksk (sc->uri))
1418  {
1419  GNUNET_assert (0 != sc->uri->data.ksk.keywordCount);
1421  GNUNET_CRYPTO_ecdsa_key_get_public (anon, &anon_pub);
1422  sc->requests
1423  = GNUNET_new_array (sc->uri->data.ksk.keywordCount,
1424  struct SearchRequestEntry);
1425 
1426  for (i = 0; i < sc->uri->data.ksk.keywordCount; i++)
1427  {
1428  keyword = &sc->uri->data.ksk.keywords[i][1];
1429  sre = &sc->requests[i];
1430  sre->keyword = GNUNET_strdup (keyword);
1432  keyword,
1433  "fs-ublock",
1434  &sre->dpub);
1435  GNUNET_CRYPTO_hash (&sre->dpub,
1436  sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey),
1437  &sre->uquery);
1438  sre->mandatory = (sc->uri->data.ksk.keywords[i][0] == '+');
1439  if (sre->mandatory)
1440  sc->mandatory_count++;
1442  }
1445  sc);
1446  }
1447  GNUNET_assert (NULL == sc->task);
1448  do_reconnect (sc);
1449  if (NULL == sc->mq)
1450  {
1452  sc->task = NULL;
1453  return GNUNET_SYSERR;
1454  }
1455  return GNUNET_OK;
1456 }
int GNUNET_FS_uri_test_ksk(const struct GNUNET_FS_Uri *uri)
Is this a keyword URI?
Definition: fs_uri.c:1335
const struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_CRYPTO_ecdsa_key_get_anonymous(void)
Get the shared private key we use for anonymous users.
Definition: crypto_ecc.c:812
void GNUNET_CRYPTO_ecdsa_public_key_derive(const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, const char *label, const char *context, struct GNUNET_CRYPTO_EcdsaPublicKey *result)
Derive a public key from a given public key and a label.
Definition: crypto_ecc.c:1337
struct GNUNET_SCHEDULER_Task * task
ID of a task that is using this struct and that must be cancelled when the search is being stopped (i...
Definition: fs_api.h:1582
uint32_t mandatory_count
Number of mandatory keywords in this query.
Definition: fs_api.h:1592
struct GNUNET_HashCode uquery
Hash of the public key, also known as the query.
Definition: fs_api.h:1475
struct GNUNET_CRYPTO_EcdsaPublicKey dpub
Derived public key, hashes to &#39;uquery&#39;.
Definition: fs_api.h:1480
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
int mandatory
Is this keyword a mandatory keyword (started with &#39;+&#39;)?
Definition: fs_api.h:1502
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
Private ECC key encoded for transmission.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
struct SearchRequestEntry * requests
Per-keyword information for a keyword search.
Definition: fs_api.h:1564
struct GNUNET_FS_Uri * uri
List of keywords that we&#39;re looking for.
Definition: fs_api.h:1524
static void do_reconnect(void *cls)
Reconnect to the FS service and transmit our queries NOW.
Definition: fs_search.c:1271
struct GNUNET_CONTAINER_MultiHashMap * master_result_map
Map that contains a struct GNUNET_FS_SearchResult for each result that was found in the search...
Definition: fs_api.h:1558
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:48
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
struct GNUNET_CONTAINER_MultiHashMap * results
Map that contains a "struct GNUNET_FS_SearchResult" for each result that was found under this keyword...
Definition: fs_api.h:1496
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
void GNUNET_CRYPTO_ecdsa_key_get_public(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Extract the public key for the given private key.
Definition: crypto_ecc.c:239
union GNUNET_FS_Uri::@13 data
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
struct GNUNET_FS_Uri::@13::@14 ksk
struct GNUNET_MQ_Handle * mq
Connection to the FS service.
Definition: fs_api.h:1535
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
static int update_sre_result_maps(void *cls, const struct GNUNET_HashCode *key, void *value)
Update the &#39;results&#39; map for the individual keywords with the results from the &#39;global&#39; result set...
Definition: fs_search.c:1380
Information we keep for each keyword in a keyword search.
Definition: fs_api.h:1470
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
char * keyword
The original keyword, used to derive the key (for decrypting the UBlock).
Definition: fs_api.h:1486
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
Here is the call graph for this function:
Here is the caller graph for this function:

◆ search_result_freeze_probes()

static int search_result_freeze_probes ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Freeze probes for the given search result.

Parameters
clsthe global FS handle
keythe key for the search result (unused)
valuethe search result to free
Returns
GNUNET_OK

Definition at line 1468 of file fs_search.c.

References GNUNET_FS_download_stop(), GNUNET_FS_search_pause(), GNUNET_FS_stop_probe_ping_task_(), GNUNET_OK, GNUNET_SCHEDULER_cancel(), GNUNET_YES, GNUNET_FS_SearchResult::probe_cancel_task, GNUNET_FS_SearchResult::probe_ctx, GetResultContext::sr, GNUNET_FS_SearchResult::update_search, and value.

Referenced by GNUNET_FS_search_pause().

1471 {
1472  struct GNUNET_FS_SearchResult *sr = value;
1473 
1474  if (NULL != sr->probe_ctx)
1475  {
1477  sr->probe_ctx = NULL;
1479  }
1480  if (NULL != sr->probe_cancel_task)
1481  {
1483  sr->probe_cancel_task = NULL;
1484  }
1485  if (NULL != sr->update_search)
1487  return GNUNET_OK;
1488 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
struct GNUNET_FS_DownloadContext * probe_ctx
ID of a job that is currently probing this results&#39; availability (NULL if we are not currently probin...
Definition: fs_api.h:539
struct GNUNET_FS_SearchContext * update_search
If this search result triggered an update search, this field links to the update search.
Definition: fs_api.h:551
static char * value
Value of the record to add/remove.
Information we store for each search result.
Definition: fs_api.h:497
void GNUNET_FS_stop_probe_ping_task_(struct GNUNET_FS_SearchResult *sr)
Stop the ping task for this search result.
Definition: fs_search.c:409
void GNUNET_FS_download_stop(struct GNUNET_FS_DownloadContext *dc, int do_delete)
Stop a download (aborts if download is incomplete).
Definition: fs_download.c:2333
void GNUNET_FS_search_pause(struct GNUNET_FS_SearchContext *sc)
Pause search.
Definition: fs_search.c:1639
#define GNUNET_YES
Definition: gnunet_common.h:77
struct GNUNET_SCHEDULER_Task * probe_cancel_task
ID of the task that will clean up the probe_ctx should it not complete on time (and that will need to...
Definition: fs_api.h:573
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
Here is the call graph for this function:
Here is the caller graph for this function:

◆ search_result_resume_probes()

static int search_result_resume_probes ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Resume probes for the given search result.

Parameters
clsthe global FS handle
keythe key for the search result (unused)
valuethe search result to free
Returns
GNUNET_OK

Definition at line 1500 of file fs_search.c.

References GNUNET_FS_search_continue(), GNUNET_FS_search_start_probe_(), GNUNET_OK, GetResultContext::sr, GNUNET_FS_SearchResult::update_search, and value.

Referenced by GNUNET_FS_search_continue().

1503 {
1504  struct GNUNET_FS_SearchResult *sr = value;
1505 
1507  if (NULL != sr->update_search)
1509  return GNUNET_OK;
1510 }
void GNUNET_FS_search_continue(struct GNUNET_FS_SearchContext *sc)
Continue paused search.
Definition: fs_search.c:1670
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
struct GNUNET_FS_SearchContext * update_search
If this search result triggered an update search, this field links to the update search.
Definition: fs_api.h:551
static char * value
Value of the record to add/remove.
Information we store for each search result.
Definition: fs_api.h:497
void GNUNET_FS_search_start_probe_(struct GNUNET_FS_SearchResult *sr)
Start download probes for the given search result.
Definition: fs_search.c:430
Here is the call graph for this function:
Here is the caller graph for this function:

◆ search_result_suspend()

static int search_result_suspend ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Signal suspend and free the given search result.

Parameters
clsthe global FS handle
keythe key for the search result (unused)
valuethe search result to free
Returns
GNUNET_OK

Definition at line 1522 of file fs_search.c.

References GNUNET_FS_SearchResult::client_info, GNUNET_FS_SearchResult::download, GNUNET_break, GNUNET_CONTAINER_meta_data_destroy(), GNUNET_free, GNUNET_free_non_null, GNUNET_FS_download_signal_suspend_(), GNUNET_FS_search_make_status_(), GNUNET_FS_search_signal_suspend_(), GNUNET_FS_search_stop_probe_(), GNUNET_FS_STATUS_SEARCH_RESULT_SUSPEND, GNUNET_FS_uri_destroy(), GNUNET_OK, GNUNET_FS_SearchContext::h, GNUNET_FS_SearchResult::keyword_bitmap, GNUNET_FS_SearchResult::mandatory_missing, GNUNET_FS_SearchResult::meta, GNUNET_FS_ProgressInfo::search, GNUNET_FS_SearchResult::serialization, GetResultContext::sr, GNUNET_FS_ProgressInfo::status, GNUNET_FS_SearchResult::update_search, GNUNET_FS_SearchResult::uri, value, and GNUNET_FS_ProgressInfo::value.

Referenced by GNUNET_FS_search_signal_suspend_().

1525 {
1526  struct GNUNET_FS_SearchContext *sc = cls;
1527  struct GNUNET_FS_SearchResult *sr = value;
1528  struct GNUNET_FS_ProgressInfo pi;
1529 
1530  if (NULL != sr->download)
1531  {
1533  sr->download = NULL;
1534  }
1535  if (NULL != sr->update_search)
1536  {
1538  sr->update_search = NULL;
1539  }
1541  if (0 == sr->mandatory_missing)
1542  {
1543  /* client is aware of search result, notify about suspension event */
1545  pi.value.search.specifics.result_suspend.cctx = sr->client_info;
1546  pi.value.search.specifics.result_suspend.meta = sr->meta;
1547  pi.value.search.specifics.result_suspend.uri = sr->uri;
1548  sr->client_info = GNUNET_FS_search_make_status_ (&pi, sc->h, sc);
1549  }
1550  GNUNET_break (NULL == sr->client_info);
1552  GNUNET_FS_uri_destroy (sr->uri);
1555  GNUNET_free (sr);
1556  return GNUNET_OK;
1557 }
void * client_info
Client info for this search result.
Definition: fs_api.h:533
struct GNUNET_FS_DownloadContext * download
ID of an associated download based on this search result (or NULL for none).
Definition: fs_api.h:545
uint8_t * keyword_bitmap
Bitmap that specifies precisely which keywords have been matched already.
Definition: fs_api.h:561
struct GNUNET_FS_Uri * uri
URI to which this search result refers to.
Definition: fs_api.h:523
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
static struct GNUNET_PEERINFO_Handle * pi
Handle to peerinfo service.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_FS_SearchContext * update_search
If this search result triggered an update search, this field links to the update search.
Definition: fs_api.h:551
void GNUNET_FS_download_signal_suspend_(void *cls)
Create SUSPEND event for the given download operation and then clean up our state (without stop signa...
Definition: fs_download.c:1968
static char * value
Value of the record to add/remove.
Information we store for each search result.
Definition: fs_api.h:497
void GNUNET_CONTAINER_meta_data_destroy(struct GNUNET_CONTAINER_MetaData *md)
Free meta data.
static void GNUNET_FS_search_stop_probe_(struct GNUNET_FS_SearchResult *sr)
Stop probing activity associated with a search result.
Definition: fs_search.c:515
void GNUNET_FS_uri_destroy(struct GNUNET_FS_Uri *uri)
Free URI.
Definition: fs_uri.c:678
static struct GNUNET_FS_SearchContext * sc
Definition: gnunet-search.c:37
struct GNUNET_CONTAINER_MetaData * meta
Metadata for the search result.
Definition: fs_api.h:528
uint32_t mandatory_missing
Number of mandatory keywords for which we have NOT yet found the search result; when this value hits ...
Definition: fs_api.h:595
Event generated for each search result when the respective search is suspended.
Handle for controlling a search.
Definition: fs_api.h:1509
struct GNUNET_FS_Handle * h
Handle to the global FS context.
Definition: fs_api.h:1514
void * GNUNET_FS_search_make_status_(struct GNUNET_FS_ProgressInfo *pi, struct GNUNET_FS_Handle *h, struct GNUNET_FS_SearchContext *sc)
Fill in all of the generic fields for a search event and call the callback.
Definition: fs_search.c:48
char * serialization
Name under which this search result is stored on disk.
Definition: fs_api.h:556
void GNUNET_FS_search_signal_suspend_(void *cls)
Create SUSPEND event for the given search operation and then clean up our state (without stop signal)...
Definition: fs_search.c:1567
#define GNUNET_free(ptr)
Wrapper around free.
Argument given to the progress callback with information about what is going on.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_FS_search_signal_suspend_()

void GNUNET_FS_search_signal_suspend_ ( void *  cls)

Create SUSPEND event for the given search operation and then clean up our state (without stop signal).

Parameters
clsthe struct GNUNET_FS_SearchContext to signal for

Definition at line 1567 of file fs_search.c.

References GNUNET_FS_SearchContext::client_info, GNUNET_FS_Uri::data, GNUNET_FS_SearchContext::emsg, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_free, GNUNET_free_non_null, GNUNET_FS_end_top(), GNUNET_FS_search_make_status_(), GNUNET_FS_STATUS_SEARCH_SUSPEND, GNUNET_FS_uri_destroy(), GNUNET_FS_uri_test_ksk(), GNUNET_MQ_destroy(), GNUNET_SCHEDULER_cancel(), GNUNET_FS_SearchContext::h, SearchRequestEntry::keyword, GNUNET_FS_Uri::ksk, GNUNET_FS_SearchContext::master_result_map, GNUNET_FS_SearchContext::mq, GNUNET_FS_SearchContext::requests, SearchRequestEntry::results, search_result_suspend(), GNUNET_FS_SearchContext::serialization, GNUNET_FS_ProgressInfo::status, GNUNET_FS_SearchContext::task, GNUNET_FS_SearchContext::top, and GNUNET_FS_SearchContext::uri.

Referenced by deserialize_search_file(), GNUNET_FS_search_start(), and search_result_suspend().

1568 {
1569  struct GNUNET_FS_SearchContext *sc = cls;
1570  struct GNUNET_FS_ProgressInfo pi;
1571  unsigned int i;
1572 
1573  GNUNET_FS_end_top (sc->h, sc->top);
1575  &search_result_suspend, sc);
1577  sc->client_info = GNUNET_FS_search_make_status_ (&pi, sc->h, sc);
1578  GNUNET_break (NULL == sc->client_info);
1579  if (sc->task != NULL)
1580  {
1582  sc->task = NULL;
1583  }
1584  if (NULL != sc->mq)
1585  {
1586  GNUNET_MQ_destroy (sc->mq);
1587  sc->mq = NULL;
1588  }
1590  if (NULL != sc->requests)
1591  {
1593  for (i = 0; i < sc->uri->data.ksk.keywordCount; i++)
1594  {
1596  GNUNET_free (sc->requests[i].keyword);
1597  }
1598  }
1600  GNUNET_free_non_null (sc->emsg);
1601  GNUNET_FS_uri_destroy (sc->uri);
1603  GNUNET_free (sc);
1604 }
int GNUNET_FS_uri_test_ksk(const struct GNUNET_FS_Uri *uri)
Is this a keyword URI?
Definition: fs_uri.c:1335
struct GNUNET_SCHEDULER_Task * task
ID of a task that is using this struct and that must be cancelled when the search is being stopped (i...
Definition: fs_api.h:1582
struct TopLevelActivity * top
Our top-level activity entry (if we are top-level, otherwise NULL).
Definition: fs_api.h:1519
char * emsg
Error message (non-NULL if this operation failed).
Definition: fs_api.h:1550
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
static struct GNUNET_PEERINFO_Handle * pi
Handle to peerinfo service.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct SearchRequestEntry * requests
Per-keyword information for a keyword search.
Definition: fs_api.h:1564
struct GNUNET_FS_Uri * uri
List of keywords that we&#39;re looking for.
Definition: fs_api.h:1524
char * serialization
Name of the file on disk we use for persistence.
Definition: fs_api.h:1545
struct GNUNET_CONTAINER_MultiHashMap * master_result_map
Map that contains a struct GNUNET_FS_SearchResult for each result that was found in the search...
Definition: fs_api.h:1558
void GNUNET_FS_end_top(struct GNUNET_FS_Handle *h, struct TopLevelActivity *top)
Destroy a top-level activity entry.
Definition: fs_api.c:412
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
struct GNUNET_CONTAINER_MultiHashMap * results
Map that contains a "struct GNUNET_FS_SearchResult" for each result that was found under this keyword...
Definition: fs_api.h:1496
void GNUNET_FS_uri_destroy(struct GNUNET_FS_Uri *uri)
Free URI.
Definition: fs_uri.c:678
Last event when a search is being suspended; note that "GNUNET_FS_SEARCH_STOPPED" will not be generat...
static struct GNUNET_FS_SearchContext * sc
Definition: gnunet-search.c:37
union GNUNET_FS_Uri::@13 data
Handle for controlling a search.
Definition: fs_api.h:1509
struct GNUNET_FS_Uri::@13::@14 ksk
static int search_result_suspend(void *cls, const struct GNUNET_HashCode *key, void *value)
Signal suspend and free the given search result.
Definition: fs_search.c:1522
struct GNUNET_MQ_Handle * mq
Connection to the FS service.
Definition: fs_api.h:1535
struct GNUNET_FS_Handle * h
Handle to the global FS context.
Definition: fs_api.h:1514
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
void * GNUNET_FS_search_make_status_(struct GNUNET_FS_ProgressInfo *pi, struct GNUNET_FS_Handle *h, struct GNUNET_FS_SearchContext *sc)
Fill in all of the generic fields for a search event and call the callback.
Definition: fs_search.c:48
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
void * client_info
Pointer we keep for the client.
Definition: fs_api.h:1540
char * keyword
The original keyword, used to derive the key (for decrypting the UBlock).
Definition: fs_api.h:1486
#define GNUNET_free(ptr)
Wrapper around free.
Argument given to the progress callback with information about what is going on.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
Here is the call graph for this function:
Here is the caller graph for this function:

◆ search_result_stop()

static int search_result_stop ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Signal stop for the given search result.

Parameters
clsthe global FS handle
keythe key for the search result (unused)
valuethe search result to free
Returns
GNUNET_OK

Definition at line 1694 of file fs_search.c.

References GNUNET_FS_SearchResult::client_info, GNUNET_FS_SearchResult::download, GNUNET_break, GNUNET_free, GNUNET_FS_download_make_status_(), GNUNET_FS_download_signal_suspend_(), GNUNET_FS_download_sync_(), GNUNET_FS_make_top(), GNUNET_FS_remove_sync_file_(), GNUNET_FS_search_make_status_(), GNUNET_FS_search_stop_probe_(), GNUNET_FS_STATUS_DOWNLOAD_LOST_PARENT, GNUNET_FS_STATUS_SEARCH_RESULT_STOPPED, GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD, GNUNET_OK, GNUNET_FS_SearchResult::h, GNUNET_FS_SearchContext::h, GNUNET_FS_DownloadContext::h, GNUNET_FS_SearchResult::mandatory_missing, GNUNET_FS_SearchResult::meta, GNUNET_FS_ProgressInfo::search, GNUNET_FS_DownloadContext::search, GNUNET_FS_DownloadContext::serialization, GetResultContext::sr, GNUNET_FS_ProgressInfo::status, GNUNET_FS_DownloadContext::top, GNUNET_FS_SearchResult::uri, value, and GNUNET_FS_ProgressInfo::value.

Referenced by GNUNET_FS_search_stop().

1697 {
1698  struct GNUNET_FS_SearchContext *sc = cls;
1699  struct GNUNET_FS_SearchResult *sr = value;
1700  struct GNUNET_FS_ProgressInfo pi;
1701 
1703  if (NULL != sr->download)
1704  {
1705  sr->download->search = NULL;
1706  sr->download->top
1707  = GNUNET_FS_make_top (sr->download->h,
1709  sr->download);
1710  if (NULL != sr->download->serialization)
1711  {
1714  sr->download->serialization);
1716  sr->download->serialization = NULL;
1717  }
1720  sr->download);
1722  sr->download = NULL;
1723  }
1724  if (0 != sr->mandatory_missing)
1725  {
1726  /* client is unaware of search result as
1727  it does not match required keywords */
1728  GNUNET_break (NULL == sr->client_info);
1729  return GNUNET_OK;
1730  }
1732  pi.value.search.specifics.result_stopped.cctx = sr->client_info;
1733  pi.value.search.specifics.result_stopped.meta = sr->meta;
1734  pi.value.search.specifics.result_stopped.uri = sr->uri;
1735  sr->client_info = GNUNET_FS_search_make_status_ (&pi, sr->h, sc);
1736  return GNUNET_OK;
1737 }
void * client_info
Client info for this search result.
Definition: fs_api.h:533
struct GNUNET_FS_DownloadContext * download
ID of an associated download based on this search result (or NULL for none).
Definition: fs_api.h:545
struct GNUNET_FS_Handle * h
Global FS context.
Definition: fs_api.h:1747
#define GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD
Name of the directory with downloads that are part of another download or a search.
Definition: fs_api.h:71
Event generated for each search result when the respective search is stopped.
void GNUNET_FS_download_sync_(struct GNUNET_FS_DownloadContext *dc)
Synchronize this download struct with its mirror on disk.
Definition: fs_api.c:1972
void GNUNET_FS_download_make_status_(struct GNUNET_FS_ProgressInfo *pi, struct GNUNET_FS_DownloadContext *dc)
Fill in all of the generic fields for a download event and call the callback.
Definition: fs_download.c:103
struct GNUNET_FS_Uri * uri
URI to which this search result refers to.
Definition: fs_api.h:523
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
static struct GNUNET_PEERINFO_Handle * pi
Handle to peerinfo service.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
void GNUNET_FS_download_signal_suspend_(void *cls)
Create SUSPEND event for the given download operation and then clean up our state (without stop signa...
Definition: fs_download.c:1968
char * serialization
Random portion of filename we use for syncing state of this download.
Definition: fs_api.h:1815
static char * value
Value of the record to add/remove.
Information we store for each search result.
Definition: fs_api.h:497
struct GNUNET_FS_Handle * h
File-sharing context this result belongs to.
Definition: fs_api.h:502
static void GNUNET_FS_search_stop_probe_(struct GNUNET_FS_SearchResult *sr)
Stop probing activity associated with a search result.
Definition: fs_search.c:515
struct TopLevelActivity * top
Our top-level activity entry (if we are top-level, otherwise NULL).
Definition: fs_api.h:1752
struct GNUNET_FS_SearchResult * search
Associated search (used when downloading files based on search results), or NULL for none...
Definition: fs_api.h:1769
static struct GNUNET_FS_SearchContext * sc
Definition: gnunet-search.c:37
struct GNUNET_CONTAINER_MetaData * meta
Metadata for the search result.
Definition: fs_api.h:528
struct TopLevelActivity * GNUNET_FS_make_top(struct GNUNET_FS_Handle *h, SuspendSignalFunction ssf, void *ssf_cls)
Create a top-level activity entry.
Definition: fs_api.c:391
Notification that this download is no longer part of a recursive download or search but now a &#39;stand-...
uint32_t mandatory_missing
Number of mandatory keywords for which we have NOT yet found the search result; when this value hits ...
Definition: fs_api.h:595
Handle for controlling a search.
Definition: fs_api.h:1509
struct GNUNET_FS_Handle * h
Handle to the global FS context.
Definition: fs_api.h:1514
void * GNUNET_FS_search_make_status_(struct GNUNET_FS_ProgressInfo *pi, struct GNUNET_FS_Handle *h, struct GNUNET_FS_SearchContext *sc)
Fill in all of the generic fields for a search event and call the callback.
Definition: fs_search.c:48
void GNUNET_FS_remove_sync_file_(struct GNUNET_FS_Handle *h, const char *ext, const char *ent)
Remove serialization/deserialization file from disk.
Definition: fs_api.c:744
#define GNUNET_free(ptr)
Wrapper around free.
Argument given to the progress callback with information about what is going on.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ search_result_free()

static int search_result_free ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Free the given search result.

Parameters
clsthe global FS handle
keythe key for the search result (unused)
valuethe search result to free
Returns
GNUNET_OK

Definition at line 1749 of file fs_search.c.

References GNUNET_FS_SearchResult::client_info, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_meta_data_destroy(), GNUNET_free, GNUNET_free_non_null, GNUNET_FS_search_stop(), GNUNET_FS_uri_destroy(), GNUNET_OK, GNUNET_FS_SearchResult::keyword_bitmap, GNUNET_FS_SearchResult::meta, GNUNET_FS_SearchResult::probe_cancel_task, GNUNET_FS_SearchResult::probe_ctx, GNUNET_FS_SearchResult::serialization, GetResultContext::sr, GNUNET_FS_SearchResult::update_search, GNUNET_FS_SearchResult::uri, and value.

Referenced by GNUNET_FS_search_stop().

1752 {
1753  struct GNUNET_FS_SearchResult *sr = value;
1754 
1755  if (NULL != sr->update_search)
1756  {
1758  GNUNET_assert (NULL == sr->update_search);
1759  }
1760  GNUNET_break (NULL == sr->probe_ctx);
1761  GNUNET_break (NULL == sr->probe_cancel_task);
1762  GNUNET_break (NULL == sr->client_info);
1764  GNUNET_FS_uri_destroy (sr->uri);
1767  GNUNET_free (sr);
1768  return GNUNET_OK;
1769 }
void * client_info
Client info for this search result.
Definition: fs_api.h:533
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
uint8_t * keyword_bitmap
Bitmap that specifies precisely which keywords have been matched already.
Definition: fs_api.h:561
struct GNUNET_FS_Uri * uri
URI to which this search result refers to.
Definition: fs_api.h:523
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
struct GNUNET_FS_DownloadContext * probe_ctx
ID of a job that is currently probing this results&#39; availability (NULL if we are not currently probin...
Definition: fs_api.h:539
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_FS_SearchContext * update_search
If this search result triggered an update search, this field links to the update search.
Definition: fs_api.h:551
static char * value
Value of the record to add/remove.
Information we store for each search result.
Definition: fs_api.h:497
void GNUNET_CONTAINER_meta_data_destroy(struct GNUNET_CONTAINER_MetaData *md)
Free meta data.
void GNUNET_FS_uri_destroy(struct GNUNET_FS_Uri *uri)
Free URI.
Definition: fs_uri.c:678
struct GNUNET_CONTAINER_MetaData * meta
Metadata for the search result.
Definition: fs_api.h:528
char * serialization
Name under which this search result is stored on disk.
Definition: fs_api.h:556
void GNUNET_FS_search_stop(struct GNUNET_FS_SearchContext *sc)
Stop search for content.
Definition: fs_search.c:1778
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_SCHEDULER_Task * probe_cancel_task
ID of the task that will clean up the probe_ctx should it not complete on time (and that will need to...
Definition: fs_api.h:573
Here is the call graph for this function:
Here is the caller graph for this function: