diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-03-05 19:04:38 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-03-05 19:04:38 +0000 |
commit | 78a3d311f2c3c82affe6003b9bd3c17c0b2d200b (patch) | |
tree | 97eb3fb105f5c8dba0bf910da705fd59b44783ff /src/include/gnunet_bandwidth_lib.h | |
parent | 8e7b848a1828ed26285fb983f7c28b2a51017983 (diff) | |
download | gnunet-78a3d311f2c3c82affe6003b9bd3c17c0b2d200b.tar.gz gnunet-78a3d311f2c3c82affe6003b9bd3c17c0b2d200b.zip |
update-api
Diffstat (limited to 'src/include/gnunet_bandwidth_lib.h')
-rw-r--r-- | src/include/gnunet_bandwidth_lib.h | 44 |
1 files changed, 41 insertions, 3 deletions
diff --git a/src/include/gnunet_bandwidth_lib.h b/src/include/gnunet_bandwidth_lib.h index 2dbe6e562..7dfbb1543 100644 --- a/src/include/gnunet_bandwidth_lib.h +++ b/src/include/gnunet_bandwidth_lib.h | |||
@@ -21,7 +21,6 @@ | |||
21 | /** | 21 | /** |
22 | * @file include/gnunet_bandwidth_lib.h | 22 | * @file include/gnunet_bandwidth_lib.h |
23 | * @brief functions related to bandwidth (unit) | 23 | * @brief functions related to bandwidth (unit) |
24 | * | ||
25 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
26 | */ | 25 | */ |
27 | 26 | ||
@@ -95,6 +94,33 @@ GNUNET_BANDWIDTH_value_init (uint32_t bytes_per_second); | |||
95 | 94 | ||
96 | 95 | ||
97 | /** | 96 | /** |
97 | * At the given bandwidth, calculate how much traffic will be | ||
98 | * available until the given deadline. | ||
99 | * | ||
100 | * @param bps bandwidth | ||
101 | * @param deadline when is the deadline | ||
102 | * @return number of bytes available at bps until deadline | ||
103 | */ | ||
104 | uint64_t | ||
105 | GNUNET_BANDWIDTH_value_get_available_until (struct GNUNET_BANDWIDTH_Value32NBO bps, | ||
106 | struct GNUNET_TIME_Relative deadline); | ||
107 | |||
108 | |||
109 | /** | ||
110 | * At the given bandwidth, calculate how long it would take for | ||
111 | * 'size' bytes to be transmitted. | ||
112 | * | ||
113 | * @param bps bandwidth | ||
114 | * @param size number of bytes we want to have available | ||
115 | * @return how long it would take | ||
116 | */ | ||
117 | struct GNUNET_TIME_Relative | ||
118 | GNUNET_BANDWIDTH_value_get_delay_for (struct GNUNET_BANDWIDTH_Value32NBO bps, | ||
119 | uint64_t size); | ||
120 | |||
121 | |||
122 | |||
123 | /** | ||
98 | * Compute the MIN of two bandwidth values. | 124 | * Compute the MIN of two bandwidth values. |
99 | * | 125 | * |
100 | * @param b1 first value | 126 | * @param b1 first value |
@@ -135,10 +161,11 @@ GNUNET_BANDWIDTH_tracker_init (struct GNUNET_BANDWIDTH_Tracker *av, | |||
135 | * | 161 | * |
136 | * @param av tracker to update | 162 | * @param av tracker to update |
137 | * @param size number of bytes consumed | 163 | * @param size number of bytes consumed |
164 | * @return GNUNET_YES if this consumption is above the limit | ||
138 | */ | 165 | */ |
139 | void | 166 | int |
140 | GNUNET_BANDWIDTH_tracker_consume (struct GNUNET_BANDWIDTH_Tracker *av, | 167 | GNUNET_BANDWIDTH_tracker_consume (struct GNUNET_BANDWIDTH_Tracker *av, |
141 | size_t size); | 168 | ssize_t size); |
142 | 169 | ||
143 | 170 | ||
144 | /** | 171 | /** |
@@ -156,6 +183,17 @@ GNUNET_BANDWIDTH_tracker_get_delay (struct GNUNET_BANDWIDTH_Tracker *av, | |||
156 | 183 | ||
157 | 184 | ||
158 | /** | 185 | /** |
186 | * Compute how many bytes are available for consumption right now. | ||
187 | * quota. | ||
188 | * | ||
189 | * @param av tracker to query | ||
190 | * @return number of bytes available for consumption right now | ||
191 | */ | ||
192 | int64_t | ||
193 | GNUNET_BANDWIDTH_tracker_get_available (struct GNUNET_BANDWIDTH_Tracker *av); | ||
194 | |||
195 | |||
196 | /** | ||
159 | * Update quota of bandwidth tracker. | 197 | * Update quota of bandwidth tracker. |
160 | * | 198 | * |
161 | * @param av tracker to initialize | 199 | * @param av tracker to initialize |