diff options
Diffstat (limited to 'src/seti/plugin_block_seti_test.c')
-rw-r--r-- | src/seti/plugin_block_seti_test.c | 72 |
1 files changed, 31 insertions, 41 deletions
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 @@ | |||
30 | 30 | ||
31 | 31 | ||
32 | /** | 32 | /** |
33 | * Function called to validate a reply or a request. For | ||
34 | * request evaluation, simply pass "NULL" for the reply_block. | ||
35 | * | ||
36 | * @param cls closure | ||
37 | * @param ctx block context | ||
38 | * @param type block type | ||
39 | * @param group block group to use | ||
40 | * @param eo control flags | ||
41 | * @param query original query (hash) | ||
42 | * @param xquery extrended query data (can be NULL, depending on type) | ||
43 | * @param xquery_size number of bytes in xquery | ||
44 | * @param reply_block response to validate | ||
45 | * @param reply_block_size number of bytes in reply block | ||
46 | * @return characterization of result | ||
47 | */ | ||
48 | static enum GNUNET_BLOCK_EvaluationResult | ||
49 | block_plugin_seti_test_evaluate (void *cls, | ||
50 | struct GNUNET_BLOCK_Context *ctx, | ||
51 | enum GNUNET_BLOCK_Type type, | ||
52 | struct GNUNET_BLOCK_Group *group, | ||
53 | enum GNUNET_BLOCK_EvaluationOptions eo, | ||
54 | const struct GNUNET_HashCode *query, | ||
55 | const void *xquery, | ||
56 | size_t xquery_size, | ||
57 | const void *reply_block, | ||
58 | size_t reply_block_size) | ||
59 | { | ||
60 | if ((NULL == reply_block) || | ||
61 | (reply_block_size == 0) || | ||
62 | (0 != ((char *) reply_block)[0])) | ||
63 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; | ||
64 | return GNUNET_BLOCK_EVALUATION_OK_MORE; | ||
65 | } | ||
66 | |||
67 | |||
68 | /** | ||
69 | * Function called to validate a query. | 33 | * Function called to validate a query. |
70 | * | 34 | * |
71 | * @param cls closure | 35 | * @param cls closure |
@@ -83,6 +47,16 @@ block_plugin_seti_test_check_query (void *cls, | |||
83 | const void *xquery, | 47 | const void *xquery, |
84 | size_t xquery_size) | 48 | size_t xquery_size) |
85 | { | 49 | { |
50 | if (GNUNET_BLOCK_TYPE_SETI_TEST != type) | ||
51 | { | ||
52 | GNUNET_break (0); | ||
53 | return GNUNET_SYSERR; | ||
54 | } | ||
55 | if (0 != xquery_size) | ||
56 | { | ||
57 | GNUNET_break_op (0); | ||
58 | return GNUNET_NO; | ||
59 | } | ||
86 | return GNUNET_OK; | 60 | return GNUNET_OK; |
87 | } | 61 | } |
88 | 62 | ||
@@ -92,7 +66,6 @@ block_plugin_seti_test_check_query (void *cls, | |||
92 | * | 66 | * |
93 | * @param cls closure | 67 | * @param cls closure |
94 | * @param type block type | 68 | * @param type block type |
95 | * @param query key for the block (hash), must match exactly | ||
96 | * @param block block data to validate | 69 | * @param block block data to validate |
97 | * @param block_size number of bytes in @a block | 70 | * @param block_size number of bytes in @a block |
98 | * @return #GNUNET_OK if the block is fine, #GNUNET_NO if not | 71 | * @return #GNUNET_OK if the block is fine, #GNUNET_NO if not |
@@ -100,10 +73,15 @@ block_plugin_seti_test_check_query (void *cls, | |||
100 | static enum GNUNET_GenericReturnValue | 73 | static enum GNUNET_GenericReturnValue |
101 | block_plugin_seti_test_check_block (void *cls, | 74 | block_plugin_seti_test_check_block (void *cls, |
102 | enum GNUNET_BLOCK_Type type, | 75 | enum GNUNET_BLOCK_Type type, |
103 | const struct GNUNET_HashCode *query, | ||
104 | const void *block, | 76 | const void *block, |
105 | size_t block_size) | 77 | size_t block_size) |
106 | { | 78 | { |
79 | (void) cls; | ||
80 | if (GNUNET_BLOCK_TYPE_SETI_TEST != type) | ||
81 | { | ||
82 | GNUNET_break (0); | ||
83 | return GNUNET_SYSERR; | ||
84 | } | ||
107 | if ((NULL == block) || | 85 | if ((NULL == block) || |
108 | (0 == block_size) || | 86 | (0 == block_size) || |
109 | (0 != ((char *) block)[0])) | 87 | (0 != ((char *) block)[0])) |
@@ -138,10 +116,18 @@ block_plugin_seti_test_check_reply (void *cls, | |||
138 | const void *reply_block, | 116 | const void *reply_block, |
139 | size_t reply_block_size) | 117 | size_t reply_block_size) |
140 | { | 118 | { |
119 | (void) cls; | ||
120 | (void) xquery; | ||
121 | (void) xquery_size; | ||
122 | if (GNUNET_BLOCK_TYPE_SETI_TEST != type) | ||
123 | { | ||
124 | GNUNET_break (0); | ||
125 | return GNUNET_BLOCK_REPLY_TYPE_NOT_SUPPORTED; | ||
126 | } | ||
141 | if ( (NULL == reply_block) || | 127 | if ( (NULL == reply_block) || |
142 | (0 == reply_block_size) || | 128 | (0 == reply_block_size) || |
143 | (0 != ((char *) reply_block)[0]) ) | 129 | (0 != ((char *) reply_block)[0]) ) |
144 | return GNUNET_BLOCK_REPLY_INVALID; | 130 | GNUNET_assert (0); |
145 | return GNUNET_BLOCK_REPLY_OK_MORE; | 131 | return GNUNET_BLOCK_REPLY_OK_MORE; |
146 | } | 132 | } |
147 | 133 | ||
@@ -164,7 +150,12 @@ block_plugin_seti_test_get_key (void *cls, | |||
164 | size_t block_size, | 150 | size_t block_size, |
165 | struct GNUNET_HashCode *key) | 151 | struct GNUNET_HashCode *key) |
166 | { | 152 | { |
167 | return GNUNET_SYSERR; | 153 | if (GNUNET_BLOCK_TYPE_SETI_TEST != type) |
154 | { | ||
155 | GNUNET_break (0); | ||
156 | return GNUNET_SYSERR; | ||
157 | } | ||
158 | return GNUNET_NO; | ||
168 | } | 159 | } |
169 | 160 | ||
170 | 161 | ||
@@ -181,7 +172,6 @@ libgnunet_plugin_block_seti_test_init (void *cls) | |||
181 | struct GNUNET_BLOCK_PluginFunctions *api; | 172 | struct GNUNET_BLOCK_PluginFunctions *api; |
182 | 173 | ||
183 | api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions); | 174 | api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions); |
184 | api->evaluate = &block_plugin_seti_test_evaluate; | ||
185 | api->get_key = &block_plugin_seti_test_get_key; | 175 | api->get_key = &block_plugin_seti_test_get_key; |
186 | api->check_query = &block_plugin_seti_test_check_query; | 176 | api->check_query = &block_plugin_seti_test_check_query; |
187 | api->check_block = &block_plugin_seti_test_check_block; | 177 | api->check_block = &block_plugin_seti_test_check_block; |