~ubuntu-branches/ubuntu/quantal/iptables/quantal-proposed

« back to all changes in this revision

Viewing changes to include/libiptc/libiptc.h

  • Committer: Bazaar Package Importer
  • Author(s): Nicolas Valcárcel Scerpella
  • Date: 2009-05-06 16:35:21 UTC
  • mfrom: (5.1.6 upstream) (2.1.2 lenny)
  • Revision ID: james.westby@ubuntu.com-20090506163521-2hbruo0m33h04wxf
Tags: 1.4.3.2-2ubuntu1
* Merge from debian unstable (LP: #372920), remaining changes:
  - Don't fail to run iptables-save if iptables module isn't loaded.
  - debian/patches/0901-build-libipq_pic.a.patch - Build libipq_pic.a with
    -fPIC. Upstream changed build system and patch modified accordingly.
  - Revert changes between 1.4.1.1-3 and 1.4.1.1-4, thus bringing back
    the howtos.
* Droped unexistent patches from debian/patches/series
* Droped 0903-autoload-module-in-iptables-save.diff, fixed upstream
* Added linuxdoc-tools to Build-Depends
* Modified debian/iptables{,-dev}.install to match DM syntax 
  (removed debian/tmp)

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 
5
5
#include <linux/types.h>
6
6
#include <libiptc/ipt_kernel_headers.h>
 
7
#ifdef __cplusplus
 
8
#       include <climits>
 
9
#else
 
10
#       include <limits.h> /* INT_MAX in ip_tables.h */
 
11
#endif
7
12
#include <linux/netfilter_ipv4/ip_tables.h>
8
13
 
9
14
#ifdef __cplusplus
19
24
 
20
25
#define IPT_ALIGN(s) (((s) + ((IPT_MIN_ALIGN)-1)) & ~((IPT_MIN_ALIGN)-1))
21
26
 
 
27
struct iptc_handle;
 
28
 
22
29
typedef char ipt_chainlabel[32];
23
30
 
24
31
#define IPTC_LABEL_ACCEPT  "ACCEPT"
26
33
#define IPTC_LABEL_QUEUE   "QUEUE"
27
34
#define IPTC_LABEL_RETURN  "RETURN"
28
35
 
29
 
/* Transparent handle type. */
30
 
typedef struct iptc_handle *iptc_handle_t;
31
 
 
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);
34
38
 
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);
37
41
 
38
42
/* Cleanup after iptc_init(). */
39
 
void iptc_free(iptc_handle_t *h);
 
43
void iptc_free(struct iptc_handle *h);
40
44
 
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);
44
48
 
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);
48
52
 
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);
52
56
 
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);
56
60
 
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);
59
63
 
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);
64
68
 
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);
74
78
 
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);
80
84
 
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);
86
90
 
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);
93
97
 
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);
98
102
 
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);
104
108
 
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);
108
112
 
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);
112
116
 
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);
116
120
 
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);
120
124
 
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);
125
129
 
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);
131
135
 
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);
136
140
 
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);
141
145
 
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);
146
150
 
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);
152
156
 
153
157
/* Makes the actual changes. */
154
 
int iptc_commit(iptc_handle_t *handle);
 
158
int iptc_commit(struct iptc_handle *handle);
155
159
 
156
160
/* Get raw socket. */
157
161
int iptc_get_raw_socket(void);
159
163
/* Translates errno numbers into more human-readable form than strerror. */
160
164
const char *iptc_strerror(int err);
161
165
 
162
 
extern void dump_entries(const iptc_handle_t);
 
166
extern void dump_entries(struct iptc_handle *const);
163
167
 
164
168
#ifdef __cplusplus
165
169
}