From: Ana Rey <anarey@gmail.com>
To: netfilter-devel@vger.kernel.org
Cc: Ana Rey <anarey@gmail.com>
Subject: [libnftnl PATCH 3/5] src: table: Add set, unset and parse implementation for use value
Date: Thu, 26 Jun 2014 19:08:39 +0200 [thread overview]
Message-ID: <1403802521-12571-4-git-send-email-anarey@gmail.com> (raw)
In-Reply-To: <1403802521-12571-1-git-send-email-anarey@gmail.com>
Add some parts of the implemention of 'use' vualue in table that miss it.
These changes are neeeded for a correct import/export of xml/json file
Signed-off-by: Ana Rey <anarey@gmail.com>
---
src/table.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/src/table.c b/src/table.c
index de4a64d..5a0135f 100644
--- a/src/table.c
+++ b/src/table.c
@@ -72,8 +72,7 @@ void nft_table_attr_unset(struct nft_table *t, uint16_t attr)
case NFT_TABLE_ATTR_FAMILY:
break;
case NFT_TABLE_ATTR_USE:
- /* Cannot be unset, ignoring it */
- return;
+ break;
}
t->flags &= ~(1 << attr);
}
@@ -106,8 +105,8 @@ void nft_table_attr_set_data(struct nft_table *t, uint16_t attr,
t->family = *((uint32_t *)data);
break;
case NFT_TABLE_ATTR_USE:
- /* Cannot be set, ignoring it */
- return;
+ t->use = *((uint32_t *)data);
+ break;
}
t->flags |= (1 << attr);
}
@@ -263,7 +262,7 @@ int nft_mxml_table_parse(mxml_node_t *tree, struct nft_table *t,
{
const char *name;
int family;
- uint32_t flags;
+ uint32_t flags, use;
name = nft_mxml_str_parse(tree, "name", MXML_DESCEND_FIRST,
NFT_XML_MAND, err);
@@ -282,6 +281,10 @@ int nft_mxml_table_parse(mxml_node_t *tree, struct nft_table *t,
return -1;
nft_table_attr_set_u32(t, NFT_TABLE_ATTR_FLAGS, flags);
+ if (nft_mxml_num_parse(tree, "use", MXML_DESCEND, BASE_DEC,
+ &use, NFT_TYPE_U32, NFT_XML_MAND, err) == 0)
+ nft_table_attr_set_u32(t, NFT_TABLE_ATTR_USE, use);
+
return 0;
}
#endif
@@ -310,7 +313,7 @@ int nft_jansson_parse_table(struct nft_table *t, json_t *tree,
struct nft_parse_err *err)
{
json_t *root;
- uint32_t flags;
+ uint32_t flags, use;
const char *str;
int family;
@@ -334,6 +337,9 @@ int nft_jansson_parse_table(struct nft_table *t, json_t *tree,
nft_table_attr_set_u32(t, NFT_TABLE_ATTR_FLAGS, flags);
+ if (nft_jansson_parse_val(root, "use", NFT_TYPE_U32, &use, err) == 0)
+ nft_table_attr_set_u32(t, NFT_TABLE_ATTR_USE, use);
+
return 0;
}
#endif
--
2.0.0
next prev parent reply other threads:[~2014-06-26 17:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-26 17:08 [libnftnl PATCH 0/5] Do not print unset values in xml and json Ana Rey
2014-06-26 17:08 ` [libnftnl PATCH 1/5] src: table: Free memory in the same function that is reserved Ana Rey
2014-06-26 17:08 ` [libnftnl PATCH 2/5] src: table: Use nft_table_attr_set_* in the xml functions Ana Rey
2014-06-26 17:08 ` Ana Rey [this message]
2014-06-26 17:08 ` [libnftnl PATCH 4/5] src: table: Do not print unset values in xml file Ana Rey
2014-06-26 17:08 ` [libnftnl PATCH 5/5] src: table: Do not print unset values in json file Ana Rey
2014-06-30 10:49 ` [libnftnl PATCH 0/5] Do not print unset values in xml and json 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=1403802521-12571-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).