summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <grothoff@gnunet.org>2022-03-12 04:01:02 +0100
committerChristian Grothoff <grothoff@gnunet.org>2022-03-12 04:01:02 +0100
commitff992f47e6528b00937c3951b812f6938e1ee21a (patch)
tree96917d63e24d2cc02b0e09a4e1dc29987541ffe8
parent06f6791f2d55ab3a1b4ca4c3ba9ed5c315f8d79b (diff)
revise block API to match latest DHT specs
-rw-r--r--po/POTFILES.in100
-rw-r--r--src/block/block.c33
-rw-r--r--src/block/plugin_block_template.c82
-rw-r--r--src/block/plugin_block_test.c120
-rw-r--r--src/consensus/plugin_block_consensus.c61
-rw-r--r--src/dht/gnunet-service-dht_clients.c3
-rw-r--r--src/dht/gnunet-service-dht_datacache.c21
-rw-r--r--src/dht/gnunet-service-dht_datacache.h4
-rw-r--r--src/dht/gnunet-service-dht_neighbours.c44
-rw-r--r--src/dht/gnunet-service-dht_routing.c7
-rw-r--r--src/dht/plugin_block_dht.c163
-rw-r--r--src/dns/plugin_block_dns.c128
-rw-r--r--src/fs/gnunet-service-fs_pr.c74
-rw-r--r--src/fs/plugin_block_fs.c117
-rw-r--r--src/gns/plugin_block_gns.c132
-rw-r--r--src/gnsrecord/gnsrecord_crypto.c5
-rw-r--r--src/include/gnunet_block_lib.h136
-rw-r--r--src/include/gnunet_block_plugin.h61
-rw-r--r--src/regex/plugin_block_regex.c287
-rw-r--r--src/revocation/plugin_block_revocation.c74
-rw-r--r--src/set/plugin_block_set_test.c44
-rw-r--r--src/seti/plugin_block_seti_test.c72
-rw-r--r--src/setu/plugin_block_setu_test.c76
23 files changed, 410 insertions, 1434 deletions
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 5c1152e7c..64df0a13b 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -10,14 +10,13 @@ src/arm/arm_monitor_api.c
src/arm/gnunet-arm.c
src/arm/gnunet-service-arm.c
src/arm/mockup-service.c
-src/ats-tool/gnunet-ats.c
src/ats/ats_api_connectivity.c
src/ats/ats_api_performance.c
src/ats/ats_api_scanner.c
src/ats/ats_api_scheduling.c
src/ats/gnunet-ats-solver-eval.c
-src/ats/gnunet-service-ats.c
src/ats/gnunet-service-ats_addresses.c
+src/ats/gnunet-service-ats.c
src/ats/gnunet-service-ats_connectivity.c
src/ats/gnunet-service-ats_normalization.c
src/ats/gnunet-service-ats_performance.c
@@ -26,6 +25,7 @@ src/ats/gnunet-service-ats_preferences.c
src/ats/gnunet-service-ats_reservations.c
src/ats/gnunet-service-ats_scheduling.c
src/ats/plugin_ats_proportional.c
+src/ats-tool/gnunet-ats.c
src/auction/gnunet-auction-create.c
src/auction/gnunet-auction-info.c
src/auction/gnunet-auction-join.c
@@ -43,8 +43,8 @@ src/cadet/cadet_api_list_peers.c
src/cadet/cadet_api_list_tunnels.c
src/cadet/cadet_test_lib.c
src/cadet/desirability_table.c
-src/cadet/gnunet-cadet-profiler.c
src/cadet/gnunet-cadet.c
+src/cadet/gnunet-cadet-profiler.c
src/cadet/gnunet-service-cadet.c
src/cadet/gnunet-service-cadet_channel.c
src/cadet/gnunet-service-cadet_connection.c
@@ -60,15 +60,15 @@ src/consensus/gnunet-service-consensus.c
src/consensus/plugin_block_consensus.c
src/conversation/conversation_api.c
src/conversation/conversation_api_call.c
-src/conversation/gnunet-conversation-test.c
src/conversation/gnunet-conversation.c
-src/conversation/gnunet-helper-audio-playback-gst.c
+src/conversation/gnunet-conversation-test.c
+src/conversation/gnunet_gst.c
+src/conversation/gnunet_gst_test.c
src/conversation/gnunet-helper-audio-playback.c
-src/conversation/gnunet-helper-audio-record-gst.c
+src/conversation/gnunet-helper-audio-playback-gst.c
src/conversation/gnunet-helper-audio-record.c
+src/conversation/gnunet-helper-audio-record-gst.c
src/conversation/gnunet-service-conversation.c
-src/conversation/gnunet_gst.c
-src/conversation/gnunet_gst_test.c
src/conversation/microphone.c
src/conversation/plugin_gnsrecord_conversation.c
src/conversation/speaker.c
@@ -99,13 +99,13 @@ src/dht/dht_test_lib.c
src/dht/gnunet-dht-get.c
src/dht/gnunet-dht-hello.c
src/dht/gnunet-dht-monitor.c
+src/dht/gnunet_dht_profiler.c
src/dht/gnunet-dht-put.c
src/dht/gnunet-service-dht.c
src/dht/gnunet-service-dht_clients.c
src/dht/gnunet-service-dht_datacache.c
src/dht/gnunet-service-dht_neighbours.c
src/dht/gnunet-service-dht_routing.c
-src/dht/gnunet_dht_profiler.c
src/dht/plugin_block_dht.c
src/dhtu/plugin_dhtu_gnunet.c
src/dhtu/plugin_dhtu_ip.c
@@ -143,8 +143,8 @@ src/fs/gnunet-auto-share.c
src/fs/gnunet-daemon-fsprofiler.c
src/fs/gnunet-directory.c
src/fs/gnunet-download.c
-src/fs/gnunet-fs-profiler.c
src/fs/gnunet-fs.c
+src/fs/gnunet-fs-profiler.c
src/fs/gnunet-helper-fs-publish.c
src/fs/gnunet-publish.c
src/fs/gnunet-search.c
@@ -164,9 +164,9 @@ src/gns/gns_tld_api.c
src/gns/gnunet-bcd.c
src/gns/gnunet-dns2gns.c
src/gns/gnunet-gns-benchmark.c
+src/gns/gnunet-gns.c
src/gns/gnunet-gns-import.c
src/gns/gnunet-gns-proxy.c
-src/gns/gnunet-gns.c
src/gns/gnunet-service-gns.c
src/gns/gnunet-service-gns_interceptor.c
src/gns/gnunet-service-gns_resolver.c
@@ -184,9 +184,9 @@ src/gnsrecord/json_gnsrecord.c
src/gnsrecord/plugin_gnsrecord_dns.c
src/hello/address.c
src/hello/gnunet-hello.c
+src/hello/hello.c
src/hello/hello-ng.c
src/hello/hello-uri.c
-src/hello/hello.c
src/hostlist/gnunet-daemon-hostlist.c
src/hostlist/gnunet-daemon-hostlist_client.c
src/hostlist/gnunet-daemon-hostlist_server.c
@@ -202,8 +202,8 @@ src/json/json_helper.c
src/json/json_mhd.c
src/json/json_pack.c
src/messenger/gnunet-messenger.c
-src/messenger/gnunet-service-messenger.c
src/messenger/gnunet-service-messenger_basement.c
+src/messenger/gnunet-service-messenger.c
src/messenger/gnunet-service-messenger_ego_store.c
src/messenger/gnunet-service-messenger_handle.c
src/messenger/gnunet-service-messenger_list_handles.c
@@ -243,8 +243,8 @@ src/namecache/namecache_api.c
src/namecache/plugin_namecache_flat.c
src/namecache/plugin_namecache_postgres.c
src/namecache/plugin_namecache_sqlite.c
-src/namestore/gnunet-namestore-fcfsd.c
src/namestore/gnunet-namestore.c
+src/namestore/gnunet-namestore-fcfsd.c
src/namestore/gnunet-service-namestore.c
src/namestore/gnunet-zoneimport.c
src/namestore/namestore_api.c
@@ -270,17 +270,17 @@ src/nat/gnunet-service-nat_mini.c
src/nat/gnunet-service-nat_stun.c
src/nat/nat_api.c
src/nat/nat_api_stun.c
-src/nse/gnunet-nse-profiler.c
src/nse/gnunet-nse.c
+src/nse/gnunet-nse-profiler.c
src/nse/gnunet-service-nse.c
src/nse/nse_api.c
src/nt/nt.c
-src/peerinfo-tool/gnunet-peerinfo.c
-src/peerinfo-tool/gnunet-peerinfo_plugins.c
-src/peerinfo-tool/plugin_rest_peerinfo.c
src/peerinfo/gnunet-service-peerinfo.c
src/peerinfo/peerinfo_api.c
src/peerinfo/peerinfo_api_notify.c
+src/peerinfo-tool/gnunet-peerinfo.c
+src/peerinfo-tool/gnunet-peerinfo_plugins.c
+src/peerinfo-tool/plugin_rest_peerinfo.c
src/peerstore/gnunet-peerstore.c
src/peerstore/gnunet-service-peerstore.c
src/peerstore/peerstore_api.c
@@ -332,27 +332,27 @@ src/rest/gnunet-rest-server.c
src/rest/plugin_rest_config.c
src/rest/plugin_rest_copying.c
src/rest/rest.c
-src/revocation/gnunet-revocation-tvg.c
src/revocation/gnunet-revocation.c
+src/revocation/gnunet-revocation-tvg.c
src/revocation/gnunet-service-revocation.c
src/revocation/plugin_block_revocation.c
src/revocation/revocation_api.c
-src/rps/gnunet-rps-profiler.c
src/rps/gnunet-rps.c
+src/rps/gnunet-rps-profiler.c
src/rps/gnunet-service-rps.c
src/rps/gnunet-service-rps_custommap.c
src/rps/gnunet-service-rps_sampler.c
src/rps/gnunet-service-rps_sampler_elem.c
src/rps/gnunet-service-rps_view.c
+src/rps/rps_api.c
src/rps/rps-sampler_client.c
src/rps/rps-sampler_common.c
src/rps/rps-test_util.c
-src/rps/rps_api.c
src/scalarproduct/gnunet-scalarproduct.c
-src/scalarproduct/gnunet-service-scalarproduct-ecc_alice.c
-src/scalarproduct/gnunet-service-scalarproduct-ecc_bob.c
src/scalarproduct/gnunet-service-scalarproduct_alice.c
src/scalarproduct/gnunet-service-scalarproduct_bob.c
+src/scalarproduct/gnunet-service-scalarproduct-ecc_alice.c
+src/scalarproduct/gnunet-service-scalarproduct-ecc_bob.c
src/scalarproduct/scalarproduct_api.c
src/secretsharing/gnunet-secretsharing-profiler.c
src/secretsharing/gnunet-service-secretsharing.c
@@ -366,12 +366,12 @@ src/set/gnunet-set-ibf-profiler.c
src/set/gnunet-set-profiler.c
src/set/ibf.c
src/set/ibf_sim.c
-src/set/plugin_block_set_test.c
-src/set/set_api.c
src/seti/gnunet-service-seti.c
src/seti/gnunet-seti-profiler.c
src/seti/plugin_block_seti_test.c
src/seti/seti_api.c
+src/set/plugin_block_set_test.c
+src/set/set_api.c
src/setu/gnunet-service-setu.c
src/setu/gnunet-service-setu_strata_estimator.c
src/setu/gnunet-setu-ibf-profiler.c
@@ -390,16 +390,15 @@ src/statistics/gnunet-statistics.c
src/statistics/statistics_api.c
src/template/gnunet-service-template.c
src/template/gnunet-template.c
-src/testbed-logger/gnunet-service-testbed-logger.c
-src/testbed-logger/testbed_logger_api.c
src/testbed/generate-underlay-topology.c
src/testbed/gnunet-daemon-latency-logger.c
src/testbed/gnunet-daemon-testbed-blacklist.c
src/testbed/gnunet-daemon-testbed-underlay.c
src/testbed/gnunet-helper-testbed.c
+src/testbed/gnunet_mpi_test.c
src/testbed/gnunet-service-test-barriers.c
-src/testbed/gnunet-service-testbed.c
src/testbed/gnunet-service-testbed_barriers.c
+src/testbed/gnunet-service-testbed.c
src/testbed/gnunet-service-testbed_cache.c
src/testbed/gnunet-service-testbed_connectionpool.c
src/testbed/gnunet-service-testbed_cpustatus.c
@@ -408,23 +407,23 @@ src/testbed/gnunet-service-testbed_meminfo.c
src/testbed/gnunet-service-testbed_oc.c
src/testbed/gnunet-service-testbed_peers.c
src/testbed/gnunet-testbed-profiler.c
-src/testbed/gnunet_mpi_test.c
-src/testbed/testbed_api.c
+src/testbed-logger/gnunet-service-testbed-logger.c
+src/testbed-logger/testbed_logger_api.c
src/testbed/testbed_api_barriers.c
+src/testbed/testbed_api.c
src/testbed/testbed_api_hosts.c
src/testbed/testbed_api_operations.c
src/testbed/testbed_api_peers.c
src/testbed/testbed_api_sd.c
src/testbed/testbed_api_services.c
src/testbed/testbed_api_statistics.c
-src/testbed/testbed_api_test.c
src/testbed/testbed_api_testbed.c
+src/testbed/testbed_api_test.c
src/testbed/testbed_api_topology.c
src/testbed/testbed_api_underlay.c
src/testing/gnunet-cmds-helper.c
src/testing/gnunet-testing.c
src/testing/list-keys.c
-src/testing/testing.c
src/testing/testing_api_cmd_batch.c
src/testing/testing_api_cmd_block_until_external_trigger.c
src/testing/testing_api_cmd_end.c
@@ -440,51 +439,41 @@ src/testing/testing_api_cmd_system_create.c
src/testing/testing_api_cmd_system_destroy.c
src/testing/testing_api_loop.c
src/testing/testing_api_traits.c
+src/testing/testing.c
src/topology/friends.c
src/topology/gnunet-daemon-topology.c
src/transport/gnunet-communicator-tcp.c
src/transport/gnunet-communicator-udp.c
src/transport/gnunet-communicator-unix.c
src/transport/gnunet-helper-transport-bluetooth.c
-src/transport/gnunet-helper-transport-wlan-dummy.c
src/transport/gnunet-helper-transport-wlan.c
+src/transport/gnunet-helper-transport-wlan-dummy.c
src/transport/gnunet-service-tng.c
-src/transport/gnunet-service-transport.c
src/transport/gnunet-service-transport_ats.c
+src/transport/gnunet-service-transport.c
src/transport/gnunet-service-transport_hello.c
src/transport/gnunet-service-transport_manipulation.c
src/transport/gnunet-service-transport_neighbours.c
src/transport/gnunet-service-transport_plugins.c
src/transport/gnunet-service-transport_validation.c
+src/transport/gnunet-transport.c
src/transport/gnunet-transport-profiler.c
src/transport/gnunet-transport-wlan-receiver.c
src/transport/gnunet-transport-wlan-sender.c
-src/transport/gnunet-transport.c
src/transport/plugin_transport_http_client.c
src/transport/plugin_transport_http_common.c
src/transport/plugin_transport_http_server.c
src/transport/plugin_transport_smtp.c
src/transport/plugin_transport_tcp.c
src/transport/plugin_transport_template.c
-src/transport/plugin_transport_udp.c
src/transport/plugin_transport_udp_broadcasting.c
+src/transport/plugin_transport_udp.c
src/transport/plugin_transport_unix.c
src/transport/plugin_transport_wlan.c
src/transport/tcp_connection_legacy.c
src/transport/tcp_server_legacy.c
src/transport/tcp_server_mst_legacy.c
src/transport/tcp_service_legacy.c
-src/transport/transport-testing-communicator.c
-src/transport/transport-testing-filenames.c
-src/transport/transport-testing-filenames2.c
-src/transport/transport-testing-loggers.c
-src/transport/transport-testing-loggers2.c
-src/transport/transport-testing-main.c
-src/transport/transport-testing-main2.c
-src/transport/transport-testing-send.c
-src/transport/transport-testing-send2.c
-src/transport/transport-testing.c
-src/transport/transport-testing2.c
src/transport/transport_api2_application.c
src/transport/transport_api2_communication.c
src/transport/transport_api2_core.c
@@ -503,6 +492,17 @@ src/transport/transport_api_monitor_peers.c
src/transport/transport_api_monitor_plugins.c
src/transport/transport_api_offer_hello.c
src/transport/transport_api_traits.c
+src/transport/transport-testing2.c
+src/transport/transport-testing.c
+src/transport/transport-testing-communicator.c
+src/transport/transport-testing-filenames2.c
+src/transport/transport-testing-filenames.c
+src/transport/transport-testing-loggers2.c
+src/transport/transport-testing-loggers.c
+src/transport/transport-testing-main2.c
+src/transport/transport-testing-main.c
+src/transport/transport-testing-send2.c
+src/transport/transport-testing-send.c
src/util/bandwidth.c
src/util/benchmark.c
src/util/bio.c
@@ -518,8 +518,8 @@ src/util/consttime_memcmp.c
src/util/container_bloomfilter.c
src/util/container_heap.c
src/util/container_meta_data.c
-src/util/container_multihashmap.c
src/util/container_multihashmap32.c
+src/util/container_multihashmap.c
src/util/container_multipeermap.c
src/util/container_multishortmap.c
src/util/container_multiuuidmap.c
@@ -546,8 +546,8 @@ src/util/dnsstub.c
src/util/getopt.c
src/util/getopt_helpers.c
src/util/gnunet-base32.c
-src/util/gnunet-config-diff.c
src/util/gnunet-config.c
+src/util/gnunet-config-diff.c
src/util/gnunet-crypto-tvg.c
src/util/gnunet-ecc.c
src/util/gnunet-qr.c
@@ -585,8 +585,8 @@ src/vpn/gnunet-helper-vpn.c
src/vpn/gnunet-service-vpn.c
src/vpn/gnunet-vpn.c
src/vpn/vpn_api.c
-src/zonemaster/gnunet-service-zonemaster-monitor.c
src/zonemaster/gnunet-service-zonemaster.c
+src/zonemaster/gnunet-service-zonemaster-monitor.c
src/fs/fs_api.h
src/include/gnunet_json_lib.h
src/testbed/testbed_api.h
diff --git a/src/block/block.c b/src/block/block.c
index 5824946f7..2e3c1dc70 100644
--- a/src/block/block.c
+++ b/src/block/block.c
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- Copyright (C) 2010, 2017, 2021 GNUnet e.V.
+ Copyright (C) 2010, 2017, 2021, 2022 GNUnet e.V.
GNUnet is free software: you can redistribute it and/or modify it
under the terms of the GNU Affero General Public License as published
@@ -255,35 +255,6 @@ GNUNET_BLOCK_group_create (struct GNUNET_BLOCK_Context *ctx,
}
-enum GNUNET_BLOCK_EvaluationResult
-GNUNET_BLOCK_evaluate (struct GNUNET_BLOCK_Context *ctx,
- enum GNUNET_BLOCK_Type type,
- struct GNUNET_BLOCK_Group *group,
- enum GNUNET_BLOCK_EvaluationOptions eo,
- const struct GNUNET_HashCode *query,
- const void *xquery,
- size_t xquery_size,
- const void *reply_block,
- size_t reply_block_size)
-{
- struct GNUNET_BLOCK_PluginFunctions *plugin = find_plugin (ctx,
- type);
-
- if (NULL == plugin)
- return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED;
- return plugin->evaluate (plugin->cls,
- ctx,
- type,
- group,
- eo,
- query,
- xquery,
- xquery_size,
- reply_block,
- reply_block_size);
-}
-
-
enum GNUNET_GenericReturnValue
GNUNET_BLOCK_get_key (struct GNUNET_BLOCK_Context *ctx,
enum GNUNET_BLOCK_Type type,
@@ -327,7 +298,6 @@ GNUNET_BLOCK_check_query (struct GNUNET_BLOCK_Context *ctx,
enum GNUNET_GenericReturnValue
GNUNET_BLOCK_check_block (struct GNUNET_BLOCK_Context *ctx,
enum GNUNET_BLOCK_Type type,
- const struct GNUNET_HashCode *query,
const void *block,
size_t block_size)
{
@@ -338,7 +308,6 @@ GNUNET_BLOCK_check_block (struct GNUNET_BLOCK_Context *ctx,
return GNUNET_SYSERR;
return plugin->check_block (plugin->cls,
type,
- query,
block,
block_size);
}
diff --git a/src/block/plugin_block_template.c b/src/block/plugin_block_template.c
index 13d9adfda..dcaf1afaa 100644
--- a/src/block/plugin_block_template.c
+++ b/src/block/plugin_block_template.c
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet
- Copyright (C) 2010 GNUnet e.V.
+ Copyright (C) 2010, 2021, 2022 GNUnet e.V.
GNUnet is free software: you can redistribute it and/or modify it
under the terms of the GNU Affero General Public License as published
@@ -92,49 +92,6 @@ block_plugin_template_create_group (void *cls,
/**
- * Function called to validate a reply or a request. For
- * request evaluation, simply pass "NULL" for the reply_block.
- *
- * @param cls closure
- * @param ctx context
- * @param type block type
- * @param group block group to use
- * @param eo control flags
- * @param query original query (hash)
- * @param xquery extrended query data (can be NULL, depending on type)
- * @param xquery_size number of bytes in xquery
- * @param reply_block response to validate
- * @param reply_block_size number of bytes in reply block
- * @return characterization of result
- */
-static enum GNUNET_BLOCK_EvaluationResult
-block_plugin_template_evaluate (void *cls,
- struct GNUNET_BLOCK_Context *ctx,
- enum GNUNET_BLOCK_Type type,
- struct GNUNET_BLOCK_Group *group,
- enum GNUNET_BLOCK_EvaluationOptions eo,
- const struct GNUNET_HashCode *query,
- const void *xquery,
- size_t xquery_size,
- const void *reply_block,
- size_t reply_block_size)
-{
- struct GNUNET_HashCode chash;
-
- if (NULL == reply_block)
- return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
- GNUNET_CRYPTO_hash (reply_block,
- reply_block_size,
- &chash);
- if (GNUNET_YES ==
- GNUNET_BLOCK_GROUP_bf_test_and_set (group,
- &chash))
- return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE;
- return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED;
-}
-
-
-/**
* Function called to validate a query.
*
* @param cls closure
@@ -143,16 +100,16 @@ block_plugin_template_evaluate (void *cls,
* @param query original query (hash)
* @param xquery extrended query data (can be NULL, depending on type)
* @param xquery_size number of bytes in @a xquery
- * @return #GNUNET_OK if the query is fine, #GNUNET_NO if not
+ * @return #GNUNET_OK if the query is fine, #GNUNET_NO if not, #GNUNET_SYSERR if not supported
*/
static enum GNUNET_GenericReturnValue
block_plugin_template_check_query (void *cls,
- enum GNUNET_BLOCK_Type type,
- const struct GNUNET_HashCode *query,
- const void *xquery,
- size_t xquery_size)
+ enum GNUNET_BLOCK_Type type,
+ const struct GNUNET_HashCode *query,
+ const void *xquery,
+ size_t xquery_size)
{
- return GNUNET_OK;
+ return GNUNET_SYSERR;
}
@@ -161,19 +118,17 @@ block_plugin_template_check_query (void *cls,
*
* @param cls closure
* @param type block type
- * @param query key for the block (hash), must match exactly
* @param block block data to validate
* @param block_size number of bytes in @a block
- * @return #GNUNET_OK if the block is fine, #GNUNET_NO if not
+ * @return #GNUNET_OK if the block is fine, #GNUNET_NO if not, #GNUNET_SYSERR if not supported
*/
static enum GNUNET_GenericReturnValue
block_plugin_template_check_block (void *cls,
enum GNUNET_BLOCK_Type type,
- const struct GNUNET_HashCode *query,
const void *block,
size_t block_size)
{
- return GNUNET_OK;
+ return GNUNET_SYSERR;
}
@@ -195,16 +150,16 @@ block_plugin_template_check_block (void *cls,
*/
static enum GNUNET_BLOCK_ReplyEvaluationResult
block_plugin_template_check_reply (
- void *cls,
- enum GNUNET_BLOCK_Type type,
- struct GNUNET_BLOCK_Group *group,
- const struct GNUNET_HashCode *query,
- const void *xquery,
- size_t xquery_size,
- const void *reply_block,
- size_t reply_block_size)
+ void *cls,
+ enum GNUNET_BLOCK_Type type,
+ struct GNUNET_BLOCK_Group *group,
+ const struct GNUNET_HashCode *query,
+ const void *xquery,
+ size_t xquery_size,
+ const void *reply_block,
+ size_t reply_block_size)
{
- return GNUNET_BLOCK_REPLY_OK_MORE;
+ return GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED;
}
@@ -245,7 +200,6 @@ libgnunet_plugin_block_template_init (void *cls)
struct GNUNET_BLOCK_PluginFunctions *api;
api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions);
- api->evaluate = &block_plugin_template_evaluate;
api->get_key = &block_plugin_template_get_key;
api->check_query = &block_plugin_template_check_query;
api->check_block = &block_plugin_template_check_block;
diff --git a/src/block/plugin_block_test.c b/src/block/plugin_block_test.c
index fd643c4dc..05d379387 100644
--- a/src/block/plugin_block_test.c
+++ b/src/block/plugin_block_test.c
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet
- Copyright (C) 2010 GNUnet e.V.
+ Copyright (C) 2010, 2021, 2022 GNUnet e.V.
GNUnet is free software: you can redistribute it and/or modify it
under the terms of the GNU Affero General Public License as published
@@ -90,59 +90,6 @@ block_plugin_test_create_group (void *cls,
/**
- * Function called to validate a reply or a request. For
- * request evaluation, simply pass "NULL" for the reply_block.
- *
- * @param cls closure
- * @param ctx block context
- * @param type block type
- * @param group group to check against
- * @param eo control flags
- * @param query original query (hash)
- * @param xquery extrended query data (can be NULL, depending on type)
- * @param xquery_size number of bytes in @a xquery
- * @param reply_block response to validate
- * @param reply_block_size number of bytes in @a reply_block
- * @return characterization of result
- */
-static enum GNUNET_BLOCK_EvaluationResult
-block_plugin_test_evaluate (void *cls,
- struct GNUNET_BLOCK_Context *ctx,
- enum GNUNET_BLOCK_Type type,
- struct GNUNET_BLOCK_Group *group,
- enum GNUNET_BLOCK_EvaluationOptions eo,
- const struct GNUNET_HashCode *query,
- const void *xquery,
- size_t xquery_size,
- const void *reply_block,
- size_t reply_block_size)
-{
- struct GNUNET_HashCode chash;
-
- if (GNUNET_BLOCK_TYPE_TEST != type)
- {
- GNUNET_break (0);
- return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED;
- }
- if (0 != xquery_size)
- {
- GNUNET_break_op (0);
- return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID;
- }
- if (NULL == reply_block)
- return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
- GNUNET_CRYPTO_hash (reply_block,
- reply_block_size,
- &chash);
- if (GNUNET_YES ==
- GNUNET_BLOCK_GROUP_bf_test_and_set (group,
- &chash))
- return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE;
- return GNUNET_BLOCK_EVALUATION_OK_MORE;
-}
-
-
-/**
* Function called to validate a query.
*
* @param cls closure
@@ -151,15 +98,18 @@ block_plugin_test_evaluate (void *cls,
* @param query original query (hash)
* @param xquery extrended query data (can be NULL, depending on type)
* @param xquery_size number of bytes in @a xquery
- * @return #GNUNET_OK if the query is fine, #GNUNET_NO if not
+ * @return #GNUNET_OK if the query is fine, #GNUNET_NO if not, #GNUNET_SYSERR if @a type is not supported
*/
static enum GNUNET_GenericReturnValue
block_plugin_test_check_query (void *cls,
- enum GNUNET_BLOCK_Type type,
- const struct GNUNET_HashCode *query,
- const void *xquery,
- size_t xquery_size)
+ enum GNUNET_BLOCK_Type type,
+ const struct GNUNET_HashCode *query,
+ const void *xquery,
+ size_t xquery_size)
{
+ (void) cls;
+ (void) query;
+ (void) xquery;
if (GNUNET_BLOCK_TYPE_TEST != type)
{
GNUNET_break (0);
@@ -168,9 +118,9 @@ block_plugin_test_check_query (void *cls,
if (0 != xquery_size)
{
GNUNET_break_op (0);
- return GNUNET_SYSERR;
+ return GNUNET_NO;
}
- return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
+ return GNUNET_OK;
}
@@ -179,18 +129,19 @@ block_plugin_test_check_query (void *cls,
*
* @param cls closure
* @param type block type
- * @param query key for the block (hash), must match exactly
* @param block block data to validate
* @param block_size number of bytes in @a block
- * @return #GNUNET_OK if the block is fine, #GNUNET_NO if not
+ * @return #GNUNET_OK if the block is fine, #GNUNET_NO if not, #GNUNET_SYSERR if @a type is not supported
*/
static enum GNUNET_GenericReturnValue
block_plugin_test_check_block (void *cls,
- enum GNUNET_BLOCK_Type type,
- const struct GNUNET_HashCode *query,
- const void *block,
- size_t block_size)
+ enum GNUNET_BLOCK_Type type,
+ const void *block,
+ size_t block_size)
{
+ (void) cls;
+ (void) block;
+ (void) block_size;
if (GNUNET_BLOCK_TYPE_TEST != type)
{
GNUNET_break (0);
@@ -218,16 +169,20 @@ block_plugin_test_check_block (void *cls,
*/
static enum GNUNET_BLOCK_ReplyEvaluationResult
block_plugin_test_check_reply (void *cls,
- enum GNUNET_BLOCK_Type type,
- struct GNUNET_BLOCK_Group *group,
- const struct GNUNET_HashCode *query,
- const void *xquery,
- size_t xquery_size,
- const void *reply_block,
- size_t reply_block_size)
+ enum GNUNET_BLOCK_Type type,
+ struct GNUNET_BLOCK_Group *group,
+ const struct GNUNET_HashCode *query,
+ const void *xquery,
+ size_t xquery_size,
+ const void *reply_block,
+ size_t reply_block_size)
{
struct GNUNET_HashCode chash;
+ (void) cls;
+ (void) query;
+ (void) xquery;
+ (void) xquery_size;
if (GNUNET_BLOCK_TYPE_TEST != type)
{
GNUNET_break (0);
@@ -252,8 +207,7 @@ block_plugin_test_check_reply (void *cls,
* @param block block to get the key for
* @param block_size number of bytes in @a block
* @param key set to the key (query) for the given block
- * @return #GNUNET_OK on success, #GNUNET_SYSERR if type not supported
- * (or if extracting a key from a block of this type does not work)
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR if type not supported, #GNUNET_NO if extracting a key from a block of this type does not work
*/
static enum GNUNET_GenericReturnValue
block_plugin_test_get_key (void *cls,
@@ -262,9 +216,16 @@ block_plugin_test_get_key (void *cls,
size_t block_size,
struct GNUNET_HashCode *key)
{
- /* always fails since there is no fixed relationship between
- * keys and values for test values */
- return GNUNET_SYSERR;
+ (void) cls;
+ (void) block;
+ (void) block_size;
+ (void) key;
+ if (GNUNET_BLOCK_TYPE_TEST != type)
+ {
+ GNUNET_break (0);
+ return GNUNET_SYSERR;
+ }
+ return GNUNET_NO;
}
@@ -284,7 +245,6 @@ libgnunet_plugin_block_test_init (void *cls)
struct GNUNET_BLOCK_PluginFunctions *api;
api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions);
- api->evaluate = &block_plugin_test_evaluate;
api->get_key = &block_plugin_test_get_key;
api->check_query = &block_plugin_test_check_query;
api->check_block = &block_plugin_test_check_block;
diff --git a/src/consensus/plugin_block_consensus.c b/src/consensus/plugin_block_consensus.c
index 430a2c0cb..f30b9b0d7 100644
--- a/src/consensus/plugin_block_consensus.c
+++ b/src/consensus/plugin_block_consensus.c
@@ -47,57 +47,6 @@ struct BlockContext
};
-/**
- * Function called to validate a reply or a request. For
- * request evaluation, simply pass "NULL" for the reply_block.
- *
- * @param cls closure
- * @param ctx context
- * @param type block type
- * @param group block group to use
- * @param eo control flags
- * @param query original query (hash)
- * @param xquery extrended query data (can be NULL, depending on type)
- * @param xquery_size number of bytes in xquery
- * @param reply_block response to validate
- * @param reply_block_size number of bytes in reply block
- * @return characterization of result
- */
-static enum GNUNET_BLOCK_EvaluationResult
-block_plugin_consensus_evaluate (void *cls,
- struct GNUNET_BLOCK_Context *ctx,
- enum GNUNET_BLOCK_Type type,
- struct GNUNET_BLOCK_Group *group,
- enum GNUNET_BLOCK_EvaluationOptions eo,
- const struct GNUNET_HashCode *query,
- const void *xquery,
- size_t xquery_size,
- const void *reply_block,
- size_t reply_block_size)
-{
- struct BlockContext *bctx = cls;
- const struct ConsensusElement *ce = reply_block;
-
- if (reply_block_size < sizeof(struct ConsensusElement))
- return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
- if ( (0 != ce->marker) ||
- (0 == ce->payload_type) )
- return GNUNET_BLOCK_EVALUATION_OK_MORE;
-
- if (NULL == bctx->bc)
- bctx->bc = GNUNET_BLOCK_context_create (bctx->cfg);
- return GNUNET_BLOCK_evaluate (bctx->bc,
- type,
- group,
- eo,
- query,
- xquery,
- xquery_size,
- &ce[1],
- reply_block_size
- - sizeof(struct ConsensusElement));
-}
-
/**
* Function called to validate a query.
@@ -128,7 +77,6 @@ block_plugin_consensus_check_query (void *cls,
*
* @param cls closure
* @param type block type
- * @param query key for the block (hash), must match exactly
* @param block block data to validate
* @param block_size number of bytes in @a block
* @return #GNUNET_OK if the block is fine, #GNUNET_NO if not
@@ -136,7 +84,6 @@ block_plugin_consensus_check_query (void *cls,
static enum GNUNET_GenericReturnValue
block_plugin_consensus_check_block (void *cls,
enum GNUNET_BLOCK_Type type,
- const struct GNUNET_HashCode *query,
const void *block,
size_t block_size)
{
@@ -144,7 +91,10 @@ block_plugin_consensus_check_block (void *cls,
const struct ConsensusElement *ce = block;
if (block_size < sizeof(*ce))
+ {
+ GNUNET_break_op (0);
return GNUNET_NO;
+ }
if ( (0 != ce->marker) ||
(0 == ce->payload_type) )
return GNUNET_OK;
@@ -152,7 +102,6 @@ block_plugin_consensus_check_block (void *cls,
ctx->bc = GNUNET_BLOCK_context_create (ctx->cfg);
return GNUNET_BLOCK_check_block (ctx->bc,
ntohl (ce->payload_type),
- query,
&ce[1],
block_size - sizeof(*ce));
}
@@ -188,8 +137,7 @@ block_plugin_consensus_check_reply (
struct BlockContext *ctx = cls;
const struct ConsensusElement *ce = reply_block;
- if (reply_block_size < sizeof(struct ConsensusElement))
- return GNUNET_NO;
+ GNUNET_assert (reply_block_size >= sizeof(struct ConsensusElement));
if ( (0 != ce->marker) ||
(0 == ce->payload_type) )
return GNUNET_BLOCK_REPLY_OK_MORE;
@@ -246,7 +194,6 @@ libgnunet_plugin_block_consensus_init (void *cls)
ctx->cfg = cfg;
api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions);
api->cls = ctx;
- api->evaluate = &block_plugin_consensus_evaluate;
api->get_key = &block_plugin_consensus_get_key;
api->check_query = &block_plugin_consensus_check_query;
api->check_block = &block_plugin_consensus_check_block;
diff --git a/src/dht/gnunet-service-dht_clients.c b/src/dht/gnunet-service-dht_clients.c
index 5735b2420..c50406ada 100644
--- a/src/dht/gnunet-service-dht_clients.c
+++ b/src/dht/gnunet-service-dht_clients.c
@@ -982,9 +982,6 @@ forward_reply (void *cls,
/* should be impossible to encounter here */
GNUNET_break (0);
return GNUNET_YES;
- case GNUNET_BLOCK_REPLY_INVALID:
- GNUNET_break_op (0);
- return GNUNET_NO;
case GNUNET_BLOCK_REPLY_IRRELEVANT:
return GNUNET_YES;
default:
diff --git a/src/dht/gnunet-service-dht_datacache.c b/src/dht/gnunet-service-dht_datacache.c
index 91bdfe3da..be0a6db81 100644
--- a/src/dht/gnunet-service-dht_datacache.c
+++ b/src/dht/gnunet-service-dht_datacache.c
@@ -126,7 +126,7 @@ struct GetRequestContext
/**
* Return value to give back.
*/
- enum GNUNET_BLOCK_EvaluationResult eval;
+ enum GNUNET_BLOCK_ReplyEvaluationResult eval;
};
@@ -204,13 +204,6 @@ datacache_get_iterator (void *cls,
1,
GNUNET_NO);
break;
- case GNUNET_BLOCK_REPLY_INVALID:
- /* maybe it expired? */
- GNUNET_STATISTICS_update (GDS_stats,
- "# Invalid RESULTS found in datacache",
- 1,
- GNUNET_NO);
- break;
case GNUNET_BLOCK_REPLY_IRRELEVANT:
GNUNET_STATISTICS_update (GDS_stats,
"# Irrelevant RESULTS found in datacache",
@@ -222,7 +215,7 @@ datacache_get_iterator (void *cls,
}
-enum GNUNET_BLOCK_EvaluationResult
+enum GNUNET_BLOCK_ReplyEvaluationResult
GDS_DATACACHE_handle_get (const struct GNUNET_HashCode *key,
enum GNUNET_BLOCK_Type type,
const void *xquery,
@@ -232,7 +225,7 @@ GDS_DATACACHE_handle_get (const struct GNUNET_HashCode *key,
void *gc_cls)
{
struct GetRequestContext ctx = {
- .eval = GNUNET_BLOCK_EVALUATION_REQUEST_VALID,
+ .eval = GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED,
.key = *key,
.xquery = xquery,
.xquery_size = xquery_size,
@@ -243,7 +236,7 @@ GDS_DATACACHE_handle_get (const struct GNUNET_HashCode *key,
unsigned int r;
if (NULL == datacache)
- return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
+ return GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED;
GNUNET_STATISTICS_update (GDS_stats,
"# GET requests given to datacache",
1,
@@ -262,7 +255,7 @@ GDS_DATACACHE_handle_get (const struct GNUNET_HashCode *key,
}
-enum GNUNET_BLOCK_EvaluationResult
+enum GNUNET_BLOCK_ReplyEvaluationResult
GDS_DATACACHE_get_closest (const struct GNUNET_HashCode *key,
enum GNUNET_BLOCK_Type type,
const void *xquery,
@@ -272,7 +265,7 @@ GDS_DATACACHE_get_closest (const struct GNUNET_HashCode *key,
void *cb_cls)
{
struct GetRequestContext ctx = {
- .eval = GNUNET_BLOCK_EVALUATION_REQUEST_VALID,
+ .eval = GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED,
.key = *key,
.xquery = xquery,
.xquery_size = xquery_size,
@@ -283,7 +276,7 @@ GDS_DATACACHE_get_closest (const struct GNUNET_HashCode *key,
unsigned int r;
if (NULL == datacache)
- return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
+ return GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED;
GNUNET_STATISTICS_update (GDS_stats,
"# GET closest requests given to datacache",
1,
diff --git a/src/dht/gnunet-service-dht_datacache.h b/src/dht/gnunet-service-dht_datacache.h
index 69a18c605..d860139f5 100644
--- a/src/dht/gnunet-service-dht_datacache.h
+++ b/src/dht/gnunet-service-dht_datacache.h
@@ -107,7 +107,7 @@ typedef void
* @param gc_cls closure for @a gc
* @return evaluation result for the local replies
*/
-enum GNUNET_BLOCK_EvaluationResult
+enum GNUNET_BLOCK_ReplyEvaluationResult
GDS_DATACACHE_handle_get (const struct GNUNET_HashCode *key,
enum GNUNET_BLOCK_Type type,
const void *xquery,
@@ -130,7 +130,7 @@ GDS_DATACACHE_handle_get (const struct GNUNET_HashCode *key,
* @param cb_cls closure for @a cb
* @return evaluation result for the local replies
*/
-enum GNUNET_BLOCK_EvaluationResult
+enum GNUNET_BLOCK_ReplyEvaluationResult
GDS_DATACACHE_get_closest (const struct GNUNET_HashCode *key,
enum GNUNET_BLOCK_Type type,
const void *xquery,
diff --git a/src/dht/gnunet-service-dht_neighbours.c b/src/dht/gnunet-service-dht_neighbours.c
index db4ecb34a..7e570d4f5 100644
--- a/src/dht/gnunet-service-dht_neighbours.c
+++ b/src/dht/gnunet-service-dht_neighbours.c
@@ -1821,6 +1821,16 @@ handle_dht_p2p_put (void *cls,
GNUNET_NO);
return;
}
+ if (GNUNET_NO ==
+ GNUNET_BLOCK_check_block (GDS_block_context,
+ bd.type,
+ bd.data,
+ bd.data_size))
+ {
+ GNUNET_break_op (0);
+ return;
+ }
+
GNUNET_STATISTICS_update (GDS_stats,
"# P2P PUT requests received",
1,
@@ -1857,17 +1867,6 @@ handle_dht_p2p_put (void *cls,
}
}
- if (GNUNET_NO ==
- GNUNET_BLOCK_check_block (GDS_block_context,
- bd.type,
- &bd.key,
- bd.data,
- bd.data_size))
- {
- GNUNET_break_op (0);
- return;
- }
-
{
struct GNUNET_CONTAINER_BloomFilter *bf;
struct GNUNET_DHT_PathElement pp[putlen + 1];
@@ -2465,6 +2464,15 @@ handle_dht_p2p_result (void *cls,
bd.data_size = msize - (sizeof(struct PeerResultMessage)
+ (get_path_length + bd.put_path_length)
* sizeof(struct GNUNET_DHT_PathElement));
+ if (GNUNET_OK !=
+ GNUNET_BLOCK_check_block (GDS_block_context,
+ bd.type,
+ bd.data,
+ bd.data_size))
+ {
+ GNUNET_break_op (0);
+ return;
+ }
GNUNET_STATISTICS_update (GDS_stats,
"# P2P RESULTS received",
1,
@@ -2475,7 +2483,6 @@ handle_dht_p2p_result (void *cls,
GNUNET_NO);
{
enum GNUNET_GenericReturnValue ret;
- const struct GNUNET_HashCode *pquery;
ret = GNUNET_BLOCK_get_key (GDS_block_context,
bd.type,
@@ -2484,18 +2491,7 @@ handle_dht_p2p_result (void *cls,
&bd.key);
if (GNUNET_NO == ret)
{
- GNUNET_break_op (0);
- return;
- }
- pquery = (GNUNET_OK == ret) ? &bd.key : &prm->key;
- if (GNUNET_OK !=
- GNUNET_BLOCK_check_block (GDS_block_context,
- bd.type,
- pquery,
- bd.data,
- bd.data_size))
- {
- GNUNET_break_op (0);
+ bd.key = prm->key;
return;
}
}
diff --git a/src/dht/gnunet-service-dht_routing.c b/src/dht/gnunet-service-dht_routing.c
index da9919e82..05902b941 100644
--- a/src/dht/gnunet-service-dht_routing.c
+++ b/src/dht/gnunet-service-dht_routing.c
@@ -208,13 +208,6 @@ process (void *cls,
1,
GNUNET_NO);
return GNUNET_OK;
- case GNUNET_BLOCK_REPLY_INVALID:
- GNUNET_break (0);
- GNUNET_STATISTICS_update (GDS_stats,
- "# Invalid REPLIES matched against routing table",
- 1,
- GNUNET_NO);
- return GNUNET_OK;
case GNUNET_BLOCK_REPLY_IRRELEVANT:
GNUNET_STATISTICS_update (GDS_stats,
"# Irrelevant REPLIES matched against routing table",
diff --git a/src/dht/plugin_block_dht.c b/src/dht/plugin_block_dht.c
index 0dbe21af9..9ff67fa4e 100644
--- a/src/dht/plugin_block_dht.c
+++ b/src/dht/plugin_block_dht.c
@@ -90,88 +90,9 @@ block_plugin_dht_create_group (void *cls,
/**
- * Function called to validate a reply or a request. For
- * request evaluation, simply pass "NULL" for the @a reply_block.
- *
- * @param cls closure
- * @param ctx context
- * @param type block type
- * @param group block group to check against
- * @param eo control flags
- * @param query original query (hash)
- * @param xquery extended query data (can be NULL, depending on type)
- * @param xquery_size number of bytes in @a xquery
- * @param reply_block response to validate
- * @param reply_block_size number of bytes in @a reply_block
- * @return characterization of result
- */
-static enum GNUNET_BLOCK_EvaluationResult
-block_plugin_dht_evaluate (void *cls,
- struct GNUNET_BLOCK_Context *ctx,
- enum GNUNET_BLOCK_Type type,
- struct GNUNET_BLOCK_Group *group,
- enum GNUNET_BLOCK_EvaluationOptions eo,
- const struct GNUNET_HashCode *query,
- const void *xquery,
- size_t xquery_size,
- const void *reply_block,
- size_t reply_block_size)
-{
- switch (type)
- {
- case GNUNET_BLOCK_TYPE_DHT_HELLO:
- {
- const struct GNUNET_HELLO_Message *hello;
- struct GNUNET_PeerIdentity pid;
- const struct GNUNET_MessageHeader *msg;
- struct GNUNET_HashCode phash;
-
- 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 (reply_block_size < sizeof(struct GNUNET_MessageHeader))
- {
- GNUNET_break_op (0);
- return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
- }
- msg = reply_block;
- if (reply_block_size != ntohs (msg->size))
- {
- GNUNET_break_op (0);
- return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
- }
- hello = reply_block;
- if (GNUNET_OK != GNUNET_HELLO_get_id (hello, &pid))
- {
- GNUNET_break_op (0);
- return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
- }
- GNUNET_CRYPTO_hash (&pid,
- sizeof(pid),
- &phash);
- if (GNUNET_YES ==
- GNUNET_BLOCK_GROUP_bf_test_and_set (group,
- &phash))
- return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE;
- return GNUNET_BLOCK_EVALUATION_OK_MORE;
- }
- case GNUNET_BLOCK_TYPE_DHT_URL_HELLO:
- GNUNET_break (0); // legacy API not implemented
- default:
- return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED;
- }
-}
-
-
-/**
* Function called to validate a query.
*
* @param cls closure
- * @param ctx block context
* @param type block type
* @param query original query (hash)
* @param xquery extrended query data (can be NULL, depending on type)
@@ -202,6 +123,7 @@ block_plugin_dht_check_query (void *cls,
}
return GNUNET_OK;
default:
+ GNUNET_break (0);
return GNUNET_SYSERR;
}
}
@@ -212,7 +134,6 @@ block_plugin_dht_check_query (void *cls,
*
* @param cls closure
* @param type block type
- * @param query key for the block (hash), must match exactly
* @param block block data to validate
* @param block_size number of bytes in @a block
* @return #GNUNET_OK if the block is fine, #GNUNET_NO if not
@@ -220,7 +141,6 @@ block_plugin_dht_check_query (void *cls,
static enum GNUNET_GenericReturnValue
block_plugin_dht_check_block (void *cls,
enum GNUNET_BLOCK_Type type,
- const struct GNUNET_HashCode *query,
const void *block,
size_t block_size)
{
@@ -273,16 +193,10 @@ block_plugin_dht_check_block (void *cls,
sizeof (pid),
&h_pid);
GNUNET_HELLO_builder_free (b);
- if (0 !=
- GNUNET_memcmp (&h_pid,
- query))
- {
- GNUNET_break_op (0);
- return GNUNET_NO;
- }
return GNUNET_OK;
}
default:
+ GNUNET_break (0);
return GNUNET_SYSERR;
}
}
@@ -319,30 +233,16 @@ block_plugin_dht_check_reply (
{
case GNUNET_BLOCK_TYPE_DHT_HELLO:
{
- const struct GNUNET_HELLO_Message *hello;
+ const struct GNUNET_MessageHeader *msg = reply_block;
+ const struct GNUNET_HELLO_Message *hello = reply_block;
struct GNUNET_PeerIdentity pid;
- const struct GNUNET_MessageHeader *msg;
struct GNUNET_HashCode phash;
- if (reply_block_size < sizeof(struct GNUNET_MessageHeader))
- {
- GNUNET_break_op (0);
- return GNUNET_BLOCK_REPLY_INVALID;
- }
- msg = reply_block;
- if (reply_block_size != ntohs (msg->size))
- {
- GNUNET_break_op (0);
- return GNUNET_BLOCK_REPLY_INVALID;
- }
- hello = reply_block;
- if (GNUNET_OK !=
- GNUNET_HELLO_get_id (hello,
- &pid))
- {
- GNUNET_break_op (0);
- return GNUNET_BLOCK_REPLY_INVALID;
- }
+ GNUNET_assert (reply_block_size >= sizeof(struct GNUNET_MessageHeader));
+ GNUNET_assert (reply_block_size == ntohs (msg->size));
+ GNUNET_assert (GNUNET_OK !=
+ GNUNET_HELLO_get_id (hello,
+ &pid));
GNUNET_CRYPTO_hash (&pid,
sizeof(pid),
&phash);
@@ -399,31 +299,35 @@ block_plugin_dht_get_key (void *cls,
if (block_size < sizeof(struct GNUNET_MessageHeader))
{
- GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
- "block-dht",
- _ ("Block not of type %u\n"),
- GNUNET_BLOCK_TYPE_DHT_HELLO);
- return GNUNET_NO;
+ GNUNET_break_op (0);
+ memset (key,
+ 0,
+ sizeof (*key));
+ return GNUNET_OK;
}
msg = block;
if (block_size != ntohs (msg->size))
{
- GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
- "block-dht",
- _ ("Size mismatch for block with type %u\n"),
- GNUNET_BLOCK_TYPE_DHT_HELLO);
- return GNUNET_NO;
+ GNUNET_break_op (0);
+ memset (key,
+ 0,
+ sizeof (*key));
+ return GNUNET_OK;
}
hello = block;
- memset (key, 0, sizeof(*key));
+ memset (key,
+ 0,
+ sizeof(*key));
pid = (struct GNUNET_PeerIdentity *) key;
- if (GNUNET_OK != GNUNET_HELLO_get_id (hello, pid))
+ if (GNUNET_OK !=
+ GNUNET_HELLO_get_id (hello,
+ pid))
{
- GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
- "block-dht",
- _ ("Block of type %u is malformed\n"),
- GNUNET_BLOCK_TYPE_DHT_HELLO);
- return GNUNET_NO;
+ GNUNET_break_op (0);
+ memset (key,
+ 0,
+ sizeof (*key));
+ return GNUNET_OK;
}
return GNUNET_OK;
}
@@ -437,7 +341,10 @@ block_plugin_dht_get_key (void *cls,
if (NULL == b)
{
GNUNET_break (0);
- return GNUNET_NO;
+ memset (key,
+ 0,
+ sizeof (*key));
+ return GNUNET_OK;
}
GNUNET_HELLO_builder_iterate (b,
&pid,
@@ -449,6 +356,7 @@ block_plugin_dht_get_key (void *cls,
return GNUNET_OK;
}
default:
+ GNUNET_break (0);
return GNUNET_SYSERR;
}
}
@@ -468,7 +376,6 @@ libgnunet_plugin_block_dht_init (void *cls)
struct GNUNET_BLOCK_PluginFunctions *api;
api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions);
- api->evaluate = &block_plugin_dht_evaluate;
api->get_key = &block_plugin_dht_get_key;
api->check_query = &block_plugin_dht_check_query;
api->check_block = &block_plugin_dht_check_block;
diff --git a/src/dns/plugin_block_dns.c b/src/dns/plugin_block_dns.c
index d3eb7d2b9..a596beb28 100644
--- a/src/dns/plugin_block_dns.c
+++ b/src/dns/plugin_block_dns.c
@@ -90,93 +90,6 @@ block_plugin_dns_create_group (void *cls,
/**
- * Function called to validate a reply or a request. For
- * request evaluation, simply pass "NULL" for the reply_block.
- *
- * @param cls closure
- * @param ctx block context
- * @param type block type
- * @param bg group to evaluate against
- * @param eo control flags
- * @param query original query (hash)
- * @param xquery extended query data (can be NULL, depending on type)
- * @param xquery_size number of bytes in @a xquery
- * @param reply_block response to validate
- * @param reply_block_size number of bytes in @a reply_block
- * @return characterization of result
- */
-static enum GNUNET_BLOCK_EvaluationResult
-block_plugin_dns_evaluate (void *cls,
- struct GNUNET_BLOCK_Context *ctx,
- enum GNUNET_BLOCK_Type type,
- struct GNUNET_BLOCK_Group *bg,
- enum GNUNET_BLOCK_EvaluationOptions eo,
- const struct GNUNET_HashCode *query,
- const void *xquery,
- size_t xquery_size,
- const void *reply_block,
- size_t reply_block_size)
-{
- const struct GNUNET_DNS_Advertisement *ad;
- struct GNUNET_HashCode phash;
-
- switch (type)
- {
- case GNUNET_BLOCK_TYPE_DNS:
- if (0 != xquery_size)
- return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID;
-
- if (NULL == reply_block)
- return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
-
- if (sizeof(struct GNUNET_DNS_Advertisement) != reply_block_size)
- {
- GNUNET_break_op (0);
- return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
- }
- ad = reply_block;
-
- if (ntohl (ad->purpose.size) !=
- sizeof(struct GNUNET_DNS_Advertisement)
- - sizeof(struct GNUNET_CRYPTO_EddsaSignature))
- {
- GNUNET_break_op (0);
- return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
- }
- if (0 ==
- GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_ntoh
- (ad->expiration_time)).
- rel_value_us)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "DNS advertisement has expired\n");
- return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
- }
- if (GNUNET_OK !=
- GNUNET_CRYPTO_eddsa_verify_ (GNUNET_SIGNATURE_PURPOSE_DNS_RECORD,
- &ad->purpose,
- &ad->signature,
- &ad->peer.public_key))
- {
- GNUNET_break_op (0);
- return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
- }
- GNUNET_CRYPTO_hash (reply_block,
- reply_block_size,
- &phash);
- if (GNUNET_YES ==
- GNUNET_BLOCK_GROUP_bf_test_and_set (bg,
- &phash))
- return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE;
- return GNUNET_BLOCK_EVALUATION_OK_MORE;
-
- default:
- return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED;
- }
-}
-
-
-/**
* Function called to validate a query.
*
* @param cls closure
@@ -198,9 +111,13 @@ block_plugin_dns_check_query (void *cls,
{
case GNUNET_BLOCK_TYPE_DNS:
if (0 != xquery_size)
- return GNUNET_NO;
+ {
+ GNUNET_break_op (0);
+ return GNUNET_NO;
+ }
return GNUNET_OK;
default:
+ GNUNET_break (0);
return GNUNET_SYSERR;
}
}
@@ -211,17 +128,15 @@ block_plugin_dns_check_query (void *cls,
*
* @param cls closure
* @param type block type
- * @param query key for the block (hash), must match exactly
* @param block block data to validate
* @param block_size number of bytes in @a block
* @return #GNUNET_OK if the block is fine, #GNUNET_NO if not
*/
static enum GNUNET_GenericReturnValue
block_plugin_dns_check_block (void *cls,
- enum GNUNET_BLOCK_Type type,
- const struct GNUNET_HashCode *query,
- const void *block,
- size_t block_size)
+ enum GNUNET_BLOCK_Type type,
+ const void *block,
+ size_t block_size)
{
const struct GNUNET_DNS_Advertisement *ad;
@@ -260,6 +175,7 @@ block_plugin_dns_check_block (void *cls,
}
return GNUNET_OK;
default:
+ GNUNET_break (0);
return GNUNET_SYSERR;
}
}
@@ -283,14 +199,14 @@ block_plugin_dns_check_block (void *cls,
*/
static enum GNUNET_BLOCK_ReplyEvaluationResult
block_plugin_dns_check_reply (
- void *cls,
- enum GNUNET_BLOCK_Type type,
- struct GNUNET_BLOCK_Group *group,
- const struct GNUNET_HashCode *query,
- const void *xquery,
- size_t xquery_size,
- const void *reply_block,
- size_t reply_block_size)
+ void *cls,
+ enum GNUNET_BLOCK_Type type,
+ struct GNUNET_BLOCK_Group *group,
+ const struct GNUNET_HashCode *query,
+ const void *xquery,
+ size_t xquery_size,
+ const void *reply_block,
+ size_t reply_block_size)
{
struct GNUNET_HashCode phash;
@@ -306,6 +222,7 @@ block_plugin_dns_check_reply (
return GNUNET_BLOCK_REPLY_OK_DUPLICATE;
return GNUNET_BLOCK_REPLY_OK_MORE;
default:
+ GNUNET_break (0);
return GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED;
}
}
@@ -329,8 +246,12 @@ block_plugin_dns_get_key (void *cls,
size_t block_size,
struct GNUNET_HashCode *key)
{
- /* we cannot extract a key from a block of this type */
- return GNUNET_SYSERR;
+ if (GNUNET_BLOCK_TYPE_DNS != type)
+ {
+ GNUNET_break (0);
+ return GNUNET_SYSERR;
+ }
+ return GNUNET_NO;
}
@@ -347,7 +268,6 @@ libgnunet_plugin_block_dns_init (void *cls)
struct GNUNET_BLOCK_PluginFunctions *api;
api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions);
- api->evaluate = &block_plugin_dns_evaluate;
api->get_key = &block_plugin_dns_get_key;
api->check_query = &block_plugin_dns_check_query;
api->check_block = &block_plugin_dns_check_block;
diff --git a/src/fs/gnunet-service-fs_pr.c b/src/fs/gnunet-service-fs_pr.c
index beb29a506..154c454ca 100644
--- a/src/fs/gnunet-service-fs_pr.c
+++ b/src/fs/gnunet-service-fs_pr.c
@@ -247,7 +247,8 @@ static unsigned long long max_pending_requests = (32 * 1024);
* @param pr request for which the BF is to be recomputed
*/
static void
-refresh_bloomfilter (enum GNUNET_BLOCK_Type type, struct GSF_PendingRequest *pr)
+refresh_bloomfilter (enum GNUNET_BLOCK_Type type,
+ struct GSF_PendingRequest *pr)
{
if (NULL != pr->bg)
{
@@ -406,7 +407,7 @@ GSF_pending_request_create_ (enum GSF_PendingRequestOptions options,
break; /* let the request live briefly... */
if (NULL != dpr->rh)
dpr->rh (dpr->rh_cls,
- GNUNET_BLOCK_EVALUATION_REQUEST_VALID,
+ GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED,
dpr,
UINT32_MAX,
GNUNET_TIME_UNIT_FOREVER_ABS,
@@ -557,7 +558,10 @@ GSF_pending_request_get_message_ (struct GSF_PendingRequest *pr)
k++;
}
if (GNUNET_OK !=
- GNUNET_BLOCK_group_serialize (pr->bg, &bf_nonce, &bf_data, &bf_size))
+ GNUNET_BLOCK_group_serialize (pr->bg,
+ &bf_nonce,
+ &bf_data,
+ &bf_size))
{
bf_size = 0;
bf_data = NULL;
@@ -765,11 +769,6 @@ struct ProcessReplyClosure
enum GNUNET_BLOCK_Type type;
/**
- * Control flags for evaluation.
- */
- enum GNUNET_BLOCK_EvaluationOptions eo;
-
- /**
* How much was this reply worth to us?
*/
uint32_t priority;
@@ -850,7 +849,6 @@ process_reply (void *cls,
case GNUNET_BLOCK_REPLY_OK_MORE:
update_request_performance_data (prq, pr);
break;
-
case GNUNET_BLOCK_REPLY_OK_LAST:
/* short cut: stop processing early, no BF-update, etc. */
update_request_performance_data (prq, pr);
@@ -885,7 +883,6 @@ process_reply (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Duplicate response, discarding.\n");
return GNUNET_YES; /* duplicate */
-
case GNUNET_BLOCK_REPLY_IRRELEVANT:
GNUNET_STATISTICS_update (GSF_stats,
"# irrelevant replies discarded",
@@ -894,8 +891,6 @@ process_reply (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Irrelevant response, ignoring.\n");
return GNUNET_YES;
- case GNUNET_BLOCK_REPLY_INVALID:
- return GNUNET_YES;
case GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED:
GNUNET_break (0); /* bad installation? */
return GNUNET_NO;
@@ -1127,8 +1122,9 @@ handle_dht_reply (void *cls,
prq.expiration);
prq.size = size;
prq.type = type;
- prq.eo = GNUNET_BLOCK_EO_NONE;
- process_reply (&prq, key, pr);
+ process_reply (&prq,
+ key,
+ pr);
if ((GNUNET_YES == active_to_migration) &&
(GNUNET_NO == test_put_load_too_high (prq.priority)))
{
@@ -1229,6 +1225,15 @@ cadet_reply_proc (void *cls,
struct GNUNET_HashCode query;
pr->cadet_request = NULL;
+ if (GNUNET_OK !=
+ GNUNET_BLOCK_check_block (GSF_block_ctx,
+ type,
+ data,
+ data_size))
+ {
+ GNUNET_break_op (0);
+ return;
+ }
if (GNUNET_BLOCK_TYPE_ANY == type)
{
GNUNET_break (NULL == data);
@@ -1247,7 +1252,11 @@ cadet_reply_proc (void *cls,
return;
}
if (GNUNET_YES !=
- GNUNET_BLOCK_get_key (GSF_block_ctx, type, data, data_size, &query))
+ GNUNET_BLOCK_get_key (GSF_block_ctx,
+ type,
+ data,
+ data_size,
+ &query))
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Failed to derive key for block of type %d\n",
@@ -1268,8 +1277,9 @@ cadet_reply_proc (void *cls,
prq.expiration);
prq.size = data_size;
prq.type = type;
- prq.eo = GNUNET_BLOCK_EO_NONE;
- process_reply (&prq, &query, pr);
+ process_reply (&prq,
+ &query,
+ pr);
}
@@ -1611,7 +1621,11 @@ called_from_on_demand:
prq.expiration = expiration;
prq.size = size;
if (GNUNET_OK !=
- GNUNET_BLOCK_get_key (GSF_block_ctx, type, data, size, &query))
+ GNUNET_BLOCK_get_key (GSF_block_ctx,
+ type,
+ data,
+ size,
+ &query))
{
GNUNET_break (0);
GNUNET_DATASTORE_remove (GSF_dsh,
@@ -1631,8 +1645,9 @@ called_from_on_demand:
prq.anonymity_level = anonymity;
if ((0 == old_rf) && (0 == pr->public_data.results_found))
GSF_update_datastore_delay_ (pr->public_data.start_time);
- prq.eo = GNUNET_BLOCK_EO_LOCAL_SKIP_CRYPTO;
- process_reply (&prq, key, pr);
+ process_reply (&prq,
+ key,
+ pr);
pr->local_result = prq.eval;
if (GNUNET_BLOCK_REPLY_OK_LAST == prq.eval)
{
@@ -1720,7 +1735,8 @@ GSF_local_lookup_ (struct GSF_PendingRequest *pr,
* @param put the actual message
*/
void
-handle_p2p_put (void *cls, const struct PutMessage *put)
+handle_p2p_put (void *cls,
+ const struct PutMessage *put)
{
struct GSF_ConnectedPeer *cp = cls;
uint16_t msize;
@@ -1746,7 +1762,20 @@ handle_p2p_put (void *cls, const struct PutMessage *put)
GNUNET_TIME_UNIT_YEARS),
expiration);
if (GNUNET_OK !=
- GNUNET_BLOCK_get_key (GSF_block_ctx, type, &put[1], dsize, &query))
+ GNUNET_BLOCK_check_block (GSF_block_ctx,
+ type,
+ &put[1],
+ dsize))
+ {
+ GNUNET_break_op (0);
+ return;
+ }
+ if (GNUNET_OK !=
+ GNUNET_BLOCK_get_key (GSF_block_ctx,
+ type,
+ &put[1],
+ dsize,
+ &query))
{
GNUNET_break_op (0);
return;
@@ -1764,7 +1793,6 @@ handle_p2p_put (void *cls, const struct PutMessage *put)
prq.priority = 0;
prq.anonymity_level = UINT32_MAX;
prq.request_found = GNUNET_NO;
- prq.eo = GNUNET_BLOCK_EO_NONE;
GNUNET_CONTAINER_multihashmap_get_multiple (pr_map,
&query,
&process_reply,
diff --git a/src/fs/plugin_block_fs.c b/src/fs/plugin_block_fs.c
index 43380b3b6..029f95bc5 100644
--- a/src/fs/plugin_block_fs.c
+++ b/src/fs/plugin_block_fs.c
@@ -111,110 +111,6 @@ block_plugin_fs_create_group (void *cls,
/**
- * Function called to validate a reply or a request. For
- * request evaluation, simply pass "NULL" for the reply_block.
- * Note that it is assumed that the reply has already been
- * matched to the key (and signatures checked) as it would
- * be done with the #GNUNET_BLOCK_get_key() function.
- *
- * @param cls closure
- * @param ctx block context
- * @param type block type
- * @param bg group to use for evaluation
- * @param eo control flags
- * @param query original query (hash)
- * @param xquery extrended query data (can be NULL, depending on type)
- * @param xquery_size number of bytes in @a xquery
- * @param reply_block response to validate
- * @param reply_block_size number of bytes in @a reply_block
- * @return characterization of result
- */
-static enum GNUNET_BLOCK_EvaluationResult
-block_plugin_fs_evaluate (void *cls,
- struct GNUNET_BLOCK_Context *ctx,
- enum GNUNET_BLOCK_Type type,
- struct GNUNET_BLOCK_Group *bg,
- enum GNUNET_BLOCK_EvaluationOptions eo,
- const struct GNUNET_HashCode *query,
- const void *xquery,
- size_t xquery_size,
- const void *reply_block,
- size_t reply_block_size)
-{
- const struct UBlock *ub;
- struct GNUNET_HashCode hc;
- struct GNUNET_HashCode chash;
-
- switch (type)
- {
- case GNUNET_BLOCK_TYPE_FS_DBLOCK:
- case GNUNET_BLOCK_TYPE_FS_IBLOCK:
- if (0 != xquery_size)
- {
- GNUNET_break_op (0);
- return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID;
- }
- if (NULL == reply_block)
- return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
- return GNUNET_BLOCK_EVALUATION_OK_LAST;
-
- case GNUNET_BLOCK_TYPE_FS_UBLOCK:
- 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 (reply_block_size < sizeof(struct UBlock))
- {
- GNUNET_break_op (0);
- return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
- }
- ub = reply_block;
- GNUNET_CRYPTO_hash (&ub->verification_key,
- sizeof(ub->verification_key),
- &hc);
- if (0 != memcmp (&hc,
- query,
- sizeof(struct GNUNET_HashCode)))
- {
- GNUNET_break_op (0);
- return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
- }
- if (reply_block_size != ntohl (ub->purpose.size) + sizeof(struct
- GNUNET_CRYPTO_EcdsaSignature))
- {
- GNUNET_break_op (0);
- return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
- }
- if ((0 == (eo & GNUNET_BLOCK_EO_LOCAL_SKIP_CRYPTO)) &&
- (GNUNET_OK !=
- GNUNET_CRYPTO_ecdsa_verify_ (GNUNET_SIGNATURE_PURPOSE_FS_UBLOCK,
- &ub->purpose,
- &ub->signature,
- &ub->verification_key)))
- {
- GNUNET_break_op (0);
- return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
- }
- GNUNET_CRYPTO_hash (reply_block,
- reply_block_size,
- &chash);
- if (GNUNET_YES ==
- GNUNET_BLOCK_GROUP_bf_test_and_set (bg,
- &chash))
- return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE;
- return GNUNET_BLOCK_EVALUATION_OK_MORE;
-
- default:
- return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED;
- }
-}
-
-
-/**
* Function called to obtain the key for a block.
*
* @param cls closure
@@ -245,8 +141,11 @@ block_plugin_fs_get_key (void *cls,
case GNUNET_BLOCK_TYPE_FS_UBLOCK:
if (block_size < sizeof(struct UBlock))
{
- GNUNET_break (0);
- return GNUNET_SYSERR;
+ GNUNET_break_op (0);
+ memset (key,
+ 0,
+ sizeof (*key));
+ return GNUNET_OK;
}
ub = block;
GNUNET_CRYPTO_hash (&ub->verification_key,
@@ -290,6 +189,7 @@ block_plugin_fs_check_query (void *cls,
}
return GNUNET_OK;
default:
+ GNUNET_break (0);
return GNUNET_SYSERR;
}
}
@@ -300,7 +200,6 @@ block_plugin_fs_check_query (void *cls,
*
* @param cls closure
* @param type block type
- * @param query key for the block (hash), must match exactly
* @param block block data to validate
* @param block_size number of bytes in @a block
* @return #GNUNET_OK if the block is fine, #GNUNET_NO if not
@@ -308,7 +207,6 @@ block_plugin_fs_check_query (void *cls,
static enum GNUNET_GenericReturnValue
block_plugin_fs_check_block (void *cls,
enum GNUNET_BLOCK_Type type,
- const struct GNUNET_HashCode *query,
const void *block,
size_t block_size)
{
@@ -346,6 +244,7 @@ block_plugin_fs_check_block (void *cls,
return GNUNET_OK;
}
default:
+ GNUNET_break (0);
return GNUNET_SYSERR;
}
}
@@ -396,6 +295,7 @@ block_plugin_fs_check_reply (void *cls,
return GNUNET_BLOCK_REPLY_OK_MORE;
}
default:
+ GNUNET_break (0);
return GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED;
}
}
@@ -416,7 +316,6 @@ libgnunet_plugin_block_fs_init (void *cls)
struct GNUNET_BLOCK_PluginFunctions *api;
api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions);
- api->evaluate = &block_plugin_fs_evaluate;
api->get_key = &block_plugin_fs_get_key;
api->create_group = &block_plugin_fs_create_group;
api->check_query = &block_plugin_fs_check_query;
diff --git a/src/gns/plugin_block_gns.c b/src/gns/plugin_block_gns.c
index 407754a8c..fd9c99cb4 100644
--- a/src/gns/plugin_block_gns.c
+++ b/src/gns/plugin_block_gns.c
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet
- Copyright (C) 2010-2013 GNUnet e.V.
+ Copyright (C) 2010-2013, 2021, 2022 GNUnet e.V.
GNUnet is free software: you can redistribute it and/or modify it
under the terms of the GNU Affero General Public License as published
@@ -92,98 +92,16 @@ block_plugin_gns_create_group (void *cls,
/**
- * Function called to validate a reply or a request. For
- * request evaluation, simply pass "NULL" for the reply_block.
- * Note that it is assumed that the reply has already been
- * matched to the key (and signatures checked) as it would
- * be done with the "get_key" function.
- *
- * @param cls closure
- * @param ctx block context
- * @param type block type
- * @param bg block group to use for evaluation
- * @param eo control flags
- * @param query original query (hash)
- * @param xquery extrended query data (can be NULL, depending on @a type)
- * @param xquery_size number of bytes in @a xquery
- * @param reply_block response to validate
- * @param reply_block_size number of bytes in @a reply_block
- * @return characterization of result
- */
-static enum GNUNET_BLOCK_EvaluationResult
-block_plugin_gns_evaluate (void *cls,
- struct GNUNET_BLOCK_Context *ctx,
- enum GNUNET_BLOCK_Type type,
- struct GNUNET_BLOCK_Group *bg,
- enum GNUNET_BLOCK_EvaluationOptions eo,
- const struct GNUNET_HashCode *query,
- const void *xquery,
- size_t xquery_size,
- const void *reply_block,
- size_t reply_block_size)
-{
- const struct GNUNET_GNSRECORD_Block *block;
- struct GNUNET_HashCode h;
- struct GNUNET_HashCode chash;
-
- if (type != GNUNET_BLOCK_TYPE_GNS_NAMERECORD)
- return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED;
- if (NULL == reply_block)
- {
- if (0 != xquery_size)
- {
- GNUNET_break_op (0);
- return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID;
- }
- return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
- }
-
- /* this is a reply */
- if (reply_block_size < sizeof(struct GNUNET_GNSRECORD_Block))
- {
- GNUNET_break_op (0);
- return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
- }
- block = reply_block;
- if (GNUNET_GNSRECORD_block_get_size (block) > reply_block_size)
- {
- GNUNET_break_op (0);
- return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
- }
- GNUNET_GNSRECORD_query_from_block (block,
- &h);
- if (0 != GNUNET_memcmp (&h, query))
- {
- GNUNET_break_op (0);
- return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
- }
- if (GNUNET_OK !=
- GNUNET_GNSRECORD_block_verify (block))
- {
- GNUNET_break_op (0);
- return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
- }
- GNUNET_CRYPTO_hash (reply_block,
- reply_block_size,
- &chash);
- if (GNUNET_YES ==
- GNUNET_BLOCK_GROUP_bf_test_and_set (bg,
- &chash))
- return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE;
- return GNUNET_BLOCK_EVALUATION_OK_MORE;
-}
-
-
-/**
* Function called to obtain the key for a block.
+ * If the @a block is malformed, the function should
+ * zero-out @a key and return #GNUNET_OK.
*
* @param cls closure
* @param type block type
* @param reply_block block to get the key for
* @param reply_block_size number of bytes in @a reply_block
* @param key set to the key (query) for the given block
- * @return #GNUNET_OK on success, #GNUNET_SYSERR if type not supported
- * (or if extracting a key from a block of this type does not work)
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR if type not supported, #GNUNET_NO if extracting a key from a block of this type does not work
*/
static enum GNUNET_GenericReturnValue
block_plugin_gns_get_key (void *cls,
@@ -194,12 +112,18 @@ block_plugin_gns_get_key (void *cls,
{
const struct GNUNET_GNSRECORD_Block *block;
- if (type != GNUNET_BLOCK_TYPE_GNS_NAMERECORD)
+ if (GNUNET_BLOCK_TYPE_GNS_NAMERECORD != type)
+ {
+ GNUNET_break (0);
return GNUNET_SYSERR;
+ }
if (reply_block_size < sizeof(struct GNUNET_GNSRECORD_Block))
{
GNUNET_break_op (0);
- return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
+ memset (key,
+ 0,
+ sizeof (*key));
+ return GNUNET_OK;
}
block = reply_block;
GNUNET_GNSRECORD_query_from_block (block,
@@ -227,8 +151,11 @@ block_plugin_gns_check_query (void *cls,
const void *xquery,
size_t xquery_size)
{
- if (type != GNUNET_BLOCK_TYPE_GNS_NAMERECORD)
+ if (GNUNET_BLOCK_TYPE_GNS_NAMERECORD != type)
+ {
+ GNUNET_break (0);
return GNUNET_SYSERR;
+ }
if (0 != xquery_size)
{
GNUNET_break_op (0);
@@ -243,7 +170,6 @@ block_plugin_gns_check_query (void *cls,
*
* @param cls closure
* @param type block type
- * @param query key for the block (hash), must match exactly
* @param block block data to validate
* @param block_size number of bytes in @a block
* @return #GNUNET_OK if the block is fine, #GNUNET_NO if not
@@ -251,14 +177,16 @@ block_plugin_gns_check_query (void *cls,
static enum GNUNET_GenericReturnValue
block_plugin_gns_check_block (void *cls,
enum GNUNET_BLOCK_Type type,
- const struct GNUNET_HashCode *query,
const void *block,
size_t block_size)
{
const struct GNUNET_GNSRECORD_Block *gblock;
- if (type != GNUNET_BLOCK_TYPE_GNS_NAMERECORD)
+ if (GNUNET_BLOCK_TYPE_GNS_NAMERECORD != type)
+ {
+ GNUNET_break (0);
return GNUNET_SYSERR;
+ }
if (block_size < sizeof(struct GNUNET_GNSRECORD_Block))
{
GNUNET_break_op (0);
@@ -306,23 +234,16 @@ block_plugin_gns_check_reply (void *cls,
const void *reply_block,
size_t reply_block_size)
{
- const struct GNUNET_GNSRECORD_Block *block;
+ const struct GNUNET_GNSRECORD_Block *block = reply_block;
struct GNUNET_HashCode chash;
- if (type != GNUNET_BLOCK_TYPE_GNS_NAMERECORD)
- return GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED;
- /* this is a reply */
- if (reply_block_size < sizeof(struct GNUNET_GNSRECORD_Block))
+ if (GNUNET_BLOCK_TYPE_GNS_NAMERECORD != type)
{
- GNUNET_break_op (0);
- return GNUNET_BLOCK_REPLY_INVALID;
- }
- block = reply_block;
- if (GNUNET_GNSRECORD_block_get_size (block) > reply_block_size)
- {
- GNUNET_break_op (0);
- return GNUNET_BLOCK_REPLY_INVALID;
+ GNUNET_break (0);
+ return GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED;
}
+ GNUNET_assert (reply_block_size >= sizeof(struct GNUNET_GNSRECORD_Block));
+ GNUNET_assert (GNUNET_GNSRECORD_block_get_size (block) > reply_block_size);
GNUNET_CRYPTO_hash (reply_block,
reply_block_size,
&chash);
@@ -347,7 +268,6 @@ libgnunet_plugin_block_gns_init (void *cls)
struct GNUNET_BLOCK_PluginFunctions *api;
api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions);
- api->evaluate = &block_plugin_gns_evaluate;
api->get_key = &block_plugin_gns_get_key;
api->create_group = &block_plugin_gns_create_group;
api->check_query = &block_plugin_gns_check_query;
diff --git a/src/gnsrecord/gnsrecord_crypto.c b/src/gnsrecord/gnsrecord_crypto.c
index 688e639f3..ff92911de 100644
--- a/src/gnsrecord/gnsrecord_crypto.c
+++ b/src/gnsrecord/gnsrecord_crypto.c
@@ -591,8 +591,9 @@ GNUNET_GNSRECORD_block_verify (const struct GNUNET_GNSRECORD_Block *block)
purp = GNUNET_malloc (sizeof (struct GNRBlockPS) + payload_len);
purp->purpose.size = htonl (sizeof (struct GNRBlockPS) + payload_len);
purp->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_GNS_RECORD_SIGN);
- GNUNET_memcpy (&purp[1], &block[1], payload_len);
-
+ GNUNET_memcpy (&purp[1],
+ &block[1],
+ payload_len);
switch (ntohl (block->type))
{
case GNUNET_GNSRECORD_TYPE_PKEY:
diff --git a/src/include/gnunet_block_lib.h b/src/include/gnunet_block_lib.h
index f6db8d642..463c7af9f 100644
--- a/src/include/gnunet_block_lib.h
+++ b/src/include/gnunet_block_lib.h
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- Copyright (C) 2010 GNUnet e.V.
+ Copyright (C) 2010, 2022 GNUnet e.V.
GNUnet is free software: you can redistribute it and/or modify it
under the terms of the GNU Affero General Public License as published
@@ -162,108 +162,35 @@ enum GNUNET_BLOCK_Type
/**
- * Flags that can be set to control the evaluation.
- * @deprecated
- */
-enum GNUNET_BLOCK_EvaluationOptions
-{
- /**
- * Default behavior.
- */
- GNUNET_BLOCK_EO_NONE = 0,
-
- /**
- * The block is obtained from the local database, skip cryptographic
- * checks.
- */
- GNUNET_BLOCK_EO_LOCAL_SKIP_CRYPTO = 1
-};
-
-
-/**
* Possible ways for how a block may relate to a query.
- * @deprecated
*/
-enum GNUNET_BLOCK_EvaluationResult
+enum GNUNET_BLOCK_ReplyEvaluationResult
{
- /**
- * Valid result, and there may be more.
- */
- GNUNET_BLOCK_EVALUATION_OK_MORE = 0,
/**
- * Last possible valid result.
+ * Specified block type not supported by any plugin.
*/
- GNUNET_BLOCK_EVALUATION_OK_LAST = 1,
+ GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED = -1,
/**
* Valid result, but suppressed because it is a duplicate.
*/
- GNUNET_BLOCK_EVALUATION_OK_DUPLICATE = 2,
-
- /**
- * Block does not match query (invalid result)
- */
- GNUNET_BLOCK_EVALUATION_RESULT_INVALID = 3,
+ GNUNET_BLOCK_REPLY_OK_DUPLICATE = 0,
/**
* Block does not match xquery (valid result, not relevant for the request)
*/
- GNUNET_BLOCK_EVALUATION_RESULT_IRRELEVANT = 4,
-
- /**
- * Query is valid, no reply given.
- */
- GNUNET_BLOCK_EVALUATION_REQUEST_VALID = 10,
-
- /**
- * Query format does not match block type (invalid query). For
- * example, xquery not given or xquery_size not appropriate for
- * type.
- */
- GNUNET_BLOCK_EVALUATION_REQUEST_INVALID = 11,
-
- /**
- * Specified block type not supported by this plugin.
- */
- GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED = 20
-};
-
-
-/**
- * Possible ways for how a block may relate to a query.
- */
-enum GNUNET_BLOCK_ReplyEvaluationResult
-{
- /**
- * Valid result, but suppressed because it is a duplicate.
- */
- GNUNET_BLOCK_REPLY_OK_DUPLICATE = 0,
+ GNUNET_BLOCK_REPLY_IRRELEVANT = 1,
/**
* Valid result, and there may be more.
*/
- GNUNET_BLOCK_REPLY_OK_MORE = 1,
+ GNUNET_BLOCK_REPLY_OK_MORE = 2,
/**
* Last possible valid result.
*/
- GNUNET_BLOCK_REPLY_OK_LAST = 2,
-
- /**
- * Specified block type not supported by any plugin.
- */
- GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED = -1,
-
- /**
- * Block does not match query (invalid result)
- */
- GNUNET_BLOCK_REPLY_INVALID = -2,
-
- /**
- * Block does not match xquery (valid result, not relevant for the request)
- */
- GNUNET_BLOCK_REPLY_IRRELEVANT = -3,
+ GNUNET_BLOCK_REPLY_OK_LAST = 3
};
@@ -362,40 +289,8 @@ GNUNET_BLOCK_group_destroy (struct GNUNET_BLOCK_Group *bg);
/**
- * Function called to validate a reply or a request. For
- * request evaluation, simply pass "NULL" for the @a reply_block.
- * Note that it is assumed that the reply has already been
- * matched to the key (and signatures checked) as it would
- * be done with the #GNUNET_BLOCK_get_key() function.
- *
- * @param ctx block contxt
- * @param type block type
- * @param group block group to use for evaluation
- * @param eo evaluation options to control evaluation
- * @param query original query (hash)
- * @param xquery extrended query data (can be NULL, depending on type)
- * @param xquery_size number of bytes in @a xquery
- * @param reply_block response to validate
- * @param reply_block_size number of bytes in @a reply_block
- * @return characterization of result
- * @deprecated
- */
-enum GNUNET_BLOCK_EvaluationResult
-GNUNET_BLOCK_evaluate (struct GNUNET_BLOCK_Context *ctx,
- enum GNUNET_BLOCK_Type type,
- struct GNUNET_BLOCK_Group *group,
- enum GNUNET_BLOCK_EvaluationOptions eo,
- const struct GNUNET_HashCode *query,
- const void *xquery,
- size_t xquery_size,
- const void *reply_block,
- size_t reply_block_size);
-
-
-/**
- * Function called to validate a reply.
- * Also checks the query key against the block contents
- * as it would be done with the #GNUNET_BLOCK_get_key() function.
+ * Function called to validate if a reply is good for a
+ * particular query.
*
* @param ctx block contxt
* @param type block type
@@ -442,7 +337,6 @@ GNUNET_BLOCK_check_query (struct GNUNET_BLOCK_Context *ctx,
*
* @param ctx block contxt
* @param type block type
- * @param query query key (hash)
* @param block payload to put
* @param block_size number of bytes in @a block
* @return #GNUNET_OK if the block is fine, #GNUNET_NO if not,
@@ -451,13 +345,14 @@ GNUNET_BLOCK_check_query (struct GNUNET_BLOCK_Context *ctx,
enum GNUNET_GenericReturnValue
GNUNET_BLOCK_check_block (struct GNUNET_BLOCK_Context *ctx,
enum GNUNET_BLOCK_Type type,
- const struct GNUNET_HashCode *query,
const void *block,
size_t block_size);
/**
- * Function called to obtain the key for a block.
+ * Function called to obtain the @a key for a @a block.
+ * If the @a block is malformed, the function should
+ * zero-out @a key and return #GNUNET_OK.
*
* @param ctx block context
* @param type block type
@@ -465,9 +360,8 @@ GNUNET_BLOCK_check_block (struct GNUNET_BLOCK_Context *ctx,
* @param block_size number of bytes in @a block
* @param key set to the key (query) for the given block
* @return #GNUNET_YES on success,
- * #GNUNET_NO if the block is malformed
- * #GNUNET_SYSERR if type not supported
- * (or if extracting a key from a block of this type does not work)
+ * #GNUNET_NO if extracting a key from a block of this @a type does not work
+ * #GNUNET_SYSERR if @a type not supported
*/
enum GNUNET_GenericReturnValue
GNUNET_BLOCK_get_key (struct GNUNET_BLOCK_Context *ctx,
diff --git a/src/include/gnunet_block_plugin.h b/src/include/gnunet_block_plugin.h
index 2c9a3839d..1fa7ccf8b 100644
--- a/src/include/gnunet_block_plugin.h
+++ b/src/include/gnunet_block_plugin.h
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet
- Copyright (C) 2010,2013,2017 GNUnet e.V.
+ Copyright (C) 2010, 2013, 2017, 2021, 2022 GNUnet e.V.
GNUnet is free software: you can redistribute it and/or modify it
under the terms of the GNU Affero General Public License as published
@@ -163,43 +163,9 @@ typedef struct GNUNET_BLOCK_Group *
/**
- * Function called to validate a reply or a request. For
- * request evaluation, simply pass "NULL" for the @a reply_block.
- * Note that it is assumed that the reply has already been
- * matched to the key (and signatures checked) as it would
- * be done with the "get_key" function.
- *
- * @param cls closure
- * @param ctx block context
- * @param type block type
- * @param group which block group to use for evaluation
- * @param eo evaluation options to control evaluation
- * @param query original query (hash)
- * @param xquery extrended query data (can be NULL, depending on type)
- * @param xquery_size number of bytes in @a xquery
- * @param reply_block response to validate
- * @param reply_block_size number of bytes in @a reply_block
- * @return characterization of result
- * @deprecated
- */
-typedef enum GNUNET_BLOCK_EvaluationResult
-(*GNUNET_BLOCK_EvaluationFunction)(void *cls,
- struct GNUNET_BLOCK_Context *ctx,
- enum GNUNET_BLOCK_Type type,
- struct GNUNET_BLOCK_Group *group,
- enum GNUNET_BLOCK_EvaluationOptions eo,
- const struct GNUNET_HashCode *query,
- const void *xquery,
- size_t xquery_size,
- const void *reply_block,
- size_t reply_block_size);
-
-
-/**
* Function called to validate a query.
*
* @param cls closure
- * @param ctx block context
* @param type block type
* @param query original query (hash)
* @param xquery extrended query data (can be NULL, depending on type)
@@ -215,19 +181,17 @@ typedef enum GNUNET_GenericReturnValue
/**
- * Function called to validate a block for storage.
+ * Function called to validate a @a block for storage.
*
* @param cls closure
* @param type block type
- * @param query key for the block (hash), must match exactly
* @param block block data to validate
* @param block_size number of bytes in @a block
- * @return #GNUNET_OK if the block is fine, #GNUNET_NO if not
+ * @return #GNUNET_OK if the @a block is fine, #GNUNET_NO if not, #GNUNET_SYSERR if the @a type is not supported
*/
typedef enum GNUNET_GenericReturnValue
(*GNUNET_BLOCK_BlockEvaluationFunction)(void *cls,
enum GNUNET_BLOCK_Type type,
- const struct GNUNET_HashCode *query,
const void *block,
size_t block_size);
@@ -260,17 +224,18 @@ typedef enum GNUNET_BLOCK_ReplyEvaluationResult
/**
- * Function called to obtain the key for a block.
+ * Function called to obtain the @a key for a block.
+ * If the @a block is malformed, the function should
+ * zero-out @a key and return #GNUNET_OK.
*
* @param cls closure
* @param type block type
- * @param block block to get the key for
+ * @param block block to get the @a key for
* @param block_size number of bytes in @a block
* @param[out] key set to the key (query) for the given block
* @return #GNUNET_YES on success,
- * #GNUNET_NO if the block is malformed
- * #GNUNET_SYSERR if type not supported
- * (or if extracting a key from a block of this type does not work)
+ * #GNUNET_NO if extracting a key for this @a type does not work
+ * #GNUNET_SYSERR if @a type not supported
*/
typedef enum GNUNET_GenericReturnValue
(*GNUNET_BLOCK_GetKeyFunction) (void *cls,
@@ -297,14 +262,6 @@ struct GNUNET_BLOCK_PluginFunctions
const enum GNUNET_BLOCK_Type *types;
/**
- * Main function of a block plugin. Allows us to check if a
- * block matches a query.
- *
- * @param deprecated
- */
- GNUNET_BLOCK_EvaluationFunction evaluate;
-
- /**
* Obtain the key for a given block (if possible).
*/
GNUNET_BLOCK_GetKeyFunction get_key;
diff --git a/src/regex/plugin_block_regex.c b/src/regex/plugin_block_regex.c
index 0953830ab..61442ac10 100644
--- a/src/regex/plugin_block_regex.c
+++ b/src/regex/plugin_block_regex.c
@@ -93,242 +93,6 @@ block_plugin_regex_create_group (void *cls,
/**
- * Function called to validate a reply or a request of type
- * #GNUNET_BLOCK_TYPE_REGEX.
- * For request evaluation, pass "NULL" for the reply_block.
- * Note that it is assumed that the reply has already been
- * matched to the key (and signatures checked) as it would
- * be done with the #GNUNET_BLOCK_get_key() function.
- *
- * @param cls closure
- * @param type block type
- * @param bg block group to evaluate against
- * @param eo control flags
- * @param query original query (hash)
- * @param xquery extrended query data (can be NULL, depending on type)
- * @param xquery_size number of bytes in @a xquery
- * @param reply_block response to validate
- * @param reply_block_size number of bytes in @a reply_block
- * @return characterization of result
- */
-static enum GNUNET_BLOCK_EvaluationResult
-evaluate_block_regex (void *cls,
- enum GNUNET_BLOCK_Type type,
- struct GNUNET_BLOCK_Group *bg,
- enum GNUNET_BLOCK_EvaluationOptions eo,
- const struct GNUNET_HashCode *query,
- const void *xquery,
- size_t xquery_size,
- const void *reply_block,
- size_t reply_block_size)
-{
- struct GNUNET_HashCode chash;
-
- if (NULL == reply_block)
- {
- if (0 != xquery_size)
- {
- const char *s;
-
- s = (const char *) xquery;
- if ('\0' != s[xquery_size - 1]) /* must be valid 0-terminated string */
- {
- GNUNET_break_op (0);
- return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID;
- }
- }
- return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
- }
- if (0 != xquery_size)
- {
- const char *s;
-
- s = (const char *) xquery;
- if ('\0' != s[xquery_size - 1]) /* must be valid 0-terminated string */
- {
- GNUNET_break_op (0);
- return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID;
- }
- }
- else if (NULL != query)
- {
- /* xquery is required for regex GETs, at least an empty string */
- GNUNET_break_op (0);
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "type %d, query %p, xquery %p\n",
- type, query, xquery);
- return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID;
- }
- switch (REGEX_BLOCK_check (reply_block,
- reply_block_size,
- query,
- xquery))
- {
- case GNUNET_SYSERR:
- GNUNET_break_op (0);
- return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
-
- case GNUNET_NO:
- /* xquery mismatch, can happen */
- return GNUNET_BLOCK_EVALUATION_RESULT_IRRELEVANT;
-
- default:
- break;
- }
- GNUNET_CRYPTO_hash (reply_block,
- reply_block_size,
- &chash);
- if (GNUNET_YES ==
- GNUNET_BLOCK_GROUP_bf_test_and_set (bg,
- &chash))
- return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE;
- return GNUNET_BLOCK_EVALUATION_OK_MORE;
-}
-
-
-/**
- * Function called to validate a reply or a request of type
- * #GNUNET_BLOCK_TYPE_REGEX_ACCEPT.
- * For request evaluation, pass "NULL" for the reply_block.
- * Note that it is assumed that the reply has already been
- * matched to the key (and signatures checked) as it would
- * be done with the #GNUNET_BLOCK_get_key() function.
- *
- * @param cls closure
- * @param type block type
- * @param bg block group to evaluate against
- * @param eo control flags
- * @param query original query (hash)
- * @param xquery extrended query data (can be NULL, depending on type)
- * @param xquery_size number of bytes in @a xquery
- * @param reply_block response to validate
- * @param reply_block_size number of bytes in @a reply_block
- * @return characterization of result
- */
-static enum GNUNET_BLOCK_EvaluationResult
-evaluate_block_regex_accept (void *cls,
- enum GNUNET_BLOCK_Type type,
- struct GNUNET_BLOCK_Group *bg,
- enum GNUNET_BLOCK_EvaluationOptions eo,
- const struct GNUNET_HashCode *query,
- const void *xquery,
- size_t xquery_size, const void *reply_block,
- size_t reply_block_size)
-{
- const struct RegexAcceptBlock *rba;
- struct GNUNET_HashCode chash;
-
- 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 RegexAcceptBlock) != reply_block_size)
- {
- GNUNET_break_op (0);
- return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
- }
- rba = reply_block;
- if (ntohl (rba->purpose.size) !=
- sizeof(struct GNUNET_CRYPTO_EccSignaturePurpose)
- + sizeof(struct GNUNET_TIME_AbsoluteNBO)
- + sizeof(struct GNUNET_HashCode))
- {
- GNUNET_break_op (0);
- return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
- }
- if (0 == GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_ntoh (
- rba->expiration_time)).
- rel_value_us)
- {
- /* technically invalid, but can happen without an error, so
- we're nice by reporting it as a 'duplicate' */
- return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE;
- }
- if (GNUNET_OK !=
- GNUNET_CRYPTO_eddsa_verify_ (GNUNET_SIGNATURE_PURPOSE_REGEX_ACCEPT,
- &rba->purpose,
- &rba->signature,
- &rba->peer.public_key))
- {
- GNUNET_break_op (0);
- return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
- }
- GNUNET_CRYPTO_hash (reply_block,
- reply_block_size,
- &chash);
- if (GNUNET_YES ==
- GNUNET_BLOCK_GROUP_bf_test_and_set (bg,
- &chash))
- return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE;
- return GNUNET_BLOCK_EVALUATION_OK_MORE;
-}
-
-
-/**
- * Function called to validate a reply or a request. For
- * request evaluation, simply pass "NULL" for the reply_block.
- * Note that it is assumed that the reply has already been
- * matched to the key (and signatures checked) as it would
- * be done with the #GNUNET_BLOCK_get_key() function.
- *
- * @param cls closure
- * @param ctx block context
- * @param type block type
- * @param bg group to evaluate against
- * @param eo control flags
- * @param query original query (hash)
- * @param xquery extrended query data (can be NULL, depending on type)
- * @param xquery_size number of bytes in xquery
- * @param reply_block response to validate
- * @param reply_block_size number of bytes in reply block
- * @return characterization of result
- */
-static enum GNUNET_BLOCK_EvaluationResult
-block_plugin_regex_evaluate (void *cls,
- struct GNUNET_BLOCK_Context *ctx,
- enum GNUNET_BLOCK_Type type,
- struct GNUNET_BLOCK_Group *bg,
- enum GNUNET_BLOCK_EvaluationOptions eo,
- const struct GNUNET_HashCode *query,
- const void *xquery,
- size_t xquery_size,
- const void *reply_block,
- size_t reply_block_size)
-{
- enum GNUNET_BLOCK_EvaluationResult result;
-
- switch (type)
- {
- case GNUNET_BLOCK_TYPE_REGEX:
- result = evaluate_block_regex (cls,
- type,
- bg,
- eo,
- query,
- xquery, xquery_size,
- reply_block, reply_block_size);
- break;
-
- case GNUNET_BLOCK_TYPE_REGEX_ACCEPT:
- result = evaluate_block_regex_accept (cls,
- type,
- bg,
- eo,
- query,
- xquery, xquery_size,
- reply_block, reply_block_size);
- break;
-
- default:
- result = GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED;
- }
- return result;
-}
-
-
-/**
* Function called to validate a query.
*
* @param cls closure
@@ -341,10 +105,10 @@ block_plugin_regex_evaluate (void *cls,
*/
static enum GNUNET_GenericReturnValue
block_plugin_regex_check_query (void *cls,
- enum GNUNET_BLOCK_Type type,
- const struct GNUNET_HashCode *query,
- const void *xquery,
- size_t xquery_size)
+ enum GNUNET_BLOCK_Type type,
+ const struct GNUNET_HashCode *query,
+ const void *xquery,
+ size_t xquery_size)
{
switch (type)
{
@@ -380,7 +144,6 @@ block_plugin_regex_check_query (void *cls,
*
* @param cls closure
* @param type block type
- * @param query key for the block (hash), must match exactly
* @param block block data to validate
* @param block_size number of bytes in @a block
* @return #GNUNET_OK if the block is fine, #GNUNET_NO if not
@@ -388,7 +151,6 @@ block_plugin_regex_check_query (void *cls,
static enum GNUNET_GenericReturnValue
block_plugin_regex_check_block (void *cls,
enum GNUNET_BLOCK_Type type,
- const struct GNUNET_HashCode *query,
const void *block,
size_t block_size)
{
@@ -398,7 +160,7 @@ block_plugin_regex_check_block (void *cls,
if (GNUNET_SYSERR ==
REGEX_BLOCK_check (block,
block_size,
- query,
+ NULL,
NULL))
return GNUNET_NO;
return GNUNET_OK;
@@ -480,12 +242,7 @@ block_plugin_regex_check_reply (
const char *s;
s = (const char *) xquery;
- if ('\0' != s[xquery_size - 1]) /* must be valid 0-terminated string */
- {
- /* Technically, the query is invalid ... */
- GNUNET_break (0);
- return GNUNET_BLOCK_REPLY_INVALID;
- }
+ GNUNET_assert ('\0' == s[xquery_size - 1]);
}
switch (REGEX_BLOCK_check (reply_block,
reply_block_size,
@@ -493,8 +250,7 @@ block_plugin_regex_check_reply (
xquery))
{
case GNUNET_SYSERR:
- GNUNET_break_op (0);
- return GNUNET_BLOCK_REPLY_INVALID;
+ GNUNET_assert (0);
case GNUNET_NO:
/* xquery mismatch, can happen */
return GNUNET_BLOCK_REPLY_IRRELEVANT;
@@ -513,20 +269,12 @@ block_plugin_regex_check_reply (
{
const struct RegexAcceptBlock *rba;
- if (sizeof(struct RegexAcceptBlock) != reply_block_size)
- {
- GNUNET_break_op (0);
- return GNUNET_BLOCK_REPLY_INVALID;
- }
+ GNUNET_assert (sizeof(struct RegexAcceptBlock) == reply_block_size);
rba = reply_block;
- if (ntohl (rba->purpose.size) !=
+ GNUNET_assert (ntohl (rba->purpose.size) ==
sizeof(struct GNUNET_CRYPTO_EccSignaturePurpose)
+ sizeof(struct GNUNET_TIME_AbsoluteNBO)
- + sizeof(struct GNUNET_HashCode))
- {
- GNUNET_break_op (0);
- return GNUNET_BLOCK_REPLY_INVALID;
- }
+ + sizeof(struct GNUNET_HashCode));
GNUNET_CRYPTO_hash (reply_block,
reply_block_size,
&chash);
@@ -552,8 +300,8 @@ block_plugin_regex_check_reply (
* @param block block to get the key for
* @param block_size number of bytes in @a block
* @param key set to the key (query) for the given block
- * @return #GNUNET_OK on success, #GNUNET_SYSERR if type not supported
- * (or if extracting a key from a block of this type does not work)
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR if type not supported,
+ * #GNUNET_NO if extracting a key from a block of this type does not work
*/
static enum GNUNET_GenericReturnValue
block_plugin_regex_get_key (void *cls,
@@ -571,14 +319,20 @@ block_plugin_regex_get_key (void *cls,
key))
{
GNUNET_break_op (0);
- return GNUNET_NO;
+ memset (key,
+ 0,
+ sizeof (*key));
+ return GNUNET_OK;
}
return GNUNET_OK;
case GNUNET_BLOCK_TYPE_REGEX_ACCEPT:
if (sizeof(struct RegexAcceptBlock) != block_size)
{
GNUNET_break_op (0);
- return GNUNET_NO;
+ memset (key,
+ 0,
+ sizeof (*key));
+ return GNUNET_OK;
}
*key = ((struct RegexAcceptBlock *) block)->key;
return GNUNET_OK;
@@ -603,7 +357,6 @@ libgnunet_plugin_block_regex_init (void *cls)
struct GNUNET_BLOCK_PluginFunctions *api;
api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions);
- api->evaluate = &block_plugin_regex_evaluate;
api->get_key = &block_plugin_regex_get_key;
api->check_query = &block_plugin_regex_check_query;
api->check_block = &block_plugin_regex_check_block;
diff --git a/src/revocation/plugin_block_revocation.c b/src/revocation/plugin_block_revocation.c
index 3beae60bb..12ec555e4 100644
--- a/src/revocation/plugin_block_revocation.c
+++ b/src/revocation/plugin_block_revocation.c
@@ -44,65 +44,6 @@ struct InternalContext
/**
- * Function called to validate a reply or a request. For
- * request evaluation, simply pass "NULL" for the reply_block.
- *
- * @param cls our `struct InternalContext`
- * @param ctx context
- * @param type block type
- * @param group block group to use
- * @param eo control flags
- * @param query original query (hash)
- * @param xquery extrended query data (can be NULL, depending on type)
- * @param xquery_size number of bytes in xquery
- * @param reply_block response to validate
- * @param reply_block_size number of bytes in reply block
- * @return characterization of result
- */
-static enum GNUNET_BLOCK_EvaluationResult
-block_plugin_revocation_evaluate (void *cls,
- struct GNUNET_BLOCK_Context *ctx,
- enum GNUNET_BLOCK_Type type,
- struct GNUNET_BLOCK_Group *group,
- enum GNUNET_BLOCK_EvaluationOptions eo,
- const struct GNUNET_HashCode *query,
- const void *xquery,
- size_t xquery_size,
- const void *reply_block,
- size_t reply_block_size)
-{
- struct InternalContext *ic = cls;
- ssize_t pklen;
- const struct RevokeMessage *rm = reply_block;
-
- if (NULL == reply_block)
- return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
- if (reply_block_size != sizeof(*rm))
- {
- GNUNET_break_op (0);
- return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
- }
- struct GNUNET_REVOCATION_PowP *pow = (struct GNUNET_REVOCATION_PowP *) &rm[1];
- const struct GNUNET_IDENTITY_PublicKey *pk;
- pk = (const struct GNUNET_IDENTITY_PublicKey *) &pow[1];
- if (GNUNET_YES != GNUNET_REVOCATION_check_pow (pow,
- ic->matching_bits,
- ic->epoch_duration))
- {
- GNUNET_break_op (0);
- return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
- }
- pklen = GNUNET_IDENTITY_key_get_length (pk);
- if (0 > pklen)
- {
- GNUNET_break_op (0);
- return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
- }
- return GNUNET_BLOCK_EVALUATION_OK_LAST;
-}
-
-
-/**
* Function called to validate a query.
*
* @param cls closure
@@ -124,7 +65,10 @@ block_plugin_revocation_check_query (void *cls,
(void) query;
(void) xquery;
if (GNUNET_BLOCK_TYPE_REVOCATION != type)
+ {
+ GNUNET_break (0);
return GNUNET_SYSERR;
+ }
if (0 != xquery_size)
return GNUNET_NO;
return GNUNET_OK;
@@ -136,7 +80,6 @@ block_plugin_revocation_check_query (void *cls,
*
* @param cls closure
* @param type block type
- * @param query key for the block (hash), must match exactly
* @param block block data to validate
* @param block_size number of bytes in @a block
* @return #GNUNET_OK if the block is fine, #GNUNET_NO if not
@@ -144,7 +87,6 @@ block_plugin_revocation_check_query (void *cls,
static enum GNUNET_GenericReturnValue
block_plugin_revocation_check_block (void *cls,
enum GNUNET_BLOCK_Type type,
- const struct GNUNET_HashCode *query,
const void *block,
size_t block_size)
{
@@ -157,7 +99,10 @@ block_plugin_revocation_check_block (void *cls,
size_t left;
if (GNUNET_BLOCK_TYPE_REVOCATION != type)
+ {
+ GNUNET_break (0);
return GNUNET_SYSERR;
+ }
if (block_size < sizeof(*rm) + sizeof(*pow))
{
GNUNET_break_op (0);
@@ -224,7 +169,10 @@ block_plugin_revocation_check_reply (
(void) reply_block;
(void) reply_block_size;
if (GNUNET_BLOCK_TYPE_REVOCATION != type)
+ {
+ GNUNET_break (0);
return GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED;
+ }
return GNUNET_BLOCK_REPLY_OK_LAST;
}
@@ -255,7 +203,10 @@ block_plugin_revocation_get_key (void *cls,
size_t left;
if (GNUNET_BLOCK_TYPE_REVOCATION != type)
+ {
+ GNUNET_break (0);
return GNUNET_SYSERR;
+ }
if (block_size < sizeof(*rm) + sizeof(*pow))
{
GNUNET_break_op (0);
@@ -314,7 +265,6 @@ libgnunet_plugin_block_revocation_init (void *cls)
return NULL;
api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions);
- api->evaluate = &block_plugin_revocation_evaluate;
api->get_key = &block_plugin_revocation_get_key;
api->check_query = &block_plugin_revocation_check_query;
api->check_block = &block_plugin_revocation_check_block;
diff --git a/src/set/plugin_block_set_test.c b/src/set/plugin_block_set_test.c
index 3d66831bb..cb5cef5ad 100644
--- a/src/set/plugin_block_set_test.c
+++ b/src/set/plugin_block_set_test.c
@@ -30,46 +30,9 @@
/**
- * Function called to validate a reply or a request. For
- * request evaluation, simply pass "NULL" for the reply_block.
- *
- * @param cls closure
- * @param ctx block context
- * @param type block type
- * @param group block group to use
- * @param eo control flags
- * @param query original query (hash)
- * @param xquery extrended query data (can be NULL, depending on type)
- * @param xquery_size number of bytes in xquery
- * @param reply_block response to validate
- * @param reply_block_size number of bytes in reply block
- * @return characterization of result
- */
-static enum GNUNET_BLOCK_EvaluationResult
-block_plugin_set_test_evaluate (void *cls,
- struct GNUNET_BLOCK_Context *ctx,
- enum GNUNET_BLOCK_Type type,
- struct GNUNET_BLOCK_Group *group,
- enum GNUNET_BLOCK_EvaluationOptions eo,
- const struct GNUNET_HashCode *query,
- const void *xquery,
- size_t xquery_size,
- const void *reply_block,
- size_t reply_block_size)
-{
- if ((NULL == reply_block) ||
- (reply_block_size == 0) ||
- (0 != ((char *) reply_block)[0]))
- return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
- return GNUNET_BLOCK_EVALUATION_OK_MORE;
-}
-
-
-/**
* Function called to validate a query.
*
* @param cls closure
- * @param ctx block context
* @param type block type
* @param query original query (hash)
* @param xquery extrended query data (can be NULL, depending on type)
@@ -92,7 +55,6 @@ block_plugin_set_test_check_query (void *cls,
*
* @param cls closure
* @param type block type
- * @param query key for the block (hash), must match exactly
* @param block block data to validate
* @param block_size number of bytes in @a block
* @return #GNUNET_OK if the block is fine, #GNUNET_NO if not
@@ -100,7 +62,6 @@ block_plugin_set_test_check_query (void *cls,
static enum GNUNET_GenericReturnValue
block_plugin_set_test_check_block (void *cls,
enum GNUNET_BLOCK_Type type,
- const struct GNUNET_HashCode *query,
const void *block,
size_t block_size)
{
@@ -141,7 +102,7 @@ block_plugin_set_test_check_reply (void *cls,
if ((NULL == reply_block) ||
(0 == reply_block_size) ||
(0 != ((char *) reply_block)[0]))
- return GNUNET_BLOCK_REPLY_INVALID;
+ GNUNET_assert (0);
return GNUNET_BLOCK_REPLY_OK_MORE;
}
@@ -164,7 +125,7 @@ block_plugin_set_test_get_key (void *cls,
size_t block_size,
struct GNUNET_HashCode *key)
{
- return GNUNET_SYSERR;
+ return GNUNET_NO;
}
@@ -181,7 +142,6 @@ libgnunet_plugin_block_set_test_init (void *cls)
struct GNUNET_BLOCK_PluginFunctions *api;
api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions);
- api->evaluate = &block_plugin_set_test_evaluate;
api->get_key = &block_plugin_set_test_get_key;
api->check_query = &block_plugin_set_test_check_query;
api->check_block = &block_plugin_set_test_check_block;
diff --git a/src/seti/plugin_block_seti_test.c b/src/seti/plugin_block_seti_test.c
index af86e1af6..5b9196cef 100644
--- a/src/seti/plugin_block_seti_test.c
+++ b/src/seti/plugin_block_seti_test.c
@@ -30,42 +30,6 @@
/**
- * Function called to validate a reply or a request. For
- * request evaluation, simply pass "NULL" for the reply_block.
- *
- * @param cls closure
- * @param ctx block context
- * @param type block type
- * @param group block group to use
- * @param eo control flags
- * @param query original query (hash)
- * @param xquery extrended query data (can be NULL, depending on type)
- * @param xquery_size number of bytes in xquery
- * @param reply_block response to validate
- * @param reply_block_size number of bytes in reply block
- * @return characterization of result
- */
-static enum GNUNET_BLOCK_EvaluationResult
-block_plugin_seti_test_evaluate (void *cls,
- struct GNUNET_BLOCK_Context *ctx,
- enum GNUNET_BLOCK_Type type,
- struct GNUNET_BLOCK_Group *group,
- enum GNUNET_BLOCK_EvaluationOptions eo,
- const struct GNUNET_HashCode *query,
- const void *xquery,
- size_t xquery_size,
- const void *reply_block,
- size_t reply_block_size)
-{
- if ((NULL == reply_block) ||
- (reply_block_size == 0) ||
- (0 != ((char *) reply_block)[0]))
- return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
- return GNUNET_BLOCK_EVALUATION_OK_MORE;
-}
-
-
-/**
* Function called to validate a query.
*
* @param cls closure
@@ -83,6 +47,16 @@ block_plugin_seti_test_check_query (void *cls,
const void *xquery,
size_t xquery_size)
{
+ if (GNUNET_BLOCK_TYPE_SETI_TEST != type)
+ {
+ GNUNET_break (0);
+ return GNUNET_SYSERR;
+ }
+ if (0 != xquery_size)
+ {
+ GNUNET_break_op (0);
+ return GNUNET_NO;
+ }
return GNUNET_OK;
}
@@ -92,7 +66,6 @@ block_plugin_seti_test_check_query (void *cls,
*
* @param cls closure
* @param type block type
- * @param query key for the block (hash), must match exactly
* @param block block data to validate
* @param block_size number of bytes in @a block
* @return #GNUNET_OK if the block is fine, #GNUNET_NO if not
@@ -100,10 +73,15 @@ block_plugin_seti_test_check_query (void *cls,
static enum GNUNET_GenericReturnValue
block_plugin_seti_test_check_block (void *cls,
enum GNUNET_BLOCK_Type type,
- const struct GNUNET_HashCode *query,
const void *block,
size_t block_size)
{
+ (void) cls;
+ if (GNUNET_BLOCK_TYPE_SETI_TEST != type)
+ {
+ GNUNET_break (0);
+ return GNUNET_SYSERR;
+ }
if ((NULL == block) ||
(0 == block_size) ||
(0 != ((char *) block)[0]))
@@ -138,10 +116,18 @@ block_plugin_seti_test_check_reply (void *cls,
const void *reply_block,
size_t reply_block_size)
{
+ (void) cls;
+ (void) xquery;
+ (void) xquery_size;
+ if (GNUNET_BLOCK_TYPE_SETI_TEST != type)
+ {
+ GNUNET_break (0);
+ return GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED;
+ }
if ( (NULL == reply_block) ||
(0 == reply_block_size) ||
(0 != ((char *) reply_block)[0]) )
- return GNUNET_BLOCK_REPLY_INVALID;
+ GNUNET_assert (0);
return GNUNET_BLOCK_REPLY_OK_MORE;
}
@@ -164,7 +150,12 @@ block_plugin_seti_test_get_key (void *cls,
size_t block_size,
struct GNUNET_HashCode *key)
{
- return GNUNET_SYSERR;
+ if (GNUNET_BLOCK_TYPE_SETI_TEST != type)
+ {
+ GNUNET_break (0);
+ return GNUNET_SYSERR;
+ }
+ return GNUNET_NO;
}
@@ -181,7 +172,6 @@ libgnunet_plugin_block_seti_test_init (void *cls)
struct GNUNET_BLOCK_PluginFunctions *api;
api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions);
- api->evaluate = &block_plugin_seti_test_evaluate;
api->get_key = &block_plugin_seti_test_get_key;
api->check_query = &block_plugin_seti_test_check_query;
api->check_block = &block_plugin_seti_test_check_block;
diff --git a/src/setu/plugin_block_setu_test.c b/src/setu/plugin_block_setu_test.c
index 9872bba39..178ad3314 100644
--- a/src/setu/plugin_block_setu_test.c
+++ b/src/setu/plugin_block_setu_test.c
@@ -23,49 +23,12 @@
* @brief set test block, recognizes elements with non-zero first byte as invalid
* @author Christian Grothoff
*/
-
#include "platform.h"
#include "gnunet_block_plugin.h"
#include "gnunet_block_group_lib.h"
/**
- * Function called to validate a reply or a request. For
- * request evaluation, simply pass "NULL" for the reply_block.
- *
- * @param cls closure
- * @param ctx block context
- * @param type block type
- * @param group block group to use
- * @param eo control flags
- * @param query original query (hash)
- * @param xquery extrended query data (can be NULL, depending on type)
- * @param xquery_size number of bytes in xquery
- * @param reply_block response to validate
- * @param reply_block_size number of bytes in reply block
- * @return characterization of result
- */
-static enum GNUNET_BLOCK_EvaluationResult
-block_plugin_setu_test_evaluate (void *cls,
- struct GNUNET_BLOCK_Context *ctx,
- enum GNUNET_BLOCK_Type type,
- struct GNUNET_BLOCK_Group *group,
- enum GNUNET_BLOCK_EvaluationOptions eo,
- const struct GNUNET_HashCode *query,
- const void *xquery,
- size_t xquery_size,
- const void *reply_block,
- size_t reply_block_size)
-{
- if ((NULL == reply_block) ||
- (reply_block_size == 0) ||
- (0 != ((char *) reply_block)[0]))
- return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
- return GNUNET_BLOCK_EVALUATION_OK_MORE;
-}
-
-
-/**
* Function called to validate a query.
*
* @param cls closure
@@ -83,6 +46,16 @@ block_plugin_setu_test_check_query (void *cls,
const void *xquery,
size_t xquery_size)
{
+ if (GNUNET_BLOCK_TYPE_SETU_TEST != type)
+ {
+ GNUNET_break (0);
+ return GNUNET_SYSERR;
+ }
+ if (0 != xquery_size)
+ {
+ GNUNET_break_op (0);
+ return GNUNET_NO;
+ }
return GNUNET_OK;
}
@@ -92,7 +65,6 @@ block_plugin_setu_test_check_query (void *cls,
*
* @param cls closure
* @param type block type
- * @param query key for the block (hash), must match exactly
* @param block block data to validate
* @param block_size number of bytes in @a block
* @return #GNUNET_OK if the block is fine, #GNUNET_NO if not
@@ -100,14 +72,18 @@ block_plugin_setu_test_check_query (void *cls,
static enum GNUNET_GenericReturnValue
block_plugin_setu_test_check_block (void *cls,
enum GNUNET_BLOCK_Type type,
- const struct GNUNET_HashCode *query,
const void *block,
size_t block_size)
{
+ if (GNUNET_BLOCK_TYPE_SETU_TEST != type)
+ {
+ GNUNET_break (0);
+ return GNUNET_SYSERR;
+ }
if ( (NULL == block) ||
(0 == block_size) ||
(0 != ((char *) block)[0]) )
- return GNUNET_SYSERR;
+ return GNUNET_NO;
return GNUNET_OK;
}
@@ -138,10 +114,18 @@ block_plugin_setu_test_check_reply (void *cls,
const void *reply_block,
size_t reply_block_size)
{
+ (void) cls;
+ (void) xquery;
+ (void) xquery_size;
+ if (GNUNET_BLOCK_TYPE_SETU_TEST != type)
+ {
+ GNUNET_break (0);
+ return GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED;
+ }
if ( (NULL == reply_block) ||
(0 == reply_block_size) ||
(0 != ((char *) reply_block)[0]) )
- return GNUNET_BLOCK_REPLY_INVALID;
+ GNUNET_assert (0);
return GNUNET_BLOCK_REPLY_OK_MORE;
}
@@ -164,7 +148,12 @@ block_plugin_setu_test_get_key (void *cls,
size_t block_size,
struct GNUNET_HashCode *key)
{
- return GNUNET_SYSERR;
+ if (GNUNET_BLOCK_TYPE_SETU_TEST != type)
+ {
+ GNUNET_break (0);
+ return GNUNET_SYSERR;
+ }
+ return GNUNET_NO;
}
@@ -175,13 +164,12 @@ void *
libgnunet_plugin_block_setu_test_init (void *cls)
{
static enum GNUNET_BLOCK_Type types[] = {
- GNUNET_BLOCK_TYPE_SETU_TEST,
+ GNUNET_BLOCK_TYPE_SETU_TEST,
GNUNET_BLOCK_TYPE_ANY /* end of list */
};
struct GNUNET_BLOCK_PluginFunctions *api;
api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions);
- api->evaluate = &block_plugin_setu_test_evaluate;
api->get_key = &block_plugin_setu_test_get_key;
api->check_query = &block_plugin_setu_test_check_query;
api->check_block = &block_plugin_setu_test_check_block;