include Acct-Session-Time in interim records
[l2tpns.git] / tbf.h
1 #ifndef __TBF_H__
2 #define __TBF_H__
3
4 // Need a time interval.
5
6 #define TBF_MAX_QUEUE 2 // Maximum of 2 queued packet per
7 #define TBF_MAX_SIZE 3000 // Maxiumum queued packet size is 2048.
8
9 #define TBF_MAX_CREDIT 6000 // Maximum 6000 bytes of credit.
10 #define TBF_RATE 360 // 360 bytes per 1/10th of a second.
11
12 typedef struct {
13 int credit;
14 int lasttime;
15 int queued;
16 int oldest; // Position of packet in the ring buffer.
17 sessionidt sid; // associated session ID.
18 int max_credit; // Maximum amount of credit available (burst size).
19 int rate; // How many bytes of credit per second we get? (sustained rate)
20 void (*send)(sessionidt s, uint8_t *, int); // Routine to actually send out the data.
21 int prev; // Timer chain position.
22 int next; // Timer chain position.
23
24 uint32_t b_queued; // Total bytes sent through this TBF
25 uint32_t b_sent; // Total bytes sucessfully made it to the network.
26 uint32_t p_queued; // ditto packets.
27 uint32_t p_sent; // ditto packets.
28 uint32_t b_dropped; // Total bytes dropped.
29 uint32_t p_dropped; // Total packets dropped.
30 uint32_t p_delayed; // Total packets not sent immediately.
31
32 int sizes[TBF_MAX_QUEUE];
33 uint8_t packets[TBF_MAX_QUEUE][TBF_MAX_SIZE];
34 } tbft;
35
36 void init_tbf(int num_tbfs);
37 int tbf_run_timer(void);
38 int tbf_queue_packet(int tbf_id, uint8_t * data, int size);
39 int new_tbf(int sid, int max_credit, int rate, void (*f)(sessionidt, uint8_t *, int));
40 int free_tbf(int tid);
41 void fsck_tbfs(void);
42
43 int cmd_show_tbf(struct cli_def *cli, char *command, char **argv, int argc);
44
45 #endif /* __TBF_H__ */