aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorGabor X Toth <*@tg-x.net>2014-03-06 23:46:45 +0000
committerGabor X Toth <*@tg-x.net>2014-03-06 23:46:45 +0000
commit8a0b8a4604526e5f832c4971f9c3b1b48d79bea4 (patch)
treedfd18a61272a18381fe9ce9b09849a965480a303 /src/include
parenta21beab58c1d2abc747359a98326f19aaad4e8cd (diff)
PSYC: implement slave to master requests, tests, fixes, reorg
Multicast lib: handle member to origin requests. Keep track of members and origins and call their callbacks when necessary.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/gnunet_multicast_service.h62
-rw-r--r--src/include/gnunet_protocols.h32
-rw-r--r--src/include/gnunet_psyc_service.h92
-rw-r--r--src/include/gnunet_social_service.h6
4 files changed, 133 insertions, 59 deletions
diff --git a/src/include/gnunet_multicast_service.h b/src/include/gnunet_multicast_service.h
index 0abd803a49..aa5597fd33 100644
--- a/src/include/gnunet_multicast_service.h
+++ b/src/include/gnunet_multicast_service.h
@@ -160,8 +160,62 @@ struct GNUNET_MULTICAST_MessageHeader
/* Followed by message body. */
};
+
+/**
+ * Header of a request from a member to the origin.
+ */
+struct GNUNET_MULTICAST_RequestHeader
+{
+ /**
+ * Header for all requests from a member to the origin.
+ */
+ struct GNUNET_MessageHeader header;
+
+ /**
+ * Public key of the sending member.
+ */
+ struct GNUNET_CRYPTO_EddsaPublicKey member_key;
+
+ /**
+ * ECC signature of the request fragment.
+ *
+ * Signature must match the public key of the multicast group.
+ */
+ struct GNUNET_CRYPTO_EddsaSignature signature;
+
+ /**
+ * Purpose for the signature and size of the signed data.
+ */
+ struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
+
+ /**
+ * Number of the request fragment, monotonically increasing.
+ */
+ uint64_t fragment_id GNUNET_PACKED;
+
+ /**
+ * Byte offset of this @e fragment of the @e request.
+ */
+ uint64_t fragment_offset GNUNET_PACKED;
+
+ /**
+ * Number of the request this fragment belongs to.
+ *
+ * Set in GNUNET_MULTICAST_origin_to_all().
+ */
+ uint64_t request_id GNUNET_PACKED;
+
+ /**
+ * Flags for this request.
+ */
+ enum GNUNET_MULTICAST_MessageFlags flags GNUNET_PACKED;
+
+ /* Followed by request body. */
+};
+
GNUNET_NETWORK_STRUCT_END
+
/**
* Maximum size of a multicast message fragment.
*/
@@ -492,7 +546,7 @@ GNUNET_MULTICAST_replay_response2 (struct GNUNET_MULTICAST_ReplayHandle *rh,
* @param next_fragment_id Next fragment ID to continue counting fragments from
* when restarting the origin. 1 for a new group.
* @param join_cb Function called to approve / disapprove joining of a peer.
- * @param mem_test_cb Function multicast can use to test group membership.
+ * @param member_test_cb Function multicast can use to test group membership.
* @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.
@@ -507,7 +561,7 @@ GNUNET_MULTICAST_origin_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
const struct GNUNET_CRYPTO_EddsaPrivateKey *priv_key,
uint64_t next_fragment_id,
GNUNET_MULTICAST_JoinCallback join_cb,
- GNUNET_MULTICAST_MembershipTestCallback mem_test_cb,
+ GNUNET_MULTICAST_MembershipTestCallback member_test_cb,
GNUNET_MULTICAST_ReplayFragmentCallback replay_frag_cb,
GNUNET_MULTICAST_ReplayMessageCallback replay_msg_cb,
GNUNET_MULTICAST_RequestCallback request_cb,
@@ -756,14 +810,14 @@ struct GNUNET_MULTICAST_MemberRequestHandle;
* Send a message to the origin of the multicast group.
*
* @param member Membership handle.
- * @param message_id Application layer ID for the message. Opaque to multicast.
+ * @param request_id Application layer ID for the request. Opaque to multicast.
* @param notify Callback to call to get the message.
* @param notify_cls Closure for @a notify.
* @return Handle to cancel request, NULL on error (i.e. request already pending).
*/
struct GNUNET_MULTICAST_MemberRequestHandle *
GNUNET_MULTICAST_member_to_origin (struct GNUNET_MULTICAST_Member *member,
- uint64_t message_id,
+ uint64_t request_id,
GNUNET_MULTICAST_MemberTransmitNotify notify,
void *notify_cls);
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h
index 65ecb22e64..88cf5a0249 100644
--- a/src/include/gnunet_protocols.h
+++ b/src/include/gnunet_protocols.h
@@ -2279,14 +2279,34 @@ extern "C"
/* WIP: no numbers assigned yet */
/**
+ * Start an origin.
+ */
+#define GNUNET_MESSAGE_TYPE_MULTICAST_ORIGIN_START 750
+
+/**
+ * Stop an origin.
+ */
+#define GNUNET_MESSAGE_TYPE_MULTICAST_ORIGIN_STOP 751
+
+/**
+ * Join a group as a member.
+ */
+#define GNUNET_MESSAGE_TYPE_MULTICAST_MEMBER_JOIN 752
+
+/**
+ * Leave a group.
+ */
+#define GNUNET_MESSAGE_TYPE_MULTICAST_MEMBER_PART 753
+
+/**
* Multicast message from the origin to all members.
*/
-#define GNUNET_MESSAGE_TYPE_MULTICAST_MESSAGE 750
+#define GNUNET_MESSAGE_TYPE_MULTICAST_MESSAGE 754
/**
* A unicast message from a group member to the origin.
*/
-#define GNUNET_MESSAGE_TYPE_MULTICAST_REQUEST
+#define GNUNET_MESSAGE_TYPE_MULTICAST_REQUEST 755
/**
* A peer wants to join the group.
@@ -2366,14 +2386,6 @@ extern "C"
/*******************************************************************************
- * PSYC message types
- ******************************************************************************/
-
-/*******************************************************************************
- * PSYCSTORE message types
- ******************************************************************************/
-
-/*******************************************************************************
* SOCIAL message types
******************************************************************************/
diff --git a/src/include/gnunet_psyc_service.h b/src/include/gnunet_psyc_service.h
index f843fbe1f6..8f1707854e 100644
--- a/src/include/gnunet_psyc_service.h
+++ b/src/include/gnunet_psyc_service.h
@@ -110,7 +110,7 @@ enum GNUNET_PSYC_ChannelFlags
* Past messages are only available to slaves who were admitted at the time
* they were sent to the channel.
*/
- GNUNET_PSYC_CHANNEL_RESTRICTED_HISTORY = 1 << 1,
+ GNUNET_PSYC_CHANNEL_RESTRICTED_HISTORY = 1 << 1
};
/**
@@ -132,7 +132,7 @@ enum GNUNET_PSYC_Policy
*/
GNUNET_PSYC_CHANNEL_PRIVATE
= GNUNET_PSYC_CHANNEL_ADMISSION_CONTROL
- | GNUNET_PSYC_CHANNEL_RESTRICTED_HISTORY,
+ | GNUNET_PSYC_CHANNEL_RESTRICTED_HISTORY
#if IDEAS_FOR_FUTURE
/**
@@ -152,9 +152,7 @@ enum GNUNET_PSYC_Policy
*/
GNUNET_PSYC_CHANNEL_CLOSED
= GNUNET_PSYC_CHANNEL_ADMISSION_CONTROL,
-,
#endif
-
};
@@ -163,7 +161,12 @@ enum GNUNET_PSYC_MessageFlags
/**
* Historic message, retrieved from PSYCstore.
*/
- GNUNET_PSYC_MESSAGE_HISTORIC = 1
+ GNUNET_PSYC_MESSAGE_HISTORIC = 1 << 0,
+
+ /**
+ * Request from slave to master.
+ */
+ GNUNET_PSYC_MESSAGE_REQUEST = 1 << 1
};
GNUNET_NETWORK_STRUCT_BEGIN
@@ -406,7 +409,7 @@ GNUNET_PSYC_master_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
/**
* Function called to provide data for a transmission via PSYC.
*
- * Note that returning #GNUNET_OK or #GNUNET_SYSERR (but not #GNUNET_NO)
+ * Note that returning #GNUNET_YES or #GNUNET_SYSERR (but not #GNUNET_NO)
* invalidates the respective transmission handle.
*
* @param cls Closure.
@@ -422,15 +425,43 @@ GNUNET_PSYC_master_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
* #GNUNET_YES if this completes the transmission (all data supplied)
*/
typedef int
-(*GNUNET_PSYC_MasterTransmitNotify) (void *cls,
- uint16_t *data_size,
- void *data);
+(*GNUNET_PSYC_TransmitNotifyData) (void *cls,
+ uint16_t *data_size,
+ void *data);
+/**
+ * Function called to provide a modifier for a transmission via PSYC.
+ *
+ * Note that returning #GNUNET_YES or #GNUNET_SYSERR (but not #GNUNET_NO)
+ * invalidates the respective transmission handle.
+ *
+ * @param cls Closure.
+ * @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 modifier's name and value.
+ * The function must copy at most @a data_size bytes to @a data.
+ * When this callback is first called for a modifier, @a data should
+ * contain: "name\0value". If the whole value does not fit, subsequent
+ * calls to this function should write continuations of the value to
+ * @a data.
+ * @param oper Where to write the operator of the modifier. Only needed during
+ * the first call to this callback at the beginning of the modifier.
+ * In case of subsequent calls asking for value continuations @a oper is
+ * set to #NULL.
+ * @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 for the modifier's value (the name must be always returned
+ * during the first call to this callback).
+ * If 0 is returned in @a data_size the transmission is paused,
+ * and can be resumed with GNUNET_PSYC_master_transmit_resume().
+ * #GNUNET_YES if this completes the modifier (the whole value is supplied).
+ */
typedef int
-(*GNUNET_PSYC_MasterTransmitNotifyModifier) (void *cls,
- uint16_t *data_size,
- void *data,
- uint8_t *oper);
+(*GNUNET_PSYC_TransmitNotifyModifier) (void *cls,
+ uint16_t *data_size,
+ void *data,
+ uint8_t *oper);
/**
* Flags for transmitting messages to a channel by the master.
@@ -477,8 +508,8 @@ struct GNUNET_PSYC_MasterTransmitHandle;
struct GNUNET_PSYC_MasterTransmitHandle *
GNUNET_PSYC_master_transmit (struct GNUNET_PSYC_Master *master,
const char *method_name,
- GNUNET_PSYC_MasterTransmitNotifyModifier notify_mod,
- GNUNET_PSYC_MasterTransmitNotify notify_data,
+ GNUNET_PSYC_TransmitNotifyModifier notify_mod,
+ GNUNET_PSYC_TransmitNotifyData notify_data,
void *notify_cls,
enum GNUNET_PSYC_MasterTransmitFlags flags);
@@ -588,29 +619,6 @@ GNUNET_PSYC_slave_part (struct GNUNET_PSYC_Slave *slave);
/**
- * Function called to provide data for a transmission to the channel master
- * (a.k.a. the @e host of the channel).
- *
- * Note that returning #GNUNET_OK or #GNUNET_SYSERR (but not #GNUNET_NO)
- * invalidates the respective transmission handle.
- *
- * @param cls Closure.
- * @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.
- * @return #GNUNET_SYSERR on error (fatal, aborts transmission).
- * #GNUNET_NO on success, if more data is to be transmitted later.
- * #GNUNET_YES if this completes the transmission (all data supplied).
- */
-typedef int
-(*GNUNET_PSYC_SlaveTransmitNotify) (void *cls,
- size_t *data_size,
- char *data);
-
-
-/**
* Flags for transmitting messages to the channel master by a slave.
*/
enum GNUNET_PSYC_SlaveTransmitFlags
@@ -630,8 +638,8 @@ struct GNUNET_PSYC_SlaveTransmitHandle;
*
* @param slave Slave handle.
* @param method_name Which (PSYC) method should be invoked (on host).
- * @param env Environment containing transient variables for the message, or NULL.
- * @param notify Function to call when we are allowed to transmit (to get data).
+ * @param notify_mod Function to call to obtain modifiers.
+ * @param notify_data Function to call to obtain fragments of the data.
* @param notify_cls Closure for @a notify.
* @param flags Flags for the message being transmitted.
* @return Transmission handle, NULL on error (i.e. more than one request queued).
@@ -639,8 +647,8 @@ struct GNUNET_PSYC_SlaveTransmitHandle;
struct GNUNET_PSYC_SlaveTransmitHandle *
GNUNET_PSYC_slave_transmit (struct GNUNET_PSYC_Slave *slave,
const char *method_name,
- const struct GNUNET_ENV_Environment *env,
- GNUNET_PSYC_SlaveTransmitNotify notify,
+ GNUNET_PSYC_TransmitNotifyModifier notify_mod,
+ GNUNET_PSYC_TransmitNotifyData notify_data,
void *notify_cls,
enum GNUNET_PSYC_SlaveTransmitFlags flags);
diff --git a/src/include/gnunet_social_service.h b/src/include/gnunet_social_service.h
index 8bd1a959f4..98ad883461 100644
--- a/src/include/gnunet_social_service.h
+++ b/src/include/gnunet_social_service.h
@@ -375,12 +375,11 @@ GNUNET_SOCIAL_home_announce_cancel (struct GNUNET_SOCIAL_Announcement *a);
* Convert our home to a place so we can access it via the place API.
*
* @param home Handle for the home.
- * @param keep_active Keep home active after last application disconnected.
* @return Place handle for the same home, valid as long as @a home is valid;
* do NOT try to GNUNET_SOCIAL_place_leave() this place, it's your home!
*/
struct GNUNET_SOCIAL_Place *
-GNUNET_SOCIAL_home_get_place (struct GNUNET_SOCIAL_Home *home, int keep_active);
+GNUNET_SOCIAL_home_get_place (struct GNUNET_SOCIAL_Home *home);
/**
@@ -390,9 +389,10 @@ GNUNET_SOCIAL_home_get_place (struct GNUNET_SOCIAL_Home *home, int keep_active);
* Guests will be disconnected until the home is restarted.
*
* @param home Home to leave.
+ * @param keep_active Keep home active after last application disconnected.
*/
void
-GNUNET_SOCIAL_home_leave (struct GNUNET_SOCIAL_Home *home);
+GNUNET_SOCIAL_home_leave (struct GNUNET_SOCIAL_Home *home, int keep_active);
/**
* Request entry to a place (home hosted by someone else).