diff options
author | Gabor X Toth <*@tg-x.net> | 2013-06-26 17:12:59 +0000 |
---|---|---|
committer | Gabor X Toth <*@tg-x.net> | 2013-06-26 17:12:59 +0000 |
commit | 2fc296b9df9bb7559f044a1769da8d2e43771b39 (patch) | |
tree | 6adb5c64011a15ca08e22eec3f5afc1ea6faad2c /src/include/gnunet_psyc_service.h | |
parent | d74bfc8a7987f457a1f4380108fd3296581bf52e (diff) | |
download | gnunet-2fc296b9df9bb7559f044a1769da8d2e43771b39.tar.gz gnunet-2fc296b9df9bb7559f044a1769da8d2e43771b39.zip |
psyc apis: use more doxygen syntax, added some missing docs
Diffstat (limited to 'src/include/gnunet_psyc_service.h')
-rw-r--r-- | src/include/gnunet_psyc_service.h | 506 |
1 files changed, 259 insertions, 247 deletions
diff --git a/src/include/gnunet_psyc_service.h b/src/include/gnunet_psyc_service.h index 8116e3d93..e2a839243 100644 --- a/src/include/gnunet_psyc_service.h +++ b/src/include/gnunet_psyc_service.h | |||
@@ -18,7 +18,7 @@ | |||
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file include/gnunet_psyc_service.h | 22 | * @file include/gnunet_psyc_service.h |
23 | * @brief PSYC service; high-level access to the PSYC protocol | 23 | * @brief PSYC service; high-level access to the PSYC protocol |
24 | * note that clients of this API are NOT expected to | 24 | * note that clients of this API are NOT expected to |
@@ -88,53 +88,53 @@ extern "C" | |||
88 | #include "gnunet_multicast_service.h" | 88 | #include "gnunet_multicast_service.h" |
89 | 89 | ||
90 | 90 | ||
91 | /** | 91 | /** |
92 | * Version number of GNUnet-PSYC API. | 92 | * Version number of GNUnet-PSYC API. |
93 | */ | 93 | */ |
94 | #define GNUNET_PSYC_VERSION 0x00000000 | 94 | #define GNUNET_PSYC_VERSION 0x00000000 |
95 | 95 | ||
96 | 96 | ||
97 | /** | 97 | /** |
98 | * Information flags for data fragments set via PSYC. | 98 | * Information flags for data fragments set via PSYC. |
99 | */ | 99 | */ |
100 | enum GNUNET_PSYC_FragmentStatus | 100 | enum GNUNET_PSYC_FragmentStatus |
101 | { | 101 | { |
102 | /** | 102 | /** |
103 | * This is the first part of data for the given method call. | 103 | * This is the first part of data for the given method call. |
104 | */ | 104 | */ |
105 | GNUNET_PSYC_FS_FIRST = 1, | 105 | GNUNET_PSYC_FS_FIRST = 1, |
106 | 106 | ||
107 | /** | 107 | /** |
108 | * This is the last part of data for the given method call. | 108 | * This is the last part of data for the given method call. |
109 | */ | 109 | */ |
110 | GNUNET_PSYC_FS_LAST = 2, | 110 | GNUNET_PSYC_FS_LAST = 2, |
111 | 111 | ||
112 | /** | 112 | /** |
113 | * OR'ed flags if payload is not fragmented. | 113 | * OR'ed flags if payload is not fragmented. |
114 | */ | 114 | */ |
115 | GNUNET_PSYC_FS_NOT_FRAGMENTED = (GNUNET_PSYC_FS_FIRST | GNUNET_PSYC_FS_LAST) | 115 | GNUNET_PSYC_FS_NOT_FRAGMENTED = (GNUNET_PSYC_FS_FIRST | GNUNET_PSYC_FS_LAST) |
116 | }; | 116 | }; |
117 | 117 | ||
118 | 118 | ||
119 | /** | 119 | /** |
120 | * Method called from PSYC upon receiving a message indicating a call | 120 | * Method called from PSYC upon receiving a message indicating a call |
121 | * to a 'method'. | 121 | * to a @e method. |
122 | * | 122 | * |
123 | * @param cls closure | 123 | * @param cls Closure. |
124 | * @param full_method_name original method name from PSYC (may be more | 124 | * @param full_method_name Original method name from PSYC (may be more |
125 | * specific than the registered method name due to try-and-slice matching) | 125 | * specific than the registered method name due to try-and-slice matching). |
126 | * @param sender who transmitted the message (origin, except for messages | 126 | * @param sender Who transmitted the message (origin, except for messages |
127 | * from one of the members to the origin) | 127 | * from one of the members to the origin). |
128 | * @param message_id unique message counter for this message; | 128 | * @param message_id Unique message counter for this message; |
129 | * (unique only in combination with the given sender for | 129 | * (unique only in combination with the given sender for |
130 | * this channel) | 130 | * this channel). |
131 | * @param group_generation group generation counter for this message | 131 | * @param group_generation Group generation counter for this message |
132 | * (always zero for messages from members to channel owner); FIXME: needed? | 132 | * (always zero for messages from members to channel owner); FIXME: needed? |
133 | * @param data_off byte offset of 'data' in the overall data of the method | 133 | * @param data_off Byte offset of @a data in the overall data of the method. |
134 | * @param data_size number of bytes in 'data'; | 134 | * @param data_size Number of bytes in @a data. |
135 | * @param data data stream given to the method (might not be zero-terminated | 135 | * @param data Data stream given to the method (might not be zero-terminated |
136 | * if data is binary) | 136 | * if data is binary). |
137 | * @param frag fragmentation status for the data | 137 | * @param frag Fragmentation status for the data. |
138 | */ | 138 | */ |
139 | typedef int (*GNUNET_PSYC_Method)(void *cls, | 139 | typedef int (*GNUNET_PSYC_Method)(void *cls, |
140 | const char *full_method_name, | 140 | const char *full_method_name, |
@@ -147,28 +147,28 @@ typedef int (*GNUNET_PSYC_Method)(void *cls, | |||
147 | enum GNUNET_PSYC_FragmentStatus frag); | 147 | enum GNUNET_PSYC_FragmentStatus frag); |
148 | 148 | ||
149 | 149 | ||
150 | /** | 150 | /** |
151 | * Handle for the channel of a PSYC group. | 151 | * Handle for the channel of a PSYC group. |
152 | */ | 152 | */ |
153 | struct GNUNET_PSYC_Channel; | 153 | struct GNUNET_PSYC_Channel; |
154 | 154 | ||
155 | 155 | ||
156 | /** | 156 | /** |
157 | * Start a PSYC channel. Will create a multicast group identified by | 157 | * Create a PSYC channel. |
158 | * the given ECC key. Messages recevied from group members will be | 158 | * |
159 | * given to the respective handler methods. If a new member wants to | 159 | * Will create a multicast group identified by the given ECC key. Messages |
160 | * join a group, the "join" method handler will be invoked; the join | 160 | * received from group members will be given to the respective handler methods. |
161 | * handler must then generate a "join" message to approve the joining | 161 | * If a new member wants to join a group, the "join" method handler will be |
162 | * of the new member. The channel can also change group membership | 162 | * invoked; the join handler must then generate a "join" message to approve the |
163 | * without explicit requests. Note that PSYC doesn't itself "understand" | 163 | * joining of the new member. The channel can also change group membership |
164 | * join or leave messages, the respective methods must call other | 164 | * without explicit requests. Note that PSYC doesn't itself "understand" join |
165 | * PSYC functions to inform PSYC about the meaning of the respective | 165 | * or leave messages, the respective methods must call other PSYC functions to |
166 | * events. | 166 | * inform PSYC about the meaning of the respective events. |
167 | * | 167 | * |
168 | * @param cfg configuration to use (to connect to PSYC service) | 168 | * @param cfg Configuration to use (to connect to PSYC service). |
169 | * @param method functions to invoke on messages received from members, | 169 | * @param method Function to invoke on messages received from members, |
170 | * typcially at least contains functions for 'join' and 'leave'. | 170 | * typcially at least contains functions for @e join and @e leave. |
171 | * @param method_cls closure for 'method' | 171 | * @param method_cls Closure for @a method. |
172 | * @param priv_key ECC key that will be used to sign messages for this | 172 | * @param priv_key ECC key that will be used to sign messages for this |
173 | * PSYC session; public key is used to identify the | 173 | * PSYC session; public key is used to identify the |
174 | * PSYC group; FIXME: we'll likely want to use | 174 | * PSYC group; FIXME: we'll likely want to use |
@@ -177,46 +177,46 @@ struct GNUNET_PSYC_Channel; | |||
177 | * directly, but rather look it up in GADS for groups | 177 | * directly, but rather look it up in GADS for groups |
178 | * managed by other users, or select a file with the private | 178 | * managed by other users, or select a file with the private |
179 | * key(s) when setting up their own channels | 179 | * key(s) when setting up their own channels |
180 | * @param join_policy what is the membership policy of the group? | 180 | * @param join_policy What is the membership policy of the group? |
181 | * Used to automate group management decisions. | 181 | * Used to automate group management decisions. |
182 | * @return handle for the channel, NULL on error | 182 | * @return Handle for the channel, NULL on error. |
183 | */ | 183 | */ |
184 | struct GNUNET_PSYC_Channel * | 184 | struct GNUNET_PSYC_Channel * |
185 | GNUNET_PSYC_channel_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | 185 | GNUNET_PSYC_channel_create (const struct GNUNET_CONFIGURATION_Handle *cfg, |
186 | GNUNET_PSYC_Method method, | 186 | GNUNET_PSYC_Method method, |
187 | void *method_cls, | 187 | void *method_cls, |
188 | const struct GNUNET_CRYPTO_EccPrivateKey *priv_key, | 188 | const struct GNUNET_CRYPTO_EccPrivateKey *priv_key, |
189 | enum GNUNET_MULTICAST_JoinPolicy join_policy); | 189 | enum GNUNET_MULTICAST_JoinPolicy join_policy); |
190 | 190 | ||
191 | 191 | ||
192 | /** | 192 | /** |
193 | * Possible operations on PSYC state (persistent) and variables (per message). | 193 | * Possible operations on PSYC state (persistent) and variables (per message). |
194 | */ | 194 | */ |
195 | enum GNUNET_PSYC_Operator | 195 | enum GNUNET_PSYC_Operator |
196 | { | 196 | { |
197 | /** | 197 | /** |
198 | * Replace the full state with the new value ("="). | 198 | * Replace the full state with the new value ("="). |
199 | */ | 199 | */ |
200 | GNUNET_PSYC_SOT_SET_STATE = 0, | 200 | GNUNET_PSYC_SOT_SET_STATE = 0, |
201 | 201 | ||
202 | /** | 202 | /** |
203 | * Delete the complete entry from the state (given data must be | 203 | * Delete the complete entry from the state (given data must be |
204 | * empty). Equivalent to 'SET' with emtpy data, but more | 204 | * empty). Equivalent to @a SET with empty data, but more |
205 | * explicit ("="); | 205 | * explicit ("="); |
206 | */ | 206 | */ |
207 | GNUNET_PSYC_SOT_DELETE = 0, | 207 | GNUNET_PSYC_SOT_DELETE = 0, |
208 | 208 | ||
209 | /** | 209 | /** |
210 | * Set the value of a variable to a new value (":"). | 210 | * Set the value of a variable to a new value (":"). |
211 | */ | 211 | */ |
212 | GNUNET_PSYC_SOT_SET_VARIABLE, | 212 | GNUNET_PSYC_SOT_SET_VARIABLE, |
213 | 213 | ||
214 | /** | 214 | /** |
215 | * Add the given value to the set of values in the state ("+"). | 215 | * Add the given value to the set of values in the state ("+"). |
216 | */ | 216 | */ |
217 | GNUNET_PSYC_SOT_ADD_STATE, | 217 | GNUNET_PSYC_SOT_ADD_STATE, |
218 | 218 | ||
219 | /** | 219 | /** |
220 | * Remove the given value from the set of values in the state ("-"). | 220 | * Remove the given value from the set of values in the state ("-"). |
221 | */ | 221 | */ |
222 | GNUNET_PSYC_SOT_REMOVE_STATE | 222 | GNUNET_PSYC_SOT_REMOVE_STATE |
@@ -224,23 +224,23 @@ enum GNUNET_PSYC_Operator | |||
224 | }; | 224 | }; |
225 | 225 | ||
226 | 226 | ||
227 | /** | 227 | /** |
228 | * Update channel state (or set a variable). The state of a channel | 228 | * Update channel state (or set a variable). |
229 | * must fit into the memory of each member (and the channel); large | 229 | * |
230 | * values that require streaming must only be passed as the stream | 230 | * The state of a channel must fit into the memory of each member (and the |
231 | * arguments to methods. State updates might not be transmitted to | 231 | * channel); large values that require streaming must only be passed as the |
232 | * group members until the next call to | 232 | * stream arguments to methods. State updates might not be transmitted to group |
233 | * 'GNUNET_PSYC_channel_notify_transmit_ready'. Variable updates must | 233 | * members until the next call to GNUNET_PSYC_channel_notify_transmit_ready(). |
234 | * be given just before the call to the respective method that needs | 234 | * Variable updates must be given just before the call to the respective method |
235 | * the variables. | 235 | * that needs the variables. |
236 | * | 236 | * |
237 | * @param channel handle to the PSYC group / channel | 237 | * @param channel Handle to the PSYC group / channel. |
238 | * @param full_state_name name of the field in the channel state to change | 238 | * @param full_state_name Name of the field in the channel state to change. |
239 | * @param type kind of update operation (add, remove, replace, delete) | 239 | * @param type Kind of update operation (add, remove, replace, delete). |
240 | * @param data_size number of bytes in data | 240 | * @param data_size Number of bytes in data. |
241 | * @param data new state value | 241 | * @param data New state value. |
242 | * @return GNUNET_OK on success, GNUNET_SYSERR on internal error | 242 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on internal error |
243 | * (i.e. state too large) | 243 | * (i.e. state too large). |
244 | */ | 244 | */ |
245 | int | 245 | int |
246 | GNUNET_PSYC_channel_state_update (struct GNUNET_PSYC_Channel *channel, | 246 | GNUNET_PSYC_channel_state_update (struct GNUNET_PSYC_Channel *channel, |
@@ -250,24 +250,25 @@ GNUNET_PSYC_channel_state_update (struct GNUNET_PSYC_Channel *channel, | |||
250 | const void *data); | 250 | const void *data); |
251 | 251 | ||
252 | 252 | ||
253 | /** | 253 | /** |
254 | * Function called to provide data for a transmission via PSYC. Note | 254 | * Function called to provide data for a transmission via PSYC. |
255 | * that returning GNUNET_OK or GNUNET_SYSERR (but not GNUNET_NO) | 255 | * |
256 | * Note that returning #GNUNET_OK or #GNUNET_SYSERR (but not #GNUNET_NO) | ||
256 | * invalidates the respective transmission handle. | 257 | * invalidates the respective transmission handle. |
257 | * | 258 | * |
258 | * @param cls closure | 259 | * @param cls Closure. |
259 | * @param message_id set to the unique message ID that was generated for | 260 | * @param message_id Set to the unique message ID that was generated for |
260 | * this message | 261 | * this message. |
261 | * @param group_generation set to the group generation used for this | 262 | * @param group_generation Set to the group generation used for this |
262 | * message | 263 | * message. |
263 | * @param data_size initially set to the number of bytes available in 'data', | 264 | * @param data_size[in,out] Initially set to the number of bytes available in @a data, |
264 | * should be set to the number of bytes written to data (IN/OUT) | 265 | * should be set to the number of bytes written to data (IN/OUT). |
265 | * @param data where to write the body of the message to give to the method; | 266 | * @param data[out] Where to write the body of the message to give to the method; |
266 | * function must copy at most '*data_size' bytes to 'data'. | 267 | * function must copy at most @a *data_size bytes to @a data. |
267 | * @return GNUNET_SYSERR on error (fatal, aborts transmission) | 268 | * @return #GNUNET_SYSERR on error (fatal, aborts transmission) |
268 | * GNUNET_NO on success, if more data is to be transmitted later | 269 | * #GNUNET_NO on success, if more data is to be transmitted later |
269 | * (should be used if 'data_size' was not big enough to take all the data) | 270 | * (should be used if @a *data_size was not big enough to take all the data) |
270 | * GNUNET_YES if this completes the transmission (all data supplied) | 271 | * #GNUNET_YES if this completes the transmission (all data supplied) |
271 | */ | 272 | */ |
272 | typedef int (*GNUNET_PSYC_ChannelReadyNotify)(void *cls, | 273 | typedef int (*GNUNET_PSYC_ChannelReadyNotify)(void *cls, |
273 | uint64_t message_id, | 274 | uint64_t message_id, |
@@ -276,22 +277,22 @@ typedef int (*GNUNET_PSYC_ChannelReadyNotify)(void *cls, | |||
276 | void *data); | 277 | void *data); |
277 | 278 | ||
278 | 279 | ||
279 | /** | 280 | /** |
280 | * Handle for a pending PSYC transmission operation. | 281 | * Handle for a pending PSYC transmission operation. |
281 | */ | 282 | */ |
282 | struct GNUNET_PSYC_ChannelTransmitHandle; | 283 | struct GNUNET_PSYC_ChannelTransmitHandle; |
283 | 284 | ||
284 | 285 | ||
285 | /** | 286 | /** |
286 | * Send a message to call a method to all members in the PSYC channel. | 287 | * Send a message to call a method to all members in the PSYC channel. |
287 | * | 288 | * |
288 | * @param channel handle to the PSYC multicast group | 289 | * @param channel Handle to the PSYC multicast group. |
289 | * @param increment_group_generation GNUNET_YES if we need to increment | 290 | * @param increment_group_generation #GNUNET_YES if we need to increment |
290 | * the group generation counter after transmitting this message | 291 | * the group generation counter after transmitting this message. |
291 | * @param full_method_name which method should be invoked | 292 | * @param full_method_name Which method should be invoked. |
292 | * @param notify function to call to obtain the arguments | 293 | * @param notify Function to call to obtain the arguments. |
293 | * @param notify_cls closure for 'notify' | 294 | * @param notify_cls Closure for @a notify. |
294 | * @return transmission handle, NULL on error (i.e. more than one request queued) | 295 | * @return Transmission handle, NULL on error (i.e. more than one request queued). |
295 | */ | 296 | */ |
296 | struct GNUNET_PSYC_ChannelTransmitHandle * | 297 | struct GNUNET_PSYC_ChannelTransmitHandle * |
297 | GNUNET_PSYC_channel_notify_transmit_ready (struct GNUNET_PSYC_Channel *channel, | 298 | GNUNET_PSYC_channel_notify_transmit_ready (struct GNUNET_PSYC_Channel *channel, |
@@ -301,69 +302,70 @@ GNUNET_PSYC_channel_notify_transmit_ready (struct GNUNET_PSYC_Channel *channel, | |||
301 | void *notify_cls); | 302 | void *notify_cls); |
302 | 303 | ||
303 | 304 | ||
304 | /** | 305 | /** |
305 | * Abort transmission request to channel. | 306 | * Abort transmission request to channel. |
306 | * | 307 | * |
307 | * @param th handle of the request that is being aborted | 308 | * @param th Handle of the request that is being aborted. |
308 | */ | 309 | */ |
309 | void | 310 | void |
310 | GNUNET_PSYC_channel_notify_transmit_ready_cancel (struct GNUNET_PSYC_ChannelTransmitHandle *th); | 311 | GNUNET_PSYC_channel_notify_transmit_ready_cancel (struct GNUNET_PSYC_ChannelTransmitHandle *th); |
311 | 312 | ||
312 | 313 | ||
313 | /** | 314 | /** |
314 | * End a PSYC channel. | 315 | * Destroy a PSYC channel. |
315 | * | 316 | * |
316 | * @param channel PSYC channel to terminate | 317 | * @param channel PSYC channel to terminate. |
317 | */ | 318 | */ |
318 | void | 319 | tvoid |
319 | GNUNET_PSYC_channel_end (struct GNUNET_PSYC_Channel *channel); | 320 | GNUNET_PSYC_channel_destroy (struct GNUNET_PSYC_Channel *channel); |
320 | 321 | ||
321 | 322 | ||
322 | /** | 323 | /** |
323 | * Handle to access PSYC group operations for all members. | 324 | * Handle to access PSYC group operations for all members. |
324 | */ | 325 | */ |
325 | struct GNUNET_PSYC_Group; | 326 | struct GNUNET_PSYC_Group; |
326 | 327 | ||
327 | 328 | ||
328 | /** | 329 | /** |
329 | * Convert 'channel' to a 'group' handle to access the 'group' APIs. | 330 | * Convert @a channel to a @e group handle to access the @e group APIs. |
330 | * | 331 | * |
331 | * @param channel channel handle | 332 | * @param channel Channel handle. |
332 | * @return group handle, valid for as long as 'channel' is valid | 333 | * @return Group handle, valid for as long as @a channel is valid. |
333 | */ | 334 | */ |
334 | struct GNUNET_PSYC_Group * | 335 | struct GNUNET_PSYC_Group * |
335 | GNUNET_PSYC_channel_get_group (struct GNUNET_PSYC_Channel *channel); | 336 | GNUNET_PSYC_channel_get_group (struct GNUNET_PSYC_Channel *channel); |
336 | 337 | ||
337 | 338 | ||
338 | /** | 339 | /** |
339 | * Convert 'member' to a 'group' handle to access the 'group' APIs. | 340 | * Convert @a member to a @e group handle to access the @e group APIs. |
340 | * | 341 | * |
341 | * @param member membership handle | 342 | * @param member Membership handle. |
342 | * @return group handle, valid for as long as 'member' is valid | 343 | * @return Group handle, valid for as long as @a member is valid. |
343 | */ | 344 | */ |
344 | struct GNUNET_PSYC_Group * | 345 | struct GNUNET_PSYC_Group * |
345 | GNUNET_PSYC_member_get_group (struct GNUNET_PSYC_Member *member); | 346 | GNUNET_PSYC_member_get_group (struct GNUNET_PSYC_Member *member); |
346 | 347 | ||
347 | 348 | ||
348 | /** | 349 | /** |
349 | * Add a member to the group. Note that this will NOT generate any | 350 | * Add a member to the group. |
350 | * PSYC traffic, it will merely update the local data base to modify | 351 | * |
351 | * how we react to 'membership test' queries. The channel still needs to | 352 | * Note that this will NOT generate any PSYC traffic, it will merely update the |
352 | * explicitly transmit a 'join' message to notify other group members | 353 | * local data base to modify how we react to <em>membership test</em> queries. The |
353 | * and they then also must still call this function in their respective | 354 | * channel still needs to explicitly transmit a @e join message to notify other |
354 | * methods handling the 'join' message. This way, how 'join' and 'leave' | 355 | * group members and they then also must still call this function in their |
355 | * operations are exactly implemented is still up to the application; | 356 | * respective methods handling the @e join message. This way, how @e join and |
356 | * for example, there might be a 'leave_all' method to kick out everyone. | 357 | * @e leave operations are exactly implemented is still up to the application; |
358 | * for example, there might be a @e leave_all method to kick out everyone. | ||
357 | * | 359 | * |
358 | * Note that group members are explicitly trusted to execute such | 360 | * Note that group members are explicitly trusted to execute such |
359 | * methods correctly; not doing so correctly will result in either | 361 | * methods correctly; not doing so correctly will result in either |
360 | * denying members access or offering access to group data to | 362 | * denying members access or offering access to group data to |
361 | * non-members. | 363 | * non-members. |
362 | * | 364 | * |
363 | * @param group group handle | 365 | * @param group Group handle. |
364 | * @param member which peer to add | 366 | * @param member Which peer to add. |
365 | * @param message_id message ID for the message that changed the membership | 367 | * @param message_id Message ID for the message that changed the membership. |
366 | * @param group_generation the generation ID where the change went into effect | 368 | * @param group_generation The generation ID where the change went into effect. |
367 | */ | 369 | */ |
368 | void | 370 | void |
369 | GNUNET_PSYC_group_member_add (struct GNUNET_PSYC_Group *group, | 371 | GNUNET_PSYC_group_member_add (struct GNUNET_PSYC_Group *group, |
@@ -372,25 +374,26 @@ GNUNET_PSYC_group_member_add (struct GNUNET_PSYC_Group *group, | |||
372 | uint64_t group_generation); | 374 | uint64_t group_generation); |
373 | 375 | ||
374 | 376 | ||
375 | /** | 377 | /** |
376 | * Remove a member from the group. Note that this will NOT generate any | 378 | * Remove a member from the group. |
377 | * PSYC traffic, it will merely update the local data base to modify | 379 | * |
378 | * how we react to 'membership test' queries. The channel still needs to | 380 | * Note that this will NOT generate any PSYC traffic, it will merely update the |
379 | * explicitly transmit a 'leave' message to notify other group members | 381 | * local data base to modify how we react to <em>membership test</em> queries. The |
380 | * and they then also must still call this function in their respective | 382 | * channel still needs to explicitly transmit a @e leave message to notify other |
381 | * methods handling the 'leave' message. This way, how 'join' and 'leave' | 383 | * group members and they then also must still call this function in their |
382 | * operations are exactly implemented is still up to the application; | 384 | * respective methods handling the @e leave message. This way, how @e join and |
383 | * for example, there might be a 'leave_all' message to kick out everyone. | 385 | * @e leave operations are exactly implemented is still up to the application; |
386 | * for example, there might be a @e leave_all message to kick out everyone. | ||
384 | * | 387 | * |
385 | * Note that group members are explicitly trusted to perform these | 388 | * Note that group members are explicitly trusted to perform these |
386 | * operations correctly; not doing so correctly will result in either | 389 | * operations correctly; not doing so correctly will result in either |
387 | * denying members access or offering access to group data to | 390 | * denying members access or offering access to group data to |
388 | * non-members. | 391 | * non-members. |
389 | * | 392 | * |
390 | * @param group group handle | 393 | * @param group Group handle. |
391 | * @param member which peer to remove | 394 | * @param member Which peer to remove. |
392 | * @param message_id message ID for the message that changed the membership | 395 | * @param message_id Message ID for the message that changed the membership. |
393 | * @param group_generation the generation ID where the change went into effect | 396 | * @param group_generation The generation ID where the change went into effect. |
394 | */ | 397 | */ |
395 | void | 398 | void |
396 | GNUNET_PSYC_group_member_remove (struct GNUNET_PSYC_Group *group, | 399 | GNUNET_PSYC_group_member_remove (struct GNUNET_PSYC_Group *group, |
@@ -399,16 +402,16 @@ GNUNET_PSYC_group_member_remove (struct GNUNET_PSYC_Group *group, | |||
399 | uint64_t group_generation); | 402 | uint64_t group_generation); |
400 | 403 | ||
401 | 404 | ||
402 | /** | 405 | /** |
403 | * Function called to inform a member about state changes for a | 406 | * Function called to inform a member about state changes for a channel. |
404 | * channel. Note that (for sets) only the delta is communicated, not | ||
405 | * the full state. | ||
406 | * | 407 | * |
407 | * @param cls closure | 408 | * Note that (for sets) only the delta is communicated, not the full state. |
408 | * @param full_state_name full name of the state | 409 | * |
409 | * @param type how to interpret the change | 410 | * @param cls Closure. |
410 | * @param state_value information about the new state | 411 | * @param full_state_name Full name of the state. |
411 | * @param state_value_size number of bytes in 'state_value' | 412 | * @param type How to interpret the change. |
413 | * @param state_value Information about the new state. | ||
414 | * @param state_value_size Number of bytes in @a state_value. | ||
412 | */ | 415 | */ |
413 | typedef void (*GNUNET_PSYC_StateCallback)(void *cls, | 416 | typedef void (*GNUNET_PSYC_StateCallback)(void *cls, |
414 | const char *full_state_name, | 417 | const char *full_state_name, |
@@ -417,48 +420,49 @@ typedef void (*GNUNET_PSYC_StateCallback)(void *cls, | |||
417 | size_t state_value_size); | 420 | size_t state_value_size); |
418 | 421 | ||
419 | 422 | ||
420 | /** | 423 | /** |
421 | * Descriptor for an event handler handling PSYC state updates. | 424 | * Descriptor for an event handler handling PSYC state updates. |
422 | */ | 425 | */ |
423 | struct GNUNET_PSYC_StateHandler | 426 | struct GNUNET_PSYC_StateHandler |
424 | { | 427 | { |
425 | 428 | ||
426 | /** | 429 | /** |
427 | * Name of the state this handler calls about, used in try-and-slice matching. | 430 | * Name of the state variable this handler calls about, used in try-and-slice matching. |
428 | */ | 431 | */ |
429 | const char *state_name; | 432 | const char *state_name; |
430 | 433 | ||
431 | /** | 434 | /** |
432 | * Function to call whenever the respective state changes. | 435 | * Function to call whenever the respective state changes. |
433 | */ | 436 | */ |
434 | GNUNET_PSYC_StateCallback event_handler; | 437 | GNUNET_PSYC_StateCallback event_handler; |
435 | 438 | ||
436 | /** | 439 | /** |
437 | * Closure for the 'event_handler' function. | 440 | * Closure for the @a event_handler function. |
438 | */ | 441 | */ |
439 | void *event_handler_cls; | 442 | void *event_handler_cls; |
440 | 443 | ||
441 | }; | 444 | }; |
442 | 445 | ||
443 | 446 | ||
444 | /** | 447 | /** |
445 | * Join a PSYC group. The entity joining is always the local peer. | 448 | * Join a PSYC group. |
446 | * The user must immediately use the 'GNUNET_PSYC_member_send_to_host' | 449 | * |
447 | * (and possibly 'GNUNET_PSYC_member_host_variable_set') functions to | 450 | * The entity joining is always the local peer. The user must immediately use |
448 | * transmit a 'join_msg' to the channel; if the join request succeeds, | 451 | * the GNUNET_PSYC_member_send_to_host() (and possibly |
449 | * the channel state (and 'recent' method calls) will be replayed to | 452 | * GNUNET_PSYC_member_host_variable_set()) functions to transmit a @e join_msg to |
450 | * the joining member. There is no explicit notification on failure | 453 | * the channel; if the join request succeeds, the channel state (and @e recent |
451 | * (as the channel may simply take days to approve, and disapproval is | 454 | * method calls) will be replayed to the joining member. There is no explicit |
452 | * simply being ignored). | 455 | * notification on failure (as the channel may simply take days to approve, and |
456 | * disapproval is simply being ignored). | ||
453 | * | 457 | * |
454 | * @param cfg configuration to use | 458 | * @param cfg Configuration to use. |
455 | * @param pub_key ECC key that identifies the channel we wish to join | 459 | * @param pub_key ECC key that identifies the channel we wish to join |
456 | * @param method function to invoke on messages received from the channel, | 460 | * @param method Function to invoke on messages received from the channel, |
457 | * typcially at least contains functions for 'join' and 'leave'. | 461 | * typically at least contains functions for @e join and @e leave. |
458 | * @param method_cls closure for 'method' | 462 | * @param method_cls Closure for @a method. |
459 | * @param state_count number of state handlers | 463 | * @param state_count Number of @a state_handlers. |
460 | * @param state_handlers array of state event handlers | 464 | * @param state_handlers Array of state event handlers. |
461 | * @return handle for the member, NULL on error | 465 | * @return Handle for the member, NULL on error. |
462 | */ | 466 | */ |
463 | struct GNUNET_PSYC_Member * | 467 | struct GNUNET_PSYC_Member * |
464 | GNUNET_PSYC_member_join (const struct GNUNET_CONFIGURATION_Handle *cfg, | 468 | GNUNET_PSYC_member_join (const struct GNUNET_CONFIGURATION_Handle *cfg, |
@@ -469,10 +473,12 @@ GNUNET_PSYC_member_join (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
469 | struct GNUNET_PSYC_StateHandler *state_handlers); | 473 | struct GNUNET_PSYC_StateHandler *state_handlers); |
470 | 474 | ||
471 | 475 | ||
472 | /** | 476 | /** |
473 | * Leave a multicast group. Will terminate the connection to the PSYC | 477 | * Leave a multicast group. |
474 | * service. Polite clients should first explicitly send a 'leave' | 478 | * |
475 | * request (via 'GNUNET_PSYC_member_send_to_host'). | 479 | * Will terminate the connection to the PSYC service. Polite clients should |
480 | * first explicitly send a @e leave request (via | ||
481 | * GNUNET_PSYC_member_send_to_host()). | ||
476 | * | 482 | * |
477 | * @param member membership handle | 483 | * @param member membership handle |
478 | */ | 484 | */ |
@@ -480,40 +486,41 @@ void | |||
480 | GNUNET_PSYC_member_leave (struct GNUNET_PSYC_Member *member); | 486 | GNUNET_PSYC_member_leave (struct GNUNET_PSYC_Member *member); |
481 | 487 | ||
482 | 488 | ||
483 | /** | 489 | /** |
484 | * Function called to provide data for a transmission to the channel | 490 | * Function called to provide data for a transmission to the channel |
485 | * owner (aka the 'host' of the channel). Note that returning | 491 | * owner (aka the @e host of the channel). |
486 | * GNUNET_OK or GNUNET_SYSERR (but not GNUNET_NO) invalidates the | 492 | * |
487 | * respective transmission handle. | 493 | * Note that returning #GNUNET_OK or #GNUNET_SYSERR (but not #GNUNET_NO) |
488 | * | 494 | * invalidates the respective transmission handle. |
489 | * @param cls closure | 495 | * |
490 | * @param data_size initially set to the number of bytes available in 'data', | 496 | * @param cls Closure. |
491 | * should be set to the number of bytes written to data (IN/OUT) | 497 | * @param data_size[in,out] Initially set to the number of bytes available in @a data, |
492 | * @param data where to write the body of the message to give to the method; | 498 | * should be set to the number of bytes written to data (IN/OUT). |
493 | * function must copy at most '*data_size' bytes to 'data'. | 499 | * @param data[out] Where to write the body of the message to give to the method; |
494 | * @return GNUNET_SYSERR on error (fatal, aborts transmission) | 500 | * function must copy at most @a *data_size bytes to @a data. |
495 | * GNUNET_NO on success, if more data is to be transmitted later | 501 | * @return #GNUNET_SYSERR on error (fatal, aborts transmission). |
496 | * GNUNET_YES if this completes the transmission (all data supplied) | 502 | * #GNUNET_NO on success, if more data is to be transmitted later. |
503 | * #GNUNET_YES if this completes the transmission (all data supplied). | ||
497 | */ | 504 | */ |
498 | typedef int (*GNUNET_PSYC_OriginReadyNotify)(void *cls, | 505 | typedef int (*GNUNET_PSYC_OriginReadyNotify)(void *cls, |
499 | size_t *data_size, | 506 | size_t *data_size, |
500 | char *data); | 507 | char *data); |
501 | 508 | ||
502 | 509 | ||
503 | /** | 510 | /** |
504 | * Handle for a pending PSYC transmission operation. | 511 | * Handle for a pending PSYC transmission operation. |
505 | */ | 512 | */ |
506 | struct GNUNET_PSYC_OriginTransmitHandle; | 513 | struct GNUNET_PSYC_OriginTransmitHandle; |
507 | 514 | ||
508 | 515 | ||
509 | /** | 516 | /** |
510 | * Request a message to be sent to the channel origin. | 517 | * Request a message to be sent to the channel origin. |
511 | * | 518 | * |
512 | * @param member membership handle | 519 | * @param member Membership handle. |
513 | * @param method_name which (PSYC) method should be invoked (on host) | 520 | * @param method_name Which (PSYC) method should be invoked (on host). |
514 | * @param notify function to call when we are allowed to transmit (to get data) | 521 | * @param notify Function to call when we are allowed to transmit (to get data). |
515 | * @param notify_cls closure for 'notify' | 522 | * @param notify_cls Closure for @a notify. |
516 | * @return transmission handle, NULL on error (i.e. more than one request queued) | 523 | * @return Transmission handle, NULL on error (i.e. more than one request queued). |
517 | */ | 524 | */ |
518 | struct GNUNET_PSYC_OriginTransmitHandle * | 525 | struct GNUNET_PSYC_OriginTransmitHandle * |
519 | GNUNET_PSYC_member_send_to_origin (struct GNUNET_PSYC_Member *member, | 526 | GNUNET_PSYC_member_send_to_origin (struct GNUNET_PSYC_Member *member, |
@@ -522,17 +529,19 @@ GNUNET_PSYC_member_send_to_origin (struct GNUNET_PSYC_Member *member, | |||
522 | void *notify_cls); | 529 | void *notify_cls); |
523 | 530 | ||
524 | 531 | ||
525 | /** | 532 | /** |
526 | * Set a (temporary, ":") variable for the next message being transmitted | 533 | * Set a (temporary, ":") variable for the next message being transmitted |
527 | * via 'GNUNET_PSYC_member_send_to_host'. If 'GNUNET_PSYC_member_send_to_host' | 534 | * via GNUNET_PSYC_member_send_to_host(). |
528 | * is called and then cancelled, all variables that were set using this | ||
529 | * function will be unset (lost/forgotten). To clear a variable state after | ||
530 | * setting it, you can also call this function again with NULL/0 for the value. | ||
531 | * | 535 | * |
532 | * @param member membership handle | 536 | * If GNUNET_PSYC_member_send_to_host() is called and then cancelled, all |
533 | * @param variable_name name of the variable to set | 537 | * variables that were set using this function will be unset (lost/forgotten). |
534 | * @param value value to set for the given variable | 538 | * To clear a variable state after setting it, you can also call this function |
535 | * @param value_size number of bytes in 'value' | 539 | * again with NULL/0 for the @a value. |
540 | * | ||
541 | * @param member Membership handle. | ||
542 | * @param variable_name Name of the variable to set. | ||
543 | * @param value Value to set for the given variable. | ||
544 | * @param value_size Number of bytes in @a value. | ||
536 | */ | 545 | */ |
537 | uint64_t | 546 | uint64_t |
538 | GNUNET_PSYC_member_origin_variable_set (struct GNUNET_PSYC_Member *member, | 547 | GNUNET_PSYC_member_origin_variable_set (struct GNUNET_PSYC_Member *member, |
@@ -541,40 +550,40 @@ GNUNET_PSYC_member_origin_variable_set (struct GNUNET_PSYC_Member *member, | |||
541 | size_t value_size); | 550 | size_t value_size); |
542 | 551 | ||
543 | 552 | ||
544 | /** | 553 | /** |
545 | * Abort transmission request to origin. | 554 | * Abort transmission request to origin. |
546 | * | 555 | * |
547 | * @param th handle of the request that is being aborted | 556 | * @param th Handle of the request that is being aborted. |
548 | */ | 557 | */ |
549 | void | 558 | void |
550 | GNUNET_PSYC_member_send_to_origin_cancel (struct GNUNET_PSYC_OriginTransmitHandle *th); | 559 | GNUNET_PSYC_member_send_to_origin_cancel (struct GNUNET_PSYC_OriginTransmitHandle *th); |
551 | 560 | ||
552 | 561 | ||
553 | /** | 562 | /** |
554 | * Handle to a story telling operation. | 563 | * Handle to a story telling operation. |
555 | */ | 564 | */ |
556 | struct GNUNET_PSYC_Story; | 565 | struct GNUNET_PSYC_Story; |
557 | 566 | ||
558 | 567 | ||
559 | /** | 568 | /** |
560 | * Request to be told the message history of the channel. Historic | 569 | * Request to be told the message history of the channel. |
561 | * messages (but NOT the state at the time) will be replayed (given to | ||
562 | * the normal method handlers) if available and if access is | ||
563 | * permitted. | ||
564 | * | 570 | * |
565 | * @param member which channel should be replayed? | 571 | * Historic messages (but NOT the state at the time) will be replayed (given to |
566 | * @param start earliest interesting point in history | 572 | * the normal method handlers) if available and if access is permitted. |
567 | * @param end last (exclusive) interesting point in history | 573 | * |
568 | * @param method function to invoke on messages received from the story | 574 | * @param member Which channel should be replayed? |
569 | * @param method_cls closure for 'method' | 575 | * @param start Earliest interesting point in history. |
570 | * @param finish_cb function to call when the requested story has been fully | 576 | * @param end Last (exclusive) interesting point in history. |
577 | * @param method Function to invoke on messages received from the story. | ||
578 | * @param method_cls Closure for @a method. | ||
579 | * @param finish_cb Function to call when the requested story has been fully | ||
571 | * told (counting message IDs might not suffice, as some messages | 580 | * told (counting message IDs might not suffice, as some messages |
572 | * might be secret and thus the listener would not know the story is | 581 | * might be secret and thus the listener would not know the story is |
573 | * finished without being told explicitly); once this function | 582 | * finished without being told explicitly); once this function |
574 | * has been called, the client must not call | 583 | * has been called, the client must not call |
575 | * 'GNUNET_PSYC_member_story_tell_cancel' anymore | 584 | * GNUNET_PSYC_member_story_tell_cancel() anymore. |
576 | * @param finish_cb_cls closure to finish_cb | 585 | * @param finish_cb_cls Closure to finish_cb. |
577 | * @return handle to cancel story telling operation | 586 | * @return Handle to cancel story telling operation. |
578 | */ | 587 | */ |
579 | struct GNUNET_PSYC_Story * | 588 | struct GNUNET_PSYC_Story * |
580 | GNUNET_PSYC_member_story_tell (struct GNUNET_PSYC_Member *member, | 589 | GNUNET_PSYC_member_story_tell (struct GNUNET_PSYC_Member *member, |
@@ -586,35 +595,37 @@ GNUNET_PSYC_member_story_tell (struct GNUNET_PSYC_Member *member, | |||
586 | void *finish_cb_cls); | 595 | void *finish_cb_cls); |
587 | 596 | ||
588 | 597 | ||
589 | /** | 598 | /** |
590 | * Abort story telling. This function must not be called from within | 599 | * Abort story telling. |
591 | * method handlers (as given to 'GNUNET_PSYC_member_join') of the | 600 | * |
592 | * member. | 601 | * This function must not be called from within method handlers (as given to |
602 | * GNUNET_PSYC_member_join()) of the member. | ||
593 | * | 603 | * |
594 | * @param story story telling operation to stop | 604 | * @param story Story telling operation to stop. |
595 | */ | 605 | */ |
596 | void | 606 | void |
597 | GNUNET_PSYC_member_story_tell_cancel (struct GNUNET_PSYC_Story *story); | 607 | GNUNET_PSYC_member_story_tell_cancel (struct GNUNET_PSYC_Story *story); |
598 | 608 | ||
599 | 609 | ||
600 | /** | 610 | /** |
601 | * Call the given callback on all matching values (including | 611 | * Call the given callback on all matching values (including variables) in the |
602 | * variables) in the channel state. The callback is invoked | 612 | * channel state. |
603 | * synchronously on all matching states (as the state is fully | 613 | * |
604 | * replicated in the library in this process; channel states should be | 614 | * The callback is invoked synchronously on all matching states (as the state is |
615 | * fully replicated in the library in this process; channel states should be | ||
605 | * small, large data is to be passed as streaming data to methods). | 616 | * small, large data is to be passed as streaming data to methods). |
606 | * | 617 | * |
607 | * A name matches if it includes the 'state_name' prefix, thus | 618 | * A name matches if it includes the @a state_name prefix, thus requesting the |
608 | * requesting the empty state ("") will match all values; requesting | 619 | * empty state ("") will match all values; requesting "a_b" will also return |
609 | * "a_b" will also return values stored under "a_b_c". | 620 | * values stored under "a_b_c". |
610 | * | 621 | * |
611 | * @param member membership handle | 622 | * @param member Membership handle. |
612 | * @param state_name name of the state to query (full name | 623 | * @param state_name Name of the state to query (full name |
613 | * might be longer, this is only the prefix that must match) | 624 | * might be longer, this is only the prefix that must match). |
614 | * @param cb function to call on the matching state values | 625 | * @param cb Function to call on the matching state values. |
615 | * @param cb_cls closure for 'cb' | 626 | * @param cb_cls Closure for @a cb. |
616 | * @return message ID for which the state was returned (last seen | 627 | * @return Message ID for which the state was returned (last seen |
617 | * message ID) | 628 | * message ID). |
618 | */ | 629 | */ |
619 | uint64_t | 630 | uint64_t |
620 | GNUNET_PSYC_member_state_get_all (struct GNUNET_PSYC_Member *member, | 631 | GNUNET_PSYC_member_state_get_all (struct GNUNET_PSYC_Member *member, |
@@ -623,23 +634,24 @@ GNUNET_PSYC_member_state_get_all (struct GNUNET_PSYC_Member *member, | |||
623 | void *cb_cls); | 634 | void *cb_cls); |
624 | 635 | ||
625 | 636 | ||
626 | /** | 637 | /** |
627 | * Obtain the current value of the best-matching value in the state | 638 | * Obtain the current value of the best-matching value in the state |
628 | * (including variables). Note that variables are only valid during a | 639 | * (including variables). |
629 | * GNUNET_PSYC_Method invocation, as variables are only valid for the | 640 | * |
630 | * duration of a method invocation. | 641 | * Note that variables are only valid during a #GNUNET_PSYC_Method invocation, as |
642 | * variables are only valid for the duration of a method invocation. | ||
631 | * | 643 | * |
632 | * If the requested variable name does not have an exact state in | 644 | * If the requested variable name does not have an exact state in |
633 | * the state, the nearest less-specific name is matched; for example, | 645 | * the state, the nearest less-specific name is matched; for example, |
634 | * requesting "a_b" will match "a" if "a_b" does not exist. | 646 | * requesting "a_b" will match "a" if "a_b" does not exist. |
635 | * | 647 | * |
636 | * @param member membership handle | 648 | * @param member Membership handle. |
637 | * @param variable_name name of the variable to query | 649 | * @param variable_name Name of the variable to query. |
638 | * @param return_value_size set to number of bytes in variable, | 650 | * @param return_value_size Set to number of bytes in variable, |
639 | * needed as variables might contain binary data and | 651 | * needed as variables might contain binary data and |
640 | * might also not be 0-terminated; set to 0 on errors | 652 | * might also not be 0-terminated; set to 0 on errors. |
641 | * @return NULL on error (no matching state or variable), pointer | 653 | * @return NULL on error (no matching state or variable), pointer |
642 | to the respective value otherwise | 654 | to the respective value otherwise. |
643 | */ | 655 | */ |
644 | const void * | 656 | const void * |
645 | GNUNET_PSYC_member_state_get (struct GNUNET_PSYC_Member *member, | 657 | GNUNET_PSYC_member_state_get (struct GNUNET_PSYC_Member *member, |