ipt_ACCOUNT: (tomj) done Patrick McHardy fixes (except "won't compile on older gccs"?)
[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_acc_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_acc_table {
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:
32 0: 8 bit, 1: 16bit, 2: 24 bit */
33 u_int32_t refcount; /* refcount of this table.
34 if zero, destroy it */
35 u_int32_t itemcount; /* number of IPs in this table */
36 void *data; /* pointer to the actual data,
37 depending on netmask */
38};
39
40/* Internal handle structure */
41struct ipt_acc_handle {
42 u_int32_t ip; /* base IP of network. Used for
43 caculating the final IP during
44 get_data() */
45 unsigned char depth; /* size of network. See above for
46 details */
47 u_int32_t itemcount; /* number of IPs in this table */
48 void *data; /* pointer to the actual data,
49 depending on size */
50};
51
52/* Handle structure for communication with the userspace library */
53struct ipt_acc_handle_sockopt {
54 u_int32_t handle_nr; /* Used for HANDLE_FREE */
55 char name[ACCOUNT_TABLE_NAME_LEN]; /* Used for HANDLE_PREPARE_READ/
56 HANDLE_READ_FLUSH */
57 u_int32_t itemcount; /* Used for HANDLE_PREPARE_READ/
58 HANDLE_READ_FLUSH */
59};
60
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 */
64struct ipt_acc_ip {
65 u_int32_t src_packets;
66 u_int32_t src_bytes;
67 u_int32_t dst_packets;
68 u_int32_t dst_bytes;
69};
70
71/*
72 Used for every IP when returning data
73*/
74struct ipt_acc_handle_ip {
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;
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*/
88struct ipt_acc_mask_24 {
89 struct ipt_acc_ip ip[256];
90};
91
92struct ipt_acc_mask_16 {
93 struct ipt_acc_mask_24 *mask_24[256];
94};
95
96struct ipt_acc_mask_8 {
97 struct ipt_acc_mask_16 *mask_16[256];
98};
99
100#endif /*_IPT_ACCOUNT_H*/