blob: d4dadd881f85452093351eb6969c6545f3bf25e9 [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
Martin Josefsson69ac0e02004-02-02 20:02:10 +000011struct ip6tables_rule_match
12{
13 struct ip6tables_rule_match *next;
14
15 struct ip6tables_match *match;
16};
17
Rusty Russell79dee072000-05-02 16:45:16 +000018/* Include file for additions: new matches and targets. */
19struct ip6tables_match
20{
21 struct ip6tables_match *next;
22
23 ip6t_chainlabel name;
24
25 const char *version;
26
27 /* Size of match data. */
28 size_t size;
29
Philip Blundell8c700902000-05-15 02:17:52 +000030 /* Size of match data relevent for userspace comparison purposes */
31 size_t userspacesize;
32
Rusty Russell79dee072000-05-02 16:45:16 +000033 /* Function which prints out usage message. */
34 void (*help)(void);
35
36 /* Initialize the match. */
37 void (*init)(struct ip6t_entry_match *m, unsigned int *nfcache);
38
39 /* Function which parses command options; returns true if it
40 ate an option */
41 int (*parse)(int c, char **argv, int invert, unsigned int *flags,
42 const struct ip6t_entry *entry,
43 unsigned int *nfcache,
44 struct ip6t_entry_match **match);
45
46 /* Final check; exit if not ok. */
47 void (*final_check)(unsigned int flags);
48
49 /* Prints out the match iff non-NULL: put space at end */
50 void (*print)(const struct ip6t_ip6 *ip,
51 const struct ip6t_entry_match *match, int numeric);
52
53 /* Saves the union ipt_matchinfo in parsable form to stdout. */
54 void (*save)(const struct ip6t_ip6 *ip,
55 const struct ip6t_entry_match *match);
56
57 /* Pointer to list of extra command-line options */
Jan Echternachb6db3312000-08-27 07:39:08 +000058 const struct option *extra_opts;
Rusty Russell79dee072000-05-02 16:45:16 +000059
60 /* Ignore these men behind the curtain: */
61 unsigned int option_offset;
62 struct ip6t_entry_match *m;
63 unsigned int mflags;
Harald Welte3efb6ea2001-08-06 18:50:21 +000064#ifdef NO_SHARED_LIBS
65 unsigned int loaded; /* simulate loading so options are merged properly */
66#endif
Rusty Russell79dee072000-05-02 16:45:16 +000067};
68
69struct ip6tables_target
70{
71 struct ip6tables_target *next;
72
73 ip6t_chainlabel name;
74
75 const char *version;
76
77 /* Size of target data. */
78 size_t size;
79
Philip Blundell8c700902000-05-15 02:17:52 +000080 /* Size of target data relevent for userspace comparison purposes */
81 size_t userspacesize;
82
Rusty Russell79dee072000-05-02 16:45:16 +000083 /* Function which prints out usage message. */
84 void (*help)(void);
85
86 /* Initialize the target. */
87 void (*init)(struct ip6t_entry_target *t, unsigned int *nfcache);
88
89 /* Function which parses command options; returns true if it
90 ate an option */
91 int (*parse)(int c, char **argv, int invert, unsigned int *flags,
92 const struct ip6t_entry *entry,
93 struct ip6t_entry_target **target);
94
95 /* Final check; exit if not ok. */
96 void (*final_check)(unsigned int flags);
97
98 /* Prints out the target iff non-NULL: put space at end */
99 void (*print)(const struct ip6t_ip6 *ip,
100 const struct ip6t_entry_target *target, int numeric);
101
102 /* Saves the targinfo in parsable form to stdout. */
103 void (*save)(const struct ip6t_ip6 *ip,
104 const struct ip6t_entry_target *target);
105
106 /* Pointer to list of extra command-line options */
107 struct option *extra_opts;
108
109 /* Ignore these men behind the curtain: */
110 unsigned int option_offset;
111 struct ip6t_entry_target *t;
112 unsigned int tflags;
Fabrice MARIE8a5eb6d2001-05-05 21:37:47 +0000113 unsigned int used;
Harald Welte3efb6ea2001-08-06 18:50:21 +0000114#ifdef NO_SHARED_LIBS
115 unsigned int loaded; /* simulate loading so options are merged properly */
116#endif
Rusty Russell79dee072000-05-02 16:45:16 +0000117};
118
Harald Weltea8658ca2003-03-05 07:46:15 +0000119extern int line;
120
Rusty Russell79dee072000-05-02 16:45:16 +0000121/* Your shared library should call one of these. */
122extern void register_match6(struct ip6tables_match *me);
123extern void register_target6(struct ip6tables_target *me);
124
125extern int do_command6(int argc, char *argv[], char **table,
126 ip6tc_handle_t *handle);
127/* Keeping track of external matches and targets: linked lists. */
128extern struct ip6tables_match *ip6tables_matches;
129extern struct ip6tables_target *ip6tables_targets;
130
Philip Blundell8c700902000-05-15 02:17:52 +0000131enum ip6t_tryload {
132 DONT_LOAD,
133 TRY_LOAD,
134 LOAD_MUST_SUCCEED
135};
136
Fabrice MARIE8a5eb6d2001-05-05 21:37:47 +0000137extern struct ip6tables_target *find_target(const char *name, enum ip6t_tryload);
Martin Josefsson69ac0e02004-02-02 20:02:10 +0000138extern 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 +0000139
140extern int for_each_chain(int (*fn)(const ip6t_chainlabel, int, ip6tc_handle_t *), int verbose, int builtinstoo, ip6tc_handle_t *handle);
141extern int flush_entries(const ip6t_chainlabel chain, int verbose, ip6tc_handle_t *handle);
142extern int delete_chain(const ip6t_chainlabel chain, int verbose, ip6tc_handle_t *handle);
Harald Welte58918652001-06-16 18:25:25 +0000143extern int ip6tables_insmod(const char *modname, const char *modprobe);
András Kis-Szabó764316a2001-02-26 17:31:20 +0000144
Rusty Russell79dee072000-05-02 16:45:16 +0000145#endif /*_IP6TABLES_USER_H*/