netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: kaber@trash.net
Subject: [PATCH 2/2] expression: fix printing of binary operation
Date: Wed, 15 Jan 2014 12:09:27 +0100	[thread overview]
Message-ID: <1389784167-10198-2-git-send-email-pablo@netfilter.org> (raw)
In-Reply-To: <1389784167-10198-1-git-send-email-pablo@netfilter.org>

This patch adds a special print function for the relational case in
which == is assumed, so it's not printed. It also fixes the output of
binary operations from:

& 0x00000003 0x00000001

to:

and 0x00000003 == 0x00000001

An example output of how thing are left after this patch follows:

% nft list table filter
table ip filter {
        chain output {
                 type filter hook output priority 0;
                 meta mark and 0x00000003 == 0x00000001 counter packets 0 bytes 0
                 meta mark 0x00000003 counter packets 0 bytes 0
        }
}

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 src/expression.c |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/expression.c b/src/expression.c
index 6da5c10..452b0d7 100644
--- a/src/expression.c
+++ b/src/expression.c
@@ -411,7 +411,9 @@ static void binop_expr_print(const struct expr *expr)
 		printf(" %s ", expr_op_symbols[expr->op]);
 	else
 		printf(" ");
+
 	expr_print(expr->right);
+	printf(" ==");
 }
 
 static void binop_expr_clone(struct expr *new, const struct expr *expr)
@@ -447,10 +449,17 @@ struct expr *binop_expr_alloc(const struct location *loc, enum ops op,
 	return expr;
 }
 
+static void relational_expr_print(const struct expr *expr)
+{
+	expr_print(expr->left);
+	printf(" ");
+	expr_print(expr->right);
+}
+
 static const struct expr_ops relational_expr_ops = {
 	.type		= EXPR_RELATIONAL,
 	.name		= "relational",
-	.print		= binop_expr_print,
+	.print		= relational_expr_print,
 	.destroy	= binop_expr_destroy,
 };
 
-- 
1.7.10.4


  reply	other threads:[~2014-01-15 11:10 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-15 11:09 [PATCH 1/2 nft RFC] expression: default to print binary operations using nominal representation Pablo Neira Ayuso
2014-01-15 11:09 ` Pablo Neira Ayuso [this message]
2014-01-15 11:21   ` [PATCH 2/2] expression: fix printing of binary operation Patrick McHardy
2014-01-15 11:25     ` Pablo Neira Ayuso
2014-01-15 11:28       ` Patrick McHardy
2014-01-15 11:27     ` Patrick McHardy
2014-01-15 11:41       ` Pablo Neira Ayuso
2014-01-15 11:49         ` Patrick McHardy
2014-01-15 11:59           ` Pablo Neira Ayuso
2014-01-15 11:18 ` [PATCH 1/2 nft RFC] expression: default to print binary operations using nominal representation Patrick McHardy
2014-01-15 11:32   ` Arturo Borrero Gonzalez
2014-01-15 11:36     ` Patrick McHardy

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=1389784167-10198-2-git-send-email-pablo@netfilter.org \
    --to=pablo@netfilter.org \
    --cc=kaber@trash.net \
    --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).