[PATCH 2/2] expression: fix printing of binary operation

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

 



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@xxxxxxxxxxxxx>
---
 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

--
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