0.9.0pre1:
+* MIGRATION [CG]
+ - on-demand encoding => move logic to block-library!?
+ - peer selection => how to consider latency/bw/etc?
+ - content transmission => how often the same block?
+ - how to select delay before next migration?
+ - testing
* FS: [CG]
+ - migration (inbound)
+ - support for in-line files in directories (FIXME in fs_download)
- bound parallelism (# fs downloads)
- distinguish in performance tracking and event signalling between
downloads that are actually running and those that are merely in the queue
- persistence support (publish, unindex, search, download)
- - active migration support (in fs or in datastore or new daemon?)
- - support for in-line files in directories (FIXME in fs_download)
- gnunet-service-fs (hot-path routing, load-based routing, nitpicks)
- [gnunet-service-fs.c:208]: member 'LocalGetContext::results_bf_size' is never used
- [gnunet-service-fs.c:501]: member 'PendingRequest::used_pids_size' is never used
+ download
+ search
+ unindex
+* MIGRATION:
+ - improved content selection (not just 'get_random')
0.9.0pre3:
* Determine RC bugs and fix those!
- add stats (# bytes available, # bytes used, # PUTs, # GETs, # GETs satisfied)
* FS:
- support inline data in directories for recursive file downloads (fs_download)
-
+* BLOCKS:
+ - testcase would be nice...
po/Makefile.in
src/Makefile
src/arm/Makefile
+src/block/Makefile
src/core/Makefile
src/datacache/Makefile
src/datastore/Makefile
src/include/Makefile
src/include/gnunet_directories.h
src/hostlist/Makefile
+src/migration/Makefile
src/nat/Makefile
src/nat/libnatpmp/Makefile
src/nat/miniupnp/Makefile
SUBDIRS = \
include $(INTLEMU_SUBDIRS) \
util \
+ block \
statistics \
arm \
hello \
hostlist \
topology \
$(NAT_DIR) \
- fs
+ fs \
+ migration
const GNUNET_HashCode * key,
uint32_t size,
const char *data,
- unsigned int type,
+ enum GNUNET_BLOCK_Type type,
struct GNUNET_TIME_Absolute discard_time)
{
uint32_t used;
unsigned int
GNUNET_DATACACHE_get (struct GNUNET_DATACACHE_Handle *h,
const GNUNET_HashCode * key,
- unsigned int type,
+ enum GNUNET_BLOCK_Type type,
GNUNET_DATACACHE_Iterator iter,
void *iter_cls)
{
const GNUNET_HashCode * key,
uint32_t size,
const char *data,
- uint32_t type)
+ enum GNUNET_BLOCK_Type type)
{
if ( (size == sizeof (GNUNET_HashCode)) &&
(0 == memcmp (data, cls, size)) )
const GNUNET_HashCode * key,
uint32_t size,
const char *data,
- uint32_t type,
+ enum GNUNET_BLOCK_Type type,
struct GNUNET_TIME_Absolute discard_time);
*/
unsigned int (*get) (void *cls,
const GNUNET_HashCode * key,
- uint32_t type,
+ enum GNUNET_BLOCK_Type type,
GNUNET_DATACACHE_Iterator iter,
void *iter_cls);
const GNUNET_HashCode * key,
uint32_t size,
const char *data,
- uint32_t type,
+ enum GNUNET_BLOCK_Type type,
struct GNUNET_TIME_Absolute discard_time)
{
struct Plugin *plugin = cls;
static unsigned int
sqlite_plugin_get (void *cls,
const GNUNET_HashCode * key,
- uint32_t type,
+ enum GNUNET_BLOCK_Type type,
GNUNET_DATACACHE_Iterator iter,
void *iter_cls)
{
const GNUNET_HashCode * key,
uint32_t size,
const char *data,
- uint32_t type,
+ enum GNUNET_BLOCK_Type type,
struct GNUNET_TIME_Absolute discard_time)
{
GNUNET_break (0);
static unsigned int
template_plugin_get (void *cls,
const GNUNET_HashCode * key,
- uint32_t type,
+ enum GNUNET_BLOCK_Type type,
GNUNET_DATACACHE_Iterator iter,
void *iter_cls)
{
const GNUNET_HashCode * key,
uint32_t size,
const char *data,
- uint32_t type)
+ enum GNUNET_BLOCK_Type type)
{
if (size != sizeof (GNUNET_HashCode))
{
const GNUNET_HashCode * key,
uint32_t size,
const void *data,
- uint32_t type,
+ enum GNUNET_BLOCK_Type type,
uint32_t priority,
uint32_t anonymity,
struct GNUNET_TIME_Absolute expiration,
void
GNUNET_DATASTORE_get (struct GNUNET_DATASTORE_Handle *h,
const GNUNET_HashCode * key,
- uint32_t type,
+ enum GNUNET_BLOCK_Type type,
GNUNET_DATASTORE_Iterator iter, void *iter_cls,
struct GNUNET_TIME_Relative timeout)
{
const GNUNET_HashCode * key,
uint32_t size,
const void *data,
- uint32_t type,
+ enum GNUNET_BLOCK_Type type,
uint32_t priority,
uint32_t anonymity,
struct GNUNET_TIME_Absolute
const GNUNET_HashCode * key,
uint32_t size,
const void *data,
- uint32_t type,
+ enum GNUNET_BLOCK_Type type,
uint32_t priority,
uint32_t anonymity,
struct GNUNET_TIME_Absolute
const GNUNET_HashCode * key,
uint32_t size,
const void *data,
- uint32_t type,
+ enum GNUNET_BLOCK_Type type,
uint32_t priority,
uint32_t anonymity,
struct GNUNET_TIME_Absolute
const GNUNET_HashCode * key,
uint32_t size,
const void *data,
- uint32_t type,
+ enum GNUNET_BLOCK_Type type,
uint32_t priority,
uint32_t anonymity,
struct GNUNET_TIME_Absolute
const GNUNET_HashCode * key,
uint32_t size,
const void *data,
- uint32_t type,
+ enum GNUNET_BLOCK_Type type,
uint32_t priority,
uint32_t anonymity,
struct GNUNET_TIME_Absolute
const GNUNET_HashCode * key,
uint32_t size,
const void *data,
- uint32_t type,
+ enum GNUNET_BLOCK_Type type,
uint32_t priority,
uint32_t anonymity,
struct GNUNET_TIME_Absolute
#ifndef PLUGIN_DATASTORE_H
#define PLUGIN_DATASTORE_H
+#include "gnunet_block_lib.h"
#include "gnunet_configuration_lib.h"
#include "gnunet_datastore_service.h"
#include "gnunet_statistics_service.h"
const GNUNET_HashCode * key,
uint32_t size,
const void *data,
- uint32_t type,
+ enum GNUNET_BLOCK_Type type,
uint32_t priority,
uint32_t anonymity,
struct GNUNET_TIME_Absolute
const GNUNET_HashCode * key,
uint32_t size,
const void *data,
- uint32_t type,
+ enum GNUNET_BLOCK_Type type,
uint32_t priority,
uint32_t anonymity,
struct GNUNET_TIME_Absolute expiration,
typedef void (*PluginGet) (void *cls,
const GNUNET_HashCode * key,
const GNUNET_HashCode * vhash,
- uint32_t type,
+ enum GNUNET_BLOCK_Type type,
PluginIterator iter, void *iter_cls);
* @param iter_cls closure for iter
*/
typedef void (*PluginSelector) (void *cls,
- uint32_t type,
+ enum GNUNET_BLOCK_Type type,
PluginIterator iter,
void *iter_cls);
const GNUNET_HashCode * key,
uint32_t size,
const void *data,
- uint32_t type,
+ enum GNUNET_BLOCK_Type type,
uint32_t priority,
uint32_t anonymity,
struct GNUNET_TIME_Absolute expiration,
/**
* Desired type for blocks returned by this iterator.
*/
- uint32_t type;
+ enum GNUNET_BLOCK_Type type;
};
*/
static void
basic_iter (struct Plugin *plugin,
- uint32_t type,
+ enum GNUNET_BLOCK_Type type,
int is_asc,
int is_prio,
int is_migr,
*/
static void
sqlite_plugin_iter_low_priority (void *cls,
- uint32_t type,
+ enum GNUNET_BLOCK_Type type,
PluginIterator iter,
void *iter_cls)
{
*/
static void
sqlite_plugin_iter_zero_anonymity (void *cls,
- uint32_t type,
+ enum GNUNET_BLOCK_Type type,
PluginIterator iter,
void *iter_cls)
{
*/
static void
sqlite_plugin_iter_ascending_expiration (void *cls,
- uint32_t type,
+ enum GNUNET_BLOCK_Type type,
PluginIterator iter,
void *iter_cls)
{
*/
static void
sqlite_plugin_iter_migration_order (void *cls,
- uint32_t type,
+ enum GNUNET_BLOCK_Type type,
PluginIterator iter,
void *iter_cls)
{
*/
static void
sqlite_plugin_iter_all_now (void *cls,
- uint32_t type,
+ enum GNUNET_BLOCK_Type type,
PluginIterator iter,
void *iter_cls)
{
sqlite_plugin_get (void *cls,
const GNUNET_HashCode * key,
const GNUNET_HashCode * vhash,
- uint32_t type,
+ enum GNUNET_BLOCK_Type type,
PluginIterator iter, void *iter_cls)
{
struct Plugin *plugin = cls;
*/
static int
template_plugin_put (void *cls,
- const GNUNET_HashCode * key,
- uint32_t size,
- const void *data,
- uint32_t type,
- uint32_t priority,
- uint32_t anonymity,
+ const GNUNET_HashCode * key,
+ uint32_t size,
+ const void *data,
+ enum GNUNET_BLOCK_Type type,
+ uint32_t priority,
+ uint32_t anonymity,
struct GNUNET_TIME_Absolute expiration,
char **msg)
{
template_plugin_get (void *cls,
const GNUNET_HashCode * key,
const GNUNET_HashCode * vhash,
- uint32_t type,
+ enum GNUNET_BLOCK_Type type,
PluginIterator iter, void *iter_cls)
{
GNUNET_break (0);
*/
static void
template_plugin_iter_low_priority (void *cls,
- uint32_t type,
+ enum GNUNET_BLOCK_Type type,
PluginIterator iter,
void *iter_cls)
{
*/
static void
template_plugin_iter_zero_anonymity (void *cls,
- uint32_t type,
- PluginIterator iter,
- void *iter_cls)
+ enum GNUNET_BLOCK_Type type,
+ PluginIterator iter,
+ void *iter_cls)
{
GNUNET_break (0);
}
*/
static void
template_plugin_iter_ascending_expiration (void *cls,
- uint32_t type,
- PluginIterator iter,
- void *iter_cls)
+ enum GNUNET_BLOCK_Type type,
+ PluginIterator iter,
+ void *iter_cls)
{
GNUNET_break (0);
}
*/
static void
template_plugin_iter_migration_order (void *cls,
- uint32_t type,
- PluginIterator iter,
- void *iter_cls)
+ enum GNUNET_BLOCK_Type type,
+ PluginIterator iter,
+ void *iter_cls)
{
GNUNET_break (0);
}
*/
static void
template_plugin_iter_all_now (void *cls,
- uint32_t type,
- PluginIterator iter,
- void *iter_cls)
+ enum GNUNET_BLOCK_Type type,
+ PluginIterator iter,
+ void *iter_cls)
{
GNUNET_break (0);
}
const GNUNET_HashCode * key,
uint32_t size,
const void *data,
- uint32_t type,
+ enum GNUNET_BLOCK_Type type,
uint32_t priority,
uint32_t anonymity,
struct GNUNET_TIME_Absolute
static void
delete_value (void *cls,
- const GNUNET_HashCode * key,
- uint32_t size,
- const void *data,
- uint32_t type,
- uint32_t priority,
- uint32_t anonymity,
- struct GNUNET_TIME_Absolute
- expiration, uint64_t uid)
+ const GNUNET_HashCode * key,
+ uint32_t size,
+ const void *data,
+ enum GNUNET_BLOCK_Type type,
+ uint32_t priority,
+ uint32_t anonymity,
+ struct GNUNET_TIME_Absolute
+ expiration, uint64_t uid)
{
struct CpsRunContext *crc = cls;
if (key == NULL)
static void
check_nothing (void *cls,
- const GNUNET_HashCode * key,
- uint32_t size,
- const void *data,
- uint32_t type,
- uint32_t priority,
- uint32_t anonymity,
- struct GNUNET_TIME_Absolute
- expiration, uint64_t uid)
+ const GNUNET_HashCode * key,
+ uint32_t size,
+ const void *data,
+ enum GNUNET_BLOCK_Type type,
+ uint32_t priority,
+ uint32_t anonymity,
+ struct GNUNET_TIME_Absolute
+ expiration, uint64_t uid)
{
struct CpsRunContext *crc = cls;
GNUNET_assert (key == NULL);
const GNUNET_HashCode * key,
uint32_t size,
const void *data,
- uint32_t type,
+ enum GNUNET_BLOCK_Type type,
uint32_t priority,
uint32_t anonymity,
struct GNUNET_TIME_Absolute
const GNUNET_HashCode * key,
uint32_t size,
const void *data,
- uint32_t type,
+ enum GNUNET_BLOCK_Type type,
uint32_t priority,
uint32_t anonymity,
struct GNUNET_TIME_Absolute
const GNUNET_HashCode * key,
uint32_t size,
const void *data,
- uint32_t type,
+ enum GNUNET_BLOCK_Type type,
uint32_t priority,
uint32_t anonymity,
struct GNUNET_TIME_Absolute
static void
check_nothing (void *cls,
- const GNUNET_HashCode * key,
- uint32_t size,
- const void *data,
- uint32_t type,
- uint32_t priority,
- uint32_t anonymity,
- struct GNUNET_TIME_Absolute
- expiration, uint64_t uid)
+ const GNUNET_HashCode * key,
+ uint32_t size,
+ const void *data,
+ enum GNUNET_BLOCK_Type type,
+ uint32_t priority,
+ uint32_t anonymity,
+ struct GNUNET_TIME_Absolute
+ expiration, uint64_t uid)
{
struct CpsRunContext *crc = cls;
gnunet-service-fs_indexing.c gnunet-service-fs_indexing.h
gnunet_service_fs_LDADD = \
$(top_builddir)/src/fs/libgnunetfs.la \
+ $(top_builddir)/src/block/libgnunetblock.la \
$(top_builddir)/src/datastore/libgnunetdatastore.la \
$(top_builddir)/src/statistics/libgnunetstatistics.la \
$(top_builddir)/src/core/libgnunetcore.la \
#include "gnunet_constants.h"
#include "gnunet_datastore_service.h"
#include "gnunet_fs_service.h"
+#include "gnunet_block_lib.h"
/**
* Size of the individual blocks used for file-sharing.
};
-/**
- * @brief index block (indexing a DBlock that
- * can be obtained directly from reading
- * the plaintext file)
- */
-struct OnDemandBlock
-{
- /**
- * Hash code of the entire content of the
- * file that was indexed (used to uniquely
- * identify the plaintext file).
- */
- GNUNET_HashCode file_id;
-
- /**
- * At which offset should we be able to find
- * this on-demand encoded block? (in NBO)
- */
- uint64_t offset GNUNET_PACKED;
-
-};
-
-
-/**
- * @brief keyword block (advertising data under a keyword)
- */
-struct KBlock
-{
-
- /**
- * GNUNET_RSA_Signature using RSA-key generated from search keyword.
- */
- struct GNUNET_CRYPTO_RsaSignature signature;
-
- /**
- * What is being signed and why?
- */
- struct GNUNET_CRYPTO_RsaSignaturePurpose purpose;
-
- /**
- * Key generated (!) from the H(keyword) as the seed!
- */
- struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded keyspace;
-
- /* 0-terminated URI here */
-
- /* variable-size Meta-Data follows here */
-
-};
-
-/**
- * @brief namespace content block (advertising data under an identifier in a namespace)
- */
-struct SBlock
-{
-
- /**
- * GNUNET_RSA_Signature using RSA-key of the namespace
- */
- struct GNUNET_CRYPTO_RsaSignature signature;
-
- /**
- * What is being signed and why?
- */
- struct GNUNET_CRYPTO_RsaSignaturePurpose purpose;
-
- /**
- * Hash of the hash of the human-readable identifier used for
- * this entry (the hash of the human-readable identifier is
- * used as the key for decryption; the xor of this identifier
- * and the hash of the "keyspace" is the datastore-query hash).
- */
- GNUNET_HashCode identifier;
-
- /**
- * Public key of the namespace.
- */
- struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded subspace;
-
- /* 0-terminated update-identifier here */
-
- /* 0-terminated URI here (except for NBlocks) */
-
- /* variable-size Meta-Data follows here */
-
-};
-
-
-/**
- * @brief namespace advertisement block (advertising root of a namespace)
- */
-struct NBlock
-{
-
- /**
- * GNUNET_RSA_Signature using RSA-key generated from search keyword.
- */
- struct GNUNET_CRYPTO_RsaSignature ksk_signature;
-
- /**
- * What is being signed and why?
- */
- struct GNUNET_CRYPTO_RsaSignaturePurpose ksk_purpose;
-
- /**
- * Key generated (!) from the H(keyword) as the seed!
- */
- struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded keyspace;
-
- /**
- * GNUNET_RSA_Signature using RSA-key of the namespace
- */
- struct GNUNET_CRYPTO_RsaSignature ns_signature;
-
- /**
- * What is being signed and why?
- */
- struct GNUNET_CRYPTO_RsaSignaturePurpose ns_purpose;
-
- /**
- * Public key of the namespace.
- */
- struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded subspace;
-
- /* from here on, data is encrypted with H(keyword) */
-
- /* 0-terminated root identifier here */
-
- /* variable-size Meta-Data follows here */
-
-};
-
-
/**
* Message sent from a GNUnet (fs) publishing activity to the
* gnunet-fs-service to initiate indexing of a file. The service is
/**
* Type of data.
*/
- uint32_t type;
+ enum GNUNET_BLOCK_Type type;
/**
* Flag to indicate if this block should be stored on disk.
prc.data = enc;
prc.size = len;
prc.type = (dc->treedepth == depth)
- ? GNUNET_DATASTORE_BLOCKTYPE_DBLOCK
- : GNUNET_DATASTORE_BLOCKTYPE_IBLOCK;
+ ? GNUNET_BLOCK_TYPE_DBLOCK
+ : GNUNET_BLOCK_TYPE_IBLOCK;
prc.query = chk->query;
prc.do_store = GNUNET_NO; /* useless */
process_result_with_request (&prc,
*/
static void
process_result (struct GNUNET_FS_DownloadContext *dc,
- uint32_t type,
+ enum GNUNET_BLOCK_Type type,
const void *data,
size_t size)
{
sm->header.size = htons (sizeof (struct SearchMessage));
sm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_START_SEARCH);
if (dc->pending->depth == dc->treedepth)
- sm->type = htonl (GNUNET_DATASTORE_BLOCKTYPE_DBLOCK);
+ sm->type = htonl (GNUNET_BLOCK_TYPE_DBLOCK);
else
- sm->type = htonl (GNUNET_DATASTORE_BLOCKTYPE_IBLOCK);
+ sm->type = htonl (GNUNET_BLOCK_TYPE_IBLOCK);
sm->anonymity_level = htonl (dc->anonymity);
sm->target = dc->target.hashPubKey;
sm->query = dc->pending->chk.query;
&query,
ac->pt_size + sizeof (struct NBlock),
ac->nb,
- GNUNET_DATASTORE_BLOCKTYPE_NBLOCK,
+ GNUNET_BLOCK_TYPE_NBLOCK,
ac->priority,
ac->anonymity,
ac->expiration,
block_proc (void *cls,
const GNUNET_HashCode *query,
uint64_t offset,
- uint32_t type,
+ enum GNUNET_BLOCK_Type type,
const void *block,
uint16_t block_size)
{
dpc_cls->p = p;
if ( (! p->is_directory) &&
(GNUNET_YES == p->data.file.do_index) &&
- (type == GNUNET_DATASTORE_BLOCKTYPE_DBLOCK) )
+ (type == GNUNET_BLOCK_TYPE_DBLOCK) )
{
#if DEBUG_PUBLISH
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
query,
sizeof(struct OnDemandBlock),
&odb,
- GNUNET_DATASTORE_BLOCKTYPE_ONDEMAND,
+ GNUNET_BLOCK_TYPE_ONDEMAND,
p->priority,
p->anonymity,
p->expirationTime,
sizeof (struct KBlock) +
pkc->slen,
pkc->cpy,
- GNUNET_DATASTORE_BLOCKTYPE_KBLOCK,
+ GNUNET_BLOCK_TYPE_KBLOCK,
pkc->priority,
pkc->anonymity,
pkc->expirationTime,
&sb_enc->identifier,
size,
sb_enc,
- GNUNET_DATASTORE_BLOCKTYPE_SBLOCK,
+ GNUNET_BLOCK_TYPE_SBLOCK,
priority,
anonymity,
expirationTime,
*/
static void
process_result (struct GNUNET_FS_SearchContext *sc,
- uint32_t type,
+ enum GNUNET_BLOCK_Type type,
struct GNUNET_TIME_Absolute expiration,
const void *data,
size_t size)
}
switch (type)
{
- case GNUNET_DATASTORE_BLOCKTYPE_KBLOCK:
+ case GNUNET_BLOCK_TYPE_KBLOCK:
if (! GNUNET_FS_uri_test_ksk (sc->uri))
{
GNUNET_break (0);
}
process_kblock (sc, data, size);
break;
- case GNUNET_DATASTORE_BLOCKTYPE_SBLOCK:
+ case GNUNET_BLOCK_TYPE_SBLOCK:
if (! GNUNET_FS_uri_test_sks (sc->uri))
{
GNUNET_break (0);
}
process_sblock (sc, data, size);
break;
- case GNUNET_DATASTORE_BLOCKTYPE_NBLOCK:
+ case GNUNET_BLOCK_TYPE_NBLOCK:
if (! GNUNET_FS_uri_test_ksk (sc->uri))
{
GNUNET_break (0);
}
process_nblock (sc, data, size);
break;
- case GNUNET_DATASTORE_BLOCKTYPE_ANY:
- case GNUNET_DATASTORE_BLOCKTYPE_DBLOCK:
- case GNUNET_DATASTORE_BLOCKTYPE_ONDEMAND:
- case GNUNET_DATASTORE_BLOCKTYPE_IBLOCK:
+ case GNUNET_BLOCK_TYPE_ANY:
+ case GNUNET_BLOCK_TYPE_DBLOCK:
+ case GNUNET_BLOCK_TYPE_ONDEMAND:
+ case GNUNET_BLOCK_TYPE_IBLOCK:
GNUNET_break (0);
break;
default:
{
sm[i].header.size = htons (sizeof (struct SearchMessage));
sm[i].header.type = htons (GNUNET_MESSAGE_TYPE_FS_START_SEARCH);
- sm[i].type = htonl (GNUNET_DATASTORE_BLOCKTYPE_ANY);
+ sm[i].type = htonl (GNUNET_BLOCK_TYPE_ANY);
sm[i].anonymity_level = htonl (sc->anonymity);
sm[i].query = sc->requests[i].query;
}
memset (sm, 0, msize);
sm->header.size = htons (sizeof (struct SearchMessage));
sm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_START_SEARCH);
- sm->type = htonl (GNUNET_DATASTORE_BLOCKTYPE_SBLOCK);
+ sm->type = htonl (GNUNET_BLOCK_TYPE_SBLOCK);
sm->anonymity_level = htonl (sc->anonymity);
sm->target = sc->uri->data.sks.namespace;
identifier = sc->uri->data.sks.identifier;
&mychk->query,
te->publish_offset,
(te->current_depth == te->chk_tree_depth)
- ? GNUNET_DATASTORE_BLOCKTYPE_DBLOCK
- : GNUNET_DATASTORE_BLOCKTYPE_IBLOCK,
+ ? GNUNET_BLOCK_TYPE_DBLOCK
+ : GNUNET_BLOCK_TYPE_IBLOCK,
enc,
pt_size);
if (NULL != te->progress)
typedef void (*GNUNET_FS_TreeBlockProcessor)(void *cls,
const GNUNET_HashCode *query,
uint64_t offset,
- uint32_t type,
+ enum GNUNET_BLOCK_Type type,
const void *block,
uint16_t block_size);
unindex_process (void *cls,
const GNUNET_HashCode *query,
uint64_t offset,
- uint32_t type,
+ enum GNUNET_BLOCK_Type type,
const void *block,
uint16_t block_size)
{
const void *data;
struct OnDemandBlock odb;
- if (type != GNUNET_DATASTORE_BLOCKTYPE_DBLOCK)
+ if (type != GNUNET_BLOCK_TYPE_DBLOCK)
{
size = block_size;
data = block;
/**
* Type of the content that this request is for.
*/
- uint32_t type;
+ enum GNUNET_BLOCK_Type type;
/**
* Remove this request after transmission of the current response.
switch (pr->type)
{
- case GNUNET_DATASTORE_BLOCKTYPE_DBLOCK:
- case GNUNET_DATASTORE_BLOCKTYPE_IBLOCK:
+ case GNUNET_BLOCK_TYPE_DBLOCK:
+ case GNUNET_BLOCK_TYPE_IBLOCK:
/* only one reply expected, done with the request! */
destroy_pending_request (pr);
break;
- case GNUNET_DATASTORE_BLOCKTYPE_ANY:
- case GNUNET_DATASTORE_BLOCKTYPE_KBLOCK:
- case GNUNET_DATASTORE_BLOCKTYPE_SBLOCK:
+ case GNUNET_BLOCK_TYPE_ANY:
+ case GNUNET_BLOCK_TYPE_KBLOCK:
+ case GNUNET_BLOCK_TYPE_SBLOCK:
break;
default:
GNUNET_break (0);
}
-/**
- * Check if the given KBlock is well-formed.
- *
- * @param kb the kblock data (or at least "dsize" bytes claiming to be one)
- * @param dsize size of "kb" in bytes; check for < sizeof(struct KBlock)!
- * @param query where to store the query that this block answers
- * @return GNUNET_OK if this is actually a well-formed KBlock
- */
-static int
-check_kblock (const struct KBlock *kb,
- size_t dsize,
- GNUNET_HashCode *query)
-{
- if (dsize < sizeof (struct KBlock))
- {
- GNUNET_break_op (0);
- return GNUNET_SYSERR;
- }
- if (dsize - sizeof (struct KBlock) !=
- ntohl (kb->purpose.size)
- - sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose)
- - sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded) )
- {
- GNUNET_break_op (0);
- return GNUNET_SYSERR;
- }
- if (GNUNET_OK !=
- GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_FS_KBLOCK,
- &kb->purpose,
- &kb->signature,
- &kb->keyspace))
- {
- GNUNET_break_op (0);
- return GNUNET_SYSERR;
- }
- if (query != NULL)
- GNUNET_CRYPTO_hash (&kb->keyspace,
- sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
- query);
- return GNUNET_OK;
-}
-
-
-/**
- * Check if the given NBlock is well-formed.
- *
- * @param nb the nblock data (or at least "dsize" bytes claiming to be one)
- * @param dsize size of "nb" in bytes; check for < sizeof(struct NBlock)!
- * @param query where to store the query that this block answers
- * @return GNUNET_OK if this is actually a well-formed NBlock
- */
-static int
-check_nblock (const struct NBlock *nb,
- size_t dsize,
- GNUNET_HashCode *query)
-{
- if (dsize < sizeof (struct NBlock))
- {
- GNUNET_break_op (0);
- return GNUNET_SYSERR;
- }
- if (dsize - sizeof (struct NBlock) !=
- ntohl (nb->ns_purpose.size)
- - sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose)
- - sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded) )
- {
- GNUNET_break_op (0);
- return GNUNET_SYSERR;
- }
- if (dsize !=
- ntohl (nb->ksk_purpose.size) + sizeof (struct GNUNET_CRYPTO_RsaSignature))
- {
- GNUNET_break_op (0);
- return GNUNET_SYSERR;
- }
- if (GNUNET_OK !=
- GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_FS_NBLOCK_KSIG,
- &nb->ksk_purpose,
- &nb->ksk_signature,
- &nb->keyspace))
- {
- GNUNET_break_op (0);
- return GNUNET_SYSERR;
- }
- if (GNUNET_OK !=
- GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_FS_NBLOCK,
- &nb->ns_purpose,
- &nb->ns_signature,
- &nb->subspace))
- {
- GNUNET_break_op (0);
- return GNUNET_SYSERR;
- }
- if (query != NULL)
- GNUNET_CRYPTO_hash (&nb->keyspace,
- sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
- query);
- return GNUNET_OK;
-}
-
-
-/**
- * Check if the given SBlock is well-formed.
- *
- * @param sb the sblock data (or at least "dsize" bytes claiming to be one)
- * @param dsize size of "kb" in bytes; check for < sizeof(struct SBlock)!
- * @param query where to store the query that this block answers
- * @param namespace where to store the namespace that this block belongs to
- * @return GNUNET_OK if this is actually a well-formed SBlock
- */
-static int
-check_sblock (const struct SBlock *sb,
- size_t dsize,
- GNUNET_HashCode *query,
- GNUNET_HashCode *namespace)
-{
- if (dsize < sizeof (struct SBlock))
- {
- GNUNET_break_op (0);
- return GNUNET_SYSERR;
- }
- if (dsize !=
- ntohl (sb->purpose.size) + sizeof (struct GNUNET_CRYPTO_RsaSignature))
- {
- GNUNET_break_op (0);
- return GNUNET_SYSERR;
- }
- if (GNUNET_OK !=
- GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_FS_SBLOCK,
- &sb->purpose,
- &sb->signature,
- &sb->subspace))
- {
- GNUNET_break_op (0);
- return GNUNET_SYSERR;
- }
- if (query != NULL)
- *query = sb->identifier;
- if (namespace != NULL)
- GNUNET_CRYPTO_hash (&sb->subspace,
- sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
- namespace);
- return GNUNET_OK;
-}
-
-
/**
* Transmit the given message by copying it to the target buffer
* "buf". "buf" will be NULL and "size" zero if the socket was closed
/**
* Type of the block.
*/
- uint32_t type;
+ enum GNUNET_BLOCK_Type type;
/**
* How much was this reply worth to us?
&chash);
switch (prq->type)
{
- case GNUNET_DATASTORE_BLOCKTYPE_DBLOCK:
- case GNUNET_DATASTORE_BLOCKTYPE_IBLOCK:
+ case GNUNET_BLOCK_TYPE_DBLOCK:
+ case GNUNET_BLOCK_TYPE_IBLOCK:
/* only possible reply, stop requesting! */
while (NULL != pr->pending_head)
destroy_pending_message_list_entry (pr->pending_head);
key,
pr));
break;
- case GNUNET_DATASTORE_BLOCKTYPE_SBLOCK:
+ case GNUNET_BLOCK_TYPE_SBLOCK:
if (pr->namespace == NULL)
{
GNUNET_break (0);
return GNUNET_YES; /* wrong namespace */
}
/* then: fall-through! */
- case GNUNET_DATASTORE_BLOCKTYPE_KBLOCK:
- case GNUNET_DATASTORE_BLOCKTYPE_NBLOCK:
+ case GNUNET_BLOCK_TYPE_KBLOCK:
+ case GNUNET_BLOCK_TYPE_NBLOCK:
if (pr->bf != NULL)
{
mingle_hash (&chash, pr->mingle, &mhash);
const struct PutMessage *put;
uint16_t msize;
size_t dsize;
- uint32_t type;
+ enum GNUNET_BLOCK_Type type;
struct GNUNET_TIME_Absolute expiration;
GNUNET_HashCode query;
struct ProcessReplyClosure prq;
+ const struct SBlock *sb;
msize = ntohs (message->size);
if (msize < sizeof (struct PutMessage))
type = ntohl (put->type);
expiration = GNUNET_TIME_absolute_ntoh (put->expiration);
- /* first, validate! */
- switch (type)
+ if (GNUNET_OK !=
+ GNUNET_BLOCK_check_block (type,
+ &put[1],
+ dsize,
+ &query))
{
- case GNUNET_DATASTORE_BLOCKTYPE_DBLOCK:
- case GNUNET_DATASTORE_BLOCKTYPE_IBLOCK:
- GNUNET_CRYPTO_hash (&put[1], dsize, &query);
- break;
- case GNUNET_DATASTORE_BLOCKTYPE_KBLOCK:
- if (GNUNET_OK !=
- check_kblock ((const struct KBlock*) &put[1],
- dsize,
- &query))
- return GNUNET_SYSERR;
- break;
- case GNUNET_DATASTORE_BLOCKTYPE_SBLOCK:
- if (GNUNET_OK !=
- check_sblock ((const struct SBlock*) &put[1],
- dsize,
- &query,
- &prq.namespace))
- return GNUNET_SYSERR;
- break;
- case GNUNET_DATASTORE_BLOCKTYPE_NBLOCK:
- if (GNUNET_OK !=
- check_nblock ((const struct NBlock*) &put[1],
- dsize,
- &query))
- return GNUNET_SYSERR;
- return GNUNET_OK;
- default:
- /* unknown block type */
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
+ if (type == GNUNET_BLOCK_TYPE_ONDEMAND)
+ return GNUNET_SYSERR;
+ if (GNUNET_BLOCK_TYPE_SBLOCK == type)
+ {
+ sb = (const struct SBlock*) &put[1];
+ GNUNET_CRYPTO_hash (&sb->subspace,
+ sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
+ &prq.namespace);
+ }
#if DEBUG_FS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
const GNUNET_HashCode * key,
uint32_t size,
const void *data,
- uint32_t type,
+ enum GNUNET_BLOCK_Type type,
uint32_t priority,
uint32_t anonymity,
struct GNUNET_TIME_Absolute
struct PendingRequest *pr = cls;
struct ProcessReplyClosure prq;
struct CheckDuplicateRequestClosure cdrc;
+ const struct SBlock *sb;
GNUNET_HashCode dhash;
GNUNET_HashCode mhash;
GNUNET_HashCode query;
GNUNET_h2s (key),
type);
#endif
- if (type == GNUNET_DATASTORE_BLOCKTYPE_ONDEMAND)
+ if (type == GNUNET_BLOCK_TYPE_ONDEMAND)
{
#if DEBUG_FS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
prq.data = data;
prq.expiration = expiration;
prq.size = size;
- if ( (type == GNUNET_DATASTORE_BLOCKTYPE_SBLOCK) &&
- (GNUNET_OK != check_sblock ((const struct SBlock*) data,
- size,
- &query,
- &prq.namespace)) )
+ if (GNUNET_BLOCK_TYPE_SBLOCK == type)
+ {
+ sb = (const struct SBlock*) data;
+ GNUNET_CRYPTO_hash (&sb->subspace,
+ sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
+ &prq.namespace);
+ }
+ if (GNUNET_OK != GNUNET_BLOCK_check_block (type,
+ data,
+ size,
+ &query))
{
GNUNET_break (0);
/* FIXME: consider removing the block? */
prq.priority = priority;
process_reply (&prq, key, pr);
- if ( (type == GNUNET_DATASTORE_BLOCKTYPE_DBLOCK) ||
- (type == GNUNET_DATASTORE_BLOCKTYPE_IBLOCK) )
+ if ( (type == GNUNET_BLOCK_TYPE_DBLOCK) ||
+ (type == GNUNET_BLOCK_TYPE_IBLOCK) )
{
GNUNET_FS_drq_get_next (GNUNET_NO);
return;
uint32_t bm;
size_t bfsize;
uint32_t ttl_decrement;
- uint32_t type;
+ enum GNUNET_BLOCK_Type type;
double preference;
int have_ns;
type = ntohl (gm->type);
switch (type)
{
- case GNUNET_DATASTORE_BLOCKTYPE_ANY:
- case GNUNET_DATASTORE_BLOCKTYPE_DBLOCK:
- case GNUNET_DATASTORE_BLOCKTYPE_IBLOCK:
- case GNUNET_DATASTORE_BLOCKTYPE_KBLOCK:
- case GNUNET_DATASTORE_BLOCKTYPE_SBLOCK:
+ case GNUNET_BLOCK_TYPE_ANY:
+ case GNUNET_BLOCK_TYPE_DBLOCK:
+ case GNUNET_BLOCK_TYPE_IBLOCK:
+ case GNUNET_BLOCK_TYPE_KBLOCK:
+ case GNUNET_BLOCK_TYPE_SBLOCK:
break;
default:
GNUNET_break_op (0);
bfsize = msize - sizeof (struct GetMessage) + bits * sizeof (GNUNET_HashCode);
bm = ntohl (gm->hash_bitmap);
if ( (0 != (bm & GET_MESSAGE_BIT_SKS_NAMESPACE)) &&
- (type != GNUNET_DATASTORE_BLOCKTYPE_SBLOCK) )
+ (type != GNUNET_BLOCK_TYPE_SBLOCK) )
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
cps->inc_preference += preference;
/* process locally */
- if (type == GNUNET_DATASTORE_BLOCKTYPE_DBLOCK)
- type = GNUNET_DATASTORE_BLOCKTYPE_ANY; /* to get on-demand as well */
+ if (type == GNUNET_BLOCK_TYPE_DBLOCK)
+ type = GNUNET_BLOCK_TYPE_ANY; /* to get on-demand as well */
timeout = GNUNET_TIME_relative_multiply (BASIC_DATASTORE_REQUEST_DELAY,
(pr->priority + 1));
pr->drq = GNUNET_FS_drq_get (&gm->query,
/* Are multiple results possible? If so, start processing remotely now! */
switch (pr->type)
{
- case GNUNET_DATASTORE_BLOCKTYPE_DBLOCK:
- case GNUNET_DATASTORE_BLOCKTYPE_IBLOCK:
+ case GNUNET_BLOCK_TYPE_DBLOCK:
+ case GNUNET_BLOCK_TYPE_IBLOCK:
/* only one result, wait for datastore */
break;
default:
struct PendingRequest *pr;
uint16_t msize;
unsigned int sc;
- uint32_t type;
+ enum GNUNET_BLOCK_Type type;
msize = ntohs (message->size);
if ( (msize < sizeof (struct SearchMessage)) ||
#endif
switch (type)
{
- case GNUNET_DATASTORE_BLOCKTYPE_ANY:
- case GNUNET_DATASTORE_BLOCKTYPE_DBLOCK:
- case GNUNET_DATASTORE_BLOCKTYPE_IBLOCK:
- case GNUNET_DATASTORE_BLOCKTYPE_KBLOCK:
- case GNUNET_DATASTORE_BLOCKTYPE_SBLOCK:
- case GNUNET_DATASTORE_BLOCKTYPE_NBLOCK:
+ case GNUNET_BLOCK_TYPE_ANY:
+ case GNUNET_BLOCK_TYPE_DBLOCK:
+ case GNUNET_BLOCK_TYPE_IBLOCK:
+ case GNUNET_BLOCK_TYPE_KBLOCK:
+ case GNUNET_BLOCK_TYPE_SBLOCK:
+ case GNUNET_BLOCK_TYPE_NBLOCK:
break;
default:
GNUNET_break (0);
client_list = cl;
}
/* detect duplicate KBLOCK requests */
- if ( (type == GNUNET_DATASTORE_BLOCKTYPE_KBLOCK) ||
- (type == GNUNET_DATASTORE_BLOCKTYPE_NBLOCK) ||
- (type == GNUNET_DATASTORE_BLOCKTYPE_ANY) )
+ if ( (type == GNUNET_BLOCK_TYPE_KBLOCK) ||
+ (type == GNUNET_BLOCK_TYPE_NBLOCK) ||
+ (type == GNUNET_BLOCK_TYPE_ANY) )
{
crl = cl->rl_head;
while ( (crl != NULL) &&
1,
GNUNET_NO);
pr = GNUNET_malloc (sizeof (struct PendingRequest) +
- ((type == GNUNET_DATASTORE_BLOCKTYPE_SBLOCK) ? sizeof(GNUNET_HashCode) : 0));
+ ((type == GNUNET_BLOCK_TYPE_SBLOCK) ? sizeof(GNUNET_HashCode) : 0));
crl = GNUNET_malloc (sizeof (struct ClientRequestList));
memset (crl, 0, sizeof (struct ClientRequestList));
crl->client_list = cl;
pr->query = sm->query;
switch (type)
{
- case GNUNET_DATASTORE_BLOCKTYPE_DBLOCK:
- case GNUNET_DATASTORE_BLOCKTYPE_IBLOCK:
+ case GNUNET_BLOCK_TYPE_DBLOCK:
+ case GNUNET_BLOCK_TYPE_IBLOCK:
if (0 != memcmp (&sm->target,
&all_zeros,
sizeof (GNUNET_HashCode)))
pr->target_pid = GNUNET_PEER_intern ((const struct GNUNET_PeerIdentity*) &sm->target);
break;
- case GNUNET_DATASTORE_BLOCKTYPE_SBLOCK:
+ case GNUNET_BLOCK_TYPE_SBLOCK:
pr->namespace = (GNUNET_HashCode*) &pr[1];
memcpy (&pr[1], &sm->target, sizeof (GNUNET_HashCode));
break;
&sm->query,
pr,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
- if (type == GNUNET_DATASTORE_BLOCKTYPE_DBLOCK)
- type = GNUNET_DATASTORE_BLOCKTYPE_ANY; /* get on-demand blocks too! */
+ if (type == GNUNET_BLOCK_TYPE_DBLOCK)
+ type = GNUNET_BLOCK_TYPE_ANY; /* get on-demand blocks too! */
pr->drq = GNUNET_FS_drq_get (&sm->query,
type,
&process_local_reply,
/**
* Datastore entry type we are doing the 'get' for.
*/
- uint32_t type;
+ enum GNUNET_BLOCK_Type type;
/**
* Is this request at the head of the queue irrespective of its
const GNUNET_HashCode * key,
uint32_t size,
const void *data,
- uint32_t type,
+ enum GNUNET_BLOCK_Type type,
uint32_t priority,
uint32_t anonymity,
struct GNUNET_TIME_Absolute
*/
struct DatastoreRequestQueue *
GNUNET_FS_drq_get (const GNUNET_HashCode * key,
- uint32_t type,
+ enum GNUNET_BLOCK_Type type,
GNUNET_DATASTORE_Iterator iter,
void *iter_cls,
struct GNUNET_TIME_Relative timeout,
*/
struct DatastoreRequestQueue *
GNUNET_FS_drq_get (const GNUNET_HashCode * key,
- uint32_t type,
+ enum GNUNET_BLOCK_Type type,
GNUNET_DATASTORE_Iterator iter,
void *iter_cls,
struct GNUNET_TIME_Relative timeout,
GNUNET_FS_handle_on_demand_block (const GNUNET_HashCode * key,
uint32_t size,
const void *data,
- uint32_t type,
+ enum GNUNET_BLOCK_Type type,
uint32_t priority,
uint32_t anonymity,
struct GNUNET_TIME_Absolute
key,
nsize,
edata,
- GNUNET_DATASTORE_BLOCKTYPE_DBLOCK,
+ GNUNET_BLOCK_TYPE_DBLOCK,
priority,
anonymity,
expiration,
#ifndef GNUNET_SERVICE_FS_INDEXING_H
#define GNUNET_SERVICE_FS_INDEXING_H
+#include "gnunet_block_lib.h"
#include "gnunet_core_service.h"
#include "gnunet_datastore_service.h"
#include "gnunet_peer_lib.h"
GNUNET_FS_handle_on_demand_block (const GNUNET_HashCode * key,
uint32_t size,
const void *data,
- uint32_t type,
+ enum GNUNET_BLOCK_Type type,
uint32_t priority,
uint32_t anonymity,
struct GNUNET_TIME_Absolute
#define GNUNET_DATACACHE_LIB_H
#include "gnunet_util_lib.h"
+#include "gnunet_block_lib.h"
#ifdef __cplusplus
extern "C"
const GNUNET_HashCode * key,
uint32_t size,
const char *data,
- uint32_t type);
+ enum GNUNET_BLOCK_Type type);
/**
const GNUNET_HashCode * key,
uint32_t size,
const char *data,
- unsigned int type,
+ enum GNUNET_BLOCK_Type type,
struct GNUNET_TIME_Absolute discard_time);
unsigned int
GNUNET_DATACACHE_get (struct GNUNET_DATACACHE_Handle *h,
const GNUNET_HashCode * key,
- unsigned int type,
+ enum GNUNET_BLOCK_Type type,
GNUNET_DATACACHE_Iterator iter,
void *iter_cls);
#define GNUNET_DATASTORE_SERVICE_H
#include "gnunet_util_lib.h"
+#include "gnunet_block_lib.h"
#ifdef __cplusplus
extern "C"
#endif
#endif
-/**
- * Any type of block, used as a wildcard when searching. Should
- * never be attached to a specific block.
- */
-#define GNUNET_DATASTORE_BLOCKTYPE_ANY 0
-
-/**
- * Data block (leaf) in the CHK tree.
- */
-#define GNUNET_DATASTORE_BLOCKTYPE_DBLOCK 1
-
-/**
- * Inner block in the CHK tree.
- */
-#define GNUNET_DATASTORE_BLOCKTYPE_IBLOCK 2
-
-/**
- * Type of a block representing a keyword search result.
- */
-#define GNUNET_DATASTORE_BLOCKTYPE_KBLOCK 3
-
-/**
- * Type of a block that is used to advertise content in a namespace.
- */
-#define GNUNET_DATASTORE_BLOCKTYPE_SBLOCK 4
-
-/**
- * Type of a block representing a block to be encoded on demand from disk.
- * Should never appear on the network directly.
- */
-#define GNUNET_DATASTORE_BLOCKTYPE_ONDEMAND 5
-
-/**
- * Type of a block that is used to advertise a namespace.
- */
-#define GNUNET_DATASTORE_BLOCKTYPE_NBLOCK 6
-
/**
* Handle to the datastore service.
const GNUNET_HashCode * key,
uint32_t size,
const void *data,
- uint32_t type,
+ enum GNUNET_BLOCK_Type type,
uint32_t priority,
uint32_t anonymity,
struct GNUNET_TIME_Absolute expiration,
const GNUNET_HashCode * key,
uint32_t size,
const void *data,
- uint32_t type,
+ enum GNUNET_BLOCK_Type type,
uint32_t priority,
uint32_t anonymity,
struct GNUNET_TIME_Absolute
void
GNUNET_DATASTORE_get (struct GNUNET_DATASTORE_Handle *h,
const GNUNET_HashCode * key,
- uint32_t type,
+ enum GNUNET_BLOCK_Type type,
GNUNET_DATASTORE_Iterator iter,
void *iter_cls,
struct GNUNET_TIME_Relative timeout);
* @param handle handle to the DHT service
* @param timeout timeout for this request to be sent to the
* service (this is NOT a timeout for receiving responses)
- * @param type expected type of the response object (GNUNET_DATASTORE_BLOCKTYPE_*)
+ * @param type expected type of the response object (GNUNET_BLOCK_TYPE_*)
* @param key the key to look up
* @param iter function to call on each result
* @param iter_cls closure for iter
--- /dev/null
+INCLUDES = -I$(top_srcdir)/src/include
+
+if MINGW
+ WINFLAGS = -Wl,--no-undefined -Wl,--export-all-symbols
+endif
+
+if USE_COVERAGE
+ AM_CFLAGS = --coverage -O0
+ XLIBS = -lgcov
+endif
+
+bin_PROGRAMS = \
+ gnunet-daemon-migration
+
+gnunet_daemon_migration_SOURCES = \
+ gnunet-daemon-migration.c
+gnunet_daemon_migration_LDADD = \
+ $(top_builddir)/src/datastore/libgnunetdatastore.la \
+ $(top_builddir)/src/statistics/libgnunetstatistics.la \
+ $(top_builddir)/src/core/libgnunetcore.la \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ $(GN_LIBINTL)
+
+check_PROGRAMS = test_gnunet_daemon_migration
+#TESTS = $(check_PROGRAMS)
+
+test_gnunet_daemon_migration_SOURCES = \
+ test_gnunet_daemon_migration.c
+test_gnunet_daemon_migration_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
+ $(top_builddir)/src/util/libgnunetutil.la
+
+EXTRA_DIST = \
+ test_gnunet_daemon_migration_data.conf
--- /dev/null
+#! /bin/sh
+
+# gnunet-daemon-migration - temporary wrapper script for .libs/gnunet-daemon-migration
+# Generated by ltmain.sh (GNU libtool) 2.2.6b Debian-2.2.6b-2
+#
+# The gnunet-daemon-migration program cannot be directly executed until all the libtool
+# libraries that it depends on are installed.
+#
+# This wrapper script should never be moved out of the build directory.
+# If it is, it will not operate correctly.
+
+# Sed substitution that helps us do robust quoting. It backslashifies
+# metacharacters that are still active within double-quoted strings.
+Xsed='/bin/sed -e 1s/^X//'
+sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
+
+# Be Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+ # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+ setopt NO_GLOB_SUBST
+else
+ case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
+fi
+BIN_SH=xpg4; export BIN_SH # for Tru64
+DUALCASE=1; export DUALCASE # for MKS sh
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+relink_command="(cd /home/grothoff/svn/gnunet/src/migration; { test -z \"\${LIBRARY_PATH+set}\" || unset LIBRARY_PATH || { LIBRARY_PATH=; export LIBRARY_PATH; }; }; { test -z \"\${COMPILER_PATH+set}\" || unset COMPILER_PATH || { COMPILER_PATH=; export COMPILER_PATH; }; }; { test -z \"\${GCC_EXEC_PREFIX+set}\" || unset GCC_EXEC_PREFIX || { GCC_EXEC_PREFIX=; export GCC_EXEC_PREFIX; }; }; { test -z \"\${LD_RUN_PATH+set}\" || unset LD_RUN_PATH || { LD_RUN_PATH=; export LD_RUN_PATH; }; }; { test -z \"\${LD_LIBRARY_PATH+set}\" || unset LD_LIBRARY_PATH || { LD_LIBRARY_PATH=; export LD_LIBRARY_PATH; }; }; PATH=/home/grothoff/bin:/home/grothoff/private/software/prevent-linux-4.3.0/bin/:/home/grothoff/bin:/usr/local/bin:/usr/bin:/bin:/usr/games; export PATH; gcc -fno-strict-aliasing -Wall -g -O0 -o \$progdir/\$file gnunet-daemon-migration.o -L/home/grothoff//lib ../../src/datastore/.libs/libgnunetdatastore.so ../../src/statistics/.libs/libgnunetstatistics.so ../../src/core/.libs/libgnunetcore.so ../../src/util/.libs/libgnunetutil.so -lm -ldl -Wl,-rpath -Wl,/home/grothoff/svn/gnunet/src/datastore/.libs -Wl,-rpath -Wl,/home/grothoff/svn/gnunet/src/statistics/.libs -Wl,-rpath -Wl,/home/grothoff/svn/gnunet/src/core/.libs -Wl,-rpath -Wl,/home/grothoff/svn/gnunet/src/util/.libs -Wl,-rpath -Wl,/home/grothoff/lib)"
+
+# This environment variable determines our operation mode.
+if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then
+ # install mode needs the following variables:
+ generated_by_libtool_version='2.2.6b'
+ notinst_deplibs=' ../../src/datastore/libgnunetdatastore.la ../../src/statistics/libgnunetstatistics.la ../../src/core/libgnunetcore.la ../../src/util/libgnunetutil.la'
+else
+ # When we are sourced in execute mode, $file and $ECHO are already set.
+ if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then
+ ECHO="echo"
+ file="$0"
+ # Make sure echo works.
+ if test "X$1" = X--no-reexec; then
+ # Discard the --no-reexec flag, and continue.
+ shift
+ elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t'; then
+ # Yippee, $ECHO works!
+ :
+ else
+ # Restart under the correct shell, and then maybe $ECHO will work.
+ exec /bin/sh "$0" --no-reexec ${1+"$@"}
+ fi
+ fi
+
+ # Find the directory that this script lives in.
+ thisdir=`$ECHO "X$file" | $Xsed -e 's%/[^/]*$%%'`
+ test "x$thisdir" = "x$file" && thisdir=.
+
+ # Follow symbolic links until we get to the real thisdir.
+ file=`ls -ld "$file" | /bin/sed -n 's/.*-> //p'`
+ while test -n "$file"; do
+ destdir=`$ECHO "X$file" | $Xsed -e 's%/[^/]*$%%'`
+
+ # If there was a directory component, then change thisdir.
+ if test "x$destdir" != "x$file"; then
+ case "$destdir" in
+ [\\/]* | [A-Za-z]:[\\/]*) thisdir="$destdir" ;;
+ *) thisdir="$thisdir/$destdir" ;;
+ esac
+ fi
+
+ file=`$ECHO "X$file" | $Xsed -e 's%^.*/%%'`
+ file=`ls -ld "$thisdir/$file" | /bin/sed -n 's/.*-> //p'`
+ done
+
+
+ # Usually 'no', except on cygwin/mingw when embedded into
+ # the cwrapper.
+ WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=no
+ if test "$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR" = "yes"; then
+ # special case for '.'
+ if test "$thisdir" = "."; then
+ thisdir=`pwd`
+ fi
+ # remove .libs from thisdir
+ case "$thisdir" in
+ *[\\/].libs ) thisdir=`$ECHO "X$thisdir" | $Xsed -e 's%[\\/][^\\/]*$%%'` ;;
+ .libs ) thisdir=. ;;
+ esac
+ fi
+
+ # Try to get the absolute directory name.
+ absdir=`cd "$thisdir" && pwd`
+ test -n "$absdir" && thisdir="$absdir"
+
+ program=lt-'gnunet-daemon-migration'
+ progdir="$thisdir/.libs"
+
+ if test ! -f "$progdir/$program" ||
+ { file=`ls -1dt "$progdir/$program" "$progdir/../$program" 2>/dev/null | /bin/sed 1q`; \
+ test "X$file" != "X$progdir/$program"; }; then
+
+ file="$$-$program"
+
+ if test ! -d "$progdir"; then
+ mkdir "$progdir"
+ else
+ rm -f "$progdir/$file"
+ fi
+
+ # relink executable if necessary
+ if test -n "$relink_command"; then
+ if relink_command_output=`eval $relink_command 2>&1`; then :
+ else
+ echo "$relink_command_output" >&2
+ rm -f "$progdir/$file"
+ exit 1
+ fi
+ fi
+
+ mv -f "$progdir/$file" "$progdir/$program" 2>/dev/null ||
+ { rm -f "$progdir/$program";
+ mv -f "$progdir/$file" "$progdir/$program"; }
+ rm -f "$progdir/$file"
+ fi
+
+ if test -f "$progdir/$program"; then
+ if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then
+ # Run the actual program with our arguments.
+
+ exec "$progdir/$program" ${1+"$@"}
+
+ $ECHO "$0: cannot exec $program $*" 1>&2
+ exit 1
+ fi
+ else
+ # The program doesn't exist.
+ $ECHO "$0: error: \`$progdir/$program' does not exist" 1>&2
+ $ECHO "This script is just a wrapper for $program." 1>&2
+ echo "See the libtool documentation for more information." 1>&2
+ exit 1
+ fi
+fi
--- /dev/null
+/*
+ This file is part of GNUnet.
+ (C) 2010 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 2, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file migration/gnunet-daemon-migration.c
+ * @brief migrating (file-sharing) content through the network; this
+ * daemon is only responsible for pushing content out (not for
+ * processing inbound messages)
+ * @author Christian Grothoff
+ */
+#include <stdlib.h>
+#include "platform.h"
+#include "../fs/fs.h"
+#include "gnunet_constants.h"
+#include "gnunet_core_service.h"
+#include "gnunet_datastore_service.h"
+#include "gnunet_protocols.h"
+#include "gnunet_statistics_service.h"
+#include "gnunet_util_lib.h"
+
+
+#define DEBUG_MIGRATION GNUNET_YES
+
+/**
+ * Information we keep per peer.
+ */
+struct Peer
+{
+ /**
+ * Last time we migrated data to this peer.
+ */
+ struct GNUNET_TIME_Absolute last_migration;
+
+};
+
+
+/**
+ * Our scheduler.
+ */
+static struct GNUNET_SCHEDULER_Handle *sched;
+
+/**
+ * Our configuration.
+ */
+static const struct GNUNET_CONFIGURATION_Handle *cfg;
+
+/**
+ * Handle to the core API.
+ */
+static struct GNUNET_CORE_Handle *handle;
+
+/**
+ * Handle for reporting statistics.
+ */
+static struct GNUNET_STATISTICS_Handle *stats;
+
+/**
+ * Handle for the core service.
+*/
+static struct GNUNET_CORE_Handle *handle;
+
+/**
+ * Handle to the datastore.
+ */
+static struct GNUNET_DATASTORE_Handle *datastore;
+
+/**
+ * Anonymity level for the current block.
+ */
+static unsigned int current_anonymity;
+
+/**
+ * Type of the current block.
+ */
+static enum GNUNET_BLOCK_Type current_type;
+
+/**
+ * Data of the current block (already encrypted).
+ */
+static char current_block[GNUNET_SERVER_MAX_MESSAGE_SIZE];
+
+/**
+ * Size of the current block.
+ */
+static size_t current_block_size;
+
+/**
+ * Key of the current block.
+ */
+static GNUNET_HashCode current_key;
+
+/**
+ * Task scheduled to receive content from the datastore (with some delay).
+ */
+static GNUNET_SCHEDULER_TaskIdentifier get_task;
+
+
+/**
+ * Select a peer for transmitting the current block to.
+ */
+static void
+select_peer ()
+{
+ /* FIXME: select a peer for transmission... */
+}
+
+
+/**
+ * Method called whenever a peer connects.
+ *
+ * @param cls closure
+ * @param peer peer identity this notification is about
+ * @param latency reported latency of the connection with 'other'
+ * @param distance reported distance (DV) to 'other'
+ */
+static void
+connect_notify (void *cls,
+ const struct
+ GNUNET_PeerIdentity * peer,
+ struct GNUNET_TIME_Relative latency,
+ uint32_t distance)
+{
+ /* FIXME: track peer */
+}
+
+
+/**
+ * Method called whenever a peer disconnects.
+ *
+ * @param cls closure
+ * @param peer peer identity this notification is about
+ */
+static void
+disconnect_notify (void *cls,
+ const struct
+ GNUNET_PeerIdentity * peer)
+{
+ /* FIXME: untrack peer */
+}
+
+
+/**
+ * Ask datastore for more content.
+ * @param cls closure
+ * @param tc scheduler context
+ */
+static void
+get_content (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc);
+
+
+/**
+ * An iterator over a set of items stored in the datastore.
+ *
+ * @param cls closure
+ * @param key key for the content
+ * @param size number of bytes in data
+ * @param data content stored
+ * @param type type of the content
+ * @param priority priority of the content
+ * @param anonymity anonymity-level for the content
+ * @param expiration expiration time for the content
+ * @param uid unique identifier for the datum;
+ * maybe 0 if no unique identifier is available
+ */
+static void
+content_processor (void *cls,
+ const GNUNET_HashCode * key,
+ uint32_t size,
+ const void *data,
+ enum GNUNET_BLOCK_Type type,
+ uint32_t priority,
+ uint32_t anonymity,
+ struct GNUNET_TIME_Absolute
+ expiration, uint64_t uid)
+{
+ if (key != NULL)
+ {
+ memcpy (current_block, data, size);
+ current_block_size = size;
+ current_type = type;
+ current_anonymity = anonymity;
+ current_key = *key;
+ return;
+ }
+ if (current_block_size == 0)
+ {
+ get_task = GNUNET_SCHEDULER_add_delayed (sched,
+ GNUNET_TIME_UNIT_MINUTES,
+ &get_content,
+ NULL);
+ return;
+ }
+ if (current_type == GNUNET_BLOCK_TYPE_ONDEMAND)
+ {
+ /* FIXME: do on-demand encoding... */
+ return;
+ }
+ select_peer ();
+}
+
+
+/**
+ * Ask datastore for more content.
+ * @param cls closure
+ * @param tc scheduler context
+ */
+static void
+get_content (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ get_task = GNUNET_SCHEDULER_NO_TASK;
+ GNUNET_DATASTORE_get_random (datastore,
+ &content_processor,
+ NULL,
+ GNUNET_CONSTANTS_SERVICE_TIMEOUT);
+}
+
+
+/**
+ * Function called after GNUNET_CORE_connect has succeeded
+ * (or failed for good).
+ *
+ * @param cls closure
+ * @param server handle to the server, NULL if we failed
+ * @param my_id ID of this peer, NULL if we failed
+ * @param publicKey public key of this peer, NULL if we failed
+ */
+static void
+core_init (void *cls,
+ struct GNUNET_CORE_Handle * server,
+ const struct GNUNET_PeerIdentity *
+ my_id,
+ const struct
+ GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *
+ publicKey)
+{
+ handle = server;
+ if (datastore != NULL)
+ get_task = GNUNET_SCHEDULER_add_now (sched,
+ &get_content,
+ NULL);
+}
+
+
+/**
+ * Last task run during shutdown. Disconnects us from
+ * the core.
+ *
+ * @param cls unused, NULL
+ * @param tc scheduler context
+ */
+static void
+cleaning_task (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ if (get_task != GNUNET_SCHEDULER_NO_TASK)
+ {
+ GNUNET_SCHEDULER_cancel (sched,
+ get_task);
+ get_task = GNUNET_SCHEDULER_NO_TASK;
+ }
+ if (handle != NULL)
+ {
+ GNUNET_CORE_disconnect (handle);
+ handle = NULL;
+ }
+ if (datastore != NULL)
+ {
+ GNUNET_DATASTORE_disconnect (datastore, GNUNET_NO);
+ datastore = NULL;
+ }
+ if (stats != NULL)
+ {
+ GNUNET_STATISTICS_destroy (stats, GNUNET_NO);
+ stats = NULL;
+ }
+}
+
+
+/**
+ * Main function that will be run.
+ *
+ * @param cls closure
+ * @param s the scheduler to use
+ * @param args remaining command-line arguments
+ * @param cfgfile name of the configuration file used (for saving, can be NULL!)
+ * @param c configuration
+ */
+static void
+run (void *cls,
+ struct GNUNET_SCHEDULER_Handle * s,
+ char *const *args,
+ const char *cfgfile,
+ const struct GNUNET_CONFIGURATION_Handle * c)
+{
+ struct GNUNET_CORE_MessageHandler handlers[] =
+ {
+ { NULL, 0, 0 }
+ };
+ sched = s;
+ cfg = c;
+ stats = GNUNET_STATISTICS_create (sched, "topology", cfg);
+ handle = GNUNET_CORE_connect (sched,
+ cfg,
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ NULL,
+ &core_init,
+ &connect_notify,
+ &disconnect_notify,
+ NULL, GNUNET_NO,
+ NULL, GNUNET_NO,
+ handlers);
+ datastore = GNUNET_DATASTORE_connect (cfg, sched);
+ GNUNET_SCHEDULER_add_delayed (sched,
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ &cleaning_task, NULL);
+ if ( (NULL == handle) ||
+ (NULL == datastore) )
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Failed to connect to `%s' service.\n"),
+ (NULL == handle) ? "core" : "datastore");
+ GNUNET_SCHEDULER_shutdown (sched);
+ return;
+ }
+}
+
+
+/**
+ * gnunet-daemon-topology command line options.
+ */
+static struct GNUNET_GETOPT_CommandLineOption options[] = {
+ GNUNET_GETOPT_OPTION_END
+};
+
+
+/**
+ * The main function for the topology daemon.
+ *
+ * @param argc number of arguments from the command line
+ * @param argv command line arguments
+ * @return 0 ok, 1 on error
+ */
+int
+main (int argc, char *const *argv)
+{
+ int ret;
+
+ ret = (GNUNET_OK ==
+ GNUNET_PROGRAM_run (argc,
+ argv,
+ "migration",
+ _("Content migration for anonymous file-sharing"),
+ options,
+ &run, NULL)) ? 0 : 1;
+ return ret;
+}
+
+/* end of gnunet-daemon-migration.c */
--- /dev/null
+/*
+ This file is part of GNUnet.
+ (C) 2010 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 2, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+/**
+ * @file topology/test_gnunet_daemon_migration.c
+ * @brief testcase for content migration code
+ */
+#include "platform.h"
+#include "gnunet_testing_lib.h"
+
+#define VERBOSE GNUNET_YES
+
+#define NUM_PEERS 2
+
+/**
+ * How long until we give up on connecting the peers?
+ */
+#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
+
+#define CONNECT_ATTEMPTS 3
+
+
+static int ok;
+
+static int peers_left;
+
+static int connect_left;
+
+static struct GNUNET_TESTING_PeerGroup *pg;
+
+static struct GNUNET_TESTING_Daemon *first;
+
+static struct GNUNET_TESTING_Daemon *last;
+
+static struct GNUNET_SCHEDULER_Handle *sched;
+
+
+static void
+clean_up_task (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ GNUNET_TESTING_daemons_stop (pg);
+ ok = 0;
+}
+
+
+static void
+notify_connect_complete(void *cls,
+ const struct GNUNET_PeerIdentity *first,
+ const struct GNUNET_PeerIdentity *second,
+ const struct GNUNET_CONFIGURATION_Handle *first_cfg,
+ const struct GNUNET_CONFIGURATION_Handle *second_cfg,
+ struct GNUNET_TESTING_Daemon *first_daemon,
+ struct GNUNET_TESTING_Daemon *second_daemon,
+ const char *emsg)
+{
+ if (NULL != emsg)
+ {
+ fprintf (stderr,
+ "Failed to connect two peers: %s\n",
+ emsg);
+ GNUNET_TESTING_daemons_stop (pg);
+ GNUNET_assert (0);
+ return;
+ }
+ connect_left--;
+ if (connect_left == 0)
+ {
+ /* FIXME: check that topology adds a few more links
+ in addition to those that were seeded */
+ /* For now, sleep so we can have the daemon do some work */
+ GNUNET_SCHEDULER_add_delayed (sched,
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5),
+ &clean_up_task,
+ NULL);
+ }
+}
+
+
+static void my_cb(void *cls,
+ const struct GNUNET_PeerIdentity *id,
+ const struct GNUNET_CONFIGURATION_Handle *cfg,
+ struct GNUNET_TESTING_Daemon *d,
+ const char *emsg)
+{
+ GNUNET_assert (id != NULL);
+ peers_left--;
+ if (first == NULL)
+ {
+ connect_left = NUM_PEERS;
+ first = d;
+ last = d;
+ return;
+ }
+ GNUNET_TESTING_daemons_connect (last, d, TIMEOUT, CONNECT_ATTEMPTS,
+ ¬ify_connect_complete,
+ NULL);
+ if (peers_left == 0)
+ {
+ /* close circle */
+ GNUNET_TESTING_daemons_connect (d, first, TIMEOUT, CONNECT_ATTEMPTS,
+ ¬ify_connect_complete,
+ NULL);
+ }
+}
+
+
+static void
+run (void *cls,
+ struct GNUNET_SCHEDULER_Handle *s,
+ char *const *args,
+ const char *cfgfile,
+ const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+ sched = s;
+ ok = 1;
+#if VERBOSE
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Starting daemons.\n");
+#endif
+ peers_left = NUM_PEERS;
+ pg = GNUNET_TESTING_daemons_start (sched, cfg,
+ peers_left,
+ &my_cb, NULL, NULL, NULL, NULL);
+ GNUNET_assert (pg != NULL);
+}
+
+static int
+check ()
+{
+ char *const argv[] = { "test-testing",
+ "-c",
+ "test_gnunet_service_topology_data.conf",
+#if VERBOSE
+ "-L", "DEBUG",
+#endif
+ NULL
+ };
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+ GNUNET_GETOPT_OPTION_END
+ };
+ GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
+ argv, "test-gnunet-service-topology", "nohelp",
+ options, &run, &ok);
+ return ok;
+}
+
+int
+main (int argc, char *argv[])
+{
+ int ret;
+
+ GNUNET_log_setup ("test-gnunet-daemon-migration",
+#if VERBOSE
+ "DEBUG",
+#else
+ "WARNING",
+#endif
+ NULL);
+ ret = check ();
+ sleep (1); /* FIXME: needed? */
+ GNUNET_DISK_directory_remove ("/tmp/test-gnunet-topology");
+ return ret;
+}
+
+/* end of test_gnunet_daemon_migration.c */
--- /dev/null
+[PATHS]
+SERVICEHOME = /tmp/test-gnunet-topology/
+# DEFAULTCONFIG = test_gnunet_service_topology_data.conf
+
+[resolver]
+PORT = 2664
+
+[transport]
+PORT = 2665
+PLUGINS = tcp
+# DEBUG = YES
+#PREFIX = xterm -e xterm -T transport -e gdb -x cmd --args
+#PREFIX = valgrind --tool=memcheck --log-file=logs%p
+
+[arm]
+PORT = 2666
+DEFAULTSERVICES = peerinfo transport core topology
+
+[statistics]
+PORT = 2667
+
+[transport-tcp]
+PORT = 2668
+
+[peerinfo]
+PORT = 2669
+
+[core]
+PORT = 2670
+# DEBUG = YES
+
+[topology]
+# DEBUG = YES
+#PREFIX = valgrind --tool=memcheck
+
+[testing]
+WEAKRANDOM = YES
check_PROGRAMS = \
- test_gnunet_service_topology
+ test_gnunet_daemon_topology
TESTS = $(check_PROGRAMS)
-test_gnunet_service_topology_SOURCES = \
- test_gnunet_service_topology.c
-test_gnunet_service_topology_LDADD = \
+test_gnunet_daemon_topology_SOURCES = \
+ test_gnunet_daemon_topology.c
+test_gnunet_daemon_topology_LDADD = \
$(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/util/libgnunetutil.la
EXTRA_DIST = \
- test_gnunet_service_topology_data.conf
+ test_gnunet_daemon_topology_data.conf
--- /dev/null
+/*
+ This file is part of GNUnet.
+ (C) 2009 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 2, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+/**
+ * @file topology/test_gnunet_daemon_topology.c
+ * @brief testcase for topology maintenance code
+ */
+#include "platform.h"
+#include "gnunet_testing_lib.h"
+
+#define VERBOSE GNUNET_YES
+
+#define NUM_PEERS 2
+
+/**
+ * How long until we give up on connecting the peers?
+ */
+#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
+
+#define CONNECT_ATTEMPTS 3
+
+
+static int ok;
+
+static int peers_left;
+
+static int connect_left;
+
+static struct GNUNET_TESTING_PeerGroup *pg;
+
+static struct GNUNET_TESTING_Daemon *first;
+
+static struct GNUNET_TESTING_Daemon *last;
+
+static struct GNUNET_SCHEDULER_Handle *sched;
+
+
+static void
+clean_up_task (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ GNUNET_TESTING_daemons_stop (pg);
+ ok = 0;
+}
+
+
+static void
+notify_connect_complete(void *cls,
+ const struct GNUNET_PeerIdentity *first,
+ const struct GNUNET_PeerIdentity *second,
+ const struct GNUNET_CONFIGURATION_Handle *first_cfg,
+ const struct GNUNET_CONFIGURATION_Handle *second_cfg,
+ struct GNUNET_TESTING_Daemon *first_daemon,
+ struct GNUNET_TESTING_Daemon *second_daemon,
+ const char *emsg)
+{
+ if (NULL != emsg)
+ {
+ fprintf (stderr,
+ "Failed to connect two peers: %s\n",
+ emsg);
+ GNUNET_TESTING_daemons_stop (pg);
+ GNUNET_assert (0);
+ return;
+ }
+ connect_left--;
+ if (connect_left == 0)
+ {
+ /* FIXME: check that topology adds a few more links
+ in addition to those that were seeded */
+ /* For now, sleep so we can have the daemon do some work */
+ GNUNET_SCHEDULER_add_delayed (sched,
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5),
+ &clean_up_task,
+ NULL);
+ }
+}
+
+
+static void my_cb(void *cls,
+ const struct GNUNET_PeerIdentity *id,
+ const struct GNUNET_CONFIGURATION_Handle *cfg,
+ struct GNUNET_TESTING_Daemon *d,
+ const char *emsg)
+{
+ GNUNET_assert (id != NULL);
+ peers_left--;
+ if (first == NULL)
+ {
+ connect_left = NUM_PEERS;
+ first = d;
+ last = d;
+ return;
+ }
+ GNUNET_TESTING_daemons_connect (last, d, TIMEOUT, CONNECT_ATTEMPTS,
+ ¬ify_connect_complete,
+ NULL);
+ if (peers_left == 0)
+ {
+ /* close circle */
+ GNUNET_TESTING_daemons_connect (d, first, TIMEOUT, CONNECT_ATTEMPTS,
+ ¬ify_connect_complete,
+ NULL);
+ }
+}
+
+
+static void
+run (void *cls,
+ struct GNUNET_SCHEDULER_Handle *s,
+ char *const *args,
+ const char *cfgfile,
+ const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+ sched = s;
+ ok = 1;
+#if VERBOSE
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Starting daemons.\n");
+#endif
+ peers_left = NUM_PEERS;
+ pg = GNUNET_TESTING_daemons_start (sched, cfg,
+ peers_left,
+ &my_cb, NULL, NULL, NULL, NULL);
+ GNUNET_assert (pg != NULL);
+}
+
+static int
+check ()
+{
+ char *const argv[] = { "test-testing",
+ "-c",
+ "test_gnunet_daemon_topology_data.conf",
+#if VERBOSE
+ "-L", "DEBUG",
+#endif
+ NULL
+ };
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+ GNUNET_GETOPT_OPTION_END
+ };
+ GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
+ argv, "test-gnunet-daemon-topology", "nohelp",
+ options, &run, &ok);
+ return ok;
+}
+
+int
+main (int argc, char *argv[])
+{
+ int ret;
+
+ GNUNET_log_setup ("test-gnunet-daemon-topology",
+#if VERBOSE
+ "DEBUG",
+#else
+ "WARNING",
+#endif
+ NULL);
+ ret = check ();
+ sleep (1); /* FIXME: needed? */
+ GNUNET_DISK_directory_remove ("/tmp/test-gnunet-topology");
+ return ret;
+}
+
+/* end of test_gnunet_daemon_topology.c */
--- /dev/null
+[PATHS]
+SERVICEHOME = /tmp/test-gnunet-topology/
+# DEFAULTCONFIG = test_gnunet_service_topology_data.conf
+
+[resolver]
+PORT = 2664
+
+[transport]
+PORT = 2665
+PLUGINS = tcp
+# DEBUG = YES
+#PREFIX = xterm -e xterm -T transport -e gdb -x cmd --args
+#PREFIX = valgrind --tool=memcheck --log-file=logs%p
+
+[arm]
+PORT = 2666
+DEFAULTSERVICES = peerinfo transport core topology
+
+[statistics]
+PORT = 2667
+
+[transport-tcp]
+PORT = 2668
+
+[peerinfo]
+PORT = 2669
+
+[core]
+PORT = 2670
+# DEBUG = YES
+
+[topology]
+# DEBUG = YES
+#PREFIX = valgrind --tool=memcheck
+
+[testing]
+WEAKRANDOM = YES
+++ /dev/null
-/*
- This file is part of GNUnet.
- (C) 2009 Christian Grothoff (and other contributing authors)
-
- GNUnet is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 2, or (at your
- option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-*/
-/**
- * @file topology/test_gnunet_service_topology.c
- * @brief testcase for topology maintenance code
- */
-#include "platform.h"
-#include "gnunet_testing_lib.h"
-
-#define VERBOSE GNUNET_YES
-
-#define NUM_PEERS 2
-
-/**
- * How long until we give up on connecting the peers?
- */
-#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
-
-#define CONNECT_ATTEMPTS 3
-
-
-static int ok;
-
-static int peers_left;
-
-static int connect_left;
-
-static struct GNUNET_TESTING_PeerGroup *pg;
-
-static struct GNUNET_TESTING_Daemon *first;
-
-static struct GNUNET_TESTING_Daemon *last;
-
-static struct GNUNET_SCHEDULER_Handle *sched;
-
-
-static void
-clean_up_task (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
- GNUNET_TESTING_daemons_stop (pg);
- ok = 0;
-}
-
-
-static void
-notify_connect_complete(void *cls,
- const struct GNUNET_PeerIdentity *first,
- const struct GNUNET_PeerIdentity *second,
- const struct GNUNET_CONFIGURATION_Handle *first_cfg,
- const struct GNUNET_CONFIGURATION_Handle *second_cfg,
- struct GNUNET_TESTING_Daemon *first_daemon,
- struct GNUNET_TESTING_Daemon *second_daemon,
- const char *emsg)
-{
- if (NULL != emsg)
- {
- fprintf (stderr,
- "Failed to connect two peers: %s\n",
- emsg);
- GNUNET_TESTING_daemons_stop (pg);
- GNUNET_assert (0);
- return;
- }
- connect_left--;
- if (connect_left == 0)
- {
- /* FIXME: check that topology adds a few more links
- in addition to those that were seeded */
- /* For now, sleep so we can have the daemon do some work */
- GNUNET_SCHEDULER_add_delayed (sched,
- GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5),
- &clean_up_task,
- NULL);
- }
-}
-
-
-static void my_cb(void *cls,
- const struct GNUNET_PeerIdentity *id,
- const struct GNUNET_CONFIGURATION_Handle *cfg,
- struct GNUNET_TESTING_Daemon *d,
- const char *emsg)
-{
- GNUNET_assert (id != NULL);
- peers_left--;
- if (first == NULL)
- {
- connect_left = NUM_PEERS;
- first = d;
- last = d;
- return;
- }
- GNUNET_TESTING_daemons_connect (last, d, TIMEOUT, CONNECT_ATTEMPTS,
- ¬ify_connect_complete,
- NULL);
- if (peers_left == 0)
- {
- /* close circle */
- GNUNET_TESTING_daemons_connect (d, first, TIMEOUT, CONNECT_ATTEMPTS,
- ¬ify_connect_complete,
- NULL);
- }
-}
-
-
-static void
-run (void *cls,
- struct GNUNET_SCHEDULER_Handle *s,
- char *const *args,
- const char *cfgfile,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
- sched = s;
- ok = 1;
-#if VERBOSE
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Starting daemons.\n");
-#endif
- peers_left = NUM_PEERS;
- pg = GNUNET_TESTING_daemons_start (sched, cfg,
- peers_left,
- &my_cb, NULL, NULL, NULL, NULL);
- GNUNET_assert (pg != NULL);
-}
-
-static int
-check ()
-{
- char *const argv[] = { "test-testing",
- "-c",
- "test_gnunet_service_topology_data.conf",
-#if VERBOSE
- "-L", "DEBUG",
-#endif
- NULL
- };
- struct GNUNET_GETOPT_CommandLineOption options[] = {
- GNUNET_GETOPT_OPTION_END
- };
- GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
- argv, "test-gnunet-service-topology", "nohelp",
- options, &run, &ok);
- return ok;
-}
-
-int
-main (int argc, char *argv[])
-{
- int ret;
-
- GNUNET_log_setup ("test-gnunet-service-topology",
-#if VERBOSE
- "DEBUG",
-#else
- "WARNING",
-#endif
- NULL);
- ret = check ();
- sleep (1); /* FIXME: needed? */
- GNUNET_DISK_directory_remove ("/tmp/test-gnunet-topology");
- return ret;
-}
-
-/* end of test_gnunet_service_topology.c */
+++ /dev/null
-[PATHS]
-SERVICEHOME = /tmp/test-gnunet-topology/
-# DEFAULTCONFIG = test_gnunet_service_topology_data.conf
-
-[resolver]
-PORT = 2664
-
-[transport]
-PORT = 2665
-PLUGINS = tcp
-# DEBUG = YES
-#PREFIX = xterm -e xterm -T transport -e gdb -x cmd --args
-#PREFIX = valgrind --tool=memcheck --log-file=logs%p
-
-[arm]
-PORT = 2666
-DEFAULTSERVICES = peerinfo transport core topology
-
-[statistics]
-PORT = 2667
-
-[transport-tcp]
-PORT = 2668
-
-[peerinfo]
-PORT = 2669
-
-[core]
-PORT = 2670
-# DEBUG = YES
-
-[topology]
-# DEBUG = YES
-#PREFIX = valgrind --tool=memcheck
-
-[testing]
-WEAKRANDOM = YES
_("gethostbyname() could not lookup IP address: %s\n"),
hstrerror (h_errno));
#endif
- GNUNET_break(0);
+ fprintf (stderr,
+ "System seems to be off-line, will not run all DNS tests\n");
return;
}