aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorGabor X Toth <*@tg-x.net>2014-07-10 17:49:53 +0000
committerGabor X Toth <*@tg-x.net>2014-07-10 17:49:53 +0000
commita8133f3ff80aaaccc904e4bbaf69bc53dee499cb (patch)
treec10edd7a8156280c61357ccf9e0f1f27c7a0d6db /src/include
parent6c75526e936fcc74ee79b13831b2b6dda57f293d (diff)
downloadgnunet-a8133f3ff80aaaccc904e4bbaf69bc53dee499cb.tar.gz
gnunet-a8133f3ff80aaaccc904e4bbaf69bc53dee499cb.zip
PSYC(store), Multicast: use ECDSA slave/member keys; PSYC: add GNUNET_PSYC_message_create()
Diffstat (limited to 'src/include')
-rw-r--r--src/include/gnunet_gnsrecord_lib.h24
-rw-r--r--src/include/gnunet_multicast_service.h14
-rw-r--r--src/include/gnunet_protocols.h24
-rw-r--r--src/include/gnunet_psyc_service.h96
-rw-r--r--src/include/gnunet_psyc_util_lib.h22
-rw-r--r--src/include/gnunet_psycstore_plugin.h4
-rw-r--r--src/include/gnunet_psycstore_service.h11
-rw-r--r--src/include/gnunet_social_service.h276
8 files changed, 344 insertions, 127 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
177GNUNET_NETWORK_STRUCT_BEGIN 176GNUNET_NETWORK_STRUCT_BEGIN
178 177
178/**
179 * Data stored in a PLACE record.
180 */
181struct 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 */
281typedef void 281typedef 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 */
345typedef void 345typedef 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 */
431typedef void 431typedef 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 */
454typedef void 454typedef 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);
712struct GNUNET_MULTICAST_Member * 712struct GNUNET_MULTICAST_Member *
713GNUNET_MULTICAST_member_join (const struct GNUNET_CONFIGURATION_Handle *cfg, 713GNUNET_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
283struct 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
302struct 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
317struct 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
282GNUNET_NETWORK_STRUCT_END 339GNUNET_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 */
358enum 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
335typedef void 409typedef 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
646struct GNUNET_PSYC_Slave * 721struct GNUNET_PSYC_Slave *
647GNUNET_PSYC_slave_join (const struct GNUNET_CONFIGURATION_Handle *cfg, 722GNUNET_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 */
776void 848void
777GNUNET_PSYC_channel_slave_add (struct GNUNET_PSYC_Channel *channel, 849GNUNET_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 */
804void 876void
805GNUNET_PSYC_channel_slave_remove (struct GNUNET_PSYC_Channel *channel, 877GNUNET_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 */
58struct GNUNET_MessageHeader *
59GNUNET_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
43void 65void
44GNUNET_PSYC_log_message (enum GNUNET_ErrorType kind, 66GNUNET_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
134struct GNUNET_PSYCSTORE_OperationHandle * 134struct GNUNET_PSYCSTORE_OperationHandle *
135GNUNET_PSYCSTORE_membership_store (struct GNUNET_PSYCSTORE_Handle *h, 135GNUNET_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,
166struct GNUNET_PSYCSTORE_OperationHandle * 167struct GNUNET_PSYCSTORE_OperationHandle *
167GNUNET_PSYCSTORE_membership_test (struct GNUNET_PSYCSTORE_Handle *h, 168GNUNET_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,
189struct GNUNET_PSYCSTORE_OperationHandle * 190struct GNUNET_PSYCSTORE_OperationHandle *
190GNUNET_PSYCSTORE_fragment_store (struct GNUNET_PSYCSTORE_Handle *h, 191GNUNET_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 */
105typedef int 113typedef 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 */
185typedef void 193typedef 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
206typedef void 213typedef 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 */
228typedef 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 */
231struct GNUNET_SOCIAL_Host * 258struct GNUNET_SOCIAL_Host *
232GNUNET_SOCIAL_host_enter (const struct GNUNET_CONFIGURATION_Handle *cfg, 259GNUNET_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 */
375struct GNUNET_SOCIAL_Announcement * 411struct GNUNET_SOCIAL_Announcement *
376GNUNET_SOCIAL_host_announce (struct GNUNET_SOCIAL_Host *host, 412GNUNET_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 */
470typedef 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 */
496typedef 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);
436struct GNUNET_SOCIAL_Guest * 522struct GNUNET_SOCIAL_Guest *
437GNUNET_SOCIAL_guest_enter (const struct GNUNET_CONFIGURATION_Handle *cfg, 523GNUNET_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 */
463struct GNUNET_SOCIAL_Guest * 557struct GNUNET_SOCIAL_Guest *
464GNUNET_SOCIAL_guest_enter2 (const struct GNUNET_CONFIGURATION_Handle *cfg, 558GNUNET_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 */
505struct GNUNET_SOCIAL_TalkRequest * 605struct GNUNET_SOCIAL_TalkRequest *
506GNUNET_SOCIAL_guest_talk (struct GNUNET_SOCIAL_Place *place, 606GNUNET_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 */
531void 631void
532GNUNET_SOCIAL_guest_leave (struct GNUNET_SOCIAL_Place *place, int keep_active); 632GNUNET_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 */
544struct GNUNET_SOCIAL_Place * 644struct GNUNET_SOCIAL_Place *
545GNUNET_SOCIAL_guest_get_place (struct GNUNET_SOCIAL_Host *guest); 645GNUNET_SOCIAL_guest_get_place (struct GNUNET_SOCIAL_Guest *guest);
546 646
547 647
548/** 648/**