2 This file is part of GNUnet
3 Copyright (C) 2009-2015, 2018 GNUnet e.V.
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.
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.
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/>.
20 * @author Christian Grothoff
23 * API for the ATS solvers.
25 * @defgroup ats-plugin ATS service plugin API
26 * Plugin API for the ATS service.
28 * Specifies the struct that is given to the plugin's entry method and the other
29 * struct that must be returned. Note that the destructors of ATS plugins will
30 * be given the value returned by the constructor and is expected to return a
38 #include "gnunet_mq_lib.h"
39 #include "gnunet_bandwidth_lib.h"
40 #include "gnunet_ats_application_service.h"
41 #include "gnunet_ats_transport_service.h"
42 #include "gnunet_statistics_service.h"
46 * Preference being expressed by an application client.
48 struct GNUNET_ATS_Preference {
51 * Peer to get address suggestions for.
53 struct GNUNET_PeerIdentity peer;
56 * How much bandwidth in bytes/second does the application expect?
58 struct GNUNET_BANDWIDTH_Value32NBO bw;
61 * What type of performance preference does the client have?
63 enum GNUNET_MQ_PreferenceKind pk;
68 * Opaque representation of a session the plugin can allocate bandwidth for.
70 struct GNUNET_ATS_Session;
73 * Plugin-relevant information about a session.
75 struct GNUNET_ATS_SessionData {
78 * Peer the session is with.
80 struct GNUNET_PeerIdentity peer;
83 * ATS performance characteristics for a session.
85 struct GNUNET_ATS_Properties prop;
88 * Handle to the session that has the given properties.
90 struct GNUNET_ATS_Session *session;
93 * Is the session inbound only?
100 * Internal representation of a preference by the plugin.
101 * (If desired, plugin may just use NULL.)
103 struct GNUNET_ATS_PreferenceHandle;
106 * Internal representation of a session by the plugin.
107 * (If desired, plugin may just use NULL.)
109 struct GNUNET_ATS_SessionHandle;
115 * Each solver is required to set up and return an instance
116 * of this struct during initialization.
118 struct GNUNET_ATS_SolverFunctions
122 * Closure to pass to all solver functions in this struct.
127 * The plugin should begin to respect a new preference.
129 * @param cls the closure
130 * @param pref the preference to add
131 * @return plugin's internal representation, or NULL
133 struct GNUNET_ATS_PreferenceHandle *
134 (*preference_add)(void *cls,
135 const struct GNUNET_ATS_Preference *pref);
138 * The plugin should end respecting a preference.
140 * @param cls the closure
141 * @param ph whatever @e preference_add returned
142 * @param pref the preference to delete
143 * @return plugin's internal representation, or NULL
146 (*preference_del)(void *cls,
147 struct GNUNET_ATS_PreferenceHandle *ph,
148 const struct GNUNET_ATS_Preference *pref);
151 struct GNUNET_ATS_SessionHandle *
152 (*session_add)(void *cls,
153 const struct GNUNET_ATS_SessionData *data);
156 (*session_update)(void *cls,
157 struct GNUNET_ATS_SessionHandle *sh,
158 const struct GNUNET_ATS_SessionData *data);
161 (*session_del)(void *cls,
162 struct GNUNET_ATS_SessionHandle *sh,
163 const struct GNUNET_ATS_SessionData *data);
169 /** @} */ /* end of group */