/*
This file is part of GNUnet
- (C) 2012 Christian Grothoff (and other contributing authors)
+ (C) 2012,2013 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
#include "platform.h"
#include "gnunet_block_plugin.h"
#include "block_mesh.h"
-#include "mesh_block_lib.h"
/**
* Number of bits we set per entry in the bloomfilter.
return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
if (sizeof (struct PBlock) != reply_block_size)
return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
- return GNUNET_BLOCK_EVALUATION_OK_LAST;
-
-
- case GNUNET_BLOCK_TYPE_MESH_PEER_BY_TYPE:
- /* FIXME: have an xquery? not sure */
- if (0 != xquery_size)
- {
- GNUNET_break_op (0);
- return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID;
- }
- if (NULL == reply_block)
- return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
- if (sizeof (struct PBlock) != reply_block_size)
- {
- GNUNET_break_op(0);
- return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
- }
if (NULL != bf)
{
GNUNET_CRYPTO_hash (reply_block, reply_block_size, &chash);
}
GNUNET_CONTAINER_bloomfilter_add (*bf, &mhash);
}
- return GNUNET_BLOCK_EVALUATION_OK_MORE;
-
- case GNUNET_BLOCK_TYPE_MESH_REGEX:
- if (NULL == reply_block)
- return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
- if (0 != xquery_size)
- {
- const char *query;
-
- query = (const char *) xquery;
- if ('\0' != query[xquery_size - 1]) /* must be valid string */
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Block xquery not a valid string\n");
- return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
- }
- }
- else
- {
- GNUNET_break_op (0);
- return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
- }
- switch (GNUNET_MESH_regex_block_check (reply_block,
- reply_block_size,
- xquery))
- {
- case GNUNET_SYSERR:
- GNUNET_break_op(0);
- return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
- case GNUNET_NO:
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "BLOCK XQUERY %s not accepted\n", xquery);
- return GNUNET_BLOCK_EVALUATION_RESULT_IRRELEVANT;
- default:
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "BLOCK XQUERY %s accepted\n", xquery);
- break;
- }
- if (NULL != bf)
- {
- GNUNET_CRYPTO_hash (reply_block, reply_block_size, &chash);
- GNUNET_BLOCK_mingle_hash (&chash, bf_mutator, &mhash);
- if (NULL != *bf)
- {
- if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (*bf, &mhash))
- return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE;
- }
- else
- {
- *bf = GNUNET_CONTAINER_bloomfilter_init (NULL, 8, BLOOMFILTER_K);
- }
- GNUNET_CONTAINER_bloomfilter_add (*bf, &mhash);
- }
- return GNUNET_BLOCK_EVALUATION_OK_MORE;
+ return GNUNET_BLOCK_EVALUATION_OK_LAST;
- case GNUNET_BLOCK_TYPE_MESH_REGEX_ACCEPT:
+ case GNUNET_BLOCK_TYPE_MESH_PEER_BY_TYPE:
+ /* FIXME: have an xquery? not sure */
if (0 != xquery_size)
{
GNUNET_break_op (0);
}
if (NULL == reply_block)
return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
- if (sizeof (struct MeshRegexAccept) != reply_block_size)
+ if (sizeof (struct PBlock) != reply_block_size)
{
GNUNET_break_op(0);
return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
}
return GNUNET_BLOCK_EVALUATION_OK_MORE;
-
default:
return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED;
}
struct GNUNET_HashCode * key)
{
const struct PBlock *pb;
+ GNUNET_MESH_ApplicationType app_type;
pb = block;
switch (type)
*key = pb->id.hashPubKey;
return GNUNET_OK;
case GNUNET_BLOCK_TYPE_MESH_PEER_BY_TYPE:
- GNUNET_CRYPTO_hash (&pb->type, sizeof(GNUNET_MESH_ApplicationType), key);
+ app_type = ntohl (pb->type);
+ GNUNET_CRYPTO_hash (&app_type, sizeof(GNUNET_MESH_ApplicationType), key);
return GNUNET_OK;
default:
+ GNUNET_break (0);
return GNUNET_SYSERR;
}
}
{
GNUNET_BLOCK_TYPE_MESH_PEER,
GNUNET_BLOCK_TYPE_MESH_PEER_BY_TYPE,
- GNUNET_BLOCK_TYPE_MESH_REGEX,
- GNUNET_BLOCK_TYPE_MESH_REGEX_ACCEPT,
GNUNET_BLOCK_TYPE_ANY /* end of list */
};
struct GNUNET_BLOCK_PluginFunctions *api;