netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Arturo Borrero <arturo.borrero.glez@gmail.com>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [libnftables PATCH] src: rule: fix compat XML output
Date: Tue, 9 Apr 2013 21:49:00 +0200	[thread overview]
Message-ID: <20130409194900.GB5544@localhost> (raw)
In-Reply-To: <20130408083502.9509.95918.stgit@nfdev.cica.es>

Hi Arturo,

On Mon, Apr 08, 2013 at 10:35:02AM +0200, Arturo Borrero wrote:
> The compat struct was not printed in XML. So, I think give output
> format is the first step to parse it.
> ---
>  src/rule.c |    9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/src/rule.c b/src/rule.c
> index 57b849d..e419b0a 100644
> --- a/src/rule.c
> +++ b/src/rule.c
> @@ -445,11 +445,18 @@ static int nft_rule_snprintf_xml(char *buf, size_t size, struct nft_rule *r,
>  
>  	ret = snprintf(buf, size,
>  		"<rule family=\"%u\" table=\"%s\" "
> -			"chain=\"%s\" handle=\"%llu\"> ",
> +			"chain=\"%s\" handle=\"%llu\">\n ",
                                                      ^^^

We don't need the space after ">" and the \n and the extra formatting.

As example, check the output of conntrack in XML:

# conntrack -L -o xml
<?xml version="1.0" encoding="utf-8"?>
<conntrack>
<flow type="new"><meta direction="original"><layer3 protonum="2" protoname="ipv4"><src>77.209.70.77</src><dst>150.214.142.14</dst></layer3><layer4 protonum="1" protoname="icmp"></layer4></meta><meta direction="reply"><layer3 protonum="2" protoname="ipv4"><src>150.214.142.14</src><dst>77.209.70.77</dst></layer3><layer4 protonum="1" protoname="icmp"></layer4></meta><meta direction="independent"><timeout>30</timeout><id>830164440</id><unreplied/></meta></flow>
<flow type="update"><meta direction="original"><layer3 protonum="2" protoname="ipv4"><src>77.209.70.77</src><dst>150.214.142.14</dst></layer3><layer4 protonum="1" protoname="icmp"></layer4></meta><meta direction="reply"><layer3 protonum="2" protoname="ipv4"><src>150.214.142.14</src><dst>77.209.70.77</dst></layer3><layer4 protonum="1" protoname="icmp"></layer4></meta><meta direction="independent"><timeout>29</timeout><id>830164440</id></meta></flow>
</conntrack>

Note that every flow is expressed in one single line in XML.

Now do:

# conntrack -L -o xml > /tmp/x.xml

And have a look at some XML visualizer, eg:

$ firefox /tmp/x.xml

Does it clarify?

  reply	other threads:[~2013-04-09 19:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-08  8:35 [libnftables PATCH] src: rule: fix compat XML output Arturo Borrero
2013-04-09 19:49 ` Pablo Neira Ayuso [this message]
2013-04-09 20:34   ` Arturo Borrero Gonzalez
2013-04-18 23:29     ` 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=20130409194900.GB5544@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).