aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_bandwidth_lib.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-04-21 11:37:56 +0200
committerChristian Grothoff <christian@grothoff.org>2019-04-21 11:37:56 +0200
commit300bb8d62d412eccb1537cbdaf27b8264fa6fc19 (patch)
treee5c097394c1ccfe605e945d263198100e367426c /src/include/gnunet_bandwidth_lib.h
parent32485c3b58983ada1943b3fa27eac3b0cff2a9da (diff)
downloadgnunet-300bb8d62d412eccb1537cbdaf27b8264fa6fc19.tar.gz
gnunet-300bb8d62d412eccb1537cbdaf27b8264fa6fc19.zip
fix quota out calculation, even if it may go away
Diffstat (limited to 'src/include/gnunet_bandwidth_lib.h')
-rw-r--r--src/include/gnunet_bandwidth_lib.h70
1 files changed, 42 insertions, 28 deletions
diff --git a/src/include/gnunet_bandwidth_lib.h b/src/include/gnunet_bandwidth_lib.h
index e52ab54be..f941624af 100644
--- a/src/include/gnunet_bandwidth_lib.h
+++ b/src/include/gnunet_bandwidth_lib.h
@@ -33,9 +33,8 @@
33#define GNUNET_BANDWIDTH_LIB_H 33#define GNUNET_BANDWIDTH_LIB_H
34 34
35#ifdef __cplusplus 35#ifdef __cplusplus
36extern "C" 36extern "C" {
37{ 37#if 0 /* keep Emacsens' auto-indent happy */
38#if 0 /* keep Emacsens' auto-indent happy */
39} 38}
40#endif 39#endif
41#endif 40#endif
@@ -55,6 +54,7 @@ struct GNUNET_BANDWIDTH_Value32NBO
55 */ 54 */
56 uint32_t value__ GNUNET_PACKED; 55 uint32_t value__ GNUNET_PACKED;
57}; 56};
57
58GNUNET_NETWORK_STRUCT_END 58GNUNET_NETWORK_STRUCT_END
59 59
60 60
@@ -64,8 +64,7 @@ GNUNET_NETWORK_STRUCT_END
64 * 64 *
65 * @param cls a closure to pass 65 * @param cls a closure to pass
66 */ 66 */
67typedef void 67typedef void (*GNUNET_BANDWIDTH_TrackerUpdateCallback) (void *cls);
68(*GNUNET_BANDWIDTH_TrackerUpdateCallback) (void *cls);
69 68
70 69
71/** 70/**
@@ -74,8 +73,7 @@ typedef void
74 * 73 *
75 * @param cls a closure to pass 74 * @param cls a closure to pass
76 */ 75 */
77typedef void 76typedef void (*GNUNET_BANDWIDTH_ExcessNotificationCallback) (void *cls);
78(*GNUNET_BANDWIDTH_ExcessNotificationCallback) (void *cls);
79 77
80 78
81/** 79/**
@@ -158,7 +156,7 @@ GNUNET_BANDWIDTH_value_init (uint32_t bytes_per_second);
158/** 156/**
159 * Maximum possible bandwidth value. 157 * Maximum possible bandwidth value.
160 */ 158 */
161#define GNUNET_BANDWIDTH_VALUE_MAX GNUNET_BANDWIDTH_value_init(UINT32_MAX) 159#define GNUNET_BANDWIDTH_VALUE_MAX GNUNET_BANDWIDTH_value_init (UINT32_MAX)
162 160
163 161
164/** 162/**
@@ -170,8 +168,9 @@ GNUNET_BANDWIDTH_value_init (uint32_t bytes_per_second);
170 * @return number of bytes available at bps until deadline 168 * @return number of bytes available at bps until deadline
171 */ 169 */
172uint64_t 170uint64_t
173GNUNET_BANDWIDTH_value_get_available_until (struct GNUNET_BANDWIDTH_Value32NBO bps, 171GNUNET_BANDWIDTH_value_get_available_until (
174 struct GNUNET_TIME_Relative deadline); 172 struct GNUNET_BANDWIDTH_Value32NBO bps,
173 struct GNUNET_TIME_Relative deadline);
175 174
176 175
177/** 176/**
@@ -212,6 +211,18 @@ GNUNET_BANDWIDTH_value_max (struct GNUNET_BANDWIDTH_Value32NBO b1,
212 211
213 212
214/** 213/**
214 * Compute the SUM of two bandwidth values.
215 *
216 * @param b1 first value
217 * @param b2 second value
218 * @return the sum of b1 and b2
219 */
220struct GNUNET_BANDWIDTH_Value32NBO
221GNUNET_BANDWIDTH_value_sum (struct GNUNET_BANDWIDTH_Value32NBO b1,
222 struct GNUNET_BANDWIDTH_Value32NBO b2);
223
224
225/**
215 * Initialize bandwidth tracker. Note that in addition to the 226 * Initialize bandwidth tracker. Note that in addition to the
216 * 'max_carry_s' limit, we also always allow at least 227 * 'max_carry_s' limit, we also always allow at least
217 * #GNUNET_MAX_MESSAGE_SIZE to accumulate. So if the 228 * #GNUNET_MAX_MESSAGE_SIZE to accumulate. So if the
@@ -228,11 +239,12 @@ GNUNET_BANDWIDTH_value_max (struct GNUNET_BANDWIDTH_Value32NBO b1,
228 * may accumulate before it expires 239 * may accumulate before it expires
229 */ 240 */
230void 241void
231GNUNET_BANDWIDTH_tracker_init (struct GNUNET_BANDWIDTH_Tracker *av, 242GNUNET_BANDWIDTH_tracker_init (
232 GNUNET_BANDWIDTH_TrackerUpdateCallback update_cb, 243 struct GNUNET_BANDWIDTH_Tracker *av,
233 void *update_cb_cls, 244 GNUNET_BANDWIDTH_TrackerUpdateCallback update_cb,
234 struct GNUNET_BANDWIDTH_Value32NBO bytes_per_second_limit, 245 void *update_cb_cls,
235 uint32_t max_carry_s); 246 struct GNUNET_BANDWIDTH_Value32NBO bytes_per_second_limit,
247 uint32_t max_carry_s);
236 248
237 249
238/** 250/**
@@ -254,13 +266,14 @@ GNUNET_BANDWIDTH_tracker_init (struct GNUNET_BANDWIDTH_Tracker *av,
254 * @param excess_cb_cls closure for @a excess_cb 266 * @param excess_cb_cls closure for @a excess_cb
255 */ 267 */
256void 268void
257GNUNET_BANDWIDTH_tracker_init2 (struct GNUNET_BANDWIDTH_Tracker *av, 269GNUNET_BANDWIDTH_tracker_init2 (
258 GNUNET_BANDWIDTH_TrackerUpdateCallback update_cb, 270 struct GNUNET_BANDWIDTH_Tracker *av,
259 void *update_cb_cls, 271 GNUNET_BANDWIDTH_TrackerUpdateCallback update_cb,
260 struct GNUNET_BANDWIDTH_Value32NBO bytes_per_second_limit, 272 void *update_cb_cls,
261 uint32_t max_carry_s, 273 struct GNUNET_BANDWIDTH_Value32NBO bytes_per_second_limit,
262 GNUNET_BANDWIDTH_ExcessNotificationCallback excess_cb, 274 uint32_t max_carry_s,
263 void *excess_cb_cls); 275 GNUNET_BANDWIDTH_ExcessNotificationCallback excess_cb,
276 void *excess_cb_cls);
264 277
265 278
266/** 279/**
@@ -269,7 +282,8 @@ GNUNET_BANDWIDTH_tracker_init2 (struct GNUNET_BANDWIDTH_Tracker *av,
269 * @param av the respective trackers 282 * @param av the respective trackers
270 */ 283 */
271void 284void
272GNUNET_BANDWIDTH_tracker_notification_stop (struct GNUNET_BANDWIDTH_Tracker *av); 285GNUNET_BANDWIDTH_tracker_notification_stop (
286 struct GNUNET_BANDWIDTH_Tracker *av);
273 287
274 288
275/** 289/**
@@ -320,12 +334,12 @@ GNUNET_BANDWIDTH_tracker_get_available (struct GNUNET_BANDWIDTH_Tracker *av);
320 * @param bytes_per_second_limit new limit to assume 334 * @param bytes_per_second_limit new limit to assume
321 */ 335 */
322void 336void
323GNUNET_BANDWIDTH_tracker_update_quota (struct GNUNET_BANDWIDTH_Tracker *av, 337GNUNET_BANDWIDTH_tracker_update_quota (
324 struct GNUNET_BANDWIDTH_Value32NBO 338 struct GNUNET_BANDWIDTH_Tracker *av,
325 bytes_per_second_limit); 339 struct GNUNET_BANDWIDTH_Value32NBO bytes_per_second_limit);
326 340
327 341
328#if 0 /* keep Emacsens' auto-indent happy */ 342#if 0 /* keep Emacsens' auto-indent happy */
329{ 343{
330#endif 344#endif
331#ifdef __cplusplus 345#ifdef __cplusplus
@@ -335,6 +349,6 @@ GNUNET_BANDWIDTH_tracker_update_quota (struct GNUNET_BANDWIDTH_Tracker *av,
335/* ifndef GNUNET_BANDWIDTH_LIB_H */ 349/* ifndef GNUNET_BANDWIDTH_LIB_H */
336#endif 350#endif
337 351
338/** @} */ /* end of group */ 352/** @} */ /* end of group */
339 353
340/* end of gnunet_bandwidth_lib.h */ 354/* end of gnunet_bandwidth_lib.h */