diff options
-rw-r--r-- | brandt.c | 16 | ||||
-rw-r--r-- | brandt.h | 50 | ||||
-rw-r--r-- | internals.h | 8 |
3 files changed, 30 insertions, 44 deletions
@@ -185,7 +185,7 @@ seller_start (void *arg) | |||
185 | 185 | ||
186 | struct BRANDT_Auction * | 186 | struct BRANDT_Auction * |
187 | BRANDT_new (BRANDT_CbResult result, | 187 | BRANDT_new (BRANDT_CbResult result, |
188 | BRANDT_CbBroadcast broadcast, | 188 | BRANDT_CbDeliver broadcast, |
189 | BRANDT_CbStart start, | 189 | BRANDT_CbStart start, |
190 | void *auction_closure, | 190 | void *auction_closure, |
191 | void **auction_desc, | 191 | void **auction_desc, |
@@ -283,13 +283,13 @@ BRANDT_parse_desc (const void *auction_desc, | |||
283 | 283 | ||
284 | 284 | ||
285 | struct BRANDT_Auction * | 285 | struct BRANDT_Auction * |
286 | BRANDT_join (BRANDT_CbResult result, | 286 | BRANDT_join (BRANDT_CbResult result, |
287 | BRANDT_CbBroadcast broadcast, | 287 | BRANDT_CbDeliver broadcast, |
288 | BRANDT_CbUnicast unicast, | 288 | BRANDT_CbDeliver unicast, |
289 | void *auction_closure, | 289 | void *auction_closure, |
290 | const void *auction_desc, | 290 | const void *auction_desc, |
291 | size_t auction_desc_len, | 291 | size_t auction_desc_len, |
292 | uint16_t bid) | 292 | uint16_t bid) |
293 | { | 293 | { |
294 | struct BRANDT_Auction *ret = GNUNET_new (struct BRANDT_Auction); | 294 | struct BRANDT_Auction *ret = GNUNET_new (struct BRANDT_Auction); |
295 | 295 | ||
@@ -68,36 +68,22 @@ typedef uint16_t | |||
68 | 68 | ||
69 | 69 | ||
70 | /** | 70 | /** |
71 | * Functions of this type are called by libbrandt to broadcast messages to the | 71 | * Functions of this type are called by libbrandt to deliver messages to other |
72 | * blackboard of a specific auction. They have to be sent using authenticated | 72 | * participants of an auction. There are two variants how this Callback needs to |
73 | * encryption. | 73 | * be implemented. The first is delivering messages as unicast directly to the |
74 | * seller, the second is delivering messages as broadcast to all participants | ||
75 | * (bidders + seller). All messages need to be authenticated and encrypted | ||
76 | * before sending and the signature needs to be checked immediately after | ||
77 | * receipt. | ||
74 | * | 78 | * |
75 | * @param[in] auction_closure Closure pointer representing the respective | 79 | * @param[in] auction_closure Closure pointer representing the respective |
76 | * auction. This is the Pointer given to BRANDT_join(). | 80 | * auction. This is the Pointer given to BRANDT_join() / BRANDT_new(). |
77 | * @param[in] msg The message to be broadcast to all participants of | 81 | * @param[in] msg The message to be delivered |
78 | * @a auction_closure. | ||
79 | * @param[in] msg_len The length of the message @a msg in bytes. | ||
80 | * @return 0 on success, -1 on failure. | ||
81 | */ | ||
82 | typedef int | ||
83 | (*BRANDT_CbBroadcast)(void *auction_closure, | ||
84 | const void *msg, | ||
85 | size_t msg_len); | ||
86 | |||
87 | |||
88 | /** | ||
89 | * Functions of this type are called by libbrandt to unicast messages to the | ||
90 | * seller of a specific auction. They have to be sent using authenticated | ||
91 | * encryption. | ||
92 | * | ||
93 | * @param[in] auction_closure Closure pointer representing the respective | ||
94 | * auction. This is the Pointer given to BRANDT_join(). | ||
95 | * @param[in] msg The message to be sent to the seller of @a auction_closure. | ||
96 | * @param[in] msg_len The length of the message @a msg in bytes. | 82 | * @param[in] msg_len The length of the message @a msg in bytes. |
97 | * @return 0 on success, -1 on failure. | 83 | * @return 0 on success, -1 on failure. |
98 | */ | 84 | */ |
99 | typedef int | 85 | typedef int |
100 | (*BRANDT_CbUnicast)(void *auction_closure, | 86 | (*BRANDT_CbDeliver)(void *auction_closure, |
101 | const void *msg, | 87 | const void *msg, |
102 | size_t msg_len); | 88 | size_t msg_len); |
103 | 89 | ||
@@ -166,13 +152,13 @@ BRANDT_parse_desc (const void *auction_desc, | |||
166 | * black-box pointer, do NOT dereference/change it or the data it points to! | 152 | * black-box pointer, do NOT dereference/change it or the data it points to! |
167 | */ | 153 | */ |
168 | struct BRANDT_Auction * | 154 | struct BRANDT_Auction * |
169 | BRANDT_join (BRANDT_CbResult result, | 155 | BRANDT_join (BRANDT_CbResult result, |
170 | BRANDT_CbBroadcast broadcast, | 156 | BRANDT_CbDeliver broadcast, |
171 | BRANDT_CbUnicast unicast, | 157 | BRANDT_CbDeliver unicast, |
172 | void *auction_closure, | 158 | void *auction_closure, |
173 | const void *auction_desc, | 159 | const void *auction_desc, |
174 | size_t auction_desc_len, | 160 | size_t auction_desc_len, |
175 | uint16_t bid); | 161 | uint16_t bid); |
176 | 162 | ||
177 | 163 | ||
178 | /* \todo: have cancellation (BRANDT_join_cancel()) */ | 164 | /* \todo: have cancellation (BRANDT_join_cancel()) */ |
@@ -208,7 +194,7 @@ BRANDT_join (BRANDT_CbResult result, | |||
208 | */ | 194 | */ |
209 | struct BRANDT_Auction * | 195 | struct BRANDT_Auction * |
210 | BRANDT_new (BRANDT_CbResult result, | 196 | BRANDT_new (BRANDT_CbResult result, |
211 | BRANDT_CbBroadcast broadcast, | 197 | BRANDT_CbDeliver broadcast, |
212 | BRANDT_CbStart start, | 198 | BRANDT_CbStart start, |
213 | void *auction_closure, | 199 | void *auction_closure, |
214 | void **auction_desc, | 200 | void **auction_desc, |
diff --git a/internals.h b/internals.h index d6de9db..8a82e2e 100644 --- a/internals.h +++ b/internals.h | |||
@@ -110,10 +110,10 @@ struct BRANDT_Auction { | |||
110 | 110 | ||
111 | void *closure; /** auction closure given by the user */ | 111 | void *closure; /** auction closure given by the user */ |
112 | 112 | ||
113 | BRANDT_CbResult result; /** result reporting callback */ | 113 | BRANDT_CbResult result; /** result reporting callback */ |
114 | BRANDT_CbBroadcast bcast; /** broadcast callback */ | 114 | BRANDT_CbDeliver bcast; /** broadcast callback */ |
115 | BRANDT_CbUnicast ucast; /** unicast callback */ | 115 | BRANDT_CbDeliver ucast; /** unicast callback */ |
116 | BRANDT_CbStart start; /** start callback */ | 116 | BRANDT_CbStart start; /** start callback */ |
117 | 117 | ||
118 | int seller_mode; /** If 0 we are bidding, selling otherwise */ | 118 | int seller_mode; /** If 0 we are bidding, selling otherwise */ |
119 | enum rounds cur_round; /** The round we expect messages from */ | 119 | enum rounds cur_round; /** The round we expect messages from */ |