diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2013-07-25 21:21:51 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2013-07-25 21:31:35 +0200 |
commit | 3f994836f6bb124a5c0185ab6659ef7f57ceac5f (patch) | |
tree | 42e568f80d1d47c5e01b1367e58a494c5dfa446e /src/expr/exthdr.c | |
parent | 1c86a5f0f9df07b66691115ba4b0a9ee0f978dd6 (diff) |
src: xml: consolidate common XML code via nft_mxml_str_parse
This patch moves common XML string parsing code to nft_mxml_str_parse().
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/expr/exthdr.c')
-rw-r--r-- | src/expr/exthdr.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/expr/exthdr.c b/src/expr/exthdr.c index 769b53c..9781232 100644 --- a/src/expr/exthdr.c +++ b/src/expr/exthdr.c @@ -176,7 +176,7 @@ static const char *exthdr_type2str(uint32_t type) } } -static inline int str2exthdr_type(char *str) +static inline int str2exthdr_type(const char *str) { if (strcmp(str, "hopopts") == 0) return IPPROTO_HOPOPTS; @@ -198,7 +198,7 @@ nft_rule_expr_exthdr_xml_parse(struct nft_rule_expr *e, mxml_node_t *tree) { #ifdef XML_PARSING struct nft_expr_exthdr *exthdr = nft_expr_data(e); - mxml_node_t *node = NULL; + const char *exthdr_type; int32_t reg; int type; @@ -209,13 +209,12 @@ nft_rule_expr_exthdr_xml_parse(struct nft_rule_expr *e, mxml_node_t *tree) exthdr->dreg = reg; e->flags |= (1 << NFT_EXPR_EXTHDR_DREG); - /* Get and set <exthdr_type> */ - node = mxmlFindElement(tree, tree, "exthdr_type", NULL, NULL, - MXML_DESCEND); - if (node == NULL) + exthdr_type = nft_mxml_str_parse(tree, "exthdr_type", + MXML_DESCEND_FIRST); + if (exthdr_type == NULL) return -1; - type = str2exthdr_type(node->child->value.opaque); + type = str2exthdr_type(exthdr_type); if (type < 0) return -1; |