diff options
Diffstat (limited to 'src/include/gnunet_ats_plugin_new.h')
-rw-r--r-- | src/include/gnunet_ats_plugin_new.h | 247 |
1 files changed, 0 insertions, 247 deletions
diff --git a/src/include/gnunet_ats_plugin_new.h b/src/include/gnunet_ats_plugin_new.h deleted file mode 100644 index b371321fa..000000000 --- a/src/include/gnunet_ats_plugin_new.h +++ /dev/null | |||
@@ -1,247 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2009-2015, 2018 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 | * @author Christian Grothoff | ||
23 | * | ||
24 | * @file | ||
25 | * API for the ATS solvers. | ||
26 | * | ||
27 | * @defgroup ats-plugin ATS service plugin API | ||
28 | * Plugin API for the ATS service. | ||
29 | * | ||
30 | * Specifies the struct that is given to the plugin's entry method and the other | ||
31 | * struct that must be returned. Note that the destructors of ATS plugins will | ||
32 | * be given the value returned by the constructor and is expected to return a | ||
33 | * NULL pointer. | ||
34 | * | ||
35 | * @{ | ||
36 | */ | ||
37 | #ifndef PLUGIN_ATS_H | ||
38 | #define PLUGIN_ATS_H | ||
39 | |||
40 | #include "gnunet_util_lib.h" | ||
41 | #include "gnunet_ats_application_service.h" | ||
42 | #include "gnunet_ats_transport_service.h" | ||
43 | #include "gnunet_statistics_service.h" | ||
44 | |||
45 | |||
46 | /** | ||
47 | * Preference being expressed by an application client. | ||
48 | */ | ||
49 | struct GNUNET_ATS_Preference | ||
50 | { | ||
51 | /** | ||
52 | * Peer to get address suggestions for. | ||
53 | */ | ||
54 | struct GNUNET_PeerIdentity peer; | ||
55 | |||
56 | /** | ||
57 | * How much bandwidth in bytes/second does the application expect? | ||
58 | */ | ||
59 | struct GNUNET_BANDWIDTH_Value32NBO bw; | ||
60 | |||
61 | /** | ||
62 | * What type of performance preference does the client have? | ||
63 | */ | ||
64 | enum GNUNET_MQ_PreferenceKind pk; | ||
65 | }; | ||
66 | |||
67 | |||
68 | /** | ||
69 | * Opaque representation of a session the plugin can allocate bandwidth for. | ||
70 | */ | ||
71 | struct GNUNET_ATS_Session; | ||
72 | |||
73 | /** | ||
74 | * Plugin-relevant information about a session. | ||
75 | */ | ||
76 | struct GNUNET_ATS_SessionData | ||
77 | { | ||
78 | /** | ||
79 | * Peer the session is with. | ||
80 | */ | ||
81 | struct GNUNET_PeerIdentity peer; | ||
82 | |||
83 | /** | ||
84 | * ATS performance characteristics for a session. | ||
85 | */ | ||
86 | struct GNUNET_ATS_Properties prop; | ||
87 | |||
88 | /** | ||
89 | * Handle to the session that has the given properties. | ||
90 | */ | ||
91 | struct GNUNET_ATS_Session *session; | ||
92 | |||
93 | /** | ||
94 | * Is the session inbound only? | ||
95 | */ | ||
96 | int inbound_only; | ||
97 | }; | ||
98 | |||
99 | /** | ||
100 | * Internal representation of a preference by the plugin. | ||
101 | * (If desired, plugin may just use NULL.) | ||
102 | */ | ||
103 | struct GNUNET_ATS_PreferenceHandle; | ||
104 | |||
105 | /** | ||
106 | * Internal representation of a session by the plugin. | ||
107 | * (If desired, plugin may just use NULL.) | ||
108 | */ | ||
109 | struct GNUNET_ATS_SessionHandle; | ||
110 | |||
111 | |||
112 | /** | ||
113 | * Solver functions. | ||
114 | * | ||
115 | * Each solver is required to set up and return an instance | ||
116 | * of this struct during initialization. | ||
117 | */ | ||
118 | struct GNUNET_ATS_SolverFunctions | ||
119 | { | ||
120 | /** | ||
121 | * Closure to pass to all solver functions in this struct. | ||
122 | */ | ||
123 | void *cls; | ||
124 | |||
125 | /** | ||
126 | * The plugin should begin to respect a new preference. | ||
127 | * | ||
128 | * @param cls the closure | ||
129 | * @param pref the preference to add | ||
130 | * @return plugin's internal representation, or NULL | ||
131 | */ | ||
132 | struct GNUNET_ATS_PreferenceHandle * | ||
133 | (*preference_add)(void *cls, | ||
134 | const struct GNUNET_ATS_Preference *pref); | ||
135 | |||
136 | /** | ||
137 | * The plugin should end respecting a preference. | ||
138 | * | ||
139 | * @param cls the closure | ||
140 | * @param ph whatever @e preference_add returned | ||
141 | * @param pref the preference to delete | ||
142 | * @return plugin's internal representation, or NULL | ||
143 | */ | ||
144 | void | ||
145 | (*preference_del)(void *cls, | ||
146 | struct GNUNET_ATS_PreferenceHandle *ph, | ||
147 | const struct GNUNET_ATS_Preference *pref); | ||
148 | |||
149 | /** | ||
150 | * Transport established a new session with performance | ||
151 | * characteristics given in @a data. | ||
152 | * | ||
153 | * @param cls closure | ||
154 | * @param data performance characteristics of @a sh | ||
155 | * @param address address information (for debugging) | ||
156 | * @return handle by which the plugin will identify this session | ||
157 | */ | ||
158 | struct GNUNET_ATS_SessionHandle * | ||
159 | (*session_add)(void *cls, | ||
160 | const struct GNUNET_ATS_SessionData *data, | ||
161 | const char *address); | ||
162 | |||
163 | /** | ||
164 | * @a data changed for a given @a sh, solver should consider | ||
165 | * the updated performance characteristics. | ||
166 | * | ||
167 | * @param cls closure | ||
168 | * @param sh session this is about | ||
169 | * @param data performance characteristics of @a sh | ||
170 | */ | ||
171 | void | ||
172 | (*session_update)(void *cls, | ||
173 | struct GNUNET_ATS_SessionHandle *sh, | ||
174 | const struct GNUNET_ATS_SessionData *data); | ||
175 | |||
176 | /** | ||
177 | * A session went away. Solver should update accordingly. | ||
178 | * | ||
179 | * @param cls closure | ||
180 | * @param sh session this is about | ||
181 | * @param data (last) performance characteristics of @a sh | ||
182 | */ | ||
183 | void | ||
184 | (*session_del)(void *cls, | ||
185 | struct GNUNET_ATS_SessionHandle *sh, | ||
186 | const struct GNUNET_ATS_SessionData *data); | ||
187 | }; | ||
188 | |||
189 | |||
190 | /** | ||
191 | * The ATS plugin will pass a pointer to a struct | ||
192 | * of this type as to the initialization function | ||
193 | * of the ATS plugins. | ||
194 | */ | ||
195 | struct GNUNET_ATS_PluginEnvironment | ||
196 | { | ||
197 | /** | ||
198 | * Configuration handle to be used by the solver | ||
199 | */ | ||
200 | const struct GNUNET_CONFIGURATION_Handle *cfg; | ||
201 | |||
202 | /** | ||
203 | * Statistics handle to be used by the solver | ||
204 | */ | ||
205 | struct GNUNET_STATISTICS_Handle *stats; | ||
206 | |||
207 | /** | ||
208 | * Closure to pass to all callbacks in this struct. | ||
209 | */ | ||
210 | void *cls; | ||
211 | |||
212 | /** | ||
213 | * Suggest to the transport that it should try establishing | ||
214 | * a connection using the given address. | ||
215 | * | ||
216 | * @param cls closure, NULL | ||
217 | * @param pid peer this is about | ||
218 | * @param address address the transport should try | ||
219 | */ | ||
220 | void | ||
221 | (*suggest_cb) (void *cls, | ||
222 | const struct GNUNET_PeerIdentity *pid, | ||
223 | const char *address); | ||
224 | |||
225 | /** | ||
226 | * Tell the transport that it should allocate the given | ||
227 | * bandwidth to the specified session. | ||
228 | * | ||
229 | * @param cls closure, NULL | ||
230 | * @param session session this is about | ||
231 | * @param peer peer this is about | ||
232 | * @param bw_in suggested bandwidth for receiving | ||
233 | * @param bw_out suggested bandwidth for transmission | ||
234 | */ | ||
235 | void | ||
236 | (*allocate_cb) (void *cls, | ||
237 | struct GNUNET_ATS_Session *session, | ||
238 | const struct GNUNET_PeerIdentity *peer, | ||
239 | struct GNUNET_BANDWIDTH_Value32NBO bw_in, | ||
240 | struct GNUNET_BANDWIDTH_Value32NBO bw_out); | ||
241 | }; | ||
242 | |||
243 | |||
244 | |||
245 | #endif | ||
246 | |||
247 | /** @} */ /* end of group */ | ||