From: Arturo Borrero <arturo.borrero.glez@gmail.com>
To: netfilter-devel@vger.kernel.org
Cc: pablo@netfilter.org
Subject: [libnftables PATCH 2/5] src: expr: XML printing for binary data in targer and match
Date: Wed, 10 Apr 2013 18:40:02 +0200 [thread overview]
Message-ID: <20130410164002.6303.24175.stgit@nfdev.cica.es> (raw)
In-Reply-To: <20130410163912.6303.8705.stgit@nfdev.cica.es>
This is a try for expr/match and expr/target to be more XML friendly.
Signed-off-by: Arturo Borrero González <arturo.borrero.glez@gmail.com>
---
src/expr/match.c | 6 +++---
src/expr/target.c | 6 +++---
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/expr/match.c b/src/expr/match.c
index f83a8ea..d1f5963 100644
--- a/src/expr/match.c
+++ b/src/expr/match.c
@@ -193,12 +193,12 @@ int nft_rule_expr_match_snprintf_xml(char *buf, size_t len,
int offset = 0;
uint8_t *data = (uint8_t *)mt->data;
- ret = snprintf(buf, len, "\t\t<name>%s</name> <rev>%u</rev> <info>0x",
- mt->name, mt->rev);
+ ret = snprintf(buf, len, "\t\t<name>%s</name> <rev>%u</rev> <info><len>%u</len>",
+ mt->name, mt->rev, mt->data_len);
SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
for (i=0; i < mt->data_len; i++) {
- ret = snprintf(buf+offset, len, "%x", data[i] & 0xff);
+ ret = snprintf(buf+offset, len, "<data%d>0x%.2x</data%d>",i, data[i] & 0xff, i);
SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
}
diff --git a/src/expr/target.c b/src/expr/target.c
index 86c9bc8..aae58ce 100644
--- a/src/expr/target.c
+++ b/src/expr/target.c
@@ -193,12 +193,12 @@ int nft_rule_exp_target_snprintf_xml(char *buf, size_t len,
int offset = 0;
uint8_t *data = (uint8_t *)tg->data;
- ret = snprintf(buf, len, "\t\t<name>%s</name> <rev>%u</rev> <info>0x",
- tg->name, tg->rev);
+ ret = snprintf(buf, len, "\t\t<name>%s</name> <rev>%u</rev> <info><len>%u</len>",
+ tg->name, tg->rev, tg->data_len);
SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
for (i=0; i < tg->data_len; i++) {
- ret = snprintf(buf+offset, len, "%x", data[i] & 0xff);
+ ret = snprintf(buf+offset, len, "<data%d>0x%.2x</data%d>",i, data[i] & 0xff, i);
SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
}
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2013-04-10 16:40 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-10 16:39 [libnftables PATCH 0/5] XML works Arturo Borrero
2013-04-10 16:39 ` [libnftables PATCH 1/5] src: rule: small fix XML output Arturo Borrero
2013-04-18 23:32 ` Pablo Neira Ayuso
2013-04-10 16:40 ` Arturo Borrero [this message]
2013-04-10 16:40 ` [libnftables PATCH 3/5] src: xml printing: delete text format Arturo Borrero
2013-04-19 0:00 ` Pablo Neira Ayuso
2013-04-10 16:40 ` [libnftables PATCH 4/5] src: expr: print flags in XML Arturo Borrero
2013-04-10 16:40 ` [libnftables PATCH 5/5] src: support for XML parsing Arturo Borrero
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=20130410164002.6303.24175.stgit@nfdev.cica.es \
--to=arturo.borrero.glez@gmail.com \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.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.