26
33
#define IPTC_LABEL_QUEUE "QUEUE"
27
34
#define IPTC_LABEL_RETURN "RETURN"
29
/* Transparent handle type. */
30
typedef struct iptc_handle *iptc_handle_t;
32
36
/* Does this chain exist? */
33
int iptc_is_chain(const char *chain, const iptc_handle_t handle);
37
int iptc_is_chain(const char *chain, struct iptc_handle *const handle);
35
39
/* Take a snapshot of the rules. Returns NULL on error. */
36
iptc_handle_t iptc_init(const char *tablename);
40
struct iptc_handle *iptc_init(const char *tablename);
38
42
/* Cleanup after iptc_init(). */
39
void iptc_free(iptc_handle_t *h);
43
void iptc_free(struct iptc_handle *h);
41
45
/* Iterator functions to run through the chains. Returns NULL at end. */
42
const char *iptc_first_chain(iptc_handle_t *handle);
43
const char *iptc_next_chain(iptc_handle_t *handle);
46
const char *iptc_first_chain(struct iptc_handle *handle);
47
const char *iptc_next_chain(struct iptc_handle *handle);
45
49
/* Get first rule in the given chain: NULL for empty chain. */
46
50
const struct ipt_entry *iptc_first_rule(const char *chain,
47
iptc_handle_t *handle);
51
struct iptc_handle *handle);
49
53
/* Returns NULL when rules run out. */
50
54
const struct ipt_entry *iptc_next_rule(const struct ipt_entry *prev,
51
iptc_handle_t *handle);
55
struct iptc_handle *handle);
53
57
/* Returns a pointer to the target name of this entry. */
54
58
const char *iptc_get_target(const struct ipt_entry *e,
55
iptc_handle_t *handle);
59
struct iptc_handle *handle);
57
61
/* Is this a built-in chain? */
58
int iptc_builtin(const char *chain, const iptc_handle_t handle);
62
int iptc_builtin(const char *chain, struct iptc_handle *const handle);
60
64
/* Get the policy of a given built-in chain */
61
65
const char *iptc_get_policy(const char *chain,
62
66
struct ipt_counters *counter,
63
iptc_handle_t *handle);
67
struct iptc_handle *handle);
65
69
/* These functions return TRUE for OK or 0 and set errno. If errno ==
66
70
0, it means there was a version error (ie. upgrade libiptc). */
70
74
int iptc_insert_entry(const ipt_chainlabel chain,
71
75
const struct ipt_entry *e,
72
76
unsigned int rulenum,
73
iptc_handle_t *handle);
77
struct iptc_handle *handle);
75
79
/* Atomically replace rule `rulenum' in `chain' with `e'. */
76
80
int iptc_replace_entry(const ipt_chainlabel chain,
77
81
const struct ipt_entry *e,
78
82
unsigned int rulenum,
79
iptc_handle_t *handle);
83
struct iptc_handle *handle);
81
85
/* Append entry `e' to chain `chain'. Equivalent to insert with
82
86
rulenum = length of chain. */
83
87
int iptc_append_entry(const ipt_chainlabel chain,
84
88
const struct ipt_entry *e,
85
iptc_handle_t *handle);
89
struct iptc_handle *handle);
87
91
/* Delete the first rule in `chain' which matches `e', subject to
88
92
matchmask (array of length == origfw) */
89
93
int iptc_delete_entry(const ipt_chainlabel chain,
90
94
const struct ipt_entry *origfw,
91
95
unsigned char *matchmask,
92
iptc_handle_t *handle);
96
struct iptc_handle *handle);
94
98
/* Delete the rule in position `rulenum' in `chain'. */
95
99
int iptc_delete_num_entry(const ipt_chainlabel chain,
96
100
unsigned int rulenum,
97
iptc_handle_t *handle);
101
struct iptc_handle *handle);
99
103
/* Check the packet `e' on chain `chain'. Returns the verdict, or
100
104
NULL and sets errno. */
101
105
const char *iptc_check_packet(const ipt_chainlabel chain,
102
106
struct ipt_entry *entry,
103
iptc_handle_t *handle);
107
struct iptc_handle *handle);
105
109
/* Flushes the entries in the given chain (ie. empties chain). */
106
110
int iptc_flush_entries(const ipt_chainlabel chain,
107
iptc_handle_t *handle);
111
struct iptc_handle *handle);
109
113
/* Zeroes the counters in a chain. */
110
114
int iptc_zero_entries(const ipt_chainlabel chain,
111
iptc_handle_t *handle);
115
struct iptc_handle *handle);
113
117
/* Creates a new chain. */
114
118
int iptc_create_chain(const ipt_chainlabel chain,
115
iptc_handle_t *handle);
119
struct iptc_handle *handle);
117
121
/* Deletes a chain. */
118
122
int iptc_delete_chain(const ipt_chainlabel chain,
119
iptc_handle_t *handle);
123
struct iptc_handle *handle);
121
125
/* Renames a chain. */
122
126
int iptc_rename_chain(const ipt_chainlabel oldname,
123
127
const ipt_chainlabel newname,
124
iptc_handle_t *handle);
128
struct iptc_handle *handle);
126
130
/* Sets the policy on a built-in chain. */
127
131
int iptc_set_policy(const ipt_chainlabel chain,
128
132
const ipt_chainlabel policy,
129
133
struct ipt_counters *counters,
130
iptc_handle_t *handle);
134
struct iptc_handle *handle);
132
136
/* Get the number of references to this chain */
133
137
int iptc_get_references(unsigned int *ref,
134
138
const ipt_chainlabel chain,
135
iptc_handle_t *handle);
139
struct iptc_handle *handle);
137
141
/* read packet and byte counters for a specific rule */
138
142
struct ipt_counters *iptc_read_counter(const ipt_chainlabel chain,
139
143
unsigned int rulenum,
140
iptc_handle_t *handle);
144
struct iptc_handle *handle);
142
146
/* zero packet and byte counters for a specific rule */
143
147
int iptc_zero_counter(const ipt_chainlabel chain,
144
148
unsigned int rulenum,
145
iptc_handle_t *handle);
149
struct iptc_handle *handle);
147
151
/* set packet and byte counters for a specific rule */
148
152
int iptc_set_counter(const ipt_chainlabel chain,
149
153
unsigned int rulenum,
150
154
struct ipt_counters *counters,
151
iptc_handle_t *handle);
155
struct iptc_handle *handle);
153
157
/* Makes the actual changes. */
154
int iptc_commit(iptc_handle_t *handle);
158
int iptc_commit(struct iptc_handle *handle);
156
160
/* Get raw socket. */
157
161
int iptc_get_raw_socket(void);