aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_ats_plugin.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/gnunet_ats_plugin.h')
-rw-r--r--src/include/gnunet_ats_plugin.h492
1 files changed, 0 insertions, 492 deletions
diff --git a/src/include/gnunet_ats_plugin.h b/src/include/gnunet_ats_plugin.h
deleted file mode 100644
index 206f2dd52..000000000
--- a/src/include/gnunet_ats_plugin.h
+++ /dev/null
@@ -1,492 +0,0 @@
1/*
2 This file is part of GNUnet
3 Copyright (C) 2009-2015 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 * @addtogroup Backbone
23 * @{
24 *
25 * @author Christian Grothoff
26 *
27 * @file
28 * API for the ATS solvers.
29 *
30 * @defgroup ats-plugin ATS service plugin API
31 * Plugin API for the ATS service.
32 *
33 * Specifies the struct that is given to the plugin's entry method and the other
34 * struct that must be returned. Note that the destructors of ATS plugins will
35 * be given the value returned by the constructor and is expected to return a
36 * NULL pointer.
37 *
38 * @{
39 */
40#ifndef PLUGIN_ATS_H
41#define PLUGIN_ATS_H
42
43
44#include "gnunet_ats_service.h"
45#include "gnunet_statistics_service.h"
46
47/**
48 * Representation of an address the plugin can choose from.
49 */
50struct ATS_Address;
51
52/**
53 * Change the preference for a peer
54 *
55 * @param handle the solver handle
56 * @param client the client sending this request
57 * @param peer the peer id
58 * @param kind the preference kind to change
59 * @param score the new preference score
60 * @param pref_rel the normalized preference value for this kind over all clients
61 */
62typedef void
63(*GAS_solver_address_change_preference) (void *solver,
64 const struct GNUNET_PeerIdentity *peer,
65 enum GNUNET_ATS_PreferenceKind kind,
66 double pref_rel);
67
68
69/**
70 * Give feedback about the current assignment
71 *
72 * @param handle the solver handle
73 * @param application the application sending this request
74 * @param peer the peer id
75 * @param scope the time interval for this feedback: [now - scope .. now]
76 * @param kind the preference kind for this feedback
77 * @param score the feedback score
78 */
79typedef void
80(*GAS_solver_address_feedback_preference) (void *solver,
81 struct GNUNET_SERVICE_Client *
82 application,
83 const struct
84 GNUNET_PeerIdentity *peer,
85 const struct GNUNET_TIME_Relative
86 scope,
87 enum GNUNET_ATS_PreferenceKind kind,
88 double score);
89
90/**
91 * Notify the solver about a bulk operation changing possibly a lot of values
92 * Solver will not resolve until all bulk operations are marked as done
93 *
94 * @param solver the solver
95 */
96typedef void
97(*GAS_solver_bulk_start) (void *solver);
98
99
100/**
101 * Mark a bulk operation as done
102 * Solver will resolve if values have changed
103 *
104 * @param solver the solver
105 */
106typedef void
107(*GAS_solver_bulk_stop) (void *solver);
108
109
110/**
111 * Add a single address within a network to the solver
112 *
113 * @param solver the solver Handle
114 * @param address the address to add
115 * @param network network type of this address
116 */
117typedef void
118(*GAS_solver_address_add) (void *solver,
119 struct ATS_Address *address,
120 uint32_t network);
121
122
123/**
124 * Delete an address or just the session from the solver
125 *
126 * @param solver the solver Handle
127 * @param address the address to delete
128 */
129typedef void
130(*GAS_solver_address_delete) (void *solver,
131 struct ATS_Address *address);
132
133
134/**
135 * Transport properties for this address have changed
136 *
137 * @param solver solver handle
138 * @param address the address
139 */
140typedef void
141(*GAS_solver_address_property_changed) (void *solver,
142 struct ATS_Address *address);
143
144
145/**
146 * Get the preferred address for a peer from solver
147 *
148 * @param solver the solver to use
149 * @param peer the peer
150 */
151typedef void
152(*GAS_solver_get_preferred_address) (void *solver,
153 const struct GNUNET_PeerIdentity *peer);
154
155
156/**
157 * Stop getting the preferred address for a peer from solver
158 *
159 * @param solver the solver to use
160 * @param peer the peer
161 */
162typedef void
163(*GAS_solver_stop_get_preferred_address) (void *solver,
164 const struct
165 GNUNET_PeerIdentity *peer);
166
167
168/**
169 * Solver functions.
170 *
171 * Each solver is required to set up and return an instance
172 * of this struct during initialization.
173 */
174struct GNUNET_ATS_SolverFunctions
175{
176 /**
177 * Closure to pass to all solver functions in this struct.
178 */
179 void *cls;
180
181 /**
182 * Add a new address for a peer to the solver
183 *
184 * The address is already contained in the addresses hashmap!
185 */
186 GAS_solver_address_add s_add;
187
188 /**
189 * Update the properties of an address in the solver
190 */
191 GAS_solver_address_property_changed s_address_update_property;
192
193 /**
194 * Tell solver to notify ATS if the address to use changes for a specific
195 * peer using the bandwidth changed callback
196 *
197 * The solver must only notify about changes for peers with pending address
198 * requests!
199 */
200 GAS_solver_get_preferred_address s_get;
201
202 /**
203 * Tell solver stop notifying ATS about changes for this peers
204 *
205 * The solver must only notify about changes for peers with pending address
206 * requests!
207 */
208 GAS_solver_stop_get_preferred_address s_get_stop;
209
210 /**
211 * Delete an address in the solver
212 *
213 * The address is not contained in the address hashmap anymore!
214 */
215 GAS_solver_address_delete s_del;
216
217 /**
218 * Change relative preference for quality in solver
219 */
220 GAS_solver_address_change_preference s_pref;
221
222 /**
223 * Give feedback about the current assignment
224 */
225 GAS_solver_address_feedback_preference s_feedback;
226
227 /**
228 * Start a bulk operation
229 *
230 * Used if many values have to be updated at the same time.
231 * When a bulk operation is pending the solver does not have to resolve
232 * the problem since more updates will follow anyway
233 *
234 * For each call to bulk_start, a call to bulk_stop is required!
235 */
236 GAS_solver_bulk_start s_bulk_start;
237
238 /**
239 * Bulk operation done
240 *
241 * If no more bulk operations are pending, the solver can solve the problem
242 * with the updated values
243 */
244 GAS_solver_bulk_stop s_bulk_stop;
245};
246
247
248/**
249 * Operation codes for solver information callback
250 *
251 * Order of calls is expected to be:
252 * #GAS_OP_SOLVE_START
253 * #GAS_OP_SOLVE_STOP
254 * #GAS_OP_SOLVE_UPDATE_NOTIFICATION_START
255 * #GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP
256 *
257 */
258enum GAS_Solver_Operation
259{
260 /**
261 * A solution iteration has been started
262 */
263 GAS_OP_SOLVE_START,
264
265 /**
266 * A solution iteration has been finished
267 */
268 GAS_OP_SOLVE_STOP,
269
270 /**
271 * The setup of the problem as a preparation to solve it was started
272 */
273 GAS_OP_SOLVE_SETUP_START,
274
275 /**
276 * The setup of the problem as a preparation to solve is finished
277 */
278 GAS_OP_SOLVE_SETUP_STOP,
279
280 /**
281 * Solving of the LP problem was started
282 * MLP solver only
283 */
284 GAS_OP_SOLVE_MLP_LP_START,
285
286 /**
287 * Solving of the LP problem is done
288 * MLP solver only
289 */
290 GAS_OP_SOLVE_MLP_LP_STOP,
291
292 /**
293 * Solving of the MLP problem was started
294 * MLP solver only
295 */
296 GAS_OP_SOLVE_MLP_MLP_START,
297
298 /**
299 * Solving of the MLP problem is done
300 * MLP solver only
301 */
302 GAS_OP_SOLVE_MLP_MLP_STOP,
303
304 /**
305 * After the problem was finished, start notifications about changes
306 * to addresses
307 */
308 GAS_OP_SOLVE_UPDATE_NOTIFICATION_START,
309
310 /**
311 * After the problem was finished, notifications about changes to addresses
312 * are done
313 */
314 GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP
315};
316
317
318/**
319 * Status of a GAS_Solver_Operation operation
320 */
321enum GAS_Solver_Status
322{
323 /**
324 * Success
325 */
326 GAS_STAT_SUCCESS,
327
328 /**
329 * Failure
330 */
331 GAS_STAT_FAIL
332};
333
334
335/**
336 * Status of the operation
337 */
338enum GAS_Solver_Additional_Information
339{
340 /**
341 * No more specific information
342 */
343 GAS_INFO_NONE,
344
345 /**
346 * A full solution process is performed
347 * Quite specific to the MLP solver
348 */
349 GAS_INFO_FULL,
350
351 /**
352 * An existing solution was reused
353 * Quite specific to the MLP solver
354 */
355 GAS_INFO_UPDATED,
356
357 /**
358 * The proportional solver had to recalculate for a single network
359 */
360 GAS_INFO_PROP_SINGLE,
361
362 /**
363 * The proportional solver had to recalculate for all networks
364 */
365 GAS_INFO_PROP_ALL
366};
367
368
369/**
370 * Callback to call with additional information
371 * Used for measurement
372 *
373 * @param cls the closure
374 * @param op the operation
375 */
376typedef void
377(*GAS_solver_information_callback) (void *cls,
378 enum GAS_Solver_Operation op,
379 enum GAS_Solver_Status stat,
380 enum GAS_Solver_Additional_Information);
381
382
383/**
384 * Callback to call from solver when bandwidth for address has changed
385 *
386 * @param address the with changed bandwidth assigned
387 */
388typedef void
389(*GAS_bandwidth_changed_cb) (void *cls,
390 struct ATS_Address *address);
391
392
393/**
394 * Callback to call from solver to obtain application preference
395 * values for a peer.
396 *
397 * @param cls the cls
398 * @param id the peer id
399 * @return carry of double values containing the preferences with
400 * GNUNET_ATS_PreferenceCount elements
401 */
402typedef const double *
403(*GAS_get_preferences) (void *cls,
404 const struct GNUNET_PeerIdentity *id);
405
406
407/**
408 * Callback to call from solver to obtain application connectivity
409 * preferences for a peer.
410 *
411 * @param cls the cls
412 * @param id the peer id
413 * @return 0 if connectivity is not desired, non-null if address
414 * suggestions are requested
415 */
416typedef unsigned int
417(*GAS_get_connectivity) (void *cls,
418 const struct GNUNET_PeerIdentity *id);
419
420
421/**
422 * The ATS plugin will pass a pointer to a struct
423 * of this type as to the initialization function
424 * of the ATS plugins.
425 */
426struct GNUNET_ATS_PluginEnvironment
427{
428 /**
429 * Configuration handle to be used by the solver
430 */
431 const struct GNUNET_CONFIGURATION_Handle *cfg;
432
433 /**
434 * Statistics handle to be used by the solver
435 */
436 struct GNUNET_STATISTICS_Handle *stats;
437
438 /**
439 * Closure to pass to all callbacks in this struct.
440 */
441 void *cls;
442
443 /**
444 * Hashmap containing all addresses available
445 */
446 struct GNUNET_CONTAINER_MultiPeerMap *addresses;
447
448 /**
449 * ATS addresses callback to be notified about bandwidth assignment changes
450 */
451 GAS_bandwidth_changed_cb bandwidth_changed_cb;
452
453 /**
454 * ATS addresses function to obtain preference values
455 */
456 GAS_get_preferences get_preferences;
457
458 /**
459 * ATS addresses function to obtain preference values
460 */
461 GAS_get_connectivity get_connectivity;
462
463 /**
464 * Callback for solver to call with status information,
465 * can be NULL
466 */
467 GAS_solver_information_callback info_cb;
468
469 /**
470 * Number of networks available, size of the @e out_quota
471 * and @e in_quota arrays.
472 */
473 unsigned int network_count;
474
475 /**
476 * Array of configured outbound quotas
477 * Order according to networks in network array
478 */
479 unsigned long long out_quota[GNUNET_NT_COUNT];
480
481 /**
482 * Array of configured inbound quotas
483 * Order according to networks in network array
484 */
485 unsigned long long in_quota[GNUNET_NT_COUNT];
486};
487
488#endif
489
490/** @} */ /* end of group */
491
492/** @} */ /* end of group addition */