diff options
author | Gabor X Toth <*@tg-x.net> | 2014-03-13 18:49:13 +0000 |
---|---|---|
committer | Gabor X Toth <*@tg-x.net> | 2014-03-13 18:49:13 +0000 |
commit | 49fb1901d18e1e42c41b7cd8817e5778ed473470 (patch) | |
tree | 657826803c2a9b36448bad59672edca2b65a4748 /src | |
parent | d309f70641efc038d4b23558030b0551c3101256 (diff) | |
download | gnunet-49fb1901d18e1e42c41b7cd8817e5778ed473470.tar.gz gnunet-49fb1901d18e1e42c41b7cd8817e5778ed473470.zip |
PSYC: message types, documentation
Diffstat (limited to 'src')
-rw-r--r-- | src/include/gnunet_multicast_service.h | 3 | ||||
-rw-r--r-- | src/include/gnunet_protocols.h | 50 | ||||
-rw-r--r-- | src/include/gnunet_psyc_service.h | 7 | ||||
-rw-r--r-- | src/psyc/gnunet-service-psyc.c | 171 | ||||
-rw-r--r-- | src/psyc/psyc.h | 127 |
5 files changed, 255 insertions, 103 deletions
diff --git a/src/include/gnunet_multicast_service.h b/src/include/gnunet_multicast_service.h index aa5597fd3..50dcf7aef 100644 --- a/src/include/gnunet_multicast_service.h +++ b/src/include/gnunet_multicast_service.h | |||
@@ -189,7 +189,8 @@ struct GNUNET_MULTICAST_RequestHeader | |||
189 | struct GNUNET_CRYPTO_EccSignaturePurpose purpose; | 189 | struct GNUNET_CRYPTO_EccSignaturePurpose purpose; |
190 | 190 | ||
191 | /** | 191 | /** |
192 | * Number of the request fragment, monotonically increasing. | 192 | * Number of the request fragment. |
193 | * Monotonically increasing from 1. | ||
193 | */ | 194 | */ |
194 | uint64_t fragment_id GNUNET_PACKED; | 195 | uint64_t fragment_id GNUNET_PACKED; |
195 | 196 | ||
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h index 88cf5a024..b67e3bdcb 100644 --- a/src/include/gnunet_protocols.h +++ b/src/include/gnunet_protocols.h | |||
@@ -2126,64 +2126,84 @@ extern "C" | |||
2126 | * PSYC message types | 2126 | * PSYC message types |
2127 | ******************************************************************************/ | 2127 | ******************************************************************************/ |
2128 | 2128 | ||
2129 | #define GNUNET_MESSAGE_TYPE_PSYC_RESULT_CODE 680 | 2129 | /** |
2130 | * C: client | ||
2131 | * S: service | ||
2132 | * M: muticast | ||
2133 | */ | ||
2130 | 2134 | ||
2135 | /** S->C: result of an operation */ | ||
2136 | #define GNUNET_MESSAGE_TYPE_PSYC_RESULT_CODE 680 | ||
2131 | 2137 | ||
2138 | /** C->S: request to start a master */ | ||
2132 | #define GNUNET_MESSAGE_TYPE_PSYC_MASTER_START 681 | 2139 | #define GNUNET_MESSAGE_TYPE_PSYC_MASTER_START 681 |
2133 | 2140 | ||
2141 | /** S->C: master start acknowledgement */ | ||
2134 | #define GNUNET_MESSAGE_TYPE_PSYC_MASTER_START_ACK 682 | 2142 | #define GNUNET_MESSAGE_TYPE_PSYC_MASTER_START_ACK 682 |
2135 | 2143 | ||
2136 | #define GNUNET_MESSAGE_TYPE_PSYC_MASTER_STOP 683 | 2144 | /** C->S: request to start a master */ |
2137 | 2145 | #define GNUNET_MESSAGE_TYPE_PSYC_SLAVE_JOIN 683 | |
2138 | 2146 | ||
2139 | #define GNUNET_MESSAGE_TYPE_PSYC_SLAVE_JOIN 684 | 2147 | /** S->C: slave join acknowledgement */ |
2140 | 2148 | #define GNUNET_MESSAGE_TYPE_PSYC_SLAVE_JOIN_ACK 684 | |
2141 | #define GNUNET_MESSAGE_TYPE_PSYC_SLAVE_JOIN_ACK 685 | ||
2142 | |||
2143 | #define GNUNET_MESSAGE_TYPE_PSYC_SLAVE_PART 686 | ||
2144 | 2149 | ||
2150 | /* 685-686 */ | ||
2145 | 2151 | ||
2152 | /** M->S->C: incoming join request from multicast */ | ||
2146 | #define GNUNET_MESSAGE_TYPE_PSYC_JOIN_REQUEST 687 | 2153 | #define GNUNET_MESSAGE_TYPE_PSYC_JOIN_REQUEST 687 |
2147 | 2154 | ||
2155 | /** C->S->M: decision about a join request */ | ||
2148 | #define GNUNET_MESSAGE_TYPE_PSYC_JOIN_DECISION 688 | 2156 | #define GNUNET_MESSAGE_TYPE_PSYC_JOIN_DECISION 688 |
2149 | 2157 | ||
2150 | 2158 | ||
2159 | /** C->S: request to remove channel slave from the membership database. */ | ||
2151 | #define GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_SLAVE_ADD 689 | 2160 | #define GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_SLAVE_ADD 689 |
2152 | 2161 | ||
2162 | /** C->S: request to add channel slave to the membership database */ | ||
2153 | #define GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_SLAVE_RM 690 | 2163 | #define GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_SLAVE_RM 690 |
2154 | 2164 | ||
2155 | 2165 | ||
2166 | /** M<->S<->C: PSYC message which contains one or more message parts. */ | ||
2156 | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE 691 | 2167 | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE 691 |
2157 | 2168 | ||
2169 | /** Message part: method */ | ||
2158 | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD 692 | 2170 | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD 692 |
2159 | 2171 | ||
2172 | /** Message part: modifier */ | ||
2160 | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MODIFIER 693 | 2173 | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MODIFIER 693 |
2161 | 2174 | ||
2175 | /** Message part: modifier continuation */ | ||
2162 | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MOD_CONT 694 | 2176 | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MOD_CONT 694 |
2163 | 2177 | ||
2178 | /** Message part: data */ | ||
2164 | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_DATA 695 | 2179 | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_DATA 695 |
2165 | 2180 | ||
2181 | /** Message part: end of message */ | ||
2166 | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END 696 | 2182 | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END 696 |
2167 | 2183 | ||
2184 | /** Message part: message cancelled */ | ||
2168 | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_CANCEL 697 | 2185 | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_CANCEL 697 |
2169 | 2186 | ||
2187 | /** S->C: message acknowledgment */ | ||
2170 | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_ACK 698 | 2188 | #define GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_ACK 698 |
2171 | 2189 | ||
2190 | /* 699-700 */ | ||
2172 | 2191 | ||
2192 | /** C->S: client requests channel history from PSYCstore. */ | ||
2173 | #define GNUNET_MESSAGE_TYPE_PSYC_STORY_REQUEST 701 | 2193 | #define GNUNET_MESSAGE_TYPE_PSYC_STORY_REQUEST 701 |
2174 | 2194 | ||
2175 | #define GNUNET_MESSAGE_TYPE_PSYC_STORY_RESPONSE 702 | 2195 | /** S->C: result for a channel history request */ |
2196 | #define GNUNET_MESSAGE_TYPE_PSYC_STORY_RESULT 702 | ||
2176 | 2197 | ||
2177 | 2198 | ||
2199 | /** C->S: request best matching state variable from PSYCstore. */ | ||
2178 | #define GNUNET_MESSAGE_TYPE_PSYC_STATE_GET 703 | 2200 | #define GNUNET_MESSAGE_TYPE_PSYC_STATE_GET 703 |
2179 | 2201 | ||
2202 | /** C->S: request state variables with a given prefix from PSYCstore. */ | ||
2180 | #define GNUNET_MESSAGE_TYPE_PSYC_STATE_GET_PREFIX 704 | 2203 | #define GNUNET_MESSAGE_TYPE_PSYC_STATE_GET_PREFIX 704 |
2181 | 2204 | ||
2182 | #define GNUNET_MESSAGE_TYPE_PSYC_STATE_RESPONSE 705 | 2205 | /** S->C: result for a state request. */ |
2183 | 2206 | #define GNUNET_MESSAGE_TYPE_PSYC_STATE_RESULT 705 | |
2184 | #define GNUNET_MESSAGE_TYPE_PSYC_STATE_MODIFIER 706 | ||
2185 | |||
2186 | #define GNUNET_MESSAGE_TYPE_PSYC_STATE_MOD_CONT 707 | ||
2187 | 2207 | ||
2188 | 2208 | ||
2189 | /******************************************************************************* | 2209 | /******************************************************************************* |
@@ -2196,7 +2216,7 @@ extern "C" | |||
2196 | #define GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO 730 | 2216 | #define GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO 730 |
2197 | 2217 | ||
2198 | /** | 2218 | /** |
2199 | * Client -> Server message register a phone. | 2219 | * Client -> Server message to register a phone. |
2200 | */ | 2220 | */ |
2201 | #define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_REGISTER 731 | 2221 | #define GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_REGISTER 731 |
2202 | 2222 | ||
diff --git a/src/include/gnunet_psyc_service.h b/src/include/gnunet_psyc_service.h index 3a0c713d5..018f012f4 100644 --- a/src/include/gnunet_psyc_service.h +++ b/src/include/gnunet_psyc_service.h | |||
@@ -113,6 +113,7 @@ enum GNUNET_PSYC_ChannelFlags | |||
113 | GNUNET_PSYC_CHANNEL_RESTRICTED_HISTORY = 1 << 1 | 113 | GNUNET_PSYC_CHANNEL_RESTRICTED_HISTORY = 1 << 1 |
114 | }; | 114 | }; |
115 | 115 | ||
116 | |||
116 | /** | 117 | /** |
117 | * PSYC channel policies. | 118 | * PSYC channel policies. |
118 | */ | 119 | */ |
@@ -169,6 +170,7 @@ enum GNUNET_PSYC_MessageFlags | |||
169 | GNUNET_PSYC_MESSAGE_REQUEST = 1 << 1 | 170 | GNUNET_PSYC_MESSAGE_REQUEST = 1 << 1 |
170 | }; | 171 | }; |
171 | 172 | ||
173 | |||
172 | GNUNET_NETWORK_STRUCT_BEGIN | 174 | GNUNET_NETWORK_STRUCT_BEGIN |
173 | 175 | ||
174 | /** | 176 | /** |
@@ -190,6 +192,7 @@ struct GNUNET_PSYC_MessageHeader | |||
190 | 192 | ||
191 | /** | 193 | /** |
192 | * Number of the message this message part belongs to. | 194 | * Number of the message this message part belongs to. |
195 | * Monotonically increasing from 1. | ||
193 | */ | 196 | */ |
194 | uint64_t message_id GNUNET_PACKED; | 197 | uint64_t message_id GNUNET_PACKED; |
195 | 198 | ||
@@ -254,6 +257,7 @@ struct GNUNET_PSYC_MessageModifier | |||
254 | 257 | ||
255 | GNUNET_NETWORK_STRUCT_END | 258 | GNUNET_NETWORK_STRUCT_END |
256 | 259 | ||
260 | |||
257 | #define GNUNET_PSYC_MODIFIER_MAX_PAYLOAD \ | 261 | #define GNUNET_PSYC_MODIFIER_MAX_PAYLOAD \ |
258 | GNUNET_MULTICAST_FRAGMENT_MAX_PAYLOAD \ | 262 | GNUNET_MULTICAST_FRAGMENT_MAX_PAYLOAD \ |
259 | - sizeof (struct GNUNET_PSYC_MessageModifier) | 263 | - sizeof (struct GNUNET_PSYC_MessageModifier) |
@@ -266,6 +270,7 @@ GNUNET_NETWORK_STRUCT_END | |||
266 | GNUNET_MULTICAST_FRAGMENT_MAX_PAYLOAD \ | 270 | GNUNET_MULTICAST_FRAGMENT_MAX_PAYLOAD \ |
267 | - sizeof (struct GNUNET_MessageHeader) | 271 | - sizeof (struct GNUNET_MessageHeader) |
268 | 272 | ||
273 | |||
269 | /** | 274 | /** |
270 | * Handle that identifies a join request. | 275 | * Handle that identifies a join request. |
271 | * | 276 | * |
@@ -362,7 +367,7 @@ struct GNUNET_PSYC_Master; | |||
362 | * Function called after the channel master started. | 367 | * Function called after the channel master started. |
363 | * | 368 | * |
364 | * @param cls Closure. | 369 | * @param cls Closure. |
365 | * @param last_message_id Last message ID sent to the channel. | 370 | * @param max_message_id Last message ID sent to the channel. |
366 | */ | 371 | */ |
367 | typedef void | 372 | typedef void |
368 | (*GNUNET_PSYC_MasterStartCallback) (void *cls, uint64_t max_message_id); | 373 | (*GNUNET_PSYC_MasterStartCallback) (void *cls, uint64_t max_message_id); |
diff --git a/src/psyc/gnunet-service-psyc.c b/src/psyc/gnunet-service-psyc.c index 4cdb490a1..1b1f4b1db 100644 --- a/src/psyc/gnunet-service-psyc.c +++ b/src/psyc/gnunet-service-psyc.c | |||
@@ -63,6 +63,7 @@ static struct GNUNET_PSYCSTORE_Handle *store; | |||
63 | */ | 63 | */ |
64 | static struct GNUNET_CONTAINER_MultiHashMap *clients; | 64 | static struct GNUNET_CONTAINER_MultiHashMap *clients; |
65 | 65 | ||
66 | |||
66 | /** | 67 | /** |
67 | * Message in the transmission queue. | 68 | * Message in the transmission queue. |
68 | */ | 69 | */ |
@@ -71,10 +72,18 @@ struct TransmitMessage | |||
71 | struct TransmitMessage *prev; | 72 | struct TransmitMessage *prev; |
72 | struct TransmitMessage *next; | 73 | struct TransmitMessage *next; |
73 | 74 | ||
75 | /** | ||
76 | * Buffer with message to be transmitted. | ||
77 | */ | ||
74 | char *buf; | 78 | char *buf; |
75 | uint16_t size; | 79 | |
76 | /** | 80 | /** |
77 | * enum MessageState | 81 | * Size of @a buf |
82 | */ | ||
83 | uint16_t size | ||
84 | ; | ||
85 | /** | ||
86 | * @see enum MessageState | ||
78 | */ | 87 | */ |
79 | uint8_t state; | 88 | uint8_t state; |
80 | }; | 89 | }; |
@@ -147,34 +156,57 @@ struct Channel | |||
147 | uint32_t tmit_mod_value_size; | 156 | uint32_t tmit_mod_value_size; |
148 | 157 | ||
149 | /** | 158 | /** |
150 | * enum MessageState | 159 | * @see enum MessageState |
151 | */ | 160 | */ |
152 | uint8_t tmit_state; | 161 | uint8_t tmit_state; |
153 | 162 | ||
154 | uint8_t in_transmit; | 163 | uint8_t in_transmit; |
164 | |||
165 | /** | ||
166 | * Is this a channel master (#GNUNET_YES), or slave (#GNUNET_NO)? | ||
167 | */ | ||
155 | uint8_t is_master; | 168 | uint8_t is_master; |
156 | 169 | ||
157 | /** | 170 | /** |
158 | * Ready to receive messages from client. | 171 | * Ready to receive messages from client? #GNUNET_YES or #GNUNET_NO |
159 | */ | 172 | */ |
160 | uint8_t ready; | 173 | uint8_t ready; |
161 | 174 | ||
162 | /** | 175 | /** |
163 | * Client disconnected. | 176 | * Is the client disconnected? #GNUNET_YES or #GNUNET_NO |
164 | */ | 177 | */ |
165 | uint8_t disconnected; | 178 | uint8_t disconnected; |
166 | }; | 179 | }; |
167 | 180 | ||
181 | |||
168 | /** | 182 | /** |
169 | * Client context for a channel master. | 183 | * Client context for a channel master. |
170 | */ | 184 | */ |
171 | struct Master | 185 | struct Master |
172 | { | 186 | { |
187 | /** | ||
188 | * Channel struct common for Master and Slave | ||
189 | */ | ||
173 | struct Channel channel; | 190 | struct Channel channel; |
191 | |||
192 | /** | ||
193 | * Private key of the channel. | ||
194 | */ | ||
174 | struct GNUNET_CRYPTO_EddsaPrivateKey priv_key; | 195 | struct GNUNET_CRYPTO_EddsaPrivateKey priv_key; |
196 | |||
197 | /** | ||
198 | * Public key of the channel. | ||
199 | */ | ||
175 | struct GNUNET_CRYPTO_EddsaPublicKey pub_key; | 200 | struct GNUNET_CRYPTO_EddsaPublicKey pub_key; |
176 | 201 | ||
202 | /** | ||
203 | * Handle for the multicast origin. | ||
204 | */ | ||
177 | struct GNUNET_MULTICAST_Origin *origin; | 205 | struct GNUNET_MULTICAST_Origin *origin; |
206 | |||
207 | /** | ||
208 | * Transmit handle for multicast. | ||
209 | */ | ||
178 | struct GNUNET_MULTICAST_OriginMessageHandle *tmit_handle; | 210 | struct GNUNET_MULTICAST_OriginMessageHandle *tmit_handle; |
179 | 211 | ||
180 | /** | 212 | /** |
@@ -201,6 +233,9 @@ struct Master | |||
201 | */ | 233 | */ |
202 | uint32_t policy; | 234 | uint32_t policy; |
203 | 235 | ||
236 | /** | ||
237 | * Hash of @a pub_key | ||
238 | */ | ||
204 | struct GNUNET_HashCode pub_key_hash; | 239 | struct GNUNET_HashCode pub_key_hash; |
205 | }; | 240 | }; |
206 | 241 | ||
@@ -210,23 +245,64 @@ struct Master | |||
210 | */ | 245 | */ |
211 | struct Slave | 246 | struct Slave |
212 | { | 247 | { |
248 | /** | ||
249 | * Channel struct common for Master and Slave | ||
250 | */ | ||
213 | struct Channel channel; | 251 | struct Channel channel; |
252 | |||
253 | /** | ||
254 | * Private key of the slave. | ||
255 | */ | ||
214 | struct GNUNET_CRYPTO_EddsaPrivateKey slave_key; | 256 | struct GNUNET_CRYPTO_EddsaPrivateKey slave_key; |
257 | |||
258 | /** | ||
259 | * Public key of the channel. | ||
260 | */ | ||
215 | struct GNUNET_CRYPTO_EddsaPublicKey chan_key; | 261 | struct GNUNET_CRYPTO_EddsaPublicKey chan_key; |
216 | 262 | ||
263 | /** | ||
264 | * Handle for the multicast member. | ||
265 | */ | ||
217 | struct GNUNET_MULTICAST_Member *member; | 266 | struct GNUNET_MULTICAST_Member *member; |
267 | |||
268 | /** | ||
269 | * Transmit handle for multicast. | ||
270 | */ | ||
218 | struct GNUNET_MULTICAST_MemberRequestHandle *tmit_handle; | 271 | struct GNUNET_MULTICAST_MemberRequestHandle *tmit_handle; |
219 | 272 | ||
273 | /** | ||
274 | * Peer identity of the origin. | ||
275 | */ | ||
220 | struct GNUNET_PeerIdentity origin; | 276 | struct GNUNET_PeerIdentity origin; |
221 | 277 | ||
278 | /** | ||
279 | * Number of items in @a relays. | ||
280 | */ | ||
222 | uint32_t relay_count; | 281 | uint32_t relay_count; |
282 | |||
283 | /** | ||
284 | * Relays that multicast can use to connect. | ||
285 | */ | ||
223 | struct GNUNET_PeerIdentity *relays; | 286 | struct GNUNET_PeerIdentity *relays; |
224 | 287 | ||
288 | /** | ||
289 | * Join request to be transmitted to the master on join. | ||
290 | */ | ||
225 | struct GNUNET_MessageHeader *join_req; | 291 | struct GNUNET_MessageHeader *join_req; |
226 | 292 | ||
293 | /** | ||
294 | * Maximum message ID for this channel. | ||
295 | */ | ||
227 | uint64_t max_message_id; | 296 | uint64_t max_message_id; |
297 | |||
298 | /** | ||
299 | * Maximum request ID for this channel. | ||
300 | */ | ||
228 | uint64_t max_request_id; | 301 | uint64_t max_request_id; |
229 | 302 | ||
303 | /** | ||
304 | * Hash of @a chan_key. | ||
305 | */ | ||
230 | struct GNUNET_HashCode chan_key_hash; | 306 | struct GNUNET_HashCode chan_key_hash; |
231 | }; | 307 | }; |
232 | 308 | ||
@@ -323,8 +399,11 @@ client_disconnect (void *cls, struct GNUNET_SERVER_Client *client) | |||
323 | } | 399 | } |
324 | 400 | ||
325 | 401 | ||
402 | /** | ||
403 | * Master receives a join request from a slave. | ||
404 | */ | ||
326 | static void | 405 | static void |
327 | join_cb (void *cls, const struct GNUNET_CRYPTO_EddsaPublicKey *member_key, | 406 | join_cb (void *cls, const struct GNUNET_CRYPTO_EddsaPublicKey *slave_key, |
328 | const struct GNUNET_MessageHeader *join_req, | 407 | const struct GNUNET_MessageHeader *join_req, |
329 | struct GNUNET_MULTICAST_JoinHandle *jh) | 408 | struct GNUNET_MULTICAST_JoinHandle *jh) |
330 | { | 409 | { |
@@ -334,7 +413,7 @@ join_cb (void *cls, const struct GNUNET_CRYPTO_EddsaPublicKey *member_key, | |||
334 | 413 | ||
335 | static void | 414 | static void |
336 | membership_test_cb (void *cls, | 415 | membership_test_cb (void *cls, |
337 | const struct GNUNET_CRYPTO_EddsaPublicKey *member_key, | 416 | const struct GNUNET_CRYPTO_EddsaPublicKey *slave_key, |
338 | uint64_t message_id, uint64_t group_generation, | 417 | uint64_t message_id, uint64_t group_generation, |
339 | struct GNUNET_MULTICAST_MembershipTestHandle *mth) | 418 | struct GNUNET_MULTICAST_MembershipTestHandle *mth) |
340 | { | 419 | { |
@@ -344,7 +423,7 @@ membership_test_cb (void *cls, | |||
344 | 423 | ||
345 | static void | 424 | static void |
346 | replay_fragment_cb (void *cls, | 425 | replay_fragment_cb (void *cls, |
347 | const struct GNUNET_CRYPTO_EddsaPublicKey *member_key, | 426 | const struct GNUNET_CRYPTO_EddsaPublicKey *slave_key, |
348 | uint64_t fragment_id, uint64_t flags, | 427 | uint64_t fragment_id, uint64_t flags, |
349 | struct GNUNET_MULTICAST_ReplayHandle *rh) | 428 | struct GNUNET_MULTICAST_ReplayHandle *rh) |
350 | 429 | ||
@@ -354,7 +433,7 @@ replay_fragment_cb (void *cls, | |||
354 | 433 | ||
355 | static void | 434 | static void |
356 | replay_message_cb (void *cls, | 435 | replay_message_cb (void *cls, |
357 | const struct GNUNET_CRYPTO_EddsaPublicKey *member_key, | 436 | const struct GNUNET_CRYPTO_EddsaPublicKey *slave_key, |
358 | uint64_t message_id, | 437 | uint64_t message_id, |
359 | uint64_t fragment_offset, | 438 | uint64_t fragment_offset, |
360 | uint64_t flags, | 439 | uint64_t flags, |
@@ -702,12 +781,12 @@ slave_message_cb (void *cls, const struct GNUNET_MessageHeader *msg) | |||
702 | * Incoming request fragment from multicast for a master. | 781 | * Incoming request fragment from multicast for a master. |
703 | * | 782 | * |
704 | * @param cls Master. | 783 | * @param cls Master. |
705 | * @param member_key Sending member's public key. | 784 | * @param slave_key Sending slave's public key. |
706 | * @param msg The message. | 785 | * @param msg The message. |
707 | * @param flags Request flags. | 786 | * @param flags Request flags. |
708 | */ | 787 | */ |
709 | static void | 788 | static void |
710 | request_cb (void *cls, const struct GNUNET_CRYPTO_EddsaPublicKey *member_key, | 789 | request_cb (void *cls, const struct GNUNET_CRYPTO_EddsaPublicKey *slave_key, |
711 | const struct GNUNET_MessageHeader *msg, | 790 | const struct GNUNET_MessageHeader *msg, |
712 | enum GNUNET_MULTICAST_MessageFlags flags) | 791 | enum GNUNET_MULTICAST_MessageFlags flags) |
713 | { | 792 | { |
@@ -1159,6 +1238,61 @@ handle_psyc_message (void *cls, struct GNUNET_SERVER_Client *client, | |||
1159 | 1238 | ||
1160 | 1239 | ||
1161 | /** | 1240 | /** |
1241 | * Client requests to add a slave to the membership database. | ||
1242 | */ | ||
1243 | static void | ||
1244 | handle_slave_add (void *cls, struct GNUNET_SERVER_Client *client, | ||
1245 | const struct GNUNET_MessageHeader *msg) | ||
1246 | { | ||
1247 | |||
1248 | } | ||
1249 | |||
1250 | |||
1251 | /** | ||
1252 | * Client requests to remove a slave from the membership database. | ||
1253 | */ | ||
1254 | static void | ||
1255 | handle_slave_remove (void *cls, struct GNUNET_SERVER_Client *client, | ||
1256 | const struct GNUNET_MessageHeader *msg) | ||
1257 | { | ||
1258 | |||
1259 | } | ||
1260 | |||
1261 | |||
1262 | /** | ||
1263 | * Client requests channel history from PSYCstore. | ||
1264 | */ | ||
1265 | static void | ||
1266 | handle_story_request (void *cls, struct GNUNET_SERVER_Client *client, | ||
1267 | const struct GNUNET_MessageHeader *msg) | ||
1268 | { | ||
1269 | |||
1270 | } | ||
1271 | |||
1272 | |||
1273 | /** | ||
1274 | * Client requests best matching state variable from PSYCstore. | ||
1275 | */ | ||
1276 | static void | ||
1277 | handle_state_get (void *cls, struct GNUNET_SERVER_Client *client, | ||
1278 | const struct GNUNET_MessageHeader *msg) | ||
1279 | { | ||
1280 | |||
1281 | } | ||
1282 | |||
1283 | |||
1284 | /** | ||
1285 | * Client requests state variables with a given prefix from PSYCstore. | ||
1286 | */ | ||
1287 | static void | ||
1288 | handle_state_get_prefix (void *cls, struct GNUNET_SERVER_Client *client, | ||
1289 | const struct GNUNET_MessageHeader *msg) | ||
1290 | { | ||
1291 | |||
1292 | } | ||
1293 | |||
1294 | |||
1295 | /** | ||
1162 | * Initialize the PSYC service. | 1296 | * Initialize the PSYC service. |
1163 | * | 1297 | * |
1164 | * @param cls Closure. | 1298 | * @param cls Closure. |
@@ -1178,6 +1312,21 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
1178 | 1312 | ||
1179 | { &handle_psyc_message, NULL, | 1313 | { &handle_psyc_message, NULL, |
1180 | GNUNET_MESSAGE_TYPE_PSYC_MESSAGE, 0 }, | 1314 | GNUNET_MESSAGE_TYPE_PSYC_MESSAGE, 0 }, |
1315 | |||
1316 | { &handle_slave_add, NULL, | ||
1317 | GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_SLAVE_ADD, 0 }, | ||
1318 | |||
1319 | { &handle_slave_remove, NULL, | ||
1320 | GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_SLAVE_RM, 0 }, | ||
1321 | |||
1322 | { &handle_story_request, NULL, | ||
1323 | GNUNET_MESSAGE_TYPE_PSYC_STORY_REQUEST, 0 }, | ||
1324 | |||
1325 | { &handle_state_get, NULL, | ||
1326 | GNUNET_MESSAGE_TYPE_PSYC_STATE_GET, 0 }, | ||
1327 | |||
1328 | { &handle_state_get_prefix, NULL, | ||
1329 | GNUNET_MESSAGE_TYPE_PSYC_STATE_GET_PREFIX, 0 } | ||
1181 | }; | 1330 | }; |
1182 | 1331 | ||
1183 | cfg = c; | 1332 | cfg = c; |
diff --git a/src/psyc/psyc.h b/src/psyc/psyc.h index 940412a32..582a8e168 100644 --- a/src/psyc/psyc.h +++ b/src/psyc/psyc.h | |||
@@ -54,72 +54,6 @@ enum MessageState | |||
54 | 54 | ||
55 | GNUNET_NETWORK_STRUCT_BEGIN | 55 | GNUNET_NETWORK_STRUCT_BEGIN |
56 | 56 | ||
57 | /**** service -> library ****/ | ||
58 | |||
59 | /** | ||
60 | * Answer from service to client about last operation. | ||
61 | */ | ||
62 | struct OperationResult | ||
63 | { | ||
64 | /** | ||
65 | * Type: GNUNET_MESSAGE_TYPE_PSYCSTORE_RESULT_CODE | ||
66 | */ | ||
67 | struct GNUNET_MessageHeader header; | ||
68 | |||
69 | /** | ||
70 | * Operation ID. | ||
71 | */ | ||
72 | uint32_t op_id GNUNET_PACKED; | ||
73 | |||
74 | /** | ||
75 | * Status code for the operation. | ||
76 | */ | ||
77 | int64_t result_code GNUNET_PACKED; | ||
78 | |||
79 | /* followed by NUL-terminated error message (on error) */ | ||
80 | }; | ||
81 | |||
82 | |||
83 | struct CountersResult | ||
84 | { | ||
85 | /** | ||
86 | * Type: GNUNET_MESSAGE_TYPE_PSYC_RESULT_COUNTERS | ||
87 | */ | ||
88 | struct GNUNET_MessageHeader header; | ||
89 | |||
90 | /** | ||
91 | * Status code for the operation. | ||
92 | */ | ||
93 | int32_t result_code GNUNET_PACKED; | ||
94 | |||
95 | uint64_t max_message_id; | ||
96 | }; | ||
97 | |||
98 | |||
99 | #if REMOVE | ||
100 | /** | ||
101 | * Transmit acknowledgment. | ||
102 | * | ||
103 | * Sent after the last GNUNET_PSYC_MessageModifier and after each | ||
104 | * GNUNET_PSYC_MessageData. | ||
105 | * | ||
106 | * This message acknowledges previously received messages and asks for the next | ||
107 | * fragment of data. | ||
108 | */ | ||
109 | struct TransmitAck | ||
110 | { | ||
111 | /** | ||
112 | * Type: GNUNET_MESSAGE_TYPE_PSYC_TRANSMIT_ACK | ||
113 | */ | ||
114 | struct GNUNET_MessageHeader header; | ||
115 | |||
116 | /** | ||
117 | * Buffer space available for the next data fragment. | ||
118 | */ | ||
119 | uint16_t buf_avail; | ||
120 | }; | ||
121 | #endif | ||
122 | |||
123 | 57 | ||
124 | /**** library -> service ****/ | 58 | /**** library -> service ****/ |
125 | 59 | ||
@@ -203,37 +137,80 @@ struct StoryRequest | |||
203 | }; | 137 | }; |
204 | 138 | ||
205 | 139 | ||
206 | struct StateQuery | 140 | struct StateRequest |
207 | { | 141 | { |
208 | /** | 142 | /** |
209 | * Type: GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_STATE_QUERY | 143 | * Types: |
144 | * - GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_STATE_GET | ||
145 | * - GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_STATE_GET_PREFIX | ||
210 | */ | 146 | */ |
211 | struct GNUNET_MessageHeader header; | 147 | struct GNUNET_MessageHeader header; |
212 | 148 | ||
149 | /** | ||
150 | * ID for this operation. | ||
151 | */ | ||
213 | uint64_t op_id; | 152 | uint64_t op_id; |
214 | 153 | ||
215 | /* Followed by NUL-terminated name. */ | 154 | /* Followed by NUL-terminated name. */ |
216 | }; | 155 | }; |
217 | 156 | ||
218 | 157 | ||
219 | struct StateResult | 158 | /**** service -> library ****/ |
159 | |||
160 | |||
161 | struct CountersResult | ||
162 | { | ||
163 | /** | ||
164 | * Type: GNUNET_MESSAGE_TYPE_PSYC_RESULT_COUNTERS | ||
165 | */ | ||
166 | struct GNUNET_MessageHeader header; | ||
167 | |||
168 | /** | ||
169 | * Status code for the operation. | ||
170 | */ | ||
171 | int32_t result_code GNUNET_PACKED; | ||
172 | |||
173 | /** | ||
174 | * Last message ID sent to the channel. | ||
175 | */ | ||
176 | uint64_t max_message_id; | ||
177 | }; | ||
178 | |||
179 | /** | ||
180 | * Answer from service to client about last operation. | ||
181 | */ | ||
182 | struct OperationResult | ||
220 | { | 183 | { |
221 | /** | 184 | /** |
222 | * Type: GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_STATE_RESULT | 185 | * Types: |
186 | * - GNUNET_MESSAGE_TYPE_PSYC_RESULT_CODE | ||
187 | * - GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_STORY_RESULT | ||
188 | * - GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_STATE_RESULT | ||
223 | */ | 189 | */ |
224 | struct GNUNET_MessageHeader header; | 190 | struct GNUNET_MessageHeader header; |
225 | 191 | ||
226 | /** | 192 | /** |
227 | * Size of name, including NUL terminator. | 193 | * Operation ID. |
228 | */ | 194 | */ |
229 | uint16_t name_size GNUNET_PACKED; | 195 | uint32_t op_id GNUNET_PACKED; |
230 | 196 | ||
231 | /** | 197 | /** |
232 | * OR'd StateOpFlags | 198 | * Status code for the operation. |
233 | */ | 199 | */ |
234 | uint8_t flags; | 200 | int64_t result_code GNUNET_PACKED; |
235 | 201 | ||
236 | /* Followed by NUL-terminated name, then the value. */ | 202 | /* Followed by: |
203 | * - on error: NUL-terminated error message | ||
204 | * - on success: one of the following message types | ||
205 | * | ||
206 | * For a STORY_RESULT: | ||
207 | * - GNUNET_MESSAGE_TYPE_PSYC_MESSAGE | ||
208 | * | ||
209 | * For a STATE_RESULT, one of: | ||
210 | * - GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MODIFIER | ||
211 | * - GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MOD_CONT | ||
212 | * - GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END | ||
213 | */ | ||
237 | }; | 214 | }; |
238 | 215 | ||
239 | 216 | ||