Commit | Line | Data |
---|---|---|
54756114 TJ |
1 | /*************************************************************************** |
2 | * Copyright (C) 2004 by Intra2net AG * | |
3 | * opensource@intra2net.com * | |
4 | * * | |
5 | * This program is free software; you can redistribute it and/or modify * | |
6 | * it under the terms of the GNU General Public License * | |
7 | * version 2 as published by the Free Software Foundation; * | |
8 | * * | |
9 | ***************************************************************************/ | |
10 | ||
35a8230b TJ |
11 | #ifndef _IPT_ACCOUNT_H |
12 | #define _IPT_ACCOUNT_H | |
13 | ||
ac83062b | 14 | #define ACCOUNT_MAX_TABLES 128 |
35a8230b | 15 | #define ACCOUNT_TABLE_NAME_LEN 32 |
3e722f3c | 16 | #define ACCOUNT_MAX_HANDLES 10 |
35a8230b | 17 | |
3e722f3c | 18 | /* Structure for the userspace part of ipt_ACCOUNT */ |
6803acfc | 19 | struct ipt_acc_info { |
2ea7a43c TJ |
20 | u_int32_t net_ip; |
21 | u_int32_t net_mask; | |
22 | char table_name[ACCOUNT_TABLE_NAME_LEN]; | |
23 | int32_t table_nr; | |
35a8230b TJ |
24 | }; |
25 | ||
3e722f3c | 26 | /* Internal table structure, generated by check_entry() */ |
6803acfc | 27 | struct ipt_acc_table { |
6fe5ced9 TJ |
28 | char name[ACCOUNT_TABLE_NAME_LEN]; /* name of the table */ |
29 | u_int32_t ip; /* base IP of network */ | |
30 | u_int32_t netmask; /* netmask of the network */ | |
31 | unsigned char depth; /* size of network: | |
013fcc80 | 32 | 0: 8 bit, 1: 16bit, 2: 24 bit */ |
6fe5ced9 | 33 | u_int32_t refcount; /* refcount of this table. |
013fcc80 | 34 | if zero, destroy it */ |
6fe5ced9 TJ |
35 | u_int32_t itemcount; /* number of IPs in this table */ |
36 | void *data; /* pointer to the actual data, | |
013fcc80 | 37 | depending on netmask */ |
3e722f3c TJ |
38 | }; |
39 | ||
bea3921b | 40 | /* Internal handle structure */ |
6803acfc | 41 | struct ipt_acc_handle { |
6fe5ced9 | 42 | u_int32_t ip; /* base IP of network. Used for |
013fcc80 GE |
43 | caculating the final IP during |
44 | get_data() */ | |
6fe5ced9 | 45 | unsigned char depth; /* size of network. See above for |
013fcc80 | 46 | details */ |
6fe5ced9 TJ |
47 | u_int32_t itemcount; /* number of IPs in this table */ |
48 | void *data; /* pointer to the actual data, | |
013fcc80 | 49 | depending on size */ |
bea3921b TJ |
50 | }; |
51 | ||
52 | /* Handle structure for communication with the userspace library */ | |
6803acfc | 53 | struct ipt_acc_handle_sockopt { |
6fe5ced9 TJ |
54 | u_int32_t handle_nr; /* Used for HANDLE_FREE */ |
55 | char name[ACCOUNT_TABLE_NAME_LEN]; /* Used for HANDLE_PREPARE_READ/ | |
013fcc80 | 56 | HANDLE_READ_FLUSH */ |
6fe5ced9 | 57 | u_int32_t itemcount; /* Used for HANDLE_PREPARE_READ/ |
013fcc80 | 58 | HANDLE_READ_FLUSH */ |
3e722f3c TJ |
59 | }; |
60 | ||
013fcc80 GE |
61 | /* Used for every IP entry |
62 | Size is 16 bytes so that 256 (class C network) * 16 | |
63 | fits in one kernel (zero) page */ | |
6803acfc | 64 | struct ipt_acc_ip { |
6fe5ced9 TJ |
65 | u_int32_t src_packets; |
66 | u_int32_t src_bytes; | |
67 | u_int32_t dst_packets; | |
68 | u_int32_t dst_bytes; | |
3e722f3c TJ |
69 | }; |
70 | ||
71 | /* | |
72 | Used for every IP when returning data | |
73 | */ | |
6803acfc | 74 | struct ipt_acc_handle_ip { |
6fe5ced9 TJ |
75 | u_int32_t ip; |
76 | u_int32_t src_packets; | |
77 | u_int32_t src_bytes; | |
78 | u_int32_t dst_packets; | |
79 | u_int32_t dst_bytes; | |
3e722f3c TJ |
80 | }; |
81 | ||
82 | /* | |
83 | The IPs are organized as an array so that direct slot | |
84 | calculations are possible. | |
85 | Only 8 bit networks are preallocated, 16/24 bit networks | |
86 | allocate their slots when needed -> very efficent. | |
87 | */ | |
6803acfc TJ |
88 | struct ipt_acc_mask_24 { |
89 | struct ipt_acc_ip ip[256]; | |
3e722f3c TJ |
90 | }; |
91 | ||
6803acfc TJ |
92 | struct ipt_acc_mask_16 { |
93 | struct ipt_acc_mask_24 *mask_24[256]; | |
3e722f3c TJ |
94 | }; |
95 | ||
6803acfc TJ |
96 | struct ipt_acc_mask_8 { |
97 | struct ipt_acc_mask_16 *mask_16[256]; | |
3e722f3c TJ |
98 | }; |
99 | ||
35a8230b | 100 | #endif /*_IPT_ACCOUNT_H*/ |