blob: 1ddd8712437f18b6aaa2e9455624cacd98e20668 [file] [log] [blame]
Marc Bouchere6869a82000-03-20 06:03:29 +00001#ifndef _IPTABLES_USER_H
2#define _IPTABLES_USER_H
3
4#include "libiptc/libiptc.h"
5
6/* Include file for additions: new matches and targets. */
7struct iptables_match
8{
9 struct iptables_match *next;
10
11 ipt_chainlabel name;
12
13 const char *version;
14
15 /* Size of match data. */
16 size_t size;
17
Rusty Russelledf14cf2000-04-19 11:26:44 +000018 /* Size of match data relevent for userspace comparison purposes */
19 size_t userspacesize;
20
Marc Bouchere6869a82000-03-20 06:03:29 +000021 /* Function which prints out usage message. */
22 void (*help)(void);
23
24 /* Initialize the match. */
25 void (*init)(struct ipt_entry_match *m, unsigned int *nfcache);
26
27 /* Function which parses command options; returns true if it
28 ate an option */
29 int (*parse)(int c, char **argv, int invert, unsigned int *flags,
30 const struct ipt_entry *entry,
31 unsigned int *nfcache,
32 struct ipt_entry_match **match);
33
34 /* Final check; exit if not ok. */
35 void (*final_check)(unsigned int flags);
36
37 /* Prints out the match iff non-NULL: put space at end */
38 void (*print)(const struct ipt_ip *ip,
39 const struct ipt_entry_match *match, int numeric);
40
41 /* Saves the union ipt_matchinfo in parsable form to stdout. */
42 void (*save)(const struct ipt_ip *ip,
43 const struct ipt_entry_match *match);
44
45 /* Pointer to list of extra command-line options */
46 struct option *extra_opts;
47
48 /* Ignore these men behind the curtain: */
49 unsigned int option_offset;
50 struct ipt_entry_match *m;
51 unsigned int mflags;
52};
53
54struct iptables_target
55{
56 struct iptables_target *next;
57
58 ipt_chainlabel name;
59
60 const char *version;
61
62 /* Size of target data. */
63 size_t size;
64
Rusty Russelledf14cf2000-04-19 11:26:44 +000065 /* Size of target data relevent for userspace comparison purposes */
66 size_t userspacesize;
67
Marc Bouchere6869a82000-03-20 06:03:29 +000068 /* Function which prints out usage message. */
69 void (*help)(void);
70
71 /* Initialize the target. */
72 void (*init)(struct ipt_entry_target *t, unsigned int *nfcache);
73
74 /* Function which parses command options; returns true if it
75 ate an option */
76 int (*parse)(int c, char **argv, int invert, unsigned int *flags,
77 const struct ipt_entry *entry,
78 struct ipt_entry_target **target);
79
80 /* Final check; exit if not ok. */
81 void (*final_check)(unsigned int flags);
82
83 /* Prints out the target iff non-NULL: put space at end */
84 void (*print)(const struct ipt_ip *ip,
85 const struct ipt_entry_target *target, int numeric);
86
87 /* Saves the targinfo in parsable form to stdout. */
88 void (*save)(const struct ipt_ip *ip,
89 const struct ipt_entry_target *target);
90
91 /* Pointer to list of extra command-line options */
92 struct option *extra_opts;
93
94 /* Ignore these men behind the curtain: */
95 unsigned int option_offset;
96 struct ipt_entry_target *t;
97 unsigned int tflags;
98};
99
100/* Your shared library should call one of these. */
101extern void register_match(struct iptables_match *me);
102extern void register_target(struct iptables_target *me);
103
104/* Functions we share */
105enum exittype {
106 OTHER_PROBLEM = 1,
107 PARAMETER_PROBLEM,
108 VERSION_PROBLEM
109};
110extern void exit_printhelp() __attribute__((noreturn));
111extern void exit_tryhelp(int) __attribute__((noreturn));
112int check_inverse(const char option[], int *invert);
113extern int string_to_number(const char *, int, int);
114void exit_error(enum exittype, char *, ...)__attribute__((noreturn,
115 format(printf,2,3)));
116extern char *addr_to_dotted(const struct in_addr *addrp);
117struct in_addr *dotted_to_addr(const char *dotted);
118extern const char *program_name, *program_version;
119
120extern int do_command(int argc, char *argv[], char **table,
121 iptc_handle_t *handle);
122/* Keeping track of external matches and targets: linked lists. */
123extern struct iptables_match *iptables_matches;
124extern struct iptables_target *iptables_targets;
125
126extern struct iptables_target *find_target(const char *name, int tryload);
127extern struct iptables_match *find_match(const char *name, int tryload);
128#endif /*_IPTABLES_USER_H*/