1 /***************************************************************************
2 * Copyright (C) 2004 by Intra2net AG *
3 * opensource@intra2net.com *
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; *
9 ***************************************************************************/
11 #ifndef _IPT_ACCOUNT_H
12 #define _IPT_ACCOUNT_H
14 #define ACCOUNT_MAX_TABLES 32
15 #define ACCOUNT_TABLE_NAME_LEN 32
16 #define ACCOUNT_MAX_HANDLES 10
18 /* Structure for the userspace part of ipt_ACCOUNT */
19 struct ipt_account_info {
22 char table_name[ACCOUNT_TABLE_NAME_LEN];
26 /* Internal table structure, generated by check_entry() */
27 struct ipt_account_table
29 char name[ACCOUNT_TABLE_NAME_LEN]; /* name of the table */
30 unsigned int ip; /* base IP of network */
31 unsigned int netmask; /* netmask of the network */
32 unsigned char depth; /* size of network: 0: 8 bit, 1: 16bit, 2: 24 bit */
33 unsigned int refcount; /* refcount of this table. if zero, destroy it */
34 unsigned int itemcount; /* number of IPs in this table */
35 void *data; /* pointer to the actual data, depending on netmask */
38 /* Internal handle structure */
39 struct ipt_account_handle
41 unsigned int ip; /* base IP of network. Used for caculating the final IP during get_data() */
42 unsigned char depth; /* size of network. See above for details */
43 unsigned int itemcount; /* number of IPs in this table */
44 void *data; /* pointer to the actual data, depending on size */
47 /* Handle structure for communication with the userspace library */
48 struct ipt_account_handle_sockopt
50 unsigned int handle_nr; /* Used for HANDLE_FREE */
51 char name[ACCOUNT_TABLE_NAME_LEN]; /* Used for HANDLE_PREPARE_READ/READ_FLUSH */
52 unsigned int itemcount; /* Used for HANDLE_PREPARE_READ/READ_FLUSH */
55 /* Used for every IP entry */
56 /* Size is 16 bytes so that 256 (class C network) * 16 fits in one kernel (zero) page */
59 unsigned int src_packets;
60 unsigned int src_bytes;
61 unsigned int dst_packets;
62 unsigned int dst_bytes;
66 Used for every IP when returning data
68 struct ipt_account_handle_ip
71 unsigned int src_packets;
72 unsigned int src_bytes;
73 unsigned int dst_packets;
74 unsigned int dst_bytes;
78 The IPs are organized as an array so that direct slot
79 calculations are possible.
80 Only 8 bit networks are preallocated, 16/24 bit networks
81 allocate their slots when needed -> very efficent.
83 struct ipt_account_mask_24
85 struct ipt_account_ip ip[256];
88 struct ipt_account_mask_16
90 struct ipt_account_mask_24 *mask_24[256];
93 struct ipt_account_mask_8
95 struct ipt_account_mask_16 *mask_16[256];
98 #endif /*_IPT_ACCOUNT_H*/