1 #ifndef _IPTABLES_USER_H
2 #define _IPTABLES_USER_H
4 #include "iptables_common.h"
5 #include "libiptc/libiptc.h"
7 /* Include file for additions: new matches and targets. */
10 struct iptables_match *next;
16 /* Size of match data. */
19 /* Size of match data relevent for userspace comparison purposes */
22 /* Function which prints out usage message. */
25 /* Initialize the match. */
26 void (*init)(struct ipt_entry_match *m, unsigned int *nfcache);
28 /* Function which parses command options; returns true if it
30 int (*parse)(int c, char **argv, int invert, unsigned int *flags,
31 const struct ipt_entry *entry,
32 unsigned int *nfcache,
33 struct ipt_entry_match **match);
35 /* Final check; exit if not ok. */
36 void (*final_check)(unsigned int flags);
38 /* Prints out the match iff non-NULL: put space at end */
39 void (*print)(const struct ipt_ip *ip,
40 const struct ipt_entry_match *match, int numeric);
42 /* Saves the match info in parsable form to stdout. */
43 void (*save)(const struct ipt_ip *ip,
44 const struct ipt_entry_match *match);
46 /* Pointer to list of extra command-line options */
47 const struct option *extra_opts;
49 /* Ignore these men behind the curtain: */
50 unsigned int option_offset;
51 struct ipt_entry_match *m;
55 unsigned int loaded; /* simulate loading so options are merged properly */
59 struct iptables_target
61 struct iptables_target *next;
67 /* Size of target data. */
70 /* Size of target data relevent for userspace comparison purposes */
73 /* Function which prints out usage message. */
76 /* Initialize the target. */
77 void (*init)(struct ipt_entry_target *t, unsigned int *nfcache);
79 /* Function which parses command options; returns true if it
81 int (*parse)(int c, char **argv, int invert, unsigned int *flags,
82 const struct ipt_entry *entry,
83 struct ipt_entry_target **target);
85 /* Final check; exit if not ok. */
86 void (*final_check)(unsigned int flags);
88 /* Prints out the target iff non-NULL: put space at end */
89 void (*print)(const struct ipt_ip *ip,
90 const struct ipt_entry_target *target, int numeric);
92 /* Saves the targinfo in parsable form to stdout. */
93 void (*save)(const struct ipt_ip *ip,
94 const struct ipt_entry_target *target);
96 /* Pointer to list of extra command-line options */
97 struct option *extra_opts;
99 /* Ignore these men behind the curtain: */
100 unsigned int option_offset;
101 struct ipt_entry_target *t;
104 #ifdef NO_SHARED_LIBS
105 unsigned int loaded; /* simulate loading so options are merged properly */
111 /* Your shared library should call one of these. */
112 extern void register_match(struct iptables_match *me);
113 extern void register_target(struct iptables_target *me);
115 extern struct in_addr *dotted_to_addr(const char *dotted);
116 extern char *addr_to_dotted(const struct in_addr *addrp);
117 extern char *addr_to_anyname(const struct in_addr *addr);
118 extern char *mask_to_dotted(const struct in_addr *mask);
120 extern void parse_hostnetworkmask(const char *name, struct in_addr **addrpp,
121 struct in_addr *maskp, unsigned int *naddrs);
122 extern u_int16_t parse_protocol(const char *s);
124 extern int do_command(int argc, char *argv[], char **table,
125 iptc_handle_t *handle);
126 /* Keeping track of external matches and targets: linked lists. */
127 extern struct iptables_match *iptables_matches;
128 extern struct iptables_target *iptables_targets;
136 extern struct iptables_target *find_target(const char *name, enum ipt_tryload);
137 extern struct iptables_match *find_match(const char *name, enum ipt_tryload);
139 extern int delete_chain(const ipt_chainlabel chain, int verbose,
140 iptc_handle_t *handle);
141 extern int flush_entries(const ipt_chainlabel chain, int verbose,
142 iptc_handle_t *handle);
143 extern int for_each_chain(int (*fn)(const ipt_chainlabel, int, iptc_handle_t *),
144 int verbose, int builtinstoo, iptc_handle_t *handle);
145 #endif /*_IPTABLES_USER_H*/