File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / bird / lib / tbf.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue Aug 22 12:33:54 2017 UTC (6 years, 10 months ago) by misho
Branches: bird, MAIN
CVS tags: v1_6_8p3, v1_6_3p0, v1_6_3, HEAD
bird 1.6.3

    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>