From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Jan Engelhardt <jengelh@medozas.de>
Cc: netfilter-devel@vger.kernel.org, eleblond@edenwall.com
Subject: Re: [PATCH] add nfq_snprintf_xml() to output a packet in XML format
Date: Thu, 27 May 2010 13:50:23 +0200 [thread overview]
Message-ID: <4BFE5C7F.2030400@netfilter.org> (raw)
In-Reply-To: <alpine.LSU.2.01.1005261740270.1686@obet.zrqbmnf.qr>
Jan Engelhardt wrote:
> On Wednesday 2010-05-26 14:39, Pablo Neira Ayuso wrote:
>
>> This patch adds a new function to output the packet in XML format.
>
>> +int nfq_snprintf_xml(char *buf, int len, struct nfq_data *tb, int flags)
>> +{
>> + struct nfqnl_msg_packet_hdr *ph;
>> + struct nfqnl_msg_packet_hw *hwph;
>> + u_int32_t mark, ifi;
>> + int size, offset = 0, ret;
>> + char *data;
>> +
>> + size = snprintf(buf + offset, len, "<pkt>");
>> + SNPRINTF_FAILURE(size, len, offset);
>> +
>> + ph = nfq_get_msg_packet_hdr(tb);
>> + if (ph) {
>> + size = snprintf(buf + offset, len,
>> + "<hook>%u</hook><id>%u</id>",
>> + ph->hook, ntohl(ph->packet_id));
>> + SNPRINTF_FAILURE(size, len, offset);
>
> Couldn't libxml be used to generate the XML?
Adding such a dependency is overkill. One of the good things of these
libraries is that they are small and they have small dependencies.
>> + ret = nfq_get_payload(tb, &data);
>> + if (ret >= 0 && (flags & NFQ_XML_PAYLOAD)) {
>> + int i;
>> +
>> + size = snprintf(buf + offset, len, "<payload>");
>> + SNPRINTF_FAILURE(size, len, offset);
>> +
>> + for (i=0; i<ret; i++) {
>> + size = snprintf(buf + offset, len, "x%02x",
>
> What's the leading x for? It seems to add no value.
We can remove that or include a backslash before the 'x'.
next prev parent reply other threads:[~2010-05-27 11:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-26 12:39 [PATCH] add nfq_snprintf_xml() to output a packet in XML format Pablo Neira Ayuso
2010-05-26 15:44 ` Jan Engelhardt
2010-05-27 11:50 ` Pablo Neira Ayuso [this message]
2010-05-27 13:14 ` 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=4BFE5C7F.2030400@netfilter.org \
--to=pablo@netfilter.org \
--cc=eleblond@edenwall.com \
--cc=jengelh@medozas.de \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.