1 /* Shared library add-on to iptables to add related packet matching support. */
9 #include <linux/netfilter_ipv4/ipt_helper.h>
11 /* Function which prints out usage message. */
16 "helper match v%s options:\n"
17 "[!] --helper string Match helper identified by string\n"
22 static struct option opts[] = {
23 { "helper", 1, 0, '1' },
27 /* Initialize the match. */
29 init(struct ipt_entry_match *m, unsigned int *nfcache)
31 /* Can't cache this. */
32 *nfcache |= NFC_UNKNOWN;
35 /* Function which parses command options; returns true if it
38 parse(int c, char **argv, int invert, unsigned int *flags,
39 const struct ipt_entry *entry,
40 unsigned int *nfcache,
41 struct ipt_entry_match **match)
43 struct ipt_helper_info *info = (struct ipt_helper_info *)(*match)->data;
47 check_inverse(optarg, &invert, &invert, 0);
48 strncpy(info->name, optarg, 29);
60 /* Final check; must have specified --helper. */
62 final_check(unsigned int flags)
65 exit_error(PARAMETER_PROBLEM,
66 "helper match: You must specify `--helper'");
69 /* Prints out the info. */
71 print(const struct ipt_ip *ip,
72 const struct ipt_entry_match *match,
75 struct ipt_helper_info *info = (struct ipt_helper_info *)match->data;
77 printf("helper match %s\"%s\" ", info->invert ? "! " : "", info->name);
80 /* Saves the union ipt_info in parsable form to stdout. */
82 save(const struct ipt_ip *ip, const struct ipt_entry_match *match)
84 struct ipt_helper_info *info = (struct ipt_helper_info *)match->data;
86 printf("%s--helper \"%s\" ",info->invert ? "! " : "", info->name);
90 struct iptables_match helper
94 IPT_ALIGN(sizeof(struct ipt_helper_info)),
95 IPT_ALIGN(sizeof(struct ipt_helper_info)),
107 register_match(&helper);