From 0ba8f80bc1ac4ac88b007626eea493e7560ea4cb Mon Sep 17 00:00:00 2001 From: Markus Teich Date: Fri, 2 Dec 2016 11:45:05 +0100 Subject: unify msg delivery callback --- brandt.h | 50 ++++++++++++++++++-------------------------------- 1 file changed, 18 insertions(+), 32 deletions(-) (limited to 'brandt.h') diff --git a/brandt.h b/brandt.h index 3029031..f441f00 100644 --- a/brandt.h +++ b/brandt.h @@ -68,36 +68,22 @@ typedef uint16_t /** - * 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 - * encryption. + * Functions of this type are called by libbrandt to deliver messages to other + * participants of an auction. There are two variants how this Callback needs to + * be implemented. The first is delivering messages as unicast directly to the + * seller, the second is delivering messages as broadcast to all participants + * (bidders + seller). All messages need to be authenticated and encrypted + * before sending and the signature needs to be checked immediately after + * receipt. * * @param[in] auction_closure Closure pointer representing the respective - * auction. This is the Pointer given to BRANDT_join(). - * @param[in] msg The message to be broadcast to all participants of - * @a auction_closure. - * @param[in] msg_len The length of the message @a msg in bytes. - * @return 0 on success, -1 on failure. - */ -typedef int -(*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. 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(). - * @param[in] msg The message to be sent to the seller of @a auction_closure. + * auction. This is the Pointer given to BRANDT_join() / BRANDT_new(). + * @param[in] msg The message to be delivered * @param[in] msg_len The length of the message @a msg in bytes. * @return 0 on success, -1 on failure. */ typedef int -(*BRANDT_CbUnicast)(void *auction_closure, +(*BRANDT_CbDeliver)(void *auction_closure, const void *msg, size_t msg_len); @@ -166,13 +152,13 @@ BRANDT_parse_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_CbResult result, - BRANDT_CbBroadcast broadcast, - BRANDT_CbUnicast unicast, - void *auction_closure, - const void *auction_desc, - size_t auction_desc_len, - uint16_t bid); +BRANDT_join (BRANDT_CbResult result, + BRANDT_CbDeliver broadcast, + BRANDT_CbDeliver unicast, + void *auction_closure, + const void *auction_desc, + size_t auction_desc_len, + uint16_t bid); /* \todo: have cancellation (BRANDT_join_cancel()) */ @@ -208,7 +194,7 @@ BRANDT_join (BRANDT_CbResult result, */ struct BRANDT_Auction * BRANDT_new (BRANDT_CbResult result, - BRANDT_CbBroadcast broadcast, + BRANDT_CbDeliver broadcast, BRANDT_CbStart start, void *auction_closure, void **auction_desc, -- cgit v1.2.3