static void
env_delete_notify (void *cls,
const GNUNET_HashCode *key,
- uint32_t size)
+ size_t size)
{
struct GNUNET_DATACACHE_Handle * h = cls;
GNUNET_assert (h->utilization >= size);
int
GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h,
const GNUNET_HashCode * key,
- uint32_t size,
+ size_t size,
const char *data,
enum GNUNET_BLOCK_Type type,
struct GNUNET_TIME_Absolute discard_time)
checkIt (void *cls,
struct GNUNET_TIME_Absolute exp,
const GNUNET_HashCode * key,
- uint32_t size,
+ size_t size,
const char *data,
enum GNUNET_BLOCK_Type type)
{
*/
typedef void (*GNUNET_DATACACHE_DeleteNotifyCallback)(void *cls,
const GNUNET_HashCode *key,
- uint32_t size);
+ size_t size);
/**
* @param discard_time when to discard the value in any case
* @return 0 on error, number of bytes used otherwise
*/
- uint32_t (*put) (void *cls,
- const GNUNET_HashCode * key,
- uint32_t size,
- const char *data,
- enum GNUNET_BLOCK_Type type,
- struct GNUNET_TIME_Absolute discard_time);
+ size_t (*put) (void *cls,
+ const GNUNET_HashCode * key,
+ size_t size,
+ const char *data,
+ enum GNUNET_BLOCK_Type type,
+ struct GNUNET_TIME_Absolute discard_time);
/**
* @param discard_time when to discard the value in any case
* @return 0 on error, number of bytes used otherwise
*/
-static uint32_t
+static size_t
mysql_plugin_put (void *cls,
const GNUNET_HashCode * key,
- uint32_t size,
+ size_t size,
const char *data,
enum GNUNET_BLOCK_Type type,
struct GNUNET_TIME_Absolute discard_time)
* @param discard_time when to discard the value in any case
* @return 0 on error, number of bytes used otherwise
*/
-static uint32_t
+static size_t
postgres_plugin_put (void *cls,
const GNUNET_HashCode * key,
- uint32_t size,
+ size_t size,
const char *data,
enum GNUNET_BLOCK_Type type,
struct GNUNET_TIME_Absolute discard_time)
* @param discard_time when to discard the value in any case
* @return 0 on error, number of bytes used otherwise
*/
-static uint32_t
+static size_t
sqlite_plugin_put (void *cls,
const GNUNET_HashCode * key,
- uint32_t size,
+ size_t size,
const char *data,
enum GNUNET_BLOCK_Type type,
struct GNUNET_TIME_Absolute discard_time)
* @param discard_time when to discard the value in any case
* @return 0 on error, number of bytes used otherwise
*/
-static uint32_t
+static size_t
template_plugin_put (void *cls,
const GNUNET_HashCode * key,
- uint32_t size,
+ size_t size,
const char *data,
enum GNUNET_BLOCK_Type type,
struct GNUNET_TIME_Absolute discard_time)
checkIt (void *cls,
struct GNUNET_TIME_Absolute exp,
const GNUNET_HashCode * key,
- uint32_t size,
+ size_t size,
const char *data,
enum GNUNET_BLOCK_Type type)
{
GNUNET_DATASTORE_put (struct GNUNET_DATASTORE_Handle *h,
int rid,
const GNUNET_HashCode * key,
- uint32_t size,
+ size_t size,
const void *data,
enum GNUNET_BLOCK_Type type,
uint32_t priority,
dm->header.type = htons(GNUNET_MESSAGE_TYPE_DATASTORE_PUT);
dm->header.size = htons(msize);
dm->rid = htonl(rid);
- dm->size = htonl(size);
+ dm->size = htonl( (uint32_t) size);
dm->type = htonl(type);
dm->priority = htonl(priority);
dm->anonymity = htonl(anonymity);
struct GNUNET_DATASTORE_QueueEntry *
GNUNET_DATASTORE_remove (struct GNUNET_DATASTORE_Handle *h,
const GNUNET_HashCode *key,
- uint32_t size,
+ size_t size,
const void *data,
unsigned int queue_priority,
unsigned int max_queue_size,
int i;
GNUNET_HashCode key;
- uint32_t esize;
+ size_t esize;
char data[65536];
};
static void
delete_value (void *cls,
const GNUNET_HashCode * key,
- uint32_t size,
+ size_t size,
const void *data,
enum GNUNET_BLOCK_Type type,
uint32_t priority,
static void
check_value (void *cls,
const GNUNET_HashCode * key,
- uint32_t size,
+ size_t size,
const void *data,
enum GNUNET_BLOCK_Type type,
uint32_t priority,
static void
delete_value (void *cls,
const GNUNET_HashCode * key,
- uint32_t size,
+ size_t size,
const void *data,
enum GNUNET_BLOCK_Type type,
uint32_t priority,
static void
check_nothing (void *cls,
const GNUNET_HashCode * key,
- uint32_t size,
+ size_t size,
const void *data,
enum GNUNET_BLOCK_Type type,
uint32_t priority,
static void
check_multiple (void *cls,
const GNUNET_HashCode * key,
- uint32_t size,
+ size_t size,
const void *data,
enum GNUNET_BLOCK_Type type,
uint32_t priority,
static void
check_update (void *cls,
const GNUNET_HashCode * key,
- uint32_t size,
+ size_t size,
const void *data,
enum GNUNET_BLOCK_Type type,
uint32_t priority,
static void
check_value (void *cls,
const GNUNET_HashCode * key,
- uint32_t size,
+ size_t size,
const void *data,
enum GNUNET_BLOCK_Type type,
uint32_t priority,
static void
check_nothing (void *cls,
const GNUNET_HashCode * key,
- uint32_t size,
+ size_t size,
const void *data,
enum GNUNET_BLOCK_Type type,
uint32_t priority,
datacache_get_iterator (void *cls,
struct GNUNET_TIME_Absolute exp,
const GNUNET_HashCode * key,
- uint32_t size, const char *data,
+ size_t size, const char *data,
enum GNUNET_BLOCK_Type type)
{
struct DHT_MessageContext *msg_ctx = cls;
const struct GNUNET_MessageHeader *msg,
struct DHT_MessageContext *message_context)
{
- struct GNUNET_DHT_PutMessage *put_msg;
+ const struct GNUNET_DHT_PutMessage *put_msg;
enum GNUNET_BLOCK_Type put_type;
size_t data_size;
int ret;
struct RepublishContext *put_context;
+ GNUNET_HashCode key;
GNUNET_assert (ntohs (msg->size) >=
sizeof (struct GNUNET_DHT_PutMessage));
- put_msg = (struct GNUNET_DHT_PutMessage *)msg;
+ put_msg = (const struct GNUNET_DHT_PutMessage *)msg;
put_type = (enum GNUNET_BLOCK_Type) ntohl (put_msg->type);
if (put_type == GNUNET_BLOCK_DHT_MALICIOUS_MESSAGE_TYPE)
return;
-
data_size = ntohs (put_msg->header.size) - sizeof (struct GNUNET_DHT_PutMessage);
-
+ ret = GNUNET_BLOCK_get_key (block_context,
+ put_type,
+ &put_msg[1],
+ data_size,
+ &key);
+ if (GNUNET_NO == ret)
+ {
+ /* invalid reply */
+ GNUNET_break_op (0);
+ return;
+ }
+ if ( (GNUNET_YES == ret) &&
+ (0 != memcmp (&key,
+ &message_context->key,
+ sizeof (GNUNET_HashCode))) )
+ {
+ /* invalid wrapper: key mismatch! */
+ GNUNET_break_op (0);
+ return;
+ }
+ /* ret == GNUNET_SYSERR means that there is no known relationship between
+ data and the key, so we cannot check it */
+#if DEBUG_DHT
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "`%s:%s': Received `%s' request (inserting data!), message type %d, key %s, uid %llu\n",
+ my_short_id, "DHT", "PUT", put_type, GNUNET_h2s (&message_context->key), message_context->unique_id);
+#endif
#if DEBUG_DHT_ROUTING
if (message_context->hop_count == 0) /* Locally initiated request */
{
republish_content_iterator (void *cls,
struct GNUNET_TIME_Absolute exp,
const GNUNET_HashCode * key,
- uint32_t size, const char *data, uint32_t type)
+ size_t size, const char *data, uint32_t type)
{
struct DHT_MessageContext *new_msg_ctx;
typedef int (*GNUNET_DATACACHE_Iterator) (void *cls,
struct GNUNET_TIME_Absolute exp,
const GNUNET_HashCode * key,
- uint32_t size, /* FIXME: use size_t? */
+ size_t size,
const char *data,
enum GNUNET_BLOCK_Type type);
int
GNUNET_DATACACHE_put (struct GNUNET_DATACACHE_Handle *h,
const GNUNET_HashCode * key,
- uint32_t size,
+ size_t size,
const char *data,
enum GNUNET_BLOCK_Type type,
struct GNUNET_TIME_Absolute discard_time);
GNUNET_DATASTORE_put (struct GNUNET_DATASTORE_Handle *h,
int rid,
const GNUNET_HashCode * key,
- uint32_t size,
+ size_t size,
const void *data,
enum GNUNET_BLOCK_Type type,
uint32_t priority,
struct GNUNET_DATASTORE_QueueEntry *
GNUNET_DATASTORE_remove (struct GNUNET_DATASTORE_Handle *h,
const GNUNET_HashCode *key,
- uint32_t size,
+ size_t size,
const void *data,
unsigned int queue_priority,
unsigned int max_queue_size,
*/
typedef void (*GNUNET_DATASTORE_Iterator) (void *cls,
const GNUNET_HashCode * key,
- uint32_t size,
+ size_t size,
const void *data,
enum GNUNET_BLOCK_Type type,
uint32_t priority,
GNUNET_DATASTORE_Iterator iter,
void *iter_cls);
+
/**
* Cancel a datastore operation. The final callback from the
* operation must not have been done yet.