aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_psyc_service.h
diff options
context:
space:
mode:
authorGabor X Toth <*@tg-x.net>2014-01-06 00:09:37 +0000
committerGabor X Toth <*@tg-x.net>2014-01-06 00:09:37 +0000
commitc04d45b9738e1764d2e2c21efdbeb129f298d5d1 (patch)
tree9eec32efdd3fe3f9f459630af16058cc47436bce /src/include/gnunet_psyc_service.h
parent83a0e31631dbc199c37c42f11004e1be544f04a8 (diff)
downloadgnunet-c04d45b9738e1764d2e2c21efdbeb129f298d5d1.tar.gz
gnunet-c04d45b9738e1764d2e2c21efdbeb129f298d5d1.zip
psyc: ipc messages
Diffstat (limited to 'src/include/gnunet_psyc_service.h')
-rw-r--r--src/include/gnunet_psyc_service.h168
1 files changed, 71 insertions, 97 deletions
diff --git a/src/include/gnunet_psyc_service.h b/src/include/gnunet_psyc_service.h
index 91dcd0b07..eb17c9351 100644
--- a/src/include/gnunet_psyc_service.h
+++ b/src/include/gnunet_psyc_service.h
@@ -161,31 +161,49 @@ enum GNUNET_PSYC_Policy
161enum GNUNET_PSYC_MessageFlags 161enum GNUNET_PSYC_MessageFlags
162{ 162{
163 /** 163 /**
164 * First fragment of a message. 164 * Historic message, retrieved from PSYCstore.
165 */
166 GNUNET_PSYC_MESSAGE_HISTORIC = 1
167};
168
169GNUNET_NETWORK_STRUCT_BEGIN
170
171/**
172 * Header of a PSYC message.
173 */
174struct GNUNET_PSYC_MessageHeader
175{
176 /**
177 * Generic message header with size and type information.
165 */ 178 */
166 GNUNET_PSYC_MESSAGE_FIRST_FRAGMENT = 1 << 0, 179 struct GNUNET_MessageHeader header;
167 180
168 /** 181 /**
169 * Last fragment of a message. 182 * Flags for this message fragment.
183 *
184 * @see enum GNUNET_PSYC_MessageFlags
170 */ 185 */
171 GNUNET_PSYC_MESSAGE_LAST_FRAGMENT = 1 << 1, 186 uint32_t flags GNUNET_PACKED;
172 187
173 /** 188 /**
174 * OR'ed flags if message is not fragmented. 189 * Number of the message this message part belongs to.
175 */ 190 */
176 GNUNET_PSYC_MESSAGE_NOT_FRAGMENTED 191 uint64_t message_id GNUNET_PACKED;
177 = GNUNET_PSYC_MESSAGE_FIRST_FRAGMENT
178 | GNUNET_PSYC_MESSAGE_LAST_FRAGMENT,
179 192
180 /** 193 /**
181 * Historic message, retrieved from PSYCstore. 194 * Sending slave's public key.
195 * Not set if the message is from the master.
196 */
197 struct GNUNET_CRYPTO_EddsaPublicKey slave_key;
198
199 /* Followed by concatenated PSYC message parts:
200 * messages with GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_* types
182 */ 201 */
183 GNUNET_PSYC_MESSAGE_HISTORIC = 1 << 30
184}; 202};
185 203
186 204
187/** 205/**
188 * M 206 * The method of a message.
189 */ 207 */
190struct GNUNET_PSYC_MessageMethod 208struct GNUNET_PSYC_MessageMethod
191{ 209{
@@ -194,28 +212,18 @@ struct GNUNET_PSYC_MessageMethod
194 */ 212 */
195 struct GNUNET_MessageHeader header; 213 struct GNUNET_MessageHeader header;
196 214
197 uint32_t reserved GNUNET_PACKED;
198
199 /**
200 * Number of modifiers in the message.
201 */
202 uint32_t mod_count GNUNET_PACKED;
203
204 /** 215 /**
205 * OR'ed GNUNET_PSYC_MasterTransmitFlags 216 * OR'ed GNUNET_PSYC_MasterTransmitFlags
206 */ 217 */
207 uint32_t flags GNUNET_PACKED; 218 uint32_t flags GNUNET_PACKED;
208 219
209 /**
210 * Sending slave's public key.
211 * NULL if the message is from the master, or when transmitting a message.
212 */
213 struct GNUNET_CRYPTO_EddsaPublicKey slave_key;
214
215 /* Followed by NUL-terminated method name. */ 220 /* Followed by NUL-terminated method name. */
216}; 221};
217 222
218 223
224/**
225 * A modifier of a message.
226 */
219struct GNUNET_PSYC_MessageModifier 227struct GNUNET_PSYC_MessageModifier
220{ 228{
221 /** 229 /**
@@ -241,38 +249,19 @@ struct GNUNET_PSYC_MessageModifier
241 /* Followed by NUL-terminated name, then the value. */ 249 /* Followed by NUL-terminated name, then the value. */
242}; 250};
243 251
252GNUNET_NETWORK_STRUCT_END
244 253
245enum GNUNET_PSYC_DataStatus 254#define GNUNET_PSYC_MODIFIER_MAX_PAYLOAD \
246{ 255 GNUNET_MULTICAST_FRAGMENT_MAX_PAYLOAD \
247 /** 256 - sizeof (struct GNUNET_PSYC_MessageModifier)
248 * To be continued.
249 */
250 GNUNET_PSYC_DATA_CONT = 0,
251 257
252 /** 258#define GNUNET_PSYC_MOD_CONT_MAX_PAYLOAD \
253 * Reached the end of message. 259 GNUNET_MULTICAST_FRAGMENT_MAX_PAYLOAD \
254 */ 260 - sizeof (struct GNUNET_MessageHeader)
255 GNUNET_PSYC_DATA_END = 1,
256
257 /**
258 * Cancelled before the end.
259 */
260 GNUNET_PSYC_DATA_CANCEL = 2
261};
262
263
264struct GNUNET_PSYC_MessageData
265{
266 /**
267 * Type: GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_DATA
268 */
269 struct GNUNET_MessageHeader header;
270 261
271 /** 262#define GNUNET_PSYC_DATA_MAX_PAYLOAD \
272 * enum GNUNET_PSYC_DataStatus 263 GNUNET_MULTICAST_FRAGMENT_MAX_PAYLOAD \
273 */ 264 - sizeof (struct GNUNET_MessageHeader)
274 uint8_t status;
275};
276 265
277/** 266/**
278 * Handle that identifies a join request. 267 * Handle that identifies a join request.
@@ -284,36 +273,21 @@ struct GNUNET_PSYC_JoinHandle;
284 273
285 274
286/** 275/**
287 * Method called from PSYC upon receiving a message indicating a call to a 276 * Method called from PSYC upon receiving part of a message.
288 * @e method.
289 * 277 *
290 * @param cls Closure. 278 * @param cls Closure.
291 * @param slave_key Who transmitted the message. 279 * @param msg Message part, one of the following types:
292 * - NULL for multicast messages from the master. 280 * - GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_HEADER
293 * - The sending slave's public key for unicast requests from one of the 281 * - GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD
294 * slaves to the master. 282 * - GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MODIFIER
295 * @param message_id Unique message counter for this message. 283 * - GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MOD_CONT
296 * Unique only in combination with the given sender for this channel. 284 * - GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_DATA
297 * @param method_name Method name from PSYC.
298 * @param modifier_count Number of elements in the @a modifiers array.
299 * @param modifiers State modifiers and transient variables for the message.
300 * @param data_offset Byte offset of @a data in the overall data of the method.
301 * @param data Data stream given to the method (might not be zero-terminated
302 * if data is binary).
303 * @param data_size Number of bytes in @a data.
304 * @param frag Fragmentation status for the data.
305 */ 285 */
306typedef int 286typedef void
307(*GNUNET_PSYC_Method) (void *cls, 287(*GNUNET_PSYC_MessageCallback) (void *cls,
308 const struct GNUNET_CRYPTO_EddsaPublicKey *slave_key, 288 uint64_t message_id,
309 uint64_t message_id, 289 uint32_t flags,
310 const char *method_name, 290 const struct GNUNET_MessageHeader *msg);
311 size_t modifier_count,
312 const struct GNUNET_ENV_Modifier *modifiers,
313 uint64_t data_offset,
314 const void *data,
315 size_t data_size,
316 enum GNUNET_PSYC_MessageFlags flags);
317 291
318 292
319/** 293/**
@@ -329,7 +303,7 @@ typedef int
329 * @param data_size Number of bytes in @a data. 303 * @param data_size Number of bytes in @a data.
330 * @param jh Join handle to use with GNUNET_PSYC_join_decision() 304 * @param jh Join handle to use with GNUNET_PSYC_join_decision()
331 */ 305 */
332typedef int 306typedef void
333(*GNUNET_PSYC_JoinCallback) (void *cls, 307(*GNUNET_PSYC_JoinCallback) (void *cls,
334 const struct GNUNET_CRYPTO_EddsaPublicKey 308 const struct GNUNET_CRYPTO_EddsaPublicKey
335 *slave_key, 309 *slave_key,
@@ -413,7 +387,7 @@ typedef void
413 * one in the future. 387 * one in the future.
414 * @param policy Channel policy specifying join and history restrictions. 388 * @param policy Channel policy specifying join and history restrictions.
415 * Used to automate join decisions. 389 * Used to automate join decisions.
416 * @param method Function to invoke on messages received from slaves. 390 * @param message_cb Function to invoke on message parts received from slaves.
417 * @param join_cb Function to invoke when a peer wants to join. 391 * @param join_cb Function to invoke when a peer wants to join.
418 * @param master_started_cb Function to invoke after the channel master started. 392 * @param master_started_cb Function to invoke after the channel master started.
419 * @param cls Closure for @a method and @a join_cb. 393 * @param cls Closure for @a method and @a join_cb.
@@ -423,7 +397,7 @@ struct GNUNET_PSYC_Master *
423GNUNET_PSYC_master_start (const struct GNUNET_CONFIGURATION_Handle *cfg, 397GNUNET_PSYC_master_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
424 const struct GNUNET_CRYPTO_EddsaPrivateKey *channel_key, 398 const struct GNUNET_CRYPTO_EddsaPrivateKey *channel_key,
425 enum GNUNET_PSYC_Policy policy, 399 enum GNUNET_PSYC_Policy policy,
426 GNUNET_PSYC_Method method, 400 GNUNET_PSYC_MessageCallback message_cb,
427 GNUNET_PSYC_JoinCallback join_cb, 401 GNUNET_PSYC_JoinCallback join_cb,
428 GNUNET_PSYC_MasterStartCallback master_started_cb, 402 GNUNET_PSYC_MasterStartCallback master_started_cb,
429 void *cls); 403 void *cls);
@@ -449,7 +423,7 @@ GNUNET_PSYC_master_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
449 */ 423 */
450typedef int 424typedef int
451(*GNUNET_PSYC_MasterTransmitNotify) (void *cls, 425(*GNUNET_PSYC_MasterTransmitNotify) (void *cls,
452 size_t *data_size, 426 uint16_t *data_size,
453 void *data); 427 void *data);
454 428
455 429
@@ -489,18 +463,17 @@ struct GNUNET_PSYC_MasterTransmitHandle;
489 * 463 *
490 * @param master Handle to the PSYC channel. 464 * @param master Handle to the PSYC channel.
491 * @param method_name Which method should be invoked. 465 * @param method_name Which method should be invoked.
492 * @param env Environment containing state operations and transient variables 466 * @param notify_mod Function to call to obtain modifiers.
493 * for the message, or NULL. 467 * @param notify_data Function to call to obtain fragments of the data.
494 * @param notify Function to call to obtain the arguments. 468 * @param notify_cls Closure for @a notify_mod and @a notify_data.
495 * @param notify_cls Closure for @a notify.
496 * @param flags Flags for the message being transmitted. 469 * @param flags Flags for the message being transmitted.
497 * @return Transmission handle, NULL on error (i.e. more than one request queued). 470 * @return Transmission handle, NULL on error (i.e. more than one request queued).
498 */ 471 */
499struct GNUNET_PSYC_MasterTransmitHandle * 472struct GNUNET_PSYC_MasterTransmitHandle *
500GNUNET_PSYC_master_transmit (struct GNUNET_PSYC_Master *master, 473GNUNET_PSYC_master_transmit (struct GNUNET_PSYC_Master *master,
501 const char *method_name, 474 const char *method_name,
502 const struct GNUNET_ENV_Environment *env, 475 GNUNET_PSYC_MasterTransmitNotify notify_mod,
503 GNUNET_PSYC_MasterTransmitNotify notify, 476 GNUNET_PSYC_MasterTransmitNotify notify_data,
504 void *notify_cls, 477 void *notify_cls,
505 enum GNUNET_PSYC_MasterTransmitFlags flags); 478 enum GNUNET_PSYC_MasterTransmitFlags flags);
506 479
@@ -567,12 +540,13 @@ typedef void
567 * @param relay_count Number of peers in the @a relays array. 540 * @param relay_count Number of peers in the @a relays array.
568 * @param relays Peer identities of members of the multicast group, which serve 541 * @param relays Peer identities of members of the multicast group, which serve
569 * as relays and used to join the group at. 542 * as relays and used to join the group at.
570 * @param method Function to invoke on messages received from the channel, 543 * @param message_cb Function to invoke on message parts received from the
571 * typically at least contains functions for @e join and @e part. 544 * channel, typically at least contains method handlers for @e join and
545 * @e part.
572 * @param join_cb function invoked once we have joined with the current 546 * @param join_cb function invoked once we have joined with the current
573 * message ID of the channel 547 * message ID of the channel
574 * @param slave_joined_cb Function to invoke when a peer wants to join. 548 * @param slave_joined_cb Function to invoke when a peer wants to join.
575 * @param cls Closure for @a method_cb and @a slave_joined_cb. 549 * @param cls Closure for @a message_cb and @a slave_joined_cb.
576 * @param method_name Method name for the join request. 550 * @param method_name Method name for the join request.
577 * @param env Environment containing transient variables for the request, or NULL. 551 * @param env Environment containing transient variables for the request, or NULL.
578 * @param data Payload for the join message. 552 * @param data Payload for the join message.
@@ -586,7 +560,7 @@ GNUNET_PSYC_slave_join (const struct GNUNET_CONFIGURATION_Handle *cfg,
586 const struct GNUNET_PeerIdentity *origin, 560 const struct GNUNET_PeerIdentity *origin,
587 uint32_t relay_count, 561 uint32_t relay_count,
588 const struct GNUNET_PeerIdentity *relays, 562 const struct GNUNET_PeerIdentity *relays,
589 GNUNET_PSYC_Method method, 563 GNUNET_PSYC_MessageCallback message_cb,
590 GNUNET_PSYC_JoinCallback join_cb, 564 GNUNET_PSYC_JoinCallback join_cb,
591 GNUNET_PSYC_SlaveJoinCallback slave_joined_cb, 565 GNUNET_PSYC_SlaveJoinCallback slave_joined_cb,
592 void *cls, 566 void *cls,
@@ -809,7 +783,7 @@ struct GNUNET_PSYC_Story;
809 * @param channel Which channel should be replayed? 783 * @param channel Which channel should be replayed?
810 * @param start_message_id Earliest interesting point in history. 784 * @param start_message_id Earliest interesting point in history.
811 * @param end_message_id Last (exclusive) interesting point in history. 785 * @param end_message_id Last (exclusive) interesting point in history.
812 * @param method Function to invoke on messages received from the story. 786 * @param message_cb Function to invoke on message parts received from the story.
813 * @param finish_cb Function to call when the requested story has been fully 787 * @param finish_cb Function to call when the requested story has been fully
814 * told (counting message IDs might not suffice, as some messages 788 * told (counting message IDs might not suffice, as some messages
815 * might be secret and thus the listener would not know the story is 789 * might be secret and thus the listener would not know the story is
@@ -823,8 +797,8 @@ struct GNUNET_PSYC_Story *
823GNUNET_PSYC_channel_story_tell (struct GNUNET_PSYC_Channel *channel, 797GNUNET_PSYC_channel_story_tell (struct GNUNET_PSYC_Channel *channel,
824 uint64_t start_message_id, 798 uint64_t start_message_id,
825 uint64_t end_message_id, 799 uint64_t end_message_id,
826 GNUNET_PSYC_Method method, 800 GNUNET_PSYC_MessageCallback message_cb,
827 GNUNET_PSYC_FinishCallback *finish_cb, 801 GNUNET_PSYC_FinishCallback finish_cb,
828 void *cls); 802 void *cls);
829 803
830 804