diff options
author | Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com> | 2013-04-07 22:30:22 +0000 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2013-04-19 01:35:33 +0200 |
commit | aa56f410581fe3539b3c907c2a2fdec360481d5c (patch) | |
tree | 2e0fbf8123ea70f739c4b6879f2817eabb2a0cad /src/expr/bitwise.c | |
parent | 00ea30a840c0a7620b3a227198ded78b49d7e67e (diff) |
expr: basic support for printing nft_data_reg in XML format
nft_data_reg now is printed in XML according to what it contains
<data> nodes have been also renamed.
Arturo Borrero Gonzalez says:
====================
cmp is using <cmpdata> <cmpdata> has <data_reg></data_reg> 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 <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/expr/bitwise.c')
-rw-r--r-- | src/expr/bitwise.c | 39 |
1 files changed, 17 insertions, 22 deletions
diff --git a/src/expr/bitwise.c b/src/expr/bitwise.c index ac89cba..052144e 100644 --- a/src/expr/bitwise.c +++ b/src/expr/bitwise.c @@ -199,29 +199,26 @@ static int nft_rule_expr_bitwise_snprintf_xml(char *buf, size_t size, struct nft_expr_bitwise *bitwise) { - int len = size, offset = 0, ret, i; + int len = size, offset = 0, ret; ret = snprintf(buf, len, "\t\t<sreg>%u</sreg> " "<dreg>%u</dreg> ", - bitwise->sreg, bitwise->dreg); + bitwise->sreg, bitwise->dreg); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); ret = snprintf(buf+offset, len, "<mask>"); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); - for (i=0; i<bitwise->mask.len/sizeof(uint32_t); i++) { - ret = snprintf(buf+offset, len, "%.8x ", - bitwise->mask.val[i]); - SNPRINTF_BUFFER_SIZE(ret, size, len, offset); - } + ret = nft_data_reg_snprintf(buf+offset, len, &bitwise->mask, + NFT_RULE_O_XML, 0, DATA_VALUE); + SNPRINTF_BUFFER_SIZE(ret, size, len, offset); ret = snprintf(buf+offset, len, "</mask> <xor>"); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); - for (i=0; i<bitwise->xor.len/sizeof(uint32_t); i++) { - ret = snprintf(buf+offset, len, "%.8x ", bitwise->xor.val[i]); - SNPRINTF_BUFFER_SIZE(ret, size, len, offset); - } + ret = nft_data_reg_snprintf(buf+offset, len, &bitwise->xor, + NFT_RULE_O_XML, 0, DATA_VALUE); + SNPRINTF_BUFFER_SIZE(ret, size, len, offset); ret = snprintf(buf+offset, len, "</xor> "); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); @@ -231,29 +228,27 @@ nft_rule_expr_bitwise_snprintf_xml(char *buf, size_t size, static int nft_rule_expr_bitwise_snprintf_default(char *buf, size_t size, - struct nft_expr_bitwise *bitwise) + struct nft_expr_bitwise *bitwise) { - int len = size, offset = 0, ret, i; + int len = size, offset = 0, ret; ret = snprintf(buf, len, "sreg=%u dreg=%u ", - bitwise->sreg, bitwise->dreg); + bitwise->sreg, bitwise->dreg); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); ret = snprintf(buf+offset, len, " mask="); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); - for (i=0; i<bitwise->mask.len/sizeof(uint32_t); i++) { - ret = snprintf(buf+offset, len, "%.8x ", bitwise->mask.val[i]); - SNPRINTF_BUFFER_SIZE(ret, size, len, offset); - } + ret = nft_data_reg_snprintf(buf+offset, len, &bitwise->mask, + NFT_RULE_O_DEFAULT, 0, DATA_VALUE); + SNPRINTF_BUFFER_SIZE(ret, size, len, offset); ret = snprintf(buf+offset, len, " xor="); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); - for (i=0; i<bitwise->xor.len/sizeof(uint32_t); i++) { - ret = snprintf(buf+offset, len, "%.8x ", bitwise->xor.val[i]); - SNPRINTF_BUFFER_SIZE(ret, size, len, offset); - } + ret = nft_data_reg_snprintf(buf+offset, len, &bitwise->xor, + NFT_RULE_O_DEFAULT, 0, DATA_VALUE); + SNPRINTF_BUFFER_SIZE(ret, size, len, offset); return offset; } |