1 /* Shared library add-on to iptables to add related packet matching support. */
9 #include <linux/netfilter/xt_helper.h>
11 static void helper_help(void)
14 "helper match options:\n"
15 "[!] --helper string Match helper identified by string\n");
18 static const struct option helper_opts[] = {
19 { "helper", 1, NULL, '1' },
24 helper_parse(int c, char **argv, int invert, unsigned int *flags,
25 const void *entry, struct xt_entry_match **match)
27 struct xt_helper_info *info = (struct xt_helper_info *)(*match)->data;
32 xtables_error(PARAMETER_PROBLEM,
33 "helper match: Only use --helper ONCE!");
34 xtables_check_inverse(optarg, &invert, &optind, 0, argv);
35 strncpy(info->name, optarg, 29);
36 info->name[29] = '\0';
48 static void helper_check(unsigned int flags)
51 xtables_error(PARAMETER_PROBLEM,
52 "helper match: You must specify `--helper'");
56 helper_print(const void *ip, const struct xt_entry_match *match, int numeric)
58 const struct xt_helper_info *info = (const void *)match->data;
60 printf("helper match %s\"%s\" ", info->invert ? "! " : "", info->name);
63 static void helper_save(const void *ip, const struct xt_entry_match *match)
65 const struct xt_helper_info *info = (const void *)match->data;
67 printf("%s--helper ",info->invert ? "! " : "");
68 xtables_save_string(info->name);
71 static struct xtables_match helper_match = {
72 .family = NFPROTO_UNSPEC,
74 .version = XTABLES_VERSION,
75 .size = XT_ALIGN(sizeof(struct xt_helper_info)),
77 .parse = helper_parse,
78 .final_check = helper_check,
79 .print = helper_print,
81 .extra_opts = helper_opts,
86 xtables_register_match(&helper_match);