aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorGabor X Toth <*@tg-x.net>2013-09-03 22:33:21 +0000
committerGabor X Toth <*@tg-x.net>2013-09-03 22:33:21 +0000
commiteb9556bf2983ca19a5cbcf7cf460a0b2509b290a (patch)
tree285d31e951f7ecf9308b22257adcadd5b07d80ea /src/include
parent37bafa60a6f0e447cb5b61547404f0902fa7ad41 (diff)
PSYCstore SQLite backend; API fixes/enhancements
Diffstat (limited to 'src/include')
-rw-r--r--src/include/gnunet_multicast_service.h86
-rw-r--r--src/include/gnunet_protocols.h2
-rw-r--r--src/include/gnunet_psyc_service.h47
-rw-r--r--src/include/gnunet_psycstore_plugin.h120
-rw-r--r--src/include/gnunet_psycstore_service.h78
-rw-r--r--src/include/gnunet_social_service.h63
6 files changed, 248 insertions, 148 deletions
diff --git a/src/include/gnunet_multicast_service.h b/src/include/gnunet_multicast_service.h
index e1dec7b85e..1c23af2f04 100644
--- a/src/include/gnunet_multicast_service.h
+++ b/src/include/gnunet_multicast_service.h
@@ -101,7 +101,7 @@ struct GNUNET_MULTICAST_MessageHeader
* unicast requests from members. Updated at each hop and thus not signed and
* not secure.
*/
- uint32_t hop_counter GNUNET_PACKED;
+ uint32_t hop_counter;
/**
* ECC signature of the message fragment.
@@ -118,19 +118,19 @@ struct GNUNET_MULTICAST_MessageHeader
/**
* Number of the message fragment, monotonically increasing.
*/
- uint64_t fragment_id GNUNET_PACKED;
+ uint64_t fragment_id;
/**
* Byte offset of this @e fragment of the @e message.
*/
- uint64_t fragment_offset GNUNET_PACKED;
+ uint64_t fragment_offset;
/**
* Number of the message this fragment belongs to.
*
* Set in GNUNET_MULTICAST_origin_to_all().
*/
- uint64_t message_id GNUNET_PACKED;
+ uint64_t message_id;
/**
* Counter that monotonically increases whenever a member parts the group.
@@ -142,15 +142,15 @@ struct GNUNET_MULTICAST_MessageHeader
* is still the same before and after the missed messages, it means that no
* @e join or @e part operations happened during the missed messages.
*/
- uint64_t group_generation GNUNET_PACKED;
+ uint64_t group_generation;
/**
* Flags for this message fragment.
*/
- enum GNUNET_MULTICAST_MessageFlags flags GNUNET_PACKED;
+ uint32_t flags;
/* Followed by message body. */
-};
+} GNUNET_PACKED;
GNUNET_NETWORK_STRUCT_END
@@ -309,7 +309,7 @@ struct GNUNET_MULTICAST_ReplayHandle;
/**
* Functions with this signature are called whenever the multicast service needs
- * a message to be replayed.
+ * a message fragemnt to be replayed by fragment_id.
*
* Implementations of this function MUST call GNUNET_MULTICAST_replay() ONCE
* (with a message or an error); however, if the origin is destroyed or the
@@ -331,7 +331,7 @@ typedef void
/**
* Functions with this signature are called whenever the multicast service needs
- * a message to be replayed.
+ * a message fragment to be replayed by message_id and fragment_offset.
*
* Implementations of this function MUST call GNUNET_MULTICAST_replay() ONCE
* (with a message or an error); however, if the origin is destroyed or the
@@ -404,9 +404,9 @@ enum GNUNET_MULTICAST_ReplayErrorCode
* @param ec Error code.
*/
void
-GNUNET_MULTICAST_replay (struct GNUNET_MULTICAST_ReplayHandle *rh,
- const struct GNUNET_MessageHeader *msg,
- enum GNUNET_MULTICAST_ReplayErrorCode ec);
+GNUNET_MULTICAST_replay_response (struct GNUNET_MULTICAST_ReplayHandle *rh,
+ const struct GNUNET_MessageHeader *msg,
+ enum GNUNET_MULTICAST_ReplayErrorCode ec);
/**
@@ -417,7 +417,7 @@ GNUNET_MULTICAST_replay (struct GNUNET_MULTICAST_ReplayHandle *rh,
* @param rh Replay session to end.
*/
void
-GNUNET_MULTICAST_replay_end (struct GNUNET_MULTICAST_ReplayHandle *rh);
+GNUNET_MULTICAST_replay_response_end (struct GNUNET_MULTICAST_ReplayHandle *rh);
/**
@@ -426,9 +426,9 @@ GNUNET_MULTICAST_replay_end (struct GNUNET_MULTICAST_ReplayHandle *rh);
* @see GNUNET_MULTICAST_replay2()
*/
typedef int
-(*GNUNET_MULTICAST_ReplayTransmitNotify)(void *cls,
- size_t *data_size,
- void *data);
+(*GNUNET_MULTICAST_ReplayTransmitNotify) (void *cls,
+ size_t *data_size,
+ void *data);
/**
@@ -439,9 +439,9 @@ typedef int
* @param notify_cls Closure for @a notify.
*/
void
-GNUNET_MULTICAST_replay2 (struct GNUNET_MULTICAST_ReplayHandle *rh,
- GNUNET_MULTICAST_ReplayTransmitNotify notify,
- void *notify_cls);
+GNUNET_MULTICAST_replay_response2 (struct GNUNET_MULTICAST_ReplayHandle *rh,
+ GNUNET_MULTICAST_ReplayTransmitNotify notify,
+ void *notify_cls);
/**
@@ -465,7 +465,8 @@ GNUNET_MULTICAST_replay2 (struct GNUNET_MULTICAST_ReplayHandle *rh,
* when restarting the origin. 0 for a new group.
* @param join_cb Function called to approve / disapprove joining of a peer.
* @param test_cb Function multicast can use to test group membership.
- * @param replay_cb Function that can be called to replay a message.
+ * @param replay_frag_cb Function that can be called to replay a message fragment.
+ * @param replay_msg_cb Function that can be called to replay a message.
* @param request_cb Function called with message fragments from group members.
* @param message_cb Function called with the message fragments sent to the
* network by GNUNET_MULTICAST_origin_to_all(). These message fragments
@@ -486,12 +487,13 @@ GNUNET_MULTICAST_origin_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
void *cls);
/**
- * Function called to provide data for a transmission from the origin to all members.
+ * Function called to provide data for a transmission from the origin to all
+ * members.
*/
typedef int
-(*GNUNET_MULTICAST_OriginTransmitNotify)(void *cls,
- size_t *data_size,
- void *data);
+(*GNUNET_MULTICAST_OriginTransmitNotify) (void *cls,
+ size_t *data_size,
+ void *data);
/**
@@ -568,15 +570,13 @@ GNUNET_MULTICAST_origin_stop (struct GNUNET_MULTICAST_Origin *origin);
* @a relay (might, for example, contain a user, bind user
* identity/pseudonym to peer identity, application-level message to
* origin, etc.).
- * @param max_known_fragment_id Largest known message fragment ID to the replay
- * service; all messages with IDs larger than this ID will be replayed if
- * possible (lower IDs will be considered known and thus only
- * be replayed upon explicit request).
- * FIXME: needed? can be optional or moved to a separate function.
* @param join_cb Function called to approve / disapprove joining of a peer.
* @param test_cb Function multicast can use to test group membership.
- * @param replay_cb Function that can be called to replay messages
- * this peer already knows from this group; NULL if this
+ * @param replay_frag_cb Function that can be called to replay message fragments
+ * this peer already knows from this group. NULL if this
+ * client is unable to support replay.
+ * @param replay_msg_cb Function that can be called to replay message fragments
+ * this peer already knows from this group. NULL if this
* client is unable to support replay.
* @param message_cb Function to be called for all message fragments we
* receive from the group, excluding those our @a replay_cb
@@ -597,8 +597,8 @@ GNUNET_MULTICAST_member_join (const struct GNUNET_CONFIGURATION_Handle *cfg,
GNUNET_MULTICAST_ReplayFragmentCallback replay_frag_cb,
GNUNET_MULTICAST_ReplayMessageCallback replay_msg_cb,
GNUNET_MULTICAST_MessageCallback message_cb,
- void *cls);
-
+ void *cls)
+;
/**
* Handle for a replay request.
@@ -633,16 +633,10 @@ GNUNET_MULTICAST_member_replay_fragment (struct GNUNET_MULTICAST_Member *member,
* needed and not known to the client.
*
* @param member Membership handle.
- * @param fragment_id ID of a message fragment that this client would like to
- see replayed.
- * @param message_id ID of a message that this client would like to see
- * replayed. Typically only one of the @a fragment_id and @a message_id
- * is given. Specifying a @a message_id would return the last fragment
- * of the message, which allows requesting the preceding fragments of the
- * message by looking at the @e fragment_delta header field.
+ * @param message_id ID of the message this client would like to see replayed.
+ * @param fragment_offset Offset of the fragment within the message to replay.
* @param flags Additional flags for the replay request. It is used & defined
- * by the replay callback. E.g. the PSYC service would use this to
- * implement state synchronization.
+ * by the replay callback.
* @param result_cb Function to be called for the replayed message.
* @param result_cb_cls Closure for @a message_cb.
* @return Replay request handle, NULL on error.
@@ -679,7 +673,7 @@ void
GNUNET_MULTICAST_member_part (struct GNUNET_MULTICAST_Member *member);
-/**
+/**
* Function called to provide data for a transmission from a member to the origin.
*
* @param cls closure
@@ -688,9 +682,9 @@ GNUNET_MULTICAST_member_part (struct GNUNET_MULTICAST_Member *member);
* @return number of bytes copied to data
*/
typedef int
-(*GNUNET_MULTICAST_MemberTransmitNotify)(void *cls,
- size_t *data_size,
- void *data);
+(*GNUNET_MULTICAST_MemberTransmitNotify) (void *cls,
+ size_t *data_size,
+ void *data);
/**
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h
index f7e65536b8..1b231296fc 100644
--- a/src/include/gnunet_protocols.h
+++ b/src/include/gnunet_protocols.h
@@ -1997,7 +1997,7 @@ extern "C"
/**
* Multicast message from the origin to all members.
*/
-#define GNUNET_MESSAGE_TYPE_MULTICAST_MESSAGE
+#define GNUNET_MESSAGE_TYPE_MULTICAST_MESSAGE 700
/**
* A unicast message from a group member to the origin.
diff --git a/src/include/gnunet_psyc_service.h b/src/include/gnunet_psyc_service.h
index 8e43b387e8..df7a6b4d9f 100644
--- a/src/include/gnunet_psyc_service.h
+++ b/src/include/gnunet_psyc_service.h
@@ -208,9 +208,9 @@ struct GNUNET_PSYC_JoinHandle;
* @param modifier_count Number of elements in the @a modifiers array.
* @param modifiers State modifiers and transient variables for the message.
* @param data_offset Byte offset of @a data in the overall data of the method.
- * @param data_size Number of bytes in @a data.
* @param data Data stream given to the method (might not be zero-terminated
* if data is binary).
+ * @param data_size Number of bytes in @a data.
* @param frag Fragmentation status for the data.
*/
typedef int
@@ -221,8 +221,8 @@ typedef int
size_t modifier_count,
const struct GNUNET_ENV_Modifier *modifiers,
uint64_t data_offset,
- size_t data_size,
const void *data,
+ size_t data_size,
enum GNUNET_PSYC_MessageFlags flags);
@@ -234,9 +234,10 @@ typedef int
* @param method_name Method name in the join request.
* @param variable_count Number of elements in the @a variables array.
* @param variables Transient variables for the join request.
- * @param data_size Number of bytes in @a data.
* @param data Data stream given to the method (might not be zero-terminated
* if data is binary).
+ * @param data_size Number of bytes in @a data.
+ * @param jh Join handle to use with GNUNET_PSYC_join_decision()
*/
typedef int
(*GNUNET_PSYC_JoinCallback) (void *cls,
@@ -244,8 +245,8 @@ typedef int
const char *method_name,
size_t variable_count,
const struct GNUNET_ENV_Modifier *variables,
- size_t data_size,
const void *data,
+ size_t data_size,
struct GNUNET_PSYC_JoinHandle *jh);
@@ -268,8 +269,8 @@ typedef int
* peer identity in this array.
* @param method_name Method name for the message transmitted with the response.
* @param env Environment containing transient variables for the message, or NULL.
- * @param data_size Size of @a data.
* @param data Data of the message.
+ * @param data_size Size of @a data.
*/
void
GNUNET_PSYC_join_decision (struct GNUNET_PSYC_JoinHandle *jh,
@@ -278,8 +279,8 @@ GNUNET_PSYC_join_decision (struct GNUNET_PSYC_JoinHandle *jh,
const struct GNUNET_PeerIdentity *relays,
const char *method_name,
const struct GNUNET_ENV_Environment *env,
- size_t data_size,
- const void *data);
+ const void *data,
+ size_t data_size);
/**
@@ -333,21 +334,20 @@ GNUNET_PSYC_master_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
* @param cls Closure.
* @param message_id Set to the unique message ID that was generated for
* this message.
- * @param[in,out] data_size Initially set to the number of bytes available in @a data,
- * should be set to the number of bytes written to data (IN/OUT).
- * @param[out] data Where to write the body of the message to give to the method;
- * function must copy at most @a *data_size bytes to @a data.
+ * @param[in,out] data_size Initially set to the number of bytes available in
+ * @a data, should be set to the number of bytes written to data.
+ * @param[out] data Where to write the body of the message to give to the
+ * method. The function must copy at most @a data_size bytes to @a data.
* @return #GNUNET_SYSERR on error (fatal, aborts transmission)
* #GNUNET_NO on success, if more data is to be transmitted later
- * (should be used if @a *data_size was not big enough to take all the data)
+ * (should be used if @a data_size was not big enough to take all the data)
* #GNUNET_YES if this completes the transmission (all data supplied)
*/
typedef int
-(*GNUNET_PSYC_MasterTransmitNotify)(void *cls,
- uint64_t message_id,
- size_t *data_size,
- void *data);
-
+(*GNUNET_PSYC_MasterTransmitNotify) (void *cls,
+ uint64_t message_id,
+ size_t *data_size,
+ void *data);
/**
@@ -450,8 +450,8 @@ struct GNUNET_PSYC_Slave;
* @param cls Closure for @a method_cb and @a join_cb.
* @param method_name Method name for the join request.
* @param env Environment containing transient variables for the request, or NULL.
- * @param data_size Number of bytes in @a data.
* @param data Payload for the join message.
+ * @param data_size Number of bytes in @a data.
* @return Handle for the slave, NULL on error.
*/
struct GNUNET_PSYC_Slave *
@@ -466,8 +466,8 @@ GNUNET_PSYC_slave_join (const struct GNUNET_CONFIGURATION_Handle *cfg,
void *cls,
const char *method_name,
const struct GNUNET_ENV_Environment *env,
- size_t data_size,
- const void *data);
+ const void *data,
+ size_t data_size);
/**
@@ -618,7 +618,6 @@ GNUNET_PSYC_channel_slave_add (struct GNUNET_PSYC_Channel *channel,
* @param channel Channel handle.
* @param slave_key Identity of channel slave to remove.
* @param announced_at ID of the message that announced the membership change.
- * @param effective_since Removal of slave is in effect since this message ID.
*/
void
GNUNET_PSYC_channel_slave_remove (struct GNUNET_PSYC_Channel *channel,
@@ -632,14 +631,14 @@ GNUNET_PSYC_channel_slave_remove (struct GNUNET_PSYC_Channel *channel,
* @param cls Closure.
* @param name Name of the state variable. A NULL value indicates that there
* are no more state variables to be returned.
- * @param value_size Number of bytes in @a value.
* @param value Value of the state variable.
+ * @param value_size Number of bytes in @a value.
*/
typedef void
(*GNUNET_PSYC_StateCallback) (void *cls,
const char *name,
- size_t value_size,
- const void *value);
+ const void *value,
+ size_t value_size);
/**
diff --git a/src/include/gnunet_psycstore_plugin.h b/src/include/gnunet_psycstore_plugin.h
index e567de2786..69d4bf7fc3 100644
--- a/src/include/gnunet_psycstore_plugin.h
+++ b/src/include/gnunet_psycstore_plugin.h
@@ -40,7 +40,7 @@ extern "C"
/**
- * @brief struct returned by the initialization function of the plugin
+ * Struct returned by the initialization function of the plugin.
*/
struct GNUNET_PSYCSTORE_PluginFunctions
{
@@ -59,9 +59,9 @@ struct GNUNET_PSYCSTORE_PluginFunctions
* @return #GNUNET_OK on success, else #GNUNET_SYSERR
*/
int
- (*membership_store) (void *cls,
- const struct GNUNET_HashCode *channel_key,
- const struct GNUNET_HashCode *slave_key,
+ (*membership_store) (void *cls,
+ const struct GNUNET_CRYPTO_EccPublicKey *channel_key,
+ const struct GNUNET_CRYPTO_EccPublicKey *slave_key,
int did_join,
uint64_t announced_at,
uint64_t effective_since,
@@ -71,7 +71,7 @@ struct GNUNET_PSYCSTORE_PluginFunctions
* Test if a member was admitted to the channel at the given message ID.
*
* @see GNUNET_PSYCSTORE_membership_test()
- *
+ *
* @return #GNUNET_YES if the member was admitted, #GNUNET_NO if not,
* #GNUNET_SYSERR if there was en error.
*/
@@ -79,41 +79,42 @@ struct GNUNET_PSYCSTORE_PluginFunctions
(*membership_test) (void *cls,
const struct GNUNET_CRYPTO_EccPublicKey *channel_key,
const struct GNUNET_CRYPTO_EccPublicKey *slave_key,
- uint64_t message_id,
- uint64_t group_generation);
+ uint64_t message_id);
/**
* Store a message fragment sent to a channel.
*
* @see GNUNET_PSYCSTORE_fragment_store()
- *
+ *
* @return #GNUNET_OK on success, else #GNUNET_SYSERR
*/
int
(*fragment_store) (void *cls,
const struct GNUNET_CRYPTO_EccPublicKey *channel_key,
- const struct GNUNET_MULTICAST_MessageHeader *message);
+ const struct GNUNET_MULTICAST_MessageHeader *message,
+ uint32_t psycstore_flags);
/**
* Set additional flags for a given message.
*
+ * They are OR'd with any existing flags set.
+ *
* @param message_id ID of the message.
- * @param flags Flags to add.
- *
+ * @param psycstore_flags OR'd GNUNET_PSYCSTORE_MessageFlags.
+ *
* @return #GNUNET_OK on success, else #GNUNET_SYSERR
*/
int
- (*fragment_add_flags) (void *cls,
- const struct GNUNET_CRYPTO_EccPublicKey *channel_key,
- uint64_t message_id,
- uint64_t multicast_flags,
- uint64_t psyc_flags);
+ (*message_add_flags) (void *cls,
+ const struct GNUNET_CRYPTO_EccPublicKey *channel_key,
+ uint64_t message_id,
+ uint64_t psycstore_flags);
/**
* Retrieve a message fragment by fragment ID.
*
* @see GNUNET_PSYCSTORE_fragment_get()
- *
+ *
* @return #GNUNET_OK on success, else #GNUNET_SYSERR
*/
int
@@ -127,7 +128,7 @@ struct GNUNET_PSYCSTORE_PluginFunctions
* Retrieve all fragments of a message.
*
* @see GNUNET_PSYCSTORE_message_get()
- *
+ *
* @return #GNUNET_OK on success, else #GNUNET_SYSERR
*/
int
@@ -142,7 +143,7 @@ struct GNUNET_PSYCSTORE_PluginFunctions
* offset.
*
* @see GNUNET_PSYCSTORE_message_get_fragment()
- *
+ *
* @return #GNUNET_OK on success, else #GNUNET_SYSERR
*/
int
@@ -157,7 +158,7 @@ struct GNUNET_PSYCSTORE_PluginFunctions
* Retrieve latest values of counters for a channel master.
*
* @see GNUNET_PSYCSTORE_counters_get_master()
- *
+ *
* @return #GNUNET_OK on success, else #GNUNET_SYSERR
*/
int
@@ -168,10 +169,10 @@ struct GNUNET_PSYCSTORE_PluginFunctions
uint64_t *group_generation);
/**
- * Retrieve latest values of counters for a channel slave.
+ * Retrieve latest values of counters for a channel slave.
*
* @see GNUNET_PSYCSTORE_counters_get_slave()
- *
+ *
* @return #GNUNET_OK on success, else #GNUNET_SYSERR
*/
int
@@ -183,27 +184,66 @@ struct GNUNET_PSYCSTORE_PluginFunctions
* Set a state variable to the given value.
*
* @see GNUNET_PSYCSTORE_state_modify()
- *
+ *
* @return #GNUNET_OK on success, else #GNUNET_SYSERR
*/
int
- (*state_set) (struct GNUNET_PSYCSTORE_Handle *h,
+ (*state_set) (void *cls,
const struct GNUNET_CRYPTO_EccPublicKey *channel_key,
const char *name,
- size_t value_size,
- const void *value);
+ const void *value,
+ size_t value_size);
+
+
+ /**
+ * Reset the state of a channel.
+ *
+ * Delete all state variables stored for the given channel.
+ *
+ * @see GNUNET_PSYCSTORE_state_reset()
+ *
+ * @return #GNUNET_OK on success, else #GNUNET_SYSERR
+ */
+ int
+ (*state_reset) (void *cls,
+ const struct GNUNET_CRYPTO_EccPublicKey *channel_key);
+
+ /**
+ * Update signed state values from the current ones.
+ *
+ * Sets value_signed = value_current for each variable for the given channel.
+ */
+ int
+ (*state_update_signed) (void *cls,
+ const struct GNUNET_CRYPTO_EccPublicKey *channel_key);
+
+ /**
+ * Update signed values of state variables in the state store.
+ *
+ * @param h Handle for the PSYCstore.
+ * @param channel_key The channel we are interested in.
+ * @param message_id Message ID that contained the state @a hash.
+ * @param hash Hash of the serialized full state.
+ * @param rcb Callback to call with the result of the operation.
+ * @param rcb_cls Closure for the callback.
+ *
+ * @return #GNUNET_OK on success, else #GNUNET_SYSERR
+ */
+ int
+ (*state_hash_update) (void *cls,
+ const struct GNUNET_CRYPTO_EccPublicKey *channel_key,
+ uint64_t message_id,
+ const struct GNUNET_HashCode *hash,
+ GNUNET_PSYCSTORE_ResultCallback rcb,
+ void *rcb_cls);
/**
- * Retrieve a state variable by name.
+ * Retrieve a state variable by name (exact match).
*
- * @param name Name of the variable to retrieve.
- * @param[out] value_size Size of value.
- * @param[out] value Returned value.
- *
* @return #GNUNET_OK on success, else #GNUNET_SYSERR
*/
int
- (*state_get) (struct GNUNET_PSYCSTORE_Handle *h,
+ (*state_get) (void *cls,
const struct GNUNET_CRYPTO_EccPublicKey *channel_key,
const char *name,
GNUNET_PSYCSTORE_StateCallback cb,
@@ -213,16 +253,28 @@ struct GNUNET_PSYCSTORE_PluginFunctions
* Retrieve all state variables for a channel with the given prefix.
*
* @see GNUNET_PSYCSTORE_state_get_all()
- *
+ *
* @return #GNUNET_OK on success, else #GNUNET_SYSERR
*/
int
- (*state_get_all) (struct GNUNET_PSYCSTORE_Handle *h,
+ (*state_get_all) (void *cls,
const struct GNUNET_CRYPTO_EccPublicKey *channel_key,
const char *name,
GNUNET_PSYCSTORE_StateCallback cb,
void *cb_cls);
+
+ /**
+ * Retrieve all signed state variables for a channel.
+ *
+ * @return #GNUNET_OK on success, else #GNUNET_SYSERR
+ */
+ int
+ (*state_get_signed) (void *cls,
+ const struct GNUNET_CRYPTO_EccPublicKey *channel_key,
+ GNUNET_PSYCSTORE_StateCallback cb,
+ void *cb_cls);
+
};
diff --git a/src/include/gnunet_psycstore_service.h b/src/include/gnunet_psycstore_service.h
index bbf5a7d196..fab2594df9 100644
--- a/src/include/gnunet_psycstore_service.h
+++ b/src/include/gnunet_psycstore_service.h
@@ -45,6 +45,28 @@ extern "C"
*/
#define GNUNET_PSYCSTORE_VERSION 0x00000000
+/**
+ * Flags for stored messages.
+ */
+enum GNUNET_PSYCSTORE_MessageFlags
+{
+ /**
+ * The message contains state modifiers.
+ */
+ GNUNET_PSYCSTORE_MESSAGE_STATE = 1 << 0,
+
+ /**
+ * The state modifiers have been applied to the state store.
+ */
+ GNUNET_PSYCSTORE_MESSAGE_STATE_APPLIED = 1 << 1,
+
+ /**
+ * The message contains a state hash.
+ */
+ GNUNET_PSYCSTORE_MESSAGE_STATE_HASH = 1 << 2
+};
+
+
/**
* Handle for a PSYCstore
*/
@@ -157,6 +179,8 @@ GNUNET_PSYCSTORE_membership_test (struct GNUNET_PSYCSTORE_Handle *h,
* @param h Handle for the PSYCstore.
* @param channel_key The channel the message belongs to.
* @param message Message to store.
+ * @param psycstore_flags Flags indicating whether the PSYC message contains
+ * state modifiers.
* @param rcb Callback to call with the result of the operation.
* @param rcb_cls Closure for the callback.
*
@@ -166,6 +190,7 @@ struct GNUNET_PSYCSTORE_OperationHandle *
GNUNET_PSYCSTORE_fragment_store (struct GNUNET_PSYCSTORE_Handle *h,
const struct GNUNET_CRYPTO_EccPublicKey *channel_key,
const struct GNUNET_MULTICAST_MessageHeader *message,
+ uint32_t psycstore_flags,
GNUNET_PSYCSTORE_ResultCallback rcb,
void *rcb_cls);
@@ -177,12 +202,15 @@ GNUNET_PSYCSTORE_fragment_store (struct GNUNET_PSYCSTORE_Handle *h,
* @param cls Closure.
* @param message The retrieved message fragment. A NULL value indicates that
* there are no more results to be returned.
- * @param flags Message flags indicating fragmentation status.
+ * @param flags Flags stored with the message.
+ *
+ * @return #GNUNET_NO to stop calling this callback with further fragments,
+ * #GNUNET_YES to continue.
*/
-typedef void
+typedef int
(*GNUNET_PSYCSTORE_FragmentCallback) (void *cls,
- const struct GNUNET_MULTICAST_MessageHeader *message,
- enum GNUNET_PSYC_MessageFlags flags);
+ struct GNUNET_MULTICAST_MessageHeader *message,
+ enum GNUNET_PSYCSTORE_MessageFlags flags);
/**
@@ -224,7 +252,8 @@ GNUNET_PSYCSTORE_message_get (struct GNUNET_PSYCSTORE_Handle *h,
/**
- * Retrieve a fragment of message specified by its message ID and fragment offset.
+ * Retrieve a fragment of message specified by its message ID and fragment
+ * offset.
*
* @param h Handle for the PSYCstore.
* @param channel_key The channel we are interested in.
@@ -267,7 +296,8 @@ typedef void
* @see GNUNET_PSYCSTORE_counters_get_slave()
*
* @param cls Closure.
- * @param max_state_msg_id Latest message ID containing state modifiers that was applied to the state store. Used for the state sync process.
+ * @param max_state_msg_id Latest message ID containing state modifiers that was
+ * applied to the state store. Used for the state sync process.
*/
typedef void
(*GNUNET_PSYCSTORE_SlaveCountersCallback) (void *cls,
@@ -343,6 +373,26 @@ GNUNET_PSYCSTORE_state_modify (struct GNUNET_PSYCSTORE_Handle *h,
/**
+ * Reset the state of a channel.
+ *
+ * Delete all state variables stored for the given channel.
+ *
+ * @param h Handle for the PSYCstore.
+ * @param channel_key The channel we are interested in.
+ * @param rcb Callback to call with the result of the operation.
+ * @param rcb_cls Closure for the callback.
+ *
+ * @return Handle that can be used to cancel the operation.
+ */
+struct GNUNET_PSYCSTORE_Handle *
+GNUNET_PSYCSTORE_state_reset (struct GNUNET_PSYCSTORE_Handle *h,
+ const struct GNUNET_CRYPTO_EccPublicKey
+ *channel_key,
+ GNUNET_PSYCSTORE_ResultCallback rcb,
+ void *rcb_cls);
+
+
+/**
* Update signed values of state variables in the state store.
*
* @param h Handle for the PSYCstore.
@@ -368,15 +418,17 @@ GNUNET_PSYCSTORE_state_hash_update (struct GNUNET_PSYCSTORE_Handle *h,
* @param cls Closure.
* @param name Name of the state variable. A NULL value indicates that there are no more
* state variables to be returned.
- * @param value_size Number of bytes in @a value.
* @param value Value of the state variable.
-t *
+ * @param value_size Number of bytes in @a value.
+ *
+ * @return #GNUNET_NO to stop calling this callback with further variables,
+ * #GNUNET_YES to continue.
*/
-typedef void
+typedef int
(*GNUNET_PSYCSTORE_StateCallback) (void *cls,
const char *name,
- size_t value_size,
- const void *value);
+ const void *value,
+ size_t value_size);
/**
@@ -420,10 +472,10 @@ GNUNET_PSYCSTORE_state_get_all (struct GNUNET_PSYCSTORE_Handle *h,
/**
* Cancel an operation.
*
- * @param oh Handle for the operation to cancel.
+ * @param op Handle for the operation to cancel.
*/
void
-GNUNET_PSYCSTORE_operation_cancel (struct GNUNET_PSYCSTORE_OperationHandle *oh);
+GNUNET_PSYCSTORE_operation_cancel (struct GNUNET_PSYCSTORE_OperationHandle *op);
diff --git a/src/include/gnunet_social_service.h b/src/include/gnunet_social_service.h
index abb749b9b7..62a221de23 100644
--- a/src/include/gnunet_social_service.h
+++ b/src/include/gnunet_social_service.h
@@ -83,21 +83,22 @@ struct GNUNET_SOCIAL_Slicer;
* @param modifier_count Number of elements in the @a modifiers array.
* @param modifiers Modifiers present in the message. FIXME: use environment instead?
* @param data_offset Byte offset of @a data in the overall data of the method.
- * @param data_size Number of bytes in @a data.
* @param data Data stream given to the method (might not be zero-terminated
* if data is binary).
+ * @param data_size Number of bytes in @a data.
* @param flags Message flags indicating fragmentation status.
*/
-typedef int (*GNUNET_SOCIAL_Method)(void *cls,
- struct GNUNET_SOCIAL_Nym *nym,
- const char *full_method_name,
- uint64_t message_id,
- size_t modifier_count,
- GNUNET_PSYC_Modifier *modifiers,
- uint64_t data_offset,
- size_t data_size,
- const void *data,
- enum GNUNET_PSYC_MessageFlags flags);
+typedef int
+(*GNUNET_SOCIAL_Method) (void *cls,
+ struct GNUNET_SOCIAL_Nym *nym,
+ const char *full_method_name,
+ uint64_t message_id,
+ size_t modifier_count,
+ GNUNET_PSYC_Modifier *modifiers,
+ uint64_t data_offset,
+ const void *data,
+ size_t data_size,
+ enum GNUNET_PSYC_MessageFlags flags);
/**
@@ -164,16 +165,17 @@ GNUNET_SOCIAL_slicer_destroy (struct GNUNET_SOCIAL_Slicer *slicer);
* @param method_name Method name in the entry request.
* @param variable_count Number of elements in the @a variables array.
* @param variables Variables present in the message.
- * @param data_size Number of bytes in @a data.
* @param data Payload given on enter (e.g. a password).
+ * @param data_size Number of bytes in @a data.
*/
-typedef void (*GNUNET_SOCIAL_AnswerDoorCallback)(void *cls,
- struct GNUNET_SOCIAL_Nym *nym,
- size_t variable_count,
- const char *method_name,
- GNUNET_PSYC_Modifier *variables,
- size_t data_size,
- const void *data);
+typedef void
+(*GNUNET_SOCIAL_AnswerDoorCallback) (void *cls,
+ struct GNUNET_SOCIAL_Nym *nym,
+ size_t variable_count,
+ const char *method_name,
+ GNUNET_PSYC_Modifier *variables,
+ const void *data,
+ size_t data_size);
/**
@@ -187,10 +189,11 @@ typedef void (*GNUNET_SOCIAL_AnswerDoorCallback)(void *cls,
* @param variable_count Number of elements in the @a variables array.
* @param variables Variables present in the message.
*/
-typedef void (*GNUNET_SOCIAL_FarewellCallback)(void *cls,
- struct GNUNET_SOCIAL_Nym *nym,
- size_t variable_count,
- GNUNET_PSYC_Modifier *variables);
+typedef void
+(*GNUNET_SOCIAL_FarewellCallback) (void *cls,
+ struct GNUNET_SOCIAL_Nym *nym,
+ size_t variable_count,
+ GNUNET_PSYC_Modifier *variables);
/**
@@ -258,16 +261,16 @@ GNUNET_SOCIAL_home_eject (struct GNUNET_SOCIAL_Home *home,
* @param nym Handle for the entity that wanted to enter.
* @param method_name Method name for the rejection message.
* @param env Environment containing variables for the message, or NULL.
- * @param data_size Number of bytes in @a data for method.
* @param data Data for the rejection message to send back.
+ * @param data_size Number of bytes in @a data for method.
*/
void
GNUNET_SOCIAL_home_reject_entry (struct GNUNET_SOCIAL_Home *home,
struct GNUNET_SOCIAL_Nym *nym,
const char *method_name,
const struct GNUNET_ENV_Environment *env,
- size_t data_size,
- const void *data);
+ const void *data,
+ size_t data_size);
/**
@@ -403,8 +406,8 @@ GNUNET_SOCIAL_home_leave (struct GNUNET_SOCIAL_Home *home);
* pseudonym's place directly.
* @param method_name Method name for the message.
* @param env Environment containing variables for the message, or NULL.
- * @param data_size Number of bytes in @a data.
* @param data Payload for the message to give to the enter callback.
+ * @param data_size Number of bytes in @a data.
* @param slicer Slicer to use for processing incoming requests from guests.
* @return NULL on errors, otherwise handle to the place.
*/
@@ -414,8 +417,8 @@ GNUNET_SOCIAL_place_enter (const struct GNUNET_CONFIGURATION_Handle *cfg,
char *address,
const char *method_name,
const struct GNUNET_ENV_Environment *env,
- size_t data_size,
const void *data,
+ size_t data_size,
struct GNUNET_SOCIAL_Slicer *slicer);
/**
@@ -429,8 +432,8 @@ GNUNET_SOCIAL_place_enter (const struct GNUNET_CONFIGURATION_Handle *cfg,
* @param relays Relays for the underlying multicast group.
* @param method_name Method name for the message.
* @param env Environment containing variables for the message, or NULL.
- * @param data_size Number of bytes in @a data.
* @param data Payload for the message to give to the enter callback.
+ * @param data_size Number of bytes in @a data.
* @param slicer Slicer to use for processing incoming requests from guests.
* @return NULL on errors, otherwise handle to the place.
*/
@@ -443,8 +446,8 @@ GNUNET_SOCIAL_place_enter2 (const struct GNUNET_CONFIGURATION_Handle *cfg,
struct GNUNET_PeerIdentity *relays,
const char *method_name,
const struct GNUNET_ENV_Environment *env,
- size_t data_size,
const void *data,
+ size_t data_size,
struct GNUNET_SOCIAL_Slicer *slicer);