blob: e711982ceaac60b510043e1110361edbef29a005 [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
Martin Josefsson69ac0e02004-02-02 20:02:10 +000018struct ip6tables_rule_match
19{
20 struct ip6tables_rule_match *next;
21
22 struct ip6tables_match *match;
Joszef Kadlecsika258ad72006-03-03 09:36:50 +000023
24 /* Multiple matches of the same type: the ones before
25 the current one are completed from parsing point of view */
26 unsigned int completed;
Martin Josefsson69ac0e02004-02-02 20:02:10 +000027};
28
Rusty Russell79dee072000-05-02 16:45:16 +000029/* Include file for additions: new matches and targets. */
30struct ip6tables_match
31{
32 struct ip6tables_match *next;
33
34 ip6t_chainlabel name;
35
36 const char *version;
37
38 /* Size of match data. */
39 size_t size;
40
Philip Blundell8c700902000-05-15 02:17:52 +000041 /* Size of match data relevent for userspace comparison purposes */
42 size_t userspacesize;
43
Rusty Russell79dee072000-05-02 16:45:16 +000044 /* Function which prints out usage message. */
45 void (*help)(void);
46
47 /* Initialize the match. */
48 void (*init)(struct ip6t_entry_match *m, unsigned int *nfcache);
49
50 /* Function which parses command options; returns true if it
51 ate an option */
52 int (*parse)(int c, char **argv, int invert, unsigned int *flags,
53 const struct ip6t_entry *entry,
54 unsigned int *nfcache,
55 struct ip6t_entry_match **match);
56
57 /* Final check; exit if not ok. */
58 void (*final_check)(unsigned int flags);
59
60 /* Prints out the match iff non-NULL: put space at end */
61 void (*print)(const struct ip6t_ip6 *ip,
62 const struct ip6t_entry_match *match, int numeric);
63
64 /* Saves the union ipt_matchinfo in parsable form to stdout. */
65 void (*save)(const struct ip6t_ip6 *ip,
66 const struct ip6t_entry_match *match);
67
68 /* Pointer to list of extra command-line options */
Jan Echternachb6db3312000-08-27 07:39:08 +000069 const struct option *extra_opts;
Rusty Russell79dee072000-05-02 16:45:16 +000070
71 /* Ignore these men behind the curtain: */
72 unsigned int option_offset;
73 struct ip6t_entry_match *m;
74 unsigned int mflags;
Harald Welte3efb6ea2001-08-06 18:50:21 +000075#ifdef NO_SHARED_LIBS
76 unsigned int loaded; /* simulate loading so options are merged properly */
77#endif
Rusty Russell79dee072000-05-02 16:45:16 +000078};
79
80struct ip6tables_target
81{
82 struct ip6tables_target *next;
83
84 ip6t_chainlabel name;
85
86 const char *version;
87
88 /* Size of target data. */
89 size_t size;
90
Philip Blundell8c700902000-05-15 02:17:52 +000091 /* Size of target data relevent for userspace comparison purposes */
92 size_t userspacesize;
93
Rusty Russell79dee072000-05-02 16:45:16 +000094 /* Function which prints out usage message. */
95 void (*help)(void);
96
97 /* Initialize the target. */
98 void (*init)(struct ip6t_entry_target *t, unsigned int *nfcache);
99
100 /* Function which parses command options; returns true if it
101 ate an option */
102 int (*parse)(int c, char **argv, int invert, unsigned int *flags,
103 const struct ip6t_entry *entry,
104 struct ip6t_entry_target **target);
105
106 /* Final check; exit if not ok. */
107 void (*final_check)(unsigned int flags);
108
109 /* Prints out the target iff non-NULL: put space at end */
110 void (*print)(const struct ip6t_ip6 *ip,
111 const struct ip6t_entry_target *target, int numeric);
112
113 /* Saves the targinfo in parsable form to stdout. */
114 void (*save)(const struct ip6t_ip6 *ip,
115 const struct ip6t_entry_target *target);
116
117 /* Pointer to list of extra command-line options */
118 struct option *extra_opts;
119
120 /* Ignore these men behind the curtain: */
121 unsigned int option_offset;
122 struct ip6t_entry_target *t;
123 unsigned int tflags;
Fabrice MARIE8a5eb6d2001-05-05 21:37:47 +0000124 unsigned int used;
Harald Welte3efb6ea2001-08-06 18:50:21 +0000125#ifdef NO_SHARED_LIBS
126 unsigned int loaded; /* simulate loading so options are merged properly */
127#endif
Rusty Russell79dee072000-05-02 16:45:16 +0000128};
129
Harald Weltea8658ca2003-03-05 07:46:15 +0000130extern int line;
131
Rusty Russell79dee072000-05-02 16:45:16 +0000132/* Your shared library should call one of these. */
133extern void register_match6(struct ip6tables_match *me);
134extern void register_target6(struct ip6tables_target *me);
135
Phil Oester58179b12006-07-20 17:00:19 +0000136extern int service_to_port(const char *name, const char *proto);
Rusty Russell79dee072000-05-02 16:45:16 +0000137extern int do_command6(int argc, char *argv[], char **table,
138 ip6tc_handle_t *handle);
139/* Keeping track of external matches and targets: linked lists. */
140extern struct ip6tables_match *ip6tables_matches;
141extern struct ip6tables_target *ip6tables_targets;
142
Philip Blundell8c700902000-05-15 02:17:52 +0000143enum ip6t_tryload {
144 DONT_LOAD,
Jones Desougif5b86e62005-12-22 03:33:50 +0000145 DURING_LOAD,
Philip Blundell8c700902000-05-15 02:17:52 +0000146 TRY_LOAD,
147 LOAD_MUST_SUCCEED
148};
149
Fabrice MARIE8a5eb6d2001-05-05 21:37:47 +0000150extern struct ip6tables_target *find_target(const char *name, enum ip6t_tryload);
Martin Josefsson69ac0e02004-02-02 20:02:10 +0000151extern 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 +0000152
Yasuyuki KOZAKAI9867e812005-06-22 12:24:21 +0000153extern void parse_interface(const char *arg, char *vianame, unsigned char *mask);
154
András Kis-Szabó764316a2001-02-26 17:31:20 +0000155extern int for_each_chain(int (*fn)(const ip6t_chainlabel, int, ip6tc_handle_t *), int verbose, int builtinstoo, ip6tc_handle_t *handle);
156extern int flush_entries(const ip6t_chainlabel chain, int verbose, ip6tc_handle_t *handle);
157extern int delete_chain(const ip6t_chainlabel chain, int verbose, ip6tc_handle_t *handle);
Harald Welte58918652001-06-16 18:25:25 +0000158extern int ip6tables_insmod(const char *modname, const char *modprobe);
András Kis-Szabó764316a2001-02-26 17:31:20 +0000159
Rusty Russell79dee072000-05-02 16:45:16 +0000160#endif /*_IP6TABLES_USER_H*/