diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2009-12-17 01:31:13 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2009-12-17 01:31:13 +0000 |
commit | ba9cae9b9083ea6b4d1fe3d9431ceabdbea5479f (patch) | |
tree | fba99fb0e1edeb4f5464f37f504208c577e4a036 /contrib/fwd/src/fwd_xtables.c | |
parent | 47f94ba62cc7e062910446818281a8500f62ac03 (diff) |
contrib/fwd: add fwd_xt_parse_frag(), fwd_xt_append_rule() and fwd_xt_insert_rule() - completes xtables api
Diffstat (limited to 'contrib/fwd/src/fwd_xtables.c')
-rw-r--r-- | contrib/fwd/src/fwd_xtables.c | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/contrib/fwd/src/fwd_xtables.c b/contrib/fwd/src/fwd_xtables.c index 6f569fd27a..c0a3c582d8 100644 --- a/contrib/fwd/src/fwd_xtables.c +++ b/contrib/fwd/src/fwd_xtables.c @@ -82,6 +82,17 @@ struct fwd_xt_rule * fwd_xt_init_rule(struct iptc_handle *h) return NULL; } +void fwd_xt_parse_frag( + struct fwd_xt_rule *r, int frag, int inv +) { + if( frag ) + { + r->entry->ip.flags |= IPT_F_FRAG; + + if( inv ) + r->entry->ip.invflags |= IPT_INV_FRAG; + } +} void fwd_xt_parse_proto( struct fwd_xt_rule *r, struct fwd_proto *p, int inv @@ -312,7 +323,7 @@ void __fwd_xt_parse_target( } -int fwd_xt_exec_rule(struct fwd_xt_rule *r, const char *chain) +static int fwd_xt_exec_rule(struct fwd_xt_rule *r, const char *chain, int pos) { size_t s; struct xtables_rule_match *m, *next; @@ -344,7 +355,10 @@ int fwd_xt_exec_rule(struct fwd_xt_rule *r, const char *chain) memcpy(e->elems + s, r->target->t, r->target->t->u.target_size); - rv = iptc_append_entry(chain, e, r->iptc); + rv = (pos > -1) + ? iptc_insert_entry(chain, e, (unsigned int) pos, r->iptc) + : iptc_append_entry(chain, e, r->iptc) + ; } else { @@ -383,3 +397,15 @@ int fwd_xt_exec_rule(struct fwd_xt_rule *r, const char *chain) return rv; } +int fwd_xt_insert_rule( + struct fwd_xt_rule *r, const char *chain, unsigned int pos +) { + return fwd_xt_exec_rule(r, chain, pos); +} + +int fwd_xt_append_rule( + struct fwd_xt_rule *r, const char *chain +) { + return fwd_xt_exec_rule(r, chain, -1); +} + |