• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/ap/gpl/iptables-1.4.12.1/include/

Lines Matching defs:*

0 #ifndef _XTABLES_H
2 #define _XTABLES_H
5 * Changing any structs/functions may incur a needed change
6 * in libxtables_vcurrent/vage too.
9 #include <sys/socket.h> /* PF_* */
10 #include <sys/types.h>
11 #include <limits.h>
12 #include <stdbool.h>
13 #include <stddef.h>
14 #include <stdint.h>
15 #include <netinet/in.h>
16 #include <net/if.h>
17 #include <linux/types.h>
18 #include <linux/netfilter.h>
19 #include <linux/netfilter/x_tables.h>
21 #ifndef IPPROTO_SCTP
22 #define IPPROTO_SCTP 132
23 #endif
24 #ifndef IPPROTO_DCCP
25 #define IPPROTO_DCCP 33
26 #endif
27 #ifndef IPPROTO_MH
28 # define IPPROTO_MH 135
29 #endif
30 #ifndef IPPROTO_UDPLITE
31 #define IPPROTO_UDPLITE 136
32 #endif
34 #define XTABLES_VERSION "libxtables.so.7"
35 #define XTABLES_VERSION_CODE 7
37 struct in_addr;
40 * .size is here so that there is a somewhat reasonable check
41 * against the chosen .type.
43 #define XTOPT_POINTER(stype, member) \
44 .ptroff = offsetof(stype, member), \
45 .size = sizeof(((stype *)NULL)->member)
46 #define XTOPT_TABLEEND {.name = NULL}
49 * Select the format the input has to conform to, as well as the target type
50 * (area pointed to with XTOPT_POINTER). Note that the storing is not always
51 * uniform. @cb->val will be populated with as much as there is space, i.e.
52 * exactly 2 items for ranges, but the target area can receive more values
53 * (e.g. in case of ranges), or less values (e.g. %XTTYPE_HOSTMASK).
55 * %XTTYPE_NONE: option takes no argument
56 * %XTTYPE_UINT*: standard integer
57 * %XTTYPE_UINT*RC: colon-separated range of standard integers
58 * %XTTYPE_DOUBLE: double-precision floating point number
59 * %XTTYPE_STRING: arbitrary string
60 * %XTTYPE_TOSMASK: 8-bit TOS value with optional mask
61 * %XTTYPE_MARKMASK32: 32-bit mark with optional mask
62 * %XTTYPE_SYSLOGLEVEL: syslog level by name or number
63 * %XTTYPE_HOST: one host or address (ptr: union nf_inet_addr)
64 * %XTTYPE_HOSTMASK: one host or address, with an optional prefix length
65 * (ptr: union nf_inet_addr; only host portion is stored)
66 * %XTTYPE_PROTOCOL: protocol number/name from /etc/protocols (ptr: uint8_t)
67 * %XTTYPE_PORT: 16-bit port name or number (supports %XTOPT_NBO)
68 * %XTTYPE_PORTRC: colon-separated port range (names acceptable),
69 * (supports %XTOPT_NBO)
70 * %XTTYPE_PLEN: prefix length
71 * %XTTYPE_PLENMASK: prefix length (ptr: union nf_inet_addr)
72 * %XTTYPE_ETHERMAC: Ethernet MAC address in hex form
74 enum xt_option_type {
75 XTTYPE_NONE,
76 XTTYPE_UINT8,
77 XTTYPE_UINT16,
78 XTTYPE_UINT32,
79 XTTYPE_UINT64,
80 XTTYPE_UINT8RC,
81 XTTYPE_UINT16RC,
82 XTTYPE_UINT32RC,
83 XTTYPE_UINT64RC,
84 XTTYPE_DOUBLE,
85 XTTYPE_STRING,
86 XTTYPE_TOSMASK,
87 XTTYPE_MARKMASK32,
88 XTTYPE_SYSLOGLEVEL,
89 XTTYPE_HOST,
90 XTTYPE_HOSTMASK,
91 XTTYPE_PROTOCOL,
92 XTTYPE_PORT,
93 XTTYPE_PORTRC,
94 XTTYPE_PLEN,
95 XTTYPE_PLENMASK,
96 XTTYPE_ETHERMAC,
100 * %XTOPT_INVERT: option is invertible (usable with !)
101 * %XTOPT_MAND: option is mandatory
102 * %XTOPT_MULTI: option may be specified multiple times
103 * %XTOPT_PUT: store value into memory at @ptroff
104 * %XTOPT_NBO: store value in network-byte order
105 * (only certain XTTYPEs recognize this)
107 enum xt_option_flags {
108 XTOPT_INVERT = 1 << 0,
109 XTOPT_MAND = 1 << 1,
110 XTOPT_MULTI = 1 << 2,
111 XTOPT_PUT = 1 << 3,
112 XTOPT_NBO = 1 << 4,
116 * @name: name of option
117 * @type: type of input and validation method, see %XTTYPE_*
118 * @id: unique number (within extension) for option, 0-31
119 * @excl: bitmask of flags that cannot be used with this option
120 * @also: bitmask of flags that must be used with this option
121 * @flags: bitmask of option flags, see %XTOPT_*
122 * @ptroff: offset into private structure for member
123 * @size: size of the item pointed to by @ptroff; this is a safeguard
124 * @min: lowest allowed value (for singular integral types)
125 * @max: highest allowed value (for singular integral types)
127 struct xt_option_entry {
128 const char *name;
129 enum xt_option_type type;
130 unsigned int id, excl, also, flags;
131 unsigned int ptroff;
132 size_t size;
133 unsigned int min, max;
137 * @arg: input from command line
138 * @ext_name: name of extension currently being processed
139 * @entry: current option being processed
140 * @data: per-extension kernel data block
141 * @xflags: options of the extension that have been used
142 * @invert: whether option was used with !
143 * @nvals: number of results in uXX_multi
144 * @val: parsed result
145 * @udata: per-extension private scratch area
146 * (cf. xtables_{match,target}->udata_size)
148 struct xt_option_call {
149 const char *arg, *ext_name;
150 const struct xt_option_entry *entry;
151 void *data;
152 unsigned int xflags;
153 bool invert;
154 uint8_t nvals;
155 union {
156 uint8_t u8, u8_range[2], syslog_level, protocol;
157 uint16_t u16, u16_range[2], port, port_range[2];
158 uint32_t u32, u32_range[2];
159 uint64_t u64, u64_range[2];
160 double dbl;
161 struct {
162 union nf_inet_addr haddr, hmask;
163 uint8_t hlen;
165 struct {
166 uint8_t tos_value, tos_mask;
168 struct {
169 uint32_t mark, mask;
171 uint8_t ethermac[6];
172 } val;
173 /* Wished for a world where the ones below were gone: */
174 union {
175 struct xt_entry_match **match;
176 struct xt_entry_target **target;
178 void *xt_entry;
179 void *udata;
183 * @ext_name: name of extension currently being processed
184 * @data: per-extension (kernel) data block
185 * @udata: per-extension private scratch area
186 * (cf. xtables_{match,target}->udata_size)
187 * @xflags: options of the extension that have been used
189 struct xt_fcheck_call {
190 const char *ext_name;
191 void *data, *udata;
192 unsigned int xflags;
196 * A "linear"/linked-list based name<->id map, for files similar to
197 * /etc/iproute2/.
199 struct xtables_lmap {
200 char *name;
201 int id;
202 struct xtables_lmap *next;
205 /* Include file for additions: new matches and targets. */
206 struct xtables_match
209 * ABI/API version this module requires. Must be first member,
210 * as the rest of this struct may be subject to ABI changes.
212 const char *version;
214 struct xtables_match *next;
216 const char *name;
218 /* Revision of match (0 by default). */
219 u_int8_t revision;
221 u_int16_t family;
223 /* Size of match data. */
224 size_t size;
226 /* Size of match data relevent for userspace comparison purposes */
227 size_t userspacesize;
229 /* Function which prints out usage message. */
230 void (*help)(void);
232 /* Initialize the match. */
233 void (*init)(struct xt_entry_match *m);
235 /* Function which parses command options; returns true if it
236 ate an option */
237 /* entry is struct ipt_entry for example */
238 int (*parse)(int c, char **argv, int invert, unsigned int *flags,
239 const void *entry,
240 struct xt_entry_match **match);
242 /* Final check; exit if not ok. */
243 void (*final_check)(unsigned int flags);
245 /* Prints out the match iff non-NULL: put space at end */
246 /* ip is struct ipt_ip * for example */
247 void (*print)(const void *ip,
248 const struct xt_entry_match *match, int numeric);
250 /* Saves the match info in parsable form to stdout. */
251 /* ip is struct ipt_ip * for example */
252 void (*save)(const void *ip, const struct xt_entry_match *match);
254 /* Pointer to list of extra command-line options */
255 const struct option *extra_opts;
257 /* New parser */
258 void (*x6_parse)(struct xt_option_call *);
259 void (*x6_fcheck)(struct xt_fcheck_call *);
260 const struct xt_option_entry *x6_options;
262 /* Size of per-extension instance extra "global" scratch space */
263 size_t udata_size;
265 /* Ignore these men behind the curtain: */
266 void *udata;
267 unsigned int option_offset;
268 struct xt_entry_match *m;
269 unsigned int mflags;
270 unsigned int loaded; /* simulate loading so options are merged properly */
273 struct xtables_target
276 * ABI/API version this module requires. Must be first member,
277 * as the rest of this struct may be subject to ABI changes.
279 const char *version;
281 struct xtables_target *next;
284 const char *name;
286 /* Revision of target (0 by default). */
287 u_int8_t revision;
289 u_int16_t family;
292 /* Size of target data. */
293 size_t size;
295 /* Size of target data relevent for userspace comparison purposes */
296 size_t userspacesize;
298 /* Function which prints out usage message. */
299 void (*help)(void);
301 /* Initialize the target. */
302 void (*init)(struct xt_entry_target *t);
304 /* Function which parses command options; returns true if it
305 ate an option */
306 /* entry is struct ipt_entry for example */
307 int (*parse)(int c, char **argv, int invert, unsigned int *flags,
308 const void *entry,
309 struct xt_entry_target **targetinfo);
311 /* Final check; exit if not ok. */
312 void (*final_check)(unsigned int flags);
314 /* Prints out the target iff non-NULL: put space at end */
315 void (*print)(const void *ip,
316 const struct xt_entry_target *target, int numeric);
318 /* Saves the targinfo in parsable form to stdout. */
319 void (*save)(const void *ip,
320 const struct xt_entry_target *target);
322 /* Pointer to list of extra command-line options */
323 const struct option *extra_opts;
325 /* New parser */
326 void (*x6_parse)(struct xt_option_call *);
327 void (*x6_fcheck)(struct xt_fcheck_call *);
328 const struct xt_option_entry *x6_options;
330 size_t udata_size;
332 /* Ignore these men behind the curtain: */
333 void *udata;
334 unsigned int option_offset;
335 struct xt_entry_target *t;
336 unsigned int tflags;
337 unsigned int used;
338 unsigned int loaded; /* simulate loading so options are merged properly */
341 struct xtables_rule_match {
342 struct xtables_rule_match *next;
343 struct xtables_match *match;
344 /* Multiple matches of the same type: the ones before
345 the current one are completed from parsing point of view */
346 bool completed;
350 * struct xtables_pprot -
352 * A few hardcoded protocols for 'all' and in case the user has no
353 * /etc/protocols.
355 struct xtables_pprot {
356 const char *name;
357 u_int8_t num;
360 enum xtables_tryload {
361 XTF_DONT_LOAD,
362 XTF_DURING_LOAD,
363 XTF_TRY_LOAD,
364 XTF_LOAD_MUST_SUCCEED,
367 enum xtables_exittype {
368 OTHER_PROBLEM = 1,
369 PARAMETER_PROBLEM,
370 VERSION_PROBLEM,
371 RESOURCE_PROBLEM,
372 XTF_ONLY_ONCE,
373 XTF_NO_INVERT,
374 XTF_BAD_VALUE,
375 XTF_ONE_ACTION,
378 struct xtables_globals
380 unsigned int option_offset;
381 const char *program_name, *program_version;
382 struct option *orig_opts;
383 struct option *opts;
384 void (*exit_err)(enum xtables_exittype status, const char *msg, ...) __attribute__((noreturn, format(printf,2,3)));
387 #define XT_GETOPT_TABLEEND {.name = NULL, .has_arg = false}
389 #ifdef __cplusplus
390 extern "C" {
391 #endif
393 extern const char *xtables_modprobe_program;
394 extern struct xtables_match *xtables_matches;
395 extern struct xtables_target *xtables_targets;
397 extern void xtables_init(void);
398 extern void xtables_set_nfproto(uint8_t);
399 extern void *xtables_calloc(size_t, size_t);
400 extern void *xtables_malloc(size_t);
401 extern void *xtables_realloc(void *, size_t);
403 extern int xtables_insmod(const char *, const char *, bool);
404 extern int xtables_load_ko(const char *, bool);
405 extern int xtables_set_params(struct xtables_globals *xtp);
406 extern void xtables_free_opts(int reset_offset);
407 extern struct option *xtables_merge_options(struct option *origopts,
408 struct option *oldopts, const struct option *newopts,
409 unsigned int *option_offset);
411 extern int xtables_init_all(struct xtables_globals *xtp, uint8_t nfproto);
412 extern struct xtables_match *xtables_find_match(const char *name,
413 enum xtables_tryload, struct xtables_rule_match **match);
414 extern struct xtables_target *xtables_find_target(const char *name,
415 enum xtables_tryload);
417 /* Your shared library should call one of these. */
418 extern void xtables_register_match(struct xtables_match *me);
419 extern void xtables_register_matches(struct xtables_match *, unsigned int);
420 extern void xtables_register_target(struct xtables_target *me);
421 extern void xtables_register_targets(struct xtables_target *, unsigned int);
423 extern bool xtables_strtoul(const char *, char **, uintmax_t *,
424 uintmax_t, uintmax_t);
425 extern bool xtables_strtoui(const char *, char **, unsigned int *,
426 unsigned int, unsigned int);
427 extern int xtables_service_to_port(const char *name, const char *proto);
428 extern u_int16_t xtables_parse_port(const char *port, const char *proto);
429 extern void
430 xtables_parse_interface(const char *arg, char *vianame, unsigned char *mask);
432 /* this is a special 64bit data type that is 8-byte aligned */
433 #define aligned_u64 u_int64_t __attribute__((aligned(8)))
435 extern struct xtables_globals *xt_params;
436 #define xtables_error (xt_params->exit_err)
438 extern void xtables_param_act(unsigned int, const char *, ...);
440 extern const char *xtables_ipaddr_to_numeric(const struct in_addr *);
441 extern const char *xtables_ipaddr_to_anyname(const struct in_addr *);
442 extern const char *xtables_ipmask_to_numeric(const struct in_addr *);
443 extern struct in_addr *xtables_numeric_to_ipaddr(const char *);
444 extern struct in_addr *xtables_numeric_to_ipmask(const char *);
445 extern void xtables_ipparse_any(const char *, struct in_addr **,
446 struct in_addr *, unsigned int *);
447 extern void xtables_ipparse_multiple(const char *, struct in_addr **,
448 struct in_addr **, unsigned int *);
450 extern struct in6_addr *xtables_numeric_to_ip6addr(const char *);
451 extern const char *xtables_ip6addr_to_numeric(const struct in6_addr *);
452 extern const char *xtables_ip6addr_to_anyname(const struct in6_addr *);
453 extern const char *xtables_ip6mask_to_numeric(const struct in6_addr *);
454 extern void xtables_ip6parse_any(const char *, struct in6_addr **,
455 struct in6_addr *, unsigned int *);
456 extern void xtables_ip6parse_multiple(const char *, struct in6_addr **,
457 struct in6_addr **, unsigned int *);
460 * Print the specified value to standard output, quoting dangerous
461 * characters if required.
463 extern void xtables_save_string(const char *value);
465 #if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS)
466 # ifdef _INIT
467 # undef _init
468 # define _init _INIT
469 # endif
470 extern void init_extensions(void);
471 extern void init_extensions4(void);
472 extern void init_extensions6(void);
473 #else
474 # define _init __attribute__((constructor)) _INIT
475 #endif
477 extern const struct xtables_pprot xtables_chain_protos[];
478 extern u_int16_t xtables_parse_protocol(const char *s);
480 /* xtoptions.c */
481 extern void xtables_option_metavalidate(const char *,
482 const struct xt_option_entry *);
483 extern struct option *xtables_options_xfrm(struct option *, struct option *,
484 const struct xt_option_entry *,
485 unsigned int *);
486 extern void xtables_option_parse(struct xt_option_call *);
487 extern void xtables_option_tpcall(unsigned int, char **, bool,
488 struct xtables_target *, void *);
489 extern void xtables_option_mpcall(unsigned int, char **, bool,
490 struct xtables_match *, void *);
491 extern void xtables_option_tfcall(struct xtables_target *);
492 extern void xtables_option_mfcall(struct xtables_match *);
493 extern void xtables_options_fcheck(const char *, unsigned int,
494 const struct xt_option_entry *);
496 extern struct xtables_lmap *xtables_lmap_init(const char *);
497 extern void xtables_lmap_free(struct xtables_lmap *);
498 extern int xtables_lmap_name2id(const struct xtables_lmap *, const char *);
499 extern const char *xtables_lmap_id2name(const struct xtables_lmap *, int);
501 #ifdef XTABLES_INTERNAL
503 /* Shipped modules rely on this... */
505 # ifndef ARRAY_SIZE
506 # define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x)))
507 # endif
509 extern void _init(void);
511 #endif
513 #ifdef __cplusplus
514 } /* extern "C" */
515 #endif
517 #endif /* _XTABLES_H */