From: Ana Rey <anarey@gmail.com>
To: netfilter-devel@vger.kernel.org
Cc: Ana Rey <anarey@gmail.com>
Subject: [libnftnl PATCH 3/3] expr: nat: Do not print unset values in json file
Date: Fri, 13 Jun 2014 14:08:29 +0200 [thread overview]
Message-ID: <1402661309-17839-4-git-send-email-anarey@gmail.com> (raw)
In-Reply-To: <1402661309-17839-1-git-send-email-anarey@gmail.com>
It changes the parse functions to omit unset values.
Now, It possible to use a xml file like this:
[...]
{
"type": "nat",
"nat_type": "snat",
"family": "ip",
"sreg_addr_min": 1,
"sreg_addr_max": 1,
}
Signed-off-by: Ana Rey <anarey@gmail.com>
---
src/expr/nat.c | 24 ++++++++----------------
1 file changed, 8 insertions(+), 16 deletions(-)
diff --git a/src/expr/nat.c b/src/expr/nat.c
index c10f0ff..0136fca 100644
--- a/src/expr/nat.c
+++ b/src/expr/nat.c
@@ -225,28 +225,20 @@ static int nft_rule_expr_nat_json_parse(struct nft_rule_expr *e, json_t *root,
nft_rule_expr_set_u32(e, NFT_EXPR_NAT_FAMILY, val32);
if (nft_jansson_parse_reg(root, "sreg_addr_min", NFT_TYPE_U32,
- ®, err) < 0)
- return -1;
-
- nft_rule_expr_set_u32(e, NFT_EXPR_NAT_REG_ADDR_MIN, reg);
+ ®, err) == 0)
+ nft_rule_expr_set_u32(e, NFT_EXPR_NAT_REG_ADDR_MIN, reg);
if (nft_jansson_parse_reg(root, "sreg_addr_max", NFT_TYPE_U32,
- ®, err) < 0)
- return -1;
-
- nft_rule_expr_set_u32(e, NFT_EXPR_NAT_REG_ADDR_MAX, reg);
+ ®, err) == 0)
+ nft_rule_expr_set_u32(e, NFT_EXPR_NAT_REG_ADDR_MAX, reg);
if (nft_jansson_parse_reg(root, "sreg_proto_min", NFT_TYPE_U32,
- ®, err) < 0)
- return -1;
-
- nft_rule_expr_set_u32(e, NFT_EXPR_NAT_REG_PROTO_MIN, reg);
+ ®, err) == 0)
+ nft_rule_expr_set_u32(e, NFT_EXPR_NAT_REG_PROTO_MIN, reg);
if (nft_jansson_parse_reg(root, "sreg_proto_max", NFT_TYPE_U32,
- ®, err) < 0)
- return -1;
-
- nft_rule_expr_set_u32(e, NFT_EXPR_NAT_REG_PROTO_MAX, reg);
+ ®, err) == 0)
+ nft_rule_expr_set_u32(e, NFT_EXPR_NAT_REG_PROTO_MAX, reg);
return 0;
#else
--
2.0.0
prev parent reply other threads:[~2014-06-13 12:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-13 12:08 [libnftnl PATCH 0/3] expr: nat: Do not print unset value Ana Rey
2014-06-13 12:08 ` [libnftnl PATCH 1/3] expr: nat: Use nft_rule_expr_set_* in the xml Ana Rey
2014-06-13 12:08 ` [libnftnl PATCH 2/3] expr: nat: Do not print unset values in xml file Ana Rey
2014-06-13 12:08 ` Ana Rey [this message]
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=1402661309-17839-4-git-send-email-anarey@gmail.com \
--to=anarey@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).