Commit | Line | Data |
---|---|---|
35a8230b TJ |
1 | #ifndef _IPT_ACCOUNT_H |
2 | #define _IPT_ACCOUNT_H | |
3 | ||
3e722f3c | 4 | #define ACCOUNT_MAX_TABLES 32 |
35a8230b | 5 | #define ACCOUNT_TABLE_NAME_LEN 32 |
3e722f3c | 6 | #define ACCOUNT_MAX_HANDLES 10 |
35a8230b | 7 | |
3e722f3c | 8 | /* Structure for the userspace part of ipt_ACCOUNT */ |
35a8230b TJ |
9 | struct ipt_account_info { |
10 | u_int32_t net_ip; | |
11 | u_int32_t net_mask; | |
12 | char table_name[ACCOUNT_TABLE_NAME_LEN]; | |
13 | int32_t table_nr; | |
14 | }; | |
15 | ||
3e722f3c TJ |
16 | /* Internal table structure, generated by check_entry() */ |
17 | struct ipt_account_table | |
18 | { | |
19 | char name[ACCOUNT_TABLE_NAME_LEN]; /* name of the table */ | |
70288420 TJ |
20 | unsigned int ip; /* base IP of network */ |
21 | unsigned int netmask; /* netmask of the network */ | |
22 | unsigned char netsize; /* Number of bits used in this netmask */ | |
3e722f3c TJ |
23 | unsigned int refcount; /* refcount of this table. if zero, destroy it */ |
24 | unsigned int itemcount; /* number of IPs in this table */ | |
25 | void *data; /* pointer to the actual data, depending on netmask */ | |
26 | }; | |
27 | ||
28 | /* Handle structure for communication with the userspace library */ | |
29 | struct ipt_account_handle | |
30 | { | |
31 | unsigned int ip; /* base IP of network */ | |
32 | unsigned char netmask; /* netmask of the network */ | |
33 | unsigned int itemcount; /* number of IPs in this table */ | |
34 | void *data; /* pointer to the actual data, depending on netmask */ | |
35 | }; | |
36 | ||
37 | /* Used for every IP entry */ | |
38 | /* Size is 16 bytes so that 256 (class C network) * 16 fits in one kernel (zero) page */ | |
39 | struct ipt_account_ip | |
40 | { | |
41 | unsigned int src_packets; | |
42 | unsigned int src_bytes; | |
43 | unsigned int dst_packets; | |
44 | unsigned int dst_bytes; | |
45 | }; | |
46 | ||
47 | /* | |
48 | Used for every IP when returning data | |
49 | */ | |
50 | struct ipt_account_handle_ip | |
51 | { | |
52 | unsigned int ip; | |
53 | unsigned int src_packets; | |
54 | unsigned int src_bytes; | |
55 | unsigned int dst_packets; | |
56 | unsigned int dst_bytes; | |
57 | }; | |
58 | ||
59 | /* | |
60 | The IPs are organized as an array so that direct slot | |
61 | calculations are possible. | |
62 | Only 8 bit networks are preallocated, 16/24 bit networks | |
63 | allocate their slots when needed -> very efficent. | |
64 | */ | |
65 | struct ipt_account_mask_24 | |
66 | { | |
67 | struct ipt_account_ip ip[256]; | |
68 | }; | |
69 | ||
e5da6d22 | 70 | struct ipt_account_mask_16 |
3e722f3c TJ |
71 | { |
72 | struct ipt_account_mask_24 *mask_24[256]; | |
73 | }; | |
74 | ||
75 | struct ipt_account_mask_8 | |
76 | { | |
77 | struct ipt_account_mask_16 *mask_16[256]; | |
78 | }; | |
79 | ||
35a8230b | 80 | #endif /*_IPT_ACCOUNT_H*/ |