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/set.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'src/set.c') diff --git a/src/set.c b/src/set.c index 4b0ec6a..23a2ab1 100644 --- a/src/set.c +++ b/src/set.c @@ -311,7 +311,6 @@ static int nft_set_xml_parse(struct nft_set *s, char *xml) struct nft_set_elem *elem; char *name; char *table; - int version; int family; char *family_str; @@ -324,13 +323,6 @@ static int nft_set_xml_parse(struct nft_set *s, char *xml) if (strcmp(tree->value.opaque, "set") != 0) goto err; - if (nft_mxml_num_parse(tree, "set_xml_version", MXML_DESCEND_FIRST, - BASE_DEC, &version, NFT_TYPE_S32) != 0) - goto err; - - if (version != NFT_SET_XML_VERSION) - goto err; - name = (char *)nft_mxml_str_parse(tree, "set_name", MXML_DESCEND_FIRST); if (name == NULL) @@ -448,10 +440,10 @@ static int nft_set_snprintf_json(char *buf, size_t size, struct nft_set *s, struct nft_set_elem *elem; ret = snprintf(buf, size, "{ \"set\": { \"name\": \"%s\"," - "\"table\": \"%s\",\"version\": %d," + "\"table\": \"%s\"," "\"flags\": %u,\"family\": \"%s\"," "\"key_type\": %u,\"key_len\": %u", - s->name, s->table, NFT_SET_JSON_VERSION, s->set_flags, + s->name, s->table, s->set_flags, nft_family2str(s->family), s->key_type, s->key_len); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); @@ -529,14 +521,13 @@ static int nft_set_snprintf_xml(char *buf, size_t size, struct nft_set *s, ret = snprintf(buf, size, "%s" "%s" "%s" - "%d" "%u" "%u" "%u" "%u" "%u", nft_family2str(s->family), s->table, s->name, - NFT_SET_XML_VERSION, s->set_flags, s->key_type, + s->set_flags, s->key_type, s->key_len, s->data_type, s->data_len); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); -- cgit v1.2.3