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
31 #include "gnunet_util_lib.h"
32 #include "gnunet-service-cadet-new.h"
33 #include "gnunet-service-cadet-new_peer.h"
34 #include "cadet_protocol.h"
38 * Function called to notify tunnel about change in our readyness.
41 * @param is_ready #GNUNET_YES if the connection is now ready for transmission,
42 * #GNUNET_NO if the connection is no longer ready for transmission
45 (*GCC_ReadyCallback)(void *cls,
50 * Destroy a connection.
52 * @param cc connection to destroy
55 GCC_destroy (struct CadetConnection *cc);
59 * Create a connection to @a destination via @a path and
60 * notify @a cb whenever we are ready for more data.
62 * @param destination where to go
63 * @param path which path to take (may not be the full path)
64 * @param ct which tunnel uses this connection
65 * @param ready_cb function to call when ready to transmit
66 * @param ready_cb_cls closure for @a cb
67 * @return handle to the connection
69 struct CadetConnection *
70 GCC_create (struct CadetPeer *destination,
71 struct CadetPeerPath *path,
72 struct CadetTConnection *ct,
73 GCC_ReadyCallback ready_cb,
78 * Create a connection to @a destination via @a path and
79 * notify @a cb whenever we are ready for more data. This
80 * is an inbound tunnel, so we must use the existing @a cid
82 * @param destination where to go
83 * @param path which path to take (may not be the full path)
84 * @param ct which tunnel uses this connection
85 * @param ready_cb function to call when ready to transmit
86 * @param ready_cb_cls closure for @a cb
87 * @return handle to the connection
89 struct CadetConnection *
90 GCC_create_inbound (struct CadetPeer *destination,
91 struct CadetPeerPath *path,
92 struct CadetTConnection *ct,
93 const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid,
94 GCC_ReadyCallback ready_cb,
99 * Transmit message @a msg via connection @a cc. Must only be called
100 * (once) after the connection has signalled that it is ready via the
101 * `ready_cb`. Clients can also use #GCC_is_ready() to check if the
102 * connection is right now ready for transmission.
104 * @param cc connection identification
105 * @param env envelope with message to transmit;
106 * the #GNUNET_MQ_notify_send() must not have yet been used
107 * for the envelope. Also, the message better match the
108 * connection identifier of this connection...
111 GCC_transmit (struct CadetConnection *cc,
112 struct GNUNET_MQ_Envelope *env);
116 * A CREATE_ACK was received for this connection, process it.
118 * @param cc the connection that got the ACK.
121 GCC_handle_connection_create_ack (struct CadetConnection *cc);
125 * We got a #GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE for a
126 * connection that we already have. Either our ACK got lost
127 * or something is fishy. Consider retransmitting the ACK.
129 * @param cc connection that got the duplicate CREATE
132 GCC_handle_duplicate_create (struct CadetConnection *cc);
138 * @param cc connection that received encrypted message
139 * @param msg the key exchange message
142 GCC_handle_kx (struct CadetConnection *cc,
143 const struct GNUNET_CADET_TunnelKeyExchangeMessage *msg);
147 * Handle encrypted message.
149 * @param cc connection that received encrypted message
150 * @param msg the encrypted message to decrypt
153 GCC_handle_encrypted (struct CadetConnection *cc,
154 const struct GNUNET_CADET_TunnelEncryptedMessage *msg);
158 * Return the tunnel associated with this connection.
160 * @param cc connection to query
161 * @return corresponding entry in the tunnel's connection list
163 struct CadetTConnection *
164 GCC_get_ct (struct CadetConnection *cc);
168 * Obtain the path used by this connection.
170 * @param cc connection
171 * @return path to @a cc
173 struct CadetPeerPath *
174 GCC_get_path (struct CadetConnection *cc);
178 * Obtain unique ID for the connection.
180 * @param cc connection.
181 * @return unique number of the connection
183 const struct GNUNET_CADET_ConnectionTunnelIdentifier *
184 GCC_get_id (struct CadetConnection *cc);
188 * Get a (static) string for a connection.
190 * @param cc Connection.
193 GCC_2s (const struct CadetConnection *cc);
197 * Log connection info.
199 * @param cc connection
200 * @param level Debug level to use.
203 GCC_debug (struct CadetConnection *cc,
204 enum GNUNET_ErrorType level);