functions for manipulating non-accept blocks stored for regex in the DHT More...
Go to the source code of this file.
Data Structures | |
struct | EdgeInfo |
Information for each edge. More... | |
struct | RegexBlock |
Block to announce a regex state. More... | |
struct | CheckEdgeContext |
Struct to keep track of the xquery while iterating all the edges in a block. More... | |
Macros | |
#define | LOG(kind, ...) GNUNET_log_from (kind, "regex-bck", __VA_ARGS__) |
Functions | |
GNUNET_NETWORK_STRUCT_END int | GNUNET_BLOCK_is_accepting (const struct RegexBlock *block, size_t size) |
Test if this block is marked as being an accept state. More... | |
int | REGEX_BLOCK_check_proof (const char *proof, size_t proof_len, const struct GNUNET_HashCode *key) |
Check if the given 'proof' matches the given 'key'. More... | |
static int | check_edge (void *cls, const char *token, size_t len, const struct GNUNET_HashCode *key) |
Iterator over all edges in a block, checking for a presence of a given query. More... | |
int | REGEX_BLOCK_check (const struct RegexBlock *block, size_t size, const struct GNUNET_HashCode *query, const char *xquery) |
Check if the regex block is well formed, including all edges. More... | |
int | REGEX_BLOCK_get_key (const struct RegexBlock *block, size_t block_len, struct GNUNET_HashCode *key) |
Obtain the key that a particular block is to be stored under. More... | |
int | REGEX_BLOCK_iterate (const struct RegexBlock *block, size_t size, REGEX_INTERNAL_EgdeIterator iterator, void *iter_cls) |
Iterate over all edges of a block of a regex state. More... | |
struct RegexBlock * | REGEX_BLOCK_create (const char *proof, unsigned int num_edges, const struct REGEX_BLOCK_Edge *edges, int accepting, size_t *rsize) |
Construct a regex block to be stored in the DHT. More... | |
functions for manipulating non-accept blocks stored for regex in the DHT
Definition in file regex_block_lib.c.
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, "regex-bck", __VA_ARGS__) |
Definition at line 30 of file regex_block_lib.c.
GNUNET_NETWORK_STRUCT_END int GNUNET_BLOCK_is_accepting | ( | const struct RegexBlock * | block, |
size_t | size | ||
) |
Test if this block is marked as being an accept state.
block | block to test |
size | number of bytes in block |
Definition at line 101 of file regex_block_lib.c.
References GNUNET_break_op, GNUNET_SYSERR, RegexBlock::is_accepting, and size.
Referenced by dht_get_string_handler(), and regex_result_iterator().
int REGEX_BLOCK_check_proof | ( | const char * | proof, |
size_t | proof_len, | ||
const struct GNUNET_HashCode * | key | ||
) |
Check if the given 'proof' matches the given 'key'.
proof | partial regex of a state |
proof_len | number of bytes in proof |
key | hash of a state. |
Definition at line 114 of file regex_block_lib.c.
References GNUNET_CRYPTO_hash(), GNUNET_CRYPTO_hash_cmp(), GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_NO, GNUNET_OK, key, and proof.
|
static |
Iterator over all edges in a block, checking for a presence of a given query.
cls | Closure, (xquery context). |
token | Token that follows to next state. |
len | Length of token. |
key | Hash of next state. |
Definition at line 159 of file regex_block_lib.c.
References ctx, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_OK, GNUNET_YES, and key.
Referenced by REGEX_BLOCK_check().
int REGEX_BLOCK_check | ( | const struct RegexBlock * | block, |
size_t | size, | ||
const struct GNUNET_HashCode * | query, | ||
const char * | xquery | ||
) |
Check if the regex block is well formed, including all edges.
block | The start of the block. |
size | The size of the block. |
query | the query for the block |
xquery | String describing the edge we are looking for. Can be NULL in case this is a put block. |
Definition at line 183 of file regex_block_lib.c.
References check_edge(), ctx, GNUNET_break_op, GNUNET_ERROR_TYPE_DEBUG, GNUNET_memcmp, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, RegexBlock::is_accepting, key, LOG, REGEX_BLOCK_get_key(), REGEX_BLOCK_iterate(), res, size, and CheckEdgeContext::xquery.
Referenced by block_plugin_regex_check_block(), and block_plugin_regex_check_reply().
int REGEX_BLOCK_get_key | ( | const struct RegexBlock * | block, |
size_t | block_len, | ||
struct GNUNET_HashCode * | key | ||
) |
Obtain the key that a particular block is to be stored under.
block | block to get the key from |
block_len | number of bytes in block |
key | where to store the key |
Definition at line 230 of file regex_block_lib.c.
References GNUNET_break_op, GNUNET_CRYPTO_hash(), GNUNET_OK, GNUNET_SYSERR, key, RegexBlock::num_destinations, RegexBlock::num_edges, and RegexBlock::proof_len.
Referenced by block_plugin_regex_get_key(), and REGEX_BLOCK_check().
int REGEX_BLOCK_iterate | ( | const struct RegexBlock * | block, |
size_t | size, | ||
REGEX_INTERNAL_EgdeIterator | iterator, | ||
void * | iter_cls | ||
) |
Iterate over all edges of a block of a regex state.
block | Block to iterate over. |
size | Size of block. |
iterator | Function to call on each edge in the block. |
iter_cls | Closure for the iterator. |
Definition at line 265 of file regex_block_lib.c.
References GNUNET_break_op, GNUNET_ERROR_TYPE_DEBUG, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, LOG, RegexBlock::num_destinations, RegexBlock::num_edges, RegexBlock::proof_len, and size.
Referenced by REGEX_BLOCK_check(), and regex_next_edge().
struct RegexBlock * REGEX_BLOCK_create | ( | const char * | proof, |
unsigned int | num_edges, | ||
const struct REGEX_BLOCK_Edge * | edges, | ||
int | accepting, | ||
size_t * | rsize | ||
) |
Construct a regex block to be stored in the DHT.
proof | proof string for the block |
num_edges | number of edges in the block |
edges | the edges of the block |
accepting | is this an accepting state |
rsize | set to the size of the returned block (OUT-only) |
Definition at line 346 of file regex_block_lib.c.
References REGEX_BLOCK_Edge::destination, EdgeInfo::destination_index, GNUNET_break, GNUNET_CONSTANTS_MAX_BLOCK_SIZE, GNUNET_malloc, GNUNET_memcpy, RegexBlock::is_accepting, RegexBlock::num_destinations, RegexBlock::num_edges, proof, RegexBlock::proof_len, and EdgeInfo::token_length.
Referenced by regex_iterator().