diff options
Diffstat (limited to 'src/revocation/gnunet-service-revocation.c')
-rw-r--r-- | src/revocation/gnunet-service-revocation.c | 943 |
1 files changed, 474 insertions, 469 deletions
diff --git a/src/revocation/gnunet-service-revocation.c b/src/revocation/gnunet-service-revocation.c index 62be5a96b..8be2d3926 100644 --- a/src/revocation/gnunet-service-revocation.c +++ b/src/revocation/gnunet-service-revocation.c | |||
@@ -53,7 +53,8 @@ | |||
53 | /** | 53 | /** |
54 | * Per-peer information. | 54 | * Per-peer information. |
55 | */ | 55 | */ |
56 | struct PeerEntry { | 56 | struct PeerEntry |
57 | { | ||
57 | /** | 58 | /** |
58 | * Queue for sending messages to this peer. | 59 | * Queue for sending messages to this peer. |
59 | */ | 60 | */ |
@@ -141,17 +142,17 @@ static struct GNUNET_HashCode revocation_set_union_app_id; | |||
141 | * @return a pointer to the new PeerEntry | 142 | * @return a pointer to the new PeerEntry |
142 | */ | 143 | */ |
143 | static struct PeerEntry * | 144 | static struct PeerEntry * |
144 | new_peer_entry(const struct GNUNET_PeerIdentity *peer) | 145 | new_peer_entry (const struct GNUNET_PeerIdentity *peer) |
145 | { | 146 | { |
146 | struct PeerEntry *peer_entry; | 147 | struct PeerEntry *peer_entry; |
147 | 148 | ||
148 | peer_entry = GNUNET_new(struct PeerEntry); | 149 | peer_entry = GNUNET_new (struct PeerEntry); |
149 | peer_entry->id = *peer; | 150 | peer_entry->id = *peer; |
150 | GNUNET_assert(GNUNET_OK == | 151 | GNUNET_assert (GNUNET_OK == |
151 | GNUNET_CONTAINER_multipeermap_put(peers, | 152 | GNUNET_CONTAINER_multipeermap_put (peers, |
152 | &peer_entry->id, | 153 | &peer_entry->id, |
153 | peer_entry, | 154 | peer_entry, |
154 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 155 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
155 | return peer_entry; | 156 | return peer_entry; |
156 | } | 157 | } |
157 | 158 | ||
@@ -164,27 +165,27 @@ new_peer_entry(const struct GNUNET_PeerIdentity *peer) | |||
164 | * #GNUNET_NO if the key/signature don't verify | 165 | * #GNUNET_NO if the key/signature don't verify |
165 | */ | 166 | */ |
166 | static int | 167 | static int |
167 | verify_revoke_message(const struct RevokeMessage *rm) | 168 | verify_revoke_message (const struct RevokeMessage *rm) |
168 | { | 169 | { |
169 | if (GNUNET_YES != | 170 | if (GNUNET_YES != |
170 | GNUNET_REVOCATION_check_pow(&rm->public_key, | 171 | GNUNET_REVOCATION_check_pow (&rm->public_key, |
171 | rm->proof_of_work, | 172 | rm->proof_of_work, |
172 | (unsigned int)revocation_work_required)) | 173 | (unsigned int) revocation_work_required)) |
173 | { | 174 | { |
174 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 175 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
175 | "Proof of work invalid!\n"); | 176 | "Proof of work invalid!\n"); |
176 | GNUNET_break_op(0); | 177 | GNUNET_break_op (0); |
177 | return GNUNET_NO; | 178 | return GNUNET_NO; |
178 | } | 179 | } |
179 | if (GNUNET_OK != | 180 | if (GNUNET_OK != |
180 | GNUNET_CRYPTO_ecdsa_verify(GNUNET_SIGNATURE_PURPOSE_REVOCATION, | 181 | GNUNET_CRYPTO_ecdsa_verify (GNUNET_SIGNATURE_PURPOSE_REVOCATION, |
181 | &rm->purpose, | 182 | &rm->purpose, |
182 | &rm->signature, | 183 | &rm->signature, |
183 | &rm->public_key)) | 184 | &rm->public_key)) |
184 | { | 185 | { |
185 | GNUNET_break_op(0); | 186 | GNUNET_break_op (0); |
186 | return GNUNET_NO; | 187 | return GNUNET_NO; |
187 | } | 188 | } |
188 | return GNUNET_YES; | 189 | return GNUNET_YES; |
189 | } | 190 | } |
190 | 191 | ||
@@ -198,9 +199,9 @@ verify_revoke_message(const struct RevokeMessage *rm) | |||
198 | * @return @a client | 199 | * @return @a client |
199 | */ | 200 | */ |
200 | static void * | 201 | static void * |
201 | client_connect_cb(void *cls, | 202 | client_connect_cb (void *cls, |
202 | struct GNUNET_SERVICE_Client *client, | 203 | struct GNUNET_SERVICE_Client *client, |
203 | struct GNUNET_MQ_Handle *mq) | 204 | struct GNUNET_MQ_Handle *mq) |
204 | { | 205 | { |
205 | return client; | 206 | return client; |
206 | } | 207 | } |
@@ -214,11 +215,11 @@ client_connect_cb(void *cls, | |||
214 | * @param app_cls must alias @a client | 215 | * @param app_cls must alias @a client |
215 | */ | 216 | */ |
216 | static void | 217 | static void |
217 | client_disconnect_cb(void *cls, | 218 | client_disconnect_cb (void *cls, |
218 | struct GNUNET_SERVICE_Client *client, | 219 | struct GNUNET_SERVICE_Client *client, |
219 | void *app_cls) | 220 | void *app_cls) |
220 | { | 221 | { |
221 | GNUNET_assert(client == app_cls); | 222 | GNUNET_assert (client == app_cls); |
222 | } | 223 | } |
223 | 224 | ||
224 | 225 | ||
@@ -229,8 +230,8 @@ client_disconnect_cb(void *cls, | |||
229 | * @param qm the message received | 230 | * @param qm the message received |
230 | */ | 231 | */ |
231 | static void | 232 | static void |
232 | handle_query_message(void *cls, | 233 | handle_query_message (void *cls, |
233 | const struct QueryMessage *qm) | 234 | const struct QueryMessage *qm) |
234 | { | 235 | { |
235 | struct GNUNET_SERVICE_Client *client = cls; | 236 | struct GNUNET_SERVICE_Client *client = cls; |
236 | struct GNUNET_MQ_Envelope *env; | 237 | struct GNUNET_MQ_Envelope *env; |
@@ -238,22 +239,22 @@ handle_query_message(void *cls, | |||
238 | struct GNUNET_HashCode hc; | 239 | struct GNUNET_HashCode hc; |
239 | int res; | 240 | int res; |
240 | 241 | ||
241 | GNUNET_CRYPTO_hash(&qm->key, | 242 | GNUNET_CRYPTO_hash (&qm->key, |
242 | sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey), | 243 | sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey), |
243 | &hc); | 244 | &hc); |
244 | res = GNUNET_CONTAINER_multihashmap_contains(revocation_map, | 245 | res = GNUNET_CONTAINER_multihashmap_contains (revocation_map, |
245 | &hc); | 246 | &hc); |
246 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 247 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
247 | (GNUNET_NO == res) | 248 | (GNUNET_NO == res) |
248 | ? "Received revocation check for valid key `%s' from client\n" | 249 | ? "Received revocation check for valid key `%s' from client\n" |
249 | : "Received revocation check for revoked key `%s' from client\n", | 250 | : "Received revocation check for revoked key `%s' from client\n", |
250 | GNUNET_h2s(&hc)); | 251 | GNUNET_h2s (&hc)); |
251 | env = GNUNET_MQ_msg(qrm, | 252 | env = GNUNET_MQ_msg (qrm, |
252 | GNUNET_MESSAGE_TYPE_REVOCATION_QUERY_RESPONSE); | 253 | GNUNET_MESSAGE_TYPE_REVOCATION_QUERY_RESPONSE); |
253 | qrm->is_valid = htonl((GNUNET_YES == res) ? GNUNET_NO : GNUNET_YES); | 254 | qrm->is_valid = htonl ((GNUNET_YES == res) ? GNUNET_NO : GNUNET_YES); |
254 | GNUNET_MQ_send(GNUNET_SERVICE_client_get_mq(client), | 255 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), |
255 | env); | 256 | env); |
256 | GNUNET_SERVICE_client_continue(client); | 257 | GNUNET_SERVICE_client_continue (client); |
257 | } | 258 | } |
258 | 259 | ||
259 | 260 | ||
@@ -266,9 +267,9 @@ handle_query_message(void *cls, | |||
266 | * @return #GNUNET_OK (continue to iterate) | 267 | * @return #GNUNET_OK (continue to iterate) |
267 | */ | 268 | */ |
268 | static int | 269 | static int |
269 | do_flood(void *cls, | 270 | do_flood (void *cls, |
270 | const struct GNUNET_PeerIdentity *target, | 271 | const struct GNUNET_PeerIdentity *target, |
271 | void *value) | 272 | void *value) |
272 | { | 273 | { |
273 | const struct RevokeMessage *rm = cls; | 274 | const struct RevokeMessage *rm = cls; |
274 | struct PeerEntry *pe = value; | 275 | struct PeerEntry *pe = value; |
@@ -279,14 +280,14 @@ do_flood(void *cls, | |||
279 | return GNUNET_OK; /* peer connected to us via SET, | 280 | return GNUNET_OK; /* peer connected to us via SET, |
280 | but we have no direct CORE | 281 | but we have no direct CORE |
281 | connection for flooding */ | 282 | connection for flooding */ |
282 | e = GNUNET_MQ_msg(cp, | 283 | e = GNUNET_MQ_msg (cp, |
283 | GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE); | 284 | GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE); |
284 | *cp = *rm; | 285 | *cp = *rm; |
285 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 286 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
286 | "Flooding revocation to `%s'\n", | 287 | "Flooding revocation to `%s'\n", |
287 | GNUNET_i2s(target)); | 288 | GNUNET_i2s (target)); |
288 | GNUNET_MQ_send(pe->mq, | 289 | GNUNET_MQ_send (pe->mq, |
289 | e); | 290 | e); |
290 | return GNUNET_OK; | 291 | return GNUNET_OK; |
291 | } | 292 | } |
292 | 293 | ||
@@ -301,75 +302,75 @@ do_flood(void *cls, | |||
301 | * #GNUNET_SYSERR if the message was malformed | 302 | * #GNUNET_SYSERR if the message was malformed |
302 | */ | 303 | */ |
303 | static int | 304 | static int |
304 | publicize_rm(const struct RevokeMessage *rm) | 305 | publicize_rm (const struct RevokeMessage *rm) |
305 | { | 306 | { |
306 | struct RevokeMessage *cp; | 307 | struct RevokeMessage *cp; |
307 | struct GNUNET_HashCode hc; | 308 | struct GNUNET_HashCode hc; |
308 | struct GNUNET_SET_Element e; | 309 | struct GNUNET_SET_Element e; |
309 | 310 | ||
310 | GNUNET_CRYPTO_hash(&rm->public_key, | 311 | GNUNET_CRYPTO_hash (&rm->public_key, |
311 | sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey), | 312 | sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey), |
312 | &hc); | 313 | &hc); |
313 | if (GNUNET_YES == | 314 | if (GNUNET_YES == |
314 | GNUNET_CONTAINER_multihashmap_contains(revocation_map, | 315 | GNUNET_CONTAINER_multihashmap_contains (revocation_map, |
315 | &hc)) | 316 | &hc)) |
316 | { | 317 | { |
317 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 318 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
318 | "Duplicate revocation received from peer. Ignored.\n"); | 319 | "Duplicate revocation received from peer. Ignored.\n"); |
319 | return GNUNET_OK; | 320 | return GNUNET_OK; |
320 | } | 321 | } |
321 | if (GNUNET_OK != | 322 | if (GNUNET_OK != |
322 | verify_revoke_message(rm)) | 323 | verify_revoke_message (rm)) |
323 | { | 324 | { |
324 | GNUNET_break_op(0); | 325 | GNUNET_break_op (0); |
325 | return GNUNET_SYSERR; | 326 | return GNUNET_SYSERR; |
326 | } | 327 | } |
327 | /* write to disk */ | 328 | /* write to disk */ |
328 | if (sizeof(struct RevokeMessage) != | 329 | if (sizeof(struct RevokeMessage) != |
329 | GNUNET_DISK_file_write(revocation_db, | 330 | GNUNET_DISK_file_write (revocation_db, |
330 | rm, | 331 | rm, |
331 | sizeof(struct RevokeMessage))) | 332 | sizeof(struct RevokeMessage))) |
332 | { | 333 | { |
333 | GNUNET_log_strerror(GNUNET_ERROR_TYPE_ERROR, | 334 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, |
334 | "write"); | 335 | "write"); |
335 | return GNUNET_NO; | 336 | return GNUNET_NO; |
336 | } | 337 | } |
337 | if (GNUNET_OK != | 338 | if (GNUNET_OK != |
338 | GNUNET_DISK_file_sync(revocation_db)) | 339 | GNUNET_DISK_file_sync (revocation_db)) |
339 | { | 340 | { |
340 | GNUNET_log_strerror(GNUNET_ERROR_TYPE_ERROR, | 341 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, |
341 | "sync"); | 342 | "sync"); |
342 | return GNUNET_NO; | 343 | return GNUNET_NO; |
343 | } | 344 | } |
344 | /* keep copy in memory */ | 345 | /* keep copy in memory */ |
345 | cp = (struct RevokeMessage *)GNUNET_copy_message(&rm->header); | 346 | cp = (struct RevokeMessage *) GNUNET_copy_message (&rm->header); |
346 | GNUNET_break(GNUNET_OK == | 347 | GNUNET_break (GNUNET_OK == |
347 | GNUNET_CONTAINER_multihashmap_put(revocation_map, | 348 | GNUNET_CONTAINER_multihashmap_put (revocation_map, |
348 | &hc, | 349 | &hc, |
349 | cp, | 350 | cp, |
350 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 351 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
351 | /* add to set for future connections */ | 352 | /* add to set for future connections */ |
352 | e.size = htons(rm->header.size); | 353 | e.size = htons (rm->header.size); |
353 | e.element_type = GNUNET_BLOCK_TYPE_REVOCATION; | 354 | e.element_type = GNUNET_BLOCK_TYPE_REVOCATION; |
354 | e.data = rm; | 355 | e.data = rm; |
355 | if (GNUNET_OK != | 356 | if (GNUNET_OK != |
356 | GNUNET_SET_add_element(revocation_set, | 357 | GNUNET_SET_add_element (revocation_set, |
357 | &e, | 358 | &e, |
358 | NULL, | 359 | NULL, |
359 | NULL)) | 360 | NULL)) |
360 | { | 361 | { |
361 | GNUNET_break(0); | 362 | GNUNET_break (0); |
362 | return GNUNET_OK; | 363 | return GNUNET_OK; |
363 | } | 364 | } |
364 | else | 365 | else |
365 | { | 366 | { |
366 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 367 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
367 | "Added revocation info to SET\n"); | 368 | "Added revocation info to SET\n"); |
368 | } | 369 | } |
369 | /* flood to neighbours */ | 370 | /* flood to neighbours */ |
370 | GNUNET_CONTAINER_multipeermap_iterate(peers, | 371 | GNUNET_CONTAINER_multipeermap_iterate (peers, |
371 | &do_flood, | 372 | &do_flood, |
372 | cp); | 373 | cp); |
373 | return GNUNET_OK; | 374 | return GNUNET_OK; |
374 | } | 375 | } |
375 | 376 | ||
@@ -381,28 +382,28 @@ publicize_rm(const struct RevokeMessage *rm) | |||
381 | * @param rm the message received | 382 | * @param rm the message received |
382 | */ | 383 | */ |
383 | static void | 384 | static void |
384 | handle_revoke_message(void *cls, | 385 | handle_revoke_message (void *cls, |
385 | const struct RevokeMessage *rm) | 386 | const struct RevokeMessage *rm) |
386 | { | 387 | { |
387 | struct GNUNET_SERVICE_Client *client = cls; | 388 | struct GNUNET_SERVICE_Client *client = cls; |
388 | struct GNUNET_MQ_Envelope *env; | 389 | struct GNUNET_MQ_Envelope *env; |
389 | struct RevocationResponseMessage *rrm; | 390 | struct RevocationResponseMessage *rrm; |
390 | int ret; | 391 | int ret; |
391 | 392 | ||
392 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 393 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
393 | "Received REVOKE message from client\n"); | 394 | "Received REVOKE message from client\n"); |
394 | if (GNUNET_SYSERR == (ret = publicize_rm(rm))) | 395 | if (GNUNET_SYSERR == (ret = publicize_rm (rm))) |
395 | { | 396 | { |
396 | GNUNET_break_op(0); | 397 | GNUNET_break_op (0); |
397 | GNUNET_SERVICE_client_drop(client); | 398 | GNUNET_SERVICE_client_drop (client); |
398 | return; | 399 | return; |
399 | } | 400 | } |
400 | env = GNUNET_MQ_msg(rrm, | 401 | env = GNUNET_MQ_msg (rrm, |
401 | GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE_RESPONSE); | 402 | GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE_RESPONSE); |
402 | rrm->is_valid = htonl((GNUNET_OK == ret) ? GNUNET_NO : GNUNET_YES); | 403 | rrm->is_valid = htonl ((GNUNET_OK == ret) ? GNUNET_NO : GNUNET_YES); |
403 | GNUNET_MQ_send(GNUNET_SERVICE_client_get_mq(client), | 404 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), |
404 | env); | 405 | env); |
405 | GNUNET_SERVICE_client_continue(client); | 406 | GNUNET_SERVICE_client_continue (client); |
406 | } | 407 | } |
407 | 408 | ||
408 | 409 | ||
@@ -413,13 +414,13 @@ handle_revoke_message(void *cls, | |||
413 | * @param rm revocation message | 414 | * @param rm revocation message |
414 | */ | 415 | */ |
415 | static void | 416 | static void |
416 | handle_p2p_revoke(void *cls, | 417 | handle_p2p_revoke (void *cls, |
417 | const struct RevokeMessage *rm) | 418 | const struct RevokeMessage *rm) |
418 | { | 419 | { |
419 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 420 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
420 | "Received REVOKE message\n"); | 421 | "Received REVOKE message\n"); |
421 | GNUNET_break_op(GNUNET_SYSERR != | 422 | GNUNET_break_op (GNUNET_SYSERR != |
422 | publicize_rm(rm)); | 423 | publicize_rm (rm)); |
423 | } | 424 | } |
424 | 425 | ||
425 | 426 | ||
@@ -434,64 +435,67 @@ handle_p2p_revoke(void *cls, | |||
434 | * @param status see `enum GNUNET_SET_Status` | 435 | * @param status see `enum GNUNET_SET_Status` |
435 | */ | 436 | */ |
436 | static void | 437 | static void |
437 | add_revocation(void *cls, | 438 | add_revocation (void *cls, |
438 | const struct GNUNET_SET_Element *element, | 439 | const struct GNUNET_SET_Element *element, |
439 | uint64_t current_size, | 440 | uint64_t current_size, |
440 | enum GNUNET_SET_Status status) | 441 | enum GNUNET_SET_Status status) |
441 | { | 442 | { |
442 | struct PeerEntry *peer_entry = cls; | 443 | struct PeerEntry *peer_entry = cls; |
443 | const struct RevokeMessage *rm; | 444 | const struct RevokeMessage *rm; |
444 | 445 | ||
445 | switch (status) | 446 | switch (status) |
447 | { | ||
448 | case GNUNET_SET_STATUS_OK: | ||
449 | if (element->size != sizeof(struct RevokeMessage)) | ||
446 | { | 450 | { |
447 | case GNUNET_SET_STATUS_OK: | 451 | GNUNET_break_op (0); |
448 | if (element->size != sizeof(struct RevokeMessage)) | 452 | return; |
449 | { | 453 | } |
450 | GNUNET_break_op(0); | 454 | if (GNUNET_BLOCK_TYPE_REVOCATION != element->element_type) |
451 | return; | 455 | { |
452 | } | 456 | GNUNET_STATISTICS_update (stats, |
453 | if (GNUNET_BLOCK_TYPE_REVOCATION != element->element_type) | 457 | gettext_noop ( |
454 | { | 458 | "# unsupported revocations received via set union"), |
455 | GNUNET_STATISTICS_update(stats, | 459 | 1, |
456 | gettext_noop("# unsupported revocations received via set union"), | 460 | GNUNET_NO); |
457 | 1, | 461 | return; |
458 | GNUNET_NO); | ||
459 | return; | ||
460 | } | ||
461 | rm = element->data; | ||
462 | (void)handle_p2p_revoke(NULL, | ||
463 | rm); | ||
464 | GNUNET_STATISTICS_update(stats, | ||
465 | gettext_noop("# revocation messages received via set union"), | ||
466 | 1, GNUNET_NO); | ||
467 | break; | ||
468 | |||
469 | case GNUNET_SET_STATUS_FAILURE: | ||
470 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, | ||
471 | _("Error computing revocation set union with %s\n"), | ||
472 | GNUNET_i2s(&peer_entry->id)); | ||
473 | peer_entry->so = NULL; | ||
474 | GNUNET_STATISTICS_update(stats, | ||
475 | gettext_noop("# revocation set unions failed"), | ||
476 | 1, | ||
477 | GNUNET_NO); | ||
478 | break; | ||
479 | |||
480 | case GNUNET_SET_STATUS_HALF_DONE: | ||
481 | break; | ||
482 | |||
483 | case GNUNET_SET_STATUS_DONE: | ||
484 | peer_entry->so = NULL; | ||
485 | GNUNET_STATISTICS_update(stats, | ||
486 | gettext_noop("# revocation set unions completed"), | ||
487 | 1, | ||
488 | GNUNET_NO); | ||
489 | break; | ||
490 | |||
491 | default: | ||
492 | GNUNET_break(0); | ||
493 | break; | ||
494 | } | 462 | } |
463 | rm = element->data; | ||
464 | (void) handle_p2p_revoke (NULL, | ||
465 | rm); | ||
466 | GNUNET_STATISTICS_update (stats, | ||
467 | gettext_noop ( | ||
468 | "# revocation messages received via set union"), | ||
469 | 1, GNUNET_NO); | ||
470 | break; | ||
471 | |||
472 | case GNUNET_SET_STATUS_FAILURE: | ||
473 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
474 | _ ("Error computing revocation set union with %s\n"), | ||
475 | GNUNET_i2s (&peer_entry->id)); | ||
476 | peer_entry->so = NULL; | ||
477 | GNUNET_STATISTICS_update (stats, | ||
478 | gettext_noop ("# revocation set unions failed"), | ||
479 | 1, | ||
480 | GNUNET_NO); | ||
481 | break; | ||
482 | |||
483 | case GNUNET_SET_STATUS_HALF_DONE: | ||
484 | break; | ||
485 | |||
486 | case GNUNET_SET_STATUS_DONE: | ||
487 | peer_entry->so = NULL; | ||
488 | GNUNET_STATISTICS_update (stats, | ||
489 | gettext_noop ( | ||
490 | "# revocation set unions completed"), | ||
491 | 1, | ||
492 | GNUNET_NO); | ||
493 | break; | ||
494 | |||
495 | default: | ||
496 | GNUNET_break (0); | ||
497 | break; | ||
498 | } | ||
495 | } | 499 | } |
496 | 500 | ||
497 | 501 | ||
@@ -502,31 +506,31 @@ add_revocation(void *cls, | |||
502 | * @param cls NULL | 506 | * @param cls NULL |
503 | */ | 507 | */ |
504 | static void | 508 | static void |
505 | transmit_task_cb(void *cls) | 509 | transmit_task_cb (void *cls) |
506 | { | 510 | { |
507 | struct PeerEntry *peer_entry = cls; | 511 | struct PeerEntry *peer_entry = cls; |
508 | 512 | ||
509 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 513 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
510 | "Starting set exchange with peer `%s'\n", | 514 | "Starting set exchange with peer `%s'\n", |
511 | GNUNET_i2s(&peer_entry->id)); | 515 | GNUNET_i2s (&peer_entry->id)); |
512 | peer_entry->transmit_task = NULL; | 516 | peer_entry->transmit_task = NULL; |
513 | GNUNET_assert(NULL == peer_entry->so); | 517 | GNUNET_assert (NULL == peer_entry->so); |
514 | peer_entry->so = GNUNET_SET_prepare(&peer_entry->id, | 518 | peer_entry->so = GNUNET_SET_prepare (&peer_entry->id, |
515 | &revocation_set_union_app_id, | 519 | &revocation_set_union_app_id, |
516 | NULL, | 520 | NULL, |
517 | GNUNET_SET_RESULT_ADDED, | 521 | GNUNET_SET_RESULT_ADDED, |
518 | (struct GNUNET_SET_Option[]) { { 0 } }, | 522 | (struct GNUNET_SET_Option[]) { { 0 } }, |
519 | &add_revocation, | 523 | &add_revocation, |
520 | peer_entry); | 524 | peer_entry); |
521 | if (GNUNET_OK != | 525 | if (GNUNET_OK != |
522 | GNUNET_SET_commit(peer_entry->so, | 526 | GNUNET_SET_commit (peer_entry->so, |
523 | revocation_set)) | 527 | revocation_set)) |
524 | { | 528 | { |
525 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, | 529 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
526 | _("SET service crashed, terminating revocation service\n")); | 530 | _ ("SET service crashed, terminating revocation service\n")); |
527 | GNUNET_SCHEDULER_shutdown(); | 531 | GNUNET_SCHEDULER_shutdown (); |
528 | return; | 532 | return; |
529 | } | 533 | } |
530 | } | 534 | } |
531 | 535 | ||
532 | 536 | ||
@@ -538,57 +542,57 @@ transmit_task_cb(void *cls) | |||
538 | * @param peer peer identity this notification is about | 542 | * @param peer peer identity this notification is about |
539 | */ | 543 | */ |
540 | static void * | 544 | static void * |
541 | handle_core_connect(void *cls, | 545 | handle_core_connect (void *cls, |
542 | const struct GNUNET_PeerIdentity *peer, | 546 | const struct GNUNET_PeerIdentity *peer, |
543 | struct GNUNET_MQ_Handle *mq) | 547 | struct GNUNET_MQ_Handle *mq) |
544 | { | 548 | { |
545 | struct PeerEntry *peer_entry; | 549 | struct PeerEntry *peer_entry; |
546 | struct GNUNET_HashCode my_hash; | 550 | struct GNUNET_HashCode my_hash; |
547 | struct GNUNET_HashCode peer_hash; | 551 | struct GNUNET_HashCode peer_hash; |
548 | 552 | ||
549 | if (0 == GNUNET_memcmp(peer, | 553 | if (0 == GNUNET_memcmp (peer, |
550 | &my_identity)) | 554 | &my_identity)) |
551 | { | 555 | { |
552 | return NULL; | 556 | return NULL; |
553 | } | 557 | } |
554 | 558 | ||
555 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 559 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
556 | "Peer `%s' connected to us\n", | 560 | "Peer `%s' connected to us\n", |
557 | GNUNET_i2s(peer)); | 561 | GNUNET_i2s (peer)); |
558 | GNUNET_STATISTICS_update(stats, | 562 | GNUNET_STATISTICS_update (stats, |
559 | "# peers connected", | 563 | "# peers connected", |
560 | 1, | 564 | 1, |
561 | GNUNET_NO); | 565 | GNUNET_NO); |
562 | peer_entry = GNUNET_CONTAINER_multipeermap_get(peers, | 566 | peer_entry = GNUNET_CONTAINER_multipeermap_get (peers, |
563 | peer); | 567 | peer); |
564 | if (NULL != peer_entry) | 568 | if (NULL != peer_entry) |
565 | { | 569 | { |
566 | /* This can happen if "core"'s notification is a tad late | 570 | /* This can happen if "core"'s notification is a tad late |
567 | and CADET+SET were faster and already produced a | 571 | and CADET+SET were faster and already produced a |
568 | #handle_revocation_union_request() for us to deal | 572 | #handle_revocation_union_request() for us to deal |
569 | with. This should be rare, but isn't impossible. */ | 573 | with. This should be rare, but isn't impossible. */ |
570 | peer_entry->mq = mq; | 574 | peer_entry->mq = mq; |
571 | return peer_entry; | 575 | return peer_entry; |
572 | } | 576 | } |
573 | peer_entry = new_peer_entry(peer); | 577 | peer_entry = new_peer_entry (peer); |
574 | peer_entry->mq = mq; | 578 | peer_entry->mq = mq; |
575 | GNUNET_CRYPTO_hash(&my_identity, | 579 | GNUNET_CRYPTO_hash (&my_identity, |
576 | sizeof(my_identity), | 580 | sizeof(my_identity), |
577 | &my_hash); | 581 | &my_hash); |
578 | GNUNET_CRYPTO_hash(peer, | 582 | GNUNET_CRYPTO_hash (peer, |
579 | sizeof(*peer), | 583 | sizeof(*peer), |
580 | &peer_hash); | 584 | &peer_hash); |
581 | if (0 < GNUNET_CRYPTO_hash_cmp(&my_hash, | 585 | if (0 < GNUNET_CRYPTO_hash_cmp (&my_hash, |
582 | &peer_hash)) | 586 | &peer_hash)) |
583 | { | 587 | { |
584 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 588 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
585 | "Starting SET operation with peer `%s'\n", | 589 | "Starting SET operation with peer `%s'\n", |
586 | GNUNET_i2s(peer)); | 590 | GNUNET_i2s (peer)); |
587 | peer_entry->transmit_task = | 591 | peer_entry->transmit_task = |
588 | GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_SECONDS, | 592 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, |
589 | &transmit_task_cb, | 593 | &transmit_task_cb, |
590 | peer_entry); | 594 | peer_entry); |
591 | } | 595 | } |
592 | return peer_entry; | 596 | return peer_entry; |
593 | } | 597 | } |
594 | 598 | ||
@@ -602,38 +606,38 @@ handle_core_connect(void *cls, | |||
602 | * @param internal_cls our `struct PeerEntry` for this peer | 606 | * @param internal_cls our `struct PeerEntry` for this peer |
603 | */ | 607 | */ |
604 | static void | 608 | static void |
605 | handle_core_disconnect(void *cls, | 609 | handle_core_disconnect (void *cls, |
606 | const struct GNUNET_PeerIdentity *peer, | 610 | const struct GNUNET_PeerIdentity *peer, |
607 | void *internal_cls) | 611 | void *internal_cls) |
608 | { | 612 | { |
609 | struct PeerEntry *peer_entry = internal_cls; | 613 | struct PeerEntry *peer_entry = internal_cls; |
610 | 614 | ||
611 | if (0 == GNUNET_memcmp(peer, | 615 | if (0 == GNUNET_memcmp (peer, |
612 | &my_identity)) | 616 | &my_identity)) |
613 | return; | 617 | return; |
614 | GNUNET_assert(NULL != peer_entry); | 618 | GNUNET_assert (NULL != peer_entry); |
615 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 619 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
616 | "Peer `%s' disconnected from us\n", | 620 | "Peer `%s' disconnected from us\n", |
617 | GNUNET_i2s(peer)); | 621 | GNUNET_i2s (peer)); |
618 | GNUNET_assert(GNUNET_YES == | 622 | GNUNET_assert (GNUNET_YES == |
619 | GNUNET_CONTAINER_multipeermap_remove(peers, | 623 | GNUNET_CONTAINER_multipeermap_remove (peers, |
620 | peer, | 624 | peer, |
621 | peer_entry)); | 625 | peer_entry)); |
622 | if (NULL != peer_entry->transmit_task) | 626 | if (NULL != peer_entry->transmit_task) |
623 | { | 627 | { |
624 | GNUNET_SCHEDULER_cancel(peer_entry->transmit_task); | 628 | GNUNET_SCHEDULER_cancel (peer_entry->transmit_task); |
625 | peer_entry->transmit_task = NULL; | 629 | peer_entry->transmit_task = NULL; |
626 | } | 630 | } |
627 | if (NULL != peer_entry->so) | 631 | if (NULL != peer_entry->so) |
628 | { | 632 | { |
629 | GNUNET_SET_operation_cancel(peer_entry->so); | 633 | GNUNET_SET_operation_cancel (peer_entry->so); |
630 | peer_entry->so = NULL; | 634 | peer_entry->so = NULL; |
631 | } | 635 | } |
632 | GNUNET_free(peer_entry); | 636 | GNUNET_free (peer_entry); |
633 | GNUNET_STATISTICS_update(stats, | 637 | GNUNET_STATISTICS_update (stats, |
634 | "# peers connected", | 638 | "# peers connected", |
635 | -1, | 639 | -1, |
636 | GNUNET_NO); | 640 | GNUNET_NO); |
637 | } | 641 | } |
638 | 642 | ||
639 | 643 | ||
@@ -646,11 +650,11 @@ handle_core_disconnect(void *cls, | |||
646 | * @return #GNUNET_OK (continue to iterate) | 650 | * @return #GNUNET_OK (continue to iterate) |
647 | */ | 651 | */ |
648 | static int | 652 | static int |
649 | free_entry(void *cls, | 653 | free_entry (void *cls, |
650 | const struct GNUNET_HashCode *key, | 654 | const struct GNUNET_HashCode *key, |
651 | void *value) | 655 | void *value) |
652 | { | 656 | { |
653 | GNUNET_free(value); | 657 | GNUNET_free (value); |
654 | return GNUNET_OK; | 658 | return GNUNET_OK; |
655 | } | 659 | } |
656 | 660 | ||
@@ -661,42 +665,42 @@ free_entry(void *cls, | |||
661 | * @param cls unused | 665 | * @param cls unused |
662 | */ | 666 | */ |
663 | static void | 667 | static void |
664 | shutdown_task(void *cls) | 668 | shutdown_task (void *cls) |
665 | { | 669 | { |
666 | if (NULL != revocation_set) | 670 | if (NULL != revocation_set) |
667 | { | 671 | { |
668 | GNUNET_SET_destroy(revocation_set); | 672 | GNUNET_SET_destroy (revocation_set); |
669 | revocation_set = NULL; | 673 | revocation_set = NULL; |
670 | } | 674 | } |
671 | if (NULL != revocation_union_listen_handle) | 675 | if (NULL != revocation_union_listen_handle) |
672 | { | 676 | { |
673 | GNUNET_SET_listen_cancel(revocation_union_listen_handle); | 677 | GNUNET_SET_listen_cancel (revocation_union_listen_handle); |
674 | revocation_union_listen_handle = NULL; | 678 | revocation_union_listen_handle = NULL; |
675 | } | 679 | } |
676 | if (NULL != core_api) | 680 | if (NULL != core_api) |
677 | { | 681 | { |
678 | GNUNET_CORE_disconnect(core_api); | 682 | GNUNET_CORE_disconnect (core_api); |
679 | core_api = NULL; | 683 | core_api = NULL; |
680 | } | 684 | } |
681 | if (NULL != stats) | 685 | if (NULL != stats) |
682 | { | 686 | { |
683 | GNUNET_STATISTICS_destroy(stats, GNUNET_NO); | 687 | GNUNET_STATISTICS_destroy (stats, GNUNET_NO); |
684 | stats = NULL; | 688 | stats = NULL; |
685 | } | 689 | } |
686 | if (NULL != peers) | 690 | if (NULL != peers) |
687 | { | 691 | { |
688 | GNUNET_CONTAINER_multipeermap_destroy(peers); | 692 | GNUNET_CONTAINER_multipeermap_destroy (peers); |
689 | peers = NULL; | 693 | peers = NULL; |
690 | } | 694 | } |
691 | if (NULL != revocation_db) | 695 | if (NULL != revocation_db) |
692 | { | 696 | { |
693 | GNUNET_DISK_file_close(revocation_db); | 697 | GNUNET_DISK_file_close (revocation_db); |
694 | revocation_db = NULL; | 698 | revocation_db = NULL; |
695 | } | 699 | } |
696 | GNUNET_CONTAINER_multihashmap_iterate(revocation_map, | 700 | GNUNET_CONTAINER_multihashmap_iterate (revocation_map, |
697 | &free_entry, | 701 | &free_entry, |
698 | NULL); | 702 | NULL); |
699 | GNUNET_CONTAINER_multihashmap_destroy(revocation_map); | 703 | GNUNET_CONTAINER_multihashmap_destroy (revocation_map); |
700 | } | 704 | } |
701 | 705 | ||
702 | 706 | ||
@@ -707,16 +711,16 @@ shutdown_task(void *cls) | |||
707 | * @param identity the public identity of this peer | 711 | * @param identity the public identity of this peer |
708 | */ | 712 | */ |
709 | static void | 713 | static void |
710 | core_init(void *cls, | 714 | core_init (void *cls, |
711 | const struct GNUNET_PeerIdentity *identity) | 715 | const struct GNUNET_PeerIdentity *identity) |
712 | { | 716 | { |
713 | if (NULL == identity) | 717 | if (NULL == identity) |
714 | { | 718 | { |
715 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 719 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
716 | "Connection to core FAILED!\n"); | 720 | "Connection to core FAILED!\n"); |
717 | GNUNET_SCHEDULER_shutdown(); | 721 | GNUNET_SCHEDULER_shutdown (); |
718 | return; | 722 | return; |
719 | } | 723 | } |
720 | my_identity = *identity; | 724 | my_identity = *identity; |
721 | } | 725 | } |
722 | 726 | ||
@@ -737,45 +741,45 @@ core_init(void *cls, | |||
737 | * message. It's necessary to specify the timeout. | 741 | * message. It's necessary to specify the timeout. |
738 | */ | 742 | */ |
739 | static void | 743 | static void |
740 | handle_revocation_union_request(void *cls, | 744 | handle_revocation_union_request (void *cls, |
741 | const struct GNUNET_PeerIdentity *other_peer, | 745 | const struct GNUNET_PeerIdentity *other_peer, |
742 | const struct GNUNET_MessageHeader *context_msg, | 746 | const struct GNUNET_MessageHeader *context_msg, |
743 | struct GNUNET_SET_Request *request) | 747 | struct GNUNET_SET_Request *request) |
744 | { | 748 | { |
745 | struct PeerEntry *peer_entry; | 749 | struct PeerEntry *peer_entry; |
746 | 750 | ||
747 | if (NULL == request) | 751 | if (NULL == request) |
748 | { | 752 | { |
749 | GNUNET_break(0); | 753 | GNUNET_break (0); |
750 | return; | 754 | return; |
751 | } | 755 | } |
752 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 756 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
753 | "Received set exchange request from peer `%s'\n", | 757 | "Received set exchange request from peer `%s'\n", |
754 | GNUNET_i2s(other_peer)); | 758 | GNUNET_i2s (other_peer)); |
755 | peer_entry = GNUNET_CONTAINER_multipeermap_get(peers, | 759 | peer_entry = GNUNET_CONTAINER_multipeermap_get (peers, |
756 | other_peer); | 760 | other_peer); |
757 | if (NULL == peer_entry) | 761 | if (NULL == peer_entry) |
758 | { | 762 | { |
759 | peer_entry = new_peer_entry(other_peer); | 763 | peer_entry = new_peer_entry (other_peer); |
760 | } | 764 | } |
761 | if (NULL != peer_entry->so) | 765 | if (NULL != peer_entry->so) |
762 | { | 766 | { |
763 | GNUNET_break_op(0); | 767 | GNUNET_break_op (0); |
764 | return; | 768 | return; |
765 | } | 769 | } |
766 | peer_entry->so = GNUNET_SET_accept(request, | 770 | peer_entry->so = GNUNET_SET_accept (request, |
767 | GNUNET_SET_RESULT_ADDED, | 771 | GNUNET_SET_RESULT_ADDED, |
768 | (struct GNUNET_SET_Option[]) { { 0 } }, | 772 | (struct GNUNET_SET_Option[]) { { 0 } }, |
769 | &add_revocation, | 773 | &add_revocation, |
770 | peer_entry); | 774 | peer_entry); |
771 | if (GNUNET_OK != | 775 | if (GNUNET_OK != |
772 | GNUNET_SET_commit(peer_entry->so, | 776 | GNUNET_SET_commit (peer_entry->so, |
773 | revocation_set)) | 777 | revocation_set)) |
774 | { | 778 | { |
775 | GNUNET_break(0); | 779 | GNUNET_break (0); |
776 | GNUNET_SCHEDULER_shutdown(); | 780 | GNUNET_SCHEDULER_shutdown (); |
777 | return; | 781 | return; |
778 | } | 782 | } |
779 | } | 783 | } |
780 | 784 | ||
781 | 785 | ||
@@ -787,136 +791,137 @@ handle_revocation_union_request(void *cls, | |||
787 | * @param c configuration to use | 791 | * @param c configuration to use |
788 | */ | 792 | */ |
789 | static void | 793 | static void |
790 | run(void *cls, | 794 | run (void *cls, |
791 | const struct GNUNET_CONFIGURATION_Handle *c, | 795 | const struct GNUNET_CONFIGURATION_Handle *c, |
792 | struct GNUNET_SERVICE_Handle *service) | 796 | struct GNUNET_SERVICE_Handle *service) |
793 | { | 797 | { |
794 | struct GNUNET_MQ_MessageHandler core_handlers[] = { | 798 | struct GNUNET_MQ_MessageHandler core_handlers[] = { |
795 | GNUNET_MQ_hd_fixed_size(p2p_revoke, | 799 | GNUNET_MQ_hd_fixed_size (p2p_revoke, |
796 | GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE, | 800 | GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE, |
797 | struct RevokeMessage, | 801 | struct RevokeMessage, |
798 | NULL), | 802 | NULL), |
799 | GNUNET_MQ_handler_end() | 803 | GNUNET_MQ_handler_end () |
800 | }; | 804 | }; |
801 | char *fn; | 805 | char *fn; |
802 | uint64_t left; | 806 | uint64_t left; |
803 | struct RevokeMessage *rm; | 807 | struct RevokeMessage *rm; |
804 | struct GNUNET_HashCode hc; | 808 | struct GNUNET_HashCode hc; |
805 | 809 | ||
806 | GNUNET_CRYPTO_hash("revocation-set-union-application-id", | 810 | GNUNET_CRYPTO_hash ("revocation-set-union-application-id", |
807 | strlen("revocation-set-union-application-id"), | 811 | strlen ("revocation-set-union-application-id"), |
808 | &revocation_set_union_app_id); | 812 | &revocation_set_union_app_id); |
809 | if (GNUNET_OK != | 813 | if (GNUNET_OK != |
810 | GNUNET_CONFIGURATION_get_value_filename(c, | 814 | GNUNET_CONFIGURATION_get_value_filename (c, |
811 | "REVOCATION", | 815 | "REVOCATION", |
812 | "DATABASE", | 816 | "DATABASE", |
813 | &fn)) | 817 | &fn)) |
814 | { | 818 | { |
815 | GNUNET_log_config_missing(GNUNET_ERROR_TYPE_ERROR, | 819 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, |
816 | "REVOCATION", | 820 | "REVOCATION", |
817 | "DATABASE"); | 821 | "DATABASE"); |
818 | GNUNET_SCHEDULER_shutdown(); | 822 | GNUNET_SCHEDULER_shutdown (); |
819 | return; | 823 | return; |
820 | } | 824 | } |
821 | cfg = c; | 825 | cfg = c; |
822 | revocation_map = GNUNET_CONTAINER_multihashmap_create(16, | 826 | revocation_map = GNUNET_CONTAINER_multihashmap_create (16, |
823 | GNUNET_NO); | 827 | GNUNET_NO); |
824 | if (GNUNET_OK != | 828 | if (GNUNET_OK != |
825 | GNUNET_CONFIGURATION_get_value_number(cfg, | 829 | GNUNET_CONFIGURATION_get_value_number (cfg, |
826 | "REVOCATION", | 830 | "REVOCATION", |
827 | "WORKBITS", | 831 | "WORKBITS", |
828 | &revocation_work_required)) | 832 | &revocation_work_required)) |
829 | { | 833 | { |
830 | GNUNET_log_config_missing(GNUNET_ERROR_TYPE_ERROR, | 834 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, |
831 | "REVOCATION", | 835 | "REVOCATION", |
832 | "WORKBITS"); | 836 | "WORKBITS"); |
833 | GNUNET_SCHEDULER_shutdown(); | 837 | GNUNET_SCHEDULER_shutdown (); |
834 | GNUNET_free(fn); | 838 | GNUNET_free (fn); |
835 | return; | 839 | return; |
836 | } | 840 | } |
837 | if (revocation_work_required >= sizeof(struct GNUNET_HashCode) * 8) | 841 | if (revocation_work_required >= sizeof(struct GNUNET_HashCode) * 8) |
838 | { | 842 | { |
839 | GNUNET_log_config_invalid(GNUNET_ERROR_TYPE_ERROR, | 843 | GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, |
840 | "REVOCATION", | 844 | "REVOCATION", |
841 | "WORKBITS", | 845 | "WORKBITS", |
842 | _("Value is too large.\n")); | 846 | _ ("Value is too large.\n")); |
843 | GNUNET_SCHEDULER_shutdown(); | 847 | GNUNET_SCHEDULER_shutdown (); |
844 | GNUNET_free(fn); | 848 | GNUNET_free (fn); |
845 | return; | 849 | return; |
846 | } | 850 | } |
847 | revocation_set = GNUNET_SET_create(cfg, | 851 | revocation_set = GNUNET_SET_create (cfg, |
848 | GNUNET_SET_OPERATION_UNION); | 852 | GNUNET_SET_OPERATION_UNION); |
849 | revocation_union_listen_handle | 853 | revocation_union_listen_handle |
850 | = GNUNET_SET_listen(cfg, | 854 | = GNUNET_SET_listen (cfg, |
851 | GNUNET_SET_OPERATION_UNION, | 855 | GNUNET_SET_OPERATION_UNION, |
852 | &revocation_set_union_app_id, | 856 | &revocation_set_union_app_id, |
853 | &handle_revocation_union_request, | 857 | &handle_revocation_union_request, |
854 | NULL); | 858 | NULL); |
855 | revocation_db = GNUNET_DISK_file_open(fn, | 859 | revocation_db = GNUNET_DISK_file_open (fn, |
856 | GNUNET_DISK_OPEN_READWRITE | | 860 | GNUNET_DISK_OPEN_READWRITE |
857 | GNUNET_DISK_OPEN_CREATE, | 861 | | GNUNET_DISK_OPEN_CREATE, |
858 | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE | | 862 | GNUNET_DISK_PERM_USER_READ |
859 | GNUNET_DISK_PERM_GROUP_READ | | 863 | | GNUNET_DISK_PERM_USER_WRITE |
860 | GNUNET_DISK_PERM_OTHER_READ); | 864 | | GNUNET_DISK_PERM_GROUP_READ |
865 | | GNUNET_DISK_PERM_OTHER_READ); | ||
861 | if (NULL == revocation_db) | 866 | if (NULL == revocation_db) |
862 | { | 867 | { |
863 | GNUNET_log_config_invalid(GNUNET_ERROR_TYPE_ERROR, | 868 | GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, |
864 | "REVOCATION", | 869 | "REVOCATION", |
865 | "DATABASE", | 870 | "DATABASE", |
866 | _("Could not open revocation database file!")); | 871 | _ ("Could not open revocation database file!")); |
867 | GNUNET_SCHEDULER_shutdown(); | 872 | GNUNET_SCHEDULER_shutdown (); |
868 | GNUNET_free(fn); | 873 | GNUNET_free (fn); |
869 | return; | 874 | return; |
870 | } | 875 | } |
871 | if (GNUNET_OK != | 876 | if (GNUNET_OK != |
872 | GNUNET_DISK_file_size(fn, &left, GNUNET_YES, GNUNET_YES)) | 877 | GNUNET_DISK_file_size (fn, &left, GNUNET_YES, GNUNET_YES)) |
873 | left = 0; | 878 | left = 0; |
874 | while (left > sizeof(struct RevokeMessage)) | 879 | while (left > sizeof(struct RevokeMessage)) |
875 | { | 880 | { |
876 | rm = GNUNET_new(struct RevokeMessage); | 881 | rm = GNUNET_new (struct RevokeMessage); |
877 | if (sizeof(struct RevokeMessage) != | 882 | if (sizeof(struct RevokeMessage) != |
878 | GNUNET_DISK_file_read(revocation_db, | 883 | GNUNET_DISK_file_read (revocation_db, |
879 | rm, | 884 | rm, |
880 | sizeof(struct RevokeMessage))) | 885 | sizeof(struct RevokeMessage))) |
881 | { | 886 | { |
882 | GNUNET_log_strerror_file(GNUNET_ERROR_TYPE_ERROR, | 887 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, |
883 | "read", | 888 | "read", |
884 | fn); | 889 | fn); |
885 | GNUNET_free(rm); | 890 | GNUNET_free (rm); |
886 | GNUNET_SCHEDULER_shutdown(); | 891 | GNUNET_SCHEDULER_shutdown (); |
887 | GNUNET_free(fn); | 892 | GNUNET_free (fn); |
888 | return; | 893 | return; |
889 | } | 894 | } |
890 | GNUNET_break(0 == ntohl(rm->reserved)); | 895 | GNUNET_break (0 == ntohl (rm->reserved)); |
891 | GNUNET_CRYPTO_hash(&rm->public_key, | 896 | GNUNET_CRYPTO_hash (&rm->public_key, |
892 | sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey), | 897 | sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey), |
893 | &hc); | 898 | &hc); |
894 | GNUNET_break(GNUNET_OK == | 899 | GNUNET_break (GNUNET_OK == |
895 | GNUNET_CONTAINER_multihashmap_put(revocation_map, | 900 | GNUNET_CONTAINER_multihashmap_put (revocation_map, |
896 | &hc, | 901 | &hc, |
897 | rm, | 902 | rm, |
898 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 903 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
899 | } | 904 | } |
900 | GNUNET_free(fn); | 905 | GNUNET_free (fn); |
901 | 906 | ||
902 | GNUNET_SCHEDULER_add_shutdown(&shutdown_task, | 907 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
903 | NULL); | 908 | NULL); |
904 | peers = GNUNET_CONTAINER_multipeermap_create(128, | 909 | peers = GNUNET_CONTAINER_multipeermap_create (128, |
905 | GNUNET_YES); | 910 | GNUNET_YES); |
906 | /* Connect to core service and register core handlers */ | 911 | /* Connect to core service and register core handlers */ |
907 | core_api = GNUNET_CORE_connect(cfg, /* Main configuration */ | 912 | core_api = GNUNET_CORE_connect (cfg, /* Main configuration */ |
908 | NULL, /* Closure passed to functions */ | 913 | NULL, /* Closure passed to functions */ |
909 | &core_init, /* Call core_init once connected */ | 914 | &core_init, /* Call core_init once connected */ |
910 | &handle_core_connect, /* Handle connects */ | 915 | &handle_core_connect, /* Handle connects */ |
911 | &handle_core_disconnect, /* Handle disconnects */ | 916 | &handle_core_disconnect, /* Handle disconnects */ |
912 | core_handlers); /* Register these handlers */ | 917 | core_handlers); /* Register these handlers */ |
913 | if (NULL == core_api) | 918 | if (NULL == core_api) |
914 | { | 919 | { |
915 | GNUNET_SCHEDULER_shutdown(); | 920 | GNUNET_SCHEDULER_shutdown (); |
916 | return; | 921 | return; |
917 | } | 922 | } |
918 | stats = GNUNET_STATISTICS_create("revocation", | 923 | stats = GNUNET_STATISTICS_create ("revocation", |
919 | cfg); | 924 | cfg); |
920 | } | 925 | } |
921 | 926 | ||
922 | 927 | ||
@@ -930,15 +935,15 @@ GNUNET_SERVICE_MAIN | |||
930 | &client_connect_cb, | 935 | &client_connect_cb, |
931 | &client_disconnect_cb, | 936 | &client_disconnect_cb, |
932 | NULL, | 937 | NULL, |
933 | GNUNET_MQ_hd_fixed_size(query_message, | 938 | GNUNET_MQ_hd_fixed_size (query_message, |
934 | GNUNET_MESSAGE_TYPE_REVOCATION_QUERY, | 939 | GNUNET_MESSAGE_TYPE_REVOCATION_QUERY, |
935 | struct QueryMessage, | 940 | struct QueryMessage, |
936 | NULL), | 941 | NULL), |
937 | GNUNET_MQ_hd_fixed_size(revoke_message, | 942 | GNUNET_MQ_hd_fixed_size (revoke_message, |
938 | GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE, | 943 | GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE, |
939 | struct RevokeMessage, | 944 | struct RevokeMessage, |
940 | NULL), | 945 | NULL), |
941 | GNUNET_MQ_handler_end()); | 946 | GNUNET_MQ_handler_end ()); |
942 | 947 | ||
943 | 948 | ||
944 | #if defined(LINUX) && defined(__GLIBC__) | 949 | #if defined(LINUX) && defined(__GLIBC__) |
@@ -948,11 +953,11 @@ GNUNET_SERVICE_MAIN | |||
948 | * MINIMIZE heap size (way below 128k) since this process doesn't need much. | 953 | * MINIMIZE heap size (way below 128k) since this process doesn't need much. |
949 | */ | 954 | */ |
950 | void __attribute__ ((constructor)) | 955 | void __attribute__ ((constructor)) |
951 | GNUNET_REVOCATION_memory_init() | 956 | GNUNET_REVOCATION_memory_init () |
952 | { | 957 | { |
953 | mallopt(M_TRIM_THRESHOLD, 4 * 1024); | 958 | mallopt (M_TRIM_THRESHOLD, 4 * 1024); |
954 | mallopt(M_TOP_PAD, 1 * 1024); | 959 | mallopt (M_TOP_PAD, 1 * 1024); |
955 | malloc_trim(0); | 960 | malloc_trim (0); |
956 | } | 961 | } |
957 | 962 | ||
958 | #endif | 963 | #endif |