1 /* Shared library add-on to iptables to add MARK target support. */
8 #include <linux/netfilter_ipv6/ip6_tables.h>
9 /* For 64bit kernel / 32bit userspace */
10 #include "../include/linux/netfilter_ipv6/ip6t_MARK.h"
12 /* Function which prints out usage message. */
17 "MARK target v%s options:\n"
18 " --set-mark value Set nfmark value\n"
23 static struct option opts[] = {
24 { .name = "set-mark", .has_arg = 1, .flag = 0, .val = '1' },
28 /* Initialize the target. */
30 init(struct ip6t_entry_target *t, unsigned int *nfcache)
34 /* Function which parses command options; returns true if it
37 parse(int c, char **argv, int invert, unsigned int *flags,
38 const struct ip6t_entry *entry,
39 struct ip6t_entry_target **target)
41 struct ip6t_mark_target_info *markinfo
42 = (struct ip6t_mark_target_info *)(*target)->data;
46 #ifdef KERNEL_64_USERSPACE_32
47 if (string_to_number_ll(optarg, 0, 0,
50 if (string_to_number_l(optarg, 0, 0,
53 exit_error(PARAMETER_PROBLEM, "Bad MARK value `%s'", optarg);
55 exit_error(PARAMETER_PROBLEM,
56 "MARK target: Can't specify --set-mark twice");
68 final_check(unsigned int flags)
71 exit_error(PARAMETER_PROBLEM,
72 "MARK target: Parameter --set-mark is required");
75 #ifdef KERNEL_64_USERSPACE_32
77 print_mark(unsigned long long mark)
79 printf("0x%llx ", mark);
83 print_mark(unsigned long mark)
85 printf("0x%lx ", mark);
89 /* Prints out the targinfo. */
91 print(const struct ip6t_ip6 *ip,
92 const struct ip6t_entry_target *target,
95 const struct ip6t_mark_target_info *markinfo =
96 (const struct ip6t_mark_target_info *)target->data;
99 print_mark(markinfo->mark);
102 /* Saves the union ipt_targinfo in parsable form to stdout. */
104 save(const struct ip6t_ip6 *ip, const struct ip6t_entry_target *target)
106 const struct ip6t_mark_target_info *markinfo =
107 (const struct ip6t_mark_target_info *)target->data;
109 printf("--set-mark ");
110 print_mark(markinfo->mark);
114 struct ip6tables_target mark = {
116 .version = IPTABLES_VERSION,
117 .size = IP6T_ALIGN(sizeof(struct ip6t_mark_target_info)),
118 .userspacesize = IP6T_ALIGN(sizeof(struct ip6t_mark_target_info)),
122 .final_check = &final_check,
130 register_target6(&mark);