* of the GNU Lesser General Public License.
*/
-#include "ucw/lib.h"
-#include "ucw/tbf.h"
+#include <ucw/lib.h>
+#include <ucw/tbf.h>
void
tbf_init(struct token_bucket_filter *f)
b = MIN(b, f->burst);
if (b >= 1)
{
+ uint dropped = f->drop_count;
f->bucket = b - 1;
- return 1;
+ f->drop_count = 0;
+ return dropped;
}
else
{
f->bucket = b;
- return 0;
+ f->drop_count++;
+ return -f->drop_count;
}
}
for (timestamp_t now = 0; now < 3000; now += 77)
{
int res = tbf_limit(&t, now);
- msg(L_DEBUG, "t=%u result=%d bucket=%f", (uns) now, res, t.bucket);
+ msg(L_DEBUG, "t=%u result=%d bucket=%f", (uint) now, res, t.bucket);
}
return 0;
}