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/psyc | |
parent | d309f70641efc038d4b23558030b0551c3101256 (diff) | |
download | gnunet-49fb1901d18e1e42c41b7cd8817e5778ed473470.tar.gz gnunet-49fb1901d18e1e42c41b7cd8817e5778ed473470.zip |
PSYC: message types, documentation
Diffstat (limited to 'src/psyc')
-rw-r--r-- | src/psyc/gnunet-service-psyc.c | 171 | ||||
-rw-r--r-- | src/psyc/psyc.h | 127 |
2 files changed, 212 insertions, 86 deletions
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 | ||