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.c
25 * @author Bartlomiej Polot
26 * @author Christian Grothoff
29 #include "gnunet-service-cadet-new_channel.h"
30 #include "gnunet-service-cadet-new_paths.h"
31 #include "gnunet-service-cadet-new_peer.h"
32 #include "gnunet-service-cadet-new_connection.h"
36 * Low-level connection to a destination.
38 struct CadetConnection
41 * To which peer does this connection go?
43 struct CadetPeer *destination;
46 * Path we are using to our destination.
48 struct CadetPeerPath *path;
51 * Function to call once we are ready to transmit.
53 GNUNET_SCHEDULER_TaskCallback ready_cb;
56 * Closure for @e ready_cb.
61 * Offset of our @e destination in @e path.
69 * Is the given connection currently ready for transmission?
71 * @param cc connection to transmit on
72 * @return #GNUNET_YES if we could transmit
75 GCC_is_ready (struct CadetConnection *cc)
83 * Destroy a connection.
85 * @param cc connection to destroy
88 GCC_destroy (struct CadetConnection *cc)
90 GCPP_del_connection (cc->path,
93 GNUNET_assert (0); // FIXME: incomplete implementation!
99 * Create a connection to @a destination via @a path and
100 * notify @a cb whenever we are ready for more data.
102 * @param destination where to go
103 * @param path which path to take (may not be the full path)
104 * @param ready_cb function to call when ready to transmit
105 * @param ready_cb_cls closure for @a cb
107 struct CadetConnection *
108 GCC_create (struct CadetPeer *destination,
109 struct CadetPeerPath *path,
110 GNUNET_SCHEDULER_TaskCallback ready_cb,
113 struct CadetConnection *cc;
116 off = GCPP_find_peer (path,
118 GNUNET_assert (UINT_MAX > off);
120 GNUNET_assert (0); // fIXME: unfinished
122 cc = GNUNET_new (struct CadetConnection);
125 GCPP_add_connection (path,
128 for (unsigned int i=0;i<off;i++)
130 // FIXME: remember existence of this connection with
131 // ALL peers on the path!
132 // (and remove on destruction of connection!)
139 * Transmit message @a msg via connection @a cc. Must only be called
140 * (once) after the connection has signalled that it is ready via the
141 * `ready_cb`. Clients can also use #GCC_is_ready() to check if the
142 * connection is right now ready for transmission.
144 * @param cc connection identification
145 * @param msg message to transmit
148 GCC_transmit (struct CadetConnection *cc,
149 const struct GNUNET_MessageHeader *msg)
151 GNUNET_assert (0); // FIXME
156 * Obtain the path used by this connection.
158 * @param cc connection
159 * @return path to @a cc
161 struct CadetPeerPath *
162 GCC_get_path (struct CadetConnection *cc)
169 * Obtain unique ID for the connection.
171 * @param cc connection.
172 * @return unique number of the connection
174 const struct GNUNET_CADET_ConnectionTunnelIdentifier *
175 GCC_get_id (struct CadetConnection *cc)
177 GNUNET_assert (0); // FIXME
183 * Log connection info.
185 * @param cc connection
186 * @param level Debug level to use.
189 GCC_debug (struct CadetConnection *cc,
190 enum GNUNET_ErrorType level)