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