diff options
Diffstat (limited to 'src/cadet/gnunet-service-cadet_channel.h')
-rw-r--r-- | src/cadet/gnunet-service-cadet_channel.h | 304 |
1 files changed, 0 insertions, 304 deletions
diff --git a/src/cadet/gnunet-service-cadet_channel.h b/src/cadet/gnunet-service-cadet_channel.h deleted file mode 100644 index 6d691cafc..000000000 --- a/src/cadet/gnunet-service-cadet_channel.h +++ /dev/null | |||
@@ -1,304 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2001-2017 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file cadet/gnunet-service-cadet_channel.h | ||
23 | * @brief GNUnet CADET service with encryption | ||
24 | * @author Bartlomiej Polot | ||
25 | * @author Christian Grothoff | ||
26 | */ | ||
27 | #ifndef GNUNET_SERVICE_CADET_CHANNEL_H | ||
28 | #define GNUNET_SERVICE_CADET_CHANNEL_H | ||
29 | |||
30 | #include "gnunet-service-cadet.h" | ||
31 | #include "gnunet-service-cadet_peer.h" | ||
32 | #include "cadet_protocol.h" | ||
33 | |||
34 | |||
35 | /** | ||
36 | * A channel is a bidirectional connection between two CADET | ||
37 | * clients. Communication can be reliable, unreliable, in-order | ||
38 | * or out-of-order. One client is the "local" client, this | ||
39 | * one initiated the connection. The other client is the | ||
40 | * "incoming" client, this one listened on a port to accept | ||
41 | * the connection from the "local" client. | ||
42 | */ | ||
43 | struct CadetChannel; | ||
44 | |||
45 | |||
46 | /** | ||
47 | * Hash the @a port and @a initiator and @a listener to | ||
48 | * calculate the "challenge" @a h_port we send to the other | ||
49 | * peer on #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN. | ||
50 | * | ||
51 | * @param[out] h_port set to the hash of @a port, @a initiator and @a listener | ||
52 | * @param port cadet port, as seen by CADET clients | ||
53 | * @param listener peer that is listining on @a port | ||
54 | */ | ||
55 | void | ||
56 | GCCH_hash_port (struct GNUNET_HashCode *h_port, | ||
57 | const struct GNUNET_HashCode *port, | ||
58 | const struct GNUNET_PeerIdentity *listener); | ||
59 | |||
60 | /** | ||
61 | * Check if type of message is the one to drop. | ||
62 | * @param ch CadetChannel to check for message type to drop. | ||
63 | * @param message GNUNET_MessageHeader to compare the type with. | ||
64 | */ | ||
65 | int | ||
66 | GCCH_is_type_to_drop (struct CadetChannel *ch, const struct | ||
67 | GNUNET_MessageHeader *message); | ||
68 | |||
69 | /** | ||
70 | * Check if type of message is the one to drop. | ||
71 | * @param ch CadetChannel to assign type to drop. | ||
72 | * @param message GNUNET_CADET_RequestDropCadetMessage to get the type from. | ||
73 | */ | ||
74 | void | ||
75 | GCCH_assign_type_to_drop (struct CadetChannel *ch, const struct | ||
76 | GNUNET_CADET_RequestDropCadetMessage *message); | ||
77 | |||
78 | /** | ||
79 | * Get the static string for identification of the channel. | ||
80 | * | ||
81 | * @param ch Channel. | ||
82 | * | ||
83 | * @return Static string with the channel IDs. | ||
84 | */ | ||
85 | const char * | ||
86 | GCCH_2s (const struct CadetChannel *ch); | ||
87 | |||
88 | |||
89 | /** | ||
90 | * Log channel info. | ||
91 | * | ||
92 | * @param ch Channel. | ||
93 | * @param level Debug level to use. | ||
94 | */ | ||
95 | void | ||
96 | GCCH_debug (struct CadetChannel *ch, | ||
97 | enum GNUNET_ErrorType level); | ||
98 | |||
99 | |||
100 | /** | ||
101 | * Get the channel's public ID. | ||
102 | * | ||
103 | * @param ch Channel. | ||
104 | * | ||
105 | * @return ID used to identify the channel with the remote peer. | ||
106 | */ | ||
107 | struct GNUNET_CADET_ChannelTunnelNumber | ||
108 | GCCH_get_id (const struct CadetChannel *ch); | ||
109 | |||
110 | |||
111 | /** | ||
112 | * Create a new channel. | ||
113 | * | ||
114 | * @param owner local client owning the channel | ||
115 | * @param owner_id local chid of this channel at the @a owner | ||
116 | * @param destination peer to which we should build the channel | ||
117 | * @param port desired port at @a destination | ||
118 | * @param options options for the channel | ||
119 | * @return handle to the new channel | ||
120 | */ | ||
121 | struct CadetChannel * | ||
122 | GCCH_channel_local_new (struct CadetClient *owner, | ||
123 | struct GNUNET_CADET_ClientChannelNumber owner_id, | ||
124 | struct CadetPeer *destination, | ||
125 | const struct GNUNET_HashCode *port, | ||
126 | uint32_t options); | ||
127 | |||
128 | |||
129 | /** | ||
130 | * A client is bound to the port that we have a channel | ||
131 | * open to. Send the acknowledgement for the connection | ||
132 | * request and establish the link with the client. | ||
133 | * | ||
134 | * @param ch open incoming channel | ||
135 | * @param c client listening on the respective @a port | ||
136 | * @param port port number @a c is listening on | ||
137 | */ | ||
138 | void | ||
139 | GCCH_bind (struct CadetChannel *ch, | ||
140 | struct CadetClient *c, | ||
141 | const struct GNUNET_HashCode *port); | ||
142 | |||
143 | |||
144 | /** | ||
145 | * Destroy locally created channel. Called by the | ||
146 | * local client, so no need to tell the client. | ||
147 | * | ||
148 | * @param ch channel to destroy | ||
149 | * @param c client that caused the destruction | ||
150 | * @param ccn client number of the client @a c | ||
151 | */ | ||
152 | void | ||
153 | GCCH_channel_local_destroy (struct CadetChannel *ch, | ||
154 | struct CadetClient *c, | ||
155 | struct GNUNET_CADET_ClientChannelNumber ccn); | ||
156 | |||
157 | |||
158 | /** | ||
159 | * Function called once and only once after a channel was bound | ||
160 | * to its tunnel via #GCT_add_channel() is ready for transmission. | ||
161 | * Note that this is only the case for channels that this peer | ||
162 | * initiates, as for incoming channels we assume that they are | ||
163 | * ready for transmission immediately upon receiving the open | ||
164 | * message. Used to bootstrap the #GCT_send() process. | ||
165 | * | ||
166 | * @param ch the channel for which the tunnel is now ready | ||
167 | */ | ||
168 | void | ||
169 | GCCH_tunnel_up (struct CadetChannel *ch); | ||
170 | |||
171 | |||
172 | /** | ||
173 | * Create a new channel based on a request coming in over the network. | ||
174 | * | ||
175 | * @param t tunnel to the remote peer | ||
176 | * @param chid identifier of this channel in the tunnel | ||
177 | * @param origin peer to who initiated the channel | ||
178 | * @param h_port hash of desired local port | ||
179 | * @param options options for the channel | ||
180 | * @return handle to the new channel | ||
181 | */ | ||
182 | struct CadetChannel * | ||
183 | GCCH_channel_incoming_new (struct CadetTunnel *t, | ||
184 | struct GNUNET_CADET_ChannelTunnelNumber chid, | ||
185 | const struct GNUNET_HashCode *h_port, | ||
186 | uint32_t options); | ||
187 | |||
188 | |||
189 | /** | ||
190 | * We got a #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN message again for | ||
191 | * this channel. If the binding was successful, (re)transmit the | ||
192 | * #GNUNET_MESSAGE_TYPE_CADET_CHANNEL_OPEN_ACK. | ||
193 | * | ||
194 | * @param ch channel that got the duplicate open | ||
195 | * @param cti identifier of the connection that delivered the message | ||
196 | */ | ||
197 | void | ||
198 | GCCH_handle_duplicate_open (struct CadetChannel *ch, | ||
199 | const struct | ||
200 | GNUNET_CADET_ConnectionTunnelIdentifier *cti); | ||
201 | |||
202 | |||
203 | /** | ||
204 | * We got payload data for a channel. Pass it on to the client. | ||
205 | * | ||
206 | * @param ch channel that got data | ||
207 | * @param cti identifier of the connection that delivered the message | ||
208 | * @param msg message that was received | ||
209 | */ | ||
210 | void | ||
211 | GCCH_handle_channel_plaintext_data (struct CadetChannel *ch, | ||
212 | const struct | ||
213 | GNUNET_CADET_ConnectionTunnelIdentifier *cti, | ||
214 | const struct | ||
215 | GNUNET_CADET_ChannelAppDataMessage *msg); | ||
216 | |||
217 | |||
218 | /** | ||
219 | * We got an acknowledgement for payload data for a channel. | ||
220 | * Possibly resume transmissions. | ||
221 | * | ||
222 | * @param ch channel that got the ack | ||
223 | * @param cti identifier of the connection that delivered the message | ||
224 | * @param ack details about what was received | ||
225 | */ | ||
226 | void | ||
227 | GCCH_handle_channel_plaintext_data_ack (struct CadetChannel *ch, | ||
228 | const struct | ||
229 | GNUNET_CADET_ConnectionTunnelIdentifier | ||
230 | *cti, | ||
231 | const struct | ||
232 | GNUNET_CADET_ChannelDataAckMessage *ack); | ||
233 | |||
234 | |||
235 | /** | ||
236 | * We got an acknowledgement for the creation of the channel | ||
237 | * (the port is open on the other side). Begin transmissions. | ||
238 | * | ||
239 | * @param ch channel to destroy | ||
240 | * @param cti identifier of the connection that delivered the message, | ||
241 | * NULL if the ACK was inferred because we got payload or are on loopback | ||
242 | * @param port port number (needed to verify receiver knows the port) | ||
243 | */ | ||
244 | void | ||
245 | GCCH_handle_channel_open_ack (struct CadetChannel *ch, | ||
246 | const struct | ||
247 | GNUNET_CADET_ConnectionTunnelIdentifier *cti, | ||
248 | const struct GNUNET_HashCode *port); | ||
249 | |||
250 | |||
251 | /** | ||
252 | * Destroy channel, based on the other peer closing the | ||
253 | * connection. Also needs to remove this channel from | ||
254 | * the tunnel. | ||
255 | * | ||
256 | * FIXME: need to make it possible to defer destruction until we have | ||
257 | * received all messages up to the destroy, and right now the destroy | ||
258 | * message (and this API) fails to give is the information we need! | ||
259 | * | ||
260 | * FIXME: also need to know if the other peer got a destroy from | ||
261 | * us before! | ||
262 | * | ||
263 | * @param ch channel to destroy | ||
264 | * @param cti identifier of the connection that delivered the message, | ||
265 | * NULL during shutdown | ||
266 | */ | ||
267 | void | ||
268 | GCCH_handle_remote_destroy (struct CadetChannel *ch, | ||
269 | const struct | ||
270 | GNUNET_CADET_ConnectionTunnelIdentifier *cti); | ||
271 | |||
272 | |||
273 | /** | ||
274 | * Handle data given by a client. | ||
275 | * | ||
276 | * Check whether the client is allowed to send in this tunnel, save if | ||
277 | * channel is reliable and send an ACK to the client if there is still | ||
278 | * buffer space in the tunnel. | ||
279 | * | ||
280 | * @param ch Channel. | ||
281 | * @param sender_ccn ccn of the sender | ||
282 | * @param buf payload to transmit. | ||
283 | * @param buf_len number of bytes in @a buf | ||
284 | * @return #GNUNET_OK if everything goes well, | ||
285 | * #GNUNET_SYSERR in case of an error. | ||
286 | */ | ||
287 | int | ||
288 | GCCH_handle_local_data (struct CadetChannel *ch, | ||
289 | struct GNUNET_CADET_ClientChannelNumber sender_ccn, | ||
290 | const char *buf, | ||
291 | size_t buf_len); | ||
292 | |||
293 | |||
294 | /** | ||
295 | * Handle ACK from client on local channel. | ||
296 | * | ||
297 | * @param ch channel to destroy | ||
298 | * @param client_ccn ccn of the client sending the ack | ||
299 | */ | ||
300 | void | ||
301 | GCCH_handle_local_ack (struct CadetChannel *ch, | ||
302 | struct GNUNET_CADET_ClientChannelNumber client_ccn); | ||
303 | |||
304 | #endif | ||