aboutsummaryrefslogtreecommitdiff
path: root/src/revocation/gnunet-service-revocation.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-03-07 19:10:51 +0000
committerChristian Grothoff <christian@grothoff.org>2015-03-07 19:10:51 +0000
commitcd0ad4c559f9338eec2a152ded51d16e021eca06 (patch)
tree151c7e7b1483f4b50411e1fd30be1091cc7480bd /src/revocation/gnunet-service-revocation.c
parent71c9ff44f0b1b1f6c3dc72e945644e47ab5ab921 (diff)
downloadgnunet-cd0ad4c559f9338eec2a152ded51d16e021eca06.tar.gz
gnunet-cd0ad4c559f9338eec2a152ded51d16e021eca06.zip
-indentation and comment fixes
Diffstat (limited to 'src/revocation/gnunet-service-revocation.c')
-rw-r--r--src/revocation/gnunet-service-revocation.c109
1 files changed, 64 insertions, 45 deletions
diff --git a/src/revocation/gnunet-service-revocation.c b/src/revocation/gnunet-service-revocation.c
index 4dc869fd2..08b8c24f0 100644
--- a/src/revocation/gnunet-service-revocation.c
+++ b/src/revocation/gnunet-service-revocation.c
@@ -200,7 +200,8 @@ handle_query_message (void *cls,
200 GNUNET_CRYPTO_hash (&qm->key, 200 GNUNET_CRYPTO_hash (&qm->key,
201 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey), 201 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey),
202 &hc); 202 &hc);
203 res = GNUNET_CONTAINER_multihashmap_contains (revocation_map, &hc); 203 res = GNUNET_CONTAINER_multihashmap_contains (revocation_map,
204 &hc);
204 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 205 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
205 (GNUNET_NO == res) 206 (GNUNET_NO == res)
206 ? "Received revocation check for valid key `%s' from client\n" 207 ? "Received revocation check for valid key `%s' from client\n"
@@ -215,7 +216,8 @@ handle_query_message (void *cls,
215 client, 216 client,
216 &qrm.header, 217 &qrm.header,
217 GNUNET_NO); 218 GNUNET_NO);
218 GNUNET_SERVER_receive_done (client, GNUNET_OK); 219 GNUNET_SERVER_receive_done (client,
220 GNUNET_OK);
219} 221}
220 222
221 223
@@ -237,10 +239,14 @@ do_flood (void *cls,
237 struct GNUNET_MQ_Envelope *e; 239 struct GNUNET_MQ_Envelope *e;
238 struct RevokeMessage *cp; 240 struct RevokeMessage *cp;
239 241
240 e = GNUNET_MQ_msg (cp, GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE); 242 e = GNUNET_MQ_msg (cp,
243 GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE);
241 *cp = *rm; 244 *cp = *rm;
242 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Flooding revocation to `%s'\n", GNUNET_i2s (target)); 245 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
243 GNUNET_MQ_send (pe->mq, e); 246 "Flooding revocation to `%s'\n",
247 GNUNET_i2s (target));
248 GNUNET_MQ_send (pe->mq,
249 e);
244 return GNUNET_OK; 250 return GNUNET_OK;
245} 251}
246 252
@@ -309,7 +315,8 @@ publicize_rm (const struct RevokeMessage *rm)
309 if (GNUNET_OK != 315 if (GNUNET_OK !=
310 GNUNET_SET_add_element (revocation_set, 316 GNUNET_SET_add_element (revocation_set,
311 &e, 317 &e,
312 NULL, NULL)) 318 NULL,
319 NULL))
313 { 320 {
314 GNUNET_break (0); 321 GNUNET_break (0);
315 return GNUNET_OK; 322 return GNUNET_OK;
@@ -349,7 +356,8 @@ handle_revoke_message (void *cls,
349 if (GNUNET_SYSERR == (ret = publicize_rm (rm))) 356 if (GNUNET_SYSERR == (ret = publicize_rm (rm)))
350 { 357 {
351 GNUNET_break_op (0); 358 GNUNET_break_op (0);
352 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 359 GNUNET_SERVER_receive_done (client,
360 GNUNET_SYSERR);
353 return; 361 return;
354 } 362 }
355 rrm.header.size = htons (sizeof (struct RevocationResponseMessage)); 363 rrm.header.size = htons (sizeof (struct RevocationResponseMessage));
@@ -361,7 +369,8 @@ handle_revoke_message (void *cls,
361 client, 369 client,
362 &rrm.header, 370 &rrm.header,
363 GNUNET_NO); 371 GNUNET_NO);
364 GNUNET_SERVER_receive_done (client, GNUNET_OK); 372 GNUNET_SERVER_receive_done (client,
373 GNUNET_OK);
365} 374}
366 375
367 376
@@ -387,7 +396,6 @@ handle_p2p_revoke_message (void *cls,
387} 396}
388 397
389 398
390
391/** 399/**
392 * Callback for set operation results. Called for each element in the 400 * Callback for set operation results. Called for each element in the
393 * result set. Each element contains a revocation, which we should 401 * result set. Each element contains a revocation, which we should
@@ -416,7 +424,7 @@ add_revocation (void *cls,
416 if (0 != element->element_type) 424 if (0 != element->element_type)
417 { 425 {
418 GNUNET_STATISTICS_update (stats, 426 GNUNET_STATISTICS_update (stats,
419 "# unsupported revocations received via set union", 427 gettext_noop ("# unsupported revocations received via set union"),
420 1, GNUNET_NO); 428 1, GNUNET_NO);
421 return; 429 return;
422 } 430 }
@@ -425,7 +433,7 @@ add_revocation (void *cls,
425 &peer_entry->id, 433 &peer_entry->id,
426 &rm->header); 434 &rm->header);
427 GNUNET_STATISTICS_update (stats, 435 GNUNET_STATISTICS_update (stats,
428 "# revocation messages received via set union", 436 gettext_noop ("# revocation messages received via set union"),
429 1, GNUNET_NO); 437 1, GNUNET_NO);
430 break; 438 break;
431 case GNUNET_SET_STATUS_FAILURE: 439 case GNUNET_SET_STATUS_FAILURE:
@@ -434,16 +442,18 @@ add_revocation (void *cls,
434 GNUNET_i2s (&peer_entry->id)); 442 GNUNET_i2s (&peer_entry->id));
435 peer_entry->so = NULL; 443 peer_entry->so = NULL;
436 GNUNET_STATISTICS_update (stats, 444 GNUNET_STATISTICS_update (stats,
437 "# revocation set unions failed", 445 gettext_noop ("# revocation set unions failed"),
438 1, GNUNET_NO); 446 1,
447 GNUNET_NO);
439 break; 448 break;
440 case GNUNET_SET_STATUS_HALF_DONE: 449 case GNUNET_SET_STATUS_HALF_DONE:
441 break; 450 break;
442 case GNUNET_SET_STATUS_DONE: 451 case GNUNET_SET_STATUS_DONE:
443 peer_entry->so = NULL; 452 peer_entry->so = NULL;
444 GNUNET_STATISTICS_update (stats, 453 GNUNET_STATISTICS_update (stats,
445 "# revocation set unions completed", 454 gettext_noop ("# revocation set unions completed"),
446 1, GNUNET_NO); 455 1,
456 GNUNET_NO);
447 break; 457 break;
448 default: 458 default:
449 GNUNET_break (0); 459 GNUNET_break (0);
@@ -502,7 +512,9 @@ handle_core_connect (void *cls,
502 struct GNUNET_HashCode my_hash; 512 struct GNUNET_HashCode my_hash;
503 struct GNUNET_HashCode peer_hash; 513 struct GNUNET_HashCode peer_hash;
504 514
505 if (0 == memcmp(peer, &my_identity, sizeof (my_identity))) 515 if (0 == memcmp(peer,
516 &my_identity,
517 sizeof (my_identity)))
506 return; 518 return;
507 519
508 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 520 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -510,22 +522,21 @@ handle_core_connect (void *cls,
510 GNUNET_i2s (peer)); 522 GNUNET_i2s (peer));
511 peer_entry = GNUNET_CONTAINER_multipeermap_get (peers, 523 peer_entry = GNUNET_CONTAINER_multipeermap_get (peers,
512 peer); 524 peer);
513 if (NULL == peer_entry) 525 GNUNET_assert (NULL == peer_entry);
514 { 526 peer_entry = GNUNET_new (struct PeerEntry);
515 peer_entry = GNUNET_new (struct PeerEntry); 527 peer_entry->id = *peer;
516 peer_entry->id = *peer; 528 GNUNET_assert (GNUNET_OK ==
517 GNUNET_assert (GNUNET_OK == 529 GNUNET_CONTAINER_multipeermap_put (peers,
518 GNUNET_CONTAINER_multipeermap_put (peers, peer, 530 &peer_entry->id,
519 peer_entry, 531 peer_entry,
520 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 532 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
521 }
522 else
523 {
524 GNUNET_assert (NULL == peer_entry->mq);
525 }
526 peer_entry->mq = GNUNET_CORE_mq_create (core_api, peer); 533 peer_entry->mq = GNUNET_CORE_mq_create (core_api, peer);
527 GNUNET_CRYPTO_hash (&my_identity, sizeof (my_identity), &my_hash); 534 GNUNET_CRYPTO_hash (&my_identity,
528 GNUNET_CRYPTO_hash (peer, sizeof (*peer), &peer_hash); 535 sizeof (my_identity),
536 &my_hash);
537 GNUNET_CRYPTO_hash (peer,
538 sizeof (*peer),
539 &peer_hash);
529 if (0 < GNUNET_CRYPTO_hash_cmp (&my_hash, 540 if (0 < GNUNET_CRYPTO_hash_cmp (&my_hash,
530 &peer_hash)) 541 &peer_hash))
531 { 542 {
@@ -537,7 +548,10 @@ handle_core_connect (void *cls,
537 &transmit_task_cb, 548 &transmit_task_cb,
538 peer_entry); 549 peer_entry);
539 } 550 }
540 GNUNET_STATISTICS_update (stats, "# peers connected", 1, GNUNET_NO); 551 GNUNET_STATISTICS_update (stats,
552 "# peers connected",
553 1,
554 GNUNET_NO);
541} 555}
542 556
543 557
@@ -554,23 +568,23 @@ handle_core_disconnect (void *cls,
554{ 568{
555 struct PeerEntry *pos; 569 struct PeerEntry *pos;
556 570
557 if (0 == memcmp(peer, &my_identity, sizeof (my_identity))) 571 if (0 == memcmp (peer,
558 return; 572 &my_identity,
573 sizeof (my_identity)))
574 return;
559 575
560 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 576 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
561 "Peer `%s' disconnected from us\n", 577 "Peer `%s' disconnected from us\n",
562 GNUNET_i2s (peer)); 578 GNUNET_i2s (peer));
563 pos = GNUNET_CONTAINER_multipeermap_get (peers, peer); 579 pos = GNUNET_CONTAINER_multipeermap_get (peers,
564 if (NULL == pos) 580 peer);
565 { 581 GNUNET_assert (NULL != pos);
566 GNUNET_break (0);
567 return;
568 }
569 GNUNET_assert (GNUNET_YES == 582 GNUNET_assert (GNUNET_YES ==
570 GNUNET_CONTAINER_multipeermap_remove (peers, peer, 583 GNUNET_CONTAINER_multipeermap_remove (peers,
584 peer,
571 pos)); 585 pos));
572 GNUNET_MQ_destroy (pos->mq); 586 GNUNET_MQ_destroy (pos->mq);
573 if (pos->transmit_task != NULL) 587 if (NULL != pos->transmit_task)
574 { 588 {
575 GNUNET_SCHEDULER_cancel (pos->transmit_task); 589 GNUNET_SCHEDULER_cancel (pos->transmit_task);
576 pos->transmit_task = NULL; 590 pos->transmit_task = NULL;
@@ -581,7 +595,10 @@ handle_core_disconnect (void *cls,
581 pos->so = NULL; 595 pos->so = NULL;
582 } 596 }
583 GNUNET_free (pos); 597 GNUNET_free (pos);
584 GNUNET_STATISTICS_update (stats, "# peers connected", -1, GNUNET_NO); 598 GNUNET_STATISTICS_update (stats,
599 "# peers connected",
600 -1,
601 GNUNET_NO);
585} 602}
586 603
587 604
@@ -855,9 +872,11 @@ run (void *cls,
855 } 872 }
856 GNUNET_free (fn); 873 GNUNET_free (fn);
857 874
858 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, 875 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
876 &shutdown_task,
859 NULL); 877 NULL);
860 peers = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_NO); 878 peers = GNUNET_CONTAINER_multipeermap_create (128,
879 GNUNET_YES);
861 GNUNET_SERVER_add_handlers (srv, handlers); 880 GNUNET_SERVER_add_handlers (srv, handlers);
862 /* Connect to core service and register core handlers */ 881 /* Connect to core service and register core handlers */
863 core_api = GNUNET_CORE_connect (cfg, /* Main configuration */ 882 core_api = GNUNET_CORE_connect (cfg, /* Main configuration */