libipt_ACCOUNT_cl: (tomj) wrote complete userspace client library for ipt_ACCOUNT
[libipt_ACCOUNT] / src / ipt_ACCOUNT_cl.h
CommitLineData
322f2b5b
TJ
1#ifndef _ipt_ACCOUNT_cl_H
2#define _ipt_ACCOUNT_cl_H
3
4// TODO: Path needs fixing
5#include "../ipt_ACCOUNT.h"
6
7// TODO: Move these to the ip_tables.h
8#define IPT_BASE_CTL 64 /* base for firewall socket options */
9#define IPT_SO_SET_ACCOUNT_HANDLE_FREE (IPT_BASE_CTL + 3)
10#define IPT_SO_SET_ACCOUNT_MAX IPT_SO_SET_ACCOUNT_HANDLE_FREE
11
12#define IPT_SO_GET_ACCOUNT_PREPARE_READ (IPT_BASE_CTL + 3)
13#define IPT_SO_GET_ACCOUNT_PREPARE_READ_FLUSH (IPT_BASE_CTL + 4)
14#define IPT_SO_GET_ACCOUNT_GET_DATA (IPT_BASE_CTL + 5)
15#define IPT_SO_GET_ACCOUNT_MAX IPT_SO_GET_ACCOUNT_GET_DATA
16
17#define IPT_ACCOUNT_MIN_BUFSIZE 4096 /* Don't set this below the size of struct ipt_account_handle_sockopt */
18
19struct ipt_ACCOUNT_context
20{
21 int sockfd;
22 struct ipt_account_handle_sockopt handle;
23
24 unsigned int data_size;
25 void *data;
26 unsigned int pos;
27
28 char *error_str;
29};
30
31int ipt_ACCOUNT_init(struct ipt_ACCOUNT_context *ctx);
32void ipt_ACCOUNT_deinit(struct ipt_ACCOUNT_context *ctx);
33
34int ipt_ACCOUNT_read_entries(struct ipt_ACCOUNT_context *ctx, char *table, char dont_flush);
35struct ipt_account_handle_ip *ipt_ACCOUNT_get_next_entry(struct ipt_ACCOUNT_context *ctx);
36/* ipt_ACCOUNT_free_entries is for internal use only function as this library
37 is constructed to be used in a loop -> Don't allocate memory all the time.
38 The data buffer is freed on deinit() */
39
40#endif