blob: 7907f66b4680af576da44ab008aa18b0f223431b [file] [log] [blame]
Rusty Russell79dee072000-05-02 16:45:16 +00001#ifndef _IP6TABLES_USER_H
2#define _IP6TABLES_USER_H
3
4#include "iptables_common.h"
5#include "libiptc/libip6tc.h"
6
Martin Josefsson357d59d2004-12-27 19:49:28 +00007#ifndef IP6T_LIB_DIR
8#define IP6T_LIB_DIR "/usr/local/lib/iptables"
9#endif
10
Patrick McHardy2452baf2006-04-28 08:10:08 +000011#ifndef IPPROTO_SCTP
12#define IPPROTO_SCTP 132
13#endif
14#ifndef IPPROTO_DCCP
15#define IPPROTO_DCCP 33
16#endif
17
Rémi Denis-Courmont06652172006-10-20 12:24:34 +000018#ifndef IP6T_SO_GET_REVISION_MATCH /* Old kernel source. */
Yasuyuki KOZAKAI4ebfad02006-11-13 04:03:26 +000019#define IP6T_SO_GET_REVISION_MATCH 68
20#define IP6T_SO_GET_REVISION_TARGET 69
Rémi Denis-Courmont06652172006-10-20 12:24:34 +000021
22struct ip6t_get_revision
23{
24 char name[IP6T_FUNCTION_MAXNAMELEN-1];
25
26 u_int8_t revision;
27};
28#endif /* IP6T_SO_GET_REVISION_MATCH Old kernel source */
29
Martin Josefsson69ac0e02004-02-02 20:02:10 +000030struct ip6tables_rule_match
31{
32 struct ip6tables_rule_match *next;
33
34 struct ip6tables_match *match;
Joszef Kadlecsika258ad72006-03-03 09:36:50 +000035
36 /* Multiple matches of the same type: the ones before
37 the current one are completed from parsing point of view */
38 unsigned int completed;
Martin Josefsson69ac0e02004-02-02 20:02:10 +000039};
40
Rusty Russell79dee072000-05-02 16:45:16 +000041/* Include file for additions: new matches and targets. */
42struct ip6tables_match
43{
44 struct ip6tables_match *next;
45
46 ip6t_chainlabel name;
47
Rémi Denis-Courmont06652172006-10-20 12:24:34 +000048 /* Revision of match (0 by default). */
49 u_int8_t revision;
50
Rusty Russell79dee072000-05-02 16:45:16 +000051 const char *version;
52
53 /* Size of match data. */
54 size_t size;
55
Philip Blundell8c700902000-05-15 02:17:52 +000056 /* Size of match data relevent for userspace comparison purposes */
57 size_t userspacesize;
58
Rusty Russell79dee072000-05-02 16:45:16 +000059 /* Function which prints out usage message. */
60 void (*help)(void);
61
62 /* Initialize the match. */
63 void (*init)(struct ip6t_entry_match *m, unsigned int *nfcache);
64
65 /* Function which parses command options; returns true if it
66 ate an option */
67 int (*parse)(int c, char **argv, int invert, unsigned int *flags,
68 const struct ip6t_entry *entry,
69 unsigned int *nfcache,
70 struct ip6t_entry_match **match);
71
72 /* Final check; exit if not ok. */
73 void (*final_check)(unsigned int flags);
74
75 /* Prints out the match iff non-NULL: put space at end */
76 void (*print)(const struct ip6t_ip6 *ip,
77 const struct ip6t_entry_match *match, int numeric);
78
79 /* Saves the union ipt_matchinfo in parsable form to stdout. */
80 void (*save)(const struct ip6t_ip6 *ip,
81 const struct ip6t_entry_match *match);
82
83 /* Pointer to list of extra command-line options */
Jan Echternachb6db3312000-08-27 07:39:08 +000084 const struct option *extra_opts;
Rusty Russell79dee072000-05-02 16:45:16 +000085
86 /* Ignore these men behind the curtain: */
87 unsigned int option_offset;
88 struct ip6t_entry_match *m;
89 unsigned int mflags;
Harald Welte3efb6ea2001-08-06 18:50:21 +000090#ifdef NO_SHARED_LIBS
91 unsigned int loaded; /* simulate loading so options are merged properly */
92#endif
Rusty Russell79dee072000-05-02 16:45:16 +000093};
94
95struct ip6tables_target
96{
97 struct ip6tables_target *next;
98
99 ip6t_chainlabel name;
100
101 const char *version;
102
103 /* Size of target data. */
104 size_t size;
105
Philip Blundell8c700902000-05-15 02:17:52 +0000106 /* Size of target data relevent for userspace comparison purposes */
107 size_t userspacesize;
108
Rusty Russell79dee072000-05-02 16:45:16 +0000109 /* Function which prints out usage message. */
110 void (*help)(void);
111
112 /* Initialize the target. */
113 void (*init)(struct ip6t_entry_target *t, unsigned int *nfcache);
114
115 /* Function which parses command options; returns true if it
116 ate an option */
117 int (*parse)(int c, char **argv, int invert, unsigned int *flags,
118 const struct ip6t_entry *entry,
119 struct ip6t_entry_target **target);
120
121 /* Final check; exit if not ok. */
122 void (*final_check)(unsigned int flags);
123
124 /* Prints out the target iff non-NULL: put space at end */
125 void (*print)(const struct ip6t_ip6 *ip,
126 const struct ip6t_entry_target *target, int numeric);
127
128 /* Saves the targinfo in parsable form to stdout. */
129 void (*save)(const struct ip6t_ip6 *ip,
130 const struct ip6t_entry_target *target);
131
132 /* Pointer to list of extra command-line options */
133 struct option *extra_opts;
134
135 /* Ignore these men behind the curtain: */
136 unsigned int option_offset;
137 struct ip6t_entry_target *t;
138 unsigned int tflags;
Fabrice MARIE8a5eb6d2001-05-05 21:37:47 +0000139 unsigned int used;
Harald Welte3efb6ea2001-08-06 18:50:21 +0000140#ifdef NO_SHARED_LIBS
141 unsigned int loaded; /* simulate loading so options are merged properly */
142#endif
Rusty Russell79dee072000-05-02 16:45:16 +0000143};
144
Harald Weltea8658ca2003-03-05 07:46:15 +0000145extern int line;
146
Rusty Russell79dee072000-05-02 16:45:16 +0000147/* Your shared library should call one of these. */
148extern void register_match6(struct ip6tables_match *me);
149extern void register_target6(struct ip6tables_target *me);
150
Phil Oester58179b12006-07-20 17:00:19 +0000151extern int service_to_port(const char *name, const char *proto);
Phil Oesterdbac8ad2006-07-20 17:01:54 +0000152extern u_int16_t parse_port(const char *port, const char *proto);
Rusty Russell79dee072000-05-02 16:45:16 +0000153extern int do_command6(int argc, char *argv[], char **table,
154 ip6tc_handle_t *handle);
155/* Keeping track of external matches and targets: linked lists. */
156extern struct ip6tables_match *ip6tables_matches;
157extern struct ip6tables_target *ip6tables_targets;
158
Philip Blundell8c700902000-05-15 02:17:52 +0000159enum ip6t_tryload {
160 DONT_LOAD,
Jones Desougif5b86e62005-12-22 03:33:50 +0000161 DURING_LOAD,
Philip Blundell8c700902000-05-15 02:17:52 +0000162 TRY_LOAD,
163 LOAD_MUST_SUCCEED
164};
165
Fabrice MARIE8a5eb6d2001-05-05 21:37:47 +0000166extern struct ip6tables_target *find_target(const char *name, enum ip6t_tryload);
Martin Josefsson69ac0e02004-02-02 20:02:10 +0000167extern struct ip6tables_match *find_match(const char *name, enum ip6t_tryload, struct ip6tables_rule_match **match);
András Kis-Szabó764316a2001-02-26 17:31:20 +0000168
Yasuyuki KOZAKAI9867e812005-06-22 12:24:21 +0000169extern void parse_interface(const char *arg, char *vianame, unsigned char *mask);
170
András Kis-Szabó764316a2001-02-26 17:31:20 +0000171extern int for_each_chain(int (*fn)(const ip6t_chainlabel, int, ip6tc_handle_t *), int verbose, int builtinstoo, ip6tc_handle_t *handle);
172extern int flush_entries(const ip6t_chainlabel chain, int verbose, ip6tc_handle_t *handle);
173extern int delete_chain(const ip6t_chainlabel chain, int verbose, ip6tc_handle_t *handle);
Harald Welte58918652001-06-16 18:25:25 +0000174extern int ip6tables_insmod(const char *modname, const char *modprobe);
Yasuyuki KOZAKAI740d7272006-11-13 05:09:16 +0000175extern int load_ip6tables_ko(const char *modprobe);
András Kis-Szabó764316a2001-02-26 17:31:20 +0000176
Rusty Russell79dee072000-05-02 16:45:16 +0000177#endif /*_IP6TABLES_USER_H*/