more rename festivities
[oweals/gnunet.git] / src / cadet / gnunet-service-cadet-new_connection.h
1
2 /*
3      This file is part of GNUnet.
4      Copyright (C) 2001-2017 GNUnet e.V.
5
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.
10
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.
15
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.
20 */
21
22 /**
23  * @file cadet/gnunet-service-cadet-new_connection.h
24  * @brief
25  * @author Bartlomiej Polot
26  * @author Christian Grothoff
27  */
28 #ifndef GNUNET_SERVICE_CADET_CONNECTION_H
29 #define GNUNET_SERVICE_CADET_CONNECTION_H
30
31 #define NEW_CADET
32
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"
37
38 /**
39  * Is the given connection currently ready for transmission?
40  *
41  * @param cc connection to transmit on
42  * @return #GNUNET_YES if we could transmit
43  */
44 int
45 GCC_is_ready (struct CadetConnection *cc);
46
47
48 /**
49  * Destroy a connection.
50  *
51  * @param cc connection to destroy
52  */
53 void
54 GCC_destroy (struct CadetConnection *cc);
55
56
57 /**
58  * Create a connection to @a destination via @a path and
59  * notify @a cb whenever we are ready for more data.
60  *
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
67  */
68 struct CadetConnection *
69 GCC_create (struct CadetPeer *destination,
70             struct CadetPeerPath *path,
71             struct CadetTConnection *ct,
72             GNUNET_SCHEDULER_TaskCallback ready_cb,
73             void *ready_cb_cls);
74
75
76 /**
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.
81  *
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...
87  */
88 void
89 GCC_transmit (struct CadetConnection *cc,
90               struct GNUNET_MQ_Envelope *env);
91
92
93 /**
94  * An ACK was received for this connection, process it.
95  *
96  * @param cc the connection that got the ACK.
97  */
98 void
99 GCC_handle_connection_ack (struct CadetConnection *cc);
100
101
102 /**
103  * Handle KX message.
104  *
105  * @param cc connection that received encrypted message
106  * @param msg the key exchange message
107  */
108 void
109 GCC_handle_kx (struct CadetConnection *cc,
110                const struct GNUNET_CADET_TunnelKeyExchangeMessage *msg);
111
112
113 /**
114  * Handle encrypted message.
115  *
116  * @param cc connection that received encrypted message
117  * @param msg the encrypted message to decrypt
118  */
119 void
120 GCC_handle_encrypted (struct CadetConnection *cc,
121                       const struct GNUNET_CADET_TunnelEncryptedMessage *msg);
122
123
124 /**
125  * Return the tunnel associated with this connection.
126  *
127  * @param cc connection to query
128  * @return corresponding entry in the tunnel's connection list
129  */
130 struct CadetTConnection *
131 GCC_get_ct (struct CadetConnection *cc);
132
133
134 /**
135  * Obtain the path used by this connection.
136  *
137  * @param cc connection
138  * @return path to @a cc
139  */
140 struct CadetPeerPath *
141 GCC_get_path (struct CadetConnection *cc);
142
143
144 /**
145  * Obtain unique ID for the connection.
146  *
147  * @param cc connection.
148  * @return unique number of the connection
149  */
150 const struct GNUNET_CADET_ConnectionTunnelIdentifier *
151 GCC_get_id (struct CadetConnection *cc);
152
153
154 /**
155  * Log connection info.
156  *
157  * @param cc connection
158  * @param level Debug level to use.
159  */
160 void
161 GCC_debug (struct CadetConnection *cc,
162            enum GNUNET_ErrorType level);
163
164
165 #endif