1 /* Shared library add-on to iptables to add TCPMSS target support.
3 * Copyright (c) 2000 Marc Boucher
10 #include <ip6tables.h>
11 #include <linux/netfilter_ipv6/ip6_tables.h>
12 #include <linux/netfilter_ipv6/ip6t_TCPMSS.h>
15 struct ip6t_entry_target t;
16 struct ip6t_tcpmss_info mss;
19 /* Function which prints out usage message. */
24 "TCPMSS target v%s mutually-exclusive options:\n"
25 " --set-mss value explicitly set MSS option to specified value\n"
26 " --clamp-mss-to-pmtu automatically clamp MSS value to (path_MTU - 60)\n",
30 static struct option opts[] = {
31 { "set-mss", 1, 0, '1' },
32 { "clamp-mss-to-pmtu", 0, 0, '2' },
36 /* Initialize the target. */
38 init(struct ip6t_entry_target *t, unsigned int *nfcache)
42 /* Function which parses command options; returns true if it
45 parse(int c, char **argv, int invert, unsigned int *flags,
46 const struct ip6t_entry *entry,
47 struct ip6t_entry_target **target)
49 struct ip6t_tcpmss_info *mssinfo
50 = (struct ip6t_tcpmss_info *)(*target)->data;
57 exit_error(PARAMETER_PROBLEM,
58 "TCPMSS target: Only one option may be specified");
59 if (string_to_number(optarg, 0, 65535 - 60, &mssval) == -1)
60 exit_error(PARAMETER_PROBLEM, "Bad TCPMSS value `%s'", optarg);
62 mssinfo->mss = mssval;
68 exit_error(PARAMETER_PROBLEM,
69 "TCPMSS target: Only one option may be specified");
70 mssinfo->mss = IP6T_TCPMSS_CLAMP_PMTU;
82 final_check(unsigned int flags)
85 exit_error(PARAMETER_PROBLEM,
86 "TCPMSS target: At least one parameter is required");
89 /* Prints out the targinfo. */
91 print(const struct ip6t_ip6 *ip6,
92 const struct ip6t_entry_target *target,
95 const struct ip6t_tcpmss_info *mssinfo =
96 (const struct ip6t_tcpmss_info *)target->data;
97 if(mssinfo->mss == IP6T_TCPMSS_CLAMP_PMTU)
98 printf("TCPMSS clamp to PMTU ");
100 printf("TCPMSS set %u ", mssinfo->mss);
103 /* Saves the union ip6t_targinfo in parsable form to stdout. */
105 save(const struct ip6t_ip6 *ip, const struct ip6t_entry_target *target)
107 const struct ip6t_tcpmss_info *mssinfo =
108 (const struct ip6t_tcpmss_info *)target->data;
110 if(mssinfo->mss == IP6T_TCPMSS_CLAMP_PMTU)
111 printf("--clamp-mss-to-pmtu ");
113 printf("--set-mss %u ", mssinfo->mss);
116 static struct ip6tables_target mss = {
119 .version = IPTABLES_VERSION,
120 .size = IP6T_ALIGN(sizeof(struct ip6t_tcpmss_info)),
121 .userspacesize = IP6T_ALIGN(sizeof(struct ip6t_tcpmss_info)),
125 .final_check = &final_check,
133 register_target6(&mss);