From patchwork Thu Aug 15 23:24:11 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil Oester X-Patchwork-Id: 267506 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 D5CEB2C0205 for ; Fri, 16 Aug 2013 09:24:09 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751535Ab3HOXYI (ORCPT ); Thu, 15 Aug 2013 19:24:08 -0400 Received: from mail-pd0-f180.google.com ([209.85.192.180]:59532 "EHLO mail-pd0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751481Ab3HOXYH (ORCPT ); Thu, 15 Aug 2013 19:24:07 -0400 Received: by mail-pd0-f180.google.com with SMTP id y10so1401347pdj.11 for ; Thu, 15 Aug 2013 16:24:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-type:content-disposition:user-agent; bh=+w5Oq7pWVT6F8VRMkfIehxIygC6LcuaMsQqCnRZDsRc=; b=Sn+HLvE67AVM+O8kMx83PDc9vWwN+6WYsk84uQ6oVZ383XNV/dFvXf+V7bOwH52zSO jI8AAuK2H7UaCMbdRJ3zqikQm0xd7NPi1WCRnFHDmoXYjIt2MDyUNU3jJjBjkVwWTQNh wILwNoEIXztAB5Ss43I3EbQdSJFEJpuP9GhBUxfCyOb3BYO4wBBA/UbhNj9WFaAHijv9 dgiKreM59Jvvl7U9GwzMKGC4bWWsTbKfjil4oX/JzNRJ5PqbAKC87gjmHZlCS7RxvnQF YKv18gU4zgq2/PNC9k+HQQtHGK3WntpruAbxgXs6QGHZJ9uafjlBuQgSODvkqZoT8/SL QVxw== X-Gm-Message-State: ALoCoQlC6QkYvQ0MwNuRMe6LgCOZDF4owvz3rMPB2Tg8xxYkbNeVbCr0LwcLw3ih/wLngI1Q+3D5 X-Received: by 10.66.253.195 with SMTP id ac3mr18263200pad.107.1376609045868; Thu, 15 Aug 2013 16:24:05 -0700 (PDT) Received: from linuxace.com (cpe-76-171-169-87.socal.res.rr.com. [76.171.169.87]) by mx.google.com with ESMTPSA id xl3sm2005458pbb.17.2013.08.15.16.24.04 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 15 Aug 2013 16:24:05 -0700 (PDT) Date: Thu, 15 Aug 2013 16:24:11 -0700 From: Phil Oester To: netfilter-devel@vger.kernel.org Cc: pablo@netfilter.org Subject: [PATCH] nftables: add additional --numeric level Message-ID: <20130815232411.GA22555@linuxace.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org Personally, I like seeing ports and IPs numerically, but prefer protocols to be shown by name. As such, add a third --numeric level which will show protocols by number, splitting them out from ports. -n/--numeric When specified once, show network addresses numerically. When specified twice, also show Internet services, user IDs and group IDs numerically. When specified thrice, also show protocols numerically. Phil Signed-off-by: Phil Oester diff --git a/include/nftables.h b/include/nftables.h index ec21d37..12f3c49 100644 --- a/include/nftables.h +++ b/include/nftables.h @@ -8,6 +8,7 @@ enum numeric_level { NUMERIC_NONE, NUMERIC_ADDR, + NUMERIC_PORT, NUMERIC_ALL, }; diff --git a/src/datatype.c b/src/datatype.c index 55368ee..243760d 100644 --- a/src/datatype.c +++ b/src/datatype.c @@ -487,7 +487,7 @@ static void inet_service_type_print(const struct expr *expr) sin.sin_port = mpz_get_be16(expr->value); err = getnameinfo((struct sockaddr *)&sin, sizeof(sin), NULL, 0, buf, sizeof(buf), - numeric_output < NUMERIC_ALL ? 0 : NI_NUMERICSERV); + numeric_output < NUMERIC_PORT ? 0 : NI_NUMERICSERV); if (err != 0) { getnameinfo((struct sockaddr *)&sin, sizeof(sin), NULL, 0, buf, sizeof(buf), NI_NUMERICSERV); diff --git a/src/main.c b/src/main.c index 48d4e03..1a40b9e 100644 --- a/src/main.c +++ b/src/main.c @@ -104,8 +104,9 @@ static void show_help(const char *name) " -i/--interactive Read input from interactive CLI\n" "\n" " -n/--numeric When specified once, show network addresses numerically.\n" -" When specified twice, also show Internet protocols,\n" -" Internet services, user IDs and group IDs numerically.\n" +" When specified twice, also show Internet services,\n" +" user IDs and group IDs numerically.\n" +" When specified thrice, also show protocols numerically.\n" " -a/--handle Output rule handle.\n" " -I/--includepath Add to the paths searched for include files.\n" #ifdef DEBUG