]> git.ipfire.org Git - thirdparty/libnftnl.git/commitdiff
src: xml: use nodes instead of attributes
authorArturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Tue, 6 Aug 2013 08:40:33 +0000 (10:40 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 6 Aug 2013 09:44:20 +0000 (11:44 +0200)
When working with XML, it's desirable to work with nodes better than
attributes.

Table/chain/rules had attributes in their XML representation, and
this patch transform those to nodes, ie:

Before:
<table name="filter">
<family>ip</family>
<table_flags>0</table_flags>
</table>

After:
<table>
<name>filter</name>
<family>ip</family>
<table_flags>0</table_flags>
</table>

While at it:
 * There was a lot of redundant code that is now collapsed with the
new nft_mxml_family_parse() helper function.

 * I've added a small fix: additional validation for the name of
the current XML object, and also replace raw strtol calls to nft_strtoi.

 * Also, all XML testfiles are updated to keep passing the parsing tests and
mantain the repo in consisten state.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
64 files changed:
src/chain.c
src/expr/nat.c
src/internal.h
src/mxml.c
src/rule.c
src/table.c
tests/xmlfiles/01-table.xml
tests/xmlfiles/02-table.xml
tests/xmlfiles/10-chain.xml
tests/xmlfiles/11-chain.xml
tests/xmlfiles/12-chain.xml
tests/xmlfiles/20-rule-bitwise.xml
tests/xmlfiles/21-rule-byteorder.xml
tests/xmlfiles/22-rule-cmp.xml
tests/xmlfiles/23-rule-counter.xml
tests/xmlfiles/24-rule-ct.xml
tests/xmlfiles/25-rule-exthdr.xml
tests/xmlfiles/26-rule-immediate.xml
tests/xmlfiles/27-rule-limit.xml
tests/xmlfiles/28-rule-log.xml
tests/xmlfiles/29-rule-lookup.xml
tests/xmlfiles/30-rule-match.xml
tests/xmlfiles/31-rule-meta.xml
tests/xmlfiles/32-rule-nat6.xml
tests/xmlfiles/33-rule-nat4.xml
tests/xmlfiles/34-rule-payload.xml
tests/xmlfiles/35-rule-target.xml
tests/xmlfiles/36-rule-real.xml
tests/xmlfiles/37-rule-real.xml
tests/xmlfiles/38-rule-real.xml
tests/xmlfiles/39-rule-real.xml
tests/xmlfiles/40-rule-real.xml
tests/xmlfiles/41-rule-real.xml
tests/xmlfiles/42-rule-real.xml
tests/xmlfiles/43-rule-real.xml
tests/xmlfiles/44-rule-real.xml
tests/xmlfiles/45-rule-real.xml
tests/xmlfiles/46-rule-real.xml
tests/xmlfiles/47-rule-real.xml
tests/xmlfiles/48-rule-real.xml
tests/xmlfiles/49-rule-real.xml
tests/xmlfiles/50-rule-real.xml
tests/xmlfiles/51-rule-real.xml
tests/xmlfiles/52-rule-real.xml
tests/xmlfiles/53-rule-real.xml
tests/xmlfiles/54-rule-real.xml
tests/xmlfiles/55-rule-real.xml
tests/xmlfiles/56-rule-real.xml
tests/xmlfiles/57-rule-real.xml
tests/xmlfiles/58-rule-real.xml
tests/xmlfiles/59-rule-real.xml
tests/xmlfiles/60-rule-real.xml
tests/xmlfiles/61-rule-real.xml
tests/xmlfiles/62-rule-real.xml
tests/xmlfiles/63-rule-real.xml
tests/xmlfiles/64-rule-real.xml
tests/xmlfiles/65-rule-real.xml
tests/xmlfiles/66-rule-real.xml
tests/xmlfiles/67-rule-real.xml
tests/xmlfiles/68-rule-real.xml
tests/xmlfiles/69-rule-real.xml
tests/xmlfiles/70-rule-real.xml
tests/xmlfiles/71-rule-real.xml
tests/xmlfiles/72-rule-real.xml

index 0dd3461a6bf83428d53a82e36edf4c9ebeea8484..3ad52fd7b13999ffc564c62c41008b7e78fba794 100644 (file)
@@ -587,8 +587,7 @@ static int nft_chain_xml_parse(struct nft_chain *c, char *xml)
 #ifdef XML_PARSING
        mxml_node_t *tree = NULL;
        mxml_node_t *node = NULL;
-       char *endptr = NULL;
-       uint64_t utmp;
+       const char *name;
        const char *hooknum_str;
        int family, hooknum;
 
@@ -599,54 +598,43 @@ static int nft_chain_xml_parse(struct nft_chain *c, char *xml)
        if (tree == NULL)
                return -1;
 
-       /* Get and set <chain name="xxx" ... >*/
-       if (mxmlElementGetAttr(tree, "name") == NULL) {
+       if (strcmp(tree->value.opaque, "chain") != 0) {
                mxmlDelete(tree);
                return -1;
        }
-       strncpy(c->name, mxmlElementGetAttr(tree, "name"),
-               NFT_CHAIN_MAXNAMELEN);
-       c->flags |= (1 << NFT_CHAIN_ATTR_NAME);
 
-       /* Get and set <chain handle="x" ... >*/
-       if (mxmlElementGetAttr(tree, "handle") == NULL) {
+       name = nft_mxml_str_parse(tree, "name", MXML_DESCEND_FIRST);
+       if (name == NULL) {
                mxmlDelete(tree);
                return -1;
        }
 
-       utmp = strtoull(mxmlElementGetAttr(tree, "handle"), &endptr, 10);
-       if (utmp == UINT64_MAX || utmp < 0 || *endptr) {
+       strncpy(c->name, name, NFT_CHAIN_MAXNAMELEN);
+       xfree(name);
+       c->flags |= (1 << NFT_CHAIN_ATTR_NAME);
+
+       if (nft_mxml_num_parse(tree, "handle", MXML_DESCEND_FIRST, BASE_DEC,
+                              &c->handle, NFT_TYPE_U64) != 0) {
                mxmlDelete(tree);
                return -1;
        }
 
-       c->handle = utmp;
        c->flags |= (1 << NFT_CHAIN_ATTR_HANDLE);
 
-       /* Get and set <chain bytes="x" ... >*/
-       if (mxmlElementGetAttr(tree, "bytes") == NULL) {
+       if (nft_mxml_num_parse(tree, "bytes", MXML_DESCEND_FIRST, BASE_DEC,
+                              &c->bytes, NFT_TYPE_U64) != 0) {
                mxmlDelete(tree);
                return -1;
        }
-       utmp = strtoull(mxmlElementGetAttr(tree, "bytes"), &endptr, 10);
-       if (utmp == UINT64_MAX || utmp < 0 || *endptr) {
-               mxmlDelete(tree);
-               return -1;
-       }
-       c->bytes = utmp;
+
        c->flags |= (1 << NFT_CHAIN_ATTR_BYTES);
 
-       /* Get and set <chain packets="x" ... > */
-       if (mxmlElementGetAttr(tree, "packets") == NULL) {
+       if (nft_mxml_num_parse(tree, "packets", MXML_DESCEND_FIRST, BASE_DEC,
+                              &c->packets, NFT_TYPE_U64) != 0) {
                mxmlDelete(tree);
                return -1;
        }
-       utmp = strtoull(mxmlElementGetAttr(tree, "packets"), &endptr, 10);
-       if (utmp == UINT64_MAX || utmp < 0 || *endptr) {
-               mxmlDelete(tree);
-               return -1;
-       }
-       c->packets = utmp;
+
        c->flags |= (1 << NFT_CHAIN_ATTR_PACKETS);
 
        /* Get and set <type> */
@@ -724,13 +712,7 @@ static int nft_chain_xml_parse(struct nft_chain *c, char *xml)
        c->flags |= (1 << NFT_CHAIN_ATTR_POLICY);
 
        /* Get and set <family> */
-       node = mxmlFindElement(tree, tree, "family", NULL, NULL, MXML_DESCEND);
-       if (node == NULL) {
-               mxmlDelete(tree);
-               return -1;
-       }
-
-       family = nft_str2family(node->child->value.opaque);
+       family = nft_mxml_family_parse(tree, "family", MXML_DESCEND_FIRST);
        if (family < 0) {
                mxmlDelete(tree);
                return -1;
@@ -810,11 +792,11 @@ static int nft_chain_snprintf_xml(char *buf, size_t size, struct nft_chain *c)
 {
        int ret, len = size, offset = 0;
 
-       ret = snprintf(buf, size,
-                      "<chain name=\"%s\" handle=\"%"PRIu64"\""
-                      " bytes=\"%"PRIu64"\" packets=\"%"PRIu64"\">"
-                      "<type>%s</type><table>%s</table><prio>%d</prio>"
-                      "<use>%d</use><hooknum>%s</hooknum>",
+       ret = snprintf(buf, size, "<chain><name>%s</name>"
+                      "<handle>%"PRIu64"</handle><bytes>%"PRIu64"</bytes>"
+                      "<packets>%"PRIu64"</packets><type>%s</type>"
+                      "<table>%s</table><prio>%d</prio><use>%d</use>"
+                      "<hooknum>%s</hooknum>",
                       c->name, c->handle, c->bytes, c->packets,
                       c->type, c->table,
                       c->prio, c->use, hooknum2str_array[c->hooknum]);
index 7446258eb26ab80289a583cddb86f233e0ab2c7c..4b7ec279493e248e86c1cc2ac9c2a09f1aec4834 100644 (file)
@@ -188,7 +188,7 @@ static int nft_rule_expr_nat_xml_parse(struct nft_rule_expr *e, mxml_node_t *tre
 {
 #ifdef XML_PARSING
        struct nft_expr_nat *nat = nft_expr_data(e);
-       const char *nat_type, *family_str;
+       const char *nat_type;
        int32_t reg;
        int family;
 
@@ -205,13 +205,11 @@ static int nft_rule_expr_nat_xml_parse(struct nft_rule_expr *e, mxml_node_t *tre
 
        e->flags |= (1 << NFT_EXPR_NAT_TYPE);
 
-       family_str = nft_mxml_str_parse(tree, "family", MXML_DESCEND_FIRST);
-       if (family_str == NULL)
-               return -1;
-
-       family = nft_str2family(family_str);
-       if (family < 0)
+       family = nft_mxml_family_parse(tree, "family", MXML_DESCEND_FIRST);
+       if (family < 0) {
+               mxmlDelete(tree);
                return -1;
+       }
 
        nat->family = family;
        e->flags |= (1 << NFT_EXPR_NAT_FAMILY);
index 8d11acfc87cc1a61801400e2b251e98e987facd7..1ebdb1afde332c4dc0f5d00127bea111fcd7b575 100644 (file)
@@ -36,6 +36,7 @@ union nft_data_reg;
 int nft_mxml_data_reg_parse(mxml_node_t *tree, const char *node_name, union nft_data_reg *data_reg);
 int nft_mxml_num_parse(mxml_node_t *tree, const char *node_name, uint32_t mxml_flags, int base, void *number, enum nft_type type);
 const char *nft_mxml_str_parse(mxml_node_t *tree, const char *node_name, uint32_t mxml_flags);
+int nft_mxml_family_parse(mxml_node_t *tree, const char *node_name, uint32_t mxml_flags);
 struct nft_set_elem *nft_mxml_set_elem_parse(mxml_node_t *node);
 #endif
 
index ed1134f05b5f8a50156083efd93d5c2b549f7b7c..1f0a2df9f1e6f083052f4956ad6d02c4814669a3 100644 (file)
@@ -166,6 +166,25 @@ const char *nft_mxml_str_parse(mxml_node_t *tree, const char *node_name,
        return strdup(node->child->value.opaque);
 }
 
+int nft_mxml_family_parse(mxml_node_t *tree, const char *node_name,
+                         uint32_t mxml_flags)
+{
+       const char *family_str;
+       int family;
+
+       family_str = nft_mxml_str_parse(tree, node_name, mxml_flags);
+       if (family_str == NULL)
+               return -1;
+
+       family = nft_str2family(family_str);
+       xfree(family_str);
+
+       if (family < 0)
+               errno = EAFNOSUPPORT;
+
+       return family;
+}
+
 struct nft_set_elem *nft_mxml_set_elem_parse(mxml_node_t *node)
 {
        mxml_node_t *save;
index 3e9ca89b5c30cd87f6cc0cdc9c68aca241944983..a315cca8a343627ef1ae9654f07fcd2373cac186 100644 (file)
@@ -477,8 +477,8 @@ static int nft_rule_xml_parse(struct nft_rule *r, char *xml)
        mxml_node_t *node = NULL;
        mxml_node_t *save = NULL;
        struct nft_rule_expr *e;
-       char *endptr = NULL;
-       uint64_t tmp;
+       const char *table;
+       const char *chain;
        int family;
 
        /* Load the tree */
@@ -486,13 +486,12 @@ static int nft_rule_xml_parse(struct nft_rule *r, char *xml)
        if (tree == NULL)
                return -1;
 
-       /* get and set <rule ... family=X ... > */
-       if (mxmlElementGetAttr(tree, "family") == NULL) {
+       if (strcmp(tree->value.opaque, "rule") != 0) {
                mxmlDelete(tree);
                return -1;
        }
 
-       family = nft_str2family(mxmlElementGetAttr(tree, "family"));
+       family = nft_mxml_family_parse(tree, "family", MXML_DESCEND_FIRST);
        if (family < 0) {
                mxmlDelete(tree);
                return -1;
@@ -501,8 +500,8 @@ static int nft_rule_xml_parse(struct nft_rule *r, char *xml)
        r->family = family;
        r->flags |= (1 << NFT_RULE_ATTR_FAMILY);
 
-       /* get and set <rule ... table=X ...> */
-       if (mxmlElementGetAttr(tree, "table") == NULL) {
+       table = nft_mxml_str_parse(tree, "table", MXML_DESCEND_FIRST);
+       if (table == NULL) {
                mxmlDelete(tree);
                return -1;
        }
@@ -510,11 +509,11 @@ static int nft_rule_xml_parse(struct nft_rule *r, char *xml)
        if (r->table)
                xfree(r->table);
 
-       r->table = strdup(mxmlElementGetAttr(tree, "table"));
+       r->table = (char *)table;
        r->flags |= (1 << NFT_RULE_ATTR_TABLE);
 
-       /* get and set <rule ... chain=X ...> */
-       if (mxmlElementGetAttr(tree, "chain") == NULL) {
+       chain = nft_mxml_str_parse(tree, "chain", MXML_DESCEND_FIRST);
+       if (chain == NULL) {
                mxmlDelete(tree);
                return -1;
        }
@@ -522,21 +521,15 @@ static int nft_rule_xml_parse(struct nft_rule *r, char *xml)
        if (r->chain)
                xfree(r->chain);
 
-       r->chain = strdup(mxmlElementGetAttr(tree, "chain"));
+       r->chain = (char *)chain;
        r->flags |= (1 << NFT_RULE_ATTR_CHAIN);
 
-       /* get and set <rule ... handle=X ...> */
-       if (mxmlElementGetAttr(tree, "handle") == NULL) {
-               mxmlDelete(tree);
-               return -1;
-       }
-       tmp = strtoull(mxmlElementGetAttr(tree, "handle"), &endptr, 10);
-       if (tmp == UINT64_MAX || tmp < 0 || *endptr) {
+       if (nft_mxml_num_parse(tree, "handle", MXML_DESCEND_FIRST, BASE_DEC,
+                              &r->handle, NFT_TYPE_U64) != 0) {
                mxmlDelete(tree);
                return -1;
        }
 
-       r->handle = tmp;
        r->flags |= (1 << NFT_RULE_ATTR_HANDLE);
 
        /* get and set <rule_flags> */
@@ -551,28 +544,26 @@ static int nft_rule_xml_parse(struct nft_rule *r, char *xml)
        /* <compat_proto> is optional */
        node = mxmlFindElement(tree, tree, "compat_proto", NULL, NULL,
                               MXML_DESCEND);
-       if (node != NULL) {
-               tmp = strtoull(node->child->value.opaque, &endptr, 10);
-               if (tmp > UINT32_MAX || tmp < 0 || *endptr) {
+       if (node != NULL && node->child != NULL) {
+               if (nft_strtoi(node->child->value.opaque, BASE_DEC,
+                              &r->compat.proto, NFT_TYPE_U32) != 0) {
                        mxmlDelete(tree);
                        return -1;
                }
 
-               r->compat.proto = tmp;
                r->flags |= (1 << NFT_RULE_ATTR_COMPAT_PROTO);
        }
 
        /* <compat_flags> is optional */
        node = mxmlFindElement(tree, tree, "compat_flags", NULL, NULL,
                               MXML_DESCEND);
-       if (node != NULL) {
-               tmp = strtoull(node->child->value.opaque, &endptr, 10);
-               if (tmp > UINT32_MAX || tmp < 0 || *endptr) {
+       if (node != NULL && node->child != NULL) {
+               if (nft_strtoi(node->child->value.opaque, BASE_DEC,
+                              &r->compat.flags, NFT_TYPE_U32) != 0) {
                        mxmlDelete(tree);
                        return -1;
                }
 
-               r->compat.flags = tmp;
                r->flags |= (1 << NFT_RULE_ATTR_COMPAT_FLAGS);
        }
 
@@ -676,11 +667,11 @@ static int nft_rule_snprintf_xml(char *buf, size_t size, struct nft_rule *r,
        int ret, len = size, offset = 0;
        struct nft_rule_expr *expr;
 
-       ret = snprintf(buf, size,
-               "<rule family=\"%s\" table=\"%s\" "
-                       "chain=\"%s\" handle=\"%llu\">",
-                               nft_family2str(r->family), r->table, r->chain,
-                               (unsigned long long)r->handle);
+       ret = snprintf(buf, size, "<rule><family>%s</family>"
+                      "<table>%s</table><chain>%s</chain>"
+                      "<handle>%llu</handle>",
+                      nft_family2str(r->family), r->table, r->chain,
+                      (unsigned long long)r->handle);
        SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
 
        ret = snprintf(buf+offset, len, "<rule_flags>%u</rule_flags>",
index 6875dd71aacb88b7dade387c9f479a52f5ed7540..bb66717be405504e95caed39e45392d274a182df 100644 (file)
@@ -222,7 +222,7 @@ 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;
+       const char *name;
        int family;
 
        /* NOTE: all XML nodes are mandatory */
@@ -232,8 +232,13 @@ static int nft_table_xml_parse(struct nft_table *t, char *xml)
        if (tree == NULL)
                return -1;
 
-       /* Get and set the name of the table */
-       if (mxmlElementGetAttr(tree, "name") == NULL) {
+       if (strcmp(tree->value.opaque, "table") != 0) {
+               mxmlDelete(tree);
+               return -1;
+       }
+
+       name = nft_mxml_str_parse(tree, "name", MXML_DESCEND_FIRST);
+       if (name == NULL) {
                mxmlDelete(tree);
                return -1;
        }
@@ -241,18 +246,10 @@ static int nft_table_xml_parse(struct nft_table *t, char *xml)
        if (t->name)
                xfree(t->name);
 
-       t->name = strdup(mxmlElementGetAttr(tree, "name"));
+       t->name = name;
        t->flags |= (1 << NFT_TABLE_ATTR_NAME);
 
-       /* Get the and set <family> node */
-       node = mxmlFindElement(tree, tree, "family", NULL, NULL,
-                              MXML_DESCEND_FIRST);
-       if (node == NULL) {
-               mxmlDelete(tree);
-               return -1;
-       }
-
-       family = nft_str2family(node->child->value.opaque);
+       family = nft_mxml_family_parse(tree, "family", MXML_DESCEND_FIRST);
        if (family < 0) {
                mxmlDelete(tree);
                return -1;
@@ -261,7 +258,6 @@ static int nft_table_xml_parse(struct nft_table *t, char *xml)
        t->family = family;
        t->flags |= (1 << NFT_TABLE_ATTR_FAMILY);
 
-       /* Get and set <table_flags> */
        if (nft_mxml_num_parse(tree, "table_flags", MXML_DESCEND, BASE_DEC,
                               &t->table_flags, NFT_TYPE_U32) != 0) {
                mxmlDelete(tree);
@@ -360,7 +356,7 @@ static int nft_table_snprintf_json(char *buf, size_t size, struct nft_table *t)
 
 static int nft_table_snprintf_xml(char *buf, size_t size, struct nft_table *t)
 {
-       return snprintf(buf, size, "<table name=\"%s\"><family>%s</family>"
+       return snprintf(buf, size, "<table><name>%s</name><family>%s</family>"
                        "<table_flags>%d</table_flags></table>",
                        t->name, nft_family2str(t->family), t->table_flags);
 }
index 2e333547fd255ecf8b7772737d5148d1d0cdf80a..2aa64927b9d415c45dcdbe2327d70e48e000f8dd 100644 (file)
@@ -1,4 +1,5 @@
-<table name="filter">
+<table>
+       <name>filter</name>
        <family>ip</family>
        <table_flags>0</table_flags>
 </table>
index 27d02083e255565be7cc014b6ff0d2ce39c9b307..fa18d328e6168438bbaf9839b91948943603b48b 100644 (file)
@@ -1,4 +1,5 @@
-<table name="nat">
+<table>
+       <name>nat</name>
        <family>ip6</family>
        <table_flags>0</table_flags>
 </table>
index 6d1875e5f7f15ef3d7ca96cf7ca6bb2c59d59a32..014a9157431e5bfd6eb1e6d9595f3e352873a4a8 100644 (file)
@@ -1,4 +1,8 @@
-<chain name="test" handle="0" bytes="0" packets="0">
+<chain>
+       <name>test</name>
+       <handle>0</handle>
+       <bytes>0</bytes>
+       <packets>0</packets>
        <type>filter</type>
        <table>filter</table>
        <prio>0</prio>
index 986cd81379ab421e1f7befb387555df2bfcb5874..ea6aa19410aba1cbecb516c7e373a6a105f6d30b 100644 (file)
@@ -1,4 +1,8 @@
-<chain name="test" handle="0" bytes="59" packets="1">
+<chain>
+       <name>test</name>
+       <handle>0</handle>
+       <bytes>59</bytes>
+       <packets>1</packets>
        <type>filter</type>
        <table>filter</table>
        <prio>0</prio>
index 23fef8c3e9c25294459eac9d3536565354466f20..7f03ace7d078123630c028f65c09a464000d1c9d 100644 (file)
@@ -1,4 +1,8 @@
-<chain name="foo" handle="100" bytes="59264154979" packets="2548796325">
+<chain>
+       <name>foo</name>
+       <handle>100</handle>
+       <bytes>59264154979</bytes>
+       <packets>2548796325</packets>
        <type>nat</type>
        <table>nat</table>
        <prio>0</prio>
index 616bb03749239919a24ac12a4dffcd88b71eed9e..86b2c6a3ff810dac06fd3e285643a3017e64e8be 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip" table="filter" chain="INPUT" handle="100">
+<rule>
+       <family>ip</family>
+       <table>filter</table>
+       <chain>INPUT</chain>
+       <handle>100</handle>
        <rule_flags>0</rule_flags>
        <expr type="bitwise">
                <sreg>1</sreg>
index c83fe229e3c4979e6e11cfa409966632da060887..b19380c3c91d0bd42642051aa68fa32025b08efc 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip" table="test" chain="test" handle="1000">
+<rule>
+       <family>ip</family>
+       <table>test</table>
+       <chain>test</chain>
+       <handle>1000</handle>
        <rule_flags>0</rule_flags>
        <expr type="byteorder">
                <sreg>3</sreg>
index 1ad90cb41a636f8a72838733c8a0708257d101ee..aae6de9291a16ebc4b80f2e902be7c8365d00031 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip6" table="filter" chain="test" handle="36">
+<rule>
+       <family>ip6</family>
+       <table>filter</table>
+       <chain>test</chain>
+       <handle>36</handle>
        <rule_flags>0</rule_flags>
        <expr type="cmp">
                <sreg>1</sreg>
index 15f2e51b6ee19754353c8704448b78ff2c195e53..0c56f4ab330b6b7caf3e074135509bb87cca30ef 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip6" table="filter" chain="test" handle="39">
+<rule>
+       <family>ip6</family>
+       <table>filter</table>
+       <chain>test</chain>
+       <handle>39</handle>
        <rule_flags>0</rule_flags>
        <expr type="counter">
                <pkts>3</pkts>
index 9a534c556ea73532c26e262ac61679580cb0f2ec..f4d52c13dd6a540cd766fdcdaf8c5c148efad975 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip" table="filter" chain="INPUT" handle="100">
+<rule>
+       <family>ip</family>
+       <table>filter</table>
+       <chain>INPUT</chain>
+       <handle>100</handle>
        <rule_flags>0</rule_flags>
        <expr type="ct">
                <dreg>1</dreg>
index f4c44f022f3af0388023ba18bc00eba66007b5ea..a29e857fb102b10349b372e83b74b264a6bd73df 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip6" table="filter" chain="INPUT" handle="100">
+<rule>
+       <family>ip6</family>
+       <table>filter</table>
+       <chain>INPUT</chain>
+       <handle>100</handle>
        <rule_flags>0</rule_flags>
        <expr type="exthdr">
                <dreg>1</dreg>
index 322e49f802bbc766f824603c6c816ce83a3f1c58..dee0e7a6b5e656aba782d88c1cac9bad761a6837 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip" table="filter" chain="input" handle="32">
+<rule>
+       <family>ip</family>
+       <table>filter</table>
+       <chain>input</chain>
+       <handle>32</handle>
        <rule_flags>0</rule_flags>
        <expr type="immediate">
                <dreg>0</dreg>
index 7fa6963058d213d57888485e132039f0c0bd345f..75964296af9e2ad04ad82d39ee8b4813911aa11d 100644 (file)
@@ -1,7 +1,11 @@
-<rule family="ip" table="filter" chain="INPUT" handle="100">
-  <rule_flags>0</rule_flags>
-  <expr type="limit">
-    <rate>123123</rate>
-    <depth>321321</depth>
-  </expr>
+<rule>
+       <family>ip</family>
+       <table>filter</table>
+       <chain>INPUT</chain>
+       <handle>100</handle>
+       <rule_flags>0</rule_flags>
+       <expr type="limit">
+               <rate>123123</rate>
+               <depth>321321</depth>
+       </expr>
 </rule>
index b0016100e090f48c52f80395c7c03f57be8eb0ab..976b29c7491bd8bda8f322bd484443960da43804 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip6" table="filter" chain="test" handle="96">
+<rule>
+       <family>ip6</family>
+       <table>filter</table>
+       <chain>test</chain>
+       <handle>96</handle>
        <rule_flags>0</rule_flags>
        <expr type="log">
                <prefix>test_chain</prefix>
index 50f9340737aa32a8d495cf5bd7f4a3e7206fe225..0df770989991facbfe4c3b3e52a7741c953371e4 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip6" table="filter" chain="test" handle="37">
+<rule>
+       <family>ip6</family>
+       <table>filter</table>
+       <chain>test</chain>
+       <handle>37</handle>
        <rule_flags>0</rule_flags>
        <expr type="lookup">
                <set>set0</set>
index 99d53f746a107cfc8c06e609654ca5fbc4b46188..817b88fa8124f09635afb099687cf4b278fda642 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip" table="filter" chain="INPUT" handle="100">
+<rule>
+       <family>ip</family>
+       <table>filter</table>
+       <chain>INPUT</chain>
+       <handle>100</handle>
        <rule_flags>0</rule_flags>
        <expr type="match">
                <name>state</name>
index 2ffb7c5ae894dd049f495efd6bfe9ed49ad73d13..1bce08b14121dfc9ca04221e429677b365fef3eb 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip6" table="filter" chain="test" handle="36">
+<rule>
+       <family>ip6</family>
+       <table>filter</table>
+       <chain>test</chain>
+       <handle>36</handle>
        <rule_flags>0</rule_flags>
        <expr type="meta">
                <dreg>1</dreg>
index 108722a51edd70061286b135f13c358a9edcf4f4..a80b4d40f13610899865e534576315556f451684 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip6" table="nat" chain="OUTPUT" handle="100">
+<rule>
+       <family>ip6</family>
+       <table>nat</table>
+       <chain>OUTPUT</chain>
+       <handle>100</handle>
        <rule_flags>0</rule_flags>
        <expr type="nat">
                <family>ip6</family>
index 1729b9fc5b2480cb298b4c3f7d536d353dbe5f7a..05933aff40b4c4e504983592b41572c1bdb17296 100644 (file)
@@ -1,11 +1,15 @@
-<rule family="ip" table="filter" chain="INPUT" handle="100">
-  <rule_flags>0</rule_flags>
-  <expr type="nat">
-    <sreg_addr_min>1</sreg_addr_min>
-    <sreg_addr_max>2</sreg_addr_max>
-    <sreg_proto_min>3</sreg_proto_min>
-    <sreg_proto_max>4</sreg_proto_max>
-    <family>ip</family>
-    <nat_type>dnat</nat_type>
-  </expr>
+<rule>
+       <family>ip</family>
+       <table>filter</table>
+       <chain>INPUT</chain>
+       <handle>100</handle>
+       <rule_flags>0</rule_flags>
+       <expr type="nat">
+               <sreg_addr_min>1</sreg_addr_min>
+               <sreg_addr_max>2</sreg_addr_max>
+               <sreg_proto_min>3</sreg_proto_min>
+               <sreg_proto_max>4</sreg_proto_max>
+               <family>ip</family>
+               <nat_type>dnat</nat_type>
+       </expr>
 </rule>
index 0920c6527c803be880ca7e799f70f0c4a22b52d7..bd344cc513bab864bd4206bc5ed5963a8b6bb7b2 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip6" table="filter" chain="test" handle="34">
+<rule>
+       <family>ip6</family>
+       <table>filter</table>
+       <chain>test</chain>
+       <handle>34</handle>
        <rule_flags>0</rule_flags>
        <expr type="payload">
                <dreg>1</dreg>
index 8fce3b58e61cb817ef7e1bb7a99c233cb08bd577..914bb9a54a56cc7e3f0089bffb1d0aa0c40981c1 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip" table="filter" chain="INPUT" handle="100">
+<rule>
+       <family>ip</family>
+       <table>filter</table>
+       <chain>INPUT</chain>
+       <handle>100</handle>
        <rule_flags>0</rule_flags>
        <expr type="target">
                <name>LOG</name>
index 352027a269acc4177ef09f7d4b7a06a0a525580d..5ba79b7c40c8d9617d656ae1e76b191b8e08745d 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip" table="filter" chain="output" handle="22">
+<rule>
+       <family>ip</family>
+       <table>filter</table>
+       <chain>output</chain>
+       <handle>22</handle>
        <rule_flags>0</rule_flags>
        <expr type="payload">
                <dreg>1</dreg>
index a4ced2c4a7a495d79d0ca9305fb709813e1a4eea..42ea43a9d20a3467bfa5b087935217b207ed9352 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip" table="filter" chain="INPUT" handle="25">
+<rule>
+       <family>ip</family>
+       <table>filter</table>
+       <chain>INPUT</chain>
+       <handle>25</handle>
        <rule_flags>0</rule_flags>
        <expr type="meta">
                <dreg>1</dreg>
index d48547c63e67791771ef6bd9ae308c1b1f541415..08de9d3851e871fc1588d0620189b08c5e478bef 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip" table="filter" chain="INPUT" handle="30">
+<rule>
+       <family>ip</family>
+       <table>filter</table>
+       <chain>INPUT</chain>
+       <handle>30</handle>
        <rule_flags>0</rule_flags>
        <expr type="payload">
                <dreg>1</dreg>
index 8e8b77fb6fc2240bdbd568b210c224d9e695ce51..de1692c019c654850fc2bfc4447a1aad761d8ed1 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip6" table="filter" chain="test" handle="31">
+<rule>
+       <family>ip6</family>
+       <table>filter</table>
+       <chain>test</chain>
+       <handle>31</handle>
        <rule_flags>0</rule_flags>
        <expr type="meta">
                <dreg>1</dreg>
index 00a333df8e61f76bf0b57b8be682da0cdf895b88..944b1bd0ef892dd56d9d1e39b3aef09587bd4382 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip" table="filter" chain="output" handle="2">
+<rule>
+       <family>ip</family>
+       <table>filter</table>
+       <chain>output</chain>
+       <handle>2</handle>
        <rule_flags>0</rule_flags>
        <expr type="payload">
                <dreg>1</dreg>
index 58c13d0c9631752ab2678d7f89522747a44f4b14..de951f8d9c1c38d53acc6a43cc2bb2ad23a33c7e 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip" table="filter" chain="output" handle="3">
+<rule>
+       <family>ip</family>
+       <table>filter</table>
+       <chain>output</chain>
+       <handle>3</handle>
        <rule_flags>0</rule_flags>
        <expr type="payload">
                <dreg>1</dreg>
index 298181cb339da21cd7522aacfbc77c14ddde79c5..d528a38cf45c4c858a90e6d40dfd00fb3f6ca2e0 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip" table="filter" chain="output" handle="4">
+<rule>
+       <family>ip</family>
+       <table>filter</table>
+       <chain>output</chain>
+       <handle>4</handle>
        <rule_flags>0</rule_flags>
        <expr type="payload">
                <dreg>1</dreg>
index b814e554982d2bb448b881bc7f91ca213336f915..0e6381c528059b993a2d99b9cad200250c95e094 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip" table="filter" chain="output" handle="5">
+<rule>
+       <family>ip</family>
+       <table>filter</table>
+       <chain>output</chain>
+       <handle>5</handle>
        <rule_flags>0</rule_flags>
        <expr type="payload">
                <dreg>1</dreg>
index 7be57051564d31e71312579e4cc9aee8fca2accd..a9fc698ae3d7f5832ba4642e7b1de42074a91853 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip" table="filter" chain="output" handle="6">
+<rule>
+       <family>ip</family>
+       <table>filter</table>
+       <chain>output</chain>
+       <handle>6</handle>
        <rule_flags>0</rule_flags>
        <expr type="payload">
                <dreg>1</dreg>
index d1cab480041b8f2a1cf77e5cfe738feaec327cb4..ed4645db7d212de261cf330cdc6c935b4f55461b 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip" table="filter" chain="output" handle="7">
+<rule>
+       <family>ip</family>
+       <table>filter</table>
+       <chain>output</chain>
+       <handle>7</handle>
        <rule_flags>0</rule_flags>
        <expr type="payload">
                <dreg>1</dreg>
index e87194f2fc4931a4558becb63d95b31320e7d118..56cb088e187434c5c4fb59bbd8cc68c525635391 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip" table="filter" chain="output" handle="8">
+<rule>
+       <family>ip</family>
+       <table>filter</table>
+       <chain>output</chain>
+       <handle>8</handle>
        <rule_flags>0</rule_flags>
        <expr type="payload">
                <dreg>1</dreg>
index c15edc04e456b7a2d2be31d3b86b13c7595d35d1..2ec3e19d7cc7a80fe4de8632d70026c2f9ec2ad2 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip" table="filter" chain="output" handle="9">
+<rule>
+       <family>ip</family>
+       <table>filter</table>
+       <chain>output</chain>
+       <handle>9</handle>
        <rule_flags>0</rule_flags>
        <expr type="payload">
                <dreg>1</dreg>
index 097f60250f2c9ae2f3147a2b86ac8a03c706f365..36ca11b125690430bcbef0c028a6f2808fda0034 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip" table="filter" chain="output" handle="10">
+<rule>
+       <family>ip</family>
+       <table>filter</table>
+       <chain>output</chain>
+       <handle>10</handle>
        <rule_flags>0</rule_flags>
        <expr type="payload">
                <dreg>1</dreg>
index 32cc6238addaf6a22617f8de593a0f66b855c091..ef968ac43cd38ed78de4f8f4d4e4bc9679fe733d 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip" table="filter" chain="output" handle="11">
+<rule>
+       <family>ip</family>
+       <table>filter</table>
+       <chain>output</chain>
+       <handle>11</handle>
        <rule_flags>0</rule_flags>
        <expr type="payload">
                <dreg>1</dreg>
index 6800d19ea46dee04a398ec8ffe47b720802d081b..5b4bb2f7a2191ca636c672caf37df16ad05de9db 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip" table="filter" chain="output" handle="12">
+<rule>
+       <family>ip</family>
+       <table>filter</table>
+       <chain>output</chain>
+       <handle>12</handle>
        <rule_flags>0</rule_flags>
        <expr type="ct">
                <dreg>1</dreg>
index a77d5d987c28ea039ff5630804a28fc177634151..1e5a46c9f76aee873a239abe89ba59ea1b21affc 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip" table="filter" chain="output" handle="13">
+<rule>
+       <family>ip</family>
+       <table>filter</table>
+       <chain>output</chain>
+       <handle>13</handle>
        <rule_flags>0</rule_flags>
        <expr type="ct">
                <dreg>1</dreg>
index 289a6eb3d4cdd5ecb6db006745448baa25c32ae6..6cb3a0e86045f618934db27d5eb02c266773f01f 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip" table="filter" chain="output" handle="14">
+<rule>
+       <family>ip</family>
+       <table>filter</table>
+       <chain>output</chain>
+       <handle>14</handle>
        <rule_flags>0</rule_flags>
        <expr type="ct">
                <dreg>1</dreg>
index ba1ba42a98efba23bcfe2e3be12cb0d8148203c6..1be6c89f1e5bcc0ab9b549b4f197d28bd37a4e26 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip" table="filter" chain="output" handle="15">
+<rule>
+       <family>ip</family>
+       <table>filter</table>
+       <chain>output</chain>
+       <handle>15</handle>
        <rule_flags>0</rule_flags>
        <expr type="ct">
                <dreg>1</dreg>
index bcb81b7514c7b555732ee2c2b4da5bf549ade4cf..caf9ebe5790765e177763b4b04c38ee70c63af3b 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip" table="filter" chain="output" handle="16">
+<rule>
+       <family>ip</family>
+       <table>filter</table>
+       <chain>output</chain>
+       <handle>16</handle>
        <rule_flags>0</rule_flags>
        <expr type="ct">
                <dreg>1</dreg>
index fd9849583a0b10f7dcbc98d29f78d9338df46778..f452e503180593f757cd5e5dda292c516cc9af2e 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip" table="filter" chain="output" handle="17">
+<rule>
+       <family>ip</family>
+       <table>filter</table>
+       <chain>output</chain>
+       <handle>17</handle>
        <rule_flags>0</rule_flags>
        <expr type="ct">
                <dreg>1</dreg>
index cfffce8cbf6c06a36ff145b05a1d5a57360bcc27..317580376499b7fb8da0dd40f9dbe625477b5b60 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip" table="filter" chain="output" handle="18">
+<rule>
+       <family>ip</family>
+       <table>filter</table>
+       <chain>output</chain>
+       <handle>18</handle>
        <rule_flags>0</rule_flags>
        <expr type="ct">
                <dreg>1</dreg>
index 667449676420e249d6e6d13ddfcfddfc410765d2..9c63ed446761b36c1cd4dba6ed19de88095e7432 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip" table="filter" chain="output" handle="19">
+<rule>
+       <family>ip</family>
+       <table>filter</table>
+       <chain>output</chain>
+       <handle>19</handle>
        <rule_flags>0</rule_flags>
        <expr type="ct">
                <dreg>1</dreg>
index f7adb9c85de314f9313f62a48e11944cbd617ee3..0ba27a81821bbb09418f2489442822ece92f6c01 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip" table="filter" chain="output" handle="20">
+<rule>
+       <family>ip</family>
+       <table>filter</table>
+       <chain>output</chain>
+       <handle>20</handle>
        <rule_flags>0</rule_flags>
        <expr type="meta">
                <dreg>1</dreg>
index 88442a1970ed033973024011889abea6797012e5..1305516e300646da387e793bc62f716c8750fce9 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip" table="filter" chain="output" handle="21">
+<rule>
+       <family>ip</family>
+       <table>filter</table>
+       <chain>output</chain>
+       <handle>21</handle>
        <rule_flags>0</rule_flags>
        <expr type="meta">
                <dreg>1</dreg>
index 2cfbec76b450dd1d5edc9a81a33bef17502c04b3..d7db20624836cad9b3c41943c639de4e91e2257e 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip" table="filter" chain="output" handle="22">
+<rule>
+       <family>ip</family>
+       <table>filter</table>
+       <chain>output</chain>
+       <handle>22</handle>
        <rule_flags>0</rule_flags>
        <expr type="meta">
                <dreg>1</dreg>
index 0b7e8a3c14e17433fec4012f9ab00ce97afe4286..0d2196885dcf5e9f54d78d481a46623792af54e7 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip" table="filter" chain="output" handle="23">
+<rule>
+       <family>ip</family>
+       <table>filter</table>
+       <chain>output</chain>
+       <handle>23</handle>
        <rule_flags>0</rule_flags>
        <expr type="meta">
                <dreg>1</dreg>
index 6ef30559b4714a58396b08dc995aaa6d451e1cf0..7f2aba2a01bded955fcbdc3481e3406f702ddd66 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip" table="filter" chain="output" handle="24">
+<rule>
+       <family>ip</family>
+       <table>filter</table>
+       <chain>output</chain>
+       <handle>24</handle>
        <rule_flags>0</rule_flags>
        <expr type="meta">
                <dreg>1</dreg>
index 69933f28c4391af84b6ca8fb9a1de2400874f735..e632d510c15e9701f5dbe4aa12260e34aa9c3c44 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip" table="filter" chain="output" handle="25">
+<rule>
+       <family>ip</family>
+       <table>filter</table>
+       <chain>output</chain>
+       <handle>25</handle>
        <rule_flags>0</rule_flags>
        <expr type="meta">
                <dreg>1</dreg>
index 10db311f0defc39e9af9878acae9581be9aed738..9e111320538bc393884dccc3931d1c06dab89f36 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip" table="filter" chain="output" handle="26">
+<rule>
+       <family>ip</family>
+       <table>filter</table>
+       <chain>output</chain>
+       <handle>26</handle>
        <rule_flags>0</rule_flags>
        <expr type="meta">
                <dreg>1</dreg>
index b88f81a0e103dcc1e1c88584c04ef0e03333a64f..3cbdd1371b77538722ab0130ecda3d97eb20fc23 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip" table="filter" chain="output" handle="27">
+<rule>
+       <family>ip</family>
+       <table>filter</table>
+       <chain>output</chain>
+       <handle>27</handle>
        <rule_flags>0</rule_flags>
        <expr type="meta">
                <dreg>1</dreg>
index f0bf768c40fbf484b63fb9e8ad92a3e51c0e1da8..47900651349157825596c476da665e77ba38cceb 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip" table="filter" chain="output" handle="28">
+<rule>
+       <family>ip</family>
+       <table>filter</table>
+       <chain>output</chain>
+       <handle>28</handle>
        <rule_flags>0</rule_flags>
        <expr type="meta">
                <dreg>1</dreg>
index 82d1310a3a9a0152bcc64f88832b63b06fd5dd80..c3413e27069d675edd3fbdaef6d69e856f6ccc6e 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip" table="filter" chain="output" handle="29">
+<rule>
+       <family>ip</family>
+       <table>filter</table>
+       <chain>output</chain>
+       <handle>29</handle>
        <rule_flags>0</rule_flags>
        <expr type="meta">
                <dreg>1</dreg>
index f53818565a1c45884f2461c9a9bbec82be435028..a63a51c6c69060353744aee82394f598e2ae3752 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip" table="filter" chain="output" handle="32">
+<rule>
+       <family>ip</family>
+       <table>filter</table>
+       <chain>output</chain>
+       <handle>32</handle>
        <rule_flags>0</rule_flags>
        <expr type="payload">
                <dreg>1</dreg>
index bfa4efed3ee1fb78d57a8ceec4d1d4f61a5dd5bc..02baab42e3296bd13f4cc3059c0428a11d767bc1 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip" table="filter" chain="output" handle="33">
+<rule>
+       <family>ip</family>
+       <table>filter</table>
+       <chain>output</chain>
+       <handle>33</handle>
        <rule_flags>0</rule_flags>
        <expr type="payload">
                <dreg>1</dreg>
index 8f157330bd0c4747d605b277cae32182b0b206b5..a459542aa9468d5e6813dc7e9c3e351f31d7a3ff 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip" table="filter" chain="output" handle="34">
+<rule>
+       <family>ip</family>
+       <table>filter</table>
+       <chain>output</chain>
+       <handle>34</handle>
        <rule_flags>0</rule_flags>
        <expr type="payload">
                <dreg>1</dreg>
index f8e199acdc7129211a709eea655b9186a60b8c61..444b9ca8830b757ae4e5ce6d2b57c818e215e718 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip" table="filter" chain="output" handle="35">
+<rule>
+       <family>ip</family>
+       <table>filter</table>
+       <chain>output</chain>
+       <handle>35</handle>
        <rule_flags>0</rule_flags>
        <expr type="payload">
                <dreg>1</dreg>
index 4b9f93b9c58fdc4366837f3ebbd1c6e56d1129f4..64b4ec6bfe85831c71bd49da0f0b2802de92783d 100644 (file)
@@ -1,4 +1,8 @@
-<rule family="ip" table="filter" chain="output" handle="36">
+<rule>
+       <family>ip</family>
+       <table>filter</table>
+       <chain>output</chain>
+       <handle>36</handle>
        <rule_flags>0</rule_flags>
        <expr type="payload">
                <dreg>1</dreg>