Annotation of embedaddon/bird/lib/tbf.c, revision 1.1
1.1 ! misho 1: /*
! 2: * BIRD Library -- Token Bucket Filter
! 3: *
! 4: * (c) 2014 Ondrej Zajicek <santiago@crfreenet.org>
! 5: * (c) 2014 CZ.NIC z.s.p.o.
! 6: *
! 7: * Can be freely distributed and used under the terms of the GNU GPL.
! 8: */
! 9:
! 10: #include "nest/bird.h"
! 11:
! 12: void
! 13: tbf_update(struct tbf *f)
! 14: {
! 15: bird_clock_t delta = now - f->timestamp;
! 16:
! 17: if (delta == 0)
! 18: return;
! 19:
! 20: f->timestamp = now;
! 21:
! 22: if ((0 < delta) && (delta < f->burst))
! 23: {
! 24: u32 next = f->count + delta * f->rate;
! 25: f->count = MIN(next, f->burst);
! 26: }
! 27: else
! 28: f->count = f->burst;
! 29: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>