diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2013-07-26 15:56:37 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2013-07-26 16:15:51 +0200 |
commit | 2d16da839c46428c546d3ff372d919236920ead1 (patch) | |
tree | fd92c20dae6f07eb6f62493f15cda3dc5d44f899 /src/chain.c | |
parent | 44928cd546f00a73797a570dcaee44f0bfe5bea7 (diff) |
src: remove version from XML and JSON representations
This patch removes the version XML node and the version JSON field
in all our existing objects. The current versioning approach
consists of adding a version field to every object representation
in XML and JSON. While listing my entire rule-set, one can notice
that this approach is too bloated.
Once the library enters stable stage, if we need to obsolete a XML
node and a JSON field, we can follow this procedure:
1) Remove the XML node and the JSON field from the output, so fresh
outputs will not contain the old ones anymore.
2) Do not remove the parsing of the old XML node and the JSON field
inmediately. We have to keep supporting the parsing for a while
to avoid breaking the interpretion of old XML/JSON files. We can
spot a warning to warn about it, so users generate a fresh
output again.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/chain.c')
-rw-r--r-- | src/chain.c | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/src/chain.c b/src/chain.c index 1e07044..14db5f7 100644 --- a/src/chain.c +++ b/src/chain.c @@ -475,7 +475,6 @@ static int nft_chain_xml_parse(struct nft_chain *c, char *xml) mxml_node_t *node = NULL; char *endptr = NULL; uint64_t utmp; - int64_t tmp; int family; /* NOTE: all XML nodes are mandatory */ @@ -485,17 +484,6 @@ static int nft_chain_xml_parse(struct nft_chain *c, char *xml) if (tree == NULL) return -1; - /* Validate version */ - if (mxmlElementGetAttr(tree, "version") == NULL) { - mxmlDelete(tree); - return -1; - } - tmp = strtoll(mxmlElementGetAttr(tree, "version"), &endptr, 10); - if (tmp == LLONG_MAX || *endptr || tmp != NFT_CHAIN_XML_VERSION) { - mxmlDelete(tree); - return -1; - } - /* Get and set <chain name="xxx" ... >*/ if (mxmlElementGetAttr(tree, "name") == NULL) { mxmlDelete(tree); @@ -694,13 +682,12 @@ static int nft_chain_snprintf_json(char *buf, size_t size, struct nft_chain *c) "\"handle\": %"PRIu64"," "\"bytes\": %"PRIu64"," "\"packets\": %"PRIu64"," - "\"version\": %d," "\"properties\": {" "\"family\": \"%s\"," "\"table\": \"%s\"," "\"use\": %d", c->name, c->handle, c->bytes, c->packets, - NFT_CHAIN_JSON_VERSION, nft_family2str(c->family), + nft_family2str(c->family), c->table, c->use); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); @@ -730,7 +717,7 @@ static int nft_chain_snprintf_xml(char *buf, size_t size, struct nft_chain *c) ret = snprintf(buf, size, "<chain name=\"%s\" handle=\"%"PRIu64"\"" - " bytes=\"%"PRIu64"\" packets=\"%"PRIu64"\" version=\"%d\">" + " bytes=\"%"PRIu64"\" packets=\"%"PRIu64"\">" "<properties>" "<type>%s</type>" "<table>%s</table>" @@ -738,7 +725,7 @@ static int nft_chain_snprintf_xml(char *buf, size_t size, struct nft_chain *c) "<use>%d</use>" "<hooknum>%s</hooknum>", c->name, c->handle, c->bytes, c->packets, - NFT_CHAIN_XML_VERSION, c->type, c->table, + c->type, c->table, c->prio, c->use, hooknum2str_array[c->hooknum]); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); |