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

« back to all changes in this revision

Viewing changes to include/xtables.h.in

  • 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:
1
1
#ifndef _XTABLES_H
2
2
#define _XTABLES_H
3
3
 
 
4
/*
 
5
 * Changing any structs/functions may incur a needed change
 
6
 * in libxtables_vcurrent/vage too.
 
7
 */
 
8
 
 
9
#include <sys/socket.h> /* PF_* */
4
10
#include <sys/types.h>
 
11
#include <limits.h>
 
12
#include <stdbool.h>
 
13
#include <netinet/in.h>
 
14
#include <net/if.h>
5
15
#include <linux/types.h>
 
16
#include <linux/netfilter.h>
6
17
#include <linux/netfilter/x_tables.h>
7
 
#include <libiptc/libxtc.h>
8
 
#include <stdbool.h>
9
18
 
10
19
#ifndef IPPROTO_SCTP
11
20
#define IPPROTO_SCTP 132
13
22
#ifndef IPPROTO_DCCP
14
23
#define IPPROTO_DCCP 33
15
24
#endif
 
25
#ifndef IPPROTO_MH
 
26
#       define IPPROTO_MH 135
 
27
#endif
16
28
#ifndef IPPROTO_UDPLITE
17
29
#define IPPROTO_UDPLITE 136
18
30
#endif
19
31
 
20
 
#define XTABLES_VERSION "@PACKAGE_VERSION@"
21
 
#define XTABLES_VERSION_CODE (0x10000 * @XTABLES_VERSION_MAJOR@ + 0x100 * @XTABLES_VERSION_MINOR@ + @XTABLES_VERSION_PATCH@)
 
32
#define XTABLES_VERSION "libxtables.so.@libxtables_vmajor@"
 
33
#define XTABLES_VERSION_CODE @libxtables_vmajor@
22
34
 
23
 
#define XTABLES_API_VERSION(x,y,z)    (0x10000*(x) + 0x100*(y) + z)
 
35
struct in_addr;
24
36
 
