diff options
Diffstat (limited to 'src/include/gnunet_bandwidth_lib.h')
-rw-r--r-- | src/include/gnunet_bandwidth_lib.h | 50 |
1 files changed, 24 insertions, 26 deletions
diff --git a/src/include/gnunet_bandwidth_lib.h b/src/include/gnunet_bandwidth_lib.h index f941624af..945c0321a 100644 --- a/src/include/gnunet_bandwidth_lib.h +++ b/src/include/gnunet_bandwidth_lib.h | |||
@@ -16,7 +16,7 @@ | |||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @author Christian Grothoff | 22 | * @author Christian Grothoff |
@@ -47,8 +47,7 @@ GNUNET_NETWORK_STRUCT_BEGIN | |||
47 | /** | 47 | /** |
48 | * 32-bit bandwidth used for network exchange by GNUnet, in bytes per second. | 48 | * 32-bit bandwidth used for network exchange by GNUnet, in bytes per second. |
49 | */ | 49 | */ |
50 | struct GNUNET_BANDWIDTH_Value32NBO | 50 | struct GNUNET_BANDWIDTH_Value32NBO { |
51 | { | ||
52 | /** | 51 | /** |
53 | * The actual value (bytes per second). | 52 | * The actual value (bytes per second). |
54 | */ | 53 | */ |
@@ -83,8 +82,7 @@ typedef void (*GNUNET_BANDWIDTH_ExcessNotificationCallback) (void *cls); | |||
83 | * structures (reducing malloc-ing); however, values should not be | 82 | * structures (reducing malloc-ing); however, values should not be |
84 | * accessed directly by clients (hence the '__'). | 83 | * accessed directly by clients (hence the '__'). |
85 | */ | 84 | */ |
86 | struct GNUNET_BANDWIDTH_Tracker | 85 | struct GNUNET_BANDWIDTH_Tracker { |
87 | { | ||
88 | /** | 86 | /** |
89 | * Closure for @e update_cb. | 87 | * Closure for @e update_cb. |
90 | */ | 88 | */ |
@@ -140,7 +138,7 @@ struct GNUNET_BANDWIDTH_Tracker | |||
140 | /** | 138 | /** |
141 | * Convenience definition to use for 0-bandwidth. | 139 | * Convenience definition to use for 0-bandwidth. |
142 | */ | 140 | */ |
143 | #define GNUNET_BANDWIDTH_ZERO GNUNET_BANDWIDTH_value_init (0) | 141 | #define GNUNET_BANDWIDTH_ZERO GNUNET_BANDWIDTH_value_init(0) |
144 | 142 | ||
145 | 143 | ||
146 | /** | 144 | /** |
@@ -150,13 +148,13 @@ struct GNUNET_BANDWIDTH_Tracker | |||
150 | * @return the new bandwidth value | 148 | * @return the new bandwidth value |
151 | */ | 149 | */ |
152 | struct GNUNET_BANDWIDTH_Value32NBO | 150 | struct GNUNET_BANDWIDTH_Value32NBO |
153 | GNUNET_BANDWIDTH_value_init (uint32_t bytes_per_second); | 151 | GNUNET_BANDWIDTH_value_init(uint32_t bytes_per_second); |
154 | 152 | ||
155 | 153 | ||
156 | /** | 154 | /** |
157 | * Maximum possible bandwidth value. | 155 | * Maximum possible bandwidth value. |
158 | */ | 156 | */ |
159 | #define GNUNET_BANDWIDTH_VALUE_MAX GNUNET_BANDWIDTH_value_init (UINT32_MAX) | 157 | #define GNUNET_BANDWIDTH_VALUE_MAX GNUNET_BANDWIDTH_value_init(UINT32_MAX) |
160 | 158 | ||
161 | 159 | ||
162 | /** | 160 | /** |
@@ -168,7 +166,7 @@ GNUNET_BANDWIDTH_value_init (uint32_t bytes_per_second); | |||
168 | * @return number of bytes available at bps until deadline | 166 | * @return number of bytes available at bps until deadline |
169 | */ | 167 | */ |
170 | uint64_t | 168 | uint64_t |
171 | GNUNET_BANDWIDTH_value_get_available_until ( | 169 | GNUNET_BANDWIDTH_value_get_available_until( |
172 | struct GNUNET_BANDWIDTH_Value32NBO bps, | 170 | struct GNUNET_BANDWIDTH_Value32NBO bps, |
173 | struct GNUNET_TIME_Relative deadline); | 171 | struct GNUNET_TIME_Relative deadline); |
174 | 172 | ||
@@ -182,8 +180,8 @@ GNUNET_BANDWIDTH_value_get_available_until ( | |||
182 | * @return how long it would take | 180 | * @return how long it would take |
183 | */ | 181 | */ |
184 | struct GNUNET_TIME_Relative | 182 | struct GNUNET_TIME_Relative |
185 | GNUNET_BANDWIDTH_value_get_delay_for (struct GNUNET_BANDWIDTH_Value32NBO bps, | 183 | GNUNET_BANDWIDTH_value_get_delay_for(struct GNUNET_BANDWIDTH_Value32NBO bps, |
186 | uint64_t size); | 184 | uint64_t size); |
187 | 185 | ||
188 | 186 | ||
189 | /** | 187 | /** |
@@ -194,8 +192,8 @@ GNUNET_BANDWIDTH_value_get_delay_for (struct GNUNET_BANDWIDTH_Value32NBO bps, | |||
194 | * @return the min of b1 and b2 | 192 | * @return the min of b1 and b2 |
195 | */ | 193 | */ |
196 | struct GNUNET_BANDWIDTH_Value32NBO | 194 | struct GNUNET_BANDWIDTH_Value32NBO |
197 | GNUNET_BANDWIDTH_value_min (struct GNUNET_BANDWIDTH_Value32NBO b1, | 195 | GNUNET_BANDWIDTH_value_min(struct GNUNET_BANDWIDTH_Value32NBO b1, |
198 | struct GNUNET_BANDWIDTH_Value32NBO b2); | 196 | struct GNUNET_BANDWIDTH_Value32NBO b2); |
199 | 197 | ||
200 | 198 | ||
201 | /** | 199 | /** |
@@ -206,8 +204,8 @@ GNUNET_BANDWIDTH_value_min (struct GNUNET_BANDWIDTH_Value32NBO b1, | |||
206 | * @return the min of b1 and b2 | 204 | * @return the min of b1 and b2 |
207 | */ | 205 | */ |
208 | struct GNUNET_BANDWIDTH_Value32NBO | 206 | struct GNUNET_BANDWIDTH_Value32NBO |
209 | GNUNET_BANDWIDTH_value_max (struct GNUNET_BANDWIDTH_Value32NBO b1, | 207 | GNUNET_BANDWIDTH_value_max(struct GNUNET_BANDWIDTH_Value32NBO b1, |
210 | struct GNUNET_BANDWIDTH_Value32NBO b2); | 208 | struct GNUNET_BANDWIDTH_Value32NBO b2); |
211 | 209 | ||
212 | 210 | ||
213 | /** | 211 | /** |
@@ -218,8 +216,8 @@ GNUNET_BANDWIDTH_value_max (struct GNUNET_BANDWIDTH_Value32NBO b1, | |||
218 | * @return the sum of b1 and b2 | 216 | * @return the sum of b1 and b2 |
219 | */ | 217 | */ |
220 | struct GNUNET_BANDWIDTH_Value32NBO | 218 | struct GNUNET_BANDWIDTH_Value32NBO |
221 | GNUNET_BANDWIDTH_value_sum (struct GNUNET_BANDWIDTH_Value32NBO b1, | 219 | GNUNET_BANDWIDTH_value_sum(struct GNUNET_BANDWIDTH_Value32NBO b1, |
222 | struct GNUNET_BANDWIDTH_Value32NBO b2); | 220 | struct GNUNET_BANDWIDTH_Value32NBO b2); |
223 | 221 | ||
224 | 222 | ||
225 | /** | 223 | /** |
@@ -239,7 +237,7 @@ GNUNET_BANDWIDTH_value_sum (struct GNUNET_BANDWIDTH_Value32NBO b1, | |||
239 | * may accumulate before it expires | 237 | * may accumulate before it expires |
240 | */ | 238 | */ |
241 | void | 239 | void |
242 | GNUNET_BANDWIDTH_tracker_init ( | 240 | GNUNET_BANDWIDTH_tracker_init( |
243 | struct GNUNET_BANDWIDTH_Tracker *av, | 241 | struct GNUNET_BANDWIDTH_Tracker *av, |
244 | GNUNET_BANDWIDTH_TrackerUpdateCallback update_cb, | 242 | GNUNET_BANDWIDTH_TrackerUpdateCallback update_cb, |
245 | void *update_cb_cls, | 243 | void *update_cb_cls, |
@@ -266,7 +264,7 @@ GNUNET_BANDWIDTH_tracker_init ( | |||
266 | * @param excess_cb_cls closure for @a excess_cb | 264 | * @param excess_cb_cls closure for @a excess_cb |
267 | */ | 265 | */ |
268 | void | 266 | void |
269 | GNUNET_BANDWIDTH_tracker_init2 ( | 267 | GNUNET_BANDWIDTH_tracker_init2( |
270 | struct GNUNET_BANDWIDTH_Tracker *av, | 268 | struct GNUNET_BANDWIDTH_Tracker *av, |
271 | GNUNET_BANDWIDTH_TrackerUpdateCallback update_cb, | 269 | GNUNET_BANDWIDTH_TrackerUpdateCallback update_cb, |
272 | void *update_cb_cls, | 270 | void *update_cb_cls, |
@@ -282,7 +280,7 @@ GNUNET_BANDWIDTH_tracker_init2 ( | |||
282 | * @param av the respective trackers | 280 | * @param av the respective trackers |
283 | */ | 281 | */ |
284 | void | 282 | void |
285 | GNUNET_BANDWIDTH_tracker_notification_stop ( | 283 | GNUNET_BANDWIDTH_tracker_notification_stop( |
286 | struct GNUNET_BANDWIDTH_Tracker *av); | 284 | struct GNUNET_BANDWIDTH_Tracker *av); |
287 | 285 | ||
288 | 286 | ||
@@ -298,8 +296,8 @@ GNUNET_BANDWIDTH_tracker_notification_stop ( | |||
298 | * @return #GNUNET_YES if this consumption is above the limit | 296 | * @return #GNUNET_YES if this consumption is above the limit |
299 | */ | 297 | */ |
300 | int | 298 | int |
301 | GNUNET_BANDWIDTH_tracker_consume (struct GNUNET_BANDWIDTH_Tracker *av, | 299 | GNUNET_BANDWIDTH_tracker_consume(struct GNUNET_BANDWIDTH_Tracker *av, |
302 | ssize_t size); | 300 | ssize_t size); |
303 | 301 | ||
304 | 302 | ||
305 | /** | 303 | /** |
@@ -312,8 +310,8 @@ GNUNET_BANDWIDTH_tracker_consume (struct GNUNET_BANDWIDTH_Tracker *av, | |||
312 | * @return time to wait for consumption to be OK | 310 | * @return time to wait for consumption to be OK |
313 | */ | 311 | */ |
314 | struct GNUNET_TIME_Relative | 312 | struct GNUNET_TIME_Relative |
315 | GNUNET_BANDWIDTH_tracker_get_delay (struct GNUNET_BANDWIDTH_Tracker *av, | 313 | GNUNET_BANDWIDTH_tracker_get_delay(struct GNUNET_BANDWIDTH_Tracker *av, |
316 | size_t size); | 314 | size_t size); |
317 | 315 | ||
318 | 316 | ||
319 | /** | 317 | /** |
@@ -324,7 +322,7 @@ GNUNET_BANDWIDTH_tracker_get_delay (struct GNUNET_BANDWIDTH_Tracker *av, | |||
324 | * @return number of bytes available for consumption right now | 322 | * @return number of bytes available for consumption right now |
325 | */ | 323 | */ |
326 | int64_t | 324 | int64_t |
327 | GNUNET_BANDWIDTH_tracker_get_available (struct GNUNET_BANDWIDTH_Tracker *av); | 325 | GNUNET_BANDWIDTH_tracker_get_available(struct GNUNET_BANDWIDTH_Tracker *av); |
328 | 326 | ||
329 | 327 | ||
330 | /** | 328 | /** |
@@ -334,7 +332,7 @@ GNUNET_BANDWIDTH_tracker_get_available (struct GNUNET_BANDWIDTH_Tracker *av); | |||
334 | * @param bytes_per_second_limit new limit to assume | 332 | * @param bytes_per_second_limit new limit to assume |
335 | */ | 333 | */ |
336 | void | 334 | void |
337 | GNUNET_BANDWIDTH_tracker_update_quota ( | 335 | GNUNET_BANDWIDTH_tracker_update_quota( |
338 | struct GNUNET_BANDWIDTH_Tracker *av, | 336 | struct GNUNET_BANDWIDTH_Tracker *av, |
339 | struct GNUNET_BANDWIDTH_Value32NBO bytes_per_second_limit); | 337 | struct GNUNET_BANDWIDTH_Value32NBO bytes_per_second_limit); |
340 | 338 | ||