diff options
author | Gabor X Toth <*@tg-x.net> | 2014-07-10 17:49:53 +0000 |
---|---|---|
committer | Gabor X Toth <*@tg-x.net> | 2014-07-10 17:49:53 +0000 |
commit | a8133f3ff80aaaccc904e4bbaf69bc53dee499cb (patch) | |
tree | c10edd7a8156280c61357ccf9e0f1f27c7a0d6db | |
parent | 6c75526e936fcc74ee79b13831b2b6dda57f293d (diff) | |
download | gnunet-a8133f3ff80aaaccc904e4bbaf69bc53dee499cb.tar.gz gnunet-a8133f3ff80aaaccc904e4bbaf69bc53dee499cb.zip |
PSYC(store), Multicast: use ECDSA slave/member keys; PSYC: add GNUNET_PSYC_message_create()
-rw-r--r-- | src/include/gnunet_gnsrecord_lib.h | 24 | ||||
-rw-r--r-- | src/include/gnunet_multicast_service.h | 14 | ||||
-rw-r--r-- | src/include/gnunet_protocols.h | 24 | ||||
-rw-r--r-- | src/include/gnunet_psyc_service.h | 96 | ||||
-rw-r--r-- | src/include/gnunet_psyc_util_lib.h | 22 | ||||
-rw-r--r-- | src/include/gnunet_psycstore_plugin.h | 4 | ||||
-rw-r--r-- | src/include/gnunet_psycstore_service.h | 11 | ||||
-rw-r--r-- | src/include/gnunet_social_service.h | 276 | ||||
-rw-r--r-- | src/multicast/gnunet-service-multicast.c | 25 | ||||
-rw-r--r-- | src/multicast/multicast.h | 13 | ||||
-rw-r--r-- | src/multicast/multicast_api.c | 4 | ||||
-rw-r--r-- | src/psyc/gnunet-service-psyc.c | 89 | ||||
-rw-r--r-- | src/psyc/psyc.h | 57 | ||||
-rw-r--r-- | src/psyc/psyc_api.c | 33 | ||||
-rw-r--r-- | src/psyc/psyc_util_lib.c | 113 | ||||
-rw-r--r-- | src/psyc/test_psyc.c | 18 | ||||
-rw-r--r-- | src/psycstore/plugin_psycstore_sqlite.c | 6 | ||||
-rw-r--r-- | src/psycstore/psycstore.h | 11 | ||||
-rw-r--r-- | src/psycstore/psycstore_api.c | 12 |
19 files changed, 561 insertions, 291 deletions
diff --git a/src/include/gnunet_gnsrecord_lib.h b/src/include/gnunet_gnsrecord_lib.h index 5efaa64b7..3713d8d11 100644 --- a/src/include/gnunet_gnsrecord_lib.h +++ b/src/include/gnunet_gnsrecord_lib.h | |||
@@ -173,9 +173,31 @@ struct GNUNET_GNSRECORD_Data | |||
173 | }; | 173 | }; |
174 | 174 | ||
175 | 175 | ||
176 | |||
177 | GNUNET_NETWORK_STRUCT_BEGIN | 176 | GNUNET_NETWORK_STRUCT_BEGIN |
178 | 177 | ||
178 | /** | ||
179 | * Data stored in a PLACE record. | ||
180 | */ | ||
181 | struct GNUNET_GNSRECORD_PlaceData | ||
182 | { | ||
183 | /** | ||
184 | * Public key of the place. | ||
185 | */ | ||
186 | struct GNUNET_CRYPTO_EddsaPublicKey place_key; | ||
187 | |||
188 | /** | ||
189 | * Peer identity of the origin. | ||
190 | */ | ||
191 | struct GNUNET_PeerIdentity origin; | ||
192 | |||
193 | /** | ||
194 | * Number of relays that follow. | ||
195 | */ | ||
196 | uint32_t relay_count GNUNET_PACKED; | ||
197 | |||
198 | /* Followed by struct GNUNET_PeerIdentity relays[relay_count] */ | ||
199 | }; | ||
200 | |||
179 | 201 | ||
180 | /** | 202 | /** |
181 | * Information we have in an encrypted block with record data (i.e. in the DHT). | 203 | * Information we have in an encrypted block with record data (i.e. in the DHT). |
diff --git a/src/include/gnunet_multicast_service.h b/src/include/gnunet_multicast_service.h index bb109f4de..41227b925 100644 --- a/src/include/gnunet_multicast_service.h +++ b/src/include/gnunet_multicast_service.h | |||
@@ -174,14 +174,14 @@ struct GNUNET_MULTICAST_RequestHeader | |||
174 | /** | 174 | /** |
175 | * Public key of the sending member. | 175 | * Public key of the sending member. |
176 | */ | 176 | */ |
177 | struct GNUNET_CRYPTO_EddsaPublicKey member_key; | 177 | struct GNUNET_CRYPTO_EcdsaPublicKey member_key; |
178 | 178 | ||
179 | /** | 179 | /** |
180 | * ECC signature of the request fragment. | 180 | * ECC signature of the request fragment. |
181 | * | 181 | * |
182 | * Signature must match the public key of the multicast group. | 182 | * Signature must match the public key of the multicast group. |
183 | */ | 183 | */ |
184 | struct GNUNET_CRYPTO_EddsaSignature signature; | 184 | struct GNUNET_CRYPTO_EcdsaSignature signature; |
185 | 185 | ||
186 | /** | 186 | /** |
187 | * Purpose for the signature and size of the signed data. | 187 | * Purpose for the signature and size of the signed data. |
@@ -280,7 +280,7 @@ GNUNET_MULTICAST_join_decision (struct GNUNET_MULTICAST_JoinHandle *jh, | |||
280 | */ | 280 | */ |
281 | typedef void | 281 | typedef void |
282 | (*GNUNET_MULTICAST_JoinRequestCallback) (void *cls, | 282 | (*GNUNET_MULTICAST_JoinRequestCallback) (void *cls, |
283 | const struct GNUNET_CRYPTO_EddsaPublicKey *member_key, | 283 | const struct GNUNET_CRYPTO_EcdsaPublicKey *member_key, |
284 | const struct GNUNET_MessageHeader *join_msg, | 284 | const struct GNUNET_MessageHeader *join_msg, |
285 | struct GNUNET_MULTICAST_JoinHandle *jh); | 285 | struct GNUNET_MULTICAST_JoinHandle *jh); |
286 | 286 | ||
@@ -344,7 +344,7 @@ GNUNET_MULTICAST_membership_test_result (struct GNUNET_MULTICAST_MembershipTestH | |||
344 | */ | 344 | */ |
345 | typedef void | 345 | typedef void |
346 | (*GNUNET_MULTICAST_MembershipTestCallback) (void *cls, | 346 | (*GNUNET_MULTICAST_MembershipTestCallback) (void *cls, |
347 | const struct GNUNET_CRYPTO_EddsaPublicKey *member_key, | 347 | const struct GNUNET_CRYPTO_EcdsaPublicKey *member_key, |
348 | uint64_t message_id, | 348 | uint64_t message_id, |
349 | uint64_t group_generation, | 349 | uint64_t group_generation, |
350 | struct GNUNET_MULTICAST_MembershipTestHandle *mth); | 350 | struct GNUNET_MULTICAST_MembershipTestHandle *mth); |
@@ -430,7 +430,7 @@ struct GNUNET_MULTICAST_ReplayHandle; | |||
430 | */ | 430 | */ |
431 | typedef void | 431 | typedef void |
432 | (*GNUNET_MULTICAST_ReplayFragmentCallback) (void *cls, | 432 | (*GNUNET_MULTICAST_ReplayFragmentCallback) (void *cls, |
433 | const struct GNUNET_CRYPTO_EddsaPublicKey *member_key, | 433 | const struct GNUNET_CRYPTO_EcdsaPublicKey *member_key, |
434 | uint64_t fragment_id, | 434 | uint64_t fragment_id, |
435 | uint64_t flags, | 435 | uint64_t flags, |
436 | struct GNUNET_MULTICAST_ReplayHandle *rh); | 436 | struct GNUNET_MULTICAST_ReplayHandle *rh); |
@@ -453,7 +453,7 @@ typedef void | |||
453 | */ | 453 | */ |
454 | typedef void | 454 | typedef void |
455 | (*GNUNET_MULTICAST_ReplayMessageCallback) (void *cls, | 455 | (*GNUNET_MULTICAST_ReplayMessageCallback) (void *cls, |
456 | const struct GNUNET_CRYPTO_EddsaPublicKey *member_key, | 456 | const struct GNUNET_CRYPTO_EcdsaPublicKey *member_key, |
457 | uint64_t message_id, | 457 | uint64_t message_id, |
458 | uint64_t fragment_offset, | 458 | uint64_t fragment_offset, |
459 | uint64_t flags, | 459 | uint64_t flags, |
@@ -712,7 +712,7 @@ GNUNET_MULTICAST_origin_stop (struct GNUNET_MULTICAST_Origin *origin); | |||
712 | struct GNUNET_MULTICAST_Member * | 712 | struct GNUNET_MULTICAST_Member * |
713 | GNUNET_MULTICAST_member_join (const struct GNUNET_CONFIGURATION_Handle *cfg, | 713 | GNUNET_MULTICAST_member_join (const struct GNUNET_CONFIGURATION_Handle *cfg, |
714 | const struct GNUNET_CRYPTO_EddsaPublicKey *group_key, | 714 | const struct GNUNET_CRYPTO_EddsaPublicKey *group_key, |
715 | const struct GNUNET_CRYPTO_EddsaPrivateKey *member_key, | 715 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *member_key, |
716 | const struct GNUNET_PeerIdentity *origin, | 716 | const struct GNUNET_PeerIdentity *origin, |
717 | uint16_t relay_count, | 717 | uint16_t relay_count, |
718 | const struct GNUNET_PeerIdentity *relays, | 718 | const struct GNUNET_PeerIdentity *relays, |
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h index 06e906622..3451cdbf4 100644 --- a/src/include/gnunet_protocols.h +++ b/src/include/gnunet_protocols.h | |||
@@ -2180,7 +2180,7 @@ extern "C" | |||
2180 | /** Message part: message cancelled */ | 2180 | /** Message part: message cancelled */ |
2181 | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_CANCEL 697 | 2181 | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_CANCEL 697 |
2182 | 2182 | ||
2183 | /** S->C: message acknowledgment */ | 2183 | /** S->C: message acknowledgement */ |
2184 | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_ACK 698 | 2184 | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_ACK 698 |
2185 | 2185 | ||
2186 | /* 699-700 */ | 2186 | /* 699-700 */ |
@@ -2479,23 +2479,23 @@ extern "C" | |||
2479 | /** S->C: result of an operation */ | 2479 | /** S->C: result of an operation */ |
2480 | #define GNUNET_MESSAGE_TYPE_SOCIAL_RESULT_CODE 840 | 2480 | #define GNUNET_MESSAGE_TYPE_SOCIAL_RESULT_CODE 840 |
2481 | 2481 | ||
2482 | /** C->S: request to enter a home as the host */ | 2482 | /** C->S: request to enter a place as the host */ |
2483 | #define GNUNET_MESSAGE_TYPE_SOCIAL_HOME_ENTER 841 | 2483 | #define GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER 841 |
2484 | 2484 | ||
2485 | /** S->C: home enter acknowledgement */ | 2485 | /** S->C: host enter acknowledgement */ |
2486 | #define GNUNET_MESSAGE_TYPE_SOCIAL_HOME_ENTER_ACK 842 | 2486 | #define GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER_ACK 842 |
2487 | 2487 | ||
2488 | /** C->S: request to enter a place as a guest */ | 2488 | /** C->S: request to enter a place as a guest */ |
2489 | #define GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_ENTER 843 | 2489 | #define GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER 843 |
2490 | 2490 | ||
2491 | /** S->C: guest join acknowledgement */ | 2491 | /** S->C: guest enter acknowledgement */ |
2492 | #define GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_ENTER_ACK 844 | 2492 | #define GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER_ACK 844 |
2493 | 2493 | ||
2494 | /** P->S->C: incoming join request from PSYC */ | 2494 | /** P->S->C: incoming entry request from PSYC */ |
2495 | #define GNUNET_MESSAGE_TYPE_SOCIAL_JOIN_REQUEST 847 | 2495 | #define GNUNET_MESSAGE_TYPE_SOCIAL_ENTRY_REQUEST 845 |
2496 | 2496 | ||
2497 | /** C->S->P: decision about a join request */ | 2497 | /** C->S->P: decision about an entry request */ |
2498 | #define GNUNET_MESSAGE_TYPE_SOCIAL_JOIN_DECISION 848 | 2498 | #define GNUNET_MESSAGE_TYPE_SOCIAL_ENTRY_DECISION 846 |
2499 | 2499 | ||
2500 | /******************************************************************************* | 2500 | /******************************************************************************* |
2501 | * X-VINE DHT messages | 2501 | * X-VINE DHT messages |
diff --git a/src/include/gnunet_psyc_service.h b/src/include/gnunet_psyc_service.h index 4806767fb..2ea282fa3 100644 --- a/src/include/gnunet_psyc_service.h +++ b/src/include/gnunet_psyc_service.h | |||
@@ -218,7 +218,7 @@ struct GNUNET_PSYC_MessageHeader | |||
218 | * Sending slave's public key. | 218 | * Sending slave's public key. |
219 | * Not set if the message is from the master. | 219 | * Not set if the message is from the master. |
220 | */ | 220 | */ |
221 | struct GNUNET_CRYPTO_EddsaPublicKey slave_key; | 221 | struct GNUNET_CRYPTO_EcdsaPublicKey slave_key; |
222 | 222 | ||
223 | /* Followed by concatenated PSYC message parts: | 223 | /* Followed by concatenated PSYC message parts: |
224 | * messages with GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_* types | 224 | * messages with GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_* types |
@@ -279,6 +279,63 @@ struct GNUNET_PSYC_MessageModifier | |||
279 | /* Followed by NUL-terminated name, then the value. */ | 279 | /* Followed by NUL-terminated name, then the value. */ |
280 | }; | 280 | }; |
281 | 281 | ||
282 | |||
283 | struct GNUNET_PSYC_CountersResultMessage | ||
284 | { | ||
285 | /** | ||
286 | * Type: GNUNET_MESSAGE_TYPE_PSYC_RESULT_COUNTERS | ||
287 | */ | ||
288 | struct GNUNET_MessageHeader header; | ||
289 | |||
290 | /** | ||
291 | * Status code for the operation. | ||
292 | */ | ||
293 | int32_t result_code GNUNET_PACKED; | ||
294 | |||
295 | /** | ||
296 | * Last message ID sent to the channel. | ||
297 | */ | ||
298 | uint64_t max_message_id; | ||
299 | }; | ||
300 | |||
301 | |||
302 | struct GNUNET_PSYC_JoinRequestMessage | ||
303 | { | ||
304 | /** | ||
305 | * Type: GNUNET_MESSAGE_TYPE_PSYC_MASTER_JOIN_REQUEST | ||
306 | */ | ||
307 | struct GNUNET_MessageHeader header; | ||
308 | /** | ||
309 | * Public key of the joining slave. | ||
310 | */ | ||
311 | struct GNUNET_CRYPTO_EcdsaPublicKey slave_key; | ||
312 | |||
313 | /* Followed by struct GNUNET_MessageHeader join_request */ | ||
314 | }; | ||
315 | |||
316 | |||
317 | struct GNUNET_PSYC_JoinDecisionMessage | ||
318 | { | ||
319 | /** | ||
320 | * Type: GNUNET_MESSAGE_TYPE_PSYC_JOIN_DECISION | ||
321 | */ | ||
322 | struct GNUNET_MessageHeader header; | ||
323 | |||
324 | /** | ||
325 | * #GNUNET_YES if the slave was admitted. | ||
326 | */ | ||
327 | int32_t is_admitted; | ||
328 | |||
329 | /** | ||
330 | * Public key of the joining slave. | ||
331 | * Only set when the master is sending the decision, | ||
332 | * not set when a slave is receiving it. | ||
333 | */ | ||
334 | struct GNUNET_CRYPTO_EcdsaPublicKey slave_key; | ||
335 | |||
336 | /* Followed by struct GNUNET_MessageHeader join_response */ | ||
337 | }; | ||
338 | |||
282 | GNUNET_NETWORK_STRUCT_END | 339 | GNUNET_NETWORK_STRUCT_END |
283 | 340 | ||
284 | 341 | ||
@@ -296,6 +353,23 @@ GNUNET_NETWORK_STRUCT_END | |||
296 | 353 | ||
297 | 354 | ||
298 | /** | 355 | /** |
356 | * PSYC message part processing states. | ||
357 | */ | ||
358 | enum GNUNET_PSYC_MessageState | ||
359 | { | ||
360 | GNUNET_PSYC_MESSAGE_STATE_START = 0, | ||
361 | GNUNET_PSYC_MESSAGE_STATE_HEADER = 1, | ||
362 | GNUNET_PSYC_MESSAGE_STATE_METHOD = 2, | ||
363 | GNUNET_PSYC_MESSAGE_STATE_MODIFIER = 3, | ||
364 | GNUNET_PSYC_MESSAGE_STATE_MOD_CONT = 4, | ||
365 | GNUNET_PSYC_MESSAGE_STATE_DATA = 5, | ||
366 | GNUNET_PSYC_MESSAGE_STATE_END = 6, | ||
367 | GNUNET_PSYC_MESSAGE_STATE_CANCEL = 7, | ||
368 | GNUNET_PSYC_MESSAGE_STATE_ERROR = 8, | ||
369 | }; | ||
370 | |||
371 | |||
372 | /** | ||
299 | * Handle that identifies a join request. | 373 | * Handle that identifies a join request. |
300 | * | 374 | * |
301 | * Used to match calls to #GNUNET_PSYC_JoinCallback to the | 375 | * Used to match calls to #GNUNET_PSYC_JoinCallback to the |
@@ -335,7 +409,7 @@ typedef void | |||
335 | typedef void | 409 | typedef void |
336 | (*GNUNET_PSYC_JoinRequestCallback) (void *cls, | 410 | (*GNUNET_PSYC_JoinRequestCallback) (void *cls, |
337 | const struct | 411 | const struct |
338 | GNUNET_CRYPTO_EddsaPublicKey *slave_key, | 412 | GNUNET_CRYPTO_EcdsaPublicKey *slave_key, |
339 | const struct | 413 | const struct |
340 | GNUNET_PSYC_MessageHeader *join_msg, | 414 | GNUNET_PSYC_MessageHeader *join_msg, |
341 | struct GNUNET_PSYC_JoinHandle *jh); | 415 | struct GNUNET_PSYC_JoinHandle *jh); |
@@ -348,9 +422,10 @@ typedef void | |||
348 | * #GNUNET_PSYC_JoinCallback. | 422 | * #GNUNET_PSYC_JoinCallback. |
349 | * | 423 | * |
350 | * @param jh Join request handle. | 424 | * @param jh Join request handle. |
351 | * @param is_admitted #GNUNET_YES if the join is approved, | 425 | * @param is_admitted |
352 | * #GNUNET_NO if it is disapproved, | 426 | * #GNUNET_YES if the join is approved, |
353 | * #GNUNET_SYSERR if we cannot answer the request. | 427 | * #GNUNET_NO if it is disapproved, |
428 | * #GNUNET_SYSERR if we cannot answer the request. | ||
354 | * @param relay_count Number of relays given. | 429 | * @param relay_count Number of relays given. |
355 | * @param relays Array of suggested peers that might be useful relays to use | 430 | * @param relays Array of suggested peers that might be useful relays to use |
356 | * when joining the multicast group (essentially a list of peers that | 431 | * when joining the multicast group (essentially a list of peers that |
@@ -646,7 +721,7 @@ typedef void | |||
646 | struct GNUNET_PSYC_Slave * | 721 | struct GNUNET_PSYC_Slave * |
647 | GNUNET_PSYC_slave_join (const struct GNUNET_CONFIGURATION_Handle *cfg, | 722 | GNUNET_PSYC_slave_join (const struct GNUNET_CONFIGURATION_Handle *cfg, |
648 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, | 723 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, |
649 | const struct GNUNET_CRYPTO_EddsaPrivateKey *slave_key, | 724 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *slave_key, |
650 | const struct GNUNET_PeerIdentity *origin, | 725 | const struct GNUNET_PeerIdentity *origin, |
651 | uint32_t relay_count, | 726 | uint32_t relay_count, |
652 | const struct GNUNET_PeerIdentity *relays, | 727 | const struct GNUNET_PeerIdentity *relays, |
@@ -654,10 +729,7 @@ GNUNET_PSYC_slave_join (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
654 | GNUNET_PSYC_SlaveConnectCallback slave_connect_cb, | 729 | GNUNET_PSYC_SlaveConnectCallback slave_connect_cb, |
655 | GNUNET_PSYC_JoinDecisionCallback join_decision_cb, | 730 | GNUNET_PSYC_JoinDecisionCallback join_decision_cb, |
656 | void *cls, | 731 | void *cls, |
657 | const char *method_name, | 732 | const struct GNUNET_MessageHeader *join_msg); |
658 | const struct GNUNET_ENV_Environment *env, | ||
659 | const void *data, | ||
660 | uint16_t data_size); | ||
661 | 733 | ||
662 | 734 | ||
663 | /** | 735 | /** |
@@ -775,7 +847,7 @@ GNUNET_PSYC_slave_get_channel (struct GNUNET_PSYC_Slave *slave); | |||
775 | */ | 847 | */ |
776 | void | 848 | void |
777 | GNUNET_PSYC_channel_slave_add (struct GNUNET_PSYC_Channel *channel, | 849 | GNUNET_PSYC_channel_slave_add (struct GNUNET_PSYC_Channel *channel, |
778 | const struct GNUNET_CRYPTO_EddsaPublicKey *slave_key, | 850 | const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key, |
779 | uint64_t announced_at, | 851 | uint64_t announced_at, |
780 | uint64_t effective_since); | 852 | uint64_t effective_since); |
781 | 853 | ||
@@ -803,7 +875,7 @@ GNUNET_PSYC_channel_slave_add (struct GNUNET_PSYC_Channel *channel, | |||
803 | */ | 875 | */ |
804 | void | 876 | void |
805 | GNUNET_PSYC_channel_slave_remove (struct GNUNET_PSYC_Channel *channel, | 877 | GNUNET_PSYC_channel_slave_remove (struct GNUNET_PSYC_Channel *channel, |
806 | const struct GNUNET_CRYPTO_EddsaPublicKey | 878 | const struct GNUNET_CRYPTO_EcdsaPublicKey |
807 | *slave_key, | 879 | *slave_key, |
808 | uint64_t announced_at); | 880 | uint64_t announced_at); |
809 | 881 | ||
diff --git a/src/include/gnunet_psyc_util_lib.h b/src/include/gnunet_psyc_util_lib.h index eea338ba4..f356b245b 100644 --- a/src/include/gnunet_psyc_util_lib.h +++ b/src/include/gnunet_psyc_util_lib.h | |||
@@ -40,6 +40,28 @@ extern "C" | |||
40 | #include "gnunet_psyc_service.h" | 40 | #include "gnunet_psyc_service.h" |
41 | 41 | ||
42 | 42 | ||
43 | /** | ||
44 | * Create a PSYC message. | ||
45 | * | ||
46 | * @param method_name | ||
47 | * PSYC method for the message. | ||
48 | * @param env | ||
49 | * Environment for the message. | ||
50 | * @param data | ||
51 | * Data payload for the message. | ||
52 | * @param data_size | ||
53 | * Size of @a data. | ||
54 | * | ||
55 | * @return Message header with size information, | ||
56 | * followed by the message parts. | ||
57 | */ | ||
58 | struct GNUNET_MessageHeader * | ||
59 | GNUNET_PSYC_message_create (const char *method_name, | ||
60 | const struct GNUNET_ENV_Environment *env, | ||
61 | const void *data, | ||
62 | size_t data_size); | ||
63 | |||
64 | |||
43 | void | 65 | void |
44 | GNUNET_PSYC_log_message (enum GNUNET_ErrorType kind, | 66 | GNUNET_PSYC_log_message (enum GNUNET_ErrorType kind, |
45 | const struct GNUNET_MessageHeader *msg); | 67 | const struct GNUNET_MessageHeader *msg); |
diff --git a/src/include/gnunet_psycstore_plugin.h b/src/include/gnunet_psycstore_plugin.h index 7564ed4bd..1945b400e 100644 --- a/src/include/gnunet_psycstore_plugin.h +++ b/src/include/gnunet_psycstore_plugin.h | |||
@@ -60,7 +60,7 @@ struct GNUNET_PSYCSTORE_PluginFunctions | |||
60 | int | 60 | int |
61 | (*membership_store) (void *cls, | 61 | (*membership_store) (void *cls, |
62 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, | 62 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, |
63 | const struct GNUNET_CRYPTO_EddsaPublicKey *slave_key, | 63 | const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key, |
64 | int did_join, | 64 | int did_join, |
65 | uint64_t announced_at, | 65 | uint64_t announced_at, |
66 | uint64_t effective_since, | 66 | uint64_t effective_since, |
@@ -77,7 +77,7 @@ struct GNUNET_PSYCSTORE_PluginFunctions | |||
77 | int | 77 | int |
78 | (*membership_test) (void *cls, | 78 | (*membership_test) (void *cls, |
79 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, | 79 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, |
80 | const struct GNUNET_CRYPTO_EddsaPublicKey *slave_key, | 80 | const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key, |
81 | uint64_t message_id); | 81 | uint64_t message_id); |
82 | 82 | ||
83 | /** | 83 | /** |
diff --git a/src/include/gnunet_psycstore_service.h b/src/include/gnunet_psycstore_service.h index 29d7ff1ec..20af9f3d3 100644 --- a/src/include/gnunet_psycstore_service.h +++ b/src/include/gnunet_psycstore_service.h | |||
@@ -134,7 +134,7 @@ typedef void | |||
134 | struct GNUNET_PSYCSTORE_OperationHandle * | 134 | struct GNUNET_PSYCSTORE_OperationHandle * |
135 | GNUNET_PSYCSTORE_membership_store (struct GNUNET_PSYCSTORE_Handle *h, | 135 | GNUNET_PSYCSTORE_membership_store (struct GNUNET_PSYCSTORE_Handle *h, |
136 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, | 136 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, |
137 | const struct GNUNET_CRYPTO_EddsaPublicKey *slave_key, | 137 | const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key, |
138 | int did_join, | 138 | int did_join, |
139 | uint64_t announced_at, | 139 | uint64_t announced_at, |
140 | uint64_t effective_since, | 140 | uint64_t effective_since, |
@@ -158,6 +158,7 @@ GNUNET_PSYCSTORE_membership_store (struct GNUNET_PSYCSTORE_Handle *h, | |||
158 | * @param group_generation Group generation of the fragment of the message to | 158 | * @param group_generation Group generation of the fragment of the message to |
159 | * test. It has relevance if the message consists of multiple fragments | 159 | * test. It has relevance if the message consists of multiple fragments |
160 | * with different group generations. | 160 | * with different group generations. |
161 | * FIXME: not needed if there are no overlapping messages. | ||
161 | * @param rcb Callback to call with the test result. | 162 | * @param rcb Callback to call with the test result. |
162 | * @param rcb_cls Closure for the callback. | 163 | * @param rcb_cls Closure for the callback. |
163 | * | 164 | * |
@@ -166,7 +167,7 @@ GNUNET_PSYCSTORE_membership_store (struct GNUNET_PSYCSTORE_Handle *h, | |||
166 | struct GNUNET_PSYCSTORE_OperationHandle * | 167 | struct GNUNET_PSYCSTORE_OperationHandle * |
167 | GNUNET_PSYCSTORE_membership_test (struct GNUNET_PSYCSTORE_Handle *h, | 168 | GNUNET_PSYCSTORE_membership_test (struct GNUNET_PSYCSTORE_Handle *h, |
168 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, | 169 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, |
169 | const struct GNUNET_CRYPTO_EddsaPublicKey *slave_key, | 170 | const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key, |
170 | uint64_t message_id, | 171 | uint64_t message_id, |
171 | uint64_t group_generation, | 172 | uint64_t group_generation, |
172 | GNUNET_PSYCSTORE_ResultCallback rcb, | 173 | GNUNET_PSYCSTORE_ResultCallback rcb, |
@@ -178,7 +179,7 @@ GNUNET_PSYCSTORE_membership_test (struct GNUNET_PSYCSTORE_Handle *h, | |||
178 | * | 179 | * |
179 | * @param h Handle for the PSYCstore. | 180 | * @param h Handle for the PSYCstore. |
180 | * @param channel_key The channel the message belongs to. | 181 | * @param channel_key The channel the message belongs to. |
181 | * @param message Message to store. | 182 | * @param msg Message to store. |
182 | * @param psycstore_flags Flags indicating whether the PSYC message contains | 183 | * @param psycstore_flags Flags indicating whether the PSYC message contains |
183 | * state modifiers. | 184 | * state modifiers. |
184 | * @param rcb Callback to call with the result of the operation. | 185 | * @param rcb Callback to call with the result of the operation. |
@@ -189,8 +190,8 @@ GNUNET_PSYCSTORE_membership_test (struct GNUNET_PSYCSTORE_Handle *h, | |||
189 | struct GNUNET_PSYCSTORE_OperationHandle * | 190 | struct GNUNET_PSYCSTORE_OperationHandle * |
190 | GNUNET_PSYCSTORE_fragment_store (struct GNUNET_PSYCSTORE_Handle *h, | 191 | GNUNET_PSYCSTORE_fragment_store (struct GNUNET_PSYCSTORE_Handle *h, |
191 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, | 192 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, |
192 | const struct GNUNET_MULTICAST_MessageHeader *message, | 193 | const struct GNUNET_MULTICAST_MessageHeader *msg, |
193 | uint32_t psycstore_flags, | 194 | enum GNUNET_PSYCSTORE_MessageFlags psycstore_flags, |
194 | GNUNET_PSYCSTORE_ResultCallback rcb, | 195 | GNUNET_PSYCSTORE_ResultCallback rcb, |
195 | void *rcb_cls); | 196 | void *rcb_cls); |
196 | 197 | ||
diff --git a/src/include/gnunet_social_service.h b/src/include/gnunet_social_service.h index e68d84d2f..f8b24c161 100644 --- a/src/include/gnunet_social_service.h +++ b/src/include/gnunet_social_service.h | |||
@@ -79,30 +79,38 @@ struct GNUNET_SOCIAL_Slicer; | |||
79 | * This function is called one or more times for each message until all data | 79 | * This function is called one or more times for each message until all data |
80 | * fragments arrive from the network. | 80 | * fragments arrive from the network. |
81 | * | 81 | * |
82 | * @param cls Closure. | 82 | * @param cls |
83 | * @param message_id Message counter, monotonically increasing from 1. | 83 | * Closure. |
84 | * @param nym The sender of the message. Can be NULL if the message is not | 84 | * @param message_id |
85 | * connected to a pseudonym. | 85 | * Message counter, monotonically increasing from 1. |
86 | * @param flags OR'ed GNUNET_PSYC_MessageFlags | 86 | * @param nym |
87 | * @param method_name Original method name from PSYC (may be more specific | 87 | * The sender of the message. |
88 | * than the registered method name due to try-and-slice matching). | 88 | * Can be NULL if the message is not connected to a pseudonym. |
89 | * @param env Environment containing variables for the message and operations | 89 | * @param flags |
90 | * on objects of the place, or NULL. | 90 | * OR'ed GNUNET_PSYC_MessageFlags |
91 | * Only set for the first call of this function for each @a message_id, | 91 | * @param method_name |
92 | * NULL when notifying about further data fragments. | 92 | * Original method name from PSYC. |
93 | * @param data_offset Byte offset of @a data in the overall data of the method. | 93 | * May be more specific than the registered method name due to |
94 | * @param data_size Number of bytes in @a data. | 94 | * try-and-slice matching. |
95 | * @param data Data stream given to the method (might not be zero-terminated | 95 | * @param env |
96 | * if data is binary). | 96 | * Environment with operations and variables for the message. |
97 | * @param end End of message? | 97 | * Only set for the first call of this function for each @a message_id, |
98 | * #GNUNET_NO if there are further fragments, | 98 | * NULL when notifying about further data fragments. |
99 | * #GNUNET_YES if this is the last fragment, | 99 | * It has to be freed using GNUNET_ENV_environment_destroy() |
100 | * #GNUNET_SYSERR indicates the message was cancelled by the sender. | 100 | * when it is not needed anymore. |
101 | * | 101 | * @param data_offset |
102 | * @return #GNUNET_YES the application keeps @a env for further use, | 102 | * Byte offset of @a data in the overall data of the method. |
103 | * #GNUNET_NO @a env is free()'d after the function returns. | 103 | * @param data_size |
104 | * Number of bytes in @a data. | ||
105 | * @param data | ||
106 | * Data stream given to the method. | ||
107 | * @param end | ||
108 | * End of message? | ||
109 | * #GNUNET_NO if there are further fragments, | ||
110 | * #GNUNET_YES if this is the last fragment, | ||
111 | * #GNUNET_SYSERR indicates the message was cancelled by the sender. | ||
104 | */ | 112 | */ |
105 | typedef int | 113 | typedef void |
106 | (*GNUNET_SOCIAL_MethodCallback) (void *cls, | 114 | (*GNUNET_SOCIAL_MethodCallback) (void *cls, |
107 | uint64_t message_id, | 115 | uint64_t message_id, |
108 | uint32_t flags, | 116 | uint32_t flags, |
@@ -179,17 +187,16 @@ GNUNET_SOCIAL_slicer_destroy (struct GNUNET_SOCIAL_Slicer *slicer); | |||
179 | * @param method_name Method name in the entry request. | 187 | * @param method_name Method name in the entry request. |
180 | * @param variable_count Number of elements in the @a variables array. | 188 | * @param variable_count Number of elements in the @a variables array. |
181 | * @param variables Variables present in the message. | 189 | * @param variables Variables present in the message. |
182 | * @param data Payload given on enter (e.g. a password). | ||
183 | * @param data_size Number of bytes in @a data. | 190 | * @param data_size Number of bytes in @a data. |
191 | * @param data Payload given on enter (e.g. a password). | ||
184 | */ | 192 | */ |
185 | typedef void | 193 | typedef void |
186 | (*GNUNET_SOCIAL_AnswerDoorCallback) (void *cls, | 194 | (*GNUNET_SOCIAL_AnswerDoorCallback) (void *cls, |
187 | struct GNUNET_SOCIAL_Nym *nym, | 195 | struct GNUNET_SOCIAL_Nym *nym, |
188 | size_t variable_count, | ||
189 | const char *method_name, | 196 | const char *method_name, |
190 | struct GNUNET_ENV_Modifier *variables, | 197 | struct GNUNET_ENV_Environment *env, |
191 | const void *data, | 198 | size_t data_size, |
192 | size_t data_size); | 199 | const void *data); |
193 | 200 | ||
194 | 201 | ||
195 | /** | 202 | /** |
@@ -198,7 +205,7 @@ typedef void | |||
198 | * This is also called if the @a nym was never given permission to enter | 205 | * This is also called if the @a nym was never given permission to enter |
199 | * (i.e. the @a nym stopped asking to get in). | 206 | * (i.e. the @a nym stopped asking to get in). |
200 | * | 207 | * |
201 | * @param cls Closure. | 208 | * @param cls Closure. |
202 | * @param nym Handle for the user who left. | 209 | * @param nym Handle for the user who left. |
203 | * @param variable_count Number of elements in the @a variables array. | 210 | * @param variable_count Number of elements in the @a variables array. |
204 | * @param variables Variables present in the message. | 211 | * @param variables Variables present in the message. |
@@ -206,35 +213,56 @@ typedef void | |||
206 | typedef void | 213 | typedef void |
207 | (*GNUNET_SOCIAL_FarewellCallback) (void *cls, | 214 | (*GNUNET_SOCIAL_FarewellCallback) (void *cls, |
208 | struct GNUNET_SOCIAL_Nym *nym, | 215 | struct GNUNET_SOCIAL_Nym *nym, |
216 | struct GNUNET_ENV_Environment *env, | ||
209 | size_t variable_count, | 217 | size_t variable_count, |
210 | struct GNUNET_ENV_Modifier *variables); | 218 | struct GNUNET_ENV_Modifier *variables); |
211 | 219 | ||
212 | 220 | ||
213 | /** | 221 | /** |
222 | * Function called after the host entered the place. | ||
223 | * | ||
224 | * @param cls Closure. | ||
225 | * @param max_message_id Last message ID sent to the channel. | ||
226 | * Or 0 if no messages have been sent to the place yet. | ||
227 | */ | ||
228 | typedef void | ||
229 | (*GNUNET_SOCIAL_HostEnterCallback) (void *cls, uint64_t max_message_id); | ||
230 | |||
231 | |||
232 | /** | ||
214 | * Enter a place as host. | 233 | * Enter a place as host. |
215 | * | 234 | * |
216 | * A place is created upon first entering, and it is active until permanently | 235 | * A place is created upon first entering, and it is active until permanently |
217 | * left using GNUNET_SOCIAL_host_leave(). | 236 | * left using GNUNET_SOCIAL_host_leave(). |
218 | * | 237 | * |
219 | * @param cfg Configuration to contact the social service. | 238 | * @param cfg |
220 | * @param place_keyfile File with the private-public key pair of the place, | 239 | * Configuration to contact the social service. |
221 | * created if the file does not exist; pass NULL for ephemeral places. | 240 | * @param ego |
222 | * @param policy Policy specifying entry and history restrictions of the place. | 241 | * Identity of the host. |
223 | * @param ego Identity of the host. | 242 | * @param place_key |
224 | * @param slicer Slicer to handle incoming messages. | 243 | * Private-public key pair of the place. |
225 | * @param listener_cb Function to handle new nyms that want to enter. | 244 | * NULL for ephemeral places. |
226 | * @param farewell_cb Function to handle departing nyms. | 245 | * @param policy |
227 | * @param cls Closure for @a listener_cb and @a farewell_cb. | 246 | * Policy specifying entry and history restrictions for the place. |
247 | * @param slicer | ||
248 | * Slicer to handle incoming messages. | ||
249 | * @param answer_door_cb | ||
250 | * Function to handle new nyms that want to enter. | ||
251 | * @param farewell_cb | ||
252 | * Function to handle departing nyms. | ||
253 | * @param cls | ||
254 | * Closure for the callbacks. | ||
228 | * | 255 | * |
229 | * @return Handle for the host. | 256 | * @return Handle for the host. |
230 | */ | 257 | */ |
231 | struct GNUNET_SOCIAL_Host * | 258 | struct GNUNET_SOCIAL_Host * |
232 | GNUNET_SOCIAL_host_enter (const struct GNUNET_CONFIGURATION_Handle *cfg, | 259 | GNUNET_SOCIAL_host_enter (const struct GNUNET_CONFIGURATION_Handle *cfg, |
233 | const char *place_keyfile, | ||
234 | enum GNUNET_PSYC_Policy policy, | ||
235 | struct GNUNET_IDENTITY_Ego *ego, | 260 | struct GNUNET_IDENTITY_Ego *ego, |
261 | const struct GNUNET_CRYPTO_EddsaPrivateKey *place_key, | ||
262 | enum GNUNET_PSYC_Policy policy, | ||
236 | struct GNUNET_SOCIAL_Slicer *slicer, | 263 | struct GNUNET_SOCIAL_Slicer *slicer, |
237 | GNUNET_SOCIAL_AnswerDoorCallback listener_cb, | 264 | GNUNET_SOCIAL_HostEnterCallback enter_cb, |
265 | GNUNET_SOCIAL_AnswerDoorCallback answer_door_cb, | ||
238 | GNUNET_SOCIAL_FarewellCallback farewell_cb, | 266 | GNUNET_SOCIAL_FarewellCallback farewell_cb, |
239 | void *cls); | 267 | void *cls); |
240 | 268 | ||
@@ -362,22 +390,30 @@ struct GNUNET_SOCIAL_Announcement; | |||
362 | * This function is restricted to the host. Nyms can only send requests | 390 | * This function is restricted to the host. Nyms can only send requests |
363 | * to the host who can decide to relay it to everyone in the place. | 391 | * to the host who can decide to relay it to everyone in the place. |
364 | * | 392 | * |
365 | * @param host Host of the place. | 393 | * @param host |
366 | * @param method_name Method to use for the announcement. | 394 | * Host of the place. |
367 | * @param env Environment containing variables for the message and operations | 395 | * @param method_name |
368 | * on objects of the place. Can be NULL. | 396 | * Method to use for the announcement. |
369 | * @param notify Function to call to get the payload of the announcement. | 397 | * @param env |
370 | * @param notify_cls Closure for @a notify. | 398 | * Environment containing variables for the message and operations |
371 | * @param flags Flags for this announcement. | 399 | * on objects of the place. |
372 | * | 400 | * Has to remain available until the first call to @a notify_data. |
373 | * @return NULL on error (announcement already in progress?). | 401 | * Can be NULL. |
402 | * @param notify_data | ||
403 | * Function to call to get the payload of the announcement. | ||
404 | * @param notify_data_cls | ||
405 | * Closure for @a notify. | ||
406 | * @param flags | ||
407 | * Flags for this announcement. | ||
408 | * | ||
409 | * @return NULL on error (another announcement already in progress?). | ||
374 | */ | 410 | */ |
375 | struct GNUNET_SOCIAL_Announcement * | 411 | struct GNUNET_SOCIAL_Announcement * |
376 | GNUNET_SOCIAL_host_announce (struct GNUNET_SOCIAL_Host *host, | 412 | GNUNET_SOCIAL_host_announce (struct GNUNET_SOCIAL_Host *host, |
377 | const char *method_name, | 413 | const char *method_name, |
378 | const struct GNUNET_ENV_Environment *env, | 414 | const struct GNUNET_ENV_Environment *env, |
379 | GNUNET_CONNECTION_TransmitReadyNotify notify, | 415 | GNUNET_PSYC_TransmitNotifyData notify_data, |
380 | void *notify_cls, | 416 | void *notify_data_cls, |
381 | enum GNUNET_SOCIAL_AnnounceFlags flags); | 417 | enum GNUNET_SOCIAL_AnnounceFlags flags); |
382 | 418 | ||
383 | 419 | ||
@@ -416,15 +452,65 @@ GNUNET_SOCIAL_host_leave (struct GNUNET_SOCIAL_Host *host, int keep_active); | |||
416 | 452 | ||
417 | 453 | ||
418 | /** | 454 | /** |
455 | * Function called after the guest entered the local copy of the place. | ||
456 | * | ||
457 | * History and object query functions can be used after this call, | ||
458 | * but new messages can't be sent or received. | ||
459 | * | ||
460 | * @param cls | ||
461 | * Closure. | ||
462 | * @param result | ||
463 | * #GNUNET_OK on success, or | ||
464 | * #GNUNET_SYSERR on error, e.g. could not connect to the service, or | ||
465 | * could not resolve GNS name. | ||
466 | * @param max_message_id | ||
467 | * Last message ID sent to the place. | ||
468 | * Or 0 if no messages have been sent to the place yet. | ||
469 | */ | ||
470 | typedef void | ||
471 | (*GNUNET_SOCIAL_GuestEnterCallback) (void *cls, int result, | ||
472 | uint64_t max_message_id); | ||
473 | |||
474 | |||
475 | /** | ||
476 | * Function called upon a guest receives a decision about entry to the place. | ||
477 | * | ||
478 | * @param is_admitted | ||
479 | * Is the guest admitted to the place? | ||
480 | * #GNUNET_YES if admitted, | ||
481 | * #GNUNET_NO if refused entry | ||
482 | * #GNUNET_SYSERR if the request could not be answered. | ||
483 | * @param method_name | ||
484 | * Method for the message sent along with the decision. | ||
485 | * NULL if no message was sent. | ||
486 | * @param env | ||
487 | * Environment with variables for the message. | ||
488 | * NULL if there are no variables. | ||
489 | * It has to be freed using GNUNET_ENV_environment_destroy() | ||
490 | * when it is not needed anymore. | ||
491 | * @param data_size | ||
492 | * Size of @data. | ||
493 | * @param data | ||
494 | * Payload of the message. | ||
495 | */ | ||
496 | typedef int | ||
497 | (*GNUNET_SOCIAL_EntryDecisionCallback) (void *cls, | ||
498 | int is_admitted, | ||
499 | const char *method_name, | ||
500 | struct GNUNET_ENV_Environment *env, | ||
501 | size_t data_size, | ||
502 | const void *data); | ||
503 | |||
504 | |||
505 | /** | ||
419 | * Request entry to a place as a guest. | 506 | * Request entry to a place as a guest. |
420 | * | 507 | * |
421 | * @param cfg Configuration to contact the social service. | 508 | * @param cfg Configuration to contact the social service. |
422 | * @param ego Identity of the guest. | 509 | * @param ego Identity of the guest. |
423 | * @param address GNS name of the place to enter. Either in the form of | 510 | * @param crypto_address Public key of the place to enter. |
424 | * 'room.friend.gnu', or 'NYMPUBKEY.zkey'. This latter case refers to | 511 | * @param origin Peer identity of the origin of the underlying multicast group. |
425 | * the 'PLACE' record of the empty label ("+") in the GNS zone with the | 512 | * @param relay_count Number of elements in the @a relays array. |
426 | * nym's public key 'NYMPUBKEY', and can be used to request entry to a | 513 | * @param relays Relays for the underlying multicast group. |
427 | * pseudonym's place directly. | ||
428 | * @param method_name Method name for the message. | 514 | * @param method_name Method name for the message. |
429 | * @param env Environment containing variables for the message, or NULL. | 515 | * @param env Environment containing variables for the message, or NULL. |
430 | * @param data Payload for the message to give to the enter callback. | 516 | * @param data Payload for the message to give to the enter callback. |
@@ -436,22 +522,30 @@ GNUNET_SOCIAL_host_leave (struct GNUNET_SOCIAL_Host *host, int keep_active); | |||
436 | struct GNUNET_SOCIAL_Guest * | 522 | struct GNUNET_SOCIAL_Guest * |
437 | GNUNET_SOCIAL_guest_enter (const struct GNUNET_CONFIGURATION_Handle *cfg, | 523 | GNUNET_SOCIAL_guest_enter (const struct GNUNET_CONFIGURATION_Handle *cfg, |
438 | struct GNUNET_IDENTITY_Ego *ego, | 524 | struct GNUNET_IDENTITY_Ego *ego, |
439 | char *address, | 525 | struct GNUNET_CRYPTO_EddsaPublicKey *place_key, |
526 | struct GNUNET_PeerIdentity *origin, | ||
527 | uint32_t relay_count, | ||
528 | struct GNUNET_PeerIdentity *relays, | ||
440 | const char *method_name, | 529 | const char *method_name, |
441 | const struct GNUNET_ENV_Environment *env, | 530 | const struct GNUNET_ENV_Environment *env, |
442 | const void *data, | 531 | const void *data, |
443 | size_t data_size, | 532 | size_t data_size, |
444 | struct GNUNET_SOCIAL_Slicer *slicer); | 533 | struct GNUNET_SOCIAL_Slicer *slicer, |
534 | GNUNET_SOCIAL_GuestEnterCallback local_enter_cb, | ||
535 | GNUNET_SOCIAL_EntryDecisionCallback entry_decision_cb, | ||
536 | void *cls); | ||
537 | |||
445 | 538 | ||
446 | /** | 539 | /** |
447 | * Request entry to a place as a guest. | 540 | * Request entry to a place as a guest using a GNS name. |
448 | * | 541 | * |
449 | * @param cfg Configuration to contact the social service. | 542 | * @param cfg Configuration to contact the social service. |
450 | * @param ego Identity of the guest. | 543 | * @param ego Identity of the guest. |
451 | * @param crypto_address Public key of the place to enter. | 544 | * @param address GNS name of the place to enter. Either in the form of |
452 | * @param origin Peer identity of the origin of the underlying multicast group. | 545 | * 'room.friend.gnu', or 'NYMPUBKEY.zkey'. This latter case refers to |
453 | * @param relay_count Number of elements in the @a relays array. | 546 | * the 'PLACE' record of the empty label ("+") in the GNS zone with the |
454 | * @param relays Relays for the underlying multicast group. | 547 | * nym's public key 'NYMPUBKEY', and can be used to request entry to a |
548 | * pseudonym's place directly. | ||
455 | * @param method_name Method name for the message. | 549 | * @param method_name Method name for the message. |
456 | * @param env Environment containing variables for the message, or NULL. | 550 | * @param env Environment containing variables for the message, or NULL. |
457 | * @param data Payload for the message to give to the enter callback. | 551 | * @param data Payload for the message to give to the enter callback. |
@@ -461,17 +555,17 @@ GNUNET_SOCIAL_guest_enter (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
461 | * @return NULL on errors, otherwise handle for the guest. | 555 | * @return NULL on errors, otherwise handle for the guest. |
462 | */ | 556 | */ |
463 | struct GNUNET_SOCIAL_Guest * | 557 | struct GNUNET_SOCIAL_Guest * |
464 | GNUNET_SOCIAL_guest_enter2 (const struct GNUNET_CONFIGURATION_Handle *cfg, | 558 | GNUNET_SOCIAL_guest_enter_by_name (const struct GNUNET_CONFIGURATION_Handle *cfg, |
465 | struct GNUNET_IDENTITY_Ego *ego, | 559 | struct GNUNET_IDENTITY_Ego *ego, |
466 | struct GNUNET_CRYPTO_EddsaPublicKey *crypto_address, | 560 | char *gns_name, |
467 | struct GNUNET_PeerIdentity *origin, | 561 | const char *method_name, |
468 | size_t relay_count, | 562 | const struct GNUNET_ENV_Environment *env, |
469 | struct GNUNET_PeerIdentity *relays, | 563 | const void *data, |
470 | const char *method_name, | 564 | size_t data_size, |
471 | const struct GNUNET_ENV_Environment *env, | 565 | struct GNUNET_SOCIAL_Slicer *slicer, |
472 | const void *data, | 566 | GNUNET_SOCIAL_GuestEnterCallback local_enter_cb, |
473 | size_t data_size, | 567 | GNUNET_SOCIAL_EntryDecisionCallback entry_decision_cb, |
474 | struct GNUNET_SOCIAL_Slicer *slicer); | 568 | void *cls); |
475 | 569 | ||
476 | 570 | ||
477 | /** | 571 | /** |
@@ -492,22 +586,28 @@ struct GNUNET_SOCIAL_TalkRequest; | |||
492 | /** | 586 | /** |
493 | * Talk to the host of the place. | 587 | * Talk to the host of the place. |
494 | * | 588 | * |
495 | * @param place Place where we want to talk to the host. | 589 | * @param place |
496 | * @param method_name Method to invoke on the host. | 590 | * Place where we want to talk to the host. |
497 | * @param env Environment containing variables for the message, or NULL. | 591 | * @param method_name |
498 | * @param notify Function to use to get the payload for the method. | 592 | * Method to invoke on the host. |
499 | * @param notify_cls Closure for @a notify. | 593 | * @param env |
500 | * @param flags Flags for the message being sent. | 594 | * Environment containing variables for the message, or NULL. |
595 | * @param notify_data | ||
596 | * Function to use to get the payload for the method. | ||
597 | * @param notify_data_cls | ||
598 | * Closure for @a notify_data. | ||
599 | * @param flags | ||
600 | * Flags for the message being sent. | ||
501 | * | 601 | * |
502 | * @return NULL if we are already trying to talk to the host, | 602 | * @return NULL if we are already trying to talk to the host, |
503 | * otherwise handle to cancel the request. | 603 | * otherwise handle to cancel the request. |
504 | */ | 604 | */ |
505 | struct GNUNET_SOCIAL_TalkRequest * | 605 | struct GNUNET_SOCIAL_TalkRequest * |
506 | GNUNET_SOCIAL_guest_talk (struct GNUNET_SOCIAL_Place *place, | 606 | GNUNET_SOCIAL_guest_talk (struct GNUNET_SOCIAL_Guest *guest, |
507 | const char *method_name, | 607 | const char *method_name, |
508 | const struct GNUNET_ENV_Environment *env, | 608 | const struct GNUNET_ENV_Environment *env, |
509 | GNUNET_CONNECTION_TransmitReadyNotify notify, | 609 | GNUNET_PSYC_TransmitNotifyData notify_data, |
510 | void *notify_cls, | 610 | void *notify_data_cls, |
511 | enum GNUNET_SOCIAL_TalkFlags flags); | 611 | enum GNUNET_SOCIAL_TalkFlags flags); |
512 | 612 | ||
513 | 613 | ||
@@ -529,7 +629,7 @@ GNUNET_SOCIAL_guest_talk_cancel (struct GNUNET_SOCIAL_TalkRequest *tr); | |||
529 | * @param keep_active Keep place active after last application disconnected. | 629 | * @param keep_active Keep place active after last application disconnected. |
530 | */ | 630 | */ |
531 | void | 631 | void |
532 | GNUNET_SOCIAL_guest_leave (struct GNUNET_SOCIAL_Place *place, int keep_active); | 632 | GNUNET_SOCIAL_guest_leave (struct GNUNET_SOCIAL_Guest *guest, int keep_active); |
533 | 633 | ||
534 | 634 | ||
535 | /** | 635 | /** |
@@ -542,7 +642,7 @@ GNUNET_SOCIAL_guest_leave (struct GNUNET_SOCIAL_Place *place, int keep_active); | |||
542 | * @return Handle for the place, valid as long as @a guest is valid. | 642 | * @return Handle for the place, valid as long as @a guest is valid. |
543 | */ | 643 | */ |
544 | struct GNUNET_SOCIAL_Place * | 644 | struct GNUNET_SOCIAL_Place * |
545 | GNUNET_SOCIAL_guest_get_place (struct GNUNET_SOCIAL_Host *guest); | 645 | GNUNET_SOCIAL_guest_get_place (struct GNUNET_SOCIAL_Guest *guest); |
546 | 646 | ||
547 | 647 | ||
548 | /** | 648 | /** |
diff --git a/src/multicast/gnunet-service-multicast.c b/src/multicast/gnunet-service-multicast.c index 5421c1b2b..1bb27f96e 100644 --- a/src/multicast/gnunet-service-multicast.c +++ b/src/multicast/gnunet-service-multicast.c | |||
@@ -148,12 +148,12 @@ struct Member | |||
148 | /** | 148 | /** |
149 | * Private key of the member. | 149 | * Private key of the member. |
150 | */ | 150 | */ |
151 | struct GNUNET_CRYPTO_EddsaPrivateKey priv_key; | 151 | struct GNUNET_CRYPTO_EcdsaPrivateKey priv_key; |
152 | 152 | ||
153 | /** | 153 | /** |
154 | * Public key of the member. | 154 | * Public key of the member. |
155 | */ | 155 | */ |
156 | struct GNUNET_CRYPTO_EddsaPublicKey pub_key; | 156 | struct GNUNET_CRYPTO_EcdsaPublicKey pub_key; |
157 | 157 | ||
158 | /** | 158 | /** |
159 | * Hash of @a pub_key. | 159 | * Hash of @a pub_key. |
@@ -458,11 +458,12 @@ client_member_join (void *cls, struct GNUNET_SERVER_Client *client, | |||
458 | { | 458 | { |
459 | const struct MulticastMemberJoinMessage * | 459 | const struct MulticastMemberJoinMessage * |
460 | msg = (const struct MulticastMemberJoinMessage *) m; | 460 | msg = (const struct MulticastMemberJoinMessage *) m; |
461 | uint16_t msg_size = ntohs (msg->header.size); | ||
461 | 462 | ||
462 | struct GNUNET_CRYPTO_EddsaPublicKey mem_pub_key; | 463 | struct GNUNET_CRYPTO_EcdsaPublicKey mem_pub_key; |
463 | struct GNUNET_HashCode pub_key_hash, mem_pub_key_hash; | 464 | struct GNUNET_HashCode pub_key_hash, mem_pub_key_hash; |
464 | 465 | ||
465 | GNUNET_CRYPTO_eddsa_key_get_public (&msg->member_key, &mem_pub_key); | 466 | GNUNET_CRYPTO_ecdsa_key_get_public (&msg->member_key, &mem_pub_key); |
466 | GNUNET_CRYPTO_hash (&mem_pub_key, sizeof (mem_pub_key), &mem_pub_key_hash); | 467 | GNUNET_CRYPTO_hash (&mem_pub_key, sizeof (mem_pub_key), &mem_pub_key_hash); |
467 | GNUNET_CRYPTO_hash (&msg->group_key, sizeof (msg->group_key), &pub_key_hash); | 468 | GNUNET_CRYPTO_hash (&msg->group_key, sizeof (msg->group_key), &pub_key_hash); |
468 | 469 | ||
@@ -532,12 +533,18 @@ client_member_join (void *cls, struct GNUNET_SERVER_Client *client, | |||
532 | struct GNUNET_MessageHeader *join_msg = NULL; | 533 | struct GNUNET_MessageHeader *join_msg = NULL; |
533 | uint16_t join_msg_size = 0; | 534 | uint16_t join_msg_size = 0; |
534 | if (sizeof (*msg) + relay_size + sizeof (struct GNUNET_MessageHeader) | 535 | if (sizeof (*msg) + relay_size + sizeof (struct GNUNET_MessageHeader) |
535 | <= ntohs (msg->header.size)) | 536 | <= msg_size) |
536 | { | 537 | { |
537 | join_msg = (struct GNUNET_MessageHeader *) | 538 | join_msg = (struct GNUNET_MessageHeader *) |
538 | (((char *) &msg[1]) + relay_size); | 539 | (((char *) &msg[1]) + relay_size); |
539 | join_msg_size = ntohs (join_msg->size); | 540 | join_msg_size = ntohs (join_msg->size); |
540 | } | 541 | } |
542 | if (sizeof (*msg) + relay_size + join_msg_size != msg_size) | ||
543 | { | ||
544 | GNUNET_break (0); | ||
545 | GNUNET_SERVER_client_disconnect (client); | ||
546 | return; | ||
547 | } | ||
541 | 548 | ||
542 | struct MulticastJoinRequestMessage * | 549 | struct MulticastJoinRequestMessage * |
543 | req = GNUNET_malloc (sizeof (*req) + join_msg_size); | 550 | req = GNUNET_malloc (sizeof (*req) + join_msg_size); |
@@ -545,7 +552,7 @@ client_member_join (void *cls, struct GNUNET_SERVER_Client *client, | |||
545 | req->header.type = htons (GNUNET_MESSAGE_TYPE_MULTICAST_JOIN_REQUEST); | 552 | req->header.type = htons (GNUNET_MESSAGE_TYPE_MULTICAST_JOIN_REQUEST); |
546 | req->group_key = grp->pub_key; | 553 | req->group_key = grp->pub_key; |
547 | req->member_peer = this_peer; | 554 | req->member_peer = this_peer; |
548 | GNUNET_CRYPTO_eddsa_key_get_public (&mem->priv_key, &req->member_key); | 555 | GNUNET_CRYPTO_ecdsa_key_get_public (&mem->priv_key, &req->member_key); |
549 | if (0 < join_msg_size) | 556 | if (0 < join_msg_size) |
550 | memcpy (&req[1], join_msg, join_msg_size); | 557 | memcpy (&req[1], join_msg, join_msg_size); |
551 | 558 | ||
@@ -554,7 +561,7 @@ client_member_join (void *cls, struct GNUNET_SERVER_Client *client, | |||
554 | - sizeof (req->signature)); | 561 | - sizeof (req->signature)); |
555 | req->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_MULTICAST_REQUEST); | 562 | req->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_MULTICAST_REQUEST); |
556 | 563 | ||
557 | if (GNUNET_OK != GNUNET_CRYPTO_eddsa_sign (&mem->priv_key, &req->purpose, | 564 | if (GNUNET_OK != GNUNET_CRYPTO_ecdsa_sign (&mem->priv_key, &req->purpose, |
558 | &req->signature)) | 565 | &req->signature)) |
559 | { | 566 | { |
560 | /* FIXME: handle error */ | 567 | /* FIXME: handle error */ |
@@ -700,7 +707,7 @@ client_multicast_request (void *cls, struct GNUNET_SERVER_Client *client, | |||
700 | - sizeof (req->signature)); | 707 | - sizeof (req->signature)); |
701 | req->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_MULTICAST_REQUEST); | 708 | req->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_MULTICAST_REQUEST); |
702 | 709 | ||
703 | if (GNUNET_OK != GNUNET_CRYPTO_eddsa_sign (&mem->priv_key, &req->purpose, | 710 | if (GNUNET_OK != GNUNET_CRYPTO_ecdsa_sign (&mem->priv_key, &req->purpose, |
704 | &req->signature)) | 711 | &req->signature)) |
705 | { | 712 | { |
706 | /* FIXME: handle error */ | 713 | /* FIXME: handle error */ |
@@ -721,7 +728,7 @@ client_multicast_request (void *cls, struct GNUNET_SERVER_Client *client, | |||
721 | 728 | ||
722 | 729 | ||
723 | /** | 730 | /** |
724 | * Core connected. | 731 | * Connected to core service. |
725 | */ | 732 | */ |
726 | static void | 733 | static void |
727 | core_connected_cb (void *cls, const struct GNUNET_PeerIdentity *my_identity) | 734 | core_connected_cb (void *cls, const struct GNUNET_PeerIdentity *my_identity) |
diff --git a/src/multicast/multicast.h b/src/multicast/multicast.h index 76492e868..9abf3802c 100644 --- a/src/multicast/multicast.h +++ b/src/multicast/multicast.h | |||
@@ -50,7 +50,7 @@ struct MulticastJoinRequestMessage | |||
50 | * | 50 | * |
51 | * Signature must match the public key of the joining member. | 51 | * Signature must match the public key of the joining member. |
52 | */ | 52 | */ |
53 | struct GNUNET_CRYPTO_EddsaSignature signature; | 53 | struct GNUNET_CRYPTO_EcdsaSignature signature; |
54 | 54 | ||
55 | /** | 55 | /** |
56 | * Purpose for the signature and size of the signed data. | 56 | * Purpose for the signature and size of the signed data. |
@@ -65,7 +65,7 @@ struct MulticastJoinRequestMessage | |||
65 | /** | 65 | /** |
66 | * Public key of the joining member. | 66 | * Public key of the joining member. |
67 | */ | 67 | */ |
68 | struct GNUNET_CRYPTO_EddsaPublicKey member_key; | 68 | struct GNUNET_CRYPTO_EcdsaPublicKey member_key; |
69 | 69 | ||
70 | /** | 70 | /** |
71 | * Peer identity of the joining member. | 71 | * Peer identity of the joining member. |
@@ -125,7 +125,7 @@ struct MulticastJoinDecisionMessageHeader | |||
125 | * C->S: Public key of the member requesting join. | 125 | * C->S: Public key of the member requesting join. |
126 | * S->C: Unused. | 126 | * S->C: Unused. |
127 | */ | 127 | */ |
128 | struct GNUNET_CRYPTO_EddsaPublicKey member_key; | 128 | struct GNUNET_CRYPTO_EcdsaPublicKey member_key; |
129 | 129 | ||
130 | /* Followed by struct MulticastJoinDecisionMessage */ | 130 | /* Followed by struct MulticastJoinDecisionMessage */ |
131 | }; | 131 | }; |
@@ -244,12 +244,13 @@ struct MulticastMemberJoinMessage | |||
244 | 244 | ||
245 | struct GNUNET_CRYPTO_EddsaPublicKey group_key; | 245 | struct GNUNET_CRYPTO_EddsaPublicKey group_key; |
246 | 246 | ||
247 | struct GNUNET_CRYPTO_EddsaPrivateKey member_key; | 247 | struct GNUNET_CRYPTO_EcdsaPrivateKey member_key; |
248 | 248 | ||
249 | struct GNUNET_PeerIdentity origin; | 249 | struct GNUNET_PeerIdentity origin; |
250 | 250 | ||
251 | /* Followed by struct GNUNET_PeerIdentity relays[relay_count] */ | 251 | /* Followed by struct GNUNET_PeerIdentity relays[relay_count] */ |
252 | /* Followed by struct GNUNET_MessageHeader join_request */ | 252 | |
253 | /* Followed by struct GNUNET_MessageHeader join_msg */ | ||
253 | }; | 254 | }; |
254 | 255 | ||
255 | 256 | ||
@@ -313,7 +314,7 @@ struct MulticastJoinMessage | |||
313 | /** | 314 | /** |
314 | * Our private key for the group. | 315 | * Our private key for the group. |
315 | */ | 316 | */ |
316 | struct GNUNET_CRYPTO_EddsaPrivateKey member_key; | 317 | struct GNUNET_CRYPTO_EcdsaPrivateKey member_key; |
317 | 318 | ||
318 | /* followed by 'relay_count' `struct GNUNET_PeerIdentity`s */ | 319 | /* followed by 'relay_count' `struct GNUNET_PeerIdentity`s */ |
319 | 320 | ||
diff --git a/src/multicast/multicast_api.c b/src/multicast/multicast_api.c index b6d51896d..d2a0412bb 100644 --- a/src/multicast/multicast_api.c +++ b/src/multicast/multicast_api.c | |||
@@ -138,7 +138,7 @@ struct GNUNET_MULTICAST_JoinHandle | |||
138 | /** | 138 | /** |
139 | * Public key of the member requesting join. | 139 | * Public key of the member requesting join. |
140 | */ | 140 | */ |
141 | struct GNUNET_CRYPTO_EddsaPublicKey member_key; | 141 | struct GNUNET_CRYPTO_EcdsaPublicKey member_key; |
142 | 142 | ||
143 | /** | 143 | /** |
144 | * Peer identity of the member requesting join. | 144 | * Peer identity of the member requesting join. |
@@ -714,7 +714,7 @@ GNUNET_MULTICAST_origin_to_all_cancel (struct GNUNET_MULTICAST_OriginTransmitHan | |||
714 | struct GNUNET_MULTICAST_Member * | 714 | struct GNUNET_MULTICAST_Member * |
715 | GNUNET_MULTICAST_member_join (const struct GNUNET_CONFIGURATION_Handle *cfg, | 715 | GNUNET_MULTICAST_member_join (const struct GNUNET_CONFIGURATION_Handle *cfg, |
716 | const struct GNUNET_CRYPTO_EddsaPublicKey *group_key, | 716 | const struct GNUNET_CRYPTO_EddsaPublicKey *group_key, |
717 | const struct GNUNET_CRYPTO_EddsaPrivateKey *member_key, | 717 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *member_key, |
718 | const struct GNUNET_PeerIdentity *origin, | 718 | const struct GNUNET_PeerIdentity *origin, |
719 | uint16_t relay_count, | 719 | uint16_t relay_count, |
720 | const struct GNUNET_PeerIdentity *relays, | 720 | const struct GNUNET_PeerIdentity *relays, |
diff --git a/src/psyc/gnunet-service-psyc.c b/src/psyc/gnunet-service-psyc.c index 9dcf40e0f..866275a79 100644 --- a/src/psyc/gnunet-service-psyc.c +++ b/src/psyc/gnunet-service-psyc.c | |||
@@ -93,7 +93,7 @@ struct TransmitMessage | |||
93 | uint64_t id; | 93 | uint64_t id; |
94 | 94 | ||
95 | /** | 95 | /** |
96 | * Size of @a buf | 96 | * Size of message. |
97 | */ | 97 | */ |
98 | uint16_t size; | 98 | uint16_t size; |
99 | 99 | ||
@@ -211,11 +211,6 @@ struct Channel | |||
211 | struct GNUNET_CONTAINER_Heap *recv_msgs; | 211 | struct GNUNET_CONTAINER_Heap *recv_msgs; |
212 | 212 | ||
213 | /** | 213 | /** |
214 | * FIXME: needed? | ||
215 | */ | ||
216 | GNUNET_SCHEDULER_TaskIdentifier tmit_task; | ||
217 | |||
218 | /** | ||
219 | * Public key of the channel. | 214 | * Public key of the channel. |
220 | */ | 215 | */ |
221 | struct GNUNET_CRYPTO_EddsaPublicKey pub_key; | 216 | struct GNUNET_CRYPTO_EddsaPublicKey pub_key; |
@@ -264,14 +259,16 @@ struct Channel | |||
264 | uint8_t is_master; | 259 | uint8_t is_master; |
265 | 260 | ||
266 | /** | 261 | /** |
267 | * Ready to receive messages from client? #GNUNET_YES or #GNUNET_NO | 262 | * Is this channel ready to receive messages from client? |
263 | * #GNUNET_YES or #GNUNET_NO | ||
268 | */ | 264 | */ |
269 | uint8_t ready; | 265 | uint8_t is_ready; |
270 | 266 | ||
271 | /** | 267 | /** |
272 | * Is the client disconnected? #GNUNET_YES or #GNUNET_NO | 268 | * Is the client disconnected? |
269 | * #GNUNET_YES or #GNUNET_NO | ||
273 | */ | 270 | */ |
274 | uint8_t disconnected; | 271 | uint8_t is_disconnected; |
275 | }; | 272 | }; |
276 | 273 | ||
277 | 274 | ||
@@ -345,12 +342,12 @@ struct Slave | |||
345 | /** | 342 | /** |
346 | * Private key of the slave. | 343 | * Private key of the slave. |
347 | */ | 344 | */ |
348 | struct GNUNET_CRYPTO_EddsaPrivateKey priv_key; | 345 | struct GNUNET_CRYPTO_EcdsaPrivateKey priv_key; |
349 | 346 | ||
350 | /** | 347 | /** |
351 | * Public key of the slave. | 348 | * Public key of the slave. |
352 | */ | 349 | */ |
353 | struct GNUNET_CRYPTO_EddsaPublicKey pub_key; | 350 | struct GNUNET_CRYPTO_EcdsaPublicKey pub_key; |
354 | 351 | ||
355 | /** | 352 | /** |
356 | * Hash of @a pub_key. | 353 | * Hash of @a pub_key. |
@@ -390,7 +387,7 @@ struct Slave | |||
390 | /** | 387 | /** |
391 | * Join decision received from multicast. | 388 | * Join decision received from multicast. |
392 | */ | 389 | */ |
393 | struct SlaveJoinDecision *join_dcsn; | 390 | struct GNUNET_PSYC_JoinDecisionMessage *join_dcsn; |
394 | 391 | ||
395 | /** | 392 | /** |
396 | * Maximum request ID for this channel. | 393 | * Maximum request ID for this channel. |
@@ -514,6 +511,7 @@ client_disconnect (void *cls, struct GNUNET_SERVER_Client *client) | |||
514 | { | 511 | { |
515 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 512 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
516 | "%p User context is NULL in client_disconnect()\n", chn); | 513 | "%p User context is NULL in client_disconnect()\n", chn); |
514 | GNUNET_break (0); | ||
517 | return; | 515 | return; |
518 | } | 516 | } |
519 | 517 | ||
@@ -573,7 +571,7 @@ client_send_msg (const struct Channel *chn, | |||
573 | */ | 571 | */ |
574 | struct JoinMemTestClosure | 572 | struct JoinMemTestClosure |
575 | { | 573 | { |
576 | struct GNUNET_CRYPTO_EddsaPublicKey slave_key; | 574 | struct GNUNET_CRYPTO_EcdsaPublicKey slave_key; |
577 | struct Channel *chn; | 575 | struct Channel *chn; |
578 | struct GNUNET_MULTICAST_JoinHandle *jh; | 576 | struct GNUNET_MULTICAST_JoinHandle *jh; |
579 | struct MasterJoinRequest *master_join_req; | 577 | struct MasterJoinRequest *master_join_req; |
@@ -613,7 +611,7 @@ join_mem_test_cb (void *cls, int64_t result, const char *err_msg) | |||
613 | */ | 611 | */ |
614 | static void | 612 | static void |
615 | mcast_recv_join_request (void *cls, | 613 | mcast_recv_join_request (void *cls, |
616 | const struct GNUNET_CRYPTO_EddsaPublicKey *slave_key, | 614 | const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key, |
617 | const struct GNUNET_MessageHeader *join_msg, | 615 | const struct GNUNET_MessageHeader *join_msg, |
618 | struct GNUNET_MULTICAST_JoinHandle *jh) | 616 | struct GNUNET_MULTICAST_JoinHandle *jh) |
619 | { | 617 | { |
@@ -670,7 +668,7 @@ mcast_recv_join_decision (void *cls, int is_admitted, | |||
670 | "%p Got join decision: %d\n", slv, is_admitted); | 668 | "%p Got join decision: %d\n", slv, is_admitted); |
671 | 669 | ||
672 | uint16_t join_resp_size = (NULL != join_resp) ? ntohs (join_resp->size) : 0; | 670 | uint16_t join_resp_size = (NULL != join_resp) ? ntohs (join_resp->size) : 0; |
673 | struct SlaveJoinDecision * | 671 | struct GNUNET_PSYC_JoinDecisionMessage * |
674 | dcsn = slv->join_dcsn = GNUNET_malloc (sizeof (*dcsn) + join_resp_size); | 672 | dcsn = slv->join_dcsn = GNUNET_malloc (sizeof (*dcsn) + join_resp_size); |
675 | dcsn->header.size = htons (sizeof (*dcsn) + join_resp_size); | 673 | dcsn->header.size = htons (sizeof (*dcsn) + join_resp_size); |
676 | dcsn->header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_JOIN_DECISION); | 674 | dcsn->header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_JOIN_DECISION); |
@@ -682,7 +680,7 @@ mcast_recv_join_decision (void *cls, int is_admitted, | |||
682 | 680 | ||
683 | if (GNUNET_YES == is_admitted) | 681 | if (GNUNET_YES == is_admitted) |
684 | { | 682 | { |
685 | chn->ready = GNUNET_YES; | 683 | chn->is_ready = GNUNET_YES; |
686 | } | 684 | } |
687 | else | 685 | else |
688 | { | 686 | { |
@@ -693,7 +691,7 @@ mcast_recv_join_decision (void *cls, int is_admitted, | |||
693 | 691 | ||
694 | static void | 692 | static void |
695 | mcast_recv_membership_test (void *cls, | 693 | mcast_recv_membership_test (void *cls, |
696 | const struct GNUNET_CRYPTO_EddsaPublicKey *slave_key, | 694 | const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key, |
697 | uint64_t message_id, uint64_t group_generation, | 695 | uint64_t message_id, uint64_t group_generation, |
698 | struct GNUNET_MULTICAST_MembershipTestHandle *mth) | 696 | struct GNUNET_MULTICAST_MembershipTestHandle *mth) |
699 | { | 697 | { |
@@ -703,7 +701,7 @@ mcast_recv_membership_test (void *cls, | |||
703 | 701 | ||
704 | static void | 702 | static void |
705 | mcast_recv_replay_fragment (void *cls, | 703 | mcast_recv_replay_fragment (void *cls, |
706 | const struct GNUNET_CRYPTO_EddsaPublicKey *slave_key, | 704 | const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key, |
707 | uint64_t fragment_id, uint64_t flags, | 705 | uint64_t fragment_id, uint64_t flags, |
708 | struct GNUNET_MULTICAST_ReplayHandle *rh) | 706 | struct GNUNET_MULTICAST_ReplayHandle *rh) |
709 | 707 | ||
@@ -714,7 +712,7 @@ mcast_recv_replay_fragment (void *cls, | |||
714 | 712 | ||
715 | static void | 713 | static void |
716 | mcast_recv_replay_message (void *cls, | 714 | mcast_recv_replay_message (void *cls, |
717 | const struct GNUNET_CRYPTO_EddsaPublicKey *slave_key, | 715 | const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key, |
718 | uint64_t message_id, | 716 | uint64_t message_id, |
719 | uint64_t fragment_offset, | 717 | uint64_t fragment_offset, |
720 | uint64_t flags, | 718 | uint64_t flags, |
@@ -737,7 +735,7 @@ hash_key_from_nll (struct GNUNET_HashCode *key, uint64_t n) | |||
737 | n = ((n << 8) & 0xFF00FF00FF00FF00ULL) | ((n >> 8) & 0x00FF00FF00FF00FFULL); | 735 | n = ((n << 8) & 0xFF00FF00FF00FF00ULL) | ((n >> 8) & 0x00FF00FF00FF00FFULL); |
738 | n = ((n << 16) & 0xFFFF0000FFFF0000ULL) | ((n >> 16) & 0x0000FFFF0000FFFFULL); | 736 | n = ((n << 16) & 0xFFFF0000FFFF0000ULL) | ((n >> 16) & 0x0000FFFF0000FFFFULL); |
739 | 737 | ||
740 | *key = (struct GNUNET_HashCode) {{ 0 }}; | 738 | *key = (struct GNUNET_HashCode) {}; |
741 | *((uint64_t *) key) | 739 | *((uint64_t *) key) |
742 | = (n << 32) | (n >> 32); | 740 | = (n << 32) | (n >> 32); |
743 | } | 741 | } |
@@ -753,7 +751,7 @@ hash_key_from_hll (struct GNUNET_HashCode *key, uint64_t n) | |||
753 | #if __BYTE_ORDER == __BIG_ENDIAN | 751 | #if __BYTE_ORDER == __BIG_ENDIAN |
754 | hash_key_from_nll (key, n); | 752 | hash_key_from_nll (key, n); |
755 | #elif __BYTE_ORDER == __LITTLE_ENDIAN | 753 | #elif __BYTE_ORDER == __LITTLE_ENDIAN |
756 | *key = (struct GNUNET_HashCode) {{ 0 }}; | 754 | *key = (struct GNUNET_HashCode) {}; |
757 | *((uint64_t *) key) = n; | 755 | *((uint64_t *) key) = n; |
758 | #else | 756 | #else |
759 | #error byteorder undefined | 757 | #error byteorder undefined |
@@ -1225,10 +1223,8 @@ mcast_recv_message (void *cls, const struct GNUNET_MULTICAST_MessageHeader *mmsg | |||
1225 | /** | 1223 | /** |
1226 | * Incoming request fragment from multicast for a master. | 1224 | * Incoming request fragment from multicast for a master. |
1227 | * | 1225 | * |
1228 | * @param cls Master. | 1226 | * @param cls Master. |
1229 | * @param slave_key Sending slave's public key. | 1227 | * @param req The request. |
1230 | * @param msg The message. | ||
1231 | * @param flags Request flags. | ||
1232 | */ | 1228 | */ |
1233 | static void | 1229 | static void |
1234 | mcast_recv_request (void *cls, | 1230 | mcast_recv_request (void *cls, |
@@ -1295,7 +1291,7 @@ store_recv_master_counters (void *cls, int result, uint64_t max_fragment_id, | |||
1295 | &mcast_recv_replay_message, | 1291 | &mcast_recv_replay_message, |
1296 | &mcast_recv_request, | 1292 | &mcast_recv_request, |
1297 | &mcast_recv_message, chn); | 1293 | &mcast_recv_message, chn); |
1298 | chn->ready = GNUNET_YES; | 1294 | chn->is_ready = GNUNET_YES; |
1299 | } | 1295 | } |
1300 | else | 1296 | else |
1301 | { | 1297 | { |
@@ -1400,7 +1396,7 @@ client_recv_master_start (void *cls, struct GNUNET_SERVER_Client *client, | |||
1400 | GNUNET_CONTAINER_multihashmap_put (masters, &chn->pub_key_hash, chn, | 1396 | GNUNET_CONTAINER_multihashmap_put (masters, &chn->pub_key_hash, chn, |
1401 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 1397 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
1402 | chn->store_op = GNUNET_PSYCSTORE_counters_get (store, &chn->pub_key, | 1398 | chn->store_op = GNUNET_PSYCSTORE_counters_get (store, &chn->pub_key, |
1403 | store_recv_master_counters, mst); | 1399 | store_recv_master_counters, mst); |
1404 | } | 1400 | } |
1405 | else | 1401 | else |
1406 | { | 1402 | { |
@@ -1440,10 +1436,10 @@ client_recv_slave_join (void *cls, struct GNUNET_SERVER_Client *client, | |||
1440 | const struct SlaveJoinRequest *req | 1436 | const struct SlaveJoinRequest *req |
1441 | = (const struct SlaveJoinRequest *) msg; | 1437 | = (const struct SlaveJoinRequest *) msg; |
1442 | 1438 | ||
1443 | struct GNUNET_CRYPTO_EddsaPublicKey slv_pub_key; | 1439 | struct GNUNET_CRYPTO_EcdsaPublicKey slv_pub_key; |
1444 | struct GNUNET_HashCode pub_key_hash, slv_pub_key_hash; | 1440 | struct GNUNET_HashCode pub_key_hash, slv_pub_key_hash; |
1445 | 1441 | ||
1446 | GNUNET_CRYPTO_eddsa_key_get_public (&req->slave_key, &slv_pub_key); | 1442 | GNUNET_CRYPTO_ecdsa_key_get_public (&req->slave_key, &slv_pub_key); |
1447 | GNUNET_CRYPTO_hash (&slv_pub_key, sizeof (slv_pub_key), &slv_pub_key_hash); | 1443 | GNUNET_CRYPTO_hash (&slv_pub_key, sizeof (slv_pub_key), &slv_pub_key_hash); |
1448 | GNUNET_CRYPTO_hash (&req->channel_key, sizeof (req->channel_key), &pub_key_hash); | 1444 | GNUNET_CRYPTO_hash (&req->channel_key, sizeof (req->channel_key), &pub_key_hash); |
1449 | 1445 | ||
@@ -1540,7 +1536,7 @@ client_recv_slave_join (void *cls, struct GNUNET_SERVER_Client *client, | |||
1540 | cli->client = client; | 1536 | cli->client = client; |
1541 | GNUNET_CONTAINER_DLL_insert (chn->clients_head, chn->clients_tail, cli); | 1537 | GNUNET_CONTAINER_DLL_insert (chn->clients_head, chn->clients_tail, cli); |
1542 | 1538 | ||
1543 | GNUNET_SERVER_client_set_user_context (client, &slv->chn); | 1539 | GNUNET_SERVER_client_set_user_context (client, chn); |
1544 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 1540 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
1545 | } | 1541 | } |
1546 | 1542 | ||
@@ -1578,7 +1574,8 @@ client_recv_join_decision (void *cls, struct GNUNET_SERVER_Client *client, | |||
1578 | GNUNET_assert (GNUNET_YES == chn->is_master); | 1574 | GNUNET_assert (GNUNET_YES == chn->is_master); |
1579 | struct Master *mst = (struct Master *) chn; | 1575 | struct Master *mst = (struct Master *) chn; |
1580 | 1576 | ||
1581 | struct MasterJoinDecision *dcsn = (struct MasterJoinDecision *) msg; | 1577 | struct GNUNET_PSYC_JoinDecisionMessage * |
1578 | dcsn = (struct GNUNET_PSYC_JoinDecisionMessage *) msg; | ||
1582 | struct JoinDecisionClosure jcls; | 1579 | struct JoinDecisionClosure jcls; |
1583 | jcls.is_admitted = ntohl (dcsn->is_admitted); | 1580 | jcls.is_admitted = ntohl (dcsn->is_admitted); |
1584 | jcls.msg | 1581 | jcls.msg |
@@ -1655,19 +1652,15 @@ transmit_notify (void *cls, size_t *data_size, void *data) | |||
1655 | GNUNET_CONTAINER_DLL_remove (chn->tmit_head, chn->tmit_tail, tmit_msg); | 1652 | GNUNET_CONTAINER_DLL_remove (chn->tmit_head, chn->tmit_tail, tmit_msg); |
1656 | GNUNET_free (tmit_msg); | 1653 | GNUNET_free (tmit_msg); |
1657 | 1654 | ||
1658 | if (0 == chn->tmit_task) | 1655 | if (NULL != chn->tmit_head) |
1659 | { | 1656 | { |
1660 | if (NULL != chn->tmit_head) | 1657 | transmit_message (chn); |
1661 | { | 1658 | } |
1662 | transmit_message (chn); | 1659 | else if (GNUNET_YES == chn->is_disconnected) |
1663 | } | 1660 | { |
1664 | else if (chn->disconnected) | 1661 | /* FIXME: handle partial message (when still in_transmit) */ |
1665 | { | 1662 | cleanup_channel (chn); |
1666 | /* FIXME: handle partial message (when still in_transmit) */ | ||
1667 | cleanup_channel (chn); | ||
1668 | } | ||
1669 | } | 1663 | } |
1670 | |||
1671 | return ret; | 1664 | return ret; |
1672 | } | 1665 | } |
1673 | 1666 | ||
@@ -1712,8 +1705,6 @@ slave_transmit_notify (void *cls, size_t *data_size, void *data) | |||
1712 | static void | 1705 | static void |
1713 | master_transmit_message (struct Master *mst) | 1706 | master_transmit_message (struct Master *mst) |
1714 | { | 1707 | { |
1715 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%p master_transmit_message()\n", mst); | ||
1716 | mst->chn.tmit_task = 0; | ||
1717 | if (NULL == mst->tmit_handle) | 1708 | if (NULL == mst->tmit_handle) |
1718 | { | 1709 | { |
1719 | mst->tmit_handle | 1710 | mst->tmit_handle |
@@ -1734,7 +1725,6 @@ master_transmit_message (struct Master *mst) | |||
1734 | static void | 1725 | static void |
1735 | slave_transmit_message (struct Slave *slv) | 1726 | slave_transmit_message (struct Slave *slv) |
1736 | { | 1727 | { |
1737 | slv->chn.tmit_task = 0; | ||
1738 | if (NULL == slv->tmit_handle) | 1728 | if (NULL == slv->tmit_handle) |
1739 | { | 1729 | { |
1740 | slv->tmit_handle | 1730 | slv->tmit_handle |
@@ -1830,6 +1820,8 @@ queue_message (struct Channel *chn, | |||
1830 | tmit_msg->size = data_size; | 1820 | tmit_msg->size = data_size; |
1831 | tmit_msg->state = chn->tmit_state; | 1821 | tmit_msg->state = chn->tmit_state; |
1832 | 1822 | ||
1823 | /* FIXME: separate queue per message ID */ | ||
1824 | |||
1833 | GNUNET_CONTAINER_DLL_insert_tail (chn->tmit_head, chn->tmit_tail, tmit_msg); | 1825 | GNUNET_CONTAINER_DLL_insert_tail (chn->tmit_head, chn->tmit_tail, tmit_msg); |
1834 | 1826 | ||
1835 | chn->is_master | 1827 | chn->is_master |
@@ -1877,10 +1869,11 @@ client_recv_psyc_message (void *cls, struct GNUNET_SERVER_Client *client, | |||
1877 | "%p Received message from client.\n", chn); | 1869 | "%p Received message from client.\n", chn); |
1878 | GNUNET_PSYC_log_message (GNUNET_ERROR_TYPE_DEBUG, msg); | 1870 | GNUNET_PSYC_log_message (GNUNET_ERROR_TYPE_DEBUG, msg); |
1879 | 1871 | ||
1880 | if (GNUNET_YES != chn->ready) | 1872 | if (GNUNET_YES != chn->is_ready) |
1881 | { | 1873 | { |
1882 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1874 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1883 | "%p Channel is not ready, dropping message from client.\n", chn); | 1875 | "%p Channel is not ready yet, disconnecting client.\n", chn); |
1876 | GNUNET_break (0); | ||
1884 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 1877 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
1885 | return; | 1878 | return; |
1886 | } | 1879 | } |
diff --git a/src/psyc/psyc.h b/src/psyc/psyc.h index 66c8de898..995fb1fa4 100644 --- a/src/psyc/psyc.h +++ b/src/psyc/psyc.h | |||
@@ -78,9 +78,9 @@ struct MasterStartRequest | |||
78 | */ | 78 | */ |
79 | struct GNUNET_MessageHeader header; | 79 | struct GNUNET_MessageHeader header; |
80 | 80 | ||
81 | struct GNUNET_CRYPTO_EddsaPrivateKey channel_key; | ||
82 | |||
83 | uint32_t policy GNUNET_PACKED; | 81 | uint32_t policy GNUNET_PACKED; |
82 | |||
83 | struct GNUNET_CRYPTO_EddsaPrivateKey channel_key; | ||
84 | }; | 84 | }; |
85 | 85 | ||
86 | 86 | ||
@@ -95,15 +95,17 @@ struct SlaveJoinRequest | |||
95 | 95 | ||
96 | struct GNUNET_CRYPTO_EddsaPublicKey channel_key; | 96 | struct GNUNET_CRYPTO_EddsaPublicKey channel_key; |
97 | 97 | ||
98 | struct GNUNET_CRYPTO_EddsaPrivateKey slave_key; | 98 | struct GNUNET_CRYPTO_EcdsaPrivateKey slave_key; |
99 | 99 | ||
100 | struct GNUNET_PeerIdentity origin; | 100 | struct GNUNET_PeerIdentity origin; |
101 | 101 | ||
102 | /* Followed by struct GNUNET_PeerIdentity relays[relay_count] */ | 102 | /* Followed by struct GNUNET_PeerIdentity relays[relay_count] */ |
103 | |||
104 | /* Followed by struct GNUNET_MessageHeader join_msg */ | ||
103 | }; | 105 | }; |
104 | 106 | ||
105 | 107 | ||
106 | struct ChannelSlaveAdd | 108 | struct ChannelSlaveAddRequest |
107 | { | 109 | { |
108 | /** | 110 | /** |
109 | * Type: GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_SLAVE_ADD | 111 | * Type: GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_SLAVE_ADD |
@@ -112,7 +114,7 @@ struct ChannelSlaveAdd | |||
112 | 114 | ||
113 | uint32_t reserved; | 115 | uint32_t reserved; |
114 | 116 | ||
115 | struct GNUNET_CRYPTO_EddsaPublicKey *slave_key; | 117 | struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key; |
116 | 118 | ||
117 | uint64_t announced_at; | 119 | uint64_t announced_at; |
118 | 120 | ||
@@ -120,7 +122,7 @@ struct ChannelSlaveAdd | |||
120 | }; | 122 | }; |
121 | 123 | ||
122 | 124 | ||
123 | struct ChannelSlaveRemove | 125 | struct ChannelSlaveRemoveRequest |
124 | { | 126 | { |
125 | /** | 127 | /** |
126 | * Type: GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_SLAVE_RM | 128 | * Type: GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_SLAVE_RM |
@@ -129,7 +131,7 @@ struct ChannelSlaveRemove | |||
129 | 131 | ||
130 | uint32_t reserved; | 132 | uint32_t reserved; |
131 | 133 | ||
132 | struct GNUNET_CRYPTO_EddsaPublicKey *slave_key; | 134 | struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key; |
133 | 135 | ||
134 | uint64_t announced_at; | 136 | uint64_t announced_at; |
135 | }; | 137 | }; |
@@ -189,6 +191,7 @@ struct CountersResult | |||
189 | uint64_t max_message_id; | 191 | uint64_t max_message_id; |
190 | }; | 192 | }; |
191 | 193 | ||
194 | |||
192 | /** | 195 | /** |
193 | * Answer from service to client about last operation. | 196 | * Answer from service to client about last operation. |
194 | */ | 197 | */ |
@@ -236,50 +239,12 @@ struct MasterJoinRequest | |||
236 | /** | 239 | /** |
237 | * Public key of the joining slave. | 240 | * Public key of the joining slave. |
238 | */ | 241 | */ |
239 | struct GNUNET_CRYPTO_EddsaPublicKey slave_key; | 242 | struct GNUNET_CRYPTO_EcdsaPublicKey slave_key; |
240 | 243 | ||
241 | /* Followed by struct GNUNET_MessageHeader join_request */ | 244 | /* Followed by struct GNUNET_MessageHeader join_request */ |
242 | }; | 245 | }; |
243 | 246 | ||
244 | 247 | ||
245 | struct MasterJoinDecision | ||
246 | { | ||
247 | /** | ||
248 | * Type: GNUNET_MESSAGE_TYPE_PSYC_JOIN_DECISION | ||
249 | */ | ||
250 | struct GNUNET_MessageHeader header; | ||
251 | |||
252 | /** | ||
253 | * #GNUNET_YES if the slave was admitted. | ||
254 | */ | ||
255 | int32_t is_admitted; | ||
256 | |||
257 | /** | ||
258 | * Public key of the joining slave. | ||
259 | */ | ||
260 | struct GNUNET_CRYPTO_EddsaPublicKey slave_key; | ||
261 | |||
262 | /* Followed by struct GNUNET_MessageHeader join_response */ | ||
263 | }; | ||
264 | |||
265 | |||
266 | struct SlaveJoinDecision | ||
267 | { | ||
268 | /** | ||
269 | * Type: GNUNET_MESSAGE_TYPE_PSYC_JOIN_DECISION | ||
270 | */ | ||
271 | struct GNUNET_MessageHeader header; | ||
272 | |||
273 | /** | ||
274 | * #GNUNET_YES if the slave was admitted. | ||
275 | */ | ||
276 | int32_t is_admitted; | ||
277 | |||
278 | /* Followed by struct GNUNET_MessageHeader join_response */ | ||
279 | }; | ||
280 | |||
281 | |||
282 | |||
283 | GNUNET_NETWORK_STRUCT_END | 248 | GNUNET_NETWORK_STRUCT_END |
284 | 249 | ||
285 | #endif | 250 | #endif |
diff --git a/src/psyc/psyc_api.c b/src/psyc/psyc_api.c index bfb6f43fb..88b007a0f 100644 --- a/src/psyc/psyc_api.c +++ b/src/psyc/psyc_api.c | |||
@@ -133,7 +133,7 @@ struct GNUNET_PSYC_Slave | |||
133 | struct GNUNET_PSYC_JoinHandle | 133 | struct GNUNET_PSYC_JoinHandle |
134 | { | 134 | { |
135 | struct GNUNET_PSYC_Master *mst; | 135 | struct GNUNET_PSYC_Master *mst; |
136 | struct GNUNET_CRYPTO_EddsaPublicKey slave_key; | 136 | struct GNUNET_CRYPTO_EcdsaPublicKey slave_key; |
137 | }; | 137 | }; |
138 | 138 | ||
139 | 139 | ||
@@ -270,8 +270,8 @@ slave_recv_join_decision (void *cls, | |||
270 | struct GNUNET_PSYC_Slave * | 270 | struct GNUNET_PSYC_Slave * |
271 | slv = GNUNET_CLIENT_MANAGER_get_user_context_ (client, | 271 | slv = GNUNET_CLIENT_MANAGER_get_user_context_ (client, |
272 | sizeof (struct GNUNET_PSYC_Channel)); | 272 | sizeof (struct GNUNET_PSYC_Channel)); |
273 | const struct SlaveJoinDecision * | 273 | const struct GNUNET_PSYC_JoinDecisionMessage * |
274 | dcsn = (const struct SlaveJoinDecision *) msg; | 274 | dcsn = (const struct GNUNET_PSYC_JoinDecisionMessage *) msg; |
275 | 275 | ||
276 | struct GNUNET_PSYC_MessageHeader *pmsg = NULL; | 276 | struct GNUNET_PSYC_MessageHeader *pmsg = NULL; |
277 | if (ntohs (dcsn->header.size) <= sizeof (*dcsn) + sizeof (*pmsg)) | 277 | if (ntohs (dcsn->header.size) <= sizeof (*dcsn) + sizeof (*pmsg)) |
@@ -285,8 +285,6 @@ slave_recv_join_decision (void *cls, | |||
285 | 285 | ||
286 | static struct GNUNET_CLIENT_MANAGER_MessageHandler master_handlers[] = | 286 | static struct GNUNET_CLIENT_MANAGER_MessageHandler master_handlers[] = |
287 | { | 287 | { |
288 | { &channel_recv_disconnect, NULL, 0, 0, GNUNET_NO }, | ||
289 | |||
290 | { &channel_recv_message, NULL, | 288 | { &channel_recv_message, NULL, |
291 | GNUNET_MESSAGE_TYPE_PSYC_MESSAGE, | 289 | GNUNET_MESSAGE_TYPE_PSYC_MESSAGE, |
292 | sizeof (struct GNUNET_PSYC_MessageHeader), GNUNET_YES }, | 290 | sizeof (struct GNUNET_PSYC_MessageHeader), GNUNET_YES }, |
@@ -303,14 +301,14 @@ static struct GNUNET_CLIENT_MANAGER_MessageHandler master_handlers[] = | |||
303 | GNUNET_MESSAGE_TYPE_PSYC_JOIN_REQUEST, | 301 | GNUNET_MESSAGE_TYPE_PSYC_JOIN_REQUEST, |
304 | sizeof (struct MasterJoinRequest), GNUNET_YES }, | 302 | sizeof (struct MasterJoinRequest), GNUNET_YES }, |
305 | 303 | ||
304 | { &channel_recv_disconnect, NULL, 0, 0, GNUNET_NO }, | ||
305 | |||
306 | { NULL, NULL, 0, 0, GNUNET_NO } | 306 | { NULL, NULL, 0, 0, GNUNET_NO } |
307 | }; | 307 | }; |
308 | 308 | ||
309 | 309 | ||
310 | static struct GNUNET_CLIENT_MANAGER_MessageHandler slave_handlers[] = | 310 | static struct GNUNET_CLIENT_MANAGER_MessageHandler slave_handlers[] = |
311 | { | 311 | { |
312 | { &channel_recv_disconnect, NULL, 0, 0, GNUNET_NO }, | ||
313 | |||
314 | { &channel_recv_message, NULL, | 312 | { &channel_recv_message, NULL, |
315 | GNUNET_MESSAGE_TYPE_PSYC_MESSAGE, | 313 | GNUNET_MESSAGE_TYPE_PSYC_MESSAGE, |
316 | sizeof (struct GNUNET_PSYC_MessageHeader), GNUNET_YES }, | 314 | sizeof (struct GNUNET_PSYC_MessageHeader), GNUNET_YES }, |
@@ -325,7 +323,9 @@ static struct GNUNET_CLIENT_MANAGER_MessageHandler slave_handlers[] = | |||
325 | 323 | ||
326 | { &slave_recv_join_decision, NULL, | 324 | { &slave_recv_join_decision, NULL, |
327 | GNUNET_MESSAGE_TYPE_PSYC_JOIN_DECISION, | 325 | GNUNET_MESSAGE_TYPE_PSYC_JOIN_DECISION, |
328 | sizeof (struct SlaveJoinDecision), GNUNET_YES }, | 326 | sizeof (struct GNUNET_PSYC_JoinDecisionMessage), GNUNET_YES }, |
327 | |||
328 | { &channel_recv_disconnect, NULL, 0, 0, GNUNET_NO }, | ||
329 | 329 | ||
330 | { NULL, NULL, 0, 0, GNUNET_NO } | 330 | { NULL, NULL, 0, 0, GNUNET_NO } |
331 | }; | 331 | }; |
@@ -442,7 +442,7 @@ GNUNET_PSYC_join_decision (struct GNUNET_PSYC_JoinHandle *jh, | |||
442 | const struct GNUNET_PSYC_MessageHeader *join_resp) | 442 | const struct GNUNET_PSYC_MessageHeader *join_resp) |
443 | { | 443 | { |
444 | struct GNUNET_PSYC_Channel *chn = &jh->mst->chn; | 444 | struct GNUNET_PSYC_Channel *chn = &jh->mst->chn; |
445 | struct MasterJoinDecision *dcsn; | 445 | struct GNUNET_PSYC_JoinDecisionMessage *dcsn; |
446 | uint16_t join_resp_size | 446 | uint16_t join_resp_size |
447 | = (NULL != join_resp) ? ntohs (join_resp->header.size) : 0; | 447 | = (NULL != join_resp) ? ntohs (join_resp->header.size) : 0; |
448 | uint16_t relay_size = relay_count * sizeof (*relays); | 448 | uint16_t relay_size = relay_count * sizeof (*relays); |
@@ -571,7 +571,7 @@ GNUNET_PSYC_master_get_channel (struct GNUNET_PSYC_Master *master) | |||
571 | struct GNUNET_PSYC_Slave * | 571 | struct GNUNET_PSYC_Slave * |
572 | GNUNET_PSYC_slave_join (const struct GNUNET_CONFIGURATION_Handle *cfg, | 572 | GNUNET_PSYC_slave_join (const struct GNUNET_CONFIGURATION_Handle *cfg, |
573 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, | 573 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, |
574 | const struct GNUNET_CRYPTO_EddsaPrivateKey *slave_key, | 574 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *slave_key, |
575 | const struct GNUNET_PeerIdentity *origin, | 575 | const struct GNUNET_PeerIdentity *origin, |
576 | uint32_t relay_count, | 576 | uint32_t relay_count, |
577 | const struct GNUNET_PeerIdentity *relays, | 577 | const struct GNUNET_PeerIdentity *relays, |
@@ -579,10 +579,7 @@ GNUNET_PSYC_slave_join (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
579 | GNUNET_PSYC_SlaveConnectCallback connect_cb, | 579 | GNUNET_PSYC_SlaveConnectCallback connect_cb, |
580 | GNUNET_PSYC_JoinDecisionCallback join_decision_cb, | 580 | GNUNET_PSYC_JoinDecisionCallback join_decision_cb, |
581 | void *cls, | 581 | void *cls, |
582 | const char *method_name, | 582 | const struct GNUNET_MessageHeader *join_msg) |
583 | const struct GNUNET_ENV_Environment *env, | ||
584 | const void *data, | ||
585 | uint16_t data_size) | ||
586 | { | 583 | { |
587 | struct GNUNET_PSYC_Slave *slv = GNUNET_malloc (sizeof (*slv)); | 584 | struct GNUNET_PSYC_Slave *slv = GNUNET_malloc (sizeof (*slv)); |
588 | struct GNUNET_PSYC_Channel *chn = &slv->chn; | 585 | struct GNUNET_PSYC_Channel *chn = &slv->chn; |
@@ -725,11 +722,11 @@ GNUNET_PSYC_slave_get_channel (struct GNUNET_PSYC_Slave *slv) | |||
725 | */ | 722 | */ |
726 | void | 723 | void |
727 | GNUNET_PSYC_channel_slave_add (struct GNUNET_PSYC_Channel *chn, | 724 | GNUNET_PSYC_channel_slave_add (struct GNUNET_PSYC_Channel *chn, |
728 | const struct GNUNET_CRYPTO_EddsaPublicKey *slave_key, | 725 | const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key, |
729 | uint64_t announced_at, | 726 | uint64_t announced_at, |
730 | uint64_t effective_since) | 727 | uint64_t effective_since) |
731 | { | 728 | { |
732 | struct ChannelSlaveAdd *add = GNUNET_malloc (sizeof (*add)); | 729 | struct ChannelSlaveAddRequest *add = GNUNET_malloc (sizeof (*add)); |
733 | add->header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_SLAVE_ADD); | 730 | add->header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_SLAVE_ADD); |
734 | add->header.size = htons (sizeof (*add)); | 731 | add->header.size = htons (sizeof (*add)); |
735 | add->announced_at = GNUNET_htonll (announced_at); | 732 | add->announced_at = GNUNET_htonll (announced_at); |
@@ -761,10 +758,10 @@ GNUNET_PSYC_channel_slave_add (struct GNUNET_PSYC_Channel *chn, | |||
761 | */ | 758 | */ |
762 | void | 759 | void |
763 | GNUNET_PSYC_channel_slave_remove (struct GNUNET_PSYC_Channel *chn, | 760 | GNUNET_PSYC_channel_slave_remove (struct GNUNET_PSYC_Channel *chn, |
764 | const struct GNUNET_CRYPTO_EddsaPublicKey *slave_key, | 761 | const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key, |
765 | uint64_t announced_at) | 762 | uint64_t announced_at) |
766 | { | 763 | { |
767 | struct ChannelSlaveRemove *rm = GNUNET_malloc (sizeof (*rm)); | 764 | struct ChannelSlaveRemoveRequest *rm = GNUNET_malloc (sizeof (*rm)); |
768 | rm->header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_SLAVE_RM); | 765 | rm->header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_SLAVE_RM); |
769 | rm->header.size = htons (sizeof (*rm)); | 766 | rm->header.size = htons (sizeof (*rm)); |
770 | rm->announced_at = GNUNET_htonll (announced_at); | 767 | rm->announced_at = GNUNET_htonll (announced_at); |
diff --git a/src/psyc/psyc_util_lib.c b/src/psyc/psyc_util_lib.c index a50d99bec..8ab0bdad2 100644 --- a/src/psyc/psyc_util_lib.c +++ b/src/psyc/psyc_util_lib.c | |||
@@ -34,22 +34,6 @@ | |||
34 | 34 | ||
35 | #define LOG(kind,...) GNUNET_log_from (kind, "psyc-util",__VA_ARGS__) | 35 | #define LOG(kind,...) GNUNET_log_from (kind, "psyc-util",__VA_ARGS__) |
36 | 36 | ||
37 | /** | ||
38 | * Message receive states. | ||
39 | */ | ||
40 | enum GNUNET_PSYC_MessageState | ||
41 | { | ||
42 | GNUNET_PSYC_MESSAGE_STATE_START = 0, | ||
43 | GNUNET_PSYC_MESSAGE_STATE_HEADER = 1, | ||
44 | GNUNET_PSYC_MESSAGE_STATE_METHOD = 2, | ||
45 | GNUNET_PSYC_MESSAGE_STATE_MODIFIER = 3, | ||
46 | GNUNET_PSYC_MESSAGE_STATE_MOD_CONT = 4, | ||
47 | GNUNET_PSYC_MESSAGE_STATE_DATA = 5, | ||
48 | GNUNET_PSYC_MESSAGE_STATE_END = 6, | ||
49 | GNUNET_PSYC_MESSAGE_STATE_CANCEL = 7, | ||
50 | GNUNET_PSYC_MESSAGE_STATE_ERROR = 8, | ||
51 | }; | ||
52 | |||
53 | 37 | ||
54 | struct GNUNET_PSYC_TransmitHandle | 38 | struct GNUNET_PSYC_TransmitHandle |
55 | { | 39 | { |
@@ -142,7 +126,7 @@ struct GNUNET_PSYC_ReceiveHandle | |||
142 | /** | 126 | /** |
143 | * Public key of the slave from which a message is being received. | 127 | * Public key of the slave from which a message is being received. |
144 | */ | 128 | */ |
145 | struct GNUNET_CRYPTO_EddsaPublicKey slave_key; | 129 | struct GNUNET_CRYPTO_EcdsaPublicKey slave_key; |
146 | 130 | ||
147 | /** | 131 | /** |
148 | * State of the currently being received message from the PSYC service. | 132 | * State of the currently being received message from the PSYC service. |
@@ -165,6 +149,101 @@ struct GNUNET_PSYC_ReceiveHandle | |||
165 | uint32_t mod_value_size; | 149 | uint32_t mod_value_size; |
166 | }; | 150 | }; |
167 | 151 | ||
152 | /**** Messages ****/ | ||
153 | |||
154 | |||
155 | /** | ||
156 | * Create a PSYC message. | ||
157 | * | ||
158 | * @param method_name | ||
159 | * PSYC method for the message. | ||
160 | * @param env | ||
161 | * Environment for the message. | ||
162 | * @param data | ||
163 | * Data payload for the message. | ||
164 | * @param data_size | ||
165 | * Size of @a data. | ||
166 | * | ||
167 | * @return Message header with size information, | ||
168 | * followed by the message parts. | ||
169 | */ | ||
170 | struct GNUNET_MessageHeader * | ||
171 | GNUNET_PSYC_message_create (const char *method_name, | ||
172 | const struct GNUNET_ENV_Environment *env, | ||
173 | const void *data, | ||
174 | size_t data_size) | ||
175 | { | ||
176 | struct GNUNET_ENV_Modifier *mod = NULL; | ||
177 | struct GNUNET_PSYC_MessageMethod *pmeth = NULL; | ||
178 | struct GNUNET_PSYC_MessageModifier *pmod = NULL; | ||
179 | struct GNUNET_MessageHeader *pmsg = NULL; | ||
180 | uint16_t env_size = 0; | ||
181 | if (NULL != env) | ||
182 | { | ||
183 | mod = GNUNET_ENV_environment_head (env); | ||
184 | while (NULL != mod) | ||
185 | { | ||
186 | env_size += sizeof (*pmod) + strlen (mod->name) + 1 + mod->value_size; | ||
187 | mod = mod->next; | ||
188 | } | ||
189 | } | ||
190 | |||
191 | struct GNUNET_MessageHeader *msg; | ||
192 | uint16_t method_name_size = strlen (method_name) + 1; | ||
193 | if (method_name_size == 1) | ||
194 | return NULL; | ||
195 | |||
196 | uint16_t msg_size = sizeof (*msg) /* header */ | ||
197 | + sizeof (*pmeth) + method_name_size /* method */ | ||
198 | + env_size /* modifiers */ | ||
199 | + ((0 < data_size) ? sizeof (*pmsg) + data_size : 0)/* data */ | ||
200 | + sizeof (*pmsg); /* end of message */ | ||
201 | msg = GNUNET_malloc (msg_size); | ||
202 | msg->size = htons (msg_size); | ||
203 | msg->type = htons (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE); | ||
204 | |||
205 | pmeth = (struct GNUNET_PSYC_MessageMethod *) &msg[1]; | ||
206 | pmeth->header.size = htons (sizeof (*pmeth) + method_name_size); | ||
207 | memcpy (pmeth, method_name, method_name_size); | ||
208 | |||
209 | uint16_t p = sizeof (*msg) + sizeof (*pmeth) + method_name_size; | ||
210 | if (NULL != env) | ||
211 | { | ||
212 | mod = GNUNET_ENV_environment_head (env); | ||
213 | while (NULL != mod) | ||
214 | { | ||
215 | uint16_t mod_name_size = strlen (mod->name) + 1; | ||
216 | pmod = (struct GNUNET_PSYC_MessageModifier *) ((char *) msg + p); | ||
217 | pmod->header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MODIFIER); | ||
218 | pmod->header.size = sizeof (*pmod) + mod_name_size + 1 + mod->value_size; | ||
219 | p += pmod->header.size; | ||
220 | pmod->header.size = htons (pmod->header.size); | ||
221 | |||
222 | memcpy (&pmod[1], mod->name, mod_name_size); | ||
223 | if (0 < mod->value_size) | ||
224 | memcpy ((char *) &pmod[1] + mod_name_size, mod->value, mod->value_size); | ||
225 | |||
226 | mod = mod->next; | ||
227 | } | ||
228 | } | ||
229 | |||
230 | if (0 < data_size) | ||
231 | { | ||
232 | pmsg = (struct GNUNET_MessageHeader *) ((char *) msg + p); | ||
233 | pmsg->size = sizeof (*pmsg) + data_size; | ||
234 | p += pmsg->size; | ||
235 | pmsg->size = htons (pmsg->size); | ||
236 | pmsg->type = htons (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_DATA); | ||
237 | memcpy (&pmsg[1], data, data_size); | ||
238 | } | ||
239 | |||
240 | pmsg = (struct GNUNET_MessageHeader *) ((char *) msg + p); | ||
241 | pmsg->size = htons (sizeof (*pmsg)); | ||
242 | pmsg->type = htons (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END); | ||
243 | |||
244 | return msg; | ||
245 | } | ||
246 | |||
168 | 247 | ||
169 | void | 248 | void |
170 | GNUNET_PSYC_log_message (enum GNUNET_ErrorType kind, | 249 | GNUNET_PSYC_log_message (enum GNUNET_ErrorType kind, |
diff --git a/src/psyc/test_psyc.c b/src/psyc/test_psyc.c index 6468b8a2b..0077bc9b7 100644 --- a/src/psyc/test_psyc.c +++ b/src/psyc/test_psyc.c | |||
@@ -33,11 +33,12 @@ | |||
33 | #include "gnunet_util_lib.h" | 33 | #include "gnunet_util_lib.h" |
34 | #include "gnunet_testing_lib.h" | 34 | #include "gnunet_testing_lib.h" |
35 | #include "gnunet_env_lib.h" | 35 | #include "gnunet_env_lib.h" |
36 | #include "gnunet_psyc_util_lib.h" | ||
36 | #include "gnunet_psyc_service.h" | 37 | #include "gnunet_psyc_service.h" |
37 | 38 | ||
38 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) | 39 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) |
39 | 40 | ||
40 | #define DEBUG_SERVICE 1 | 41 | #define DEBUG_SERVICE 0 |
41 | 42 | ||
42 | 43 | ||
43 | /** | 44 | /** |
@@ -56,10 +57,10 @@ static struct GNUNET_PSYC_Master *mst; | |||
56 | static struct GNUNET_PSYC_Slave *slv; | 57 | static struct GNUNET_PSYC_Slave *slv; |
57 | 58 | ||
58 | static struct GNUNET_CRYPTO_EddsaPrivateKey *channel_key; | 59 | static struct GNUNET_CRYPTO_EddsaPrivateKey *channel_key; |
59 | static struct GNUNET_CRYPTO_EddsaPrivateKey *slave_key; | 60 | static struct GNUNET_CRYPTO_EcdsaPrivateKey *slave_key; |
60 | 61 | ||
61 | static struct GNUNET_CRYPTO_EddsaPublicKey channel_pub_key; | 62 | static struct GNUNET_CRYPTO_EddsaPublicKey channel_pub_key; |
62 | static struct GNUNET_CRYPTO_EddsaPublicKey slave_pub_key; | 63 | static struct GNUNET_CRYPTO_EcdsaPublicKey slave_pub_key; |
63 | 64 | ||
64 | struct GNUNET_PSYC_MasterTransmitHandle *mth; | 65 | struct GNUNET_PSYC_MasterTransmitHandle *mth; |
65 | 66 | ||
@@ -414,7 +415,7 @@ join_decision_cb (void *cls, int is_admitted, | |||
414 | 415 | ||
415 | 416 | ||
416 | static void | 417 | static void |
417 | join_request_cb (void *cls, const struct GNUNET_CRYPTO_EddsaPublicKey *slave_key, | 418 | join_request_cb (void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key, |
418 | const struct GNUNET_PSYC_MessageHeader *msg, | 419 | const struct GNUNET_PSYC_MessageHeader *msg, |
419 | struct GNUNET_PSYC_JoinHandle *jh) | 420 | struct GNUNET_PSYC_JoinHandle *jh) |
420 | { | 421 | { |
@@ -449,10 +450,13 @@ slave_join () | |||
449 | "_foo", "bar baz", 7); | 450 | "_foo", "bar baz", 7); |
450 | GNUNET_ENV_environment_add (env, GNUNET_ENV_OP_ASSIGN, | 451 | GNUNET_ENV_environment_add (env, GNUNET_ENV_OP_ASSIGN, |
451 | "_foo_bar", "foo bar baz", 11); | 452 | "_foo_bar", "foo bar baz", 11); |
453 | struct GNUNET_MessageHeader * | ||
454 | join_msg = GNUNET_PSYC_message_create ("_request_join", env, "some data", 9); | ||
455 | |||
452 | slv = GNUNET_PSYC_slave_join (cfg, &channel_pub_key, slave_key, &origin, | 456 | slv = GNUNET_PSYC_slave_join (cfg, &channel_pub_key, slave_key, &origin, |
453 | 0, NULL, &slave_message_cb, | 457 | 0, NULL, &slave_message_cb, |
454 | &slave_connect_cb, &join_decision_cb, NULL, | 458 | &slave_connect_cb, &join_decision_cb, NULL, |
455 | "_request_join", env, "some data", 9); | 459 | join_msg); |
456 | GNUNET_ENV_environment_destroy (env); | 460 | GNUNET_ENV_environment_destroy (env); |
457 | } | 461 | } |
458 | 462 | ||
@@ -539,10 +543,10 @@ run (void *cls, | |||
539 | end_badly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); | 543 | end_badly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); |
540 | 544 | ||
541 | channel_key = GNUNET_CRYPTO_eddsa_key_create (); | 545 | channel_key = GNUNET_CRYPTO_eddsa_key_create (); |
542 | slave_key = GNUNET_CRYPTO_eddsa_key_create (); | 546 | slave_key = GNUNET_CRYPTO_ecdsa_key_create (); |
543 | 547 | ||
544 | GNUNET_CRYPTO_eddsa_key_get_public (channel_key, &channel_pub_key); | 548 | GNUNET_CRYPTO_eddsa_key_get_public (channel_key, &channel_pub_key); |
545 | GNUNET_CRYPTO_eddsa_key_get_public (slave_key, &slave_pub_key); | 549 | GNUNET_CRYPTO_ecdsa_key_get_public (slave_key, &slave_pub_key); |
546 | 550 | ||
547 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Starting master.\n"); | 551 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Starting master.\n"); |
548 | mst = GNUNET_PSYC_master_start (cfg, channel_key, GNUNET_PSYC_CHANNEL_PRIVATE, | 552 | mst = GNUNET_PSYC_master_start (cfg, channel_key, GNUNET_PSYC_CHANNEL_PRIVATE, |
diff --git a/src/psycstore/plugin_psycstore_sqlite.c b/src/psycstore/plugin_psycstore_sqlite.c index 6ca0236d5..86b969c5d 100644 --- a/src/psycstore/plugin_psycstore_sqlite.c +++ b/src/psycstore/plugin_psycstore_sqlite.c | |||
@@ -750,7 +750,7 @@ channel_key_store (struct Plugin *plugin, | |||
750 | 750 | ||
751 | static int | 751 | static int |
752 | slave_key_store (struct Plugin *plugin, | 752 | slave_key_store (struct Plugin *plugin, |
753 | const struct GNUNET_CRYPTO_EddsaPublicKey *slave_key) | 753 | const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key) |
754 | { | 754 | { |
755 | sqlite3_stmt *stmt = plugin->insert_slave_key; | 755 | sqlite3_stmt *stmt = plugin->insert_slave_key; |
756 | 756 | ||
@@ -789,7 +789,7 @@ slave_key_store (struct Plugin *plugin, | |||
789 | static int | 789 | static int |
790 | membership_store (void *cls, | 790 | membership_store (void *cls, |
791 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, | 791 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, |
792 | const struct GNUNET_CRYPTO_EddsaPublicKey *slave_key, | 792 | const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key, |
793 | int did_join, | 793 | int did_join, |
794 | uint64_t announced_at, | 794 | uint64_t announced_at, |
795 | uint64_t effective_since, | 795 | uint64_t effective_since, |
@@ -851,7 +851,7 @@ membership_store (void *cls, | |||
851 | static int | 851 | static int |
852 | membership_test (void *cls, | 852 | membership_test (void *cls, |
853 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, | 853 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, |
854 | const struct GNUNET_CRYPTO_EddsaPublicKey *slave_key, | 854 | const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key, |
855 | uint64_t message_id) | 855 | uint64_t message_id) |
856 | { | 856 | { |
857 | struct Plugin *plugin = cls; | 857 | struct Plugin *plugin = cls; |
diff --git a/src/psycstore/psycstore.h b/src/psycstore/psycstore.h index 16d898a45..1d586990f 100644 --- a/src/psycstore/psycstore.h +++ b/src/psycstore/psycstore.h | |||
@@ -175,7 +175,7 @@ struct MembershipStoreRequest | |||
175 | /** | 175 | /** |
176 | * Slave's public key. | 176 | * Slave's public key. |
177 | */ | 177 | */ |
178 | struct GNUNET_CRYPTO_EddsaPublicKey slave_key; | 178 | struct GNUNET_CRYPTO_EcdsaPublicKey slave_key; |
179 | 179 | ||
180 | uint64_t announced_at GNUNET_PACKED; | 180 | uint64_t announced_at GNUNET_PACKED; |
181 | uint64_t effective_since GNUNET_PACKED; | 181 | uint64_t effective_since GNUNET_PACKED; |
@@ -207,7 +207,7 @@ struct MembershipTestRequest | |||
207 | /** | 207 | /** |
208 | * Slave's public key. | 208 | * Slave's public key. |
209 | */ | 209 | */ |
210 | struct GNUNET_CRYPTO_EddsaPublicKey slave_key; | 210 | struct GNUNET_CRYPTO_EcdsaPublicKey slave_key; |
211 | 211 | ||
212 | uint64_t message_id GNUNET_PACKED; | 212 | uint64_t message_id GNUNET_PACKED; |
213 | 213 | ||
@@ -235,7 +235,12 @@ struct FragmentStoreRequest | |||
235 | */ | 235 | */ |
236 | struct GNUNET_CRYPTO_EddsaPublicKey channel_key; | 236 | struct GNUNET_CRYPTO_EddsaPublicKey channel_key; |
237 | 237 | ||
238 | /** | ||
239 | * enum GNUNET_PSYCSTORE_MessageFlags | ||
240 | */ | ||
238 | uint32_t psycstore_flags GNUNET_PACKED; | 241 | uint32_t psycstore_flags GNUNET_PACKED; |
242 | |||
243 | /* Followed by fragment */ | ||
239 | }; | 244 | }; |
240 | 245 | ||
241 | 246 | ||
@@ -336,12 +341,14 @@ struct StateHashUpdateRequest | |||
336 | struct GNUNET_HashCode hash; | 341 | struct GNUNET_HashCode hash; |
337 | }; | 342 | }; |
338 | 343 | ||
344 | |||
339 | enum StateOpFlags | 345 | enum StateOpFlags |
340 | { | 346 | { |
341 | STATE_OP_FIRST = 1 << 0, | 347 | STATE_OP_FIRST = 1 << 0, |
342 | STATE_OP_LAST = 1 << 1 | 348 | STATE_OP_LAST = 1 << 1 |
343 | }; | 349 | }; |
344 | 350 | ||
351 | |||
345 | /** | 352 | /** |
346 | * @see GNUNET_PSYCSTORE_state_modify() | 353 | * @see GNUNET_PSYCSTORE_state_modify() |
347 | */ | 354 | */ |
diff --git a/src/psycstore/psycstore_api.c b/src/psycstore/psycstore_api.c index a5fdea10b..38580b013 100644 --- a/src/psycstore/psycstore_api.c +++ b/src/psycstore/psycstore_api.c | |||
@@ -656,7 +656,7 @@ GNUNET_PSYCSTORE_operation_cancel (struct GNUNET_PSYCSTORE_OperationHandle *op) | |||
656 | struct GNUNET_PSYCSTORE_OperationHandle * | 656 | struct GNUNET_PSYCSTORE_OperationHandle * |
657 | GNUNET_PSYCSTORE_membership_store (struct GNUNET_PSYCSTORE_Handle *h, | 657 | GNUNET_PSYCSTORE_membership_store (struct GNUNET_PSYCSTORE_Handle *h, |
658 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, | 658 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, |
659 | const struct GNUNET_CRYPTO_EddsaPublicKey *slave_key, | 659 | const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key, |
660 | int did_join, | 660 | int did_join, |
661 | uint64_t announced_at, | 661 | uint64_t announced_at, |
662 | uint64_t effective_since, | 662 | uint64_t effective_since, |
@@ -722,7 +722,7 @@ GNUNET_PSYCSTORE_membership_store (struct GNUNET_PSYCSTORE_Handle *h, | |||
722 | struct GNUNET_PSYCSTORE_OperationHandle * | 722 | struct GNUNET_PSYCSTORE_OperationHandle * |
723 | GNUNET_PSYCSTORE_membership_test (struct GNUNET_PSYCSTORE_Handle *h, | 723 | GNUNET_PSYCSTORE_membership_test (struct GNUNET_PSYCSTORE_Handle *h, |
724 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, | 724 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, |
725 | const struct GNUNET_CRYPTO_EddsaPublicKey *slave_key, | 725 | const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key, |
726 | uint64_t message_id, | 726 | uint64_t message_id, |
727 | uint64_t group_generation, | 727 | uint64_t group_generation, |
728 | GNUNET_PSYCSTORE_ResultCallback rcb, | 728 | GNUNET_PSYCSTORE_ResultCallback rcb, |
@@ -770,12 +770,12 @@ GNUNET_PSYCSTORE_membership_test (struct GNUNET_PSYCSTORE_Handle *h, | |||
770 | struct GNUNET_PSYCSTORE_OperationHandle * | 770 | struct GNUNET_PSYCSTORE_OperationHandle * |
771 | GNUNET_PSYCSTORE_fragment_store (struct GNUNET_PSYCSTORE_Handle *h, | 771 | GNUNET_PSYCSTORE_fragment_store (struct GNUNET_PSYCSTORE_Handle *h, |
772 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, | 772 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, |
773 | const struct GNUNET_MULTICAST_MessageHeader *message, | 773 | const struct GNUNET_MULTICAST_MessageHeader *msg, |
774 | uint32_t psycstore_flags, | 774 | enum GNUNET_PSYCSTORE_MessageFlags psycstore_flags, |
775 | GNUNET_PSYCSTORE_ResultCallback rcb, | 775 | GNUNET_PSYCSTORE_ResultCallback rcb, |
776 | void *rcb_cls) | 776 | void *rcb_cls) |
777 | { | 777 | { |
778 | uint16_t size = ntohs (message->header.size); | 778 | uint16_t size = ntohs (msg->header.size); |
779 | struct FragmentStoreRequest *req; | 779 | struct FragmentStoreRequest *req; |
780 | struct GNUNET_PSYCSTORE_OperationHandle *op | 780 | struct GNUNET_PSYCSTORE_OperationHandle *op |
781 | = GNUNET_malloc (sizeof (*op) + sizeof (*req) + size); | 781 | = GNUNET_malloc (sizeof (*op) + sizeof (*req) + size); |
@@ -789,7 +789,7 @@ GNUNET_PSYCSTORE_fragment_store (struct GNUNET_PSYCSTORE_Handle *h, | |||
789 | req->header.size = htons (sizeof (*req) + size); | 789 | req->header.size = htons (sizeof (*req) + size); |
790 | req->channel_key = *channel_key; | 790 | req->channel_key = *channel_key; |
791 | req->psycstore_flags = htonl (psycstore_flags); | 791 | req->psycstore_flags = htonl (psycstore_flags); |
792 | memcpy (&req[1], message, size); | 792 | memcpy (&req[1], msg, size); |
793 | 793 | ||
794 | op->op_id = get_next_op_id (h); | 794 | op->op_id = get_next_op_id (h); |
795 | req->op_id = htonl (op->op_id); | 795 | req->op_id = htonl (op->op_id); |