25
37
/* Include file for additions: new matches and targets. */
26
38
struct xtables_match
27
39
{
 
40
        /*
 
41
         * ABI/API version this module requires. Must be first member,
 
42
         * as the rest of this struct may be subject to ABI changes.
 
43
         */
 
44
        const char *version;
 
45
 
28
46
        struct xtables_match *next;
29
47
 
30
 
        xt_chainlabel name;
 
48
        const char *name;
31
49
 
32
50
        /* Revision of match (0 by default). */
33
51
        u_int8_t revision;
34
52
 
35
53
        u_int16_t family;
36
54
 
37
 
        const char *version;
38
 
 
39
55
        /* Size of match data. */
40
56
        size_t size;
41
57
 
81
97
 
82
98
struct xtables_target
83
99
{
 
100
        /*
 
101
         * ABI/API version this module requires. Must be first member,
 
102
         * as the rest of this struct may be subject to ABI changes.
 
103
         */
 
104
        const char *version;
 
105
 
84
106
        struct xtables_target *next;
85
107
 
86
 
        xt_chainlabel name;
 
108
 
 
109
        const char *name;
87
110
 
88
111
        /* Revision of target (0 by default). */
89
112
        u_int8_t revision;
90
113
 
91
114
        u_int16_t family;
92
115
 
93
 
        const char *version;
94
116
 
95
117
        /* Size of target data. */
96
118
        size_t size;
135
157
#endif
136
158
};
137
159
 
 
160
struct xtables_rule_match {
 
161
        struct xtables_rule_match *next;
 
162
        struct xtables_match *match;
 
163
        /* Multiple matches of the same type: the ones before
 
164
           the current one are completed from parsing point of view */
 
165
        bool completed;
 
166
};
 
167
 
 
168
/**
 
169
 * struct xtables_pprot -
 
170
 *
 
171
 * A few hardcoded protocols for 'all' and in case the user has no
 
172
 * /etc/protocols.
 
173
 */
 
174
struct xtables_pprot {
 
175
        const char *name;
 
176
        u_int8_t num;
 
177
};
 
178
 
 
179
enum xtables_tryload {
 
180
        XTF_DONT_LOAD,
 
181
        XTF_DURING_LOAD,
 
182
        XTF_TRY_LOAD,
 
183
        XTF_LOAD_MUST_SUCCEED,
 
184
};
 
185
 
 
186
enum xtables_exittype {
 
187
        OTHER_PROBLEM = 1,
 
188
        PARAMETER_PROBLEM,
 
189
        VERSION_PROBLEM,
 
190
        RESOURCE_PROBLEM,
 
191
        XTF_ONLY_ONCE,
 
192
        XTF_NO_INVERT,
 
193
        XTF_BAD_VALUE,
 
194
        XTF_ONE_ACTION,
 
195
};
 
196
 
 
197
struct xtables_globals
 
198
{
 
199
        unsigned int option_offset;
 
200
        const char *program_name, *program_version;
 
201
        struct option *orig_opts;
 
202
        struct option *opts;
 
203
        void (*exit_err)(enum xtables_exittype status, const char *msg, ...) __attribute__((noreturn, format(printf,2,3)));
 
204
};
 
205
 
 
206
extern const char *xtables_modprobe_program;
 
207
extern struct xtables_match *xtables_matches;
 
208
extern struct xtables_target *xtables_targets;
 
209
 
 
210
extern void xtables_init(void);
 
211
extern void xtables_set_nfproto(uint8_t);
 
212
extern void *xtables_calloc(size_t, size_t);
 
213
extern void *xtables_malloc(size_t);
 
214
 
 
215
extern int xtables_insmod(const char *, const char *, bool);
 
216
extern int xtables_load_ko(const char *, bool);
 
217
extern int xtables_set_params(struct xtables_globals *xtp);
 
218
extern void xtables_set_revision(char *name, u_int8_t revision);
 
219
extern void xtables_free_opts(int reset_offset);
 
220
extern struct option *xtables_merge_options(struct option *oldopts,
 
221
        const struct option *newopts, unsigned int *option_offset);
 
222
 
 
223
extern int xtables_init_all(struct xtables_globals *xtp, uint8_t nfproto);
 
224
extern struct xtables_match *xtables_find_match(const char *name,
 
225
        enum xtables_tryload, struct xtables_rule_match **match);
 
226
extern struct xtables_target *xtables_find_target(const char *name,
 
227
        enum xtables_tryload);
 
228
 
138
229
/* Your shared library should call one of these. */
139
230
extern void xtables_register_match(struct xtables_match *me);
140
231
extern void xtables_register_target(struct xtables_target *me);
141
232
 
142
 
extern int string_to_number_ll(const char *s,
143
 
                               unsigned long long min,
144
 
                               unsigned long long max,
145
 
                               unsigned long long *ret);
146
 
extern int string_to_number_l(const char *s,
147
 
                              unsigned long min,
148
 
                              unsigned long max,
149
 
                              unsigned long *ret);
150
 
extern int string_to_number(const char *s,
151
 
                            unsigned int min,
152
 
                            unsigned int max,
153
 
                            unsigned int *ret);
154
 
extern bool strtonuml(const char *, char **, unsigned long *,
 
233
extern bool xtables_strtoul(const char *, char **, unsigned long *,
155
234
        unsigned long, unsigned long);
156
 
extern bool strtonum(const char *, char **, unsigned int *,
 
235
extern bool xtables_strtoui(const char *, char **, unsigned int *,
157
236
        unsigned int, unsigned int);
158
 
extern int service_to_port(const char *name, const char *proto);
159
 
extern u_int16_t parse_port(const char *port, const char *proto);
 
237
extern int xtables_service_to_port(const char *name, const char *proto);
 
238
extern u_int16_t xtables_parse_port(const char *port, const char *proto);
160
239
extern void
161
 
parse_interface(const char *arg, char *vianame, unsigned char *mask);
162
 
 
163
 
enum exittype {
164
 
        OTHER_PROBLEM = 1,
165
 
        PARAMETER_PROBLEM,
166
 
        VERSION_PROBLEM,
167
 
        RESOURCE_PROBLEM,
168
 
        P_ONLY_ONCE,
169
 
        P_NO_INVERT,
170
 
        P_BAD_VALUE,
171
 
        P_ONE_ACTION,
172
 
};
 
240
xtables_parse_interface(const char *arg, char *vianame, unsigned char *mask);
173
241
 
174
242
/* this is a special 64bit data type that is 8-byte aligned */
175
243
#define aligned_u64 u_int64_t __attribute__((aligned(8)))
176
244
 
177
 
int check_inverse(const char option[], int *invert, int *my_optind, int argc);
178
 
void exit_error(enum exittype, const char *, ...)__attribute__((noreturn,
179
 
                                                          format(printf,2,3)));
180
 
extern void param_act(unsigned int, const char *, ...);
181
 
extern const char *program_name, *program_version;
182
 
 
183
 
extern const char *ipaddr_to_numeric(const struct in_addr *);
184
 
extern const char *ipaddr_to_anyname(const struct in_addr *);
185
 
extern const char *ipmask_to_numeric(const struct in_addr *);
186
 
extern struct in_addr *numeric_to_ipaddr(const char *);
187
 
extern struct in_addr *numeric_to_ipmask(const char *);
188
 
extern void ipparse_hostnetworkmask(const char *, struct in_addr **,
 
245
int xtables_check_inverse(const char option[], int *invert,
 
246
        int *my_optind, int argc);
 
247
extern struct xtables_globals *xt_params;
 
248
#define xtables_error (xt_params->exit_err)
 
249
 
 
250
extern void xtables_param_act(unsigned int, const char *, ...);
 
251
 
 
252
extern const char *xtables_ipaddr_to_numeric(const struct in_addr *);
 
253
extern const char *xtables_ipaddr_to_anyname(const struct in_addr *);
 
254
extern const char *xtables_ipmask_to_numeric(const struct in_addr *);
 
255
extern struct in_addr *xtables_numeric_to_ipaddr(const char *);
 
256
extern struct in_addr *xtables_numeric_to_ipmask(const char *);
 
257
extern void xtables_ipparse_any(const char *, struct in_addr **,
189
258
        struct in_addr *, unsigned int *);
190
259
 
191
 
extern struct in6_addr *numeric_to_ip6addr(const char *);
192
 
extern const char *ip6addr_to_numeric(const struct in6_addr *);
193
 
extern const char *ip6addr_to_anyname(const struct in6_addr *);
194
 
extern const char *ip6mask_to_numeric(const struct in6_addr *);
195
 
extern void ip6parse_hostnetworkmask(const char *, struct in6_addr **,
 
260
extern struct in6_addr *xtables_numeric_to_ip6addr(const char *);
 
261
extern const char *xtables_ip6addr_to_numeric(const struct in6_addr *);
 
262
extern const char *xtables_ip6addr_to_anyname(const struct in6_addr *);
 
263
extern const char *xtables_ip6mask_to_numeric(const struct in6_addr *);
 
264
extern void xtables_ip6parse_any(const char *, struct in6_addr **,
196
265
        struct in6_addr *, unsigned int *);
197
266
 
198
267
/**
199
268
 * Print the specified value to standard output, quoting dangerous
200
269
 * characters if required.
201
270
 */
202
 
extern void save_string(const char *value);
 
271
extern void xtables_save_string(const char *value);
203
272
 
204
273
#ifdef NO_SHARED_LIBS
205
274
#       ifdef _INIT
211
280
#       define _init __attribute__((constructor)) _INIT
212
281
#endif
213
282
 
214
 
/* Present in both iptables.c and ip6tables.c */
215
 
extern u_int16_t parse_protocol(const char *s);
 
283
extern const struct xtables_pprot xtables_chain_protos[];
 
284
extern u_int16_t xtables_parse_protocol(const char *s);
216
285
 
217
286
#ifdef XTABLES_INTERNAL
218
 
#       include <xtables/internal.h>
 
287
 
 
288
/* Shipped modules rely on this... */
 
289
 
 
290
#       ifndef ARRAY_SIZE
 
291
#               define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x)))
 
292
#       endif
 
293
 
 
294
extern void _init(void);
 
295
 
219
296
#endif
220
297
 
221
298
#endif /* _XTABLES_H */