diff options
Diffstat (limited to 'brandt.h')
-rw-r--r-- | brandt.h | 99 |
1 files changed, 42 insertions, 57 deletions
@@ -23,19 +23,16 @@ | |||
23 | #ifndef _BRANDT_BRANDT_H | 23 | #ifndef _BRANDT_BRANDT_H |
24 | #define _BRANDT_BRANDT_H | 24 | #define _BRANDT_BRANDT_H |
25 | 25 | ||
26 | #include <unistd.h> | ||
27 | #include <stdint.h> | 26 | #include <stdint.h> |
27 | #include <unistd.h> | ||
28 | 28 | ||
29 | /** | 29 | /** defined in internals.h */ |
30 | * \todo. | ||
31 | */ | ||
32 | struct BRANDT_Auction; | 30 | struct BRANDT_Auction; |
33 | 31 | ||
34 | /** | 32 | /** |
35 | * Functions of this type are called by libbrandt to broadcast messages to the | 33 | * Functions of this type are called by libbrandt to broadcast messages to the |
36 | * blackboard of a specific auction. | 34 | * blackboard of a specific auction. They have to be sent using authenticated |
37 | * | 35 | * encryption. |
38 | * \todo: how must the message be handled? (encryption, auth, reliability, …) | ||
39 | * | 36 | * |
40 | * @param[in] auction_closure Closure pointer representing the respective | 37 | * @param[in] auction_closure Closure pointer representing the respective |
41 | * auction. This is the Pointer given to BRANDT_join(). | 38 | * auction. This is the Pointer given to BRANDT_join(). |
@@ -45,16 +42,15 @@ struct BRANDT_Auction; | |||
45 | * @return 0 on success, -1 on failure. | 42 | * @return 0 on success, -1 on failure. |
46 | */ | 43 | */ |
47 | typedef int | 44 | typedef int |
48 | (*BRANDT_BroadcastCallback)(void * auction_closure, | 45 | (*BRANDT_CbBroadcast)(void *auction_closure, |
49 | const void *msg, | 46 | const void *msg, |
50 | size_t msg_len); | 47 | size_t msg_len); |
51 | 48 | ||
52 | 49 | ||
53 | /** | 50 | /** |
54 | * Functions of this type are called by libbrandt to unicast messages to the | 51 | * Functions of this type are called by libbrandt to unicast messages to the |
55 | * seller of a specific auction. | 52 | * seller of a specific auction. They have to be sent using authenticated |
56 | * | 53 | * encryption. |
57 | * \todo: how must the message be handled? (encryption, auth, reliability, …) | ||
58 | * | 54 | * |
59 | * @param[in] auction_closure Closure pointer representing the respective | 55 | * @param[in] auction_closure Closure pointer representing the respective |
60 | * auction. This is the Pointer given to BRANDT_join(). | 56 | * auction. This is the Pointer given to BRANDT_join(). |
@@ -63,16 +59,15 @@ typedef int | |||
63 | * @return 0 on success, -1 on failure. | 59 | * @return 0 on success, -1 on failure. |
64 | */ | 60 | */ |
65 | typedef int | 61 | typedef int |
66 | (*BRANDT_UnicastSellerCallback)(void * auction_closure, | 62 | (*BRANDT_CbUnicast)(void *auction_closure, |
67 | const void *msg, | 63 | const void *msg, |
68 | size_t msg_len); | 64 | size_t msg_len); |
69 | 65 | ||
70 | 66 | ||
71 | /** | 67 | /** |
72 | * Functions of this type are called by libbrandt to report the auction outcome | 68 | * Functions of this type are called by libbrandt to report the auction outcome |
73 | * or malicious/erroneous participants. | 69 | * or malicious/erroneous participants. |
74 | * | 70 | * |
75 | * \todo: update price type. | ||
76 | * \todo: export proof of erroneous behaviour. | 71 | * \todo: export proof of erroneous behaviour. |
77 | * | 72 | * |
78 | * @param[in] auction_closure Closure pointer representing the respective | 73 | * @param[in] auction_closure Closure pointer representing the respective |
@@ -84,10 +79,10 @@ typedef int | |||
84 | * is private and the user did not win. | 79 | * is private and the user did not win. |
85 | */ | 80 | */ |
86 | typedef void | 81 | typedef void |
87 | (*BRANDT_ReportResultCallback)(void * auction_closure, | 82 | (*BRANDT_CbResult)(void *auction_closure, |
88 | unsigned int bidder_id, | 83 | unsigned int bidder_id, |
89 | int status, | 84 | int status, |
90 | uint16_t price); | 85 | uint16_t price); |
91 | 86 | ||
92 | 87 | ||
93 | void | 88 | void |
@@ -98,7 +93,7 @@ BRANDT_init (); | |||
98 | * | 93 | * |
99 | * @param[in] broadcast Pointer to the broadcast callback function | 94 | * @param[in] broadcast Pointer to the broadcast callback function |
100 | * @param[in] unicast Pointer to the unicast callback function | 95 | * @param[in] unicast Pointer to the unicast callback function |
101 | * @param[in] report Pointer to the report callback function | 96 | * @param[in] result Pointer to the result callback function |
102 | * @param[in] auction_closure Closure pointer representing the auction. This | 97 | * @param[in] auction_closure Closure pointer representing the auction. This |
103 | * will not be touched by libbrandt. It is only passed to the callbacks. | 98 | * will not be touched by libbrandt. It is only passed to the callbacks. |
104 | * @param[in] auction_data The auction information data a an opaque data | 99 | * @param[in] auction_data The auction information data a an opaque data |
@@ -110,12 +105,12 @@ BRANDT_init (); | |||
110 | * black-box pointer, do NOT access/change it or the data it points to! | 105 | * black-box pointer, do NOT access/change it or the data it points to! |
111 | */ | 106 | */ |
112 | struct BRANDT_Auction * | 107 | struct BRANDT_Auction * |
113 | BRANDT_join (BRANDT_BroadcastCallback broadcast, | 108 | BRANDT_join (BRANDT_CbBroadcast broadcast, |
114 | BRANDT_UnicastSellerCallback unicast, | 109 | BRANDT_CbUnicast unicast, |
115 | BRANDT_ReportResultCallback report, | 110 | BRANDT_CbResult result, |
116 | const void * auction_closure, | 111 | const void *auction_closure, |
117 | const void * auction_data, | 112 | const void *auction_data, |
118 | size_t auction_data_len); | 113 | size_t auction_data_len); |
119 | /* \todo: where do I specify my bid? */ | 114 | /* \todo: where do I specify my bid? */ |
120 | 115 | ||
121 | 116 | ||
@@ -132,7 +127,7 @@ BRANDT_join (BRANDT_BroadcastCallback broadcast, | |||
132 | * Create a new auction described by the @a auction_data parameter. | 127 | * Create a new auction described by the @a auction_data parameter. |
133 | * | 128 | * |
134 | * @param[in] broadcast Pointer to the broadcast callback function | 129 | * @param[in] broadcast Pointer to the broadcast callback function |
135 | * @param[in] report Pointer to the report callback function | 130 | * @param[in] result Pointer to the result callback function |
136 | * @param[in] auction_closure Closure pointer representing the auction. This | 131 | * @param[in] auction_closure Closure pointer representing the auction. This |
137 | * will not be touched by libbrandt. It is only passed to the callbacks. | 132 | * will not be touched by libbrandt. It is only passed to the callbacks. |
138 | * @param[out] auction_data The auction information data a an opaque data | 133 | * @param[out] auction_data The auction information data a an opaque data |
@@ -155,45 +150,35 @@ BRANDT_join (BRANDT_BroadcastCallback broadcast, | |||
155 | * black-box pointer, do NOT access/change it or the data it points to! | 150 | * black-box pointer, do NOT access/change it or the data it points to! |
156 | */ | 151 | */ |
157 | struct BRANDT_Auction * | 152 | struct BRANDT_Auction * |
158 | BRANDT_new (BRANDT_BroadcastCallback broadcast, | 153 | BRANDT_new (BRANDT_CbBroadcast broadcast, |
159 | BRANDT_ReportResultCallback report, | 154 | BRANDT_CbResult result, |
160 | const void * auction_closure, | 155 | void *auction_closure, |
161 | const void ** auction_data, | 156 | void **auction_data, |
162 | size_t * auction_data_len, | 157 | size_t *auction_data_len, |
163 | uint16_t num_prices, | 158 | uint16_t num_prices, |
164 | uint16_t m, | 159 | uint16_t m, |
165 | int outcome_public); | 160 | int outcome_public); |
166 | 161 | ||
167 | 162 | ||
168 | /** | 163 | /** \todo */ |
169 | * Receive a broadcast message related to a specific auction. | ||
170 | * | ||
171 | * @param[in] auction The pointer returned by BRANDT_join() or BRANDT_new() from | ||
172 | * which message @a msg was received. | ||
173 | * @param[in] msg The message that was received. | ||
174 | * @param[in] msg_len The length in bytes of @a msg. | ||
175 | */ | ||
176 | void | 164 | void |
177 | BRANDT_got_broadcast (struct BRANDT_Auction *auction, | 165 | BRANDT_free (); |
178 | void * msg, | ||
179 | size_t msg_len); | ||
180 | 166 | ||
181 | 167 | ||
182 | /** | 168 | /** |
183 | * Receive a unicast message from a bidder related to a specific auction. | 169 | * Receive a message related to a specific auction. |
184 | * | 170 | * |
185 | * @param[in] auction The pointer returned by BRANDT_new() from which message | 171 | * @param[in] auction The pointer returned by BRANDT_join() or BRANDT_new() from |
186 | * @a msg was received. | 172 | * which message @a msg was received. |
173 | * @param[in] sender The id of the sender. | ||
187 | * @param[in] msg The message that was received. | 174 | * @param[in] msg The message that was received. |
188 | * @param[in] msg_len The length in bytes of @a msg. | 175 | * @param[in] msg_len The length in bytes of @a msg. |
189 | * \todo: how to link message to sender id within auction? | ||
190 | * ANSWER: on start, know that we have 'n' participants, here give | ||
191 | * participant number (1..n) | ||
192 | */ | 176 | */ |
193 | void | 177 | void |
194 | BRANDT_got_unicast (struct BRANDT_Auction *auction, | 178 | BRANDT_got_message (struct BRANDT_Auction *auction, |
195 | void * msg, | 179 | uint16_t sender, |
196 | size_t msg_len); | 180 | const unsigned char *msg, |
181 | size_t msg_len); | ||
197 | 182 | ||
198 | 183 | ||
199 | /**\todo: Error handling functions? */ | 184 | /**\todo: Error handling functions? */ |