aboutsummaryrefslogtreecommitdiff
path: root/brandt.c
diff options
context:
space:
mode:
authorMarkus Teich <markus.teich@stusta.mhn.de>2016-12-02 09:34:25 +0100
committerMarkus Teich <markus.teich@stusta.mhn.de>2016-12-02 09:34:25 +0100
commit56b43dab7ff80acc4cd0e7ad3057abd5e6bad680 (patch)
tree74b6a5f1ff6f8994582926112b4102574784f524 /brandt.c
parentaee7167739e666ea94c3b68c58a0f7aa1ede238e (diff)
downloadlibbrandt-56b43dab7ff80acc4cd0e7ad3057abd5e6bad680.tar.gz
libbrandt-56b43dab7ff80acc4cd0e7ad3057abd5e6bad680.zip
migrate to GNUNET_log
Diffstat (limited to 'brandt.c')
-rw-r--r--brandt.c60
1 files changed, 44 insertions, 16 deletions
diff --git a/brandt.c b/brandt.c
index 5a75eda..86239a8 100644
--- a/brandt.c
+++ b/brandt.c
@@ -37,13 +37,18 @@ BRANDT_init (struct GNUNET_CRYPTO_EccDlogContext *dlogctx)
37 37
38 /* SECMEM cannot be resized dynamically. We do not know how much we need */ 38 /* SECMEM cannot be resized dynamically. We do not know how much we need */
39 if ((err = gcry_control (GCRYCTL_DISABLE_SECMEM, 0))) 39 if ((err = gcry_control (GCRYCTL_DISABLE_SECMEM, 0)))
40 weprintf ("failed to set libgcrypt option DISABLE_SECMEM: %s", 40 GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING,
41 gcry_strerror (err)); 41 "libbrandt",
42 "failed to set libgcrypt option DISABLE_SECMEM: %s\n",
43 gcry_strerror (err));
42 44
43 /* ecc is slow otherwise and we don't create long term keys anyway. */ 45 /* ecc is slow otherwise and we don't create long term keys anyway. */
44 if ((err = gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0))) 46 if ((err = gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0)))
45 weprintf ("failed to set libgcrypt option ENABLE_QUICK_RANDOM: %s", 47 GNUNET_log_from (
46 gcry_strerror (err)); 48 GNUNET_ERROR_TYPE_WARNING,
49 "libbrandt",
50 "failed to set libgcrypt option ENABLE_QUICK_RANDOM: %s\n",
51 gcry_strerror (err));
47 52
48 gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); 53 gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
49 brandt_crypto_init (dlogctx); 54 brandt_crypto_init (dlogctx);
@@ -110,7 +115,9 @@ BRANDT_bidder_start (struct BRANDT_Auction *auction,
110 !(buf = handler_out[atype][outcome][msg_init](auction, &buflen))) 115 !(buf = handler_out[atype][outcome][msg_init](auction, &buflen)))
111 { 116 {
112 /** \todo */ 117 /** \todo */
113 weprintf ("wow fail out"); 118 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
119 "libbrandt",
120 "wow fail out\n");
114 return; 121 return;
115 } 122 }
116 123
@@ -132,7 +139,9 @@ seller_start (void *arg)
132 ad->n = ad->start (ad->closure); 139 ad->n = ad->start (ad->closure);
133 if (0 == ad->n) 140 if (0 == ad->n)
134 { 141 {
135 weprintf ("no bidders registered for auction"); 142 GNUNET_log_from (GNUNET_ERROR_TYPE_INFO,
143 "libbrandt",
144 "no bidders registered for auction\n");
136 ad->result (ad->closure, NULL, 0); 145 ad->result (ad->closure, NULL, 0);
137 return; 146 return;
138 } 147 }
@@ -141,7 +150,9 @@ seller_start (void *arg)
141 struct BRANDT_Result *res = GNUNET_new_array (ad->n, 150 struct BRANDT_Result *res = GNUNET_new_array (ad->n,
142 struct BRANDT_Result); 151 struct BRANDT_Result);
143 152
144 weprintf ("less bidders than needed, selling for lowest price"); 153 GNUNET_log_from (GNUNET_ERROR_TYPE_INFO,
154 "libbrandt",
155 "less bidders than needed, selling for lowest price\n");
145 for (uint16_t i = 0; i < ad->n; i++) 156 for (uint16_t i = 0; i < ad->n; i++)
146 { 157 {
147 res[i].bidder = i; 158 res[i].bidder = i;
@@ -237,13 +248,17 @@ BRANDT_parse_desc (const void *auction_desc,
237 248
238 if (sizeof (struct BRANDT_DescrP) != auction_desc_len) 249 if (sizeof (struct BRANDT_DescrP) != auction_desc_len)
239 { 250 {
240 weprintf ("auction desc struct size mismatch"); 251 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
252 "libbrandt",
253 "auction desc struct size mismatch\n");
241 return -1; 254 return -1;
242 } 255 }
243 256
244 if (0 != memcmp (&desc->reserved, &zero, sizeof (desc->reserved))) 257 if (0 != memcmp (&desc->reserved, &zero, sizeof (desc->reserved)))
245 { 258 {
246 weprintf ("reserved field in auction description must be zero"); 259 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
260 "libbrandt",
261 "reserved field in auction description must be zero\n");
247 return -1; 262 return -1;
248 } 263 }
249 264
@@ -282,7 +297,9 @@ BRANDT_join (BRANDT_CbResult result,
282 &ret->outcome_public)) 297 &ret->outcome_public))
283 { 298 {
284 GNUNET_free (ret); 299 GNUNET_free (ret);
285 weprintf ("failed to parse auction description blob"); 300 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
301 "libbrandt",
302 "failed to parse auction description blob\n");
286 return NULL; 303 return NULL;
287 } 304 }
288 ret->cur_round = msg_init; 305 ret->cur_round = msg_init;
@@ -378,8 +395,10 @@ advance_round (struct BRANDT_Auction *ad,
378 if (!handler_out[atype][outcome][ad->cur_round] || 395 if (!handler_out[atype][outcome][ad->cur_round] ||
379 !(buf = handler_out[atype][outcome][ad->cur_round](ad, &buflen))) 396 !(buf = handler_out[atype][outcome][ad->cur_round](ad, &buflen)))
380 { 397 {
381 weprintf ("failed to create msg %d buffer as seller", 398 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
382 ad->cur_round); 399 "libbrandt",
400 "failed to create msg %d buffer as seller\n",
401 ad->cur_round);
383 return; 402 return;
384 } 403 }
385 ad->bcast (ad->closure, buf, buflen); 404 ad->bcast (ad->closure, buf, buflen);
@@ -410,7 +429,10 @@ advance_round (struct BRANDT_Auction *ad,
410 if (!handler_out[atype][outcome][ad->cur_round] || 429 if (!handler_out[atype][outcome][ad->cur_round] ||
411 !(buf = handler_out[atype][outcome][ad->cur_round](ad, &buflen))) 430 !(buf = handler_out[atype][outcome][ad->cur_round](ad, &buflen)))
412 { 431 {
413 weprintf ("failed to create msg %d buffer as bidder", ad->cur_round); 432 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
433 "libbrandt",
434 "failed to create msg %d buffer as bidder\n",
435 ad->cur_round);
414 return; 436 return;
415 } 437 }
416 438
@@ -441,14 +463,18 @@ BRANDT_got_message (struct BRANDT_Auction *auction,
441 /** \todo: cache out of order messages instead of discarding */ 463 /** \todo: cache out of order messages instead of discarding */
442 if (ntohl (head->msg_type) != round || ntohl (head->prot_version) != 0) 464 if (ntohl (head->msg_type) != round || ntohl (head->prot_version) != 0)
443 { 465 {
444 weprintf ("got unexpected message, ignoring..."); 466 GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING,
467 "libbrandt",
468 "got unexpected message, ignoring...\n");
445 return; 469 return;
446 } 470 }
447 471
448 /* check if we already got that round message from the same user */ 472 /* check if we already got that round message from the same user */
449 if (gcry_mpi_test_bit (auction->round_progress, sender)) 473 if (gcry_mpi_test_bit (auction->round_progress, sender))
450 { 474 {
451 weprintf ("got a duplicate message from user %d", sender); 475 GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING,
476 "libbrandt",
477 "got a duplicate message from user %d\n", sender);
452 return; 478 return;
453 } 479 }
454 480
@@ -459,7 +485,9 @@ BRANDT_got_message (struct BRANDT_Auction *auction,
459 sender)) 485 sender))
460 { 486 {
461 /** \todo */ 487 /** \todo */
462 weprintf ("wow fail in"); 488 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
489 "libbrandt",
490 "wow fail in\n");
463 return; 491 return;
464 } 492 }
465 gcry_mpi_set_bit (auction->round_progress, sender); 493 gcry_mpi_set_bit (auction->round_progress, sender);