diff options
author | Bart Polot <bart@net.in.tum.de> | 2013-10-09 01:06:44 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2013-10-09 01:06:44 +0000 |
commit | d1106ec22a4f714484ce964b24b4f10b397c720e (patch) | |
tree | a88d297d01a88ad0afa348afffab886e8d02a37f /src/mesh/gnunet-service-mesh_connection.h | |
parent | 7c31fa06ba410b36d4fadaeea962fc0dae4da0b5 (diff) | |
download | gnunet-d1106ec22a4f714484ce964b24b4f10b397c720e.tar.gz gnunet-d1106ec22a4f714484ce964b24b4f10b397c720e.zip |
- fixed _tunnel
- solved data struct visibility
Diffstat (limited to 'src/mesh/gnunet-service-mesh_connection.h')
-rw-r--r-- | src/mesh/gnunet-service-mesh_connection.h | 119 |
1 files changed, 71 insertions, 48 deletions
diff --git a/src/mesh/gnunet-service-mesh_connection.h b/src/mesh/gnunet-service-mesh_connection.h index d3f7b0b84..638bda162 100644 --- a/src/mesh/gnunet-service-mesh_connection.h +++ b/src/mesh/gnunet-service-mesh_connection.h | |||
@@ -41,6 +41,34 @@ extern "C" | |||
41 | 41 | ||
42 | #include "mesh_path.h" | 42 | #include "mesh_path.h" |
43 | #include "gnunet-service-mesh_channel.h" | 43 | #include "gnunet-service-mesh_channel.h" |
44 | #include "gnunet-service-mesh_peer.h" | ||
45 | |||
46 | |||
47 | /** | ||
48 | * All the states a connection can be in. | ||
49 | */ | ||
50 | enum MeshConnectionState | ||
51 | { | ||
52 | /** | ||
53 | * Uninitialized status, should never appear in operation. | ||
54 | */ | ||
55 | MESH_CONNECTION_NEW, | ||
56 | |||
57 | /** | ||
58 | * Connection create message sent, waiting for ACK. | ||
59 | */ | ||
60 | MESH_CONNECTION_SENT, | ||
61 | |||
62 | /** | ||
63 | * Connection ACK sent, waiting for ACK. | ||
64 | */ | ||
65 | MESH_CONNECTION_ACK, | ||
66 | |||
67 | /** | ||
68 | * Connection confirmed, ready to carry traffic. | ||
69 | */ | ||
70 | MESH_CONNECTION_READY, | ||
71 | }; | ||
44 | 72 | ||
45 | 73 | ||
46 | /** | 74 | /** |
@@ -203,7 +231,7 @@ GMC_shutdown (void); | |||
203 | */ | 231 | */ |
204 | struct MeshConnection * | 232 | struct MeshConnection * |
205 | GMC_new (const struct GNUNET_HashCode *cid, | 233 | GMC_new (const struct GNUNET_HashCode *cid, |
206 | struct MeshTunnel2 *t, | 234 | struct MeshTunnel3 *t, |
207 | struct MeshPeerPath *p, | 235 | struct MeshPeerPath *p, |
208 | unsigned int own_pos); | 236 | unsigned int own_pos); |
209 | 237 | ||
@@ -215,6 +243,9 @@ GMC_new (const struct GNUNET_HashCode *cid, | |||
215 | void | 243 | void |
216 | GMC_destroy (struct MeshConnection *c); | 244 | GMC_destroy (struct MeshConnection *c); |
217 | 245 | ||
246 | struct MeshConnection * | ||
247 | GMC_next (struct MeshConnection *c); | ||
248 | |||
218 | /** | 249 | /** |
219 | * Get the connection ID. | 250 | * Get the connection ID. |
220 | * | 251 | * |
@@ -226,10 +257,36 @@ const struct GNUNET_HashCode * | |||
226 | GMC_get_id (const struct MeshConnection *c); | 257 | GMC_get_id (const struct MeshConnection *c); |
227 | 258 | ||
228 | /** | 259 | /** |
229 | * Count connections in a DLL. | 260 | * Get the connection state. |
261 | * | ||
262 | * @param c Connection to get the state from. | ||
263 | * | ||
264 | * @return state of the connection. | ||
265 | */ | ||
266 | enum MeshConnectionState | ||
267 | GMC_get_state (const struct MeshConnection *c); | ||
268 | |||
269 | /** | ||
270 | * Get free buffer space in a connection. | ||
271 | * | ||
272 | * @param c Connection. | ||
273 | * @param fwd Is query about FWD traffic? | ||
274 | * | ||
275 | * @return Free buffer space [0 - max_msgs_queue/max_connections] | ||
276 | */ | ||
277 | unsigned int | ||
278 | GMC_get_buffer (struct MeshConnection *c, int fwd); | ||
279 | |||
280 | /** | ||
281 | * Get messages queued in a connection. | ||
282 | * | ||
283 | * @param c Connection. | ||
284 | * @param fwd Is query about FWD traffic? | ||
285 | * | ||
286 | * @return Number of messages queued. | ||
230 | */ | 287 | */ |
231 | unsigned int | 288 | unsigned int |
232 | GMC_count (const struct MeshConnection *head); | 289 | GMC_get_qn (struct MeshConnection *c, int fwd); |
233 | 290 | ||
234 | /** | 291 | /** |
235 | * Send FWD keepalive packets for a connection. | 292 | * Send FWD keepalive packets for a connection. |
@@ -273,51 +330,6 @@ GMC_notify_broken (struct MeshConnection *c, | |||
273 | struct GNUNET_PeerIdentity *my_full_id); | 330 | struct GNUNET_PeerIdentity *my_full_id); |
274 | 331 | ||
275 | /** | 332 | /** |
276 | * @brief Queue and pass message to core when possible. | ||
277 | * | ||
278 | * @param cls Closure (@c type dependant). It will be used by queue_send to | ||
279 | * build the message to be sent if not already prebuilt. | ||
280 | * @param type Type of the message, 0 for a raw message. | ||
281 | * @param size Size of the message. | ||
282 | * @param c Connection this message belongs to (cannot be NULL). | ||
283 | * @param ch Channel this message belongs to, if applicable (otherwise NULL). | ||
284 | * @param fwd Is this a message going root->dest? (FWD ACK are NOT FWD!) | ||
285 | */ | ||
286 | void | ||
287 | GMC_queue_add (void* cls, | ||
288 | uint16_t type, | ||
289 | size_t size, | ||
290 | struct MeshConnection* c, | ||
291 | struct MeshChannel* ch, | ||
292 | int fwd); | ||
293 | |||
294 | |||
295 | /** | ||
296 | * Free a transmission that was already queued with all resources | ||
297 | * associated to the request. | ||
298 | * | ||
299 | * @param queue Queue handler to cancel. | ||
300 | * @param clear_cls Is it necessary to free associated cls? | ||
301 | */ | ||
302 | void | ||
303 | GMC_queue_destroy (struct MeshPeerQueue *queue, int clear_cls); | ||
304 | |||
305 | |||
306 | /** | ||
307 | * Core callback to write a queued packet to core buffer | ||
308 | * | ||
309 | * @param cls Closure (peer info). | ||
310 | * @param size Number of bytes available in buf. | ||
311 | * @param buf Where the to write the message. | ||
312 | * | ||
313 | * @return number of bytes written to buf | ||
314 | */ | ||
315 | size_t | ||
316 | GMC_queue_send (void *cls, size_t size, void *buf); | ||
317 | |||
318 | |||
319 | |||
320 | /** | ||
321 | * Is this peer the first one on the connection? | 333 | * Is this peer the first one on the connection? |
322 | * | 334 | * |
323 | * @param c Connection. | 335 | * @param c Connection. |
@@ -356,6 +368,17 @@ GMC_send_prebuilt_message (const struct GNUNET_MessageHeader *message, | |||
356 | struct MeshChannel *ch, | 368 | struct MeshChannel *ch, |
357 | int fwd); | 369 | int fwd); |
358 | 370 | ||
371 | /** | ||
372 | * Send a message to all peers in this connection that the connection | ||
373 | * is no longer valid. | ||
374 | * | ||
375 | * If some peer should not receive the message, it should be zero'ed out | ||
376 | * before calling this function. | ||
377 | * | ||
378 | * @param c The connection whose peers to notify. | ||
379 | */ | ||
380 | void | ||
381 | GMC_send_destroy (struct MeshConnection *c); | ||
359 | 382 | ||
360 | #if 0 /* keep Emacsens' auto-indent happy */ | 383 | #if 0 /* keep Emacsens' auto-indent happy */ |
361 | { | 384 | { |