netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nepenthes Development Team <nepenthesdev@gmail.com>
To: netfilter-devel@vger.kernel.org
Subject: socket match - add wildcard option [3/4]
Date: Sun, 25 Jul 2010 16:51:09 +0200	[thread overview]
Message-ID: <AANLkTik6Y6Sdnd7Ce-jEQGoa8S7ew0H+HHTz6pc5uW9J@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 89 bytes --]

iptables-socket-match-add-wildcard-option.diff
  - add wildcard option to socket match

[-- Attachment #2: iptables-socket-match-add-wildcard-option.diff --]
[-- Type: text/x-diff, Size: 2559 bytes --]

diff --git a/extensions/libxt_socket.c b/extensions/libxt_socket.c
index 2230a93..f7f5c3c 100644
--- a/extensions/libxt_socket.c
+++ b/extensions/libxt_socket.c
@@ -16,11 +16,14 @@ static void socket_mt_help_v0(void)
 static void socket_mt_help_v1(void)
 {
 	printf("socket match options:\n"
-"--transparent      Matches only if the socket's transparent option is set\n");
+"--transparent      Matches only if the socket's transparent option is set\n"
+"--wildcard         Match wildcard socket's too\n"
+);
 }
 
 static const struct option socket_opts_v1[] = {
 	{ "transparent", 0, NULL, '1' },
+	{ "wildcard",    0, NULL, '2' },
 	{ }
 };
 
@@ -39,11 +42,18 @@ static int socket_mt_parse_v1(int c, char **argv, int invert,
 
 	switch (c) {
 	case '1':
-		if (*flags)
+		if (*flags & XT_SOCKET_TRANSPARENT)
 			xtables_error(PARAMETER_PROBLEM,
 				      "Can't specify multiple --transparent");
 		info->flags |= XT_SOCKET_TRANSPARENT;
-		*flags = 1;
+		*flags |= XT_SOCKET_TRANSPARENT;
+		break;
+	case '2':
+		if (*flags & XT_SOCKET_WILDCARD)
+			xtables_error(PARAMETER_PROBLEM,
+				      "Can't specify multiple --wildcard");
+		info->flags |= XT_SOCKET_WILDCARD;
+		*flags |= XT_SOCKET_WILDCARD;
 		break;
 	default:
 		return 0;
@@ -63,6 +73,9 @@ static void socket_mt_print_v1(const void *ip,
 	printf("socket ");
 	if (info->flags & XT_SOCKET_TRANSPARENT)
 		printf("transparent ");
+	if (info->flags & XT_SOCKET_WILDCARD)
+		printf("wildcard ");
+
 }
 
 static void socket_mt_save_v1(const void *ip,
@@ -72,6 +85,10 @@ static void socket_mt_save_v1(const void *ip,
 
 	if (info->flags & XT_SOCKET_TRANSPARENT)
 		printf("--transparent ");
+
+	if (info->flags & XT_SOCKET_WILDCARD)
+		printf("--wildcard ");
+
 }
 
 static struct xtables_match socket_mt_reg_v0 = {
diff --git a/extensions/libxt_socket.man b/extensions/libxt_socket.man
index edc9d75..9051c7f 100644
--- a/extensions/libxt_socket.man
+++ b/extensions/libxt_socket.man
@@ -4,3 +4,5 @@ packet which doesn\'t listen on the \'any\' IP address (0.0.0.0).
 .BI "\-\-transparent"
 Enables additional check, that the actual socket's transparent socket option
 has to be set.
+.BI "\-\-wildcard"
+Matches sockets listening on the \'any\' IP address (0.0.0.0) too.
diff --git a/include/linux/netfilter/xt_socket.h b/include/linux/netfilter/xt_socket.h
index f6ba866..2127c57 100644
--- a/include/linux/netfilter/xt_socket.h
+++ b/include/linux/netfilter/xt_socket.h
@@ -3,6 +3,7 @@
 
 enum {
 	XT_SOCKET_TRANSPARENT = 1 << 0,
+	XT_SOCKET_WILDCARD = 1 << 1,
 };
 
 struct xt_socket_mtinfo1 {

                 reply	other threads:[~2010-07-25 14:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AANLkTik6Y6Sdnd7Ce-jEQGoa8S7ew0H+HHTz6pc5uW9J@mail.gmail.com \
    --to=nepenthesdev@gmail.com \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).