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"
37 * Is the given connection currently ready for transmission?
39 * @param cc connection to transmit on
40 * @return #GNUNET_YES if we could transmit
43 GCC_is_ready (struct CadetConnection *cc);
47 * Destroy a connection.
49 * @param cc connection to destroy
52 GCC_destroy (struct CadetConnection *cc);
56 * Create a connection to @a destination via @a path and
57 * notify @a cb whenever we are ready for more data.
59 * @param destination where to go
60 * @param path which path to take (may not be the full path)
61 * @param ready_cb function to call when ready to transmit
62 * @param ready_cb_cls closure for @a cb
63 * @return handle to the connection
65 struct CadetConnection *
66 GCC_create (struct CadetPeer *destination,
67 struct CadetPeerPath *path,
68 GNUNET_SCHEDULER_TaskCallback ready_cb,
73 * Transmit message @a msg via connection @a cc. Must only be called
74 * (once) after the connection has signalled that it is ready via the
75 * `ready_cb`. Clients can also use #GCC_is_ready() to check if the
76 * connection is right now ready for transmission.
78 * @param cc connection identification
79 * @param env envelope with message to transmit;
80 * the #GNUNET_MQ_notify_send() must not have yet been used
81 * for the envelope. Also, the message better match the
82 * connection identifier of this connection...
85 GCC_transmit (struct CadetConnection *cc,
86 struct GNUNET_MQ_Envelope *env);
90 * Obtain the path used by this connection.
92 * @param cc connection
93 * @return path to @a cc
95 struct CadetPeerPath *
96 GCC_get_path (struct CadetConnection *cc);
100 * Obtain unique ID for the connection.
102 * @param cc connection.
103 * @return unique number of the connection
105 const struct GNUNET_CADET_ConnectionTunnelIdentifier *
106 GCC_get_id (struct CadetConnection *cc);
110 * Get the connection ID as a full hash.
112 * @param cc Connection to get the ID from.
113 * @return full hash ID of the connection.
114 * @deprecated try to replace use of full hash codes eventually...
116 const struct GNUNET_HashCode *
117 GCC_get_h (const struct CadetConnection *cc);
121 * Log connection info.
123 * @param cc connection
124 * @param level Debug level to use.
127 GCC_debug (struct CadetConnection *cc,
128 enum GNUNET_ErrorType level);