34 #define CONTENT_LIFETIME GNUNET_TIME_UNIT_HOURS
214 "Timeout while trying to publish data\n");
235 switch (
info->status)
249 (
unsigned long long)
info->value.publish.completed,
250 (
unsigned long long)
info->value.publish.size);
259 (
unsigned long long)
info->value.download.completed,
260 (
unsigned long long)
info->value.download.size);
296 for (pos = 0; pos < 8; pos++)
297 cbuf[pos] = (uint8_t) (offset >> pos * 8);
298 for (pos = 8; pos <
max; pos++)
300 mod = (255 - (offset / 1024 / 32));
303 cbuf[pos] = (uint8_t) ((offset * (*
publish_seed)) % mod);
372 if (NULL == ca_result)
375 "Failed to connect to FS for publishing: %s\n", emsg);
399 while (off < po->
size)
435 int do_index, uint64_t
size, uint32_t seed,
476 "Timeout while trying to download file\n");
520 switch (
info->status)
525 "Download at %llu/%llu bytes\n",
526 (
unsigned long long)
info->value.download.completed,
527 (
unsigned long long)
info->value.download.size);
#define DBLOCK_SIZE
Size of the individual blocks used for file-sharing.
shared definitions for the FS library
static size_t file_generator(void *cls, uint64_t offset, size_t max, void *buf, char **emsg)
Generate test data for publishing test.
static void download_timeout(void *cls)
Task scheduled to run when download operation times out.
static void fs_disconnect_adapter(void *cls, void *op_result)
Adapter function called to destroy connection to file-sharing service.
void GNUNET_FS_TEST_download(struct GNUNET_TESTBED_Peer *peer, struct GNUNET_TIME_Relative timeout, uint32_t anonymity, uint32_t seed, const struct GNUNET_FS_Uri *uri, unsigned int verbose, GNUNET_SCHEDULER_TaskCallback cont, void *cont_cls)
Perform test download.
static void report_uri(void *cls)
Task scheduled to report on the completion of our publish operation.
static void * publish_progress_cb(void *cls, const struct GNUNET_FS_ProgressInfo *info)
Progress callback for file-sharing events while publishing.
static void * publish_connect_adapter(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect adapter for publishing operation.
static void publish_timeout(void *cls)
Task scheduled to run when publish operation times out.
static void download_fs_connect_complete_cb(void *cls, struct GNUNET_TESTBED_Operation *op, void *ca_result, const char *emsg)
Callback to be called when testbed has connected to the fs service.
static void * download_connect_adapter(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect adapter for download operation.
static void report_success(void *cls)
Task scheduled to report on the completion of our download operation.
static void publish_fs_connect_complete_cb(void *cls, struct GNUNET_TESTBED_Operation *op, void *ca_result, const char *emsg)
Callback to be called when testbed has connected to the fs service.
static void * download_progress_cb(void *cls, const struct GNUNET_FS_ProgressInfo *info)
Progress callback for file-sharing events while downloading.
void GNUNET_FS_TEST_publish(struct GNUNET_TESTBED_Peer *peer, struct GNUNET_TIME_Relative timeout, uint32_t anonymity, int do_index, uint64_t size, uint32_t seed, unsigned int verbose, GNUNET_FS_TEST_UriContinuation cont, void *cont_cls)
Publish a file at the given daemon.
library routines for testing FS publishing and downloading; this code is limited to flat files and no...
void(* GNUNET_FS_TEST_UriContinuation)(void *cls, const struct GNUNET_FS_Uri *uri, const char *fn)
Function signature.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
static struct GNUNET_TIME_Relative timeout
Desired timeout for the lookup (default is no timeout).
static struct GNUNET_ARM_Operation * op
Current operation.
static unsigned int anonymity
static struct GNUNET_FS_Handle * fs
Handle to FS service.
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 struct GNUNET_FS_BlockOptions bo
Options we set for published blocks.
static unsigned int bsize
static struct GNUNET_DISK_FileHandle * fh
File handle to STDIN, for reading restart/quit commands.
struct GNUNET_DISK_FileHandle * GNUNET_DISK_file_open(const char *fn, enum GNUNET_DISK_OpenFlags flags, enum GNUNET_DISK_AccessPermissions perm)
Open a file.
char * GNUNET_DISK_mktemp(const char *t)
Create an (empty) temporary file on disk.
ssize_t GNUNET_DISK_file_write(const struct GNUNET_DISK_FileHandle *h, const void *buffer, size_t n)
Write a buffer to a file.
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_remove(const char *filename)
Remove all files in a directory (rm -rf).
enum GNUNET_GenericReturnValue GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
@ GNUNET_DISK_OPEN_WRITE
Open the file for writing.
@ GNUNET_DISK_OPEN_CREATE
Create file if it doesn't exist.
@ GNUNET_DISK_PERM_USER_READ
Owner can read.
@ GNUNET_DISK_PERM_USER_WRITE
Owner can write.
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?
struct GNUNET_FS_FileInformation * GNUNET_FS_file_information_create_from_file(struct GNUNET_FS_Handle *h, void *client_info, const char *filename, const struct GNUNET_FS_Uri *keywords, const struct GNUNET_FS_MetaData *meta, int do_index, const struct GNUNET_FS_BlockOptions *bo)
Create an entry for a file in a publish-structure.
struct GNUNET_FS_PublishContext * GNUNET_FS_publish_start(struct GNUNET_FS_Handle *h, struct GNUNET_FS_FileInformation *fi, const struct GNUNET_CRYPTO_EcdsaPrivateKey *ns, const char *nid, const char *nuid, enum GNUNET_FS_PublishOptions options)
Publish a file or directory.
void GNUNET_FS_uri_destroy(struct GNUNET_FS_Uri *uri)
Free URI.
struct GNUNET_FS_DownloadContext * GNUNET_FS_download_start(struct GNUNET_FS_Handle *h, const struct GNUNET_FS_Uri *uri, const struct GNUNET_FS_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.
struct GNUNET_FS_Uri * GNUNET_FS_uri_dup(const struct GNUNET_FS_Uri *uri)
Duplicate URI.
struct GNUNET_FS_FileInformation * GNUNET_FS_file_information_create_from_reader(struct GNUNET_FS_Handle *h, void *client_info, uint64_t length, GNUNET_FS_DataReader reader, void *reader_cls, const struct GNUNET_FS_Uri *keywords, const struct GNUNET_FS_MetaData *meta, int do_index, const struct GNUNET_FS_BlockOptions *bo)
Create an entry for a file in a publish-structure.
void GNUNET_FS_download_stop(struct GNUNET_FS_DownloadContext *dc, int do_delete)
Stop a download (aborts if download is incomplete).
struct GNUNET_FS_Handle * GNUNET_FS_start(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *client_name, GNUNET_FS_ProgressCallback upcb, void *upcb_cls, enum GNUNET_FS_Flags flags,...)
Setup a connection to the file-sharing service.
void GNUNET_FS_stop(struct GNUNET_FS_Handle *h)
Close our connection with the file-sharing service.
void GNUNET_FS_publish_stop(struct GNUNET_FS_PublishContext *pc)
Stop an upload.
@ GNUNET_FS_FLAGS_NONE
No special flags set.
@ GNUNET_FS_DOWNLOAD_OPTION_NONE
No options (use defaults for everything).
@ GNUNET_FS_OPTIONS_END
Last option in the VARARG list.
@ GNUNET_FS_STATUS_DOWNLOAD_INACTIVE
Notification that this download is no longer actively being pursued (back in the queue).
@ GNUNET_FS_STATUS_DOWNLOAD_COMPLETED
Notification that this download completed.
@ GNUNET_FS_STATUS_PUBLISH_PROGRESS
Notification that we are making progress sharing a file structure.
@ GNUNET_FS_STATUS_DOWNLOAD_PROGRESS
Notification about progress with this download.
@ GNUNET_FS_STATUS_PUBLISH_PROGRESS_DIRECTORY
Notification that we are making progress sharing a directory.
@ GNUNET_FS_STATUS_PUBLISH_COMPLETED
Notification that we completed sharing a file structure.
@ GNUNET_FS_STATUS_DOWNLOAD_ACTIVE
Notification that this download is now actively being pursued (as opposed to waiting in the queue).
@ GNUNET_FS_PUBLISH_OPTION_NONE
No options (use defaults for everything).
#define GNUNET_log(kind,...)
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
@ GNUNET_ERROR_TYPE_ERROR
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
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.
void(* GNUNET_SCHEDULER_TaskCallback)(void *cls)
Signature of the main function of a task.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
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.
void GNUNET_TESTBED_operation_done(struct GNUNET_TESTBED_Operation *operation)
This function is used to signal that the event information (struct GNUNET_TESTBED_EventInformation) f...
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_service_connect(void *op_cls, struct GNUNET_TESTBED_Peer *peer, const char *service_name, GNUNET_TESTBED_ServiceConnectCompletionCallback cb, void *cb_cls, GNUNET_TESTBED_ConnectAdapter ca, GNUNET_TESTBED_DisconnectAdapter da, void *cada_cls)
Connect to a service offered by the given peer.
struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute(struct GNUNET_TIME_Relative rel)
Convert relative time to an absolute time in the future.
static int op_result(struct GNUNET_OP_Handle *h, uint64_t op_id, int64_t result_code, const void *data, uint16_t data_size, void **ctx, uint8_t cancel)
Remove an operation, and call its result callback (unless it was cancelled).
static unsigned int size
Size of the "table".
Handle used to access files (and pipes).
Settings for publishing a block (which may of course also apply to an entire directory or file).
uint32_t anonymity_level
At which anonymity level should the block be shared? (0: no anonymity, 1: normal GAP,...
uint32_t content_priority
How important is it for us to store the block? If we run out of space, the highest-priority,...
uint32_t replication_level
How often should we try to migrate the block to other peers? Only used if "CONTENT_PUSHING" is set to...
struct GNUNET_TIME_Absolute expiration_time
At what time should the block expire? Data blocks (DBLOCKS and IBLOCKS) may still be used even if the...
Context for controlling a download.
Master context for most FS operations.
Argument given to the progress callback with information about what is going on.
Handle for controlling a publication process.
A Universal Resource Identifier (URI), opaque.
Entry in list of pending tasks.
Opaque handle to an abstract operation to be executed by the testing framework.
A peer controlled by the testing framework.
Time for relative time used by GNUnet, in microseconds.
Handle for a download operation started for testing FS.
uint32_t download_seed
Seed for download verification.
struct GNUNET_FS_DownloadContext * download_context
Context for current download operation.
uint32_t anonymity
Anonymity level used.
unsigned int verbose
Verbosity level of the current operation.
struct GNUNET_FS_Uri * uri
URI to download.
struct GNUNET_TESTING_Daemon * daemon
Handle to the daemon via testing.
struct GNUNET_SCHEDULER_Task * download_timeout_task
Task to abort downloading (timeout).
void * download_cont_cls
Closure for download_cont.
struct GNUNET_TESTBED_Operation * fs_op
Handle for the operation to connect to the peer's 'fs' service.
uint64_t size
Size of the file.
GNUNET_SCHEDULER_TaskCallback download_cont
Function to call when download is done.
struct GNUNET_FS_Handle * fs
Handle to the file sharing context using this daemon.
Handle for a publishing operation started for testing FS.
void * publish_cont_cls
Closure for publish_cont.
uint32_t anonymity
Anonymity level used.
GNUNET_FS_TEST_UriContinuation publish_cont
Function to call when upload is done.
struct GNUNET_TESTBED_Operation * fs_op
Handle for the operation to connect to the peer's 'fs' service.
struct GNUNET_FS_Handle * fs
Handle to the file sharing context using this daemon.
uint32_t publish_seed
Seed for file generation.
uint64_t size
Size of the file.
int do_index
Are we testing indexing? (YES: index, NO: insert, SYSERR: simulate)
char * publish_tmp_file
Name of the temporary file used, or NULL for none.
struct GNUNET_FS_Uri * publish_uri
Result URI.
unsigned int verbose
Verbosity level of the current operation.
struct GNUNET_SCHEDULER_Task * publish_timeout_task
Task to abort publishing (timeout).
struct GNUNET_FS_PublishContext * publish_context
Context for current publishing operation.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.