diff options
Diffstat (limited to 'src/block/plugin_block_template.c')
-rw-r--r-- | src/block/plugin_block_template.c | 83 |
1 files changed, 80 insertions, 3 deletions
diff --git a/src/block/plugin_block_template.c b/src/block/plugin_block_template.c index ecd46e364..13d9adfda 100644 --- a/src/block/plugin_block_template.c +++ b/src/block/plugin_block_template.c | |||
@@ -135,6 +135,80 @@ block_plugin_template_evaluate (void *cls, | |||
135 | 135 | ||
136 | 136 | ||
137 | /** | 137 | /** |
138 | * Function called to validate a query. | ||
139 | * | ||
140 | * @param cls closure | ||
141 | * @param ctx block context | ||
142 | * @param type block type | ||
143 | * @param query original query (hash) | ||
144 | * @param xquery extrended query data (can be NULL, depending on type) | ||
145 | * @param xquery_size number of bytes in @a xquery | ||
146 | * @return #GNUNET_OK if the query is fine, #GNUNET_NO if not | ||
147 | */ | ||
148 | static enum GNUNET_GenericReturnValue | ||
149 | block_plugin_template_check_query (void *cls, | ||
150 | enum GNUNET_BLOCK_Type type, | ||
151 | const struct GNUNET_HashCode *query, | ||
152 | const void *xquery, | ||
153 | size_t xquery_size) | ||
154 | { | ||
155 | return GNUNET_OK; | ||
156 | } | ||
157 | |||
158 | |||
159 | /** | ||
160 | * Function called to validate a block for storage. | ||
161 | * | ||
162 | * @param cls closure | ||
163 | * @param type block type | ||
164 | * @param query key for the block (hash), must match exactly | ||
165 | * @param block block data to validate | ||
166 | * @param block_size number of bytes in @a block | ||
167 | * @return #GNUNET_OK if the block is fine, #GNUNET_NO if not | ||
168 | */ | ||
169 | static enum GNUNET_GenericReturnValue | ||
170 | block_plugin_template_check_block (void *cls, | ||
171 | enum GNUNET_BLOCK_Type type, | ||
172 | const struct GNUNET_HashCode *query, | ||
173 | const void *block, | ||
174 | size_t block_size) | ||
175 | { | ||
176 | return GNUNET_OK; | ||
177 | } | ||
178 | |||
179 | |||
180 | /** | ||
181 | * Function called to validate a reply to a request. Note that it is assumed | ||
182 | * that the reply has already been matched to the key (and signatures checked) | ||
183 | * as it would be done with the GetKeyFunction and the | ||
184 | * BlockEvaluationFunction. | ||
185 | * | ||
186 | * @param cls closure | ||
187 | * @param type block type | ||
188 | * @param group which block group to use for evaluation | ||
189 | * @param query original query (hash) | ||
190 | * @param xquery extrended query data (can be NULL, depending on type) | ||
191 | * @param xquery_size number of bytes in @a xquery | ||
192 | * @param reply_block response to validate | ||
193 | * @param reply_block_size number of bytes in @a reply_block | ||
194 | * @return characterization of result | ||
195 | */ | ||
196 | static enum GNUNET_BLOCK_ReplyEvaluationResult | ||
197 | block_plugin_template_check_reply ( | ||
198 | void *cls, | ||
199 | enum GNUNET_BLOCK_Type type, | ||
200 | struct GNUNET_BLOCK_Group *group, | ||
201 | const struct GNUNET_HashCode *query, | ||
202 | const void *xquery, | ||
203 | size_t xquery_size, | ||
204 | const void *reply_block, | ||
205 | size_t reply_block_size) | ||
206 | { | ||
207 | return GNUNET_BLOCK_REPLY_OK_MORE; | ||
208 | } | ||
209 | |||
210 | |||
211 | /** | ||
138 | * Function called to obtain the key for a block. | 212 | * Function called to obtain the key for a block. |
139 | * | 213 | * |
140 | * @param cls closure | 214 | * @param cls closure |
@@ -145,7 +219,7 @@ block_plugin_template_evaluate (void *cls, | |||
145 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if type not supported | 219 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if type not supported |
146 | * (or if extracting a key from a block of this type does not work) | 220 | * (or if extracting a key from a block of this type does not work) |
147 | */ | 221 | */ |
148 | static int | 222 | static enum GNUNET_GenericReturnValue |
149 | block_plugin_template_get_key (void *cls, | 223 | block_plugin_template_get_key (void *cls, |
150 | enum GNUNET_BLOCK_Type type, | 224 | enum GNUNET_BLOCK_Type type, |
151 | const void *block, | 225 | const void *block, |
@@ -164,8 +238,8 @@ block_plugin_template_get_key (void *cls, | |||
164 | void * | 238 | void * |
165 | libgnunet_plugin_block_template_init (void *cls) | 239 | libgnunet_plugin_block_template_init (void *cls) |
166 | { | 240 | { |
167 | static enum GNUNET_BLOCK_Type types[] = { | 241 | static const enum GNUNET_BLOCK_Type types[] = { |
168 | /* FIXME: insert supported block types here */ | 242 | /* NOTE: insert supported block types here */ |
169 | GNUNET_BLOCK_TYPE_ANY /* end of list */ | 243 | GNUNET_BLOCK_TYPE_ANY /* end of list */ |
170 | }; | 244 | }; |
171 | struct GNUNET_BLOCK_PluginFunctions *api; | 245 | struct GNUNET_BLOCK_PluginFunctions *api; |
@@ -173,6 +247,9 @@ libgnunet_plugin_block_template_init (void *cls) | |||
173 | api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions); | 247 | api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions); |
174 | api->evaluate = &block_plugin_template_evaluate; | 248 | api->evaluate = &block_plugin_template_evaluate; |
175 | api->get_key = &block_plugin_template_get_key; | 249 | api->get_key = &block_plugin_template_get_key; |
250 | api->check_query = &block_plugin_template_check_query; | ||
251 | api->check_block = &block_plugin_template_check_block; | ||
252 | api->check_reply = &block_plugin_template_check_reply; | ||
176 | api->create_group = &block_plugin_template_create_group; | 253 | api->create_group = &block_plugin_template_create_group; |
177 | api->types = types; | 254 | api->types = types; |
178 | return api; | 255 | return api; |