Thursday, May 13, 2004

Woaow I am about to append a rule...

What do you need to append a rule? It seems to be a little bit complicated. insert_rules gives the clues so lets read it...

ret = insert_rules(1, e->next_offset, e, c->end_off, offset2index(*handle, c->end_off), 0, handle);

1 : I will insert one rule
e->next_offset : size of the entry(rule) that I will insert
e : the entry that I will insert
c->end_off : c is chain_cache and chain_cache->end_off is the end_offset of the chain_cache like e->next_offset, so I guess it gives the size of the chain.
offset2index(*handle, c->end_off) : returns the position of the rule, detailed below...
0 : no prepend, not the first rule
handle : address for the table

offset2index uses entry2index which uses offset2entry.
offset2entry returns an ipt_entry by adding c->end_off to handle->entries.entrytable.
entry2index returns the position number of the rule, by using ENTRY_ITERATE(in ip_tables.h).

Next I wish to write about insert_rules internals...


Comments: Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?