From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [libnftnl PATCH 1/2] src: add flag to add event wrapping in output functions
Date: Tue, 15 Apr 2014 15:36:18 +0200 [thread overview]
Message-ID: <20140415133618.GA8835@localhost> (raw)
In-Reply-To: <20140415125030.2590.5501.stgit@nfdev.cica.es>
On Tue, Apr 15, 2014 at 02:50:30PM +0200, Arturo Borrero Gonzalez wrote:
> This patch uses the flag option of each output function to print an
> event wrapper string in each object.
>
> In order to use this functionality, the caller must pass a flag with either
> NFT_OUTPUT_FLAG_EVENTNEW or NFT_OUTPUT_FLAG_EVENTDEL activated.
>
> Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
> ---
> include/libnftnl/common.h | 5 +++
> src/chain.c | 37 ++++++++++++++++++++++---
> src/internal.h | 2 +
> src/rule.c | 43 ++++++++++++++++++++++++++---
> src/ruleset.c | 66 ++++++++++++++++++++++++++++++++++++++++-----
> src/set.c | 42 +++++++++++++++++++++++++----
> src/set_elem.c | 37 ++++++++++++++++++++++---
> src/table.c | 36 +++++++++++++++++++++----
> src/utils.c | 45 +++++++++++++++++++++++++++++++
> 9 files changed, 280 insertions(+), 33 deletions(-)
>
> diff --git a/include/libnftnl/common.h b/include/libnftnl/common.h
> index f0c20f0..f105c9a 100644
> --- a/include/libnftnl/common.h
> +++ b/include/libnftnl/common.h
> @@ -15,6 +15,11 @@ enum nft_output_type {
> NFT_OUTPUT_JSON,
> };
>
> +enum {
> + NFT_OUTPUT_FLAG_EVENTNEW = 0,
> + NFT_OUTPUT_FLAG_EVENTDEL,
> +};
Please, change this to:
enum nft_output_flags {
NFT_OF_EVENT_NEW = (1 << 0),
NFT_OF_EVENT_DEL = (1 << 1),
};
So people don't need to use (1 << NFT_OUTPUT_FLAG_EVENTNEW) to pass
the flag to nft_*_snprintf from their applications.
> +
> enum nft_parse_type {
> NFT_PARSE_NONE = 0,
> NFT_PARSE_XML,
> diff --git a/src/chain.c b/src/chain.c
> index 472203e..87558a1 100644
> --- a/src/chain.c
> +++ b/src/chain.c
> @@ -924,17 +924,44 @@ static int nft_chain_snprintf_default(char *buf, size_t size,
> int nft_chain_snprintf(char *buf, size_t size, struct nft_chain *c,
> uint32_t type, uint32_t flags)
> {
> + int ret, len = size, offset = 0;
> +
> + if (flags & (1 << NFT_OUTPUT_FLAG_EVENTNEW)) {
> + ret = snprintf(buf+offset, len, "%s",
Use this instead "%9s ".
So you can use [NEW] and [DELETE] tags and the plain text event output
gets aligned (and you don't need to trim DELETE to DEL anymore).
next prev parent reply other threads:[~2014-04-15 13:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-15 12:50 [libnftnl PATCH 1/2] src: add flag to add event wrapping in output functions Arturo Borrero Gonzalez
2014-04-15 12:50 ` [libnftnl PATCH 2/2] examples: nft-events: use new events wrappers Arturo Borrero Gonzalez
2014-04-15 13:36 ` Pablo Neira Ayuso [this message]
2014-04-15 13:44 ` [libnftnl PATCH 1/2] src: add flag to add event wrapping in output functions Pablo Neira Ayuso
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=20140415133618.GA8835@localhost \
--to=pablo@netfilter.org \
--cc=arturo.borrero.glez@gmail.com \
--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).