]>
git.proxmox.com Git - mirror_iproute2.git/blob - include/iptables.h
1 #ifndef _IPTABLES_USER_H
2 #define _IPTABLES_USER_H
4 #include "iptables_common.h"
5 #include "libiptc/libiptc.h"
8 #define IPT_LIB_DIR "/usr/local/lib/iptables"
12 #define IPPROTO_SCTP 132
15 #ifndef IPT_SO_GET_REVISION_MATCH /* Old kernel source. */
16 #define IPT_SO_GET_REVISION_MATCH (IPT_BASE_CTL + 2)
17 #define IPT_SO_GET_REVISION_TARGET (IPT_BASE_CTL + 3)
19 struct ipt_get_revision
21 char name
[IPT_FUNCTION_MAXNAMELEN
-1];
25 #endif /* IPT_SO_GET_REVISION_MATCH Old kernel source */
27 struct iptables_rule_match
29 struct iptables_rule_match
*next
;
31 struct iptables_match
*match
;
34 /* Include file for additions: new matches and targets. */
37 struct iptables_match
*next
;
41 /* Revision of match (0 by default). */
46 /* Size of match data. */
49 /* Size of match data relevent for userspace comparison purposes */
52 /* Function which prints out usage message. */
55 /* Initialize the match. */
56 void (*init
)(struct ipt_entry_match
*m
, unsigned int *nfcache
);
58 /* Function which parses command options; returns true if it
60 int (*parse
)(int c
, char **argv
, int invert
, unsigned int *flags
,
61 const struct ipt_entry
*entry
,
62 unsigned int *nfcache
,
63 struct ipt_entry_match
**match
);
65 /* Final check; exit if not ok. */
66 void (*final_check
)(unsigned int flags
);
68 /* Prints out the match iff non-NULL: put space at end */
69 void (*print
)(const struct ipt_ip
*ip
,
70 const struct ipt_entry_match
*match
, int numeric
);
72 /* Saves the match info in parsable form to stdout. */
73 void (*save
)(const struct ipt_ip
*ip
,
74 const struct ipt_entry_match
*match
);
76 /* Pointer to list of extra command-line options */
77 const struct option
*extra_opts
;
79 /* Ignore these men behind the curtain: */
80 unsigned int option_offset
;
81 struct ipt_entry_match
*m
;
84 unsigned int loaded
; /* simulate loading so options are merged properly */
88 struct iptables_target
90 struct iptables_target
*next
;
94 /* Revision of target (0 by default). */
99 /* Size of target data. */
102 /* Size of target data relevent for userspace comparison purposes */
103 size_t userspacesize
;
105 /* Function which prints out usage message. */
108 /* Initialize the target. */
109 void (*init
)(struct ipt_entry_target
*t
, unsigned int *nfcache
);
111 /* Function which parses command options; returns true if it
113 int (*parse
)(int c
, char **argv
, int invert
, unsigned int *flags
,
114 const struct ipt_entry
*entry
,
115 struct ipt_entry_target
**target
);
117 /* Final check; exit if not ok. */
118 void (*final_check
)(unsigned int flags
);
120 /* Prints out the target iff non-NULL: put space at end */
121 void (*print
)(const struct ipt_ip
*ip
,
122 const struct ipt_entry_target
*target
, int numeric
);
124 /* Saves the targinfo in parsable form to stdout. */
125 void (*save
)(const struct ipt_ip
*ip
,
126 const struct ipt_entry_target
*target
);
128 /* Pointer to list of extra command-line options */
129 struct option
*extra_opts
;
131 /* Ignore these men behind the curtain: */
132 unsigned int option_offset
;
133 struct ipt_entry_target
*t
;
136 #ifdef NO_SHARED_LIBS
137 unsigned int loaded
; /* simulate loading so options are merged properly */
143 /* Your shared library should call one of these. */
144 extern void register_match(struct iptables_match
*me
);
145 extern void register_target(struct iptables_target
*me
);
147 extern struct in_addr
*dotted_to_addr(const char *dotted
);
148 extern char *addr_to_dotted(const struct in_addr
*addrp
);
149 extern char *addr_to_anyname(const struct in_addr
*addr
);
150 extern char *mask_to_dotted(const struct in_addr
*mask
);
152 extern void parse_hostnetworkmask(const char *name
, struct in_addr
**addrpp
,
153 struct in_addr
*maskp
, unsigned int *naddrs
);
154 extern u_int16_t
parse_protocol(const char *s
);
156 extern int do_command(int argc
, char *argv
[], char **table
,
157 iptc_handle_t
*handle
);
158 /* Keeping track of external matches and targets: linked lists. */
159 extern struct iptables_match
*iptables_matches
;
160 extern struct iptables_target
*iptables_targets
;
168 extern struct iptables_target
*find_target(const char *name
, enum ipt_tryload
);
169 extern struct iptables_match
*find_match(const char *name
, enum ipt_tryload
, struct iptables_rule_match
**match
);
171 extern int delete_chain(const ipt_chainlabel chain
, int verbose
,
172 iptc_handle_t
*handle
);
173 extern int flush_entries(const ipt_chainlabel chain
, int verbose
,
174 iptc_handle_t
*handle
);
175 extern int for_each_chain(int (*fn
)(const ipt_chainlabel
, int, iptc_handle_t
*),
176 int verbose
, int builtinstoo
, iptc_handle_t
*handle
);
177 #endif /*_IPTABLES_USER_H*/