All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Schwendt <rh0209ms@arcor.de>
To: netfilter-devel@lists.netfilter.org
Cc: Harald Welte <laforge@gnumonks.org>
Subject: Re: [PATCH] save inverted MAC match
Date: Thu, 12 Dec 2002 18:27:14 +0100	[thread overview]
Message-ID: <20021212182714.47791aa0.rh0209ms@arcor.de> (raw)
In-Reply-To: <20021114234340.59dbc60a.rh0209ms@arcor.de>

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

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

In CVS, only the IPv4 code has been fixed. Hopefully this was the
last "missing space in saved rules" bug.

The patch is for current CVS codebase, both IPv6 and IPv4.

It's a bit longer again because it tidies up save() as used by
iptables-save without adding white-space in print() as used by
iptables -L.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)

iD8DBQE9+Mby0iMVcrivHFQRAprxAJ4viAlVrnJ9O+78kO+tKOO7XXgu7QCcCdbX
U8auSUapy/8PJFzbW1I95cQ=
=9r4z
-----END PGP SIGNATURE-----

[-- Attachment #2: iptables-CVS-invertmac.patch --]
[-- Type: application/octet-stream, Size: 2876 bytes --]

Add missing space in front of inverted MAC match upon saving rules,
but not upon printing rules.

diff -Naur iptables-CVS-orig/extensions/libip6t_mac.c iptables-CVS/extensions/libip6t_mac.c
--- iptables-CVS-orig/extensions/libip6t_mac.c	Thu Dec 12 17:52:50 2002
+++ iptables-CVS/extensions/libip6t_mac.c	Thu Dec 12 18:16:37 2002
@@ -86,11 +86,11 @@
 	return 1;
 }
 
-static void print_mac(unsigned char macaddress[ETH_ALEN], int invert)
+static void print_mac(unsigned char macaddress[ETH_ALEN])
 {
 	unsigned int i;
 
-	printf("%s%02X", invert ? "!" : "", macaddress[0]);
+	printf("%02X", macaddress[0]);
 	for (i = 1; i < ETH_ALEN; i++)
 		printf(":%02X", macaddress[i]);
 	printf(" ");
@@ -110,17 +110,23 @@
       const struct ip6t_entry_match *match,
       int numeric)
 {
+	struct ip6t_mac_info *info = (struct ip6t_mac_info *)match->data;
+	
 	printf("MAC ");
-	print_mac(((struct ip6t_mac_info *)match->data)->srcaddr,
-		  ((struct ip6t_mac_info *)match->data)->invert);
+	if ( info->invert )
+		printf("!");
+	print_mac(info->srcaddr);
 }
 
 /* Saves the union ip6t_matchinfo in parsable form to stdout. */
 static void save(const struct ip6t_ip6 *ip, const struct ip6t_entry_match *match)
 {
+	struct ip6t_mac_info *info = (struct ip6t_mac_info *)match->data;
+	
 	printf("--mac-source ");
-	print_mac(((struct ip6t_mac_info *)match->data)->srcaddr,
-		  ((struct ip6t_mac_info *)match->data)->invert);
+	if ( info->invert )
+		printf("! ");
+	print_mac(info->srcaddr);
 }
 
 static
diff -Naur iptables-CVS-orig/extensions/libipt_mac.c iptables-CVS/extensions/libipt_mac.c
--- iptables-CVS-orig/extensions/libipt_mac.c	Thu Dec 12 17:54:07 2002
+++ iptables-CVS/extensions/libipt_mac.c	Thu Dec 12 18:14:51 2002
@@ -86,11 +86,11 @@
 	return 1;
 }
 
-static void print_mac(unsigned char macaddress[ETH_ALEN], int invert)
+static void print_mac(unsigned char macaddress[ETH_ALEN])
 {
 	unsigned int i;
 
-	printf("%s%02X", invert ? "! " : "", macaddress[0]);
+	printf("%02X", macaddress[0]);
 	for (i = 1; i < ETH_ALEN; i++)
 		printf(":%02X", macaddress[i]);
 	printf(" ");
@@ -110,17 +110,23 @@
       const struct ipt_entry_match *match,
       int numeric)
 {
+	struct ipt_mac_info *info = (struct ipt_mac_info *)match->data;
+	
 	printf("MAC ");
-	print_mac(((struct ipt_mac_info *)match->data)->srcaddr,
-		  ((struct ipt_mac_info *)match->data)->invert);
+	if ( info->invert )
+		printf("!");
+	print_mac(info->srcaddr);
 }
 
 /* Saves the union ipt_matchinfo in parsable form to stdout. */
 static void save(const struct ipt_ip *ip, const struct ipt_entry_match *match)
 {
+	struct ipt_mac_info *info = (struct ipt_mac_info *)match->data;
+	
 	printf("--mac-source ");
-	print_mac(((struct ipt_mac_info *)match->data)->srcaddr,
-		  ((struct ipt_mac_info *)match->data)->invert);
+	if ( info->invert )
+		printf("! ");
+	print_mac(info->srcaddr);
 }
 
 static

      reply	other threads:[~2002-12-12 17:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-06 16:21 [PATCH] save inverted MAC match Michael Schwendt
2002-11-14 22:43 ` Michael Schwendt
2002-12-12 17:27   ` Michael Schwendt [this message]

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=20021212182714.47791aa0.rh0209ms@arcor.de \
    --to=rh0209ms@arcor.de \
    --cc=laforge@gnumonks.org \
    --cc=netfilter-devel@lists.netfilter.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.