2 * This file was imported from the iptables sources.
3 * Copyright (C) 1999-2008 Netfilter Core Team
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; only version 2 of the License is applicable.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #include <sys/types.h>
23 #include <linux/types.h>
24 #include <linux/netfilter/x_tables.h>
29 #define IPPROTO_SCTP 132
32 #define IPPROTO_DCCP 33
34 #ifndef IPPROTO_UDPLITE
35 #define IPPROTO_UDPLITE 136
38 #define XTABLES_VERSION "1.4.1.1"
39 #define XTABLES_VERSION_CODE (0x10000 * 1 + 0x100 * 4 + 1)
41 #define XTABLES_API_VERSION(x,y,z) (0x10000*(x) + 0x100*(y) + z)
43 /* Include file for additions: new matches and targets. */
46 struct xtables_match *next;
50 /* Revision of match (0 by default). */
57 /* Size of match data. */
60 /* Size of match data relevent for userspace comparison purposes */
63 /* Function which prints out usage message. */
66 /* Initialize the match. */
67 void (*init)(struct xt_entry_match *m);
69 /* Function which parses command options; returns true if it
71 /* entry is struct ipt_entry for example */
72 int (*parse)(int c, char **argv, int invert, unsigned int *flags,
74 struct xt_entry_match **match);
76 /* Final check; exit if not ok. */
77 void (*final_check)(unsigned int flags);
79 /* Prints out the match iff non-NULL: put space at end */
80 /* ip is struct ipt_ip * for example */
81 void (*print)(const void *ip,
82 const struct xt_entry_match *match, int numeric);
84 /* Saves the match info in parsable form to stdout. */
85 /* ip is struct ipt_ip * for example */
86 void (*save)(const void *ip, const struct xt_entry_match *match);
88 /* Pointer to list of extra command-line options */
89 const struct option *extra_opts;
91 /* Ignore these men behind the curtain: */
92 unsigned int option_offset;
93 struct xt_entry_match *m;
96 unsigned int loaded; /* simulate loading so options are merged properly */
100 struct xtables_target
102 struct xtables_target *next;
106 /* Revision of target (0 by default). */
113 /* Size of target data. */
116 /* Size of target data relevent for userspace comparison purposes */
117 size_t userspacesize;
119 /* Function which prints out usage message. */
122 /* Initialize the target. */
123 void (*init)(struct xt_entry_target *t);
125 /* Function which parses command options; returns true if it
127 /* entry is struct ipt_entry for example */
128 int (*parse)(int c, char **argv, int invert, unsigned int *flags,
130 struct xt_entry_target **targetinfo);
132 /* Final check; exit if not ok. */
133 void (*final_check)(unsigned int flags);
135 /* Prints out the target iff non-NULL: put space at end */
136 void (*print)(const void *ip,
137 const struct xt_entry_target *target, int numeric);
139 /* Saves the targinfo in parsable form to stdout. */
140 void (*save)(const void *ip,
141 const struct xt_entry_target *target);
143 /* Pointer to list of extra command-line options */
144 const struct option *extra_opts;
146 /* Ignore these men behind the curtain: */
147 unsigned int option_offset;
148 struct xt_entry_target *t;
151 #ifdef NO_SHARED_LIBS
152 unsigned int loaded; /* simulate loading so options are merged properly */
156 /* Your shared library should call one of these. */
157 extern void xtables_register_match(struct xtables_match *me);
158 extern void xtables_register_target(struct xtables_target *me);
160 extern int string_to_number_ll(const char *s,
161 unsigned long long min,
162 unsigned long long max,
163 unsigned long long *ret);
164 extern int string_to_number_l(const char *s,
168 extern int string_to_number(const char *s,
172 extern bool strtonuml(const char *, char **, unsigned long *,
173 unsigned long, unsigned long);
174 extern bool strtonum(const char *, char **, unsigned int *,
175 unsigned int, unsigned int);
176 extern int service_to_port(const char *name, const char *proto);
177 extern u_int16_t parse_port(const char *port, const char *proto);
179 parse_interface(const char *arg, char *vianame, unsigned char *mask);
192 /* this is a special 64bit data type that is 8-byte aligned */
193 #define aligned_u64 u_int64_t __attribute__((aligned(8)))
195 int check_inverse(const char option[], int *invert, int *my_optind, int argc);
196 void exit_error(enum exittype, const char *, ...)__attribute__((noreturn,
197 format(printf,2,3)));
198 extern void param_act(unsigned int, const char *, ...);
199 extern const char *program_name, *program_version;
201 extern const char *ipaddr_to_numeric(const struct in_addr *);
202 extern const char *ipaddr_to_anyname(const struct in_addr *);
203 extern const char *ipmask_to_numeric(const struct in_addr *);
204 extern struct in_addr *numeric_to_ipaddr(const char *);
205 extern struct in_addr *numeric_to_ipmask(const char *);
206 extern void ipparse_hostnetworkmask(const char *, struct in_addr **,
207 struct in_addr *, unsigned int *);
209 extern struct in6_addr *numeric_to_ip6addr(const char *);
210 extern const char *ip6addr_to_numeric(const struct in6_addr *);
211 extern const char *ip6addr_to_anyname(const struct in6_addr *);
212 extern const char *ip6mask_to_numeric(const struct in6_addr *);
213 extern void ip6parse_hostnetworkmask(const char *, struct in6_addr **,
214 struct in6_addr *, unsigned int *);
217 * Print the specified value to standard output, quoting dangerous
218 * characters if required.
220 extern void save_string(const char *value);
222 #ifdef NO_SHARED_LIBS
227 extern void init_extensions(void);
229 # define _init __attribute__((constructor)) _INIT
232 /* Present in both iptables.c and ip6tables.c */
233 extern u_int16_t parse_protocol(const char *s);
235 #ifdef XTABLES_INTERNAL
236 # include <xtables/internal.h>
239 #endif /* _XTABLES_H */