diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/chain.c | 19 | ||||
-rw-r--r-- | src/internal.h | 9 | ||||
-rw-r--r-- | src/rule.c | 21 | ||||
-rw-r--r-- | src/set.c | 15 | ||||
-rw-r--r-- | src/table.c | 33 |
5 files changed, 13 insertions, 84 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); diff --git a/src/internal.h b/src/internal.h index 1970c9c..a8ae431 100644 --- a/src/internal.h +++ b/src/internal.h @@ -47,15 +47,6 @@ const char *nft_jansson_value_parse_str(json_t *root, const char *tag); bool nft_jansson_node_exist(json_t *root, const char *tag); #endif -#define NFT_TABLE_XML_VERSION 0 -#define NFT_CHAIN_XML_VERSION 0 -#define NFT_RULE_XML_VERSION 0 -#define NFT_SET_XML_VERSION 0 -#define NFT_TABLE_JSON_VERSION 0 -#define NFT_CHAIN_JSON_VERSION 0 -#define NFT_RULE_JSON_VERSION 0 -#define NFT_SET_JSON_VERSION 0 - const char *nft_family2str(uint32_t family); int nft_str2family(const char *family); int nft_strtoi(const char *string, int base, void *number, enum nft_type type); @@ -486,17 +486,6 @@ static int nft_rule_xml_parse(struct nft_rule *r, char *xml) if (tree == NULL) return -1; - /* validate XML version <rule ... version=X ... > */ - if (mxmlElementGetAttr(tree, "version") == NULL) { - mxmlDelete(tree); - return -1; - } - tmp = strtoll(mxmlElementGetAttr(tree, "version"), &endptr, 10); - if (tmp == LLONG_MAX || *endptr || tmp != NFT_RULE_XML_VERSION) { - mxmlDelete(tree); - return -1; - } - /* get and set <rule ... family=X ... > */ if (mxmlElementGetAttr(tree, "family") == NULL) { mxmlDelete(tree); @@ -644,10 +633,9 @@ static int nft_rule_snprintf_json(char *buf, size_t size, struct nft_rule *r, ret = snprintf(buf, size, "{ \"rule\": { \"family\" : \"%s\", \"table\" : \"%s\", " - "\"chain\" : \"%s\", \"handle\" : %llu, \"version\" : %d, ", + "\"chain\" : \"%s\", \"handle\" : %llu,", nft_family2str(r->family), r->table, r->chain, - (unsigned long long)r->handle, - NFT_RULE_JSON_VERSION); + (unsigned long long)r->handle); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); ret = snprintf(buf+offset, len, "\"rule_flags\" : %u, ", @@ -690,10 +678,9 @@ static int nft_rule_snprintf_xml(char *buf, size_t size, struct nft_rule *r, ret = snprintf(buf, size, "<rule family=\"%s\" table=\"%s\" " - "chain=\"%s\" handle=\"%llu\" version=\"%d\">", + "chain=\"%s\" handle=\"%llu\">", nft_family2str(r->family), r->table, r->chain, - (unsigned long long)r->handle, - NFT_RULE_XML_VERSION); + (unsigned long long)r->handle); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); ret = snprintf(buf+offset, len, "<rule_flags>%u</rule_flags>", @@ -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, "<set><family>%s</family>" "<set_table>%s</set_table>" "<set_name>%s</set_name>" - "<set_xml_version>%d</set_xml_version>" "<set_flags>%u</set_flags>" "<key_type>%u</key_type>" "<key_len>%u</key_len>" "<data_type>%u</data_type>" "<data_len>%u</data_len>", 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); diff --git a/src/table.c b/src/table.c index 1d17d3b..1f4fe76 100644 --- a/src/table.c +++ b/src/table.c @@ -223,8 +223,6 @@ static int nft_table_xml_parse(struct nft_table *t, char *xml) #ifdef XML_PARSING mxml_node_t *tree = NULL; mxml_node_t *node = NULL; - char *endptr = NULL; - int64_t stmp; int family; /* NOTE: all XML nodes are mandatory */ @@ -234,18 +232,6 @@ static int nft_table_xml_parse(struct nft_table *t, char *xml) if (tree == NULL) return -1; - /* Check the version of the XML */ - if (mxmlElementGetAttr(tree, "version") == NULL) { - mxmlDelete(tree); - return -1; - } - - stmp = strtoll(mxmlElementGetAttr(tree, "version"), &endptr, 10); - if (stmp == LLONG_MAX || *endptr || stmp != NFT_TABLE_XML_VERSION) { - mxmlDelete(tree); - return -1; - } - /* Get and set the name of the table */ if (mxmlElementGetAttr(tree, "name") == NULL) { mxmlDelete(tree); @@ -300,7 +286,6 @@ static int nft_table_json_parse(struct nft_table *t, char *json) #ifdef JSON_PARSING json_t *root; json_error_t error; - uint64_t version; uint32_t table_flag; const char *str; int family; @@ -317,15 +302,6 @@ static int nft_table_json_parse(struct nft_table *t, char *json) goto err; } - if (nft_jansson_value_parse_val(root, "version", - NFT_TYPE_U64, &version) == -1) - goto err; - - if (version != NFT_TABLE_JSON_VERSION) { - errno = EINVAL; - goto err; - } - str = nft_jansson_value_parse_str(root, "name"); if (str == NULL) goto err; @@ -392,27 +368,24 @@ static int nft_table_snprintf_json(char *buf, size_t size, struct nft_table *t) return snprintf(buf, size, "{\"table\" : {" "\"name\" : \"%s\"," - "\"version\" : %d," "\"properties\" : {" "\"family\" : \"%s\"," "\"table_flags\" : %d" "}" "}" "}" , - t->name, NFT_TABLE_JSON_VERSION, - nft_family2str(t->family), t->table_flags); + t->name, nft_family2str(t->family), t->table_flags); } static int nft_table_snprintf_xml(char *buf, size_t size, struct nft_table *t) { - return snprintf(buf, size, "<table name=\"%s\" version=\"%d\">" + return snprintf(buf, size, "<table name=\"%s\">" "<properties>" "<family>%s</family>" "<table_flags>%d</table_flags>" "</properties>" "</table>", - t->name, NFT_TABLE_XML_VERSION, - nft_family2str(t->family), t->table_flags); + t->name, nft_family2str(t->family), t->table_flags); } static int nft_table_snprintf_default(char *buf, size_t size, struct nft_table *t) |