summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/chain.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/src/chain.c b/src/chain.c
index 4f07bf8..69ea68f 100644
--- a/src/chain.c
+++ b/src/chain.c
@@ -589,7 +589,8 @@ static int nft_chain_xml_parse(struct nft_chain *c, char *xml)
mxml_node_t *node = NULL;
char *endptr = NULL;
uint64_t utmp;
- int family;
+ const char *hooknum_str;
+ int family, hooknum;
/* NOTE: all XML nodes are mandatory */
@@ -686,29 +687,24 @@ static int nft_chain_xml_parse(struct nft_chain *c, char *xml)
/* Ignore <use> (cannot be set)*/
node = mxmlFindElement(tree, tree, "use", NULL, NULL, MXML_DESCEND);
- /* Get and set <hooknum> */
- node = mxmlFindElement(tree, tree, "hooknum", NULL, NULL,
- MXML_DESCEND);
- if (node == NULL) {
+
+ hooknum_str = nft_mxml_str_parse(tree, "hooknum", MXML_DESCEND_FIRST);
+ if (hooknum_str == NULL) {
mxmlDelete(tree);
return -1;
}
- /* iterate the list of hooks until a match is found */
- for (utmp = 0; utmp < NF_INET_NUMHOOKS; utmp++) {
- if (strcmp(node->child->value.opaque, hooknum2str_array[utmp]) == 0) {
- c->hooknum = utmp;
- c->flags |= (1 << NFT_CHAIN_ATTR_HOOKNUM);
- break;
- }
- }
+ hooknum = nft_str2hooknum(hooknum_str);
+ free((char *)hooknum_str);
- /* if no hook was found, error */
- if (!(c->flags & (1 << NFT_CHAIN_ATTR_HOOKNUM))) {
+ if (hooknum < 0) {
mxmlDelete(tree);
return -1;
}
+ c->hooknum = hooknum;
+ c->flags |= (1 << NFT_CHAIN_ATTR_HOOKNUM);
+
/* Get and set <policy> */
node = mxmlFindElement(tree, tree, "policy", NULL, NULL, MXML_DESCEND);
if (node == NULL) {