From 578af6f726651c2fad9fe12136465bca77e0ffd0 Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Fri, 23 Oct 2009 18:02:25 +0200 Subject: [PATCH] ACCOUNT: move private struct declarations into .c file --- extensions/ACCOUNT/xt_ACCOUNT.c | 62 +++++++++++++++++++++++++++++++++ extensions/ACCOUNT/xt_ACCOUNT.h | 54 ---------------------------- 2 files changed, 62 insertions(+), 54 deletions(-) diff --git a/extensions/ACCOUNT/xt_ACCOUNT.c b/extensions/ACCOUNT/xt_ACCOUNT.c index 34e16b1..9967896 100644 --- a/extensions/ACCOUNT/xt_ACCOUNT.c +++ b/extensions/ACCOUNT/xt_ACCOUNT.c @@ -42,6 +42,68 @@ #error "ipt_ACCOUNT needs at least a PAGE_SIZE of 4096" #endif +/** + * Internal table structure, generated by check_entry() + * @name: name of the table + * @ip: base IP address of the network + * @mask: netmask of the network + * @depth: size of network (0: 8-bit, 1: 16-bit, 2: 24-bit) + * @refcount: refcount of the table; if zero, destroy it + * @itemcount: number of IP addresses in this table + * @data; pointer to the actual data, depending on netmask + */ +struct ipt_acc_table { + char name[ACCOUNT_TABLE_NAME_LEN]; + uint32_t ip; + uint32_t netmask; + unsigned char depth; + uint32_t refcount; + uint32_t itemcount; + void *data; +}; + +/** + * Internal handle structure + * @ip: base IP address of the network. Used for caculating the final + * address during get_data(). + * @depth: size of the network; see above + * @itemcount: number of addresses in this table + */ +struct ipt_acc_handle { + uint32_t ip; + unsigned char depth; + uint32_t itemcount; + void *data; +}; + +/* Used for every IP entry + Size is 16 bytes so that 256 (class C network) * 16 + fits in one kernel (zero) page */ +struct ipt_acc_ip { + uint32_t src_packets; + uint32_t src_bytes; + uint32_t dst_packets; + uint32_t dst_bytes; +}; + +/* + * The IP addresses are organized as an array so that direct slot + * calculations are possible. + * Only 8-bit networks are preallocated, 16/24-bit networks + * allocate their slots when needed -> very efficent. + */ +struct ipt_acc_mask_24 { + struct ipt_acc_ip ip[256]; +}; + +struct ipt_acc_mask_16 { + struct ipt_acc_mask_24 *mask_24[256]; +}; + +struct ipt_acc_mask_8 { + struct ipt_acc_mask_16 *mask_16[256]; +}; + static struct ipt_acc_table *ipt_acc_tables; static struct ipt_acc_handle *ipt_acc_handles; static void *ipt_acc_tmpbuf; diff --git a/extensions/ACCOUNT/xt_ACCOUNT.h b/extensions/ACCOUNT/xt_ACCOUNT.h index 65ff4ab..1d1a222 100644 --- a/extensions/ACCOUNT/xt_ACCOUNT.h +++ b/extensions/ACCOUNT/xt_ACCOUNT.h @@ -41,32 +41,6 @@ struct ipt_acc_info { int32_t table_nr; }; -/* Internal table structure, generated by check_entry() */ -struct ipt_acc_table { - char name[ACCOUNT_TABLE_NAME_LEN]; /* name of the table */ - uint32_t ip; /* base IP of network */ - uint32_t netmask; /* netmask of the network */ - unsigned char depth; /* size of network: - 0: 8 bit, 1: 16bit, 2: 24 bit */ - uint32_t refcount; /* refcount of this table. - if zero, destroy it */ - uint32_t itemcount; /* number of IPs in this table */ - void *data; /* pointer to the actual data, - depending on netmask */ -}; - -/* Internal handle structure */ -struct ipt_acc_handle { - uint32_t ip; /* base IP of network. Used for - caculating the final IP during - get_data() */ - unsigned char depth; /* size of network. See above for - details */ - uint32_t itemcount; /* number of IPs in this table */ - void *data; /* pointer to the actual data, - depending on size */ -}; - /* Handle structure for communication with the userspace library */ struct ipt_acc_handle_sockopt { uint32_t handle_nr; /* Used for HANDLE_FREE */ @@ -76,16 +50,6 @@ struct ipt_acc_handle_sockopt { HANDLE_READ_FLUSH */ }; -/* Used for every IP entry - Size is 16 bytes so that 256 (class C network) * 16 - fits in one kernel (zero) page */ -struct ipt_acc_ip { - uint32_t src_packets; - uint32_t src_bytes; - uint32_t dst_packets; - uint32_t dst_bytes; -}; - /* Used for every IP when returning data */ @@ -97,22 +61,4 @@ struct ipt_acc_handle_ip { uint32_t dst_bytes; }; -/* - The IPs are organized as an array so that direct slot - calculations are possible. - Only 8 bit networks are preallocated, 16/24 bit networks - allocate their slots when needed -> very efficent. -*/ -struct ipt_acc_mask_24 { - struct ipt_acc_ip ip[256]; -}; - -struct ipt_acc_mask_16 { - struct ipt_acc_mask_24 *mask_24[256]; -}; - -struct ipt_acc_mask_8 { - struct ipt_acc_mask_16 *mask_16[256]; -}; - #endif /* _IPT_ACCOUNT_H */