aboutsummaryrefslogtreecommitdiff
path: root/src/mesh/gnunet-service-mesh_connection.h
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2013-10-09 01:06:44 +0000
committerBart Polot <bart@net.in.tum.de>2013-10-09 01:06:44 +0000
commitd1106ec22a4f714484ce964b24b4f10b397c720e (patch)
treea88d297d01a88ad0afa348afffab886e8d02a37f /src/mesh/gnunet-service-mesh_connection.h
parent7c31fa06ba410b36d4fadaeea962fc0dae4da0b5 (diff)
downloadgnunet-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.h119
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 */
50enum 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 */
204struct MeshConnection * 232struct MeshConnection *
205GMC_new (const struct GNUNET_HashCode *cid, 233GMC_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,
215void 243void
216GMC_destroy (struct MeshConnection *c); 244GMC_destroy (struct MeshConnection *c);
217 245
246struct MeshConnection *
247GMC_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 *
226GMC_get_id (const struct MeshConnection *c); 257GMC_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 */
266enum MeshConnectionState
267GMC_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 */
277unsigned int
278GMC_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 */
231unsigned int 288unsigned int
232GMC_count (const struct MeshConnection *head); 289GMC_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 */
286void
287GMC_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 */
302void
303GMC_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 */
315size_t
316GMC_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 */
380void
381GMC_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{