X-Git-Url: http://git.sameswireless.fr/l2tpns.git/blobdiff_plain/570d0d53855b9121b29c94bd20206e2158130997..f6f9bebeaa11fad58aedcde9a4e382f98b7ba08d:/tbf.c diff --git a/tbf.c b/tbf.c index ca3a930..117ebd8 100644 --- a/tbf.c +++ b/tbf.c @@ -1,6 +1,6 @@ // L2TPNS: token bucket filters -char const *cvs_id_tbf = "$Id: tbf.c,v 1.4 2004/07/08 16:54:35 bodea Exp $"; +char const *cvs_id_tbf = "$Id: tbf.c,v 1.6 2004/09/02 04:18:07 fred_nerk Exp $"; #define _GNU_SOURCE @@ -12,40 +12,7 @@ char const *cvs_id_tbf = "$Id: tbf.c,v 1.4 2004/07/08 16:54:35 bodea Exp $"; #include "util.h" #include "tbf.h" -// Need a time interval. - -#define TBF_MAX_QUEUE 2 // Maximum of 2 queued packet per -#define TBF_MAX_SIZE 3000 // Maxiumum queued packet size is 2048. - -#define TBF_MAX_CREDIT 6000 // Maximum 6000 bytes of credit. -#define TBF_RATE 360 // 360 bytes per 1/10th of a second. - -typedef struct { - int credit; - int lasttime; - int queued; - int oldest; // Position of packet in the ring buffer. - sessionidt sid; // associated session ID. - int max_credit; // Maximum amount of credit available (burst size). - int rate; // How many bytes of credit per second we get? (sustained rate) - void (*send)(sessionidt s, u8 *, int); // Routine to actually send out the data. - int prev; // Timer chain position. - int next; // Timer chain position. - - u32 b_queued; // Total bytes sent through this TBF - u32 b_sent; // Total bytes sucessfully made it to the network. - u32 p_queued; // ditto packets. - u32 p_sent; // ditto packets. - u32 b_dropped; // Total bytes dropped. - u32 p_dropped; // Total packets dropped. - u32 p_delayed; // Total packets not sent immediately. - - int sizes[TBF_MAX_QUEUE]; - char packets[TBF_MAX_QUEUE][TBF_MAX_SIZE]; -} tbft; - - -static tbft *filter_list = NULL; +tbft *filter_list = NULL; static int filter_list_size = 0; static int timer_chain = -1; // Head of timer chain. @@ -54,8 +21,7 @@ static void tbf_run_queue(int tbf_id); void init_tbf(void) { - filter_list = mmap(NULL, sizeof(*filter_list) * MAXTBFS, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0); - if (!filter_list) + if ((filter_list = shared_malloc(sizeof(*filter_list) * MAXTBFS)) == MAP_FAILED) return; filter_list_size = MAXTBFS;