]>
git.ipfire.org Git - thirdparty/bird.git/blob - lib/tbf.c
2 * BIRD Library -- Token Bucket Filter
4 * (c) 2014 Ondrej Zajicek <santiago@crfreenet.org>
5 * (c) 2014 CZ.NIC z.s.p.o.
7 * Can be freely distributed and used under the terms of the GNU GPL.
10 #include "nest/bird.h"
13 tbf_update(struct tbf
*f
)
15 bird_clock_t delta
= now
- f
->timestamp
;
22 if ((0 < delta
) && (delta
< f
->burst
))
24 u32 next
= f
->count
+ delta
* f
->rate
;
25 f
->count
= MIN(next
, f
->burst
);