Yasuyuki KOZAKAI | 5208806 | 2007-07-24 05:44:11 +0000 | [diff] [blame] | 1 | #ifndef _XTABLES_H |
| 2 | #define _XTABLES_H |
| 3 | |
Jan Engelhardt | dacafa5 | 2009-01-27 20:56:23 +0100 | [diff] [blame] | 4 | /* |
| 5 | * Changing any structs/functions may incur a needed change |
| 6 | * in libxtables_vcurrent/vage too. |
| 7 | */ |
| 8 | |
Jan Engelhardt | ef18e81 | 2008-08-04 12:47:48 +0200 | [diff] [blame] | 9 | #include <sys/socket.h> /* PF_* */ |
Yasuyuki KOZAKAI | 0d502bc | 2007-07-24 05:52:07 +0000 | [diff] [blame] | 10 | #include <sys/types.h> |
Stephen Hemminger | 71886fb | 2009-02-25 08:25:17 +0100 | [diff] [blame] | 11 | #include <limits.h> |
Jan Engelhardt | ef18e81 | 2008-08-04 12:47:48 +0200 | [diff] [blame] | 12 | #include <stdbool.h> |
Jan Engelhardt | aa37acc | 2011-02-07 04:00:50 +0100 | [diff] [blame] | 13 | #include <stddef.h> |
| 14 | #include <stdint.h> |
Jan Engelhardt | 03d9948 | 2008-11-18 12:27:54 +0100 | [diff] [blame] | 15 | #include <netinet/in.h> |
Jan Engelhardt | ef18e81 | 2008-08-04 12:47:48 +0200 | [diff] [blame] | 16 | #include <net/if.h> |
Jan Engelhardt | 5e9eaed | 2007-12-17 13:12:01 +0000 | [diff] [blame] | 17 | #include <linux/types.h> |
Jan Engelhardt | 03d9948 | 2008-11-18 12:27:54 +0100 | [diff] [blame] | 18 | #include <linux/netfilter.h> |
Yasuyuki KOZAKAI | 0d502bc | 2007-07-24 05:52:07 +0000 | [diff] [blame] | 19 | #include <linux/netfilter/x_tables.h> |
Yasuyuki KOZAKAI | 0d502bc | 2007-07-24 05:52:07 +0000 | [diff] [blame] | 20 | |
Yasuyuki KOZAKAI | 5cd1ff5 | 2007-07-24 05:55:12 +0000 | [diff] [blame] | 21 | #ifndef IPPROTO_SCTP |
| 22 | #define IPPROTO_SCTP 132 |
| 23 | #endif |
| 24 | #ifndef IPPROTO_DCCP |
| 25 | #define IPPROTO_DCCP 33 |
| 26 | #endif |
Jan Engelhardt | 1de7edf | 2009-01-30 05:38:11 +0100 | [diff] [blame] | 27 | #ifndef IPPROTO_MH |
| 28 | # define IPPROTO_MH 135 |
| 29 | #endif |
Yasuyuki KOZAKAI | 5cd1ff5 | 2007-07-24 05:55:12 +0000 | [diff] [blame] | 30 | #ifndef IPPROTO_UDPLITE |
| 31 | #define IPPROTO_UDPLITE 136 |
| 32 | #endif |
| 33 | |
Jan Engelhardt | df60a30 | 2012-08-31 03:59:07 +0200 | [diff] [blame] | 34 | #include <xtables-version.h> |
Jan Engelhardt | 493c712 | 2008-04-15 11:15:16 +0200 | [diff] [blame] | 35 | |
Jan Engelhardt | ef18e81 | 2008-08-04 12:47:48 +0200 | [diff] [blame] | 36 | struct in_addr; |
| 37 | |
Jan Engelhardt | aa37acc | 2011-02-07 04:00:50 +0100 | [diff] [blame] | 38 | /* |
| 39 | * .size is here so that there is a somewhat reasonable check |
| 40 | * against the chosen .type. |
| 41 | */ |
| 42 | #define XTOPT_POINTER(stype, member) \ |
| 43 | .ptroff = offsetof(stype, member), \ |
| 44 | .size = sizeof(((stype *)NULL)->member) |
| 45 | #define XTOPT_TABLEEND {.name = NULL} |
| 46 | |
| 47 | /** |
Jan Engelhardt | d728241 | 2011-05-04 16:41:13 +0200 | [diff] [blame] | 48 | * Select the format the input has to conform to, as well as the target type |
| 49 | * (area pointed to with XTOPT_POINTER). Note that the storing is not always |
| 50 | * uniform. @cb->val will be populated with as much as there is space, i.e. |
| 51 | * exactly 2 items for ranges, but the target area can receive more values |
| 52 | * (e.g. in case of ranges), or less values (e.g. %XTTYPE_HOSTMASK). |
| 53 | * |
Jan Engelhardt | aa37acc | 2011-02-07 04:00:50 +0100 | [diff] [blame] | 54 | * %XTTYPE_NONE: option takes no argument |
Jan Engelhardt | a93142d | 2011-02-16 01:22:25 +0100 | [diff] [blame] | 55 | * %XTTYPE_UINT*: standard integer |
Jan Engelhardt | 04bb988 | 2011-02-27 23:41:10 +0100 | [diff] [blame] | 56 | * %XTTYPE_UINT*RC: colon-separated range of standard integers |
Jan Engelhardt | f012b3c | 2011-05-02 18:09:59 +0200 | [diff] [blame] | 57 | * %XTTYPE_DOUBLE: double-precision floating point number |
Jan Engelhardt | 4a0a176 | 2011-02-15 22:09:21 +0100 | [diff] [blame] | 58 | * %XTTYPE_STRING: arbitrary string |
Jan Engelhardt | 61cc52b | 2011-04-29 01:25:14 +0200 | [diff] [blame] | 59 | * %XTTYPE_TOSMASK: 8-bit TOS value with optional mask |
Jan Engelhardt | d25e217 | 2011-03-06 14:57:44 +0100 | [diff] [blame] | 60 | * %XTTYPE_MARKMASK32: 32-bit mark with optional mask |
Jan Engelhardt | 41a4cea | 2011-02-15 22:10:48 +0100 | [diff] [blame] | 61 | * %XTTYPE_SYSLOGLEVEL: syslog level by name or number |
Jan Engelhardt | d728241 | 2011-05-04 16:41:13 +0200 | [diff] [blame] | 62 | * %XTTYPE_HOST: one host or address (ptr: union nf_inet_addr) |
Jan Engelhardt | 66266ab | 2011-05-05 14:19:25 +0200 | [diff] [blame] | 63 | * %XTTYPE_HOSTMASK: one host or address, with an optional prefix length |
| 64 | * (ptr: union nf_inet_addr; only host portion is stored) |
Jan Engelhardt | 170cf49 | 2011-05-07 12:56:39 +0200 | [diff] [blame] | 65 | * %XTTYPE_PROTOCOL: protocol number/name from /etc/protocols (ptr: uint8_t) |
Jan Engelhardt | c02c92d | 2011-05-18 22:48:51 +0200 | [diff] [blame] | 66 | * %XTTYPE_PORT: 16-bit port name or number (supports %XTOPT_NBO) |
| 67 | * %XTTYPE_PORTRC: colon-separated port range (names acceptable), |
| 68 | * (supports %XTOPT_NBO) |
Jan Engelhardt | fa9b759 | 2011-05-04 17:25:54 +0200 | [diff] [blame] | 69 | * %XTTYPE_PLEN: prefix length |
Jan Engelhardt | d728241 | 2011-05-04 16:41:13 +0200 | [diff] [blame] | 70 | * %XTTYPE_PLENMASK: prefix length (ptr: union nf_inet_addr) |
Jan Engelhardt | cb225e2 | 2011-05-08 13:31:19 +0200 | [diff] [blame] | 71 | * %XTTYPE_ETHERMAC: Ethernet MAC address in hex form |
Jan Engelhardt | aa37acc | 2011-02-07 04:00:50 +0100 | [diff] [blame] | 72 | */ |
| 73 | enum xt_option_type { |
| 74 | XTTYPE_NONE, |
Jan Engelhardt | dfe99f1 | 2011-02-27 19:03:28 +0100 | [diff] [blame] | 75 | XTTYPE_UINT8, |
Jan Engelhardt | 0eff54b | 2011-03-06 17:42:51 +0100 | [diff] [blame] | 76 | XTTYPE_UINT16, |
Jan Engelhardt | a93142d | 2011-02-16 01:22:25 +0100 | [diff] [blame] | 77 | XTTYPE_UINT32, |
Jan Engelhardt | 8b5bdea | 2011-03-06 16:56:53 +0100 | [diff] [blame] | 78 | XTTYPE_UINT64, |
Jan Engelhardt | 8bf513a | 2011-03-06 17:09:19 +0100 | [diff] [blame] | 79 | XTTYPE_UINT8RC, |
Jan Engelhardt | 564eaf4 | 2011-03-06 16:59:23 +0100 | [diff] [blame] | 80 | XTTYPE_UINT16RC, |
Jan Engelhardt | 04bb988 | 2011-02-27 23:41:10 +0100 | [diff] [blame] | 81 | XTTYPE_UINT32RC, |
Jan Engelhardt | bc438c4 | 2011-03-06 17:13:54 +0100 | [diff] [blame] | 82 | XTTYPE_UINT64RC, |
Jan Engelhardt | f012b3c | 2011-05-02 18:09:59 +0200 | [diff] [blame] | 83 | XTTYPE_DOUBLE, |
Jan Engelhardt | 4a0a176 | 2011-02-15 22:09:21 +0100 | [diff] [blame] | 84 | XTTYPE_STRING, |
Jan Engelhardt | 61cc52b | 2011-04-29 01:25:14 +0200 | [diff] [blame] | 85 | XTTYPE_TOSMASK, |
Jan Engelhardt | d25e217 | 2011-03-06 14:57:44 +0100 | [diff] [blame] | 86 | XTTYPE_MARKMASK32, |
Jan Engelhardt | 41a4cea | 2011-02-15 22:10:48 +0100 | [diff] [blame] | 87 | XTTYPE_SYSLOGLEVEL, |
Jan Engelhardt | d728241 | 2011-05-04 16:41:13 +0200 | [diff] [blame] | 88 | XTTYPE_HOST, |
Jan Engelhardt | 66266ab | 2011-05-05 14:19:25 +0200 | [diff] [blame] | 89 | XTTYPE_HOSTMASK, |
Jan Engelhardt | 170cf49 | 2011-05-07 12:56:39 +0200 | [diff] [blame] | 90 | XTTYPE_PROTOCOL, |
Jan Engelhardt | b8592fa | 2011-02-14 15:12:50 +0100 | [diff] [blame] | 91 | XTTYPE_PORT, |
Jan Engelhardt | f30231a | 2011-04-17 13:33:50 +0200 | [diff] [blame] | 92 | XTTYPE_PORTRC, |
Jan Engelhardt | fa9b759 | 2011-05-04 17:25:54 +0200 | [diff] [blame] | 93 | XTTYPE_PLEN, |
Jan Engelhardt | e8b42fe | 2011-05-02 02:13:16 +0200 | [diff] [blame] | 94 | XTTYPE_PLENMASK, |
Jan Engelhardt | cb225e2 | 2011-05-08 13:31:19 +0200 | [diff] [blame] | 95 | XTTYPE_ETHERMAC, |
Jan Engelhardt | aa37acc | 2011-02-07 04:00:50 +0100 | [diff] [blame] | 96 | }; |
| 97 | |
| 98 | /** |
| 99 | * %XTOPT_INVERT: option is invertible (usable with !) |
| 100 | * %XTOPT_MAND: option is mandatory |
| 101 | * %XTOPT_MULTI: option may be specified multiple times |
| 102 | * %XTOPT_PUT: store value into memory at @ptroff |
Jan Engelhardt | c02c92d | 2011-05-18 22:48:51 +0200 | [diff] [blame] | 103 | * %XTOPT_NBO: store value in network-byte order |
| 104 | * (only certain XTTYPEs recognize this) |
Jan Engelhardt | aa37acc | 2011-02-07 04:00:50 +0100 | [diff] [blame] | 105 | */ |
| 106 | enum xt_option_flags { |
| 107 | XTOPT_INVERT = 1 << 0, |
| 108 | XTOPT_MAND = 1 << 1, |
| 109 | XTOPT_MULTI = 1 << 2, |
| 110 | XTOPT_PUT = 1 << 3, |
Jan Engelhardt | c02c92d | 2011-05-18 22:48:51 +0200 | [diff] [blame] | 111 | XTOPT_NBO = 1 << 4, |
Jan Engelhardt | aa37acc | 2011-02-07 04:00:50 +0100 | [diff] [blame] | 112 | }; |
| 113 | |
| 114 | /** |
| 115 | * @name: name of option |
| 116 | * @type: type of input and validation method, see %XTTYPE_* |
| 117 | * @id: unique number (within extension) for option, 0-31 |
| 118 | * @excl: bitmask of flags that cannot be used with this option |
| 119 | * @also: bitmask of flags that must be used with this option |
| 120 | * @flags: bitmask of option flags, see %XTOPT_* |
| 121 | * @ptroff: offset into private structure for member |
| 122 | * @size: size of the item pointed to by @ptroff; this is a safeguard |
Jan Engelhardt | d78254d | 2011-02-27 17:38:34 +0100 | [diff] [blame] | 123 | * @min: lowest allowed value (for singular integral types) |
| 124 | * @max: highest allowed value (for singular integral types) |
Jan Engelhardt | aa37acc | 2011-02-07 04:00:50 +0100 | [diff] [blame] | 125 | */ |
| 126 | struct xt_option_entry { |
| 127 | const char *name; |
| 128 | enum xt_option_type type; |
| 129 | unsigned int id, excl, also, flags; |
| 130 | unsigned int ptroff; |
| 131 | size_t size; |
Jan Engelhardt | d78254d | 2011-02-27 17:38:34 +0100 | [diff] [blame] | 132 | unsigned int min, max; |
Jan Engelhardt | aa37acc | 2011-02-07 04:00:50 +0100 | [diff] [blame] | 133 | }; |
| 134 | |
| 135 | /** |
| 136 | * @arg: input from command line |
| 137 | * @ext_name: name of extension currently being processed |
| 138 | * @entry: current option being processed |
Jan Engelhardt | 2dba676 | 2011-06-18 21:34:25 +0200 | [diff] [blame] | 139 | * @data: per-extension kernel data block |
Jan Engelhardt | aa37acc | 2011-02-07 04:00:50 +0100 | [diff] [blame] | 140 | * @xflags: options of the extension that have been used |
| 141 | * @invert: whether option was used with ! |
Jan Engelhardt | 04bb988 | 2011-02-27 23:41:10 +0100 | [diff] [blame] | 142 | * @nvals: number of results in uXX_multi |
Jan Engelhardt | aa37acc | 2011-02-07 04:00:50 +0100 | [diff] [blame] | 143 | * @val: parsed result |
Jan Engelhardt | 2dba676 | 2011-06-18 21:34:25 +0200 | [diff] [blame] | 144 | * @udata: per-extension private scratch area |
| 145 | * (cf. xtables_{match,target}->udata_size) |
Jan Engelhardt | aa37acc | 2011-02-07 04:00:50 +0100 | [diff] [blame] | 146 | */ |
| 147 | struct xt_option_call { |
| 148 | const char *arg, *ext_name; |
| 149 | const struct xt_option_entry *entry; |
| 150 | void *data; |
| 151 | unsigned int xflags; |
| 152 | bool invert; |
Jan Engelhardt | 04bb988 | 2011-02-27 23:41:10 +0100 | [diff] [blame] | 153 | uint8_t nvals; |
Jan Engelhardt | aa37acc | 2011-02-07 04:00:50 +0100 | [diff] [blame] | 154 | union { |
Jan Engelhardt | 170cf49 | 2011-05-07 12:56:39 +0200 | [diff] [blame] | 155 | uint8_t u8, u8_range[2], syslog_level, protocol; |
Jan Engelhardt | f30231a | 2011-04-17 13:33:50 +0200 | [diff] [blame] | 156 | uint16_t u16, u16_range[2], port, port_range[2]; |
Jan Engelhardt | 04bb988 | 2011-02-27 23:41:10 +0100 | [diff] [blame] | 157 | uint32_t u32, u32_range[2]; |
Jan Engelhardt | bc438c4 | 2011-03-06 17:13:54 +0100 | [diff] [blame] | 158 | uint64_t u64, u64_range[2]; |
Jan Engelhardt | f012b3c | 2011-05-02 18:09:59 +0200 | [diff] [blame] | 159 | double dbl; |
Jan Engelhardt | d728241 | 2011-05-04 16:41:13 +0200 | [diff] [blame] | 160 | struct { |
| 161 | union nf_inet_addr haddr, hmask; |
| 162 | uint8_t hlen; |
| 163 | }; |
Jan Engelhardt | d25e217 | 2011-03-06 14:57:44 +0100 | [diff] [blame] | 164 | struct { |
Jan Engelhardt | 61cc52b | 2011-04-29 01:25:14 +0200 | [diff] [blame] | 165 | uint8_t tos_value, tos_mask; |
| 166 | }; |
| 167 | struct { |
Jan Engelhardt | d25e217 | 2011-03-06 14:57:44 +0100 | [diff] [blame] | 168 | uint32_t mark, mask; |
| 169 | }; |
Jan Engelhardt | cb225e2 | 2011-05-08 13:31:19 +0200 | [diff] [blame] | 170 | uint8_t ethermac[6]; |
Jan Engelhardt | aa37acc | 2011-02-07 04:00:50 +0100 | [diff] [blame] | 171 | } val; |
Jan Engelhardt | 87a34d7 | 2011-05-07 00:15:49 +0200 | [diff] [blame] | 172 | /* Wished for a world where the ones below were gone: */ |
Jan Engelhardt | 33d1808 | 2011-03-06 18:11:58 +0100 | [diff] [blame] | 173 | union { |
| 174 | struct xt_entry_match **match; |
| 175 | struct xt_entry_target **target; |
| 176 | }; |
Jan Engelhardt | 87a34d7 | 2011-05-07 00:15:49 +0200 | [diff] [blame] | 177 | void *xt_entry; |
Jan Engelhardt | 2dba676 | 2011-06-18 21:34:25 +0200 | [diff] [blame] | 178 | void *udata; |
Jan Engelhardt | aa37acc | 2011-02-07 04:00:50 +0100 | [diff] [blame] | 179 | }; |
| 180 | |
Jan Engelhardt | 3af739b | 2011-02-10 16:57:37 +0100 | [diff] [blame] | 181 | /** |
| 182 | * @ext_name: name of extension currently being processed |
Jan Engelhardt | 2dba676 | 2011-06-18 21:34:25 +0200 | [diff] [blame] | 183 | * @data: per-extension (kernel) data block |
| 184 | * @udata: per-extension private scratch area |
| 185 | * (cf. xtables_{match,target}->udata_size) |
Jan Engelhardt | 3af739b | 2011-02-10 16:57:37 +0100 | [diff] [blame] | 186 | * @xflags: options of the extension that have been used |
| 187 | */ |
| 188 | struct xt_fcheck_call { |
| 189 | const char *ext_name; |
Jan Engelhardt | 2dba676 | 2011-06-18 21:34:25 +0200 | [diff] [blame] | 190 | void *data, *udata; |
Jan Engelhardt | 3af739b | 2011-02-10 16:57:37 +0100 | [diff] [blame] | 191 | unsigned int xflags; |
| 192 | }; |
| 193 | |
Jan Engelhardt | 2e0ec4f | 2011-03-06 16:24:43 +0100 | [diff] [blame] | 194 | /** |
| 195 | * A "linear"/linked-list based name<->id map, for files similar to |
| 196 | * /etc/iproute2/. |
| 197 | */ |
| 198 | struct xtables_lmap { |
| 199 | char *name; |
| 200 | int id; |
| 201 | struct xtables_lmap *next; |
| 202 | }; |
| 203 | |
Jozsef Kadlecsik | efcdba4 | 2013-01-28 21:15:27 +0100 | [diff] [blame] | 204 | enum xtables_ext_flags { |
| 205 | XTABLES_EXT_ALIAS = 1 << 0, |
| 206 | }; |
| 207 | |
Yasuyuki KOZAKAI | 0d502bc | 2007-07-24 05:52:07 +0000 | [diff] [blame] | 208 | /* Include file for additions: new matches and targets. */ |
| 209 | struct xtables_match |
| 210 | { |
Jan Engelhardt | c4edfa6 | 2009-03-30 00:44:46 +0200 | [diff] [blame] | 211 | /* |
| 212 | * ABI/API version this module requires. Must be first member, |
| 213 | * as the rest of this struct may be subject to ABI changes. |
| 214 | */ |
| 215 | const char *version; |
| 216 | |
Yasuyuki KOZAKAI | 0d502bc | 2007-07-24 05:52:07 +0000 | [diff] [blame] | 217 | struct xtables_match *next; |
| 218 | |
Jan Engelhardt | ef18e81 | 2008-08-04 12:47:48 +0200 | [diff] [blame] | 219 | const char *name; |
Jan Engelhardt | c436dad | 2012-09-27 23:48:25 +0200 | [diff] [blame] | 220 | const char *real_name; |
Yasuyuki KOZAKAI | 0d502bc | 2007-07-24 05:52:07 +0000 | [diff] [blame] | 221 | |
| 222 | /* Revision of match (0 by default). */ |
| 223 | u_int8_t revision; |
| 224 | |
Jozsef Kadlecsik | efcdba4 | 2013-01-28 21:15:27 +0100 | [diff] [blame] | 225 | /* Extension flags */ |
| 226 | u_int8_t ext_flags; |
| 227 | |
Yasuyuki KOZAKAI | 0d502bc | 2007-07-24 05:52:07 +0000 | [diff] [blame] | 228 | u_int16_t family; |
| 229 | |
Yasuyuki KOZAKAI | 0d502bc | 2007-07-24 05:52:07 +0000 | [diff] [blame] | 230 | /* Size of match data. */ |
| 231 | size_t size; |
| 232 | |
| 233 | /* Size of match data relevent for userspace comparison purposes */ |
| 234 | size_t userspacesize; |
| 235 | |
| 236 | /* Function which prints out usage message. */ |
| 237 | void (*help)(void); |
| 238 | |
| 239 | /* Initialize the match. */ |
Peter Riley | ea146a9 | 2007-09-02 13:09:07 +0000 | [diff] [blame] | 240 | void (*init)(struct xt_entry_match *m); |
Yasuyuki KOZAKAI | 0d502bc | 2007-07-24 05:52:07 +0000 | [diff] [blame] | 241 | |
| 242 | /* Function which parses command options; returns true if it |
| 243 | ate an option */ |
| 244 | /* entry is struct ipt_entry for example */ |
| 245 | int (*parse)(int c, char **argv, int invert, unsigned int *flags, |
| 246 | const void *entry, |
Yasuyuki KOZAKAI | 0d502bc | 2007-07-24 05:52:07 +0000 | [diff] [blame] | 247 | struct xt_entry_match **match); |
| 248 | |
| 249 | /* Final check; exit if not ok. */ |
| 250 | void (*final_check)(unsigned int flags); |
| 251 | |
| 252 | /* Prints out the match iff non-NULL: put space at end */ |
| 253 | /* ip is struct ipt_ip * for example */ |
| 254 | void (*print)(const void *ip, |
| 255 | const struct xt_entry_match *match, int numeric); |
| 256 | |
| 257 | /* Saves the match info in parsable form to stdout. */ |
| 258 | /* ip is struct ipt_ip * for example */ |
| 259 | void (*save)(const void *ip, const struct xt_entry_match *match); |
| 260 | |
Jozsef Kadlecsik | efcdba4 | 2013-01-28 21:15:27 +0100 | [diff] [blame] | 261 | /* Print match name or alias */ |
| 262 | const char *(*alias)(const struct xt_entry_match *match); |
| 263 | |
Yasuyuki KOZAKAI | 0d502bc | 2007-07-24 05:52:07 +0000 | [diff] [blame] | 264 | /* Pointer to list of extra command-line options */ |
| 265 | const struct option *extra_opts; |
| 266 | |
Jan Engelhardt | aa37acc | 2011-02-07 04:00:50 +0100 | [diff] [blame] | 267 | /* New parser */ |
| 268 | void (*x6_parse)(struct xt_option_call *); |
Jan Engelhardt | 3af739b | 2011-02-10 16:57:37 +0100 | [diff] [blame] | 269 | void (*x6_fcheck)(struct xt_fcheck_call *); |
Jan Engelhardt | aa37acc | 2011-02-07 04:00:50 +0100 | [diff] [blame] | 270 | const struct xt_option_entry *x6_options; |
| 271 | |
Jan Engelhardt | 2dba676 | 2011-06-18 21:34:25 +0200 | [diff] [blame] | 272 | /* Size of per-extension instance extra "global" scratch space */ |
| 273 | size_t udata_size; |
| 274 | |
Yasuyuki KOZAKAI | 0d502bc | 2007-07-24 05:52:07 +0000 | [diff] [blame] | 275 | /* Ignore these men behind the curtain: */ |
Jan Engelhardt | 2dba676 | 2011-06-18 21:34:25 +0200 | [diff] [blame] | 276 | void *udata; |
Yasuyuki KOZAKAI | 0d502bc | 2007-07-24 05:52:07 +0000 | [diff] [blame] | 277 | unsigned int option_offset; |
| 278 | struct xt_entry_match *m; |
| 279 | unsigned int mflags; |
Yasuyuki KOZAKAI | 0d502bc | 2007-07-24 05:52:07 +0000 | [diff] [blame] | 280 | unsigned int loaded; /* simulate loading so options are merged properly */ |
Yasuyuki KOZAKAI | 0d502bc | 2007-07-24 05:52:07 +0000 | [diff] [blame] | 281 | }; |
| 282 | |
| 283 | struct xtables_target |
| 284 | { |
Jan Engelhardt | c4edfa6 | 2009-03-30 00:44:46 +0200 | [diff] [blame] | 285 | /* |
| 286 | * ABI/API version this module requires. Must be first member, |
| 287 | * as the rest of this struct may be subject to ABI changes. |
| 288 | */ |
| 289 | const char *version; |
| 290 | |
Yasuyuki KOZAKAI | 0d502bc | 2007-07-24 05:52:07 +0000 | [diff] [blame] | 291 | struct xtables_target *next; |
| 292 | |
Jan Engelhardt | c4edfa6 | 2009-03-30 00:44:46 +0200 | [diff] [blame] | 293 | |
Jan Engelhardt | ef18e81 | 2008-08-04 12:47:48 +0200 | [diff] [blame] | 294 | const char *name; |
Yasuyuki KOZAKAI | 0d502bc | 2007-07-24 05:52:07 +0000 | [diff] [blame] | 295 | |
Jan Engelhardt | cd2f9bd | 2012-09-04 05:24:47 +0200 | [diff] [blame] | 296 | /* Real target behind this, if any. */ |
| 297 | const char *real_name; |
| 298 | |
Yasuyuki KOZAKAI | 0d502bc | 2007-07-24 05:52:07 +0000 | [diff] [blame] | 299 | /* Revision of target (0 by default). */ |
| 300 | u_int8_t revision; |
| 301 | |
Jozsef Kadlecsik | efcdba4 | 2013-01-28 21:15:27 +0100 | [diff] [blame] | 302 | /* Extension flags */ |
| 303 | u_int8_t ext_flags; |
| 304 | |
Yasuyuki KOZAKAI | 0d502bc | 2007-07-24 05:52:07 +0000 | [diff] [blame] | 305 | u_int16_t family; |
| 306 | |
Yasuyuki KOZAKAI | 0d502bc | 2007-07-24 05:52:07 +0000 | [diff] [blame] | 307 | |
| 308 | /* Size of target data. */ |
| 309 | size_t size; |
| 310 | |
| 311 | /* Size of target data relevent for userspace comparison purposes */ |
| 312 | size_t userspacesize; |
| 313 | |
| 314 | /* Function which prints out usage message. */ |
| 315 | void (*help)(void); |
| 316 | |
| 317 | /* Initialize the target. */ |
Peter Riley | ea146a9 | 2007-09-02 13:09:07 +0000 | [diff] [blame] | 318 | void (*init)(struct xt_entry_target *t); |
Yasuyuki KOZAKAI | 0d502bc | 2007-07-24 05:52:07 +0000 | [diff] [blame] | 319 | |
| 320 | /* Function which parses command options; returns true if it |
| 321 | ate an option */ |
| 322 | /* entry is struct ipt_entry for example */ |
| 323 | int (*parse)(int c, char **argv, int invert, unsigned int *flags, |
| 324 | const void *entry, |
| 325 | struct xt_entry_target **targetinfo); |
| 326 | |
| 327 | /* Final check; exit if not ok. */ |
| 328 | void (*final_check)(unsigned int flags); |
| 329 | |
| 330 | /* Prints out the target iff non-NULL: put space at end */ |
| 331 | void (*print)(const void *ip, |
| 332 | const struct xt_entry_target *target, int numeric); |
| 333 | |
| 334 | /* Saves the targinfo in parsable form to stdout. */ |
| 335 | void (*save)(const void *ip, |
| 336 | const struct xt_entry_target *target); |
| 337 | |
Jozsef Kadlecsik | efcdba4 | 2013-01-28 21:15:27 +0100 | [diff] [blame] | 338 | /* Print target name or alias */ |
| 339 | const char *(*alias)(const struct xt_entry_target *target); |
| 340 | |
Yasuyuki KOZAKAI | 0d502bc | 2007-07-24 05:52:07 +0000 | [diff] [blame] | 341 | /* Pointer to list of extra command-line options */ |
Jan Engelhardt | 3365332 | 2007-07-30 13:20:43 +0000 | [diff] [blame] | 342 | const struct option *extra_opts; |
Yasuyuki KOZAKAI | 0d502bc | 2007-07-24 05:52:07 +0000 | [diff] [blame] | 343 | |
Jan Engelhardt | aa37acc | 2011-02-07 04:00:50 +0100 | [diff] [blame] | 344 | /* New parser */ |
| 345 | void (*x6_parse)(struct xt_option_call *); |
Jan Engelhardt | 3af739b | 2011-02-10 16:57:37 +0100 | [diff] [blame] | 346 | void (*x6_fcheck)(struct xt_fcheck_call *); |
Jan Engelhardt | aa37acc | 2011-02-07 04:00:50 +0100 | [diff] [blame] | 347 | const struct xt_option_entry *x6_options; |
| 348 | |
Jan Engelhardt | 2dba676 | 2011-06-18 21:34:25 +0200 | [diff] [blame] | 349 | size_t udata_size; |
| 350 | |
Yasuyuki KOZAKAI | 0d502bc | 2007-07-24 05:52:07 +0000 | [diff] [blame] | 351 | /* Ignore these men behind the curtain: */ |
Jan Engelhardt | 2dba676 | 2011-06-18 21:34:25 +0200 | [diff] [blame] | 352 | void *udata; |
Yasuyuki KOZAKAI | 0d502bc | 2007-07-24 05:52:07 +0000 | [diff] [blame] | 353 | unsigned int option_offset; |
| 354 | struct xt_entry_target *t; |
| 355 | unsigned int tflags; |
| 356 | unsigned int used; |
Yasuyuki KOZAKAI | 0d502bc | 2007-07-24 05:52:07 +0000 | [diff] [blame] | 357 | unsigned int loaded; /* simulate loading so options are merged properly */ |
Yasuyuki KOZAKAI | 0d502bc | 2007-07-24 05:52:07 +0000 | [diff] [blame] | 358 | }; |
| 359 | |
Jan Engelhardt | 2338efd | 2009-01-27 15:23:01 +0100 | [diff] [blame] | 360 | struct xtables_rule_match { |
| 361 | struct xtables_rule_match *next; |
| 362 | struct xtables_match *match; |
| 363 | /* Multiple matches of the same type: the ones before |
| 364 | the current one are completed from parsing point of view */ |
| 365 | bool completed; |
| 366 | }; |
| 367 | |
Jan Engelhardt | 1de7edf | 2009-01-30 05:38:11 +0100 | [diff] [blame] | 368 | /** |
| 369 | * struct xtables_pprot - |
| 370 | * |
| 371 | * A few hardcoded protocols for 'all' and in case the user has no |
| 372 | * /etc/protocols. |
| 373 | */ |
| 374 | struct xtables_pprot { |
| 375 | const char *name; |
| 376 | u_int8_t num; |
| 377 | }; |
| 378 | |
Jan Engelhardt | 2338efd | 2009-01-27 15:23:01 +0100 | [diff] [blame] | 379 | enum xtables_tryload { |
| 380 | XTF_DONT_LOAD, |
| 381 | XTF_DURING_LOAD, |
| 382 | XTF_TRY_LOAD, |
| 383 | XTF_LOAD_MUST_SUCCEED, |
| 384 | }; |
| 385 | |
Jan Engelhardt | a41545c | 2009-01-27 21:27:19 +0100 | [diff] [blame] | 386 | enum xtables_exittype { |
| 387 | OTHER_PROBLEM = 1, |
| 388 | PARAMETER_PROBLEM, |
| 389 | VERSION_PROBLEM, |
| 390 | RESOURCE_PROBLEM, |
| 391 | XTF_ONLY_ONCE, |
| 392 | XTF_NO_INVERT, |
| 393 | XTF_BAD_VALUE, |
| 394 | XTF_ONE_ACTION, |
| 395 | }; |
| 396 | |
Jamal Hadi Salim | 40a8343 | 2009-02-11 13:02:21 +0100 | [diff] [blame] | 397 | struct xtables_globals |
| 398 | { |
| 399 | unsigned int option_offset; |
Jan Engelhardt | 41f03ba | 2009-02-11 16:13:47 +0100 | [diff] [blame] | 400 | const char *program_name, *program_version; |
Jamal Hadi Salim | 139b3fe | 2009-02-12 11:43:01 -0500 | [diff] [blame] | 401 | struct option *orig_opts; |
Jamal Hadi Salim | 40a8343 | 2009-02-11 13:02:21 +0100 | [diff] [blame] | 402 | struct option *opts; |
Jamal Hadi Salim | 8b7baeb | 2009-02-11 13:05:43 +0100 | [diff] [blame] | 403 | void (*exit_err)(enum xtables_exittype status, const char *msg, ...) __attribute__((noreturn, format(printf,2,3))); |
Jamal Hadi Salim | 40a8343 | 2009-02-11 13:02:21 +0100 | [diff] [blame] | 404 | }; |
| 405 | |
Jan Engelhardt | 104fb31 | 2011-05-07 04:01:25 +0200 | [diff] [blame] | 406 | #define XT_GETOPT_TABLEEND {.name = NULL, .has_arg = false} |
Jan Engelhardt | 32b8e61 | 2010-07-23 21:16:14 +0200 | [diff] [blame] | 407 | |
Jan Engelhardt | 771871e | 2009-05-22 11:46:55 +0200 | [diff] [blame] | 408 | #ifdef __cplusplus |
| 409 | extern "C" { |
| 410 | #endif |
| 411 | |
Jan Engelhardt | c021c3c | 2009-01-27 15:10:05 +0100 | [diff] [blame] | 412 | extern const char *xtables_modprobe_program; |
Jan Engelhardt | 2338efd | 2009-01-27 15:23:01 +0100 | [diff] [blame] | 413 | extern struct xtables_match *xtables_matches; |
| 414 | extern struct xtables_target *xtables_targets; |
Jan Engelhardt | c021c3c | 2009-01-27 15:10:05 +0100 | [diff] [blame] | 415 | |
Jan Engelhardt | 39bf9c8 | 2009-01-27 15:59:06 +0100 | [diff] [blame] | 416 | extern void xtables_init(void); |
Jan Engelhardt | 77f48c2 | 2009-02-07 19:59:53 +0100 | [diff] [blame] | 417 | extern void xtables_set_nfproto(uint8_t); |
Jan Engelhardt | 630ef48 | 2009-01-27 14:58:41 +0100 | [diff] [blame] | 418 | extern void *xtables_calloc(size_t, size_t); |
| 419 | extern void *xtables_malloc(size_t); |
Michael Granzow | 332e4ac | 2009-04-09 18:24:36 +0100 | [diff] [blame] | 420 | extern void *xtables_realloc(void *, size_t); |
Jan Engelhardt | 630ef48 | 2009-01-27 14:58:41 +0100 | [diff] [blame] | 421 | |
Jan Engelhardt | c021c3c | 2009-01-27 15:10:05 +0100 | [diff] [blame] | 422 | extern int xtables_insmod(const char *, const char *, bool); |
| 423 | extern int xtables_load_ko(const char *, bool); |
Jamal Hadi Salim | 8b7baeb | 2009-02-11 13:05:43 +0100 | [diff] [blame] | 424 | extern int xtables_set_params(struct xtables_globals *xtp); |
Jamal Hadi Salim | 139b3fe | 2009-02-12 11:43:01 -0500 | [diff] [blame] | 425 | extern void xtables_free_opts(int reset_offset); |
Jan Engelhardt | 710a132 | 2010-11-15 14:39:35 +0100 | [diff] [blame] | 426 | extern struct option *xtables_merge_options(struct option *origopts, |
| 427 | struct option *oldopts, const struct option *newopts, |
| 428 | unsigned int *option_offset); |
Jan Engelhardt | c021c3c | 2009-01-27 15:10:05 +0100 | [diff] [blame] | 429 | |
Jamal Hadi Salim | 7e4db2f | 2009-02-13 09:14:17 -0500 | [diff] [blame] | 430 | extern int xtables_init_all(struct xtables_globals *xtp, uint8_t nfproto); |
Jan Engelhardt | 2338efd | 2009-01-27 15:23:01 +0100 | [diff] [blame] | 431 | extern struct xtables_match *xtables_find_match(const char *name, |
| 432 | enum xtables_tryload, struct xtables_rule_match **match); |
| 433 | extern struct xtables_target *xtables_find_target(const char *name, |
| 434 | enum xtables_tryload); |
| 435 | |
Pablo Neira Ayuso | d1e7922 | 2013-01-04 20:27:11 +0100 | [diff] [blame] | 436 | extern void xtables_rule_matches_free(struct xtables_rule_match **matches); |
| 437 | |
Yasuyuki KOZAKAI | 0d502bc | 2007-07-24 05:52:07 +0000 | [diff] [blame] | 438 | /* Your shared library should call one of these. */ |
| 439 | extern void xtables_register_match(struct xtables_match *me); |
Jan Engelhardt | 9a8fc4f | 2009-06-25 17:13:46 +0200 | [diff] [blame] | 440 | extern void xtables_register_matches(struct xtables_match *, unsigned int); |
Yasuyuki KOZAKAI | 0d502bc | 2007-07-24 05:52:07 +0000 | [diff] [blame] | 441 | extern void xtables_register_target(struct xtables_target *me); |
Jan Engelhardt | 9a8fc4f | 2009-06-25 17:13:46 +0200 | [diff] [blame] | 442 | extern void xtables_register_targets(struct xtables_target *, unsigned int); |
Yasuyuki KOZAKAI | 0d502bc | 2007-07-24 05:52:07 +0000 | [diff] [blame] | 443 | |
Jan Engelhardt | 0b7a140 | 2011-05-24 02:30:23 +0200 | [diff] [blame] | 444 | extern bool xtables_strtoul(const char *, char **, uintmax_t *, |
| 445 | uintmax_t, uintmax_t); |
Jan Engelhardt | 5f2922c | 2009-01-27 18:43:01 +0100 | [diff] [blame] | 446 | extern bool xtables_strtoui(const char *, char **, unsigned int *, |
Jan Engelhardt | cd9e7aa | 2008-01-20 13:18:54 +0000 | [diff] [blame] | 447 | unsigned int, unsigned int); |
Jan Engelhardt | aae6be9 | 2009-01-30 04:24:47 +0100 | [diff] [blame] | 448 | extern int xtables_service_to_port(const char *name, const char *proto); |
| 449 | extern u_int16_t xtables_parse_port(const char *port, const char *proto); |
Yasuyuki KOZAKAI | 04f8c54 | 2007-07-24 05:53:48 +0000 | [diff] [blame] | 450 | extern void |
Jan Engelhardt | aae6be9 | 2009-01-30 04:24:47 +0100 | [diff] [blame] | 451 | xtables_parse_interface(const char *arg, char *vianame, unsigned char *mask); |
Yasuyuki KOZAKAI | 04f8c54 | 2007-07-24 05:53:48 +0000 | [diff] [blame] | 452 | |
Yasuyuki KOZAKAI | a3732db | 2007-07-24 06:39:40 +0000 | [diff] [blame] | 453 | /* this is a special 64bit data type that is 8-byte aligned */ |
Patrick McHardy | c329d6a | 2007-09-05 14:19:23 +0000 | [diff] [blame] | 454 | #define aligned_u64 u_int64_t __attribute__((aligned(8))) |
Yasuyuki KOZAKAI | a3732db | 2007-07-24 06:39:40 +0000 | [diff] [blame] | 455 | |
Jamal Hadi Salim | 8b7baeb | 2009-02-11 13:05:43 +0100 | [diff] [blame] | 456 | extern struct xtables_globals *xt_params; |
Jan Engelhardt | 1829ed4 | 2009-02-21 03:29:44 +0100 | [diff] [blame] | 457 | #define xtables_error (xt_params->exit_err) |
Jamal Hadi Salim | 7058192 | 2009-02-13 08:36:44 -0500 | [diff] [blame] | 458 | |
Jan Engelhardt | a41545c | 2009-01-27 21:27:19 +0100 | [diff] [blame] | 459 | extern void xtables_param_act(unsigned int, const char *, ...); |
Yasuyuki KOZAKAI | a3732db | 2007-07-24 06:39:40 +0000 | [diff] [blame] | 460 | |
Jan Engelhardt | e44ea7f | 2009-01-30 03:55:09 +0100 | [diff] [blame] | 461 | extern const char *xtables_ipaddr_to_numeric(const struct in_addr *); |
| 462 | extern const char *xtables_ipaddr_to_anyname(const struct in_addr *); |
| 463 | extern const char *xtables_ipmask_to_numeric(const struct in_addr *); |
Jan Engelhardt | 1e01b0b | 2009-01-30 04:20:32 +0100 | [diff] [blame] | 464 | extern struct in_addr *xtables_numeric_to_ipaddr(const char *); |
| 465 | extern struct in_addr *xtables_numeric_to_ipmask(const char *); |
Pablo Neira Ayuso | a96166c | 2012-07-14 15:39:20 +0200 | [diff] [blame] | 466 | extern int xtables_ipmask_to_cidr(const struct in_addr *); |
Jan Engelhardt | a0baae8 | 2009-01-30 04:32:50 +0100 | [diff] [blame] | 467 | extern void xtables_ipparse_any(const char *, struct in_addr **, |
Jan Engelhardt | bd94384 | 2008-01-20 13:38:08 +0000 | [diff] [blame] | 468 | struct in_addr *, unsigned int *); |
Michael Granzow | 332e4ac | 2009-04-09 18:24:36 +0100 | [diff] [blame] | 469 | extern void xtables_ipparse_multiple(const char *, struct in_addr **, |
| 470 | struct in_addr **, unsigned int *); |
Jan Engelhardt | 08b1616 | 2008-01-20 13:36:08 +0000 | [diff] [blame] | 471 | |
Jan Engelhardt | 1e01b0b | 2009-01-30 04:20:32 +0100 | [diff] [blame] | 472 | extern struct in6_addr *xtables_numeric_to_ip6addr(const char *); |
Jan Engelhardt | e44ea7f | 2009-01-30 03:55:09 +0100 | [diff] [blame] | 473 | extern const char *xtables_ip6addr_to_numeric(const struct in6_addr *); |
| 474 | extern const char *xtables_ip6addr_to_anyname(const struct in6_addr *); |
| 475 | extern const char *xtables_ip6mask_to_numeric(const struct in6_addr *); |
Pablo Neira Ayuso | a96166c | 2012-07-14 15:39:20 +0200 | [diff] [blame] | 476 | extern int xtables_ip6mask_to_cidr(const struct in6_addr *); |
Jan Engelhardt | a0baae8 | 2009-01-30 04:32:50 +0100 | [diff] [blame] | 477 | extern void xtables_ip6parse_any(const char *, struct in6_addr **, |
Jan Engelhardt | bd94384 | 2008-01-20 13:38:08 +0000 | [diff] [blame] | 478 | struct in6_addr *, unsigned int *); |
Michael Granzow | 332e4ac | 2009-04-09 18:24:36 +0100 | [diff] [blame] | 479 | extern void xtables_ip6parse_multiple(const char *, struct in6_addr **, |
| 480 | struct in6_addr **, unsigned int *); |
Jan Engelhardt | 08b1616 | 2008-01-20 13:36:08 +0000 | [diff] [blame] | 481 | |
Max Kellermann | a5d0994 | 2008-01-29 13:44:34 +0000 | [diff] [blame] | 482 | /** |
| 483 | * Print the specified value to standard output, quoting dangerous |
| 484 | * characters if required. |
| 485 | */ |
Jan Engelhardt | a0baae8 | 2009-01-30 04:32:50 +0100 | [diff] [blame] | 486 | extern void xtables_save_string(const char *value); |
Max Kellermann | a5d0994 | 2008-01-29 13:44:34 +0000 | [diff] [blame] | 487 | |
Pablo Neira Ayuso | 2f655ed | 2012-10-29 10:49:42 +0100 | [diff] [blame] | 488 | #define FMT_NUMERIC 0x0001 |
| 489 | #define FMT_NOCOUNTS 0x0002 |
| 490 | #define FMT_KILOMEGAGIGA 0x0004 |
| 491 | #define FMT_OPTIONS 0x0008 |
| 492 | #define FMT_NOTABLE 0x0010 |
| 493 | #define FMT_NOTARGET 0x0020 |
| 494 | #define FMT_VIA 0x0040 |
| 495 | #define FMT_NONEWLINE 0x0080 |
| 496 | #define FMT_LINENUMBERS 0x0100 |
| 497 | |
| 498 | #define FMT_PRINT_RULE (FMT_NOCOUNTS | FMT_OPTIONS | FMT_VIA \ |
| 499 | | FMT_NUMERIC | FMT_NOTABLE) |
| 500 | #define FMT(tab,notab) ((format) & FMT_NOTABLE ? (notab) : (tab)) |
| 501 | |
| 502 | extern void xtables_print_num(uint64_t number, unsigned int format); |
| 503 | |
Jan Engelhardt | b79ec69 | 2009-07-23 17:41:21 +0200 | [diff] [blame] | 504 | #if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS) |
Jan Engelhardt | f82070f | 2008-01-20 13:14:00 +0000 | [diff] [blame] | 505 | # ifdef _INIT |
| 506 | # undef _init |
| 507 | # define _init _INIT |
| 508 | # endif |
Maciej Żenczykowski | 9a9694f | 2011-04-06 13:35:11 -0700 | [diff] [blame] | 509 | extern void init_extensions(void); |
Maciej Zenczykowski | 5e8f947 | 2011-04-04 15:32:39 +0200 | [diff] [blame] | 510 | extern void init_extensions4(void); |
Maciej Zenczykowski | 49d8c5d | 2011-04-04 15:33:25 +0200 | [diff] [blame] | 511 | extern void init_extensions6(void); |
Jan Engelhardt | f82070f | 2008-01-20 13:14:00 +0000 | [diff] [blame] | 512 | #else |
| 513 | # define _init __attribute__((constructor)) _INIT |
Yasuyuki KOZAKAI | a3732db | 2007-07-24 06:39:40 +0000 | [diff] [blame] | 514 | #endif |
| 515 | |
Jan Engelhardt | 1de7edf | 2009-01-30 05:38:11 +0100 | [diff] [blame] | 516 | extern const struct xtables_pprot xtables_chain_protos[]; |
| 517 | extern u_int16_t xtables_parse_protocol(const char *s); |
Jan Engelhardt | 33690a1 | 2008-02-11 00:54:00 +0100 | [diff] [blame] | 518 | |
Jan Engelhardt | f56b8a8 | 2011-09-03 14:27:55 +0200 | [diff] [blame] | 519 | /* kernel revision handling */ |
| 520 | extern int kernel_version; |
| 521 | extern void get_kernel_version(void); |
| 522 | #define LINUX_VERSION(x,y,z) (0x10000*(x) + 0x100*(y) + z) |
| 523 | #define LINUX_VERSION_MAJOR(x) (((x)>>16) & 0xFF) |
| 524 | #define LINUX_VERSION_MINOR(x) (((x)>> 8) & 0xFF) |
| 525 | #define LINUX_VERSION_PATCH(x) ( (x) & 0xFF) |
| 526 | |
Jan Engelhardt | aa37acc | 2011-02-07 04:00:50 +0100 | [diff] [blame] | 527 | /* xtoptions.c */ |
| 528 | extern void xtables_option_metavalidate(const char *, |
| 529 | const struct xt_option_entry *); |
| 530 | extern struct option *xtables_options_xfrm(struct option *, struct option *, |
| 531 | const struct xt_option_entry *, |
| 532 | unsigned int *); |
| 533 | extern void xtables_option_parse(struct xt_option_call *); |
| 534 | extern void xtables_option_tpcall(unsigned int, char **, bool, |
| 535 | struct xtables_target *, void *); |
| 536 | extern void xtables_option_mpcall(unsigned int, char **, bool, |
| 537 | struct xtables_match *, void *); |
Jan Engelhardt | 3af739b | 2011-02-10 16:57:37 +0100 | [diff] [blame] | 538 | extern void xtables_option_tfcall(struct xtables_target *); |
| 539 | extern void xtables_option_mfcall(struct xtables_match *); |
Jan Engelhardt | aa37acc | 2011-02-07 04:00:50 +0100 | [diff] [blame] | 540 | extern void xtables_options_fcheck(const char *, unsigned int, |
| 541 | const struct xt_option_entry *); |
| 542 | |
Jan Engelhardt | 2e0ec4f | 2011-03-06 16:24:43 +0100 | [diff] [blame] | 543 | extern struct xtables_lmap *xtables_lmap_init(const char *); |
| 544 | extern void xtables_lmap_free(struct xtables_lmap *); |
| 545 | extern int xtables_lmap_name2id(const struct xtables_lmap *, const char *); |
| 546 | extern const char *xtables_lmap_id2name(const struct xtables_lmap *, int); |
| 547 | |
Jan Engelhardt | 33690a1 | 2008-02-11 00:54:00 +0100 | [diff] [blame] | 548 | #ifdef XTABLES_INTERNAL |
Jan Engelhardt | c02e808 | 2009-02-10 10:40:15 +0100 | [diff] [blame] | 549 | |
| 550 | /* Shipped modules rely on this... */ |
| 551 | |
Jan Engelhardt | 1de7edf | 2009-01-30 05:38:11 +0100 | [diff] [blame] | 552 | # ifndef ARRAY_SIZE |
| 553 | # define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x))) |
| 554 | # endif |
Jan Engelhardt | c02e808 | 2009-02-10 10:40:15 +0100 | [diff] [blame] | 555 | |
| 556 | extern void _init(void); |
| 557 | |
Jan Engelhardt | 33690a1 | 2008-02-11 00:54:00 +0100 | [diff] [blame] | 558 | #endif |
| 559 | |
Jan Engelhardt | 771871e | 2009-05-22 11:46:55 +0200 | [diff] [blame] | 560 | #ifdef __cplusplus |
| 561 | } /* extern "C" */ |
| 562 | #endif |
| 563 | |
Yasuyuki KOZAKAI | 5208806 | 2007-07-24 05:44:11 +0000 | [diff] [blame] | 564 | #endif /* _XTABLES_H */ |