iptables: (tomj) implemented code for userspace communication
[ipt_ACCOUNT] / linux / include / linux / netfilter_ipv4 / ipt_ACCOUNT.h
... / ...
CommitLineData
1#ifndef _IPT_ACCOUNT_H
2#define _IPT_ACCOUNT_H
3
4#define ACCOUNT_MAX_TABLES 32
5#define ACCOUNT_TABLE_NAME_LEN 32
6#define ACCOUNT_MAX_HANDLES 10
7
8/* Structure for the userspace part of ipt_ACCOUNT */
9struct 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
16/* Internal table structure, generated by check_entry() */
17struct ipt_account_table
18{
19 char name[ACCOUNT_TABLE_NAME_LEN]; /* name of the table */
20 unsigned int ip; /* base IP of network */
21 unsigned int netmask; /* netmask of the network */
22 unsigned char depth; /* size of network: 0: 8 bit, 1: 16bit, 2: 24 bit */
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/* Internal handle structure */
29struct ipt_account_handle
30{
31 unsigned int ip; /* base IP of network. Used for caculating the final IP during get_data() */
32 unsigned char depth; /* size of network. See above for details */
33 unsigned int itemcount; /* number of IPs in this table */
34 void *data; /* pointer to the actual data, depending on size */
35};
36
37/* Handle structure for communication with the userspace library */
38struct ipt_account_handle_sockopt
39{
40 unsigned int handle_nr; /* Used for HANDLE_FREE */
41 char name[ACCOUNT_TABLE_NAME_LEN]; /* Used for HANDLE_PREPARE_READ/READ_FLUSH */
42 unsigned int itemcount; /* Used for HANDLE_PREPARE_READ/READ_FLUSH */
43};
44
45/* Used for every IP entry */
46/* Size is 16 bytes so that 256 (class C network) * 16 fits in one kernel (zero) page */
47struct ipt_account_ip
48{
49 unsigned int src_packets;
50 unsigned int src_bytes;
51 unsigned int dst_packets;
52 unsigned int dst_bytes;
53};
54
55/*
56 Used for every IP when returning data
57*/
58struct ipt_account_handle_ip
59{
60 unsigned int ip;
61 unsigned int src_packets;
62 unsigned int src_bytes;
63 unsigned int dst_packets;
64 unsigned int dst_bytes;
65};
66
67/*
68 The IPs are organized as an array so that direct slot
69 calculations are possible.
70 Only 8 bit networks are preallocated, 16/24 bit networks
71 allocate their slots when needed -> very efficent.
72*/
73struct ipt_account_mask_24
74{
75 struct ipt_account_ip ip[256];
76};
77
78struct ipt_account_mask_16
79{
80 struct ipt_account_mask_24 *mask_24[256];
81};
82
83struct ipt_account_mask_8
84{
85 struct ipt_account_mask_16 *mask_16[256];
86};
87
88#endif /*_IPT_ACCOUNT_H*/