1 #ifndef _IPTABLES_USER_H
2 #define _IPTABLES_USER_H
4 #include "iptables_common.h"
5 #include "libiptc/libiptc.h"
8 #define IPPROTO_SCTP 132
11 struct iptables_rule_match
13 struct iptables_rule_match *next;
15 struct iptables_match *match;
18 /* Include file for additions: new matches and targets. */
21 struct iptables_match *next;
27 /* Size of match data. */
30 /* Size of match data relevent for userspace comparison purposes */
33 /* Function which prints out usage message. */
36 /* Initialize the match. */
37 void (*init)(struct ipt_entry_match *m, unsigned int *nfcache);
39 /* Function which parses command options; returns true if it
41 int (*parse)(int c, char **argv, int invert, unsigned int *flags,
42 const struct ipt_entry *entry,
43 unsigned int *nfcache,
44 struct ipt_entry_match **match);
46 /* Final check; exit if not ok. */
47 void (*final_check)(unsigned int flags);
49 /* Prints out the match iff non-NULL: put space at end */
50 void (*print)(const struct ipt_ip *ip,
51 const struct ipt_entry_match *match, int numeric);
53 /* Saves the match info in parsable form to stdout. */
54 void (*save)(const struct ipt_ip *ip,
55 const struct ipt_entry_match *match);
57 /* Pointer to list of extra command-line options */
58 const struct option *extra_opts;
60 /* Ignore these men behind the curtain: */
61 unsigned int option_offset;
62 struct ipt_entry_match *m;
65 unsigned int loaded; /* simulate loading so options are merged properly */
69 struct iptables_target
71 struct iptables_target *next;
77 /* Size of target data. */
80 /* Size of target data relevent for userspace comparison purposes */
83 /* Function which prints out usage message. */
86 /* Initialize the target. */
87 void (*init)(struct ipt_entry_target *t, unsigned int *nfcache);
89 /* Function which parses command options; returns true if it
91 int (*parse)(int c, char **argv, int invert, unsigned int *flags,
92 const struct ipt_entry *entry,
93 struct ipt_entry_target **target);
95 /* Final check; exit if not ok. */
96 void (*final_check)(unsigned int flags);
98 /* Prints out the target iff non-NULL: put space at end */
99 void (*print)(const struct ipt_ip *ip,
100 const struct ipt_entry_target *target, int numeric);
102 /* Saves the targinfo in parsable form to stdout. */
103 void (*save)(const struct ipt_ip *ip,
104 const struct ipt_entry_target *target);
106 /* Pointer to list of extra command-line options */
107 struct option *extra_opts;
109 /* Ignore these men behind the curtain: */
110 unsigned int option_offset;
111 struct ipt_entry_target *t;
114 #ifdef NO_SHARED_LIBS
115 unsigned int loaded; /* simulate loading so options are merged properly */
121 /* Your shared library should call one of these. */
122 extern void register_match(struct iptables_match *me);
123 extern void register_target(struct iptables_target *me);
125 extern struct in_addr *dotted_to_addr(const char *dotted);
126 extern char *addr_to_dotted(const struct in_addr *addrp);
127 extern char *addr_to_anyname(const struct in_addr *addr);
128 extern char *mask_to_dotted(const struct in_addr *mask);
130 extern void parse_hostnetworkmask(const char *name, struct in_addr **addrpp,
131 struct in_addr *maskp, unsigned int *naddrs);
132 extern u_int16_t parse_protocol(const char *s);
134 extern int do_command(int argc, char *argv[], char **table,
135 iptc_handle_t *handle);
136 /* Keeping track of external matches and targets: linked lists. */
137 extern struct iptables_match *iptables_matches;
138 extern struct iptables_target *iptables_targets;
146 extern struct iptables_target *find_target(const char *name, enum ipt_tryload);
147 extern struct iptables_match *find_match(const char *name, enum ipt_tryload, struct iptables_rule_match **match);
149 extern int delete_chain(const ipt_chainlabel chain, int verbose,
150 iptc_handle_t *handle);
151 extern int flush_entries(const ipt_chainlabel chain, int verbose,
152 iptc_handle_t *handle);
153 extern int for_each_chain(int (*fn)(const ipt_chainlabel, int, iptc_handle_t *),
154 int verbose, int builtinstoo, iptc_handle_t *handle);
155 #endif /*_IPTABLES_USER_H*/