blob: 9df1a2976d3a87185df1623fe971dcfe438267d1 [file] [log] [blame]
Marc Bouchere6869a82000-03-20 06:03:29 +00001#ifndef _IPTABLES_USER_H
2#define _IPTABLES_USER_H
3
Yasuyuki KOZAKAI0d502bc2007-07-24 05:52:07 +00004#include "xtables.h"
Rusty Russell79dee072000-05-02 16:45:16 +00005#include "iptables_common.h"
Marc Bouchere6869a82000-03-20 06:03:29 +00006#include "libiptc/libiptc.h"
7
Martin Josefsson357d59d2004-12-27 19:49:28 +00008#ifndef IPT_LIB_DIR
9#define IPT_LIB_DIR "/usr/local/lib/iptables"
10#endif
11
Harald Weltedb0422f2004-03-04 07:45:30 +000012#ifndef IPPROTO_SCTP
13#define IPPROTO_SCTP 132
14#endif
Patrick McHardy2452baf2006-04-28 08:10:08 +000015#ifndef IPPROTO_DCCP
16#define IPPROTO_DCCP 33
17#endif
Patrick McHardy95616062007-01-11 09:08:22 +000018#ifndef IPPROTO_UDPLITE
19#define IPPROTO_UDPLITE 136
20#endif
Harald Weltedb0422f2004-03-04 07:45:30 +000021
Rusty Russell3aef54d2005-01-03 03:48:40 +000022#ifndef IPT_SO_GET_REVISION_MATCH /* Old kernel source. */
23#define IPT_SO_GET_REVISION_MATCH (IPT_BASE_CTL + 2)
24#define IPT_SO_GET_REVISION_TARGET (IPT_BASE_CTL + 3)
Rusty Russell3aef54d2005-01-03 03:48:40 +000025#endif /* IPT_SO_GET_REVISION_MATCH Old kernel source */
26
Yasuyuki KOZAKAI0d502bc2007-07-24 05:52:07 +000027#define iptables_rule_match xtables_rule_match
28#define iptables_match xtables_match
29#define iptables_target xtables_target
30#define ipt_tryload xt_tryload
Marc Bouchere6869a82000-03-20 06:03:29 +000031
Illes Marci63e90632003-03-03 08:08:37 +000032extern int line;
33
Marc Bouchere6869a82000-03-20 06:03:29 +000034/* Your shared library should call one of these. */
35extern void register_match(struct iptables_match *me);
36extern void register_target(struct iptables_target *me);
37
Phil Oester58179b12006-07-20 17:00:19 +000038extern int service_to_port(const char *name, const char *proto);
Phil Oesterdbac8ad2006-07-20 17:01:54 +000039extern u_int16_t parse_port(const char *port, const char *proto);
Rusty Russell79dee072000-05-02 16:45:16 +000040extern struct in_addr *dotted_to_addr(const char *dotted);
Pablo Neira Ayuso267a5702006-11-29 13:32:32 +000041extern struct in_addr *dotted_to_mask(const char *dotted);
Marc Bouchere6869a82000-03-20 06:03:29 +000042extern char *addr_to_dotted(const struct in_addr *addrp);
Marc Boucherb93c7982001-12-06 14:50:19 +000043extern char *addr_to_anyname(const struct in_addr *addr);
44extern char *mask_to_dotted(const struct in_addr *mask);
45
46extern void parse_hostnetworkmask(const char *name, struct in_addr **addrpp,
47 struct in_addr *maskp, unsigned int *naddrs);
48extern u_int16_t parse_protocol(const char *s);
Yasuyuki KOZAKAI9867e812005-06-22 12:24:21 +000049extern void parse_interface(const char *arg, char *vianame, unsigned char *mask);
Marc Bouchere6869a82000-03-20 06:03:29 +000050
51extern int do_command(int argc, char *argv[], char **table,
52 iptc_handle_t *handle);
Harald Weltea114e9e2000-12-01 14:28:19 +000053extern int delete_chain(const ipt_chainlabel chain, int verbose,
54 iptc_handle_t *handle);
55extern int flush_entries(const ipt_chainlabel chain, int verbose,
56 iptc_handle_t *handle);
57extern int for_each_chain(int (*fn)(const ipt_chainlabel, int, iptc_handle_t *),
58 int verbose, int builtinstoo, iptc_handle_t *handle);
Phil Oester8cf65912005-09-19 15:00:33 +000059
60/* kernel revision handling */
61extern int kernel_version;
62extern void get_kernel_version(void);
63#define LINUX_VERSION(x,y,z) (0x10000*(x) + 0x100*(y) + z)
64#define LINUX_VERSION_MAJOR(x) (((x)>>16) & 0xFF)
65#define LINUX_VERSION_MINOR(x) (((x)>> 8) & 0xFF)
66#define LINUX_VERSION_PATCH(x) ( (x) & 0xFF)
67
Marc Bouchere6869a82000-03-20 06:03:29 +000068#endif /*_IPTABLES_USER_H*/