ipt_ACCOUNT: (tomj) astyled using K&R style
[ipt_ACCOUNT] / linux / include / linux / netfilter_ipv4 / ipt_ACCOUNT.h
CommitLineData
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
3e722f3c 14#define ACCOUNT_MAX_TABLES 32
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 */
35a8230b 19struct ipt_account_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() */
2ea7a43c 27struct ipt_account_table {
3e722f3c 28 char name[ACCOUNT_TABLE_NAME_LEN]; /* name of the table */
70288420
TJ
29 unsigned int ip; /* base IP of network */
30 unsigned int netmask; /* netmask of the network */
bea3921b 31 unsigned char depth; /* size of network: 0: 8 bit, 1: 16bit, 2: 24 bit */
3e722f3c
TJ
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
bea3921b 37/* Internal handle structure */
2ea7a43c 38struct ipt_account_handle {
bea3921b
TJ
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 */
3e722f3c 41 unsigned int itemcount; /* number of IPs in this table */
bea3921b
TJ
42 void *data; /* pointer to the actual data, depending on size */
43};
44
45/* Handle structure for communication with the userspace library */
2ea7a43c 46struct ipt_account_handle_sockopt {
bea3921b
TJ
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 */
3e722f3c
TJ
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 */
2ea7a43c 54struct ipt_account_ip {
3e722f3c
TJ
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*/
2ea7a43c 64struct ipt_account_handle_ip {
3e722f3c
TJ
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*/
2ea7a43c
TJ
78struct ipt_account_mask_24 {
79 struct ipt_account_ip ip[256];
3e722f3c
TJ
80};
81
2ea7a43c 82struct ipt_account_mask_16 {
3e722f3c
TJ
83 struct ipt_account_mask_24 *mask_24[256];
84};
85
2ea7a43c 86struct ipt_account_mask_8 {
3e722f3c
TJ
87 struct ipt_account_mask_16 *mask_16[256];
88};
89
35a8230b 90#endif /*_IPT_ACCOUNT_H*/