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 /* Function which parses command options; returns true if it
30 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
)
35 struct ipt_helper_info
*info
= (struct ipt_helper_info
*)(*match
)->data
;
40 exit_error(PARAMETER_PROBLEM
,
41 "helper match: Only use --helper ONCE!");
42 check_inverse(optarg
, &invert
, &invert
, 0);
43 strncpy(info
->name
, optarg
, 29);
44 info
->name
[29] = '\0';
56 /* Final check; must have specified --helper. */
58 final_check(unsigned int flags
)
61 exit_error(PARAMETER_PROBLEM
,
62 "helper match: You must specify `--helper'");
65 /* Prints out the info. */
67 print(const struct ipt_ip
*ip
,
68 const struct ipt_entry_match
*match
,
71 struct ipt_helper_info
*info
= (struct ipt_helper_info
*)match
->data
;
73 printf("helper match %s\"%s\" ", info
->invert
? "! " : "", info
->name
);
76 /* Saves the union ipt_info in parsable form to stdout. */
78 save(const struct ipt_ip
*ip
, const struct ipt_entry_match
*match
)
80 struct ipt_helper_info
*info
= (struct ipt_helper_info
*)match
->data
;
82 printf("%s--helper \"%s\" ",info
->invert
? "! " : "", info
->name
);
85 static struct iptables_match helper
= {
88 .version
= IPTABLES_VERSION
,
89 .size
= IPT_ALIGN(sizeof(struct ipt_helper_info
)),
92 .final_check
= &final_check
,
100 register_match(&helper
);