aboutsummaryrefslogtreecommitdiff
path: root/src/include
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
parent83a0e31631dbc199c37c42f11004e1be544f04a8 (diff)
downloadgnunet-c04d45b9738e1764d2e2c21efdbeb129f298d5d1.tar.gz
gnunet-c04d45b9738e1764d2e2c21efdbeb129f298d5d1.zip
psyc: ipc messages
Diffstat (limited to 'src/include')
-rw-r--r--src/include/gnunet_env_lib.h4
-rw-r--r--src/include/gnunet_multicast_service.h27
-rw-r--r--src/include/gnunet_protocols.h16
-rw-r--r--src/include/gnunet_psyc_service.h168
-rw-r--r--src/include/gnunet_social_service.h2
5 files changed, 106 insertions, 111 deletions
diff --git a/src/include/gnunet_env_lib.h b/src/include/gnunet_env_lib.h
index 857ad45c2..89101afc1 100644
--- a/src/include/gnunet_env_lib.h
+++ b/src/include/gnunet_env_lib.h
@@ -168,7 +168,9 @@ GNUNET_ENV_environment_add_mod (struct GNUNET_ENV_Environment *env,
168 * #GNUNET_NO to stop. 168 * #GNUNET_NO to stop.
169 */ 169 */
170typedef int 170typedef int
171(*GNUNET_ENV_Iterator) (void *cls, struct GNUNET_ENV_Modifier *mod); 171(*GNUNET_ENV_Iterator) (void *cls, enum GNUNET_ENV_Operator oper,
172 const char *name, const char *value,
173 uint32_t value_size);
172 174
173 175
174/** 176/**
diff --git a/src/include/gnunet_multicast_service.h b/src/include/gnunet_multicast_service.h
index 58a99c0d8..0abd803a4 100644
--- a/src/include/gnunet_multicast_service.h
+++ b/src/include/gnunet_multicast_service.h
@@ -45,11 +45,6 @@ extern "C"
45#define GNUNET_MULTICAST_VERSION 0x00000000 45#define GNUNET_MULTICAST_VERSION 0x00000000
46 46
47/** 47/**
48 * Maximum size of a multicast message fragment.
49 */
50#define GNUNET_MULTICAST_FRAGMENT_MAX_SIZE 63 * 1024
51
52/**
53 * Opaque handle for a multicast group member. 48 * Opaque handle for a multicast group member.
54 */ 49 */
55struct GNUNET_MULTICAST_Member; 50struct GNUNET_MULTICAST_Member;
@@ -77,7 +72,14 @@ enum GNUNET_MULTICAST_MessageFlags
77 */ 72 */
78 GNUNET_MULTICAST_MESSAGE_NOT_FRAGMENTED 73 GNUNET_MULTICAST_MESSAGE_NOT_FRAGMENTED
79 = GNUNET_MULTICAST_MESSAGE_FIRST_FRAGMENT 74 = GNUNET_MULTICAST_MESSAGE_FIRST_FRAGMENT
80 | GNUNET_MULTICAST_MESSAGE_LAST_FRAGMENT 75 | GNUNET_MULTICAST_MESSAGE_LAST_FRAGMENT,
76
77 /**
78 * Historic message, used only locally when replaying messages from local
79 * storage.
80 */
81 GNUNET_MULTICAST_MESSAGE_HISTORIC = 1 << 30
82
81}; 83};
82 84
83 85
@@ -120,7 +122,7 @@ struct GNUNET_MULTICAST_MessageHeader
120 struct GNUNET_CRYPTO_EccSignaturePurpose purpose; 122 struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
121 123
122 /** 124 /**
123 * Number of the message fragment, monotonically increasing. 125 * Number of the message fragment, monotonically increasing starting from 1.
124 */ 126 */
125 uint64_t fragment_id GNUNET_PACKED; 127 uint64_t fragment_id GNUNET_PACKED;
126 128
@@ -150,6 +152,8 @@ struct GNUNET_MULTICAST_MessageHeader
150 152
151 /** 153 /**
152 * Flags for this message fragment. 154 * Flags for this message fragment.
155 *
156 * @see enum GNUNET_MULTICAST_MessageFlags
153 */ 157 */
154 uint32_t flags GNUNET_PACKED; 158 uint32_t flags GNUNET_PACKED;
155 159
@@ -158,6 +162,15 @@ struct GNUNET_MULTICAST_MessageHeader
158 162
159GNUNET_NETWORK_STRUCT_END 163GNUNET_NETWORK_STRUCT_END
160 164
165/**
166 * Maximum size of a multicast message fragment.
167 */
168#define GNUNET_MULTICAST_FRAGMENT_MAX_SIZE 63 * 1024
169
170#define GNUNET_MULTICAST_FRAGMENT_MAX_PAYLOAD \
171 GNUNET_MULTICAST_FRAGMENT_MAX_SIZE \
172 - sizeof (struct GNUNET_MULTICAST_MessageHeader)
173
161 174
162/** 175/**
163 * Handle that identifies a join request. 176 * Handle that identifies a join request.
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h
index 5b7bc591a..9ca4155e8 100644
--- a/src/include/gnunet_protocols.h
+++ b/src/include/gnunet_protocols.h
@@ -2116,15 +2116,21 @@ extern "C"
2116#define GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_SLAVE_RM 690 2116#define GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_SLAVE_RM 690
2117 2117
2118 2118
2119#define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD 691 2119#define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE 691
2120 2120
2121#define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MODIFIER 692 2121#define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD 692
2122 2122
2123#define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MOD_CONT 693 2123#define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MODIFIER 693
2124 2124
2125#define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_DATA 694 2125#define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MOD_CONT 694
2126 2126
2127#define GNUNET_MESSAGE_TYPE_PSYC_TRANSMIT_ACK 695 2127#define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_DATA 695
2128
2129#define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END 696
2130
2131#define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_CANCEL 697
2132
2133#define GNUNET_MESSAGE_TYPE_PSYC_TRANSMIT_ACK 698
2128 2134
2129 2135
2130#define GNUNET_MESSAGE_TYPE_PSYC_STORY_REQUEST 701 2136#define GNUNET_MESSAGE_TYPE_PSYC_STORY_REQUEST 701
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
diff --git a/src/include/gnunet_social_service.h b/src/include/gnunet_social_service.h
index b0c7b63cd..8bd1a959f 100644
--- a/src/include/gnunet_social_service.h
+++ b/src/include/gnunet_social_service.h
@@ -587,7 +587,7 @@ struct GNUNET_SOCIAL_HistoryLesson;
587 * @param slicer Slicer to use to process history. Can be the same as the 587 * @param slicer Slicer to use to process history. Can be the same as the
588 * slicer of the place, as the HISTORIC flag allows distinguishing 588 * slicer of the place, as the HISTORIC flag allows distinguishing
589 * old messages from fresh ones. 589 * old messages from fresh ones.
590 * @param finish_cb Function called after the last message if the history lesson 590 * @param finish_cb Function called after the last message in the history lesson
591 * is passed through the @a slicer. NULL if not needed. 591 * is passed through the @a slicer. NULL if not needed.
592 * @param finish_cb_cls Closure for @a finish_cb. 592 * @param finish_cb_cls Closure for @a finish_cb.
593 * @return Handle to abort history lesson, never NULL (multiple lessons 593 * @return Handle to abort history lesson, never NULL (multiple lessons