diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-09-18 19:10:12 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-09-18 19:10:12 +0000 |
commit | 3756b235a8ef6a680a1bc7197c1ce45d778af09c (patch) | |
tree | ec506ec28427cfc7813711b938fccbbbb6d1d728 /src/block | |
parent | d24bc034571753884f63bdb9c45ec53ef289121c (diff) | |
download | gnunet-3756b235a8ef6a680a1bc7197c1ce45d778af09c.tar.gz gnunet-3756b235a8ef6a680a1bc7197c1ce45d778af09c.zip |
plane hacking
Diffstat (limited to 'src/block')
-rw-r--r-- | src/block/Makefile.am | 21 | ||||
-rw-r--r-- | src/block/plugin_block_dht.c | 163 | ||||
-rw-r--r-- | src/block/plugin_block_fs.c | 35 | ||||
-rw-r--r-- | src/block/plugin_block_test.c | 154 | ||||
-rw-r--r-- | src/block/test_block.c | 8 |
5 files changed, 359 insertions, 22 deletions
diff --git a/src/block/Makefile.am b/src/block/Makefile.am index 2fc0c0081..b37c7705e 100644 --- a/src/block/Makefile.am +++ b/src/block/Makefile.am | |||
@@ -13,8 +13,19 @@ endif | |||
13 | lib_LTLIBRARIES = libgnunetblock.la | 13 | lib_LTLIBRARIES = libgnunetblock.la |
14 | 14 | ||
15 | plugin_LTLIBRARIES = \ | 15 | plugin_LTLIBRARIES = \ |
16 | libgnunet_plugin_block_dht.la \ | ||
16 | libgnunet_plugin_block_fs.la \ | 17 | libgnunet_plugin_block_fs.la \ |
17 | libgnunet_plugin_block_template.la | 18 | libgnunet_plugin_block_template.la \ |
19 | libgnunet_plugin_block_test.la | ||
20 | |||
21 | libgnunet_plugin_block_dht_la_SOURCES = \ | ||
22 | plugin_block_dht.c | ||
23 | libgnunet_plugin_block_dht_la_LIBADD = \ | ||
24 | $(top_builddir)/src/hello/libgnunethello.la \ | ||
25 | $(top_builddir)/src/block/libgnunetblock.la \ | ||
26 | $(top_builddir)/src/util/libgnunetutil.la | ||
27 | libgnunet_plugin_block_dht_la_LDFLAGS = \ | ||
28 | $(GN_PLUGIN_LDFLAGS) | ||
18 | 29 | ||
19 | libgnunet_plugin_block_fs_la_SOURCES = \ | 30 | libgnunet_plugin_block_fs_la_SOURCES = \ |
20 | plugin_block_fs.c | 31 | plugin_block_fs.c |
@@ -31,6 +42,14 @@ libgnunet_plugin_block_template_la_LIBADD = \ | |||
31 | libgnunet_plugin_block_template_la_LDFLAGS = \ | 42 | libgnunet_plugin_block_template_la_LDFLAGS = \ |
32 | $(GN_PLUGIN_LDFLAGS) | 43 | $(GN_PLUGIN_LDFLAGS) |
33 | 44 | ||
45 | libgnunet_plugin_block_test_la_SOURCES = \ | ||
46 | plugin_block_test.c | ||
47 | libgnunet_plugin_block_test_la_LIBADD = \ | ||
48 | $(top_builddir)/src/block/libgnunetblock.la \ | ||
49 | $(top_builddir)/src/util/libgnunetutil.la | ||
50 | libgnunet_plugin_block_test_la_LDFLAGS = \ | ||
51 | $(GN_PLUGIN_LDFLAGS) | ||
52 | |||
34 | 53 | ||
35 | libgnunetblock_la_SOURCES = \ | 54 | libgnunetblock_la_SOURCES = \ |
36 | block.c plugin_block.h | 55 | block.c plugin_block.h |
diff --git a/src/block/plugin_block_dht.c b/src/block/plugin_block_dht.c new file mode 100644 index 000000000..8312a69b5 --- /dev/null +++ b/src/block/plugin_block_dht.c | |||
@@ -0,0 +1,163 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | (C) 2010 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file block/plugin_block_dht.c | ||
23 | * @brief block plugin for DHT internals (right now, find-peer requests only); | ||
24 | * other plugins should be used to store "useful" data in the | ||
25 | * DHT (see fs block plugin) | ||
26 | * @author Christian Grothoff | ||
27 | */ | ||
28 | |||
29 | #include "platform.h" | ||
30 | #include "gnunet_hello_lib.h" | ||
31 | #include "plugin_block.h" | ||
32 | |||
33 | #define DEBUG_DHT GNUNET_NO | ||
34 | |||
35 | |||
36 | /** | ||
37 | * Function called to validate a reply or a request. For | ||
38 | * request evaluation, simply pass "NULL" for the reply_block. | ||
39 | * | ||
40 | * @param cls closure | ||
41 | * @param type block type | ||
42 | * @param query original query (hash) | ||
43 | * @param bf pointer to bloom filter associated with query; possibly updated (!) | ||
44 | * @param bf_mutator mutation value for bf | ||
45 | * @param xquery extrended query data (can be NULL, depending on type) | ||
46 | * @param xquery_size number of bytes in xquery | ||
47 | * @param reply_block response to validate | ||
48 | * @param reply_block_size number of bytes in reply block | ||
49 | * @return characterization of result | ||
50 | */ | ||
51 | static enum GNUNET_BLOCK_EvaluationResult | ||
52 | block_plugin_dht_evaluate (void *cls, | ||
53 | enum GNUNET_BLOCK_Type type, | ||
54 | const GNUNET_HashCode *query, | ||
55 | struct GNUNET_CONTAINER_BloomFilter **bf, | ||
56 | int32_t bf_mutator, | ||
57 | const void *xquery, | ||
58 | size_t xquery_size, | ||
59 | const void *reply_block, | ||
60 | size_t reply_block_size) | ||
61 | { | ||
62 | if (type != GNUNET_BLOCK_TYPE_DHT_HELLO) | ||
63 | return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED; | ||
64 | if (xquery_size != 0) | ||
65 | return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID; | ||
66 | if (reply_block_size == 0) | ||
67 | return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; | ||
68 | GNUNET_break (NULL == *bf); | ||
69 | return GNUNET_BLOCK_EVALUATION_OK_LAST; | ||
70 | } | ||
71 | |||
72 | |||
73 | /** | ||
74 | * Function called to obtain the key for a block. | ||
75 | * | ||
76 | * @param cls closure | ||
77 | * @param type block type | ||
78 | * @param block block to get the key for | ||
79 | * @param block_size number of bytes in block | ||
80 | * @param key set to the key (query) for the given block | ||
81 | * @return GNUNET_OK on success, GNUNET_SYSERR if type not supported | ||
82 | * (or if extracting a key from a block of this type does not work) | ||
83 | */ | ||
84 | static int | ||
85 | block_plugin_dht_get_key (void *cls, | ||
86 | enum GNUNET_BLOCK_Type type, | ||
87 | const void *block, | ||
88 | size_t block_size, | ||
89 | GNUNET_HashCode *key) | ||
90 | { | ||
91 | const struct GNUNET_MessageHeader *msg; | ||
92 | const struct GNUNET_HELLO_Message *hello; | ||
93 | struct GNUNET_PeerIdentity *pid; | ||
94 | |||
95 | if (type != GNUNET_BLOCK_TYPE_DHT_HELLO) | ||
96 | return GNUNET_SYSERR; | ||
97 | if (block_size < sizeof (struct GNUNET_MessageHeader)) | ||
98 | { | ||
99 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, | ||
100 | "block-dht", | ||
101 | _("Block not of type %u\n"), | ||
102 | GNUNET_BLOCK_TYPE_DHT_HELLO); | ||
103 | return GNUNET_SYSERR; | ||
104 | } | ||
105 | msg = block; | ||
106 | if (block_size != ntohs (msg->size)) | ||
107 | { | ||
108 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, | ||
109 | "block-dht", | ||
110 | _("Size mismatch for block\n"), | ||
111 | GNUNET_BLOCK_TYPE_DHT_HELLO); | ||
112 | return GNUNET_SYSERR; | ||
113 | } | ||
114 | hello = block; | ||
115 | pid = (struct GNUNET_PeerIdentity*) key; | ||
116 | if (GNUNET_OK != | ||
117 | GNUNET_HELLO_get_id (hello, | ||
118 | pid)) | ||
119 | { | ||
120 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, | ||
121 | "block-dht", | ||
122 | _("Block of type %u is malformed\n"), | ||
123 | GNUNET_BLOCK_TYPE_DHT_HELLO); | ||
124 | return GNUNET_SYSERR; | ||
125 | } | ||
126 | return GNUNET_OK; | ||
127 | } | ||
128 | |||
129 | |||
130 | /** | ||
131 | * Entry point for the plugin. | ||
132 | */ | ||
133 | void * | ||
134 | gnunet_plugin_block_dht_init (void *cls) | ||
135 | { | ||
136 | static enum GNUNET_BLOCK_Type types[] = | ||
137 | { | ||
138 | GNUNET_BLOCK_TYPE_DHT_HELLO, | ||
139 | GNUNET_BLOCK_TYPE_ANY /* end of list */ | ||
140 | }; | ||
141 | struct GNUNET_BLOCK_PluginFunctions *api; | ||
142 | |||
143 | api = GNUNET_malloc (sizeof (struct GNUNET_BLOCK_PluginFunctions)); | ||
144 | api->evaluate = &block_plugin_dht_evaluate; | ||
145 | api->get_key = &block_plugin_dht_get_key; | ||
146 | api->types = types; | ||
147 | return api; | ||
148 | } | ||
149 | |||
150 | |||
151 | /** | ||
152 | * Exit point from the plugin. | ||
153 | */ | ||
154 | void * | ||
155 | gnunet_plugin_block_dht_done (void *cls) | ||
156 | { | ||
157 | struct GNUNET_TRANSPORT_PluginFunctions *api = cls; | ||
158 | |||
159 | GNUNET_free (api); | ||
160 | return NULL; | ||
161 | } | ||
162 | |||
163 | /* end of plugin_block_dht.c */ | ||
diff --git a/src/block/plugin_block_fs.c b/src/block/plugin_block_fs.c index 3ad15a0c6..d4e510abe 100644 --- a/src/block/plugin_block_fs.c +++ b/src/block/plugin_block_fs.c | |||
@@ -74,8 +74,8 @@ block_plugin_fs_evaluate (void *cls, | |||
74 | 74 | ||
75 | switch (type) | 75 | switch (type) |
76 | { | 76 | { |
77 | case GNUNET_BLOCK_TYPE_DBLOCK: | 77 | case GNUNET_BLOCK_TYPE_FS_DBLOCK: |
78 | case GNUNET_BLOCK_TYPE_IBLOCK: | 78 | case GNUNET_BLOCK_TYPE_FS_IBLOCK: |
79 | if (xquery_size != 0) | 79 | if (xquery_size != 0) |
80 | { | 80 | { |
81 | GNUNET_break_op (0); | 81 | GNUNET_break_op (0); |
@@ -84,8 +84,8 @@ block_plugin_fs_evaluate (void *cls, | |||
84 | if (reply_block == NULL) | 84 | if (reply_block == NULL) |
85 | return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; | 85 | return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; |
86 | return GNUNET_BLOCK_EVALUATION_OK_LAST; | 86 | return GNUNET_BLOCK_EVALUATION_OK_LAST; |
87 | case GNUNET_BLOCK_TYPE_KBLOCK: | 87 | case GNUNET_BLOCK_TYPE_FS_KBLOCK: |
88 | case GNUNET_BLOCK_TYPE_NBLOCK: | 88 | case GNUNET_BLOCK_TYPE_FS_NBLOCK: |
89 | if (xquery_size != 0) | 89 | if (xquery_size != 0) |
90 | { | 90 | { |
91 | GNUNET_break_op (0); | 91 | GNUNET_break_op (0); |
@@ -111,7 +111,7 @@ block_plugin_fs_evaluate (void *cls, | |||
111 | } | 111 | } |
112 | GNUNET_CONTAINER_bloomfilter_add (*bf, &mhash); | 112 | GNUNET_CONTAINER_bloomfilter_add (*bf, &mhash); |
113 | return GNUNET_BLOCK_EVALUATION_OK_MORE; | 113 | return GNUNET_BLOCK_EVALUATION_OK_MORE; |
114 | case GNUNET_BLOCK_TYPE_SBLOCK: | 114 | case GNUNET_BLOCK_TYPE_FS_SBLOCK: |
115 | if (xquery_size != sizeof (GNUNET_HashCode)) | 115 | if (xquery_size != sizeof (GNUNET_HashCode)) |
116 | { | 116 | { |
117 | GNUNET_break_op (0); | 117 | GNUNET_break_op (0); |
@@ -133,8 +133,9 @@ block_plugin_fs_evaluate (void *cls, | |||
133 | &sh, | 133 | &sh, |
134 | sizeof (GNUNET_HashCode))) | 134 | sizeof (GNUNET_HashCode))) |
135 | { | 135 | { |
136 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 136 | GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, |
137 | _("Reply mismatched in terms of namespace. Discarded.\n")); | 137 | "block-fs", |
138 | _("Reply mismatched in terms of namespace. Discarded.\n")); | ||
138 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; | 139 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; |
139 | } | 140 | } |
140 | GNUNET_CRYPTO_hash (reply_block, | 141 | GNUNET_CRYPTO_hash (reply_block, |
@@ -185,11 +186,11 @@ block_plugin_fs_get_key (void *cls, | |||
185 | 186 | ||
186 | switch (type) | 187 | switch (type) |
187 | { | 188 | { |
188 | case GNUNET_BLOCK_TYPE_DBLOCK: | 189 | case GNUNET_BLOCK_TYPE_FS_DBLOCK: |
189 | case GNUNET_BLOCK_TYPE_IBLOCK: | 190 | case GNUNET_BLOCK_TYPE_FS_IBLOCK: |
190 | GNUNET_CRYPTO_hash (block, block_size, key); | 191 | GNUNET_CRYPTO_hash (block, block_size, key); |
191 | return GNUNET_OK; | 192 | return GNUNET_OK; |
192 | case GNUNET_BLOCK_TYPE_KBLOCK: | 193 | case GNUNET_BLOCK_TYPE_FS_KBLOCK: |
193 | if (block_size < sizeof (struct KBlock)) | 194 | if (block_size < sizeof (struct KBlock)) |
194 | { | 195 | { |
195 | GNUNET_break_op (0); | 196 | GNUNET_break_op (0); |
@@ -218,7 +219,7 @@ block_plugin_fs_get_key (void *cls, | |||
218 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | 219 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), |
219 | key); | 220 | key); |
220 | return GNUNET_OK; | 221 | return GNUNET_OK; |
221 | case GNUNET_BLOCK_TYPE_SBLOCK: | 222 | case GNUNET_BLOCK_TYPE_FS_SBLOCK: |
222 | if (block_size < sizeof (struct SBlock)) | 223 | if (block_size < sizeof (struct SBlock)) |
223 | { | 224 | { |
224 | GNUNET_break_op (0); | 225 | GNUNET_break_op (0); |
@@ -243,7 +244,7 @@ block_plugin_fs_get_key (void *cls, | |||
243 | if (key != NULL) | 244 | if (key != NULL) |
244 | *key = sb->identifier; | 245 | *key = sb->identifier; |
245 | return GNUNET_OK; | 246 | return GNUNET_OK; |
246 | case GNUNET_BLOCK_TYPE_NBLOCK: | 247 | case GNUNET_BLOCK_TYPE_FS_NBLOCK: |
247 | if (block_size < sizeof (struct NBlock)) | 248 | if (block_size < sizeof (struct NBlock)) |
248 | { | 249 | { |
249 | GNUNET_break_op (0); | 250 | GNUNET_break_op (0); |
@@ -303,11 +304,11 @@ libgnunet_plugin_block_fs_init (void *cls) | |||
303 | { | 304 | { |
304 | static enum GNUNET_BLOCK_Type types[] = | 305 | static enum GNUNET_BLOCK_Type types[] = |
305 | { | 306 | { |
306 | GNUNET_BLOCK_TYPE_DBLOCK, | 307 | GNUNET_BLOCK_TYPE_FS_DBLOCK, |
307 | GNUNET_BLOCK_TYPE_IBLOCK, | 308 | GNUNET_BLOCK_TYPE_FS_IBLOCK, |
308 | GNUNET_BLOCK_TYPE_KBLOCK, | 309 | GNUNET_BLOCK_TYPE_FS_KBLOCK, |
309 | GNUNET_BLOCK_TYPE_SBLOCK, | 310 | GNUNET_BLOCK_TYPE_FS_SBLOCK, |
310 | GNUNET_BLOCK_TYPE_NBLOCK, | 311 | GNUNET_BLOCK_TYPE_FS_NBLOCK, |
311 | GNUNET_BLOCK_TYPE_ANY /* end of list */ | 312 | GNUNET_BLOCK_TYPE_ANY /* end of list */ |
312 | }; | 313 | }; |
313 | struct GNUNET_BLOCK_PluginFunctions *api; | 314 | struct GNUNET_BLOCK_PluginFunctions *api; |
diff --git a/src/block/plugin_block_test.c b/src/block/plugin_block_test.c new file mode 100644 index 000000000..1cf8c701d --- /dev/null +++ b/src/block/plugin_block_test.c | |||
@@ -0,0 +1,154 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | (C) 2010 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file block/plugin_block_test.c | ||
23 | * @brief block plugin to test the DHT as a simple key-value store; | ||
24 | * this plugin simply accepts any (new) response for any key | ||
25 | * @author Christian Grothoff | ||
26 | */ | ||
27 | |||
28 | #include "platform.h" | ||
29 | #include "plugin_block.h" | ||
30 | |||
31 | #define DEBUG_TEST GNUNET_NO | ||
32 | |||
33 | |||
34 | /** | ||
35 | * Number of bits we set per entry in the bloomfilter. | ||
36 | * Do not change! | ||
37 | */ | ||
38 | #define BLOOMFILTER_K 16 | ||
39 | |||
40 | /** | ||
41 | * Function called to validate a reply or a request. For | ||
42 | * request evaluation, simply pass "NULL" for the reply_block. | ||
43 | * | ||
44 | * @param cls closure | ||
45 | * @param type block type | ||
46 | * @param query original query (hash) | ||
47 | * @param bf pointer to bloom filter associated with query; possibly updated (!) | ||
48 | * @param bf_mutator mutation value for bf | ||
49 | * @param xquery extrended query data (can be NULL, depending on type) | ||
50 | * @param xquery_size number of bytes in xquery | ||
51 | * @param reply_block response to validate | ||
52 | * @param reply_block_size number of bytes in reply block | ||
53 | * @return characterization of result | ||
54 | */ | ||
55 | static enum GNUNET_BLOCK_EvaluationResult | ||
56 | block_plugin_test_evaluate (void *cls, | ||
57 | enum GNUNET_BLOCK_Type type, | ||
58 | const GNUNET_HashCode *query, | ||
59 | struct GNUNET_CONTAINER_BloomFilter **bf, | ||
60 | int32_t bf_mutator, | ||
61 | const void *xquery, | ||
62 | size_t xquery_size, | ||
63 | const void *reply_block, | ||
64 | size_t reply_block_size) | ||
65 | { | ||
66 | GNUNET_HashCode chash; | ||
67 | GNUNET_HashCode mhash; | ||
68 | |||
69 | if (type != GNUNET_BLOCK_TYPE_TEST) | ||
70 | return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED; | ||
71 | if (xquery_size != 0) | ||
72 | GNUNET_BLOCK_EVALUATION_REQUEST_INVALID; | ||
73 | if (reply_block_size == 0) | ||
74 | GNUNET_BLOCK_EVALUATION_REQUEST_VALID; | ||
75 | |||
76 | GNUNET_CRYPTO_hash (reply_block, | ||
77 | reply_block_size, | ||
78 | &chash); | ||
79 | GNUNET_BLOCK_mingle_hash (&chash, bf_mutator, &mhash); | ||
80 | if (NULL != *bf) | ||
81 | { | ||
82 | if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (*bf, | ||
83 | &mhash)) | ||
84 | return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE; | ||
85 | } | ||
86 | else | ||
87 | { | ||
88 | *bf = GNUNET_CONTAINER_bloomfilter_init (NULL, | ||
89 | 8, | ||
90 | BLOOMFILTER_K); | ||
91 | } | ||
92 | GNUNET_CONTAINER_bloomfilter_add (*bf, &mhash); | ||
93 | return GNUNET_BLOCK_EVALUATION_OK_MORE; | ||
94 | } | ||
95 | |||
96 | |||
97 | /** | ||
98 | * Function called to obtain the key for a block. | ||
99 | * | ||
100 | * @param cls closure | ||
101 | * @param type block type | ||
102 | * @param block block to get the key for | ||
103 | * @param block_size number of bytes in block | ||
104 | * @param key set to the key (query) for the given block | ||
105 | * @return GNUNET_OK on success, GNUNET_SYSERR if type not supported | ||
106 | * (or if extracting a key from a block of this type does not work) | ||
107 | */ | ||
108 | static int | ||
109 | block_plugin_test_get_key (void *cls, | ||
110 | enum GNUNET_BLOCK_Type type, | ||
111 | const void *block, | ||
112 | size_t block_size, | ||
113 | GNUNET_HashCode *key) | ||
114 | { | ||
115 | /* always fails since there is no fixed relationship between | ||
116 | keys and values for test values */ | ||
117 | return GNUNET_SYSERR; | ||
118 | } | ||
119 | |||
120 | |||
121 | /** | ||
122 | * Entry point for the plugin. | ||
123 | */ | ||
124 | void * | ||
125 | gnunet_plugin_block_test_init (void *cls) | ||
126 | { | ||
127 | static enum GNUNET_BLOCK_Type types[] = | ||
128 | { | ||
129 | GNUNET_BLOCK_TYPE_TEST, | ||
130 | GNUNET_BLOCK_TYPE_ANY /* end of list */ | ||
131 | }; | ||
132 | struct GNUNET_BLOCK_PluginFunctions *api; | ||
133 | |||
134 | api = GNUNET_malloc (sizeof (struct GNUNET_BLOCK_PluginFunctions)); | ||
135 | api->evaluate = &block_plugin_test_evaluate; | ||
136 | api->get_key = &block_plugin_test_get_key; | ||
137 | api->types = types; | ||
138 | return api; | ||
139 | } | ||
140 | |||
141 | |||
142 | /** | ||
143 | * Exit point from the plugin. | ||
144 | */ | ||
145 | void * | ||
146 | gnunet_plugin_block_test_done (void *cls) | ||
147 | { | ||
148 | struct GNUNET_TRANSPORT_PluginFunctions *api = cls; | ||
149 | |||
150 | GNUNET_free (api); | ||
151 | return NULL; | ||
152 | } | ||
153 | |||
154 | /* end of plugin_block_test.c */ | ||
diff --git a/src/block/test_block.c b/src/block/test_block.c index 02719e5aa..bb9a1f01b 100644 --- a/src/block/test_block.c +++ b/src/block/test_block.c | |||
@@ -38,14 +38,14 @@ test_fs (struct GNUNET_BLOCK_Context *ctx) | |||
38 | memset (block, 1, sizeof (block)); | 38 | memset (block, 1, sizeof (block)); |
39 | if (GNUNET_OK != | 39 | if (GNUNET_OK != |
40 | GNUNET_BLOCK_get_key (ctx, | 40 | GNUNET_BLOCK_get_key (ctx, |
41 | GNUNET_BLOCK_TYPE_DBLOCK, | 41 | GNUNET_BLOCK_TYPE_FS_DBLOCK, |
42 | block, | 42 | block, |
43 | sizeof (block), | 43 | sizeof (block), |
44 | &key)) | 44 | &key)) |
45 | return 1; | 45 | return 1; |
46 | if (GNUNET_BLOCK_EVALUATION_OK_LAST != | 46 | if (GNUNET_BLOCK_EVALUATION_OK_LAST != |
47 | GNUNET_BLOCK_evaluate (ctx, | 47 | GNUNET_BLOCK_evaluate (ctx, |
48 | GNUNET_BLOCK_TYPE_DBLOCK, | 48 | GNUNET_BLOCK_TYPE_FS_DBLOCK, |
49 | &key, | 49 | &key, |
50 | NULL, 0, | 50 | NULL, 0, |
51 | NULL, 0, | 51 | NULL, 0, |
@@ -53,7 +53,7 @@ test_fs (struct GNUNET_BLOCK_Context *ctx) | |||
53 | return 2; | 53 | return 2; |
54 | if (GNUNET_BLOCK_EVALUATION_REQUEST_VALID != | 54 | if (GNUNET_BLOCK_EVALUATION_REQUEST_VALID != |
55 | GNUNET_BLOCK_evaluate (ctx, | 55 | GNUNET_BLOCK_evaluate (ctx, |
56 | GNUNET_BLOCK_TYPE_DBLOCK, | 56 | GNUNET_BLOCK_TYPE_FS_DBLOCK, |
57 | &key, | 57 | &key, |
58 | NULL, 0, | 58 | NULL, 0, |
59 | NULL, 0, | 59 | NULL, 0, |
@@ -62,7 +62,7 @@ test_fs (struct GNUNET_BLOCK_Context *ctx) | |||
62 | GNUNET_log_skip (1, GNUNET_NO); | 62 | GNUNET_log_skip (1, GNUNET_NO); |
63 | if (GNUNET_BLOCK_EVALUATION_REQUEST_INVALID != | 63 | if (GNUNET_BLOCK_EVALUATION_REQUEST_INVALID != |
64 | GNUNET_BLOCK_evaluate (ctx, | 64 | GNUNET_BLOCK_evaluate (ctx, |
65 | GNUNET_BLOCK_TYPE_DBLOCK, | 65 | GNUNET_BLOCK_TYPE_FS_DBLOCK, |
66 | &key, | 66 | &key, |
67 | NULL, 0, | 67 | NULL, 0, |
68 | "bogus", 5, | 68 | "bogus", 5, |