aboutsummaryrefslogtreecommitdiff
path: root/src/revocation/gnunet-service-revocation.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/revocation/gnunet-service-revocation.c')
-rw-r--r--src/revocation/gnunet-service-revocation.c60
1 files changed, 30 insertions, 30 deletions
diff --git a/src/revocation/gnunet-service-revocation.c b/src/revocation/gnunet-service-revocation.c
index c4622279a..7f85301be 100644
--- a/src/revocation/gnunet-service-revocation.c
+++ b/src/revocation/gnunet-service-revocation.c
@@ -34,7 +34,7 @@
34 * - broadcast p2p revocations 34 * - broadcast p2p revocations
35 * - handle p2p connect (trigger SET union) 35 * - handle p2p connect (trigger SET union)
36 * - optimization: avoid sending revocation back to peer that we got it from; 36 * - optimization: avoid sending revocation back to peer that we got it from;
37 * - optimization: have randomized delay in sending revocations to other peers 37 * - optimization: have randomized delay in sending revocations to other peers
38 * to make it rare to traverse each link twice (NSE-style) 38 * to make it rare to traverse each link twice (NSE-style)
39 */ 39 */
40#include "platform.h" 40#include "platform.h"
@@ -83,7 +83,7 @@ static struct GNUNET_SET_Handle *revocation_set;
83/** 83/**
84 * Hash map with all revoked keys, maps the hash of the public key 84 * Hash map with all revoked keys, maps the hash of the public key
85 * to the respective `struct RevokeMessage`. 85 * to the respective `struct RevokeMessage`.
86 */ 86 */
87static struct GNUNET_CONTAINER_MultiHashMap *revocation_map; 87static struct GNUNET_CONTAINER_MultiHashMap *revocation_map;
88 88
89/** 89/**
@@ -147,7 +147,7 @@ verify_revoke_message (const struct RevokeMessage *rm)
147 rm->proof_of_work, 147 rm->proof_of_work,
148 (unsigned int) revocation_work_required)) 148 (unsigned int) revocation_work_required))
149 { 149 {
150 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 150 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
151 "Proof of work invalid: %llu!\n", 151 "Proof of work invalid: %llu!\n",
152 (unsigned long long) 152 (unsigned long long)
153 GNUNET_ntohll (rm->proof_of_work)); 153 GNUNET_ntohll (rm->proof_of_work));
@@ -175,7 +175,7 @@ verify_revoke_message (const struct RevokeMessage *rm)
175 * @param message the message received 175 * @param message the message received
176 */ 176 */
177static void 177static void
178handle_query_message (void *cls, 178handle_query_message (void *cls,
179 struct GNUNET_SERVER_Client *client, 179 struct GNUNET_SERVER_Client *client,
180 const struct GNUNET_MessageHeader *message) 180 const struct GNUNET_MessageHeader *message)
181{ 181{
@@ -188,15 +188,15 @@ handle_query_message (void *cls,
188 sizeof (struct GNUNET_CRYPTO_EccPublicSignKey), 188 sizeof (struct GNUNET_CRYPTO_EccPublicSignKey),
189 &hc); 189 &hc);
190 res = GNUNET_CONTAINER_multihashmap_contains (revocation_map, &hc); 190 res = GNUNET_CONTAINER_multihashmap_contains (revocation_map, &hc);
191 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 191 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
192 (GNUNET_NO == res) 192 (GNUNET_NO == res)
193 ? "Received revocation check for valid key `%s' from client\n" 193 ? "Received revocation check for valid key `%s' from client\n"
194 : "Received revocation check for revoked key `%s' from client\n", 194 : "Received revocation check for revoked key `%s' from client\n",
195 GNUNET_h2s (&hc)); 195 GNUNET_h2s (&hc));
196 qrm.header.size = htons (sizeof (struct QueryResponseMessage)); 196 qrm.header.size = htons (sizeof (struct QueryResponseMessage));
197 qrm.header.type = htons (GNUNET_MESSAGE_TYPE_REVOCATION_QUERY_RESPONSE); 197 qrm.header.type = htons (GNUNET_MESSAGE_TYPE_REVOCATION_QUERY_RESPONSE);
198 qrm.is_valid = htons ((GNUNET_YES == res) ? GNUNET_NO : GNUNET_YES); 198 qrm.is_valid = htons ((GNUNET_YES == res) ? GNUNET_NO : GNUNET_YES);
199 GNUNET_SERVER_notification_context_add (nc, 199 GNUNET_SERVER_notification_context_add (nc,
200 client); 200 client);
201 GNUNET_SERVER_notification_context_unicast (nc, 201 GNUNET_SERVER_notification_context_unicast (nc,
202 client, 202 client,
@@ -228,7 +228,7 @@ do_flood (void *cls,
228 * Publicize revocation message. Stores the message locally in the 228 * Publicize revocation message. Stores the message locally in the
229 * database and passes it to all connected neighbours (and adds it to 229 * database and passes it to all connected neighbours (and adds it to
230 * the set for future connections). 230 * the set for future connections).
231 * 231 *
232 * @param rm message to publicize 232 * @param rm message to publicize
233 * @return #GNUNET_OK on success, #GNUNET_NO if we encountered an error, 233 * @return #GNUNET_OK on success, #GNUNET_NO if we encountered an error,
234 * #GNUNET_SYSERR if the message was malformed 234 * #GNUNET_SYSERR if the message was malformed
@@ -251,12 +251,12 @@ publicize_rm (const struct RevokeMessage *rm)
251 _("Duplicate revocation received from peer. Ignored.\n")); 251 _("Duplicate revocation received from peer. Ignored.\n"));
252 return GNUNET_OK; 252 return GNUNET_OK;
253 } 253 }
254 if (GNUNET_OK != 254 if (GNUNET_OK !=
255 verify_revoke_message (rm)) 255 verify_revoke_message (rm))
256 { 256 {
257 GNUNET_break_op (0); 257 GNUNET_break_op (0);
258 return GNUNET_SYSERR; 258 return GNUNET_SYSERR;
259 } 259 }
260 /* write to disk */ 260 /* write to disk */
261 if (sizeof (struct RevokeMessage) != 261 if (sizeof (struct RevokeMessage) !=
262 GNUNET_DISK_file_write (revocation_db, 262 GNUNET_DISK_file_write (revocation_db,
@@ -294,7 +294,7 @@ publicize_rm (const struct RevokeMessage *rm)
294 return GNUNET_OK; 294 return GNUNET_OK;
295 } 295 }
296 /* flood to neighbours */ 296 /* flood to neighbours */
297 GNUNET_CONTAINER_multipeermap_iterate (peers, 297 GNUNET_CONTAINER_multipeermap_iterate (peers,
298 &do_flood, 298 &do_flood,
299 cp); 299 cp);
300 return GNUNET_OK; 300 return GNUNET_OK;
@@ -309,7 +309,7 @@ publicize_rm (const struct RevokeMessage *rm)
309 * @param message the message received 309 * @param message the message received
310 */ 310 */
311static void 311static void
312handle_revoke_message (void *cls, 312handle_revoke_message (void *cls,
313 struct GNUNET_SERVER_Client *client, 313 struct GNUNET_SERVER_Client *client,
314 const struct GNUNET_MessageHeader *message) 314 const struct GNUNET_MessageHeader *message)
315{ 315{
@@ -317,7 +317,7 @@ handle_revoke_message (void *cls,
317 struct RevocationResponseMessage rrm; 317 struct RevocationResponseMessage rrm;
318 int ret; 318 int ret;
319 319
320 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 320 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
321 "Received REVOKE message from client\n"); 321 "Received REVOKE message from client\n");
322 rm = (const struct RevokeMessage *) message; 322 rm = (const struct RevokeMessage *) message;
323 if (GNUNET_SYSERR == (ret = publicize_rm (rm))) 323 if (GNUNET_SYSERR == (ret = publicize_rm (rm)))
@@ -329,7 +329,7 @@ handle_revoke_message (void *cls,
329 rrm.header.size = htons (sizeof (struct RevocationResponseMessage)); 329 rrm.header.size = htons (sizeof (struct RevocationResponseMessage));
330 rrm.header.type = htons (GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE_RESPONSE); 330 rrm.header.type = htons (GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE_RESPONSE);
331 rrm.is_valid = htons ((GNUNET_OK == ret) ? GNUNET_NO : GNUNET_YES); 331 rrm.is_valid = htons ((GNUNET_OK == ret) ? GNUNET_NO : GNUNET_YES);
332 GNUNET_SERVER_notification_context_add (nc, 332 GNUNET_SERVER_notification_context_add (nc,
333 client); 333 client);
334 GNUNET_SERVER_notification_context_unicast (nc, 334 GNUNET_SERVER_notification_context_unicast (nc,
335 client, 335 client,
@@ -347,13 +347,13 @@ handle_revoke_message (void *cls,
347 * @param peer peer identity this message is from (ignored) 347 * @param peer peer identity this message is from (ignored)
348 */ 348 */
349static int 349static int
350handle_p2p_revoke_message (void *cls, 350handle_p2p_revoke_message (void *cls,
351 const struct GNUNET_PeerIdentity *peer, 351 const struct GNUNET_PeerIdentity *peer,
352 const struct GNUNET_MessageHeader *message) 352 const struct GNUNET_MessageHeader *message)
353{ 353{
354 const struct RevokeMessage *rm; 354 const struct RevokeMessage *rm;
355 355
356 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 356 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
357 "Received REVOKE message from peer\n"); 357 "Received REVOKE message from peer\n");
358 rm = (const struct RevokeMessage *) message; 358 rm = (const struct RevokeMessage *) message;
359 GNUNET_break_op (GNUNET_SYSERR != publicize_rm (rm)); 359 GNUNET_break_op (GNUNET_SYSERR != publicize_rm (rm));
@@ -400,7 +400,7 @@ handle_core_connect (void *cls,
400 * @param peer peer identity this notification is about 400 * @param peer peer identity this notification is about
401 */ 401 */
402static void 402static void
403handle_core_disconnect (void *cls, 403handle_core_disconnect (void *cls,
404 const struct GNUNET_PeerIdentity *peer) 404 const struct GNUNET_PeerIdentity *peer)
405{ 405{
406 struct PeerEntry *pos; 406 struct PeerEntry *pos;
@@ -418,7 +418,7 @@ handle_core_disconnect (void *cls,
418 GNUNET_CONTAINER_multipeermap_remove (peers, peer, 418 GNUNET_CONTAINER_multipeermap_remove (peers, peer,
419 pos)); 419 pos));
420#if 0 420#if 0
421 if (pos->transmit_task != GNUNET_SCHEDULER_NO_TASK) 421 if (pos->transmit_task != GNUNET_SCHEDULER_NO_TASK)
422 { 422 {
423 GNUNET_SCHEDULER_cancel (pos->transmit_task); 423 GNUNET_SCHEDULER_cancel (pos->transmit_task);
424 pos->transmit_task = GNUNET_SCHEDULER_NO_TASK; 424 pos->transmit_task = GNUNET_SCHEDULER_NO_TASK;
@@ -436,7 +436,7 @@ handle_core_disconnect (void *cls,
436 436
437/** 437/**
438 * Free all values in a hash map. 438 * Free all values in a hash map.
439 * 439 *
440 * @param cls NULL 440 * @param cls NULL
441 * @param key the key 441 * @param key the key
442 * @param value value to free 442 * @param value value to free
@@ -506,12 +506,12 @@ shutdown_task (void *cls,
506 * @param identity the public identity of this peer 506 * @param identity the public identity of this peer
507 */ 507 */
508static void 508static void
509core_init (void *cls, 509core_init (void *cls,
510 const struct GNUNET_PeerIdentity *identity) 510 const struct GNUNET_PeerIdentity *identity)
511{ 511{
512 if (NULL == identity) 512 if (NULL == identity)
513 { 513 {
514 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 514 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
515 "Connection to core FAILED!\n"); 515 "Connection to core FAILED!\n");
516 GNUNET_SCHEDULER_shutdown (); 516 GNUNET_SCHEDULER_shutdown ();
517 return; 517 return;
@@ -528,7 +528,7 @@ core_init (void *cls,
528 * @param c configuration to use 528 * @param c configuration to use
529 */ 529 */
530static void 530static void
531run (void *cls, 531run (void *cls,
532 struct GNUNET_SERVER_Handle *server, 532 struct GNUNET_SERVER_Handle *server,
533 const struct GNUNET_CONFIGURATION_Handle *c) 533 const struct GNUNET_CONFIGURATION_Handle *c)
534{ 534{
@@ -562,7 +562,7 @@ run (void *cls,
562 return; 562 return;
563 } 563 }
564 cfg = c; 564 cfg = c;
565 srv = server; 565 srv = server;
566 revocation_map = GNUNET_CONTAINER_multihashmap_create (16, GNUNET_NO); 566 revocation_map = GNUNET_CONTAINER_multihashmap_create (16, GNUNET_NO);
567 nc = GNUNET_SERVER_notification_context_create (server, 1); 567 nc = GNUNET_SERVER_notification_context_create (server, 1);
568 if (GNUNET_OK != 568 if (GNUNET_OK !=
@@ -588,7 +588,7 @@ run (void *cls,
588 } 588 }
589 revocation_set = GNUNET_SET_create (cfg, 589 revocation_set = GNUNET_SET_create (cfg,
590 GNUNET_SET_OPERATION_UNION); 590 GNUNET_SET_OPERATION_UNION);
591 591
592 revocation_db = GNUNET_DISK_file_open (fn, 592 revocation_db = GNUNET_DISK_file_open (fn,
593 GNUNET_DISK_OPEN_READWRITE | 593 GNUNET_DISK_OPEN_READWRITE |
594 GNUNET_DISK_OPEN_CREATE, 594 GNUNET_DISK_OPEN_CREATE,
@@ -607,10 +607,10 @@ run (void *cls,
607 } 607 }
608 if (GNUNET_OK != 608 if (GNUNET_OK !=
609 GNUNET_DISK_file_size (fn, &left, GNUNET_YES, GNUNET_YES)) 609 GNUNET_DISK_file_size (fn, &left, GNUNET_YES, GNUNET_YES))
610 left = 0; 610 left = 0;
611 while (left > sizeof (struct RevokeMessage)) 611 while (left > sizeof (struct RevokeMessage))
612 { 612 {
613 rm = GNUNET_new (struct RevokeMessage); 613 rm = GNUNET_new (struct RevokeMessage);
614 if (sizeof (struct RevokeMessage) != 614 if (sizeof (struct RevokeMessage) !=
615 GNUNET_DISK_file_read (revocation_db, 615 GNUNET_DISK_file_read (revocation_db,
616 rm, 616 rm,
@@ -632,10 +632,10 @@ run (void *cls,
632 GNUNET_CONTAINER_multihashmap_put (revocation_map, 632 GNUNET_CONTAINER_multihashmap_put (revocation_map,
633 &hc, 633 &hc,
634 rm, 634 rm,
635 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 635 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
636 } 636 }
637 GNUNET_free (fn); 637 GNUNET_free (fn);
638 638
639 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, 639 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task,
640 NULL); 640 NULL);
641 peers = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_NO); 641 peers = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_NO);
@@ -668,7 +668,7 @@ run (void *cls,
668 * @return 0 ok, 1 on error 668 * @return 0 ok, 1 on error
669 */ 669 */
670int 670int
671main (int argc, 671main (int argc,
672 char *const *argv) 672 char *const *argv)
673{ 673{
674 return (GNUNET_OK == 674 return (GNUNET_OK ==
@@ -683,7 +683,7 @@ main (int argc,
683/** 683/**
684 * MINIMIZE heap size (way below 128k) since this process doesn't need much. 684 * MINIMIZE heap size (way below 128k) since this process doesn't need much.
685 */ 685 */
686void __attribute__ ((constructor)) 686void __attribute__ ((constructor))
687GNUNET_ARM_memory_init () 687GNUNET_ARM_memory_init ()
688{ 688{
689 mallopt (M_TRIM_THRESHOLD, 4 * 1024); 689 mallopt (M_TRIM_THRESHOLD, 4 * 1024);