1 /* Shared library add-on to iptables to add MARK target support. */
8 #include <linux/netfilter_ipv6/ip6_tables.h>
9 #include <linux/netfilter_ipv6/ip6t_MARK.h>
11 /* Function which prints out usage message. */
16 "MARK target v%s options:\n"
17 " --set-mark value Set nfmark value\n"
22 static struct option opts[] = {
23 { .name = "set-mark", .has_arg = 1, .flag = 0, .val = '1' },
27 /* Initialize the target. */
29 init(struct ip6t_entry_target *t, unsigned int *nfcache)
33 /* Function which parses command options; returns true if it
36 parse(int c, char **argv, int invert, unsigned int *flags,
37 const struct ip6t_entry *entry,
38 struct ip6t_entry_target **target)
40 struct ip6t_mark_target_info *markinfo
41 = (struct ip6t_mark_target_info *)(*target)->data;
46 markinfo->mark = strtoul(optarg, &end, 0);
47 if (*end != '\0' || end == optarg)
48 exit_error(PARAMETER_PROBLEM, "Bad MARK value `%s'", optarg);
50 exit_error(PARAMETER_PROBLEM,
51 "MARK target: Can't specify --set-mark twice");
63 final_check(unsigned int flags)
66 exit_error(PARAMETER_PROBLEM,
67 "MARK target: Parameter --set-mark is required");
70 /* Prints out the targinfo. */
72 print(const struct ip6t_ip6 *ip,
73 const struct ip6t_entry_target *target,
76 const struct ip6t_mark_target_info *markinfo =
77 (const struct ip6t_mark_target_info *)target->data;
79 printf("MARK set 0x%lx ", markinfo->mark);
82 /* Saves the union ipt_targinfo in parsable form to stdout. */
84 save(const struct ip6t_ip6 *ip, const struct ip6t_entry_target *target)
86 const struct ip6t_mark_target_info *markinfo =
87 (const struct ip6t_mark_target_info *)target->data;
89 printf("--set-mark 0x%lx ", markinfo->mark);
93 struct ip6tables_target mark = {
95 .version = IPTABLES_VERSION,
96 .size = IP6T_ALIGN(sizeof(struct ip6t_mark_target_info)),
97 .userspacesize = IP6T_ALIGN(sizeof(struct ip6t_mark_target_info)),
101 .final_check = &final_check,
109 register_target6(&mark);