From 4deee5eb1247b46d04c4ab8eeba52ca4e4db0567 Mon Sep 17 00:00:00 2001 From: Markus Teich Date: Wed, 6 Jul 2016 14:56:14 +0200 Subject: start with brandt.c --- brandt.h | 99 +++++++++++++++++++++++++++------------------------------------- 1 file changed, 42 insertions(+), 57 deletions(-) (limited to 'brandt.h') diff --git a/brandt.h b/brandt.h index e66866d..dd1c8a0 100644 --- a/brandt.h +++ b/brandt.h @@ -23,19 +23,16 @@ #ifndef _BRANDT_BRANDT_H #define _BRANDT_BRANDT_H -#include #include +#include -/** - * \todo. - */ +/** defined in internals.h */ struct BRANDT_Auction; /** * Functions of this type are called by libbrandt to broadcast messages to the - * blackboard of a specific auction. - * - * \todo: how must the message be handled? (encryption, auth, reliability, …) + * blackboard of a specific auction. They have to be sent using authenticated + * encryption. * * @param[in] auction_closure Closure pointer representing the respective * auction. This is the Pointer given to BRANDT_join(). @@ -45,16 +42,15 @@ struct BRANDT_Auction; * @return 0 on success, -1 on failure. */ typedef int -(*BRANDT_BroadcastCallback)(void * auction_closure, - const void *msg, - size_t msg_len); +(*BRANDT_CbBroadcast)(void *auction_closure, + const void *msg, + size_t msg_len); /** * Functions of this type are called by libbrandt to unicast messages to the - * seller of a specific auction. - * - * \todo: how must the message be handled? (encryption, auth, reliability, …) + * seller of a specific auction. They have to be sent using authenticated + * encryption. * * @param[in] auction_closure Closure pointer representing the respective * auction. This is the Pointer given to BRANDT_join(). @@ -63,16 +59,15 @@ typedef int * @return 0 on success, -1 on failure. */ typedef int -(*BRANDT_UnicastSellerCallback)(void * auction_closure, - const void *msg, - size_t msg_len); +(*BRANDT_CbUnicast)(void *auction_closure, + const void *msg, + size_t msg_len); /** * Functions of this type are called by libbrandt to report the auction outcome * or malicious/erroneous participants. * - * \todo: update price type. * \todo: export proof of erroneous behaviour. * * @param[in] auction_closure Closure pointer representing the respective @@ -84,10 +79,10 @@ typedef int * is private and the user did not win. */ typedef void -(*BRANDT_ReportResultCallback)(void * auction_closure, - unsigned int bidder_id, - int status, - uint16_t price); +(*BRANDT_CbResult)(void *auction_closure, + unsigned int bidder_id, + int status, + uint16_t price); void @@ -98,7 +93,7 @@ BRANDT_init (); * * @param[in] broadcast Pointer to the broadcast callback function * @param[in] unicast Pointer to the unicast callback function - * @param[in] report Pointer to the report callback function + * @param[in] result Pointer to the result callback function * @param[in] auction_closure Closure pointer representing the auction. This * will not be touched by libbrandt. It is only passed to the callbacks. * @param[in] auction_data The auction information data a an opaque data @@ -110,12 +105,12 @@ BRANDT_init (); * black-box pointer, do NOT access/change it or the data it points to! */ struct BRANDT_Auction * -BRANDT_join (BRANDT_BroadcastCallback broadcast, - BRANDT_UnicastSellerCallback unicast, - BRANDT_ReportResultCallback report, - const void * auction_closure, - const void * auction_data, - size_t auction_data_len); +BRANDT_join (BRANDT_CbBroadcast broadcast, + BRANDT_CbUnicast unicast, + BRANDT_CbResult result, + const void *auction_closure, + const void *auction_data, + size_t auction_data_len); /* \todo: where do I specify my bid? */ @@ -132,7 +127,7 @@ BRANDT_join (BRANDT_BroadcastCallback broadcast, * Create a new auction described by the @a auction_data parameter. * * @param[in] broadcast Pointer to the broadcast callback function - * @param[in] report Pointer to the report callback function + * @param[in] result Pointer to the result callback function * @param[in] auction_closure Closure pointer representing the auction. This * will not be touched by libbrandt. It is only passed to the callbacks. * @param[out] auction_data The auction information data a an opaque data @@ -155,45 +150,35 @@ BRANDT_join (BRANDT_BroadcastCallback broadcast, * black-box pointer, do NOT access/change it or the data it points to! */ struct BRANDT_Auction * -BRANDT_new (BRANDT_BroadcastCallback broadcast, - BRANDT_ReportResultCallback report, - const void * auction_closure, - const void ** auction_data, - size_t * auction_data_len, - uint16_t num_prices, - uint16_t m, - int outcome_public); +BRANDT_new (BRANDT_CbBroadcast broadcast, + BRANDT_CbResult result, + void *auction_closure, + void **auction_data, + size_t *auction_data_len, + uint16_t num_prices, + uint16_t m, + int outcome_public); -/** - * Receive a broadcast message related to a specific auction. - * - * @param[in] auction The pointer returned by BRANDT_join() or BRANDT_new() from - * which message @a msg was received. - * @param[in] msg The message that was received. - * @param[in] msg_len The length in bytes of @a msg. - */ +/** \todo */ void -BRANDT_got_broadcast (struct BRANDT_Auction *auction, - void * msg, - size_t msg_len); +BRANDT_free (); /** - * Receive a unicast message from a bidder related to a specific auction. + * Receive a message related to a specific auction. * - * @param[in] auction The pointer returned by BRANDT_new() from which message - * @a msg was received. + * @param[in] auction The pointer returned by BRANDT_join() or BRANDT_new() from + * which message @a msg was received. + * @param[in] sender The id of the sender. * @param[in] msg The message that was received. * @param[in] msg_len The length in bytes of @a msg. - * \todo: how to link message to sender id within auction? - * ANSWER: on start, know that we have 'n' participants, here give - * participant number (1..n) */ void -BRANDT_got_unicast (struct BRANDT_Auction *auction, - void * msg, - size_t msg_len); +BRANDT_got_message (struct BRANDT_Auction *auction, + uint16_t sender, + const unsigned char *msg, + size_t msg_len); /**\todo: Error handling functions? */ -- cgit v1.2.3