[PATCH 1/1] TCPOPTSTRIP 20071006 descriptions (iptables)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Oct 6 2007 17:37, Krzysztof Oledzki wrote:
>
>> +struct tcp_optionmap_struct {
>> +	const char *name;
>> +	const int option;
> +	const char *desc;
>> +};
>
>> +static const struct tcp_optionmap_struct tcp_optionmap[] = {
>> +	{"wscale",         TCPOPT_WINDOW},
>> +	{"mss",            TCPOPT_MAXSEG},
>> +	{"sack-permitted", TCPOPT_SACK_PERMITTED},
>> +	{"sack",           TCPOPT_SACK},
>> +	{"timestamp",      TCPOPT_TIMESTAMP},
>> +	{"md5",            TCPOPT_MD5SIG},
>> +	{NULL},
>> +};
>
> We could convert spaces into tabs here, plus:

We should not, because that would break alignment.
When adhering to the indent-is-not-alignment distinction (see the one or
other CodingStyle debate on lkml), people can set their tab width to
their preferred value, while code does not look bad with other tab widths.
Only remaining requirement then is that it fits into 80 when \t width is 8,
which is easy; so the overall situation is a plus.

>> +	{"mss",			TCPOPT_MAXSEG,		"Maximum Segment
>> Size"},
>> +	{"wscale",		TCPOPT_WINDOW,		"Window Scale"},
>> +	{"sack-permitted",	TCPOPT_SACK_PERMITTED,	"SACK Permitted"},
>> +	{"sack",		TCPOPT_SACK,		"SACK"},
>> +	{"timestamp",		TCPOPT_TIMESTAMP,	"Time Stamp"},
>> +	{"md5",			TCPOPT_MD5SIG,		"MD5 Signature"},
>> +	{NULL},

==

The following patch implements option descriptions after a
suggestion by Krzysztof Olędzki. It goes _on top_ of the
afore-posted libxt_TCPOPTSTRIP patch.

== patch begins here ==

Replace the manually typed help by option description fields.

Signed-off-by: Jan Engelhardt <jengelh@xxxxxxxxxxxxxxx>

---
 extensions/libxt_TCPOPTSTRIP.c |   29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)

Index: iptables/extensions/libxt_TCPOPTSTRIP.c
===================================================================
--- iptables.orig/extensions/libxt_TCPOPTSTRIP.c
+++ iptables/extensions/libxt_TCPOPTSTRIP.c
@@ -19,8 +19,8 @@ enum {
 	F_STRIP = 1 << 0,
 };
 
-struct tcp_optionmap_struct {
-	const char *name;
+struct tcp_optionmap {
+	const char *name, *desc;
 	const int option;
 };
 
@@ -29,30 +29,29 @@ static const struct option tcpoptstrip_o
 	{NULL},
 };
 
-static const struct tcp_optionmap_struct tcp_optionmap[] = {
-	{"wscale",         TCPOPT_WINDOW},
-	{"mss",            TCPOPT_MAXSEG},
-	{"sack-permitted", TCPOPT_SACK_PERMITTED},
-	{"sack",           TCPOPT_SACK},
-	{"timestamp",      TCPOPT_TIMESTAMP},
-	{"md5",            TCPOPT_MD5SIG},
+static const struct tcp_optionmap tcp_optionmap[] = {
+	{"wscale",         "Window scale",         TCPOPT_WINDOW},
+	{"mss",            "Maximum Segment Size", TCPOPT_MAXSEG},
+	{"sack-permitted", "SACK permitted",       TCPOPT_SACK_PERMITTED},
+	{"sack",           "Selective ACK",        TCPOPT_SACK},
+	{"timestamp",      "Timestamp",            TCPOPT_TIMESTAMP},
+	{"md5",            "MD5 signature",        TCPOPT_MD5SIG},
 	{NULL},
 };
 
 static void tcpoptstrip_help(void)
 {
+	const struct tcp_optionmap *w;
+
 	printf(
 "TCPOPTSTRIP target options:\n"
 "  --strip-options value     strip specified TCP options denoted by value\n"
 "                            (separated by comma) from TCP header\n"
 "  Instead of the numeric value, you can also use the following names:\n"
-"    mss               strip MSS option\n"
-"    wscale            strip window scaling option\n"
-"    sack-permitted    strip \"SACK permitted\" option\n"
-"    sack              strip SACK option\n"
-"    timestamp         strip timestamp option\n"
-"    md5               strip MD5 signature option (RFC2385)\n"
 	);
+
+	for (w = tcp_optionmap; w->name != NULL; ++w)
+		printf("    %-14s    strip \"%s\" option\n", w->name, w->desc);
 }
 
 static void tcpoptstrip_init(struct xt_entry_target *t)
-
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux