~ubuntu-branches/ubuntu/lucid/iptables/lucid

« back to all changes in this revision

Viewing changes to include/xtables.h.in

  • Committer: Bazaar Package Importer
  • Author(s): Soren Hansen, Iain Lane, Soren Hansen
  • Date: 2008-11-15 01:27:37 UTC
  • mfrom: (5.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20081115012737-o3kdn2z1o9ercq10
Tags: 1.4.1.1-4ubuntu1
[ Iain Lane ]
* Merge from debian unstable (LP: #294220), remaining changes:
  - debian/patches/0901-build-libipq_pic.a.patch - Build libipq_pic.a with
    -fPIC. Upstream changed build system and patch modified accordingly.

[ Soren Hansen ]
* Revert changes between 1.4.1.1-3 and 1.4.1.1-4, thus bringing back
  the howtos.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef _XTABLES_H
 
2
#define _XTABLES_H
 
3
 
 
4
#include <sys/types.h>
 
5
#include <linux/types.h>
 
6
#include <linux/netfilter/x_tables.h>
 
7
#include <libiptc/libxtc.h>
 
8
#include <stdbool.h>
 
9
 
 
10
#ifndef IPPROTO_SCTP
 
11
#define IPPROTO_SCTP 132
 
12
#endif
 
13
#ifndef IPPROTO_DCCP
 
14
#define IPPROTO_DCCP 33
 
15
#endif
 
16
#ifndef IPPROTO_UDPLITE
 
17
#define IPPROTO_UDPLITE 136
 
18
#endif
 
19
 
 
20
#define XTABLES_VERSION "@PACKAGE_VERSION@"
 
21
#define XTABLES_VERSION_CODE (0x10000 * @XTABLES_VERSION_MAJOR@ + 0x100 * @XTABLES_VERSION_MINOR@ + @XTABLES_VERSION_PATCH@)
 
22
 
 
23
#define XTABLES_API_VERSION(x,y,z)    (0x10000*(x) + 0x100*(y) + z)
 
24
 
 
25
/* Include file for additions: new matches and targets. */
 
26
struct xtables_match
 
27
{
 
28
        struct xtables_match *next;
 
29
 
 
30
        xt_chainlabel name;
 
31
 
 
32
        /* Revision of match (0 by default). */
 
33
        u_int8_t revision;
 
34
 
 
35
        u_int16_t family;
 
36
 
 
37
        const char *version;
 
38
 
 
39
        /* Size of match data. */
 
40
        size_t size;
 
41
 
 
42
        /* Size of match data relevent for userspace comparison purposes */
 
43
        size_t userspacesize;
 
44
 
 
45
        /* Function which prints out usage message. */
 
46
        void (*help)(void);
 
47
 
 
48
        /* Initialize the match. */
 
49
        void (*init)(struct xt_entry_match *m);
 
50
 
 
51
        /* Function which parses command options; returns true if it
 
52
           ate an option */
 
53
        /* entry is struct ipt_entry for example */
 
54
        int (*parse)(int c, char **argv, int invert, unsigned int *flags,
 
55
                     const void *entry,
 
56
                     struct xt_entry_match **match);
 
57
 
 
58
        /* Final check; exit if not ok. */
 
59
        void (*final_check)(unsigned int flags);
 
60
 
 
61
        /* Prints out the match iff non-NULL: put space at end */
 
62
        /* ip is struct ipt_ip * for example */
 
63
        void (*print)(const void *ip,
 
64
                      const struct xt_entry_match *match, int numeric);
 
65
 
 
66
        /* Saves the match info in parsable form to stdout. */
 
67
        /* ip is struct ipt_ip * for example */
 
68
        void (*save)(const void *ip, const struct xt_entry_match *match);
 
69
 
 
70
        /* Pointer to list of extra command-line options */
 
71
        const struct option *extra_opts;
 
72
 
 
73
        /* Ignore these men behind the curtain: */
 
74
        unsigned int option_offset;
 
75
        struct xt_entry_match *m;
 
76
        unsigned int mflags;
 
77
#ifdef NO_SHARED_LIBS
 
78
        unsigned int loaded; /* simulate loading so options are merged properly */
 
79
#endif
 
80
};
 
81
 
 
82
struct xtables_target
 
83
{
 
84
        struct xtables_target *next;
 
85
 
 
86
        xt_chainlabel name;
 
87
 
 
88
        /* Revision of target (0 by default). */
 
89
        u_int8_t revision;
 
90
 
 
91
        u_int16_t family;
 
92
 
 
93
        const char *version;
 
94
 
 
95
        /* Size of target data. */
 
96
        size_t size;
 
97
 
 
98
        /* Size of target data relevent for userspace comparison purposes */
 
99
        size_t userspacesize;
 
100
 
 
101
        /* Function which prints out usage message. */
 
102
        void (*help)(void);
 
103
 
 
104
        /* Initialize the target. */
 
105
        void (*init)(struct xt_entry_target *t);
 
106
 
 
107
        /* Function which parses command options; returns true if it
 
108
           ate an option */
 
109
        /* entry is struct ipt_entry for example */
 
110
        int (*parse)(int c, char **argv, int invert, unsigned int *flags,
 
111
                     const void *entry,
 
112
                     struct xt_entry_target **targetinfo);
 
113
 
 
114
        /* Final check; exit if not ok. */
 
115
        void (*final_check)(unsigned int flags);
 
116
 
 
117
        /* Prints out the target iff non-NULL: put space at end */
 
118
        void (*print)(const void *ip,
 
119
                      const struct xt_entry_target *target, int numeric);
 
120
 
 
121
        /* Saves the targinfo in parsable form to stdout. */
 
122
        void (*save)(const void *ip,
 
123
                     const struct xt_entry_target *target);
 
124
 
 
125
        /* Pointer to list of extra command-line options */
 
126
        const struct option *extra_opts;
 
127
 
 
128
        /* Ignore these men behind the curtain: */
 
129
        unsigned int option_offset;
 
130
        struct xt_entry_target *t;
 
131
        unsigned int tflags;
 
132
        unsigned int used;
 
133
#ifdef NO_SHARED_LIBS
 
134
        unsigned int loaded; /* simulate loading so options are merged properly */
 
135
#endif
 
136
};
 
137
 
 
138
/* Your shared library should call one of these. */
 
139
extern void xtables_register_match(struct xtables_match *me);
 
140
extern void xtables_register_target(struct xtables_target *me);
 
141
 
 
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 *,
 
155
        unsigned long, unsigned long);
 
156
extern bool strtonum(const char *, char **, unsigned int *,
 
157
        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);
 
160
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
};
 
173
 
 
174
/* this is a special 64bit data type that is 8-byte aligned */
 
175
#define aligned_u64 u_int64_t __attribute__((aligned(8)))
 
176
 
 
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 **,
 
189
        struct in_addr *, unsigned int *);
 
190
 
 
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 **,
 
196
        struct in6_addr *, unsigned int *);
 
197
 
 
198
/**
 
199
 * Print the specified value to standard output, quoting dangerous
 
200
 * characters if required.
 
201
 */
 
202
extern void save_string(const char *value);
 
203
 
 
204
#ifdef NO_SHARED_LIBS
 
205
#       ifdef _INIT
 
206
#               undef _init
 
207
#               define _init _INIT
 
208
#       endif
 
209
        extern void init_extensions(void);
 
210
#else
 
211
#       define _init __attribute__((constructor)) _INIT
 
212
#endif
 
213
 
 
214
/* Present in both iptables.c and ip6tables.c */
 
215
extern u_int16_t parse_protocol(const char *s);
 
216
 
 
217
#ifdef XTABLES_INTERNAL
 
218
#       include <xtables/internal.h>
 
219
#endif
 
220
 
 
221
#endif /* _XTABLES_H */