From aa56f410581fe3539b3c907c2a2fdec360481d5c Mon Sep 17 00:00:00 2001 From: Arturo Borrero Gonzalez Date: Sun, 7 Apr 2013 22:30:22 +0000 Subject: expr: basic support for printing nft_data_reg in XML format nft_data_reg now is printed in XML according to what it contains nodes have been also renamed. Arturo Borrero Gonzalez says: ==================== cmp is using has which can also be redundant. But all around the XML printing (including sets, an incoming patch) i've been nesting the data_reg into another XML node, so you could easily see (also the XML parser) the difference between (for example. in set) nft_set_elem->key and nft_set_elem->data. As I needed to nest in nft_set_elem I decided to follow a constant line and do nest all data_reg. ==================== Signed-off-by: Arturo Borrero Gonzalez Signed-off-by: Pablo Neira Ayuso --- src/expr/cmp.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'src/expr/cmp.c') diff --git a/src/expr/cmp.c b/src/expr/cmp.c index 429f024..6b5a3a2 100644 --- a/src/expr/cmp.c +++ b/src/expr/cmp.c @@ -169,18 +169,17 @@ static char *expr_cmp_str[] = { static int nft_rule_expr_cmp_snprintf_xml(char *buf, size_t size, struct nft_expr_cmp *cmp) { - int len = size, offset = 0, ret, i; + int len = size, offset = 0, ret; - ret = snprintf(buf, len, "\t\t%u %s ", - cmp->sreg, expr_cmp_str[cmp->op]); + ret = snprintf(buf, len, "\t\t%u %s ", + cmp->sreg, expr_cmp_str[cmp->op]); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); - for (i=0; idata.len/sizeof(uint32_t); i++) { - ret = snprintf(buf+offset, len, "%.8x ", cmp->data.val[i]); - SNPRINTF_BUFFER_SIZE(ret, size, len, offset); - } + ret = nft_data_reg_snprintf(buf+offset, len, &cmp->data, + NFT_RULE_O_XML, 0, DATA_VALUE); + SNPRINTF_BUFFER_SIZE(ret, size, len, offset); - ret = snprintf(buf+offset, len, " "); + ret = snprintf(buf+offset, len, " "); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); return offset; @@ -190,16 +189,16 @@ static int nft_rule_expr_cmp_snprintf_default(char *buf, size_t size, struct nft_expr_cmp *cmp) { - int len = size, offset = 0, ret, i; + int len = size, offset = 0, ret; ret = snprintf(buf, len, "sreg=%u op=%s data=", - cmp->sreg, expr_cmp_str[cmp->op]); + cmp->sreg, expr_cmp_str[cmp->op]); + SNPRINTF_BUFFER_SIZE(ret, size, len, offset); + + ret = nft_data_reg_snprintf(buf+offset, len, &cmp->data, + NFT_RULE_O_DEFAULT, 0, DATA_VALUE); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); - for (i=0; idata.len/sizeof(uint32_t); i++) { - ret = snprintf(buf+offset, len, "%.8x ", cmp->data.val[i]); - SNPRINTF_BUFFER_SIZE(ret, size, len, offset); - } return offset; } -- cgit v1.2.3