diff options
Diffstat (limited to 'src/regex/plugin_block_regex.c')
-rw-r--r-- | src/regex/plugin_block_regex.c | 121 |
1 files changed, 59 insertions, 62 deletions
diff --git a/src/regex/plugin_block_regex.c b/src/regex/plugin_block_regex.c index 61442ac10..5f23a32df 100644 --- a/src/regex/plugin_block_regex.c +++ b/src/regex/plugin_block_regex.c | |||
@@ -49,7 +49,6 @@ | |||
49 | * | 49 | * |
50 | * @param ctx block context in which the block group is created | 50 | * @param ctx block context in which the block group is created |
51 | * @param type type of the block for which we are creating the group | 51 | * @param type type of the block for which we are creating the group |
52 | * @param nonce random value used to seed the group creation | ||
53 | * @param raw_data optional serialized prior state of the group, NULL if unavailable/fresh | 52 | * @param raw_data optional serialized prior state of the group, NULL if unavailable/fresh |
54 | * @param raw_data_size number of bytes in @a raw_data, 0 if unavailable/fresh | 53 | * @param raw_data_size number of bytes in @a raw_data, 0 if unavailable/fresh |
55 | * @param va variable arguments specific to @a type | 54 | * @param va variable arguments specific to @a type |
@@ -59,7 +58,6 @@ | |||
59 | static struct GNUNET_BLOCK_Group * | 58 | static struct GNUNET_BLOCK_Group * |
60 | block_plugin_regex_create_group (void *cls, | 59 | block_plugin_regex_create_group (void *cls, |
61 | enum GNUNET_BLOCK_Type type, | 60 | enum GNUNET_BLOCK_Type type, |
62 | uint32_t nonce, | ||
63 | const void *raw_data, | 61 | const void *raw_data, |
64 | size_t raw_data_size, | 62 | size_t raw_data_size, |
65 | va_list va) | 63 | va_list va) |
@@ -86,7 +84,6 @@ block_plugin_regex_create_group (void *cls, | |||
86 | bf_size, | 84 | bf_size, |
87 | BLOOMFILTER_K, | 85 | BLOOMFILTER_K, |
88 | type, | 86 | type, |
89 | nonce, | ||
90 | raw_data, | 87 | raw_data, |
91 | raw_data_size); | 88 | raw_data_size); |
92 | } | 89 | } |
@@ -150,9 +147,9 @@ block_plugin_regex_check_query (void *cls, | |||
150 | */ | 147 | */ |
151 | static enum GNUNET_GenericReturnValue | 148 | static enum GNUNET_GenericReturnValue |
152 | block_plugin_regex_check_block (void *cls, | 149 | block_plugin_regex_check_block (void *cls, |
153 | enum GNUNET_BLOCK_Type type, | 150 | enum GNUNET_BLOCK_Type type, |
154 | const void *block, | 151 | const void *block, |
155 | size_t block_size) | 152 | size_t block_size) |
156 | { | 153 | { |
157 | switch (type) | 154 | switch (type) |
158 | { | 155 | { |
@@ -166,37 +163,37 @@ block_plugin_regex_check_block (void *cls, | |||
166 | return GNUNET_OK; | 163 | return GNUNET_OK; |
167 | case GNUNET_BLOCK_TYPE_REGEX_ACCEPT: | 164 | case GNUNET_BLOCK_TYPE_REGEX_ACCEPT: |
168 | { | 165 | { |
169 | const struct RegexAcceptBlock *rba; | 166 | const struct RegexAcceptBlock *rba; |
170 | 167 | ||
171 | if (sizeof(struct RegexAcceptBlock) != block_size) | 168 | if (sizeof(struct RegexAcceptBlock) != block_size) |
172 | { | 169 | { |
173 | GNUNET_break_op (0); | 170 | GNUNET_break_op (0); |
174 | return GNUNET_NO; | 171 | return GNUNET_NO; |
175 | } | 172 | } |
176 | rba = block; | 173 | rba = block; |
177 | if (ntohl (rba->purpose.size) != | 174 | if (ntohl (rba->purpose.size) != |
178 | sizeof(struct GNUNET_CRYPTO_EccSignaturePurpose) | 175 | sizeof(struct GNUNET_CRYPTO_EccSignaturePurpose) |
179 | + sizeof(struct GNUNET_TIME_AbsoluteNBO) | 176 | + sizeof(struct GNUNET_TIME_AbsoluteNBO) |
180 | + sizeof(struct GNUNET_HashCode)) | 177 | + sizeof(struct GNUNET_HashCode)) |
181 | { | 178 | { |
182 | GNUNET_break_op (0); | 179 | GNUNET_break_op (0); |
183 | return GNUNET_NO; | 180 | return GNUNET_NO; |
184 | } | 181 | } |
185 | if (GNUNET_TIME_absolute_is_past (GNUNET_TIME_absolute_ntoh ( | 182 | if (GNUNET_TIME_absolute_is_past (GNUNET_TIME_absolute_ntoh ( |
186 | rba->expiration_time))) | 183 | rba->expiration_time))) |
187 | { | 184 | { |
188 | return GNUNET_NO; | 185 | return GNUNET_NO; |
189 | } | 186 | } |
190 | if (GNUNET_OK != | 187 | if (GNUNET_OK != |
191 | GNUNET_CRYPTO_eddsa_verify_ (GNUNET_SIGNATURE_PURPOSE_REGEX_ACCEPT, | 188 | GNUNET_CRYPTO_eddsa_verify_ (GNUNET_SIGNATURE_PURPOSE_REGEX_ACCEPT, |
192 | &rba->purpose, | 189 | &rba->purpose, |
193 | &rba->signature, | 190 | &rba->signature, |
194 | &rba->peer.public_key)) | 191 | &rba->peer.public_key)) |
195 | { | 192 | { |
196 | GNUNET_break_op (0); | 193 | GNUNET_break_op (0); |
197 | return GNUNET_NO; | 194 | return GNUNET_NO; |
198 | } | 195 | } |
199 | return GNUNET_OK; | 196 | return GNUNET_OK; |
200 | } | 197 | } |
201 | default: | 198 | default: |
202 | GNUNET_break (0); | 199 | GNUNET_break (0); |
@@ -223,14 +220,14 @@ block_plugin_regex_check_block (void *cls, | |||
223 | */ | 220 | */ |
224 | static enum GNUNET_BLOCK_ReplyEvaluationResult | 221 | static enum GNUNET_BLOCK_ReplyEvaluationResult |
225 | block_plugin_regex_check_reply ( | 222 | block_plugin_regex_check_reply ( |
226 | void *cls, | 223 | void *cls, |
227 | enum GNUNET_BLOCK_Type type, | 224 | enum GNUNET_BLOCK_Type type, |
228 | struct GNUNET_BLOCK_Group *group, | 225 | struct GNUNET_BLOCK_Group *group, |
229 | const struct GNUNET_HashCode *query, | 226 | const struct GNUNET_HashCode *query, |
230 | const void *xquery, | 227 | const void *xquery, |
231 | size_t xquery_size, | 228 | size_t xquery_size, |
232 | const void *reply_block, | 229 | const void *reply_block, |
233 | size_t reply_block_size) | 230 | size_t reply_block_size) |
234 | { | 231 | { |
235 | struct GNUNET_HashCode chash; | 232 | struct GNUNET_HashCode chash; |
236 | 233 | ||
@@ -240,7 +237,7 @@ block_plugin_regex_check_reply ( | |||
240 | if (0 != xquery_size) | 237 | if (0 != xquery_size) |
241 | { | 238 | { |
242 | const char *s; | 239 | const char *s; |
243 | 240 | ||
244 | s = (const char *) xquery; | 241 | s = (const char *) xquery; |
245 | GNUNET_assert ('\0' == s[xquery_size - 1]); | 242 | GNUNET_assert ('\0' == s[xquery_size - 1]); |
246 | } | 243 | } |
@@ -267,22 +264,22 @@ block_plugin_regex_check_reply ( | |||
267 | return GNUNET_BLOCK_REPLY_OK_MORE; | 264 | return GNUNET_BLOCK_REPLY_OK_MORE; |
268 | case GNUNET_BLOCK_TYPE_REGEX_ACCEPT: | 265 | case GNUNET_BLOCK_TYPE_REGEX_ACCEPT: |
269 | { | 266 | { |
270 | const struct RegexAcceptBlock *rba; | 267 | const struct RegexAcceptBlock *rba; |
271 | 268 | ||
272 | GNUNET_assert (sizeof(struct RegexAcceptBlock) == reply_block_size); | 269 | GNUNET_assert (sizeof(struct RegexAcceptBlock) == reply_block_size); |
273 | rba = reply_block; | 270 | rba = reply_block; |
274 | GNUNET_assert (ntohl (rba->purpose.size) == | 271 | GNUNET_assert (ntohl (rba->purpose.size) == |
275 | sizeof(struct GNUNET_CRYPTO_EccSignaturePurpose) | 272 | sizeof(struct GNUNET_CRYPTO_EccSignaturePurpose) |
276 | + sizeof(struct GNUNET_TIME_AbsoluteNBO) | 273 | + sizeof(struct GNUNET_TIME_AbsoluteNBO) |
277 | + sizeof(struct GNUNET_HashCode)); | 274 | + sizeof(struct GNUNET_HashCode)); |
278 | GNUNET_CRYPTO_hash (reply_block, | 275 | GNUNET_CRYPTO_hash (reply_block, |
279 | reply_block_size, | 276 | reply_block_size, |
280 | &chash); | 277 | &chash); |
281 | if (GNUNET_YES == | 278 | if (GNUNET_YES == |
282 | GNUNET_BLOCK_GROUP_bf_test_and_set (group, | 279 | GNUNET_BLOCK_GROUP_bf_test_and_set (group, |
283 | &chash)) | 280 | &chash)) |
284 | return GNUNET_BLOCK_REPLY_OK_DUPLICATE; | 281 | return GNUNET_BLOCK_REPLY_OK_DUPLICATE; |
285 | return GNUNET_BLOCK_REPLY_OK_MORE; | 282 | return GNUNET_BLOCK_REPLY_OK_MORE; |
286 | } | 283 | } |
287 | default: | 284 | default: |
288 | GNUNET_break (0); | 285 | GNUNET_break (0); |