From 2d16da839c46428c546d3ff372d919236920ead1 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Fri, 26 Jul 2013 15:56:37 +0200 Subject: 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 --- src/chain.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) (limited to 'src/chain.c') 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 */ 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, "" + " bytes=\"%"PRIu64"\" packets=\"%"PRIu64"\">" "" "%s" "%s
" @@ -738,7 +725,7 @@ static int nft_chain_snprintf_xml(char *buf, size_t size, struct nft_chain *c) "%d" "%s", 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); -- cgit v1.2.3