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