summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarlos Falgueras García <carlosfg@riseup.net>2016-08-10 11:48:54 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2016-08-10 13:41:53 +0200
commit94ccd4e72d3dfff000d8212ae63f45cd950bb53b (patch)
tree81689320216a488863bb7c6823c854fc6e5eceee
parentb02d5d5b766e30a2afcbb706aa69ea7a51b40bc8 (diff)
rule: Implement internal iterator for expressions
Introduce nftnl_expr_iter_init() to allow stack allocated iterators for internal use. Signed-off-by: Carlos Falgueras García <carlosfg@riseup.net>
-rw-r--r--src/rule.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/rule.c b/src/rule.c
index 21039bb..dada00e 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -1030,6 +1030,17 @@ struct nftnl_expr_iter {
struct nftnl_expr *cur;
};
+static void nftnl_expr_iter_init(const struct nftnl_rule *r,
+ struct nftnl_expr_iter *iter)
+{
+ iter->r = r;
+ if (list_empty(&r->expr_list))
+ iter->cur = NULL;
+ else
+ iter->cur = list_entry(r->expr_list.next, struct nftnl_expr,
+ head);
+}
+
struct nftnl_expr_iter *nftnl_expr_iter_create(const struct nftnl_rule *r)
{
struct nftnl_expr_iter *iter;
@@ -1038,12 +1049,7 @@ struct nftnl_expr_iter *nftnl_expr_iter_create(const struct nftnl_rule *r)
if (iter == NULL)
return NULL;
- iter->r = r;
- if (list_empty(&r->expr_list))
- iter->cur = NULL;
- else
- iter->cur = list_entry(r->expr_list.next, struct nftnl_expr,
- head);
+ nftnl_expr_iter_init(r, iter);
return iter;
}