3 This file is part of GNUnet.
4 Copyright (C) 2001-2017 GNUnet e.V.
6 GNUnet is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published
8 by the Free Software Foundation; either version 3, or (at your
9 option) any later version.
11 GNUnet is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNUnet; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
23 * @file cadet/gnunet-service-cadet-new_connection.h
25 * @author Bartlomiej Polot
26 * @author Christian Grothoff
28 #ifndef GNUNET_SERVICE_CADET_CONNECTION_H
29 #define GNUNET_SERVICE_CADET_CONNECTION_H
33 #include "gnunet_util_lib.h"
34 #include "gnunet-service-cadet-new.h"
35 #include "gnunet-service-cadet-new_peer.h"
36 #include "cadet_protocol.h"
39 * Is the given connection currently ready for transmission?
41 * @param cc connection to transmit on
42 * @return #GNUNET_YES if we could transmit
45 GCC_is_ready (struct CadetConnection *cc);
49 * Destroy a connection.
51 * @param cc connection to destroy
54 GCC_destroy (struct CadetConnection *cc);
58 * Create a connection to @a destination via @a path and
59 * notify @a cb whenever we are ready for more data.
61 * @param destination where to go
62 * @param path which path to take (may not be the full path)
63 * @param ct which tunnel uses this connection
64 * @param ready_cb function to call when ready to transmit
65 * @param ready_cb_cls closure for @a cb
66 * @return handle to the connection
68 struct CadetConnection *
69 GCC_create (struct CadetPeer *destination,
70 struct CadetPeerPath *path,
71 struct CadetTConnection *ct,
72 GNUNET_SCHEDULER_TaskCallback ready_cb,
77 * Transmit message @a msg via connection @a cc. Must only be called
78 * (once) after the connection has signalled that it is ready via the
79 * `ready_cb`. Clients can also use #GCC_is_ready() to check if the
80 * connection is right now ready for transmission.
82 * @param cc connection identification
83 * @param env envelope with message to transmit;
84 * the #GNUNET_MQ_notify_send() must not have yet been used
85 * for the envelope. Also, the message better match the
86 * connection identifier of this connection...
89 GCC_transmit (struct CadetConnection *cc,
90 struct GNUNET_MQ_Envelope *env);
94 * An ACK was received for this connection, process it.
96 * @param cc the connection that got the ACK.
99 GCC_handle_connection_ack (struct CadetConnection *cc);
105 * @param cc connection that received encrypted message
106 * @param msg the key exchange message
109 GCC_handle_kx (struct CadetConnection *cc,
110 const struct GNUNET_CADET_TunnelKeyExchangeMessage *msg);
114 * Handle encrypted message.
116 * @param cc connection that received encrypted message
117 * @param msg the encrypted message to decrypt
120 GCC_handle_encrypted (struct CadetConnection *cc,
121 const struct GNUNET_CADET_TunnelEncryptedMessage *msg);
125 * Return the tunnel associated with this connection.
127 * @param cc connection to query
128 * @return corresponding entry in the tunnel's connection list
130 struct CadetTConnection *
131 GCC_get_ct (struct CadetConnection *cc);
135 * Obtain the path used by this connection.
137 * @param cc connection
138 * @return path to @a cc
140 struct CadetPeerPath *
141 GCC_get_path (struct CadetConnection *cc);
145 * Obtain unique ID for the connection.
147 * @param cc connection.
148 * @return unique number of the connection
150 const struct GNUNET_CADET_ConnectionTunnelIdentifier *
151 GCC_get_id (struct CadetConnection *cc);
155 * Log connection info.
157 * @param cc connection
158 * @param level Debug level to use.
161 GCC_debug (struct CadetConnection *cc,
162 enum GNUNET_ErrorType level);