aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-10-13 11:59:13 +0000
committerChristian Grothoff <christian@grothoff.org>2011-10-13 11:59:13 +0000
commit86ad1393cdf6c8b37437c330fce25ebfffbc8ffd (patch)
treea74f38f8f6379361490ca8b9395d1ee161943b98 /src/include
parent0a5333c2df162d6f6f9bd35ea04d57e6abcc0b6f (diff)
downloadgnunet-86ad1393cdf6c8b37437c330fce25ebfffbc8ffd.tar.gz
gnunet-86ad1393cdf6c8b37437c330fce25ebfffbc8ffd.zip
new ATS API -- code won't compile
Diffstat (limited to 'src/include')
-rw-r--r--src/include/gnunet_ats_service.h294
-rw-r--r--src/include/gnunet_protocols.h21
2 files changed, 189 insertions, 126 deletions
diff --git a/src/include/gnunet_ats_service.h b/src/include/gnunet_ats_service.h
index 713178411..12446991a 100644
--- a/src/include/gnunet_ats_service.h
+++ b/src/include/gnunet_ats_service.h
@@ -25,8 +25,6 @@
25 * 25 *
26 * TODO: 26 * TODO:
27 * - move GNUNET_TRANSPORT_ATS* in here and rename... 27 * - move GNUNET_TRANSPORT_ATS* in here and rename...
28 * - extend API to express communication preferences to ATS
29 * (to be called DIRECTLY from apps, not from transport/core!)
30 */ 28 */
31#ifndef GNUNET_ATS_SERVICE_H 29#ifndef GNUNET_ATS_SERVICE_H
32#define GNUNET_ATS_SERVICE_H 30#define GNUNET_ATS_SERVICE_H
@@ -37,24 +35,26 @@
37#include "gnunet_transport_plugin.h" 35#include "gnunet_transport_plugin.h"
38 36
39 37
38/* ******************************** Scheduling API ***************************** */
39
40/** 40/**
41 * Handle to the ATS subsystem. 41 * Handle to the ATS subsystem for bandwidth/transport scheduling information.
42 */ 42 */
43struct GNUNET_ATS_Handle; 43struct GNUNET_ATS_SchedulingHandle;
44 44
45 45
46/** 46/**
47 * Signature of a function that takes an address suggestion 47 * Signature of a function called by ATS with the current bandwidth
48 * and address preferences as determined by ATS.
48 * 49 *
49 * @param cls closure 50 * @param cls closure
50 * @param peer identity of the new peer 51 * @param peer identity of the new peer
51 * @param plugin_name name of the plugin, NULL if we have no suggestion 52 * @param plugin_name name of the plugin, NULL if we have no suggestion
52 * @param plugin_addr suggested address, NULL if we have no suggestion 53 * @param plugin_addr suggested address, NULL if we have no suggestion
53 * @param plugin_addr_len number of bytes in plugin_addr 54 * @param plugin_addr_len number of bytes in plugin_addr
55 * @param session session to use
54 * @param bandwidth_out assigned outbound bandwidth for the connection 56 * @param bandwidth_out assigned outbound bandwidth for the connection
55 * @param bandwidth_in assigned inbound bandwidth for the connection 57 * @param bandwidth_in assigned inbound bandwidth for the connection
56 * @param ats performance data for the address (as far as known)
57 * @param ats_count number of performance records in 'ats'
58 */ 58 */
59typedef void (*GNUNET_ATS_AddressSuggestionCallback) (void *cls, 59typedef void (*GNUNET_ATS_AddressSuggestionCallback) (void *cls,
60 const struct 60 const struct
@@ -69,11 +69,7 @@ typedef void (*GNUNET_ATS_AddressSuggestionCallback) (void *cls,
69 bandwidth_out, 69 bandwidth_out,
70 struct 70 struct
71 GNUNET_BANDWIDTH_Value32NBO 71 GNUNET_BANDWIDTH_Value32NBO
72 bandwidth_in, 72 bandwidth_in);
73 const struct
74 GNUNET_TRANSPORT_ATS_Information
75 * ats,
76 uint32_t ats_count);
77 73
78 74
79/** 75/**
@@ -84,86 +80,58 @@ typedef void (*GNUNET_ATS_AddressSuggestionCallback) (void *cls,
84 * @param alloc_cb_cls closure for 'alloc_cb' 80 * @param alloc_cb_cls closure for 'alloc_cb'
85 * @return ats context 81 * @return ats context
86 */ 82 */
87struct GNUNET_ATS_Handle * 83struct GNUNET_ATS_SchedulingHandle *
88GNUNET_ATS_init (const struct GNUNET_CONFIGURATION_Handle *cfg, 84GNUNET_ATS_scheduling_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
89 GNUNET_ATS_AddressSuggestionCallback alloc_cb, 85 GNUNET_ATS_AddressSuggestionCallback alloc_cb,
90 void *alloc_cb_cls); 86 void *alloc_cb_cls);
91 87
92 88
93/** 89/**
94 * Shutdown the ATS subsystem. 90 * Client is done with ATS scheduling, release resources.
95 * 91 *
96 * @param atc handle 92 * @param atc handle to release
97 */ 93 */
98void 94void
99GNUNET_ATS_shutdown (struct GNUNET_ATS_Handle *atc); 95GNUNET_ATS_scheduling_done (struct GNUNET_ATS_SchedulingHandle *atc);
100
101
102/**
103 * Handle to cancel suggestion request.
104 */
105struct GNUNET_ATS_SuggestionContext;
106 96
107 97
108/** 98/**
109 * We would like to establish a new connection with a peer. 99 * We would like to establish a new connection with a peer. ATS
110 * ATS should suggest a good address to begin with. 100 * should suggest a good address to begin with.
111 * 101 *
112 * @param atc handle 102 * @param atc handle
113 * @param peer identity of the new peer 103 * @param peer identity of the peer we need an address for
114 * @param cb function to call with the address
115 * @param cb_cls closure for cb
116 */
117struct GNUNET_ATS_SuggestionContext *
118GNUNET_ATS_suggest_address (struct GNUNET_ATS_Handle *atc,
119 const struct GNUNET_PeerIdentity *peer,
120 GNUNET_ATS_AddressSuggestionCallback cb,
121 void *cb_cls);
122
123
124/**
125 * Cancel suggestion request.
126 *
127 * @param asc handle of the request to cancel
128 */ 104 */
129void 105void
130GNUNET_ATS_suggest_address_cancel (struct GNUNET_ATS_SuggestionContext *asc); 106GNUNET_ATS_suggest_address (struct GNUNET_ATS_SchedulingHandle *atc,
107 const struct GNUNET_PeerIdentity *peer);
131 108
132 109
133/** 110/**
134 * We established a new connection with a peer (for example, because 111 * We have updated performance statistics for a given address. Note
135 * core asked for it or because the other peer connected to us). 112 * that this function can be called for addresses that are currently
136 * Calculate bandwidth assignments including the new peer. 113 * in use as well as addresses that are valid but not actively in use.
114 * Furthermore, the peer may not even be connected to us right now (in
115 * which case the call may be ignored or the information may be stored
116 * for later use). Update bandwidth assignments.
137 * 117 *
138 * @param atc handle 118 * @param atc handle
139 * @param peer identity of the new peer 119 * @param peer identity of the new peer
140 * @param plugin_name name of the currently used transport plugin 120 * @param plugin_name name of the transport plugin
141 * @param session session in use (if available) 121 * @param plugin_addr address (if available)
142 * @param plugin_addr address in use (if available)
143 * @param plugin_addr_len number of bytes in plugin_addr 122 * @param plugin_addr_len number of bytes in plugin_addr
144 * @param ats performance data for the connection 123 * @param session session handle (if available)
124 * @param ats performance data for the address
145 * @param ats_count number of performance records in 'ats' 125 * @param ats_count number of performance records in 'ats'
146 */ 126 */
147void 127void
148GNUNET_ATS_peer_connect (struct GNUNET_ATS_Handle *atc, 128GNUNET_ATS_address_update (struct GNUNET_ATS_SchedulingHandle *atc,
149 const struct GNUNET_PeerIdentity *peer, 129 const struct GNUNET_PeerIdentity *peer,
150 const char *plugin_name, struct Session *session, 130 const char *plugin_name,
151 const void *plugin_addr, size_t plugin_addr_len, 131 const void *plugin_addr, size_t plugin_addr_len,
152 const struct GNUNET_TRANSPORT_ATS_Information *ats, 132 struct Session *session,
153 uint32_t ats_count); 133 const struct GNUNET_TRANSPORT_ATS_Information *ats,
154 134 uint32_t ats_count);
155
156/**
157 * We disconnected from the given peer (for example, because ats, core
158 * or blacklist asked for it or because the other peer disconnected).
159 * Calculate bandwidth assignments without the peer.
160 *
161 * @param atc handle
162 * @param peer identity of the peer
163 */
164void
165GNUNET_ATS_peer_disconnect (struct GNUNET_ATS_Handle *atc,
166 const struct GNUNET_PeerIdentity *peer);
167 135
168 136
169/** 137/**
@@ -171,45 +139,85 @@ GNUNET_ATS_peer_disconnect (struct GNUNET_ATS_Handle *atc,
171 * 139 *
172 * @param atc handle 140 * @param atc handle
173 * @param peer identity of the peer 141 * @param peer identity of the peer
142 * @param plugin_name name of the transport plugin
143 * @param plugin_addr address (if available)
144 * @param plugin_addr_len number of bytes in plugin_addr
174 * @param session session handle that is no longer valid 145 * @param session session handle that is no longer valid
175 */ 146 */
176void 147void
177GNUNET_ATS_session_destroyed (struct GNUNET_ATS_Handle *atc, 148GNUNET_ATS_address_destroyed (struct GNUNET_ATS_SchedulingHandle *atc,
178 const struct GNUNET_PeerIdentity *peer, 149 const struct GNUNET_PeerIdentity *peer,
150 const char *plugin_name,
151 const void *plugin_addr,
152 size_t plugin_addr_len,
179 const struct Session *session); 153 const struct Session *session);
180 154
181 155
156/* ******************************** Performance API ***************************** */
157
182/** 158/**
183 * We have updated performance statistics for a given address. Note 159 * ATS Handle to obtain and/or modify performance information.
184 * that this function can be called for addresses that are currently 160 */
185 * in use as well as addresses that are valid but not actively in use. 161struct GNUNET_ATS_PerformanceHandle;
186 * Furthermore, the peer may not even be connected to us right now (in 162
187 * which case the call may be ignored or the information may be stored 163
188 * for later use). Update bandwidth assignments. 164/**
165 * Signature of a function that is called with QoS information about a peer.
189 * 166 *
190 * @param atc handle 167 * @param cls closure
191 * @param peer identity of the new peer 168 * @param peer identity of the new peer
192 * @param valid_until how long is the address valid? 169 * @param plugin_name name of the plugin, NULL if we have no suggestion
193 * @param plugin_name name of the transport plugin 170 * @param plugin_addr suggested address, NULL if we have no suggestion
194 * @param session session handle (if available)
195 * @param plugin_addr address (if available)
196 * @param plugin_addr_len number of bytes in plugin_addr 171 * @param plugin_addr_len number of bytes in plugin_addr
197 * @param ats performance data for the address 172 * @param bandwidth_out assigned outbound bandwidth for the connection
173 * @param bandwidth_in assigned inbound bandwidth for the connection
174 * @param ats performance data for the address (as far as known)
198 * @param ats_count number of performance records in 'ats' 175 * @param ats_count number of performance records in 'ats'
199 */ 176 */
200void 177typedef void (*GNUNET_ATS_PeerInformationCallback) (void *cls,
201GNUNET_ATS_address_update (struct GNUNET_ATS_Handle *atc, 178 const struct
202 const struct GNUNET_PeerIdentity *peer, 179 GNUNET_PeerIdentity *
203 struct GNUNET_TIME_Absolute valid_until, 180 peer,
204 const char *plugin_name, struct Session *session, 181 const char *plugin_name,
205 const void *plugin_addr, size_t plugin_addr_len, 182 const void *plugin_addr,
206 const struct GNUNET_TRANSPORT_ATS_Information *ats, 183 size_t plugin_addr_len,
207 uint32_t ats_count); 184 struct
185 GNUNET_BANDWIDTH_Value32NBO
186 bandwidth_out,
187 struct
188 GNUNET_BANDWIDTH_Value32NBO
189 bandwidth_in,
190 const struct
191 GNUNET_TRANSPORT_ATS_Information
192 * ats,
193 uint32_t ats_count);
208 194
209 195
196/**
197 * Get handle to access performance API of the ATS subsystem.
198 *
199 * @param cfg configuration to use
200 * @param infocb function to call on allocation changes, can be NULL
201 * @param infocb_cls closure for infocb
202 * @return ats performance context
203 */
204struct GNUNET_ATS_PerformanceHandle *
205GNUNET_ATS_performance_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
206 GNUNET_ATS_PeerInformationCallback infocb,
207 void *infocb_cls);
208
209
210/**
211 * Client is done using the ATS performance subsystem, release resources.
212 *
213 * @param atc handle
214 */
215void
216GNUNET_ATS_performance_done (struct GNUNET_ATS_SchedulingHandle *atc);
217
210 218
211/** 219/**
212 * Function called with perference change information about the given peer. 220 * Function called with reservation result.
213 * 221 *
214 * @param cls closure 222 * @param cls closure
215 * @param peer identifies the peer 223 * @param peer identifies the peer
@@ -218,65 +226,99 @@ GNUNET_ATS_address_update (struct GNUNET_ATS_Handle *atc,
218 * @param res_delay if the reservation could not be satisfied (amount was 0), how 226 * @param res_delay if the reservation could not be satisfied (amount was 0), how
219 * long should the client wait until re-trying? 227 * long should the client wait until re-trying?
220 */ 228 */
221typedef void (*GNUNET_ATS_PeerConfigurationInfoCallback) (void *cls, 229typedef void (*GNUNET_ATS_ReservationCallback) (void *cls,
222 const struct 230 const struct
223 GNUNET_PeerIdentity * 231 GNUNET_PeerIdentity *
224 peer, 232 peer,
225 int32_t amount, 233 int32_t amount,
226 struct 234 struct
227 GNUNET_TIME_Relative 235 GNUNET_TIME_Relative
228 res_delay); 236 res_delay);
229 237
230 238
231 239
232/** 240/**
233 * Context that can be used to cancel a peer information request. 241 * Context that can be used to cancel a peer information request.
234 */ 242 */
235struct GNUNET_ATS_InformationRequestContext; 243struct GNUNET_ATS_ReservationContext;
236 244
237 245
238/** 246/**
239 * Obtain statistics and/or change preferences for the given peer. 247 * Reserve inbound bandwidth from the given peer. ATS will look at
240 * You can only have one such pending request per peer. 248 * the current amount of traffic we receive from the peer and ensure
249 * that the peer could add 'amount' of data to its stream.
241 * 250 *
242 * @param h core handle 251 * @param h core handle
243 * @param peer identifies the peer 252 * @param peer identifies the peer
244 * @param amount reserve N bytes for receiving, negative 253 * @param amount reserve N bytes for receiving, negative
245 * amounts can be used to undo a (recent) reservation; 254 * amounts can be used to undo a (recent) reservation;
246 * @param preference increase incoming traffic share preference by this amount; 255 * @param info function to call with the resulting reservation information
247 * in the absence of "amount" reservations, we use this
248 * preference value to assign proportional bandwidth shares
249 * to all connected peers; in the future, this should be
250 * replaced with more specific QoS expressions...
251 * @param info function to call with the resulting configuration information
252 * @param info_cls closure for info 256 * @param info_cls closure for info
253 * @return NULL on error 257 * @return NULL on error
254 * @deprecated will be replaced soon 258 * @deprecated will be replaced soon
255 */ 259 */
256struct GNUNET_ATS_InformationRequestContext * 260struct GNUNET_ATS_ReservationContext *
257GNUNET_ATS_peer_change_preference (struct GNUNET_ATS_Handle *h, 261GNUNET_ATS_reserve_bandwidth (struct GNUNET_ATS_PerformanceHandle *h,
258 const struct GNUNET_PeerIdentity *peer, 262 const struct GNUNET_PeerIdentity *peer,
259 int32_t amount, uint64_t preference, 263 int32_t amount,
260 GNUNET_ATS_PeerConfigurationInfoCallback 264 GNUNET_ATS_ReservationCallback info,
261 info, void *info_cls); 265 void *info_cls);
262 266
263 267
264/** 268/**
265 * Cancel request for getting information about a peer. 269 * Cancel request for reserving bandwidth.
266 * Note that an eventual change in preference, trust or bandwidth
267 * assignment MAY have already been committed at the time,
268 * so cancelling a request is NOT sure to undo the original
269 * request. The original request may or may not still commit.
270 * The only thing cancellation ensures is that the callback
271 * from the original request will no longer be called.
272 * 270 *
273 * @param irc context returned by the original GNUNET_ATS_peer_get_info call 271 * @param rc context returned by the original GNUNET_ATS_reserve_bandwidth call
274 * @deprecated will be replaced soon 272 */
273void
274GNUNET_ATS_reserve_bandwidth_cancel (struct
275 GNUNET_ATS_ReservationContext *rc);
276
277
278
279/**
280 * Enum defining all known preference categories.
281 */
282enum GNUNET_ATS_PreferenceKind
283{
284
285 /**
286 * End of preference list.
287 */
288 GNUNET_ATS_PREFERENCE_END = 0,
289
290 /**
291 * Change the peer's bandwidth value (value per byte of bandwidth in
292 * the goal function) to the given amount. The argument is followed
293 * by a double value giving the desired value (can be negative).
294 * Preference changes are forgotten if peers disconnect.
295 */
296 GNUNET_ATS_PREFERENCE_BANDWIDTH,
297
298 /**
299 * Change the peer's latency value to the given amount. The
300 * argument is followed by a double value giving the desired value
301 * (can be negative). The absolute score in the goal function is
302 * the inverse of the latency in ms (minimum: 1 ms) multiplied by
303 * the latency preferences.
304 */
305 GNUNET_ATS_PREFERENCE_LATENCY
306
307};
308
309
310/**
311 * Change preferences for the given peer. Preference changes are forgotten if peers
312 * disconnect.
313 *
314 * @param cls closure
315 * @param peer identifies the peer
316 * @param ... 0-terminated specification of the desired changes
275 */ 317 */
276void 318void
277GNUNET_ATS_peer_change_preference_cancel (struct 319GNUNET_ATS_change_preference (struct GNUNET_ATS_PerformanceHandle *h,
278 GNUNET_ATS_InformationRequestContext 320 const struct GNUNET_PeerIdentity *peer,
279 *irc); 321 ...);
280 322
281 323
282 324
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h
index 418c9f8ef..9f106c3a9 100644
--- a/src/include/gnunet_protocols.h
+++ b/src/include/gnunet_protocols.h
@@ -987,6 +987,27 @@ extern "C"
987#define GNUNET_MESSAGE_TYPE_PEERINFO_NOTIFY 334 987#define GNUNET_MESSAGE_TYPE_PEERINFO_NOTIFY 334
988 988
989/******************************************************************************* 989/*******************************************************************************
990 * ATS message types
991 ******************************************************************************/
992
993#define GNUNET_MESSAGE_TYPE_ATS_START 340
994
995#define GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS 341
996
997#define GNUNET_MESSAGE_TYPE_ATS_ADDRESS_UPDATE 342
998
999#define GNUNET_MESSAGE_TYPE_ATS_ADDRESS_DESTROYED 343
1000
1001#define GNUNET_MESSAGE_TYPE_ATS_ADDRESS_SUGGESTION 344
1002
1003#define GNUNET_MESSAGE_TYPE_ATS_RESERVATION_REQUEST 345
1004
1005#define GNUNET_MESSAGE_TYPE_ATS_RESERVATION_RESULT 346
1006
1007#define GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_CHANGE 347
1008
1009
1010/*******************************************************************************
990 * TODO: we need a way to register message types centrally (via some webpage). 1011 * TODO: we need a way to register message types centrally (via some webpage).
991 * For now: unofficial extensions should start at 48k, internal extensions 1012 * For now: unofficial extensions should start at 48k, internal extensions
992 * define here should leave some room (4-10 additional messages to the previous 1013 * define here should leave some room (4-10 additional messages to the previous