diff options
author | Phil Sutter <phil@nwl.cc> | 2019-06-07 19:21:19 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2019-06-07 23:54:51 +0200 |
commit | 4cbbb0a31a45860cdc365e9fba9621c24bbaf8d8 (patch) | |
tree | 3eec0c2e36df961a8939fca8e8842e27e4044085 /src | |
parent | 7a11d807058cfdc684064ad064d9ea904e4b43de (diff) |
rule: Introduce rule_lookup_by_index()
In contrast to rule_lookup(), this function returns a chain's rule at a
given index instead of by handle.
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/rule.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -641,6 +641,17 @@ struct rule *rule_lookup(const struct chain *chain, uint64_t handle) return NULL; } +struct rule *rule_lookup_by_index(const struct chain *chain, uint64_t index) +{ + struct rule *rule; + + list_for_each_entry(rule, &chain->rules, list) { + if (!--index) + return rule; + } + return NULL; +} + struct scope *scope_init(struct scope *scope, const struct scope *parent) { scope->parent = parent; |