From patchwork Fri Jun 5 15:31:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pablo Neira Ayuso X-Patchwork-Id: 481403 X-Patchwork-Delegate: pablo@netfilter.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 1FCA21401DE for ; Sat, 6 Jun 2015 01:27:12 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754918AbbFEP1K (ORCPT ); Fri, 5 Jun 2015 11:27:10 -0400 Received: from mail.us.es ([193.147.175.20]:58201 "EHLO mail.us.es" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754628AbbFEP1G (ORCPT ); Fri, 5 Jun 2015 11:27:06 -0400 Received: (qmail 24375 invoked from network); 5 Jun 2015 17:27:05 +0200 Received: from unknown (HELO us.es) (192.168.2.12) by us.es with SMTP; 5 Jun 2015 17:27:05 +0200 Received: (qmail 32195 invoked by uid 507); 5 Jun 2015 15:27:05 -0000 X-Qmail-Scanner-Diagnostics: from 127.0.0.1 by antivirus2 (envelope-from , uid 501) with qmail-scanner-2.10 (clamdscan: 0.98.7/20551. spamassassin: 3.4.0. Clear:RC:1(127.0.0.1):SA:0(-103.2/7.5):. Processed in 3.100442 secs); 05 Jun 2015 15:27:05 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on antivirus2 X-Spam-Level: X-Spam-Status: No, score=-103.2 required=7.5 tests=BAYES_50,SMTPAUTH_US, USER_IN_WHITELIST autolearn=disabled version=3.4.0 X-Spam-ASN: AS12715 87.216.0.0/16 X-Envelope-From: pablo@netfilter.org Received: from unknown (HELO antivirus2) (127.0.0.1) by us.es with SMTP; 5 Jun 2015 15:27:01 -0000 Received: from 192.168.1.13 (192.168.1.13) by antivirus2 (F-Secure/fsigk_smtp/412/antivirus2); Fri, 05 Jun 2015 17:27:01 +0200 (CEST) X-Virus-Status: clean(F-Secure/fsigk_smtp/412/antivirus2) Received: (qmail 18129 invoked from network); 5 Jun 2015 17:27:01 +0200 Received: from 77.166.216.87.static.jazztel.es (HELO salvia.here) (pneira@us.es@87.216.166.77) by mail.us.es with SMTP; 5 Jun 2015 17:27:01 +0200 From: Pablo Neira Ayuso To: netfilter-devel@vger.kernel.org Cc: kaber@trash.net Subject: [PATCH nft 1/2] datatype: default to display bitmask in hexadecimal Date: Fri, 5 Jun 2015 17:31:56 +0200 Message-Id: <1433518317-9901-1-git-send-email-pablo@netfilter.org> X-Mailer: git-send-email 1.7.10.4 Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org Instead of a plain integer. This updates integer_type_print() to look up some basefmt in the change of datatype, the first we find will be used to format the output. Signed-off-by: Pablo Neira Ayuso --- src/datatype.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/datatype.c b/src/datatype.c index f93337b..82a7753 100644 --- a/src/datatype.c +++ b/src/datatype.c @@ -260,15 +260,22 @@ const struct datatype bitmask_type = { .type = TYPE_BITMASK, .name = "bitmask", .desc = "bitmask", + .basefmt = "0x%Zx", .basetype = &integer_type, }; static void integer_type_print(const struct expr *expr) { + const struct datatype *dtype = expr->dtype; const char *fmt = "%Zu"; - if (expr->dtype->basefmt != NULL) - fmt = expr->dtype->basefmt; + do { + if (dtype->basefmt != NULL) { + fmt = dtype->basefmt; + break; + } + } while ((dtype = dtype->basetype)); + gmp_printf(fmt, expr->value); }