aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--brandt.c15
-rw-r--r--brandt.h27
-rw-r--r--internals.h22
-rw-r--r--platform.h2
-rw-r--r--test_brandt.c16
5 files changed, 61 insertions, 21 deletions
diff --git a/brandt.c b/brandt.c
index 03337c4..e90ec2f 100644
--- a/brandt.c
+++ b/brandt.c
@@ -60,8 +60,9 @@ start_auction (void *arg)
struct BRANDT_Auction *
-BRANDT_new (BRANDT_CbBroadcast broadcast,
- BRANDT_CbResult result,
+BRANDT_new (BRANDT_CbResult result,
+ BRANDT_CbBroadcast broadcast,
+ BRANDT_CbStart start,
void *auction_closure,
void **auction_desc,
size_t *auction_desc_len,
@@ -97,7 +98,7 @@ BRANDT_new (BRANDT_CbBroadcast broadcast,
ret->k = num_prices;
ret->m = m;
ret->outcome_public = outcome_public;
- ret->cur_round = msg_join;
+ ret->cur_round = msg_init;
ret->round_progress = gcry_mpi_new (256);
/* we are the seller */
@@ -107,9 +108,9 @@ BRANDT_new (BRANDT_CbBroadcast broadcast,
ret->closure = auction_closure;
ret->bcast = broadcast;
ret->result = result;
+ ret->start = start;
until_start = GNUNET_TIME_absolute_get_remaining (time_start);
- /* \todo: store returned task somewhere to cancel it on shutdown */
ret->task = GNUNET_SCHEDULER_add_delayed (until_start,
&start_auction,
ret);
@@ -178,9 +179,9 @@ BRANDT_verify_desc (const void *auction_desc,
struct BRANDT_Auction *
-BRANDT_join (BRANDT_CbBroadcast broadcast,
+BRANDT_join (BRANDT_CbResult result,
+ BRANDT_CbBroadcast broadcast,
BRANDT_CbUnicast unicast,
- BRANDT_CbResult result,
void *auction_closure,
const void *auction_desc,
size_t auction_desc_len,
@@ -202,7 +203,7 @@ BRANDT_join (BRANDT_CbBroadcast broadcast,
weprintf ("failed to parse auction description blob");
return NULL;
}
- ret->cur_round = msg_join;
+ ret->cur_round = msg_init;
ret->round_progress = gcry_mpi_new (256);
/* we are the seller */
diff --git a/brandt.h b/brandt.h
index dad324a..1903301 100644
--- a/brandt.h
+++ b/brandt.h
@@ -31,6 +31,22 @@
/** defined in internals.h */
struct BRANDT_Auction;
+
+/**
+ * Functions of this type are called by libbrandt when the auction should be
+ * started. The application has to announce the ordered list of all bidders to
+ * them and must return the amount of bidders. After this function is called no
+ * more new bidders may be accepted by the application. This callback is only
+ * used if the auction is in seller mode.
+ *
+ * @param[in] auction_closure Closure pointer representing the respective
+ * auction. This is the Pointer given to BRANDT_new().
+ * @return The amount of bidders participating in the auction.
+ */
+typedef uint16_t
+(*BRANDT_CbStart)(void *auction_closure);
+
+
/**
* Functions of this type are called by libbrandt to broadcast messages to the
* blackboard of a specific auction. They have to be sent using authenticated
@@ -70,7 +86,7 @@ typedef int
* Functions of this type are called by libbrandt to report the auction outcome
* or malicious/erroneous participants.
*
- * \todo: export proof of erroneous behaviour.
+ * \todo: export proof of erroneous behaviour / outcome.
*
* @param[in] auction_closure Closure pointer representing the respective
* auction. This is the Pointer given to BRANDT_join() / BRANDT_new().
@@ -135,9 +151,9 @@ BRANDT_verify_desc (const void *auction_desc,
* black-box pointer, do NOT dereference/change it or the data it points to!
*/
struct BRANDT_Auction *
-BRANDT_join (BRANDT_CbBroadcast broadcast,
+BRANDT_join (BRANDT_CbResult result,
+ BRANDT_CbBroadcast broadcast,
BRANDT_CbUnicast unicast,
- BRANDT_CbResult result,
void *auction_closure,
const void *auction_desc,
size_t auction_desc_len,
@@ -182,8 +198,9 @@ BRANDT_join (BRANDT_CbBroadcast broadcast,
* black-box pointer, do NOT dereference/change it or the data it points to!
*/
struct BRANDT_Auction *
-BRANDT_new (BRANDT_CbBroadcast broadcast,
- BRANDT_CbResult result,
+BRANDT_new (BRANDT_CbResult result,
+ BRANDT_CbBroadcast broadcast,
+ BRANDT_CbStart start,
void *auction_closure,
void **auction_desc,
size_t *auction_desc_len,
diff --git a/internals.h b/internals.h
index 23dab78..a1c939a 100644
--- a/internals.h
+++ b/internals.h
@@ -29,7 +29,6 @@
enum rounds {
- msg_join,
msg_init,
msg_bid,
msg_outcome,
@@ -39,21 +38,27 @@ enum rounds {
enum auction_type {
- auction_firstPrice,
- auction_mPlusFirstPrice,
- auction_last
+ auction_firstPrice = 0,
+ auction_mPlusFirstPrice = 1,
+ auction_last = 2
};
enum outcome_type {
- outcome_private,
- outcome_public,
- outcome_last
+ outcome_private = 0,
+ outcome_public = 1,
+ outcome_last = 2
};
GNUNET_NETWORK_STRUCT_BEGIN
+struct msg_head {
+ uint32_t prot_version GNUNET_PACKED;
+ uint32_t msg_type GNUNET_PACKED;
+};
+
+
/**
* This struct describes an auction and is always linked to a description buffer
* of #description_len bytes of arbitrary data where the description of the item
@@ -121,9 +126,10 @@ struct BRANDT_Auction {
void *closure; /** auction closure given by the user */
+ BRANDT_CbResult result; /** result reporting callback */
BRANDT_CbBroadcast bcast; /** broadcast callback */
BRANDT_CbUnicast ucast; /** unicast callback */
- BRANDT_CbResult result; /** result reporting callback */
+ BRANDT_CbStart start; /** start callback */
int seller_mode; /** If 0 we are bidding, selling otherwise */
enum rounds cur_round; /** The round we expect messages from */
diff --git a/platform.h b/platform.h
index e47c28c..4d454be 100644
--- a/platform.h
+++ b/platform.h
@@ -31,7 +31,7 @@
# ifdef HAVE_CONFIG_H
# include "brandt_config.h"
# endif /* ifdef HAVE_CONFIG_H */
-#endif /* ifndef HAVE_USED_CONFIG_H */
+#endif /* ifndef HAVE_USED_CONFIG_H */
/* Include GNUnet's platform file */
#include <gnunet/platform.h>
diff --git a/test_brandt.c b/test_brandt.c
index 17f1d10..c5a8d3b 100644
--- a/test_brandt.c
+++ b/test_brandt.c
@@ -43,6 +43,7 @@ run_new_join (void *arg)
ad_seller = BRANDT_new (NULL,
NULL,
NULL,
+ NULL,
&desc,
&desc_len,
description,
@@ -75,6 +76,21 @@ run_new_join (void *arg)
return;
}
+ if (ad_seller->k != ad_bidder->k ||
+ ad_seller->m != ad_bidder->m ||
+ ad_seller->outcome_public != ad_bidder->outcome_public ||
+ ad_seller->time_start.abs_value_us
+ != ad_bidder->time_start.abs_value_us ||
+ ad_seller->time_round.rel_value_us
+ != ad_bidder->time_round.rel_value_us ||
+ !ad_seller->seller_mode ||
+ ad_bidder->seller_mode)
+ {
+ weprintf ("error/mismatch in basic auction data");
+ *ret = 0;
+ return;
+ }
+
BRANDT_destroy (ad_seller);
BRANDT_destroy (ad_bidder);