aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_transport_communication_service.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-07-06 23:09:59 +0000
committerChristian Grothoff <christian@grothoff.org>2016-07-06 23:09:59 +0000
commitaeece360025012e270a30d4cd174a60fca30af38 (patch)
treec011ee6f932d36971feaf1b70ea9313129bcd987 /src/include/gnunet_transport_communication_service.h
parentf8de70cbb50e5821fcbb5f2303ca8e1eae12a348 (diff)
downloadgnunet-aeece360025012e270a30d4cd174a60fca30af38.tar.gz
gnunet-aeece360025012e270a30d4cd174a60fca30af38.zip
-skeletons for transport-ng
Diffstat (limited to 'src/include/gnunet_transport_communication_service.h')
-rw-r--r--src/include/gnunet_transport_communication_service.h228
1 files changed, 228 insertions, 0 deletions
diff --git a/src/include/gnunet_transport_communication_service.h b/src/include/gnunet_transport_communication_service.h
new file mode 100644
index 000000000..aa8cc1ba1
--- /dev/null
+++ b/src/include/gnunet_transport_communication_service.h
@@ -0,0 +1,228 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2009-2016 GNUnet e.V.
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 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 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20
21/**
22 * @author Christian Grothoff
23 *
24 * @file
25 * API of the transport service towards the communicator processes.
26 *
27 * @defgroup transport TRANSPORT service
28 * Low-level communication with other peers
29 *
30 * @see [Documentation](https://gnunet.org/transport-service)
31 *
32 * @{
33 */
34
35#ifndef GNUNET_TRANSPORT_COMMUNICATION_SERVICE_H
36#define GNUNET_TRANSPORT_COMMUNICATION_SERVICE_H
37
38#ifdef __cplusplus
39extern "C"
40{
41#if 0 /* keep Emacsens' auto-indent happy */
42}
43#endif
44#endif
45
46#include "gnunet_util_lib.h"
47
48/**
49 * Version number of the transport communication API.
50 */
51#define GNUNET_TRANSPORT_COMMUNICATION_VERSION 0x00000000
52
53
54/**
55 * Function called by the transport service to initialize a
56 * message queue given address information about another peer.
57 *
58 * @param cls closure
59 * @param peer identity of the other peer
60 * @param address where to send the message, human-readable
61 * communicator-specific format, 0-terminated, UTF-8
62 * @return NULL if the provided address is invalid, otherwise an MQ to
63 * send messages to that peer
64 */
65typedef struct GNUNET_MQ_Handle *
66(*GNUNET_TRANSPORT_CommunicatorMqInit) (void *cls,
67 const struct GNUNET_PeerIdentity *peer,
68 const void *address);
69
70
71/**
72 * Opaque handle to the transport service for communicators.
73 */
74struct GNUNET_TRANSPORT_CommunicatorHandle;
75
76
77/**
78 * Connect to the transport service.
79 *
80 * @param cfg configuration to use
81 * @param name name of the communicator that is connecting
82 * @param mtu maximum message size supported by communicator, 0 if
83 * sending is not supported
84 * @param mq_init function to call to initialize a message queue given
85 * the address of another peer, can be NULL if the
86 * communicator only supports receiving messages
87 * @param mq_init_cls closure for @a mq_init
88 * @return NULL on error
89 */
90struct GNUNET_TRANSPORT_CommunicatorHandle *
91GNUNET_TRANSPORT_communicator_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
92 const char *name,
93 size_t mtu,
94 GNUNET_TRANSPORT_CommunicatorMqInit mq_init,
95 void *mq_init_cls);
96
97
98/**
99 * Disconnect from the transport service.
100 *
101 * @param ch handle returned from connect
102 */
103void
104GNUNET_TRANSPORT_communicator_disconnect (struct GNUNET_TRANSPORT_CommunicatorHandle *ch);
105
106
107/* ************************* Receiving *************************** */
108
109/**
110 * Function called to notify communicator that we have received
111 * and processed the message.
112 *
113 * @param cls closure
114 * @param success #GNUNET_SYSERR on failure (try to disconnect/reset connection)
115 * #GNUNET_OK on success
116 */
117typedef void
118(*GNUNET_TRANSPORT_MessageCompletedCallback) (void *cls,
119 int success);
120
121
122/**
123 * Notify transport service that the communicator has received
124 * a message.
125 *
126 * @param handle connection to transport service
127 * @param sender presumed sender of the message (details to be checked
128 * by higher layers)
129 * @param msg the message
130 * @param cb function to call once handling the message is done, NULL if
131 * flow control is not supported by this communicator
132 * @param cb_cls closure for @a cb
133 * @return #GNUNET_OK if all is well, #GNUNET_NO if the message was
134 * immediately dropped due to memory limitations (communicator
135 * should try to apply back pressure),
136 * #GNUNET_SYSERR if the message is ill formed and communicator
137 * should try to reset stream
138 */
139int
140GNUNET_TRANSPORT_communicator_receive (struct GNUNET_TRANSPORT_CommunicatorHandle *handle,
141 const struct GNUNET_PeerIdentity *sender,
142 const struct GNUNET_MessageHeader *msg,
143 GNUNET_TRANSPORT_MessageCompletedCallback cb,
144 void *cb_cls);
145
146
147/* ************************* Discovery *************************** */
148
149
150/**
151 * Notify transport service that an MQ became available due to an
152 * "inbound" connection or because the communicator discovered the
153 * presence of another peer.
154 *
155 * @param handle connection to transport service
156 * @param peer peer with which we can now communicate
157 * @param address address in human-readable format, 0-terminated, UTF-8
158 * @param nt which network type does the @a address belong to?
159 * @param mq message queue of the @a peer
160 */
161void
162GNUNET_TRANSPORT_communicator_mq_add (struct GNUNET_TRANSPORT_CommunicatorHandle *handle,
163 const struct GNUNET_PeerIdentity *peer,
164 const char *address,
165 enum GNUNET_ATS_Network_Type nt,
166 struct GNUNET_MQ_Handle *mq);
167
168
169/**
170 * Notify transport service that an MQ became unavailable due to a
171 * disconnect or timeout.
172 *
173 * @param handle connection to transport service
174 * @param peer peer with which we can no longer communicate via the given mq
175 * @param address address in human-readable format, 0-terminated, UTF-8
176 * @param nt which network type does the @a address belong to?
177 * @param mq message queue of the @a peer
178 */
179void
180GNUNET_TRANSPORT_communicator_mq_remove (struct GNUNET_TRANSPORT_CommunicatorHandle *handle,
181 const struct GNUNET_PeerIdentity *peer,
182 const char *address,
183 enum GNUNET_ATS_Network_Type nt,
184 struct GNUNET_MQ_Handle *mq);
185
186
187/**
188 * Notify transport service about an address that this communicator
189 * provides for this peer.
190 *
191 * @param handle connection to transport service
192 * @param address our address in human-readable format, 0-terminated, UTF-8
193 * @param nt which network type does the address belong to?
194 * @param expiration when does the communicator forsee this address expiring?
195 */
196void
197GNUNET_TRANSPORT_communicator_address_add (struct GNUNET_TRANSPORT_CommunicatorHandle *handle,
198 const char *address,
199 enum GNUNET_ATS_Network_Type nt,
200 struct GNUNET_TIME_Absolute expiration);
201
202
203/**
204 * Notify transport service about an address that this communicator
205 * no longer provides for this peer.
206 *
207 * @param handle connection to transport service
208 * @param address our former address in human-readable format,
209 * 0-terminated, in UTF-8
210 */
211void
212GNUNET_TRANSPORT_communicator_address_remove (struct GNUNET_TRANSPORT_CommunicatorHandle *handle,
213 const char *address);
214
215
216#if 0 /* keep Emacsens' auto-indent happy */
217{
218#endif
219#ifdef __cplusplus
220}
221#endif
222
223/* ifndef GNUNET_TRANSPORT_COMMUNICATOR_SERVICE_H */
224#endif
225
226/** @} */ /* end of group */
227
228/* end of gnunet_transport_communicator_service.h */