aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_transport_service.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-07-29 23:01:30 +0000
committerChristian Grothoff <christian@grothoff.org>2016-07-29 23:01:30 +0000
commitff1c357933910f707cdf13bb6ef705ef0ae90960 (patch)
treef503553309d25ed47983e1e15a1b462ff089ac04 /src/include/gnunet_transport_service.h
parent88295b5a3adc0f17ffd5fa4d2c1fafc632db6dab (diff)
downloadgnunet-ff1c357933910f707cdf13bb6ef705ef0ae90960.tar.gz
gnunet-ff1c357933910f707cdf13bb6ef705ef0ae90960.zip
-finally able to remove old transport API transmission logic
Diffstat (limited to 'src/include/gnunet_transport_service.h')
-rw-r--r--src/include/gnunet_transport_service.h210
1 files changed, 2 insertions, 208 deletions
diff --git a/src/include/gnunet_transport_service.h b/src/include/gnunet_transport_service.h
index b40763b92..91e9aad4f 100644
--- a/src/include/gnunet_transport_service.h
+++ b/src/include/gnunet_transport_service.h
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2009-2014 GNUnet e.V. 3 Copyright (C) 2009-2016 GNUnet e.V.
4 4
5 GNUnet is free software; you can redistribute it and/or modify 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 6 it under the terms of the GNU General Public License as published
@@ -49,213 +49,7 @@ extern "C"
49/** 49/**
50 * Version number of the transport API. 50 * Version number of the transport API.
51 */ 51 */
52#define GNUNET_TRANSPORT_VERSION 0x00000002 52#define GNUNET_TRANSPORT_VERSION 0x00000003
53
54
55/**
56 * Function called by the transport for each received message.
57 *
58 * @param cls closure
59 * @param peer (claimed) identity of the other peer
60 * @param message the message
61 */
62typedef void
63(*GNUNET_TRANSPORT_ReceiveCallback) (void *cls,
64 const struct GNUNET_PeerIdentity *peer,
65 const struct GNUNET_MessageHeader *message);
66
67
68/**
69 * Function called to notify transport users that another
70 * peer connected to us.
71 *
72 * @param cls closure
73 * @param peer the peer that connected
74 */
75typedef void
76(*GNUNET_TRANSPORT_NotifyConnect) (void *cls,
77 const struct GNUNET_PeerIdentity *peer);
78
79
80/**
81 * Function called to notify transport users that another
82 * peer disconnected from us.
83 *
84 * @param cls closure
85 * @param peer the peer that disconnected
86 */
87typedef void
88(*GNUNET_TRANSPORT_NotifyDisconnect) (void *cls,
89 const struct GNUNET_PeerIdentity *peer);
90
91
92/**
93 * Connect to the transport service. Note that the connection may
94 * complete (or fail) asynchronously.
95 *
96 * @param cfg configuration to use
97 * @param self our own identity (API should check that it matches
98 * the identity found by transport), or NULL (no check)
99 * @param cls closure for the callbacks
100 * @param rec receive function to call, or NULL
101 * @param nc function to call on connect events, or NULL
102 * @param nd function to call on disconnect events, or NULL
103 * @return NULL on error
104 */
105struct GNUNET_TRANSPORT_Handle *
106GNUNET_TRANSPORT_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
107 const struct GNUNET_PeerIdentity *self,
108 void *cls,
109 GNUNET_TRANSPORT_ReceiveCallback rec,
110 GNUNET_TRANSPORT_NotifyConnect nc,
111 GNUNET_TRANSPORT_NotifyDisconnect nd);
112
113
114/**
115 * Function called if we have "excess" bandwidth to a peer.
116 * The notification will happen the first time we have excess
117 * bandwidth, and then only again after the client has performed
118 * some transmission to the peer.
119 *
120 * Excess bandwidth is defined as being allowed (by ATS) to send
121 * more data, and us reaching the limit of the capacity build-up
122 * (which, if we go past it, means we don't use available bandwidth).
123 * See also the "max carry" in `struct GNUNET_BANDWIDTH_Tracker`.
124 *
125 * @param cls the closure
126 * @param neighbour peer that we have excess bandwidth to
127 */
128typedef void
129(*GNUNET_TRANSPORT_NotifyExcessBandwidth)(void *cls,
130 const struct GNUNET_PeerIdentity *neighbour);
131
132
133/**
134 * Connect to the transport service. Note that the connection may
135 * complete (or fail) asynchronously.
136 *
137 * @param cfg configuration to use
138 * @param self our own identity (API should check that it matches
139 * the identity found by transport), or NULL (no check)
140 * @param cls closure for the callbacks
141 * @param rec receive function to call, or NULL
142 * @param nc function to call on connect events, or NULL
143 * @param nd function to call on disconnect events, or NULL
144 * @param neb function to call if we have excess bandwidth to a peer
145 * @return NULL on error
146 */
147struct GNUNET_TRANSPORT_Handle *
148GNUNET_TRANSPORT_connect2 (const struct GNUNET_CONFIGURATION_Handle *cfg,
149 const struct GNUNET_PeerIdentity *self,
150 void *cls,
151 GNUNET_TRANSPORT_ReceiveCallback rec,
152 GNUNET_TRANSPORT_NotifyConnect nc,
153 GNUNET_TRANSPORT_NotifyDisconnect nd,
154 GNUNET_TRANSPORT_NotifyExcessBandwidth neb);
155
156
157/**
158 * Disconnect from the transport service.
159 *
160 * @param handle handle returned from connect
161 */
162void
163GNUNET_TRANSPORT_disconnect (struct GNUNET_TRANSPORT_Handle *handle);
164
165
166/* ************************* Sending *************************** */
167
168/**
169 * Opaque handle for a transmission-ready request.
170 */
171struct GNUNET_TRANSPORT_TransmitHandle;
172
173
174/**
175 * Function called to notify a client about the connection begin ready
176 * to queue more data. @a buf will be NULL and @a size zero if the
177 * connection was closed for writing in the meantime.
178 *
179 * @param cls closure
180 * @param size number of bytes available in @a buf
181 * @param buf where the callee should write the message
182 * @return number of bytes written to @a buf
183 */
184typedef size_t
185(*GNUNET_TRANSPORT_TransmitReadyNotify) (void *cls,
186 size_t size,
187 void *buf);
188
189
190/**
191 * Check if we could queue a message of the given size for
192 * transmission. The transport service will take both its internal
193 * buffers and bandwidth limits imposed by the other peer into
194 * consideration when answering this query.
195 *
196 * @param handle connection to transport service
197 * @param target who should receive the message
198 * @param size how big is the message we want to transmit?
199 * @param timeout after how long should we give up (and call
200 * notify with buf NULL and size 0)?
201 * @param notify function to call when we are ready to
202 * send such a message
203 * @param notify_cls closure for @a notify
204 * @return NULL if someone else is already waiting to be notified
205 * non-NULL if the notify callback was queued (can be used to cancel
206 * using #GNUNET_TRANSPORT_notify_transmit_ready_cancel())
207 */
208struct GNUNET_TRANSPORT_TransmitHandle *
209GNUNET_TRANSPORT_notify_transmit_ready (struct GNUNET_TRANSPORT_Handle *handle,
210 const struct GNUNET_PeerIdentity *target,
211 size_t size,
212 struct GNUNET_TIME_Relative timeout,
213 GNUNET_TRANSPORT_TransmitReadyNotify notify,
214 void *notify_cls);
215
216
217/**
218 * Cancel the specified transmission-ready notification.
219 *
220 * @param th handle of the transmission notification request to cancel
221 */
222void
223GNUNET_TRANSPORT_notify_transmit_ready_cancel (struct GNUNET_TRANSPORT_TransmitHandle *th);
224
225
226/**
227 * Checks if a given peer is connected to us
228 *
229 * @param handle connection to transport service
230 * @param peer the peer to check
231 * @return #GNUNET_YES (connected) or #GNUNET_NO (disconnected)
232 */
233int
234GNUNET_TRANSPORT_check_peer_connected (struct GNUNET_TRANSPORT_Handle *handle,
235 const struct GNUNET_PeerIdentity *peer);
236
237
238
239/* *********************** Metric manipulation ***************** */
240
241/**
242 * Set transport metrics for a peer and a direction
243 *
244 * @param handle transport handle
245 * @param peer the peer to set the metric for
246 * @param prop the performance metrics to set
247 * @param delay_in inbound delay to introduce
248 * @param delay_out outbound delay to introduce
249 *
250 * Note: Delay restrictions in receiving direction will be enforced
251 * with one message delay.
252 */
253void
254GNUNET_TRANSPORT_set_traffic_metric (struct GNUNET_TRANSPORT_Handle *handle,
255 const struct GNUNET_PeerIdentity *peer,
256 const struct GNUNET_ATS_Properties *prop,
257 struct GNUNET_TIME_Relative delay_in,
258 struct GNUNET_TIME_Relative delay_out);
259 53
260 54
261/* *************************** HELLO *************************** */ 55/* *************************** HELLO *************************** */