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 * An ACK was received for this connection, process it.
118 * @param cc the connection that got the ACK.
121 GCC_handle_connection_ack (struct CadetConnection *cc);
127 * @param cc connection that received encrypted message
128 * @param msg the key exchange message
131 GCC_handle_kx (struct CadetConnection *cc,
132 const struct GNUNET_CADET_TunnelKeyExchangeMessage *msg);
136 * Handle encrypted message.
138 * @param cc connection that received encrypted message
139 * @param msg the encrypted message to decrypt
142 GCC_handle_encrypted (struct CadetConnection *cc,
143 const struct GNUNET_CADET_TunnelEncryptedMessage *msg);
147 * Return the tunnel associated with this connection.
149 * @param cc connection to query
150 * @return corresponding entry in the tunnel's connection list
152 struct CadetTConnection *
153 GCC_get_ct (struct CadetConnection *cc);
157 * Obtain the path used by this connection.
159 * @param cc connection
160 * @return path to @a cc
162 struct CadetPeerPath *
163 GCC_get_path (struct CadetConnection *cc);
167 * Obtain unique ID for the connection.
169 * @param cc connection.
170 * @return unique number of the connection
172 const struct GNUNET_CADET_ConnectionTunnelIdentifier *
173 GCC_get_id (struct CadetConnection *cc);
177 * Get a (static) string for a connection.
179 * @param cc Connection.
182 GCC_2s (const struct CadetConnection *cc);
186 * Log connection info.
188 * @param cc connection
189 * @param level Debug level to use.
192 GCC_debug (struct CadetConnection *cc,
193 enum GNUNET_ErrorType level);